@@ -92,7 +92,10 @@ 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')) |
|
| 96 | + { |
|
| 97 | + Api\Hooks::read(true); |
|
| 98 | + } |
|
| 96 | 99 | |
| 97 | 100 | $this->config =& $GLOBALS['egw_info']['server']; |
| 98 | 101 | |
@@ -131,15 +134,21 @@ discard block |
||
| 131 | 134 | { |
| 132 | 135 | $do_email = $_content['do_email']; |
| 133 | 136 | |
| 134 | - if (isset($_content['nm']['rows']['delete'])) // handle a single delete like delete with the checkboxes |
|
| 137 | + if (isset($_content['nm']['rows']['delete'])) |
|
| 138 | + { |
|
| 139 | + // handle a single delete like delete with the checkboxes |
|
| 135 | 140 | { |
| 136 | 141 | list($id) = @each($_content['nm']['rows']['delete']); |
| 142 | + } |
|
| 137 | 143 | $_content['nm']['action'] = 'delete'; |
| 138 | 144 | $_content['nm']['selected'] = array($id); |
| 139 | 145 | } |
| 140 | - if (isset($_content['nm']['rows']['document'])) // handle insert in default document button like an action |
|
| 146 | + if (isset($_content['nm']['rows']['document'])) |
|
| 147 | + { |
|
| 148 | + // handle insert in default document button like an action |
|
| 141 | 149 | { |
| 142 | 150 | list($id) = @each($_content['nm']['rows']['document']); |
| 151 | + } |
|
| 143 | 152 | $_content['nm']['action'] = 'document'; |
| 144 | 153 | $_content['nm']['selected'] = array($id); |
| 145 | 154 | } |
@@ -149,10 +158,13 @@ discard block |
||
| 149 | 158 | { |
| 150 | 159 | $msg = lang('You need to select some contacts first'); |
| 151 | 160 | } |
| 152 | - elseif ($_content['nm']['action'] == 'view_org') // org-view via context menu |
|
| 161 | + elseif ($_content['nm']['action'] == 'view_org') |
|
| 162 | + { |
|
| 163 | + // org-view via context menu |
|
| 153 | 164 | { |
| 154 | 165 | $_content['nm']['org_view'] = array_shift($_content['nm']['selected']); |
| 155 | 166 | } |
| 167 | + } |
|
| 156 | 168 | else |
| 157 | 169 | { |
| 158 | 170 | $success = $failed = $action_msg = null; |
@@ -175,10 +187,13 @@ discard block |
||
| 175 | 187 | list($org) = each($_content['nm']['rows']['infolog']); |
| 176 | 188 | return $this->infolog_org_view($org); |
| 177 | 189 | } |
| 178 | - if ($_content['nm']['rows']['view']) // show all contacts of an organisation |
|
| 190 | + if ($_content['nm']['rows']['view']) |
|
| 191 | + { |
|
| 192 | + // show all contacts of an organisation |
|
| 179 | 193 | { |
| 180 | 194 | list($org_view) = each($_content['nm']['rows']['view']); |
| 181 | 195 | } |
| 196 | + } |
|
| 182 | 197 | else |
| 183 | 198 | { |
| 184 | 199 | $org_view = $_content['nm']['org_view']; |
@@ -271,10 +286,14 @@ discard block |
||
| 271 | 286 | } |
| 272 | 287 | |
| 273 | 288 | // Search parameter passed in |
| 274 | - if ($_GET['search']) { |
|
| 289 | + if ($_GET['search']) |
|
| 290 | + { |
|
| 275 | 291 | $content['nm']['search'] = $_GET['search']; |
| 276 | 292 | } |
| 277 | - if (isset($typeselection)) $content['nm']['col_filter']['tid'] = $typeselection; |
|
| 293 | + if (isset($typeselection)) |
|
| 294 | + { |
|
| 295 | + $content['nm']['col_filter']['tid'] = $typeselection; |
|
| 296 | + } |
|
| 278 | 297 | // save the tid for use in creating new addressbook entrys via UI. Current tid is to be used as type of new entrys |
| 279 | 298 | //error_log(__METHOD__.__LINE__.' '.$content['nm']['col_filter']['tid']); |
| 280 | 299 | Api\Cache::setSession('addressbook','active_tid',$content['nm']['col_filter']['tid']); |
@@ -312,7 +331,10 @@ discard block |
||
| 312 | 331 | $sel_options['adr_one_countrycode']['-custom-'] = lang('No country selected'); |
| 313 | 332 | |
| 314 | 333 | // if there is any export limit set, pass it on to the nextmatch, to be evaluated by the export |
| 315 | - if (isset($this->config['contact_export_limit']) && (int)$this->config['contact_export_limit']) $content['nm']['export_limit']=$this->config['contact_export_limit']; |
|
| 334 | + if (isset($this->config['contact_export_limit']) && (int)$this->config['contact_export_limit']) |
|
| 335 | + { |
|
| 336 | + $content['nm']['export_limit']=$this->config['contact_export_limit']; |
|
| 337 | + } |
|
| 316 | 338 | |
| 317 | 339 | // dont show tid-selection if we have only one content_type |
| 318 | 340 | // be a bit more sophisticated about it |
@@ -322,7 +344,10 @@ discard block |
||
| 322 | 344 | //_debug_array(array('Typefilter:'=> $content['nm']['col_filter']['tid'],'Available Types:'=>$availabletypes,'action:'=>'remove invalid filter')); |
| 323 | 345 | unset($content['nm']['col_filter']['tid']); |
| 324 | 346 | } |
| 325 | - if (!isset($content['nm']['col_filter']['tid'])) $content['nm']['col_filter']['tid'] = $availabletypes[0]; |
|
| 347 | + if (!isset($content['nm']['col_filter']['tid'])) |
|
| 348 | + { |
|
| 349 | + $content['nm']['col_filter']['tid'] = $availabletypes[0]; |
|
| 350 | + } |
|
| 326 | 351 | if (count($this->content_types) > 1) |
| 327 | 352 | { |
| 328 | 353 | foreach($this->content_types as $tid => $data) |
@@ -421,7 +446,10 @@ discard block |
||
| 421 | 446 | $crm_apps = array('infolog','tracker'); |
| 422 | 447 | foreach($crm_apps as $app) |
| 423 | 448 | { |
| 424 | - if ($GLOBALS['egw_info']['user']['apps'][$app]) $crm_count++; |
|
| 449 | + if ($GLOBALS['egw_info']['user']['apps'][$app]) |
|
| 450 | + { |
|
| 451 | + $crm_count++; |
|
| 452 | + } |
|
| 425 | 453 | } |
| 426 | 454 | if($crm_count > 1) |
| 427 | 455 | { |
@@ -477,7 +505,10 @@ discard block |
||
| 477 | 505 | ), |
| 478 | 506 | ), |
| 479 | 507 | ); |
| 480 | - if (!$GLOBALS['egw_info']['user']['apps']['preferences']) unset($actions['cats']['children']['cat_edit']); |
|
| 508 | + if (!$GLOBALS['egw_info']['user']['apps']['preferences']) |
|
| 509 | + { |
|
| 510 | + unset($actions['cats']['children']['cat_edit']); |
|
| 511 | + } |
|
| 481 | 512 | // Submenu for all distributionlist stuff |
| 482 | 513 | $actions['lists'] = array( |
| 483 | 514 | 'caption' => 'Distribution lists', |
@@ -490,7 +521,9 @@ discard block |
||
| 490 | 521 | ), |
| 491 | 522 | 'group' => $group, |
| 492 | 523 | ); |
| 493 | - if (($add_lists = $this->get_lists(Acl::EDIT))) // do we have distribution lists?, and are we allowed to edit them |
|
| 524 | + if (($add_lists = $this->get_lists(Acl::EDIT))) |
|
| 525 | + { |
|
| 526 | + // do we have distribution lists?, and are we allowed to edit them |
|
| 494 | 527 | { |
| 495 | 528 | $actions['lists']['children'] += array( |
| 496 | 529 | 'to_list' => array( |
@@ -526,6 +559,7 @@ discard block |
||
| 526 | 559 | 'fieldValue' => '!', // enable if list != '' |
| 527 | 560 | ), |
| 528 | 561 | ); |
| 562 | + } |
|
| 529 | 563 | if(is_subclass_of('etemplate', 'etemplate_new')) |
| 530 | 564 | { |
| 531 | 565 | $actions['lists']['children']['remove_from_list']['fieldId'] = 'filter2'; |
@@ -534,9 +568,13 @@ discard block |
||
| 534 | 568 | } |
| 535 | 569 | } |
| 536 | 570 | // move to AB |
| 537 | - if (($move2addressbooks = $this->get_addressbooks(Acl::ADD))) // do we have addressbooks, we should |
|
| 571 | + if (($move2addressbooks = $this->get_addressbooks(Acl::ADD))) |
|
| 572 | + { |
|
| 573 | + // do we have addressbooks, we should |
|
| 538 | 574 | { |
| 539 | - unset($move2addressbooks[0]); // do not offer action to move contact to an account, as we dont support that currrently |
|
| 575 | + unset($move2addressbooks[0]); |
|
| 576 | + } |
|
| 577 | + // do not offer action to move contact to an account, as we dont support that currrently |
|
| 540 | 578 | foreach($move2addressbooks as $owner => $label) |
| 541 | 579 | { |
| 542 | 580 | $icon = $type_label = null; |
@@ -667,7 +705,9 @@ discard block |
||
| 667 | 705 | |
| 668 | 706 | ); |
| 669 | 707 | if (!$this->prefs['preferredMail']) |
| 670 | - $actions['email']['children']['email_business']['checked'] = true; |
|
| 708 | + { |
|
| 709 | + $actions['email']['children']['email_business']['checked'] = true; |
|
| 710 | + } |
|
| 671 | 711 | |
| 672 | 712 | if ($GLOBALS['egw_info']['user']['apps']['filemanager']) |
| 673 | 713 | { |
@@ -811,11 +851,17 @@ discard block |
||
| 811 | 851 | private function _get_org_name($org) |
| 812 | 852 | { |
| 813 | 853 | $org_name = array(); |
| 814 | - if (strpos($org,'*AND*')!== false) $org = str_replace('*AND*','&',$org); |
|
| 854 | + if (strpos($org,'*AND*')!== false) |
|
| 855 | + { |
|
| 856 | + $org = str_replace('*AND*','&',$org); |
|
| 857 | + } |
|
| 815 | 858 | foreach(explode('|||',$org) as $part) |
| 816 | 859 | { |
| 817 | 860 | list(,$name) = explode(':',$part,2); |
| 818 | - if ($name) $org_name[] = $name; |
|
| 861 | + if ($name) |
|
| 862 | + { |
|
| 863 | + $org_name[] = $name; |
|
| 864 | + } |
|
| 819 | 865 | } |
| 820 | 866 | $name = implode(': ',$org_name); |
| 821 | 867 | return $name ? array($org => $name) : array(); |
@@ -877,9 +923,15 @@ discard block |
||
| 877 | 923 | $org_contacts = array(); |
| 878 | 924 | $query = !$_query ? Api\Cache::getSession('addressbook', 'index') : $_query; |
| 879 | 925 | $query['num_rows'] = -1; // all |
| 880 | - if(!is_array($query['col_filter'])) $query['col_filter'] = array(); |
|
| 926 | + if(!is_array($query['col_filter'])) |
|
| 927 | + { |
|
| 928 | + $query['col_filter'] = array(); |
|
| 929 | + } |
|
| 881 | 930 | |
| 882 | - if(!is_array($org)) $org = array($org); |
|
| 931 | + if(!is_array($org)) |
|
| 932 | + { |
|
| 933 | + $org = array($org); |
|
| 934 | + } |
|
| 883 | 935 | foreach($org as $org_name) |
| 884 | 936 | { |
| 885 | 937 | $query['org_view'] = $org_name; |
@@ -908,14 +960,23 @@ discard block |
||
| 908 | 960 | $checked = $readonlys = null; |
| 909 | 961 | $this->get_rows($query,$checked,$readonlys,true); // true = only return the id's |
| 910 | 962 | |
| 911 | - if (count($checked) > 1) // use a nicely formatted org-name as title in infolog |
|
| 963 | + if (count($checked) > 1) |
|
| 964 | + { |
|
| 965 | + // use a nicely formatted org-name as title in infolog |
|
| 912 | 966 | { |
| 913 | 967 | $parts = array(); |
| 914 | - if (strpos($org,'*AND*')!== false) $org = str_replace('*AND*','&',$org); |
|
| 968 | + } |
|
| 969 | + if (strpos($org,'*AND*')!== false) |
|
| 970 | + { |
|
| 971 | + $org = str_replace('*AND*','&',$org); |
|
| 972 | + } |
|
| 915 | 973 | foreach(explode('|||',$org) as $part) |
| 916 | 974 | { |
| 917 | 975 | list(,$part) = explode(':',$part,2); |
| 918 | - if ($part) $parts[] = $part; |
|
| 976 | + if ($part) |
|
| 977 | + { |
|
| 978 | + $parts[] = $part; |
|
| 979 | + } |
|
| 919 | 980 | } |
| 920 | 981 | $org = implode(', ',$parts); |
| 921 | 982 | } |
@@ -1059,10 +1120,16 @@ discard block |
||
| 1059 | 1120 | unset($query['filter2']); |
| 1060 | 1121 | $extra = $readonlys = null; |
| 1061 | 1122 | $this->get_rows($query,$extra,$readonlys,true); // true = only return the id's |
| 1062 | - if ($extra[0]) $org_contacts = array_merge($org_contacts,$extra); |
|
| 1123 | + if ($extra[0]) |
|
| 1124 | + { |
|
| 1125 | + $org_contacts = array_merge($org_contacts,$extra); |
|
| 1126 | + } |
|
| 1063 | 1127 | } |
| 1064 | 1128 | } |
| 1065 | - if ($org_contacts) $checked = array_unique($checked ? array_merge($checked,$org_contacts) : $org_contacts); |
|
| 1129 | + if ($org_contacts) |
|
| 1130 | + { |
|
| 1131 | + $checked = array_unique($checked ? array_merge($checked,$org_contacts) : $org_contacts); |
|
| 1132 | + } |
|
| 1066 | 1133 | //_debug_array($checked); exit; |
| 1067 | 1134 | |
| 1068 | 1135 | if (substr($action,0,8) == 'move_to_') |
@@ -1079,9 +1146,12 @@ discard block |
||
| 1079 | 1146 | $document = substr($action,9); |
| 1080 | 1147 | $action = 'document'; |
| 1081 | 1148 | } |
| 1082 | - elseif(substr($action,0,4) == 'cat_') // cat_add_123 or cat_del_456 |
|
| 1149 | + elseif(substr($action,0,4) == 'cat_') |
|
| 1150 | + { |
|
| 1151 | + // cat_add_123 or cat_del_456 |
|
| 1083 | 1152 | { |
| 1084 | 1153 | $cat_id = (int)substr($action, 8); |
| 1154 | + } |
|
| 1085 | 1155 | $action = substr($action,0,7); |
| 1086 | 1156 | } |
| 1087 | 1157 | // Security: stop non-admins to export more then the configured number of contacts |
@@ -1128,7 +1198,10 @@ discard block |
||
| 1128 | 1198 | return false; |
| 1129 | 1199 | |
| 1130 | 1200 | case 'document': |
| 1131 | - if (!$document) $document = $this->prefs['default_document']; |
|
| 1201 | + if (!$document) |
|
| 1202 | + { |
|
| 1203 | + $document = $this->prefs['default_document']; |
|
| 1204 | + } |
|
| 1132 | 1205 | $document_merge = new Api\Contacts\Merge(); |
| 1133 | 1206 | $msg = $document_merge->download($document, $checked, '', $this->prefs['document_dir']); |
| 1134 | 1207 | $failed = count($checked); |
@@ -1280,19 +1353,25 @@ discard block |
||
| 1280 | 1353 | break; |
| 1281 | 1354 | |
| 1282 | 1355 | default: // move to an other addressbook |
| 1283 | - if (!(int)$action || !($this->grants[(string) (int) $action] & Acl::EDIT)) // might be ADD in the future |
|
| 1356 | + if (!(int)$action || !($this->grants[(string) (int) $action] & Acl::EDIT)) |
|
| 1357 | + { |
|
| 1358 | + // might be ADD in the future |
|
| 1284 | 1359 | { |
| 1285 | 1360 | return false; |
| 1286 | 1361 | } |
| 1362 | + } |
|
| 1287 | 1363 | if (!$checkboxes['move_to_copy']) |
| 1288 | 1364 | { |
| 1289 | 1365 | $action_msg = lang('moved'); |
| 1290 | 1366 | if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE,$contact))) |
| 1291 | 1367 | { |
| 1292 | - if (!$contact['owner']) // no (mass-)move of Api\Accounts |
|
| 1368 | + if (!$contact['owner']) |
|
| 1369 | + { |
|
| 1370 | + // no (mass-)move of Api\Accounts |
|
| 1293 | 1371 | { |
| 1294 | 1372 | $Ok = false; |
| 1295 | 1373 | } |
| 1374 | + } |
|
| 1296 | 1375 | elseif ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action,-1) == 'p')) |
| 1297 | 1376 | { |
| 1298 | 1377 | $contact['owner'] = (int) $action; |
@@ -1381,9 +1460,12 @@ discard block |
||
| 1381 | 1460 | $do_email = $query['do_email']; |
| 1382 | 1461 | $what = $query['sitemgr_display'] ? $query['sitemgr_display'] : ($do_email ? 'email' : 'index'); |
| 1383 | 1462 | |
| 1384 | - if (!$id_only && !$query['csv_export']) // do NOT store state for csv_export or querying id's (no regular view) |
|
| 1463 | + if (!$id_only && !$query['csv_export']) |
|
| 1464 | + { |
|
| 1465 | + // do NOT store state for csv_export or querying id's (no regular view) |
|
| 1385 | 1466 | { |
| 1386 | 1467 | $store_query = $query; |
| 1468 | + } |
|
| 1387 | 1469 | // Do not store these |
| 1388 | 1470 | foreach(array('options-cat_id','actions','action_links','placeholder_actions') as $key) |
| 1389 | 1471 | { |
@@ -1396,14 +1478,25 @@ discard block |
||
| 1396 | 1478 | { |
| 1397 | 1479 | $old_state = Api\Cache::getSession('addressbook', $what); |
| 1398 | 1480 | } |
| 1399 | - if (!isset($this->org_views[(string) $query['org_view']]) || strpos($query['org_view'],':') === false) // we dont have an org view, unset the according col_filters |
|
| 1481 | + if (!isset($this->org_views[(string) $query['org_view']]) || strpos($query['org_view'],':') === false) |
|
| 1482 | + { |
|
| 1483 | + // we dont have an org view, unset the according col_filters |
|
| 1400 | 1484 | { |
| 1401 | 1485 | if (isset($query['col_filter']['org_name'])) unset($query['col_filter']['org_name']); |
| 1402 | - if (isset($query['col_filter']['adr_one_locality'])) unset($query['col_filter']['adr_one_locality']); |
|
| 1403 | - if (isset($query['col_filter']['org_unit'])) unset($query['col_filter']['org_unit']); |
|
| 1486 | + } |
|
| 1487 | + if (isset($query['col_filter']['adr_one_locality'])) |
|
| 1488 | + { |
|
| 1489 | + unset($query['col_filter']['adr_one_locality']); |
|
| 1490 | + } |
|
| 1491 | + if (isset($query['col_filter']['org_unit'])) |
|
| 1492 | + { |
|
| 1493 | + unset($query['col_filter']['org_unit']); |
|
| 1494 | + } |
|
| 1404 | 1495 | } |
| 1405 | 1496 | |
| 1406 | - if (isset($this->org_views[(string) $query['org_view']])) // we have an org view, reset the advanced search |
|
| 1497 | + if (isset($this->org_views[(string) $query['org_view']])) |
|
| 1498 | + { |
|
| 1499 | + // we have an org view, reset the advanced search |
|
| 1407 | 1500 | { |
| 1408 | 1501 | //_debug_array(array('Search'=>$query['search'], |
| 1409 | 1502 | // 'AdvancedSearch'=>$query['advanced_search'])); |
@@ -1411,10 +1504,14 @@ discard block |
||
| 1411 | 1504 | //unset($query['advanced_search']); |
| 1412 | 1505 | if(!$query['search'] && $old_state['advanced_search']) $query['advanced_search'] = $old_state['advanced_search']; |
| 1413 | 1506 | } |
| 1414 | - elseif(!$query['search'] && array_key_exists('advanced_search',$old_state)) // eg. paging in an advanced search |
|
| 1507 | + } |
|
| 1508 | + elseif(!$query['search'] && array_key_exists('advanced_search',$old_state)) |
|
| 1509 | + { |
|
| 1510 | + // eg. paging in an advanced search |
|
| 1415 | 1511 | { |
| 1416 | 1512 | $query['advanced_search'] = $old_state['advanced_search']; |
| 1417 | 1513 | } |
| 1514 | + } |
|
| 1418 | 1515 | /* this cant work anymore, as Framework::set_onload no longer exists |
| 1419 | 1516 | if ($do_email && etemplate::$loop) |
| 1420 | 1517 | { // remove previous addEmail() calls, otherwise they will be run again |
@@ -1424,11 +1521,13 @@ discard block |
||
| 1424 | 1521 | // Make sure old lettersearch filter doesn't stay - current letter filter will be added later |
| 1425 | 1522 | foreach($query['col_filter'] as $key => $col_filter) |
| 1426 | 1523 | { |
| 1427 | - if(!is_numeric($key)) continue; |
|
| 1524 | + if(!is_numeric($key)) |
|
| 1525 | + { |
|
| 1526 | + continue; |
|
| 1527 | + } |
|
| 1428 | 1528 | if(preg_match('/'.$GLOBALS['egw']->db->capabilities['case_insensitive_like']. |
| 1429 | 1529 | ' '.$GLOBALS['egw']->db->quote('[a-z]%').'$/',$col_filter) == 1 |
| 1430 | - ) |
|
| 1431 | - { |
|
| 1530 | + ) { |
|
| 1432 | 1531 | unset($query['col_filter'][$key]); |
| 1433 | 1532 | } |
| 1434 | 1533 | } |
@@ -1439,9 +1538,13 @@ discard block |
||
| 1439 | 1538 | // check if accounts are stored in ldap, which does NOT yet support the org-views |
| 1440 | 1539 | if ($this->so_accounts && $query['filter'] === '0' && $query['org_view']) |
| 1441 | 1540 | { |
| 1442 | - if ($old_state['filter'] === '0') // user changed to org_view |
|
| 1541 | + if ($old_state['filter'] === '0') |
|
| 1542 | + { |
|
| 1543 | + // user changed to org_view |
|
| 1443 | 1544 | { |
| 1444 | - $query['filter'] = ''; // --> change filter to all contacts |
|
| 1545 | + $query['filter'] = ''; |
|
| 1546 | + } |
|
| 1547 | + // --> change filter to all contacts |
|
| 1445 | 1548 | } |
| 1446 | 1549 | else // user changed to accounts |
| 1447 | 1550 | { |
@@ -1478,9 +1581,12 @@ discard block |
||
| 1478 | 1581 | { |
| 1479 | 1582 | unset($query['col_filter']['cat_id']); |
| 1480 | 1583 | } |
| 1481 | - if ($query['filter'] !== '') // not all addressbooks |
|
| 1584 | + if ($query['filter'] !== '') |
|
| 1585 | + { |
|
| 1586 | + // not all addressbooks |
|
| 1482 | 1587 | { |
| 1483 | 1588 | $query['col_filter']['owner'] = (string) (int) $query['filter']; |
| 1589 | + } |
|
| 1484 | 1590 | |
| 1485 | 1591 | if ($this->private_addressbook) |
| 1486 | 1592 | { |
@@ -1492,10 +1598,13 @@ discard block |
||
| 1492 | 1598 | unset($query['col_filter']['owner']); |
| 1493 | 1599 | unset($query['col_filter']['private']); |
| 1494 | 1600 | } |
| 1495 | - if ((int)$query['filter2']) // not no distribution list |
|
| 1601 | + if ((int)$query['filter2']) |
|
| 1602 | + { |
|
| 1603 | + // not no distribution list |
|
| 1496 | 1604 | { |
| 1497 | 1605 | $query['col_filter']['list'] = (string) (int) $query['filter2']; |
| 1498 | 1606 | } |
| 1607 | + } |
|
| 1499 | 1608 | else |
| 1500 | 1609 | { |
| 1501 | 1610 | unset($query['col_filter']['list']); |
@@ -1507,10 +1616,13 @@ discard block |
||
| 1507 | 1616 | // all backends allow now at least to use groups as distribution lists |
| 1508 | 1617 | $query['no_filter2'] = false; |
| 1509 | 1618 | |
| 1510 | - if (isset($this->org_views[(string) $query['org_view']]) && !$query['col_filter']['parent_id']) // we have an org view |
|
| 1619 | + if (isset($this->org_views[(string) $query['org_view']]) && !$query['col_filter']['parent_id']) |
|
| 1620 | + { |
|
| 1621 | + // we have an org view |
|
| 1511 | 1622 | { |
| 1512 | 1623 | // Query doesn't like empties |
| 1513 | 1624 | unset($query['col_filter']['parent_id']); |
| 1625 | + } |
|
| 1514 | 1626 | |
| 1515 | 1627 | if($query['actions'] && $query['actions']['open']) |
| 1516 | 1628 | { |
@@ -1563,9 +1675,12 @@ discard block |
||
| 1563 | 1675 | } |
| 1564 | 1676 | // Query doesn't like parent_id |
| 1565 | 1677 | unset($query['col_filter']['parent_id']); |
| 1566 | - if ($query['org_view']) // view the contacts of one organisation only |
|
| 1678 | + if ($query['org_view']) |
|
| 1679 | + { |
|
| 1680 | + // view the contacts of one organisation only |
|
| 1567 | 1681 | { |
| 1568 | 1682 | if (strpos($query['org_view'],'*AND*') !== false) $query['org_view'] = str_replace('*AND*','&',$query['org_view']); |
| 1683 | + } |
|
| 1569 | 1684 | foreach(explode('|||',$query['org_view']) as $part) |
| 1570 | 1685 | { |
| 1571 | 1686 | list($name,$value) = explode(':',$part,2); |
@@ -1584,14 +1699,18 @@ discard block |
||
| 1584 | 1699 | // translate the select order to the really used over all 3 columns |
| 1585 | 1700 | $sort = $query['sort']; |
| 1586 | 1701 | switch($query['order']) // "xxx<>'' DESC" sorts contacts with empty order-criteria always at the end |
| 1587 | - { // we don't exclude them, as the total would otherwise depend on the order-criteria |
|
| 1702 | + { |
|
| 1703 | +// we don't exclude them, as the total would otherwise depend on the order-criteria |
|
| 1588 | 1704 | case 'org_name': |
| 1589 | 1705 | $order = "egw_addressbook.org_name<>''DESC,egw_addressbook.org_name $sort,n_family $sort,n_given $sort"; |
| 1590 | 1706 | break; |
| 1591 | 1707 | default: |
| 1592 | - if ($query['order'][0] == '#') // we order by a custom field |
|
| 1708 | + if ($query['order'][0] == '#') |
|
| 1709 | + { |
|
| 1710 | + // we order by a custom field |
|
| 1593 | 1711 | { |
| 1594 | 1712 | $order = "{$query['order']} $sort,org_name $sort,n_family $sort,n_given $sort"; |
| 1713 | + } |
|
| 1595 | 1714 | break; |
| 1596 | 1715 | } |
| 1597 | 1716 | $query['order'] = 'n_family'; |
@@ -1615,9 +1734,12 @@ discard block |
||
| 1615 | 1734 | case 'contact_id': |
| 1616 | 1735 | $order = "egw_addressbook.$query[order] $sort"; |
| 1617 | 1736 | } |
| 1618 | - if ($query['searchletter']) // only show contacts if the order-criteria starts with the given letter |
|
| 1737 | + if ($query['searchletter']) |
|
| 1738 | + { |
|
| 1739 | + // only show contacts if the order-criteria starts with the given letter |
|
| 1619 | 1740 | { |
| 1620 | 1741 | $no_letter_search = array('adr_one_postalcode', 'adr_two_postalcode', 'contact_id', 'contact_created','contact_modified'); |
| 1742 | + } |
|
| 1621 | 1743 | $query['col_filter'][] = (in_array($query['order'],$no_letter_search) ? 'org_name' : (substr($query['order'],0,1)=='#'?'':'egw_addressbook.').$query['order']).' '. |
| 1622 | 1744 | $GLOBALS['egw']->db->capabilities['case_insensitive_like'].' '.$GLOBALS['egw']->db->quote(strtolower($query['searchletter']).'%'); |
| 1623 | 1745 | } |
@@ -1657,11 +1779,17 @@ discard block |
||
| 1657 | 1779 | { |
| 1658 | 1780 | foreach($columselection as $col) |
| 1659 | 1781 | { |
| 1660 | - if ($col[0] == '#') $selected_cfs[] = substr($col,1); |
|
| 1782 | + if ($col[0] == '#') |
|
| 1783 | + { |
|
| 1784 | + $selected_cfs[] = substr($col,1); |
|
| 1785 | + } |
|
| 1661 | 1786 | } |
| 1662 | 1787 | $customfields = $this->read_customfields($ids,$selected_cfs); |
| 1663 | 1788 | } |
| 1664 | - if ($show_calendar && !empty($ids)) $calendar = $this->read_calendar($calendar_participants); |
|
| 1789 | + if ($show_calendar && !empty($ids)) |
|
| 1790 | + { |
|
| 1791 | + $calendar = $this->read_calendar($calendar_participants); |
|
| 1792 | + } |
|
| 1665 | 1793 | // distributionlist memership for the entrys |
| 1666 | 1794 | //_debug_array($this->get_lists(Acl::EDIT)); |
| 1667 | 1795 | if ($show_distributionlist && $available_distib_lists) |
@@ -1671,7 +1799,10 @@ discard block |
||
| 1671 | 1799 | } |
| 1672 | 1800 | } |
| 1673 | 1801 | } |
| 1674 | - if (!$rows) $rows = array(); |
|
| 1802 | + if (!$rows) |
|
| 1803 | + { |
|
| 1804 | + $rows = array(); |
|
| 1805 | + } |
|
| 1675 | 1806 | |
| 1676 | 1807 | if ($id_only) |
| 1677 | 1808 | { |
@@ -1704,7 +1835,10 @@ discard block |
||
| 1704 | 1835 | $row['line2'] = $row['org_name']; |
| 1705 | 1836 | break; |
| 1706 | 1837 | case 'n_fileas': |
| 1707 | - if (!$row['n_fileas']) $row['n_fileas'] = $this->fileas($row); |
|
| 1838 | + if (!$row['n_fileas']) |
|
| 1839 | + { |
|
| 1840 | + $row['n_fileas'] = $this->fileas($row); |
|
| 1841 | + } |
|
| 1708 | 1842 | list($row['line1'],$row['line2']) = explode(': ',$row['n_fileas']); |
| 1709 | 1843 | break; |
| 1710 | 1844 | } |
@@ -1778,8 +1912,14 @@ discard block |
||
| 1778 | 1912 | } |
| 1779 | 1913 | |
| 1780 | 1914 | // hide region for address format 'postcode_city' |
| 1781 | - if (($row['addr_format'] = $this->addr_format_by_country($row['adr_one_countryname']))=='postcode_city') unset($row['adr_one_region']); |
|
| 1782 | - if (($row['addr_format2'] = $this->addr_format_by_country($row['adr_two_countryname']))=='postcode_city') unset($row['adr_two_region']); |
|
| 1915 | + if (($row['addr_format'] = $this->addr_format_by_country($row['adr_one_countryname']))=='postcode_city') |
|
| 1916 | + { |
|
| 1917 | + unset($row['adr_one_region']); |
|
| 1918 | + } |
|
| 1919 | + if (($row['addr_format2'] = $this->addr_format_by_country($row['adr_two_countryname']))=='postcode_city') |
|
| 1920 | + { |
|
| 1921 | + unset($row['adr_two_region']); |
|
| 1922 | + } |
|
| 1783 | 1923 | |
| 1784 | 1924 | // respect category permissions |
| 1785 | 1925 | if(!empty($row['cat_id'])) |
@@ -1790,7 +1930,10 @@ discard block |
||
| 1790 | 1930 | $rows['no_distribution_list'] = (bool)$query['filter2']; |
| 1791 | 1931 | |
| 1792 | 1932 | // disable customfields column, if we have no customefield(s) |
| 1793 | - if (!$this->customfields) $rows['no_customfields'] = true; |
|
| 1933 | + if (!$this->customfields) |
|
| 1934 | + { |
|
| 1935 | + $rows['no_customfields'] = true; |
|
| 1936 | + } |
|
| 1794 | 1937 | |
| 1795 | 1938 | $rows['order'] = $order; |
| 1796 | 1939 | $rows['call_popup'] = $this->config['call_popup']; |
@@ -1829,10 +1972,13 @@ discard block |
||
| 1829 | 1972 | $order = $order == 'n_given' ? lang('first name') : ($order == 'n_family' ? lang('last name') : lang('Organisation')); |
| 1830 | 1973 | $header[] = lang("%1 starts with '%2'",$order,$query['searchletter']); |
| 1831 | 1974 | } |
| 1832 | - if ($query['search'] && !$query['advanced_search']) // do not add that, if we have advanced search active |
|
| 1975 | + if ($query['search'] && !$query['advanced_search']) |
|
| 1976 | + { |
|
| 1977 | + // do not add that, if we have advanced search active |
|
| 1833 | 1978 | { |
| 1834 | 1979 | $header[] = lang("Search for '%1'",$query['search']); |
| 1835 | 1980 | } |
| 1981 | + } |
|
| 1836 | 1982 | $GLOBALS['egw_info']['flags']['app_header'] = implode(': ', $header); |
| 1837 | 1983 | |
| 1838 | 1984 | return $this->total; |
@@ -1899,7 +2045,10 @@ discard block |
||
| 1899 | 2045 | $content['private'] = (int) ($content['owner'] && substr($content['owner'],-1) == 'p'); |
| 1900 | 2046 | $content['owner'] = (string) (int) $content['owner']; |
| 1901 | 2047 | $content['cat_id'] = $this->config['cat_tab'] === 'Tree' ? $content['cat_id_tree'] : $content['cat_id']; |
| 1902 | - if ($this->config['private_cf_tab']) $content = (array)$content['private_cfs'] + $content; |
|
| 2048 | + if ($this->config['private_cf_tab']) |
|
| 2049 | + { |
|
| 2050 | + $content = (array)$content['private_cfs'] + $content; |
|
| 2051 | + } |
|
| 1903 | 2052 | unset($content['private_cfs']); |
| 1904 | 2053 | |
| 1905 | 2054 | switch($button) |
@@ -2096,7 +2245,10 @@ discard block |
||
| 2096 | 2245 | { |
| 2097 | 2246 | // arguments containing a comma get quoted by etemplate/js/nextmatch_action.js |
| 2098 | 2247 | // leading to error in Api\Db::column_data_implode, if not unquoted |
| 2099 | - if ($org[0] == '"') $org = substr($org, 1, -1); |
|
| 2248 | + if ($org[0] == '"') |
|
| 2249 | + { |
|
| 2250 | + $org = substr($org, 1, -1); |
|
| 2251 | + } |
|
| 2100 | 2252 | $content = $this->read_org($org); |
| 2101 | 2253 | } |
| 2102 | 2254 | elseif ($state['org_view'] && !isset($this->org_views[$state['org_view']])) |
@@ -2116,7 +2268,10 @@ discard block |
||
| 2116 | 2268 | $content['adr_two_countryname'] = |
| 2117 | 2269 | $GLOBALS['egw']->country->get_full_name($GLOBALS['egw_info']['user']['preferences']['common']['country']); |
| 2118 | 2270 | } |
| 2119 | - if ($this->prefs['fileas_default']) $content['fileas_type'] = $this->prefs['fileas_default']; |
|
| 2271 | + if ($this->prefs['fileas_default']) |
|
| 2272 | + { |
|
| 2273 | + $content['fileas_type'] = $this->prefs['fileas_default']; |
|
| 2274 | + } |
|
| 2120 | 2275 | } |
| 2121 | 2276 | if (isset($_GET['owner']) && $_GET['owner'] !== '') |
| 2122 | 2277 | { |
@@ -2141,7 +2296,10 @@ discard block |
||
| 2141 | 2296 | $new_type = array_keys($this->content_types); |
| 2142 | 2297 | // fetch active type to preset the type, if param typeid is not passed |
| 2143 | 2298 | $active_tid = Api\Cache::getSession('addressbook','active_tid'); |
| 2144 | - if ($active_tid && strtoupper($active_tid) === 'D') unset($active_tid); |
|
| 2299 | + if ($active_tid && strtoupper($active_tid) === 'D') |
|
| 2300 | + { |
|
| 2301 | + unset($active_tid); |
|
| 2302 | + } |
|
| 2145 | 2303 | $content['tid'] = $_GET['typeid'] ? $_GET['typeid'] : ($active_tid?$active_tid:$new_type[0]); |
| 2146 | 2304 | foreach($this->get_contact_columns() as $field) |
| 2147 | 2305 | { |
@@ -2159,19 +2317,37 @@ discard block |
||
| 2159 | 2317 | if (strpos($singleAddress[0]->personal,',')===false) |
| 2160 | 2318 | { |
| 2161 | 2319 | list($P_n_given,$P_n_family,$P_org_name)=explode(' ',$singleAddress[0]->personal,3); |
| 2162 | - if (strlen(trim($P_n_given))>0) $content['n_given'] = trim($P_n_given); |
|
| 2163 | - if (strlen(trim($P_n_family))>0) $content['n_family'] = trim($P_n_family); |
|
| 2164 | - if (strlen(trim($P_org_name))>0) $content['org_name'] = trim($P_org_name); |
|
| 2320 | + if (strlen(trim($P_n_given))>0) |
|
| 2321 | + { |
|
| 2322 | + $content['n_given'] = trim($P_n_given); |
|
| 2323 | + } |
|
| 2324 | + if (strlen(trim($P_n_family))>0) |
|
| 2325 | + { |
|
| 2326 | + $content['n_family'] = trim($P_n_family); |
|
| 2327 | + } |
|
| 2328 | + if (strlen(trim($P_org_name))>0) |
|
| 2329 | + { |
|
| 2330 | + $content['org_name'] = trim($P_org_name); |
|
| 2331 | + } |
|
| 2165 | 2332 | } |
| 2166 | 2333 | else |
| 2167 | 2334 | { |
| 2168 | 2335 | list($P_n_family,$P_other)=explode(',',$singleAddress[0]->personal,2); |
| 2169 | - if (strlen(trim($P_n_family))>0) $content['n_family'] = trim($P_n_family); |
|
| 2336 | + if (strlen(trim($P_n_family))>0) |
|
| 2337 | + { |
|
| 2338 | + $content['n_family'] = trim($P_n_family); |
|
| 2339 | + } |
|
| 2170 | 2340 | if (strlen(trim($P_other))>0) |
| 2171 | 2341 | { |
| 2172 | 2342 | list($P_n_given,$P_org_name)=explode(',',$P_other,2); |
| 2173 | - if (strlen(trim($P_n_given))>0) $content['n_given'] = trim($P_n_given); |
|
| 2174 | - if (strlen(trim($P_org_name))>0) $content['org_name'] = trim($P_org_name); |
|
| 2343 | + if (strlen(trim($P_n_given))>0) |
|
| 2344 | + { |
|
| 2345 | + $content['n_given'] = trim($P_n_given); |
|
| 2346 | + } |
|
| 2347 | + if (strlen(trim($P_org_name))>0) |
|
| 2348 | + { |
|
| 2349 | + $content['org_name'] = trim($P_org_name); |
|
| 2350 | + } |
|
| 2175 | 2351 | } |
| 2176 | 2352 | } |
| 2177 | 2353 | } |
@@ -2199,7 +2375,10 @@ discard block |
||
| 2199 | 2375 | break; |
| 2200 | 2376 | } |
| 2201 | 2377 | } |
| 2202 | - if (empty($content['n_fn'])) $content['n_fn'] = $this->fullname($content); |
|
| 2378 | + if (empty($content['n_fn'])) |
|
| 2379 | + { |
|
| 2380 | + $content['n_fn'] = $this->fullname($content); |
|
| 2381 | + } |
|
| 2203 | 2382 | } |
| 2204 | 2383 | $content['creator'] = $this->user; |
| 2205 | 2384 | $content['created'] = $this->now_su; |
@@ -2207,17 +2386,27 @@ discard block |
||
| 2207 | 2386 | //_debug_array($content); |
| 2208 | 2387 | } |
| 2209 | 2388 | |
| 2210 | - if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']); // dont allow HTML! |
|
| 2389 | + if ($_GET['msg']) |
|
| 2390 | + { |
|
| 2391 | + $content['msg'] = strip_tags($_GET['msg']); |
|
| 2392 | + } |
|
| 2393 | + // dont allow HTML! |
|
| 2211 | 2394 | |
| 2212 | - if($content && $_GET['makecp']) // copy the contact |
|
| 2395 | + if($content && $_GET['makecp']) |
|
| 2396 | + { |
|
| 2397 | + // copy the contact |
|
| 2213 | 2398 | { |
| 2214 | 2399 | $this->copy_contact($content); |
| 2400 | + } |
|
| 2215 | 2401 | $content['msg'] = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('addressbook','entry'))); |
| 2216 | 2402 | $view = false; |
| 2217 | 2403 | } |
| 2218 | 2404 | else |
| 2219 | 2405 | { |
| 2220 | - if (is_numeric($contact_id)) $content['link_to']['to_id'] = $contact_id; |
|
| 2406 | + if (is_numeric($contact_id)) |
|
| 2407 | + { |
|
| 2408 | + $content['link_to']['to_id'] = $contact_id; |
|
| 2409 | + } |
|
| 2221 | 2410 | } |
| 2222 | 2411 | // automatic link new entries to entries specified in the url |
| 2223 | 2412 | if (!$contact_id && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id']) && !is_array($content['link_to']['to_id'])) |
@@ -2226,10 +2415,13 @@ discard block |
||
| 2226 | 2415 | foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
| 2227 | 2416 | { |
| 2228 | 2417 | $link_id = $link_ids[$n]; |
| 2229 | - if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) // gard against XSS |
|
| 2418 | + if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) |
|
| 2419 | + { |
|
| 2420 | + // gard against XSS |
|
| 2230 | 2421 | { |
| 2231 | 2422 | Link::link('addressbook',$content['link_to']['to_id'],$link_app,$link_id); |
| 2232 | 2423 | } |
| 2424 | + } |
|
| 2233 | 2425 | } |
| 2234 | 2426 | } |
| 2235 | 2427 | } |
@@ -2237,7 +2429,10 @@ discard block |
||
| 2237 | 2429 | { |
| 2238 | 2430 | // last and next calendar date |
| 2239 | 2431 | list(,$dates) = each($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']),false)); |
| 2240 | - if(is_array($dates)) $content += $dates; |
|
| 2432 | + if(is_array($dates)) |
|
| 2433 | + { |
|
| 2434 | + $content += $dates; |
|
| 2435 | + } |
|
| 2241 | 2436 | } |
| 2242 | 2437 | |
| 2243 | 2438 | // Registry has view_id as contact_id, so set it (custom fields uses it) |
@@ -2277,7 +2472,11 @@ discard block |
||
| 2277 | 2472 | $sel_options['fileas_type'] = $this->fileas_options($content); |
| 2278 | 2473 | $sel_options['adr_one_countrycode']['-custom-'] = lang('Custom'); |
| 2279 | 2474 | $sel_options['owner'] = $this->get_addressbooks(Acl::ADD); |
| 2280 | - if ($content['owner']) unset($sel_options['owner'][0]); // do not offer to switch to accounts, as we do not support moving contacts to accounts |
|
| 2475 | + if ($content['owner']) |
|
| 2476 | + { |
|
| 2477 | + unset($sel_options['owner'][0]); |
|
| 2478 | + } |
|
| 2479 | + // do not offer to switch to accounts, as we do not support moving contacts to accounts |
|
| 2281 | 2480 | if ((string) $content['owner'] !== '') |
| 2282 | 2481 | { |
| 2283 | 2482 | if (!isset($sel_options['owner'][(int)$content['owner']])) |
@@ -2312,7 +2511,10 @@ discard block |
||
| 2312 | 2511 | )); |
| 2313 | 2512 | } |
| 2314 | 2513 | } |
| 2315 | - if (isset($readonlys['n_fileas'])) $readonlys['fileas_type'] = $readonlys['n_fileas']; |
|
| 2514 | + if (isset($readonlys['n_fileas'])) |
|
| 2515 | + { |
|
| 2516 | + $readonlys['fileas_type'] = $readonlys['n_fileas']; |
|
| 2517 | + } |
|
| 2316 | 2518 | // disable not needed tabs |
| 2317 | 2519 | $readonlys['tabs']['cats'] = !($content['cat_tab'] = $this->config['cat_tab']); |
| 2318 | 2520 | $readonlys['tabs']['custom'] = !$this->customfields || $this->get_backend($content['id'],$content['owner']) == $this->so_accounts; |
@@ -2320,8 +2522,14 @@ discard block |
||
| 2320 | 2522 | $readonlys['tabs']['distribution_list'] = !$content['distrib_lists'];#false; |
| 2321 | 2523 | $readonlys['tabs']['history'] = $this->contact_repository != 'sql' || !$content['id'] || |
| 2322 | 2524 | $this->account_repository != 'sql' && $content['account_id']; |
| 2323 | - if (!$content['id']) $readonlys['button[delete]'] = !$content['id']; |
|
| 2324 | - if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0; |
|
| 2525 | + if (!$content['id']) |
|
| 2526 | + { |
|
| 2527 | + $readonlys['button[delete]'] = !$content['id']; |
|
| 2528 | + } |
|
| 2529 | + if ($this->config['private_cf_tab']) |
|
| 2530 | + { |
|
| 2531 | + $content['no_private_cfs'] = 0; |
|
| 2532 | + } |
|
| 2325 | 2533 | $readonlys['change_org'] = empty($content['org_name']) || $view; |
| 2326 | 2534 | |
| 2327 | 2535 | // for editing the own account (by a non-admin), enable only the fields allowed via the "own_account_acl" |
@@ -2369,7 +2577,10 @@ discard block |
||
| 2369 | 2577 | |
| 2370 | 2578 | $content['photo'] = $this->photo_src($content['id'],$content['jpegphoto'],'photo',$content['etag']); |
| 2371 | 2579 | |
| 2372 | - if ($content['private']) $content['owner'] .= 'p'; |
|
| 2580 | + if ($content['private']) |
|
| 2581 | + { |
|
| 2582 | + $content['owner'] .= 'p'; |
|
| 2583 | + } |
|
| 2373 | 2584 | |
| 2374 | 2585 | // for custom types, check if we have a custom edit template named "addressbook.edit.$type", $type is the name |
| 2375 | 2586 | if (in_array($content['tid'], array('n',self::DELETED_TYPE)) || !$this->tmpl->read('addressbook.edit.'.$this->content_types[$content['tid']]['name'])) |
@@ -2391,7 +2602,10 @@ discard block |
||
| 2391 | 2602 | //error_log(__METHOD__."() hook_data=".array2string($hook_data)); |
| 2392 | 2603 | foreach($hook_data as $extra_tabs) |
| 2393 | 2604 | { |
| 2394 | - if (!$extra_tabs) continue; |
|
| 2605 | + if (!$extra_tabs) |
|
| 2606 | + { |
|
| 2607 | + continue; |
|
| 2608 | + } |
|
| 2395 | 2609 | |
| 2396 | 2610 | foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
| 2397 | 2611 | { |
@@ -2408,7 +2622,10 @@ discard block |
||
| 2408 | 2622 | $readonlys = array_merge($readonlys, $extra_tab['readonlys']); |
| 2409 | 2623 | } |
| 2410 | 2624 | // we must NOT add tabs and callbacks more then once! |
| 2411 | - if (!$first_call) continue; |
|
| 2625 | + if (!$first_call) |
|
| 2626 | + { |
|
| 2627 | + continue; |
|
| 2628 | + } |
|
| 2412 | 2629 | |
| 2413 | 2630 | if (!empty($extra_tab['pre_save_callback'])) |
| 2414 | 2631 | { |
@@ -2492,20 +2709,27 @@ discard block |
||
| 2492 | 2709 | public function ajax_check_values($values, $name, $own_id=0) |
| 2493 | 2710 | { |
| 2494 | 2711 | $matches = null; |
| 2495 | - if (preg_match('/^exec\[([^\]]+)\]$/', $name, $matches)) $name = $matches[1]; // remove exec[ ] |
|
| 2712 | + if (preg_match('/^exec\[([^\]]+)\]$/', $name, $matches)) |
|
| 2713 | + { |
|
| 2714 | + $name = $matches[1]; |
|
| 2715 | + } |
|
| 2716 | + // remove exec[ ] |
|
| 2496 | 2717 | |
| 2497 | 2718 | $ret = array('doublicates' => array(), 'msg' => null); |
| 2498 | 2719 | |
| 2499 | 2720 | // if email changed, check for doublicates |
| 2500 | 2721 | if (in_array($name, array('email', 'email_home'))) |
| 2501 | 2722 | { |
| 2502 | - if (preg_match(Etemplate\Widget\Url::EMAIL_PREG, $values[$name])) // only search for real email addresses, to not return to many contacts |
|
| 2723 | + if (preg_match(Etemplate\Widget\Url::EMAIL_PREG, $values[$name])) |
|
| 2724 | + { |
|
| 2725 | + // only search for real email addresses, to not return to many contacts |
|
| 2503 | 2726 | { |
| 2504 | 2727 | $contacts = parent::search(array( |
| 2505 | 2728 | 'email' => $values[$name], |
| 2506 | 2729 | 'email_home' => $values[$name], |
| 2507 | 2730 | ), false, '', '', '', false, 'OR'); |
| 2508 | 2731 | } |
| 2732 | + } |
|
| 2509 | 2733 | } |
| 2510 | 2734 | else |
| 2511 | 2735 | { |
@@ -2519,10 +2743,13 @@ discard block |
||
| 2519 | 2743 | !empty($values['n_given'])+!empty($values['n_family'])+!empty($values['org_name']) >= 2) |
| 2520 | 2744 | { |
| 2521 | 2745 | $filter = array(); |
| 2522 | - foreach(array('email', 'n_given', 'n_family', 'org_name') as $n) // use email too, to exclude obvious false positives |
|
| 2746 | + foreach(array('email', 'n_given', 'n_family', 'org_name') as $n) |
|
| 2747 | + { |
|
| 2748 | + // use email too, to exclude obvious false positives |
|
| 2523 | 2749 | { |
| 2524 | 2750 | if (!empty($values[$n])) $filter[$n] = $values[$n]; |
| 2525 | 2751 | } |
| 2752 | + } |
|
| 2526 | 2753 | $contacts = parent::search('', false, '', '', '', false, 'AND', false, $filter); |
| 2527 | 2754 | } |
| 2528 | 2755 | } |
@@ -2530,7 +2757,10 @@ discard block |
||
| 2530 | 2757 | { |
| 2531 | 2758 | foreach($contacts as $contact) |
| 2532 | 2759 | { |
| 2533 | - if ($own_id && $contact['id'] == $own_id) continue; |
|
| 2760 | + if ($own_id && $contact['id'] == $own_id) |
|
| 2761 | + { |
|
| 2762 | + continue; |
|
| 2763 | + } |
|
| 2534 | 2764 | |
| 2535 | 2765 | $ret['doublicates'][$contact['id']] = $this->fileas($contact).' ('. |
| 2536 | 2766 | (!$contact['owner'] ? lang('Accounts') : ($contact['owner'] == $this->user ? |
@@ -2557,7 +2787,10 @@ discard block |
||
| 2557 | 2787 | // CRM list comes from content, request, or preference |
| 2558 | 2788 | $crm_list = $content['crm_list'] ? $content['crm_list'] : |
| 2559 | 2789 | ($_GET['crm_list'] ? $_GET['crm_list'] : $GLOBALS['egw_info']['user']['preferences']['addressbook']['crm_list']); |
| 2560 | - if(!$crm_list || $crm_list == '~edit~') $crm_list = 'infolog'; |
|
| 2790 | + if(!$crm_list || $crm_list == '~edit~') |
|
| 2791 | + { |
|
| 2792 | + $crm_list = 'infolog'; |
|
| 2793 | + } |
|
| 2561 | 2794 | |
| 2562 | 2795 | if(is_array($content)) |
| 2563 | 2796 | { |
@@ -2580,7 +2813,10 @@ discard block |
||
| 2580 | 2813 | $inc = 1; |
| 2581 | 2814 | // fall through |
| 2582 | 2815 | case 'back': |
| 2583 | - if (!isset($inc)) $inc = -1; |
|
| 2816 | + if (!isset($inc)) |
|
| 2817 | + { |
|
| 2818 | + $inc = -1; |
|
| 2819 | + } |
|
| 2584 | 2820 | // get next/previous contact in selection |
| 2585 | 2821 | $query = Api\Cache::getSession('addressbook', 'index'); |
| 2586 | 2822 | $query['start'] = $content['index'] + $inc; |
@@ -2743,11 +2979,20 @@ discard block |
||
| 2743 | 2979 | $readonlys['tabs']['distribution_list'] = !$content['distrib_lists'];#false; |
| 2744 | 2980 | $readonlys['tabs']['history'] = $this->contact_repository != 'sql' || !$content['id'] || |
| 2745 | 2981 | $this->account_repository != 'sql' && $content['account_id']; |
| 2746 | - if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0; |
|
| 2982 | + if ($this->config['private_cf_tab']) |
|
| 2983 | + { |
|
| 2984 | + $content['no_private_cfs'] = 0; |
|
| 2985 | + } |
|
| 2747 | 2986 | |
| 2748 | 2987 | // last and next calendar date |
| 2749 | - if (!empty($content['id'])) list(,$dates) = each($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']),false)); |
|
| 2750 | - if(is_array($dates)) $content += $dates; |
|
| 2988 | + if (!empty($content['id'])) |
|
| 2989 | + { |
|
| 2990 | + list(,$dates) = each($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']),false)); |
|
| 2991 | + } |
|
| 2992 | + if(is_array($dates)) |
|
| 2993 | + { |
|
| 2994 | + $content += $dates; |
|
| 2995 | + } |
|
| 2751 | 2996 | |
| 2752 | 2997 | // Disable importexport |
| 2753 | 2998 | $GLOBALS['egw_info']['flags']['disable_importexport']['export'] = true; |
@@ -2826,7 +3071,10 @@ discard block |
||
| 2826 | 3071 | */ |
| 2827 | 3072 | function email2link($email) |
| 2828 | 3073 | { |
| 2829 | - if (strpos($email,'@') == false) return ''; |
|
| 3074 | + if (strpos($email,'@') == false) |
|
| 3075 | + { |
|
| 3076 | + return ''; |
|
| 3077 | + } |
|
| 2830 | 3078 | |
| 2831 | 3079 | if($GLOBALS['egw_info']['user']['apps']['mail']) |
| 2832 | 3080 | { |
@@ -2878,7 +3126,10 @@ discard block |
||
| 2878 | 3126 | $query['advanced_search'] = array_intersect_key($_content,array_flip(array_merge($this->get_contact_columns(),array('operator','meth_select')))); |
| 2879 | 3127 | foreach ($query['advanced_search'] as $key => $value) |
| 2880 | 3128 | { |
| 2881 | - if(!$value) unset($query['advanced_search'][$key]); |
|
| 3129 | + if(!$value) |
|
| 3130 | + { |
|
| 3131 | + unset($query['advanced_search'][$key]); |
|
| 3132 | + } |
|
| 2882 | 3133 | } |
| 2883 | 3134 | // Skip n_fn, it causes problems in sql |
| 2884 | 3135 | unset($query['advanced_search']['n_fn']); |
@@ -2935,8 +3186,14 @@ discard block |
||
| 2935 | 3186 | { |
| 2936 | 3187 | if (substr($data['type'], 0, 6) == 'select' && !($data['rows'] > 1)) |
| 2937 | 3188 | { |
| 2938 | - if (!isset($content['#'.$name])) $content['#'.$name] = ''; |
|
| 2939 | - if(!isset($data['values'][''])) $sel_options['#'.$name][''] = lang('Select one'); |
|
| 3189 | + if (!isset($content['#'.$name])) |
|
| 3190 | + { |
|
| 3191 | + $content['#'.$name] = ''; |
|
| 3192 | + } |
|
| 3193 | + if(!isset($data['values'][''])) |
|
| 3194 | + { |
|
| 3195 | + $sel_options['#'.$name][''] = lang('Select one'); |
|
| 3196 | + } |
|
| 2940 | 3197 | } |
| 2941 | 3198 | // Make them not required, otherwise you can't search |
| 2942 | 3199 | $this->tmpl->setElementAttribute('#'.$name, 'needed', FALSE); |
@@ -2960,7 +3217,10 @@ discard block |
||
| 2960 | 3217 | $content['no_tid'] = true; |
| 2961 | 3218 | $content['showsearchbuttons'] = true; // enable search operation and search buttons| they're disabled by default |
| 2962 | 3219 | |
| 2963 | - if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0; |
|
| 3220 | + if ($this->config['private_cf_tab']) |
|
| 3221 | + { |
|
| 3222 | + $content['no_private_cfs'] = 0; |
|
| 3223 | + } |
|
| 2964 | 3224 | |
| 2965 | 3225 | $this->tmpl->set_cell_attribute('change_org','disabled',true); |
| 2966 | 3226 | return $this->tmpl->exec('addressbook.addressbook_ui.search',$content,$sel_options,$readonlys,array(),2); |