@@ -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()) |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | * @param string $copytoreceiver=false send a copy of notification to receiver |
| 41 | 41 | * @return string html content |
| 42 | 42 | */ |
| 43 | - function display(array $content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array()) |
|
| 43 | + function display(array $content = null, $addressbook = null, $fields = null, $msg = null, $email = null, $tpl_name = null, $subject = null, $copytoreceiver = false, $sel_options = array()) |
|
| 44 | 44 | { |
| 45 | - return $this->display_var($content,$addressbook,$fields,$msg,$email,$tpl_name,$subject,$copytoreceiver,$sel_options); |
|
| 45 | + return $this->display_var($content, $addressbook, $fields, $msg, $email, $tpl_name, $subject, $copytoreceiver, $sel_options); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -58,25 +58,25 @@ discard block |
||
| 58 | 58 | * @param string $copytoreceiver=false send a copy of notification to receiver |
| 59 | 59 | * @return string html content |
| 60 | 60 | */ |
| 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()) |
|
| 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'])) $tpl_name = $content['tpl_form_name']; |
|
| 65 | 65 | $tpl = new etemplate($tpl_name ? $tpl_name : 'addressbook.contactform'); |
| 66 | 66 | // initializing some fields |
| 67 | - if (!$fields) $fields = array('org_name','n_fn','email','tel_work','url','note','captcha'); |
|
| 67 | + if (!$fields) $fields = array('org_name', 'n_fn', 'email', 'tel_work', 'url', 'note', 'captcha'); |
|
| 68 | 68 | $submitted = false; |
| 69 | 69 | // check if submitted |
| 70 | 70 | if (is_array($content)) |
| 71 | 71 | { |
| 72 | - if (isset($_POST['g-recaptcha-response'])) $recaptcha = sitemgr_module::verify_recaptcha ($_POST['g-recaptcha-response']); |
|
| 72 | + if (isset($_POST['g-recaptcha-response'])) $recaptcha = sitemgr_module::verify_recaptcha($_POST['g-recaptcha-response']); |
|
| 73 | 73 | $captcha = (isset($content['captcha_result']) && $content['captcha'] != $content['captcha_result']) || ($recaptcha && $recaptcha->success == false); |
| 74 | 74 | if ($captcha || // no correct captcha OR |
| 75 | - (time() - $content['start_time'] < 10 && // bot indicator (less then 10 sec to fill out the form and |
|
| 75 | + (time() - $content['start_time'] < 10 && // bot indicator (less then 10 sec to fill out the form and |
|
| 76 | 76 | !$GLOBALS['egw_info']['etemplate']['java_script'])) // javascript disabled) |
| 77 | 77 | { |
| 78 | 78 | $submitted = "truebutfalse"; |
| 79 | - $tpl->set_validation_error('captcha',lang('Wrong - try again ...')); |
|
| 79 | + $tpl->set_validation_error('captcha', lang('Wrong - try again ...')); |
|
| 80 | 80 | } |
| 81 | 81 | elseif ($content['submitit']) |
| 82 | 82 | { |
@@ -84,11 +84,11 @@ discard block |
||
| 84 | 84 | $contact = new Api\Contacts(); |
| 85 | 85 | if ($content['owner']) // save the contact in the addressbook |
| 86 | 86 | { |
| 87 | - $content['private'] = 0; // in case default_private is set |
|
| 87 | + $content['private'] = 0; // in case default_private is set |
|
| 88 | 88 | if (($id = $contact->save($content))) |
| 89 | 89 | { |
| 90 | 90 | // check for fileuploads and attach the found files |
| 91 | - foreach($content as $name => $value) |
|
| 91 | + foreach ($content as $name => $value) |
|
| 92 | 92 | { |
| 93 | 93 | if (is_array($value) && isset($value['tmp_name']) && is_readable($value['tmp_name'])) |
| 94 | 94 | { |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | // edit rights for the addressbook used to store the new entry, |
| 98 | 98 | // which is clearly not wanted securitywise |
| 99 | 99 | Vfs::$is_root = true; |
| 100 | - Link::link('addressbook',$id,Link::VFS_APPNAME,$value,$name); |
|
| 100 | + Link::link('addressbook', $id, Link::VFS_APPNAME, $value, $name); |
|
| 101 | 101 | Vfs::$is_root = false; |
| 102 | 102 | } |
| 103 | 103 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | { |
| 117 | 117 | $tracking = new Api\Contacts\Tracking($contact); |
| 118 | 118 | } |
| 119 | - if ($tracking->do_notifications($contact->data2db($content),null)) |
|
| 119 | + if ($tracking->do_notifications($contact->data2db($content), null)) |
|
| 120 | 120 | { |
| 121 | 121 | return '<p align="center">'.$content['msg'].'</p>'; |
| 122 | 122 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | $preserv['email_copytoreceiver'] = $copytoreceiver; |
| 140 | 140 | #if (!$fields) $fields = array('org_name','n_fn','email','tel_work','url','note','captcha'); |
| 141 | 141 | $custom = 1; |
| 142 | - foreach($fields as $name) |
|
| 142 | + foreach ($fields as $name) |
|
| 143 | 143 | { |
| 144 | 144 | if ($name[0] == '#') // custom field |
| 145 | 145 | { |
@@ -150,10 +150,10 @@ discard block |
||
| 150 | 150 | } |
| 151 | 151 | $content['show']['custom'.$custom] = true; |
| 152 | 152 | $content['customfield'][$custom] = $name; |
| 153 | - $content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label']; |
|
| 153 | + $content['customlabel'][$custom] = $contact->customfields[substr($name, 1)]['label']; |
|
| 154 | 154 | ++$custom; |
| 155 | 155 | } |
| 156 | - elseif($name == 'adr_one_locality') |
|
| 156 | + elseif ($name == 'adr_one_locality') |
|
| 157 | 157 | { |
| 158 | 158 | if (!($content['show'][$name] = $GLOBALS['egw_info']['user']['preferences']['addressbook']['addr_format'])) |
| 159 | 159 | { |
@@ -174,18 +174,18 @@ discard block |
||
| 174 | 174 | unset($content['submitit']); |
| 175 | 175 | $custom = 1; |
| 176 | 176 | // fieldnames are "defined" by the commit attempt, that way, we do not have to remember them |
| 177 | - foreach($content as $name => $value) { |
|
| 178 | - $preserv[$name]=$value; |
|
| 177 | + foreach ($content as $name => $value) { |
|
| 178 | + $preserv[$name] = $value; |
|
| 179 | 179 | if ($name[0] == '#') // custom field |
| 180 | 180 | { |
| 181 | 181 | static $contact; |
| 182 | 182 | if (is_null($contact)) $contact = new Api\Contacts(); |
| 183 | 183 | $content['show']['custom'.$custom] = true; |
| 184 | 184 | $content['customfield'][$custom] = $name; |
| 185 | - $content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label']; |
|
| 185 | + $content['customlabel'][$custom] = $contact->customfields[substr($name, 1)]['label']; |
|
| 186 | 186 | ++$custom; |
| 187 | 187 | } |
| 188 | - elseif($name == 'adr_one_locality') |
|
| 188 | + elseif ($name == 'adr_one_locality') |
|
| 189 | 189 | { |
| 190 | 190 | if (!($content['show'][$name] = $GLOBALS['egw_info']['user']['preferences']['addressbook']['addr_format'])) |
| 191 | 191 | { |
@@ -207,16 +207,16 @@ discard block |
||
| 207 | 207 | if (!sitemgr_module::get_recaptcha()) |
| 208 | 208 | { |
| 209 | 209 | // a simple calculation captcha |
| 210 | - $num1 = rand(1,99); |
|
| 211 | - $num2 = rand(1,99); |
|
| 210 | + $num1 = rand(1, 99); |
|
| 211 | + $num2 = rand(1, 99); |
|
| 212 | 212 | if ($num2 > $num1) // keep the result positive |
| 213 | 213 | { |
| 214 | 214 | $n = $num1; $num1 = $num2; $num2 = $n; |
| 215 | 215 | } |
| 216 | - if (in_array('captcha',$fields)) |
|
| 216 | + if (in_array('captcha', $fields)) |
|
| 217 | 217 | { |
| 218 | - $content['captcha_task'] = sprintf('%d - %d =',$num1,$num2); |
|
| 219 | - $preserv['captcha_result'] = $num1-$num2; |
|
| 218 | + $content['captcha_task'] = sprintf('%d - %d =', $num1, $num2); |
|
| 219 | + $preserv['captcha_result'] = $num1 - $num2; |
|
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | else |
@@ -232,6 +232,6 @@ discard block |
||
| 232 | 232 | $content = array_merge($_GET, (array)$content); |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - return $tpl->exec($this->callback,$content,$sel_options,array(),$preserv); |
|
| 235 | + return $tpl->exec($this->callback, $content, $sel_options, array(), $preserv); |
|
| 236 | 236 | } |
| 237 | 237 | } |
@@ -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 | { |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | /** |
| 37 | 37 | * Exports records as defined in $_definition |
| 38 | 38 | * |
| 39 | - * @param egw_record $_definition |
|
| 39 | + * @param importexport_definition $_definition |
|
| 40 | 40 | */ |
| 41 | 41 | public function export( $_stream, importexport_definition $_definition) { |
| 42 | 42 | |
@@ -365,10 +365,10 @@ discard block |
||
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | /** |
| 368 | - * Convert some internal data to something with more meaning |
|
| 369 | - * |
|
| 370 | - * Dates, times, user IDs, category IDs |
|
| 371 | - */ |
|
| 368 | + * Convert some internal data to something with more meaning |
|
| 369 | + * |
|
| 370 | + * Dates, times, user IDs, category IDs |
|
| 371 | + */ |
|
| 372 | 372 | public static function convert(addressbook_egw_record &$record, $options) { |
| 373 | 373 | |
| 374 | 374 | if ($record->tel_prefer) { |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | * Adjust automatically generated filter fields |
| 437 | 437 | */ |
| 438 | 438 | public function get_filter_fields(Array &$filters) |
| 439 | - { |
|
| 439 | + { |
|
| 440 | 440 | unset($filters['last_event']); |
| 441 | 441 | unset($filters['next_event']); |
| 442 | 442 | foreach($filters as $field_name => &$settings) |
@@ -38,7 +38,8 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @param egw_record $_definition |
| 40 | 40 | */ |
| 41 | - public function export( $_stream, importexport_definition $_definition) { |
|
| 41 | + public function export( $_stream, importexport_definition $_definition) |
|
| 42 | + { |
|
| 42 | 43 | |
| 43 | 44 | $options = $_definition->plugin_options; |
| 44 | 45 | $this->export_object = $export_object = new importexport_export_csv($_stream, (array)$options); |
@@ -48,8 +49,13 @@ discard block |
||
| 48 | 49 | // Addressbook defines its own export imits |
| 49 | 50 | $limit_exception = Api\Storage\Merge::is_export_limit_excepted(); |
| 50 | 51 | $export_limit = Api\Storage\Merge::getExportLimit($app='addressbook'); |
| 51 | - if (!$limit_exception) $export_object->export_limit = $export_limit; // we may not need that after all |
|
| 52 | - if($export_limit == 'no' && !$limit_exception) { |
|
| 52 | + if (!$limit_exception) |
|
| 53 | + { |
|
| 54 | + $export_object->export_limit = $export_limit; |
|
| 55 | + } |
|
| 56 | + // we may not need that after all |
|
| 57 | + if($export_limit == 'no' && !$limit_exception) |
|
| 58 | + { |
|
| 53 | 59 | return; |
| 54 | 60 | } |
| 55 | 61 | |
@@ -57,18 +63,24 @@ discard block |
||
| 57 | 63 | $old_app = $GLOBALS['egw_info']['flags']['currentapp']; |
| 58 | 64 | $GLOBALS['egw_info']['flags']['currentapp'] = 'addressbook'; |
| 59 | 65 | |
| 60 | - if ($options['selection'] == 'search') { |
|
| 66 | + if ($options['selection'] == 'search') |
|
| 67 | + { |
|
| 61 | 68 | // uicontacts selection with checkbox 'use_all' |
| 62 | 69 | $query = Api\Cache::getSession('addressbook', 'index'); |
| 63 | 70 | $query['num_rows'] = -1; // all |
| 64 | 71 | $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
| 65 | 72 | $query['order'] = 'contact_id'; |
| 66 | - if(!array_key_exists('filter',$query)) $query['filter'] = $GLOBALS['egw_info']['user']['account_id']; |
|
| 73 | + if(!array_key_exists('filter',$query)) |
|
| 74 | + { |
|
| 75 | + $query['filter'] = $GLOBALS['egw_info']['user']['account_id']; |
|
| 76 | + } |
|
| 67 | 77 | $readonlys = null; |
| 68 | 78 | $this->ui->get_rows($query,$selection,$readonlys, true); // only return the ids |
| 69 | 79 | } |
| 70 | - elseif ( $options['selection'] == 'all' ) { |
|
| 71 | - if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) { |
|
| 80 | + elseif ( $options['selection'] == 'all' ) |
|
| 81 | + { |
|
| 82 | + if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) |
|
| 83 | + { |
|
| 72 | 84 | $col_filter['account_id'] = null; |
| 73 | 85 | } |
| 74 | 86 | $selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$col_filter); |
@@ -107,11 +119,20 @@ discard block |
||
| 107 | 119 | $field = 'contact_'.$field; |
| 108 | 120 | } |
| 109 | 121 | $query['col_filter'][$field] = $value; |
| 110 | - if(!is_array($value) || (!$value['from'] && !$value['to'])) continue; |
|
| 122 | + if(!is_array($value) || (!$value['from'] && !$value['to'])) |
|
| 123 | + { |
|
| 124 | + continue; |
|
| 125 | + } |
|
| 111 | 126 | |
| 112 | 127 | // Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10) |
| 113 | - if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from']; |
|
| 114 | - if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to']; |
|
| 128 | + if($value['from']) |
|
| 129 | + { |
|
| 130 | + $query['col_filter'][] = "$field >= " . (int)$value['from']; |
|
| 131 | + } |
|
| 132 | + if($value['to']) |
|
| 133 | + { |
|
| 134 | + $query['col_filter'][] = "$field <= " . (int)$value['to']; |
|
| 135 | + } |
|
| 115 | 136 | unset($query['col_filter'][$field]); |
| 116 | 137 | } |
| 117 | 138 | $selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$query['col_filter']); |
@@ -126,29 +147,36 @@ discard block |
||
| 126 | 147 | } |
| 127 | 148 | $GLOBALS['egw_info']['flags']['currentapp'] = $old_app; |
| 128 | 149 | |
| 129 | - if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) { |
|
| 150 | + if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) |
|
| 151 | + { |
|
| 130 | 152 | $selection = array_slice($selection, 0, $export_limit); |
| 131 | 153 | } |
| 132 | 154 | |
| 133 | - if($options['explode_multiselects']) { |
|
| 155 | + if($options['explode_multiselects']) |
|
| 156 | + { |
|
| 134 | 157 | $customfields = Api\Storage\Customfields::get('addressbook'); |
| 135 | 158 | $additional_fields = array(); |
| 136 | 159 | $cat_obj = new Api\Categories('', 'addressbook'); |
| 137 | - foreach($options['explode_multiselects'] as $field => $explode) { |
|
| 138 | - switch($explode['explode']) { |
|
| 160 | + foreach($options['explode_multiselects'] as $field => $explode) |
|
| 161 | + { |
|
| 162 | + switch($explode['explode']) |
|
| 163 | + { |
|
| 139 | 164 | case self::MAIN_CATS: |
| 140 | 165 | $cats = $cat_obj->return_array('mains', 0, false,'','ASC','',true); |
| 141 | - foreach($cats as $settings) { |
|
| 166 | + foreach($cats as $settings) |
|
| 167 | + { |
|
| 142 | 168 | $additional_fields[$field][$settings['id']] = array( |
| 143 | 169 | 'count' => 0, |
| 144 | 170 | 'label' => $settings['name'], |
| 145 | 171 | 'subs' => array(), |
| 146 | 172 | ); |
| 147 | 173 | $subs = $cat_obj->return_sorted_array(0, False, '', 'ASC', 'cat_name', True, $settings['id']); |
| 148 | - foreach($subs as $sub) { |
|
| 174 | + foreach($subs as $sub) |
|
| 175 | + { |
|
| 149 | 176 | $name = $sub['name']; |
| 150 | 177 | $path = $sub; |
| 151 | - while($path['parent'] != $settings['id']) { |
|
| 178 | + while($path['parent'] != $settings['id']) |
|
| 179 | + { |
|
| 152 | 180 | $path = $cat_obj->read($path['parent']); |
| 153 | 181 | $name = $path['name'] . '/' . $name; |
| 154 | 182 | } |
@@ -158,10 +186,12 @@ discard block |
||
| 158 | 186 | break; |
| 159 | 187 | case self::EACH_CAT: |
| 160 | 188 | $cats = $cat_obj->return_array('all', 0, false,'','ASC','',true); |
| 161 | - foreach($cats as $settings) { |
|
| 189 | + foreach($cats as $settings) |
|
| 190 | + { |
|
| 162 | 191 | $name = $settings['name']; |
| 163 | 192 | $path = $settings; |
| 164 | - while($path['level'] != 0) { |
|
| 193 | + while($path['level'] != 0) |
|
| 194 | + { |
|
| 165 | 195 | $path = $cat_obj->read($path['parent']); |
| 166 | 196 | $name = $path['name'] . '/' . $name; |
| 167 | 197 | } |
@@ -174,7 +204,8 @@ discard block |
||
| 174 | 204 | case self::EXPLODE: |
| 175 | 205 | // Only works for custom fields |
| 176 | 206 | $index = substr($field, 1); |
| 177 | - foreach($customfields[$index]['values'] as $key => $value) { |
|
| 207 | + foreach($customfields[$index]['values'] as $key => $value) |
|
| 208 | + { |
|
| 178 | 209 | $additional_fields[$field][$key] = array( |
| 179 | 210 | 'count' => 0, |
| 180 | 211 | 'label' => $customfields[$index]['label'] . ': ' . $value, |
@@ -185,30 +216,47 @@ discard block |
||
| 185 | 216 | } |
| 186 | 217 | |
| 187 | 218 | // Check records to see if additional fields are actually used |
| 188 | - foreach ($selection as $_contact) { |
|
| 189 | - if(is_array($_contact) && array_key_exists('photo', $_contact)) { |
|
| 219 | + foreach ($selection as $_contact) |
|
| 220 | + { |
|
| 221 | + if(is_array($_contact) && array_key_exists('photo', $_contact)) |
|
| 222 | + { |
|
| 190 | 223 | unset($_contact['photo']); |
| 191 | 224 | } |
| 192 | - if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) { |
|
| 225 | + if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) |
|
| 226 | + { |
|
| 193 | 227 | $_contact = $_contact['id']; |
| 194 | 228 | } |
| 195 | - if(is_array($_contact) && $_contact['id']) { |
|
| 229 | + if(is_array($_contact) && $_contact['id']) |
|
| 230 | + { |
|
| 196 | 231 | $contact = new addressbook_egw_record(); |
| 197 | 232 | $contact->set_record($_contact); |
| 198 | - } else { |
|
| 233 | + } |
|
| 234 | + else |
|
| 235 | + { |
|
| 199 | 236 | $contact = new addressbook_egw_record($_contact); |
| 200 | 237 | } |
| 201 | - foreach($additional_fields as $field => &$values) { |
|
| 202 | - if(!$contact->$field) continue; |
|
| 203 | - foreach($values as $value => &$settings) { |
|
| 204 | - if(!is_array($contact->$field)) { |
|
| 238 | + foreach($additional_fields as $field => &$values) |
|
| 239 | + { |
|
| 240 | + if(!$contact->$field) |
|
| 241 | + { |
|
| 242 | + continue; |
|
| 243 | + } |
|
| 244 | + foreach($values as $value => &$settings) |
|
| 245 | + { |
|
| 246 | + if(!is_array($contact->$field)) |
|
| 247 | + { |
|
| 205 | 248 | $contact->$field = explode(',', $contact->$field); |
| 206 | 249 | } |
| 207 | - if(is_array($contact->$field) && in_array($value, $contact->$field)) { |
|
| 250 | + if(is_array($contact->$field) && in_array($value, $contact->$field)) |
|
| 251 | + { |
|
| 208 | 252 | $settings['count']++; |
| 209 | - } elseif($contact->$field == $value) { |
|
| 253 | + } |
|
| 254 | + elseif($contact->$field == $value) |
|
| 255 | + { |
|
| 210 | 256 | $settings['count']++; |
| 211 | - } elseif($options['explode_multiselects'][$field]['explode'] == self::MAIN_CATS && array_intersect($contact->$field, array_keys($settings['subs']))) { |
|
| 257 | + } |
|
| 258 | + elseif($options['explode_multiselects'][$field]['explode'] == self::MAIN_CATS && array_intersect($contact->$field, array_keys($settings['subs']))) |
|
| 259 | + { |
|
| 212 | 260 | $settings['count']++; |
| 213 | 261 | } |
| 214 | 262 | } |
@@ -220,21 +268,27 @@ discard block |
||
| 220 | 268 | unset($settings); |
| 221 | 269 | |
| 222 | 270 | // Add additional columns |
| 223 | - foreach($additional_fields as $field => $additional_values) { |
|
| 271 | + foreach($additional_fields as $field => $additional_values) |
|
| 272 | + { |
|
| 224 | 273 | // Remove original |
| 225 | 274 | unset($options['mapping'][$field]); |
| 226 | 275 | // Add exploded |
| 227 | 276 | $field_count = 0; |
| 228 | - foreach($additional_values as $value => $settings) { |
|
| 229 | - if($settings['count'] > 0) { |
|
| 277 | + foreach($additional_values as $value => $settings) |
|
| 278 | + { |
|
| 279 | + if($settings['count'] > 0) |
|
| 280 | + { |
|
| 230 | 281 | $field_count += $settings['count']; |
| 231 | 282 | $options['mapping'][$field.'-'.$value] = $settings['label']; |
| 232 | 283 | } |
| 233 | 284 | } |
| 234 | - if($field_count > 0) { |
|
| 285 | + if($field_count > 0) |
|
| 286 | + { |
|
| 235 | 287 | // Set some options for converting |
| 236 | 288 | $options['explode_multiselects'][$field]['values'] = $additional_values; |
| 237 | - } else { |
|
| 289 | + } |
|
| 290 | + else |
|
| 291 | + { |
|
| 238 | 292 | // Don't need this anymore |
| 239 | 293 | unset($options['explode_multiselects'][$field]); |
| 240 | 294 | } |
@@ -263,17 +317,23 @@ discard block |
||
| 263 | 317 | |
| 264 | 318 | // $options['selection'] is array of identifiers as this plugin doesn't |
| 265 | 319 | // support other selectors atm. |
| 266 | - foreach ($selection as $_contact) { |
|
| 267 | - if(is_array($_contact) && array_key_exists('photo', $_contact)) { |
|
| 320 | + foreach ($selection as $_contact) |
|
| 321 | + { |
|
| 322 | + if(is_array($_contact) && array_key_exists('photo', $_contact)) |
|
| 323 | + { |
|
| 268 | 324 | unset($_contact['photo']); |
| 269 | 325 | } |
| 270 | - if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) { |
|
| 326 | + if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) |
|
| 327 | + { |
|
| 271 | 328 | $_contact = $_contact['id']; |
| 272 | 329 | } |
| 273 | - if(is_array($_contact) && $_contact['id']) { |
|
| 330 | + if(is_array($_contact) && $_contact['id']) |
|
| 331 | + { |
|
| 274 | 332 | $contact = new addressbook_egw_record(); |
| 275 | 333 | $contact->set_record($_contact); |
| 276 | - } else { |
|
| 334 | + } |
|
| 335 | + else |
|
| 336 | + { |
|
| 277 | 337 | $contact = new addressbook_egw_record($_contact); |
| 278 | 338 | } |
| 279 | 339 | |
@@ -286,12 +346,19 @@ discard block |
||
| 286 | 346 | } |
| 287 | 347 | // Some conversion |
| 288 | 348 | $this->convert($contact, $options); |
| 289 | - if($options['convert']) { |
|
| 349 | + if($options['convert']) |
|
| 350 | + { |
|
| 290 | 351 | importexport_export_csv::convert($contact, addressbook_egw_record::$types, 'addressbook',$this->selects); |
| 291 | - } else { |
|
| 352 | + } |
|
| 353 | + else |
|
| 354 | + { |
|
| 292 | 355 | // Implode arrays, so they don't say 'Array' |
| 293 | - foreach($contact->get_record_array() as $key => $value) { |
|
| 294 | - if(is_array($value)) $contact->$key = implode(',', $value); |
|
| 356 | + foreach($contact->get_record_array() as $key => $value) |
|
| 357 | + { |
|
| 358 | + if(is_array($value)) |
|
| 359 | + { |
|
| 360 | + $contact->$key = implode(',', $value); |
|
| 361 | + } |
|
| 295 | 362 | } |
| 296 | 363 | } |
| 297 | 364 | |
@@ -306,7 +373,8 @@ discard block |
||
| 306 | 373 | * |
| 307 | 374 | * @return string name |
| 308 | 375 | */ |
| 309 | - public static function get_name() { |
|
| 376 | + public static function get_name() |
|
| 377 | + { |
|
| 310 | 378 | return lang('Addressbook CSV export'); |
| 311 | 379 | } |
| 312 | 380 | |
@@ -315,7 +383,8 @@ discard block |
||
| 315 | 383 | * |
| 316 | 384 | * @return string descriprion |
| 317 | 385 | */ |
| 318 | - public static function get_description() { |
|
| 386 | + public static function get_description() |
|
| 387 | + { |
|
| 319 | 388 | return lang("Exports contacts from your Addressbook into a CSV File."); |
| 320 | 389 | } |
| 321 | 390 | |
@@ -324,11 +393,13 @@ discard block |
||
| 324 | 393 | * |
| 325 | 394 | * @return string suffix |
| 326 | 395 | */ |
| 327 | - public static function get_filesuffix() { |
|
| 396 | + public static function get_filesuffix() |
|
| 397 | + { |
|
| 328 | 398 | return 'csv'; |
| 329 | 399 | } |
| 330 | 400 | |
| 331 | - public static function get_mimetype() { |
|
| 401 | + public static function get_mimetype() |
|
| 402 | + { |
|
| 332 | 403 | return 'text/csv'; |
| 333 | 404 | } |
| 334 | 405 | |
@@ -351,14 +422,16 @@ discard block |
||
| 351 | 422 | * |
| 352 | 423 | * @return string html |
| 353 | 424 | */ |
| 354 | - public function get_options_etpl() { |
|
| 425 | + public function get_options_etpl() |
|
| 426 | + { |
|
| 355 | 427 | } |
| 356 | 428 | |
| 357 | 429 | /** |
| 358 | 430 | * returns slectors of this plugin via xajax |
| 359 | 431 | * |
| 360 | 432 | */ |
| 361 | - public function get_selectors_etpl() { |
|
| 433 | + public function get_selectors_etpl() |
|
| 434 | + { |
|
| 362 | 435 | return array( |
| 363 | 436 | 'name' => 'importexport.export_csv_selectors', |
| 364 | 437 | ); |
@@ -369,9 +442,11 @@ discard block |
||
| 369 | 442 | * |
| 370 | 443 | * Dates, times, user IDs, category IDs |
| 371 | 444 | */ |
| 372 | - public static function convert(addressbook_egw_record &$record, $options) { |
|
| 445 | + public static function convert(addressbook_egw_record &$record, $options) |
|
| 446 | + { |
|
| 373 | 447 | |
| 374 | - if ($record->tel_prefer) { |
|
| 448 | + if ($record->tel_prefer) |
|
| 449 | + { |
|
| 375 | 450 | $field = $record->tel_prefer; |
| 376 | 451 | $record->tel_prefer = $record->$field; |
| 377 | 452 | } |
@@ -380,33 +455,52 @@ discard block |
||
| 380 | 455 | { |
| 381 | 456 | return; |
| 382 | 457 | } |
| 383 | - foreach((array)$options['explode_multiselects'] as $field => $explode_settings) { |
|
| 384 | - if(!is_array($record->$field)) $record->$field = explode(',', $record->$field); |
|
| 385 | - foreach((array)$explode_settings['values'] as $value => $settings) { |
|
| 458 | + foreach((array)$options['explode_multiselects'] as $field => $explode_settings) |
|
| 459 | + { |
|
| 460 | + if(!is_array($record->$field)) |
|
| 461 | + { |
|
| 462 | + $record->$field = explode(',', $record->$field); |
|
| 463 | + } |
|
| 464 | + foreach((array)$explode_settings['values'] as $value => $settings) |
|
| 465 | + { |
|
| 386 | 466 | $field_name = "$field-$value"; |
| 387 | 467 | $record->$field_name = array(); |
| 388 | - if(is_array($record->$field) && in_array($value, $record->$field) || $record->$field == $value) { |
|
| 389 | - if($explode_settings['explode'] != self::MAIN_CATS) { |
|
| 468 | + if(is_array($record->$field) && in_array($value, $record->$field) || $record->$field == $value) |
|
| 469 | + { |
|
| 470 | + if($explode_settings['explode'] != self::MAIN_CATS) |
|
| 471 | + { |
|
| 390 | 472 | $record->$field_name = $options['convert'] ? lang('Yes') : true; |
| 391 | - } elseif($options['convert']) { |
|
| 473 | + } |
|
| 474 | + elseif($options['convert']) |
|
| 475 | + { |
|
| 392 | 476 | // 3 part assign due to magic get method |
| 393 | 477 | $record_value = $record->$field_name; |
| 394 | 478 | $record_value[] = $settings['label']; |
| 395 | 479 | $record->$field_name = $record_value; |
| 396 | - } else { |
|
| 480 | + } |
|
| 481 | + else |
|
| 482 | + { |
|
| 397 | 483 | $record->$field_name = $value; |
| 398 | 484 | } |
| 399 | 485 | } |
| 400 | - if($explode_settings['explode'] == self::MAIN_CATS && count(array_intersect($record->$field, array_keys($settings['subs'])))) { |
|
| 486 | + if($explode_settings['explode'] == self::MAIN_CATS && count(array_intersect($record->$field, array_keys($settings['subs'])))) |
|
| 487 | + { |
|
| 401 | 488 | // 3 part assign due to magic get method |
| 402 | 489 | $record_value = $record->$field_name; |
| 403 | - if(!is_array($record_value)) $record_value = array($record_value); |
|
| 404 | - foreach(array_intersect($record->$field, array_keys($settings['subs'])) as $sub_id) { |
|
| 490 | + if(!is_array($record_value)) |
|
| 491 | + { |
|
| 492 | + $record_value = array($record_value); |
|
| 493 | + } |
|
| 494 | + foreach(array_intersect($record->$field, array_keys($settings['subs'])) as $sub_id) |
|
| 495 | + { |
|
| 405 | 496 | $record_value[] = $options['convert'] ? $settings['subs'][$sub_id] : $sub_id; |
| 406 | 497 | } |
| 407 | 498 | $record->$field_name = $record_value; |
| 408 | 499 | } |
| 409 | - if(is_array($record->$field_name)) $record->$field_name = implode(($options['convert'] ? ', ' : ','), $record->$field_name); |
|
| 500 | + if(is_array($record->$field_name)) |
|
| 501 | + { |
|
| 502 | + $record->$field_name = implode(($options['convert'] ? ', ' : ','), $record->$field_name); |
|
| 503 | + } |
|
| 410 | 504 | } |
| 411 | 505 | } |
| 412 | 506 | } |
@@ -436,12 +530,15 @@ discard block |
||
| 436 | 530 | * Adjust automatically generated filter fields |
| 437 | 531 | */ |
| 438 | 532 | public function get_filter_fields(Array &$filters) |
| 439 | - { |
|
| 533 | + { |
|
| 440 | 534 | unset($filters['last_event']); |
| 441 | 535 | unset($filters['next_event']); |
| 442 | 536 | foreach($filters as $field_name => &$settings) |
| 443 | 537 | { |
| 444 | - if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
| 538 | + if($this->selects[$field_name]) |
|
| 539 | + { |
|
| 540 | + $settings['values'] = $this->selects[$field_name]; |
|
| 541 | + } |
|
| 445 | 542 | } |
| 446 | 543 | $filters['owner'] = array( |
| 447 | 544 | 'name' => 'owner', |
@@ -435,7 +435,7 @@ |
||
| 435 | 435 | /** |
| 436 | 436 | * Adjust automatically generated filter fields |
| 437 | 437 | */ |
| 438 | - public function get_filter_fields(Array &$filters) |
|
| 438 | + public function get_filter_fields(array &$filters) |
|
| 439 | 439 | { |
| 440 | 440 | unset($filters['last_event']); |
| 441 | 441 | unset($filters['next_event']); |
@@ -23,13 +23,13 @@ discard block |
||
| 23 | 23 | * Constants used for exploding categories & multi-selectboxes into seperate fields |
| 24 | 24 | */ |
| 25 | 25 | const NO_EXPLODE = False; |
| 26 | - const MAIN_CATS = 'main_cats'; // Only the top-level categories get their own field |
|
| 27 | - const EACH_CAT = 'each_cat'; // Every category gets its own field |
|
| 28 | - const EXPLODE = 'explode'; // For [custom] multi-selects, each option gets its own field |
|
| 26 | + const MAIN_CATS = 'main_cats'; // Only the top-level categories get their own field |
|
| 27 | + const EACH_CAT = 'each_cat'; // Every category gets its own field |
|
| 28 | + const EXPLODE = 'explode'; // For [custom] multi-selects, each option gets its own field |
|
| 29 | 29 | |
| 30 | 30 | public function __construct() |
| 31 | 31 | { |
| 32 | - $this->ui= new addressbook_ui(); |
|
| 32 | + $this->ui = new addressbook_ui(); |
|
| 33 | 33 | $this->get_selects(); |
| 34 | 34 | } |
| 35 | 35 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @param egw_record $_definition |
| 40 | 40 | */ |
| 41 | - public function export( $_stream, importexport_definition $_definition) { |
|
| 41 | + public function export($_stream, importexport_definition $_definition) { |
|
| 42 | 42 | |
| 43 | 43 | $options = $_definition->plugin_options; |
| 44 | 44 | $this->export_object = $export_object = new importexport_export_csv($_stream, (array)$options); |
@@ -47,9 +47,9 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | // Addressbook defines its own export imits |
| 49 | 49 | $limit_exception = Api\Storage\Merge::is_export_limit_excepted(); |
| 50 | - $export_limit = Api\Storage\Merge::getExportLimit($app='addressbook'); |
|
| 50 | + $export_limit = Api\Storage\Merge::getExportLimit($app = 'addressbook'); |
|
| 51 | 51 | if (!$limit_exception) $export_object->export_limit = $export_limit; // we may not need that after all |
| 52 | - if($export_limit == 'no' && !$limit_exception) { |
|
| 52 | + if ($export_limit == 'no' && !$limit_exception) { |
|
| 53 | 53 | return; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -60,18 +60,18 @@ discard block |
||
| 60 | 60 | if ($options['selection'] == 'search') { |
| 61 | 61 | // uicontacts selection with checkbox 'use_all' |
| 62 | 62 | $query = Api\Cache::getSession('addressbook', 'index'); |
| 63 | - $query['num_rows'] = -1; // all |
|
| 64 | - $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
| 63 | + $query['num_rows'] = -1; // all |
|
| 64 | + $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
| 65 | 65 | $query['order'] = 'contact_id'; |
| 66 | - if(!array_key_exists('filter',$query)) $query['filter'] = $GLOBALS['egw_info']['user']['account_id']; |
|
| 66 | + if (!array_key_exists('filter', $query)) $query['filter'] = $GLOBALS['egw_info']['user']['account_id']; |
|
| 67 | 67 | $readonlys = null; |
| 68 | - $this->ui->get_rows($query,$selection,$readonlys, true); // only return the ids |
|
| 68 | + $this->ui->get_rows($query, $selection, $readonlys, true); // only return the ids |
|
| 69 | 69 | } |
| 70 | - elseif ( $options['selection'] == 'all' ) { |
|
| 70 | + elseif ($options['selection'] == 'all') { |
|
| 71 | 71 | if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) { |
| 72 | 72 | $col_filter['account_id'] = null; |
| 73 | 73 | } |
| 74 | - $selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$col_filter); |
|
| 74 | + $selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '', '', false, 'AND', false, $col_filter); |
|
| 75 | 75 | //$uicontacts->get_rows($query,$selection,$readonlys,true); |
| 76 | 76 | } |
| 77 | 77 | elseif ($options['selection'] == 'filter') |
@@ -80,90 +80,90 @@ discard block |
||
| 80 | 80 | $query = array(); |
| 81 | 81 | |
| 82 | 82 | // Handle ranges |
| 83 | - foreach($filter as $field => $value) |
|
| 83 | + foreach ($filter as $field => $value) |
|
| 84 | 84 | { |
| 85 | - if($field == 'cat_id') |
|
| 85 | + if ($field == 'cat_id') |
|
| 86 | 86 | { |
| 87 | - $query['col_filter'][$field] = implode(',',$value); |
|
| 87 | + $query['col_filter'][$field] = implode(',', $value); |
|
| 88 | 88 | continue; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | // Birthdays in addressbook are formatted Y-m-d |
| 92 | - if($field == 'bday') |
|
| 92 | + if ($field == 'bday') |
|
| 93 | 93 | { |
| 94 | - if($value['from']) |
|
| 94 | + if ($value['from']) |
|
| 95 | 95 | { |
| 96 | - $query['col_filter'][] = "contact_bday >= " . $GLOBALS['egw']->db->quote(date('Y-m-d', (int)$value['from'])); |
|
| 96 | + $query['col_filter'][] = "contact_bday >= ".$GLOBALS['egw']->db->quote(date('Y-m-d', (int)$value['from'])); |
|
| 97 | 97 | } |
| 98 | - if($value['to']) |
|
| 98 | + if ($value['to']) |
|
| 99 | 99 | { |
| 100 | - $query['col_filter'][] = "contact_bday <= " . $GLOBALS['egw']->db->quote(date('Y-m-d', (int)$value['to'])); |
|
| 100 | + $query['col_filter'][] = "contact_bday <= ".$GLOBALS['egw']->db->quote(date('Y-m-d', (int)$value['to'])); |
|
| 101 | 101 | } |
| 102 | 102 | continue; |
| 103 | 103 | } |
| 104 | 104 | // Custom fields & listed exceptions are not filtered with contact_ prefix |
| 105 | - if(strpos($field, '#') !== 0 && !in_array($field, array('tid','owner'))) |
|
| 105 | + if (strpos($field, '#') !== 0 && !in_array($field, array('tid', 'owner'))) |
|
| 106 | 106 | { |
| 107 | 107 | $field = 'contact_'.$field; |
| 108 | 108 | } |
| 109 | 109 | $query['col_filter'][$field] = $value; |
| 110 | - if(!is_array($value) || (!$value['from'] && !$value['to'])) continue; |
|
| 110 | + if (!is_array($value) || (!$value['from'] && !$value['to'])) continue; |
|
| 111 | 111 | |
| 112 | 112 | // Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10) |
| 113 | - if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from']; |
|
| 114 | - if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to']; |
|
| 113 | + if ($value['from']) $query['col_filter'][] = "$field >= ".(int)$value['from']; |
|
| 114 | + if ($value['to']) $query['col_filter'][] = "$field <= ".(int)$value['to']; |
|
| 115 | 115 | unset($query['col_filter'][$field]); |
| 116 | 116 | } |
| 117 | - $selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$query['col_filter']); |
|
| 117 | + $selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '', '', false, 'AND', false, $query['col_filter']); |
|
| 118 | 118 | } |
| 119 | 119 | else |
| 120 | 120 | { |
| 121 | - $selection = explode(',',$options['selection']); |
|
| 121 | + $selection = explode(',', $options['selection']); |
|
| 122 | 122 | } |
| 123 | - if(!is_array($selection)) |
|
| 123 | + if (!is_array($selection)) |
|
| 124 | 124 | { |
| 125 | 125 | $selection = array(); |
| 126 | 126 | } |
| 127 | 127 | $GLOBALS['egw_info']['flags']['currentapp'] = $old_app; |
| 128 | 128 | |
| 129 | - if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) { |
|
| 129 | + if (Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) { |
|
| 130 | 130 | $selection = array_slice($selection, 0, $export_limit); |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - if($options['explode_multiselects']) { |
|
| 133 | + if ($options['explode_multiselects']) { |
|
| 134 | 134 | $customfields = Api\Storage\Customfields::get('addressbook'); |
| 135 | 135 | $additional_fields = array(); |
| 136 | 136 | $cat_obj = new Api\Categories('', 'addressbook'); |
| 137 | - foreach($options['explode_multiselects'] as $field => $explode) { |
|
| 138 | - switch($explode['explode']) { |
|
| 137 | + foreach ($options['explode_multiselects'] as $field => $explode) { |
|
| 138 | + switch ($explode['explode']) { |
|
| 139 | 139 | case self::MAIN_CATS: |
| 140 | - $cats = $cat_obj->return_array('mains', 0, false,'','ASC','',true); |
|
| 141 | - foreach($cats as $settings) { |
|
| 140 | + $cats = $cat_obj->return_array('mains', 0, false, '', 'ASC', '', true); |
|
| 141 | + foreach ($cats as $settings) { |
|
| 142 | 142 | $additional_fields[$field][$settings['id']] = array( |
| 143 | 143 | 'count' => 0, |
| 144 | 144 | 'label' => $settings['name'], |
| 145 | 145 | 'subs' => array(), |
| 146 | 146 | ); |
| 147 | 147 | $subs = $cat_obj->return_sorted_array(0, False, '', 'ASC', 'cat_name', True, $settings['id']); |
| 148 | - foreach($subs as $sub) { |
|
| 148 | + foreach ($subs as $sub) { |
|
| 149 | 149 | $name = $sub['name']; |
| 150 | 150 | $path = $sub; |
| 151 | - while($path['parent'] != $settings['id']) { |
|
| 151 | + while ($path['parent'] != $settings['id']) { |
|
| 152 | 152 | $path = $cat_obj->read($path['parent']); |
| 153 | - $name = $path['name'] . '/' . $name; |
|
| 153 | + $name = $path['name'].'/'.$name; |
|
| 154 | 154 | } |
| 155 | 155 | $additional_fields[$field][$settings['id']]['subs'][$sub['id']] = $name; |
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | break; |
| 159 | 159 | case self::EACH_CAT: |
| 160 | - $cats = $cat_obj->return_array('all', 0, false,'','ASC','',true); |
|
| 161 | - foreach($cats as $settings) { |
|
| 160 | + $cats = $cat_obj->return_array('all', 0, false, '', 'ASC', '', true); |
|
| 161 | + foreach ($cats as $settings) { |
|
| 162 | 162 | $name = $settings['name']; |
| 163 | 163 | $path = $settings; |
| 164 | - while($path['level'] != 0) { |
|
| 164 | + while ($path['level'] != 0) { |
|
| 165 | 165 | $path = $cat_obj->read($path['parent']); |
| 166 | - $name = $path['name'] . '/' . $name; |
|
| 166 | + $name = $path['name'].'/'.$name; |
|
| 167 | 167 | } |
| 168 | 168 | $additional_fields[$field][$settings['id']] = array( |
| 169 | 169 | 'count' => 0, |
@@ -174,10 +174,10 @@ discard block |
||
| 174 | 174 | case self::EXPLODE: |
| 175 | 175 | // Only works for custom fields |
| 176 | 176 | $index = substr($field, 1); |
| 177 | - foreach($customfields[$index]['values'] as $key => $value) { |
|
| 177 | + foreach ($customfields[$index]['values'] as $key => $value) { |
|
| 178 | 178 | $additional_fields[$field][$key] = array( |
| 179 | 179 | 'count' => 0, |
| 180 | - 'label' => $customfields[$index]['label'] . ': ' . $value, |
|
| 180 | + 'label' => $customfields[$index]['label'].': '.$value, |
|
| 181 | 181 | ); |
| 182 | 182 | } |
| 183 | 183 | break; |
@@ -186,29 +186,29 @@ discard block |
||
| 186 | 186 | |
| 187 | 187 | // Check records to see if additional fields are actually used |
| 188 | 188 | foreach ($selection as $_contact) { |
| 189 | - if(is_array($_contact) && array_key_exists('photo', $_contact)) { |
|
| 189 | + if (is_array($_contact) && array_key_exists('photo', $_contact)) { |
|
| 190 | 190 | unset($_contact['photo']); |
| 191 | 191 | } |
| 192 | - if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) { |
|
| 192 | + if (is_array($_contact) && count($_contact) == 1 && $_contact['id']) { |
|
| 193 | 193 | $_contact = $_contact['id']; |
| 194 | 194 | } |
| 195 | - if(is_array($_contact) && $_contact['id']) { |
|
| 195 | + if (is_array($_contact) && $_contact['id']) { |
|
| 196 | 196 | $contact = new addressbook_egw_record(); |
| 197 | 197 | $contact->set_record($_contact); |
| 198 | 198 | } else { |
| 199 | 199 | $contact = new addressbook_egw_record($_contact); |
| 200 | 200 | } |
| 201 | - foreach($additional_fields as $field => &$values) { |
|
| 202 | - if(!$contact->$field) continue; |
|
| 203 | - foreach($values as $value => &$settings) { |
|
| 204 | - if(!is_array($contact->$field)) { |
|
| 201 | + foreach ($additional_fields as $field => &$values) { |
|
| 202 | + if (!$contact->$field) continue; |
|
| 203 | + foreach ($values as $value => &$settings) { |
|
| 204 | + if (!is_array($contact->$field)) { |
|
| 205 | 205 | $contact->$field = explode(',', $contact->$field); |
| 206 | 206 | } |
| 207 | - if(is_array($contact->$field) && in_array($value, $contact->$field)) { |
|
| 207 | + if (is_array($contact->$field) && in_array($value, $contact->$field)) { |
|
| 208 | 208 | $settings['count']++; |
| 209 | - } elseif($contact->$field == $value) { |
|
| 209 | + } elseif ($contact->$field == $value) { |
|
| 210 | 210 | $settings['count']++; |
| 211 | - } elseif($options['explode_multiselects'][$field]['explode'] == self::MAIN_CATS && array_intersect($contact->$field, array_keys($settings['subs']))) { |
|
| 211 | + } elseif ($options['explode_multiselects'][$field]['explode'] == self::MAIN_CATS && array_intersect($contact->$field, array_keys($settings['subs']))) { |
|
| 212 | 212 | $settings['count']++; |
| 213 | 213 | } |
| 214 | 214 | } |
@@ -220,18 +220,18 @@ discard block |
||
| 220 | 220 | unset($settings); |
| 221 | 221 | |
| 222 | 222 | // Add additional columns |
| 223 | - foreach($additional_fields as $field => $additional_values) { |
|
| 223 | + foreach ($additional_fields as $field => $additional_values) { |
|
| 224 | 224 | // Remove original |
| 225 | 225 | unset($options['mapping'][$field]); |
| 226 | 226 | // Add exploded |
| 227 | 227 | $field_count = 0; |
| 228 | - foreach($additional_values as $value => $settings) { |
|
| 229 | - if($settings['count'] > 0) { |
|
| 228 | + foreach ($additional_values as $value => $settings) { |
|
| 229 | + if ($settings['count'] > 0) { |
|
| 230 | 230 | $field_count += $settings['count']; |
| 231 | 231 | $options['mapping'][$field.'-'.$value] = $settings['label']; |
| 232 | 232 | } |
| 233 | 233 | } |
| 234 | - if($field_count > 0) { |
|
| 234 | + if ($field_count > 0) { |
|
| 235 | 235 | // Set some options for converting |
| 236 | 236 | $options['explode_multiselects'][$field]['values'] = $additional_values; |
| 237 | 237 | } else { |
@@ -244,12 +244,12 @@ discard block |
||
| 244 | 244 | $export_object->set_mapping($options['mapping']); |
| 245 | 245 | |
| 246 | 246 | // Add in last/next event, if needed |
| 247 | - if($options['mapping']['last_date'] || $options['mapping']['next_date']) |
|
| 247 | + if ($options['mapping']['last_date'] || $options['mapping']['next_date']) |
|
| 248 | 248 | { |
| 249 | 249 | $contact_ids = array(); |
| 250 | - foreach($selection as $_contact) |
|
| 250 | + foreach ($selection as $_contact) |
|
| 251 | 251 | { |
| 252 | - if(is_array($_contact) && $_contact['id']) |
|
| 252 | + if (is_array($_contact) && $_contact['id']) |
|
| 253 | 253 | { |
| 254 | 254 | $contact_ids[] = $_contact['account_id'] ? $_contact['account_id'] : 'c'.$_contact['id']; |
| 255 | 255 | } |
@@ -264,20 +264,20 @@ discard block |
||
| 264 | 264 | // $options['selection'] is array of identifiers as this plugin doesn't |
| 265 | 265 | // support other selectors atm. |
| 266 | 266 | foreach ($selection as $_contact) { |
| 267 | - if(is_array($_contact) && array_key_exists('photo', $_contact)) { |
|
| 267 | + if (is_array($_contact) && array_key_exists('photo', $_contact)) { |
|
| 268 | 268 | unset($_contact['photo']); |
| 269 | 269 | } |
| 270 | - if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) { |
|
| 270 | + if (is_array($_contact) && count($_contact) == 1 && $_contact['id']) { |
|
| 271 | 271 | $_contact = $_contact['id']; |
| 272 | 272 | } |
| 273 | - if(is_array($_contact) && $_contact['id']) { |
|
| 273 | + if (is_array($_contact) && $_contact['id']) { |
|
| 274 | 274 | $contact = new addressbook_egw_record(); |
| 275 | 275 | $contact->set_record($_contact); |
| 276 | 276 | } else { |
| 277 | 277 | $contact = new addressbook_egw_record($_contact); |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - if($events && $events[$contact->id]) |
|
| 280 | + if ($events && $events[$contact->id]) |
|
| 281 | 281 | { |
| 282 | 282 | // NB: last_date and next_date are used instead of last_event & next_event |
| 283 | 283 | // to avoid automatic conversion - we want to export link title, not date-time |
@@ -286,12 +286,12 @@ discard block |
||
| 286 | 286 | } |
| 287 | 287 | // Some conversion |
| 288 | 288 | $this->convert($contact, $options); |
| 289 | - if($options['convert']) { |
|
| 290 | - importexport_export_csv::convert($contact, addressbook_egw_record::$types, 'addressbook',$this->selects); |
|
| 289 | + if ($options['convert']) { |
|
| 290 | + importexport_export_csv::convert($contact, addressbook_egw_record::$types, 'addressbook', $this->selects); |
|
| 291 | 291 | } else { |
| 292 | 292 | // Implode arrays, so they don't say 'Array' |
| 293 | - foreach($contact->get_record_array() as $key => $value) { |
|
| 294 | - if(is_array($value)) $contact->$key = implode(',', $value); |
|
| 293 | + foreach ($contact->get_record_array() as $key => $value) { |
|
| 294 | + if (is_array($value)) $contact->$key = implode(',', $value); |
|
| 295 | 295 | } |
| 296 | 296 | } |
| 297 | 297 | |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | */ |
| 339 | 339 | public function get_filename() |
| 340 | 340 | { |
| 341 | - if(is_object($this->export_object) && $this->export_object->get_num_of_records() == 1) |
|
| 341 | + if (is_object($this->export_object) && $this->export_object->get_num_of_records() == 1) |
|
| 342 | 342 | { |
| 343 | 343 | return $this->export_object->record->get_title(); |
| 344 | 344 | } |
@@ -369,26 +369,26 @@ discard block |
||
| 369 | 369 | * |
| 370 | 370 | * Dates, times, user IDs, category IDs |
| 371 | 371 | */ |
| 372 | - public static function convert(addressbook_egw_record &$record, $options) { |
|
| 372 | + public static function convert(addressbook_egw_record&$record, $options) { |
|
| 373 | 373 | |
| 374 | 374 | if ($record->tel_prefer) { |
| 375 | 375 | $field = $record->tel_prefer; |
| 376 | 376 | $record->tel_prefer = $record->$field; |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - if(!is_array($options['explode_multiselects'])) |
|
| 379 | + if (!is_array($options['explode_multiselects'])) |
|
| 380 | 380 | { |
| 381 | 381 | return; |
| 382 | 382 | } |
| 383 | - foreach((array)$options['explode_multiselects'] as $field => $explode_settings) { |
|
| 384 | - if(!is_array($record->$field)) $record->$field = explode(',', $record->$field); |
|
| 385 | - foreach((array)$explode_settings['values'] as $value => $settings) { |
|
| 383 | + foreach ((array)$options['explode_multiselects'] as $field => $explode_settings) { |
|
| 384 | + if (!is_array($record->$field)) $record->$field = explode(',', $record->$field); |
|
| 385 | + foreach ((array)$explode_settings['values'] as $value => $settings) { |
|
| 386 | 386 | $field_name = "$field-$value"; |
| 387 | 387 | $record->$field_name = array(); |
| 388 | - if(is_array($record->$field) && in_array($value, $record->$field) || $record->$field == $value) { |
|
| 389 | - if($explode_settings['explode'] != self::MAIN_CATS) { |
|
| 388 | + if (is_array($record->$field) && in_array($value, $record->$field) || $record->$field == $value) { |
|
| 389 | + if ($explode_settings['explode'] != self::MAIN_CATS) { |
|
| 390 | 390 | $record->$field_name = $options['convert'] ? lang('Yes') : true; |
| 391 | - } elseif($options['convert']) { |
|
| 391 | + } elseif ($options['convert']) { |
|
| 392 | 392 | // 3 part assign due to magic get method |
| 393 | 393 | $record_value = $record->$field_name; |
| 394 | 394 | $record_value[] = $settings['label']; |
@@ -397,16 +397,16 @@ discard block |
||
| 397 | 397 | $record->$field_name = $value; |
| 398 | 398 | } |
| 399 | 399 | } |
| 400 | - if($explode_settings['explode'] == self::MAIN_CATS && count(array_intersect($record->$field, array_keys($settings['subs'])))) { |
|
| 400 | + if ($explode_settings['explode'] == self::MAIN_CATS && count(array_intersect($record->$field, array_keys($settings['subs'])))) { |
|
| 401 | 401 | // 3 part assign due to magic get method |
| 402 | 402 | $record_value = $record->$field_name; |
| 403 | - if(!is_array($record_value)) $record_value = array($record_value); |
|
| 404 | - foreach(array_intersect($record->$field, array_keys($settings['subs'])) as $sub_id) { |
|
| 403 | + if (!is_array($record_value)) $record_value = array($record_value); |
|
| 404 | + foreach (array_intersect($record->$field, array_keys($settings['subs'])) as $sub_id) { |
|
| 405 | 405 | $record_value[] = $options['convert'] ? $settings['subs'][$sub_id] : $sub_id; |
| 406 | 406 | } |
| 407 | 407 | $record->$field_name = $record_value; |
| 408 | 408 | } |
| 409 | - if(is_array($record->$field_name)) $record->$field_name = implode(($options['convert'] ? ', ' : ','), $record->$field_name); |
|
| 409 | + if (is_array($record->$field_name)) $record->$field_name = implode(($options['convert'] ? ', ' : ','), $record->$field_name); |
|
| 410 | 410 | } |
| 411 | 411 | } |
| 412 | 412 | } |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | $this->selects = array( |
| 418 | 418 | 'tid' => array('n' => 'Contact') |
| 419 | 419 | ); |
| 420 | - foreach($this->ui->content_types as $tid => $data) |
|
| 420 | + foreach ($this->ui->content_types as $tid => $data) |
|
| 421 | 421 | { |
| 422 | 422 | $this->selects['tid'][$tid] = $data['name']; |
| 423 | 423 | } |
@@ -439,9 +439,9 @@ discard block |
||
| 439 | 439 | { |
| 440 | 440 | unset($filters['last_event']); |
| 441 | 441 | unset($filters['next_event']); |
| 442 | - foreach($filters as $field_name => &$settings) |
|
| 442 | + foreach ($filters as $field_name => &$settings) |
|
| 443 | 443 | { |
| 444 | - if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
| 444 | + if ($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
| 445 | 445 | } |
| 446 | 446 | $filters['owner'] = array( |
| 447 | 447 | 'name' => 'owner', |
@@ -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 | { |
@@ -30,13 +30,13 @@ discard block |
||
| 30 | 30 | $context['appname'] = 'addressbook'; |
| 31 | 31 | |
| 32 | 32 | // Let parent handle the basic stuff |
| 33 | - parent::__construct($context,$need_reload); |
|
| 33 | + parent::__construct($context, $need_reload); |
|
| 34 | 34 | |
| 35 | 35 | $ui = new addressbook_ui(); |
| 36 | 36 | |
| 37 | 37 | $this->context['template'] = 'addressbook.index.rows'; |
| 38 | 38 | $this->context['sel_options'] = array(); |
| 39 | - foreach($ui->content_types as $tid => $data) |
|
| 39 | + foreach ($ui->content_types as $tid => $data) |
|
| 40 | 40 | { |
| 41 | 41 | $this->context['sel_options']['tid'][$tid] = $data['name']; |
| 42 | 42 | } |
@@ -49,11 +49,11 @@ discard block |
||
| 49 | 49 | ); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public function exec($id = null, Etemplate &$etemplate = null) |
|
| 52 | + public function exec($id = null, Etemplate&$etemplate = null) |
|
| 53 | 53 | { |
| 54 | 54 | $ui = new addressbook_ui(); |
| 55 | - $this->context['sel_options']['filter'] = $this->context['sel_options']['owner'] = $ui->get_addressbooks(Acl::READ,lang('All')); |
|
| 56 | - $this->context['sel_options']['filter2'] = $ui->get_lists(Acl::READ,array('' => lang('none'))); |
|
| 55 | + $this->context['sel_options']['filter'] = $this->context['sel_options']['owner'] = $ui->get_addressbooks(Acl::READ, lang('All')); |
|
| 56 | + $this->context['sel_options']['filter2'] = $ui->get_lists(Acl::READ, array('' => lang('none'))); |
|
| 57 | 57 | $this->nm_settings['actions'] = $ui->get_actions($this->nm_settings['col_filter']['tid'], $this->nm_settings['org_view']); |
| 58 | 58 | |
| 59 | 59 | parent::exec($id, $etemplate); |
@@ -96,27 +96,27 @@ discard block |
||
| 96 | 96 | { |
| 97 | 97 | // Some processing to add values in for links and cats |
| 98 | 98 | $success = $failed = $action_msg = $msg = null; |
| 99 | - if ($ui->action($values['nm']['action'],$values['nm']['selected'],$values['nm']['select_all'], |
|
| 100 | - $success,$failed,$action_msg,$values['do_email'] ? 'email' : 'index',$msg,$values['nm']['checkboxes'])) |
|
| 99 | + if ($ui->action($values['nm']['action'], $values['nm']['selected'], $values['nm']['select_all'], |
|
| 100 | + $success, $failed, $action_msg, $values['do_email'] ? 'email' : 'index', $msg, $values['nm']['checkboxes'])) |
|
| 101 | 101 | { |
| 102 | - $msg .= lang('%1 contact(s) %2',$success,$action_msg); |
|
| 103 | - Api\Json\Response::get()->apply('egw.message',array($msg,'success')); |
|
| 104 | - foreach($values['nm']['selected'] as &$id) |
|
| 102 | + $msg .= lang('%1 contact(s) %2', $success, $action_msg); |
|
| 103 | + Api\Json\Response::get()->apply('egw.message', array($msg, 'success')); |
|
| 104 | + foreach ($values['nm']['selected'] as &$id) |
|
| 105 | 105 | { |
| 106 | 106 | $id = 'addressbook::'.$id; |
| 107 | 107 | } |
| 108 | 108 | // Directly request an update - this will get addressbook tab too |
| 109 | - Api\Json\Response::get()->apply('egw.dataRefreshUIDs',array($values['nm']['selected'])); |
|
| 109 | + Api\Json\Response::get()->apply('egw.dataRefreshUIDs', array($values['nm']['selected'])); |
|
| 110 | 110 | } |
| 111 | - elseif(is_null($msg)) |
|
| 111 | + elseif (is_null($msg)) |
|
| 112 | 112 | { |
| 113 | - $msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); |
|
| 114 | - Api\Json\Response::get()->apply('egw.message',array($msg,'error')); |
|
| 113 | + $msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed); |
|
| 114 | + Api\Json\Response::get()->apply('egw.message', array($msg, 'error')); |
|
| 115 | 115 | } |
| 116 | - elseif($msg) |
|
| 116 | + elseif ($msg) |
|
| 117 | 117 | { |
| 118 | - $msg .= "\n".lang('%1 entries %2, %3 failed.',$success,$action_msg,$failed); |
|
| 119 | - Api\Json\Response::get()->apply('egw.message',array($msg,'error')); |
|
| 118 | + $msg .= "\n".lang('%1 entries %2, %3 failed.', $success, $action_msg, $failed); |
|
| 119 | + Api\Json\Response::get()->apply('egw.message', array($msg, 'error')); |
|
| 120 | 120 | } |
| 121 | 121 | unset($values['nm']['action']); |
| 122 | 122 | unset($values['nm']['select_all']); |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | * Construct the portlet |
| 26 | 26 | * |
| 27 | 27 | */ |
| 28 | - public function __construct(Array &$context = array(), &$need_reload = false) |
|
| 28 | + public function __construct(array &$context = array(), &$need_reload = false) |
|
| 29 | 29 | { |
| 30 | 30 | $context['appname'] = 'addressbook'; |
| 31 | 31 | |
@@ -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 | { |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | // LDAP does NOT have a carddav_name attribute --> stick with id mapped to LDAP attribute uid |
| 77 | 77 | if (version_compare($GLOBALS['egw_info']['apps']['phpgwapi']['version'], '1.9.007', '<') || |
| 78 | 78 | $this->bo->contact_repository != 'sql' || |
| 79 | - $this->bo->account_repository != 'sql' && strpos($_SERVER['REQUEST_URI'].'/','/addressbook-accounts/') !== false) |
|
| 79 | + $this->bo->account_repository != 'sql' && strpos($_SERVER['REQUEST_URI'].'/', '/addressbook-accounts/') !== false) |
|
| 80 | 80 | { |
| 81 | 81 | self::$path_extension = '.vcf'; |
| 82 | 82 | } |
@@ -88,11 +88,11 @@ discard block |
||
| 88 | 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); |
| 89 | 89 | |
| 90 | 90 | $this->home_set_pref = $GLOBALS['egw_info']['user']['preferences']['groupdav']['addressbook-home-set']; |
| 91 | - $this->home_set_pref = $this->home_set_pref ? explode(',',$this->home_set_pref) : array(); |
|
| 91 | + $this->home_set_pref = $this->home_set_pref ? explode(',', $this->home_set_pref) : array(); |
|
| 92 | 92 | |
| 93 | 93 | // silently switch "Sync all into one" preference on for OS X addressbook, as it only supports one AB |
| 94 | 94 | // this restores behavior before Lion (10.7), where AB synced all ABs contained in addressbook-home-set |
| 95 | - if (substr(self::get_agent(),0,9) == 'cfnetwork' && !in_array('O',$this->home_set_pref)) |
|
| 95 | + if (substr(self::get_agent(), 0, 9) == 'cfnetwork' && !in_array('O', $this->home_set_pref)) |
|
| 96 | 96 | { |
| 97 | 97 | $this->home_set_pref[] = 'O'; |
| 98 | 98 | } |
@@ -108,13 +108,13 @@ discard block |
||
| 108 | 108 | * @param string $id ='' |
| 109 | 109 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
| 110 | 110 | */ |
| 111 | - function propfind($path,&$options,&$files,$user,$id='') |
|
| 111 | + function propfind($path, &$options, &$files, $user, $id = '') |
|
| 112 | 112 | { |
| 113 | 113 | $filter = array(); |
| 114 | 114 | // If "Sync selected addressbooks into one" is set |
| 115 | - if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O',$this->home_set_pref)) |
|
| 115 | + if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O', $this->home_set_pref)) |
|
| 116 | 116 | { |
| 117 | - $filter['owner'] = array_keys($this->get_shared(true)); // true: ignore all-in-one pref |
|
| 117 | + $filter['owner'] = array_keys($this->get_shared(true)); // true: ignore all-in-one pref |
|
| 118 | 118 | $filter['owner'][] = $user; |
| 119 | 119 | } |
| 120 | 120 | // show addressbook of a single user? |
@@ -127,11 +127,11 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | // process REPORT filters or multiget href's |
| 129 | 129 | $nresults = null; |
| 130 | - if (($id || $options['root']['name'] != 'propfind') && !$this->_report_filters($options,$filter,$id, $nresults)) |
|
| 130 | + if (($id || $options['root']['name'] != 'propfind') && !$this->_report_filters($options, $filter, $id, $nresults)) |
|
| 131 | 131 | { |
| 132 | 132 | return false; |
| 133 | 133 | } |
| 134 | - if ($id) $path = dirname($path).'/'; // carddav_name get's added anyway in the callback |
|
| 134 | + if ($id) $path = dirname($path).'/'; // carddav_name get's added anyway in the callback |
|
| 135 | 135 | |
| 136 | 136 | if ($this->debug) error_log(__METHOD__."($path,".array2string($options).",,$user,$id) filter=".array2string($filter)); |
| 137 | 137 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | if (!($filter['address_data'] = $options['props'] == 'all' && |
| 140 | 140 | $options['root']['ns'] == Api\CalDAV::CARDDAV) && is_array($options['props'])) |
| 141 | 141 | { |
| 142 | - foreach($options['props'] as $prop) |
|
| 142 | + foreach ($options['props'] as $prop) |
|
| 143 | 143 | { |
| 144 | 144 | if ($prop['name'] == 'address-data') |
| 145 | 145 | { |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | $this->sync_collection_token = null; |
| 160 | 160 | |
| 161 | - $filter['order'] = 'contact_modified ASC'; // return oldest modifications first |
|
| 161 | + $filter['order'] = 'contact_modified ASC'; // return oldest modifications first |
|
| 162 | 162 | $filter['sync-collection'] = true; |
| 163 | 163 | } |
| 164 | 164 | |
@@ -172,13 +172,13 @@ discard block |
||
| 172 | 172 | if ($options['root']['name'] == 'sync-collection' && $this->bo->total > $nresults) |
| 173 | 173 | { |
| 174 | 174 | --$this->sync_collection_token; |
| 175 | - $files['sync-token-params'][] = true; // tel get_sync_collection_token that we have more entries |
|
| 175 | + $files['sync-token-params'][] = true; // tel get_sync_collection_token that we have more entries |
|
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | else |
| 179 | 179 | { |
| 180 | 180 | // return iterator, calling ourself to return result in chunks |
| 181 | - $files['files'] = new Api\CalDAV\PropfindIterator($this,$path,$filter,$files['files']); |
|
| 181 | + $files['files'] = new Api\CalDAV\PropfindIterator($this, $path, $filter, $files['files']); |
|
| 182 | 182 | } |
| 183 | 183 | return true; |
| 184 | 184 | } |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | * @param array|boolean $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 | - function &propfind_callback($path,array &$filter,$start=false,$report_not_found_multiget_ids=true) |
|
| 194 | + function &propfind_callback($path, array &$filter, $start = false, $report_not_found_multiget_ids = true) |
|
| 195 | 195 | { |
| 196 | 196 | //error_log(__METHOD__."('$path', ".array2string($filter).", ".array2string($start).", $report_not_found_multiget_ids)"); |
| 197 | 197 | $starttime = microtime(true); |
@@ -219,18 +219,18 @@ discard block |
||
| 219 | 219 | if (isset($filter[self::$path_attr])) |
| 220 | 220 | { |
| 221 | 221 | if (!is_array($filter[self::$path_attr])) $filter[self::$path_attr] = (array)$filter[self::$path_attr]; |
| 222 | - $requested_multiget_ids =& $filter[self::$path_attr]; |
|
| 222 | + $requested_multiget_ids = & $filter[self::$path_attr]; |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | $files = array(); |
| 226 | 226 | // we query etag and modified, as LDAP does not have the strong sql etag |
| 227 | - $cols = array('id','uid','etag','modified','n_fn'); |
|
| 228 | - if (!in_array(self::$path_attr,$cols)) $cols[] = self::$path_attr; |
|
| 227 | + $cols = array('id', 'uid', 'etag', 'modified', 'n_fn'); |
|
| 228 | + if (!in_array(self::$path_attr, $cols)) $cols[] = self::$path_attr; |
|
| 229 | 229 | // we need tid for sync-collection report |
| 230 | 230 | if (array_key_exists('tid', $filter) && !isset($filter['tid']) && !in_array('tid', $cols)) $cols[] = 'tid'; |
| 231 | - if (($contacts =& $this->bo->search(array(),$cols,$order,'','',False,'AND',$start,$filter))) |
|
| 231 | + if (($contacts = & $this->bo->search(array(), $cols, $order, '', '', False, 'AND', $start, $filter))) |
|
| 232 | 232 | { |
| 233 | - foreach($contacts as &$contact) |
|
| 233 | + foreach ($contacts as &$contact) |
|
| 234 | 234 | { |
| 235 | 235 | // remove contact from requested multiget ids, to be able to report not found urls |
| 236 | 236 | if ($requested_multiget_ids && ($k = array_search($contact[self::$path_attr], $requested_multiget_ids)) !== false) |
@@ -250,9 +250,9 @@ discard block |
||
| 250 | 250 | ); |
| 251 | 251 | if ($address_data) |
| 252 | 252 | { |
| 253 | - $content = $handler->getVCard($contact['id'],$this->charset,false); |
|
| 253 | + $content = $handler->getVCard($contact['id'], $this->charset, false); |
|
| 254 | 254 | $props['getcontentlength'] = bytes($content); |
| 255 | - $props[] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'address-data',$content,true); |
|
| 255 | + $props[] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'address-data', $content, true); |
|
| 256 | 256 | } |
| 257 | 257 | $files[] = $this->add_resource($path, $contact, $props); |
| 258 | 258 | } |
@@ -283,10 +283,10 @@ discard block |
||
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | 285 | // add groups after contacts, but only if enabled and NOT for '/addressbook/' (!isset($filter['owner']) |
| 286 | - if (in_array('D',$this->home_set_pref) && (string)$filter['owner'] !== '0') |
|
| 286 | + if (in_array('D', $this->home_set_pref) && (string)$filter['owner'] !== '0') |
|
| 287 | 287 | { |
| 288 | 288 | $where = array( |
| 289 | - 'list_owner' => isset($filter['owner'])?$filter['owner']:array_keys($this->bo->grants) |
|
| 289 | + 'list_owner' => isset($filter['owner']) ? $filter['owner'] : array_keys($this->bo->grants) |
|
| 290 | 290 | ); |
| 291 | 291 | // add sync-token to support sync-collection report |
| 292 | 292 | if ($sync_collection_report) |
@@ -299,20 +299,20 @@ discard block |
||
| 299 | 299 | $where['list_'.self::$path_attr] = $filter[self::$path_attr]; |
| 300 | 300 | } |
| 301 | 301 | //error_log(__METHOD__."() filter=".array2string($filter).", do_groups=".in_array('D',$this->home_set_pref).", where=".array2string($where)); |
| 302 | - if ($where['id'] && ($lists = $this->bo->read_lists($where,'contact_uid',$where['list_owner']))) // limit to contacts in same AB! |
|
| 302 | + if ($where['id'] && ($lists = $this->bo->read_lists($where, 'contact_uid', $where['list_owner']))) // limit to contacts in same AB! |
|
| 303 | 303 | { |
| 304 | - foreach($lists as $list) |
|
| 304 | + foreach ($lists as $list) |
|
| 305 | 305 | { |
| 306 | 306 | $list[self::$path_attr] = $list['list_carddav_name']; |
| 307 | 307 | $etag = $list['list_id'].':'.$list['list_etag']; |
| 308 | 308 | // for all-in-one addressbook, add selected ABs to etag |
| 309 | 309 | if (isset($filter['owner']) && is_array($filter['owner'])) |
| 310 | 310 | { |
| 311 | - $etag .= ':'.implode('-',$filter['owner']); |
|
| 311 | + $etag .= ':'.implode('-', $filter['owner']); |
|
| 312 | 312 | } |
| 313 | 313 | $props = array( |
| 314 | 314 | 'getcontenttype' => Api\CalDAV::mkprop('getcontenttype', 'text/vcard'), |
| 315 | - 'getlastmodified' => Api\DateTime::to($list['list_modified'],'ts'), |
|
| 315 | + 'getlastmodified' => Api\DateTime::to($list['list_modified'], 'ts'), |
|
| 316 | 316 | 'displayname' => $list['list_name'], |
| 317 | 317 | 'getetag' => '"'.$etag.'"', |
| 318 | 318 | ); |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | { |
| 321 | 321 | $content = $handler->getGroupVCard($list); |
| 322 | 322 | $props['getcontentlength'] = bytes($content); |
| 323 | - $props[] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'address-data',$content,true); |
|
| 323 | + $props[] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'address-data', $content, true); |
|
| 324 | 324 | } |
| 325 | 325 | $files[] = $this->add_resource($path, $list, $props); |
| 326 | 326 | |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | unset($requested_multiget_ids[$k]); |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - if ($sync_collection_report && $this->sync_collection_token < ($ts=$GLOBALS['egw']->db->from_timestamp($list['list_modified']))) |
|
| 333 | + if ($sync_collection_report && $this->sync_collection_token < ($ts = $GLOBALS['egw']->db->from_timestamp($list['list_modified']))) |
|
| 334 | 334 | { |
| 335 | 335 | $this->sync_collection_token = $ts; |
| 336 | 336 | } |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | // report not found multiget urls |
| 341 | 341 | if ($report_not_found_multiget_ids && $requested_multiget_ids) |
| 342 | 342 | { |
| 343 | - foreach($requested_multiget_ids as $id) |
|
| 343 | + foreach ($requested_multiget_ids as $id) |
|
| 344 | 344 | { |
| 345 | 345 | $files[] = array('path' => $path.$id.self::$path_extension); |
| 346 | 346 | } |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | * @param int &$nresult on return limit for number or results or unchanged/null |
| 361 | 361 | * @return boolean true if filter could be processed |
| 362 | 362 | */ |
| 363 | - function _report_filters($options,&$filters,$id, &$nresults) |
|
| 363 | + function _report_filters($options, &$filters, $id, &$nresults) |
|
| 364 | 364 | { |
| 365 | 365 | if ($options['filters']) |
| 366 | 366 | { |
@@ -385,17 +385,17 @@ discard block |
||
| 385 | 385 | $prop_filters = array(); |
| 386 | 386 | |
| 387 | 387 | $matches = $prop_test = $column = null; |
| 388 | - foreach($options['filters'] as $n => $filter) |
|
| 388 | + foreach ($options['filters'] as $n => $filter) |
|
| 389 | 389 | { |
| 390 | - if (!is_int($n)) continue; // eg. attributes of filter xml element |
|
| 390 | + if (!is_int($n)) continue; // eg. attributes of filter xml element |
|
| 391 | 391 | |
| 392 | - switch((string)$filter['name']) |
|
| 392 | + switch ((string)$filter['name']) |
|
| 393 | 393 | { |
| 394 | 394 | case 'param-filter': |
| 395 | 395 | $this->caldav->log(__METHOD__."(...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!"); |
| 396 | 396 | break; |
| 397 | 397 | case 'prop-filter': // can be multiple prop-filter, see example |
| 398 | - if ($matches) $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches); |
|
| 398 | + if ($matches) $prop_filters[] = implode($prop_test == 'allof' ? ' AND ' : ' OR ', $matches); |
|
| 399 | 399 | $matches = array(); |
| 400 | 400 | $prop_filter = strtoupper($filter['attrs']['name']); |
| 401 | 401 | $prop_test = isset($filter['attrs']['test']) ? $filter['attrs']['test'] : 'anyof'; |
@@ -408,11 +408,11 @@ discard block |
||
| 408 | 408 | if (!isset($this->filter_prop2cal[$prop_filter])) // eg. not existing NICKNAME in EGroupware |
| 409 | 409 | { |
| 410 | 410 | if ($this->debug || $prop_filter != 'NICKNAME') error_log(__METHOD__."(...) text-match: $prop_filter {$filter['attrs']['match-type']} '{$filter['data']}' unknown property '$prop_filter' --> ignored"); |
| 411 | - $column = false; // to ignore following data too |
|
| 411 | + $column = false; // to ignore following data too |
|
| 412 | 412 | } |
| 413 | 413 | else |
| 414 | 414 | { |
| 415 | - switch($filter['attrs']['collation']) // todo: which other collations allowed, we are allways unicode |
|
| 415 | + switch ($filter['attrs']['collation']) // todo: which other collations allowed, we are allways unicode |
|
| 416 | 416 | { |
| 417 | 417 | case 'i;unicode-casemap': |
| 418 | 418 | default: |
@@ -432,20 +432,20 @@ discard block |
||
| 432 | 432 | if ($column) // false for properties not known to EGroupware |
| 433 | 433 | { |
| 434 | 434 | $value = str_replace(array('%', '_'), array('\\%', '\\_'), $filter['data']); |
| 435 | - switch($match_type) |
|
| 435 | + switch ($match_type) |
|
| 436 | 436 | { |
| 437 | 437 | case 'equals': |
| 438 | - $sql_filter = $column . $comp . $GLOBALS['egw']->db->quote($value); |
|
| 438 | + $sql_filter = $column.$comp.$GLOBALS['egw']->db->quote($value); |
|
| 439 | 439 | break; |
| 440 | 440 | default: |
| 441 | 441 | case 'contains': |
| 442 | - $sql_filter = $column . $comp . $GLOBALS['egw']->db->quote('%'.$value.'%'); |
|
| 442 | + $sql_filter = $column.$comp.$GLOBALS['egw']->db->quote('%'.$value.'%'); |
|
| 443 | 443 | break; |
| 444 | 444 | case 'starts-with': |
| 445 | - $sql_filter = $column . $comp . $GLOBALS['egw']->db->quote($value.'%'); |
|
| 445 | + $sql_filter = $column.$comp.$GLOBALS['egw']->db->quote($value.'%'); |
|
| 446 | 446 | break; |
| 447 | 447 | case 'ends-with': |
| 448 | - $sql_filter = $column . $comp . $GLOBALS['egw']->db->quote('%'.$value); |
|
| 448 | + $sql_filter = $column.$comp.$GLOBALS['egw']->db->quote('%'.$value); |
|
| 449 | 449 | break; |
| 450 | 450 | } |
| 451 | 451 | $matches[] = ($negate_condition ? 'NOT ' : '').$sql_filter; |
@@ -461,10 +461,10 @@ discard block |
||
| 461 | 461 | break; |
| 462 | 462 | } |
| 463 | 463 | } |
| 464 | - if ($matches) $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches); |
|
| 464 | + if ($matches) $prop_filters[] = implode($prop_test == 'allof' ? ' AND ' : ' OR ', $matches); |
|
| 465 | 465 | if ($prop_filters) |
| 466 | 466 | { |
| 467 | - $filters[] = $filter = '(('.implode($filter_test=='allof'?') AND (':') OR (', $prop_filters).'))'; |
|
| 467 | + $filters[] = $filter = '(('.implode($filter_test == 'allof' ? ') AND (' : ') OR (', $prop_filters).'))'; |
|
| 468 | 468 | if ($this->debug) error_log(__METHOD__."(path=$options[path], ...) sql-filter: $filter"); |
| 469 | 469 | } |
| 470 | 470 | } |
@@ -474,9 +474,9 @@ discard block |
||
| 474 | 474 | <B:nresults>10</B:nresults> |
| 475 | 475 | </B:limit> |
| 476 | 476 | */ |
| 477 | - foreach((array)$options['other'] as $option) |
|
| 477 | + foreach ((array)$options['other'] as $option) |
|
| 478 | 478 | { |
| 479 | - switch($option['name']) |
|
| 479 | + switch ($option['name']) |
|
| 480 | 480 | { |
| 481 | 481 | case 'nresults': |
| 482 | 482 | $nresults = (int)$option['data']; |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | case 'limit': |
| 486 | 486 | break; |
| 487 | 487 | case 'href': |
| 488 | - break; // from addressbook-multiget, handled below |
|
| 488 | + break; // from addressbook-multiget, handled below |
|
| 489 | 489 | // rfc 6578 sync-report |
| 490 | 490 | case 'sync-token': |
| 491 | 491 | if (!empty($option['data'])) |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | $parts = explode('/', $option['data']); |
| 494 | 494 | $sync_token = array_pop($parts); |
| 495 | 495 | $filters[] = 'contact_modified>'.(int)$sync_token; |
| 496 | - $filters['tid'] = null; // to return deleted entries too |
|
| 496 | + $filters['tid'] = null; // to return deleted entries too |
|
| 497 | 497 | } |
| 498 | 498 | break; |
| 499 | 499 | case 'sync-level': |
@@ -511,23 +511,23 @@ discard block |
||
| 511 | 511 | if ($options['root']['name'] == 'addressbook-multiget') |
| 512 | 512 | { |
| 513 | 513 | $ids = array(); |
| 514 | - foreach($options['other'] as $option) |
|
| 514 | + foreach ($options['other'] as $option) |
|
| 515 | 515 | { |
| 516 | 516 | if ($option['name'] == 'href') |
| 517 | 517 | { |
| 518 | - $parts = explode('/',$option['data']); |
|
| 518 | + $parts = explode('/', $option['data']); |
|
| 519 | 519 | if (($id = urldecode(array_pop($parts)))) |
| 520 | 520 | { |
| 521 | - $ids[] = self::$path_extension ? basename($id,self::$path_extension) : $id; |
|
| 521 | + $ids[] = self::$path_extension ? basename($id, self::$path_extension) : $id; |
|
| 522 | 522 | } |
| 523 | 523 | } |
| 524 | 524 | } |
| 525 | 525 | if ($ids) $filters[self::$path_attr] = $ids; |
| 526 | - if ($this->debug) error_log(__METHOD__."(...) addressbook-multiget: ids=".implode(',',$ids)); |
|
| 526 | + if ($this->debug) error_log(__METHOD__."(...) addressbook-multiget: ids=".implode(',', $ids)); |
|
| 527 | 527 | } |
| 528 | 528 | elseif ($id) |
| 529 | 529 | { |
| 530 | - $filters[self::$path_attr] = self::$path_extension ? basename($id,self::$path_extension) : $id; |
|
| 530 | + $filters[self::$path_attr] = self::$path_extension ? basename($id, self::$path_extension) : $id; |
|
| 531 | 531 | } |
| 532 | 532 | //error_log(__METHOD__."() options[other]=".array2string($options['other'])." --> filters=".array2string($filters)); |
| 533 | 533 | return true; |
@@ -541,17 +541,16 @@ discard block |
||
| 541 | 541 | * @param int $user =null account_id |
| 542 | 542 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
| 543 | 543 | */ |
| 544 | - function get(&$options,$id,$user=null) |
|
| 544 | + function get(&$options, $id, $user = null) |
|
| 545 | 545 | { |
| 546 | - unset($user); // not used, but required by function signature |
|
| 546 | + unset($user); // not used, but required by function signature |
|
| 547 | 547 | |
| 548 | - if (!is_array($contact = $this->_common_get_put_delete('GET',$options,$id))) |
|
| 548 | + if (!is_array($contact = $this->_common_get_put_delete('GET', $options, $id))) |
|
| 549 | 549 | { |
| 550 | 550 | return $contact; |
| 551 | 551 | } |
| 552 | 552 | $handler = self::_get_handler(); |
| 553 | - $options['data'] = $contact['list_id'] ? $handler->getGroupVCard($contact) : |
|
| 554 | - $handler->getVCard($contact['id'],$this->charset,false); |
|
| 553 | + $options['data'] = $contact['list_id'] ? $handler->getGroupVCard($contact) : $handler->getVCard($contact['id'], $this->charset, false); |
|
| 555 | 554 | // e.g. Evolution does not understand 'text/vcard' |
| 556 | 555 | $options['mimetype'] = 'text/x-vcard; charset='.$this->charset; |
| 557 | 556 | header('Content-Encoding: identity'); |
@@ -568,11 +567,11 @@ discard block |
||
| 568 | 567 | * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook) |
| 569 | 568 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
| 570 | 569 | */ |
| 571 | - function put(&$options,$id,$user=null,$prefix=null) |
|
| 570 | + function put(&$options, $id, $user = null, $prefix = null) |
|
| 572 | 571 | { |
| 573 | 572 | if ($this->debug) error_log(__METHOD__.'('.array2string($options).",$id,$user)"); |
| 574 | 573 | |
| 575 | - $oldContact = $this->_common_get_put_delete('PUT',$options,$id); |
|
| 574 | + $oldContact = $this->_common_get_put_delete('PUT', $options, $id); |
|
| 576 | 575 | if (!is_null($oldContact) && !is_array($oldContact)) |
| 577 | 576 | { |
| 578 | 577 | if ($this->debug) error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($oldContact)); |
@@ -597,7 +596,7 @@ discard block |
||
| 597 | 596 | switch (strtolower($key)) |
| 598 | 597 | { |
| 599 | 598 | case 'charset': |
| 600 | - $charset = strtoupper(substr($value,1,-1)); |
|
| 599 | + $charset = strtoupper(substr($value, 1, -1)); |
|
| 601 | 600 | } |
| 602 | 601 | } |
| 603 | 602 | } |
@@ -624,7 +623,7 @@ discard block |
||
| 624 | 623 | |
| 625 | 624 | if (!$is_group && is_array($contact['cat_id'])) |
| 626 | 625 | { |
| 627 | - $contact['cat_id'] = implode(',',$this->bo->find_or_add_categories($contact['cat_id'], $contactId)); |
|
| 626 | + $contact['cat_id'] = implode(',', $this->bo->find_or_add_categories($contact['cat_id'], $contactId)); |
|
| 628 | 627 | } |
| 629 | 628 | elseif ($contactId > 0) |
| 630 | 629 | { |
@@ -648,12 +647,12 @@ discard block |
||
| 648 | 647 | $contact['carddav_name'] = $id; |
| 649 | 648 | |
| 650 | 649 | // only set owner, if user is explicitly specified in URL (check via prefix, NOT for /addressbook/) or sync-all-in-one!) |
| 651 | - if ($prefix && !in_array('O',$this->home_set_pref) && $user) |
|
| 650 | + if ($prefix && !in_array('O', $this->home_set_pref) && $user) |
|
| 652 | 651 | { |
| 653 | 652 | $contact['owner'] = $user; |
| 654 | 653 | } |
| 655 | 654 | // check if default addressbook is synced and not Api\Accounts, if not use (always synced) personal addressbook |
| 656 | - elseif(!$this->bo->default_addressbook || !in_array($this->bo->default_addressbook,$this->home_set_pref)) |
|
| 655 | + elseif (!$this->bo->default_addressbook || !in_array($this->bo->default_addressbook, $this->home_set_pref)) |
|
| 657 | 656 | { |
| 658 | 657 | $contact['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
| 659 | 658 | } |
@@ -664,7 +663,7 @@ discard block |
||
| 664 | 663 | } |
| 665 | 664 | // check if user has add rights for addressbook |
| 666 | 665 | // done here again, as _common_get_put_delete knows nothing about default addressbooks... |
| 667 | - if (!($this->bo->grants[$contact['owner']] & Acl::ADD)) |
|
| 666 | + if (!($this->bo->grants[$contact['owner']]&Acl::ADD)) |
|
| 668 | 667 | { |
| 669 | 668 | if ($this->debug) error_log(__METHOD__."(,'$id', $user, '$prefix') returning '403 Forbidden'"); |
| 670 | 669 | return '403 Forbidden'; |
@@ -681,7 +680,7 @@ discard block |
||
| 681 | 680 | $this->check_return_representation($options, $id, $user); |
| 682 | 681 | return '412 Precondition Failed'; |
| 683 | 682 | } |
| 684 | - return '403 Forbidden'; // happens when writing new entries in AB's without ADD rights |
|
| 683 | + return '403 Forbidden'; // happens when writing new entries in AB's without ADD rights |
|
| 685 | 684 | } |
| 686 | 685 | |
| 687 | 686 | if (empty($contact['etag']) || empty($contact['cardav_name'])) |
@@ -714,16 +713,16 @@ discard block |
||
| 714 | 713 | * @param array|false $oldContact |
| 715 | 714 | * @return int|boolean $list_id or false on error |
| 716 | 715 | */ |
| 717 | - function save_group(array &$contact, $oldContact=null) |
|
| 716 | + function save_group(array &$contact, $oldContact = null) |
|
| 718 | 717 | { |
| 719 | 718 | $data = array('list_name' => $contact['n_fn']); |
| 720 | 719 | if (!isset($contact['owner'])) $contact['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
| 721 | - foreach(array('id','carddav_name','uid','owner') as $name) |
|
| 720 | + foreach (array('id', 'carddav_name', 'uid', 'owner') as $name) |
|
| 722 | 721 | { |
| 723 | 722 | $data['list_'.$name] = $contact[$name]; |
| 724 | 723 | } |
| 725 | 724 | //error_log(__METHOD__.'('.array2string($contact).', '.array2string($oldContact).') data='.array2string($data)); |
| 726 | - if (($list_id=$this->bo->add_list(array('list_'.self::$path_attr => $contact[self::$path_attr]), |
|
| 725 | + if (($list_id = $this->bo->add_list(array('list_'.self::$path_attr => $contact[self::$path_attr]), |
|
| 727 | 726 | $contact['owner'], null, $data))) |
| 728 | 727 | { |
| 729 | 728 | // update members given in $contact['##X-ADDRESSBOOKSERVER-MEMBER'] |
@@ -736,14 +735,14 @@ discard block |
||
| 736 | 735 | { |
| 737 | 736 | $new_members = array($new_members); |
| 738 | 737 | } |
| 739 | - foreach($new_members as &$uid) |
|
| 738 | + foreach ($new_members as &$uid) |
|
| 740 | 739 | { |
| 741 | - $uid = substr($uid,9); // cut off "urn:uuid:" prefix |
|
| 740 | + $uid = substr($uid, 9); // cut off "urn:uuid:" prefix |
|
| 742 | 741 | } |
| 743 | 742 | if ($oldContact) |
| 744 | 743 | { |
| 745 | - $to_add = array_diff($new_members,$oldContact['members']); |
|
| 746 | - $to_delete = array_diff($oldContact['members'],$new_members); |
|
| 744 | + $to_add = array_diff($new_members, $oldContact['members']); |
|
| 745 | + $to_delete = array_diff($oldContact['members'], $new_members); |
|
| 747 | 746 | } |
| 748 | 747 | else |
| 749 | 748 | { |
@@ -754,9 +753,9 @@ discard block |
||
| 754 | 753 | { |
| 755 | 754 | $to_add_ids = $to_delete_ids = array(); |
| 756 | 755 | $filter = array('uid' => $to_delete ? array_merge($to_add, $to_delete) : $to_add); |
| 757 | - if (($contacts =& $this->bo->search(array(), array('id', 'uid'),'','','',False,'AND',false,$filter))) |
|
| 756 | + if (($contacts = & $this->bo->search(array(), array('id', 'uid'), '', '', '', False, 'AND', false, $filter))) |
|
| 758 | 757 | { |
| 759 | - foreach($contacts as $c) |
|
| 758 | + foreach ($contacts as $c) |
|
| 760 | 759 | { |
| 761 | 760 | if ($to_delete && in_array($c['uid'], $to_delete)) |
| 762 | 761 | { |
@@ -786,9 +785,9 @@ discard block |
||
| 786 | 785 | * @param int $user |
| 787 | 786 | * @return string |
| 788 | 787 | */ |
| 789 | - public function getctag($path,$user) |
|
| 788 | + public function getctag($path, $user) |
|
| 790 | 789 | { |
| 791 | - static $ctags = array(); // a little per request caching, in case ctag and sync-token is both requested |
|
| 790 | + static $ctags = array(); // a little per request caching, in case ctag and sync-token is both requested |
|
| 792 | 791 | if (isset($ctags[$path])) return $ctags[$path]; |
| 793 | 792 | |
| 794 | 793 | $user_in = $user; |
@@ -796,9 +795,9 @@ discard block |
||
| 796 | 795 | if (is_null($user) || $user === '' || $path == '/addressbook/') $user = null; |
| 797 | 796 | |
| 798 | 797 | // If "Sync selected addressbooks into one" is set --> ctag need to take selected AB's into account too |
| 799 | - if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O',$this->home_set_pref)) |
|
| 798 | + if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O', $this->home_set_pref)) |
|
| 800 | 799 | { |
| 801 | - $user = array_merge((array)$user,array_keys($this->get_shared(true))); // true: ignore all-in-one pref |
|
| 800 | + $user = array_merge((array)$user, array_keys($this->get_shared(true))); // true: ignore all-in-one pref |
|
| 802 | 801 | |
| 803 | 802 | // include accounts ctag, if accounts stored different from contacts (eg.in LDAP or ADS) |
| 804 | 803 | if ($this->bo->so_accounts && in_array('0', $user)) |
@@ -809,7 +808,7 @@ discard block |
||
| 809 | 808 | $ctag = $this->bo->get_ctag($user); |
| 810 | 809 | |
| 811 | 810 | // include lists-ctag, if enabled |
| 812 | - if (in_array('D',$this->home_set_pref)) |
|
| 811 | + if (in_array('D', $this->home_set_pref)) |
|
| 813 | 812 | { |
| 814 | 813 | $lists_ctag = $this->bo->lists_ctag($user); |
| 815 | 814 | } |
@@ -842,34 +841,34 @@ discard block |
||
| 842 | 841 | * @param int $user =null account_id of owner of collection |
| 843 | 842 | * @return array |
| 844 | 843 | */ |
| 845 | - public function extra_properties(array $props, $displayname, $base_uri=null, $user=null) |
|
| 844 | + public function extra_properties(array $props, $displayname, $base_uri = null, $user = null) |
|
| 846 | 845 | { |
| 847 | - unset($displayname, $base_uri, $user); // not used, but required by function signature |
|
| 846 | + unset($displayname, $base_uri, $user); // not used, but required by function signature |
|
| 848 | 847 | |
| 849 | 848 | if (!isset($props['addressbook-description'])) |
| 850 | 849 | { |
| 851 | 850 | // default addressbook description: can be overwritten via PROPPATCH, in which case it's already set |
| 852 | - $props['addressbook-description'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'addressbook-description',$props['displayname']); |
|
| 851 | + $props['addressbook-description'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'addressbook-description', $props['displayname']); |
|
| 853 | 852 | } |
| 854 | 853 | // setting an max image size, so iOS scales the images before transmitting them |
| 855 | 854 | // we currently scale down to width of 240px, which tests shown to be ~20k |
| 856 | - $props['max-image-size'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'max-image-size',24*1024); |
|
| 855 | + $props['max-image-size'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'max-image-size', 24 * 1024); |
|
| 857 | 856 | |
| 858 | 857 | // supported reports (required property for CardDAV) |
| 859 | 858 | $props['supported-report-set'] = array( |
| 860 | - 'addressbook-query' => Api\CalDAV::mkprop('supported-report',array( |
|
| 861 | - Api\CalDAV::mkprop('report',array( |
|
| 862 | - Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'addressbook-query',''))))), |
|
| 863 | - 'addressbook-multiget' => Api\CalDAV::mkprop('supported-report',array( |
|
| 864 | - Api\CalDAV::mkprop('report',array( |
|
| 865 | - Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'addressbook-multiget',''))))), |
|
| 859 | + 'addressbook-query' => Api\CalDAV::mkprop('supported-report', array( |
|
| 860 | + Api\CalDAV::mkprop('report', array( |
|
| 861 | + Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'addressbook-query', ''))))), |
|
| 862 | + 'addressbook-multiget' => Api\CalDAV::mkprop('supported-report', array( |
|
| 863 | + Api\CalDAV::mkprop('report', array( |
|
| 864 | + Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'addressbook-multiget', ''))))), |
|
| 866 | 865 | ); |
| 867 | 866 | // only advertice rfc 6578 sync-collection report, if "delete-prevention" is switched on (deleted entries get marked deleted but not actualy deleted |
| 868 | 867 | if ($GLOBALS['egw_info']['server']['history']) |
| 869 | 868 | { |
| 870 | - $props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report',array( |
|
| 871 | - Api\CalDAV::mkprop('report',array( |
|
| 872 | - Api\CalDAV::mkprop('sync-collection',''))))); |
|
| 869 | + $props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report', array( |
|
| 870 | + Api\CalDAV::mkprop('report', array( |
|
| 871 | + Api\CalDAV::mkprop('sync-collection', ''))))); |
|
| 873 | 872 | } |
| 874 | 873 | return $props; |
| 875 | 874 | } |
@@ -881,7 +880,7 @@ discard block |
||
| 881 | 880 | */ |
| 882 | 881 | private function _get_handler() |
| 883 | 882 | { |
| 884 | - $handler = new addressbook_vcal('addressbook','text/vcard'); |
|
| 883 | + $handler = new addressbook_vcal('addressbook', 'text/vcard'); |
|
| 885 | 884 | $supportedFields = $handler->supportedFields; |
| 886 | 885 | // Apple iOS or OS X addressbook |
| 887 | 886 | if ($this->agent == 'cfnetwork' || $this->agent == 'dataaccess') |
@@ -894,11 +893,11 @@ discard block |
||
| 894 | 893 | unset($supportedFields['TEL;CELL;WORK']); |
| 895 | 894 | $supportedFields['TEL;IPHONE'] = array('tel_cell_private'); |
| 896 | 895 | unset($supportedFields['TEL;CELL;HOME']); |
| 897 | - $databaseFields['X-ABSHOWAS'] = $supportedFields['X-ABSHOWAS'] = array('fileas_type'); // Horde vCard class uses uppercase prop-names! |
|
| 896 | + $databaseFields['X-ABSHOWAS'] = $supportedFields['X-ABSHOWAS'] = array('fileas_type'); // Horde vCard class uses uppercase prop-names! |
|
| 898 | 897 | |
| 899 | 898 | // Apple Addressbook pre Lion (OS X 10.7) messes up CLASS and CATEGORIES (Lion cant set them but leaves them alone) |
| 900 | 899 | $matches = null; |
| 901 | - if (preg_match('|CFNetwork/([0-9]+)|i', $_SERVER['HTTP_USER_AGENT'],$matches) && $matches[1] < 520 || |
|
| 900 | + if (preg_match('|CFNetwork/([0-9]+)|i', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] < 520 || |
|
| 902 | 901 | // iOS 5.1.1 does not display CLASS or CATEGORY, but wrongly escapes multiple, comma-separated categories |
| 903 | 902 | // and appends CLASS: PUBLIC to an empty NOTE: field --> leaving them out for iOS |
| 904 | 903 | $this->agent == 'dataaccess') |
@@ -908,7 +907,7 @@ discard block |
||
| 908 | 907 | unset($supportedFields['CATEGORIES']); |
| 909 | 908 | unset($databaseFields['CATEGORIES']); |
| 910 | 909 | } |
| 911 | - if (preg_match('|CFNetwork/([0-9]+)|i', $_SERVER['HTTP_USER_AGENT'],$matches) && $matches[1] < 520) |
|
| 910 | + if (preg_match('|CFNetwork/([0-9]+)|i', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] < 520) |
|
| 912 | 911 | { |
| 913 | 912 | // gd cant parse or resize images stored from snow leopard addressbook: gd-jpeg: |
| 914 | 913 | // - JPEG library reports unrecoverable error |
@@ -920,7 +919,7 @@ discard block |
||
| 920 | 919 | } |
| 921 | 920 | $handler->setDatabaseFields($databaseFields); |
| 922 | 921 | } |
| 923 | - $handler->setSupportedFields('GroupDAV',$this->agent,$supportedFields); |
|
| 922 | + $handler->setSupportedFields('GroupDAV', $this->agent, $supportedFields); |
|
| 924 | 923 | return $handler; |
| 925 | 924 | } |
| 926 | 925 | |
@@ -931,9 +930,9 @@ discard block |
||
| 931 | 930 | * @param int $id |
| 932 | 931 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
| 933 | 932 | */ |
| 934 | - function delete(&$options,$id) |
|
| 933 | + function delete(&$options, $id) |
|
| 935 | 934 | { |
| 936 | - if (!is_array($contact = $this->_common_get_put_delete('DELETE',$options,$id))) |
|
| 935 | + if (!is_array($contact = $this->_common_get_put_delete('DELETE', $options, $id))) |
|
| 937 | 936 | { |
| 938 | 937 | return $contact; |
| 939 | 938 | } |
@@ -941,7 +940,7 @@ discard block |
||
| 941 | 940 | { |
| 942 | 941 | $ok = $this->bo->delete_list($contact['list_id']) !== false; |
| 943 | 942 | } |
| 944 | - elseif (($ok = $this->bo->delete($contact['id'],self::etag2value($this->http_if_match))) === 0) |
|
| 943 | + elseif (($ok = $this->bo->delete($contact['id'], self::etag2value($this->http_if_match))) === 0) |
|
| 945 | 944 | { |
| 946 | 945 | return '412 Precondition Failed'; |
| 947 | 946 | } |
@@ -958,9 +957,9 @@ discard block |
||
| 958 | 957 | * @param string $path =null |
| 959 | 958 | * @return array|boolean array with entry, false if no read rights, null if $id does not exist |
| 960 | 959 | */ |
| 961 | - function read($id, $path=null) |
|
| 960 | + function read($id, $path = null) |
|
| 962 | 961 | { |
| 963 | - static $non_deleted_tids=null; |
|
| 962 | + static $non_deleted_tids = null; |
|
| 964 | 963 | if (is_null($non_deleted_tids)) |
| 965 | 964 | { |
| 966 | 965 | $tids = $this->bo->content_types; |
@@ -970,7 +969,7 @@ discard block |
||
| 970 | 969 | $contact = $this->bo->read(array(self::$path_attr => $id, 'tid' => $non_deleted_tids)); |
| 971 | 970 | |
| 972 | 971 | // if contact not found and accounts stored NOT like contacts, try reading it without path-extension as id |
| 973 | - if (is_null($contact) && $this->bo->so_accounts && ($c = $this->bo->read($test=basename($id, '.vcf')))) |
|
| 972 | + if (is_null($contact) && $this->bo->so_accounts && ($c = $this->bo->read($test = basename($id, '.vcf')))) |
|
| 974 | 973 | { |
| 975 | 974 | $contact = $c; |
| 976 | 975 | } |
@@ -979,9 +978,9 @@ discard block |
||
| 979 | 978 | // bo->read_list(..., true) limits returned uid to same owner's addressbook, as iOS and OS X addressbooks |
| 980 | 979 | // only understands/shows that and if return more, save_lists would delete the others ones on update! |
| 981 | 980 | $limit_in_ab = true; |
| 982 | - list(,$account_lid,$app) = explode('/',$path); // eg. /<username>/addressbook/<id> |
|
| 981 | + list(,$account_lid, $app) = explode('/', $path); // eg. /<username>/addressbook/<id> |
|
| 983 | 982 | // /<username>/addressbook/ with home_set_prefs containing 'O'=all-in-one contains selected ab's |
| 984 | - if($account_lid == $GLOBALS['egw_info']['user']['account_lid'] && $app == 'addressbook' && in_array('O',$this->home_set_pref)) |
|
| 983 | + if ($account_lid == $GLOBALS['egw_info']['user']['account_lid'] && $app == 'addressbook' && in_array('O', $this->home_set_pref)) |
|
| 985 | 984 | { |
| 986 | 985 | $limit_in_ab = array_keys($this->get_shared(true)); |
| 987 | 986 | $limit_in_ab[] = $GLOBALS['egw_info']['user']['account_id']; |
@@ -992,28 +991,28 @@ discard block |
||
| 992 | 991 | { |
| 993 | 992 | $limit_in_ab = array_keys($this->bo->grants); |
| 994 | 993 | }*/ |
| 995 | - if (!$contact && ($contact = $this->bo->read_lists(array('list_'.self::$path_attr => $id),'contact_uid',$limit_in_ab))) |
|
| 994 | + if (!$contact && ($contact = $this->bo->read_lists(array('list_'.self::$path_attr => $id), 'contact_uid', $limit_in_ab))) |
|
| 996 | 995 | { |
| 997 | 996 | $contact = array_shift($contact); |
| 998 | 997 | $contact['n_fn'] = $contact['n_family'] = $contact['list_name']; |
| 999 | - foreach(array('owner','id','carddav_name','modified','modifier','created','creator','etag','uid') as $name) |
|
| 998 | + foreach (array('owner', 'id', 'carddav_name', 'modified', 'modifier', 'created', 'creator', 'etag', 'uid') as $name) |
|
| 1000 | 999 | { |
| 1001 | 1000 | $contact[$name] = $contact['list_'.$name]; |
| 1002 | 1001 | } |
| 1003 | 1002 | // if NOT limited to containing AB ($limit_in_ab === true), add that limit to etag |
| 1004 | 1003 | if ($limit_in_ab !== true) |
| 1005 | 1004 | { |
| 1006 | - $contact['etag'] .= ':'.implode('-',$limit_in_ab); |
|
| 1005 | + $contact['etag'] .= ':'.implode('-', $limit_in_ab); |
|
| 1007 | 1006 | } |
| 1008 | 1007 | } |
| 1009 | - elseif($contact === array()) // not found from read_lists() |
|
| 1008 | + elseif ($contact === array()) // not found from read_lists() |
|
| 1010 | 1009 | { |
| 1011 | 1010 | $contact = null; |
| 1012 | 1011 | } |
| 1013 | 1012 | |
| 1014 | 1013 | if ($contact && $contact['tid'] == Api\Contacts::DELETED_TYPE) |
| 1015 | 1014 | { |
| 1016 | - $contact = null; // handle deleted events, as not existing (404 Not Found) |
|
| 1015 | + $contact = null; // handle deleted events, as not existing (404 Not Found) |
|
| 1017 | 1016 | } |
| 1018 | 1017 | if ($this->debug > 1) error_log(__METHOD__."('$id') returning ".array2string($contact)); |
| 1019 | 1018 | return $contact; |
@@ -1026,9 +1025,9 @@ discard block |
||
| 1026 | 1025 | * @param array|int $contact contact-array or id |
| 1027 | 1026 | * @return boolean null if entry does not exist, false if no access, true if access permitted |
| 1028 | 1027 | */ |
| 1029 | - function check_access($acl,$contact) |
|
| 1028 | + function check_access($acl, $contact) |
|
| 1030 | 1029 | { |
| 1031 | - return $this->bo->check_perms($acl, $contact, true); // true = deny to delete accounts |
|
| 1030 | + return $this->bo->check_perms($acl, $contact, true); // true = deny to delete accounts |
|
| 1032 | 1031 | } |
| 1033 | 1032 | |
| 1034 | 1033 | /** |
@@ -1056,15 +1055,15 @@ discard block |
||
| 1056 | 1055 | * @param boolean $ignore_all_in_one =false if true, return selected addressbooks and not array() for all-in-one |
| 1057 | 1056 | * @return array account_id => account_lid pairs |
| 1058 | 1057 | */ |
| 1059 | - function get_shared($ignore_all_in_one=false) |
|
| 1058 | + function get_shared($ignore_all_in_one = false) |
|
| 1060 | 1059 | { |
| 1061 | 1060 | $shared = array(); |
| 1062 | 1061 | |
| 1063 | 1062 | // if "Sync all selected addressbook into one" is set --> no (additional) shared addressbooks |
| 1064 | - if (!$ignore_all_in_one && in_array('O',$this->home_set_pref)) return array(); |
|
| 1063 | + if (!$ignore_all_in_one && in_array('O', $this->home_set_pref)) return array(); |
|
| 1065 | 1064 | |
| 1066 | 1065 | // replace symbolic id's with real nummeric id's |
| 1067 | - foreach(array( |
|
| 1066 | + foreach (array( |
|
| 1068 | 1067 | 'G' => $GLOBALS['egw_info']['user']['account_primary_group'], |
| 1069 | 1068 | 'U' => '0', |
| 1070 | 1069 | ) as $sym => $id) |
@@ -1074,11 +1073,11 @@ discard block |
||
| 1074 | 1073 | $this->home_set_pref[$key] = $id; |
| 1075 | 1074 | } |
| 1076 | 1075 | } |
| 1077 | - foreach(array_keys($this->bo->get_addressbooks(Acl::READ)) as $id) |
|
| 1076 | + foreach (array_keys($this->bo->get_addressbooks(Acl::READ)) as $id) |
|
| 1078 | 1077 | { |
| 1079 | 1078 | if (($id || !$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) && |
| 1080 | - $GLOBALS['egw_info']['user']['account_id'] != $id && // no current user and no accounts, if disabled in ab prefs |
|
| 1081 | - (in_array('A',$this->home_set_pref) || in_array((string)$id,$this->home_set_pref)) && |
|
| 1079 | + $GLOBALS['egw_info']['user']['account_id'] != $id && // no current user and no accounts, if disabled in ab prefs |
|
| 1080 | + (in_array('A', $this->home_set_pref) || in_array((string)$id, $this->home_set_pref)) && |
|
| 1082 | 1081 | is_numeric($id) && ($owner = $id ? $this->accounts->id2name($id) : 'accounts')) |
| 1083 | 1082 | { |
| 1084 | 1083 | $shared[$id] = 'addressbook-'.$owner; |
@@ -1098,14 +1097,14 @@ discard block |
||
| 1098 | 1097 | public static function groupdav_root_props(array $data) |
| 1099 | 1098 | { |
| 1100 | 1099 | $data['props']['addressbook-home-set'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'addressbook-home-set', array( |
| 1101 | - Api\CalDAV::mkprop('href',$data['caldav']->base_uri.'/'.$GLOBALS['egw_info']['user']['account_lid'].'/'))); |
|
| 1100 | + Api\CalDAV::mkprop('href', $data['caldav']->base_uri.'/'.$GLOBALS['egw_info']['user']['account_lid'].'/'))); |
|
| 1102 | 1101 | |
| 1103 | 1102 | $data['props']['principal-address'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'principal-address', |
| 1104 | 1103 | $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] ? '' : array( |
| 1105 | - Api\CalDAV::mkprop('href',$data['caldav']->base_uri.'/addressbook-accounts/'.$GLOBALS['egw_info']['user']['person_id'].'.vcf'))); |
|
| 1104 | + Api\CalDAV::mkprop('href', $data['caldav']->base_uri.'/addressbook-accounts/'.$GLOBALS['egw_info']['user']['person_id'].'.vcf'))); |
|
| 1106 | 1105 | |
| 1107 | 1106 | $data['props']['directory-gateway'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'directory-gateway', array( |
| 1108 | - Api\CalDAV::mkprop('href',$data['caldav']->base_uri.'/addressbook/'))); |
|
| 1107 | + Api\CalDAV::mkprop('href', $data['caldav']->base_uri.'/addressbook/'))); |
|
| 1109 | 1108 | } |
| 1110 | 1109 | |
| 1111 | 1110 | /** |
@@ -1128,8 +1127,8 @@ discard block |
||
| 1128 | 1127 | $user = $hook_data['account_id']; |
| 1129 | 1128 | $addressbook_bo = new Api\Contacts(); |
| 1130 | 1129 | $addressbooks += $addressbook_bo->get_addressbooks(Acl::READ, null, $user); |
| 1131 | - if ($user > 0) unset($addressbooks[$user]); // allways synced |
|
| 1132 | - unset($addressbooks[$user.'p']);// ignore (optional) private addressbook for now |
|
| 1130 | + if ($user > 0) unset($addressbooks[$user]); // allways synced |
|
| 1131 | + unset($addressbooks[$user.'p']); // ignore (optional) private addressbook for now |
|
| 1133 | 1132 | } |
| 1134 | 1133 | |
| 1135 | 1134 | // allow to force no other addressbooks |
@@ -1156,9 +1155,9 @@ discard block |
||
| 1156 | 1155 | 'label' => 'Addressbooks to sync in addition to personal addressbook', |
| 1157 | 1156 | 'name' => 'addressbook-home-set', |
| 1158 | 1157 | 'help' => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likely not be supported!'). |
| 1159 | - '<br/>'.lang('They will be sub-folders in users home (%1 attribute).','CardDAV "addressbook-home-set"'). |
|
| 1160 | - '<br/>'.lang('Select "%1", if your client does not support multiple addressbooks.',lang('Sync all selected into one')). |
|
| 1161 | - '<br/>'.lang('Select "%1", if your client support groups, eg. OS X or iOS addressbook.',lang('Distribution lists as groups')), |
|
| 1158 | + '<br/>'.lang('They will be sub-folders in users home (%1 attribute).', 'CardDAV "addressbook-home-set"'). |
|
| 1159 | + '<br/>'.lang('Select "%1", if your client does not support multiple addressbooks.', lang('Sync all selected into one')). |
|
| 1160 | + '<br/>'.lang('Select "%1", if your client support groups, eg. OS X or iOS addressbook.', lang('Distribution lists as groups')), |
|
| 1162 | 1161 | 'values' => $addressbooks, |
| 1163 | 1162 | 'xmlrpc' => True, |
| 1164 | 1163 | 'admin' => False, |
@@ -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']) $filter['account_id'] = null; |
|
| 129 | + if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) |
|
| 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 ($where['id'] && ($lists = $this->bo->read_lists($where,'contact_uid',$where['list_owner']))) // limit to contacts in same AB! |
|
| 333 | + if ($where['id'] && ($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,15 +746,24 @@ 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 | if (!($save_ok = $is_group ? $this->save_group($contact, $oldContact) : $this->bo->save($contact))) |
| 676 | 762 | { |
| 677 | - if ($this->debug) error_log(__METHOD__."(,$id) save(".array2string($contact).") failed, Ok=$save_ok"); |
|
| 763 | + if ($this->debug) |
|
| 764 | + { |
|
| 765 | + error_log(__METHOD__."(,$id) save(".array2string($contact).") failed, Ok=$save_ok"); |
|
| 766 | + } |
|
| 678 | 767 | if ($save_ok === 0) |
| 679 | 768 | { |
| 680 | 769 | // honor Prefer: return=representation for 412 too (no need for client to explicitly reload) |
@@ -703,7 +792,10 @@ discard block |
||
| 703 | 792 | // send evtl. necessary respose headers: Location, etag, ... |
| 704 | 793 | $this->put_response_headers($contact, $options['path'], $retval, self::$path_attr != 'id'); |
| 705 | 794 | |
| 706 | - if ($this->debug > 1) error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($retval)); |
|
| 795 | + if ($this->debug > 1) |
|
| 796 | + { |
|
| 797 | + error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($retval)); |
|
| 798 | + } |
|
| 707 | 799 | return $retval; |
| 708 | 800 | } |
| 709 | 801 | |
@@ -717,7 +809,10 @@ discard block |
||
| 717 | 809 | function save_group(array &$contact, $oldContact=null) |
| 718 | 810 | { |
| 719 | 811 | $data = array('list_name' => $contact['n_fn']); |
| 720 | - if (!isset($contact['owner'])) $contact['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
| 812 | + if (!isset($contact['owner'])) |
|
| 813 | + { |
|
| 814 | + $contact['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
| 815 | + } |
|
| 721 | 816 | foreach(array('id','carddav_name','uid','owner') as $name) |
| 722 | 817 | { |
| 723 | 818 | $data['list_'.$name] = $contact[$name]; |
@@ -769,13 +864,22 @@ discard block |
||
| 769 | 864 | } |
| 770 | 865 | } |
| 771 | 866 | //error_log('to_add_ids='.array2string($to_add_ids).', to_delete_ids='.array2string($to_delete_ids)); |
| 772 | - if ($to_add_ids) $this->bo->add2list($to_add_ids, $list_id, array()); |
|
| 773 | - if ($to_delete_ids) $this->bo->remove_from_list($to_delete_ids, $list_id); |
|
| 867 | + if ($to_add_ids) |
|
| 868 | + { |
|
| 869 | + $this->bo->add2list($to_add_ids, $list_id, array()); |
|
| 870 | + } |
|
| 871 | + if ($to_delete_ids) |
|
| 872 | + { |
|
| 873 | + $this->bo->remove_from_list($to_delete_ids, $list_id); |
|
| 874 | + } |
|
| 774 | 875 | } |
| 775 | 876 | // reread as update of list-members updates etag and modified |
| 776 | 877 | $contact = $this->bo->read_list($list_id); |
| 777 | 878 | } |
| 778 | - if ($this->debug > 1) error_log(__METHOD__.'('.array2string($contact).', '.array2string($oldContact).') on return contact='.array2string($data).' returning '.array2string($list_id)); |
|
| 879 | + if ($this->debug > 1) |
|
| 880 | + { |
|
| 881 | + error_log(__METHOD__.'('.array2string($contact).', '.array2string($oldContact).') on return contact='.array2string($data).' returning '.array2string($list_id)); |
|
| 882 | + } |
|
| 779 | 883 | return $list_id; |
| 780 | 884 | } |
| 781 | 885 | |
@@ -789,11 +893,17 @@ discard block |
||
| 789 | 893 | public function getctag($path,$user) |
| 790 | 894 | { |
| 791 | 895 | static $ctags = array(); // a little per request caching, in case ctag and sync-token is both requested |
| 792 | - if (isset($ctags[$path])) return $ctags[$path]; |
|
| 896 | + if (isset($ctags[$path])) |
|
| 897 | + { |
|
| 898 | + return $ctags[$path]; |
|
| 899 | + } |
|
| 793 | 900 | |
| 794 | 901 | $user_in = $user; |
| 795 | 902 | // not showing addressbook of a single user? |
| 796 | - if (is_null($user) || $user === '' || $path == '/addressbook/') $user = null; |
|
| 903 | + if (is_null($user) || $user === '' || $path == '/addressbook/') |
|
| 904 | + { |
|
| 905 | + $user = null; |
|
| 906 | + } |
|
| 797 | 907 | |
| 798 | 908 | // If "Sync selected addressbooks into one" is set --> ctag need to take selected AB's into account too |
| 799 | 909 | if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O',$this->home_set_pref)) |
@@ -1006,16 +1116,22 @@ discard block |
||
| 1006 | 1116 | $contact['etag'] .= ':'.implode('-',$limit_in_ab); |
| 1007 | 1117 | } |
| 1008 | 1118 | } |
| 1009 | - elseif($contact === array()) // not found from read_lists() |
|
| 1119 | + elseif($contact === array()) |
|
| 1120 | + { |
|
| 1121 | + // not found from read_lists() |
|
| 1010 | 1122 | { |
| 1011 | 1123 | $contact = null; |
| 1012 | 1124 | } |
| 1125 | + } |
|
| 1013 | 1126 | |
| 1014 | 1127 | if ($contact && $contact['tid'] == Api\Contacts::DELETED_TYPE) |
| 1015 | 1128 | { |
| 1016 | 1129 | $contact = null; // handle deleted events, as not existing (404 Not Found) |
| 1017 | 1130 | } |
| 1018 | - if ($this->debug > 1) error_log(__METHOD__."('$id') returning ".array2string($contact)); |
|
| 1131 | + if ($this->debug > 1) |
|
| 1132 | + { |
|
| 1133 | + error_log(__METHOD__."('$id') returning ".array2string($contact)); |
|
| 1134 | + } |
|
| 1019 | 1135 | return $contact; |
| 1020 | 1136 | } |
| 1021 | 1137 | |
@@ -1045,7 +1161,10 @@ discard block |
||
| 1045 | 1161 | // remove add and delete grants for accounts (for admins too) |
| 1046 | 1162 | // as accounts can not be created as contacts, they eg. need further data |
| 1047 | 1163 | // and admins might not recognice they delete an account incl. its data |
| 1048 | - if (isset($grants[0])) $grants[0] &= ~(EGW_ACL_ADD|EGW_ACL_DELETE); |
|
| 1164 | + if (isset($grants[0])) |
|
| 1165 | + { |
|
| 1166 | + $grants[0] &= ~(EGW_ACL_ADD|EGW_ACL_DELETE); |
|
| 1167 | + } |
|
| 1049 | 1168 | |
| 1050 | 1169 | return $grants; |
| 1051 | 1170 | } |
@@ -1061,7 +1180,10 @@ discard block |
||
| 1061 | 1180 | $shared = array(); |
| 1062 | 1181 | |
| 1063 | 1182 | // if "Sync all selected addressbook into one" is set --> no (additional) shared addressbooks |
| 1064 | - if (!$ignore_all_in_one && in_array('O',$this->home_set_pref)) return array(); |
|
| 1183 | + if (!$ignore_all_in_one && in_array('O',$this->home_set_pref)) |
|
| 1184 | + { |
|
| 1185 | + return array(); |
|
| 1186 | + } |
|
| 1065 | 1187 | |
| 1066 | 1188 | // replace symbolic id's with real nummeric id's |
| 1067 | 1189 | foreach(array( |
@@ -1128,7 +1250,11 @@ discard block |
||
| 1128 | 1250 | $user = $hook_data['account_id']; |
| 1129 | 1251 | $addressbook_bo = new Api\Contacts(); |
| 1130 | 1252 | $addressbooks += $addressbook_bo->get_addressbooks(Acl::READ, null, $user); |
| 1131 | - if ($user > 0) unset($addressbooks[$user]); // allways synced |
|
| 1253 | + if ($user > 0) |
|
| 1254 | + { |
|
| 1255 | + unset($addressbooks[$user]); |
|
| 1256 | + } |
|
| 1257 | + // allways synced |
|
| 1132 | 1258 | unset($addressbooks[$user.'p']);// ignore (optional) private addressbook for now |
| 1133 | 1259 | } |
| 1134 | 1260 | |
@@ -44,9 +44,7 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | 46 | * imports entries according to given definition object. |
| 47 | - * @param resource $_stream |
|
| 48 | - * @param string $_charset |
|
| 49 | - * @param definition $_definition |
|
| 47 | + * @param importexport_definition $_definition |
|
| 50 | 48 | */ |
| 51 | 49 | public function init(importexport_definition &$_definition ) { |
| 52 | 50 | |
@@ -84,7 +82,7 @@ discard block |
||
| 84 | 82 | * |
| 85 | 83 | * Updates the count of actions taken |
| 86 | 84 | * |
| 87 | - * @return boolean success |
|
| 85 | + * @return null|boolean success |
|
| 88 | 86 | */ |
| 89 | 87 | protected function import_record(importexport_iface_egw_record &$record, &$import_csv) |
| 90 | 88 | { |
@@ -381,38 +381,38 @@ |
||
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | /** |
| 384 | - * Returns warnings that were encountered during importing |
|
| 385 | - * Maximum of one warning message per record, but you can append if you need to |
|
| 386 | - * |
|
| 387 | - * @return Array ( |
|
| 388 | - * record_# => warning message |
|
| 389 | - * ) |
|
| 390 | - */ |
|
| 391 | - public function get_warnings() { |
|
| 384 | + * Returns warnings that were encountered during importing |
|
| 385 | + * Maximum of one warning message per record, but you can append if you need to |
|
| 386 | + * |
|
| 387 | + * @return Array ( |
|
| 388 | + * record_# => warning message |
|
| 389 | + * ) |
|
| 390 | + */ |
|
| 391 | + public function get_warnings() { |
|
| 392 | 392 | return $this->warnings; |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | /** |
| 396 | - * Returns errors that were encountered during importing |
|
| 397 | - * Maximum of one error message per record, but you can append if you need to |
|
| 398 | - * |
|
| 399 | - * @return Array ( |
|
| 400 | - * record_# => error message |
|
| 401 | - * ) |
|
| 402 | - */ |
|
| 403 | - public function get_errors() { |
|
| 396 | + * Returns errors that were encountered during importing |
|
| 397 | + * Maximum of one error message per record, but you can append if you need to |
|
| 398 | + * |
|
| 399 | + * @return Array ( |
|
| 400 | + * record_# => error message |
|
| 401 | + * ) |
|
| 402 | + */ |
|
| 403 | + public function get_errors() { |
|
| 404 | 404 | return $this->errors; |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | /** |
| 408 | - * Returns a list of actions taken, and the number of records for that action. |
|
| 409 | - * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
| 410 | - * |
|
| 411 | - * @return Array ( |
|
| 412 | - * action => record count |
|
| 413 | - * ) |
|
| 414 | - */ |
|
| 415 | - public function get_results() { |
|
| 416 | - return $this->results; |
|
| 417 | - } |
|
| 408 | + * Returns a list of actions taken, and the number of records for that action. |
|
| 409 | + * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
| 410 | + * |
|
| 411 | + * @return Array ( |
|
| 412 | + * action => record count |
|
| 413 | + * ) |
|
| 414 | + */ |
|
| 415 | + public function get_results() { |
|
| 416 | + return $this->results; |
|
| 417 | + } |
|
| 418 | 418 | } |
@@ -15,14 +15,14 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * class import_csv for addressbook |
| 17 | 17 | */ |
| 18 | -class addressbook_import_contacts_csv extends importexport_basic_import_csv { |
|
| 18 | +class addressbook_import_contacts_csv extends importexport_basic_import_csv { |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * conditions for actions |
| 22 | 22 | * |
| 23 | 23 | * @var array |
| 24 | 24 | */ |
| 25 | - protected static $conditions = array( 'exists', 'equal' ); |
|
| 25 | + protected static $conditions = array('exists', 'equal'); |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * @var bocontacts |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @param string $_charset |
| 49 | 49 | * @param definition $_definition |
| 50 | 50 | */ |
| 51 | - public function init(importexport_definition &$_definition ) { |
|
| 51 | + public function init(importexport_definition&$_definition) { |
|
| 52 | 52 | |
| 53 | 53 | // fetch the addressbook bo |
| 54 | 54 | $this->bocontacts = new Api\Contacts(); |
@@ -59,17 +59,17 @@ discard block |
||
| 59 | 59 | $this->lookups = array( |
| 60 | 60 | 'tid' => array('n'=>'contact') |
| 61 | 61 | ); |
| 62 | - foreach($this->bocontacts->content_types as $tid => $data) |
|
| 62 | + foreach ($this->bocontacts->content_types as $tid => $data) |
|
| 63 | 63 | { |
| 64 | 64 | $this->lookups['tid'][$tid] = $data['name']; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | // set contact owner |
| 68 | - $contact_owner = isset( $_definition->plugin_options['contact_owner'] ) ? |
|
| 68 | + $contact_owner = isset($_definition->plugin_options['contact_owner']) ? |
|
| 69 | 69 | $_definition->plugin_options['contact_owner'] : $this->user; |
| 70 | 70 | |
| 71 | 71 | // Import into importer's personal addressbook |
| 72 | - if($contact_owner == 'personal') |
|
| 72 | + if ($contact_owner == 'personal') |
|
| 73 | 73 | { |
| 74 | 74 | $contact_owner = $this->user; |
| 75 | 75 | } |
@@ -86,15 +86,15 @@ discard block |
||
| 86 | 86 | * |
| 87 | 87 | * @return boolean success |
| 88 | 88 | */ |
| 89 | - protected function import_record(importexport_iface_egw_record &$record, &$import_csv) |
|
| 89 | + protected function import_record(importexport_iface_egw_record&$record, &$import_csv) |
|
| 90 | 90 | { |
| 91 | 91 | |
| 92 | 92 | // Set owner, unless it's supposed to come from CSV file |
| 93 | - if($this->definition->plugin_options['owner_from_csv'] && $record->owner) { |
|
| 94 | - if(!is_numeric($record->owner)) { |
|
| 93 | + if ($this->definition->plugin_options['owner_from_csv'] && $record->owner) { |
|
| 94 | + if (!is_numeric($record->owner)) { |
|
| 95 | 95 | // Automatically handle text owner without explicit translation |
| 96 | 96 | $new_owner = importexport_helper_functions::account_name2id($record->owner); |
| 97 | - if($new_owner == '') { |
|
| 97 | + if ($new_owner == '') { |
|
| 98 | 98 | $this->errors[$import_csv->get_current_position()] = lang( |
| 99 | 99 | 'Unable to convert "%1" to account ID. Using plugin setting (%2) for owner.', |
| 100 | 100 | $record->owner, |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | // Check that owner (addressbook) is allowed |
| 113 | - if(!array_key_exists($record->owner, $this->bocontacts->get_addressbooks())) |
|
| 113 | + if (!array_key_exists($record->owner, $this->bocontacts->get_addressbooks())) |
|
| 114 | 114 | { |
| 115 | 115 | $this->errors[$import_csv->get_current_position()] = lang("Unable to import into %1, using %2", |
| 116 | 116 | Api\Accounts::username($record->owner), |
@@ -121,18 +121,18 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | // Do not allow owner == 0 (accounts) without an account_id |
| 123 | 123 | // It causes the contact to be filed as an account, and can't delete |
| 124 | - if(!$record->owner && !$record->account_id) |
|
| 124 | + if (!$record->owner && !$record->account_id) |
|
| 125 | 125 | { |
| 126 | 126 | $record->owner = $GLOBALS['egw_info']['user']['account_id']; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | // Do not import into non-existing type, warn and change |
| 130 | - if(!$record->tid || !$this->lookups['tid'][$record->tid]) |
|
| 130 | + if (!$record->tid || !$this->lookups['tid'][$record->tid]) |
|
| 131 | 131 | { |
| 132 | 132 | // Avoid lots of warnings about type (2 types are contact and deleted) |
| 133 | - if(!$this->type_warned || count($this->lookups['tid']) == 2 ) |
|
| 133 | + if (!$this->type_warned || count($this->lookups['tid']) == 2) |
|
| 134 | 134 | { |
| 135 | - $this->warnings[$import_csv->get_current_position()] = lang('Unknown type %1, imported as %2',$record->tid,lang($this->lookups['tid']['n'])); |
|
| 135 | + $this->warnings[$import_csv->get_current_position()] = lang('Unknown type %1, imported as %2', $record->tid, lang($this->lookups['tid']['n'])); |
|
| 136 | 136 | $this->type_warned = true; |
| 137 | 137 | } |
| 138 | 138 | $record->tid = 'n'; |
@@ -141,45 +141,45 @@ discard block |
||
| 141 | 141 | // Also handle categories in their own field |
| 142 | 142 | $record_array = $record->get_record_array(); |
| 143 | 143 | $more_categories = array(); |
| 144 | - foreach($this->definition->plugin_options['field_mapping'] as $field_name) { |
|
| 145 | - if(!array_key_exists($field_name, $record_array) || |
|
| 146 | - substr($field_name,0,3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') continue; |
|
| 144 | + foreach ($this->definition->plugin_options['field_mapping'] as $field_name) { |
|
| 145 | + if (!array_key_exists($field_name, $record_array) || |
|
| 146 | + substr($field_name, 0, 3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') continue; |
|
| 147 | 147 | list(, $cat_id) = explode('-', $field_name); |
| 148 | - if(is_numeric($record->$field_name) && $record->$field_name != 1) { |
|
| 148 | + if (is_numeric($record->$field_name) && $record->$field_name != 1) { |
|
| 149 | 149 | // Column has a single category ID |
| 150 | 150 | $more_categories[] = $record->$field_name; |
| 151 | - } elseif($record->$field_name == '1' || |
|
| 151 | + } elseif ($record->$field_name == '1' || |
|
| 152 | 152 | (!is_numeric($record->$field_name) && strtolower($record->$field_name) == strtolower(lang('Yes')))) { |
| 153 | 153 | // Each category got its own column. '1' is the database value, lang('yes') is the human value |
| 154 | 154 | $more_categories[] = $cat_id; |
| 155 | 155 | } else { |
| 156 | 156 | // Text categories |
| 157 | - $more_categories = array_merge($more_categories, importexport_helper_functions::cat_name2id(is_array($record->$field_name) ? $record->$field_name : explode(',',$record->$field_name), $cat_id)); |
|
| 157 | + $more_categories = array_merge($more_categories, importexport_helper_functions::cat_name2id(is_array($record->$field_name) ? $record->$field_name : explode(',', $record->$field_name), $cat_id)); |
|
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | - if(count($more_categories) > 0) $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',',$record->cat_id), $more_categories); |
|
| 160 | + if (count($more_categories) > 0) $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',', $record->cat_id), $more_categories); |
|
| 161 | 161 | |
| 162 | 162 | // Private set but missing causes hidden entries |
| 163 | - if(array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) unset($record->private); |
|
| 163 | + if (array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) unset($record->private); |
|
| 164 | 164 | |
| 165 | 165 | // Format birthday as backend requires - converter should give timestamp |
| 166 | - if($record->bday && is_numeric($record->bday)) |
|
| 166 | + if ($record->bday && is_numeric($record->bday)) |
|
| 167 | 167 | { |
| 168 | 168 | $time = new Api\DateTime($record->bday); |
| 169 | 169 | $record->bday = $time->format('Y-m-d'); |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - if ( $this->definition->plugin_options['conditions'] ) { |
|
| 173 | - foreach ( $this->definition->plugin_options['conditions'] as $condition ) { |
|
| 172 | + if ($this->definition->plugin_options['conditions']) { |
|
| 173 | + foreach ($this->definition->plugin_options['conditions'] as $condition) { |
|
| 174 | 174 | $contacts = array(); |
| 175 | - switch ( $condition['type'] ) { |
|
| 175 | + switch ($condition['type']) { |
|
| 176 | 176 | // exists |
| 177 | 177 | case 'exists' : |
| 178 | - if($record_array[$condition['string']]) { |
|
| 179 | - $searchcondition = array( $condition['string'] => $record_array[$condition['string']]); |
|
| 178 | + if ($record_array[$condition['string']]) { |
|
| 179 | + $searchcondition = array($condition['string'] => $record_array[$condition['string']]); |
|
| 180 | 180 | // if we use account_id for the condition, we need to set the owner for filtering, as this |
| 181 | 181 | // enables Api\Contacts\Storage to decide what backend is to be used |
| 182 | - if ($condition['string']=='account_id') $searchcondition['owner']=0; |
|
| 182 | + if ($condition['string'] == 'account_id') $searchcondition['owner'] = 0; |
|
| 183 | 183 | $contacts = $this->bocontacts->search( |
| 184 | 184 | //array( $condition['string'] => $record[$condition['string']],), |
| 185 | 185 | '', |
@@ -188,37 +188,37 @@ discard block |
||
| 188 | 188 | $searchcondition |
| 189 | 189 | ); |
| 190 | 190 | } |
| 191 | - if ( is_array( $contacts ) && count( array_keys( $contacts ) ) >= 1 ) { |
|
| 191 | + if (is_array($contacts) && count(array_keys($contacts)) >= 1) { |
|
| 192 | 192 | // apply action to all contacts matching this exists condition |
| 193 | 193 | $action = $condition['true']; |
| 194 | - foreach ( (array)$contacts as $contact ) { |
|
| 194 | + foreach ((array)$contacts as $contact) { |
|
| 195 | 195 | $record->id = $contact['id']; |
| 196 | - if ( $this->definition->plugin_options['update_cats'] == 'add' ) { |
|
| 197 | - if ( !is_array( $contact['cat_id'] ) ) $contact['cat_id'] = explode( ',', $contact['cat_id'] ); |
|
| 198 | - if ( !is_array( $record_array['cat_id'] ) ) $record->cat_id = explode( ',', $record->cat_id ); |
|
| 199 | - $record->cat_id = implode( ',', array_unique( array_merge( $record->cat_id, $contact['cat_id'] ) ) ); |
|
| 196 | + if ($this->definition->plugin_options['update_cats'] == 'add') { |
|
| 197 | + if (!is_array($contact['cat_id'])) $contact['cat_id'] = explode(',', $contact['cat_id']); |
|
| 198 | + if (!is_array($record_array['cat_id'])) $record->cat_id = explode(',', $record->cat_id); |
|
| 199 | + $record->cat_id = implode(',', array_unique(array_merge($record->cat_id, $contact['cat_id']))); |
|
| 200 | 200 | } |
| 201 | - $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
|
| 201 | + $success = $this->action($action['action'], $record, $import_csv->get_current_position()); |
|
| 202 | 202 | } |
| 203 | 203 | } else { |
| 204 | 204 | $action = $condition['false']; |
| 205 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
| 205 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
| 206 | 206 | } |
| 207 | 207 | break; |
| 208 | 208 | case 'equal': |
| 209 | 209 | // Match on field |
| 210 | 210 | $result = $this->equal($record, $condition); |
| 211 | - if($result) |
|
| 211 | + if ($result) |
|
| 212 | 212 | { |
| 213 | 213 | // Apply true action to any matching records found |
| 214 | 214 | $action = $condition['true']; |
| 215 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
| 215 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
| 216 | 216 | } |
| 217 | 217 | else |
| 218 | 218 | { |
| 219 | 219 | // Apply false action if no matching records found |
| 220 | 220 | $action = $condition['false']; |
| 221 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
| 221 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
| 222 | 222 | } |
| 223 | 223 | break; |
| 224 | 224 | |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | } |
| 232 | 232 | } else { |
| 233 | 233 | // unconditional insert |
| 234 | - $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
|
| 234 | + $success = $this->action('insert', $record, $import_csv->get_current_position()); |
|
| 235 | 235 | } |
| 236 | 236 | return $success; |
| 237 | 237 | } |
@@ -243,21 +243,21 @@ discard block |
||
| 243 | 243 | * @param importexport_iface_egw_record $record contact data for the action |
| 244 | 244 | * @return bool success or not |
| 245 | 245 | */ |
| 246 | - protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) { |
|
| 246 | + protected function action($_action, importexport_iface_egw_record&$record, $record_num = 0) { |
|
| 247 | 247 | $_data = $record->get_record_array(); |
| 248 | 248 | switch ($_action) { |
| 249 | 249 | case 'none' : |
| 250 | 250 | return true; |
| 251 | 251 | case 'delete': |
| 252 | - if($_data['id']) |
|
| 252 | + if ($_data['id']) |
|
| 253 | 253 | { |
| 254 | - if ( $this->dry_run ) { |
|
| 254 | + if ($this->dry_run) { |
|
| 255 | 255 | //print_r($_data); |
| 256 | 256 | $this->results[$_action]++; |
| 257 | 257 | return true; |
| 258 | 258 | } |
| 259 | 259 | $result = $this->bocontacts->delete($_data); |
| 260 | - if($result && $result === true) |
|
| 260 | + if ($result && $result === true) |
|
| 261 | 261 | { |
| 262 | 262 | $this->results[$_action]++; |
| 263 | 263 | } |
@@ -272,14 +272,14 @@ discard block |
||
| 272 | 272 | // Only update if there are changes |
| 273 | 273 | $old = $this->bocontacts->read($_data['id']); |
| 274 | 274 | // if we get countrycodes as countryname, try to translate them -> the rest should be handled by bo classes. |
| 275 | - foreach(array('adr_one_', 'adr_two_') as $c_prefix) { |
|
| 276 | - if (strlen(trim($_data[$c_prefix.'countryname']))==2) |
|
| 275 | + foreach (array('adr_one_', 'adr_two_') as $c_prefix) { |
|
| 276 | + if (strlen(trim($_data[$c_prefix.'countryname'])) == 2) |
|
| 277 | 277 | $_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']), true); |
| 278 | 278 | } |
| 279 | 279 | // Don't change a user account into a contact |
| 280 | - if($old['owner'] == 0) { |
|
| 280 | + if ($old['owner'] == 0) { |
|
| 281 | 281 | unset($_data['owner']); |
| 282 | - } elseif(!$this->definition->plugin_options['change_owner']) { |
|
| 282 | + } elseif (!$this->definition->plugin_options['change_owner']) { |
|
| 283 | 283 | // Don't change addressbook of an existing contact |
| 284 | 284 | unset($_data['owner']); |
| 285 | 285 | } |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | // Merge to deal with fields not in import record |
| 288 | 288 | $_data = array_merge($old, $_data); |
| 289 | 289 | $changed = $this->tracking->changed_fields($_data, $old); |
| 290 | - if(count($changed) == 0) { |
|
| 290 | + if (count($changed) == 0) { |
|
| 291 | 291 | return true; |
| 292 | 292 | } else { |
| 293 | 293 | //error_log(__METHOD__.__LINE__.array2string($changed).' Old:'.$old['adr_one_countryname'].' ('.$old['adr_one_countrycode'].') New:'.$_data['adr_one_countryname'].' ('.$_data['adr_one_countryname'].')'); |
@@ -298,22 +298,22 @@ discard block |
||
| 298 | 298 | |
| 299 | 299 | // Fall through |
| 300 | 300 | case 'insert' : |
| 301 | - if($_action == 'insert') { |
|
| 301 | + if ($_action == 'insert') { |
|
| 302 | 302 | // Addressbook backend doesn't like inserting with ID specified, it screws up the owner & etag |
| 303 | 303 | unset($_data['id']); |
| 304 | 304 | } |
| 305 | - if(!isset($_data['org_name'])) { |
|
| 305 | + if (!isset($_data['org_name'])) { |
|
| 306 | 306 | // org_name is a trigger to update n_fileas |
| 307 | 307 | $_data['org_name'] = ''; |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - if ( $this->dry_run ) { |
|
| 310 | + if ($this->dry_run) { |
|
| 311 | 311 | //print_r($_data); |
| 312 | 312 | $this->results[$_action]++; |
| 313 | 313 | return true; |
| 314 | 314 | } else { |
| 315 | - $result = $this->bocontacts->save( $_data, $this->is_admin); |
|
| 316 | - if(!$result) { |
|
| 315 | + $result = $this->bocontacts->save($_data, $this->is_admin); |
|
| 316 | + if (!$result) { |
|
| 317 | 317 | $this->errors[$record_num] = $this->bocontacts->error; |
| 318 | 318 | } else { |
| 319 | 319 | $this->results[$_action]++; |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | return $result; |
| 324 | 324 | } |
| 325 | 325 | default: |
| 326 | - throw new Api\Exception('Unsupported action: '. $_action); |
|
| 326 | + throw new Api\Exception('Unsupported action: '.$_action); |
|
| 327 | 327 | |
| 328 | 328 | } |
| 329 | 329 | } |
@@ -15,7 +15,8 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * class import_csv for addressbook |
| 17 | 17 | */ |
| 18 | -class addressbook_import_contacts_csv extends importexport_basic_import_csv { |
|
| 18 | +class addressbook_import_contacts_csv extends importexport_basic_import_csv |
|
| 19 | +{ |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * conditions for actions |
@@ -48,7 +49,8 @@ discard block |
||
| 48 | 49 | * @param string $_charset |
| 49 | 50 | * @param definition $_definition |
| 50 | 51 | */ |
| 51 | - public function init(importexport_definition &$_definition ) { |
|
| 52 | + public function init(importexport_definition &$_definition ) |
|
| 53 | + { |
|
| 52 | 54 | |
| 53 | 55 | // fetch the addressbook bo |
| 54 | 56 | $this->bocontacts = new Api\Contacts(); |
@@ -90,22 +92,29 @@ discard block |
||
| 90 | 92 | { |
| 91 | 93 | |
| 92 | 94 | // Set owner, unless it's supposed to come from CSV file |
| 93 | - if($this->definition->plugin_options['owner_from_csv'] && $record->owner) { |
|
| 94 | - if(!is_numeric($record->owner)) { |
|
| 95 | + if($this->definition->plugin_options['owner_from_csv'] && $record->owner) |
|
| 96 | + { |
|
| 97 | + if(!is_numeric($record->owner)) |
|
| 98 | + { |
|
| 95 | 99 | // Automatically handle text owner without explicit translation |
| 96 | 100 | $new_owner = importexport_helper_functions::account_name2id($record->owner); |
| 97 | - if($new_owner == '') { |
|
| 101 | + if($new_owner == '') |
|
| 102 | + { |
|
| 98 | 103 | $this->errors[$import_csv->get_current_position()] = lang( |
| 99 | 104 | 'Unable to convert "%1" to account ID. Using plugin setting (%2) for owner.', |
| 100 | 105 | $record->owner, |
| 101 | 106 | Api\Accounts::username($this->user) |
| 102 | 107 | ); |
| 103 | 108 | $record->owner = $this->user; |
| 104 | - } else { |
|
| 109 | + } |
|
| 110 | + else |
|
| 111 | + { |
|
| 105 | 112 | $record->owner = $new_owner; |
| 106 | 113 | } |
| 107 | 114 | } |
| 108 | - } else { |
|
| 115 | + } |
|
| 116 | + else |
|
| 117 | + { |
|
| 109 | 118 | $record->owner = $this->user; |
| 110 | 119 | } |
| 111 | 120 | |
@@ -141,26 +150,41 @@ discard block |
||
| 141 | 150 | // Also handle categories in their own field |
| 142 | 151 | $record_array = $record->get_record_array(); |
| 143 | 152 | $more_categories = array(); |
| 144 | - foreach($this->definition->plugin_options['field_mapping'] as $field_name) { |
|
| 153 | + foreach($this->definition->plugin_options['field_mapping'] as $field_name) |
|
| 154 | + { |
|
| 145 | 155 | if(!array_key_exists($field_name, $record_array) || |
| 146 | - substr($field_name,0,3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') continue; |
|
| 156 | + substr($field_name,0,3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') |
|
| 157 | + { |
|
| 158 | + continue; |
|
| 159 | + } |
|
| 147 | 160 | list(, $cat_id) = explode('-', $field_name); |
| 148 | - if(is_numeric($record->$field_name) && $record->$field_name != 1) { |
|
| 161 | + if(is_numeric($record->$field_name) && $record->$field_name != 1) |
|
| 162 | + { |
|
| 149 | 163 | // Column has a single category ID |
| 150 | 164 | $more_categories[] = $record->$field_name; |
| 151 | - } elseif($record->$field_name == '1' || |
|
| 152 | - (!is_numeric($record->$field_name) && strtolower($record->$field_name) == strtolower(lang('Yes')))) { |
|
| 165 | + } |
|
| 166 | + elseif($record->$field_name == '1' || |
|
| 167 | + (!is_numeric($record->$field_name) && strtolower($record->$field_name) == strtolower(lang('Yes')))) |
|
| 168 | + { |
|
| 153 | 169 | // Each category got its own column. '1' is the database value, lang('yes') is the human value |
| 154 | 170 | $more_categories[] = $cat_id; |
| 155 | - } else { |
|
| 171 | + } |
|
| 172 | + else |
|
| 173 | + { |
|
| 156 | 174 | // Text categories |
| 157 | 175 | $more_categories = array_merge($more_categories, importexport_helper_functions::cat_name2id(is_array($record->$field_name) ? $record->$field_name : explode(',',$record->$field_name), $cat_id)); |
| 158 | 176 | } |
| 159 | 177 | } |
| 160 | - if(count($more_categories) > 0) $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',',$record->cat_id), $more_categories); |
|
| 178 | + if(count($more_categories) > 0) |
|
| 179 | + { |
|
| 180 | + $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',',$record->cat_id), $more_categories); |
|
| 181 | + } |
|
| 161 | 182 | |
| 162 | 183 | // Private set but missing causes hidden entries |
| 163 | - if(array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) unset($record->private); |
|
| 184 | + if(array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) |
|
| 185 | + { |
|
| 186 | + unset($record->private); |
|
| 187 | + } |
|
| 164 | 188 | |
| 165 | 189 | // Format birthday as backend requires - converter should give timestamp |
| 166 | 190 | if($record->bday && is_numeric($record->bday)) |
@@ -169,17 +193,24 @@ discard block |
||
| 169 | 193 | $record->bday = $time->format('Y-m-d'); |
| 170 | 194 | } |
| 171 | 195 | |
| 172 | - if ( $this->definition->plugin_options['conditions'] ) { |
|
| 173 | - foreach ( $this->definition->plugin_options['conditions'] as $condition ) { |
|
| 196 | + if ( $this->definition->plugin_options['conditions'] ) |
|
| 197 | + { |
|
| 198 | + foreach ( $this->definition->plugin_options['conditions'] as $condition ) |
|
| 199 | + { |
|
| 174 | 200 | $contacts = array(); |
| 175 | - switch ( $condition['type'] ) { |
|
| 201 | + switch ( $condition['type'] ) |
|
| 202 | + { |
|
| 176 | 203 | // exists |
| 177 | 204 | case 'exists' : |
| 178 | - if($record_array[$condition['string']]) { |
|
| 205 | + if($record_array[$condition['string']]) |
|
| 206 | + { |
|
| 179 | 207 | $searchcondition = array( $condition['string'] => $record_array[$condition['string']]); |
| 180 | 208 | // if we use account_id for the condition, we need to set the owner for filtering, as this |
| 181 | 209 | // enables Api\Contacts\Storage to decide what backend is to be used |
| 182 | - if ($condition['string']=='account_id') $searchcondition['owner']=0; |
|
| 210 | + if ($condition['string']=='account_id') |
|
| 211 | + { |
|
| 212 | + $searchcondition['owner']=0; |
|
| 213 | + } |
|
| 183 | 214 | $contacts = $this->bocontacts->search( |
| 184 | 215 | //array( $condition['string'] => $record[$condition['string']],), |
| 185 | 216 | '', |
@@ -188,19 +219,30 @@ discard block |
||
| 188 | 219 | $searchcondition |
| 189 | 220 | ); |
| 190 | 221 | } |
| 191 | - if ( is_array( $contacts ) && count( array_keys( $contacts ) ) >= 1 ) { |
|
| 222 | + if ( is_array( $contacts ) && count( array_keys( $contacts ) ) >= 1 ) |
|
| 223 | + { |
|
| 192 | 224 | // apply action to all contacts matching this exists condition |
| 193 | 225 | $action = $condition['true']; |
| 194 | - foreach ( (array)$contacts as $contact ) { |
|
| 226 | + foreach ( (array)$contacts as $contact ) |
|
| 227 | + { |
|
| 195 | 228 | $record->id = $contact['id']; |
| 196 | - if ( $this->definition->plugin_options['update_cats'] == 'add' ) { |
|
| 197 | - if ( !is_array( $contact['cat_id'] ) ) $contact['cat_id'] = explode( ',', $contact['cat_id'] ); |
|
| 198 | - if ( !is_array( $record_array['cat_id'] ) ) $record->cat_id = explode( ',', $record->cat_id ); |
|
| 229 | + if ( $this->definition->plugin_options['update_cats'] == 'add' ) |
|
| 230 | + { |
|
| 231 | + if ( !is_array( $contact['cat_id'] ) ) |
|
| 232 | + { |
|
| 233 | + $contact['cat_id'] = explode( ',', $contact['cat_id'] ); |
|
| 234 | + } |
|
| 235 | + if ( !is_array( $record_array['cat_id'] ) ) |
|
| 236 | + { |
|
| 237 | + $record->cat_id = explode( ',', $record->cat_id ); |
|
| 238 | + } |
|
| 199 | 239 | $record->cat_id = implode( ',', array_unique( array_merge( $record->cat_id, $contact['cat_id'] ) ) ); |
| 200 | 240 | } |
| 201 | 241 | $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
| 202 | 242 | } |
| 203 | - } else { |
|
| 243 | + } |
|
| 244 | + else |
|
| 245 | + { |
|
| 204 | 246 | $action = $condition['false']; |
| 205 | 247 | $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
| 206 | 248 | } |
@@ -227,9 +269,14 @@ discard block |
||
| 227 | 269 | die('condition / action not supported!!!'); |
| 228 | 270 | break; |
| 229 | 271 | } |
| 230 | - if ($action['stop']) break; |
|
| 272 | + if ($action['stop']) |
|
| 273 | + { |
|
| 274 | + break; |
|
| 275 | + } |
|
| 231 | 276 | } |
| 232 | - } else { |
|
| 277 | + } |
|
| 278 | + else |
|
| 279 | + { |
|
| 233 | 280 | // unconditional insert |
| 234 | 281 | $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
| 235 | 282 | } |
@@ -243,15 +290,18 @@ discard block |
||
| 243 | 290 | * @param importexport_iface_egw_record $record contact data for the action |
| 244 | 291 | * @return bool success or not |
| 245 | 292 | */ |
| 246 | - protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) { |
|
| 293 | + protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) |
|
| 294 | + { |
|
| 247 | 295 | $_data = $record->get_record_array(); |
| 248 | - switch ($_action) { |
|
| 296 | + switch ($_action) |
|
| 297 | + { |
|
| 249 | 298 | case 'none' : |
| 250 | 299 | return true; |
| 251 | 300 | case 'delete': |
| 252 | 301 | if($_data['id']) |
| 253 | 302 | { |
| 254 | - if ( $this->dry_run ) { |
|
| 303 | + if ( $this->dry_run ) |
|
| 304 | + { |
|
| 255 | 305 | //print_r($_data); |
| 256 | 306 | $this->results[$_action]++; |
| 257 | 307 | return true; |
@@ -272,14 +322,20 @@ discard block |
||
| 272 | 322 | // Only update if there are changes |
| 273 | 323 | $old = $this->bocontacts->read($_data['id']); |
| 274 | 324 | // if we get countrycodes as countryname, try to translate them -> the rest should be handled by bo classes. |
| 275 | - foreach(array('adr_one_', 'adr_two_') as $c_prefix) { |
|
| 325 | + foreach(array('adr_one_', 'adr_two_') as $c_prefix) |
|
| 326 | + { |
|
| 276 | 327 | if (strlen(trim($_data[$c_prefix.'countryname']))==2) |
| 277 | - $_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']), true); |
|
| 328 | + { |
|
| 329 | + $_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']), true); |
|
| 330 | + } |
|
| 278 | 331 | } |
| 279 | 332 | // Don't change a user account into a contact |
| 280 | - if($old['owner'] == 0) { |
|
| 333 | + if($old['owner'] == 0) |
|
| 334 | + { |
|
| 281 | 335 | unset($_data['owner']); |
| 282 | - } elseif(!$this->definition->plugin_options['change_owner']) { |
|
| 336 | + } |
|
| 337 | + elseif(!$this->definition->plugin_options['change_owner']) |
|
| 338 | + { |
|
| 283 | 339 | // Don't change addressbook of an existing contact |
| 284 | 340 | unset($_data['owner']); |
| 285 | 341 | } |
@@ -287,9 +343,12 @@ discard block |
||
| 287 | 343 | // Merge to deal with fields not in import record |
| 288 | 344 | $_data = array_merge($old, $_data); |
| 289 | 345 | $changed = $this->tracking->changed_fields($_data, $old); |
| 290 | - if(count($changed) == 0) { |
|
| 346 | + if(count($changed) == 0) |
|
| 347 | + { |
|
| 291 | 348 | return true; |
| 292 | - } else { |
|
| 349 | + } |
|
| 350 | + else |
|
| 351 | + { |
|
| 293 | 352 | //error_log(__METHOD__.__LINE__.array2string($changed).' Old:'.$old['adr_one_countryname'].' ('.$old['adr_one_countrycode'].') New:'.$_data['adr_one_countryname'].' ('.$_data['adr_one_countryname'].')'); |
| 294 | 353 | } |
| 295 | 354 | |
@@ -298,24 +357,32 @@ discard block |
||
| 298 | 357 | |
| 299 | 358 | // Fall through |
| 300 | 359 | case 'insert' : |
| 301 | - if($_action == 'insert') { |
|
| 360 | + if($_action == 'insert') |
|
| 361 | + { |
|
| 302 | 362 | // Addressbook backend doesn't like inserting with ID specified, it screws up the owner & etag |
| 303 | 363 | unset($_data['id']); |
| 304 | 364 | } |
| 305 | - if(!isset($_data['org_name'])) { |
|
| 365 | + if(!isset($_data['org_name'])) |
|
| 366 | + { |
|
| 306 | 367 | // org_name is a trigger to update n_fileas |
| 307 | 368 | $_data['org_name'] = ''; |
| 308 | 369 | } |
| 309 | 370 | |
| 310 | - if ( $this->dry_run ) { |
|
| 371 | + if ( $this->dry_run ) |
|
| 372 | + { |
|
| 311 | 373 | //print_r($_data); |
| 312 | 374 | $this->results[$_action]++; |
| 313 | 375 | return true; |
| 314 | - } else { |
|
| 376 | + } |
|
| 377 | + else |
|
| 378 | + { |
|
| 315 | 379 | $result = $this->bocontacts->save( $_data, $this->is_admin); |
| 316 | - if(!$result) { |
|
| 380 | + if(!$result) |
|
| 381 | + { |
|
| 317 | 382 | $this->errors[$record_num] = $this->bocontacts->error; |
| 318 | - } else { |
|
| 383 | + } |
|
| 384 | + else |
|
| 385 | + { |
|
| 319 | 386 | $this->results[$_action]++; |
| 320 | 387 | // This does nothing (yet?) but update the identifier |
| 321 | 388 | $record->save($result); |
@@ -333,7 +400,8 @@ discard block |
||
| 333 | 400 | * |
| 334 | 401 | * @return string name |
| 335 | 402 | */ |
| 336 | - public static function get_name() { |
|
| 403 | + public static function get_name() |
|
| 404 | + { |
|
| 337 | 405 | return lang('Addressbook CSV import'); |
| 338 | 406 | } |
| 339 | 407 | |
@@ -342,7 +410,8 @@ discard block |
||
| 342 | 410 | * |
| 343 | 411 | * @return string descriprion |
| 344 | 412 | */ |
| 345 | - public static function get_description() { |
|
| 413 | + public static function get_description() |
|
| 414 | + { |
|
| 346 | 415 | return lang("Imports contacts into your Addressbook from a CSV File. CSV means 'Comma Seperated Values'. However in the options Tab you can also choose other seperators."); |
| 347 | 416 | } |
| 348 | 417 | |
@@ -351,7 +420,8 @@ discard block |
||
| 351 | 420 | * |
| 352 | 421 | * @return string suffix (comma seperated) |
| 353 | 422 | */ |
| 354 | - public static function get_filesuffix() { |
|
| 423 | + public static function get_filesuffix() |
|
| 424 | + { |
|
| 355 | 425 | return 'csv'; |
| 356 | 426 | } |
| 357 | 427 | |
@@ -367,7 +437,8 @@ discard block |
||
| 367 | 437 | * preserv => array, |
| 368 | 438 | * ) |
| 369 | 439 | */ |
| 370 | - public function get_options_etpl() { |
|
| 440 | + public function get_options_etpl() |
|
| 441 | + { |
|
| 371 | 442 | // lets do it! |
| 372 | 443 | } |
| 373 | 444 | |
@@ -376,7 +447,8 @@ discard block |
||
| 376 | 447 | * |
| 377 | 448 | * @return string etemplate name |
| 378 | 449 | */ |
| 379 | - public function get_selectors_etpl() { |
|
| 450 | + public function get_selectors_etpl() |
|
| 451 | + { |
|
| 380 | 452 | // lets do it! |
| 381 | 453 | } |
| 382 | 454 | |
@@ -388,7 +460,8 @@ discard block |
||
| 388 | 460 | * record_# => warning message |
| 389 | 461 | * ) |
| 390 | 462 | */ |
| 391 | - public function get_warnings() { |
|
| 463 | + public function get_warnings() |
|
| 464 | + { |
|
| 392 | 465 | return $this->warnings; |
| 393 | 466 | } |
| 394 | 467 | |
@@ -400,7 +473,8 @@ discard block |
||
| 400 | 473 | * record_# => error message |
| 401 | 474 | * ) |
| 402 | 475 | */ |
| 403 | - public function get_errors() { |
|
| 476 | + public function get_errors() |
|
| 477 | + { |
|
| 404 | 478 | return $this->errors; |
| 405 | 479 | } |
| 406 | 480 | |
@@ -412,7 +486,8 @@ discard block |
||
| 412 | 486 | * action => record count |
| 413 | 487 | * ) |
| 414 | 488 | */ |
| 415 | - public function get_results() { |
|
| 489 | + public function get_results() |
|
| 490 | + { |
|
| 416 | 491 | return $this->results; |
| 417 | 492 | } |
| 418 | 493 | } |
@@ -83,8 +83,7 @@ |
||
| 83 | 83 | /** |
| 84 | 84 | * imports entries according to given definition object. |
| 85 | 85 | * @param resource $_stream |
| 86 | - * @param string $_charset |
|
| 87 | - * @param definition $_definition |
|
| 86 | + * @param importexport_definition $_definition |
|
| 88 | 87 | */ |
| 89 | 88 | public function import( $_stream, importexport_definition $_definition ) { |
| 90 | 89 | $this->definition = $_definition; |
@@ -45,8 +45,8 @@ discard block |
||
| 45 | 45 | private $bocontacts; |
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | - * For figuring out if a contact has changed |
|
| 49 | - */ |
|
| 48 | + * For figuring out if a contact has changed |
|
| 49 | + */ |
|
| 50 | 50 | protected $tracking; |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -76,9 +76,9 @@ discard block |
||
| 76 | 76 | protected $errors = array(); |
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | - * List of actions, and how many times that action was taken |
|
| 80 | - */ |
|
| 81 | - protected $results = array(); |
|
| 79 | + * List of actions, and how many times that action was taken |
|
| 80 | + */ |
|
| 81 | + protected $results = array(); |
|
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | 84 | * imports entries according to given definition object. |
@@ -93,14 +93,14 @@ discard block |
||
| 93 | 93 | $this->is_admin = isset( $GLOBALS['egw_info']['user']['apps']['admin'] ) && $GLOBALS['egw_info']['user']['apps']['admin']; |
| 94 | 94 | $this->user = $GLOBALS['egw_info']['user']['account_id']; |
| 95 | 95 | |
| 96 | - // set contact owner |
|
| 97 | - $contact_owner = isset( $_definition->plugin_options['contact_owner'] ) ? |
|
| 98 | - $_definition->plugin_options['contact_owner'] : $this->user; |
|
| 99 | - // Import into importer's personal addressbook |
|
| 100 | - if($contact_owner == 'personal') |
|
| 101 | - { |
|
| 102 | - $contact_owner = $this->user; |
|
| 103 | - } |
|
| 96 | + // set contact owner |
|
| 97 | + $contact_owner = isset( $_definition->plugin_options['contact_owner'] ) ? |
|
| 98 | + $_definition->plugin_options['contact_owner'] : $this->user; |
|
| 99 | + // Import into importer's personal addressbook |
|
| 100 | + if($contact_owner == 'personal') |
|
| 101 | + { |
|
| 102 | + $contact_owner = $this->user; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | 105 | // dry run? |
| 106 | 106 | $this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] : false; |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | $this->errors = array(); |
| 124 | 124 | |
| 125 | 125 | // Fix for Apple Addressbook |
| 126 | - $vCard = preg_replace('/item\d\.(ADR|TEL|EMAIL|URL)/', '\1', stream_get_contents($_stream)); |
|
| 126 | + $vCard = preg_replace('/item\d\.(ADR|TEL|EMAIL|URL)/', '\1', stream_get_contents($_stream)); |
|
| 127 | 127 | |
| 128 | 128 | $contacts = new Api\CalDAV\IcalIterator($vCard, '', $charset, array($this, '_vcard'),array( |
| 129 | 129 | // Owner (addressbook) |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | foreach($this->preview_records as $record) |
| 278 | 278 | { |
| 279 | 279 | // Convert to human-friendly |
| 280 | - importexport_export_csv::convert($record,$record_class::$types,$_definition->application); |
|
| 280 | + importexport_export_csv::convert($record,$record_class::$types,$_definition->application); |
|
| 281 | 281 | $record = $record->get_record_array(); |
| 282 | 282 | $row = array(); |
| 283 | 283 | foreach(array_keys($labels) as $field) |
@@ -350,38 +350,38 @@ discard block |
||
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | /** |
| 353 | - * Returns warnings that were encountered during importing |
|
| 354 | - * Maximum of one warning message per record, but you can append if you need to |
|
| 355 | - * |
|
| 356 | - * @return Array ( |
|
| 357 | - * record_# => warning message |
|
| 358 | - * ) |
|
| 359 | - */ |
|
| 360 | - public function get_warnings() { |
|
| 353 | + * Returns warnings that were encountered during importing |
|
| 354 | + * Maximum of one warning message per record, but you can append if you need to |
|
| 355 | + * |
|
| 356 | + * @return Array ( |
|
| 357 | + * record_# => warning message |
|
| 358 | + * ) |
|
| 359 | + */ |
|
| 360 | + public function get_warnings() { |
|
| 361 | 361 | return $this->warnings; |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | /** |
| 365 | - * Returns errors that were encountered during importing |
|
| 366 | - * Maximum of one error message per record, but you can append if you need to |
|
| 367 | - * |
|
| 368 | - * @return Array ( |
|
| 369 | - * record_# => error message |
|
| 370 | - * ) |
|
| 371 | - */ |
|
| 372 | - public function get_errors() { |
|
| 365 | + * Returns errors that were encountered during importing |
|
| 366 | + * Maximum of one error message per record, but you can append if you need to |
|
| 367 | + * |
|
| 368 | + * @return Array ( |
|
| 369 | + * record_# => error message |
|
| 370 | + * ) |
|
| 371 | + */ |
|
| 372 | + public function get_errors() { |
|
| 373 | 373 | return $this->errors; |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | /** |
| 377 | - * Returns a list of actions taken, and the number of records for that action. |
|
| 378 | - * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
| 379 | - * |
|
| 380 | - * @return Array ( |
|
| 381 | - * action => record count |
|
| 382 | - * ) |
|
| 383 | - */ |
|
| 384 | - public function get_results() { |
|
| 385 | - return $this->results; |
|
| 386 | - } |
|
| 377 | + * Returns a list of actions taken, and the number of records for that action. |
|
| 378 | + * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
| 379 | + * |
|
| 380 | + * @return Array ( |
|
| 381 | + * action => record count |
|
| 382 | + * ) |
|
| 383 | + */ |
|
| 384 | + public function get_results() { |
|
| 385 | + return $this->results; |
|
| 386 | + } |
|
| 387 | 387 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * Plugin to import vCard files |
| 17 | 17 | */ |
| 18 | -class addressbook_import_vcard implements importexport_iface_import_plugin { |
|
| 18 | +class addressbook_import_vcard implements importexport_iface_import_plugin { |
|
| 19 | 19 | |
| 20 | 20 | private static $plugin_options = array( |
| 21 | 21 | |
@@ -86,24 +86,24 @@ discard block |
||
| 86 | 86 | * @param string $_charset |
| 87 | 87 | * @param definition $_definition |
| 88 | 88 | */ |
| 89 | - public function import( $_stream, importexport_definition $_definition ) { |
|
| 89 | + public function import($_stream, importexport_definition $_definition) { |
|
| 90 | 90 | $this->definition = $_definition; |
| 91 | 91 | |
| 92 | 92 | // user, is admin ? |
| 93 | - $this->is_admin = isset( $GLOBALS['egw_info']['user']['apps']['admin'] ) && $GLOBALS['egw_info']['user']['apps']['admin']; |
|
| 93 | + $this->is_admin = isset($GLOBALS['egw_info']['user']['apps']['admin']) && $GLOBALS['egw_info']['user']['apps']['admin']; |
|
| 94 | 94 | $this->user = $GLOBALS['egw_info']['user']['account_id']; |
| 95 | 95 | |
| 96 | 96 | // set contact owner |
| 97 | - $contact_owner = isset( $_definition->plugin_options['contact_owner'] ) ? |
|
| 97 | + $contact_owner = isset($_definition->plugin_options['contact_owner']) ? |
|
| 98 | 98 | $_definition->plugin_options['contact_owner'] : $this->user; |
| 99 | 99 | // Import into importer's personal addressbook |
| 100 | - if($contact_owner == 'personal') |
|
| 100 | + if ($contact_owner == 'personal') |
|
| 101 | 101 | { |
| 102 | 102 | $contact_owner = $this->user; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | // dry run? |
| 106 | - $this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] : false; |
|
| 106 | + $this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false; |
|
| 107 | 107 | |
| 108 | 108 | // Needed for categories to work right |
| 109 | 109 | $GLOBALS['egw_info']['flags']['currentapp'] = 'addressbook'; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | $this->bocontacts = new addressbook_vcal(); |
| 113 | 113 | |
| 114 | 114 | $charset = $_definition->plugin_options['charset']; |
| 115 | - if($charset == 'user') $charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset']; |
|
| 115 | + if ($charset == 'user') $charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset']; |
|
| 116 | 116 | |
| 117 | 117 | // Start counting successes |
| 118 | 118 | $this->current = 0; |
@@ -125,24 +125,24 @@ discard block |
||
| 125 | 125 | // Fix for Apple Addressbook |
| 126 | 126 | $vCard = preg_replace('/item\d\.(ADR|TEL|EMAIL|URL)/', '\1', stream_get_contents($_stream)); |
| 127 | 127 | |
| 128 | - $contacts = new Api\CalDAV\IcalIterator($vCard, '', $charset, array($this, '_vcard'),array( |
|
| 128 | + $contacts = new Api\CalDAV\IcalIterator($vCard, '', $charset, array($this, '_vcard'), array( |
|
| 129 | 129 | // Owner (addressbook) |
| 130 | 130 | $contact_owner |
| 131 | 131 | )); |
| 132 | 132 | $contacts->next(); |
| 133 | - while($contacts->valid()) { |
|
| 133 | + while ($contacts->valid()) { |
|
| 134 | 134 | $this->current++; |
| 135 | 135 | $contact = $contacts->current(); |
| 136 | 136 | |
| 137 | 137 | $this->action('insert', $contact, $this->current); |
| 138 | 138 | |
| 139 | 139 | // Stop if we have enough records for a preview |
| 140 | - if($this->dry_run) |
|
| 140 | + if ($this->dry_run) |
|
| 141 | 141 | { |
| 142 | 142 | $egw_record = new addressbook_egw_record(); |
| 143 | 143 | $egw_record->set_record($contact); |
| 144 | 144 | $this->preview_records[] = $egw_record; |
| 145 | - if($count >= $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']) break; |
|
| 145 | + if ($count >= $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']) break; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | $count++; |
@@ -158,13 +158,13 @@ discard block |
||
| 158 | 158 | public function _vcard($_vcard, $owner) |
| 159 | 159 | { |
| 160 | 160 | $charset = $this->definition->plugin_options['charset']; |
| 161 | - if($charset == 'user') $charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset']; |
|
| 162 | - $record = $this->bocontacts->vcardtoegw($_vcard,$charset); |
|
| 161 | + if ($charset == 'user') $charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset']; |
|
| 162 | + $record = $this->bocontacts->vcardtoegw($_vcard, $charset); |
|
| 163 | 163 | |
| 164 | 164 | $record['owner'] = $owner; |
| 165 | 165 | |
| 166 | 166 | // Check that owner (addressbook) is allowed |
| 167 | - if(!array_key_exists($record['owner'], $this->bocontacts->get_addressbooks())) |
|
| 167 | + if (!array_key_exists($record['owner'], $this->bocontacts->get_addressbooks())) |
|
| 168 | 168 | { |
| 169 | 169 | $this->errors[$this->current] = lang("Unable to import into %1, using %2", |
| 170 | 170 | Api\Accounts::username($record['owner']), |
@@ -175,14 +175,14 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | // Do not allow owner == 0 (accounts) without an account_id |
| 177 | 177 | // It causes the contact to be filed as an account, and can't delete |
| 178 | - if(!$record['owner'] && !$record['account_id']) |
|
| 178 | + if (!$record['owner'] && !$record['account_id']) |
|
| 179 | 179 | { |
| 180 | 180 | $record['owner'] = $this->user; |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | if (is_array($record['cat_id'])) |
| 184 | 184 | { |
| 185 | - $record['cat_id'] = implode(',',$this->bocontacts->find_or_add_categories($record['cat_id'], -1)); |
|
| 185 | + $record['cat_id'] = implode(',', $this->bocontacts->find_or_add_categories($record['cat_id'], -1)); |
|
| 186 | 186 | } |
| 187 | 187 | return $record; |
| 188 | 188 | } |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | * @param array $_data contact data for the action |
| 195 | 195 | * @return bool success or not |
| 196 | 196 | */ |
| 197 | - private function action ( $_action, $_data, $record_num = 0 ) { |
|
| 197 | + private function action($_action, $_data, $record_num = 0) { |
|
| 198 | 198 | switch ($_action) { |
| 199 | 199 | case 'none' : |
| 200 | 200 | return true; |
@@ -202,17 +202,17 @@ discard block |
||
| 202 | 202 | // Only update if there are changes |
| 203 | 203 | $old = $this->bocontacts->read($_data['id']); |
| 204 | 204 | // if we get countrycodes as countryname, try to translate them -> the rest should be handled by bo classes. |
| 205 | - foreach(array('adr_one_', 'adr_two_') as $c_prefix) |
|
| 205 | + foreach (array('adr_one_', 'adr_two_') as $c_prefix) |
|
| 206 | 206 | { |
| 207 | - if (strlen(trim($_data[$c_prefix.'countryname']))==2) |
|
| 207 | + if (strlen(trim($_data[$c_prefix.'countryname'])) == 2) |
|
| 208 | 208 | { |
| 209 | 209 | $_data[$c_prefix.'countryname'] = Api\Country::get_full_name(trim($_data[$c_prefix.'countryname']), true); |
| 210 | 210 | } |
| 211 | 211 | } |
| 212 | 212 | // Don't change a user account into a contact |
| 213 | - if($old['owner'] == 0) { |
|
| 213 | + if ($old['owner'] == 0) { |
|
| 214 | 214 | unset($_data['owner']); |
| 215 | - } elseif(!$this->definition->plugin_options['change_owner']) { |
|
| 215 | + } elseif (!$this->definition->plugin_options['change_owner']) { |
|
| 216 | 216 | // Don't change addressbook of an existing contact |
| 217 | 217 | unset($_data['owner']); |
| 218 | 218 | } |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | // Merge to deal with fields not in import record |
| 221 | 221 | $_data = array_merge($old, $_data); |
| 222 | 222 | $changed = $this->tracking->changed_fields($_data, $old); |
| 223 | - if(count($changed) == 0) { |
|
| 223 | + if (count($changed) == 0) { |
|
| 224 | 224 | return true; |
| 225 | 225 | } else { |
| 226 | 226 | //error_log(__METHOD__.__LINE__.array2string($changed).' Old:'.$old['adr_one_countryname'].' ('.$old['adr_one_countrycode'].') New:'.$_data['adr_one_countryname'].' ('.$_data['adr_one_countryname'].')'); |
@@ -231,22 +231,22 @@ discard block |
||
| 231 | 231 | |
| 232 | 232 | // Fall through |
| 233 | 233 | case 'insert' : |
| 234 | - if($_action == 'insert') { |
|
| 234 | + if ($_action == 'insert') { |
|
| 235 | 235 | // Addressbook backend doesn't like inserting with ID specified, it screws up the owner & etag |
| 236 | 236 | unset($_data['id']); |
| 237 | 237 | } |
| 238 | - if(!isset($_data['org_name'])) { |
|
| 238 | + if (!isset($_data['org_name'])) { |
|
| 239 | 239 | // org_name is a trigger to update n_fileas |
| 240 | 240 | $_data['org_name'] = ''; |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - if ( $this->dry_run ) { |
|
| 243 | + if ($this->dry_run) { |
|
| 244 | 244 | //print_r($_data); |
| 245 | 245 | $this->results[$_action]++; |
| 246 | 246 | return true; |
| 247 | 247 | } else { |
| 248 | - $result = $this->bocontacts->save( $_data, $this->is_admin); |
|
| 249 | - if(!$result) { |
|
| 248 | + $result = $this->bocontacts->save($_data, $this->is_admin); |
|
| 249 | + if (!$result) { |
|
| 250 | 250 | $this->errors[$record_num] = $this->bocontacts->error; |
| 251 | 251 | } else { |
| 252 | 252 | $this->results[$_action]++; |
@@ -254,14 +254,14 @@ discard block |
||
| 254 | 254 | return $result; |
| 255 | 255 | } |
| 256 | 256 | default: |
| 257 | - throw new Api\Exception('Unsupported action: '. $_action); |
|
| 257 | + throw new Api\Exception('Unsupported action: '.$_action); |
|
| 258 | 258 | |
| 259 | 259 | } |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - public function preview( $_stream, importexport_definition $_definition ) |
|
| 262 | + public function preview($_stream, importexport_definition $_definition) |
|
| 263 | 263 | { |
| 264 | - $rows = array('h1'=>array(),'f1'=>array(),'.h1'=>'class=th'); |
|
| 264 | + $rows = array('h1'=>array(), 'f1'=>array(), '.h1'=>'class=th'); |
|
| 265 | 265 | |
| 266 | 266 | // Set this so plugin doesn't do any data changes |
| 267 | 267 | $_definition->plugin_options = (array)$_definition->plugin_options + array('dry_run' => true); |
@@ -274,18 +274,18 @@ discard block |
||
| 274 | 274 | |
| 275 | 275 | $record_class = get_class($this->preview_records[0]); |
| 276 | 276 | |
| 277 | - foreach($this->preview_records as $record) |
|
| 277 | + foreach ($this->preview_records as $record) |
|
| 278 | 278 | { |
| 279 | 279 | // Convert to human-friendly |
| 280 | - importexport_export_csv::convert($record,$record_class::$types,$_definition->application); |
|
| 280 | + importexport_export_csv::convert($record, $record_class::$types, $_definition->application); |
|
| 281 | 281 | $record = $record->get_record_array(); |
| 282 | 282 | $row = array(); |
| 283 | - foreach(array_keys($labels) as $field) |
|
| 283 | + foreach (array_keys($labels) as $field) |
|
| 284 | 284 | { |
| 285 | 285 | $row[$field] = $record[$field]; |
| 286 | 286 | |
| 287 | 287 | // Don't scare users, do something with jpeg |
| 288 | - if($field == 'jpegphoto' && $row[$field]) |
|
| 288 | + if ($field == 'jpegphoto' && $row[$field]) |
|
| 289 | 289 | { |
| 290 | 290 | $row[$field] = '<img style="max-width:50px;max-height:50px;" src="data:image/jpeg;base64,'.$row[$field].'"/>'; |
| 291 | 291 | } |
@@ -15,7 +15,8 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * Plugin to import vCard files |
| 17 | 17 | */ |
| 18 | -class addressbook_import_vcard implements importexport_iface_import_plugin { |
|
| 18 | +class addressbook_import_vcard implements importexport_iface_import_plugin |
|
| 19 | +{ |
|
| 19 | 20 | |
| 20 | 21 | private static $plugin_options = array( |
| 21 | 22 | |
@@ -86,7 +87,8 @@ discard block |
||
| 86 | 87 | * @param string $_charset |
| 87 | 88 | * @param definition $_definition |
| 88 | 89 | */ |
| 89 | - public function import( $_stream, importexport_definition $_definition ) { |
|
| 90 | + public function import( $_stream, importexport_definition $_definition ) |
|
| 91 | + { |
|
| 90 | 92 | $this->definition = $_definition; |
| 91 | 93 | |
| 92 | 94 | // user, is admin ? |
@@ -112,7 +114,10 @@ discard block |
||
| 112 | 114 | $this->bocontacts = new addressbook_vcal(); |
| 113 | 115 | |
| 114 | 116 | $charset = $_definition->plugin_options['charset']; |
| 115 | - if($charset == 'user') $charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset']; |
|
| 117 | + if($charset == 'user') |
|
| 118 | + { |
|
| 119 | + $charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset']; |
|
| 120 | + } |
|
| 116 | 121 | |
| 117 | 122 | // Start counting successes |
| 118 | 123 | $this->current = 0; |
@@ -130,7 +135,8 @@ discard block |
||
| 130 | 135 | $contact_owner |
| 131 | 136 | )); |
| 132 | 137 | $contacts->next(); |
| 133 | - while($contacts->valid()) { |
|
| 138 | + while($contacts->valid()) |
|
| 139 | + { |
|
| 134 | 140 | $this->current++; |
| 135 | 141 | $contact = $contacts->current(); |
| 136 | 142 | |
@@ -142,7 +148,10 @@ discard block |
||
| 142 | 148 | $egw_record = new addressbook_egw_record(); |
| 143 | 149 | $egw_record->set_record($contact); |
| 144 | 150 | $this->preview_records[] = $egw_record; |
| 145 | - if($count >= $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']) break; |
|
| 151 | + if($count >= $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']) |
|
| 152 | + { |
|
| 153 | + break; |
|
| 154 | + } |
|
| 146 | 155 | } |
| 147 | 156 | |
| 148 | 157 | $count++; |
@@ -158,7 +167,10 @@ discard block |
||
| 158 | 167 | public function _vcard($_vcard, $owner) |
| 159 | 168 | { |
| 160 | 169 | $charset = $this->definition->plugin_options['charset']; |
| 161 | - if($charset == 'user') $charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset']; |
|
| 170 | + if($charset == 'user') |
|
| 171 | + { |
|
| 172 | + $charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset']; |
|
| 173 | + } |
|
| 162 | 174 | $record = $this->bocontacts->vcardtoegw($_vcard,$charset); |
| 163 | 175 | |
| 164 | 176 | $record['owner'] = $owner; |
@@ -194,8 +206,10 @@ discard block |
||
| 194 | 206 | * @param array $_data contact data for the action |
| 195 | 207 | * @return bool success or not |
| 196 | 208 | */ |
| 197 | - private function action ( $_action, $_data, $record_num = 0 ) { |
|
| 198 | - switch ($_action) { |
|
| 209 | + private function action ( $_action, $_data, $record_num = 0 ) |
|
| 210 | + { |
|
| 211 | + switch ($_action) |
|
| 212 | + { |
|
| 199 | 213 | case 'none' : |
| 200 | 214 | return true; |
| 201 | 215 | case 'update' : |
@@ -210,9 +224,12 @@ discard block |
||
| 210 | 224 | } |
| 211 | 225 | } |
| 212 | 226 | // Don't change a user account into a contact |
| 213 | - if($old['owner'] == 0) { |
|
| 227 | + if($old['owner'] == 0) |
|
| 228 | + { |
|
| 214 | 229 | unset($_data['owner']); |
| 215 | - } elseif(!$this->definition->plugin_options['change_owner']) { |
|
| 230 | + } |
|
| 231 | + elseif(!$this->definition->plugin_options['change_owner']) |
|
| 232 | + { |
|
| 216 | 233 | // Don't change addressbook of an existing contact |
| 217 | 234 | unset($_data['owner']); |
| 218 | 235 | } |
@@ -220,9 +237,12 @@ discard block |
||
| 220 | 237 | // Merge to deal with fields not in import record |
| 221 | 238 | $_data = array_merge($old, $_data); |
| 222 | 239 | $changed = $this->tracking->changed_fields($_data, $old); |
| 223 | - if(count($changed) == 0) { |
|
| 240 | + if(count($changed) == 0) |
|
| 241 | + { |
|
| 224 | 242 | return true; |
| 225 | - } else { |
|
| 243 | + } |
|
| 244 | + else |
|
| 245 | + { |
|
| 226 | 246 | //error_log(__METHOD__.__LINE__.array2string($changed).' Old:'.$old['adr_one_countryname'].' ('.$old['adr_one_countrycode'].') New:'.$_data['adr_one_countryname'].' ('.$_data['adr_one_countryname'].')'); |
| 227 | 247 | } |
| 228 | 248 | |
@@ -231,24 +251,32 @@ discard block |
||
| 231 | 251 | |
| 232 | 252 | // Fall through |
| 233 | 253 | case 'insert' : |
| 234 | - if($_action == 'insert') { |
|
| 254 | + if($_action == 'insert') |
|
| 255 | + { |
|
| 235 | 256 | // Addressbook backend doesn't like inserting with ID specified, it screws up the owner & etag |
| 236 | 257 | unset($_data['id']); |
| 237 | 258 | } |
| 238 | - if(!isset($_data['org_name'])) { |
|
| 259 | + if(!isset($_data['org_name'])) |
|
| 260 | + { |
|
| 239 | 261 | // org_name is a trigger to update n_fileas |
| 240 | 262 | $_data['org_name'] = ''; |
| 241 | 263 | } |
| 242 | 264 | |
| 243 | - if ( $this->dry_run ) { |
|
| 265 | + if ( $this->dry_run ) |
|
| 266 | + { |
|
| 244 | 267 | //print_r($_data); |
| 245 | 268 | $this->results[$_action]++; |
| 246 | 269 | return true; |
| 247 | - } else { |
|
| 270 | + } |
|
| 271 | + else |
|
| 272 | + { |
|
| 248 | 273 | $result = $this->bocontacts->save( $_data, $this->is_admin); |
| 249 | - if(!$result) { |
|
| 274 | + if(!$result) |
|
| 275 | + { |
|
| 250 | 276 | $this->errors[$record_num] = $this->bocontacts->error; |
| 251 | - } else { |
|
| 277 | + } |
|
| 278 | + else |
|
| 279 | + { |
|
| 252 | 280 | $this->results[$_action]++; |
| 253 | 281 | } |
| 254 | 282 | return $result; |
@@ -302,7 +330,8 @@ discard block |
||
| 302 | 330 | * |
| 303 | 331 | * @return string name |
| 304 | 332 | */ |
| 305 | - public static function get_name() { |
|
| 333 | + public static function get_name() |
|
| 334 | + { |
|
| 306 | 335 | return lang('Addressbook vCard import'); |
| 307 | 336 | } |
| 308 | 337 | |
@@ -311,7 +340,8 @@ discard block |
||
| 311 | 340 | * |
| 312 | 341 | * @return string descriprion |
| 313 | 342 | */ |
| 314 | - public static function get_description() { |
|
| 343 | + public static function get_description() |
|
| 344 | + { |
|
| 315 | 345 | return lang("Imports contacts into your Addressbook from a vCard File. "); |
| 316 | 346 | } |
| 317 | 347 | |
@@ -320,7 +350,8 @@ discard block |
||
| 320 | 350 | * |
| 321 | 351 | * @return string suffix (comma seperated) |
| 322 | 352 | */ |
| 323 | - public static function get_filesuffix() { |
|
| 353 | + public static function get_filesuffix() |
|
| 354 | + { |
|
| 324 | 355 | return 'vcf'; |
| 325 | 356 | } |
| 326 | 357 | |
@@ -336,7 +367,8 @@ discard block |
||
| 336 | 367 | * preserv => array, |
| 337 | 368 | * ) |
| 338 | 369 | */ |
| 339 | - public function get_options_etpl() { |
|
| 370 | + public function get_options_etpl() |
|
| 371 | + { |
|
| 340 | 372 | // lets do it! |
| 341 | 373 | } |
| 342 | 374 | |
@@ -345,7 +377,8 @@ discard block |
||
| 345 | 377 | * |
| 346 | 378 | * @return string etemplate name |
| 347 | 379 | */ |
| 348 | - public function get_selectors_etpl() { |
|
| 380 | + public function get_selectors_etpl() |
|
| 381 | + { |
|
| 349 | 382 | // lets do it! |
| 350 | 383 | } |
| 351 | 384 | |
@@ -357,7 +390,8 @@ discard block |
||
| 357 | 390 | * record_# => warning message |
| 358 | 391 | * ) |
| 359 | 392 | */ |
| 360 | - public function get_warnings() { |
|
| 393 | + public function get_warnings() |
|
| 394 | + { |
|
| 361 | 395 | return $this->warnings; |
| 362 | 396 | } |
| 363 | 397 | |
@@ -369,7 +403,8 @@ discard block |
||
| 369 | 403 | * record_# => error message |
| 370 | 404 | * ) |
| 371 | 405 | */ |
| 372 | - public function get_errors() { |
|
| 406 | + public function get_errors() |
|
| 407 | + { |
|
| 373 | 408 | return $this->errors; |
| 374 | 409 | } |
| 375 | 410 | |
@@ -381,7 +416,8 @@ discard block |
||
| 381 | 416 | * action => record count |
| 382 | 417 | * ) |
| 383 | 418 | */ |
| 384 | - public function get_results() { |
|
| 419 | + public function get_results() |
|
| 420 | + { |
|
| 385 | 421 | return $this->results; |
| 386 | 422 | } |
| 387 | 423 | } |
@@ -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) |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | use EGroupware\Api\Framework; |
| 16 | 16 | use EGroupware\Api\Vfs; |
| 17 | 17 | |
| 18 | -chdir(dirname(__FILE__)); // to enable our relative pathes to work |
|
| 18 | +chdir(dirname(__FILE__)); // to enable our relative pathes to work |
|
| 19 | 19 | |
| 20 | 20 | if (php_sapi_name() !== 'cli') // security precaution: forbit calling admin-cli as web-page |
| 21 | 21 | { |
@@ -33,17 +33,17 @@ discard block |
||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | // allow to specify instance by using a username with appended @domain-name |
| 36 | -$arg0s = explode(',',@array_shift($arguments)); |
|
| 37 | -@list($user,$domain) = explode('@',$arg0s[0].'@'); |
|
| 38 | -load_egw($user,$arg0s[1],$domain); |
|
| 36 | +$arg0s = explode(',', @array_shift($arguments)); |
|
| 37 | +@list($user, $domain) = explode('@', $arg0s[0].'@'); |
|
| 38 | +load_egw($user, $arg0s[1], $domain); |
|
| 39 | 39 | |
| 40 | -switch($action) |
|
| 40 | +switch ($action) |
|
| 41 | 41 | { |
| 42 | 42 | case '--edit-user': |
| 43 | 43 | return do_edit_user($arg0s); |
| 44 | 44 | |
| 45 | 45 | case '--add-user': // like --edit-account, but always runs addaccount hook |
| 46 | - return do_edit_user($arg0s,true); |
|
| 46 | + return do_edit_user($arg0s, true); |
|
| 47 | 47 | |
| 48 | 48 | case '--edit-alias': |
| 49 | 49 | case '--edit-forward': |
@@ -54,17 +54,17 @@ discard block |
||
| 54 | 54 | return do_change_pw($arg0s); |
| 55 | 55 | |
| 56 | 56 | case '--delete-user': |
| 57 | - return do_delete_account($arg0s[2],$arg0s[3]); |
|
| 57 | + return do_delete_account($arg0s[2], $arg0s[3]); |
|
| 58 | 58 | |
| 59 | 59 | case '--edit-group': |
| 60 | 60 | return do_edit_group($arg0s); |
| 61 | 61 | |
| 62 | 62 | case '--delete-group': |
| 63 | - return do_delete_account($arg0s[2],0,false); |
|
| 63 | + return do_delete_account($arg0s[2], 0, false); |
|
| 64 | 64 | |
| 65 | 65 | case '--allow-app': |
| 66 | 66 | case '--deny-app': |
| 67 | - return do_account_app($arg0s,$action == '--allow-app'); |
|
| 67 | + return do_account_app($arg0s, $action == '--allow-app'); |
|
| 68 | 68 | |
| 69 | 69 | case '--change-account-id': |
| 70 | 70 | return do_change_account_id($arg0s); |
@@ -84,21 +84,21 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | default: |
| 86 | 86 | // we allow to call admin_cmd classes directly, if they define the constant SETUP_CLI_CALLABLE |
| 87 | - if (substr($action,0,2) == '--' && class_exists($class = str_replace('-','_',substr($action,2))) && |
|
| 88 | - is_subclass_of($class,'admin_cmd') && @constant($class.'::SETUP_CLI_CALLABLE')) |
|
| 87 | + if (substr($action, 0, 2) == '--' && class_exists($class = str_replace('-', '_', substr($action, 2))) && |
|
| 88 | + is_subclass_of($class, 'admin_cmd') && @constant($class.'::SETUP_CLI_CALLABLE')) |
|
| 89 | 89 | { |
| 90 | 90 | $args = array(); |
| 91 | - $args['domain'] = array_shift($arg0s); // domain must be first argument, to ensure right domain get's selected in header-include |
|
| 92 | - foreach($arg0s as $arg) |
|
| 91 | + $args['domain'] = array_shift($arg0s); // domain must be first argument, to ensure right domain get's selected in header-include |
|
| 92 | + foreach ($arg0s as $arg) |
|
| 93 | 93 | { |
| 94 | - list($name,$value) = explode('=',$arg,2); |
|
| 95 | - if(property_exists('admin_cmd',$name)) // dont allow to overwrite admin_cmd properties |
|
| 94 | + list($name, $value) = explode('=', $arg, 2); |
|
| 95 | + if (property_exists('admin_cmd', $name)) // dont allow to overwrite admin_cmd properties |
|
| 96 | 96 | { |
| 97 | - throw new Api\Exception\WrongUserinput(lang("Invalid argument '%1' !!!",$arg),90); |
|
| 97 | + throw new Api\Exception\WrongUserinput(lang("Invalid argument '%1' !!!", $arg), 90); |
|
| 98 | 98 | } |
| 99 | - if (substr($name,-1) == ']') // allow 1-dim. arrays |
|
| 99 | + if (substr($name, -1) == ']') // allow 1-dim. arrays |
|
| 100 | 100 | { |
| 101 | - list($name,$sub) = explode('[',substr($name,0,-1),2); |
|
| 101 | + list($name, $sub) = explode('[', substr($name, 0, -1), 2); |
|
| 102 | 102 | $args[$name][$sub] = $value; |
| 103 | 103 | } |
| 104 | 104 | else |
@@ -122,12 +122,12 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | function run_command(admin_cmd $cmd) |
| 124 | 124 | { |
| 125 | - global $arguments,$user,$arg0s,$domain; |
|
| 125 | + global $arguments, $user, $arg0s, $domain; |
|
| 126 | 126 | |
| 127 | 127 | $skip_checks = false; |
| 128 | 128 | while ($arguments && ($extra = array_shift($arguments))) |
| 129 | 129 | { |
| 130 | - switch($extra) |
|
| 130 | + switch ($extra) |
|
| 131 | 131 | { |
| 132 | 132 | case '--schedule': // schedule the command instead of running it directly |
| 133 | 133 | $time = admin_cmd::parse_date(array_shift($arguments)); |
@@ -157,15 +157,15 @@ discard block |
||
| 157 | 157 | case '--header-access': |
| 158 | 158 | if ($cmd instanceof setup_cmd) |
| 159 | 159 | { |
| 160 | - list($user,$pw) = explode(',',array_shift($arguments),2); |
|
| 161 | - $cmd->set_header_secret($user,$pw); |
|
| 160 | + list($user, $pw) = explode(',', array_shift($arguments), 2); |
|
| 161 | + $cmd->set_header_secret($user, $pw); |
|
| 162 | 162 | } |
| 163 | 163 | break; |
| 164 | 164 | |
| 165 | 165 | default: |
| 166 | 166 | //fail(99,lang('Unknown option %1',$extra); |
| 167 | - echo lang('Unknown option %1',$extra)."\n\n"; |
|
| 168 | - usage('',99); |
|
| 167 | + echo lang('Unknown option %1', $extra)."\n\n"; |
|
| 168 | + usage('', 99); |
|
| 169 | 169 | break; |
| 170 | 170 | } |
| 171 | 171 | } |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | { |
| 185 | 185 | $url = $GLOBALS['egw_info']['server']['webserver_url'].'/json.php?menuaction=admin.admin_hooks.ajax_clear_cache'; |
| 186 | 186 | if ($url[0] == '/') $url = 'http://'.(!empty($domain) && $domain != 'default' ? $domain : 'localhost').$url; |
| 187 | - $data = file_get_contents($url, false, Framework::proxy_context($user,$arg0s[1])); |
|
| 187 | + $data = file_get_contents($url, false, Framework::proxy_context($user, $arg0s[1])); |
|
| 188 | 188 | error_log("file_get_contents('$url') returned ".array2string($data)); |
| 189 | 189 | if ($data && strpos($data, '"success"') !== false) |
| 190 | 190 | { |
@@ -223,13 +223,13 @@ discard block |
||
| 223 | 223 | { |
| 224 | 224 | //fail(1,lang("Wrong admin-account or -password !!!")); |
| 225 | 225 | echo lang("Wrong admin-account or -password !!!")."\n\n"; |
| 226 | - usage('',1); |
|
| 226 | + usage('', 1); |
|
| 227 | 227 | } |
| 228 | 228 | if (!$GLOBALS['egw_info']['user']['apps']['admin']) // will be tested by the header too, but whould give html error-message |
| 229 | 229 | { |
| 230 | 230 | //fail(2,lang("Permission denied !!!")); |
| 231 | 231 | echo lang("Permission denied !!!")."\n\n"; |
| 232 | - usage('',2); |
|
| 232 | + usage('', 2); |
|
| 233 | 233 | } |
| 234 | 234 | return $sessionid; |
| 235 | 235 | } |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | * @param string $passwd |
| 242 | 242 | * @param string $domain |
| 243 | 243 | */ |
| 244 | -function load_egw($user,$passwd,$domain='default') |
|
| 244 | +function load_egw($user, $passwd, $domain = 'default') |
|
| 245 | 245 | { |
| 246 | 246 | //echo "load_egw($user,$passwd,$domain)\n"; |
| 247 | 247 | $_REQUEST['domain'] = $domain; |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | |
| 254 | 254 | if (ini_get('session.save_handler') == 'files' && !is_writable(ini_get('session.save_path')) && is_dir('/tmp') && is_writable('/tmp')) |
| 255 | 255 | { |
| 256 | - ini_set('session.save_path','/tmp'); // regular users may have no rights to apache's session dir |
|
| 256 | + ini_set('session.save_path', '/tmp'); // regular users may have no rights to apache's session dir |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | $GLOBALS['egw_info'] = array( |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | ) |
| 266 | 266 | ); |
| 267 | 267 | |
| 268 | - if (substr($user,0,5) != 'root_') |
|
| 268 | + if (substr($user, 0, 5) != 'root_') |
|
| 269 | 269 | { |
| 270 | 270 | include('../header.inc.php'); |
| 271 | 271 | } |
@@ -275,9 +275,9 @@ discard block |
||
| 275 | 275 | include('../header.inc.php'); |
| 276 | 276 | |
| 277 | 277 | if ($user == 'root_'.$GLOBALS['egw_info']['server']['header_admin_user'] && |
| 278 | - _check_pw($GLOBALS['egw_info']['server']['header_admin_password'],$passwd) || |
|
| 278 | + _check_pw($GLOBALS['egw_info']['server']['header_admin_password'], $passwd) || |
|
| 279 | 279 | $user == 'root_'.$GLOBALS['egw_domain'][$_GET['domain']]['config_user'] && |
| 280 | - _check_pw($GLOBALS['egw_domain'][$_GET['domain']]['config_passwd'],$passwd)) |
|
| 280 | + _check_pw($GLOBALS['egw_domain'][$_GET['domain']]['config_passwd'], $passwd)) |
|
| 281 | 281 | { |
| 282 | 282 | echo "\nRoot access granted!\n"; |
| 283 | 283 | Vfs::$is_root = true; |
@@ -296,10 +296,10 @@ discard block |
||
| 296 | 296 | * @param string $pw |
| 297 | 297 | * @return boolean |
| 298 | 298 | */ |
| 299 | -function _check_pw($hash_or_cleartext,$pw) |
|
| 299 | +function _check_pw($hash_or_cleartext, $pw) |
|
| 300 | 300 | { |
| 301 | 301 | //echo "_check_pw($hash_or_cleartext,$pw) md5=".md5($pw)."\n"; |
| 302 | - if (preg_match('/^[0-9a-f]{32}$/',$hash_or_cleartext)) |
|
| 302 | + if (preg_match('/^[0-9a-f]{32}$/', $hash_or_cleartext)) |
|
| 303 | 303 | { |
| 304 | 304 | return $hash_or_cleartext == md5($pw); |
| 305 | 305 | } |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | * @param string $action =null |
| 313 | 313 | * @param int $ret =0 exit-code |
| 314 | 314 | */ |
| 315 | -function usage($action=null,$ret=0) |
|
| 315 | +function usage($action = null, $ret = 0) |
|
| 316 | 316 | { |
| 317 | 317 | unset($action); |
| 318 | 318 | $cmd = basename($_SERVER['argv'][0]); |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | function do_edit_mail($type, array $arg0s) |
| 366 | 366 | { |
| 367 | 367 | array_shift($arg0s); // admin-account |
| 368 | - array_shift($arg0s); // admin-pw |
|
| 368 | + array_shift($arg0s); // admin-pw |
|
| 369 | 369 | list($account, $acc_id) = explode('=', array_shift($arg0s)); |
| 370 | 370 | $account_id = is_numeric($account) ? (int)$account : $GLOBALS['egw']->accounts->name2id($account); |
| 371 | 371 | if (!$GLOBALS['egw']->accounts->exists($account_id) && !($account_id = $GLOBALS['egw']->accounts->name2id($account))) |
@@ -374,18 +374,17 @@ discard block |
||
| 374 | 374 | exit(1); |
| 375 | 375 | } |
| 376 | 376 | $found = 0; |
| 377 | - foreach($acc_id ? array(Api\Mail\Account::read($acc_id, $account_id)) : |
|
| 378 | - Api\Mail\Account::search($account_id, false) as $account) |
|
| 377 | + foreach ($acc_id ? array(Api\Mail\Account::read($acc_id, $account_id)) : Api\Mail\Account::search($account_id, false) as $account) |
|
| 379 | 378 | { |
| 380 | - if (!isset($acc_id) && !Api\Mail\Account::is_multiple($account)) continue; // no need to waste time on personal accounts |
|
| 379 | + if (!isset($acc_id) && !Api\Mail\Account::is_multiple($account)) continue; // no need to waste time on personal accounts |
|
| 381 | 380 | |
| 382 | 381 | $args = $arg0s; |
| 383 | 382 | try { |
| 384 | 383 | if (!($data = $account->getUserData($account_id))) |
| 385 | 384 | { |
| 386 | - continue; // not a managed mail-server |
|
| 385 | + continue; // not a managed mail-server |
|
| 387 | 386 | } |
| 388 | - switch($type) |
|
| 387 | + switch ($type) |
|
| 389 | 388 | { |
| 390 | 389 | case 'alias': |
| 391 | 390 | $create_identity = strtolower(array_shift($args)) === 'yes'; |
@@ -408,7 +407,7 @@ discard block |
||
| 408 | 407 | if ($type == 'alias' && $create_identity && $args) |
| 409 | 408 | { |
| 410 | 409 | // check if user allready has an identity created for given aliases |
| 411 | - foreach(Api\Mail\Account::identities($account, false, 'ident_email', $account_id) as $ident_id => $email) |
|
| 410 | + foreach (Api\Mail\Account::identities($account, false, 'ident_email', $account_id) as $ident_id => $email) |
|
| 412 | 411 | { |
| 413 | 412 | if (($key = array_search($email, $args)) !== false) |
| 414 | 413 | { |
@@ -421,19 +420,19 @@ discard block |
||
| 421 | 420 | } |
| 422 | 421 | } |
| 423 | 422 | // create not existing identities by copying standard identity plus alias as email |
| 424 | - foreach($args as $email) |
|
| 423 | + foreach ($args as $email) |
|
| 425 | 424 | { |
| 426 | 425 | $identity = $account->params; |
| 427 | 426 | unset($identity['ident_id']); |
| 428 | 427 | unset($identity['ident_name']); |
| 429 | 428 | $identity['ident_email'] = $email; |
| 430 | - $identity['account_id'] = $account_id; // make this a personal identity for $account_id |
|
| 429 | + $identity['account_id'] = $account_id; // make this a personal identity for $account_id |
|
| 431 | 430 | Api\Mail\Account::save_identity($identity); |
| 432 | 431 | } |
| 433 | 432 | if ($args) echo "Identity(s) for ".implode(', ', $args)." created.\n"; |
| 434 | 433 | } |
| 435 | 434 | } |
| 436 | - catch(\Exception $e) { |
|
| 435 | + catch (\Exception $e) { |
|
| 437 | 436 | _egw_log_exception($e); |
| 438 | 437 | echo $e->getMessage()."\n"; |
| 439 | 438 | } |
@@ -458,7 +457,7 @@ discard block |
||
| 458 | 457 | { |
| 459 | 458 | if (!is_array($arr)) $arr = array(); |
| 460 | 459 | |
| 461 | - switch($mod[0][0]) |
|
| 460 | + switch ($mod[0][0]) |
|
| 462 | 461 | { |
| 463 | 462 | case '-': |
| 464 | 463 | $mod[0] = substr($mod[0], 1); |
@@ -483,14 +482,14 @@ discard block |
||
| 483 | 482 | * @param boolean $allow true=allow, false=deny |
| 484 | 483 | * @return int 0 on success |
| 485 | 484 | */ |
| 486 | -function do_account_app($args,$allow) |
|
| 485 | +function do_account_app($args, $allow) |
|
| 487 | 486 | { |
| 488 | - array_shift($args); // admin-account |
|
| 489 | - array_shift($args); // admin-pw |
|
| 487 | + array_shift($args); // admin-account |
|
| 488 | + array_shift($args); // admin-pw |
|
| 490 | 489 | $account = array_shift($args); |
| 491 | 490 | |
| 492 | 491 | include_once(EGW_INCLUDE_ROOT.'/admin/inc/class.admin_cmd_account_app.inc.php'); |
| 493 | - run_command(new admin_cmd_account_app($allow,$account,$args)); |
|
| 492 | + run_command(new admin_cmd_account_app($allow, $account, $args)); |
|
| 494 | 493 | } |
| 495 | 494 | |
| 496 | 495 | /** |
@@ -500,9 +499,9 @@ discard block |
||
| 500 | 499 | */ |
| 501 | 500 | function do_edit_group($args) |
| 502 | 501 | { |
| 503 | - array_shift($args); // admin-account |
|
| 504 | - array_shift($args); // admin-pw |
|
| 505 | - list($account,$new_account_name) = explode('=',array_shift($args)); // account[=new-account-name] |
|
| 502 | + array_shift($args); // admin-account |
|
| 503 | + array_shift($args); // admin-pw |
|
| 504 | + list($account, $new_account_name) = explode('=', array_shift($args)); // account[=new-account-name] |
|
| 506 | 505 | |
| 507 | 506 | $data = array( |
| 508 | 507 | 'account_lid' => $new_account_name, |
@@ -510,19 +509,19 @@ discard block |
||
| 510 | 509 | 'account_members' => $args, |
| 511 | 510 | ); |
| 512 | 511 | try { |
| 513 | - admin_cmd::parse_account($account,false); |
|
| 512 | + admin_cmd::parse_account($account, false); |
|
| 514 | 513 | |
| 515 | - foreach($data as &$value) // existing account --> empty values mean dont change, not set them empty! |
|
| 514 | + foreach ($data as &$value) // existing account --> empty values mean dont change, not set them empty! |
|
| 516 | 515 | { |
| 517 | 516 | if ((string)$value === '') $value = null; |
| 518 | 517 | } |
| 519 | 518 | } |
| 520 | 519 | catch (Exception $e) { // new group |
| 521 | - unset($e); // not used |
|
| 520 | + unset($e); // not used |
|
| 522 | 521 | $data['account_lid'] = $account; |
| 523 | 522 | $account = false; |
| 524 | 523 | } |
| 525 | - run_command(new admin_cmd_edit_group($account,$data)); |
|
| 524 | + run_command(new admin_cmd_edit_group($account, $data)); |
|
| 526 | 525 | } |
| 527 | 526 | |
| 528 | 527 | /** |
@@ -532,12 +531,12 @@ discard block |
||
| 532 | 531 | */ |
| 533 | 532 | function do_change_pw($args) |
| 534 | 533 | { |
| 535 | - array_shift($args); // admin-account |
|
| 536 | - array_shift($args); // admin-pw |
|
| 537 | - $account = array_shift($args); // account |
|
| 538 | - $password = array_shift($args); // pw |
|
| 534 | + array_shift($args); // admin-account |
|
| 535 | + array_shift($args); // admin-pw |
|
| 536 | + $account = array_shift($args); // account |
|
| 537 | + $password = array_shift($args); // pw |
|
| 539 | 538 | |
| 540 | - run_command(new admin_cmd_change_pw($account,$password)); |
|
| 539 | + run_command(new admin_cmd_change_pw($account, $password)); |
|
| 541 | 540 | } |
| 542 | 541 | |
| 543 | 542 | /** |
@@ -546,18 +545,18 @@ discard block |
||
| 546 | 545 | * @param array $args admin-account[@domain],admin-password,account[=new-account-name],first-name,last-name,password,email,expires{never(default)|YYYY-MM-DD|already},can-change-pw{true(default)|false},anon-user{true|false(default)},primary-group{Default(default)|...}[,groups,...][,homedirectory,loginshell] |
| 547 | 546 | * @param boolean $run_addaccount_hook =null default run hook depending on account existence, true=allways run addaccount hook |
| 548 | 547 | */ |
| 549 | -function do_edit_user($args,$run_addaccount_hook=null) |
|
| 548 | +function do_edit_user($args, $run_addaccount_hook = null) |
|
| 550 | 549 | { |
| 551 | - array_shift($args); // admin-account |
|
| 552 | - array_shift($args); // admin-pw |
|
| 553 | - list($account,$new_account_name) = explode('=',array_shift($args)); // account[=new-account-name] |
|
| 550 | + array_shift($args); // admin-account |
|
| 551 | + array_shift($args); // admin-pw |
|
| 552 | + list($account, $new_account_name) = explode('=', array_shift($args)); // account[=new-account-name] |
|
| 554 | 553 | |
| 555 | 554 | $data = array(); |
| 556 | 555 | // do we need to support ldap only attributes: homedirectory and loginshell |
| 557 | 556 | if (($GLOBALS['egw_info']['server']['account_repository'] == 'ldap' || |
| 558 | 557 | empty($GLOBALS['egw_info']['server']['account_repository']) && $GLOBALS['egw_info']['server']['auth_type'] == 'ldap') && |
| 559 | - $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 |
|
| 558 | + $GLOBALS['egw_info']['server']['ldap_extra_attributes'] && count($args) > 9 && // 9 = primary group |
|
| 559 | + ($last_arg = array_pop($dummy = $args)) && $last_arg[0] == '/') // last argument start with a slash |
|
| 561 | 560 | { |
| 562 | 561 | $data['loginshell'] = array_pop($args); |
| 563 | 562 | $data['homedirectory'] = array_pop($args); |
@@ -575,19 +574,19 @@ discard block |
||
| 575 | 574 | 'account_groups' => $args, |
| 576 | 575 | ); |
| 577 | 576 | try { |
| 578 | - admin_cmd::parse_account($account,true); |
|
| 577 | + admin_cmd::parse_account($account, true); |
|
| 579 | 578 | |
| 580 | - foreach($data as &$value) // existing account --> empty values mean dont change, not set them empty! |
|
| 579 | + foreach ($data as &$value) // existing account --> empty values mean dont change, not set them empty! |
|
| 581 | 580 | { |
| 582 | 581 | if ((string)$value === '') $value = null; |
| 583 | 582 | } |
| 584 | 583 | } |
| 585 | 584 | catch (Exception $e) { // new account |
| 586 | - unset($e); // not used |
|
| 585 | + unset($e); // not used |
|
| 587 | 586 | $data['account_lid'] = $account; |
| 588 | 587 | $account = false; |
| 589 | 588 | } |
| 590 | - run_command(new admin_cmd_edit_user($account,$data,null,$run_addaccount_hook)); |
|
| 589 | + run_command(new admin_cmd_edit_user($account, $data, null, $run_addaccount_hook)); |
|
| 591 | 590 | } |
| 592 | 591 | |
| 593 | 592 | /** |
@@ -598,9 +597,9 @@ discard block |
||
| 598 | 597 | * @param boolean $is_user =true are we called for a user or group |
| 599 | 598 | * @return int 0 on success, 2-4 otherwise (see source) |
| 600 | 599 | */ |
| 601 | -function do_delete_account($account,$new_user=0,$is_user=true) |
|
| 600 | +function do_delete_account($account, $new_user = 0, $is_user = true) |
|
| 602 | 601 | { |
| 603 | - run_command(new admin_cmd_delete_account($account,$new_user,$is_user)); |
|
| 602 | + run_command(new admin_cmd_delete_account($account, $new_user, $is_user)); |
|
| 604 | 603 | } |
| 605 | 604 | |
| 606 | 605 | /** |
@@ -621,13 +620,13 @@ discard block |
||
| 621 | 620 | */ |
| 622 | 621 | function do_change_account_id($args) |
| 623 | 622 | { |
| 624 | - if (count($args) < 4) usage(); // 4 means at least user,pw,from1,to1 |
|
| 623 | + if (count($args) < 4) usage(); // 4 means at least user,pw,from1,to1 |
|
| 625 | 624 | |
| 626 | 625 | $ids2change = array(); |
| 627 | - for($n = 2; $n < count($args); $n += 2) |
|
| 626 | + for ($n = 2; $n < count($args); $n += 2) |
|
| 628 | 627 | { |
| 629 | 628 | $from = (int)$args[$n]; |
| 630 | - $to = (int)$args[$n+1]; |
|
| 629 | + $to = (int)$args[$n + 1]; |
|
| 631 | 630 | $ids2change[$from] = $to; |
| 632 | 631 | } |
| 633 | 632 | run_command(new admin_cmd_change_account_id($ids2change)); |
@@ -643,22 +642,22 @@ discard block |
||
| 643 | 642 | */ |
| 644 | 643 | function list_exit_codes() |
| 645 | 644 | { |
| 646 | - error_reporting(error_reporting() & ~E_NOTICE); |
|
| 645 | + error_reporting(error_reporting()&~E_NOTICE); |
|
| 647 | 646 | |
| 648 | 647 | $codes = array('Ok'); |
| 649 | - foreach(file(__FILE__) as $line) |
|
| 648 | + foreach (file(__FILE__) as $line) |
|
| 650 | 649 | { |
| 651 | 650 | $matches = null; |
| 652 | - if (preg_match('/fail\(([0-9]+),(.*)\);/',$line,$matches)) |
|
| 651 | + if (preg_match('/fail\(([0-9]+),(.*)\);/', $line, $matches)) |
|
| 653 | 652 | { |
| 654 | 653 | //echo "Line $n: $matches[1]: $matches[2]\n"; |
| 655 | 654 | @eval('$codes['.$matches[1].'] = '.$matches[2].';'); |
| 656 | 655 | } |
| 657 | 656 | } |
| 658 | - ksort($codes,SORT_NUMERIC); |
|
| 659 | - foreach($codes as $num => $msg) |
|
| 657 | + ksort($codes, SORT_NUMERIC); |
|
| 658 | + foreach ($codes as $num => $msg) |
|
| 660 | 659 | { |
| 661 | - echo $num."\t".str_replace("\n","\n\t",$msg)."\n"; |
|
| 660 | + echo $num."\t".str_replace("\n", "\n\t", $msg)."\n"; |
|
| 662 | 661 | } |
| 663 | 662 | } |
| 664 | 663 | |
@@ -668,7 +667,7 @@ discard block |
||
| 668 | 667 | * @param array $args admin-account[@domain],admin-password,accout_lid[,pw] |
| 669 | 668 | * @return int 0 on success |
| 670 | 669 | */ |
| 671 | -function do_subscribe_other($account_lid,$pw=null) |
|
| 670 | +function do_subscribe_other($account_lid, $pw = null) |
|
| 672 | 671 | { |
| 673 | 672 | unset($account_lid, $pw); |
| 674 | 673 | /* ToDo: this cant work, not even in 14.x |
@@ -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 | { |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | function __construct() |
| 52 | 52 | { |
| 53 | - $this->so = new Api\Storage\Base(self::APP,self::TABLE,null,'',true); |
|
| 53 | + $this->so = new Api\Storage\Base(self::APP, self::TABLE, null, '', true); |
|
| 54 | 54 | $this->so->timestamps = array('li', 'lo', 'session_dla', 'notification_heartbeat'); |
| 55 | 55 | } |
| 56 | 56 | |
@@ -63,19 +63,19 @@ discard block |
||
| 63 | 63 | * @param array &$readonlys eg. to disable buttons based on acl, not use here, maybe in a derived class |
| 64 | 64 | * @return int total number of rows |
| 65 | 65 | */ |
| 66 | - function get_rows($query,&$rows,&$readonlys) |
|
| 66 | + function get_rows($query, &$rows, &$readonlys) |
|
| 67 | 67 | { |
| 68 | 68 | $heartbeat_limit = Api\Session::heartbeat_limit(); |
| 69 | 69 | |
| 70 | 70 | if ($query['session_list']) // filter active sessions |
| 71 | 71 | { |
| 72 | - $query['col_filter']['lo'] = null; // not logged out |
|
| 72 | + $query['col_filter']['lo'] = null; // not logged out |
|
| 73 | 73 | $query['col_filter'][0] = 'session_dla > '.(int)(time() - $GLOBALS['egw_info']['server']['sessions_timeout']); |
| 74 | - switch((string)$query['session_list']) |
|
| 74 | + switch ((string)$query['session_list']) |
|
| 75 | 75 | { |
| 76 | 76 | case 'active': // remove status != 'active', eg. CalDAV/eSync |
| 77 | 77 | $query['col_filter'][1] = "notification_heartbeat > $heartbeat_limit"; |
| 78 | - $query['col_filter'][3] = "session_php NOT LIKE '% %'"; // remove blocked, bad login, etc |
|
| 78 | + $query['col_filter'][3] = "session_php NOT LIKE '% %'"; // remove blocked, bad login, etc |
|
| 79 | 79 | break; |
| 80 | 80 | default: |
| 81 | 81 | $query['col_filter'][1] = "(notification_heartbeat IS NULL OR notification_heartbeat > $heartbeat_limit)"; |
@@ -83,20 +83,20 @@ discard block |
||
| 83 | 83 | } |
| 84 | 84 | $query['col_filter'][2] = 'account_id>0'; |
| 85 | 85 | } |
| 86 | - $total = $this->so->get_rows($query,$rows,$readonlys); |
|
| 86 | + $total = $this->so->get_rows($query, $rows, $readonlys); |
|
| 87 | 87 | |
| 88 | 88 | $heartbeat_limit_user = Api\DateTime::server2user($heartbeat_limit, 'ts'); |
| 89 | 89 | |
| 90 | - foreach($rows as &$row) |
|
| 90 | + foreach ($rows as &$row) |
|
| 91 | 91 | { |
| 92 | 92 | $row['sessionstatus'] = 'success'; |
| 93 | 93 | if ($row['notification_heartbeat'] > $heartbeat_limit_user) |
| 94 | 94 | { |
| 95 | 95 | $row['sessionstatus'] = 'active'; |
| 96 | 96 | } |
| 97 | - if (stripos($row['session_php'],'blocked') !== false || |
|
| 98 | - stripos($row['session_php'],'bad login') !== false || |
|
| 99 | - strpos($row['session_php'],' ') !== false) |
|
| 97 | + if (stripos($row['session_php'], 'blocked') !== false || |
|
| 98 | + stripos($row['session_php'], 'bad login') !== false || |
|
| 99 | + strpos($row['session_php'], ' ') !== false) |
|
| 100 | 100 | { |
| 101 | 101 | $row['sessionstatus'] = $row['session_php']; |
| 102 | 102 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | $row['sessionstatus'] = 'logged out'; |
| 106 | 106 | } |
| 107 | 107 | // eg. for bad login or password |
| 108 | - if (!$row['account_id']) $row['alt_loginid'] = ($row['loginid']?$row['loginid']:lang('none')); |
|
| 108 | + if (!$row['account_id']) $row['alt_loginid'] = ($row['loginid'] ? $row['loginid'] : lang('none')); |
|
| 109 | 109 | |
| 110 | 110 | // do not allow to kill or select own session |
| 111 | 111 | if ($GLOBALS['egw']->session->sessionid_access_log == $row['sessionid'] && $query['session_list']) |
@@ -113,13 +113,13 @@ discard block |
||
| 113 | 113 | $row['class'] .= ' rowNoDelete '; |
| 114 | 114 | } |
| 115 | 115 | // do not allow to delete access log off active sessions |
| 116 | - if (!$row['lo'] && $row['session_dla'] > time()-$GLOBALS['egw_info']['server']['sessions_timeout'] && |
|
| 116 | + if (!$row['lo'] && $row['session_dla'] > time() - $GLOBALS['egw_info']['server']['sessions_timeout'] && |
|
| 117 | 117 | in_array($row['sessionstatus'], array('active', 'success')) && !$query['session_list']) |
| 118 | 118 | { |
| 119 | 119 | $row['class'] .= ' rowNoDelete '; |
| 120 | 120 | } |
| 121 | 121 | $row['sessionstatus'] = lang($row['sessionstatus']); |
| 122 | - unset($row['session_php']); // for security reasons, do NOT give real PHP sessionid to UI |
|
| 122 | + unset($row['session_php']); // for security reasons, do NOT give real PHP sessionid to UI |
|
| 123 | 123 | } |
| 124 | 124 | if ($query['session_list']) |
| 125 | 125 | { |
@@ -139,33 +139,33 @@ discard block |
||
| 139 | 139 | * @param string $msg ='' |
| 140 | 140 | * @param boolean $sessions_list =false |
| 141 | 141 | */ |
| 142 | - function index(array $content=null, $msg='', $sessions_list=false) |
|
| 142 | + function index(array $content = null, $msg = '', $sessions_list = false) |
|
| 143 | 143 | { |
| 144 | 144 | |
| 145 | 145 | if (is_array($content)) $sessions_list = $content['nm']['session_list']; |
| 146 | 146 | |
| 147 | 147 | // check if user has access to requested functionality |
| 148 | - if ($GLOBALS['egw']->acl->check($sessions_list ? 'current_sessions' : 'access_log_acces',1,'admin')) |
|
| 148 | + if ($GLOBALS['egw']->acl->check($sessions_list ? 'current_sessions' : 'access_log_acces', 1, 'admin')) |
|
| 149 | 149 | { |
| 150 | 150 | $GLOBALS['egw']->redirect_link('/index.php'); |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - if(!isset($content)) |
|
| 153 | + if (!isset($content)) |
|
| 154 | 154 | { |
| 155 | 155 | $content['nm'] = array( |
| 156 | - 'get_rows' => 'admin.admin_accesslog.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
| 157 | - 'no_filter' => True, // I disable the 1. filter |
|
| 158 | - 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
| 159 | - 'no_cat' => True, // I disable the cat-selectbox |
|
| 160 | - 'header_left' => false, // I template to show left of the range-value, left-aligned (optional) |
|
| 161 | - 'header_right' => false, // I template to show right of the range-value, right-aligned (optional) |
|
| 162 | - 'never_hide' => True, // I never hide the nextmatch-line if less then maxmatch entries |
|
| 163 | - 'lettersearch' => false, // I show a lettersearch |
|
| 164 | - 'start' => 0, // IO position in list |
|
| 165 | - 'order' => 'li', // IO name of the column to sort after (optional for the sortheaders) |
|
| 166 | - 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 156 | + 'get_rows' => 'admin.admin_accesslog.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
| 157 | + 'no_filter' => True, // I disable the 1. filter |
|
| 158 | + 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
| 159 | + 'no_cat' => True, // I disable the cat-selectbox |
|
| 160 | + 'header_left' => false, // I template to show left of the range-value, left-aligned (optional) |
|
| 161 | + 'header_right' => false, // I template to show right of the range-value, right-aligned (optional) |
|
| 162 | + 'never_hide' => True, // I never hide the nextmatch-line if less then maxmatch entries |
|
| 163 | + 'lettersearch' => false, // I show a lettersearch |
|
| 164 | + 'start' => 0, // IO position in list |
|
| 165 | + 'order' => 'li', // IO name of the column to sort after (optional for the sortheaders) |
|
| 166 | + 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 167 | 167 | //'default_cols' => // I columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns |
| 168 | - 'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, |
|
| 168 | + 'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, |
|
| 169 | 169 | //or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type) |
| 170 | 170 | 'actions' => $this->get_actions($sessions_list), |
| 171 | 171 | 'placeholder_actions' => false, |
@@ -196,12 +196,12 @@ discard block |
||
| 196 | 196 | 'col_filter' => $content['nm']['col_filter'] |
| 197 | 197 | ); |
| 198 | 198 | |
| 199 | - @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
| 200 | - $query['num_rows'] = -1; // all |
|
| 199 | + @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
| 200 | + $query['num_rows'] = -1; // all |
|
| 201 | 201 | $all = $readonlys = array(); |
| 202 | - $this->get_rows($query,$all,$readonlys); |
|
| 202 | + $this->get_rows($query, $all, $readonlys); |
|
| 203 | 203 | $content['nm']['selected'] = array(); |
| 204 | - foreach($all as $session) |
|
| 204 | + foreach ($all as $session) |
|
| 205 | 205 | { |
| 206 | 206 | $content['nm']['selected'][] = $session[$content['nm']['row_id']]; |
| 207 | 207 | } |
@@ -213,19 +213,19 @@ discard block |
||
| 213 | 213 | else |
| 214 | 214 | { |
| 215 | 215 | $success = $failed = $action = $action_msg = null; |
| 216 | - if ($this->action($content['nm']['action'],$content['nm']['selected'] |
|
| 217 | - ,$success,$failed,$action_msg,$msg)) |
|
| 216 | + if ($this->action($content['nm']['action'], $content['nm']['selected'] |
|
| 217 | + ,$success, $failed, $action_msg, $msg)) |
|
| 218 | 218 | { // In case of action success |
| 219 | 219 | switch ($action_msg) |
| 220 | 220 | { |
| 221 | 221 | case'deleted': |
| 222 | - $msg = lang('%1 log entries deleted.',$success); |
|
| 222 | + $msg = lang('%1 log entries deleted.', $success); |
|
| 223 | 223 | break; |
| 224 | 224 | case'killed': |
| 225 | - $msg = lang('%1 sessions killed',$success); |
|
| 225 | + $msg = lang('%1 sessions killed', $success); |
|
| 226 | 226 | } |
| 227 | 227 | } |
| 228 | - elseif($failed) // In case of action failiure |
|
| 228 | + elseif ($failed) // In case of action failiure |
|
| 229 | 229 | { |
| 230 | 230 | switch ($action_msg) |
| 231 | 231 | { |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | $content['msg'] = $msg; |
| 243 | 243 | $content['percent'] = 100.0 * $GLOBALS['egw']->db->query( |
| 244 | 244 | 'SELECT ((SELECT COUNT(*) FROM '.self::TABLE.' WHERE lo != 0) / COUNT(*)) FROM '.self::TABLE, |
| 245 | - __LINE__,__FILE__)->fetchColumn(); |
|
| 245 | + __LINE__, __FILE__)->fetchColumn(); |
|
| 246 | 246 | |
| 247 | 247 | $tmpl = new Etemplate('admin.accesslog'); |
| 248 | 248 | $tmpl->exec('admin.admin_accesslog.index', $content, array(), $readonlys, array( |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | * @param type $action_msg |
| 262 | 262 | * @return type number of failed |
| 263 | 263 | */ |
| 264 | - function action($action,$checked,&$success,&$failed,&$action_msg) |
|
| 264 | + function action($action, $checked, &$success, &$failed, &$action_msg) |
|
| 265 | 265 | { |
| 266 | 266 | $success = $failed = 0; |
| 267 | 267 | //error_log(__METHOD__.'selected:' . array2string($checked). 'action:' . $action); |
@@ -269,14 +269,14 @@ discard block |
||
| 269 | 269 | { |
| 270 | 270 | case "delete": |
| 271 | 271 | $action_msg = "deleted"; |
| 272 | - $del_msg= $this->so->delete(array('sessionid' => $checked)); |
|
| 272 | + $del_msg = $this->so->delete(array('sessionid' => $checked)); |
|
| 273 | 273 | if ($checked && $del_msg) |
| 274 | 274 | { |
| 275 | 275 | $success = $del_msg; |
| 276 | 276 | } |
| 277 | 277 | else |
| 278 | 278 | { |
| 279 | - $failed ++; |
|
| 279 | + $failed++; |
|
| 280 | 280 | } |
| 281 | 281 | break; |
| 282 | 282 | case "kill": |
@@ -284,19 +284,19 @@ discard block |
||
| 284 | 284 | $sessionid = $checked; |
| 285 | 285 | if (($key = array_search($GLOBALS['egw']->session->sessionid_access_log, $sessionid))) |
| 286 | 286 | { |
| 287 | - unset($sessionid[$key]); // dont allow to kill own sessions |
|
| 287 | + unset($sessionid[$key]); // dont allow to kill own sessions |
|
| 288 | 288 | } |
| 289 | - if ($GLOBALS['egw']->acl->check('current_sessions',8,'admin')) |
|
| 289 | + if ($GLOBALS['egw']->acl->check('current_sessions', 8, 'admin')) |
|
| 290 | 290 | { |
| 291 | - $failed ++; |
|
| 291 | + $failed++; |
|
| 292 | 292 | } |
| 293 | 293 | else |
| 294 | 294 | { |
| 295 | - foreach((array)$sessionid as $id) |
|
| 295 | + foreach ((array)$sessionid as $id) |
|
| 296 | 296 | { |
| 297 | 297 | $GLOBALS['egw']->session->destroy($id); |
| 298 | 298 | } |
| 299 | - $success= count($sessionid); |
|
| 299 | + $success = count($sessionid); |
|
| 300 | 300 | } |
| 301 | 301 | break; |
| 302 | 302 | } |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | if ($sessions_list) |
| 317 | 317 | { |
| 318 | 318 | // error_log(__METHOD__. $sessions_list); |
| 319 | - $actions= array( |
|
| 319 | + $actions = array( |
|
| 320 | 320 | 'kill' => array( |
| 321 | 321 | 'caption' => 'Kill', |
| 322 | 322 | 'confirm' => 'Kill this session', |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | } |
| 330 | 330 | else |
| 331 | 331 | { |
| 332 | - $actions= array( |
|
| 332 | + $actions = array( |
|
| 333 | 333 | 'delete' => array( |
| 334 | 334 | 'caption' => 'Delete', |
| 335 | 335 | 'confirm' => 'Delete this entry', |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | * @param array $content =null |
| 362 | 362 | * @param string $msg ='' |
| 363 | 363 | */ |
| 364 | - function sessions(array $content=null, $msg='') |
|
| 364 | + function sessions(array $content = null, $msg = '') |
|
| 365 | 365 | { |
| 366 | 366 | return $this->index($content, $msg, true); |
| 367 | 367 | } |
@@ -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); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | { |
| 64 | 64 | throw new Api\Exception\NoPermission\Admin(); |
| 65 | 65 | } |
| 66 | - if ($GLOBALS['egw']->acl->check('global_categorie',1,'admin')) |
|
| 66 | + if ($GLOBALS['egw']->acl->check('global_categorie', 1, 'admin')) |
|
| 67 | 67 | { |
| 68 | 68 | $GLOBALS['egw']->redirect_link('/index.php'); |
| 69 | 69 | } |
@@ -77,12 +77,12 @@ discard block |
||
| 77 | 77 | { |
| 78 | 78 | if (is_null(self::$acl_search)) |
| 79 | 79 | { |
| 80 | - self::$acl_search = !$GLOBALS['egw']->acl->check('global_categorie',2,'admin'); |
|
| 81 | - self::$acl_add = !$GLOBALS['egw']->acl->check('global_categorie',4,'admin'); |
|
| 82 | - self::$acl_view = !$GLOBALS['egw']->acl->check('global_categorie',8,'admin'); |
|
| 83 | - self::$acl_edit = !$GLOBALS['egw']->acl->check('global_categorie',16,'admin'); |
|
| 84 | - self::$acl_delete = !$GLOBALS['egw']->acl->check('global_categorie',32,'admin'); |
|
| 85 | - self::$acl_add_sub= !$GLOBALS['egw']->acl->check('global_categorie',64,'admin'); |
|
| 80 | + self::$acl_search = !$GLOBALS['egw']->acl->check('global_categorie', 2, 'admin'); |
|
| 81 | + self::$acl_add = !$GLOBALS['egw']->acl->check('global_categorie', 4, 'admin'); |
|
| 82 | + self::$acl_view = !$GLOBALS['egw']->acl->check('global_categorie', 8, 'admin'); |
|
| 83 | + self::$acl_edit = !$GLOBALS['egw']->acl->check('global_categorie', 16, 'admin'); |
|
| 84 | + self::$acl_delete = !$GLOBALS['egw']->acl->check('global_categorie', 32, 'admin'); |
|
| 85 | + self::$acl_add_sub = !$GLOBALS['egw']->acl->check('global_categorie', 64, 'admin'); |
|
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
@@ -92,11 +92,11 @@ discard block |
||
| 92 | 92 | * @param array $content = null |
| 93 | 93 | * @param string $msg = '' |
| 94 | 94 | */ |
| 95 | - public function edit(array $content=null,$msg='') |
|
| 95 | + public function edit(array $content = null, $msg = '') |
|
| 96 | 96 | { |
| 97 | 97 | // read the session, as the global_cats param is stored with it. |
| 98 | - $appname = $content['appname'] ? $content['appname'] : ($_GET['appname']?$_GET['appname']:Api\Categories::GLOBAL_APPNAME); |
|
| 99 | - $session = Api\Cache::getSession(__CLASS__.$appname,'nm'); |
|
| 98 | + $appname = $content['appname'] ? $content['appname'] : ($_GET['appname'] ? $_GET['appname'] : Api\Categories::GLOBAL_APPNAME); |
|
| 99 | + $session = Api\Cache::getSession(__CLASS__.$appname, 'nm'); |
|
| 100 | 100 | unset($session); |
| 101 | 101 | if (!isset($content)) |
| 102 | 102 | { |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | ($content = Categories::read($_GET['cat_id'])))) |
| 105 | 105 | { |
| 106 | 106 | $content = array('data' => array()); |
| 107 | - if(isset($_GET['parent']) && $_GET['parent'] > 0) |
|
| 107 | + if (isset($_GET['parent']) && $_GET['parent'] > 0) |
|
| 108 | 108 | { |
| 109 | 109 | // Sub-category - set some defaults from parent |
| 110 | 110 | $content['parent'] = (int)$_GET['parent']; |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | $appname = Categories::GLOBAL_APPNAME; |
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | - elseif ($content['appname'] != $appname || !self::$acl_edit || ( $content['owner'] != $GLOBALS['egw_info']['user']['account_id'] && $this->appname != 'admin')) |
|
| 123 | + elseif ($content['appname'] != $appname || !self::$acl_edit || ($content['owner'] != $GLOBALS['egw_info']['user']['account_id'] && $this->appname != 'admin')) |
|
| 124 | 124 | { |
| 125 | 125 | // only allow to view category |
| 126 | 126 | $readonlys['__ALL__'] = true; |
@@ -130,12 +130,12 @@ discard block |
||
| 130 | 130 | } |
| 131 | 131 | elseif ($content['button'] || $content['delete']) |
| 132 | 132 | { |
| 133 | - $cats = new Categories($content['owner'] ? $content['owner'] : Categories::GLOBAL_ACCOUNT,$content['appname']); |
|
| 133 | + $cats = new Categories($content['owner'] ? $content['owner'] : Categories::GLOBAL_ACCOUNT, $content['appname']); |
|
| 134 | 134 | |
| 135 | 135 | if ($content['delete']['delete'] || $content['delete']['subs']) |
| 136 | 136 | { |
| 137 | 137 | $button = 'delete'; |
| 138 | - $delete_subs = $content['delete']['subs']?true:false; |
|
| 138 | + $delete_subs = $content['delete']['subs'] ?true:false; |
|
| 139 | 139 | } |
| 140 | 140 | else |
| 141 | 141 | { |
@@ -146,23 +146,23 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | $refresh_app = $this->appname == 'preferences' ? $content['appname'] : $this->appname; |
| 148 | 148 | |
| 149 | - switch($button) |
|
| 149 | + switch ($button) |
|
| 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'])) $content['owner'] = implode(',', $content['owner']); |
|
| 154 | + if ($content['owner'] == '') $content['owner'] = 0; |
|
| 155 | 155 | if ($content['id'] && self::$acl_edit) |
| 156 | 156 | { |
| 157 | 157 | |
| 158 | - $data = $cats->id2name($content['id'],'data'); |
|
| 158 | + $data = $cats->id2name($content['id'], 'data'); |
|
| 159 | 159 | try { |
| 160 | 160 | $cats->edit($content); |
| 161 | 161 | $msg = lang('Category saved.'); |
| 162 | 162 | } |
| 163 | 163 | catch (Api\Exception\WrongUserinput $e) |
| 164 | 164 | { |
| 165 | - $msg = lang('Unwilling to save category with current settings. Check for inconsistency:').$e->getMessage(); // display conflicts etc. |
|
| 165 | + $msg = lang('Unwilling to save category with current settings. Check for inconsistency:').$e->getMessage(); // display conflicts etc. |
|
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | elseif (!$content['id'] && ( |
@@ -181,15 +181,15 @@ discard block |
||
| 181 | 181 | // to reload the whole nextmatch instead of just the row |
| 182 | 182 | $change_color = ($data['color'] != $content['data']['color']); |
| 183 | 183 | // Nicely reload just the category window / iframe |
| 184 | - if($change_color) |
|
| 184 | + if ($change_color) |
|
| 185 | 185 | { |
| 186 | - if(Api\Json\Response::isJSONResponse()) |
|
| 186 | + if (Api\Json\Response::isJSONResponse()) |
|
| 187 | 187 | { |
| 188 | 188 | // Update category styles |
| 189 | - Api\Json\Response::get()->apply('opener.egw.includeCSS',array(Categories::css($refresh_app == 'admin' ? Categories::GLOBAL_APPNAME : $refresh_app))); |
|
| 190 | - if($this->appname != 'admin') |
|
| 189 | + Api\Json\Response::get()->apply('opener.egw.includeCSS', array(Categories::css($refresh_app == 'admin' ? Categories::GLOBAL_APPNAME : $refresh_app))); |
|
| 190 | + if ($this->appname != 'admin') |
|
| 191 | 191 | { |
| 192 | - Api\Json\Response::get()->apply('opener.egw.show_preferences',array( |
|
| 192 | + Api\Json\Response::get()->apply('opener.egw.show_preferences', array( |
|
| 193 | 193 | 'cats', |
| 194 | 194 | $this->appname == 'admin' ? Categories::GLOBAL_APPNAME : array($refresh_app) |
| 195 | 195 | )); |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | { |
| 200 | 200 | Categories::css($refresh_app == 'admin' ? Categories::GLOBAL_APPNAME : $refresh_app); |
| 201 | 201 | // Need to forcably re-load the iframe to avoid smart etemplate refresh |
| 202 | - Api\Json\Response::get()->apply('opener.app.admin.load',array( |
|
| 202 | + Api\Json\Response::get()->apply('opener.app.admin.load', array( |
|
| 203 | 203 | Framework::link('/index.php', array( |
| 204 | 204 | 'menuaction' => $this->list_link, |
| 205 | 205 | 'appname' => $appname |
@@ -229,10 +229,10 @@ discard block |
||
| 229 | 229 | case 'delete': |
| 230 | 230 | if (self::$acl_delete) |
| 231 | 231 | { |
| 232 | - $cats->delete($content['id'],$delete_subs,!$delete_subs); |
|
| 232 | + $cats->delete($content['id'], $delete_subs, !$delete_subs); |
|
| 233 | 233 | $msg = lang('Category deleted.'); |
| 234 | 234 | |
| 235 | - Framework::refresh_opener($msg, $refresh_app, $content['id'],'delete', $this->appname); |
|
| 235 | + Framework::refresh_opener($msg, $refresh_app, $content['id'], 'delete', $this->appname); |
|
| 236 | 236 | Framework::window_close(); |
| 237 | 237 | return; |
| 238 | 238 | } |
@@ -247,19 +247,19 @@ discard block |
||
| 247 | 247 | Framework::refresh_opener($msg, $this->appname, $content['id'], $change_color ? null : 'update', $refresh_app); |
| 248 | 248 | } |
| 249 | 249 | $content['msg'] = $msg; |
| 250 | - if(!$content['appname']) $content['appname'] = $appname; |
|
| 251 | - if($content['data']['icon']) |
|
| 250 | + if (!$content['appname']) $content['appname'] = $appname; |
|
| 251 | + if ($content['data']['icon']) |
|
| 252 | 252 | { |
| 253 | - $content['icon_url'] = $content['base_url'] . $content['data']['icon']; |
|
| 253 | + $content['icon_url'] = $content['base_url'].$content['data']['icon']; |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | $sel_options['icon'] = self::get_icons(); |
| 257 | 257 | $sel_options['owner'] = array(); |
| 258 | 258 | |
| 259 | 259 | // User's category - add current value to be able to preserve owner |
| 260 | - if(!$content['id']) |
|
| 260 | + if (!$content['id']) |
|
| 261 | 261 | { |
| 262 | - if($this->appname != 'admin') |
|
| 262 | + if ($this->appname != 'admin') |
|
| 263 | 263 | { |
| 264 | 264 | $content['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
| 265 | 265 | } |
@@ -269,24 +269,24 @@ discard block |
||
| 269 | 269 | } |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - if($this->appname != 'admin' && $content['owner'] > 0 ) |
|
| 272 | + if ($this->appname != 'admin' && $content['owner'] > 0) |
|
| 273 | 273 | { |
| 274 | 274 | $sel_options['owner'][$content['owner']] = Api\Accounts::username($content['owner']); |
| 275 | 275 | } |
| 276 | 276 | // Add 'All users', in case owner is readonlys |
| 277 | - if($content['id'] && $content['owner'] == 0) |
|
| 277 | + if ($content['id'] && $content['owner'] == 0) |
|
| 278 | 278 | { |
| 279 | 279 | $sel_options['owner'][0] = lang('All users'); |
| 280 | 280 | } |
| 281 | - if($this->appname == 'admin' || ($content['id'] && !((int)$content['owner'] > 0))) |
|
| 281 | + if ($this->appname == 'admin' || ($content['id'] && !((int)$content['owner'] > 0))) |
|
| 282 | 282 | { |
| 283 | - if($content['owner'] > 0) |
|
| 283 | + if ($content['owner'] > 0) |
|
| 284 | 284 | { |
| 285 | 285 | $content['msg'] .= "\n".lang('owner "%1" removed, please select group-owner', Api\Accounts::username($content['owner'])); |
| 286 | 286 | $content['owner'] = 0; |
| 287 | 287 | } |
| 288 | 288 | $sel_options['owner'][0] = lang('All users'); |
| 289 | - foreach($GLOBALS['egw']->accounts->search(array('type' => 'groups')) as $acc) |
|
| 289 | + foreach ($GLOBALS['egw']->accounts->search(array('type' => 'groups')) as $acc) |
|
| 290 | 290 | { |
| 291 | 291 | if ($acc['account_type'] == 'g') |
| 292 | 292 | { |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | $content['no_private'] = true; |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - if($this->appname == 'admin') |
|
| 299 | + if ($this->appname == 'admin') |
|
| 300 | 300 | { |
| 301 | 301 | $content['access'] = 'public'; |
| 302 | 302 | // Allow admins access to all categories as parent |
@@ -307,17 +307,17 @@ discard block |
||
| 307 | 307 | $readonlys['access'] = $content['owner'] != $GLOBALS['egw_info']['user']['account_id']; |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - Framework::includeJS('.','global_categories','admin'); |
|
| 310 | + Framework::includeJS('.', 'global_categories', 'admin'); |
|
| 311 | 311 | |
| 312 | - $readonlys['button[delete]'] = !$content['id'] || !self::$acl_delete || // cant delete not yet saved category |
|
| 312 | + $readonlys['button[delete]'] = !$content['id'] || !self::$acl_delete || // cant delete not yet saved category |
|
| 313 | 313 | $appname != $content['appname'] || // Can't edit a category from a different app |
| 314 | 314 | ($this->appname != 'admin' && $content['owner'] != $GLOBALS['egw_info']['user']['account_id']); |
| 315 | 315 | // 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']); |
|
| 316 | + if (!is_array($content['owner'])) $content['owner'] = explode(',', $content['owner']); |
|
| 317 | 317 | $tmpl = new Etemplate('admin.categories.edit'); |
| 318 | - $tmpl->exec($this->edit_link,$content,$sel_options,$readonlys,$content+array( |
|
| 318 | + $tmpl->exec($this->edit_link, $content, $sel_options, $readonlys, $content + array( |
|
| 319 | 319 | 'old_parent' => $content['old_parent'] ? $content['old_parent'] : $content['parent'], 'appname' => $appname |
| 320 | - ),2); |
|
| 320 | + ), 2); |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /** |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | * @param string $icon = '' filename |
| 327 | 327 | * @return string url |
| 328 | 328 | */ |
| 329 | - static function icon_url($icon='') |
|
| 329 | + static function icon_url($icon = '') |
|
| 330 | 330 | { |
| 331 | 331 | return $GLOBALS['egw_info']['server']['webserver_url'].self::ICON_PATH.'/'.$icon; |
| 332 | 332 | } |
@@ -339,12 +339,12 @@ discard block |
||
| 339 | 339 | static function get_icons() |
| 340 | 340 | { |
| 341 | 341 | $icons = array(); |
| 342 | - if (file_exists($image_dir=EGW_SERVER_ROOT.self::ICON_PATH) && ($dir = dir($image_dir))) |
|
| 342 | + if (file_exists($image_dir = EGW_SERVER_ROOT.self::ICON_PATH) && ($dir = dir($image_dir))) |
|
| 343 | 343 | { |
| 344 | 344 | $matches = null; |
| 345 | - while(($file = $dir->read())) |
|
| 345 | + while (($file = $dir->read())) |
|
| 346 | 346 | { |
| 347 | - if (preg_match('/^(.*)\\.(png|gif|jpe?g)$/i',$file,$matches)) |
|
| 347 | + if (preg_match('/^(.*)\\.(png|gif|jpe?g)$/i', $file, $matches)) |
|
| 348 | 348 | { |
| 349 | 349 | $icons[$file] = ucfirst($matches[1]); |
| 350 | 350 | } |
@@ -363,13 +363,13 @@ discard block |
||
| 363 | 363 | * @param array &$readonlys eg. to disable buttons based on Acl, not use here, maybe in a derived class |
| 364 | 364 | * @return int total number of rows |
| 365 | 365 | */ |
| 366 | - public function get_rows(&$query,&$rows,&$readonlys) |
|
| 366 | + public function get_rows(&$query, &$rows, &$readonlys) |
|
| 367 | 367 | { |
| 368 | 368 | self::init_static(); |
| 369 | 369 | |
| 370 | 370 | $filter = array(); |
| 371 | 371 | $globalcat = ($query['filter'] === Categories::GLOBAL_ACCOUNT || !$query['filter']); |
| 372 | - if (isset($query['global_cats']) && $query['global_cats']===false) |
|
| 372 | + if (isset($query['global_cats']) && $query['global_cats'] === false) |
|
| 373 | 373 | { |
| 374 | 374 | $globalcat = false; |
| 375 | 375 | } |
@@ -377,49 +377,49 @@ discard block |
||
| 377 | 377 | // new column-filter access has highest priority |
| 378 | 378 | if (!empty($query['col_filter']['access']))$filter['access'] = $query['col_filter']['access']; |
| 379 | 379 | |
| 380 | - Api\Cache::setSession(__CLASS__.$query['appname'],'nm',$query); |
|
| 380 | + Api\Cache::setSession(__CLASS__.$query['appname'], 'nm', $query); |
|
| 381 | 381 | |
| 382 | - if($query['filter'] > 0 || $query['col_filter']['owner']) |
|
| 382 | + if ($query['filter'] > 0 || $query['col_filter']['owner']) |
|
| 383 | 383 | { |
| 384 | 384 | $owner = $query['col_filter']['owner'] ? $query['col_filter']['owner'] : $query['filter']; |
| 385 | 385 | } |
| 386 | - if($query['col_filter']['app']) |
|
| 386 | + if ($query['col_filter']['app']) |
|
| 387 | 387 | { |
| 388 | 388 | $filter['appname'] = $query['col_filter']['app']; |
| 389 | 389 | } |
| 390 | - $GLOBALS['egw']->categories = $cats = new Categories($filter['owner'],$query['appname']); |
|
| 391 | - $globals = isset($GLOBALS['egw_info']['user']['apps']['admin']) ? 'all_no_acl' : $globalcat; // ignore Acl only for admins |
|
| 390 | + $GLOBALS['egw']->categories = $cats = new Categories($filter['owner'], $query['appname']); |
|
| 391 | + $globals = isset($GLOBALS['egw_info']['user']['apps']['admin']) ? 'all_no_acl' : $globalcat; // ignore Acl only for admins |
|
| 392 | 392 | $parent = $query['search'] ? false : 0; |
| 393 | - $rows = $cats->return_sorted_array($query['start'],false,$query['search'],$query['sort'],$query['order'],$globals,$parent,true,$filter); |
|
| 393 | + $rows = $cats->return_sorted_array($query['start'], false, $query['search'], $query['sort'], $query['order'], $globals, $parent, true, $filter); |
|
| 394 | 394 | $count = $cats->total_records; |
| 395 | - foreach($rows as $key => &$row) |
|
| 395 | + foreach ($rows as $key => &$row) |
|
| 396 | 396 | { |
| 397 | - $row['owner'] = explode(',',$row['owner']); |
|
| 398 | - if(($owner && !in_array($owner, $row['owner'])) || ((string)$query['filter'] === (string)Api\Categories::GLOBAL_ACCOUNT && $row['owner'][0] > 0)) |
|
| 397 | + $row['owner'] = explode(',', $row['owner']); |
|
| 398 | + if (($owner && !in_array($owner, $row['owner'])) || ((string)$query['filter'] === (string)Api\Categories::GLOBAL_ACCOUNT && $row['owner'][0] > 0)) |
|
| 399 | 399 | { |
| 400 | 400 | unset($rows[$key]); |
| 401 | 401 | $count--; |
| 402 | 402 | continue; |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | - $row['level_spacer'] = str_repeat(' ',$row['level']); |
|
| 405 | + $row['level_spacer'] = str_repeat(' ', $row['level']); |
|
| 406 | 406 | |
| 407 | 407 | if ($row['data']['icon']) $row['icon_url'] = self::icon_url($row['data']['icon']); |
| 408 | 408 | |
| 409 | 409 | $row['subs'] = count($row['children']); |
| 410 | 410 | |
| 411 | 411 | $row['class'] = 'level'.$row['level']; |
| 412 | - if($row['owner'][0] > 0 && !$GLOBALS['egw_info']['user']['apps']['admin'] && $row['owner'][0] != $GLOBALS['egw_info']['user']['account_id']) |
|
| 412 | + if ($row['owner'][0] > 0 && !$GLOBALS['egw_info']['user']['apps']['admin'] && $row['owner'][0] != $GLOBALS['egw_info']['user']['account_id']) |
|
| 413 | 413 | { |
| 414 | 414 | $row['class'] .= ' rowNoEdit rowNoDelete '; |
| 415 | 415 | } |
| 416 | 416 | else if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
| 417 | 417 | { |
| 418 | - if(!$cats->check_perms(Acl::EDIT, $row['id']) || !self::$acl_edit) |
|
| 418 | + if (!$cats->check_perms(Acl::EDIT, $row['id']) || !self::$acl_edit) |
|
| 419 | 419 | { |
| 420 | 420 | $row['class'] .= ' rowNoEdit'; |
| 421 | 421 | } |
| 422 | - if(!$cats->check_perms(Acl::DELETE, $row['id']) || !self::$acl_delete || |
|
| 422 | + if (!$cats->check_perms(Acl::DELETE, $row['id']) || !self::$acl_delete || |
|
| 423 | 423 | // Only admins can delete globals |
| 424 | 424 | $cats->is_global($row['id']) && !$GLOBALS['egw_info']['user']['apps']['admin']) |
| 425 | 425 | { |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | } |
| 428 | 428 | } |
| 429 | 429 | // Can only edit (via context menu) Categories for the selected app (backend restriction) |
| 430 | - if($row['appname'] != $query['appname']) |
|
| 430 | + if ($row['appname'] != $query['appname']) |
|
| 431 | 431 | { |
| 432 | 432 | $row['class'] .= ' rowNoEdit '; |
| 433 | 433 | } |
@@ -455,60 +455,60 @@ discard block |
||
| 455 | 455 | * @param array $content = null |
| 456 | 456 | * @param string $msg = '' |
| 457 | 457 | */ |
| 458 | - public function index(array $content=null,$msg='') |
|
| 458 | + public function index(array $content = null, $msg = '') |
|
| 459 | 459 | { |
| 460 | 460 | //_debug_array($_GET); |
| 461 | - if ($this->appname != 'admin') Api\Translation::add_app('admin'); // need admin translations |
|
| 461 | + if ($this->appname != 'admin') Api\Translation::add_app('admin'); // need admin translations |
|
| 462 | 462 | |
| 463 | - if(!isset($content)) |
|
| 463 | + if (!isset($content)) |
|
| 464 | 464 | { |
| 465 | 465 | if (isset($_GET['msg'])) $msg = $_GET['msg']; |
| 466 | 466 | |
| 467 | 467 | $appname = Categories::GLOBAL_APPNAME; |
| 468 | - foreach(array($content['nm']['appname'], $_GET['cats_app'], $_GET['appname']) as $field) |
|
| 468 | + foreach (array($content['nm']['appname'], $_GET['cats_app'], $_GET['appname']) as $field) |
|
| 469 | 469 | { |
| 470 | - if($field) |
|
| 470 | + if ($field) |
|
| 471 | 471 | { |
| 472 | 472 | $appname = $field; |
| 473 | 473 | break; |
| 474 | 474 | } |
| 475 | 475 | } |
| 476 | - $content['nm'] = Api\Cache::getSession(__CLASS__.$appname,'nm'); |
|
| 476 | + $content['nm'] = Api\Cache::getSession(__CLASS__.$appname, 'nm'); |
|
| 477 | 477 | if (!is_array($content['nm'])) |
| 478 | 478 | { |
| 479 | 479 | $content['nm'] = array( |
| 480 | - 'get_rows' => $this->get_rows, // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
| 480 | + 'get_rows' => $this->get_rows, // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
| 481 | 481 | 'options-filter' => array( |
| 482 | 482 | '' => lang('All categories'), |
| 483 | 483 | Categories::GLOBAL_ACCOUNT => lang('Global categories'), |
| 484 | 484 | $GLOBALS['egw_info']['user']['account_id'] => lang('Own categories'), |
| 485 | 485 | ), |
| 486 | - 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
| 487 | - 'no_cat' => True, // I disable the cat-selectbox |
|
| 488 | - 'header_left' => false, // I template to show left of the range-value, left-aligned (optional) |
|
| 489 | - 'header_right' => false, // I template to show right of the range-value, right-aligned (optional) |
|
| 490 | - 'never_hide' => True, // I never hide the nextmatch-line if less then maxmatch entries |
|
| 491 | - 'lettersearch' => false, // I show a lettersearch |
|
| 492 | - 'start' => 0, // IO position in list |
|
| 493 | - 'order' => 'name', // IO name of the column to sort after (optional for the sortheaders) |
|
| 494 | - 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 495 | - 'default_cols' => '!color,last_mod,subs,legacy_actions', // I columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns |
|
| 496 | - 'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, |
|
| 486 | + 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
| 487 | + 'no_cat' => True, // I disable the cat-selectbox |
|
| 488 | + 'header_left' => false, // I template to show left of the range-value, left-aligned (optional) |
|
| 489 | + 'header_right' => false, // I template to show right of the range-value, right-aligned (optional) |
|
| 490 | + 'never_hide' => True, // I never hide the nextmatch-line if less then maxmatch entries |
|
| 491 | + 'lettersearch' => false, // I show a lettersearch |
|
| 492 | + 'start' => 0, // IO position in list |
|
| 493 | + 'order' => 'name', // IO name of the column to sort after (optional for the sortheaders) |
|
| 494 | + 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 495 | + 'default_cols' => '!color,last_mod,subs,legacy_actions', // I columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns |
|
| 496 | + 'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, |
|
| 497 | 497 | //or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type) |
| 498 | 498 | 'no_search' => !self::$acl_search, |
| 499 | 499 | 'row_id' => 'id', |
| 500 | 500 | 'dataStorePrefix' => 'categories' // Avoid conflict with user list when in admin |
| 501 | 501 | ); |
| 502 | - $content['nm']['filter'] = $this->appname == 'admin'?Api\Categories::GLOBAL_ACCOUNT:$GLOBALS['egw_info']['user']['account_id']; |
|
| 502 | + $content['nm']['filter'] = $this->appname == 'admin' ?Api\Categories::GLOBAL_ACCOUNT : $GLOBALS['egw_info']['user']['account_id']; |
|
| 503 | 503 | } |
| 504 | 504 | else |
| 505 | 505 | { |
| 506 | - $content['nm']['start']=0; |
|
| 506 | + $content['nm']['start'] = 0; |
|
| 507 | 507 | } |
| 508 | 508 | $content['nm']['appname'] = $appname = $_GET['appname'] ? $_GET['appname'] : $appname; |
| 509 | 509 | $content['nm']['actions'] = $this->get_actions($appname); |
| 510 | 510 | // switch filter off for super-global categories |
| 511 | - if($appname == 'phpgw') |
|
| 511 | + if ($appname == 'phpgw') |
|
| 512 | 512 | { |
| 513 | 513 | $content['nm']['no_filter'] = true; |
| 514 | 514 | // Make sure filter is set properly, could be different if user was looking at something else |
@@ -516,18 +516,18 @@ discard block |
||
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | $content['nm']['global_cats'] = true; |
| 519 | - if (isset($_GET['global_cats']) && empty($_GET['global_cats'] )) |
|
| 519 | + if (isset($_GET['global_cats']) && empty($_GET['global_cats'])) |
|
| 520 | 520 | { |
| 521 | 521 | $content['nm']['global_cats'] = false; |
| 522 | 522 | } |
| 523 | 523 | } |
| 524 | - elseif($content['nm']['action']) |
|
| 524 | + elseif ($content['nm']['action']) |
|
| 525 | 525 | { |
| 526 | 526 | $appname = $content['nm']['appname']; |
| 527 | 527 | // Old buttons |
| 528 | - foreach(array('delete') as $button) |
|
| 528 | + foreach (array('delete') as $button) |
|
| 529 | 529 | { |
| 530 | - if(isset($content['nm']['rows'][$button])) |
|
| 530 | + if (isset($content['nm']['rows'][$button])) |
|
| 531 | 531 | { |
| 532 | 532 | list($id) = @each($content['nm']['rows'][$button]); |
| 533 | 533 | $content['nm']['action'] = $button; |
@@ -542,39 +542,39 @@ discard block |
||
| 542 | 542 | else |
| 543 | 543 | { |
| 544 | 544 | // Action has an additional action - add / delete, etc. Buttons named <multi-action>_action[action_name] |
| 545 | - if(in_array($content['nm']['action'], array('owner'))) |
|
| 545 | + if (in_array($content['nm']['action'], array('owner'))) |
|
| 546 | 546 | { |
| 547 | 547 | $action = $content['nm']['action']; |
| 548 | 548 | if ($content[$action.'_popup']) |
| 549 | 549 | { |
| 550 | - $content = array_merge($content,$content[$action.'_popup']); |
|
| 550 | + $content = array_merge($content, $content[$action.'_popup']); |
|
| 551 | 551 | } |
| 552 | - $content['nm']['action'] .= '_' . key($content[$action . '_action']); |
|
| 552 | + $content['nm']['action'] .= '_'.key($content[$action.'_action']); |
|
| 553 | 553 | |
| 554 | - if(is_array($content[$action])) |
|
| 554 | + if (is_array($content[$action])) |
|
| 555 | 555 | { |
| 556 | - $content[$action] = implode(',',$content[$action]); |
|
| 556 | + $content[$action] = implode(',', $content[$action]); |
|
| 557 | 557 | } |
| 558 | - $content['nm']['action'] .= '_' . $content[$action]; |
|
| 558 | + $content['nm']['action'] .= '_'.$content[$action]; |
|
| 559 | 559 | } |
| 560 | 560 | $success = $failed = 0; |
| 561 | 561 | $action_msg = null; |
| 562 | - if ($this->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'], |
|
| 563 | - $success,$failed,$action_msg,$content['nm'])) |
|
| 562 | + if ($this->action($content['nm']['action'], $content['nm']['selected'], $content['nm']['select_all'], |
|
| 563 | + $success, $failed, $action_msg, $content['nm'])) |
|
| 564 | 564 | { |
| 565 | - $msg .= lang('%1 category(s) %2',$success,$action_msg); |
|
| 565 | + $msg .= lang('%1 category(s) %2', $success, $action_msg); |
|
| 566 | 566 | } |
| 567 | - elseif(empty($msg)) |
|
| 567 | + elseif (empty($msg)) |
|
| 568 | 568 | { |
| 569 | - $msg .= lang('%1 category(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); |
|
| 569 | + $msg .= lang('%1 category(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed); |
|
| 570 | 570 | } |
| 571 | 571 | Framework::refresh_opener($msg, $this->appname); |
| 572 | 572 | $msg = ''; |
| 573 | 573 | } |
| 574 | 574 | } |
| 575 | 575 | $content['msg'] = $msg; |
| 576 | - $content['nm']['add_link']= Framework::link('/index.php','menuaction='.$this->add_link . '&cat_id=&appname='.$appname); |
|
| 577 | - $content['edit_link']= $this->edit_link.'&appname='.$appname; |
|
| 576 | + $content['nm']['add_link'] = Framework::link('/index.php', 'menuaction='.$this->add_link.'&cat_id=&appname='.$appname); |
|
| 577 | + $content['edit_link'] = $this->edit_link.'&appname='.$appname; |
|
| 578 | 578 | $content['owner'] = ''; |
| 579 | 579 | |
| 580 | 580 | $sel_options['appname'] = $this->get_app_list(); |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | ); |
| 589 | 589 | |
| 590 | 590 | $sel_options['owner'][0] = lang('All users'); |
| 591 | - foreach($GLOBALS['egw']->accounts->search(array('type' => 'groups')) as $acc) |
|
| 591 | + foreach ($GLOBALS['egw']->accounts->search(array('type' => 'groups')) as $acc) |
|
| 592 | 592 | { |
| 593 | 593 | if ($acc['account_type'] == 'g') |
| 594 | 594 | { |
@@ -597,12 +597,12 @@ discard block |
||
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | $readonlys['add'] = !self::$acl_add; |
| 600 | - if(!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 600 | + if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 601 | 601 | { |
| 602 | 602 | $readonlys['nm']['rows']['owner'] = true; |
| 603 | 603 | $readonlys['nm']['col_filter']['owner'] = true; |
| 604 | 604 | } |
| 605 | - if($appname == Categories::GLOBAL_APPNAME) { |
|
| 605 | + if ($appname == Categories::GLOBAL_APPNAME) { |
|
| 606 | 606 | $sel_options['app'] = array(''=>''); |
| 607 | 607 | $readonlys['nm']['rows']['app'] = true; |
| 608 | 608 | } |
@@ -615,12 +615,12 @@ discard block |
||
| 615 | 615 | // Category styles |
| 616 | 616 | Categories::css($appname); |
| 617 | 617 | |
| 618 | - $tmpl->exec($this->list_link,$content,$sel_options,$readonlys,array( |
|
| 618 | + $tmpl->exec($this->list_link, $content, $sel_options, $readonlys, array( |
|
| 619 | 619 | 'nm' => $content['nm'], |
| 620 | 620 | )); |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | - protected function get_actions($appname=Api\Categories::GLOBAL_APPNAME) { |
|
| 623 | + protected function get_actions($appname = Api\Categories::GLOBAL_APPNAME) { |
|
| 624 | 624 | |
| 625 | 625 | $actions = array( |
| 626 | 626 | 'open' => array( // does edit if allowed, otherwise view |
@@ -629,7 +629,7 @@ discard block |
||
| 629 | 629 | 'allowOnMultiple' => false, |
| 630 | 630 | 'url' => 'menuaction='.$this->edit_link.'&cat_id=$id&appname='.$appname, |
| 631 | 631 | 'popup' => '600x380', |
| 632 | - 'group' => $group=1, |
|
| 632 | + 'group' => $group = 1, |
|
| 633 | 633 | ), |
| 634 | 634 | 'add' => array( |
| 635 | 635 | 'caption' => 'Add', |
@@ -664,7 +664,7 @@ discard block |
||
| 664 | 664 | ), |
| 665 | 665 | ); |
| 666 | 666 | |
| 667 | - if(!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 667 | + if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 668 | 668 | { |
| 669 | 669 | unset($actions['owner']); |
| 670 | 670 | } |
@@ -690,14 +690,14 @@ discard block |
||
| 690 | 690 | $success = $failed = 0; |
| 691 | 691 | if ($use_all) |
| 692 | 692 | { |
| 693 | - @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
| 694 | - $query['num_rows'] = -1; // all |
|
| 693 | + @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
| 694 | + $query['num_rows'] = -1; // all |
|
| 695 | 695 | $result = $readonlys = array(); |
| 696 | - $this->get_rows($query,$result,$readonlys); |
|
| 696 | + $this->get_rows($query, $result, $readonlys); |
|
| 697 | 697 | $checked = array(); |
| 698 | - foreach($result as $key => $info) |
|
| 698 | + foreach ($result as $key => $info) |
|
| 699 | 699 | { |
| 700 | - if(is_numeric($key)) |
|
| 700 | + if (is_numeric($key)) |
|
| 701 | 701 | { |
| 702 | 702 | $checked[] = $info['id']; |
| 703 | 703 | } |
@@ -705,19 +705,19 @@ discard block |
||
| 705 | 705 | } |
| 706 | 706 | $owner = $query['col_filter']['owner'] ? $query['col_filter']['owner'] : $query['filter']; |
| 707 | 707 | $app = $query['col_filter']['app'] ? $query['col_filter']['app'] : $query['appname']; |
| 708 | - $cats = new Categories($owner,$app); |
|
| 708 | + $cats = new Categories($owner, $app); |
|
| 709 | 709 | |
| 710 | 710 | list($action, $settings) = explode('_', $_action, 2); |
| 711 | 711 | |
| 712 | - switch($action) |
|
| 712 | + switch ($action) |
|
| 713 | 713 | { |
| 714 | 714 | case 'delete': |
| 715 | 715 | $action_msg = lang('deleted'); |
| 716 | - foreach($checked as $id) |
|
| 716 | + foreach ($checked as $id) |
|
| 717 | 717 | { |
| 718 | - if($cats->check_perms(Acl::DELETE, $id, (boolean)$GLOBALS['egw_info']['user']['apps']['admin'])) |
|
| 718 | + if ($cats->check_perms(Acl::DELETE, $id, (boolean)$GLOBALS['egw_info']['user']['apps']['admin'])) |
|
| 719 | 719 | { |
| 720 | - $cats->delete($id,$settings == 'sub',$settings != 'sub'); |
|
| 720 | + $cats->delete($id, $settings == 'sub', $settings != 'sub'); |
|
| 721 | 721 | $success++; |
| 722 | 722 | } |
| 723 | 723 | else |
@@ -731,20 +731,19 @@ discard block |
||
| 731 | 731 | list($add_remove, $ids_csv) = explode('_', $settings, 2); |
| 732 | 732 | $ids = explode(',', $ids_csv); |
| 733 | 733 | // Adding 'All users' removes all the others |
| 734 | - if($add_remove == 'add' && array_search(Categories::GLOBAL_ACCOUNT,$ids) !== false) $ids = array(Categories::GLOBAL_ACCOUNT); |
|
| 734 | + if ($add_remove == 'add' && array_search(Categories::GLOBAL_ACCOUNT, $ids) !== false) $ids = array(Categories::GLOBAL_ACCOUNT); |
|
| 735 | 735 | |
| 736 | - foreach($checked as $id) |
|
| 736 | + foreach ($checked as $id) |
|
| 737 | 737 | { |
| 738 | 738 | if (!$data = $cats->read($id)) continue; |
| 739 | - $data['owner'] = explode(',',$data['owner']); |
|
| 740 | - if(array_search(Categories::GLOBAL_ACCOUNT,$data['owner']) !== false || $data['owner'][0] > 0) |
|
| 739 | + $data['owner'] = explode(',', $data['owner']); |
|
| 740 | + if (array_search(Categories::GLOBAL_ACCOUNT, $data['owner']) !== false || $data['owner'][0] > 0) |
|
| 741 | 741 | { |
| 742 | 742 | $data['owner'] = array(); |
| 743 | 743 | } |
| 744 | 744 | $data['owner'] = $add_remove == 'add' ? |
| 745 | - $ids == array(Categories::GLOBAL_ACCOUNT) ? $ids : array_merge($data['owner'],$ids) : |
|
| 746 | - array_diff($data['owner'],$ids); |
|
| 747 | - $data['owner'] = implode(',',array_unique($data['owner'])); |
|
| 745 | + $ids == array(Categories::GLOBAL_ACCOUNT) ? $ids : array_merge($data['owner'], $ids) : array_diff($data['owner'], $ids); |
|
| 746 | + $data['owner'] = implode(',', array_unique($data['owner'])); |
|
| 748 | 747 | |
| 749 | 748 | if ($cats->edit($data)) |
| 750 | 749 | { |
@@ -775,7 +774,7 @@ discard block |
||
| 775 | 774 | continue; |
| 776 | 775 | } |
| 777 | 776 | // 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; |
|
| 777 | + if ($data['status'] > 1 || in_array($app, array('home', 'admin', 'felamimail', 'sitemgr', 'sitemgr-link'))) continue; |
|
| 779 | 778 | if ($GLOBALS['egw_info']['user']['apps'][$app]) |
| 780 | 779 | { |
| 781 | 780 | $apps[$app] = $data['title'] ? $data['title'] : lang($app); |