@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * @param string|int $account =null account name or id |
| 25 | 25 | * @param array|string $apps =null app-names |
| 26 | 26 | */ |
| 27 | - function __construct($allow,$account=null,$apps=null) |
|
| 27 | + function __construct($allow, $account = null, $apps = null) |
|
| 28 | 28 | { |
| 29 | 29 | if (!is_array($allow)) |
| 30 | 30 | { |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | } |
| 37 | 37 | if (isset($allow['apps']) && !is_array($allow['apps'])) |
| 38 | 38 | { |
| 39 | - $allow['apps'] = explode(',',$allow['apps']); |
|
| 39 | + $allow['apps'] = explode(',', $allow['apps']); |
|
| 40 | 40 | } |
| 41 | 41 | admin_cmd::__construct($allow); |
| 42 | 42 | } |
@@ -50,11 +50,11 @@ discard block |
||
| 50 | 50 | * @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$this->account),15); |
| 51 | 51 | * @throws Api\Exception\WrongUserinput(lang("Application '%1' not found (maybe not installed or misspelled)!",$name),8); |
| 52 | 52 | */ |
| 53 | - protected function exec($check_only=false) |
|
| 53 | + protected function exec($check_only = false) |
|
| 54 | 54 | { |
| 55 | 55 | $account_id = admin_cmd::parse_account($this->account); |
| 56 | 56 | // check creator is still admin and not explicitly forbidden to edit accounts/groups |
| 57 | - if ($this->creator) $this->_check_admin($account_id > 0 ? 'account_access' : 'group_access',16); |
|
| 57 | + if ($this->creator) $this->_check_admin($account_id > 0 ? 'account_access' : 'group_access', 16); |
|
| 58 | 58 | |
| 59 | 59 | $apps = admin_cmd::parse_apps($this->apps); |
| 60 | 60 | |
@@ -62,15 +62,15 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | //echo "account=$this->account, account_id=$account_id, apps: ".implode(', ',$apps)."\n"; |
| 64 | 64 | admin_cmd::_instanciate_acl($account_id); |
| 65 | - foreach($apps as $app) |
|
| 65 | + foreach ($apps as $app) |
|
| 66 | 66 | { |
| 67 | 67 | if ($this->allow) |
| 68 | 68 | { |
| 69 | - admin_cmd::$acl->add_repository($app,'run',$account_id,1); |
|
| 69 | + admin_cmd::$acl->add_repository($app, 'run', $account_id, 1); |
|
| 70 | 70 | } |
| 71 | 71 | else |
| 72 | 72 | { |
| 73 | - admin_cmd::$acl->delete_repository($app,'run',$account_id); |
|
| 73 | + admin_cmd::$acl->delete_repository($app, 'run', $account_id); |
|
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | return lang('Applications run rights updated.'); |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | function __tostring() |
| 85 | 85 | { |
| 86 | - return lang('%1 rights for %2 and applications %3',$this->allow ? lang('Grant') : lang('Remove'), |
|
| 87 | - admin_cmd::display_account($this->account),implode(', ',$this->apps)); |
|
| 86 | + return lang('%1 rights for %2 and applications %3', $this->allow ? lang('Grant') : lang('Remove'), |
|
| 87 | + admin_cmd::display_account($this->account), implode(', ', $this->apps)); |
|
| 88 | 88 | } |
| 89 | 89 | } |
@@ -18,9 +18,8 @@ discard block |
||
| 18 | 18 | /** |
| 19 | 19 | * Constructor |
| 20 | 20 | * |
| 21 | - * @param boolean/array $allow true=give rights, false=remove rights, or array with all 3 params |
|
| 22 | - * @param string/int $account=null account name or id |
|
| 23 | - * @param array/string $apps=null app-names |
|
| 21 | + * @param boolean $allow true=give rights, false=remove rights, or array with all 3 params |
|
| 22 | + * @param string/int $account account name or id |
|
| 24 | 23 | */ |
| 25 | 24 | function __construct($allow,$account=null,$apps=null) |
| 26 | 25 | { |
@@ -42,7 +41,7 @@ discard block |
||
| 42 | 41 | /** |
| 43 | 42 | * give or remove run rights from a given account and application |
| 44 | 43 | * |
| 45 | - * @param boolean $check_only=false only run the checks (and throw the exceptions), but not the command itself |
|
| 44 | + * @param boolean $check_only only run the checks (and throw the exceptions), but not the command itself |
|
| 46 | 45 | * @return string success message |
| 47 | 46 | * @throws egw_exception_no_admin |
| 48 | 47 | * @throws egw_exception_wrong_userinput(lang("Unknown account: %1 !!!",$this->account),15); |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * admin command: give or remove run rights from a given account and application |
| 15 | 15 | */ |
| 16 | -class admin_cmd_account_app extends admin_cmd |
|
| 16 | +class admin_cmd_account_app extends admin_cmd |
|
| 17 | 17 | { |
| 18 | 18 | /** |
| 19 | 19 | * Constructor |
@@ -52,11 +52,17 @@ discard block |
||
| 52 | 52 | { |
| 53 | 53 | $account_id = admin_cmd::parse_account($this->account); |
| 54 | 54 | // check creator is still admin and not explicitly forbidden to edit accounts/groups |
| 55 | - if ($this->creator) $this->_check_admin($account_id > 0 ? 'account_access' : 'group_access',16); |
|
| 55 | + if ($this->creator) |
|
| 56 | + { |
|
| 57 | + $this->_check_admin($account_id > 0 ? 'account_access' : 'group_access',16); |
|
| 58 | + } |
|
| 56 | 59 | |
| 57 | 60 | $apps = admin_cmd::parse_apps($this->apps); |
| 58 | 61 | |
| 59 | - if ($check_only) return true; |
|
| 62 | + if ($check_only) |
|
| 63 | + { |
|
| 64 | + return true; |
|
| 65 | + } |
|
| 60 | 66 | |
| 61 | 67 | //echo "account=$this->account, account_id=$account_id, apps: ".implode(', ',$apps)."\n"; |
| 62 | 68 | admin_cmd::_instanciate_acl($account_id); |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @param egw_record $_definition |
| 23 | 23 | */ |
| 24 | - public function export( $_stream, importexport_definition $_definition) { |
|
| 24 | + public function export($_stream, importexport_definition $_definition) { |
|
| 25 | 25 | $options = $_definition->plugin_options; |
| 26 | 26 | |
| 27 | 27 | $query = array( |
@@ -40,12 +40,12 @@ discard block |
||
| 40 | 40 | // $_record is an array, that's what search() returns |
| 41 | 41 | foreach ($selection as $_record) { |
| 42 | 42 | $record = new admin_egw_group_record($_record); |
| 43 | - if($options['convert']) { |
|
| 43 | + if ($options['convert']) { |
|
| 44 | 44 | importexport_export_csv::convert($record, admin_egw_group_record::$types, 'admin', $lookups); |
| 45 | 45 | } else { |
| 46 | 46 | // Implode arrays, so they don't say 'Array' |
| 47 | - foreach($record->get_record_array() as $key => $value) { |
|
| 48 | - if(is_array($value)) $record->$key = implode(',', $value); |
|
| 47 | + foreach ($record->get_record_array() as $key => $value) { |
|
| 48 | + if (is_array($value)) $record->$key = implode(',', $value); |
|
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | $export_object->export_record($record); |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | /** |
| 26 | 26 | * Exports records as defined in $_definition |
| 27 | 27 | * |
| 28 | - * @param egw_record $_definition |
|
| 28 | + * @param importexport_definition $_definition |
|
| 29 | 29 | */ |
| 30 | 30 | public function export( $_stream, importexport_definition $_definition) { |
| 31 | 31 | $options = $_definition->plugin_options; |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | * return html for options. |
| 133 | 133 | * this way the plugin has all opportunities for options tab |
| 134 | 134 | * |
| 135 | - * @return string html |
|
| 135 | + * @return boolean html |
|
| 136 | 136 | */ |
| 137 | 137 | public function get_options_etpl() { |
| 138 | 138 | return false; |
@@ -125,8 +125,8 @@ |
||
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | public static function get_mimetype() { |
| 128 | - return 'text/csv'; |
|
| 129 | - } |
|
| 128 | + return 'text/csv'; |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | 131 | /** |
| 132 | 132 | * return html for options. |
@@ -14,14 +14,16 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * Export users plugin |
| 16 | 16 | */ |
| 17 | -class admin_export_groups_csv implements importexport_iface_export_plugin { |
|
| 17 | +class admin_export_groups_csv implements importexport_iface_export_plugin |
|
| 18 | +{ |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Exports records as defined in $_definition |
| 21 | 22 | * |
| 22 | 23 | * @param egw_record $_definition |
| 23 | 24 | */ |
| 24 | - public function export( $_stream, importexport_definition $_definition) { |
|
| 25 | + public function export( $_stream, importexport_definition $_definition) |
|
| 26 | + { |
|
| 25 | 27 | $options = $_definition->plugin_options; |
| 26 | 28 | |
| 27 | 29 | $selection = array(); |
@@ -40,14 +42,22 @@ discard block |
||
| 40 | 42 | ); |
| 41 | 43 | |
| 42 | 44 | // $_record is an array, that's what search() returns |
| 43 | - foreach ($selection as $_record) { |
|
| 45 | + foreach ($selection as $_record) |
|
| 46 | + { |
|
| 44 | 47 | $record = new admin_egw_group_record($_record); |
| 45 | - if($options['convert']) { |
|
| 48 | + if($options['convert']) |
|
| 49 | + { |
|
| 46 | 50 | importexport_export_csv::convert($record, admin_egw_group_record::$types, 'admin', $lookups); |
| 47 | - } else { |
|
| 51 | + } |
|
| 52 | + else |
|
| 53 | + { |
|
| 48 | 54 | // Implode arrays, so they don't say 'Array' |
| 49 | - foreach($record->get_record_array() as $key => $value) { |
|
| 50 | - if(is_array($value)) $record->$key = implode(',', $value); |
|
| 55 | + foreach($record->get_record_array() as $key => $value) |
|
| 56 | + { |
|
| 57 | + if(is_array($value)) |
|
| 58 | + { |
|
| 59 | + $record->$key = implode(',', $value); |
|
| 60 | + } |
|
| 51 | 61 | } |
| 52 | 62 | } |
| 53 | 63 | $export_object->export_record($record); |
@@ -60,7 +70,8 @@ discard block |
||
| 60 | 70 | * |
| 61 | 71 | * @return string name |
| 62 | 72 | */ |
| 63 | - public static function get_name() { |
|
| 73 | + public static function get_name() |
|
| 74 | + { |
|
| 64 | 75 | return lang('Group CSV export'); |
| 65 | 76 | } |
| 66 | 77 | |
@@ -69,7 +80,8 @@ discard block |
||
| 69 | 80 | * |
| 70 | 81 | * @return string descriprion |
| 71 | 82 | */ |
| 72 | - public static function get_description() { |
|
| 83 | + public static function get_description() |
|
| 84 | + { |
|
| 73 | 85 | return lang("Exports groups into a CSV File. "); |
| 74 | 86 | } |
| 75 | 87 | |
@@ -78,11 +90,13 @@ discard block |
||
| 78 | 90 | * |
| 79 | 91 | * @return string suffix |
| 80 | 92 | */ |
| 81 | - public static function get_filesuffix() { |
|
| 93 | + public static function get_filesuffix() |
|
| 94 | + { |
|
| 82 | 95 | return 'csv'; |
| 83 | 96 | } |
| 84 | 97 | |
| 85 | - public static function get_mimetype() { |
|
| 98 | + public static function get_mimetype() |
|
| 99 | + { |
|
| 86 | 100 | return 'text/csv'; |
| 87 | 101 | } |
| 88 | 102 | |
@@ -92,7 +106,8 @@ discard block |
||
| 92 | 106 | * |
| 93 | 107 | * @return string html |
| 94 | 108 | */ |
| 95 | - public function get_options_etpl() { |
|
| 109 | + public function get_options_etpl() |
|
| 110 | + { |
|
| 96 | 111 | return false; |
| 97 | 112 | } |
| 98 | 113 | |
@@ -100,7 +115,8 @@ discard block |
||
| 100 | 115 | * returns slectors of this plugin via xajax |
| 101 | 116 | * |
| 102 | 117 | */ |
| 103 | - public function get_selectors_etpl() { |
|
| 118 | + public function get_selectors_etpl() |
|
| 119 | + { |
|
| 104 | 120 | return array( |
| 105 | 121 | 'preserv' => array('no_error_for_no_selection'), |
| 106 | 122 | ); |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | 'List config settings' => 1, |
| 15 | 15 | 'Change config settings' => 2 |
| 16 | 16 | ) |
| 17 | -); // added and working ralfbecker |
|
| 17 | +); // added and working ralfbecker |
|
| 18 | 18 | |
| 19 | 19 | $GLOBALS['acl_manager']['admin']['account_access'] = array( |
| 20 | 20 | 'name' => 'Deny access to user accounts', |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | 'Delete account' => 32, |
| 28 | 28 | 'change ACL Rights' => 64 |
| 29 | 29 | ) |
| 30 | -); // was already there and seems to work ralfbecker |
|
| 30 | +); // was already there and seems to work ralfbecker |
|
| 31 | 31 | |
| 32 | 32 | $GLOBALS['acl_manager']['admin']['group_access'] = array( |
| 33 | 33 | 'name' => 'Deny access to groups', |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | 'Edit group' => 16, |
| 40 | 40 | 'Delete group' => 32 |
| 41 | 41 | ) |
| 42 | -); // was already there and seems to work ralfbecker |
|
| 42 | +); // was already there and seems to work ralfbecker |
|
| 43 | 43 | |
| 44 | 44 | $GLOBALS['acl_manager']['admin']['applications_acc'] = array( |
| 45 | 45 | 'name' => 'Deny access to applications', |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | 'Register application hooks' => 16 |
| 54 | 54 | ) |
| 55 | -); // added and working ralfbecker |
|
| 55 | +); // added and working ralfbecker |
|
| 56 | 56 | |
| 57 | 57 | $GLOBALS['acl_manager']['admin']['global_categorie'] = array( |
| 58 | 58 | 'name' => 'Deny access to global categories', |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | 'Delete category' => 32, |
| 66 | 66 | 'Add sub-category' => 64 |
| 67 | 67 | ) |
| 68 | -); // added and working ralfbecker |
|
| 68 | +); // added and working ralfbecker |
|
| 69 | 69 | |
| 70 | 70 | $GLOBALS['acl_manager']['admin']['mainscreen_messa'] = array( |
| 71 | 71 | 'name' => 'Deny access to mainscreen message', |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | 'Main screen message' => 1, |
| 74 | 74 | 'Login message' => 2 |
| 75 | 75 | ) |
| 76 | -); // added and working ralfbecker |
|
| 76 | +); // added and working ralfbecker |
|
| 77 | 77 | |
| 78 | 78 | $GLOBALS['acl_manager']['admin']['current_sessions'] = array( |
| 79 | 79 | 'name' => 'Deny access to current sessions', |
@@ -83,40 +83,40 @@ discard block |
||
| 83 | 83 | 'Show session IP address' => 4, |
| 84 | 84 | 'Kill session' => 8 |
| 85 | 85 | ) |
| 86 | -); // checked and working ralfbecker |
|
| 86 | +); // checked and working ralfbecker |
|
| 87 | 87 | |
| 88 | 88 | $GLOBALS['acl_manager']['admin']['access_log_acces'] = array( |
| 89 | 89 | 'name' => 'Deny access to access log', |
| 90 | 90 | 'rights' => array( |
| 91 | 91 | 'Show access log' => 1 |
| 92 | 92 | ) |
| 93 | -); // added and working ralfbecker |
|
| 93 | +); // added and working ralfbecker |
|
| 94 | 94 | |
| 95 | 95 | $GLOBALS['acl_manager']['admin']['error_log_access'] = array( |
| 96 | 96 | 'name' => 'Deny access to error log', |
| 97 | 97 | 'rights' => array( |
| 98 | 98 | 'Show error log' => 1 |
| 99 | 99 | ) |
| 100 | -); // added and working ralfbecker |
|
| 100 | +); // added and working ralfbecker |
|
| 101 | 101 | |
| 102 | 102 | $GLOBALS['acl_manager']['admin']['asyncservice_acc'] = array( |
| 103 | 103 | 'name' => 'Deny access to asynchronous timed services', |
| 104 | 104 | 'rights' => array( |
| 105 | 105 | 'Asynchronous timed services' => 1 |
| 106 | 106 | ) |
| 107 | -); // added and working ralfbecker |
|
| 107 | +); // added and working ralfbecker |
|
| 108 | 108 | |
| 109 | 109 | $GLOBALS['acl_manager']['admin']['db_backup_access'] = array( |
| 110 | 110 | 'name' => 'Deny access to DB backup and restore', |
| 111 | 111 | 'rights' => array( |
| 112 | 112 | 'DB backup and restore' => 1 |
| 113 | 113 | ) |
| 114 | -); // added and working ralfbecker |
|
| 114 | +); // added and working ralfbecker |
|
| 115 | 115 | |
| 116 | 116 | $GLOBALS['acl_manager']['admin']['info_access'] = array( |
| 117 | 117 | 'name' => 'Deny access to phpinfo', |
| 118 | 118 | 'rights' => array( |
| 119 | 119 | 'Show phpinfo()' => 1 |
| 120 | 120 | ) |
| 121 | -); // added and working ralfbecker |
|
| 121 | +); // added and working ralfbecker |
|
| 122 | 122 | |
@@ -18,11 +18,11 @@ |
||
| 18 | 18 | parent::__construct(); |
| 19 | 19 | |
| 20 | 20 | // Field mapping |
| 21 | - $this->export_fields = array( |
|
| 21 | + $this->export_fields = array( |
|
| 22 | 22 | 'account_id' => lang('Account ID'), |
| 23 | 23 | 'account_lid' => lang('Group Name'), |
| 24 | 24 | 'account_members' => lang('Members'), |
| 25 | - ); |
|
| 25 | + ); |
|
| 26 | 26 | |
| 27 | 27 | // Custom fields - not really used in admin... |
| 28 | 28 | unset($this->export_fields['customfields']); |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | ); |
| 48 | 48 | |
| 49 | 49 | $custom = Api\Storage\Customfields::get('resources', true); |
| 50 | - foreach($custom as $name => $data) { |
|
| 50 | + foreach ($custom as $name => $data) { |
|
| 51 | 51 | $this->mapping_fields['#'.$name] = $data['label']; |
| 52 | 52 | } |
| 53 | 53 | |
@@ -14,7 +14,8 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | class infolog_wizard_export_csv extends importexport_wizard_basic_export_csv |
| 16 | 16 | { |
| 17 | - public function __construct() { |
|
| 17 | + public function __construct() |
|
| 18 | + { |
|
| 18 | 19 | parent::__construct(); |
| 19 | 20 | |
| 20 | 21 | // Field mapping |
@@ -27,7 +28,8 @@ discard block |
||
| 27 | 28 | // Custom fields |
| 28 | 29 | unset($this->export_fields['custom']); // Heading, not a real field |
| 29 | 30 | $custom = Api\Storage\Customfields::get('infolog', true); |
| 30 | - foreach($custom as $name => $data) { |
|
| 31 | + foreach($custom as $name => $data) |
|
| 32 | + { |
|
| 31 | 33 | $this->export_fields['#'.$name] = $data['label']; |
| 32 | 34 | } |
| 33 | 35 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @param array $data =array() default parm from parent class, no real parameters |
| 26 | 26 | */ |
| 27 | - function __construct($data=array()) |
|
| 27 | + function __construct($data = array()) |
|
| 28 | 28 | { |
| 29 | 29 | admin_cmd::__construct($data); |
| 30 | 30 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @param boolean $check_only =false only run the checks (and throw the exceptions), but not the command itself |
| 36 | 36 | * @return string success message |
| 37 | 37 | */ |
| 38 | - protected function exec($check_only=false) |
|
| 38 | + protected function exec($check_only = false) |
|
| 39 | 39 | { |
| 40 | 40 | if ($check_only) return true; |
| 41 | 41 | |
@@ -37,7 +37,10 @@ |
||
| 37 | 37 | */ |
| 38 | 38 | protected function exec($check_only=false) |
| 39 | 39 | { |
| 40 | - if ($check_only) return true; |
|
| 40 | + if ($check_only) |
|
| 41 | + { |
|
| 42 | + return true; |
|
| 43 | + } |
|
| 41 | 44 | |
| 42 | 45 | admin_cmd::_instanciate_accounts(); |
| 43 | 46 | |
@@ -20,7 +20,6 @@ discard block |
||
| 20 | 20 | /** |
| 21 | 21 | * Constructor |
| 22 | 22 | * |
| 23 | - * @param array $data=array() default parm from parent class, no real parameters |
|
| 24 | 23 | */ |
| 25 | 24 | function __construct($data=array()) |
| 26 | 25 | { |
@@ -30,7 +29,7 @@ discard block |
||
| 30 | 29 | /** |
| 31 | 30 | * give or remove run rights from a given account and application |
| 32 | 31 | * |
| 33 | - * @param boolean $check_only=false only run the checks (and throw the exceptions), but not the command itself |
|
| 32 | + * @param boolean $check_only only run the checks (and throw the exceptions), but not the command itself |
|
| 34 | 33 | * @return string success message |
| 35 | 34 | */ |
| 36 | 35 | protected function exec($check_only=false) |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | if (($f = $this->db_backup->fopen_backup())) |
| 29 | 29 | { |
| 30 | 30 | $this->db_backup->backup($f); |
| 31 | - if(is_resource($f)) |
|
| 31 | + if (is_resource($f)) |
|
| 32 | 32 | fclose($f); |
| 33 | 33 | /* Remove old backups. */ |
| 34 | 34 | $this->db_backup->housekeeping(); |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | function index() |
| 42 | 42 | { |
| 43 | 43 | $tpl_root = EGW_SERVER_ROOT.'/setup/templates/default'; |
| 44 | - $self = $GLOBALS['egw']->link('/index.php',array('menuaction'=>'admin.admin_db_backup.index')); |
|
| 44 | + $self = $GLOBALS['egw']->link('/index.php', array('menuaction'=>'admin.admin_db_backup.index')); |
|
| 45 | 45 | Api\Translation::add_app('setup'); |
| 46 | 46 | Api\Header\ContentSecurityPolicy::add('script-src', 'unsafe-inline'); |
| 47 | 47 | |
@@ -29,7 +29,9 @@ |
||
| 29 | 29 | { |
| 30 | 30 | $this->db_backup->backup($f); |
| 31 | 31 | if(is_resource($f)) |
| 32 | - fclose($f); |
|
| 32 | + { |
|
| 33 | + fclose($f); |
|
| 34 | + } |
|
| 33 | 35 | /* Remove old backups. */ |
| 34 | 36 | $this->db_backup->housekeeping(); |
| 35 | 37 | } |
@@ -18,20 +18,20 @@ |
||
| 18 | 18 | parent::__construct(); |
| 19 | 19 | |
| 20 | 20 | // Field mapping |
| 21 | - $this->export_fields = array( |
|
| 21 | + $this->export_fields = array( |
|
| 22 | 22 | 'account_id' => lang('Account ID'), |
| 23 | - 'account_lid' => lang('LoginID'), |
|
| 24 | - 'account_firstname' => lang('First Name'), |
|
| 25 | - 'account_lastname' => lang('Last Name'), |
|
| 26 | - 'account_email' => lang('email'), |
|
| 27 | - 'account_pwd' => lang('Password'), |
|
| 28 | - 'account_status' => lang('Status'), |
|
| 29 | - 'account_primary_group' => lang('Primary Group'), |
|
| 30 | - 'account_groups' => lang('Groups'), |
|
| 31 | - 'account_expires' => lang('Expires'), |
|
| 32 | - 'account_lastlogin' => lang('Last login'), |
|
| 33 | - 'account_lastpwd_change'=> lang('Last password change'), |
|
| 34 | - ); |
|
| 23 | + 'account_lid' => lang('LoginID'), |
|
| 24 | + 'account_firstname' => lang('First Name'), |
|
| 25 | + 'account_lastname' => lang('Last Name'), |
|
| 26 | + 'account_email' => lang('email'), |
|
| 27 | + 'account_pwd' => lang('Password'), |
|
| 28 | + 'account_status' => lang('Status'), |
|
| 29 | + 'account_primary_group' => lang('Primary Group'), |
|
| 30 | + 'account_groups' => lang('Groups'), |
|
| 31 | + 'account_expires' => lang('Expires'), |
|
| 32 | + 'account_lastlogin' => lang('Last login'), |
|
| 33 | + 'account_lastpwd_change'=> lang('Last password change'), |
|
| 34 | + ); |
|
| 35 | 35 | |
| 36 | 36 | // Custom fields - not really used in admin... |
| 37 | 37 | unset($this->export_fields['customfields']); |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | ); |
| 48 | 48 | |
| 49 | 49 | $custom = Api\Storage\Customfields::get('resources', true); |
| 50 | - foreach($custom as $name => $data) { |
|
| 50 | + foreach ($custom as $name => $data) { |
|
| 51 | 51 | $this->mapping_fields['#'.$name] = $data['label']; |
| 52 | 52 | } |
| 53 | 53 | |
@@ -14,7 +14,8 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | class infolog_wizard_export_csv extends importexport_wizard_basic_export_csv |
| 16 | 16 | { |
| 17 | - public function __construct() { |
|
| 17 | + public function __construct() |
|
| 18 | + { |
|
| 18 | 19 | parent::__construct(); |
| 19 | 20 | |
| 20 | 21 | // Field mapping |
@@ -27,7 +28,8 @@ discard block |
||
| 27 | 28 | // Custom fields |
| 28 | 29 | unset($this->export_fields['custom']); // Heading, not a real field |
| 29 | 30 | $custom = Api\Storage\Customfields::get('infolog', true); |
| 30 | - foreach($custom as $name => $data) { |
|
| 31 | + foreach($custom as $name => $data) |
|
| 32 | + { |
|
| 31 | 33 | $this->export_fields['#'.$name] = $data['label']; |
| 32 | 34 | } |
| 33 | 35 | } |
@@ -21,13 +21,13 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @param egw_record $_definition |
| 23 | 23 | */ |
| 24 | - public function export( $_stream, importexport_definition $_definition) { |
|
| 24 | + public function export($_stream, importexport_definition $_definition) { |
|
| 25 | 25 | $options = $_definition->plugin_options; |
| 26 | 26 | |
| 27 | 27 | $query = array( |
| 28 | 28 | 'type' => 'accounts', |
| 29 | 29 | ); |
| 30 | - if($options['selection']['group_id']) { |
|
| 30 | + if ($options['selection']['group_id']) { |
|
| 31 | 31 | $query['type'] = (int)$options['selection']['group_id']; |
| 32 | 32 | } |
| 33 | 33 | $selection = $GLOBALS['egw']->accounts->search($query); |
@@ -43,14 +43,14 @@ discard block |
||
| 43 | 43 | // $_record is an array, that's what search() returns |
| 44 | 44 | foreach ($selection as $_record) { |
| 45 | 45 | $record = new admin_egw_user_record($_record); |
| 46 | - if($options['convert']) { |
|
| 46 | + if ($options['convert']) { |
|
| 47 | 47 | $never_expires = ($record->account_expires == -1); |
| 48 | 48 | importexport_export_csv::convert($record, admin_egw_user_record::$types, 'admin', $lookups); |
| 49 | - if($never_expires) $record->account_expires = 'never'; // Has to be 'never' for admin_cmd_edit_user to parse it |
|
| 49 | + if ($never_expires) $record->account_expires = 'never'; // Has to be 'never' for admin_cmd_edit_user to parse it |
|
| 50 | 50 | } else { |
| 51 | 51 | // Implode arrays, so they don't say 'Array' |
| 52 | - foreach($record->get_record_array() as $key => $value) { |
|
| 53 | - if(is_array($value)) $record->$key = implode(',', $value); |
|
| 52 | + foreach ($record->get_record_array() as $key => $value) { |
|
| 53 | + if (is_array($value)) $record->$key = implode(',', $value); |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | $export_object->export_record($record); |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | /** |
| 26 | 26 | * Exports records as defined in $_definition |
| 27 | 27 | * |
| 28 | - * @param egw_record $_definition |
|
| 28 | + * @param importexport_definition $_definition |
|
| 29 | 29 | */ |
| 30 | 30 | public function export( $_stream, importexport_definition $_definition) { |
| 31 | 31 | $options = $_definition->plugin_options; |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | * return html for options. |
| 133 | 133 | * this way the plugin has all opportunities for options tab |
| 134 | 134 | * |
| 135 | - * @return string html |
|
| 135 | + * @return boolean html |
|
| 136 | 136 | */ |
| 137 | 137 | public function get_options_etpl() { |
| 138 | 138 | return false; |
@@ -125,8 +125,8 @@ |
||
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | public static function get_mimetype() { |
| 128 | - return 'text/csv'; |
|
| 129 | - } |
|
| 128 | + return 'text/csv'; |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | 131 | /** |
| 132 | 132 | * return html for options. |
@@ -14,14 +14,16 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * Export users plugin |
| 16 | 16 | */ |
| 17 | -class admin_export_users_csv implements importexport_iface_export_plugin { |
|
| 17 | +class admin_export_users_csv implements importexport_iface_export_plugin |
|
| 18 | +{ |
|
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * Exports records as defined in $_definition |
| 21 | 22 | * |
| 22 | 23 | * @param egw_record $_definition |
| 23 | 24 | */ |
| 24 | - public function export( $_stream, importexport_definition $_definition) { |
|
| 25 | + public function export( $_stream, importexport_definition $_definition) |
|
| 26 | + { |
|
| 25 | 27 | $options = $_definition->plugin_options; |
| 26 | 28 | |
| 27 | 29 | $selection = array(); |
@@ -29,7 +31,8 @@ discard block |
||
| 29 | 31 | $query = array( |
| 30 | 32 | 'type' => 'accounts', |
| 31 | 33 | ); |
| 32 | - if($options['selection']['group_id']) { |
|
| 34 | + if($options['selection']['group_id']) |
|
| 35 | + { |
|
| 33 | 36 | $query['type'] = (int)$options['selection']['group_id']; |
| 34 | 37 | } |
| 35 | 38 | $selection = $GLOBALS['egw']->accounts->search($query); |
@@ -43,16 +46,28 @@ discard block |
||
| 43 | 46 | ); |
| 44 | 47 | |
| 45 | 48 | // $_record is an array, that's what search() returns |
| 46 | - foreach ($selection as $_record) { |
|
| 49 | + foreach ($selection as $_record) |
|
| 50 | + { |
|
| 47 | 51 | $record = new admin_egw_user_record($_record); |
| 48 | - if($options['convert']) { |
|
| 52 | + if($options['convert']) |
|
| 53 | + { |
|
| 49 | 54 | $never_expires = ($record->account_expires == -1); |
| 50 | 55 | importexport_export_csv::convert($record, admin_egw_user_record::$types, 'admin', $lookups); |
| 51 | - if($never_expires) $record->account_expires = 'never'; // Has to be 'never' for admin_cmd_edit_user to parse it |
|
| 52 | - } else { |
|
| 56 | + if($never_expires) |
|
| 57 | + { |
|
| 58 | + $record->account_expires = 'never'; |
|
| 59 | + } |
|
| 60 | + // Has to be 'never' for admin_cmd_edit_user to parse it |
|
| 61 | + } |
|
| 62 | + else |
|
| 63 | + { |
|
| 53 | 64 | // Implode arrays, so they don't say 'Array' |
| 54 | - foreach($record->get_record_array() as $key => $value) { |
|
| 55 | - if(is_array($value)) $record->$key = implode(',', $value); |
|
| 65 | + foreach($record->get_record_array() as $key => $value) |
|
| 66 | + { |
|
| 67 | + if(is_array($value)) |
|
| 68 | + { |
|
| 69 | + $record->$key = implode(',', $value); |
|
| 70 | + } |
|
| 56 | 71 | } |
| 57 | 72 | } |
| 58 | 73 | $export_object->export_record($record); |
@@ -65,7 +80,8 @@ discard block |
||
| 65 | 80 | * |
| 66 | 81 | * @return string name |
| 67 | 82 | */ |
| 68 | - public static function get_name() { |
|
| 83 | + public static function get_name() |
|
| 84 | + { |
|
| 69 | 85 | return lang('User CSV export'); |
| 70 | 86 | } |
| 71 | 87 | |
@@ -74,7 +90,8 @@ discard block |
||
| 74 | 90 | * |
| 75 | 91 | * @return string descriprion |
| 76 | 92 | */ |
| 77 | - public static function get_description() { |
|
| 93 | + public static function get_description() |
|
| 94 | + { |
|
| 78 | 95 | return lang("Exports users into a CSV File. "); |
| 79 | 96 | } |
| 80 | 97 | |
@@ -83,11 +100,13 @@ discard block |
||
| 83 | 100 | * |
| 84 | 101 | * @return string suffix |
| 85 | 102 | */ |
| 86 | - public static function get_filesuffix() { |
|
| 103 | + public static function get_filesuffix() |
|
| 104 | + { |
|
| 87 | 105 | return 'csv'; |
| 88 | 106 | } |
| 89 | 107 | |
| 90 | - public static function get_mimetype() { |
|
| 108 | + public static function get_mimetype() |
|
| 109 | + { |
|
| 91 | 110 | return 'text/csv'; |
| 92 | 111 | } |
| 93 | 112 | |
@@ -97,7 +116,8 @@ discard block |
||
| 97 | 116 | * |
| 98 | 117 | * @return string html |
| 99 | 118 | */ |
| 100 | - public function get_options_etpl() { |
|
| 119 | + public function get_options_etpl() |
|
| 120 | + { |
|
| 101 | 121 | return false; |
| 102 | 122 | } |
| 103 | 123 | |
@@ -105,7 +125,8 @@ discard block |
||
| 105 | 125 | * returns slectors of this plugin via xajax |
| 106 | 126 | * |
| 107 | 127 | */ |
| 108 | - public function get_selectors_etpl() { |
|
| 128 | + public function get_selectors_etpl() |
|
| 129 | + { |
|
| 109 | 130 | return array( |
| 110 | 131 | 'name' => 'admin.export_users_csv_selectors', |
| 111 | 132 | 'preserv' => array('no_error_for_all'), |
@@ -239,11 +239,11 @@ |
||
| 239 | 239 | unset($postdata[$name]); |
| 240 | 240 | } |
| 241 | 241 | $opts = array('http' => |
| 242 | - array( |
|
| 243 | - 'method' => 'POST', |
|
| 244 | - 'header' => 'Content-type: application/x-www-form-urlencoded', |
|
| 245 | - 'content' => http_build_query($postdata), |
|
| 246 | - ) |
|
| 242 | + array( |
|
| 243 | + 'method' => 'POST', |
|
| 244 | + 'header' => 'Content-type: application/x-www-form-urlencoded', |
|
| 245 | + 'content' => http_build_query($postdata), |
|
| 246 | + ) |
|
| 247 | 247 | ); |
| 248 | 248 | $url = $remote['remote_url'].'/admin/remote.php?domain='.urlencode($remote['remote_domain']).'&secret='.urlencode($secret); |
| 249 | 249 | //echo "sending command to $url\n"; _debug_array($opts); |
@@ -183,7 +183,10 @@ discard block |
||
| 183 | 183 | { |
| 184 | 184 | $ret = $this->remote_exec($dry_run); |
| 185 | 185 | } |
| 186 | - if (is_null($this->status)) $this->status = admin_cmd::successful; |
|
| 186 | + if (is_null($this->status)) |
|
| 187 | + { |
|
| 188 | + $this->status = admin_cmd::successful; |
|
| 189 | + } |
|
| 187 | 190 | } |
| 188 | 191 | catch (Exception $e) { |
| 189 | 192 | $this->error = $e->getMessage(); |
@@ -277,7 +280,10 @@ discard block |
||
| 277 | 280 | */ |
| 278 | 281 | function delete() |
| 279 | 282 | { |
| 280 | - if ($this->status != admin_cmd::scheduled) return false; |
|
| 283 | + if ($this->status != admin_cmd::scheduled) |
|
| 284 | + { |
|
| 285 | + return false; |
|
| 286 | + } |
|
| 281 | 287 | |
| 282 | 288 | $this->status = admin_cmd::deleted; |
| 283 | 289 | |
@@ -303,7 +309,10 @@ discard block |
||
| 303 | 309 | { |
| 304 | 310 | $this->modified = time(); |
| 305 | 311 | $this->modifier = $set_modifier ? $GLOBALS['egw_info']['user']['account_id'] : 0; |
| 306 | - if ($set_modifier) $this->modifier_email = admin_cmd::user_email(); |
|
| 312 | + if ($set_modifier) |
|
| 313 | + { |
|
| 314 | + $this->modifier_email = admin_cmd::user_email(); |
|
| 315 | + } |
|
| 307 | 316 | } |
| 308 | 317 | if (version_compare(PHP_VERSION,'5.1.2','>')) |
| 309 | 318 | { |
@@ -411,10 +420,13 @@ discard block |
||
| 411 | 420 | } |
| 412 | 421 | $cmd = new $class($data); |
| 413 | 422 | |
| 414 | - if ($cmd instanceof admin_cmd) // dont allow others classes to be executed that way! |
|
| 423 | + if ($cmd instanceof admin_cmd) |
|
| 424 | + { |
|
| 425 | + // dont allow others classes to be executed that way! |
|
| 415 | 426 | { |
| 416 | 427 | return $cmd; |
| 417 | 428 | } |
| 429 | + } |
|
| 418 | 430 | throw new Api\Exception\WrongParameter(lang('%1 is no command!',$class),0); |
| 419 | 431 | } |
| 420 | 432 | |
@@ -564,7 +576,10 @@ discard block |
||
| 564 | 576 | } |
| 565 | 577 | } |
| 566 | 578 | unset($vars['data']); |
| 567 | - if ($this->data) $vars = array_merge($this->data,$vars); |
|
| 579 | + if ($this->data) |
|
| 580 | + { |
|
| 581 | + $vars = array_merge($this->data,$vars); |
|
| 582 | + } |
|
| 568 | 583 | |
| 569 | 584 | return $vars; |
| 570 | 585 | } |
@@ -583,10 +598,13 @@ discard block |
||
| 583 | 598 | admin_cmd::_instanciate_acl($this->creator); |
| 584 | 599 | // todo: check only if and with $this->creator |
| 585 | 600 | if (!admin_cmd::$acl->check('run',1,'admin') && // creator is no longer admin |
| 586 | - $extra_acl && $extra_deny && admin_cmd::$acl->check($extra_acl,$extra_deny,'admin')) // creator is explicitly forbidden to do something |
|
| 601 | + $extra_acl && $extra_deny && admin_cmd::$acl->check($extra_acl,$extra_deny,'admin')) |
|
| 602 | + { |
|
| 603 | + // creator is explicitly forbidden to do something |
|
| 587 | 604 | { |
| 588 | 605 | throw new Api\Exception\NoPermission\Admin(); |
| 589 | 606 | } |
| 607 | + } |
|
| 590 | 608 | } |
| 591 | 609 | } |
| 592 | 610 | |
@@ -603,11 +621,14 @@ discard block |
||
| 603 | 621 | { |
| 604 | 622 | if (!isset($GLOBALS['egw_info']['apps'][$name])) |
| 605 | 623 | { |
| 606 | - foreach($GLOBALS['egw_info']['apps'] as $app => $data) // check against title and localised name |
|
| 624 | + foreach($GLOBALS['egw_info']['apps'] as $app => $data) |
|
| 625 | + { |
|
| 626 | + // check against title and localised name |
|
| 607 | 627 | { |
| 608 | 628 | if (!strcasecmp($name,$data['title']) || !strcasecmp($name,lang($app))) |
| 609 | 629 | { |
| 610 | 630 | $apps[$key] = $name = $app; |
| 631 | + } |
|
| 611 | 632 | break; |
| 612 | 633 | } |
| 613 | 634 | } |
@@ -642,7 +663,11 @@ discard block |
||
| 642 | 663 | { |
| 643 | 664 | throw new Api\Exception\WrongUserinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only_user?lang('user'):lang('group')),15); |
| 644 | 665 | } |
| 645 | - if ($type == 2 && $id > 0) $id = -$id; // groups use negative id's internally, fix it, if user given the wrong sign |
|
| 666 | + if ($type == 2 && $id > 0) |
|
| 667 | + { |
|
| 668 | + $id = -$id; |
|
| 669 | + } |
|
| 670 | + // groups use negative id's internally, fix it, if user given the wrong sign |
|
| 646 | 671 | |
| 647 | 672 | return $id; |
| 648 | 673 | } |
@@ -658,7 +683,10 @@ discard block |
||
| 658 | 683 | */ |
| 659 | 684 | static function parse_accounts($accounts,$allow_only_user=null) |
| 660 | 685 | { |
| 661 | - if (!$accounts) return null; |
|
| 686 | + if (!$accounts) |
|
| 687 | + { |
|
| 688 | + return null; |
|
| 689 | + } |
|
| 662 | 690 | |
| 663 | 691 | $ids = array(); |
| 664 | 692 | foreach(is_array($accounts) ? $accounts : explode(',',$accounts) as $account) |
@@ -677,9 +705,12 @@ discard block |
||
| 677 | 705 | */ |
| 678 | 706 | static function parse_date($date) |
| 679 | 707 | { |
| 680 | - if (!is_numeric($date)) // we allow to input a timestamp |
|
| 708 | + if (!is_numeric($date)) |
|
| 709 | + { |
|
| 710 | + // we allow to input a timestamp |
|
| 681 | 711 | { |
| 682 | 712 | $datein = $date; |
| 713 | + } |
|
| 683 | 714 | // convert german DD.MM.YYYY format into ISO YYYY-MM-DD format |
| 684 | 715 | $date = preg_replace('/^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$/','\3-\2-\1',$date); |
| 685 | 716 | |
@@ -837,10 +868,13 @@ discard block |
||
| 837 | 868 | return false; // no schduled command, no need to setup the job |
| 838 | 869 | } |
| 839 | 870 | $next = $jobs[0]; |
| 840 | - if (($time = $next['scheduled']) < time()) // should run immediatly |
|
| 871 | + if (($time = $next['scheduled']) < time()) |
|
| 872 | + { |
|
| 873 | + // should run immediatly |
|
| 841 | 874 | { |
| 842 | 875 | return admin_cmd::run_queued_jobs(); |
| 843 | 876 | } |
| 877 | + } |
|
| 844 | 878 | $async = new Api\Asyncservice(); |
| 845 | 879 | |
| 846 | 880 | // we cant use this class as callback, as it's abstract and ExecMethod used by the async service instanciated the class! |
@@ -944,10 +978,13 @@ discard block |
||
| 944 | 978 | { |
| 945 | 979 | admin_cmd::_instanciate_remote(); |
| 946 | 980 | |
| 947 | - if ($data['install_id'] && $data['config_passwd']) // calculate hash |
|
| 981 | + if ($data['install_id'] && $data['config_passwd']) |
|
| 982 | + { |
|
| 983 | + // calculate hash |
|
| 948 | 984 | { |
| 949 | 985 | $data['remote_hash'] = self::remote_hash($data['install_id'],$data['config_passwd']); |
| 950 | 986 | } |
| 987 | + } |
|
| 951 | 988 | elseif (!$data['remote_hash'] && !($data['install_id'] && $data['config_passwd'])) |
| 952 | 989 | { |
| 953 | 990 | throw new Api\Exception\WrongUserinput(lang('Either Install ID AND Api\Config password needed OR the remote hash!')); |
@@ -981,7 +1018,10 @@ discard block |
||
| 981 | 1018 | { |
| 982 | 1019 | throw new Api\Exception\WrongParameter(empty($config_passwd)?'Empty Api\Config password':'install_id no md5 hash'); |
| 983 | 1020 | } |
| 984 | - if (!self::is_md5($config_passwd)) $config_passwd = md5($config_passwd); |
|
| 1021 | + if (!self::is_md5($config_passwd)) |
|
| 1022 | + { |
|
| 1023 | + $config_passwd = md5($config_passwd); |
|
| 1024 | + } |
|
| 985 | 1025 | |
| 986 | 1026 | return md5($config_passwd.$install_id); |
| 987 | 1027 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | /** |
| 101 | 101 | * Executes the command |
| 102 | 102 | * |
| 103 | - * @param boolean $check_only=false only run the checks (and throw the exceptions), but not the command itself |
|
| 103 | + * @param boolean $check_only only run the checks (and throw the exceptions), but not the command itself |
|
| 104 | 104 | * @return string success message |
| 105 | 105 | * @throws Exception() |
| 106 | 106 | */ |
@@ -141,10 +141,10 @@ discard block |
||
| 141 | 141 | * |
| 142 | 142 | * The command will be written to the database queue, incl. its scheduled start time or execution status |
| 143 | 143 | * |
| 144 | - * @param int $time=null timestamp to run the command or null to run it immediatly |
|
| 145 | - * @param boolean $set_modifier=null should the current user be set as modifier, default true |
|
| 146 | - * @param booelan $skip_checks=false do not yet run the checks for a scheduled command |
|
| 147 | - * @param boolean $dry_run=false only run checks, NOT command itself |
|
| 144 | + * @param boolean $set_modifier should the current user be set as modifier, default true |
|
| 145 | + * @param booelan $skip_checks do not yet run the checks for a scheduled command |
|
| 146 | + * @param boolean $dry_run only run checks, NOT command itself |
|
| 147 | + * @param integer $time |
|
| 148 | 148 | * @return mixed return value of the command |
| 149 | 149 | * @throws Exceptions on error |
| 150 | 150 | */ |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | /** |
| 283 | 283 | * Saving the object to the database |
| 284 | 284 | * |
| 285 | - * @param boolean $set_modifier=true set the current user as modifier or 0 (= run by the system) |
|
| 285 | + * @param boolean $set_modifier set the current user as modifier or 0 (= run by the system) |
|
| 286 | 286 | * @return boolean true on success, false otherwise |
| 287 | 287 | */ |
| 288 | 288 | function save($set_modifier=true) |
@@ -438,15 +438,12 @@ discard block |
||
| 438 | 438 | * |
| 439 | 439 | * @static |
| 440 | 440 | * @param array/string $criteria array of key and data cols, OR a SQL query (content for WHERE), fully quoted (!) |
| 441 | - * @param boolean/string/array $only_keys=true True returns only keys, False returns all cols. or |
|
| 441 | + * @param boolean/string/array $only_keys True returns only keys, False returns all cols. or |
|
| 442 | 442 | * comma seperated list or array of columns to return |
| 443 | 443 | * @param string $order_by='' fieldnames + {ASC|DESC} separated by colons ',', can also contain a GROUP BY (if it contains ORDER BY) |
| 444 | 444 | * @param string/array $extra_cols='' string or array of strings to be added to the SELECT, eg. "count(*) as num" |
| 445 | 445 | * @param string $wildcard='' appended befor and after each criteria |
| 446 | - * @param boolean $empty=false False=empty criteria are ignored in query, True=empty have to be empty in row |
|
| 447 | - * @param string $op='AND' defaults to 'AND', can be set to 'OR' too, then criteria's are OR'ed together |
|
| 448 | - * @param mixed $start=false if != false, return only maxmatch rows begining with start, or array($start,$num), or 'UNION' for a part of a union query |
|
| 449 | - * @param array $filter=null if set (!=null) col-data pairs, to be and-ed (!) into the query without wildcards |
|
| 446 | + * @param array $filter if set (!=null) col-data pairs, to be and-ed (!) into the query without wildcards |
|
| 450 | 447 | * @return array |
| 451 | 448 | */ |
| 452 | 449 | static function &search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null) |
@@ -567,8 +564,8 @@ discard block |
||
| 567 | 564 | /** |
| 568 | 565 | * Check if the creator is still admin and has the neccessary admin rights |
| 569 | 566 | * |
| 570 | - * @param string $extra_acl=null further admin rights to check, eg. 'account_access' |
|
| 571 | - * @param int $extra_deny=null further admin rights to check, eg. 16 = deny edit accounts |
|
| 567 | + * @param string $extra_acl further admin rights to check, eg. 'account_access' |
|
| 568 | + * @param integer $extra_deny further admin rights to check, eg. 16 = deny edit accounts |
|
| 572 | 569 | * @throws egw_exception_no_admin |
| 573 | 570 | */ |
| 574 | 571 | protected function _check_admin($extra_acl=null,$extra_deny=null) |
@@ -619,7 +616,7 @@ discard block |
||
| 619 | 616 | * parse account name or id |
| 620 | 617 | * |
| 621 | 618 | * @param string/int $account account_id or account_lid |
| 622 | - * @param boolean $allow_only_user=null true=only user, false=only groups, default both |
|
| 619 | + * @param boolean $allow_only_user true=only user, false=only groups, default both |
|
| 623 | 620 | * @return int/array account_id |
| 624 | 621 | * @throws egw_exception_wrong_userinput(lang("Unknown account: %1 !!!",$account),15); |
| 625 | 622 | * @throws egw_exception_wrong_userinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only_user?lang('user'):lang('group')),15); |
@@ -646,7 +643,7 @@ discard block |
||
| 646 | 643 | * parse account names or ids |
| 647 | 644 | * |
| 648 | 645 | * @param string/int/array $accounts array or comma-separated account_id's or account_lid's |
| 649 | - * @param boolean $allow_only_user=null true=only user, false=only groups, default both |
|
| 646 | + * @param boolean $allow_only_user true=only user, false=only groups, default both |
|
| 650 | 647 | * @return array of account_id's or null if none specified |
| 651 | 648 | * @throws egw_exception_wrong_userinput(lang("Unknown account: %1 !!!",$account),15); |
| 652 | 649 | * @throws egw_exception_wrong_userinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only?lang('user'):lang('group')),15); |
@@ -690,7 +687,7 @@ discard block |
||
| 690 | 687 | * Parse a boolean value |
| 691 | 688 | * |
| 692 | 689 | * @param string|boolean|int $value |
| 693 | - * @param boolean $default=null |
|
| 690 | + * @param boolean $default |
|
| 694 | 691 | * @return boolean |
| 695 | 692 | * @throws egw_exception_wrong_userinput(lang('Invalid value "%1" use yes or no!',$value),998); |
| 696 | 693 | */ |
@@ -759,7 +756,7 @@ discard block |
||
| 759 | 756 | * Instanciated acl class |
| 760 | 757 | * |
| 761 | 758 | * @todo acl class instanciation for setup |
| 762 | - * @param int $account=null account_id the class needs to be instanciated for, default need only account-independent methods |
|
| 759 | + * @param int $account account_id the class needs to be instanciated for, default need only account-independent methods |
|
| 763 | 760 | * @throws egw_exception_assertion_failed(lang('%1 class not instanciated','acl'),999); |
| 764 | 761 | */ |
| 765 | 762 | protected function _instanciate_acl($account=null) |
@@ -920,7 +917,7 @@ discard block |
||
| 920 | 917 | * Read data of a remote instance |
| 921 | 918 | * |
| 922 | 919 | * @param array/int $keys |
| 923 | - * @return array |
|
| 920 | + * @return string |
|
| 924 | 921 | */ |
| 925 | 922 | static function read_remote($keys) |
| 926 | 923 | { |
@@ -1000,7 +997,7 @@ discard block |
||
| 1000 | 997 | * Check if string is a md5 hash (32 chars of 0-9 or a-f) |
| 1001 | 998 | * |
| 1002 | 999 | * @param string $str |
| 1003 | - * @return boolean |
|
| 1000 | + * @return integer |
|
| 1004 | 1001 | */ |
| 1005 | 1002 | static function is_md5($str) |
| 1006 | 1003 | { |
@@ -1046,7 +1043,6 @@ discard block |
||
| 1046 | 1043 | /** |
| 1047 | 1044 | * Return a rand string, eg. to generate passwords |
| 1048 | 1045 | * |
| 1049 | - * @param int $len=16 |
|
| 1050 | 1046 | * @return string |
| 1051 | 1047 | */ |
| 1052 | 1048 | static function randomstring($len=16) |
@@ -20,14 +20,14 @@ discard block |
||
| 20 | 20 | const successful = 2; |
| 21 | 21 | const failed = 3; |
| 22 | 22 | const pending = 4; |
| 23 | - const queued = 5; // command waits to be fetched from remote |
|
| 23 | + const queued = 5; // command waits to be fetched from remote |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Status which stil need passwords available |
| 27 | 27 | * |
| 28 | 28 | * @var array |
| 29 | 29 | */ |
| 30 | - static $require_pw_stati = array(self::scheduled,self::pending,self::queued); |
|
| 30 | + static $require_pw_stati = array(self::scheduled, self::pending, self::queued); |
|
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * The status of the command, one of either scheduled, successful, failed or deleted |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @return string success message |
| 105 | 105 | * @throws Exception() |
| 106 | 106 | */ |
| 107 | - protected abstract function exec($check_only=false); |
|
| 107 | + protected abstract function exec($check_only = false); |
|
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | 110 | * Return a title / string representation for a given command, eg. to display it |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | $this->type = get_class($this); |
| 131 | 131 | |
| 132 | - foreach($data as $name => $value) |
|
| 132 | + foreach ($data as $name => $value) |
|
| 133 | 133 | { |
| 134 | 134 | $this->$name = $name == 'data' && !is_array($value) ? json_php_unserialize($value) : $value; |
| 135 | 135 | } |
@@ -148,13 +148,13 @@ discard block |
||
| 148 | 148 | * @return mixed return value of the command |
| 149 | 149 | * @throws Exceptions on error |
| 150 | 150 | */ |
| 151 | - function run($time=null,$set_modifier=true,$skip_checks=false,$dry_run=false) |
|
| 151 | + function run($time = null, $set_modifier = true, $skip_checks = false, $dry_run = false) |
|
| 152 | 152 | { |
| 153 | 153 | if (!is_null($time)) |
| 154 | 154 | { |
| 155 | 155 | $this->scheduled = $time; |
| 156 | 156 | $this->status = admin_cmd::scheduled; |
| 157 | - $ret = lang('Command scheduled to run at %1',date('Y-m-d H:i',$time)); |
|
| 157 | + $ret = lang('Command scheduled to run at %1', date('Y-m-d H:i', $time)); |
|
| 158 | 158 | // running the checks of the arguments for local commands, if not explicitly requested to not run them |
| 159 | 159 | if (!$this->remote_id && !$skip_checks) |
| 160 | 160 | { |
@@ -217,21 +217,21 @@ discard block |
||
| 217 | 217 | { |
| 218 | 218 | if (!($remote = $this->read_remote($this->remote_id))) |
| 219 | 219 | { |
| 220 | - throw new egw_exception_wrong_userinput(lang('Invalid remote id or name "%1"!',$id_or_name),997); |
|
| 220 | + throw new egw_exception_wrong_userinput(lang('Invalid remote id or name "%1"!', $id_or_name), 997); |
|
| 221 | 221 | } |
| 222 | 222 | if (!$this->uid) |
| 223 | 223 | { |
| 224 | - $this->save(); // to get the uid |
|
| 224 | + $this->save(); // to get the uid |
|
| 225 | 225 | } |
| 226 | 226 | $secret = md5($this->uid.$remote['remote_hash']); |
| 227 | 227 | |
| 228 | 228 | $postdata = $this->as_array(); |
| 229 | 229 | if (is_object($GLOBALS['egw']->translation)) |
| 230 | 230 | { |
| 231 | - $postdata = $GLOBALS['egw']->translation->convert($postdata,$GLOBALS['egw']->translation->charset(),'utf-8'); |
|
| 231 | + $postdata = $GLOBALS['egw']->translation->convert($postdata, $GLOBALS['egw']->translation->charset(), 'utf-8'); |
|
| 232 | 232 | } |
| 233 | 233 | // dont send the id's which have no meaning on the remote install |
| 234 | - foreach(array('id','creator','modifier','requested','remote_id') as $name) |
|
| 234 | + foreach (array('id', 'creator', 'modifier', 'requested', 'remote_id') as $name) |
|
| 235 | 235 | { |
| 236 | 236 | unset($postdata[$name]); |
| 237 | 237 | } |
@@ -256,11 +256,11 @@ discard block |
||
| 256 | 256 | } |
| 257 | 257 | if (is_object($GLOBALS['egw']->translation)) |
| 258 | 258 | { |
| 259 | - $message = $GLOBALS['egw']->translation->convert($message,'utf-8'); |
|
| 259 | + $message = $GLOBALS['egw']->translation->convert($message, 'utf-8'); |
|
| 260 | 260 | } |
| 261 | - if (is_string($message) && preg_match('/^([0-9]+) (.*)$/',$message,$matches)) |
|
| 261 | + if (is_string($message) && preg_match('/^([0-9]+) (.*)$/', $message, $matches)) |
|
| 262 | 262 | { |
| 263 | - throw new egw_exception($matches[2],(int)$matches[1]); |
|
| 263 | + throw new egw_exception($matches[2], (int)$matches[1]); |
|
| 264 | 264 | } |
| 265 | 265 | return $message; |
| 266 | 266 | } |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | * @param boolean $set_modifier=true set the current user as modifier or 0 (= run by the system) |
| 286 | 286 | * @return boolean true on success, false otherwise |
| 287 | 287 | */ |
| 288 | - function save($set_modifier=true) |
|
| 288 | + function save($set_modifier = true) |
|
| 289 | 289 | { |
| 290 | 290 | admin_cmd::_instanciate_sql(); |
| 291 | 291 | |
@@ -300,13 +300,13 @@ discard block |
||
| 300 | 300 | $this->modifier = $set_modifier ? $GLOBALS['egw_info']['user']['account_id'] : 0; |
| 301 | 301 | if ($set_modifier) $this->modifier_email = admin_cmd::user_email(); |
| 302 | 302 | } |
| 303 | - if (version_compare(PHP_VERSION,'5.1.2','>')) |
|
| 303 | + if (version_compare(PHP_VERSION, '5.1.2', '>')) |
|
| 304 | 304 | { |
| 305 | - $vars = get_object_vars($this); // does not work in php5.1.2 due a bug |
|
| 305 | + $vars = get_object_vars($this); // does not work in php5.1.2 due a bug |
|
| 306 | 306 | } |
| 307 | 307 | else |
| 308 | 308 | { |
| 309 | - foreach(array_keys(get_class_vars(__CLASS__)) as $name) |
|
| 309 | + foreach (array_keys(get_class_vars(__CLASS__)) as $name) |
|
| 310 | 310 | { |
| 311 | 311 | $vars[$name] = $this->$name; |
| 312 | 312 | } |
@@ -346,13 +346,13 @@ discard block |
||
| 346 | 346 | * @param boolean $return_serialized =true true: return json serialized string, false: return array |
| 347 | 347 | * @return string|array see $return_serialized |
| 348 | 348 | */ |
| 349 | - static function mask_passwords($data, $return_serialized=true) |
|
| 349 | + static function mask_passwords($data, $return_serialized = true) |
|
| 350 | 350 | { |
| 351 | 351 | if (!is_array($data)) |
| 352 | 352 | { |
| 353 | 353 | $data = json_php_unserialize($data); |
| 354 | 354 | } |
| 355 | - foreach($data as $key => &$value) |
|
| 355 | + foreach ($data as $key => &$value) |
|
| 356 | 356 | { |
| 357 | 357 | if (is_array($value)) |
| 358 | 358 | { |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | } |
| 403 | 403 | if (!class_exists($class = $data['type']) || $class == 'admin_cmd') |
| 404 | 404 | { |
| 405 | - throw new egw_exception_wrong_parameter(lang('Unknown command %1!',$class),0); |
|
| 405 | + throw new egw_exception_wrong_parameter(lang('Unknown command %1!', $class), 0); |
|
| 406 | 406 | } |
| 407 | 407 | $cmd = new $class($data); |
| 408 | 408 | |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | { |
| 411 | 411 | return $cmd; |
| 412 | 412 | } |
| 413 | - throw new egw_exception_wrong_parameter(lang('%1 is no command!',$class),0); |
|
| 413 | + throw new egw_exception_wrong_parameter(lang('%1 is no command!', $class), 0); |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | /** |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | * @param array $readonlys |
| 423 | 423 | * @return int |
| 424 | 424 | */ |
| 425 | - static function get_rows($query,&$rows,$readonlys) |
|
| 425 | + static function get_rows($query, &$rows, $readonlys) |
|
| 426 | 426 | { |
| 427 | 427 | admin_cmd::_instanciate_sql(); |
| 428 | 428 | |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | { |
| 431 | 431 | $query['col_filter']['remote_id'] = null; |
| 432 | 432 | } |
| 433 | - return admin_cmd::$sql->get_rows($query,$rows,$readonlys); |
|
| 433 | + return admin_cmd::$sql->get_rows($query, $rows, $readonlys); |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | /** |
@@ -449,11 +449,11 @@ discard block |
||
| 449 | 449 | * @param array $filter=null if set (!=null) col-data pairs, to be and-ed (!) into the query without wildcards |
| 450 | 450 | * @return array |
| 451 | 451 | */ |
| 452 | - static function &search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null) |
|
| 452 | + static function &search($criteria, $only_keys = True, $order_by = '', $extra_cols = '', $wildcard = '', $empty = False, $op = 'AND', $start = false, $filter = null) |
|
| 453 | 453 | { |
| 454 | 454 | admin_cmd::_instanciate_sql(); |
| 455 | 455 | |
| 456 | - return admin_cmd::$sql->search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,$start,$filter); |
|
| 456 | + return admin_cmd::$sql->search($criteria, $only_keys, $order_by, $extra_cols, $wildcard, $empty, $op, $start, $filter); |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | /** |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | { |
| 466 | 466 | if (is_null(admin_cmd::$sql)) |
| 467 | 467 | { |
| 468 | - admin_cmd::$sql = new so_sql('admin','egw_admin_queue',null,'cmd_'); |
|
| 468 | + admin_cmd::$sql = new so_sql('admin', 'egw_admin_queue', null, 'cmd_'); |
|
| 469 | 469 | } |
| 470 | 470 | } |
| 471 | 471 | |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | { |
| 479 | 479 | if (is_null(admin_cmd::$remote)) |
| 480 | 480 | { |
| 481 | - admin_cmd::$remote = new so_sql('admin','egw_admin_remote'); |
|
| 481 | + admin_cmd::$remote = new so_sql('admin', 'egw_admin_remote'); |
|
| 482 | 482 | } |
| 483 | 483 | } |
| 484 | 484 | |
@@ -490,11 +490,11 @@ discard block |
||
| 490 | 490 | */ |
| 491 | 491 | function __get($property) |
| 492 | 492 | { |
| 493 | - if (property_exists('admin_cmd',$property)) |
|
| 493 | + if (property_exists('admin_cmd', $property)) |
|
| 494 | 494 | { |
| 495 | - return $this->$property; // making all (non static) class vars readonly available |
|
| 495 | + return $this->$property; // making all (non static) class vars readonly available |
|
| 496 | 496 | } |
| 497 | - switch($property) |
|
| 497 | + switch ($property) |
|
| 498 | 498 | { |
| 499 | 499 | case 'accounts': |
| 500 | 500 | self::_instanciate_accounts(); |
@@ -511,9 +511,9 @@ discard block |
||
| 511 | 511 | */ |
| 512 | 512 | function __isset($property) |
| 513 | 513 | { |
| 514 | - if (property_exists('admin_cmd',$property)) |
|
| 514 | + if (property_exists('admin_cmd', $property)) |
|
| 515 | 515 | { |
| 516 | - return isset($this->$property); // making all (non static) class vars readonly available |
|
| 516 | + return isset($this->$property); // making all (non static) class vars readonly available |
|
| 517 | 517 | } |
| 518 | 518 | return isset($this->data[$property]); |
| 519 | 519 | } |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | * @param mixed $value |
| 526 | 526 | * @return mixed |
| 527 | 527 | */ |
| 528 | - function __set($property,$value) |
|
| 528 | + function __set($property, $value) |
|
| 529 | 529 | { |
| 530 | 530 | $this->data[$property] = $value; |
| 531 | 531 | } |
@@ -547,19 +547,19 @@ discard block |
||
| 547 | 547 | */ |
| 548 | 548 | function as_array() |
| 549 | 549 | { |
| 550 | - if (version_compare(PHP_VERSION,'5.1.2','>')) |
|
| 550 | + if (version_compare(PHP_VERSION, '5.1.2', '>')) |
|
| 551 | 551 | { |
| 552 | - $vars = get_object_vars($this); // does not work in php5.1.2 due a bug |
|
| 552 | + $vars = get_object_vars($this); // does not work in php5.1.2 due a bug |
|
| 553 | 553 | } |
| 554 | 554 | else |
| 555 | 555 | { |
| 556 | - foreach(array_keys(get_class_vars(__CLASS__)) as $name) |
|
| 556 | + foreach (array_keys(get_class_vars(__CLASS__)) as $name) |
|
| 557 | 557 | { |
| 558 | 558 | $vars[$name] = $this->$name; |
| 559 | 559 | } |
| 560 | 560 | } |
| 561 | 561 | unset($vars['data']); |
| 562 | - if ($this->data) $vars = array_merge($this->data,$vars); |
|
| 562 | + if ($this->data) $vars = array_merge($this->data, $vars); |
|
| 563 | 563 | |
| 564 | 564 | return $vars; |
| 565 | 565 | } |
@@ -571,14 +571,14 @@ discard block |
||
| 571 | 571 | * @param int $extra_deny=null further admin rights to check, eg. 16 = deny edit accounts |
| 572 | 572 | * @throws egw_exception_no_admin |
| 573 | 573 | */ |
| 574 | - protected function _check_admin($extra_acl=null,$extra_deny=null) |
|
| 574 | + protected function _check_admin($extra_acl = null, $extra_deny = null) |
|
| 575 | 575 | { |
| 576 | 576 | if ($this->creator) |
| 577 | 577 | { |
| 578 | 578 | admin_cmd::_instanciate_acl($this->creator); |
| 579 | 579 | // todo: check only if and with $this->creator |
| 580 | - if (!admin_cmd::$acl->check('run',1,'admin') && // creator is no longer admin |
|
| 581 | - $extra_acl && $extra_deny && admin_cmd::$acl->check($extra_acl,$extra_deny,'admin')) // creator is explicitly forbidden to do something |
|
| 580 | + if (!admin_cmd::$acl->check('run', 1, 'admin') && // creator is no longer admin |
|
| 581 | + $extra_acl && $extra_deny && admin_cmd::$acl->check($extra_acl, $extra_deny, 'admin')) // creator is explicitly forbidden to do something |
|
| 582 | 582 | { |
| 583 | 583 | throw new egw_exception_no_permission_admin(); |
| 584 | 584 | } |
@@ -594,13 +594,13 @@ discard block |
||
| 594 | 594 | */ |
| 595 | 595 | static function parse_apps(array $apps) |
| 596 | 596 | { |
| 597 | - foreach($apps as $key => $name) |
|
| 597 | + foreach ($apps as $key => $name) |
|
| 598 | 598 | { |
| 599 | 599 | if (!isset($GLOBALS['egw_info']['apps'][$name])) |
| 600 | 600 | { |
| 601 | - foreach($GLOBALS['egw_info']['apps'] as $app => $data) // check against title and localised name |
|
| 601 | + foreach ($GLOBALS['egw_info']['apps'] as $app => $data) // check against title and localised name |
|
| 602 | 602 | { |
| 603 | - if (!strcasecmp($name,$data['title']) || !strcasecmp($name,lang($app))) |
|
| 603 | + if (!strcasecmp($name, $data['title']) || !strcasecmp($name, lang($app))) |
|
| 604 | 604 | { |
| 605 | 605 | $apps[$key] = $name = $app; |
| 606 | 606 | break; |
@@ -609,7 +609,7 @@ discard block |
||
| 609 | 609 | } |
| 610 | 610 | if (!isset($GLOBALS['egw_info']['apps'][$name])) |
| 611 | 611 | { |
| 612 | - throw new egw_exception_wrong_userinput(lang("Application '%1' not found (maybe not installed or misspelled)!",$name),8); |
|
| 612 | + throw new egw_exception_wrong_userinput(lang("Application '%1' not found (maybe not installed or misspelled)!", $name), 8); |
|
| 613 | 613 | } |
| 614 | 614 | } |
| 615 | 615 | return $apps; |
@@ -624,20 +624,20 @@ discard block |
||
| 624 | 624 | * @throws egw_exception_wrong_userinput(lang("Unknown account: %1 !!!",$account),15); |
| 625 | 625 | * @throws egw_exception_wrong_userinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only_user?lang('user'):lang('group')),15); |
| 626 | 626 | */ |
| 627 | - static function parse_account($account,$allow_only_user=null) |
|
| 627 | + static function parse_account($account, $allow_only_user = null) |
|
| 628 | 628 | { |
| 629 | 629 | admin_cmd::_instanciate_accounts(); |
| 630 | 630 | |
| 631 | 631 | if (!($type = admin_cmd::$accounts->exists($account)) || |
| 632 | - !is_numeric($id=$account) && !($id = admin_cmd::$accounts->name2id($account))) |
|
| 632 | + !is_numeric($id = $account) && !($id = admin_cmd::$accounts->name2id($account))) |
|
| 633 | 633 | { |
| 634 | - throw new egw_exception_wrong_userinput(lang("Unknown account: %1 !!!",$account),15); |
|
| 634 | + throw new egw_exception_wrong_userinput(lang("Unknown account: %1 !!!", $account), 15); |
|
| 635 | 635 | } |
| 636 | 636 | if (!is_null($allow_only_user) && $allow_only_user !== ($type == 1)) |
| 637 | 637 | { |
| 638 | - throw new egw_exception_wrong_userinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only_user?lang('user'):lang('group')),15); |
|
| 638 | + throw new egw_exception_wrong_userinput(lang("Wrong account type: %1 is NO %2 !!!", $account, $allow_only_user ? lang('user') : lang('group')), 15); |
|
| 639 | 639 | } |
| 640 | - if ($type == 2 && $id > 0) $id = -$id; // groups use negative id's internally, fix it, if user given the wrong sign |
|
| 640 | + if ($type == 2 && $id > 0) $id = -$id; // groups use negative id's internally, fix it, if user given the wrong sign |
|
| 641 | 641 | |
| 642 | 642 | return $id; |
| 643 | 643 | } |
@@ -651,14 +651,14 @@ discard block |
||
| 651 | 651 | * @throws egw_exception_wrong_userinput(lang("Unknown account: %1 !!!",$account),15); |
| 652 | 652 | * @throws egw_exception_wrong_userinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only?lang('user'):lang('group')),15); |
| 653 | 653 | */ |
| 654 | - static function parse_accounts($accounts,$allow_only_user=null) |
|
| 654 | + static function parse_accounts($accounts, $allow_only_user = null) |
|
| 655 | 655 | { |
| 656 | 656 | if (!$accounts) return null; |
| 657 | 657 | |
| 658 | 658 | $ids = array(); |
| 659 | - foreach(is_array($accounts) ? $accounts : explode(',',$accounts) as $account) |
|
| 659 | + foreach (is_array($accounts) ? $accounts : explode(',', $accounts) as $account) |
|
| 660 | 660 | { |
| 661 | - $ids[] = admin_cmd::parse_account($account,$allow_only_user); |
|
| 661 | + $ids[] = admin_cmd::parse_account($account, $allow_only_user); |
|
| 662 | 662 | } |
| 663 | 663 | return $ids; |
| 664 | 664 | } |
@@ -676,11 +676,11 @@ discard block |
||
| 676 | 676 | { |
| 677 | 677 | $datein = $date; |
| 678 | 678 | // convert german DD.MM.YYYY format into ISO YYYY-MM-DD format |
| 679 | - $date = preg_replace('/^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$/','\3-\2-\1',$date); |
|
| 679 | + $date = preg_replace('/^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$/', '\3-\2-\1', $date); |
|
| 680 | 680 | |
| 681 | - if (($date = strtotime($date)) === false) |
|
| 681 | + if (($date = strtotime($date)) === false) |
|
| 682 | 682 | { |
| 683 | - throw new egw_exception_wrong_userinput(lang('Invalid formated date "%1"!',$datein),6); |
|
| 683 | + throw new egw_exception_wrong_userinput(lang('Invalid formated date "%1"!', $datein), 6); |
|
| 684 | 684 | } |
| 685 | 685 | } |
| 686 | 686 | return (int)$date; |
@@ -694,7 +694,7 @@ discard block |
||
| 694 | 694 | * @return boolean |
| 695 | 695 | * @throws egw_exception_wrong_userinput(lang('Invalid value "%1" use yes or no!',$value),998); |
| 696 | 696 | */ |
| 697 | - static function parse_boolean($value,$default=null) |
|
| 697 | + static function parse_boolean($value, $default = null) |
|
| 698 | 698 | { |
| 699 | 699 | if (is_bool($value) || is_int($value)) |
| 700 | 700 | { |
@@ -704,15 +704,15 @@ discard block |
||
| 704 | 704 | { |
| 705 | 705 | return $default; |
| 706 | 706 | } |
| 707 | - if (in_array($value,array('1','yes','true',lang('yes'),lang('true')))) |
|
| 707 | + if (in_array($value, array('1', 'yes', 'true', lang('yes'), lang('true')))) |
|
| 708 | 708 | { |
| 709 | 709 | return true; |
| 710 | 710 | } |
| 711 | - if (in_array($value,array('0','no','false',lang('no'),lang('false')))) |
|
| 711 | + if (in_array($value, array('0', 'no', 'false', lang('no'), lang('false')))) |
|
| 712 | 712 | { |
| 713 | 713 | return false; |
| 714 | 714 | } |
| 715 | - throw new egw_exception_wrong_userinput(lang('Invalid value "%1" use yes or no!',$value),998); |
|
| 715 | + throw new egw_exception_wrong_userinput(lang('Invalid value "%1" use yes or no!', $value), 998); |
|
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | /** |
@@ -730,9 +730,9 @@ discard block |
||
| 730 | 730 | 'remote_id' => $id_or_name, |
| 731 | 731 | 'remote_name' => $id_or_name, |
| 732 | 732 | 'remote_domain' => $id_or_name, |
| 733 | - ),true,'','','',false,'OR')) || count($remotes) != 1) |
|
| 733 | + ), true, '', '', '', false, 'OR')) || count($remotes) != 1) |
|
| 734 | 734 | { |
| 735 | - throw new egw_exception_wrong_userinput(lang('Invalid remote id or name "%1"!',$id_or_name),997); |
|
| 735 | + throw new egw_exception_wrong_userinput(lang('Invalid remote id or name "%1"!', $id_or_name), 997); |
|
| 736 | 736 | } |
| 737 | 737 | return $remotes[0]['remote_id']; |
| 738 | 738 | } |
@@ -749,7 +749,7 @@ discard block |
||
| 749 | 749 | { |
| 750 | 750 | if (!is_object($GLOBALS['egw']->accounts)) |
| 751 | 751 | { |
| 752 | - throw new egw_exception_assertion_failed(lang('%1 class not instanciated','accounts'),999); |
|
| 752 | + throw new egw_exception_assertion_failed(lang('%1 class not instanciated', 'accounts'), 999); |
|
| 753 | 753 | } |
| 754 | 754 | admin_cmd::$accounts = $GLOBALS['egw']->accounts; |
| 755 | 755 | } |
@@ -762,13 +762,13 @@ discard block |
||
| 762 | 762 | * @param int $account=null account_id the class needs to be instanciated for, default need only account-independent methods |
| 763 | 763 | * @throws egw_exception_assertion_failed(lang('%1 class not instanciated','acl'),999); |
| 764 | 764 | */ |
| 765 | - protected function _instanciate_acl($account=null) |
|
| 765 | + protected function _instanciate_acl($account = null) |
|
| 766 | 766 | { |
| 767 | 767 | if (!is_object(admin_cmd::$acl) || $account && admin_cmd::$acl->account_id != $account) |
| 768 | 768 | { |
| 769 | 769 | if (!is_object($GLOBALS['egw']->acl)) |
| 770 | 770 | { |
| 771 | - throw new egw_exception_assertion_failed(lang('%1 class not instanciated','acl'),999); |
|
| 771 | + throw new egw_exception_assertion_failed(lang('%1 class not instanciated', 'acl'), 999); |
|
| 772 | 772 | } |
| 773 | 773 | if ($account && $GLOBALS['egw']->acl->account_id != $account) |
| 774 | 774 | { |
@@ -788,20 +788,20 @@ discard block |
||
| 788 | 788 | * @param $account_id=null account_id, default current user |
| 789 | 789 | * @return string |
| 790 | 790 | */ |
| 791 | - static function user_email($account_id=null) |
|
| 791 | + static function user_email($account_id = null) |
|
| 792 | 792 | { |
| 793 | 793 | if ($account_id) |
| 794 | 794 | { |
| 795 | 795 | admin_cmd::_instanciate_accounts(); |
| 796 | - $fullname = admin_cmd::$accounts->id2name($account_id,'account_fullname'); |
|
| 797 | - $email = admin_cmd::$accounts->id2name($account_id,'account_email'); |
|
| 796 | + $fullname = admin_cmd::$accounts->id2name($account_id, 'account_fullname'); |
|
| 797 | + $email = admin_cmd::$accounts->id2name($account_id, 'account_email'); |
|
| 798 | 798 | } |
| 799 | 799 | else |
| 800 | 800 | { |
| 801 | 801 | $fullname = $GLOBALS['egw_info']['user']['account_fullname']; |
| 802 | 802 | $email = $GLOBALS['egw_info']['user']['account_email']; |
| 803 | 803 | } |
| 804 | - return $fullname . ($email ? ' <'.$email.'>' : ''); |
|
| 804 | + return $fullname.($email ? ' <'.$email.'>' : ''); |
|
| 805 | 805 | } |
| 806 | 806 | |
| 807 | 807 | /** |
@@ -825,11 +825,11 @@ discard block |
||
| 825 | 825 | { |
| 826 | 826 | return false; |
| 827 | 827 | } |
| 828 | - if (!($jobs = admin_cmd::search(array(),false,'cmd_scheduled','','',false,'AND',array(0,1),array( |
|
| 828 | + if (!($jobs = admin_cmd::search(array(), false, 'cmd_scheduled', '', '', false, 'AND', array(0, 1), array( |
|
| 829 | 829 | 'cmd_status' => admin_cmd::scheduled, |
| 830 | 830 | )))) |
| 831 | 831 | { |
| 832 | - return false; // no schduled command, no need to setup the job |
|
| 832 | + return false; // no schduled command, no need to setup the job |
|
| 833 | 833 | } |
| 834 | 834 | $next = $jobs[0]; |
| 835 | 835 | if (($time = $next['scheduled']) < time()) // should run immediatly |
@@ -840,11 +840,11 @@ discard block |
||
| 840 | 840 | $async = new asyncservice(); |
| 841 | 841 | |
| 842 | 842 | // we cant use this class as callback, as it's abstract and ExecMethod used by the async service instanciated the class! |
| 843 | - list($app) = explode('_',$class=$next['type']); |
|
| 843 | + list($app) = explode('_', $class = $next['type']); |
|
| 844 | 844 | $callback = $app.'.'.$class.'.run_queued_jobs'; |
| 845 | 845 | |
| 846 | - $async->cancel_timer(admin_cmd::async_job_id); // we delete it in case a job already exists |
|
| 847 | - return $async->set_timer($time,admin_cmd::async_job_id,$callback,null,$next['creator']); |
|
| 846 | + $async->cancel_timer(admin_cmd::async_job_id); // we delete it in case a job already exists |
|
| 847 | + return $async->set_timer($time, admin_cmd::async_job_id, $callback, null, $next['creator']); |
|
| 848 | 848 | } |
| 849 | 849 | |
| 850 | 850 | /** |
@@ -854,26 +854,26 @@ discard block |
||
| 854 | 854 | */ |
| 855 | 855 | static function run_queued_jobs() |
| 856 | 856 | { |
| 857 | - if (!($jobs = admin_cmd::search(array(),false,'cmd_scheduled','','',false,'AND',false,array( |
|
| 857 | + if (!($jobs = admin_cmd::search(array(), false, 'cmd_scheduled', '', '', false, 'AND', false, array( |
|
| 858 | 858 | 'cmd_status' => admin_cmd::scheduled, |
| 859 | 859 | 'cmd_scheduled <= '.time(), |
| 860 | 860 | )))) |
| 861 | 861 | { |
| 862 | - return false; // no schduled commands, no need to setup the job |
|
| 862 | + return false; // no schduled commands, no need to setup the job |
|
| 863 | 863 | } |
| 864 | - admin_cmd::$running_queued_jobs = true; // stop admin_cmd::run() which calls admin_cmd::save() to install a new job |
|
| 864 | + admin_cmd::$running_queued_jobs = true; // stop admin_cmd::run() which calls admin_cmd::save() to install a new job |
|
| 865 | 865 | |
| 866 | - foreach($jobs as $job) |
|
| 866 | + foreach ($jobs as $job) |
|
| 867 | 867 | { |
| 868 | 868 | try { |
| 869 | 869 | $cmd = admin_cmd::instanciate($job); |
| 870 | - $cmd->run(null,false); // false = dont set current user as modifier, as job is run by the queue/system itself |
|
| 870 | + $cmd->run(null, false); // false = dont set current user as modifier, as job is run by the queue/system itself |
|
| 871 | 871 | } |
| 872 | 872 | catch (Exception $e) { // we need to mark that command as failed, to prevent further execution |
| 873 | 873 | admin_cmd::$sql->init($job); |
| 874 | 874 | admin_cmd::$sql->save(array( |
| 875 | 875 | 'status' => admin_cmd::failed, |
| 876 | - 'error' => lang('Unknown command %1!',$job['type']), |
|
| 876 | + 'error' => lang('Unknown command %1!', $job['type']), |
|
| 877 | 877 | 'errno' => 0, |
| 878 | 878 | 'data' => self::mask_passwords($job['data']), |
| 879 | 879 | )); |
@@ -894,9 +894,9 @@ discard block |
||
| 894 | 894 | admin_cmd::_instanciate_remote(); |
| 895 | 895 | |
| 896 | 896 | $sites = array(lang('local')); |
| 897 | - if ($remote = admin_cmd::$remote->query_list('remote_name','remote_id')) |
|
| 897 | + if ($remote = admin_cmd::$remote->query_list('remote_name', 'remote_id')) |
|
| 898 | 898 | { |
| 899 | - $sites = array_merge($sites,$remote); |
|
| 899 | + $sites = array_merge($sites, $remote); |
|
| 900 | 900 | } |
| 901 | 901 | return $sites; |
| 902 | 902 | } |
@@ -909,11 +909,11 @@ discard block |
||
| 909 | 909 | * @param array &$readonlys |
| 910 | 910 | * @return int |
| 911 | 911 | */ |
| 912 | - static function get_remotes($query,&$rows,&$readonlys) |
|
| 912 | + static function get_remotes($query, &$rows, &$readonlys) |
|
| 913 | 913 | { |
| 914 | 914 | admin_cmd::_instanciate_remote(); |
| 915 | 915 | |
| 916 | - return admin_cmd::$remote->get_rows($query,$rows,$readonlys); |
|
| 916 | + return admin_cmd::$remote->get_rows($query, $rows, $readonlys); |
|
| 917 | 917 | } |
| 918 | 918 | |
| 919 | 919 | /** |
@@ -941,7 +941,7 @@ discard block |
||
| 941 | 941 | |
| 942 | 942 | if ($data['install_id'] && $data['config_passwd']) // calculate hash |
| 943 | 943 | { |
| 944 | - $data['remote_hash'] = self::remote_hash($data['install_id'],$data['config_passwd']); |
|
| 944 | + $data['remote_hash'] = self::remote_hash($data['install_id'], $data['config_passwd']); |
|
| 945 | 945 | } |
| 946 | 946 | elseif (!$data['remote_hash'] && !($data['install_id'] && $data['config_passwd'])) |
| 947 | 947 | { |
@@ -953,12 +953,12 @@ discard block |
||
| 953 | 953 | // check if a unique key constrain would be violated by saving the entry |
| 954 | 954 | if (($num = admin_cmd::$remote->not_unique())) |
| 955 | 955 | { |
| 956 | - $col = admin_cmd::$remote->table_def['uc'][$num-1]; // $num is 1 based! |
|
| 957 | - throw new egw_exception_db_not_unique(lang('Value for column %1 is not unique!',$this->table_name.'.'.$col),$num); |
|
| 956 | + $col = admin_cmd::$remote->table_def['uc'][$num - 1]; // $num is 1 based! |
|
| 957 | + throw new egw_exception_db_not_unique(lang('Value for column %1 is not unique!', $this->table_name.'.'.$col), $num); |
|
| 958 | 958 | } |
| 959 | 959 | if (admin_cmd::$remote->save() != 0) |
| 960 | 960 | { |
| 961 | - throw new egw_exception_db(lang('Error saving to db:').' '.$this->sql->db->Error.' ('.$this->sql->db->Errno.')',$this->sql->db->Errno); |
|
| 961 | + throw new egw_exception_db(lang('Error saving to db:').' '.$this->sql->db->Error.' ('.$this->sql->db->Errno.')', $this->sql->db->Errno); |
|
| 962 | 962 | } |
| 963 | 963 | return admin_cmd::$remote->data['remote_id']; |
| 964 | 964 | } |
@@ -970,11 +970,11 @@ discard block |
||
| 970 | 970 | * @param string $config_passwd |
| 971 | 971 | * @return string 32char md5 hash |
| 972 | 972 | */ |
| 973 | - static function remote_hash($install_id,$config_passwd) |
|
| 973 | + static function remote_hash($install_id, $config_passwd) |
|
| 974 | 974 | { |
| 975 | 975 | if (empty($config_passwd) || !self::is_md5($install_id)) |
| 976 | 976 | { |
| 977 | - throw new egw_exception_wrong_parameter(empty($config_passwd)?'Empty config password':'install_id no md5 hash'); |
|
| 977 | + throw new egw_exception_wrong_parameter(empty($config_passwd) ? 'Empty config password' : 'install_id no md5 hash'); |
|
| 978 | 978 | } |
| 979 | 979 | if (!self::is_md5($config_passwd)) $config_passwd = md5($config_passwd); |
| 980 | 980 | |
@@ -1004,7 +1004,7 @@ discard block |
||
| 1004 | 1004 | */ |
| 1005 | 1005 | static function is_md5($str) |
| 1006 | 1006 | { |
| 1007 | - return preg_match('/^[0-9a-f]{32}$/',$str); |
|
| 1007 | + return preg_match('/^[0-9a-f]{32}$/', $str); |
|
| 1008 | 1008 | } |
| 1009 | 1009 | |
| 1010 | 1010 | /** |
@@ -1021,25 +1021,25 @@ discard block |
||
| 1021 | 1021 | * @param string $config_passwd of the current domain |
| 1022 | 1022 | * @throws egw_exception_no_permission |
| 1023 | 1023 | */ |
| 1024 | - function check_remote_access($secret,$config_passwd) |
|
| 1024 | + function check_remote_access($secret, $config_passwd) |
|
| 1025 | 1025 | { |
| 1026 | 1026 | // as a security measure remote administration need to be enabled under Admin > Site configuration |
| 1027 | - list(,$remote_admin_install_id) = explode('-',$this->uid); |
|
| 1028 | - $allowed_remote_admin_ids = $GLOBALS['egw_info']['server']['allow_remote_admin'] ? explode(',',$GLOBALS['egw_info']['server']['allow_remote_admin']) : array(); |
|
| 1027 | + list(,$remote_admin_install_id) = explode('-', $this->uid); |
|
| 1028 | + $allowed_remote_admin_ids = $GLOBALS['egw_info']['server']['allow_remote_admin'] ? explode(',', $GLOBALS['egw_info']['server']['allow_remote_admin']) : array(); |
|
| 1029 | 1029 | |
| 1030 | 1030 | // to authenticate with the installation we use a secret, which is a md5 hash build from the uid |
| 1031 | 1031 | // of the command (to not allow to send new commands with an earsdroped secret) and the md5 hash |
| 1032 | 1032 | // of the md5 hash of the config password and the install_id (egw_admin_remote.remote_hash) |
| 1033 | - if (is_null($config_passwd) || is_numeric($this->uid) || !in_array($remote_admin_install_id,$allowed_remote_admin_ids) || |
|
| 1034 | - $secret != ($md5=md5($this->uid.$this->remote_hash($GLOBALS['egw_info']['server']['install_id'],$config_passwd)))) |
|
| 1033 | + if (is_null($config_passwd) || is_numeric($this->uid) || !in_array($remote_admin_install_id, $allowed_remote_admin_ids) || |
|
| 1034 | + $secret != ($md5 = md5($this->uid.$this->remote_hash($GLOBALS['egw_info']['server']['install_id'], $config_passwd)))) |
|
| 1035 | 1035 | { |
| 1036 | 1036 | //die("secret='$secret' != '$md5', is_null($config_passwd)=".is_null($config_passwd).", uid=$this->uid, remote_install_id=$remote_admin_install_id, allowed: ".implode(', ',$allowed_remote_admin_ids)); |
| 1037 | 1037 | $msg = lang('Permission denied!'); |
| 1038 | - if (!in_array($remote_admin_install_id,$allowed_remote_admin_ids)) |
|
| 1038 | + if (!in_array($remote_admin_install_id, $allowed_remote_admin_ids)) |
|
| 1039 | 1039 | { |
| 1040 | 1040 | $msg .= "\n".lang('Remote administration need to be enabled in the remote instance under Admin > Site configuration!'); |
| 1041 | 1041 | } |
| 1042 | - throw new egw_exception_no_permission($msg,0); |
|
| 1042 | + throw new egw_exception_no_permission($msg, 0); |
|
| 1043 | 1043 | } |
| 1044 | 1044 | } |
| 1045 | 1045 | |
@@ -1049,21 +1049,21 @@ discard block |
||
| 1049 | 1049 | * @param int $len=16 |
| 1050 | 1050 | * @return string |
| 1051 | 1051 | */ |
| 1052 | - static function randomstring($len=16) |
|
| 1052 | + static function randomstring($len = 16) |
|
| 1053 | 1053 | { |
| 1054 | 1054 | static $usedchars = array( |
| 1055 | - '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f', |
|
| 1056 | - 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v', |
|
| 1057 | - 'w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L', |
|
| 1058 | - 'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', |
|
| 1059 | - '@','!','$','%','&','/','(',')','=','?',';',':','#','_','-','<', |
|
| 1060 | - '>','|','{','[',']','}', // dont add \,'" as we have problems dealing with them |
|
| 1055 | + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', |
|
| 1056 | + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', |
|
| 1057 | + 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', |
|
| 1058 | + 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', |
|
| 1059 | + '@', '!', '$', '%', '&', '/', '(', ')', '=', '?', ';', ':', '#', '_', '-', '<', |
|
| 1060 | + '>', '|', '{', '[', ']', '}', // dont add \,'" as we have problems dealing with them |
|
| 1061 | 1061 | ); |
| 1062 | 1062 | |
| 1063 | 1063 | $str = ''; |
| 1064 | - for($i=0; $i < $len; $i++) |
|
| 1064 | + for ($i = 0; $i < $len; $i++) |
|
| 1065 | 1065 | { |
| 1066 | - $str .= $usedchars[mt_rand(0,count($usedchars)-1)]; |
|
| 1066 | + $str .= $usedchars[mt_rand(0, count($usedchars) - 1)]; |
|
| 1067 | 1067 | } |
| 1068 | 1068 | return $str; |
| 1069 | 1069 | } |