@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * |
| 79 | 79 | * @param string $contact_app |
| 80 | 80 | */ |
| 81 | - function __construct($contact_app='addressbook') |
|
| 81 | + function __construct($contact_app = 'addressbook') |
|
| 82 | 82 | { |
| 83 | 83 | parent::__construct($contact_app); |
| 84 | 84 | |
@@ -92,23 +92,23 @@ discard block |
||
| 92 | 92 | ); |
| 93 | 93 | |
| 94 | 94 | // make sure the hook for export_limit is registered |
| 95 | - if (!Api\Hooks::exists('export_limit','addressbook')) Api\Hooks::read(true); |
|
| 95 | + if (!Api\Hooks::exists('export_limit', 'addressbook')) Api\Hooks::read(true); |
|
| 96 | 96 | |
| 97 | - $this->config =& $GLOBALS['egw_info']['server']; |
|
| 97 | + $this->config = & $GLOBALS['egw_info']['server']; |
|
| 98 | 98 | |
| 99 | 99 | // check if a contact specific export limit is set, if yes use it also for etemplate's csv export |
| 100 | - $this->config['export_limit'] = $this->config['contact_export_limit'] = Api\Storage\Merge::getExportLimit($app='addressbook'); |
|
| 100 | + $this->config['export_limit'] = $this->config['contact_export_limit'] = Api\Storage\Merge::getExportLimit($app = 'addressbook'); |
|
| 101 | 101 | |
| 102 | 102 | if ($this->config['copy_fields'] && ($fields = is_array($this->config['copy_fields']) ? |
| 103 | 103 | $this->config['copy_fields'] : unserialize($this->config['copy_fields']))) |
| 104 | 104 | { |
| 105 | 105 | // Set country code if country name is selected |
| 106 | - $supported_fields = $this->get_fields('supported',null,0); |
|
| 107 | - if(in_array('adr_one_countrycode', $supported_fields) && in_array('adr_one_countryname',$fields)) |
|
| 106 | + $supported_fields = $this->get_fields('supported', null, 0); |
|
| 107 | + if (in_array('adr_one_countrycode', $supported_fields) && in_array('adr_one_countryname', $fields)) |
|
| 108 | 108 | { |
| 109 | 109 | $fields[] = 'adr_one_countrycode'; |
| 110 | 110 | } |
| 111 | - if(in_array('adr_two_countrycode', $supported_fields) && in_array('adr_two_countryname',$fields)) |
|
| 111 | + if (in_array('adr_two_countrycode', $supported_fields) && in_array('adr_two_countryname', $fields)) |
|
| 112 | 112 | { |
| 113 | 113 | $fields[] = 'adr_two_countrycode'; |
| 114 | 114 | } |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * @param array $_content =null submitted content |
| 124 | 124 | * @param string $msg =null message to show |
| 125 | 125 | */ |
| 126 | - function index($_content=null,$msg=null) |
|
| 126 | + function index($_content = null, $msg = null) |
|
| 127 | 127 | { |
| 128 | 128 | //echo "<p>uicontacts::index(".print_r($_content,true).",'$msg')</p>\n"; |
| 129 | 129 | if (($re_submit = is_array($_content))) |
@@ -155,16 +155,16 @@ discard block |
||
| 155 | 155 | else |
| 156 | 156 | { |
| 157 | 157 | $success = $failed = $action_msg = null; |
| 158 | - if ($this->action($_content['nm']['action'],$_content['nm']['selected'],$_content['nm']['select_all'], |
|
| 159 | - $success,$failed,$action_msg,'index',$msg,$_content['nm']['checkboxes'])) |
|
| 158 | + if ($this->action($_content['nm']['action'], $_content['nm']['selected'], $_content['nm']['select_all'], |
|
| 159 | + $success, $failed, $action_msg, 'index', $msg, $_content['nm']['checkboxes'])) |
|
| 160 | 160 | { |
| 161 | - $msg .= lang('%1 contact(s) %2',$success,$action_msg); |
|
| 161 | + $msg .= lang('%1 contact(s) %2', $success, $action_msg); |
|
| 162 | 162 | Framework::message($msg); |
| 163 | 163 | } |
| 164 | - elseif(is_null($msg)) |
|
| 164 | + elseif (is_null($msg)) |
|
| 165 | 165 | { |
| 166 | - $msg .= lang('%1 contact(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); |
|
| 167 | - Framework::message($msg,'error'); |
|
| 166 | + $msg .= lang('%1 contact(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed); |
|
| 167 | + Framework::message($msg, 'error'); |
|
| 168 | 168 | } |
| 169 | 169 | $msg = ''; |
| 170 | 170 | } |
@@ -184,9 +184,9 @@ discard block |
||
| 184 | 184 | } |
| 185 | 185 | $typeselection = $_content['nm']['col_filter']['tid']; |
| 186 | 186 | } |
| 187 | - elseif($_GET['add_list']) |
|
| 187 | + elseif ($_GET['add_list']) |
|
| 188 | 188 | { |
| 189 | - $list = $this->add_list($_GET['add_list'],$_GET['owner']?$_GET['owner']:$this->user); |
|
| 189 | + $list = $this->add_list($_GET['add_list'], $_GET['owner'] ? $_GET['owner'] : $this->user); |
|
| 190 | 190 | if ($list === true) |
| 191 | 191 | { |
| 192 | 192 | $msg = lang('List already exists!'); |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | } |
| 203 | 203 | $preserv = array(); |
| 204 | 204 | $content = array(); |
| 205 | - if($msg || $_GET['msg']) |
|
| 205 | + if ($msg || $_GET['msg']) |
|
| 206 | 206 | { |
| 207 | 207 | Framework::message($msg ? $msg : $_GET['msg']); |
| 208 | 208 | } |
@@ -211,23 +211,23 @@ discard block |
||
| 211 | 211 | if (!is_array($content['nm'])) |
| 212 | 212 | { |
| 213 | 213 | $content['nm'] = array( |
| 214 | - 'get_rows' => 'addressbook.addressbook_ui.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
| 215 | - 'bottom_too' => false, // I show the nextmatch-line (arrows, filters, search, ...) again after the rows |
|
| 216 | - 'never_hide' => True, // I never hide the nextmatch-line if less then maxmatch entrie |
|
| 217 | - 'start' => 0, // IO position in list |
|
| 218 | - 'cat_id' => '', // IO category, if not 'no_cat' => True |
|
| 219 | - 'search' => '', // IO search pattern |
|
| 220 | - 'order' => 'n_family', // IO name of the column to sort after (optional for the sortheaders) |
|
| 221 | - 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 222 | - 'col_filter' => array(), // IO array of column-name value pairs (optional for the filterheaders) |
|
| 214 | + 'get_rows' => 'addressbook.addressbook_ui.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
| 215 | + 'bottom_too' => false, // I show the nextmatch-line (arrows, filters, search, ...) again after the rows |
|
| 216 | + 'never_hide' => True, // I never hide the nextmatch-line if less then maxmatch entrie |
|
| 217 | + 'start' => 0, // IO position in list |
|
| 218 | + 'cat_id' => '', // IO category, if not 'no_cat' => True |
|
| 219 | + 'search' => '', // IO search pattern |
|
| 220 | + 'order' => 'n_family', // IO name of the column to sort after (optional for the sortheaders) |
|
| 221 | + 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 222 | + 'col_filter' => array(), // IO array of column-name value pairs (optional for the filterheaders) |
|
| 223 | 223 | //'cat_id_label' => lang('Categories'), |
| 224 | 224 | //'filter_label' => lang('Addressbook'), // I label for filter (optional) |
| 225 | - 'filter' => '', // =All // IO filter, if not 'no_filter' => True |
|
| 226 | - 'filter_no_lang' => True, // I set no_lang for filter (=dont translate the options) |
|
| 227 | - 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
| 225 | + 'filter' => '', // =All // IO filter, if not 'no_filter' => True |
|
| 226 | + 'filter_no_lang' => True, // I set no_lang for filter (=dont translate the options) |
|
| 227 | + 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
| 228 | 228 | //'filter2_label'=> lang('Distribution lists'), // IO filter2, if not 'no_filter2' => True |
| 229 | - 'filter2' => '', // IO filter2, if not 'no_filter2' => True |
|
| 230 | - 'filter2_no_lang'=> True, // I set no_lang for filter2 (=dont translate the options) |
|
| 229 | + 'filter2' => '', // IO filter2, if not 'no_filter2' => True |
|
| 230 | + 'filter2_no_lang'=> True, // I set no_lang for filter2 (=dont translate the options) |
|
| 231 | 231 | 'lettersearch' => true, |
| 232 | 232 | // using a positiv list now, as we constantly adding new columns in addressbook, but not removing them from default |
| 233 | 233 | 'default_cols' => 'type,n_fileas_n_given_n_family_n_family_n_given_org_name_n_family_n_given_n_fileas,'. |
@@ -248,14 +248,14 @@ discard block |
||
| 248 | 248 | // use the state of the last session stored in the user prefs |
| 249 | 249 | if (($state = @unserialize($this->prefs['index_state']))) |
| 250 | 250 | { |
| 251 | - $content['nm'] = array_merge($content['nm'],$state); |
|
| 251 | + $content['nm'] = array_merge($content['nm'], $state); |
|
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | $sel_options['cat_id'] = array('' => lang('All categories'), '0' => lang('None')); |
| 255 | 255 | |
| 256 | 256 | $content['nm']['placeholder_actions'] = array('add'); |
| 257 | 257 | // Edit and delete list actions depends on permissions |
| 258 | - if($this->get_lists(Acl::EDIT)) |
|
| 258 | + if ($this->get_lists(Acl::EDIT)) |
|
| 259 | 259 | { |
| 260 | 260 | $content['nm']['placeholder_actions'][] = 'rename_list'; |
| 261 | 261 | $content['nm']['placeholder_actions'][] = 'delete_list'; |
@@ -268,15 +268,15 @@ discard block |
||
| 268 | 268 | if (isset($typeselection)) $content['nm']['col_filter']['tid'] = $typeselection; |
| 269 | 269 | // save the tid for use in creating new addressbook entrys via UI. Current tid is to be used as type of new entrys |
| 270 | 270 | //error_log(__METHOD__.__LINE__.' '.$content['nm']['col_filter']['tid']); |
| 271 | - Api\Cache::setSession('addressbook','active_tid',$content['nm']['col_filter']['tid']); |
|
| 271 | + Api\Cache::setSession('addressbook', 'active_tid', $content['nm']['col_filter']['tid']); |
|
| 272 | 272 | if ($this->lists_available()) |
| 273 | 273 | { |
| 274 | - $sel_options['filter2'] = $this->get_lists(Acl::READ,array('' => lang('No distribution list'))); |
|
| 275 | - $sel_options['filter2']['add'] = lang('Add a new list').'...'; // put it at the end |
|
| 274 | + $sel_options['filter2'] = $this->get_lists(Acl::READ, array('' => lang('No distribution list'))); |
|
| 275 | + $sel_options['filter2']['add'] = lang('Add a new list').'...'; // put it at the end |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | // Organisation stuff is not (yet) availible with ldap |
| 279 | - if($GLOBALS['egw_info']['server']['contact_repository'] != 'ldap') |
|
| 279 | + if ($GLOBALS['egw_info']['server']['contact_repository'] != 'ldap') |
|
| 280 | 280 | { |
| 281 | 281 | $content['nm']['header_left'] = 'addressbook.index.left'; |
| 282 | 282 | } |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | $sel_options['adr_one_countrycode']['-custom-'] = lang('No country selected'); |
| 290 | 290 | |
| 291 | 291 | // if there is any export limit set, pass it on to the nextmatch, to be evaluated by the export |
| 292 | - if (isset($this->config['contact_export_limit']) && (int)$this->config['contact_export_limit']) $content['nm']['export_limit']=$this->config['contact_export_limit']; |
|
| 292 | + if (isset($this->config['contact_export_limit']) && (int)$this->config['contact_export_limit']) $content['nm']['export_limit'] = $this->config['contact_export_limit']; |
|
| 293 | 293 | |
| 294 | 294 | // Merge to email dialog needs the infolog types |
| 295 | 295 | $infolog = new infolog_bo(); |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | // dont show tid-selection if we have only one content_type |
| 299 | 299 | // be a bit more sophisticated about it |
| 300 | 300 | $availabletypes = array_keys($this->content_types); |
| 301 | - if ($content['nm']['col_filter']['tid'] && !in_array($content['nm']['col_filter']['tid'],$availabletypes)) |
|
| 301 | + if ($content['nm']['col_filter']['tid'] && !in_array($content['nm']['col_filter']['tid'], $availabletypes)) |
|
| 302 | 302 | { |
| 303 | 303 | //_debug_array(array('Typefilter:'=> $content['nm']['col_filter']['tid'],'Available Types:'=>$availabletypes,'action:'=>'remove invalid filter')); |
| 304 | 304 | unset($content['nm']['col_filter']['tid']); |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | if (!isset($content['nm']['col_filter']['tid'])) $content['nm']['col_filter']['tid'] = $availabletypes[0]; |
| 307 | 307 | if (count($this->content_types) > 1) |
| 308 | 308 | { |
| 309 | - foreach($this->content_types as $tid => $data) |
|
| 309 | + foreach ($this->content_types as $tid => $data) |
|
| 310 | 310 | { |
| 311 | 311 | $sel_options['tid'][$tid] = $data['name']; |
| 312 | 312 | } |
@@ -324,20 +324,20 @@ discard block |
||
| 324 | 324 | |
| 325 | 325 | $content['nm']['actions'] = $this->get_actions($content['nm']['col_filter']['tid']); |
| 326 | 326 | |
| 327 | - if (!isset($sel_options['grouped_view'][(string) $content['nm']['grouped_view']])) |
|
| 327 | + if (!isset($sel_options['grouped_view'][(string)$content['nm']['grouped_view']])) |
|
| 328 | 328 | { |
| 329 | 329 | $sel_options['grouped_view'] += $this->_get_grouped_name((string)$content['nm']['grouped_view']); |
| 330 | 330 | } |
| 331 | 331 | // unset the filters regarding grouped views, when there is no group selected |
| 332 | - if (empty($sel_options['grouped_view'][(string) $content['nm']['grouped_view']]) || stripos($grouped_view,":") === false ) |
|
| 332 | + if (empty($sel_options['grouped_view'][(string)$content['nm']['grouped_view']]) || stripos($grouped_view, ":") === false) |
|
| 333 | 333 | { |
| 334 | 334 | $this->unset_grouped_filters($content['nm']); |
| 335 | 335 | } |
| 336 | - $content['nm']['grouped_view_label'] = $sel_options['grouped_view'][(string) $content['nm']['grouped_view']]; |
|
| 336 | + $content['nm']['grouped_view_label'] = $sel_options['grouped_view'][(string)$content['nm']['grouped_view']]; |
|
| 337 | 337 | |
| 338 | 338 | $this->tmpl->read('addressbook.index'); |
| 339 | 339 | return $this->tmpl->exec('addressbook.addressbook_ui.index', |
| 340 | - $content,$sel_options,array(),$preserv); |
|
| 340 | + $content, $sel_options, array(), $preserv); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | /** |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | * @param string $tid_filter =null |
| 347 | 347 | * @return array see Etemplate\Widget\Nextmatch::get_actions() |
| 348 | 348 | */ |
| 349 | - public function get_actions($tid_filter=null) |
|
| 349 | + public function get_actions($tid_filter = null) |
|
| 350 | 350 | { |
| 351 | 351 | // Contact view |
| 352 | 352 | $actions = array( |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | 'caption' => 'CRM-View', |
| 355 | 355 | 'default' => $GLOBALS['egw_info']['user']['preferences']['addressbook']['crm_list'] != '~edit~', |
| 356 | 356 | 'allowOnMultiple' => false, |
| 357 | - 'group' => $group=1, |
|
| 357 | + 'group' => $group = 1, |
|
| 358 | 358 | 'onExecute' => 'javaScript:app.addressbook.view', |
| 359 | 359 | 'enableClass' => 'contact_contact', |
| 360 | 360 | 'hideOnDisabled' => true, |
@@ -397,14 +397,14 @@ discard block |
||
| 397 | 397 | ); |
| 398 | 398 | // CRM view options |
| 399 | 399 | $crm_count = 0; |
| 400 | - $crm_apps = array('infolog','tracker'); |
|
| 401 | - foreach($crm_apps as $app) |
|
| 400 | + $crm_apps = array('infolog', 'tracker'); |
|
| 401 | + foreach ($crm_apps as $app) |
|
| 402 | 402 | { |
| 403 | 403 | if ($GLOBALS['egw_info']['user']['apps'][$app]) $crm_count++; |
| 404 | 404 | } |
| 405 | - if($crm_count > 1) |
|
| 405 | + if ($crm_count > 1) |
|
| 406 | 406 | { |
| 407 | - foreach($crm_apps as $app) |
|
| 407 | + foreach ($crm_apps as $app) |
|
| 408 | 408 | { |
| 409 | 409 | $actions['view']['children']["view-$app"] = array( |
| 410 | 410 | 'caption' => $app, |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | 'caption' => 'View', |
| 420 | 420 | 'default' => true, |
| 421 | 421 | 'allowOnMultiple' => false, |
| 422 | - 'group' => $group=1, |
|
| 422 | + 'group' => $group = 1, |
|
| 423 | 423 | 'enableClass' => 'contact_organisation', |
| 424 | 424 | 'hideOnDisabled' => true |
| 425 | 425 | ), |
@@ -440,29 +440,29 @@ discard block |
||
| 440 | 440 | 'caption' => 'View', |
| 441 | 441 | 'default' => true, |
| 442 | 442 | 'allowOnMultiple' => false, |
| 443 | - 'group' => $group=1, |
|
| 443 | + 'group' => $group = 1, |
|
| 444 | 444 | 'enableClass' => 'contact_duplicate', |
| 445 | 445 | 'hideOnDisabled' => true |
| 446 | 446 | ) |
| 447 | 447 | ); |
| 448 | 448 | |
| 449 | - ++$group; // other AB related stuff group: lists, AB's, categories |
|
| 449 | + ++$group; // other AB related stuff group: lists, AB's, categories |
|
| 450 | 450 | // categories submenu |
| 451 | 451 | $actions['cat'] = array( |
| 452 | 452 | 'caption' => 'Categories', |
| 453 | 453 | 'group' => $group, |
| 454 | 454 | 'children' => array( |
| 455 | 455 | 'cat_add' => Etemplate\Widget\Nextmatch::category_action( |
| 456 | - 'addressbook',$group,'Add category', 'cat_add_', |
|
| 457 | - true, 0,Etemplate\Widget\Nextmatch::DEFAULT_MAX_MENU_LENGTH,false |
|
| 458 | - )+array( |
|
| 456 | + 'addressbook', $group, 'Add category', 'cat_add_', |
|
| 457 | + true, 0, Etemplate\Widget\Nextmatch::DEFAULT_MAX_MENU_LENGTH, false |
|
| 458 | + ) + array( |
|
| 459 | 459 | 'icon' => 'foldertree_nolines_plus', |
| 460 | 460 | 'disableClass' => 'rowNoEdit', |
| 461 | 461 | ), |
| 462 | 462 | 'cat_del' => Etemplate\Widget\Nextmatch::category_action( |
| 463 | - 'addressbook',$group,'Delete category', 'cat_del_', |
|
| 464 | - true, 0,Etemplate\Widget\Nextmatch::DEFAULT_MAX_MENU_LENGTH,false |
|
| 465 | - )+array( |
|
| 463 | + 'addressbook', $group, 'Delete category', 'cat_del_', |
|
| 464 | + true, 0, Etemplate\Widget\Nextmatch::DEFAULT_MAX_MENU_LENGTH, false |
|
| 465 | + ) + array( |
|
| 466 | 466 | 'icon' => 'foldertree_nolines_minus', |
| 467 | 467 | 'disableClass' => 'rowNoEdit', |
| 468 | 468 | ), |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | 'children' => $add_lists, |
| 490 | 490 | 'prefix' => 'to_list_', |
| 491 | 491 | 'icon' => 'foldertree_nolines_plus', |
| 492 | - 'enabled' => ($add_lists?true:false), // if there are editable lists, allow to add a contact to one of them, |
|
| 492 | + 'enabled' => ($add_lists ?true:false), // if there are editable lists, allow to add a contact to one of them, |
|
| 493 | 493 | //'disableClass' => 'rowNoEdit', // wether you are allowed to edit the contact or not, as you alter a list, not the contact |
| 494 | 494 | ), |
| 495 | 495 | 'remove_from_list' => array( |
@@ -498,14 +498,14 @@ discard block |
||
| 498 | 498 | 'icon' => 'foldertree_nolines_minus', |
| 499 | 499 | 'enabled' => 'javaScript:app.addressbook.nm_compare_field', |
| 500 | 500 | 'fieldId' => 'exec[nm][filter2]', |
| 501 | - 'fieldValue' => '!', // enable if list != '' |
|
| 501 | + 'fieldValue' => '!', // enable if list != '' |
|
| 502 | 502 | ), |
| 503 | 503 | 'rename_list' => array( |
| 504 | 504 | 'caption' => 'Rename selected distribution list', |
| 505 | 505 | 'icon' => 'edit', |
| 506 | 506 | 'enabled' => 'javaScript:app.addressbook.nm_compare_field', |
| 507 | 507 | 'fieldId' => 'exec[nm][filter2]', |
| 508 | - 'fieldValue' => '!', // enable if list != '' |
|
| 508 | + 'fieldValue' => '!', // enable if list != '' |
|
| 509 | 509 | 'onExecute' => 'javaScript:app.addressbook.rename_list' |
| 510 | 510 | ), |
| 511 | 511 | 'delete_list' => array( |
@@ -514,10 +514,10 @@ discard block |
||
| 514 | 514 | 'icon' => 'delete', |
| 515 | 515 | 'enabled' => 'javaScript:app.addressbook.nm_compare_field', |
| 516 | 516 | 'fieldId' => 'exec[nm][filter2]', |
| 517 | - 'fieldValue' => '!', // enable if list != '' |
|
| 517 | + 'fieldValue' => '!', // enable if list != '' |
|
| 518 | 518 | ), |
| 519 | 519 | ); |
| 520 | - if(is_subclass_of('etemplate', 'etemplate_new')) |
|
| 520 | + if (is_subclass_of('etemplate', 'etemplate_new')) |
|
| 521 | 521 | { |
| 522 | 522 | $actions['lists']['children']['remove_from_list']['fieldId'] = 'filter2'; |
| 523 | 523 | $actions['lists']['children']['rename_list']['fieldId'] = 'filter2'; |
@@ -527,18 +527,18 @@ discard block |
||
| 527 | 527 | // move to AB |
| 528 | 528 | if (($move2addressbooks = $this->get_addressbooks(Acl::ADD))) // do we have addressbooks, we should |
| 529 | 529 | { |
| 530 | - unset($move2addressbooks[0]); // do not offer action to move contact to an account, as we dont support that currrently |
|
| 531 | - foreach($move2addressbooks as $owner => $label) |
|
| 530 | + unset($move2addressbooks[0]); // do not offer action to move contact to an account, as we dont support that currrently |
|
| 531 | + foreach ($move2addressbooks as $owner => $label) |
|
| 532 | 532 | { |
| 533 | 533 | $icon = $type_label = null; |
| 534 | - $this->type_icon((int)$owner, substr($owner,-1) == 'p', 'n', $icon, $type_label); |
|
| 534 | + $this->type_icon((int)$owner, substr($owner, -1) == 'p', 'n', $icon, $type_label); |
|
| 535 | 535 | $move2addressbooks[$owner] = array( |
| 536 | 536 | 'icon' => $icon, |
| 537 | 537 | 'caption' => $label, |
| 538 | 538 | ); |
| 539 | 539 | } |
| 540 | 540 | // copy checkbox |
| 541 | - $move2addressbooks= array( |
|
| 541 | + $move2addressbooks = array( |
|
| 542 | 542 | 'copy' =>array( |
| 543 | 543 | 'id' => 'move_to_copy', |
| 544 | 544 | 'caption' => 'Copy instead of move', |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | 'hideOnDisabled' => true |
| 572 | 572 | ); |
| 573 | 573 | |
| 574 | - ++$group; // integration with other apps: infolog, calendar, filemanager, messenger |
|
| 574 | + ++$group; // integration with other apps: infolog, calendar, filemanager, messenger |
|
| 575 | 575 | |
| 576 | 576 | // Integrate Messenger app actions for adding new buddy into roster list |
| 577 | 577 | if ($GLOBALS['egw_info']['user']['apps']['messenger']) |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | 'icon' => 'new', |
| 613 | 613 | 'url' => 'menuaction=infolog.infolog_ui.edit&type=task&action=addressbook&action_id=$id', |
| 614 | 614 | 'popup' => Link::get_registry('infolog', 'add_popup'), |
| 615 | - 'onExecute' => 'javaScript:app.addressbook.add_task', // call server for org-view only |
|
| 615 | + 'onExecute' => 'javaScript:app.addressbook.add_task', // call server for org-view only |
|
| 616 | 616 | ), |
| 617 | 617 | ), |
| 618 | 618 | 'hideOnMobile' => true |
@@ -630,7 +630,7 @@ discard block |
||
| 630 | 630 | 'caption' => 'Show', |
| 631 | 631 | 'icon' => 'view', |
| 632 | 632 | 'onExecute' => 'javaScript:app.addressbook.view_calendar', |
| 633 | - 'targetapp' => 'calendar', // open in calendar tab, |
|
| 633 | + 'targetapp' => 'calendar', // open in calendar tab, |
|
| 634 | 634 | 'hideOnDisabled' => true, |
| 635 | 635 | ), |
| 636 | 636 | 'calendar_add' => array( |
@@ -710,7 +710,7 @@ discard block |
||
| 710 | 710 | 'icon' => 'map', |
| 711 | 711 | 'group' => ++$group, |
| 712 | 712 | 'enableClass' => 'contact_contact', |
| 713 | - 'children' => array ( |
|
| 713 | + 'children' => array( |
|
| 714 | 714 | 'private' => array( |
| 715 | 715 | 'caption' => 'Private Address', |
| 716 | 716 | 'enabled' => 'javaScript:app.addressbook.geoLocation_enabled', |
@@ -729,7 +729,7 @@ discard block |
||
| 729 | 729 | |
| 730 | 730 | // check if user is an admin or the export is not generally turned off (contact_export_limit is non-numerical, eg. no) |
| 731 | 731 | $exception = Api\Storage\Merge::is_export_limit_excepted(); |
| 732 | - if ((isset($GLOBALS['egw_info']['user']['apps']['admin']) || $exception) || !$this->config['contact_export_limit'] || (int)$this->config['contact_export_limit']) |
|
| 732 | + if ((isset($GLOBALS['egw_info']['user']['apps']['admin']) || $exception) || !$this->config['contact_export_limit'] || (int)$this->config['contact_export_limit']) |
|
| 733 | 733 | { |
| 734 | 734 | $actions['export'] = array( |
| 735 | 735 | 'caption' => 'Export', |
@@ -745,7 +745,7 @@ discard block |
||
| 745 | 745 | ), |
| 746 | 746 | 'vcard' => array( |
| 747 | 747 | 'caption' => 'Export as VCard', |
| 748 | - 'postSubmit' => true, // download needs post submit (not Ajax) to work |
|
| 748 | + 'postSubmit' => true, // download needs post submit (not Ajax) to work |
|
| 749 | 749 | 'icon' => Vfs::mime_icon('text/vcard'), |
| 750 | 750 | ), |
| 751 | 751 | ), |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | $this->prefs['document_dir'], $group, 'Insert in document', 'document_', |
| 758 | 758 | $this->prefs['default_document'], $this->config['contact_export_limit'] |
| 759 | 759 | ); |
| 760 | - if ($GLOBALS['egw_info']['user']['apps']['felamimail']||$GLOBALS['egw_info']['user']['apps']['mail']) |
|
| 760 | + if ($GLOBALS['egw_info']['user']['apps']['felamimail'] || $GLOBALS['egw_info']['user']['apps']['mail']) |
|
| 761 | 761 | { |
| 762 | 762 | $actions['mail'] = array( |
| 763 | 763 | 'caption' => lang('Mail VCard'), |
@@ -781,7 +781,7 @@ discard block |
||
| 781 | 781 | 'disableClass' => 'rowNoDelete', |
| 782 | 782 | ); |
| 783 | 783 | } |
| 784 | - if ($this->grants[0] & Acl::DELETE) |
|
| 784 | + if ($this->grants[0]&Acl::DELETE) |
|
| 785 | 785 | { |
| 786 | 786 | $actions['delete_account'] = array( |
| 787 | 787 | 'caption' => 'Delete', |
@@ -794,7 +794,7 @@ discard block |
||
| 794 | 794 | ); |
| 795 | 795 | $actions['delete']['hideOnDisabled'] = true; |
| 796 | 796 | } |
| 797 | - if($tid_filter == 'D') |
|
| 797 | + if ($tid_filter == 'D') |
|
| 798 | 798 | { |
| 799 | 799 | $actions['undelete'] = array( |
| 800 | 800 | 'caption' => 'Un-delete', |
@@ -805,7 +805,7 @@ discard block |
||
| 805 | 805 | } |
| 806 | 806 | if (isset($actions['export']['children']['csv']) && |
| 807 | 807 | (!isset($GLOBALS['egw_info']['user']['apps']['importexport']) || |
| 808 | - !importexport_helper_functions::has_definitions('addressbook','export'))) |
|
| 808 | + !importexport_helper_functions::has_definitions('addressbook', 'export'))) |
|
| 809 | 809 | { |
| 810 | 810 | unset($actions['export']['children']['csv']); |
| 811 | 811 | } |
@@ -838,13 +838,13 @@ discard block |
||
| 838 | 838 | protected function _get_grouped_name($view_id) |
| 839 | 839 | { |
| 840 | 840 | $group_name = array(); |
| 841 | - if (strpos($view_id,'*AND*')!== false) $view_id = str_replace('*AND*','&',$view_id); |
|
| 842 | - foreach(explode('|||',$view_id) as $part) |
|
| 841 | + if (strpos($view_id, '*AND*') !== false) $view_id = str_replace('*AND*', '&', $view_id); |
|
| 842 | + foreach (explode('|||', $view_id) as $part) |
|
| 843 | 843 | { |
| 844 | - list(,$name) = explode(':',$part,2); |
|
| 844 | + list(,$name) = explode(':', $part, 2); |
|
| 845 | 845 | if ($name) $group_name[] = $name; |
| 846 | 846 | } |
| 847 | - $name = implode(': ',$group_name); |
|
| 847 | + $name = implode(': ', $group_name); |
|
| 848 | 848 | return $name ? array($view_id => $name) : array(); |
| 849 | 849 | } |
| 850 | 850 | |
@@ -858,7 +858,7 @@ discard block |
||
| 858 | 858 | unset($query['col_filter']['org_name']); |
| 859 | 859 | unset($query['col_filter']['org_unit']); |
| 860 | 860 | unset($query['col_filter']['adr_one_locality']); |
| 861 | - foreach(array_keys(static::$duplicate_fields) as $field) |
|
| 861 | + foreach (array_keys(static::$duplicate_fields) as $field) |
|
| 862 | 862 | { |
| 863 | 863 | unset($query['col_filter'][$field]); |
| 864 | 864 | } |
@@ -876,7 +876,7 @@ discard block |
||
| 876 | 876 | // Query doesn't like empties |
| 877 | 877 | unset($query['col_filter']['parent_id']); |
| 878 | 878 | |
| 879 | - if($query['actions'] && $query['actions']['open']) |
|
| 879 | + if ($query['actions'] && $query['actions']['open']) |
|
| 880 | 880 | { |
| 881 | 881 | // Just switched from contact view, update actions |
| 882 | 882 | $query['actions'] = $this->get_actions($query['col_filter']['tid']); |
@@ -904,10 +904,10 @@ discard block |
||
| 904 | 904 | } |
| 905 | 905 | $query['org_view'] = $query['grouped_view']; |
| 906 | 906 | // switch the distribution list selection off for ldap |
| 907 | - if($this->contact_repository != 'sql') |
|
| 907 | + if ($this->contact_repository != 'sql') |
|
| 908 | 908 | { |
| 909 | 909 | $query['no_filter2'] = true; |
| 910 | - unset($query['col_filter']['list']); // does not work here |
|
| 910 | + unset($query['col_filter']['list']); // does not work here |
|
| 911 | 911 | } |
| 912 | 912 | else |
| 913 | 913 | { |
@@ -915,8 +915,8 @@ discard block |
||
| 915 | 915 | } |
| 916 | 916 | break; |
| 917 | 917 | case 'addressbook.index.duplicate_rows': |
| 918 | - $query['no_filter2'] = true; // switch the distribution list selection off |
|
| 919 | - unset($query['col_filter']['list']); // does not work for duplicates |
|
| 918 | + $query['no_filter2'] = true; // switch the distribution list selection off |
|
| 919 | + unset($query['col_filter']['list']); // does not work for duplicates |
|
| 920 | 920 | $rows = parent::duplicates($query); |
| 921 | 921 | break; |
| 922 | 922 | } |
@@ -943,19 +943,19 @@ discard block |
||
| 943 | 943 | { |
| 944 | 944 | $org_contacts = array(); |
| 945 | 945 | $query = !$_query ? Api\Cache::getSession('addressbook', 'index') : $_query; |
| 946 | - $query['num_rows'] = -1; // all |
|
| 947 | - if(!is_array($query['col_filter'])) $query['col_filter'] = array(); |
|
| 946 | + $query['num_rows'] = -1; // all |
|
| 947 | + if (!is_array($query['col_filter'])) $query['col_filter'] = array(); |
|
| 948 | 948 | |
| 949 | - if(!is_array($org)) $org = array($org); |
|
| 950 | - foreach($org as $org_name) |
|
| 949 | + if (!is_array($org)) $org = array($org); |
|
| 950 | + foreach ($org as $org_name) |
|
| 951 | 951 | { |
| 952 | 952 | $query['grouped_view'] = $org_name; |
| 953 | 953 | $checked = array(); |
| 954 | 954 | $readonlys = null; |
| 955 | - $this->get_rows($query,$checked,$readonlys,true); // true = only return the id's |
|
| 956 | - if($checked[0]) |
|
| 955 | + $this->get_rows($query, $checked, $readonlys, true); // true = only return the id's |
|
| 956 | + if ($checked[0]) |
|
| 957 | 957 | { |
| 958 | - $org_contacts = array_merge($org_contacts,$checked); |
|
| 958 | + $org_contacts = array_merge($org_contacts, $checked); |
|
| 959 | 959 | } |
| 960 | 960 | } |
| 961 | 961 | Api\Json\Response::get()->data(array_unique($org_contacts)); |
@@ -969,33 +969,33 @@ discard block |
||
| 969 | 969 | function infolog_org_view($org) |
| 970 | 970 | { |
| 971 | 971 | $query = Api\Cache::getSession('addressbook', 'index'); |
| 972 | - $query['num_rows'] = -1; // all |
|
| 972 | + $query['num_rows'] = -1; // all |
|
| 973 | 973 | $query['grouped_view'] = $org; |
| 974 | 974 | $query['searchletter'] = ''; |
| 975 | 975 | $checked = $readonlys = null; |
| 976 | - $this->get_rows($query,$checked,$readonlys,true); // true = only return the id's |
|
| 976 | + $this->get_rows($query, $checked, $readonlys, true); // true = only return the id's |
|
| 977 | 977 | |
| 978 | 978 | if (count($checked) > 1) // use a nicely formatted org-name as title in infolog |
| 979 | 979 | { |
| 980 | 980 | $parts = array(); |
| 981 | - if (strpos($org,'*AND*')!== false) $org = str_replace('*AND*','&',$org); |
|
| 982 | - foreach(explode('|||',$org) as $part) |
|
| 981 | + if (strpos($org, '*AND*') !== false) $org = str_replace('*AND*', '&', $org); |
|
| 982 | + foreach (explode('|||', $org) as $part) |
|
| 983 | 983 | { |
| 984 | - list(,$part) = explode(':',$part,2); |
|
| 984 | + list(,$part) = explode(':', $part, 2); |
|
| 985 | 985 | if ($part) $parts[] = $part; |
| 986 | 986 | } |
| 987 | - $org = implode(', ',$parts); |
|
| 987 | + $org = implode(', ', $parts); |
|
| 988 | 988 | } |
| 989 | 989 | else |
| 990 | 990 | { |
| 991 | - $org = ''; // use infolog default of link-title |
|
| 991 | + $org = ''; // use infolog default of link-title |
|
| 992 | 992 | } |
| 993 | - Egw::redirect_link('/index.php',array( |
|
| 993 | + Egw::redirect_link('/index.php', array( |
|
| 994 | 994 | 'menuaction' => 'infolog.infolog_ui.index', |
| 995 | 995 | 'action' => 'addressbook', |
| 996 | - 'action_id' => implode(',',$checked), |
|
| 996 | + 'action_id' => implode(',', $checked), |
|
| 997 | 997 | 'action_title' => $org, |
| 998 | - ),'infolog'); |
|
| 998 | + ), 'infolog'); |
|
| 999 | 999 | } |
| 1000 | 1000 | |
| 1001 | 1001 | /** |
@@ -1020,31 +1020,31 @@ discard block |
||
| 1020 | 1020 | $owner = $this->default_addressbook; |
| 1021 | 1021 | } |
| 1022 | 1022 | // Check for valid list & permissions |
| 1023 | - if(!(int)$list_id && !$this->check_list(null,EGW_ACL_ADD|EGW_ACL_EDIT,$owner)) |
|
| 1023 | + if (!(int)$list_id && !$this->check_list(null, EGW_ACL_ADD|EGW_ACL_EDIT, $owner)) |
|
| 1024 | 1024 | { |
| 1025 | - Api\Json\Response::get()->apply('egw.message', array( lang('List creation failed, no rights!'),'error')); |
|
| 1025 | + Api\Json\Response::get()->apply('egw.message', array(lang('List creation failed, no rights!'), 'error')); |
|
| 1026 | 1026 | return; |
| 1027 | 1027 | } |
| 1028 | 1028 | if ((int)$list_id && !$this->check_list((int)$list_id, Acl::EDIT, $owner)) |
| 1029 | 1029 | { |
| 1030 | - Api\Json\Response::get()->apply('egw.message', array( lang('Insufficent rights to edit this list!'),'error')); |
|
| 1030 | + Api\Json\Response::get()->apply('egw.message', array(lang('Insufficent rights to edit this list!'), 'error')); |
|
| 1031 | 1031 | return; |
| 1032 | 1032 | } |
| 1033 | 1033 | |
| 1034 | 1034 | $list = array('list_owner' => $owner); |
| 1035 | 1035 | |
| 1036 | 1036 | // Rename |
| 1037 | - if($list_id) |
|
| 1037 | + if ($list_id) |
|
| 1038 | 1038 | { |
| 1039 | 1039 | $list = $this->read_list((int)$list_id); |
| 1040 | 1040 | } |
| 1041 | 1041 | $list['list_name'] = $new_name; |
| 1042 | 1042 | |
| 1043 | - $new_id = $this->add_list(array('list_id' => (int)$list_id), $list['list_owner'],array(),$list); |
|
| 1043 | + $new_id = $this->add_list(array('list_id' => (int)$list_id), $list['list_owner'], array(), $list); |
|
| 1044 | 1044 | |
| 1045 | - if($contacts) |
|
| 1045 | + if ($contacts) |
|
| 1046 | 1046 | { |
| 1047 | - $this->add2list($contacts,$new_id); |
|
| 1047 | + $this->add2list($contacts, $new_id); |
|
| 1048 | 1048 | } |
| 1049 | 1049 | Api\Json\Response::get()->apply('egw.message', array( |
| 1050 | 1050 | $new_id == $list_id ? lang('Distribution list renamed') : lang('List created'), |
@@ -1059,7 +1059,7 @@ discard block |
||
| 1059 | 1059 | * |
| 1060 | 1060 | * @param string $account_id |
| 1061 | 1061 | */ |
| 1062 | - function ajax_get_contact ($account_id) |
|
| 1062 | + function ajax_get_contact($account_id) |
|
| 1063 | 1063 | { |
| 1064 | 1064 | $bo = new Api\Contacts(); |
| 1065 | 1065 | $contact = $bo->read('account:'.$account_id); |
@@ -1076,7 +1076,7 @@ discard block |
||
| 1076 | 1076 | { |
| 1077 | 1077 | $query = Api\Cache::getSession('addressbook', 'index'); |
| 1078 | 1078 | unset($query['advanced_search']); |
| 1079 | - Api\Cache::setSession('addressbook','index',$query); |
|
| 1079 | + Api\Cache::setSession('addressbook', 'index', $query); |
|
| 1080 | 1080 | Api\Cache::setSession('addressbook', 'advanced_search', false); |
| 1081 | 1081 | } |
| 1082 | 1082 | |
@@ -1092,60 +1092,60 @@ discard block |
||
| 1092 | 1092 | * @param string/array $session_name 'index' or array with session-data depending if we are in the main list or the popup |
| 1093 | 1093 | * @return boolean true if all actions succeded, false otherwise |
| 1094 | 1094 | */ |
| 1095 | - function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg, $checkboxes = NULL) |
|
| 1095 | + function action($action, $checked, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg, $checkboxes = NULL) |
|
| 1096 | 1096 | { |
| 1097 | 1097 | //echo "<p>uicontacts::action('$action',".print_r($checked,true).','.(int)$use_all.",...)</p>\n"; |
| 1098 | 1098 | $success = $failed = 0; |
| 1099 | - if ($use_all || in_array($action,array('remove_from_list','delete_list'))) |
|
| 1099 | + if ($use_all || in_array($action, array('remove_from_list', 'delete_list'))) |
|
| 1100 | 1100 | { |
| 1101 | 1101 | // get the whole selection |
| 1102 | 1102 | $query = is_array($session_name) ? $session_name : Api\Cache::getSession('addressbook', $session_name); |
| 1103 | 1103 | |
| 1104 | 1104 | if ($use_all) |
| 1105 | 1105 | { |
| 1106 | - @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
| 1107 | - $query['num_rows'] = -1; // all |
|
| 1106 | + @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
| 1107 | + $query['num_rows'] = -1; // all |
|
| 1108 | 1108 | $readonlys = null; |
| 1109 | - $this->get_rows($query,$checked,$readonlys,true); // true = only return the id's |
|
| 1109 | + $this->get_rows($query, $checked, $readonlys, true); // true = only return the id's |
|
| 1110 | 1110 | } |
| 1111 | 1111 | } |
| 1112 | 1112 | // replace org_name:* id's with all id's of that org |
| 1113 | - $grouped_contacts = $this->find_grouped_ids($action, $checked, $use_all, $success,$failed,$action_msg,$session_name, $msg); |
|
| 1114 | - if ($grouped_contacts) $checked = array_unique($checked ? array_merge($checked,$grouped_contacts) : $grouped_contacts); |
|
| 1113 | + $grouped_contacts = $this->find_grouped_ids($action, $checked, $use_all, $success, $failed, $action_msg, $session_name, $msg); |
|
| 1114 | + if ($grouped_contacts) $checked = array_unique($checked ? array_merge($checked, $grouped_contacts) : $grouped_contacts); |
|
| 1115 | 1115 | //_debug_array($checked); exit; |
| 1116 | 1116 | |
| 1117 | - if (substr($action,0,8) == 'move_to_') |
|
| 1117 | + if (substr($action, 0, 8) == 'move_to_') |
|
| 1118 | 1118 | { |
| 1119 | - $action = (int)substr($action,8).(substr($action,-1) == 'p' ? 'p' : ''); |
|
| 1119 | + $action = (int)substr($action, 8).(substr($action, -1) == 'p' ? 'p' : ''); |
|
| 1120 | 1120 | } |
| 1121 | - elseif (substr($action,0,8) == 'to_list_') |
|
| 1121 | + elseif (substr($action, 0, 8) == 'to_list_') |
|
| 1122 | 1122 | { |
| 1123 | - $to_list = (int)substr($action,8); |
|
| 1123 | + $to_list = (int)substr($action, 8); |
|
| 1124 | 1124 | $action = 'to_list'; |
| 1125 | 1125 | } |
| 1126 | - elseif (substr($action,0,9) == 'document_') |
|
| 1126 | + elseif (substr($action, 0, 9) == 'document_') |
|
| 1127 | 1127 | { |
| 1128 | - $document = substr($action,9); |
|
| 1128 | + $document = substr($action, 9); |
|
| 1129 | 1129 | $action = 'document'; |
| 1130 | 1130 | } |
| 1131 | - elseif(substr($action,0,4) == 'cat_') // cat_add_123 or cat_del_456 |
|
| 1131 | + elseif (substr($action, 0, 4) == 'cat_') // cat_add_123 or cat_del_456 |
|
| 1132 | 1132 | { |
| 1133 | 1133 | $cat_id = (int)substr($action, 8); |
| 1134 | - $action = substr($action,0,7); |
|
| 1134 | + $action = substr($action, 0, 7); |
|
| 1135 | 1135 | } |
| 1136 | 1136 | // Security: stop non-admins to export more then the configured number of contacts |
| 1137 | - if (in_array($action,array('csv','vcard')) && $this->config['contact_export_limit'] && !Api\Storage\Merge::is_export_limit_excepted() && |
|
| 1137 | + if (in_array($action, array('csv', 'vcard')) && $this->config['contact_export_limit'] && !Api\Storage\Merge::is_export_limit_excepted() && |
|
| 1138 | 1138 | (!is_numeric($this->config['contact_export_limit']) || count($checked) > $this->config['contact_export_limit'])) |
| 1139 | 1139 | { |
| 1140 | 1140 | $action_msg = lang('exported'); |
| 1141 | 1141 | $failed = count($checked); |
| 1142 | 1142 | return false; |
| 1143 | 1143 | } |
| 1144 | - switch($action) |
|
| 1144 | + switch ($action) |
|
| 1145 | 1145 | { |
| 1146 | 1146 | case 'vcard': |
| 1147 | 1147 | $action_msg = lang('exported'); |
| 1148 | - $vcard = new addressbook_vcal('addressbook','text/vcard'); |
|
| 1148 | + $vcard = new addressbook_vcal('addressbook', 'text/vcard'); |
|
| 1149 | 1149 | $vcard->export($checked); |
| 1150 | 1150 | // does not return! |
| 1151 | 1151 | $Ok = false; |
@@ -1153,10 +1153,10 @@ discard block |
||
| 1153 | 1153 | |
| 1154 | 1154 | case 'merge': |
| 1155 | 1155 | $error_msg = null; |
| 1156 | - $success = $this->merge($checked,$error_msg); |
|
| 1156 | + $success = $this->merge($checked, $error_msg); |
|
| 1157 | 1157 | $failed = count($checked) - (int)$success; |
| 1158 | 1158 | $action_msg = lang('merged'); |
| 1159 | - $checked = array(); // to not start the single actions |
|
| 1159 | + $checked = array(); // to not start the single actions |
|
| 1160 | 1160 | break; |
| 1161 | 1161 | |
| 1162 | 1162 | case 'delete_list': |
@@ -1164,7 +1164,7 @@ discard block |
||
| 1164 | 1164 | { |
| 1165 | 1165 | $msg = lang('You need to select a distribution list'); |
| 1166 | 1166 | } |
| 1167 | - elseif($this->delete_list($query['filter2']) === false) |
|
| 1167 | + elseif ($this->delete_list($query['filter2']) === false) |
|
| 1168 | 1168 | { |
| 1169 | 1169 | $msg = lang('Insufficent rights to delete this list!'); |
| 1170 | 1170 | } |
@@ -1184,49 +1184,49 @@ discard block |
||
| 1184 | 1184 | return false; |
| 1185 | 1185 | |
| 1186 | 1186 | case 'infolog_add': |
| 1187 | - Framework::popup(Egw::link('/index.php',array( |
|
| 1187 | + Framework::popup(Egw::link('/index.php', array( |
|
| 1188 | 1188 | 'menuaction' => 'infolog.infolog_ui.edit', |
| 1189 | 1189 | 'type' => 'task', |
| 1190 | 1190 | 'action' => 'addressbook', |
| 1191 | - 'action_id' => implode(',',$checked), |
|
| 1192 | - )),'_blank',Link::get_registry('infolog', 'add_popup')); |
|
| 1193 | - $msg = ''; // no message, as we send none in javascript too and users sees opening popup |
|
| 1191 | + 'action_id' => implode(',', $checked), |
|
| 1192 | + )), '_blank', Link::get_registry('infolog', 'add_popup')); |
|
| 1193 | + $msg = ''; // no message, as we send none in javascript too and users sees opening popup |
|
| 1194 | 1194 | return false; |
| 1195 | 1195 | |
| 1196 | 1196 | case 'calendar_add': // add appointment for org-views, other views are handled directly in javascript |
| 1197 | - Framework::popup(Egw::link('/index.php',array( |
|
| 1197 | + Framework::popup(Egw::link('/index.php', array( |
|
| 1198 | 1198 | 'menuaction' => 'calendar.calendar_uiforms.edit', |
| 1199 | - 'participants' => 'c'.implode(',c',$checked), |
|
| 1200 | - )),'_blank',Link::get_registry('calendar', 'add_popup')); |
|
| 1201 | - $msg = ''; // no message, as we send none in javascript too and users sees opening popup |
|
| 1199 | + 'participants' => 'c'.implode(',c', $checked), |
|
| 1200 | + )), '_blank', Link::get_registry('calendar', 'add_popup')); |
|
| 1201 | + $msg = ''; // no message, as we send none in javascript too and users sees opening popup |
|
| 1202 | 1202 | return false; |
| 1203 | 1203 | |
| 1204 | 1204 | case 'calendar_view': // show calendar for org-views, although all views are handled directly in javascript |
| 1205 | - Egw::redirect_link('/index.php',array( |
|
| 1205 | + Egw::redirect_link('/index.php', array( |
|
| 1206 | 1206 | 'menuaction' => 'calendar.calendar_uiviews.index', |
| 1207 | - 'owner' => 'c'.implode(',c',$checked), |
|
| 1207 | + 'owner' => 'c'.implode(',c', $checked), |
|
| 1208 | 1208 | )); |
| 1209 | 1209 | } |
| 1210 | - foreach($checked as $id) |
|
| 1210 | + foreach ($checked as $id) |
|
| 1211 | 1211 | { |
| 1212 | - switch($action) |
|
| 1212 | + switch ($action) |
|
| 1213 | 1213 | { |
| 1214 | 1214 | case 'cat_add': |
| 1215 | 1215 | case 'cat_del': |
| 1216 | - if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::EDIT,$contact))) |
|
| 1216 | + if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::EDIT, $contact))) |
|
| 1217 | 1217 | { |
| 1218 | 1218 | $action_msg = $action == 'cat_add' ? lang('categorie added') : lang('categorie delete'); |
| 1219 | - $cat_ids = $contact['cat_id'] ? explode(',', $contact['cat_id']) : array(); //existing Api\Categories |
|
| 1219 | + $cat_ids = $contact['cat_id'] ? explode(',', $contact['cat_id']) : array(); //existing Api\Categories |
|
| 1220 | 1220 | if ($action == 'cat_add') |
| 1221 | 1221 | { |
| 1222 | 1222 | $cat_ids[] = $cat_id; |
| 1223 | 1223 | $cat_ids = array_unique($cat_ids); |
| 1224 | 1224 | } |
| 1225 | - elseif ((($key = array_search($cat_id,$cat_ids))) !== false) |
|
| 1225 | + elseif ((($key = array_search($cat_id, $cat_ids))) !== false) |
|
| 1226 | 1226 | { |
| 1227 | 1227 | unset($cat_ids[$key]); |
| 1228 | 1228 | } |
| 1229 | - $ids = $cat_ids ? implode(',',$cat_ids) : null; |
|
| 1229 | + $ids = $cat_ids ? implode(',', $cat_ids) : null; |
|
| 1230 | 1230 | if ($ids !== $contact['cat_id']) |
| 1231 | 1231 | { |
| 1232 | 1232 | $contact['cat_id'] = $ids; |
@@ -1237,10 +1237,10 @@ discard block |
||
| 1237 | 1237 | |
| 1238 | 1238 | case 'delete': |
| 1239 | 1239 | $action_msg = lang('deleted'); |
| 1240 | - if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE,$contact))) |
|
| 1240 | + if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE, $contact))) |
|
| 1241 | 1241 | { |
| 1242 | - if ($contact['owner'] || // regular contact or |
|
| 1243 | - empty($contact['account_id']) || // accounts without account_id |
|
| 1242 | + if ($contact['owner'] || // regular contact or |
|
| 1243 | + empty($contact['account_id']) || // accounts without account_id |
|
| 1244 | 1244 | // already deleted account (should no longer happen, but needed to allow for cleanup) |
| 1245 | 1245 | $contact['tid'] == self::DELETED_TYPE) |
| 1246 | 1246 | { |
@@ -1249,7 +1249,7 @@ discard block |
||
| 1249 | 1249 | // delete single account --> redirect to admin |
| 1250 | 1250 | elseif (count($checked) == 1 && $contact['account_id']) |
| 1251 | 1251 | { |
| 1252 | - Egw::redirect_link('/index.php',array( |
|
| 1252 | + Egw::redirect_link('/index.php', array( |
|
| 1253 | 1253 | 'menuaction' => 'admin.admin_account.delete', |
| 1254 | 1254 | 'account_id' => $contact['account_id'], |
| 1255 | 1255 | )); |
@@ -1311,7 +1311,7 @@ discard block |
||
| 1311 | 1311 | } |
| 1312 | 1312 | else |
| 1313 | 1313 | { |
| 1314 | - $Ok = $this->remove_from_list($id,$query['filter2']) !== false; |
|
| 1314 | + $Ok = $this->remove_from_list($id, $query['filter2']) !== false; |
|
| 1315 | 1315 | } |
| 1316 | 1316 | break; |
| 1317 | 1317 | |
@@ -1324,28 +1324,28 @@ discard block |
||
| 1324 | 1324 | } |
| 1325 | 1325 | else |
| 1326 | 1326 | { |
| 1327 | - $Ok = $this->add2list($id,$to_list) !== false; |
|
| 1327 | + $Ok = $this->add2list($id, $to_list) !== false; |
|
| 1328 | 1328 | } |
| 1329 | 1329 | break; |
| 1330 | 1330 | |
| 1331 | 1331 | default: // move to an other addressbook |
| 1332 | - if (!(int)$action || !($this->grants[(string) (int) $action] & Acl::EDIT)) // might be ADD in the future |
|
| 1332 | + if (!(int)$action || !($this->grants[(string)(int)$action]&Acl::EDIT)) // might be ADD in the future |
|
| 1333 | 1333 | { |
| 1334 | 1334 | return false; |
| 1335 | 1335 | } |
| 1336 | 1336 | if (!$checkboxes['move_to_copy']) |
| 1337 | 1337 | { |
| 1338 | 1338 | $action_msg = lang('moved'); |
| 1339 | - if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE,$contact))) |
|
| 1339 | + if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE, $contact))) |
|
| 1340 | 1340 | { |
| 1341 | 1341 | if (!$contact['owner']) // no (mass-)move of Api\Accounts |
| 1342 | 1342 | { |
| 1343 | 1343 | $Ok = false; |
| 1344 | 1344 | } |
| 1345 | - elseif ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action,-1) == 'p')) |
|
| 1345 | + elseif ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action, -1) == 'p')) |
|
| 1346 | 1346 | { |
| 1347 | - $contact['owner'] = (int) $action; |
|
| 1348 | - $contact['private'] = (int)(substr($action,-1) == 'p'); |
|
| 1347 | + $contact['owner'] = (int)$action; |
|
| 1348 | + $contact['private'] = (int)(substr($action, -1) == 'p'); |
|
| 1349 | 1349 | $Ok = $this->save($contact); |
| 1350 | 1350 | } |
| 1351 | 1351 | } |
@@ -1353,14 +1353,14 @@ discard block |
||
| 1353 | 1353 | else |
| 1354 | 1354 | { |
| 1355 | 1355 | $action_msg = lang('copied'); |
| 1356 | - if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::READ,$contact))) |
|
| 1356 | + if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::READ, $contact))) |
|
| 1357 | 1357 | { |
| 1358 | - if ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action,-1) == 'p')) |
|
| 1358 | + if ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action, -1) == 'p')) |
|
| 1359 | 1359 | { |
| 1360 | - $this->copy_contact($contact, false); // do NOT use self::$copy_fields, copy everything but uid etc. |
|
| 1360 | + $this->copy_contact($contact, false); // do NOT use self::$copy_fields, copy everything but uid etc. |
|
| 1361 | 1361 | $links = $contact['link_to']['to_id']; |
| 1362 | - $contact['owner'] = (int) $action; |
|
| 1363 | - $contact['private'] = (int)(substr($action,-1) == 'p'); |
|
| 1362 | + $contact['owner'] = (int)$action; |
|
| 1363 | + $contact['private'] = (int)(substr($action, -1) == 'p'); |
|
| 1364 | 1364 | $Ok = $this->save($contact); |
| 1365 | 1365 | if ($Ok && is_array($links)) |
| 1366 | 1366 | { |
@@ -1399,38 +1399,38 @@ discard block |
||
| 1399 | 1399 | * |
| 1400 | 1400 | * @return array List of contact IDs in the provided groups |
| 1401 | 1401 | */ |
| 1402 | - protected function find_grouped_ids($action,&$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg) |
|
| 1402 | + protected function find_grouped_ids($action, &$checked, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg) |
|
| 1403 | 1403 | { |
| 1404 | 1404 | unset($use_all); |
| 1405 | 1405 | $grouped_contacts = array(); |
| 1406 | - foreach((array)$checked as $n => $id) |
|
| 1406 | + foreach ((array)$checked as $n => $id) |
|
| 1407 | 1407 | { |
| 1408 | - if (substr($id,0,9) == 'org_name:' || substr($id, 0,10) == 'duplicate:') |
|
| 1408 | + if (substr($id, 0, 9) == 'org_name:' || substr($id, 0, 10) == 'duplicate:') |
|
| 1409 | 1409 | { |
| 1410 | 1410 | if (count($checked) == 1 && !count($grouped_contacts) && $action == 'infolog') |
| 1411 | 1411 | { |
| 1412 | - return $this->infolog_org_view($id); // uses the org-name, instead of 'selected contacts' |
|
| 1412 | + return $this->infolog_org_view($id); // uses the org-name, instead of 'selected contacts' |
|
| 1413 | 1413 | } |
| 1414 | 1414 | unset($checked[$n]); |
| 1415 | 1415 | $query = Api\Cache::getSession('addressbook', $session_name); |
| 1416 | - $query['num_rows'] = -1; // all |
|
| 1416 | + $query['num_rows'] = -1; // all |
|
| 1417 | 1417 | $query['grouped_view'] = $id; |
| 1418 | 1418 | unset($query['filter2']); |
| 1419 | 1419 | $extra = $readonlys = null; |
| 1420 | - $this->get_rows($query,$extra,$readonlys,true); // true = only return the id's |
|
| 1420 | + $this->get_rows($query, $extra, $readonlys, true); // true = only return the id's |
|
| 1421 | 1421 | |
| 1422 | 1422 | // Merge them here, so we only merge the ones that are duplicates, |
| 1423 | 1423 | // not merge all selected together |
| 1424 | - if($action == 'merge_duplicates') |
|
| 1424 | + if ($action == 'merge_duplicates') |
|
| 1425 | 1425 | { |
| 1426 | 1426 | $loop_success = $loop_fail = 0; |
| 1427 | - $this->action('merge', $extra, false, $loop_success, $loop_fail, $action_msg,$session_name,$msg); |
|
| 1427 | + $this->action('merge', $extra, false, $loop_success, $loop_fail, $action_msg, $session_name, $msg); |
|
| 1428 | 1428 | $success += $loop_success; |
| 1429 | 1429 | $failed += $loop_fail; |
| 1430 | 1430 | } |
| 1431 | 1431 | if ($extra[0]) |
| 1432 | 1432 | { |
| 1433 | - $grouped_contacts = array_merge($grouped_contacts,$extra); |
|
| 1433 | + $grouped_contacts = array_merge($grouped_contacts, $extra); |
|
| 1434 | 1434 | } |
| 1435 | 1435 | } |
| 1436 | 1436 | } |
@@ -1446,22 +1446,22 @@ discard block |
||
| 1446 | 1446 | * @param boolean $only_copy_fields =true true: only copy fields configured for copying (eg. no name), |
| 1447 | 1447 | * false: copy everything, but never to copy fields |
| 1448 | 1448 | */ |
| 1449 | - function copy_contact(array &$content, $only_copy_fields=true) |
|
| 1449 | + function copy_contact(array &$content, $only_copy_fields = true) |
|
| 1450 | 1450 | { |
| 1451 | 1451 | $content['link_to']['to_id'] = 0; |
| 1452 | - Link::link('addressbook',$content['link_to']['to_id'],'addressbook',$content['id'], |
|
| 1453 | - lang('Copied by %1, from record #%2.',Api\Accounts::format_username('', |
|
| 1454 | - $GLOBALS['egw_info']['user']['account_firstname'],$GLOBALS['egw_info']['user']['account_lastname']), |
|
| 1452 | + Link::link('addressbook', $content['link_to']['to_id'], 'addressbook', $content['id'], |
|
| 1453 | + lang('Copied by %1, from record #%2.', Api\Accounts::format_username('', |
|
| 1454 | + $GLOBALS['egw_info']['user']['account_firstname'], $GLOBALS['egw_info']['user']['account_lastname']), |
|
| 1455 | 1455 | $content['id'])); |
| 1456 | 1456 | // create a new contact with the content of the old |
| 1457 | - foreach(array_keys($content) as $key) |
|
| 1457 | + foreach (array_keys($content) as $key) |
|
| 1458 | 1458 | { |
| 1459 | - if($only_copy_fields && !in_array($key, self::$copy_fields) || in_array($key, array('id','etag','carddav_name','uid'))) |
|
| 1459 | + if ($only_copy_fields && !in_array($key, self::$copy_fields) || in_array($key, array('id', 'etag', 'carddav_name', 'uid'))) |
|
| 1460 | 1460 | { |
| 1461 | 1461 | unset($content[$key]); |
| 1462 | 1462 | } |
| 1463 | 1463 | } |
| 1464 | - if(!isset($content['owner'])) |
|
| 1464 | + if (!isset($content['owner'])) |
|
| 1465 | 1465 | { |
| 1466 | 1466 | $content['owner'] = $this->default_private ? $this->user.'p' : $this->default_addressbook; |
| 1467 | 1467 | } |
@@ -1479,7 +1479,7 @@ discard block |
||
| 1479 | 1479 | * @param boolean $id_only =false if true only return (via $rows) an array of contact-ids, dont save state to session |
| 1480 | 1480 | * @return int total number of contacts matching the selection |
| 1481 | 1481 | */ |
| 1482 | - function get_rows(&$query,&$rows,&$readonlys,$id_only=false) |
|
| 1482 | + function get_rows(&$query, &$rows, &$readonlys, $id_only = false) |
|
| 1483 | 1483 | { |
| 1484 | 1484 | $what = $query['sitemgr_display'] ? $query['sitemgr_display'] : 'index'; |
| 1485 | 1485 | |
@@ -1487,7 +1487,7 @@ discard block |
||
| 1487 | 1487 | { |
| 1488 | 1488 | $store_query = $query; |
| 1489 | 1489 | // Do not store these |
| 1490 | - foreach(array('options-cat_id','actions','action_links','placeholder_actions') as $key) |
|
| 1490 | + foreach (array('options-cat_id', 'actions', 'action_links', 'placeholder_actions') as $key) |
|
| 1491 | 1491 | { |
| 1492 | 1492 | unset($store_query[$key]); |
| 1493 | 1493 | } |
@@ -1499,28 +1499,28 @@ discard block |
||
| 1499 | 1499 | $old_state = Api\Cache::getSession('addressbook', $what); |
| 1500 | 1500 | } |
| 1501 | 1501 | $GLOBALS['egw']->session->commit_session(); |
| 1502 | - if (!isset($this->grouped_views[(string) $query['grouped_view']]) || strpos($query['grouped_view'],':') === false) |
|
| 1502 | + if (!isset($this->grouped_views[(string)$query['grouped_view']]) || strpos($query['grouped_view'], ':') === false) |
|
| 1503 | 1503 | { |
| 1504 | 1504 | // we don't have a grouped view, unset the according col_filters |
| 1505 | 1505 | $this->unset_grouped_filters($query); |
| 1506 | 1506 | } |
| 1507 | 1507 | |
| 1508 | - if (isset($this->grouped_views[(string) $query['grouped_view']])) |
|
| 1508 | + if (isset($this->grouped_views[(string)$query['grouped_view']])) |
|
| 1509 | 1509 | { |
| 1510 | 1510 | // we have a grouped view, reset the advanced search |
| 1511 | - if(!$query['search'] && $old_state['advanced_search']) $query['advanced_search'] = $old_state['advanced_search']; |
|
| 1511 | + if (!$query['search'] && $old_state['advanced_search']) $query['advanced_search'] = $old_state['advanced_search']; |
|
| 1512 | 1512 | } |
| 1513 | - elseif(!$query['search'] && array_key_exists('advanced_search',$old_state)) // eg. paging in an advanced search |
|
| 1513 | + elseif (!$query['search'] && array_key_exists('advanced_search', $old_state)) // eg. paging in an advanced search |
|
| 1514 | 1514 | { |
| 1515 | 1515 | $query['advanced_search'] = $old_state['advanced_search']; |
| 1516 | 1516 | } |
| 1517 | 1517 | |
| 1518 | 1518 | // Make sure old lettersearch filter doesn't stay - current letter filter will be added later |
| 1519 | - foreach($query['col_filter'] as $key => $col_filter) |
|
| 1519 | + foreach ($query['col_filter'] as $key => $col_filter) |
|
| 1520 | 1520 | { |
| 1521 | - if(!is_numeric($key)) continue; |
|
| 1522 | - if(preg_match('/'.$GLOBALS['egw']->db->capabilities['case_insensitive_like']. |
|
| 1523 | - ' '.$GLOBALS['egw']->db->quote('[a-z]%').'$/i',$col_filter) == 1 |
|
| 1521 | + if (!is_numeric($key)) continue; |
|
| 1522 | + if (preg_match('/'.$GLOBALS['egw']->db->capabilities['case_insensitive_like']. |
|
| 1523 | + ' '.$GLOBALS['egw']->db->quote('[a-z]%').'$/i', $col_filter) == 1 |
|
| 1524 | 1524 | ) |
| 1525 | 1525 | { |
| 1526 | 1526 | unset($query['col_filter'][$key]); |
@@ -1535,16 +1535,16 @@ discard block |
||
| 1535 | 1535 | { |
| 1536 | 1536 | if ($old_state['filter'] === '0') // user changed to org_view |
| 1537 | 1537 | { |
| 1538 | - $query['filter'] = ''; // --> change filter to all contacts |
|
| 1538 | + $query['filter'] = ''; // --> change filter to all contacts |
|
| 1539 | 1539 | } |
| 1540 | 1540 | else // user changed to accounts |
| 1541 | 1541 | { |
| 1542 | - $query['grouped_view'] = ''; // --> change to regular contacts view |
|
| 1542 | + $query['grouped_view'] = ''; // --> change to regular contacts view |
|
| 1543 | 1543 | } |
| 1544 | 1544 | } |
| 1545 | 1545 | if ($query['grouped_view'] && isset($this->grouped_views[$old_state['grouped_view']]) && !isset($this->grouped_views[$query['grouped_view']])) |
| 1546 | 1546 | { |
| 1547 | - $query['searchletter'] = ''; // reset lettersearch if viewing the contacts of one group (org or duplicates) |
|
| 1547 | + $query['searchletter'] = ''; // reset lettersearch if viewing the contacts of one group (org or duplicates) |
|
| 1548 | 1548 | } |
| 1549 | 1549 | // save the state of the index in the user prefs |
| 1550 | 1550 | $state = serialize(array( |
@@ -1557,9 +1557,9 @@ discard block |
||
| 1557 | 1557 | )); |
| 1558 | 1558 | if ($state != $this->prefs[$what.'_state'] && !$query['csv_export']) |
| 1559 | 1559 | { |
| 1560 | - $GLOBALS['egw']->preferences->add('addressbook',$what.'_state',$state); |
|
| 1560 | + $GLOBALS['egw']->preferences->add('addressbook', $what.'_state', $state); |
|
| 1561 | 1561 | // save prefs, but do NOT invalid the cache (unnecessary) |
| 1562 | - $GLOBALS['egw']->preferences->save_repository(false,'user',false); |
|
| 1562 | + $GLOBALS['egw']->preferences->save_repository(false, 'user', false); |
|
| 1563 | 1563 | } |
| 1564 | 1564 | } |
| 1565 | 1565 | unset($old_state); |
@@ -1574,11 +1574,11 @@ discard block |
||
| 1574 | 1574 | } |
| 1575 | 1575 | if ($query['filter'] !== '') // not all addressbooks |
| 1576 | 1576 | { |
| 1577 | - $query['col_filter']['owner'] = (string) (int) $query['filter']; |
|
| 1577 | + $query['col_filter']['owner'] = (string)(int)$query['filter']; |
|
| 1578 | 1578 | |
| 1579 | 1579 | if ($this->private_addressbook) |
| 1580 | 1580 | { |
| 1581 | - $query['col_filter']['private'] = substr($query['filter'],-1) == 'p' ? 1 : 0; |
|
| 1581 | + $query['col_filter']['private'] = substr($query['filter'], -1) == 'p' ? 1 : 0; |
|
| 1582 | 1582 | } |
| 1583 | 1583 | } |
| 1584 | 1584 | else |
@@ -1588,7 +1588,7 @@ discard block |
||
| 1588 | 1588 | } |
| 1589 | 1589 | if ((int)$query['filter2']) // not no distribution list |
| 1590 | 1590 | { |
| 1591 | - $query['col_filter']['list'] = (string) (int) $query['filter2']; |
|
| 1591 | + $query['col_filter']['list'] = (string)(int)$query['filter2']; |
|
| 1592 | 1592 | } |
| 1593 | 1593 | else |
| 1594 | 1594 | { |
@@ -1607,7 +1607,7 @@ discard block |
||
| 1607 | 1607 | $query['no_filter2'] = false; |
| 1608 | 1608 | |
| 1609 | 1609 | // Grouped view |
| 1610 | - if (isset($this->grouped_views[(string) $query['grouped_view']]) && !$query['col_filter']['parent_id']) |
|
| 1610 | + if (isset($this->grouped_views[(string)$query['grouped_view']]) && !$query['col_filter']['parent_id']) |
|
| 1611 | 1611 | { |
| 1612 | 1612 | $query['grouped_view_label'] = ''; |
| 1613 | 1613 | $rows = $this->get_grouped_rows($query); |
@@ -1622,7 +1622,7 @@ discard block |
||
| 1622 | 1622 | { |
| 1623 | 1623 | $query['template'] = 'addressbook.index.rows'; |
| 1624 | 1624 | } |
| 1625 | - if($query['col_filter']['parent_id']) |
|
| 1625 | + if ($query['col_filter']['parent_id']) |
|
| 1626 | 1626 | { |
| 1627 | 1627 | $query['grouped_view'] = $query['col_filter']['parent_id']; |
| 1628 | 1628 | $query['template'] = strpos($query['grouped_view'], 'duplicate') === 0 ? |
@@ -1632,11 +1632,11 @@ discard block |
||
| 1632 | 1632 | unset($query['col_filter']['parent_id']); |
| 1633 | 1633 | if ($query['grouped_view']) // view the contacts of one organisation only |
| 1634 | 1634 | { |
| 1635 | - if (strpos($query['grouped_view'],'*AND*') !== false) $query['grouped_view'] = str_replace('*AND*','&',$query['grouped_view']); |
|
| 1636 | - $fields = explode(',',$GLOBALS['egw_info']['user']['preferences']['addressbook']['duplicate_fields']); |
|
| 1637 | - foreach(explode('|||',$query['grouped_view']) as $part) |
|
| 1635 | + if (strpos($query['grouped_view'], '*AND*') !== false) $query['grouped_view'] = str_replace('*AND*', '&', $query['grouped_view']); |
|
| 1636 | + $fields = explode(',', $GLOBALS['egw_info']['user']['preferences']['addressbook']['duplicate_fields']); |
|
| 1637 | + foreach (explode('|||', $query['grouped_view']) as $part) |
|
| 1638 | 1638 | { |
| 1639 | - list($name,$value) = explode(':',$part,2); |
|
| 1639 | + list($name, $value) = explode(':', $part, 2); |
|
| 1640 | 1640 | // do NOT set invalid column, as this gives an SQL error ("AND AND" in sql) |
| 1641 | 1641 | if (static::$duplicate_fields[$name] && $value && ( |
| 1642 | 1642 | strpos($query['grouped_view'], 'duplicate:') === 0 && in_array($name, $fields) || |
@@ -1647,14 +1647,14 @@ discard block |
||
| 1647 | 1647 | } |
| 1648 | 1648 | } |
| 1649 | 1649 | } |
| 1650 | - else if($query['actions'] && !$query['actions']['edit']) |
|
| 1650 | + else if ($query['actions'] && !$query['actions']['edit']) |
|
| 1651 | 1651 | { |
| 1652 | 1652 | // Just switched from grouped view, update actions |
| 1653 | 1653 | $query['actions'] = $this->get_actions($query['col_filter']['tid']); |
| 1654 | 1654 | } |
| 1655 | 1655 | // translate the select order to the really used over all 3 columns |
| 1656 | 1656 | $sort = $query['sort']; |
| 1657 | - switch($query['order']) // "xxx<>'' DESC" sorts contacts with empty order-criteria always at the end |
|
| 1657 | + switch ($query['order']) // "xxx<>'' DESC" sorts contacts with empty order-criteria always at the end |
|
| 1658 | 1658 | { // we don't exclude them, as the total would otherwise depend on the order-criteria |
| 1659 | 1659 | case 'org_name': |
| 1660 | 1660 | $order = "egw_addressbook.org_name<>''DESC,egw_addressbook.org_name $sort,n_family $sort,n_given $sort"; |
@@ -1688,8 +1688,8 @@ discard block |
||
| 1688 | 1688 | } |
| 1689 | 1689 | if ($query['searchletter']) // only show contacts if the order-criteria starts with the given letter |
| 1690 | 1690 | { |
| 1691 | - $no_letter_search = array('adr_one_postalcode', 'adr_two_postalcode', 'contact_id', 'contact_created','contact_modified'); |
|
| 1692 | - $query['col_filter'][] = (in_array($query['order'],$no_letter_search) ? 'org_name' : (substr($query['order'],0,1)=='#'?'':'egw_addressbook.').$query['order']).' '. |
|
| 1691 | + $no_letter_search = array('adr_one_postalcode', 'adr_two_postalcode', 'contact_id', 'contact_created', 'contact_modified'); |
|
| 1692 | + $query['col_filter'][] = (in_array($query['order'], $no_letter_search) ? 'org_name' : (substr($query['order'], 0, 1) == '#' ? '' : 'egw_addressbook.').$query['order']).' '. |
|
| 1693 | 1693 | $GLOBALS['egw']->db->capabilities['case_insensitive_like'].' '.$GLOBALS['egw']->db->quote($query['searchletter'].'%'); |
| 1694 | 1694 | } |
| 1695 | 1695 | $wildcard = '%'; |
@@ -1703,40 +1703,40 @@ discard block |
||
| 1703 | 1703 | unset($query['advanced_search']['meth_select']); |
| 1704 | 1704 | } |
| 1705 | 1705 | |
| 1706 | - $rows = parent::search($query['advanced_search'] ? $query['advanced_search'] : $query['search'],$id_only, |
|
| 1707 | - $order,'',$wildcard,false,$op,array((int)$query['start'],(int) $query['num_rows']),$query['col_filter']); |
|
| 1706 | + $rows = parent::search($query['advanced_search'] ? $query['advanced_search'] : $query['search'], $id_only, |
|
| 1707 | + $order, '', $wildcard, false, $op, array((int)$query['start'], (int)$query['num_rows']), $query['col_filter']); |
|
| 1708 | 1708 | |
| 1709 | 1709 | // do we need to read the custom fields, depends on the column is enabled and customfields |
| 1710 | 1710 | $columsel = $this->prefs['nextmatch-addressbook.index.rows']; |
| 1711 | - $available_distib_lists=$this->get_lists(Acl::READ); |
|
| 1712 | - $columselection = $columsel ? explode(',',$columsel) : array(); |
|
| 1711 | + $available_distib_lists = $this->get_lists(Acl::READ); |
|
| 1712 | + $columselection = $columsel ? explode(',', $columsel) : array(); |
|
| 1713 | 1713 | $ids = $calendar_participants = array(); |
| 1714 | 1714 | if (!$id_only && $rows) |
| 1715 | 1715 | { |
| 1716 | - $show_custom_fields = (in_array('customfields',$columselection)) && $this->customfields; |
|
| 1717 | - $show_calendar = $this->config['disable_event_column'] != 'True' && in_array('calendar_calendar',$columselection); |
|
| 1718 | - $show_distributionlist = in_array('distrib_lists',$columselection) || count($available_distib_lists); |
|
| 1716 | + $show_custom_fields = (in_array('customfields', $columselection)) && $this->customfields; |
|
| 1717 | + $show_calendar = $this->config['disable_event_column'] != 'True' && in_array('calendar_calendar', $columselection); |
|
| 1718 | + $show_distributionlist = in_array('distrib_lists', $columselection) || count($available_distib_lists); |
|
| 1719 | 1719 | if ($show_calendar || $show_custom_fields || $show_distributionlist) |
| 1720 | 1720 | { |
| 1721 | - foreach($rows as $val) |
|
| 1721 | + foreach ($rows as $val) |
|
| 1722 | 1722 | { |
| 1723 | 1723 | $ids[] = $val['id']; |
| 1724 | 1724 | $calendar_participants[$val['id']] = $val['account_id'] ? $val['account_id'] : 'c'.$val['id']; |
| 1725 | 1725 | } |
| 1726 | 1726 | if ($show_custom_fields) |
| 1727 | 1727 | { |
| 1728 | - foreach($columselection as $col) |
|
| 1728 | + foreach ($columselection as $col) |
|
| 1729 | 1729 | { |
| 1730 | - if ($col[0] == '#') $selected_cfs[] = substr($col,1); |
|
| 1730 | + if ($col[0] == '#') $selected_cfs[] = substr($col, 1); |
|
| 1731 | 1731 | } |
| 1732 | - $customfields = $this->read_customfields($ids,$selected_cfs); |
|
| 1732 | + $customfields = $this->read_customfields($ids, $selected_cfs); |
|
| 1733 | 1733 | } |
| 1734 | 1734 | if ($show_calendar && !empty($ids)) $calendar = $this->read_calendar($calendar_participants); |
| 1735 | 1735 | // distributionlist memership for the entrys |
| 1736 | 1736 | //_debug_array($this->get_lists(Acl::EDIT)); |
| 1737 | 1737 | if ($show_distributionlist && $available_distib_lists) |
| 1738 | 1738 | { |
| 1739 | - $distributionlist = $this->read_distributionlist($ids,array_keys($available_distib_lists)); |
|
| 1739 | + $distributionlist = $this->read_distributionlist($ids, array_keys($available_distib_lists)); |
|
| 1740 | 1740 | } |
| 1741 | 1741 | } |
| 1742 | 1742 | } |
@@ -1745,20 +1745,20 @@ discard block |
||
| 1745 | 1745 | |
| 1746 | 1746 | if ($id_only) |
| 1747 | 1747 | { |
| 1748 | - foreach($rows as $n => $row) |
|
| 1748 | + foreach ($rows as $n => $row) |
|
| 1749 | 1749 | { |
| 1750 | 1750 | $rows[$n] = $row['id']; |
| 1751 | 1751 | } |
| 1752 | - return $this->total; // no need to set other fields or $readonlys |
|
| 1752 | + return $this->total; // no need to set other fields or $readonlys |
|
| 1753 | 1753 | } |
| 1754 | 1754 | $order = $query['order']; |
| 1755 | 1755 | |
| 1756 | 1756 | $readonlys = array(); |
| 1757 | - foreach($rows as $n => &$row) |
|
| 1757 | + foreach ($rows as $n => &$row) |
|
| 1758 | 1758 | { |
| 1759 | 1759 | $given = $row['n_given'] ? $row['n_given'] : ($row['n_prefix'] ? $row['n_prefix'] : ''); |
| 1760 | 1760 | |
| 1761 | - switch($order) |
|
| 1761 | + switch ($order) |
|
| 1762 | 1762 | { |
| 1763 | 1763 | default: // postalcode, created, modified, ... |
| 1764 | 1764 | case 'org_name': |
@@ -1775,43 +1775,43 @@ discard block |
||
| 1775 | 1775 | break; |
| 1776 | 1776 | case 'n_fileas': |
| 1777 | 1777 | if (!$row['n_fileas']) $row['n_fileas'] = $this->fileas($row); |
| 1778 | - list($row['line1'],$row['line2']) = explode(': ',$row['n_fileas']); |
|
| 1778 | + list($row['line1'], $row['line2']) = explode(': ', $row['n_fileas']); |
|
| 1779 | 1779 | break; |
| 1780 | 1780 | } |
| 1781 | - if (isset($this->grouped_views[(string) $query['grouped_view']])) |
|
| 1781 | + if (isset($this->grouped_views[(string)$query['grouped_view']])) |
|
| 1782 | 1782 | { |
| 1783 | 1783 | $row['type'] = 'home'; |
| 1784 | 1784 | $row['type_label'] = $query['grouped_view'] == 'duplicate' ? lang('Duplicates') : lang('Organisation'); |
| 1785 | 1785 | |
| 1786 | - if ($query['filter'] && !($this->grants[(int)$query['filter']] & Acl::DELETE)) |
|
| 1786 | + if ($query['filter'] && !($this->grants[(int)$query['filter']]&Acl::DELETE)) |
|
| 1787 | 1787 | { |
| 1788 | 1788 | $row['class'] .= 'rowNoDelete '; |
| 1789 | 1789 | } |
| 1790 | - $row['class'] .= 'rowNoEdit '; // no edit in OrgView |
|
| 1790 | + $row['class'] .= 'rowNoEdit '; // no edit in OrgView |
|
| 1791 | 1791 | $row['class'] .= $query['grouped_view'] == 'duplicates' ? 'contact_duplicate' : 'contact_organisation '; |
| 1792 | 1792 | } |
| 1793 | 1793 | else |
| 1794 | 1794 | { |
| 1795 | - $this->type_icon($row['owner'],$row['private'],$row['tid'],$row['type'],$row['type_label']); |
|
| 1795 | + $this->type_icon($row['owner'], $row['private'], $row['tid'], $row['type'], $row['type_label']); |
|
| 1796 | 1796 | |
| 1797 | - static $tel2show = array('tel_work','tel_cell','tel_home','tel_fax'); |
|
| 1797 | + static $tel2show = array('tel_work', 'tel_cell', 'tel_home', 'tel_fax'); |
|
| 1798 | 1798 | static $prefer_marker = null; |
| 1799 | 1799 | if (is_null($prefer_marker)) |
| 1800 | 1800 | { |
| 1801 | 1801 | // as et2 adds options with .text(), it can't be entities, but php knows no string literals with utf-8 |
| 1802 | 1802 | $prefer_marker = html_entity_decode(' ☆', ENT_NOQUOTES, 'utf-8'); |
| 1803 | 1803 | } |
| 1804 | - foreach($tel2show as $name) |
|
| 1804 | + foreach ($tel2show as $name) |
|
| 1805 | 1805 | { |
| 1806 | - $row[$name] .= ' '.($row['tel_prefer'] == $name ? $prefer_marker : ''); // .' ' to NOT remove the field |
|
| 1806 | + $row[$name] .= ' '.($row['tel_prefer'] == $name ? $prefer_marker : ''); // .' ' to NOT remove the field |
|
| 1807 | 1807 | } |
| 1808 | 1808 | // allways show the prefered phone, if not already shown |
| 1809 | - if (!in_array($row['tel_prefer'],$tel2show) && $row[$row['tel_prefer']]) |
|
| 1809 | + if (!in_array($row['tel_prefer'], $tel2show) && $row[$row['tel_prefer']]) |
|
| 1810 | 1810 | { |
| 1811 | 1811 | $row['tel_prefered'] = $row[$row['tel_prefer']].$prefer_marker; |
| 1812 | 1812 | } |
| 1813 | 1813 | // Show nice name as status text |
| 1814 | - if($row['tel_prefer']) |
|
| 1814 | + if ($row['tel_prefer']) |
|
| 1815 | 1815 | { |
| 1816 | 1816 | $row['tel_prefer_label'] = $this->contact_fields[$row['tel_prefer']]; |
| 1817 | 1817 | } |
@@ -1819,33 +1819,33 @@ discard block |
||
| 1819 | 1819 | { |
| 1820 | 1820 | $row['class'] .= 'rowAccount rowNoDelete '; |
| 1821 | 1821 | } |
| 1822 | - elseif (!$this->check_perms(Acl::DELETE,$row) || (!$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge' && $query['col_filter']['tid'] == self::DELETED_TYPE)) |
|
| 1822 | + elseif (!$this->check_perms(Acl::DELETE, $row) || (!$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge' && $query['col_filter']['tid'] == self::DELETED_TYPE)) |
|
| 1823 | 1823 | { |
| 1824 | 1824 | $row['class'] .= 'rowNoDelete '; |
| 1825 | 1825 | } |
| 1826 | - if (!$this->check_perms(Acl::EDIT,$row)) |
|
| 1826 | + if (!$this->check_perms(Acl::EDIT, $row)) |
|
| 1827 | 1827 | { |
| 1828 | 1828 | $row['class'] .= 'rowNoEdit '; |
| 1829 | 1829 | } |
| 1830 | 1830 | $row['class'] .= 'contact_contact '; |
| 1831 | 1831 | |
| 1832 | - unset($row['jpegphoto']); // unused and messes up json encoding (not utf-8) |
|
| 1832 | + unset($row['jpegphoto']); // unused and messes up json encoding (not utf-8) |
|
| 1833 | 1833 | |
| 1834 | 1834 | if (isset($customfields[$row['id']])) |
| 1835 | 1835 | { |
| 1836 | - foreach($this->customfields as $name => $data) |
|
| 1836 | + foreach ($this->customfields as $name => $data) |
|
| 1837 | 1837 | { |
| 1838 | 1838 | $row['#'.$name] = $customfields[$row['id']]['#'.$name]; |
| 1839 | 1839 | } |
| 1840 | 1840 | } |
| 1841 | 1841 | if (isset($distributionlist[$row['id']])) |
| 1842 | 1842 | { |
| 1843 | - $row['distrib_lists'] = implode("\n",array_values($distributionlist[$row['id']])); |
|
| 1843 | + $row['distrib_lists'] = implode("\n", array_values($distributionlist[$row['id']])); |
|
| 1844 | 1844 | //if ($show_distributionlist) $readonlys['distrib_lists'] =true; |
| 1845 | 1845 | } |
| 1846 | 1846 | if (isset($calendar[$calendar_participants[$row['id']]])) |
| 1847 | 1847 | { |
| 1848 | - foreach($calendar[$calendar_participants[$row['id']]] as $name => $data) |
|
| 1848 | + foreach ($calendar[$calendar_participants[$row['id']]] as $name => $data) |
|
| 1849 | 1849 | { |
| 1850 | 1850 | $row[$name] = $data; |
| 1851 | 1851 | } |
@@ -1853,13 +1853,13 @@ discard block |
||
| 1853 | 1853 | } |
| 1854 | 1854 | |
| 1855 | 1855 | // hide region for address format 'postcode_city' |
| 1856 | - if (($row['addr_format'] = $this->addr_format_by_country($row['adr_one_countryname']))=='postcode_city') unset($row['adr_one_region']); |
|
| 1857 | - if (($row['addr_format2'] = $this->addr_format_by_country($row['adr_two_countryname']))=='postcode_city') unset($row['adr_two_region']); |
|
| 1856 | + if (($row['addr_format'] = $this->addr_format_by_country($row['adr_one_countryname'])) == 'postcode_city') unset($row['adr_one_region']); |
|
| 1857 | + if (($row['addr_format2'] = $this->addr_format_by_country($row['adr_two_countryname'])) == 'postcode_city') unset($row['adr_two_region']); |
|
| 1858 | 1858 | |
| 1859 | 1859 | // respect category permissions |
| 1860 | - if(!empty($row['cat_id'])) |
|
| 1860 | + if (!empty($row['cat_id'])) |
|
| 1861 | 1861 | { |
| 1862 | - $row['cat_id'] = $this->categories->check_list(Acl::READ,$row['cat_id']); |
|
| 1862 | + $row['cat_id'] = $this->categories->check_list(Acl::READ, $row['cat_id']); |
|
| 1863 | 1863 | } |
| 1864 | 1864 | } |
| 1865 | 1865 | $rows['no_distribution_list'] = (bool)$query['filter2']; |
@@ -1871,7 +1871,7 @@ discard block |
||
| 1871 | 1871 | } |
| 1872 | 1872 | |
| 1873 | 1873 | // Disable next/last date if so configured |
| 1874 | - if($this->config['disable_event_column'] == 'True') |
|
| 1874 | + if ($this->config['disable_event_column'] == 'True') |
|
| 1875 | 1875 | { |
| 1876 | 1876 | $rows['no_event_column'] = true; |
| 1877 | 1877 | } |
@@ -1884,23 +1884,21 @@ discard block |
||
| 1884 | 1884 | $header = array(); |
| 1885 | 1885 | if ($query['filter'] !== '' && !isset($this->grouped_views[$query['grouped_view']])) |
| 1886 | 1886 | { |
| 1887 | - $header[] = ($query['filter'] == '0' ? lang('accounts') : |
|
| 1888 | - ($GLOBALS['egw']->accounts->get_type($query['filter']) == 'g' ? |
|
| 1889 | - lang('Group %1',$GLOBALS['egw']->accounts->id2name($query['filter'])) : |
|
| 1890 | - Api\Accounts::username((int)$query['filter']). |
|
| 1891 | - (substr($query['filter'],-1) == 'p' ? ' ('.lang('private').')' : ''))); |
|
| 1887 | + $header[] = ($query['filter'] == '0' ? lang('accounts') : ($GLOBALS['egw']->accounts->get_type($query['filter']) == 'g' ? |
|
| 1888 | + lang('Group %1', $GLOBALS['egw']->accounts->id2name($query['filter'])) : Api\Accounts::username((int)$query['filter']). |
|
| 1889 | + (substr($query['filter'], -1) == 'p' ? ' ('.lang('private').')' : ''))); |
|
| 1892 | 1890 | } |
| 1893 | 1891 | if ($query['grouped_view']) |
| 1894 | 1892 | { |
| 1895 | 1893 | $header[] = $query['grouped_view_label']; |
| 1896 | 1894 | // Make sure option is there |
| 1897 | - if(!array_key_exists($query['grouped_view'], $this->grouped_views)) |
|
| 1895 | + if (!array_key_exists($query['grouped_view'], $this->grouped_views)) |
|
| 1898 | 1896 | { |
| 1899 | 1897 | $this->grouped_views += $this->_get_grouped_name($query['grouped_view']); |
| 1900 | 1898 | $rows['sel_options']['grouped_view'] = $this->grouped_views; |
| 1901 | 1899 | } |
| 1902 | 1900 | } |
| 1903 | - if($query['advanced_search']) |
|
| 1901 | + if ($query['advanced_search']) |
|
| 1904 | 1902 | { |
| 1905 | 1903 | $header[] = lang('Advanced search'); |
| 1906 | 1904 | } |
@@ -1911,11 +1909,11 @@ discard block |
||
| 1911 | 1909 | if ($query['searchletter']) |
| 1912 | 1910 | { |
| 1913 | 1911 | $order = $order == 'n_given' ? lang('first name') : ($order == 'n_family' ? lang('last name') : lang('Organisation')); |
| 1914 | - $header[] = lang("%1 starts with '%2'",$order,$query['searchletter']); |
|
| 1912 | + $header[] = lang("%1 starts with '%2'", $order, $query['searchletter']); |
|
| 1915 | 1913 | } |
| 1916 | 1914 | if ($query['search'] && !$query['advanced_search']) // do not add that, if we have advanced search active |
| 1917 | 1915 | { |
| 1918 | - $header[] = lang("Search for '%1'",$query['search']); |
|
| 1916 | + $header[] = lang("Search for '%1'", $query['search']); |
|
| 1919 | 1917 | } |
| 1920 | 1918 | $GLOBALS['egw_info']['flags']['app_header'] = implode(': ', $header); |
| 1921 | 1919 | |
@@ -1931,7 +1929,7 @@ discard block |
||
| 1931 | 1929 | * @param string &$icon icon-name |
| 1932 | 1930 | * @param string &$label translated label |
| 1933 | 1931 | */ |
| 1934 | - function type_icon($owner,$private,$tid,&$icon,&$label) |
|
| 1932 | + function type_icon($owner, $private, $tid, &$icon, &$label) |
|
| 1935 | 1933 | { |
| 1936 | 1934 | if (!$owner) |
| 1937 | 1935 | { |
@@ -1946,7 +1944,7 @@ discard block |
||
| 1946 | 1944 | elseif ($GLOBALS['egw']->accounts->get_type($owner) == 'g') |
| 1947 | 1945 | { |
| 1948 | 1946 | $icon = 'group'; |
| 1949 | - $label = lang('group %1',$GLOBALS['egw']->accounts->id2name($owner)); |
|
| 1947 | + $label = lang('group %1', $GLOBALS['egw']->accounts->id2name($owner)); |
|
| 1950 | 1948 | } |
| 1951 | 1949 | else |
| 1952 | 1950 | { |
@@ -1954,9 +1952,9 @@ discard block |
||
| 1954 | 1952 | $label = $owner == $this->user ? lang('personal') : Api\Accounts::username($owner); |
| 1955 | 1953 | } |
| 1956 | 1954 | // show tid icon for tid!='n' AND only if one is defined |
| 1957 | - if ($tid != 'n' && Api\Image::find('addressbook',$this->content_types[$tid]['name'])) |
|
| 1955 | + if ($tid != 'n' && Api\Image::find('addressbook', $this->content_types[$tid]['name'])) |
|
| 1958 | 1956 | { |
| 1959 | - $icon = Api\Image::find('addressbook',$this->content_types[$tid]['name']); |
|
| 1957 | + $icon = Api\Image::find('addressbook', $this->content_types[$tid]['name']); |
|
| 1960 | 1958 | } |
| 1961 | 1959 | |
| 1962 | 1960 | // Legacy - from when icons could be anywhere |
@@ -1974,19 +1972,19 @@ discard block |
||
| 1974 | 1972 | * @param int $_GET['contact_id'] contact_id mainly for popup use |
| 1975 | 1973 | * @param bool $_GET['makecp'] true if you want to copy the contact given by $_GET['contact_id'] |
| 1976 | 1974 | */ |
| 1977 | - function edit($content=null) |
|
| 1975 | + function edit($content = null) |
|
| 1978 | 1976 | { |
| 1979 | 1977 | if (is_array($content)) |
| 1980 | 1978 | { |
| 1981 | 1979 | $button = @key($content['button']); |
| 1982 | 1980 | unset($content['button']); |
| 1983 | - $content['private'] = (int) ($content['owner'] && substr($content['owner'],-1) == 'p'); |
|
| 1984 | - $content['owner'] = (string) (int) $content['owner']; |
|
| 1981 | + $content['private'] = (int)($content['owner'] && substr($content['owner'], -1) == 'p'); |
|
| 1982 | + $content['owner'] = (string)(int)$content['owner']; |
|
| 1985 | 1983 | $content['cat_id'] = $this->config['cat_tab'] === 'Tree' ? $content['cat_id_tree'] : $content['cat_id']; |
| 1986 | 1984 | if ($this->config['private_cf_tab']) $content = (array)$content['private_cfs'] + $content; |
| 1987 | 1985 | unset($content['private_cfs']); |
| 1988 | 1986 | |
| 1989 | - switch($button) |
|
| 1987 | + switch ($button) |
|
| 1990 | 1988 | { |
| 1991 | 1989 | case 'save': |
| 1992 | 1990 | case 'apply': |
@@ -1998,7 +1996,7 @@ discard block |
||
| 1998 | 1996 | // photo might be changed by ajax_upload_photo |
| 1999 | 1997 | if (!array_key_exists('jpegphoto', $content)) |
| 2000 | 1998 | { |
| 2001 | - $content['photo_unchanged'] = true; // hint no need to store photo |
|
| 1999 | + $content['photo_unchanged'] = true; // hint no need to store photo |
|
| 2002 | 2000 | } |
| 2003 | 2001 | $links = false; |
| 2004 | 2002 | if (!$content['id'] && is_array($content['link_to']['to_id'])) |
@@ -2011,12 +2009,12 @@ discard block |
||
| 2011 | 2009 | $old_org_entry = $this->read($content['id']); |
| 2012 | 2010 | $old_fullname = ($old_org_entry['n_fn'] ? $old_org_entry['n_fn'] : parent::fullname($old_org_entry)); |
| 2013 | 2011 | } |
| 2014 | - if ( $content['n_fn'] != $fullname || $fullname != $old_fullname) |
|
| 2012 | + if ($content['n_fn'] != $fullname || $fullname != $old_fullname) |
|
| 2015 | 2013 | { |
| 2016 | 2014 | unset($content['n_fn']); |
| 2017 | 2015 | } |
| 2018 | 2016 | // Country codes |
| 2019 | - foreach(array('adr_one', 'adr_two') as $c_prefix) |
|
| 2017 | + foreach (array('adr_one', 'adr_two') as $c_prefix) |
|
| 2020 | 2018 | { |
| 2021 | 2019 | if ($content[$c_prefix.'_countrycode'] == '-custom-') |
| 2022 | 2020 | { |
@@ -2025,7 +2023,7 @@ discard block |
||
| 2025 | 2023 | } |
| 2026 | 2024 | $content['msg'] = ''; |
| 2027 | 2025 | $this->error = false; |
| 2028 | - foreach((array)$content['pre_save_callbacks'] as $callback) |
|
| 2026 | + foreach ((array)$content['pre_save_callbacks'] as $callback) |
|
| 2029 | 2027 | { |
| 2030 | 2028 | try { |
| 2031 | 2029 | if (($success_msg = call_user_func_array($callback, array(&$content)))) |
@@ -2035,7 +2033,7 @@ discard block |
||
| 2035 | 2033 | } |
| 2036 | 2034 | catch (Exception $ex) { |
| 2037 | 2035 | $content['msg'] .= ($content['msg'] ? ', ' : '').$ex->getMessage(); |
| 2038 | - $button = 'apply'; // do not close dialog |
|
| 2036 | + $button = 'apply'; // do not close dialog |
|
| 2039 | 2037 | $this->error = true; |
| 2040 | 2038 | break; |
| 2041 | 2039 | } |
@@ -2050,7 +2048,7 @@ discard block |
||
| 2050 | 2048 | |
| 2051 | 2049 | unset($content['jpegphoto'], $content['photo_unchanged']); |
| 2052 | 2050 | |
| 2053 | - foreach((array)$content['post_save_callbacks'] as $callback) |
|
| 2051 | + foreach ((array)$content['post_save_callbacks'] as $callback) |
|
| 2054 | 2052 | { |
| 2055 | 2053 | try { |
| 2056 | 2054 | if (($success_msg = call_user_func_array($callback, array(&$content)))) |
@@ -2058,58 +2056,58 @@ discard block |
||
| 2058 | 2056 | $content['msg'] .= ', '.$success_msg; |
| 2059 | 2057 | } |
| 2060 | 2058 | } |
| 2061 | - catch(Api\Exception\Redirect $r) |
|
| 2059 | + catch (Api\Exception\Redirect $r) |
|
| 2062 | 2060 | { |
| 2063 | 2061 | // catch it to continue execution and rethrow it later |
| 2064 | 2062 | } |
| 2065 | 2063 | catch (Exception $ex) { |
| 2066 | 2064 | $content['msg'] .= ', '.$ex->getMessage(); |
| 2067 | - $button = 'apply'; // do not close dialog |
|
| 2065 | + $button = 'apply'; // do not close dialog |
|
| 2068 | 2066 | $this->error = true; |
| 2069 | 2067 | break; |
| 2070 | 2068 | } |
| 2071 | 2069 | } |
| 2072 | 2070 | |
| 2073 | - if ($content['change_org'] && $old_org_entry && ($changed = $this->changed_fields($old_org_entry,$content,true)) && |
|
| 2074 | - ($members = $this->org_similar($old_org_entry['org_name'],$changed))) |
|
| 2071 | + if ($content['change_org'] && $old_org_entry && ($changed = $this->changed_fields($old_org_entry, $content, true)) && |
|
| 2072 | + ($members = $this->org_similar($old_org_entry['org_name'], $changed))) |
|
| 2075 | 2073 | { |
| 2076 | 2074 | //foreach($changed as $name => $old_value) echo "<p>$name: '$old_value' --> '{$content[$name]}'</p>\n"; |
| 2077 | - list($changed_members,$changed_fields,$failed_members) = $this->change_org($old_org_entry['org_name'],$changed,$content,$members); |
|
| 2075 | + list($changed_members, $changed_fields, $failed_members) = $this->change_org($old_org_entry['org_name'], $changed, $content, $members); |
|
| 2078 | 2076 | if ($changed_members) |
| 2079 | 2077 | { |
| 2080 | - $content['msg'] .= ', '.lang('%1 fields in %2 other organisation member(s) changed',$changed_fields,$changed_members); |
|
| 2078 | + $content['msg'] .= ', '.lang('%1 fields in %2 other organisation member(s) changed', $changed_fields, $changed_members); |
|
| 2081 | 2079 | } |
| 2082 | 2080 | if ($failed_members) |
| 2083 | 2081 | { |
| 2084 | - $content['msg'] .= ', '.lang('failed to change %1 organisation member(s) (insufficent rights) !!!',$failed_members); |
|
| 2082 | + $content['msg'] .= ', '.lang('failed to change %1 organisation member(s) (insufficent rights) !!!', $failed_members); |
|
| 2085 | 2083 | } |
| 2086 | 2084 | } |
| 2087 | 2085 | } |
| 2088 | - elseif($this->error === true) |
|
| 2086 | + elseif ($this->error === true) |
|
| 2089 | 2087 | { |
| 2090 | 2088 | $content['msg'] = lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
| 2091 | - lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'. |
|
| 2092 | - htmlspecialchars(Egw::link('/index.php',array( |
|
| 2089 | + lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'. |
|
| 2090 | + htmlspecialchars(Egw::link('/index.php', array( |
|
| 2093 | 2091 | 'menuaction' => 'addressbook.addressbook_ui.edit', |
| 2094 | 2092 | 'contact_id' => $content['id'], |
| 2095 | - ))).'">','</a>'); |
|
| 2096 | - break; // dont refresh the list |
|
| 2093 | + ))).'">', '</a>'); |
|
| 2094 | + break; // dont refresh the list |
|
| 2097 | 2095 | } |
| 2098 | 2096 | else |
| 2099 | 2097 | { |
| 2100 | 2098 | $content['msg'] = lang('Error saving the contact !!!'). |
| 2101 | 2099 | ($this->error ? ' '.$this->error : ''); |
| 2102 | - $button = 'apply'; // to not leave the dialog |
|
| 2100 | + $button = 'apply'; // to not leave the dialog |
|
| 2103 | 2101 | } |
| 2104 | 2102 | // writing links for new entry, existing ones are handled by the widget itself |
| 2105 | 2103 | if ($links && $content['id']) |
| 2106 | 2104 | { |
| 2107 | - Link::link('addressbook',$content['id'],$links); |
|
| 2105 | + Link::link('addressbook', $content['id'], $links); |
|
| 2108 | 2106 | } |
| 2109 | 2107 | // Update client side global datastore |
| 2110 | 2108 | $response = Api\Json\Response::get(); |
| 2111 | 2109 | $response->generic('data', array('uid' => 'addressbook::'.$content['id'], 'data' => $content)); |
| 2112 | - Framework::refresh_opener($content['msg'], 'addressbook', $content['id'], $content['id'] ? 'edit' : 'add', |
|
| 2110 | + Framework::refresh_opener($content['msg'], 'addressbook', $content['id'], $content['id'] ? 'edit' : 'add', |
|
| 2113 | 2111 | null, null, null, $this->error ? 'error' : 'success'); |
| 2114 | 2112 | |
| 2115 | 2113 | // re-throw redirect exception, if there's no error |
@@ -2131,11 +2129,11 @@ discard block |
||
| 2131 | 2129 | |
| 2132 | 2130 | case 'delete': |
| 2133 | 2131 | $success = $failed = $action_msg = null; |
| 2134 | - if($this->action('delete',array($content['id']),false,$success,$failed,$action_msg,'',$content['msg'])) |
|
| 2132 | + if ($this->action('delete', array($content['id']), false, $success, $failed, $action_msg, '', $content['msg'])) |
|
| 2135 | 2133 | { |
| 2136 | 2134 | if ($GLOBALS['egw']->currentapp == 'addressbook') |
| 2137 | 2135 | { |
| 2138 | - Framework::refresh_opener(lang('Contact deleted'), 'addressbook', $content['id'], 'delete' ); |
|
| 2136 | + Framework::refresh_opener(lang('Contact deleted'), 'addressbook', $content['id'], 'delete'); |
|
| 2139 | 2137 | Framework::window_close(); |
| 2140 | 2138 | } |
| 2141 | 2139 | else |
@@ -2160,7 +2158,7 @@ discard block |
||
| 2160 | 2158 | // new contact --> set some defaults |
| 2161 | 2159 | if ($contact_id && is_array($content = $this->read($contact_id))) |
| 2162 | 2160 | { |
| 2163 | - $contact_id = $content['id']; // it could have been: "account:$account_id" |
|
| 2161 | + $contact_id = $content['id']; // it could have been: "account:$account_id" |
|
| 2164 | 2162 | if (!$this->check_perms(Acl::EDIT, $content)) |
| 2165 | 2163 | { |
| 2166 | 2164 | $view = true; |
@@ -2204,52 +2202,52 @@ discard block |
||
| 2204 | 2202 | { |
| 2205 | 2203 | $content['owner'] = (string)($state['filter'] == 0 ? '' : $state['filter']); |
| 2206 | 2204 | } |
| 2207 | - $content['private'] = (int) ($content['owner'] && substr($content['owner'],-1) == 'p'); |
|
| 2208 | - if ($content['owner'] === '' || !($this->grants[$content['owner'] = (string) (int) $content['owner']] & Acl::ADD)) |
|
| 2205 | + $content['private'] = (int)($content['owner'] && substr($content['owner'], -1) == 'p'); |
|
| 2206 | + if ($content['owner'] === '' || !($this->grants[$content['owner'] = (string)(int)$content['owner']]&Acl::ADD)) |
|
| 2209 | 2207 | { |
| 2210 | 2208 | $content['owner'] = $this->default_addressbook; |
| 2211 | 2209 | $content['private'] = (int)$this->default_private; |
| 2212 | 2210 | |
| 2213 | - if (!($this->grants[$content['owner'] = (string) (int) $content['owner']] & Acl::ADD)) |
|
| 2211 | + if (!($this->grants[$content['owner'] = (string)(int)$content['owner']]&Acl::ADD)) |
|
| 2214 | 2212 | { |
| 2215 | - $content['owner'] = (string) $this->user; |
|
| 2213 | + $content['owner'] = (string)$this->user; |
|
| 2216 | 2214 | $content['private'] = 0; |
| 2217 | 2215 | } |
| 2218 | 2216 | } |
| 2219 | 2217 | $new_type = array_keys($this->content_types); |
| 2220 | 2218 | // fetch active type to preset the type, if param typeid is not passed |
| 2221 | - $active_tid = Api\Cache::getSession('addressbook','active_tid'); |
|
| 2219 | + $active_tid = Api\Cache::getSession('addressbook', 'active_tid'); |
|
| 2222 | 2220 | if ($active_tid && strtoupper($active_tid) === 'D') unset($active_tid); |
| 2223 | - $content['tid'] = $_GET['typeid'] ? $_GET['typeid'] : ($active_tid?$active_tid:$new_type[0]); |
|
| 2224 | - foreach($this->get_contact_columns() as $field) |
|
| 2221 | + $content['tid'] = $_GET['typeid'] ? $_GET['typeid'] : ($active_tid ? $active_tid : $new_type[0]); |
|
| 2222 | + foreach ($this->get_contact_columns() as $field) |
|
| 2225 | 2223 | { |
| 2226 | 2224 | if ($_GET['presets'][$field]) |
| 2227 | 2225 | { |
| 2228 | - if ($field=='email'||$field=='email_home') |
|
| 2226 | + if ($field == 'email' || $field == 'email_home') |
|
| 2229 | 2227 | { |
| 2230 | - $singleAddress = imap_rfc822_parse_adrlist($_GET['presets'][$field],''); |
|
| 2228 | + $singleAddress = imap_rfc822_parse_adrlist($_GET['presets'][$field], ''); |
|
| 2231 | 2229 | //error_log(__METHOD__.__LINE__.' Address:'.$singleAddress[0]->mailbox."@".$singleAddress[0]->host.", ".$singleAddress[0]->personal); |
| 2232 | - if (!(!is_array($singleAddress) || count($singleAddress)<1)) |
|
| 2230 | + if (!(!is_array($singleAddress) || count($singleAddress) < 1)) |
|
| 2233 | 2231 | { |
| 2234 | 2232 | $content[$field] = $singleAddress[0]->mailbox."@".$singleAddress[0]->host; |
| 2235 | 2233 | if (!empty($singleAddress[0]->personal)) |
| 2236 | 2234 | { |
| 2237 | - if (strpos($singleAddress[0]->personal,',')===false) |
|
| 2235 | + if (strpos($singleAddress[0]->personal, ',') === false) |
|
| 2238 | 2236 | { |
| 2239 | - list($P_n_given,$P_n_family,$P_org_name)=explode(' ',$singleAddress[0]->personal,3); |
|
| 2240 | - if (strlen(trim($P_n_given))>0) $content['n_given'] = trim($P_n_given); |
|
| 2241 | - if (strlen(trim($P_n_family))>0) $content['n_family'] = trim($P_n_family); |
|
| 2242 | - if (strlen(trim($P_org_name))>0) $content['org_name'] = trim($P_org_name); |
|
| 2237 | + list($P_n_given, $P_n_family, $P_org_name) = explode(' ', $singleAddress[0]->personal, 3); |
|
| 2238 | + if (strlen(trim($P_n_given)) > 0) $content['n_given'] = trim($P_n_given); |
|
| 2239 | + if (strlen(trim($P_n_family)) > 0) $content['n_family'] = trim($P_n_family); |
|
| 2240 | + if (strlen(trim($P_org_name)) > 0) $content['org_name'] = trim($P_org_name); |
|
| 2243 | 2241 | } |
| 2244 | 2242 | else |
| 2245 | 2243 | { |
| 2246 | - list($P_n_family,$P_other)=explode(',',$singleAddress[0]->personal,2); |
|
| 2247 | - if (strlen(trim($P_n_family))>0) $content['n_family'] = trim($P_n_family); |
|
| 2248 | - if (strlen(trim($P_other))>0) |
|
| 2244 | + list($P_n_family, $P_other) = explode(',', $singleAddress[0]->personal, 2); |
|
| 2245 | + if (strlen(trim($P_n_family)) > 0) $content['n_family'] = trim($P_n_family); |
|
| 2246 | + if (strlen(trim($P_other)) > 0) |
|
| 2249 | 2247 | { |
| 2250 | - list($P_n_given,$P_org_name)=explode(',',$P_other,2); |
|
| 2251 | - if (strlen(trim($P_n_given))>0) $content['n_given'] = trim($P_n_given); |
|
| 2252 | - if (strlen(trim($P_org_name))>0) $content['org_name'] = trim($P_org_name); |
|
| 2248 | + list($P_n_given, $P_org_name) = explode(',', $P_other, 2); |
|
| 2249 | + if (strlen(trim($P_n_given)) > 0) $content['n_given'] = trim($P_n_given); |
|
| 2250 | + if (strlen(trim($P_org_name)) > 0) $content['org_name'] = trim($P_org_name); |
|
| 2253 | 2251 | } |
| 2254 | 2252 | } |
| 2255 | 2253 | } |
@@ -2267,13 +2265,13 @@ discard block |
||
| 2267 | 2265 | } |
| 2268 | 2266 | if (isset($_GET['presets'])) |
| 2269 | 2267 | { |
| 2270 | - foreach(array('email','email_home','n_family','n_given','org_name') as $field) |
|
| 2268 | + foreach (array('email', 'email_home', 'n_family', 'n_given', 'org_name') as $field) |
|
| 2271 | 2269 | { |
| 2272 | 2270 | if (!empty($content[$field])) |
| 2273 | 2271 | { |
| 2274 | 2272 | //Set the presets fields in content in order to be able to use them later in client side for checking duplication only on first time load |
| 2275 | 2273 | // after save/apply we unset them |
| 2276 | - $content['presets_fields'][]= $field; |
|
| 2274 | + $content['presets_fields'][] = $field; |
|
| 2277 | 2275 | break; |
| 2278 | 2276 | } |
| 2279 | 2277 | } |
@@ -2285,12 +2283,12 @@ discard block |
||
| 2285 | 2283 | //_debug_array($content); |
| 2286 | 2284 | } |
| 2287 | 2285 | |
| 2288 | - if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']); // dont allow HTML! |
|
| 2286 | + if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']); // dont allow HTML! |
|
| 2289 | 2287 | |
| 2290 | - if($content && $_GET['makecp']) // copy the contact |
|
| 2288 | + if ($content && $_GET['makecp']) // copy the contact |
|
| 2291 | 2289 | { |
| 2292 | 2290 | $this->copy_contact($content); |
| 2293 | - $content['msg'] = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('addressbook','entry'))); |
|
| 2291 | + $content['msg'] = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('addressbook', 'entry'))); |
|
| 2294 | 2292 | $view = false; |
| 2295 | 2293 | } |
| 2296 | 2294 | else |
@@ -2301,12 +2299,12 @@ discard block |
||
| 2301 | 2299 | if (!$contact_id && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id']) && !is_array($content['link_to']['to_id'])) |
| 2302 | 2300 | { |
| 2303 | 2301 | $link_ids = is_array($_REQUEST['link_id']) ? $_REQUEST['link_id'] : array($_REQUEST['link_id']); |
| 2304 | - foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
|
| 2302 | + foreach (is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
|
| 2305 | 2303 | { |
| 2306 | 2304 | $link_id = $link_ids[$n]; |
| 2307 | - if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) // gard against XSS |
|
| 2305 | + if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i', $link_app.':'.$link_id)) // gard against XSS |
|
| 2308 | 2306 | { |
| 2309 | - Link::link('addressbook',$content['link_to']['to_id'],$link_app,$link_id); |
|
| 2307 | + Link::link('addressbook', $content['link_to']['to_id'], $link_app, $link_id); |
|
| 2310 | 2308 | } |
| 2311 | 2309 | } |
| 2312 | 2310 | } |
@@ -2314,8 +2312,8 @@ discard block |
||
| 2314 | 2312 | if ($content['id']) |
| 2315 | 2313 | { |
| 2316 | 2314 | // last and next calendar date |
| 2317 | - $dates = current($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']),false)); |
|
| 2318 | - if(is_array($dates)) $content += $dates; |
|
| 2315 | + $dates = current($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']), false)); |
|
| 2316 | + if (is_array($dates)) $content += $dates; |
|
| 2319 | 2317 | } |
| 2320 | 2318 | |
| 2321 | 2319 | // Registry has view_id as contact_id, so set it (custom fields uses it) |
@@ -2326,7 +2324,7 @@ discard block |
||
| 2326 | 2324 | |
| 2327 | 2325 | // Avoid setting conflicts with private custom fields |
| 2328 | 2326 | $content['private_cfs'] = array(); |
| 2329 | - foreach(Api\Storage\Customfields::get('addressbook', true) as $name => $cf) |
|
| 2327 | + foreach (Api\Storage\Customfields::get('addressbook', true) as $name => $cf) |
|
| 2330 | 2328 | { |
| 2331 | 2329 | if ($this->config['private_cf_tab'] && $cf['private'] && isset($content['#'.$name])) |
| 2332 | 2330 | { |
@@ -2339,7 +2337,7 @@ discard block |
||
| 2339 | 2337 | $content['addr_format2'] = $this->addr_format_by_country($content['adr_two_countryname']); |
| 2340 | 2338 | |
| 2341 | 2339 | //_debug_array($content); |
| 2342 | - $readonlys['button[delete]'] = !$content['owner'] || !$this->check_perms(Acl::DELETE,$content); |
|
| 2340 | + $readonlys['button[delete]'] = !$content['owner'] || !$this->check_perms(Acl::DELETE, $content); |
|
| 2343 | 2341 | $readonlys['button[copy]'] = $readonlys['button[edit]'] = $readonlys['button[vcard]'] = true; |
| 2344 | 2342 | $readonlys['button[save]'] = $readonlys['button[apply]'] = $view; |
| 2345 | 2343 | if ($view) |
@@ -2351,19 +2349,18 @@ discard block |
||
| 2351 | 2349 | $sel_options['fileas_type'] = $this->fileas_options($content); |
| 2352 | 2350 | $sel_options['adr_one_countrycode']['-custom-'] = lang('Custom'); |
| 2353 | 2351 | $sel_options['owner'] = $this->get_addressbooks(Acl::ADD); |
| 2354 | - if ($content['owner']) unset($sel_options['owner'][0]); // do not offer to switch to accounts, as we do not support moving contacts to accounts |
|
| 2355 | - if ((string) $content['owner'] !== '') |
|
| 2352 | + if ($content['owner']) unset($sel_options['owner'][0]); // do not offer to switch to accounts, as we do not support moving contacts to accounts |
|
| 2353 | + if ((string)$content['owner'] !== '') |
|
| 2356 | 2354 | { |
| 2357 | 2355 | if (!isset($sel_options['owner'][(int)$content['owner']])) |
| 2358 | 2356 | { |
| 2359 | - $sel_options['owner'][(int)$content['owner']] = !$content['owner'] ? lang('Accounts') : |
|
| 2360 | - Api\Accounts::username($content['owner']); |
|
| 2357 | + $sel_options['owner'][(int)$content['owner']] = !$content['owner'] ? lang('Accounts') : Api\Accounts::username($content['owner']); |
|
| 2361 | 2358 | } |
| 2362 | - $readonlys['owner'] = !$content['owner'] || // dont allow to move accounts, as this mean deleting the user incl. all content he owns |
|
| 2363 | - $content['id'] && !$this->check_perms(Acl::DELETE,$content); // you need delete rights to move an existing contact into an other addressbook |
|
| 2359 | + $readonlys['owner'] = !$content['owner'] || // dont allow to move accounts, as this mean deleting the user incl. all content he owns |
|
| 2360 | + $content['id'] && !$this->check_perms(Acl::DELETE, $content); // you need delete rights to move an existing contact into an other addressbook |
|
| 2364 | 2361 | } |
| 2365 | 2362 | // set the unsupported fields from the backend to readonly |
| 2366 | - foreach($this->get_fields('unsupported',$content['id'],$content['owner']) as $field) |
|
| 2363 | + foreach ($this->get_fields('unsupported', $content['id'], $content['owner']) as $field) |
|
| 2367 | 2364 | { |
| 2368 | 2365 | $readonlys[$field] = true; |
| 2369 | 2366 | } |
@@ -2373,7 +2370,7 @@ discard block |
||
| 2373 | 2370 | $readonlys['__ALL__'] = true; |
| 2374 | 2371 | $readonlys['button[cancel]'] = false; |
| 2375 | 2372 | |
| 2376 | - foreach($this->own_account_acl as $field) |
|
| 2373 | + foreach ($this->own_account_acl as $field) |
|
| 2377 | 2374 | { |
| 2378 | 2375 | $readonlys[$field] = false; |
| 2379 | 2376 | } |
@@ -2395,9 +2392,9 @@ discard block |
||
| 2395 | 2392 | if (isset($readonlys['n_fileas'])) $readonlys['fileas_type'] = $readonlys['n_fileas']; |
| 2396 | 2393 | // disable not needed tabs |
| 2397 | 2394 | $readonlys['tabs']['cats'] = !($content['cat_tab'] = $this->config['cat_tab']); |
| 2398 | - $readonlys['tabs']['custom'] = !$this->customfields || $this->get_backend($content['id'],$content['owner']) == $this->so_accounts; |
|
| 2395 | + $readonlys['tabs']['custom'] = !$this->customfields || $this->get_backend($content['id'], $content['owner']) == $this->so_accounts; |
|
| 2399 | 2396 | $readonlys['tabs']['custom_private'] = $readonlys['tabs']['custom'] || !$this->config['private_cf_tab']; |
| 2400 | - $readonlys['tabs']['distribution_list'] = !$content['distrib_lists'];#false; |
|
| 2397 | + $readonlys['tabs']['distribution_list'] = !$content['distrib_lists']; #false; |
|
| 2401 | 2398 | $readonlys['tabs']['history'] = $this->contact_repository != 'sql' || !$content['id'] || |
| 2402 | 2399 | $this->account_repository != 'sql' && $content['account_id']; |
| 2403 | 2400 | if (!$content['id']) $readonlys['button[delete]'] = !$content['id']; |
@@ -2409,7 +2406,7 @@ discard block |
||
| 2409 | 2406 | { |
| 2410 | 2407 | $this->_set_readonlys_for_own_account_acl($readonlys, $content['id']); |
| 2411 | 2408 | } |
| 2412 | - for($i = -23; $i<=23; $i++) |
|
| 2409 | + for ($i = -23; $i <= 23; $i++) |
|
| 2413 | 2410 | { |
| 2414 | 2411 | $tz[$i] = ($i > 0 ? '+' : '').$i; |
| 2415 | 2412 | } |
@@ -2417,11 +2414,11 @@ discard block |
||
| 2417 | 2414 | $content['tz'] = $content['tz'] ? $content['tz'] : '0'; |
| 2418 | 2415 | if (count($this->content_types) > 1) |
| 2419 | 2416 | { |
| 2420 | - foreach($this->content_types as $type => $data) |
|
| 2417 | + foreach ($this->content_types as $type => $data) |
|
| 2421 | 2418 | { |
| 2422 | 2419 | $sel_options['tid'][$type] = $data['name']; |
| 2423 | 2420 | } |
| 2424 | - $content['typegfx'] = Api\Html::image('addressbook',$this->content_types[$content['tid']]['options']['icon'],'',' width="16px" height="16px"'); |
|
| 2421 | + $content['typegfx'] = Api\Html::image('addressbook', $this->content_types[$content['tid']]['options']['icon'], '', ' width="16px" height="16px"'); |
|
| 2425 | 2422 | } |
| 2426 | 2423 | else |
| 2427 | 2424 | { |
@@ -2435,10 +2432,10 @@ discard block |
||
| 2435 | 2432 | ); |
| 2436 | 2433 | |
| 2437 | 2434 | // Links for deleted entries |
| 2438 | - if($content['tid'] == self::DELETED_TYPE) |
|
| 2435 | + if ($content['tid'] == self::DELETED_TYPE) |
|
| 2439 | 2436 | { |
| 2440 | 2437 | $content['link_to']['show_deleted'] = true; |
| 2441 | - if(!$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge') |
|
| 2438 | + if (!$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge') |
|
| 2442 | 2439 | { |
| 2443 | 2440 | $readonlys['button[delete]'] = true; |
| 2444 | 2441 | } |
@@ -2447,12 +2444,12 @@ discard block |
||
| 2447 | 2444 | // Enable history |
| 2448 | 2445 | $this->setup_history($content, $sel_options); |
| 2449 | 2446 | |
| 2450 | - $content['photo'] = $this->photo_src($content['id'],$content['jpegphoto'],'',$content['etag']); |
|
| 2447 | + $content['photo'] = $this->photo_src($content['id'], $content['jpegphoto'], '', $content['etag']); |
|
| 2451 | 2448 | |
| 2452 | 2449 | if ($content['private']) $content['owner'] .= 'p'; |
| 2453 | 2450 | |
| 2454 | 2451 | // for custom types, check if we have a custom edit template named "addressbook.edit.$type", $type is the name |
| 2455 | - if (in_array($content['tid'], array('n',self::DELETED_TYPE)) || !$this->tmpl->read('addressbook.edit.'.$this->content_types[$content['tid']]['name'])) |
|
| 2452 | + if (in_array($content['tid'], array('n', self::DELETED_TYPE)) || !$this->tmpl->read('addressbook.edit.'.$this->content_types[$content['tid']]['name'])) |
|
| 2456 | 2453 | { |
| 2457 | 2454 | $this->tmpl->read('addressbook.edit'); |
| 2458 | 2455 | } |
@@ -2460,21 +2457,21 @@ discard block |
||
| 2460 | 2457 | // allow other apps to add tabs to addressbook edit |
| 2461 | 2458 | $preserve = $content; |
| 2462 | 2459 | unset($preserve['jpegphoto']); |
| 2463 | - $content['jpegphoto'] = !empty($content['jpegphoto']); // unused and messes up json encoding (not utf-8) |
|
| 2460 | + $content['jpegphoto'] = !empty($content['jpegphoto']); // unused and messes up json encoding (not utf-8) |
|
| 2464 | 2461 | $this->tmpl->setElementAttribute('tabs', 'add_tabs', true); |
| 2465 | - $tabs =& $this->tmpl->getElementAttribute('tabs', 'tabs'); |
|
| 2462 | + $tabs = & $this->tmpl->getElementAttribute('tabs', 'tabs'); |
|
| 2466 | 2463 | if (($first_call = !isset($tabs))) |
| 2467 | 2464 | { |
| 2468 | 2465 | $tabs = array(); |
| 2469 | 2466 | } |
| 2470 | 2467 | //error_log(__LINE__.': '.__METHOD__."() first_call=$first_call"); |
| 2471 | - $hook_data = Api\Hooks::process(array('location' => 'addressbook_edit')+$content); |
|
| 2468 | + $hook_data = Api\Hooks::process(array('location' => 'addressbook_edit') + $content); |
|
| 2472 | 2469 | //error_log(__METHOD__."() hook_data=".array2string($hook_data)); |
| 2473 | - foreach($hook_data as $extra_tabs) |
|
| 2470 | + foreach ($hook_data as $extra_tabs) |
|
| 2474 | 2471 | { |
| 2475 | 2472 | if (!$extra_tabs) continue; |
| 2476 | 2473 | |
| 2477 | - foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
|
| 2474 | + foreach (isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
|
| 2478 | 2475 | { |
| 2479 | 2476 | if ($extra_tab['data'] && is_array($extra_tab['data'])) |
| 2480 | 2477 | { |
@@ -2519,15 +2516,15 @@ discard block |
||
| 2519 | 2516 | * @param array &$readonlys |
| 2520 | 2517 | * @param int $id |
| 2521 | 2518 | */ |
| 2522 | - function _set_readonlys_for_own_account_acl(&$readonlys,$id) |
|
| 2519 | + function _set_readonlys_for_own_account_acl(&$readonlys, $id) |
|
| 2523 | 2520 | { |
| 2524 | 2521 | // regular fields depending on the backend |
| 2525 | - foreach($this->get_fields('supported',$id,0) as $field) |
|
| 2522 | + foreach ($this->get_fields('supported', $id, 0) as $field) |
|
| 2526 | 2523 | { |
| 2527 | - if (!$this->own_account_acl || !in_array($field,$this->own_account_acl)) |
|
| 2524 | + if (!$this->own_account_acl || !in_array($field, $this->own_account_acl)) |
|
| 2528 | 2525 | { |
| 2529 | 2526 | $readonlys[$field] = true; |
| 2530 | - switch($field) |
|
| 2527 | + switch ($field) |
|
| 2531 | 2528 | { |
| 2532 | 2529 | case 'tel_work': |
| 2533 | 2530 | case 'tel_cell': |
@@ -2543,16 +2540,16 @@ discard block |
||
| 2543 | 2540 | // custom fields |
| 2544 | 2541 | if ($this->customfields) |
| 2545 | 2542 | { |
| 2546 | - foreach(array_keys($this->customfields) as $name) |
|
| 2543 | + foreach (array_keys($this->customfields) as $name) |
|
| 2547 | 2544 | { |
| 2548 | - if (!$this->own_account_acl || !in_array('#'.$name,$this->own_account_acl)) |
|
| 2545 | + if (!$this->own_account_acl || !in_array('#'.$name, $this->own_account_acl)) |
|
| 2549 | 2546 | { |
| 2550 | 2547 | $readonlys['#'.$name] = true; |
| 2551 | 2548 | } |
| 2552 | 2549 | } |
| 2553 | 2550 | } |
| 2554 | 2551 | // links |
| 2555 | - if (!$this->own_account_acl || !in_array('link_to',$this->own_account_acl)) |
|
| 2552 | + if (!$this->own_account_acl || !in_array('link_to', $this->own_account_acl)) |
|
| 2556 | 2553 | { |
| 2557 | 2554 | $readonlys['link_to'] = true; |
| 2558 | 2555 | } |
@@ -2570,9 +2567,9 @@ discard block |
||
| 2570 | 2567 | * 'data' => array of id => "full name (addressbook)" pairs |
| 2571 | 2568 | * 'fileas_options' |
| 2572 | 2569 | */ |
| 2573 | - public function ajax_check_values($values, $name, $own_id=0) |
|
| 2570 | + public function ajax_check_values($values, $name, $own_id = 0) |
|
| 2574 | 2571 | { |
| 2575 | - $fields = explode(',',$GLOBALS['egw_info']['user']['preferences']['addressbook']['duplicate_fields']); |
|
| 2572 | + $fields = explode(',', $GLOBALS['egw_info']['user']['preferences']['addressbook']['duplicate_fields']); |
|
| 2576 | 2573 | $threshold = (int)$GLOBALS['egw_info']['user']['preferences']['addressbook']['duplicate_threshold']; |
| 2577 | 2574 | |
| 2578 | 2575 | $ret = array('doublicates' => array(), 'msg' => null); |
@@ -2597,17 +2594,17 @@ discard block |
||
| 2597 | 2594 | |
| 2598 | 2595 | // if name, firstname or org changed and enough are specified, check for doublicates |
| 2599 | 2596 | $specified_count = 0; |
| 2600 | - foreach($fields as $field) |
|
| 2597 | + foreach ($fields as $field) |
|
| 2601 | 2598 | { |
| 2602 | - if($values[trim($field)]) |
|
| 2599 | + if ($values[trim($field)]) |
|
| 2603 | 2600 | { |
| 2604 | 2601 | $specified_count++; |
| 2605 | 2602 | } |
| 2606 | 2603 | } |
| 2607 | - if (in_array($name,$fields) && $specified_count >= $threshold) |
|
| 2604 | + if (in_array($name, $fields) && $specified_count >= $threshold) |
|
| 2608 | 2605 | { |
| 2609 | 2606 | $filter = array(); |
| 2610 | - foreach($fields as $n) // use email too, to exclude obvious false positives |
|
| 2607 | + foreach ($fields as $n) // use email too, to exclude obvious false positives |
|
| 2611 | 2608 | { |
| 2612 | 2609 | if (!empty($values[$n])) $filter[$n] = $values[$n]; |
| 2613 | 2610 | } |
@@ -2616,7 +2613,7 @@ discard block |
||
| 2616 | 2613 | } |
| 2617 | 2614 | if ($contacts) |
| 2618 | 2615 | { |
| 2619 | - foreach($contacts as $contact) |
|
| 2616 | + foreach ($contacts as $contact) |
|
| 2620 | 2617 | { |
| 2621 | 2618 | if ($own_id && $contact['id'] == $own_id) continue; |
| 2622 | 2619 | |
@@ -2640,26 +2637,24 @@ discard block |
||
| 2640 | 2637 | * |
| 2641 | 2638 | * @param array $content |
| 2642 | 2639 | */ |
| 2643 | - function view(array $content=null) |
|
| 2640 | + function view(array $content = null) |
|
| 2644 | 2641 | { |
| 2645 | 2642 | // CRM list comes from content, request, or preference |
| 2646 | - $crm_list = $content['crm_list'] ? $content['crm_list'] : |
|
| 2647 | - ($_GET['crm_list'] ? $_GET['crm_list'] : $GLOBALS['egw_info']['user']['preferences']['addressbook']['crm_list']); |
|
| 2648 | - if(!$crm_list || $crm_list == '~edit~') $crm_list = 'infolog'; |
|
| 2643 | + $crm_list = $content['crm_list'] ? $content['crm_list'] : ($_GET['crm_list'] ? $_GET['crm_list'] : $GLOBALS['egw_info']['user']['preferences']['addressbook']['crm_list']); |
|
| 2644 | + if (!$crm_list || $crm_list == '~edit~') $crm_list = 'infolog'; |
|
| 2649 | 2645 | |
| 2650 | - if(is_array($content)) |
|
| 2646 | + if (is_array($content)) |
|
| 2651 | 2647 | { |
| 2652 | 2648 | $button = key($content['button']); |
| 2653 | 2649 | switch ($content['toolbar'] ? $content['toolbar'] : $button) |
| 2654 | 2650 | { |
| 2655 | - case 'vcard': |
|
| 2656 | - Egw::redirect_link('/index.php','menuaction=addressbook.uivcard.out&ab_id=' .$content['id']); |
|
| 2651 | + case 'vcard' : Egw::redirect_link('/index.php', 'menuaction=addressbook.uivcard.out&ab_id='.$content['id']); |
|
| 2657 | 2652 | |
| 2658 | 2653 | case 'cancel': |
| 2659 | - Egw::redirect_link('/index.php','menuaction=addressbook.addressbook_ui.index&ajax=true'); |
|
| 2654 | + Egw::redirect_link('/index.php', 'menuaction=addressbook.addressbook_ui.index&ajax=true'); |
|
| 2660 | 2655 | |
| 2661 | 2656 | case 'delete': |
| 2662 | - Egw::redirect_link('/index.php',array( |
|
| 2657 | + Egw::redirect_link('/index.php', array( |
|
| 2663 | 2658 | 'menuaction' => 'addressbook.addressbook_ui.index', |
| 2664 | 2659 | 'msg' => $this->delete($content) ? lang('Contact deleted') : lang('Error deleting the contact !!!'), |
| 2665 | 2660 | )); |
@@ -2677,9 +2672,9 @@ discard block |
||
| 2677 | 2672 | $num_rows = $this->get_rows($query, $rows, $readonlys, true); |
| 2678 | 2673 | //error_log(__METHOD__."() get_rows()=$num_rows rows=".array2string($rows)); |
| 2679 | 2674 | $contact_id = $rows[0]; |
| 2680 | - if(!$contact_id || !is_array($content = $this->read($contact_id))) |
|
| 2675 | + if (!$contact_id || !is_array($content = $this->read($contact_id))) |
|
| 2681 | 2676 | { |
| 2682 | - Egw::redirect_link('/index.php',array( |
|
| 2677 | + Egw::redirect_link('/index.php', array( |
|
| 2683 | 2678 | 'menuaction' => 'addressbook.addressbook_ui.index', |
| 2684 | 2679 | 'msg' => $content, |
| 2685 | 2680 | 'ajax' => 'true' |
@@ -2688,14 +2683,14 @@ discard block |
||
| 2688 | 2683 | $content['index'] = $query['start']; |
| 2689 | 2684 | |
| 2690 | 2685 | // List nextmatch is already there, just update the filter |
| 2691 | - if($contact_id && Api\Json\Request::isJSONRequest()) |
|
| 2686 | + if ($contact_id && Api\Json\Request::isJSONRequest()) |
|
| 2692 | 2687 | { |
| 2693 | - switch($crm_list) |
|
| 2688 | + switch ($crm_list) |
|
| 2694 | 2689 | { |
| 2695 | 2690 | case 'infolog': |
| 2696 | 2691 | case 'tracker': |
| 2697 | 2692 | default: |
| 2698 | - Api\Json\Response::get()->apply('app.addressbook.view_set_list',Array(Array('action'=>'addressbook', 'action_id' => $contact_id))); |
|
| 2693 | + Api\Json\Response::get()->apply('app.addressbook.view_set_list', Array(Array('action'=>'addressbook', 'action_id' => $contact_id))); |
|
| 2699 | 2694 | break; |
| 2700 | 2695 | } |
| 2701 | 2696 | |
@@ -2726,13 +2721,13 @@ discard block |
||
| 2726 | 2721 | $_GET['index'] = 0; |
| 2727 | 2722 | } |
| 2728 | 2723 | $contact_id = $_GET['contact_id'] ? $_GET['contact_id'] : ((int)$_GET['account_id'] ? 'account:'.(int)$_GET['account_id'] : 0); |
| 2729 | - if(!$contact_id || !is_array($content = $this->read($contact_id))) |
|
| 2724 | + if (!$contact_id || !is_array($content = $this->read($contact_id))) |
|
| 2730 | 2725 | { |
| 2731 | - Egw::redirect_link('/index.php',array( |
|
| 2726 | + Egw::redirect_link('/index.php', array( |
|
| 2732 | 2727 | 'menuaction' => 'addressbook.addressbook_ui.index', |
| 2733 | 2728 | 'msg' => $content, |
| 2734 | 2729 | 'ajax' => 'true' |
| 2735 | - )+(isset($_GET['search']) ? array('search' => $_GET['search']) : array())); |
|
| 2730 | + ) + (isset($_GET['search']) ? array('search' => $_GET['search']) : array())); |
|
| 2736 | 2731 | } |
| 2737 | 2732 | if (isset($_GET['index'])) |
| 2738 | 2733 | { |
@@ -2745,25 +2740,25 @@ discard block |
||
| 2745 | 2740 | $num_rows = $this->get_rows($query, $rows, $readonlys, true); |
| 2746 | 2741 | } |
| 2747 | 2742 | } |
| 2748 | - $content['jpegphoto'] = !empty($content['jpegphoto']); // unused and messes up json encoding (not utf-8) |
|
| 2743 | + $content['jpegphoto'] = !empty($content['jpegphoto']); // unused and messes up json encoding (not utf-8) |
|
| 2749 | 2744 | |
| 2750 | 2745 | // make everything not explicit mentioned readonly |
| 2751 | 2746 | $readonlys['__ALL__'] = true; |
| 2752 | 2747 | $readonlys['photo'] = $readonlys['button[cancel]'] = $readonlys['button[copy]'] = |
| 2753 | 2748 | $readonlys['button[ok]'] = $readonlys['button[more]'] = $readonlys['toolbar'] = false; |
| 2754 | 2749 | |
| 2755 | - foreach(array_keys($this->contact_fields) as $key) |
|
| 2750 | + foreach (array_keys($this->contact_fields) as $key) |
|
| 2756 | 2751 | { |
| 2757 | - if (in_array($key,array('tel_home','tel_work','tel_cell','tel_fax'))) |
|
| 2752 | + if (in_array($key, array('tel_home', 'tel_work', 'tel_cell', 'tel_fax'))) |
|
| 2758 | 2753 | { |
| 2759 | 2754 | $content[$key.'2'] = $content[$key]; |
| 2760 | 2755 | } |
| 2761 | 2756 | } |
| 2762 | 2757 | |
| 2763 | 2758 | // respect category permissions |
| 2764 | - if(!empty($content['cat_id'])) |
|
| 2759 | + if (!empty($content['cat_id'])) |
|
| 2765 | 2760 | { |
| 2766 | - $content['cat_id'] = $this->categories->check_list(Acl::READ,$content['cat_id']); |
|
| 2761 | + $content['cat_id'] = $this->categories->check_list(Acl::READ, $content['cat_id']); |
|
| 2767 | 2762 | } |
| 2768 | 2763 | $content['cat_id_tree'] = $content['cat_id']; |
| 2769 | 2764 | |
@@ -2773,12 +2768,12 @@ discard block |
||
| 2773 | 2768 | 'to_id' => $content['id'], |
| 2774 | 2769 | ); |
| 2775 | 2770 | // Links for deleted entries |
| 2776 | - if($content['tid'] == self::DELETED_TYPE) |
|
| 2771 | + if ($content['tid'] == self::DELETED_TYPE) |
|
| 2777 | 2772 | { |
| 2778 | 2773 | $content['link_to']['show_deleted'] = true; |
| 2779 | 2774 | } |
| 2780 | - $readonlys['button[delete]'] = !$content['owner'] || !$this->check_perms(Acl::DELETE,$content); |
|
| 2781 | - $readonlys['button[edit]'] = !$this->check_perms(Acl::EDIT,$content); |
|
| 2775 | + $readonlys['button[delete]'] = !$content['owner'] || !$this->check_perms(Acl::DELETE, $content); |
|
| 2776 | + $readonlys['button[edit]'] = !$this->check_perms(Acl::EDIT, $content); |
|
| 2782 | 2777 | |
| 2783 | 2778 | // how to display addresses |
| 2784 | 2779 | $content['addr_format'] = $this->addr_format_by_country($content['adr_one_countryname']); |
@@ -2786,7 +2781,7 @@ discard block |
||
| 2786 | 2781 | |
| 2787 | 2782 | $sel_options['fileas_type'][$content['fileas_type']] = $this->fileas($content); |
| 2788 | 2783 | $sel_options['owner'] = $this->get_addressbooks(); |
| 2789 | - for($i = -23; $i<=23; $i++) |
|
| 2784 | + for ($i = -23; $i <= 23; $i++) |
|
| 2790 | 2785 | { |
| 2791 | 2786 | $tz[$i] = ($i > 0 ? '+' : '').$i; |
| 2792 | 2787 | } |
@@ -2794,11 +2789,11 @@ discard block |
||
| 2794 | 2789 | $content['tz'] = $content['tz'] ? $content['tz'] : 0; |
| 2795 | 2790 | if (count($this->content_types) > 1) |
| 2796 | 2791 | { |
| 2797 | - foreach($this->content_types as $type => $data) |
|
| 2792 | + foreach ($this->content_types as $type => $data) |
|
| 2798 | 2793 | { |
| 2799 | 2794 | $sel_options['tid'][$type] = $data['name']; |
| 2800 | 2795 | } |
| 2801 | - $content['typegfx'] = Api\Html::image('addressbook',$this->content_types[$content['tid']]['options']['icon'],'',' width="16px" height="16px"'); |
|
| 2796 | + $content['typegfx'] = Api\Html::image('addressbook', $this->content_types[$content['tid']]['options']['icon'], '', ' width="16px" height="16px"'); |
|
| 2802 | 2797 | } |
| 2803 | 2798 | else |
| 2804 | 2799 | { |
@@ -2815,7 +2810,7 @@ discard block |
||
| 2815 | 2810 | { |
| 2816 | 2811 | $content['owner'] .= 'p'; |
| 2817 | 2812 | } |
| 2818 | - $this->tmpl->set_cell_attribute('change_org','disabled',true); |
|
| 2813 | + $this->tmpl->set_cell_attribute('change_org', 'disabled', true); |
|
| 2819 | 2814 | |
| 2820 | 2815 | // Prevent double countries - invalid code blanks it, disabling doesn't work |
| 2821 | 2816 | $content['adr_one_countrycode'] = '-'; |
@@ -2828,14 +2823,14 @@ discard block |
||
| 2828 | 2823 | $readonlys['tabs']['cats'] = !($content['cat_tab'] = $this->config['cat_tab']); |
| 2829 | 2824 | $readonlys['tabs']['custom'] = !$this->customfields; |
| 2830 | 2825 | $readonlys['tabs']['custom_private'] = !$this->customfields || !$this->config['private_cf_tab']; |
| 2831 | - $readonlys['tabs']['distribution_list'] = !$content['distrib_lists'];#false; |
|
| 2826 | + $readonlys['tabs']['distribution_list'] = !$content['distrib_lists']; #false; |
|
| 2832 | 2827 | $readonlys['tabs']['history'] = $this->contact_repository != 'sql' || !$content['id'] || |
| 2833 | 2828 | $this->account_repository != 'sql' && $content['account_id']; |
| 2834 | 2829 | if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0; |
| 2835 | 2830 | |
| 2836 | 2831 | // last and next calendar date |
| 2837 | - if (!empty($content['id'])) $dates = current($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']),false)); |
|
| 2838 | - if(is_array($dates)) $content += $dates; |
|
| 2832 | + if (!empty($content['id'])) $dates = current($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']), false)); |
|
| 2833 | + if (is_array($dates)) $content += $dates; |
|
| 2839 | 2834 | |
| 2840 | 2835 | // Disable importexport |
| 2841 | 2836 | $GLOBALS['egw_info']['flags']['disable_importexport']['export'] = true; |
@@ -2877,7 +2872,7 @@ discard block |
||
| 2877 | 2872 | { |
| 2878 | 2873 | unset($actions['back']); |
| 2879 | 2874 | } |
| 2880 | - if (!isset($content['index']) || $content['index'] >= $num_rows-1) |
|
| 2875 | + if (!isset($content['index']) || $content['index'] >= $num_rows - 1) |
|
| 2881 | 2876 | { |
| 2882 | 2877 | unset($actions['next']); |
| 2883 | 2878 | } |
@@ -2889,7 +2884,7 @@ discard block |
||
| 2889 | 2884 | // need to load list's app.js now, as exec calls header before other app can include it |
| 2890 | 2885 | Framework::includeJS('/'.$crm_list.'/js/app.js'); |
| 2891 | 2886 | |
| 2892 | - $this->tmpl->exec('addressbook.addressbook_ui.view',$content,$sel_options,$readonlys,array( |
|
| 2887 | + $this->tmpl->exec('addressbook.addressbook_ui.view', $content, $sel_options, $readonlys, array( |
|
| 2893 | 2888 | 'id' => $content['id'], |
| 2894 | 2889 | 'index' => $content['index'], |
| 2895 | 2890 | 'crm_list' => $crm_list |
@@ -2897,12 +2892,12 @@ discard block |
||
| 2897 | 2892 | |
| 2898 | 2893 | // Only load this on first time - we're using AJAX, so it stays there through submits. |
| 2899 | 2894 | // Sending it again (via ajax) will break the addressbook.view etemplate2 |
| 2900 | - if($contact_id) |
|
| 2895 | + if ($contact_id) |
|
| 2901 | 2896 | { |
| 2902 | 2897 | Api\Hooks::single(array( |
| 2903 | 2898 | 'location' => 'addressbook_view', |
| 2904 | 2899 | 'ab_id' => $content['id'] |
| 2905 | - ),$crm_list); |
|
| 2900 | + ), $crm_list); |
|
| 2906 | 2901 | } |
| 2907 | 2902 | } |
| 2908 | 2903 | |
@@ -2914,30 +2909,30 @@ discard block |
||
| 2914 | 2909 | */ |
| 2915 | 2910 | function email2link($email) |
| 2916 | 2911 | { |
| 2917 | - if (strpos($email,'@') == false) return ''; |
|
| 2912 | + if (strpos($email, '@') == false) return ''; |
|
| 2918 | 2913 | |
| 2919 | - if($GLOBALS['egw_info']['user']['apps']['mail']) |
|
| 2914 | + if ($GLOBALS['egw_info']['user']['apps']['mail']) |
|
| 2920 | 2915 | { |
| 2921 | 2916 | return array( |
| 2922 | 2917 | 'menuaction' => 'mail.mail_compose.compose', |
| 2923 | 2918 | 'send_to' => base64_encode($email) |
| 2924 | 2919 | ); |
| 2925 | 2920 | } |
| 2926 | - if($GLOBALS['egw_info']['user']['apps']['felamimail']) |
|
| 2921 | + if ($GLOBALS['egw_info']['user']['apps']['felamimail']) |
|
| 2927 | 2922 | { |
| 2928 | 2923 | return array( |
| 2929 | 2924 | 'menuaction' => 'felamimail.uicompose.compose', |
| 2930 | 2925 | 'send_to' => base64_encode($email) |
| 2931 | 2926 | ); |
| 2932 | 2927 | } |
| 2933 | - if($GLOBALS['egw_info']['user']['apps']['email']) |
|
| 2928 | + if ($GLOBALS['egw_info']['user']['apps']['email']) |
|
| 2934 | 2929 | { |
| 2935 | 2930 | return array( |
| 2936 | 2931 | 'menuaction' => 'email.uicompose.compose', |
| 2937 | 2932 | 'to' => $email, |
| 2938 | 2933 | ); |
| 2939 | 2934 | } |
| 2940 | - return 'mailto:' . $email; |
|
| 2935 | + return 'mailto:'.$email; |
|
| 2941 | 2936 | } |
| 2942 | 2937 | |
| 2943 | 2938 | /** |
@@ -2946,9 +2941,9 @@ discard block |
||
| 2946 | 2941 | * @param array $_content |
| 2947 | 2942 | * @return string |
| 2948 | 2943 | */ |
| 2949 | - function search($_content=array()) |
|
| 2944 | + function search($_content = array()) |
|
| 2950 | 2945 | { |
| 2951 | - if(!empty($_content)) |
|
| 2946 | + if (!empty($_content)) |
|
| 2952 | 2947 | { |
| 2953 | 2948 | |
| 2954 | 2949 | $_content['cat_id'] = $this->config['cat_tab'] === 'Tree' ? $_content['cat_id_tree'] : $_content['cat_id']; |
@@ -2963,10 +2958,10 @@ discard block |
||
| 2963 | 2958 | } |
| 2964 | 2959 | else |
| 2965 | 2960 | { |
| 2966 | - $query['advanced_search'] = array_intersect_key($_content,array_flip(array_merge($this->get_contact_columns(),array('operator','meth_select')))); |
|
| 2961 | + $query['advanced_search'] = array_intersect_key($_content, array_flip(array_merge($this->get_contact_columns(), array('operator', 'meth_select')))); |
|
| 2967 | 2962 | foreach ($query['advanced_search'] as $key => $value) |
| 2968 | 2963 | { |
| 2969 | - if(!$value) unset($query['advanced_search'][$key]); |
|
| 2964 | + if (!$value) unset($query['advanced_search'][$key]); |
|
| 2970 | 2965 | } |
| 2971 | 2966 | // Skip n_fn, it causes problems in sql |
| 2972 | 2967 | unset($query['advanced_search']['n_fn']); |
@@ -2982,7 +2977,7 @@ discard block |
||
| 2982 | 2977 | $response->call("app.addressbook.adv_search", array('advanced_search' => $_content['button']['search'] ? $query['advanced_search'] : '')); |
| 2983 | 2978 | if ($_content['button']['cancelsearch']) |
| 2984 | 2979 | { |
| 2985 | - Framework::window_close (); |
|
| 2980 | + Framework::window_close(); |
|
| 2986 | 2981 | |
| 2987 | 2982 | // No need to reload popup |
| 2988 | 2983 | return; |
@@ -2999,7 +2994,7 @@ discard block |
||
| 2999 | 2994 | // Avoid ID conflict with tree & selectboxes |
| 3000 | 2995 | $content['cat_id_tree'] = $content['cat_id']; |
| 3001 | 2996 | |
| 3002 | - for($i = -23; $i<=23; $i++) |
|
| 2997 | + for ($i = -23; $i <= 23; $i++) |
|
| 3003 | 2998 | { |
| 3004 | 2999 | $tz[$i] = ($i > 0 ? '+' : '').$i; |
| 3005 | 3000 | } |
@@ -3008,8 +3003,8 @@ discard block |
||
| 3008 | 3003 | //foreach($this->content_types as $type => $data) $sel_options['tid'][$type] = $data['name']; |
| 3009 | 3004 | |
| 3010 | 3005 | // configure search options |
| 3011 | - $sel_options['owner'] = $this->get_addressbooks(Acl::READ,lang('all')); |
|
| 3012 | - $sel_options['operator'] = array( |
|
| 3006 | + $sel_options['owner'] = $this->get_addressbooks(Acl::READ, lang('all')); |
|
| 3007 | + $sel_options['operator'] = array( |
|
| 3013 | 3008 | 'AND' => 'AND', |
| 3014 | 3009 | 'OR' => 'OR', |
| 3015 | 3010 | ); |
@@ -3019,12 +3014,12 @@ discard block |
||
| 3019 | 3014 | ); |
| 3020 | 3015 | if ($this->customfields) |
| 3021 | 3016 | { |
| 3022 | - foreach($this->customfields as $name => $data) |
|
| 3017 | + foreach ($this->customfields as $name => $data) |
|
| 3023 | 3018 | { |
| 3024 | 3019 | if (substr($data['type'], 0, 6) == 'select' && !($data['rows'] > 1)) |
| 3025 | 3020 | { |
| 3026 | 3021 | if (!isset($content['#'.$name])) $content['#'.$name] = ''; |
| 3027 | - if(!isset($data['values'][''])) $sel_options['#'.$name][''] = lang('Select one'); |
|
| 3022 | + if (!isset($data['values'][''])) $sel_options['#'.$name][''] = lang('Select one'); |
|
| 3028 | 3023 | } |
| 3029 | 3024 | // Make them not required, otherwise you can't search |
| 3030 | 3025 | $this->tmpl->setElementAttribute('#'.$name, 'needed', FALSE); |
@@ -3050,8 +3045,8 @@ discard block |
||
| 3050 | 3045 | |
| 3051 | 3046 | if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0; |
| 3052 | 3047 | |
| 3053 | - $this->tmpl->set_cell_attribute('change_org','disabled',true); |
|
| 3054 | - return $this->tmpl->exec('addressbook.addressbook_ui.search',$content,$sel_options,$readonlys,array(),2); |
|
| 3048 | + $this->tmpl->set_cell_attribute('change_org', 'disabled', true); |
|
| 3049 | + return $this->tmpl->exec('addressbook.addressbook_ui.search', $content, $sel_options, $readonlys, array(), 2); |
|
| 3055 | 3050 | } |
| 3056 | 3051 | |
| 3057 | 3052 | /** |
@@ -3060,12 +3055,12 @@ discard block |
||
| 3060 | 3055 | * |
| 3061 | 3056 | * @param type $contact_id |
| 3062 | 3057 | */ |
| 3063 | - function ajax_noPhotoExists ($contact_id) |
|
| 3058 | + function ajax_noPhotoExists($contact_id) |
|
| 3064 | 3059 | { |
| 3065 | 3060 | $response = Api\Json\Response::get(); |
| 3066 | 3061 | $response->data((!($contact = $this->read($contact_id)) || |
| 3067 | - empty($contact['jpegphoto']) && !(($contact['files'] & Api\Contacts::FILES_BIT_PHOTO) && |
|
| 3068 | - ($size = filesize($url=Api\Link::vfs_path('addressbook', $contact_id, Api\Contacts::FILES_PHOTO)))))); |
|
| 3062 | + empty($contact['jpegphoto']) && !(($contact['files']&Api\Contacts::FILES_BIT_PHOTO) && |
|
| 3063 | + ($size = filesize($url = Api\Link::vfs_path('addressbook', $contact_id, Api\Contacts::FILES_PHOTO)))))); |
|
| 3069 | 3064 | } |
| 3070 | 3065 | |
| 3071 | 3066 | /** |
@@ -3074,13 +3069,13 @@ discard block |
||
| 3074 | 3069 | * @param string $etemplate_exec_id to update id, files, etag, ... |
| 3075 | 3070 | * @param file string $file null means to delete |
| 3076 | 3071 | */ |
| 3077 | - function ajax_update_photo ($etemplate_exec_id, $file) |
|
| 3072 | + function ajax_update_photo($etemplate_exec_id, $file) |
|
| 3078 | 3073 | { |
| 3079 | 3074 | $et_request = Api\Etemplate\Request::read($etemplate_exec_id); |
| 3080 | 3075 | $response = Api\Json\Response::get(); |
| 3081 | 3076 | if ($file) |
| 3082 | 3077 | { |
| 3083 | - $filteredFile = substr($file, strpos($file, ",")+1); |
|
| 3078 | + $filteredFile = substr($file, strpos($file, ",") + 1); |
|
| 3084 | 3079 | // resize photo if wider then default width of 240pixel (keeping aspect ratio) |
| 3085 | 3080 | $decoded = $this->resize_photo(base64_decode($filteredFile)); |
| 3086 | 3081 | } |
@@ -3088,7 +3083,7 @@ discard block |
||
| 3088 | 3083 | // add photo into current eT2 request |
| 3089 | 3084 | $et_request->preserv = array_merge($et_request->preserv, array( |
| 3090 | 3085 | 'jpegphoto' => is_null($file) ? $file : $decoded, |
| 3091 | - 'photo_unchanged' => false, // hint photo is changed |
|
| 3086 | + 'photo_unchanged' => false, // hint photo is changed |
|
| 3092 | 3087 | )); |
| 3093 | 3088 | } |
| 3094 | 3089 | |
@@ -3103,14 +3098,14 @@ discard block |
||
| 3103 | 3098 | public function pubkey_uploaded(array $file, $widget_id, Api\Etemplate\Request $request, Api\Json\Response $response) |
| 3104 | 3099 | { |
| 3105 | 3100 | //error_log(__METHOD__."(".array2string($file).", ...) widget_id=$widget_id, id=".$request->content['id'].", files=".$request->content['files']); |
| 3106 | - unset($file, $response); // not used, but required by function signature |
|
| 3107 | - list(,,$path) = explode(':', $widget_id); |
|
| 3101 | + unset($file, $response); // not used, but required by function signature |
|
| 3102 | + list(,, $path) = explode(':', $widget_id); |
|
| 3108 | 3103 | $bit = $path === Api\Contacts::FILES_PGP_PUBKEY ? Api\Contacts::FILES_BIT_PGP_PUBKEY : Api\Contacts::FILES_BIT_SMIME_PUBKEY; |
| 3109 | - if (!($request->content['files'] & $bit) && $this->check_perms(Acl::EDIT, $request->content)) |
|
| 3104 | + if (!($request->content['files']&$bit) && $this->check_perms(Acl::EDIT, $request->content)) |
|
| 3110 | 3105 | { |
| 3111 | 3106 | $content = $request->content; |
| 3112 | 3107 | $content['files'] |= $bit; |
| 3113 | - $content['photo_unchanged'] = true; // hint no need to store photo |
|
| 3108 | + $content['photo_unchanged'] = true; // hint no need to store photo |
|
| 3114 | 3109 | if ($this->save($content)) |
| 3115 | 3110 | { |
| 3116 | 3111 | $changed = array_diff_assoc($content, $request->content); |
@@ -3158,15 +3153,15 @@ discard block |
||
| 3158 | 3153 | echo $GLOBALS['egw']->framework->navbar(); |
| 3159 | 3154 | |
| 3160 | 3155 | // check if user has admin rights AND if a valid fileas type is given (Security) |
| 3161 | - if (!$this->is_admin() || $_GET['type'] != '' && !in_array($_GET['type'],$this->fileas_types)) |
|
| 3156 | + if (!$this->is_admin() || $_GET['type'] != '' && !in_array($_GET['type'], $this->fileas_types)) |
|
| 3162 | 3157 | { |
| 3163 | 3158 | echo '<h1>'.lang('Permission denied !!!')."</h1>\n"; |
| 3164 | 3159 | } |
| 3165 | 3160 | else |
| 3166 | 3161 | { |
| 3167 | 3162 | $errors = null; |
| 3168 | - $updated = parent::set_all_fileas($_GET['type'],(boolean)$_GET['all'],$errors,true); // true = ignore Acl |
|
| 3169 | - echo '<p style="margin-top: 20px;"><b>'.lang('%1 contacts updated (%2 errors).',$updated,$errors)."</b></p>\n"; |
|
| 3163 | + $updated = parent::set_all_fileas($_GET['type'], (boolean)$_GET['all'], $errors, true); // true = ignore Acl |
|
| 3164 | + echo '<p style="margin-top: 20px;"><b>'.lang('%1 contacts updated (%2 errors).', $updated, $errors)."</b></p>\n"; |
|
| 3170 | 3165 | } |
| 3171 | 3166 | echo $GLOBALS['egw']->framework->footer(); |
| 3172 | 3167 | } |
@@ -3190,8 +3185,8 @@ discard block |
||
| 3190 | 3185 | else |
| 3191 | 3186 | { |
| 3192 | 3187 | $errors = null; |
| 3193 | - $updated = parent::set_all_cleanup($errors,true); // true = ignore Acl |
|
| 3194 | - echo '<p style="margin-top: 20px;"><b>'.lang('%1 contacts updated (%2 errors).',$updated,$errors)."</b></p>\n"; |
|
| 3188 | + $updated = parent::set_all_cleanup($errors, true); // true = ignore Acl |
|
| 3189 | + echo '<p style="margin-top: 20px;"><b>'.lang('%1 contacts updated (%2 errors).', $updated, $errors)."</b></p>\n"; |
|
| 3195 | 3190 | } |
| 3196 | 3191 | echo $GLOBALS['egw']->framework->footer(); |
| 3197 | 3192 | } |
@@ -3204,7 +3199,7 @@ discard block |
||
| 3204 | 3199 | if ($this->contact_repository == 'ldap' || !$content['id'] || |
| 3205 | 3200 | $this->account_repository == 'ldap' && $content['account_id']) |
| 3206 | 3201 | { |
| 3207 | - return; // no history for ldap as history table only allows integer id's |
|
| 3202 | + return; // no history for ldap as history table only allows integer id's |
|
| 3208 | 3203 | } |
| 3209 | 3204 | $content['history'] = array( |
| 3210 | 3205 | 'id' => $content['id'], |
@@ -3219,7 +3214,7 @@ discard block |
||
| 3219 | 3214 | ), |
| 3220 | 3215 | ); |
| 3221 | 3216 | |
| 3222 | - foreach($this->content_types as $id => $settings) |
|
| 3217 | + foreach ($this->content_types as $id => $settings) |
|
| 3223 | 3218 | { |
| 3224 | 3219 | $content['history']['status-widgets']['tid'][$id] = $settings['name']; |
| 3225 | 3220 | } |