@@ -150,7 +150,10 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | protected function action($attr, $action, array &$attrs) |
| 152 | 152 | { |
| 153 | - if (self::DEBUG) error_log(__METHOD__."('$attr', ".array2string($action).')'); |
|
| 153 | + if (self::DEBUG) |
|
| 154 | + { |
|
| 155 | + error_log(__METHOD__."('$attr', ".array2string($action).')'); |
|
| 156 | + } |
|
| 154 | 157 | // action is an assignment |
| 155 | 158 | if (is_scalar($action) || is_null($action)) |
| 156 | 159 | { |
@@ -160,7 +163,10 @@ discard block |
||
| 160 | 163 | $replace = array(); |
| 161 | 164 | foreach($attrs as $a => $v) |
| 162 | 165 | { |
| 163 | - if (is_scalar($v) || is_null($v)) $replace['@'.$a] = $v; |
|
| 166 | + if (is_scalar($v) || is_null($v)) |
|
| 167 | + { |
|
| 168 | + $replace['@'.$a] = $v; |
|
| 169 | + } |
|
| 164 | 170 | } |
| 165 | 171 | $action = strtr($action, $replace); |
| 166 | 172 | // now replace with non-scalar value, eg. if values is an array: "@value", "@value[key] or "@value[@key]" |
@@ -170,7 +176,10 @@ discard block |
||
| 170 | 176 | } |
| 171 | 177 | } |
| 172 | 178 | $attrs[$attr] = $action; |
| 173 | - if (self::DEBUG) error_log(__METHOD__."('$attr', ".array2string($action).") attrs['$attr'] = ".array2string($action).', attrs='.array2string($attrs)); |
|
| 179 | + if (self::DEBUG) |
|
| 180 | + { |
|
| 181 | + error_log(__METHOD__."('$attr', ".array2string($action).") attrs['$attr'] = ".array2string($action).', attrs='.array2string($attrs)); |
|
| 182 | + } |
|
| 174 | 183 | } |
| 175 | 184 | // action is a serverside callback |
| 176 | 185 | elseif(is_array($action) && isset($action['__callback__'])) |
@@ -218,7 +227,10 @@ discard block |
||
| 218 | 227 | $attrs[$attr] = $actions; |
| 219 | 228 | $actions = array($attr => $actions); |
| 220 | 229 | } |
| 221 | - if (self::DEBUG) error_log(__METHOD__."(attr='$attr', action=".array2string($action).") attrs['$attr']=='{$attrs[$attr]}' --> running actions"); |
|
| 230 | + if (self::DEBUG) |
|
| 231 | + { |
|
| 232 | + error_log(__METHOD__."(attr='$attr', action=".array2string($action).") attrs['$attr']=='{$attrs[$attr]}' --> running actions"); |
|
| 233 | + } |
|
| 222 | 234 | foreach($actions as $attr => $action) |
| 223 | 235 | { |
| 224 | 236 | $this->action($attr, $action, $attrs); |
@@ -187,7 +187,10 @@ discard block |
||
| 187 | 187 | } |
| 188 | 188 | foreach((array)$item['item'] as $child) |
| 189 | 189 | { |
| 190 | - if (self::in_tree($id, $child)) return true; |
|
| 190 | + if (self::in_tree($id, $child)) |
|
| 191 | + { |
|
| 192 | + return true; |
|
| 193 | + } |
|
| 191 | 194 | } |
| 192 | 195 | return false; |
| 193 | 196 | } |
@@ -251,7 +254,10 @@ discard block |
||
| 251 | 254 | self::set_validation_error($form_name,lang('Field must not be empty !!!',$value),''); |
| 252 | 255 | } |
| 253 | 256 | $valid =& self::get_array($validated, $form_name, true); |
| 254 | - if (true) $valid = $value; |
|
| 257 | + if (true) |
|
| 258 | + { |
|
| 259 | + $valid = $value; |
|
| 260 | + } |
|
| 255 | 261 | //error_log(__METHOD__."() $form_name: ".array2string($value_in).' --> '.array2string($value).', allowed='.array2string($allowed)); |
| 256 | 262 | } |
| 257 | 263 | } |
@@ -271,7 +277,10 @@ discard block |
||
| 271 | 277 | //error_log(__METHOD__."() setting templated image-path for $form_name: $templated_path"); |
| 272 | 278 | } |
| 273 | 279 | |
| 274 | - if (!is_array(self::$request->sel_options[$form_name])) self::$request->sel_options[$form_name] = array(); |
|
| 280 | + if (!is_array(self::$request->sel_options[$form_name])) |
|
| 281 | + { |
|
| 282 | + self::$request->sel_options[$form_name] = array(); |
|
| 283 | + } |
|
| 275 | 284 | if ($this->attrs['type']) |
| 276 | 285 | { |
| 277 | 286 | // += to keep further options set by app code |
@@ -339,7 +348,10 @@ discard block |
||
| 339 | 348 | public static function imagePath($image) |
| 340 | 349 | { |
| 341 | 350 | static $image_path=null; |
| 342 | - if (!isset($image_path)) $image_path = self::templateImagePath (); |
|
| 351 | + if (!isset($image_path)) |
|
| 352 | + { |
|
| 353 | + $image_path = self::templateImagePath (); |
|
| 354 | + } |
|
| 343 | 355 | |
| 344 | 356 | $parts = explode('/', $image_path); |
| 345 | 357 | $image_parts = explode('/', $image); |
@@ -414,12 +426,18 @@ discard block |
||
| 414 | 426 | switch ($widget_type) |
| 415 | 427 | { |
| 416 | 428 | case 'tree-cat': // !$type == globals cats too, $type2: extraStyleMultiselect, $type3: application, if not current-app, $type4: parent-id, $type5=owner (-1=global),$type6=show missing |
| 417 | - if ($readonly) // for readonly we dont need to fetch all cat's, nor do we need to indent them by level |
|
| 429 | + if ($readonly) |
|
| 430 | + { |
|
| 431 | + // for readonly we dont need to fetch all cat's, nor do we need to indent them by level |
|
| 418 | 432 | { |
| 419 | 433 | $cell['no_lang'] = True; |
| 434 | + } |
|
| 420 | 435 | foreach(is_array($value) ? $value : (strpos($value,',') !== false ? explode(',',$value) : array($value)) as $id) |
| 421 | 436 | { |
| 422 | - if ($id) $cell['sel_options'][$id] = stripslashes($GLOBALS['egw']->categories->id2name($id)); |
|
| 437 | + if ($id) |
|
| 438 | + { |
|
| 439 | + $cell['sel_options'][$id] = stripslashes($GLOBALS['egw']->categories->id2name($id)); |
|
| 440 | + } |
|
| 423 | 441 | } |
| 424 | 442 | break; |
| 425 | 443 | } |
@@ -89,7 +89,10 @@ discard block |
||
| 89 | 89 | public function beforeSendToClient($cname, array $expand=null) |
| 90 | 90 | { |
| 91 | 91 | // No name, no way to get parameters client-side. |
| 92 | - if(!$this->id) $this->id = self::GLOBAL_ID; |
|
| 92 | + if(!$this->id) |
|
| 93 | + { |
|
| 94 | + $this->id = self::GLOBAL_ID; |
|
| 95 | + } |
|
| 93 | 96 | |
| 94 | 97 | $form_name = self::form_name($cname, $this->id, $expand); |
| 95 | 98 | |
@@ -180,7 +183,10 @@ discard block |
||
| 180 | 183 | $form_name = self::$prefix.$name; |
| 181 | 184 | } |
| 182 | 185 | |
| 183 | - if(!is_array($fields)) $fields = array(); |
|
| 186 | + if(!is_array($fields)) |
|
| 187 | + { |
|
| 188 | + $fields = array(); |
|
| 189 | + } |
|
| 184 | 190 | switch($type = $this->type) |
| 185 | 191 | { |
| 186 | 192 | case 'customfields-types': |
@@ -205,11 +211,18 @@ discard block |
||
| 205 | 211 | foreach(array_reverse($fields) as $lname => $field) |
| 206 | 212 | { |
| 207 | 213 | if (!empty($this->attrs['sub-type']) && !empty($field['type2']) && |
| 208 | - strpos(','.$field['type2'].',',','.$field['type2'].',') === false) continue; // not for our content type// |
|
| 209 | - if (isset($value[self::$prefix.$lname]) && $value[self::$prefix.$lname] !== '') //break; |
|
| 214 | + strpos(','.$field['type2'].',',','.$field['type2'].',') === false) |
|
| 215 | + { |
|
| 216 | + continue; |
|
| 217 | + } |
|
| 218 | + // not for our content type// |
|
| 219 | + if (isset($value[self::$prefix.$lname]) && $value[self::$prefix.$lname] !== '') |
|
| 220 | + { |
|
| 221 | + //break; |
|
| 210 | 222 | { |
| 211 | 223 | $fields_with_vals[]=$lname; |
| 212 | 224 | } |
| 225 | + } |
|
| 213 | 226 | //$stop_at_field = $name; |
| 214 | 227 | } |
| 215 | 228 | break; |
@@ -240,7 +253,10 @@ discard block |
||
| 240 | 253 | |
| 241 | 254 | // Re-format date custom fields from Y-m-d |
| 242 | 255 | $field_settings =& self::get_array(self::$request->modifications, "{$this->id}[customfields]",true); |
| 243 | - if (true) $field_settings = array(); |
|
| 256 | + if (true) |
|
| 257 | + { |
|
| 258 | + $field_settings = array(); |
|
| 259 | + } |
|
| 244 | 260 | $link_types = Api\Link::app_list(); |
| 245 | 261 | foreach($fields as $fname => $field) |
| 246 | 262 | { |
@@ -263,7 +279,10 @@ discard block |
||
| 263 | 279 | protected function _widget($fname, array $field) |
| 264 | 280 | { |
| 265 | 281 | static $link_types = null; |
| 266 | - if (!isset($link_types)) $link_types = Api\Link::app_list (); |
|
| 282 | + if (!isset($link_types)) |
|
| 283 | + { |
|
| 284 | + $link_types = Api\Link::app_list (); |
|
| 285 | + } |
|
| 267 | 286 | |
| 268 | 287 | $type = $field['type']; |
| 269 | 288 | // Link-tos needs to change from appname to link-to |
@@ -288,8 +307,14 @@ discard block |
||
| 288 | 307 | case 'date': |
| 289 | 308 | case 'date-time': |
| 290 | 309 | $widget->attrs['dataformat'] = $type == 'date' ? 'Y-m-d' : 'Y-m-d H:i:s'; |
| 291 | - if($field['values']['min']) $widget->attrs['min'] = $field['values']['min']; |
|
| 292 | - if($field['values']['max']) $widget->attrs['min'] = $field['values']['max']; |
|
| 310 | + if($field['values']['min']) |
|
| 311 | + { |
|
| 312 | + $widget->attrs['min'] = $field['values']['min']; |
|
| 313 | + } |
|
| 314 | + if($field['values']['max']) |
|
| 315 | + { |
|
| 316 | + $widget->attrs['min'] = $field['values']['max']; |
|
| 317 | + } |
|
| 293 | 318 | break; |
| 294 | 319 | |
| 295 | 320 | case 'vfs-upload': |
@@ -306,7 +331,10 @@ discard block |
||
| 306 | 331 | break; |
| 307 | 332 | |
| 308 | 333 | default: |
| 309 | - if (substr($type, 0, 7) !== 'select-' && $type != 'ajax_select') break; |
|
| 334 | + if (substr($type, 0, 7) !== 'select-' && $type != 'ajax_select') |
|
| 335 | + { |
|
| 336 | + break; |
|
| 337 | + } |
|
| 310 | 338 | // fall-through for all select-* widgets |
| 311 | 339 | case 'select': |
| 312 | 340 | $this->attrs['multiple'] = $field['rows'] > 1; |
@@ -367,7 +395,10 @@ discard block |
||
| 367 | 395 | $all_readonly = $this->is_readonly($cname, $form_name); |
| 368 | 396 | $value_in = self::get_array($content, $form_name); |
| 369 | 397 | // if we have no id / use self::GLOBAL_ID, we have to set $value_in in global namespace for regular widgets validation to find |
| 370 | - if (!$this->id) $content = array_merge($content, $value_in); |
|
| 398 | + if (!$this->id) |
|
| 399 | + { |
|
| 400 | + $content = array_merge($content, $value_in); |
|
| 401 | + } |
|
| 371 | 402 | //error_log(__METHOD__."($cname, ...) form_name=$form_name, use-private={$this->attrs['use-private']}, value_in=".array2string($value_in)); |
| 372 | 403 | $customfields =& $this->getElementAttribute(self::GLOBAL_VALS, 'customfields'); |
| 373 | 404 | if(is_array($value_in)) |
@@ -392,7 +423,10 @@ discard block |
||
| 392 | 423 | // run validation method of widget implementing this custom field |
| 393 | 424 | $widget = $this->_widget($fname, $field_settings); |
| 394 | 425 | // widget has no validate method, eg. is only displaying stuff --> nothing to validate |
| 395 | - if (!method_exists($widget, 'validate')) continue; |
|
| 426 | + if (!method_exists($widget, 'validate')) |
|
| 427 | + { |
|
| 428 | + continue; |
|
| 429 | + } |
|
| 396 | 430 | $widget->validate($form_name != self::GLOBAL_ID ? $form_name : $cname, $expand, $content, $validated); |
| 397 | 431 | if ($field_settings['needed'] && (is_array($value) ? !$value : (string)$value === '')) |
| 398 | 432 | { |
@@ -401,10 +435,16 @@ discard block |
||
| 401 | 435 | $field_name = $this->id[0] == self::$prefix && $customfields[substr($this->id,1)] ? $this->id : self::form_name($form_name != self::GLOBAL_ID ? $form_name : $cname, $field); |
| 402 | 436 | $valid =& self::get_array($validated, $field_name, true); |
| 403 | 437 | |
| 404 | - if (is_array($valid)) $valid = implode(',', $valid); |
|
| 438 | + if (is_array($valid)) |
|
| 439 | + { |
|
| 440 | + $valid = implode(',', $valid); |
|
| 441 | + } |
|
| 405 | 442 | // NULL is valid for most fields, but not custom fields due to backend handling |
| 406 | 443 | // See so_sql_cf->save() |
| 407 | - if (is_null($valid)) $valid = false; |
|
| 444 | + if (is_null($valid)) |
|
| 445 | + { |
|
| 446 | + $valid = false; |
|
| 447 | + } |
|
| 408 | 448 | //error_log(__METHOD__."() $field_name: ".array2string($value).' --> '.array2string($valid)); |
| 409 | 449 | } |
| 410 | 450 | } |
@@ -412,7 +452,10 @@ discard block |
||
| 412 | 452 | { |
| 413 | 453 | // Transformation doesn't handle validation |
| 414 | 454 | $valid =& self::get_array($validated, $this->id ? $form_name : $field, true); |
| 415 | - if (true) $valid = $value_in; |
|
| 455 | + if (true) |
|
| 456 | + { |
|
| 457 | + $valid = $value_in; |
|
| 458 | + } |
|
| 416 | 459 | //error_log(__METHOD__."() $form_name $field: ".array2string($value).' --> '.array2string($value)); |
| 417 | 460 | } |
| 418 | 461 | } |
@@ -148,9 +148,15 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | public function get_contact($value, array $attrs) |
| 150 | 150 | { |
| 151 | - if (is_array($value) && !(array_key_exists('app',$value) && array_key_exists('id', $value))) return $value; |
|
| 151 | + if (is_array($value) && !(array_key_exists('app',$value) && array_key_exists('id', $value))) |
|
| 152 | + { |
|
| 153 | + return $value; |
|
| 154 | + } |
|
| 152 | 155 | |
| 153 | - if(is_array($value) && array_key_exists('app', $value) && array_key_exists('id', $value)) $value = $value['id']; |
|
| 156 | + if(is_array($value) && array_key_exists('app', $value) && array_key_exists('id', $value)) |
|
| 157 | + { |
|
| 158 | + $value = $value['id']; |
|
| 159 | + } |
|
| 154 | 160 | switch($attrs['type']) |
| 155 | 161 | { |
| 156 | 162 | case 'contact-account': |
@@ -162,7 +168,11 @@ discard block |
||
| 162 | 168 | // fall-through |
| 163 | 169 | case 'contact-value': |
| 164 | 170 | default: |
| 165 | - if (substr($value,0,12) == 'addressbook:') $value = substr($value,12); // link-entry syntax |
|
| 171 | + if (substr($value,0,12) == 'addressbook:') |
|
| 172 | + { |
|
| 173 | + $value = substr($value,12); |
|
| 174 | + } |
|
| 175 | + // link-entry syntax |
|
| 166 | 176 | if (!($contact = $this->contacts->read($value))) |
| 167 | 177 | { |
| 168 | 178 | $contact = array(); |
@@ -27,7 +27,10 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | public function __construct($xml='') |
| 29 | 29 | { |
| 30 | - if($xml) parent::__construct($xml); |
|
| 30 | + if($xml) |
|
| 31 | + { |
|
| 32 | + parent::__construct($xml); |
|
| 33 | + } |
|
| 31 | 34 | } |
| 32 | 35 | |
| 33 | 36 | /** |
@@ -64,9 +67,15 @@ discard block |
||
| 64 | 67 | } |
| 65 | 68 | $value =& self::get_array(self::$request->content, $form_name, true); |
| 66 | 69 | $path = Api\Link::vfs_path($app,$id,'',true); |
| 67 | - if (!empty($relpath)) $path .= '/'.$relpath; |
|
| 70 | + if (!empty($relpath)) |
|
| 71 | + { |
|
| 72 | + $path .= '/'.$relpath; |
|
| 73 | + } |
|
| 68 | 74 | |
| 69 | - if (true) $value = array(); |
|
| 75 | + if (true) |
|
| 76 | + { |
|
| 77 | + $value = array(); |
|
| 78 | + } |
|
| 70 | 79 | |
| 71 | 80 | // Single file, already existing |
| 72 | 81 | if (substr($path,-1) != '/' && Api\Vfs::file_exists($path) && !Api\Vfs::is_dir($path)) |
@@ -194,7 +203,10 @@ discard block |
||
| 194 | 203 | $replace[substr($link['id']['tmp_name'], strlen(Api\Vfs::PREFIX))] = |
| 195 | 204 | Api\Link::vfs_path($app, $id, Api\Vfs::basename($link['id']['tmp_name']), true); |
| 196 | 205 | |
| 197 | - if (!in_array($matches[1], $remove_dir)) $remove_dir[] = $matches[1]; |
|
| 206 | + if (!in_array($matches[1], $remove_dir)) |
|
| 207 | + { |
|
| 208 | + $remove_dir[] = $matches[1]; |
|
| 209 | + } |
|
| 198 | 210 | } |
| 199 | 211 | } |
| 200 | 212 | if ($replace) |
@@ -218,7 +230,10 @@ discard block |
||
| 218 | 230 | */ |
| 219 | 231 | static function get_temp_dir($app, $postfix=null) |
| 220 | 232 | { |
| 221 | - if (!isset($postfix)) $postfix = md5(time().session_id()); |
|
| 233 | + if (!isset($postfix)) |
|
| 234 | + { |
|
| 235 | + $postfix = md5(time().session_id()); |
|
| 236 | + } |
|
| 222 | 237 | |
| 223 | 238 | return '/home/'.$GLOBALS['egw_info']['user']['account_lid'].'/.tmp/'.$app.'_'.$postfix; |
| 224 | 239 | } |
@@ -245,10 +260,13 @@ discard block |
||
| 245 | 260 | { |
| 246 | 261 | // add extension to path |
| 247 | 262 | $parts = explode('.',$filename); |
| 248 | - if (($extension = array_pop($parts)) && Api\MimeMagic::ext2mime($extension)) // really an extension --> add it to path |
|
| 263 | + if (($extension = array_pop($parts)) && Api\MimeMagic::ext2mime($extension)) |
|
| 264 | + { |
|
| 265 | + // really an extension --> add it to path |
|
| 249 | 266 | { |
| 250 | 267 | $path .= '.'.$extension; |
| 251 | 268 | } |
| 269 | + } |
|
| 252 | 270 | } |
| 253 | 271 | else // multiple upload with dir given (trailing slash) |
| 254 | 272 | { |
@@ -294,7 +312,10 @@ discard block |
||
| 294 | 312 | switch($this->type) |
| 295 | 313 | { |
| 296 | 314 | case 'vfs-upload': |
| 297 | - if(!is_array($value)) $value = array(); |
|
| 315 | + if(!is_array($value)) |
|
| 316 | + { |
|
| 317 | + $value = array(); |
|
| 318 | + } |
|
| 298 | 319 | /* Check & skip files that made it asyncronously |
| 299 | 320 | list($app,$id,$relpath) = explode(':',$this->id,3); |
| 300 | 321 | //... |
@@ -305,7 +326,10 @@ discard block |
||
| 305 | 326 | parent::validate($cname, $content, $validated); |
| 306 | 327 | break; |
| 307 | 328 | } |
| 308 | - if (true) $valid = $value; |
|
| 329 | + if (true) |
|
| 330 | + { |
|
| 331 | + $valid = $value; |
|
| 332 | + } |
|
| 309 | 333 | } |
| 310 | 334 | |
| 311 | 335 | /** |
@@ -317,14 +341,20 @@ discard block |
||
| 317 | 341 | if (empty($id) || $id == 'undefined') |
| 318 | 342 | { |
| 319 | 343 | static $tmppath = array(); // static var, so all vfs-uploads get created in the same temporary dir |
| 320 | - if (!isset($tmppath[$app])) $tmppath[$app] = self::get_temp_dir ($app); |
|
| 344 | + if (!isset($tmppath[$app])) |
|
| 345 | + { |
|
| 346 | + $tmppath[$app] = self::get_temp_dir ($app); |
|
| 347 | + } |
|
| 321 | 348 | $path = $tmppath[$app]; |
| 322 | 349 | } |
| 323 | 350 | else |
| 324 | 351 | { |
| 325 | 352 | $path = Api\Link::vfs_path($app,$id,'',true); |
| 326 | 353 | } |
| 327 | - if (!empty($relpath)) $path .= '/'.$relpath; |
|
| 354 | + if (!empty($relpath)) |
|
| 355 | + { |
|
| 356 | + $path .= '/'.$relpath; |
|
| 357 | + } |
|
| 328 | 358 | return $path; |
| 329 | 359 | } |
| 330 | 360 | } |
@@ -81,7 +81,8 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | public function __construct($xml = '') |
| 83 | 83 | { |
| 84 | - if($xml) { |
|
| 84 | + if($xml) |
|
| 85 | + { |
|
| 85 | 86 | parent::__construct($xml); |
| 86 | 87 | } |
| 87 | 88 | } |
@@ -144,21 +145,33 @@ discard block |
||
| 144 | 145 | // add option children's values too, "" is not read, therefore we cast to string |
| 145 | 146 | foreach($this->children as $child) |
| 146 | 147 | { |
| 147 | - if ($child->type == 'option') $allowed[] = (string)$child->attrs['value']; |
|
| 148 | + if ($child->type == 'option') |
|
| 149 | + { |
|
| 150 | + $allowed[] = (string)$child->attrs['value']; |
|
| 151 | + } |
|
| 148 | 152 | } |
| 149 | 153 | |
| 150 | - if (!$this->attrs['multiple'] || !($this->attrs['options'] > 1)) $allowed[] = ''; |
|
| 154 | + if (!$this->attrs['multiple'] || !($this->attrs['options'] > 1)) |
|
| 155 | + { |
|
| 156 | + $allowed[] = ''; |
|
| 157 | + } |
|
| 151 | 158 | |
| 152 | 159 | foreach((array) $value as $val) |
| 153 | 160 | { |
| 154 | 161 | // handle empty-label for all widget types |
| 155 | - if ((string)$val === '' && in_array('', $allowed)) continue; |
|
| 162 | + if ((string)$val === '' && in_array('', $allowed)) |
|
| 163 | + { |
|
| 164 | + continue; |
|
| 165 | + } |
|
| 156 | 166 | |
| 157 | 167 | switch ($widget_type) |
| 158 | 168 | { |
| 159 | 169 | case 'select-account': |
| 160 | 170 | // If in allowed options, skip account check to support app-specific options |
| 161 | - if(count($allowed) > 0 && in_array($val,$allowed)) continue; |
|
| 171 | + if(count($allowed) > 0 && in_array($val,$allowed)) |
|
| 172 | + { |
|
| 173 | + continue; |
|
| 174 | + } |
|
| 162 | 175 | |
| 163 | 176 | // validate accounts independent of options know to server |
| 164 | 177 | $account_type = $this->attrs['account_type'] ? $this->attrs['account_type'] : 'accounts'; |
@@ -169,8 +182,7 @@ discard block |
||
| 169 | 182 | in_array($account_type, array('owngroups', 'memberships')) && |
| 170 | 183 | !in_array($val, $GLOBALS['egw']->accounts->memberships( |
| 171 | 184 | $GLOBALS['egw_info']['user']['account_id'], true)) |
| 172 | - ) |
|
| 173 | - { |
|
| 185 | + ) { |
|
| 174 | 186 | self::set_validation_error($form_name, lang("'%1' is NOT allowed ('%2')!", $val, |
| 175 | 187 | !$type?'not found' : ($type == 1 ? 'user' : 'group')),''); |
| 176 | 188 | $value = ''; |
@@ -230,10 +242,13 @@ discard block |
||
| 230 | 242 | { |
| 231 | 243 | $value = array_merge($value, (array)self::$request->preserv[$unavailable_name]); |
| 232 | 244 | } |
| 233 | - elseif(!$value) // for single cat, we only restore unavailable one, if no other was selected |
|
| 245 | + elseif(!$value) |
|
| 246 | + { |
|
| 247 | + // for single cat, we only restore unavailable one, if no other was selected |
|
| 234 | 248 | { |
| 235 | 249 | $value = self::$request->preserv[$unavailable_name]; |
| 236 | 250 | } |
| 251 | + } |
|
| 237 | 252 | } |
| 238 | 253 | } |
| 239 | 254 | if (isset($value)) |
@@ -258,10 +273,13 @@ discard block |
||
| 258 | 273 | { |
| 259 | 274 | //error_log(__METHOD__."('$cname') this->id=$this->id, this->type=$this->type, this->attrs=".array2string($this->attrs)); |
| 260 | 275 | $matches = null; |
| 261 | - if ($cname == '$row') // happens eg. with custom-fields: $cname='$row', this->id='#something' |
|
| 276 | + if ($cname == '$row') |
|
| 277 | + { |
|
| 278 | + // happens eg. with custom-fields: $cname='$row', this->id='#something' |
|
| 262 | 279 | { |
| 263 | 280 | $form_name = $this->id; |
| 264 | 281 | } |
| 282 | + } |
|
| 265 | 283 | // happens with fields in nm-header: $cname='nm', this->id='${row}[something]' or '{$row}[something]' |
| 266 | 284 | elseif (preg_match('/(\${row}|{\$row})\[([^]]+)\]$/', $this->id, $matches)) |
| 267 | 285 | { |
@@ -281,7 +299,10 @@ discard block |
||
| 281 | 299 | { |
| 282 | 300 | $form_name = self::form_name($cname, $this->id, $expand); |
| 283 | 301 | } |
| 284 | - if (!is_array(self::$request->sel_options[$form_name])) self::$request->sel_options[$form_name] = array(); |
|
| 302 | + if (!is_array(self::$request->sel_options[$form_name])) |
|
| 303 | + { |
|
| 304 | + self::$request->sel_options[$form_name] = array(); |
|
| 305 | + } |
|
| 285 | 306 | $type = $this->attrs['type'] ? $this->attrs['type'] : $this->type; |
| 286 | 307 | if ($type != 'select' && $type != 'menupopup') |
| 287 | 308 | { |
@@ -380,7 +401,10 @@ discard block |
||
| 380 | 401 | if(is_array($label)) |
| 381 | 402 | { |
| 382 | 403 | self::fix_encoded_options($label, false); |
| 383 | - if ($use_array_of_objects && !array_key_exists('value', $label)) $label['value'] = $value; |
|
| 404 | + if ($use_array_of_objects && !array_key_exists('value', $label)) |
|
| 405 | + { |
|
| 406 | + $label['value'] = $value; |
|
| 407 | + } |
|
| 384 | 408 | } |
| 385 | 409 | else |
| 386 | 410 | { |
@@ -607,13 +631,27 @@ discard block |
||
| 607 | 631 | |
| 608 | 632 | case 'select-year': // options: #rows,#before(default=3),#after(default=2) |
| 609 | 633 | $options[''] = ''; |
| 610 | - if ($type <= 0) $type = 3; |
|
| 611 | - if ($type2 <= 0) $type2 = 2; |
|
| 612 | - if ($type > 100 && $type2 > 100 && $type > $type) { $y = $type; $type=$type2; $type2=$y; } |
|
| 634 | + if ($type <= 0) |
|
| 635 | + { |
|
| 636 | + $type = 3; |
|
| 637 | + } |
|
| 638 | + if ($type2 <= 0) |
|
| 639 | + { |
|
| 640 | + $type2 = 2; |
|
| 641 | + } |
|
| 642 | + if ($type > 100 && $type2 > 100 && $type > $type) |
|
| 643 | + { |
|
| 644 | +$y = $type; $type=$type2; $type2=$y; } |
|
| 613 | 645 | $y = date('Y')-$type; |
| 614 | - if ($value && $value-$type < $y || $type > 100) $y = $type > 100 ? $type : $value-$type; |
|
| 646 | + if ($value && $value-$type < $y || $type > 100) |
|
| 647 | + { |
|
| 648 | + $y = $type > 100 ? $type : $value-$type; |
|
| 649 | + } |
|
| 615 | 650 | $to = date('Y')+$type2; |
| 616 | - if ($value && $value+$type2 > $to || $type2 > 100) $to = $type2 > 100 ? $type2 : $value+$type2; |
|
| 651 | + if ($value && $value+$type2 > $to || $type2 > 100) |
|
| 652 | + { |
|
| 653 | + $to = $type2 > 100 ? $type2 : $value+$type2; |
|
| 654 | + } |
|
| 617 | 655 | for ($n = 0; $y <= $to && $n < 200; ++$n) |
| 618 | 656 | { |
| 619 | 657 | $options[$y] = $y++; |
@@ -651,8 +689,14 @@ discard block |
||
| 651 | 689 | MCAL_M_WEEKEND => 'weekend', |
| 652 | 690 | ); |
| 653 | 691 | } |
| 654 | - if ($weekstart == 'Saturday') $options[MCAL_M_SATURDAY] = 'saturday'; |
|
| 655 | - if ($weekstart != 'Monday') $options[MCAL_M_SUNDAY] = 'sunday'; |
|
| 692 | + if ($weekstart == 'Saturday') |
|
| 693 | + { |
|
| 694 | + $options[MCAL_M_SATURDAY] = 'saturday'; |
|
| 695 | + } |
|
| 696 | + if ($weekstart != 'Monday') |
|
| 697 | + { |
|
| 698 | + $options[MCAL_M_SUNDAY] = 'sunday'; |
|
| 699 | + } |
|
| 656 | 700 | $options += array( |
| 657 | 701 | MCAL_M_MONDAY => 'monday', |
| 658 | 702 | MCAL_M_TUESDAY => 'tuesday', |
@@ -660,8 +704,14 @@ discard block |
||
| 660 | 704 | MCAL_M_THURSDAY => 'thursday', |
| 661 | 705 | MCAL_M_FRIDAY => 'friday', |
| 662 | 706 | ); |
| 663 | - if ($weekstart != 'Saturday') $options[MCAL_M_SATURDAY] = 'saturday'; |
|
| 664 | - if ($weekstart == 'Monday') $options[MCAL_M_SUNDAY] = 'sunday'; |
|
| 707 | + if ($weekstart != 'Saturday') |
|
| 708 | + { |
|
| 709 | + $options[MCAL_M_SATURDAY] = 'saturday'; |
|
| 710 | + } |
|
| 711 | + if ($weekstart == 'Monday') |
|
| 712 | + { |
|
| 713 | + $options[MCAL_M_SUNDAY] = 'sunday'; |
|
| 714 | + } |
|
| 665 | 715 | if ($rows >= 2 && $type == 1) |
| 666 | 716 | { |
| 667 | 717 | $options += array( |
@@ -698,16 +748,22 @@ discard block |
||
| 698 | 748 | $type = $type === '' ? 1 : intval($type); // min |
| 699 | 749 | $type2 = $type2 === '' ? 10 : intval($type2); // max |
| 700 | 750 | $format = '%d'; |
| 701 | - if (!empty($type3) && $type3[0] == '0') // leading zero |
|
| 751 | + if (!empty($type3) && $type3[0] == '0') |
|
| 752 | + { |
|
| 753 | + // leading zero |
|
| 702 | 754 | { |
| 703 | 755 | $format = '%0'.strlen($type3).'d'; |
| 704 | 756 | } |
| 757 | + } |
|
| 705 | 758 | $type3 = !$type3 ? 1 : intval($type3); // decrement |
| 706 | 759 | if (($type <= $type2) != ($type3 > 0)) |
| 707 | 760 | { |
| 708 | 761 | $type3 = -$type3; // void infinite loop |
| 709 | 762 | } |
| 710 | - if (!empty($type4)) $format .= lang($type4); |
|
| 763 | + if (!empty($type4)) |
|
| 764 | + { |
|
| 765 | + $format .= lang($type4); |
|
| 766 | + } |
|
| 711 | 767 | for ($i=0,$n=$type; $n <= $type2 && $i <= 100; $n += $type3,++$i) |
| 712 | 768 | { |
| 713 | 769 | $options[$n] = sprintf($format,$n); |
@@ -741,10 +797,13 @@ discard block |
||
| 741 | 797 | { |
| 742 | 798 | $value = calendar_timezones::id2tz($value); |
| 743 | 799 | } |
| 744 | - if ($readonly) // for readonly we dont need to fetch all TZ's |
|
| 800 | + if ($readonly) |
|
| 801 | + { |
|
| 802 | + // for readonly we dont need to fetch all TZ's |
|
| 745 | 803 | { |
| 746 | 804 | $options[$value] = calendar_timezones::tz2id($value,'name'); |
| 747 | 805 | } |
| 806 | + } |
|
| 748 | 807 | else |
| 749 | 808 | { |
| 750 | 809 | $options = $type ? Api\DateTime::getTimezones() : Api\DateTime::getUserTimezones($value); |
@@ -816,7 +875,10 @@ discard block |
||
| 816 | 875 | if (!is_array($acc)) |
| 817 | 876 | { |
| 818 | 877 | $data = $GLOBALS['egw']->accounts->get_account_data($id); |
| 819 | - if (!isset($data[$id])) return '#'.$id; |
|
| 878 | + if (!isset($data[$id])) |
|
| 879 | + { |
|
| 880 | + return '#'.$id; |
|
| 881 | + } |
|
| 820 | 882 | foreach(array('type','lid','firstname','lastname') as $name) |
| 821 | 883 | { |
| 822 | 884 | $acc['account_'.$name] = $data[$id][$name]; |
@@ -844,7 +906,8 @@ discard block |
||
| 844 | 906 | $acc['account_firstname'],$acc['account_lastname']); |
| 845 | 907 | break; |
| 846 | 908 | } |
| 847 | - if($show_type) { |
|
| 909 | + if($show_type) |
|
| 910 | + { |
|
| 848 | 911 | $info = array( |
| 849 | 912 | 'label' => $info, |
| 850 | 913 | 'icon' => $acc['account_type'] == 'g' ? 'addressbook/group' : 'user' |
@@ -49,7 +49,10 @@ discard block |
||
| 49 | 49 | $old_cname = $params[0]; |
| 50 | 50 | $old_expand = $params[1]; |
| 51 | 51 | |
| 52 | - if ($this->id && $this->type != 'groupbox') $cname = self::form_name($cname, $this->id, $params[1]); |
|
| 52 | + if ($this->id && $this->type != 'groupbox') |
|
| 53 | + { |
|
| 54 | + $cname = self::form_name($cname, $this->id, $params[1]); |
|
| 55 | + } |
|
| 53 | 56 | if ($expand['cname'] !== $cname && $cname) |
| 54 | 57 | { |
| 55 | 58 | $expand['cont'] =& self::get_array(self::$request->content, $cname); |
@@ -121,10 +124,13 @@ discard block |
||
| 121 | 124 | // need to break if fname ends in [] as get_array() will ignore it and returns whole array |
| 122 | 125 | // for an id like "run[$row_cont[appname]]" |
| 123 | 126 | substr($fname, -2) != '[]' && |
| 124 | - ($value = self::get_array(self::$request->content, $fname)) !== null) // null = not found (can be false!) |
|
| 127 | + ($value = self::get_array(self::$request->content, $fname)) !== null) |
|
| 128 | + { |
|
| 129 | + // null = not found (can be false!) |
|
| 125 | 130 | { |
| 126 | 131 | //error_log(__METHOD__."($widget,$cname) $this autorepeating row $expand[row] because of $check_widget->id = '$fname' is ".array2string($value)); |
| 127 | 132 | unset($value); |
| 133 | + } |
|
| 128 | 134 | return true; |
| 129 | 135 | } |
| 130 | 136 | } |
@@ -29,10 +29,13 @@ |
||
| 29 | 29 | public function beforeSendToClient($cname, array $expand=null) |
| 30 | 30 | { |
| 31 | 31 | $matches = null; |
| 32 | - if ($cname == '$row') // happens eg. with custom-fields: $cname='$row', this->id='#something' |
|
| 32 | + if ($cname == '$row') |
|
| 33 | + { |
|
| 34 | + // happens eg. with custom-fields: $cname='$row', this->id='#something' |
|
| 33 | 35 | { |
| 34 | 36 | $form_name = $this->id; |
| 35 | 37 | } |
| 38 | + } |
|
| 36 | 39 | // happens with fields in nm-header: $cname='nm', this->id='${row}[something]' or '{$row}[something]' |
| 37 | 40 | elseif (preg_match('/(\${row}|{\$row})\[([^]]+)\]$/', $this->id, $matches)) |
| 38 | 41 | { |
@@ -37,7 +37,8 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public function __construct($xml = '') |
| 39 | 39 | { |
| 40 | - if($xml) { |
|
| 40 | + if($xml) |
|
| 41 | + { |
|
| 41 | 42 | parent::__construct($xml); |
| 42 | 43 | } |
| 43 | 44 | } |
@@ -85,14 +86,18 @@ discard block |
||
| 85 | 86 | |
| 86 | 87 | |
| 87 | 88 | // ToDo: implement on client-side |
| 88 | - if (!$attrs['help']) self::setElementAttribute($form_name, 'help', 'view this linked entry in its application'); |
|
| 89 | + if (!$attrs['help']) |
|
| 90 | + { |
|
| 91 | + self::setElementAttribute($form_name, 'help', 'view this linked entry in its application'); |
|
| 92 | + } |
|
| 89 | 93 | |
| 90 | 94 | if($attrs['type'] == 'link-list') |
| 91 | 95 | { |
| 92 | 96 | $app = $value['to_app']; |
| 93 | 97 | $id = $value['to_id']; |
| 94 | 98 | $links = Api\Link::get_links($app,$id,'','link_lastmod DESC',true, $value['show_deleted']); |
| 95 | - foreach($links as $link) { |
|
| 99 | + foreach($links as $link) |
|
| 100 | + { |
|
| 96 | 101 | $value[] = $link; |
| 97 | 102 | } |
| 98 | 103 | } |
@@ -104,7 +109,10 @@ discard block |
||
| 104 | 109 | public static function ajax_link_search($app, $type, $pattern, $options=array()) |
| 105 | 110 | { |
| 106 | 111 | $options['type'] = $type ? $type : $options['type']; |
| 107 | - if(!$options['num_rows']) $options['num_rows'] = 1000; |
|
| 112 | + if(!$options['num_rows']) |
|
| 113 | + { |
|
| 114 | + $options['num_rows'] = 1000; |
|
| 115 | + } |
|
| 108 | 116 | |
| 109 | 117 | $links = Api\Link::query($app, $pattern, $options); |
| 110 | 118 | |
@@ -160,8 +168,10 @@ discard block |
||
| 160 | 168 | public static function ajax_link($app, $id, Array $links) |
| 161 | 169 | { |
| 162 | 170 | // Files need to know full path in tmp directory |
| 163 | - foreach($links as $key => $link) { |
|
| 164 | - if($link['app'] == Api\Link::VFS_APPNAME) { |
|
| 171 | + foreach($links as $key => $link) |
|
| 172 | + { |
|
| 173 | + if($link['app'] == Api\Link::VFS_APPNAME) |
|
| 174 | + { |
|
| 165 | 175 | if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir'])) |
| 166 | 176 | { |
| 167 | 177 | $path = $GLOBALS['egw_info']['server']['temp_dir'] . '/' . $link['id']; |
@@ -253,7 +263,10 @@ discard block |
||
| 253 | 263 | $id .= "/$dest_file"; |
| 254 | 264 | } |
| 255 | 265 | |
| 256 | - if(!is_array($files)) $files = array($files); |
|
| 266 | + if(!is_array($files)) |
|
| 267 | + { |
|
| 268 | + $files = array($files); |
|
| 269 | + } |
|
| 257 | 270 | foreach($files as $target) |
| 258 | 271 | { |
| 259 | 272 | Api\Link::link_file($app, $id, $target); |
@@ -340,7 +353,10 @@ discard block |
||
| 340 | 353 | else |
| 341 | 354 | { |
| 342 | 355 | // Not enough information, leave it to the application |
| 343 | - if(!is_array($value['to_id'])) $value['to_id'] = array(); |
|
| 356 | + if(!is_array($value['to_id'])) |
|
| 357 | + { |
|
| 358 | + $value['to_id'] = array(); |
|
| 359 | + } |
|
| 344 | 360 | $value['to_id'][] = $link; |
| 345 | 361 | } |
| 346 | 362 | } |
@@ -360,7 +376,10 @@ discard block |
||
| 360 | 376 | } |
| 361 | 377 | foreach($files as $name => $attrs) |
| 362 | 378 | { |
| 363 | - if(!is_array($value['to_id'])) $value['to_id'] = array(); |
|
| 379 | + if(!is_array($value['to_id'])) |
|
| 380 | + { |
|
| 381 | + $value['to_id'] = array(); |
|
| 382 | + } |
|
| 364 | 383 | $value['to_id'][] = array( |
| 365 | 384 | 'app' => Api\Link::VFS_APPNAME, |
| 366 | 385 | 'id' => array( |
@@ -372,7 +391,10 @@ discard block |
||
| 372 | 391 | } |
| 373 | 392 | } |
| 374 | 393 | $valid =& self::get_array($validated, $form_name, true); |
| 375 | - if (true) $valid = $value; |
|
| 394 | + if (true) |
|
| 395 | + { |
|
| 396 | + $valid = $value; |
|
| 397 | + } |
|
| 376 | 398 | //error_log($this); |
| 377 | 399 | //error_log(" " . array2string($valid)); |
| 378 | 400 | } |