@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | /** |
124 | 124 | * converts accound_lid to account_id |
125 | 125 | * |
126 | - * @param mixed $_account_lid comma seperated list or array with lids |
|
126 | + * @param mixed $_account_lids comma seperated list or array with lids |
|
127 | 127 | * @return mixed comma seperated list or array with ids |
128 | 128 | */ |
129 | 129 | public static function account_name2id( &$_account_lids ) { |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | /** |
204 | 204 | * converts account_ids to account_lids |
205 | 205 | * |
206 | - * @param mixed $_account_ids comma seperated list or array with ids |
|
206 | + * @param mixed $_account_id comma seperated list or array with ids |
|
207 | 207 | * @return mixed comma seperated list or array with lids |
208 | 208 | */ |
209 | 209 | public static function account_id2name( $_account_id ) { |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | /** |
420 | 420 | * returns a list of importexport plugins |
421 | 421 | * |
422 | - * @param string $_tpye {import | export | all} |
|
422 | + * @param string $_type {import | export | all} |
|
423 | 423 | * @param string $_appname {<appname> | all} |
424 | 424 | * @return array(<appname> => array( <type> => array(<plugin> => <title>))) |
425 | 425 | */ |
@@ -591,6 +591,7 @@ discard block |
||
591 | 591 | * |
592 | 592 | * @param $app_name String name of app |
593 | 593 | * @param $plugin_name Name of the plugin |
594 | + * @param importexport_wizard_basic_export_csv $wizard_plugin |
|
594 | 595 | * |
595 | 596 | * @return Array ([fieldname] => array(widget settings), ...) |
596 | 597 | */ |
@@ -32,25 +32,25 @@ discard block |
||
32 | 32 | * Relative date ranges for filtering |
33 | 33 | */ |
34 | 34 | public static $relative_dates = array( // Start: year,month,day,week, End: year,month,day,week |
35 | - 'Today' => array(0,0,0,0, 0,0,1,0), |
|
36 | - 'Yesterday' => array(0,0,-1,0, 0,0,0,0), |
|
37 | - 'This week' => array(0,0,0,0, 0,0,0,1), |
|
38 | - 'Last week' => array(0,0,0,-1, 0,0,0,0), |
|
39 | - 'This month' => array(0,0,0,0, 0,1,0,0), |
|
40 | - 'Last month' => array(0,-1,0,0, 0,0,0,0), |
|
41 | - 'Last 3 months' => array(0,-3,0,0, 0,0,0,0), |
|
42 | - 'This quarter'=> array(0,0,0,0, 0,0,0,0), // Just a marker, needs special handling |
|
43 | - 'Last quarter'=> array(0,-4,0,0, 0,-4,0,0), // Just a marker |
|
44 | - 'This year' => array(0,0,0,0, 1,0,0,0), |
|
45 | - 'Last year' => array(-1,0,0,0, 0,0,0,0), |
|
46 | - '2 years ago' => array(-2,0,0,0, -1,0,0,0), |
|
47 | - '3 years ago' => array(-3,0,0,0, -2,0,0,0), |
|
48 | - ); |
|
35 | + 'Today' => array(0,0,0,0, 0,0,1,0), |
|
36 | + 'Yesterday' => array(0,0,-1,0, 0,0,0,0), |
|
37 | + 'This week' => array(0,0,0,0, 0,0,0,1), |
|
38 | + 'Last week' => array(0,0,0,-1, 0,0,0,0), |
|
39 | + 'This month' => array(0,0,0,0, 0,1,0,0), |
|
40 | + 'Last month' => array(0,-1,0,0, 0,0,0,0), |
|
41 | + 'Last 3 months' => array(0,-3,0,0, 0,0,0,0), |
|
42 | + 'This quarter'=> array(0,0,0,0, 0,0,0,0), // Just a marker, needs special handling |
|
43 | + 'Last quarter'=> array(0,-4,0,0, 0,-4,0,0), // Just a marker |
|
44 | + 'This year' => array(0,0,0,0, 1,0,0,0), |
|
45 | + 'Last year' => array(-1,0,0,0, 0,0,0,0), |
|
46 | + '2 years ago' => array(-2,0,0,0, -1,0,0,0), |
|
47 | + '3 years ago' => array(-3,0,0,0, -2,0,0,0), |
|
48 | + ); |
|
49 | 49 | |
50 | 50 | /** |
51 | - * Files known to cause problems, and will be skipped in a plugin scan |
|
52 | - * If you put appname => true, the whole app will be skipped. |
|
53 | - */ |
|
51 | + * Files known to cause problems, and will be skipped in a plugin scan |
|
52 | + * If you put appname => true, the whole app will be skipped. |
|
53 | + */ |
|
54 | 54 | protected static $blacklist_files = array( |
55 | 55 | 'api' => true, |
56 | 56 | 'etemplate' => true, |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | ); |
65 | 65 | |
66 | 66 | /** |
67 | - * Class used to provide extra conversion functions |
|
68 | - * |
|
69 | - * Passed in as a param to conversion() |
|
70 | - */ |
|
67 | + * Class used to provide extra conversion functions |
|
68 | + * |
|
69 | + * Passed in as a param to conversion() |
|
70 | + */ |
|
71 | 71 | protected static $cclass = null; |
72 | 72 | |
73 | 73 | /** |
@@ -32,19 +32,19 @@ discard block |
||
32 | 32 | * Relative date ranges for filtering |
33 | 33 | */ |
34 | 34 | public static $relative_dates = array( // Start: year,month,day,week, End: year,month,day,week |
35 | - 'Today' => array(0,0,0,0, 0,0,1,0), |
|
36 | - 'Yesterday' => array(0,0,-1,0, 0,0,0,0), |
|
37 | - 'This week' => array(0,0,0,0, 0,0,0,1), |
|
38 | - 'Last week' => array(0,0,0,-1, 0,0,0,0), |
|
39 | - 'This month' => array(0,0,0,0, 0,1,0,0), |
|
40 | - 'Last month' => array(0,-1,0,0, 0,0,0,0), |
|
41 | - 'Last 3 months' => array(0,-3,0,0, 0,0,0,0), |
|
42 | - 'This quarter'=> array(0,0,0,0, 0,0,0,0), // Just a marker, needs special handling |
|
43 | - 'Last quarter'=> array(0,-4,0,0, 0,-4,0,0), // Just a marker |
|
44 | - 'This year' => array(0,0,0,0, 1,0,0,0), |
|
45 | - 'Last year' => array(-1,0,0,0, 0,0,0,0), |
|
46 | - '2 years ago' => array(-2,0,0,0, -1,0,0,0), |
|
47 | - '3 years ago' => array(-3,0,0,0, -2,0,0,0), |
|
35 | + 'Today' => array(0, 0, 0, 0, 0, 0, 1, 0), |
|
36 | + 'Yesterday' => array(0, 0, -1, 0, 0, 0, 0, 0), |
|
37 | + 'This week' => array(0, 0, 0, 0, 0, 0, 0, 1), |
|
38 | + 'Last week' => array(0, 0, 0, -1, 0, 0, 0, 0), |
|
39 | + 'This month' => array(0, 0, 0, 0, 0, 1, 0, 0), |
|
40 | + 'Last month' => array(0, -1, 0, 0, 0, 0, 0, 0), |
|
41 | + 'Last 3 months' => array(0, -3, 0, 0, 0, 0, 0, 0), |
|
42 | + 'This quarter'=> array(0, 0, 0, 0, 0, 0, 0, 0), // Just a marker, needs special handling |
|
43 | + 'Last quarter'=> array(0, -4, 0, 0, 0, -4, 0, 0), // Just a marker |
|
44 | + 'This year' => array(0, 0, 0, 0, 1, 0, 0, 0), |
|
45 | + 'Last year' => array(-1, 0, 0, 0, 0, 0, 0, 0), |
|
46 | + '2 years ago' => array(-2, 0, 0, 0, -1, 0, 0, 0), |
|
47 | + '3 years ago' => array(-3, 0, 0, 0, -2, 0, 0, 0), |
|
48 | 48 | ); |
49 | 49 | |
50 | 50 | /** |
@@ -85,22 +85,22 @@ discard block |
||
85 | 85 | * @param string $_format format of time string e.g.: d.m.Y H:i |
86 | 86 | * @param int $_is_dst is day light saving time? 0 = no, 1 = yes, -1 = system default |
87 | 87 | */ |
88 | - public static function custom_strtotime( $_string, $_format='', $_is_dst = -1) { |
|
89 | - if ( empty( $_format ) ) return strtotime( $_string ); |
|
90 | - $fparams = explode( ',', chunk_split( $_format, 1, ',' ) ); |
|
88 | + public static function custom_strtotime($_string, $_format = '', $_is_dst = -1) { |
|
89 | + if (empty($_format)) return strtotime($_string); |
|
90 | + $fparams = explode(',', chunk_split($_format, 1, ',')); |
|
91 | 91 | $spos = 0; |
92 | - foreach ( $fparams as $fparam ) { |
|
93 | - |
|
94 | - switch ( $fparam ) { |
|
95 | - case 'd': (int)$day = substr( $_string, $spos, 2 ); $spos += 2; break; |
|
96 | - case 'm': (int)$mon = substr( $_string, $spos, 2 ); $spos += 2; break; |
|
97 | - case 'y': (int)$year = substr( $_string, $spos, 2 ); $spos += 2; break; |
|
98 | - case 'Y': (int)$year = substr( $_string, $spos, 4 ); $spos += 4; break; |
|
99 | - case 'H': (int)$hour = substr( $_string, $spos, 2 ); $spos += 2; break; |
|
100 | - case 'h': (int)$hour = substr( $_string, $spos, 2 ); $spos += 2; break; |
|
101 | - case 'i': (int)$min = substr( $_string, $spos, 2 ); $spos += 2; break; |
|
102 | - case 's': (int)$sec = substr( $_string, $spos, 2 ); $spos += 2; break; |
|
103 | - case 'O': (int)$offset = $year = substr( $_string, $spos, 5 ); $spos += 5; break; |
|
92 | + foreach ($fparams as $fparam) { |
|
93 | + |
|
94 | + switch ($fparam) { |
|
95 | + case 'd': (int)$day = substr($_string, $spos, 2); $spos += 2; break; |
|
96 | + case 'm': (int)$mon = substr($_string, $spos, 2); $spos += 2; break; |
|
97 | + case 'y': (int)$year = substr($_string, $spos, 2); $spos += 2; break; |
|
98 | + case 'Y': (int)$year = substr($_string, $spos, 4); $spos += 4; break; |
|
99 | + case 'H': (int)$hour = substr($_string, $spos, 2); $spos += 2; break; |
|
100 | + case 'h': (int)$hour = substr($_string, $spos, 2); $spos += 2; break; |
|
101 | + case 'i': (int)$min = substr($_string, $spos, 2); $spos += 2; break; |
|
102 | + case 's': (int)$sec = substr($_string, $spos, 2); $spos += 2; break; |
|
103 | + case 'O': (int)$offset = $year = substr($_string, $spos, 5); $spos += 5; break; |
|
104 | 104 | case 'a': (int)$hour = $fparam == 'am' ? $hour : $hour + 12; break; |
105 | 105 | case 'A': (int)$hour = $fparam == 'AM' ? $hour : $hour + 12; break; |
106 | 106 | default: $spos++; // seperator |
@@ -111,11 +111,11 @@ discard block |
||
111 | 111 | $timestamp = mktime($hour, $min, $sec, $mon, $day, $year, $_is_dst); |
112 | 112 | |
113 | 113 | // offset given? |
114 | - if ( isset( $offset ) && strlen( $offset == 5 ) ) { |
|
114 | + if (isset($offset) && strlen($offset == 5)) { |
|
115 | 115 | $operator = $offset{0}; |
116 | - $ohour = 60 * 60 * (int)substr( $offset, 1, 2 ); |
|
117 | - $omin = 60 * (int)substr( $offset, 3, 2 ); |
|
118 | - if ( $operator == '+' ) $timestamp += $ohour + $omin; |
|
116 | + $ohour = 60 * 60 * (int)substr($offset, 1, 2); |
|
117 | + $omin = 60 * (int)substr($offset, 3, 2); |
|
118 | + if ($operator == '+') $timestamp += $ohour + $omin; |
|
119 | 119 | else $timestamp -= $ohour + $omin; |
120 | 120 | } |
121 | 121 | return $timestamp; |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | * @param mixed $_account_lid comma seperated list or array with lids |
127 | 127 | * @return mixed comma seperated list or array with ids |
128 | 128 | */ |
129 | - public static function account_name2id( &$_account_lids ) { |
|
130 | - $account_lids = is_array( $_account_lids ) ? $_account_lids : explode( ',', $_account_lids ); |
|
129 | + public static function account_name2id(&$_account_lids) { |
|
130 | + $account_lids = is_array($_account_lids) ? $_account_lids : explode(',', $_account_lids); |
|
131 | 131 | $skip = false; |
132 | - foreach ( $account_lids as $key => $account_lid ) { |
|
133 | - if($skip) { |
|
132 | + foreach ($account_lids as $key => $account_lid) { |
|
133 | + if ($skip) { |
|
134 | 134 | unset($account_lids[$key]); |
135 | 135 | $skip = false; |
136 | 136 | continue; |
@@ -138,15 +138,15 @@ discard block |
||
138 | 138 | $account_lid = trim($account_lid); |
139 | 139 | |
140 | 140 | // Handle any IDs that slip in |
141 | - if(is_numeric($account_lid) && $GLOBALS['egw']->accounts->id2name($account_lid)) { |
|
141 | + if (is_numeric($account_lid) && $GLOBALS['egw']->accounts->id2name($account_lid)) { |
|
142 | 142 | unset($account_lids[$key]); |
143 | 143 | $account_ids[] = (int)$account_lid; |
144 | 144 | continue; |
145 | 145 | } |
146 | 146 | // Check for [username] |
147 | - if(strpos($account_lid,'[') !== false) |
|
147 | + if (strpos($account_lid, '[') !== false) |
|
148 | 148 | { |
149 | - if(preg_match('/\[(.+)\]/',$account_lid,$matches)) |
|
149 | + if (preg_match('/\[(.+)\]/', $account_lid, $matches)) |
|
150 | 150 | { |
151 | 151 | $account_id = $GLOBALS['egw']->accounts->name2id($matches[1]); |
152 | 152 | unset($account_lids[$key]); |
@@ -157,46 +157,46 @@ discard block |
||
157 | 157 | |
158 | 158 | // Handle users listed as Lastname, Firstname instead of login ID |
159 | 159 | // Do this first, in case their first name matches a username |
160 | - if ( $account_lids[$key+1][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id( trim($account_lids[$key+1]).' ' .$account_lid, 'account_fullname')) { |
|
160 | + if ($account_lids[$key + 1][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id(trim($account_lids[$key + 1]).' '.$account_lid, 'account_fullname')) { |
|
161 | 161 | $account_ids[] = $account_id; |
162 | 162 | unset($account_lids[$key]); |
163 | 163 | $skip = true; // Skip the next one, it's the first name |
164 | - continue ; |
|
164 | + continue; |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | // Deal with groups listed as <name> Group, remove the Group |
168 | - if(substr(trim($account_lid),-strlen(lang('Group'))) == lang('Group')) |
|
168 | + if (substr(trim($account_lid), -strlen(lang('Group'))) == lang('Group')) |
|
169 | 169 | { |
170 | 170 | $account_lid = trim(substr(trim($account_lid), 0, -strlen(lang('Group')))); |
171 | 171 | } |
172 | 172 | |
173 | - if ( $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid )) { |
|
173 | + if ($account_id = $GLOBALS['egw']->accounts->name2id($account_lid)) { |
|
174 | 174 | $account_ids[] = $account_id; |
175 | 175 | unset($account_lids[$key]); |
176 | 176 | continue; |
177 | 177 | } |
178 | - if ( $account_id = $GLOBALS['egw']->accounts->name2id( trim($account_lid), 'account_fullname' )) { |
|
178 | + if ($account_id = $GLOBALS['egw']->accounts->name2id(trim($account_lid), 'account_fullname')) { |
|
179 | 179 | $account_ids[] = $account_id; |
180 | 180 | unset($account_lids[$key]); |
181 | 181 | continue; |
182 | 182 | } |
183 | 183 | |
184 | 184 | // Handle groups listed as Group, <name> |
185 | - if ( $account_lids[$key][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid)) { |
|
185 | + if ($account_lids[$key][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id($account_lid)) { |
|
186 | 186 | $account_ids[] = $account_id; |
187 | - unset($account_lids[$key-1]); |
|
187 | + unset($account_lids[$key - 1]); |
|
188 | 188 | unset($account_lids[$key]); |
189 | 189 | continue; |
190 | 190 | } |
191 | 191 | // Group, <name> - remove the Group part |
192 | - if($account_lid == lang('Group')) |
|
192 | + if ($account_lid == lang('Group')) |
|
193 | 193 | { |
194 | 194 | unset($account_lids[$key]); |
195 | 195 | continue; |
196 | 196 | } |
197 | 197 | } |
198 | - $_account_lids = (is_array($_account_lids) ? $account_lids : implode(',',array_unique($account_lids))); |
|
199 | - return is_array( $_account_lids ) ? array_unique($account_ids) : implode( ',', array_unique((array)$account_ids )); |
|
198 | + $_account_lids = (is_array($_account_lids) ? $account_lids : implode(',', array_unique($account_lids))); |
|
199 | + return is_array($_account_lids) ? array_unique($account_ids) : implode(',', array_unique((array)$account_ids)); |
|
200 | 200 | |
201 | 201 | } // end of member function account_lid2id |
202 | 202 | |
@@ -206,14 +206,14 @@ discard block |
||
206 | 206 | * @param mixed $_account_ids comma seperated list or array with ids |
207 | 207 | * @return mixed comma seperated list or array with lids |
208 | 208 | */ |
209 | - public static function account_id2name( $_account_id ) { |
|
210 | - $account_ids = is_array( $_account_id ) ? $_account_id : explode( ',', $_account_id ); |
|
211 | - foreach ( $account_ids as $account_id ) { |
|
212 | - if ( $account_lid = $GLOBALS['egw']->accounts->id2name( $account_id )) { |
|
209 | + public static function account_id2name($_account_id) { |
|
210 | + $account_ids = is_array($_account_id) ? $_account_id : explode(',', $_account_id); |
|
211 | + foreach ($account_ids as $account_id) { |
|
212 | + if ($account_lid = $GLOBALS['egw']->accounts->id2name($account_id)) { |
|
213 | 213 | $account_lids[] = $account_lid; |
214 | 214 | } |
215 | 215 | } |
216 | - return is_array( $_account_id ) ? $account_lids : implode( ',', (array)$account_lids ); |
|
216 | + return is_array($_account_id) ? $account_lids : implode(',', (array)$account_lids); |
|
217 | 217 | } // end of member function account_id2lid |
218 | 218 | |
219 | 219 | /** |
@@ -222,12 +222,12 @@ discard block |
||
222 | 222 | * @param mixed _cat_ids comma seperated list or array |
223 | 223 | * @return mixed comma seperated list or array with cat_names |
224 | 224 | */ |
225 | - public static function cat_id2name( $_cat_ids ) { |
|
226 | - $cat_ids = is_array( $_cat_ids ) ? $_cat_ids : explode( ',', $_cat_ids ); |
|
227 | - foreach ( $cat_ids as $cat_id ) { |
|
228 | - $cat_names[] = Api\Categories::id2name( (int)$cat_id ); |
|
225 | + public static function cat_id2name($_cat_ids) { |
|
226 | + $cat_ids = is_array($_cat_ids) ? $_cat_ids : explode(',', $_cat_ids); |
|
227 | + foreach ($cat_ids as $cat_id) { |
|
228 | + $cat_names[] = Api\Categories::id2name((int)$cat_id); |
|
229 | 229 | } |
230 | - return is_array( $_cat_ids ) ? $cat_names : implode(',',(array)$cat_names); |
|
230 | + return is_array($_cat_ids) ? $cat_names : implode(',', (array)$cat_names); |
|
231 | 231 | } // end of member function category_id2name |
232 | 232 | |
233 | 233 | /** |
@@ -238,24 +238,24 @@ discard block |
||
238 | 238 | * @param int $parent Optional parent ID to use for new categories |
239 | 239 | * @return mixed comma seperated list or array with cat_ids |
240 | 240 | */ |
241 | - public static function cat_name2id( $_cat_names, $parent = 0 ) { |
|
242 | - $cats = new Api\Categories(); // uses current user and app (egw_info[flags][currentapp]) |
|
241 | + public static function cat_name2id($_cat_names, $parent = 0) { |
|
242 | + $cats = new Api\Categories(); // uses current user and app (egw_info[flags][currentapp]) |
|
243 | 243 | |
244 | - $cat_names = is_array( $_cat_names ) ? $_cat_names : explode( ',', $_cat_names ); |
|
245 | - foreach ( $cat_names as $cat_name ) { |
|
244 | + $cat_names = is_array($_cat_names) ? $_cat_names : explode(',', $_cat_names); |
|
245 | + foreach ($cat_names as $cat_name) { |
|
246 | 246 | $cat_name = trim($cat_name); |
247 | - if ( $cat_name == '' ) continue; |
|
248 | - if ( ( $cat_id = $cats->name2id( $cat_name ) ) == 0 && !self::$dry_run) { |
|
249 | - $cat_id = $cats->add( array( |
|
247 | + if ($cat_name == '') continue; |
|
248 | + if (($cat_id = $cats->name2id($cat_name)) == 0 && !self::$dry_run) { |
|
249 | + $cat_id = $cats->add(array( |
|
250 | 250 | 'name' => $cat_name, |
251 | 251 | 'parent' => $parent, |
252 | 252 | 'access' => 'public', |
253 | - 'descr' => $cat_name. ' ('. lang('Automatically created by importexport'). ')' |
|
253 | + 'descr' => $cat_name.' ('.lang('Automatically created by importexport').')' |
|
254 | 254 | )); |
255 | 255 | } |
256 | 256 | $cat_ids[] = $cat_id; |
257 | 257 | } |
258 | - return is_array( $_cat_names ) ? $cat_ids : implode( ',', (array)$cat_ids ); |
|
258 | + return is_array($_cat_names) ? $cat_ids : implode(',', (array)$cat_ids); |
|
259 | 259 | |
260 | 260 | } // end of member function category_name2id |
261 | 261 | |
@@ -294,76 +294,76 @@ discard block |
||
294 | 294 | * @param object &$cclass calling class to process the '@ evals' |
295 | 295 | * @return bool |
296 | 296 | */ |
297 | - public static function conversion( &$_record, $_conversion, &$_cclass = null ) { |
|
298 | - if (empty( $_conversion ) ) return $_record; |
|
297 | + public static function conversion(&$_record, $_conversion, &$_cclass = null) { |
|
298 | + if (empty($_conversion)) return $_record; |
|
299 | 299 | |
300 | - self::$cclass =& $_cclass; |
|
300 | + self::$cclass = & $_cclass; |
|
301 | 301 | |
302 | 302 | $PSep = '||'; // Pattern-Separator, separats the pattern-replacement-pairs in conversion |
303 | 303 | $ASep = '|>'; // Assignment-Separator, separats pattern and replacesment |
304 | - $CPre = '|['; $CPos = ']'; // |[_record-idx] is expanded to the corespondig value |
|
304 | + $CPre = '|['; $CPos = ']'; // |[_record-idx] is expanded to the corespondig value |
|
305 | 305 | $TPre = '|T{'; $TPos = '}'; // |{_record-idx} is trimmed |
306 | - $CntlPre = '|TC{'; // Filter all cntl-chars \x01-\x1f and trim |
|
307 | - $CntlnCLPre = '|TCnCL{'; // Like |C{ but allowes CR and LF |
|
308 | - $INE = '|INE{'; // Only insert if stuff in ^^ is not empty |
|
306 | + $CntlPre = '|TC{'; // Filter all cntl-chars \x01-\x1f and trim |
|
307 | + $CntlnCLPre = '|TCnCL{'; // Like |C{ but allowes CR and LF |
|
308 | + $INE = '|INE{'; // Only insert if stuff in ^^ is not empty |
|
309 | 309 | |
310 | - foreach ( $_conversion as $idx => $conversion_string ) { |
|
311 | - if ( empty( $conversion_string ) ) continue; |
|
310 | + foreach ($_conversion as $idx => $conversion_string) { |
|
311 | + if (empty($conversion_string)) continue; |
|
312 | 312 | |
313 | 313 | // fetch patterns ($rvalues) |
314 | 314 | $rvalues = array(); |
315 | - $pat_reps = explode( $PSep, stripslashes( $conversion_string ) ); |
|
316 | - foreach( $pat_reps as $k => $pat_rep ) { |
|
317 | - list( $pattern, $replace ) = explode( $ASep, $pat_rep, 2 ); |
|
318 | - if( $replace == '' ) { |
|
315 | + $pat_reps = explode($PSep, stripslashes($conversion_string)); |
|
316 | + foreach ($pat_reps as $k => $pat_rep) { |
|
317 | + list($pattern, $replace) = explode($ASep, $pat_rep, 2); |
|
318 | + if ($replace == '') { |
|
319 | 319 | $replace = $pattern; $pattern = '^.*$'; |
320 | 320 | } |
321 | - $rvalues[$pattern] = $replace; // replace two with only one, added by the form |
|
321 | + $rvalues[$pattern] = $replace; // replace two with only one, added by the form |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | // conversion list may be longer than $_record aka (no_csv) |
325 | - $val = array_key_exists( $idx, $_record ) ? $_record[$idx] : ''; |
|
325 | + $val = array_key_exists($idx, $_record) ? $_record[$idx] : ''; |
|
326 | 326 | |
327 | 327 | $c_functions = array('cat', 'account', 'strtotime', 'list'); |
328 | - if($_cclass) { |
|
328 | + if ($_cclass) { |
|
329 | 329 | // Add in additional methods |
330 | 330 | $reflection = new ReflectionClass(get_class($_cclass)); |
331 | 331 | $methods = $reflection->getMethods(ReflectionMethod::IS_STATIC); |
332 | - foreach($methods as $method) { |
|
332 | + foreach ($methods as $method) { |
|
333 | 333 | $c_functions[] = $method->name; |
334 | 334 | } |
335 | 335 | } |
336 | 336 | $c_functions = implode('|', $c_functions); |
337 | - foreach ( $rvalues as $pattern => $replace ) { |
|
337 | + foreach ($rvalues as $pattern => $replace) { |
|
338 | 338 | // Allow to include record indexes in pattern |
339 | 339 | $reg = '/\|\[([0-9]+)\]/'; |
340 | - while( preg_match( $reg, $pattern, $vars ) ) { |
|
340 | + while (preg_match($reg, $pattern, $vars)) { |
|
341 | 341 | // expand all _record fields |
342 | 342 | $pattern = str_replace( |
343 | - $CPre . $vars[1] . $CPos, |
|
343 | + $CPre.$vars[1].$CPos, |
|
344 | 344 | $_record[array_search($vars[1], array_keys($_record))], |
345 | 345 | $pattern |
346 | 346 | ); |
347 | 347 | } |
348 | - if( preg_match('/'. (string)$pattern.'/', $val) ) { |
|
348 | + if (preg_match('/'.(string)$pattern.'/', $val)) { |
|
349 | 349 | |
350 | - $val = preg_replace( '/'.(string)$pattern.'/', $replace, (string)$val ); |
|
350 | + $val = preg_replace('/'.(string)$pattern.'/', $replace, (string)$val); |
|
351 | 351 | |
352 | 352 | $reg = '/\|\[([a-zA-Z_0-9]+)\]/'; |
353 | - while( preg_match( $reg, $val, $vars ) ) { |
|
353 | + while (preg_match($reg, $val, $vars)) { |
|
354 | 354 | // expand all _record fields |
355 | 355 | $val = str_replace( |
356 | - $CPre . $vars[1] . $CPos, |
|
356 | + $CPre.$vars[1].$CPos, |
|
357 | 357 | $_record[array_search($vars[1], array_keys($_record))], |
358 | 358 | $val |
359 | 359 | ); |
360 | 360 | } |
361 | - $val = preg_replace_callback( "/($c_functions)\(([^)]*)\)/i", array( self, 'c2_dispatcher') , $val ); |
|
361 | + $val = preg_replace_callback("/($c_functions)\(([^)]*)\)/i", array(self, 'c2_dispatcher'), $val); |
|
362 | 362 | break; |
363 | 363 | } |
364 | 364 | } |
365 | 365 | // clean each field |
366 | - $val = preg_replace_callback("/(\|T\{|\|TC\{|\|TCnCL\{|\|INE\{)(.*)\}/", array( self, 'strclean'), $val ); |
|
366 | + $val = preg_replace_callback("/(\|T\{|\|TC\{|\|TCnCL\{|\|INE\{)(.*)\}/", array(self, 'strclean'), $val); |
|
367 | 367 | |
368 | 368 | $_record[$idx] = $val; |
369 | 369 | } |
@@ -377,42 +377,42 @@ discard block |
||
377 | 377 | * |
378 | 378 | * @param array $_matches |
379 | 379 | */ |
380 | - private static function c2_dispatcher( $_matches ) { |
|
380 | + private static function c2_dispatcher($_matches) { |
|
381 | 381 | $action = &$_matches[1]; // cat or account ... |
382 | - $data = &$_matches[2]; // datas for action |
|
382 | + $data = &$_matches[2]; // datas for action |
|
383 | 383 | |
384 | - switch ( $action ) { |
|
384 | + switch ($action) { |
|
385 | 385 | case 'strtotime' : |
386 | - list( $string, $format ) = explode( ',', $data ); |
|
387 | - return self::custom_strtotime( trim( $string ), trim( $format ) ); |
|
386 | + list($string, $format) = explode(',', $data); |
|
387 | + return self::custom_strtotime(trim($string), trim($format)); |
|
388 | 388 | case 'list': |
389 | - list( $split, $data, $index) = explode(',',$data); |
|
389 | + list($split, $data, $index) = explode(',', $data); |
|
390 | 390 | $exploded = explode($split, $data); |
391 | 391 | // 1 based indexing for user ease |
392 | 392 | return $exploded[$index - 1]; |
393 | 393 | default : |
394 | - if(self::$cclass && method_exists(self::$cclass, $action)) { |
|
394 | + if (self::$cclass && method_exists(self::$cclass, $action)) { |
|
395 | 395 | $class = get_class(self::$cclass); |
396 | 396 | return call_user_func("$class::$action", $data); |
397 | 397 | } |
398 | - $method = (string)$action. ( is_int( $data ) ? '_id2name' : '_name2id' ); |
|
399 | - if(self::$cclass && method_exists(self::$cclass, $method)) { |
|
398 | + $method = (string)$action.(is_int($data) ? '_id2name' : '_name2id'); |
|
399 | + if (self::$cclass && method_exists(self::$cclass, $method)) { |
|
400 | 400 | $class = get_class(self::$cclass); |
401 | 401 | return call_user_func("$class::$action", $data); |
402 | 402 | } else { |
403 | - return self::$method( $data ); |
|
403 | + return self::$method($data); |
|
404 | 404 | } |
405 | 405 | } |
406 | 406 | } |
407 | 407 | |
408 | - private static function strclean( $_matches ) { |
|
409 | - switch( $_matches[1] ) { |
|
410 | - case '|T{' : return trim( $_matches[2] ); |
|
411 | - case '|TC{' : return trim( preg_replace( '/[\x01-\x1F]+/', '', $_matches[2] ) ); |
|
412 | - case '|TCnCL{' : return trim( preg_replace( '/[\x01-\x09\x11\x12\x14-\x1F]+/', '', $_matches[2] ) ); |
|
413 | - case '|INE{' : return preg_match( '/\^.+\^/', $_matches[2] ) ? $_matches[2] : ''; |
|
408 | + private static function strclean($_matches) { |
|
409 | + switch ($_matches[1]) { |
|
410 | + case '|T{' : return trim($_matches[2]); |
|
411 | + case '|TC{' : return trim(preg_replace('/[\x01-\x1F]+/', '', $_matches[2])); |
|
412 | + case '|TCnCL{' : return trim(preg_replace('/[\x01-\x09\x11\x12\x14-\x1F]+/', '', $_matches[2])); |
|
413 | + case '|INE{' : return preg_match('/\^.+\^/', $_matches[2]) ? $_matches[2] : ''; |
|
414 | 414 | default: |
415 | - throw new Exception('Error in conversion string! "'. substr( $_matches[1], 0, -1 ). '" is not valid!'); |
|
415 | + throw new Exception('Error in conversion string! "'.substr($_matches[1], 0, -1).'" is not valid!'); |
|
416 | 416 | } |
417 | 417 | } |
418 | 418 | |
@@ -423,23 +423,23 @@ discard block |
||
423 | 423 | * @param string $_appname {<appname> | all} |
424 | 424 | * @return array(<appname> => array( <type> => array(<plugin> => <title>))) |
425 | 425 | */ |
426 | - public static function get_plugins( $_appname = 'all', $_type = 'all' ) { |
|
426 | + public static function get_plugins($_appname = 'all', $_type = 'all') { |
|
427 | 427 | $plugins = Api\Cache::getTree( |
428 | 428 | __CLASS__, |
429 | 429 | 'plugins', |
430 | - array('importexport_helper_functions','_get_plugins'), |
|
430 | + array('importexport_helper_functions', '_get_plugins'), |
|
431 | 431 | array(array_keys($GLOBALS['egw_info']['apps']), array('import', 'export')), |
432 | 432 | self::CACHE_EXPIRATION |
433 | 433 | ); |
434 | 434 | $appnames = $_appname == 'all' ? array_keys($GLOBALS['egw_info']['apps']) : (array)$_appname; |
435 | - $types = $_type == 'all' ? array('import','export') : (array)$_type; |
|
435 | + $types = $_type == 'all' ? array('import', 'export') : (array)$_type; |
|
436 | 436 | |
437 | 437 | // Testing: comment out Api\Cache call, use this |
438 | 438 | //$plugins = self::_get_plugins($appnames, $types); |
439 | - foreach($plugins as $appname => $_types) { |
|
440 | - if(!in_array($appname, $appnames)) unset($plugins[$appname]); |
|
439 | + foreach ($plugins as $appname => $_types) { |
|
440 | + if (!in_array($appname, $appnames)) unset($plugins[$appname]); |
|
441 | 441 | } |
442 | - foreach($plugins as $appname => $types) { |
|
442 | + foreach ($plugins as $appname => $types) { |
|
443 | 443 | $plugins[$appname] = array_intersect_key($plugins[$appname], $types); |
444 | 444 | } |
445 | 445 | return $plugins; |
@@ -448,25 +448,25 @@ discard block |
||
448 | 448 | public static function _get_plugins(Array $appnames, Array $types) { |
449 | 449 | $plugins = array(); |
450 | 450 | foreach ($appnames as $appname) { |
451 | - if(array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) continue; |
|
451 | + if (array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) continue; |
|
452 | 452 | |
453 | - $appdir = EGW_INCLUDE_ROOT. "/$appname/inc"; |
|
454 | - if(!is_dir($appdir)) continue; |
|
453 | + $appdir = EGW_INCLUDE_ROOT."/$appname/inc"; |
|
454 | + if (!is_dir($appdir)) continue; |
|
455 | 455 | $d = dir($appdir); |
456 | 456 | |
457 | 457 | // step through each file in appdir |
458 | 458 | while (false !== ($entry = $d->read())) { |
459 | 459 | // Blacklisted? |
460 | - if(is_array(self::$blacklist_files[$appname]) && in_array($entry, self::$blacklist_files[$appname])) continue; |
|
460 | + if (is_array(self::$blacklist_files[$appname]) && in_array($entry, self::$blacklist_files[$appname])) continue; |
|
461 | 461 | if (!preg_match('/^class\.([^.]+)\.inc\.php$/', $entry, $matches)) continue; |
462 | 462 | $classname = $matches[1]; |
463 | - $file = $appdir. '/'. $entry; |
|
463 | + $file = $appdir.'/'.$entry; |
|
464 | 464 | |
465 | 465 | foreach ($types as $type) { |
466 | - if( !is_file($file) || strpos($entry, $type) === false || strpos($entry,'wizard') !== false) continue; |
|
466 | + if (!is_file($file) || strpos($entry, $type) === false || strpos($entry, 'wizard') !== false) continue; |
|
467 | 467 | require_once($file); |
468 | 468 | $reflectionClass = new ReflectionClass($classname); |
469 | - if($reflectionClass->IsInstantiable() && |
|
469 | + if ($reflectionClass->IsInstantiable() && |
|
470 | 470 | $reflectionClass->implementsInterface('importexport_iface_'.$type.'_plugin')) { |
471 | 471 | try { |
472 | 472 | $plugin_object = new $classname; |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | $d->close(); |
483 | 483 | |
484 | 484 | $config = Api\Config::read('importexport'); |
485 | - if($config['update'] == 'auto') { |
|
485 | + if ($config['update'] == 'auto') { |
|
486 | 486 | self::load_defaults($appname); |
487 | 487 | } |
488 | 488 | } |
@@ -497,37 +497,37 @@ discard block |
||
497 | 497 | * @return array $num => $appname |
498 | 498 | */ |
499 | 499 | public static function get_apps($_type, $ignore_acl = false) { |
500 | - $apps = array_keys(self::get_plugins('all',$_type)); |
|
501 | - if($ignore_acl) return $apps; |
|
500 | + $apps = array_keys(self::get_plugins('all', $_type)); |
|
501 | + if ($ignore_acl) return $apps; |
|
502 | 502 | |
503 | - foreach($apps as $key => $app) { |
|
504 | - if(!self::has_definitions($app, $_type)) unset($apps[$key]); |
|
503 | + foreach ($apps as $key => $app) { |
|
504 | + if (!self::has_definitions($app, $_type)) unset($apps[$key]); |
|
505 | 505 | } |
506 | 506 | return $apps; |
507 | 507 | } |
508 | 508 | |
509 | 509 | public static function load_defaults($appname) { |
510 | 510 | // Check for new definitions to import from $appname/setup/*.xml |
511 | - $appdir = EGW_INCLUDE_ROOT. "/$appname/setup"; |
|
512 | - if(!is_dir($appdir)) return; |
|
511 | + $appdir = EGW_INCLUDE_ROOT."/$appname/setup"; |
|
512 | + if (!is_dir($appdir)) return; |
|
513 | 513 | $d = dir($appdir); |
514 | 514 | |
515 | 515 | // step through each file in app's setup |
516 | 516 | while (false !== ($entry = $d->read())) { |
517 | - $file = $appdir. '/'. $entry; |
|
518 | - list( $filename, $extension) = explode('.',$entry); |
|
519 | - if ( $extension != 'xml' ) continue; |
|
517 | + $file = $appdir.'/'.$entry; |
|
518 | + list($filename, $extension) = explode('.', $entry); |
|
519 | + if ($extension != 'xml') continue; |
|
520 | 520 | try { |
521 | 521 | // import will skip invalid files |
522 | - importexport_definitions_bo::import( $file ); |
|
522 | + importexport_definitions_bo::import($file); |
|
523 | 523 | } catch (Exception $e) { |
524 | - error_log(__CLASS__.__FUNCTION__. " import $appname definitions: " . $e->getMessage()); |
|
524 | + error_log(__CLASS__.__FUNCTION__." import $appname definitions: ".$e->getMessage()); |
|
525 | 525 | } |
526 | 526 | } |
527 | 527 | $d->close(); |
528 | 528 | } |
529 | 529 | |
530 | - public static function guess_filetype( $_file ) { |
|
530 | + public static function guess_filetype($_file) { |
|
531 | 531 | |
532 | 532 | } |
533 | 533 | |
@@ -538,24 +538,24 @@ discard block |
||
538 | 538 | * @param string $_type {import | export | all} |
539 | 539 | * @return boolean |
540 | 540 | */ |
541 | - public static function has_definitions( $_appname = 'all', $_type = 'all' ) { |
|
541 | + public static function has_definitions($_appname = 'all', $_type = 'all') { |
|
542 | 542 | $definitions = Api\Cache::getSession( |
543 | 543 | __CLASS__, |
544 | 544 | 'has_definitions', |
545 | - array('importexport_helper_functions','_has_definitions'), |
|
545 | + array('importexport_helper_functions', '_has_definitions'), |
|
546 | 546 | array(array_keys($GLOBALS['egw_info']['apps']), array('import', 'export')), |
547 | 547 | self::CACHE_EXPIRATION |
548 | 548 | ); |
549 | 549 | $appnames = $_appname == 'all' ? array_keys($GLOBALS['egw_info']['apps']) : (array)$_appname; |
550 | - $types = $_type == 'all' ? array('import','export') : (array)$_type; |
|
550 | + $types = $_type == 'all' ? array('import', 'export') : (array)$_type; |
|
551 | 551 | |
552 | 552 | // Testing: Comment out cache call above, use this |
553 | 553 | //$definitions = self::_has_definitions($appnames, $types); |
554 | 554 | |
555 | - foreach($definitions as $appname => $_types) { |
|
556 | - if(!in_array($appname, $appnames)) unset($definitions[$appname]); |
|
555 | + foreach ($definitions as $appname => $_types) { |
|
556 | + if (!in_array($appname, $appnames)) unset($definitions[$appname]); |
|
557 | 557 | } |
558 | - foreach($definitions as $appname => $_types) { |
|
558 | + foreach ($definitions as $appname => $_types) { |
|
559 | 559 | $definitions[$appname] = array_intersect_key($definitions[$appname], array_flip($types)); |
560 | 560 | } |
561 | 561 | return count($definitions[$appname]) > 0; |
@@ -565,11 +565,11 @@ discard block |
||
565 | 565 | public static function _has_definitions(Array $appnames, Array $types) { |
566 | 566 | $def = new importexport_definitions_bo(array('application'=>$appnames, 'type' => $types)); |
567 | 567 | $list = array(); |
568 | - foreach((array)$def->get_definitions() as $id) { |
|
568 | + foreach ((array)$def->get_definitions() as $id) { |
|
569 | 569 | // Need to instanciate it to check, but if the user doesn't have permission, it throws an exception |
570 | 570 | try { |
571 | 571 | $definition = new importexport_definition($id); |
572 | - if($def->is_permitted($definition->get_record_array())) { |
|
572 | + if ($def->is_permitted($definition->get_record_array())) { |
|
573 | 573 | $list[$definition->application][$definition->type][] = $id; |
574 | 574 | } |
575 | 575 | } catch (Exception $e) { |
@@ -601,13 +601,13 @@ discard block |
||
601 | 601 | $plugin = is_object($plugin_name) ? $plugin_name : new $plugin_name(); |
602 | 602 | $plugin_name = get_class($plugin); |
603 | 603 | |
604 | - if($record_classname == null) $record_classname = $plugin::get_egw_record_class(); |
|
605 | - if(!class_exists($record_classname)) throw new Exception('Bad class name ' . $record_classname); |
|
604 | + if ($record_classname == null) $record_classname = $plugin::get_egw_record_class(); |
|
605 | + if (!class_exists($record_classname)) throw new Exception('Bad class name '.$record_classname); |
|
606 | 606 | |
607 | - if(!$wizard_plugin) |
|
607 | + if (!$wizard_plugin) |
|
608 | 608 | { |
609 | - $wizard_name = $app_name . '_wizard_' . str_replace($app_name . '_', '', $plugin_name); |
|
610 | - if(!class_exists($wizard_name)) throw new Exception('Bad wizard name ' . $wizard_name); |
|
609 | + $wizard_name = $app_name.'_wizard_'.str_replace($app_name.'_', '', $plugin_name); |
|
610 | + if (!class_exists($wizard_name)) throw new Exception('Bad wizard name '.$wizard_name); |
|
611 | 611 | $wizard_plugin = new $wizard_name; |
612 | 612 | } |
613 | 613 | } |
@@ -619,16 +619,16 @@ discard block |
||
619 | 619 | |
620 | 620 | // Get field -> label map and initialize fields using wizard field order |
621 | 621 | $fields = $export_fields = array(); |
622 | - if(method_exists($wizard_plugin, 'get_export_fields')) |
|
622 | + if (method_exists($wizard_plugin, 'get_export_fields')) |
|
623 | 623 | { |
624 | 624 | $fields = $export_fields = $wizard_plugin->get_export_fields(); |
625 | 625 | } |
626 | 626 | |
627 | - foreach($record_classname::$types as $type => $type_fields) |
|
627 | + foreach ($record_classname::$types as $type => $type_fields) |
|
628 | 628 | { |
629 | 629 | // Only these for now, until filter methods for others are figured out |
630 | - if(!in_array($type, array('select','select-cat','select-account','date','date-time'))) continue; |
|
631 | - foreach($type_fields as $field_name) |
|
630 | + if (!in_array($type, array('select', 'select-cat', 'select-account', 'date', 'date-time'))) continue; |
|
631 | + foreach ($type_fields as $field_name) |
|
632 | 632 | { |
633 | 633 | $fields[$field_name] = array( |
634 | 634 | 'name' => $field_name, |
@@ -639,21 +639,21 @@ discard block |
||
639 | 639 | } |
640 | 640 | // Add custom fields |
641 | 641 | $custom = Api\Storage\Customfields::get($app_name); |
642 | - foreach($custom as $field_name => $settings) |
|
642 | + foreach ($custom as $field_name => $settings) |
|
643 | 643 | { |
644 | 644 | $settings['name'] = '#'.$field_name; |
645 | 645 | $fields['#'.$field_name] = $settings; |
646 | 646 | } |
647 | 647 | |
648 | - foreach($fields as $field_name => &$settings) { |
|
648 | + foreach ($fields as $field_name => &$settings) { |
|
649 | 649 | // Can't really filter on these (or at least no generic, sane way figured out yet) |
650 | - if(!is_array($settings) || in_array($settings['type'], array('text','button', 'label','url','url-email','url-phone','htmlarea'))) |
|
650 | + if (!is_array($settings) || in_array($settings['type'], array('text', 'button', 'label', 'url', 'url-email', 'url-phone', 'htmlarea'))) |
|
651 | 651 | { |
652 | 652 | unset($fields[$field_name]); |
653 | 653 | continue; |
654 | 654 | } |
655 | - if($settings['type'] == 'radio') $settings['type'] = 'select'; |
|
656 | - switch($settings['type']) |
|
655 | + if ($settings['type'] == 'radio') $settings['type'] = 'select'; |
|
656 | + switch ($settings['type']) |
|
657 | 657 | { |
658 | 658 | case 'checkbox': |
659 | 659 | // This isn't quite right - there's only 2 options and you can select both |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | } |
677 | 677 | } |
678 | 678 | |
679 | - if(method_exists($plugin, 'get_filter_fields')) |
|
679 | + if (method_exists($plugin, 'get_filter_fields')) |
|
680 | 680 | { |
681 | 681 | $plugin->get_filter_fields($fields); |
682 | 682 | } |
@@ -692,65 +692,65 @@ discard block |
||
692 | 692 | */ |
693 | 693 | public static function date_rel2abs($value) |
694 | 694 | { |
695 | - if(is_array($value)) |
|
695 | + if (is_array($value)) |
|
696 | 696 | { |
697 | 697 | $abs = array(); |
698 | - foreach($value as $key => $val) |
|
698 | + foreach ($value as $key => $val) |
|
699 | 699 | { |
700 | 700 | $abs[$key] = self::date_rel2abs($val); |
701 | 701 | } |
702 | 702 | return $abs; |
703 | 703 | } |
704 | - if($date = self::$relative_dates[$value]) |
|
704 | + if ($date = self::$relative_dates[$value]) |
|
705 | 705 | { |
706 | - $year = (int) date('Y'); |
|
707 | - $month = (int) date('m'); |
|
708 | - $day = (int) date('d'); |
|
709 | - $today = mktime(0,0,0,date('m'),date('d'),date('Y')); |
|
706 | + $year = (int)date('Y'); |
|
707 | + $month = (int)date('m'); |
|
708 | + $day = (int)date('d'); |
|
709 | + $today = mktime(0, 0, 0, date('m'), date('d'), date('Y')); |
|
710 | 710 | |
711 | - list($syear,$smonth,$sday,$sweek,$eyear,$emonth,$eday,$eweek) = $date; |
|
711 | + list($syear, $smonth, $sday, $sweek, $eyear, $emonth, $eday, $eweek) = $date; |
|
712 | 712 | |
713 | - if(stripos($value, 'quarter') !== false) |
|
713 | + if (stripos($value, 'quarter') !== false) |
|
714 | 714 | { |
715 | 715 | // Handle quarters |
716 | - $start = mktime(0,0,0,((int)floor(($smonth+$month) / 3.1)) * 3 + 1, 1, $year); |
|
717 | - $end = mktime(0,0,0,((int)floor(($emonth+$month) / 3.1)+1) * 3 + 1, 1, $year); |
|
716 | + $start = mktime(0, 0, 0, ((int)floor(($smonth + $month) / 3.1)) * 3 + 1, 1, $year); |
|
717 | + $end = mktime(0, 0, 0, ((int)floor(($emonth + $month) / 3.1) + 1) * 3 + 1, 1, $year); |
|
718 | 718 | } |
719 | 719 | elseif ($syear || $eyear) |
720 | 720 | { |
721 | - $start = mktime(0,0,0,1,1,$syear+$year); |
|
722 | - $end = mktime(0,0,0,1,1,$eyear+$year); |
|
721 | + $start = mktime(0, 0, 0, 1, 1, $syear + $year); |
|
722 | + $end = mktime(0, 0, 0, 1, 1, $eyear + $year); |
|
723 | 723 | } |
724 | 724 | elseif ($smonth || $emonth) |
725 | 725 | { |
726 | - $start = mktime(0,0,0,$smonth+$month,1,$year); |
|
727 | - $end = mktime(0,0,0,$emonth+$month,1,$year); |
|
726 | + $start = mktime(0, 0, 0, $smonth + $month, 1, $year); |
|
727 | + $end = mktime(0, 0, 0, $emonth + $month, 1, $year); |
|
728 | 728 | } |
729 | 729 | elseif ($sday || $eday) |
730 | 730 | { |
731 | - $start = mktime(0,0,0,$month,$sday+$day,$year); |
|
732 | - $end = mktime(0,0,0,$month,$eday+$day,$year); |
|
731 | + $start = mktime(0, 0, 0, $month, $sday + $day, $year); |
|
732 | + $end = mktime(0, 0, 0, $month, $eday + $day, $year); |
|
733 | 733 | } |
734 | 734 | elseif ($sweek || $eweek) |
735 | 735 | { |
736 | - $wday = (int) date('w'); // 0=sun, ..., 6=sat |
|
737 | - switch($GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts']) |
|
736 | + $wday = (int)date('w'); // 0=sun, ..., 6=sat |
|
737 | + switch ($GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts']) |
|
738 | 738 | { |
739 | 739 | case 'Sunday': |
740 | - $weekstart = $today - $wday * 24*60*60; |
|
740 | + $weekstart = $today - $wday * 24 * 60 * 60; |
|
741 | 741 | break; |
742 | 742 | case 'Saturday': |
743 | - $weekstart = $today - (6-$wday) * 24*60*60; |
|
743 | + $weekstart = $today - (6 - $wday) * 24 * 60 * 60; |
|
744 | 744 | break; |
745 | 745 | case 'Moday': |
746 | 746 | default: |
747 | - $weekstart = $today - ($wday ? $wday-1 : 6) * 24*60*60; |
|
747 | + $weekstart = $today - ($wday ? $wday - 1 : 6) * 24 * 60 * 60; |
|
748 | 748 | break; |
749 | 749 | } |
750 | - $start = $weekstart + $sweek*7*24*60*60; |
|
751 | - $end = $weekstart + $eweek*7*24*60*60; |
|
750 | + $start = $weekstart + $sweek * 7 * 24 * 60 * 60; |
|
751 | + $end = $weekstart + $eweek * 7 * 24 * 60 * 60; |
|
752 | 752 | } |
753 | - $end_param = $end - 24*60*60; |
|
753 | + $end_param = $end - 24 * 60 * 60; |
|
754 | 754 | |
755 | 755 | // Take 1 second off end to provide an inclusive range.for filtering |
756 | 756 | $end -= 1; |
@@ -16,7 +16,8 @@ discard block |
||
16 | 16 | * class importexport_helper_functions (only static methods) |
17 | 17 | * use importexport_helper_functions::method |
18 | 18 | */ |
19 | -class importexport_helper_functions { |
|
19 | +class importexport_helper_functions |
|
20 | +{ |
|
20 | 21 | |
21 | 22 | /** |
22 | 23 | * Plugins are scanned and cached for all instances using this source path for given time (in seconds) |
@@ -85,13 +86,19 @@ discard block |
||
85 | 86 | * @param string $_format format of time string e.g.: d.m.Y H:i |
86 | 87 | * @param int $_is_dst is day light saving time? 0 = no, 1 = yes, -1 = system default |
87 | 88 | */ |
88 | - public static function custom_strtotime( $_string, $_format='', $_is_dst = -1) { |
|
89 | - if ( empty( $_format ) ) return strtotime( $_string ); |
|
89 | + public static function custom_strtotime( $_string, $_format='', $_is_dst = -1) |
|
90 | + { |
|
91 | + if ( empty( $_format ) ) |
|
92 | + { |
|
93 | + return strtotime( $_string ); |
|
94 | + } |
|
90 | 95 | $fparams = explode( ',', chunk_split( $_format, 1, ',' ) ); |
91 | 96 | $spos = 0; |
92 | - foreach ( $fparams as $fparam ) { |
|
97 | + foreach ( $fparams as $fparam ) |
|
98 | + { |
|
93 | 99 | |
94 | - switch ( $fparam ) { |
|
100 | + switch ( $fparam ) |
|
101 | + { |
|
95 | 102 | case 'd': (int)$day = substr( $_string, $spos, 2 ); $spos += 2; break; |
96 | 103 | case 'm': (int)$mon = substr( $_string, $spos, 2 ); $spos += 2; break; |
97 | 104 | case 'y': (int)$year = substr( $_string, $spos, 2 ); $spos += 2; break; |
@@ -111,12 +118,18 @@ discard block |
||
111 | 118 | $timestamp = mktime($hour, $min, $sec, $mon, $day, $year, $_is_dst); |
112 | 119 | |
113 | 120 | // offset given? |
114 | - if ( isset( $offset ) && strlen( $offset == 5 ) ) { |
|
121 | + if ( isset( $offset ) && strlen( $offset == 5 ) ) |
|
122 | + { |
|
115 | 123 | $operator = $offset{0}; |
116 | 124 | $ohour = 60 * 60 * (int)substr( $offset, 1, 2 ); |
117 | 125 | $omin = 60 * (int)substr( $offset, 3, 2 ); |
118 | - if ( $operator == '+' ) $timestamp += $ohour + $omin; |
|
119 | - else $timestamp -= $ohour + $omin; |
|
126 | + if ( $operator == '+' ) |
|
127 | + { |
|
128 | + $timestamp += $ohour + $omin; |
|
129 | + } |
|
130 | + else { |
|
131 | + $timestamp -= $ohour + $omin; |
|
132 | + } |
|
120 | 133 | } |
121 | 134 | return $timestamp; |
122 | 135 | } |
@@ -126,11 +139,14 @@ discard block |
||
126 | 139 | * @param mixed $_account_lid comma seperated list or array with lids |
127 | 140 | * @return mixed comma seperated list or array with ids |
128 | 141 | */ |
129 | - public static function account_name2id( &$_account_lids ) { |
|
142 | + public static function account_name2id( &$_account_lids ) |
|
143 | + { |
|
130 | 144 | $account_lids = is_array( $_account_lids ) ? $_account_lids : explode( ',', $_account_lids ); |
131 | 145 | $skip = false; |
132 | - foreach ( $account_lids as $key => $account_lid ) { |
|
133 | - if($skip) { |
|
146 | + foreach ( $account_lids as $key => $account_lid ) |
|
147 | + { |
|
148 | + if($skip) |
|
149 | + { |
|
134 | 150 | unset($account_lids[$key]); |
135 | 151 | $skip = false; |
136 | 152 | continue; |
@@ -138,7 +154,8 @@ discard block |
||
138 | 154 | $account_lid = trim($account_lid); |
139 | 155 | |
140 | 156 | // Handle any IDs that slip in |
141 | - if(is_numeric($account_lid) && $GLOBALS['egw']->accounts->id2name($account_lid)) { |
|
157 | + if(is_numeric($account_lid) && $GLOBALS['egw']->accounts->id2name($account_lid)) |
|
158 | + { |
|
142 | 159 | unset($account_lids[$key]); |
143 | 160 | $account_ids[] = (int)$account_lid; |
144 | 161 | continue; |
@@ -157,7 +174,8 @@ discard block |
||
157 | 174 | |
158 | 175 | // Handle users listed as Lastname, Firstname instead of login ID |
159 | 176 | // Do this first, in case their first name matches a username |
160 | - if ( $account_lids[$key+1][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id( trim($account_lids[$key+1]).' ' .$account_lid, 'account_fullname')) { |
|
177 | + if ( $account_lids[$key+1][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id( trim($account_lids[$key+1]).' ' .$account_lid, 'account_fullname')) |
|
178 | + { |
|
161 | 179 | $account_ids[] = $account_id; |
162 | 180 | unset($account_lids[$key]); |
163 | 181 | $skip = true; // Skip the next one, it's the first name |
@@ -170,19 +188,22 @@ discard block |
||
170 | 188 | $account_lid = trim(substr(trim($account_lid), 0, -strlen(lang('Group')))); |
171 | 189 | } |
172 | 190 | |
173 | - if ( $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid )) { |
|
191 | + if ( $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid )) |
|
192 | + { |
|
174 | 193 | $account_ids[] = $account_id; |
175 | 194 | unset($account_lids[$key]); |
176 | 195 | continue; |
177 | 196 | } |
178 | - if ( $account_id = $GLOBALS['egw']->accounts->name2id( trim($account_lid), 'account_fullname' )) { |
|
197 | + if ( $account_id = $GLOBALS['egw']->accounts->name2id( trim($account_lid), 'account_fullname' )) |
|
198 | + { |
|
179 | 199 | $account_ids[] = $account_id; |
180 | 200 | unset($account_lids[$key]); |
181 | 201 | continue; |
182 | 202 | } |
183 | 203 | |
184 | 204 | // Handle groups listed as Group, <name> |
185 | - if ( $account_lids[$key][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid)) { |
|
205 | + if ( $account_lids[$key][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid)) |
|
206 | + { |
|
186 | 207 | $account_ids[] = $account_id; |
187 | 208 | unset($account_lids[$key-1]); |
188 | 209 | unset($account_lids[$key]); |
@@ -206,10 +227,13 @@ discard block |
||
206 | 227 | * @param mixed $_account_ids comma seperated list or array with ids |
207 | 228 | * @return mixed comma seperated list or array with lids |
208 | 229 | */ |
209 | - public static function account_id2name( $_account_id ) { |
|
230 | + public static function account_id2name( $_account_id ) |
|
231 | + { |
|
210 | 232 | $account_ids = is_array( $_account_id ) ? $_account_id : explode( ',', $_account_id ); |
211 | - foreach ( $account_ids as $account_id ) { |
|
212 | - if ( $account_lid = $GLOBALS['egw']->accounts->id2name( $account_id )) { |
|
233 | + foreach ( $account_ids as $account_id ) |
|
234 | + { |
|
235 | + if ( $account_lid = $GLOBALS['egw']->accounts->id2name( $account_id )) |
|
236 | + { |
|
213 | 237 | $account_lids[] = $account_lid; |
214 | 238 | } |
215 | 239 | } |
@@ -222,9 +246,11 @@ discard block |
||
222 | 246 | * @param mixed _cat_ids comma seperated list or array |
223 | 247 | * @return mixed comma seperated list or array with cat_names |
224 | 248 | */ |
225 | - public static function cat_id2name( $_cat_ids ) { |
|
249 | + public static function cat_id2name( $_cat_ids ) |
|
250 | + { |
|
226 | 251 | $cat_ids = is_array( $_cat_ids ) ? $_cat_ids : explode( ',', $_cat_ids ); |
227 | - foreach ( $cat_ids as $cat_id ) { |
|
252 | + foreach ( $cat_ids as $cat_id ) |
|
253 | + { |
|
228 | 254 | $cat_names[] = Api\Categories::id2name( (int)$cat_id ); |
229 | 255 | } |
230 | 256 | return is_array( $_cat_ids ) ? $cat_names : implode(',',(array)$cat_names); |
@@ -238,14 +264,20 @@ discard block |
||
238 | 264 | * @param int $parent Optional parent ID to use for new categories |
239 | 265 | * @return mixed comma seperated list or array with cat_ids |
240 | 266 | */ |
241 | - public static function cat_name2id( $_cat_names, $parent = 0 ) { |
|
267 | + public static function cat_name2id( $_cat_names, $parent = 0 ) |
|
268 | + { |
|
242 | 269 | $cats = new Api\Categories(); // uses current user and app (egw_info[flags][currentapp]) |
243 | 270 | |
244 | 271 | $cat_names = is_array( $_cat_names ) ? $_cat_names : explode( ',', $_cat_names ); |
245 | - foreach ( $cat_names as $cat_name ) { |
|
272 | + foreach ( $cat_names as $cat_name ) |
|
273 | + { |
|
246 | 274 | $cat_name = trim($cat_name); |
247 | - if ( $cat_name == '' ) continue; |
|
248 | - if ( ( $cat_id = $cats->name2id( $cat_name ) ) == 0 && !self::$dry_run) { |
|
275 | + if ( $cat_name == '' ) |
|
276 | + { |
|
277 | + continue; |
|
278 | + } |
|
279 | + if ( ( $cat_id = $cats->name2id( $cat_name ) ) == 0 && !self::$dry_run) |
|
280 | + { |
|
249 | 281 | $cat_id = $cats->add( array( |
250 | 282 | 'name' => $cat_name, |
251 | 283 | 'parent' => $parent, |
@@ -294,8 +326,12 @@ discard block |
||
294 | 326 | * @param object &$cclass calling class to process the '@ evals' |
295 | 327 | * @return bool |
296 | 328 | */ |
297 | - public static function conversion( &$_record, $_conversion, &$_cclass = null ) { |
|
298 | - if (empty( $_conversion ) ) return $_record; |
|
329 | + public static function conversion( &$_record, $_conversion, &$_cclass = null ) |
|
330 | + { |
|
331 | + if (empty( $_conversion ) ) |
|
332 | + { |
|
333 | + return $_record; |
|
334 | + } |
|
299 | 335 | |
300 | 336 | self::$cclass =& $_cclass; |
301 | 337 | |
@@ -307,15 +343,21 @@ discard block |
||
307 | 343 | $CntlnCLPre = '|TCnCL{'; // Like |C{ but allowes CR and LF |
308 | 344 | $INE = '|INE{'; // Only insert if stuff in ^^ is not empty |
309 | 345 | |
310 | - foreach ( $_conversion as $idx => $conversion_string ) { |
|
311 | - if ( empty( $conversion_string ) ) continue; |
|
346 | + foreach ( $_conversion as $idx => $conversion_string ) |
|
347 | + { |
|
348 | + if ( empty( $conversion_string ) ) |
|
349 | + { |
|
350 | + continue; |
|
351 | + } |
|
312 | 352 | |
313 | 353 | // fetch patterns ($rvalues) |
314 | 354 | $rvalues = array(); |
315 | 355 | $pat_reps = explode( $PSep, stripslashes( $conversion_string ) ); |
316 | - foreach( $pat_reps as $k => $pat_rep ) { |
|
356 | + foreach( $pat_reps as $k => $pat_rep ) |
|
357 | + { |
|
317 | 358 | list( $pattern, $replace ) = explode( $ASep, $pat_rep, 2 ); |
318 | - if( $replace == '' ) { |
|
359 | + if( $replace == '' ) |
|
360 | + { |
|
319 | 361 | $replace = $pattern; $pattern = '^.*$'; |
320 | 362 | } |
321 | 363 | $rvalues[$pattern] = $replace; // replace two with only one, added by the form |
@@ -325,19 +367,23 @@ discard block |
||
325 | 367 | $val = array_key_exists( $idx, $_record ) ? $_record[$idx] : ''; |
326 | 368 | |
327 | 369 | $c_functions = array('cat', 'account', 'strtotime', 'list'); |
328 | - if($_cclass) { |
|
370 | + if($_cclass) |
|
371 | + { |
|
329 | 372 | // Add in additional methods |
330 | 373 | $reflection = new ReflectionClass(get_class($_cclass)); |
331 | 374 | $methods = $reflection->getMethods(ReflectionMethod::IS_STATIC); |
332 | - foreach($methods as $method) { |
|
375 | + foreach($methods as $method) |
|
376 | + { |
|
333 | 377 | $c_functions[] = $method->name; |
334 | 378 | } |
335 | 379 | } |
336 | 380 | $c_functions = implode('|', $c_functions); |
337 | - foreach ( $rvalues as $pattern => $replace ) { |
|
381 | + foreach ( $rvalues as $pattern => $replace ) |
|
382 | + { |
|
338 | 383 | // Allow to include record indexes in pattern |
339 | 384 | $reg = '/\|\[([0-9]+)\]/'; |
340 | - while( preg_match( $reg, $pattern, $vars ) ) { |
|
385 | + while( preg_match( $reg, $pattern, $vars ) ) |
|
386 | + { |
|
341 | 387 | // expand all _record fields |
342 | 388 | $pattern = str_replace( |
343 | 389 | $CPre . $vars[1] . $CPos, |
@@ -345,12 +391,14 @@ discard block |
||
345 | 391 | $pattern |
346 | 392 | ); |
347 | 393 | } |
348 | - if( preg_match('/'. (string)$pattern.'/', $val) ) { |
|
394 | + if( preg_match('/'. (string)$pattern.'/', $val) ) |
|
395 | + { |
|
349 | 396 | |
350 | 397 | $val = preg_replace( '/'.(string)$pattern.'/', $replace, (string)$val ); |
351 | 398 | |
352 | 399 | $reg = '/\|\[([a-zA-Z_0-9]+)\]/'; |
353 | - while( preg_match( $reg, $val, $vars ) ) { |
|
400 | + while( preg_match( $reg, $val, $vars ) ) |
|
401 | + { |
|
354 | 402 | // expand all _record fields |
355 | 403 | $val = str_replace( |
356 | 404 | $CPre . $vars[1] . $CPos, |
@@ -377,11 +425,13 @@ discard block |
||
377 | 425 | * |
378 | 426 | * @param array $_matches |
379 | 427 | */ |
380 | - private static function c2_dispatcher( $_matches ) { |
|
428 | + private static function c2_dispatcher( $_matches ) |
|
429 | + { |
|
381 | 430 | $action = &$_matches[1]; // cat or account ... |
382 | 431 | $data = &$_matches[2]; // datas for action |
383 | 432 | |
384 | - switch ( $action ) { |
|
433 | + switch ( $action ) |
|
434 | + { |
|
385 | 435 | case 'strtotime' : |
386 | 436 | list( $string, $format ) = explode( ',', $data ); |
387 | 437 | return self::custom_strtotime( trim( $string ), trim( $format ) ); |
@@ -391,22 +441,28 @@ discard block |
||
391 | 441 | // 1 based indexing for user ease |
392 | 442 | return $exploded[$index - 1]; |
393 | 443 | default : |
394 | - if(self::$cclass && method_exists(self::$cclass, $action)) { |
|
444 | + if(self::$cclass && method_exists(self::$cclass, $action)) |
|
445 | + { |
|
395 | 446 | $class = get_class(self::$cclass); |
396 | 447 | return call_user_func("$class::$action", $data); |
397 | 448 | } |
398 | 449 | $method = (string)$action. ( is_int( $data ) ? '_id2name' : '_name2id' ); |
399 | - if(self::$cclass && method_exists(self::$cclass, $method)) { |
|
450 | + if(self::$cclass && method_exists(self::$cclass, $method)) |
|
451 | + { |
|
400 | 452 | $class = get_class(self::$cclass); |
401 | 453 | return call_user_func("$class::$action", $data); |
402 | - } else { |
|
454 | + } |
|
455 | + else |
|
456 | + { |
|
403 | 457 | return self::$method( $data ); |
404 | 458 | } |
405 | 459 | } |
406 | 460 | } |
407 | 461 | |
408 | - private static function strclean( $_matches ) { |
|
409 | - switch( $_matches[1] ) { |
|
462 | + private static function strclean( $_matches ) |
|
463 | + { |
|
464 | + switch( $_matches[1] ) |
|
465 | + { |
|
410 | 466 | case '|T{' : return trim( $_matches[2] ); |
411 | 467 | case '|TC{' : return trim( preg_replace( '/[\x01-\x1F]+/', '', $_matches[2] ) ); |
412 | 468 | case '|TCnCL{' : return trim( preg_replace( '/[\x01-\x09\x11\x12\x14-\x1F]+/', '', $_matches[2] ) ); |
@@ -423,7 +479,8 @@ discard block |
||
423 | 479 | * @param string $_appname {<appname> | all} |
424 | 480 | * @return array(<appname> => array( <type> => array(<plugin> => <title>))) |
425 | 481 | */ |
426 | - public static function get_plugins( $_appname = 'all', $_type = 'all' ) { |
|
482 | + public static function get_plugins( $_appname = 'all', $_type = 'all' ) |
|
483 | + { |
|
427 | 484 | $plugins = Api\Cache::getTree( |
428 | 485 | __CLASS__, |
429 | 486 | 'plugins', |
@@ -436,38 +493,63 @@ discard block |
||
436 | 493 | |
437 | 494 | // Testing: comment out Api\Cache call, use this |
438 | 495 | //$plugins = self::_get_plugins($appnames, $types); |
439 | - foreach($plugins as $appname => $_types) { |
|
440 | - if(!in_array($appname, $appnames)) unset($plugins[$appname]); |
|
496 | + foreach($plugins as $appname => $_types) |
|
497 | + { |
|
498 | + if(!in_array($appname, $appnames)) |
|
499 | + { |
|
500 | + unset($plugins[$appname]); |
|
501 | + } |
|
441 | 502 | } |
442 | - foreach($plugins as $appname => $types) { |
|
503 | + foreach($plugins as $appname => $types) |
|
504 | + { |
|
443 | 505 | $plugins[$appname] = array_intersect_key($plugins[$appname], $types); |
444 | 506 | } |
445 | 507 | return $plugins; |
446 | 508 | } |
447 | 509 | |
448 | - public static function _get_plugins(Array $appnames, Array $types) { |
|
510 | + public static function _get_plugins(Array $appnames, Array $types) |
|
511 | + { |
|
449 | 512 | $plugins = array(); |
450 | - foreach ($appnames as $appname) { |
|
451 | - if(array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) continue; |
|
513 | + foreach ($appnames as $appname) |
|
514 | + { |
|
515 | + if(array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) |
|
516 | + { |
|
517 | + continue; |
|
518 | + } |
|
452 | 519 | |
453 | 520 | $appdir = EGW_INCLUDE_ROOT. "/$appname/inc"; |
454 | - if(!is_dir($appdir)) continue; |
|
521 | + if(!is_dir($appdir)) |
|
522 | + { |
|
523 | + continue; |
|
524 | + } |
|
455 | 525 | $d = dir($appdir); |
456 | 526 | |
457 | 527 | // step through each file in appdir |
458 | - while (false !== ($entry = $d->read())) { |
|
528 | + while (false !== ($entry = $d->read())) |
|
529 | + { |
|
459 | 530 | // Blacklisted? |
460 | - if(is_array(self::$blacklist_files[$appname]) && in_array($entry, self::$blacklist_files[$appname])) continue; |
|
461 | - if (!preg_match('/^class\.([^.]+)\.inc\.php$/', $entry, $matches)) continue; |
|
531 | + if(is_array(self::$blacklist_files[$appname]) && in_array($entry, self::$blacklist_files[$appname])) |
|
532 | + { |
|
533 | + continue; |
|
534 | + } |
|
535 | + if (!preg_match('/^class\.([^.]+)\.inc\.php$/', $entry, $matches)) |
|
536 | + { |
|
537 | + continue; |
|
538 | + } |
|
462 | 539 | $classname = $matches[1]; |
463 | 540 | $file = $appdir. '/'. $entry; |
464 | 541 | |
465 | - foreach ($types as $type) { |
|
466 | - if( !is_file($file) || strpos($entry, $type) === false || strpos($entry,'wizard') !== false) continue; |
|
542 | + foreach ($types as $type) |
|
543 | + { |
|
544 | + if( !is_file($file) || strpos($entry, $type) === false || strpos($entry,'wizard') !== false) |
|
545 | + { |
|
546 | + continue; |
|
547 | + } |
|
467 | 548 | require_once($file); |
468 | 549 | $reflectionClass = new ReflectionClass($classname); |
469 | 550 | if($reflectionClass->IsInstantiable() && |
470 | - $reflectionClass->implementsInterface('importexport_iface_'.$type.'_plugin')) { |
|
551 | + $reflectionClass->implementsInterface('importexport_iface_'.$type.'_plugin')) |
|
552 | + { |
|
471 | 553 | try { |
472 | 554 | $plugin_object = new $classname; |
473 | 555 | } |
@@ -482,7 +564,8 @@ discard block |
||
482 | 564 | $d->close(); |
483 | 565 | |
484 | 566 | $config = Api\Config::read('importexport'); |
485 | - if($config['update'] == 'auto') { |
|
567 | + if($config['update'] == 'auto') |
|
568 | + { |
|
486 | 569 | self::load_defaults($appname); |
487 | 570 | } |
488 | 571 | } |
@@ -496,38 +579,56 @@ discard block |
||
496 | 579 | * @param string $_type |
497 | 580 | * @return array $num => $appname |
498 | 581 | */ |
499 | - public static function get_apps($_type, $ignore_acl = false) { |
|
582 | + public static function get_apps($_type, $ignore_acl = false) |
|
583 | + { |
|
500 | 584 | $apps = array_keys(self::get_plugins('all',$_type)); |
501 | - if($ignore_acl) return $apps; |
|
585 | + if($ignore_acl) |
|
586 | + { |
|
587 | + return $apps; |
|
588 | + } |
|
502 | 589 | |
503 | - foreach($apps as $key => $app) { |
|
504 | - if(!self::has_definitions($app, $_type)) unset($apps[$key]); |
|
590 | + foreach($apps as $key => $app) |
|
591 | + { |
|
592 | + if(!self::has_definitions($app, $_type)) |
|
593 | + { |
|
594 | + unset($apps[$key]); |
|
595 | + } |
|
505 | 596 | } |
506 | 597 | return $apps; |
507 | 598 | } |
508 | 599 | |
509 | - public static function load_defaults($appname) { |
|
600 | + public static function load_defaults($appname) |
|
601 | + { |
|
510 | 602 | // Check for new definitions to import from $appname/setup/*.xml |
511 | 603 | $appdir = EGW_INCLUDE_ROOT. "/$appname/setup"; |
512 | - if(!is_dir($appdir)) return; |
|
604 | + if(!is_dir($appdir)) |
|
605 | + { |
|
606 | + return; |
|
607 | + } |
|
513 | 608 | $d = dir($appdir); |
514 | 609 | |
515 | 610 | // step through each file in app's setup |
516 | - while (false !== ($entry = $d->read())) { |
|
611 | + while (false !== ($entry = $d->read())) |
|
612 | + { |
|
517 | 613 | $file = $appdir. '/'. $entry; |
518 | 614 | list( $filename, $extension) = explode('.',$entry); |
519 | - if ( $extension != 'xml' ) continue; |
|
615 | + if ( $extension != 'xml' ) |
|
616 | + { |
|
617 | + continue; |
|
618 | + } |
|
520 | 619 | try { |
521 | 620 | // import will skip invalid files |
522 | 621 | importexport_definitions_bo::import( $file ); |
523 | - } catch (Exception $e) { |
|
622 | + } |
|
623 | + catch (Exception $e) { |
|
524 | 624 | error_log(__CLASS__.__FUNCTION__. " import $appname definitions: " . $e->getMessage()); |
525 | 625 | } |
526 | 626 | } |
527 | 627 | $d->close(); |
528 | 628 | } |
529 | 629 | |
530 | - public static function guess_filetype( $_file ) { |
|
630 | + public static function guess_filetype( $_file ) |
|
631 | + { |
|
531 | 632 | |
532 | 633 | } |
533 | 634 | |
@@ -538,7 +639,8 @@ discard block |
||
538 | 639 | * @param string $_type {import | export | all} |
539 | 640 | * @return boolean |
540 | 641 | */ |
541 | - public static function has_definitions( $_appname = 'all', $_type = 'all' ) { |
|
642 | + public static function has_definitions( $_appname = 'all', $_type = 'all' ) |
|
643 | + { |
|
542 | 644 | $definitions = Api\Cache::getSession( |
543 | 645 | __CLASS__, |
544 | 646 | 'has_definitions', |
@@ -552,27 +654,36 @@ discard block |
||
552 | 654 | // Testing: Comment out cache call above, use this |
553 | 655 | //$definitions = self::_has_definitions($appnames, $types); |
554 | 656 | |
555 | - foreach($definitions as $appname => $_types) { |
|
556 | - if(!in_array($appname, $appnames)) unset($definitions[$appname]); |
|
657 | + foreach($definitions as $appname => $_types) |
|
658 | + { |
|
659 | + if(!in_array($appname, $appnames)) |
|
660 | + { |
|
661 | + unset($definitions[$appname]); |
|
662 | + } |
|
557 | 663 | } |
558 | - foreach($definitions as $appname => $_types) { |
|
664 | + foreach($definitions as $appname => $_types) |
|
665 | + { |
|
559 | 666 | $definitions[$appname] = array_intersect_key($definitions[$appname], array_flip($types)); |
560 | 667 | } |
561 | 668 | return count($definitions[$appname]) > 0; |
562 | 669 | } |
563 | 670 | |
564 | 671 | // Api\Cache needs this public |
565 | - public static function _has_definitions(Array $appnames, Array $types) { |
|
672 | + public static function _has_definitions(Array $appnames, Array $types) |
|
673 | + { |
|
566 | 674 | $def = new importexport_definitions_bo(array('application'=>$appnames, 'type' => $types)); |
567 | 675 | $list = array(); |
568 | - foreach((array)$def->get_definitions() as $id) { |
|
676 | + foreach((array)$def->get_definitions() as $id) |
|
677 | + { |
|
569 | 678 | // Need to instanciate it to check, but if the user doesn't have permission, it throws an exception |
570 | 679 | try { |
571 | 680 | $definition = new importexport_definition($id); |
572 | - if($def->is_permitted($definition->get_record_array())) { |
|
681 | + if($def->is_permitted($definition->get_record_array())) |
|
682 | + { |
|
573 | 683 | $list[$definition->application][$definition->type][] = $id; |
574 | 684 | } |
575 | - } catch (Exception $e) { |
|
685 | + } |
|
686 | + catch (Exception $e) { |
|
576 | 687 | // That one doesn't work, keep going |
577 | 688 | } |
578 | 689 | $definition = null; |
@@ -601,13 +712,22 @@ discard block |
||
601 | 712 | $plugin = is_object($plugin_name) ? $plugin_name : new $plugin_name(); |
602 | 713 | $plugin_name = get_class($plugin); |
603 | 714 | |
604 | - if($record_classname == null) $record_classname = $plugin::get_egw_record_class(); |
|
605 | - if(!class_exists($record_classname)) throw new Exception('Bad class name ' . $record_classname); |
|
715 | + if($record_classname == null) |
|
716 | + { |
|
717 | + $record_classname = $plugin::get_egw_record_class(); |
|
718 | + } |
|
719 | + if(!class_exists($record_classname)) |
|
720 | + { |
|
721 | + throw new Exception('Bad class name ' . $record_classname); |
|
722 | + } |
|
606 | 723 | |
607 | 724 | if(!$wizard_plugin) |
608 | 725 | { |
609 | 726 | $wizard_name = $app_name . '_wizard_' . str_replace($app_name . '_', '', $plugin_name); |
610 | - if(!class_exists($wizard_name)) throw new Exception('Bad wizard name ' . $wizard_name); |
|
727 | + if(!class_exists($wizard_name)) |
|
728 | + { |
|
729 | + throw new Exception('Bad wizard name ' . $wizard_name); |
|
730 | + } |
|
611 | 731 | $wizard_plugin = new $wizard_name; |
612 | 732 | } |
613 | 733 | } |
@@ -627,7 +747,10 @@ discard block |
||
627 | 747 | foreach($record_classname::$types as $type => $type_fields) |
628 | 748 | { |
629 | 749 | // Only these for now, until filter methods for others are figured out |
630 | - if(!in_array($type, array('select','select-cat','select-account','date','date-time'))) continue; |
|
750 | + if(!in_array($type, array('select','select-cat','select-account','date','date-time'))) |
|
751 | + { |
|
752 | + continue; |
|
753 | + } |
|
631 | 754 | foreach($type_fields as $field_name) |
632 | 755 | { |
633 | 756 | $fields[$field_name] = array( |
@@ -645,14 +768,18 @@ discard block |
||
645 | 768 | $fields['#'.$field_name] = $settings; |
646 | 769 | } |
647 | 770 | |
648 | - foreach($fields as $field_name => &$settings) { |
|
771 | + foreach($fields as $field_name => &$settings) |
|
772 | + { |
|
649 | 773 | // Can't really filter on these (or at least no generic, sane way figured out yet) |
650 | 774 | if(!is_array($settings) || in_array($settings['type'], array('text','button', 'label','url','url-email','url-phone','htmlarea'))) |
651 | 775 | { |
652 | 776 | unset($fields[$field_name]); |
653 | 777 | continue; |
654 | 778 | } |
655 | - if($settings['type'] == 'radio') $settings['type'] = 'select'; |
|
779 | + if($settings['type'] == 'radio') |
|
780 | + { |
|
781 | + $settings['type'] = 'select'; |
|
782 | + } |
|
656 | 783 | switch($settings['type']) |
657 | 784 | { |
658 | 785 | case 'checkbox': |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | return $plugins; |
446 | 446 | } |
447 | 447 | |
448 | - public static function _get_plugins(Array $appnames, Array $types) { |
|
448 | + public static function _get_plugins(array $appnames, array $types) { |
|
449 | 449 | $plugins = array(); |
450 | 450 | foreach ($appnames as $appname) { |
451 | 451 | if(array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) continue; |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | } |
563 | 563 | |
564 | 564 | // Api\Cache needs this public |
565 | - public static function _has_definitions(Array $appnames, Array $types) { |
|
565 | + public static function _has_definitions(array $appnames, array $types) { |
|
566 | 566 | $def = new importexport_definitions_bo(array('application'=>$appnames, 'type' => $types)); |
567 | 567 | $list = array(); |
568 | 568 | foreach((array)$def->get_definitions() as $id) { |
@@ -35,6 +35,7 @@ discard block |
||
35 | 35 | * reads record from backend if identifier is given. |
36 | 36 | * |
37 | 37 | * @param string $_identifier |
38 | + * @return void |
|
38 | 39 | */ |
39 | 40 | public function __construct( $_identifier='' ); |
40 | 41 | |
@@ -50,6 +51,7 @@ discard block |
||
50 | 51 | * |
51 | 52 | * @param string $_attribute_name |
52 | 53 | * @param data $data |
54 | + * @return void |
|
53 | 55 | */ |
54 | 56 | public function __set($_attribute_name, $data); |
55 | 57 | |
@@ -126,6 +128,7 @@ discard block |
||
126 | 128 | /** |
127 | 129 | * destructor |
128 | 130 | * |
131 | + * @return void |
|
129 | 132 | */ |
130 | 133 | public function __destruct(); |
131 | 134 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @param string $_identifier |
38 | 38 | */ |
39 | - public function __construct( $_identifier='' ); |
|
39 | + public function __construct($_identifier = ''); |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * magic method to set attributes of record |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @return string identifier |
99 | 99 | */ |
100 | - public function save ( $_dst_identifier ); |
|
100 | + public function save($_dst_identifier); |
|
101 | 101 | |
102 | 102 | /** |
103 | 103 | * copys current record to record identified by $_dst_identifier |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @param string $_dst_identifier |
106 | 106 | * @return string dst_identifier |
107 | 107 | */ |
108 | - public function copy ( $_dst_identifier ); |
|
108 | + public function copy($_dst_identifier); |
|
109 | 109 | |
110 | 110 | /** |
111 | 111 | * moves current record to record identified by $_dst_identifier |
@@ -114,14 +114,14 @@ discard block |
||
114 | 114 | * @param string $_dst_identifier |
115 | 115 | * @return string dst_identifier |
116 | 116 | */ |
117 | - public function move ( $_dst_identifier ); |
|
117 | + public function move($_dst_identifier); |
|
118 | 118 | |
119 | 119 | /** |
120 | 120 | * delets current record from backend |
121 | 121 | * @return void |
122 | 122 | * |
123 | 123 | */ |
124 | - public function delete (); |
|
124 | + public function delete(); |
|
125 | 125 | |
126 | 126 | /** |
127 | 127 | * destructor |
@@ -107,7 +107,7 @@ |
||
107 | 107 | * and automatic conversions. In most cases they are named <appname>_egw_record, |
108 | 108 | * but projectmanager is an exception to this. |
109 | 109 | * |
110 | - * @return string; |
|
110 | + * @return string |
|
111 | 111 | */ |
112 | 112 | public static function get_egw_record_class(); |
113 | 113 | } // end of iface_export_plugin |
@@ -34,7 +34,8 @@ |
||
34 | 34 | * |
35 | 35 | * get_selector(); //returns array |
36 | 36 | */ |
37 | -interface importexport_iface_export_plugin { |
|
37 | +interface importexport_iface_export_plugin |
|
38 | +{ |
|
38 | 39 | |
39 | 40 | /** |
40 | 41 | * exports entries according to given definition object. |
@@ -29,8 +29,8 @@ |
||
29 | 29 | /** |
30 | 30 | * imports entries according to given definition object. |
31 | 31 | * |
32 | - * @param stram $_stram |
|
33 | - * @param definition $_definition |
|
32 | + * @param stram $_stream |
|
33 | + * @param importexport_definition $_definition |
|
34 | 34 | * @return int number of successful imports |
35 | 35 | */ |
36 | 36 | public function import( $_stream, importexport_definition $_definition ); |
@@ -88,33 +88,33 @@ |
||
88 | 88 | public function get_selectors_etpl(); |
89 | 89 | |
90 | 90 | /** |
91 | - * Returns errors that were encountered during importing |
|
92 | - * Maximum of one error message per record, but you can concatenate them if you need to |
|
93 | - * |
|
94 | - * @return Array ( |
|
95 | - * record_# => error message |
|
96 | - * ) |
|
97 | - */ |
|
91 | + * Returns errors that were encountered during importing |
|
92 | + * Maximum of one error message per record, but you can concatenate them if you need to |
|
93 | + * |
|
94 | + * @return Array ( |
|
95 | + * record_# => error message |
|
96 | + * ) |
|
97 | + */ |
|
98 | 98 | public function get_errors(); |
99 | 99 | |
100 | 100 | /** |
101 | - * Returns warnings that were encountered during importing |
|
102 | - * Maximum of one warning message per record, but you can concatenate them if you need to |
|
103 | - * |
|
104 | - * @return Array ( |
|
105 | - * record_# => warning message |
|
106 | - * ) |
|
107 | - */ |
|
101 | + * Returns warnings that were encountered during importing |
|
102 | + * Maximum of one warning message per record, but you can concatenate them if you need to |
|
103 | + * |
|
104 | + * @return Array ( |
|
105 | + * record_# => warning message |
|
106 | + * ) |
|
107 | + */ |
|
108 | 108 | public function get_warnings(); |
109 | 109 | |
110 | 110 | /** |
111 | - * Returns a list of actions taken, and the number of records for that action. |
|
112 | - * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
113 | - * |
|
114 | - * @return Array ( |
|
115 | - * action => record count |
|
116 | - * ) |
|
117 | - */ |
|
111 | + * Returns a list of actions taken, and the number of records for that action. |
|
112 | + * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
113 | + * |
|
114 | + * @return Array ( |
|
115 | + * action => record count |
|
116 | + * ) |
|
117 | + */ |
|
118 | 118 | public function get_results(); |
119 | 119 | |
120 | 120 | } // end of iface_export_plugin |
@@ -33,7 +33,7 @@ |
||
33 | 33 | * @param definition $_definition |
34 | 34 | * @return int number of successful imports |
35 | 35 | */ |
36 | - public function import( $_stream, importexport_definition $_definition ); |
|
36 | + public function import($_stream, importexport_definition $_definition); |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Reads entries, and presents them back as they will be understood |
@@ -24,7 +24,8 @@ |
||
24 | 24 | * So this interface just garanties the interaction with userinterfaces. It |
25 | 25 | * has nothing to do with datatypes. |
26 | 26 | */ |
27 | -interface importexport_iface_import_plugin { |
|
27 | +interface importexport_iface_import_plugin |
|
28 | +{ |
|
28 | 29 | |
29 | 30 | /** |
30 | 31 | * imports entries according to given definition object. |
@@ -33,7 +33,7 @@ |
||
33 | 33 | * cleanup |
34 | 34 | * |
35 | 35 | * @return |
36 | - */ |
|
36 | + void |
|
37 | 37 | public function __destruct( ); |
38 | 38 | |
39 | 39 | /** |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * @param array $_options options for specific backends |
28 | 28 | * @return bool |
29 | 29 | */ |
30 | - public function __construct( $_stream, array $_options ); |
|
30 | + public function __construct($_stream, array $_options); |
|
31 | 31 | |
32 | 32 | /** |
33 | 33 | * cleanup |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param string _position may be: {first|last|next|previous|somenumber} |
43 | 43 | * @return bool |
44 | 44 | */ |
45 | - public function get_record( $_position = 'next' ); |
|
45 | + public function get_record($_position = 'next'); |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Retruns total number of records for the open resource. |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | /** |
138 | 138 | * updates $this->record |
139 | 139 | * |
140 | - * @param mixed $_position |
|
141 | - * @return bool |
|
140 | + * @param string $_position |
|
141 | + * @return null|false |
|
142 | 142 | */ |
143 | 143 | private function get_raw_record( $_position = 'next' ) { |
144 | 144 | switch ($_position) { |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | /** |
245 | 245 | * does conversions according to $this->conversion |
246 | 246 | * |
247 | - * @return bool |
|
247 | + * @return boolean|null |
|
248 | 248 | */ |
249 | 249 | protected function do_conversions() { |
250 | 250 | if ( $record = importexport_helper_functions::conversion( $this->record, $this->conversion, $this->conversion_class )) { |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | * @param string $_resource resource containing data. May be each valid php-stream |
84 | 84 | * @param array $_options options for the resource array with keys: charset and fieldsep |
85 | 85 | */ |
86 | - public function __construct( $_resource, array $_options ) { |
|
86 | + public function __construct($_resource, array $_options) { |
|
87 | 87 | $this->resource = $_resource; |
88 | 88 | $this->csv_fieldsep = $_options['fieldsep']; |
89 | - if($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
|
89 | + if ($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
|
90 | 90 | $this->csv_charset = $_options['charset']; |
91 | 91 | return; |
92 | 92 | } // end of member function __construct |
@@ -103,20 +103,20 @@ discard block |
||
103 | 103 | * @param mixed _position may be: {current|first|last|next|previous|somenumber} |
104 | 104 | * @return mixed array with data / false if no furtor records |
105 | 105 | */ |
106 | - public function get_record( $_position = 'next' ) { |
|
106 | + public function get_record($_position = 'next') { |
|
107 | 107 | |
108 | - if ($this->get_raw_record( $_position ) === false) { |
|
108 | + if ($this->get_raw_record($_position) === false) { |
|
109 | 109 | return false; |
110 | 110 | } |
111 | 111 | |
112 | 112 | // skip empty records |
113 | - if( count( array_unique( $this->record ) ) < 2 ) return $this->get_record( $_position ); |
|
113 | + if (count(array_unique($this->record)) < 2) return $this->get_record($_position); |
|
114 | 114 | |
115 | - if ( !empty( $this->conversion ) ) { |
|
115 | + if (!empty($this->conversion)) { |
|
116 | 116 | $this->do_conversions(); |
117 | 117 | } |
118 | 118 | |
119 | - if ( !empty( $this->mapping ) ) { |
|
119 | + if (!empty($this->mapping)) { |
|
120 | 120 | $this->do_fieldmapping(); |
121 | 121 | } |
122 | 122 | |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @param int $_numToSkip |
130 | 130 | */ |
131 | - public function skip_records( $_numToSkip ) { |
|
132 | - while ( (int)$_numToSkip-- !== 0 ) { |
|
133 | - fgetcsv( $this->resource, self::csv_max_linelength, $this->csv_fieldsep); |
|
131 | + public function skip_records($_numToSkip) { |
|
132 | + while ((int)$_numToSkip-- !== 0) { |
|
133 | + fgetcsv($this->resource, self::csv_max_linelength, $this->csv_fieldsep); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @param mixed $_position |
141 | 141 | * @return bool |
142 | 142 | */ |
143 | - private function get_raw_record( $_position = 'next' ) { |
|
143 | + private function get_raw_record($_position = 'next') { |
|
144 | 144 | switch ($_position) { |
145 | 145 | case 'current' : |
146 | 146 | if ($this->current_position == 0) { |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | } |
155 | 155 | |
156 | 156 | case 'next' : |
157 | - $csv_data = fgetcsv( $this->resource, self::csv_max_linelength, $this->csv_fieldsep); |
|
157 | + $csv_data = fgetcsv($this->resource, self::csv_max_linelength, $this->csv_fieldsep); |
|
158 | 158 | if (!is_array($csv_data)) { |
159 | 159 | return false; |
160 | 160 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | $this->record = array(); |
236 | 236 | foreach ($this->mapping as $cvs_idx => $new_idx) |
237 | 237 | { |
238 | - if( $new_idx == '' ) continue; |
|
238 | + if ($new_idx == '') continue; |
|
239 | 239 | $this->record[$new_idx] = $record[$cvs_idx]; |
240 | 240 | } |
241 | 241 | return true; |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * @return bool |
248 | 248 | */ |
249 | 249 | protected function do_conversions() { |
250 | - if ( $record = importexport_helper_functions::conversion( $this->record, $this->conversion, $this->conversion_class )) { |
|
250 | + if ($record = importexport_helper_functions::conversion($this->record, $this->conversion, $this->conversion_class)) { |
|
251 | 251 | $this->record = $record; |
252 | 252 | return; |
253 | 253 | } |
@@ -264,25 +264,25 @@ discard block |
||
264 | 264 | * |
265 | 265 | * @return string warnings, if any |
266 | 266 | */ |
267 | - public static function convert(Array &$record, Array $fields = array(), $appname = null, Array $selects = array(), $format=0) { |
|
267 | + public static function convert(Array &$record, Array $fields = array(), $appname = null, Array $selects = array(), $format = 0) { |
|
268 | 268 | $warnings = array(); |
269 | 269 | |
270 | 270 | // Automatic conversions |
271 | - if($appname) { |
|
271 | + if ($appname) { |
|
272 | 272 | |
273 | 273 | // Load translations |
274 | 274 | Api\Translation::add_app($appname); |
275 | 275 | |
276 | - if(!self::$cf_parse_cache[$appname]) { |
|
276 | + if (!self::$cf_parse_cache[$appname]) { |
|
277 | 277 | $c_fields = importexport_export_csv::convert_parse_custom_fields($appname, $selects, $links, $methods); |
278 | 278 | self::$cf_parse_cache[$appname] = array($c_fields, $selects, $links, $methods); |
279 | 279 | } |
280 | 280 | list($c_fields, $c_selects, $links, $methods) = self::$cf_parse_cache[$appname]; |
281 | 281 | |
282 | 282 | // Add in any fields that are keys to another app |
283 | - foreach((array)$fields['links'] as $link_field => $app) |
|
283 | + foreach ((array)$fields['links'] as $link_field => $app) |
|
284 | 284 | { |
285 | - if(is_numeric($link_field)) continue; |
|
285 | + if (is_numeric($link_field)) continue; |
|
286 | 286 | $links[$link_field] = $app; |
287 | 287 | // Set it as a normal link field |
288 | 288 | $fields['links'][] = $link_field; |
@@ -290,9 +290,9 @@ discard block |
||
290 | 290 | } |
291 | 291 | |
292 | 292 | // Not quite a recursive merge, since only one level |
293 | - foreach($fields as $type => &$list) |
|
293 | + foreach ($fields as $type => &$list) |
|
294 | 294 | { |
295 | - if($c_fields[$type]) { |
|
295 | + if ($c_fields[$type]) { |
|
296 | 296 | $list = array_merge($c_fields[$type], $list); |
297 | 297 | unset($c_fields[$type]); |
298 | 298 | } |
@@ -300,36 +300,36 @@ discard block |
||
300 | 300 | $fields += $c_fields; |
301 | 301 | $selects += $c_selects; |
302 | 302 | } |
303 | - if($fields) { |
|
304 | - foreach((array)$fields['select'] as $name) { |
|
305 | - if($record[$name] != null && is_array($selects) && $selects[$name]) { |
|
306 | - $key = array_search(strtolower($record[$name]), array_map('strtolower',$selects[$name])); |
|
307 | - if($key !== false) |
|
303 | + if ($fields) { |
|
304 | + foreach ((array)$fields['select'] as $name) { |
|
305 | + if ($record[$name] != null && is_array($selects) && $selects[$name]) { |
|
306 | + $key = array_search(strtolower($record[$name]), array_map('strtolower', $selects[$name])); |
|
307 | + if ($key !== false) |
|
308 | 308 | { |
309 | 309 | $record[$name] = $key; |
310 | 310 | } |
311 | 311 | else |
312 | 312 | { |
313 | - $key = array_search(strtolower($record[$name]), array_map('strtolower',array_map('lang',$selects[$name]))); |
|
314 | - if($key !== false) $record[$name] = $key; |
|
313 | + $key = array_search(strtolower($record[$name]), array_map('strtolower', array_map('lang', $selects[$name]))); |
|
314 | + if ($key !== false) $record[$name] = $key; |
|
315 | 315 | } |
316 | 316 | } |
317 | 317 | } |
318 | - foreach((array)$fields['links'] as $name) { |
|
319 | - if($record[$name] && $links[$name]) |
|
318 | + foreach ((array)$fields['links'] as $name) { |
|
319 | + if ($record[$name] && $links[$name]) |
|
320 | 320 | { |
321 | 321 | // Primary key to another app, not a link |
322 | 322 | // Text - search for a matching record |
323 | - if(!is_numeric($record[$name])) |
|
323 | + if (!is_numeric($record[$name])) |
|
324 | 324 | { |
325 | 325 | $results = Link::query($links[$name], $record[$name]); |
326 | - if(count($results) >= 1) |
|
326 | + if (count($results) >= 1) |
|
327 | 327 | { |
328 | 328 | // More than 1 result. Check for exact match |
329 | 329 | $exact_count = 0; |
330 | - foreach($results as $id => $title) |
|
330 | + foreach ($results as $id => $title) |
|
331 | 331 | { |
332 | - if($title == $record[$name]) |
|
332 | + if ($title == $record[$name]) |
|
333 | 333 | { |
334 | 334 | $exact_count++; |
335 | 335 | $app_id = $id; |
@@ -338,11 +338,11 @@ discard block |
||
338 | 338 | unset($results[$id]); |
339 | 339 | } |
340 | 340 | // Too many exact matches, or none good enough |
341 | - if($exact_count > 1 || count($results) == 0) |
|
341 | + if ($exact_count > 1 || count($results) == 0) |
|
342 | 342 | { |
343 | 343 | $warnings[] = lang('Unable to link to %1 "%2"', |
344 | 344 | lang($links[$name]), $record[$name]). |
345 | - ' - ' .lang('too many matches'); |
|
345 | + ' - '.lang('too many matches'); |
|
346 | 346 | continue; |
347 | 347 | } |
348 | 348 | elseif ($exact_count == 1) |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | { |
356 | 356 | $warnings[] = lang('Unable to link to %1 "%2"', |
357 | 357 | lang($links[$name]), $record[$name]). |
358 | - ' - ' . lang('no matches'); |
|
358 | + ' - '.lang('no matches'); |
|
359 | 359 | continue; |
360 | 360 | } else { |
361 | 361 | $record[$name] = key($results); |
@@ -363,17 +363,17 @@ discard block |
||
363 | 363 | } |
364 | 364 | } |
365 | 365 | } |
366 | - foreach((array)$fields['select-account'] as $name) { |
|
366 | + foreach ((array)$fields['select-account'] as $name) { |
|
367 | 367 | // Compare against null to deal with empty arrays |
368 | 368 | if ($record[$name]) { |
369 | 369 | // Automatically handle text owner without explicit translation |
370 | 370 | $new_owner = importexport_helper_functions::account_name2id($record[$name]); |
371 | - if(count($new_owner) != count(explode(',',$record[$name]))) |
|
371 | + if (count($new_owner) != count(explode(',', $record[$name]))) |
|
372 | 372 | { |
373 | 373 | // Unable to parse value into account |
374 | - $warnings[] = $name . ': ' .lang('%1 is not a known user or group', $record[$name]); |
|
374 | + $warnings[] = $name.': '.lang('%1 is not a known user or group', $record[$name]); |
|
375 | 375 | } |
376 | - if($new_owner != '') { |
|
376 | + if ($new_owner != '') { |
|
377 | 377 | $record[$name] = $new_owner; |
378 | 378 | } else { |
379 | 379 | // Clear it to prevent trouble later on |
@@ -381,24 +381,24 @@ discard block |
||
381 | 381 | } |
382 | 382 | } |
383 | 383 | } |
384 | - foreach((array)$fields['select-bool'] as $name) { |
|
385 | - if($record[$name] != null && $record[$name] != '') { |
|
384 | + foreach ((array)$fields['select-bool'] as $name) { |
|
385 | + if ($record[$name] != null && $record[$name] != '') { |
|
386 | 386 | $record[$name] = ($record[$name] == lang('Yes') || $record[$name] == '1' ? 1 : 0); |
387 | 387 | } |
388 | 388 | } |
389 | - foreach((array)$fields['date-time'] as $name) { |
|
389 | + foreach ((array)$fields['date-time'] as $name) { |
|
390 | 390 | if (isset($record[$name]) && !is_numeric($record[$name]) && strlen(trim($record[$name])) > 0) |
391 | 391 | { |
392 | 392 | // Need to handle format first |
393 | - if($format == 1) |
|
393 | + if ($format == 1) |
|
394 | 394 | { |
395 | 395 | $formatted = Api\DateTime::createFromFormat( |
396 | - '!'.Api\DateTime::$user_dateformat . ' ' .Api\DateTime::$user_timeformat, |
|
396 | + '!'.Api\DateTime::$user_dateformat.' '.Api\DateTime::$user_timeformat, |
|
397 | 397 | $record[$name], |
398 | 398 | Api\DateTime::$user_timezone |
399 | 399 | ); |
400 | 400 | |
401 | - if(!$formatted && $errors = Api\DateTime::getLastErrors()) |
|
401 | + if (!$formatted && $errors = Api\DateTime::getLastErrors()) |
|
402 | 402 | { |
403 | 403 | // Try again, without time |
404 | 404 | $formatted = Api\DateTime::createFromFormat( |
@@ -407,70 +407,70 @@ discard block |
||
407 | 407 | Api\DateTime::$user_timezone |
408 | 408 | ); |
409 | 409 | |
410 | - if(!$formatted && $errors = Api\DateTime::getLastErrors()) |
|
410 | + if (!$formatted && $errors = Api\DateTime::getLastErrors()) |
|
411 | 411 | { |
412 | 412 | // Try again, anything goes |
413 | 413 | try { |
414 | 414 | $formatted = new Api\DateTime($record[$name]); |
415 | 415 | } catch (Exception $e) { |
416 | - $warnings[] = $name.': ' . $e->getMessage() . "\n" . |
|
417 | - 'Format: '.'!'.Api\DateTime::$user_dateformat . ' ' .Api\DateTime::$user_timeformat; |
|
416 | + $warnings[] = $name.': '.$e->getMessage()."\n". |
|
417 | + 'Format: '.'!'.Api\DateTime::$user_dateformat.' '.Api\DateTime::$user_timeformat; |
|
418 | 418 | continue; |
419 | 419 | } |
420 | 420 | $errors = Api\DateTime::getLastErrors(); |
421 | - foreach($errors['errors'] as $char => $msg) |
|
421 | + foreach ($errors['errors'] as $char => $msg) |
|
422 | 422 | { |
423 | 423 | $warnings[] = "$name: [$char] $msg\n". |
424 | - 'Format: '.'!'.Api\DateTime::$user_dateformat . ' ' .Api\DateTime::$user_timeformat; |
|
424 | + 'Format: '.'!'.Api\DateTime::$user_dateformat.' '.Api\DateTime::$user_timeformat; |
|
425 | 425 | } |
426 | 426 | } |
427 | 427 | } |
428 | - if($formatted) |
|
428 | + if ($formatted) |
|
429 | 429 | { |
430 | 430 | $record[$name] = $formatted->getTimestamp(); |
431 | 431 | // Timestamp is apparently in server time, but apps will do the same conversion |
432 | - $record[$name] = Api\DateTime::server2user($record[$name],'ts'); |
|
432 | + $record[$name] = Api\DateTime::server2user($record[$name], 'ts'); |
|
433 | 433 | } |
434 | 434 | } |
435 | 435 | |
436 | - if(is_array(self::$cf_parse_cache[$appname][0]['date-time']) && |
|
436 | + if (is_array(self::$cf_parse_cache[$appname][0]['date-time']) && |
|
437 | 437 | in_array($name, self::$cf_parse_cache[$appname][0]['date-time'])) { |
438 | 438 | // Custom fields stored in a particular format (from customfields_widget) |
439 | 439 | $record[$name] = date('Y-m-d H:i:s', $record[$name]); |
440 | 440 | } |
441 | 441 | } |
442 | - if(array_key_exists($name, $record) && strlen(trim($record[$name])) == 0) |
|
442 | + if (array_key_exists($name, $record) && strlen(trim($record[$name])) == 0) |
|
443 | 443 | { |
444 | 444 | $record[$name] = null; |
445 | 445 | } |
446 | 446 | } |
447 | - foreach((array)$fields['date'] as $name) { |
|
447 | + foreach ((array)$fields['date'] as $name) { |
|
448 | 448 | if (isset($record[$name]) && !is_numeric($record[$name]) && strlen(trim($record[$name])) > 0) |
449 | 449 | { |
450 | 450 | // Need to handle format first |
451 | - if($format == 1) |
|
451 | + if ($format == 1) |
|
452 | 452 | { |
453 | 453 | $formatted = Api\DateTime::createFromFormat('!'.Api\DateTime::$user_dateformat, $record[$name]); |
454 | - if($formatted && $errors = Api\DateTime::getLastErrors() && $errors['error_count'] == 0) |
|
454 | + if ($formatted && $errors = Api\DateTime::getLastErrors() && $errors['error_count'] == 0) |
|
455 | 455 | { |
456 | 456 | $record[$name] = $formatted->getTimestamp(); |
457 | 457 | } |
458 | 458 | } |
459 | - $record[$name] = Api\DateTime::server2user($record[$name],'ts'); |
|
460 | - if(is_array(self::$cf_parse_cache[$appname][0]['date']) && |
|
459 | + $record[$name] = Api\DateTime::server2user($record[$name], 'ts'); |
|
460 | + if (is_array(self::$cf_parse_cache[$appname][0]['date']) && |
|
461 | 461 | in_array($name, self::$cf_parse_cache[$appname][0]['date'])) { |
462 | 462 | // Custom fields stored in a particular format (from customfields_widget) |
463 | 463 | $record[$name] = date('Y-m-d', $record[$name]); |
464 | 464 | } |
465 | 465 | } |
466 | - if(array_key_exists($name, $record) && strlen(trim($record[$name])) == 0) |
|
466 | + if (array_key_exists($name, $record) && strlen(trim($record[$name])) == 0) |
|
467 | 467 | { |
468 | 468 | $record[$name] = null; |
469 | 469 | } |
470 | 470 | } |
471 | - foreach((array)$fields['float'] as $name) |
|
471 | + foreach ((array)$fields['float'] as $name) |
|
472 | 472 | { |
473 | - if($record[$name] != null && $record[$name] != '') { |
|
473 | + if ($record[$name] != null && $record[$name] != '') { |
|
474 | 474 | $dec_point = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0]; |
475 | 475 | if (empty($dec_point)) $dec_point = '.'; |
476 | 476 | $record[$name] = floatval(str_replace($dec_point, '.', preg_replace('/[^\d'.preg_quote($dec_point).']/', '', $record[$name]))); |
@@ -478,23 +478,23 @@ discard block |
||
478 | 478 | } |
479 | 479 | |
480 | 480 | // Some custom methods for conversion |
481 | - foreach((array)$methods as $name => $method) { |
|
482 | - if($record[$name]) $record[$name] = ExecMethod($method, $record[$name]); |
|
481 | + foreach ((array)$methods as $name => $method) { |
|
482 | + if ($record[$name]) $record[$name] = ExecMethod($method, $record[$name]); |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | // cat_name2id will use currentapp to create new categories |
486 | 486 | $current_app = $GLOBALS['egw_info']['flags']['currentapp']; |
487 | - if($appname) { |
|
487 | + if ($appname) { |
|
488 | 488 | $GLOBALS['egw_info']['flags']['currentapp'] = $appname; |
489 | 489 | } |
490 | - $categories = new Api\Categories('',$appname); |
|
491 | - foreach((array)$fields['select-cat'] as $name) { |
|
492 | - if($record[$name]) { |
|
490 | + $categories = new Api\Categories('', $appname); |
|
491 | + foreach ((array)$fields['select-cat'] as $name) { |
|
492 | + if ($record[$name]) { |
|
493 | 493 | // Only parse name if it needs it |
494 | - if($format == 1) |
|
494 | + if ($format == 1) |
|
495 | 495 | { |
496 | - $existing_cat = $categories->exists('all',$record[$name]); |
|
497 | - if($existing_cat) |
|
496 | + $existing_cat = $categories->exists('all', $record[$name]); |
|
497 | + if ($existing_cat) |
|
498 | 498 | { |
499 | 499 | $cat_id = $existing_cat; |
500 | 500 | } |
@@ -503,14 +503,14 @@ discard block |
||
503 | 503 | $cat_id = importexport_helper_functions::cat_name2id($record[$name]); |
504 | 504 | } |
505 | 505 | // Don't clear it if it wasn't found |
506 | - if($cat_id) $record[$name] = $cat_id; |
|
506 | + if ($cat_id) $record[$name] = $cat_id; |
|
507 | 507 | } |
508 | 508 | } |
509 | 509 | } |
510 | 510 | $GLOBALS['egw_info']['flags']['currentapp'] = $current_app; |
511 | 511 | } |
512 | 512 | |
513 | - return implode("\n",$warnings); |
|
513 | + return implode("\n", $warnings); |
|
514 | 514 | } |
515 | 515 | } // end of import_csv |
516 | 516 | ?> |
@@ -22,7 +22,9 @@ discard block |
||
22 | 22 | * @todo Throw away spechial chars and trim() entries ? |
23 | 23 | * @todo Check for XSS like userinput! (see common_functions) |
24 | 24 | */ |
25 | -class importexport_import_csv implements importexport_iface_import_record { //, Iterator { |
|
25 | +class importexport_import_csv implements importexport_iface_import_record |
|
26 | +{ |
|
27 | +//, Iterator { |
|
26 | 28 | |
27 | 29 | const csv_max_linelength = 8000; |
28 | 30 | |
@@ -83,10 +85,14 @@ discard block |
||
83 | 85 | * @param string $_resource resource containing data. May be each valid php-stream |
84 | 86 | * @param array $_options options for the resource array with keys: charset and fieldsep |
85 | 87 | */ |
86 | - public function __construct( $_resource, array $_options ) { |
|
88 | + public function __construct( $_resource, array $_options ) |
|
89 | + { |
|
87 | 90 | $this->resource = $_resource; |
88 | 91 | $this->csv_fieldsep = $_options['fieldsep']; |
89 | - if($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
|
92 | + if($_options['charset'] == 'user') |
|
93 | + { |
|
94 | + $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
|
95 | + } |
|
90 | 96 | $this->csv_charset = $_options['charset']; |
91 | 97 | return; |
92 | 98 | } // end of member function __construct |
@@ -94,7 +100,8 @@ discard block |
||
94 | 100 | /** |
95 | 101 | * cleanup |
96 | 102 | */ |
97 | - public function __destruct( ) { |
|
103 | + public function __destruct( ) |
|
104 | + { |
|
98 | 105 | } // end of member function __destruct |
99 | 106 | |
100 | 107 | /** |
@@ -103,20 +110,27 @@ discard block |
||
103 | 110 | * @param mixed _position may be: {current|first|last|next|previous|somenumber} |
104 | 111 | * @return mixed array with data / false if no furtor records |
105 | 112 | */ |
106 | - public function get_record( $_position = 'next' ) { |
|
113 | + public function get_record( $_position = 'next' ) |
|
114 | + { |
|
107 | 115 | |
108 | - if ($this->get_raw_record( $_position ) === false) { |
|
116 | + if ($this->get_raw_record( $_position ) === false) |
|
117 | + { |
|
109 | 118 | return false; |
110 | 119 | } |
111 | 120 | |
112 | 121 | // skip empty records |
113 | - if( count( array_unique( $this->record ) ) < 2 ) return $this->get_record( $_position ); |
|
122 | + if( count( array_unique( $this->record ) ) < 2 ) |
|
123 | + { |
|
124 | + return $this->get_record( $_position ); |
|
125 | + } |
|
114 | 126 | |
115 | - if ( !empty( $this->conversion ) ) { |
|
127 | + if ( !empty( $this->conversion ) ) |
|
128 | + { |
|
116 | 129 | $this->do_conversions(); |
117 | 130 | } |
118 | 131 | |
119 | - if ( !empty( $this->mapping ) ) { |
|
132 | + if ( !empty( $this->mapping ) ) |
|
133 | + { |
|
120 | 134 | $this->do_fieldmapping(); |
121 | 135 | } |
122 | 136 | |
@@ -128,8 +142,10 @@ discard block |
||
128 | 142 | * |
129 | 143 | * @param int $_numToSkip |
130 | 144 | */ |
131 | - public function skip_records( $_numToSkip ) { |
|
132 | - while ( (int)$_numToSkip-- !== 0 ) { |
|
145 | + public function skip_records( $_numToSkip ) |
|
146 | + { |
|
147 | + while ( (int)$_numToSkip-- !== 0 ) |
|
148 | + { |
|
133 | 149 | fgetcsv( $this->resource, self::csv_max_linelength, $this->csv_fieldsep); |
134 | 150 | } |
135 | 151 | } |
@@ -140,22 +156,27 @@ discard block |
||
140 | 156 | * @param mixed $_position |
141 | 157 | * @return bool |
142 | 158 | */ |
143 | - private function get_raw_record( $_position = 'next' ) { |
|
144 | - switch ($_position) { |
|
159 | + private function get_raw_record( $_position = 'next' ) |
|
160 | + { |
|
161 | + switch ($_position) |
|
162 | + { |
|
145 | 163 | case 'current' : |
146 | - if ($this->current_position == 0) { |
|
164 | + if ($this->current_position == 0) |
|
165 | + { |
|
147 | 166 | return; |
148 | 167 | } |
149 | 168 | break; |
150 | 169 | case 'first' : |
151 | - if (!$this->current_position == 0) { |
|
170 | + if (!$this->current_position == 0) |
|
171 | + { |
|
152 | 172 | $this->current_position = 0; |
153 | 173 | rewind($this->resource); |
154 | 174 | } |
155 | 175 | |
156 | 176 | case 'next' : |
157 | 177 | $csv_data = fgetcsv( $this->resource, self::csv_max_linelength, $this->csv_fieldsep); |
158 | - if (!is_array($csv_data)) { |
|
178 | + if (!is_array($csv_data)) |
|
179 | + { |
|
159 | 180 | return false; |
160 | 181 | } |
161 | 182 | $this->current_position++; |
@@ -163,33 +184,41 @@ discard block |
||
163 | 184 | break; |
164 | 185 | |
165 | 186 | case 'previous' : |
166 | - if ($this->current_position < 2) { |
|
187 | + if ($this->current_position < 2) |
|
188 | + { |
|
167 | 189 | throw new Exception('Error: There is no previous record!'); |
168 | 190 | } |
169 | 191 | $final_position = --$this->current_position; |
170 | 192 | $this->current_position = 0; |
171 | 193 | rewind($this->resource); |
172 | - while ($this->current_position !== $final_position) { |
|
194 | + while ($this->current_position !== $final_position) |
|
195 | + { |
|
173 | 196 | $this->get_raw_record(); |
174 | 197 | } |
175 | 198 | break; |
176 | 199 | |
177 | 200 | case 'last' : |
178 | - while ($this->get_raw_record()) {} |
|
201 | + while ($this->get_raw_record()) |
|
202 | + { |
|
203 | +} |
|
179 | 204 | break; |
180 | 205 | |
181 | 206 | default: //somenumber |
182 | - if (!is_int($_position)) { |
|
207 | + if (!is_int($_position)) |
|
208 | + { |
|
183 | 209 | throw new Exception('Error: $position must be one of {current|first|last|next|previous} or an integer value'); |
184 | 210 | } |
185 | - if ($_position == $this->current_position) { |
|
211 | + if ($_position == $this->current_position) |
|
212 | + { |
|
186 | 213 | break; |
187 | 214 | } |
188 | - elseif ($_position < $this->current_position) { |
|
215 | + elseif ($_position < $this->current_position) |
|
216 | + { |
|
189 | 217 | $this->current_position = 0; |
190 | 218 | rewind($this->resource); |
191 | 219 | } |
192 | - while ($this->current_position !== $_position) { |
|
220 | + while ($this->current_position !== $_position) |
|
221 | + { |
|
193 | 222 | $this->get_raw_record(); |
194 | 223 | } |
195 | 224 | break; |
@@ -202,12 +231,16 @@ discard block |
||
202 | 231 | * |
203 | 232 | * @return int |
204 | 233 | */ |
205 | - public function get_num_of_records( ) { |
|
206 | - if ($this->num_of_records > 0) { |
|
234 | + public function get_num_of_records( ) |
|
235 | + { |
|
236 | + if ($this->num_of_records > 0) |
|
237 | + { |
|
207 | 238 | return $this->num_of_records; |
208 | 239 | } |
209 | 240 | $current_position = $this->current_position; |
210 | - while ($this->get_raw_record()) {} |
|
241 | + while ($this->get_raw_record()) |
|
242 | + { |
|
243 | +} |
|
211 | 244 | $this->num_of_records = $this->current_position; |
212 | 245 | $this->get_record($current_position); |
213 | 246 | return $this->num_of_records; |
@@ -218,7 +251,8 @@ discard block |
||
218 | 251 | * |
219 | 252 | * @return int |
220 | 253 | */ |
221 | - public function get_current_position( ) { |
|
254 | + public function get_current_position( ) |
|
255 | + { |
|
222 | 256 | |
223 | 257 | return $this->current_position; |
224 | 258 | |
@@ -230,12 +264,16 @@ discard block |
||
230 | 264 | * |
231 | 265 | * @return |
232 | 266 | */ |
233 | - protected function do_fieldmapping( ) { |
|
267 | + protected function do_fieldmapping( ) |
|
268 | + { |
|
234 | 269 | $record = $this->record; |
235 | 270 | $this->record = array(); |
236 | 271 | foreach ($this->mapping as $cvs_idx => $new_idx) |
237 | 272 | { |
238 | - if( $new_idx == '' ) continue; |
|
273 | + if( $new_idx == '' ) |
|
274 | + { |
|
275 | + continue; |
|
276 | + } |
|
239 | 277 | $this->record[$new_idx] = $record[$cvs_idx]; |
240 | 278 | } |
241 | 279 | return true; |
@@ -246,8 +284,10 @@ discard block |
||
246 | 284 | * |
247 | 285 | * @return bool |
248 | 286 | */ |
249 | - protected function do_conversions() { |
|
250 | - if ( $record = importexport_helper_functions::conversion( $this->record, $this->conversion, $this->conversion_class )) { |
|
287 | + protected function do_conversions() |
|
288 | + { |
|
289 | + if ( $record = importexport_helper_functions::conversion( $this->record, $this->conversion, $this->conversion_class )) |
|
290 | + { |
|
251 | 291 | $this->record = $record; |
252 | 292 | return; |
253 | 293 | } |
@@ -264,16 +304,19 @@ discard block |
||
264 | 304 | * |
265 | 305 | * @return string warnings, if any |
266 | 306 | */ |
267 | - public static function convert(Array &$record, Array $fields = array(), $appname = null, Array $selects = array(), $format=0) { |
|
307 | + public static function convert(Array &$record, Array $fields = array(), $appname = null, Array $selects = array(), $format=0) |
|
308 | + { |
|
268 | 309 | $warnings = array(); |
269 | 310 | |
270 | 311 | // Automatic conversions |
271 | - if($appname) { |
|
312 | + if($appname) |
|
313 | + { |
|
272 | 314 | |
273 | 315 | // Load translations |
274 | 316 | Api\Translation::add_app($appname); |
275 | 317 | |
276 | - if(!self::$cf_parse_cache[$appname]) { |
|
318 | + if(!self::$cf_parse_cache[$appname]) |
|
319 | + { |
|
277 | 320 | $c_fields = importexport_export_csv::convert_parse_custom_fields($appname, $selects, $links, $methods); |
278 | 321 | self::$cf_parse_cache[$appname] = array($c_fields, $selects, $links, $methods); |
279 | 322 | } |
@@ -282,7 +325,10 @@ discard block |
||
282 | 325 | // Add in any fields that are keys to another app |
283 | 326 | foreach((array)$fields['links'] as $link_field => $app) |
284 | 327 | { |
285 | - if(is_numeric($link_field)) continue; |
|
328 | + if(is_numeric($link_field)) |
|
329 | + { |
|
330 | + continue; |
|
331 | + } |
|
286 | 332 | $links[$link_field] = $app; |
287 | 333 | // Set it as a normal link field |
288 | 334 | $fields['links'][] = $link_field; |
@@ -292,7 +338,8 @@ discard block |
||
292 | 338 | // Not quite a recursive merge, since only one level |
293 | 339 | foreach($fields as $type => &$list) |
294 | 340 | { |
295 | - if($c_fields[$type]) { |
|
341 | + if($c_fields[$type]) |
|
342 | + { |
|
296 | 343 | $list = array_merge($c_fields[$type], $list); |
297 | 344 | unset($c_fields[$type]); |
298 | 345 | } |
@@ -300,9 +347,12 @@ discard block |
||
300 | 347 | $fields += $c_fields; |
301 | 348 | $selects += $c_selects; |
302 | 349 | } |
303 | - if($fields) { |
|
304 | - foreach((array)$fields['select'] as $name) { |
|
305 | - if($record[$name] != null && is_array($selects) && $selects[$name]) { |
|
350 | + if($fields) |
|
351 | + { |
|
352 | + foreach((array)$fields['select'] as $name) |
|
353 | + { |
|
354 | + if($record[$name] != null && is_array($selects) && $selects[$name]) |
|
355 | + { |
|
306 | 356 | $key = array_search(strtolower($record[$name]), array_map('strtolower',$selects[$name])); |
307 | 357 | if($key !== false) |
308 | 358 | { |
@@ -311,11 +361,15 @@ discard block |
||
311 | 361 | else |
312 | 362 | { |
313 | 363 | $key = array_search(strtolower($record[$name]), array_map('strtolower',array_map('lang',$selects[$name]))); |
314 | - if($key !== false) $record[$name] = $key; |
|
364 | + if($key !== false) |
|
365 | + { |
|
366 | + $record[$name] = $key; |
|
367 | + } |
|
315 | 368 | } |
316 | 369 | } |
317 | 370 | } |
318 | - foreach((array)$fields['links'] as $name) { |
|
371 | + foreach((array)$fields['links'] as $name) |
|
372 | + { |
|
319 | 373 | if($record[$name] && $links[$name]) |
320 | 374 | { |
321 | 375 | // Primary key to another app, not a link |
@@ -357,15 +411,19 @@ discard block |
||
357 | 411 | lang($links[$name]), $record[$name]). |
358 | 412 | ' - ' . lang('no matches'); |
359 | 413 | continue; |
360 | - } else { |
|
414 | + } |
|
415 | + else |
|
416 | + { |
|
361 | 417 | $record[$name] = key($results); |
362 | 418 | } |
363 | 419 | } |
364 | 420 | } |
365 | 421 | } |
366 | - foreach((array)$fields['select-account'] as $name) { |
|
422 | + foreach((array)$fields['select-account'] as $name) |
|
423 | + { |
|
367 | 424 | // Compare against null to deal with empty arrays |
368 | - if ($record[$name]) { |
|
425 | + if ($record[$name]) |
|
426 | + { |
|
369 | 427 | // Automatically handle text owner without explicit translation |
370 | 428 | $new_owner = importexport_helper_functions::account_name2id($record[$name]); |
371 | 429 | if(count($new_owner) != count(explode(',',$record[$name]))) |
@@ -373,20 +431,26 @@ discard block |
||
373 | 431 | // Unable to parse value into account |
374 | 432 | $warnings[] = $name . ': ' .lang('%1 is not a known user or group', $record[$name]); |
375 | 433 | } |
376 | - if($new_owner != '') { |
|
434 | + if($new_owner != '') |
|
435 | + { |
|
377 | 436 | $record[$name] = $new_owner; |
378 | - } else { |
|
437 | + } |
|
438 | + else |
|
439 | + { |
|
379 | 440 | // Clear it to prevent trouble later on |
380 | 441 | $record[$name] = ''; |
381 | 442 | } |
382 | 443 | } |
383 | 444 | } |
384 | - foreach((array)$fields['select-bool'] as $name) { |
|
385 | - if($record[$name] != null && $record[$name] != '') { |
|
445 | + foreach((array)$fields['select-bool'] as $name) |
|
446 | + { |
|
447 | + if($record[$name] != null && $record[$name] != '') |
|
448 | + { |
|
386 | 449 | $record[$name] = ($record[$name] == lang('Yes') || $record[$name] == '1' ? 1 : 0); |
387 | 450 | } |
388 | 451 | } |
389 | - foreach((array)$fields['date-time'] as $name) { |
|
452 | + foreach((array)$fields['date-time'] as $name) |
|
453 | + { |
|
390 | 454 | if (isset($record[$name]) && !is_numeric($record[$name]) && strlen(trim($record[$name])) > 0) |
391 | 455 | { |
392 | 456 | // Need to handle format first |
@@ -412,7 +476,8 @@ discard block |
||
412 | 476 | // Try again, anything goes |
413 | 477 | try { |
414 | 478 | $formatted = new Api\DateTime($record[$name]); |
415 | - } catch (Exception $e) { |
|
479 | + } |
|
480 | + catch (Exception $e) { |
|
416 | 481 | $warnings[] = $name.': ' . $e->getMessage() . "\n" . |
417 | 482 | 'Format: '.'!'.Api\DateTime::$user_dateformat . ' ' .Api\DateTime::$user_timeformat; |
418 | 483 | continue; |
@@ -434,7 +499,8 @@ discard block |
||
434 | 499 | } |
435 | 500 | |
436 | 501 | if(is_array(self::$cf_parse_cache[$appname][0]['date-time']) && |
437 | - in_array($name, self::$cf_parse_cache[$appname][0]['date-time'])) { |
|
502 | + in_array($name, self::$cf_parse_cache[$appname][0]['date-time'])) |
|
503 | + { |
|
438 | 504 | // Custom fields stored in a particular format (from customfields_widget) |
439 | 505 | $record[$name] = date('Y-m-d H:i:s', $record[$name]); |
440 | 506 | } |
@@ -444,7 +510,8 @@ discard block |
||
444 | 510 | $record[$name] = null; |
445 | 511 | } |
446 | 512 | } |
447 | - foreach((array)$fields['date'] as $name) { |
|
513 | + foreach((array)$fields['date'] as $name) |
|
514 | + { |
|
448 | 515 | if (isset($record[$name]) && !is_numeric($record[$name]) && strlen(trim($record[$name])) > 0) |
449 | 516 | { |
450 | 517 | // Need to handle format first |
@@ -458,7 +525,8 @@ discard block |
||
458 | 525 | } |
459 | 526 | $record[$name] = Api\DateTime::server2user($record[$name],'ts'); |
460 | 527 | if(is_array(self::$cf_parse_cache[$appname][0]['date']) && |
461 | - in_array($name, self::$cf_parse_cache[$appname][0]['date'])) { |
|
528 | + in_array($name, self::$cf_parse_cache[$appname][0]['date'])) |
|
529 | + { |
|
462 | 530 | // Custom fields stored in a particular format (from customfields_widget) |
463 | 531 | $record[$name] = date('Y-m-d', $record[$name]); |
464 | 532 | } |
@@ -470,26 +538,37 @@ discard block |
||
470 | 538 | } |
471 | 539 | foreach((array)$fields['float'] as $name) |
472 | 540 | { |
473 | - if($record[$name] != null && $record[$name] != '') { |
|
541 | + if($record[$name] != null && $record[$name] != '') |
|
542 | + { |
|
474 | 543 | $dec_point = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0]; |
475 | - if (empty($dec_point)) $dec_point = '.'; |
|
544 | + if (empty($dec_point)) |
|
545 | + { |
|
546 | + $dec_point = '.'; |
|
547 | + } |
|
476 | 548 | $record[$name] = floatval(str_replace($dec_point, '.', preg_replace('/[^\d'.preg_quote($dec_point).']/', '', $record[$name]))); |
477 | 549 | } |
478 | 550 | } |
479 | 551 | |
480 | 552 | // Some custom methods for conversion |
481 | - foreach((array)$methods as $name => $method) { |
|
482 | - if($record[$name]) $record[$name] = ExecMethod($method, $record[$name]); |
|
553 | + foreach((array)$methods as $name => $method) |
|
554 | + { |
|
555 | + if($record[$name]) |
|
556 | + { |
|
557 | + $record[$name] = ExecMethod($method, $record[$name]); |
|
558 | + } |
|
483 | 559 | } |
484 | 560 | |
485 | 561 | // cat_name2id will use currentapp to create new categories |
486 | 562 | $current_app = $GLOBALS['egw_info']['flags']['currentapp']; |
487 | - if($appname) { |
|
563 | + if($appname) |
|
564 | + { |
|
488 | 565 | $GLOBALS['egw_info']['flags']['currentapp'] = $appname; |
489 | 566 | } |
490 | 567 | $categories = new Api\Categories('',$appname); |
491 | - foreach((array)$fields['select-cat'] as $name) { |
|
492 | - if($record[$name]) { |
|
568 | + foreach((array)$fields['select-cat'] as $name) |
|
569 | + { |
|
570 | + if($record[$name]) |
|
571 | + { |
|
493 | 572 | // Only parse name if it needs it |
494 | 573 | if($format == 1) |
495 | 574 | { |
@@ -503,7 +582,10 @@ discard block |
||
503 | 582 | $cat_id = importexport_helper_functions::cat_name2id($record[$name]); |
504 | 583 | } |
505 | 584 | // Don't clear it if it wasn't found |
506 | - if($cat_id) $record[$name] = $cat_id; |
|
585 | + if($cat_id) |
|
586 | + { |
|
587 | + $record[$name] = $cat_id; |
|
588 | + } |
|
507 | 589 | } |
508 | 590 | } |
509 | 591 | } |
@@ -264,7 +264,7 @@ |
||
264 | 264 | * |
265 | 265 | * @return string warnings, if any |
266 | 266 | */ |
267 | - public static function convert(Array &$record, Array $fields = array(), $appname = null, Array $selects = array(), $format=0) { |
|
267 | + public static function convert(array &$record, array $fields = array(), $appname = null, array $selects = array(), $format=0) { |
|
268 | 268 | $warnings = array(); |
269 | 269 | |
270 | 270 | // Automatic conversions |
@@ -295,7 +295,7 @@ |
||
295 | 295 | * |
296 | 296 | * @param importexport_iface_import_plugin $plugin Instance of plugin to be used |
297 | 297 | * @param resource $stream |
298 | - * @param importexport_definition $definition |
|
298 | + * @param importexport_definition $definition_obj |
|
299 | 299 | * @return String HTML fragment illustrating how the data will be understood by Egw |
300 | 300 | */ |
301 | 301 | protected function preview(importexport_iface_import_plugin &$plugin, &$stream, importexport_definition &$definition_obj) |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
44 | - * Step user through importing their file |
|
45 | - */ |
|
44 | + * Step user through importing their file |
|
45 | + */ |
|
46 | 46 | public function import_dialog($content = array()) { |
47 | 47 | $appname = $_GET['appname'] ? $_GET['appname'] : $content['appname']; |
48 | 48 | $definition = $_GET['definition'] ? $_GET['definition'] : $content['definition']; |
@@ -224,8 +224,8 @@ discard block |
||
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
227 | - * Get options for select boxes |
|
228 | - */ |
|
227 | + * Get options for select boxes |
|
228 | + */ |
|
229 | 229 | public static function get_select_options(Array $data) { |
230 | 230 | $options = array( |
231 | 231 | 'delimiter' => array( |
@@ -274,8 +274,8 @@ discard block |
||
274 | 274 | } |
275 | 275 | |
276 | 276 | /** |
277 | - * Get definitions via ajax |
|
278 | - */ |
|
277 | + * Get definitions via ajax |
|
278 | + */ |
|
279 | 279 | public function ajax_get_definitions($appname, $file=null) { |
280 | 280 | $options = self::get_select_options(array('appname'=>$appname, 'file'=>$file)); |
281 | 281 | $response = new xajaxResponse(); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | private $plugins; |
37 | 37 | |
38 | 38 | public function __construct() { |
39 | - $this->plugins = importexport_helper_functions::get_plugins('all','import'); |
|
39 | + $this->plugins = importexport_helper_functions::get_plugins('all', 'import'); |
|
40 | 40 | $GLOBALS['egw_info']['flags']['include_xajax'] = true; |
41 | 41 | } |
42 | 42 | |
@@ -53,20 +53,20 @@ discard block |
||
53 | 53 | $template = new Etemplate('importexport.import_dialog'); |
54 | 54 | |
55 | 55 | // Load application's translations |
56 | - if($appname) |
|
56 | + if ($appname) |
|
57 | 57 | { |
58 | 58 | Api\Translation::add_app($appname); |
59 | 59 | } |
60 | - if($content['import'] && $definition) { |
|
60 | + if ($content['import'] && $definition) { |
|
61 | 61 | try { |
62 | 62 | $definition_obj = new importexport_definition($content['definition']); |
63 | - if($content['dry-run']) { |
|
63 | + if ($content['dry-run']) { |
|
64 | 64 | // Set this so plugin doesn't do any data changes |
65 | 65 | $definition_obj->plugin_options = (array)$definition_obj->plugin_options + array('dry_run' => true); |
66 | 66 | } |
67 | - $options =& $definition_obj->plugin_options; |
|
67 | + $options = & $definition_obj->plugin_options; |
|
68 | 68 | $options['no_notification'] = $content['no_notifications']; |
69 | - if($content['delimiter']) { |
|
69 | + if ($content['delimiter']) { |
|
70 | 70 | $options['fieldsep'] = |
71 | 71 | $content['delimiter'] == 'other' ? $content['other_delimiter'] : $content['delimiter']; |
72 | 72 | } |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | $plugin = new $definition_obj->plugin; |
76 | 76 | |
77 | 77 | // Check file encoding matches import |
78 | - $sample = file_get_contents($content['file']['tmp_name'],false, null, 0, 1024); |
|
79 | - if($appname == 'addressbook' && $definition_obj->plugin == 'addressbook_import_vcard') |
|
78 | + $sample = file_get_contents($content['file']['tmp_name'], false, null, 0, 1024); |
|
79 | + if ($appname == 'addressbook' && $definition_obj->plugin == 'addressbook_import_vcard') |
|
80 | 80 | { |
81 | 81 | $preference = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset']; |
82 | 82 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | } |
87 | 87 | $required = $options['charset'] == 'user' || !$options['charset'] ? $preference : $options['charset']; |
88 | 88 | $encoding = Api\Translation::detect_encoding($sample, $required); |
89 | - if($encoding && strtoupper($required) != strtoupper($encoding)) |
|
89 | + if ($encoding && strtoupper($required) != strtoupper($encoding)) |
|
90 | 90 | { |
91 | 91 | $this->message = lang("Encoding mismatch. Expected %1 file, you uploaded %2.<br />\n", |
92 | 92 | $required, |
@@ -101,37 +101,37 @@ discard block |
||
101 | 101 | $GLOBALS['egw_info']['flags']['currentapp'] = $appname; |
102 | 102 | |
103 | 103 | // Destination if we need to hold the file |
104 | - if($file) |
|
104 | + if ($file) |
|
105 | 105 | { |
106 | 106 | $cachefile = new egw_cache_files(array()); |
107 | 107 | $dst_file = $cachefile->filename(Api\Cache::keys(Api\Cache::INSTANCE, 'importexport', |
108 | - 'import_'.md5($content['file']['name'].$GLOBALS['egw_info']['user']['account_id']), true),true); |
|
108 | + 'import_'.md5($content['file']['name'].$GLOBALS['egw_info']['user']['account_id']), true), true); |
|
109 | 109 | // Keep file |
110 | - if($dst_file) |
|
110 | + if ($dst_file) |
|
111 | 111 | { |
112 | - if($content['file']['name'] && copy($content['file']['tmp_name'],$dst_file)) { |
|
112 | + if ($content['file']['name'] && copy($content['file']['tmp_name'], $dst_file)) { |
|
113 | 113 | $preserve['file']['tmp_name'] = $dst_file; |
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | 117 | // Check on matching columns |
118 | 118 | $check_message = array(); |
119 | - if(!self::check_file($file, $definition_obj, $check_message, $dst_file)) |
|
119 | + if (!self::check_file($file, $definition_obj, $check_message, $dst_file)) |
|
120 | 120 | { |
121 | 121 | // Set this so plugin doesn't do any data changes |
122 | 122 | $content['dry-run'] = true; |
123 | 123 | importexport_helper_functions::$dry_run = true; |
124 | - $this->message .= '<b>' . lang('Import aborted').":</b><br />\n"; |
|
124 | + $this->message .= '<b>'.lang('Import aborted').":</b><br />\n"; |
|
125 | 125 | $definition_obj->plugin_options = (array)$definition_obj->plugin_options + array('dry_run' => true); |
126 | 126 | } |
127 | - if(count($check_message)) |
|
127 | + if (count($check_message)) |
|
128 | 128 | { |
129 | - $this->message .= implode($check_message, "<br />\n") . "<br />\n"; |
|
129 | + $this->message .= implode($check_message, "<br />\n")."<br />\n"; |
|
130 | 130 | } |
131 | - if($content['dry-run']) |
|
131 | + if ($content['dry-run']) |
|
132 | 132 | { |
133 | 133 | $preview = $this->preview($plugin, $file, $definition_obj); |
134 | - if(trim($this->message) == '') |
|
134 | + if (trim($this->message) == '') |
|
135 | 135 | { |
136 | 136 | // Clear first, to prevent request from being collected if the result is the same |
137 | 137 | $template->setElementAttribute('preview', 'value', ''); |
@@ -150,34 +150,34 @@ discard block |
||
150 | 150 | $this->message .= lang('please select file to import'."<br />\n"); |
151 | 151 | } |
152 | 152 | |
153 | - if($content['dry-run']) |
|
153 | + if ($content['dry-run']) |
|
154 | 154 | { |
155 | - $this->message .= '<b>' . lang('test only').":</b><br />\n"; |
|
155 | + $this->message .= '<b>'.lang('test only').":</b><br />\n"; |
|
156 | 156 | } |
157 | 157 | $this->message .= lang('%1 records processed', $count); |
158 | 158 | |
159 | 159 | // Refresh opening window |
160 | - if(!$content['dry-run']) |
|
160 | + if (!$content['dry-run']) |
|
161 | 161 | { |
162 | - Framework::refresh_opener(lang('%1 records processed',$count), $appname, null,null,$appname); |
|
162 | + Framework::refresh_opener(lang('%1 records processed', $count), $appname, null, null, $appname); |
|
163 | 163 | } |
164 | 164 | $total_processed = 0; |
165 | - foreach($plugin->get_results() as $action => $a_count) { |
|
166 | - $this->message .= "<br />\n" . lang($action) . ": $a_count"; |
|
165 | + foreach ($plugin->get_results() as $action => $a_count) { |
|
166 | + $this->message .= "<br />\n".lang($action).": $a_count"; |
|
167 | 167 | $total_processed += $a_count; |
168 | 168 | } |
169 | - if(count($plugin->get_warnings())) { |
|
169 | + if (count($plugin->get_warnings())) { |
|
170 | 170 | $this->message .= "<br />\n".lang('Warnings').':'; |
171 | - foreach($plugin->get_warnings() as $record => $message) { |
|
171 | + foreach ($plugin->get_warnings() as $record => $message) { |
|
172 | 172 | $this->message .= "\n$record: $message"; |
173 | 173 | } |
174 | 174 | } |
175 | - if(count($plugin->get_errors())) { |
|
175 | + if (count($plugin->get_errors())) { |
|
176 | 176 | $this->message .= "<br />\n".lang('Problems during import:'); |
177 | - foreach($plugin->get_errors() as $record => $message) { |
|
177 | + foreach ($plugin->get_errors() as $record => $message) { |
|
178 | 178 | $this->message .= "<br />\n$record: $message"; |
179 | 179 | } |
180 | - if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported'); |
|
180 | + if ($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported'); |
|
181 | 181 | } |
182 | 182 | if ($dst_file && $content['file']['tmp_name'] == $dst_file) { |
183 | 183 | // Remove file |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | $this->message .= $e->getMessage(); |
191 | 191 | } |
192 | 192 | } |
193 | - elseif($content['cancel']) |
|
193 | + elseif ($content['cancel']) |
|
194 | 194 | { |
195 | 195 | egw_framework::set_onload('window.close();'); |
196 | 196 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | ); |
204 | 204 | } |
205 | 205 | |
206 | - if(!array_key_exists('dry-run',$content)) |
|
206 | + if (!array_key_exists('dry-run', $content)) |
|
207 | 207 | { |
208 | 208 | $data['dry-run'] = true; |
209 | 209 | } |
@@ -211,14 +211,14 @@ discard block |
||
211 | 211 | $data['appname'] = $preserve['appname'] = $appname ? $appname : ($definition_obj ? $definition_obj->application : ''); |
212 | 212 | $data['definition'] = $definition; |
213 | 213 | $data['delimiter'] = $definition_obj->plugin_options['delimiter']; |
214 | - $data['no_notifications'] = true; // switch notifications off by default |
|
214 | + $data['no_notifications'] = true; // switch notifications off by default |
|
215 | 215 | |
216 | 216 | $sel_options = self::get_select_options($data); |
217 | 217 | |
218 | 218 | $data['message'] = $this->message; |
219 | - Framework::includeJS('.','importexport','importexport'); |
|
219 | + Framework::includeJS('.', 'importexport', 'importexport'); |
|
220 | 220 | |
221 | - if($_GET['appname']) $readonlys['appname'] = true; |
|
221 | + if ($_GET['appname']) $readonlys['appname'] = true; |
|
222 | 222 | |
223 | 223 | $template->exec('importexport.importexport_import_ui.import_dialog', $data, $sel_options, $readonlys, $preserve, 2); |
224 | 224 | } |
@@ -240,12 +240,12 @@ discard block |
||
240 | 240 | ); |
241 | 241 | |
242 | 242 | (array)$apps = importexport_helper_functions::get_apps('import'); |
243 | - $options['appname'] = array('' => lang('Select one')) + array_combine($apps,$apps); |
|
243 | + $options['appname'] = array('' => lang('Select one')) + array_combine($apps, $apps); |
|
244 | 244 | |
245 | - if($data['appname']) { |
|
245 | + if ($data['appname']) { |
|
246 | 246 | $options['definition'] = array(); |
247 | 247 | |
248 | - if($data['file'] && !is_array($data['file'])) { |
|
248 | + if ($data['file'] && !is_array($data['file'])) { |
|
249 | 249 | $extension = substr($data['file'], -3); |
250 | 250 | } |
251 | 251 | $definitions = new importexport_definitions_bo(array( |
@@ -276,11 +276,11 @@ discard block |
||
276 | 276 | /** |
277 | 277 | * Get definitions via ajax |
278 | 278 | */ |
279 | - public function ajax_get_definitions($appname, $file=null) { |
|
279 | + public function ajax_get_definitions($appname, $file = null) { |
|
280 | 280 | $options = self::get_select_options(array('appname'=>$appname, 'file'=>$file)); |
281 | 281 | $response = new xajaxResponse(); |
282 | 282 | $response->addScript("clear_options('exec[definition]');"); |
283 | - if(is_array($options['definition'])) { |
|
283 | + if (is_array($options['definition'])) { |
|
284 | 284 | foreach ($options['definition'] as $value => $title) { |
285 | 285 | $response->addScript("selectbox_add_option('exec[definition]','$title', '$value',false);"); |
286 | 286 | } |
@@ -298,28 +298,28 @@ discard block |
||
298 | 298 | * @param importexport_definition $definition |
299 | 299 | * @return String HTML fragment illustrating how the data will be understood by Egw |
300 | 300 | */ |
301 | - protected function preview(importexport_iface_import_plugin &$plugin, &$stream, importexport_definition &$definition_obj) |
|
301 | + protected function preview(importexport_iface_import_plugin&$plugin, &$stream, importexport_definition&$definition_obj) |
|
302 | 302 | { |
303 | - if(method_exists($plugin, 'preview')) |
|
303 | + if (method_exists($plugin, 'preview')) |
|
304 | 304 | { |
305 | 305 | $preview = $plugin->preview($stream, $definition_obj); |
306 | 306 | } |
307 | - elseif($definition_obj->plugin_options['csv_fields']) |
|
307 | + elseif ($definition_obj->plugin_options['csv_fields']) |
|
308 | 308 | { |
309 | - $import_csv = new importexport_import_csv( $stream, array( |
|
309 | + $import_csv = new importexport_import_csv($stream, array( |
|
310 | 310 | 'fieldsep' => $definition_obj->plugin_options['fieldsep'], |
311 | 311 | 'charset' => $definition_obj->plugin_options['charset'], |
312 | 312 | )); |
313 | 313 | // set FieldMapping. |
314 | 314 | $import_csv->mapping = $definition_obj->plugin_options['field_mapping']; |
315 | 315 | |
316 | - $rows = array('h1'=>array(),'f1'=>array(),'.h1'=>'class=th'); |
|
317 | - for($row = 0; $row < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; $row++) |
|
316 | + $rows = array('h1'=>array(), 'f1'=>array(), '.h1'=>'class=th'); |
|
317 | + for ($row = 0; $row < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; $row++) |
|
318 | 318 | { |
319 | 319 | $row_data = $import_csv->get_record(); |
320 | - if($row_data === false) break; |
|
320 | + if ($row_data === false) break; |
|
321 | 321 | $rows[$import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines'] ? 'h1' : $row] = $row_data; |
322 | - if($import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines']) $row--; |
|
322 | + if ($import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines']) $row--; |
|
323 | 323 | } |
324 | 324 | $preview = Api\Html::table($rows); |
325 | 325 | rewind($stream); |
@@ -328,22 +328,22 @@ discard block |
||
328 | 328 | { |
329 | 329 | $preview = lang('Preview not supported by %1', $plugin->get_name()); |
330 | 330 | } |
331 | - if(count($plugin->get_warnings())) { |
|
331 | + if (count($plugin->get_warnings())) { |
|
332 | 332 | $this->message .= "<br />\n".lang('Warnings').':'; |
333 | - foreach($plugin->get_warnings() as $record => $message) { |
|
333 | + foreach ($plugin->get_warnings() as $record => $message) { |
|
334 | 334 | $this->message .= "\n$record: $message"; |
335 | 335 | } |
336 | 336 | $this->message .= "<br />\n"; |
337 | 337 | }; |
338 | - if(count($plugin->get_errors())) { |
|
338 | + if (count($plugin->get_errors())) { |
|
339 | 339 | $this->message .= "<br />\n".lang('Problems during import:'); |
340 | - foreach($plugin->get_errors() as $record => $message) { |
|
340 | + foreach ($plugin->get_errors() as $record => $message) { |
|
341 | 341 | $this->message .= "<br />\n$record: $message"; |
342 | 342 | } |
343 | - if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported'); |
|
343 | + if ($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported'); |
|
344 | 344 | $this->message .= "<br />\n"; |
345 | 345 | } |
346 | - return '<div class="header">' . lang('Preview') . ' - ' . $plugin->get_name() . '</div>' . $preview; |
|
346 | + return '<div class="header">'.lang('Preview').' - '.$plugin->get_name().'</div>'.$preview; |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | /** |
@@ -361,24 +361,24 @@ discard block |
||
361 | 361 | */ |
362 | 362 | public static function check_file(&$file, &$definition, &$message = array(), $dst_file = false) |
363 | 363 | { |
364 | - $options =& $definition->plugin_options; |
|
364 | + $options = & $definition->plugin_options; |
|
365 | 365 | $message_count = count($message); |
366 | 366 | |
367 | 367 | // Only CSV files |
368 | - if(!$options['csv_fields']) return true; |
|
368 | + if (!$options['csv_fields']) return true; |
|
369 | 369 | |
370 | 370 | // Can't check if definition has no header |
371 | - if($options['num_header_lines'] == 0) return true; |
|
371 | + if ($options['num_header_lines'] == 0) return true; |
|
372 | 372 | |
373 | 373 | $preference = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
374 | 374 | $charset = $options['charset'] == 'user' || !$options['charset'] ? $preference : $options['charset']; |
375 | 375 | |
376 | 376 | $data = fgetcsv($file, 8000, $options['fieldsep']); |
377 | 377 | rewind($file); |
378 | - $data = Api\Translation::convert($data,$charset); |
|
378 | + $data = Api\Translation::convert($data, $charset); |
|
379 | 379 | |
380 | 380 | $ok = true; |
381 | - if(count($data) != count($options['csv_fields']) && max(array_keys($data)) != max(array_keys($options['csv_fields']))) |
|
381 | + if (count($data) != count($options['csv_fields']) && max(array_keys($data)) != max(array_keys($options['csv_fields']))) |
|
382 | 382 | { |
383 | 383 | $message[] = lang("Column mismatch. Expected %1 columns, your file has %2.", |
384 | 384 | count($options['field_mapping']), |
@@ -386,9 +386,9 @@ discard block |
||
386 | 386 | ); |
387 | 387 | $ok = false; |
388 | 388 | } |
389 | - foreach($data as $index => $header) |
|
389 | + foreach ($data as $index => $header) |
|
390 | 390 | { |
391 | - if($index < count($options['csv_fields']) && !$options['field_mapping'][$index]) |
|
391 | + if ($index < count($options['csv_fields']) && !$options['field_mapping'][$index]) |
|
392 | 392 | { |
393 | 393 | // Skipped column in definition |
394 | 394 | continue; |
@@ -400,16 +400,16 @@ discard block |
||
400 | 400 | } |
401 | 401 | |
402 | 402 | // Check for matching headers |
403 | - if($options['csv_fields'][$index] == $header) |
|
403 | + if ($options['csv_fields'][$index] == $header) |
|
404 | 404 | { |
405 | 405 | // Simple match |
406 | 406 | continue; |
407 | 407 | } |
408 | 408 | // Check column headers, taking into account different translations - make sure no * |
409 | - $lang_defn = mb_strtoupper(Api\Translation::translate($options['csv_fields'][$index],false,'')); |
|
410 | - $lang_file = mb_strtoupper(Api\Translation::translate($header,false,'')); |
|
409 | + $lang_defn = mb_strtoupper(Api\Translation::translate($options['csv_fields'][$index], false, '')); |
|
410 | + $lang_file = mb_strtoupper(Api\Translation::translate($header, false, '')); |
|
411 | 411 | |
412 | - if($lang_defn == $lang_file || |
|
412 | + if ($lang_defn == $lang_file || |
|
413 | 413 | $lang_defn == mb_strtoupper($header) || |
414 | 414 | $lang_file == mb_strtoupper($options['csv_fields'][$index]) |
415 | 415 | ) |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | $file_message_id = Api\Translation::get_message_id($header, $definition->application); |
422 | 422 | $defn_message_id = Api\Translation::get_message_id($options['csv_fields'][$index], $definition->application); |
423 | 423 | |
424 | - if($file_message_id && $defn_message_id && $file_message_id == $defn_message_id) |
|
424 | + if ($file_message_id && $defn_message_id && $file_message_id == $defn_message_id) |
|
425 | 425 | { |
426 | 426 | continue; |
427 | 427 | } |
@@ -429,19 +429,19 @@ discard block |
||
429 | 429 | |
430 | 430 | // Problem |
431 | 431 | $message[] = lang("Column mismatch: %1 should be %2, not %3", |
432 | - $index,$options['csv_fields'][$index], $header); |
|
432 | + $index, $options['csv_fields'][$index], $header); |
|
433 | 433 | // But can still continue |
434 | 434 | // $ok = false; |
435 | 435 | } |
436 | - if(!$ok || count($message) != $message_count) |
|
436 | + if (!$ok || count($message) != $message_count) |
|
437 | 437 | { |
438 | 438 | // Add links for new / edit definition |
439 | 439 | $config = Api\Config::read('importexport'); |
440 | - if($GLOBALS['egw_info']['user']['apps']['admin'] || $config['users_create_definitions']) |
|
440 | + if ($GLOBALS['egw_info']['user']['apps']['admin'] || $config['users_create_definitions']) |
|
441 | 441 | { |
442 | 442 | $actions = ''; |
443 | 443 | // New definition |
444 | - $add_link = Egw::link('/index.php',array( |
|
444 | + $add_link = Egw::link('/index.php', array( |
|
445 | 445 | 'menuaction' => 'importexport.importexport_definitions_ui.edit', |
446 | 446 | 'application' => $definition->application, |
447 | 447 | 'plugin' => $definition->plugin, |
@@ -453,13 +453,13 @@ discard block |
||
453 | 453 | 'menuaction' => 'importexport.importexport_import_ui.import_dialog', |
454 | 454 | // Don't set appname, or user won't be able to select & see their new definition |
455 | 455 | //'appname' => $definition->application, |
456 | - )) . "'; |
|
456 | + ))."'; |
|
457 | 457 | egw_openWindowCentered2('$add_link','_blank',500,500,'yes'); |
458 | 458 | "; |
459 | 459 | $actions[] = lang('Create a <a href="%1">new definition</a> for this file', $add_link); |
460 | 460 | |
461 | 461 | // Edit selected definition, if allowed |
462 | - if($definition->owner == $GLOBALS['egw_info']['user']['account_id'] || |
|
462 | + if ($definition->owner == $GLOBALS['egw_info']['user']['account_id'] || |
|
463 | 463 | !$definition->owner && $GLOBALS['egw_info']['user']['apps']['admin']) |
464 | 464 | { |
465 | 465 | $edit_link = array( |
@@ -468,20 +468,20 @@ discard block |
||
468 | 468 | // Jump to file step |
469 | 469 | 'step' => 'wizard_step21' |
470 | 470 | ); |
471 | - if($dst_file) |
|
471 | + if ($dst_file) |
|
472 | 472 | { |
473 | 473 | // Still have uploaded file, jump there |
474 | - Api\Cache::setSession($definition->application,'csvfile',$dst_file); |
|
474 | + Api\Cache::setSession($definition->application, 'csvfile', $dst_file); |
|
475 | 475 | $edit_link['step'] = 'wizard_step30'; |
476 | 476 | } |
477 | - $edit_link = Egw::link('/index.php',$edit_link); |
|
477 | + $edit_link = Egw::link('/index.php', $edit_link); |
|
478 | 478 | $edit_link = "javascript:egw_openWindowCentered2('$edit_link','_blank',500,500,'yes')"; |
479 | 479 | $actions[] = lang('Edit definition <a href="%1">%2</a> to match your file', |
480 | - $edit_link, $definition->name ); |
|
480 | + $edit_link, $definition->name); |
|
481 | 481 | } |
482 | - $actions[] = lang('Edit your file to match the definition:') . ' ' |
|
483 | - . implode(array_map('lang',array_intersect_key($options['csv_fields'],$options['field_mapping'])),', '); |
|
484 | - $message[] = "\n<li>".implode($actions,"\n<li>"); |
|
482 | + $actions[] = lang('Edit your file to match the definition:').' ' |
|
483 | + . implode(array_map('lang', array_intersect_key($options['csv_fields'], $options['field_mapping'])), ', '); |
|
484 | + $message[] = "\n<li>".implode($actions, "\n<li>"); |
|
485 | 485 | } |
486 | 486 | } |
487 | 487 | return $ok; |
@@ -20,7 +20,8 @@ discard block |
||
20 | 20 | * |
21 | 21 | */ |
22 | 22 | |
23 | - class importexport_import_ui { |
|
23 | + class importexport_import_ui |
|
24 | + { |
|
24 | 25 | |
25 | 26 | const _appname = 'importexport'; |
26 | 27 | |
@@ -35,7 +36,8 @@ discard block |
||
35 | 36 | */ |
36 | 37 | private $plugins; |
37 | 38 | |
38 | - public function __construct() { |
|
39 | + public function __construct() |
|
40 | + { |
|
39 | 41 | $this->plugins = importexport_helper_functions::get_plugins('all','import'); |
40 | 42 | $GLOBALS['egw_info']['flags']['include_xajax'] = true; |
41 | 43 | } |
@@ -43,7 +45,8 @@ discard block |
||
43 | 45 | /** |
44 | 46 | * Step user through importing their file |
45 | 47 | */ |
46 | - public function import_dialog($content = array()) { |
|
48 | + public function import_dialog($content = array()) |
|
49 | + { |
|
47 | 50 | $appname = $_GET['appname'] ? $_GET['appname'] : $content['appname']; |
48 | 51 | $definition = $_GET['definition'] ? $_GET['definition'] : $content['definition']; |
49 | 52 | |
@@ -57,16 +60,19 @@ discard block |
||
57 | 60 | { |
58 | 61 | Api\Translation::add_app($appname); |
59 | 62 | } |
60 | - if($content['import'] && $definition) { |
|
63 | + if($content['import'] && $definition) |
|
64 | + { |
|
61 | 65 | try { |
62 | 66 | $definition_obj = new importexport_definition($content['definition']); |
63 | - if($content['dry-run']) { |
|
67 | + if($content['dry-run']) |
|
68 | + { |
|
64 | 69 | // Set this so plugin doesn't do any data changes |
65 | 70 | $definition_obj->plugin_options = (array)$definition_obj->plugin_options + array('dry_run' => true); |
66 | 71 | } |
67 | 72 | $options =& $definition_obj->plugin_options; |
68 | 73 | $options['no_notification'] = $content['no_notifications']; |
69 | - if($content['delimiter']) { |
|
74 | + if($content['delimiter']) |
|
75 | + { |
|
70 | 76 | $options['fieldsep'] = |
71 | 77 | $content['delimiter'] == 'other' ? $content['other_delimiter'] : $content['delimiter']; |
72 | 78 | } |
@@ -109,7 +115,8 @@ discard block |
||
109 | 115 | // Keep file |
110 | 116 | if($dst_file) |
111 | 117 | { |
112 | - if($content['file']['name'] && copy($content['file']['tmp_name'],$dst_file)) { |
|
118 | + if($content['file']['name'] && copy($content['file']['tmp_name'],$dst_file)) |
|
119 | + { |
|
113 | 120 | $preserve['file']['tmp_name'] = $dst_file; |
114 | 121 | } |
115 | 122 | } |
@@ -162,31 +169,41 @@ discard block |
||
162 | 169 | Framework::refresh_opener(lang('%1 records processed',$count), $appname, null,null,$appname); |
163 | 170 | } |
164 | 171 | $total_processed = 0; |
165 | - foreach($plugin->get_results() as $action => $a_count) { |
|
172 | + foreach($plugin->get_results() as $action => $a_count) |
|
173 | + { |
|
166 | 174 | $this->message .= "<br />\n" . lang($action) . ": $a_count"; |
167 | 175 | $total_processed += $a_count; |
168 | 176 | } |
169 | - if(count($plugin->get_warnings())) { |
|
177 | + if(count($plugin->get_warnings())) |
|
178 | + { |
|
170 | 179 | $this->message .= "<br />\n".lang('Warnings').':'; |
171 | - foreach($plugin->get_warnings() as $record => $message) { |
|
180 | + foreach($plugin->get_warnings() as $record => $message) |
|
181 | + { |
|
172 | 182 | $this->message .= "\n$record: $message"; |
173 | 183 | } |
174 | 184 | } |
175 | - if(count($plugin->get_errors())) { |
|
185 | + if(count($plugin->get_errors())) |
|
186 | + { |
|
176 | 187 | $this->message .= "<br />\n".lang('Problems during import:'); |
177 | - foreach($plugin->get_errors() as $record => $message) { |
|
188 | + foreach($plugin->get_errors() as $record => $message) |
|
189 | + { |
|
178 | 190 | $this->message .= "<br />\n$record: $message"; |
179 | 191 | } |
180 | - if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported'); |
|
192 | + if($count != $total_processed) |
|
193 | + { |
|
194 | + $this->message .= "<br />\n".lang('Some records may not have been imported'); |
|
195 | + } |
|
181 | 196 | } |
182 | - if ($dst_file && $content['file']['tmp_name'] == $dst_file) { |
|
197 | + if ($dst_file && $content['file']['tmp_name'] == $dst_file) |
|
198 | + { |
|
183 | 199 | // Remove file |
184 | 200 | $cachefile->delete(Api\Cache::keys(Api\Cache::INSTANCE, 'importexport', |
185 | 201 | 'import_'.md5($content['file']['name'].$GLOBALS['egw_info']['user']['account_id']))); |
186 | 202 | unset($dst_file); |
187 | 203 | } |
188 | 204 | |
189 | - } catch (Exception $e) { |
|
205 | + } |
|
206 | + catch (Exception $e) { |
|
190 | 207 | $this->message .= $e->getMessage(); |
191 | 208 | } |
192 | 209 | } |
@@ -218,7 +235,10 @@ discard block |
||
218 | 235 | $data['message'] = $this->message; |
219 | 236 | Framework::includeJS('.','importexport','importexport'); |
220 | 237 | |
221 | - if($_GET['appname']) $readonlys['appname'] = true; |
|
238 | + if($_GET['appname']) |
|
239 | + { |
|
240 | + $readonlys['appname'] = true; |
|
241 | + } |
|
222 | 242 | |
223 | 243 | $template->exec('importexport.importexport_import_ui.import_dialog', $data, $sel_options, $readonlys, $preserve, 2); |
224 | 244 | } |
@@ -226,7 +246,8 @@ discard block |
||
226 | 246 | /** |
227 | 247 | * Get options for select boxes |
228 | 248 | */ |
229 | - public static function get_select_options(Array $data) { |
|
249 | + public static function get_select_options(Array $data) |
|
250 | + { |
|
230 | 251 | $options = array( |
231 | 252 | 'delimiter' => array( |
232 | 253 | '' => lang('From definition'), |
@@ -242,17 +263,20 @@ discard block |
||
242 | 263 | (array)$apps = importexport_helper_functions::get_apps('import'); |
243 | 264 | $options['appname'] = array('' => lang('Select one')) + array_combine($apps,$apps); |
244 | 265 | |
245 | - if($data['appname']) { |
|
266 | + if($data['appname']) |
|
267 | + { |
|
246 | 268 | $options['definition'] = array(); |
247 | 269 | |
248 | - if($data['file'] && !is_array($data['file'])) { |
|
270 | + if($data['file'] && !is_array($data['file'])) |
|
271 | + { |
|
249 | 272 | $extension = substr($data['file'], -3); |
250 | 273 | } |
251 | 274 | $definitions = new importexport_definitions_bo(array( |
252 | 275 | 'type' => 'import', |
253 | 276 | 'application' => $data['appname'] |
254 | 277 | )); |
255 | - foreach ((array)$definitions->get_definitions() as $identifier) { |
|
278 | + foreach ((array)$definitions->get_definitions() as $identifier) |
|
279 | + { |
|
256 | 280 | try |
257 | 281 | { |
258 | 282 | $definition = new importexport_definition($identifier); |
@@ -262,7 +286,8 @@ discard block |
||
262 | 286 | // Permission error |
263 | 287 | continue; |
264 | 288 | } |
265 | - if ($title = $definition->get_title()) { |
|
289 | + if ($title = $definition->get_title()) |
|
290 | + { |
|
266 | 291 | $options['definition'][$title] = $title; |
267 | 292 | } |
268 | 293 | unset($definition); |
@@ -276,12 +301,15 @@ discard block |
||
276 | 301 | /** |
277 | 302 | * Get definitions via ajax |
278 | 303 | */ |
279 | - public function ajax_get_definitions($appname, $file=null) { |
|
304 | + public function ajax_get_definitions($appname, $file=null) |
|
305 | + { |
|
280 | 306 | $options = self::get_select_options(array('appname'=>$appname, 'file'=>$file)); |
281 | 307 | $response = new xajaxResponse(); |
282 | 308 | $response->addScript("clear_options('exec[definition]');"); |
283 | - if(is_array($options['definition'])) { |
|
284 | - foreach ($options['definition'] as $value => $title) { |
|
309 | + if(is_array($options['definition'])) |
|
310 | + { |
|
311 | + foreach ($options['definition'] as $value => $title) |
|
312 | + { |
|
285 | 313 | $response->addScript("selectbox_add_option('exec[definition]','$title', '$value',false);"); |
286 | 314 | } |
287 | 315 | } |
@@ -317,9 +345,15 @@ discard block |
||
317 | 345 | for($row = 0; $row < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; $row++) |
318 | 346 | { |
319 | 347 | $row_data = $import_csv->get_record(); |
320 | - if($row_data === false) break; |
|
348 | + if($row_data === false) |
|
349 | + { |
|
350 | + break; |
|
351 | + } |
|
321 | 352 | $rows[$import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines'] ? 'h1' : $row] = $row_data; |
322 | - if($import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines']) $row--; |
|
353 | + if($import_csv->get_current_position() <= $definition_obj->plugin_options['num_header_lines']) |
|
354 | + { |
|
355 | + $row--; |
|
356 | + } |
|
323 | 357 | } |
324 | 358 | $preview = Api\Html::table($rows); |
325 | 359 | rewind($stream); |
@@ -328,19 +362,26 @@ discard block |
||
328 | 362 | { |
329 | 363 | $preview = lang('Preview not supported by %1', $plugin->get_name()); |
330 | 364 | } |
331 | - if(count($plugin->get_warnings())) { |
|
365 | + if(count($plugin->get_warnings())) |
|
366 | + { |
|
332 | 367 | $this->message .= "<br />\n".lang('Warnings').':'; |
333 | - foreach($plugin->get_warnings() as $record => $message) { |
|
368 | + foreach($plugin->get_warnings() as $record => $message) |
|
369 | + { |
|
334 | 370 | $this->message .= "\n$record: $message"; |
335 | 371 | } |
336 | 372 | $this->message .= "<br />\n"; |
337 | 373 | }; |
338 | - if(count($plugin->get_errors())) { |
|
374 | + if(count($plugin->get_errors())) |
|
375 | + { |
|
339 | 376 | $this->message .= "<br />\n".lang('Problems during import:'); |
340 | - foreach($plugin->get_errors() as $record => $message) { |
|
377 | + foreach($plugin->get_errors() as $record => $message) |
|
378 | + { |
|
341 | 379 | $this->message .= "<br />\n$record: $message"; |
342 | 380 | } |
343 | - if($count != $total_processed) $this->message .= "<br />\n".lang('Some records may not have been imported'); |
|
381 | + if($count != $total_processed) |
|
382 | + { |
|
383 | + $this->message .= "<br />\n".lang('Some records may not have been imported'); |
|
384 | + } |
|
344 | 385 | $this->message .= "<br />\n"; |
345 | 386 | } |
346 | 387 | return '<div class="header">' . lang('Preview') . ' - ' . $plugin->get_name() . '</div>' . $preview; |
@@ -365,10 +406,16 @@ discard block |
||
365 | 406 | $message_count = count($message); |
366 | 407 | |
367 | 408 | // Only CSV files |
368 | - if(!$options['csv_fields']) return true; |
|
409 | + if(!$options['csv_fields']) |
|
410 | + { |
|
411 | + return true; |
|
412 | + } |
|
369 | 413 | |
370 | 414 | // Can't check if definition has no header |
371 | - if($options['num_header_lines'] == 0) return true; |
|
415 | + if($options['num_header_lines'] == 0) |
|
416 | + { |
|
417 | + return true; |
|
418 | + } |
|
372 | 419 | |
373 | 420 | $preference = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
374 | 421 | $charset = $options['charset'] == 'user' || !$options['charset'] ? $preference : $options['charset']; |
@@ -412,8 +459,7 @@ discard block |
||
412 | 459 | if($lang_defn == $lang_file || |
413 | 460 | $lang_defn == mb_strtoupper($header) || |
414 | 461 | $lang_file == mb_strtoupper($options['csv_fields'][$index]) |
415 | - ) |
|
416 | - { |
|
462 | + ) { |
|
417 | 463 | continue; |
418 | 464 | } |
419 | 465 |
@@ -226,7 +226,7 @@ |
||
226 | 226 | /** |
227 | 227 | * Get options for select boxes |
228 | 228 | */ |
229 | - public static function get_select_options(Array $data) { |
|
229 | + public static function get_select_options(array $data) { |
|
230 | 230 | $options = array( |
231 | 231 | 'delimiter' => array( |
232 | 232 | '' => lang('From definition'), |
@@ -1226,7 +1226,7 @@ discard block |
||
1226 | 1226 | * Is called as hook to participate in the linking |
1227 | 1227 | * |
1228 | 1228 | * @param int|array $info int info_id or array with infolog entry |
1229 | - * @return string|boolean string with the title, null if $info not found, false if no perms to view |
|
1229 | + * @return string string with the title, null if $info not found, false if no perms to view |
|
1230 | 1230 | */ |
1231 | 1231 | function link_title($info) |
1232 | 1232 | { |
@@ -1324,9 +1324,6 @@ discard block |
||
1324 | 1324 | /** |
1325 | 1325 | * hook called be calendar to include events or todos in the cal-dayview |
1326 | 1326 | * |
1327 | - * @param int $args[year], $args[month], $args[day] date of the events |
|
1328 | - * @param int $args[owner] owner of the events |
|
1329 | - * @param string $args[location] calendar_include_{events|todos} |
|
1330 | 1327 | * @return array of events (array with keys starttime, endtime, title, view, icon, content) |
1331 | 1328 | */ |
1332 | 1329 | function cal_to_include($args) |
@@ -1515,7 +1512,7 @@ discard block |
||
1515 | 1512 | * Get names for categories specified by their id's |
1516 | 1513 | * |
1517 | 1514 | * @param array|string $cat_id_list array or comma-sparated list of id's |
1518 | - * @return array with names |
|
1515 | + * @return string|boolean with names |
|
1519 | 1516 | */ |
1520 | 1517 | function get_categories($cat_id_list) |
1521 | 1518 | { |
@@ -701,20 +701,20 @@ discard block |
||
701 | 701 | } |
702 | 702 | |
703 | 703 | /** |
704 | - * writes the given $values to InfoLog, a new entry gets created if info_id is not set or 0 |
|
705 | - * |
|
706 | - * checks and asures ACL |
|
707 | - * |
|
708 | - * @param array &$values values to write |
|
709 | - * @param boolean $check_defaults = true check and set certain defaults |
|
710 | - * @param boolean|int $touch_modified = true touch the modification date and sets the modifier's user-id, 2: only modifier |
|
711 | - * @param boolean $user2server = true conversion between user- and server-time necessary |
|
712 | - * @param boolean $skip_notification = false true = do NOT send notification, false (default) = send notifications |
|
713 | - * @param boolean $throw_exception = false Throw an exception (if required fields are not set) |
|
714 | - * @param string $purge_cfs = null null=dont, 'ical'=only iCal X-properties (cfs name starting with "#"), 'all'=all cfs |
|
715 | - * |
|
716 | - * @return int|boolean info_id on a successfull write or false |
|
717 | - */ |
|
704 | + * writes the given $values to InfoLog, a new entry gets created if info_id is not set or 0 |
|
705 | + * |
|
706 | + * checks and asures ACL |
|
707 | + * |
|
708 | + * @param array &$values values to write |
|
709 | + * @param boolean $check_defaults = true check and set certain defaults |
|
710 | + * @param boolean|int $touch_modified = true touch the modification date and sets the modifier's user-id, 2: only modifier |
|
711 | + * @param boolean $user2server = true conversion between user- and server-time necessary |
|
712 | + * @param boolean $skip_notification = false true = do NOT send notification, false (default) = send notifications |
|
713 | + * @param boolean $throw_exception = false Throw an exception (if required fields are not set) |
|
714 | + * @param string $purge_cfs = null null=dont, 'ical'=only iCal X-properties (cfs name starting with "#"), 'all'=all cfs |
|
715 | + * |
|
716 | + * @return int|boolean info_id on a successfull write or false |
|
717 | + */ |
|
718 | 718 | function write(&$values_in, $check_defaults=true, $touch_modified=true, $user2server=true, |
719 | 719 | $skip_notification=false, $throw_exception=false, $purge_cfs=null) |
720 | 720 | { |
@@ -751,7 +751,7 @@ discard block |
||
751 | 751 | } |
752 | 752 | } |
753 | 753 | if ($values['info_id'] && !$this->check_access($values['info_id'],Acl::EDIT) && !$status_only || |
754 | - !$values['info_id'] && $values['info_id_parent'] && !$this->check_access($values['info_id_parent'],Acl::ADD)) |
|
754 | + !$values['info_id'] && $values['info_id_parent'] && !$this->check_access($values['info_id_parent'],Acl::ADD)) |
|
755 | 755 | { |
756 | 756 | return false; |
757 | 757 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | var $total; |
42 | 42 | var $vfs; |
43 | - var $vfs_basedir='/infolog'; |
|
43 | + var $vfs_basedir = '/infolog'; |
|
44 | 44 | /** |
45 | 45 | * Set Logging |
46 | 46 | * |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @var array |
67 | 67 | */ |
68 | - var $timestamps = array('info_startdate','info_enddate','info_datemodified','info_datecompleted','info_created'); |
|
68 | + var $timestamps = array('info_startdate', 'info_enddate', 'info_datemodified', 'info_datecompleted', 'info_created'); |
|
69 | 69 | /** |
70 | 70 | * fields the responsible user can change |
71 | 71 | * |
72 | 72 | * @var array |
73 | 73 | */ |
74 | - var $responsible_edit=array('info_status','info_percent','info_datecompleted'); |
|
74 | + var $responsible_edit = array('info_status', 'info_percent', 'info_datecompleted'); |
|
75 | 75 | /** |
76 | 76 | * Fields to exclude from copy, if an entry is copied, the ones below are excluded by default. |
77 | 77 | * |
@@ -95,19 +95,19 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @var string |
97 | 97 | */ |
98 | - var $implicit_rights='read'; |
|
98 | + var $implicit_rights = 'read'; |
|
99 | 99 | /** |
100 | 100 | * Custom fields read from the infolog config |
101 | 101 | * |
102 | 102 | * @var array |
103 | 103 | */ |
104 | - var $customfields=array(); |
|
104 | + var $customfields = array(); |
|
105 | 105 | /** |
106 | 106 | * Group owners for certain types read from the infolog config |
107 | 107 | * |
108 | 108 | * @var array |
109 | 109 | */ |
110 | - var $group_owners=array(); |
|
110 | + var $group_owners = array(); |
|
111 | 111 | /** |
112 | 112 | * Current user |
113 | 113 | * |
@@ -174,55 +174,55 @@ discard block |
||
174 | 174 | function __construct($info_id = 0) |
175 | 175 | { |
176 | 176 | $this->enums = $this->stock_enums = array( |
177 | - 'priority' => array ( |
|
177 | + 'priority' => array( |
|
178 | 178 | 3 => 'urgent', |
179 | 179 | 2 => 'high', |
180 | 180 | 1 => 'normal', |
181 | 181 | 0 => 'low' |
182 | 182 | ), |
183 | 183 | 'confirm' => array( |
184 | - 'not' => 'not','accept' => 'accept','finish' => 'finish', |
|
184 | + 'not' => 'not', 'accept' => 'accept', 'finish' => 'finish', |
|
185 | 185 | 'both' => 'both' ), |
186 | 186 | 'type' => array( |
187 | - 'task' => 'task','phone' => 'phone','note' => 'note','email' => 'email' |
|
187 | + 'task' => 'task', 'phone' => 'phone', 'note' => 'note', 'email' => 'email' |
|
188 | 188 | /* ,'confirm' => 'confirm','reject' => 'reject','fax' => 'fax' not implemented so far */ ) |
189 | 189 | ); |
190 | 190 | $this->status = $this->stock_status = array( |
191 | 191 | 'defaults' => array( |
192 | - 'task' => 'not-started', 'phone' => 'not-started', 'note' => 'done','email' => 'done'), |
|
192 | + 'task' => 'not-started', 'phone' => 'not-started', 'note' => 'done', 'email' => 'done'), |
|
193 | 193 | 'task' => array( |
194 | - 'offer' => 'offer', // --> NEEDS-ACTION |
|
195 | - 'not-started' => 'not-started', // iCal NEEDS-ACTION |
|
196 | - 'ongoing' => 'ongoing', // iCal IN-PROCESS |
|
197 | - 'done' => 'done', // iCal COMPLETED |
|
198 | - 'cancelled' => 'cancelled', // iCal CANCELLED |
|
199 | - 'billed' => 'billed', // --> DONE |
|
200 | - 'template' => 'template', // --> cancelled |
|
201 | - 'nonactive' => 'nonactive', // --> cancelled |
|
202 | - 'archive' => 'archive' ), // --> cancelled |
|
194 | + 'offer' => 'offer', // --> NEEDS-ACTION |
|
195 | + 'not-started' => 'not-started', // iCal NEEDS-ACTION |
|
196 | + 'ongoing' => 'ongoing', // iCal IN-PROCESS |
|
197 | + 'done' => 'done', // iCal COMPLETED |
|
198 | + 'cancelled' => 'cancelled', // iCal CANCELLED |
|
199 | + 'billed' => 'billed', // --> DONE |
|
200 | + 'template' => 'template', // --> cancelled |
|
201 | + 'nonactive' => 'nonactive', // --> cancelled |
|
202 | + 'archive' => 'archive' ), // --> cancelled |
|
203 | 203 | 'phone' => array( |
204 | - 'not-started' => 'call', // iCal NEEDS-ACTION |
|
205 | - 'ongoing' => 'will-call', // iCal IN-PROCESS |
|
206 | - 'done' => 'done', // iCal COMPLETED |
|
207 | - 'billed' => 'billed' ), // --> DONE |
|
204 | + 'not-started' => 'call', // iCal NEEDS-ACTION |
|
205 | + 'ongoing' => 'will-call', // iCal IN-PROCESS |
|
206 | + 'done' => 'done', // iCal COMPLETED |
|
207 | + 'billed' => 'billed' ), // --> DONE |
|
208 | 208 | 'note' => array( |
209 | - 'ongoing' => 'ongoing', // iCal has no status on notes |
|
209 | + 'ongoing' => 'ongoing', // iCal has no status on notes |
|
210 | 210 | 'done' => 'done' ), |
211 | 211 | 'email' => array( |
212 | - 'ongoing' => 'ongoing', // iCal has no status on notes |
|
212 | + 'ongoing' => 'ongoing', // iCal has no status on notes |
|
213 | 213 | 'done' => 'done' ), |
214 | 214 | ); |
215 | 215 | if (($config_data = Api\Config::read('infolog'))) |
216 | 216 | { |
217 | 217 | if (isset($config_data['status']) && is_array($config_data['status'])) |
218 | 218 | { |
219 | - foreach(array_keys($config_data['status']) as $key) |
|
219 | + foreach (array_keys($config_data['status']) as $key) |
|
220 | 220 | { |
221 | 221 | if (!is_array($this->status[$key])) |
222 | 222 | { |
223 | 223 | $this->status[$key] = array(); |
224 | 224 | } |
225 | - $this->status[$key] = array_merge($this->status[$key],(array)$config_data['status'][$key]); |
|
225 | + $this->status[$key] = array_merge($this->status[$key], (array)$config_data['status'][$key]); |
|
226 | 226 | } |
227 | 227 | } |
228 | 228 | if (isset($config_data['types']) && is_array($config_data['types'])) |
@@ -237,10 +237,10 @@ discard block |
||
237 | 237 | $this->customfields = Api\Storage\Customfields::get('infolog'); |
238 | 238 | if ($this->customfields) |
239 | 239 | { |
240 | - foreach($this->customfields as $name => $field) |
|
240 | + foreach ($this->customfields as $name => $field) |
|
241 | 241 | { |
242 | 242 | // old infolog customefield record |
243 | - if(empty($field['type'])) |
|
243 | + if (empty($field['type'])) |
|
244 | 244 | { |
245 | 245 | if (count($field['values'])) $field['type'] = 'select'; // selectbox |
246 | 246 | elseif ($field['rows'] > 1) $field['type'] = 'textarea'; // textarea |
@@ -252,23 +252,23 @@ discard block |
||
252 | 252 | $save_config = true; |
253 | 253 | } |
254 | 254 | } |
255 | - if ($save_config) Api\Config::save_value('customfields',$this->customfields,'infolog'); |
|
255 | + if ($save_config) Api\Config::save_value('customfields', $this->customfields, 'infolog'); |
|
256 | 256 | } |
257 | 257 | if (is_array($config_data['responsible_edit'])) |
258 | 258 | { |
259 | - $this->responsible_edit = array_merge($this->responsible_edit,$config_data['responsible_edit']); |
|
259 | + $this->responsible_edit = array_merge($this->responsible_edit, $config_data['responsible_edit']); |
|
260 | 260 | } |
261 | 261 | if (is_array($config_data['copy_excludefields'])) |
262 | 262 | { |
263 | - $this->copy_excludefields = array_merge($this->copy_excludefields,$config_data['copy_excludefields']); |
|
263 | + $this->copy_excludefields = array_merge($this->copy_excludefields, $config_data['copy_excludefields']); |
|
264 | 264 | } |
265 | 265 | if (is_array($config_data['sub_excludefields']) && $config_data['sub_excludefields']) |
266 | 266 | { |
267 | - $this->sub_excludefields = array_merge($this->sub_excludefields,$config_data['sub_excludefields']); |
|
267 | + $this->sub_excludefields = array_merge($this->sub_excludefields, $config_data['sub_excludefields']); |
|
268 | 268 | } |
269 | 269 | else |
270 | 270 | { |
271 | - $this->sub_excludefields = array_merge($this->sub_excludefields,$this->default_sub_excludefields); |
|
271 | + $this->sub_excludefields = array_merge($this->sub_excludefields, $this->default_sub_excludefields); |
|
272 | 272 | } |
273 | 273 | if ($config_data['implicit_rights'] == 'edit') |
274 | 274 | { |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | $this->history = $config_data['history']; |
278 | 278 | } |
279 | 279 | // sort types by there translation |
280 | - foreach($this->enums['type'] as $key => $val) |
|
280 | + foreach ($this->enums['type'] as $key => $val) |
|
281 | 281 | { |
282 | 282 | if (($val = lang($key)) != $key.'*') $this->enums['type'][$key] = lang($key); |
283 | 283 | } |
@@ -286,14 +286,14 @@ discard block |
||
286 | 286 | $this->user = $GLOBALS['egw_info']['user']['account_id']; |
287 | 287 | |
288 | 288 | $this->now = time(); |
289 | - $this->user_time_now = Api\DateTime::server2user($this->now,'ts'); |
|
289 | + $this->user_time_now = Api\DateTime::server2user($this->now, 'ts'); |
|
290 | 290 | |
291 | - $this->grants = $GLOBALS['egw']->acl->get_grants('infolog',$this->group_owners ? $this->group_owners : true); |
|
291 | + $this->grants = $GLOBALS['egw']->acl->get_grants('infolog', $this->group_owners ? $this->group_owners : true); |
|
292 | 292 | $this->so = new infolog_so($this->grants); |
293 | 293 | |
294 | 294 | if ($info_id) |
295 | 295 | { |
296 | - $this->read( $info_id ); |
|
296 | + $this->read($info_id); |
|
297 | 297 | } |
298 | 298 | else |
299 | 299 | { |
@@ -309,9 +309,9 @@ discard block |
||
309 | 309 | */ |
310 | 310 | function has_customfields($type) |
311 | 311 | { |
312 | - foreach($this->customfields as $field) |
|
312 | + foreach ($this->customfields as $field) |
|
313 | 313 | { |
314 | - if ((!$type || empty($field['type2']) || in_array($type,is_array($field['type2']) ? $field['type2'] : explode(',',$field['type2'])))) |
|
314 | + if ((!$type || empty($field['type2']) || in_array($type, is_array($field['type2']) ? $field['type2'] : explode(',', $field['type2'])))) |
|
315 | 315 | { |
316 | 316 | return True; |
317 | 317 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * @param int $user = null user whos rights to check, default current user |
329 | 329 | * @return boolean |
330 | 330 | */ |
331 | - function check_access($info,$required_rights,$other=0,$user=null) |
|
331 | + function check_access($info, $required_rights, $other = 0, $user = null) |
|
332 | 332 | { |
333 | 333 | static $cache = array(); |
334 | 334 | |
@@ -338,17 +338,17 @@ discard block |
||
338 | 338 | if ($user == $this->user) |
339 | 339 | { |
340 | 340 | $grants = $this->grants; |
341 | - if ($info_id) $access =& $cache[$info_id][$required_rights]; // we only cache the current user! |
|
341 | + if ($info_id) $access = & $cache[$info_id][$required_rights]; // we only cache the current user! |
|
342 | 342 | } |
343 | 343 | else |
344 | 344 | { |
345 | - $grants = $GLOBALS['egw']->acl->get_grants('infolog',$this->group_owners ? $this->group_owners : true,$user); |
|
345 | + $grants = $GLOBALS['egw']->acl->get_grants('infolog', $this->group_owners ? $this->group_owners : true, $user); |
|
346 | 346 | } |
347 | 347 | if (!$info) |
348 | 348 | { |
349 | 349 | $owner = $other ? $other : $user; |
350 | 350 | $grant = $grants[$owner]; |
351 | - return $grant & $required_rights; |
|
351 | + return $grant&$required_rights; |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | |
@@ -360,10 +360,10 @@ discard block |
||
360 | 360 | if (!is_array($info) && !($info = $this->so->read(array('info_id' => $info_id)))) return false; |
361 | 361 | |
362 | 362 | if ($info['info_status'] == 'deleted' && |
363 | - ($required_rights == Acl::EDIT || // no edit rights for deleted entries |
|
364 | - $required_rights == Acl::ADD || // no add rights for deleted entries |
|
363 | + ($required_rights == Acl::EDIT || // no edit rights for deleted entries |
|
364 | + $required_rights == Acl::ADD || // no add rights for deleted entries |
|
365 | 365 | $required_rights == Acl::DELETE && ($this->history == 'history_no_delete' || // no delete at all! |
366 | - $this->history == 'history_admin_delete' && (!isset($GLOBALS['egw_info']['user']['apps']['admin']) || $user!=$this->user)))) // delete only for admins |
|
366 | + $this->history == 'history_admin_delete' && (!isset($GLOBALS['egw_info']['user']['apps']['admin']) || $user != $this->user)))) // delete only for admins |
|
367 | 367 | { |
368 | 368 | $access = false; |
369 | 369 | } |
@@ -371,12 +371,12 @@ discard block |
||
371 | 371 | { |
372 | 372 | if ($info['info_status'] != 'deleted') |
373 | 373 | { |
374 | - $access = false; // can only undelete deleted items |
|
374 | + $access = false; // can only undelete deleted items |
|
375 | 375 | } |
376 | 376 | else |
377 | 377 | { |
378 | 378 | // undelete requires edit rights |
379 | - $access = $this->so->check_access( $info,Acl::EDIT,$this->implicit_rights == 'edit',$grants,$user ); |
|
379 | + $access = $this->so->check_access($info, Acl::EDIT, $this->implicit_rights == 'edit', $grants, $user); |
|
380 | 380 | } |
381 | 381 | } |
382 | 382 | } |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | } |
387 | 387 | if (!isset($access)) |
388 | 388 | { |
389 | - $access = $this->so->check_access( $info,$required_rights,$this->implicit_rights == 'edit',$grants,$user ); |
|
389 | + $access = $this->so->check_access($info, $required_rights, $this->implicit_rights == 'edit', $grants, $user); |
|
390 | 390 | } |
391 | 391 | } |
392 | 392 | // else $cached = ' (from cache)'; |
@@ -421,12 +421,12 @@ discard block |
||
421 | 421 | * @param string $not_id = '' id to exclude |
422 | 422 | * @return boolean True if we have a linked item, False otherwise |
423 | 423 | */ |
424 | - function link_id2from(&$info,$not_app='',$not_id='') |
|
424 | + function link_id2from(&$info, $not_app = '', $not_id = '') |
|
425 | 425 | { |
426 | 426 | //echo "<p>boinfolog::link_id2from(subject='$info[info_subject]', link_id='$info[info_link_id]', from='$info[info_from]', not_app='$not_app', not_id='$not_id')"; |
427 | 427 | |
428 | 428 | if ($info['info_link_id'] > 0 && |
429 | - (isset($info['links']) && ($link = $info['links'][$info['info_link_id']]) || // use supplied links info |
|
429 | + (isset($info['links']) && ($link = $info['links'][$info['info_link_id']]) || // use supplied links info |
|
430 | 430 | ($link = Link::get_link($info['info_link_id'])) !== False)) // if link not found in supplied links, we always search! |
431 | 431 | { |
432 | 432 | if (isset($info['links']) && isset($link['app'])) |
@@ -440,11 +440,11 @@ discard block |
||
440 | 440 | $app = $link['link_app'.$nr]; |
441 | 441 | $id = $link['link_id'.$nr]; |
442 | 442 | } |
443 | - $title = Link::title($app,$id); |
|
443 | + $title = Link::title($app, $id); |
|
444 | 444 | |
445 | 445 | if ((string)$info['info_custom_from'] === '') // old entry |
446 | 446 | { |
447 | - $info['info_custom_from'] = (int) ($title != $info['info_from'] && @htmlentities($title) != $info['info_from']); |
|
447 | + $info['info_custom_from'] = (int)($title != $info['info_from'] && @htmlentities($title) != $info['info_from']); |
|
448 | 448 | } |
449 | 449 | if (!$info['info_custom_from']) |
450 | 450 | { |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | return $info['blur_title'] = $title; |
467 | 467 | } |
468 | 468 | $info['info_link'] = array('title' => $info['info_from']); |
469 | - $info['info_link_id'] = 0; // link might have been deleted |
|
469 | + $info['info_link_id'] = 0; // link might have been deleted |
|
470 | 470 | $info['info_custom_from'] = (int)!!$info['info_from']; |
471 | 471 | |
472 | 472 | return False; |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | */ |
478 | 478 | static function subject_from_des($des) |
479 | 479 | { |
480 | - return substr($des,0,60).' ...'; |
|
480 | + return substr($des, 0, 60).' ...'; |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | /** |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | * or NULL for timestamps in user-time |
493 | 493 | * or false for timestamps in server-time |
494 | 494 | */ |
495 | - function time2time(&$values, $fromTZId=false, $toTZId=null) |
|
495 | + function time2time(&$values, $fromTZId = false, $toTZId = null) |
|
496 | 496 | { |
497 | 497 | |
498 | 498 | if ($fromTZId === $toTZId) return; |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | $toTZ = Api\DateTime::$server_timezone; |
534 | 534 | } |
535 | 535 | //error_log(__METHOD__.'(values[info_enddate]='.date('Y-m-d H:i:s',$values['info_enddate']).", from=".array2string($fromTZId).", to=".array2string($toTZId).") tz=".$tz->getName().', fromTZ='.$fromTZ->getName().', toTZ='.$toTZ->getName().', userTZ='.Api\DateTime::$user_timezone->getName()); |
536 | - foreach($this->timestamps as $key) |
|
536 | + foreach ($this->timestamps as $key) |
|
537 | 537 | { |
538 | 538 | if ($values[$key]) |
539 | 539 | { |
@@ -542,14 +542,14 @@ discard block |
||
542 | 542 | if ($time->format('Hi') == '0000') |
543 | 543 | { |
544 | 544 | // we keep dates the same in new timezone |
545 | - $arr = Api\DateTime::to($time,'array'); |
|
545 | + $arr = Api\DateTime::to($time, 'array'); |
|
546 | 546 | $time = new Api\DateTime($arr, $toTZ); |
547 | 547 | } |
548 | 548 | else |
549 | 549 | { |
550 | 550 | $time->setTimezone($toTZ); |
551 | 551 | } |
552 | - $values[$key] = Api\DateTime::to($time,'ts'); |
|
552 | + $values[$key] = Api\DateTime::to($time, 'ts'); |
|
553 | 553 | } |
554 | 554 | } |
555 | 555 | //error_log(__METHOD__.'() --> values[info_enddate]='.date('Y-m-d H:i:s',$values['info_enddate'])); |
@@ -562,11 +562,11 @@ discard block |
||
562 | 562 | * @param string $date_format = 'ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format |
563 | 563 | * @return mixed depending of $date_format |
564 | 564 | */ |
565 | - function date2usertime($ts,$date_format='ts') |
|
565 | + function date2usertime($ts, $date_format = 'ts') |
|
566 | 566 | { |
567 | 567 | if (empty($ts) || $date_format == 'server') return $ts; |
568 | 568 | |
569 | - return Api\DateTime::server2user($ts,$date_format); |
|
569 | + return Api\DateTime::server2user($ts, $date_format); |
|
570 | 570 | } |
571 | 571 | |
572 | 572 | /** |
@@ -581,10 +581,10 @@ discard block |
||
581 | 581 | * |
582 | 582 | * @return array|boolean infolog entry, null if not found or false if no permission to read it |
583 | 583 | */ |
584 | - function &read($info_id,$run_link_id2from=true,$date_format='ts',$ignore_acl=false) |
|
584 | + function &read($info_id, $run_link_id2from = true, $date_format = 'ts', $ignore_acl = false) |
|
585 | 585 | { |
586 | 586 | //error_log(__METHOD__.'('.array2string($info_id).', '.array2string($run_link_id2from).", '$date_format') ".function_backtrace()); |
587 | - if (is_scalar($info_id) || isset($info_id[count($info_id)-1])) |
|
587 | + if (is_scalar($info_id) || isset($info_id[count($info_id) - 1])) |
|
588 | 588 | { |
589 | 589 | if (is_scalar($info_id) && !is_numeric($info_id)) |
590 | 590 | { |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | return null; |
602 | 602 | } |
603 | 603 | |
604 | - if (!$ignore_acl && !$this->check_access($data,Acl::READ)) // check behind read, to prevent a double read |
|
604 | + if (!$ignore_acl && !$this->check_access($data, Acl::READ)) // check behind read, to prevent a double read |
|
605 | 605 | { |
606 | 606 | return False; |
607 | 607 | } |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | * @param boolean $skip_notification Do not send notification of delete |
634 | 634 | * @return boolean True if delete was successful, False otherwise ($info_id does not exist or no rights) |
635 | 635 | */ |
636 | - function delete($info_id,$delete_children=False,$new_parent=False, $skip_notification=False) |
|
636 | + function delete($info_id, $delete_children = False, $new_parent = False, $skip_notification = False) |
|
637 | 637 | { |
638 | 638 | if (is_array($info_id)) |
639 | 639 | { |
@@ -643,18 +643,18 @@ discard block |
||
643 | 643 | { |
644 | 644 | return False; |
645 | 645 | } |
646 | - if (!$this->check_access($info,Acl::DELETE)) |
|
646 | + if (!$this->check_access($info, Acl::DELETE)) |
|
647 | 647 | { |
648 | 648 | return False; |
649 | 649 | } |
650 | 650 | // check if we have children and delete or re-parent them |
651 | 651 | if (($children = $this->so->get_children($info_id))) |
652 | 652 | { |
653 | - foreach($children as $id => $owner) |
|
653 | + foreach ($children as $id => $owner) |
|
654 | 654 | { |
655 | - if ($delete_children && $this->so->grants[$owner] & Acl::DELETE) |
|
655 | + if ($delete_children && $this->so->grants[$owner]&Acl::DELETE) |
|
656 | 656 | { |
657 | - $this->delete($id,$delete_children,$new_parent,$skip_notification); // call ourself recursive to delete the child |
|
657 | + $this->delete($id, $delete_children, $new_parent, $skip_notification); // call ourself recursive to delete the child |
|
658 | 658 | } |
659 | 659 | else // dont delete or no rights to delete the child --> re-parent it |
660 | 660 | { |
@@ -673,28 +673,28 @@ discard block |
||
673 | 673 | // if we have history switched on and not an already deleted item --> set only status deleted |
674 | 674 | if ($this->history && $info['info_status'] != 'deleted') |
675 | 675 | { |
676 | - if ($info['info_status'] == 'deleted') return false; // entry already deleted |
|
676 | + if ($info['info_status'] == 'deleted') return false; // entry already deleted |
|
677 | 677 | |
678 | 678 | $this->so->write($deleted); |
679 | 679 | |
680 | - Link::unlink(0,'infolog',$info_id,'','!file','',true); // keep the file attachments, hide the rest |
|
680 | + Link::unlink(0, 'infolog', $info_id, '', '!file', '', true); // keep the file attachments, hide the rest |
|
681 | 681 | } |
682 | 682 | else |
683 | 683 | { |
684 | - $this->so->delete($info_id,false); // we delete the children via bo to get all notifications! |
|
684 | + $this->so->delete($info_id, false); // we delete the children via bo to get all notifications! |
|
685 | 685 | |
686 | - Link::unlink(0,'infolog',$info_id); |
|
686 | + Link::unlink(0, 'infolog', $info_id); |
|
687 | 687 | } |
688 | 688 | if ($info['info_status'] != 'deleted') // dont notify of final purge of already deleted items |
689 | 689 | { |
690 | 690 | // send email notifications and do the history logging |
691 | - if(!$skip_notification) |
|
691 | + if (!$skip_notification) |
|
692 | 692 | { |
693 | 693 | if (!is_object($this->tracking)) |
694 | 694 | { |
695 | 695 | $this->tracking = new infolog_tracking($this); |
696 | 696 | } |
697 | - $this->tracking->track($deleted,$info,$this->user,true); |
|
697 | + $this->tracking->track($deleted, $info, $this->user, true); |
|
698 | 698 | } |
699 | 699 | } |
700 | 700 | return True; |
@@ -715,13 +715,13 @@ discard block |
||
715 | 715 | * |
716 | 716 | * @return int|boolean info_id on a successfull write or false |
717 | 717 | */ |
718 | - function write(&$values_in, $check_defaults=true, $touch_modified=true, $user2server=true, |
|
719 | - $skip_notification=false, $throw_exception=false, $purge_cfs=null) |
|
718 | + function write(&$values_in, $check_defaults = true, $touch_modified = true, $user2server = true, |
|
719 | + $skip_notification = false, $throw_exception = false, $purge_cfs = null) |
|
720 | 720 | { |
721 | 721 | $values = $values_in; |
722 | 722 | //echo "boinfolog::write()values="; _debug_array($values); |
723 | - if (!$values['info_id'] && !$this->check_access(0,Acl::EDIT,$values['info_owner']) && |
|
724 | - !$this->check_access(0,Acl::ADD,$values['info_owner'])) |
|
723 | + if (!$values['info_id'] && !$this->check_access(0, Acl::EDIT, $values['info_owner']) && |
|
724 | + !$this->check_access(0, Acl::ADD, $values['info_owner'])) |
|
725 | 725 | { |
726 | 726 | return false; |
727 | 727 | } |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | $old = $this->read($values['info_id'], false, 'server'); |
732 | 732 | } |
733 | 733 | |
734 | - if (($status_only = $values['info_id'] && !$this->check_access($values,Acl::EDIT))) |
|
734 | + if (($status_only = $values['info_id'] && !$this->check_access($values, Acl::EDIT))) |
|
735 | 735 | { |
736 | 736 | if (!isset($values['info_responsible'])) |
737 | 737 | { |
@@ -743,31 +743,31 @@ discard block |
||
743 | 743 | } |
744 | 744 | if (!($status_only = in_array($this->user, (array)$responsible))) // responsible has implicit right to change status |
745 | 745 | { |
746 | - $status_only = !!array_intersect((array)$responsible,array_keys($GLOBALS['egw']->accounts->memberships($this->user))); |
|
746 | + $status_only = !!array_intersect((array)$responsible, array_keys($GLOBALS['egw']->accounts->memberships($this->user))); |
|
747 | 747 | } |
748 | 748 | if (!$status_only && $values['info_status'] != 'deleted') |
749 | 749 | { |
750 | - $status_only = $undelete = $this->check_access($values['info_id'],self::ACL_UNDELETE); |
|
750 | + $status_only = $undelete = $this->check_access($values['info_id'], self::ACL_UNDELETE); |
|
751 | 751 | } |
752 | 752 | } |
753 | - if ($values['info_id'] && !$this->check_access($values['info_id'],Acl::EDIT) && !$status_only || |
|
754 | - !$values['info_id'] && $values['info_id_parent'] && !$this->check_access($values['info_id_parent'],Acl::ADD)) |
|
753 | + if ($values['info_id'] && !$this->check_access($values['info_id'], Acl::EDIT) && !$status_only || |
|
754 | + !$values['info_id'] && $values['info_id_parent'] && !$this->check_access($values['info_id_parent'], Acl::ADD)) |
|
755 | 755 | { |
756 | 756 | return false; |
757 | 757 | } |
758 | 758 | |
759 | 759 | // Make sure status is still valid if the type changes |
760 | - if($old['info_type'] != $values['info_type'] && $values['info_status']) |
|
760 | + if ($old['info_type'] != $values['info_type'] && $values['info_status']) |
|
761 | 761 | { |
762 | - if(!in_array($values['info_status'], array_keys($this->status[$values['info_type']]))) |
|
762 | + if (!in_array($values['info_status'], array_keys($this->status[$values['info_type']]))) |
|
763 | 763 | { |
764 | 764 | $values['info_status'] = $this->status['defaults'][$values['info_type']]; |
765 | 765 | } |
766 | 766 | } |
767 | 767 | if ($status_only && !$undelete) // make sure only status gets writen |
768 | 768 | { |
769 | - $set_completed = !$values['info_datecompleted'] && // set date completed of finished job, only if its not already set |
|
770 | - in_array($values['info_status'],array('done','billed','cancelled')); |
|
769 | + $set_completed = !$values['info_datecompleted'] && // set date completed of finished job, only if its not already set |
|
770 | + in_array($values['info_status'], array('done', 'billed', 'cancelled')); |
|
771 | 771 | |
772 | 772 | $values = $old; |
773 | 773 | // only overwrite explicitly allowed fields |
@@ -782,7 +782,7 @@ discard block |
||
782 | 782 | $values['info_percent'] = 100; |
783 | 783 | $forcestatus = true; |
784 | 784 | $status = 'done'; |
785 | - if (isset($values['info_type']) && !in_array($values['info_status'],array('done','billed','cancelled'))) { |
|
785 | + if (isset($values['info_type']) && !in_array($values['info_status'], array('done', 'billed', 'cancelled'))) { |
|
786 | 786 | $forcestatus = false; |
787 | 787 | //echo "set_completed:"; _debug_array($this->status[$values['info_type']]); |
788 | 788 | if (isset($this->status[$values['info_type']]['done'])) { |
@@ -796,19 +796,19 @@ discard block |
||
796 | 796 | $status = 'cancelled'; |
797 | 797 | } |
798 | 798 | } |
799 | - if ($forcestatus && !in_array($values['info_status'],array('done','billed','cancelled'))) $values['info_status'] = $status; |
|
799 | + if ($forcestatus && !in_array($values['info_status'], array('done', 'billed', 'cancelled'))) $values['info_status'] = $status; |
|
800 | 800 | } |
801 | 801 | $check_defaults = false; |
802 | 802 | } |
803 | 803 | if ($check_defaults) |
804 | 804 | { |
805 | 805 | if (!$values['info_datecompleted'] && |
806 | - (in_array($values['info_status'],array('done','billed')))) |
|
806 | + (in_array($values['info_status'], array('done', 'billed')))) |
|
807 | 807 | { |
808 | - $values['info_datecompleted'] = $user2server ? $this->user_time_now : $this->now; // set date completed to today if status == done |
|
808 | + $values['info_datecompleted'] = $user2server ? $this->user_time_now : $this->now; // set date completed to today if status == done |
|
809 | 809 | } |
810 | 810 | // Check for valid status / percent combinations |
811 | - if (in_array($values['info_status'],array('done','billed'))) |
|
811 | + if (in_array($values['info_status'], array('done', 'billed'))) |
|
812 | 812 | { |
813 | 813 | $values['info_percent'] = 100; |
814 | 814 | } |
@@ -823,7 +823,7 @@ discard block |
||
823 | 823 | // We change percent to match status, not status to match percent |
824 | 824 | $values['info_percent'] = 10; |
825 | 825 | } |
826 | - if ((int)$values['info_percent'] == 100 && !in_array($values['info_status'],array('done','billed','cancelled','archive'))) |
|
826 | + if ((int)$values['info_percent'] == 100 && !in_array($values['info_status'], array('done', 'billed', 'cancelled', 'archive'))) |
|
827 | 827 | { |
828 | 828 | //echo "check_defaults:"; _debug_array($this->status[$values['info_type']]); |
829 | 829 | //$values['info_status'] = 'done'; |
@@ -844,7 +844,7 @@ discard block |
||
844 | 844 | } |
845 | 845 | if ($values['info_responsible'] && $values['info_status'] == 'offer') |
846 | 846 | { |
847 | - $values['info_status'] = 'not-started'; // have to match if not finished |
|
847 | + $values['info_status'] = 'not-started'; // have to match if not finished |
|
848 | 848 | } |
849 | 849 | if (isset($values['info_subject']) && empty($values['info_subject'])) |
850 | 850 | { |
@@ -852,18 +852,18 @@ discard block |
||
852 | 852 | } |
853 | 853 | |
854 | 854 | // Check required custom fields |
855 | - if($throw_exception) |
|
855 | + if ($throw_exception) |
|
856 | 856 | { |
857 | 857 | $custom = Api\Storage\Customfields::get('infolog'); |
858 | - foreach($custom as $c_name => $c_field) |
|
858 | + foreach ($custom as $c_name => $c_field) |
|
859 | 859 | { |
860 | - if($c_field['type2']) $type2 = is_array($c_field['type2']) ? $c_field['type2'] : explode(',',$c_field['type2']); |
|
861 | - if($c_field['needed'] && (!$c_field['type2'] || $c_field['type2'] && in_array($values['info_type'],$type2))) |
|
860 | + if ($c_field['type2']) $type2 = is_array($c_field['type2']) ? $c_field['type2'] : explode(',', $c_field['type2']); |
|
861 | + if ($c_field['needed'] && (!$c_field['type2'] || $c_field['type2'] && in_array($values['info_type'], $type2))) |
|
862 | 862 | { |
863 | 863 | // Required custom field |
864 | - if(!$values['#'.$c_name]) |
|
864 | + if (!$values['#'.$c_name]) |
|
865 | 865 | { |
866 | - throw new Api\Exception\WrongUserinput(lang('For infolog type %1, %2 is required',lang($values['info_type']),$c_field['label'])); |
|
866 | + throw new Api\Exception\WrongUserinput(lang('For infolog type %1, %2 is required', lang($values['info_type']), $c_field['label'])); |
|
867 | 867 | } |
868 | 868 | } |
869 | 869 | } |
@@ -872,16 +872,16 @@ discard block |
||
872 | 872 | if (isset($this->group_owners[$values['info_type']])) |
873 | 873 | { |
874 | 874 | $values['info_owner'] = $this->group_owners[$values['info_type']]; |
875 | - if (!($this->grants[$this->group_owners[$values['info_type']]] & Acl::EDIT)) |
|
875 | + if (!($this->grants[$this->group_owners[$values['info_type']]]&Acl::EDIT)) |
|
876 | 876 | { |
877 | - if (!$this->check_access($values['info_id'],Acl::EDIT) || |
|
878 | - !$values['info_id'] && !$this->check_access($values,Acl::ADD) |
|
877 | + if (!$this->check_access($values['info_id'], Acl::EDIT) || |
|
878 | + !$values['info_id'] && !$this->check_access($values, Acl::ADD) |
|
879 | 879 | ) |
880 | 880 | { |
881 | - return false; // no edit rights from the group-owner and no implicit rights (delegated and sufficient rights) |
|
881 | + return false; // no edit rights from the group-owner and no implicit rights (delegated and sufficient rights) |
|
882 | 882 | } |
883 | 883 | } |
884 | - $values['info_access'] = 'public'; // group-owners are allways public |
|
884 | + $values['info_access'] = 'public'; // group-owners are allways public |
|
885 | 885 | } |
886 | 886 | elseif (!$values['info_id'] && !$values['info_owner'] || $GLOBALS['egw']->accounts->get_type($values['info_owner']) == 'g') |
887 | 887 | { |
@@ -941,23 +941,23 @@ discard block |
||
941 | 941 | $to_write['info_id'] = $info_id; |
942 | 942 | |
943 | 943 | // if the info responbsible array is not passed, fetch it from old. |
944 | - if (!array_key_exists('info_responsible',$values)) $values['info_responsible'] = $old['info_responsible']; |
|
944 | + if (!array_key_exists('info_responsible', $values)) $values['info_responsible'] = $old['info_responsible']; |
|
945 | 945 | if (!is_array($values['info_responsible'])) // this should not happen, bug it does ;-) |
946 | 946 | { |
947 | - $values['info_responsible'] = $values['info_responsible'] ? explode(',',$values['info_responsible']) : array(); |
|
947 | + $values['info_responsible'] = $values['info_responsible'] ? explode(',', $values['info_responsible']) : array(); |
|
948 | 948 | $to_write['info_responsible'] = $values['info_responsible']; |
949 | 949 | } |
950 | 950 | // create (and remove) links in custom fields |
951 | - Api\Storage\Customfields::update_links('infolog',$values,$old,'info_id'); |
|
951 | + Api\Storage\Customfields::update_links('infolog', $values, $old, 'info_id'); |
|
952 | 952 | |
953 | 953 | // Check for restore of deleted entry, restore held links |
954 | - if($old['info_status'] == 'deleted' && $values['info_status'] != 'deleted') |
|
954 | + if ($old['info_status'] == 'deleted' && $values['info_status'] != 'deleted') |
|
955 | 955 | { |
956 | 956 | Link::restore('infolog', $info_id); |
957 | 957 | } |
958 | 958 | |
959 | 959 | // notify the link-class about the update, as other apps may be subscribt to it |
960 | - Link::notify_update('infolog',$info_id,$values); |
|
960 | + Link::notify_update('infolog', $info_id, $values); |
|
961 | 961 | |
962 | 962 | // pre-cache the new values |
963 | 963 | self::set_link_cache($values); |
@@ -968,42 +968,42 @@ discard block |
||
968 | 968 | $this->tracking = new infolog_tracking($this); |
969 | 969 | } |
970 | 970 | |
971 | - if ($old && ($missing_fields = array_diff_key($old,$values))) |
|
971 | + if ($old && ($missing_fields = array_diff_key($old, $values))) |
|
972 | 972 | { |
973 | 973 | // Some custom fields (multiselect with nothing selected) will be missing, |
974 | 974 | // and that's OK. Don't put them back. |
975 | - foreach(array_keys($missing_fields) as $field) |
|
975 | + foreach (array_keys($missing_fields) as $field) |
|
976 | 976 | { |
977 | - if(array_key_exists($field, $values_in)) |
|
977 | + if (array_key_exists($field, $values_in)) |
|
978 | 978 | { |
979 | 979 | unset($missing_fields[$field]); |
980 | 980 | } |
981 | 981 | } |
982 | - $values = array_merge($values,$missing_fields); |
|
982 | + $values = array_merge($values, $missing_fields); |
|
983 | 983 | } |
984 | 984 | // Add keys missing in the $to_write array |
985 | - if (($missing_fields = array_diff_key($values,$to_write))) |
|
985 | + if (($missing_fields = array_diff_key($values, $to_write))) |
|
986 | 986 | { |
987 | - $to_write = array_merge($to_write,$missing_fields); |
|
987 | + $to_write = array_merge($to_write, $missing_fields); |
|
988 | 988 | } |
989 | - $this->tracking->track($to_write,$old,$this->user,$values['info_status'] == 'deleted' || $old['info_status'] == 'deleted', |
|
990 | - null,$skip_notification); |
|
989 | + $this->tracking->track($to_write, $old, $this->user, $values['info_status'] == 'deleted' || $old['info_status'] == 'deleted', |
|
990 | + null, $skip_notification); |
|
991 | 991 | |
992 | 992 | if ($info_from_set) $values['info_from'] = ''; |
993 | 993 | |
994 | 994 | // Change new values back to user time before sending them back |
995 | - if($user2server) |
|
995 | + if ($user2server) |
|
996 | 996 | { |
997 | 997 | $this->time2time($values); |
998 | 998 | } |
999 | 999 | // merge changes (keeping extra values from the UI) |
1000 | - $values_in = array_merge($values_in,$values); |
|
1000 | + $values_in = array_merge($values_in, $values); |
|
1001 | 1001 | |
1002 | 1002 | // Update modified timestamp of parent |
1003 | - if($values['info_id_parent']) |
|
1003 | + if ($values['info_id_parent']) |
|
1004 | 1004 | { |
1005 | - $parent = $this->read($values['info_id_parent'], false, 'server',true); |
|
1006 | - $this->write($parent,false, true, false, true); |
|
1005 | + $parent = $this->read($values['info_id_parent'], false, 'server', true); |
|
1006 | + $this->write($parent, false, true, false, true); |
|
1007 | 1007 | } |
1008 | 1008 | } |
1009 | 1009 | return $info_id; |
@@ -1015,9 +1015,9 @@ discard block |
||
1015 | 1015 | * @param int|array $info_id id |
1016 | 1016 | * @return int|array number of subs |
1017 | 1017 | */ |
1018 | - function anzSubs( $info_id ) |
|
1018 | + function anzSubs($info_id) |
|
1019 | 1019 | { |
1020 | - return $this->so->anzSubs( $info_id ); |
|
1020 | + return $this->so->anzSubs($info_id); |
|
1021 | 1021 | } |
1022 | 1022 | |
1023 | 1023 | /** |
@@ -1037,19 +1037,19 @@ discard block |
||
1037 | 1037 | { |
1038 | 1038 | //error_log(__METHOD__.'('.array2string($query).')'); |
1039 | 1039 | |
1040 | - if($query['filter'] == 'bydate') |
|
1040 | + if ($query['filter'] == 'bydate') |
|
1041 | 1041 | { |
1042 | 1042 | if (is_int($query['startdate'])) $query['col_filter'][] = 'info_startdate >= '.$GLOBALS['egw']->db->quote($query['startdate']); |
1043 | - if (is_int($query['enddate'])) $query['col_filter'][] = 'info_startdate <= '.$GLOBALS['egw']->db->quote($query['enddate']+(60*60*24)-1); |
|
1043 | + if (is_int($query['enddate'])) $query['col_filter'][] = 'info_startdate <= '.$GLOBALS['egw']->db->quote($query['enddate'] + (60 * 60 * 24) - 1); |
|
1044 | 1044 | } |
1045 | 1045 | elseif ($query['filter'] == 'duedate') |
1046 | 1046 | { |
1047 | 1047 | if (is_int($query['startdate'])) $query['col_filter'][] = 'info_enddate >= '.$GLOBALS['egw']->db->quote($query['startdate']); |
1048 | - if (is_int($query['enddate'])) $query['col_filter'][] = 'info_enddate <= '.$GLOBALS['egw']->db->quote($query['enddate']+(60*60*24)-1); |
|
1048 | + if (is_int($query['enddate'])) $query['col_filter'][] = 'info_enddate <= '.$GLOBALS['egw']->db->quote($query['enddate'] + (60 * 60 * 24) - 1); |
|
1049 | 1049 | } |
1050 | 1050 | elseif ($query['filter'] == 'private') |
1051 | 1051 | { |
1052 | - $query['col_filter'][] = 'info_access = ' . $GLOBALS['egw']->db->quote('private'); |
|
1052 | + $query['col_filter'][] = 'info_access = '.$GLOBALS['egw']->db->quote('private'); |
|
1053 | 1053 | } |
1054 | 1054 | if (!isset($query['date_format']) || $query['date_format'] != 'server') |
1055 | 1055 | { |
@@ -1059,7 +1059,7 @@ discard block |
||
1059 | 1059 | { |
1060 | 1060 | if (!empty($query['col_filter'][$key])) |
1061 | 1061 | { |
1062 | - $query['col_filter'][$key] = Api\DateTime::user2server($query['col_filter'][$key],'ts'); |
|
1062 | + $query['col_filter'][$key] = Api\DateTime::user2server($query['col_filter'][$key], 'ts'); |
|
1063 | 1063 | } |
1064 | 1064 | } |
1065 | 1065 | } |
@@ -1072,7 +1072,7 @@ discard block |
||
1072 | 1072 | { |
1073 | 1073 | foreach ($ret as $id => &$data) |
1074 | 1074 | { |
1075 | - if (!$this->check_access($data,Acl::READ)) |
|
1075 | + if (!$this->check_access($data, Acl::READ)) |
|
1076 | 1076 | { |
1077 | 1077 | unset($ret[$id]); |
1078 | 1078 | continue; |
@@ -1088,7 +1088,7 @@ discard block |
||
1088 | 1088 | if ($time->format('Hi') == '0000') |
1089 | 1089 | { |
1090 | 1090 | // we keep dates the same in user-time |
1091 | - $arr = Api\DateTime::to($time,'array'); |
|
1091 | + $arr = Api\DateTime::to($time, 'array'); |
|
1092 | 1092 | $time = new Api\DateTime($arr, Api\DateTime::$user_timezone); |
1093 | 1093 | } |
1094 | 1094 | else |
@@ -1096,7 +1096,7 @@ discard block |
||
1096 | 1096 | $time->setTimezone(Api\DateTime::$user_timezone); |
1097 | 1097 | } |
1098 | 1098 | } |
1099 | - $data[$key] = Api\DateTime::to($time,'ts'); |
|
1099 | + $data[$key] = Api\DateTime::to($time, 'ts'); |
|
1100 | 1100 | } |
1101 | 1101 | } |
1102 | 1102 | // pre-cache title and file access |
@@ -1113,7 +1113,7 @@ discard block |
||
1113 | 1113 | * @param array $filter = array('filter'=>'own','info_type'=>'task') |
1114 | 1114 | * @return string |
1115 | 1115 | */ |
1116 | - public function getctag(array $filter=array('filter'=>'own','info_type'=>'task')) |
|
1116 | + public function getctag(array $filter = array('filter'=>'own', 'info_type'=>'task')) |
|
1117 | 1117 | { |
1118 | 1118 | $filter += array( |
1119 | 1119 | 'order' => 'info_datemodified', |
@@ -1125,7 +1125,7 @@ discard block |
||
1125 | 1125 | // we need to query deleted entries too for a ctag! |
1126 | 1126 | $filter['filter'] .= '+deleted'; |
1127 | 1127 | |
1128 | - $result =& $this->search($filter); |
|
1128 | + $result = & $this->search($filter); |
|
1129 | 1129 | |
1130 | 1130 | if (empty($result)) return 'EGw-empty-wGE'; |
1131 | 1131 | |
@@ -1147,12 +1147,12 @@ discard block |
||
1147 | 1147 | * @param string $_date |
1148 | 1148 | * @return array $content array for uiinfolog |
1149 | 1149 | */ |
1150 | - function import_mail($_addresses,$_subject,$_message,$_attachments,$_date) |
|
1150 | + function import_mail($_addresses, $_subject, $_message, $_attachments, $_date) |
|
1151 | 1151 | { |
1152 | - foreach($_addresses as $address) |
|
1152 | + foreach ($_addresses as $address) |
|
1153 | 1153 | { |
1154 | 1154 | $names[] = $address['name']; |
1155 | - $emails[] =$address['email']; |
|
1155 | + $emails[] = $address['email']; |
|
1156 | 1156 | } |
1157 | 1157 | |
1158 | 1158 | $type = isset($this->enums['type']['email']) ? 'email' : 'note'; |
@@ -1160,8 +1160,8 @@ discard block |
||
1160 | 1160 | $info = array( |
1161 | 1161 | 'info_id' => 0, |
1162 | 1162 | 'info_type' => $type, |
1163 | - 'info_from' => implode(', ',$names), |
|
1164 | - 'info_addr' => implode(', ',$emails), |
|
1163 | + 'info_from' => implode(', ', $names), |
|
1164 | + 'info_addr' => implode(', ', $emails), |
|
1165 | 1165 | 'info_subject' => $_subject, |
1166 | 1166 | 'info_des' => $_message, |
1167 | 1167 | 'info_startdate' => Api\DateTime::server2user($_date), |
@@ -1180,16 +1180,16 @@ discard block |
||
1180 | 1180 | $contacts = array(); |
1181 | 1181 | foreach ($emails as $mailadr) |
1182 | 1182 | { |
1183 | - $contacts = array_merge($contacts,(array)$addressbook->search( |
|
1183 | + $contacts = array_merge($contacts, (array)$addressbook->search( |
|
1184 | 1184 | array( |
1185 | 1185 | 'email' => $mailadr, |
1186 | 1186 | 'email_home' => $mailadr |
1187 | - ),True,'','','',false,'OR',false,null,'',false)); |
|
1187 | + ), True, '', '', '', false, 'OR', false, null, '', false)); |
|
1188 | 1188 | } |
1189 | 1189 | if (!$contacts || !is_array($contacts) || !is_array($contacts[0])) |
1190 | 1190 | { |
1191 | - $info['msg'] = lang('Attention: No Contact with address %1 found.',$info['info_addr']); |
|
1192 | - $info['info_custom_from'] = true; // show the info_from line and NOT only the link |
|
1191 | + $info['msg'] = lang('Attention: No Contact with address %1 found.', $info['info_addr']); |
|
1192 | + $info['info_custom_from'] = true; // show the info_from line and NOT only the link |
|
1193 | 1193 | } |
1194 | 1194 | else |
1195 | 1195 | { |
@@ -1199,21 +1199,21 @@ discard block |
||
1199 | 1199 | // create the rest a "ordinary" links |
1200 | 1200 | foreach ($contacts as $contact) |
1201 | 1201 | { |
1202 | - Link::link('infolog',$info['link_to']['to_id'],'addressbook',$contact['id']); |
|
1202 | + Link::link('infolog', $info['link_to']['to_id'], 'addressbook', $contact['id']); |
|
1203 | 1203 | } |
1204 | 1204 | } |
1205 | 1205 | if (is_array($_attachments)) |
1206 | 1206 | { |
1207 | 1207 | foreach ($_attachments as $attachment) |
1208 | 1208 | { |
1209 | - if($attachment['egw_data']) |
|
1209 | + if ($attachment['egw_data']) |
|
1210 | 1210 | { |
1211 | - Link::link('infolog',$info['link_to']['to_id'],Link::DATA_APPNAME, $attachment); |
|
1211 | + Link::link('infolog', $info['link_to']['to_id'], Link::DATA_APPNAME, $attachment); |
|
1212 | 1212 | } |
1213 | - else if(is_readable($attachment['tmp_name']) || |
|
1213 | + else if (is_readable($attachment['tmp_name']) || |
|
1214 | 1214 | (Vfs::is_readable($attachment['tmp_name']) && parse_url($attachment['tmp_name'], PHP_URL_SCHEME) === 'vfs')) |
1215 | 1215 | { |
1216 | - Link::link('infolog',$info['link_to']['to_id'],'file', $attachment); |
|
1216 | + Link::link('infolog', $info['link_to']['to_id'], 'file', $attachment); |
|
1217 | 1217 | } |
1218 | 1218 | } |
1219 | 1219 | } |
@@ -1232,14 +1232,14 @@ discard block |
||
1232 | 1232 | { |
1233 | 1233 | if (!is_array($info)) |
1234 | 1234 | { |
1235 | - $info = $this->read( $info,false ); |
|
1235 | + $info = $this->read($info, false); |
|
1236 | 1236 | } |
1237 | 1237 | if (!$info) |
1238 | 1238 | { |
1239 | 1239 | return $info; |
1240 | 1240 | } |
1241 | - $title = !empty($info['info_subject']) ? $info['info_subject'] :self::subject_from_des($info['info_descr']); |
|
1242 | - return $title.($GLOBALS['egw_info']['user']['preferences']['infolog']['show_id']?' (#'.$info['info_id'].')':''); |
|
1241 | + $title = !empty($info['info_subject']) ? $info['info_subject'] : self::subject_from_des($info['info_descr']); |
|
1242 | + return $title.($GLOBALS['egw_info']['user']['preferences']['infolog']['show_id'] ? ' (#'.$info['info_id'].')' : ''); |
|
1243 | 1243 | } |
1244 | 1244 | |
1245 | 1245 | /** |
@@ -1250,15 +1250,15 @@ discard block |
||
1250 | 1250 | function link_titles(array $ids) |
1251 | 1251 | { |
1252 | 1252 | $titles = array(); |
1253 | - foreach ($this->search($params=array( |
|
1253 | + foreach ($this->search($params = array( |
|
1254 | 1254 | 'col_filter' => array('info_id' => $ids), |
1255 | 1255 | )) as $info) |
1256 | 1256 | { |
1257 | 1257 | $titles[$info['info_id']] = $this->link_title($info); |
1258 | 1258 | } |
1259 | - foreach (array_diff($ids,array_keys($titles)) as $id) |
|
1259 | + foreach (array_diff($ids, array_keys($titles)) as $id) |
|
1260 | 1260 | { |
1261 | - $titles[$id] = false; // we assume every not returned entry to be not readable, as we notify the link class about all deletes |
|
1261 | + $titles[$id] = false; // we assume every not returned entry to be not readable, as we notify the link class about all deletes |
|
1262 | 1262 | } |
1263 | 1263 | return $titles; |
1264 | 1264 | } |
@@ -1285,7 +1285,7 @@ discard block |
||
1285 | 1285 | $content = array(); |
1286 | 1286 | if (is_array($ids)) |
1287 | 1287 | { |
1288 | - foreach(array_keys($ids) as $id) |
|
1288 | + foreach (array_keys($ids) as $id) |
|
1289 | 1289 | { |
1290 | 1290 | $content[$id] = $this->link_title($id); |
1291 | 1291 | } |
@@ -1302,10 +1302,10 @@ discard block |
||
1302 | 1302 | * @param int $user = null for which user to check, default current user |
1303 | 1303 | * @return boolean true if access is granted or false otherwise |
1304 | 1304 | */ |
1305 | - function file_access($id,$check,$rel_path=null,$user=null) |
|
1305 | + function file_access($id, $check, $rel_path = null, $user = null) |
|
1306 | 1306 | { |
1307 | - unset($rel_path); // not used |
|
1308 | - return $this->check_access($id,$check,0,$user); |
|
1307 | + unset($rel_path); // not used |
|
1308 | + return $this->check_access($id, $check, 0, $user); |
|
1309 | 1309 | } |
1310 | 1310 | |
1311 | 1311 | /** |
@@ -1315,10 +1315,9 @@ discard block |
||
1315 | 1315 | */ |
1316 | 1316 | function set_link_cache(array $info) |
1317 | 1317 | { |
1318 | - Link::set_cache('infolog',$info['info_id'], |
|
1318 | + Link::set_cache('infolog', $info['info_id'], |
|
1319 | 1319 | $this->link_title($info), |
1320 | - $this->file_access($info,Acl::EDIT) ? EGW_ACL_READ|EGW_ACL_EDIT : |
|
1321 | - ($this->file_access($info,Acl::READ) ? Acl::READ : 0)); |
|
1320 | + $this->file_access($info, Acl::EDIT) ? EGW_ACL_READ|EGW_ACL_EDIT : ($this->file_access($info, Acl::READ) ? Acl::READ : 0)); |
|
1322 | 1321 | } |
1323 | 1322 | |
1324 | 1323 | /** |
@@ -1332,8 +1331,8 @@ discard block |
||
1332 | 1331 | function cal_to_include($args) |
1333 | 1332 | { |
1334 | 1333 | //echo "<p>cal_to_include("; print_r($args); echo ")</p>\n"; |
1335 | - $user = (int) $args['owner']; |
|
1336 | - if ($user <= 0 && !checkdate($args['month'],$args['day'],$args['year'])) |
|
1334 | + $user = (int)$args['owner']; |
|
1335 | + if ($user <= 0 && !checkdate($args['month'], $args['day'], $args['year'])) |
|
1337 | 1336 | { |
1338 | 1337 | return False; |
1339 | 1338 | } |
@@ -1341,7 +1340,7 @@ discard block |
||
1341 | 1340 | |
1342 | 1341 | $do_events = $args['location'] == 'calendar_include_events'; |
1343 | 1342 | $to_include = array(); |
1344 | - $date_wanted = sprintf('%04d/%02d/%02d',$args['year'],$args['month'],$args['day']); |
|
1343 | + $date_wanted = sprintf('%04d/%02d/%02d', $args['year'], $args['month'], $args['day']); |
|
1345 | 1344 | $query = array( |
1346 | 1345 | 'order' => 'info_startdate', |
1347 | 1346 | 'sort' => $do_events ? 'ASC' : 'DESC', |
@@ -1350,34 +1349,34 @@ discard block |
||
1350 | 1349 | ); |
1351 | 1350 | if ($GLOBALS['egw_info']['user']['preferences']['infolog']['cal_show'] || $GLOBALS['egw_info']['user']['preferences']['infolog']['cal_show'] === '0') |
1352 | 1351 | { |
1353 | - $query['col_filter']['info_type'] = explode(',',$GLOBALS['egw_info']['user']['preferences']['infolog']['cal_show']); |
|
1352 | + $query['col_filter']['info_type'] = explode(',', $GLOBALS['egw_info']['user']['preferences']['infolog']['cal_show']); |
|
1354 | 1353 | } |
1355 | 1354 | elseif ($this->customfields && !$GLOBALS['egw_info']['user']['preferences']['infolog']['cal_show_custom']) |
1356 | 1355 | { |
1357 | - $query['col_filter']['info_type'] = array('task','phone','note','email'); |
|
1356 | + $query['col_filter']['info_type'] = array('task', 'phone', 'note', 'email'); |
|
1358 | 1357 | } |
1359 | 1358 | while ($infos = $this->search($query)) |
1360 | 1359 | { |
1361 | 1360 | foreach ($infos as $info) |
1362 | 1361 | { |
1363 | - $start = new Api\DateTime($info['info_startdate'],Api\DateTime::$user_timezone); |
|
1362 | + $start = new Api\DateTime($info['info_startdate'], Api\DateTime::$user_timezone); |
|
1364 | 1363 | $title = ($do_events ? $start->format(false).' ' : ''). |
1365 | 1364 | $info['info_subject']; |
1366 | - $view = Link::view('infolog',$info['info_id']); |
|
1365 | + $view = Link::view('infolog', $info['info_id']); |
|
1367 | 1366 | $size = null; |
1368 | - $edit = Link::edit('infolog',$info['info_id'], $size); |
|
1367 | + $edit = Link::edit('infolog', $info['info_id'], $size); |
|
1369 | 1368 | $edit['size'] = $size; |
1370 | - $content=array(); |
|
1369 | + $content = array(); |
|
1371 | 1370 | $status = $this->status[$info['info_type']][$info['info_status']]; |
1372 | 1371 | $icons = array(); |
1373 | - foreach(array( |
|
1372 | + foreach (array( |
|
1374 | 1373 | $info['info_type'] => 'navbar', |
1375 | 1374 | $status => 'status' |
1376 | 1375 | ) as $icon => $default) |
1377 | 1376 | { |
1378 | - $icons[Api\Image::find('infolog',$icon) ? $icon : $default] = $icon; |
|
1377 | + $icons[Api\Image::find('infolog', $icon) ? $icon : $default] = $icon; |
|
1379 | 1378 | } |
1380 | - $content[] = Api\Html::a_href($title,$view); |
|
1379 | + $content[] = Api\Html::a_href($title, $view); |
|
1381 | 1380 | $html = Api\Html::table(array(1 => $content)); |
1382 | 1381 | |
1383 | 1382 | $to_include[] = array( |
@@ -1390,9 +1389,9 @@ discard block |
||
1390 | 1389 | 'content' => $html, |
1391 | 1390 | ); |
1392 | 1391 | } |
1393 | - if ($query['total'] <= ($query['start']+=count($infos))) |
|
1392 | + if ($query['total'] <= ($query['start'] += count($infos))) |
|
1394 | 1393 | { |
1395 | - break; // no more availible |
|
1394 | + break; // no more availible |
|
1396 | 1395 | } |
1397 | 1396 | } |
1398 | 1397 | //echo "boinfolog::cal_to_include("; print_r($args); echo ")<pre>"; print_r($to_include); echo "</pre>\n"; |
@@ -1415,7 +1414,7 @@ discard block |
||
1415 | 1414 | 'cols' => 'info_id,info_type,info_status,info_percent,info_id_parent', |
1416 | 1415 | ); |
1417 | 1416 | $infos = array(); |
1418 | - foreach($this->search($query) as $row) |
|
1417 | + foreach ($this->search($query) as $row) |
|
1419 | 1418 | { |
1420 | 1419 | $infos[$row['info_id']] = array( |
1421 | 1420 | 'status' => $row['info_type'] != 'phone' && $row['info_status'] == 'ongoing' ? |
@@ -1424,13 +1423,13 @@ discard block |
||
1424 | 1423 | 'ongoing' : 'infolog/'.$row['info_status'], |
1425 | 1424 | 'class' => $row['info_id_parent'] ? 'infolog_rowHasParent' : null, |
1426 | 1425 | ); |
1427 | - if (Api\Image::find('infolog', $icon=$row['info_type'].'_element') || |
|
1428 | - Api\Image::find('infolog', $icon=$row['info_type'])) |
|
1426 | + if (Api\Image::find('infolog', $icon = $row['info_type'].'_element') || |
|
1427 | + Api\Image::find('infolog', $icon = $row['info_type'])) |
|
1429 | 1428 | { |
1430 | 1429 | $infos[$row['info_id']]['icon'] = 'infolog/'.$icon; |
1431 | 1430 | } |
1432 | 1431 | } |
1433 | - foreach($this->anzSubs(array_keys($infos)) as $info_id => $subs) |
|
1432 | + foreach ($this->anzSubs(array_keys($infos)) as $info_id => $subs) |
|
1434 | 1433 | { |
1435 | 1434 | if ($subs) $infos[$info_id]['class'] .= ' infolog_rowHasSubs'; |
1436 | 1435 | } |
@@ -1449,18 +1448,18 @@ discard block |
||
1449 | 1448 | * by the ones the user normally does not see due to category permissions - used to preserve categories |
1450 | 1449 | * @return array category ids (found, added and preserved categories) |
1451 | 1450 | */ |
1452 | - function find_or_add_categories($catname_list, $info_id=-1) |
|
1451 | + function find_or_add_categories($catname_list, $info_id = -1) |
|
1453 | 1452 | { |
1454 | 1453 | if (!is_object($this->categories)) |
1455 | 1454 | { |
1456 | - $this->categories = new Api\Categories($this->user,'infolog'); |
|
1455 | + $this->categories = new Api\Categories($this->user, 'infolog'); |
|
1457 | 1456 | } |
1458 | 1457 | $old_cats_preserve = array(); |
1459 | 1458 | if ($info_id && $info_id > 0) |
1460 | 1459 | { |
1461 | 1460 | // preserve Api\Categories without users read access |
1462 | 1461 | $old_infolog = $this->read($info_id); |
1463 | - $old_categories = explode(',',$old_infolog['info_cat']); |
|
1462 | + $old_categories = explode(',', $old_infolog['info_cat']); |
|
1464 | 1463 | if (is_array($old_categories) && count($old_categories) > 0) |
1465 | 1464 | { |
1466 | 1465 | foreach ($old_categories as $cat_id) |
@@ -1521,15 +1520,15 @@ discard block |
||
1521 | 1520 | { |
1522 | 1521 | if (!is_object($this->categories)) |
1523 | 1522 | { |
1524 | - $this->categories = new Api\Categories($this->user,'infolog'); |
|
1523 | + $this->categories = new Api\Categories($this->user, 'infolog'); |
|
1525 | 1524 | } |
1526 | 1525 | |
1527 | 1526 | if (!is_array($cat_id_list)) |
1528 | 1527 | { |
1529 | - $cat_id_list = explode(',',$cat_id_list); |
|
1528 | + $cat_id_list = explode(',', $cat_id_list); |
|
1530 | 1529 | } |
1531 | 1530 | $cat_list = array(); |
1532 | - foreach($cat_id_list as $cat_id) |
|
1531 | + foreach ($cat_id_list as $cat_id) |
|
1533 | 1532 | { |
1534 | 1533 | if ($cat_id && $this->categories->check_perms(Acl::READ, $cat_id) && |
1535 | 1534 | ($cat_name = $this->categories->id2name($cat_id)) && $cat_name != '--') |
@@ -1556,20 +1555,20 @@ discard block |
||
1556 | 1555 | |
1557 | 1556 | $save_account_id = $GLOBALS['egw_info']['user']['account_id']; |
1558 | 1557 | $save_prefs = $GLOBALS['egw_info']['user']['preferences']; |
1559 | - foreach($users as $user) |
|
1558 | + foreach ($users as $user) |
|
1560 | 1559 | { |
1561 | - if (!($email = $GLOBALS['egw']->accounts->id2name($user,'account_email'))) continue; |
|
1560 | + if (!($email = $GLOBALS['egw']->accounts->id2name($user, 'account_email'))) continue; |
|
1562 | 1561 | // create the enviroment for $user |
1563 | 1562 | $this->user = $GLOBALS['egw_info']['user']['account_id'] = $user; |
1564 | 1563 | $GLOBALS['egw']->preferences->__construct($user); |
1565 | 1564 | $GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository(); |
1566 | 1565 | $GLOBALS['egw']->acl->__construct($user); |
1567 | 1566 | $GLOBALS['egw']->acl->read_repository(); |
1568 | - $this->grants = $GLOBALS['egw']->acl->get_grants('infolog',$this->group_owners ? $this->group_owners : true); |
|
1569 | - $this->so = new infolog_so($this->grants); // so caches it's filters |
|
1567 | + $this->grants = $GLOBALS['egw']->acl->get_grants('infolog', $this->group_owners ? $this->group_owners : true); |
|
1568 | + $this->so = new infolog_so($this->grants); // so caches it's filters |
|
1570 | 1569 | |
1571 | 1570 | $notified_info_ids = array(); |
1572 | - foreach(array( |
|
1571 | + foreach (array( |
|
1573 | 1572 | 'notify_due_responsible' => 'open-responsible-enddate', |
1574 | 1573 | 'notify_due_delegated' => 'open-delegated-enddate', |
1575 | 1574 | 'notify_start_responsible' => 'open-responsible-date', |
@@ -1578,44 +1577,44 @@ discard block |
||
1578 | 1577 | { |
1579 | 1578 | if (!($pref_value = $GLOBALS['egw_info']['user']['preferences']['infolog'][$pref])) continue; |
1580 | 1579 | |
1581 | - $filter .= date('Y-m-d',time()+24*60*60*(int)$pref_value); |
|
1580 | + $filter .= date('Y-m-d', time() + 24 * 60 * 60 * (int)$pref_value); |
|
1582 | 1581 | //error_log(__METHOD__."() checking with filter '$filter' ($pref_value) for user $user ($email)"); |
1583 | 1582 | |
1584 | 1583 | $params = array('filter' => $filter, 'custom_fields' => true, 'subs' => true); |
1585 | - foreach($this->so->search($params) as $info) |
|
1584 | + foreach ($this->so->search($params) as $info) |
|
1586 | 1585 | { |
1587 | 1586 | // check if we already send a notification for that infolog entry, eg. starting and due on same day |
1588 | - if (in_array($info['info_id'],$notified_info_ids)) continue; |
|
1587 | + if (in_array($info['info_id'], $notified_info_ids)) continue; |
|
1589 | 1588 | |
1590 | 1589 | if (is_null($this->tracking) || $this->tracking->user != $user) |
1591 | 1590 | { |
1592 | 1591 | $this->tracking = new infolog_tracking($this); |
1593 | 1592 | } |
1594 | - switch($pref) |
|
1593 | + switch ($pref) |
|
1595 | 1594 | { |
1596 | 1595 | case 'notify_due_responsible': |
1597 | - $info['prefix'] = lang('Due %1',$this->enums['type'][$info['info_type']]); |
|
1598 | - $info['message'] = lang('%1 you are responsible for is due at %2',$this->enums['type'][$info['info_type']], |
|
1599 | - $this->tracking->datetime($info['info_enddate'],false)); |
|
1596 | + $info['prefix'] = lang('Due %1', $this->enums['type'][$info['info_type']]); |
|
1597 | + $info['message'] = lang('%1 you are responsible for is due at %2', $this->enums['type'][$info['info_type']], |
|
1598 | + $this->tracking->datetime($info['info_enddate'], false)); |
|
1600 | 1599 | break; |
1601 | 1600 | case 'notify_due_delegated': |
1602 | - $info['prefix'] = lang('Due %1',$this->enums['type'][$info['info_type']]); |
|
1603 | - $info['message'] = lang('%1 you delegated is due at %2',$this->enums['type'][$info['info_type']], |
|
1604 | - $this->tracking->datetime($info['info_enddate'],false)); |
|
1601 | + $info['prefix'] = lang('Due %1', $this->enums['type'][$info['info_type']]); |
|
1602 | + $info['message'] = lang('%1 you delegated is due at %2', $this->enums['type'][$info['info_type']], |
|
1603 | + $this->tracking->datetime($info['info_enddate'], false)); |
|
1605 | 1604 | break; |
1606 | 1605 | case 'notify_start_responsible': |
1607 | - $info['prefix'] = lang('Starting %1',$this->enums['type'][$info['info_type']]); |
|
1608 | - $info['message'] = lang('%1 you are responsible for is starting at %2',$this->enums['type'][$info['info_type']], |
|
1609 | - $this->tracking->datetime($info['info_startdate'],null)); |
|
1606 | + $info['prefix'] = lang('Starting %1', $this->enums['type'][$info['info_type']]); |
|
1607 | + $info['message'] = lang('%1 you are responsible for is starting at %2', $this->enums['type'][$info['info_type']], |
|
1608 | + $this->tracking->datetime($info['info_startdate'], null)); |
|
1610 | 1609 | break; |
1611 | 1610 | case 'notify_start_delegated': |
1612 | - $info['prefix'] = lang('Starting %1',$this->enums['type'][$info['info_type']]); |
|
1613 | - $info['message'] = lang('%1 you delegated is starting at %2',$this->enums['type'][$info['info_type']], |
|
1614 | - $this->tracking->datetime($info['info_startdate'],null)); |
|
1611 | + $info['prefix'] = lang('Starting %1', $this->enums['type'][$info['info_type']]); |
|
1612 | + $info['message'] = lang('%1 you delegated is starting at %2', $this->enums['type'][$info['info_type']], |
|
1613 | + $this->tracking->datetime($info['info_startdate'], null)); |
|
1615 | 1614 | break; |
1616 | 1615 | } |
1617 | 1616 | //error_log("notifiying $user($email) about $info[info_subject]: $info[message]"); |
1618 | - $this->tracking->send_notification($info,null,$email,$user,$pref); |
|
1617 | + $this->tracking->send_notification($info, null, $email, $user, $pref); |
|
1619 | 1618 | |
1620 | 1619 | $notified_info_ids[] = $info['info_id']; |
1621 | 1620 | } |
@@ -1678,7 +1677,7 @@ discard block |
||
1678 | 1677 | * @param string $x_infolog_status preserved original infolog status |
1679 | 1678 | * @return string |
1680 | 1679 | */ |
1681 | - function vtodo2status($_vtodo_status,$x_infolog_status=null) |
|
1680 | + function vtodo2status($_vtodo_status, $x_infolog_status = null) |
|
1682 | 1681 | { |
1683 | 1682 | $vtodo_status = strtoupper($_vtodo_status); |
1684 | 1683 | |
@@ -1702,7 +1701,7 @@ discard block |
||
1702 | 1701 | * @param array &$icons = null on return name of icons |
1703 | 1702 | * @return array value => (commaseparated) translations |
1704 | 1703 | */ |
1705 | - function get_status($type=null, array &$icons=null) |
|
1704 | + function get_status($type = null, array &$icons = null) |
|
1706 | 1705 | { |
1707 | 1706 | // if filtered by type, show only the stati of the filtered type |
1708 | 1707 | if ($type && isset($this->status[$type])) |
@@ -1712,16 +1711,16 @@ discard block |
||
1712 | 1711 | else // show all stati |
1713 | 1712 | { |
1714 | 1713 | $statis = $icons = array(); |
1715 | - foreach($this->status as $t => $stati) |
|
1714 | + foreach ($this->status as $t => $stati) |
|
1716 | 1715 | { |
1717 | 1716 | if ($t === 'defaults') continue; |
1718 | - foreach($stati as $val => $label) |
|
1717 | + foreach ($stati as $val => $label) |
|
1719 | 1718 | { |
1720 | 1719 | $statis[$val][$label] = lang($label); |
1721 | 1720 | if (!isset($icons[$val])) $icons[$val] = $label; |
1722 | 1721 | } |
1723 | 1722 | } |
1724 | - foreach($statis as $val => &$labels) |
|
1723 | + foreach ($statis as $val => &$labels) |
|
1725 | 1724 | { |
1726 | 1725 | $labels = implode(', ', $labels); |
1727 | 1726 | } |
@@ -1737,7 +1736,7 @@ discard block |
||
1737 | 1736 | */ |
1738 | 1737 | function activate($info) |
1739 | 1738 | { |
1740 | - switch((int)$info['info_percent']) |
|
1739 | + switch ((int)$info['info_percent']) |
|
1741 | 1740 | { |
1742 | 1741 | case 0: return 'not-started'; |
1743 | 1742 | case 100: return 'done'; |
@@ -1756,8 +1755,8 @@ discard block |
||
1756 | 1755 | #Horde::logMessage("getParentID($_guid)", __FILE__, __LINE__, PEAR_LOG_DEBUG); |
1757 | 1756 | |
1758 | 1757 | $parentID = False; |
1759 | - $myfilter = array('col_filter' => array('info_uid'=>$_guid)) ; |
|
1760 | - if ($_guid && ($found=$this->search($myfilter)) && ($uidmatch = array_shift($found))) |
|
1758 | + $myfilter = array('col_filter' => array('info_uid'=>$_guid)); |
|
1759 | + if ($_guid && ($found = $this->search($myfilter)) && ($uidmatch = array_shift($found))) |
|
1761 | 1760 | { |
1762 | 1761 | $parentID = $uidmatch['info_id']; |
1763 | 1762 | } |
@@ -1774,7 +1773,7 @@ discard block |
||
1774 | 1773 | * |
1775 | 1774 | * @return array of infolog_ids of matching entries |
1776 | 1775 | */ |
1777 | - function findInfo($infoData, $relax=false, $tzid=null) |
|
1776 | + function findInfo($infoData, $relax = false, $tzid = null) |
|
1778 | 1777 | { |
1779 | 1778 | $foundInfoLogs = array(); |
1780 | 1779 | $filter = array(); |
@@ -1782,7 +1781,7 @@ discard block |
||
1782 | 1781 | if ($this->log) |
1783 | 1782 | { |
1784 | 1783 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
1785 | - . '('. ($relax ? 'RELAX, ': 'EXACT, ') . $tzid . ')[InfoData]:' |
|
1784 | + . '('.($relax ? 'RELAX, ' : 'EXACT, ').$tzid.')[InfoData]:' |
|
1786 | 1785 | . array2string($infoData)); |
1787 | 1786 | } |
1788 | 1787 | |
@@ -1801,9 +1800,9 @@ discard block |
||
1801 | 1800 | if (!$relax && !empty($infoData['info_uid'])) |
1802 | 1801 | { |
1803 | 1802 | $filter = array('col_filter' => array('info_uid' => $infoData['info_uid'])); |
1804 | - foreach($this->so->search($filter) as $egwData) |
|
1803 | + foreach ($this->so->search($filter) as $egwData) |
|
1805 | 1804 | { |
1806 | - if (!$this->check_access($egwData,Acl::READ)) continue; |
|
1805 | + if (!$this->check_access($egwData, Acl::READ)) continue; |
|
1807 | 1806 | $foundInfoLogs[$egwData['info_id']] = $egwData['info_id']; |
1808 | 1807 | } |
1809 | 1808 | return $foundInfoLogs; |
@@ -1831,7 +1830,7 @@ discard block |
||
1831 | 1830 | $text = ''; |
1832 | 1831 | foreach ($matches as $chunk) |
1833 | 1832 | { |
1834 | - if (strlen($text) < strlen($chunk[0])) |
|
1833 | + if (strlen($text) < strlen($chunk[0])) |
|
1835 | 1834 | { |
1836 | 1835 | $text = $chunk[0]; |
1837 | 1836 | } |
@@ -1855,7 +1854,7 @@ discard block |
||
1855 | 1854 | |
1856 | 1855 | foreach ($this->so->search($filter) as $itemID => $egwData) |
1857 | 1856 | { |
1858 | - if (!$this->check_access($egwData,Acl::READ)) continue; |
|
1857 | + if (!$this->check_access($egwData, Acl::READ)) continue; |
|
1859 | 1858 | |
1860 | 1859 | switch ($infoData['info_type']) |
1861 | 1860 | { |
@@ -1872,7 +1871,7 @@ discard block |
||
1872 | 1871 | { |
1873 | 1872 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
1874 | 1873 | . '()[location mismatch]: ' |
1875 | - . $infoData['info_location'] . ' <> ' . $egwData['info_location']); |
|
1874 | + . $infoData['info_location'].' <> '.$egwData['info_location']); |
|
1876 | 1875 | } |
1877 | 1876 | continue; |
1878 | 1877 | } |
@@ -1889,7 +1888,7 @@ discard block |
||
1889 | 1888 | { |
1890 | 1889 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
1891 | 1890 | . '()[description mismatch]: ' |
1892 | - . $infoData['info_des'] . ' <> ' . $egwData['info_des']); |
|
1891 | + . $infoData['info_des'].' <> '.$egwData['info_des']); |
|
1893 | 1892 | } |
1894 | 1893 | continue; |
1895 | 1894 | } |
@@ -1903,7 +1902,7 @@ discard block |
||
1903 | 1902 | if ($this->log) |
1904 | 1903 | { |
1905 | 1904 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
1906 | - . '()[FOUND]:' . array2string($foundInfoLogs)); |
|
1905 | + . '()[FOUND]:'.array2string($foundInfoLogs)); |
|
1907 | 1906 | } |
1908 | 1907 | return $foundInfoLogs; |
1909 | 1908 | } |
@@ -1928,7 +1927,7 @@ discard block |
||
1928 | 1927 | // __FILE__, __LINE__, PEAR_LOG_DEBUG); |
1929 | 1928 | foreach ($this->so->search($filter) as $itemID => $egwData) |
1930 | 1929 | { |
1931 | - if (!$this->check_access($egwData,Acl::READ)) continue; |
|
1930 | + if (!$this->check_access($egwData, Acl::READ)) continue; |
|
1932 | 1931 | // Horde::logMessage("findVTODO Trying\n" |
1933 | 1932 | // . print_r($egwData, true), |
1934 | 1933 | // __FILE__, __LINE__, PEAR_LOG_DEBUG); |
@@ -1940,7 +1939,7 @@ discard block |
||
1940 | 1939 | { |
1941 | 1940 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
1942 | 1941 | . '()[category mismatch]: ' |
1943 | - . $infoData['info_cat'] . ' <> ' . $egwData['info_cat']); |
|
1942 | + . $infoData['info_cat'].' <> '.$egwData['info_cat']); |
|
1944 | 1943 | } |
1945 | 1944 | continue; |
1946 | 1945 | } |
@@ -1950,15 +1949,15 @@ discard block |
||
1950 | 1949 | if (isset($egwData['info_startdate']) && $egwData['info_startdate']) |
1951 | 1950 | { |
1952 | 1951 | // We compare the date only |
1953 | - $taskTime = new Api\DateTime($infoData['info_startdate'],Api\DateTime::$server_timezone); |
|
1954 | - $egwTime = new Api\DateTime($egwData['info_startdate'],Api\DateTime::$server_timezone); |
|
1952 | + $taskTime = new Api\DateTime($infoData['info_startdate'], Api\DateTime::$server_timezone); |
|
1953 | + $egwTime = new Api\DateTime($egwData['info_startdate'], Api\DateTime::$server_timezone); |
|
1955 | 1954 | if ($taskTime->format('Ymd') != $egwTime->format('Ymd')) |
1956 | 1955 | { |
1957 | 1956 | if ($this->log) |
1958 | 1957 | { |
1959 | 1958 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
1960 | 1959 | . '()[start mismatch]: ' |
1961 | - . $taskTime->format('Ymd') . ' <> ' . $egwTime->format('Ymd')); |
|
1960 | + . $taskTime->format('Ymd').' <> '.$egwTime->format('Ymd')); |
|
1962 | 1961 | } |
1963 | 1962 | continue; |
1964 | 1963 | } |
@@ -1985,7 +1984,7 @@ discard block |
||
1985 | 1984 | { |
1986 | 1985 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
1987 | 1986 | . '()[status mismatch]: ' |
1988 | - . $infoData['info_status'] . ' <> ' . $egwData['info_status']); |
|
1987 | + . $infoData['info_status'].' <> '.$egwData['info_status']); |
|
1989 | 1988 | } |
1990 | 1989 | continue; |
1991 | 1990 | } |
@@ -1995,15 +1994,15 @@ discard block |
||
1995 | 1994 | if (isset($egwData['info_enddate']) && $egwData['info_enddate']) |
1996 | 1995 | { |
1997 | 1996 | // We compare the date only |
1998 | - $taskTime = new Api\DateTime($infoData['info_enddate'],Api\DateTime::$server_timezone); |
|
1999 | - $egwTime = new Api\DateTime($egwData['info_enddate'],Api\DateTime::$server_timezone); |
|
1997 | + $taskTime = new Api\DateTime($infoData['info_enddate'], Api\DateTime::$server_timezone); |
|
1998 | + $egwTime = new Api\DateTime($egwData['info_enddate'], Api\DateTime::$server_timezone); |
|
2000 | 1999 | if ($taskTime->format('Ymd') != $egwTime->format('Ymd')) |
2001 | 2000 | { |
2002 | 2001 | if ($this->log) |
2003 | 2002 | { |
2004 | 2003 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2005 | 2004 | . '()[DUE mismatch]: ' |
2006 | - . $taskTime->format('Ymd') . ' <> ' . $egwTime->format('Ymd')); |
|
2005 | + . $taskTime->format('Ymd').' <> '.$egwTime->format('Ymd')); |
|
2007 | 2006 | } |
2008 | 2007 | continue; |
2009 | 2008 | } |
@@ -2024,15 +2023,15 @@ discard block |
||
2024 | 2023 | if (isset($egwData['info_datecompleted']) && $egwData['info_datecompleted']) |
2025 | 2024 | { |
2026 | 2025 | // We compare the date only |
2027 | - $taskTime = new Api\DateTime($infoData['info_datecompleted'],Api\DateTime::$server_timezone); |
|
2028 | - $egwTime = new Api\DateTime($egwData['info_datecompleted'],Api\DateTime::$server_timezone); |
|
2026 | + $taskTime = new Api\DateTime($infoData['info_datecompleted'], Api\DateTime::$server_timezone); |
|
2027 | + $egwTime = new Api\DateTime($egwData['info_datecompleted'], Api\DateTime::$server_timezone); |
|
2029 | 2028 | if ($taskTime->format('Ymd') != $egwTime->format('Ymd')) |
2030 | 2029 | { |
2031 | 2030 | if ($this->log) |
2032 | 2031 | { |
2033 | 2032 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2034 | 2033 | . '()[completed mismatch]: ' |
2035 | - . $taskTime->format('Ymd') . ' <> ' . $egwTime->format('Ymd')); |
|
2034 | + . $taskTime->format('Ymd').' <> '.$egwTime->format('Ymd')); |
|
2036 | 2035 | } |
2037 | 2036 | continue; |
2038 | 2037 | } |
@@ -2062,7 +2061,7 @@ discard block |
||
2062 | 2061 | if ($this->log) |
2063 | 2062 | { |
2064 | 2063 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ |
2065 | - . '()[FOUND]:' . array2string($foundInfoLogs)); |
|
2064 | + . '()[FOUND]:'.array2string($foundInfoLogs)); |
|
2066 | 2065 | } |
2067 | 2066 | return $foundInfoLogs; |
2068 | 2067 | } |
@@ -232,7 +232,10 @@ discard block |
||
232 | 232 | $this->enums['type'] += $config_data['types']; |
233 | 233 | //echo "types:<pre>"; print_r($this->enums['type']); echo "</pre>\n"; |
234 | 234 | } |
235 | - if ($config_data['group_owners']) $this->group_owners = $config_data['group_owners']; |
|
235 | + if ($config_data['group_owners']) |
|
236 | + { |
|
237 | + $this->group_owners = $config_data['group_owners']; |
|
238 | + } |
|
236 | 239 | |
237 | 240 | $this->customfields = Api\Storage\Customfields::get('infolog'); |
238 | 241 | if ($this->customfields) |
@@ -242,17 +245,35 @@ discard block |
||
242 | 245 | // old infolog customefield record |
243 | 246 | if(empty($field['type'])) |
244 | 247 | { |
245 | - if (count($field['values'])) $field['type'] = 'select'; // selectbox |
|
246 | - elseif ($field['rows'] > 1) $field['type'] = 'textarea'; // textarea |
|
247 | - elseif (intval($field['len']) > 0) $field['type'] = 'text'; // regular input field |
|
248 | - else $field['type'] = 'label'; // header-row |
|
248 | + if (count($field['values'])) |
|
249 | + { |
|
250 | + $field['type'] = 'select'; |
|
251 | + } |
|
252 | + // selectbox |
|
253 | + elseif ($field['rows'] > 1) |
|
254 | + { |
|
255 | + $field['type'] = 'textarea'; |
|
256 | + } |
|
257 | + // textarea |
|
258 | + elseif (intval($field['len']) > 0) |
|
259 | + { |
|
260 | + $field['type'] = 'text'; |
|
261 | + } |
|
262 | + // regular input field |
|
263 | + else { |
|
264 | + $field['type'] = 'label'; |
|
265 | + } |
|
266 | + // header-row |
|
249 | 267 | $field['type2'] = $field['typ']; |
250 | 268 | unset($field['typ']); |
251 | 269 | $this->customfields[$name] = $field; |
252 | 270 | $save_config = true; |
253 | 271 | } |
254 | 272 | } |
255 | - if ($save_config) Api\Config::save_value('customfields',$this->customfields,'infolog'); |
|
273 | + if ($save_config) |
|
274 | + { |
|
275 | + Api\Config::save_value('customfields',$this->customfields,'infolog'); |
|
276 | + } |
|
256 | 277 | } |
257 | 278 | if (is_array($config_data['responsible_edit'])) |
258 | 279 | { |
@@ -279,7 +300,10 @@ discard block |
||
279 | 300 | // sort types by there translation |
280 | 301 | foreach($this->enums['type'] as $key => $val) |
281 | 302 | { |
282 | - if (($val = lang($key)) != $key.'*') $this->enums['type'][$key] = lang($key); |
|
303 | + if (($val = lang($key)) != $key.'*') |
|
304 | + { |
|
305 | + $this->enums['type'][$key] = lang($key); |
|
306 | + } |
|
283 | 307 | } |
284 | 308 | natcasesort($this->enums['type']); |
285 | 309 | |
@@ -334,11 +358,18 @@ discard block |
||
334 | 358 | |
335 | 359 | $info_id = is_array($info) ? $info['info_id'] : $info; |
336 | 360 | |
337 | - if (!$user) $user = $this->user; |
|
361 | + if (!$user) |
|
362 | + { |
|
363 | + $user = $this->user; |
|
364 | + } |
|
338 | 365 | if ($user == $this->user) |
339 | 366 | { |
340 | 367 | $grants = $this->grants; |
341 | - if ($info_id) $access =& $cache[$info_id][$required_rights]; // we only cache the current user! |
|
368 | + if ($info_id) |
|
369 | + { |
|
370 | + $access =& $cache[$info_id][$required_rights]; |
|
371 | + } |
|
372 | + // we only cache the current user! |
|
342 | 373 | } |
343 | 374 | else |
344 | 375 | { |
@@ -357,16 +388,22 @@ discard block |
||
357 | 388 | // handle delete for the various history modes |
358 | 389 | if ($this->history) |
359 | 390 | { |
360 | - if (!is_array($info) && !($info = $this->so->read(array('info_id' => $info_id)))) return false; |
|
391 | + if (!is_array($info) && !($info = $this->so->read(array('info_id' => $info_id)))) |
|
392 | + { |
|
393 | + return false; |
|
394 | + } |
|
361 | 395 | |
362 | 396 | if ($info['info_status'] == 'deleted' && |
363 | 397 | ($required_rights == Acl::EDIT || // no edit rights for deleted entries |
364 | 398 | $required_rights == Acl::ADD || // no add rights for deleted entries |
365 | 399 | $required_rights == Acl::DELETE && ($this->history == 'history_no_delete' || // no delete at all! |
366 | - $this->history == 'history_admin_delete' && (!isset($GLOBALS['egw_info']['user']['apps']['admin']) || $user!=$this->user)))) // delete only for admins |
|
400 | + $this->history == 'history_admin_delete' && (!isset($GLOBALS['egw_info']['user']['apps']['admin']) || $user!=$this->user)))) |
|
401 | + { |
|
402 | + // delete only for admins |
|
367 | 403 | { |
368 | 404 | $access = false; |
369 | 405 | } |
406 | + } |
|
370 | 407 | elseif ($required_rights == self::ACL_UNDELETE) |
371 | 408 | { |
372 | 409 | if ($info['info_status'] != 'deleted') |
@@ -427,11 +464,14 @@ discard block |
||
427 | 464 | |
428 | 465 | if ($info['info_link_id'] > 0 && |
429 | 466 | (isset($info['links']) && ($link = $info['links'][$info['info_link_id']]) || // use supplied links info |
430 | - ($link = Link::get_link($info['info_link_id'])) !== False)) // if link not found in supplied links, we always search! |
|
467 | + ($link = Link::get_link($info['info_link_id'])) !== False)) |
|
468 | + { |
|
469 | + // if link not found in supplied links, we always search! |
|
431 | 470 | { |
432 | 471 | if (isset($info['links']) && isset($link['app'])) |
433 | 472 | { |
434 | 473 | $app = $link['app']; |
474 | + } |
|
435 | 475 | $id = $link['id']; |
436 | 476 | } |
437 | 477 | else |
@@ -442,10 +482,13 @@ discard block |
||
442 | 482 | } |
443 | 483 | $title = Link::title($app,$id); |
444 | 484 | |
445 | - if ((string)$info['info_custom_from'] === '') // old entry |
|
485 | + if ((string)$info['info_custom_from'] === '') |
|
486 | + { |
|
487 | + // old entry |
|
446 | 488 | { |
447 | 489 | $info['info_custom_from'] = (int) ($title != $info['info_from'] && @htmlentities($title) != $info['info_from']); |
448 | 490 | } |
491 | + } |
|
449 | 492 | if (!$info['info_custom_from']) |
450 | 493 | { |
451 | 494 | $info['info_from'] = ''; |
@@ -495,12 +538,15 @@ discard block |
||
495 | 538 | function time2time(&$values, $fromTZId=false, $toTZId=null) |
496 | 539 | { |
497 | 540 | |
498 | - if ($fromTZId === $toTZId) return; |
|
541 | + if ($fromTZId === $toTZId) |
|
542 | + { |
|
543 | + return; |
|
544 | + } |
|
499 | 545 | |
500 | 546 | $tz = Api\DateTime::$server_timezone; |
501 | 547 | |
502 | 548 | if ($fromTZId) |
503 | - { |
|
549 | + { |
|
504 | 550 | if (!isset(self::$tz_cache[$fromTZId])) |
505 | 551 | { |
506 | 552 | self::$tz_cache[$fromTZId] = calendar_timezones::DateTimeZone($fromTZId); |
@@ -534,7 +580,7 @@ discard block |
||
534 | 580 | } |
535 | 581 | //error_log(__METHOD__.'(values[info_enddate]='.date('Y-m-d H:i:s',$values['info_enddate']).", from=".array2string($fromTZId).", to=".array2string($toTZId).") tz=".$tz->getName().', fromTZ='.$fromTZ->getName().', toTZ='.$toTZ->getName().', userTZ='.Api\DateTime::$user_timezone->getName()); |
536 | 582 | foreach($this->timestamps as $key) |
537 | - { |
|
583 | + { |
|
538 | 584 | if ($values[$key]) |
539 | 585 | { |
540 | 586 | $time = new Api\DateTime($values[$key], $tz); |
@@ -564,7 +610,10 @@ discard block |
||
564 | 610 | */ |
565 | 611 | function date2usertime($ts,$date_format='ts') |
566 | 612 | { |
567 | - if (empty($ts) || $date_format == 'server') return $ts; |
|
613 | + if (empty($ts) || $date_format == 'server') |
|
614 | + { |
|
615 | + return $ts; |
|
616 | + } |
|
568 | 617 | |
569 | 618 | return Api\DateTime::server2user($ts,$date_format); |
570 | 619 | } |
@@ -601,16 +650,22 @@ discard block |
||
601 | 650 | return null; |
602 | 651 | } |
603 | 652 | |
604 | - if (!$ignore_acl && !$this->check_access($data,Acl::READ)) // check behind read, to prevent a double read |
|
653 | + if (!$ignore_acl && !$this->check_access($data,Acl::READ)) |
|
654 | + { |
|
655 | + // check behind read, to prevent a double read |
|
605 | 656 | { |
606 | 657 | return False; |
607 | 658 | } |
659 | + } |
|
608 | 660 | |
609 | 661 | if ($data['info_subject'] == $this->subject_from_des($data['info_des'])) |
610 | 662 | { |
611 | 663 | $data['info_subject'] = ''; |
612 | 664 | } |
613 | - if ($run_link_id2from) $this->link_id2from($data); |
|
665 | + if ($run_link_id2from) |
|
666 | + { |
|
667 | + $this->link_id2from($data); |
|
668 | + } |
|
614 | 669 | |
615 | 670 | // convert server- to user-time |
616 | 671 | if ($date_format == 'ts') |
@@ -673,7 +728,11 @@ discard block |
||
673 | 728 | // if we have history switched on and not an already deleted item --> set only status deleted |
674 | 729 | if ($this->history && $info['info_status'] != 'deleted') |
675 | 730 | { |
676 | - if ($info['info_status'] == 'deleted') return false; // entry already deleted |
|
731 | + if ($info['info_status'] == 'deleted') |
|
732 | + { |
|
733 | + return false; |
|
734 | + } |
|
735 | + // entry already deleted |
|
677 | 736 | |
678 | 737 | $this->so->write($deleted); |
679 | 738 | |
@@ -685,7 +744,9 @@ discard block |
||
685 | 744 | |
686 | 745 | Link::unlink(0,'infolog',$info_id); |
687 | 746 | } |
688 | - if ($info['info_status'] != 'deleted') // dont notify of final purge of already deleted items |
|
747 | + if ($info['info_status'] != 'deleted') |
|
748 | + { |
|
749 | + // dont notify of final purge of already deleted items |
|
689 | 750 | { |
690 | 751 | // send email notifications and do the history logging |
691 | 752 | if(!$skip_notification) |
@@ -693,6 +754,7 @@ discard block |
||
693 | 754 | if (!is_object($this->tracking)) |
694 | 755 | { |
695 | 756 | $this->tracking = new infolog_tracking($this); |
757 | + } |
|
696 | 758 | } |
697 | 759 | $this->tracking->track($deleted,$info,$this->user,true); |
698 | 760 | } |
@@ -741,10 +803,13 @@ discard block |
||
741 | 803 | { |
742 | 804 | $responsible = $values['info_responsible']; |
743 | 805 | } |
744 | - if (!($status_only = in_array($this->user, (array)$responsible))) // responsible has implicit right to change status |
|
806 | + if (!($status_only = in_array($this->user, (array)$responsible))) |
|
807 | + { |
|
808 | + // responsible has implicit right to change status |
|
745 | 809 | { |
746 | 810 | $status_only = !!array_intersect((array)$responsible,array_keys($GLOBALS['egw']->accounts->memberships($this->user))); |
747 | 811 | } |
812 | + } |
|
748 | 813 | if (!$status_only && $values['info_status'] != 'deleted') |
749 | 814 | { |
750 | 815 | $status_only = $undelete = $this->check_access($values['info_id'],self::ACL_UNDELETE); |
@@ -764,17 +829,23 @@ discard block |
||
764 | 829 | $values['info_status'] = $this->status['defaults'][$values['info_type']]; |
765 | 830 | } |
766 | 831 | } |
767 | - if ($status_only && !$undelete) // make sure only status gets writen |
|
832 | + if ($status_only && !$undelete) |
|
833 | + { |
|
834 | + // make sure only status gets writen |
|
768 | 835 | { |
769 | 836 | $set_completed = !$values['info_datecompleted'] && // set date completed of finished job, only if its not already set |
770 | 837 | in_array($values['info_status'],array('done','billed','cancelled')); |
838 | + } |
|
771 | 839 | |
772 | 840 | $values = $old; |
773 | 841 | // only overwrite explicitly allowed fields |
774 | 842 | $values['info_datemodified'] = $values_in['info_datemodified']; |
775 | 843 | foreach ($this->responsible_edit as $name) |
776 | 844 | { |
777 | - if (isset($values_in[$name])) $values[$name] = $values_in[$name]; |
|
845 | + if (isset($values_in[$name])) |
|
846 | + { |
|
847 | + $values[$name] = $values_in[$name]; |
|
848 | + } |
|
778 | 849 | } |
779 | 850 | if ($set_completed) |
780 | 851 | { |
@@ -782,21 +853,30 @@ discard block |
||
782 | 853 | $values['info_percent'] = 100; |
783 | 854 | $forcestatus = true; |
784 | 855 | $status = 'done'; |
785 | - if (isset($values['info_type']) && !in_array($values['info_status'],array('done','billed','cancelled'))) { |
|
856 | + if (isset($values['info_type']) && !in_array($values['info_status'],array('done','billed','cancelled'))) |
|
857 | + { |
|
786 | 858 | $forcestatus = false; |
787 | 859 | //echo "set_completed:"; _debug_array($this->status[$values['info_type']]); |
788 | - if (isset($this->status[$values['info_type']]['done'])) { |
|
860 | + if (isset($this->status[$values['info_type']]['done'])) |
|
861 | + { |
|
789 | 862 | $forcestatus = true; |
790 | 863 | $status = 'done'; |
791 | - } elseif (isset($this->status[$values['info_type']]['billed'])) { |
|
864 | + } |
|
865 | + elseif (isset($this->status[$values['info_type']]['billed'])) |
|
866 | + { |
|
792 | 867 | $forcestatus = true; |
793 | 868 | $status = 'billed'; |
794 | - } elseif (isset($this->status[$values['info_type']]['cancelled'])) { |
|
869 | + } |
|
870 | + elseif (isset($this->status[$values['info_type']]['cancelled'])) |
|
871 | + { |
|
795 | 872 | $forcestatus = true; |
796 | 873 | $status = 'cancelled'; |
797 | 874 | } |
798 | 875 | } |
799 | - if ($forcestatus && !in_array($values['info_status'],array('done','billed','cancelled'))) $values['info_status'] = $status; |
|
876 | + if ($forcestatus && !in_array($values['info_status'],array('done','billed','cancelled'))) |
|
877 | + { |
|
878 | + $values['info_status'] = $status; |
|
879 | + } |
|
800 | 880 | } |
801 | 881 | $check_defaults = false; |
802 | 882 | } |
@@ -828,14 +908,22 @@ discard block |
||
828 | 908 | //echo "check_defaults:"; _debug_array($this->status[$values['info_type']]); |
829 | 909 | //$values['info_status'] = 'done'; |
830 | 910 | $status = 'done'; |
831 | - if (isset($values['info_type'])) { |
|
832 | - if (isset($this->status[$values['info_type']]['done'])) { |
|
911 | + if (isset($values['info_type'])) |
|
912 | + { |
|
913 | + if (isset($this->status[$values['info_type']]['done'])) |
|
914 | + { |
|
833 | 915 | $status = 'done'; |
834 | - } elseif (isset($this->status[$values['info_type']]['billed'])) { |
|
916 | + } |
|
917 | + elseif (isset($this->status[$values['info_type']]['billed'])) |
|
918 | + { |
|
835 | 919 | $status = 'billed'; |
836 | - } elseif (isset($this->status[$values['info_type']]['cancelled'])) { |
|
920 | + } |
|
921 | + elseif (isset($this->status[$values['info_type']]['cancelled'])) |
|
922 | + { |
|
837 | 923 | $status = 'cancelled'; |
838 | - } else { |
|
924 | + } |
|
925 | + else |
|
926 | + { |
|
839 | 927 | // since the comlete stati above do not exist for that type, dont change it |
840 | 928 | $status = $values['info_status']; |
841 | 929 | } |
@@ -857,7 +945,10 @@ discard block |
||
857 | 945 | $custom = Api\Storage\Customfields::get('infolog'); |
858 | 946 | foreach($custom as $c_name => $c_field) |
859 | 947 | { |
860 | - if($c_field['type2']) $type2 = is_array($c_field['type2']) ? $c_field['type2'] : explode(',',$c_field['type2']); |
|
948 | + if($c_field['type2']) |
|
949 | + { |
|
950 | + $type2 = is_array($c_field['type2']) ? $c_field['type2'] : explode(',',$c_field['type2']); |
|
951 | + } |
|
861 | 952 | if($c_field['needed'] && (!$c_field['type2'] || $c_field['type2'] && in_array($values['info_type'],$type2))) |
862 | 953 | { |
863 | 954 | // Required custom field |
@@ -876,8 +967,7 @@ discard block |
||
876 | 967 | { |
877 | 968 | if (!$this->check_access($values['info_id'],Acl::EDIT) || |
878 | 969 | !$values['info_id'] && !$this->check_access($values,Acl::ADD) |
879 | - ) |
|
880 | - { |
|
970 | + ) { |
|
881 | 971 | return false; // no edit rights from the group-owner and no implicit rights (delegated and sufficient rights) |
882 | 972 | } |
883 | 973 | } |
@@ -941,10 +1031,16 @@ discard block |
||
941 | 1031 | $to_write['info_id'] = $info_id; |
942 | 1032 | |
943 | 1033 | // if the info responbsible array is not passed, fetch it from old. |
944 | - if (!array_key_exists('info_responsible',$values)) $values['info_responsible'] = $old['info_responsible']; |
|
945 | - if (!is_array($values['info_responsible'])) // this should not happen, bug it does ;-) |
|
1034 | + if (!array_key_exists('info_responsible',$values)) |
|
1035 | + { |
|
1036 | + $values['info_responsible'] = $old['info_responsible']; |
|
1037 | + } |
|
1038 | + if (!is_array($values['info_responsible'])) |
|
1039 | + { |
|
1040 | + // this should not happen, bug it does ;-) |
|
946 | 1041 | { |
947 | 1042 | $values['info_responsible'] = $values['info_responsible'] ? explode(',',$values['info_responsible']) : array(); |
1043 | + } |
|
948 | 1044 | $to_write['info_responsible'] = $values['info_responsible']; |
949 | 1045 | } |
950 | 1046 | // create (and remove) links in custom fields |
@@ -989,7 +1085,10 @@ discard block |
||
989 | 1085 | $this->tracking->track($to_write,$old,$this->user,$values['info_status'] == 'deleted' || $old['info_status'] == 'deleted', |
990 | 1086 | null,$skip_notification); |
991 | 1087 | |
992 | - if ($info_from_set) $values['info_from'] = ''; |
|
1088 | + if ($info_from_set) |
|
1089 | + { |
|
1090 | + $values['info_from'] = ''; |
|
1091 | + } |
|
993 | 1092 | |
994 | 1093 | // Change new values back to user time before sending them back |
995 | 1094 | if($user2server) |
@@ -1039,13 +1138,25 @@ discard block |
||
1039 | 1138 | |
1040 | 1139 | if($query['filter'] == 'bydate') |
1041 | 1140 | { |
1042 | - if (is_int($query['startdate'])) $query['col_filter'][] = 'info_startdate >= '.$GLOBALS['egw']->db->quote($query['startdate']); |
|
1043 | - if (is_int($query['enddate'])) $query['col_filter'][] = 'info_startdate <= '.$GLOBALS['egw']->db->quote($query['enddate']+(60*60*24)-1); |
|
1141 | + if (is_int($query['startdate'])) |
|
1142 | + { |
|
1143 | + $query['col_filter'][] = 'info_startdate >= '.$GLOBALS['egw']->db->quote($query['startdate']); |
|
1144 | + } |
|
1145 | + if (is_int($query['enddate'])) |
|
1146 | + { |
|
1147 | + $query['col_filter'][] = 'info_startdate <= '.$GLOBALS['egw']->db->quote($query['enddate']+(60*60*24)-1); |
|
1148 | + } |
|
1044 | 1149 | } |
1045 | 1150 | elseif ($query['filter'] == 'duedate') |
1046 | 1151 | { |
1047 | - if (is_int($query['startdate'])) $query['col_filter'][] = 'info_enddate >= '.$GLOBALS['egw']->db->quote($query['startdate']); |
|
1048 | - if (is_int($query['enddate'])) $query['col_filter'][] = 'info_enddate <= '.$GLOBALS['egw']->db->quote($query['enddate']+(60*60*24)-1); |
|
1152 | + if (is_int($query['startdate'])) |
|
1153 | + { |
|
1154 | + $query['col_filter'][] = 'info_enddate >= '.$GLOBALS['egw']->db->quote($query['startdate']); |
|
1155 | + } |
|
1156 | + if (is_int($query['enddate'])) |
|
1157 | + { |
|
1158 | + $query['col_filter'][] = 'info_enddate <= '.$GLOBALS['egw']->db->quote($query['enddate']+(60*60*24)-1); |
|
1159 | + } |
|
1049 | 1160 | } |
1050 | 1161 | elseif ($query['filter'] == 'private') |
1051 | 1162 | { |
@@ -1127,7 +1238,10 @@ discard block |
||
1127 | 1238 | |
1128 | 1239 | $result =& $this->search($filter); |
1129 | 1240 | |
1130 | - if (empty($result)) return 'EGw-empty-wGE'; |
|
1241 | + if (empty($result)) |
|
1242 | + { |
|
1243 | + return 'EGw-empty-wGE'; |
|
1244 | + } |
|
1131 | 1245 | |
1132 | 1246 | $entry = array_shift($result); |
1133 | 1247 | |
@@ -1174,7 +1288,10 @@ discard block |
||
1174 | 1288 | 'to_id' => 0, |
1175 | 1289 | ), |
1176 | 1290 | ); |
1177 | - if ($GLOBALS['egw_info']['user']['preferences']['infolog']['cat_add_default']) $info['info_cat'] = $GLOBALS['egw_info']['user']['preferences']['infolog']['cat_add_default']; |
|
1291 | + if ($GLOBALS['egw_info']['user']['preferences']['infolog']['cat_add_default']) |
|
1292 | + { |
|
1293 | + $info['info_cat'] = $GLOBALS['egw_info']['user']['preferences']['infolog']['cat_add_default']; |
|
1294 | + } |
|
1178 | 1295 | // find the addressbookentry to link with |
1179 | 1296 | $addressbook = new Api\Contacts(); |
1180 | 1297 | $contacts = array(); |
@@ -1432,7 +1549,10 @@ discard block |
||
1432 | 1549 | } |
1433 | 1550 | foreach($this->anzSubs(array_keys($infos)) as $info_id => $subs) |
1434 | 1551 | { |
1435 | - if ($subs) $infos[$info_id]['class'] .= ' infolog_rowHasSubs'; |
|
1552 | + if ($subs) |
|
1553 | + { |
|
1554 | + $infos[$info_id]['class'] .= ' infolog_rowHasSubs'; |
|
1555 | + } |
|
1436 | 1556 | } |
1437 | 1557 | } |
1438 | 1558 | return $infos; |
@@ -1558,7 +1678,10 @@ discard block |
||
1558 | 1678 | $save_prefs = $GLOBALS['egw_info']['user']['preferences']; |
1559 | 1679 | foreach($users as $user) |
1560 | 1680 | { |
1561 | - if (!($email = $GLOBALS['egw']->accounts->id2name($user,'account_email'))) continue; |
|
1681 | + if (!($email = $GLOBALS['egw']->accounts->id2name($user,'account_email'))) |
|
1682 | + { |
|
1683 | + continue; |
|
1684 | + } |
|
1562 | 1685 | // create the enviroment for $user |
1563 | 1686 | $this->user = $GLOBALS['egw_info']['user']['account_id'] = $user; |
1564 | 1687 | $GLOBALS['egw']->preferences->__construct($user); |
@@ -1576,7 +1699,10 @@ discard block |
||
1576 | 1699 | 'notify_start_delegated' => 'open-delegated-date', |
1577 | 1700 | ) as $pref => $filter) |
1578 | 1701 | { |
1579 | - if (!($pref_value = $GLOBALS['egw_info']['user']['preferences']['infolog'][$pref])) continue; |
|
1702 | + if (!($pref_value = $GLOBALS['egw_info']['user']['preferences']['infolog'][$pref])) |
|
1703 | + { |
|
1704 | + continue; |
|
1705 | + } |
|
1580 | 1706 | |
1581 | 1707 | $filter .= date('Y-m-d',time()+24*60*60*(int)$pref_value); |
1582 | 1708 | //error_log(__METHOD__."() checking with filter '$filter' ($pref_value) for user $user ($email)"); |
@@ -1585,7 +1711,10 @@ discard block |
||
1585 | 1711 | foreach($this->so->search($params) as $info) |
1586 | 1712 | { |
1587 | 1713 | // check if we already send a notification for that infolog entry, eg. starting and due on same day |
1588 | - if (in_array($info['info_id'],$notified_info_ids)) continue; |
|
1714 | + if (in_array($info['info_id'],$notified_info_ids)) |
|
1715 | + { |
|
1716 | + continue; |
|
1717 | + } |
|
1589 | 1718 | |
1590 | 1719 | if (is_null($this->tracking) || $this->tracking->user != $user) |
1591 | 1720 | { |
@@ -1714,11 +1843,17 @@ discard block |
||
1714 | 1843 | $statis = $icons = array(); |
1715 | 1844 | foreach($this->status as $t => $stati) |
1716 | 1845 | { |
1717 | - if ($t === 'defaults') continue; |
|
1846 | + if ($t === 'defaults') |
|
1847 | + { |
|
1848 | + continue; |
|
1849 | + } |
|
1718 | 1850 | foreach($stati as $val => $label) |
1719 | 1851 | { |
1720 | 1852 | $statis[$val][$label] = lang($label); |
1721 | - if (!isset($icons[$val])) $icons[$val] = $label; |
|
1853 | + if (!isset($icons[$val])) |
|
1854 | + { |
|
1855 | + $icons[$val] = $label; |
|
1856 | + } |
|
1722 | 1857 | } |
1723 | 1858 | } |
1724 | 1859 | foreach($statis as $val => &$labels) |
@@ -1794,7 +1929,10 @@ discard block |
||
1794 | 1929 | { |
1795 | 1930 | return array($egwData['info_id']); |
1796 | 1931 | } |
1797 | - if (!$relax) return array(); |
|
1932 | + if (!$relax) |
|
1933 | + { |
|
1934 | + return array(); |
|
1935 | + } |
|
1798 | 1936 | } |
1799 | 1937 | unset($infoData['info_id']); |
1800 | 1938 | |
@@ -1803,7 +1941,10 @@ discard block |
||
1803 | 1941 | $filter = array('col_filter' => array('info_uid' => $infoData['info_uid'])); |
1804 | 1942 | foreach($this->so->search($filter) as $egwData) |
1805 | 1943 | { |
1806 | - if (!$this->check_access($egwData,Acl::READ)) continue; |
|
1944 | + if (!$this->check_access($egwData,Acl::READ)) |
|
1945 | + { |
|
1946 | + continue; |
|
1947 | + } |
|
1807 | 1948 | $foundInfoLogs[$egwData['info_id']] = $egwData['info_id']; |
1808 | 1949 | } |
1809 | 1950 | return $foundInfoLogs; |
@@ -1855,7 +1996,10 @@ discard block |
||
1855 | 1996 | |
1856 | 1997 | foreach ($this->so->search($filter) as $itemID => $egwData) |
1857 | 1998 | { |
1858 | - if (!$this->check_access($egwData,Acl::READ)) continue; |
|
1999 | + if (!$this->check_access($egwData,Acl::READ)) |
|
2000 | + { |
|
2001 | + continue; |
|
2002 | + } |
|
1859 | 2003 | |
1860 | 2004 | switch ($infoData['info_type']) |
1861 | 2005 | { |
@@ -1928,7 +2072,10 @@ discard block |
||
1928 | 2072 | // __FILE__, __LINE__, PEAR_LOG_DEBUG); |
1929 | 2073 | foreach ($this->so->search($filter) as $itemID => $egwData) |
1930 | 2074 | { |
1931 | - if (!$this->check_access($egwData,Acl::READ)) continue; |
|
2075 | + if (!$this->check_access($egwData,Acl::READ)) |
|
2076 | + { |
|
2077 | + continue; |
|
2078 | + } |
|
1932 | 2079 | // Horde::logMessage("findVTODO Trying\n" |
1933 | 2080 | // . print_r($egwData, true), |
1934 | 2081 | // __FILE__, __LINE__, PEAR_LOG_DEBUG); |
@@ -1272,7 +1272,7 @@ |
||
1272 | 1272 | * @param array $options Array of options for the search |
1273 | 1273 | * @return array with info_id - title pairs of the matching entries |
1274 | 1274 | */ |
1275 | - function link_query($pattern, Array &$options = array()) |
|
1275 | + function link_query($pattern, array &$options = array()) |
|
1276 | 1276 | { |
1277 | 1277 | $query = array( |
1278 | 1278 | 'search' => $pattern, |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @param array &$options |
142 | 142 | * @param array &$files |
143 | 143 | * @param int $user account_id |
144 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
144 | + * @return boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
145 | 145 | */ |
146 | 146 | function propfind($path,&$options,&$files,$user,$id='') |
147 | 147 | { |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @param string $path |
223 | 223 | * @param array $filter |
224 | - * @param array|boolean $start =false false=return all or array(start,num) |
|
224 | + * @param integer[] $start =false false=return all or array(start,num) |
|
225 | 225 | * @return array with "files" array with values for keys path and props |
226 | 226 | */ |
227 | 227 | function &propfind_callback($path,array $filter,$start=false) |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | * @param array &$options |
522 | 522 | * @param int $id |
523 | 523 | * @param int $user =null account_id |
524 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
524 | + * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
525 | 525 | */ |
526 | 526 | function get(&$options,$id,$user=null) |
527 | 527 | { |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | * @param int $id |
547 | 547 | * @param int $user =null account_id of owner, default null |
548 | 548 | * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook) |
549 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
549 | + * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
550 | 550 | */ |
551 | 551 | function put(&$options,$id,$user=null,$prefix=null) |
552 | 552 | { |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | * |
683 | 683 | * @param array &$options |
684 | 684 | * @param int $id |
685 | - * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
685 | + * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
|
686 | 686 | */ |
687 | 687 | function delete(&$options,$id) |
688 | 688 | { |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | * etag currently uses the modifcation time (info_datemodified), 1.9.002 adds etag column, but it's not yet used! |
758 | 758 | * |
759 | 759 | * @param array|int $info array with infolog entry or info_id |
760 | - * @return string|boolean string with etag or false |
|
760 | + * @return false|string string with etag or false |
|
761 | 761 | */ |
762 | 762 | function get_etag($info) |
763 | 763 | { |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } |
113 | 113 | if ($path == '/infolog/') |
114 | 114 | { |
115 | - $task_filter= 'own'; |
|
115 | + $task_filter = 'own'; |
|
116 | 116 | } |
117 | 117 | else |
118 | 118 | { |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | } |
123 | 123 | else |
124 | 124 | { |
125 | - $task_filter = 'user' . $user; |
|
125 | + $task_filter = 'user'.$user; |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @param int $user account_id |
144 | 144 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
145 | 145 | */ |
146 | - function propfind($path,&$options,&$files,$user,$id='') |
|
146 | + function propfind($path, &$options, &$files, $user, $id = '') |
|
147 | 147 | { |
148 | 148 | // todo add a filter to limit how far back entries from the past get synced |
149 | 149 | $filter = $this->get_infolog_filter($path, $user); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | // enable time-range filter for tests via propfind / autoindex |
160 | 160 | //$filter[] = $sql = $this->_time_range_filter(array('end' => '20001231T000000Z')); |
161 | 161 | |
162 | - if ($id) $path = dirname($path).'/'; // caldav_name get's added anyway in the callback |
|
162 | + if ($id) $path = dirname($path).'/'; // caldav_name get's added anyway in the callback |
|
163 | 163 | |
164 | 164 | if ($this->debug > 1) |
165 | 165 | { |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | if (!($filter['calendar_data'] = $options['props'] == 'all' && |
172 | 172 | $options['root']['ns'] == Api\CalDAV::CALDAV) && is_array($options['props'])) |
173 | 173 | { |
174 | - foreach($options['props'] as $prop) |
|
174 | + foreach ($options['props'] as $prop) |
|
175 | 175 | { |
176 | 176 | if ($prop['name'] == 'calendar-data') |
177 | 177 | { |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | |
192 | 192 | $this->sync_collection_token = null; |
193 | 193 | |
194 | - $filter['order'] = 'info_datemodified ASC'; // return oldest modifications first |
|
194 | + $filter['order'] = 'info_datemodified ASC'; // return oldest modifications first |
|
195 | 195 | $filter['sync-collection'] = true; |
196 | 196 | } |
197 | 197 | |
@@ -205,13 +205,13 @@ discard block |
||
205 | 205 | if ($options['root']['name'] == 'sync-collection' && $this->bo->total > $nresults) |
206 | 206 | { |
207 | 207 | --$this->sync_collection_token; |
208 | - $files['sync-token-params'][] = true; // tel get_sync_collection_token that we have more entries |
|
208 | + $files['sync-token-params'][] = true; // tel get_sync_collection_token that we have more entries |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | else |
212 | 212 | { |
213 | 213 | // return iterator, calling ourself to return result in chunks |
214 | - $files['files'] = new Api\CalDAV\PropfindIterator($this,$path,$filter,$files['files']); |
|
214 | + $files['files'] = new Api\CalDAV\PropfindIterator($this, $path, $filter, $files['files']); |
|
215 | 215 | } |
216 | 216 | return true; |
217 | 217 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * @param array|boolean $start =false false=return all or array(start,num) |
225 | 225 | * @return array with "files" array with values for keys path and props |
226 | 226 | */ |
227 | - function &propfind_callback($path,array $filter,$start=false) |
|
227 | + function &propfind_callback($path, array $filter, $start = false) |
|
228 | 228 | { |
229 | 229 | if ($this->debug) $starttime = microtime(true); |
230 | 230 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | 'filter' => $task_filter, |
252 | 252 | 'date_format' => 'server', |
253 | 253 | 'col_filter' => $filter, |
254 | - 'custom_fields' => true, // otherwise custom fields get NOT loaded! |
|
254 | + 'custom_fields' => true, // otherwise custom fields get NOT loaded! |
|
255 | 255 | ); |
256 | 256 | |
257 | 257 | if (!$calendar_data) |
@@ -273,10 +273,10 @@ discard block |
||
273 | 273 | |
274 | 274 | $files = array(); |
275 | 275 | // ToDo: add parameter to only return id & etag |
276 | - $tasks =& $this->bo->search($query); |
|
276 | + $tasks = & $this->bo->search($query); |
|
277 | 277 | if ($tasks && $offset == $query['start']) |
278 | 278 | { |
279 | - foreach($tasks as $task) |
|
279 | + foreach ($tasks as $task) |
|
280 | 280 | { |
281 | 281 | // remove task from requested multiget ids, to be able to report not found urls |
282 | 282 | if ($requested_multiget_ids && ($k = array_search($task[self::$path_attr], $requested_multiget_ids)) !== false) |
@@ -290,15 +290,15 @@ discard block |
||
290 | 290 | continue; |
291 | 291 | } |
292 | 292 | $props = array( |
293 | - 'getcontenttype' => $this->agent != 'kde' ? 'text/calendar; charset=utf-8; component=VTODO' : 'text/calendar', // Konqueror (3.5) dont understand it otherwise |
|
293 | + 'getcontenttype' => $this->agent != 'kde' ? 'text/calendar; charset=utf-8; component=VTODO' : 'text/calendar', // Konqueror (3.5) dont understand it otherwise |
|
294 | 294 | 'getlastmodified' => $task['info_datemodified'], |
295 | 295 | 'displayname' => $task['info_subject'], |
296 | 296 | ); |
297 | 297 | if ($calendar_data) |
298 | 298 | { |
299 | - $content = $handler->exportVTODO($task, '2.0', null); // no METHOD:PUBLISH for CalDAV |
|
299 | + $content = $handler->exportVTODO($task, '2.0', null); // no METHOD:PUBLISH for CalDAV |
|
300 | 300 | $props['getcontentlength'] = bytes($content); |
301 | - $props[] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-data',$content); |
|
301 | + $props[] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-data', $content); |
|
302 | 302 | } |
303 | 303 | $files[] = $this->add_resource($path, $task, $props); |
304 | 304 | } |
@@ -306,13 +306,13 @@ discard block |
||
306 | 306 | // report not found multiget urls |
307 | 307 | if ($requested_multiget_ids) |
308 | 308 | { |
309 | - foreach($requested_multiget_ids as $id) |
|
309 | + foreach ($requested_multiget_ids as $id) |
|
310 | 310 | { |
311 | 311 | $files[] = array('path' => $path.$id.self::$path_extension); |
312 | 312 | } |
313 | 313 | } |
314 | 314 | // sync-collection report --> return modified of last contact as sync-token |
315 | - $sync_collection_report = $filter['sync-collection']; |
|
315 | + $sync_collection_report = $filter['sync-collection']; |
|
316 | 316 | if ($sync_collection_report) |
317 | 317 | { |
318 | 318 | $this->sync_collection_token = $task['date_modified']; |
@@ -338,18 +338,18 @@ discard block |
||
338 | 338 | * @param int &$nresult on return limit for number or results or unchanged/null |
339 | 339 | * @return boolean true if filter could be processed |
340 | 340 | */ |
341 | - function _report_filters($options,&$cal_filters,$id, &$nresults) |
|
341 | + function _report_filters($options, &$cal_filters, $id, &$nresults) |
|
342 | 342 | { |
343 | 343 | if ($options['filters']) |
344 | 344 | { |
345 | - foreach($options['filters'] as $filter) |
|
345 | + foreach ($options['filters'] as $filter) |
|
346 | 346 | { |
347 | - switch($filter['name']) |
|
347 | + switch ($filter['name']) |
|
348 | 348 | { |
349 | 349 | case 'comp-filter': |
350 | 350 | if ($this->debug > 1) error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'"); |
351 | 351 | |
352 | - switch($filter['attrs']['name']) |
|
352 | + switch ($filter['attrs']['name']) |
|
353 | 353 | { |
354 | 354 | case 'VTODO': |
355 | 355 | case 'VCALENDAR': |
@@ -392,9 +392,9 @@ discard block |
||
392 | 392 | <B:nresults>10</B:nresults> |
393 | 393 | </B:limit> |
394 | 394 | */ |
395 | - foreach((array)$options['other'] as $option) |
|
395 | + foreach ((array)$options['other'] as $option) |
|
396 | 396 | { |
397 | - switch($option['name']) |
|
397 | + switch ($option['name']) |
|
398 | 398 | { |
399 | 399 | case 'nresults': |
400 | 400 | $nresults = (int)$option['data']; |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | case 'limit': |
404 | 404 | break; |
405 | 405 | case 'href': |
406 | - break; // from addressbook-multiget, handled below |
|
406 | + break; // from addressbook-multiget, handled below |
|
407 | 407 | // rfc 6578 sync-report |
408 | 408 | case 'sync-token': |
409 | 409 | if (!empty($option['data'])) |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | $parts = explode('/', $option['data']); |
412 | 412 | $sync_token = array_pop($parts); |
413 | 413 | $cal_filters[] = 'info_datemodified>'.(int)$sync_token; |
414 | - $cal_filters['filter'] .= '+deleted'; // to return deleted entries too |
|
414 | + $cal_filters['filter'] .= '+deleted'; // to return deleted entries too |
|
415 | 415 | } |
416 | 416 | break; |
417 | 417 | case 'sync-level': |
@@ -433,24 +433,24 @@ discard block |
||
433 | 433 | if ($id) |
434 | 434 | { |
435 | 435 | $cal_filters[self::$path_attr] = self::$path_extension ? |
436 | - basename($id,self::$path_extension) : $id; |
|
436 | + basename($id, self::$path_extension) : $id; |
|
437 | 437 | } |
438 | 438 | else // fetch all given url's |
439 | 439 | { |
440 | - foreach($options['other'] as $option) |
|
440 | + foreach ($options['other'] as $option) |
|
441 | 441 | { |
442 | 442 | if ($option['name'] == 'href') |
443 | 443 | { |
444 | - $parts = explode('/',$option['data']); |
|
444 | + $parts = explode('/', $option['data']); |
|
445 | 445 | if (($id = basename(urldecode(array_pop($parts))))) |
446 | 446 | { |
447 | 447 | $cal_filters[self::$path_attr][] = self::$path_extension ? |
448 | - basename($id,self::$path_extension) : $id; |
|
448 | + basename($id, self::$path_extension) : $id; |
|
449 | 449 | } |
450 | 450 | } |
451 | 451 | } |
452 | 452 | } |
453 | - if ($this->debug > 1) error_log(__METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids)); |
|
453 | + if ($this->debug > 1) error_log(__METHOD__."($options[path],...,$id) calendar-multiget: ids=".implode(',', $ids)); |
|
454 | 454 | } |
455 | 455 | return true; |
456 | 456 | } |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | elseif (empty($attrs['start'])) |
479 | 479 | { |
480 | 480 | $this->caldav->log(__METHOD__.'('.array2string($attrs).') minimum one of start or end is required!'); |
481 | - return '1'; // to not give sql error, but simply not filter out anything |
|
481 | + return '1'; // to not give sql error, but simply not filter out anything |
|
482 | 482 | } |
483 | 483 | // we dont need to care for DURATION line in rfc4791#section-9.9, as we always put that in DUE/info_enddate |
484 | 484 | |
@@ -508,10 +508,10 @@ discard block |
||
508 | 508 | "info_datecompleted > 0".(isset($start) ? " AND ($start <= info_datecompleted OR $start <= info_created)" : ''). |
509 | 509 | (isset($end) ? " AND (info_datecompleted <= $end OR info_created <= $end)" : '').' OR '. |
510 | 510 | // we have no completed date, but always a created date |
511 | - "NOT info_datecompleted > 0". (isset($end) ? " AND info_created < $end" : ''). |
|
511 | + "NOT info_datecompleted > 0".(isset($end) ? " AND info_created < $end" : ''). |
|
512 | 512 | ')'; |
513 | 513 | $sql = '('.implode(' OR ', $to_or).')'; |
514 | - if ($this->debug > 1) error_log(__FILE__ . __METHOD__.'('.array2string($attrs).") time-range=$attrs[start]-$attrs[end] --> $sql"); |
|
514 | + if ($this->debug > 1) error_log(__FILE__.__METHOD__.'('.array2string($attrs).") time-range=$attrs[start]-$attrs[end] --> $sql"); |
|
515 | 515 | return $sql; |
516 | 516 | } |
517 | 517 | |
@@ -523,16 +523,16 @@ discard block |
||
523 | 523 | * @param int $user =null account_id |
524 | 524 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
525 | 525 | */ |
526 | - function get(&$options,$id,$user=null) |
|
526 | + function get(&$options, $id, $user = null) |
|
527 | 527 | { |
528 | - unset($user); // not used, but required by function signature |
|
528 | + unset($user); // not used, but required by function signature |
|
529 | 529 | |
530 | - if (!is_array($task = $this->_common_get_put_delete('GET',$options,$id))) |
|
530 | + if (!is_array($task = $this->_common_get_put_delete('GET', $options, $id))) |
|
531 | 531 | { |
532 | 532 | return $task; |
533 | 533 | } |
534 | 534 | $handler = $this->_get_handler(); |
535 | - $options['data'] = $handler->exportVTODO($task, '2.0', null); // no METHOD:PUBLISH for CalDAV |
|
535 | + $options['data'] = $handler->exportVTODO($task, '2.0', null); // no METHOD:PUBLISH for CalDAV |
|
536 | 536 | $options['mimetype'] = 'text/calendar; charset=utf-8'; |
537 | 537 | header('Content-Encoding: identity'); |
538 | 538 | header('ETag: "'.$this->get_etag($task).'"'); |
@@ -548,13 +548,13 @@ discard block |
||
548 | 548 | * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook) |
549 | 549 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
550 | 550 | */ |
551 | - function put(&$options,$id,$user=null,$prefix=null) |
|
551 | + function put(&$options, $id, $user = null, $prefix = null) |
|
552 | 552 | { |
553 | - unset($prefix); // not used, but required by function signature |
|
553 | + unset($prefix); // not used, but required by function signature |
|
554 | 554 | |
555 | - if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
555 | + if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options, true)); |
|
556 | 556 | |
557 | - $oldTask = $this->_common_get_put_delete('PUT',$options,$id); |
|
557 | + $oldTask = $this->_common_get_put_delete('PUT', $options, $id); |
|
558 | 558 | if (!is_null($oldTask) && !is_array($oldTask)) |
559 | 559 | { |
560 | 560 | return $oldTask; |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | * @param array $oldTask =null |
620 | 620 | * @return array modified task data |
621 | 621 | */ |
622 | - public function cat_action(array $task, $oldTask=null) |
|
622 | + public function cat_action(array $task, $oldTask = null) |
|
623 | 623 | { |
624 | 624 | $action = $GLOBALS['egw_info']['user']['preferences']['groupdav']['infolog-cat-action']; |
625 | 625 | |
@@ -650,13 +650,13 @@ discard block |
||
650 | 650 | { |
651 | 651 | unset($task['info_responsible'][$key]); |
652 | 652 | } |
653 | - switch($action) |
|
653 | + switch ($action) |
|
654 | 654 | { |
655 | 655 | case 'set': |
656 | 656 | $task['info_responsible'] = array(); |
657 | 657 | // fall through |
658 | 658 | case 'set-user': |
659 | - foreach($task['info_responsible'] as $key => $account_id) |
|
659 | + foreach ($task['info_responsible'] as $key => $account_id) |
|
660 | 660 | { |
661 | 661 | if ($GLOBALS['egw']->accounts->get_type($account_id) == 'u') |
662 | 662 | { |
@@ -684,9 +684,9 @@ discard block |
||
684 | 684 | * @param int $id |
685 | 685 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
686 | 686 | */ |
687 | - function delete(&$options,$id) |
|
687 | + function delete(&$options, $id) |
|
688 | 688 | { |
689 | - if (!is_array($task = $this->_common_get_put_delete('DELETE',$options,$id))) |
|
689 | + if (!is_array($task = $this->_common_get_put_delete('DELETE', $options, $id))) |
|
690 | 690 | { |
691 | 691 | return $task; |
692 | 692 | } |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | */ |
705 | 705 | function read($id) |
706 | 706 | { |
707 | - return $this->bo->read(array(self::$path_attr => $id, "info_status!='deleted'"),false,'server'); |
|
707 | + return $this->bo->read(array(self::$path_attr => $id, "info_status!='deleted'"), false, 'server'); |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | /** |
@@ -727,15 +727,15 @@ discard block |
||
727 | 727 | * @param array|int $task task-array or id |
728 | 728 | * @return boolean null if entry does not exist, false if no access, true if access permitted |
729 | 729 | */ |
730 | - function check_access($acl,$task) |
|
730 | + function check_access($acl, $task) |
|
731 | 731 | { |
732 | 732 | if (is_null($task)) return true; |
733 | 733 | |
734 | - $access = $this->bo->check_access($task,$acl); |
|
734 | + $access = $this->bo->check_access($task, $acl); |
|
735 | 735 | |
736 | 736 | if (!$access && $acl == Acl::EDIT && $this->bo->is_responsible($task)) |
737 | 737 | { |
738 | - $access = true; // access limited to $this->bo->responsible_edit fields (handled in infolog_bo::write()) |
|
738 | + $access = true; // access limited to $this->bo->responsible_edit fields (handled in infolog_bo::write()) |
|
739 | 739 | } |
740 | 740 | if ($this->debug > 1) error_log(__METHOD__."($acl, ".array2string($task).') returning '.array2string($access)); |
741 | 741 | return $access; |
@@ -746,7 +746,7 @@ discard block |
||
746 | 746 | * |
747 | 747 | * @return string |
748 | 748 | */ |
749 | - public function getctag($path,$user) |
|
749 | + public function getctag($path, $user) |
|
750 | 750 | { |
751 | 751 | return $this->bo->getctag($this->get_infolog_filter($path, $user)); |
752 | 752 | } |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | { |
764 | 764 | if (!is_array($info)) |
765 | 765 | { |
766 | - $info = $this->bo->read($info,true,'server'); |
|
766 | + $info = $this->bo->read($info, true, 'server'); |
|
767 | 767 | } |
768 | 768 | if (!is_array($info) || !isset($info['info_id']) || !isset($info['info_datemodified'])) |
769 | 769 | { |
@@ -781,39 +781,39 @@ discard block |
||
781 | 781 | * @param int $user =null account_id of owner of collection |
782 | 782 | * @return array |
783 | 783 | */ |
784 | - public function extra_properties(array $props, $displayname, $base_uri=null,$user=null) |
|
784 | + public function extra_properties(array $props, $displayname, $base_uri = null, $user = null) |
|
785 | 785 | { |
786 | - unset($base_uri); // not used, but required by function signature |
|
786 | + unset($base_uri); // not used, but required by function signature |
|
787 | 787 | |
788 | 788 | // calendar description |
789 | - $displayname = Api\Translation::convert(lang('Tasks of'),Api\Translation::charset(),'utf-8').' '.$displayname; |
|
790 | - $props['calendar-description'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-description',$displayname); |
|
789 | + $displayname = Api\Translation::convert(lang('Tasks of'), Api\Translation::charset(), 'utf-8').' '.$displayname; |
|
790 | + $props['calendar-description'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-description', $displayname); |
|
791 | 791 | // supported components, currently only VEVENT |
792 | - $props['supported-calendar-component-set'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'supported-calendar-component-set',array( |
|
793 | - Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'comp',array('name' => 'VCALENDAR')), |
|
794 | - Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'comp',array('name' => 'VTODO')), |
|
792 | + $props['supported-calendar-component-set'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'supported-calendar-component-set', array( |
|
793 | + Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'comp', array('name' => 'VCALENDAR')), |
|
794 | + Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'comp', array('name' => 'VTODO')), |
|
795 | 795 | )); |
796 | 796 | // supported reports |
797 | 797 | $props['supported-report-set'] = array( |
798 | - 'calendar-query' => Api\CalDAV::mkprop('supported-report',array( |
|
799 | - Api\CalDAV::mkprop('report',array( |
|
800 | - Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-query',''))))), |
|
801 | - 'calendar-multiget' => Api\CalDAV::mkprop('supported-report',array( |
|
802 | - Api\CalDAV::mkprop('report',array( |
|
803 | - Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-multiget',''))))), |
|
798 | + 'calendar-query' => Api\CalDAV::mkprop('supported-report', array( |
|
799 | + Api\CalDAV::mkprop('report', array( |
|
800 | + Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-query', ''))))), |
|
801 | + 'calendar-multiget' => Api\CalDAV::mkprop('supported-report', array( |
|
802 | + Api\CalDAV::mkprop('report', array( |
|
803 | + Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-multiget', ''))))), |
|
804 | 804 | ); |
805 | 805 | // only advertice rfc 6578 sync-collection report, if "delete-prevention" is switched on (deleted entries get marked deleted but not actualy deleted |
806 | 806 | $config = Api\Config::read('infolog'); |
807 | 807 | if ($config['history']) |
808 | 808 | { |
809 | - $props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report',array( |
|
810 | - Api\CalDAV::mkprop('report',array( |
|
811 | - Api\CalDAV::mkprop('sync-collection',''))))); |
|
809 | + $props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report', array( |
|
810 | + Api\CalDAV::mkprop('report', array( |
|
811 | + Api\CalDAV::mkprop('sync-collection', ''))))); |
|
812 | 812 | } |
813 | 813 | // get timezone of calendar |
814 | 814 | if ($this->caldav->prop_requested('calendar-timezone')) |
815 | 815 | { |
816 | - $props['calendar-timezone'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-timezone', |
|
816 | + $props['calendar-timezone'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-timezone', |
|
817 | 817 | calendar_timezones::user_timezone($user)); |
818 | 818 | } |
819 | 819 | return $props; |
@@ -827,8 +827,8 @@ discard block |
||
827 | 827 | private function _get_handler() |
828 | 828 | { |
829 | 829 | $handler = new infolog_ical(); |
830 | - $handler->tzid = false; // as we read server-time timestamps (!= null=user-time), exports UTC times |
|
831 | - $handler->setSupportedFields('GroupDAV',$this->agent); |
|
830 | + $handler->tzid = false; // as we read server-time timestamps (!= null=user-time), exports UTC times |
|
831 | + $handler->setSupportedFields('GroupDAV', $this->agent); |
|
832 | 832 | |
833 | 833 | return $handler; |
834 | 834 | } |
@@ -91,7 +91,10 @@ discard block |
||
91 | 91 | } |
92 | 92 | else |
93 | 93 | { |
94 | - if (!is_array($info)) $info = $this->bo->read($info); |
|
94 | + if (!is_array($info)) |
|
95 | + { |
|
96 | + $info = $this->bo->read($info); |
|
97 | + } |
|
95 | 98 | $name = $info[self::$path_attr]; |
96 | 99 | } |
97 | 100 | return $name.self::$path_extension; |
@@ -159,7 +162,11 @@ discard block |
||
159 | 162 | // enable time-range filter for tests via propfind / autoindex |
160 | 163 | //$filter[] = $sql = $this->_time_range_filter(array('end' => '20001231T000000Z')); |
161 | 164 | |
162 | - if ($id) $path = dirname($path).'/'; // caldav_name get's added anyway in the callback |
|
165 | + if ($id) |
|
166 | + { |
|
167 | + $path = dirname($path).'/'; |
|
168 | + } |
|
169 | + // caldav_name get's added anyway in the callback |
|
163 | 170 | |
164 | 171 | if ($this->debug > 1) |
165 | 172 | { |
@@ -226,7 +233,10 @@ discard block |
||
226 | 233 | */ |
227 | 234 | function &propfind_callback($path,array $filter,$start=false) |
228 | 235 | { |
229 | - if ($this->debug) $starttime = microtime(true); |
|
236 | + if ($this->debug) |
|
237 | + { |
|
238 | + $starttime = microtime(true); |
|
239 | + } |
|
230 | 240 | |
231 | 241 | if (($calendar_data = $filter['calendar_data'])) |
232 | 242 | { |
@@ -242,7 +252,10 @@ discard block |
||
242 | 252 | if (preg_match('/^([a-z0-9_]+)( DESC| ASC)?$/i', $filter['order'], $matches)) |
243 | 253 | { |
244 | 254 | $order = $matches[1]; |
245 | - if ($matches[2]) $sort = $matches[2]; |
|
255 | + if ($matches[2]) |
|
256 | + { |
|
257 | + $sort = $matches[2]; |
|
258 | + } |
|
246 | 259 | unset($filter['order']); |
247 | 260 | } |
248 | 261 | $query = array( |
@@ -325,7 +338,10 @@ discard block |
||
325 | 338 | --$this->sync_collection_token; |
326 | 339 | } |
327 | 340 | } |
328 | - if ($this->debug) error_log(__METHOD__."($path) took ".(microtime(true) - $starttime).' to return '.count($files).' items'); |
|
341 | + if ($this->debug) |
|
342 | + { |
|
343 | + error_log(__METHOD__."($path) took ".(microtime(true) - $starttime).' to return '.count($files).' items'); |
|
344 | + } |
|
329 | 345 | return $files; |
330 | 346 | } |
331 | 347 | |
@@ -347,7 +363,10 @@ discard block |
||
347 | 363 | switch($filter['name']) |
348 | 364 | { |
349 | 365 | case 'comp-filter': |
350 | - if ($this->debug > 1) error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'"); |
|
366 | + if ($this->debug > 1) |
|
367 | + { |
|
368 | + error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'"); |
|
369 | + } |
|
351 | 370 | |
352 | 371 | switch($filter['attrs']['name']) |
353 | 372 | { |
@@ -359,14 +378,23 @@ discard block |
||
359 | 378 | } |
360 | 379 | break; |
361 | 380 | case 'prop-filter': |
362 | - if ($this->debug > 1) error_log(__METHOD__."($options[path],...) prop-filter='{$filter['attrs']['name']}'"); |
|
381 | + if ($this->debug > 1) |
|
382 | + { |
|
383 | + error_log(__METHOD__."($options[path],...) prop-filter='{$filter['attrs']['name']}'"); |
|
384 | + } |
|
363 | 385 | $prop_filter = $filter['attrs']['name']; |
364 | 386 | break; |
365 | 387 | case 'text-match': |
366 | - if ($this->debug > 1) error_log(__METHOD__."($options[path],...) text-match: $prop_filter='{$filter['data']}'"); |
|
388 | + if ($this->debug > 1) |
|
389 | + { |
|
390 | + error_log(__METHOD__."($options[path],...) text-match: $prop_filter='{$filter['data']}'"); |
|
391 | + } |
|
367 | 392 | if (!isset($this->filter_prop2infolog[strtoupper($prop_filter)])) |
368 | 393 | { |
369 | - if ($this->debug) error_log(__METHOD__."($options[path],".array2string($options).",...) unknown property '$prop_filter' --> ignored"); |
|
394 | + if ($this->debug) |
|
395 | + { |
|
396 | + error_log(__METHOD__."($options[path],".array2string($options).",...) unknown property '$prop_filter' --> ignored"); |
|
397 | + } |
|
370 | 398 | } |
371 | 399 | else |
372 | 400 | { |
@@ -375,13 +403,19 @@ discard block |
||
375 | 403 | unset($prop_filter); |
376 | 404 | break; |
377 | 405 | case 'param-filter': |
378 | - if ($this->debug) error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!"); |
|
406 | + if ($this->debug) |
|
407 | + { |
|
408 | + error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!"); |
|
409 | + } |
|
379 | 410 | break; |
380 | 411 | case 'time-range': |
381 | 412 | $cal_filters[] = $this->_time_range_filter($filter['attrs']); |
382 | 413 | break; |
383 | 414 | default: |
384 | - if ($this->debug) error_log(__METHOD__."($options[path],".array2string($options).",...) unknown filter --> ignored"); |
|
415 | + if ($this->debug) |
|
416 | + { |
|
417 | + error_log(__METHOD__."($options[path],".array2string($options).",...) unknown filter --> ignored"); |
|
418 | + } |
|
385 | 419 | break; |
386 | 420 | } |
387 | 421 | } |
@@ -450,7 +484,10 @@ discard block |
||
450 | 484 | } |
451 | 485 | } |
452 | 486 | } |
453 | - if ($this->debug > 1) error_log(__METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids)); |
|
487 | + if ($this->debug > 1) |
|
488 | + { |
|
489 | + error_log(__METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids)); |
|
490 | + } |
|
454 | 491 | } |
455 | 492 | return true; |
456 | 493 | } |
@@ -511,7 +548,10 @@ discard block |
||
511 | 548 | "NOT info_datecompleted > 0". (isset($end) ? " AND info_created < $end" : ''). |
512 | 549 | ')'; |
513 | 550 | $sql = '('.implode(' OR ', $to_or).')'; |
514 | - if ($this->debug > 1) error_log(__FILE__ . __METHOD__.'('.array2string($attrs).") time-range=$attrs[start]-$attrs[end] --> $sql"); |
|
551 | + if ($this->debug > 1) |
|
552 | + { |
|
553 | + error_log(__FILE__ . __METHOD__.'('.array2string($attrs).") time-range=$attrs[start]-$attrs[end] --> $sql"); |
|
554 | + } |
|
515 | 555 | return $sql; |
516 | 556 | } |
517 | 557 | |
@@ -552,7 +592,10 @@ discard block |
||
552 | 592 | { |
553 | 593 | unset($prefix); // not used, but required by function signature |
554 | 594 | |
555 | - if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
595 | + if ($this->debug) |
|
596 | + { |
|
597 | + error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
598 | + } |
|
556 | 599 | |
557 | 600 | $oldTask = $this->_common_get_put_delete('PUT',$options,$id); |
558 | 601 | if (!is_null($oldTask) && !is_array($oldTask)) |
@@ -580,7 +623,10 @@ discard block |
||
580 | 623 | } |
581 | 624 | if (!($infoId = $handler->importVTODO($vTodo, $taskId, false, $user, null, $id, $callback_data))) |
582 | 625 | { |
583 | - if ($this->debug) error_log(__METHOD__."(,$id) import_vtodo($options[content]) returned false"); |
|
626 | + if ($this->debug) |
|
627 | + { |
|
628 | + error_log(__METHOD__."(,$id) import_vtodo($options[content]) returned false"); |
|
629 | + } |
|
584 | 630 | return '403 Forbidden'; |
585 | 631 | } |
586 | 632 | |
@@ -592,11 +638,13 @@ discard block |
||
592 | 638 | // send evtl. necessary respose headers: Location, etag, ... |
593 | 639 | // but only for new entries, as X-INFOLOG-STATUS get's not updated on client, if we confirm with an etag |
594 | 640 | if ($retval !== true) |
595 | - // POST with add-member query parameter |
|
641 | + { |
|
642 | + // POST with add-member query parameter |
|
596 | 643 | //$_SERVER['REQUEST_METHOD'] == 'POST' && isset($_GET['add-member']))) |
597 | 644 | { |
598 | 645 | $this->put_response_headers($infoId, $options['path'], $retval, self::$path_attr == 'caldav_name'); |
599 | 646 | } |
647 | + } |
|
600 | 648 | return $retval; |
601 | 649 | } |
602 | 650 | |
@@ -607,7 +655,10 @@ discard block |
||
607 | 655 | */ |
608 | 656 | public function update_tags($entry) |
609 | 657 | { |
610 | - if (!is_array($entry)) $entry = $this->read($entry); |
|
658 | + if (!is_array($entry)) |
|
659 | + { |
|
660 | + $entry = $this->read($entry); |
|
661 | + } |
|
611 | 662 | |
612 | 663 | $this->bo->write($entry, true); |
613 | 664 | } |
@@ -729,7 +780,10 @@ discard block |
||
729 | 780 | */ |
730 | 781 | function check_access($acl,$task) |
731 | 782 | { |
732 | - if (is_null($task)) return true; |
|
783 | + if (is_null($task)) |
|
784 | + { |
|
785 | + return true; |
|
786 | + } |
|
733 | 787 | |
734 | 788 | $access = $this->bo->check_access($task,$acl); |
735 | 789 | |
@@ -737,7 +791,10 @@ discard block |
||
737 | 791 | { |
738 | 792 | $access = true; // access limited to $this->bo->responsible_edit fields (handled in infolog_bo::write()) |
739 | 793 | } |
740 | - if ($this->debug > 1) error_log(__METHOD__."($acl, ".array2string($task).') returning '.array2string($access)); |
|
794 | + if ($this->debug > 1) |
|
795 | + { |
|
796 | + error_log(__METHOD__."($acl, ".array2string($task).') returning '.array2string($access)); |
|
797 | + } |
|
741 | 798 | return $access; |
742 | 799 | } |
743 | 800 |