2020-02-09 12:26:23 +01:00
"use strict" ;
2013-07-01 19:07:07 +02:00
/ * *
* EGroupware - Admin - Javascript UI
*
2020-02-09 12:26:23 +01:00
* @ link : https : //www.egroupware.org
2013-07-01 19:07:07 +02:00
* @ package filemanager
* @ author Ralf Becker < RalfBecker - AT - outdoor - training . de >
2020-01-29 11:08:44 +01:00
* @ copyright ( c ) 2013 - 20 by Ralf Becker < RalfBecker - AT - outdoor - training . de >
2013-07-01 19:07:07 +02:00
* @ license http : //opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* /
2020-02-09 12:26:23 +01:00
var _ _extends = ( this && this . _ _extends ) || ( function ( ) {
var extendStatics = function ( d , b ) {
extendStatics = Object . setPrototypeOf ||
( { _ _proto _ _ : [ ] } instanceof Array && function ( d , b ) { d . _ _proto _ _ = b ; } ) ||
function ( d , b ) { for ( var p in b ) if ( b . hasOwnProperty ( p ) ) d [ p ] = b [ p ] ; } ;
return extendStatics ( d , b ) ;
} ;
return function ( d , b ) {
extendStatics ( d , b ) ;
function _ _ ( ) { this . constructor = d ; }
d . prototype = b === null ? Object . create ( b ) : ( _ _ . prototype = b . prototype , new _ _ ( ) ) ;
} ;
} ) ( ) ;
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
/ * e g w : u s e s
/ a p i / j s / j s a p i / e g w _ a p p . j s
* /
require ( "jquery" ) ;
require ( "jqueryui" ) ;
require ( "../jsapi/egw_global" ) ;
require ( "../etemplate/et2_types" ) ;
var egw _app _1 = require ( "../../api/js/jsapi/egw_app" ) ;
2013-07-01 19:07:07 +02:00
/ * *
* UI for Admin
2013-11-04 21:54:23 +01:00
*
2013-07-01 19:07:07 +02:00
* @ augments AppJS
* /
2020-02-09 12:26:23 +01:00
var AdminApp = /** @class */ ( function ( _super ) {
_ _extends ( AdminApp , _super ) ;
/ * *
* Constructor
*
* @ memberOf app . classes . admin
* /
function AdminApp ( ) {
2020-04-08 20:22:24 +02:00
var _this =
// call parent
_super . call ( this , 'admin' ) || this ;
/ * *
* reference to iframe
*
* { et2 _iframe }
* /
_this . iframe = null ;
/ * *
* reference to nextmatch
*
* { et2 _extension _nextmatch }
2020-02-09 12:26:23 +01:00
* /
_this . nm = null ;
/ * *
* Reference to div to hold AJAX loadable pages
*
* { et2 _box }
* /
_this . ajax _target = null ;
/ * *
* Reference to ACL edit dialog ( not the list )
* /
_this . acl _dialog = null ;
_this . tree = null ;
/ * *
* No SSL
* /
_this . SSL _NONE = 0 ;
/ * *
* STARTTLS on regular tcp connection / port
* /
_this . SSL _STARTTLS = 1 ;
/ * *
* SSL ( inferior to TLS ! )
* /
_this . SSL _SSL = 3 ;
/ * *
* require TLS version 1 + , no SSL version 2 or 3
* /
_this . SSL _TLS = 2 ;
/ * *
* if set , verify certifcate ( currently not implemented in Horde _Imap _Client ! )
* /
_this . SSL _VERIFY = 8 ;
return _this ;
}
/ * *
* Destructor
* /
2020-02-11 17:40:17 +01:00
AdminApp . prototype . destroy = function ( _app ) {
2020-02-09 12:26:23 +01:00
this . iframe = null ;
this . nm = null ;
this . acl _dialog = null ;
this . tree = null ;
// call parent
2020-02-11 17:40:17 +01:00
_super . prototype . destroy . call ( this , _app ) ;
2020-02-09 12:26:23 +01:00
} ;
/ * *
* This function is called when the etemplate2 object is loaded
* and ready . If you must store a reference to the et2 object ,
* make sure to clean it up in destroy ( ) .
*
* @ param { etemplate2 } _et2
* @ param { string } _name name of template loaded
* /
AdminApp . prototype . et2 _ready = function ( _et2 , _name ) {
// call parent
2020-02-11 17:40:17 +01:00
_super . prototype . et2 _ready . call ( this , _et2 , _name ) ;
2020-02-09 12:26:23 +01:00
switch ( _name ) {
case 'admin.index' :
var iframe = this . iframe = this . et2 . getWidgetById ( 'iframe' ) ;
this . nm = this . et2 . getWidgetById ( 'nm' ) ;
this . groups = this . et2 . getWidgetById ( 'groups' ) ;
this . groups . set _disabled ( true ) ;
this . ajax _target = this . et2 . getWidgetById ( 'ajax_target' ) ;
this . tree = this . et2 . getWidgetById ( 'tree' ) ;
if ( iframe ) {
var self = this ;
jQuery ( iframe . getDOMNode ( ) ) . off ( 'load.admin' )
. bind ( 'load.admin' , function ( ) {
if ( this . contentDocument . location . href . match ( /(\/admin\/|\/admin\/index.php|menuaction=admin.admin_ui.index)/ ) ) {
this . contentDocument . location . href = 'about:blank' ; // stops redirect from admin/index.php
self . load ( ) ; // load own top-level index aka user-list
}
self . _hide _navbar . call ( self ) ;
} ) ;
}
if ( this . ajax _target && this . et2 . getArrayMgr ( 'content' ) . getEntry ( 'ajax_target' ) ) {
this . load ( this . et2 . getArrayMgr ( 'content' ) . getEntry ( 'ajax_target' ) ) ;
}
break ;
case 'admin.customfield_edit' :
// Load settings appropriate to currently set type
var widget = _et2 . widgetContainer . getWidgetById ( 'cf_type' ) ;
this . cf _type _change ( null , widget ) ;
break ;
case 'admin.mailaccount' :
this . account _hide _not _applying ( ) ;
break ;
case 'admin.cmds' :
var selected = this . et2 . getWidgetById ( 'nm' ) . getSelection ( ) ;
if ( selected && selected . ids . length == 1 ) {
this . cmds _onselect ( selected . ids ) ;
}
else {
this . et2 . getWidgetById ( 'splitter' ) . dock ( ) ;
}
break ;
}
} ;
/ * *
* Show given url in ( visible ) iframe or nextmatch with accounts ( ! _url )
*
* @ param { string } [ _url = ] url to show in iframe or nothing for showing
* /
AdminApp . prototype . load = function ( _url ) {
if ( this . iframe && this . iframe . getDOMNode ( ) . contentDocument . location . href
. match ( /menuaction=admin.admin_statistics.submit.+required=true/ ) && ( ! _url ||
! _url . match ( /statistics=(postpone|canceled|submitted)/ ) ) ) {
this . egw . message ( this . egw . lang ( 'Please submit (or postpone) statistic first' ) , 'info' ) ;
return ; // do not allow to leave statistics submit
}
// url outside EGroupware eg. eSyncPro linking to wikipedia
if ( _url && _url . indexOf ( this . egw . webserverUrl ) == - 1 ) {
window . open ( _url , '_blank' ) ;
return ;
}
var ajax = false ;
if ( _url ) {
// Try to load it without the iframe
ajax = _url . match ( /ajax=true/ ) && _url . match ( /menuaction=/ ) ;
if ( ajax ) {
if ( this . ajax _target . node . children . length ) {
// Node has children already? Check for loading over an
// existing etemplate, and remove it first
jQuery ( this . ajax _target . node . children ) . each ( function ( ) {
var old = etemplate2 . getById ( this . id ) ;
if ( old )
old . clear ( ) ;
} ) ;
jQuery ( this . ajax _target . node ) . empty ( ) ;
}
this . egw . json ( framework . activeApp . getMenuaction ( 'ajax_exec' , _url ) ,
// It's important that the context is null, or etemplate2
// won't load the template properly
[ _url ] , this . _ajax _load _callback , null , true , this ) . sendRequest ( ) ;
}
else {
this . iframe . set _src ( _url ) ;
}
var m = _url . match ( /menuaction=([^&]+)(?:.*appname=(\w+))?/ ) ;
if ( m && m . length >= 2 ) {
var app = m [ 2 ] ? m [ 2 ] : m [ 1 ] . split ( '.' ) [ 0 ] ;
this . tree . set _value ( '/apps/' + app + '/' + m [ 1 ] ) ;
}
}
else {
this . egw . app _header ( '' ) ;
// blank iframe, to not keep something running there
this . iframe . getDOMNode ( ) . contentDocument . location . href = 'about:blank' ;
}
this . iframe . set _disabled ( ! _url || ajax ) ;
this . nm . set _disabled ( ! ! _url || ajax ) ;
this . groups . set _disabled ( true ) ;
this . ajax _target . set _disabled ( ! ajax ) ;
} ;
/ * *
* Observer method receives update notifications from all applications
*
* App is responsible for only reacting to "messages" it is interested in !
*
* @ param { string } _msg message ( already translated ) to show , eg . 'Entry deleted'
* @ param { string } _app application name
* @ param { ( string | number ) } _id id of entry to refresh or null
* @ param { string } _type either 'update' , 'edit' , 'delete' , 'add' or null
* - update : request just modified data from given rows . Sorting is not considered ,
* so if the sort field is changed , the row will not be moved .
* - edit : rows changed , but sorting may be affected . Requires full reload .
* - delete : just delete the given rows clientside ( no server interaction neccessary )
* - add : requires full reload for proper sorting
* @ param { string } _msg _type 'error' , 'warning' or 'success' ( default )
* @ param { string } _targetapp which app ' s window should be refreshed , default current
* @ return { false | * } false to stop regular refresh , thought all observers are run
* /
AdminApp . prototype . observer = function ( _msg , _app , _id , _type , _msg _type , _targetapp ) {
switch ( _app ) {
case 'admin' :
// if iframe is used --> refresh it
var iframe _node = this . iframe ? this . iframe . getDOMNode ( ) : undefined ;
var iframe _url = iframe _node ? iframe _node . contentDocument . location . href : undefined ;
if ( _id && iframe _url != 'about:blank' ) {
var refresh _done = false ;
// Try for intelligent et2 refresh inside iframe
if ( iframe _node && iframe _node . contentWindow && iframe _node . contentWindow . etemplate2 ) {
var templates = iframe _node . contentWindow . etemplate2 . getByApplication ( 'admin' ) ;
for ( var i = 0 ; i < templates . length ; i ++ ) {
templates [ i ] . refresh ( _msg , _app , _id , _type ) ;
refresh _done = true ;
}
}
if ( ! refresh _done ) // --> reload iframe
{
this . load ( iframe _url ) ;
}
return false ; // --> no regular refresh
}
// invalidate client-side account-cache
this . egw . invalidate _account ( _id , _type ) ;
// group deleted, added or updated
if ( _id < 0 ) {
var tree = this . et2 . getWidgetById ( 'tree' ) ;
var nm = this . et2 . getWidgetById ( 'nm' ) ;
switch ( _type ) {
case 'delete' :
tree . deleteItem ( '/groups/' + _id , false ) ;
if ( nm )
nm . getInstanceManager ( ) . submit ( ) ;
break ;
default : // add, update, edit, null
if ( nm ) {
var activeFilters = nm . activeFilters ;
nm . getInstanceManager ( ) . submit ( ) ;
var nm = this . et2 . getWidgetById ( 'nm' ) ;
nm . applyFilters ( activeFilters ) ;
}
}
var refreshTree = this . et2 . getWidgetById ( 'tree' ) ;
if ( refreshTree )
refreshTree . refreshItem ( '/groups' ) ;
return false ; // --> no regular refresh
}
// not a user or group, eg. categories
else if ( ! _id ) {
// Try just refreshing the nextmatch
if ( this . nm ) {
this . nm . refresh ( ) ;
}
if ( this . groups ) {
this . groups . refresh ( ) ;
}
if ( this . et2 && this . et2 . getWidgetById ( 'nm' ) && this . nm !== this . et2 . getWidgetById ( 'nm' ) ) {
this . et2 . getWidgetById ( 'nm' ) . refresh ( ) ;
}
else {
// Load something else
this . load ( ) ;
}
return false ; // --> no regular refresh needed
}
}
} ;
2020-09-22 21:53:08 +02:00
/ * *
* Handle a push notification about entry changes from the websocket
*
* Get ' s called for data of all apps , but should only handle data of apps it displays ,
* which is by default only it ' s own , but can be for multiple apps eg . for calendar .
*
* @ param pushData
* @ param { string } pushData . app application name
* @ param { ( string | number ) } pushData . id id of entry to refresh or null
* @ param { string } pushData . type either 'update' , 'edit' , 'delete' , 'add' or null
* - update : request just modified data from given rows . Sorting is not considered ,
* so if the sort field is changed , the row will not be moved .
* - edit : rows changed , but sorting may be affected . Requires full reload .
* - delete : just delete the given rows clientside ( no server interaction neccessary )
* - add : requires full reload for proper sorting
* @ param { object | null } pushData . acl Extra data for determining relevance . eg : owner or responsible to decide if update is necessary
* @ param { number } pushData . account _id User that caused the notification
* /
AdminApp . prototype . push = function ( pushData ) {
// We'll listen to addressbook, but only if it has an account ID
if ( pushData . app != this . appname )
return ;
if ( pushData . id > 0 ) {
this . nm . refresh ( pushData . id , pushData . type ) ;
}
else if ( pushData . id < 0 ) {
this . groups . refresh ( pushData . id , pushData . type ) ;
}
} ;
2020-02-09 12:26:23 +01:00
/ * *
* Hide navbar for idots template
*
* Just a hack for old idots , not neccesary for jdots
* /
AdminApp . prototype . _hide _navbar = function ( ) {
var document = this . iframe . getDOMNode ( ) . contentDocument ;
if ( ! document )
return ; // nothing we can do ...
// set white background, as transparent one lets account-list show through
document . getElementsByTagName ( 'body' ) [ 0 ] . style . backgroundColor = 'white' ;
// hide navbar elements
var ids2hide = [ 'divLogo' , 'topmenu' , 'divAppIconBar' , 'divStatusBar' , 'tdSidebox' , 'divAppboxHeader' ] ;
for ( var i = 0 ; i < ids2hide . length ; ++ i ) {
var elem = document . getElementById ( ids2hide [ i ] ) ;
if ( elem )
elem . style . display = 'none' ;
}
} ;
/ * *
* Set location of iframe for given _action and _sender ( row )
*
* @ param _action
* @ param _senders
* /
AdminApp . prototype . iframe _location = function ( _action , _senders ) {
var id = _senders [ 0 ] . id . split ( '::' ) ;
var url = _action . data . url . replace ( /(%24|\$)id/ , id [ 1 ] ) ;
this . load ( url ) ;
} ;
/ * *
* Callback to load an etemplate
*
* @ param { Object [ ] } _data
* /
AdminApp . prototype . _ajax _load _callback = function ( _data ) {
if ( ! _data || _data . type != undefined )
return ;
// Insert the content, etemplate will load into it
jQuery ( this . ajax _target . node ) . append ( typeof _data === 'string' ? _data : _data [ 0 ] ) ;
} ;
/ * *
* Link hander for jDots template to just reload our iframe , instead of reloading whole admin app
*
* @ param _url
* @ return boolean true , if linkHandler took care of link , false otherwise
* /
AdminApp . prototype . linkHandler = function ( _url ) {
var matches = _url . match ( /menuaction=admin.admin_ui.index.*&load=([^&]+)/ ) ;
if ( _url != 'about:blank' && ( this . iframe != null && ! _url . match ( 'menuaction=admin.admin_ui.index' ) || matches ) ) {
if ( matches ) {
_url = _url . replace ( /menuaction=admin.admin_ui.index/ , 'menuaction=' + matches [ 1 ] ) . replace ( /&(load=[^&]+)/g , '' ) ;
}
this . load ( _url ) ;
return true ;
}
// can not load our own index page, has to be done by framework
return false ;
} ;
/ * *
* Run an admin module / onclick callback for tree
*
* @ param { string } _id id of clicked node
* @ param { et2 _tree } _widget reference to tree widget
* /
AdminApp . prototype . run = function ( _id , _widget ) {
var link = _widget . getUserData ( _id , 'link' ) ;
this . groups . set _disabled ( true ) ;
if ( _id == '/accounts' || _id . substr ( 0 , 8 ) == '/groups/' ) {
this . load ( ) ;
var parts = _id . split ( '/' ) ;
this . nm . applyFilters ( { filter : parts [ 2 ] ? parts [ 2 ] : '' , search : '' } ) ;
}
else if ( _id === '/groups' ) {
this . load ( ) ;
this . group _list ( ) ;
}
else if ( typeof link == 'undefined' ) {
_widget . openItem ( _id , 'toggle' ) ;
}
else if ( link [ 0 ] == '/' || link . substr ( 0 , 4 ) == 'http' ) {
link += ( link . indexOf ( '?' ) >= 0 ? '&' : '?' ) + 'nonavbar=1' ;
this . load ( link ) ;
}
else if ( link . substr ( 0 , 11 ) == 'javascript:' ) {
2021-03-15 07:56:58 +01:00
var href _regexp = /^javascript:([^\(]+)\((.*)?\);?$/ ;
var matches = link . match ( href _regexp ) ;
var args = [ ] ;
if ( matches . length > 1 && matches [ 2 ] !== undefined ) {
try {
args = JSON . parse ( '[' + matches [ 2 ] + ']' ) ;
}
catch ( e ) { // deal with '-encloded strings (JSON allows only ")
args = JSON . parse ( '[' + matches [ 2 ] . replace ( /'/g , '"' ) + ']' ) ;
}
}
egw . applyFunc ( matches [ 1 ] , args ) ;
2020-02-09 12:26:23 +01:00
}
} ;
/ * *
* Show the group list in the main window
* /
AdminApp . prototype . group _list = function ( ) {
this . nm . set _disabled ( true ) ;
this . groups . set _disabled ( false ) ;
} ;
/ * *
* View , edit or delete a group callback for tree
*
* @ param { object } _action egwAction
* @ param { array } _senders egwActionObject _senders [ 0 ] . id holds id
* /
AdminApp . prototype . group = function ( _action , _senders ) {
// Tree IDs look like /groups/ID, nm uses admin::ID
var from _nm = _senders [ 0 ] . id . indexOf ( '::' ) > 0 ;
var account _id = _senders [ 0 ] . id . split ( from _nm ? '::' : '/' ) [ from _nm ? 1 : 2 ] ;
switch ( _action . id ) {
case 'view' :
this . run ( from _nm ? '/groups/' + account _id : _senders [ 0 ] . id , this . et2 . getWidgetById ( 'tree' ) ) ;
break ;
case 'delete' :
this . egw . json ( 'admin_account::ajax_delete_group' , [ account _id , _action . data , this . et2 . _inst . etemplate _exec _id ] ) . sendRequest ( ) ;
break ;
default :
if ( ! _action . data . url ) {
alert ( 'Missing url in action ' + _action . id + '!' ) ;
break ;
}
var url = unescape ( _action . data . url ) . replace ( '$id' , account _id ) ;
if ( url [ 0 ] != '/' && url . substr ( 0 , 4 ) != 'http' ) {
url = this . egw . link ( '/index.php' , url ) ;
}
if ( _action . data . popup || _action . data . width && _action . data . height ) {
this . egw . open _link ( url , '_blank' , _action . data . popup ? _action . data . popup : _action . data . width + 'x' + _action . data . height ) ;
}
else {
this . load ( url ) ;
}
break ;
}
} ;
/ * *
* Modify an ACL entry
*
* @ param { object } _action egwAction
* @ param { array } _senders egwActionObject _senders [ 0 ] . id holds the id "admin::app:account:location"
* /
AdminApp . prototype . acl = function ( _action , _senders ) {
var ids = [ ] ;
for ( var i = 0 ; i < _senders . length ; ++ i ) {
ids . push ( _senders [ i ] . id . split ( '::' ) . pop ( ) ) ; // remove "admin::" prefix
}
// For edit, set some data from the list since it's already there
var content = _senders [ 0 ] . id ? jQuery . extend ( { } , egw . dataGetUIDdata ( _senders [ 0 ] . id ) . data ) : { } ;
switch ( _action . id ) {
case 'delete' :
this . _acl _delete ( ids ) ;
break ;
case 'add' :
// No content, even if they clicked on a row
// Defaults set by _acl_content() based on nm values
content = { } ;
// Fall through
case 'edit' :
this . _acl _dialog ( content ) ;
break ;
}
} ;
AdminApp . prototype . _acl _delete = function ( ids ) {
var app = egw . app _name ( ) ; // can be either admin or preferences!
if ( app != 'admin' )
app = 'preferences' ;
var className = app + '_acl' ;
var callback = function ( _button _id , _value ) {
if ( _button _id != et2 _dialog . OK _BUTTON )
return ;
var request = egw . json ( className + '::ajax_change_acl' , [ ids , null , _value , this . et2 . _inst . etemplate _exec _id ] , this . _acl _callback , this , false , this )
. sendRequest ( ) ;
} . bind ( this ) ;
var modifications = { } ;
var dialog _options = {
callback : callback ,
title : this . egw . lang ( 'Delete' ) ,
buttons : et2 _dialog . BUTTONS _OK _CANCEL ,
value : {
content : { } ,
sel _options : { } ,
modifications : modifications ,
readonlys : { }
} ,
template : egw . webserverUrl + '/admin/templates/default/acl.delete.xet'
} ;
// Handle policy documentation tab here
if ( this . egw . user ( 'apps' ) . policy ) {
dialog _options [ 'width' ] = 550 ;
dialog _options [ 'height' ] = 350 ,
modifications . tabs = {
add _tabs : true ,
tabs : [ {
label : egw . lang ( 'Documentation' ) ,
template : 'policy.admin_cmd' ,
prepend : false
} ]
} ;
}
// Create the dialog
this . acl _dialog = et2 _createWidget ( "dialog" , dialog _options , et2 _dialog . _create _parent ( app ) ) ;
} ;
/ * *
* Create the ACL edit dialog , including defaults & fetching what can be found
*
* @ param content List of content for the dialog template
* @ param sel _options optional select options
* @ param { etemplate2 } etemplate of etemplate that 'owns' the dialog
* @ param { string } app Name of app
* @ param { function } callback
* /
AdminApp . prototype . _acl _dialog = function ( content , sel _options , etemplate , app , callback ) {
if ( typeof content == 'undefined' )
content = { } ;
// Determine which application we're running as
app = app ? app : egw . app _name ( ) ;
// can be either admin or preferences!
if ( app != 'admin' )
app = 'preferences' ;
// Get by ID, since this.et2 isn't always the ACL list
var et2 = etemplate ? etemplate : etemplate2 . getById ( 'admin-acl' ) . widgetContainer ;
var className = app + '_acl' ;
var acl _rights = { } ;
var readonlys = { acl : { } } ;
var modifications = { } ;
// Select options are already here, just pull them and pass along
sel _options = et2 . getArrayMgr ( 'sel_options' ) . data || { } ;
// Some defaults
if ( et2 && et2 . getWidgetById ( 'nm' ) ) {
// This is which checkboxes are available for each app
acl _rights = et2 . getWidgetById ( 'nm' ) . getArrayMgr ( 'content' ) . getEntry ( 'acl_rights' ) || { } ;
if ( ! content . acl _appname ) {
// Pre-set appname to currently selected
content . acl _appname = et2 . getWidgetById ( 'filter2' ) . getValue ( ) || "" ;
}
if ( ! content . acl _account ) {
content . acl _account = et2 . getWidgetById ( 'nm' ) . getArrayMgr ( 'content' ) . getEntry ( 'account_id' ) ;
}
if ( ! content . acl _location ) {
content . acl _location = et2 . getWidgetById ( 'filter' ) . getValue ( ) == 'run' ? 'run' : null ;
}
// If no admin rights, change UI to not allow adding access to apps
if ( content . acl _location == 'run' && ! egw . user ( 'apps' ) [ 'admin' ] ) {
content . acl _location = null ;
}
if ( content . acl _location == 'run' ) {
// These are the apps the account has access to
// Fetch current values from server
this . egw . json ( className + '::ajax_get_app_list' , [ content . acl _account ] , function ( data ) { content . apps = data ; } , this , false , this )
. sendRequest ( ) ;
}
else {
// Restrict application selectbox to only apps that support ACL
sel _options . acl _appname = [ ] ;
for ( var app _1 in acl _rights ) {
2021-02-22 23:05:15 +01:00
sel _options . acl _appname . push ( { value : app _1 , label : this . egw . lang ( this . egw . link _get _registry ( app _1 , 'entries' ) || app _1 ) } ) ;
2020-02-09 12:26:23 +01:00
}
// Sort list
sel _options . acl _appname . sort ( function ( a , b ) {
if ( a . label > b . label )
return 1 ;
if ( a . label < b . label )
return - 1 ;
return 0 ;
} ) ;
}
}
if ( content . acl _appname ) {
// Load checkboxes & their values
content . acl _rights = content . acl _rights ? parseInt ( content . acl _rights ) : null ;
jQuery . extend ( content , { acl : [ ] , right : [ ] , label : [ ] } ) ;
2020-04-08 20:22:24 +02:00
// Use this to make sure we get correct app translations
var app _egw = egw ( content . acl _appname , window ) ;
2020-02-09 12:26:23 +01:00
for ( var right in acl _rights [ content . acl _appname ] ) {
// only user himself is allowed to grant private (16) rights
if ( right == '16' && content [ 'acl_account' ] != egw . user ( 'account_id' ) ) {
readonlys . acl [ content . acl . length ] = true ;
}
content . acl . push ( content . acl _rights & parseInt ( right ) ) ;
content . right . push ( right ) ;
2020-04-08 20:22:24 +02:00
content . label . push ( app _egw . lang ( acl _rights [ content . acl _appname ] [ right ] ) ) ;
2020-02-09 12:26:23 +01:00
}
}
if ( content . acl _account && ! egw . user ( 'apps' ) [ 'admin' ] ) {
readonlys . acl _account = true ;
}
if ( content . acl _location ) {
sel _options . acl _location = jQuery . extend ( { } , sel _options . acl _location ) ;
this . egw . link _title ( 'api-accounts' , content . acl _location , function ( title ) { sel _options . acl _location [ content . acl _location ] = title ; } ) ;
}
var dialog _options = {
callback : jQuery . proxy ( function ( _button _id , _value ) {
this . acl _dialog = null ;
if ( _button _id != et2 _dialog . OK _BUTTON )
return ;
// Restore account if it's readonly in dialog
if ( ! _value . acl _account )
_value . acl _account = content . acl _account ;
// Handle no applications selected
if ( typeof _value . apps == 'undefined' && content . acl _location == 'run' ) {
_value . apps = [ ] ;
}
// Only send the request if they entered everything (or selected no apps)
if ( _value . acl _account && ( _value . acl _appname && _value . acl _location || typeof _value . apps != 'undefined' ) ) {
var id = [ ] ;
if ( _value . acl _appname && _value . acl _account && _value . acl _location ) {
id = _value . acl _appname + ':' + _value . acl _account + ':' + _value . acl _location ;
if ( content && content . id && id != content . id ) {
// Changed the account or location, remove previous or we
// get a new line instead of an edit
this . egw . json ( className + '::ajax_change_acl' , [ content . id , 0 , [ ] , this . et2 . _inst . etemplate _exec _id ] , null , this , false , this )
. sendRequest ( ) ;
}
id = [ id ] ;
}
var rights = 0 ;
for ( var i in _value . acl ) {
rights += parseInt ( _value . acl [ i ] ) ;
}
if ( typeof _value . apps != 'undefined' && ! _value . acl _appname ) {
rights = 1 ;
var removed = [ ] ;
// Loop through all apps, remove the ones with no permission
for ( var idx in sel _options . filter2 ) {
var app = sel _options . filter2 [ idx ] . value || false ;
if ( ! app )
continue ;
var run _id = app + ":" + _value . acl _account + ":run" ;
if ( _value . apps . indexOf ( app ) < 0 && ( content . apps . indexOf ( app ) >= 0 || content . apps . length == 0 ) ) {
removed . push ( run _id ) ;
}
else if ( _value . apps . indexOf ( app ) >= 0 && content . apps . indexOf ( app ) < 0 ) {
id . push ( run _id ) ;
}
}
// Remove any removed
if ( removed . length > 0 ) {
this . egw . json ( className + '::ajax_change_acl' , [ removed , 0 , [ ] , this . et2 . _inst . etemplate _exec _id ] , callback ? callback : this . _acl _callback , this , false , this )
. sendRequest ( ) ;
}
}
this . egw . json ( className + '::ajax_change_acl' , [ id , rights , _value , this . et2 . _inst . etemplate _exec _id ] , callback ? callback : this . _acl _callback , this , false , this )
. sendRequest ( ) ;
}
} , this ) ,
title : this . egw . lang ( 'Access control' ) ,
buttons : et2 _dialog . BUTTONS _OK _CANCEL ,
value : {
content : content ,
2020-08-11 15:48:18 +02:00
// @todo: we need to investigate more on et2_widget_selectbox type of apps
// where the sel options are not ready while setting its content. Therefore,
// the explicit apps should be removed after fixing it on the widget side.
sel _options : jQuery . extend ( sel _options , { apps : sel _options . filter2 } ) ,
2020-02-09 12:26:23 +01:00
modifications : modifications ,
readonlys : readonlys
} ,
template : egw . webserverUrl + '/admin/templates/default/acl.edit.xet'
} ;
// Handle policy documentation tab here
if ( this . egw . user ( 'apps' ) . policy ) {
dialog _options [ 'width' ] = 550 ;
dialog _options [ 'height' ] = 450 ,
modifications . tabs = {
add _tabs : true ,
tabs : [ {
label : egw . lang ( 'Documentation' ) ,
template : 'policy.admin_cmd' ,
prepend : false
} ]
} ;
}
// Create the dialog
this . acl _dialog = et2 _createWidget ( "dialog" , dialog _options , et2 _dialog . _create _parent ( app ) ) ;
} ;
/ * *
* Change handler for ACL edit dialog application selectbox .
* Re - creates the dialog with the current values
*
* @ param input
* @ param widget
* /
AdminApp . prototype . acl _reopen _dialog = function ( input , widget ) {
var content = { } ;
if ( this . acl _dialog != null ) {
content = this . acl _dialog . get _value ( ) || { } ;
// Destroy the dialog
2020-05-15 17:50:38 +02:00
this . acl _dialog . destroy ( ) ;
2020-02-09 12:26:23 +01:00
this . acl _dialog = null ;
}
// Re-open the dialog
this . _acl _dialog ( content ) ;
} ;
2020-04-08 20:22:24 +02:00
/ * *
* Load the new application ' s lang files when the app filter is changed
* /
AdminApp . prototype . acl _app _change = function ( event , nm ) {
var appname = nm . getWidgetById ( 'filter2' ) . getValue ( ) || '' ;
if ( appname ) {
var app _egw = egw ( appname ) ;
app _egw . langRequireApp ( window , appname ) ;
nm . getRoot ( ) . setApiInstance ( app _egw ) ;
}
} ;
2020-02-09 12:26:23 +01:00
/ * *
* Callback called on successfull call of serverside ACL handling
*
* @ param { object } _data returned from server
* /
AdminApp . prototype . _acl _callback = function ( _data ) {
// Avoid the window / framework / app and just refresh the etemplate
// Framework will try to refresh the opener
// Get by ID, since this.et2 isn't always the ACL list
var et2 = etemplate2 . getById ( 'admin-acl' ) . widgetContainer ;
et2 . getInstanceManager ( ) . refresh ( _data . msg , this . appname , _data . ids , _data . type ) ;
} ;
/ * *
* Check to see if admin has taken away access to a category
*
* @ @ param { widget } button add / apply pressed button
* /
AdminApp . prototype . check _owner = function ( button ) {
var select _owner = this . et2 . getWidgetById ( 'owner' ) ;
var diff = [ ] ;
if ( typeof select _owner != 'undefined' ) {
var owner = select _owner . get _value ( ) ;
}
if ( typeof owner != 'object' ) {
owner = [ owner ] ;
}
// No owner probably means selectbox is read-only, so no need to check
if ( owner == null )
return true ;
var all _users = owner . indexOf ( '0' ) >= 0 ;
// If they checked all users, uncheck the others
if ( all _users ) {
select _owner . set _value ( [ '0' ] ) ;
return true ;
}
// Find out what changed
var cat _original _owner = this . et2 . getArrayMgr ( 'content' ) . getEntry ( 'owner' ) ;
if ( cat _original _owner ) {
var selected _groups = select _owner . get _value ( ) . toString ( ) ;
for ( var i = 0 ; i < cat _original _owner . length ; i ++ ) {
if ( selected _groups . search ( cat _original _owner [ i ] ) < 0 ) {
diff . push ( cat _original _owner [ i ] ) ;
}
}
if ( diff . length > 0 ) {
var removed _cat _label = jQuery . map ( select _owner . options . select _options , function ( val , i ) {
for ( var j = 0 ; j <= diff . length ; j ++ ) {
if ( diff [ j ] == val . value ) {
return val . label ;
}
}
} ) ;
// Somebody will lose permission, give warning.
if ( removed _cat _label ) {
var msg = this . egw . lang ( 'Removing access for groups may cause problems for data in this category. Are you sure? Users in these groups may no longer have access:' ) ;
return et2 _dialog . confirm ( button , msg + removed _cat _label . join ( ',' ) ) ;
}
}
}
return true ;
} ;
/ * *
* Show icon based on icon - selectbox , hide placeholder ( broken image ) , if no icon selected
*
* @ param { widget } widget select box widget
* /
AdminApp . prototype . change _icon = function ( widget ) {
var img = widget . getRoot ( ) . getWidgetById ( 'icon_url' ) ;
if ( img ) {
img . set _src ( widget . getValue ( ) ) ;
}
} ;
/ * *
* Add / edit an account
*
* @ param { object } _action egwAction
* @ param { array } _senders egwActionObject _senders [ 0 ] . id holds account _id
* /
AdminApp . prototype . account = function ( _action , _senders ) {
var params = jQuery . extend ( { } , this . egw . link _get _registry ( 'addressbook' , 'edit' ) ) ;
var popup = this . egw . link _get _registry ( 'addressbook' , 'edit_popup' ) ;
2020-03-03 00:00:58 +01:00
switch ( _action . id ) {
case 'add' :
params . owner = '0' ;
break ;
case 'copy' :
params . owner = '0' ;
params . copy = true ;
// Fall through
default :
params . account _id = _senders [ 0 ] . id . split ( '::' ) . pop ( ) ; // get last :: separated part
break ;
2020-02-09 12:26:23 +01:00
}
2020-04-08 20:22:24 +02:00
this . egw . open _link ( this . egw . link ( '/index.php' , params ) , 'admin' , popup , 'admin' ) ;
2020-02-09 12:26:23 +01:00
} ;
/ * *
* Submit statistic
*
* Webkit browsers ( Chrome , Safari , ... ) do NOT allow to call form . submit ( ) from within onclick of a submit button .
* Therefor we first store our own form action , replace it with egroupware . org submit url and set a timeout calling
* submit _statistic again with just the form , to do the second submit to our own webserver
*
* @ param { DOM } form
* @ param { string } submit _url
* @ return { boolean }
* /
AdminApp . prototype . submit _statistic = function ( form , submit _url ) {
var that = this ;
var submit = function ( ) {
// submit to egroupware.org
var method = form . method ;
form . method = 'POST' ;
var action = form . action ;
form . action = submit _url ;
var target = form . target ;
form . target = '_blank' ;
form . submit ( ) ;
// submit to own webserver
form . method = method ;
form . action = action ;
form . target = target ;
that . et2 . getInstanceManager ( ) . submit ( 'submit' ) ;
} ;
// Safari does NOT allow to call form.submit() outside of onclick callback
// so we have to use browsers ugly synchron confirm
if ( navigator . userAgent . match ( /Safari/ ) && ! navigator . userAgent . match ( /Chrome/ ) ) {
if ( confirm ( this . egw . lang ( 'Submit displayed information?' ) ) ) {
submit ( ) ;
}
}
else {
et2 _dialog . show _dialog ( function ( _button ) {
if ( _button == et2 _dialog . YES _BUTTON ) {
submit ( ) ;
}
} , this . egw . lang ( 'Submit displayed information?' ) , '' , { } , et2 _dialog . BUTTON _YES _NO , et2 _dialog . QUESTION _MESSAGE , undefined , egw ) ;
}
return false ;
} ;
/ * *
* Change handler for when you change the type of a custom field .
* It toggles options / attributes as appropriate .
* @ param { event object } e
* @ param { widget object } widget
* /
AdminApp . prototype . cf _type _change = function ( e , widget ) {
var root = widget . getRoot ( ) ;
var attributes = widget . getArrayMgr ( 'content' ) . getEntry ( 'attributes[' + widget . getValue ( ) + ']' ) || { } ;
root . getWidgetById ( 'cf_values' ) . set _statustext ( widget . egw ( ) . lang ( widget . getArrayMgr ( 'content' ) . getEntry ( 'options[' + widget . getValue ( ) + ']' ) || '' ) ) ;
jQuery ( root . getWidgetById ( 'cf_len' ) . getDOMNode ( ) ) . toggle ( attributes . cf _len && true ) ;
jQuery ( root . getWidgetById ( 'cf_rows' ) . getDOMNode ( ) ) . toggle ( attributes . cf _rows && true ) ;
jQuery ( root . getWidgetById ( 'cf_values' ) . getParentDOMNode ( ) ) . toggle ( attributes . cf _values && true ) ;
} ;
/ * *
* Change handler for when you delete a custom app type
* If Policy app is available , it asks for documentation
* /
AdminApp . prototype . cf _type _delete = function ( e , widget ) {
var callback = function ( button , value ) {
if ( button === et2 _dialog . YES _BUTTON ) {
var values = jQuery . extend ( { } , this . getInstanceManager ( ) . getValues ( this . getRoot ( ) ) , value , { appname : this . getRoot ( ) . getArrayMgr ( 'content' ) . getEntry ( 'content_types[appname]' ) } ) ;
egw . json ( 'admin.admin_customfields.ajax_delete_type' , [ values , this . getInstanceManager ( ) . etemplate _exec _id ] ) . sendRequest ( ) ;
// Immediately remove the type
var types = this . getRoot ( ) . getWidgetById ( 'types' ) ;
var options = types . options . select _options ;
var key ;
for ( key in options ) {
if ( options . hasOwnProperty ( key ) && key === types . getValue ( ) ) {
delete options [ key ] ;
break ;
}
}
types . set _select _options ( options ) ;
this . egw ( ) . message ( '' ) ;
// Trigger load of status for existing type
types . set _value ( Object . keys ( options ) [ 0 ] ) ;
}
} . bind ( widget ) ;
if ( egw . app ( 'policy' ) ) {
egw . includeJS ( egw . link ( '/policy/js/app.js' ) , function ( ) {
if ( typeof app . policy === 'undefined' || typeof app . policy . confirm === 'undefined' ) {
app . policy = new app . classes . policy ( ) ;
}
var parent = et2 _dialog . _create _parent ( widget . egw ( ) ) ;
var dialog = et2 _createWidget ( "dialog" , {
callback : callback ,
template : egw . link ( '/policy/templates/default/admin_cmd_narrow.xet' ) ,
title : egw . lang ( 'Delete' ) ,
buttons : et2 _dialog . BUTTONS _YES _NO ,
value : { content : { } } ,
width : 'auto'
} , parent ) ;
dialog . egw ( ) . message ( "Entries with a deleted type can cause problems.\nCheck for entries with this type before deleting." , 'warning' ) ;
} ) ;
}
else {
callback ( et2 _dialog . YES _BUTTON ) ;
}
return false ;
} ;
/ * *
* Activate none standard SMTP mail accounts for selected users
*
* @ param { egw _action } _action
* @ param { array } _selected selected users
* /
AdminApp . prototype . emailadminActiveAccounts = function ( _action , _selected ) {
var menuaction = 'admin.admin_mail.ajax_activeAccounts' ;
var accounts = [ ] ;
var msg1 = egw . lang ( '%1 accounts being activated' , "" + Object . keys ( _selected ) . length ) ;
for ( var i = 0 ; i < Object . keys ( _selected ) . length ; i ++ ) {
accounts [ i ] = [ { id : _selected [ i ] [ 'id' ] . split ( '::' ) [ 1 ] , qouta : "" , domain : "" , status : _action . id == 'active' ? _action . id : '' } , this . et2 . _inst . etemplate _exec _id ] ;
}
var callbackDialog = function ( btn ) {
if ( btn === et2 _dialog . YES _BUTTON ) {
// long task dialog for de/activation accounts
et2 _dialog . long _task ( function ( _val , _resp ) {
if ( _val && _resp . type !== 'error' ) {
console . log ( _val , _resp ) ;
}
else {
}
} , msg1 , 'Mail Acounts Activation' , menuaction , accounts , 'admin' ) ;
}
} ;
// confirmation dialog
et2 _dialog . show _dialog ( callbackDialog , egw . lang ( 'Are you sure you want to %1 mail for selected accounts?' , egw . lang ( _action . id ) ) , egw . lang ( 'Active Mail Accounts' ) , { } , et2 _dialog . BUTTON _YES _NO , et2 _dialog . WARNING _MESSAGE , undefined , egw ) ;
} ;
/ * *
* Resize window methode
*
* @ returns { undefined }
* /
AdminApp . prototype . wizard _popup _resize = function ( ) {
var $main _div = jQuery ( '#popupMainDiv' ) ;
var $et2 = jQuery ( '.et2_container' ) ;
var w = {
width : egw _getWindowInnerWidth ( ) ,
height : egw _getWindowInnerHeight ( )
} ;
// Use et2_container for width since #popupMainDiv is full width, but we still need
// to take padding/margin into account
var delta _width = w . width - ( $et2 . outerWidth ( true ) + ( $main _div . outerWidth ( true ) - $main _div . width ( ) ) ) ;
var delta _height = w . height - ( $et2 . outerHeight ( true ) + ( $main _div . outerHeight ( true ) - $main _div . height ( ) ) ) ;
if ( delta _width != 0 || delta _height != 0 ) {
window . resizeTo ( egw _getWindowOuterWidth ( ) - delta _width , egw _getWindowOuterHeight ( ) - delta _height ) ;
}
} ;
/ * *
* Switch account wizard to manual entry
* /
AdminApp . prototype . wizard _manual = function ( ) {
jQuery ( '.emailadmin_manual' ) . fadeToggle ( ) ; // not sure how to to this et2-isch
this . wizard _popup _resize ( ) ; // popup needs to be resized after toggling
} ;
/ * *
* onclick for continue button to show progress animation
*
* @ param { object } _event event - object or information about event
* @ param { et2 _baseWidget } _widget widget causing the event
* /
AdminApp . prototype . wizard _detect = function ( _event , _widget ) {
// we need to do a manual asynchronious submit to show progress animation
// default synchronious submit stops animation!
if ( this . et2 . _inst . submit ( 'button[continue]' , true ) ) // true = async submit
{
var sieve _enabled = this . et2 . getWidgetById ( 'acc_sieve_enabled' ) ;
if ( ! sieve _enabled || sieve _enabled . get _value ( ) ) {
jQuery ( '#admin-mailwizard_output' ) . hide ( ) ;
jQuery ( 'td.emailadmin_progress' ) . show ( ) ;
}
}
return false ;
} ;
/ * *
* Set default port , if imap ssl - type changes
*
* @ param { object } _event event - object or information about event
* @ param { et2 _baseWidget } _widget widget causing the event
* /
AdminApp . prototype . wizard _imap _ssl _onchange = function ( _event , _widget ) {
var ssl _type = _widget . get _value ( ) ;
this . et2 . getWidgetById ( 'acc_imap_port' ) . set _value ( ssl _type == this . SSL _SSL || ssl _type == this . SSL _TLS ? 993 : 143 ) ;
} ;
/ * *
* Set default port , if imap ssl - type changes
*
* @ param { object } _event event - object or information about event
* @ param { et2 _baseWidget } _widget widget causing the event
* /
AdminApp . prototype . wizard _smtp _ssl _onchange = function ( _event , _widget ) {
var ssl _type = _widget . get _value ( ) ;
this . et2 . getWidgetById ( 'acc_smtp_port' ) . set _value ( ssl _type == 'no' ? 25 : ( ssl _type == this . SSL _SSL || ssl _type == this . SSL _TLS ? 465 : 587 ) ) ;
} ;
/ * *
* Set default port , if imap ssl - type changes
*
* @ param { object } _event event - object or information about event
* @ param { et2 _baseWidget } _widget widget causing the event
* /
AdminApp . prototype . wizard _sieve _ssl _onchange = function ( _event , _widget ) {
var ssl _type = _widget . get _value ( ) ;
this . et2 . getWidgetById ( 'acc_sieve_port' ) . set _value ( ssl _type == this . SSL _SSL || ssl _type == this . SSL _TLS ? 5190 : 4190 ) ;
this . wizard _sieve _onchange ( _event , _widget ) ;
} ;
/ * *
* Enable sieve , if user changes some setting
*
* @ param { object } _event event - object or information about event
* @ param { et2 _baseWidget } _widget widget causing the event
* /
AdminApp . prototype . wizard _sieve _onchange = function ( _event , _widget ) {
this . et2 . getWidgetById ( 'acc_sieve_enabled' ) . set _value ( 1 ) ;
} ;
/ * *
* Switch to select multiple accounts
*
* @ param { object } _event event - object or information about event
* @ param { et2 _baseWidget } _widget widget causing the event
* /
AdminApp . prototype . edit _multiple = function ( _event , _widget ) {
// hide multiple button
_widget . set _disabled ( true ) ;
// switch account-selection to multiple
var account _id = this . et2 . getWidgetById ( 'account_id' ) ;
account _id . set _multiple ( true ) ;
} ;
/ * *
* Hide not applying fields , used as :
* - onchange handler on account _id
* - called from et2 _ready for emailadmin . account template
*
* @ param { object } _event event - object or information about event
* @ param { et2 _baseWidget } _widget widget causing the event
* /
AdminApp . prototype . account _hide _not _applying = function ( _event , _widget ) {
var account _id = this . et2 . getWidgetById ( 'account_id' ) ;
var ids = account _id && account _id . get _value ? account _id . get _value ( ) : [ ] ;
if ( typeof ids == 'string' )
ids = ids . split ( ',' ) ;
var multiple = ids . length >= 2 || ids [ 0 ] === '' || ids [ 0 ] < 0 ;
//alert('multiple='+(multiple?'true':'false')+': '+ids.join(','));
// initial call
if ( typeof _widget == 'undefined' ) {
if ( ! multiple ) {
jQuery ( '.emailadmin_no_single' ) . hide ( ) ;
}
if ( ! this . egw . user ( 'apps' ) . admin ) {
jQuery ( '.emailadmin_no_user,#button\\[multiple\\]' ) . hide ( ) ;
}
if ( ids . length == 1 ) {
// switch back to single selectbox
account _id . set _multiple ( false ) ;
this . et2 . getWidgetById ( 'button[multiple]' ) . set _disabled ( false ) ;
}
}
// switched to single user
else if ( ! multiple ) {
jQuery ( '.emailadmin_no_single' ) . fadeOut ( ) ;
// switch back to single selectbox
account _id . set _multiple ( false ) ;
this . et2 . getWidgetById ( 'button[multiple]' ) . set _disabled ( false ) ;
}
// switched to multiple user
else {
jQuery ( '.emailadmin_no_single' ) . fadeIn ( ) ;
}
if ( _event && _event . stopPropagation )
_event . stopPropagation ( ) ;
return false ;
} ;
/ * *
* Callback if user changed account selction
*
* @ param { object } _event event - object or information about event
* @ param { et2 _baseWidget } _widget widget causing the event
* /
AdminApp . prototype . change _account = function ( _event , _widget ) {
// todo check dirty and query user to a) save changes, b) discard changes, c) cancel selection
_widget . getInstanceManager ( ) . submit ( ) ;
} ;
/ * *
* Callback if user changes notification folders : unset use - default checkbox
*
* @ param { object } _event
* @ param { et2 _widget } _widget
* /
AdminApp . prototype . change _folders = function ( _event , _widget ) {
var use _default = this . et2 . getWidgetById ( 'notify_use_default' ) ;
if ( use _default )
use _default . set _value ( false ) ;
} ;
/ * *
* default onExecute for admin actions
*
* @ param { object } _action
* @ param { object } _senders
* /
AdminApp . prototype . account _edit _action = function ( _action , _senders ) {
if ( _action . data . url ) {
this . egw . open _link ( _action . data . url , _action . data . target || '_blank' , _action . data . popup ) ;
}
} ;
/ * *
* Clear instance cache
*
* If there is an error on server - side , resend request with an parameter allowing
* cache to use different method not requiring eg . so much memory
* /
AdminApp . prototype . clear _cache = function ( ) {
2020-07-30 15:01:50 +02:00
var wait = this . egw . message ( this . egw . lang ( 'Clear cache and register hooks' ) + "\n" + this . egw . lang ( 'Please wait...' ) , 'info' ) ;
var success = function ( ) {
wait . close ( ) ;
egw . message ( 'Done' ) ;
} ;
this . egw . json ( 'admin.admin_hooks.ajax_clear_cache' , null , success ) . sendRequest ( true , undefined , jQuery . proxy ( function ( _xmlhttp , _err ) {
this . egw . json ( 'admin.admin_hooks.ajax_clear_cache&errored=1' , null , success ) . sendRequest ( true ) ;
2020-02-09 12:26:23 +01:00
} , this ) ) ;
} ;
2020-12-17 21:12:21 +01:00
/ * *
* Action handler for clear credentials action
*
* @ param action
* @ param selected
* /
AdminApp . prototype . clear _credentials _handler = function ( action , selected ) {
var ids = [ ] ;
for ( var _i = 0 , selected _1 = selected ; _i < selected _1 . length ; _i ++ ) {
var row = selected _1 [ _i ] ;
ids . push ( row . id . split ( "::" ) . pop ( ) ) ;
}
2021-01-11 19:53:04 +01:00
this . egw . request ( "admin.admin_passwordreset.ajax_clear_credentials" , [ action . id , ids ] ) ;
2020-12-17 21:12:21 +01:00
} ;
2020-02-09 12:26:23 +01:00
/ * *
* Export content of given field into relevant file
* /
AdminApp . prototype . smime _exportCert = function ( ) {
var $a = jQuery ( document . createElement ( 'a' ) ) . appendTo ( 'body' ) . hide ( ) ;
var acc _id = this . et2 . getArrayMgr ( "content" ) . getEntry ( 'acc_id' ) ;
var url = window . egw . webserverUrl + '/index.php?' ;
url += 'menuaction=mail.mail_ui.smimeExportCert' ;
url += '&acc_id=' + acc _id ;
$a . prop ( 'href' , url ) ;
$a . prop ( 'download' , "" ) ;
$a [ 0 ] . click ( ) ;
$a . remove ( ) ;
} ;
/ * *
* Create certificate generator dialog
* /
AdminApp . prototype . smime _genCertificate = function ( ) {
var self = this ;
et2 _createWidget ( "dialog" , {
callback : function ( _button _id , _value ) {
if ( _button _id == 'create' && _value ) {
var isValid = true ;
var required = [ 'countryName' , 'emailAddress' ] ;
var widget ;
// check the required fields
for ( var i = 0 ; i < required . length ; i ++ ) {
if ( _value [ required [ i ] ] )
continue ;
widget = this . template . widgetContainer . getWidgetById ( required [ i ] ) ;
widget . set _validation _error ( 'This field is required!' ) ;
isValid = false ;
}
// check mismatch passphrase
if ( _value . passphrase && _value . passphrase !== _value . passphraseConf ) {
var passphraseConf = this . template . widgetContainer . getWidgetById ( 'passphrase' ) ;
passphraseConf . set _validation _error ( 'Confirm passphrase is not match!' ) ;
isValid = false ;
}
if ( isValid ) {
egw . json ( 'mail.mail_ui.ajax_smimeGenCertificate' , _value , function ( _cert ) {
if ( _cert ) {
for ( var key in _cert ) {
if ( ! _cert [ key ] )
continue ;
switch ( key ) {
case 'cert' :
self . et2 . getWidgetById ( 'smime_cert' ) . set _value ( _cert [ key ] ) ;
break ;
case 'privkey' :
self . et2 . getWidgetById ( 'acc_smime_password' ) . set _value ( _cert [ key ] ) ;
break ;
}
}
self . egw . message ( 'New certificate information has been generated, please save your account if you want to store it.' ) ;
}
} ) . sendRequest ( true ) ;
}
else {
return false ;
}
}
} ,
title : egw . lang ( 'Generate Certificate' ) ,
buttons : [
{ text : this . egw . lang ( "Create" ) , id : "create" , "class" : "ui-priority-primary" , "default" : true } ,
{ text : this . egw . lang ( "Cancel" ) , id : "cancel" }
] ,
value : {
content : {
value : ''
}
} ,
template : egw . webserverUrl + '/mail/templates/default/smimeCertGen.xet?' + Date . now ( ) ,
resizable : false ,
position : 'left top'
} , et2 _dialog . _create _parent ( 'mail' ) ) ;
} ;
/ * *
* Triggers upload for background image and updates its taglist
*
* @ param { type } node
* @ param { type } widget
* /
AdminApp . prototype . login _background _update = function ( node , widget ) {
var taglist = widget . _parent . _children [ 0 ] ;
egw . json ( 'admin.admin_config.ajax_upload_anon_images' , [ widget . get _value ( ) , taglist . get _value ( ) ] , function ( _data ) {
taglist . set _value ( _data ) ;
} ) . sendRequest ( ) ;
} ;
/ * *
* Set content of selected row
*
* @ param { array } node
* @ returns
* /
AdminApp . prototype . cmds _onselect = function ( node ) {
var splitter = this . et2 . getWidgetById ( 'splitter' ) ;
var cmds _preview = this . et2 . getWidgetById ( 'cmds_preview' ) ;
if ( node . length != 1 ) {
splitter . dock ( ) ;
return ;
}
if ( splitter . isDocked ( ) ) {
splitter . undock ( ) ;
}
var data = egw . dataGetUIDdata ( node [ 0 ] ) ;
var policy _preview = this . et2 . getWidgetById ( 'policy_preview' ) ;
var id = node [ 0 ] . replace ( 'admin::' , '' ) ;
if ( app . policy ) {
cmds _preview . set _disabled ( true ) ;
policy _preview . set _src ( egw . link ( '/index.php' , {
menuaction : 'policy.EGroupware\\Policy\\History.view' ,
'cmd_id' : id ,
'cmd_template' : "policy.admin_cmd_history"
} ) ) ;
}
else {
policy _preview . set _disabled ( true ) ;
cmds _preview . set _value ( { content : [ data . data ] } ) ;
}
} ;
return AdminApp ;
} ( egw _app _1 . EgwApp
2014-03-27 20:00:52 +01:00
/ * *
* @ lends app . classes . admin
* /
2020-02-09 12:26:23 +01:00
) ) ;
app . classes . admin = AdminApp ;
//# sourceMappingURL=app.js.map