@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | |
32 | 32 | // Used in conversions |
33 | 33 | static $types = array( |
34 | - 'select-account' => array('owner','creator','modifier'), |
|
35 | - 'date-time' => array('modified','created','last_event','next_event'), |
|
34 | + 'select-account' => array('owner', 'creator', 'modifier'), |
|
35 | + 'date-time' => array('modified', 'created', 'last_event', 'next_event'), |
|
36 | 36 | 'date' => array('bday'), |
37 | 37 | 'select-cat' => array('cat_id'), |
38 | 38 | 'select' => array('tid') |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @param string $_identifier |
47 | 47 | */ |
48 | - public function __construct( $_identifier='' ){ |
|
48 | + public function __construct($_identifier = '') { |
|
49 | 49 | $this->identifier = $_identifier; |
50 | 50 | $this->bocontacts = new Api\Contacts(); |
51 | - if($_identifier) { |
|
51 | + if ($_identifier) { |
|
52 | 52 | $this->contact = $this->bocontacts->read($this->identifier); |
53 | 53 | } |
54 | 54 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @todo add some checks |
100 | 100 | * @return void |
101 | 101 | */ |
102 | - public function set_record(array $_record){ |
|
102 | + public function set_record(array $_record) { |
|
103 | 103 | $this->contact = $_record; |
104 | 104 | } |
105 | 105 | |
@@ -126,14 +126,14 @@ discard block |
||
126 | 126 | $ui->type_icon($this->owner, $this->private, $this->tid, $icon, $label); |
127 | 127 | |
128 | 128 | // Specific photo |
129 | - return $this->jpegphoto ? Framework::link('/index.php',$ui->photo_src($this->identifier,$this->jpegphoto)):$icon; |
|
129 | + return $this->jpegphoto ? Framework::link('/index.php', $ui->photo_src($this->identifier, $this->jpegphoto)) : $icon; |
|
130 | 130 | } |
131 | 131 | /** |
132 | 132 | * saves record into backend |
133 | 133 | * |
134 | 134 | * @return string identifier |
135 | 135 | */ |
136 | - public function save ( $_dst_identifier ) { |
|
136 | + public function save($_dst_identifier) { |
|
137 | 137 | // Not yet implemeted |
138 | 138 | $this->identifier = $_dst_identifier; |
139 | 139 | } |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | * @param string $_dst_identifier |
145 | 145 | * @return string dst_identifier |
146 | 146 | */ |
147 | - public function copy ( $_dst_identifier ) { |
|
148 | - unset($_dst_identifier); // not used, but required by function signature |
|
147 | + public function copy($_dst_identifier) { |
|
148 | + unset($_dst_identifier); // not used, but required by function signature |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -155,15 +155,15 @@ discard block |
||
155 | 155 | * @param string $_dst_identifier |
156 | 156 | * @return string dst_identifier |
157 | 157 | */ |
158 | - public function move ( $_dst_identifier ) { |
|
159 | - unset($_dst_identifier); // not used, but required by function signature |
|
158 | + public function move($_dst_identifier) { |
|
159 | + unset($_dst_identifier); // not used, but required by function signature |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
163 | 163 | * delets current record from backend |
164 | 164 | * |
165 | 165 | */ |
166 | - public function delete () { |
|
166 | + public function delete() { |
|
167 | 167 | |
168 | 168 | } |
169 | 169 |
@@ -45,10 +45,12 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @param string $_identifier |
47 | 47 | */ |
48 | - public function __construct( $_identifier='' ){ |
|
48 | + public function __construct( $_identifier='' ) |
|
49 | + { |
|
49 | 50 | $this->identifier = $_identifier; |
50 | 51 | $this->bocontacts = new Api\Contacts(); |
51 | - if($_identifier) { |
|
52 | + if($_identifier) |
|
53 | + { |
|
52 | 54 | $this->contact = $this->bocontacts->read($this->identifier); |
53 | 55 | } |
54 | 56 | } |
@@ -58,7 +60,8 @@ discard block |
||
58 | 60 | * |
59 | 61 | * @param string $_attribute_name |
60 | 62 | */ |
61 | - public function __get($_attribute_name) { |
|
63 | + public function __get($_attribute_name) |
|
64 | + { |
|
62 | 65 | return $this->contact[$_attribute_name]; |
63 | 66 | } |
64 | 67 | |
@@ -68,7 +71,8 @@ discard block |
||
68 | 71 | * @param string $_attribute_name |
69 | 72 | * @param data $data |
70 | 73 | */ |
71 | - public function __set($_attribute_name, $data) { |
|
74 | + public function __set($_attribute_name, $data) |
|
75 | + { |
|
72 | 76 | $this->contact[$_attribute_name] = $data; |
73 | 77 | } |
74 | 78 | |
@@ -80,7 +84,8 @@ discard block |
||
80 | 84 | * |
81 | 85 | * @return array complete record as associative array |
82 | 86 | */ |
83 | - public function get_record_array() { |
|
87 | + public function get_record_array() |
|
88 | + { |
|
84 | 89 | return $this->contact; |
85 | 90 | } |
86 | 91 | |
@@ -89,7 +94,8 @@ discard block |
||
89 | 94 | * |
90 | 95 | *@return string tiltle |
91 | 96 | */ |
92 | - public function get_title() { |
|
97 | + public function get_title() |
|
98 | + { |
|
93 | 99 | return $this->bocontacts->link_title(empty($this->contact) ? $this->identifier : $this->contact); |
94 | 100 | } |
95 | 101 | |
@@ -99,7 +105,8 @@ discard block |
||
99 | 105 | * @todo add some checks |
100 | 106 | * @return void |
101 | 107 | */ |
102 | - public function set_record(array $_record){ |
|
108 | + public function set_record(array $_record) |
|
109 | + { |
|
103 | 110 | $this->contact = $_record; |
104 | 111 | } |
105 | 112 | |
@@ -108,7 +115,8 @@ discard block |
||
108 | 115 | * |
109 | 116 | * @return string identifier of current record |
110 | 117 | */ |
111 | - public function get_identifier() { |
|
118 | + public function get_identifier() |
|
119 | + { |
|
112 | 120 | return $this->identifier ? $this->identifier : $this->id; |
113 | 121 | } |
114 | 122 | |
@@ -118,7 +126,8 @@ discard block |
||
118 | 126 | * |
119 | 127 | * @return string Full URL of an icon, or appname/icon_name |
120 | 128 | */ |
121 | - public function get_icon() { |
|
129 | + public function get_icon() |
|
130 | + { |
|
122 | 131 | $ui = new addressbook_ui(); |
123 | 132 | |
124 | 133 | // Type as default |
@@ -133,7 +142,8 @@ discard block |
||
133 | 142 | * |
134 | 143 | * @return string identifier |
135 | 144 | */ |
136 | - public function save ( $_dst_identifier ) { |
|
145 | + public function save ( $_dst_identifier ) |
|
146 | + { |
|
137 | 147 | // Not yet implemeted |
138 | 148 | $this->identifier = $_dst_identifier; |
139 | 149 | } |
@@ -144,7 +154,8 @@ discard block |
||
144 | 154 | * @param string $_dst_identifier |
145 | 155 | * @return string dst_identifier |
146 | 156 | */ |
147 | - public function copy ( $_dst_identifier ) { |
|
157 | + public function copy ( $_dst_identifier ) |
|
158 | + { |
|
148 | 159 | unset($_dst_identifier); // not used, but required by function signature |
149 | 160 | } |
150 | 161 | |
@@ -155,7 +166,8 @@ discard block |
||
155 | 166 | * @param string $_dst_identifier |
156 | 167 | * @return string dst_identifier |
157 | 168 | */ |
158 | - public function move ( $_dst_identifier ) { |
|
169 | + public function move ( $_dst_identifier ) |
|
170 | + { |
|
159 | 171 | unset($_dst_identifier); // not used, but required by function signature |
160 | 172 | } |
161 | 173 | |
@@ -163,7 +175,8 @@ discard block |
||
163 | 175 | * delets current record from backend |
164 | 176 | * |
165 | 177 | */ |
166 | - public function delete () { |
|
178 | + public function delete () |
|
179 | + { |
|
167 | 180 | |
168 | 181 | } |
169 | 182 | |
@@ -171,7 +184,8 @@ discard block |
||
171 | 184 | * destructor |
172 | 185 | * |
173 | 186 | */ |
174 | - public function __destruct() { |
|
187 | + public function __destruct() |
|
188 | + { |
|
175 | 189 | unset ($this->bocontacts); |
176 | 190 | } |
177 | 191 | } |
@@ -365,10 +365,10 @@ discard block |
||
365 | 365 | } |
366 | 366 | |
367 | 367 | /** |
368 | - * Convert some internal data to something with more meaning |
|
369 | - * |
|
370 | - * Dates, times, user IDs, category IDs |
|
371 | - */ |
|
368 | + * Convert some internal data to something with more meaning |
|
369 | + * |
|
370 | + * Dates, times, user IDs, category IDs |
|
371 | + */ |
|
372 | 372 | public static function convert(addressbook_egw_record &$record, $options) { |
373 | 373 | |
374 | 374 | if ($record->tel_prefer) { |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | * Adjust automatically generated filter fields |
437 | 437 | */ |
438 | 438 | public function get_filter_fields(Array &$filters) |
439 | - { |
|
439 | + { |
|
440 | 440 | unset($filters['last_event']); |
441 | 441 | unset($filters['next_event']); |
442 | 442 | foreach($filters as $field_name => &$settings) |
@@ -435,7 +435,7 @@ |
||
435 | 435 | /** |
436 | 436 | * Adjust automatically generated filter fields |
437 | 437 | */ |
438 | - public function get_filter_fields(Array &$filters) |
|
438 | + public function get_filter_fields(array &$filters) |
|
439 | 439 | { |
440 | 440 | unset($filters['last_event']); |
441 | 441 | unset($filters['next_event']); |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | * Constants used for exploding categories & multi-selectboxes into seperate fields |
24 | 24 | */ |
25 | 25 | const NO_EXPLODE = False; |
26 | - const MAIN_CATS = 'main_cats'; // Only the top-level categories get their own field |
|
27 | - const EACH_CAT = 'each_cat'; // Every category gets its own field |
|
28 | - const EXPLODE = 'explode'; // For [custom] multi-selects, each option gets its own field |
|
26 | + const MAIN_CATS = 'main_cats'; // Only the top-level categories get their own field |
|
27 | + const EACH_CAT = 'each_cat'; // Every category gets its own field |
|
28 | + const EXPLODE = 'explode'; // For [custom] multi-selects, each option gets its own field |
|
29 | 29 | |
30 | 30 | public function __construct() |
31 | 31 | { |
32 | - $this->ui= new addressbook_ui(); |
|
32 | + $this->ui = new addressbook_ui(); |
|
33 | 33 | $this->get_selects(); |
34 | 34 | } |
35 | 35 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @param egw_record $_definition |
40 | 40 | */ |
41 | - public function export( $_stream, importexport_definition $_definition) { |
|
41 | + public function export($_stream, importexport_definition $_definition) { |
|
42 | 42 | |
43 | 43 | $options = $_definition->plugin_options; |
44 | 44 | $this->export_object = $export_object = new importexport_export_csv($_stream, (array)$options); |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | |
48 | 48 | // Addressbook defines its own export imits |
49 | 49 | $limit_exception = Api\Storage\Merge::is_export_limit_excepted(); |
50 | - $export_limit = Api\Storage\Merge::getExportLimit($app='addressbook'); |
|
50 | + $export_limit = Api\Storage\Merge::getExportLimit($app = 'addressbook'); |
|
51 | 51 | if (!$limit_exception) $export_object->export_limit = $export_limit; // we may not need that after all |
52 | - if($export_limit == 'no' && !$limit_exception) { |
|
52 | + if ($export_limit == 'no' && !$limit_exception) { |
|
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
@@ -60,18 +60,18 @@ discard block |
||
60 | 60 | if ($options['selection'] == 'search') { |
61 | 61 | // uicontacts selection with checkbox 'use_all' |
62 | 62 | $query = Api\Cache::getSession('addressbook', 'index'); |
63 | - $query['num_rows'] = -1; // all |
|
64 | - $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
63 | + $query['num_rows'] = -1; // all |
|
64 | + $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
65 | 65 | $query['order'] = 'contact_id'; |
66 | - if(!array_key_exists('filter',$query)) $query['filter'] = $GLOBALS['egw_info']['user']['account_id']; |
|
66 | + if (!array_key_exists('filter', $query)) $query['filter'] = $GLOBALS['egw_info']['user']['account_id']; |
|
67 | 67 | $readonlys = null; |
68 | - $this->ui->get_rows($query,$selection,$readonlys, true); // only return the ids |
|
68 | + $this->ui->get_rows($query, $selection, $readonlys, true); // only return the ids |
|
69 | 69 | } |
70 | - elseif ( $options['selection'] == 'all' ) { |
|
70 | + elseif ($options['selection'] == 'all') { |
|
71 | 71 | if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1') { |
72 | 72 | $col_filter['account_id'] = null; |
73 | 73 | } |
74 | - $selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$col_filter); |
|
74 | + $selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '', '', false, 'AND', false, $col_filter); |
|
75 | 75 | //$uicontacts->get_rows($query,$selection,$readonlys,true); |
76 | 76 | } |
77 | 77 | elseif ($options['selection'] == 'filter') |
@@ -80,90 +80,90 @@ discard block |
||
80 | 80 | $query = array(); |
81 | 81 | |
82 | 82 | // Handle ranges |
83 | - foreach($filter as $field => $value) |
|
83 | + foreach ($filter as $field => $value) |
|
84 | 84 | { |
85 | - if($field == 'cat_id') |
|
85 | + if ($field == 'cat_id') |
|
86 | 86 | { |
87 | - $query['col_filter'][$field] = implode(',',$value); |
|
87 | + $query['col_filter'][$field] = implode(',', $value); |
|
88 | 88 | continue; |
89 | 89 | } |
90 | 90 | |
91 | 91 | // Birthdays in addressbook are formatted Y-m-d |
92 | - if($field == 'bday') |
|
92 | + if ($field == 'bday') |
|
93 | 93 | { |
94 | - if($value['from']) |
|
94 | + if ($value['from']) |
|
95 | 95 | { |
96 | - $query['col_filter'][] = "contact_bday >= " . $GLOBALS['egw']->db->quote(date('Y-m-d', (int)$value['from'])); |
|
96 | + $query['col_filter'][] = "contact_bday >= ".$GLOBALS['egw']->db->quote(date('Y-m-d', (int)$value['from'])); |
|
97 | 97 | } |
98 | - if($value['to']) |
|
98 | + if ($value['to']) |
|
99 | 99 | { |
100 | - $query['col_filter'][] = "contact_bday <= " . $GLOBALS['egw']->db->quote(date('Y-m-d', (int)$value['to'])); |
|
100 | + $query['col_filter'][] = "contact_bday <= ".$GLOBALS['egw']->db->quote(date('Y-m-d', (int)$value['to'])); |
|
101 | 101 | } |
102 | 102 | continue; |
103 | 103 | } |
104 | 104 | // Custom fields & listed exceptions are not filtered with contact_ prefix |
105 | - if(strpos($field, '#') !== 0 && !in_array($field, array('tid','owner'))) |
|
105 | + if (strpos($field, '#') !== 0 && !in_array($field, array('tid', 'owner'))) |
|
106 | 106 | { |
107 | 107 | $field = 'contact_'.$field; |
108 | 108 | } |
109 | 109 | $query['col_filter'][$field] = $value; |
110 | - if(!is_array($value) || (!$value['from'] && !$value['to'])) continue; |
|
110 | + if (!is_array($value) || (!$value['from'] && !$value['to'])) continue; |
|
111 | 111 | |
112 | 112 | // Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10) |
113 | - if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from']; |
|
114 | - if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to']; |
|
113 | + if ($value['from']) $query['col_filter'][] = "$field >= ".(int)$value['from']; |
|
114 | + if ($value['to']) $query['col_filter'][] = "$field <= ".(int)$value['to']; |
|
115 | 115 | unset($query['col_filter'][$field]); |
116 | 116 | } |
117 | - $selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$query['col_filter']); |
|
117 | + $selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '', '', false, 'AND', false, $query['col_filter']); |
|
118 | 118 | } |
119 | 119 | else |
120 | 120 | { |
121 | - $selection = explode(',',$options['selection']); |
|
121 | + $selection = explode(',', $options['selection']); |
|
122 | 122 | } |
123 | - if(!is_array($selection)) |
|
123 | + if (!is_array($selection)) |
|
124 | 124 | { |
125 | 125 | $selection = array(); |
126 | 126 | } |
127 | 127 | $GLOBALS['egw_info']['flags']['currentapp'] = $old_app; |
128 | 128 | |
129 | - if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) { |
|
129 | + if (Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) { |
|
130 | 130 | $selection = array_slice($selection, 0, $export_limit); |
131 | 131 | } |
132 | 132 | |
133 | - if($options['explode_multiselects']) { |
|
133 | + if ($options['explode_multiselects']) { |
|
134 | 134 | $customfields = Api\Storage\Customfields::get('addressbook'); |
135 | 135 | $additional_fields = array(); |
136 | 136 | $cat_obj = new Api\Categories('', 'addressbook'); |
137 | - foreach($options['explode_multiselects'] as $field => $explode) { |
|
138 | - switch($explode['explode']) { |
|
137 | + foreach ($options['explode_multiselects'] as $field => $explode) { |
|
138 | + switch ($explode['explode']) { |
|
139 | 139 | case self::MAIN_CATS: |
140 | - $cats = $cat_obj->return_array('mains', 0, false,'','ASC','',true); |
|
141 | - foreach($cats as $settings) { |
|
140 | + $cats = $cat_obj->return_array('mains', 0, false, '', 'ASC', '', true); |
|
141 | + foreach ($cats as $settings) { |
|
142 | 142 | $additional_fields[$field][$settings['id']] = array( |
143 | 143 | 'count' => 0, |
144 | 144 | 'label' => $settings['name'], |
145 | 145 | 'subs' => array(), |
146 | 146 | ); |
147 | 147 | $subs = $cat_obj->return_sorted_array(0, False, '', 'ASC', 'cat_name', True, $settings['id']); |
148 | - foreach($subs as $sub) { |
|
148 | + foreach ($subs as $sub) { |
|
149 | 149 | $name = $sub['name']; |
150 | 150 | $path = $sub; |
151 | - while($path['parent'] != $settings['id']) { |
|
151 | + while ($path['parent'] != $settings['id']) { |
|
152 | 152 | $path = $cat_obj->read($path['parent']); |
153 | - $name = $path['name'] . '/' . $name; |
|
153 | + $name = $path['name'].'/'.$name; |
|
154 | 154 | } |
155 | 155 | $additional_fields[$field][$settings['id']]['subs'][$sub['id']] = $name; |
156 | 156 | } |
157 | 157 | } |
158 | 158 | break; |
159 | 159 | case self::EACH_CAT: |
160 | - $cats = $cat_obj->return_array('all', 0, false,'','ASC','',true); |
|
161 | - foreach($cats as $settings) { |
|
160 | + $cats = $cat_obj->return_array('all', 0, false, '', 'ASC', '', true); |
|
161 | + foreach ($cats as $settings) { |
|
162 | 162 | $name = $settings['name']; |
163 | 163 | $path = $settings; |
164 | - while($path['level'] != 0) { |
|
164 | + while ($path['level'] != 0) { |
|
165 | 165 | $path = $cat_obj->read($path['parent']); |
166 | - $name = $path['name'] . '/' . $name; |
|
166 | + $name = $path['name'].'/'.$name; |
|
167 | 167 | } |
168 | 168 | $additional_fields[$field][$settings['id']] = array( |
169 | 169 | 'count' => 0, |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | case self::EXPLODE: |
175 | 175 | // Only works for custom fields |
176 | 176 | $index = substr($field, 1); |
177 | - foreach($customfields[$index]['values'] as $key => $value) { |
|
177 | + foreach ($customfields[$index]['values'] as $key => $value) { |
|
178 | 178 | $additional_fields[$field][$key] = array( |
179 | 179 | 'count' => 0, |
180 | - 'label' => $customfields[$index]['label'] . ': ' . $value, |
|
180 | + 'label' => $customfields[$index]['label'].': '.$value, |
|
181 | 181 | ); |
182 | 182 | } |
183 | 183 | break; |
@@ -186,29 +186,29 @@ discard block |
||
186 | 186 | |
187 | 187 | // Check records to see if additional fields are actually used |
188 | 188 | foreach ($selection as $_contact) { |
189 | - if(is_array($_contact) && array_key_exists('photo', $_contact)) { |
|
189 | + if (is_array($_contact) && array_key_exists('photo', $_contact)) { |
|
190 | 190 | unset($_contact['photo']); |
191 | 191 | } |
192 | - if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) { |
|
192 | + if (is_array($_contact) && count($_contact) == 1 && $_contact['id']) { |
|
193 | 193 | $_contact = $_contact['id']; |
194 | 194 | } |
195 | - if(is_array($_contact) && $_contact['id']) { |
|
195 | + if (is_array($_contact) && $_contact['id']) { |
|
196 | 196 | $contact = new addressbook_egw_record(); |
197 | 197 | $contact->set_record($_contact); |
198 | 198 | } else { |
199 | 199 | $contact = new addressbook_egw_record($_contact); |
200 | 200 | } |
201 | - foreach($additional_fields as $field => &$values) { |
|
202 | - if(!$contact->$field) continue; |
|
203 | - foreach($values as $value => &$settings) { |
|
204 | - if(!is_array($contact->$field)) { |
|
201 | + foreach ($additional_fields as $field => &$values) { |
|
202 | + if (!$contact->$field) continue; |
|
203 | + foreach ($values as $value => &$settings) { |
|
204 | + if (!is_array($contact->$field)) { |
|
205 | 205 | $contact->$field = explode(',', $contact->$field); |
206 | 206 | } |
207 | - if(is_array($contact->$field) && in_array($value, $contact->$field)) { |
|
207 | + if (is_array($contact->$field) && in_array($value, $contact->$field)) { |
|
208 | 208 | $settings['count']++; |
209 | - } elseif($contact->$field == $value) { |
|
209 | + } elseif ($contact->$field == $value) { |
|
210 | 210 | $settings['count']++; |
211 | - } elseif($options['explode_multiselects'][$field]['explode'] == self::MAIN_CATS && array_intersect($contact->$field, array_keys($settings['subs']))) { |
|
211 | + } elseif ($options['explode_multiselects'][$field]['explode'] == self::MAIN_CATS && array_intersect($contact->$field, array_keys($settings['subs']))) { |
|
212 | 212 | $settings['count']++; |
213 | 213 | } |
214 | 214 | } |
@@ -220,18 +220,18 @@ discard block |
||
220 | 220 | unset($settings); |
221 | 221 | |
222 | 222 | // Add additional columns |
223 | - foreach($additional_fields as $field => $additional_values) { |
|
223 | + foreach ($additional_fields as $field => $additional_values) { |
|
224 | 224 | // Remove original |
225 | 225 | unset($options['mapping'][$field]); |
226 | 226 | // Add exploded |
227 | 227 | $field_count = 0; |
228 | - foreach($additional_values as $value => $settings) { |
|
229 | - if($settings['count'] > 0) { |
|
228 | + foreach ($additional_values as $value => $settings) { |
|
229 | + if ($settings['count'] > 0) { |
|
230 | 230 | $field_count += $settings['count']; |
231 | 231 | $options['mapping'][$field.'-'.$value] = $settings['label']; |
232 | 232 | } |
233 | 233 | } |
234 | - if($field_count > 0) { |
|
234 | + if ($field_count > 0) { |
|
235 | 235 | // Set some options for converting |
236 | 236 | $options['explode_multiselects'][$field]['values'] = $additional_values; |
237 | 237 | } else { |
@@ -244,12 +244,12 @@ discard block |
||
244 | 244 | $export_object->set_mapping($options['mapping']); |
245 | 245 | |
246 | 246 | // Add in last/next event, if needed |
247 | - if($options['mapping']['last_date'] || $options['mapping']['next_date']) |
|
247 | + if ($options['mapping']['last_date'] || $options['mapping']['next_date']) |
|
248 | 248 | { |
249 | 249 | $contact_ids = array(); |
250 | - foreach($selection as $_contact) |
|
250 | + foreach ($selection as $_contact) |
|
251 | 251 | { |
252 | - if(is_array($_contact) && $_contact['id']) |
|
252 | + if (is_array($_contact) && $_contact['id']) |
|
253 | 253 | { |
254 | 254 | $contact_ids[] = $_contact['account_id'] ? $_contact['account_id'] : 'c'.$_contact['id']; |
255 | 255 | } |
@@ -264,20 +264,20 @@ discard block |
||
264 | 264 | // $options['selection'] is array of identifiers as this plugin doesn't |
265 | 265 | // support other selectors atm. |
266 | 266 | foreach ($selection as $_contact) { |
267 | - if(is_array($_contact) && array_key_exists('photo', $_contact)) { |
|
267 | + if (is_array($_contact) && array_key_exists('photo', $_contact)) { |
|
268 | 268 | unset($_contact['photo']); |
269 | 269 | } |
270 | - if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) { |
|
270 | + if (is_array($_contact) && count($_contact) == 1 && $_contact['id']) { |
|
271 | 271 | $_contact = $_contact['id']; |
272 | 272 | } |
273 | - if(is_array($_contact) && $_contact['id']) { |
|
273 | + if (is_array($_contact) && $_contact['id']) { |
|
274 | 274 | $contact = new addressbook_egw_record(); |
275 | 275 | $contact->set_record($_contact); |
276 | 276 | } else { |
277 | 277 | $contact = new addressbook_egw_record($_contact); |
278 | 278 | } |
279 | 279 | |
280 | - if($events && $events[$contact->id]) |
|
280 | + if ($events && $events[$contact->id]) |
|
281 | 281 | { |
282 | 282 | // NB: last_date and next_date are used instead of last_event & next_event |
283 | 283 | // to avoid automatic conversion - we want to export link title, not date-time |
@@ -286,12 +286,12 @@ discard block |
||
286 | 286 | } |
287 | 287 | // Some conversion |
288 | 288 | $this->convert($contact, $options); |
289 | - if($options['convert']) { |
|
290 | - importexport_export_csv::convert($contact, addressbook_egw_record::$types, 'addressbook',$this->selects); |
|
289 | + if ($options['convert']) { |
|
290 | + importexport_export_csv::convert($contact, addressbook_egw_record::$types, 'addressbook', $this->selects); |
|
291 | 291 | } else { |
292 | 292 | // Implode arrays, so they don't say 'Array' |
293 | - foreach($contact->get_record_array() as $key => $value) { |
|
294 | - if(is_array($value)) $contact->$key = implode(',', $value); |
|
293 | + foreach ($contact->get_record_array() as $key => $value) { |
|
294 | + if (is_array($value)) $contact->$key = implode(',', $value); |
|
295 | 295 | } |
296 | 296 | } |
297 | 297 | |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | */ |
339 | 339 | public function get_filename() |
340 | 340 | { |
341 | - if(is_object($this->export_object) && $this->export_object->get_num_of_records() == 1) |
|
341 | + if (is_object($this->export_object) && $this->export_object->get_num_of_records() == 1) |
|
342 | 342 | { |
343 | 343 | return $this->export_object->record->get_title(); |
344 | 344 | } |
@@ -376,19 +376,19 @@ discard block |
||
376 | 376 | $record->tel_prefer = $record->$field; |
377 | 377 | } |
378 | 378 | |
379 | - if(!is_array($options['explode_multiselects'])) |
|
379 | + if (!is_array($options['explode_multiselects'])) |
|
380 | 380 | { |
381 | 381 | return; |
382 | 382 | } |
383 | - foreach((array)$options['explode_multiselects'] as $field => $explode_settings) { |
|
384 | - if(!is_array($record->$field)) $record->$field = explode(',', $record->$field); |
|
385 | - foreach((array)$explode_settings['values'] as $value => $settings) { |
|
383 | + foreach ((array)$options['explode_multiselects'] as $field => $explode_settings) { |
|
384 | + if (!is_array($record->$field)) $record->$field = explode(',', $record->$field); |
|
385 | + foreach ((array)$explode_settings['values'] as $value => $settings) { |
|
386 | 386 | $field_name = "$field-$value"; |
387 | 387 | $record->$field_name = array(); |
388 | - if(is_array($record->$field) && in_array($value, $record->$field) || $record->$field == $value) { |
|
389 | - if($explode_settings['explode'] != self::MAIN_CATS) { |
|
388 | + if (is_array($record->$field) && in_array($value, $record->$field) || $record->$field == $value) { |
|
389 | + if ($explode_settings['explode'] != self::MAIN_CATS) { |
|
390 | 390 | $record->$field_name = $options['convert'] ? lang('Yes') : true; |
391 | - } elseif($options['convert']) { |
|
391 | + } elseif ($options['convert']) { |
|
392 | 392 | // 3 part assign due to magic get method |
393 | 393 | $record_value = $record->$field_name; |
394 | 394 | $record_value[] = $settings['label']; |
@@ -397,16 +397,16 @@ discard block |
||
397 | 397 | $record->$field_name = $value; |
398 | 398 | } |
399 | 399 | } |
400 | - if($explode_settings['explode'] == self::MAIN_CATS && count(array_intersect($record->$field, array_keys($settings['subs'])))) { |
|
400 | + if ($explode_settings['explode'] == self::MAIN_CATS && count(array_intersect($record->$field, array_keys($settings['subs'])))) { |
|
401 | 401 | // 3 part assign due to magic get method |
402 | 402 | $record_value = $record->$field_name; |
403 | - if(!is_array($record_value)) $record_value = array($record_value); |
|
404 | - foreach(array_intersect($record->$field, array_keys($settings['subs'])) as $sub_id) { |
|
403 | + if (!is_array($record_value)) $record_value = array($record_value); |
|
404 | + foreach (array_intersect($record->$field, array_keys($settings['subs'])) as $sub_id) { |
|
405 | 405 | $record_value[] = $options['convert'] ? $settings['subs'][$sub_id] : $sub_id; |
406 | 406 | } |
407 | 407 | $record->$field_name = $record_value; |
408 | 408 | } |
409 | - if(is_array($record->$field_name)) $record->$field_name = implode(($options['convert'] ? ', ' : ','), $record->$field_name); |
|
409 | + if (is_array($record->$field_name)) $record->$field_name = implode(($options['convert'] ? ', ' : ','), $record->$field_name); |
|
410 | 410 | } |
411 | 411 | } |
412 | 412 | } |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | $this->selects = array( |
418 | 418 | 'tid' => array('n' => 'Contact') |
419 | 419 | ); |
420 | - foreach($this->ui->content_types as $tid => $data) |
|
420 | + foreach ($this->ui->content_types as $tid => $data) |
|
421 | 421 | { |
422 | 422 | $this->selects['tid'][$tid] = $data['name']; |
423 | 423 | } |
@@ -439,9 +439,9 @@ discard block |
||
439 | 439 | { |
440 | 440 | unset($filters['last_event']); |
441 | 441 | unset($filters['next_event']); |
442 | - foreach($filters as $field_name => &$settings) |
|
442 | + foreach ($filters as $field_name => &$settings) |
|
443 | 443 | { |
444 | - if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
444 | + if ($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
445 | 445 | } |
446 | 446 | $filters['owner'] = array( |
447 | 447 | 'name' => 'owner', |
@@ -38,7 +38,8 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @param egw_record $_definition |
40 | 40 | */ |
41 | - public function export( $_stream, importexport_definition $_definition) { |
|
41 | + public function export( $_stream, importexport_definition $_definition) |
|
42 | + { |
|
42 | 43 | |
43 | 44 | $options = $_definition->plugin_options; |
44 | 45 | $this->export_object = $export_object = new importexport_export_csv($_stream, (array)$options); |
@@ -48,8 +49,13 @@ discard block |
||
48 | 49 | // Addressbook defines its own export imits |
49 | 50 | $limit_exception = Api\Storage\Merge::is_export_limit_excepted(); |
50 | 51 | $export_limit = Api\Storage\Merge::getExportLimit($app='addressbook'); |
51 | - if (!$limit_exception) $export_object->export_limit = $export_limit; // we may not need that after all |
|
52 | - if($export_limit == 'no' && !$limit_exception) { |
|
52 | + if (!$limit_exception) |
|
53 | + { |
|
54 | + $export_object->export_limit = $export_limit; |
|
55 | + } |
|
56 | + // we may not need that after all |
|
57 | + if($export_limit == 'no' && !$limit_exception) |
|
58 | + { |
|
53 | 59 | return; |
54 | 60 | } |
55 | 61 | |
@@ -57,18 +63,24 @@ discard block |
||
57 | 63 | $old_app = $GLOBALS['egw_info']['flags']['currentapp']; |
58 | 64 | $GLOBALS['egw_info']['flags']['currentapp'] = 'addressbook'; |
59 | 65 | |
60 | - if ($options['selection'] == 'search') { |
|
66 | + if ($options['selection'] == 'search') |
|
67 | + { |
|
61 | 68 | // uicontacts selection with checkbox 'use_all' |
62 | 69 | $query = Api\Cache::getSession('addressbook', 'index'); |
63 | 70 | $query['num_rows'] = -1; // all |
64 | 71 | $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
65 | 72 | $query['order'] = 'contact_id'; |
66 | - if(!array_key_exists('filter',$query)) $query['filter'] = $GLOBALS['egw_info']['user']['account_id']; |
|
73 | + if(!array_key_exists('filter',$query)) |
|
74 | + { |
|
75 | + $query['filter'] = $GLOBALS['egw_info']['user']['account_id']; |
|
76 | + } |
|
67 | 77 | $readonlys = null; |
68 | 78 | $this->ui->get_rows($query,$selection,$readonlys, true); // only return the ids |
69 | 79 | } |
70 | - elseif ( $options['selection'] == 'all' ) { |
|
71 | - if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1') { |
|
80 | + elseif ( $options['selection'] == 'all' ) |
|
81 | + { |
|
82 | + if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1') |
|
83 | + { |
|
72 | 84 | $col_filter['account_id'] = null; |
73 | 85 | } |
74 | 86 | $selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$col_filter); |
@@ -107,11 +119,20 @@ discard block |
||
107 | 119 | $field = 'contact_'.$field; |
108 | 120 | } |
109 | 121 | $query['col_filter'][$field] = $value; |
110 | - if(!is_array($value) || (!$value['from'] && !$value['to'])) continue; |
|
122 | + if(!is_array($value) || (!$value['from'] && !$value['to'])) |
|
123 | + { |
|
124 | + continue; |
|
125 | + } |
|
111 | 126 | |
112 | 127 | // Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10) |
113 | - if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from']; |
|
114 | - if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to']; |
|
128 | + if($value['from']) |
|
129 | + { |
|
130 | + $query['col_filter'][] = "$field >= " . (int)$value['from']; |
|
131 | + } |
|
132 | + if($value['to']) |
|
133 | + { |
|
134 | + $query['col_filter'][] = "$field <= " . (int)$value['to']; |
|
135 | + } |
|
115 | 136 | unset($query['col_filter'][$field]); |
116 | 137 | } |
117 | 138 | $selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$query['col_filter']); |
@@ -126,29 +147,36 @@ discard block |
||
126 | 147 | } |
127 | 148 | $GLOBALS['egw_info']['flags']['currentapp'] = $old_app; |
128 | 149 | |
129 | - if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) { |
|
150 | + if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) |
|
151 | + { |
|
130 | 152 | $selection = array_slice($selection, 0, $export_limit); |
131 | 153 | } |
132 | 154 | |
133 | - if($options['explode_multiselects']) { |
|
155 | + if($options['explode_multiselects']) |
|
156 | + { |
|
134 | 157 | $customfields = Api\Storage\Customfields::get('addressbook'); |
135 | 158 | $additional_fields = array(); |
136 | 159 | $cat_obj = new Api\Categories('', 'addressbook'); |
137 | - foreach($options['explode_multiselects'] as $field => $explode) { |
|
138 | - switch($explode['explode']) { |
|
160 | + foreach($options['explode_multiselects'] as $field => $explode) |
|
161 | + { |
|
162 | + switch($explode['explode']) |
|
163 | + { |
|
139 | 164 | case self::MAIN_CATS: |
140 | 165 | $cats = $cat_obj->return_array('mains', 0, false,'','ASC','',true); |
141 | - foreach($cats as $settings) { |
|
166 | + foreach($cats as $settings) |
|
167 | + { |
|
142 | 168 | $additional_fields[$field][$settings['id']] = array( |
143 | 169 | 'count' => 0, |
144 | 170 | 'label' => $settings['name'], |
145 | 171 | 'subs' => array(), |
146 | 172 | ); |
147 | 173 | $subs = $cat_obj->return_sorted_array(0, False, '', 'ASC', 'cat_name', True, $settings['id']); |
148 | - foreach($subs as $sub) { |
|
174 | + foreach($subs as $sub) |
|
175 | + { |
|
149 | 176 | $name = $sub['name']; |
150 | 177 | $path = $sub; |
151 | - while($path['parent'] != $settings['id']) { |
|
178 | + while($path['parent'] != $settings['id']) |
|
179 | + { |
|
152 | 180 | $path = $cat_obj->read($path['parent']); |
153 | 181 | $name = $path['name'] . '/' . $name; |
154 | 182 | } |
@@ -158,10 +186,12 @@ discard block |
||
158 | 186 | break; |
159 | 187 | case self::EACH_CAT: |
160 | 188 | $cats = $cat_obj->return_array('all', 0, false,'','ASC','',true); |
161 | - foreach($cats as $settings) { |
|
189 | + foreach($cats as $settings) |
|
190 | + { |
|
162 | 191 | $name = $settings['name']; |
163 | 192 | $path = $settings; |
164 | - while($path['level'] != 0) { |
|
193 | + while($path['level'] != 0) |
|
194 | + { |
|
165 | 195 | $path = $cat_obj->read($path['parent']); |
166 | 196 | $name = $path['name'] . '/' . $name; |
167 | 197 | } |
@@ -174,7 +204,8 @@ discard block |
||
174 | 204 | case self::EXPLODE: |
175 | 205 | // Only works for custom fields |
176 | 206 | $index = substr($field, 1); |
177 | - foreach($customfields[$index]['values'] as $key => $value) { |
|
207 | + foreach($customfields[$index]['values'] as $key => $value) |
|
208 | + { |
|
178 | 209 | $additional_fields[$field][$key] = array( |
179 | 210 | 'count' => 0, |
180 | 211 | 'label' => $customfields[$index]['label'] . ': ' . $value, |
@@ -185,30 +216,47 @@ discard block |
||
185 | 216 | } |
186 | 217 | |
187 | 218 | // Check records to see if additional fields are actually used |
188 | - foreach ($selection as $_contact) { |
|
189 | - if(is_array($_contact) && array_key_exists('photo', $_contact)) { |
|
219 | + foreach ($selection as $_contact) |
|
220 | + { |
|
221 | + if(is_array($_contact) && array_key_exists('photo', $_contact)) |
|
222 | + { |
|
190 | 223 | unset($_contact['photo']); |
191 | 224 | } |
192 | - if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) { |
|
225 | + if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) |
|
226 | + { |
|
193 | 227 | $_contact = $_contact['id']; |
194 | 228 | } |
195 | - if(is_array($_contact) && $_contact['id']) { |
|
229 | + if(is_array($_contact) && $_contact['id']) |
|
230 | + { |
|
196 | 231 | $contact = new addressbook_egw_record(); |
197 | 232 | $contact->set_record($_contact); |
198 | - } else { |
|
233 | + } |
|
234 | + else |
|
235 | + { |
|
199 | 236 | $contact = new addressbook_egw_record($_contact); |
200 | 237 | } |
201 | - foreach($additional_fields as $field => &$values) { |
|
202 | - if(!$contact->$field) continue; |
|
203 | - foreach($values as $value => &$settings) { |
|
204 | - if(!is_array($contact->$field)) { |
|
238 | + foreach($additional_fields as $field => &$values) |
|
239 | + { |
|
240 | + if(!$contact->$field) |
|
241 | + { |
|
242 | + continue; |
|
243 | + } |
|
244 | + foreach($values as $value => &$settings) |
|
245 | + { |
|
246 | + if(!is_array($contact->$field)) |
|
247 | + { |
|
205 | 248 | $contact->$field = explode(',', $contact->$field); |
206 | 249 | } |
207 | - if(is_array($contact->$field) && in_array($value, $contact->$field)) { |
|
250 | + if(is_array($contact->$field) && in_array($value, $contact->$field)) |
|
251 | + { |
|
208 | 252 | $settings['count']++; |
209 | - } elseif($contact->$field == $value) { |
|
253 | + } |
|
254 | + elseif($contact->$field == $value) |
|
255 | + { |
|
210 | 256 | $settings['count']++; |
211 | - } elseif($options['explode_multiselects'][$field]['explode'] == self::MAIN_CATS && array_intersect($contact->$field, array_keys($settings['subs']))) { |
|
257 | + } |
|
258 | + elseif($options['explode_multiselects'][$field]['explode'] == self::MAIN_CATS && array_intersect($contact->$field, array_keys($settings['subs']))) |
|
259 | + { |
|
212 | 260 | $settings['count']++; |
213 | 261 | } |
214 | 262 | } |
@@ -220,21 +268,27 @@ discard block |
||
220 | 268 | unset($settings); |
221 | 269 | |
222 | 270 | // Add additional columns |
223 | - foreach($additional_fields as $field => $additional_values) { |
|
271 | + foreach($additional_fields as $field => $additional_values) |
|
272 | + { |
|
224 | 273 | // Remove original |
225 | 274 | unset($options['mapping'][$field]); |
226 | 275 | // Add exploded |
227 | 276 | $field_count = 0; |
228 | - foreach($additional_values as $value => $settings) { |
|
229 | - if($settings['count'] > 0) { |
|
277 | + foreach($additional_values as $value => $settings) |
|
278 | + { |
|
279 | + if($settings['count'] > 0) |
|
280 | + { |
|
230 | 281 | $field_count += $settings['count']; |
231 | 282 | $options['mapping'][$field.'-'.$value] = $settings['label']; |
232 | 283 | } |
233 | 284 | } |
234 | - if($field_count > 0) { |
|
285 | + if($field_count > 0) |
|
286 | + { |
|
235 | 287 | // Set some options for converting |
236 | 288 | $options['explode_multiselects'][$field]['values'] = $additional_values; |
237 | - } else { |
|
289 | + } |
|
290 | + else |
|
291 | + { |
|
238 | 292 | // Don't need this anymore |
239 | 293 | unset($options['explode_multiselects'][$field]); |
240 | 294 | } |
@@ -263,17 +317,23 @@ discard block |
||
263 | 317 | |
264 | 318 | // $options['selection'] is array of identifiers as this plugin doesn't |
265 | 319 | // support other selectors atm. |
266 | - foreach ($selection as $_contact) { |
|
267 | - if(is_array($_contact) && array_key_exists('photo', $_contact)) { |
|
320 | + foreach ($selection as $_contact) |
|
321 | + { |
|
322 | + if(is_array($_contact) && array_key_exists('photo', $_contact)) |
|
323 | + { |
|
268 | 324 | unset($_contact['photo']); |
269 | 325 | } |
270 | - if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) { |
|
326 | + if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) |
|
327 | + { |
|
271 | 328 | $_contact = $_contact['id']; |
272 | 329 | } |
273 | - if(is_array($_contact) && $_contact['id']) { |
|
330 | + if(is_array($_contact) && $_contact['id']) |
|
331 | + { |
|
274 | 332 | $contact = new addressbook_egw_record(); |
275 | 333 | $contact->set_record($_contact); |
276 | - } else { |
|
334 | + } |
|
335 | + else |
|
336 | + { |
|
277 | 337 | $contact = new addressbook_egw_record($_contact); |
278 | 338 | } |
279 | 339 | |
@@ -286,12 +346,19 @@ discard block |
||
286 | 346 | } |
287 | 347 | // Some conversion |
288 | 348 | $this->convert($contact, $options); |
289 | - if($options['convert']) { |
|
349 | + if($options['convert']) |
|
350 | + { |
|
290 | 351 | importexport_export_csv::convert($contact, addressbook_egw_record::$types, 'addressbook',$this->selects); |
291 | - } else { |
|
352 | + } |
|
353 | + else |
|
354 | + { |
|
292 | 355 | // Implode arrays, so they don't say 'Array' |
293 | - foreach($contact->get_record_array() as $key => $value) { |
|
294 | - if(is_array($value)) $contact->$key = implode(',', $value); |
|
356 | + foreach($contact->get_record_array() as $key => $value) |
|
357 | + { |
|
358 | + if(is_array($value)) |
|
359 | + { |
|
360 | + $contact->$key = implode(',', $value); |
|
361 | + } |
|
295 | 362 | } |
296 | 363 | } |
297 | 364 | |
@@ -306,7 +373,8 @@ discard block |
||
306 | 373 | * |
307 | 374 | * @return string name |
308 | 375 | */ |
309 | - public static function get_name() { |
|
376 | + public static function get_name() |
|
377 | + { |
|
310 | 378 | return lang('Addressbook CSV export'); |
311 | 379 | } |
312 | 380 | |
@@ -315,7 +383,8 @@ discard block |
||
315 | 383 | * |
316 | 384 | * @return string descriprion |
317 | 385 | */ |
318 | - public static function get_description() { |
|
386 | + public static function get_description() |
|
387 | + { |
|
319 | 388 | return lang("Exports contacts from your Addressbook into a CSV File."); |
320 | 389 | } |
321 | 390 | |
@@ -324,11 +393,13 @@ discard block |
||
324 | 393 | * |
325 | 394 | * @return string suffix |
326 | 395 | */ |
327 | - public static function get_filesuffix() { |
|
396 | + public static function get_filesuffix() |
|
397 | + { |
|
328 | 398 | return 'csv'; |
329 | 399 | } |
330 | 400 | |
331 | - public static function get_mimetype() { |
|
401 | + public static function get_mimetype() |
|
402 | + { |
|
332 | 403 | return 'text/csv'; |
333 | 404 | } |
334 | 405 | |
@@ -368,7 +439,8 @@ discard block |
||
368 | 439 | * returns slectors of this plugin via xajax |
369 | 440 | * |
370 | 441 | */ |
371 | - public function get_selectors_etpl() { |
|
442 | + public function get_selectors_etpl() |
|
443 | + { |
|
372 | 444 | return array( |
373 | 445 | 'name' => 'importexport.export_csv_selectors', |
374 | 446 | ); |
@@ -379,9 +451,11 @@ discard block |
||
379 | 451 | * |
380 | 452 | * Dates, times, user IDs, category IDs |
381 | 453 | */ |
382 | - public static function convert(addressbook_egw_record &$record, $options) { |
|
454 | + public static function convert(addressbook_egw_record &$record, $options) |
|
455 | + { |
|
383 | 456 | |
384 | - if ($record->tel_prefer) { |
|
457 | + if ($record->tel_prefer) |
|
458 | + { |
|
385 | 459 | $field = $record->tel_prefer; |
386 | 460 | $record->tel_prefer = $record->$field; |
387 | 461 | } |
@@ -390,33 +464,52 @@ discard block |
||
390 | 464 | { |
391 | 465 | return; |
392 | 466 | } |
393 | - foreach((array)$options['explode_multiselects'] as $field => $explode_settings) { |
|
394 | - if(!is_array($record->$field)) $record->$field = explode(',', $record->$field); |
|
395 | - foreach((array)$explode_settings['values'] as $value => $settings) { |
|
467 | + foreach((array)$options['explode_multiselects'] as $field => $explode_settings) |
|
468 | + { |
|
469 | + if(!is_array($record->$field)) |
|
470 | + { |
|
471 | + $record->$field = explode(',', $record->$field); |
|
472 | + } |
|
473 | + foreach((array)$explode_settings['values'] as $value => $settings) |
|
474 | + { |
|
396 | 475 | $field_name = "$field-$value"; |
397 | 476 | $record->$field_name = array(); |
398 | - if(is_array($record->$field) && in_array($value, $record->$field) || $record->$field == $value) { |
|
399 | - if($explode_settings['explode'] != self::MAIN_CATS) { |
|
477 | + if(is_array($record->$field) && in_array($value, $record->$field) || $record->$field == $value) |
|
478 | + { |
|
479 | + if($explode_settings['explode'] != self::MAIN_CATS) |
|
480 | + { |
|
400 | 481 | $record->$field_name = $options['convert'] ? lang('Yes') : true; |
401 | - } elseif($options['convert']) { |
|
482 | + } |
|
483 | + elseif($options['convert']) |
|
484 | + { |
|
402 | 485 | // 3 part assign due to magic get method |
403 | 486 | $record_value = $record->$field_name; |
404 | 487 | $record_value[] = $settings['label']; |
405 | 488 | $record->$field_name = $record_value; |
406 | - } else { |
|
489 | + } |
|
490 | + else |
|
491 | + { |
|
407 | 492 | $record->$field_name = $value; |
408 | 493 | } |
409 | 494 | } |
410 | - if($explode_settings['explode'] == self::MAIN_CATS && count(array_intersect($record->$field, array_keys($settings['subs'])))) { |
|
495 | + if($explode_settings['explode'] == self::MAIN_CATS && count(array_intersect($record->$field, array_keys($settings['subs'])))) |
|
496 | + { |
|
411 | 497 | // 3 part assign due to magic get method |
412 | 498 | $record_value = $record->$field_name; |
413 | - if(!is_array($record_value)) $record_value = array($record_value); |
|
414 | - foreach(array_intersect($record->$field, array_keys($settings['subs'])) as $sub_id) { |
|
499 | + if(!is_array($record_value)) |
|
500 | + { |
|
501 | + $record_value = array($record_value); |
|
502 | + } |
|
503 | + foreach(array_intersect($record->$field, array_keys($settings['subs'])) as $sub_id) |
|
504 | + { |
|
415 | 505 | $record_value[] = $options['convert'] ? $settings['subs'][$sub_id] : $sub_id; |
416 | 506 | } |
417 | 507 | $record->$field_name = $record_value; |
418 | 508 | } |
419 | - if(is_array($record->$field_name)) $record->$field_name = implode(($options['convert'] ? ', ' : ','), $record->$field_name); |
|
509 | + if(is_array($record->$field_name)) |
|
510 | + { |
|
511 | + $record->$field_name = implode(($options['convert'] ? ', ' : ','), $record->$field_name); |
|
512 | + } |
|
420 | 513 | } |
421 | 514 | } |
422 | 515 | } |
@@ -446,12 +539,15 @@ discard block |
||
446 | 539 | * Adjust automatically generated filter fields |
447 | 540 | */ |
448 | 541 | public function get_filter_fields(Array &$filters) |
449 | - { |
|
542 | + { |
|
450 | 543 | unset($filters['last_event']); |
451 | 544 | unset($filters['next_event']); |
452 | 545 | foreach($filters as $field_name => &$settings) |
453 | 546 | { |
454 | - if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
547 | + if($this->selects[$field_name]) |
|
548 | + { |
|
549 | + $settings['values'] = $this->selects[$field_name]; |
|
550 | + } |
|
455 | 551 | } |
456 | 552 | $filters['owner'] = array( |
457 | 553 | 'name' => 'owner', |
@@ -381,38 +381,38 @@ |
||
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
384 | - * Returns warnings that were encountered during importing |
|
385 | - * Maximum of one warning message per record, but you can append if you need to |
|
386 | - * |
|
387 | - * @return Array ( |
|
388 | - * record_# => warning message |
|
389 | - * ) |
|
390 | - */ |
|
391 | - public function get_warnings() { |
|
384 | + * Returns warnings that were encountered during importing |
|
385 | + * Maximum of one warning message per record, but you can append if you need to |
|
386 | + * |
|
387 | + * @return Array ( |
|
388 | + * record_# => warning message |
|
389 | + * ) |
|
390 | + */ |
|
391 | + public function get_warnings() { |
|
392 | 392 | return $this->warnings; |
393 | 393 | } |
394 | 394 | |
395 | 395 | /** |
396 | - * Returns errors that were encountered during importing |
|
397 | - * Maximum of one error message per record, but you can append if you need to |
|
398 | - * |
|
399 | - * @return Array ( |
|
400 | - * record_# => error message |
|
401 | - * ) |
|
402 | - */ |
|
403 | - public function get_errors() { |
|
396 | + * Returns errors that were encountered during importing |
|
397 | + * Maximum of one error message per record, but you can append if you need to |
|
398 | + * |
|
399 | + * @return Array ( |
|
400 | + * record_# => error message |
|
401 | + * ) |
|
402 | + */ |
|
403 | + public function get_errors() { |
|
404 | 404 | return $this->errors; |
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
408 | - * Returns a list of actions taken, and the number of records for that action. |
|
409 | - * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
410 | - * |
|
411 | - * @return Array ( |
|
412 | - * action => record count |
|
413 | - * ) |
|
414 | - */ |
|
415 | - public function get_results() { |
|
416 | - return $this->results; |
|
417 | - } |
|
408 | + * Returns a list of actions taken, and the number of records for that action. |
|
409 | + * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
410 | + * |
|
411 | + * @return Array ( |
|
412 | + * action => record count |
|
413 | + * ) |
|
414 | + */ |
|
415 | + public function get_results() { |
|
416 | + return $this->results; |
|
417 | + } |
|
418 | 418 | } |
@@ -15,14 +15,14 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * class import_csv for addressbook |
17 | 17 | */ |
18 | -class addressbook_import_contacts_csv extends importexport_basic_import_csv { |
|
18 | +class addressbook_import_contacts_csv extends importexport_basic_import_csv { |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * conditions for actions |
22 | 22 | * |
23 | 23 | * @var array |
24 | 24 | */ |
25 | - protected static $conditions = array( 'exists', 'equal' ); |
|
25 | + protected static $conditions = array('exists', 'equal'); |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * @var addressbook_bo |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | * @param string $_charset |
57 | 57 | * @param definition $_definition |
58 | 58 | */ |
59 | - public function import( $_stream, importexport_definition $_definition ) { |
|
59 | + public function import($_stream, importexport_definition $_definition) { |
|
60 | 60 | parent::import($_stream, $_definition); |
61 | 61 | |
62 | - if($_definition->plugin_options['empty_addressbook']) |
|
62 | + if ($_definition->plugin_options['empty_addressbook']) |
|
63 | 63 | { |
64 | 64 | $this->empty_addressbook($this->user, $this->ids); |
65 | 65 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @param string $_charset |
72 | 72 | * @param definition $_definition |
73 | 73 | */ |
74 | - public function init(importexport_definition &$_definition ) { |
|
74 | + public function init(importexport_definition &$_definition) { |
|
75 | 75 | |
76 | 76 | // fetch the addressbook bo |
77 | 77 | $this->bocontacts = new addressbook_bo(); |
@@ -82,13 +82,13 @@ discard block |
||
82 | 82 | $this->lookups = array( |
83 | 83 | 'tid' => array('n'=>'contact') |
84 | 84 | ); |
85 | - foreach($this->bocontacts->content_types as $tid => $data) |
|
85 | + foreach ($this->bocontacts->content_types as $tid => $data) |
|
86 | 86 | { |
87 | 87 | $this->lookups['tid'][$tid] = $data['name']; |
88 | 88 | } |
89 | 89 | |
90 | 90 | // Try and set a default type, for use if file does not specify |
91 | - if(!$this->lookups['tid'][Api\Contacts\Storage::DELETED_TYPE] && count($this->lookups['tid']) == 1 || |
|
91 | + if (!$this->lookups['tid'][Api\Contacts\Storage::DELETED_TYPE] && count($this->lookups['tid']) == 1 || |
|
92 | 92 | $this->lookups['tid'][Api\Contacts\Storage::DELETED_TYPE] && count($this->lookups['tid']) == 2) |
93 | 93 | { |
94 | 94 | reset($this->lookups['tid']); |
@@ -97,21 +97,21 @@ discard block |
||
97 | 97 | |
98 | 98 | |
99 | 99 | // set contact owner |
100 | - $contact_owner = isset( $_definition->plugin_options['contact_owner'] ) ? |
|
100 | + $contact_owner = isset($_definition->plugin_options['contact_owner']) ? |
|
101 | 101 | $_definition->plugin_options['contact_owner'] : $this->user; |
102 | 102 | |
103 | 103 | // Check to make sure target addressbook is valid |
104 | - if(!in_array($contact_owner, array_keys($this->bocontacts->get_addressbooks(Api\Acl::ADD)))) |
|
104 | + if (!in_array($contact_owner, array_keys($this->bocontacts->get_addressbooks(Api\Acl::ADD)))) |
|
105 | 105 | { |
106 | 106 | $this->warnings[0] = lang("Unable to import into %1, using %2", |
107 | - $contact_owner . ' ('.Api\Accounts::username($record->owner) . ')', |
|
107 | + $contact_owner.' ('.Api\Accounts::username($record->owner).')', |
|
108 | 108 | Api\Accounts::username($this->user) |
109 | 109 | ); |
110 | 110 | $contact_owner = 'personal'; |
111 | 111 | } |
112 | 112 | |
113 | 113 | // Import into importer's personal addressbook |
114 | - if($contact_owner == 'personal') |
|
114 | + if ($contact_owner == 'personal') |
|
115 | 115 | { |
116 | 116 | $contact_owner = $this->user; |
117 | 117 | } |
@@ -131,11 +131,11 @@ discard block |
||
131 | 131 | protected function import_record(importexport_iface_egw_record &$record, &$import_csv) |
132 | 132 | { |
133 | 133 | // Set owner, unless it's supposed to come from CSV file |
134 | - if($this->definition->plugin_options['owner_from_csv'] && $record->owner) { |
|
135 | - if(!is_numeric($record->owner)) { |
|
134 | + if ($this->definition->plugin_options['owner_from_csv'] && $record->owner) { |
|
135 | + if (!is_numeric($record->owner)) { |
|
136 | 136 | // Automatically handle text owner without explicit translation |
137 | 137 | $new_owner = importexport_helper_functions::account_name2id($record->owner); |
138 | - if($new_owner == '') { |
|
138 | + if ($new_owner == '') { |
|
139 | 139 | $this->errors[$import_csv->get_current_position()] = lang( |
140 | 140 | 'Unable to convert "%1" to account ID. Using plugin setting (%2) for owner.', |
141 | 141 | $record->owner, |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | } |
152 | 152 | |
153 | 153 | // Check that owner (addressbook) is allowed |
154 | - if(!array_key_exists($record->owner, $this->bocontacts->get_addressbooks())) |
|
154 | + if (!array_key_exists($record->owner, $this->bocontacts->get_addressbooks())) |
|
155 | 155 | { |
156 | 156 | $this->errors[$import_csv->get_current_position()] = lang("Unable to import into %1, using %2", |
157 | 157 | Api\Accounts::username($record->owner), |
@@ -162,18 +162,18 @@ discard block |
||
162 | 162 | |
163 | 163 | // Do not allow owner == 0 (accounts) without an account_id |
164 | 164 | // It causes the contact to be filed as an account, and can't delete |
165 | - if(!$record->owner && !$record->account_id) |
|
165 | + if (!$record->owner && !$record->account_id) |
|
166 | 166 | { |
167 | 167 | $record->owner = $GLOBALS['egw_info']['user']['account_id']; |
168 | 168 | } |
169 | 169 | |
170 | 170 | // Do not import into non-existing type, warn and change |
171 | - if(!$record->tid || !$this->lookups['tid'][$record->tid]) |
|
171 | + if (!$record->tid || !$this->lookups['tid'][$record->tid]) |
|
172 | 172 | { |
173 | 173 | // Avoid lots of warnings about type (2 types are contact and deleted) |
174 | - if($record->tid && !$this->type_warned[$record->tid] && !$this->lookups['tid'][$record->tid] ) |
|
174 | + if ($record->tid && !$this->type_warned[$record->tid] && !$this->lookups['tid'][$record->tid]) |
|
175 | 175 | { |
176 | - $this->warnings[$import_csv->get_current_position()] = lang('Unknown type %1, imported as %2',$record->tid,lang($this->lookups['tid']['n'])); |
|
176 | + $this->warnings[$import_csv->get_current_position()] = lang('Unknown type %1, imported as %2', $record->tid, lang($this->lookups['tid']['n'])); |
|
177 | 177 | $this->type_warned[$record->tid] = true; |
178 | 178 | } |
179 | 179 | $record->tid = $this->default_type; |
@@ -182,45 +182,45 @@ discard block |
||
182 | 182 | // Also handle categories in their own field |
183 | 183 | $record_array = $record->get_record_array(); |
184 | 184 | $more_categories = array(); |
185 | - foreach($this->definition->plugin_options['field_mapping'] as $field_name) { |
|
186 | - if(!array_key_exists($field_name, $record_array) || |
|
187 | - substr($field_name,0,3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') continue; |
|
185 | + foreach ($this->definition->plugin_options['field_mapping'] as $field_name) { |
|
186 | + if (!array_key_exists($field_name, $record_array) || |
|
187 | + substr($field_name, 0, 3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') continue; |
|
188 | 188 | list(, $cat_id) = explode('-', $field_name); |
189 | - if(is_numeric($record->$field_name) && $record->$field_name != 1) { |
|
189 | + if (is_numeric($record->$field_name) && $record->$field_name != 1) { |
|
190 | 190 | // Column has a single category ID |
191 | 191 | $more_categories[] = $record->$field_name; |
192 | - } elseif($record->$field_name == '1' || |
|
192 | + } elseif ($record->$field_name == '1' || |
|
193 | 193 | (!is_numeric($record->$field_name) && strtolower($record->$field_name) == strtolower(lang('Yes')))) { |
194 | 194 | // Each category got its own column. '1' is the database value, lang('yes') is the human value |
195 | 195 | $more_categories[] = $cat_id; |
196 | 196 | } else { |
197 | 197 | // Text categories |
198 | - $more_categories = array_merge($more_categories, importexport_helper_functions::cat_name2id(is_array($record->$field_name) ? $record->$field_name : explode(',',$record->$field_name), $cat_id)); |
|
198 | + $more_categories = array_merge($more_categories, importexport_helper_functions::cat_name2id(is_array($record->$field_name) ? $record->$field_name : explode(',', $record->$field_name), $cat_id)); |
|
199 | 199 | } |
200 | 200 | } |
201 | - if(count($more_categories) > 0) $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',',$record->cat_id), $more_categories); |
|
201 | + if (count($more_categories) > 0) $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',', $record->cat_id), $more_categories); |
|
202 | 202 | |
203 | 203 | // Private set but missing causes hidden entries |
204 | - if(array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) unset($record->private); |
|
204 | + if (array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) unset($record->private); |
|
205 | 205 | |
206 | 206 | // Format birthday as backend requires - converter should give timestamp |
207 | - if($record->bday && is_numeric($record->bday)) |
|
207 | + if ($record->bday && is_numeric($record->bday)) |
|
208 | 208 | { |
209 | 209 | $time = new Api\DateTime($record->bday); |
210 | 210 | $record->bday = $time->format('Y-m-d'); |
211 | 211 | } |
212 | 212 | |
213 | - if ( $this->definition->plugin_options['conditions'] ) { |
|
214 | - foreach ( $this->definition->plugin_options['conditions'] as $condition ) { |
|
213 | + if ($this->definition->plugin_options['conditions']) { |
|
214 | + foreach ($this->definition->plugin_options['conditions'] as $condition) { |
|
215 | 215 | $contacts = array(); |
216 | - switch ( $condition['type'] ) { |
|
216 | + switch ($condition['type']) { |
|
217 | 217 | // exists |
218 | 218 | case 'exists' : |
219 | - if($record_array[$condition['string']]) { |
|
220 | - $searchcondition = array( $condition['string'] => $record_array[$condition['string']]); |
|
219 | + if ($record_array[$condition['string']]) { |
|
220 | + $searchcondition = array($condition['string'] => $record_array[$condition['string']]); |
|
221 | 221 | // if we use account_id for the condition, we need to set the owner for filtering, as this |
222 | 222 | // enables Api\Contacts\Storage to decide what backend is to be used |
223 | - if ($condition['string']=='account_id') $searchcondition['owner']=0; |
|
223 | + if ($condition['string'] == 'account_id') $searchcondition['owner'] = 0; |
|
224 | 224 | $contacts = $this->bocontacts->search( |
225 | 225 | //array( $condition['string'] => $record[$condition['string']],), |
226 | 226 | '', |
@@ -229,37 +229,37 @@ discard block |
||
229 | 229 | $searchcondition |
230 | 230 | ); |
231 | 231 | } |
232 | - if ( is_array( $contacts ) && count( array_keys( $contacts ) ) >= 1 ) { |
|
232 | + if (is_array($contacts) && count(array_keys($contacts)) >= 1) { |
|
233 | 233 | // apply action to all contacts matching this exists condition |
234 | 234 | $action = $condition['true']; |
235 | - foreach ( (array)$contacts as $contact ) { |
|
235 | + foreach ((array)$contacts as $contact) { |
|
236 | 236 | $record->id = $contact['id']; |
237 | - if ( $this->definition->plugin_options['update_cats'] == 'add' ) { |
|
238 | - if ( !is_array( $contact['cat_id'] ) ) $contact['cat_id'] = explode( ',', $contact['cat_id'] ); |
|
239 | - if ( !is_array( $record_array['cat_id'] ) ) $record->cat_id = explode( ',', $record->cat_id ); |
|
240 | - $record->cat_id = implode( ',', array_unique( array_merge( $record->cat_id, $contact['cat_id'] ) ) ); |
|
237 | + if ($this->definition->plugin_options['update_cats'] == 'add') { |
|
238 | + if (!is_array($contact['cat_id'])) $contact['cat_id'] = explode(',', $contact['cat_id']); |
|
239 | + if (!is_array($record_array['cat_id'])) $record->cat_id = explode(',', $record->cat_id); |
|
240 | + $record->cat_id = implode(',', array_unique(array_merge($record->cat_id, $contact['cat_id']))); |
|
241 | 241 | } |
242 | - $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
|
242 | + $success = $this->action($action['action'], $record, $import_csv->get_current_position()); |
|
243 | 243 | } |
244 | 244 | } else { |
245 | 245 | $action = $condition['false']; |
246 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
246 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
247 | 247 | } |
248 | 248 | break; |
249 | 249 | case 'equal': |
250 | 250 | // Match on field |
251 | 251 | $result = $this->equal($record, $condition); |
252 | - if($result) |
|
252 | + if ($result) |
|
253 | 253 | { |
254 | 254 | // Apply true action to any matching records found |
255 | 255 | $action = $condition['true']; |
256 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
256 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
257 | 257 | } |
258 | 258 | else |
259 | 259 | { |
260 | 260 | // Apply false action if no matching records found |
261 | 261 | $action = $condition['false']; |
262 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
262 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
263 | 263 | } |
264 | 264 | break; |
265 | 265 | |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | } |
272 | 272 | } else { |
273 | 273 | // unconditional insert |
274 | - $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
|
274 | + $success = $this->action('insert', $record, $import_csv->get_current_position()); |
|
275 | 275 | } |
276 | 276 | return $success; |
277 | 277 | } |
@@ -283,11 +283,11 @@ discard block |
||
283 | 283 | * @param importexport_iface_egw_record $record contact data for the action |
284 | 284 | * @return bool success or not |
285 | 285 | */ |
286 | - protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) { |
|
286 | + protected function action($_action, importexport_iface_egw_record &$record, $record_num = 0) { |
|
287 | 287 | $_data = $record->get_record_array(); |
288 | 288 | |
289 | 289 | // Make sure picture is loaded/updated |
290 | - if($_data['jpegphoto']) |
|
290 | + if ($_data['jpegphoto']) |
|
291 | 291 | { |
292 | 292 | $_data['photo_unchanged'] = false; |
293 | 293 | } |
@@ -296,15 +296,15 @@ discard block |
||
296 | 296 | case 'none' : |
297 | 297 | return true; |
298 | 298 | case 'delete': |
299 | - if($_data['id']) |
|
299 | + if ($_data['id']) |
|
300 | 300 | { |
301 | - if ( $this->dry_run ) { |
|
301 | + if ($this->dry_run) { |
|
302 | 302 | //print_r($_data); |
303 | 303 | $this->results[$_action]++; |
304 | 304 | return true; |
305 | 305 | } |
306 | 306 | $result = $this->bocontacts->delete($_data); |
307 | - if($result && $result === true) |
|
307 | + if ($result && $result === true) |
|
308 | 308 | { |
309 | 309 | $this->results[$_action]++; |
310 | 310 | } |
@@ -319,14 +319,14 @@ discard block |
||
319 | 319 | // Only update if there are changes |
320 | 320 | $old = $this->bocontacts->read($_data['id']); |
321 | 321 | // if we get countrycodes as countryname, try to translate them -> the rest should be handled by bo classes. |
322 | - foreach(array('adr_one_', 'adr_two_') as $c_prefix) { |
|
323 | - if (strlen(trim($_data[$c_prefix.'countryname']))==2) |
|
322 | + foreach (array('adr_one_', 'adr_two_') as $c_prefix) { |
|
323 | + if (strlen(trim($_data[$c_prefix.'countryname'])) == 2) |
|
324 | 324 | $_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']), true); |
325 | 325 | } |
326 | 326 | // Don't change a user account into a contact |
327 | - if($old['owner'] == 0) { |
|
327 | + if ($old['owner'] == 0) { |
|
328 | 328 | unset($_data['owner']); |
329 | - } elseif(!$this->definition->plugin_options['change_owner']) { |
|
329 | + } elseif (!$this->definition->plugin_options['change_owner']) { |
|
330 | 330 | // Don't change addressbook of an existing contact |
331 | 331 | unset($_data['owner']); |
332 | 332 | } |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | // Merge to deal with fields not in import record |
337 | 337 | $_data = array_merge($old, $_data); |
338 | 338 | $changed = $this->tracking->changed_fields($_data, $old); |
339 | - if(count($changed) == 0) { |
|
339 | + if (count($changed) == 0) { |
|
340 | 340 | return true; |
341 | 341 | } else { |
342 | 342 | //error_log(__METHOD__.__LINE__.array2string($changed).' Old:'.$old['adr_one_countryname'].' ('.$old['adr_one_countrycode'].') New:'.$_data['adr_one_countryname'].' ('.$_data['adr_one_countryname'].')'); |
@@ -347,22 +347,22 @@ discard block |
||
347 | 347 | |
348 | 348 | // Fall through |
349 | 349 | case 'insert' : |
350 | - if($_action == 'insert') { |
|
350 | + if ($_action == 'insert') { |
|
351 | 351 | // Addressbook backend doesn't like inserting with ID specified, it screws up the owner & etag |
352 | 352 | unset($_data['id']); |
353 | 353 | } |
354 | - if(!isset($_data['org_name'])) { |
|
354 | + if (!isset($_data['org_name'])) { |
|
355 | 355 | // org_name is a trigger to update n_fileas |
356 | 356 | $_data['org_name'] = ''; |
357 | 357 | } |
358 | 358 | |
359 | - if ( $this->dry_run ) { |
|
359 | + if ($this->dry_run) { |
|
360 | 360 | //print_r($_data); |
361 | 361 | $this->results[$_action]++; |
362 | 362 | return true; |
363 | 363 | } else { |
364 | - $result = $this->bocontacts->save( $_data, $this->is_admin); |
|
365 | - if(!$result) { |
|
364 | + $result = $this->bocontacts->save($_data, $this->is_admin); |
|
365 | + if (!$result) { |
|
366 | 366 | $this->errors[$record_num] = $this->bocontacts->error; |
367 | 367 | } else { |
368 | 368 | $this->ids[] = $result; |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | return $result; |
374 | 374 | } |
375 | 375 | default: |
376 | - throw new Api\Exception('Unsupported action: '. $_action); |
|
376 | + throw new Api\Exception('Unsupported action: '.$_action); |
|
377 | 377 | |
378 | 378 | } |
379 | 379 | } |
@@ -393,15 +393,15 @@ discard block |
||
393 | 393 | |
394 | 394 | $delete = array_diff($contacts, $ids); |
395 | 395 | |
396 | - foreach($delete as $id) |
|
396 | + foreach ($delete as $id) |
|
397 | 397 | { |
398 | - if($this->dry_run || $this->bocontacts->delete($id)) |
|
398 | + if ($this->dry_run || $this->bocontacts->delete($id)) |
|
399 | 399 | { |
400 | 400 | $this->results['deleted']++; |
401 | 401 | } |
402 | 402 | else |
403 | 403 | { |
404 | - $this->warnings[] = lang('Unable to delete') . ': ' . Api\Link::title('addressbook', $id); |
|
404 | + $this->warnings[] = lang('Unable to delete').': '.Api\Link::title('addressbook', $id); |
|
405 | 405 | } |
406 | 406 | } |
407 | 407 | } |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | * preserv => array, |
446 | 446 | * ) |
447 | 447 | */ |
448 | - public function get_options_etpl(importexport_definition &$definition=null) |
|
448 | + public function get_options_etpl(importexport_definition &$definition = null) |
|
449 | 449 | { |
450 | 450 | // lets do it! |
451 | 451 | } |
@@ -15,7 +15,8 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * class import_csv for addressbook |
17 | 17 | */ |
18 | -class addressbook_import_contacts_csv extends importexport_basic_import_csv { |
|
18 | +class addressbook_import_contacts_csv extends importexport_basic_import_csv |
|
19 | +{ |
|
19 | 20 | |
20 | 21 | /** |
21 | 22 | * conditions for actions |
@@ -56,7 +57,8 @@ discard block |
||
56 | 57 | * @param string $_charset |
57 | 58 | * @param definition $_definition |
58 | 59 | */ |
59 | - public function import( $_stream, importexport_definition $_definition ) { |
|
60 | + public function import( $_stream, importexport_definition $_definition ) |
|
61 | + { |
|
60 | 62 | parent::import($_stream, $_definition); |
61 | 63 | |
62 | 64 | if($_definition->plugin_options['empty_addressbook']) |
@@ -71,7 +73,8 @@ discard block |
||
71 | 73 | * @param string $_charset |
72 | 74 | * @param definition $_definition |
73 | 75 | */ |
74 | - public function init(importexport_definition &$_definition ) { |
|
76 | + public function init(importexport_definition &$_definition ) |
|
77 | + { |
|
75 | 78 | |
76 | 79 | // fetch the addressbook bo |
77 | 80 | $this->bocontacts = new addressbook_bo(); |
@@ -131,22 +134,29 @@ discard block |
||
131 | 134 | protected function import_record(importexport_iface_egw_record &$record, &$import_csv) |
132 | 135 | { |
133 | 136 | // Set owner, unless it's supposed to come from CSV file |
134 | - if($this->definition->plugin_options['owner_from_csv'] && $record->owner) { |
|
135 | - if(!is_numeric($record->owner)) { |
|
137 | + if($this->definition->plugin_options['owner_from_csv'] && $record->owner) |
|
138 | + { |
|
139 | + if(!is_numeric($record->owner)) |
|
140 | + { |
|
136 | 141 | // Automatically handle text owner without explicit translation |
137 | 142 | $new_owner = importexport_helper_functions::account_name2id($record->owner); |
138 | - if($new_owner == '') { |
|
143 | + if($new_owner == '') |
|
144 | + { |
|
139 | 145 | $this->errors[$import_csv->get_current_position()] = lang( |
140 | 146 | 'Unable to convert "%1" to account ID. Using plugin setting (%2) for owner.', |
141 | 147 | $record->owner, |
142 | 148 | Api\Accounts::username($this->user) |
143 | 149 | ); |
144 | 150 | $record->owner = $this->user; |
145 | - } else { |
|
151 | + } |
|
152 | + else |
|
153 | + { |
|
146 | 154 | $record->owner = $new_owner; |
147 | 155 | } |
148 | 156 | } |
149 | - } else { |
|
157 | + } |
|
158 | + else |
|
159 | + { |
|
150 | 160 | $record->owner = $this->user; |
151 | 161 | } |
152 | 162 | |
@@ -182,26 +192,41 @@ discard block |
||
182 | 192 | // Also handle categories in their own field |
183 | 193 | $record_array = $record->get_record_array(); |
184 | 194 | $more_categories = array(); |
185 | - foreach($this->definition->plugin_options['field_mapping'] as $field_name) { |
|
195 | + foreach($this->definition->plugin_options['field_mapping'] as $field_name) |
|
196 | + { |
|
186 | 197 | if(!array_key_exists($field_name, $record_array) || |
187 | - substr($field_name,0,3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') continue; |
|
198 | + substr($field_name,0,3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') |
|
199 | + { |
|
200 | + continue; |
|
201 | + } |
|
188 | 202 | list(, $cat_id) = explode('-', $field_name); |
189 | - if(is_numeric($record->$field_name) && $record->$field_name != 1) { |
|
203 | + if(is_numeric($record->$field_name) && $record->$field_name != 1) |
|
204 | + { |
|
190 | 205 | // Column has a single category ID |
191 | 206 | $more_categories[] = $record->$field_name; |
192 | - } elseif($record->$field_name == '1' || |
|
193 | - (!is_numeric($record->$field_name) && strtolower($record->$field_name) == strtolower(lang('Yes')))) { |
|
207 | + } |
|
208 | + elseif($record->$field_name == '1' || |
|
209 | + (!is_numeric($record->$field_name) && strtolower($record->$field_name) == strtolower(lang('Yes')))) |
|
210 | + { |
|
194 | 211 | // Each category got its own column. '1' is the database value, lang('yes') is the human value |
195 | 212 | $more_categories[] = $cat_id; |
196 | - } else { |
|
213 | + } |
|
214 | + else |
|
215 | + { |
|
197 | 216 | // Text categories |
198 | 217 | $more_categories = array_merge($more_categories, importexport_helper_functions::cat_name2id(is_array($record->$field_name) ? $record->$field_name : explode(',',$record->$field_name), $cat_id)); |
199 | 218 | } |
200 | 219 | } |
201 | - if(count($more_categories) > 0) $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',',$record->cat_id), $more_categories); |
|
220 | + if(count($more_categories) > 0) |
|
221 | + { |
|
222 | + $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',',$record->cat_id), $more_categories); |
|
223 | + } |
|
202 | 224 | |
203 | 225 | // Private set but missing causes hidden entries |
204 | - if(array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) unset($record->private); |
|
226 | + if(array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) |
|
227 | + { |
|
228 | + unset($record->private); |
|
229 | + } |
|
205 | 230 | |
206 | 231 | // Format birthday as backend requires - converter should give timestamp |
207 | 232 | if($record->bday && is_numeric($record->bday)) |
@@ -210,17 +235,24 @@ discard block |
||
210 | 235 | $record->bday = $time->format('Y-m-d'); |
211 | 236 | } |
212 | 237 | |
213 | - if ( $this->definition->plugin_options['conditions'] ) { |
|
214 | - foreach ( $this->definition->plugin_options['conditions'] as $condition ) { |
|
238 | + if ( $this->definition->plugin_options['conditions'] ) |
|
239 | + { |
|
240 | + foreach ( $this->definition->plugin_options['conditions'] as $condition ) |
|
241 | + { |
|
215 | 242 | $contacts = array(); |
216 | - switch ( $condition['type'] ) { |
|
243 | + switch ( $condition['type'] ) |
|
244 | + { |
|
217 | 245 | // exists |
218 | 246 | case 'exists' : |
219 | - if($record_array[$condition['string']]) { |
|
247 | + if($record_array[$condition['string']]) |
|
248 | + { |
|
220 | 249 | $searchcondition = array( $condition['string'] => $record_array[$condition['string']]); |
221 | 250 | // if we use account_id for the condition, we need to set the owner for filtering, as this |
222 | 251 | // enables Api\Contacts\Storage to decide what backend is to be used |
223 | - if ($condition['string']=='account_id') $searchcondition['owner']=0; |
|
252 | + if ($condition['string']=='account_id') |
|
253 | + { |
|
254 | + $searchcondition['owner']=0; |
|
255 | + } |
|
224 | 256 | $contacts = $this->bocontacts->search( |
225 | 257 | //array( $condition['string'] => $record[$condition['string']],), |
226 | 258 | '', |
@@ -229,19 +261,30 @@ discard block |
||
229 | 261 | $searchcondition |
230 | 262 | ); |
231 | 263 | } |
232 | - if ( is_array( $contacts ) && count( array_keys( $contacts ) ) >= 1 ) { |
|
264 | + if ( is_array( $contacts ) && count( array_keys( $contacts ) ) >= 1 ) |
|
265 | + { |
|
233 | 266 | // apply action to all contacts matching this exists condition |
234 | 267 | $action = $condition['true']; |
235 | - foreach ( (array)$contacts as $contact ) { |
|
268 | + foreach ( (array)$contacts as $contact ) |
|
269 | + { |
|
236 | 270 | $record->id = $contact['id']; |
237 | - if ( $this->definition->plugin_options['update_cats'] == 'add' ) { |
|
238 | - if ( !is_array( $contact['cat_id'] ) ) $contact['cat_id'] = explode( ',', $contact['cat_id'] ); |
|
239 | - if ( !is_array( $record_array['cat_id'] ) ) $record->cat_id = explode( ',', $record->cat_id ); |
|
271 | + if ( $this->definition->plugin_options['update_cats'] == 'add' ) |
|
272 | + { |
|
273 | + if ( !is_array( $contact['cat_id'] ) ) |
|
274 | + { |
|
275 | + $contact['cat_id'] = explode( ',', $contact['cat_id'] ); |
|
276 | + } |
|
277 | + if ( !is_array( $record_array['cat_id'] ) ) |
|
278 | + { |
|
279 | + $record->cat_id = explode( ',', $record->cat_id ); |
|
280 | + } |
|
240 | 281 | $record->cat_id = implode( ',', array_unique( array_merge( $record->cat_id, $contact['cat_id'] ) ) ); |
241 | 282 | } |
242 | 283 | $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
243 | 284 | } |
244 | - } else { |
|
285 | + } |
|
286 | + else |
|
287 | + { |
|
245 | 288 | $action = $condition['false']; |
246 | 289 | $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
247 | 290 | } |
@@ -267,9 +310,14 @@ discard block |
||
267 | 310 | default : |
268 | 311 | die('condition / action not supported!!!'); |
269 | 312 | } |
270 | - if ($action['stop']) break; |
|
313 | + if ($action['stop']) |
|
314 | + { |
|
315 | + break; |
|
316 | + } |
|
271 | 317 | } |
272 | - } else { |
|
318 | + } |
|
319 | + else |
|
320 | + { |
|
273 | 321 | // unconditional insert |
274 | 322 | $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
275 | 323 | } |
@@ -283,7 +331,8 @@ discard block |
||
283 | 331 | * @param importexport_iface_egw_record $record contact data for the action |
284 | 332 | * @return bool success or not |
285 | 333 | */ |
286 | - protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) { |
|
334 | + protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) |
|
335 | + { |
|
287 | 336 | $_data = $record->get_record_array(); |
288 | 337 | |
289 | 338 | // Make sure picture is loaded/updated |
@@ -292,13 +341,15 @@ discard block |
||
292 | 341 | $_data['photo_unchanged'] = false; |
293 | 342 | } |
294 | 343 | |
295 | - switch ($_action) { |
|
344 | + switch ($_action) |
|
345 | + { |
|
296 | 346 | case 'none' : |
297 | 347 | return true; |
298 | 348 | case 'delete': |
299 | 349 | if($_data['id']) |
300 | 350 | { |
301 | - if ( $this->dry_run ) { |
|
351 | + if ( $this->dry_run ) |
|
352 | + { |
|
302 | 353 | //print_r($_data); |
303 | 354 | $this->results[$_action]++; |
304 | 355 | return true; |
@@ -319,14 +370,20 @@ discard block |
||
319 | 370 | // Only update if there are changes |
320 | 371 | $old = $this->bocontacts->read($_data['id']); |
321 | 372 | // if we get countrycodes as countryname, try to translate them -> the rest should be handled by bo classes. |
322 | - foreach(array('adr_one_', 'adr_two_') as $c_prefix) { |
|
373 | + foreach(array('adr_one_', 'adr_two_') as $c_prefix) |
|
374 | + { |
|
323 | 375 | if (strlen(trim($_data[$c_prefix.'countryname']))==2) |
324 | - $_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']), true); |
|
376 | + { |
|
377 | + $_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']), true); |
|
378 | + } |
|
325 | 379 | } |
326 | 380 | // Don't change a user account into a contact |
327 | - if($old['owner'] == 0) { |
|
381 | + if($old['owner'] == 0) |
|
382 | + { |
|
328 | 383 | unset($_data['owner']); |
329 | - } elseif(!$this->definition->plugin_options['change_owner']) { |
|
384 | + } |
|
385 | + elseif(!$this->definition->plugin_options['change_owner']) |
|
386 | + { |
|
330 | 387 | // Don't change addressbook of an existing contact |
331 | 388 | unset($_data['owner']); |
332 | 389 | } |
@@ -336,9 +393,12 @@ discard block |
||
336 | 393 | // Merge to deal with fields not in import record |
337 | 394 | $_data = array_merge($old, $_data); |
338 | 395 | $changed = $this->tracking->changed_fields($_data, $old); |
339 | - if(count($changed) == 0) { |
|
396 | + if(count($changed) == 0) |
|
397 | + { |
|
340 | 398 | return true; |
341 | - } else { |
|
399 | + } |
|
400 | + else |
|
401 | + { |
|
342 | 402 | //error_log(__METHOD__.__LINE__.array2string($changed).' Old:'.$old['adr_one_countryname'].' ('.$old['adr_one_countrycode'].') New:'.$_data['adr_one_countryname'].' ('.$_data['adr_one_countryname'].')'); |
343 | 403 | } |
344 | 404 | |
@@ -347,24 +407,32 @@ discard block |
||
347 | 407 | |
348 | 408 | // Fall through |
349 | 409 | case 'insert' : |
350 | - if($_action == 'insert') { |
|
410 | + if($_action == 'insert') |
|
411 | + { |
|
351 | 412 | // Addressbook backend doesn't like inserting with ID specified, it screws up the owner & etag |
352 | 413 | unset($_data['id']); |
353 | 414 | } |
354 | - if(!isset($_data['org_name'])) { |
|
415 | + if(!isset($_data['org_name'])) |
|
416 | + { |
|
355 | 417 | // org_name is a trigger to update n_fileas |
356 | 418 | $_data['org_name'] = ''; |
357 | 419 | } |
358 | 420 | |
359 | - if ( $this->dry_run ) { |
|
421 | + if ( $this->dry_run ) |
|
422 | + { |
|
360 | 423 | //print_r($_data); |
361 | 424 | $this->results[$_action]++; |
362 | 425 | return true; |
363 | - } else { |
|
426 | + } |
|
427 | + else |
|
428 | + { |
|
364 | 429 | $result = $this->bocontacts->save( $_data, $this->is_admin); |
365 | - if(!$result) { |
|
430 | + if(!$result) |
|
431 | + { |
|
366 | 432 | $this->errors[$record_num] = $this->bocontacts->error; |
367 | - } else { |
|
433 | + } |
|
434 | + else |
|
435 | + { |
|
368 | 436 | $this->ids[] = $result; |
369 | 437 | $this->results[$_action]++; |
370 | 438 | // This does nothing (yet?) but update the identifier |
@@ -411,7 +479,8 @@ discard block |
||
411 | 479 | * |
412 | 480 | * @return string name |
413 | 481 | */ |
414 | - public static function get_name() { |
|
482 | + public static function get_name() |
|
483 | + { |
|
415 | 484 | return lang('Addressbook CSV import'); |
416 | 485 | } |
417 | 486 | |
@@ -420,7 +489,8 @@ discard block |
||
420 | 489 | * |
421 | 490 | * @return string descriprion |
422 | 491 | */ |
423 | - public static function get_description() { |
|
492 | + public static function get_description() |
|
493 | + { |
|
424 | 494 | return lang("Imports contacts into your Addressbook from a CSV File. CSV means 'Comma Separated Values'. However in the options Tab you can also choose other seperators."); |
425 | 495 | } |
426 | 496 | |
@@ -429,7 +499,8 @@ discard block |
||
429 | 499 | * |
430 | 500 | * @return string suffix (comma seperated) |
431 | 501 | */ |
432 | - public static function get_filesuffix() { |
|
502 | + public static function get_filesuffix() |
|
503 | + { |
|
433 | 504 | return 'csv'; |
434 | 505 | } |
435 | 506 | |
@@ -455,7 +526,8 @@ discard block |
||
455 | 526 | * |
456 | 527 | * @return string etemplate name |
457 | 528 | */ |
458 | - public function get_selectors_etpl() { |
|
529 | + public function get_selectors_etpl() |
|
530 | + { |
|
459 | 531 | // lets do it! |
460 | 532 | } |
461 | 533 | |
@@ -467,7 +539,8 @@ discard block |
||
467 | 539 | * record_# => warning message |
468 | 540 | * ) |
469 | 541 | */ |
470 | - public function get_warnings() { |
|
542 | + public function get_warnings() |
|
543 | + { |
|
471 | 544 | return $this->warnings; |
472 | 545 | } |
473 | 546 | |
@@ -479,7 +552,8 @@ discard block |
||
479 | 552 | * record_# => error message |
480 | 553 | * ) |
481 | 554 | */ |
482 | - public function get_errors() { |
|
555 | + public function get_errors() |
|
556 | + { |
|
483 | 557 | return $this->errors; |
484 | 558 | } |
485 | 559 | |
@@ -491,7 +565,8 @@ discard block |
||
491 | 565 | * action => record count |
492 | 566 | * ) |
493 | 567 | */ |
494 | - public function get_results() { |
|
568 | + public function get_results() |
|
569 | + { |
|
495 | 570 | return $this->results; |
496 | 571 | } |
497 | 572 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * @param string $id folder id |
278 | 278 | * @param int $cutoffdate =null |
279 | 279 | * @return array |
280 | - */ |
|
280 | + */ |
|
281 | 281 | function GetMessageList($id, $cutoffdate=NULL) |
282 | 282 | { |
283 | 283 | unset($cutoffdate); // not used, but required by function signature |
@@ -378,10 +378,10 @@ discard block |
||
378 | 378 | case 'bday': // zpush seems to use a timestamp in utc (at least vcard backend does) |
379 | 379 | if (!empty($contact[$attr])) |
380 | 380 | { |
381 | - $tz = date_default_timezone_get(); |
|
382 | - date_default_timezone_set('UTC'); |
|
383 | - $message->birthday = strtotime($contact[$attr]); |
|
384 | - date_default_timezone_set($tz); |
|
381 | + $tz = date_default_timezone_get(); |
|
382 | + date_default_timezone_set('UTC'); |
|
383 | + $message->birthday = strtotime($contact[$attr]); |
|
384 | + date_default_timezone_set($tz); |
|
385 | 385 | } |
386 | 386 | break; |
387 | 387 | |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | * @param $folderid of the current folder |
635 | 635 | * @param $id of the message |
636 | 636 | * @param $newfolderid |
637 | - * @param ContentParameters $contentParameters |
|
637 | + * @param ContentParameters $contentParameters |
|
638 | 638 | * |
639 | 639 | * @return $newid as a string | boolean false on error |
640 | 640 | * |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | * |
663 | 663 | * @param $folderid |
664 | 664 | * @param $id |
665 | - * @param ContentParameters $contentParameters |
|
665 | + * @param ContentParameters $contentParameters |
|
666 | 666 | * |
667 | 667 | * @return boolean true on success, false on error, diffbackend does NOT use the returnvalue |
668 | 668 | * |
@@ -681,23 +681,23 @@ discard block |
||
681 | 681 | return $ret; |
682 | 682 | } |
683 | 683 | |
684 | - /** |
|
685 | - * Changes the 'read' flag of a message on disk. The $flags |
|
686 | - * parameter can only be '1' (read) or '0' (unread). After a call to |
|
687 | - * SetReadFlag(), GetMessageList() should return the message with the |
|
688 | - * new 'flags' but should not modify the 'mod' parameter. If you do |
|
689 | - * change 'mod', simply setting the message to 'read' on the mobile will trigger |
|
690 | - * a full resync of the item from the server. |
|
691 | - * |
|
692 | - * @param string $folderid id of the folder |
|
693 | - * @param string $id id of the message |
|
694 | - * @param int $flags read flag of the message |
|
695 | - * @param ContentParameters $contentParameters |
|
696 | - * |
|
697 | - * @access public |
|
698 | - * @return boolean status of the operation |
|
699 | - * @throws StatusException could throw specific SYNC_STATUS_* exceptions |
|
700 | - */ |
|
684 | + /** |
|
685 | + * Changes the 'read' flag of a message on disk. The $flags |
|
686 | + * parameter can only be '1' (read) or '0' (unread). After a call to |
|
687 | + * SetReadFlag(), GetMessageList() should return the message with the |
|
688 | + * new 'flags' but should not modify the 'mod' parameter. If you do |
|
689 | + * change 'mod', simply setting the message to 'read' on the mobile will trigger |
|
690 | + * a full resync of the item from the server. |
|
691 | + * |
|
692 | + * @param string $folderid id of the folder |
|
693 | + * @param string $id id of the message |
|
694 | + * @param int $flags read flag of the message |
|
695 | + * @param ContentParameters $contentParameters |
|
696 | + * |
|
697 | + * @access public |
|
698 | + * @return boolean status of the operation |
|
699 | + * @throws StatusException could throw specific SYNC_STATUS_* exceptions |
|
700 | + */ |
|
701 | 701 | function SetReadFlag($folderid, $id, $flags, $contentParameters) |
702 | 702 | { |
703 | 703 | unset($folderid, $id, $flags, $contentParameters); |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | * |
714 | 714 | * |
715 | 715 | * @DESC The $flags parameter must contains the poommailflag Object |
716 | - */ |
|
716 | + */ |
|
717 | 717 | function ChangeMessageFlag($folderid, $id, $flags) |
718 | 718 | { |
719 | 719 | unset($folderid, $id, $flags); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | 'homestreet' => 'adr_two_street', |
72 | 72 | 'homefaxnumber' => 'tel_fax_home', |
73 | 73 | 'homephonenumber' => 'tel_home', |
74 | - 'jobtitle' => 'title', // unfortunatly outlook only has title & jobtitle, while EGw has 'n_prefix', 'title' & 'role', |
|
74 | + 'jobtitle' => 'title', // unfortunatly outlook only has title & jobtitle, while EGw has 'n_prefix', 'title' & 'role', |
|
75 | 75 | 'lastname' => 'n_family', |
76 | 76 | 'middlename' => 'n_middle', |
77 | 77 | 'mobilephonenumber' => 'tel_cell', |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | * @param booelan $ab_prefix =false prefix personal, private and accounts addressbook with lang('Addressbook').' ' |
124 | 124 | * @return string|array addressbook name of array with int account_id => label pairs |
125 | 125 | */ |
126 | - private function get_addressbooks($account=null,$return_all_in_one=true, $ab_prefix=false) |
|
126 | + private function get_addressbooks($account = null, $return_all_in_one = true, $ab_prefix = false) |
|
127 | 127 | { |
128 | - static $abs=null; |
|
128 | + static $abs = null; |
|
129 | 129 | |
130 | 130 | if (!isset($abs) || !$return_all_in_one) |
131 | 131 | { |
@@ -137,14 +137,14 @@ discard block |
||
137 | 137 | } |
138 | 138 | else |
139 | 139 | { |
140 | - Api\Translation::add_app('addressbook'); // we need the addressbook translations |
|
140 | + Api\Translation::add_app('addressbook'); // we need the addressbook translations |
|
141 | 141 | |
142 | 142 | if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
143 | 143 | |
144 | 144 | $pref_abs = $GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-abs']; |
145 | 145 | if (!is_array($pref_abs)) |
146 | 146 | { |
147 | - $pref_abs = $pref_abs ? explode(',',$pref_abs) : []; |
|
147 | + $pref_abs = $pref_abs ? explode(',', $pref_abs) : []; |
|
148 | 148 | } |
149 | 149 | foreach ($this->addressbook->get_addressbooks() as $account_id => $label) |
150 | 150 | { |
@@ -152,18 +152,17 @@ discard block |
||
152 | 152 | { |
153 | 153 | $account_id = self::PRIVATE_AB; |
154 | 154 | } |
155 | - if ($account_id && in_array($account_id,$pref_abs) || in_array('A',$pref_abs) || |
|
156 | - $account_id == 0 && in_array('U',$pref_abs) || |
|
157 | - $account_id == $GLOBALS['egw_info']['user']['account_id'] || // allways sync pers. AB |
|
158 | - $account_id == $GLOBALS['egw_info']['user']['account_primary_group'] && in_array('G',$pref_abs)) |
|
155 | + if ($account_id && in_array($account_id, $pref_abs) || in_array('A', $pref_abs) || |
|
156 | + $account_id == 0 && in_array('U', $pref_abs) || |
|
157 | + $account_id == $GLOBALS['egw_info']['user']['account_id'] || // allways sync pers. AB |
|
158 | + $account_id == $GLOBALS['egw_info']['user']['account_primary_group'] && in_array('G', $pref_abs)) |
|
159 | 159 | { |
160 | 160 | $abs[$account_id] = $label; |
161 | 161 | } |
162 | 162 | } |
163 | 163 | } |
164 | 164 | } |
165 | - $ret = is_null($account) ? $abs : |
|
166 | - ($ab_prefix && (!$account || (int)$account == (int)$GLOBALS['egw_info']['user']['account_id']) ? |
|
165 | + $ret = is_null($account) ? $abs : ($ab_prefix && (!$account || (int)$account == (int)$GLOBALS['egw_info']['user']['account_id']) ? |
|
167 | 166 | lang('Addressbook').' ' : '').$abs[$account]; |
168 | 167 | //error_log(__METHOD__."($account, $return_all_in_one, $ab_prefix) returning ".array2string($ret)); |
169 | 168 | return $ret; |
@@ -181,7 +180,7 @@ discard block |
||
181 | 180 | foreach ($this->get_addressbooks() as $account => $label) |
182 | 181 | { |
183 | 182 | $folderlist[] = array( |
184 | - 'id' => $this->backend->createID('addressbook',$account), |
|
183 | + 'id' => $this->backend->createID('addressbook', $account), |
|
185 | 184 | 'mod' => $label, |
186 | 185 | 'parent'=> '0', |
187 | 186 | ); |
@@ -279,20 +278,20 @@ discard block |
||
279 | 278 | * @param int $cutoffdate =null |
280 | 279 | * @return array |
281 | 280 | */ |
282 | - function GetMessageList($id, $cutoffdate=NULL) |
|
281 | + function GetMessageList($id, $cutoffdate = NULL) |
|
283 | 282 | { |
284 | - unset($cutoffdate); // not used, but required by function signature |
|
283 | + unset($cutoffdate); // not used, but required by function signature |
|
285 | 284 | if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
286 | 285 | |
287 | 286 | $type = $user = null; |
288 | - $this->backend->splitID($id,$type,$user); |
|
287 | + $this->backend->splitID($id, $type, $user); |
|
289 | 288 | $filter = array('owner' => $user); |
290 | 289 | |
291 | 290 | // handle all-in-one addressbook |
292 | 291 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one'] && |
293 | 292 | $user == $GLOBALS['egw_info']['user']['account_id']) |
294 | 293 | { |
295 | - $filter['owner'] = array_keys($this->get_addressbooks(null,false)); // false = return all selected abs |
|
294 | + $filter['owner'] = array_keys($this->get_addressbooks(null, false)); // false = return all selected abs |
|
296 | 295 | // translate AS private AB ID to EGroupware one |
297 | 296 | if (($key = array_search(self::PRIVATE_AB, $filter['owner'])) !== false) |
298 | 297 | { |
@@ -309,10 +308,10 @@ discard block |
||
309 | 308 | |
310 | 309 | $messagelist = array(); |
311 | 310 | $criteria = null; |
312 | - if (($contacts =& $this->addressbook->search($criteria, 'contact_id,contact_etag', '', '', '', |
|
313 | - false, 'AND', false,$filter))) |
|
311 | + if (($contacts = & $this->addressbook->search($criteria, 'contact_id,contact_etag', '', '', '', |
|
312 | + false, 'AND', false, $filter))) |
|
314 | 313 | { |
315 | - foreach($contacts as $contact) |
|
314 | + foreach ($contacts as $contact) |
|
316 | 315 | { |
317 | 316 | $messagelist[] = $this->StatMessage($id, $contact); |
318 | 317 | } |
@@ -349,9 +348,9 @@ discard block |
||
349 | 348 | } |
350 | 349 | $emailname = isset($contact['n_given']) ? $contact['n_given'].' ' : ''; |
351 | 350 | $emailname .= isset($contact['n_middle']) ? $contact['n_middle'].' ' : ''; |
352 | - $emailname .= isset($contact['n_family']) ? $contact['n_family']: ''; |
|
351 | + $emailname .= isset($contact['n_family']) ? $contact['n_family'] : ''; |
|
353 | 352 | $message = new SyncContact(); |
354 | - foreach(self::$mapping as $key => $attr) |
|
353 | + foreach (self::$mapping as $key => $attr) |
|
355 | 354 | { |
356 | 355 | switch ($attr) |
357 | 356 | { |
@@ -364,7 +363,7 @@ discard block |
||
364 | 363 | } |
365 | 364 | else |
366 | 365 | { |
367 | - if (strlen ($contact[$attr]) > 0) |
|
366 | + if (strlen($contact[$attr]) > 0) |
|
368 | 367 | { |
369 | 368 | $message->asbody = new SyncBaseBody(); |
370 | 369 | $this->backend->note2messagenote($contact[$attr], $bodypreference, $message->asbody); |
@@ -373,7 +372,7 @@ discard block |
||
373 | 372 | break; |
374 | 373 | |
375 | 374 | case 'jpegphoto': |
376 | - if (empty($contact[$attr]) && ($contact['files'] & Api\Contacts::FILES_BIT_PHOTO)) |
|
375 | + if (empty($contact[$attr]) && ($contact['files']&Api\Contacts::FILES_BIT_PHOTO)) |
|
377 | 376 | { |
378 | 377 | $contact[$attr] = file_get_contents(Api\Link::vfs_path('addressbook', $contact['id'], Api\Contacts::FILES_PHOTO)); |
379 | 378 | } |
@@ -392,14 +391,14 @@ discard block |
||
392 | 391 | |
393 | 392 | case 'cat_id': |
394 | 393 | $message->$key = array(); |
395 | - foreach($contact[$attr] ? explode(',',$contact[$attr]) : array() as $cat_id) |
|
394 | + foreach ($contact[$attr] ? explode(',', $contact[$attr]) : array() as $cat_id) |
|
396 | 395 | { |
397 | 396 | $message->categories[] = Api\Categories::id2name($cat_id); |
398 | 397 | } |
399 | 398 | // for all addressbooks in one, add addressbook name itself as category |
400 | 399 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one']) |
401 | 400 | { |
402 | - $message->categories[] = $this->get_addressbooks($contact['owner'].($contact['private']?'p':''), false, true); |
|
401 | + $message->categories[] = $this->get_addressbooks($contact['owner'].($contact['private'] ? 'p' : ''), false, true); |
|
403 | 402 | } |
404 | 403 | break; |
405 | 404 | // HTC Desire needs at least one telefon number, otherwise sync of contact fails without error, |
@@ -411,7 +410,7 @@ discard block |
||
411 | 410 | case 'n_fileas': |
412 | 411 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-force-fileas']) |
413 | 412 | { |
414 | - $message->$key = $this->addressbook->fileas($contact,$GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-force-fileas']); |
|
413 | + $message->$key = $this->addressbook->fileas($contact, $GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-force-fileas']); |
|
415 | 414 | break; |
416 | 415 | } |
417 | 416 | // fall through |
@@ -437,7 +436,7 @@ discard block |
||
437 | 436 | */ |
438 | 437 | public function StatMessage($folderid, $contact) |
439 | 438 | { |
440 | - unset($folderid); // not used (contact_id is global), but required by function signaure |
|
439 | + unset($folderid); // not used (contact_id is global), but required by function signaure |
|
441 | 440 | if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
442 | 441 | |
443 | 442 | if (!is_array($contact)) $contact = $this->addressbook->read($contact); |
@@ -472,7 +471,7 @@ discard block |
||
472 | 471 | */ |
473 | 472 | public function ChangeFolder($id, $oldid, $displayname, $type) |
474 | 473 | { |
475 | - unset($id, $oldid, $displayname, $type); // not used, but required by function signature |
|
474 | + unset($id, $oldid, $displayname, $type); // not used, but required by function signature |
|
476 | 475 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." not implemented"); |
477 | 476 | } |
478 | 477 | |
@@ -511,7 +510,7 @@ discard block |
||
511 | 510 | */ |
512 | 511 | public function ChangeMessage($folderid, $id, $message, $contentParameters) |
513 | 512 | { |
514 | - unset($contentParameters); // not used, but required by function signature |
|
513 | + unset($contentParameters); // not used, but required by function signature |
|
515 | 514 | if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
516 | 515 | |
517 | 516 | $type = $account = null; |
@@ -532,10 +531,10 @@ discard block |
||
532 | 531 | if ($account == 0) // as a precausion, we currently do NOT allow to change Api\Accounts |
533 | 532 | { |
534 | 533 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." Changing of Api\Accounts denied!"); |
535 | - return false; //no changing of Api\Accounts |
|
534 | + return false; //no changing of Api\Accounts |
|
536 | 535 | } |
537 | 536 | $contact = array(); |
538 | - if (empty($id) && ($this->addressbook->grants[$account] & Acl::EDIT) || ($contact = $this->addressbook->read($id)) && $this->addressbook->check_perms(Acl::EDIT, $contact)) |
|
537 | + if (empty($id) && ($this->addressbook->grants[$account]&Acl::EDIT) || ($contact = $this->addressbook->read($id)) && $this->addressbook->check_perms(Acl::EDIT, $contact)) |
|
539 | 538 | { |
540 | 539 | // remove all fields supported by AS, leaving all unsupported fields unchanged |
541 | 540 | $contact = array_diff_key($contact, array_flip(self::$mapping)); |
@@ -548,7 +547,7 @@ discard block |
||
548 | 547 | break; |
549 | 548 | |
550 | 549 | case 'bday': // zpush uses timestamp in servertime |
551 | - $contact[$attr] = $message->$key ? date('Y-m-d',$message->$key) : null; |
|
550 | + $contact[$attr] = $message->$key ? date('Y-m-d', $message->$key) : null; |
|
552 | 551 | break; |
553 | 552 | |
554 | 553 | case 'jpegphoto': |
@@ -558,20 +557,20 @@ discard block |
||
558 | 557 | case 'cat_id': |
559 | 558 | // for existing entries in all-in-one addressbook, remove addressbook name as category |
560 | 559 | if ($contact && $GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one'] && |
561 | - ($k=array_search($this->get_addressbooks($contact['owner'].($contact['private']?'p':''), false, true),$message->$key))) |
|
560 | + ($k = array_search($this->get_addressbooks($contact['owner'].($contact['private'] ? 'p' : ''), false, true), $message->$key))) |
|
562 | 561 | { |
563 | 562 | unset($message->categories[$k]); |
564 | 563 | } |
565 | 564 | if (is_array($message->$key)) |
566 | 565 | { |
567 | - $contact[$attr] = implode(',', array_filter($this->addressbook->find_or_add_categories($message->$key, $id),'strlen')); |
|
566 | + $contact[$attr] = implode(',', array_filter($this->addressbook->find_or_add_categories($message->$key, $id), 'strlen')); |
|
568 | 567 | } |
569 | 568 | break; |
570 | 569 | case 'email': |
571 | 570 | case 'email_home': |
572 | - if (function_exists ('imap_rfc822_parse_adrlist')) |
|
571 | + if (function_exists('imap_rfc822_parse_adrlist')) |
|
573 | 572 | { |
574 | - $email_array = array_shift(imap_rfc822_parse_adrlist($message->$key,"")); |
|
573 | + $email_array = array_shift(imap_rfc822_parse_adrlist($message->$key, "")); |
|
575 | 574 | if (!empty($email_array->mailbox) && $email_array->mailbox != 'INVALID_ADDRESS' && !empty($email_array->host)) |
576 | 575 | { |
577 | 576 | $contact[$attr] = $email_array->mailbox.'@'.$email_array->host; |
@@ -583,7 +582,7 @@ discard block |
||
583 | 582 | } |
584 | 583 | else |
585 | 584 | { |
586 | - ZLog::Write(LOGLEVEL_DEBUG, __METHOD__. " Warning : php-imap not available"); |
|
585 | + ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." Warning : php-imap not available"); |
|
587 | 586 | $contact[$attr] = $message->$key; |
588 | 587 | } |
589 | 588 | break; |
@@ -610,9 +609,9 @@ discard block |
||
610 | 609 | $contact['private'] = (int)$is_private; |
611 | 610 | } |
612 | 611 | // if default addressbook for new contacts is NOT synced --> use personal addressbook |
613 | - elseif($GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'] && |
|
612 | + elseif ($GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'] && |
|
614 | 613 | !in_array($GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'], |
615 | - array_keys($this->get_addressbooks(null,false)))) |
|
614 | + array_keys($this->get_addressbooks(null, false)))) |
|
616 | 615 | { |
617 | 616 | $contact['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
618 | 617 | } |
@@ -644,7 +643,7 @@ discard block |
||
644 | 643 | */ |
645 | 644 | public function MoveMessage($folderid, $id, $newfolderid, $contentParameters) |
646 | 645 | { |
647 | - unset($contentParameters); // not used, but required by function signature |
|
646 | + unset($contentParameters); // not used, but required by function signature |
|
648 | 647 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one']) |
649 | 648 | { |
650 | 649 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', $id, $newfolderid) NOT allowed for an all-in-one addressbook --> returning false"); |
@@ -671,7 +670,7 @@ discard block |
||
671 | 670 | */ |
672 | 671 | public function DeleteMessage($folderid, $id, $contentParameters) |
673 | 672 | { |
674 | - unset($contentParameters); // not used, but required by function signature |
|
673 | + unset($contentParameters); // not used, but required by function signature |
|
675 | 674 | if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
676 | 675 | |
677 | 676 | $ret = $this->addressbook->delete($id); |
@@ -747,16 +746,16 @@ discard block |
||
747 | 746 | } |
748 | 747 | if (in_array('A', $prefs_abs)) |
749 | 748 | { |
750 | - $owner = null; // all AB's |
|
749 | + $owner = null; // all AB's |
|
751 | 750 | } |
752 | 751 | else |
753 | 752 | { |
754 | - $owner = array_keys($this->get_addressbooks(null,false)); // false = return all selected abs |
|
753 | + $owner = array_keys($this->get_addressbooks(null, false)); // false = return all selected abs |
|
755 | 754 | // translate AS private AB ID to current user |
756 | 755 | if (($key = array_search(self::PRIVATE_AB, $owner)) !== false) |
757 | 756 | { |
758 | 757 | unset($owner[$key]); |
759 | - if (!in_array($GLOBALS['egw_info']['user']['account_id'],$owner)) |
|
758 | + if (!in_array($GLOBALS['egw_info']['user']['account_id'], $owner)) |
|
760 | 759 | { |
761 | 760 | $owner[] = $GLOBALS['egw_info']['user']['account_id']; |
762 | 761 | } |
@@ -769,7 +768,7 @@ discard block |
||
769 | 768 | } |
770 | 769 | $ctag = $this->addressbook->get_ctag($owner); |
771 | 770 | |
772 | - $changes = array(); // no change |
|
771 | + $changes = array(); // no change |
|
773 | 772 | //$syncstate_was = $syncstate; |
774 | 773 | |
775 | 774 | if ($ctag !== $syncstate) |
@@ -797,32 +796,32 @@ discard block |
||
797 | 796 | $range = false; |
798 | 797 | if (isset($searchquery['range']) && preg_match('/^\d+-\d+$/', $searchquery['range'])) |
799 | 798 | { |
800 | - list($start,$end) = explode('-', $searchquery['range']); |
|
801 | - $range = array($start, $end-$start+1); // array(start, num_entries) |
|
799 | + list($start, $end) = explode('-', $searchquery['range']); |
|
800 | + $range = array($start, $end - $start + 1); // array(start, num_entries) |
|
802 | 801 | } |
803 | 802 | //error_log(__METHOD__.'('.array2string($searchquery).') range='.array2string($range)); |
804 | 803 | |
805 | 804 | $items = $filter = array(); |
806 | 805 | $filter['cols_to_search'] = array('n_fn', 'n_family', 'n_given', |
807 | - 'room','org_name', 'title', 'role', 'tel_work', 'tel_home', 'tel_cell', |
|
806 | + 'room', 'org_name', 'title', 'role', 'tel_work', 'tel_home', 'tel_cell', |
|
808 | 807 | 'email', 'email_home'); |
809 | - if (($contacts =& $this->addressbook->search($searchquery['query'], false, false, '', '%', false, 'OR', $range, $filter))) |
|
808 | + if (($contacts = & $this->addressbook->search($searchquery['query'], false, false, '', '%', false, 'OR', $range, $filter))) |
|
810 | 809 | { |
811 | - foreach($contacts as $contact) |
|
810 | + foreach ($contacts as $contact) |
|
812 | 811 | { |
813 | 812 | //$item[SYNC_GAL_ALIAS] = $contact['contact_id']; |
814 | - $item[SYNC_GAL_LASTNAME] = $contact['n_family']?$contact['n_family']:$contact['org_name']; |
|
813 | + $item[SYNC_GAL_LASTNAME] = $contact['n_family'] ? $contact['n_family'] : $contact['org_name']; |
|
815 | 814 | $item[SYNC_GAL_FIRSTNAME] = $contact['n_given']; |
816 | 815 | $item[SYNC_GAL_DISPLAYNAME] = $contact['n_fn']; |
817 | - if (!trim($item[SYNC_GAL_DISPLAYNAME])) $item[SYNC_GAL_DISPLAYNAME] = $contact['n_family']?$contact['n_family']:$contact['org_name']; |
|
818 | - $item[SYNC_GAL_EMAILADDRESS] = $contact['email'] ? $contact['email'] : (string)$contact['email_private'] ; |
|
816 | + if (!trim($item[SYNC_GAL_DISPLAYNAME])) $item[SYNC_GAL_DISPLAYNAME] = $contact['n_family'] ? $contact['n_family'] : $contact['org_name']; |
|
817 | + $item[SYNC_GAL_EMAILADDRESS] = $contact['email'] ? $contact['email'] : (string)$contact['email_private']; |
|
819 | 818 | //$item['nameid'] = $searchquery; |
820 | 819 | $item[SYNC_GAL_PHONE] = (string)$contact['tel_work']; |
821 | 820 | $item[SYNC_GAL_HOMEPHONE] = (string)$contact['tel_home']; |
822 | 821 | $item[SYNC_GAL_MOBILEPHONE] = (string)$contact['tel_cell']; |
823 | 822 | $item[SYNC_GAL_COMPANY] = (string)$contact['org_name']; |
824 | 823 | $item[SYNC_GAL_OFFICE] = $contact['room']; |
825 | - $item[SYNC_GAL_TITLE ] = $contact['title']; |
|
824 | + $item[SYNC_GAL_TITLE] = $contact['title']; |
|
826 | 825 | |
827 | 826 | //do not return users without email |
828 | 827 | if (!trim($item[SYNC_GAL_EMAILADDRESS])) continue; |
@@ -830,8 +829,8 @@ discard block |
||
830 | 829 | $items[] = $item; |
831 | 830 | } |
832 | 831 | } |
833 | - $items['searchtotal']=count($items); |
|
834 | - $items['range']=$searchquery['range']; |
|
832 | + $items['searchtotal'] = count($items); |
|
833 | + $items['range'] = $searchquery['range']; |
|
835 | 834 | return $items; |
836 | 835 | } |
837 | 836 | |
@@ -853,14 +852,14 @@ discard block |
||
853 | 852 | $addressbooks = $addressbook_bo->get_addressbooks(Acl::READ, null, $user); |
854 | 853 | if ($user > 0) |
855 | 854 | { |
856 | - unset($addressbooks[$user]); // personal addressbook is allways synced |
|
855 | + unset($addressbooks[$user]); // personal addressbook is allways synced |
|
857 | 856 | if (isset($addressbooks[$user.'p'])) |
858 | 857 | { |
859 | 858 | $addressbooks[self::PRIVATE_AB] = lang('Private'); |
860 | 859 | } |
861 | 860 | } |
862 | - unset($addressbooks[$user.'p']);// private addressbook uses ID self::PRIVATE_AB |
|
863 | - $fileas_options = array('0' => lang('use addressbooks "own sorting" attribute'))+$addressbook_bo->fileas_options(); |
|
861 | + unset($addressbooks[$user.'p']); // private addressbook uses ID self::PRIVATE_AB |
|
862 | + $fileas_options = array('0' => lang('use addressbooks "own sorting" attribute')) + $addressbook_bo->fileas_options(); |
|
864 | 863 | } |
865 | 864 | $addressbooks += array( |
866 | 865 | 'G' => lang('Primary Group'), |
@@ -139,7 +139,10 @@ discard block |
||
139 | 139 | { |
140 | 140 | Api\Translation::add_app('addressbook'); // we need the addressbook translations |
141 | 141 | |
142 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
142 | + if (!isset($this->addressbook)) |
|
143 | + { |
|
144 | + $this->addressbook = new Api\Contacts(); |
|
145 | + } |
|
143 | 146 | |
144 | 147 | $pref_abs = $GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-abs']; |
145 | 148 | if (!is_array($pref_abs)) |
@@ -282,7 +285,10 @@ discard block |
||
282 | 285 | function GetMessageList($id, $cutoffdate=NULL) |
283 | 286 | { |
284 | 287 | unset($cutoffdate); // not used, but required by function signature |
285 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
288 | + if (!isset($this->addressbook)) |
|
289 | + { |
|
290 | + $this->addressbook = new Api\Contacts(); |
|
291 | + } |
|
286 | 292 | |
287 | 293 | $type = $user = null; |
288 | 294 | $this->backend->splitID($id,$type,$user); |
@@ -333,7 +339,10 @@ discard block |
||
333 | 339 | */ |
334 | 340 | public function GetMessage($folderid, $id, $contentparameters) |
335 | 341 | { |
336 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
342 | + if (!isset($this->addressbook)) |
|
343 | + { |
|
344 | + $this->addressbook = new Api\Contacts(); |
|
345 | + } |
|
337 | 346 | |
338 | 347 | //$truncsize = Utils::GetTruncSize($contentparameters->GetTruncation()); |
339 | 348 | //$mimesupport = $contentparameters->GetMimeSupport(); |
@@ -377,7 +386,10 @@ discard block |
||
377 | 386 | { |
378 | 387 | $contact[$attr] = file_get_contents(Api\Link::vfs_path('addressbook', $contact['id'], Api\Contacts::FILES_PHOTO)); |
379 | 388 | } |
380 | - if (!empty($contact[$attr])) $message->$key = base64_encode($contact[$attr]); |
|
389 | + if (!empty($contact[$attr])) |
|
390 | + { |
|
391 | + $message->$key = base64_encode($contact[$attr]); |
|
392 | + } |
|
381 | 393 | break; |
382 | 394 | |
383 | 395 | case 'bday': // zpush seems to use a timestamp in utc (at least vcard backend does) |
@@ -416,7 +428,10 @@ discard block |
||
416 | 428 | } |
417 | 429 | // fall through |
418 | 430 | default: |
419 | - if (!empty($contact[$attr])) $message->$key = $contact[$attr]; |
|
431 | + if (!empty($contact[$attr])) |
|
432 | + { |
|
433 | + $message->$key = $contact[$attr]; |
|
434 | + } |
|
420 | 435 | } |
421 | 436 | } |
422 | 437 | //error_log(__METHOD__."(folder='$folderid',$id,...) returning ".array2string($message)); |
@@ -438,9 +453,15 @@ discard block |
||
438 | 453 | public function StatMessage($folderid, $contact) |
439 | 454 | { |
440 | 455 | unset($folderid); // not used (contact_id is global), but required by function signaure |
441 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
456 | + if (!isset($this->addressbook)) |
|
457 | + { |
|
458 | + $this->addressbook = new Api\Contacts(); |
|
459 | + } |
|
442 | 460 | |
443 | - if (!is_array($contact)) $contact = $this->addressbook->read($contact); |
|
461 | + if (!is_array($contact)) |
|
462 | + { |
|
463 | + $contact = $this->addressbook->read($contact); |
|
464 | + } |
|
444 | 465 | |
445 | 466 | if (!$contact) |
446 | 467 | { |
@@ -512,7 +533,10 @@ discard block |
||
512 | 533 | public function ChangeMessage($folderid, $id, $message, $contentParameters) |
513 | 534 | { |
514 | 535 | unset($contentParameters); // not used, but required by function signature |
515 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
536 | + if (!isset($this->addressbook)) |
|
537 | + { |
|
538 | + $this->addressbook = new Api\Contacts(); |
|
539 | + } |
|
516 | 540 | |
517 | 541 | $type = $account = null; |
518 | 542 | $this->backend->splitID($folderid, $type, $account); |
@@ -524,14 +548,20 @@ discard block |
||
524 | 548 | |
525 | 549 | } |
526 | 550 | // error_log(__METHOD__. " Id " .$id. " Account ". $account . " FolderID " . $folderid); |
527 | - if ($type != 'addressbook') // || !($contact = $this->addressbook->read($id))) |
|
551 | + if ($type != 'addressbook') |
|
552 | + { |
|
553 | + // || !($contact = $this->addressbook->read($id))) |
|
528 | 554 | { |
529 | 555 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." Folder wrong or contact not existing"); |
556 | + } |
|
530 | 557 | return false; |
531 | 558 | } |
532 | - if ($account == 0) // as a precausion, we currently do NOT allow to change Api\Accounts |
|
559 | + if ($account == 0) |
|
560 | + { |
|
561 | + // as a precausion, we currently do NOT allow to change Api\Accounts |
|
533 | 562 | { |
534 | 563 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__." Changing of Api\Accounts denied!"); |
564 | + } |
|
535 | 565 | return false; //no changing of Api\Accounts |
536 | 566 | } |
537 | 567 | $contact = array(); |
@@ -594,7 +624,10 @@ discard block |
||
594 | 624 | } |
595 | 625 | break; |
596 | 626 | case 'title': // as ol jobtitle mapping changed in egw from role to title, do NOT overwrite title with value of role |
597 | - if ($id && $message->$key == $contact['role']) break; |
|
627 | + if ($id && $message->$key == $contact['role']) |
|
628 | + { |
|
629 | + break; |
|
630 | + } |
|
598 | 631 | // fall throught |
599 | 632 | default: |
600 | 633 | $contact[$attr] = $message->$key; |
@@ -603,7 +636,10 @@ discard block |
||
603 | 636 | } |
604 | 637 | // for all-in-one addressbook, account is meaningless and wrong! |
605 | 638 | // Api\Contacts::save() keeps the owner or sets an appropriate one if none given |
606 | - if (!isset($contact['private'])) $contact['private'] = (int)$is_private; |
|
639 | + if (!isset($contact['private'])) |
|
640 | + { |
|
641 | + $contact['private'] = (int)$is_private; |
|
642 | + } |
|
607 | 643 | if (!$GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one']) |
608 | 644 | { |
609 | 645 | $contact['owner'] = $account; |
@@ -616,7 +652,10 @@ discard block |
||
616 | 652 | { |
617 | 653 | $contact['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
618 | 654 | } |
619 | - if (!empty($id)) $contact['id'] = $id; |
|
655 | + if (!empty($id)) |
|
656 | + { |
|
657 | + $contact['id'] = $id; |
|
658 | + } |
|
620 | 659 | $this->addressbook->fixup_contact($contact); |
621 | 660 | $newid = $this->addressbook->save($contact); |
622 | 661 | //error_log(__METHOD__."($folderid,$id) contact=".array2string($contact)." returning ".array2string($newid)); |
@@ -672,7 +711,10 @@ discard block |
||
672 | 711 | public function DeleteMessage($folderid, $id, $contentParameters) |
673 | 712 | { |
674 | 713 | unset($contentParameters); // not used, but required by function signature |
675 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
714 | + if (!isset($this->addressbook)) |
|
715 | + { |
|
716 | + $this->addressbook = new Api\Contacts(); |
|
717 | + } |
|
676 | 718 | |
677 | 719 | $ret = $this->addressbook->delete($id); |
678 | 720 | ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', $id) delete($id) returned ".array2string($ret)); |
@@ -732,9 +774,15 @@ discard block |
||
732 | 774 | $type = $owner = null; |
733 | 775 | $this->backend->splitID($folderid, $type, $owner); |
734 | 776 | |
735 | - if ($type != 'addressbook') return false; |
|
777 | + if ($type != 'addressbook') |
|
778 | + { |
|
779 | + return false; |
|
780 | + } |
|
736 | 781 | |
737 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
782 | + if (!isset($this->addressbook)) |
|
783 | + { |
|
784 | + $this->addressbook = new Api\Contacts(); |
|
785 | + } |
|
738 | 786 | |
739 | 787 | // handle all-in-one addressbook |
740 | 788 | if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one'] && |
@@ -790,7 +838,10 @@ discard block |
||
790 | 838 | */ |
791 | 839 | function getSearchResultsGAL($searchquery) |
792 | 840 | { |
793 | - if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts(); |
|
841 | + if (!isset($this->addressbook)) |
|
842 | + { |
|
843 | + $this->addressbook = new Api\Contacts(); |
|
844 | + } |
|
794 | 845 | //error_log(__METHOD__.'('.array2string($searchquery).')'); |
795 | 846 | |
796 | 847 | // only return items in given range, eg. "0-50" |
@@ -814,7 +865,10 @@ discard block |
||
814 | 865 | $item[SYNC_GAL_LASTNAME] = $contact['n_family']?$contact['n_family']:$contact['org_name']; |
815 | 866 | $item[SYNC_GAL_FIRSTNAME] = $contact['n_given']; |
816 | 867 | $item[SYNC_GAL_DISPLAYNAME] = $contact['n_fn']; |
817 | - if (!trim($item[SYNC_GAL_DISPLAYNAME])) $item[SYNC_GAL_DISPLAYNAME] = $contact['n_family']?$contact['n_family']:$contact['org_name']; |
|
868 | + if (!trim($item[SYNC_GAL_DISPLAYNAME])) |
|
869 | + { |
|
870 | + $item[SYNC_GAL_DISPLAYNAME] = $contact['n_family']?$contact['n_family']:$contact['org_name']; |
|
871 | + } |
|
818 | 872 | $item[SYNC_GAL_EMAILADDRESS] = $contact['email'] ? $contact['email'] : (string)$contact['email_private'] ; |
819 | 873 | //$item['nameid'] = $searchquery; |
820 | 874 | $item[SYNC_GAL_PHONE] = (string)$contact['tel_work']; |
@@ -825,7 +879,10 @@ discard block |
||
825 | 879 | $item[SYNC_GAL_TITLE ] = $contact['title']; |
826 | 880 | |
827 | 881 | //do not return users without email |
828 | - if (!trim($item[SYNC_GAL_EMAILADDRESS])) continue; |
|
882 | + if (!trim($item[SYNC_GAL_EMAILADDRESS])) |
|
883 | + { |
|
884 | + continue; |
|
885 | + } |
|
829 | 886 | |
830 | 887 | $items[] = $item; |
831 | 888 | } |
@@ -1885,12 +1885,12 @@ discard block |
||
1885 | 1885 | } |
1886 | 1886 | |
1887 | 1887 | /** |
1888 | - * Edit a contact |
|
1889 | - * |
|
1890 | - * @param array $content=null submitted content |
|
1891 | - * @param int $_GET['contact_id'] contact_id mainly for popup use |
|
1892 | - * @param bool $_GET['makecp'] true if you want to copy the contact given by $_GET['contact_id'] |
|
1893 | - */ |
|
1888 | + * Edit a contact |
|
1889 | + * |
|
1890 | + * @param array $content=null submitted content |
|
1891 | + * @param int $_GET['contact_id'] contact_id mainly for popup use |
|
1892 | + * @param bool $_GET['makecp'] true if you want to copy the contact given by $_GET['contact_id'] |
|
1893 | + */ |
|
1894 | 1894 | function edit($content=null) |
1895 | 1895 | { |
1896 | 1896 | if (is_array($content)) |
@@ -3069,8 +3069,8 @@ discard block |
||
3069 | 3069 | } |
3070 | 3070 | |
3071 | 3071 | /** |
3072 | - * Set up history log widget |
|
3073 | - */ |
|
3072 | + * Set up history log widget |
|
3073 | + */ |
|
3074 | 3074 | protected function setup_history(&$content, &$sel_options) |
3075 | 3075 | { |
3076 | 3076 | if ($this->contact_repository == 'ldap' || !$content['id'] || |
@@ -2594,7 +2594,7 @@ |
||
2594 | 2594 | case 'infolog': |
2595 | 2595 | case 'tracker': |
2596 | 2596 | default: |
2597 | - Api\Json\Response::get()->apply('app.addressbook.view_set_list',Array(Array('action'=>'addressbook', 'action_id' => $contact_id))); |
|
2597 | + Api\Json\Response::get()->apply('app.addressbook.view_set_list',array(array('action'=>'addressbook', 'action_id' => $contact_id))); |
|
2598 | 2598 | break; |
2599 | 2599 | } |
2600 | 2600 |
@@ -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,18 +397,18 @@ 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($GLOBALS['egw_info']['user']['apps']['infolog']) |
|
405 | + if ($GLOBALS['egw_info']['user']['apps']['infolog']) |
|
406 | 406 | { |
407 | 407 | array_splice($crm_apps, 1, 0, 'infolog-organisation'); |
408 | 408 | } |
409 | - if($crm_count > 1) |
|
409 | + if ($crm_count > 1) |
|
410 | 410 | { |
411 | - foreach($crm_apps as $app) |
|
411 | + foreach ($crm_apps as $app) |
|
412 | 412 | { |
413 | 413 | $actions['view']['children']["view-$app"] = array( |
414 | 414 | 'caption' => $app, |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | 'caption' => 'View', |
424 | 424 | 'default' => true, |
425 | 425 | 'allowOnMultiple' => false, |
426 | - 'group' => $group=1, |
|
426 | + 'group' => $group = 1, |
|
427 | 427 | 'enableClass' => 'contact_organisation', |
428 | 428 | 'hideOnDisabled' => true |
429 | 429 | ), |
@@ -444,29 +444,29 @@ discard block |
||
444 | 444 | 'caption' => 'View', |
445 | 445 | 'default' => true, |
446 | 446 | 'allowOnMultiple' => false, |
447 | - 'group' => $group=1, |
|
447 | + 'group' => $group = 1, |
|
448 | 448 | 'enableClass' => 'contact_duplicate', |
449 | 449 | 'hideOnDisabled' => true |
450 | 450 | ) |
451 | 451 | ); |
452 | 452 | |
453 | - ++$group; // other AB related stuff group: lists, AB's, categories |
|
453 | + ++$group; // other AB related stuff group: lists, AB's, categories |
|
454 | 454 | // categories submenu |
455 | 455 | $actions['cat'] = array( |
456 | 456 | 'caption' => 'Categories', |
457 | 457 | 'group' => $group, |
458 | 458 | 'children' => array( |
459 | 459 | 'cat_add' => Etemplate\Widget\Nextmatch::category_action( |
460 | - 'addressbook',$group,'Add category', 'cat_add_', |
|
461 | - true, 0,Etemplate\Widget\Nextmatch::DEFAULT_MAX_MENU_LENGTH,false |
|
462 | - )+array( |
|
460 | + 'addressbook', $group, 'Add category', 'cat_add_', |
|
461 | + true, 0, Etemplate\Widget\Nextmatch::DEFAULT_MAX_MENU_LENGTH, false |
|
462 | + ) + array( |
|
463 | 463 | 'icon' => 'foldertree_nolines_plus', |
464 | 464 | 'disableClass' => 'rowNoEdit', |
465 | 465 | ), |
466 | 466 | 'cat_del' => Etemplate\Widget\Nextmatch::category_action( |
467 | - 'addressbook',$group,'Delete category', 'cat_del_', |
|
468 | - true, 0,Etemplate\Widget\Nextmatch::DEFAULT_MAX_MENU_LENGTH,false |
|
469 | - )+array( |
|
467 | + 'addressbook', $group, 'Delete category', 'cat_del_', |
|
468 | + true, 0, Etemplate\Widget\Nextmatch::DEFAULT_MAX_MENU_LENGTH, false |
|
469 | + ) + array( |
|
470 | 470 | 'icon' => 'foldertree_nolines_minus', |
471 | 471 | 'disableClass' => 'rowNoEdit', |
472 | 472 | ), |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | 'children' => $add_lists, |
494 | 494 | 'prefix' => 'to_list_', |
495 | 495 | 'icon' => 'foldertree_nolines_plus', |
496 | - 'enabled' => ($add_lists?true:false), // if there are editable lists, allow to add a contact to one of them, |
|
496 | + 'enabled' => ($add_lists ?true:false), // if there are editable lists, allow to add a contact to one of them, |
|
497 | 497 | //'disableClass' => 'rowNoEdit', // wether you are allowed to edit the contact or not, as you alter a list, not the contact |
498 | 498 | ), |
499 | 499 | 'remove_from_list' => array( |
@@ -502,14 +502,14 @@ discard block |
||
502 | 502 | 'icon' => 'foldertree_nolines_minus', |
503 | 503 | 'enabled' => 'javaScript:app.addressbook.nm_compare_field', |
504 | 504 | 'fieldId' => 'exec[nm][filter2]', |
505 | - 'fieldValue' => '!', // enable if list != '' |
|
505 | + 'fieldValue' => '!', // enable if list != '' |
|
506 | 506 | ), |
507 | 507 | 'rename_list' => array( |
508 | 508 | 'caption' => 'Rename selected distribution list', |
509 | 509 | 'icon' => 'edit', |
510 | 510 | 'enabled' => 'javaScript:app.addressbook.nm_compare_field', |
511 | 511 | 'fieldId' => 'exec[nm][filter2]', |
512 | - 'fieldValue' => '!', // enable if list != '' |
|
512 | + 'fieldValue' => '!', // enable if list != '' |
|
513 | 513 | 'onExecute' => 'javaScript:app.addressbook.rename_list' |
514 | 514 | ), |
515 | 515 | 'delete_list' => array( |
@@ -518,10 +518,10 @@ discard block |
||
518 | 518 | 'icon' => 'delete', |
519 | 519 | 'enabled' => 'javaScript:app.addressbook.nm_compare_field', |
520 | 520 | 'fieldId' => 'exec[nm][filter2]', |
521 | - 'fieldValue' => '!', // enable if list != '' |
|
521 | + 'fieldValue' => '!', // enable if list != '' |
|
522 | 522 | ), |
523 | 523 | ); |
524 | - if(is_subclass_of('etemplate', 'etemplate_new')) |
|
524 | + if (is_subclass_of('etemplate', 'etemplate_new')) |
|
525 | 525 | { |
526 | 526 | $actions['lists']['children']['remove_from_list']['fieldId'] = 'filter2'; |
527 | 527 | $actions['lists']['children']['rename_list']['fieldId'] = 'filter2'; |
@@ -531,18 +531,18 @@ discard block |
||
531 | 531 | // move to AB |
532 | 532 | if (($move2addressbooks = $this->get_addressbooks(Acl::ADD))) // do we have addressbooks, we should |
533 | 533 | { |
534 | - unset($move2addressbooks[0]); // do not offer action to move contact to an account, as we dont support that currrently |
|
535 | - foreach($move2addressbooks as $owner => $label) |
|
534 | + unset($move2addressbooks[0]); // do not offer action to move contact to an account, as we dont support that currrently |
|
535 | + foreach ($move2addressbooks as $owner => $label) |
|
536 | 536 | { |
537 | 537 | $icon = $type_label = null; |
538 | - $this->type_icon((int)$owner, substr($owner,-1) == 'p', 'n', $icon, $type_label); |
|
538 | + $this->type_icon((int)$owner, substr($owner, -1) == 'p', 'n', $icon, $type_label); |
|
539 | 539 | $move2addressbooks[$owner] = array( |
540 | 540 | 'icon' => $icon, |
541 | 541 | 'caption' => $label, |
542 | 542 | ); |
543 | 543 | } |
544 | 544 | // copy checkbox |
545 | - $move2addressbooks= array( |
|
545 | + $move2addressbooks = array( |
|
546 | 546 | 'copy' =>array( |
547 | 547 | 'id' => 'move_to_copy', |
548 | 548 | 'caption' => 'Copy instead of move', |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | 'hideOnDisabled' => true |
576 | 576 | ); |
577 | 577 | |
578 | - ++$group; // integration with other apps: infolog, calendar, filemanager, messenger |
|
578 | + ++$group; // integration with other apps: infolog, calendar, filemanager, messenger |
|
579 | 579 | |
580 | 580 | // Integrate Messenger app actions for adding new buddy into roster list |
581 | 581 | if ($GLOBALS['egw_info']['user']['apps']['messenger']) |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | 'icon' => 'new', |
617 | 617 | 'url' => 'menuaction=infolog.infolog_ui.edit&type=task&action=addressbook&action_id=$id', |
618 | 618 | 'popup' => Link::get_registry('infolog', 'add_popup'), |
619 | - 'onExecute' => 'javaScript:app.addressbook.add_task', // call server for org-view only |
|
619 | + 'onExecute' => 'javaScript:app.addressbook.add_task', // call server for org-view only |
|
620 | 620 | ), |
621 | 621 | ), |
622 | 622 | 'hideOnMobile' => true |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | 'caption' => 'Show', |
635 | 635 | 'icon' => 'view', |
636 | 636 | 'onExecute' => 'javaScript:app.addressbook.view_calendar', |
637 | - 'targetapp' => 'calendar', // open in calendar tab, |
|
637 | + 'targetapp' => 'calendar', // open in calendar tab, |
|
638 | 638 | 'hideOnDisabled' => true, |
639 | 639 | ), |
640 | 640 | 'calendar_add' => array( |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | 'icon' => 'map', |
715 | 715 | 'group' => ++$group, |
716 | 716 | 'enableClass' => 'contact_contact', |
717 | - 'children' => array ( |
|
717 | + 'children' => array( |
|
718 | 718 | 'private' => array( |
719 | 719 | 'caption' => 'Private Address', |
720 | 720 | 'enabled' => 'javaScript:app.addressbook.geoLocation_enabled', |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | |
734 | 734 | // check if user is an admin or the export is not generally turned off (contact_export_limit is non-numerical, eg. no) |
735 | 735 | $exception = Api\Storage\Merge::is_export_limit_excepted(); |
736 | - if ((isset($GLOBALS['egw_info']['user']['apps']['admin']) || $exception) || !$this->config['contact_export_limit'] || (int)$this->config['contact_export_limit']) |
|
736 | + if ((isset($GLOBALS['egw_info']['user']['apps']['admin']) || $exception) || !$this->config['contact_export_limit'] || (int)$this->config['contact_export_limit']) |
|
737 | 737 | { |
738 | 738 | $actions['export'] = array( |
739 | 739 | 'caption' => 'Export', |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | ), |
750 | 750 | 'vcard' => array( |
751 | 751 | 'caption' => 'Export as VCard', |
752 | - 'postSubmit' => true, // download needs post submit (not Ajax) to work |
|
752 | + 'postSubmit' => true, // download needs post submit (not Ajax) to work |
|
753 | 753 | 'icon' => Vfs::mime_icon('text/vcard'), |
754 | 754 | ), |
755 | 755 | ), |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | $this->prefs['document_dir'], $group, 'Insert in document', 'document_', |
762 | 762 | $this->prefs['default_document'], $this->config['contact_export_limit'] |
763 | 763 | ); |
764 | - if ($GLOBALS['egw_info']['user']['apps']['felamimail']||$GLOBALS['egw_info']['user']['apps']['mail']) |
|
764 | + if ($GLOBALS['egw_info']['user']['apps']['felamimail'] || $GLOBALS['egw_info']['user']['apps']['mail']) |
|
765 | 765 | { |
766 | 766 | $actions['mail'] = array( |
767 | 767 | 'caption' => lang('Mail VCard'), |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | 'disableClass' => 'rowNoDelete', |
786 | 786 | ); |
787 | 787 | } |
788 | - if ($this->grants[0] & Acl::DELETE) |
|
788 | + if ($this->grants[0]&Acl::DELETE) |
|
789 | 789 | { |
790 | 790 | $actions['delete_account'] = array( |
791 | 791 | 'caption' => 'Delete', |
@@ -798,7 +798,7 @@ discard block |
||
798 | 798 | ); |
799 | 799 | $actions['delete']['hideOnDisabled'] = true; |
800 | 800 | } |
801 | - if($tid_filter == 'D') |
|
801 | + if ($tid_filter == 'D') |
|
802 | 802 | { |
803 | 803 | $actions['undelete'] = array( |
804 | 804 | 'caption' => 'Un-delete', |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | } |
810 | 810 | if (isset($actions['export']['children']['csv']) && |
811 | 811 | (!isset($GLOBALS['egw_info']['user']['apps']['importexport']) || |
812 | - !importexport_helper_functions::has_definitions('addressbook','export'))) |
|
812 | + !importexport_helper_functions::has_definitions('addressbook', 'export'))) |
|
813 | 813 | { |
814 | 814 | unset($actions['export']['children']['csv']); |
815 | 815 | } |
@@ -842,13 +842,13 @@ discard block |
||
842 | 842 | protected function _get_grouped_name($view_id) |
843 | 843 | { |
844 | 844 | $group_name = array(); |
845 | - if (strpos($view_id,'*AND*')!== false) $view_id = str_replace('*AND*','&',$view_id); |
|
846 | - foreach(explode('|||',$view_id) as $part) |
|
845 | + if (strpos($view_id, '*AND*') !== false) $view_id = str_replace('*AND*', '&', $view_id); |
|
846 | + foreach (explode('|||', $view_id) as $part) |
|
847 | 847 | { |
848 | - list(,$name) = explode(':',$part,2); |
|
848 | + list(,$name) = explode(':', $part, 2); |
|
849 | 849 | if ($name) $group_name[] = $name; |
850 | 850 | } |
851 | - $name = implode(': ',$group_name); |
|
851 | + $name = implode(': ', $group_name); |
|
852 | 852 | return $name ? array($view_id => $name) : array(); |
853 | 853 | } |
854 | 854 | |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | unset($query['col_filter']['org_name']); |
863 | 863 | unset($query['col_filter']['org_unit']); |
864 | 864 | unset($query['col_filter']['adr_one_locality']); |
865 | - foreach(array_keys(static::$duplicate_fields) as $field) |
|
865 | + foreach (array_keys(static::$duplicate_fields) as $field) |
|
866 | 866 | { |
867 | 867 | unset($query['col_filter'][$field]); |
868 | 868 | } |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | // Query doesn't like empties |
881 | 881 | unset($query['col_filter']['parent_id']); |
882 | 882 | |
883 | - if($query['actions'] && $query['actions']['open']) |
|
883 | + if ($query['actions'] && $query['actions']['open']) |
|
884 | 884 | { |
885 | 885 | // Just switched from contact view, update actions |
886 | 886 | $query['actions'] = $this->get_actions($query['col_filter']['tid']); |
@@ -908,10 +908,10 @@ discard block |
||
908 | 908 | } |
909 | 909 | $query['org_view'] = $query['grouped_view']; |
910 | 910 | // switch the distribution list selection off for ldap |
911 | - if($this->contact_repository != 'sql') |
|
911 | + if ($this->contact_repository != 'sql') |
|
912 | 912 | { |
913 | 913 | $query['no_filter2'] = true; |
914 | - unset($query['col_filter']['list']); // does not work here |
|
914 | + unset($query['col_filter']['list']); // does not work here |
|
915 | 915 | } |
916 | 916 | else |
917 | 917 | { |
@@ -919,8 +919,8 @@ discard block |
||
919 | 919 | } |
920 | 920 | break; |
921 | 921 | case 'addressbook.index.duplicate_rows': |
922 | - $query['no_filter2'] = true; // switch the distribution list selection off |
|
923 | - unset($query['col_filter']['list']); // does not work for duplicates |
|
922 | + $query['no_filter2'] = true; // switch the distribution list selection off |
|
923 | + unset($query['col_filter']['list']); // does not work for duplicates |
|
924 | 924 | $rows = parent::duplicates($query); |
925 | 925 | break; |
926 | 926 | } |
@@ -947,19 +947,19 @@ discard block |
||
947 | 947 | { |
948 | 948 | $org_contacts = array(); |
949 | 949 | $query = !$_query ? Api\Cache::getSession('addressbook', 'index') : $_query; |
950 | - $query['num_rows'] = -1; // all |
|
951 | - if(!is_array($query['col_filter'])) $query['col_filter'] = array(); |
|
950 | + $query['num_rows'] = -1; // all |
|
951 | + if (!is_array($query['col_filter'])) $query['col_filter'] = array(); |
|
952 | 952 | |
953 | - if(!is_array($org)) $org = array($org); |
|
954 | - foreach($org as $org_name) |
|
953 | + if (!is_array($org)) $org = array($org); |
|
954 | + foreach ($org as $org_name) |
|
955 | 955 | { |
956 | 956 | $query['grouped_view'] = $org_name; |
957 | 957 | $checked = array(); |
958 | 958 | $readonlys = null; |
959 | - $this->get_rows($query,$checked,$readonlys,true); // true = only return the id's |
|
960 | - if($checked[0]) |
|
959 | + $this->get_rows($query, $checked, $readonlys, true); // true = only return the id's |
|
960 | + if ($checked[0]) |
|
961 | 961 | { |
962 | - $org_contacts = array_merge($org_contacts,$checked); |
|
962 | + $org_contacts = array_merge($org_contacts, $checked); |
|
963 | 963 | } |
964 | 964 | } |
965 | 965 | Api\Json\Response::get()->data(array_unique($org_contacts)); |
@@ -973,33 +973,33 @@ discard block |
||
973 | 973 | function infolog_org_view($org) |
974 | 974 | { |
975 | 975 | $query = Api\Cache::getSession('addressbook', 'index'); |
976 | - $query['num_rows'] = -1; // all |
|
976 | + $query['num_rows'] = -1; // all |
|
977 | 977 | $query['grouped_view'] = $org; |
978 | 978 | $query['searchletter'] = ''; |
979 | 979 | $checked = $readonlys = null; |
980 | - $this->get_rows($query,$checked,$readonlys,true); // true = only return the id's |
|
980 | + $this->get_rows($query, $checked, $readonlys, true); // true = only return the id's |
|
981 | 981 | |
982 | 982 | if (count($checked) > 1) // use a nicely formatted org-name as title in infolog |
983 | 983 | { |
984 | 984 | $parts = array(); |
985 | - if (strpos($org,'*AND*')!== false) $org = str_replace('*AND*','&',$org); |
|
986 | - foreach(explode('|||',$org) as $part) |
|
985 | + if (strpos($org, '*AND*') !== false) $org = str_replace('*AND*', '&', $org); |
|
986 | + foreach (explode('|||', $org) as $part) |
|
987 | 987 | { |
988 | - list(,$part) = explode(':',$part,2); |
|
988 | + list(,$part) = explode(':', $part, 2); |
|
989 | 989 | if ($part) $parts[] = $part; |
990 | 990 | } |
991 | - $org = implode(', ',$parts); |
|
991 | + $org = implode(', ', $parts); |
|
992 | 992 | } |
993 | 993 | else |
994 | 994 | { |
995 | - $org = ''; // use infolog default of link-title |
|
995 | + $org = ''; // use infolog default of link-title |
|
996 | 996 | } |
997 | - Egw::redirect_link('/index.php',array( |
|
997 | + Egw::redirect_link('/index.php', array( |
|
998 | 998 | 'menuaction' => 'infolog.infolog_ui.index', |
999 | 999 | 'action' => 'addressbook', |
1000 | - 'action_id' => implode(',',$checked), |
|
1000 | + 'action_id' => implode(',', $checked), |
|
1001 | 1001 | 'action_title' => $org, |
1002 | - ),'infolog'); |
|
1002 | + ), 'infolog'); |
|
1003 | 1003 | } |
1004 | 1004 | |
1005 | 1005 | /** |
@@ -1024,31 +1024,31 @@ discard block |
||
1024 | 1024 | $owner = $this->default_addressbook; |
1025 | 1025 | } |
1026 | 1026 | // Check for valid list & permissions |
1027 | - if(!(int)$list_id && !$this->check_list(null,EGW_ACL_ADD|EGW_ACL_EDIT,$owner)) |
|
1027 | + if (!(int)$list_id && !$this->check_list(null, EGW_ACL_ADD|EGW_ACL_EDIT, $owner)) |
|
1028 | 1028 | { |
1029 | - Api\Json\Response::get()->apply('egw.message', array( lang('List creation failed, no rights!'),'error')); |
|
1029 | + Api\Json\Response::get()->apply('egw.message', array(lang('List creation failed, no rights!'), 'error')); |
|
1030 | 1030 | return; |
1031 | 1031 | } |
1032 | 1032 | if ((int)$list_id && !$this->check_list((int)$list_id, Acl::EDIT, $owner)) |
1033 | 1033 | { |
1034 | - Api\Json\Response::get()->apply('egw.message', array( lang('Insufficent rights to edit this list!'),'error')); |
|
1034 | + Api\Json\Response::get()->apply('egw.message', array(lang('Insufficent rights to edit this list!'), 'error')); |
|
1035 | 1035 | return; |
1036 | 1036 | } |
1037 | 1037 | |
1038 | 1038 | $list = array('list_owner' => $owner); |
1039 | 1039 | |
1040 | 1040 | // Rename |
1041 | - if($list_id) |
|
1041 | + if ($list_id) |
|
1042 | 1042 | { |
1043 | 1043 | $list = $this->read_list((int)$list_id); |
1044 | 1044 | } |
1045 | 1045 | $list['list_name'] = $new_name; |
1046 | 1046 | |
1047 | - $new_id = $this->add_list(array('list_id' => (int)$list_id), $list['list_owner'],array(),$list); |
|
1047 | + $new_id = $this->add_list(array('list_id' => (int)$list_id), $list['list_owner'], array(), $list); |
|
1048 | 1048 | |
1049 | - if($contacts) |
|
1049 | + if ($contacts) |
|
1050 | 1050 | { |
1051 | - $this->add2list($contacts,$new_id); |
|
1051 | + $this->add2list($contacts, $new_id); |
|
1052 | 1052 | } |
1053 | 1053 | Api\Json\Response::get()->apply('egw.message', array( |
1054 | 1054 | $new_id == $list_id ? lang('Distribution list renamed') : lang('List created'), |
@@ -1063,7 +1063,7 @@ discard block |
||
1063 | 1063 | * |
1064 | 1064 | * @param string $account_id |
1065 | 1065 | */ |
1066 | - function ajax_get_contact ($account_id) |
|
1066 | + function ajax_get_contact($account_id) |
|
1067 | 1067 | { |
1068 | 1068 | $bo = new Api\Contacts(); |
1069 | 1069 | $contact = $bo->read('account:'.$account_id); |
@@ -1080,7 +1080,7 @@ discard block |
||
1080 | 1080 | { |
1081 | 1081 | $query = Api\Cache::getSession('addressbook', 'index'); |
1082 | 1082 | unset($query['advanced_search']); |
1083 | - Api\Cache::setSession('addressbook','index',$query); |
|
1083 | + Api\Cache::setSession('addressbook', 'index', $query); |
|
1084 | 1084 | Api\Cache::setSession('addressbook', 'advanced_search', false); |
1085 | 1085 | } |
1086 | 1086 | |
@@ -1096,60 +1096,60 @@ discard block |
||
1096 | 1096 | * @param string/array $session_name 'index' or array with session-data depending if we are in the main list or the popup |
1097 | 1097 | * @return boolean true if all actions succeded, false otherwise |
1098 | 1098 | */ |
1099 | - function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg, $checkboxes = NULL) |
|
1099 | + function action($action, $checked, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg, $checkboxes = NULL) |
|
1100 | 1100 | { |
1101 | 1101 | //echo "<p>uicontacts::action('$action',".print_r($checked,true).','.(int)$use_all.",...)</p>\n"; |
1102 | 1102 | $success = $failed = 0; |
1103 | - if ($use_all || in_array($action,array('remove_from_list','delete_list'))) |
|
1103 | + if ($use_all || in_array($action, array('remove_from_list', 'delete_list'))) |
|
1104 | 1104 | { |
1105 | 1105 | // get the whole selection |
1106 | 1106 | $query = is_array($session_name) ? $session_name : Api\Cache::getSession('addressbook', $session_name); |
1107 | 1107 | |
1108 | 1108 | if ($use_all) |
1109 | 1109 | { |
1110 | - @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
1111 | - $query['num_rows'] = -1; // all |
|
1110 | + @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
1111 | + $query['num_rows'] = -1; // all |
|
1112 | 1112 | $readonlys = null; |
1113 | - $this->get_rows($query,$checked,$readonlys,true); // true = only return the id's |
|
1113 | + $this->get_rows($query, $checked, $readonlys, true); // true = only return the id's |
|
1114 | 1114 | } |
1115 | 1115 | } |
1116 | 1116 | // replace org_name:* id's with all id's of that org |
1117 | - $grouped_contacts = $this->find_grouped_ids($action, $checked, $use_all, $success,$failed,$action_msg,$session_name, $msg); |
|
1118 | - if ($grouped_contacts) $checked = array_unique($checked ? array_merge($checked,$grouped_contacts) : $grouped_contacts); |
|
1117 | + $grouped_contacts = $this->find_grouped_ids($action, $checked, $use_all, $success, $failed, $action_msg, $session_name, $msg); |
|
1118 | + if ($grouped_contacts) $checked = array_unique($checked ? array_merge($checked, $grouped_contacts) : $grouped_contacts); |
|
1119 | 1119 | //_debug_array($checked); exit; |
1120 | 1120 | |
1121 | - if (substr($action,0,8) == 'move_to_') |
|
1121 | + if (substr($action, 0, 8) == 'move_to_') |
|
1122 | 1122 | { |
1123 | - $action = (int)substr($action,8).(substr($action,-1) == 'p' ? 'p' : ''); |
|
1123 | + $action = (int)substr($action, 8).(substr($action, -1) == 'p' ? 'p' : ''); |
|
1124 | 1124 | } |
1125 | - elseif (substr($action,0,8) == 'to_list_') |
|
1125 | + elseif (substr($action, 0, 8) == 'to_list_') |
|
1126 | 1126 | { |
1127 | - $to_list = (int)substr($action,8); |
|
1127 | + $to_list = (int)substr($action, 8); |
|
1128 | 1128 | $action = 'to_list'; |
1129 | 1129 | } |
1130 | - elseif (substr($action,0,9) == 'document_') |
|
1130 | + elseif (substr($action, 0, 9) == 'document_') |
|
1131 | 1131 | { |
1132 | - $document = substr($action,9); |
|
1132 | + $document = substr($action, 9); |
|
1133 | 1133 | $action = 'document'; |
1134 | 1134 | } |
1135 | - elseif(substr($action,0,4) == 'cat_') // cat_add_123 or cat_del_456 |
|
1135 | + elseif (substr($action, 0, 4) == 'cat_') // cat_add_123 or cat_del_456 |
|
1136 | 1136 | { |
1137 | 1137 | $cat_id = (int)substr($action, 8); |
1138 | - $action = substr($action,0,7); |
|
1138 | + $action = substr($action, 0, 7); |
|
1139 | 1139 | } |
1140 | 1140 | // Security: stop non-admins to export more then the configured number of contacts |
1141 | - if (in_array($action,array('csv','vcard')) && $this->config['contact_export_limit'] && !Api\Storage\Merge::is_export_limit_excepted() && |
|
1141 | + if (in_array($action, array('csv', 'vcard')) && $this->config['contact_export_limit'] && !Api\Storage\Merge::is_export_limit_excepted() && |
|
1142 | 1142 | (!is_numeric($this->config['contact_export_limit']) || count($checked) > $this->config['contact_export_limit'])) |
1143 | 1143 | { |
1144 | 1144 | $action_msg = lang('exported'); |
1145 | 1145 | $failed = count($checked); |
1146 | 1146 | return false; |
1147 | 1147 | } |
1148 | - switch($action) |
|
1148 | + switch ($action) |
|
1149 | 1149 | { |
1150 | 1150 | case 'vcard': |
1151 | 1151 | $action_msg = lang('exported'); |
1152 | - $vcard = new addressbook_vcal('addressbook','text/vcard'); |
|
1152 | + $vcard = new addressbook_vcal('addressbook', 'text/vcard'); |
|
1153 | 1153 | $vcard->export($checked); |
1154 | 1154 | // does not return! |
1155 | 1155 | $Ok = false; |
@@ -1157,10 +1157,10 @@ discard block |
||
1157 | 1157 | |
1158 | 1158 | case 'merge': |
1159 | 1159 | $error_msg = null; |
1160 | - $success = $this->merge($checked,$error_msg); |
|
1160 | + $success = $this->merge($checked, $error_msg); |
|
1161 | 1161 | $failed = count($checked) - (int)$success; |
1162 | 1162 | $action_msg = lang('merged'); |
1163 | - $checked = array(); // to not start the single actions |
|
1163 | + $checked = array(); // to not start the single actions |
|
1164 | 1164 | break; |
1165 | 1165 | |
1166 | 1166 | case 'delete_list': |
@@ -1168,7 +1168,7 @@ discard block |
||
1168 | 1168 | { |
1169 | 1169 | $msg = lang('You need to select a distribution list'); |
1170 | 1170 | } |
1171 | - elseif($this->delete_list($query['filter2']) === false) |
|
1171 | + elseif ($this->delete_list($query['filter2']) === false) |
|
1172 | 1172 | { |
1173 | 1173 | $msg = lang('Insufficent rights to delete this list!'); |
1174 | 1174 | } |
@@ -1188,49 +1188,49 @@ discard block |
||
1188 | 1188 | return false; |
1189 | 1189 | |
1190 | 1190 | case 'infolog_add': |
1191 | - Framework::popup(Egw::link('/index.php',array( |
|
1191 | + Framework::popup(Egw::link('/index.php', array( |
|
1192 | 1192 | 'menuaction' => 'infolog.infolog_ui.edit', |
1193 | 1193 | 'type' => 'task', |
1194 | 1194 | 'action' => 'addressbook', |
1195 | - 'action_id' => implode(',',$checked), |
|
1196 | - )),'_blank',Link::get_registry('infolog', 'add_popup')); |
|
1197 | - $msg = ''; // no message, as we send none in javascript too and users sees opening popup |
|
1195 | + 'action_id' => implode(',', $checked), |
|
1196 | + )), '_blank', Link::get_registry('infolog', 'add_popup')); |
|
1197 | + $msg = ''; // no message, as we send none in javascript too and users sees opening popup |
|
1198 | 1198 | return false; |
1199 | 1199 | |
1200 | 1200 | case 'calendar_add': // add appointment for org-views, other views are handled directly in javascript |
1201 | - Framework::popup(Egw::link('/index.php',array( |
|
1201 | + Framework::popup(Egw::link('/index.php', array( |
|
1202 | 1202 | 'menuaction' => 'calendar.calendar_uiforms.edit', |
1203 | - 'participants' => 'c'.implode(',c',$checked), |
|
1204 | - )),'_blank',Link::get_registry('calendar', 'add_popup')); |
|
1205 | - $msg = ''; // no message, as we send none in javascript too and users sees opening popup |
|
1203 | + 'participants' => 'c'.implode(',c', $checked), |
|
1204 | + )), '_blank', Link::get_registry('calendar', 'add_popup')); |
|
1205 | + $msg = ''; // no message, as we send none in javascript too and users sees opening popup |
|
1206 | 1206 | return false; |
1207 | 1207 | |
1208 | 1208 | case 'calendar_view': // show calendar for org-views, although all views are handled directly in javascript |
1209 | - Egw::redirect_link('/index.php',array( |
|
1209 | + Egw::redirect_link('/index.php', array( |
|
1210 | 1210 | 'menuaction' => 'calendar.calendar_uiviews.index', |
1211 | - 'owner' => 'c'.implode(',c',$checked), |
|
1211 | + 'owner' => 'c'.implode(',c', $checked), |
|
1212 | 1212 | )); |
1213 | 1213 | } |
1214 | - foreach($checked as $id) |
|
1214 | + foreach ($checked as $id) |
|
1215 | 1215 | { |
1216 | - switch($action) |
|
1216 | + switch ($action) |
|
1217 | 1217 | { |
1218 | 1218 | case 'cat_add': |
1219 | 1219 | case 'cat_del': |
1220 | - if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::EDIT,$contact))) |
|
1220 | + if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::EDIT, $contact))) |
|
1221 | 1221 | { |
1222 | 1222 | $action_msg = $action == 'cat_add' ? lang('categorie added') : lang('categorie delete'); |
1223 | - $cat_ids = $contact['cat_id'] ? explode(',', $contact['cat_id']) : array(); //existing Api\Categories |
|
1223 | + $cat_ids = $contact['cat_id'] ? explode(',', $contact['cat_id']) : array(); //existing Api\Categories |
|
1224 | 1224 | if ($action == 'cat_add') |
1225 | 1225 | { |
1226 | 1226 | $cat_ids[] = $cat_id; |
1227 | 1227 | $cat_ids = array_unique($cat_ids); |
1228 | 1228 | } |
1229 | - elseif ((($key = array_search($cat_id,$cat_ids))) !== false) |
|
1229 | + elseif ((($key = array_search($cat_id, $cat_ids))) !== false) |
|
1230 | 1230 | { |
1231 | 1231 | unset($cat_ids[$key]); |
1232 | 1232 | } |
1233 | - $ids = $cat_ids ? implode(',',$cat_ids) : null; |
|
1233 | + $ids = $cat_ids ? implode(',', $cat_ids) : null; |
|
1234 | 1234 | if ($ids !== $contact['cat_id']) |
1235 | 1235 | { |
1236 | 1236 | $contact['cat_id'] = $ids; |
@@ -1241,10 +1241,10 @@ discard block |
||
1241 | 1241 | |
1242 | 1242 | case 'delete': |
1243 | 1243 | $action_msg = lang('deleted'); |
1244 | - if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE,$contact))) |
|
1244 | + if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE, $contact))) |
|
1245 | 1245 | { |
1246 | - if ($contact['owner'] || // regular contact or |
|
1247 | - empty($contact['account_id']) || // accounts without account_id |
|
1246 | + if ($contact['owner'] || // regular contact or |
|
1247 | + empty($contact['account_id']) || // accounts without account_id |
|
1248 | 1248 | // already deleted account (should no longer happen, but needed to allow for cleanup) |
1249 | 1249 | $contact['tid'] == self::DELETED_TYPE) |
1250 | 1250 | { |
@@ -1253,7 +1253,7 @@ discard block |
||
1253 | 1253 | // delete single account --> redirect to admin |
1254 | 1254 | elseif (count($checked) == 1 && $contact['account_id']) |
1255 | 1255 | { |
1256 | - Egw::redirect_link('/index.php',array( |
|
1256 | + Egw::redirect_link('/index.php', array( |
|
1257 | 1257 | 'menuaction' => 'admin.admin_account.delete', |
1258 | 1258 | 'account_id' => $contact['account_id'], |
1259 | 1259 | )); |
@@ -1315,7 +1315,7 @@ discard block |
||
1315 | 1315 | } |
1316 | 1316 | else |
1317 | 1317 | { |
1318 | - $Ok = $this->remove_from_list($id,$query['filter2']) !== false; |
|
1318 | + $Ok = $this->remove_from_list($id, $query['filter2']) !== false; |
|
1319 | 1319 | } |
1320 | 1320 | break; |
1321 | 1321 | |
@@ -1328,28 +1328,28 @@ discard block |
||
1328 | 1328 | } |
1329 | 1329 | else |
1330 | 1330 | { |
1331 | - $Ok = $this->add2list($id,$to_list) !== false; |
|
1331 | + $Ok = $this->add2list($id, $to_list) !== false; |
|
1332 | 1332 | } |
1333 | 1333 | break; |
1334 | 1334 | |
1335 | 1335 | default: // move to an other addressbook |
1336 | - if (!(int)$action || !($this->grants[(string) (int) $action] & Acl::EDIT)) // might be ADD in the future |
|
1336 | + if (!(int)$action || !($this->grants[(string)(int)$action]&Acl::EDIT)) // might be ADD in the future |
|
1337 | 1337 | { |
1338 | 1338 | return false; |
1339 | 1339 | } |
1340 | 1340 | if (!$checkboxes['move_to_copy']) |
1341 | 1341 | { |
1342 | 1342 | $action_msg = lang('moved'); |
1343 | - if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE,$contact))) |
|
1343 | + if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE, $contact))) |
|
1344 | 1344 | { |
1345 | 1345 | if (!$contact['owner']) // no (mass-)move of Api\Accounts |
1346 | 1346 | { |
1347 | 1347 | $Ok = false; |
1348 | 1348 | } |
1349 | - elseif ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action,-1) == 'p')) |
|
1349 | + elseif ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action, -1) == 'p')) |
|
1350 | 1350 | { |
1351 | - $contact['owner'] = (int) $action; |
|
1352 | - $contact['private'] = (int)(substr($action,-1) == 'p'); |
|
1351 | + $contact['owner'] = (int)$action; |
|
1352 | + $contact['private'] = (int)(substr($action, -1) == 'p'); |
|
1353 | 1353 | $Ok = $this->save($contact); |
1354 | 1354 | } |
1355 | 1355 | } |
@@ -1357,14 +1357,14 @@ discard block |
||
1357 | 1357 | else |
1358 | 1358 | { |
1359 | 1359 | $action_msg = lang('copied'); |
1360 | - if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::READ,$contact))) |
|
1360 | + if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::READ, $contact))) |
|
1361 | 1361 | { |
1362 | - if ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action,-1) == 'p')) |
|
1362 | + if ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action, -1) == 'p')) |
|
1363 | 1363 | { |
1364 | - $this->copy_contact($contact, false); // do NOT use self::$copy_fields, copy everything but uid etc. |
|
1364 | + $this->copy_contact($contact, false); // do NOT use self::$copy_fields, copy everything but uid etc. |
|
1365 | 1365 | $links = $contact['link_to']['to_id']; |
1366 | - $contact['owner'] = (int) $action; |
|
1367 | - $contact['private'] = (int)(substr($action,-1) == 'p'); |
|
1366 | + $contact['owner'] = (int)$action; |
|
1367 | + $contact['private'] = (int)(substr($action, -1) == 'p'); |
|
1368 | 1368 | $Ok = $this->save($contact); |
1369 | 1369 | if ($Ok && is_array($links)) |
1370 | 1370 | { |
@@ -1403,38 +1403,38 @@ discard block |
||
1403 | 1403 | * |
1404 | 1404 | * @return array List of contact IDs in the provided groups |
1405 | 1405 | */ |
1406 | - protected function find_grouped_ids($action,&$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg) |
|
1406 | + protected function find_grouped_ids($action, &$checked, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg) |
|
1407 | 1407 | { |
1408 | 1408 | unset($use_all); |
1409 | 1409 | $grouped_contacts = array(); |
1410 | - foreach((array)$checked as $n => $id) |
|
1410 | + foreach ((array)$checked as $n => $id) |
|
1411 | 1411 | { |
1412 | - if (substr($id,0,9) == 'org_name:' || substr($id, 0,10) == 'duplicate:') |
|
1412 | + if (substr($id, 0, 9) == 'org_name:' || substr($id, 0, 10) == 'duplicate:') |
|
1413 | 1413 | { |
1414 | 1414 | if (count($checked) == 1 && !count($grouped_contacts) && $action == 'infolog') |
1415 | 1415 | { |
1416 | - return $this->infolog_org_view($id); // uses the org-name, instead of 'selected contacts' |
|
1416 | + return $this->infolog_org_view($id); // uses the org-name, instead of 'selected contacts' |
|
1417 | 1417 | } |
1418 | 1418 | unset($checked[$n]); |
1419 | 1419 | $query = Api\Cache::getSession('addressbook', $session_name); |
1420 | - $query['num_rows'] = -1; // all |
|
1420 | + $query['num_rows'] = -1; // all |
|
1421 | 1421 | $query['grouped_view'] = $id; |
1422 | 1422 | unset($query['filter2']); |
1423 | 1423 | $extra = $readonlys = null; |
1424 | - $this->get_rows($query,$extra,$readonlys,true); // true = only return the id's |
|
1424 | + $this->get_rows($query, $extra, $readonlys, true); // true = only return the id's |
|
1425 | 1425 | |
1426 | 1426 | // Merge them here, so we only merge the ones that are duplicates, |
1427 | 1427 | // not merge all selected together |
1428 | - if($action == 'merge_duplicates') |
|
1428 | + if ($action == 'merge_duplicates') |
|
1429 | 1429 | { |
1430 | 1430 | $loop_success = $loop_fail = 0; |
1431 | - $this->action('merge', $extra, false, $loop_success, $loop_fail, $action_msg,$session_name,$msg); |
|
1431 | + $this->action('merge', $extra, false, $loop_success, $loop_fail, $action_msg, $session_name, $msg); |
|
1432 | 1432 | $success += $loop_success; |
1433 | 1433 | $failed += $loop_fail; |
1434 | 1434 | } |
1435 | 1435 | if ($extra[0]) |
1436 | 1436 | { |
1437 | - $grouped_contacts = array_merge($grouped_contacts,$extra); |
|
1437 | + $grouped_contacts = array_merge($grouped_contacts, $extra); |
|
1438 | 1438 | } |
1439 | 1439 | } |
1440 | 1440 | } |
@@ -1450,22 +1450,22 @@ discard block |
||
1450 | 1450 | * @param boolean $only_copy_fields =true true: only copy fields configured for copying (eg. no name), |
1451 | 1451 | * false: copy everything, but never to copy fields |
1452 | 1452 | */ |
1453 | - function copy_contact(array &$content, $only_copy_fields=true) |
|
1453 | + function copy_contact(array &$content, $only_copy_fields = true) |
|
1454 | 1454 | { |
1455 | 1455 | $content['link_to']['to_id'] = 0; |
1456 | - Link::link('addressbook',$content['link_to']['to_id'],'addressbook',$content['id'], |
|
1457 | - lang('Copied by %1, from record #%2.',Api\Accounts::format_username('', |
|
1458 | - $GLOBALS['egw_info']['user']['account_firstname'],$GLOBALS['egw_info']['user']['account_lastname']), |
|
1456 | + Link::link('addressbook', $content['link_to']['to_id'], 'addressbook', $content['id'], |
|
1457 | + lang('Copied by %1, from record #%2.', Api\Accounts::format_username('', |
|
1458 | + $GLOBALS['egw_info']['user']['account_firstname'], $GLOBALS['egw_info']['user']['account_lastname']), |
|
1459 | 1459 | $content['id'])); |
1460 | 1460 | // create a new contact with the content of the old |
1461 | - foreach(array_keys($content) as $key) |
|
1461 | + foreach (array_keys($content) as $key) |
|
1462 | 1462 | { |
1463 | - if($only_copy_fields && !in_array($key, self::$copy_fields) || in_array($key, array('id','etag','carddav_name','uid'))) |
|
1463 | + if ($only_copy_fields && !in_array($key, self::$copy_fields) || in_array($key, array('id', 'etag', 'carddav_name', 'uid'))) |
|
1464 | 1464 | { |
1465 | 1465 | unset($content[$key]); |
1466 | 1466 | } |
1467 | 1467 | } |
1468 | - if(!isset($content['owner'])) |
|
1468 | + if (!isset($content['owner'])) |
|
1469 | 1469 | { |
1470 | 1470 | $content['owner'] = $this->default_private ? $this->user.'p' : $this->default_addressbook; |
1471 | 1471 | } |
@@ -1483,7 +1483,7 @@ discard block |
||
1483 | 1483 | * @param boolean $id_only =false if true only return (via $rows) an array of contact-ids, dont save state to session |
1484 | 1484 | * @return int total number of contacts matching the selection |
1485 | 1485 | */ |
1486 | - function get_rows(&$query,&$rows,&$readonlys,$id_only=false) |
|
1486 | + function get_rows(&$query, &$rows, &$readonlys, $id_only = false) |
|
1487 | 1487 | { |
1488 | 1488 | $what = $query['sitemgr_display'] ? $query['sitemgr_display'] : 'index'; |
1489 | 1489 | |
@@ -1491,7 +1491,7 @@ discard block |
||
1491 | 1491 | { |
1492 | 1492 | $store_query = $query; |
1493 | 1493 | // Do not store these |
1494 | - foreach(array('options-cat_id','actions','action_links','placeholder_actions') as $key) |
|
1494 | + foreach (array('options-cat_id', 'actions', 'action_links', 'placeholder_actions') as $key) |
|
1495 | 1495 | { |
1496 | 1496 | unset($store_query[$key]); |
1497 | 1497 | } |
@@ -1503,28 +1503,28 @@ discard block |
||
1503 | 1503 | $old_state = Api\Cache::getSession('addressbook', $what); |
1504 | 1504 | } |
1505 | 1505 | $GLOBALS['egw']->session->commit_session(); |
1506 | - if (!isset($this->grouped_views[(string) $query['grouped_view']]) || strpos($query['grouped_view'],':') === false) |
|
1506 | + if (!isset($this->grouped_views[(string)$query['grouped_view']]) || strpos($query['grouped_view'], ':') === false) |
|
1507 | 1507 | { |
1508 | 1508 | // we don't have a grouped view, unset the according col_filters |
1509 | 1509 | $this->unset_grouped_filters($query); |
1510 | 1510 | } |
1511 | 1511 | |
1512 | - if (isset($this->grouped_views[(string) $query['grouped_view']])) |
|
1512 | + if (isset($this->grouped_views[(string)$query['grouped_view']])) |
|
1513 | 1513 | { |
1514 | 1514 | // we have a grouped view, reset the advanced search |
1515 | - if(!$query['search'] && $old_state['advanced_search']) $query['advanced_search'] = $old_state['advanced_search']; |
|
1515 | + if (!$query['search'] && $old_state['advanced_search']) $query['advanced_search'] = $old_state['advanced_search']; |
|
1516 | 1516 | } |
1517 | - elseif(!$query['search'] && array_key_exists('advanced_search',$old_state)) // eg. paging in an advanced search |
|
1517 | + elseif (!$query['search'] && array_key_exists('advanced_search', $old_state)) // eg. paging in an advanced search |
|
1518 | 1518 | { |
1519 | 1519 | $query['advanced_search'] = $old_state['advanced_search']; |
1520 | 1520 | } |
1521 | 1521 | |
1522 | 1522 | // Make sure old lettersearch filter doesn't stay - current letter filter will be added later |
1523 | - foreach($query['col_filter'] as $key => $col_filter) |
|
1523 | + foreach ($query['col_filter'] as $key => $col_filter) |
|
1524 | 1524 | { |
1525 | - if(!is_numeric($key)) continue; |
|
1526 | - if(preg_match('/'.$GLOBALS['egw']->db->capabilities['case_insensitive_like']. |
|
1527 | - ' '.$GLOBALS['egw']->db->quote('[a-z]%').'$/i',$col_filter) == 1 |
|
1525 | + if (!is_numeric($key)) continue; |
|
1526 | + if (preg_match('/'.$GLOBALS['egw']->db->capabilities['case_insensitive_like']. |
|
1527 | + ' '.$GLOBALS['egw']->db->quote('[a-z]%').'$/i', $col_filter) == 1 |
|
1528 | 1528 | ) |
1529 | 1529 | { |
1530 | 1530 | unset($query['col_filter'][$key]); |
@@ -1539,16 +1539,16 @@ discard block |
||
1539 | 1539 | { |
1540 | 1540 | if ($old_state['filter'] === '0') // user changed to org_view |
1541 | 1541 | { |
1542 | - $query['filter'] = ''; // --> change filter to all contacts |
|
1542 | + $query['filter'] = ''; // --> change filter to all contacts |
|
1543 | 1543 | } |
1544 | 1544 | else // user changed to accounts |
1545 | 1545 | { |
1546 | - $query['grouped_view'] = ''; // --> change to regular contacts view |
|
1546 | + $query['grouped_view'] = ''; // --> change to regular contacts view |
|
1547 | 1547 | } |
1548 | 1548 | } |
1549 | 1549 | if ($query['grouped_view'] && isset($this->grouped_views[$old_state['grouped_view']]) && !isset($this->grouped_views[$query['grouped_view']])) |
1550 | 1550 | { |
1551 | - $query['searchletter'] = ''; // reset lettersearch if viewing the contacts of one group (org or duplicates) |
|
1551 | + $query['searchletter'] = ''; // reset lettersearch if viewing the contacts of one group (org or duplicates) |
|
1552 | 1552 | } |
1553 | 1553 | // save the state of the index in the user prefs |
1554 | 1554 | $state = serialize(array( |
@@ -1561,9 +1561,9 @@ discard block |
||
1561 | 1561 | )); |
1562 | 1562 | if ($state != $this->prefs[$what.'_state'] && !$query['csv_export']) |
1563 | 1563 | { |
1564 | - $GLOBALS['egw']->preferences->add('addressbook',$what.'_state',$state); |
|
1564 | + $GLOBALS['egw']->preferences->add('addressbook', $what.'_state', $state); |
|
1565 | 1565 | // save prefs, but do NOT invalid the cache (unnecessary) |
1566 | - $GLOBALS['egw']->preferences->save_repository(false,'user',false); |
|
1566 | + $GLOBALS['egw']->preferences->save_repository(false, 'user', false); |
|
1567 | 1567 | } |
1568 | 1568 | } |
1569 | 1569 | unset($old_state); |
@@ -1578,11 +1578,11 @@ discard block |
||
1578 | 1578 | } |
1579 | 1579 | if ($query['filter'] !== '') // not all addressbooks |
1580 | 1580 | { |
1581 | - $query['col_filter']['owner'] = (string) (int) $query['filter']; |
|
1581 | + $query['col_filter']['owner'] = (string)(int)$query['filter']; |
|
1582 | 1582 | |
1583 | 1583 | if ($this->private_addressbook) |
1584 | 1584 | { |
1585 | - $query['col_filter']['private'] = substr($query['filter'],-1) == 'p' ? 1 : 0; |
|
1585 | + $query['col_filter']['private'] = substr($query['filter'], -1) == 'p' ? 1 : 0; |
|
1586 | 1586 | } |
1587 | 1587 | } |
1588 | 1588 | else |
@@ -1592,7 +1592,7 @@ discard block |
||
1592 | 1592 | } |
1593 | 1593 | if ((int)$query['filter2']) // not no distribution list |
1594 | 1594 | { |
1595 | - $query['col_filter']['list'] = (string) (int) $query['filter2']; |
|
1595 | + $query['col_filter']['list'] = (string)(int)$query['filter2']; |
|
1596 | 1596 | } |
1597 | 1597 | else |
1598 | 1598 | { |
@@ -1611,7 +1611,7 @@ discard block |
||
1611 | 1611 | $query['no_filter2'] = false; |
1612 | 1612 | |
1613 | 1613 | // Grouped view |
1614 | - if (isset($this->grouped_views[(string) $query['grouped_view']]) && !$query['col_filter']['parent_id']) |
|
1614 | + if (isset($this->grouped_views[(string)$query['grouped_view']]) && !$query['col_filter']['parent_id']) |
|
1615 | 1615 | { |
1616 | 1616 | $query['grouped_view_label'] = ''; |
1617 | 1617 | $rows = $this->get_grouped_rows($query); |
@@ -1626,7 +1626,7 @@ discard block |
||
1626 | 1626 | { |
1627 | 1627 | $query['template'] = 'addressbook.index.rows'; |
1628 | 1628 | } |
1629 | - if($query['col_filter']['parent_id']) |
|
1629 | + if ($query['col_filter']['parent_id']) |
|
1630 | 1630 | { |
1631 | 1631 | $query['grouped_view'] = $query['col_filter']['parent_id']; |
1632 | 1632 | $query['template'] = strpos($query['grouped_view'], 'duplicate') === 0 ? |
@@ -1636,11 +1636,11 @@ discard block |
||
1636 | 1636 | unset($query['col_filter']['parent_id']); |
1637 | 1637 | if ($query['grouped_view']) // view the contacts of one organisation only |
1638 | 1638 | { |
1639 | - if (strpos($query['grouped_view'],'*AND*') !== false) $query['grouped_view'] = str_replace('*AND*','&',$query['grouped_view']); |
|
1640 | - $fields = explode(',',$GLOBALS['egw_info']['user']['preferences']['addressbook']['duplicate_fields']); |
|
1641 | - foreach(explode('|||',$query['grouped_view']) as $part) |
|
1639 | + if (strpos($query['grouped_view'], '*AND*') !== false) $query['grouped_view'] = str_replace('*AND*', '&', $query['grouped_view']); |
|
1640 | + $fields = explode(',', $GLOBALS['egw_info']['user']['preferences']['addressbook']['duplicate_fields']); |
|
1641 | + foreach (explode('|||', $query['grouped_view']) as $part) |
|
1642 | 1642 | { |
1643 | - list($name,$value) = explode(':',$part,2); |
|
1643 | + list($name, $value) = explode(':', $part, 2); |
|
1644 | 1644 | // do NOT set invalid column, as this gives an SQL error ("AND AND" in sql) |
1645 | 1645 | if (static::$duplicate_fields[$name] && $value && ( |
1646 | 1646 | strpos($query['grouped_view'], 'duplicate:') === 0 && in_array($name, $fields) || |
@@ -1651,14 +1651,14 @@ discard block |
||
1651 | 1651 | } |
1652 | 1652 | } |
1653 | 1653 | } |
1654 | - else if($query['actions'] && !$query['actions']['edit']) |
|
1654 | + else if ($query['actions'] && !$query['actions']['edit']) |
|
1655 | 1655 | { |
1656 | 1656 | // Just switched from grouped view, update actions |
1657 | 1657 | $query['actions'] = $this->get_actions($query['col_filter']['tid']); |
1658 | 1658 | } |
1659 | 1659 | // translate the select order to the really used over all 3 columns |
1660 | 1660 | $sort = $query['sort']; |
1661 | - switch($query['order']) // "xxx<>'' DESC" sorts contacts with empty order-criteria always at the end |
|
1661 | + switch ($query['order']) // "xxx<>'' DESC" sorts contacts with empty order-criteria always at the end |
|
1662 | 1662 | { // we don't exclude them, as the total would otherwise depend on the order-criteria |
1663 | 1663 | case 'org_name': |
1664 | 1664 | $order = "egw_addressbook.org_name<>''DESC,egw_addressbook.org_name $sort,n_family $sort,n_given $sort"; |
@@ -1692,8 +1692,8 @@ discard block |
||
1692 | 1692 | } |
1693 | 1693 | if ($query['searchletter']) // only show contacts if the order-criteria starts with the given letter |
1694 | 1694 | { |
1695 | - $no_letter_search = array('adr_one_postalcode', 'adr_two_postalcode', 'contact_id', 'contact_created','contact_modified'); |
|
1696 | - $query['col_filter'][] = (in_array($query['order'],$no_letter_search) ? 'org_name' : (substr($query['order'],0,1)=='#'?'':'egw_addressbook.').$query['order']).' '. |
|
1695 | + $no_letter_search = array('adr_one_postalcode', 'adr_two_postalcode', 'contact_id', 'contact_created', 'contact_modified'); |
|
1696 | + $query['col_filter'][] = (in_array($query['order'], $no_letter_search) ? 'org_name' : (substr($query['order'], 0, 1) == '#' ? '' : 'egw_addressbook.').$query['order']).' '. |
|
1697 | 1697 | $GLOBALS['egw']->db->capabilities['case_insensitive_like'].' '.$GLOBALS['egw']->db->quote($query['searchletter'].'%'); |
1698 | 1698 | } |
1699 | 1699 | $wildcard = '%'; |
@@ -1707,22 +1707,22 @@ discard block |
||
1707 | 1707 | unset($query['advanced_search']['meth_select']); |
1708 | 1708 | } |
1709 | 1709 | |
1710 | - $rows = parent::search($query['advanced_search'] ? $query['advanced_search'] : $query['search'],$id_only, |
|
1711 | - $order,'',$wildcard,false,$op,array((int)$query['start'],(int) $query['num_rows']),$query['col_filter']); |
|
1710 | + $rows = parent::search($query['advanced_search'] ? $query['advanced_search'] : $query['search'], $id_only, |
|
1711 | + $order, '', $wildcard, false, $op, array((int)$query['start'], (int)$query['num_rows']), $query['col_filter']); |
|
1712 | 1712 | |
1713 | 1713 | // do we need to read the custom fields, depends on the column is enabled and customfields |
1714 | 1714 | $columsel = $this->prefs['nextmatch-addressbook.index.rows']; |
1715 | - $available_distib_lists=$this->get_lists(Acl::READ); |
|
1716 | - $columselection = $columsel ? explode(',',$columsel) : array(); |
|
1715 | + $available_distib_lists = $this->get_lists(Acl::READ); |
|
1716 | + $columselection = $columsel ? explode(',', $columsel) : array(); |
|
1717 | 1717 | $ids = $calendar_participants = array(); |
1718 | 1718 | if (!$id_only && $rows) |
1719 | 1719 | { |
1720 | - $show_custom_fields = (in_array('customfields',$columselection) || $this->config['index_load_cfs']) && $this->customfields; |
|
1721 | - $show_calendar = $this->config['disable_event_column'] != 'True' && in_array('calendar_calendar',$columselection); |
|
1722 | - $show_distributionlist = in_array('distrib_lists',$columselection) || count($available_distib_lists); |
|
1720 | + $show_custom_fields = (in_array('customfields', $columselection) || $this->config['index_load_cfs']) && $this->customfields; |
|
1721 | + $show_calendar = $this->config['disable_event_column'] != 'True' && in_array('calendar_calendar', $columselection); |
|
1722 | + $show_distributionlist = in_array('distrib_lists', $columselection) || count($available_distib_lists); |
|
1723 | 1723 | if ($show_calendar || $show_custom_fields || $show_distributionlist) |
1724 | 1724 | { |
1725 | - foreach($rows as $val) |
|
1725 | + foreach ($rows as $val) |
|
1726 | 1726 | { |
1727 | 1727 | $ids[] = $val['id']; |
1728 | 1728 | $calendar_participants[$val['id']] = $val['account_id'] ? $val['account_id'] : 'c'.$val['id']; |
@@ -1730,22 +1730,22 @@ discard block |
||
1730 | 1730 | if ($show_custom_fields) |
1731 | 1731 | { |
1732 | 1732 | $selected_cfs = array(); |
1733 | - if(in_array('customfields',$columselection)) |
|
1733 | + if (in_array('customfields', $columselection)) |
|
1734 | 1734 | { |
1735 | - foreach($columselection as $col) |
|
1735 | + foreach ($columselection as $col) |
|
1736 | 1736 | { |
1737 | - if ($col[0] == '#') $selected_cfs[] = substr($col,1); |
|
1737 | + if ($col[0] == '#') $selected_cfs[] = substr($col, 1); |
|
1738 | 1738 | } |
1739 | 1739 | } |
1740 | 1740 | $selected_cfs = array_unique(array_merge($selected_cfs, (array)$this->config['index_load_cfs'])); |
1741 | - $customfields = $this->read_customfields($ids,$selected_cfs); |
|
1741 | + $customfields = $this->read_customfields($ids, $selected_cfs); |
|
1742 | 1742 | } |
1743 | 1743 | if ($show_calendar && !empty($ids)) $calendar = $this->read_calendar($calendar_participants); |
1744 | 1744 | // distributionlist memership for the entrys |
1745 | 1745 | //_debug_array($this->get_lists(Acl::EDIT)); |
1746 | 1746 | if ($show_distributionlist && $available_distib_lists) |
1747 | 1747 | { |
1748 | - $distributionlist = $this->read_distributionlist($ids,array_keys($available_distib_lists)); |
|
1748 | + $distributionlist = $this->read_distributionlist($ids, array_keys($available_distib_lists)); |
|
1749 | 1749 | } |
1750 | 1750 | } |
1751 | 1751 | } |
@@ -1754,20 +1754,20 @@ discard block |
||
1754 | 1754 | |
1755 | 1755 | if ($id_only) |
1756 | 1756 | { |
1757 | - foreach($rows as $n => $row) |
|
1757 | + foreach ($rows as $n => $row) |
|
1758 | 1758 | { |
1759 | 1759 | $rows[$n] = $row['id']; |
1760 | 1760 | } |
1761 | - return $this->total; // no need to set other fields or $readonlys |
|
1761 | + return $this->total; // no need to set other fields or $readonlys |
|
1762 | 1762 | } |
1763 | 1763 | $order = $query['order']; |
1764 | 1764 | |
1765 | 1765 | $readonlys = array(); |
1766 | - foreach($rows as $n => &$row) |
|
1766 | + foreach ($rows as $n => &$row) |
|
1767 | 1767 | { |
1768 | 1768 | $given = $row['n_given'] ? $row['n_given'] : ($row['n_prefix'] ? $row['n_prefix'] : ''); |
1769 | 1769 | |
1770 | - switch($order) |
|
1770 | + switch ($order) |
|
1771 | 1771 | { |
1772 | 1772 | default: // postalcode, created, modified, ... |
1773 | 1773 | case 'org_name': |
@@ -1784,43 +1784,43 @@ discard block |
||
1784 | 1784 | break; |
1785 | 1785 | case 'n_fileas': |
1786 | 1786 | if (!$row['n_fileas']) $row['n_fileas'] = $this->fileas($row); |
1787 | - list($row['line1'],$row['line2']) = explode(': ',$row['n_fileas']); |
|
1787 | + list($row['line1'], $row['line2']) = explode(': ', $row['n_fileas']); |
|
1788 | 1788 | break; |
1789 | 1789 | } |
1790 | - if (isset($this->grouped_views[(string) $query['grouped_view']])) |
|
1790 | + if (isset($this->grouped_views[(string)$query['grouped_view']])) |
|
1791 | 1791 | { |
1792 | 1792 | $row['type'] = 'home'; |
1793 | 1793 | $row['type_label'] = $query['grouped_view'] == 'duplicate' ? lang('Duplicates') : lang('Organisation'); |
1794 | 1794 | |
1795 | - if ($query['filter'] && !($this->grants[(int)$query['filter']] & Acl::DELETE)) |
|
1795 | + if ($query['filter'] && !($this->grants[(int)$query['filter']]&Acl::DELETE)) |
|
1796 | 1796 | { |
1797 | 1797 | $row['class'] .= 'rowNoDelete '; |
1798 | 1798 | } |
1799 | - $row['class'] .= 'rowNoEdit '; // no edit in OrgView |
|
1799 | + $row['class'] .= 'rowNoEdit '; // no edit in OrgView |
|
1800 | 1800 | $row['class'] .= $query['grouped_view'] == 'duplicates' ? 'contact_duplicate' : 'contact_organisation '; |
1801 | 1801 | } |
1802 | 1802 | else |
1803 | 1803 | { |
1804 | - $this->type_icon($row['owner'],$row['private'],$row['tid'],$row['type'],$row['type_label']); |
|
1804 | + $this->type_icon($row['owner'], $row['private'], $row['tid'], $row['type'], $row['type_label']); |
|
1805 | 1805 | |
1806 | - static $tel2show = array('tel_work','tel_cell','tel_home','tel_fax'); |
|
1806 | + static $tel2show = array('tel_work', 'tel_cell', 'tel_home', 'tel_fax'); |
|
1807 | 1807 | static $prefer_marker = null; |
1808 | 1808 | if (is_null($prefer_marker)) |
1809 | 1809 | { |
1810 | 1810 | // as et2 adds options with .text(), it can't be entities, but php knows no string literals with utf-8 |
1811 | 1811 | $prefer_marker = html_entity_decode(' ☆', ENT_NOQUOTES, 'utf-8'); |
1812 | 1812 | } |
1813 | - foreach($tel2show as $name) |
|
1813 | + foreach ($tel2show as $name) |
|
1814 | 1814 | { |
1815 | - $row[$name] .= ' '.($row['tel_prefer'] == $name ? $prefer_marker : ''); // .' ' to NOT remove the field |
|
1815 | + $row[$name] .= ' '.($row['tel_prefer'] == $name ? $prefer_marker : ''); // .' ' to NOT remove the field |
|
1816 | 1816 | } |
1817 | 1817 | // allways show the prefered phone, if not already shown |
1818 | - if (!in_array($row['tel_prefer'],$tel2show) && $row[$row['tel_prefer']]) |
|
1818 | + if (!in_array($row['tel_prefer'], $tel2show) && $row[$row['tel_prefer']]) |
|
1819 | 1819 | { |
1820 | 1820 | $row['tel_prefered'] = $row[$row['tel_prefer']].$prefer_marker; |
1821 | 1821 | } |
1822 | 1822 | // Show nice name as status text |
1823 | - if($row['tel_prefer']) |
|
1823 | + if ($row['tel_prefer']) |
|
1824 | 1824 | { |
1825 | 1825 | $row['tel_prefer_label'] = $this->contact_fields[$row['tel_prefer']]; |
1826 | 1826 | } |
@@ -1828,33 +1828,33 @@ discard block |
||
1828 | 1828 | { |
1829 | 1829 | $row['class'] .= 'rowAccount rowNoDelete '; |
1830 | 1830 | } |
1831 | - elseif (!$this->check_perms(Acl::DELETE,$row) || (!$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge' && $query['col_filter']['tid'] == self::DELETED_TYPE)) |
|
1831 | + elseif (!$this->check_perms(Acl::DELETE, $row) || (!$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge' && $query['col_filter']['tid'] == self::DELETED_TYPE)) |
|
1832 | 1832 | { |
1833 | 1833 | $row['class'] .= 'rowNoDelete '; |
1834 | 1834 | } |
1835 | - if (!$this->check_perms(Acl::EDIT,$row)) |
|
1835 | + if (!$this->check_perms(Acl::EDIT, $row)) |
|
1836 | 1836 | { |
1837 | 1837 | $row['class'] .= 'rowNoEdit '; |
1838 | 1838 | } |
1839 | 1839 | $row['class'] .= 'contact_contact '; |
1840 | 1840 | |
1841 | - unset($row['jpegphoto']); // unused and messes up json encoding (not utf-8) |
|
1841 | + unset($row['jpegphoto']); // unused and messes up json encoding (not utf-8) |
|
1842 | 1842 | |
1843 | 1843 | if (isset($customfields[$row['id']])) |
1844 | 1844 | { |
1845 | - foreach($this->customfields as $name => $data) |
|
1845 | + foreach ($this->customfields as $name => $data) |
|
1846 | 1846 | { |
1847 | 1847 | $row['#'.$name] = $customfields[$row['id']]['#'.$name]; |
1848 | 1848 | } |
1849 | 1849 | } |
1850 | 1850 | if (isset($distributionlist[$row['id']])) |
1851 | 1851 | { |
1852 | - $row['distrib_lists'] = implode("\n",array_values($distributionlist[$row['id']])); |
|
1852 | + $row['distrib_lists'] = implode("\n", array_values($distributionlist[$row['id']])); |
|
1853 | 1853 | //if ($show_distributionlist) $readonlys['distrib_lists'] =true; |
1854 | 1854 | } |
1855 | 1855 | if (isset($calendar[$calendar_participants[$row['id']]])) |
1856 | 1856 | { |
1857 | - foreach($calendar[$calendar_participants[$row['id']]] as $name => $data) |
|
1857 | + foreach ($calendar[$calendar_participants[$row['id']]] as $name => $data) |
|
1858 | 1858 | { |
1859 | 1859 | $row[$name] = $data; |
1860 | 1860 | } |
@@ -1862,13 +1862,13 @@ discard block |
||
1862 | 1862 | } |
1863 | 1863 | |
1864 | 1864 | // hide region for address format 'postcode_city' |
1865 | - if (($row['addr_format'] = $this->addr_format_by_country($row['adr_one_countryname']))=='postcode_city') unset($row['adr_one_region']); |
|
1866 | - if (($row['addr_format2'] = $this->addr_format_by_country($row['adr_two_countryname']))=='postcode_city') unset($row['adr_two_region']); |
|
1865 | + if (($row['addr_format'] = $this->addr_format_by_country($row['adr_one_countryname'])) == 'postcode_city') unset($row['adr_one_region']); |
|
1866 | + if (($row['addr_format2'] = $this->addr_format_by_country($row['adr_two_countryname'])) == 'postcode_city') unset($row['adr_two_region']); |
|
1867 | 1867 | |
1868 | 1868 | // respect category permissions |
1869 | - if(!empty($row['cat_id'])) |
|
1869 | + if (!empty($row['cat_id'])) |
|
1870 | 1870 | { |
1871 | - $row['cat_id'] = $this->categories->check_list(Acl::READ,$row['cat_id']); |
|
1871 | + $row['cat_id'] = $this->categories->check_list(Acl::READ, $row['cat_id']); |
|
1872 | 1872 | } |
1873 | 1873 | } |
1874 | 1874 | $rows['no_distribution_list'] = (bool)$query['filter2']; |
@@ -1880,7 +1880,7 @@ discard block |
||
1880 | 1880 | } |
1881 | 1881 | |
1882 | 1882 | // Disable next/last date if so configured |
1883 | - if($this->config['disable_event_column'] == 'True') |
|
1883 | + if ($this->config['disable_event_column'] == 'True') |
|
1884 | 1884 | { |
1885 | 1885 | $rows['no_event_column'] = true; |
1886 | 1886 | } |
@@ -1893,23 +1893,21 @@ discard block |
||
1893 | 1893 | $header = array(); |
1894 | 1894 | if ($query['filter'] !== '' && !isset($this->grouped_views[$query['grouped_view']])) |
1895 | 1895 | { |
1896 | - $header[] = ($query['filter'] == '0' ? lang('accounts') : |
|
1897 | - ($GLOBALS['egw']->accounts->get_type($query['filter']) == 'g' ? |
|
1898 | - lang('Group %1',$GLOBALS['egw']->accounts->id2name($query['filter'])) : |
|
1899 | - Api\Accounts::username((int)$query['filter']). |
|
1900 | - (substr($query['filter'],-1) == 'p' ? ' ('.lang('private').')' : ''))); |
|
1896 | + $header[] = ($query['filter'] == '0' ? lang('accounts') : ($GLOBALS['egw']->accounts->get_type($query['filter']) == 'g' ? |
|
1897 | + lang('Group %1', $GLOBALS['egw']->accounts->id2name($query['filter'])) : Api\Accounts::username((int)$query['filter']). |
|
1898 | + (substr($query['filter'], -1) == 'p' ? ' ('.lang('private').')' : ''))); |
|
1901 | 1899 | } |
1902 | 1900 | if ($query['grouped_view']) |
1903 | 1901 | { |
1904 | 1902 | $header[] = $query['grouped_view_label']; |
1905 | 1903 | // Make sure option is there |
1906 | - if(!array_key_exists($query['grouped_view'], $this->grouped_views)) |
|
1904 | + if (!array_key_exists($query['grouped_view'], $this->grouped_views)) |
|
1907 | 1905 | { |
1908 | 1906 | $this->grouped_views += $this->_get_grouped_name($query['grouped_view']); |
1909 | 1907 | $rows['sel_options']['grouped_view'] = $this->grouped_views; |
1910 | 1908 | } |
1911 | 1909 | } |
1912 | - if($query['advanced_search']) |
|
1910 | + if ($query['advanced_search']) |
|
1913 | 1911 | { |
1914 | 1912 | $header[] = lang('Advanced search'); |
1915 | 1913 | } |
@@ -1920,11 +1918,11 @@ discard block |
||
1920 | 1918 | if ($query['searchletter']) |
1921 | 1919 | { |
1922 | 1920 | $order = $order == 'n_given' ? lang('first name') : ($order == 'n_family' ? lang('last name') : lang('Organisation')); |
1923 | - $header[] = lang("%1 starts with '%2'",$order,$query['searchletter']); |
|
1921 | + $header[] = lang("%1 starts with '%2'", $order, $query['searchletter']); |
|
1924 | 1922 | } |
1925 | 1923 | if ($query['search'] && !$query['advanced_search']) // do not add that, if we have advanced search active |
1926 | 1924 | { |
1927 | - $header[] = lang("Search for '%1'",$query['search']); |
|
1925 | + $header[] = lang("Search for '%1'", $query['search']); |
|
1928 | 1926 | } |
1929 | 1927 | $GLOBALS['egw_info']['flags']['app_header'] = implode(': ', $header); |
1930 | 1928 | |
@@ -1940,7 +1938,7 @@ discard block |
||
1940 | 1938 | * @param string &$icon icon-name |
1941 | 1939 | * @param string &$label translated label |
1942 | 1940 | */ |
1943 | - function type_icon($owner,$private,$tid,&$icon,&$label) |
|
1941 | + function type_icon($owner, $private, $tid, &$icon, &$label) |
|
1944 | 1942 | { |
1945 | 1943 | if (!$owner) |
1946 | 1944 | { |
@@ -1955,7 +1953,7 @@ discard block |
||
1955 | 1953 | elseif ($GLOBALS['egw']->accounts->get_type($owner) == 'g') |
1956 | 1954 | { |
1957 | 1955 | $icon = 'group'; |
1958 | - $label = lang('group %1',$GLOBALS['egw']->accounts->id2name($owner)); |
|
1956 | + $label = lang('group %1', $GLOBALS['egw']->accounts->id2name($owner)); |
|
1959 | 1957 | } |
1960 | 1958 | else |
1961 | 1959 | { |
@@ -1963,9 +1961,9 @@ discard block |
||
1963 | 1961 | $label = $owner == $this->user ? lang('personal') : Api\Accounts::username($owner); |
1964 | 1962 | } |
1965 | 1963 | // show tid icon for tid!='n' AND only if one is defined |
1966 | - if ($tid != 'n' && Api\Image::find('addressbook',$this->content_types[$tid]['name'])) |
|
1964 | + if ($tid != 'n' && Api\Image::find('addressbook', $this->content_types[$tid]['name'])) |
|
1967 | 1965 | { |
1968 | - $icon = Api\Image::find('addressbook',$this->content_types[$tid]['name']); |
|
1966 | + $icon = Api\Image::find('addressbook', $this->content_types[$tid]['name']); |
|
1969 | 1967 | } |
1970 | 1968 | |
1971 | 1969 | // Legacy - from when icons could be anywhere |
@@ -1983,19 +1981,19 @@ discard block |
||
1983 | 1981 | * @param int $_GET['contact_id'] contact_id mainly for popup use |
1984 | 1982 | * @param bool $_GET['makecp'] true if you want to copy the contact given by $_GET['contact_id'] |
1985 | 1983 | */ |
1986 | - function edit($content=null) |
|
1984 | + function edit($content = null) |
|
1987 | 1985 | { |
1988 | 1986 | if (is_array($content)) |
1989 | 1987 | { |
1990 | 1988 | $button = @key($content['button']); |
1991 | 1989 | unset($content['button']); |
1992 | - $content['private'] = (int) ($content['owner'] && substr($content['owner'],-1) == 'p'); |
|
1993 | - $content['owner'] = (string) (int) $content['owner']; |
|
1990 | + $content['private'] = (int)($content['owner'] && substr($content['owner'], -1) == 'p'); |
|
1991 | + $content['owner'] = (string)(int)$content['owner']; |
|
1994 | 1992 | $content['cat_id'] = $this->config['cat_tab'] === 'Tree' ? $content['cat_id_tree'] : $content['cat_id']; |
1995 | 1993 | if ($this->config['private_cf_tab']) $content = (array)$content['private_cfs'] + $content; |
1996 | 1994 | unset($content['private_cfs']); |
1997 | 1995 | |
1998 | - switch($button) |
|
1996 | + switch ($button) |
|
1999 | 1997 | { |
2000 | 1998 | case 'save': |
2001 | 1999 | case 'apply': |
@@ -2007,7 +2005,7 @@ discard block |
||
2007 | 2005 | // photo might be changed by ajax_upload_photo |
2008 | 2006 | if (!array_key_exists('jpegphoto', $content)) |
2009 | 2007 | { |
2010 | - $content['photo_unchanged'] = true; // hint no need to store photo |
|
2008 | + $content['photo_unchanged'] = true; // hint no need to store photo |
|
2011 | 2009 | } |
2012 | 2010 | $links = false; |
2013 | 2011 | if (!$content['id'] && is_array($content['link_to']['to_id'])) |
@@ -2020,12 +2018,12 @@ discard block |
||
2020 | 2018 | $old_org_entry = $this->read($content['id']); |
2021 | 2019 | $old_fullname = ($old_org_entry['n_fn'] ? $old_org_entry['n_fn'] : parent::fullname($old_org_entry)); |
2022 | 2020 | } |
2023 | - if ( $content['n_fn'] != $fullname || $fullname != $old_fullname) |
|
2021 | + if ($content['n_fn'] != $fullname || $fullname != $old_fullname) |
|
2024 | 2022 | { |
2025 | 2023 | unset($content['n_fn']); |
2026 | 2024 | } |
2027 | 2025 | // Country codes |
2028 | - foreach(array('adr_one', 'adr_two') as $c_prefix) |
|
2026 | + foreach (array('adr_one', 'adr_two') as $c_prefix) |
|
2029 | 2027 | { |
2030 | 2028 | if ($content[$c_prefix.'_countrycode'] == '-custom-') |
2031 | 2029 | { |
@@ -2034,7 +2032,7 @@ discard block |
||
2034 | 2032 | } |
2035 | 2033 | $content['msg'] = ''; |
2036 | 2034 | $this->error = false; |
2037 | - foreach((array)$content['pre_save_callbacks'] as $callback) |
|
2035 | + foreach ((array)$content['pre_save_callbacks'] as $callback) |
|
2038 | 2036 | { |
2039 | 2037 | try { |
2040 | 2038 | if (($success_msg = call_user_func_array($callback, array(&$content)))) |
@@ -2044,7 +2042,7 @@ discard block |
||
2044 | 2042 | } |
2045 | 2043 | catch (Exception $ex) { |
2046 | 2044 | $content['msg'] .= ($content['msg'] ? ', ' : '').$ex->getMessage(); |
2047 | - $button = 'apply'; // do not close dialog |
|
2045 | + $button = 'apply'; // do not close dialog |
|
2048 | 2046 | $this->error = true; |
2049 | 2047 | break; |
2050 | 2048 | } |
@@ -2059,7 +2057,7 @@ discard block |
||
2059 | 2057 | |
2060 | 2058 | unset($content['jpegphoto'], $content['photo_unchanged']); |
2061 | 2059 | |
2062 | - foreach((array)$content['post_save_callbacks'] as $callback) |
|
2060 | + foreach ((array)$content['post_save_callbacks'] as $callback) |
|
2063 | 2061 | { |
2064 | 2062 | try { |
2065 | 2063 | if (($success_msg = call_user_func_array($callback, array(&$content)))) |
@@ -2067,58 +2065,58 @@ discard block |
||
2067 | 2065 | $content['msg'] .= ', '.$success_msg; |
2068 | 2066 | } |
2069 | 2067 | } |
2070 | - catch(Api\Exception\Redirect $r) |
|
2068 | + catch (Api\Exception\Redirect $r) |
|
2071 | 2069 | { |
2072 | 2070 | // catch it to continue execution and rethrow it later |
2073 | 2071 | } |
2074 | 2072 | catch (Exception $ex) { |
2075 | 2073 | $content['msg'] .= ', '.$ex->getMessage(); |
2076 | - $button = 'apply'; // do not close dialog |
|
2074 | + $button = 'apply'; // do not close dialog |
|
2077 | 2075 | $this->error = true; |
2078 | 2076 | break; |
2079 | 2077 | } |
2080 | 2078 | } |
2081 | 2079 | |
2082 | - if ($content['change_org'] && $old_org_entry && ($changed = $this->changed_fields($old_org_entry,$content,true)) && |
|
2083 | - ($members = $this->org_similar($old_org_entry['org_name'],$changed))) |
|
2080 | + if ($content['change_org'] && $old_org_entry && ($changed = $this->changed_fields($old_org_entry, $content, true)) && |
|
2081 | + ($members = $this->org_similar($old_org_entry['org_name'], $changed))) |
|
2084 | 2082 | { |
2085 | 2083 | //foreach($changed as $name => $old_value) echo "<p>$name: '$old_value' --> '{$content[$name]}'</p>\n"; |
2086 | - list($changed_members,$changed_fields,$failed_members) = $this->change_org($old_org_entry['org_name'],$changed,$content,$members); |
|
2084 | + list($changed_members, $changed_fields, $failed_members) = $this->change_org($old_org_entry['org_name'], $changed, $content, $members); |
|
2087 | 2085 | if ($changed_members) |
2088 | 2086 | { |
2089 | - $content['msg'] .= ', '.lang('%1 fields in %2 other organisation member(s) changed',$changed_fields,$changed_members); |
|
2087 | + $content['msg'] .= ', '.lang('%1 fields in %2 other organisation member(s) changed', $changed_fields, $changed_members); |
|
2090 | 2088 | } |
2091 | 2089 | if ($failed_members) |
2092 | 2090 | { |
2093 | - $content['msg'] .= ', '.lang('failed to change %1 organisation member(s) (insufficent rights) !!!',$failed_members); |
|
2091 | + $content['msg'] .= ', '.lang('failed to change %1 organisation member(s) (insufficent rights) !!!', $failed_members); |
|
2094 | 2092 | } |
2095 | 2093 | } |
2096 | 2094 | } |
2097 | - elseif($this->error === true) |
|
2095 | + elseif ($this->error === true) |
|
2098 | 2096 | { |
2099 | 2097 | $content['msg'] = lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
2100 | - lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'. |
|
2101 | - htmlspecialchars(Egw::link('/index.php',array( |
|
2098 | + lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'. |
|
2099 | + htmlspecialchars(Egw::link('/index.php', array( |
|
2102 | 2100 | 'menuaction' => 'addressbook.addressbook_ui.edit', |
2103 | 2101 | 'contact_id' => $content['id'], |
2104 | - ))).'">','</a>'); |
|
2105 | - break; // dont refresh the list |
|
2102 | + ))).'">', '</a>'); |
|
2103 | + break; // dont refresh the list |
|
2106 | 2104 | } |
2107 | 2105 | else |
2108 | 2106 | { |
2109 | 2107 | $content['msg'] = lang('Error saving the contact !!!'). |
2110 | 2108 | ($this->error ? ' '.$this->error : ''); |
2111 | - $button = 'apply'; // to not leave the dialog |
|
2109 | + $button = 'apply'; // to not leave the dialog |
|
2112 | 2110 | } |
2113 | 2111 | // writing links for new entry, existing ones are handled by the widget itself |
2114 | 2112 | if ($links && $content['id']) |
2115 | 2113 | { |
2116 | - Link::link('addressbook',$content['id'],$links); |
|
2114 | + Link::link('addressbook', $content['id'], $links); |
|
2117 | 2115 | } |
2118 | 2116 | // Update client side global datastore |
2119 | 2117 | $response = Api\Json\Response::get(); |
2120 | 2118 | $response->generic('data', array('uid' => 'addressbook::'.$content['id'], 'data' => $content)); |
2121 | - Framework::refresh_opener($content['msg'], 'addressbook', $content['id'], $content['id'] ? 'edit' : 'add', |
|
2119 | + Framework::refresh_opener($content['msg'], 'addressbook', $content['id'], $content['id'] ? 'edit' : 'add', |
|
2122 | 2120 | null, null, null, $this->error ? 'error' : 'success'); |
2123 | 2121 | |
2124 | 2122 | // re-throw redirect exception, if there's no error |
@@ -2140,11 +2138,11 @@ discard block |
||
2140 | 2138 | |
2141 | 2139 | case 'delete': |
2142 | 2140 | $success = $failed = $action_msg = null; |
2143 | - if($this->action('delete',array($content['id']),false,$success,$failed,$action_msg,'',$content['msg'])) |
|
2141 | + if ($this->action('delete', array($content['id']), false, $success, $failed, $action_msg, '', $content['msg'])) |
|
2144 | 2142 | { |
2145 | 2143 | if ($GLOBALS['egw']->currentapp == 'addressbook') |
2146 | 2144 | { |
2147 | - Framework::refresh_opener(lang('Contact deleted'), 'addressbook', $content['id'], 'delete' ); |
|
2145 | + Framework::refresh_opener(lang('Contact deleted'), 'addressbook', $content['id'], 'delete'); |
|
2148 | 2146 | Framework::window_close(); |
2149 | 2147 | } |
2150 | 2148 | else |
@@ -2169,7 +2167,7 @@ discard block |
||
2169 | 2167 | // new contact --> set some defaults |
2170 | 2168 | if ($contact_id && is_array($content = $this->read($contact_id))) |
2171 | 2169 | { |
2172 | - $contact_id = $content['id']; // it could have been: "account:$account_id" |
|
2170 | + $contact_id = $content['id']; // it could have been: "account:$account_id" |
|
2173 | 2171 | if (!$this->check_perms(Acl::EDIT, $content)) |
2174 | 2172 | { |
2175 | 2173 | $view = true; |
@@ -2213,52 +2211,52 @@ discard block |
||
2213 | 2211 | { |
2214 | 2212 | $content['owner'] = (string)($state['filter'] == 0 ? '' : $state['filter']); |
2215 | 2213 | } |
2216 | - $content['private'] = (int) ($content['owner'] && substr($content['owner'],-1) == 'p'); |
|
2217 | - if ($content['owner'] === '' || !($this->grants[$content['owner'] = (string) (int) $content['owner']] & Acl::ADD)) |
|
2214 | + $content['private'] = (int)($content['owner'] && substr($content['owner'], -1) == 'p'); |
|
2215 | + if ($content['owner'] === '' || !($this->grants[$content['owner'] = (string)(int)$content['owner']]&Acl::ADD)) |
|
2218 | 2216 | { |
2219 | 2217 | $content['owner'] = $this->default_addressbook; |
2220 | 2218 | $content['private'] = (int)$this->default_private; |
2221 | 2219 | |
2222 | - if (!($this->grants[$content['owner'] = (string) (int) $content['owner']] & Acl::ADD)) |
|
2220 | + if (!($this->grants[$content['owner'] = (string)(int)$content['owner']]&Acl::ADD)) |
|
2223 | 2221 | { |
2224 | - $content['owner'] = (string) $this->user; |
|
2222 | + $content['owner'] = (string)$this->user; |
|
2225 | 2223 | $content['private'] = 0; |
2226 | 2224 | } |
2227 | 2225 | } |
2228 | 2226 | $new_type = array_keys($this->content_types); |
2229 | 2227 | // fetch active type to preset the type, if param typeid is not passed |
2230 | - $active_tid = Api\Cache::getSession('addressbook','active_tid'); |
|
2228 | + $active_tid = Api\Cache::getSession('addressbook', 'active_tid'); |
|
2231 | 2229 | if ($active_tid && strtoupper($active_tid) === 'D') unset($active_tid); |
2232 | - $content['tid'] = $_GET['typeid'] ? $_GET['typeid'] : ($active_tid?$active_tid:$new_type[0]); |
|
2233 | - foreach($this->get_contact_columns() as $field) |
|
2230 | + $content['tid'] = $_GET['typeid'] ? $_GET['typeid'] : ($active_tid ? $active_tid : $new_type[0]); |
|
2231 | + foreach ($this->get_contact_columns() as $field) |
|
2234 | 2232 | { |
2235 | 2233 | if ($_GET['presets'][$field]) |
2236 | 2234 | { |
2237 | - if ($field=='email'||$field=='email_home') |
|
2235 | + if ($field == 'email' || $field == 'email_home') |
|
2238 | 2236 | { |
2239 | - $singleAddress = imap_rfc822_parse_adrlist($_GET['presets'][$field],''); |
|
2237 | + $singleAddress = imap_rfc822_parse_adrlist($_GET['presets'][$field], ''); |
|
2240 | 2238 | //error_log(__METHOD__.__LINE__.' Address:'.$singleAddress[0]->mailbox."@".$singleAddress[0]->host.", ".$singleAddress[0]->personal); |
2241 | - if (!(!is_array($singleAddress) || count($singleAddress)<1)) |
|
2239 | + if (!(!is_array($singleAddress) || count($singleAddress) < 1)) |
|
2242 | 2240 | { |
2243 | 2241 | $content[$field] = $singleAddress[0]->mailbox."@".$singleAddress[0]->host; |
2244 | 2242 | if (!empty($singleAddress[0]->personal)) |
2245 | 2243 | { |
2246 | - if (strpos($singleAddress[0]->personal,',')===false) |
|
2244 | + if (strpos($singleAddress[0]->personal, ',') === false) |
|
2247 | 2245 | { |
2248 | - list($P_n_given,$P_n_family,$P_org_name)=explode(' ',$singleAddress[0]->personal,3); |
|
2249 | - if (strlen(trim($P_n_given))>0) $content['n_given'] = trim($P_n_given); |
|
2250 | - if (strlen(trim($P_n_family))>0) $content['n_family'] = trim($P_n_family); |
|
2251 | - if (strlen(trim($P_org_name))>0) $content['org_name'] = trim($P_org_name); |
|
2246 | + list($P_n_given, $P_n_family, $P_org_name) = explode(' ', $singleAddress[0]->personal, 3); |
|
2247 | + if (strlen(trim($P_n_given)) > 0) $content['n_given'] = trim($P_n_given); |
|
2248 | + if (strlen(trim($P_n_family)) > 0) $content['n_family'] = trim($P_n_family); |
|
2249 | + if (strlen(trim($P_org_name)) > 0) $content['org_name'] = trim($P_org_name); |
|
2252 | 2250 | } |
2253 | 2251 | else |
2254 | 2252 | { |
2255 | - list($P_n_family,$P_other)=explode(',',$singleAddress[0]->personal,2); |
|
2256 | - if (strlen(trim($P_n_family))>0) $content['n_family'] = trim($P_n_family); |
|
2257 | - if (strlen(trim($P_other))>0) |
|
2253 | + list($P_n_family, $P_other) = explode(',', $singleAddress[0]->personal, 2); |
|
2254 | + if (strlen(trim($P_n_family)) > 0) $content['n_family'] = trim($P_n_family); |
|
2255 | + if (strlen(trim($P_other)) > 0) |
|
2258 | 2256 | { |
2259 | - list($P_n_given,$P_org_name)=explode(',',$P_other,2); |
|
2260 | - if (strlen(trim($P_n_given))>0) $content['n_given'] = trim($P_n_given); |
|
2261 | - if (strlen(trim($P_org_name))>0) $content['org_name'] = trim($P_org_name); |
|
2257 | + list($P_n_given, $P_org_name) = explode(',', $P_other, 2); |
|
2258 | + if (strlen(trim($P_n_given)) > 0) $content['n_given'] = trim($P_n_given); |
|
2259 | + if (strlen(trim($P_org_name)) > 0) $content['org_name'] = trim($P_org_name); |
|
2262 | 2260 | } |
2263 | 2261 | } |
2264 | 2262 | } |
@@ -2276,13 +2274,13 @@ discard block |
||
2276 | 2274 | } |
2277 | 2275 | if (isset($_GET['presets'])) |
2278 | 2276 | { |
2279 | - foreach(array('email','email_home','n_family','n_given','org_name') as $field) |
|
2277 | + foreach (array('email', 'email_home', 'n_family', 'n_given', 'org_name') as $field) |
|
2280 | 2278 | { |
2281 | 2279 | if (!empty($content[$field])) |
2282 | 2280 | { |
2283 | 2281 | //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 |
2284 | 2282 | // after save/apply we unset them |
2285 | - $content['presets_fields'][]= $field; |
|
2283 | + $content['presets_fields'][] = $field; |
|
2286 | 2284 | break; |
2287 | 2285 | } |
2288 | 2286 | } |
@@ -2294,12 +2292,12 @@ discard block |
||
2294 | 2292 | //_debug_array($content); |
2295 | 2293 | } |
2296 | 2294 | |
2297 | - if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']); // dont allow HTML! |
|
2295 | + if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']); // dont allow HTML! |
|
2298 | 2296 | |
2299 | - if($content && $_GET['makecp']) // copy the contact |
|
2297 | + if ($content && $_GET['makecp']) // copy the contact |
|
2300 | 2298 | { |
2301 | 2299 | $this->copy_contact($content); |
2302 | - $content['msg'] = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('addressbook','entry'))); |
|
2300 | + $content['msg'] = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('addressbook', 'entry'))); |
|
2303 | 2301 | $view = false; |
2304 | 2302 | } |
2305 | 2303 | else |
@@ -2310,12 +2308,12 @@ discard block |
||
2310 | 2308 | if (!$contact_id && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id']) && !is_array($content['link_to']['to_id'])) |
2311 | 2309 | { |
2312 | 2310 | $link_ids = is_array($_REQUEST['link_id']) ? $_REQUEST['link_id'] : array($_REQUEST['link_id']); |
2313 | - foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
|
2311 | + foreach (is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
|
2314 | 2312 | { |
2315 | 2313 | $link_id = $link_ids[$n]; |
2316 | - if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) // gard against XSS |
|
2314 | + if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i', $link_app.':'.$link_id)) // gard against XSS |
|
2317 | 2315 | { |
2318 | - Link::link('addressbook',$content['link_to']['to_id'],$link_app,$link_id); |
|
2316 | + Link::link('addressbook', $content['link_to']['to_id'], $link_app, $link_id); |
|
2319 | 2317 | } |
2320 | 2318 | } |
2321 | 2319 | } |
@@ -2323,8 +2321,8 @@ discard block |
||
2323 | 2321 | if ($content['id']) |
2324 | 2322 | { |
2325 | 2323 | // last and next calendar date |
2326 | - $dates = current($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']),false)); |
|
2327 | - if(is_array($dates)) $content += $dates; |
|
2324 | + $dates = current($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']), false)); |
|
2325 | + if (is_array($dates)) $content += $dates; |
|
2328 | 2326 | } |
2329 | 2327 | |
2330 | 2328 | // Registry has view_id as contact_id, so set it (custom fields uses it) |
@@ -2335,7 +2333,7 @@ discard block |
||
2335 | 2333 | |
2336 | 2334 | // Avoid setting conflicts with private custom fields |
2337 | 2335 | $content['private_cfs'] = array(); |
2338 | - foreach(Api\Storage\Customfields::get('addressbook', true) as $name => $cf) |
|
2336 | + foreach (Api\Storage\Customfields::get('addressbook', true) as $name => $cf) |
|
2339 | 2337 | { |
2340 | 2338 | if ($this->config['private_cf_tab'] && $cf['private'] && isset($content['#'.$name])) |
2341 | 2339 | { |
@@ -2348,7 +2346,7 @@ discard block |
||
2348 | 2346 | $content['addr_format2'] = $this->addr_format_by_country($content['adr_two_countryname']); |
2349 | 2347 | |
2350 | 2348 | //_debug_array($content); |
2351 | - $readonlys['button[delete]'] = !$content['owner'] || !$this->check_perms(Acl::DELETE,$content); |
|
2349 | + $readonlys['button[delete]'] = !$content['owner'] || !$this->check_perms(Acl::DELETE, $content); |
|
2352 | 2350 | $readonlys['button[copy]'] = $readonlys['button[edit]'] = $readonlys['button[vcard]'] = true; |
2353 | 2351 | $readonlys['button[save]'] = $readonlys['button[apply]'] = $view; |
2354 | 2352 | if ($view) |
@@ -2360,19 +2358,18 @@ discard block |
||
2360 | 2358 | $sel_options['fileas_type'] = $this->fileas_options($content); |
2361 | 2359 | $sel_options['adr_one_countrycode']['-custom-'] = lang('Custom'); |
2362 | 2360 | $sel_options['owner'] = $this->get_addressbooks(Acl::ADD); |
2363 | - if ($content['owner']) unset($sel_options['owner'][0]); // do not offer to switch to accounts, as we do not support moving contacts to accounts |
|
2364 | - if ((string) $content['owner'] !== '') |
|
2361 | + if ($content['owner']) unset($sel_options['owner'][0]); // do not offer to switch to accounts, as we do not support moving contacts to accounts |
|
2362 | + if ((string)$content['owner'] !== '') |
|
2365 | 2363 | { |
2366 | 2364 | if (!isset($sel_options['owner'][(int)$content['owner']])) |
2367 | 2365 | { |
2368 | - $sel_options['owner'][(int)$content['owner']] = !$content['owner'] ? lang('Accounts') : |
|
2369 | - Api\Accounts::username($content['owner']); |
|
2366 | + $sel_options['owner'][(int)$content['owner']] = !$content['owner'] ? lang('Accounts') : Api\Accounts::username($content['owner']); |
|
2370 | 2367 | } |
2371 | - $readonlys['owner'] = !$content['owner'] || // dont allow to move accounts, as this mean deleting the user incl. all content he owns |
|
2372 | - $content['id'] && !$this->check_perms(Acl::DELETE,$content); // you need delete rights to move an existing contact into an other addressbook |
|
2368 | + $readonlys['owner'] = !$content['owner'] || // dont allow to move accounts, as this mean deleting the user incl. all content he owns |
|
2369 | + $content['id'] && !$this->check_perms(Acl::DELETE, $content); // you need delete rights to move an existing contact into an other addressbook |
|
2373 | 2370 | } |
2374 | 2371 | // set the unsupported fields from the backend to readonly |
2375 | - foreach($this->get_fields('unsupported',$content['id'],$content['owner']) as $field) |
|
2372 | + foreach ($this->get_fields('unsupported', $content['id'], $content['owner']) as $field) |
|
2376 | 2373 | { |
2377 | 2374 | $readonlys[$field] = true; |
2378 | 2375 | } |
@@ -2382,7 +2379,7 @@ discard block |
||
2382 | 2379 | $readonlys['__ALL__'] = true; |
2383 | 2380 | $readonlys['button[cancel]'] = false; |
2384 | 2381 | |
2385 | - foreach($this->own_account_acl as $field) |
|
2382 | + foreach ($this->own_account_acl as $field) |
|
2386 | 2383 | { |
2387 | 2384 | $readonlys[$field] = false; |
2388 | 2385 | } |
@@ -2404,9 +2401,9 @@ discard block |
||
2404 | 2401 | if (isset($readonlys['n_fileas'])) $readonlys['fileas_type'] = $readonlys['n_fileas']; |
2405 | 2402 | // disable not needed tabs |
2406 | 2403 | $readonlys['tabs']['cats'] = !($content['cat_tab'] = $this->config['cat_tab']); |
2407 | - $readonlys['tabs']['custom'] = !$this->customfields || $this->get_backend($content['id'],$content['owner']) == $this->so_accounts; |
|
2404 | + $readonlys['tabs']['custom'] = !$this->customfields || $this->get_backend($content['id'], $content['owner']) == $this->so_accounts; |
|
2408 | 2405 | $readonlys['tabs']['custom_private'] = $readonlys['tabs']['custom'] || !$this->config['private_cf_tab']; |
2409 | - $readonlys['tabs']['distribution_list'] = !$content['distrib_lists'];#false; |
|
2406 | + $readonlys['tabs']['distribution_list'] = !$content['distrib_lists']; #false; |
|
2410 | 2407 | $readonlys['tabs']['history'] = $this->contact_repository != 'sql' || !$content['id'] || |
2411 | 2408 | $this->account_repository != 'sql' && $content['account_id']; |
2412 | 2409 | if (!$content['id']) $readonlys['button[delete]'] = !$content['id']; |
@@ -2418,7 +2415,7 @@ discard block |
||
2418 | 2415 | { |
2419 | 2416 | $this->_set_readonlys_for_own_account_acl($readonlys, $content['id']); |
2420 | 2417 | } |
2421 | - for($i = -23; $i<=23; $i++) |
|
2418 | + for ($i = -23; $i <= 23; $i++) |
|
2422 | 2419 | { |
2423 | 2420 | $tz[$i] = ($i > 0 ? '+' : '').$i; |
2424 | 2421 | } |
@@ -2426,11 +2423,11 @@ discard block |
||
2426 | 2423 | $content['tz'] = $content['tz'] ? $content['tz'] : '0'; |
2427 | 2424 | if (count($this->content_types) > 1) |
2428 | 2425 | { |
2429 | - foreach($this->content_types as $type => $data) |
|
2426 | + foreach ($this->content_types as $type => $data) |
|
2430 | 2427 | { |
2431 | 2428 | $sel_options['tid'][$type] = $data['name']; |
2432 | 2429 | } |
2433 | - $content['typegfx'] = Api\Html::image('addressbook',$this->content_types[$content['tid']]['options']['icon'],'',' width="16px" height="16px"'); |
|
2430 | + $content['typegfx'] = Api\Html::image('addressbook', $this->content_types[$content['tid']]['options']['icon'], '', ' width="16px" height="16px"'); |
|
2434 | 2431 | } |
2435 | 2432 | else |
2436 | 2433 | { |
@@ -2444,10 +2441,10 @@ discard block |
||
2444 | 2441 | ); |
2445 | 2442 | |
2446 | 2443 | // Links for deleted entries |
2447 | - if($content['tid'] == self::DELETED_TYPE) |
|
2444 | + if ($content['tid'] == self::DELETED_TYPE) |
|
2448 | 2445 | { |
2449 | 2446 | $content['link_to']['show_deleted'] = true; |
2450 | - if(!$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge') |
|
2447 | + if (!$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge') |
|
2451 | 2448 | { |
2452 | 2449 | $readonlys['button[delete]'] = true; |
2453 | 2450 | } |
@@ -2456,12 +2453,12 @@ discard block |
||
2456 | 2453 | // Enable history |
2457 | 2454 | $this->setup_history($content, $sel_options); |
2458 | 2455 | |
2459 | - $content['photo'] = $this->photo_src($content['id'],$content['jpegphoto'],'',$content['etag']); |
|
2456 | + $content['photo'] = $this->photo_src($content['id'], $content['jpegphoto'], '', $content['etag']); |
|
2460 | 2457 | |
2461 | 2458 | if ($content['private']) $content['owner'] .= 'p'; |
2462 | 2459 | |
2463 | 2460 | // for custom types, check if we have a custom edit template named "addressbook.edit.$type", $type is the name |
2464 | - if (in_array($content['tid'], array('n',self::DELETED_TYPE)) || !$this->tmpl->read('addressbook.edit.'.$this->content_types[$content['tid']]['name'])) |
|
2461 | + if (in_array($content['tid'], array('n', self::DELETED_TYPE)) || !$this->tmpl->read('addressbook.edit.'.$this->content_types[$content['tid']]['name'])) |
|
2465 | 2462 | { |
2466 | 2463 | $this->tmpl->read('addressbook.edit'); |
2467 | 2464 | } |
@@ -2469,21 +2466,21 @@ discard block |
||
2469 | 2466 | // allow other apps to add tabs to addressbook edit |
2470 | 2467 | $preserve = $content; |
2471 | 2468 | $preserve['old_owner'] = $content['owner']; |
2472 | - unset($preserve['jpegphoto'], $content['jpegphoto']); // unused and messes up json encoding (not utf-8) |
|
2469 | + unset($preserve['jpegphoto'], $content['jpegphoto']); // unused and messes up json encoding (not utf-8) |
|
2473 | 2470 | $this->tmpl->setElementAttribute('tabs', 'add_tabs', true); |
2474 | - $tabs =& $this->tmpl->getElementAttribute('tabs', 'tabs'); |
|
2471 | + $tabs = & $this->tmpl->getElementAttribute('tabs', 'tabs'); |
|
2475 | 2472 | if (($first_call = !isset($tabs))) |
2476 | 2473 | { |
2477 | 2474 | $tabs = array(); |
2478 | 2475 | } |
2479 | 2476 | //error_log(__LINE__.': '.__METHOD__."() first_call=$first_call"); |
2480 | - $hook_data = Api\Hooks::process(array('location' => 'addressbook_edit')+$content); |
|
2477 | + $hook_data = Api\Hooks::process(array('location' => 'addressbook_edit') + $content); |
|
2481 | 2478 | //error_log(__METHOD__."() hook_data=".array2string($hook_data)); |
2482 | - foreach($hook_data as $extra_tabs) |
|
2479 | + foreach ($hook_data as $extra_tabs) |
|
2483 | 2480 | { |
2484 | 2481 | if (!$extra_tabs) continue; |
2485 | 2482 | |
2486 | - foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
|
2483 | + foreach (isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
|
2487 | 2484 | { |
2488 | 2485 | if ($extra_tab['data'] && is_array($extra_tab['data'])) |
2489 | 2486 | { |
@@ -2528,15 +2525,15 @@ discard block |
||
2528 | 2525 | * @param array &$readonlys |
2529 | 2526 | * @param int $id |
2530 | 2527 | */ |
2531 | - function _set_readonlys_for_own_account_acl(&$readonlys,$id) |
|
2528 | + function _set_readonlys_for_own_account_acl(&$readonlys, $id) |
|
2532 | 2529 | { |
2533 | 2530 | // regular fields depending on the backend |
2534 | - foreach($this->get_fields('supported',$id,0) as $field) |
|
2531 | + foreach ($this->get_fields('supported', $id, 0) as $field) |
|
2535 | 2532 | { |
2536 | - if (!$this->own_account_acl || !in_array($field,$this->own_account_acl)) |
|
2533 | + if (!$this->own_account_acl || !in_array($field, $this->own_account_acl)) |
|
2537 | 2534 | { |
2538 | 2535 | $readonlys[$field] = true; |
2539 | - switch($field) |
|
2536 | + switch ($field) |
|
2540 | 2537 | { |
2541 | 2538 | case 'tel_work': |
2542 | 2539 | case 'tel_cell': |
@@ -2552,16 +2549,16 @@ discard block |
||
2552 | 2549 | // custom fields |
2553 | 2550 | if ($this->customfields) |
2554 | 2551 | { |
2555 | - foreach(array_keys($this->customfields) as $name) |
|
2552 | + foreach (array_keys($this->customfields) as $name) |
|
2556 | 2553 | { |
2557 | - if (!$this->own_account_acl || !in_array('#'.$name,$this->own_account_acl)) |
|
2554 | + if (!$this->own_account_acl || !in_array('#'.$name, $this->own_account_acl)) |
|
2558 | 2555 | { |
2559 | 2556 | $readonlys['#'.$name] = true; |
2560 | 2557 | } |
2561 | 2558 | } |
2562 | 2559 | } |
2563 | 2560 | // links |
2564 | - if (!$this->own_account_acl || !in_array('link_to',$this->own_account_acl)) |
|
2561 | + if (!$this->own_account_acl || !in_array('link_to', $this->own_account_acl)) |
|
2565 | 2562 | { |
2566 | 2563 | $readonlys['link_to'] = true; |
2567 | 2564 | } |
@@ -2579,9 +2576,9 @@ discard block |
||
2579 | 2576 | * 'data' => array of id => "full name (addressbook)" pairs |
2580 | 2577 | * 'fileas_options' |
2581 | 2578 | */ |
2582 | - public function ajax_check_values($values, $name, $own_id=0) |
|
2579 | + public function ajax_check_values($values, $name, $own_id = 0) |
|
2583 | 2580 | { |
2584 | - $fields = explode(',',$GLOBALS['egw_info']['user']['preferences']['addressbook']['duplicate_fields']); |
|
2581 | + $fields = explode(',', $GLOBALS['egw_info']['user']['preferences']['addressbook']['duplicate_fields']); |
|
2585 | 2582 | $threshold = (int)$GLOBALS['egw_info']['user']['preferences']['addressbook']['duplicate_threshold']; |
2586 | 2583 | |
2587 | 2584 | $ret = array('doublicates' => array(), 'msg' => null); |
@@ -2606,17 +2603,17 @@ discard block |
||
2606 | 2603 | |
2607 | 2604 | // if name, firstname or org changed and enough are specified, check for doublicates |
2608 | 2605 | $specified_count = 0; |
2609 | - foreach($fields as $field) |
|
2606 | + foreach ($fields as $field) |
|
2610 | 2607 | { |
2611 | - if($values[trim($field)]) |
|
2608 | + if ($values[trim($field)]) |
|
2612 | 2609 | { |
2613 | 2610 | $specified_count++; |
2614 | 2611 | } |
2615 | 2612 | } |
2616 | - if (in_array($name,$fields) && $specified_count >= $threshold) |
|
2613 | + if (in_array($name, $fields) && $specified_count >= $threshold) |
|
2617 | 2614 | { |
2618 | 2615 | $filter = array(); |
2619 | - foreach($fields as $n) // use email too, to exclude obvious false positives |
|
2616 | + foreach ($fields as $n) // use email too, to exclude obvious false positives |
|
2620 | 2617 | { |
2621 | 2618 | if (!empty($values[$n])) $filter[$n] = $values[$n]; |
2622 | 2619 | } |
@@ -2625,7 +2622,7 @@ discard block |
||
2625 | 2622 | } |
2626 | 2623 | if ($contacts) |
2627 | 2624 | { |
2628 | - foreach($contacts as $contact) |
|
2625 | + foreach ($contacts as $contact) |
|
2629 | 2626 | { |
2630 | 2627 | if ($own_id && $contact['id'] == $own_id) continue; |
2631 | 2628 | |
@@ -2649,26 +2646,24 @@ discard block |
||
2649 | 2646 | * |
2650 | 2647 | * @param array $content |
2651 | 2648 | */ |
2652 | - function view(array $content=null) |
|
2649 | + function view(array $content = null) |
|
2653 | 2650 | { |
2654 | 2651 | // CRM list comes from content, request, or preference |
2655 | - $crm_list = $content['crm_list'] ? $content['crm_list'] : |
|
2656 | - ($_GET['crm_list'] ? $_GET['crm_list'] : $GLOBALS['egw_info']['user']['preferences']['addressbook']['crm_list']); |
|
2657 | - if(!$crm_list || $crm_list == '~edit~') $crm_list = 'infolog'; |
|
2652 | + $crm_list = $content['crm_list'] ? $content['crm_list'] : ($_GET['crm_list'] ? $_GET['crm_list'] : $GLOBALS['egw_info']['user']['preferences']['addressbook']['crm_list']); |
|
2653 | + if (!$crm_list || $crm_list == '~edit~') $crm_list = 'infolog'; |
|
2658 | 2654 | |
2659 | - if(is_array($content)) |
|
2655 | + if (is_array($content)) |
|
2660 | 2656 | { |
2661 | 2657 | $button = key($content['button']); |
2662 | 2658 | switch ($content['toolbar'] ? $content['toolbar'] : $button) |
2663 | 2659 | { |
2664 | - case 'vcard': |
|
2665 | - Egw::redirect_link('/index.php','menuaction=addressbook.uivcard.out&ab_id=' .$content['id']); |
|
2660 | + case 'vcard' : Egw::redirect_link('/index.php', 'menuaction=addressbook.uivcard.out&ab_id='.$content['id']); |
|
2666 | 2661 | |
2667 | 2662 | case 'cancel': |
2668 | - Egw::redirect_link('/index.php','menuaction=addressbook.addressbook_ui.index&ajax=true'); |
|
2663 | + Egw::redirect_link('/index.php', 'menuaction=addressbook.addressbook_ui.index&ajax=true'); |
|
2669 | 2664 | |
2670 | 2665 | case 'delete': |
2671 | - Egw::redirect_link('/index.php',array( |
|
2666 | + Egw::redirect_link('/index.php', array( |
|
2672 | 2667 | 'menuaction' => 'addressbook.addressbook_ui.index', |
2673 | 2668 | 'msg' => $this->delete($content) ? lang('Contact deleted') : lang('Error deleting the contact !!!'), |
2674 | 2669 | )); |
@@ -2686,9 +2681,9 @@ discard block |
||
2686 | 2681 | $num_rows = $this->get_rows($query, $rows, $readonlys, true); |
2687 | 2682 | //error_log(__METHOD__."() get_rows()=$num_rows rows=".array2string($rows)); |
2688 | 2683 | $contact_id = $rows[0]; |
2689 | - if(!$contact_id || !is_array($content = $this->read($contact_id))) |
|
2684 | + if (!$contact_id || !is_array($content = $this->read($contact_id))) |
|
2690 | 2685 | { |
2691 | - Egw::redirect_link('/index.php',array( |
|
2686 | + Egw::redirect_link('/index.php', array( |
|
2692 | 2687 | 'menuaction' => 'addressbook.addressbook_ui.index', |
2693 | 2688 | 'msg' => $content, |
2694 | 2689 | 'ajax' => 'true' |
@@ -2697,9 +2692,9 @@ discard block |
||
2697 | 2692 | $content['index'] = $query['start']; |
2698 | 2693 | |
2699 | 2694 | // List nextmatch is already there, just update the filter |
2700 | - if($contact_id && Api\Json\Request::isJSONRequest()) |
|
2695 | + if ($contact_id && Api\Json\Request::isJSONRequest()) |
|
2701 | 2696 | { |
2702 | - switch($crm_list) |
|
2697 | + switch ($crm_list) |
|
2703 | 2698 | { |
2704 | 2699 | case 'infolog-organisation': |
2705 | 2700 | $contact_id = $this->get_all_org_contacts($contact_id); |
@@ -2707,7 +2702,7 @@ discard block |
||
2707 | 2702 | case 'infolog': |
2708 | 2703 | case 'tracker': |
2709 | 2704 | default: |
2710 | - Api\Json\Response::get()->apply('app.addressbook.view_set_list',Array(Array('action'=>'addressbook', 'action_id' => $contact_id))); |
|
2705 | + Api\Json\Response::get()->apply('app.addressbook.view_set_list', Array(Array('action'=>'addressbook', 'action_id' => $contact_id))); |
|
2711 | 2706 | break; |
2712 | 2707 | } |
2713 | 2708 | |
@@ -2738,13 +2733,13 @@ discard block |
||
2738 | 2733 | $_GET['index'] = 0; |
2739 | 2734 | } |
2740 | 2735 | $contact_id = $_GET['contact_id'] ? $_GET['contact_id'] : ((int)$_GET['account_id'] ? 'account:'.(int)$_GET['account_id'] : 0); |
2741 | - if(!$contact_id || !is_array($content = $this->read($contact_id))) |
|
2736 | + if (!$contact_id || !is_array($content = $this->read($contact_id))) |
|
2742 | 2737 | { |
2743 | - Egw::redirect_link('/index.php',array( |
|
2738 | + Egw::redirect_link('/index.php', array( |
|
2744 | 2739 | 'menuaction' => 'addressbook.addressbook_ui.index', |
2745 | 2740 | 'msg' => $content, |
2746 | 2741 | 'ajax' => 'true' |
2747 | - )+(isset($_GET['search']) ? array('search' => $_GET['search']) : array())); |
|
2742 | + ) + (isset($_GET['search']) ? array('search' => $_GET['search']) : array())); |
|
2748 | 2743 | } |
2749 | 2744 | if (isset($_GET['index'])) |
2750 | 2745 | { |
@@ -2757,25 +2752,25 @@ discard block |
||
2757 | 2752 | $num_rows = $this->get_rows($query, $rows, $readonlys, true); |
2758 | 2753 | } |
2759 | 2754 | } |
2760 | - $content['jpegphoto'] = !empty($content['jpegphoto']); // unused and messes up json encoding (not utf-8) |
|
2755 | + $content['jpegphoto'] = !empty($content['jpegphoto']); // unused and messes up json encoding (not utf-8) |
|
2761 | 2756 | |
2762 | 2757 | // make everything not explicit mentioned readonly |
2763 | 2758 | $readonlys['__ALL__'] = true; |
2764 | 2759 | $readonlys['photo'] = $readonlys['button[cancel]'] = $readonlys['button[copy]'] = |
2765 | 2760 | $readonlys['button[ok]'] = $readonlys['button[more]'] = $readonlys['toolbar'] = false; |
2766 | 2761 | |
2767 | - foreach(array_keys($this->contact_fields) as $key) |
|
2762 | + foreach (array_keys($this->contact_fields) as $key) |
|
2768 | 2763 | { |
2769 | - if (in_array($key,array('tel_home','tel_work','tel_cell','tel_fax'))) |
|
2764 | + if (in_array($key, array('tel_home', 'tel_work', 'tel_cell', 'tel_fax'))) |
|
2770 | 2765 | { |
2771 | 2766 | $content[$key.'2'] = $content[$key]; |
2772 | 2767 | } |
2773 | 2768 | } |
2774 | 2769 | |
2775 | 2770 | // respect category permissions |
2776 | - if(!empty($content['cat_id'])) |
|
2771 | + if (!empty($content['cat_id'])) |
|
2777 | 2772 | { |
2778 | - $content['cat_id'] = $this->categories->check_list(Acl::READ,$content['cat_id']); |
|
2773 | + $content['cat_id'] = $this->categories->check_list(Acl::READ, $content['cat_id']); |
|
2779 | 2774 | } |
2780 | 2775 | $content['cat_id_tree'] = $content['cat_id']; |
2781 | 2776 | |
@@ -2785,12 +2780,12 @@ discard block |
||
2785 | 2780 | 'to_id' => $content['id'], |
2786 | 2781 | ); |
2787 | 2782 | // Links for deleted entries |
2788 | - if($content['tid'] == self::DELETED_TYPE) |
|
2783 | + if ($content['tid'] == self::DELETED_TYPE) |
|
2789 | 2784 | { |
2790 | 2785 | $content['link_to']['show_deleted'] = true; |
2791 | 2786 | } |
2792 | - $readonlys['button[delete]'] = !$content['owner'] || !$this->check_perms(Acl::DELETE,$content); |
|
2793 | - $readonlys['button[edit]'] = !$this->check_perms(Acl::EDIT,$content); |
|
2787 | + $readonlys['button[delete]'] = !$content['owner'] || !$this->check_perms(Acl::DELETE, $content); |
|
2788 | + $readonlys['button[edit]'] = !$this->check_perms(Acl::EDIT, $content); |
|
2794 | 2789 | |
2795 | 2790 | // how to display addresses |
2796 | 2791 | $content['addr_format'] = $this->addr_format_by_country($content['adr_one_countryname']); |
@@ -2798,7 +2793,7 @@ discard block |
||
2798 | 2793 | |
2799 | 2794 | $sel_options['fileas_type'][$content['fileas_type']] = $this->fileas($content); |
2800 | 2795 | $sel_options['owner'] = $this->get_addressbooks(); |
2801 | - for($i = -23; $i<=23; $i++) |
|
2796 | + for ($i = -23; $i <= 23; $i++) |
|
2802 | 2797 | { |
2803 | 2798 | $tz[$i] = ($i > 0 ? '+' : '').$i; |
2804 | 2799 | } |
@@ -2806,11 +2801,11 @@ discard block |
||
2806 | 2801 | $content['tz'] = $content['tz'] ? $content['tz'] : 0; |
2807 | 2802 | if (count($this->content_types) > 1) |
2808 | 2803 | { |
2809 | - foreach($this->content_types as $type => $data) |
|
2804 | + foreach ($this->content_types as $type => $data) |
|
2810 | 2805 | { |
2811 | 2806 | $sel_options['tid'][$type] = $data['name']; |
2812 | 2807 | } |
2813 | - $content['typegfx'] = Api\Html::image('addressbook',$this->content_types[$content['tid']]['options']['icon'],'',' width="16px" height="16px"'); |
|
2808 | + $content['typegfx'] = Api\Html::image('addressbook', $this->content_types[$content['tid']]['options']['icon'], '', ' width="16px" height="16px"'); |
|
2814 | 2809 | } |
2815 | 2810 | else |
2816 | 2811 | { |
@@ -2827,7 +2822,7 @@ discard block |
||
2827 | 2822 | { |
2828 | 2823 | $content['owner'] .= 'p'; |
2829 | 2824 | } |
2830 | - $this->tmpl->set_cell_attribute('change_org','disabled',true); |
|
2825 | + $this->tmpl->set_cell_attribute('change_org', 'disabled', true); |
|
2831 | 2826 | |
2832 | 2827 | // Prevent double countries - invalid code blanks it, disabling doesn't work |
2833 | 2828 | $content['adr_one_countrycode'] = '-'; |
@@ -2840,14 +2835,14 @@ discard block |
||
2840 | 2835 | $readonlys['tabs']['cats'] = !($content['cat_tab'] = $this->config['cat_tab']); |
2841 | 2836 | $readonlys['tabs']['custom'] = !$this->customfields; |
2842 | 2837 | $readonlys['tabs']['custom_private'] = !$this->customfields || !$this->config['private_cf_tab']; |
2843 | - $readonlys['tabs']['distribution_list'] = !$content['distrib_lists'];#false; |
|
2838 | + $readonlys['tabs']['distribution_list'] = !$content['distrib_lists']; #false; |
|
2844 | 2839 | $readonlys['tabs']['history'] = $this->contact_repository != 'sql' || !$content['id'] || |
2845 | 2840 | $this->account_repository != 'sql' && $content['account_id']; |
2846 | 2841 | if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0; |
2847 | 2842 | |
2848 | 2843 | // last and next calendar date |
2849 | - if (!empty($content['id'])) $dates = current($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']),false)); |
|
2850 | - if(is_array($dates)) $content += $dates; |
|
2844 | + if (!empty($content['id'])) $dates = current($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']), false)); |
|
2845 | + if (is_array($dates)) $content += $dates; |
|
2851 | 2846 | |
2852 | 2847 | // Disable importexport |
2853 | 2848 | $GLOBALS['egw_info']['flags']['disable_importexport']['export'] = true; |
@@ -2890,7 +2885,7 @@ discard block |
||
2890 | 2885 | { |
2891 | 2886 | unset($actions['back']); |
2892 | 2887 | } |
2893 | - if (!isset($content['index']) || $content['index'] >= $num_rows-1) |
|
2888 | + if (!isset($content['index']) || $content['index'] >= $num_rows - 1) |
|
2894 | 2889 | { |
2895 | 2890 | unset($actions['next']); |
2896 | 2891 | } |
@@ -2902,7 +2897,7 @@ discard block |
||
2902 | 2897 | // need to load list's app.js now, as exec calls header before other app can include it |
2903 | 2898 | Framework::includeJS('/'.$crm_list.'/js/app.js'); |
2904 | 2899 | |
2905 | - $this->tmpl->exec('addressbook.addressbook_ui.view',$content,$sel_options,$readonlys,array( |
|
2900 | + $this->tmpl->exec('addressbook.addressbook_ui.view', $content, $sel_options, $readonlys, array( |
|
2906 | 2901 | 'id' => $content['id'], |
2907 | 2902 | 'index' => $content['index'], |
2908 | 2903 | 'crm_list' => $crm_list |
@@ -2910,19 +2905,19 @@ discard block |
||
2910 | 2905 | |
2911 | 2906 | // Only load this on first time - we're using AJAX, so it stays there through submits. |
2912 | 2907 | // Sending it again (via ajax) will break the addressbook.view etemplate2 |
2913 | - if($contact_id) |
|
2908 | + if ($contact_id) |
|
2914 | 2909 | { |
2915 | 2910 | // Show for whole organisation, not just selected contact |
2916 | - if($crm_list == 'infolog-organisation') |
|
2911 | + if ($crm_list == 'infolog-organisation') |
|
2917 | 2912 | { |
2918 | - $crm_list = str_replace('-organisation','',$crm_list); |
|
2913 | + $crm_list = str_replace('-organisation', '', $crm_list); |
|
2919 | 2914 | $_query = Api\Cache::getSession('addressbook', 'index'); |
2920 | 2915 | $content['id'] = $this->get_all_org_contacts($content['id']); |
2921 | 2916 | } |
2922 | 2917 | Api\Hooks::single(array( |
2923 | 2918 | 'location' => 'addressbook_view', |
2924 | 2919 | 'ab_id' => $content['id'] |
2925 | - ),$crm_list); |
|
2920 | + ), $crm_list); |
|
2926 | 2921 | } |
2927 | 2922 | } |
2928 | 2923 | |
@@ -2939,18 +2934,18 @@ discard block |
||
2939 | 2934 | $contact = $this->read($contact_id); |
2940 | 2935 | |
2941 | 2936 | // No org name, early return with just the contact |
2942 | - if(!$contact['org_name']) |
|
2937 | + if (!$contact['org_name']) |
|
2943 | 2938 | { |
2944 | 2939 | return array($contact_id); |
2945 | 2940 | } |
2946 | 2941 | |
2947 | 2942 | $query['num_rows'] = -1; |
2948 | 2943 | $query['start'] = 0; |
2949 | - if(!array_key_exists('filter', $query)) |
|
2944 | + if (!array_key_exists('filter', $query)) |
|
2950 | 2945 | { |
2951 | 2946 | $query['filter'] = ''; |
2952 | 2947 | } |
2953 | - if(!is_array($query['col_filter'])) |
|
2948 | + if (!is_array($query['col_filter'])) |
|
2954 | 2949 | { |
2955 | 2950 | $query['col_filter'] = array(); |
2956 | 2951 | } |
@@ -2958,7 +2953,7 @@ discard block |
||
2958 | 2953 | |
2959 | 2954 | $org_contacts = array(); |
2960 | 2955 | $readonlys = null; |
2961 | - $this->get_rows($query,$org_contacts,$readonlys,true); // true = only return the id's |
|
2956 | + $this->get_rows($query, $org_contacts, $readonlys, true); // true = only return the id's |
|
2962 | 2957 | |
2963 | 2958 | return $org_contacts ? $org_contacts : array($contact_id); |
2964 | 2959 | } |
@@ -2971,30 +2966,30 @@ discard block |
||
2971 | 2966 | */ |
2972 | 2967 | function email2link($email) |
2973 | 2968 | { |
2974 | - if (strpos($email,'@') == false) return ''; |
|
2969 | + if (strpos($email, '@') == false) return ''; |
|
2975 | 2970 | |
2976 | - if($GLOBALS['egw_info']['user']['apps']['mail']) |
|
2971 | + if ($GLOBALS['egw_info']['user']['apps']['mail']) |
|
2977 | 2972 | { |
2978 | 2973 | return array( |
2979 | 2974 | 'menuaction' => 'mail.mail_compose.compose', |
2980 | 2975 | 'send_to' => base64_encode($email) |
2981 | 2976 | ); |
2982 | 2977 | } |
2983 | - if($GLOBALS['egw_info']['user']['apps']['felamimail']) |
|
2978 | + if ($GLOBALS['egw_info']['user']['apps']['felamimail']) |
|
2984 | 2979 | { |
2985 | 2980 | return array( |
2986 | 2981 | 'menuaction' => 'felamimail.uicompose.compose', |
2987 | 2982 | 'send_to' => base64_encode($email) |
2988 | 2983 | ); |
2989 | 2984 | } |
2990 | - if($GLOBALS['egw_info']['user']['apps']['email']) |
|
2985 | + if ($GLOBALS['egw_info']['user']['apps']['email']) |
|
2991 | 2986 | { |
2992 | 2987 | return array( |
2993 | 2988 | 'menuaction' => 'email.uicompose.compose', |
2994 | 2989 | 'to' => $email, |
2995 | 2990 | ); |
2996 | 2991 | } |
2997 | - return 'mailto:' . $email; |
|
2992 | + return 'mailto:'.$email; |
|
2998 | 2993 | } |
2999 | 2994 | |
3000 | 2995 | /** |
@@ -3003,9 +2998,9 @@ discard block |
||
3003 | 2998 | * @param array $_content |
3004 | 2999 | * @return string |
3005 | 3000 | */ |
3006 | - function search($_content=array()) |
|
3001 | + function search($_content = array()) |
|
3007 | 3002 | { |
3008 | - if(!empty($_content)) |
|
3003 | + if (!empty($_content)) |
|
3009 | 3004 | { |
3010 | 3005 | |
3011 | 3006 | $_content['cat_id'] = $this->config['cat_tab'] === 'Tree' ? $_content['cat_id_tree'] : $_content['cat_id']; |
@@ -3020,10 +3015,10 @@ discard block |
||
3020 | 3015 | } |
3021 | 3016 | else |
3022 | 3017 | { |
3023 | - $query['advanced_search'] = array_intersect_key($_content,array_flip(array_merge($this->get_contact_columns(),array('operator','meth_select')))); |
|
3018 | + $query['advanced_search'] = array_intersect_key($_content, array_flip(array_merge($this->get_contact_columns(), array('operator', 'meth_select')))); |
|
3024 | 3019 | foreach ($query['advanced_search'] as $key => $value) |
3025 | 3020 | { |
3026 | - if(!$value) unset($query['advanced_search'][$key]); |
|
3021 | + if (!$value) unset($query['advanced_search'][$key]); |
|
3027 | 3022 | } |
3028 | 3023 | // Skip n_fn, it causes problems in sql |
3029 | 3024 | unset($query['advanced_search']['n_fn']); |
@@ -3039,7 +3034,7 @@ discard block |
||
3039 | 3034 | $response->call("app.addressbook.adv_search", array('advanced_search' => $_content['button']['search'] ? $query['advanced_search'] : '')); |
3040 | 3035 | if ($_content['button']['cancelsearch']) |
3041 | 3036 | { |
3042 | - Framework::window_close (); |
|
3037 | + Framework::window_close(); |
|
3043 | 3038 | |
3044 | 3039 | // No need to reload popup |
3045 | 3040 | return; |
@@ -3056,7 +3051,7 @@ discard block |
||
3056 | 3051 | // Avoid ID conflict with tree & selectboxes |
3057 | 3052 | $content['cat_id_tree'] = $content['cat_id']; |
3058 | 3053 | |
3059 | - for($i = -23; $i<=23; $i++) |
|
3054 | + for ($i = -23; $i <= 23; $i++) |
|
3060 | 3055 | { |
3061 | 3056 | $tz[$i] = ($i > 0 ? '+' : '').$i; |
3062 | 3057 | } |
@@ -3065,8 +3060,8 @@ discard block |
||
3065 | 3060 | //foreach($this->content_types as $type => $data) $sel_options['tid'][$type] = $data['name']; |
3066 | 3061 | |
3067 | 3062 | // configure search options |
3068 | - $sel_options['owner'] = $this->get_addressbooks(Acl::READ,lang('all')); |
|
3069 | - $sel_options['operator'] = array( |
|
3063 | + $sel_options['owner'] = $this->get_addressbooks(Acl::READ, lang('all')); |
|
3064 | + $sel_options['operator'] = array( |
|
3070 | 3065 | 'AND' => 'AND', |
3071 | 3066 | 'OR' => 'OR', |
3072 | 3067 | ); |
@@ -3076,12 +3071,12 @@ discard block |
||
3076 | 3071 | ); |
3077 | 3072 | if ($this->customfields) |
3078 | 3073 | { |
3079 | - foreach($this->customfields as $name => $data) |
|
3074 | + foreach ($this->customfields as $name => $data) |
|
3080 | 3075 | { |
3081 | 3076 | if (substr($data['type'], 0, 6) == 'select' && !($data['rows'] > 1)) |
3082 | 3077 | { |
3083 | 3078 | if (!isset($content['#'.$name])) $content['#'.$name] = ''; |
3084 | - if(!isset($data['values'][''])) $sel_options['#'.$name][''] = lang('Select one'); |
|
3079 | + if (!isset($data['values'][''])) $sel_options['#'.$name][''] = lang('Select one'); |
|
3085 | 3080 | } |
3086 | 3081 | // Make them not required, otherwise you can't search |
3087 | 3082 | $this->tmpl->setElementAttribute('#'.$name, 'needed', FALSE); |
@@ -3107,8 +3102,8 @@ discard block |
||
3107 | 3102 | |
3108 | 3103 | if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0; |
3109 | 3104 | |
3110 | - $this->tmpl->set_cell_attribute('change_org','disabled',true); |
|
3111 | - return $this->tmpl->exec('addressbook.addressbook_ui.search',$content,$sel_options,$readonlys,array(),2); |
|
3105 | + $this->tmpl->set_cell_attribute('change_org', 'disabled', true); |
|
3106 | + return $this->tmpl->exec('addressbook.addressbook_ui.search', $content, $sel_options, $readonlys, array(), 2); |
|
3112 | 3107 | } |
3113 | 3108 | |
3114 | 3109 | /** |
@@ -3117,12 +3112,12 @@ discard block |
||
3117 | 3112 | * |
3118 | 3113 | * @param type $contact_id |
3119 | 3114 | */ |
3120 | - function ajax_noPhotoExists ($contact_id) |
|
3115 | + function ajax_noPhotoExists($contact_id) |
|
3121 | 3116 | { |
3122 | 3117 | $response = Api\Json\Response::get(); |
3123 | 3118 | $response->data((!($contact = $this->read($contact_id)) || |
3124 | - empty($contact['photo']) && !(($contact['files'] & Api\Contacts::FILES_BIT_PHOTO) && |
|
3125 | - ($size = filesize($url=Api\Link::vfs_path('addressbook', $contact_id, Api\Contacts::FILES_PHOTO)))))); |
|
3119 | + empty($contact['photo']) && !(($contact['files']&Api\Contacts::FILES_BIT_PHOTO) && |
|
3120 | + ($size = filesize($url = Api\Link::vfs_path('addressbook', $contact_id, Api\Contacts::FILES_PHOTO)))))); |
|
3126 | 3121 | } |
3127 | 3122 | |
3128 | 3123 | /** |
@@ -3131,13 +3126,13 @@ discard block |
||
3131 | 3126 | * @param string $etemplate_exec_id to update id, files, etag, ... |
3132 | 3127 | * @param file string $file null means to delete |
3133 | 3128 | */ |
3134 | - function ajax_update_photo ($etemplate_exec_id, $file) |
|
3129 | + function ajax_update_photo($etemplate_exec_id, $file) |
|
3135 | 3130 | { |
3136 | 3131 | $et_request = Api\Etemplate\Request::read($etemplate_exec_id); |
3137 | 3132 | $response = Api\Json\Response::get(); |
3138 | 3133 | if ($file) |
3139 | 3134 | { |
3140 | - $filteredFile = substr($file, strpos($file, ",")+1); |
|
3135 | + $filteredFile = substr($file, strpos($file, ",") + 1); |
|
3141 | 3136 | // resize photo if wider then default width of 240pixel (keeping aspect ratio) |
3142 | 3137 | $decoded = $this->resize_photo(base64_decode($filteredFile)); |
3143 | 3138 | } |
@@ -3145,7 +3140,7 @@ discard block |
||
3145 | 3140 | // add photo into current eT2 request |
3146 | 3141 | $et_request->preserv = array_merge($et_request->preserv, array( |
3147 | 3142 | 'jpegphoto' => is_null($file) ? $file : $decoded, |
3148 | - 'photo_unchanged' => false, // hint photo is changed |
|
3143 | + 'photo_unchanged' => false, // hint photo is changed |
|
3149 | 3144 | )); |
3150 | 3145 | } |
3151 | 3146 | |
@@ -3160,14 +3155,14 @@ discard block |
||
3160 | 3155 | public function pubkey_uploaded(array $file, $widget_id, Api\Etemplate\Request $request, Api\Json\Response $response) |
3161 | 3156 | { |
3162 | 3157 | //error_log(__METHOD__."(".array2string($file).", ...) widget_id=$widget_id, id=".$request->content['id'].", files=".$request->content['files']); |
3163 | - unset($file, $response); // not used, but required by function signature |
|
3164 | - list(,,$path) = explode(':', $widget_id); |
|
3158 | + unset($file, $response); // not used, but required by function signature |
|
3159 | + list(,, $path) = explode(':', $widget_id); |
|
3165 | 3160 | $bit = $path === Api\Contacts::FILES_PGP_PUBKEY ? Api\Contacts::FILES_BIT_PGP_PUBKEY : Api\Contacts::FILES_BIT_SMIME_PUBKEY; |
3166 | - if (!($request->content['files'] & $bit) && $this->check_perms(Acl::EDIT, $request->content)) |
|
3161 | + if (!($request->content['files']&$bit) && $this->check_perms(Acl::EDIT, $request->content)) |
|
3167 | 3162 | { |
3168 | 3163 | $content = $request->content; |
3169 | 3164 | $content['files'] |= $bit; |
3170 | - $content['photo_unchanged'] = true; // hint no need to store photo |
|
3165 | + $content['photo_unchanged'] = true; // hint no need to store photo |
|
3171 | 3166 | if ($this->save($content)) |
3172 | 3167 | { |
3173 | 3168 | $changed = array_diff_assoc($content, $request->content); |
@@ -3215,15 +3210,15 @@ discard block |
||
3215 | 3210 | echo $GLOBALS['egw']->framework->navbar(); |
3216 | 3211 | |
3217 | 3212 | // check if user has admin rights AND if a valid fileas type is given (Security) |
3218 | - if (!$this->is_admin() || $_GET['type'] != '' && !in_array($_GET['type'],$this->fileas_types)) |
|
3213 | + if (!$this->is_admin() || $_GET['type'] != '' && !in_array($_GET['type'], $this->fileas_types)) |
|
3219 | 3214 | { |
3220 | 3215 | echo '<h1>'.lang('Permission denied !!!')."</h1>\n"; |
3221 | 3216 | } |
3222 | 3217 | else |
3223 | 3218 | { |
3224 | 3219 | $errors = null; |
3225 | - $updated = parent::set_all_fileas($_GET['type'],(boolean)$_GET['all'],$errors,true); // true = ignore Acl |
|
3226 | - echo '<p style="margin-top: 20px;"><b>'.lang('%1 contacts updated (%2 errors).',$updated,$errors)."</b></p>\n"; |
|
3220 | + $updated = parent::set_all_fileas($_GET['type'], (boolean)$_GET['all'], $errors, true); // true = ignore Acl |
|
3221 | + echo '<p style="margin-top: 20px;"><b>'.lang('%1 contacts updated (%2 errors).', $updated, $errors)."</b></p>\n"; |
|
3227 | 3222 | } |
3228 | 3223 | echo $GLOBALS['egw']->framework->footer(); |
3229 | 3224 | } |
@@ -3247,8 +3242,8 @@ discard block |
||
3247 | 3242 | else |
3248 | 3243 | { |
3249 | 3244 | $errors = null; |
3250 | - $updated = parent::set_all_cleanup($errors,true); // true = ignore Acl |
|
3251 | - echo '<p style="margin-top: 20px;"><b>'.lang('%1 contacts updated (%2 errors).',$updated,$errors)."</b></p>\n"; |
|
3245 | + $updated = parent::set_all_cleanup($errors, true); // true = ignore Acl |
|
3246 | + echo '<p style="margin-top: 20px;"><b>'.lang('%1 contacts updated (%2 errors).', $updated, $errors)."</b></p>\n"; |
|
3252 | 3247 | } |
3253 | 3248 | echo $GLOBALS['egw']->framework->footer(); |
3254 | 3249 | } |
@@ -3261,7 +3256,7 @@ discard block |
||
3261 | 3256 | if ($this->contact_repository == 'ldap' || !$content['id'] || |
3262 | 3257 | $this->account_repository == 'ldap' && $content['account_id']) |
3263 | 3258 | { |
3264 | - return; // no history for ldap as history table only allows integer id's |
|
3259 | + return; // no history for ldap as history table only allows integer id's |
|
3265 | 3260 | } |
3266 | 3261 | $content['history'] = array( |
3267 | 3262 | 'id' => $content['id'], |
@@ -3276,7 +3271,7 @@ discard block |
||
3276 | 3271 | ), |
3277 | 3272 | ); |
3278 | 3273 | |
3279 | - foreach($this->content_types as $id => $settings) |
|
3274 | + foreach ($this->content_types as $id => $settings) |
|
3280 | 3275 | { |
3281 | 3276 | $content['history']['status-widgets']['tid'][$id] = $settings['name']; |
3282 | 3277 | } |
@@ -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 | |
@@ -129,15 +132,21 @@ discard block |
||
129 | 132 | if (($re_submit = is_array($_content))) |
130 | 133 | { |
131 | 134 | |
132 | - if (isset($_content['nm']['rows']['delete'])) // handle a single delete like delete with the checkboxes |
|
135 | + if (isset($_content['nm']['rows']['delete'])) |
|
136 | + { |
|
137 | + // handle a single delete like delete with the checkboxes |
|
133 | 138 | { |
134 | 139 | $id = @key($_content['nm']['rows']['delete']); |
140 | + } |
|
135 | 141 | $_content['nm']['action'] = 'delete'; |
136 | 142 | $_content['nm']['selected'] = array($id); |
137 | 143 | } |
138 | - if (isset($_content['nm']['rows']['document'])) // handle insert in default document button like an action |
|
144 | + if (isset($_content['nm']['rows']['document'])) |
|
145 | + { |
|
146 | + // handle insert in default document button like an action |
|
139 | 147 | { |
140 | 148 | $id = @key($_content['nm']['rows']['document']); |
149 | + } |
|
141 | 150 | $_content['nm']['action'] = 'document'; |
142 | 151 | $_content['nm']['selected'] = array($id); |
143 | 152 | } |
@@ -174,10 +183,13 @@ discard block |
||
174 | 183 | $org = key($_content['nm']['rows']['infolog']); |
175 | 184 | return $this->infolog_org_view($org); |
176 | 185 | } |
177 | - if ($_content['nm']['rows']['view']) // show all contacts of an organisation |
|
186 | + if ($_content['nm']['rows']['view']) |
|
187 | + { |
|
188 | + // show all contacts of an organisation |
|
178 | 189 | { |
179 | 190 | $grouped_view = key($_content['nm']['rows']['view']); |
180 | 191 | } |
192 | + } |
|
181 | 193 | else |
182 | 194 | { |
183 | 195 | $grouped_view = $_content['nm']['grouped_view']; |
@@ -262,10 +274,14 @@ discard block |
||
262 | 274 | } |
263 | 275 | |
264 | 276 | // Search parameter passed in |
265 | - if ($_GET['search']) { |
|
277 | + if ($_GET['search']) |
|
278 | + { |
|
266 | 279 | $content['nm']['search'] = $_GET['search']; |
267 | 280 | } |
268 | - if (isset($typeselection)) $content['nm']['col_filter']['tid'] = $typeselection; |
|
281 | + if (isset($typeselection)) |
|
282 | + { |
|
283 | + $content['nm']['col_filter']['tid'] = $typeselection; |
|
284 | + } |
|
269 | 285 | // save the tid for use in creating new addressbook entrys via UI. Current tid is to be used as type of new entrys |
270 | 286 | //error_log(__METHOD__.__LINE__.' '.$content['nm']['col_filter']['tid']); |
271 | 287 | Api\Cache::setSession('addressbook','active_tid',$content['nm']['col_filter']['tid']); |
@@ -289,7 +305,10 @@ discard block |
||
289 | 305 | $sel_options['adr_one_countrycode']['-custom-'] = lang('No country selected'); |
290 | 306 | |
291 | 307 | // 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']; |
|
308 | + if (isset($this->config['contact_export_limit']) && (int)$this->config['contact_export_limit']) |
|
309 | + { |
|
310 | + $content['nm']['export_limit']=$this->config['contact_export_limit']; |
|
311 | + } |
|
293 | 312 | |
294 | 313 | // Merge to email dialog needs the infolog types |
295 | 314 | $infolog = new infolog_bo(); |
@@ -303,7 +322,10 @@ discard block |
||
303 | 322 | //_debug_array(array('Typefilter:'=> $content['nm']['col_filter']['tid'],'Available Types:'=>$availabletypes,'action:'=>'remove invalid filter')); |
304 | 323 | unset($content['nm']['col_filter']['tid']); |
305 | 324 | } |
306 | - if (!isset($content['nm']['col_filter']['tid'])) $content['nm']['col_filter']['tid'] = $availabletypes[0]; |
|
325 | + if (!isset($content['nm']['col_filter']['tid'])) |
|
326 | + { |
|
327 | + $content['nm']['col_filter']['tid'] = $availabletypes[0]; |
|
328 | + } |
|
307 | 329 | if (count($this->content_types) > 1) |
308 | 330 | { |
309 | 331 | foreach($this->content_types as $tid => $data) |
@@ -400,7 +422,10 @@ discard block |
||
400 | 422 | $crm_apps = array('infolog','tracker'); |
401 | 423 | foreach($crm_apps as $app) |
402 | 424 | { |
403 | - if ($GLOBALS['egw_info']['user']['apps'][$app]) $crm_count++; |
|
425 | + if ($GLOBALS['egw_info']['user']['apps'][$app]) |
|
426 | + { |
|
427 | + $crm_count++; |
|
428 | + } |
|
404 | 429 | } |
405 | 430 | if($GLOBALS['egw_info']['user']['apps']['infolog']) |
406 | 431 | { |
@@ -472,7 +497,10 @@ discard block |
||
472 | 497 | ), |
473 | 498 | ), |
474 | 499 | ); |
475 | - if (!$GLOBALS['egw_info']['user']['apps']['preferences']) unset($actions['cats']['children']['cat_edit']); |
|
500 | + if (!$GLOBALS['egw_info']['user']['apps']['preferences']) |
|
501 | + { |
|
502 | + unset($actions['cats']['children']['cat_edit']); |
|
503 | + } |
|
476 | 504 | // Submenu for all distributionlist stuff |
477 | 505 | $actions['lists'] = array( |
478 | 506 | 'caption' => 'Distribution lists', |
@@ -485,7 +513,9 @@ discard block |
||
485 | 513 | ), |
486 | 514 | 'group' => $group, |
487 | 515 | ); |
488 | - if (($add_lists = $this->get_lists(Acl::EDIT))) // do we have distribution lists?, and are we allowed to edit them |
|
516 | + if (($add_lists = $this->get_lists(Acl::EDIT))) |
|
517 | + { |
|
518 | + // do we have distribution lists?, and are we allowed to edit them |
|
489 | 519 | { |
490 | 520 | $actions['lists']['children'] += array( |
491 | 521 | 'to_list' => array( |
@@ -521,6 +551,7 @@ discard block |
||
521 | 551 | 'fieldValue' => '!', // enable if list != '' |
522 | 552 | ), |
523 | 553 | ); |
554 | + } |
|
524 | 555 | if(is_subclass_of('etemplate', 'etemplate_new')) |
525 | 556 | { |
526 | 557 | $actions['lists']['children']['remove_from_list']['fieldId'] = 'filter2'; |
@@ -529,9 +560,13 @@ discard block |
||
529 | 560 | } |
530 | 561 | } |
531 | 562 | // move to AB |
532 | - if (($move2addressbooks = $this->get_addressbooks(Acl::ADD))) // do we have addressbooks, we should |
|
563 | + if (($move2addressbooks = $this->get_addressbooks(Acl::ADD))) |
|
564 | + { |
|
565 | + // do we have addressbooks, we should |
|
533 | 566 | { |
534 | - unset($move2addressbooks[0]); // do not offer action to move contact to an account, as we dont support that currrently |
|
567 | + unset($move2addressbooks[0]); |
|
568 | + } |
|
569 | + // do not offer action to move contact to an account, as we dont support that currrently |
|
535 | 570 | foreach($move2addressbooks as $owner => $label) |
536 | 571 | { |
537 | 572 | $icon = $type_label = null; |
@@ -693,7 +728,9 @@ discard block |
||
693 | 728 | |
694 | 729 | ); |
695 | 730 | if (!$this->prefs['preferredMail']) |
696 | - $actions['email']['children']['email_business']['checked'] = true; |
|
731 | + { |
|
732 | + $actions['email']['children']['email_business']['checked'] = true; |
|
733 | + } |
|
697 | 734 | |
698 | 735 | if ($GLOBALS['egw_info']['user']['apps']['filemanager']) |
699 | 736 | { |
@@ -842,11 +879,17 @@ discard block |
||
842 | 879 | protected function _get_grouped_name($view_id) |
843 | 880 | { |
844 | 881 | $group_name = array(); |
845 | - if (strpos($view_id,'*AND*')!== false) $view_id = str_replace('*AND*','&',$view_id); |
|
882 | + if (strpos($view_id,'*AND*')!== false) |
|
883 | + { |
|
884 | + $view_id = str_replace('*AND*','&',$view_id); |
|
885 | + } |
|
846 | 886 | foreach(explode('|||',$view_id) as $part) |
847 | 887 | { |
848 | 888 | list(,$name) = explode(':',$part,2); |
849 | - if ($name) $group_name[] = $name; |
|
889 | + if ($name) |
|
890 | + { |
|
891 | + $group_name[] = $name; |
|
892 | + } |
|
850 | 893 | } |
851 | 894 | $name = implode(': ',$group_name); |
852 | 895 | return $name ? array($view_id => $name) : array(); |
@@ -948,9 +991,15 @@ discard block |
||
948 | 991 | $org_contacts = array(); |
949 | 992 | $query = !$_query ? Api\Cache::getSession('addressbook', 'index') : $_query; |
950 | 993 | $query['num_rows'] = -1; // all |
951 | - if(!is_array($query['col_filter'])) $query['col_filter'] = array(); |
|
994 | + if(!is_array($query['col_filter'])) |
|
995 | + { |
|
996 | + $query['col_filter'] = array(); |
|
997 | + } |
|
952 | 998 | |
953 | - if(!is_array($org)) $org = array($org); |
|
999 | + if(!is_array($org)) |
|
1000 | + { |
|
1001 | + $org = array($org); |
|
1002 | + } |
|
954 | 1003 | foreach($org as $org_name) |
955 | 1004 | { |
956 | 1005 | $query['grouped_view'] = $org_name; |
@@ -979,14 +1028,23 @@ discard block |
||
979 | 1028 | $checked = $readonlys = null; |
980 | 1029 | $this->get_rows($query,$checked,$readonlys,true); // true = only return the id's |
981 | 1030 | |
982 | - if (count($checked) > 1) // use a nicely formatted org-name as title in infolog |
|
1031 | + if (count($checked) > 1) |
|
1032 | + { |
|
1033 | + // use a nicely formatted org-name as title in infolog |
|
983 | 1034 | { |
984 | 1035 | $parts = array(); |
985 | - if (strpos($org,'*AND*')!== false) $org = str_replace('*AND*','&',$org); |
|
1036 | + } |
|
1037 | + if (strpos($org,'*AND*')!== false) |
|
1038 | + { |
|
1039 | + $org = str_replace('*AND*','&',$org); |
|
1040 | + } |
|
986 | 1041 | foreach(explode('|||',$org) as $part) |
987 | 1042 | { |
988 | 1043 | list(,$part) = explode(':',$part,2); |
989 | - if ($part) $parts[] = $part; |
|
1044 | + if ($part) |
|
1045 | + { |
|
1046 | + $parts[] = $part; |
|
1047 | + } |
|
990 | 1048 | } |
991 | 1049 | $org = implode(', ',$parts); |
992 | 1050 | } |
@@ -1115,7 +1173,10 @@ discard block |
||
1115 | 1173 | } |
1116 | 1174 | // replace org_name:* id's with all id's of that org |
1117 | 1175 | $grouped_contacts = $this->find_grouped_ids($action, $checked, $use_all, $success,$failed,$action_msg,$session_name, $msg); |
1118 | - if ($grouped_contacts) $checked = array_unique($checked ? array_merge($checked,$grouped_contacts) : $grouped_contacts); |
|
1176 | + if ($grouped_contacts) |
|
1177 | + { |
|
1178 | + $checked = array_unique($checked ? array_merge($checked,$grouped_contacts) : $grouped_contacts); |
|
1179 | + } |
|
1119 | 1180 | //_debug_array($checked); exit; |
1120 | 1181 | |
1121 | 1182 | if (substr($action,0,8) == 'move_to_') |
@@ -1132,9 +1193,12 @@ discard block |
||
1132 | 1193 | $document = substr($action,9); |
1133 | 1194 | $action = 'document'; |
1134 | 1195 | } |
1135 | - elseif(substr($action,0,4) == 'cat_') // cat_add_123 or cat_del_456 |
|
1196 | + elseif(substr($action,0,4) == 'cat_') |
|
1197 | + { |
|
1198 | + // cat_add_123 or cat_del_456 |
|
1136 | 1199 | { |
1137 | 1200 | $cat_id = (int)substr($action, 8); |
1201 | + } |
|
1138 | 1202 | $action = substr($action,0,7); |
1139 | 1203 | } |
1140 | 1204 | // Security: stop non-admins to export more then the configured number of contacts |
@@ -1181,7 +1245,10 @@ discard block |
||
1181 | 1245 | return false; |
1182 | 1246 | |
1183 | 1247 | case 'document': |
1184 | - if (!$document) $document = $this->prefs['default_document']; |
|
1248 | + if (!$document) |
|
1249 | + { |
|
1250 | + $document = $this->prefs['default_document']; |
|
1251 | + } |
|
1185 | 1252 | $document_merge = new Api\Contacts\Merge(); |
1186 | 1253 | $msg = $document_merge->download($document, $checked, '', $this->prefs['document_dir']); |
1187 | 1254 | $failed = count($checked); |
@@ -1333,19 +1400,25 @@ discard block |
||
1333 | 1400 | break; |
1334 | 1401 | |
1335 | 1402 | default: // move to an other addressbook |
1336 | - if (!(int)$action || !($this->grants[(string) (int) $action] & Acl::EDIT)) // might be ADD in the future |
|
1403 | + if (!(int)$action || !($this->grants[(string) (int) $action] & Acl::EDIT)) |
|
1404 | + { |
|
1405 | + // might be ADD in the future |
|
1337 | 1406 | { |
1338 | 1407 | return false; |
1339 | 1408 | } |
1409 | + } |
|
1340 | 1410 | if (!$checkboxes['move_to_copy']) |
1341 | 1411 | { |
1342 | 1412 | $action_msg = lang('moved'); |
1343 | 1413 | if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE,$contact))) |
1344 | 1414 | { |
1345 | - if (!$contact['owner']) // no (mass-)move of Api\Accounts |
|
1415 | + if (!$contact['owner']) |
|
1416 | + { |
|
1417 | + // no (mass-)move of Api\Accounts |
|
1346 | 1418 | { |
1347 | 1419 | $Ok = false; |
1348 | 1420 | } |
1421 | + } |
|
1349 | 1422 | elseif ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action,-1) == 'p')) |
1350 | 1423 | { |
1351 | 1424 | $contact['owner'] = (int) $action; |
@@ -1487,9 +1560,12 @@ discard block |
||
1487 | 1560 | { |
1488 | 1561 | $what = $query['sitemgr_display'] ? $query['sitemgr_display'] : 'index'; |
1489 | 1562 | |
1490 | - if (!$id_only && !$query['csv_export']) // do NOT store state for csv_export or querying id's (no regular view) |
|
1563 | + if (!$id_only && !$query['csv_export']) |
|
1564 | + { |
|
1565 | + // do NOT store state for csv_export or querying id's (no regular view) |
|
1491 | 1566 | { |
1492 | 1567 | $store_query = $query; |
1568 | + } |
|
1493 | 1569 | // Do not store these |
1494 | 1570 | foreach(array('options-cat_id','actions','action_links','placeholder_actions') as $key) |
1495 | 1571 | { |
@@ -1512,21 +1588,29 @@ discard block |
||
1512 | 1588 | if (isset($this->grouped_views[(string) $query['grouped_view']])) |
1513 | 1589 | { |
1514 | 1590 | // we have a grouped view, reset the advanced search |
1515 | - if(!$query['search'] && $old_state['advanced_search']) $query['advanced_search'] = $old_state['advanced_search']; |
|
1591 | + if(!$query['search'] && $old_state['advanced_search']) |
|
1592 | + { |
|
1593 | + $query['advanced_search'] = $old_state['advanced_search']; |
|
1594 | + } |
|
1516 | 1595 | } |
1517 | - elseif(!$query['search'] && array_key_exists('advanced_search',$old_state)) // eg. paging in an advanced search |
|
1596 | + elseif(!$query['search'] && array_key_exists('advanced_search',$old_state)) |
|
1597 | + { |
|
1598 | + // eg. paging in an advanced search |
|
1518 | 1599 | { |
1519 | 1600 | $query['advanced_search'] = $old_state['advanced_search']; |
1520 | 1601 | } |
1602 | + } |
|
1521 | 1603 | |
1522 | 1604 | // Make sure old lettersearch filter doesn't stay - current letter filter will be added later |
1523 | 1605 | foreach($query['col_filter'] as $key => $col_filter) |
1524 | 1606 | { |
1525 | - if(!is_numeric($key)) continue; |
|
1607 | + if(!is_numeric($key)) |
|
1608 | + { |
|
1609 | + continue; |
|
1610 | + } |
|
1526 | 1611 | if(preg_match('/'.$GLOBALS['egw']->db->capabilities['case_insensitive_like']. |
1527 | 1612 | ' '.$GLOBALS['egw']->db->quote('[a-z]%').'$/i',$col_filter) == 1 |
1528 | - ) |
|
1529 | - { |
|
1613 | + ) { |
|
1530 | 1614 | unset($query['col_filter'][$key]); |
1531 | 1615 | } |
1532 | 1616 | } |
@@ -1537,9 +1621,13 @@ discard block |
||
1537 | 1621 | // check if accounts are stored in ldap, which does NOT yet support the org-views |
1538 | 1622 | if ($this->so_accounts && $query['filter'] === '0' && $query['grouped_view']) |
1539 | 1623 | { |
1540 | - if ($old_state['filter'] === '0') // user changed to org_view |
|
1624 | + if ($old_state['filter'] === '0') |
|
1625 | + { |
|
1626 | + // user changed to org_view |
|
1541 | 1627 | { |
1542 | - $query['filter'] = ''; // --> change filter to all contacts |
|
1628 | + $query['filter'] = ''; |
|
1629 | + } |
|
1630 | + // --> change filter to all contacts |
|
1543 | 1631 | } |
1544 | 1632 | else // user changed to accounts |
1545 | 1633 | { |
@@ -1576,9 +1664,12 @@ discard block |
||
1576 | 1664 | { |
1577 | 1665 | unset($query['col_filter']['cat_id']); |
1578 | 1666 | } |
1579 | - if ($query['filter'] !== '') // not all addressbooks |
|
1667 | + if ($query['filter'] !== '') |
|
1668 | + { |
|
1669 | + // not all addressbooks |
|
1580 | 1670 | { |
1581 | 1671 | $query['col_filter']['owner'] = (string) (int) $query['filter']; |
1672 | + } |
|
1582 | 1673 | |
1583 | 1674 | if ($this->private_addressbook) |
1584 | 1675 | { |
@@ -1590,10 +1681,13 @@ discard block |
||
1590 | 1681 | unset($query['col_filter']['owner']); |
1591 | 1682 | unset($query['col_filter']['private']); |
1592 | 1683 | } |
1593 | - if ((int)$query['filter2']) // not no distribution list |
|
1684 | + if ((int)$query['filter2']) |
|
1685 | + { |
|
1686 | + // not no distribution list |
|
1594 | 1687 | { |
1595 | 1688 | $query['col_filter']['list'] = (string) (int) $query['filter2']; |
1596 | 1689 | } |
1690 | + } |
|
1597 | 1691 | else |
1598 | 1692 | { |
1599 | 1693 | unset($query['col_filter']['list']); |
@@ -1634,9 +1728,12 @@ discard block |
||
1634 | 1728 | } |
1635 | 1729 | // Query doesn't like parent_id |
1636 | 1730 | unset($query['col_filter']['parent_id']); |
1637 | - if ($query['grouped_view']) // view the contacts of one organisation only |
|
1731 | + if ($query['grouped_view']) |
|
1732 | + { |
|
1733 | + // view the contacts of one organisation only |
|
1638 | 1734 | { |
1639 | 1735 | if (strpos($query['grouped_view'],'*AND*') !== false) $query['grouped_view'] = str_replace('*AND*','&',$query['grouped_view']); |
1736 | + } |
|
1640 | 1737 | $fields = explode(',',$GLOBALS['egw_info']['user']['preferences']['addressbook']['duplicate_fields']); |
1641 | 1738 | foreach(explode('|||',$query['grouped_view']) as $part) |
1642 | 1739 | { |
@@ -1659,14 +1756,18 @@ discard block |
||
1659 | 1756 | // translate the select order to the really used over all 3 columns |
1660 | 1757 | $sort = $query['sort']; |
1661 | 1758 | switch($query['order']) // "xxx<>'' DESC" sorts contacts with empty order-criteria always at the end |
1662 | - { // we don't exclude them, as the total would otherwise depend on the order-criteria |
|
1759 | + { |
|
1760 | +// we don't exclude them, as the total would otherwise depend on the order-criteria |
|
1663 | 1761 | case 'org_name': |
1664 | 1762 | $order = "egw_addressbook.org_name<>''DESC,egw_addressbook.org_name $sort,n_family $sort,n_given $sort"; |
1665 | 1763 | break; |
1666 | 1764 | default: |
1667 | - if ($query['order'][0] == '#') // we order by a custom field |
|
1765 | + if ($query['order'][0] == '#') |
|
1766 | + { |
|
1767 | + // we order by a custom field |
|
1668 | 1768 | { |
1669 | 1769 | $order = "{$query['order']} $sort,org_name $sort,n_family $sort,n_given $sort"; |
1770 | + } |
|
1670 | 1771 | break; |
1671 | 1772 | } |
1672 | 1773 | $query['order'] = 'n_family'; |
@@ -1690,9 +1791,12 @@ discard block |
||
1690 | 1791 | case 'contact_id': |
1691 | 1792 | $order = "egw_addressbook.$query[order] $sort"; |
1692 | 1793 | } |
1693 | - if ($query['searchletter']) // only show contacts if the order-criteria starts with the given letter |
|
1794 | + if ($query['searchletter']) |
|
1795 | + { |
|
1796 | + // only show contacts if the order-criteria starts with the given letter |
|
1694 | 1797 | { |
1695 | 1798 | $no_letter_search = array('adr_one_postalcode', 'adr_two_postalcode', 'contact_id', 'contact_created','contact_modified'); |
1799 | + } |
|
1696 | 1800 | $query['col_filter'][] = (in_array($query['order'],$no_letter_search) ? 'org_name' : (substr($query['order'],0,1)=='#'?'':'egw_addressbook.').$query['order']).' '. |
1697 | 1801 | $GLOBALS['egw']->db->capabilities['case_insensitive_like'].' '.$GLOBALS['egw']->db->quote($query['searchletter'].'%'); |
1698 | 1802 | } |
@@ -1734,13 +1838,19 @@ discard block |
||
1734 | 1838 | { |
1735 | 1839 | foreach($columselection as $col) |
1736 | 1840 | { |
1737 | - if ($col[0] == '#') $selected_cfs[] = substr($col,1); |
|
1841 | + if ($col[0] == '#') |
|
1842 | + { |
|
1843 | + $selected_cfs[] = substr($col,1); |
|
1844 | + } |
|
1738 | 1845 | } |
1739 | 1846 | } |
1740 | 1847 | $selected_cfs = array_unique(array_merge($selected_cfs, (array)$this->config['index_load_cfs'])); |
1741 | 1848 | $customfields = $this->read_customfields($ids,$selected_cfs); |
1742 | 1849 | } |
1743 | - if ($show_calendar && !empty($ids)) $calendar = $this->read_calendar($calendar_participants); |
|
1850 | + if ($show_calendar && !empty($ids)) |
|
1851 | + { |
|
1852 | + $calendar = $this->read_calendar($calendar_participants); |
|
1853 | + } |
|
1744 | 1854 | // distributionlist memership for the entrys |
1745 | 1855 | //_debug_array($this->get_lists(Acl::EDIT)); |
1746 | 1856 | if ($show_distributionlist && $available_distib_lists) |
@@ -1750,7 +1860,10 @@ discard block |
||
1750 | 1860 | } |
1751 | 1861 | } |
1752 | 1862 | } |
1753 | - if (!$rows) $rows = array(); |
|
1863 | + if (!$rows) |
|
1864 | + { |
|
1865 | + $rows = array(); |
|
1866 | + } |
|
1754 | 1867 | |
1755 | 1868 | if ($id_only) |
1756 | 1869 | { |
@@ -1783,7 +1896,10 @@ discard block |
||
1783 | 1896 | $row['line2'] = $row['org_name']; |
1784 | 1897 | break; |
1785 | 1898 | case 'n_fileas': |
1786 | - if (!$row['n_fileas']) $row['n_fileas'] = $this->fileas($row); |
|
1899 | + if (!$row['n_fileas']) |
|
1900 | + { |
|
1901 | + $row['n_fileas'] = $this->fileas($row); |
|
1902 | + } |
|
1787 | 1903 | list($row['line1'],$row['line2']) = explode(': ',$row['n_fileas']); |
1788 | 1904 | break; |
1789 | 1905 | } |
@@ -1862,8 +1978,14 @@ discard block |
||
1862 | 1978 | } |
1863 | 1979 | |
1864 | 1980 | // hide region for address format 'postcode_city' |
1865 | - if (($row['addr_format'] = $this->addr_format_by_country($row['adr_one_countryname']))=='postcode_city') unset($row['adr_one_region']); |
|
1866 | - if (($row['addr_format2'] = $this->addr_format_by_country($row['adr_two_countryname']))=='postcode_city') unset($row['adr_two_region']); |
|
1981 | + if (($row['addr_format'] = $this->addr_format_by_country($row['adr_one_countryname']))=='postcode_city') |
|
1982 | + { |
|
1983 | + unset($row['adr_one_region']); |
|
1984 | + } |
|
1985 | + if (($row['addr_format2'] = $this->addr_format_by_country($row['adr_two_countryname']))=='postcode_city') |
|
1986 | + { |
|
1987 | + unset($row['adr_two_region']); |
|
1988 | + } |
|
1867 | 1989 | |
1868 | 1990 | // respect category permissions |
1869 | 1991 | if(!empty($row['cat_id'])) |
@@ -1922,10 +2044,13 @@ discard block |
||
1922 | 2044 | $order = $order == 'n_given' ? lang('first name') : ($order == 'n_family' ? lang('last name') : lang('Organisation')); |
1923 | 2045 | $header[] = lang("%1 starts with '%2'",$order,$query['searchletter']); |
1924 | 2046 | } |
1925 | - if ($query['search'] && !$query['advanced_search']) // do not add that, if we have advanced search active |
|
2047 | + if ($query['search'] && !$query['advanced_search']) |
|
2048 | + { |
|
2049 | + // do not add that, if we have advanced search active |
|
1926 | 2050 | { |
1927 | 2051 | $header[] = lang("Search for '%1'",$query['search']); |
1928 | 2052 | } |
2053 | + } |
|
1929 | 2054 | $GLOBALS['egw_info']['flags']['app_header'] = implode(': ', $header); |
1930 | 2055 | |
1931 | 2056 | return $this->total; |
@@ -1992,7 +2117,10 @@ discard block |
||
1992 | 2117 | $content['private'] = (int) ($content['owner'] && substr($content['owner'],-1) == 'p'); |
1993 | 2118 | $content['owner'] = (string) (int) $content['owner']; |
1994 | 2119 | $content['cat_id'] = $this->config['cat_tab'] === 'Tree' ? $content['cat_id_tree'] : $content['cat_id']; |
1995 | - if ($this->config['private_cf_tab']) $content = (array)$content['private_cfs'] + $content; |
|
2120 | + if ($this->config['private_cf_tab']) |
|
2121 | + { |
|
2122 | + $content = (array)$content['private_cfs'] + $content; |
|
2123 | + } |
|
1996 | 2124 | unset($content['private_cfs']); |
1997 | 2125 | |
1998 | 2126 | switch($button) |
@@ -2183,7 +2311,10 @@ discard block |
||
2183 | 2311 | { |
2184 | 2312 | // arguments containing a comma get quoted by etemplate/js/nextmatch_action.js |
2185 | 2313 | // leading to error in Api\Db::column_data_implode, if not unquoted |
2186 | - if ($org[0] == '"') $org = substr($org, 1, -1); |
|
2314 | + if ($org[0] == '"') |
|
2315 | + { |
|
2316 | + $org = substr($org, 1, -1); |
|
2317 | + } |
|
2187 | 2318 | $content = $this->read_org($org); |
2188 | 2319 | } |
2189 | 2320 | elseif ($state['grouped_view'] && !isset($this->grouped_views[$state['grouped_view']])) |
@@ -2203,7 +2334,10 @@ discard block |
||
2203 | 2334 | $content['adr_two_countryname'] = |
2204 | 2335 | $GLOBALS['egw']->country->get_full_name($GLOBALS['egw_info']['user']['preferences']['common']['country']); |
2205 | 2336 | } |
2206 | - if ($this->prefs['fileas_default']) $content['fileas_type'] = $this->prefs['fileas_default']; |
|
2337 | + if ($this->prefs['fileas_default']) |
|
2338 | + { |
|
2339 | + $content['fileas_type'] = $this->prefs['fileas_default']; |
|
2340 | + } |
|
2207 | 2341 | } |
2208 | 2342 | if (isset($_GET['owner']) && $_GET['owner'] !== '') |
2209 | 2343 | { |
@@ -2228,7 +2362,10 @@ discard block |
||
2228 | 2362 | $new_type = array_keys($this->content_types); |
2229 | 2363 | // fetch active type to preset the type, if param typeid is not passed |
2230 | 2364 | $active_tid = Api\Cache::getSession('addressbook','active_tid'); |
2231 | - if ($active_tid && strtoupper($active_tid) === 'D') unset($active_tid); |
|
2365 | + if ($active_tid && strtoupper($active_tid) === 'D') |
|
2366 | + { |
|
2367 | + unset($active_tid); |
|
2368 | + } |
|
2232 | 2369 | $content['tid'] = $_GET['typeid'] ? $_GET['typeid'] : ($active_tid?$active_tid:$new_type[0]); |
2233 | 2370 | foreach($this->get_contact_columns() as $field) |
2234 | 2371 | { |
@@ -2246,19 +2383,37 @@ discard block |
||
2246 | 2383 | if (strpos($singleAddress[0]->personal,',')===false) |
2247 | 2384 | { |
2248 | 2385 | list($P_n_given,$P_n_family,$P_org_name)=explode(' ',$singleAddress[0]->personal,3); |
2249 | - if (strlen(trim($P_n_given))>0) $content['n_given'] = trim($P_n_given); |
|
2250 | - if (strlen(trim($P_n_family))>0) $content['n_family'] = trim($P_n_family); |
|
2251 | - if (strlen(trim($P_org_name))>0) $content['org_name'] = trim($P_org_name); |
|
2386 | + if (strlen(trim($P_n_given))>0) |
|
2387 | + { |
|
2388 | + $content['n_given'] = trim($P_n_given); |
|
2389 | + } |
|
2390 | + if (strlen(trim($P_n_family))>0) |
|
2391 | + { |
|
2392 | + $content['n_family'] = trim($P_n_family); |
|
2393 | + } |
|
2394 | + if (strlen(trim($P_org_name))>0) |
|
2395 | + { |
|
2396 | + $content['org_name'] = trim($P_org_name); |
|
2397 | + } |
|
2252 | 2398 | } |
2253 | 2399 | else |
2254 | 2400 | { |
2255 | 2401 | list($P_n_family,$P_other)=explode(',',$singleAddress[0]->personal,2); |
2256 | - if (strlen(trim($P_n_family))>0) $content['n_family'] = trim($P_n_family); |
|
2402 | + if (strlen(trim($P_n_family))>0) |
|
2403 | + { |
|
2404 | + $content['n_family'] = trim($P_n_family); |
|
2405 | + } |
|
2257 | 2406 | if (strlen(trim($P_other))>0) |
2258 | 2407 | { |
2259 | 2408 | list($P_n_given,$P_org_name)=explode(',',$P_other,2); |
2260 | - if (strlen(trim($P_n_given))>0) $content['n_given'] = trim($P_n_given); |
|
2261 | - if (strlen(trim($P_org_name))>0) $content['org_name'] = trim($P_org_name); |
|
2409 | + if (strlen(trim($P_n_given))>0) |
|
2410 | + { |
|
2411 | + $content['n_given'] = trim($P_n_given); |
|
2412 | + } |
|
2413 | + if (strlen(trim($P_org_name))>0) |
|
2414 | + { |
|
2415 | + $content['org_name'] = trim($P_org_name); |
|
2416 | + } |
|
2262 | 2417 | } |
2263 | 2418 | } |
2264 | 2419 | } |
@@ -2286,7 +2441,10 @@ discard block |
||
2286 | 2441 | break; |
2287 | 2442 | } |
2288 | 2443 | } |
2289 | - if (empty($content['n_fn'])) $content['n_fn'] = $this->fullname($content); |
|
2444 | + if (empty($content['n_fn'])) |
|
2445 | + { |
|
2446 | + $content['n_fn'] = $this->fullname($content); |
|
2447 | + } |
|
2290 | 2448 | } |
2291 | 2449 | $content['creator'] = $this->user; |
2292 | 2450 | $content['created'] = $this->now_su; |
@@ -2294,17 +2452,27 @@ discard block |
||
2294 | 2452 | //_debug_array($content); |
2295 | 2453 | } |
2296 | 2454 | |
2297 | - if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']); // dont allow HTML! |
|
2455 | + if ($_GET['msg']) |
|
2456 | + { |
|
2457 | + $content['msg'] = strip_tags($_GET['msg']); |
|
2458 | + } |
|
2459 | + // dont allow HTML! |
|
2298 | 2460 | |
2299 | - if($content && $_GET['makecp']) // copy the contact |
|
2461 | + if($content && $_GET['makecp']) |
|
2462 | + { |
|
2463 | + // copy the contact |
|
2300 | 2464 | { |
2301 | 2465 | $this->copy_contact($content); |
2466 | + } |
|
2302 | 2467 | $content['msg'] = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('addressbook','entry'))); |
2303 | 2468 | $view = false; |
2304 | 2469 | } |
2305 | 2470 | else |
2306 | 2471 | { |
2307 | - if ($contact_id && is_numeric($contact_id)) $content['link_to']['to_id'] = $contact_id; |
|
2472 | + if ($contact_id && is_numeric($contact_id)) |
|
2473 | + { |
|
2474 | + $content['link_to']['to_id'] = $contact_id; |
|
2475 | + } |
|
2308 | 2476 | } |
2309 | 2477 | // automatic link new entries to entries specified in the url |
2310 | 2478 | if (!$contact_id && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id']) && !is_array($content['link_to']['to_id'])) |
@@ -2313,10 +2481,13 @@ discard block |
||
2313 | 2481 | foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
2314 | 2482 | { |
2315 | 2483 | $link_id = $link_ids[$n]; |
2316 | - if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) // gard against XSS |
|
2484 | + if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) |
|
2485 | + { |
|
2486 | + // gard against XSS |
|
2317 | 2487 | { |
2318 | 2488 | Link::link('addressbook',$content['link_to']['to_id'],$link_app,$link_id); |
2319 | 2489 | } |
2490 | + } |
|
2320 | 2491 | } |
2321 | 2492 | } |
2322 | 2493 | } |
@@ -2324,7 +2495,10 @@ discard block |
||
2324 | 2495 | { |
2325 | 2496 | // last and next calendar date |
2326 | 2497 | $dates = current($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']),false)); |
2327 | - if(is_array($dates)) $content += $dates; |
|
2498 | + if(is_array($dates)) |
|
2499 | + { |
|
2500 | + $content += $dates; |
|
2501 | + } |
|
2328 | 2502 | } |
2329 | 2503 | |
2330 | 2504 | // Registry has view_id as contact_id, so set it (custom fields uses it) |
@@ -2360,7 +2534,11 @@ discard block |
||
2360 | 2534 | $sel_options['fileas_type'] = $this->fileas_options($content); |
2361 | 2535 | $sel_options['adr_one_countrycode']['-custom-'] = lang('Custom'); |
2362 | 2536 | $sel_options['owner'] = $this->get_addressbooks(Acl::ADD); |
2363 | - if ($content['owner']) unset($sel_options['owner'][0]); // do not offer to switch to accounts, as we do not support moving contacts to accounts |
|
2537 | + if ($content['owner']) |
|
2538 | + { |
|
2539 | + unset($sel_options['owner'][0]); |
|
2540 | + } |
|
2541 | + // do not offer to switch to accounts, as we do not support moving contacts to accounts |
|
2364 | 2542 | if ((string) $content['owner'] !== '') |
2365 | 2543 | { |
2366 | 2544 | if (!isset($sel_options['owner'][(int)$content['owner']])) |
@@ -2401,7 +2579,10 @@ discard block |
||
2401 | 2579 | } |
2402 | 2580 | } |
2403 | 2581 | |
2404 | - if (isset($readonlys['n_fileas'])) $readonlys['fileas_type'] = $readonlys['n_fileas']; |
|
2582 | + if (isset($readonlys['n_fileas'])) |
|
2583 | + { |
|
2584 | + $readonlys['fileas_type'] = $readonlys['n_fileas']; |
|
2585 | + } |
|
2405 | 2586 | // disable not needed tabs |
2406 | 2587 | $readonlys['tabs']['cats'] = !($content['cat_tab'] = $this->config['cat_tab']); |
2407 | 2588 | $readonlys['tabs']['custom'] = !$this->customfields || $this->get_backend($content['id'],$content['owner']) == $this->so_accounts; |
@@ -2409,8 +2590,14 @@ discard block |
||
2409 | 2590 | $readonlys['tabs']['distribution_list'] = !$content['distrib_lists'];#false; |
2410 | 2591 | $readonlys['tabs']['history'] = $this->contact_repository != 'sql' || !$content['id'] || |
2411 | 2592 | $this->account_repository != 'sql' && $content['account_id']; |
2412 | - if (!$content['id']) $readonlys['button[delete]'] = !$content['id']; |
|
2413 | - if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0; |
|
2593 | + if (!$content['id']) |
|
2594 | + { |
|
2595 | + $readonlys['button[delete]'] = !$content['id']; |
|
2596 | + } |
|
2597 | + if ($this->config['private_cf_tab']) |
|
2598 | + { |
|
2599 | + $content['no_private_cfs'] = 0; |
|
2600 | + } |
|
2414 | 2601 | $readonlys['change_org'] = empty($content['org_name']) || $view; |
2415 | 2602 | |
2416 | 2603 | // for editing the own account (by a non-admin), enable only the fields allowed via the "own_account_acl" |
@@ -2458,7 +2645,10 @@ discard block |
||
2458 | 2645 | |
2459 | 2646 | $content['photo'] = $this->photo_src($content['id'],$content['jpegphoto'],'',$content['etag']); |
2460 | 2647 | |
2461 | - if ($content['private']) $content['owner'] .= 'p'; |
|
2648 | + if ($content['private']) |
|
2649 | + { |
|
2650 | + $content['owner'] .= 'p'; |
|
2651 | + } |
|
2462 | 2652 | |
2463 | 2653 | // for custom types, check if we have a custom edit template named "addressbook.edit.$type", $type is the name |
2464 | 2654 | if (in_array($content['tid'], array('n',self::DELETED_TYPE)) || !$this->tmpl->read('addressbook.edit.'.$this->content_types[$content['tid']]['name'])) |
@@ -2481,7 +2671,10 @@ discard block |
||
2481 | 2671 | //error_log(__METHOD__."() hook_data=".array2string($hook_data)); |
2482 | 2672 | foreach($hook_data as $extra_tabs) |
2483 | 2673 | { |
2484 | - if (!$extra_tabs) continue; |
|
2674 | + if (!$extra_tabs) |
|
2675 | + { |
|
2676 | + continue; |
|
2677 | + } |
|
2485 | 2678 | |
2486 | 2679 | foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
2487 | 2680 | { |
@@ -2498,7 +2691,10 @@ discard block |
||
2498 | 2691 | $readonlys = array_merge($readonlys, $extra_tab['readonlys']); |
2499 | 2692 | } |
2500 | 2693 | // we must NOT add tabs and callbacks more then once! |
2501 | - if (!$first_call) continue; |
|
2694 | + if (!$first_call) |
|
2695 | + { |
|
2696 | + continue; |
|
2697 | + } |
|
2502 | 2698 | |
2503 | 2699 | if (!empty($extra_tab['pre_save_callback'])) |
2504 | 2700 | { |
@@ -2589,13 +2785,16 @@ discard block |
||
2589 | 2785 | // if email changed, check for doublicates |
2590 | 2786 | if (in_array($name, array('email', 'email_home')) && in_array('contact_'.$name, $fields)) |
2591 | 2787 | { |
2592 | - if (preg_match(Etemplate\Widget\Url::EMAIL_PREG, $values[$name])) // only search for real email addresses, to not return to many contacts |
|
2788 | + if (preg_match(Etemplate\Widget\Url::EMAIL_PREG, $values[$name])) |
|
2789 | + { |
|
2790 | + // only search for real email addresses, to not return to many contacts |
|
2593 | 2791 | { |
2594 | 2792 | $contacts = parent::search(array( |
2595 | 2793 | 'email' => $values[$name], |
2596 | 2794 | 'email_home' => $values[$name], |
2597 | 2795 | ), false, '', '', '', false, 'OR'); |
2598 | 2796 | } |
2797 | + } |
|
2599 | 2798 | } |
2600 | 2799 | else |
2601 | 2800 | { |
@@ -2616,10 +2815,13 @@ discard block |
||
2616 | 2815 | if (in_array($name,$fields) && $specified_count >= $threshold) |
2617 | 2816 | { |
2618 | 2817 | $filter = array(); |
2619 | - foreach($fields as $n) // use email too, to exclude obvious false positives |
|
2818 | + foreach($fields as $n) |
|
2819 | + { |
|
2820 | + // use email too, to exclude obvious false positives |
|
2620 | 2821 | { |
2621 | 2822 | if (!empty($values[$n])) $filter[$n] = $values[$n]; |
2622 | 2823 | } |
2824 | + } |
|
2623 | 2825 | $contacts = parent::search('', false, '', '', '', false, 'AND', false, $filter); |
2624 | 2826 | } |
2625 | 2827 | } |
@@ -2627,7 +2829,10 @@ discard block |
||
2627 | 2829 | { |
2628 | 2830 | foreach($contacts as $contact) |
2629 | 2831 | { |
2630 | - if ($own_id && $contact['id'] == $own_id) continue; |
|
2832 | + if ($own_id && $contact['id'] == $own_id) |
|
2833 | + { |
|
2834 | + continue; |
|
2835 | + } |
|
2631 | 2836 | |
2632 | 2837 | $ret['doublicates'][$contact['id']] = $this->fileas($contact).' ('. |
2633 | 2838 | (!$contact['owner'] ? lang('Accounts') : ($contact['owner'] == $this->user ? |
@@ -2654,7 +2859,10 @@ discard block |
||
2654 | 2859 | // CRM list comes from content, request, or preference |
2655 | 2860 | $crm_list = $content['crm_list'] ? $content['crm_list'] : |
2656 | 2861 | ($_GET['crm_list'] ? $_GET['crm_list'] : $GLOBALS['egw_info']['user']['preferences']['addressbook']['crm_list']); |
2657 | - if(!$crm_list || $crm_list == '~edit~') $crm_list = 'infolog'; |
|
2862 | + if(!$crm_list || $crm_list == '~edit~') |
|
2863 | + { |
|
2864 | + $crm_list = 'infolog'; |
|
2865 | + } |
|
2658 | 2866 | |
2659 | 2867 | if(is_array($content)) |
2660 | 2868 | { |
@@ -2677,7 +2885,10 @@ discard block |
||
2677 | 2885 | $inc = 1; |
2678 | 2886 | // fall through |
2679 | 2887 | case 'back': |
2680 | - if (!isset($inc)) $inc = -1; |
|
2888 | + if (!isset($inc)) |
|
2889 | + { |
|
2890 | + $inc = -1; |
|
2891 | + } |
|
2681 | 2892 | // get next/previous contact in selection |
2682 | 2893 | $query = Api\Cache::getSession('addressbook', 'index'); |
2683 | 2894 | $query['start'] = $content['index'] + $inc; |
@@ -2843,11 +3054,20 @@ discard block |
||
2843 | 3054 | $readonlys['tabs']['distribution_list'] = !$content['distrib_lists'];#false; |
2844 | 3055 | $readonlys['tabs']['history'] = $this->contact_repository != 'sql' || !$content['id'] || |
2845 | 3056 | $this->account_repository != 'sql' && $content['account_id']; |
2846 | - if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0; |
|
3057 | + if ($this->config['private_cf_tab']) |
|
3058 | + { |
|
3059 | + $content['no_private_cfs'] = 0; |
|
3060 | + } |
|
2847 | 3061 | |
2848 | 3062 | // last and next calendar date |
2849 | - if (!empty($content['id'])) $dates = current($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']),false)); |
|
2850 | - if(is_array($dates)) $content += $dates; |
|
3063 | + if (!empty($content['id'])) |
|
3064 | + { |
|
3065 | + $dates = current($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']),false)); |
|
3066 | + } |
|
3067 | + if(is_array($dates)) |
|
3068 | + { |
|
3069 | + $content += $dates; |
|
3070 | + } |
|
2851 | 3071 | |
2852 | 3072 | // Disable importexport |
2853 | 3073 | $GLOBALS['egw_info']['flags']['disable_importexport']['export'] = true; |
@@ -2971,7 +3191,10 @@ discard block |
||
2971 | 3191 | */ |
2972 | 3192 | function email2link($email) |
2973 | 3193 | { |
2974 | - if (strpos($email,'@') == false) return ''; |
|
3194 | + if (strpos($email,'@') == false) |
|
3195 | + { |
|
3196 | + return ''; |
|
3197 | + } |
|
2975 | 3198 | |
2976 | 3199 | if($GLOBALS['egw_info']['user']['apps']['mail']) |
2977 | 3200 | { |
@@ -3023,7 +3246,10 @@ discard block |
||
3023 | 3246 | $query['advanced_search'] = array_intersect_key($_content,array_flip(array_merge($this->get_contact_columns(),array('operator','meth_select')))); |
3024 | 3247 | foreach ($query['advanced_search'] as $key => $value) |
3025 | 3248 | { |
3026 | - if(!$value) unset($query['advanced_search'][$key]); |
|
3249 | + if(!$value) |
|
3250 | + { |
|
3251 | + unset($query['advanced_search'][$key]); |
|
3252 | + } |
|
3027 | 3253 | } |
3028 | 3254 | // Skip n_fn, it causes problems in sql |
3029 | 3255 | unset($query['advanced_search']['n_fn']); |
@@ -3080,8 +3306,14 @@ discard block |
||
3080 | 3306 | { |
3081 | 3307 | if (substr($data['type'], 0, 6) == 'select' && !($data['rows'] > 1)) |
3082 | 3308 | { |
3083 | - if (!isset($content['#'.$name])) $content['#'.$name] = ''; |
|
3084 | - if(!isset($data['values'][''])) $sel_options['#'.$name][''] = lang('Select one'); |
|
3309 | + if (!isset($content['#'.$name])) |
|
3310 | + { |
|
3311 | + $content['#'.$name] = ''; |
|
3312 | + } |
|
3313 | + if(!isset($data['values'][''])) |
|
3314 | + { |
|
3315 | + $sel_options['#'.$name][''] = lang('Select one'); |
|
3316 | + } |
|
3085 | 3317 | } |
3086 | 3318 | // Make them not required, otherwise you can't search |
3087 | 3319 | $this->tmpl->setElementAttribute('#'.$name, 'needed', FALSE); |
@@ -3105,7 +3337,10 @@ discard block |
||
3105 | 3337 | $content['no_tid'] = true; |
3106 | 3338 | $content['showsearchbuttons'] = true; // enable search operation and search buttons| they're disabled by default |
3107 | 3339 | |
3108 | - if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0; |
|
3340 | + if ($this->config['private_cf_tab']) |
|
3341 | + { |
|
3342 | + $content['no_private_cfs'] = 0; |
|
3343 | + } |
|
3109 | 3344 | |
3110 | 3345 | $this->tmpl->set_cell_attribute('change_org','disabled',true); |
3111 | 3346 | return $this->tmpl->exec('addressbook.addressbook_ui.search',$content,$sel_options,$readonlys,array(),2); |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | - * Overridden to be able to skip the next step |
|
39 | - */ |
|
38 | + * Overridden to be able to skip the next step |
|
39 | + */ |
|
40 | 40 | function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv) { |
41 | 41 | |
42 | 42 | if ($content['step'] == 'wizard_step40' && array_search('pressed', $content['button']) == 'next') { |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - /** |
|
56 | - * Choose how to export multi-selects (includes Api\Categories) |
|
57 | - */ |
|
58 | - function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv) |
|
55 | + /** |
|
56 | + * Choose how to export multi-selects (includes Api\Categories) |
|
57 | + */ |
|
58 | + function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv) |
|
59 | 59 | { |
60 | 60 | if($this->debug) error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true)); |
61 | 61 | // return from step50 |
@@ -130,8 +130,8 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
133 | - * Get a list of multi-select fields |
|
134 | - */ |
|
133 | + * Get a list of multi-select fields |
|
134 | + */ |
|
135 | 135 | protected function get_field_list($content) { |
136 | 136 | $field_list = array(); |
137 | 137 |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | // Field mapping |
23 | 23 | $bocontacts = new Api\Contacts(); |
24 | 24 | $this->export_fields = $bocontacts->contact_fields; |
25 | - foreach($bocontacts->customfields as $name => $data) { |
|
25 | + foreach ($bocontacts->customfields as $name => $data) { |
|
26 | 26 | $this->export_fields['#'.$name] = $data['label']; |
27 | 27 | } |
28 | - unset($this->export_fields['jpegphoto']); // can't cvs export that |
|
28 | + unset($this->export_fields['jpegphoto']); // can't cvs export that |
|
29 | 29 | |
30 | 30 | // Add in last/next appointments |
31 | 31 | // NB: last_date and next_date are used instead of last_event & next_event |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | if ($content['step'] == 'wizard_step40' && array_search('pressed', $content['button']) == 'next') { |
43 | 43 | $result = parent::wizard_step40($content, $sel_options, $readonlys, $preserv); |
44 | 44 | $field_list = $this->get_field_list($content); |
45 | - if(count($field_list)) { |
|
45 | + if (count($field_list)) { |
|
46 | 46 | return $result; |
47 | 47 | } else { |
48 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],2); |
|
48 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 2); |
|
49 | 49 | } |
50 | 50 | } else { |
51 | 51 | return parent::wizard_step40($content, $sel_options, $readonlys, $preserv); |
@@ -57,15 +57,15 @@ discard block |
||
57 | 57 | */ |
58 | 58 | function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv) |
59 | 59 | { |
60 | - if($this->debug) error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true)); |
|
60 | + if ($this->debug) error_log(get_class($this).'::wizard_step50->$content '.print_r($content, true)); |
|
61 | 61 | // return from step50 |
62 | 62 | if ($content['step'] == 'wizard_step50') |
63 | 63 | { |
64 | - if($content['explode_multiselects']) { |
|
64 | + if ($content['explode_multiselects']) { |
|
65 | 65 | $explodes = $content['explode_multiselects']; |
66 | 66 | $content['explode_multiselects'] = array(); |
67 | - foreach($explodes as $row => $settings) { |
|
68 | - if($settings['explode'] != addressbook_export_contacts_csv::NO_EXPLODE) { |
|
67 | + foreach ($explodes as $row => $settings) { |
|
68 | + if ($settings['explode'] != addressbook_export_contacts_csv::NO_EXPLODE) { |
|
69 | 69 | $content['explode_multiselects'][$settings['field']] = $settings; |
70 | 70 | } |
71 | 71 | } |
@@ -73,13 +73,13 @@ discard block |
||
73 | 73 | switch (array_search('pressed', $content['button'])) |
74 | 74 | { |
75 | 75 | case 'next': |
76 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1); |
|
76 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1); |
|
77 | 77 | case 'previous' : |
78 | - return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1); |
|
78 | + return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1); |
|
79 | 79 | case 'finish': |
80 | 80 | return 'wizard_finish'; |
81 | 81 | default : |
82 | - return $this->wizard_step50($content,$sel_options,$readonlys,$preserv); |
|
82 | + return $this->wizard_step50($content, $sel_options, $readonlys, $preserv); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | // init step50 |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | $settings = $content['explode_multiselects'] ? $content['explode_multiselects'] : $content['plugin_options']['explode_multiselects']; |
94 | 94 | |
95 | 95 | // Skip this step if no fields applicable |
96 | - if(count($field_list) == 0) { |
|
96 | + if (count($field_list) == 0) { |
|
97 | 97 | $content['explode_multiselects'] = array(); |
98 | 98 | } |
99 | 99 | |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | ); |
109 | 109 | |
110 | 110 | $row = 1; |
111 | - foreach($field_list as $field => $name) { |
|
111 | + foreach ($field_list as $field => $name) { |
|
112 | 112 | $content['explode_multiselects'][$row] = array( |
113 | 113 | 'field' => $field, |
114 | 114 | 'name' => $name, |
115 | 115 | 'explode'=> $settings[$field] |
116 | 116 | ); |
117 | - if($field == 'cat_id') { |
|
117 | + if ($field == 'cat_id') { |
|
118 | 118 | $sel_options['explode_multiselects'][$row]['explode'] = $cat_options; |
119 | 119 | } else { |
120 | 120 | $sel_options['explode_multiselects'][$row]['explode'] = $multi_options; |
@@ -136,14 +136,14 @@ discard block |
||
136 | 136 | $field_list = array(); |
137 | 137 | |
138 | 138 | // Category gets special handling |
139 | - if(in_array('cat_id', array_keys($content['mapping']))) { |
|
139 | + if (in_array('cat_id', array_keys($content['mapping']))) { |
|
140 | 140 | $field_list['cat_id'] = $this->export_fields['cat_id']; |
141 | 141 | } |
142 | 142 | |
143 | 143 | // Add any multi-select custom fields |
144 | 144 | $custom = Api\Storage\Customfields::get('addressbook'); |
145 | - foreach($custom as $name => $c_field) { |
|
146 | - if($c_field['type'] == 'select' && $c_field['rows'] > 1 && in_array('#'.$name, array_keys($content['mapping']))) { |
|
145 | + foreach ($custom as $name => $c_field) { |
|
146 | + if ($c_field['type'] == 'select' && $c_field['rows'] > 1 && in_array('#'.$name, array_keys($content['mapping']))) { |
|
147 | 147 | $field_list['#'.$name] = $c_field['label']; |
148 | 148 | } |
149 | 149 | } |
@@ -13,7 +13,8 @@ discard block |
||
13 | 13 | |
14 | 14 | class addressbook_wizard_export_contacts_csv extends importexport_wizard_basic_export_csv |
15 | 15 | { |
16 | - public function __construct() { |
|
16 | + public function __construct() |
|
17 | + { |
|
17 | 18 | parent::__construct(); |
18 | 19 | |
19 | 20 | $this->steps['wizard_step50'] = lang('Choose export options'); |
@@ -22,7 +23,8 @@ discard block |
||
22 | 23 | // Field mapping |
23 | 24 | $bocontacts = new Api\Contacts(); |
24 | 25 | $this->export_fields = $bocontacts->contact_fields; |
25 | - foreach($bocontacts->customfields as $name => $data) { |
|
26 | + foreach($bocontacts->customfields as $name => $data) |
|
27 | + { |
|
26 | 28 | $this->export_fields['#'.$name] = $data['label']; |
27 | 29 | } |
28 | 30 | unset($this->export_fields['jpegphoto']); // can't cvs export that |
@@ -37,17 +39,24 @@ discard block |
||
37 | 39 | /** |
38 | 40 | * Overridden to be able to skip the next step |
39 | 41 | */ |
40 | - function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv) { |
|
42 | + function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv) |
|
43 | + { |
|
41 | 44 | |
42 | - if ($content['step'] == 'wizard_step40' && array_search('pressed', $content['button']) == 'next') { |
|
45 | + if ($content['step'] == 'wizard_step40' && array_search('pressed', $content['button']) == 'next') |
|
46 | + { |
|
43 | 47 | $result = parent::wizard_step40($content, $sel_options, $readonlys, $preserv); |
44 | 48 | $field_list = $this->get_field_list($content); |
45 | - if(count($field_list)) { |
|
49 | + if(count($field_list)) |
|
50 | + { |
|
46 | 51 | return $result; |
47 | - } else { |
|
52 | + } |
|
53 | + else |
|
54 | + { |
|
48 | 55 | return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],2); |
49 | 56 | } |
50 | - } else { |
|
57 | + } |
|
58 | + else |
|
59 | + { |
|
51 | 60 | return parent::wizard_step40($content, $sel_options, $readonlys, $preserv); |
52 | 61 | } |
53 | 62 | } |
@@ -56,16 +65,22 @@ discard block |
||
56 | 65 | * Choose how to export multi-selects (includes Api\Categories) |
57 | 66 | */ |
58 | 67 | function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv) |
59 | - { |
|
60 | - if($this->debug) error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true)); |
|
68 | + { |
|
69 | + if($this->debug) |
|
70 | + { |
|
71 | + error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true)); |
|
72 | + } |
|
61 | 73 | // return from step50 |
62 | 74 | if ($content['step'] == 'wizard_step50') |
63 | 75 | { |
64 | - if($content['explode_multiselects']) { |
|
76 | + if($content['explode_multiselects']) |
|
77 | + { |
|
65 | 78 | $explodes = $content['explode_multiselects']; |
66 | 79 | $content['explode_multiselects'] = array(); |
67 | - foreach($explodes as $row => $settings) { |
|
68 | - if($settings['explode'] != addressbook_export_contacts_csv::NO_EXPLODE) { |
|
80 | + foreach($explodes as $row => $settings) |
|
81 | + { |
|
82 | + if($settings['explode'] != addressbook_export_contacts_csv::NO_EXPLODE) |
|
83 | + { |
|
69 | 84 | $content['explode_multiselects'][$settings['field']] = $settings; |
70 | 85 | } |
71 | 86 | } |
@@ -93,7 +108,8 @@ discard block |
||
93 | 108 | $settings = $content['explode_multiselects'] ? $content['explode_multiselects'] : $content['plugin_options']['explode_multiselects']; |
94 | 109 | |
95 | 110 | // Skip this step if no fields applicable |
96 | - if(count($field_list) == 0) { |
|
111 | + if(count($field_list) == 0) |
|
112 | + { |
|
97 | 113 | $content['explode_multiselects'] = array(); |
98 | 114 | } |
99 | 115 | |
@@ -108,15 +124,19 @@ discard block |
||
108 | 124 | ); |
109 | 125 | |
110 | 126 | $row = 1; |
111 | - foreach($field_list as $field => $name) { |
|
127 | + foreach($field_list as $field => $name) |
|
128 | + { |
|
112 | 129 | $content['explode_multiselects'][$row] = array( |
113 | 130 | 'field' => $field, |
114 | 131 | 'name' => $name, |
115 | 132 | 'explode'=> $settings[$field] |
116 | 133 | ); |
117 | - if($field == 'cat_id') { |
|
134 | + if($field == 'cat_id') |
|
135 | + { |
|
118 | 136 | $sel_options['explode_multiselects'][$row]['explode'] = $cat_options; |
119 | - } else { |
|
137 | + } |
|
138 | + else |
|
139 | + { |
|
120 | 140 | $sel_options['explode_multiselects'][$row]['explode'] = $multi_options; |
121 | 141 | } |
122 | 142 | $row++; |
@@ -132,18 +152,22 @@ discard block |
||
132 | 152 | /** |
133 | 153 | * Get a list of multi-select fields |
134 | 154 | */ |
135 | - protected function get_field_list($content) { |
|
155 | + protected function get_field_list($content) |
|
156 | + { |
|
136 | 157 | $field_list = array(); |
137 | 158 | |
138 | 159 | // Category gets special handling |
139 | - if(in_array('cat_id', array_keys($content['mapping']))) { |
|
160 | + if(in_array('cat_id', array_keys($content['mapping']))) |
|
161 | + { |
|
140 | 162 | $field_list['cat_id'] = $this->export_fields['cat_id']; |
141 | 163 | } |
142 | 164 | |
143 | 165 | // Add any multi-select custom fields |
144 | 166 | $custom = Api\Storage\Customfields::get('addressbook'); |
145 | - foreach($custom as $name => $c_field) { |
|
146 | - if($c_field['type'] == 'select' && $c_field['rows'] > 1 && in_array('#'.$name, array_keys($content['mapping']))) { |
|
167 | + foreach($custom as $name => $c_field) |
|
168 | + { |
|
169 | + if($c_field['type'] == 'select' && $c_field['rows'] > 1 && in_array('#'.$name, array_keys($content['mapping']))) |
|
170 | + { |
|
147 | 171 | $field_list['#'.$name] = $c_field['label']; |
148 | 172 | } |
149 | 173 | } |
@@ -25,4 +25,4 @@ |
||
25 | 25 | unset($old_state['advanced_search']); |
26 | 26 | Api\Cache::setSession('addressbook', 'index', $old_state); |
27 | 27 | } |
28 | -Api\Egw::redirect_link('/index.php','menuaction=addressbook.addressbook_ui.index'); |
|
28 | +Api\Egw::redirect_link('/index.php', 'menuaction=addressbook.addressbook_ui.index'); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | { |
35 | 35 | if (isset($_GET['auth'])) |
36 | 36 | { |
37 | - list($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']) = explode(':',base64_decode($_GET['auth']),2); |
|
37 | + list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':', base64_decode($_GET['auth']), 2); |
|
38 | 38 | } |
39 | 39 | return Api\Header\Authenticate::autocreate_session_callback($account); |
40 | 40 | } |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | 'noheader' => True, |
46 | 46 | 'currentapp' => preg_match('|/remote.php/webdav/apps/([A-Za-z0-9_-]+)/|', $_SERVER['REQUEST_URI'], $matches) ? $matches[1] : 'filemanager', |
47 | 47 | 'autocreate_session_callback' => 'check_access', |
48 | - 'no_exception_handler' => 'basic_auth', // we use a basic auth exception handler (sends exception message as basic auth realm) |
|
49 | - 'auth_realm' => 'EGroupware WebDAV server', // cant use Vfs\WebDAV::REALM as autoloading and include path not yet setup! |
|
48 | + 'no_exception_handler' => 'basic_auth', // we use a basic auth exception handler (sends exception message as basic auth realm) |
|
49 | + 'auth_realm' => 'EGroupware WebDAV server', // cant use Vfs\WebDAV::REALM as autoloading and include path not yet setup! |
|
50 | 50 | ) |
51 | 51 | ); |
52 | 52 | |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | |
75 | 75 | // temporary mount ownCloud default /clientsync as /home/$user, if not explicitly mounted |
76 | 76 | // so ownCloud dir contains users home-dir by default |
77 | -if (strpos($_SERVER['REQUEST_URI'],'/remote.php/webdav/clientsync') !== false && |
|
78 | - ($fstab=Vfs::mount()) && !isset($fstab['/clientsync'])) |
|
77 | +if (strpos($_SERVER['REQUEST_URI'], '/remote.php/webdav/clientsync') !== false && |
|
78 | + ($fstab = Vfs::mount()) && !isset($fstab['/clientsync'])) |
|
79 | 79 | { |
80 | 80 | $is_root_backup = Vfs::$is_root; |
81 | 81 | Vfs::$is_root = true; |
82 | - $ok = Vfs::mount($url='vfs://default/home/$user', $clientsync='/clientsync', null, false); |
|
82 | + $ok = Vfs::mount($url = 'vfs://default/home/$user', $clientsync = '/clientsync', null, false); |
|
83 | 83 | Vfs::$is_root = $is_root_backup; |
84 | 84 | //error_log("mounting ownCloud default '$clientsync' as '$url' ".($ok ? 'successful' : 'failed!')); |
85 | 85 | } |
@@ -19,8 +19,8 @@ |
||
19 | 19 | // or an uncoditional redirect to this file or copy groupdav.htaccess to your docroot as .htaccess |
20 | 20 | if ($_SERVER['REQUEST_METHOD'] == 'PROPFIND' || $_SERVER['REQUEST_METHOD'] == 'OPTIONS') |
21 | 21 | { |
22 | - header('Location: groupdav.php/'); |
|
23 | - exit; |
|
22 | + header('Location: groupdav.php/'); |
|
23 | + exit; |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | // forward for not existing or empty header to setup |
@@ -24,13 +24,13 @@ discard block |
||
24 | 24 | } |
25 | 25 | |
26 | 26 | // forward for not existing or empty header to setup |
27 | -if(!file_exists('header.inc.php') || !filesize('header.inc.php')) |
|
27 | +if (!file_exists('header.inc.php') || !filesize('header.inc.php')) |
|
28 | 28 | { |
29 | 29 | Header('Location: setup/index.php'); |
30 | 30 | exit; |
31 | 31 | } |
32 | 32 | |
33 | -if(isset($_GET['hasupdates']) && $_GET['hasupdates'] == 'yes') |
|
33 | +if (isset($_GET['hasupdates']) && $_GET['hasupdates'] == 'yes') |
|
34 | 34 | { |
35 | 35 | $hasupdates = True; |
36 | 36 | } |
@@ -38,20 +38,20 @@ discard block |
||
38 | 38 | /* |
39 | 39 | This is the menuaction driver for the multi-layered design |
40 | 40 | */ |
41 | -if(isset($_GET['menuaction']) && preg_match('/^[A-Za-z0-9_]+\.[A-Za-z0-9_\\\\]+\.[A-Za-z0-9_]+$/',$_GET['menuaction'])) |
|
41 | +if (isset($_GET['menuaction']) && preg_match('/^[A-Za-z0-9_]+\.[A-Za-z0-9_\\\\]+\.[A-Za-z0-9_]+$/', $_GET['menuaction'])) |
|
42 | 42 | { |
43 | - list($app,$class,$method) = explode('.',$_GET['menuaction']); |
|
43 | + list($app, $class, $method) = explode('.', $_GET['menuaction']); |
|
44 | 44 | |
45 | 45 | // check if autoloadable class belongs to given app |
46 | 46 | if (substr($class, 0, 11) == 'EGroupware\\') |
47 | 47 | { |
48 | 48 | list(,$app_from_class) = explode('\\', strtolower($class)); |
49 | 49 | } |
50 | - elseif(strpos($class, '_') !== false) |
|
50 | + elseif (strpos($class, '_') !== false) |
|
51 | 51 | { |
52 | 52 | list($app_from_class) = explode('_', $class); |
53 | 53 | } |
54 | - if(!$app || !$class || !$method || isset($app_from_class) && |
|
54 | + if (!$app || !$class || !$method || isset($app_from_class) && |
|
55 | 55 | isset($GLOBALS['egw_info']['apps'][$app_from_class]) && $app_from_class != $app) |
56 | 56 | { |
57 | 57 | $invalid_data = True; |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $invalid_data = True; |
64 | 64 | } |
65 | 65 | //error_log(__METHOD__."$app,$class,$method"); |
66 | -if($app == 'phpgwapi') |
|
66 | +if ($app == 'phpgwapi') |
|
67 | 67 | { |
68 | 68 | $app = 'api'; |
69 | 69 | $api_requested = True; |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | // user changed timezone |
82 | 82 | if (isset($_GET['tz'])) |
83 | 83 | { |
84 | - Api\DateTime::setUserPrefs($_GET['tz']); // throws exception, if tz is invalid |
|
84 | + Api\DateTime::setUserPrefs($_GET['tz']); // throws exception, if tz is invalid |
|
85 | 85 | |
86 | - $GLOBALS['egw']->preferences->add('common','tz',$_GET['tz']); |
|
86 | + $GLOBALS['egw']->preferences->add('common', 'tz', $_GET['tz']); |
|
87 | 87 | $GLOBALS['egw']->preferences->save_repository(); |
88 | 88 | |
89 | 89 | if (($referer = Api\Header\Referer::get())) |
@@ -94,30 +94,30 @@ discard block |
||
94 | 94 | |
95 | 95 | // Check if we are using windows or normal webpage |
96 | 96 | $windowed = false; |
97 | -$tpl_info = EGW_SERVER_ROOT . '/phpgwapi/templates/' . basename($GLOBALS['egw_info']['user']['preferences']['common']['template_set']) . '/setup/setup.inc.php'; |
|
97 | +$tpl_info = EGW_SERVER_ROOT.'/phpgwapi/templates/'.basename($GLOBALS['egw_info']['user']['preferences']['common']['template_set']).'/setup/setup.inc.php'; |
|
98 | 98 | if (!file_exists($tpl_info)) |
99 | 99 | { |
100 | - $tpl_info = EGW_SERVER_ROOT.'/'.basename($GLOBALS['egw_info']['user']['preferences']['common']['template_set']) . '/setup/setup.inc.php'; |
|
100 | + $tpl_info = EGW_SERVER_ROOT.'/'.basename($GLOBALS['egw_info']['user']['preferences']['common']['template_set']).'/setup/setup.inc.php'; |
|
101 | 101 | } |
102 | -if(@file_exists($tpl_info)) |
|
102 | +if (@file_exists($tpl_info)) |
|
103 | 103 | { |
104 | 104 | include_once($tpl_info); |
105 | - if($GLOBALS['egw_info']['template'][$GLOBALS['egw_info']['user']['preferences']['common']['template_set']]['windowed']) |
|
105 | + if ($GLOBALS['egw_info']['template'][$GLOBALS['egw_info']['user']['preferences']['common']['template_set']]['windowed']) |
|
106 | 106 | { |
107 | 107 | $windowed = true; |
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
111 | 111 | |
112 | -if($app == 'api' && !$class && !$api_requested && !($windowed && $_GET['cd'] == 'yes' && !Api\Header\UserAgent::mobile()) && $GLOBALS['egw_info']['user']['preferences']['common']['template_set'] == 'idots') |
|
112 | +if ($app == 'api' && !$class && !$api_requested && !($windowed && $_GET['cd'] == 'yes' && !Api\Header\UserAgent::mobile()) && $GLOBALS['egw_info']['user']['preferences']['common']['template_set'] == 'idots') |
|
113 | 113 | { |
114 | 114 | if ($GLOBALS['egw_info']['server']['force_default_app'] && $GLOBALS['egw_info']['server']['force_default_app'] != 'user_choice') |
115 | 115 | { |
116 | 116 | $GLOBALS['egw_info']['user']['preferences']['common']['default_app'] = $GLOBALS['egw_info']['server']['force_default_app']; |
117 | 117 | } |
118 | - if($GLOBALS['egw_info']['user']['preferences']['common']['default_app'] && !$hasupdates) |
|
118 | + if ($GLOBALS['egw_info']['user']['preferences']['common']['default_app'] && !$hasupdates) |
|
119 | 119 | { |
120 | - Egw::redirect(Framework::index($GLOBALS['egw_info']['user']['preferences']['common']['default_app']),$GLOBALS['egw_info']['user']['preferences']['common']['default_app']); |
|
120 | + Egw::redirect(Framework::index($GLOBALS['egw_info']['user']['preferences']['common']['default_app']), $GLOBALS['egw_info']['user']['preferences']['common']['default_app']); |
|
121 | 121 | } |
122 | 122 | else |
123 | 123 | { |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
128 | -if($windowed && $_GET['cd'] == 'yes') |
|
128 | +if ($windowed && $_GET['cd'] == 'yes') |
|
129 | 129 | { |
130 | 130 | $GLOBALS['egw_info']['flags'] = array( |
131 | 131 | 'noheader' => False, |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | } |
138 | 138 | else |
139 | 139 | { |
140 | - if($api_requested) |
|
140 | + if ($api_requested) |
|
141 | 141 | { |
142 | 142 | $app = 'phpgwapi'; |
143 | 143 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | { |
151 | 151 | $obj = CreateObject($app.'.'.$class); |
152 | 152 | } |
153 | - if((is_array($obj->public_functions) && $obj->public_functions[$method]) && !$invalid_data) |
|
153 | + if ((is_array($obj->public_functions) && $obj->public_functions[$method]) && !$invalid_data) |
|
154 | 154 | { |
155 | 155 | $obj->$method(); |
156 | 156 | unset($app); |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | } |
162 | 162 | else |
163 | 163 | { |
164 | - if(!$app || !$class || !$method || $invalid_data) |
|
164 | + if (!$app || !$class || !$method || $invalid_data) |
|
165 | 165 | { |
166 | - if(@is_object($GLOBALS['egw']->log)) |
|
166 | + if (@is_object($GLOBALS['egw']->log)) |
|
167 | 167 | { |
168 | 168 | $GLOBALS['egw']->log->message(array( |
169 | 169 | 'text' => 'W-BadmenuactionVariable, menuaction missing or corrupt: %1', |
@@ -174,9 +174,9 @@ discard block |
||
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | - if(!is_array($GLOBALS[$class]->public_functions) || !$GLOBALS[$class]->public_functions[$method] && $method) |
|
177 | + if (!is_array($GLOBALS[$class]->public_functions) || !$GLOBALS[$class]->public_functions[$method] && $method) |
|
178 | 178 | { |
179 | - if(@is_object($GLOBALS['egw']->log)) |
|
179 | + if (@is_object($GLOBALS['egw']->log)) |
|
180 | 180 | { |
181 | 181 | $GLOBALS['egw']->log->message(array( |
182 | 182 | 'text' => 'W-BadmenuactionVariable, attempted to access private method: %1', |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | )); |
187 | 187 | } |
188 | 188 | } |
189 | - if(@is_object($GLOBALS['egw']->log)) |
|
189 | + if (@is_object($GLOBALS['egw']->log)) |
|
190 | 190 | { |
191 | 191 | $GLOBALS['egw']->log->commit(); |
192 | 192 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | $GLOBALS['egw']->redirect_link('/home/index.php'); |
195 | 195 | } |
196 | 196 | |
197 | - if(!isset($GLOBALS['egw_info']['nofooter'])) |
|
197 | + if (!isset($GLOBALS['egw_info']['nofooter'])) |
|
198 | 198 | { |
199 | 199 | echo $GLOBALS['egw']->framework->footer(); |
200 | 200 | } |