@@ -30,14 +30,12 @@ discard block |
||
| 30 | 30 | /** |
| 31 | 31 | * Shows the contactform and stores the submitted data |
| 32 | 32 | * |
| 33 | - * @param array $content=null submitted eTemplate content |
|
| 34 | - * @param int $addressbook=null int owner-id of addressbook to save contacts too |
|
| 35 | - * @param array $fields=null field-names to show |
|
| 36 | - * @param string $msg=null message to show after submitting the form |
|
| 37 | - * @param string $email=null comma-separated email addresses |
|
| 38 | - * @param string $tpl_name=null custom etemplate to use |
|
| 39 | - * @param string $subject=null subject for email |
|
| 40 | - * @param string $copytoreceiver=false send a copy of notification to receiver |
|
| 33 | + * @param array $content submitted eTemplate content |
|
| 34 | + * @param int $addressbook int owner-id of addressbook to save contacts too |
|
| 35 | + * @param array $fields field-names to show |
|
| 36 | + * @param string $tpl_name custom etemplate to use |
|
| 37 | + * @param string $subject subject for email |
|
| 38 | + * @param string $copytoreceiver send a copy of notification to receiver |
|
| 41 | 39 | * @return string html content |
| 42 | 40 | */ |
| 43 | 41 | function display(array $content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array()) |
@@ -49,13 +47,11 @@ discard block |
||
| 49 | 47 | * Shows the contactform and stores the submitted data ($content is a var parameter, eg. for extending classes) |
| 50 | 48 | * |
| 51 | 49 | * @param array &$content=null submitted eTemplate content |
| 52 | - * @param int $addressbook=null int owner-id of addressbook to save contacts too |
|
| 53 | - * @param array $fields=null field-names to show |
|
| 54 | - * @param string $msg=null message to show after submitting the form |
|
| 55 | - * @param string $email=null comma-separated email addresses |
|
| 56 | - * @param string $tpl_name=null custom etemplate to use |
|
| 57 | - * @param string $subject=null subject for email |
|
| 58 | - * @param string $copytoreceiver=false send a copy of notification to receiver |
|
| 50 | + * @param int $addressbook int owner-id of addressbook to save contacts too |
|
| 51 | + * @param array $fields field-names to show |
|
| 52 | + * @param string $tpl_name custom etemplate to use |
|
| 53 | + * @param string $subject subject for email |
|
| 54 | + * @param string $copytoreceiver send a copy of notification to receiver |
|
| 59 | 55 | * @return string html content |
| 60 | 56 | */ |
| 61 | 57 | function display_var(array &$content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array()) |
@@ -61,30 +61,46 @@ discard block |
||
| 61 | 61 | function display_var(array &$content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array()) |
| 62 | 62 | { |
| 63 | 63 | #error_log( "<p>addressbook_contactform::display(".print_r($content,true).",$addressbook,".print_r($fields,true).",$msg,$tpl_name)</p>\n"); |
| 64 | - if (empty($tpl_name) && !empty($content['tpl_form_name'])) $tpl_name =$content['tpl_form_name']; |
|
| 64 | + if (empty($tpl_name) && !empty($content['tpl_form_name'])) |
|
| 65 | + { |
|
| 66 | + $tpl_name =$content['tpl_form_name']; |
|
| 67 | + } |
|
| 65 | 68 | $tpl = new etemplate($tpl_name ? $tpl_name : 'addressbook.contactform'); |
| 66 | 69 | // initializing some fields |
| 67 | - if (!$fields) $fields = array('org_name','n_fn','email','tel_work','url','note','captcha'); |
|
| 70 | + if (!$fields) |
|
| 71 | + { |
|
| 72 | + $fields = array('org_name','n_fn','email','tel_work','url','note','captcha'); |
|
| 73 | + } |
|
| 68 | 74 | $submitted = false; |
| 69 | 75 | // check if submitted |
| 70 | 76 | if (is_array($content)) |
| 71 | 77 | { |
| 72 | - if (isset($_POST['g-recaptcha-response'])) $recaptcha = sitemgr_module::verify_recaptcha ($_POST['g-recaptcha-response']); |
|
| 78 | + if (isset($_POST['g-recaptcha-response'])) |
|
| 79 | + { |
|
| 80 | + $recaptcha = sitemgr_module::verify_recaptcha ($_POST['g-recaptcha-response']); |
|
| 81 | + } |
|
| 73 | 82 | $captcha = (isset($content['captcha_result']) && $content['captcha'] != $content['captcha_result']) || ($recaptcha && $recaptcha->success == false); |
| 74 | 83 | if ($captcha || // no correct captcha OR |
| 75 | 84 | (time() - $content['start_time'] < 10 && // bot indicator (less then 10 sec to fill out the form and |
| 76 | - !$GLOBALS['egw_info']['etemplate']['java_script'])) // javascript disabled) |
|
| 85 | + !$GLOBALS['egw_info']['etemplate']['java_script'])) |
|
| 86 | + { |
|
| 87 | + // javascript disabled) |
|
| 77 | 88 | { |
| 78 | 89 | $submitted = "truebutfalse"; |
| 90 | + } |
|
| 79 | 91 | $tpl->set_validation_error('captcha',lang('Wrong - try again ...')); |
| 80 | 92 | } |
| 81 | 93 | elseif ($content['submitit']) |
| 82 | 94 | { |
| 83 | 95 | $submitted = true; |
| 84 | 96 | $contact = new Api\Contacts(); |
| 85 | - if ($content['owner']) // save the contact in the addressbook |
|
| 97 | + if ($content['owner']) |
|
| 98 | + { |
|
| 99 | + // save the contact in the addressbook |
|
| 86 | 100 | { |
| 87 | - $content['private'] = 0; // in case default_private is set |
|
| 101 | + $content['private'] = 0; |
|
| 102 | + } |
|
| 103 | + // in case default_private is set |
|
| 88 | 104 | if (($id = $contact->save($content))) |
| 89 | 105 | { |
| 90 | 106 | // check for fileuploads and attach the found files |
@@ -141,9 +157,12 @@ discard block |
||
| 141 | 157 | $custom = 1; |
| 142 | 158 | foreach($fields as $name) |
| 143 | 159 | { |
| 144 | - if ($name[0] == '#') // custom field |
|
| 160 | + if ($name[0] == '#') |
|
| 161 | + { |
|
| 162 | + // custom field |
|
| 145 | 163 | { |
| 146 | 164 | static $contact; |
| 165 | + } |
|
| 147 | 166 | if (is_null($contact)) |
| 148 | 167 | { |
| 149 | 168 | $contact = new Api\Contacts(); |
@@ -174,12 +193,19 @@ discard block |
||
| 174 | 193 | unset($content['submitit']); |
| 175 | 194 | $custom = 1; |
| 176 | 195 | // fieldnames are "defined" by the commit attempt, that way, we do not have to remember them |
| 177 | - foreach($content as $name => $value) { |
|
| 196 | + foreach($content as $name => $value) |
|
| 197 | + { |
|
| 178 | 198 | $preserv[$name]=$value; |
| 179 | - if ($name[0] == '#') // custom field |
|
| 199 | + if ($name[0] == '#') |
|
| 200 | + { |
|
| 201 | + // custom field |
|
| 180 | 202 | { |
| 181 | 203 | static $contact; |
| 182 | - if (is_null($contact)) $contact = new Api\Contacts(); |
|
| 204 | + } |
|
| 205 | + if (is_null($contact)) |
|
| 206 | + { |
|
| 207 | + $contact = new Api\Contacts(); |
|
| 208 | + } |
|
| 183 | 209 | $content['show']['custom'.$custom] = true; |
| 184 | 210 | $content['customfield'][$custom] = $name; |
| 185 | 211 | $content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label']; |
@@ -202,16 +228,26 @@ discard block |
||
| 202 | 228 | } |
| 203 | 229 | $content['addr_format'] = $GLOBALS['egw_info']['user']['preferences']['addressbook']['addr_format']; |
| 204 | 230 | |
| 205 | - if ($addressbook) $preserv['owner'] = $addressbook; |
|
| 206 | - if ($msg) $preserv['msg'] = $msg; |
|
| 231 | + if ($addressbook) |
|
| 232 | + { |
|
| 233 | + $preserv['owner'] = $addressbook; |
|
| 234 | + } |
|
| 235 | + if ($msg) |
|
| 236 | + { |
|
| 237 | + $preserv['msg'] = $msg; |
|
| 238 | + } |
|
| 207 | 239 | if (!sitemgr_module::get_recaptcha()) |
| 208 | 240 | { |
| 209 | 241 | // a simple calculation captcha |
| 210 | 242 | $num1 = rand(1,99); |
| 211 | 243 | $num2 = rand(1,99); |
| 212 | - if ($num2 > $num1) // keep the result positive |
|
| 244 | + if ($num2 > $num1) |
|
| 245 | + { |
|
| 246 | + // keep the result positive |
|
| 213 | 247 | { |
| 214 | - $n = $num1; $num1 = $num2; $num2 = $n; |
|
| 248 | + $n = $num1; |
|
| 249 | + } |
|
| 250 | + $num1 = $num2; $num2 = $n; |
|
| 215 | 251 | } |
| 216 | 252 | if (in_array('captcha',$fields)) |
| 217 | 253 | { |
@@ -79,8 +79,6 @@ |
||
| 79 | 79 | * Here we need to handle any incoming data. Setup is done in the constructor, |
| 80 | 80 | * output is handled by parent. |
| 81 | 81 | * |
| 82 | - * @param type $id |
|
| 83 | - * @param Etemplate $etemplate |
|
| 84 | 82 | */ |
| 85 | 83 | public static function process($values = array()) |
| 86 | 84 | { |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * @param array &$files |
| 107 | 107 | * @param int $user account_id |
| 108 | 108 | * @param string $id ='' |
| 109 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
| 109 | + * @return boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
| 110 | 110 | */ |
| 111 | 111 | function propfind($path,&$options,&$files,$user,$id='') |
| 112 | 112 | { |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | * |
| 189 | 189 | * @param string $path |
| 190 | 190 | * @param array& $filter |
| 191 | - * @param array|boolean $start =false false=return all or array(start,num) |
|
| 191 | + * @param integer[] $start =false false=return all or array(start,num) |
|
| 192 | 192 | * @return array with "files" array with values for keys path and props |
| 193 | 193 | */ |
| 194 | 194 | function &propfind_callback($path,array &$filter,$start=false,$report_not_found_multiget_ids=true) |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | * @param array &$options |
| 540 | 540 | * @param int $id |
| 541 | 541 | * @param int $user =null account_id |
| 542 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
| 542 | + * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
| 543 | 543 | */ |
| 544 | 544 | function get(&$options,$id,$user=null) |
| 545 | 545 | { |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | * @param int $id |
| 567 | 567 | * @param int $user =null account_id of owner, default null |
| 568 | 568 | * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook) |
| 569 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
| 569 | + * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
| 570 | 570 | */ |
| 571 | 571 | function put(&$options,$id,$user=null,$prefix=null) |
| 572 | 572 | { |
@@ -1024,7 +1024,7 @@ discard block |
||
| 1024 | 1024 | * |
| 1025 | 1025 | * @param int $acl Acl::READ, Acl::EDIT or Acl::DELETE |
| 1026 | 1026 | * @param array|int $contact contact-array or id |
| 1027 | - * @return boolean null if entry does not exist, false if no access, true if access permitted |
|
| 1027 | + * @return null|boolean null if entry does not exist, false if no access, true if access permitted |
|
| 1028 | 1028 | */ |
| 1029 | 1029 | function check_access($acl,$contact) |
| 1030 | 1030 | { |
@@ -85,7 +85,10 @@ discard block |
||
| 85 | 85 | self::$path_attr = 'carddav_name'; |
| 86 | 86 | self::$path_extension = ''; |
| 87 | 87 | } |
| 88 | - if ($this->debug) error_log(__METHOD__."() contact_repository={$this->bo->contact_repository}, account_repository={$this->bo->account_repository}, REQUEST_URI=$_SERVER[REQUEST_URI] --> path_attr=".self::$path_attr.", path_extension=".self::$path_extension); |
|
| 88 | + if ($this->debug) |
|
| 89 | + { |
|
| 90 | + error_log(__METHOD__."() contact_repository={$this->bo->contact_repository}, account_repository={$this->bo->account_repository}, REQUEST_URI=$_SERVER[REQUEST_URI] --> path_attr=".self::$path_attr.", path_extension=".self::$path_extension); |
|
| 91 | + } |
|
| 89 | 92 | |
| 90 | 93 | $this->home_set_pref = $GLOBALS['egw_info']['user']['preferences']['groupdav']['addressbook-home-set']; |
| 91 | 94 | $this->home_set_pref = $this->home_set_pref ? explode(',',$this->home_set_pref) : array(); |
@@ -123,7 +126,10 @@ discard block |
||
| 123 | 126 | $filter['owner'] = $user; |
| 124 | 127 | } |
| 125 | 128 | // should we hide the accounts addressbook |
| 126 | - if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1') $filter['account_id'] = null; |
|
| 129 | + if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1') |
|
| 130 | + { |
|
| 131 | + $filter['account_id'] = null; |
|
| 132 | + } |
|
| 127 | 133 | |
| 128 | 134 | // process REPORT filters or multiget href's |
| 129 | 135 | $nresults = null; |
@@ -131,9 +137,16 @@ discard block |
||
| 131 | 137 | { |
| 132 | 138 | return false; |
| 133 | 139 | } |
| 134 | - if ($id) $path = dirname($path).'/'; // carddav_name get's added anyway in the callback |
|
| 140 | + if ($id) |
|
| 141 | + { |
|
| 142 | + $path = dirname($path).'/'; |
|
| 143 | + } |
|
| 144 | + // carddav_name get's added anyway in the callback |
|
| 135 | 145 | |
| 136 | - if ($this->debug) error_log(__METHOD__."($path,".array2string($options).",,$user,$id) filter=".array2string($filter)); |
|
| 146 | + if ($this->debug) |
|
| 147 | + { |
|
| 148 | + error_log(__METHOD__."($path,".array2string($options).",,$user,$id) filter=".array2string($filter)); |
|
| 149 | + } |
|
| 137 | 150 | |
| 138 | 151 | // check if we have to return the full contact data or just the etag's |
| 139 | 152 | if (!($filter['address_data'] = $options['props'] == 'all' && |
@@ -218,16 +231,25 @@ discard block |
||
| 218 | 231 | |
| 219 | 232 | if (isset($filter[self::$path_attr])) |
| 220 | 233 | { |
| 221 | - if (!is_array($filter[self::$path_attr])) $filter[self::$path_attr] = (array)$filter[self::$path_attr]; |
|
| 234 | + if (!is_array($filter[self::$path_attr])) |
|
| 235 | + { |
|
| 236 | + $filter[self::$path_attr] = (array)$filter[self::$path_attr]; |
|
| 237 | + } |
|
| 222 | 238 | $requested_multiget_ids =& $filter[self::$path_attr]; |
| 223 | 239 | } |
| 224 | 240 | |
| 225 | 241 | $files = array(); |
| 226 | 242 | // we query etag and modified, as LDAP does not have the strong sql etag |
| 227 | 243 | $cols = array('id','uid','etag','modified','n_fn'); |
| 228 | - if (!in_array(self::$path_attr,$cols)) $cols[] = self::$path_attr; |
|
| 244 | + if (!in_array(self::$path_attr,$cols)) |
|
| 245 | + { |
|
| 246 | + $cols[] = self::$path_attr; |
|
| 247 | + } |
|
| 229 | 248 | // we need tid for sync-collection report |
| 230 | - if (array_key_exists('tid', $filter) && !isset($filter['tid']) && !in_array('tid', $cols)) $cols[] = 'tid'; |
|
| 249 | + if (array_key_exists('tid', $filter) && !isset($filter['tid']) && !in_array('tid', $cols)) |
|
| 250 | + { |
|
| 251 | + $cols[] = 'tid'; |
|
| 252 | + } |
|
| 231 | 253 | if (($contacts =& $this->bo->search(array(),$cols,$order,'','',False,'AND',$start,$filter))) |
| 232 | 254 | { |
| 233 | 255 | foreach($contacts as &$contact) |
@@ -271,7 +293,10 @@ discard block |
||
| 271 | 293 | { |
| 272 | 294 | $accounts_filter = $filter_in; |
| 273 | 295 | $accounts_filter['owner'] = '0'; |
| 274 | - if ($sync_collection_report) $token_was = $this->sync_collection_token; |
|
| 296 | + if ($sync_collection_report) |
|
| 297 | + { |
|
| 298 | + $token_was = $this->sync_collection_token; |
|
| 299 | + } |
|
| 275 | 300 | self::$path_attr = 'id'; |
| 276 | 301 | self::$path_extension = '.vcf'; |
| 277 | 302 | $files = array_merge($files, $this->propfind_callback($path, $accounts_filter, false, false)); |
@@ -292,18 +317,27 @@ discard block |
||
| 292 | 317 | if ($sync_collection_report) |
| 293 | 318 | { |
| 294 | 319 | list(,$sync_token) = explode('>', $filter[0]); |
| 295 | - if ((int)$sync_token) $where[] = 'list_modified>'.$GLOBALS['egw']->db->from_unixtime((int)$sync_token); |
|
| 320 | + if ((int)$sync_token) |
|
| 321 | + { |
|
| 322 | + $where[] = 'list_modified>'.$GLOBALS['egw']->db->from_unixtime((int)$sync_token); |
|
| 323 | + } |
|
| 296 | 324 | } |
| 297 | - if (isset($filter[self::$path_attr])) // multiget report? |
|
| 325 | + if (isset($filter[self::$path_attr])) |
|
| 326 | + { |
|
| 327 | + // multiget report? |
|
| 298 | 328 | { |
| 299 | 329 | $where['list_'.self::$path_attr] = $filter[self::$path_attr]; |
| 300 | 330 | } |
| 331 | + } |
|
| 301 | 332 | //error_log(__METHOD__."() filter=".array2string($filter).", do_groups=".in_array('D',$this->home_set_pref).", where=".array2string($where)); |
| 302 | - if (($lists = $this->bo->read_lists($where,'contact_uid',$where['list_owner']))) // limit to contacts in same AB! |
|
| 333 | + if (($lists = $this->bo->read_lists($where,'contact_uid',$where['list_owner']))) |
|
| 334 | + { |
|
| 335 | + // limit to contacts in same AB! |
|
| 303 | 336 | { |
| 304 | 337 | foreach($lists as $list) |
| 305 | 338 | { |
| 306 | 339 | $list[self::$path_attr] = $list['list_carddav_name']; |
| 340 | + } |
|
| 307 | 341 | $etag = $list['list_id'].':'.$list['list_etag']; |
| 308 | 342 | // for all-in-one addressbook, add selected ABs to etag |
| 309 | 343 | if (isset($filter['owner']) && is_array($filter['owner'])) |
@@ -347,7 +381,10 @@ discard block |
||
| 347 | 381 | } |
| 348 | 382 | } |
| 349 | 383 | |
| 350 | - if ($this->debug) error_log(__METHOD__."($path,".array2string($filter).','.array2string($start).") took ".(microtime(true) - $starttime).' to return '.count($files).' items'); |
|
| 384 | + if ($this->debug) |
|
| 385 | + { |
|
| 386 | + error_log(__METHOD__."($path,".array2string($filter).','.array2string($start).") took ".(microtime(true) - $starttime).' to return '.count($files).' items'); |
|
| 387 | + } |
|
| 351 | 388 | return $files; |
| 352 | 389 | } |
| 353 | 390 | |
@@ -387,7 +424,11 @@ discard block |
||
| 387 | 424 | $matches = $prop_test = $column = null; |
| 388 | 425 | foreach($options['filters'] as $n => $filter) |
| 389 | 426 | { |
| 390 | - if (!is_int($n)) continue; // eg. attributes of filter xml element |
|
| 427 | + if (!is_int($n)) |
|
| 428 | + { |
|
| 429 | + continue; |
|
| 430 | + } |
|
| 431 | + // eg. attributes of filter xml element |
|
| 391 | 432 | |
| 392 | 433 | switch((string)$filter['name']) |
| 393 | 434 | { |
@@ -395,19 +436,28 @@ discard block |
||
| 395 | 436 | $this->caldav->log(__METHOD__."(...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!"); |
| 396 | 437 | break; |
| 397 | 438 | case 'prop-filter': // can be multiple prop-filter, see example |
| 398 | - if ($matches) $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches); |
|
| 439 | + if ($matches) |
|
| 440 | + { |
|
| 441 | + $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches); |
|
| 442 | + } |
|
| 399 | 443 | $matches = array(); |
| 400 | 444 | $prop_filter = strtoupper($filter['attrs']['name']); |
| 401 | 445 | $prop_test = isset($filter['attrs']['test']) ? $filter['attrs']['test'] : 'anyof'; |
| 402 | - if ($this->debug > 1) error_log(__METHOD__."(...) prop-filter='$prop_filter', test='$prop_test'"); |
|
| 446 | + if ($this->debug > 1) |
|
| 447 | + { |
|
| 448 | + error_log(__METHOD__."(...) prop-filter='$prop_filter', test='$prop_test'"); |
|
| 449 | + } |
|
| 403 | 450 | break; |
| 404 | 451 | case 'is-not-defined': |
| 405 | 452 | $matches[] = '('.$column."='' OR ".$column.' IS NULL)'; |
| 406 | 453 | break; |
| 407 | 454 | case 'text-match': // prop-filter can have multiple text-match, see example |
| 408 | - if (!isset($this->filter_prop2cal[$prop_filter])) // eg. not existing NICKNAME in EGroupware |
|
| 455 | + if (!isset($this->filter_prop2cal[$prop_filter])) |
|
| 456 | + { |
|
| 457 | + // eg. not existing NICKNAME in EGroupware |
|
| 409 | 458 | { |
| 410 | 459 | if ($this->debug || $prop_filter != 'NICKNAME') error_log(__METHOD__."(...) text-match: $prop_filter {$filter['attrs']['match-type']} '{$filter['data']}' unknown property '$prop_filter' --> ignored"); |
| 460 | + } |
|
| 411 | 461 | $column = false; // to ignore following data too |
| 412 | 462 | } |
| 413 | 463 | else |
@@ -420,8 +470,14 @@ discard block |
||
| 420 | 470 | break; |
| 421 | 471 | } |
| 422 | 472 | $column = $this->filter_prop2cal[strtoupper($prop_filter)]; |
| 423 | - if (strpos($column, '_') === false) $column = 'contact_'.$column; |
|
| 424 | - if (!isset($filters['order'])) $filters['order'] = $column; |
|
| 473 | + if (strpos($column, '_') === false) |
|
| 474 | + { |
|
| 475 | + $column = 'contact_'.$column; |
|
| 476 | + } |
|
| 477 | + if (!isset($filters['order'])) |
|
| 478 | + { |
|
| 479 | + $filters['order'] = $column; |
|
| 480 | + } |
|
| 425 | 481 | $match_type = $filter['attrs']['match-type']; |
| 426 | 482 | $negate_condition = isset($filter['attrs']['negate-condition']) && $filter['attrs']['negate-condition'] == 'yes'; |
| 427 | 483 | } |
@@ -429,9 +485,12 @@ discard block |
||
| 429 | 485 | case '': // data of text-match element |
| 430 | 486 | if (isset($filter['data']) && isset($column)) |
| 431 | 487 | { |
| 432 | - if ($column) // false for properties not known to EGroupware |
|
| 488 | + if ($column) |
|
| 489 | + { |
|
| 490 | + // false for properties not known to EGroupware |
|
| 433 | 491 | { |
| 434 | 492 | $value = str_replace(array('%', '_'), array('\\%', '\\_'), $filter['data']); |
| 493 | + } |
|
| 435 | 494 | switch($match_type) |
| 436 | 495 | { |
| 437 | 496 | case 'equals': |
@@ -450,7 +509,10 @@ discard block |
||
| 450 | 509 | } |
| 451 | 510 | $matches[] = ($negate_condition ? 'NOT ' : '').$sql_filter; |
| 452 | 511 | |
| 453 | - if ($this->debug > 1) error_log(__METHOD__."(...) text-match: $prop_filter $match_type' '{$filter['data']}'"); |
|
| 512 | + if ($this->debug > 1) |
|
| 513 | + { |
|
| 514 | + error_log(__METHOD__."(...) text-match: $prop_filter $match_type' '{$filter['data']}'"); |
|
| 515 | + } |
|
| 454 | 516 | } |
| 455 | 517 | unset($column); |
| 456 | 518 | break; |
@@ -461,11 +523,17 @@ discard block |
||
| 461 | 523 | break; |
| 462 | 524 | } |
| 463 | 525 | } |
| 464 | - if ($matches) $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches); |
|
| 526 | + if ($matches) |
|
| 527 | + { |
|
| 528 | + $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches); |
|
| 529 | + } |
|
| 465 | 530 | if ($prop_filters) |
| 466 | 531 | { |
| 467 | 532 | $filters[] = $filter = '(('.implode($filter_test=='allof'?') AND (':') OR (', $prop_filters).'))'; |
| 468 | - if ($this->debug) error_log(__METHOD__."(path=$options[path], ...) sql-filter: $filter"); |
|
| 533 | + if ($this->debug) |
|
| 534 | + { |
|
| 535 | + error_log(__METHOD__."(path=$options[path], ...) sql-filter: $filter"); |
|
| 536 | + } |
|
| 469 | 537 | } |
| 470 | 538 | } |
| 471 | 539 | // parse limit from $options['other'] |
@@ -522,8 +590,14 @@ discard block |
||
| 522 | 590 | } |
| 523 | 591 | } |
| 524 | 592 | } |
| 525 | - if ($ids) $filters[self::$path_attr] = $ids; |
|
| 526 | - if ($this->debug) error_log(__METHOD__."(...) addressbook-multiget: ids=".implode(',',$ids)); |
|
| 593 | + if ($ids) |
|
| 594 | + { |
|
| 595 | + $filters[self::$path_attr] = $ids; |
|
| 596 | + } |
|
| 597 | + if ($this->debug) |
|
| 598 | + { |
|
| 599 | + error_log(__METHOD__."(...) addressbook-multiget: ids=".implode(',',$ids)); |
|
| 600 | + } |
|
| 527 | 601 | } |
| 528 | 602 | elseif ($id) |
| 529 | 603 | { |
@@ -570,12 +644,18 @@ discard block |
||
| 570 | 644 | */ |
| 571 | 645 | function put(&$options,$id,$user=null,$prefix=null) |
| 572 | 646 | { |
| 573 | - if ($this->debug) error_log(__METHOD__.'('.array2string($options).",$id,$user)"); |
|
| 647 | + if ($this->debug) |
|
| 648 | + { |
|
| 649 | + error_log(__METHOD__.'('.array2string($options).",$id,$user)"); |
|
| 650 | + } |
|
| 574 | 651 | |
| 575 | 652 | $oldContact = $this->_common_get_put_delete('PUT',$options,$id); |
| 576 | 653 | if (!is_null($oldContact) && !is_array($oldContact)) |
| 577 | 654 | { |
| 578 | - if ($this->debug) error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($oldContact)); |
|
| 655 | + if ($this->debug) |
|
| 656 | + { |
|
| 657 | + error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($oldContact)); |
|
| 658 | + } |
|
| 579 | 659 | return $oldContact; |
| 580 | 660 | } |
| 581 | 661 | |
@@ -666,16 +746,25 @@ discard block |
||
| 666 | 746 | // done here again, as _common_get_put_delete knows nothing about default addressbooks... |
| 667 | 747 | if (!($this->bo->grants[$contact['owner']] & Acl::ADD)) |
| 668 | 748 | { |
| 669 | - if ($this->debug) error_log(__METHOD__."(,'$id', $user, '$prefix') returning '403 Forbidden'"); |
|
| 749 | + if ($this->debug) |
|
| 750 | + { |
|
| 751 | + error_log(__METHOD__."(,'$id', $user, '$prefix') returning '403 Forbidden'"); |
|
| 752 | + } |
|
| 670 | 753 | return '403 Forbidden'; |
| 671 | 754 | } |
| 672 | 755 | } |
| 673 | - if ($this->http_if_match) $contact['etag'] = self::etag2value($this->http_if_match); |
|
| 756 | + if ($this->http_if_match) |
|
| 757 | + { |
|
| 758 | + $contact['etag'] = self::etag2value($this->http_if_match); |
|
| 759 | + } |
|
| 674 | 760 | |
| 675 | 761 | $contact['photo_unchanged'] = false; // photo needs saving |
| 676 | 762 | if (!($save_ok = $is_group ? $this->save_group($contact, $oldContact) : $this->bo->save($contact))) |
| 677 | 763 | { |
| 678 | - if ($this->debug) error_log(__METHOD__."(,$id) save(".array2string($contact).") failed, Ok=$save_ok"); |
|
| 764 | + if ($this->debug) |
|
| 765 | + { |
|
| 766 | + error_log(__METHOD__."(,$id) save(".array2string($contact).") failed, Ok=$save_ok"); |
|
| 767 | + } |
|
| 679 | 768 | if ($save_ok === 0) |
| 680 | 769 | { |
| 681 | 770 | // honor Prefer: return=representation for 412 too (no need for client to explicitly reload) |
@@ -705,7 +794,10 @@ discard block |
||
| 705 | 794 | // send evtl. necessary respose headers: Location, etag, ... |
| 706 | 795 | $this->put_response_headers($contact, $options['path'], $retval, self::$path_attr != 'id'); |
| 707 | 796 | |
| 708 | - if ($this->debug > 1) error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($retval)); |
|
| 797 | + if ($this->debug > 1) |
|
| 798 | + { |
|
| 799 | + error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($retval)); |
|
| 800 | + } |
|
| 709 | 801 | return $retval; |
| 710 | 802 | } |
| 711 | 803 | |
@@ -719,7 +811,10 @@ discard block |
||
| 719 | 811 | function save_group(array &$contact, $oldContact=null) |
| 720 | 812 | { |
| 721 | 813 | $data = array('list_name' => $contact['n_fn']); |
| 722 | - if (!isset($contact['owner'])) $contact['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
| 814 | + if (!isset($contact['owner'])) |
|
| 815 | + { |
|
| 816 | + $contact['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
| 817 | + } |
|
| 723 | 818 | foreach(array('id','carddav_name','uid','owner') as $name) |
| 724 | 819 | { |
| 725 | 820 | $data['list_'.$name] = $contact[$name]; |
@@ -771,8 +866,14 @@ discard block |
||
| 771 | 866 | } |
| 772 | 867 | } |
| 773 | 868 | //error_log('to_add_ids='.array2string($to_add_ids).', to_delete_ids='.array2string($to_delete_ids)); |
| 774 | - if ($to_add_ids) $this->bo->add2list($to_add_ids, $list_id, array()); |
|
| 775 | - if ($to_delete_ids) $this->bo->remove_from_list($to_delete_ids, $list_id); |
|
| 869 | + if ($to_add_ids) |
|
| 870 | + { |
|
| 871 | + $this->bo->add2list($to_add_ids, $list_id, array()); |
|
| 872 | + } |
|
| 873 | + if ($to_delete_ids) |
|
| 874 | + { |
|
| 875 | + $this->bo->remove_from_list($to_delete_ids, $list_id); |
|
| 876 | + } |
|
| 776 | 877 | } |
| 777 | 878 | // reread as update of list-members updates etag and modified |
| 778 | 879 | if (($contact = $this->bo->read_list($list_id))) |
@@ -781,7 +882,10 @@ discard block |
||
| 781 | 882 | $contact = $this->read($contact['list_'.self::$path_attr]); |
| 782 | 883 | } |
| 783 | 884 | } |
| 784 | - if ($this->debug > 1) error_log(__METHOD__.'('.array2string($contact).', '.array2string($oldContact).') on return contact='.array2string($data).' returning '.array2string($list_id)); |
|
| 885 | + if ($this->debug > 1) |
|
| 886 | + { |
|
| 887 | + error_log(__METHOD__.'('.array2string($contact).', '.array2string($oldContact).') on return contact='.array2string($data).' returning '.array2string($list_id)); |
|
| 888 | + } |
|
| 785 | 889 | return $list_id; |
| 786 | 890 | } |
| 787 | 891 | |
@@ -795,11 +899,17 @@ discard block |
||
| 795 | 899 | public function getctag($path,$user) |
| 796 | 900 | { |
| 797 | 901 | static $ctags = array(); // a little per request caching, in case ctag and sync-token is both requested |
| 798 | - if (isset($ctags[$path])) return $ctags[$path]; |
|
| 902 | + if (isset($ctags[$path])) |
|
| 903 | + { |
|
| 904 | + return $ctags[$path]; |
|
| 905 | + } |
|
| 799 | 906 | |
| 800 | 907 | $user_in = $user; |
| 801 | 908 | // not showing addressbook of a single user? |
| 802 | - if (is_null($user) || $user === '' || $path == '/addressbook/') $user = null; |
|
| 909 | + if (is_null($user) || $user === '' || $path == '/addressbook/') |
|
| 910 | + { |
|
| 911 | + $user = null; |
|
| 912 | + } |
|
| 803 | 913 | |
| 804 | 914 | // If "Sync selected addressbooks into one" is set --> ctag need to take selected AB's into account too |
| 805 | 915 | if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O',$this->home_set_pref)) |
@@ -1012,16 +1122,22 @@ discard block |
||
| 1012 | 1122 | $contact['etag'] .= ':'.implode('-',$limit_in_ab); |
| 1013 | 1123 | } |
| 1014 | 1124 | } |
| 1015 | - elseif($contact === array()) // not found from read_lists() |
|
| 1125 | + elseif($contact === array()) |
|
| 1126 | + { |
|
| 1127 | + // not found from read_lists() |
|
| 1016 | 1128 | { |
| 1017 | 1129 | $contact = null; |
| 1018 | 1130 | } |
| 1131 | + } |
|
| 1019 | 1132 | |
| 1020 | 1133 | if ($contact && $contact['tid'] == Api\Contacts::DELETED_TYPE) |
| 1021 | 1134 | { |
| 1022 | 1135 | $contact = null; // handle deleted events, as not existing (404 Not Found) |
| 1023 | 1136 | } |
| 1024 | - if ($this->debug > 1) error_log(__METHOD__."('$id') returning ".array2string($contact)); |
|
| 1137 | + if ($this->debug > 1) |
|
| 1138 | + { |
|
| 1139 | + error_log(__METHOD__."('$id') returning ".array2string($contact)); |
|
| 1140 | + } |
|
| 1025 | 1141 | return $contact; |
| 1026 | 1142 | } |
| 1027 | 1143 | |
@@ -1051,7 +1167,10 @@ discard block |
||
| 1051 | 1167 | // remove add and delete grants for accounts (for admins too) |
| 1052 | 1168 | // as accounts can not be created as contacts, they eg. need further data |
| 1053 | 1169 | // and admins might not recognice they delete an account incl. its data |
| 1054 | - if (isset($grants[0])) $grants[0] &= ~(EGW_ACL_ADD|EGW_ACL_DELETE); |
|
| 1170 | + if (isset($grants[0])) |
|
| 1171 | + { |
|
| 1172 | + $grants[0] &= ~(EGW_ACL_ADD|EGW_ACL_DELETE); |
|
| 1173 | + } |
|
| 1055 | 1174 | |
| 1056 | 1175 | return $grants; |
| 1057 | 1176 | } |
@@ -1067,7 +1186,10 @@ discard block |
||
| 1067 | 1186 | $shared = array(); |
| 1068 | 1187 | |
| 1069 | 1188 | // if "Sync all selected addressbook into one" is set --> no (additional) shared addressbooks |
| 1070 | - if (!$ignore_all_in_one && in_array('O',$this->home_set_pref)) return array(); |
|
| 1189 | + if (!$ignore_all_in_one && in_array('O',$this->home_set_pref)) |
|
| 1190 | + { |
|
| 1191 | + return array(); |
|
| 1192 | + } |
|
| 1071 | 1193 | |
| 1072 | 1194 | // replace symbolic id's with real nummeric id's |
| 1073 | 1195 | foreach(array( |
@@ -1134,7 +1256,11 @@ discard block |
||
| 1134 | 1256 | $user = $hook_data['account_id']; |
| 1135 | 1257 | $addressbook_bo = new Api\Contacts(); |
| 1136 | 1258 | $addressbooks += $addressbook_bo->get_addressbooks(Acl::READ, null, $user); |
| 1137 | - if ($user > 0) unset($addressbooks[$user]); // allways synced |
|
| 1259 | + if ($user > 0) |
|
| 1260 | + { |
|
| 1261 | + unset($addressbooks[$user]); |
|
| 1262 | + } |
|
| 1263 | + // allways synced |
|
| 1138 | 1264 | unset($addressbooks[$user.'p']);// ignore (optional) private addressbook for now |
| 1139 | 1265 | } |
| 1140 | 1266 | |
@@ -532,7 +532,6 @@ |
||
| 532 | 532 | /** |
| 533 | 533 | * Read the IMAP ACLs |
| 534 | 534 | * |
| 535 | - * @param array $args admin-account[@domain],admin-password,accout_lid[,pw] |
|
| 536 | 535 | * @return int 0 on success |
| 537 | 536 | */ |
| 538 | 537 | function do_subscribe_other($account_lid,$pw=null) |
@@ -17,10 +17,13 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | chdir(dirname(__FILE__)); // to enable our relative pathes to work |
| 19 | 19 | |
| 20 | -if (php_sapi_name() !== 'cli') // security precaution: forbit calling admin-cli as web-page |
|
| 20 | +if (php_sapi_name() !== 'cli') |
|
| 21 | +{ |
|
| 22 | + // security precaution: forbit calling admin-cli as web-page |
|
| 21 | 23 | { |
| 22 | 24 | die('<h1>admin-cli.php must NOT be called as web-page --> exiting !!!</h1>'); |
| 23 | 25 | } |
| 26 | +} |
|
| 24 | 27 | elseif ($_SERVER['argc'] <= 1 || $_SERVER['argc'] == 2 && in_array($_SERVER['argv'][1], array('-h', '--help'))) |
| 25 | 28 | { |
| 26 | 29 | usage(); |
@@ -92,13 +95,19 @@ discard block |
||
| 92 | 95 | foreach($arg0s as $arg) |
| 93 | 96 | { |
| 94 | 97 | list($name,$value) = explode('=',$arg,2); |
| 95 | - if(property_exists('admin_cmd',$name)) // dont allow to overwrite admin_cmd properties |
|
| 98 | + if(property_exists('admin_cmd',$name)) |
|
| 99 | + { |
|
| 100 | + // dont allow to overwrite admin_cmd properties |
|
| 96 | 101 | { |
| 97 | 102 | throw new Api\Exception\WrongUserinput(lang("Invalid argument '%1' !!!",$arg),90); |
| 98 | 103 | } |
| 99 | - if (substr($name,-1) == ']') // allow 1-dim. arrays |
|
| 104 | + } |
|
| 105 | + if (substr($name,-1) == ']') |
|
| 106 | + { |
|
| 107 | + // allow 1-dim. arrays |
|
| 100 | 108 | { |
| 101 | 109 | list($name,$sub) = explode('[',substr($name,0,-1),2); |
| 110 | + } |
|
| 102 | 111 | $args[$name][$sub] = $value; |
| 103 | 112 | } |
| 104 | 113 | else |
@@ -183,7 +192,10 @@ discard block |
||
| 183 | 192 | if (!$dry_run) |
| 184 | 193 | { |
| 185 | 194 | $url = $GLOBALS['egw_info']['server']['webserver_url'].'/json.php?menuaction=admin.admin_hooks.ajax_clear_cache'; |
| 186 | - if ($url[0] == '/') $url = 'http://'.(!empty($domain) && $domain != 'default' ? $domain : 'localhost').$url; |
|
| 195 | + if ($url[0] == '/') |
|
| 196 | + { |
|
| 197 | + $url = 'http://'.(!empty($domain) && $domain != 'default' ? $domain : 'localhost').$url; |
|
| 198 | + } |
|
| 187 | 199 | $data = file_get_contents($url, false, Framework::proxy_context($user,$arg0s[1])); |
| 188 | 200 | //error_log("file_get_contents('$url') returned ".array2string($data)); |
| 189 | 201 | if ($data && strpos($data, '"success"') !== false) |
@@ -225,10 +237,13 @@ discard block |
||
| 225 | 237 | echo lang("Wrong admin-account or -password !!!")."\n\n"; |
| 226 | 238 | usage('',1); |
| 227 | 239 | } |
| 228 | - if (!$GLOBALS['egw_info']['user']['apps']['admin']) // will be tested by the header too, but whould give html error-message |
|
| 240 | + if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 241 | + { |
|
| 242 | + // will be tested by the header too, but whould give html error-message |
|
| 229 | 243 | { |
| 230 | 244 | //fail(2,lang("Permission denied !!!")); |
| 231 | 245 | echo lang("Permission denied !!!")."\n\n"; |
| 246 | + } |
|
| 232 | 247 | usage('',2); |
| 233 | 248 | } |
| 234 | 249 | return $sessionid; |
@@ -377,7 +392,11 @@ discard block |
||
| 377 | 392 | foreach($acc_id ? array(Api\Mail\Account::read($acc_id, $account_id)) : |
| 378 | 393 | Api\Mail\Account::search($account_id, false) as $account) |
| 379 | 394 | { |
| 380 | - if (!isset($acc_id) && !Api\Mail\Account::is_multiple($account)) continue; // no need to waste time on personal accounts |
|
| 395 | + if (!isset($acc_id) && !Api\Mail\Account::is_multiple($account)) |
|
| 396 | + { |
|
| 397 | + continue; |
|
| 398 | + } |
|
| 399 | + // no need to waste time on personal accounts |
|
| 381 | 400 | |
| 382 | 401 | $args = $arg0s; |
| 383 | 402 | try { |
@@ -430,7 +449,10 @@ discard block |
||
| 430 | 449 | $identity['account_id'] = $account_id; // make this a personal identity for $account_id |
| 431 | 450 | Api\Mail\Account::save_identity($identity); |
| 432 | 451 | } |
| 433 | - if ($args) echo "Identity(s) for ".implode(', ', $args)." created.\n"; |
|
| 452 | + if ($args) |
|
| 453 | + { |
|
| 454 | + echo "Identity(s) for ".implode(', ', $args)." created.\n"; |
|
| 455 | + } |
|
| 434 | 456 | } |
| 435 | 457 | } |
| 436 | 458 | catch(\Exception $e) { |
@@ -456,7 +478,10 @@ discard block |
||
| 456 | 478 | */ |
| 457 | 479 | function array_modify(&$arr, array &$mod) |
| 458 | 480 | { |
| 459 | - if (!is_array($arr)) $arr = array(); |
|
| 481 | + if (!is_array($arr)) |
|
| 482 | + { |
|
| 483 | + $arr = array(); |
|
| 484 | + } |
|
| 460 | 485 | |
| 461 | 486 | switch($mod[0][0]) |
| 462 | 487 | { |
@@ -512,10 +537,13 @@ discard block |
||
| 512 | 537 | try { |
| 513 | 538 | admin_cmd::parse_account($account,false); |
| 514 | 539 | |
| 515 | - foreach($data as &$value) // existing account --> empty values mean dont change, not set them empty! |
|
| 540 | + foreach($data as &$value) |
|
| 541 | + { |
|
| 542 | + // existing account --> empty values mean dont change, not set them empty! |
|
| 516 | 543 | { |
| 517 | 544 | if ((string)$value === '') $value = null; |
| 518 | 545 | } |
| 546 | + } |
|
| 519 | 547 | } |
| 520 | 548 | catch (Exception $e) { // new group |
| 521 | 549 | unset($e); // not used |
@@ -557,9 +585,12 @@ discard block |
||
| 557 | 585 | if (($GLOBALS['egw_info']['server']['account_repository'] == 'ldap' || |
| 558 | 586 | empty($GLOBALS['egw_info']['server']['account_repository']) && $GLOBALS['egw_info']['server']['auth_type'] == 'ldap') && |
| 559 | 587 | $GLOBALS['egw_info']['server']['ldap_extra_attributes'] && count($args) > 9 && // 9 = primary group |
| 560 | - ($last_arg = array_pop($dummy=$args)) && $last_arg[0] == '/') // last argument start with a slash |
|
| 588 | + ($last_arg = array_pop($dummy=$args)) && $last_arg[0] == '/') |
|
| 589 | + { |
|
| 590 | + // last argument start with a slash |
|
| 561 | 591 | { |
| 562 | 592 | $data['loginshell'] = array_pop($args); |
| 593 | + } |
|
| 563 | 594 | $data['homedirectory'] = array_pop($args); |
| 564 | 595 | } |
| 565 | 596 | $data += array( |
@@ -577,10 +608,13 @@ discard block |
||
| 577 | 608 | try { |
| 578 | 609 | admin_cmd::parse_account($account,true); |
| 579 | 610 | |
| 580 | - foreach($data as &$value) // existing account --> empty values mean dont change, not set them empty! |
|
| 611 | + foreach($data as &$value) |
|
| 612 | + { |
|
| 613 | + // existing account --> empty values mean dont change, not set them empty! |
|
| 581 | 614 | { |
| 582 | 615 | if ((string)$value === '') $value = null; |
| 583 | 616 | } |
| 617 | + } |
|
| 584 | 618 | } |
| 585 | 619 | catch (Exception $e) { // new account |
| 586 | 620 | unset($e); // not used |
@@ -621,7 +655,11 @@ discard block |
||
| 621 | 655 | */ |
| 622 | 656 | function do_change_account_id($args) |
| 623 | 657 | { |
| 624 | - if (count($args) < 4) usage(); // 4 means at least user,pw,from1,to1 |
|
| 658 | + if (count($args) < 4) |
|
| 659 | + { |
|
| 660 | + usage(); |
|
| 661 | + } |
|
| 662 | + // 4 means at least user,pw,from1,to1 |
|
| 625 | 663 | |
| 626 | 664 | $ids2change = array(); |
| 627 | 665 | for($n = 2; $n < count($args); $n += 2) |
@@ -255,11 +255,10 @@ |
||
| 255 | 255 | * |
| 256 | 256 | * @param type $action |
| 257 | 257 | * @param type $checked |
| 258 | - * @param type $use_all |
|
| 259 | 258 | * @param type $success |
| 260 | 259 | * @param int $failed |
| 261 | 260 | * @param type $action_msg |
| 262 | - * @return type number of failed |
|
| 261 | + * @return boolean number of failed |
|
| 263 | 262 | */ |
| 264 | 263 | function action($action,$checked,&$success,&$failed,&$action_msg) |
| 265 | 264 | { |
@@ -67,9 +67,13 @@ discard block |
||
| 67 | 67 | { |
| 68 | 68 | $heartbeat_limit = Api\Session::heartbeat_limit(); |
| 69 | 69 | |
| 70 | - if ($query['session_list']) // filter active sessions |
|
| 70 | + if ($query['session_list']) |
|
| 71 | + { |
|
| 72 | + // filter active sessions |
|
| 71 | 73 | { |
| 72 | - $query['col_filter']['lo'] = null; // not logged out |
|
| 74 | + $query['col_filter']['lo'] = null; |
|
| 75 | + } |
|
| 76 | + // not logged out |
|
| 73 | 77 | $query['col_filter'][0] = 'session_dla > '.(int)(time() - $GLOBALS['egw_info']['server']['sessions_timeout']); |
| 74 | 78 | switch((string)$query['session_list']) |
| 75 | 79 | { |
@@ -100,12 +104,16 @@ discard block |
||
| 100 | 104 | { |
| 101 | 105 | $row['sessionstatus'] = $row['session_php']; |
| 102 | 106 | } |
| 103 | - if ($row['lo']) { |
|
| 107 | + if ($row['lo']) |
|
| 108 | + { |
|
| 104 | 109 | $row['total'] = ($row['lo'] - $row['li']) / 60; |
| 105 | 110 | $row['sessionstatus'] = 'logged out'; |
| 106 | 111 | } |
| 107 | 112 | // eg. for bad login or password |
| 108 | - if (!$row['account_id']) $row['alt_loginid'] = ($row['loginid']?$row['loginid']:lang('none')); |
|
| 113 | + if (!$row['account_id']) |
|
| 114 | + { |
|
| 115 | + $row['alt_loginid'] = ($row['loginid']?$row['loginid']:lang('none')); |
|
| 116 | + } |
|
| 109 | 117 | |
| 110 | 118 | // do not allow to kill or select own session |
| 111 | 119 | if ($GLOBALS['egw']->session->sessionid_access_log == $row['sessionid'] && $query['session_list']) |
@@ -142,7 +150,10 @@ discard block |
||
| 142 | 150 | function index(array $content=null, $msg='', $sessions_list=false) |
| 143 | 151 | { |
| 144 | 152 | |
| 145 | - if (is_array($content)) $sessions_list = $content['nm']['session_list']; |
|
| 153 | + if (is_array($content)) |
|
| 154 | + { |
|
| 155 | + $sessions_list = $content['nm']['session_list']; |
|
| 156 | + } |
|
| 146 | 157 | |
| 147 | 158 | // check if user has access to requested functionality |
| 148 | 159 | if ($GLOBALS['egw']->acl->check($sessions_list ? 'current_sessions' : 'access_log_acces',1,'admin')) |
@@ -215,7 +226,8 @@ discard block |
||
| 215 | 226 | $success = $failed = $action = $action_msg = null; |
| 216 | 227 | if ($this->action($content['nm']['action'],$content['nm']['selected'] |
| 217 | 228 | ,$success,$failed,$action_msg,$msg)) |
| 218 | - { // In case of action success |
|
| 229 | + { |
|
| 230 | +// In case of action success |
|
| 219 | 231 | switch ($action_msg) |
| 220 | 232 | { |
| 221 | 233 | case'deleted': |
@@ -225,12 +237,15 @@ discard block |
||
| 225 | 237 | $msg = lang('%1 sessions killed',$success); |
| 226 | 238 | } |
| 227 | 239 | } |
| 228 | - elseif($failed) // In case of action failiure |
|
| 240 | + elseif($failed) |
|
| 241 | + { |
|
| 242 | + // In case of action failiure |
|
| 229 | 243 | { |
| 230 | 244 | switch ($action_msg) |
| 231 | 245 | { |
| 232 | 246 | case'deleted': |
| 233 | 247 | $msg = lang('Error deleting log entry!'); |
| 248 | + } |
|
| 234 | 249 | break; |
| 235 | 250 | case'killed': |
| 236 | 251 | $msg = lang('Permission denied!'); |
@@ -679,6 +679,8 @@ |
||
| 679 | 679 | * @param int &$failed number of failed actions (not enought permissions) |
| 680 | 680 | * @param string &$action_msg translated verb for the actions, to be used in a message like '%1 entries deleted' |
| 681 | 681 | * @param array $query get_rows parameter |
| 682 | + * @param integer $success |
|
| 683 | + * @param integer $failed |
|
| 682 | 684 | * @return boolean true if all actions succeded, false otherwise |
| 683 | 685 | */ |
| 684 | 686 | function action($_action, $checked, $use_all, &$success, &$failed, &$action_msg, array $query) |
@@ -150,8 +150,14 @@ discard block |
||
| 150 | 150 | { |
| 151 | 151 | case 'save': |
| 152 | 152 | case 'apply': |
| 153 | - if(is_array($content['owner'])) $content['owner'] = implode(',',$content['owner']); |
|
| 154 | - if($content['owner'] == '') $content['owner'] = 0; |
|
| 153 | + if(is_array($content['owner'])) |
|
| 154 | + { |
|
| 155 | + $content['owner'] = implode(',',$content['owner']); |
|
| 156 | + } |
|
| 157 | + if($content['owner'] == '') |
|
| 158 | + { |
|
| 159 | + $content['owner'] = 0; |
|
| 160 | + } |
|
| 155 | 161 | if ($content['id'] && self::$acl_edit) |
| 156 | 162 | { |
| 157 | 163 | |
@@ -247,7 +253,10 @@ discard block |
||
| 247 | 253 | Framework::refresh_opener($msg, $this->appname, $content['id'], $change_color ? null : 'update', $refresh_app); |
| 248 | 254 | } |
| 249 | 255 | $content['msg'] = $msg; |
| 250 | - if(!$content['appname']) $content['appname'] = $appname; |
|
| 256 | + if(!$content['appname']) |
|
| 257 | + { |
|
| 258 | + $content['appname'] = $appname; |
|
| 259 | + } |
|
| 251 | 260 | if($content['data']['icon']) |
| 252 | 261 | { |
| 253 | 262 | $content['icon_url'] = $content['base_url'] . $content['data']['icon']; |
@@ -302,7 +311,9 @@ discard block |
||
| 302 | 311 | // Allow admins access to all categories as parent |
| 303 | 312 | $content['all_cats'] = 'all_no_acl'; |
| 304 | 313 | $readonlys['owner'] = false; |
| 305 | - } else { |
|
| 314 | + } |
|
| 315 | + else |
|
| 316 | + { |
|
| 306 | 317 | $readonlys['owner'] = true; |
| 307 | 318 | $readonlys['access'] = $content['owner'] != $GLOBALS['egw_info']['user']['account_id']; |
| 308 | 319 | } |
@@ -313,7 +324,10 @@ discard block |
||
| 313 | 324 | $appname != $content['appname'] || // Can't edit a category from a different app |
| 314 | 325 | ($this->appname != 'admin' && $content['owner'] != $GLOBALS['egw_info']['user']['account_id']); |
| 315 | 326 | // Make sure $content['owner'] is an array otherwise it wont show up values in the multiselectbox |
| 316 | - if (!is_array($content['owner'])) $content['owner'] = explode(',',$content['owner']); |
|
| 327 | + if (!is_array($content['owner'])) |
|
| 328 | + { |
|
| 329 | + $content['owner'] = explode(',',$content['owner']); |
|
| 330 | + } |
|
| 317 | 331 | $tmpl = new Etemplate('admin.categories.edit'); |
| 318 | 332 | $tmpl->exec($this->edit_link,$content,$sel_options,$readonlys,$content+array( |
| 319 | 333 | 'old_parent' => $content['old_parent'] ? $content['old_parent'] : $content['parent'], 'appname' => $appname |
@@ -373,9 +387,15 @@ discard block |
||
| 373 | 387 | { |
| 374 | 388 | $globalcat = false; |
| 375 | 389 | } |
| 376 | - if ($globalcat && $query['filter']) $filter['access'] = 'public'; |
|
| 390 | + if ($globalcat && $query['filter']) |
|
| 391 | + { |
|
| 392 | + $filter['access'] = 'public'; |
|
| 393 | + } |
|
| 377 | 394 | // new column-filter access has highest priority |
| 378 | - if (!empty($query['col_filter']['access']))$filter['access'] = $query['col_filter']['access']; |
|
| 395 | + if (!empty($query['col_filter']['access'])) |
|
| 396 | + { |
|
| 397 | + $filter['access'] = $query['col_filter']['access']; |
|
| 398 | + } |
|
| 379 | 399 | |
| 380 | 400 | Api\Cache::setSession(__CLASS__.$query['appname'],'nm',$query); |
| 381 | 401 | |
@@ -404,7 +424,10 @@ discard block |
||
| 404 | 424 | |
| 405 | 425 | $row['level_spacer'] = str_repeat(' ',$row['level']); |
| 406 | 426 | |
| 407 | - if ($row['data']['icon']) $row['icon_url'] = self::icon_url($row['data']['icon']); |
|
| 427 | + if ($row['data']['icon']) |
|
| 428 | + { |
|
| 429 | + $row['icon_url'] = self::icon_url($row['data']['icon']); |
|
| 430 | + } |
|
| 408 | 431 | |
| 409 | 432 | $row['subs'] = count($row['children']); |
| 410 | 433 | |
@@ -435,13 +458,19 @@ discard block |
||
| 435 | 458 | $readonlys['nm']["add[$row[id]]"] = !self::$acl_add_sub; |
| 436 | 459 | $readonlys['nm']["delete[$row[id]]"] = !self::$acl_delete; |
| 437 | 460 | } |
| 438 | - if (true) $rows = $count <= $query['num_rows'] ? array_values($rows) : array_slice($rows, $query['start'], $query['num_rows']); |
|
| 461 | + if (true) |
|
| 462 | + { |
|
| 463 | + $rows = $count <= $query['num_rows'] ? array_values($rows) : array_slice($rows, $query['start'], $query['num_rows']); |
|
| 464 | + } |
|
| 439 | 465 | // make appname available for actions |
| 440 | 466 | $rows['appname'] = $query['appname']; |
| 441 | 467 | $rows['edit_link'] = $this->edit_link; |
| 442 | 468 | |
| 443 | 469 | // disable access column for global Categories |
| 444 | - if ($GLOBALS['egw_info']['flags']['currentapp'] == 'admin') $rows['no_access'] = true; |
|
| 470 | + if ($GLOBALS['egw_info']['flags']['currentapp'] == 'admin') |
|
| 471 | + { |
|
| 472 | + $rows['no_access'] = true; |
|
| 473 | + } |
|
| 445 | 474 | |
| 446 | 475 | $GLOBALS['egw_info']['flags']['app_header'] = lang($this->appname).' - '.lang('categories'). |
| 447 | 476 | ($query['appname'] != Categories::GLOBAL_APPNAME ? ': '.lang($query['appname']) : ''); |
@@ -458,11 +487,18 @@ discard block |
||
| 458 | 487 | public function index(array $content=null,$msg='') |
| 459 | 488 | { |
| 460 | 489 | //_debug_array($_GET); |
| 461 | - if ($this->appname != 'admin') Api\Translation::add_app('admin'); // need admin translations |
|
| 490 | + if ($this->appname != 'admin') |
|
| 491 | + { |
|
| 492 | + Api\Translation::add_app('admin'); |
|
| 493 | + } |
|
| 494 | + // need admin translations |
|
| 462 | 495 | |
| 463 | 496 | if(!isset($content)) |
| 464 | 497 | { |
| 465 | - if (isset($_GET['msg'])) $msg = $_GET['msg']; |
|
| 498 | + if (isset($_GET['msg'])) |
|
| 499 | + { |
|
| 500 | + $msg = $_GET['msg']; |
|
| 501 | + } |
|
| 466 | 502 | |
| 467 | 503 | $appname = Categories::GLOBAL_APPNAME; |
| 468 | 504 | foreach(array($content['nm']['appname'], $_GET['cats_app'], $_GET['appname']) as $field) |
@@ -602,7 +638,8 @@ discard block |
||
| 602 | 638 | $readonlys['nm']['rows']['owner'] = true; |
| 603 | 639 | $readonlys['nm']['col_filter']['owner'] = true; |
| 604 | 640 | } |
| 605 | - if($appname == Categories::GLOBAL_APPNAME) { |
|
| 641 | + if($appname == Categories::GLOBAL_APPNAME) |
|
| 642 | + { |
|
| 606 | 643 | $sel_options['app'] = array(''=>''); |
| 607 | 644 | $readonlys['nm']['rows']['app'] = true; |
| 608 | 645 | } |
@@ -620,7 +657,8 @@ discard block |
||
| 620 | 657 | )); |
| 621 | 658 | } |
| 622 | 659 | |
| 623 | - protected function get_actions($appname=Api\Categories::GLOBAL_APPNAME) { |
|
| 660 | + protected function get_actions($appname=Api\Categories::GLOBAL_APPNAME) |
|
| 661 | + { |
|
| 624 | 662 | |
| 625 | 663 | $actions = array( |
| 626 | 664 | 'open' => array( // does edit if allowed, otherwise view |
@@ -731,11 +769,17 @@ discard block |
||
| 731 | 769 | list($add_remove, $ids_csv) = explode('_', $settings, 2); |
| 732 | 770 | $ids = explode(',', $ids_csv); |
| 733 | 771 | // Adding 'All users' removes all the others |
| 734 | - if($add_remove == 'add' && array_search(Categories::GLOBAL_ACCOUNT,$ids) !== false) $ids = array(Categories::GLOBAL_ACCOUNT); |
|
| 772 | + if($add_remove == 'add' && array_search(Categories::GLOBAL_ACCOUNT,$ids) !== false) |
|
| 773 | + { |
|
| 774 | + $ids = array(Categories::GLOBAL_ACCOUNT); |
|
| 775 | + } |
|
| 735 | 776 | |
| 736 | 777 | foreach($checked as $id) |
| 737 | 778 | { |
| 738 | - if (!$data = $cats->read($id)) continue; |
|
| 779 | + if (!$data = $cats->read($id)) |
|
| 780 | + { |
|
| 781 | + continue; |
|
| 782 | + } |
|
| 739 | 783 | $data['owner'] = explode(',',$data['owner']); |
| 740 | 784 | if(array_search(Categories::GLOBAL_ACCOUNT,$data['owner']) !== false || $data['owner'][0] > 0) |
| 741 | 785 | { |
@@ -775,7 +819,10 @@ discard block |
||
| 775 | 819 | continue; |
| 776 | 820 | } |
| 777 | 821 | // Skip apps that don't show in the app bar, they [usually] don't have Categories |
| 778 | - if($data['status'] > 1 || in_array($app, array('home','admin','felamimail','sitemgr','sitemgr-link'))) continue; |
|
| 822 | + if($data['status'] > 1 || in_array($app, array('home','admin','felamimail','sitemgr','sitemgr-link'))) |
|
| 823 | + { |
|
| 824 | + continue; |
|
| 825 | + } |
|
| 779 | 826 | if ($GLOBALS['egw_info']['user']['apps'][$app]) |
| 780 | 827 | { |
| 781 | 828 | $apps[$app] = $data['title'] ? $data['title'] : lang($app); |
@@ -443,10 +443,10 @@ discard block |
||
| 443 | 443 | * |
| 444 | 444 | * @static |
| 445 | 445 | * @param array|string $criteria array of key and data cols, OR a SQL query (content for WHERE), fully quoted (!) |
| 446 | - * @param boolean|string|array $only_keys =true True returns only keys, False returns all cols. or |
|
| 446 | + * @param boolean $only_keys =true True returns only keys, False returns all cols. or |
|
| 447 | 447 | * comma seperated list or array of columns to return |
| 448 | 448 | * @param string $order_by ='' fieldnames + {ASC|DESC} separated by colons ',', can also contain a GROUP BY (if it contains ORDER BY) |
| 449 | - * @param string|array $extra_cols ='' string or array of strings to be added to the SELECT, eg. "count(*) as num" |
|
| 449 | + * @param string $extra_cols ='' string or array of strings to be added to the SELECT, eg. "count(*) as num" |
|
| 450 | 450 | * @param string $wildcard ='' appended befor and after each criteria |
| 451 | 451 | * @param boolean $empty =false False=empty criteria are ignored in query, True=empty have to be empty in row |
| 452 | 452 | * @param string $op ='AND' defaults to 'AND', can be set to 'OR' too, then criteria's are OR'ed together |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | * |
| 697 | 697 | * @param string|boolean|int $value |
| 698 | 698 | * @param boolean $default =null |
| 699 | - * @return boolean |
|
| 699 | + * @return boolean|null |
|
| 700 | 700 | * @throws Api\Exception\WrongUserinput(lang('Invalid value "%1" use yes or no!',$value),998); |
| 701 | 701 | */ |
| 702 | 702 | static function parse_boolean($value,$default=null) |
@@ -925,7 +925,7 @@ discard block |
||
| 925 | 925 | * Read data of a remote instance |
| 926 | 926 | * |
| 927 | 927 | * @param array|int $keys |
| 928 | - * @return array |
|
| 928 | + * @return string |
|
| 929 | 929 | */ |
| 930 | 930 | static function read_remote($keys) |
| 931 | 931 | { |
@@ -1005,7 +1005,7 @@ discard block |
||
| 1005 | 1005 | * Check if string is a md5 hash (32 chars of 0-9 or a-f) |
| 1006 | 1006 | * |
| 1007 | 1007 | * @param string $str |
| 1008 | - * @return boolean |
|
| 1008 | + * @return integer |
|
| 1009 | 1009 | */ |
| 1010 | 1010 | static function is_md5($str) |
| 1011 | 1011 | { |
@@ -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 | } |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | /** |
| 21 | 21 | * Constructor |
| 22 | 22 | * |
| 23 | - * @param boolean|array $allow true=give rights, false=remove rights, or array with all 3 params |
|
| 23 | + * @param boolean $allow true=give rights, false=remove rights, or array with all 3 params |
|
| 24 | 24 | * @param string|int $account =null account name or id |
| 25 | 25 | * @param array|string $apps =null app-names |
| 26 | 26 | */ |
@@ -54,11 +54,17 @@ |
||
| 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) |
|
| 58 | + { |
|
| 59 | + $this->_check_admin($account_id > 0 ? 'account_access' : 'group_access',16); |
|
| 60 | + } |
|
| 58 | 61 | |
| 59 | 62 | $apps = admin_cmd::parse_apps($this->apps); |
| 60 | 63 | |
| 61 | - if ($check_only) return true; |
|
| 64 | + if ($check_only) |
|
| 65 | + { |
|
| 66 | + return true; |
|
| 67 | + } |
|
| 62 | 68 | |
| 63 | 69 | //echo "account=$this->account, account_id=$account_id, apps: ".implode(', ',$apps)."\n"; |
| 64 | 70 | admin_cmd::_instanciate_acl($account_id); |
@@ -77,8 +77,7 @@ |
||
| 77 | 77 | /** |
| 78 | 78 | * imports entries according to given definition object. |
| 79 | 79 | * @param resource $_stream |
| 80 | - * @param string $_charset |
|
| 81 | - * @param definition $_definition |
|
| 80 | + * @param importexport_definition $_definition |
|
| 82 | 81 | */ |
| 83 | 82 | public function import( $_stream, importexport_definition $_definition ) { |
| 84 | 83 | $import_csv = new importexport_import_csv( $_stream, array( |
@@ -15,7 +15,8 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * class import_csv for admin (groups) |
| 17 | 17 | */ |
| 18 | -class admin_import_groups_csv implements importexport_iface_import_plugin { |
|
| 18 | +class admin_import_groups_csv implements importexport_iface_import_plugin |
|
| 19 | +{ |
|
| 19 | 20 | |
| 20 | 21 | private static $plugin_options = array( |
| 21 | 22 | 'fieldsep', // char |
@@ -80,7 +81,8 @@ discard block |
||
| 80 | 81 | * @param string $_charset |
| 81 | 82 | * @param definition $_definition |
| 82 | 83 | */ |
| 83 | - public function import( $_stream, importexport_definition $_definition ) { |
|
| 84 | + public function import( $_stream, importexport_definition $_definition ) |
|
| 85 | + { |
|
| 84 | 86 | $import_csv = new importexport_import_csv( $_stream, array( |
| 85 | 87 | 'fieldsep' => $_definition->plugin_options['fieldsep'], |
| 86 | 88 | 'charset' => $_definition->plugin_options['charset'], |
@@ -98,9 +100,12 @@ discard block |
||
| 98 | 100 | $import_csv->conversion = $_definition->plugin_options['field_conversion']; |
| 99 | 101 | |
| 100 | 102 | //check if file has a header lines |
| 101 | - if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) { |
|
| 103 | + if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) |
|
| 104 | + { |
|
| 102 | 105 | $import_csv->skip_records($_definition->plugin_options['num_header_lines']); |
| 103 | - } elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) { |
|
| 106 | + } |
|
| 107 | + elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) |
|
| 108 | + { |
|
| 104 | 109 | // First method is preferred |
| 105 | 110 | $import_csv->skip_records(1); |
| 106 | 111 | } |
@@ -112,22 +117,30 @@ discard block |
||
| 112 | 117 | // Failures |
| 113 | 118 | $this->errors = array(); |
| 114 | 119 | |
| 115 | - while ( $record = $import_csv->get_record() ) { |
|
| 120 | + while ( $record = $import_csv->get_record() ) |
|
| 121 | + { |
|
| 116 | 122 | $success = false; |
| 117 | 123 | // don't import empty records |
| 118 | - if( count( array_unique( $record ) ) < 2 ) continue; |
|
| 124 | + if( count( array_unique( $record ) ) < 2 ) |
|
| 125 | + { |
|
| 126 | + continue; |
|
| 127 | + } |
|
| 119 | 128 | |
| 120 | 129 | importexport_import_csv::convert($record, admin_egw_group_record::$types, 'admin'); |
| 121 | 130 | |
| 122 | - if ( $_definition->plugin_options['conditions'] ) { |
|
| 123 | - foreach ( $_definition->plugin_options['conditions'] as $condition ) { |
|
| 124 | - switch ( $condition['type'] ) { |
|
| 131 | + if ( $_definition->plugin_options['conditions'] ) |
|
| 132 | + { |
|
| 133 | + foreach ( $_definition->plugin_options['conditions'] as $condition ) |
|
| 134 | + { |
|
| 135 | + switch ( $condition['type'] ) |
|
| 136 | + { |
|
| 125 | 137 | // exists |
| 126 | 138 | case 'exists' : |
| 127 | 139 | $accounts = array(); |
| 128 | 140 | |
| 129 | 141 | // Skip the search if the field is empty |
| 130 | - if($record[$condition['string']] !== '') { |
|
| 142 | + if($record[$condition['string']] !== '') |
|
| 143 | + { |
|
| 131 | 144 | |
| 132 | 145 | $accounts = $GLOBALS['egw']->accounts->search(array( |
| 133 | 146 | 'type' => 'groups', |
@@ -138,13 +151,18 @@ discard block |
||
| 138 | 151 | // Search looks in the given field, but doesn't do an exact match |
| 139 | 152 | foreach ( (array)$accounts as $key => $account ) |
| 140 | 153 | { |
| 141 | - if($account[$condition['string']] != $record[$condition['string']]) unset($accounts[$key]); |
|
| 154 | + if($account[$condition['string']] != $record[$condition['string']]) |
|
| 155 | + { |
|
| 156 | + unset($accounts[$key]); |
|
| 157 | + } |
|
| 142 | 158 | } |
| 143 | - if ( is_array( $accounts ) && count( $accounts ) >= 1 ) { |
|
| 159 | + if ( is_array( $accounts ) && count( $accounts ) >= 1 ) |
|
| 160 | + { |
|
| 144 | 161 | $account = current($accounts); |
| 145 | 162 | // apply action to all contacts matching this exists condition |
| 146 | 163 | $action = $condition['true']; |
| 147 | - foreach ( (array)$accounts as $account ) { |
|
| 164 | + foreach ( (array)$accounts as $account ) |
|
| 165 | + { |
|
| 148 | 166 | // Read full account, and copy needed info for accounts->save() |
| 149 | 167 | $account = $GLOBALS['egw']->accounts->read($account['account_id']); |
| 150 | 168 | $record['account_id'] = $account['account_id']; |
@@ -152,7 +170,9 @@ discard block |
||
| 152 | 170 | $record['account_lastname'] = $account['account_lastname']; |
| 153 | 171 | $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
| 154 | 172 | } |
| 155 | - } else { |
|
| 173 | + } |
|
| 174 | + else |
|
| 175 | + { |
|
| 156 | 176 | $action = $condition['false']; |
| 157 | 177 | $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
| 158 | 178 | } |
@@ -162,13 +182,21 @@ discard block |
||
| 162 | 182 | default : |
| 163 | 183 | die('condition / action not supported!!!'); |
| 164 | 184 | } |
| 165 | - if ($action['last']) break; |
|
| 185 | + if ($action['last']) |
|
| 186 | + { |
|
| 187 | + break; |
|
| 188 | + } |
|
| 166 | 189 | } |
| 167 | - } else { |
|
| 190 | + } |
|
| 191 | + else |
|
| 192 | + { |
|
| 168 | 193 | // unconditional insert |
| 169 | 194 | $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
| 170 | 195 | } |
| 171 | - if($success) $count++; |
|
| 196 | + if($success) |
|
| 197 | + { |
|
| 198 | + $count++; |
|
| 199 | + } |
|
| 172 | 200 | } |
| 173 | 201 | return $count; |
| 174 | 202 | } |
@@ -180,24 +208,29 @@ discard block |
||
| 180 | 208 | * @param array $_data contact data for the action |
| 181 | 209 | * @return bool success or not |
| 182 | 210 | */ |
| 183 | - private function action ( $_action, $_data, $record_num = 0 ) { |
|
| 184 | - switch ($_action) { |
|
| 211 | + private function action ( $_action, $_data, $record_num = 0 ) |
|
| 212 | + { |
|
| 213 | + switch ($_action) |
|
| 214 | + { |
|
| 185 | 215 | case 'none' : |
| 186 | 216 | return true; |
| 187 | 217 | case 'update' : |
| 188 | 218 | case 'create' : |
| 189 | - if(count($_data['account_members']) < 1) { |
|
| 219 | + if(count($_data['account_members']) < 1) |
|
| 220 | + { |
|
| 190 | 221 | $this->errors[$record_num] = lang('You must select at least one group member.'); |
| 191 | 222 | return false; |
| 192 | 223 | } |
| 193 | 224 | $command = new admin_cmd_edit_group($_action == 'create' ? false : $_data['account_lid'], $_data); |
| 194 | - if($this->dry_run) { |
|
| 225 | + if($this->dry_run) |
|
| 226 | + { |
|
| 195 | 227 | $this->results[$_action]++; |
| 196 | 228 | return true; |
| 197 | 229 | } |
| 198 | 230 | try { |
| 199 | 231 | $command->run(); |
| 200 | - } catch (Exception $e) { |
|
| 232 | + } |
|
| 233 | + catch (Exception $e) { |
|
| 201 | 234 | $this->errors[$record_num] = $e->getMessage(); |
| 202 | 235 | return false; |
| 203 | 236 | } |
@@ -214,7 +247,8 @@ discard block |
||
| 214 | 247 | * |
| 215 | 248 | * @return string name |
| 216 | 249 | */ |
| 217 | - public static function get_name() { |
|
| 250 | + public static function get_name() |
|
| 251 | + { |
|
| 218 | 252 | return lang('Group CSV import'); |
| 219 | 253 | } |
| 220 | 254 | |
@@ -223,7 +257,8 @@ discard block |
||
| 223 | 257 | * |
| 224 | 258 | * @return string descriprion |
| 225 | 259 | */ |
| 226 | - public static function get_description() { |
|
| 260 | + public static function get_description() |
|
| 261 | + { |
|
| 227 | 262 | return lang("Creates / updates user groups from CSV file"); |
| 228 | 263 | } |
| 229 | 264 | |
@@ -232,7 +267,8 @@ discard block |
||
| 232 | 267 | * |
| 233 | 268 | * @return string suffix (comma seperated) |
| 234 | 269 | */ |
| 235 | - public static function get_filesuffix() { |
|
| 270 | + public static function get_filesuffix() |
|
| 271 | + { |
|
| 236 | 272 | return 'csv'; |
| 237 | 273 | } |
| 238 | 274 | |
@@ -258,7 +294,8 @@ discard block |
||
| 258 | 294 | * |
| 259 | 295 | * @return string etemplate name |
| 260 | 296 | */ |
| 261 | - public function get_selectors_etpl() { |
|
| 297 | + public function get_selectors_etpl() |
|
| 298 | + { |
|
| 262 | 299 | // lets do it! |
| 263 | 300 | } |
| 264 | 301 | |
@@ -270,7 +307,8 @@ discard block |
||
| 270 | 307 | * record_# => warning message |
| 271 | 308 | * ) |
| 272 | 309 | */ |
| 273 | - public function get_warnings() { |
|
| 310 | + public function get_warnings() |
|
| 311 | + { |
|
| 274 | 312 | return $this->warnings; |
| 275 | 313 | } |
| 276 | 314 | |
@@ -282,7 +320,8 @@ discard block |
||
| 282 | 320 | * record_# => error message |
| 283 | 321 | * ) |
| 284 | 322 | */ |
| 285 | - public function get_errors() { |
|
| 323 | + public function get_errors() |
|
| 324 | + { |
|
| 286 | 325 | return $this->errors; |
| 287 | 326 | } |
| 288 | 327 | |
@@ -294,7 +333,8 @@ discard block |
||
| 294 | 333 | * action => record count |
| 295 | 334 | * ) |
| 296 | 335 | */ |
| 297 | - public function get_results() { |
|
| 336 | + public function get_results() |
|
| 337 | + { |
|
| 298 | 338 | return $this->results; |
| 299 | 339 | } |
| 300 | 340 | } |