@@ -91,7 +91,7 @@ |
||
| 91 | 91 | /** |
| 92 | 92 | * Entries for filemanagers's admin menu |
| 93 | 93 | * |
| 94 | - * @param string|array $location ='admin' hook name or params |
|
| 94 | + * @param string $location ='admin' hook name or params |
|
| 95 | 95 | */ |
| 96 | 96 | static function admin($location = 'admin') |
| 97 | 97 | { |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | ); |
| 106 | 106 | if ($location == 'admin') |
| 107 | 107 | { |
| 108 | - display_section(self::$appname,$file); |
|
| 108 | + display_section(self::$appname,$file); |
|
| 109 | 109 | } |
| 110 | 110 | else |
| 111 | 111 | { |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | 'yes' => lang('Yes') |
| 129 | 129 | ); |
| 130 | 130 | |
| 131 | - $settings = array( |
|
| 131 | + $settings = array( |
|
| 132 | 132 | 'startfolder' => array( |
| 133 | 133 | 'type' => 'input', |
| 134 | 134 | 'name' => 'startfolder', |
@@ -85,7 +85,10 @@ discard block |
||
| 85 | 85 | $file['Shared files'] = Egw::link('/index.php','menuaction=filemanager.filemanager_shares.index&ajax=true'); |
| 86 | 86 | display_sidebox(self::$appname,$title,$file); |
| 87 | 87 | } |
| 88 | - if ($GLOBALS['egw_info']['user']['apps']['admin']) self::admin(self::$appname); |
|
| 88 | + if ($GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 89 | + { |
|
| 90 | + self::admin(self::$appname); |
|
| 91 | + } |
|
| 89 | 92 | } |
| 90 | 93 | |
| 91 | 94 | /** |
@@ -95,7 +98,10 @@ discard block |
||
| 95 | 98 | */ |
| 96 | 99 | static function admin($location = 'admin') |
| 97 | 100 | { |
| 98 | - if (is_array($location)) $location = $location['location']; |
|
| 101 | + if (is_array($location)) |
|
| 102 | + { |
|
| 103 | + $location = $location['location']; |
|
| 104 | + } |
|
| 99 | 105 | |
| 100 | 106 | $file = Array( |
| 101 | 107 | //'Site Configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname='.self::$appname.'&ajax=true'), |
@@ -36,12 +36,12 @@ discard block |
||
| 36 | 36 | $basepath = '/home'; |
| 37 | 37 | $homepath = '/home/'.$GLOBALS['egw_info']['user']['account_lid']; |
| 38 | 38 | //echo "<p>admin_prefs_sidebox_hooks::all_hooks(".print_r($args,True).") appname='$appname', location='$location'</p>\n"; |
| 39 | - $file_prefs = &$GLOBALS['egw_info']['user']['preferences'][self::$appname]; |
|
| 39 | + $file_prefs = &$GLOBALS['egw_info']['user']['preferences'][self::$appname]; |
|
| 40 | 40 | if ($location == 'sidebox_menu') |
| 41 | 41 | { |
| 42 | - $title = $GLOBALS['egw_info']['apps'][self::$appname]['title'] . ' '. lang('Menu'); |
|
| 42 | + $title = $GLOBALS['egw_info']['apps'][self::$appname]['title'].' '.lang('Menu'); |
|
| 43 | 43 | $file = array(); |
| 44 | - if($GLOBALS['egw_info']['apps']['stylite']) |
|
| 44 | + if ($GLOBALS['egw_info']['apps']['stylite']) |
|
| 45 | 45 | { |
| 46 | 46 | // add "file a file" (upload) dialog |
| 47 | 47 | $file[] = array( |
@@ -54,9 +54,9 @@ discard block |
||
| 54 | 54 | // add selection for available views, if we have more then one |
| 55 | 55 | if (count(filemanager_ui::init_views()) > 1) |
| 56 | 56 | { |
| 57 | - $index_url = Egw::link('/index.php',array('menuaction' => 'filemanager.filemanager_ui.index'),false); |
|
| 57 | + $index_url = Egw::link('/index.php', array('menuaction' => 'filemanager.filemanager_ui.index'), false); |
|
| 58 | 58 | $file[] = array( |
| 59 | - 'text' => Api\Html::select('filemanager_view',filemanager_ui::get_view(),filemanager_ui::$views,false, |
|
| 59 | + 'text' => Api\Html::select('filemanager_view', filemanager_ui::get_view(), filemanager_ui::$views, false, |
|
| 60 | 60 | ' onchange="'."egw_appWindow('filemanager').location='$index_url&view='+this.value;". |
| 61 | 61 | '" style="width: 100%;"'), |
| 62 | 62 | 'no_lang' => True, |
@@ -65,23 +65,23 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | if ($file_prefs['showhome'] != 'no') |
| 67 | 67 | { |
| 68 | - $file['Your home directory'] = Egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$homepath,'ajax'=>'true')); |
|
| 68 | + $file['Your home directory'] = Egw::link('/index.php', array('menuaction'=>self::$appname.'.filemanager_ui.index', 'path'=>$homepath, 'ajax'=>'true')); |
|
| 69 | 69 | } |
| 70 | 70 | if ($file_prefs['showusers'] != 'no') |
| 71 | 71 | { |
| 72 | - $file['Users and groups'] = Egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$basepath,'ajax'=>'true')); |
|
| 72 | + $file['Users and groups'] = Egw::link('/index.php', array('menuaction'=>self::$appname.'.filemanager_ui.index', 'path'=>$basepath, 'ajax'=>'true')); |
|
| 73 | 73 | } |
| 74 | - if (!empty($file_prefs['showbase']) && $file_prefs['showbase']=='yes') |
|
| 74 | + if (!empty($file_prefs['showbase']) && $file_prefs['showbase'] == 'yes') |
|
| 75 | 75 | { |
| 76 | - $file['Basedirectory'] = Egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$rootpath,'ajax'=>'true')); |
|
| 76 | + $file['Basedirectory'] = Egw::link('/index.php', array('menuaction'=>self::$appname.'.filemanager_ui.index', 'path'=>$rootpath, 'ajax'=>'true')); |
|
| 77 | 77 | } |
| 78 | 78 | if (!empty($file_prefs['startfolder'])) |
| 79 | 79 | { |
| 80 | - $file['Startfolder']= Egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$file_prefs['startfolder'],'ajax'=>'true')); |
|
| 80 | + $file['Startfolder'] = Egw::link('/index.php', array('menuaction'=>self::$appname.'.filemanager_ui.index', 'path'=>$file_prefs['startfolder'], 'ajax'=>'true')); |
|
| 81 | 81 | } |
| 82 | - $file['Placeholders'] = Egw::link('/index.php','menuaction=filemanager.filemanager_merge.show_replacements'); |
|
| 83 | - $file['Shared files'] = Egw::link('/index.php','menuaction=filemanager.filemanager_shares.index&ajax=true'); |
|
| 84 | - display_sidebox(self::$appname,$title,$file); |
|
| 82 | + $file['Placeholders'] = Egw::link('/index.php', 'menuaction=filemanager.filemanager_merge.show_replacements'); |
|
| 83 | + $file['Shared files'] = Egw::link('/index.php', 'menuaction=filemanager.filemanager_shares.index&ajax=true'); |
|
| 84 | + display_sidebox(self::$appname, $title, $file); |
|
| 85 | 85 | } |
| 86 | 86 | if ($GLOBALS['egw_info']['user']['apps']['admin']) self::admin(self::$appname); |
| 87 | 87 | } |
@@ -97,17 +97,17 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | $file = Array( |
| 99 | 99 | //'Site Configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname='.self::$appname.'&ajax=true'), |
| 100 | - 'Custom fields' => Egw::link('/index.php','menuaction=admin.admin_customfields.index&appname='.self::$appname.'&ajax=true'), |
|
| 101 | - 'Check virtual filesystem' => Egw::link('/index.php','menuaction=filemanager.filemanager_admin.fsck'), |
|
| 100 | + 'Custom fields' => Egw::link('/index.php', 'menuaction=admin.admin_customfields.index&appname='.self::$appname.'&ajax=true'), |
|
| 101 | + 'Check virtual filesystem' => Egw::link('/index.php', 'menuaction=filemanager.filemanager_admin.fsck'), |
|
| 102 | 102 | 'VFS mounts and versioning' => Egw::link('/index.php', 'menuaction=filemanager.filemanager_admin.index'), |
| 103 | 103 | ); |
| 104 | 104 | if ($location == 'admin') |
| 105 | 105 | { |
| 106 | - display_section(self::$appname,$file); |
|
| 106 | + display_section(self::$appname, $file); |
|
| 107 | 107 | } |
| 108 | 108 | else |
| 109 | 109 | { |
| 110 | - display_sidebox(self::$appname,lang('Admin'),$file); |
|
| 110 | + display_sidebox(self::$appname, lang('Admin'), $file); |
|
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | 'type' => 'select', |
| 151 | 151 | 'name' => 'showhome', |
| 152 | 152 | 'values' => $yes_no, |
| 153 | - 'label' => lang('Show link "%1" in side box menu?',lang('Your home directory')), |
|
| 153 | + 'label' => lang('Show link "%1" in side box menu?', lang('Your home directory')), |
|
| 154 | 154 | 'xmlrpc' => True, |
| 155 | 155 | 'admin' => False, |
| 156 | 156 | 'forced' => 'yes', |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | 'type' => 'select', |
| 160 | 160 | 'name' => 'showusers', |
| 161 | 161 | 'values' => $yes_no, |
| 162 | - 'label' => lang('Show link "%1" in side box menu?',lang('Users and groups')), |
|
| 162 | + 'label' => lang('Show link "%1" in side box menu?', lang('Users and groups')), |
|
| 163 | 163 | 'xmlrpc' => True, |
| 164 | 164 | 'admin' => False, |
| 165 | 165 | 'forced' => 'yes', |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | 'size' => 60, |
| 172 | 172 | 'label' => 'Default document to insert entries', |
| 173 | 173 | 'name' => 'default_document', |
| 174 | - 'help' => lang('If you specify a document (full vfs path) here, %1 displays an extra document icon for each entry. That icon allows to download the specified document with the data inserted.',lang('filemanager')).' '. |
|
| 174 | + 'help' => lang('If you specify a document (full vfs path) here, %1 displays an extra document icon for each entry. That icon allows to download the specified document with the data inserted.', lang('filemanager')).' '. |
|
| 175 | 175 | lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'name').' '. |
| 176 | - lang('The following document-types are supported:'). implode(',',Api\Storage\Merge::get_file_extensions()), |
|
| 176 | + lang('The following document-types are supported:').implode(',', Api\Storage\Merge::get_file_extensions()), |
|
| 177 | 177 | 'run_lang' => false, |
| 178 | 178 | 'xmlrpc' => True, |
| 179 | 179 | 'admin' => False, |
@@ -184,8 +184,8 @@ discard block |
||
| 184 | 184 | 'label' => 'Directory with documents to insert entries', |
| 185 | 185 | 'name' => 'document_dir', |
| 186 | 186 | 'help' => lang('If you specify a directory (full vfs path) here, %1 displays an action for each document. That action allows to download the specified document with the %1 data inserted.', lang('filemanager')).' '. |
| 187 | - lang('The document can contain placeholder like {{%1}}, to be replaced with the data.','name').' '. |
|
| 188 | - lang('The following document-types are supported:'). implode(',',Api\Storage\Merge::get_file_extensions()), |
|
| 187 | + lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'name').' '. |
|
| 188 | + lang('The following document-types are supported:').implode(',', Api\Storage\Merge::get_file_extensions()), |
|
| 189 | 189 | 'run_lang' => false, |
| 190 | 190 | 'xmlrpc' => True, |
| 191 | 191 | 'admin' => False, |
@@ -95,7 +95,7 @@ |
||
| 95 | 95 | { |
| 96 | 96 | if (is_array($location)) $location = $location['location']; |
| 97 | 97 | |
| 98 | - $file = Array( |
|
| 98 | + $file = array( |
|
| 99 | 99 | //'Site Configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname='.self::$appname.'&ajax=true'), |
| 100 | 100 | 'Custom fields' => Egw::link('/index.php','menuaction=admin.admin_customfields.index&appname='.self::$appname.'&ajax=true'), |
| 101 | 101 | 'Check virtual filesystem' => Egw::link('/index.php','menuaction=filemanager.filemanager_admin.fsck'), |
@@ -127,8 +127,7 @@ |
||
| 127 | 127 | /** |
| 128 | 128 | * Show files shared |
| 129 | 129 | * |
| 130 | - * @param array $content=null |
|
| 131 | - * @param string $msg='' |
|
| 130 | + * @param array $content |
|
| 132 | 131 | */ |
| 133 | 132 | public function index(array $content=null) |
| 134 | 133 | { |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | $readonlys = null; |
| 90 | 90 | $total = Sharing::so()->get_rows($query, $rows, $readonlys); |
| 91 | 91 | |
| 92 | - foreach($rows as &$row) |
|
| 92 | + foreach ($rows as &$row) |
|
| 93 | 93 | { |
| 94 | 94 | if (substr($row['share_path'], 0, strlen(self::$tmp_dir)) === self::$tmp_dir) |
| 95 | 95 | { |
@@ -130,21 +130,21 @@ discard block |
||
| 130 | 130 | * @param array $content=null |
| 131 | 131 | * @param string $msg='' |
| 132 | 132 | */ |
| 133 | - public function index(array $content=null) |
|
| 133 | + public function index(array $content = null) |
|
| 134 | 134 | { |
| 135 | 135 | if (!is_array($content)) |
| 136 | 136 | { |
| 137 | 137 | $content = array( |
| 138 | 138 | 'nm' => array( |
| 139 | - 'get_rows' => 'filemanager.filemanager_shares.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
| 140 | - 'no_filter' => True, // current dir only |
|
| 141 | - 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
| 142 | - 'no_cat' => True, // I disable the cat-selectbox |
|
| 143 | - 'lettersearch' => false, // I show a lettersearch |
|
| 144 | - 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
| 145 | - 'start' => 0, // IO position in list |
|
| 146 | - 'order' => 'share_created', // IO name of the column to sort after (optional for the sortheaders) |
|
| 147 | - 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 139 | + 'get_rows' => 'filemanager.filemanager_shares.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
| 140 | + 'no_filter' => True, // current dir only |
|
| 141 | + 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
| 142 | + 'no_cat' => True, // I disable the cat-selectbox |
|
| 143 | + 'lettersearch' => false, // I show a lettersearch |
|
| 144 | + 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
| 145 | + 'start' => 0, // IO position in list |
|
| 146 | + 'order' => 'share_created', // IO name of the column to sort after (optional for the sortheaders) |
|
| 147 | + 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 148 | 148 | //'default_cols' => '!', // I columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns |
| 149 | 149 | 'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, |
| 150 | 150 | //or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type) |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | } |
| 157 | 157 | elseif ($content['nm']['action']) |
| 158 | 158 | { |
| 159 | - switch($content['nm']['action']) |
|
| 159 | + switch ($content['nm']['action']) |
|
| 160 | 160 | { |
| 161 | 161 | case 'delete': |
| 162 | 162 | $where = array('share_owner' => $GLOBALS['egw_info']['user']['account_id']); |
@@ -101,7 +101,10 @@ |
||
| 101 | 101 | $row['type'] = $row['share_writable'] ? Sharing::WRITABLE : Sharing::READONLY; |
| 102 | 102 | } |
| 103 | 103 | $row['share_passwd'] = (boolean)$row['share_passwd']; |
| 104 | - if ($row['share_with']) $row['share_with'] = preg_replace('/,([^ ])/', ', $1', $row['share_with']); |
|
| 104 | + if ($row['share_with']) |
|
| 105 | + { |
|
| 106 | + $row['share_with'] = preg_replace('/,([^ ])/', ', $1', $row['share_with']); |
|
| 107 | + } |
|
| 105 | 108 | } |
| 106 | 109 | return $total; |
| 107 | 110 | } |
@@ -536,6 +536,9 @@ discard block |
||
| 536 | 536 | * @param int &$errs=null on return number of errors |
| 537 | 537 | * @param int &$dirs=null on return number of dirs deleted |
| 538 | 538 | * @param int &$files=null on return number of files deleted |
| 539 | + * @param integer $errs |
|
| 540 | + * @param integer $files |
|
| 541 | + * @param integer $dirs |
|
| 539 | 542 | * @return string success or failure message displayed to the user |
| 540 | 543 | */ |
| 541 | 544 | static public function action($action,$selected,$dir=null,&$errs=null,&$files=null,&$dirs=null) |
@@ -704,6 +707,9 @@ discard block |
||
| 704 | 707 | * @param int &$errs=null on return number of errors |
| 705 | 708 | * @param int &$dirs=null on return number of dirs deleted |
| 706 | 709 | * @param int &$files=null on return number of files deleted |
| 710 | + * @param integer $errs |
|
| 711 | + * @param integer $dirs |
|
| 712 | + * @param integer $files |
|
| 707 | 713 | * @return string |
| 708 | 714 | */ |
| 709 | 715 | public static function do_delete(array $selected, &$errs=null, &$dirs=null, &$files=null) |
@@ -1325,7 +1331,6 @@ discard block |
||
| 1325 | 1331 | * |
| 1326 | 1332 | * @param string $action eg. 'delete', ... |
| 1327 | 1333 | * @param array $selected selected path(s) |
| 1328 | - * @param string $dir=null current directory |
|
| 1329 | 1334 | * @see static::action() |
| 1330 | 1335 | */ |
| 1331 | 1336 | public static function ajax_action($action, $selected, $dir=null, $props=null) |
@@ -1420,7 +1420,7 @@ |
||
| 1420 | 1420 | if (Vfs::file_exists($target) && $app_dir) |
| 1421 | 1421 | { |
| 1422 | 1422 | if (!Vfs::file_exists($app_dir)) Vfs::mkdir($app_dir); |
| 1423 | - error_log("Symlinking $target to $app_dir"); |
|
| 1423 | + error_log("symlinking $target to $app_dir"); |
|
| 1424 | 1424 | Vfs::symlink($target, Vfs::concat($app_dir,Vfs::encodePathComponent($file['name']))); |
| 1425 | 1425 | } |
| 1426 | 1426 | } |
@@ -88,7 +88,10 @@ discard block |
||
| 88 | 88 | // search for plugins with additional filemanager views |
| 89 | 89 | foreach(Api\Hooks::process('filemanager_views') as $views) |
| 90 | 90 | { |
| 91 | - if (is_array($views)) static::$views += $views; |
|
| 91 | + if (is_array($views)) |
|
| 92 | + { |
|
| 93 | + static::$views += $views; |
|
| 94 | + } |
|
| 92 | 95 | } |
| 93 | 96 | static::$views_init = true; |
| 94 | 97 | } |
@@ -405,7 +408,10 @@ discard block |
||
| 405 | 408 | $content['nm']['home_dir'] = static::get_home_dir(); |
| 406 | 409 | $content['nm']['view'] = $GLOBALS['egw_info']['user']['preferences']['filemanager']['nm_view']; |
| 407 | 410 | |
| 408 | - if (isset($_GET['msg'])) $msg = $_GET['msg']; |
|
| 411 | + if (isset($_GET['msg'])) |
|
| 412 | + { |
|
| 413 | + $msg = $_GET['msg']; |
|
| 414 | + } |
|
| 409 | 415 | |
| 410 | 416 | // Blank favorite set via GET needs special handling for path |
| 411 | 417 | if (isset($_GET['favorite']) && $_GET['favorite'] == 'blank') |
@@ -439,7 +445,10 @@ discard block |
||
| 439 | 445 | // reset lettersearch as it confuses users (they think the dir is empty) |
| 440 | 446 | $content['nm']['searchletter'] = false; |
| 441 | 447 | // switch recusive display off |
| 442 | - if (!$content['nm']['filter']) $content['nm']['filter'] = ''; |
|
| 448 | + if (!$content['nm']['filter']) |
|
| 449 | + { |
|
| 450 | + $content['nm']['filter'] = ''; |
|
| 451 | + } |
|
| 443 | 452 | } |
| 444 | 453 | } |
| 445 | 454 | $view = static::get_view(); |
@@ -488,37 +497,70 @@ discard block |
||
| 488 | 497 | { |
| 489 | 498 | $tpl = new Etemplate('filemanager.index'); |
| 490 | 499 | |
| 491 | - if($msg) Framework::message($msg); |
|
| 500 | + if($msg) |
|
| 501 | + { |
|
| 502 | + Framework::message($msg); |
|
| 503 | + } |
|
| 492 | 504 | |
| 493 | 505 | if (($content['nm']['action'] || $content['nm']['rows']) && (empty($content['button']) || !isset($content['button']))) |
| 494 | 506 | { |
| 495 | 507 | if ($content['nm']['action']) |
| 496 | 508 | { |
| 497 | 509 | $msg = static::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']); |
| 498 | - if($msg) Framework::message($msg); |
|
| 510 | + if($msg) |
|
| 511 | + { |
|
| 512 | + Framework::message($msg); |
|
| 513 | + } |
|
| 499 | 514 | |
| 500 | 515 | // clean up after action |
| 501 | 516 | unset($content['nm']['selected']); |
| 502 | 517 | // reset any occasion where action may be stored, as it may be ressurected out of the helpers by etemplate, which is quite unconvenient in case of action delete |
| 503 | - if (isset($content['nm']['action'])) unset($content['nm']['action']); |
|
| 504 | - if (isset($content['nm']['nm_action'])) unset($content['nm']['nm_action']); |
|
| 505 | - if (isset($content['nm_action'])) unset($content['nm_action']); |
|
| 518 | + if (isset($content['nm']['action'])) |
|
| 519 | + { |
|
| 520 | + unset($content['nm']['action']); |
|
| 521 | + } |
|
| 522 | + if (isset($content['nm']['nm_action'])) |
|
| 523 | + { |
|
| 524 | + unset($content['nm']['nm_action']); |
|
| 525 | + } |
|
| 526 | + if (isset($content['nm_action'])) |
|
| 527 | + { |
|
| 528 | + unset($content['nm_action']); |
|
| 529 | + } |
|
| 506 | 530 | // we dont use ['nm']['rows']['delete'], so unset it, if it is present |
| 507 | - if (isset($content['nm']['rows']['delete'])) unset($content['nm']['rows']['delete']); |
|
| 531 | + if (isset($content['nm']['rows']['delete'])) |
|
| 532 | + { |
|
| 533 | + unset($content['nm']['rows']['delete']); |
|
| 534 | + } |
|
| 508 | 535 | } |
| 509 | 536 | elseif($content['nm']['rows']['delete']) |
| 510 | 537 | { |
| 511 | 538 | $msg = static::action('delete',array_keys($content['nm']['rows']['delete']),$content['nm']['path']); |
| 512 | - if($msg) Framework::message($msg); |
|
| 539 | + if($msg) |
|
| 540 | + { |
|
| 541 | + Framework::message($msg); |
|
| 542 | + } |
|
| 513 | 543 | |
| 514 | 544 | // clean up after action |
| 515 | 545 | unset($content['nm']['rows']['delete']); |
| 516 | 546 | // reset any occasion where action may be stored, as we use ['nm']['rows']['delete'] anyhow |
| 517 | 547 | // we clean this up, as it may be ressurected out of the helpers by etemplate, which is quite unconvenient in case of action delete |
| 518 | - if (isset($content['nm']['action'])) unset($content['nm']['action']); |
|
| 519 | - if (isset($content['nm']['nm_action'])) unset($content['nm']['nm_action']); |
|
| 520 | - if (isset($content['nm_action'])) unset($content['nm_action']); |
|
| 521 | - if (isset($content['nm']['selected'])) unset($content['nm']['selected']); |
|
| 548 | + if (isset($content['nm']['action'])) |
|
| 549 | + { |
|
| 550 | + unset($content['nm']['action']); |
|
| 551 | + } |
|
| 552 | + if (isset($content['nm']['nm_action'])) |
|
| 553 | + { |
|
| 554 | + unset($content['nm']['nm_action']); |
|
| 555 | + } |
|
| 556 | + if (isset($content['nm_action'])) |
|
| 557 | + { |
|
| 558 | + unset($content['nm_action']); |
|
| 559 | + } |
|
| 560 | + if (isset($content['nm']['selected'])) |
|
| 561 | + { |
|
| 562 | + unset($content['nm']['selected']); |
|
| 563 | + } |
|
| 522 | 564 | } |
| 523 | 565 | unset($content['nm']['rows']); |
| 524 | 566 | Api\Cache::setSession('filemanager', 'index',$content['nm']); |
@@ -685,9 +727,12 @@ discard block |
||
| 685 | 727 | foreach(Vfs::find($path) as $p) |
| 686 | 728 | { |
| 687 | 729 | $to = $dir.substr($p,$len); |
| 688 | - if ($to == $p) // cant copy into itself! |
|
| 730 | + if ($to == $p) |
|
| 731 | + { |
|
| 732 | + // cant copy into itself! |
|
| 689 | 733 | { |
| 690 | 734 | ++$errs; |
| 735 | + } |
|
| 691 | 736 | continue; |
| 692 | 737 | } |
| 693 | 738 | if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to,null,STREAM_MKDIR_RECURSIVE)) |
@@ -742,7 +787,10 @@ discard block |
||
| 742 | 787 | continue; |
| 743 | 788 | } |
| 744 | 789 | } |
| 745 | - if ($target[0] != '/') $target = Vfs::concat($dir, $target); |
|
| 790 | + if ($target[0] != '/') |
|
| 791 | + { |
|
| 792 | + $target = Vfs::concat($dir, $target); |
|
| 793 | + } |
|
| 746 | 794 | if (!Vfs::stat($target)) |
| 747 | 795 | { |
| 748 | 796 | return lang('Link target %1 not found!', Vfs::decodePath($target)); |
@@ -785,10 +833,16 @@ discard block |
||
| 785 | 833 | switch($action) |
| 786 | 834 | { |
| 787 | 835 | case 'document': |
| 788 | - if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document']; |
|
| 836 | + if (!$settings) |
|
| 837 | + { |
|
| 838 | + $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document']; |
|
| 839 | + } |
|
| 789 | 840 | $document_merge = new filemanager_merge(Vfs::decodePath($dir)); |
| 790 | 841 | $msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']); |
| 791 | - if($msg) return $msg; |
|
| 842 | + if($msg) |
|
| 843 | + { |
|
| 844 | + return $msg; |
|
| 845 | + } |
|
| 792 | 846 | $errs = count($selected); |
| 793 | 847 | return false; |
| 794 | 848 | } |
@@ -825,7 +879,9 @@ discard block |
||
| 825 | 879 | unset($selected[$key]); |
| 826 | 880 | } |
| 827 | 881 | } |
| 828 | - if ($selected) // somethings left to delete |
|
| 882 | + if ($selected) |
|
| 883 | + { |
|
| 884 | + // somethings left to delete |
|
| 829 | 885 | { |
| 830 | 886 | // some precaution to never allow to (recursivly) remove /, /apps or /home |
| 831 | 887 | foreach((array)$selected as $path) |
@@ -833,6 +889,7 @@ discard block |
||
| 833 | 889 | if (Vfs::isProtectedDir($path)) |
| 834 | 890 | { |
| 835 | 891 | $errs++; |
| 892 | + } |
|
| 836 | 893 | return lang("Cautiously rejecting to remove folder '%1'!",Vfs::decodePath($path)); |
| 837 | 894 | } |
| 838 | 895 | } |
@@ -881,7 +938,10 @@ discard block |
||
| 881 | 938 | Api\Cache::setSession('filemanager', 'index', |
| 882 | 939 | array_diff_key ($query, array_flip(array('rows','actions','action_links','placeholder_actions')))); |
| 883 | 940 | } |
| 884 | - if(!$query['path']) $query['path'] = static::get_home_dir(); |
|
| 941 | + if(!$query['path']) |
|
| 942 | + { |
|
| 943 | + $query['path'] = static::get_home_dir(); |
|
| 944 | + } |
|
| 885 | 945 | |
| 886 | 946 | // Change template to match selected view |
| 887 | 947 | if($query['view']) |
@@ -939,7 +999,10 @@ discard block |
||
| 939 | 999 | $filter = $query['filter'] === '' ? 1 : $query['filter']; |
| 940 | 1000 | |
| 941 | 1001 | $maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null; |
| 942 | - if($filter == 5) $maxdepth = 2; |
|
| 1002 | + if($filter == 5) |
|
| 1003 | + { |
|
| 1004 | + $maxdepth = 2; |
|
| 1005 | + } |
|
| 943 | 1006 | $n = 0; |
| 944 | 1007 | $vfs_options = array( |
| 945 | 1008 | 'mindepth' => 1, |
@@ -1002,10 +1065,16 @@ discard block |
||
| 1002 | 1065 | { |
| 1003 | 1066 | unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2 |
| 1004 | 1067 | $row =& $rows[$path2n[$path]]; |
| 1005 | - if ( !is_array($props) ) continue; |
|
| 1068 | + if ( !is_array($props) ) |
|
| 1069 | + { |
|
| 1070 | + continue; |
|
| 1071 | + } |
|
| 1006 | 1072 | foreach($props as $prop) |
| 1007 | 1073 | { |
| 1008 | - if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) continue; |
|
| 1074 | + if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) |
|
| 1075 | + { |
|
| 1076 | + continue; |
|
| 1077 | + } |
|
| 1009 | 1078 | $row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'],0,64).' ...'; |
| 1010 | 1079 | } |
| 1011 | 1080 | } |
@@ -1130,7 +1199,10 @@ discard block |
||
| 1130 | 1199 | if (!($dir = Vfs::dirname($path))) |
| 1131 | 1200 | { |
| 1132 | 1201 | $msg .= lang('File or directory not found!')." Vfs::dirname('$path')===false"; |
| 1133 | - if ($button == 'save') $button = 'apply'; |
|
| 1202 | + if ($button == 'save') |
|
| 1203 | + { |
|
| 1204 | + $button = 'apply'; |
|
| 1205 | + } |
|
| 1134 | 1206 | continue; |
| 1135 | 1207 | } |
| 1136 | 1208 | $to = Vfs::concat($dir, $content['name']); |
@@ -1139,7 +1211,10 @@ discard block |
||
| 1139 | 1211 | $tpl->set_validation_error('name',lang("There's already a file with that name!").'<br />'. |
| 1140 | 1212 | lang('To overwrite the existing file store again.',lang($button))); |
| 1141 | 1213 | $content['confirm_overwrite'] = $to; |
| 1142 | - if ($button == 'save') $button = 'apply'; |
|
| 1214 | + if ($button == 'save') |
|
| 1215 | + { |
|
| 1216 | + $button = 'apply'; |
|
| 1217 | + } |
|
| 1143 | 1218 | continue; |
| 1144 | 1219 | } |
| 1145 | 1220 | if (Vfs::rename($path,$to)) |
@@ -1212,13 +1287,19 @@ discard block |
||
| 1212 | 1287 | } |
| 1213 | 1288 | if ($ok && !$failed) |
| 1214 | 1289 | { |
| 1215 | - if(!$perm_changed++) $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren')); |
|
| 1290 | + if(!$perm_changed++) |
|
| 1291 | + { |
|
| 1292 | + $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren')); |
|
| 1293 | + } |
|
| 1216 | 1294 | $content['old'][$name] = $content[$name]; |
| 1217 | 1295 | } |
| 1218 | 1296 | elseif($failed) |
| 1219 | 1297 | { |
| 1220 | - if(!$perm_failed++) $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren'). |
|
| 1298 | + if(!$perm_failed++) |
|
| 1299 | + { |
|
| 1300 | + $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren'). |
|
| 1221 | 1301 | ($ok ? ' ('.lang('%1 failed, %2 succeded',$failed,$ok).')' : '')); |
| 1302 | + } |
|
| 1222 | 1303 | } |
| 1223 | 1304 | } |
| 1224 | 1305 | elseif (call_user_func_array($cmd,array($path,$value))) |
@@ -1271,7 +1352,10 @@ discard block |
||
| 1271 | 1352 | } |
| 1272 | 1353 | } |
| 1273 | 1354 | Framework::refresh_opener($msg, 'filemanager', $refresh_path ? $refresh_path : $path, 'edit', null, '&path=[^&]*'); |
| 1274 | - if ($button == 'save') Framework::window_close(); |
|
| 1355 | + if ($button == 'save') |
|
| 1356 | + { |
|
| 1357 | + Framework::window_close(); |
|
| 1358 | + } |
|
| 1275 | 1359 | } |
| 1276 | 1360 | if ($content['is_link'] && !Vfs::stat($path)) |
| 1277 | 1361 | { |
@@ -1281,13 +1365,19 @@ discard block |
||
| 1281 | 1365 | $content['icon'] = Vfs::mime_icon($content['mime']); |
| 1282 | 1366 | $content['msg'] = $msg; |
| 1283 | 1367 | |
| 1284 | - if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) $content['ro_uid_root'] = 'root'; |
|
| 1368 | + if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) |
|
| 1369 | + { |
|
| 1370 | + $content['ro_uid_root'] = 'root'; |
|
| 1371 | + } |
|
| 1285 | 1372 | // only owner can change group & perms |
| 1286 | 1373 | if (($readonlys['gid'] = !$content['is_owner'] || |
| 1287 | 1374 | Vfs::parse_url(Vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs') ||// no uid, gid or perms in oldvfs |
| 1288 | 1375 | !Vfs::is_writable($path)) |
| 1289 | 1376 | { |
| 1290 | - if (!$content['gid']) $content['ro_gid_root'] = 'root'; |
|
| 1377 | + if (!$content['gid']) |
|
| 1378 | + { |
|
| 1379 | + $content['ro_gid_root'] = 'root'; |
|
| 1380 | + } |
|
| 1291 | 1381 | foreach($content['perms'] as $name => $value) |
| 1292 | 1382 | { |
| 1293 | 1383 | $readonlys['perms['.$name.']'] = true; |
@@ -1322,9 +1412,13 @@ discard block |
||
| 1322 | 1412 | 0 => lang('No access'), |
| 1323 | 1413 | ); |
| 1324 | 1414 | if(($content['eacl'] = Vfs::get_eacl($content['path'])) !== false && // backend supports eacl |
| 1325 | - $GLOBALS['egw_info']['user']['account_id'] == Vfs::$user) // leave eACL tab disabled for sharing |
|
| 1415 | + $GLOBALS['egw_info']['user']['account_id'] == Vfs::$user) |
|
| 1326 | 1416 | { |
| 1327 | - unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again |
|
| 1417 | + // leave eACL tab disabled for sharing |
|
| 1418 | + { |
|
| 1419 | + unset($readonlys['tabs']['filemanager.file.eacl']); |
|
| 1420 | + } |
|
| 1421 | + // --> switch the tab on again |
|
| 1328 | 1422 | foreach($content['eacl'] as &$eacl) |
| 1329 | 1423 | { |
| 1330 | 1424 | $eacl['path'] = rtrim(Vfs::parse_url($eacl['path'],PHP_URL_PATH),'/'); |
@@ -1381,10 +1475,13 @@ discard block |
||
| 1381 | 1475 | 'comment' => (string)$content['comment'], |
| 1382 | 1476 | 'mergeapp' => $content['mergeapp'] |
| 1383 | 1477 | ); |
| 1384 | - if ($cfs) foreach($cfs as $name => $data) |
|
| 1478 | + if ($cfs) |
|
| 1479 | + { |
|
| 1480 | + foreach($cfs as $name => $data) |
|
| 1385 | 1481 | { |
| 1386 | 1482 | $preserve['old']['#'.$name] = (string)$content['#'.$name]; |
| 1387 | 1483 | } |
| 1484 | + } |
|
| 1388 | 1485 | } |
| 1389 | 1486 | if (Vfs::$is_root) |
| 1390 | 1487 | { |
@@ -1411,7 +1508,10 @@ discard block |
||
| 1411 | 1508 | $tpl->setElementAttribute('tabs', 'add_tabs', true); |
| 1412 | 1509 | |
| 1413 | 1510 | $tabs =& $tpl->getElementAttribute('tabs','tabs'); |
| 1414 | - if (true) $tabs = array(); |
|
| 1511 | + if (true) |
|
| 1512 | + { |
|
| 1513 | + $tabs = array(); |
|
| 1514 | + } |
|
| 1415 | 1515 | |
| 1416 | 1516 | foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
| 1417 | 1517 | { |
@@ -1490,7 +1590,10 @@ discard block |
||
| 1490 | 1590 | 'files' => 0, |
| 1491 | 1591 | ); |
| 1492 | 1592 | |
| 1493 | - if (!isset($dir)) $dir = array_pop($selected); |
|
| 1593 | + if (!isset($dir)) |
|
| 1594 | + { |
|
| 1595 | + $dir = array_pop($selected); |
|
| 1596 | + } |
|
| 1494 | 1597 | |
| 1495 | 1598 | switch($action) |
| 1496 | 1599 | { |
@@ -1588,7 +1691,10 @@ discard block |
||
| 1588 | 1691 | $target=Vfs::concat($dir,Vfs::encodePathComponent($file['name'])); |
| 1589 | 1692 | if (Vfs::file_exists($target) && $app_dir) |
| 1590 | 1693 | { |
| 1591 | - if (!Vfs::file_exists($app_dir)) Vfs::mkdir($app_dir); |
|
| 1694 | + if (!Vfs::file_exists($app_dir)) |
|
| 1695 | + { |
|
| 1696 | + Vfs::mkdir($app_dir); |
|
| 1697 | + } |
|
| 1592 | 1698 | error_log("Symlinking $target to $app_dir"); |
| 1593 | 1699 | Vfs::symlink($target, Vfs::concat($app_dir,Vfs::encodePathComponent($file['name']))); |
| 1594 | 1700 | } |
@@ -80,12 +80,12 @@ discard block |
||
| 80 | 80 | if (!static::$views_init) |
| 81 | 81 | { |
| 82 | 82 | // translate our labels |
| 83 | - foreach(static::$views as &$label) |
|
| 83 | + foreach (static::$views as &$label) |
|
| 84 | 84 | { |
| 85 | 85 | $label = lang($label); |
| 86 | 86 | } |
| 87 | 87 | // search for plugins with additional filemanager views |
| 88 | - foreach(Api\Hooks::process('filemanager_views') as $views) |
|
| 88 | + foreach (Api\Hooks::process('filemanager_views') as $views) |
|
| 89 | 89 | { |
| 90 | 90 | if (is_array($views)) static::$views += $views; |
| 91 | 91 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | public static function get_view() |
| 103 | 103 | { |
| 104 | - $view =& Api\Cache::getSession('filemanager', 'view'); |
|
| 104 | + $view = & Api\Cache::getSession('filemanager', 'view'); |
|
| 105 | 105 | if (isset($_GET['view'])) |
| 106 | 106 | { |
| 107 | 107 | $view = $_GET['view']; |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | 'open' => array( |
| 126 | 126 | 'caption' => lang('Open'), |
| 127 | 127 | 'icon' => '', |
| 128 | - 'group' => $group=1, |
|
| 128 | + 'group' => $group = 1, |
|
| 129 | 129 | 'allowOnMultiple' => false, |
| 130 | 130 | 'onExecute' => 'javaScript:app.filemanager.open', |
| 131 | 131 | 'default' => true |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | 'caption' => lang('Edit settings'), |
| 151 | 151 | 'group' => $group, |
| 152 | 152 | 'allowOnMultiple' => false, |
| 153 | - 'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.filemanager.viewEntry':'javaScript:app.filemanager.editprefs', |
|
| 153 | + 'onExecute' => Api\Header\UserAgent::mobile() ? 'javaScript:app.filemanager.viewEntry' : 'javaScript:app.filemanager.editprefs', |
|
| 154 | 154 | 'mobileViewTemplate' => 'file?'.filemtime(Api\Etemplate\Widget\Template::rel2path('/filemanager/templates/mobile/file.xet')) |
| 155 | 155 | ), |
| 156 | 156 | 'mkdir' => array( |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | ), |
| 211 | 211 | // DRAG and DROP events |
| 212 | 212 | 'file_drag' => array( |
| 213 | - 'dragType' => array('file','link'), |
|
| 213 | + 'dragType' => array('file', 'link'), |
|
| 214 | 214 | 'type' => 'drag', |
| 215 | 215 | 'onExecute' => 'javaScript:app.filemanager.drag' |
| 216 | 216 | ), |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | } |
| 250 | 250 | else |
| 251 | 251 | { |
| 252 | - foreach(Vfs\Sharing::$modes as $mode => $data) |
|
| 252 | + foreach (Vfs\Sharing::$modes as $mode => $data) |
|
| 253 | 253 | { |
| 254 | 254 | $actions['mail']['children']['mail_'.$mode] = array( |
| 255 | 255 | 'caption' => $data['label'], |
@@ -260,12 +260,12 @@ discard block |
||
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | 262 | // This would be done automatically, but we're overriding |
| 263 | - foreach($actions as $action_id => $action) |
|
| 263 | + foreach ($actions as $action_id => $action) |
|
| 264 | 264 | { |
| 265 | - if($action['type'] == 'drop' && $action['caption']) |
|
| 265 | + if ($action['type'] == 'drop' && $action['caption']) |
|
| 266 | 266 | { |
| 267 | 267 | $action['type'] = 'popup'; |
| 268 | - if($action['acceptedTypes'] == 'file') |
|
| 268 | + if ($action['acceptedTypes'] == 'file') |
|
| 269 | 269 | { |
| 270 | 270 | $action['enabled'] = 'javaScript:app.filemanager.paste_enabled'; |
| 271 | 271 | } |
@@ -285,10 +285,10 @@ discard block |
||
| 285 | 285 | * |
| 286 | 286 | * @return string merge application or NULL if no property found |
| 287 | 287 | */ |
| 288 | - private static function get_mergeapp($path, $scope='self') |
|
| 288 | + private static function get_mergeapp($path, $scope = 'self') |
|
| 289 | 289 | { |
| 290 | 290 | $app = null; |
| 291 | - switch($scope) |
|
| 291 | + switch ($scope) |
|
| 292 | 292 | { |
| 293 | 293 | case 'self': |
| 294 | 294 | $props = Vfs::propfind($path, static::$merge_prop_namespace); |
@@ -297,10 +297,10 @@ discard block |
||
| 297 | 297 | case 'parents': |
| 298 | 298 | // search for props in parent directories |
| 299 | 299 | $currentpath = $path; |
| 300 | - while($dir = Vfs::dirname($currentpath)) |
|
| 300 | + while ($dir = Vfs::dirname($currentpath)) |
|
| 301 | 301 | { |
| 302 | 302 | $props = Vfs::propfind($dir, static::$merge_prop_namespace); |
| 303 | - if(!empty($props)) |
|
| 303 | + if (!empty($props)) |
|
| 304 | 304 | { |
| 305 | 305 | // found prop in parent directory |
| 306 | 306 | return $app = $props[0]['val']; |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | * @param array $content |
| 320 | 320 | * @param string $msg |
| 321 | 321 | */ |
| 322 | - function index(array $content=null,$msg=null) |
|
| 322 | + function index(array $content = null, $msg = null) |
|
| 323 | 323 | { |
| 324 | 324 | if (!is_array($content)) |
| 325 | 325 | { |
@@ -329,16 +329,16 @@ discard block |
||
| 329 | 329 | if (!is_array($content['nm'])) |
| 330 | 330 | { |
| 331 | 331 | $content['nm'] = array( |
| 332 | - 'get_rows' => 'filemanager.filemanager_ui.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
| 333 | - 'filter' => '', // current dir only |
|
| 334 | - 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
| 335 | - 'no_cat' => True, // I disable the cat-selectbox |
|
| 336 | - 'lettersearch' => True, // I show a lettersearch |
|
| 337 | - 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
| 338 | - 'start' => 0, // IO position in list |
|
| 339 | - 'order' => 'name', // IO name of the column to sort after (optional for the sortheaders) |
|
| 340 | - 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 341 | - 'default_cols' => '!comment,ctime', // I columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns |
|
| 332 | + 'get_rows' => 'filemanager.filemanager_ui.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows' |
|
| 333 | + 'filter' => '', // current dir only |
|
| 334 | + 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
| 335 | + 'no_cat' => True, // I disable the cat-selectbox |
|
| 336 | + 'lettersearch' => True, // I show a lettersearch |
|
| 337 | + 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
| 338 | + 'start' => 0, // IO position in list |
|
| 339 | + 'order' => 'name', // IO name of the column to sort after (optional for the sortheaders) |
|
| 340 | + 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 341 | + 'default_cols' => '!comment,ctime', // I columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns |
|
| 342 | 342 | 'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, |
| 343 | 343 | //or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type) |
| 344 | 344 | 'row_id' => 'path', |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | 'parent_id' => 'dir', |
| 347 | 347 | 'is_parent' => 'is_dir', |
| 348 | 348 | 'favorites' => true, |
| 349 | - 'placeholder_actions' => array('mkdir','paste','file_drop_mail','file_drop_move','file_drop_copy','file_drop_symlink') |
|
| 349 | + 'placeholder_actions' => array('mkdir', 'paste', 'file_drop_mail', 'file_drop_move', 'file_drop_copy', 'file_drop_symlink') |
|
| 350 | 350 | ); |
| 351 | 351 | $content['nm']['path'] = static::get_home_dir(); |
| 352 | 352 | } |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | } |
| 369 | 369 | if (isset($_GET['path']) && ($path = $_GET['path'])) |
| 370 | 370 | { |
| 371 | - switch($path) |
|
| 371 | + switch ($path) |
|
| 372 | 372 | { |
| 373 | 373 | case '..': |
| 374 | 374 | $path = Vfs::dirname($content['nm']['path']); |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | $path = static::get_home_dir(); |
| 378 | 378 | break; |
| 379 | 379 | } |
| 380 | - if ($path && $path[0] == '/' && Vfs::stat($path,true) && Vfs::is_dir($path) && Vfs::check_access($path,Vfs::READABLE)) |
|
| 380 | + if ($path && $path[0] == '/' && Vfs::stat($path, true) && Vfs::is_dir($path) && Vfs::check_access($path, Vfs::READABLE)) |
|
| 381 | 381 | { |
| 382 | 382 | $content['nm']['path'] = $path; |
| 383 | 383 | } |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | } |
| 394 | 394 | $view = static::get_view(); |
| 395 | 395 | |
| 396 | - call_user_func($view,$content,$msg); |
|
| 396 | + call_user_func($view, $content, $msg); |
|
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | /** |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | * @param boolean &$is_setup=null on return true if authenticated user is setup config user, false otherwise |
| 407 | 407 | * @return boolean true is root user given, false otherwise (including logout / empty $user) |
| 408 | 408 | */ |
| 409 | - protected function sudo($user='',$password=null,&$is_setup=null) |
|
| 409 | + protected function sudo($user = '', $password = null, &$is_setup = null) |
|
| 410 | 410 | { |
| 411 | 411 | if (!$user) |
| 412 | 412 | { |
@@ -415,15 +415,15 @@ discard block |
||
| 415 | 415 | else |
| 416 | 416 | { |
| 417 | 417 | // config user & password |
| 418 | - $is_setup = Api\Session::user_pw_hash($user,$password) === $GLOBALS['egw_info']['server']['config_hash']; |
|
| 418 | + $is_setup = Api\Session::user_pw_hash($user, $password) === $GLOBALS['egw_info']['server']['config_hash']; |
|
| 419 | 419 | // or vfs root user from setup >> configuration |
| 420 | - $is_root = $is_setup || $GLOBALS['egw_info']['server']['vfs_root_user'] && |
|
| 421 | - in_array($user,preg_split('/, */',$GLOBALS['egw_info']['server']['vfs_root_user'])) && |
|
| 420 | + $is_root = $is_setup || $GLOBALS['egw_info']['server']['vfs_root_user'] && |
|
| 421 | + in_array($user, preg_split('/, */', $GLOBALS['egw_info']['server']['vfs_root_user'])) && |
|
| 422 | 422 | $GLOBALS['egw']->auth->authenticate($user, $password, 'text'); |
| 423 | 423 | } |
| 424 | 424 | //error_log(__METHOD__."('$user','$password',$is_setup) user_pw_hash(...)='".Api\Session::user_pw_hash($user,$password)."', config_hash='{$GLOBALS['egw_info']['server']['config_hash']}' --> returning ".array2string($is_root)); |
| 425 | - Api\Cache::setSession('filemanager', 'is_setup',$is_setup); |
|
| 426 | - Api\Cache::setSession('filemanager', 'is_root',Vfs::$is_root = $is_root); |
|
| 425 | + Api\Cache::setSession('filemanager', 'is_setup', $is_setup); |
|
| 426 | + Api\Cache::setSession('filemanager', 'is_root', Vfs::$is_root = $is_root); |
|
| 427 | 427 | return Vfs::$is_root; |
| 428 | 428 | } |
| 429 | 429 | |
@@ -433,18 +433,18 @@ discard block |
||
| 433 | 433 | * @param array $content |
| 434 | 434 | * @param string $msg |
| 435 | 435 | */ |
| 436 | - function listview(array $content=null,$msg=null) |
|
| 436 | + function listview(array $content = null, $msg = null) |
|
| 437 | 437 | { |
| 438 | 438 | $tpl = new Etemplate('filemanager.index'); |
| 439 | 439 | |
| 440 | - if($msg) Framework::message($msg); |
|
| 440 | + if ($msg) Framework::message($msg); |
|
| 441 | 441 | |
| 442 | 442 | if (($content['nm']['action'] || $content['nm']['rows']) && (empty($content['button']) || !isset($content['button']))) |
| 443 | 443 | { |
| 444 | 444 | if ($content['nm']['action']) |
| 445 | 445 | { |
| 446 | - $msg = static::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']); |
|
| 447 | - if($msg) Framework::message($msg); |
|
| 446 | + $msg = static::action($content['nm']['action'], $content['nm']['selected'], $content['nm']['path']); |
|
| 447 | + if ($msg) Framework::message($msg); |
|
| 448 | 448 | |
| 449 | 449 | // clean up after action |
| 450 | 450 | unset($content['nm']['selected']); |
@@ -455,10 +455,10 @@ discard block |
||
| 455 | 455 | // we dont use ['nm']['rows']['delete'], so unset it, if it is present |
| 456 | 456 | if (isset($content['nm']['rows']['delete'])) unset($content['nm']['rows']['delete']); |
| 457 | 457 | } |
| 458 | - elseif($content['nm']['rows']['delete']) |
|
| 458 | + elseif ($content['nm']['rows']['delete']) |
|
| 459 | 459 | { |
| 460 | - $msg = static::action('delete',array_keys($content['nm']['rows']['delete']),$content['nm']['path']); |
|
| 461 | - if($msg) Framework::message($msg); |
|
| 460 | + $msg = static::action('delete', array_keys($content['nm']['rows']['delete']), $content['nm']['path']); |
|
| 461 | + if ($msg) Framework::message($msg); |
|
| 462 | 462 | |
| 463 | 463 | // clean up after action |
| 464 | 464 | unset($content['nm']['rows']['delete']); |
@@ -470,11 +470,11 @@ discard block |
||
| 470 | 470 | if (isset($content['nm']['selected'])) unset($content['nm']['selected']); |
| 471 | 471 | } |
| 472 | 472 | unset($content['nm']['rows']); |
| 473 | - Api\Cache::setSession('filemanager', 'index',$content['nm']); |
|
| 473 | + Api\Cache::setSession('filemanager', 'index', $content['nm']); |
|
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | // be tolerant with (in previous versions) not correct urlencoded pathes |
| 477 | - if ($content['nm']['path'][0] == '/' && !Vfs::stat($content['nm']['path'],true) && Vfs::stat(urldecode($content['nm']['path']))) |
|
| 477 | + if ($content['nm']['path'][0] == '/' && !Vfs::stat($content['nm']['path'], true) && Vfs::stat(urldecode($content['nm']['path']))) |
|
| 478 | 478 | { |
| 479 | 479 | $content['nm']['path'] = urldecode($content['nm']['path']); |
| 480 | 480 | } |
@@ -485,22 +485,22 @@ discard block |
||
| 485 | 485 | list($button) = each($content['button']); |
| 486 | 486 | unset($content['button']); |
| 487 | 487 | } |
| 488 | - switch($button) |
|
| 488 | + switch ($button) |
|
| 489 | 489 | { |
| 490 | 490 | case 'upload': |
| 491 | 491 | if (!$content['upload']) |
| 492 | 492 | { |
| 493 | - Framework::message(lang('You need to select some files first!'),'error'); |
|
| 493 | + Framework::message(lang('You need to select some files first!'), 'error'); |
|
| 494 | 494 | break; |
| 495 | 495 | } |
| 496 | 496 | $upload_success = $upload_failure = array(); |
| 497 | - foreach(isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload) |
|
| 497 | + foreach (isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload) |
|
| 498 | 498 | { |
| 499 | 499 | // encode chars which special meaning in url/vfs (some like / get removed!) |
| 500 | - $to = Vfs::concat($content['nm']['path'],Vfs::encodePathComponent($upload['name'])); |
|
| 500 | + $to = Vfs::concat($content['nm']['path'], Vfs::encodePathComponent($upload['name'])); |
|
| 501 | 501 | if ($upload && |
| 502 | 502 | (Vfs::is_writable($content['nm']['path']) || Vfs::is_writable($to)) && |
| 503 | - copy($upload['tmp_name'],Vfs::PREFIX.$to)) |
|
| 503 | + copy($upload['tmp_name'], Vfs::PREFIX.$to)) |
|
| 504 | 504 | { |
| 505 | 505 | $upload_success[] = $upload['name']; |
| 506 | 506 | } |
@@ -512,12 +512,11 @@ discard block |
||
| 512 | 512 | $content['nm']['msg'] = ''; |
| 513 | 513 | if ($upload_success) |
| 514 | 514 | { |
| 515 | - Framework::message( count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') : |
|
| 516 | - lang('%1 successful uploaded.',implode(', ',$upload_success))); |
|
| 515 | + Framework::message(count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') : lang('%1 successful uploaded.', implode(', ', $upload_success))); |
|
| 517 | 516 | } |
| 518 | 517 | if ($upload_failure) |
| 519 | 518 | { |
| 520 | - Framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(),'error'); |
|
| 519 | + Framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(), 'error'); |
|
| 521 | 520 | } |
| 522 | 521 | break; |
| 523 | 522 | } |
@@ -538,16 +537,16 @@ discard block |
||
| 538 | 537 | $tpl->setElementAttribute('nm[buttons][upload]', 'drop_target', 'popupMainDiv'); |
| 539 | 538 | } |
| 540 | 539 | // Set view button to match current settings |
| 541 | - if($content['nm']['view'] == 'tile') |
|
| 540 | + if ($content['nm']['view'] == 'tile') |
|
| 542 | 541 | { |
| 543 | - $tpl->setElementAttribute('nm[button][change_view]','statustext',lang('List view')); |
|
| 544 | - $tpl->setElementAttribute('nm[button][change_view]','image','list_row'); |
|
| 542 | + $tpl->setElementAttribute('nm[button][change_view]', 'statustext', lang('List view')); |
|
| 543 | + $tpl->setElementAttribute('nm[button][change_view]', 'image', 'list_row'); |
|
| 545 | 544 | } |
| 546 | 545 | // if initial load is done via GET request (idots template or share.php) |
| 547 | 546 | // get_rows cant call app.filemanager.set_readonly, so we need to do that here |
| 548 | 547 | $content['initial_path_readonly'] = !Vfs::is_writable($content['nm']['path']); |
| 549 | 548 | |
| 550 | - $tpl->exec('filemanager.filemanager_ui.index',$content,$sel_options,$readonlys,array('nm' => $content['nm'])); |
|
| 549 | + $tpl->exec('filemanager.filemanager_ui.index', $content, $sel_options, $readonlys, array('nm' => $content['nm'])); |
|
| 551 | 550 | } |
| 552 | 551 | |
| 553 | 552 | /** |
@@ -583,7 +582,7 @@ discard block |
||
| 583 | 582 | * @param int &$files=null on return number of files deleted |
| 584 | 583 | * @return string success or failure message displayed to the user |
| 585 | 584 | */ |
| 586 | - static public function action($action,$selected,$dir=null,&$errs=null,&$files=null,&$dirs=null) |
|
| 585 | + static public function action($action, $selected, $dir = null, &$errs = null, &$files = null, &$dirs = null) |
|
| 587 | 586 | { |
| 588 | 587 | if (!count($selected)) |
| 589 | 588 | { |
@@ -591,20 +590,20 @@ discard block |
||
| 591 | 590 | } |
| 592 | 591 | $errs = $dirs = $files = 0; |
| 593 | 592 | |
| 594 | - switch($action) |
|
| 593 | + switch ($action) |
|
| 595 | 594 | { |
| 596 | 595 | |
| 597 | 596 | case 'delete': |
| 598 | - return static::do_delete($selected,$errs,$files,$dirs); |
|
| 597 | + return static::do_delete($selected, $errs, $files, $dirs); |
|
| 599 | 598 | |
| 600 | 599 | case 'mail': |
| 601 | 600 | case 'copy': |
| 602 | - foreach($selected as $path) |
|
| 601 | + foreach ($selected as $path) |
|
| 603 | 602 | { |
| 604 | 603 | if (strpos($path, 'mail::') === 0 && $path = substr($path, 6)) |
| 605 | 604 | { |
| 606 | 605 | // Support for dropping mail in filemanager - Pass mail back to mail app |
| 607 | - if(ExecMethod2('mail.mail_ui.vfsSaveMessage', $path, $dir, false)) |
|
| 606 | + if (ExecMethod2('mail.mail_ui.vfsSaveMessage', $path, $dir, false)) |
|
| 608 | 607 | { |
| 609 | 608 | ++$files; |
| 610 | 609 | } |
@@ -615,8 +614,8 @@ discard block |
||
| 615 | 614 | } |
| 616 | 615 | elseif (!Vfs::is_dir($path)) |
| 617 | 616 | { |
| 618 | - $to = Vfs::concat($dir,Vfs::basename($path)); |
|
| 619 | - if ($path != $to && Vfs::copy($path,$to)) |
|
| 617 | + $to = Vfs::concat($dir, Vfs::basename($path)); |
|
| 618 | + if ($path != $to && Vfs::copy($path, $to)) |
|
| 620 | 619 | { |
| 621 | 620 | ++$files; |
| 622 | 621 | } |
@@ -628,19 +627,19 @@ discard block |
||
| 628 | 627 | else |
| 629 | 628 | { |
| 630 | 629 | $len = strlen(dirname($path)); |
| 631 | - foreach(Vfs::find($path) as $p) |
|
| 630 | + foreach (Vfs::find($path) as $p) |
|
| 632 | 631 | { |
| 633 | - $to = $dir.substr($p,$len); |
|
| 632 | + $to = $dir.substr($p, $len); |
|
| 634 | 633 | if ($to == $p) // cant copy into itself! |
| 635 | 634 | { |
| 636 | 635 | ++$errs; |
| 637 | 636 | continue; |
| 638 | 637 | } |
| 639 | - if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to,null,STREAM_MKDIR_RECURSIVE)) |
|
| 638 | + if (($is_dir = Vfs::is_dir($p)) && Vfs::mkdir($to, null, STREAM_MKDIR_RECURSIVE)) |
|
| 640 | 639 | { |
| 641 | 640 | ++$dirs; |
| 642 | 641 | } |
| 643 | - elseif(!$is_dir && Vfs::copy($p,$to)) |
|
| 642 | + elseif (!$is_dir && Vfs::copy($p, $to)) |
|
| 644 | 643 | { |
| 645 | 644 | ++$files; |
| 646 | 645 | } |
@@ -653,15 +652,15 @@ discard block |
||
| 653 | 652 | } |
| 654 | 653 | if ($errs) |
| 655 | 654 | { |
| 656 | - return lang('%1 errors copying (%2 diretories and %3 files copied)!',$errs,$dirs,$files); |
|
| 655 | + return lang('%1 errors copying (%2 diretories and %3 files copied)!', $errs, $dirs, $files); |
|
| 657 | 656 | } |
| 658 | - return $dirs ? lang('%1 directories and %2 files copied.',$dirs,$files) : lang('%1 files copied.',$files); |
|
| 657 | + return $dirs ? lang('%1 directories and %2 files copied.', $dirs, $files) : lang('%1 files copied.', $files); |
|
| 659 | 658 | |
| 660 | 659 | case 'move': |
| 661 | - foreach($selected as $path) |
|
| 660 | + foreach ($selected as $path) |
|
| 662 | 661 | { |
| 663 | - $to = Vfs::is_dir($dir) || count($selected) > 1 ? Vfs::concat($dir,Vfs::basename($path)) : $dir; |
|
| 664 | - if ($path != $to && Vfs::rename($path,$to)) |
|
| 662 | + $to = Vfs::is_dir($dir) || count($selected) > 1 ? Vfs::concat($dir, Vfs::basename($path)) : $dir; |
|
| 663 | + if ($path != $to && Vfs::rename($path, $to)) |
|
| 665 | 664 | { |
| 666 | 665 | ++$files; |
| 667 | 666 | } |
@@ -672,17 +671,17 @@ discard block |
||
| 672 | 671 | } |
| 673 | 672 | if ($errs) |
| 674 | 673 | { |
| 675 | - return lang('%1 errors moving (%2 files moved)!',$errs,$files); |
|
| 674 | + return lang('%1 errors moving (%2 files moved)!', $errs, $files); |
|
| 676 | 675 | } |
| 677 | - return lang('%1 files moved.',$files); |
|
| 676 | + return lang('%1 files moved.', $files); |
|
| 678 | 677 | |
| 679 | 678 | case 'symlink': // symlink given files to $dir |
| 680 | - foreach((array)$selected as $target) |
|
| 679 | + foreach ((array)$selected as $target) |
|
| 681 | 680 | { |
| 682 | 681 | $link = Vfs::concat($dir, Vfs::basename($target)); |
| 683 | - if (!Vfs::stat($dir) || ($ok = Vfs::mkdir($dir,0,true))) |
|
| 682 | + if (!Vfs::stat($dir) || ($ok = Vfs::mkdir($dir, 0, true))) |
|
| 684 | 683 | { |
| 685 | - if(!$ok) |
|
| 684 | + if (!$ok) |
|
| 686 | 685 | { |
| 687 | 686 | $errs++; |
| 688 | 687 | continue; |
@@ -704,15 +703,14 @@ discard block |
||
| 704 | 703 | } |
| 705 | 704 | if (count((array)$selected) == 1) |
| 706 | 705 | { |
| 707 | - return $files ? lang('Symlink to %1 created.', Vfs::decodePath($target)) : |
|
| 708 | - lang('Error creating symlink to target %1!', Vfs::decodePath($target)); |
|
| 706 | + return $files ? lang('Symlink to %1 created.', Vfs::decodePath($target)) : lang('Error creating symlink to target %1!', Vfs::decodePath($target)); |
|
| 709 | 707 | } |
| 710 | 708 | $ret = lang('%1 elements linked.', $files); |
| 711 | 709 | if ($errs) |
| 712 | 710 | { |
| 713 | - $ret = lang('%1 errors linking (%2)!',$errs, $ret); |
|
| 711 | + $ret = lang('%1 errors linking (%2)!', $errs, $ret); |
|
| 714 | 712 | } |
| 715 | - return $ret;//." Vfs::symlink('$target', '$link')"; |
|
| 713 | + return $ret; //." Vfs::symlink('$target', '$link')"; |
|
| 716 | 714 | |
| 717 | 715 | case 'createdir': |
| 718 | 716 | $dst = Vfs::concat($dir, is_array($selected) ? $selected[0] : $selected); |
@@ -728,13 +726,13 @@ discard block |
||
| 728 | 726 | |
| 729 | 727 | default: |
| 730 | 728 | list($action, $settings) = explode('_', $action, 2); |
| 731 | - switch($action) |
|
| 729 | + switch ($action) |
|
| 732 | 730 | { |
| 733 | 731 | case 'document': |
| 734 | 732 | if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document']; |
| 735 | 733 | $document_merge = new filemanager_merge(Vfs::decodePath($dir)); |
| 736 | 734 | $msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']); |
| 737 | - if($msg) return $msg; |
|
| 735 | + if ($msg) return $msg; |
|
| 738 | 736 | $errs = count($selected); |
| 739 | 737 | return false; |
| 740 | 738 | } |
@@ -751,12 +749,12 @@ discard block |
||
| 751 | 749 | * @param int &$files=null on return number of files deleted |
| 752 | 750 | * @return string |
| 753 | 751 | */ |
| 754 | - public static function do_delete(array $selected, &$errs=null, &$dirs=null, &$files=null) |
|
| 752 | + public static function do_delete(array $selected, &$errs = null, &$dirs = null, &$files = null) |
|
| 755 | 753 | { |
| 756 | 754 | $dirs = $files = $errs = 0; |
| 757 | 755 | // we first delete all selected links (and files) |
| 758 | 756 | // feeding the links to dirs to Vfs::find() deletes the content of the dirs, not just the link! |
| 759 | - foreach($selected as $key => $path) |
|
| 757 | + foreach ($selected as $key => $path) |
|
| 760 | 758 | { |
| 761 | 759 | if (!Vfs::is_dir($path) || Vfs::is_link($path)) |
| 762 | 760 | { |
@@ -774,21 +772,21 @@ discard block |
||
| 774 | 772 | if ($selected) // somethings left to delete |
| 775 | 773 | { |
| 776 | 774 | // some precaution to never allow to (recursivly) remove /, /apps or /home |
| 777 | - foreach((array)$selected as $path) |
|
| 775 | + foreach ((array)$selected as $path) |
|
| 778 | 776 | { |
| 779 | 777 | if (Vfs::isProtectedDir($path)) |
| 780 | 778 | { |
| 781 | 779 | $errs++; |
| 782 | - return lang("Cautiously rejecting to remove folder '%1'!",Vfs::decodePath($path)); |
|
| 780 | + return lang("Cautiously rejecting to remove folder '%1'!", Vfs::decodePath($path)); |
|
| 783 | 781 | } |
| 784 | 782 | } |
| 785 | 783 | // now we use find to loop through all files and dirs: (selected only contains dirs now) |
| 786 | 784 | // - depth=true to get first the files and then the dir containing it |
| 787 | 785 | // - hidden=true to also return hidden files (eg. Thumbs.db), as we cant delete non-empty dirs |
| 788 | 786 | // - show-deleted=false to not (finally) deleted versioned files |
| 789 | - foreach(Vfs::find($selected,array('depth'=>true,'hidden'=>true,'show-deleted'=>false)) as $path) |
|
| 787 | + foreach (Vfs::find($selected, array('depth'=>true, 'hidden'=>true, 'show-deleted'=>false)) as $path) |
|
| 790 | 788 | { |
| 791 | - if (($is_dir = Vfs::is_dir($path) && !Vfs::is_link($path)) && Vfs::rmdir($path,0)) |
|
| 789 | + if (($is_dir = Vfs::is_dir($path) && !Vfs::is_link($path)) && Vfs::rmdir($path, 0)) |
|
| 792 | 790 | { |
| 793 | 791 | ++$dirs; |
| 794 | 792 | } |
@@ -804,13 +802,13 @@ discard block |
||
| 804 | 802 | } |
| 805 | 803 | if ($errs) |
| 806 | 804 | { |
| 807 | - return lang('%1 errors deleteting (%2 directories and %3 files deleted)!',$errs,$dirs,$files); |
|
| 805 | + return lang('%1 errors deleteting (%2 directories and %3 files deleted)!', $errs, $dirs, $files); |
|
| 808 | 806 | } |
| 809 | 807 | if ($dirs) |
| 810 | 808 | { |
| 811 | - return lang('%1 directories and %2 files deleted.',$dirs,$files); |
|
| 809 | + return lang('%1 directories and %2 files deleted.', $dirs, $files); |
|
| 812 | 810 | } |
| 813 | - return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.',$files); |
|
| 811 | + return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.', $files); |
|
| 814 | 812 | } |
| 815 | 813 | |
| 816 | 814 | /** |
@@ -825,37 +823,37 @@ discard block |
||
| 825 | 823 | if (!$query['csv_export']) |
| 826 | 824 | { |
| 827 | 825 | Api\Cache::setSession('filemanager', 'index', |
| 828 | - array_diff_key ($query, array_flip(array('rows','actions','action_links','placeholder_actions')))); |
|
| 826 | + array_diff_key($query, array_flip(array('rows', 'actions', 'action_links', 'placeholder_actions')))); |
|
| 829 | 827 | } |
| 830 | - if(!$query['path']) $query['path'] = static::get_home_dir(); |
|
| 828 | + if (!$query['path']) $query['path'] = static::get_home_dir(); |
|
| 831 | 829 | |
| 832 | 830 | // Change template to match selected view |
| 833 | - if($query['view']) |
|
| 831 | + if ($query['view']) |
|
| 834 | 832 | { |
| 835 | 833 | $query['template'] = ($query['view'] == 'row' ? 'filemanager.index.rows' : 'filemanager.tile'); |
| 836 | 834 | |
| 837 | 835 | // Store as preference but only for index, not home |
| 838 | - if($query['get_rows'] == 'filemanager.filemanager_ui.get_rows') |
|
| 836 | + if ($query['get_rows'] == 'filemanager.filemanager_ui.get_rows') |
|
| 839 | 837 | { |
| 840 | - $GLOBALS['egw']->preferences->add('filemanager','nm_view',$query['view']); |
|
| 838 | + $GLOBALS['egw']->preferences->add('filemanager', 'nm_view', $query['view']); |
|
| 841 | 839 | $GLOBALS['egw']->preferences->save_repository(); |
| 842 | 840 | } |
| 843 | 841 | } |
| 844 | 842 | // be tolerant with (in previous versions) not correct urlencoded pathes |
| 845 | - if (!Vfs::stat($query['path'],true) && Vfs::stat(urldecode($query['path']))) |
|
| 843 | + if (!Vfs::stat($query['path'], true) && Vfs::stat(urldecode($query['path']))) |
|
| 846 | 844 | { |
| 847 | 845 | $query['path'] = urldecode($query['path']); |
| 848 | 846 | } |
| 849 | - if (!Vfs::stat($query['path'],true) || !Vfs::is_dir($query['path']) || !Vfs::check_access($query['path'],Vfs::READABLE)) |
|
| 847 | + if (!Vfs::stat($query['path'], true) || !Vfs::is_dir($query['path']) || !Vfs::check_access($query['path'], Vfs::READABLE)) |
|
| 850 | 848 | { |
| 851 | 849 | // only redirect, if it would be to some other location, gives redirect-loop otherwise |
| 852 | 850 | if ($query['path'] != ($path = static::get_home_dir())) |
| 853 | 851 | { |
| 854 | 852 | // we will leave here, since we are not allowed, or the location does not exist. Index must handle that, and give |
| 855 | 853 | // an appropriate message |
| 856 | - Egw::redirect_link('/index.php',array('menuaction'=>'filemanager.filemanager_ui.index', |
|
| 854 | + Egw::redirect_link('/index.php', array('menuaction'=>'filemanager.filemanager_ui.index', |
|
| 857 | 855 | 'path' => $path, |
| 858 | - 'msg' => lang('The requested path %1 is not available.',Vfs::decodePath($query['path'])), |
|
| 856 | + 'msg' => lang('The requested path %1 is not available.', Vfs::decodePath($query['path'])), |
|
| 859 | 857 | 'ajax' => 'true' |
| 860 | 858 | )); |
| 861 | 859 | } |
@@ -863,35 +861,35 @@ discard block |
||
| 863 | 861 | return 0; |
| 864 | 862 | } |
| 865 | 863 | $rows = $dir_is_writable = array(); |
| 866 | - if($query['searchletter'] && !empty($query['search'])) |
|
| 864 | + if ($query['searchletter'] && !empty($query['search'])) |
|
| 867 | 865 | { |
| 868 | - $namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i'; |
|
| 866 | + $namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i'; |
|
| 869 | 867 | if ($query['searchletter'] == strtolower($query['search'][0])) |
| 870 | 868 | { |
| 871 | - $namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'|'. |
|
| 872 | - str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).')/i'; |
|
| 869 | + $namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'|'. |
|
| 870 | + str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).')/i'; |
|
| 873 | 871 | } |
| 874 | 872 | } |
| 875 | 873 | elseif ($query['searchletter']) |
| 876 | 874 | { |
| 877 | 875 | $namefilter = '/^'.$query['searchletter'].'/i'; |
| 878 | 876 | } |
| 879 | - elseif(!empty($query['search'])) |
|
| 877 | + elseif (!empty($query['search'])) |
|
| 880 | 878 | { |
| 881 | - $namefilter = '/'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i'; |
|
| 879 | + $namefilter = '/'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i'; |
|
| 882 | 880 | } |
| 883 | 881 | |
| 884 | 882 | // Re-map so 'No filters' favorite ('') is depth 1 |
| 885 | 883 | $filter = $query['filter'] === '' ? 1 : $query['filter']; |
| 886 | 884 | |
| 887 | 885 | $maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null; |
| 888 | - if($filter == 5) $maxdepth = 2; |
|
| 886 | + if ($filter == 5) $maxdepth = 2; |
|
| 889 | 887 | $n = 0; |
| 890 | 888 | $vfs_options = array( |
| 891 | 889 | 'mindepth' => 1, |
| 892 | 890 | 'maxdepth' => $maxdepth, |
| 893 | 891 | 'dirsontop' => $filter <= 1, |
| 894 | - 'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F':'f'), |
|
| 892 | + 'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F' : 'f'), |
|
| 895 | 893 | 'order' => $query['order'], 'sort' => $query['sort'], |
| 896 | 894 | 'limit' => (int)$query['num_rows'].','.(int)$query['start'], |
| 897 | 895 | 'need_mime' => true, |
@@ -899,11 +897,11 @@ discard block |
||
| 899 | 897 | 'hidden' => $filter == 3, |
| 900 | 898 | 'follow' => $filter == 5, |
| 901 | 899 | ); |
| 902 | - if($query['col_filter']['mime']) |
|
| 900 | + if ($query['col_filter']['mime']) |
|
| 903 | 901 | { |
| 904 | 902 | $vfs_options['mime'] = $query['col_filter']['mime']; |
| 905 | 903 | } |
| 906 | - foreach(Vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'],$vfs_options,true) as $path => $row) |
|
| 904 | + foreach (Vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'], $vfs_options, true) as $path => $row) |
|
| 907 | 905 | { |
| 908 | 906 | //echo $path; _debug_array($row); |
| 909 | 907 | |
@@ -922,38 +920,38 @@ discard block |
||
| 922 | 920 | $row['class'] .= 'isDir '; |
| 923 | 921 | $row['is_dir'] = 1; |
| 924 | 922 | } |
| 925 | - if(!$dir_is_writable[$path]) |
|
| 923 | + if (!$dir_is_writable[$path]) |
|
| 926 | 924 | { |
| 927 | 925 | $row['class'] .= 'noEdit '; |
| 928 | 926 | } |
| 929 | 927 | $row['class'] .= !$dir_is_writable[$dir] ? 'noDelete' : ''; |
| 930 | 928 | $row['download_url'] = Vfs::download_url($path); |
| 931 | - $row['gid'] = -abs($row['gid']); // gid are positive, but we use negagive account_id for groups internal |
|
| 929 | + $row['gid'] = -abs($row['gid']); // gid are positive, but we use negagive account_id for groups internal |
|
| 932 | 930 | |
| 933 | 931 | $rows[++$n] = $row; |
| 934 | 932 | $path2n[$path] = $n; |
| 935 | 933 | } |
| 936 | 934 | // query comments and cf's for the displayed rows |
| 937 | - $cols_to_show = explode(',',$GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']); |
|
| 935 | + $cols_to_show = explode(',', $GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']); |
|
| 938 | 936 | |
| 939 | 937 | // Always include comment in tiles |
| 940 | - if($query['view'] == 'tile') |
|
| 938 | + if ($query['view'] == 'tile') |
|
| 941 | 939 | { |
| 942 | 940 | $cols_to_show[] = 'comment'; |
| 943 | 941 | } |
| 944 | - $all_cfs = in_array('customfields',$cols_to_show) && $cols_to_show[count($cols_to_show)-1][0] != '#'; |
|
| 945 | - if ($path2n && (in_array('comment',$cols_to_show) || in_array('customfields',$cols_to_show)) && |
|
| 942 | + $all_cfs = in_array('customfields', $cols_to_show) && $cols_to_show[count($cols_to_show) - 1][0] != '#'; |
|
| 943 | + if ($path2n && (in_array('comment', $cols_to_show) || in_array('customfields', $cols_to_show)) && |
|
| 946 | 944 | ($path2props = Vfs::propfind(array_keys($path2n)))) |
| 947 | 945 | { |
| 948 | - foreach($path2props as $path => $props) |
|
| 946 | + foreach ($path2props as $path => $props) |
|
| 949 | 947 | { |
| 950 | - unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2 |
|
| 951 | - $row =& $rows[$path2n[$path]]; |
|
| 952 | - if ( !is_array($props) ) continue; |
|
| 953 | - foreach($props as $prop) |
|
| 948 | + unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2 |
|
| 949 | + $row = & $rows[$path2n[$path]]; |
|
| 950 | + if (!is_array($props)) continue; |
|
| 951 | + foreach ($props as $prop) |
|
| 954 | 952 | { |
| 955 | - if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) continue; |
|
| 956 | - $row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'],0,64).' ...'; |
|
| 953 | + if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'], $cols_to_show)) continue; |
|
| 954 | + $row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'], 0, 64).' ...'; |
|
| 957 | 955 | } |
| 958 | 956 | } |
| 959 | 957 | } |
@@ -965,7 +963,7 @@ discard block |
||
| 965 | 963 | if ($GLOBALS['egw_info']['flags']['currentapp'] == 'projectmanager') |
| 966 | 964 | { |
| 967 | 965 | // we need our app.css file |
| 968 | - if (!file_exists(EGW_SERVER_ROOT.($css_file='/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css'))) |
|
| 966 | + if (!file_exists(EGW_SERVER_ROOT.($css_file = '/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css'))) |
|
| 969 | 967 | { |
| 970 | 968 | $css_file = '/filemanager/templates/default/app.css'; |
| 971 | 969 | } |
@@ -981,7 +979,7 @@ discard block |
||
| 981 | 979 | * @param array $content |
| 982 | 980 | * @param string $msg |
| 983 | 981 | */ |
| 984 | - function file(array $content=null,$msg='') |
|
| 982 | + function file(array $content = null, $msg = '') |
|
| 985 | 983 | { |
| 986 | 984 | $tpl = new Etemplate('filemanager.file'); |
| 987 | 985 | |
@@ -991,9 +989,9 @@ discard block |
||
| 991 | 989 | { |
| 992 | 990 | $msg .= $_GET['msg']; |
| 993 | 991 | } |
| 994 | - if (!($path = str_replace(array('#','?'),array('%23','%3F'),$_GET['path'])) || // ?, # need to stay encoded! |
|
| 992 | + if (!($path = str_replace(array('#', '?'), array('%23', '%3F'), $_GET['path'])) || // ?, # need to stay encoded! |
|
| 995 | 993 | // actions enclose pathes containing comma with " |
| 996 | - ($path[0] == '"' && substr($path,-1) == '"' && !($path = substr(str_replace('""','"',$path),1,-1))) || |
|
| 994 | + ($path[0] == '"' && substr($path, -1) == '"' && !($path = substr(str_replace('""', '"', $path), 1, -1))) || |
|
| 997 | 995 | !($stat = Vfs::lstat($path))) |
| 998 | 996 | { |
| 999 | 997 | $msg .= lang('File or directory not found!')." path='$path', stat=".array2string($stat); |
@@ -1006,10 +1004,10 @@ discard block |
||
| 1006 | 1004 | $content['path'] = $path; |
| 1007 | 1005 | $content['hsize'] = Vfs::hsize($stat['size']); |
| 1008 | 1006 | $content['mime'] = Vfs::mime_content_type($path); |
| 1009 | - $content['gid'] *= -1; // our widgets use negative gid's |
|
| 1007 | + $content['gid'] *= -1; // our widgets use negative gid's |
|
| 1010 | 1008 | if (($props = Vfs::propfind($path))) |
| 1011 | 1009 | { |
| 1012 | - foreach($props as $prop) |
|
| 1010 | + foreach ($props as $prop) |
|
| 1013 | 1011 | { |
| 1014 | 1012 | $content[$prop['name']] = $prop['val']; |
| 1015 | 1013 | } |
@@ -1022,9 +1020,9 @@ discard block |
||
| 1022 | 1020 | $content['tabs'] = $_GET['tabs']; |
| 1023 | 1021 | if (!($content['is_dir'] = Vfs::is_dir($path) && !Vfs::is_link($path))) |
| 1024 | 1022 | { |
| 1025 | - $content['perms']['executable'] = (int)!!($content['mode'] & 0111); |
|
| 1023 | + $content['perms']['executable'] = (int)!!($content['mode']&0111); |
|
| 1026 | 1024 | $mask = 6; |
| 1027 | - if (preg_match('/^text/',$content['mime']) && $content['size'] < 100000) |
|
| 1025 | + if (preg_match('/^text/', $content['mime']) && $content['size'] < 100000) |
|
| 1028 | 1026 | { |
| 1029 | 1027 | $content['text_content'] = file_get_contents(Vfs::PREFIX.$path); |
| 1030 | 1028 | } |
@@ -1034,19 +1032,19 @@ discard block |
||
| 1034 | 1032 | //currently not implemented in backend $content['perms']['sticky'] = (int)!!($content['mode'] & 0x201); |
| 1035 | 1033 | $mask = 7; |
| 1036 | 1034 | } |
| 1037 | - foreach(array('owner' => 6,'group' => 3,'other' => 0) as $name => $shift) |
|
| 1035 | + foreach (array('owner' => 6, 'group' => 3, 'other' => 0) as $name => $shift) |
|
| 1038 | 1036 | { |
| 1039 | - $content['perms'][$name] = ($content['mode'] >> $shift) & $mask; |
|
| 1037 | + $content['perms'][$name] = ($content['mode'] >> $shift)&$mask; |
|
| 1040 | 1038 | } |
| 1041 | - $content['is_owner'] = Vfs::has_owner_rights($path,$content); |
|
| 1039 | + $content['is_owner'] = Vfs::has_owner_rights($path, $content); |
|
| 1042 | 1040 | } |
| 1043 | 1041 | else |
| 1044 | 1042 | { |
| 1045 | 1043 | //_debug_array($content); |
| 1046 | - $path =& $content['path']; |
|
| 1044 | + $path = & $content['path']; |
|
| 1047 | 1045 | |
| 1048 | 1046 | list($button) = @each($content['button']); unset($content['button']); |
| 1049 | - if(!$button && $content['sudo']) |
|
| 1047 | + if (!$button && $content['sudo']) |
|
| 1050 | 1048 | { |
| 1051 | 1049 | // Button to stop sudo is not in button namespace |
| 1052 | 1050 | $button = 'sudo'; |
@@ -1055,21 +1053,21 @@ discard block |
||
| 1055 | 1053 | // need to check 'setup' button (submit button in sudo popup), as some browsers (eg. chrome) also fill the hidden field |
| 1056 | 1054 | if ($button == 'sudo' && Vfs::$is_root || $button == 'setup' && $content['sudo']['user']) |
| 1057 | 1055 | { |
| 1058 | - $msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '',$content['sudo']['passwd']) ? |
|
| 1056 | + $msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '', $content['sudo']['passwd']) ? |
|
| 1059 | 1057 | lang('Root access granted.') : ($button == 'setup' && $content['sudo']['user'] ? |
| 1060 | 1058 | lang('Wrong username or password!') : lang('Root access stopped.')); |
| 1061 | 1059 | unset($content['sudo']); |
| 1062 | 1060 | $content['is_owner'] = Vfs::has_owner_rights($path); |
| 1063 | 1061 | } |
| 1064 | - if (in_array($button,array('save','apply'))) |
|
| 1062 | + if (in_array($button, array('save', 'apply'))) |
|
| 1065 | 1063 | { |
| 1066 | 1064 | $props = array(); |
| 1067 | 1065 | $perm_changed = $perm_failed = 0; |
| 1068 | - foreach($content['old'] as $name => $old_value) |
|
| 1066 | + foreach ($content['old'] as $name => $old_value) |
|
| 1069 | 1067 | { |
| 1070 | 1068 | if (isset($content[$name]) && ($old_value != $content[$name] || |
| 1071 | 1069 | // do not check for modification, if modify_subs is checked! |
| 1072 | - $content['modify_subs'] && in_array($name,array('uid','gid','perms'))) && |
|
| 1070 | + $content['modify_subs'] && in_array($name, array('uid', 'gid', 'perms'))) && |
|
| 1073 | 1071 | ($name != 'uid' || Vfs::$is_root)) |
| 1074 | 1072 | { |
| 1075 | 1073 | if ($name == 'name') |
@@ -1083,23 +1081,23 @@ discard block |
||
| 1083 | 1081 | $to = Vfs::concat($dir, $content['name']); |
| 1084 | 1082 | if (file_exists(Vfs::PREFIX.$to) && $content['confirm_overwrite'] !== $to) |
| 1085 | 1083 | { |
| 1086 | - $tpl->set_validation_error('name',lang("There's already a file with that name!").'<br />'. |
|
| 1087 | - lang('To overwrite the existing file store again.',lang($button))); |
|
| 1084 | + $tpl->set_validation_error('name', lang("There's already a file with that name!").'<br />'. |
|
| 1085 | + lang('To overwrite the existing file store again.', lang($button))); |
|
| 1088 | 1086 | $content['confirm_overwrite'] = $to; |
| 1089 | 1087 | if ($button == 'save') $button = 'apply'; |
| 1090 | 1088 | continue; |
| 1091 | 1089 | } |
| 1092 | - if (Vfs::rename($path,$to)) |
|
| 1090 | + if (Vfs::rename($path, $to)) |
|
| 1093 | 1091 | { |
| 1094 | - $msg .= lang('Renamed %1 to %2.',Vfs::decodePath(basename($path)),Vfs::decodePath(basename($to))).' '; |
|
| 1092 | + $msg .= lang('Renamed %1 to %2.', Vfs::decodePath(basename($path)), Vfs::decodePath(basename($to))).' '; |
|
| 1095 | 1093 | $content['old']['name'] = $content[$name]; |
| 1096 | 1094 | $path = $to; |
| 1097 | - $content['mime'] = Api\MimeMagic::filename2mime($path); // recheck mime type |
|
| 1098 | - $refresh_path = Vfs::dirname($path); // for renames, we have to refresh the parent |
|
| 1095 | + $content['mime'] = Api\MimeMagic::filename2mime($path); // recheck mime type |
|
| 1096 | + $refresh_path = Vfs::dirname($path); // for renames, we have to refresh the parent |
|
| 1099 | 1097 | } |
| 1100 | 1098 | else |
| 1101 | 1099 | { |
| 1102 | - $msg .= lang('Rename of %1 to %2 failed!',Vfs::decodePath(basename($path)),Vfs::decodePath(basename($to))).' '; |
|
| 1100 | + $msg .= lang('Rename of %1 to %2 failed!', Vfs::decodePath(basename($path)), Vfs::decodePath(basename($to))).' '; |
|
| 1103 | 1101 | if (Vfs::deny_script($to)) |
| 1104 | 1102 | { |
| 1105 | 1103 | $msg .= lang('You are NOT allowed to upload a script!').' '; |
@@ -1119,7 +1117,7 @@ discard block |
||
| 1119 | 1117 | 'val' => (!empty($content[$name]) ? $content[$name] : null), |
| 1120 | 1118 | ), |
| 1121 | 1119 | ); |
| 1122 | - if (Vfs::proppatch($path,$mergeprop)) |
|
| 1120 | + if (Vfs::proppatch($path, $mergeprop)) |
|
| 1123 | 1121 | { |
| 1124 | 1122 | $content['old'][$name] = $content[$name]; |
| 1125 | 1123 | $msg .= lang('Setting for document merge saved.'); |
@@ -1131,22 +1129,22 @@ discard block |
||
| 1131 | 1129 | } |
| 1132 | 1130 | else |
| 1133 | 1131 | { |
| 1134 | - static $name2cmd = array('uid' => 'chown','gid' => 'chgrp','perms' => 'chmod'); |
|
| 1135 | - $cmd = array('EGroupware\\Api\\Vfs',$name2cmd[$name]); |
|
| 1132 | + static $name2cmd = array('uid' => 'chown', 'gid' => 'chgrp', 'perms' => 'chmod'); |
|
| 1133 | + $cmd = array('EGroupware\\Api\\Vfs', $name2cmd[$name]); |
|
| 1136 | 1134 | $value = $name == 'perms' ? static::perms2mode($content['perms']) : $content[$name]; |
| 1137 | 1135 | if ($content['modify_subs']) |
| 1138 | 1136 | { |
| 1139 | 1137 | if ($name == 'perms') |
| 1140 | 1138 | { |
| 1141 | - $changed = Vfs::find($path,array('type'=>'d'),$cmd,array($value)); |
|
| 1142 | - $changed += Vfs::find($path,array('type'=>'f'),$cmd,array($value & 0666)); // no execute for files |
|
| 1139 | + $changed = Vfs::find($path, array('type'=>'d'), $cmd, array($value)); |
|
| 1140 | + $changed += Vfs::find($path, array('type'=>'f'), $cmd, array($value&0666)); // no execute for files |
|
| 1143 | 1141 | } |
| 1144 | 1142 | else |
| 1145 | 1143 | { |
| 1146 | - $changed = Vfs::find($path,null,$cmd,array($value)); |
|
| 1144 | + $changed = Vfs::find($path, null, $cmd, array($value)); |
|
| 1147 | 1145 | } |
| 1148 | 1146 | $ok = $failed = 0; |
| 1149 | - foreach($changed as &$r) |
|
| 1147 | + foreach ($changed as &$r) |
|
| 1150 | 1148 | { |
| 1151 | 1149 | if ($r) |
| 1152 | 1150 | { |
@@ -1159,32 +1157,32 @@ discard block |
||
| 1159 | 1157 | } |
| 1160 | 1158 | if ($ok && !$failed) |
| 1161 | 1159 | { |
| 1162 | - if(!$perm_changed++) $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren')); |
|
| 1160 | + if (!$perm_changed++) $msg .= lang('Permissions of %1 changed.', $path.' '.lang('and all it\'s childeren')); |
|
| 1163 | 1161 | $content['old'][$name] = $content[$name]; |
| 1164 | 1162 | } |
| 1165 | - elseif($failed) |
|
| 1163 | + elseif ($failed) |
|
| 1166 | 1164 | { |
| 1167 | - if(!$perm_failed++) $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren'). |
|
| 1168 | - ($ok ? ' ('.lang('%1 failed, %2 succeded',$failed,$ok).')' : '')); |
|
| 1165 | + if (!$perm_failed++) $msg .= lang('Failed to change permissions of %1!', $path.lang('and all it\'s childeren'). |
|
| 1166 | + ($ok ? ' ('.lang('%1 failed, %2 succeded', $failed, $ok).')' : '')); |
|
| 1169 | 1167 | } |
| 1170 | 1168 | } |
| 1171 | - elseif (call_user_func_array($cmd,array($path,$value))) |
|
| 1169 | + elseif (call_user_func_array($cmd, array($path, $value))) |
|
| 1172 | 1170 | { |
| 1173 | - $msg .= lang('Permissions of %1 changed.',$path); |
|
| 1171 | + $msg .= lang('Permissions of %1 changed.', $path); |
|
| 1174 | 1172 | $content['old'][$name] = $content[$name]; |
| 1175 | 1173 | } |
| 1176 | 1174 | else |
| 1177 | 1175 | { |
| 1178 | - $msg .= lang('Failed to change permissions of %1!',$path); |
|
| 1176 | + $msg .= lang('Failed to change permissions of %1!', $path); |
|
| 1179 | 1177 | } |
| 1180 | 1178 | } |
| 1181 | 1179 | } |
| 1182 | 1180 | } |
| 1183 | 1181 | if ($props) |
| 1184 | 1182 | { |
| 1185 | - if (Vfs::proppatch($path,$props)) |
|
| 1183 | + if (Vfs::proppatch($path, $props)) |
|
| 1186 | 1184 | { |
| 1187 | - foreach($props as $prop) |
|
| 1185 | + foreach ($props as $prop) |
|
| 1188 | 1186 | { |
| 1189 | 1187 | $content['old'][$prop['name']] = $prop['val']; |
| 1190 | 1188 | } |
@@ -1201,8 +1199,8 @@ discard block |
||
| 1201 | 1199 | if ($content['eacl']['delete']) |
| 1202 | 1200 | { |
| 1203 | 1201 | list($ino_owner) = each($content['eacl']['delete']); |
| 1204 | - list(, $owner) = explode('-',$ino_owner,2); // $owner is a group and starts with a minus! |
|
| 1205 | - $msg .= Vfs::eacl($path,null,$owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!'); |
|
| 1202 | + list(, $owner) = explode('-', $ino_owner, 2); // $owner is a group and starts with a minus! |
|
| 1203 | + $msg .= Vfs::eacl($path, null, $owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!'); |
|
| 1206 | 1204 | } |
| 1207 | 1205 | elseif ($button == 'eacl') |
| 1208 | 1206 | { |
@@ -1212,7 +1210,7 @@ discard block |
||
| 1212 | 1210 | } |
| 1213 | 1211 | else |
| 1214 | 1212 | { |
| 1215 | - $msg .= Vfs::eacl($path,$content['eacl']['rights'],$content['eacl_owner']) ? |
|
| 1213 | + $msg .= Vfs::eacl($path, $content['eacl']['rights'], $content['eacl_owner']) ? |
|
| 1216 | 1214 | lang('ACL added.') : lang('Error adding the ACL!'); |
| 1217 | 1215 | } |
| 1218 | 1216 | } |
@@ -1222,7 +1220,7 @@ discard block |
||
| 1222 | 1220 | } |
| 1223 | 1221 | if ($content['is_link'] && !Vfs::stat($path)) |
| 1224 | 1222 | { |
| 1225 | - $msg .= ($msg ? "\n" : '').lang('Link target %1 not found!',$content['symlink']); |
|
| 1223 | + $msg .= ($msg ? "\n" : '').lang('Link target %1 not found!', $content['symlink']); |
|
| 1226 | 1224 | } |
| 1227 | 1225 | $content['link'] = Egw::link(Vfs::download_url($path)); |
| 1228 | 1226 | $content['icon'] = Vfs::mime_icon($content['mime']); |
@@ -1231,11 +1229,11 @@ discard block |
||
| 1231 | 1229 | if (($readonlys['uid'] = !Vfs::$is_root) && !$content['uid']) $content['ro_uid_root'] = 'root'; |
| 1232 | 1230 | // only owner can change group & perms |
| 1233 | 1231 | if (($readonlys['gid'] = !$content['is_owner'] || |
| 1234 | - Vfs::parse_url(Vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs') ||// no uid, gid or perms in oldvfs |
|
| 1232 | + Vfs::parse_url(Vfs::resolve_url($content['path']), PHP_URL_SCHEME) == 'oldvfs') || // no uid, gid or perms in oldvfs |
|
| 1235 | 1233 | !Vfs::is_writable($path)) |
| 1236 | 1234 | { |
| 1237 | 1235 | if (!$content['gid']) $content['ro_gid_root'] = 'root'; |
| 1238 | - foreach($content['perms'] as $name => $value) |
|
| 1236 | + foreach ($content['perms'] as $name => $value) |
|
| 1239 | 1237 | { |
| 1240 | 1238 | $readonlys['perms['.$name.']'] = true; |
| 1241 | 1239 | } |
@@ -1254,38 +1252,38 @@ discard block |
||
| 1254 | 1252 | } |
| 1255 | 1253 | elseif (!Vfs::is_writable($path)) |
| 1256 | 1254 | { |
| 1257 | - foreach($cfs as $name => $data) |
|
| 1255 | + foreach ($cfs as $name => $data) |
|
| 1258 | 1256 | { |
| 1259 | 1257 | $readonlys['#'.$name] = true; |
| 1260 | 1258 | } |
| 1261 | 1259 | } |
| 1262 | - $readonlys['tabs']['filemanager.file.eacl'] = true; // eacl off by default |
|
| 1260 | + $readonlys['tabs']['filemanager.file.eacl'] = true; // eacl off by default |
|
| 1263 | 1261 | if ($content['is_dir']) |
| 1264 | 1262 | { |
| 1265 | - $readonlys['tabs']['filemanager.file.preview'] = true; // no preview tab for dirs |
|
| 1266 | - $sel_options['rights']=$sel_options['owner']=$sel_options['group']=$sel_options['other'] = array( |
|
| 1263 | + $readonlys['tabs']['filemanager.file.preview'] = true; // no preview tab for dirs |
|
| 1264 | + $sel_options['rights'] = $sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array( |
|
| 1267 | 1265 | 7 => lang('Display and modification of content'), |
| 1268 | 1266 | 5 => lang('Display of content'), |
| 1269 | 1267 | 0 => lang('No access'), |
| 1270 | 1268 | ); |
| 1271 | - if(($content['eacl'] = Vfs::get_eacl($content['path'])) !== false && // backend supports eacl |
|
| 1269 | + if (($content['eacl'] = Vfs::get_eacl($content['path'])) !== false && // backend supports eacl |
|
| 1272 | 1270 | $GLOBALS['egw_info']['user']['account_id'] == Vfs::$user) // leave eACL tab disabled for sharing |
| 1273 | 1271 | { |
| 1274 | - unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again |
|
| 1275 | - foreach($content['eacl'] as &$eacl) |
|
| 1272 | + unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again |
|
| 1273 | + foreach ($content['eacl'] as &$eacl) |
|
| 1276 | 1274 | { |
| 1277 | - $eacl['path'] = rtrim(Vfs::parse_url($eacl['path'],PHP_URL_PATH),'/'); |
|
| 1275 | + $eacl['path'] = rtrim(Vfs::parse_url($eacl['path'], PHP_URL_PATH), '/'); |
|
| 1278 | 1276 | $readonlys['delete['.$eacl['ino'].'-'.$eacl['owner'].']'] = $eacl['ino'] != $content['ino'] || |
| 1279 | 1277 | $eacl['path'] != $content['path'] || !$content['is_owner']; |
| 1280 | 1278 | } |
| 1281 | - array_unshift($content['eacl'],false); // make the keys start with 1, not 0 |
|
| 1279 | + array_unshift($content['eacl'], false); // make the keys start with 1, not 0 |
|
| 1282 | 1280 | $content['eacl']['owner'] = 0; |
| 1283 | 1281 | $content['eacl']['rights'] = 5; |
| 1284 | 1282 | } |
| 1285 | 1283 | } |
| 1286 | 1284 | else |
| 1287 | 1285 | { |
| 1288 | - $sel_options['owner']=$sel_options['group']=$sel_options['other'] = array( |
|
| 1286 | + $sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array( |
|
| 1289 | 1287 | 6 => lang('Read & write access'), |
| 1290 | 1288 | 4 => lang('Read access only'), |
| 1291 | 1289 | 0 => lang('No access'), |
@@ -1295,11 +1293,11 @@ discard block |
||
| 1295 | 1293 | // mergeapp |
| 1296 | 1294 | $content['mergeapp'] = static::get_mergeapp($path, 'self'); |
| 1297 | 1295 | $content['mergeapp_parent'] = static::get_mergeapp($path, 'parents'); |
| 1298 | - if(!empty($content['mergeapp'])) |
|
| 1296 | + if (!empty($content['mergeapp'])) |
|
| 1299 | 1297 | { |
| 1300 | 1298 | $content['mergeapp_effective'] = $content['mergeapp']; |
| 1301 | 1299 | } |
| 1302 | - elseif(!empty($content['mergeapp_parent'])) |
|
| 1300 | + elseif (!empty($content['mergeapp_parent'])) |
|
| 1303 | 1301 | { |
| 1304 | 1302 | $content['mergeapp_effective'] = $content['mergeapp_parent']; |
| 1305 | 1303 | } |
@@ -1311,7 +1309,7 @@ discard block |
||
| 1311 | 1309 | $mergeapp_list = Link::app_list('merge'); |
| 1312 | 1310 | unset($mergeapp_list[$GLOBALS['egw_info']['flags']['currentapp']]); // exclude filemanager from list |
| 1313 | 1311 | $mergeapp_empty = !empty($content['mergeapp_parent']) |
| 1314 | - ? $mergeapp_list[$content['mergeapp_parent']] . ' (parent setting)' : ''; |
|
| 1312 | + ? $mergeapp_list[$content['mergeapp_parent']].' (parent setting)' : ''; |
|
| 1315 | 1313 | $sel_options['mergeapp'] = array('' => $mergeapp_empty); |
| 1316 | 1314 | $sel_options['mergeapp'] = $sel_options['mergeapp'] + $mergeapp_list; |
| 1317 | 1315 | // mergeapp other gui options |
@@ -1328,7 +1326,7 @@ discard block |
||
| 1328 | 1326 | 'comment' => (string)$content['comment'], |
| 1329 | 1327 | 'mergeapp' => $content['mergeapp'] |
| 1330 | 1328 | ); |
| 1331 | - if ($cfs) foreach($cfs as $name => $data) |
|
| 1329 | + if ($cfs) foreach ($cfs as $name => $data) |
|
| 1332 | 1330 | { |
| 1333 | 1331 | $preserve['old']['#'.$name] = (string)$content['#'.$name]; |
| 1334 | 1332 | } |
@@ -1336,31 +1334,31 @@ discard block |
||
| 1336 | 1334 | if (Vfs::$is_root) |
| 1337 | 1335 | { |
| 1338 | 1336 | $tpl->setElementAttribute('sudouser', 'label', 'Logout'); |
| 1339 | - $tpl->setElementAttribute('sudouser', 'help','Log out as superuser'); |
|
| 1337 | + $tpl->setElementAttribute('sudouser', 'help', 'Log out as superuser'); |
|
| 1340 | 1338 | // Need a more complex submit because button type is buttononly, which doesn't submit |
| 1341 | - $tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"login")'); |
|
| 1339 | + $tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"login")'); |
|
| 1342 | 1340 | |
| 1343 | 1341 | } |
| 1344 | 1342 | elseif ($button == 'sudo') |
| 1345 | 1343 | { |
| 1346 | 1344 | $tpl->setElementAttribute('sudouser', 'label', 'Superuser'); |
| 1347 | - $tpl->setElementAttribute('sudouser', 'help','Enter setup user and password to get root rights'); |
|
| 1348 | - $tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"logout")'); |
|
| 1345 | + $tpl->setElementAttribute('sudouser', 'help', 'Enter setup user and password to get root rights'); |
|
| 1346 | + $tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"logout")'); |
|
| 1349 | 1347 | } |
| 1350 | 1348 | else if (self::is_anonymous($GLOBALS['egw_info']['user']['account_id'])) |
| 1351 | 1349 | { |
| 1352 | 1350 | // Just hide sudo for anonymous users |
| 1353 | 1351 | $readonlys['sudouser'] = true; |
| 1354 | 1352 | } |
| 1355 | - if (($extra_tabs = Vfs::getExtraInfo($path,$content))) |
|
| 1353 | + if (($extra_tabs = Vfs::getExtraInfo($path, $content))) |
|
| 1356 | 1354 | { |
| 1357 | 1355 | // add to existing tabs in template |
| 1358 | 1356 | $tpl->setElementAttribute('tabs', 'add_tabs', true); |
| 1359 | 1357 | |
| 1360 | - $tabs =& $tpl->getElementAttribute('tabs','tabs'); |
|
| 1358 | + $tabs = & $tpl->getElementAttribute('tabs', 'tabs'); |
|
| 1361 | 1359 | if (true) $tabs = array(); |
| 1362 | 1360 | |
| 1363 | - foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
|
| 1361 | + foreach (isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) |
|
| 1364 | 1362 | { |
| 1365 | 1363 | $tabs[] = array( |
| 1366 | 1364 | 'label' => $extra_tab['label'], |
@@ -1383,7 +1381,7 @@ discard block |
||
| 1383 | 1381 | Framework::window_focus(); |
| 1384 | 1382 | $GLOBALS['egw_info']['flags']['app_header'] = lang('Preferences').' '.Vfs::decodePath($path); |
| 1385 | 1383 | |
| 1386 | - $tpl->exec('filemanager.filemanager_ui.file',$content,$sel_options,$readonlys,$preserve,2); |
|
| 1384 | + $tpl->exec('filemanager.filemanager_ui.file', $content, $sel_options, $readonlys, $preserve, 2); |
|
| 1387 | 1385 | } |
| 1388 | 1386 | |
| 1389 | 1387 | /** |
@@ -1405,7 +1403,7 @@ discard block |
||
| 1405 | 1403 | * @param string $dir=null current directory |
| 1406 | 1404 | * @see static::action() |
| 1407 | 1405 | */ |
| 1408 | - public static function ajax_action($action, $selected, $dir=null, $props=null) |
|
| 1406 | + public static function ajax_action($action, $selected, $dir = null, $props = null) |
|
| 1409 | 1407 | { |
| 1410 | 1408 | // do we have root rights, need to run here too, as method is static and therefore does NOT run __construct |
| 1411 | 1409 | if (Api\Cache::getSession('filemanager', 'is_root')) |
@@ -1424,15 +1422,15 @@ discard block |
||
| 1424 | 1422 | |
| 1425 | 1423 | if (!isset($dir)) $dir = array_pop($selected); |
| 1426 | 1424 | |
| 1427 | - switch($action) |
|
| 1425 | + switch ($action) |
|
| 1428 | 1426 | { |
| 1429 | 1427 | case 'upload': |
| 1430 | 1428 | $script_error = 0; |
| 1431 | - foreach($selected as $tmp_name => &$data) |
|
| 1429 | + foreach ($selected as $tmp_name => &$data) |
|
| 1432 | 1430 | { |
| 1433 | 1431 | $path = Vfs::concat($dir, Vfs::encodePathComponent($data['name'])); |
| 1434 | 1432 | |
| 1435 | - if(Vfs::deny_script($path)) |
|
| 1433 | + if (Vfs::deny_script($path)) |
|
| 1436 | 1434 | { |
| 1437 | 1435 | if (!isset($script_error)) |
| 1438 | 1436 | { |
@@ -1454,7 +1452,7 @@ discard block |
||
| 1454 | 1452 | { |
| 1455 | 1453 | if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir'])) |
| 1456 | 1454 | { |
| 1457 | - $tmp_path = $GLOBALS['egw_info']['server']['temp_dir'] . '/' . basename($tmp_name); |
|
| 1455 | + $tmp_path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($tmp_name); |
|
| 1458 | 1456 | } |
| 1459 | 1457 | else |
| 1460 | 1458 | { |
@@ -1486,7 +1484,7 @@ discard block |
||
| 1486 | 1484 | break; |
| 1487 | 1485 | |
| 1488 | 1486 | case 'sharelink': |
| 1489 | - $share = Vfs\Sharing::create($selected, Vfs\Sharing::READONLY, basename($selected), array() ); |
|
| 1487 | + $share = Vfs\Sharing::create($selected, Vfs\Sharing::READONLY, basename($selected), array()); |
|
| 1490 | 1488 | $arr["share_link"] = $link = Vfs\Sharing::share2link($share); |
| 1491 | 1489 | $arr["template"] = Api\Etemplate\Widget\Template::rel2url('/filemanager/templates/default/share_dialog.xet'); |
| 1492 | 1490 | break; |
@@ -1495,16 +1493,16 @@ discard block |
||
| 1495 | 1493 | case 'link': |
| 1496 | 1494 | // First upload |
| 1497 | 1495 | $arr = static::ajax_action('upload', $selected, $dir, $props); |
| 1498 | - $app_dir = Link::vfs_path($props['entry']['app'],$props['entry']['id'],'',true); |
|
| 1496 | + $app_dir = Link::vfs_path($props['entry']['app'], $props['entry']['id'], '', true); |
|
| 1499 | 1497 | |
| 1500 | - foreach($arr['uploaded'] as $file) |
|
| 1498 | + foreach ($arr['uploaded'] as $file) |
|
| 1501 | 1499 | { |
| 1502 | - $target=Vfs::concat($dir,Vfs::encodePathComponent($file['name'])); |
|
| 1500 | + $target = Vfs::concat($dir, Vfs::encodePathComponent($file['name'])); |
|
| 1503 | 1501 | if (Vfs::file_exists($target) && $app_dir) |
| 1504 | 1502 | { |
| 1505 | 1503 | if (!Vfs::file_exists($app_dir)) Vfs::mkdir($app_dir); |
| 1506 | 1504 | error_log("Symlinking $target to $app_dir"); |
| 1507 | - Vfs::symlink($target, Vfs::concat($app_dir,Vfs::encodePathComponent($file['name']))); |
|
| 1505 | + Vfs::symlink($target, Vfs::concat($app_dir, Vfs::encodePathComponent($file['name']))); |
|
| 1508 | 1506 | } |
| 1509 | 1507 | } |
| 1510 | 1508 | // Must return to avoid adding to $response again |
@@ -1526,7 +1524,7 @@ discard block |
||
| 1526 | 1524 | */ |
| 1527 | 1525 | private function perms2mode(array $perms) |
| 1528 | 1526 | { |
| 1529 | - $mode = $perms['owner'] << 6 | $perms['group'] << 3 | $perms['other']; |
|
| 1527 | + $mode = $perms['owner'] << 6|$perms['group'] << 3|$perms['other']; |
|
| 1530 | 1528 | if ($mode['executable']) |
| 1531 | 1529 | { |
| 1532 | 1530 | $mode |= 0111; |
@@ -155,7 +155,7 @@ |
||
| 155 | 155 | * Get a list of the user's portlets, and their associated values & settings, for display |
| 156 | 156 | * |
| 157 | 157 | * Actual portlet content is provided by each portlet. |
| 158 | - * @param template etemplate so attributes can be set |
|
| 158 | + * @param template Etemplate so attributes can be set |
|
| 159 | 159 | */ |
| 160 | 160 | protected function get_user_portlets(Etemplate &$template) |
| 161 | 161 | { |
@@ -76,7 +76,10 @@ discard block |
||
| 76 | 76 | { |
| 77 | 77 | $id = $p_data['id']; |
| 78 | 78 | |
| 79 | - if(!$id) continue; |
|
| 79 | + if(!$id) |
|
| 80 | + { |
|
| 81 | + continue; |
|
| 82 | + } |
|
| 80 | 83 | $portlet = $this->get_portlet($id, $p_data, $content, $attrs, true); |
| 81 | 84 | } |
| 82 | 85 | |
@@ -135,7 +138,10 @@ discard block |
||
| 135 | 138 | { |
| 136 | 139 | foreach($children['children'] as $portlet => $app_portlet) |
| 137 | 140 | { |
| 138 | - if(!is_array($app_portlet)) continue; |
|
| 141 | + if(!is_array($app_portlet)) |
|
| 142 | + { |
|
| 143 | + continue; |
|
| 144 | + } |
|
| 139 | 145 | $app_portlet['class'] = $portlet; |
| 140 | 146 | $app_portlet['id'] = 'drop_' . $app_portlet['id']; |
| 141 | 147 | $app_portlet['onExecute'] = $drop_execute; |
@@ -166,14 +172,21 @@ discard block |
||
| 166 | 172 | if(strpos($id,'portlet_') !== 0 || // Not a portlet |
| 167 | 173 | in_array($id, array_keys($GLOBALS['egw_info']['user']['apps'])) || // Some other app put it's pref in here |
| 168 | 174 | !is_array($context) // Not a valid portlet (probably user deleted a default) |
| 169 | - ) continue; |
|
| 175 | + ) |
|
| 176 | + { |
|
| 177 | + continue; |
|
| 178 | + } |
|
| 170 | 179 | |
| 171 | 180 | $classname = $context['class']; |
| 172 | 181 | |
| 173 | 182 | // Avoid portlets for apps user can't use (eg. from defaults/forced) |
| 174 | 183 | list($app,$other) = explode('_',$classname); |
| 175 | - if(!$GLOBALS['egw_info']['apps'][$app]) $app .='_'.$other; |
|
| 176 | - if(!$GLOBALS['egw_info']['user']['apps'][$app]) { |
|
| 184 | + if(!$GLOBALS['egw_info']['apps'][$app]) |
|
| 185 | + { |
|
| 186 | + $app .='_'.$other; |
|
| 187 | + } |
|
| 188 | + if(!$GLOBALS['egw_info']['user']['apps'][$app]) |
|
| 189 | + { |
|
| 177 | 190 | continue; |
| 178 | 191 | } |
| 179 | 192 | |
@@ -189,7 +202,10 @@ discard block |
||
| 189 | 202 | $settings = $portlet->get_properties(); |
| 190 | 203 | foreach($settings as $key => $setting) |
| 191 | 204 | { |
| 192 | - if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]); |
|
| 205 | + if(is_array($setting) && !array_key_exists('type',$setting)) |
|
| 206 | + { |
|
| 207 | + unset($settings[$key]); |
|
| 208 | + } |
|
| 193 | 209 | } |
| 194 | 210 | $settings += $context; |
| 195 | 211 | foreach(home_portlet::$common_attributes as $attr) |
@@ -229,7 +245,10 @@ discard block |
||
| 229 | 245 | */ |
| 230 | 246 | protected function get_portlet($id, &$context, &$content, &$attributes, $full_exec = false) |
| 231 | 247 | { |
| 232 | - if(!$context['class']) $context['class'] = 'home_link_portlet'; |
|
| 248 | + if(!$context['class']) |
|
| 249 | + { |
|
| 250 | + $context['class'] = 'home_link_portlet'; |
|
| 251 | + } |
|
| 233 | 252 | |
| 234 | 253 | // This should be set already, but just in case the execution path |
| 235 | 254 | // is different from normal... |
@@ -250,7 +269,10 @@ discard block |
||
| 250 | 269 | $settings = $portlet->get_properties(); |
| 251 | 270 | foreach($settings as $key => $setting) |
| 252 | 271 | { |
| 253 | - if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]); |
|
| 272 | + if(is_array($setting) && !array_key_exists('type',$setting)) |
|
| 273 | + { |
|
| 274 | + unset($settings[$key]); |
|
| 275 | + } |
|
| 254 | 276 | } |
| 255 | 277 | $settings += $context; |
| 256 | 278 | foreach(home_portlet::$common_attributes as $attr) |
@@ -314,7 +336,10 @@ discard block |
||
| 314 | 336 | foreach($sorted_apps as $appname) |
| 315 | 337 | { |
| 316 | 338 | // If there's already [new] settings, or no preference, skip it |
| 317 | - if($content[$appname]) continue; |
|
| 339 | + if($content[$appname]) |
|
| 340 | + { |
|
| 341 | + continue; |
|
| 342 | + } |
|
| 318 | 343 | $no_pref = true; |
| 319 | 344 | foreach($portal_oldvarnames as $varcheck) |
| 320 | 345 | { |
@@ -349,7 +374,8 @@ discard block |
||
| 349 | 374 | */ |
| 350 | 375 | protected function get_portlet_list() |
| 351 | 376 | { |
| 352 | - $list = Api\Cache::getTree('home', 'portlet_classes', function() { |
|
| 377 | + $list = Api\Cache::getTree('home', 'portlet_classes', function() |
|
| 378 | + { |
|
| 353 | 379 | $list = array(); |
| 354 | 380 | $classes = array(); |
| 355 | 381 | |
@@ -363,9 +389,15 @@ discard block |
||
| 363 | 389 | // Look through all known classes for portlets - for now, they need 'portlet' in the file name |
| 364 | 390 | foreach(array_keys($GLOBALS['egw_info']['apps']) as $appname) |
| 365 | 391 | { |
| 366 | - if(in_array($appname, array('phpgwapi', 'felamimail'))) continue; |
|
| 392 | + if(in_array($appname, array('phpgwapi', 'felamimail'))) |
|
| 393 | + { |
|
| 394 | + continue; |
|
| 395 | + } |
|
| 367 | 396 | $files = (array)@scandir(EGW_SERVER_ROOT . '/'.$appname .'/inc/'); |
| 368 | - if(!$files) continue; |
|
| 397 | + if(!$files) |
|
| 398 | + { |
|
| 399 | + continue; |
|
| 400 | + } |
|
| 369 | 401 | |
| 370 | 402 | foreach($files as $entry) |
| 371 | 403 | { |
@@ -384,7 +416,10 @@ discard block |
||
| 384 | 416 | } |
| 385 | 417 | } |
| 386 | 418 | |
| 387 | - if(!$classes[$appname]) continue; |
|
| 419 | + if(!$classes[$appname]) |
|
| 420 | + { |
|
| 421 | + continue; |
|
| 422 | + } |
|
| 388 | 423 | |
| 389 | 424 | // Build 'Add' actions for each discovered portlet. |
| 390 | 425 | // Portlets from other apps go in sub-actions |
@@ -418,7 +453,8 @@ discard block |
||
| 418 | 453 | // Filter list by current user's permissions |
| 419 | 454 | foreach(array_keys($list) as $appname) |
| 420 | 455 | { |
| 421 | - if(in_array($appname, array_keys($GLOBALS['egw_info']['apps']))) { |
|
| 456 | + if(in_array($appname, array_keys($GLOBALS['egw_info']['apps']))) |
|
| 457 | + { |
|
| 422 | 458 | if(!in_array($appname, array_keys($GLOBALS['egw_info']['user']['apps']))) |
| 423 | 459 | { |
| 424 | 460 | unset($list[$appname]); |
@@ -638,7 +674,10 @@ discard block |
||
| 638 | 674 | public static function ajax_set_default($action, $portlet_ids, $group) |
| 639 | 675 | { |
| 640 | 676 | // Admins only |
| 641 | - if(!$GLOBALS['egw_info']['apps']['admin']) return; |
|
| 677 | + if(!$GLOBALS['egw_info']['apps']['admin']) |
|
| 678 | + { |
|
| 679 | + return; |
|
| 680 | + } |
|
| 642 | 681 | |
| 643 | 682 | // Load the appropriate group |
| 644 | 683 | if($group) |
@@ -701,7 +740,10 @@ discard block |
||
| 701 | 740 | $preferences = $GLOBALS['egw']->preferences; |
| 702 | 741 | $preferences->read_repository(); |
| 703 | 742 | $lang = $preferences->default['common']['lang']; |
| 704 | - if (empty($lang)) $lang = 'en'; |
|
| 743 | + if (empty($lang)) |
|
| 744 | + { |
|
| 745 | + $lang = 'en'; |
|
| 746 | + } |
|
| 705 | 747 | |
| 706 | 748 | Api\Translation::add_app('calendar', $lang); |
| 707 | 749 | $weekview = lang('Weekview'); |
@@ -49,21 +49,21 @@ discard block |
||
| 49 | 49 | $content = array( |
| 50 | 50 | 'portlets' => $this->get_user_portlets($template) |
| 51 | 51 | ); |
| 52 | - $template->setElementAttribute('home.index','actions',$this->get_actions()); |
|
| 52 | + $template->setElementAttribute('home.index', 'actions', $this->get_actions()); |
|
| 53 | 53 | |
| 54 | 54 | $GLOBALS['egw_info']['flags']['app_header'] = lang('home'); |
| 55 | 55 | $GLOBALS['egw_info']['flags']['currentapp'] = 'home'; |
| 56 | 56 | |
| 57 | 57 | // Main screen message |
| 58 | 58 | Api\Translation::add_app('mainscreen'); |
| 59 | - $greeting = Api\Translation::translate('mainscreen_message',false,''); |
|
| 59 | + $greeting = Api\Translation::translate('mainscreen_message', false, ''); |
|
| 60 | 60 | |
| 61 | - if($greeting == 'mainscreen_message'|| empty($greeting)) |
|
| 61 | + if ($greeting == 'mainscreen_message' || empty($greeting)) |
|
| 62 | 62 | { |
| 63 | - Api\Translation::add_app('mainscreen','en'); // trying the en one |
|
| 64 | - $greeting = Api\Translation::translate('mainscreen_message',false,''); |
|
| 63 | + Api\Translation::add_app('mainscreen', 'en'); // trying the en one |
|
| 64 | + $greeting = Api\Translation::translate('mainscreen_message', false, ''); |
|
| 65 | 65 | } |
| 66 | - if(!($greeting == 'mainscreen_message'|| empty($greeting))) |
|
| 66 | + if (!($greeting == 'mainscreen_message' || empty($greeting))) |
|
| 67 | 67 | { |
| 68 | 68 | $content['mainscreen_message'] = $greeting; |
| 69 | 69 | } |
@@ -72,11 +72,11 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | // Now run the portlets themselves |
| 74 | 74 | $attrs = array(); |
| 75 | - foreach($content['portlets'] as $portlet => $p_data) |
|
| 75 | + foreach ($content['portlets'] as $portlet => $p_data) |
|
| 76 | 76 | { |
| 77 | 77 | $id = $p_data['id']; |
| 78 | 78 | |
| 79 | - if(!$id) continue; |
|
| 79 | + if (!$id) continue; |
|
| 80 | 80 | $portlet = $this->get_portlet($id, $p_data, $content, $attrs, true); |
| 81 | 81 | } |
| 82 | 82 | |
@@ -94,15 +94,15 @@ discard block |
||
| 94 | 94 | $add_portlets = $portlets; |
| 95 | 95 | $change_for_add = function(&$add_portlets) use (&$change_for_add) |
| 96 | 96 | { |
| 97 | - foreach($add_portlets as $id => &$add) |
|
| 97 | + foreach ($add_portlets as $id => &$add) |
|
| 98 | 98 | { |
| 99 | - if(is_array($add['children'])) |
|
| 99 | + if (is_array($add['children'])) |
|
| 100 | 100 | { |
| 101 | 101 | $change_for_add($add['children']); |
| 102 | 102 | } |
| 103 | - if($id && !$add['children']) |
|
| 103 | + if ($id && !$add['children']) |
|
| 104 | 104 | { |
| 105 | - $add['id'] = 'add_' . $id; |
|
| 105 | + $add['id'] = 'add_'.$id; |
|
| 106 | 106 | $add['class'] = 'add_'.$id; |
| 107 | 107 | } |
| 108 | 108 | } |
@@ -121,10 +121,10 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | // Add all known portlets as drop actions too. If there are multiple matches, there will be a menu |
| 123 | 123 | $drop_execute = 'javaScript:app.home.add_from_drop'; |
| 124 | - foreach($portlets as $app => &$children) |
|
| 124 | + foreach ($portlets as $app => &$children) |
|
| 125 | 125 | { |
| 126 | 126 | // Home portlets - uses link system, so all apps that support that are accepted |
| 127 | - if(!$children['children']) |
|
| 127 | + if (!$children['children']) |
|
| 128 | 128 | { |
| 129 | 129 | $children['class'] = $app; |
| 130 | 130 | $children['onExecute'] = $drop_execute; |
@@ -133,11 +133,11 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | else |
| 135 | 135 | { |
| 136 | - foreach($children['children'] as $portlet => $app_portlet) |
|
| 136 | + foreach ($children['children'] as $portlet => $app_portlet) |
|
| 137 | 137 | { |
| 138 | - if(!is_array($app_portlet)) continue; |
|
| 138 | + if (!is_array($app_portlet)) continue; |
|
| 139 | 139 | $app_portlet['class'] = $portlet; |
| 140 | - $app_portlet['id'] = 'drop_' . $app_portlet['id']; |
|
| 140 | + $app_portlet['id'] = 'drop_'.$app_portlet['id']; |
|
| 141 | 141 | $app_portlet['onExecute'] = $drop_execute; |
| 142 | 142 | $app_portlet['acceptedTypes'] = $app; |
| 143 | 143 | $app_portlet['type'] = 'drop'; |
@@ -161,9 +161,9 @@ discard block |
||
| 161 | 161 | { |
| 162 | 162 | $portlets = array(); |
| 163 | 163 | |
| 164 | - foreach((array)$GLOBALS['egw_info']['user']['preferences']['home']as $id => $context) |
|
| 164 | + foreach ((array)$GLOBALS['egw_info']['user']['preferences']['home']as $id => $context) |
|
| 165 | 165 | { |
| 166 | - if(strpos($id,'portlet_') !== 0 || // Not a portlet |
|
| 166 | + if (strpos($id, 'portlet_') !== 0 || // Not a portlet |
|
| 167 | 167 | in_array($id, array_keys($GLOBALS['egw_info']['user']['apps'])) || // Some other app put it's pref in here |
| 168 | 168 | !is_array($context) // Not a valid portlet (probably user deleted a default) |
| 169 | 169 | ) continue; |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | $classname = $context['class']; |
| 172 | 172 | |
| 173 | 173 | // Avoid portlets for apps user can't use (eg. from defaults/forced) |
| 174 | - list($app,$other) = explode('_',$classname); |
|
| 175 | - if(!$GLOBALS['egw_info']['apps'][$app]) $app .='_'.$other; |
|
| 176 | - if(!$GLOBALS['egw_info']['user']['apps'][$app]) { |
|
| 174 | + list($app, $other) = explode('_', $classname); |
|
| 175 | + if (!$GLOBALS['egw_info']['apps'][$app]) $app .= '_'.$other; |
|
| 176 | + if (!$GLOBALS['egw_info']['user']['apps'][$app]) { |
|
| 177 | 177 | continue; |
| 178 | 178 | } |
| 179 | 179 | |
@@ -187,12 +187,12 @@ discard block |
||
| 187 | 187 | // Get settings |
| 188 | 188 | // Exclude common attributes changed through UI and settings lacking a type |
| 189 | 189 | $settings = $portlet->get_properties(); |
| 190 | - foreach($settings as $key => $setting) |
|
| 190 | + foreach ($settings as $key => $setting) |
|
| 191 | 191 | { |
| 192 | - if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]); |
|
| 192 | + if (is_array($setting) && !array_key_exists('type', $setting)) unset($settings[$key]); |
|
| 193 | 193 | } |
| 194 | 194 | $settings += $context; |
| 195 | - foreach(home_portlet::$common_attributes as $attr) |
|
| 195 | + foreach (home_portlet::$common_attributes as $attr) |
|
| 196 | 196 | { |
| 197 | 197 | unset($settings[$attr]); |
| 198 | 198 | } |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | // Add in default for admins |
| 206 | 206 | self::create_default_actions($actions, $id); |
| 207 | 207 | |
| 208 | - $template->setElementAttribute("portlets[" . count($portlets) . "[$id]", 'actions', $actions); |
|
| 208 | + $template->setElementAttribute("portlets[".count($portlets)."[$id]", 'actions', $actions); |
|
| 209 | 209 | |
| 210 | 210 | $portlets[] = $portlet_content; |
| 211 | 211 | } |
@@ -229,11 +229,11 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | protected function get_portlet($id, &$context, &$content, &$attributes, $full_exec = false) |
| 231 | 231 | { |
| 232 | - if(!$context['class']) $context['class'] = 'home_link_portlet'; |
|
| 232 | + if (!$context['class']) $context['class'] = 'home_link_portlet'; |
|
| 233 | 233 | |
| 234 | 234 | // This should be set already, but just in case the execution path |
| 235 | 235 | // is different from normal... |
| 236 | - if(Api\Json\Response::isJSONResponse()) |
|
| 236 | + if (Api\Json\Response::isJSONResponse()) |
|
| 237 | 237 | { |
| 238 | 238 | $GLOBALS['egw']->framework->response = Api\Json\Response::get(); |
| 239 | 239 | } |
@@ -248,12 +248,12 @@ discard block |
||
| 248 | 248 | |
| 249 | 249 | // Exclude common attributes changed through UI and settings lacking a type |
| 250 | 250 | $settings = $portlet->get_properties(); |
| 251 | - foreach($settings as $key => $setting) |
|
| 251 | + foreach ($settings as $key => $setting) |
|
| 252 | 252 | { |
| 253 | - if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]); |
|
| 253 | + if (is_array($setting) && !array_key_exists('type', $setting)) unset($settings[$key]); |
|
| 254 | 254 | } |
| 255 | 255 | $settings += $context; |
| 256 | - foreach(home_portlet::$common_attributes as $attr) |
|
| 256 | + foreach (home_portlet::$common_attributes as $attr) |
|
| 257 | 257 | { |
| 258 | 258 | unset($settings[$attr]); |
| 259 | 259 | } |
@@ -268,31 +268,31 @@ discard block |
||
| 268 | 268 | self::create_default_actions($attributes['actions'], $id); |
| 269 | 269 | |
| 270 | 270 | // Set any provided common attributes (size, etc) |
| 271 | - foreach(home_portlet::$common_attributes as $name) |
|
| 271 | + foreach (home_portlet::$common_attributes as $name) |
|
| 272 | 272 | { |
| 273 | - if(array_key_exists($name, $context)) |
|
| 273 | + if (array_key_exists($name, $context)) |
|
| 274 | 274 | { |
| 275 | 275 | $attributes[$name] = $context[$name]; |
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | - foreach($attributes as $attr => $value) |
|
| 278 | + foreach ($attributes as $attr => $value) |
|
| 279 | 279 | { |
| 280 | 280 | $etemplate->setElementAttribute($id, $attr, $value); |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | // Make sure custom javascript is loaded |
| 284 | 284 | $appname = $context['appname']; |
| 285 | - if(!$appname) |
|
| 285 | + if (!$appname) |
|
| 286 | 286 | { |
| 287 | - list($app) = explode('_',$classname); |
|
| 288 | - if($GLOBALS['egw_info']['apps'][$app]) |
|
| 287 | + list($app) = explode('_', $classname); |
|
| 288 | + if ($GLOBALS['egw_info']['apps'][$app]) |
|
| 289 | 289 | { |
| 290 | 290 | $appname = $app; |
| 291 | 291 | } |
| 292 | 292 | } |
| 293 | 293 | Framework::includeJS('', $classname, $appname ? $appname : 'home'); |
| 294 | 294 | |
| 295 | - if($full_exec) |
|
| 295 | + if ($full_exec) |
|
| 296 | 296 | { |
| 297 | 297 | $content = $portlet->exec($id, $etemplate, $full_exec ? 2 : -1); |
| 298 | 298 | } |
@@ -309,23 +309,23 @@ discard block |
||
| 309 | 309 | protected function get_legacy_portlets(&$content, &$attributes) |
| 310 | 310 | { |
| 311 | 311 | $sorted_apps = array_keys($GLOBALS['egw_info']['user']['apps']); |
| 312 | - $portal_oldvarnames = array('mainscreen_showevents', 'homeShowEvents','homeShowLatest','mainscreen_showmail','mainscreen_showbirthdays','mainscreen_show_new_updated', 'homepage_display'); |
|
| 312 | + $portal_oldvarnames = array('mainscreen_showevents', 'homeShowEvents', 'homeShowLatest', 'mainscreen_showmail', 'mainscreen_showbirthdays', 'mainscreen_show_new_updated', 'homepage_display'); |
|
| 313 | 313 | |
| 314 | - foreach($sorted_apps as $appname) |
|
| 314 | + foreach ($sorted_apps as $appname) |
|
| 315 | 315 | { |
| 316 | 316 | // If there's already [new] settings, or no preference, skip it |
| 317 | - if($content[$appname]) continue; |
|
| 317 | + if ($content[$appname]) continue; |
|
| 318 | 318 | $no_pref = true; |
| 319 | - foreach($portal_oldvarnames as $varcheck) |
|
| 319 | + foreach ($portal_oldvarnames as $varcheck) |
|
| 320 | 320 | { |
| 321 | 321 | $thisd = $GLOBALS['egw_info']['user']['preferences'][$appname][$varcheck]; |
| 322 | - if($thisd) |
|
| 322 | + if ($thisd) |
|
| 323 | 323 | { |
| 324 | 324 | $no_pref = false; |
| 325 | 325 | break; |
| 326 | 326 | } |
| 327 | 327 | } |
| 328 | - if($no_pref || !Api\Hooks::exists('home', $appname)) |
|
| 328 | + if ($no_pref || !Api\Hooks::exists('home', $appname)) |
|
| 329 | 329 | { |
| 330 | 330 | continue; |
| 331 | 331 | } |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | $_content = ''; |
| 337 | 337 | $_attributes = array(); |
| 338 | 338 | $this->get_portlet($appname, $context, $_content, $_attributes); |
| 339 | - if(trim($_content)) |
|
| 339 | + if (trim($_content)) |
|
| 340 | 340 | { |
| 341 | 341 | $content[$appname] = $_content; |
| 342 | 342 | $attributes[$appname] = $_attributes; |
@@ -355,24 +355,24 @@ discard block |
||
| 355 | 355 | |
| 356 | 356 | // Ignore some problem files and base classes that shouldn't be options |
| 357 | 357 | $ignore = array( |
| 358 | - '.','..', |
|
| 358 | + '.', '..', |
|
| 359 | 359 | 'class.home_portlet.inc.php', |
| 360 | 360 | 'class.home_legacy_portlet.inc.php', |
| 361 | 361 | 'class.home_favorite_portlet.inc.php' |
| 362 | 362 | ); |
| 363 | 363 | // Look through all known classes for portlets - for now, they need 'portlet' in the file name |
| 364 | - foreach(array_keys($GLOBALS['egw_info']['apps']) as $appname) |
|
| 364 | + foreach (array_keys($GLOBALS['egw_info']['apps']) as $appname) |
|
| 365 | 365 | { |
| 366 | - if(in_array($appname, array('phpgwapi', 'felamimail'))) continue; |
|
| 367 | - $files = (array)@scandir(EGW_SERVER_ROOT . '/'.$appname .'/inc/'); |
|
| 368 | - if(!$files) continue; |
|
| 366 | + if (in_array($appname, array('phpgwapi', 'felamimail'))) continue; |
|
| 367 | + $files = (array)@scandir(EGW_SERVER_ROOT.'/'.$appname.'/inc/'); |
|
| 368 | + if (!$files) continue; |
|
| 369 | 369 | |
| 370 | - foreach($files as $entry) |
|
| 370 | + foreach ($files as $entry) |
|
| 371 | 371 | { |
| 372 | - if (!in_array($entry, $ignore) && substr($entry,-8) == '.inc.php' && strpos($entry,'portlet')) |
|
| 372 | + if (!in_array($entry, $ignore) && substr($entry, -8) == '.inc.php' && strpos($entry, 'portlet')) |
|
| 373 | 373 | { |
| 374 | 374 | list(,$classname) = explode('.', $entry); |
| 375 | - if(class_exists($classname) && |
|
| 375 | + if (class_exists($classname) && |
|
| 376 | 376 | in_array('home_portlet', class_parents($classname, false))) |
| 377 | 377 | { |
| 378 | 378 | $classes[$appname][] = $classname; |
@@ -384,19 +384,19 @@ discard block |
||
| 384 | 384 | } |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | - if(!$classes[$appname]) continue; |
|
| 387 | + if (!$classes[$appname]) continue; |
|
| 388 | 388 | |
| 389 | 389 | // Build 'Add' actions for each discovered portlet. |
| 390 | 390 | // Portlets from other apps go in sub-actions |
| 391 | - $add_to =& $list; |
|
| 392 | - if($classes[$appname] && $appname != 'home') |
|
| 391 | + $add_to = & $list; |
|
| 392 | + if ($classes[$appname] && $appname != 'home') |
|
| 393 | 393 | { |
| 394 | 394 | $list[$appname] = array( |
| 395 | 395 | 'caption' => lang($appname), |
| 396 | 396 | ); |
| 397 | - $add_to =& $list[$appname]['children']; |
|
| 397 | + $add_to = & $list[$appname]['children']; |
|
| 398 | 398 | } |
| 399 | - foreach($classes[$appname] as $portlet) |
|
| 399 | + foreach ($classes[$appname] as $portlet) |
|
| 400 | 400 | { |
| 401 | 401 | $instance = new $portlet(); |
| 402 | 402 | $desc = $instance->get_description(); |
@@ -416,10 +416,10 @@ discard block |
||
| 416 | 416 | }, array(), 60); |
| 417 | 417 | |
| 418 | 418 | // Filter list by current user's permissions |
| 419 | - foreach(array_keys($list) as $appname) |
|
| 419 | + foreach (array_keys($list) as $appname) |
|
| 420 | 420 | { |
| 421 | - if(in_array($appname, array_keys($GLOBALS['egw_info']['apps']))) { |
|
| 422 | - if(!in_array($appname, array_keys($GLOBALS['egw_info']['user']['apps']))) |
|
| 421 | + if (in_array($appname, array_keys($GLOBALS['egw_info']['apps']))) { |
|
| 422 | + if (!in_array($appname, array_keys($GLOBALS['egw_info']['user']['apps']))) |
|
| 423 | 423 | { |
| 424 | 424 | unset($list[$appname]); |
| 425 | 425 | } |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | */ |
| 437 | 437 | protected static function create_default_actions(&$actions, $portlet_id = null) |
| 438 | 438 | { |
| 439 | - if($GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 439 | + if ($GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 440 | 440 | { |
| 441 | 441 | $actions['add_default'] = array( |
| 442 | 442 | 'type' => 'popup', |
@@ -446,25 +446,25 @@ discard block |
||
| 446 | 446 | 'icon' => 'preference' |
| 447 | 447 | ); |
| 448 | 448 | // Customize for the given portlet |
| 449 | - if($portlet_id !== null) |
|
| 449 | + if ($portlet_id !== null) |
|
| 450 | 450 | { |
| 451 | - foreach(array('forced','group','default') as $location) |
|
| 451 | + foreach (array('forced', 'group', 'default') as $location) |
|
| 452 | 452 | { |
| 453 | 453 | $loc = $GLOBALS['egw']->preferences->$location; |
| 454 | 454 | |
| 455 | - if($loc['home'][$portlet_id]) |
|
| 455 | + if ($loc['home'][$portlet_id]) |
|
| 456 | 456 | { |
| 457 | 457 | // If it's forced, no point in setting default |
| 458 | - if($location == 'forced') |
|
| 458 | + if ($location == 'forced') |
|
| 459 | 459 | { |
| 460 | 460 | unset($actions['add_default']); |
| 461 | 461 | } |
| 462 | 462 | // If it's a group, we'd like to know which |
| 463 | - if($location == 'group') |
|
| 463 | + if ($location == 'group') |
|
| 464 | 464 | { |
| 465 | 465 | $options = array('account_type' => 'groups'); |
| 466 | - $groups = Api\Accounts::link_query('',$options); |
|
| 467 | - foreach(array_keys($groups) as $gid) |
|
| 466 | + $groups = Api\Accounts::link_query('', $options); |
|
| 467 | + foreach (array_keys($groups) as $gid) |
|
| 468 | 468 | { |
| 469 | 469 | $prefs = new Api\Preferences($gid); |
| 470 | 470 | $prefs->read_repository(); |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | } |
| 478 | 478 | $actions['remove_default_'.$location] = array( |
| 479 | 479 | 'type' => 'popup', |
| 480 | - 'caption' => lang('Remove as default for %1',is_numeric($location) ? Api\Accounts::id2name($location,'account_fullname') : $location), |
|
| 480 | + 'caption' => lang('Remove as default for %1', is_numeric($location) ? Api\Accounts::id2name($location, 'account_fullname') : $location), |
|
| 481 | 481 | 'onExecute' => 'javaScript:app.home.set_default', |
| 482 | 482 | 'group' => 'Admins', |
| 483 | 483 | 'portlet_group' => $location |
@@ -488,14 +488,14 @@ discard block |
||
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | // Change action for forced |
| 491 | - if($portlet_id && $GLOBALS['egw']->preferences->forced['home'][$portlet_id]) |
|
| 491 | + if ($portlet_id && $GLOBALS['egw']->preferences->forced['home'][$portlet_id]) |
|
| 492 | 492 | { |
| 493 | 493 | // No one can remove it |
| 494 | 494 | $actions['remove_portlet']['enabled'] = false; |
| 495 | - $actions['remove_portlet']['caption'] .= ' ('.lang('Forced') .')'; |
|
| 495 | + $actions['remove_portlet']['caption'] .= ' ('.lang('Forced').')'; |
|
| 496 | 496 | |
| 497 | 497 | // Non-admins can't edit it |
| 498 | - if($actions['edit_settings'] && !$GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 498 | + if ($actions['edit_settings'] && !$GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 499 | 499 | { |
| 500 | 500 | $actions['edit_settings']['enabled'] = false; |
| 501 | 501 | $actions['edit_settings']['visible'] = false; |
@@ -514,14 +514,14 @@ discard block |
||
| 514 | 514 | public function ajax_set_properties($portlet_id, $attributes, $values, $group = false) |
| 515 | 515 | { |
| 516 | 516 | //error_log(__METHOD__ . "($portlet_id, " .array2string($attributes).','.array2string($values).",$group)"); |
| 517 | - if(!$attributes) |
|
| 517 | + if (!$attributes) |
|
| 518 | 518 | { |
| 519 | 519 | $attributes = array(); |
| 520 | 520 | } |
| 521 | 521 | |
| 522 | - if(!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 522 | + if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 523 | 523 | { |
| 524 | - if($group == 'forced') |
|
| 524 | + if ($group == 'forced') |
|
| 525 | 525 | { |
| 526 | 526 | // Quietly reject |
| 527 | 527 | return; |
@@ -529,7 +529,7 @@ discard block |
||
| 529 | 529 | // Not an admin, can only override. |
| 530 | 530 | $group = false; |
| 531 | 531 | } |
| 532 | - if($group && $GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 532 | + if ($group && $GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 533 | 533 | { |
| 534 | 534 | $prefs = new Api\Preferences(is_numeric($group) ? $group : $GLOBALS['egw_info']['user']['account_id']); |
| 535 | 535 | } |
@@ -543,23 +543,23 @@ discard block |
||
| 543 | 543 | |
| 544 | 544 | $response = Api\Json\Response::get(); |
| 545 | 545 | |
| 546 | - if($values =='~reload~') |
|
| 546 | + if ($values == '~reload~') |
|
| 547 | 547 | { |
| 548 | 548 | $full_exec = true; |
| 549 | 549 | $values = array(); |
| 550 | 550 | } |
| 551 | - if($values == '~remove~') |
|
| 551 | + if ($values == '~remove~') |
|
| 552 | 552 | { |
| 553 | 553 | // Already removed client side, needs to be removed permanently |
| 554 | - $default = $prefs->default_prefs('home',$portlet_id) || $prefs->group['home'][$portlet_id]; |
|
| 554 | + $default = $prefs->default_prefs('home', $portlet_id) || $prefs->group['home'][$portlet_id]; |
|
| 555 | 555 | |
| 556 | - if($default) |
|
| 556 | + if ($default) |
|
| 557 | 557 | { |
| 558 | 558 | // Can't delete forced - not a UI option though |
| 559 | - if(!$GLOBALS['egw']->preferences->forced['home'][$portlet_id]) |
|
| 559 | + if (!$GLOBALS['egw']->preferences->forced['home'][$portlet_id]) |
|
| 560 | 560 | { |
| 561 | 561 | // Set a flag to override default instead of just delete |
| 562 | - $GLOBALS['egw']->preferences->add('home',$portlet_id, 'deleted'); |
|
| 562 | + $GLOBALS['egw']->preferences->add('home', $portlet_id, 'deleted'); |
|
| 563 | 563 | $GLOBALS['egw']->preferences->save_repository(); |
| 564 | 564 | } |
| 565 | 565 | } |
@@ -576,19 +576,19 @@ discard block |
||
| 576 | 576 | // Remove some constant stuff that winds up here |
| 577 | 577 | unset($values['edit_template']); |
| 578 | 578 | unset($values['readonly']); |
| 579 | - unset($values['disabled']);unset($values['no_lang']); |
|
| 579 | + unset($values['disabled']); unset($values['no_lang']); |
|
| 580 | 580 | unset($values['actions']); |
| 581 | 581 | unset($values['statustext']); |
| 582 | - unset($values['type']);unset($values['label']);unset($values['status']); |
|
| 583 | - unset($values['value']);unset($values['align']); |
|
| 582 | + unset($values['type']); unset($values['label']); unset($values['status']); |
|
| 583 | + unset($values['value']); unset($values['align']); |
|
| 584 | 584 | |
| 585 | 585 | // Get portlet settings, and merge new with old |
| 586 | 586 | $context = array_merge((array)$portlets[$portlet_id], $values); |
| 587 | 587 | $context['group'] = $group; |
| 588 | 588 | |
| 589 | 589 | // Handle add IDs |
| 590 | - $classname =& $context['class']; |
|
| 591 | - if(strpos($classname,'add_') == 0 && !class_exists($classname)) |
|
| 590 | + $classname = & $context['class']; |
|
| 591 | + if (strpos($classname, 'add_') == 0 && !class_exists($classname)) |
|
| 592 | 592 | { |
| 593 | 593 | $add = true; |
| 594 | 594 | $classname = substr($classname, 4); |
@@ -597,13 +597,13 @@ discard block |
||
| 597 | 597 | $portlet = $this->get_portlet($portlet_id, $context, $content, $attributes, $full_exec); |
| 598 | 598 | |
| 599 | 599 | $context['class'] = get_class($portlet); |
| 600 | - foreach($portlet->get_properties() as $property) |
|
| 600 | + foreach ($portlet->get_properties() as $property) |
|
| 601 | 601 | { |
| 602 | - if($values[$property['name']]) |
|
| 602 | + if ($values[$property['name']]) |
|
| 603 | 603 | { |
| 604 | 604 | $context[$property['name']] = $values[$property['name']]; |
| 605 | 605 | } |
| 606 | - elseif($portlets[$portlet_id][$property['name']]) |
|
| 606 | + elseif ($portlets[$portlet_id][$property['name']]) |
|
| 607 | 607 | { |
| 608 | 608 | $context[$property['name']] = $portlets[$portlet_id][$property['name']]; |
| 609 | 609 | } |
@@ -613,7 +613,7 @@ discard block |
||
| 613 | 613 | $update = array('attributes' => $attributes); |
| 614 | 614 | |
| 615 | 615 | // New portlet? Flag going straight to edit mode |
| 616 | - if($add) |
|
| 616 | + if ($add) |
|
| 617 | 617 | { |
| 618 | 618 | $update['edit_settings'] = true; |
| 619 | 619 | } |
@@ -625,7 +625,7 @@ discard block |
||
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | // Save updated preferences |
| 628 | - $prefs->save_repository(True,$type); |
|
| 628 | + $prefs->save_repository(True, $type); |
|
| 629 | 629 | } |
| 630 | 630 | |
| 631 | 631 | /** |
@@ -638,10 +638,10 @@ discard block |
||
| 638 | 638 | public static function ajax_set_default($action, $portlet_ids, $group) |
| 639 | 639 | { |
| 640 | 640 | // Admins only |
| 641 | - if(!$GLOBALS['egw_info']['apps']['admin']) return; |
|
| 641 | + if (!$GLOBALS['egw_info']['apps']['admin']) return; |
|
| 642 | 642 | |
| 643 | 643 | // Load the appropriate group |
| 644 | - if($group) |
|
| 644 | + if ($group) |
|
| 645 | 645 | { |
| 646 | 646 | $prefs = new Api\Preferences(is_numeric($group) ? $group : $GLOBALS['egw_info']['user']['account_id']); |
| 647 | 647 | } |
@@ -653,30 +653,30 @@ discard block |
||
| 653 | 653 | |
| 654 | 654 | $type = is_numeric($group) ? "user" : $group; |
| 655 | 655 | |
| 656 | - if($action == 'add') |
|
| 656 | + if ($action == 'add') |
|
| 657 | 657 | { |
| 658 | - foreach($portlet_ids as $id) |
|
| 658 | + foreach ($portlet_ids as $id) |
|
| 659 | 659 | { |
| 660 | 660 | Api\Json\Response::get()->call('egw.message', lang("Set default")); |
| 661 | 661 | // Current user is setting the default, copy their settings |
| 662 | 662 | $settings = $GLOBALS['egw_info']['user']['preferences']['home'][$id]; |
| 663 | 663 | $settings['group'] = $group; |
| 664 | - $prefs->add('home',$id,$settings,$type); |
|
| 664 | + $prefs->add('home', $id, $settings, $type); |
|
| 665 | 665 | |
| 666 | 666 | // Remove user's copy |
| 667 | - $GLOBALS['egw']->preferences->delete('home',$id); |
|
| 667 | + $GLOBALS['egw']->preferences->delete('home', $id); |
|
| 668 | 668 | $GLOBALS['egw']->preferences->save_repository(true); |
| 669 | 669 | } |
| 670 | 670 | } |
| 671 | 671 | else if ($action == "delete") |
| 672 | 672 | { |
| 673 | - foreach($portlet_ids as $id) |
|
| 673 | + foreach ($portlet_ids as $id) |
|
| 674 | 674 | { |
| 675 | 675 | Api\Json\Response::get()->call('egw.message', lang("Removed default")); |
| 676 | - $prefs->delete('home',$id, $type); |
|
| 676 | + $prefs->delete('home', $id, $type); |
|
| 677 | 677 | } |
| 678 | 678 | } |
| 679 | - $prefs->save_repository(false,$type); |
|
| 679 | + $prefs->save_repository(false, $type); |
|
| 680 | 680 | |
| 681 | 681 | // Update Api\Preferences client side for consistency |
| 682 | 682 | $prefs = $GLOBALS['egw']->preferences; |
@@ -729,7 +729,7 @@ discard block |
||
| 729 | 729 | 'state' => array( |
| 730 | 730 | 'cat_id' => '0', |
| 731 | 731 | 'filter' => 'default', |
| 732 | - 'owner' => 0, // current user |
|
| 732 | + 'owner' => 0, // current user |
|
| 733 | 733 | 'sortby' => 'user', |
| 734 | 734 | 'planner_days' => '0', |
| 735 | 735 | 'view' => 'week', |
@@ -778,9 +778,9 @@ discard block |
||
| 778 | 778 | { |
| 779 | 779 | unset($app_prefs['home']['portlet_setup142n']); |
| 780 | 780 | } |
| 781 | - foreach($app_prefs as $app => $prefs) |
|
| 781 | + foreach ($app_prefs as $app => $prefs) |
|
| 782 | 782 | { |
| 783 | - foreach($prefs as $name => $value) |
|
| 783 | + foreach ($prefs as $name => $value) |
|
| 784 | 784 | { |
| 785 | 785 | Api\Preferences::delete_preference($app, $name, 'default'); |
| 786 | 786 | $preferences->add($app, $name, $value, 'default'); |
@@ -801,10 +801,10 @@ discard block |
||
| 801 | 801 | */ |
| 802 | 802 | public static function setup_default_home() |
| 803 | 803 | { |
| 804 | - switch($GLOBALS['egw_info']['server'][self::HOME_VERSION]) |
|
| 804 | + switch ($GLOBALS['egw_info']['server'][self::HOME_VERSION]) |
|
| 805 | 805 | { |
| 806 | 806 | case self::CURRENT_HOME_VERSION: |
| 807 | - return; // already up to date --> nothing to do |
|
| 807 | + return; // already up to date --> nothing to do |
|
| 808 | 808 | |
| 809 | 809 | default: |
| 810 | 810 | call_user_func(array(__CLASS__, 'setup_default_home_'.str_replace('.', '_', self::CURRENT_HOME_VERSION))); |
@@ -118,8 +118,7 @@ discard block |
||
| 118 | 118 | /** |
| 119 | 119 | * imports entries according to given definition object. |
| 120 | 120 | * @param resource $_stream |
| 121 | - * @param string $_charset |
|
| 122 | - * @param definition $_definition |
|
| 121 | + * @param importexport_definition $_definition |
|
| 123 | 122 | */ |
| 124 | 123 | public function import( $_stream, importexport_definition $_definition ) { |
| 125 | 124 | $import_csv = new importexport_import_csv( $_stream, array( |
@@ -222,7 +221,7 @@ discard block |
||
| 222 | 221 | * |
| 223 | 222 | * Updates the count of actions taken |
| 224 | 223 | * |
| 225 | - * @return boolean success |
|
| 224 | + * @return null|boolean success |
|
| 226 | 225 | */ |
| 227 | 226 | protected function import_record(importexport_iface_egw_record &$record, &$import_csv) |
| 228 | 227 | { |
@@ -274,7 +273,7 @@ discard block |
||
| 274 | 273 | * @param condition array = array('string' => field name) |
| 275 | 274 | * @param matches - On return, will be filled with matching records |
| 276 | 275 | * |
| 277 | - * @return boolean |
|
| 276 | + * @return boolean|null |
|
| 278 | 277 | */ |
| 279 | 278 | protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$matches = array()) |
| 280 | 279 | { |
@@ -451,7 +450,7 @@ discard block |
||
| 451 | 450 | /** |
| 452 | 451 | * Allows an extending class to alter a row for preview |
| 453 | 452 | * |
| 454 | - * @param egw_record $row_entry |
|
| 453 | + * @param importexport_iface_egw_record $row_entry |
|
| 455 | 454 | */ |
| 456 | 455 | protected function row_preview(importexport_iface_egw_record &$row_entry) |
| 457 | 456 | { |
@@ -523,7 +522,7 @@ discard block |
||
| 523 | 522 | * Get the primary key for an entry based on a custom field |
| 524 | 523 | * Returns key, so regular linking can take over |
| 525 | 524 | * |
| 526 | - * @param int $record_number Row number, used for errors |
|
| 525 | + * @param int $record_num Row number, used for errors |
|
| 527 | 526 | * @param string $app Target application name |
| 528 | 527 | * @param string $value CSV value in the form of custom_field_name:value |
| 529 | 528 | */ |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | $record_class = isset(static::$record_class) ? static::$record_class : "{$app}_egw_record"; |
| 164 | 164 | |
| 165 | 165 | // Needed for categories to work right |
| 166 | - $GLOBALS['egw_info']['flags']['currentapp'] = $app; |
|
| 166 | + $GLOBALS['egw_info']['flags']['currentapp'] = $app; |
|
| 167 | 167 | |
| 168 | 168 | $this->init($_definition); |
| 169 | 169 | |
@@ -215,15 +215,15 @@ discard block |
||
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | /** |
| 218 | - *Import a single record |
|
| 219 | - * |
|
| 220 | - * You don't need to worry about mappings or translations, they've been done already. |
|
| 221 | - * You do need to handle the conditions and the actions taken. |
|
| 222 | - * |
|
| 223 | - * Updates the count of actions taken |
|
| 224 | - * |
|
| 225 | - * @return boolean success |
|
| 226 | - */ |
|
| 218 | + *Import a single record |
|
| 219 | + * |
|
| 220 | + * You don't need to worry about mappings or translations, they've been done already. |
|
| 221 | + * You do need to handle the conditions and the actions taken. |
|
| 222 | + * |
|
| 223 | + * Updates the count of actions taken |
|
| 224 | + * |
|
| 225 | + * @return boolean success |
|
| 226 | + */ |
|
| 227 | 227 | protected function import_record(importexport_iface_egw_record &$record, &$import_csv) |
| 228 | 228 | { |
| 229 | 229 | if ( $this->definition->plugin_options['conditions'] ) { |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | * @param stream $stream |
| 404 | 404 | * @param importexport_definition $definition |
| 405 | 405 | * @return String HTML for preview |
| 406 | - */ |
|
| 406 | + */ |
|
| 407 | 407 | public function preview( $stream, importexport_definition $definition ) |
| 408 | 408 | { |
| 409 | 409 | $this->import($stream, $definition); |
@@ -639,37 +639,37 @@ discard block |
||
| 639 | 639 | } |
| 640 | 640 | |
| 641 | 641 | /** |
| 642 | - * Returns warnings that were encountered during importing |
|
| 643 | - * Maximum of one warning message per record, but you can append if you need to |
|
| 644 | - * |
|
| 645 | - * @return Array ( |
|
| 646 | - * record_# => warning message |
|
| 647 | - * ) |
|
| 648 | - */ |
|
| 642 | + * Returns warnings that were encountered during importing |
|
| 643 | + * Maximum of one warning message per record, but you can append if you need to |
|
| 644 | + * |
|
| 645 | + * @return Array ( |
|
| 646 | + * record_# => warning message |
|
| 647 | + * ) |
|
| 648 | + */ |
|
| 649 | 649 | public function get_warnings() { |
| 650 | 650 | return $this->warnings; |
| 651 | 651 | } |
| 652 | 652 | |
| 653 | 653 | /** |
| 654 | - * Returns errors that were encountered during importing |
|
| 655 | - * Maximum of one error message per record, but you can append if you need to |
|
| 656 | - * |
|
| 657 | - * @return Array ( |
|
| 658 | - * record_# => error message |
|
| 659 | - * ) |
|
| 660 | - */ |
|
| 654 | + * Returns errors that were encountered during importing |
|
| 655 | + * Maximum of one error message per record, but you can append if you need to |
|
| 656 | + * |
|
| 657 | + * @return Array ( |
|
| 658 | + * record_# => error message |
|
| 659 | + * ) |
|
| 660 | + */ |
|
| 661 | 661 | public function get_errors() { |
| 662 | 662 | return $this->errors; |
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | /** |
| 666 | - * Returns a list of actions taken, and the number of records for that action. |
|
| 667 | - * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
| 668 | - * |
|
| 669 | - * @return Array ( |
|
| 670 | - * action => record count |
|
| 671 | - * ) |
|
| 672 | - */ |
|
| 666 | + * Returns a list of actions taken, and the number of records for that action. |
|
| 667 | + * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin. |
|
| 668 | + * |
|
| 669 | + * @return Array ( |
|
| 670 | + * action => record count |
|
| 671 | + * ) |
|
| 672 | + */ |
|
| 673 | 673 | public function get_results() { |
| 674 | 674 | return $this->results; |
| 675 | 675 | } |
@@ -18,7 +18,8 @@ discard block |
||
| 18 | 18 | * should get you started on building a CSV plugin for an application fairly quickly. |
| 19 | 19 | * |
| 20 | 20 | */ |
| 21 | -abstract class importexport_basic_import_csv implements importexport_iface_import_plugin { |
|
| 21 | +abstract class importexport_basic_import_csv implements importexport_iface_import_plugin |
|
| 22 | +{ |
|
| 22 | 23 | |
| 23 | 24 | protected static $plugin_options = array( |
| 24 | 25 | 'fieldsep', // char |
@@ -121,7 +122,8 @@ discard block |
||
| 121 | 122 | * @param string $_charset |
| 122 | 123 | * @param definition $_definition |
| 123 | 124 | */ |
| 124 | - public function import( $_stream, importexport_definition $_definition ) { |
|
| 125 | + public function import( $_stream, importexport_definition $_definition ) |
|
| 126 | + { |
|
| 125 | 127 | $import_csv = new importexport_import_csv( $_stream, array( |
| 126 | 128 | 'fieldsep' => $_definition->plugin_options['fieldsep'], |
| 127 | 129 | 'charset' => $_definition->plugin_options['charset'], |
@@ -143,9 +145,12 @@ discard block |
||
| 143 | 145 | $import_csv->conversion = $_definition->plugin_options['field_conversion']; |
| 144 | 146 | |
| 145 | 147 | //check if file has a header lines |
| 146 | - if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) { |
|
| 148 | + if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) |
|
| 149 | + { |
|
| 147 | 150 | $import_csv->skip_records($_definition->plugin_options['num_header_lines']); |
| 148 | - } elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) { |
|
| 151 | + } |
|
| 152 | + elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) |
|
| 153 | + { |
|
| 149 | 154 | // First method is preferred |
| 150 | 155 | $import_csv->skip_records(1); |
| 151 | 156 | } |
@@ -167,15 +172,22 @@ discard block |
||
| 167 | 172 | |
| 168 | 173 | $this->init($_definition); |
| 169 | 174 | |
| 170 | - while ( $record = $import_csv->get_record() ) { |
|
| 175 | + while ( $record = $import_csv->get_record() ) |
|
| 176 | + { |
|
| 171 | 177 | $success = false; |
| 172 | 178 | |
| 173 | 179 | // don't import empty records |
| 174 | - if( count( array_unique( $record ) ) < 2 ) continue; |
|
| 180 | + if( count( array_unique( $record ) ) < 2 ) |
|
| 181 | + { |
|
| 182 | + continue; |
|
| 183 | + } |
|
| 175 | 184 | |
| 176 | 185 | |
| 177 | 186 | $warning = importexport_import_csv::convert($record, $record_class::$types, $app, $this->lookups, $_definition->plugin_options['convert']); |
| 178 | - if($warning) $this->warnings[$import_csv->get_current_position()] = $warning; |
|
| 187 | + if($warning) |
|
| 188 | + { |
|
| 189 | + $this->warnings[$import_csv->get_current_position()] = $warning; |
|
| 190 | + } |
|
| 179 | 191 | |
| 180 | 192 | $egw_record = new $record_class(); |
| 181 | 193 | $egw_record->set_record($record); |
@@ -185,7 +197,10 @@ discard block |
||
| 185 | 197 | { |
| 186 | 198 | $this->do_special_fields($egw_record, $import_csv); |
| 187 | 199 | } |
| 188 | - if($success) $count++; |
|
| 200 | + if($success) |
|
| 201 | + { |
|
| 202 | + $count++; |
|
| 203 | + } |
|
| 189 | 204 | |
| 190 | 205 | // Add some more time |
| 191 | 206 | if($success && $import_csv->get_current_position() > 0 && $import_csv->get_current_position() % 100 == 0) |
@@ -226,10 +241,13 @@ discard block |
||
| 226 | 241 | */ |
| 227 | 242 | protected function import_record(importexport_iface_egw_record &$record, &$import_csv) |
| 228 | 243 | { |
| 229 | - if ( $this->definition->plugin_options['conditions'] ) { |
|
| 230 | - foreach ( $this->definition->plugin_options['conditions'] as $condition ) { |
|
| 244 | + if ( $this->definition->plugin_options['conditions'] ) |
|
| 245 | + { |
|
| 246 | + foreach ( $this->definition->plugin_options['conditions'] as $condition ) |
|
| 247 | + { |
|
| 231 | 248 | $result = false; |
| 232 | - switch ( $condition['type'] ) { |
|
| 249 | + switch ( $condition['type'] ) |
|
| 250 | + { |
|
| 233 | 251 | // exists |
| 234 | 252 | case 'exists' : |
| 235 | 253 | // Check for that record |
@@ -257,9 +275,14 @@ discard block |
||
| 257 | 275 | $action = $condition['false']; |
| 258 | 276 | $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
| 259 | 277 | } |
| 260 | - if ($action['stop']) break; |
|
| 278 | + if ($action['stop']) |
|
| 279 | + { |
|
| 280 | + break; |
|
| 281 | + } |
|
| 261 | 282 | } |
| 262 | - } else { |
|
| 283 | + } |
|
| 284 | + else |
|
| 285 | + { |
|
| 263 | 286 | // unconditional insert |
| 264 | 287 | $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
| 265 | 288 | } |
@@ -343,9 +366,14 @@ discard block |
||
| 343 | 366 | return; |
| 344 | 367 | } |
| 345 | 368 | |
| 346 | - foreach(self::$special_fields as $field => $desc) { |
|
| 347 | - if(!$record->$field) continue; |
|
| 348 | - if(strpos($field, 'link') === 0) { |
|
| 369 | + foreach(self::$special_fields as $field => $desc) |
|
| 370 | + { |
|
| 371 | + if(!$record->$field) |
|
| 372 | + { |
|
| 373 | + continue; |
|
| 374 | + } |
|
| 375 | + if(strpos($field, 'link') === 0) |
|
| 376 | + { |
|
| 349 | 377 | list($app, $app_id) = explode(':', $record->$field,2); |
| 350 | 378 | |
| 351 | 379 | list($link, $type) = explode('_',$field); |
@@ -364,7 +392,9 @@ discard block |
||
| 364 | 392 | shift($result); |
| 365 | 393 | } while($result && !$app_id); |
| 366 | 394 | } |
| 367 | - } else if (in_array($field, array_keys($GLOBALS['egw_info']['apps']))) { |
|
| 395 | + } |
|
| 396 | + else if (in_array($field, array_keys($GLOBALS['egw_info']['apps']))) |
|
| 397 | + { |
|
| 368 | 398 | $app = $field; |
| 369 | 399 | $app_id = $record->$field; |
| 370 | 400 | |
@@ -425,11 +455,16 @@ discard block |
||
| 425 | 455 | $fields = $wizard->get_import_fields(); |
| 426 | 456 | foreach($labels as $field => &$label) |
| 427 | 457 | { |
| 428 | - if($fields[$field]) $label = $fields[$field]; |
|
| 458 | + if($fields[$field]) |
|
| 459 | + { |
|
| 460 | + $label = $fields[$field]; |
|
| 461 | + } |
|
| 429 | 462 | } |
| 430 | - } catch (Exception $e) { |
|
| 463 | + } |
|
| 464 | + catch (Exception $e) { |
|
| 431 | 465 | Api\Translation::add_app($definition->application); |
| 432 | - foreach($labels as $field => &$label) { |
|
| 466 | + foreach($labels as $field => &$label) |
|
| 467 | + { |
|
| 433 | 468 | $label = lang($label); |
| 434 | 469 | } |
| 435 | 470 | } |
@@ -468,7 +503,8 @@ discard block |
||
| 468 | 503 | * @param string $org_name |
| 469 | 504 | * @return int|boolean Contact ID of first match, or false if none found |
| 470 | 505 | */ |
| 471 | - public static function addr_id( $n_family,$n_given=null,$org_name=null, &$record=null) { |
|
| 506 | + public static function addr_id( $n_family,$n_given=null,$org_name=null, &$record=null) |
|
| 507 | + { |
|
| 472 | 508 | |
| 473 | 509 | // find in Addressbook, at least n_family AND (n_given OR org_name) have to match |
| 474 | 510 | static $contacts; |
@@ -478,28 +514,40 @@ discard block |
||
| 478 | 514 | list($n_family, $n_given, $org_name) = explode(',', $n_family); |
| 479 | 515 | } |
| 480 | 516 | $n_family = trim($n_family); |
| 481 | - if(!is_null($n_given)) $n_given = trim($n_given); |
|
| 517 | + if(!is_null($n_given)) |
|
| 518 | + { |
|
| 519 | + $n_given = trim($n_given); |
|
| 520 | + } |
|
| 482 | 521 | if (!is_object($contacts)) |
| 483 | 522 | { |
| 484 | 523 | $contacts = new Api\Contacts(); |
| 485 | 524 | } |
| 486 | - if (!is_null($org_name)) // org_name given? |
|
| 525 | + if (!is_null($org_name)) |
|
| 526 | + { |
|
| 527 | + // org_name given? |
|
| 487 | 528 | { |
| 488 | 529 | $org_name = trim($org_name); |
| 530 | + } |
|
| 489 | 531 | $addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name" ); |
| 490 | 532 | if (!count($addrs)) |
| 491 | 533 | { |
| 492 | 534 | $addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,org_name=$org_name",'','n_family,org_name'); |
| 493 | 535 | } |
| 494 | 536 | } |
| 495 | - if (!is_null($n_given) && (is_null($org_name) || !count($addrs))) // first name given and no result so far |
|
| 537 | + if (!is_null($n_given) && (is_null($org_name) || !count($addrs))) |
|
| 538 | + { |
|
| 539 | + // first name given and no result so far |
|
| 496 | 540 | { |
| 497 | 541 | $addrs = $contacts->search(array('n_family' => $n_family, 'n_given' => $n_given)); |
| 498 | 542 | } |
| 499 | - if (is_null($n_given) && is_null($org_name)) // just one name given, check against fn (= full name) |
|
| 543 | + } |
|
| 544 | + if (is_null($n_given) && is_null($org_name)) |
|
| 545 | + { |
|
| 546 | + // just one name given, check against fn (= full name) |
|
| 500 | 547 | { |
| 501 | 548 | $addrs = $contacts->read( 0,0,array('id'),'',"n_fn=$n_family",'','n_fn' ); |
| 502 | 549 | } |
| 550 | + } |
|
| 503 | 551 | if (count($addrs)) |
| 504 | 552 | { |
| 505 | 553 | if(!$record || !$record->get_identifier()) |
@@ -551,13 +599,17 @@ discard block |
||
| 551 | 599 | } |
| 552 | 600 | |
| 553 | 601 | // Couldn't find field, give an error - something's wrong |
| 554 | - if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)]) { |
|
| 602 | + if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)]) |
|
| 603 | + { |
|
| 555 | 604 | $this->errors[$record_num] .= lang('No custom field "%1" for %2.', |
| 556 | 605 | $custom_field, lang($app)); |
| 557 | 606 | return false; |
| 558 | 607 | } |
| 559 | - if($custom_field[0] != '#') $custom_field = '#' . $custom_field; |
|
| 560 | -error_log("Searching for $custom_field = $value"); |
|
| 608 | + if($custom_field[0] != '#') |
|
| 609 | + { |
|
| 610 | + $custom_field = '#' . $custom_field; |
|
| 611 | + } |
|
| 612 | + error_log("Searching for $custom_field = $value"); |
|
| 561 | 613 | // Search |
| 562 | 614 | if(Link::get_registry($app, 'query')) |
| 563 | 615 | { |
@@ -591,7 +643,8 @@ discard block |
||
| 591 | 643 | * |
| 592 | 644 | * @return string name |
| 593 | 645 | */ |
| 594 | - public static function get_name() { |
|
| 646 | + public static function get_name() |
|
| 647 | + { |
|
| 595 | 648 | return lang('Basic CSV import'); |
| 596 | 649 | } |
| 597 | 650 | |
@@ -600,7 +653,8 @@ discard block |
||
| 600 | 653 | * |
| 601 | 654 | * @return string descriprion |
| 602 | 655 | */ |
| 603 | - public static function get_description() { |
|
| 656 | + public static function get_description() |
|
| 657 | + { |
|
| 604 | 658 | return lang("Imports information from a CSV file. This is only a base class, and doesn't do anything on its own."); |
| 605 | 659 | } |
| 606 | 660 | |
@@ -609,7 +663,8 @@ discard block |
||
| 609 | 663 | * |
| 610 | 664 | * @return string suffix (comma seperated) |
| 611 | 665 | */ |
| 612 | - public static function get_filesuffix() { |
|
| 666 | + public static function get_filesuffix() |
|
| 667 | + { |
|
| 613 | 668 | return 'csv'; |
| 614 | 669 | } |
| 615 | 670 | |
@@ -625,7 +680,8 @@ discard block |
||
| 625 | 680 | * preserv => array, |
| 626 | 681 | * ) |
| 627 | 682 | */ |
| 628 | - public function get_options_etpl() { |
|
| 683 | + public function get_options_etpl() |
|
| 684 | + { |
|
| 629 | 685 | // lets do it! |
| 630 | 686 | } |
| 631 | 687 | |
@@ -634,7 +690,8 @@ discard block |
||
| 634 | 690 | * |
| 635 | 691 | * @return string etemplate name |
| 636 | 692 | */ |
| 637 | - public function get_selectors_etpl() { |
|
| 693 | + public function get_selectors_etpl() |
|
| 694 | + { |
|
| 638 | 695 | // lets do it! |
| 639 | 696 | } |
| 640 | 697 | |
@@ -646,7 +703,8 @@ discard block |
||
| 646 | 703 | * record_# => warning message |
| 647 | 704 | * ) |
| 648 | 705 | */ |
| 649 | - public function get_warnings() { |
|
| 706 | + public function get_warnings() |
|
| 707 | + { |
|
| 650 | 708 | return $this->warnings; |
| 651 | 709 | } |
| 652 | 710 | |
@@ -658,7 +716,8 @@ discard block |
||
| 658 | 716 | * record_# => error message |
| 659 | 717 | * ) |
| 660 | 718 | */ |
| 661 | - public function get_errors() { |
|
| 719 | + public function get_errors() |
|
| 720 | + { |
|
| 662 | 721 | return $this->errors; |
| 663 | 722 | } |
| 664 | 723 | |
@@ -670,7 +729,8 @@ discard block |
||
| 670 | 729 | * action => record count |
| 671 | 730 | * ) |
| 672 | 731 | */ |
| 673 | - public function get_results() { |
|
| 732 | + public function get_results() |
|
| 733 | + { |
|
| 674 | 734 | return $this->results; |
| 675 | 735 | } |
| 676 | 736 | } // end of iface_export_plugin |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | * |
| 277 | 277 | * @return boolean |
| 278 | 278 | */ |
| 279 | - protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$matches = array()) |
|
| 279 | + protected function exists(importexport_iface_egw_record &$record, array &$condition, &$matches = array()) |
|
| 280 | 280 | { |
| 281 | 281 | } |
| 282 | 282 | |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | * |
| 289 | 289 | * @return boolean |
| 290 | 290 | */ |
| 291 | - protected function equal(importexport_iface_egw_record &$record, Array &$condition) |
|
| 291 | + protected function equal(importexport_iface_egw_record &$record, array &$condition) |
|
| 292 | 292 | { |
| 293 | 293 | $field = $condition['string']; |
| 294 | 294 | return $record->$field == $condition['op_2']; |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | * |
| 304 | 304 | * @return boolean |
| 305 | 305 | */ |
| 306 | - protected function less_than(importexport_iface_egw_record &$record, Array &$condition) |
|
| 306 | + protected function less_than(importexport_iface_egw_record &$record, array &$condition) |
|
| 307 | 307 | { |
| 308 | 308 | $field = $condition['string']; |
| 309 | 309 | return $record->$field < $condition['op_2']; |
@@ -18,19 +18,19 @@ discard block |
||
| 18 | 18 | * should get you started on building a CSV plugin for an application fairly quickly. |
| 19 | 19 | * |
| 20 | 20 | */ |
| 21 | -abstract class importexport_basic_import_csv implements importexport_iface_import_plugin { |
|
| 21 | +abstract class importexport_basic_import_csv implements importexport_iface_import_plugin { |
|
| 22 | 22 | |
| 23 | 23 | protected static $plugin_options = array( |
| 24 | - 'fieldsep', // char |
|
| 25 | - 'charset', // string |
|
| 26 | - 'record_owner', // int |
|
| 27 | - 'update_cats', // string {override|add} overides record |
|
| 24 | + 'fieldsep', // char |
|
| 25 | + 'charset', // string |
|
| 26 | + 'record_owner', // int |
|
| 27 | + 'update_cats', // string {override|add} overides record |
|
| 28 | 28 | // with cat(s) from csv OR add the cat from |
| 29 | 29 | // csv file to exeisting cat(s) of record |
| 30 | 30 | 'num_header_lines', // int number of header lines |
| 31 | 31 | 'field_conversion', // array( $csv_col_num => conversion) |
| 32 | - 'field_mapping', // array( $csv_col_num => adb_filed) |
|
| 33 | - 'conditions', /* => array containing condition arrays: |
|
| 32 | + 'field_mapping', // array( $csv_col_num => adb_filed) |
|
| 33 | + 'conditions', /* => array containing condition arrays: |
|
| 34 | 34 | 'type' => exists, // exists |
| 35 | 35 | 'string' => '#kundennummer', |
| 36 | 36 | 'true' => array( |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * Actions wich could be done to data entries |
| 49 | 49 | * If your plugin supports different actions, be sure to modify this array |
| 50 | 50 | */ |
| 51 | - protected static $actions = array( 'none', 'update', 'insert', 'delete', ); |
|
| 51 | + protected static $actions = array('none', 'update', 'insert', 'delete',); |
|
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * Conditions for actions |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * |
| 57 | 57 | * @var array |
| 58 | 58 | */ |
| 59 | - protected static $conditions = array( 'exists', 'equal', 'less_than'); |
|
| 59 | + protected static $conditions = array('exists', 'equal', 'less_than'); |
|
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | 62 | * This is the definition that will be used to deal with the CSV file |
@@ -121,8 +121,8 @@ discard block |
||
| 121 | 121 | * @param string $_charset |
| 122 | 122 | * @param definition $_definition |
| 123 | 123 | */ |
| 124 | - public function import( $_stream, importexport_definition $_definition ) { |
|
| 125 | - $import_csv = new importexport_import_csv( $_stream, array( |
|
| 124 | + public function import($_stream, importexport_definition $_definition) { |
|
| 125 | + $import_csv = new importexport_import_csv($_stream, array( |
|
| 126 | 126 | 'fieldsep' => $_definition->plugin_options['fieldsep'], |
| 127 | 127 | 'charset' => $_definition->plugin_options['charset'], |
| 128 | 128 | )); |
@@ -130,11 +130,11 @@ discard block |
||
| 130 | 130 | $this->definition = $_definition; |
| 131 | 131 | |
| 132 | 132 | // user, is admin ? |
| 133 | - $this->is_admin = isset( $GLOBALS['egw_info']['user']['apps']['admin'] ) && $GLOBALS['egw_info']['user']['apps']['admin']; |
|
| 133 | + $this->is_admin = isset($GLOBALS['egw_info']['user']['apps']['admin']) && $GLOBALS['egw_info']['user']['apps']['admin']; |
|
| 134 | 134 | $this->user = $GLOBALS['egw_info']['user']['account_id']; |
| 135 | 135 | |
| 136 | 136 | // dry run? |
| 137 | - $this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] : false; |
|
| 137 | + $this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false; |
|
| 138 | 138 | |
| 139 | 139 | // set FieldMapping. |
| 140 | 140 | $import_csv->mapping = $_definition->plugin_options['field_mapping']; |
@@ -143,9 +143,9 @@ discard block |
||
| 143 | 143 | $import_csv->conversion = $_definition->plugin_options['field_conversion']; |
| 144 | 144 | |
| 145 | 145 | //check if file has a header lines |
| 146 | - if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) { |
|
| 146 | + if (isset($_definition->plugin_options['num_header_lines']) && $_definition->plugin_options['num_header_lines'] > 0) { |
|
| 147 | 147 | $import_csv->skip_records($_definition->plugin_options['num_header_lines']); |
| 148 | - } elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) { |
|
| 148 | + } elseif (isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) { |
|
| 149 | 149 | // First method is preferred |
| 150 | 150 | $import_csv->skip_records(1); |
| 151 | 151 | } |
@@ -167,38 +167,38 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | $this->init($_definition); |
| 169 | 169 | |
| 170 | - while ( $record = $import_csv->get_record() ) { |
|
| 170 | + while ($record = $import_csv->get_record()) { |
|
| 171 | 171 | $success = false; |
| 172 | 172 | |
| 173 | 173 | // don't import empty records |
| 174 | - if( count( array_unique( $record ) ) < 2 ) continue; |
|
| 174 | + if (count(array_unique($record)) < 2) continue; |
|
| 175 | 175 | |
| 176 | 176 | |
| 177 | 177 | $warning = importexport_import_csv::convert($record, $record_class::$types, $app, $this->lookups, $_definition->plugin_options['convert']); |
| 178 | - if($warning) $this->warnings[$import_csv->get_current_position()] = $warning; |
|
| 178 | + if ($warning) $this->warnings[$import_csv->get_current_position()] = $warning; |
|
| 179 | 179 | |
| 180 | 180 | $egw_record = new $record_class(); |
| 181 | 181 | $egw_record->set_record($record); |
| 182 | 182 | $success = $this->import_record($egw_record, $import_csv); |
| 183 | 183 | |
| 184 | - if($success) |
|
| 184 | + if ($success) |
|
| 185 | 185 | { |
| 186 | 186 | $this->do_special_fields($egw_record, $import_csv); |
| 187 | 187 | } |
| 188 | - if($success) $count++; |
|
| 188 | + if ($success) $count++; |
|
| 189 | 189 | |
| 190 | 190 | // Add some more time |
| 191 | - if($success && $import_csv->get_current_position() > 0 && $import_csv->get_current_position() % 100 == 0) |
|
| 191 | + if ($success && $import_csv->get_current_position() > 0 && $import_csv->get_current_position() % 100 == 0) |
|
| 192 | 192 | { |
| 193 | 193 | set_time_limit(10); |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | // Keep a few records for preview, but process the whole file |
| 197 | - if($this->dry_run && $import_csv->get_current_position() < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']) |
|
| 197 | + if ($this->dry_run && $import_csv->get_current_position() < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']) |
|
| 198 | 198 | { |
| 199 | 199 | $this->preview_records[] = $egw_record; |
| 200 | 200 | } |
| 201 | - if(count($this->warnings) > self::MAX_MESSAGES || count($this->errors) > self::MAX_MESSAGES) |
|
| 201 | + if (count($this->warnings) > self::MAX_MESSAGES || count($this->errors) > self::MAX_MESSAGES) |
|
| 202 | 202 | { |
| 203 | 203 | $this->errors[] = 'Too many errors, aborted'; |
| 204 | 204 | break; |
@@ -226,10 +226,10 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | protected function import_record(importexport_iface_egw_record &$record, &$import_csv) |
| 228 | 228 | { |
| 229 | - if ( $this->definition->plugin_options['conditions'] ) { |
|
| 230 | - foreach ( $this->definition->plugin_options['conditions'] as $condition ) { |
|
| 229 | + if ($this->definition->plugin_options['conditions']) { |
|
| 230 | + foreach ($this->definition->plugin_options['conditions'] as $condition) { |
|
| 231 | 231 | $result = false; |
| 232 | - switch ( $condition['type'] ) { |
|
| 232 | + switch ($condition['type']) { |
|
| 233 | 233 | // exists |
| 234 | 234 | case 'exists' : |
| 235 | 235 | // Check for that record |
@@ -245,23 +245,23 @@ discard block |
||
| 245 | 245 | die('condition / action not supported!!!'); |
| 246 | 246 | break; |
| 247 | 247 | } |
| 248 | - if($result) |
|
| 248 | + if ($result) |
|
| 249 | 249 | { |
| 250 | 250 | // Apply true action to any matching records found |
| 251 | 251 | $action = $condition['true']; |
| 252 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
| 252 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
| 253 | 253 | } |
| 254 | 254 | else |
| 255 | 255 | { |
| 256 | 256 | // Apply false action if no matching records found |
| 257 | 257 | $action = $condition['false']; |
| 258 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
| 258 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
| 259 | 259 | } |
| 260 | 260 | if ($action['stop']) break; |
| 261 | 261 | } |
| 262 | 262 | } else { |
| 263 | 263 | // unconditional insert |
| 264 | - $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
|
| 264 | + $success = $this->action('insert', $record, $import_csv->get_current_position()); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | return $success; |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | * @param int $record_num Which record number is being dealt with. Used for error messages. |
| 323 | 323 | * @return bool success or not |
| 324 | 324 | */ |
| 325 | - protected abstract function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ); |
|
| 325 | + protected abstract function action($_action, importexport_iface_egw_record &$record, $record_num = 0); |
|
| 326 | 326 | |
| 327 | 327 | /** |
| 328 | 328 | * Handle special fields |
@@ -337,46 +337,46 @@ discard block |
||
| 337 | 337 | $id = $record->get_identifier(); |
| 338 | 338 | |
| 339 | 339 | // Warn if there's no ID unless it's a dry_run because there probably won't be an ID then |
| 340 | - if(!$this->dry_run && !$id) |
|
| 340 | + if (!$this->dry_run && !$id) |
|
| 341 | 341 | { |
| 342 | 342 | $this->warnings[$import_csv->get_current_position()] .= "Unable to link, no identifier for record"; |
| 343 | 343 | return; |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | - foreach(self::$special_fields as $field => $desc) { |
|
| 347 | - if(!$record->$field) continue; |
|
| 348 | - if(strpos($field, 'link') === 0) { |
|
| 349 | - list($app, $app_id) = explode(':', $record->$field,2); |
|
| 346 | + foreach (self::$special_fields as $field => $desc) { |
|
| 347 | + if (!$record->$field) continue; |
|
| 348 | + if (strpos($field, 'link') === 0) { |
|
| 349 | + list($app, $app_id) = explode(':', $record->$field, 2); |
|
| 350 | 350 | |
| 351 | - list($link, $type) = explode('_',$field); |
|
| 351 | + list($link, $type) = explode('_', $field); |
|
| 352 | 352 | |
| 353 | 353 | // Searching, take first result |
| 354 | - if($type == 'custom') |
|
| 354 | + if ($type == 'custom') |
|
| 355 | 355 | { |
| 356 | 356 | $app_id = $this->link_by_cf($record, $app, $app_id, $import_csv->get_current_position()); |
| 357 | 357 | } |
| 358 | - else if($type == 'search') |
|
| 358 | + else if ($type == 'search') |
|
| 359 | 359 | { |
| 360 | 360 | $result = Link::query($app, $app_id); |
| 361 | 361 | do |
| 362 | 362 | { |
| 363 | 363 | $app_id = key($result); |
| 364 | 364 | shift($result); |
| 365 | - } while($result && !$app_id); |
|
| 365 | + } while ($result && !$app_id); |
|
| 366 | 366 | } |
| 367 | 367 | } else if (in_array($field, array_keys($GLOBALS['egw_info']['apps']))) { |
| 368 | 368 | $app = $field; |
| 369 | 369 | $app_id = $record->$field; |
| 370 | 370 | |
| 371 | 371 | // Searching, take first result |
| 372 | - if(!is_numeric($app_id)) |
|
| 372 | + if (!is_numeric($app_id)) |
|
| 373 | 373 | { |
| 374 | 374 | $result = Link::query($app, $app_id); |
| 375 | 375 | do |
| 376 | 376 | { |
| 377 | 377 | $app_id = key($result); |
| 378 | 378 | shift($result); |
| 379 | - } while($result && !$app_id); |
|
| 379 | + } while ($result && !$app_id); |
|
| 380 | 380 | } |
| 381 | 381 | } |
| 382 | 382 | else if ($field == 'contact') |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | } |
| 388 | 388 | if (!$this->dry_run && $app && $app_id && ($app != $this->definition->application || $app_id != $id)) |
| 389 | 389 | { |
| 390 | - $link_id = Link::link($this->definition->application,$id,$app,$app_id); |
|
| 390 | + $link_id = Link::link($this->definition->application, $id, $app, $app_id); |
|
| 391 | 391 | } |
| 392 | 392 | } |
| 393 | 393 | } |
@@ -404,13 +404,13 @@ discard block |
||
| 404 | 404 | * @param importexport_definition $definition |
| 405 | 405 | * @return String HTML for preview |
| 406 | 406 | */ |
| 407 | - public function preview( $stream, importexport_definition $definition ) |
|
| 407 | + public function preview($stream, importexport_definition $definition) |
|
| 408 | 408 | { |
| 409 | 409 | $this->import($stream, $definition); |
| 410 | 410 | rewind($stream); |
| 411 | 411 | |
| 412 | 412 | // Set up result |
| 413 | - $rows = array('h1'=>array(),'f1'=>array(),'.h1'=>'class=th'); |
|
| 413 | + $rows = array('h1'=>array(), 'f1'=>array(), '.h1'=>'class=th'); |
|
| 414 | 414 | |
| 415 | 415 | // Load labels for app |
| 416 | 416 | $record_class = get_class($this->preview_records[0]); |
@@ -419,27 +419,27 @@ discard block |
||
| 419 | 419 | $labels = array_combine($definition->plugin_options['field_mapping'], $definition->plugin_options['field_mapping']); |
| 420 | 420 | |
| 421 | 421 | $plugin = get_called_class(); |
| 422 | - $wizard_name = $definition->application . '_wizard_' . str_replace($definition->application . '_', '', $plugin); |
|
| 422 | + $wizard_name = $definition->application.'_wizard_'.str_replace($definition->application.'_', '', $plugin); |
|
| 423 | 423 | try { |
| 424 | 424 | $wizard = new $wizard_name; |
| 425 | 425 | $fields = $wizard->get_import_fields(); |
| 426 | - foreach($labels as $field => &$label) |
|
| 426 | + foreach ($labels as $field => &$label) |
|
| 427 | 427 | { |
| 428 | - if($fields[$field]) $label = $fields[$field]; |
|
| 428 | + if ($fields[$field]) $label = $fields[$field]; |
|
| 429 | 429 | } |
| 430 | 430 | } catch (Exception $e) { |
| 431 | 431 | Api\Translation::add_app($definition->application); |
| 432 | - foreach($labels as $field => &$label) { |
|
| 432 | + foreach ($labels as $field => &$label) { |
|
| 433 | 433 | $label = lang($label); |
| 434 | 434 | } |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | // Set up HTML |
| 438 | 438 | $rows['h1'] = $labels; |
| 439 | - foreach($this->preview_records as $i => $row_data) |
|
| 439 | + foreach ($this->preview_records as $i => $row_data) |
|
| 440 | 440 | { |
| 441 | 441 | // Convert to human-friendly |
| 442 | - importexport_export_csv::convert($row_data,$record_class::$types,$definition->application,$this->lookups); |
|
| 442 | + importexport_export_csv::convert($row_data, $record_class::$types, $definition->application, $this->lookups); |
|
| 443 | 443 | $this->row_preview($row_data); |
| 444 | 444 | $rows[] = $row_data->get_record_array(); |
| 445 | 445 | } |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | * @param string $org_name |
| 469 | 469 | * @return int|boolean Contact ID of first match, or false if none found |
| 470 | 470 | */ |
| 471 | - public static function addr_id( $n_family,$n_given=null,$org_name=null, &$record=null) { |
|
| 471 | + public static function addr_id($n_family, $n_given = null, $org_name = null, &$record = null) { |
|
| 472 | 472 | |
| 473 | 473 | // find in Addressbook, at least n_family AND (n_given OR org_name) have to match |
| 474 | 474 | static $contacts; |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | list($n_family, $n_given, $org_name) = explode(',', $n_family); |
| 479 | 479 | } |
| 480 | 480 | $n_family = trim($n_family); |
| 481 | - if(!is_null($n_given)) $n_given = trim($n_given); |
|
| 481 | + if (!is_null($n_given)) $n_given = trim($n_given); |
|
| 482 | 482 | if (!is_object($contacts)) |
| 483 | 483 | { |
| 484 | 484 | $contacts = new Api\Contacts(); |
@@ -486,10 +486,10 @@ discard block |
||
| 486 | 486 | if (!is_null($org_name)) // org_name given? |
| 487 | 487 | { |
| 488 | 488 | $org_name = trim($org_name); |
| 489 | - $addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name" ); |
|
| 489 | + $addrs = $contacts->read(0, 0, array('id'), '', "n_family=$n_family,n_given=$n_given,org_name=$org_name"); |
|
| 490 | 490 | if (!count($addrs)) |
| 491 | 491 | { |
| 492 | - $addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,org_name=$org_name",'','n_family,org_name'); |
|
| 492 | + $addrs = $contacts->read(0, 0, array('id'), '', "n_family=$n_family,org_name=$org_name", '', 'n_family,org_name'); |
|
| 493 | 493 | } |
| 494 | 494 | } |
| 495 | 495 | if (!is_null($n_given) && (is_null($org_name) || !count($addrs))) // first name given and no result so far |
@@ -498,11 +498,11 @@ discard block |
||
| 498 | 498 | } |
| 499 | 499 | if (is_null($n_given) && is_null($org_name)) // just one name given, check against fn (= full name) |
| 500 | 500 | { |
| 501 | - $addrs = $contacts->read( 0,0,array('id'),'',"n_fn=$n_family",'','n_fn' ); |
|
| 501 | + $addrs = $contacts->read(0, 0, array('id'), '', "n_fn=$n_family", '', 'n_fn'); |
|
| 502 | 502 | } |
| 503 | 503 | if (count($addrs)) |
| 504 | 504 | { |
| 505 | - if(!$record || !$record->get_identifier()) |
|
| 505 | + if (!$record || !$record->get_identifier()) |
|
| 506 | 506 | { |
| 507 | 507 | return $addrs[0]['id']; |
| 508 | 508 | } |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | { |
| 513 | 513 | $id = key($addrs); |
| 514 | 514 | array_shift($addrs); |
| 515 | - } while($addrs && !$id && $id == $record->get_identifier()); |
|
| 515 | + } while ($addrs && !$id && $id == $record->get_identifier()); |
|
| 516 | 516 | return $id; |
| 517 | 517 | } |
| 518 | 518 | } |
@@ -527,22 +527,22 @@ discard block |
||
| 527 | 527 | * @param string $app Target application name |
| 528 | 528 | * @param string $value CSV value in the form of custom_field_name:value |
| 529 | 529 | */ |
| 530 | - protected function link_by_cf(importexport_iface_egw_record &$record, $app, $value,$record_num) |
|
| 530 | + protected function link_by_cf(importexport_iface_egw_record &$record, $app, $value, $record_num) |
|
| 531 | 531 | { |
| 532 | 532 | $app_id = false; |
| 533 | 533 | |
| 534 | - list($custom_field, $value) = explode(':',$value); |
|
| 534 | + list($custom_field, $value) = explode(':', $value); |
|
| 535 | 535 | // Find matching entry |
| 536 | - if($app && $custom_field && $value) |
|
| 536 | + if ($app && $custom_field && $value) |
|
| 537 | 537 | { |
| 538 | 538 | $cfs = Api\Storage\Customfields::get($app); |
| 539 | 539 | // Error if no custom fields, probably something wrong in definition |
| 540 | - if(!$cfs[$custom_field]) |
|
| 540 | + if (!$cfs[$custom_field]) |
|
| 541 | 541 | { |
| 542 | 542 | // Check for users specifing label instead of name |
| 543 | - foreach($cfs as $name => $settings) |
|
| 543 | + foreach ($cfs as $name => $settings) |
|
| 544 | 544 | { |
| 545 | - if(strtolower($settings['label']) == strtolower($custom_field)) |
|
| 545 | + if (strtolower($settings['label']) == strtolower($custom_field)) |
|
| 546 | 546 | { |
| 547 | 547 | $custom_field = $name; |
| 548 | 548 | break; |
@@ -551,30 +551,30 @@ discard block |
||
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | // Couldn't find field, give an error - something's wrong |
| 554 | - if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)]) { |
|
| 554 | + if (!$cfs[$custom_field] && !$cfs[substr($custom_field, 1)]) { |
|
| 555 | 555 | $this->errors[$record_num] .= lang('No custom field "%1" for %2.', |
| 556 | 556 | $custom_field, lang($app)); |
| 557 | 557 | return false; |
| 558 | 558 | } |
| 559 | - if($custom_field[0] != '#') $custom_field = '#' . $custom_field; |
|
| 559 | + if ($custom_field[0] != '#') $custom_field = '#'.$custom_field; |
|
| 560 | 560 | error_log("Searching for $custom_field = $value"); |
| 561 | 561 | // Search |
| 562 | - if(Link::get_registry($app, 'query')) |
|
| 562 | + if (Link::get_registry($app, 'query')) |
|
| 563 | 563 | { |
| 564 | - $options = array('filter' => array("$custom_field = " . $GLOBALS['egw']->db->quote($value))); |
|
| 564 | + $options = array('filter' => array("$custom_field = ".$GLOBALS['egw']->db->quote($value))); |
|
| 565 | 565 | $result = Link::query($app, '', $options); |
| 566 | 566 | |
| 567 | 567 | // Only one allowed |
| 568 | - if($record->get_identifier()) |
|
| 568 | + if ($record->get_identifier()) |
|
| 569 | 569 | { |
| 570 | - while(key($result) == $record->get_identifier()) |
|
| 570 | + while (key($result) == $record->get_identifier()) |
|
| 571 | 571 | { |
| 572 | 572 | array_shift($result); |
| 573 | 573 | } |
| 574 | 574 | } |
| 575 | - if(count($result) != 1) |
|
| 575 | + if (count($result) != 1) |
|
| 576 | 576 | { |
| 577 | - $this->warnings[$record_num] .= ($this->warnings[$record_num] ? "\n" : '') . |
|
| 577 | + $this->warnings[$record_num] .= ($this->warnings[$record_num] ? "\n" : ''). |
|
| 578 | 578 | lang('Unable to link to %3 by custom field "%1": "%4". %2 matches.', |
| 579 | 579 | $custom_field, count($result), lang($app), $options['filter'][0] |
| 580 | 580 | ); |
@@ -139,7 +139,6 @@ discard block |
||
| 139 | 139 | /** |
| 140 | 140 | * Save a definition |
| 141 | 141 | * |
| 142 | - * @param definition $definition |
|
| 143 | 142 | */ |
| 144 | 143 | public function save(Array $data) { |
| 145 | 144 | $definition = new importexport_definition(); |
@@ -209,7 +208,7 @@ discard block |
||
| 209 | 208 | /** |
| 210 | 209 | * imports definitions from file |
| 211 | 210 | * |
| 212 | - * @param string $import_file |
|
| 211 | + * @param string $_import_file |
|
| 213 | 212 | * @throws Exeption |
| 214 | 213 | * @return void |
| 215 | 214 | */ |
@@ -268,7 +267,6 @@ discard block |
||
| 268 | 267 | * It is not possible to handle some plugin options automatically, because they |
| 269 | 268 | * just don't have equivalents. (eg: What to do with unknown categories) |
| 270 | 269 | * |
| 271 | - * @param importexport_definition $definition Import definition |
|
| 272 | 270 | * |
| 273 | 271 | * @return importexport_definition Export definition |
| 274 | 272 | */ |
@@ -137,10 +137,10 @@ |
||
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
| 140 | - * Save a definition |
|
| 141 | - * |
|
| 142 | - * @param definition $definition |
|
| 143 | - */ |
|
| 140 | + * Save a definition |
|
| 141 | + * |
|
| 142 | + * @param definition $definition |
|
| 143 | + */ |
|
| 144 | 144 | public function save(Array $data) { |
| 145 | 145 | $definition = new importexport_definition(); |
| 146 | 146 | $definition->set_record($data); |
@@ -31,13 +31,13 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | private $definitions; |
| 33 | 33 | |
| 34 | - public function __construct($_query=false, $ignore_acl = false) |
|
| 34 | + public function __construct($_query = false, $ignore_acl = false) |
|
| 35 | 35 | { |
| 36 | - $this->so_sql = new Api\Storage\Base(self::_appname, self::_defintion_table ); |
|
| 36 | + $this->so_sql = new Api\Storage\Base(self::_appname, self::_defintion_table); |
|
| 37 | 37 | if ($_query) { |
| 38 | 38 | $definitions = $this->so_sql->search($_query, false); |
| 39 | 39 | foreach ((array)$definitions as $definition) { |
| 40 | - if(self::is_permitted($definition) || $ignore_acl) $this->definitions[] = $definition['definition_id']; |
|
| 40 | + if (self::is_permitted($definition) || $ignore_acl) $this->definitions[] = $definition['definition_id']; |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | } |
@@ -45,16 +45,16 @@ discard block |
||
| 45 | 45 | public function get_rows(&$query, &$rows, &$readonlys) |
| 46 | 46 | { |
| 47 | 47 | // Filter only definitions user is allowed to use |
| 48 | - if(!$GLOBALS['egw_info']['user']['apps']['admin']) { |
|
| 48 | + if (!$GLOBALS['egw_info']['user']['apps']['admin']) { |
|
| 49 | 49 | $this_membership = $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true); |
| 50 | 50 | $this_membership[] = $GLOBALS['egw_info']['user']['account_id']; |
| 51 | 51 | $sql .= ' ('; |
| 52 | 52 | $read = array(); |
| 53 | - foreach($this_membership as $id) |
|
| 53 | + foreach ($this_membership as $id) |
|
| 54 | 54 | { |
| 55 | 55 | $read[] = 'allowed_users '. |
| 56 | 56 | $GLOBALS['egw']->db->capabilities['case_insensitive_like'].' '. |
| 57 | - $GLOBALS['egw']->db->quote('%,'.str_replace('_','\\_',$id) .',%'); |
|
| 57 | + $GLOBALS['egw']->db->quote('%,'.str_replace('_', '\\_', $id).',%'); |
|
| 58 | 58 | } |
| 59 | 59 | $sql .= implode(' OR ', $read); |
| 60 | 60 | $sql .= ') OR owner = '.$GLOBALS['egw_info']['user']['account_id']; |
@@ -62,37 +62,37 @@ discard block |
||
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // Handle allowed filter |
| 65 | - if($query['col_filter']['allowed_users']) |
|
| 65 | + if ($query['col_filter']['allowed_users']) |
|
| 66 | 66 | { |
| 67 | 67 | $allowed = array(); |
| 68 | - foreach((array)$query['col_filter']['allowed_users'] as $id) |
|
| 68 | + foreach ((array)$query['col_filter']['allowed_users'] as $id) |
|
| 69 | 69 | { |
| 70 | 70 | $allowed[] = 'allowed_users '. |
| 71 | 71 | $GLOBALS['egw']->db->capabilities['case_insensitive_like'].' '. |
| 72 | - $GLOBALS['egw']->db->quote('%,'.str_replace('_','\\_',$id) .',%'); |
|
| 72 | + $GLOBALS['egw']->db->quote('%,'.str_replace('_', '\\_', $id).',%'); |
|
| 73 | 73 | } |
| 74 | - if($allowed) |
|
| 74 | + if ($allowed) |
|
| 75 | 75 | { |
| 76 | 76 | unset($query['col_filter']['allowed_users']); |
| 77 | - $query['col_filter'][] = '('.implode(' OR ', $allowed) . ')'; |
|
| 77 | + $query['col_filter'][] = '('.implode(' OR ', $allowed).')'; |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | $total = $this->so_sql->get_rows($query, $rows, $readonlys); |
| 82 | 82 | $ro_count = 0; |
| 83 | - foreach($rows as &$row) { |
|
| 83 | + foreach ($rows as &$row) { |
|
| 84 | 84 | // Strip off leading + trailing , |
| 85 | - $row['allowed_users'] = substr($row['allowed_users'],1,-1); |
|
| 85 | + $row['allowed_users'] = substr($row['allowed_users'], 1, -1); |
|
| 86 | 86 | |
| 87 | 87 | $readonlys["edit[{$row['definition_id']}]"] = $readonlys["delete[{$row['definition_id']}]"] = |
| 88 | 88 | ($row['owner'] != $GLOBALS['egw_info']['user']['account_id']) && |
| 89 | 89 | !$GLOBALS['egw_info']['user']['apps']['admin']; |
| 90 | - if($readonlys["edit[{$row['definition_id']}]"]) |
|
| 90 | + if ($readonlys["edit[{$row['definition_id']}]"]) |
|
| 91 | 91 | { |
| 92 | 92 | $row['class'] .= 'rowNoEdit rowNoDelete'; |
| 93 | 93 | $ro_count++; |
| 94 | 94 | } |
| 95 | - $row['class'] .= ' ' . $row['type']; |
|
| 95 | + $row['class'] .= ' '.$row['type']; |
|
| 96 | 96 | } |
| 97 | 97 | $readonlys['delete_selected'] = $ro_count == count($rows); |
| 98 | 98 | return $total; |
@@ -107,11 +107,11 @@ discard block |
||
| 107 | 107 | return $this->definitions; |
| 108 | 108 | } |
| 109 | 109 | public function read($definition_id) { |
| 110 | - if(is_numeric($definition_id)) { |
|
| 110 | + if (is_numeric($definition_id)) { |
|
| 111 | 111 | $this->so_sql->read($definition_id); |
| 112 | 112 | $definition = new importexport_definition($this->so_sql->data['name']); |
| 113 | 113 | } else { |
| 114 | - $definition = new importexport_definition( $definition_id['name'] ); |
|
| 114 | + $definition = new importexport_definition($definition_id['name']); |
|
| 115 | 115 | } |
| 116 | 116 | return $definition->get_record_array(); |
| 117 | 117 | } |
@@ -124,14 +124,14 @@ discard block |
||
| 124 | 124 | foreach ($keys as $index => $key) { |
| 125 | 125 | // Check for ownership |
| 126 | 126 | $definition = $this->read($key); |
| 127 | - if($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id'] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
| 127 | + if ($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id'] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
| 128 | 128 | // clear private cache |
| 129 | - unset($this->definitions[array_search($key,$this->definitions)]); |
|
| 129 | + unset($this->definitions[array_search($key, $this->definitions)]); |
|
| 130 | 130 | } else { |
| 131 | 131 | unset($keys[$index]); |
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | - if(count($keys) > 0) { |
|
| 134 | + if (count($keys) > 0) { |
|
| 135 | 135 | $this->so_sql->delete(array('definition_id' => $keys)); |
| 136 | 136 | } |
| 137 | 137 | } |
@@ -154,12 +154,12 @@ discard block |
||
| 154 | 154 | * @return bool |
| 155 | 155 | */ |
| 156 | 156 | static public function is_permitted($_definition) { |
| 157 | - $allowed_user = is_array($_definition['allowed_users']) ? $_definition['allowed_users'] : explode(',',$_definition['allowed_users']); |
|
| 157 | + $allowed_user = is_array($_definition['allowed_users']) ? $_definition['allowed_users'] : explode(',', $_definition['allowed_users']); |
|
| 158 | 158 | $this_user_id = $GLOBALS['egw_info']['user']['account_id']; |
| 159 | 159 | $this_membership = $GLOBALS['egw']->accounts->memberships($this_user_id, true); |
| 160 | 160 | $this_membership[] = $this_user_id; |
| 161 | 161 | $this_membership[] = 'all'; |
| 162 | - $alluser = array_intersect($allowed_user,$this_membership); |
|
| 162 | + $alluser = array_intersect($allowed_user, $this_membership); |
|
| 163 | 163 | return ($this_user_id == $_definition['owner'] || count($alluser) > 0); |
| 164 | 164 | } |
| 165 | 165 | |
@@ -178,13 +178,13 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | $export_data['definitions'] = array(); |
| 180 | 180 | foreach ($keys as $definition_id) { |
| 181 | - $definition = new importexport_definition( $definition_id ); |
|
| 181 | + $definition = new importexport_definition($definition_id); |
|
| 182 | 182 | $export_data['definitions'][$definition->name] = $definition->get_record_array(); |
| 183 | 183 | $export_data['definitions'][$definition->name]['allowed_users'] = |
| 184 | 184 | importexport_helper_functions::account_id2name( |
| 185 | 185 | $export_data['definitions'][$definition->name]['allowed_users'] |
| 186 | 186 | ); |
| 187 | - if($export_date['definitions'][$definition->name]['owner']) { |
|
| 187 | + if ($export_date['definitions'][$definition->name]['owner']) { |
|
| 188 | 188 | $export_data['definitions'][$definition->name]['owner'] = |
| 189 | 189 | importexport_helper_functions::account_id2name( |
| 190 | 190 | $export_data['definitions'][$definition->name]['owner'] |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | unset($export_data['definitions'][$definition->name]['definition_id']); |
| 196 | 196 | unset($export_data['definitions'][$definition->name]['description']); |
| 197 | 197 | unset($export_data['definitions'][$definition->name]['user_timezone_read']); |
| 198 | - if(is_array($export_data['definitions'][$definition->name]['plugin_options'])) { |
|
| 198 | + if (is_array($export_data['definitions'][$definition->name]['plugin_options'])) { |
|
| 199 | 199 | unset($export_data['definitions'][$definition->name]['plugin_options']['user_timezone_read']); |
| 200 | 200 | } |
| 201 | 201 | unset($definition); |
@@ -213,17 +213,17 @@ discard block |
||
| 213 | 213 | * @throws Exeption |
| 214 | 214 | * @return void |
| 215 | 215 | */ |
| 216 | - public static function import( $_import_file ) |
|
| 216 | + public static function import($_import_file) |
|
| 217 | 217 | { |
| 218 | - if ( !is_file( $_import_file ) ) { |
|
| 219 | - throw new Exception("'$_import_file' does not exist or is not readable" ); |
|
| 218 | + if (!is_file($_import_file)) { |
|
| 219 | + throw new Exception("'$_import_file' does not exist or is not readable"); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - $data = importexport_arrayxml::xml2array( file_get_contents( $_import_file ) ); |
|
| 222 | + $data = importexport_arrayxml::xml2array(file_get_contents($_import_file)); |
|
| 223 | 223 | |
| 224 | 224 | $metainfo = $data['importExportDefinitions']['metainfo']; |
| 225 | 225 | $definitions = $data['importExportDefinitions']['definitions']; |
| 226 | - unset ( $data ); |
|
| 226 | + unset ($data); |
|
| 227 | 227 | |
| 228 | 228 | // convert charset into internal used charset |
| 229 | 229 | $definitions = Api\Translation::convert( |
@@ -233,26 +233,26 @@ discard block |
||
| 233 | 233 | ); |
| 234 | 234 | |
| 235 | 235 | // Avoid warning if no definitions found |
| 236 | - if(!is_array($definitions)) return lang('None found'); |
|
| 236 | + if (!is_array($definitions)) return lang('None found'); |
|
| 237 | 237 | |
| 238 | 238 | // save definition(s) into internal table |
| 239 | - foreach ( $definitions as $name => $definition_data ) |
|
| 239 | + foreach ($definitions as $name => $definition_data) |
|
| 240 | 240 | { |
| 241 | 241 | // convert allowed_user |
| 242 | - $definition_data['allowed_users'] = importexport_helper_functions::account_name2id( $definition_data['allowed_users'] ); |
|
| 243 | - if($definition_data['all_users'] && !$definition_data['allowed_users']) $definition_data['allowed_users'] = 'all'; |
|
| 242 | + $definition_data['allowed_users'] = importexport_helper_functions::account_name2id($definition_data['allowed_users']); |
|
| 243 | + if ($definition_data['all_users'] && !$definition_data['allowed_users']) $definition_data['allowed_users'] = 'all'; |
|
| 244 | 244 | |
| 245 | - $definition_data['owner'] = importexport_helper_functions::account_name2id( $definition_data['owner'] ); |
|
| 245 | + $definition_data['owner'] = importexport_helper_functions::account_name2id($definition_data['owner']); |
|
| 246 | 246 | |
| 247 | - $definition = new importexport_definition( $definition_data['name'] ); |
|
| 247 | + $definition = new importexport_definition($definition_data['name']); |
|
| 248 | 248 | |
| 249 | 249 | // Only update if the imported is newer |
| 250 | - if(strtotime($definition->modified) < strtotime($definition_data['modified']) || $definition->modified == 0) |
|
| 250 | + if (strtotime($definition->modified) < strtotime($definition_data['modified']) || $definition->modified == 0) |
|
| 251 | 251 | { |
| 252 | 252 | $definition_id = $definition->get_identifier() ? $definition->get_identifier() : NULL; |
| 253 | 253 | |
| 254 | - $definition->set_record( $definition_data ); |
|
| 255 | - $definition->save( $definition_id ); |
|
| 254 | + $definition->set_record($definition_data); |
|
| 255 | + $definition->save($definition_id); |
|
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | return $definitions; |
@@ -275,28 +275,28 @@ discard block |
||
| 275 | 275 | public static function export_from_import(importexport_definition $import) |
| 276 | 276 | { |
| 277 | 277 | // Only operates on import definitions |
| 278 | - if($import->type != 'import') throw new Api\Exception\WrongParameter('Only import definitions'); |
|
| 278 | + if ($import->type != 'import') throw new Api\Exception\WrongParameter('Only import definitions'); |
|
| 279 | 279 | |
| 280 | 280 | // Find export plugin |
| 281 | - $plugin = str_replace('import', 'export',$import->plugin); |
|
| 281 | + $plugin = str_replace('import', 'export', $import->plugin); |
|
| 282 | 282 | $plugin_list = importexport_helper_functions::get_plugins($import->application, 'export'); |
| 283 | - foreach($plugin_list as $appname => $type) |
|
| 283 | + foreach ($plugin_list as $appname => $type) |
|
| 284 | 284 | { |
| 285 | 285 | $plugins = $type['export']; |
| 286 | - foreach($plugins as $name => $label) |
|
| 286 | + foreach ($plugins as $name => $label) |
|
| 287 | 287 | { |
| 288 | - if($plugin == $name) break; |
|
| 288 | + if ($plugin == $name) break; |
|
| 289 | 289 | } |
| 290 | - if($plugin !== $name) $plugin = $name; |
|
| 290 | + if ($plugin !== $name) $plugin = $name; |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | $export = new importexport_definition(); |
| 294 | 294 | |
| 295 | 295 | // Common settings |
| 296 | - $export->name = str_replace('import', 'export',$import->name); |
|
| 297 | - if($export->name == $import->name) $export->name = $export->name . '-export'; |
|
| 296 | + $export->name = str_replace('import', 'export', $import->name); |
|
| 297 | + if ($export->name == $import->name) $export->name = $export->name.'-export'; |
|
| 298 | 298 | $test = new importexport_definition($export->name); |
| 299 | - if($test->name) $export->name = $export->name .'-'.$GLOBALS['egw_info']['user']['account_lid']; |
|
| 299 | + if ($test->name) $export->name = $export->name.'-'.$GLOBALS['egw_info']['user']['account_lid']; |
|
| 300 | 300 | |
| 301 | 301 | $export->application = $import->application; |
| 302 | 302 | $export->plugin = $plugin; |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | ); |
| 313 | 313 | |
| 314 | 314 | // Mapping |
| 315 | - foreach($i_options['field_mapping'] as $col_num => $field) |
|
| 315 | + foreach ($i_options['field_mapping'] as $col_num => $field) |
|
| 316 | 316 | { |
| 317 | 317 | // Try to use heading from import file, if possible |
| 318 | 318 | $e_options['mapping'][$field] = $i_options['csv_fields'][$col_num] ? $i_options['csv_fields'][$col_num] : $field; |
@@ -16,7 +16,8 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @todo make this class an egw_record_pool! |
| 18 | 18 | */ |
| 19 | -class importexport_definitions_bo { |
|
| 19 | +class importexport_definitions_bo |
|
| 20 | +{ |
|
| 20 | 21 | |
| 21 | 22 | const _appname = 'importexport'; |
| 22 | 23 | const _defintion_table = 'egw_importexport_definitions'; |
@@ -34,10 +35,15 @@ discard block |
||
| 34 | 35 | public function __construct($_query=false, $ignore_acl = false) |
| 35 | 36 | { |
| 36 | 37 | $this->so_sql = new Api\Storage\Base(self::_appname, self::_defintion_table ); |
| 37 | - if ($_query) { |
|
| 38 | + if ($_query) |
|
| 39 | + { |
|
| 38 | 40 | $definitions = $this->so_sql->search($_query, false); |
| 39 | - foreach ((array)$definitions as $definition) { |
|
| 40 | - if(self::is_permitted($definition) || $ignore_acl) $this->definitions[] = $definition['definition_id']; |
|
| 41 | + foreach ((array)$definitions as $definition) |
|
| 42 | + { |
|
| 43 | + if(self::is_permitted($definition) || $ignore_acl) |
|
| 44 | + { |
|
| 45 | + $this->definitions[] = $definition['definition_id']; |
|
| 46 | + } |
|
| 41 | 47 | } |
| 42 | 48 | } |
| 43 | 49 | } |
@@ -45,7 +51,8 @@ discard block |
||
| 45 | 51 | public function get_rows(&$query, &$rows, &$readonlys) |
| 46 | 52 | { |
| 47 | 53 | // Filter only definitions user is allowed to use |
| 48 | - if(!$GLOBALS['egw_info']['user']['apps']['admin']) { |
|
| 54 | + if(!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 55 | + { |
|
| 49 | 56 | $this_membership = $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true); |
| 50 | 57 | $this_membership[] = $GLOBALS['egw_info']['user']['account_id']; |
| 51 | 58 | $sql .= ' ('; |
@@ -80,7 +87,8 @@ discard block |
||
| 80 | 87 | |
| 81 | 88 | $total = $this->so_sql->get_rows($query, $rows, $readonlys); |
| 82 | 89 | $ro_count = 0; |
| 83 | - foreach($rows as &$row) { |
|
| 90 | + foreach($rows as &$row) |
|
| 91 | + { |
|
| 84 | 92 | // Strip off leading + trailing , |
| 85 | 93 | $row['allowed_users'] = substr($row['allowed_users'],1,-1); |
| 86 | 94 | |
@@ -103,14 +111,19 @@ discard block |
||
| 103 | 111 | * |
| 104 | 112 | * @return array |
| 105 | 113 | */ |
| 106 | - public function get_definitions() { |
|
| 114 | + public function get_definitions() |
|
| 115 | + { |
|
| 107 | 116 | return $this->definitions; |
| 108 | 117 | } |
| 109 | - public function read($definition_id) { |
|
| 110 | - if(is_numeric($definition_id)) { |
|
| 118 | + public function read($definition_id) |
|
| 119 | + { |
|
| 120 | + if(is_numeric($definition_id)) |
|
| 121 | + { |
|
| 111 | 122 | $this->so_sql->read($definition_id); |
| 112 | 123 | $definition = new importexport_definition($this->so_sql->data['name']); |
| 113 | - } else { |
|
| 124 | + } |
|
| 125 | + else |
|
| 126 | + { |
|
| 114 | 127 | $definition = new importexport_definition( $definition_id['name'] ); |
| 115 | 128 | } |
| 116 | 129 | return $definition->get_record_array(); |
@@ -120,18 +133,24 @@ discard block |
||
| 120 | 133 | * |
| 121 | 134 | * @param array $keys |
| 122 | 135 | */ |
| 123 | - public function delete($keys) { |
|
| 124 | - foreach ($keys as $index => $key) { |
|
| 136 | + public function delete($keys) |
|
| 137 | + { |
|
| 138 | + foreach ($keys as $index => $key) |
|
| 139 | + { |
|
| 125 | 140 | // Check for ownership |
| 126 | 141 | $definition = $this->read($key); |
| 127 | - if($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id'] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
| 142 | + if($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id'] || $GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 143 | + { |
|
| 128 | 144 | // clear private cache |
| 129 | 145 | unset($this->definitions[array_search($key,$this->definitions)]); |
| 130 | - } else { |
|
| 146 | + } |
|
| 147 | + else |
|
| 148 | + { |
|
| 131 | 149 | unset($keys[$index]); |
| 132 | 150 | } |
| 133 | 151 | } |
| 134 | - if(count($keys) > 0) { |
|
| 152 | + if(count($keys) > 0) |
|
| 153 | + { |
|
| 135 | 154 | $this->so_sql->delete(array('definition_id' => $keys)); |
| 136 | 155 | } |
| 137 | 156 | } |
@@ -141,7 +160,8 @@ discard block |
||
| 141 | 160 | * |
| 142 | 161 | * @param definition $definition |
| 143 | 162 | */ |
| 144 | - public function save(Array $data) { |
|
| 163 | + public function save(Array $data) |
|
| 164 | + { |
|
| 145 | 165 | $definition = new importexport_definition(); |
| 146 | 166 | $definition->set_record($data); |
| 147 | 167 | $definition->save($data['definition_id']); |
@@ -153,7 +173,8 @@ discard block |
||
| 153 | 173 | * @param array $_definition |
| 154 | 174 | * @return bool |
| 155 | 175 | */ |
| 156 | - static public function is_permitted($_definition) { |
|
| 176 | + static public function is_permitted($_definition) |
|
| 177 | + { |
|
| 157 | 178 | $allowed_user = is_array($_definition['allowed_users']) ? $_definition['allowed_users'] : explode(',',$_definition['allowed_users']); |
| 158 | 179 | $this_user_id = $GLOBALS['egw_info']['user']['account_id']; |
| 159 | 180 | $this_membership = $GLOBALS['egw']->accounts->memberships($this_user_id, true); |
@@ -177,25 +198,30 @@ discard block |
||
| 177 | 198 | )); |
| 178 | 199 | |
| 179 | 200 | $export_data['definitions'] = array(); |
| 180 | - foreach ($keys as $definition_id) { |
|
| 201 | + foreach ($keys as $definition_id) |
|
| 202 | + { |
|
| 181 | 203 | $definition = new importexport_definition( $definition_id ); |
| 182 | 204 | $export_data['definitions'][$definition->name] = $definition->get_record_array(); |
| 183 | 205 | $export_data['definitions'][$definition->name]['allowed_users'] = |
| 184 | 206 | importexport_helper_functions::account_id2name( |
| 185 | 207 | $export_data['definitions'][$definition->name]['allowed_users'] |
| 186 | 208 | ); |
| 187 | - if($export_date['definitions'][$definition->name]['owner']) { |
|
| 209 | + if($export_date['definitions'][$definition->name]['owner']) |
|
| 210 | + { |
|
| 188 | 211 | $export_data['definitions'][$definition->name]['owner'] = |
| 189 | 212 | importexport_helper_functions::account_id2name( |
| 190 | 213 | $export_data['definitions'][$definition->name]['owner'] |
| 191 | 214 | ); |
| 192 | - } else { |
|
| 215 | + } |
|
| 216 | + else |
|
| 217 | + { |
|
| 193 | 218 | unset($export_data['definitions'][$definition->name]['owner']); |
| 194 | 219 | } |
| 195 | 220 | unset($export_data['definitions'][$definition->name]['definition_id']); |
| 196 | 221 | unset($export_data['definitions'][$definition->name]['description']); |
| 197 | 222 | unset($export_data['definitions'][$definition->name]['user_timezone_read']); |
| 198 | - if(is_array($export_data['definitions'][$definition->name]['plugin_options'])) { |
|
| 223 | + if(is_array($export_data['definitions'][$definition->name]['plugin_options'])) |
|
| 224 | + { |
|
| 199 | 225 | unset($export_data['definitions'][$definition->name]['plugin_options']['user_timezone_read']); |
| 200 | 226 | } |
| 201 | 227 | unset($definition); |
@@ -215,7 +241,8 @@ discard block |
||
| 215 | 241 | */ |
| 216 | 242 | public static function import( $_import_file ) |
| 217 | 243 | { |
| 218 | - if ( !is_file( $_import_file ) ) { |
|
| 244 | + if ( !is_file( $_import_file ) ) |
|
| 245 | + { |
|
| 219 | 246 | throw new Exception("'$_import_file' does not exist or is not readable" ); |
| 220 | 247 | } |
| 221 | 248 | |
@@ -233,14 +260,20 @@ discard block |
||
| 233 | 260 | ); |
| 234 | 261 | |
| 235 | 262 | // Avoid warning if no definitions found |
| 236 | - if(!is_array($definitions)) return lang('None found'); |
|
| 263 | + if(!is_array($definitions)) |
|
| 264 | + { |
|
| 265 | + return lang('None found'); |
|
| 266 | + } |
|
| 237 | 267 | |
| 238 | 268 | // save definition(s) into internal table |
| 239 | 269 | foreach ( $definitions as $name => $definition_data ) |
| 240 | 270 | { |
| 241 | 271 | // convert allowed_user |
| 242 | 272 | $definition_data['allowed_users'] = importexport_helper_functions::account_name2id( $definition_data['allowed_users'] ); |
| 243 | - if($definition_data['all_users'] && !$definition_data['allowed_users']) $definition_data['allowed_users'] = 'all'; |
|
| 273 | + if($definition_data['all_users'] && !$definition_data['allowed_users']) |
|
| 274 | + { |
|
| 275 | + $definition_data['allowed_users'] = 'all'; |
|
| 276 | + } |
|
| 244 | 277 | |
| 245 | 278 | $definition_data['owner'] = importexport_helper_functions::account_name2id( $definition_data['owner'] ); |
| 246 | 279 | |
@@ -275,7 +308,10 @@ discard block |
||
| 275 | 308 | public static function export_from_import(importexport_definition $import) |
| 276 | 309 | { |
| 277 | 310 | // Only operates on import definitions |
| 278 | - if($import->type != 'import') throw new Api\Exception\WrongParameter('Only import definitions'); |
|
| 311 | + if($import->type != 'import') |
|
| 312 | + { |
|
| 313 | + throw new Api\Exception\WrongParameter('Only import definitions'); |
|
| 314 | + } |
|
| 279 | 315 | |
| 280 | 316 | // Find export plugin |
| 281 | 317 | $plugin = str_replace('import', 'export',$import->plugin); |
@@ -285,18 +321,30 @@ discard block |
||
| 285 | 321 | $plugins = $type['export']; |
| 286 | 322 | foreach($plugins as $name => $label) |
| 287 | 323 | { |
| 288 | - if($plugin == $name) break; |
|
| 324 | + if($plugin == $name) |
|
| 325 | + { |
|
| 326 | + break; |
|
| 327 | + } |
|
| 328 | + } |
|
| 329 | + if($plugin !== $name) |
|
| 330 | + { |
|
| 331 | + $plugin = $name; |
|
| 289 | 332 | } |
| 290 | - if($plugin !== $name) $plugin = $name; |
|
| 291 | 333 | } |
| 292 | 334 | |
| 293 | 335 | $export = new importexport_definition(); |
| 294 | 336 | |
| 295 | 337 | // Common settings |
| 296 | 338 | $export->name = str_replace('import', 'export',$import->name); |
| 297 | - if($export->name == $import->name) $export->name = $export->name . '-export'; |
|
| 339 | + if($export->name == $import->name) |
|
| 340 | + { |
|
| 341 | + $export->name = $export->name . '-export'; |
|
| 342 | + } |
|
| 298 | 343 | $test = new importexport_definition($export->name); |
| 299 | - if($test->name) $export->name = $export->name .'-'.$GLOBALS['egw_info']['user']['account_lid']; |
|
| 344 | + if($test->name) |
|
| 345 | + { |
|
| 346 | + $export->name = $export->name .'-'.$GLOBALS['egw_info']['user']['account_lid']; |
|
| 347 | + } |
|
| 300 | 348 | |
| 301 | 349 | $export->application = $import->application; |
| 302 | 350 | $export->plugin = $plugin; |
@@ -141,7 +141,7 @@ |
||
| 141 | 141 | * |
| 142 | 142 | * @param definition $definition |
| 143 | 143 | */ |
| 144 | - public function save(Array $data) { |
|
| 144 | + public function save(array $data) { |
|
| 145 | 145 | $definition = new importexport_definition(); |
| 146 | 146 | $definition->set_record($data); |
| 147 | 147 | $definition->save($data['definition_id']); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | /** |
| 83 | 83 | * List defined {im|ex}ports |
| 84 | 84 | * |
| 85 | - * @param array $content=null |
|
| 85 | + * @param array $content |
|
| 86 | 86 | */ |
| 87 | 87 | function index($content = null,$msg='') |
| 88 | 88 | { |
@@ -309,8 +309,9 @@ discard block |
||
| 309 | 309 | * @param int &$success number of succeded actions |
| 310 | 310 | * @param int &$failed number of failed actions (not enought permissions) |
| 311 | 311 | * @param string &$action_msg translated verb for the actions, to be used in a message like %1 entries 'deleted' |
| 312 | - * @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup |
|
| 313 | - * @return boolean true if all actions succeded, false otherwise |
|
| 312 | + * @param string $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup |
|
| 313 | + * @param string $msg |
|
| 314 | + * @return null|boolean true if all actions succeded, false otherwise |
|
| 314 | 315 | */ |
| 315 | 316 | function action($action,$selected,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg) |
| 316 | 317 | { |
@@ -940,7 +940,7 @@ |
||
| 940 | 940 | * Determine if the user is allowed to edit the definition |
| 941 | 941 | * |
| 942 | 942 | */ |
| 943 | - protected function can_edit(Array $definition) |
|
| 943 | + protected function can_edit(array $definition) |
|
| 944 | 944 | { |
| 945 | 945 | if($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id']) |
| 946 | 946 | { |
@@ -81,14 +81,18 @@ discard block |
||
| 81 | 81 | { |
| 82 | 82 | $filter = array('name' => '*'); |
| 83 | 83 | |
| 84 | - if($GLOBALS['egw_info']['user']['apps']['admin']) { |
|
| 84 | + if($GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 85 | + { |
|
| 85 | 86 | // Any public definition |
| 86 | 87 | $filter[] = '(owner=0 OR owner IS NULL OR allowed_users IS NOT NULL OR owner = ' . $GLOBALS['egw_info']['user']['account_id'] . ')'; |
| 87 | - } else { |
|
| 88 | + } |
|
| 89 | + else |
|
| 90 | + { |
|
| 88 | 91 | // Filter private definitions |
| 89 | 92 | $filter['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
| 90 | 93 | $config = Api\Config::read('phpgwapi'); |
| 91 | - if($config['export_limit'] == 'no' && !Api\Storage\Merge::is_export_limit_excepted()) { |
|
| 94 | + if($config['export_limit'] == 'no' && !Api\Storage\Merge::is_export_limit_excepted()) |
|
| 95 | + { |
|
| 92 | 96 | $filter['type'] = 'import'; |
| 93 | 97 | } |
| 94 | 98 | } |
@@ -104,7 +108,10 @@ discard block |
||
| 104 | 108 | elseif(($button = array_search('pressed',$content['nm']['rows'])) !== false) |
| 105 | 109 | { |
| 106 | 110 | $selected = $content['nm']['rows']['selected']; |
| 107 | - if(count($selected) < 1 || !is_array($selected)) exit(); |
|
| 111 | + if(count($selected) < 1 || !is_array($selected)) |
|
| 112 | + { |
|
| 113 | + exit(); |
|
| 114 | + } |
|
| 108 | 115 | switch ($button) |
| 109 | 116 | { |
| 110 | 117 | case 'delete_selected' : |
@@ -160,7 +167,8 @@ discard block |
||
| 160 | 167 | } |
| 161 | 168 | } |
| 162 | 169 | |
| 163 | - if(!is_array($content['nm'])) { |
|
| 170 | + if(!is_array($content['nm'])) |
|
| 171 | + { |
|
| 164 | 172 | $content['nm'] = array( |
| 165 | 173 | 'get_rows' => 'importexport.importexport_definitions_ui.get_rows', |
| 166 | 174 | 'no_cat' => true, |
@@ -171,7 +179,10 @@ discard block |
||
| 171 | 179 | 'row_id' => 'definition_id', |
| 172 | 180 | 'placeholder_actions' => array('add') |
| 173 | 181 | ); |
| 174 | - if($_GET['application']) $content['nm']['col_filter']['application'] = $_GET['application']; |
|
| 182 | + if($_GET['application']) |
|
| 183 | + { |
|
| 184 | + $content['nm']['col_filter']['application'] = $_GET['application']; |
|
| 185 | + } |
|
| 175 | 186 | } |
| 176 | 187 | if(Api\Cache::getSession('importexport', 'index')) |
| 177 | 188 | { |
@@ -190,17 +201,22 @@ discard block |
||
| 190 | 201 | ); |
| 191 | 202 | foreach ($this->plugins as $appname => $options) |
| 192 | 203 | { |
| 193 | - if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
| 204 | + if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 205 | + { |
|
| 194 | 206 | $sel_options['application'][$appname] = lang($appname); |
| 195 | 207 | } |
| 196 | 208 | } |
| 197 | - if($msg) $content['msg'] = $msg; |
|
| 209 | + if($msg) |
|
| 210 | + { |
|
| 211 | + $content['msg'] = $msg; |
|
| 212 | + } |
|
| 198 | 213 | |
| 199 | 214 | $etpl = new Etemplate(self::_appname.'.definition_index'); |
| 200 | 215 | return $etpl->exec( self::_appname.'.importexport_definitions_ui.index', $content, $sel_options, $readonlys, $preserv ); |
| 201 | 216 | } |
| 202 | 217 | |
| 203 | - private function get_actions() { |
|
| 218 | + private function get_actions() |
|
| 219 | + { |
|
| 204 | 220 | $group = 0; |
| 205 | 221 | $actions = array( |
| 206 | 222 | 'edit' => array( |
@@ -319,7 +335,8 @@ discard block |
||
| 319 | 335 | $this->get_rows($query,$rows,$readonlys); |
| 320 | 336 | |
| 321 | 337 | $selected = array(); |
| 322 | - foreach($rows as $row) { |
|
| 338 | + foreach($rows as $row) |
|
| 339 | + { |
|
| 323 | 340 | $selected[] = $row['definition_id']; |
| 324 | 341 | } |
| 325 | 342 | if(!is_array($session_name)) |
@@ -334,18 +351,24 @@ discard block |
||
| 334 | 351 | |
| 335 | 352 | $bodefinitions = new importexport_definitions_bo(false, true); |
| 336 | 353 | |
| 337 | - switch($action) { |
|
| 354 | + switch($action) |
|
| 355 | + { |
|
| 338 | 356 | case 'allowed': |
| 339 | 357 | // Field is allowed_users, popup doesn't like _ |
| 340 | 358 | $action = 'allowed_users'; |
| 341 | 359 | // Fall through |
| 342 | 360 | case 'owner': |
| 343 | 361 | $action_msg = lang('changed'. ' ' . $action); |
| 344 | - foreach($selected as $id) { |
|
| 362 | + foreach($selected as $id) |
|
| 363 | + { |
|
| 345 | 364 | $definition = $bodefinitions->read((int)$id); |
| 346 | - if($definition['definition_id']) { |
|
| 365 | + if($definition['definition_id']) |
|
| 366 | + { |
|
| 347 | 367 | // Prevent private with no owner |
| 348 | - if(!$definition['owner'] && !$settings) $definition['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
| 368 | + if(!$definition['owner'] && !$settings) |
|
| 369 | + { |
|
| 370 | + $definition['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
| 371 | + } |
|
| 349 | 372 | |
| 350 | 373 | $definition[$action] = $settings; |
| 351 | 374 | $bodefinitions->save($definition); |
@@ -372,18 +395,22 @@ discard block |
||
| 372 | 395 | case 'copy': |
| 373 | 396 | $action_msg = lang('copied'); |
| 374 | 397 | // Should only be one selected |
| 375 | - foreach($selected as $id) { |
|
| 398 | + foreach($selected as $id) |
|
| 399 | + { |
|
| 376 | 400 | $definition = $bodefinitions->read((int)$id); |
| 377 | - if($definition['definition_id']) { |
|
| 401 | + if($definition['definition_id']) |
|
| 402 | + { |
|
| 378 | 403 | unset($definition['definition_id']); |
| 379 | 404 | $definition['name'] = $settings ? $settings : $definition['name'] . ' copy'; |
| 380 | 405 | try { |
| 381 | 406 | $bodefinitions->save($definition); |
| 382 | - } catch (Exception $e) { |
|
| 407 | + } |
|
| 408 | + catch (Exception $e) { |
|
| 383 | 409 | try { |
| 384 | 410 | $definition['name'] .= ' ' . $GLOBALS['egw_info']['user']['account_lid']; |
| 385 | 411 | $bodefinitions->save($definition); |
| 386 | - } catch (Exception $ex) { |
|
| 412 | + } |
|
| 413 | + catch (Exception $ex) { |
|
| 387 | 414 | $failed++; |
| 388 | 415 | $msg .= lang('Duplicate name, please choose another.'); |
| 389 | 416 | continue; |
@@ -396,18 +423,21 @@ discard block |
||
| 396 | 423 | case 'createexport': |
| 397 | 424 | $action_msg = lang('created'); |
| 398 | 425 | // Should only be one selected |
| 399 | - foreach($selected as $id) { |
|
| 426 | + foreach($selected as $id) |
|
| 427 | + { |
|
| 400 | 428 | $definition = new importexport_definition($id); |
| 401 | 429 | try { |
| 402 | 430 | $export = $bodefinitions->export_from_import($definition); |
| 403 | 431 | $export->save(); |
| 404 | - } catch (Exception $e) { |
|
| 432 | + } |
|
| 433 | + catch (Exception $e) { |
|
| 405 | 434 | if($export) |
| 406 | 435 | { |
| 407 | 436 | try { |
| 408 | 437 | $export->name = $export->name.' ' . $GLOBALS['egw_info']['user']['account_lid']; |
| 409 | 438 | $export->save(); |
| 410 | - } catch (Exception $ex) { |
|
| 439 | + } |
|
| 440 | + catch (Exception $ex) { |
|
| 411 | 441 | $failed++; |
| 412 | 442 | $msg .= lang('Duplicate name, please choose another.'); |
| 413 | 443 | continue; |
@@ -425,7 +455,8 @@ discard block |
||
| 425 | 455 | return !$failed; |
| 426 | 456 | } |
| 427 | 457 | |
| 428 | - public function get_rows(&$query, &$rows, &$readonlys) { |
|
| 458 | + public function get_rows(&$query, &$rows, &$readonlys) |
|
| 459 | + { |
|
| 429 | 460 | $rows = array(); |
| 430 | 461 | Api\Cache::setSession('importexport', 'index', $query); |
| 431 | 462 | |
@@ -500,7 +531,10 @@ discard block |
||
| 500 | 531 | |
| 501 | 532 | if(is_array($content) &&! $content['edit']) |
| 502 | 533 | { |
| 503 | - if(self::_debug) error_log('importexport.wizard->$content '. print_r($content,true)); |
|
| 534 | + if(self::_debug) |
|
| 535 | + { |
|
| 536 | + error_log('importexport.wizard->$content '. print_r($content,true)); |
|
| 537 | + } |
|
| 504 | 538 | //foreach($content as $key => $val) error_log(" $key : ".array2string($val)); |
| 505 | 539 | // fetch plugin object |
| 506 | 540 | if($content['plugin'] && $content['application']) |
@@ -517,13 +551,18 @@ discard block |
||
| 517 | 551 | $wizard_plugin = $content['plugin']; |
| 518 | 552 | } |
| 519 | 553 | // App translations |
| 520 | - if($content['application']) Api\Translation::add_app($content['application']); |
|
| 554 | + if($content['application']) |
|
| 555 | + { |
|
| 556 | + Api\Translation::add_app($content['application']); |
|
| 557 | + } |
|
| 521 | 558 | |
| 522 | 559 | $this->plugin = is_object($GLOBALS['egw']->$wizard_plugin) ? $GLOBALS['egw']->$wizard_plugin : new $wizard_plugin; |
| 523 | 560 | |
| 524 | 561 | // Global object needs to be the same, or references to plugin don't work |
| 525 | 562 | if(!is_object($GLOBALS['egw']->importexport_definitions_ui) || $GLOBALS['egw']->importexport_definitions_ui !== $this) |
| 526 | - $GLOBALS['egw']->importexport_definitions_ui =& $this; |
|
| 563 | + { |
|
| 564 | + $GLOBALS['egw']->importexport_definitions_ui =& $this; |
|
| 565 | + } |
|
| 527 | 566 | } |
| 528 | 567 | // deal with buttons even if we are not on ajax |
| 529 | 568 | if(isset($content['button']) && array_search('pressed',$content['button']) === false && count($content['button']) == 1) |
@@ -653,7 +692,10 @@ discard block |
||
| 653 | 692 | |
| 654 | 693 | function wizard_step10(&$content, &$sel_options, &$readonlys, &$preserv) |
| 655 | 694 | { |
| 656 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step10->$content '.print_r($content,true)); |
|
| 695 | + if(self::_debug) |
|
| 696 | + { |
|
| 697 | + error_log('importexport.importexport_definitions_ui::wizard_step10->$content '.print_r($content,true)); |
|
| 698 | + } |
|
| 657 | 699 | |
| 658 | 700 | // return from step10 |
| 659 | 701 | if ($content['step'] == 'wizard_step10') |
@@ -675,7 +717,8 @@ discard block |
||
| 675 | 717 | $content['text'] = $this->steps['wizard_step10']; |
| 676 | 718 | foreach ($this->plugins as $appname => $options) |
| 677 | 719 | { |
| 678 | - if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
| 720 | + if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 721 | + { |
|
| 679 | 722 | $sel_options['application'][$appname] = lang($appname); |
| 680 | 723 | } |
| 681 | 724 | } |
@@ -691,7 +734,10 @@ discard block |
||
| 691 | 734 | // get plugin |
| 692 | 735 | function wizard_step20(&$content, &$sel_options, &$readonlys, &$preserv) |
| 693 | 736 | { |
| 694 | - if(self::_debug) error_log('importexport.' . get_class($this) . '::wizard_step20->$content '.print_r($content,true)); |
|
| 737 | + if(self::_debug) |
|
| 738 | + { |
|
| 739 | + error_log('importexport.' . get_class($this) . '::wizard_step20->$content '.print_r($content,true)); |
|
| 740 | + } |
|
| 695 | 741 | |
| 696 | 742 | // return from step20 |
| 697 | 743 | if ($content['step'] == 'wizard_step20') |
@@ -700,11 +746,16 @@ discard block |
||
| 700 | 746 | { |
| 701 | 747 | case 'next': |
| 702 | 748 | // There's no real reason the plugin has to come from any of these, as long as it has a $steps variable |
| 703 | - if($this->plugin instanceof importexport_iface_import_plugin || $this->plugin instanceof importexport_wizard_basic_import_csv || strpos(get_class($this->plugin), 'import') !== false) { |
|
| 749 | + if($this->plugin instanceof importexport_iface_import_plugin || $this->plugin instanceof importexport_wizard_basic_import_csv || strpos(get_class($this->plugin), 'import') !== false) |
|
| 750 | + { |
|
| 704 | 751 | $content['type'] = 'import'; |
| 705 | - } elseif($this->plugin instanceof importexport_iface_export_plugin || $this->plugin instanceof importexport_wizard_basic_export_csv || strpos(get_class($this->plugin),'export') !== false) { |
|
| 752 | + } |
|
| 753 | + elseif($this->plugin instanceof importexport_iface_export_plugin || $this->plugin instanceof importexport_wizard_basic_export_csv || strpos(get_class($this->plugin),'export') !== false) |
|
| 754 | + { |
|
| 706 | 755 | $content['type'] = 'export'; |
| 707 | - } else { |
|
| 756 | + } |
|
| 757 | + else |
|
| 758 | + { |
|
| 708 | 759 | throw new Api\Exception('Invalid plugin'); |
| 709 | 760 | } |
| 710 | 761 | return $this->get_step($content['step'],1); |
@@ -722,9 +773,14 @@ discard block |
||
| 722 | 773 | { |
| 723 | 774 | $content['text'] = $this->steps['wizard_step20']; |
| 724 | 775 | $config = Api\Config::read('phpgwapi'); |
| 725 | - foreach ($this->plugins[$content['application']] as $type => $plugins) { |
|
| 726 | - if($config['export_limit'] == 'no' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $type == 'export') continue; |
|
| 727 | - foreach($plugins as $plugin => $name) { |
|
| 776 | + foreach ($this->plugins[$content['application']] as $type => $plugins) |
|
| 777 | + { |
|
| 778 | + if($config['export_limit'] == 'no' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $type == 'export') |
|
| 779 | + { |
|
| 780 | + continue; |
|
| 781 | + } |
|
| 782 | + foreach($plugins as $plugin => $name) |
|
| 783 | + { |
|
| 728 | 784 | $sel_options['plugin'][$plugin] = $name; |
| 729 | 785 | } |
| 730 | 786 | } |
@@ -740,7 +796,10 @@ discard block |
||
| 740 | 796 | // name |
| 741 | 797 | function wizard_step21(&$content, &$sel_options, &$readonlys, &$preserv) |
| 742 | 798 | { |
| 743 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step21->$content '.print_r($content,true)); |
|
| 799 | + if(self::_debug) |
|
| 800 | + { |
|
| 801 | + error_log('importexport.importexport_definitions_ui::wizard_step21->$content '.print_r($content,true)); |
|
| 802 | + } |
|
| 744 | 803 | |
| 745 | 804 | // Check for duplicate name |
| 746 | 805 | $duplicate = isset($content['duplicate_error']); |
@@ -752,7 +811,8 @@ discard block |
||
| 752 | 811 | { |
| 753 | 812 | throw new Exception('Already exists'); |
| 754 | 813 | } |
| 755 | - } catch (Exception $e) { |
|
| 814 | + } |
|
| 815 | + catch (Exception $e) { |
|
| 756 | 816 | // throw new Exception('Already exists'); |
| 757 | 817 | $content['duplicate_error'] = lang('Duplicate name, please choose another.'); |
| 758 | 818 | |
@@ -763,13 +823,16 @@ discard block |
||
| 763 | 823 | $content['name'] .'-'. Api\DateTime::to('now', true), |
| 764 | 824 | //$content['name'] .'-'. rand(0,100), |
| 765 | 825 | ); |
| 766 | - foreach($suggestions as $key => $suggestion) { |
|
| 826 | + foreach($suggestions as $key => $suggestion) |
|
| 827 | + { |
|
| 767 | 828 | $sug_definition = new importexport_definition($suggestion); |
| 768 | - if($sug_definition->definition_id) { |
|
| 829 | + if($sug_definition->definition_id) |
|
| 830 | + { |
|
| 769 | 831 | unset($suggestions[$key]); |
| 770 | 832 | } |
| 771 | 833 | } |
| 772 | - if($suggestions) { |
|
| 834 | + if($suggestions) |
|
| 835 | + { |
|
| 773 | 836 | $content['duplicate_error'] .= ' '. lang('Try')." \n" . implode("\n", $suggestions); |
| 774 | 837 | } |
| 775 | 838 | return $this->get_step($content['step'],0); |
@@ -806,7 +869,10 @@ discard block |
||
| 806 | 869 | // allowed users |
| 807 | 870 | function wizard_step90(&$content, &$sel_options, &$readonlys, &$preserv) |
| 808 | 871 | { |
| 809 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step90->$content '.print_r($content,true)); |
|
| 872 | + if(self::_debug) |
|
| 873 | + { |
|
| 874 | + error_log('importexport.importexport_definitions_ui::wizard_step90->$content '.print_r($content,true)); |
|
| 875 | + } |
|
| 810 | 876 | |
| 811 | 877 | // return from step90 |
| 812 | 878 | if ($content['step'] == 'wizard_step90') |
@@ -876,7 +942,10 @@ discard block |
||
| 876 | 942 | |
| 877 | 943 | function wizard_finish(&$content) |
| 878 | 944 | { |
| 879 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_finish->$content '.print_r($content,true)); |
|
| 945 | + if(self::_debug) |
|
| 946 | + { |
|
| 947 | + error_log('importexport.importexport_definitions_ui::wizard_finish->$content '.print_r($content,true)); |
|
| 948 | + } |
|
| 880 | 949 | // Take out some UI leavings |
| 881 | 950 | unset($content['text']); |
| 882 | 951 | unset($content['step']); |
@@ -905,7 +974,8 @@ discard block |
||
| 905 | 974 | if($content['update']) |
| 906 | 975 | { |
| 907 | 976 | $applist = importexport_helper_functions::get_apps('all', true); |
| 908 | - foreach($applist as $appname) { |
|
| 977 | + foreach($applist as $appname) |
|
| 978 | + { |
|
| 909 | 979 | importexport_helper_functions::load_defaults($appname); |
| 910 | 980 | } |
| 911 | 981 | return $this->index(); |
@@ -971,7 +1041,9 @@ discard block |
||
| 971 | 1041 | { |
| 972 | 1042 | Api\Config::save_value($key, $value, 'importexport'); |
| 973 | 1043 | } |
| 974 | - } elseif (isset($content['cancel'])) { |
|
| 1044 | + } |
|
| 1045 | + elseif (isset($content['cancel'])) |
|
| 1046 | + { |
|
| 975 | 1047 | $GLOBALS['egw']->redirect_link('/admin/index.php'); |
| 976 | 1048 | } |
| 977 | 1049 | |
@@ -985,7 +1057,10 @@ discard block |
||
| 985 | 1057 | unset($sel_options['import_charsets'][strtoupper($charset)]); |
| 986 | 1058 | } |
| 987 | 1059 | |
| 988 | - if(!$data['update']) $data['update'] = 'request'; |
|
| 1060 | + if(!$data['update']) |
|
| 1061 | + { |
|
| 1062 | + $data['update'] = 'request'; |
|
| 1063 | + } |
|
| 989 | 1064 | |
| 990 | 1065 | $GLOBALS['egw_info']['flags']['app_header'] = lang('Site configuration') . ' - ' . lang(self::_appname); |
| 991 | 1066 | $etpl = new etemplate(self::_appname.'.config'); |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $GLOBALS['egw_info']['flags']['currentapp'] = self::_appname; |
| 61 | 61 | |
| 62 | 62 | $this->etpl = new Etemplate(); |
| 63 | - $this->clock = Api\Html::image(self::_appname,'clock'); |
|
| 63 | + $this->clock = Api\Html::image(self::_appname, 'clock'); |
|
| 64 | 64 | $this->steps = array( |
| 65 | 65 | 'wizard_step10' => lang('Choose an application'), |
| 66 | 66 | 'wizard_step20' => lang('Choose a plugin'), |
@@ -77,18 +77,18 @@ discard block |
||
| 77 | 77 | * |
| 78 | 78 | * @param array $content=null |
| 79 | 79 | */ |
| 80 | - function index($content = null,$msg='') |
|
| 80 | + function index($content = null, $msg = '') |
|
| 81 | 81 | { |
| 82 | 82 | $filter = array('name' => '*'); |
| 83 | 83 | |
| 84 | - if($GLOBALS['egw_info']['user']['apps']['admin']) { |
|
| 84 | + if ($GLOBALS['egw_info']['user']['apps']['admin']) { |
|
| 85 | 85 | // Any public definition |
| 86 | - $filter[] = '(owner=0 OR owner IS NULL OR allowed_users IS NOT NULL OR owner = ' . $GLOBALS['egw_info']['user']['account_id'] . ')'; |
|
| 86 | + $filter[] = '(owner=0 OR owner IS NULL OR allowed_users IS NOT NULL OR owner = '.$GLOBALS['egw_info']['user']['account_id'].')'; |
|
| 87 | 87 | } else { |
| 88 | 88 | // Filter private definitions |
| 89 | 89 | $filter['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
| 90 | 90 | $config = Api\Config::read('phpgwapi'); |
| 91 | - if($config['export_limit'] == 'no' && !Api\Storage\Merge::is_export_limit_excepted()) { |
|
| 91 | + if ($config['export_limit'] == 'no' && !Api\Storage\Merge::is_export_limit_excepted()) { |
|
| 92 | 92 | $filter['type'] = 'import'; |
| 93 | 93 | } |
| 94 | 94 | } |
@@ -99,12 +99,12 @@ discard block |
||
| 99 | 99 | if (isset($content['nm']['rows']['delete'])) |
| 100 | 100 | { |
| 101 | 101 | $content['nm']['action'] = 'delete'; |
| 102 | - $content['nm']['selected'] = array_keys($content['nm']['rows']['delete'],'pressed'); |
|
| 102 | + $content['nm']['selected'] = array_keys($content['nm']['rows']['delete'], 'pressed'); |
|
| 103 | 103 | } |
| 104 | - elseif(($button = array_search('pressed',$content['nm']['rows'])) !== false) |
|
| 104 | + elseif (($button = array_search('pressed', $content['nm']['rows'])) !== false) |
|
| 105 | 105 | { |
| 106 | 106 | $selected = $content['nm']['rows']['selected']; |
| 107 | - if(count($selected) < 1 || !is_array($selected)) exit(); |
|
| 107 | + if (count($selected) < 1 || !is_array($selected)) exit(); |
|
| 108 | 108 | switch ($button) |
| 109 | 109 | { |
| 110 | 110 | case 'delete_selected' : |
@@ -126,54 +126,54 @@ discard block |
||
| 126 | 126 | else |
| 127 | 127 | { |
| 128 | 128 | // Action has an additional parameter |
| 129 | - if(in_array($content['nm']['action'], array('owner', 'allowed'))) |
|
| 129 | + if (in_array($content['nm']['action'], array('owner', 'allowed'))) |
|
| 130 | 130 | { |
| 131 | 131 | $action = $content['nm']['action']; |
| 132 | - if($content['nm']['action'] == 'allowed') |
|
| 132 | + if ($content['nm']['action'] == 'allowed') |
|
| 133 | 133 | { |
| 134 | 134 | $content['allowed'] = $content['allowed_popup']['allowed_private'] == 'true' ? null : ( |
| 135 | - $content['allowed_popup']['all_users']=='true' ? 'all' : implode(',',$content['allowed_popup']['allowed']) |
|
| 135 | + $content['allowed_popup']['all_users'] == 'true' ? 'all' : implode(',', $content['allowed_popup']['allowed']) |
|
| 136 | 136 | ); |
| 137 | 137 | } |
| 138 | 138 | else |
| 139 | 139 | { |
| 140 | 140 | $content['owner'] = $content['owner_popup']['owner']; |
| 141 | 141 | } |
| 142 | - if(is_array($content[$content['nm']['action']])) |
|
| 142 | + if (is_array($content[$content['nm']['action']])) |
|
| 143 | 143 | { |
| 144 | - $content[$content['nm']['action']] = implode(',',$content[$content['nm']['action']]); |
|
| 144 | + $content[$content['nm']['action']] = implode(',', $content[$content['nm']['action']]); |
|
| 145 | 145 | } |
| 146 | - $content['nm']['action'] .= '_' . $content[$action]; |
|
| 146 | + $content['nm']['action'] .= '_'.$content[$action]; |
|
| 147 | 147 | unset($content[$action]); |
| 148 | 148 | unset($content['allowed_popup']); |
| 149 | 149 | } |
| 150 | - if ($this->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'], |
|
| 151 | - $success,$failed,$action_msg,'index',$msg)) |
|
| 150 | + if ($this->action($content['nm']['action'], $content['nm']['selected'], $content['nm']['select_all'], |
|
| 151 | + $success, $failed, $action_msg, 'index', $msg)) |
|
| 152 | 152 | { |
| 153 | - $msg .= lang('%1 definition(s) %2',$success,$action_msg); |
|
| 153 | + $msg .= lang('%1 definition(s) %2', $success, $action_msg); |
|
| 154 | 154 | } |
| 155 | - elseif(empty($msg)) |
|
| 155 | + elseif (empty($msg)) |
|
| 156 | 156 | { |
| 157 | - $msg .= lang('%1 definition(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); |
|
| 157 | + $msg .= lang('%1 definition(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed); |
|
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - if(!is_array($content['nm'])) { |
|
| 163 | + if (!is_array($content['nm'])) { |
|
| 164 | 164 | $content['nm'] = array( |
| 165 | 165 | 'get_rows' => 'importexport.importexport_definitions_ui.get_rows', |
| 166 | 166 | 'no_cat' => true, |
| 167 | 167 | 'no_filter' => true, |
| 168 | 168 | 'no_filter2' => true, |
| 169 | - 'csv_fields' => false, // Disable CSV export, uses own export |
|
| 170 | - 'default_cols' => '!actions', // switch legacy actions column and row off by default |
|
| 169 | + 'csv_fields' => false, // Disable CSV export, uses own export |
|
| 170 | + 'default_cols' => '!actions', // switch legacy actions column and row off by default |
|
| 171 | 171 | 'row_id' => 'definition_id', |
| 172 | 172 | 'placeholder_actions' => array('add') |
| 173 | 173 | ); |
| 174 | - if($_GET['application']) $content['nm']['col_filter']['application'] = $_GET['application']; |
|
| 174 | + if ($_GET['application']) $content['nm']['col_filter']['application'] = $_GET['application']; |
|
| 175 | 175 | } |
| 176 | - if(Api\Cache::getSession('importexport', 'index')) |
|
| 176 | + if (Api\Cache::getSession('importexport', 'index')) |
|
| 177 | 177 | { |
| 178 | 178 | $content['nm'] = array_merge($content['nm'], Api\Cache::getSession('importexport', 'index')); |
| 179 | 179 | } |
@@ -190,14 +190,14 @@ discard block |
||
| 190 | 190 | ); |
| 191 | 191 | foreach ($this->plugins as $appname => $options) |
| 192 | 192 | { |
| 193 | - if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
| 193 | + if ($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
| 194 | 194 | $sel_options['application'][$appname] = lang($appname); |
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | - if($msg) $content['msg'] = $msg; |
|
| 197 | + if ($msg) $content['msg'] = $msg; |
|
| 198 | 198 | |
| 199 | 199 | $etpl = new Etemplate(self::_appname.'.definition_index'); |
| 200 | - return $etpl->exec( self::_appname.'.importexport_definitions_ui.index', $content, $sel_options, $readonlys, $preserv ); |
|
| 200 | + return $etpl->exec(self::_appname.'.importexport_definitions_ui.index', $content, $sel_options, $readonlys, $preserv); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | private function get_actions() { |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | ); |
| 287 | 287 | |
| 288 | 288 | // Unset admin actions |
| 289 | - if(!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 289 | + if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 290 | 290 | { |
| 291 | 291 | unset($actions['schedule']); |
| 292 | 292 | } |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | * @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup |
| 306 | 306 | * @return boolean true if all actions succeded, false otherwise |
| 307 | 307 | */ |
| 308 | - function action($action,$selected,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg) |
|
| 308 | + function action($action, $selected, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg) |
|
| 309 | 309 | { |
| 310 | 310 | //error_log( __METHOD__."('$action', ".array2string($selected).', '.array2string($use_all).",,, '$session_name')"); |
| 311 | 311 | if ($use_all) |
@@ -313,16 +313,16 @@ discard block |
||
| 313 | 313 | // get the whole selection |
| 314 | 314 | $old_query = $query = is_array($session_name) ? $session_name : Api\Cache::getSession('importexport', $session_name); |
| 315 | 315 | |
| 316 | - @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
| 317 | - $query['num_rows'] = -1; // all |
|
| 318 | - $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
| 319 | - $this->get_rows($query,$rows,$readonlys); |
|
| 316 | + @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
| 317 | + $query['num_rows'] = -1; // all |
|
| 318 | + $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
| 319 | + $this->get_rows($query, $rows, $readonlys); |
|
| 320 | 320 | |
| 321 | 321 | $selected = array(); |
| 322 | - foreach($rows as $row) { |
|
| 322 | + foreach ($rows as $row) { |
|
| 323 | 323 | $selected[] = $row['definition_id']; |
| 324 | 324 | } |
| 325 | - if(!is_array($session_name)) |
|
| 325 | + if (!is_array($session_name)) |
|
| 326 | 326 | { |
| 327 | 327 | // Restore old query |
| 328 | 328 | Api\Cache::setSession('importexport', $session_name, $old_query); |
@@ -334,18 +334,18 @@ discard block |
||
| 334 | 334 | |
| 335 | 335 | $bodefinitions = new importexport_definitions_bo(false, true); |
| 336 | 336 | |
| 337 | - switch($action) { |
|
| 337 | + switch ($action) { |
|
| 338 | 338 | case 'allowed': |
| 339 | 339 | // Field is allowed_users, popup doesn't like _ |
| 340 | 340 | $action = 'allowed_users'; |
| 341 | 341 | // Fall through |
| 342 | 342 | case 'owner': |
| 343 | - $action_msg = lang('changed'. ' ' . $action); |
|
| 344 | - foreach($selected as $id) { |
|
| 343 | + $action_msg = lang('changed'.' '.$action); |
|
| 344 | + foreach ($selected as $id) { |
|
| 345 | 345 | $definition = $bodefinitions->read((int)$id); |
| 346 | - if($definition['definition_id']) { |
|
| 346 | + if ($definition['definition_id']) { |
|
| 347 | 347 | // Prevent private with no owner |
| 348 | - if(!$definition['owner'] && !$settings) $definition['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
| 348 | + if (!$definition['owner'] && !$settings) $definition['owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
| 349 | 349 | |
| 350 | 350 | $definition[$action] = $settings; |
| 351 | 351 | $bodefinitions->save($definition); |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | $mime_type = ($GLOBALS['egw']->html->user_agent == 'msie' || $GLOBALS['egw']->html->user_agent == 'opera') ? |
| 364 | 364 | 'application/octetstream' : 'application/octet-stream'; |
| 365 | 365 | $name = 'importexport_definition.xml'; |
| 366 | - header('Content-Type: ' . $mime_type); |
|
| 366 | + header('Content-Type: '.$mime_type); |
|
| 367 | 367 | header('Content-Disposition: attachment; filename="'.$name.'"'); |
| 368 | 368 | echo $bodefinitions->export($selected); |
| 369 | 369 | exit(); |
@@ -372,16 +372,16 @@ discard block |
||
| 372 | 372 | case 'copy': |
| 373 | 373 | $action_msg = lang('copied'); |
| 374 | 374 | // Should only be one selected |
| 375 | - foreach($selected as $id) { |
|
| 375 | + foreach ($selected as $id) { |
|
| 376 | 376 | $definition = $bodefinitions->read((int)$id); |
| 377 | - if($definition['definition_id']) { |
|
| 377 | + if ($definition['definition_id']) { |
|
| 378 | 378 | unset($definition['definition_id']); |
| 379 | - $definition['name'] = $settings ? $settings : $definition['name'] . ' copy'; |
|
| 379 | + $definition['name'] = $settings ? $settings : $definition['name'].' copy'; |
|
| 380 | 380 | try { |
| 381 | 381 | $bodefinitions->save($definition); |
| 382 | 382 | } catch (Exception $e) { |
| 383 | 383 | try { |
| 384 | - $definition['name'] .= ' ' . $GLOBALS['egw_info']['user']['account_lid']; |
|
| 384 | + $definition['name'] .= ' '.$GLOBALS['egw_info']['user']['account_lid']; |
|
| 385 | 385 | $bodefinitions->save($definition); |
| 386 | 386 | } catch (Exception $ex) { |
| 387 | 387 | $failed++; |
@@ -396,16 +396,16 @@ discard block |
||
| 396 | 396 | case 'createexport': |
| 397 | 397 | $action_msg = lang('created'); |
| 398 | 398 | // Should only be one selected |
| 399 | - foreach($selected as $id) { |
|
| 399 | + foreach ($selected as $id) { |
|
| 400 | 400 | $definition = new importexport_definition($id); |
| 401 | 401 | try { |
| 402 | 402 | $export = $bodefinitions->export_from_import($definition); |
| 403 | 403 | $export->save(); |
| 404 | 404 | } catch (Exception $e) { |
| 405 | - if($export) |
|
| 405 | + if ($export) |
|
| 406 | 406 | { |
| 407 | 407 | try { |
| 408 | - $export->name = $export->name.' ' . $GLOBALS['egw_info']['user']['account_lid']; |
|
| 408 | + $export->name = $export->name.' '.$GLOBALS['egw_info']['user']['account_lid']; |
|
| 409 | 409 | $export->save(); |
| 410 | 410 | } catch (Exception $ex) { |
| 411 | 411 | $failed++; |
@@ -430,10 +430,10 @@ discard block |
||
| 430 | 430 | Api\Cache::setSession('importexport', 'index', $query); |
| 431 | 431 | |
| 432 | 432 | // Special handling for allowed users 'private' |
| 433 | - if($query['col_filter']['allowed_users'] == 'private') |
|
| 433 | + if ($query['col_filter']['allowed_users'] == 'private') |
|
| 434 | 434 | { |
| 435 | 435 | unset($query['col_filter']['allowed_users']); |
| 436 | - $query['col_filter'][] = 'allowed_users = ' . $GLOBALS['egw']->db->quote(',,'); |
|
| 436 | + $query['col_filter'][] = 'allowed_users = '.$GLOBALS['egw']->db->quote(',,'); |
|
| 437 | 437 | } |
| 438 | 438 | $bodefinitions = new importexport_definitions_bo($query['col_filter'], true); |
| 439 | 439 | // We don't care about readonlys for the UI |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | */ |
| 449 | 449 | function edit() |
| 450 | 450 | { |
| 451 | - if(!$_definition = $_GET['definition']) |
|
| 451 | + if (!$_definition = $_GET['definition']) |
|
| 452 | 452 | { |
| 453 | 453 | $content = array( |
| 454 | 454 | 'edit' => true, |
@@ -457,11 +457,11 @@ discard block |
||
| 457 | 457 | ); |
| 458 | 458 | |
| 459 | 459 | // Jump to a step |
| 460 | - if($_GET['step']) |
|
| 460 | + if ($_GET['step']) |
|
| 461 | 461 | { |
| 462 | 462 | $content['edit'] = false; |
| 463 | 463 | // Wizard will process previous step, then advance |
| 464 | - $content['step'] = $this->get_step($_GET['step'],-1); |
|
| 464 | + $content['step'] = $this->get_step($_GET['step'], -1); |
|
| 465 | 465 | $content['button']['next'] = 'pressed'; |
| 466 | 466 | $this->wizard($content); |
| 467 | 467 | } |
@@ -472,7 +472,7 @@ discard block |
||
| 472 | 472 | } |
| 473 | 473 | return; |
| 474 | 474 | } |
| 475 | - if(is_numeric($_GET['definition'])) |
|
| 475 | + if (is_numeric($_GET['definition'])) |
|
| 476 | 476 | { |
| 477 | 477 | $definition = (int)$_GET['definition']; |
| 478 | 478 | } |
@@ -484,31 +484,31 @@ discard block |
||
| 484 | 484 | $definition = $bodefinitions->read($definition); |
| 485 | 485 | $definition['edit'] = true; |
| 486 | 486 | // Jump to a step |
| 487 | - if($_GET['step']) |
|
| 487 | + if ($_GET['step']) |
|
| 488 | 488 | { |
| 489 | 489 | $definition['edit'] = false; |
| 490 | 490 | // Wizard will process previous step, then advance |
| 491 | - $definition['step'] = $_GET['step'];; |
|
| 491 | + $definition['step'] = $_GET['step']; ; |
|
| 492 | 492 | $definition['button'] = array('next' => 'pressed'); |
| 493 | 493 | } |
| 494 | 494 | $this->wizard($definition); |
| 495 | 495 | } |
| 496 | 496 | |
| 497 | - function wizard($content = null, $msg='') |
|
| 497 | + function wizard($content = null, $msg = '') |
|
| 498 | 498 | { |
| 499 | 499 | $this->etpl->read('importexport.wizardbox'); |
| 500 | 500 | |
| 501 | - if(is_array($content) &&! $content['edit']) |
|
| 501 | + if (is_array($content) && !$content['edit']) |
|
| 502 | 502 | { |
| 503 | - if(self::_debug) error_log('importexport.wizard->$content '. print_r($content,true)); |
|
| 503 | + if (self::_debug) error_log('importexport.wizard->$content '.print_r($content, true)); |
|
| 504 | 504 | //foreach($content as $key => $val) error_log(" $key : ".array2string($val)); |
| 505 | 505 | // fetch plugin object |
| 506 | - if($content['plugin'] && $content['application']) |
|
| 506 | + if ($content['plugin'] && $content['application']) |
|
| 507 | 507 | { |
| 508 | - $wizard_name = $content['application'] . '_wizard_' . str_replace($content['application'] . '_', '', $content['plugin']); |
|
| 508 | + $wizard_name = $content['application'].'_wizard_'.str_replace($content['application'].'_', '', $content['plugin']); |
|
| 509 | 509 | |
| 510 | 510 | // we need to deal with the wizard object if exists |
| 511 | - if (file_exists(EGW_SERVER_ROOT . '/'. $content['application']."/inc/class.$wizard_name.inc.php")) |
|
| 511 | + if (file_exists(EGW_SERVER_ROOT.'/'.$content['application']."/inc/class.$wizard_name.inc.php")) |
|
| 512 | 512 | { |
| 513 | 513 | $wizard_plugin = $wizard_name; |
| 514 | 514 | } |
@@ -517,38 +517,38 @@ discard block |
||
| 517 | 517 | $wizard_plugin = $content['plugin']; |
| 518 | 518 | } |
| 519 | 519 | // App translations |
| 520 | - if($content['application']) Api\Translation::add_app($content['application']); |
|
| 520 | + if ($content['application']) Api\Translation::add_app($content['application']); |
|
| 521 | 521 | |
| 522 | 522 | $this->plugin = is_object($GLOBALS['egw']->$wizard_plugin) ? $GLOBALS['egw']->$wizard_plugin : new $wizard_plugin; |
| 523 | 523 | |
| 524 | 524 | // Global object needs to be the same, or references to plugin don't work |
| 525 | - if(!is_object($GLOBALS['egw']->importexport_definitions_ui) || $GLOBALS['egw']->importexport_definitions_ui !== $this) |
|
| 526 | - $GLOBALS['egw']->importexport_definitions_ui =& $this; |
|
| 525 | + if (!is_object($GLOBALS['egw']->importexport_definitions_ui) || $GLOBALS['egw']->importexport_definitions_ui !== $this) |
|
| 526 | + $GLOBALS['egw']->importexport_definitions_ui = & $this; |
|
| 527 | 527 | } |
| 528 | 528 | // deal with buttons even if we are not on ajax |
| 529 | - if(isset($content['button']) && array_search('pressed',$content['button']) === false && count($content['button']) == 1) |
|
| 529 | + if (isset($content['button']) && array_search('pressed', $content['button']) === false && count($content['button']) == 1) |
|
| 530 | 530 | { |
| 531 | 531 | $button = array_keys($content['button']); |
| 532 | 532 | $content['button'] = array($button[0] => 'pressed'); |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | // post process submitted step |
| 536 | - if($content['step']) |
|
| 536 | + if ($content['step']) |
|
| 537 | 537 | { |
| 538 | - if(!$this->can_edit($content)) |
|
| 538 | + if (!$this->can_edit($content)) |
|
| 539 | 539 | { |
| 540 | 540 | // Each step changes definition, reload it |
| 541 | 541 | $bodefinitions = new importexport_definitions_bo(); |
| 542 | 542 | $definition = $bodefinitions->read($content); |
| 543 | 543 | $content = $definition + array('step' => $content['step'], 'button' => $content['button']); |
| 544 | 544 | } |
| 545 | - if(!key_exists($content['step'],$this->steps)) |
|
| 545 | + if (!key_exists($content['step'], $this->steps)) |
|
| 546 | 546 | { |
| 547 | - $next_step = $this->plugin->{$content['step']}($content,$sel_options,$readonlys,$preserv); |
|
| 547 | + $next_step = $this->plugin->{$content['step']}($content, $sel_options, $readonlys, $preserv); |
|
| 548 | 548 | } |
| 549 | 549 | else |
| 550 | 550 | { |
| 551 | - $next_step = $this->{$content['step']}($content,$sel_options,$readonlys,$preserv); |
|
| 551 | + $next_step = $this->{$content['step']}($content, $sel_options, $readonlys, $preserv); |
|
| 552 | 552 | } |
| 553 | 553 | } |
| 554 | 554 | else |
@@ -560,23 +560,23 @@ discard block |
||
| 560 | 560 | $sel_options = $readonlys = $preserv = array(); |
| 561 | 561 | |
| 562 | 562 | // Disable finish button if required fields are missing |
| 563 | - if(!$content['name'] || !$content['type'] || !$content['plugin']) |
|
| 563 | + if (!$content['name'] || !$content['type'] || !$content['plugin']) |
|
| 564 | 564 | { |
| 565 | 565 | $readonlys['button[finish]'] = true; |
| 566 | 566 | } |
| 567 | 567 | do |
| 568 | 568 | { |
| 569 | - if(!key_exists($next_step,$this->steps)) |
|
| 569 | + if (!key_exists($next_step, $this->steps)) |
|
| 570 | 570 | { |
| 571 | - $this->wizard_content_template = $this->plugin->$next_step($content,$sel_options,$readonlys,$preserv); |
|
| 571 | + $this->wizard_content_template = $this->plugin->$next_step($content, $sel_options, $readonlys, $preserv); |
|
| 572 | 572 | } |
| 573 | 573 | else |
| 574 | 574 | { |
| 575 | - $this->wizard_content_template = $this->$next_step($content,$sel_options,$readonlys,$preserv); |
|
| 575 | + $this->wizard_content_template = $this->$next_step($content, $sel_options, $readonlys, $preserv); |
|
| 576 | 576 | } |
| 577 | - if($this->wizard_content_template == self::SKIP) |
|
| 577 | + if ($this->wizard_content_template == self::SKIP) |
|
| 578 | 578 | { |
| 579 | - if(!key_exists($content['step'],$this->steps)) |
|
| 579 | + if (!key_exists($content['step'], $this->steps)) |
|
| 580 | 580 | { |
| 581 | 581 | $next_step = $this->plugin->{$content['step']}($content); |
| 582 | 582 | } |
@@ -585,9 +585,9 @@ discard block |
||
| 585 | 585 | $next_step = $this->{$content['step']}($content); |
| 586 | 586 | } |
| 587 | 587 | } |
| 588 | - } while($this->wizard_content_template == self::SKIP); |
|
| 588 | + } while ($this->wizard_content_template == self::SKIP); |
|
| 589 | 589 | |
| 590 | - if(!$this->can_edit($content)) |
|
| 590 | + if (!$this->can_edit($content)) |
|
| 591 | 591 | { |
| 592 | 592 | $readonlys[$this->wizard_content_template] = true; |
| 593 | 593 | $preserve = $content; |
@@ -596,21 +596,21 @@ discard block |
||
| 596 | 596 | |
| 597 | 597 | unset($content['button']); |
| 598 | 598 | $content['wizard_content'] = $this->wizard_content_template; |
| 599 | - $this->etpl->exec(self::_appname.'.importexport_definitions_ui.wizard',$content,$sel_options,$readonlys,$preserv,2); |
|
| 599 | + $this->etpl->exec(self::_appname.'.importexport_definitions_ui.wizard', $content, $sel_options, $readonlys, $preserv, 2); |
|
| 600 | 600 | } |
| 601 | 601 | else |
| 602 | 602 | { |
| 603 | 603 | // initial content |
| 604 | 604 | $sel_options = $readonlys = $preserv = array(); |
| 605 | 605 | $readonlys['button[previous]'] = true; |
| 606 | - if($content['edit']) |
|
| 606 | + if ($content['edit']) |
|
| 607 | 607 | { |
| 608 | 608 | unset ($content['edit']); |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | $this->wizard_content_template = $this->wizard_step10($content, $sel_options, $readonlys, $preserv); |
| 612 | 612 | |
| 613 | - if(!$this->can_edit($content)) |
|
| 613 | + if (!$this->can_edit($content)) |
|
| 614 | 614 | { |
| 615 | 615 | $readonlys[$this->wizard_content_template] = true; |
| 616 | 616 | $preserve = $content; |
@@ -618,7 +618,7 @@ discard block |
||
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | $content['wizard_content'] = $this->wizard_content_template; |
| 621 | - $this->etpl->exec(self::_appname.'.importexport_definitions_ui.wizard',$content,$sel_options,$readonlys,$preserv,2); |
|
| 621 | + $this->etpl->exec(self::_appname.'.importexport_definitions_ui.wizard', $content, $sel_options, $readonlys, $preserv, 2); |
|
| 622 | 622 | } |
| 623 | 623 | } |
| 624 | 624 | |
@@ -629,31 +629,31 @@ discard block |
||
| 629 | 629 | * @param int $step_width |
| 630 | 630 | * @return string containing function name of next step |
| 631 | 631 | */ |
| 632 | - function get_step ($curr_step, $step_width) |
|
| 632 | + function get_step($curr_step, $step_width) |
|
| 633 | 633 | { |
| 634 | 634 | /*if($content['plugin'] && $content['application']&& !is_object($this->plugin)) |
| 635 | 635 | { |
| 636 | 636 | $plugin_definition = $this->plugins[$content['application']][$content['plugin']]['definition']; |
| 637 | 637 | if($plugin_definition) $this->plugin = new $plugin_definition; |
| 638 | 638 | }*/ |
| 639 | - if(is_object($this->plugin) && is_array($this->plugin->steps)) |
|
| 639 | + if (is_object($this->plugin) && is_array($this->plugin->steps)) |
|
| 640 | 640 | { |
| 641 | - $steps = array_merge($this->steps,$this->plugin->steps); |
|
| 642 | - $steps = array_flip($steps); asort($steps); $steps = array_flip($steps); |
|
| 641 | + $steps = array_merge($this->steps, $this->plugin->steps); |
|
| 642 | + $steps = array_flip($steps); asort($steps); $steps = array_flip($steps); |
|
| 643 | 643 | } |
| 644 | 644 | else |
| 645 | 645 | { |
| 646 | 646 | $steps = $this->steps; |
| 647 | 647 | } |
| 648 | 648 | $step_keys = array_keys($steps); |
| 649 | - $nn = array_search($curr_step,$step_keys)+(int)$step_width; |
|
| 650 | - return (key_exists($nn,$step_keys)) ? $step_keys[$nn] : 'wizard_finish'; |
|
| 649 | + $nn = array_search($curr_step, $step_keys) + (int)$step_width; |
|
| 650 | + return (key_exists($nn, $step_keys)) ? $step_keys[$nn] : 'wizard_finish'; |
|
| 651 | 651 | } |
| 652 | 652 | |
| 653 | 653 | |
| 654 | 654 | function wizard_step10(&$content, &$sel_options, &$readonlys, &$preserv) |
| 655 | 655 | { |
| 656 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step10->$content '.print_r($content,true)); |
|
| 656 | + if (self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step10->$content '.print_r($content, true)); |
|
| 657 | 657 | |
| 658 | 658 | // return from step10 |
| 659 | 659 | if ($content['step'] == 'wizard_step10') |
@@ -661,11 +661,11 @@ discard block |
||
| 661 | 661 | switch (array_search('pressed', $content['button'])) |
| 662 | 662 | { |
| 663 | 663 | case 'next': |
| 664 | - return $this->get_step($content['step'],1); |
|
| 664 | + return $this->get_step($content['step'], 1); |
|
| 665 | 665 | case 'finish': |
| 666 | 666 | return 'wizard_finish'; |
| 667 | 667 | default : |
| 668 | - return $this->wizard_step10($content,$sel_options,$readonlys,$preserv); |
|
| 668 | + return $this->wizard_step10($content, $sel_options, $readonlys, $preserv); |
|
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | } |
@@ -675,7 +675,7 @@ discard block |
||
| 675 | 675 | $content['text'] = $this->steps['wizard_step10']; |
| 676 | 676 | foreach ($this->plugins as $appname => $options) |
| 677 | 677 | { |
| 678 | - if($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
| 678 | + if ($GLOBALS['egw_info']['user']['apps'][$appname] || $GLOBALS['egw_info']['user']['apps']['admin']) { |
|
| 679 | 679 | $sel_options['application'][$appname] = lang($appname); |
| 680 | 680 | } |
| 681 | 681 | } |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | // get plugin |
| 692 | 692 | function wizard_step20(&$content, &$sel_options, &$readonlys, &$preserv) |
| 693 | 693 | { |
| 694 | - if(self::_debug) error_log('importexport.' . get_class($this) . '::wizard_step20->$content '.print_r($content,true)); |
|
| 694 | + if (self::_debug) error_log('importexport.'.get_class($this).'::wizard_step20->$content '.print_r($content, true)); |
|
| 695 | 695 | |
| 696 | 696 | // return from step20 |
| 697 | 697 | if ($content['step'] == 'wizard_step20') |
@@ -700,21 +700,21 @@ discard block |
||
| 700 | 700 | { |
| 701 | 701 | case 'next': |
| 702 | 702 | // There's no real reason the plugin has to come from any of these, as long as it has a $steps variable |
| 703 | - if($this->plugin instanceof importexport_iface_import_plugin || $this->plugin instanceof importexport_wizard_basic_import_csv || strpos(get_class($this->plugin), 'import') !== false) { |
|
| 703 | + if ($this->plugin instanceof importexport_iface_import_plugin || $this->plugin instanceof importexport_wizard_basic_import_csv || strpos(get_class($this->plugin), 'import') !== false) { |
|
| 704 | 704 | $content['type'] = 'import'; |
| 705 | - } elseif($this->plugin instanceof importexport_iface_export_plugin || $this->plugin instanceof importexport_wizard_basic_export_csv || strpos(get_class($this->plugin),'export') !== false) { |
|
| 705 | + } elseif ($this->plugin instanceof importexport_iface_export_plugin || $this->plugin instanceof importexport_wizard_basic_export_csv || strpos(get_class($this->plugin), 'export') !== false) { |
|
| 706 | 706 | $content['type'] = 'export'; |
| 707 | 707 | } else { |
| 708 | 708 | throw new Api\Exception('Invalid plugin'); |
| 709 | 709 | } |
| 710 | - return $this->get_step($content['step'],1); |
|
| 710 | + return $this->get_step($content['step'], 1); |
|
| 711 | 711 | case 'previous' : |
| 712 | 712 | $readonlys['button[previous]'] = true; |
| 713 | - return $this->get_step($content['step'],-1); |
|
| 713 | + return $this->get_step($content['step'], -1); |
|
| 714 | 714 | case 'finish': |
| 715 | 715 | return 'wizard_finish'; |
| 716 | 716 | default : |
| 717 | - return $this->wizard_step20($content,$sel_options,$readonlys,$preserv); |
|
| 717 | + return $this->wizard_step20($content, $sel_options, $readonlys, $preserv); |
|
| 718 | 718 | } |
| 719 | 719 | } |
| 720 | 720 | // init step20 |
@@ -723,8 +723,8 @@ discard block |
||
| 723 | 723 | $content['text'] = $this->steps['wizard_step20']; |
| 724 | 724 | $config = Api\Config::read('phpgwapi'); |
| 725 | 725 | foreach ($this->plugins[$content['application']] as $type => $plugins) { |
| 726 | - if($config['export_limit'] == 'no' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $type == 'export') continue; |
|
| 727 | - foreach($plugins as $plugin => $name) { |
|
| 726 | + if ($config['export_limit'] == 'no' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $type == 'export') continue; |
|
| 727 | + foreach ($plugins as $plugin => $name) { |
|
| 728 | 728 | $sel_options['plugin'][$plugin] = $name; |
| 729 | 729 | } |
| 730 | 730 | } |
@@ -740,15 +740,15 @@ discard block |
||
| 740 | 740 | // name |
| 741 | 741 | function wizard_step21(&$content, &$sel_options, &$readonlys, &$preserv) |
| 742 | 742 | { |
| 743 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step21->$content '.print_r($content,true)); |
|
| 743 | + if (self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step21->$content '.print_r($content, true)); |
|
| 744 | 744 | |
| 745 | 745 | // Check for duplicate name |
| 746 | 746 | $duplicate = isset($content['duplicate_error']); |
| 747 | - if($content['name'] && !$duplicate) |
|
| 747 | + if ($content['name'] && !$duplicate) |
|
| 748 | 748 | { |
| 749 | 749 | try { |
| 750 | 750 | $check_definition = new importexport_definition($content['name']); |
| 751 | - if($check_definition && $check_definition->definition_id && $check_definition->definition_id != $content['definition_id']) |
|
| 751 | + if ($check_definition && $check_definition->definition_id && $check_definition->definition_id != $content['definition_id']) |
|
| 752 | 752 | { |
| 753 | 753 | throw new Exception('Already exists'); |
| 754 | 754 | } |
@@ -758,21 +758,21 @@ discard block |
||
| 758 | 758 | |
| 759 | 759 | // Try some suggestions |
| 760 | 760 | $suggestions = array( |
| 761 | - $content['name'] .'-'. $GLOBALS['egw_info']['user']['account_lid'], |
|
| 762 | - $content['name'] .'-'. $GLOBALS['egw_info']['user']['account_id'], |
|
| 763 | - $content['name'] .'-'. Api\DateTime::to('now', true), |
|
| 761 | + $content['name'].'-'.$GLOBALS['egw_info']['user']['account_lid'], |
|
| 762 | + $content['name'].'-'.$GLOBALS['egw_info']['user']['account_id'], |
|
| 763 | + $content['name'].'-'.Api\DateTime::to('now', true), |
|
| 764 | 764 | //$content['name'] .'-'. rand(0,100), |
| 765 | 765 | ); |
| 766 | - foreach($suggestions as $key => $suggestion) { |
|
| 766 | + foreach ($suggestions as $key => $suggestion) { |
|
| 767 | 767 | $sug_definition = new importexport_definition($suggestion); |
| 768 | - if($sug_definition->definition_id) { |
|
| 768 | + if ($sug_definition->definition_id) { |
|
| 769 | 769 | unset($suggestions[$key]); |
| 770 | 770 | } |
| 771 | 771 | } |
| 772 | - if($suggestions) { |
|
| 773 | - $content['duplicate_error'] .= ' '. lang('Try')." \n" . implode("\n", $suggestions); |
|
| 772 | + if ($suggestions) { |
|
| 773 | + $content['duplicate_error'] .= ' '.lang('Try')." \n".implode("\n", $suggestions); |
|
| 774 | 774 | } |
| 775 | - return $this->get_step($content['step'],0); |
|
| 775 | + return $this->get_step($content['step'], 0); |
|
| 776 | 776 | } |
| 777 | 777 | } |
| 778 | 778 | |
@@ -782,19 +782,19 @@ discard block |
||
| 782 | 782 | switch (array_search('pressed', $content['button'])) |
| 783 | 783 | { |
| 784 | 784 | case 'next': |
| 785 | - return $this->get_step($content['step'],1); |
|
| 785 | + return $this->get_step($content['step'], 1); |
|
| 786 | 786 | case 'previous' : |
| 787 | - return $this->get_step($content['step'],-1); |
|
| 787 | + return $this->get_step($content['step'], -1); |
|
| 788 | 788 | case 'finish': |
| 789 | 789 | return 'wizard_finish'; |
| 790 | 790 | default : |
| 791 | - return $this->wizard_step21($content,$sel_options,$readonlys,$preserv); |
|
| 791 | + return $this->wizard_step21($content, $sel_options, $readonlys, $preserv); |
|
| 792 | 792 | } |
| 793 | 793 | } |
| 794 | 794 | // init step21 |
| 795 | 795 | else |
| 796 | 796 | { |
| 797 | - $content['text'] = $this->steps['wizard_step21'] . ($duplicate ? "\n".$content['duplicate_error'] : ''); |
|
| 797 | + $content['text'] = $this->steps['wizard_step21'].($duplicate ? "\n".$content['duplicate_error'] : ''); |
|
| 798 | 798 | $content['step'] = 'wizard_step21'; |
| 799 | 799 | unset($content['duplicate_error']); |
| 800 | 800 | $preserv = $content; |
@@ -806,17 +806,16 @@ discard block |
||
| 806 | 806 | // allowed users |
| 807 | 807 | function wizard_step90(&$content, &$sel_options, &$readonlys, &$preserv) |
| 808 | 808 | { |
| 809 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step90->$content '.print_r($content,true)); |
|
| 809 | + if (self::_debug) error_log('importexport.importexport_definitions_ui::wizard_step90->$content '.print_r($content, true)); |
|
| 810 | 810 | |
| 811 | 811 | // return from step90 |
| 812 | 812 | if ($content['step'] == 'wizard_step90') |
| 813 | 813 | { |
| 814 | - if($this->can_edit($content)) |
|
| 814 | + if ($this->can_edit($content)) |
|
| 815 | 815 | { |
| 816 | - $content['owner'] = $content['just_me'] || !$GLOBALS['egw']->acl->check('share_definitions', Acl::READ,'importexport') ? |
|
| 817 | - ($content['owner'] ? $content['owner'] : $GLOBALS['egw_info']['user']['account_id']) : |
|
| 818 | - null; |
|
| 819 | - $content['allowed_users'] = $content['just_me'] ? '' : ($content['all_users'] ? 'all' : implode(',',$content['allowed_users'])); |
|
| 816 | + $content['owner'] = $content['just_me'] || !$GLOBALS['egw']->acl->check('share_definitions', Acl::READ, 'importexport') ? |
|
| 817 | + ($content['owner'] ? $content['owner'] : $GLOBALS['egw_info']['user']['account_id']) : null; |
|
| 818 | + $content['allowed_users'] = $content['just_me'] ? '' : ($content['all_users'] ? 'all' : implode(',', $content['allowed_users'])); |
|
| 820 | 819 | unset($content['just_me']); |
| 821 | 820 | } |
| 822 | 821 | |
@@ -824,12 +823,12 @@ discard block |
||
| 824 | 823 | switch (array_search('pressed', $content['button'])) |
| 825 | 824 | { |
| 826 | 825 | case 'previous' : |
| 827 | - return $this->get_step($content['step'],-1); |
|
| 826 | + return $this->get_step($content['step'], -1); |
|
| 828 | 827 | case 'next': |
| 829 | 828 | case 'finish': |
| 830 | 829 | return 'wizard_finish'; |
| 831 | 830 | default : |
| 832 | - return $this->wizard_step90($content,$sel_options,$readonlys,$preserv); |
|
| 831 | + return $this->wizard_step90($content, $sel_options, $readonlys, $preserv); |
|
| 833 | 832 | } |
| 834 | 833 | } |
| 835 | 834 | // init step90 |
@@ -840,10 +839,10 @@ discard block |
||
| 840 | 839 | $preserv = $content; |
| 841 | 840 | |
| 842 | 841 | // Set owner for non-admins |
| 843 | - $content['just_me'] = ((!$content['allowed_users'] || !$content['allowed_users'][0] && count($content['allowed_users']) ==1) && $content['owner']); |
|
| 844 | - $content['all_users'] = is_array($content['allowed_users']) && array_key_exists('0',$content['allowed_users']) && $content['allowed_users'][0] == 'all' || |
|
| 842 | + $content['just_me'] = ((!$content['allowed_users'] || !$content['allowed_users'][0] && count($content['allowed_users']) == 1) && $content['owner']); |
|
| 843 | + $content['all_users'] = is_array($content['allowed_users']) && array_key_exists('0', $content['allowed_users']) && $content['allowed_users'][0] == 'all' || |
|
| 845 | 844 | $content['allowed_users'] == 'all'; |
| 846 | - if(!$GLOBALS['egw']->acl->check('share_definition', Acl::READ, 'importexport') && !$GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 845 | + if (!$GLOBALS['egw']->acl->check('share_definition', Acl::READ, 'importexport') && !$GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 847 | 846 | { |
| 848 | 847 | $content['allowed_users'] = array(); |
| 849 | 848 | $readonlys['allowed_users'] = true; |
@@ -859,11 +858,11 @@ discard block |
||
| 859 | 858 | ) |
| 860 | 859 | ); |
| 861 | 860 | // Hide 'just me' checkbox, users get confused by read-only |
| 862 | - if($readonlys['just_me'] || !$this->can_edit($content)) |
|
| 861 | + if ($readonlys['just_me'] || !$this->can_edit($content)) |
|
| 863 | 862 | { |
| 864 | 863 | $content['no_just_me'] = true; |
| 865 | 864 | } |
| 866 | - if($readonlys['all_users'] || !$this->can_edit($content)) |
|
| 865 | + if ($readonlys['all_users'] || !$this->can_edit($content)) |
|
| 867 | 866 | { |
| 868 | 867 | $content['no_all_users'] = true; |
| 869 | 868 | } |
@@ -876,7 +875,7 @@ discard block |
||
| 876 | 875 | |
| 877 | 876 | function wizard_finish(&$content) |
| 878 | 877 | { |
| 879 | - if(self::_debug) error_log('importexport.importexport_definitions_ui::wizard_finish->$content '.print_r($content,true)); |
|
| 878 | + if (self::_debug) error_log('importexport.importexport_definitions_ui::wizard_finish->$content '.print_r($content, true)); |
|
| 880 | 879 | // Take out some UI leavings |
| 881 | 880 | unset($content['text']); |
| 882 | 881 | unset($content['step']); |
@@ -886,26 +885,26 @@ discard block |
||
| 886 | 885 | $bodefinitions->save($content); |
| 887 | 886 | // This message is displayed if browser cant close window |
| 888 | 887 | $content['msg'] = lang('ImportExport wizard finished successfully!'); |
| 889 | - Framework::refresh_opener('','importexport'); |
|
| 888 | + Framework::refresh_opener('', 'importexport'); |
|
| 890 | 889 | Framework::window_close(); |
| 891 | 890 | return 'importexport.wizard_close'; |
| 892 | 891 | } |
| 893 | 892 | |
| 894 | - function import_definition($content='') |
|
| 893 | + function import_definition($content = '') |
|
| 895 | 894 | { |
| 896 | 895 | $bodefinitions = new importexport_definitions_bo(); |
| 897 | 896 | if (is_array($content)) |
| 898 | 897 | { |
| 899 | - if($content['import_file']['tmp_name']) |
|
| 898 | + if ($content['import_file']['tmp_name']) |
|
| 900 | 899 | { |
| 901 | 900 | $result = $bodefinitions->import($content['import_file']['tmp_name']); |
| 902 | - $msg = lang('%1 definitions %2', count($result), lang('imported')) ."\n". implode("\n", array_keys($result)); |
|
| 901 | + $msg = lang('%1 definitions %2', count($result), lang('imported'))."\n".implode("\n", array_keys($result)); |
|
| 903 | 902 | return $this->index(null, $msg); |
| 904 | 903 | } |
| 905 | - if($content['update']) |
|
| 904 | + if ($content['update']) |
|
| 906 | 905 | { |
| 907 | 906 | $applist = importexport_helper_functions::get_apps('all', true); |
| 908 | - foreach($applist as $appname) { |
|
| 907 | + foreach ($applist as $appname) { |
|
| 909 | 908 | importexport_helper_functions::load_defaults($appname); |
| 910 | 909 | } |
| 911 | 910 | return $this->index(); |
@@ -915,7 +914,7 @@ discard block |
||
| 915 | 914 | { |
| 916 | 915 | $content = array(); |
| 917 | 916 | $etpl = new etemplate(self::_appname.'.import_definition'); |
| 918 | - return $etpl->exec(self::_appname.'.importexport_definitions_ui.import_definition',$content,array(),$readonlys,$preserv); |
|
| 917 | + return $etpl->exec(self::_appname.'.importexport_definitions_ui.import_definition', $content, array(), $readonlys, $preserv); |
|
| 919 | 918 | } |
| 920 | 919 | } |
| 921 | 920 | |
@@ -925,17 +924,17 @@ discard block |
||
| 925 | 924 | */ |
| 926 | 925 | protected function can_edit(Array $definition) |
| 927 | 926 | { |
| 928 | - if($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id']) |
|
| 927 | + if ($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id']) |
|
| 929 | 928 | { |
| 930 | 929 | // Definition belongs to user |
| 931 | 930 | return true; |
| 932 | 931 | } |
| 933 | - elseif($definition['definition_id'] && !$definition['owner'] && $GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 932 | + elseif ($definition['definition_id'] && !$definition['owner'] && $GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 934 | 933 | { |
| 935 | 934 | // Definition is unowned, and user is an admin |
| 936 | 935 | return true; |
| 937 | 936 | } |
| 938 | - elseif(!$definition['definition_id']) |
|
| 937 | + elseif (!$definition['definition_id']) |
|
| 939 | 938 | { |
| 940 | 939 | // Definition is in-progress, not saved yet |
| 941 | 940 | return true; |
@@ -948,26 +947,26 @@ discard block |
||
| 948 | 947 | */ |
| 949 | 948 | public function site_config($content = array()) |
| 950 | 949 | { |
| 951 | - if(!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 950 | + if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
|
| 952 | 951 | { |
| 953 | 952 | Egw::redirect_link('/home'); |
| 954 | 953 | } |
| 955 | - if($content['save']) |
|
| 954 | + if ($content['save']) |
|
| 956 | 955 | { |
| 957 | 956 | unset($content['save']); |
| 958 | 957 | |
| 959 | 958 | // ACL |
| 960 | - $GLOBALS['egw']->acl->delete_repository(self::_appname, 'definition',false); |
|
| 961 | - $GLOBALS['egw']->acl->delete_repository(self::_appname, 'share_definition',false); |
|
| 959 | + $GLOBALS['egw']->acl->delete_repository(self::_appname, 'definition', false); |
|
| 960 | + $GLOBALS['egw']->acl->delete_repository(self::_appname, 'share_definition', false); |
|
| 962 | 961 | |
| 963 | - foreach($content['share_definition'] as $group) |
|
| 962 | + foreach ($content['share_definition'] as $group) |
|
| 964 | 963 | { |
| 965 | - $GLOBALS['egw']->acl->add_repository(self::_appname, 'share_definition', $group,Acl::READ); |
|
| 964 | + $GLOBALS['egw']->acl->add_repository(self::_appname, 'share_definition', $group, Acl::READ); |
|
| 966 | 965 | } |
| 967 | 966 | unset($content['share_definition']); |
| 968 | 967 | |
| 969 | 968 | // Other Api\Config |
| 970 | - foreach($content as $key=>$value) |
|
| 969 | + foreach ($content as $key=>$value) |
|
| 971 | 970 | { |
| 972 | 971 | Api\Config::save_value($key, $value, 'importexport'); |
| 973 | 972 | } |
@@ -977,18 +976,18 @@ discard block |
||
| 977 | 976 | |
| 978 | 977 | $data = Api\Config::read(self::_appname); |
| 979 | 978 | $data['share_definition'] = $GLOBALS['egw']->acl->get_ids_for_location('share_definition', Acl::READ, self::_appname); |
| 980 | - $sel_options['import_charsets'] = array_combine(mb_list_encodings(),mb_list_encodings()); |
|
| 979 | + $sel_options['import_charsets'] = array_combine(mb_list_encodings(), mb_list_encodings()); |
|
| 981 | 980 | |
| 982 | 981 | // Remove 'standard' encodings to prevent doubles |
| 983 | - foreach(Api\Translation::get_installed_charsets() as $charset => $label) |
|
| 982 | + foreach (Api\Translation::get_installed_charsets() as $charset => $label) |
|
| 984 | 983 | { |
| 985 | 984 | unset($sel_options['import_charsets'][strtoupper($charset)]); |
| 986 | 985 | } |
| 987 | 986 | |
| 988 | - if(!$data['update']) $data['update'] = 'request'; |
|
| 987 | + if (!$data['update']) $data['update'] = 'request'; |
|
| 989 | 988 | |
| 990 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('Site configuration') . ' - ' . lang(self::_appname); |
|
| 989 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('Site configuration').' - '.lang(self::_appname); |
|
| 991 | 990 | $etpl = new etemplate(self::_appname.'.config'); |
| 992 | - $etpl->exec(self::_appname.'.importexport_definitions_ui.site_config',$data,$sel_options,$readonlys,$preserv); |
|
| 991 | + $etpl->exec(self::_appname.'.importexport_definitions_ui.site_config', $data, $sel_options, $readonlys, $preserv); |
|
| 993 | 992 | } |
| 994 | 993 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * |
| 97 | 97 | * @param stram $_stream resource where records are exported to. |
| 98 | 98 | * @param array _options options for specific backends |
| 99 | - * @return bool |
|
| 99 | + * @return boolean|null |
|
| 100 | 100 | */ |
| 101 | 101 | public function __construct( $_stream, array $_options ) { |
| 102 | 102 | if (!is_object($GLOBALS['egw']->translation)) { |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | * exports a record into resource of handle |
| 152 | 152 | * |
| 153 | 153 | * @param importexport_iface_egw_record record |
| 154 | - * @return bool |
|
| 154 | + * @return boolean|null |
|
| 155 | 155 | */ |
| 156 | 156 | public function export_record( importexport_iface_egw_record $_record ) { |
| 157 | 157 | $this->record = $_record; |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | * |
| 285 | 285 | * Uses the static variable $types to convert various datatypes. |
| 286 | 286 | * |
| 287 | - * @param record Record to be converted |
|
| 287 | + * @param record importexport_iface_egw_record to be converted |
|
| 288 | 288 | * @parem fields List of field types => field names to be converted |
| 289 | 289 | * @param appname Current appname if you want to do custom fields too |
| 290 | 290 | */ |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | * @parem fields List of field types => field names to be converted |
| 289 | 289 | * @param appname Current appname if you want to do custom fields too |
| 290 | 290 | */ |
| 291 | - public static function convert(importexport_iface_egw_record &$record, Array $fields = array(), $appname = null, $selects = array()) { |
|
| 291 | + public static function convert(importexport_iface_egw_record &$record, array $fields = array(), $appname = null, $selects = array()) { |
|
| 292 | 292 | if($appname) { |
| 293 | 293 | if(!self::$cf_parse_cache[$appname]) { |
| 294 | 294 | $c_fields = self::convert_parse_custom_fields($appname, $selects, $links, $methods); |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | * @param char $delimiter |
| 453 | 453 | * @param char $enclosure |
| 454 | 454 | */ |
| 455 | - protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure){ |
|
| 455 | + protected function fputcsv($filePointer, array $dataArray, $delimiter, $enclosure){ |
|
| 456 | 456 | $string = ""; |
| 457 | 457 | $writeDelimiter = false; |
| 458 | 458 | foreach($dataArray as $dataElement) { |
@@ -98,22 +98,32 @@ discard block |
||
| 98 | 98 | * @param array _options options for specific backends |
| 99 | 99 | * @return bool |
| 100 | 100 | */ |
| 101 | - public function __construct( $_stream, array $_options ) { |
|
| 102 | - if (!is_object($GLOBALS['egw']->translation)) { |
|
| 101 | + public function __construct( $_stream, array $_options ) |
|
| 102 | + { |
|
| 103 | + if (!is_object($GLOBALS['egw']->translation)) |
|
| 104 | + { |
|
| 103 | 105 | $GLOBALS['egw']->translation = new Api\Translation(); |
| 104 | 106 | } |
| 105 | 107 | $this->translation = &$GLOBALS['egw']->translation; |
| 106 | 108 | $this->handle = $_stream; |
| 107 | - if($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
|
| 109 | + if($_options['charset'] == 'user') |
|
| 110 | + { |
|
| 111 | + $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
|
| 112 | + } |
|
| 108 | 113 | $this->csv_charset = $_options['charset'] ? $_options['charset'] : 'utf-8'; |
| 109 | - if ( !empty( $_options ) ) { |
|
| 114 | + if ( !empty( $_options ) ) |
|
| 115 | + { |
|
| 110 | 116 | $this->csv_options = array_merge( $this->csv_options, $_options ); |
| 111 | 117 | } |
| 112 | 118 | //error_log(__METHOD__.__LINE__.array2string($_options['appname'])); |
| 113 | - if(!Api\Storage\Merge::is_export_limit_excepted()) { |
|
| 119 | + if(!Api\Storage\Merge::is_export_limit_excepted()) |
|
| 120 | + { |
|
| 114 | 121 | $this->export_limit = Api\Storage\Merge::getExportLimit($_options['appname']); |
| 115 | 122 | //error_log(__METHOD__.__LINE__.' app:'.$_options['appname'].' limit:'.$this->export_limit); |
| 116 | - if($this->export_limit == 'no') throw new Api\Exception\NoPermission\Admin('Export disabled'); |
|
| 123 | + if($this->export_limit == 'no') |
|
| 124 | + { |
|
| 125 | + throw new Api\Exception\NoPermission\Admin('Export disabled'); |
|
| 126 | + } |
|
| 117 | 127 | } |
| 118 | 128 | } |
| 119 | 129 | |
@@ -122,15 +132,19 @@ discard block |
||
| 122 | 132 | * |
| 123 | 133 | * @param array $_mapping egw_field_name => csv_field_name |
| 124 | 134 | */ |
| 125 | - public function set_mapping( array &$_mapping) { |
|
| 126 | - if ($this->num_of_records > 0) { |
|
| 135 | + public function set_mapping( array &$_mapping) |
|
| 136 | + { |
|
| 137 | + if ($this->num_of_records > 0) |
|
| 138 | + { |
|
| 127 | 139 | throw new Exception('Error: Field mapping can\'t be set during ongoing export!'); |
| 128 | 140 | } |
| 129 | - if($_mapping['all_custom_fields']) { |
|
| 141 | + if($_mapping['all_custom_fields']) |
|
| 142 | + { |
|
| 130 | 143 | // Field value is the appname, so we can pull the fields |
| 131 | 144 | $custom = Api\Storage\Customfields::get($_mapping['all_custom_fields']); |
| 132 | 145 | unset($_mapping['all_custom_fields']); |
| 133 | - foreach($custom as $field => $info) { |
|
| 146 | + foreach($custom as $field => $info) |
|
| 147 | + { |
|
| 134 | 148 | $_mapping['#'.$field] = $this->csv_options['begin_with_fieldnames'] == 'label' ? $info['label'] : $field; |
| 135 | 149 | } |
| 136 | 150 | } |
@@ -143,7 +157,8 @@ discard block |
||
| 143 | 157 | * |
| 144 | 158 | * @param array $_conversion |
| 145 | 159 | */ |
| 146 | - public function set_conversion( array $_conversion) { |
|
| 160 | + public function set_conversion( array $_conversion) |
|
| 161 | + { |
|
| 147 | 162 | $this->conversion = $_conversion; |
| 148 | 163 | } |
| 149 | 164 | |
@@ -153,16 +168,23 @@ discard block |
||
| 153 | 168 | * @param importexport_iface_egw_record record |
| 154 | 169 | * @return bool |
| 155 | 170 | */ |
| 156 | - public function export_record( importexport_iface_egw_record $_record ) { |
|
| 171 | + public function export_record( importexport_iface_egw_record $_record ) |
|
| 172 | + { |
|
| 157 | 173 | $this->record = $_record; |
| 158 | 174 | $this->record_array = $_record->get_record_array(); |
| 159 | 175 | |
| 160 | 176 | // begin with fieldnames ? |
| 161 | - if ($this->num_of_records == 0 && $this->csv_options['begin_with_fieldnames'] ) { |
|
| 162 | - if($this->csv_options['begin_with_fieldnames'] == 'label') { |
|
| 177 | + if ($this->num_of_records == 0 && $this->csv_options['begin_with_fieldnames'] ) |
|
| 178 | + { |
|
| 179 | + if($this->csv_options['begin_with_fieldnames'] == 'label') |
|
| 180 | + { |
|
| 163 | 181 | // Load translations for app |
| 164 | 182 | list($appname, $part2) = explode('_', get_class($_record)); |
| 165 | - if(!$GLOBALS['egw_info']['apps'][$appname]) $appname .= $part2; // Handle apps with _ in the name |
|
| 183 | + if(!$GLOBALS['egw_info']['apps'][$appname]) |
|
| 184 | + { |
|
| 185 | + $appname .= $part2; |
|
| 186 | + } |
|
| 187 | + // Handle apps with _ in the name |
|
| 166 | 188 | |
| 167 | 189 | // Get translations from wizard, if possible |
| 168 | 190 | if(!$this->csv_options['no_header_translation']) |
@@ -180,11 +202,16 @@ discard block |
||
| 180 | 202 | $label = $label != $fields[$field] ? $fields[$field] : lang($label); |
| 181 | 203 | } |
| 182 | 204 | // Make sure no * |
| 183 | - if(substr($label,-1) == '*') $label = substr($label,0,-1); |
|
| 205 | + if(substr($label,-1) == '*') |
|
| 206 | + { |
|
| 207 | + $label = substr($label,0,-1); |
|
| 208 | + } |
|
| 184 | 209 | } |
| 185 | - } catch (Exception $e) { |
|
| 210 | + } |
|
| 211 | + catch (Exception $e) { |
|
| 186 | 212 | Api\Translation::add_app($appname); |
| 187 | - foreach($this->mapping as $field => &$label) { |
|
| 213 | + foreach($this->mapping as $field => &$label) |
|
| 214 | + { |
|
| 188 | 215 | $label = lang($label); |
| 189 | 216 | } |
| 190 | 217 | } |
@@ -195,20 +222,24 @@ discard block |
||
| 195 | 222 | } |
| 196 | 223 | |
| 197 | 224 | // Check for limit |
| 198 | - if($this->export_limit && $this->num_of_records >= $this->export_limit) { |
|
| 225 | + if($this->export_limit && $this->num_of_records >= $this->export_limit) |
|
| 226 | + { |
|
| 199 | 227 | return; |
| 200 | 228 | } |
| 201 | 229 | |
| 202 | 230 | // do conversions |
| 203 | - if ( !empty( $this->conversion )) { |
|
| 231 | + if ( !empty( $this->conversion )) |
|
| 232 | + { |
|
| 204 | 233 | $this->record_array = importexport_helper_functions::conversion( $this->record_array, $this->conversion ); |
| 205 | 234 | } |
| 206 | 235 | |
| 207 | 236 | // do fieldmapping |
| 208 | - if ( !empty( $this->mapping ) ) { |
|
| 237 | + if ( !empty( $this->mapping ) ) |
|
| 238 | + { |
|
| 209 | 239 | $record_data = $this->record_array; |
| 210 | 240 | $this->record_array = array(); |
| 211 | - foreach ($this->mapping as $egw_field => $csv_field) { |
|
| 241 | + foreach ($this->mapping as $egw_field => $csv_field) |
|
| 242 | + { |
|
| 212 | 243 | $this->record_array[$csv_field] = $record_data[$egw_field]; |
| 213 | 244 | } |
| 214 | 245 | } |
@@ -222,7 +253,8 @@ discard block |
||
| 222 | 253 | * |
| 223 | 254 | * @return int |
| 224 | 255 | */ |
| 225 | - public function get_num_of_records() { |
|
| 256 | + public function get_num_of_records() |
|
| 257 | + { |
|
| 226 | 258 | return $this->num_of_records; |
| 227 | 259 | } |
| 228 | 260 | |
@@ -236,14 +268,20 @@ discard block |
||
| 236 | 268 | * |
| 237 | 269 | * @return Array of fields to be added to list of fields needing conversion |
| 238 | 270 | */ |
| 239 | - public static function convert_parse_custom_fields($appname, &$selects = array(), &$links = array(), &$methods = array()) { |
|
| 240 | - if(!$appname) return; |
|
| 271 | + public static function convert_parse_custom_fields($appname, &$selects = array(), &$links = array(), &$methods = array()) |
|
| 272 | + { |
|
| 273 | + if(!$appname) |
|
| 274 | + { |
|
| 275 | + return; |
|
| 276 | + } |
|
| 241 | 277 | |
| 242 | 278 | $fields = array(); |
| 243 | 279 | $custom = Api\Storage\Customfields::get($appname); |
| 244 | - foreach($custom as $name => $c_field) { |
|
| 280 | + foreach($custom as $name => $c_field) |
|
| 281 | + { |
|
| 245 | 282 | $name = '#' . $name; |
| 246 | - switch($c_field['type']) { |
|
| 283 | + switch($c_field['type']) |
|
| 284 | + { |
|
| 247 | 285 | case 'date': |
| 248 | 286 | $fields['date'][] = $name; |
| 249 | 287 | break; |
@@ -254,7 +292,8 @@ discard block |
||
| 254 | 292 | $fields['select-account'][] = $name; |
| 255 | 293 | break; |
| 256 | 294 | case 'ajax_select': |
| 257 | - if($c_field['values']['get_title']) { |
|
| 295 | + if($c_field['values']['get_title']) |
|
| 296 | + { |
|
| 258 | 297 | $methods[$name] = $c_field['values']['get_title']; |
| 259 | 298 | break; |
| 260 | 299 | } |
@@ -269,7 +308,8 @@ discard block |
||
| 269 | 308 | break; |
| 270 | 309 | default: |
| 271 | 310 | list($type) = explode('-',$c_field['type'],2); |
| 272 | - if(in_array($type, array_keys($GLOBALS['egw_info']['apps']))) { |
|
| 311 | + if(in_array($type, array_keys($GLOBALS['egw_info']['apps']))) |
|
| 312 | + { |
|
| 273 | 313 | $fields['links'][] = $name; |
| 274 | 314 | $links[$name] = $c_field['type']; |
| 275 | 315 | } |
@@ -288,9 +328,12 @@ discard block |
||
| 288 | 328 | * @parem fields List of field types => field names to be converted |
| 289 | 329 | * @param appname Current appname if you want to do custom fields too |
| 290 | 330 | */ |
| 291 | - public static function convert(importexport_iface_egw_record &$record, Array $fields = array(), $appname = null, $selects = array()) { |
|
| 292 | - if($appname) { |
|
| 293 | - if(!self::$cf_parse_cache[$appname]) { |
|
| 331 | + public static function convert(importexport_iface_egw_record &$record, Array $fields = array(), $appname = null, $selects = array()) |
|
| 332 | + { |
|
| 333 | + if($appname) |
|
| 334 | + { |
|
| 335 | + if(!self::$cf_parse_cache[$appname]) |
|
| 336 | + { |
|
| 294 | 337 | $c_fields = self::convert_parse_custom_fields($appname, $selects, $links, $methods); |
| 295 | 338 | self::$cf_parse_cache[$appname] = array($c_fields, $selects, $links, $methods); |
| 296 | 339 | } |
@@ -299,7 +342,10 @@ discard block |
||
| 299 | 342 | // Add in any fields that are keys to another app |
| 300 | 343 | foreach((array)$fields['links'] as $link_field => $app) |
| 301 | 344 | { |
| 302 | - if(is_numeric($link_field)) continue; |
|
| 345 | + if(is_numeric($link_field)) |
|
| 346 | + { |
|
| 347 | + continue; |
|
| 348 | + } |
|
| 303 | 349 | $links[$link_field] = $app; |
| 304 | 350 | // Set it as a normal link field |
| 305 | 351 | $fields['links'][] = $link_field; |
@@ -307,8 +353,10 @@ discard block |
||
| 307 | 353 | } |
| 308 | 354 | |
| 309 | 355 | // Not quite a recursive merge, since only one level |
| 310 | - foreach($fields as $type => &$list) { |
|
| 311 | - if($c_fields[$type]) { |
|
| 356 | + foreach($fields as $type => &$list) |
|
| 357 | + { |
|
| 358 | + if($c_fields[$type]) |
|
| 359 | + { |
|
| 312 | 360 | $list = array_merge($c_fields[$type], $list); |
| 313 | 361 | unset($c_fields[$type]); |
| 314 | 362 | } |
@@ -316,16 +364,22 @@ discard block |
||
| 316 | 364 | $fields += $c_fields; |
| 317 | 365 | $selects += $c_selects; |
| 318 | 366 | } |
| 319 | - foreach((array)$fields['select'] as $name) { |
|
| 320 | - if($record->$name != null && is_array($selects) && $selects[$name]) { |
|
| 367 | + foreach((array)$fields['select'] as $name) |
|
| 368 | + { |
|
| 369 | + if($record->$name != null && is_array($selects) && $selects[$name]) |
|
| 370 | + { |
|
| 321 | 371 | $record->$name = is_string($record->$name) ? explode(',', $record->$name) : $record->$name; |
| 322 | - if(is_array($record->$name)) { |
|
| 372 | + if(is_array($record->$name)) |
|
| 373 | + { |
|
| 323 | 374 | $names = array(); |
| 324 | - foreach($record->$name as $_name) { |
|
| 375 | + foreach($record->$name as $_name) |
|
| 376 | + { |
|
| 325 | 377 | $names[] = lang($selects[$name][$_name]); |
| 326 | 378 | } |
| 327 | 379 | $record->$name = implode(', ', $names); |
| 328 | - } else { |
|
| 380 | + } |
|
| 381 | + else |
|
| 382 | + { |
|
| 329 | 383 | $record->$name = lang($selects[$name][$record->$name]); |
| 330 | 384 | } |
| 331 | 385 | } |
@@ -334,9 +388,12 @@ discard block |
||
| 334 | 388 | $record->$name = ''; |
| 335 | 389 | } |
| 336 | 390 | } |
| 337 | - foreach((array)$fields['links'] as $name) { |
|
| 338 | - if($record->$name) { |
|
| 339 | - if(is_numeric($record->$name) && !$links[$name]) { |
|
| 391 | + foreach((array)$fields['links'] as $name) |
|
| 392 | + { |
|
| 393 | + if($record->$name) |
|
| 394 | + { |
|
| 395 | + if(is_numeric($record->$name) && !$links[$name]) |
|
| 396 | + { |
|
| 340 | 397 | $link = Link::get_link($record->$name); |
| 341 | 398 | $links[$name] = ($link['link_app1'] == $appname ? $link['link_app2'] : $link['link_app1']); |
| 342 | 399 | $record->$name = ($link['link_app1'] == $appname ? $link['link_id2'] : $link['link_id1']); |
@@ -355,16 +412,22 @@ discard block |
||
| 355 | 412 | $record->$name = ''; |
| 356 | 413 | } |
| 357 | 414 | } |
| 358 | - foreach((array)$fields['select-account'] as $name) { |
|
| 415 | + foreach((array)$fields['select-account'] as $name) |
|
| 416 | + { |
|
| 359 | 417 | // Compare against null to deal with empty arrays |
| 360 | - if ($record->$name !== null) { |
|
| 361 | - if(is_array($record->$name)) { |
|
| 418 | + if ($record->$name !== null) |
|
| 419 | + { |
|
| 420 | + if(is_array($record->$name)) |
|
| 421 | + { |
|
| 362 | 422 | $names = array(); |
| 363 | - foreach($record->$name as $_name) { |
|
| 423 | + foreach($record->$name as $_name) |
|
| 424 | + { |
|
| 364 | 425 | $names[] = Api\Accounts::username($_name); |
| 365 | 426 | } |
| 366 | 427 | $record->$name = implode(', ', $names); |
| 367 | - } else { |
|
| 428 | + } |
|
| 429 | + else |
|
| 430 | + { |
|
| 368 | 431 | $record->$name = Api\Accounts::username($record->$name); |
| 369 | 432 | } |
| 370 | 433 | } |
@@ -373,23 +436,49 @@ discard block |
||
| 373 | 436 | $record->$name = ''; |
| 374 | 437 | } |
| 375 | 438 | } |
| 376 | - foreach((array)$fields['select-bool'] as $name) { |
|
| 377 | - if($record->$name !== null) { |
|
| 439 | + foreach((array)$fields['select-bool'] as $name) |
|
| 440 | + { |
|
| 441 | + if($record->$name !== null) |
|
| 442 | + { |
|
| 378 | 443 | $record->$name = $record->$name ? lang('Yes') : lang('No'); |
| 379 | 444 | } |
| 380 | 445 | } |
| 381 | - foreach((array)$fields['date-time'] as $name) { |
|
| 446 | + foreach((array)$fields['date-time'] as $name) |
|
| 447 | + { |
|
| 382 | 448 | //if ($record->$name) $record->$name = date('Y-m-d H:i:s',$record->$name); // Standard date format |
| 383 | - if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string |
|
| 384 | - if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'] . ' '. |
|
| 385 | - ($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '24' ? 'H:i:s' : 'h:i:s a'),$record->$name); // User date format |
|
| 386 | - if (!$record->$name) $record->$name = ''; |
|
| 449 | + if ($record->$name && !is_numeric($record->$name)) |
|
| 450 | + { |
|
| 451 | + $record->$name = strtotime($record->$name); |
|
| 452 | + } |
|
| 453 | + // Custom fields stored as string |
|
| 454 | + if ($record->$name && is_numeric($record->$name)) |
|
| 455 | + { |
|
| 456 | + $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'] . ' '. |
|
| 457 | + ($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '24' ? 'H:i:s' : 'h:i:s a'),$record->$name); |
|
| 458 | + } |
|
| 459 | + // User date format |
|
| 460 | + if (!$record->$name) |
|
| 461 | + { |
|
| 462 | + $record->$name = ''; |
|
| 463 | + } |
|
| 387 | 464 | } |
| 388 | - foreach((array)$fields['date'] as $name) { |
|
| 465 | + foreach((array)$fields['date'] as $name) |
|
| 466 | + { |
|
| 389 | 467 | //if ($record->$name) $record->$name = date('Y-m-d',$record->$name); // Standard date format |
| 390 | - if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string |
|
| 391 | - if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], $record->$name); // User date format |
|
| 392 | - if (!$record->$name) $record->$name = ''; |
|
| 468 | + if ($record->$name && !is_numeric($record->$name)) |
|
| 469 | + { |
|
| 470 | + $record->$name = strtotime($record->$name); |
|
| 471 | + } |
|
| 472 | + // Custom fields stored as string |
|
| 473 | + if ($record->$name && is_numeric($record->$name)) |
|
| 474 | + { |
|
| 475 | + $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], $record->$name); |
|
| 476 | + } |
|
| 477 | + // User date format |
|
| 478 | + if (!$record->$name) |
|
| 479 | + { |
|
| 480 | + $record->$name = ''; |
|
| 481 | + } |
|
| 393 | 482 | } |
| 394 | 483 | foreach((array)$fields['float'] as $name) |
| 395 | 484 | { |
@@ -397,7 +486,10 @@ discard block |
||
| 397 | 486 | if (is_null($dec_separator)) |
| 398 | 487 | { |
| 399 | 488 | $dec_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0]; |
| 400 | - if (empty($dec_separator)) $dec_separator = '.'; |
|
| 489 | + if (empty($dec_separator)) |
|
| 490 | + { |
|
| 491 | + $dec_separator = '.'; |
|
| 492 | + } |
|
| 401 | 493 | $thousands_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][1]; |
| 402 | 494 | } |
| 403 | 495 | if($record->$name && (string)$record->$name != '') |
@@ -413,17 +505,27 @@ discard block |
||
| 413 | 505 | } |
| 414 | 506 | |
| 415 | 507 | // Some custom methods for conversion |
| 416 | - foreach((array)$methods as $name => $method) { |
|
| 417 | - if($record->$name) $record->$name = ExecMethod($method, $record->$name); |
|
| 508 | + foreach((array)$methods as $name => $method) |
|
| 509 | + { |
|
| 510 | + if($record->$name) |
|
| 511 | + { |
|
| 512 | + $record->$name = ExecMethod($method, $record->$name); |
|
| 513 | + } |
|
| 418 | 514 | } |
| 419 | 515 | |
| 420 | 516 | static $cat_object; |
| 421 | - if(is_null($cat_object)) $cat_object = new Api\Categories(false,$appname); |
|
| 422 | - foreach((array)$fields['select-cat'] as $name) { |
|
| 423 | - if($record->$name) { |
|
| 517 | + if(is_null($cat_object)) |
|
| 518 | + { |
|
| 519 | + $cat_object = new Api\Categories(false,$appname); |
|
| 520 | + } |
|
| 521 | + foreach((array)$fields['select-cat'] as $name) |
|
| 522 | + { |
|
| 523 | + if($record->$name) |
|
| 524 | + { |
|
| 424 | 525 | $cats = array(); |
| 425 | 526 | $ids = is_array($record->$name) ? $record->$name : explode(',', $record->$name); |
| 426 | - foreach($ids as $n => $cat_id) { |
|
| 527 | + foreach($ids as $n => $cat_id) |
|
| 528 | + { |
|
| 427 | 529 | |
| 428 | 530 | if ($cat_id && $cat_object->check_perms(Acl::READ,$cat_id)) |
| 429 | 531 | { |
@@ -444,7 +546,8 @@ discard block |
||
| 444 | 546 | * |
| 445 | 547 | * @return |
| 446 | 548 | */ |
| 447 | - public function __destruct() { |
|
| 549 | + public function __destruct() |
|
| 550 | + { |
|
| 448 | 551 | |
| 449 | 552 | } |
| 450 | 553 | |
@@ -457,11 +560,16 @@ discard block |
||
| 457 | 560 | * @param char $delimiter |
| 458 | 561 | * @param char $enclosure |
| 459 | 562 | */ |
| 460 | - protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure){ |
|
| 563 | + protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure) |
|
| 564 | + { |
|
| 461 | 565 | $string = ""; |
| 462 | 566 | $writeDelimiter = false; |
| 463 | - foreach($dataArray as $dataElement) { |
|
| 464 | - if($writeDelimiter) $string .= $delimiter; |
|
| 567 | + foreach($dataArray as $dataElement) |
|
| 568 | + { |
|
| 569 | + if($writeDelimiter) |
|
| 570 | + { |
|
| 571 | + $string .= $delimiter; |
|
| 572 | + } |
|
| 465 | 573 | $string .= $enclosure . str_replace(array("\r\n", '"'), array("\n",'""'), $dataElement) . $enclosure; |
| 466 | 574 | $writeDelimiter = true; |
| 467 | 575 | } |
@@ -98,22 +98,22 @@ discard block |
||
| 98 | 98 | * @param array _options options for specific backends |
| 99 | 99 | * @return bool |
| 100 | 100 | */ |
| 101 | - public function __construct( $_stream, array $_options ) { |
|
| 101 | + public function __construct($_stream, array $_options) { |
|
| 102 | 102 | if (!is_object($GLOBALS['egw']->translation)) { |
| 103 | 103 | $GLOBALS['egw']->translation = new Api\Translation(); |
| 104 | 104 | } |
| 105 | 105 | $this->translation = &$GLOBALS['egw']->translation; |
| 106 | 106 | $this->handle = $_stream; |
| 107 | - if($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
|
| 107 | + if ($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']; |
|
| 108 | 108 | $this->csv_charset = $_options['charset'] ? $_options['charset'] : 'utf-8'; |
| 109 | - if ( !empty( $_options ) ) { |
|
| 110 | - $this->csv_options = array_merge( $this->csv_options, $_options ); |
|
| 109 | + if (!empty($_options)) { |
|
| 110 | + $this->csv_options = array_merge($this->csv_options, $_options); |
|
| 111 | 111 | } |
| 112 | 112 | //error_log(__METHOD__.__LINE__.array2string($_options['appname'])); |
| 113 | - if(!Api\Storage\Merge::is_export_limit_excepted()) { |
|
| 113 | + if (!Api\Storage\Merge::is_export_limit_excepted()) { |
|
| 114 | 114 | $this->export_limit = Api\Storage\Merge::getExportLimit($_options['appname']); |
| 115 | 115 | //error_log(__METHOD__.__LINE__.' app:'.$_options['appname'].' limit:'.$this->export_limit); |
| 116 | - if($this->export_limit == 'no') throw new Api\Exception\NoPermission\Admin('Export disabled'); |
|
| 116 | + if ($this->export_limit == 'no') throw new Api\Exception\NoPermission\Admin('Export disabled'); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
@@ -122,15 +122,15 @@ discard block |
||
| 122 | 122 | * |
| 123 | 123 | * @param array $_mapping egw_field_name => csv_field_name |
| 124 | 124 | */ |
| 125 | - public function set_mapping( array &$_mapping) { |
|
| 125 | + public function set_mapping(array &$_mapping) { |
|
| 126 | 126 | if ($this->num_of_records > 0) { |
| 127 | 127 | throw new Exception('Error: Field mapping can\'t be set during ongoing export!'); |
| 128 | 128 | } |
| 129 | - if($_mapping['all_custom_fields']) { |
|
| 129 | + if ($_mapping['all_custom_fields']) { |
|
| 130 | 130 | // Field value is the appname, so we can pull the fields |
| 131 | 131 | $custom = Api\Storage\Customfields::get($_mapping['all_custom_fields']); |
| 132 | 132 | unset($_mapping['all_custom_fields']); |
| 133 | - foreach($custom as $field => $info) { |
|
| 133 | + foreach ($custom as $field => $info) { |
|
| 134 | 134 | $_mapping['#'.$field] = $this->csv_options['begin_with_fieldnames'] == 'label' ? $info['label'] : $field; |
| 135 | 135 | } |
| 136 | 136 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * |
| 144 | 144 | * @param array $_conversion |
| 145 | 145 | */ |
| 146 | - public function set_conversion( array $_conversion) { |
|
| 146 | + public function set_conversion(array $_conversion) { |
|
| 147 | 147 | $this->conversion = $_conversion; |
| 148 | 148 | } |
| 149 | 149 | |
@@ -153,59 +153,59 @@ discard block |
||
| 153 | 153 | * @param importexport_iface_egw_record record |
| 154 | 154 | * @return bool |
| 155 | 155 | */ |
| 156 | - public function export_record( importexport_iface_egw_record $_record ) { |
|
| 156 | + public function export_record(importexport_iface_egw_record $_record) { |
|
| 157 | 157 | $this->record = $_record; |
| 158 | 158 | $this->record_array = $_record->get_record_array(); |
| 159 | 159 | |
| 160 | 160 | // begin with fieldnames ? |
| 161 | - if ($this->num_of_records == 0 && $this->csv_options['begin_with_fieldnames'] ) { |
|
| 162 | - if($this->csv_options['begin_with_fieldnames'] == 'label') { |
|
| 161 | + if ($this->num_of_records == 0 && $this->csv_options['begin_with_fieldnames']) { |
|
| 162 | + if ($this->csv_options['begin_with_fieldnames'] == 'label') { |
|
| 163 | 163 | // Load translations for app |
| 164 | 164 | list($appname, $part2) = explode('_', get_class($_record)); |
| 165 | - if(!$GLOBALS['egw_info']['apps'][$appname]) $appname .= $part2; // Handle apps with _ in the name |
|
| 165 | + if (!$GLOBALS['egw_info']['apps'][$appname]) $appname .= $part2; // Handle apps with _ in the name |
|
| 166 | 166 | |
| 167 | 167 | // Get translations from wizard, if possible |
| 168 | - if(!$this->csv_options['no_header_translation']) |
|
| 168 | + if (!$this->csv_options['no_header_translation']) |
|
| 169 | 169 | { |
| 170 | 170 | $backtrace = debug_backtrace(); |
| 171 | 171 | $plugin = $backtrace[1]['class']; |
| 172 | - $wizard_name = $appname . '_wizard_' . str_replace($appname . '_', '', $plugin); |
|
| 172 | + $wizard_name = $appname.'_wizard_'.str_replace($appname.'_', '', $plugin); |
|
| 173 | 173 | try { |
| 174 | 174 | $wizard = new $wizard_name; |
| 175 | 175 | $fields = $wizard->get_export_fields(); |
| 176 | - foreach($this->mapping as $field => &$label) |
|
| 176 | + foreach ($this->mapping as $field => &$label) |
|
| 177 | 177 | { |
| 178 | - if($fields[$field]) |
|
| 178 | + if ($fields[$field]) |
|
| 179 | 179 | { |
| 180 | 180 | $label = $label != $fields[$field] ? $fields[$field] : lang($label); |
| 181 | 181 | } |
| 182 | 182 | // Make sure no * |
| 183 | - if(substr($label,-1) == '*') $label = substr($label,0,-1); |
|
| 183 | + if (substr($label, -1) == '*') $label = substr($label, 0, -1); |
|
| 184 | 184 | } |
| 185 | 185 | } catch (Exception $e) { |
| 186 | 186 | Api\Translation::add_app($appname); |
| 187 | - foreach($this->mapping as $field => &$label) { |
|
| 187 | + foreach ($this->mapping as $field => &$label) { |
|
| 188 | 188 | $label = lang($label); |
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | - $mapping = ! empty( $this->mapping ) ? $this->mapping : array_keys ( $this->record_array ); |
|
| 194 | - self::fputcsv( $this->handle ,$mapping ,$this->csv_options['delimiter'], $this->csv_options['enclosure'] ); |
|
| 193 | + $mapping = !empty($this->mapping) ? $this->mapping : array_keys($this->record_array); |
|
| 194 | + self::fputcsv($this->handle, $mapping, $this->csv_options['delimiter'], $this->csv_options['enclosure']); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | // Check for limit |
| 198 | - if($this->export_limit && $this->num_of_records >= $this->export_limit) { |
|
| 198 | + if ($this->export_limit && $this->num_of_records >= $this->export_limit) { |
|
| 199 | 199 | return; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | // do conversions |
| 203 | - if ( !empty( $this->conversion )) { |
|
| 204 | - $this->record_array = importexport_helper_functions::conversion( $this->record_array, $this->conversion ); |
|
| 203 | + if (!empty($this->conversion)) { |
|
| 204 | + $this->record_array = importexport_helper_functions::conversion($this->record_array, $this->conversion); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | // do fieldmapping |
| 208 | - if ( !empty( $this->mapping ) ) { |
|
| 208 | + if (!empty($this->mapping)) { |
|
| 209 | 209 | $record_data = $this->record_array; |
| 210 | 210 | $this->record_array = array(); |
| 211 | 211 | foreach ($this->mapping as $egw_field => $csv_field) { |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - self::fputcsv( $this->handle, $this->record_array, $this->csv_options['delimiter'], $this->csv_options['enclosure'] ); |
|
| 216 | + self::fputcsv($this->handle, $this->record_array, $this->csv_options['delimiter'], $this->csv_options['enclosure']); |
|
| 217 | 217 | $this->num_of_records++; |
| 218 | 218 | } |
| 219 | 219 | |
@@ -237,13 +237,13 @@ discard block |
||
| 237 | 237 | * @return Array of fields to be added to list of fields needing conversion |
| 238 | 238 | */ |
| 239 | 239 | public static function convert_parse_custom_fields($appname, &$selects = array(), &$links = array(), &$methods = array()) { |
| 240 | - if(!$appname) return; |
|
| 240 | + if (!$appname) return; |
|
| 241 | 241 | |
| 242 | 242 | $fields = array(); |
| 243 | 243 | $custom = Api\Storage\Customfields::get($appname); |
| 244 | - foreach($custom as $name => $c_field) { |
|
| 245 | - $name = '#' . $name; |
|
| 246 | - switch($c_field['type']) { |
|
| 244 | + foreach ($custom as $name => $c_field) { |
|
| 245 | + $name = '#'.$name; |
|
| 246 | + switch ($c_field['type']) { |
|
| 247 | 247 | case 'date': |
| 248 | 248 | $fields['date'][] = $name; |
| 249 | 249 | break; |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | $fields['select-account'][] = $name; |
| 255 | 255 | break; |
| 256 | 256 | case 'ajax_select': |
| 257 | - if($c_field['values']['get_title']) { |
|
| 257 | + if ($c_field['values']['get_title']) { |
|
| 258 | 258 | $methods[$name] = $c_field['values']['get_title']; |
| 259 | 259 | break; |
| 260 | 260 | } |
@@ -268,8 +268,8 @@ discard block |
||
| 268 | 268 | $selects[$name] = $c_field['values']; |
| 269 | 269 | break; |
| 270 | 270 | default: |
| 271 | - list($type) = explode('-',$c_field['type'],2); |
|
| 272 | - if(in_array($type, array_keys($GLOBALS['egw_info']['apps']))) { |
|
| 271 | + list($type) = explode('-', $c_field['type'], 2); |
|
| 272 | + if (in_array($type, array_keys($GLOBALS['egw_info']['apps']))) { |
|
| 273 | 273 | $fields['links'][] = $name; |
| 274 | 274 | $links[$name] = $c_field['type']; |
| 275 | 275 | } |
@@ -289,17 +289,17 @@ discard block |
||
| 289 | 289 | * @param appname Current appname if you want to do custom fields too |
| 290 | 290 | */ |
| 291 | 291 | public static function convert(importexport_iface_egw_record &$record, Array $fields = array(), $appname = null, $selects = array()) { |
| 292 | - if($appname) { |
|
| 293 | - if(!self::$cf_parse_cache[$appname]) { |
|
| 292 | + if ($appname) { |
|
| 293 | + if (!self::$cf_parse_cache[$appname]) { |
|
| 294 | 294 | $c_fields = self::convert_parse_custom_fields($appname, $selects, $links, $methods); |
| 295 | 295 | self::$cf_parse_cache[$appname] = array($c_fields, $selects, $links, $methods); |
| 296 | 296 | } |
| 297 | 297 | list($c_fields, $c_selects, $links, $methods) = self::$cf_parse_cache[$appname]; |
| 298 | 298 | |
| 299 | 299 | // Add in any fields that are keys to another app |
| 300 | - foreach((array)$fields['links'] as $link_field => $app) |
|
| 300 | + foreach ((array)$fields['links'] as $link_field => $app) |
|
| 301 | 301 | { |
| 302 | - if(is_numeric($link_field)) continue; |
|
| 302 | + if (is_numeric($link_field)) continue; |
|
| 303 | 303 | $links[$link_field] = $app; |
| 304 | 304 | // Set it as a normal link field |
| 305 | 305 | $fields['links'][] = $link_field; |
@@ -307,8 +307,8 @@ discard block |
||
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | // Not quite a recursive merge, since only one level |
| 310 | - foreach($fields as $type => &$list) { |
|
| 311 | - if($c_fields[$type]) { |
|
| 310 | + foreach ($fields as $type => &$list) { |
|
| 311 | + if ($c_fields[$type]) { |
|
| 312 | 312 | $list = array_merge($c_fields[$type], $list); |
| 313 | 313 | unset($c_fields[$type]); |
| 314 | 314 | } |
@@ -316,12 +316,12 @@ discard block |
||
| 316 | 316 | $fields += $c_fields; |
| 317 | 317 | $selects += $c_selects; |
| 318 | 318 | } |
| 319 | - foreach((array)$fields['select'] as $name) { |
|
| 320 | - if($record->$name != null && is_array($selects) && $selects[$name]) { |
|
| 319 | + foreach ((array)$fields['select'] as $name) { |
|
| 320 | + if ($record->$name != null && is_array($selects) && $selects[$name]) { |
|
| 321 | 321 | $record->$name = is_string($record->$name) ? explode(',', $record->$name) : $record->$name; |
| 322 | - if(is_array($record->$name)) { |
|
| 322 | + if (is_array($record->$name)) { |
|
| 323 | 323 | $names = array(); |
| 324 | - foreach($record->$name as $_name) { |
|
| 324 | + foreach ($record->$name as $_name) { |
|
| 325 | 325 | $names[] = lang($selects[$name][$_name]); |
| 326 | 326 | } |
| 327 | 327 | $record->$name = implode(', ', $names); |
@@ -334,18 +334,18 @@ discard block |
||
| 334 | 334 | $record->$name = ''; |
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | - foreach((array)$fields['links'] as $name) { |
|
| 338 | - if($record->$name) { |
|
| 339 | - if(is_numeric($record->$name) && !$links[$name]) { |
|
| 337 | + foreach ((array)$fields['links'] as $name) { |
|
| 338 | + if ($record->$name) { |
|
| 339 | + if (is_numeric($record->$name) && !$links[$name]) { |
|
| 340 | 340 | $link = Link::get_link($record->$name); |
| 341 | 341 | $links[$name] = ($link['link_app1'] == $appname ? $link['link_app2'] : $link['link_app1']); |
| 342 | 342 | $record->$name = ($link['link_app1'] == $appname ? $link['link_id2'] : $link['link_id1']); |
| 343 | 343 | } |
| 344 | - if($links[$name]) |
|
| 344 | + if ($links[$name]) |
|
| 345 | 345 | { |
| 346 | 346 | $record->$name = Link::title($links[$name], $record->$name); |
| 347 | 347 | } |
| 348 | - else if ( is_array($record->$name) && $record->$name['app'] && $record->$name['id']) |
|
| 348 | + else if (is_array($record->$name) && $record->$name['app'] && $record->$name['id']) |
|
| 349 | 349 | { |
| 350 | 350 | $record->$name = Link::title($record->$name['app'], $record->$name['id']); |
| 351 | 351 | } |
@@ -355,12 +355,12 @@ discard block |
||
| 355 | 355 | $record->$name = ''; |
| 356 | 356 | } |
| 357 | 357 | } |
| 358 | - foreach((array)$fields['select-account'] as $name) { |
|
| 358 | + foreach ((array)$fields['select-account'] as $name) { |
|
| 359 | 359 | // Compare against null to deal with empty arrays |
| 360 | 360 | if ($record->$name !== null) { |
| 361 | - if(is_array($record->$name)) { |
|
| 361 | + if (is_array($record->$name)) { |
|
| 362 | 362 | $names = array(); |
| 363 | - foreach($record->$name as $_name) { |
|
| 363 | + foreach ($record->$name as $_name) { |
|
| 364 | 364 | $names[] = Api\Accounts::username($_name); |
| 365 | 365 | } |
| 366 | 366 | $record->$name = implode(', ', $names); |
@@ -373,64 +373,64 @@ discard block |
||
| 373 | 373 | $record->$name = ''; |
| 374 | 374 | } |
| 375 | 375 | } |
| 376 | - foreach((array)$fields['select-bool'] as $name) { |
|
| 377 | - if($record->$name !== null) { |
|
| 376 | + foreach ((array)$fields['select-bool'] as $name) { |
|
| 377 | + if ($record->$name !== null) { |
|
| 378 | 378 | $record->$name = $record->$name ? lang('Yes') : lang('No'); |
| 379 | 379 | } |
| 380 | 380 | } |
| 381 | - foreach((array)$fields['date-time'] as $name) { |
|
| 381 | + foreach ((array)$fields['date-time'] as $name) { |
|
| 382 | 382 | //if ($record->$name) $record->$name = date('Y-m-d H:i:s',$record->$name); // Standard date format |
| 383 | 383 | if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string |
| 384 | - if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'] . ' '. |
|
| 385 | - ($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '24' ? 'H:i:s' : 'h:i:s a'),$record->$name); // User date format |
|
| 384 | + if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'].' '. |
|
| 385 | + ($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '24' ? 'H:i:s' : 'h:i:s a'), $record->$name); // User date format |
|
| 386 | 386 | if (!$record->$name) $record->$name = ''; |
| 387 | 387 | } |
| 388 | - foreach((array)$fields['date'] as $name) { |
|
| 388 | + foreach ((array)$fields['date'] as $name) { |
|
| 389 | 389 | //if ($record->$name) $record->$name = date('Y-m-d',$record->$name); // Standard date format |
| 390 | 390 | if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string |
| 391 | 391 | if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], $record->$name); // User date format |
| 392 | 392 | if (!$record->$name) $record->$name = ''; |
| 393 | 393 | } |
| 394 | - foreach((array)$fields['float'] as $name) |
|
| 394 | + foreach ((array)$fields['float'] as $name) |
|
| 395 | 395 | { |
| 396 | - static $dec_separator,$thousands_separator; |
|
| 396 | + static $dec_separator, $thousands_separator; |
|
| 397 | 397 | if (is_null($dec_separator)) |
| 398 | 398 | { |
| 399 | 399 | $dec_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0]; |
| 400 | 400 | if (empty($dec_separator)) $dec_separator = '.'; |
| 401 | 401 | $thousands_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][1]; |
| 402 | 402 | } |
| 403 | - if($record->$name && (string)$record->$name != '') |
|
| 403 | + if ($record->$name && (string)$record->$name != '') |
|
| 404 | 404 | { |
| 405 | - if(!is_numeric($record->$name)) |
|
| 405 | + if (!is_numeric($record->$name)) |
|
| 406 | 406 | { |
| 407 | 407 | $record->$name = floatval(str_replace($dec_separator, '.', preg_replace('/[^\d'.preg_quote($dec_separator).']/', '', $record->$name))); |
| 408 | 408 | } |
| 409 | - $record->$name = number_format(str_replace(' ','',$record->$name), 2, |
|
| 410 | - $dec_separator,$thousands_separator |
|
| 409 | + $record->$name = number_format(str_replace(' ', '', $record->$name), 2, |
|
| 410 | + $dec_separator, $thousands_separator |
|
| 411 | 411 | ); |
| 412 | 412 | } |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | // Some custom methods for conversion |
| 416 | - foreach((array)$methods as $name => $method) { |
|
| 417 | - if($record->$name) $record->$name = ExecMethod($method, $record->$name); |
|
| 416 | + foreach ((array)$methods as $name => $method) { |
|
| 417 | + if ($record->$name) $record->$name = ExecMethod($method, $record->$name); |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | static $cat_object; |
| 421 | - if(is_null($cat_object)) $cat_object = new Api\Categories(false,$appname); |
|
| 422 | - foreach((array)$fields['select-cat'] as $name) { |
|
| 423 | - if($record->$name) { |
|
| 421 | + if (is_null($cat_object)) $cat_object = new Api\Categories(false, $appname); |
|
| 422 | + foreach ((array)$fields['select-cat'] as $name) { |
|
| 423 | + if ($record->$name) { |
|
| 424 | 424 | $cats = array(); |
| 425 | 425 | $ids = is_array($record->$name) ? $record->$name : explode(',', $record->$name); |
| 426 | - foreach($ids as $n => $cat_id) { |
|
| 426 | + foreach ($ids as $n => $cat_id) { |
|
| 427 | 427 | |
| 428 | - if ($cat_id && $cat_object->check_perms(Acl::READ,$cat_id)) |
|
| 428 | + if ($cat_id && $cat_object->check_perms(Acl::READ, $cat_id)) |
|
| 429 | 429 | { |
| 430 | 430 | $cats[] = $cat_object->id2name($cat_id); |
| 431 | 431 | } |
| 432 | 432 | } |
| 433 | - $record->$name = implode(', ',$cats); |
|
| 433 | + $record->$name = implode(', ', $cats); |
|
| 434 | 434 | } |
| 435 | 435 | else |
| 436 | 436 | { |
@@ -457,18 +457,18 @@ discard block |
||
| 457 | 457 | * @param char $delimiter |
| 458 | 458 | * @param char $enclosure |
| 459 | 459 | */ |
| 460 | - protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure){ |
|
| 460 | + protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure) { |
|
| 461 | 461 | $string = ""; |
| 462 | 462 | $writeDelimiter = false; |
| 463 | - foreach($dataArray as $dataElement) { |
|
| 464 | - if($writeDelimiter) $string .= $delimiter; |
|
| 465 | - $string .= $enclosure . str_replace(array("\r\n", '"'), array("\n",'""'), $dataElement) . $enclosure; |
|
| 463 | + foreach ($dataArray as $dataElement) { |
|
| 464 | + if ($writeDelimiter) $string .= $delimiter; |
|
| 465 | + $string .= $enclosure.str_replace(array("\r\n", '"'), array("\n", '""'), $dataElement).$enclosure; |
|
| 466 | 466 | $writeDelimiter = true; |
| 467 | 467 | } |
| 468 | 468 | $string .= "\n"; |
| 469 | 469 | |
| 470 | 470 | // do charset translation |
| 471 | - $string = $this->translation->convert( $string, $this->translation->charset(), $this->csv_charset ); |
|
| 471 | + $string = $this->translation->convert($string, $this->translation->charset(), $this->csv_charset); |
|
| 472 | 472 | |
| 473 | 473 | fwrite($filePointer, $string); |
| 474 | 474 | |
@@ -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 | /** |
@@ -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) { |
@@ -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,51 +157,51 @@ 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 | // Group <name> (no comma) |
| 173 | - else if(strpos($account_lid, lang('Group')) === 0) |
|
| 173 | + else if (strpos($account_lid, lang('Group')) === 0) |
|
| 174 | 174 | { |
| 175 | 175 | $account_lid = trim(substr(trim($account_lid), strlen(lang('Group')))); |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - if ( $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid )) { |
|
| 178 | + if ($account_id = $GLOBALS['egw']->accounts->name2id($account_lid)) { |
|
| 179 | 179 | $account_ids[] = $account_id; |
| 180 | 180 | unset($account_lids[$key]); |
| 181 | 181 | continue; |
| 182 | 182 | } |
| 183 | - if ( $account_id = $GLOBALS['egw']->accounts->name2id( trim($account_lid), 'account_fullname' )) { |
|
| 183 | + if ($account_id = $GLOBALS['egw']->accounts->name2id(trim($account_lid), 'account_fullname')) { |
|
| 184 | 184 | $account_ids[] = $account_id; |
| 185 | 185 | unset($account_lids[$key]); |
| 186 | 186 | continue; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | // Handle groups listed as Group, <name> |
| 190 | - if ( $account_lids[$key][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid)) { |
|
| 190 | + if ($account_lids[$key][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id($account_lid)) { |
|
| 191 | 191 | $account_ids[] = $account_id; |
| 192 | - unset($account_lids[$key-1]); |
|
| 192 | + unset($account_lids[$key - 1]); |
|
| 193 | 193 | unset($account_lids[$key]); |
| 194 | 194 | continue; |
| 195 | 195 | } |
| 196 | 196 | // Group, <name> - remove the Group part |
| 197 | - if($account_lid == lang('Group')) |
|
| 197 | + if ($account_lid == lang('Group')) |
|
| 198 | 198 | { |
| 199 | 199 | unset($account_lids[$key]); |
| 200 | 200 | continue; |
| 201 | 201 | } |
| 202 | 202 | } |
| 203 | - $_account_lids = (is_array($_account_lids) ? $account_lids : implode(',',array_unique($account_lids))); |
|
| 204 | - return is_array( $_account_lids ) ? array_unique($account_ids) : implode( ',', array_unique((array)$account_ids )); |
|
| 203 | + $_account_lids = (is_array($_account_lids) ? $account_lids : implode(',', array_unique($account_lids))); |
|
| 204 | + return is_array($_account_lids) ? array_unique($account_ids) : implode(',', array_unique((array)$account_ids)); |
|
| 205 | 205 | |
| 206 | 206 | } // end of member function account_lid2id |
| 207 | 207 | |
@@ -211,14 +211,14 @@ discard block |
||
| 211 | 211 | * @param mixed $_account_ids comma seperated list or array with ids |
| 212 | 212 | * @return mixed comma seperated list or array with lids |
| 213 | 213 | */ |
| 214 | - public static function account_id2name( $_account_id ) { |
|
| 215 | - $account_ids = is_array( $_account_id ) ? $_account_id : explode( ',', $_account_id ); |
|
| 216 | - foreach ( $account_ids as $account_id ) { |
|
| 217 | - if ( $account_lid = $GLOBALS['egw']->accounts->id2name( $account_id )) { |
|
| 214 | + public static function account_id2name($_account_id) { |
|
| 215 | + $account_ids = is_array($_account_id) ? $_account_id : explode(',', $_account_id); |
|
| 216 | + foreach ($account_ids as $account_id) { |
|
| 217 | + if ($account_lid = $GLOBALS['egw']->accounts->id2name($account_id)) { |
|
| 218 | 218 | $account_lids[] = $account_lid; |
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | - return is_array( $_account_id ) ? $account_lids : implode( ',', (array)$account_lids ); |
|
| 221 | + return is_array($_account_id) ? $account_lids : implode(',', (array)$account_lids); |
|
| 222 | 222 | } // end of member function account_id2lid |
| 223 | 223 | |
| 224 | 224 | /** |
@@ -227,12 +227,12 @@ discard block |
||
| 227 | 227 | * @param mixed _cat_ids comma seperated list or array |
| 228 | 228 | * @return mixed comma seperated list or array with cat_names |
| 229 | 229 | */ |
| 230 | - public static function cat_id2name( $_cat_ids ) { |
|
| 231 | - $cat_ids = is_array( $_cat_ids ) ? $_cat_ids : explode( ',', $_cat_ids ); |
|
| 232 | - foreach ( $cat_ids as $cat_id ) { |
|
| 233 | - $cat_names[] = Api\Categories::id2name( (int)$cat_id ); |
|
| 230 | + public static function cat_id2name($_cat_ids) { |
|
| 231 | + $cat_ids = is_array($_cat_ids) ? $_cat_ids : explode(',', $_cat_ids); |
|
| 232 | + foreach ($cat_ids as $cat_id) { |
|
| 233 | + $cat_names[] = Api\Categories::id2name((int)$cat_id); |
|
| 234 | 234 | } |
| 235 | - return is_array( $_cat_ids ) ? $cat_names : implode(',',(array)$cat_names); |
|
| 235 | + return is_array($_cat_ids) ? $cat_names : implode(',', (array)$cat_names); |
|
| 236 | 236 | } // end of member function category_id2name |
| 237 | 237 | |
| 238 | 238 | /** |
@@ -243,24 +243,24 @@ discard block |
||
| 243 | 243 | * @param int $parent Optional parent ID to use for new categories |
| 244 | 244 | * @return mixed comma seperated list or array with cat_ids |
| 245 | 245 | */ |
| 246 | - public static function cat_name2id( $_cat_names, $parent = 0 ) { |
|
| 247 | - $cats = new Api\Categories(); // uses current user and app (egw_info[flags][currentapp]) |
|
| 246 | + public static function cat_name2id($_cat_names, $parent = 0) { |
|
| 247 | + $cats = new Api\Categories(); // uses current user and app (egw_info[flags][currentapp]) |
|
| 248 | 248 | |
| 249 | - $cat_names = is_array( $_cat_names ) ? $_cat_names : explode( ',', $_cat_names ); |
|
| 250 | - foreach ( $cat_names as $cat_name ) { |
|
| 249 | + $cat_names = is_array($_cat_names) ? $_cat_names : explode(',', $_cat_names); |
|
| 250 | + foreach ($cat_names as $cat_name) { |
|
| 251 | 251 | $cat_name = trim($cat_name); |
| 252 | - if ( $cat_name == '' ) continue; |
|
| 253 | - if ( ( $cat_id = $cats->name2id( $cat_name ) ) == 0 && !self::$dry_run) { |
|
| 254 | - $cat_id = $cats->add( array( |
|
| 252 | + if ($cat_name == '') continue; |
|
| 253 | + if (($cat_id = $cats->name2id($cat_name)) == 0 && !self::$dry_run) { |
|
| 254 | + $cat_id = $cats->add(array( |
|
| 255 | 255 | 'name' => $cat_name, |
| 256 | 256 | 'parent' => $parent, |
| 257 | 257 | 'access' => 'public', |
| 258 | - 'descr' => $cat_name. ' ('. lang('Automatically created by importexport'). ')' |
|
| 258 | + 'descr' => $cat_name.' ('.lang('Automatically created by importexport').')' |
|
| 259 | 259 | )); |
| 260 | 260 | } |
| 261 | 261 | $cat_ids[] = $cat_id; |
| 262 | 262 | } |
| 263 | - return is_array( $_cat_names ) ? $cat_ids : implode( ',', (array)$cat_ids ); |
|
| 263 | + return is_array($_cat_names) ? $cat_ids : implode(',', (array)$cat_ids); |
|
| 264 | 264 | |
| 265 | 265 | } // end of member function category_name2id |
| 266 | 266 | |
@@ -299,76 +299,76 @@ discard block |
||
| 299 | 299 | * @param object &$cclass calling class to process the '@ evals' |
| 300 | 300 | * @return bool |
| 301 | 301 | */ |
| 302 | - public static function conversion( &$_record, $_conversion, &$_cclass = null ) { |
|
| 303 | - if (empty( $_conversion ) ) return $_record; |
|
| 302 | + public static function conversion(&$_record, $_conversion, &$_cclass = null) { |
|
| 303 | + if (empty($_conversion)) return $_record; |
|
| 304 | 304 | |
| 305 | - self::$cclass =& $_cclass; |
|
| 305 | + self::$cclass = & $_cclass; |
|
| 306 | 306 | |
| 307 | 307 | $PSep = '||'; // Pattern-Separator, separats the pattern-replacement-pairs in conversion |
| 308 | 308 | $ASep = '|>'; // Assignment-Separator, separats pattern and replacesment |
| 309 | - $CPre = '|['; $CPos = ']'; // |[_record-idx] is expanded to the corespondig value |
|
| 309 | + $CPre = '|['; $CPos = ']'; // |[_record-idx] is expanded to the corespondig value |
|
| 310 | 310 | $TPre = '|T{'; $TPos = '}'; // |{_record-idx} is trimmed |
| 311 | - $CntlPre = '|TC{'; // Filter all cntl-chars \x01-\x1f and trim |
|
| 312 | - $CntlnCLPre = '|TCnCL{'; // Like |C{ but allowes CR and LF |
|
| 313 | - $INE = '|INE{'; // Only insert if stuff in ^^ is not empty |
|
| 311 | + $CntlPre = '|TC{'; // Filter all cntl-chars \x01-\x1f and trim |
|
| 312 | + $CntlnCLPre = '|TCnCL{'; // Like |C{ but allowes CR and LF |
|
| 313 | + $INE = '|INE{'; // Only insert if stuff in ^^ is not empty |
|
| 314 | 314 | |
| 315 | - foreach ( $_conversion as $idx => $conversion_string ) { |
|
| 316 | - if ( empty( $conversion_string ) ) continue; |
|
| 315 | + foreach ($_conversion as $idx => $conversion_string) { |
|
| 316 | + if (empty($conversion_string)) continue; |
|
| 317 | 317 | |
| 318 | 318 | // fetch patterns ($rvalues) |
| 319 | 319 | $rvalues = array(); |
| 320 | - $pat_reps = explode( $PSep, stripslashes( $conversion_string ) ); |
|
| 321 | - foreach( $pat_reps as $k => $pat_rep ) { |
|
| 322 | - list( $pattern, $replace ) = explode( $ASep, $pat_rep, 2 ); |
|
| 323 | - if( $replace == '' ) { |
|
| 320 | + $pat_reps = explode($PSep, stripslashes($conversion_string)); |
|
| 321 | + foreach ($pat_reps as $k => $pat_rep) { |
|
| 322 | + list($pattern, $replace) = explode($ASep, $pat_rep, 2); |
|
| 323 | + if ($replace == '') { |
|
| 324 | 324 | $replace = $pattern; $pattern = '^.*$'; |
| 325 | 325 | } |
| 326 | - $rvalues[$pattern] = $replace; // replace two with only one, added by the form |
|
| 326 | + $rvalues[$pattern] = $replace; // replace two with only one, added by the form |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | // conversion list may be longer than $_record aka (no_csv) |
| 330 | - $val = array_key_exists( $idx, $_record ) ? $_record[$idx] : ''; |
|
| 330 | + $val = array_key_exists($idx, $_record) ? $_record[$idx] : ''; |
|
| 331 | 331 | |
| 332 | 332 | $c_functions = array('cat', 'account', 'strtotime', 'list'); |
| 333 | - if($_cclass) { |
|
| 333 | + if ($_cclass) { |
|
| 334 | 334 | // Add in additional methods |
| 335 | 335 | $reflection = new ReflectionClass(get_class($_cclass)); |
| 336 | 336 | $methods = $reflection->getMethods(ReflectionMethod::IS_STATIC); |
| 337 | - foreach($methods as $method) { |
|
| 337 | + foreach ($methods as $method) { |
|
| 338 | 338 | $c_functions[] = $method->name; |
| 339 | 339 | } |
| 340 | 340 | } |
| 341 | 341 | $c_functions = implode('|', $c_functions); |
| 342 | - foreach ( $rvalues as $pattern => $replace ) { |
|
| 342 | + foreach ($rvalues as $pattern => $replace) { |
|
| 343 | 343 | // Allow to include record indexes in pattern |
| 344 | 344 | $reg = '/\|\[([0-9]+)\]/'; |
| 345 | - while( preg_match( $reg, $pattern, $vars ) ) { |
|
| 345 | + while (preg_match($reg, $pattern, $vars)) { |
|
| 346 | 346 | // expand all _record fields |
| 347 | 347 | $pattern = str_replace( |
| 348 | - $CPre . $vars[1] . $CPos, |
|
| 348 | + $CPre.$vars[1].$CPos, |
|
| 349 | 349 | $_record[array_search($vars[1], array_keys($_record))], |
| 350 | 350 | $pattern |
| 351 | 351 | ); |
| 352 | 352 | } |
| 353 | - if( preg_match('/'. (string)$pattern.'/', $val) ) { |
|
| 353 | + if (preg_match('/'.(string)$pattern.'/', $val)) { |
|
| 354 | 354 | |
| 355 | - $val = preg_replace( '/'.(string)$pattern.'/', $replace, (string)$val ); |
|
| 355 | + $val = preg_replace('/'.(string)$pattern.'/', $replace, (string)$val); |
|
| 356 | 356 | |
| 357 | 357 | $reg = '/\|\[([a-zA-Z_0-9]+)\]/'; |
| 358 | - while( preg_match( $reg, $val, $vars ) ) { |
|
| 358 | + while (preg_match($reg, $val, $vars)) { |
|
| 359 | 359 | // expand all _record fields |
| 360 | 360 | $val = str_replace( |
| 361 | - $CPre . $vars[1] . $CPos, |
|
| 361 | + $CPre.$vars[1].$CPos, |
|
| 362 | 362 | $_record[array_search($vars[1], array_keys($_record))], |
| 363 | 363 | $val |
| 364 | 364 | ); |
| 365 | 365 | } |
| 366 | - $val = preg_replace_callback( "/($c_functions)\(([^)]*)\)/i", array( self, 'c2_dispatcher') , $val ); |
|
| 366 | + $val = preg_replace_callback("/($c_functions)\(([^)]*)\)/i", array(self, 'c2_dispatcher'), $val); |
|
| 367 | 367 | break; |
| 368 | 368 | } |
| 369 | 369 | } |
| 370 | 370 | // clean each field |
| 371 | - $val = preg_replace_callback("/(\|T\{|\|TC\{|\|TCnCL\{|\|INE\{)(.*)\}/", array( self, 'strclean'), $val ); |
|
| 371 | + $val = preg_replace_callback("/(\|T\{|\|TC\{|\|TCnCL\{|\|INE\{)(.*)\}/", array(self, 'strclean'), $val); |
|
| 372 | 372 | |
| 373 | 373 | $_record[$idx] = $val; |
| 374 | 374 | } |
@@ -382,42 +382,42 @@ discard block |
||
| 382 | 382 | * |
| 383 | 383 | * @param array $_matches |
| 384 | 384 | */ |
| 385 | - private static function c2_dispatcher( $_matches ) { |
|
| 385 | + private static function c2_dispatcher($_matches) { |
|
| 386 | 386 | $action = &$_matches[1]; // cat or account ... |
| 387 | - $data = &$_matches[2]; // datas for action |
|
| 387 | + $data = &$_matches[2]; // datas for action |
|
| 388 | 388 | |
| 389 | - switch ( $action ) { |
|
| 389 | + switch ($action) { |
|
| 390 | 390 | case 'strtotime' : |
| 391 | - list( $string, $format ) = explode( ',', $data ); |
|
| 392 | - return self::custom_strtotime( trim( $string ), trim( $format ) ); |
|
| 391 | + list($string, $format) = explode(',', $data); |
|
| 392 | + return self::custom_strtotime(trim($string), trim($format)); |
|
| 393 | 393 | case 'list': |
| 394 | - list( $split, $data, $index) = explode(',',$data); |
|
| 394 | + list($split, $data, $index) = explode(',', $data); |
|
| 395 | 395 | $exploded = explode($split, $data); |
| 396 | 396 | // 1 based indexing for user ease |
| 397 | 397 | return $exploded[$index - 1]; |
| 398 | 398 | default : |
| 399 | - if(self::$cclass && method_exists(self::$cclass, $action)) { |
|
| 399 | + if (self::$cclass && method_exists(self::$cclass, $action)) { |
|
| 400 | 400 | $class = get_class(self::$cclass); |
| 401 | 401 | return call_user_func("$class::$action", $data); |
| 402 | 402 | } |
| 403 | - $method = (string)$action. ( is_int( $data ) ? '_id2name' : '_name2id' ); |
|
| 404 | - if(self::$cclass && method_exists(self::$cclass, $method)) { |
|
| 403 | + $method = (string)$action.(is_int($data) ? '_id2name' : '_name2id'); |
|
| 404 | + if (self::$cclass && method_exists(self::$cclass, $method)) { |
|
| 405 | 405 | $class = get_class(self::$cclass); |
| 406 | 406 | return call_user_func("$class::$action", $data); |
| 407 | 407 | } else { |
| 408 | - return self::$method( $data ); |
|
| 408 | + return self::$method($data); |
|
| 409 | 409 | } |
| 410 | 410 | } |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - private static function strclean( $_matches ) { |
|
| 414 | - switch( $_matches[1] ) { |
|
| 415 | - case '|T{' : return trim( $_matches[2] ); |
|
| 416 | - case '|TC{' : return trim( preg_replace( '/[\x01-\x1F]+/', '', $_matches[2] ) ); |
|
| 417 | - case '|TCnCL{' : return trim( preg_replace( '/[\x01-\x09\x11\x12\x14-\x1F]+/', '', $_matches[2] ) ); |
|
| 418 | - case '|INE{' : return preg_match( '/\^.+\^/', $_matches[2] ) ? $_matches[2] : ''; |
|
| 413 | + private static function strclean($_matches) { |
|
| 414 | + switch ($_matches[1]) { |
|
| 415 | + case '|T{' : return trim($_matches[2]); |
|
| 416 | + case '|TC{' : return trim(preg_replace('/[\x01-\x1F]+/', '', $_matches[2])); |
|
| 417 | + case '|TCnCL{' : return trim(preg_replace('/[\x01-\x09\x11\x12\x14-\x1F]+/', '', $_matches[2])); |
|
| 418 | + case '|INE{' : return preg_match('/\^.+\^/', $_matches[2]) ? $_matches[2] : ''; |
|
| 419 | 419 | default: |
| 420 | - throw new Exception('Error in conversion string! "'. substr( $_matches[1], 0, -1 ). '" is not valid!'); |
|
| 420 | + throw new Exception('Error in conversion string! "'.substr($_matches[1], 0, -1).'" is not valid!'); |
|
| 421 | 421 | } |
| 422 | 422 | } |
| 423 | 423 | |
@@ -428,23 +428,23 @@ discard block |
||
| 428 | 428 | * @param string $_appname {<appname> | all} |
| 429 | 429 | * @return array(<appname> => array( <type> => array(<plugin> => <title>))) |
| 430 | 430 | */ |
| 431 | - public static function get_plugins( $_appname = 'all', $_type = 'all' ) { |
|
| 431 | + public static function get_plugins($_appname = 'all', $_type = 'all') { |
|
| 432 | 432 | $plugins = Api\Cache::getTree( |
| 433 | 433 | __CLASS__, |
| 434 | 434 | 'plugins', |
| 435 | - array('importexport_helper_functions','_get_plugins'), |
|
| 435 | + array('importexport_helper_functions', '_get_plugins'), |
|
| 436 | 436 | array(array_keys($GLOBALS['egw_info']['apps']), array('import', 'export')), |
| 437 | 437 | self::CACHE_EXPIRATION |
| 438 | 438 | ); |
| 439 | 439 | $appnames = $_appname == 'all' ? array_keys($GLOBALS['egw_info']['apps']) : (array)$_appname; |
| 440 | - $types = $_type == 'all' ? array('import','export') : (array)$_type; |
|
| 440 | + $types = $_type == 'all' ? array('import', 'export') : (array)$_type; |
|
| 441 | 441 | |
| 442 | 442 | // Testing: comment out Api\Cache call, use this |
| 443 | 443 | //$plugins = self::_get_plugins($appnames, $types); |
| 444 | - foreach($plugins as $appname => $_types) { |
|
| 445 | - if(!in_array($appname, $appnames)) unset($plugins[$appname]); |
|
| 444 | + foreach ($plugins as $appname => $_types) { |
|
| 445 | + if (!in_array($appname, $appnames)) unset($plugins[$appname]); |
|
| 446 | 446 | } |
| 447 | - foreach($plugins as $appname => $types) { |
|
| 447 | + foreach ($plugins as $appname => $types) { |
|
| 448 | 448 | $plugins[$appname] = array_intersect_key($plugins[$appname], $types); |
| 449 | 449 | } |
| 450 | 450 | return $plugins; |
@@ -453,25 +453,25 @@ discard block |
||
| 453 | 453 | public static function _get_plugins(Array $appnames, Array $types) { |
| 454 | 454 | $plugins = array(); |
| 455 | 455 | foreach ($appnames as $appname) { |
| 456 | - if(array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) continue; |
|
| 456 | + if (array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) continue; |
|
| 457 | 457 | |
| 458 | - $appdir = EGW_INCLUDE_ROOT. "/$appname/inc"; |
|
| 459 | - if(!is_dir($appdir)) continue; |
|
| 458 | + $appdir = EGW_INCLUDE_ROOT."/$appname/inc"; |
|
| 459 | + if (!is_dir($appdir)) continue; |
|
| 460 | 460 | $d = dir($appdir); |
| 461 | 461 | |
| 462 | 462 | // step through each file in appdir |
| 463 | 463 | while (false !== ($entry = $d->read())) { |
| 464 | 464 | // Blacklisted? |
| 465 | - if(is_array(self::$blacklist_files[$appname]) && in_array($entry, self::$blacklist_files[$appname])) continue; |
|
| 465 | + if (is_array(self::$blacklist_files[$appname]) && in_array($entry, self::$blacklist_files[$appname])) continue; |
|
| 466 | 466 | if (!preg_match('/^class\.([^.]+)\.inc\.php$/', $entry, $matches)) continue; |
| 467 | 467 | $classname = $matches[1]; |
| 468 | - $file = $appdir. '/'. $entry; |
|
| 468 | + $file = $appdir.'/'.$entry; |
|
| 469 | 469 | |
| 470 | 470 | foreach ($types as $type) { |
| 471 | - if( !is_file($file) || strpos($entry, $type) === false || strpos($entry,'wizard') !== false) continue; |
|
| 471 | + if (!is_file($file) || strpos($entry, $type) === false || strpos($entry, 'wizard') !== false) continue; |
|
| 472 | 472 | require_once($file); |
| 473 | 473 | $reflectionClass = new ReflectionClass($classname); |
| 474 | - if($reflectionClass->IsInstantiable() && |
|
| 474 | + if ($reflectionClass->IsInstantiable() && |
|
| 475 | 475 | $reflectionClass->implementsInterface('importexport_iface_'.$type.'_plugin')) { |
| 476 | 476 | try { |
| 477 | 477 | $plugin_object = new $classname; |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | $d->close(); |
| 488 | 488 | |
| 489 | 489 | $config = Api\Config::read('importexport'); |
| 490 | - if($config['update'] == 'auto') { |
|
| 490 | + if ($config['update'] == 'auto') { |
|
| 491 | 491 | self::load_defaults($appname); |
| 492 | 492 | } |
| 493 | 493 | } |
@@ -502,37 +502,37 @@ discard block |
||
| 502 | 502 | * @return array $num => $appname |
| 503 | 503 | */ |
| 504 | 504 | public static function get_apps($_type, $ignore_acl = false) { |
| 505 | - $apps = array_keys(self::get_plugins('all',$_type)); |
|
| 506 | - if($ignore_acl) return $apps; |
|
| 505 | + $apps = array_keys(self::get_plugins('all', $_type)); |
|
| 506 | + if ($ignore_acl) return $apps; |
|
| 507 | 507 | |
| 508 | - foreach($apps as $key => $app) { |
|
| 509 | - if(!self::has_definitions($app, $_type)) unset($apps[$key]); |
|
| 508 | + foreach ($apps as $key => $app) { |
|
| 509 | + if (!self::has_definitions($app, $_type)) unset($apps[$key]); |
|
| 510 | 510 | } |
| 511 | 511 | return $apps; |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | public static function load_defaults($appname) { |
| 515 | 515 | // Check for new definitions to import from $appname/setup/*.xml |
| 516 | - $appdir = EGW_INCLUDE_ROOT. "/$appname/setup"; |
|
| 517 | - if(!is_dir($appdir)) return; |
|
| 516 | + $appdir = EGW_INCLUDE_ROOT."/$appname/setup"; |
|
| 517 | + if (!is_dir($appdir)) return; |
|
| 518 | 518 | $d = dir($appdir); |
| 519 | 519 | |
| 520 | 520 | // step through each file in app's setup |
| 521 | 521 | while (false !== ($entry = $d->read())) { |
| 522 | - $file = $appdir. '/'. $entry; |
|
| 523 | - list( $filename, $extension) = explode('.',$entry); |
|
| 524 | - if ( $extension != 'xml' ) continue; |
|
| 522 | + $file = $appdir.'/'.$entry; |
|
| 523 | + list($filename, $extension) = explode('.', $entry); |
|
| 524 | + if ($extension != 'xml') continue; |
|
| 525 | 525 | try { |
| 526 | 526 | // import will skip invalid files |
| 527 | - importexport_definitions_bo::import( $file ); |
|
| 527 | + importexport_definitions_bo::import($file); |
|
| 528 | 528 | } catch (Exception $e) { |
| 529 | - error_log(__CLASS__.__FUNCTION__. " import $appname definitions: " . $e->getMessage()); |
|
| 529 | + error_log(__CLASS__.__FUNCTION__." import $appname definitions: ".$e->getMessage()); |
|
| 530 | 530 | } |
| 531 | 531 | } |
| 532 | 532 | $d->close(); |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | - public static function guess_filetype( $_file ) { |
|
| 535 | + public static function guess_filetype($_file) { |
|
| 536 | 536 | |
| 537 | 537 | } |
| 538 | 538 | |
@@ -543,24 +543,24 @@ discard block |
||
| 543 | 543 | * @param string $_type {import | export | all} |
| 544 | 544 | * @return boolean |
| 545 | 545 | */ |
| 546 | - public static function has_definitions( $_appname = 'all', $_type = 'all' ) { |
|
| 546 | + public static function has_definitions($_appname = 'all', $_type = 'all') { |
|
| 547 | 547 | $definitions = Api\Cache::getSession( |
| 548 | 548 | __CLASS__, |
| 549 | 549 | 'has_definitions', |
| 550 | - array('importexport_helper_functions','_has_definitions'), |
|
| 550 | + array('importexport_helper_functions', '_has_definitions'), |
|
| 551 | 551 | array(array_keys($GLOBALS['egw_info']['apps']), array('import', 'export')), |
| 552 | 552 | self::CACHE_EXPIRATION |
| 553 | 553 | ); |
| 554 | 554 | $appnames = $_appname == 'all' ? array_keys($GLOBALS['egw_info']['apps']) : (array)$_appname; |
| 555 | - $types = $_type == 'all' ? array('import','export') : (array)$_type; |
|
| 555 | + $types = $_type == 'all' ? array('import', 'export') : (array)$_type; |
|
| 556 | 556 | |
| 557 | 557 | // Testing: Comment out cache call above, use this |
| 558 | 558 | //$definitions = self::_has_definitions($appnames, $types); |
| 559 | 559 | |
| 560 | - foreach($definitions as $appname => $_types) { |
|
| 561 | - if(!in_array($appname, $appnames)) unset($definitions[$appname]); |
|
| 560 | + foreach ($definitions as $appname => $_types) { |
|
| 561 | + if (!in_array($appname, $appnames)) unset($definitions[$appname]); |
|
| 562 | 562 | } |
| 563 | - foreach($definitions as $appname => $_types) { |
|
| 563 | + foreach ($definitions as $appname => $_types) { |
|
| 564 | 564 | $definitions[$appname] = array_intersect_key($definitions[$appname], array_flip($types)); |
| 565 | 565 | } |
| 566 | 566 | return count($definitions[$appname]) > 0; |
@@ -570,11 +570,11 @@ discard block |
||
| 570 | 570 | public static function _has_definitions(Array $appnames, Array $types) { |
| 571 | 571 | $def = new importexport_definitions_bo(array('application'=>$appnames, 'type' => $types)); |
| 572 | 572 | $list = array(); |
| 573 | - foreach((array)$def->get_definitions() as $id) { |
|
| 573 | + foreach ((array)$def->get_definitions() as $id) { |
|
| 574 | 574 | // Need to instanciate it to check, but if the user doesn't have permission, it throws an exception |
| 575 | 575 | try { |
| 576 | 576 | $definition = new importexport_definition($id); |
| 577 | - if($def->is_permitted($definition->get_record_array())) { |
|
| 577 | + if ($def->is_permitted($definition->get_record_array())) { |
|
| 578 | 578 | $list[$definition->application][$definition->type][] = $id; |
| 579 | 579 | } |
| 580 | 580 | } catch (Exception $e) { |
@@ -606,13 +606,13 @@ discard block |
||
| 606 | 606 | $plugin = is_object($plugin_name) ? $plugin_name : new $plugin_name(); |
| 607 | 607 | $plugin_name = get_class($plugin); |
| 608 | 608 | |
| 609 | - if($record_classname == null) $record_classname = $plugin::get_egw_record_class(); |
|
| 610 | - if(!class_exists($record_classname)) throw new Exception('Bad class name ' . $record_classname); |
|
| 609 | + if ($record_classname == null) $record_classname = $plugin::get_egw_record_class(); |
|
| 610 | + if (!class_exists($record_classname)) throw new Exception('Bad class name '.$record_classname); |
|
| 611 | 611 | |
| 612 | - if(!$wizard_plugin) |
|
| 612 | + if (!$wizard_plugin) |
|
| 613 | 613 | { |
| 614 | - $wizard_name = $app_name . '_wizard_' . str_replace($app_name . '_', '', $plugin_name); |
|
| 615 | - if(!class_exists($wizard_name)) throw new Exception('Bad wizard name ' . $wizard_name); |
|
| 614 | + $wizard_name = $app_name.'_wizard_'.str_replace($app_name.'_', '', $plugin_name); |
|
| 615 | + if (!class_exists($wizard_name)) throw new Exception('Bad wizard name '.$wizard_name); |
|
| 616 | 616 | $wizard_plugin = new $wizard_name; |
| 617 | 617 | } |
| 618 | 618 | } |
@@ -624,16 +624,16 @@ discard block |
||
| 624 | 624 | |
| 625 | 625 | // Get field -> label map and initialize fields using wizard field order |
| 626 | 626 | $fields = $export_fields = array(); |
| 627 | - if(method_exists($wizard_plugin, 'get_export_fields')) |
|
| 627 | + if (method_exists($wizard_plugin, 'get_export_fields')) |
|
| 628 | 628 | { |
| 629 | 629 | $fields = $export_fields = $wizard_plugin->get_export_fields(); |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | - foreach($record_classname::$types as $type => $type_fields) |
|
| 632 | + foreach ($record_classname::$types as $type => $type_fields) |
|
| 633 | 633 | { |
| 634 | 634 | // Only these for now, until filter methods for others are figured out |
| 635 | - if(!in_array($type, array('select','select-cat','select-account','date','date-time'))) continue; |
|
| 636 | - foreach($type_fields as $field_name) |
|
| 635 | + if (!in_array($type, array('select', 'select-cat', 'select-account', 'date', 'date-time'))) continue; |
|
| 636 | + foreach ($type_fields as $field_name) |
|
| 637 | 637 | { |
| 638 | 638 | $fields[$field_name] = array( |
| 639 | 639 | 'name' => $field_name, |
@@ -644,21 +644,21 @@ discard block |
||
| 644 | 644 | } |
| 645 | 645 | // Add custom fields |
| 646 | 646 | $custom = Api\Storage\Customfields::get($app_name); |
| 647 | - foreach($custom as $field_name => $settings) |
|
| 647 | + foreach ($custom as $field_name => $settings) |
|
| 648 | 648 | { |
| 649 | 649 | $settings['name'] = '#'.$field_name; |
| 650 | 650 | $fields['#'.$field_name] = $settings; |
| 651 | 651 | } |
| 652 | 652 | |
| 653 | - foreach($fields as $field_name => &$settings) { |
|
| 653 | + foreach ($fields as $field_name => &$settings) { |
|
| 654 | 654 | // Can't really filter on these (or at least no generic, sane way figured out yet) |
| 655 | - if(!is_array($settings) || in_array($settings['type'], array('text','button', 'label','url','url-email','url-phone','htmlarea'))) |
|
| 655 | + if (!is_array($settings) || in_array($settings['type'], array('text', 'button', 'label', 'url', 'url-email', 'url-phone', 'htmlarea'))) |
|
| 656 | 656 | { |
| 657 | 657 | unset($fields[$field_name]); |
| 658 | 658 | continue; |
| 659 | 659 | } |
| 660 | - if($settings['type'] == 'radio') $settings['type'] = 'select'; |
|
| 661 | - switch($settings['type']) |
|
| 660 | + if ($settings['type'] == 'radio') $settings['type'] = 'select'; |
|
| 661 | + switch ($settings['type']) |
|
| 662 | 662 | { |
| 663 | 663 | case 'checkbox': |
| 664 | 664 | // This isn't quite right - there's only 2 options and you can select both |
@@ -681,7 +681,7 @@ discard block |
||
| 681 | 681 | } |
| 682 | 682 | } |
| 683 | 683 | |
| 684 | - if(method_exists($plugin, 'get_filter_fields')) |
|
| 684 | + if (method_exists($plugin, 'get_filter_fields')) |
|
| 685 | 685 | { |
| 686 | 686 | $plugin->get_filter_fields($fields); |
| 687 | 687 | } |
@@ -697,65 +697,65 @@ discard block |
||
| 697 | 697 | */ |
| 698 | 698 | public static function date_rel2abs($value) |
| 699 | 699 | { |
| 700 | - if(is_array($value)) |
|
| 700 | + if (is_array($value)) |
|
| 701 | 701 | { |
| 702 | 702 | $abs = array(); |
| 703 | - foreach($value as $key => $val) |
|
| 703 | + foreach ($value as $key => $val) |
|
| 704 | 704 | { |
| 705 | 705 | $abs[$key] = self::date_rel2abs($val); |
| 706 | 706 | } |
| 707 | 707 | return $abs; |
| 708 | 708 | } |
| 709 | - if($date = self::$relative_dates[$value]) |
|
| 709 | + if ($date = self::$relative_dates[$value]) |
|
| 710 | 710 | { |
| 711 | - $year = (int) date('Y'); |
|
| 712 | - $month = (int) date('m'); |
|
| 713 | - $day = (int) date('d'); |
|
| 714 | - $today = mktime(0,0,0,date('m'),date('d'),date('Y')); |
|
| 711 | + $year = (int)date('Y'); |
|
| 712 | + $month = (int)date('m'); |
|
| 713 | + $day = (int)date('d'); |
|
| 714 | + $today = mktime(0, 0, 0, date('m'), date('d'), date('Y')); |
|
| 715 | 715 | |
| 716 | - list($syear,$smonth,$sday,$sweek,$eyear,$emonth,$eday,$eweek) = $date; |
|
| 716 | + list($syear, $smonth, $sday, $sweek, $eyear, $emonth, $eday, $eweek) = $date; |
|
| 717 | 717 | |
| 718 | - if(stripos($value, 'quarter') !== false) |
|
| 718 | + if (stripos($value, 'quarter') !== false) |
|
| 719 | 719 | { |
| 720 | 720 | // Handle quarters |
| 721 | - $start = mktime(0,0,0,((int)floor(($smonth+$month) / 3.1)) * 3 + 1, 1, $year); |
|
| 722 | - $end = mktime(0,0,0,((int)floor(($emonth+$month) / 3.1)+1) * 3 + 1, 1, $year); |
|
| 721 | + $start = mktime(0, 0, 0, ((int)floor(($smonth + $month) / 3.1)) * 3 + 1, 1, $year); |
|
| 722 | + $end = mktime(0, 0, 0, ((int)floor(($emonth + $month) / 3.1) + 1) * 3 + 1, 1, $year); |
|
| 723 | 723 | } |
| 724 | 724 | elseif ($syear || $eyear) |
| 725 | 725 | { |
| 726 | - $start = mktime(0,0,0,1,1,$syear+$year); |
|
| 727 | - $end = mktime(0,0,0,1,1,$eyear+$year); |
|
| 726 | + $start = mktime(0, 0, 0, 1, 1, $syear + $year); |
|
| 727 | + $end = mktime(0, 0, 0, 1, 1, $eyear + $year); |
|
| 728 | 728 | } |
| 729 | 729 | elseif ($smonth || $emonth) |
| 730 | 730 | { |
| 731 | - $start = mktime(0,0,0,$smonth+$month,1,$year); |
|
| 732 | - $end = mktime(0,0,0,$emonth+$month,1,$year); |
|
| 731 | + $start = mktime(0, 0, 0, $smonth + $month, 1, $year); |
|
| 732 | + $end = mktime(0, 0, 0, $emonth + $month, 1, $year); |
|
| 733 | 733 | } |
| 734 | 734 | elseif ($sday || $eday) |
| 735 | 735 | { |
| 736 | - $start = mktime(0,0,0,$month,$sday+$day,$year); |
|
| 737 | - $end = mktime(0,0,0,$month,$eday+$day,$year); |
|
| 736 | + $start = mktime(0, 0, 0, $month, $sday + $day, $year); |
|
| 737 | + $end = mktime(0, 0, 0, $month, $eday + $day, $year); |
|
| 738 | 738 | } |
| 739 | 739 | elseif ($sweek || $eweek) |
| 740 | 740 | { |
| 741 | - $wday = (int) date('w'); // 0=sun, ..., 6=sat |
|
| 742 | - switch($GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts']) |
|
| 741 | + $wday = (int)date('w'); // 0=sun, ..., 6=sat |
|
| 742 | + switch ($GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts']) |
|
| 743 | 743 | { |
| 744 | 744 | case 'Sunday': |
| 745 | - $weekstart = $today - $wday * 24*60*60; |
|
| 745 | + $weekstart = $today - $wday * 24 * 60 * 60; |
|
| 746 | 746 | break; |
| 747 | 747 | case 'Saturday': |
| 748 | - $weekstart = $today - (6-$wday) * 24*60*60; |
|
| 748 | + $weekstart = $today - (6 - $wday) * 24 * 60 * 60; |
|
| 749 | 749 | break; |
| 750 | 750 | case 'Moday': |
| 751 | 751 | default: |
| 752 | - $weekstart = $today - ($wday ? $wday-1 : 6) * 24*60*60; |
|
| 752 | + $weekstart = $today - ($wday ? $wday - 1 : 6) * 24 * 60 * 60; |
|
| 753 | 753 | break; |
| 754 | 754 | } |
| 755 | - $start = $weekstart + $sweek*7*24*60*60; |
|
| 756 | - $end = $weekstart + $eweek*7*24*60*60; |
|
| 755 | + $start = $weekstart + $sweek * 7 * 24 * 60 * 60; |
|
| 756 | + $end = $weekstart + $eweek * 7 * 24 * 60 * 60; |
|
| 757 | 757 | } |
| 758 | - $end_param = $end - 24*60*60; |
|
| 758 | + $end_param = $end - 24 * 60 * 60; |
|
| 759 | 759 | |
| 760 | 760 | // Take 1 second off end to provide an inclusive range.for filtering |
| 761 | 761 | $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 |
@@ -175,19 +193,22 @@ discard block |
||
| 175 | 193 | $account_lid = trim(substr(trim($account_lid), strlen(lang('Group')))); |
| 176 | 194 | } |
| 177 | 195 | |
| 178 | - if ( $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid )) { |
|
| 196 | + if ( $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid )) |
|
| 197 | + { |
|
| 179 | 198 | $account_ids[] = $account_id; |
| 180 | 199 | unset($account_lids[$key]); |
| 181 | 200 | continue; |
| 182 | 201 | } |
| 183 | - if ( $account_id = $GLOBALS['egw']->accounts->name2id( trim($account_lid), 'account_fullname' )) { |
|
| 202 | + if ( $account_id = $GLOBALS['egw']->accounts->name2id( trim($account_lid), 'account_fullname' )) |
|
| 203 | + { |
|
| 184 | 204 | $account_ids[] = $account_id; |
| 185 | 205 | unset($account_lids[$key]); |
| 186 | 206 | continue; |
| 187 | 207 | } |
| 188 | 208 | |
| 189 | 209 | // Handle groups listed as Group, <name> |
| 190 | - if ( $account_lids[$key][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid)) { |
|
| 210 | + if ( $account_lids[$key][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid)) |
|
| 211 | + { |
|
| 191 | 212 | $account_ids[] = $account_id; |
| 192 | 213 | unset($account_lids[$key-1]); |
| 193 | 214 | unset($account_lids[$key]); |
@@ -211,10 +232,13 @@ discard block |
||
| 211 | 232 | * @param mixed $_account_ids comma seperated list or array with ids |
| 212 | 233 | * @return mixed comma seperated list or array with lids |
| 213 | 234 | */ |
| 214 | - public static function account_id2name( $_account_id ) { |
|
| 235 | + public static function account_id2name( $_account_id ) |
|
| 236 | + { |
|
| 215 | 237 | $account_ids = is_array( $_account_id ) ? $_account_id : explode( ',', $_account_id ); |
| 216 | - foreach ( $account_ids as $account_id ) { |
|
| 217 | - if ( $account_lid = $GLOBALS['egw']->accounts->id2name( $account_id )) { |
|
| 238 | + foreach ( $account_ids as $account_id ) |
|
| 239 | + { |
|
| 240 | + if ( $account_lid = $GLOBALS['egw']->accounts->id2name( $account_id )) |
|
| 241 | + { |
|
| 218 | 242 | $account_lids[] = $account_lid; |
| 219 | 243 | } |
| 220 | 244 | } |
@@ -227,9 +251,11 @@ discard block |
||
| 227 | 251 | * @param mixed _cat_ids comma seperated list or array |
| 228 | 252 | * @return mixed comma seperated list or array with cat_names |
| 229 | 253 | */ |
| 230 | - public static function cat_id2name( $_cat_ids ) { |
|
| 254 | + public static function cat_id2name( $_cat_ids ) |
|
| 255 | + { |
|
| 231 | 256 | $cat_ids = is_array( $_cat_ids ) ? $_cat_ids : explode( ',', $_cat_ids ); |
| 232 | - foreach ( $cat_ids as $cat_id ) { |
|
| 257 | + foreach ( $cat_ids as $cat_id ) |
|
| 258 | + { |
|
| 233 | 259 | $cat_names[] = Api\Categories::id2name( (int)$cat_id ); |
| 234 | 260 | } |
| 235 | 261 | return is_array( $_cat_ids ) ? $cat_names : implode(',',(array)$cat_names); |
@@ -243,14 +269,20 @@ discard block |
||
| 243 | 269 | * @param int $parent Optional parent ID to use for new categories |
| 244 | 270 | * @return mixed comma seperated list or array with cat_ids |
| 245 | 271 | */ |
| 246 | - public static function cat_name2id( $_cat_names, $parent = 0 ) { |
|
| 272 | + public static function cat_name2id( $_cat_names, $parent = 0 ) |
|
| 273 | + { |
|
| 247 | 274 | $cats = new Api\Categories(); // uses current user and app (egw_info[flags][currentapp]) |
| 248 | 275 | |
| 249 | 276 | $cat_names = is_array( $_cat_names ) ? $_cat_names : explode( ',', $_cat_names ); |
| 250 | - foreach ( $cat_names as $cat_name ) { |
|
| 277 | + foreach ( $cat_names as $cat_name ) |
|
| 278 | + { |
|
| 251 | 279 | $cat_name = trim($cat_name); |
| 252 | - if ( $cat_name == '' ) continue; |
|
| 253 | - if ( ( $cat_id = $cats->name2id( $cat_name ) ) == 0 && !self::$dry_run) { |
|
| 280 | + if ( $cat_name == '' ) |
|
| 281 | + { |
|
| 282 | + continue; |
|
| 283 | + } |
|
| 284 | + if ( ( $cat_id = $cats->name2id( $cat_name ) ) == 0 && !self::$dry_run) |
|
| 285 | + { |
|
| 254 | 286 | $cat_id = $cats->add( array( |
| 255 | 287 | 'name' => $cat_name, |
| 256 | 288 | 'parent' => $parent, |
@@ -299,8 +331,12 @@ discard block |
||
| 299 | 331 | * @param object &$cclass calling class to process the '@ evals' |
| 300 | 332 | * @return bool |
| 301 | 333 | */ |
| 302 | - public static function conversion( &$_record, $_conversion, &$_cclass = null ) { |
|
| 303 | - if (empty( $_conversion ) ) return $_record; |
|
| 334 | + public static function conversion( &$_record, $_conversion, &$_cclass = null ) |
|
| 335 | + { |
|
| 336 | + if (empty( $_conversion ) ) |
|
| 337 | + { |
|
| 338 | + return $_record; |
|
| 339 | + } |
|
| 304 | 340 | |
| 305 | 341 | self::$cclass =& $_cclass; |
| 306 | 342 | |
@@ -312,15 +348,21 @@ discard block |
||
| 312 | 348 | $CntlnCLPre = '|TCnCL{'; // Like |C{ but allowes CR and LF |
| 313 | 349 | $INE = '|INE{'; // Only insert if stuff in ^^ is not empty |
| 314 | 350 | |
| 315 | - foreach ( $_conversion as $idx => $conversion_string ) { |
|
| 316 | - if ( empty( $conversion_string ) ) continue; |
|
| 351 | + foreach ( $_conversion as $idx => $conversion_string ) |
|
| 352 | + { |
|
| 353 | + if ( empty( $conversion_string ) ) |
|
| 354 | + { |
|
| 355 | + continue; |
|
| 356 | + } |
|
| 317 | 357 | |
| 318 | 358 | // fetch patterns ($rvalues) |
| 319 | 359 | $rvalues = array(); |
| 320 | 360 | $pat_reps = explode( $PSep, stripslashes( $conversion_string ) ); |
| 321 | - foreach( $pat_reps as $k => $pat_rep ) { |
|
| 361 | + foreach( $pat_reps as $k => $pat_rep ) |
|
| 362 | + { |
|
| 322 | 363 | list( $pattern, $replace ) = explode( $ASep, $pat_rep, 2 ); |
| 323 | - if( $replace == '' ) { |
|
| 364 | + if( $replace == '' ) |
|
| 365 | + { |
|
| 324 | 366 | $replace = $pattern; $pattern = '^.*$'; |
| 325 | 367 | } |
| 326 | 368 | $rvalues[$pattern] = $replace; // replace two with only one, added by the form |
@@ -330,19 +372,23 @@ discard block |
||
| 330 | 372 | $val = array_key_exists( $idx, $_record ) ? $_record[$idx] : ''; |
| 331 | 373 | |
| 332 | 374 | $c_functions = array('cat', 'account', 'strtotime', 'list'); |
| 333 | - if($_cclass) { |
|
| 375 | + if($_cclass) |
|
| 376 | + { |
|
| 334 | 377 | // Add in additional methods |
| 335 | 378 | $reflection = new ReflectionClass(get_class($_cclass)); |
| 336 | 379 | $methods = $reflection->getMethods(ReflectionMethod::IS_STATIC); |
| 337 | - foreach($methods as $method) { |
|
| 380 | + foreach($methods as $method) |
|
| 381 | + { |
|
| 338 | 382 | $c_functions[] = $method->name; |
| 339 | 383 | } |
| 340 | 384 | } |
| 341 | 385 | $c_functions = implode('|', $c_functions); |
| 342 | - foreach ( $rvalues as $pattern => $replace ) { |
|
| 386 | + foreach ( $rvalues as $pattern => $replace ) |
|
| 387 | + { |
|
| 343 | 388 | // Allow to include record indexes in pattern |
| 344 | 389 | $reg = '/\|\[([0-9]+)\]/'; |
| 345 | - while( preg_match( $reg, $pattern, $vars ) ) { |
|
| 390 | + while( preg_match( $reg, $pattern, $vars ) ) |
|
| 391 | + { |
|
| 346 | 392 | // expand all _record fields |
| 347 | 393 | $pattern = str_replace( |
| 348 | 394 | $CPre . $vars[1] . $CPos, |
@@ -350,12 +396,14 @@ discard block |
||
| 350 | 396 | $pattern |
| 351 | 397 | ); |
| 352 | 398 | } |
| 353 | - if( preg_match('/'. (string)$pattern.'/', $val) ) { |
|
| 399 | + if( preg_match('/'. (string)$pattern.'/', $val) ) |
|
| 400 | + { |
|
| 354 | 401 | |
| 355 | 402 | $val = preg_replace( '/'.(string)$pattern.'/', $replace, (string)$val ); |
| 356 | 403 | |
| 357 | 404 | $reg = '/\|\[([a-zA-Z_0-9]+)\]/'; |
| 358 | - while( preg_match( $reg, $val, $vars ) ) { |
|
| 405 | + while( preg_match( $reg, $val, $vars ) ) |
|
| 406 | + { |
|
| 359 | 407 | // expand all _record fields |
| 360 | 408 | $val = str_replace( |
| 361 | 409 | $CPre . $vars[1] . $CPos, |
@@ -382,11 +430,13 @@ discard block |
||
| 382 | 430 | * |
| 383 | 431 | * @param array $_matches |
| 384 | 432 | */ |
| 385 | - private static function c2_dispatcher( $_matches ) { |
|
| 433 | + private static function c2_dispatcher( $_matches ) |
|
| 434 | + { |
|
| 386 | 435 | $action = &$_matches[1]; // cat or account ... |
| 387 | 436 | $data = &$_matches[2]; // datas for action |
| 388 | 437 | |
| 389 | - switch ( $action ) { |
|
| 438 | + switch ( $action ) |
|
| 439 | + { |
|
| 390 | 440 | case 'strtotime' : |
| 391 | 441 | list( $string, $format ) = explode( ',', $data ); |
| 392 | 442 | return self::custom_strtotime( trim( $string ), trim( $format ) ); |
@@ -396,22 +446,28 @@ discard block |
||
| 396 | 446 | // 1 based indexing for user ease |
| 397 | 447 | return $exploded[$index - 1]; |
| 398 | 448 | default : |
| 399 | - if(self::$cclass && method_exists(self::$cclass, $action)) { |
|
| 449 | + if(self::$cclass && method_exists(self::$cclass, $action)) |
|
| 450 | + { |
|
| 400 | 451 | $class = get_class(self::$cclass); |
| 401 | 452 | return call_user_func("$class::$action", $data); |
| 402 | 453 | } |
| 403 | 454 | $method = (string)$action. ( is_int( $data ) ? '_id2name' : '_name2id' ); |
| 404 | - if(self::$cclass && method_exists(self::$cclass, $method)) { |
|
| 455 | + if(self::$cclass && method_exists(self::$cclass, $method)) |
|
| 456 | + { |
|
| 405 | 457 | $class = get_class(self::$cclass); |
| 406 | 458 | return call_user_func("$class::$action", $data); |
| 407 | - } else { |
|
| 459 | + } |
|
| 460 | + else |
|
| 461 | + { |
|
| 408 | 462 | return self::$method( $data ); |
| 409 | 463 | } |
| 410 | 464 | } |
| 411 | 465 | } |
| 412 | 466 | |
| 413 | - private static function strclean( $_matches ) { |
|
| 414 | - switch( $_matches[1] ) { |
|
| 467 | + private static function strclean( $_matches ) |
|
| 468 | + { |
|
| 469 | + switch( $_matches[1] ) |
|
| 470 | + { |
|
| 415 | 471 | case '|T{' : return trim( $_matches[2] ); |
| 416 | 472 | case '|TC{' : return trim( preg_replace( '/[\x01-\x1F]+/', '', $_matches[2] ) ); |
| 417 | 473 | case '|TCnCL{' : return trim( preg_replace( '/[\x01-\x09\x11\x12\x14-\x1F]+/', '', $_matches[2] ) ); |
@@ -428,7 +484,8 @@ discard block |
||
| 428 | 484 | * @param string $_appname {<appname> | all} |
| 429 | 485 | * @return array(<appname> => array( <type> => array(<plugin> => <title>))) |
| 430 | 486 | */ |
| 431 | - public static function get_plugins( $_appname = 'all', $_type = 'all' ) { |
|
| 487 | + public static function get_plugins( $_appname = 'all', $_type = 'all' ) |
|
| 488 | + { |
|
| 432 | 489 | $plugins = Api\Cache::getTree( |
| 433 | 490 | __CLASS__, |
| 434 | 491 | 'plugins', |
@@ -441,38 +498,63 @@ discard block |
||
| 441 | 498 | |
| 442 | 499 | // Testing: comment out Api\Cache call, use this |
| 443 | 500 | //$plugins = self::_get_plugins($appnames, $types); |
| 444 | - foreach($plugins as $appname => $_types) { |
|
| 445 | - if(!in_array($appname, $appnames)) unset($plugins[$appname]); |
|
| 501 | + foreach($plugins as $appname => $_types) |
|
| 502 | + { |
|
| 503 | + if(!in_array($appname, $appnames)) |
|
| 504 | + { |
|
| 505 | + unset($plugins[$appname]); |
|
| 506 | + } |
|
| 446 | 507 | } |
| 447 | - foreach($plugins as $appname => $types) { |
|
| 508 | + foreach($plugins as $appname => $types) |
|
| 509 | + { |
|
| 448 | 510 | $plugins[$appname] = array_intersect_key($plugins[$appname], $types); |
| 449 | 511 | } |
| 450 | 512 | return $plugins; |
| 451 | 513 | } |
| 452 | 514 | |
| 453 | - public static function _get_plugins(Array $appnames, Array $types) { |
|
| 515 | + public static function _get_plugins(Array $appnames, Array $types) |
|
| 516 | + { |
|
| 454 | 517 | $plugins = array(); |
| 455 | - foreach ($appnames as $appname) { |
|
| 456 | - if(array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) continue; |
|
| 518 | + foreach ($appnames as $appname) |
|
| 519 | + { |
|
| 520 | + if(array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) |
|
| 521 | + { |
|
| 522 | + continue; |
|
| 523 | + } |
|
| 457 | 524 | |
| 458 | 525 | $appdir = EGW_INCLUDE_ROOT. "/$appname/inc"; |
| 459 | - if(!is_dir($appdir)) continue; |
|
| 526 | + if(!is_dir($appdir)) |
|
| 527 | + { |
|
| 528 | + continue; |
|
| 529 | + } |
|
| 460 | 530 | $d = dir($appdir); |
| 461 | 531 | |
| 462 | 532 | // step through each file in appdir |
| 463 | - while (false !== ($entry = $d->read())) { |
|
| 533 | + while (false !== ($entry = $d->read())) |
|
| 534 | + { |
|
| 464 | 535 | // Blacklisted? |
| 465 | - if(is_array(self::$blacklist_files[$appname]) && in_array($entry, self::$blacklist_files[$appname])) continue; |
|
| 466 | - if (!preg_match('/^class\.([^.]+)\.inc\.php$/', $entry, $matches)) continue; |
|
| 536 | + if(is_array(self::$blacklist_files[$appname]) && in_array($entry, self::$blacklist_files[$appname])) |
|
| 537 | + { |
|
| 538 | + continue; |
|
| 539 | + } |
|
| 540 | + if (!preg_match('/^class\.([^.]+)\.inc\.php$/', $entry, $matches)) |
|
| 541 | + { |
|
| 542 | + continue; |
|
| 543 | + } |
|
| 467 | 544 | $classname = $matches[1]; |
| 468 | 545 | $file = $appdir. '/'. $entry; |
| 469 | 546 | |
| 470 | - foreach ($types as $type) { |
|
| 471 | - if( !is_file($file) || strpos($entry, $type) === false || strpos($entry,'wizard') !== false) continue; |
|
| 547 | + foreach ($types as $type) |
|
| 548 | + { |
|
| 549 | + if( !is_file($file) || strpos($entry, $type) === false || strpos($entry,'wizard') !== false) |
|
| 550 | + { |
|
| 551 | + continue; |
|
| 552 | + } |
|
| 472 | 553 | require_once($file); |
| 473 | 554 | $reflectionClass = new ReflectionClass($classname); |
| 474 | 555 | if($reflectionClass->IsInstantiable() && |
| 475 | - $reflectionClass->implementsInterface('importexport_iface_'.$type.'_plugin')) { |
|
| 556 | + $reflectionClass->implementsInterface('importexport_iface_'.$type.'_plugin')) |
|
| 557 | + { |
|
| 476 | 558 | try { |
| 477 | 559 | $plugin_object = new $classname; |
| 478 | 560 | } |
@@ -487,7 +569,8 @@ discard block |
||
| 487 | 569 | $d->close(); |
| 488 | 570 | |
| 489 | 571 | $config = Api\Config::read('importexport'); |
| 490 | - if($config['update'] == 'auto') { |
|
| 572 | + if($config['update'] == 'auto') |
|
| 573 | + { |
|
| 491 | 574 | self::load_defaults($appname); |
| 492 | 575 | } |
| 493 | 576 | } |
@@ -501,38 +584,56 @@ discard block |
||
| 501 | 584 | * @param string $_type |
| 502 | 585 | * @return array $num => $appname |
| 503 | 586 | */ |
| 504 | - public static function get_apps($_type, $ignore_acl = false) { |
|
| 587 | + public static function get_apps($_type, $ignore_acl = false) |
|
| 588 | + { |
|
| 505 | 589 | $apps = array_keys(self::get_plugins('all',$_type)); |
| 506 | - if($ignore_acl) return $apps; |
|
| 590 | + if($ignore_acl) |
|
| 591 | + { |
|
| 592 | + return $apps; |
|
| 593 | + } |
|
| 507 | 594 | |
| 508 | - foreach($apps as $key => $app) { |
|
| 509 | - if(!self::has_definitions($app, $_type)) unset($apps[$key]); |
|
| 595 | + foreach($apps as $key => $app) |
|
| 596 | + { |
|
| 597 | + if(!self::has_definitions($app, $_type)) |
|
| 598 | + { |
|
| 599 | + unset($apps[$key]); |
|
| 600 | + } |
|
| 510 | 601 | } |
| 511 | 602 | return $apps; |
| 512 | 603 | } |
| 513 | 604 | |
| 514 | - public static function load_defaults($appname) { |
|
| 605 | + public static function load_defaults($appname) |
|
| 606 | + { |
|
| 515 | 607 | // Check for new definitions to import from $appname/setup/*.xml |
| 516 | 608 | $appdir = EGW_INCLUDE_ROOT. "/$appname/setup"; |
| 517 | - if(!is_dir($appdir)) return; |
|
| 609 | + if(!is_dir($appdir)) |
|
| 610 | + { |
|
| 611 | + return; |
|
| 612 | + } |
|
| 518 | 613 | $d = dir($appdir); |
| 519 | 614 | |
| 520 | 615 | // step through each file in app's setup |
| 521 | - while (false !== ($entry = $d->read())) { |
|
| 616 | + while (false !== ($entry = $d->read())) |
|
| 617 | + { |
|
| 522 | 618 | $file = $appdir. '/'. $entry; |
| 523 | 619 | list( $filename, $extension) = explode('.',$entry); |
| 524 | - if ( $extension != 'xml' ) continue; |
|
| 620 | + if ( $extension != 'xml' ) |
|
| 621 | + { |
|
| 622 | + continue; |
|
| 623 | + } |
|
| 525 | 624 | try { |
| 526 | 625 | // import will skip invalid files |
| 527 | 626 | importexport_definitions_bo::import( $file ); |
| 528 | - } catch (Exception $e) { |
|
| 627 | + } |
|
| 628 | + catch (Exception $e) { |
|
| 529 | 629 | error_log(__CLASS__.__FUNCTION__. " import $appname definitions: " . $e->getMessage()); |
| 530 | 630 | } |
| 531 | 631 | } |
| 532 | 632 | $d->close(); |
| 533 | 633 | } |
| 534 | 634 | |
| 535 | - public static function guess_filetype( $_file ) { |
|
| 635 | + public static function guess_filetype( $_file ) |
|
| 636 | + { |
|
| 536 | 637 | |
| 537 | 638 | } |
| 538 | 639 | |
@@ -543,7 +644,8 @@ discard block |
||
| 543 | 644 | * @param string $_type {import | export | all} |
| 544 | 645 | * @return boolean |
| 545 | 646 | */ |
| 546 | - public static function has_definitions( $_appname = 'all', $_type = 'all' ) { |
|
| 647 | + public static function has_definitions( $_appname = 'all', $_type = 'all' ) |
|
| 648 | + { |
|
| 547 | 649 | $definitions = Api\Cache::getSession( |
| 548 | 650 | __CLASS__, |
| 549 | 651 | 'has_definitions', |
@@ -557,27 +659,36 @@ discard block |
||
| 557 | 659 | // Testing: Comment out cache call above, use this |
| 558 | 660 | //$definitions = self::_has_definitions($appnames, $types); |
| 559 | 661 | |
| 560 | - foreach($definitions as $appname => $_types) { |
|
| 561 | - if(!in_array($appname, $appnames)) unset($definitions[$appname]); |
|
| 662 | + foreach($definitions as $appname => $_types) |
|
| 663 | + { |
|
| 664 | + if(!in_array($appname, $appnames)) |
|
| 665 | + { |
|
| 666 | + unset($definitions[$appname]); |
|
| 667 | + } |
|
| 562 | 668 | } |
| 563 | - foreach($definitions as $appname => $_types) { |
|
| 669 | + foreach($definitions as $appname => $_types) |
|
| 670 | + { |
|
| 564 | 671 | $definitions[$appname] = array_intersect_key($definitions[$appname], array_flip($types)); |
| 565 | 672 | } |
| 566 | 673 | return count($definitions[$appname]) > 0; |
| 567 | 674 | } |
| 568 | 675 | |
| 569 | 676 | // Api\Cache needs this public |
| 570 | - public static function _has_definitions(Array $appnames, Array $types) { |
|
| 677 | + public static function _has_definitions(Array $appnames, Array $types) |
|
| 678 | + { |
|
| 571 | 679 | $def = new importexport_definitions_bo(array('application'=>$appnames, 'type' => $types)); |
| 572 | 680 | $list = array(); |
| 573 | - foreach((array)$def->get_definitions() as $id) { |
|
| 681 | + foreach((array)$def->get_definitions() as $id) |
|
| 682 | + { |
|
| 574 | 683 | // Need to instanciate it to check, but if the user doesn't have permission, it throws an exception |
| 575 | 684 | try { |
| 576 | 685 | $definition = new importexport_definition($id); |
| 577 | - if($def->is_permitted($definition->get_record_array())) { |
|
| 686 | + if($def->is_permitted($definition->get_record_array())) |
|
| 687 | + { |
|
| 578 | 688 | $list[$definition->application][$definition->type][] = $id; |
| 579 | 689 | } |
| 580 | - } catch (Exception $e) { |
|
| 690 | + } |
|
| 691 | + catch (Exception $e) { |
|
| 581 | 692 | // That one doesn't work, keep going |
| 582 | 693 | } |
| 583 | 694 | $definition = null; |
@@ -606,13 +717,22 @@ discard block |
||
| 606 | 717 | $plugin = is_object($plugin_name) ? $plugin_name : new $plugin_name(); |
| 607 | 718 | $plugin_name = get_class($plugin); |
| 608 | 719 | |
| 609 | - if($record_classname == null) $record_classname = $plugin::get_egw_record_class(); |
|
| 610 | - if(!class_exists($record_classname)) throw new Exception('Bad class name ' . $record_classname); |
|
| 720 | + if($record_classname == null) |
|
| 721 | + { |
|
| 722 | + $record_classname = $plugin::get_egw_record_class(); |
|
| 723 | + } |
|
| 724 | + if(!class_exists($record_classname)) |
|
| 725 | + { |
|
| 726 | + throw new Exception('Bad class name ' . $record_classname); |
|
| 727 | + } |
|
| 611 | 728 | |
| 612 | 729 | if(!$wizard_plugin) |
| 613 | 730 | { |
| 614 | 731 | $wizard_name = $app_name . '_wizard_' . str_replace($app_name . '_', '', $plugin_name); |
| 615 | - if(!class_exists($wizard_name)) throw new Exception('Bad wizard name ' . $wizard_name); |
|
| 732 | + if(!class_exists($wizard_name)) |
|
| 733 | + { |
|
| 734 | + throw new Exception('Bad wizard name ' . $wizard_name); |
|
| 735 | + } |
|
| 616 | 736 | $wizard_plugin = new $wizard_name; |
| 617 | 737 | } |
| 618 | 738 | } |
@@ -632,7 +752,10 @@ discard block |
||
| 632 | 752 | foreach($record_classname::$types as $type => $type_fields) |
| 633 | 753 | { |
| 634 | 754 | // Only these for now, until filter methods for others are figured out |
| 635 | - if(!in_array($type, array('select','select-cat','select-account','date','date-time'))) continue; |
|
| 755 | + if(!in_array($type, array('select','select-cat','select-account','date','date-time'))) |
|
| 756 | + { |
|
| 757 | + continue; |
|
| 758 | + } |
|
| 636 | 759 | foreach($type_fields as $field_name) |
| 637 | 760 | { |
| 638 | 761 | $fields[$field_name] = array( |
@@ -650,14 +773,18 @@ discard block |
||
| 650 | 773 | $fields['#'.$field_name] = $settings; |
| 651 | 774 | } |
| 652 | 775 | |
| 653 | - foreach($fields as $field_name => &$settings) { |
|
| 776 | + foreach($fields as $field_name => &$settings) |
|
| 777 | + { |
|
| 654 | 778 | // Can't really filter on these (or at least no generic, sane way figured out yet) |
| 655 | 779 | if(!is_array($settings) || in_array($settings['type'], array('text','button', 'label','url','url-email','url-phone','htmlarea'))) |
| 656 | 780 | { |
| 657 | 781 | unset($fields[$field_name]); |
| 658 | 782 | continue; |
| 659 | 783 | } |
| 660 | - if($settings['type'] == 'radio') $settings['type'] = 'select'; |
|
| 784 | + if($settings['type'] == 'radio') |
|
| 785 | + { |
|
| 786 | + $settings['type'] = 'select'; |
|
| 787 | + } |
|
| 661 | 788 | switch($settings['type']) |
| 662 | 789 | { |
| 663 | 790 | case 'checkbox': |