Completed
Push — 14.2 ( c53e78...a8db63 )
by Ralf
29:08
created
filemanager/inc/class.filemanager_hooks.inc.php 5 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@
 block discarded – undo
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
 	{
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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',
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -34,19 +34,19 @@  discard block
 block discarded – undo
34 34
 		//echo "<p>admin_prefs_sidebox_hooks::all_hooks(".print_r($args,True).") appname='$appname', location='$location'</p>\n";
35 35
 		$config = config::read(self::$appname);
36 36
 		if (!empty($config['max_folderlinks'])) self::$foldercount = (int)$config['max_folderlinks'];
37
-		$file_prefs    = &$GLOBALS['egw_info']['user']['preferences'][self::$appname];
37
+		$file_prefs = &$GLOBALS['egw_info']['user']['preferences'][self::$appname];
38 38
 		if ($location == 'sidebox_menu')
39 39
 		{
40
-			$title = $GLOBALS['egw_info']['apps'][self::$appname]['title'] . ' '. lang('Menu');
40
+			$title = $GLOBALS['egw_info']['apps'][self::$appname]['title'].' '.lang('Menu');
41 41
 			$file = array();
42
-			if($GLOBALS['egw_info']['apps']['stylite'])
42
+			if ($GLOBALS['egw_info']['apps']['stylite'])
43 43
 			{
44 44
 				// add "file a file" (upload) dialog
45 45
 				$file[] = array(
46 46
 					'text' => 'File a file',
47
-					'link' => "javascript:egw_openWindowCentered2('".egw::link('/index.php',array(
47
+					'link' => "javascript:egw_openWindowCentered2('".egw::link('/index.php', array(
48 48
 							'menuaction'=>'stylite.stylite_filemanager.upload',
49
-						),false)."','_blank',550,350)",
49
+						), false)."','_blank',550,350)",
50 50
 					'app'  => 'phpgwapi',
51 51
 					'icon' => 'upload',
52 52
 				);
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
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' => html::select('filemanager_view',filemanager_ui::get_view(),filemanager_ui::$views,false,
59
+					'text' => 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
 block discarded – undo
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
-			if (!empty($file_prefs['startfolder'])) $file['Startfolder']= egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$file_prefs['startfolder'],'ajax'=>'true'));
79
-			for ($i=1; $i<=self::$foldercount; $i++)
78
+			if (!empty($file_prefs['startfolder'])) $file['Startfolder'] = egw::link('/index.php', array('menuaction'=>self::$appname.'.filemanager_ui.index', 'path'=>$file_prefs['startfolder'], 'ajax'=>'true'));
79
+			for ($i = 1; $i <= self::$foldercount; $i++)
80 80
 			{
81 81
 				if (!empty($file_prefs['folderlink'.$i]))
82 82
 				{
83
-					$foldername = array_pop(explode('/',$file_prefs['folderlink'.$i]));
84
-					$file[lang('Link %1: %2',$i,$foldername)]= egw::link('/index.php',array(
83
+					$foldername = array_pop(explode('/', $file_prefs['folderlink'.$i]));
84
+					$file[lang('Link %1: %2', $i, $foldername)] = egw::link('/index.php', array(
85 85
 						'menuaction' => self::$appname.'.filemanager_ui.index',
86 86
 						'path'       => $file_prefs['folderlink'.$i],
87 87
 						'nolang'     => true,
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
 					));
90 90
 				}
91 91
 			}
92
-			$file['Placeholders'] = egw::link('/index.php','menuaction=filemanager.filemanager_merge.show_replacements');
93
-			$file['Shared files'] = egw::link('/index.php','menuaction=filemanager.filemanager_shares.index&ajax=true');
94
-			display_sidebox(self::$appname,$title,$file);
92
+			$file['Placeholders'] = egw::link('/index.php', 'menuaction=filemanager.filemanager_merge.show_replacements');
93
+			$file['Shared files'] = egw::link('/index.php', 'menuaction=filemanager.filemanager_shares.index&ajax=true');
94
+			display_sidebox(self::$appname, $title, $file);
95 95
 		}
96 96
 		if ($GLOBALS['egw_info']['user']['apps']['admin']) self::admin(self::$appname);
97 97
 	}
@@ -106,18 +106,18 @@  discard block
 block discarded – undo
106 106
 		if (is_array($location)) $location = $location['location'];
107 107
 
108 108
 		$file = Array(
109
-			'Site Configuration' => egw::link('/index.php','menuaction=admin.uiconfig.index&appname='.self::$appname),
110
-			'Custom fields' => egw::link('/index.php','menuaction=admin.customfields.index&appname='.self::$appname.'&ajax=true'),
111
-			'Check virtual filesystem' => egw::link('/index.php','menuaction=filemanager.filemanager_admin.fsck'),
109
+			'Site Configuration' => egw::link('/index.php', 'menuaction=admin.uiconfig.index&appname='.self::$appname),
110
+			'Custom fields' => egw::link('/index.php', 'menuaction=admin.customfields.index&appname='.self::$appname.'&ajax=true'),
111
+			'Check virtual filesystem' => egw::link('/index.php', 'menuaction=filemanager.filemanager_admin.fsck'),
112 112
 			'VFS mounts and versioning' => egw::link('/index.php', 'menuaction=filemanager.filemanager_admin.index'),
113 113
 		);
114 114
 		if ($location == 'admin')
115 115
 		{
116
-        	display_section(self::$appname,$file);
116
+        	display_section(self::$appname, $file);
117 117
 		}
118 118
 		else
119 119
 		{
120
-			display_sidebox(self::$appname,lang('Admin'),$file);
120
+			display_sidebox(self::$appname, lang('Admin'), $file);
121 121
 		}
122 122
 	}
123 123
 
@@ -147,15 +147,15 @@  discard block
 block discarded – undo
147 147
 				'admin'		=> False,
148 148
 			),
149 149
 		);
150
-		for ($i=1; $i <= self::$foldercount; $i++)
150
+		for ($i = 1; $i <= self::$foldercount; $i++)
151 151
 		{
152
-			$settings['folderlink'.$i]	= array(
152
+			$settings['folderlink'.$i] = array(
153 153
 				'type'		=> 'input',
154 154
 				'name'		=> 'folderlink'.$i,
155 155
 				'size'		=> 60,
156 156
 				'default'	=> '',
157 157
 				'label' 	=> lang('Enter the complete VFS path to specify a fast access link to a folder').' ('.$i.').',
158
-				'run_lang'  => -1,	// -1 = no lang on label
158
+				'run_lang'  => -1, // -1 = no lang on label
159 159
 				'xmlrpc'	=> True,
160 160
 				'admin'		=> False
161 161
 			);
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 				'type'		=> 'select',
177 177
 				'name'		=> 'showhome',
178 178
 				'values'	=> $yes_no,
179
-				'label' 	=> lang('Show link "%1" in side box menu?',lang('Your home directory')),
179
+				'label' 	=> lang('Show link "%1" in side box menu?', lang('Your home directory')),
180 180
 				'xmlrpc'	=> True,
181 181
 				'admin'		=> False,
182 182
 				'forced'   => 'yes',
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 				'type'		=> 'select',
186 186
 				'name'		=> 'showusers',
187 187
 				'values'	=> $yes_no,
188
-				'label' 	=> lang('Show link "%1" in side box menu?',lang('Users and groups')),
188
+				'label' 	=> lang('Show link "%1" in side box menu?', lang('Users and groups')),
189 189
 				'xmlrpc'	=> True,
190 190
 				'admin'		=> False,
191 191
 				'forced'   => 'yes',
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
 			'size'   => 60,
198 198
 			'label'  => 'Default document to insert entries',
199 199
 			'name'   => 'default_document',
200
-			'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')).' '.
200
+			'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')).' '.
201 201
 				lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'name').' '.
202
-				lang('The following document-types are supported:'). implode(',',bo_merge::get_file_extensions()),
202
+				lang('The following document-types are supported:').implode(',', bo_merge::get_file_extensions()),
203 203
 			'run_lang' => false,
204 204
 			'xmlrpc' => True,
205 205
 			'admin'  => False,
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
 			'label'  => 'Directory with documents to insert entries',
211 211
 			'name'   => 'document_dir',
212 212
 			'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')).' '.
213
-				lang('The document can contain placeholder like {{%1}}, to be replaced with the data.','name').' '.
214
-				lang('The following document-types are supported:'). implode(',',bo_merge::get_file_extensions()),
213
+				lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'name').' '.
214
+				lang('The following document-types are supported:').implode(',', bo_merge::get_file_extensions()),
215 215
 			'run_lang' => false,
216 216
 			'xmlrpc' => True,
217 217
 			'admin'  => False,
Please login to merge, or discard this patch.
Braces   +20 added lines, -5 removed lines patch added patch discarded remove patch
@@ -33,7 +33,10 @@  discard block
 block discarded – undo
33 33
 		$homepath = '/home/'.$GLOBALS['egw_info']['user']['account_lid'];
34 34
 		//echo "<p>admin_prefs_sidebox_hooks::all_hooks(".print_r($args,True).") appname='$appname', location='$location'</p>\n";
35 35
 		$config = config::read(self::$appname);
36
-		if (!empty($config['max_folderlinks'])) self::$foldercount = (int)$config['max_folderlinks'];
36
+		if (!empty($config['max_folderlinks']))
37
+		{
38
+			self::$foldercount = (int)$config['max_folderlinks'];
39
+		}
37 40
 		$file_prefs    = &$GLOBALS['egw_info']['user']['preferences'][self::$appname];
38 41
 		if ($location == 'sidebox_menu')
39 42
 		{
@@ -75,7 +78,10 @@  discard block
 block discarded – undo
75 78
 			{
76 79
 				$file['Basedirectory'] = egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$rootpath,'ajax'=>'true'));
77 80
 			}
78
-			if (!empty($file_prefs['startfolder'])) $file['Startfolder']= egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$file_prefs['startfolder'],'ajax'=>'true'));
81
+			if (!empty($file_prefs['startfolder']))
82
+			{
83
+				$file['Startfolder']= egw::link('/index.php',array('menuaction'=>self::$appname.'.filemanager_ui.index','path'=>$file_prefs['startfolder'],'ajax'=>'true'));
84
+			}
79 85
 			for ($i=1; $i<=self::$foldercount; $i++)
80 86
 			{
81 87
 				if (!empty($file_prefs['folderlink'.$i]))
@@ -93,7 +99,10 @@  discard block
 block discarded – undo
93 99
 			$file['Shared files'] = egw::link('/index.php','menuaction=filemanager.filemanager_shares.index&ajax=true');
94 100
 			display_sidebox(self::$appname,$title,$file);
95 101
 		}
96
-		if ($GLOBALS['egw_info']['user']['apps']['admin']) self::admin(self::$appname);
102
+		if ($GLOBALS['egw_info']['user']['apps']['admin'])
103
+		{
104
+			self::admin(self::$appname);
105
+		}
97 106
 	}
98 107
 
99 108
 	/**
@@ -103,7 +112,10 @@  discard block
 block discarded – undo
103 112
 	 */
104 113
 	static function admin($location = 'admin')
105 114
 	{
106
-		if (is_array($location)) $location = $location['location'];
115
+		if (is_array($location))
116
+		{
117
+			$location = $location['location'];
118
+		}
107 119
 
108 120
 		$file = Array(
109 121
 			'Site Configuration' => egw::link('/index.php','menuaction=admin.uiconfig.index&appname='.self::$appname),
@@ -129,7 +141,10 @@  discard block
 block discarded – undo
129 141
 	static function settings()
130 142
 	{
131 143
 		$config = config::read(self::$appname);
132
-		if (!empty($config['max_folderlinks'])) self::$foldercount = (int)$config['max_folderlinks'];
144
+		if (!empty($config['max_folderlinks']))
145
+		{
146
+			self::$foldercount = (int)$config['max_folderlinks'];
147
+		}
133 148
 
134 149
 		$yes_no = array(
135 150
 			'no'  => lang('No'),
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -464,7 +464,7 @@
 block discarded – undo
464 464
 	{
465 465
 		unset($args);	// unused, but required by function signature
466 466
 		$appname = 'preferences';
467
-		$file = Array(
467
+		$file = array(
468 468
 			'Site configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname=' . $appname.'&ajax=true'),
469 469
 		);
470 470
 		display_section($appname, $file);
Please login to merge, or discard this patch.
filemanager/inc/class.filemanager_shares.inc.php 3 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -127,8 +127,7 @@
 block discarded – undo
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
 	{
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -101,7 +101,10 @@
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	{
41 41
 		// sudo handling
42 42
 		parent::__construct();
43
-		self::$is_setup = egw_session::appsession('is_setup','filemanager');
43
+		self::$is_setup = egw_session::appsession('is_setup', 'filemanager');
44 44
 		self::$tmp_dir = '/home/'.$GLOBALS['egw_info']['user']['account_lid'].'/.tmp/';
45 45
 	}
46 46
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		$readonlys = null;
85 85
 		$total = egw_sharing::so()->get_rows($query, $rows, $readonlys);
86 86
 
87
-		foreach($rows as &$row)
87
+		foreach ($rows as &$row)
88 88
 		{
89 89
 			if (substr($row['share_path'], 0, strlen(self::$tmp_dir)) === self::$tmp_dir)
90 90
 			{
@@ -125,21 +125,21 @@  discard block
 block discarded – undo
125 125
 	 * @param array $content=null
126 126
 	 * @param string $msg=''
127 127
 	 */
128
-	public function index(array $content=null)
128
+	public function index(array $content = null)
129 129
 	{
130 130
 		if (!is_array($content))
131 131
 		{
132 132
 			$content = array(
133 133
 				'nm' => array(
134
-					'get_rows'       =>	'filemanager.filemanager_shares.get_rows',	// I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
135
-					'no_filter'      => True,	// current dir only
136
-					'no_filter2'     => True,	// I  disable the 2. filter (params are the same as for filter)
137
-					'no_cat'         => True,	// I  disable the cat-selectbox
138
-					'lettersearch'   => false,	// I  show a lettersearch
139
-					'searchletter'   =>	false,	// I0 active letter of the lettersearch or false for [all]
140
-					'start'          =>	0,		// IO position in list
141
-					'order'          =>	'share_created',	// IO name of the column to sort after (optional for the sortheaders)
142
-					'sort'           =>	'DESC',	// IO direction of the sort: 'ASC' or 'DESC'
134
+					'get_rows'       =>	'filemanager.filemanager_shares.get_rows', // I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
135
+					'no_filter'      => True, // current dir only
136
+					'no_filter2'     => True, // I  disable the 2. filter (params are the same as for filter)
137
+					'no_cat'         => True, // I  disable the cat-selectbox
138
+					'lettersearch'   => false, // I  show a lettersearch
139
+					'searchletter'   =>	false, // I0 active letter of the lettersearch or false for [all]
140
+					'start'          =>	0, // IO position in list
141
+					'order'          =>	'share_created', // IO name of the column to sort after (optional for the sortheaders)
142
+					'sort'           =>	'DESC', // IO direction of the sort: 'ASC' or 'DESC'
143 143
 					//'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
144 144
 					'csv_fields'     =>	false, // I  false=disable csv export, true or unset=enable it with auto-detected fieldnames,
145 145
 									//or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type)
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 		}
152 152
 		elseif ($content['nm']['action'])
153 153
 		{
154
-			switch($content['nm']['action'])
154
+			switch ($content['nm']['action'])
155 155
 			{
156 156
 				case 'delete':
157 157
 					$where = array('share_owner' => $GLOBALS['egw_info']['user']['account_id']);
Please login to merge, or discard this patch.
filemanager/inc/class.filemanager_ui.inc.php 4 patches
Doc Comments   +6 added lines, -1 removed lines patch added patch discarded remove patch
@@ -536,6 +536,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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)
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1420,7 +1420,7 @@
 block discarded – undo
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
 				}
Please login to merge, or discard this patch.
Braces   +138 added lines, -35 removed lines patch added patch discarded remove patch
@@ -79,7 +79,10 @@  discard block
 block discarded – undo
79 79
 			// search for plugins with additional filemanager views
80 80
 			foreach($GLOBALS['egw']->hooks->process('filemanager_views') as $views)
81 81
 			{
82
-				if (is_array($views)) static::$views += $views;
82
+				if (is_array($views))
83
+				{
84
+					static::$views += $views;
85
+				}
83 86
 			}
84 87
 			static::$views_init = true;
85 88
 		}
@@ -302,7 +305,10 @@  discard block
 block discarded – undo
302 305
 			$content['nm']['home_dir'] = static::get_home_dir();
303 306
 			$content['nm']['view'] = $GLOBALS['egw_info']['user']['preferences']['filemanager']['nm_view'];
304 307
 
305
-			if (isset($_GET['msg'])) $msg = $_GET['msg'];
308
+			if (isset($_GET['msg']))
309
+			{
310
+				$msg = $_GET['msg'];
311
+			}
306 312
 
307 313
 			// Blank favorite set via GET needs special handling for path
308 314
 			if (isset($_GET['favorite']) && $_GET['favorite'] == 'blank')
@@ -336,7 +342,10 @@  discard block
 block discarded – undo
336 342
 				// reset lettersearch as it confuses users (they think the dir is empty)
337 343
 				$content['nm']['searchletter'] = false;
338 344
 				// switch recusive display off
339
-				if (!$content['nm']['filter']) $content['nm']['filter'] = '';
345
+				if (!$content['nm']['filter'])
346
+				{
347
+					$content['nm']['filter'] = '';
348
+				}
340 349
 			}
341 350
 		}
342 351
 		$view = static::get_view();
@@ -388,37 +397,70 @@  discard block
 block discarded – undo
388 397
 	{
389 398
 		$tpl = new etemplate_new('filemanager.index');
390 399
 
391
-		if($msg) egw_framework::message($msg);
400
+		if($msg)
401
+		{
402
+			egw_framework::message($msg);
403
+		}
392 404
 
393 405
 		if (($content['nm']['action'] || $content['nm']['rows']) && (empty($content['button']) || !isset($content['button'])))
394 406
 		{
395 407
 			if ($content['nm']['action'])
396 408
 			{
397 409
 				$msg = static::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']);
398
-				if($msg) egw_framework::message($msg);
410
+				if($msg)
411
+				{
412
+					egw_framework::message($msg);
413
+				}
399 414
 
400 415
 				// clean up after action
401 416
 				unset($content['nm']['selected']);
402 417
 				// 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
403
-				if (isset($content['nm']['action'])) unset($content['nm']['action']);
404
-				if (isset($content['nm']['nm_action'])) unset($content['nm']['nm_action']);
405
-				if (isset($content['nm_action'])) unset($content['nm_action']);
418
+				if (isset($content['nm']['action']))
419
+				{
420
+					unset($content['nm']['action']);
421
+				}
422
+				if (isset($content['nm']['nm_action']))
423
+				{
424
+					unset($content['nm']['nm_action']);
425
+				}
426
+				if (isset($content['nm_action']))
427
+				{
428
+					unset($content['nm_action']);
429
+				}
406 430
 				// we dont use ['nm']['rows']['delete'], so unset it, if it is present
407
-				if (isset($content['nm']['rows']['delete'])) unset($content['nm']['rows']['delete']);
431
+				if (isset($content['nm']['rows']['delete']))
432
+				{
433
+					unset($content['nm']['rows']['delete']);
434
+				}
408 435
 			}
409 436
 			elseif($content['nm']['rows']['delete'])
410 437
 			{
411 438
 				$msg = static::action('delete',array_keys($content['nm']['rows']['delete']),$content['nm']['path']);
412
-				if($msg) egw_framework::message($msg);
439
+				if($msg)
440
+				{
441
+					egw_framework::message($msg);
442
+				}
413 443
 
414 444
 				// clean up after action
415 445
 				unset($content['nm']['rows']['delete']);
416 446
 				// reset any occasion where action may be stored, as we use ['nm']['rows']['delete'] anyhow
417 447
 				// we clean this up, as it may be ressurected out of the helpers by etemplate, which is quite unconvenient in case of action delete
418
-				if (isset($content['nm']['action'])) unset($content['nm']['action']);
419
-				if (isset($content['nm']['nm_action'])) unset($content['nm']['nm_action']);
420
-				if (isset($content['nm_action'])) unset($content['nm_action']);
421
-				if (isset($content['nm']['selected'])) unset($content['nm']['selected']);
448
+				if (isset($content['nm']['action']))
449
+				{
450
+					unset($content['nm']['action']);
451
+				}
452
+				if (isset($content['nm']['nm_action']))
453
+				{
454
+					unset($content['nm']['nm_action']);
455
+				}
456
+				if (isset($content['nm_action']))
457
+				{
458
+					unset($content['nm_action']);
459
+				}
460
+				if (isset($content['nm']['selected']))
461
+				{
462
+					unset($content['nm']['selected']);
463
+				}
422 464
 			}
423 465
 			unset($content['nm']['rows']);
424 466
 			egw_session::appsession('index','filemanager',$content['nm']);
@@ -583,9 +625,12 @@  discard block
 block discarded – undo
583 625
 						foreach(egw_vfs::find($path) as $p)
584 626
 						{
585 627
 							$to = $dir.substr($p,$len);
586
-							if ($to == $p)	// cant copy into itself!
628
+							if ($to == $p)
629
+							{
630
+								// cant copy into itself!
587 631
 							{
588 632
 								++$errs;
633
+							}
589 634
 								continue;
590 635
 							}
591 636
 							if (($is_dir = egw_vfs::is_dir($p)) && egw_vfs::mkdir($to,null,STREAM_MKDIR_RECURSIVE))
@@ -640,7 +685,10 @@  discard block
 block discarded – undo
640 685
 							continue;
641 686
 						}
642 687
 					}
643
-					if ($target[0] != '/') $target = egw_vfs::concat($dir, $target);
688
+					if ($target[0] != '/')
689
+					{
690
+						$target = egw_vfs::concat($dir, $target);
691
+					}
644 692
 					if (!egw_vfs::stat($target))
645 693
 					{
646 694
 						return lang('Link target %1 not found!', egw_vfs::decodePath($target));
@@ -683,10 +731,16 @@  discard block
 block discarded – undo
683 731
 				switch($action)
684 732
 				{
685 733
 					case 'document':
686
-						if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document'];
734
+						if (!$settings)
735
+						{
736
+							$settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document'];
737
+						}
687 738
 						$document_merge = new filemanager_merge(egw_vfs::decodePath($dir));
688 739
 						$msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']);
689
-						if($msg) return $msg;
740
+						if($msg)
741
+						{
742
+							return $msg;
743
+						}
690 744
 						$errs = count($selected);
691 745
 						return false;
692 746
 				}
@@ -723,7 +777,9 @@  discard block
 block discarded – undo
723 777
 				unset($selected[$key]);
724 778
 			}
725 779
 		}
726
-		if ($selected)	// somethings left to delete
780
+		if ($selected)
781
+		{
782
+			// somethings left to delete
727 783
 		{
728 784
 			// some precaution to never allow to (recursivly) remove /, /apps or /home
729 785
 			foreach((array)$selected as $path)
@@ -731,6 +787,7 @@  discard block
 block discarded – undo
731 787
 				if (preg_match('/^\/?(home|apps|)\/*$/',$path))
732 788
 				{
733 789
 					$errs++;
790
+		}
734 791
 					return lang("Cautiously rejecting to remove folder '%1'!",egw_vfs::decodePath($path));
735 792
 				}
736 793
 			}
@@ -783,7 +840,10 @@  discard block
 block discarded – undo
783 840
 		{
784 841
 			egw_session::appsession('index','filemanager',$query);
785 842
 		}
786
-		if(!$query['path']) $query['path'] = static::get_home_dir();
843
+		if(!$query['path'])
844
+		{
845
+			$query['path'] = static::get_home_dir();
846
+		}
787 847
 
788 848
 		// Change template to match selected view
789 849
 		if($query['view'])
@@ -841,7 +901,10 @@  discard block
 block discarded – undo
841 901
 		$filter = $query['filter'] === '' ? 1 : $query['filter'];
842 902
 
843 903
 		$maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null;
844
-		if($filter == 5) $maxdepth = 2;
904
+		if($filter == 5)
905
+		{
906
+			$maxdepth = 2;
907
+		}
845 908
 		$n = 0;
846 909
 		$vfs_options = array(
847 910
 			'mindepth' => 1,
@@ -894,10 +957,16 @@  discard block
 block discarded – undo
894 957
 			{
895 958
 				unset($row);	// fixes a weird problem with php5.1, does NOT happen with php5.2
896 959
 				$row =& $rows[$path2n[$path]];
897
-				if ( !is_array($props) ) continue;
960
+				if ( !is_array($props) )
961
+				{
962
+					continue;
963
+				}
898 964
 				foreach($props as $prop)
899 965
 				{
900
-					if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) continue;
966
+					if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show))
967
+					{
968
+						continue;
969
+					}
901 970
 					$row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'],0,64).' ...';
902 971
 				}
903 972
 			}
@@ -1025,7 +1094,10 @@  discard block
 block discarded – undo
1025 1094
 								$tpl->set_validation_error('name',lang("There's already a file with that name!").'<br />'.
1026 1095
 									lang('To overwrite the existing file store again.',lang($button)));
1027 1096
 								$content['confirm_overwrite'] = $to;
1028
-								if ($button == 'save') $button = 'apply';
1097
+								if ($button == 'save')
1098
+								{
1099
+									$button = 'apply';
1100
+								}
1029 1101
 								continue;
1030 1102
 							}
1031 1103
 							if (egw_vfs::rename($path,$to))
@@ -1098,13 +1170,19 @@  discard block
 block discarded – undo
1098 1170
 								}
1099 1171
 								if ($ok && !$failed)
1100 1172
 								{
1101
-									if(!$perm_changed++) $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren'));
1173
+									if(!$perm_changed++)
1174
+									{
1175
+										$msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren'));
1176
+									}
1102 1177
 									$content['old'][$name] = $content[$name];
1103 1178
 								}
1104 1179
 								elseif($failed)
1105 1180
 								{
1106
-									if(!$perm_failed++) $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren').
1181
+									if(!$perm_failed++)
1182
+									{
1183
+										$msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren').
1107 1184
 										($ok ? ' ('.lang('%1 failed, %2 succeded',$failed,$ok).')' : ''));
1185
+									}
1108 1186
 								}
1109 1187
 							}
1110 1188
 							elseif (call_user_func_array($cmd,array($path,$value)))
@@ -1157,7 +1235,10 @@  discard block
 block discarded – undo
1157 1235
 				}
1158 1236
 			}
1159 1237
 			egw_framework::refresh_opener($msg, 'filemanager', $refresh_path ? $refresh_path : $path, 'edit', null, '&path=[^&]*');
1160
-			if ($button == 'save') egw_framework::window_close();
1238
+			if ($button == 'save')
1239
+			{
1240
+				egw_framework::window_close();
1241
+			}
1161 1242
 		}
1162 1243
 		if ($content['is_link'] && !egw_vfs::stat($path))
1163 1244
 		{
@@ -1167,12 +1248,18 @@  discard block
 block discarded – undo
1167 1248
 		$content['icon'] = egw_vfs::mime_icon($content['mime']);
1168 1249
 		$content['msg'] = $msg;
1169 1250
 
1170
-		if (($readonlys['uid'] = !egw_vfs::$is_root) && !$content['uid']) $content['ro_uid_root'] = 'root';
1251
+		if (($readonlys['uid'] = !egw_vfs::$is_root) && !$content['uid'])
1252
+		{
1253
+			$content['ro_uid_root'] = 'root';
1254
+		}
1171 1255
 		// only owner can change group & perms
1172 1256
 		if (($readonlys['gid'] = !$content['is_owner'] ||
1173
-			egw_vfs::parse_url(egw_vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs'))	// no uid, gid or perms in oldvfs
1257
+			egw_vfs::parse_url(egw_vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs'))
1258
+		{
1259
+			// no uid, gid or perms in oldvfs
1174 1260
 		{
1175 1261
 			if (!$content['gid']) $content['ro_gid_root'] = 'root';
1262
+		}
1176 1263
 			foreach($content['perms'] as $name => $value)
1177 1264
 			{
1178 1265
 				$readonlys['perms['.$name.']'] = true;
@@ -1205,9 +1292,13 @@  discard block
 block discarded – undo
1205 1292
 				5 => lang('Display of content'),
1206 1293
 				0 => lang('No access'),
1207 1294
 			);
1208
-			if(($content['eacl'] = egw_vfs::get_eacl($content['path'])) !== false)	// backend supports eacl
1295
+			if(($content['eacl'] = egw_vfs::get_eacl($content['path'])) !== false)
1209 1296
 			{
1210
-				unset($readonlys['tabs']['filemanager.file.eacl']);	// --> switch the tab on again
1297
+				// backend supports eacl
1298
+			{
1299
+				unset($readonlys['tabs']['filemanager.file.eacl']);
1300
+			}
1301
+			// --> switch the tab on again
1211 1302
 				foreach($content['eacl'] as &$eacl)
1212 1303
 				{
1213 1304
 					$eacl['path'] = rtrim(egw_vfs::parse_url($eacl['path'],PHP_URL_PATH),'/');
@@ -1264,10 +1355,13 @@  discard block
 block discarded – undo
1264 1355
 				'comment' => (string)$content['comment'],
1265 1356
 				'mergeapp' => $content['mergeapp']
1266 1357
 			);
1267
-			if ($cfs) foreach($cfs as $name => $data)
1358
+			if ($cfs)
1359
+			{
1360
+				foreach($cfs as $name => $data)
1268 1361
 			{
1269 1362
 				$preserve['old']['#'.$name] = (string)$content['#'.$name];
1270 1363
 			}
1364
+			}
1271 1365
 		}
1272 1366
 		if (egw_vfs::$is_root)
1273 1367
 		{
@@ -1289,7 +1383,10 @@  discard block
 block discarded – undo
1289 1383
 			$tpl->setElementAttribute('tabs', 'add_tabs', true);
1290 1384
 
1291 1385
 			$tabs =& $tpl->getElementAttribute('tabs','tabs');
1292
-			if (true) $tabs = array();
1386
+			if (true)
1387
+			{
1388
+				$tabs = array();
1389
+			}
1293 1390
 
1294 1391
 			foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab)
1295 1392
 			{
@@ -1342,7 +1439,10 @@  discard block
 block discarded – undo
1342 1439
 			'files' => 0,
1343 1440
 		);
1344 1441
 
1345
-		if (!isset($dir)) $dir = array_pop($selected);
1442
+		if (!isset($dir))
1443
+		{
1444
+			$dir = array_pop($selected);
1445
+		}
1346 1446
 
1347 1447
 		switch($action)
1348 1448
 		{
@@ -1416,7 +1516,10 @@  discard block
 block discarded – undo
1416 1516
 					$target=egw_vfs::concat($dir,egw_vfs::encodePathComponent($file['name']));
1417 1517
 					if (egw_vfs::file_exists($target) && $app_dir)
1418 1518
 					{
1419
-						if (!egw_vfs::file_exists($app_dir)) egw_vfs::mkdir($app_dir);
1519
+						if (!egw_vfs::file_exists($app_dir))
1520
+						{
1521
+							egw_vfs::mkdir($app_dir);
1522
+						}
1420 1523
 						error_log("Symlinking $target to $app_dir");
1421 1524
 						egw_vfs::symlink($target, egw_vfs::concat($app_dir,egw_vfs::encodePathComponent($file['name'])));
1422 1525
 					}
Please login to merge, or discard this patch.
Spacing   +203 added lines, -205 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 			$_GET = etemplate::array_stripslashes($_GET);
54 54
 		}
55 55
 		// do we have root rights
56
-		if (egw_session::appsession('is_root','filemanager'))
56
+		if (egw_session::appsession('is_root', 'filemanager'))
57 57
 		{
58 58
 			egw_vfs::$is_root = true;
59 59
 		}
@@ -72,12 +72,12 @@  discard block
 block discarded – undo
72 72
 		if (!static::$views_init)
73 73
 		{
74 74
 			// translate our labels
75
-			foreach(static::$views as &$label)
75
+			foreach (static::$views as &$label)
76 76
 			{
77 77
 				$label = lang($label);
78 78
 			}
79 79
 			// search for plugins with additional filemanager views
80
-			foreach($GLOBALS['egw']->hooks->process('filemanager_views') as $views)
80
+			foreach ($GLOBALS['egw']->hooks->process('filemanager_views') as $views)
81 81
 			{
82 82
 				if (is_array($views)) static::$views += $views;
83 83
 			}
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 */
94 94
 	public static function get_view()
95 95
 	{
96
-		$view =& egw_cache::getSession('filemanager', 'view');
96
+		$view = & egw_cache::getSession('filemanager', 'view');
97 97
 		if (isset($_GET['view']))
98 98
 		{
99 99
 			$view = $_GET['view'];
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 			'open' => array(
118 118
 				'caption' => lang('Open'),
119 119
 				'icon' => '',
120
-				'group' => $group=1,
120
+				'group' => $group = 1,
121 121
 				'allowOnMultiple' => false,
122 122
 				'onExecute' => 'javaScript:app.filemanager.open',
123 123
 				'default' => true
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 			),
171 171
 			// DRAG and DROP events
172 172
 			'file_drag' => array(
173
-				'dragType' => array('file','link'),
173
+				'dragType' => array('file', 'link'),
174 174
 				'type' => 'drag',
175 175
 				'onExecute' => 'javaScript:app.filemanager.drag'
176 176
 			),
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 		}
210 210
 		else
211 211
 		{
212
-			foreach(egw_sharing::$modes as $mode => $data)
212
+			foreach (egw_sharing::$modes as $mode => $data)
213 213
 			{
214 214
 				$actions['mail']['children']['mail_'.$mode] = array(
215 215
 					'caption' => $data['label'],
@@ -231,10 +231,10 @@  discard block
 block discarded – undo
231 231
 	 *
232 232
 	 * @return string merge application or NULL if no property found
233 233
 	 */
234
-	private static function get_mergeapp($path, $scope='self')
234
+	private static function get_mergeapp($path, $scope = 'self')
235 235
 	{
236 236
 		$app = null;
237
-		switch($scope)
237
+		switch ($scope)
238 238
 		{
239 239
 			case 'self':
240 240
 				$props = egw_vfs::propfind($path, static::$merge_prop_namespace);
@@ -243,10 +243,10 @@  discard block
 block discarded – undo
243 243
 			case 'parents':
244 244
 				// search for props in parent directories
245 245
 				$currentpath = $path;
246
-				while($dir = egw_vfs::dirname($currentpath))
246
+				while ($dir = egw_vfs::dirname($currentpath))
247 247
 				{
248 248
 					$props = egw_vfs::propfind($dir, static::$merge_prop_namespace);
249
-					if(!empty($props))
249
+					if (!empty($props))
250 250
 					{
251 251
 						// found prop in parent directory
252 252
 						return $app = $props[0]['val'];
@@ -265,26 +265,26 @@  discard block
 block discarded – undo
265 265
 	 * @param array $content
266 266
 	 * @param string $msg
267 267
 	 */
268
-	function index(array $content=null,$msg=null)
268
+	function index(array $content = null, $msg = null)
269 269
 	{
270 270
 		if (!is_array($content))
271 271
 		{
272 272
 			$content = array(
273
-				'nm' => egw_session::appsession('index','filemanager'),
273
+				'nm' => egw_session::appsession('index', 'filemanager'),
274 274
 			);
275 275
 			if (!is_array($content['nm']))
276 276
 			{
277 277
 				$content['nm'] = array(
278
-					'get_rows'       =>	'filemanager.filemanager_ui.get_rows',	// I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
279
-					'filter'         => '',	// current dir only
280
-					'no_filter2'     => True,	// I  disable the 2. filter (params are the same as for filter)
281
-					'no_cat'         => True,	// I  disable the cat-selectbox
282
-					'lettersearch'   => True,	// I  show a lettersearch
283
-					'searchletter'   =>	false,	// I0 active letter of the lettersearch or false for [all]
284
-					'start'          =>	0,		// IO position in list
285
-					'order'          =>	'name',	// IO name of the column to sort after (optional for the sortheaders)
286
-					'sort'           =>	'ASC',	// IO direction of the sort: 'ASC' or 'DESC'
287
-					'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
278
+					'get_rows'       =>	'filemanager.filemanager_ui.get_rows', // I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
279
+					'filter'         => '', // current dir only
280
+					'no_filter2'     => True, // I  disable the 2. filter (params are the same as for filter)
281
+					'no_cat'         => True, // I  disable the cat-selectbox
282
+					'lettersearch'   => True, // I  show a lettersearch
283
+					'searchletter'   =>	false, // I0 active letter of the lettersearch or false for [all]
284
+					'start'          =>	0, // IO position in list
285
+					'order'          =>	'name', // IO name of the column to sort after (optional for the sortheaders)
286
+					'sort'           =>	'ASC', // IO direction of the sort: 'ASC' or 'DESC'
287
+					'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
288 288
 					'csv_fields'     =>	false, // I  false=disable csv export, true or unset=enable it with auto-detected fieldnames,
289 289
 									//or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type)
290 290
 					'actions'        => static::get_actions(),
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 					'is_parent_value'=> egw_vfs::DIR_MIME_TYPE,
296 296
 					'header_left'    => 'filemanager.index.header_left',
297 297
 					'favorites'      => true,
298
-					'placeholder_actions' => array('mkdir','file_drop_mail','file_drop_move','file_drop_copy','file_drop_symlink')
298
+					'placeholder_actions' => array('mkdir', 'file_drop_mail', 'file_drop_move', 'file_drop_copy', 'file_drop_symlink')
299 299
 				);
300 300
 				$content['nm']['path'] = static::get_home_dir();
301 301
 			}
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 			}
317 317
 			if (isset($_GET['path']) && ($path = $_GET['path']))
318 318
 			{
319
-				switch($path)
319
+				switch ($path)
320 320
 				{
321 321
 					case '..':
322 322
 						$path = egw_vfs::dirname($content['nm']['path']);
@@ -325,13 +325,13 @@  discard block
 block discarded – undo
325 325
 						$path = static::get_home_dir();
326 326
 						break;
327 327
 				}
328
-				if ($path[0] == '/' && egw_vfs::stat($path,true) && egw_vfs::is_dir($path) && egw_vfs::check_access($path,egw_vfs::READABLE))
328
+				if ($path[0] == '/' && egw_vfs::stat($path, true) && egw_vfs::is_dir($path) && egw_vfs::check_access($path, egw_vfs::READABLE))
329 329
 				{
330 330
 					$content['nm']['path'] = $path;
331 331
 				}
332 332
 				else
333 333
 				{
334
-					$msg .= lang('The requested path %1 is not available.',egw_vfs::decodePath($path));
334
+					$msg .= lang('The requested path %1 is not available.', egw_vfs::decodePath($path));
335 335
 				}
336 336
 				// reset lettersearch as it confuses users (they think the dir is empty)
337 337
 				$content['nm']['searchletter'] = false;
@@ -341,11 +341,11 @@  discard block
 block discarded – undo
341 341
 		}
342 342
 		$view = static::get_view();
343 343
 
344
-		if (strpos($view,'::') !== false && version_compare(PHP_VERSION,'5.3.0','<'))
344
+		if (strpos($view, '::') !== false && version_compare(PHP_VERSION, '5.3.0', '<'))
345 345
 		{
346
-			$view = explode('::',$view);
346
+			$view = explode('::', $view);
347 347
 		}
348
-		call_user_func($view,$content,$msg);
348
+		call_user_func($view, $content, $msg);
349 349
 	}
350 350
 
351 351
 	/**
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 	 * @param boolean &$is_setup=null on return true if authenticated user is setup config user, false otherwise
359 359
 	 * @return boolean true is root user given, false otherwise (including logout / empty $user)
360 360
 	 */
361
-	protected function sudo($user='',$password=null,&$is_setup=null)
361
+	protected function sudo($user = '', $password = null, &$is_setup = null)
362 362
 	{
363 363
 		if (!$user)
364 364
 		{
@@ -367,15 +367,15 @@  discard block
 block discarded – undo
367 367
 		else
368 368
 		{
369 369
 			// config user & password
370
-			$is_setup = egw_session::user_pw_hash($user,$password) === $GLOBALS['egw_info']['server']['config_hash'];
370
+			$is_setup = egw_session::user_pw_hash($user, $password) === $GLOBALS['egw_info']['server']['config_hash'];
371 371
 			// or vfs root user from setup >> configuration
372
-			$is_root = $is_setup ||	$GLOBALS['egw_info']['server']['vfs_root_user'] &&
373
-				in_array($user,preg_split('/, */',$GLOBALS['egw_info']['server']['vfs_root_user'])) &&
372
+			$is_root = $is_setup || $GLOBALS['egw_info']['server']['vfs_root_user'] &&
373
+				in_array($user, preg_split('/, */', $GLOBALS['egw_info']['server']['vfs_root_user'])) &&
374 374
 				$GLOBALS['egw']->auth->authenticate($user, $password, 'text');
375 375
 		}
376 376
 		//echo "<p>".__METHOD__."('$user','$password',$is_setup) user_pw_hash(...)='".egw_session::user_pw_hash($user,$password)."', config_hash='{$GLOBALS['egw_info']['server']['config_hash']}' --> returning ".array2string($is_root)."</p>\n";
377
-		egw_session::appsession('is_setup','filemanager',$is_setup);
378
-		return egw_session::appsession('is_root','filemanager',egw_vfs::$is_root = $is_root);
377
+		egw_session::appsession('is_setup', 'filemanager', $is_setup);
378
+		return egw_session::appsession('is_root', 'filemanager', egw_vfs::$is_root = $is_root);
379 379
 	}
380 380
 
381 381
 	/**
@@ -384,18 +384,18 @@  discard block
 block discarded – undo
384 384
 	 * @param array $content
385 385
 	 * @param string $msg
386 386
 	 */
387
-	function listview(array $content=null,$msg=null)
387
+	function listview(array $content = null, $msg = null)
388 388
 	{
389 389
 		$tpl = new etemplate_new('filemanager.index');
390 390
 
391
-		if($msg) egw_framework::message($msg);
391
+		if ($msg) egw_framework::message($msg);
392 392
 
393 393
 		if (($content['nm']['action'] || $content['nm']['rows']) && (empty($content['button']) || !isset($content['button'])))
394 394
 		{
395 395
 			if ($content['nm']['action'])
396 396
 			{
397
-				$msg = static::action($content['nm']['action'],$content['nm']['selected'],$content['nm']['path']);
398
-				if($msg) egw_framework::message($msg);
397
+				$msg = static::action($content['nm']['action'], $content['nm']['selected'], $content['nm']['path']);
398
+				if ($msg) egw_framework::message($msg);
399 399
 
400 400
 				// clean up after action
401 401
 				unset($content['nm']['selected']);
@@ -406,10 +406,10 @@  discard block
 block discarded – undo
406 406
 				// we dont use ['nm']['rows']['delete'], so unset it, if it is present
407 407
 				if (isset($content['nm']['rows']['delete'])) unset($content['nm']['rows']['delete']);
408 408
 			}
409
-			elseif($content['nm']['rows']['delete'])
409
+			elseif ($content['nm']['rows']['delete'])
410 410
 			{
411
-				$msg = static::action('delete',array_keys($content['nm']['rows']['delete']),$content['nm']['path']);
412
-				if($msg) egw_framework::message($msg);
411
+				$msg = static::action('delete', array_keys($content['nm']['rows']['delete']), $content['nm']['path']);
412
+				if ($msg) egw_framework::message($msg);
413 413
 
414 414
 				// clean up after action
415 415
 				unset($content['nm']['rows']['delete']);
@@ -421,11 +421,11 @@  discard block
 block discarded – undo
421 421
 				if (isset($content['nm']['selected'])) unset($content['nm']['selected']);
422 422
 			}
423 423
 			unset($content['nm']['rows']);
424
-			egw_session::appsession('index','filemanager',$content['nm']);
424
+			egw_session::appsession('index', 'filemanager', $content['nm']);
425 425
 		}
426 426
 
427 427
 		// be tolerant with (in previous versions) not correct urlencoded pathes
428
-		if ($content['nm']['path'][0] == '/' && !egw_vfs::stat($content['nm']['path'],true) && egw_vfs::stat(urldecode($content['nm']['path'])))
428
+		if ($content['nm']['path'][0] == '/' && !egw_vfs::stat($content['nm']['path'], true) && egw_vfs::stat(urldecode($content['nm']['path'])))
429 429
 		{
430 430
 			$content['nm']['path'] = urldecode($content['nm']['path']);
431 431
 		}
@@ -436,22 +436,22 @@  discard block
 block discarded – undo
436 436
 				list($button) = each($content['button']);
437 437
 				unset($content['button']);
438 438
 			}
439
-			switch($button)
439
+			switch ($button)
440 440
 			{
441 441
 				case 'upload':
442 442
 					if (!$content['upload'])
443 443
 					{
444
-						egw_framework::message(lang('You need to select some files first!'),'error');
444
+						egw_framework::message(lang('You need to select some files first!'), 'error');
445 445
 						break;
446 446
 					}
447 447
 					$upload_success = $upload_failure = array();
448
-					foreach(isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload)
448
+					foreach (isset($content['upload'][0]) ? $content['upload'] : array($content['upload']) as $upload)
449 449
 					{
450 450
 						// encode chars which special meaning in url/vfs (some like / get removed!)
451
-						$to = egw_vfs::concat($content['nm']['path'],egw_vfs::encodePathComponent($upload['name']));
451
+						$to = egw_vfs::concat($content['nm']['path'], egw_vfs::encodePathComponent($upload['name']));
452 452
 						if ($upload &&
453 453
 							(egw_vfs::is_writable($content['nm']['path']) || egw_vfs::is_writable($to)) &&
454
-							copy($upload['tmp_name'],egw_vfs::PREFIX.$to))
454
+							copy($upload['tmp_name'], egw_vfs::PREFIX.$to))
455 455
 						{
456 456
 							$upload_success[] = $upload['name'];
457 457
 						}
@@ -463,12 +463,11 @@  discard block
 block discarded – undo
463 463
 					$content['nm']['msg'] = '';
464 464
 					if ($upload_success)
465 465
 					{
466
-						egw_framework::message( count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') :
467
-							lang('%1 successful uploaded.',implode(', ',$upload_success)));
466
+						egw_framework::message(count($upload_success) == 1 && !$upload_failure ? lang('File successful uploaded.') : lang('%1 successful uploaded.', implode(', ', $upload_success)));
468 467
 					}
469 468
 					if ($upload_failure)
470 469
 					{
471
-						egw_framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(),'error');
470
+						egw_framework::message(lang('Error uploading file!')."\n".etemplate::max_upload_size_message(), 'error');
472 471
 					}
473 472
 					break;
474 473
 			}
@@ -489,17 +488,17 @@  discard block
 block discarded – undo
489 488
 			$tpl->setElementAttribute('nm[buttons][upload]', 'drop_target', 'popupMainDiv');
490 489
 		}
491 490
 		// Set view button to match current settings
492
-		if($content['nm']['view'] == 'tile')
491
+		if ($content['nm']['view'] == 'tile')
493 492
 		{
494
-			$tpl->setElementAttribute('nm[buttons][button][change_view]','label',lang('List view'));
495
-			$tpl->setElementAttribute('nm[buttons][button][change_view]','image','list_row');
493
+			$tpl->setElementAttribute('nm[buttons][button][change_view]', 'label', lang('List view'));
494
+			$tpl->setElementAttribute('nm[buttons][button][change_view]', 'image', 'list_row');
496 495
 
497 496
 		}
498 497
 		// if initial load is done via GET request (idots template or share.php)
499 498
 		// get_rows cant call app.filemanager.set_readonly, so we need to do that here
500 499
 		$content['initial_path_readonly'] = !egw_vfs::is_writable($content['nm']['path']);
501 500
 
502
-		$tpl->exec('filemanager.filemanager_ui.index',$content,$sel_options,$readonlys,array('nm' => $content['nm']));
501
+		$tpl->exec('filemanager.filemanager_ui.index', $content, $sel_options, $readonlys, array('nm' => $content['nm']));
503 502
 	}
504 503
 
505 504
 	/**
@@ -535,7 +534,7 @@  discard block
 block discarded – undo
535 534
 	 * @param int &$files=null on return number of files deleted
536 535
 	 * @return string success or failure message displayed to the user
537 536
 	 */
538
-	static public function action($action,$selected,$dir=null,&$errs=null,&$files=null,&$dirs=null)
537
+	static public function action($action, $selected, $dir = null, &$errs = null, &$files = null, &$dirs = null)
539 538
 	{
540 539
 		if (!count($selected))
541 540
 		{
@@ -543,20 +542,20 @@  discard block
 block discarded – undo
543 542
 		}
544 543
 		$errs = $dirs = $files = 0;
545 544
 
546
-		switch($action)
545
+		switch ($action)
547 546
 		{
548 547
 
549 548
 			case 'delete':
550
-				return static::do_delete($selected,$errs,$files,$dirs);
549
+				return static::do_delete($selected, $errs, $files, $dirs);
551 550
 
552 551
 			case 'mail':
553 552
 			case 'copy':
554
-				foreach($selected as $path)
553
+				foreach ($selected as $path)
555 554
 				{
556 555
 					if (strpos($path, 'mail::') === 0 && $path = substr($path, 6))
557 556
 					{
558 557
 						// Support for dropping mail in filemanager - Pass mail back to mail app
559
-						if(ExecMethod2('mail.mail_ui.vfsSaveMessage', $path, $dir, false))
558
+						if (ExecMethod2('mail.mail_ui.vfsSaveMessage', $path, $dir, false))
560 559
 						{
561 560
 							++$files;
562 561
 						}
@@ -567,8 +566,8 @@  discard block
 block discarded – undo
567 566
 					}
568 567
 					elseif (!egw_vfs::is_dir($path))
569 568
 					{
570
-						$to = egw_vfs::concat($dir,egw_vfs::basename($path));
571
-						if ($path != $to && egw_vfs::copy($path,$to))
569
+						$to = egw_vfs::concat($dir, egw_vfs::basename($path));
570
+						if ($path != $to && egw_vfs::copy($path, $to))
572 571
 						{
573 572
 							++$files;
574 573
 						}
@@ -580,19 +579,19 @@  discard block
 block discarded – undo
580 579
 					else
581 580
 					{
582 581
 						$len = strlen(dirname($path));
583
-						foreach(egw_vfs::find($path) as $p)
582
+						foreach (egw_vfs::find($path) as $p)
584 583
 						{
585
-							$to = $dir.substr($p,$len);
584
+							$to = $dir.substr($p, $len);
586 585
 							if ($to == $p)	// cant copy into itself!
587 586
 							{
588 587
 								++$errs;
589 588
 								continue;
590 589
 							}
591
-							if (($is_dir = egw_vfs::is_dir($p)) && egw_vfs::mkdir($to,null,STREAM_MKDIR_RECURSIVE))
590
+							if (($is_dir = egw_vfs::is_dir($p)) && egw_vfs::mkdir($to, null, STREAM_MKDIR_RECURSIVE))
592 591
 							{
593 592
 								++$dirs;
594 593
 							}
595
-							elseif(!$is_dir && egw_vfs::copy($p,$to))
594
+							elseif (!$is_dir && egw_vfs::copy($p, $to))
596 595
 							{
597 596
 								++$files;
598 597
 							}
@@ -605,15 +604,15 @@  discard block
 block discarded – undo
605 604
 				}
606 605
 				if ($errs)
607 606
 				{
608
-					return lang('%1 errors copying (%2 diretories and %3 files copied)!',$errs,$dirs,$files);
607
+					return lang('%1 errors copying (%2 diretories and %3 files copied)!', $errs, $dirs, $files);
609 608
 				}
610
-				return $dirs ? lang('%1 directories and %2 files copied.',$dirs,$files) : lang('%1 files copied.',$files);
609
+				return $dirs ? lang('%1 directories and %2 files copied.', $dirs, $files) : lang('%1 files copied.', $files);
611 610
 
612 611
 			case 'move':
613
-				foreach($selected as $path)
612
+				foreach ($selected as $path)
614 613
 				{
615
-					$to = egw_vfs::is_dir($dir) || count($selected) > 1 ? egw_vfs::concat($dir,egw_vfs::basename($path)) : $dir;
616
-					if ($path != $to && egw_vfs::rename($path,$to))
614
+					$to = egw_vfs::is_dir($dir) || count($selected) > 1 ? egw_vfs::concat($dir, egw_vfs::basename($path)) : $dir;
615
+					if ($path != $to && egw_vfs::rename($path, $to))
617 616
 					{
618 617
 						++$files;
619 618
 					}
@@ -624,17 +623,17 @@  discard block
 block discarded – undo
624 623
 				}
625 624
 				if ($errs)
626 625
 				{
627
-					return lang('%1 errors moving (%2 files moved)!',$errs,$files);
626
+					return lang('%1 errors moving (%2 files moved)!', $errs, $files);
628 627
 				}
629
-				return lang('%1 files moved.',$files);
628
+				return lang('%1 files moved.', $files);
630 629
 
631 630
 			case 'symlink':	// symlink given files to $dir
632
-				foreach((array)$selected as $target)
631
+				foreach ((array)$selected as $target)
633 632
 				{
634 633
 					$link = egw_vfs::concat($dir, egw_vfs::basename($target));
635
-					if (!egw_vfs::stat($dir) || ($ok = egw_vfs::mkdir($dir,0,true)))
634
+					if (!egw_vfs::stat($dir) || ($ok = egw_vfs::mkdir($dir, 0, true)))
636 635
 					{
637
-						if(!$ok)
636
+						if (!$ok)
638 637
 						{
639 638
 							$errs++;
640 639
 							continue;
@@ -656,15 +655,14 @@  discard block
 block discarded – undo
656 655
 				}
657 656
 				if (count((array)$selected) == 1)
658 657
 				{
659
-					return $files ? lang('Symlink to %1 created.', egw_vfs::decodePath($target)) :
660
-						lang('Error creating symlink to target %1!', egw_vfs::decodePath($target));
658
+					return $files ? lang('Symlink to %1 created.', egw_vfs::decodePath($target)) : lang('Error creating symlink to target %1!', egw_vfs::decodePath($target));
661 659
 				}
662 660
 				$ret = lang('%1 elements linked.', $files);
663 661
 				if ($errs)
664 662
 				{
665
-					$ret = lang('%1 errors linking (%2)!',$errs, $ret);
663
+					$ret = lang('%1 errors linking (%2)!', $errs, $ret);
666 664
 				}
667
-				return $ret;//." egw_vfs::symlink('$target', '$link')";
665
+				return $ret; //." egw_vfs::symlink('$target', '$link')";
668 666
 
669 667
 			case 'createdir':
670 668
 				$dst = egw_vfs::concat($dir, is_array($selected) ? $selected[0] : $selected);
@@ -680,13 +678,13 @@  discard block
 block discarded – undo
680 678
 
681 679
 			default:
682 680
 				list($action, $settings) = explode('_', $action, 2);
683
-				switch($action)
681
+				switch ($action)
684 682
 				{
685 683
 					case 'document':
686 684
 						if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['filemanager']['default_document'];
687 685
 						$document_merge = new filemanager_merge(egw_vfs::decodePath($dir));
688 686
 						$msg = $document_merge->download($settings, $selected, '', $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_dir']);
689
-						if($msg) return $msg;
687
+						if ($msg) return $msg;
690 688
 						$errs = count($selected);
691 689
 						return false;
692 690
 				}
@@ -703,12 +701,12 @@  discard block
 block discarded – undo
703 701
 	 * @param int &$files=null on return number of files deleted
704 702
 	 * @return string
705 703
 	 */
706
-	public static function do_delete(array $selected, &$errs=null, &$dirs=null, &$files=null)
704
+	public static function do_delete(array $selected, &$errs = null, &$dirs = null, &$files = null)
707 705
 	{
708 706
 		$dirs = $files = $errs = 0;
709 707
 		// we first delete all selected links (and files)
710 708
 		// feeding the links to dirs to egw_vfs::find() deletes the content of the dirs, not just the link!
711
-		foreach($selected as $key => $path)
709
+		foreach ($selected as $key => $path)
712 710
 		{
713 711
 			if (!egw_vfs::is_dir($path) || egw_vfs::is_link($path))
714 712
 			{
@@ -726,21 +724,21 @@  discard block
 block discarded – undo
726 724
 		if ($selected)	// somethings left to delete
727 725
 		{
728 726
 			// some precaution to never allow to (recursivly) remove /, /apps or /home
729
-			foreach((array)$selected as $path)
727
+			foreach ((array)$selected as $path)
730 728
 			{
731
-				if (preg_match('/^\/?(home|apps|)\/*$/',$path))
729
+				if (preg_match('/^\/?(home|apps|)\/*$/', $path))
732 730
 				{
733 731
 					$errs++;
734
-					return lang("Cautiously rejecting to remove folder '%1'!",egw_vfs::decodePath($path));
732
+					return lang("Cautiously rejecting to remove folder '%1'!", egw_vfs::decodePath($path));
735 733
 				}
736 734
 			}
737 735
 			// now we use find to loop through all files and dirs: (selected only contains dirs now)
738 736
 			// - depth=true to get first the files and then the dir containing it
739 737
 			// - hidden=true to also return hidden files (eg. Thumbs.db), as we cant delete non-empty dirs
740 738
 			// - show-deleted=false to not (finally) deleted versioned files
741
-			foreach(egw_vfs::find($selected,array('depth'=>true,'hidden'=>true,'show-deleted'=>false)) as $path)
739
+			foreach (egw_vfs::find($selected, array('depth'=>true, 'hidden'=>true, 'show-deleted'=>false)) as $path)
742 740
 			{
743
-				if (($is_dir = egw_vfs::is_dir($path) && !egw_vfs::is_link($path)) && egw_vfs::rmdir($path,0))
741
+				if (($is_dir = egw_vfs::is_dir($path) && !egw_vfs::is_link($path)) && egw_vfs::rmdir($path, 0))
744 742
 				{
745 743
 					++$dirs;
746 744
 				}
@@ -756,13 +754,13 @@  discard block
 block discarded – undo
756 754
 		}
757 755
 		if ($errs)
758 756
 		{
759
-			return lang('%1 errors deleteting (%2 directories and %3 files deleted)!',$errs,$dirs,$files);
757
+			return lang('%1 errors deleteting (%2 directories and %3 files deleted)!', $errs, $dirs, $files);
760 758
 		}
761 759
 		if ($dirs)
762 760
 		{
763
-			return lang('%1 directories and %2 files deleted.',$dirs,$files);
761
+			return lang('%1 directories and %2 files deleted.', $dirs, $files);
764 762
 		}
765
-		return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.',$files);
763
+		return $files == 1 ? lang('File deleted.') : lang('%1 files deleted.', $files);
766 764
 	}
767 765
 
768 766
 	/**
@@ -776,37 +774,37 @@  discard block
 block discarded – undo
776 774
 		// do NOT store query, if hierarchical data / children are requested
777 775
 		if (!$query['csv_export'])
778 776
 		{
779
-			egw_session::appsession('index','filemanager',$query);
777
+			egw_session::appsession('index', 'filemanager', $query);
780 778
 		}
781
-		if(!$query['path']) $query['path'] = static::get_home_dir();
779
+		if (!$query['path']) $query['path'] = static::get_home_dir();
782 780
 
783 781
 		// Change template to match selected view
784
-		if($query['view'])
782
+		if ($query['view'])
785 783
 		{
786 784
 			$query['template'] = ($query['view'] == 'row' ? 'filemanager.index.rows' : 'filemanager.tile');
787 785
 
788 786
 			// Store as preference but only for index, not home
789
-			if($query['get_rows'] == 'filemanager.filemanager_ui.get_rows')
787
+			if ($query['get_rows'] == 'filemanager.filemanager_ui.get_rows')
790 788
 			{
791
-				$GLOBALS['egw']->preferences->add('filemanager','nm_view',$query['view']);
789
+				$GLOBALS['egw']->preferences->add('filemanager', 'nm_view', $query['view']);
792 790
 				$GLOBALS['egw']->preferences->save_repository();
793 791
 			}
794 792
 		}
795 793
 		// be tolerant with (in previous versions) not correct urlencoded pathes
796
-		if (!egw_vfs::stat($query['path'],true) && egw_vfs::stat(urldecode($query['path'])))
794
+		if (!egw_vfs::stat($query['path'], true) && egw_vfs::stat(urldecode($query['path'])))
797 795
 		{
798 796
 			$query['path'] = urldecode($query['path']);
799 797
 		}
800
-		if (!egw_vfs::stat($query['path'],true) || !egw_vfs::is_dir($query['path']) || !egw_vfs::check_access($query['path'],egw_vfs::READABLE))
798
+		if (!egw_vfs::stat($query['path'], true) || !egw_vfs::is_dir($query['path']) || !egw_vfs::check_access($query['path'], egw_vfs::READABLE))
801 799
 		{
802 800
 			// only redirect, if it would be to some other location, gives redirect-loop otherwise
803 801
 			if ($query['path'] != ($path = static::get_home_dir()))
804 802
 			{
805 803
 				// we will leave here, since we are not allowed, or the location does not exist. Index must handle that, and give
806 804
 				// an appropriate message
807
-				egw::redirect_link('/index.php',array('menuaction'=>'filemanager.filemanager_ui.index',
805
+				egw::redirect_link('/index.php', array('menuaction'=>'filemanager.filemanager_ui.index',
808 806
 					'path' => $path,
809
-					'msg' => lang('The requested path %1 is not available.',egw_vfs::decodePath($query['path'])),
807
+					'msg' => lang('The requested path %1 is not available.', egw_vfs::decodePath($query['path'])),
810 808
 					'ajax' => 'true'
811 809
 				));
812 810
 			}
@@ -814,35 +812,35 @@  discard block
 block discarded – undo
814 812
 			return 0;
815 813
 		}
816 814
 		$rows = $dir_is_writable = array();
817
-		if($query['searchletter'] && !empty($query['search']))
815
+		if ($query['searchletter'] && !empty($query['search']))
818 816
 		{
819
-			$namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i';
817
+			$namefilter = '/^'.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i';
820 818
 			if ($query['searchletter'] == strtolower($query['search'][0]))
821 819
 			{
822
-				$namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'|'.
823
-					str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).')/i';
820
+				$namefilter = '/^('.$query['searchletter'].'.*'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'|'.
821
+					str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).')/i';
824 822
 			}
825 823
 		}
826 824
 		elseif ($query['searchletter'])
827 825
 		{
828 826
 			$namefilter = '/^'.$query['searchletter'].'/i';
829 827
 		}
830
-		elseif(!empty($query['search']))
828
+		elseif (!empty($query['search']))
831 829
 		{
832
-			$namefilter = '/'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($query['search'])).'/i';
830
+			$namefilter = '/'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($query['search'])).'/i';
833 831
 		}
834 832
 
835 833
 		// Re-map so 'No filters' favorite ('') is depth 1
836 834
 		$filter = $query['filter'] === '' ? 1 : $query['filter'];
837 835
 
838 836
 		$maxdepth = $filter && $filter != 4 ? (int)(boolean)$filter : null;
839
-		if($filter == 5) $maxdepth = 2;
837
+		if ($filter == 5) $maxdepth = 2;
840 838
 		$n = 0;
841 839
 		$vfs_options = array(
842 840
 			'mindepth' => 1,
843 841
 			'maxdepth' => $maxdepth,
844 842
 			'dirsontop' => $filter <= 1,
845
-			'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F':'f'),
843
+			'type' => $filter && $filter != 5 ? ($filter == 4 ? 'd' : null) : ($filter == 5 ? 'F' : 'f'),
846 844
 			'order' => $query['order'], 'sort' => $query['sort'],
847 845
 			'limit' => (int)$query['num_rows'].','.(int)$query['start'],
848 846
 			'need_mime' => true,
@@ -850,11 +848,11 @@  discard block
 block discarded – undo
850 848
 			'hidden' => $filter == 3,
851 849
 			'follow' => $filter == 5,
852 850
 		);
853
-		if($query['col_filter']['mime'])
851
+		if ($query['col_filter']['mime'])
854 852
 		{
855 853
 			$vfs_options['mime'] = $query['col_filter']['mime'];
856 854
 		}
857
-		foreach(egw_vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'],$vfs_options,true) as $path => $row)
855
+		foreach (egw_vfs::find(!empty($query['col_filter']['dir']) ? $query['col_filter']['dir'] : $query['path'], $vfs_options, true) as $path => $row)
858 856
 		{
859 857
 			//echo $path; _debug_array($row);
860 858
 
@@ -868,32 +866,32 @@  discard block
 block discarded – undo
868 866
 				$row['class'] = 'isDir';
869 867
 			}
870 868
 			$row['download_url'] = egw_vfs::download_url($path);
871
-			$row['gid'] = -abs($row['gid']);	// gid are positive, but we use negagive account_id for groups internal
869
+			$row['gid'] = -abs($row['gid']); // gid are positive, but we use negagive account_id for groups internal
872 870
 
873 871
 			$rows[++$n] = $row;
874 872
 			$path2n[$path] = $n;
875 873
 		}
876 874
 		// query comments and cf's for the displayed rows
877
-		$cols_to_show = explode(',',$GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']);
875
+		$cols_to_show = explode(',', $GLOBALS['egw_info']['user']['preferences']['filemanager']['nextmatch-filemanager.index.rows']);
878 876
 
879 877
 		// Always include comment in tiles
880
-		if($query['view'] == 'tile')
878
+		if ($query['view'] == 'tile')
881 879
 		{
882 880
 			$cols_to_show[] = 'comment';
883 881
 		}
884
-		$all_cfs = in_array('customfields',$cols_to_show) && $cols_to_show[count($cols_to_show)-1][0] != '#';
885
-		if ($path2n && (in_array('comment',$cols_to_show) || in_array('customfields',$cols_to_show)) &&
882
+		$all_cfs = in_array('customfields', $cols_to_show) && $cols_to_show[count($cols_to_show) - 1][0] != '#';
883
+		if ($path2n && (in_array('comment', $cols_to_show) || in_array('customfields', $cols_to_show)) &&
886 884
 			($path2props = egw_vfs::propfind(array_keys($path2n))))
887 885
 		{
888
-			foreach($path2props as $path => $props)
886
+			foreach ($path2props as $path => $props)
889 887
 			{
890
-				unset($row);	// fixes a weird problem with php5.1, does NOT happen with php5.2
891
-				$row =& $rows[$path2n[$path]];
892
-				if ( !is_array($props) ) continue;
893
-				foreach($props as $prop)
888
+				unset($row); // fixes a weird problem with php5.1, does NOT happen with php5.2
889
+				$row = & $rows[$path2n[$path]];
890
+				if (!is_array($props)) continue;
891
+				foreach ($props as $prop)
894 892
 				{
895
-					if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'],$cols_to_show)) continue;
896
-					$row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'],0,64).' ...';
893
+					if (!$all_cfs && $prop['name'][0] == '#' && !in_array($prop['name'], $cols_to_show)) continue;
894
+					$row[$prop['name']] = strlen($prop['val']) < 64 ? $prop['val'] : substr($prop['val'], 0, 64).' ...';
897 895
 				}
898 896
 			}
899 897
 		}
@@ -905,7 +903,7 @@  discard block
 block discarded – undo
905 903
 		if ($GLOBALS['egw_info']['flags']['currentapp'] == 'projectmanager')
906 904
 		{
907 905
 			// we need our app.css file
908
-			if (!file_exists(EGW_SERVER_ROOT.($css_file='/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css')))
906
+			if (!file_exists(EGW_SERVER_ROOT.($css_file = '/filemanager/templates/'.$GLOBALS['egw_info']['server']['template_set'].'/app.css')))
909 907
 			{
910 908
 				$css_file = '/filemanager/templates/default/app.css';
911 909
 			}
@@ -921,7 +919,7 @@  discard block
 block discarded – undo
921 919
 	 * @param array $content
922 920
 	 * @param string $msg
923 921
 	 */
924
-	function file(array $content=null,$msg='')
922
+	function file(array $content = null, $msg = '')
925 923
 	{
926 924
 		$tpl = new etemplate_new('filemanager.file');
927 925
 
@@ -931,9 +929,9 @@  discard block
 block discarded – undo
931 929
 			{
932 930
 				$msg .= $_GET['msg'];
933 931
 			}
934
-			if (!($path = str_replace(array('#','?'),array('%23','%3F'),$_GET['path'])) ||	// ?, # need to stay encoded!
932
+			if (!($path = str_replace(array('#', '?'), array('%23', '%3F'), $_GET['path'])) || // ?, # need to stay encoded!
935 933
 				// actions enclose pathes containing comma with "
936
-				($path[0] == '"' && substr($path,-1) == '"' && !($path = substr(str_replace('""','"',$path),1,-1))) ||
934
+				($path[0] == '"' && substr($path, -1) == '"' && !($path = substr(str_replace('""', '"', $path), 1, -1))) ||
937 935
 				!($stat = egw_vfs::lstat($path)))
938 936
 			{
939 937
 				$msg .= lang('File or directory not found!')." path='$path', stat=".array2string($stat);
@@ -946,10 +944,10 @@  discard block
 block discarded – undo
946 944
 				$content['path'] = $path;
947 945
 				$content['hsize'] = egw_vfs::hsize($stat['size']);
948 946
 				$content['mime'] = egw_vfs::mime_content_type($path);
949
-				$content['gid'] *= -1;	// our widgets use negative gid's
947
+				$content['gid'] *= -1; // our widgets use negative gid's
950 948
 				if (($props = egw_vfs::propfind($path)))
951 949
 				{
952
-					foreach($props as $prop)
950
+					foreach ($props as $prop)
953 951
 					{
954 952
 						$content[$prop['name']] = $prop['val'];
955 953
 					}
@@ -962,9 +960,9 @@  discard block
 block discarded – undo
962 960
 			$content['tabs'] = $_GET['tabs'];
963 961
 			if (!($content['is_dir'] = egw_vfs::is_dir($path) && !egw_vfs::is_link($path)))
964 962
 			{
965
-				$content['perms']['executable'] = (int)!!($content['mode'] & 0111);
963
+				$content['perms']['executable'] = (int)!!($content['mode']&0111);
966 964
 				$mask = 6;
967
-				if (preg_match('/^text/',$content['mime']) && $content['size'] < 100000)
965
+				if (preg_match('/^text/', $content['mime']) && $content['size'] < 100000)
968 966
 				{
969 967
 					$content['text_content'] = file_get_contents(egw_vfs::PREFIX.$path);
970 968
 				}
@@ -974,19 +972,19 @@  discard block
 block discarded – undo
974 972
 				//currently not implemented in backend $content['perms']['sticky'] = (int)!!($content['mode'] & 0x201);
975 973
 				$mask = 7;
976 974
 			}
977
-			foreach(array('owner' => 6,'group' => 3,'other' => 0) as $name => $shift)
975
+			foreach (array('owner' => 6, 'group' => 3, 'other' => 0) as $name => $shift)
978 976
 			{
979
-				$content['perms'][$name] = ($content['mode'] >> $shift) & $mask;
977
+				$content['perms'][$name] = ($content['mode'] >> $shift)&$mask;
980 978
 			}
981
-			$content['is_owner'] = egw_vfs::has_owner_rights($path,$content);
979
+			$content['is_owner'] = egw_vfs::has_owner_rights($path, $content);
982 980
 		}
983 981
 		else
984 982
 		{
985 983
 			//_debug_array($content);
986
-			$path =& $content['path'];
984
+			$path = & $content['path'];
987 985
 
988 986
 			list($button) = @each($content['button']); unset($content['button']);
989
-			if(!$button && $content['sudo'])
987
+			if (!$button && $content['sudo'])
990 988
 			{
991 989
 				// Button to stop sudo is not in button namespace
992 990
 				$button = 'sudo';
@@ -995,45 +993,45 @@  discard block
 block discarded – undo
995 993
 			// need to check 'setup' button (submit button in sudo popup), as some browsers (eg. chrome) also fill the hidden field
996 994
 			if ($button == 'sudo' && egw_vfs::$is_root || $button == 'setup' && $content['sudo']['user'])
997 995
 			{
998
-				$msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '',$content['sudo']['passwd']) ?
996
+				$msg = $this->sudo($button == 'setup' ? $content['sudo']['user'] : '', $content['sudo']['passwd']) ?
999 997
 					lang('Root access granted.') : ($button == 'setup' && $content['sudo']['user'] ?
1000 998
 					lang('Wrong username or password!') : lang('Root access stopped.'));
1001 999
 				unset($content['sudo']);
1002 1000
 				$content['is_owner'] = egw_vfs::has_owner_rights($path);
1003 1001
 			}
1004
-			if (in_array($button,array('save','apply')))
1002
+			if (in_array($button, array('save', 'apply')))
1005 1003
 			{
1006 1004
 				$props = array();
1007 1005
 				$perm_changed = $perm_failed = 0;
1008
-				foreach($content['old'] as $name => $old_value)
1006
+				foreach ($content['old'] as $name => $old_value)
1009 1007
 				{
1010 1008
 					if (isset($content[$name]) && ($old_value != $content[$name] ||
1011 1009
 						// do not check for modification, if modify_subs is checked!
1012
-						$content['modify_subs'] && in_array($name,array('uid','gid','perms'))) &&
1010
+						$content['modify_subs'] && in_array($name, array('uid', 'gid', 'perms'))) &&
1013 1011
 						($name != 'uid' || egw_vfs::$is_root))
1014 1012
 					{
1015 1013
 						if ($name == 'name')
1016 1014
 						{
1017
-							$to = egw_vfs::concat(egw_vfs::dirname($path),$content['name']);
1015
+							$to = egw_vfs::concat(egw_vfs::dirname($path), $content['name']);
1018 1016
 							if (file_exists(egw_vfs::PREFIX.$to) && $content['confirm_overwrite'] !== $to)
1019 1017
 							{
1020
-								$tpl->set_validation_error('name',lang("There's already a file with that name!").'<br />'.
1021
-									lang('To overwrite the existing file store again.',lang($button)));
1018
+								$tpl->set_validation_error('name', lang("There's already a file with that name!").'<br />'.
1019
+									lang('To overwrite the existing file store again.', lang($button)));
1022 1020
 								$content['confirm_overwrite'] = $to;
1023 1021
 								if ($button == 'save') $button = 'apply';
1024 1022
 								continue;
1025 1023
 							}
1026
-							if (egw_vfs::rename($path,$to))
1024
+							if (egw_vfs::rename($path, $to))
1027 1025
 							{
1028
-								$msg .= lang('Renamed %1 to %2.',egw_vfs::decodePath(basename($path)),egw_vfs::decodePath(basename($to))).' ';
1026
+								$msg .= lang('Renamed %1 to %2.', egw_vfs::decodePath(basename($path)), egw_vfs::decodePath(basename($to))).' ';
1029 1027
 								$content['old']['name'] = $content[$name];
1030 1028
 								$path = $to;
1031
-								$content['mime'] = mime_magic::filename2mime($path);	// recheck mime type
1032
-								$refresh_path = egw_vfs::dirname($path);	// for renames, we have to refresh the parent
1029
+								$content['mime'] = mime_magic::filename2mime($path); // recheck mime type
1030
+								$refresh_path = egw_vfs::dirname($path); // for renames, we have to refresh the parent
1033 1031
 							}
1034 1032
 							else
1035 1033
 							{
1036
-								$msg .= lang('Rename of %1 to %2 failed!',egw_vfs::decodePath(basename($path)),egw_vfs::decodePath(basename($to))).' ';
1034
+								$msg .= lang('Rename of %1 to %2 failed!', egw_vfs::decodePath(basename($path)), egw_vfs::decodePath(basename($to))).' ';
1037 1035
 								if (egw_vfs::deny_script($to))
1038 1036
 								{
1039 1037
 									$msg .= lang('You are NOT allowed to upload a script!').' ';
@@ -1053,7 +1051,7 @@  discard block
 block discarded – undo
1053 1051
 									'val'	=> (!empty($content[$name]) ? $content[$name] : null),
1054 1052
 								),
1055 1053
 							);
1056
-							if (egw_vfs::proppatch($path,$mergeprop))
1054
+							if (egw_vfs::proppatch($path, $mergeprop))
1057 1055
 							{
1058 1056
 								$content['old'][$name] = $content[$name];
1059 1057
 								$msg .= lang('Setting for document merge saved.');
@@ -1065,22 +1063,22 @@  discard block
 block discarded – undo
1065 1063
 						}
1066 1064
 						else
1067 1065
 						{
1068
-							static $name2cmd = array('uid' => 'chown','gid' => 'chgrp','perms' => 'chmod');
1069
-							$cmd = array('egw_vfs',$name2cmd[$name]);
1066
+							static $name2cmd = array('uid' => 'chown', 'gid' => 'chgrp', 'perms' => 'chmod');
1067
+							$cmd = array('egw_vfs', $name2cmd[$name]);
1070 1068
 							$value = $name == 'perms' ? static::perms2mode($content['perms']) : $content[$name];
1071 1069
 							if ($content['modify_subs'])
1072 1070
 							{
1073 1071
 								if ($name == 'perms')
1074 1072
 								{
1075
-									$changed = egw_vfs::find($path,array('type'=>'d'),$cmd,array($value));
1076
-									$changed += egw_vfs::find($path,array('type'=>'f'),$cmd,array($value & 0666));	// no execute for files
1073
+									$changed = egw_vfs::find($path, array('type'=>'d'), $cmd, array($value));
1074
+									$changed += egw_vfs::find($path, array('type'=>'f'), $cmd, array($value&0666)); // no execute for files
1077 1075
 								}
1078 1076
 								else
1079 1077
 								{
1080
-									$changed = egw_vfs::find($path,null,$cmd,array($value));
1078
+									$changed = egw_vfs::find($path, null, $cmd, array($value));
1081 1079
 								}
1082 1080
 								$ok = $failed = 0;
1083
-								foreach($changed as &$r)
1081
+								foreach ($changed as &$r)
1084 1082
 								{
1085 1083
 									if ($r)
1086 1084
 									{
@@ -1093,32 +1091,32 @@  discard block
 block discarded – undo
1093 1091
 								}
1094 1092
 								if ($ok && !$failed)
1095 1093
 								{
1096
-									if(!$perm_changed++) $msg .= lang('Permissions of %1 changed.',$path.' '.lang('and all it\'s childeren'));
1094
+									if (!$perm_changed++) $msg .= lang('Permissions of %1 changed.', $path.' '.lang('and all it\'s childeren'));
1097 1095
 									$content['old'][$name] = $content[$name];
1098 1096
 								}
1099
-								elseif($failed)
1097
+								elseif ($failed)
1100 1098
 								{
1101
-									if(!$perm_failed++) $msg .= lang('Failed to change permissions of %1!',$path.lang('and all it\'s childeren').
1102
-										($ok ? ' ('.lang('%1 failed, %2 succeded',$failed,$ok).')' : ''));
1099
+									if (!$perm_failed++) $msg .= lang('Failed to change permissions of %1!', $path.lang('and all it\'s childeren').
1100
+										($ok ? ' ('.lang('%1 failed, %2 succeded', $failed, $ok).')' : ''));
1103 1101
 								}
1104 1102
 							}
1105
-							elseif (call_user_func_array($cmd,array($path,$value)))
1103
+							elseif (call_user_func_array($cmd, array($path, $value)))
1106 1104
 							{
1107
-								$msg .= lang('Permissions of %1 changed.',$path);
1105
+								$msg .= lang('Permissions of %1 changed.', $path);
1108 1106
 								$content['old'][$name] = $content[$name];
1109 1107
 							}
1110 1108
 							else
1111 1109
 							{
1112
-								$msg .= lang('Failed to change permissions of %1!',$path);
1110
+								$msg .= lang('Failed to change permissions of %1!', $path);
1113 1111
 							}
1114 1112
 						}
1115 1113
 					}
1116 1114
 				}
1117 1115
 				if ($props)
1118 1116
 				{
1119
-					if (egw_vfs::proppatch($path,$props))
1117
+					if (egw_vfs::proppatch($path, $props))
1120 1118
 					{
1121
-						foreach($props as $prop)
1119
+						foreach ($props as $prop)
1122 1120
 						{
1123 1121
 							$content['old'][$prop['name']] = $prop['val'];
1124 1122
 						}
@@ -1135,8 +1133,8 @@  discard block
 block discarded – undo
1135 1133
 				if ($content['eacl']['delete'])
1136 1134
 				{
1137 1135
 					list($ino_owner) = each($content['eacl']['delete']);
1138
-					list(, $owner) = explode('-',$ino_owner,2);	// $owner is a group and starts with a minus!
1139
-					$msg .= egw_vfs::eacl($path,null,$owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!');
1136
+					list(, $owner) = explode('-', $ino_owner, 2); // $owner is a group and starts with a minus!
1137
+					$msg .= egw_vfs::eacl($path, null, $owner) ? lang('ACL deleted.') : lang('Error deleting the ACL entry!');
1140 1138
 				}
1141 1139
 				elseif ($button == 'eacl')
1142 1140
 				{
@@ -1146,7 +1144,7 @@  discard block
 block discarded – undo
1146 1144
 					}
1147 1145
 					else
1148 1146
 					{
1149
-						$msg .= egw_vfs::eacl($path,$content['eacl']['rights'],$content['eacl_owner']) ?
1147
+						$msg .= egw_vfs::eacl($path, $content['eacl']['rights'], $content['eacl_owner']) ?
1150 1148
 							lang('ACL added.') : lang('Error adding the ACL!');
1151 1149
 					}
1152 1150
 				}
@@ -1156,7 +1154,7 @@  discard block
 block discarded – undo
1156 1154
 		}
1157 1155
 		if ($content['is_link'] && !egw_vfs::stat($path))
1158 1156
 		{
1159
-			$msg .= ($msg ? "\n" : '').lang('Link target %1 not found!',$content['symlink']);
1157
+			$msg .= ($msg ? "\n" : '').lang('Link target %1 not found!', $content['symlink']);
1160 1158
 		}
1161 1159
 		$content['link'] = egw::link(egw_vfs::download_url($path));
1162 1160
 		$content['icon'] = egw_vfs::mime_icon($content['mime']);
@@ -1165,10 +1163,10 @@  discard block
 block discarded – undo
1165 1163
 		if (($readonlys['uid'] = !egw_vfs::$is_root) && !$content['uid']) $content['ro_uid_root'] = 'root';
1166 1164
 		// only owner can change group & perms
1167 1165
 		if (($readonlys['gid'] = !$content['is_owner'] ||
1168
-			egw_vfs::parse_url(egw_vfs::resolve_url($content['path']),PHP_URL_SCHEME) == 'oldvfs'))	// no uid, gid or perms in oldvfs
1166
+			egw_vfs::parse_url(egw_vfs::resolve_url($content['path']), PHP_URL_SCHEME) == 'oldvfs'))	// no uid, gid or perms in oldvfs
1169 1167
 		{
1170 1168
 			if (!$content['gid']) $content['ro_gid_root'] = 'root';
1171
-			foreach($content['perms'] as $name => $value)
1169
+			foreach ($content['perms'] as $name => $value)
1172 1170
 			{
1173 1171
 				$readonlys['perms['.$name.']'] = true;
1174 1172
 			}
@@ -1186,37 +1184,37 @@  discard block
 block discarded – undo
1186 1184
 		}
1187 1185
 		elseif (!egw_vfs::is_writable($path))
1188 1186
 		{
1189
-			foreach($cfs as $name => $data)
1187
+			foreach ($cfs as $name => $data)
1190 1188
 			{
1191 1189
 				$readonlys['#'.$name] = true;
1192 1190
 			}
1193 1191
 		}
1194
-		$readonlys['tabs']['filemanager.file.eacl'] = true;	// eacl off by default
1192
+		$readonlys['tabs']['filemanager.file.eacl'] = true; // eacl off by default
1195 1193
 		if ($content['is_dir'])
1196 1194
 		{
1197
-			$readonlys['tabs']['filemanager.file.preview'] = true;	// no preview tab for dirs
1198
-			$sel_options['rights']=$sel_options['owner']=$sel_options['group']=$sel_options['other'] = array(
1195
+			$readonlys['tabs']['filemanager.file.preview'] = true; // no preview tab for dirs
1196
+			$sel_options['rights'] = $sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array(
1199 1197
 				7 => lang('Display and modification of content'),
1200 1198
 				5 => lang('Display of content'),
1201 1199
 				0 => lang('No access'),
1202 1200
 			);
1203
-			if(($content['eacl'] = egw_vfs::get_eacl($content['path'])) !== false)	// backend supports eacl
1201
+			if (($content['eacl'] = egw_vfs::get_eacl($content['path'])) !== false)	// backend supports eacl
1204 1202
 			{
1205
-				unset($readonlys['tabs']['filemanager.file.eacl']);	// --> switch the tab on again
1206
-				foreach($content['eacl'] as &$eacl)
1203
+				unset($readonlys['tabs']['filemanager.file.eacl']); // --> switch the tab on again
1204
+				foreach ($content['eacl'] as &$eacl)
1207 1205
 				{
1208
-					$eacl['path'] = rtrim(egw_vfs::parse_url($eacl['path'],PHP_URL_PATH),'/');
1206
+					$eacl['path'] = rtrim(egw_vfs::parse_url($eacl['path'], PHP_URL_PATH), '/');
1209 1207
 					$readonlys['delete['.$eacl['ino'].'-'.$eacl['owner'].']'] = $eacl['ino'] != $content['ino'] ||
1210 1208
 						$eacl['path'] != $content['path'] || !$content['is_owner'];
1211 1209
 				}
1212
-				array_unshift($content['eacl'],false);	// make the keys start with 1, not 0
1210
+				array_unshift($content['eacl'], false); // make the keys start with 1, not 0
1213 1211
 				$content['eacl']['owner'] = 0;
1214 1212
 				$content['eacl']['rights'] = 5;
1215 1213
 			}
1216 1214
 		}
1217 1215
 		else
1218 1216
 		{
1219
-			$sel_options['owner']=$sel_options['group']=$sel_options['other'] = array(
1217
+			$sel_options['owner'] = $sel_options['group'] = $sel_options['other'] = array(
1220 1218
 				6 => lang('Read & write access'),
1221 1219
 				4 => lang('Read access only'),
1222 1220
 				0 => lang('No access'),
@@ -1226,11 +1224,11 @@  discard block
 block discarded – undo
1226 1224
 		// mergeapp
1227 1225
 		$content['mergeapp'] = static::get_mergeapp($path, 'self');
1228 1226
 		$content['mergeapp_parent'] = static::get_mergeapp($path, 'parents');
1229
-		if(!empty($content['mergeapp']))
1227
+		if (!empty($content['mergeapp']))
1230 1228
 		{
1231 1229
 			$content['mergeapp_effective'] = $content['mergeapp'];
1232 1230
 		}
1233
-		elseif(!empty($content['mergeapp_parent']))
1231
+		elseif (!empty($content['mergeapp_parent']))
1234 1232
 		{
1235 1233
 			$content['mergeapp_effective'] = $content['mergeapp_parent'];
1236 1234
 		}
@@ -1242,7 +1240,7 @@  discard block
 block discarded – undo
1242 1240
 		$mergeapp_list = egw_link::app_list('merge');
1243 1241
 		unset($mergeapp_list[$GLOBALS['egw_info']['flags']['currentapp']]); // exclude filemanager from list
1244 1242
 		$mergeapp_empty = !empty($content['mergeapp_parent'])
1245
-			? $mergeapp_list[$content['mergeapp_parent']] . ' (parent setting)' : '';
1243
+			? $mergeapp_list[$content['mergeapp_parent']].' (parent setting)' : '';
1246 1244
 		$sel_options['mergeapp'] = array(''	=> $mergeapp_empty);
1247 1245
 		$sel_options['mergeapp'] = $sel_options['mergeapp'] + $mergeapp_list;
1248 1246
 		// mergeapp other gui options
@@ -1259,7 +1257,7 @@  discard block
 block discarded – undo
1259 1257
 				'comment' => (string)$content['comment'],
1260 1258
 				'mergeapp' => $content['mergeapp']
1261 1259
 			);
1262
-			if ($cfs) foreach($cfs as $name => $data)
1260
+			if ($cfs) foreach ($cfs as $name => $data)
1263 1261
 			{
1264 1262
 				$preserve['old']['#'.$name] = (string)$content['#'.$name];
1265 1263
 			}
@@ -1267,26 +1265,26 @@  discard block
 block discarded – undo
1267 1265
 		if (egw_vfs::$is_root)
1268 1266
 		{
1269 1267
 			$tpl->setElementAttribute('sudouser', 'label', 'Logout');
1270
-			$tpl->setElementAttribute('sudouser', 'help','Log out as superuser');
1268
+			$tpl->setElementAttribute('sudouser', 'help', 'Log out as superuser');
1271 1269
 			// Need a more complex submit because button type is buttononly, which doesn't submit
1272
-			$tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"login")');
1270
+			$tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"login")');
1273 1271
 
1274 1272
 		}
1275 1273
 		elseif ($button == 'sudo')
1276 1274
 		{
1277 1275
 			$tpl->setElementAttribute('sudouser', 'label', 'Superuser');
1278
-			$tpl->setElementAttribute('sudouser', 'help','Enter setup user and password to get root rights');
1279
-			$tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"logout")');
1276
+			$tpl->setElementAttribute('sudouser', 'help', 'Enter setup user and password to get root rights');
1277
+			$tpl->setElementAttribute('sudouser', 'onclick', 'app.filemanager.set_sudoButton(widget,"logout")');
1280 1278
 		}
1281
-		if (($extra_tabs = egw_vfs::getExtraInfo($path,$content)))
1279
+		if (($extra_tabs = egw_vfs::getExtraInfo($path, $content)))
1282 1280
 		{
1283 1281
 			// add to existing tabs in template
1284 1282
 			$tpl->setElementAttribute('tabs', 'add_tabs', true);
1285 1283
 
1286
-			$tabs =& $tpl->getElementAttribute('tabs','tabs');
1284
+			$tabs = & $tpl->getElementAttribute('tabs', 'tabs');
1287 1285
 			if (true) $tabs = array();
1288 1286
 
1289
-			foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab)
1287
+			foreach (isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab)
1290 1288
 			{
1291 1289
 				$tabs[] = array(
1292 1290
 					'label' =>	$extra_tab['label'],
@@ -1309,7 +1307,7 @@  discard block
 block discarded – undo
1309 1307
 		egw_framework::window_focus();
1310 1308
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('Preferences').' '.egw_vfs::decodePath($path);
1311 1309
 
1312
-		$tpl->exec('filemanager.filemanager_ui.file',$content,$sel_options,$readonlys,$preserve,2);
1310
+		$tpl->exec('filemanager.filemanager_ui.file', $content, $sel_options, $readonlys, $preserve, 2);
1313 1311
 	}
1314 1312
 
1315 1313
 	/**
@@ -1320,10 +1318,10 @@  discard block
 block discarded – undo
1320 1318
 	 * @param string $dir=null current directory
1321 1319
 	 * @see static::action()
1322 1320
 	 */
1323
-	public static function ajax_action($action, $selected, $dir=null, $props=null)
1321
+	public static function ajax_action($action, $selected, $dir = null, $props = null)
1324 1322
 	{
1325 1323
 		// do we have root rights, need to run here too, as method is static and therefore does NOT run __construct
1326
-		if (egw_session::appsession('is_root','filemanager'))
1324
+		if (egw_session::appsession('is_root', 'filemanager'))
1327 1325
 		{
1328 1326
 			egw_vfs::$is_root = true;
1329 1327
 		}
@@ -1339,15 +1337,15 @@  discard block
 block discarded – undo
1339 1337
 
1340 1338
 		if (!isset($dir)) $dir = array_pop($selected);
1341 1339
 
1342
-		switch($action)
1340
+		switch ($action)
1343 1341
 		{
1344 1342
 			case 'upload':
1345 1343
 				$script_error = 0;
1346
-				foreach($selected as $tmp_name => &$data)
1344
+				foreach ($selected as $tmp_name => &$data)
1347 1345
 				{
1348 1346
 					$path = egw_vfs::concat($dir, egw_vfs::encodePathComponent($data['name']));
1349 1347
 
1350
-					if(egw_vfs::deny_script($path))
1348
+					if (egw_vfs::deny_script($path))
1351 1349
 					{
1352 1350
 						if (!isset($script_error))
1353 1351
 						{
@@ -1369,7 +1367,7 @@  discard block
 block discarded – undo
1369 1367
 					{
1370 1368
 						if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir']))
1371 1369
 						{
1372
-							$tmp_path = $GLOBALS['egw_info']['server']['temp_dir'] . '/' . basename($tmp_name);
1370
+							$tmp_path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($tmp_name);
1373 1371
 						}
1374 1372
 						else
1375 1373
 						{
@@ -1404,16 +1402,16 @@  discard block
 block discarded – undo
1404 1402
 			case 'link':
1405 1403
 				// First upload
1406 1404
 				$arr = static::ajax_action('upload', $selected, $dir, $props);
1407
-				$app_dir = egw_link::vfs_path($props['entry']['app'],$props['entry']['id'],'',true);
1405
+				$app_dir = egw_link::vfs_path($props['entry']['app'], $props['entry']['id'], '', true);
1408 1406
 
1409
-				foreach($arr['uploaded'] as $file)
1407
+				foreach ($arr['uploaded'] as $file)
1410 1408
 				{
1411
-					$target=egw_vfs::concat($dir,egw_vfs::encodePathComponent($file['name']));
1409
+					$target = egw_vfs::concat($dir, egw_vfs::encodePathComponent($file['name']));
1412 1410
 					if (egw_vfs::file_exists($target) && $app_dir)
1413 1411
 					{
1414 1412
 						if (!egw_vfs::file_exists($app_dir)) egw_vfs::mkdir($app_dir);
1415 1413
 						error_log("Symlinking $target to $app_dir");
1416
-						egw_vfs::symlink($target, egw_vfs::concat($app_dir,egw_vfs::encodePathComponent($file['name'])));
1414
+						egw_vfs::symlink($target, egw_vfs::concat($app_dir, egw_vfs::encodePathComponent($file['name'])));
1417 1415
 					}
1418 1416
 				}
1419 1417
 				// Must return to avoid adding to $response again
@@ -1435,7 +1433,7 @@  discard block
 block discarded – undo
1435 1433
 	 */
1436 1434
 	private function perms2mode(array $perms)
1437 1435
 	{
1438
-		$mode = $perms['owner'] << 6 | $perms['group'] << 3 | $perms['other'];
1436
+		$mode = $perms['owner'] << 6|$perms['group'] << 3|$perms['other'];
1439 1437
 		if ($mode['executable'])
1440 1438
 		{
1441 1439
 			$mode |= 0111;
Please login to merge, or discard this patch.
home/inc/class.home_list_portlet.inc.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -198,7 +198,7 @@
 block discarded – undo
198 198
 	/**
199 199
 	 * This portlet accepts files and links
200 200
 	 *
201
-	 * @return boolean|String[]
201
+	 * @return string[]
202 202
 	 */
203 203
 	public function accept_drop()
204 204
 	{
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 * Construct the portlet
39 39
 	 *
40 40
 	 */
41
-	public function __construct(Array &$context = array(), &$need_reload = false)
41
+	public function __construct(array &$context = array(), &$need_reload = false)
42 42
 	{
43 43
 		if (false) parent::__construct();
44 44
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		$content = $this->context;
114 114
 		if(!is_array($content['list']))
115 115
 		{
116
-			$content['list'] = Array();
116
+			$content['list'] = array();
117 117
 		}
118 118
 		// Filemanager support - links need app = 'file' and type set
119 119
 		foreach($content['list'] as &$list)
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -38,16 +38,16 @@  discard block
 block discarded – undo
38 38
 	 */
39 39
 	public function __construct(Array &$context = array(), &$need_reload = false)
40 40
 	{
41
-		if(!is_array($context['list'])) $context['list'] = array();
41
+		if (!is_array($context['list'])) $context['list'] = array();
42 42
 
43 43
 		// Process dropped data (Should be GUIDs) into something useable
44
-		if($context['dropped_data'])
44
+		if ($context['dropped_data'])
45 45
 		{
46
-			foreach((Array)$context['dropped_data'] as $dropped)
46
+			foreach ((Array)$context['dropped_data'] as $dropped)
47 47
 			{
48 48
 				$add = array();
49 49
 				list($add['app'], $add['id']) = explode('::', $dropped, 2);
50
-				if($add['app'] && $add['id'])
50
+				if ($add['app'] && $add['id'])
51 51
 				{
52 52
 					$context['list'][] = $add;
53 53
 				}
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
 			unset($context['dropped_data']);
57 57
 			$need_reload = true;
58 58
 		}
59
-		if($context['title'])
59
+		if ($context['title'])
60 60
 		{
61 61
 			$this->title = $context['title'];
62 62
 		}
63
-		foreach($context['list'] as &$item)
63
+		foreach ($context['list'] as &$item)
64 64
 		{
65
-			if($item['app'] == 'filemanager' || $item['app'] == 'file')
65
+			if ($item['app'] == 'filemanager' || $item['app'] == 'file')
66 66
 			{
67 67
 				$item['app'] = 'file';
68 68
 				$item['type'] = egw_vfs::mime_content_type($item['id']);
@@ -101,21 +101,21 @@  discard block
 block discarded – undo
101 101
 	 * 	unique, if needed.
102 102
 	 * @return string HTML fragment for display
103 103
 	 */
104
-	public function exec($id = null, etemplate_new &$etemplate = null)
104
+	public function exec($id = null, etemplate_new&$etemplate = null)
105 105
 	{
106 106
 		$etemplate->read('home.list');
107 107
 
108 108
 		$etemplate->set_dom_id($id);
109 109
 		$content = $this->context;
110
-		if(!is_array($content['list']))
110
+		if (!is_array($content['list']))
111 111
 		{
112 112
 			$content['list'] = Array();
113 113
 		}
114 114
 		// Filemanager support - links need app = 'file' and type set
115
-		foreach($content['list'] as &$list)
115
+		foreach ($content['list'] as &$list)
116 116
 		{
117
-			if($list['app'] == 'filemanager') $list['app'] = 'file';
118
-			if($list['app'] == 'file')
117
+			if ($list['app'] == 'filemanager') $list['app'] = 'file';
118
+			if ($list['app'] == 'file')
119 119
 			{
120 120
 				$list['app'] = 'file';
121 121
 				$list['path'] = $list['title'] = $list['icon'] = $list['id'];
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 			}
124 124
 		}
125 125
 
126
-		$etemplate->exec('home.home_list_portlet.exec',$content);
126
+		$etemplate->exec('home.home_list_portlet.exec', $content);
127 127
 	}
128 128
 
129 129
 	/**
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 				'type' => 'drop',
179 179
 				'caption' => lang('add'),
180 180
 				'onExecute' => 'javaScript:app.home.add_link',
181
-				'acceptedTypes' => array('file','link') + array_keys($GLOBALS['egw_info']['apps']),
181
+				'acceptedTypes' => array('file', 'link') + array_keys($GLOBALS['egw_info']['apps']),
182 182
 			)
183 183
 		);
184 184
 		return $actions;
@@ -198,6 +198,6 @@  discard block
 block discarded – undo
198 198
 	 */
199 199
 	public function accept_drop()
200 200
 	{
201
-		return array('file','link');
201
+		return array('file', 'link');
202 202
 	}
203 203
 }
Please login to merge, or discard this patch.
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,7 +38,10 @@  discard block
 block discarded – undo
38 38
 	 */
39 39
 	public function __construct(Array &$context = array(), &$need_reload = false)
40 40
 	{
41
-		if(!is_array($context['list'])) $context['list'] = array();
41
+		if(!is_array($context['list']))
42
+		{
43
+			$context['list'] = array();
44
+		}
42 45
 
43 46
 		// Process dropped data (Should be GUIDs) into something useable
44 47
 		if($context['dropped_data'])
@@ -114,7 +117,10 @@  discard block
 block discarded – undo
114 117
 		// Filemanager support - links need app = 'file' and type set
115 118
 		foreach($content['list'] as &$list)
116 119
 		{
117
-			if($list['app'] == 'filemanager') $list['app'] = 'file';
120
+			if($list['app'] == 'filemanager')
121
+			{
122
+				$list['app'] = 'file';
123
+			}
118 124
 			if($list['app'] == 'file')
119 125
 			{
120 126
 				$list['app'] = 'file';
Please login to merge, or discard this patch.
home/inc/class.home_portlet.inc.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -113,7 +113,7 @@
 block discarded – undo
113 113
 	 * If this portlet can be created by dropping, these are the drop types
114 114
 	 * that are accepted
115 115
 	 *
116
-	 * @return boolean|String[]
116
+	 * @return boolean
117 117
 	 */
118 118
 	public function accept_drop()
119 119
 	{
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
 	 * @param context Array portlet settings such as size, as well as values for properties
35 35
 	 * @param boolean $need_reload Flag to indicate that the portlet needs to be reloaded (exec will be called)
36 36
 	 */
37
-	public abstract function __construct(Array &$context = array(), &$need_reload = false);
37
+	public abstract function __construct(array &$context = array(), &$need_reload = false);
38 38
 
39 39
 	/**
40 40
 	 * Some descriptive information about the portlet, so that users can decide if
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 * 	unique, if needed.
55 55
 	 * @param etemplate etemplate_new Etemplate to generate content
56 56
 	 */
57
-	public abstract function exec($id = null, etemplate_new &$etemplate = null);
57
+	public abstract function exec($id = null, etemplate_new&$etemplate = null);
58 58
 
59 59
 	/**
60 60
 	 * Return a list of settings to customize the portlet.
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	{
77 77
 		// Include the common attributes, or they won't get saved
78 78
 		$properties = array();
79
-		foreach(self::$common_attributes as $prop)
79
+		foreach (self::$common_attributes as $prop)
80 80
 		{
81 81
 			$properties[$prop] = array('name' => $prop);
82 82
 		}
@@ -121,6 +121,6 @@  discard block
 block discarded – undo
121 121
 
122 122
 	public function __toString()
123 123
 	{
124
-		return get_called_class() . ' Context:' . array2string($this->context);
124
+		return get_called_class().' Context:'.array2string($this->context);
125 125
 	}
126 126
 }
Please login to merge, or discard this patch.
importexport/inc/class.importexport_basic_import_csv.inc.php 5 patches
Doc Comments   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -118,8 +118,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	 */
Please login to merge, or discard this patch.
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
Braces   +96 added lines, -36 removed lines patch added patch discarded remove patch
@@ -18,7 +18,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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'];
Please login to merge, or discard this patch.
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -16,19 +16,19 @@  discard block
 block discarded – undo
16 16
  * should get you started on building a CSV plugin for an application fairly quickly.
17 17
  *
18 18
  */
19
-abstract class importexport_basic_import_csv implements importexport_iface_import_plugin  {
19
+abstract class importexport_basic_import_csv implements importexport_iface_import_plugin {
20 20
 
21 21
 	protected static $plugin_options = array(
22
-		'fieldsep', 		// char
23
-		'charset', 			// string
24
-		'record_owner', 	// int
25
-		'update_cats', 			// string {override|add} overides record
22
+		'fieldsep', // char
23
+		'charset', // string
24
+		'record_owner', // int
25
+		'update_cats', // string {override|add} overides record
26 26
 								// with cat(s) from csv OR add the cat from
27 27
 								// csv file to exeisting cat(s) of record
28 28
 		'num_header_lines', // int number of header lines
29 29
 		'field_conversion', // array( $csv_col_num => conversion)
30
-		'field_mapping',	// array( $csv_col_num => adb_filed)
31
-		'conditions',		/* => array containing condition arrays:
30
+		'field_mapping', // array( $csv_col_num => adb_filed)
31
+		'conditions', /* => array containing condition arrays:
32 32
 				'type' => exists, // exists
33 33
 				'string' => '#kundennummer',
34 34
 				'true' => array(
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 * Actions wich could be done to data entries
47 47
 	 * If your plugin supports different actions, be sure to modify this array
48 48
 	 */
49
-	protected static $actions = array( 'none', 'update', 'insert', 'delete', );
49
+	protected static $actions = array('none', 'update', 'insert', 'delete',);
50 50
 
51 51
 	/**
52 52
 	 * Conditions for actions
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @var array
56 56
 	 */
57
-	protected static $conditions = array( 'exists', 'equal', 'less_than');
57
+	protected static $conditions = array('exists', 'equal', 'less_than');
58 58
 
59 59
 	/**
60 60
 	 * This is the definition that will be used to deal with the CSV file
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 	 * @param string $_charset
120 120
 	 * @param definition $_definition
121 121
 	 */
122
-	public function import( $_stream, importexport_definition $_definition ) {
123
-		$import_csv = new importexport_import_csv( $_stream, array(
122
+	public function import($_stream, importexport_definition $_definition) {
123
+		$import_csv = new importexport_import_csv($_stream, array(
124 124
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
125 125
 			'charset' => $_definition->plugin_options['charset'],
126 126
 		));
@@ -128,11 +128,11 @@  discard block
 block discarded – undo
128 128
 		$this->definition = $_definition;
129 129
 
130 130
 		// user, is admin ?
131
-		$this->is_admin = isset( $GLOBALS['egw_info']['user']['apps']['admin'] ) && $GLOBALS['egw_info']['user']['apps']['admin'];
131
+		$this->is_admin = isset($GLOBALS['egw_info']['user']['apps']['admin']) && $GLOBALS['egw_info']['user']['apps']['admin'];
132 132
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
133 133
 
134 134
 		// dry run?
135
-		$this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] :  false;
135
+		$this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false;
136 136
 
137 137
 		// set FieldMapping.
138 138
 		$import_csv->mapping = $_definition->plugin_options['field_mapping'];
@@ -141,9 +141,9 @@  discard block
 block discarded – undo
141 141
 		$import_csv->conversion = $_definition->plugin_options['field_conversion'];
142 142
 
143 143
 		//check if file has a header lines
144
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) {
144
+		if (isset($_definition->plugin_options['num_header_lines']) && $_definition->plugin_options['num_header_lines'] > 0) {
145 145
 			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
146
-		} elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
146
+		} elseif (isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
147 147
 			// First method is preferred
148 148
 			$import_csv->skip_records(1);
149 149
 		}
@@ -165,38 +165,38 @@  discard block
 block discarded – undo
165 165
 
166 166
 		$this->init($_definition);
167 167
 
168
-		while ( $record = $import_csv->get_record() ) {
168
+		while ($record = $import_csv->get_record()) {
169 169
 			$success = false;
170 170
 
171 171
 			// don't import empty records
172
-			if( count( array_unique( $record ) ) < 2 ) continue;
172
+			if (count(array_unique($record)) < 2) continue;
173 173
 
174 174
 
175 175
 			$warning = importexport_import_csv::convert($record, $record_class::$types, $app, $this->lookups, $_definition->plugin_options['convert']);
176
-				if($warning) $this->warnings[$import_csv->get_current_position()] = $warning;
176
+				if ($warning) $this->warnings[$import_csv->get_current_position()] = $warning;
177 177
 
178 178
 			$egw_record = new $record_class();
179 179
 			$egw_record->set_record($record);
180 180
 			$success = $this->import_record($egw_record, $import_csv);
181 181
 
182
-			if($success)
182
+			if ($success)
183 183
 			{
184 184
 				$this->do_special_fields($egw_record, $import_csv);
185 185
 			}
186
-			if($success) $count++;
186
+			if ($success) $count++;
187 187
 
188 188
 			// Add some more time
189
-			if($success && $import_csv->get_current_position() > 0 && $import_csv->get_current_position() % 100 == 0)
189
+			if ($success && $import_csv->get_current_position() > 0 && $import_csv->get_current_position() % 100 == 0)
190 190
 			{
191 191
 				set_time_limit(10);
192 192
 			}
193 193
 			
194 194
 			// Keep a few records for preview, but process the whole file
195
-			if($this->dry_run && $import_csv->get_current_position() < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'])
195
+			if ($this->dry_run && $import_csv->get_current_position() < $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'])
196 196
 			{
197 197
 				$this->preview_records[] = $egw_record;
198 198
 			}
199
-			if(count($this->warnings) > self::MAX_MESSAGES || count($this->errors) > self::MAX_MESSAGES)
199
+			if (count($this->warnings) > self::MAX_MESSAGES || count($this->errors) > self::MAX_MESSAGES)
200 200
 			{
201 201
 				$this->errors[] = 'Too many errors, aborted';
202 202
 				break;
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	/**
209 209
 	 * Stub to hook into import initialization - set lookups, etc.
210 210
 	 */
211
-	protected function init(importexport_definition &$definition)
211
+	protected function init(importexport_definition&$definition)
212 212
 	{
213 213
 	}
214 214
 
@@ -222,12 +222,12 @@  discard block
 block discarded – undo
222 222
 	*
223 223
 	* @return boolean success
224 224
 	*/
225
-	protected function import_record(importexport_iface_egw_record &$record, &$import_csv)
225
+	protected function import_record(importexport_iface_egw_record&$record, &$import_csv)
226 226
 	{
227
-		if ( $this->definition->plugin_options['conditions'] ) {
228
-			foreach ( $this->definition->plugin_options['conditions'] as $condition ) {
227
+		if ($this->definition->plugin_options['conditions']) {
228
+			foreach ($this->definition->plugin_options['conditions'] as $condition) {
229 229
 				$result = false;
230
-				switch ( $condition['type'] ) {
230
+				switch ($condition['type']) {
231 231
 					// exists
232 232
 					case 'exists' :
233 233
 						// Check for that record
@@ -243,23 +243,23 @@  discard block
 block discarded – undo
243 243
 						die('condition / action not supported!!!');
244 244
 						break;
245 245
 				}
246
-				if($result)
246
+				if ($result)
247 247
 				{
248 248
 					// Apply true action to any matching records found
249 249
 					$action = $condition['true'];
250
-					$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
250
+					$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
251 251
 				}
252 252
 				else
253 253
 				{
254 254
 					// Apply false action if no matching records found
255 255
 					$action = $condition['false'];
256
-					$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
256
+					$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
257 257
 				}
258 258
 				if ($action['stop']) break;
259 259
 			}
260 260
 		} else {
261 261
 			// unconditional insert
262
-			$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
262
+			$success = $this->action('insert', $record, $import_csv->get_current_position());
263 263
 		}
264 264
 
265 265
 		return $success;
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 	 *
275 275
 	 * @return boolean
276 276
 	 */
277
-	protected function exists(importexport_iface_egw_record &$record, Array &$condition, &$matches = array())
277
+	protected function exists(importexport_iface_egw_record&$record, Array &$condition, &$matches = array())
278 278
 	{
279 279
 	}
280 280
 
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	 *
287 287
 	 * @return boolean
288 288
 	 */
289
-	protected function equal(importexport_iface_egw_record &$record, Array &$condition)
289
+	protected function equal(importexport_iface_egw_record&$record, Array &$condition)
290 290
 	{
291 291
 		$field = $condition['string'];
292 292
 		return $record->$field == $condition['op_2'];
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 	 *
302 302
 	 * @return boolean
303 303
 	 */
304
-	protected function less_than(importexport_iface_egw_record &$record, Array &$condition)
304
+	protected function less_than(importexport_iface_egw_record&$record, Array &$condition)
305 305
 	{
306 306
 		$field = $condition['string'];
307 307
 		return $record->$field < $condition['op_2'];
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	 * @param int $record_num Which record number is being dealt with.  Used for error messages.
321 321
 	 * @return bool success or not
322 322
 	 */
323
-	protected abstract function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 );
323
+	protected abstract function action($_action, importexport_iface_egw_record&$record, $record_num = 0);
324 324
 
325 325
 	/**
326 326
 	 * Handle special fields
@@ -330,51 +330,51 @@  discard block
 block discarded – undo
330 330
 	 *
331 331
 	 * @param importexport_iface_egw_record $record
332 332
 	 */
333
-	protected function do_special_fields(importexport_iface_egw_record &$record, &$import_csv)
333
+	protected function do_special_fields(importexport_iface_egw_record&$record, &$import_csv)
334 334
 	{
335 335
 		$id = $record->get_identifier();
336 336
 
337 337
 		// Warn if there's no ID unless it's a dry_run because there probably won't be an ID then
338
-		if(!$this->dry_run && !$id)
338
+		if (!$this->dry_run && !$id)
339 339
 		{
340 340
 			$this->warnings[$import_csv->get_current_position()] .= "Unable to link, no identifier for record";
341 341
 			return;
342 342
 		}
343 343
 
344
-		foreach(self::$special_fields as $field => $desc) {
345
-			if(!$record->$field) continue;
346
-			if(strpos($field, 'link') === 0) {
347
-				list($app, $app_id) = explode(':', $record->$field,2);
344
+		foreach (self::$special_fields as $field => $desc) {
345
+			if (!$record->$field) continue;
346
+			if (strpos($field, 'link') === 0) {
347
+				list($app, $app_id) = explode(':', $record->$field, 2);
348 348
 
349
-				list($link, $type) = explode('_',$field);
349
+				list($link, $type) = explode('_', $field);
350 350
 
351 351
 				// Searching, take first result
352
-				if($type == 'custom')
352
+				if ($type == 'custom')
353 353
 				{
354 354
 					$app_id = $this->link_by_cf($record, $app, $app_id, $import_csv->get_current_position());
355 355
 				}
356
-				else if($type == 'search')
356
+				else if ($type == 'search')
357 357
 				{
358 358
 					$result = egw_link::query($app, $app_id);
359 359
 					do
360 360
 					{
361 361
 						$app_id = key($result);
362 362
 						shift($result);
363
-					} while($result && !$app_id);
363
+					} while ($result && !$app_id);
364 364
 				}
365 365
 			} else if (in_array($field, array_keys($GLOBALS['egw_info']['apps']))) {
366 366
 				$app = $field;
367 367
 				$app_id = $record->$field;
368 368
 
369 369
 				// Searching, take first result
370
-				if(!is_numeric($app_id))
370
+				if (!is_numeric($app_id))
371 371
 				{
372 372
 					$result = egw_link::query($app, $app_id);
373 373
 					do
374 374
 					{
375 375
 						$app_id = key($result);
376 376
 						shift($result);
377
-					} while($result && !$app_id);
377
+					} while ($result && !$app_id);
378 378
 				}
379 379
 			}
380 380
 			else if ($field == 'contact')
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 			}
386 386
 			if (!$this->dry_run && $app && $app_id && ($app != $this->definition->application || $app_id != $id))
387 387
 			{
388
-				$link_id = egw_link::link($this->definition->application,$id,$app,$app_id);
388
+				$link_id = egw_link::link($this->definition->application, $id, $app, $app_id);
389 389
 			}
390 390
 		}
391 391
 	}
@@ -402,13 +402,13 @@  discard block
 block discarded – undo
402 402
 	 * @param importexport_definition $definition
403 403
 	 * @return String HTML for preview
404 404
          */
405
-	public function preview( $stream, importexport_definition $definition )
405
+	public function preview($stream, importexport_definition $definition)
406 406
 	{
407 407
 		$this->import($stream, $definition);
408 408
 		rewind($stream);
409 409
 
410 410
 		// Set up result
411
-		$rows = array('h1'=>array(),'f1'=>array(),'.h1'=>'class=th');
411
+		$rows = array('h1'=>array(), 'f1'=>array(), '.h1'=>'class=th');
412 412
 
413 413
 		// Load labels for app
414 414
 		$record_class = get_class($this->preview_records[0]);
@@ -417,27 +417,27 @@  discard block
 block discarded – undo
417 417
 		$labels = array_combine($definition->plugin_options['field_mapping'], $definition->plugin_options['field_mapping']);
418 418
 
419 419
 		$plugin = get_called_class();
420
-		$wizard_name = $definition->application . '_wizard_' . str_replace($definition->application . '_', '', $plugin);
420
+		$wizard_name = $definition->application.'_wizard_'.str_replace($definition->application.'_', '', $plugin);
421 421
 		try {
422 422
 			$wizard = new $wizard_name;
423 423
 			$fields = $wizard->get_import_fields();
424
-			foreach($labels as $field => &$label)
424
+			foreach ($labels as $field => &$label)
425 425
 			{
426
-				if($fields[$field]) $label = $fields[$field];
426
+				if ($fields[$field]) $label = $fields[$field];
427 427
 			}
428 428
 		} catch (Exception $e) {
429 429
 			translation::add_app($definition->application);
430
-			foreach($labels as $field => &$label) {
430
+			foreach ($labels as $field => &$label) {
431 431
 				$label = lang($label);
432 432
 			}
433 433
 		}
434 434
 
435 435
 		// Set up HTML
436 436
 		$rows['h1'] = $labels;
437
-		foreach($this->preview_records as $i => $row_data)
437
+		foreach ($this->preview_records as $i => $row_data)
438 438
 		{
439 439
 			// Convert to human-friendly
440
-			importexport_export_csv::convert($row_data,$record_class::$types,$definition->application,$this->lookups);
440
+			importexport_export_csv::convert($row_data, $record_class::$types, $definition->application, $this->lookups);
441 441
 			$this->row_preview($row_data);
442 442
 			$rows[] = $row_data->get_record_array();
443 443
 		}
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 	 *
452 452
 	 * @param egw_record $row_entry
453 453
 	 */
454
-	protected function row_preview(importexport_iface_egw_record &$row_entry)
454
+	protected function row_preview(importexport_iface_egw_record&$row_entry)
455 455
 	{
456 456
 	}
457 457
 
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 	 * @param string $org_name
467 467
 	 * @return int|boolean Contact ID of first match, or false if none found
468 468
 	 */
469
-	public static function addr_id( $n_family,$n_given=null,$org_name=null, &$record=null) {
469
+	public static function addr_id($n_family, $n_given = null, $org_name = null, &$record = null) {
470 470
 
471 471
 		// find in Addressbook, at least n_family AND (n_given OR org_name) have to match
472 472
 		static $contacts;
@@ -476,18 +476,18 @@  discard block
 block discarded – undo
476 476
 			list($n_family, $n_given, $org_name) = explode(',', $n_family);
477 477
 		}
478 478
 		$n_family = trim($n_family);
479
-		if(!is_null($n_given)) $n_given = trim($n_given);
479
+		if (!is_null($n_given)) $n_given = trim($n_given);
480 480
 		if (!is_object($contacts))
481 481
 		{
482
-			$contacts =& CreateObject('phpgwapi.contacts');
482
+			$contacts = & CreateObject('phpgwapi.contacts');
483 483
 		}
484 484
 		if (!is_null($org_name))	// org_name given?
485 485
 		{
486 486
 			$org_name = trim($org_name);
487
-			$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,n_given=$n_given,org_name=$org_name" );
487
+			$addrs = $contacts->read(0, 0, array('id'), '', "n_family=$n_family,n_given=$n_given,org_name=$org_name");
488 488
 			if (!count($addrs))
489 489
 			{
490
-				$addrs = $contacts->read( 0,0,array('id'),'',"n_family=$n_family,org_name=$org_name",'','n_family,org_name');
490
+				$addrs = $contacts->read(0, 0, array('id'), '', "n_family=$n_family,org_name=$org_name", '', 'n_family,org_name');
491 491
 			}
492 492
 		}
493 493
 		if (!is_null($n_given) && (is_null($org_name) || !count($addrs)))       // first name given and no result so far
@@ -496,11 +496,11 @@  discard block
 block discarded – undo
496 496
 		}
497 497
 		if (is_null($n_given) && is_null($org_name))    // just one name given, check against fn (= full name)
498 498
 		{
499
-			$addrs = $contacts->read( 0,0,array('id'),'',"n_fn=$n_family",'','n_fn' );
499
+			$addrs = $contacts->read(0, 0, array('id'), '', "n_fn=$n_family", '', 'n_fn');
500 500
 		}
501 501
 		if (count($addrs))
502 502
 		{
503
-			if(!$record || !$record->get_identifier())
503
+			if (!$record || !$record->get_identifier())
504 504
 			{
505 505
 				return $addrs[0]['id'];
506 506
 			}
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 				{
511 511
 					$id = key($addrs);
512 512
 					array_shift($addrs);
513
-				} while($addrs && !$id && $id == $record->get_identifier());
513
+				} while ($addrs && !$id && $id == $record->get_identifier());
514 514
 				return $id;
515 515
 			}
516 516
 		}
@@ -525,22 +525,22 @@  discard block
 block discarded – undo
525 525
 	 * @param string $app Target application name
526 526
 	 * @param string $value CSV value in the form of custom_field_name:value
527 527
 	 */
528
-	protected function link_by_cf(importexport_iface_egw_record &$record, $app, $value,$record_num)
528
+	protected function link_by_cf(importexport_iface_egw_record&$record, $app, $value, $record_num)
529 529
 	{
530 530
 		$app_id = false;
531 531
 
532
-		list($custom_field, $value) = explode(':',$value);
532
+		list($custom_field, $value) = explode(':', $value);
533 533
 		// Find matching entry
534
-		if($app && $custom_field && $value)
534
+		if ($app && $custom_field && $value)
535 535
 		{
536 536
 			$cfs = config::get_customfields($app);
537 537
 			// Error if no custom fields, probably something wrong in definition
538
-			if(!$cfs[$custom_field])
538
+			if (!$cfs[$custom_field])
539 539
 			{
540 540
 				// Check for users specifing label instead of name
541
-				foreach($cfs as $name => $settings)
541
+				foreach ($cfs as $name => $settings)
542 542
 				{
543
-					if(strtolower($settings['label']) == strtolower($custom_field))
543
+					if (strtolower($settings['label']) == strtolower($custom_field))
544 544
 					{
545 545
 						$custom_field = $name;
546 546
 						break;
@@ -549,30 +549,30 @@  discard block
 block discarded – undo
549 549
 			}
550 550
 
551 551
 			// Couldn't find field, give an error - something's wrong
552
-			if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)]) {
552
+			if (!$cfs[$custom_field] && !$cfs[substr($custom_field, 1)]) {
553 553
 				$this->errors[$record_num] .= lang('No custom field "%1" for %2.',
554 554
 					$custom_field, lang($app));
555 555
 				return false;
556 556
 			}
557
-			if($custom_field[0] != '#') $custom_field = '#' . $custom_field;
557
+			if ($custom_field[0] != '#') $custom_field = '#'.$custom_field;
558 558
 error_log("Searching for $custom_field = $value");
559 559
 			// Search
560
-			if(egw_link::get_registry($app, 'query'))
560
+			if (egw_link::get_registry($app, 'query'))
561 561
 			{
562
-				$options = array('filter' => array("$custom_field = " . $GLOBALS['egw']->db->quote($value)));
562
+				$options = array('filter' => array("$custom_field = ".$GLOBALS['egw']->db->quote($value)));
563 563
 				$result = egw_link::query($app, '', $options);
564 564
 
565 565
 				// Only one allowed
566
-				if($record->get_identifier())
566
+				if ($record->get_identifier())
567 567
 				{
568
-					while(key($result) == $record->get_identifier())
568
+					while (key($result) == $record->get_identifier())
569 569
 					{
570 570
 						array_shift($result);
571 571
 					}
572 572
 				}
573
-				if(count($result) != 1)
573
+				if (count($result) != 1)
574 574
 				{
575
-					$this->warnings[$record_num] .= ($this->warnings[$record_num] ? "\n" : '') .
575
+					$this->warnings[$record_num] .= ($this->warnings[$record_num] ? "\n" : '').
576 576
 						lang('Unable to link to %3 by custom field "%1": "%4".  %2 matches.',
577 577
 						$custom_field, count($result), lang($app), $options['filter'][0]
578 578
 					);
Please login to merge, or discard this patch.
importexport/inc/class.importexport_definition.inc.php 4 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -176,7 +176,6 @@
 block discarded – undo
176 176
 	/**
177 177
 	 * sets options
178 178
 	 *
179
-	 * @param array $options
180 179
 	 */
181 180
 	private function set_options(array $_plugin_options) {
182 181
 		$this->definition['plugin_options'] = $_plugin_options;
Please login to merge, or discard this patch.
Braces   +82 added lines, -39 removed lines patch added patch discarded remove patch
@@ -20,7 +20,8 @@  discard block
 block discarded – undo
20 20
  * are in one assiozative array which is complely managed by {Im|Ex}port plugins
21 21
  * @todo testing
22 22
  */
23
-class importexport_definition implements importexport_iface_egw_record {
23
+class importexport_definition implements importexport_iface_egw_record
24
+{
24 25
 
25 26
 	const _appname = 'importexport';
26 27
 	const _defintion_talbe = 'egw_importexport_definitions';
@@ -65,26 +66,36 @@  discard block
 block discarded – undo
65 66
 	 *
66 67
 	 * @param string $_identifier
67 68
 	 */
68
-	public function __construct( $_identifier='' ) {
69
+	public function __construct( $_identifier='' )
70
+	{
69 71
 		$this->so_sql = new Api\Storage\Base(self::_appname ,self::_defintion_talbe);
70 72
 		$this->user = $GLOBALS['egw_info']['user']['user_id'];
71 73
 		$this->is_admin = $GLOBALS['egw_info']['user']['apps']['admin'] || $GLOBALS['egw_setup'] ? true : false;
72 74
 		// compability to string identifiers
73
-		if (!is_numeric($_identifier) && strlen($_identifier) > 3) $_identifier = $this->name2identifier($_identifier);
75
+		if (!is_numeric($_identifier) && strlen($_identifier) > 3)
76
+		{
77
+			$_identifier = $this->name2identifier($_identifier);
78
+		}
74 79
 
75
-		if ((int)$_identifier != 0) {
80
+		if ((int)$_identifier != 0)
81
+		{
76 82
 			$this->definition = $this->so_sql->read(array('definition_id' => $_identifier));
77
-			if ( empty( $this->definition ) ) {
83
+			if ( empty( $this->definition ) )
84
+			{
78 85
 				throw new Exception('Error: No such definition with identifier :"'.$_identifier.'"!');
79 86
 			}
80
-			if ( !( importexport_definitions_bo::is_permitted($this->get_record_array()) || $this->is_admin)) {
87
+			if ( !( importexport_definitions_bo::is_permitted($this->get_record_array()) || $this->is_admin))
88
+			{
81 89
 				throw new Exception('Error: User "'.$this->user.'" is not permitted to get definition with identifier "'.$_identifier.'"!');
82 90
 			}
83 91
 			try
84 92
 			{
85 93
 				$options_data = importexport_arrayxml::xml2array( $this->definition['plugin_options'] );
86 94
 				$this->definition['plugin_options'] = $options_data['root'];
87
-				if($this->definition['filter']) $filter = importexport_arrayxml::xml2array( $this->definition['filter']  );
95
+				if($this->definition['filter'])
96
+				{
97
+					$filter = importexport_arrayxml::xml2array( $this->definition['filter']  );
98
+				}
88 99
 				$this->definition['filter'] = $filter['root'];
89 100
 			}
90 101
 			catch (Exception $e)
@@ -100,12 +111,15 @@  discard block
 block discarded – undo
100 111
 	 * @param string $_name
101 112
 	 * @return int
102 113
 	 */
103
-	private function name2identifier( $_name ) {
114
+	private function name2identifier( $_name )
115
+	{
104 116
 		$identifiers = $this->so_sql->search(array('name' => $_name),true);
105
-		if (isset($identifiers[1])) {
117
+		if (isset($identifiers[1]))
118
+		{
106 119
 			throw new Exception('Error: Definition: "'.$_name. '" is not unique! Can\'t convert to identifier');
107 120
 		}
108
-		if ( empty( $identifiers[0] ) ) {
121
+		if ( empty( $identifiers[0] ) )
122
+		{
109 123
 			// not a good idea, till we don't have different exceptions so far
110 124
 			// throw new Exception('Error: No such definition :"'.$_name.'"!');
111 125
 			$identifiers = array( array( 'definition_id' => 0 ) );
@@ -113,11 +127,14 @@  discard block
 block discarded – undo
113 127
 		return $identifiers[0]['definition_id'];
114 128
 	}
115 129
 
116
-	public function __get($_attribute_name) {
117
-		if (!array_key_exists($_attribute_name,$this->attributes)) {
130
+	public function __get($_attribute_name)
131
+	{
132
+		if (!array_key_exists($_attribute_name,$this->attributes))
133
+		{
118 134
 			throw new Exception('Error: "'. $_attribute_name. '" is not an attribute defintion');
119 135
 		}
120
-		switch ($_attribute_name) {
136
+		switch ($_attribute_name)
137
+		{
121 138
 			case 'allowed_users' :
122 139
 				return $this->get_allowed_users();
123 140
 			case 'plugin_options' :
@@ -129,11 +146,14 @@  discard block
 block discarded – undo
129 146
 		}
130 147
 	}
131 148
 
132
-	public function __set($_attribute_name,$_data) {
133
-		if (!array_key_exists($_attribute_name,$this->attributes)) {
149
+	public function __set($_attribute_name,$_data)
150
+	{
151
+		if (!array_key_exists($_attribute_name,$this->attributes))
152
+		{
134 153
 			throw new Exception('Error: "'. $_attribute_name. '" is not an attribute defintion');
135 154
 		}
136
-		switch ($_attribute_name) {
155
+		switch ($_attribute_name)
156
+		{
137 157
 			case 'allowed_users' :
138 158
 				return $this->set_allowed_users($_data);
139 159
 			case 'plugin_options' :
@@ -151,7 +171,8 @@  discard block
 block discarded – undo
151 171
 	 *
152 172
 	 * @return array
153 173
 	 */
154
-	private function get_allowed_users() {
174
+	private function get_allowed_users()
175
+	{
155 176
 		return explode(',',substr($this->definition['allowed_users'],1,-1));
156 177
 	}
157 178
 
@@ -160,7 +181,8 @@  discard block
 block discarded – undo
160 181
 	 *
161 182
 	 * @param array $_allowed_users
162 183
 	 */
163
-	private function set_allowed_users( $_allowed_users ) {
184
+	private function set_allowed_users( $_allowed_users )
185
+	{
164 186
 		$this->definition['allowed_users'] = ','.implode(',',(array)$_allowed_users) .',';
165 187
 	}
166 188
 
@@ -169,7 +191,8 @@  discard block
 block discarded – undo
169 191
 	 *
170 192
 	 * @return array
171 193
 	 */
172
-	private function get_options() {
194
+	private function get_options()
195
+	{
173 196
 		return $this->definition['plugin_options'];
174 197
 	}
175 198
 
@@ -178,7 +201,8 @@  discard block
 block discarded – undo
178 201
 	 *
179 202
 	 * @param array $options
180 203
 	 */
181
-	private function set_options(array $_plugin_options) {
204
+	private function set_options(array $_plugin_options)
205
+	{
182 206
 		$this->definition['plugin_options'] = $_plugin_options;
183 207
 	}
184 208
 
@@ -187,7 +211,8 @@  discard block
 block discarded – undo
187 211
 	 *
188 212
 	 * @return array
189 213
 	 */
190
-	private function get_filter() {
214
+	private function get_filter()
215
+	{
191 216
 		return $this->definition['filter'];
192 217
 	}
193 218
 
@@ -196,7 +221,8 @@  discard block
 block discarded – undo
196 221
 	 *
197 222
 	 * @param filter array of field => settings
198 223
 	 */
199
-	private function set_filter(Array $filter) {
224
+	private function set_filter(Array $filter)
225
+	{
200 226
 		$this->definition['filter'] = $filter;
201 227
 	}
202 228
 
@@ -208,7 +234,8 @@  discard block
 block discarded – undo
208 234
 	 *
209 235
 	 * @return array complete record as associative array
210 236
 	 */
211
-	public function get_record_array() {
237
+	public function get_record_array()
238
+	{
212 239
 		$definition = $this->definition;
213 240
 		$definition['allowed_users'] = $this->get_allowed_users();
214 241
 		$definition['plugin_options'] = $this->get_options();
@@ -221,7 +248,8 @@  discard block
 block discarded – undo
221 248
 	 *
222 249
 	 *@return string tiltle
223 250
 	 */
224
-	public function get_title() {
251
+	public function get_title()
252
+	{
225 253
 		return $this->definition['name'];
226 254
 	}
227 255
 
@@ -230,13 +258,16 @@  discard block
 block discarded – undo
230 258
 	 *
231 259
 	 * @return void
232 260
 	 */
233
-	public function set_record( array $_record ) {
261
+	public function set_record( array $_record )
262
+	{
234 263
 		$this->definition = array_intersect_key( $_record, $this->attributes );
235 264
 
236 265
 		// anything which is not an attribute is perhaps a plugin_option.
237 266
 		// If not, it gets whiped out on save time.
238
-		foreach ( $_record as $attribute => $value) {
239
-			if ( !array_key_exists( $attribute, $this->attributes ) ) {
267
+		foreach ( $_record as $attribute => $value)
268
+		{
269
+			if ( !array_key_exists( $attribute, $this->attributes ) )
270
+			{
240 271
 				$this->definition['plugin_options'][$attribute] = $value;
241 272
 			}
242 273
 		}
@@ -254,7 +285,8 @@  discard block
 block discarded – undo
254 285
 	 *
255 286
 	 * @return int identifier of this record
256 287
 	 */
257
-	public function get_identifier() {
288
+	public function get_identifier()
289
+	{
258 290
 		return $this->definition['definition_id'];
259 291
 	}
260 292
 
@@ -265,7 +297,8 @@  discard block
 block discarded – undo
265 297
 	 *
266 298
 	 * @return string Full URL of an icon, or appname/icon_name
267 299
 	 */
268
-	public function get_icon() {
300
+	public function get_icon()
301
+	{
269 302
 		return self::_appname . '/navbar';
270 303
 	}
271 304
 
@@ -274,8 +307,10 @@  discard block
 block discarded – undo
274 307
 	 *
275 308
 	 * @return string identifier
276 309
 	 */
277
-	public function save ( $_dst_identifier ) {
278
-		if ( strlen($this->definition['name']) < 3 ) {
310
+	public function save ( $_dst_identifier )
311
+	{
312
+		if ( strlen($this->definition['name']) < 3 )
313
+		{
279 314
 			throw new Exception('Error: Can\'t save definition, no valid name given!');
280 315
 		}
281 316
 
@@ -283,7 +318,8 @@  discard block
 block discarded – undo
283 318
 		$this->so_sql->data['plugin_options'] = importexport_arrayxml::array2xml( $this->definition['plugin_options'] );
284 319
 		$this->so_sql->data['filter'] = importexport_arrayxml::array2xml( $this->definition['filter'] );
285 320
 		$this->so_sql->data['modified'] = time();
286
-		if ($this->so_sql->save( array( 'definition_id' => $_dst_identifier ))) {
321
+		if ($this->so_sql->save( array( 'definition_id' => $_dst_identifier )))
322
+		{
287 323
 			throw new Exception('Error: Api\Storage\Base was not able to save definition: '.$this->get_identifier());
288 324
 		}
289 325
 
@@ -296,7 +332,8 @@  discard block
 block discarded – undo
296 332
 	 * @param string $_dst_identifier
297 333
 	 * @return string dst_identifier
298 334
 	 */
299
-	public function copy ( $_dst_identifier ) {
335
+	public function copy ( $_dst_identifier )
336
+	{
300 337
 		$dst_object = clone $this;
301 338
 		try {
302 339
 			$dst_object->set_owner($this->user);
@@ -317,8 +354,10 @@  discard block
 block discarded – undo
317 354
 	 * @param string $_dst_identifier
318 355
 	 * @return string dst_identifier
319 356
 	 */
320
-	public function move ( $_dst_identifier ) {
321
-		if ($this->user != $this->get_owner() && !$this->is_admin) {
357
+	public function move ( $_dst_identifier )
358
+	{
359
+		if ($this->user != $this->get_owner() && !$this->is_admin)
360
+		{
322 361
 			throw('Error: User '. $this->user. 'does not have permissions to move definition '.$this->get_identifier());
323 362
 		}
324 363
 		$old_object = clone $this;
@@ -339,11 +378,14 @@  discard block
 block discarded – undo
339 378
 	 * @return void
340 379
 	 *
341 380
 	 */
342
-	public function delete () {
343
-		if($this->user != $this->get_owner() && !$this->is_admin) {
381
+	public function delete ()
382
+	{
383
+		if($this->user != $this->get_owner() && !$this->is_admin)
384
+		{
344 385
 			throw('Error: User '. $this->user. 'does not have permissions to delete definition '.$this->get_identifier());
345 386
 		}
346
-		if(!$this->so_sql->delete()) {
387
+		if(!$this->so_sql->delete())
388
+		{
347 389
 			throw('Error: Api\Storage\Base was not able to delete definition: '.$this->get_identifier());
348 390
 		}
349 391
 	}
@@ -352,7 +394,8 @@  discard block
 block discarded – undo
352 394
 	 * destructor
353 395
 	 *
354 396
 	 */
355
-	public function __destruct() {
397
+	public function __destruct()
398
+	{
356 399
 		unset($this->so_sql);
357 400
 	}
358 401
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -196,7 +196,7 @@
 block discarded – undo
196 196
 	 *
197 197
 	 * @param filter array of field => settings
198 198
 	 */
199
-	private function set_filter(Array $filter) {
199
+	private function set_filter(array $filter) {
200 200
 		$this->definition['filter'] = $filter;
201 201
 	}
202 202
 
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 	 *
64 64
 	 * @param string $_identifier
65 65
 	 */
66
-	public function __construct( $_identifier='' ) {
67
-		$this->so_sql = new so_sql(self::_appname ,self::_defintion_talbe);
66
+	public function __construct($_identifier = '') {
67
+		$this->so_sql = new so_sql(self::_appname, self::_defintion_talbe);
68 68
 		$this->user = $GLOBALS['egw_info']['user']['user_id'];
69 69
 		$this->is_admin = $GLOBALS['egw_info']['user']['apps']['admin'] || $GLOBALS['egw_setup'] ? true : false;
70 70
 		// compability to string identifiers
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
 
73 73
 		if ((int)$_identifier != 0) {
74 74
 			$this->definition = $this->so_sql->read(array('definition_id' => $_identifier));
75
-			if ( empty( $this->definition ) ) {
75
+			if (empty($this->definition)) {
76 76
 				throw new Exception('Error: No such definition with identifier :"'.$_identifier.'"!');
77 77
 			}
78
-			if ( !( importexport_definitions_bo::is_permitted($this->get_record_array()) || $this->is_admin)) {
78
+			if (!(importexport_definitions_bo::is_permitted($this->get_record_array()) || $this->is_admin)) {
79 79
 				throw new Exception('Error: User "'.$this->user.'" is not permitted to get definition with identifier "'.$_identifier.'"!');
80 80
 			}
81 81
 			try
82 82
 			{
83
-				$options_data = importexport_arrayxml::xml2array( $this->definition['plugin_options'] );
83
+				$options_data = importexport_arrayxml::xml2array($this->definition['plugin_options']);
84 84
 				$this->definition['plugin_options'] = $options_data['root'];
85
-				if($this->definition['filter']) $filter = importexport_arrayxml::xml2array( $this->definition['filter']  );
85
+				if ($this->definition['filter']) $filter = importexport_arrayxml::xml2array($this->definition['filter']);
86 86
 				$this->definition['filter'] = $filter['root'];
87 87
 			}
88 88
 			catch (Exception $e)
@@ -98,22 +98,22 @@  discard block
 block discarded – undo
98 98
 	 * @param string $_name
99 99
 	 * @return int
100 100
 	 */
101
-	private function name2identifier( $_name ) {
102
-		$identifiers = $this->so_sql->search(array('name' => $_name),true);
101
+	private function name2identifier($_name) {
102
+		$identifiers = $this->so_sql->search(array('name' => $_name), true);
103 103
 		if (isset($identifiers[1])) {
104
-			throw new Exception('Error: Definition: "'.$_name. '" is not unique! Can\'t convert to identifier');
104
+			throw new Exception('Error: Definition: "'.$_name.'" is not unique! Can\'t convert to identifier');
105 105
 		}
106
-		if ( empty( $identifiers[0] ) ) {
106
+		if (empty($identifiers[0])) {
107 107
 			// not a good idea, till we don't have different exceptions so far
108 108
 			// throw new Exception('Error: No such definition :"'.$_name.'"!');
109
-			$identifiers = array( array( 'definition_id' => 0 ) );
109
+			$identifiers = array(array('definition_id' => 0));
110 110
 		}
111 111
 		return $identifiers[0]['definition_id'];
112 112
 	}
113 113
 
114 114
 	public function __get($_attribute_name) {
115
-		if (!array_key_exists($_attribute_name,$this->attributes)) {
116
-			throw new Exception('Error: "'. $_attribute_name. '" is not an attribute defintion');
115
+		if (!array_key_exists($_attribute_name, $this->attributes)) {
116
+			throw new Exception('Error: "'.$_attribute_name.'" is not an attribute defintion');
117 117
 		}
118 118
 		switch ($_attribute_name) {
119 119
 			case 'allowed_users' :
@@ -127,9 +127,9 @@  discard block
 block discarded – undo
127 127
 		}
128 128
 	}
129 129
 
130
-	public function __set($_attribute_name,$_data) {
131
-		if (!array_key_exists($_attribute_name,$this->attributes)) {
132
-			throw new Exception('Error: "'. $_attribute_name. '" is not an attribute defintion');
130
+	public function __set($_attribute_name, $_data) {
131
+		if (!array_key_exists($_attribute_name, $this->attributes)) {
132
+			throw new Exception('Error: "'.$_attribute_name.'" is not an attribute defintion');
133 133
 		}
134 134
 		switch ($_attribute_name) {
135 135
 			case 'allowed_users' :
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 * @return array
151 151
 	 */
152 152
 	private function get_allowed_users() {
153
-		return explode(',',substr($this->definition['allowed_users'],1,-1));
153
+		return explode(',', substr($this->definition['allowed_users'], 1, -1));
154 154
 	}
155 155
 
156 156
 	/**
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	 *
159 159
 	 * @param array $_allowed_users
160 160
 	 */
161
-	private function set_allowed_users( $_allowed_users ) {
162
-		$this->definition['allowed_users'] = ','.implode(',',(array)$_allowed_users) .',';
161
+	private function set_allowed_users($_allowed_users) {
162
+		$this->definition['allowed_users'] = ','.implode(',', (array)$_allowed_users).',';
163 163
 	}
164 164
 
165 165
 	/**
@@ -228,13 +228,13 @@  discard block
 block discarded – undo
228 228
 	 *
229 229
 	 * @return void
230 230
 	 */
231
-	public function set_record( array $_record ) {
232
-		$this->definition = array_intersect_key( $_record, $this->attributes );
231
+	public function set_record(array $_record) {
232
+		$this->definition = array_intersect_key($_record, $this->attributes);
233 233
 
234 234
 		// anything which is not an attribute is perhaps a plugin_option.
235 235
 		// If not, it gets whiped out on save time.
236
-		foreach ( $_record as $attribute => $value) {
237
-			if ( !array_key_exists( $attribute, $this->attributes ) ) {
236
+		foreach ($_record as $attribute => $value) {
237
+			if (!array_key_exists($attribute, $this->attributes)) {
238 238
 				$this->definition['plugin_options'][$attribute] = $value;
239 239
 			}
240 240
 		}
@@ -242,9 +242,9 @@  discard block
 block discarded – undo
242 242
 		$this->plugin = $_record['plugin'];
243 243
 
244 244
 		// convert plugin_options into internal representation
245
-		$this->set_allowed_users( $this->definition['allowed_users'] );
246
-		$this->set_options( $this->definition['plugin_options'] ? $this->definition['plugin_options'] : array());
247
-		$this->set_filter( $this->definition['filter'] ? $this->definition['filter'] : array());
245
+		$this->set_allowed_users($this->definition['allowed_users']);
246
+		$this->set_options($this->definition['plugin_options'] ? $this->definition['plugin_options'] : array());
247
+		$this->set_filter($this->definition['filter'] ? $this->definition['filter'] : array());
248 248
 	}
249 249
 
250 250
 	/**
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 	 * @return string Full URL of an icon, or appname/icon_name
265 265
 	 */
266 266
 	public function get_icon() {
267
-		return self::_appname . '/navbar';
267
+		return self::_appname.'/navbar';
268 268
 	}
269 269
 
270 270
 	/**
@@ -272,16 +272,16 @@  discard block
 block discarded – undo
272 272
 	 *
273 273
 	 * @return string identifier
274 274
 	 */
275
-	public function save ( $_dst_identifier ) {
276
-		if ( strlen($this->definition['name']) < 3 ) {
275
+	public function save($_dst_identifier) {
276
+		if (strlen($this->definition['name']) < 3) {
277 277
 			throw new Exception('Error: Can\'t save definition, no valid name given!');
278 278
 		}
279 279
 
280 280
 		$this->so_sql->data = $this->definition;
281
-		$this->so_sql->data['plugin_options'] = importexport_arrayxml::array2xml( $this->definition['plugin_options'] );
282
-		$this->so_sql->data['filter'] = importexport_arrayxml::array2xml( $this->definition['filter'] );
281
+		$this->so_sql->data['plugin_options'] = importexport_arrayxml::array2xml($this->definition['plugin_options']);
282
+		$this->so_sql->data['filter'] = importexport_arrayxml::array2xml($this->definition['filter']);
283 283
 		$this->so_sql->data['modified'] = time();
284
-		if ($this->so_sql->save( array( 'definition_id' => $_dst_identifier ))) {
284
+		if ($this->so_sql->save(array('definition_id' => $_dst_identifier))) {
285 285
 			throw new Exception('Error: so_sql was not able to save definition: '.$this->get_identifier());
286 286
 		}
287 287
 
@@ -294,13 +294,13 @@  discard block
 block discarded – undo
294 294
 	 * @param string $_dst_identifier
295 295
 	 * @return string dst_identifier
296 296
 	 */
297
-	public function copy ( $_dst_identifier ) {
297
+	public function copy($_dst_identifier) {
298 298
 		$dst_object = clone $this;
299 299
 		try {
300 300
 			$dst_object->set_owner($this->user);
301 301
 			$dst_identifier = $dst_object->save($_dst_identifier);
302 302
 		}
303
-		catch(exception $Exception) {
303
+		catch (exception $Exception) {
304 304
 			unset($dst_object);
305 305
 			throw $Exception;
306 306
 		}
@@ -315,16 +315,16 @@  discard block
 block discarded – undo
315 315
 	 * @param string $_dst_identifier
316 316
 	 * @return string dst_identifier
317 317
 	 */
318
-	public function move ( $_dst_identifier ) {
318
+	public function move($_dst_identifier) {
319 319
 		if ($this->user != $this->get_owner() && !$this->is_admin) {
320
-			throw('Error: User '. $this->user. 'does not have permissions to move definition '.$this->get_identifier());
320
+			throw('Error: User '.$this->user.'does not have permissions to move definition '.$this->get_identifier());
321 321
 		}
322 322
 		$old_object = clone $this;
323 323
 		try {
324 324
 			$dst_identifier = $this->save($_dst_identifier);
325 325
 			$old_object->delete();
326 326
 		}
327
-		catch(exception $Exception) {
327
+		catch (exception $Exception) {
328 328
 			unset($old_object);
329 329
 			throw $Exception;
330 330
 		}
@@ -337,11 +337,11 @@  discard block
 block discarded – undo
337 337
 	 * @return void
338 338
 	 *
339 339
 	 */
340
-	public function delete () {
341
-		if($this->user != $this->get_owner() && !$this->is_admin) {
342
-			throw('Error: User '. $this->user. 'does not have permissions to delete definition '.$this->get_identifier());
340
+	public function delete() {
341
+		if ($this->user != $this->get_owner() && !$this->is_admin) {
342
+			throw('Error: User '.$this->user.'does not have permissions to delete definition '.$this->get_identifier());
343 343
 		}
344
-		if(!$this->so_sql->delete()) {
344
+		if (!$this->so_sql->delete()) {
345 345
 			throw('Error: so_sql was not able to delete definition: '.$this->get_identifier());
346 346
 		}
347 347
 	}
Please login to merge, or discard this patch.
importexport/inc/class.importexport_definitions_bo.inc.php 5 patches
Doc Comments   +1 added lines, -3 removed lines patch added patch discarded remove patch
@@ -139,7 +139,6 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	 */
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -137,10 +137,10 @@
 block discarded – undo
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);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@
 block discarded – undo
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']);
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -29,13 +29,13 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	private $definitions;
31 31
 
32
-	public function __construct($_query=false, $ignore_acl = false)
32
+	public function __construct($_query = false, $ignore_acl = false)
33 33
 	{
34
-		$this->so_sql = new so_sql(self::_appname, self::_defintion_table );
34
+		$this->so_sql = new so_sql(self::_appname, self::_defintion_table);
35 35
 		if ($_query) {
36 36
 			$definitions = $this->so_sql->search($_query, false);
37 37
 			foreach ((array)$definitions as $definition) {
38
-				if(self::is_permitted($definition) || $ignore_acl) $this->definitions[] = $definition['definition_id'];
38
+				if (self::is_permitted($definition) || $ignore_acl) $this->definitions[] = $definition['definition_id'];
39 39
 			}
40 40
 		}
41 41
 	}
@@ -43,16 +43,16 @@  discard block
 block discarded – undo
43 43
 	public function get_rows(&$query, &$rows, &$readonlys)
44 44
 	{
45 45
 		// Filter only definitions user is allowed to use
46
-		if(!$GLOBALS['egw_info']['user']['apps']['admin']) {
46
+		if (!$GLOBALS['egw_info']['user']['apps']['admin']) {
47 47
 			$this_membership = $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true);
48 48
 			$this_membership[] = $GLOBALS['egw_info']['user']['account_id'];
49 49
 			$sql .= ' (';
50 50
 			$read = array();
51
-			foreach($this_membership as $id)
51
+			foreach ($this_membership as $id)
52 52
 			{
53 53
 				$read[] = 'allowed_users '.
54 54
 					$GLOBALS['egw']->db->capabilities['case_insensitive_like'].' '.
55
-					$GLOBALS['egw']->db->quote('%,'.str_replace('_','\\_',$id) .',%');
55
+					$GLOBALS['egw']->db->quote('%,'.str_replace('_', '\\_', $id).',%');
56 56
 			}
57 57
 			$sql .= implode(' OR ', $read);
58 58
 			$sql .= ') OR owner = '.$GLOBALS['egw_info']['user']['account_id'];
@@ -60,37 +60,37 @@  discard block
 block discarded – undo
60 60
 		}
61 61
 		
62 62
 		// Handle allowed filter
63
-		if($query['col_filter']['allowed_users'])
63
+		if ($query['col_filter']['allowed_users'])
64 64
 		{
65 65
 			$allowed = array();
66
-			foreach((array)$query['col_filter']['allowed_users'] as $id)
66
+			foreach ((array)$query['col_filter']['allowed_users'] as $id)
67 67
 			{
68 68
 				$allowed[] = 'allowed_users '.
69 69
 					$GLOBALS['egw']->db->capabilities['case_insensitive_like'].' '.
70
-					$GLOBALS['egw']->db->quote('%,'.str_replace('_','\\_',$id) .',%');
70
+					$GLOBALS['egw']->db->quote('%,'.str_replace('_', '\\_', $id).',%');
71 71
 			}
72
-			if($allowed)
72
+			if ($allowed)
73 73
 			{
74 74
 				unset($query['col_filter']['allowed_users']);
75
-				$query['col_filter'][] = '('.implode(' OR ', $allowed) . ')';
75
+				$query['col_filter'][] = '('.implode(' OR ', $allowed).')';
76 76
 			}
77 77
 		}
78 78
 		
79 79
 		$total = $this->so_sql->get_rows($query, $rows, $readonlys);
80 80
 		$ro_count = 0;
81
-		foreach($rows as &$row) {
81
+		foreach ($rows as &$row) {
82 82
 			// Strip off leading + trailing ,
83
-			$row['allowed_users'] = substr($row['allowed_users'],1,-1);
83
+			$row['allowed_users'] = substr($row['allowed_users'], 1, -1);
84 84
 
85 85
 			$readonlys["edit[{$row['definition_id']}]"] = $readonlys["delete[{$row['definition_id']}]"] =
86 86
 				($row['owner'] != $GLOBALS['egw_info']['user']['account_id']) &&
87 87
 				!$GLOBALS['egw_info']['user']['apps']['admin'];
88
-			if($readonlys["edit[{$row['definition_id']}]"])
88
+			if ($readonlys["edit[{$row['definition_id']}]"])
89 89
 			{
90 90
 				$row['class'] .= 'rowNoEdit rowNoDelete';
91 91
 				$ro_count++;
92 92
 			}
93
-			$row['class'] .= ' ' . $row['type'];
93
+			$row['class'] .= ' '.$row['type'];
94 94
 		}
95 95
 		$readonlys['delete_selected'] = $ro_count == count($rows);
96 96
 		return $total;
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
 		return $this->definitions;
106 106
 	}
107 107
 	public function read($definition_id) {
108
-		if(is_numeric($definition_id)) {
108
+		if (is_numeric($definition_id)) {
109 109
 			$this->so_sql->read($definition_id);
110 110
 			$definition = new importexport_definition($this->so_sql->data['name']);
111 111
 		} else {
112
-			$definition = new importexport_definition( $definition_id['name'] );
112
+			$definition = new importexport_definition($definition_id['name']);
113 113
 		}
114 114
 		return $definition->get_record_array();
115 115
 	}
@@ -122,14 +122,14 @@  discard block
 block discarded – undo
122 122
 		foreach ($keys as $index => $key) {
123 123
 			// Check for ownership
124 124
 			$definition = $this->read($key);
125
-			if($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id'] || $GLOBALS['egw_info']['user']['apps']['admin']) {
125
+			if ($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id'] || $GLOBALS['egw_info']['user']['apps']['admin']) {
126 126
 				// clear private cache
127
-				unset($this->definitions[array_search($key,$this->definitions)]);
127
+				unset($this->definitions[array_search($key, $this->definitions)]);
128 128
 			} else {
129 129
 				unset($keys[$index]);
130 130
 			}
131 131
 		}
132
-		if(count($keys) > 0) {
132
+		if (count($keys) > 0) {
133 133
 			$this->so_sql->delete(array('definition_id' => $keys));
134 134
 		}
135 135
 	}
@@ -152,12 +152,12 @@  discard block
 block discarded – undo
152 152
 	 * @return bool
153 153
 	 */
154 154
 	static public function is_permitted($_definition) {
155
-		$allowed_user = is_array($_definition['allowed_users']) ? $_definition['allowed_users'] : explode(',',$_definition['allowed_users']);
155
+		$allowed_user = is_array($_definition['allowed_users']) ? $_definition['allowed_users'] : explode(',', $_definition['allowed_users']);
156 156
 		$this_user_id = $GLOBALS['egw_info']['user']['account_id'];
157 157
 		$this_membership = $GLOBALS['egw']->accounts->memberships($this_user_id, true);
158 158
 		$this_membership[] = $this_user_id;
159 159
 		$this_membership[] = 'all';
160
-		$alluser = array_intersect($allowed_user,$this_membership);
160
+		$alluser = array_intersect($allowed_user, $this_membership);
161 161
 		return ($this_user_id == $_definition['owner'] || count($alluser) > 0);
162 162
 	}
163 163
 
@@ -176,13 +176,13 @@  discard block
 block discarded – undo
176 176
 
177 177
 		$export_data['definitions'] = array();
178 178
 		foreach ($keys as $definition_id) {
179
-			$definition = new importexport_definition( $definition_id );
179
+			$definition = new importexport_definition($definition_id);
180 180
 			$export_data['definitions'][$definition->name] = $definition->get_record_array();
181 181
 			$export_data['definitions'][$definition->name]['allowed_users'] =
182 182
 				importexport_helper_functions::account_id2name(
183 183
 					$export_data['definitions'][$definition->name]['allowed_users']
184 184
 				);
185
-			if($export_date['definitions'][$definition->name]['owner']) {
185
+			if ($export_date['definitions'][$definition->name]['owner']) {
186 186
 				$export_data['definitions'][$definition->name]['owner'] =
187 187
 					importexport_helper_functions::account_id2name(
188 188
 						$export_data['definitions'][$definition->name]['owner']
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 			unset($export_data['definitions'][$definition->name]['definition_id']);
194 194
 			unset($export_data['definitions'][$definition->name]['description']);
195 195
 			unset($export_data['definitions'][$definition->name]['user_timezone_read']);
196
-			if(is_array($export_data['definitions'][$definition->name]['plugin_options'])) {
196
+			if (is_array($export_data['definitions'][$definition->name]['plugin_options'])) {
197 197
 				unset($export_data['definitions'][$definition->name]['plugin_options']['user_timezone_read']);
198 198
 			}
199 199
 			unset($definition);
@@ -211,17 +211,17 @@  discard block
 block discarded – undo
211 211
 	 * @throws Exeption
212 212
 	 * @return void
213 213
 	 */
214
-	public static function import( $_import_file )
214
+	public static function import($_import_file)
215 215
 	{
216
-		if ( !is_file( $_import_file ) ) {
217
-			throw new Exception("'$_import_file' does not exist or is not readable" );
216
+		if (!is_file($_import_file)) {
217
+			throw new Exception("'$_import_file' does not exist or is not readable");
218 218
 		}
219 219
 
220
-		$data = importexport_arrayxml::xml2array( file_get_contents( $_import_file ) );
220
+		$data = importexport_arrayxml::xml2array(file_get_contents($_import_file));
221 221
 
222 222
 		$metainfo = $data['importExportDefinitions']['metainfo'];
223 223
 		$definitions = $data['importExportDefinitions']['definitions'];
224
-		unset ( $data );
224
+		unset ($data);
225 225
 
226 226
 		// convert charset into internal used charset
227 227
 		$definitions = translation::convert(
@@ -231,26 +231,26 @@  discard block
 block discarded – undo
231 231
 		);
232 232
 
233 233
 		// Avoid warning if no definitions found
234
-		if(!is_array($definitions)) return lang('None found');
234
+		if (!is_array($definitions)) return lang('None found');
235 235
 
236 236
 		// save definition(s) into internal table
237
-		foreach ( $definitions as $name => $definition_data )
237
+		foreach ($definitions as $name => $definition_data)
238 238
 		{
239 239
 			// convert allowed_user
240
-			$definition_data['allowed_users'] = importexport_helper_functions::account_name2id( $definition_data['allowed_users'] );
241
-			if($definition_data['all_users'] && !$definition_data['allowed_users']) $definition_data['allowed_users'] = 'all';
240
+			$definition_data['allowed_users'] = importexport_helper_functions::account_name2id($definition_data['allowed_users']);
241
+			if ($definition_data['all_users'] && !$definition_data['allowed_users']) $definition_data['allowed_users'] = 'all';
242 242
 
243
-			$definition_data['owner'] = importexport_helper_functions::account_name2id( $definition_data['owner'] );
243
+			$definition_data['owner'] = importexport_helper_functions::account_name2id($definition_data['owner']);
244 244
 
245
-			$definition = new importexport_definition( $definition_data['name'] );
245
+			$definition = new importexport_definition($definition_data['name']);
246 246
 
247 247
 			// Only update if the imported is newer
248
-			if(strtotime($definition->modified) < strtotime($definition_data['modified']) || $definition->modified == 0)
248
+			if (strtotime($definition->modified) < strtotime($definition_data['modified']) || $definition->modified == 0)
249 249
 			{
250 250
 				$definition_id = $definition->get_identifier() ? $definition->get_identifier() : NULL;
251 251
 
252
-				$definition->set_record( $definition_data );
253
-				$definition->save( $definition_id );
252
+				$definition->set_record($definition_data);
253
+				$definition->save($definition_id);
254 254
 			}
255 255
 		}
256 256
 		return $definitions;
@@ -273,28 +273,28 @@  discard block
 block discarded – undo
273 273
 	public static function export_from_import(importexport_definition $import)
274 274
 	{
275 275
 		// Only operates on import definitions
276
-		if($import->type != 'import') throw new egw_exception_wrong_parameter('Only import definitions');
276
+		if ($import->type != 'import') throw new egw_exception_wrong_parameter('Only import definitions');
277 277
 
278 278
 		// Find export plugin
279
-		$plugin = str_replace('import', 'export',$import->plugin);
279
+		$plugin = str_replace('import', 'export', $import->plugin);
280 280
 		$plugin_list = importexport_helper_functions::get_plugins($import->application, 'export');
281
-		foreach($plugin_list as $appname => $type)
281
+		foreach ($plugin_list as $appname => $type)
282 282
 		{
283 283
 			$plugins = $type['export'];
284
-			foreach($plugins as $name => $label)
284
+			foreach ($plugins as $name => $label)
285 285
 			{
286
-				if($plugin == $name) break;
286
+				if ($plugin == $name) break;
287 287
 			}
288
-			if($plugin !== $name) $plugin = $name;
288
+			if ($plugin !== $name) $plugin = $name;
289 289
 		}
290 290
 
291 291
 		$export = new importexport_definition();
292 292
 
293 293
 		// Common settings
294
-		$export->name = str_replace('import', 'export',$import->name);
295
-		if($export->name == $import->name) $export->name = $export->name . '-export';
294
+		$export->name = str_replace('import', 'export', $import->name);
295
+		if ($export->name == $import->name) $export->name = $export->name.'-export';
296 296
 		$test = new importexport_definition($export->name);
297
-		if($test->name) $export->name = $export->name .'-'.$GLOBALS['egw_info']['user']['account_lid'];
297
+		if ($test->name) $export->name = $export->name.'-'.$GLOBALS['egw_info']['user']['account_lid'];
298 298
 
299 299
 		$export->application = $import->application;
300 300
 		$export->plugin = $plugin;
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 		);
311 311
 
312 312
 		// Mapping
313
-		foreach($i_options['field_mapping'] as $col_num => $field)
313
+		foreach ($i_options['field_mapping'] as $col_num => $field)
314 314
 		{
315 315
 			// Try to use heading from import file, if possible
316 316
 			$e_options['mapping'][$field] = $i_options['csv_fields'][$col_num] ? $i_options['csv_fields'][$col_num] : $field;
Please login to merge, or discard this patch.
Braces   +77 added lines, -29 removed lines patch added patch discarded remove patch
@@ -14,7 +14,8 @@  discard block
 block discarded – undo
14 14
  *
15 15
  * @todo make this class an egw_record_pool!
16 16
  */
17
-class importexport_definitions_bo {
17
+class importexport_definitions_bo
18
+{
18 19
 
19 20
 	const _appname = 'importexport';
20 21
 	const _defintion_table = 'egw_importexport_definitions';
@@ -32,10 +33,15 @@  discard block
 block discarded – undo
32 33
 	public function __construct($_query=false, $ignore_acl = false)
33 34
 	{
34 35
 		$this->so_sql = new so_sql(self::_appname, self::_defintion_table );
35
-		if ($_query) {
36
+		if ($_query)
37
+		{
36 38
 			$definitions = $this->so_sql->search($_query, false);
37
-			foreach ((array)$definitions as $definition) {
38
-				if(self::is_permitted($definition) || $ignore_acl) $this->definitions[] = $definition['definition_id'];
39
+			foreach ((array)$definitions as $definition)
40
+			{
41
+				if(self::is_permitted($definition) || $ignore_acl)
42
+				{
43
+					$this->definitions[] = $definition['definition_id'];
44
+				}
39 45
 			}
40 46
 		}
41 47
 	}
@@ -43,7 +49,8 @@  discard block
 block discarded – undo
43 49
 	public function get_rows(&$query, &$rows, &$readonlys)
44 50
 	{
45 51
 		// Filter only definitions user is allowed to use
46
-		if(!$GLOBALS['egw_info']['user']['apps']['admin']) {
52
+		if(!$GLOBALS['egw_info']['user']['apps']['admin'])
53
+		{
47 54
 			$this_membership = $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true);
48 55
 			$this_membership[] = $GLOBALS['egw_info']['user']['account_id'];
49 56
 			$sql .= ' (';
@@ -78,7 +85,8 @@  discard block
 block discarded – undo
78 85
 		
79 86
 		$total = $this->so_sql->get_rows($query, $rows, $readonlys);
80 87
 		$ro_count = 0;
81
-		foreach($rows as &$row) {
88
+		foreach($rows as &$row)
89
+		{
82 90
 			// Strip off leading + trailing ,
83 91
 			$row['allowed_users'] = substr($row['allowed_users'],1,-1);
84 92
 
@@ -101,14 +109,19 @@  discard block
 block discarded – undo
101 109
 	 *
102 110
 	 * @return array
103 111
 	 */
104
-	public function get_definitions() {
112
+	public function get_definitions()
113
+	{
105 114
 		return $this->definitions;
106 115
 	}
107
-	public function read($definition_id) {
108
-		if(is_numeric($definition_id)) {
116
+	public function read($definition_id)
117
+	{
118
+		if(is_numeric($definition_id))
119
+		{
109 120
 			$this->so_sql->read($definition_id);
110 121
 			$definition = new importexport_definition($this->so_sql->data['name']);
111
-		} else {
122
+		}
123
+		else
124
+		{
112 125
 			$definition = new importexport_definition( $definition_id['name'] );
113 126
 		}
114 127
 		return $definition->get_record_array();
@@ -118,18 +131,24 @@  discard block
 block discarded – undo
118 131
 	 *
119 132
 	 * @param array $keys
120 133
 	 */
121
-	public function delete($keys) {
122
-		foreach ($keys as $index => $key) {
134
+	public function delete($keys)
135
+	{
136
+		foreach ($keys as $index => $key)
137
+		{
123 138
 			// Check for ownership
124 139
 			$definition = $this->read($key);
125
-			if($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id'] || $GLOBALS['egw_info']['user']['apps']['admin']) {
140
+			if($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id'] || $GLOBALS['egw_info']['user']['apps']['admin'])
141
+			{
126 142
 				// clear private cache
127 143
 				unset($this->definitions[array_search($key,$this->definitions)]);
128
-			} else {
144
+			}
145
+			else
146
+			{
129 147
 				unset($keys[$index]);
130 148
 			}
131 149
 		}
132
-		if(count($keys) > 0) {
150
+		if(count($keys) > 0)
151
+		{
133 152
 			$this->so_sql->delete(array('definition_id' => $keys));
134 153
 		}
135 154
 	}
@@ -139,7 +158,8 @@  discard block
 block discarded – undo
139 158
 	*
140 159
 	* @param definition $definition
141 160
 	*/
142
-	public function save(Array $data) {
161
+	public function save(Array $data)
162
+	{
143 163
 		$definition = new importexport_definition();
144 164
 		$definition->set_record($data);
145 165
 		$definition->save($data['definition_id']);
@@ -151,7 +171,8 @@  discard block
 block discarded – undo
151 171
 	 * @param array $_definition
152 172
 	 * @return bool
153 173
 	 */
154
-	static public function is_permitted($_definition) {
174
+	static public function is_permitted($_definition)
175
+	{
155 176
 		$allowed_user = is_array($_definition['allowed_users']) ? $_definition['allowed_users'] : explode(',',$_definition['allowed_users']);
156 177
 		$this_user_id = $GLOBALS['egw_info']['user']['account_id'];
157 178
 		$this_membership = $GLOBALS['egw']->accounts->memberships($this_user_id, true);
@@ -175,25 +196,30 @@  discard block
 block discarded – undo
175 196
 		));
176 197
 
177 198
 		$export_data['definitions'] = array();
178
-		foreach ($keys as $definition_id) {
199
+		foreach ($keys as $definition_id)
200
+		{
179 201
 			$definition = new importexport_definition( $definition_id );
180 202
 			$export_data['definitions'][$definition->name] = $definition->get_record_array();
181 203
 			$export_data['definitions'][$definition->name]['allowed_users'] =
182 204
 				importexport_helper_functions::account_id2name(
183 205
 					$export_data['definitions'][$definition->name]['allowed_users']
184 206
 				);
185
-			if($export_date['definitions'][$definition->name]['owner']) {
207
+			if($export_date['definitions'][$definition->name]['owner'])
208
+			{
186 209
 				$export_data['definitions'][$definition->name]['owner'] =
187 210
 					importexport_helper_functions::account_id2name(
188 211
 						$export_data['definitions'][$definition->name]['owner']
189 212
 					);
190
-			} else {
213
+			}
214
+			else
215
+			{
191 216
 				unset($export_data['definitions'][$definition->name]['owner']);
192 217
 			}
193 218
 			unset($export_data['definitions'][$definition->name]['definition_id']);
194 219
 			unset($export_data['definitions'][$definition->name]['description']);
195 220
 			unset($export_data['definitions'][$definition->name]['user_timezone_read']);
196
-			if(is_array($export_data['definitions'][$definition->name]['plugin_options'])) {
221
+			if(is_array($export_data['definitions'][$definition->name]['plugin_options']))
222
+			{
197 223
 				unset($export_data['definitions'][$definition->name]['plugin_options']['user_timezone_read']);
198 224
 			}
199 225
 			unset($definition);
@@ -213,7 +239,8 @@  discard block
 block discarded – undo
213 239
 	 */
214 240
 	public static function import( $_import_file )
215 241
 	{
216
-		if ( !is_file( $_import_file ) ) {
242
+		if ( !is_file( $_import_file ) )
243
+		{
217 244
 			throw new Exception("'$_import_file' does not exist or is not readable" );
218 245
 		}
219 246
 
@@ -231,14 +258,20 @@  discard block
 block discarded – undo
231 258
 		);
232 259
 
233 260
 		// Avoid warning if no definitions found
234
-		if(!is_array($definitions)) return lang('None found');
261
+		if(!is_array($definitions))
262
+		{
263
+			return lang('None found');
264
+		}
235 265
 
236 266
 		// save definition(s) into internal table
237 267
 		foreach ( $definitions as $name => $definition_data )
238 268
 		{
239 269
 			// convert allowed_user
240 270
 			$definition_data['allowed_users'] = importexport_helper_functions::account_name2id( $definition_data['allowed_users'] );
241
-			if($definition_data['all_users'] && !$definition_data['allowed_users']) $definition_data['allowed_users'] = 'all';
271
+			if($definition_data['all_users'] && !$definition_data['allowed_users'])
272
+			{
273
+				$definition_data['allowed_users'] = 'all';
274
+			}
242 275
 
243 276
 			$definition_data['owner'] = importexport_helper_functions::account_name2id( $definition_data['owner'] );
244 277
 
@@ -273,7 +306,10 @@  discard block
 block discarded – undo
273 306
 	public static function export_from_import(importexport_definition $import)
274 307
 	{
275 308
 		// Only operates on import definitions
276
-		if($import->type != 'import') throw new egw_exception_wrong_parameter('Only import definitions');
309
+		if($import->type != 'import')
310
+		{
311
+			throw new egw_exception_wrong_parameter('Only import definitions');
312
+		}
277 313
 
278 314
 		// Find export plugin
279 315
 		$plugin = str_replace('import', 'export',$import->plugin);
@@ -283,18 +319,30 @@  discard block
 block discarded – undo
283 319
 			$plugins = $type['export'];
284 320
 			foreach($plugins as $name => $label)
285 321
 			{
286
-				if($plugin == $name) break;
322
+				if($plugin == $name)
323
+				{
324
+					break;
325
+				}
326
+			}
327
+			if($plugin !== $name)
328
+			{
329
+				$plugin = $name;
287 330
 			}
288
-			if($plugin !== $name) $plugin = $name;
289 331
 		}
290 332
 
291 333
 		$export = new importexport_definition();
292 334
 
293 335
 		// Common settings
294 336
 		$export->name = str_replace('import', 'export',$import->name);
295
-		if($export->name == $import->name) $export->name = $export->name . '-export';
337
+		if($export->name == $import->name)
338
+		{
339
+			$export->name = $export->name . '-export';
340
+		}
296 341
 		$test = new importexport_definition($export->name);
297
-		if($test->name) $export->name = $export->name .'-'.$GLOBALS['egw_info']['user']['account_lid'];
342
+		if($test->name)
343
+		{
344
+			$export->name = $export->name .'-'.$GLOBALS['egw_info']['user']['account_lid'];
345
+		}
298 346
 
299 347
 		$export->application = $import->application;
300 348
 		$export->plugin = $plugin;
Please login to merge, or discard this patch.
importexport/inc/class.importexport_export_csv.inc.php 4 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	 */
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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) {
Please login to merge, or discard this patch.
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -94,22 +94,22 @@  discard block
 block discarded – undo
94 94
 	 * @param array _options options for specific backends
95 95
 	 * @return bool
96 96
 	 */
97
-	public function __construct( $_stream, array $_options ) {
97
+	public function __construct($_stream, array $_options) {
98 98
 		if (!is_object($GLOBALS['egw']->translation)) {
99 99
 			$GLOBALS['egw']->translation = new translation();
100 100
 		}
101 101
 		$this->translation = &$GLOBALS['egw']->translation;
102 102
 		$this->handle = $_stream;
103
-		if($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
103
+		if ($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
104 104
 		$this->csv_charset = $_options['charset'] ? $_options['charset'] : 'utf-8';
105
-		if ( !empty( $_options ) ) {
106
-			$this->csv_options = array_merge( $this->csv_options, $_options );
105
+		if (!empty($_options)) {
106
+			$this->csv_options = array_merge($this->csv_options, $_options);
107 107
 		}
108 108
 		//error_log(__METHOD__.__LINE__.array2string($_options['appname']));
109
-		if(!bo_merge::is_export_limit_excepted()) {
109
+		if (!bo_merge::is_export_limit_excepted()) {
110 110
 			$this->export_limit = bo_merge::getExportLimit($_options['appname']);
111 111
 			//error_log(__METHOD__.__LINE__.' app:'.$_options['appname'].' limit:'.$this->export_limit);
112
-			if($this->export_limit == 'no') throw new egw_exception_no_permission_admin('Export disabled');
112
+			if ($this->export_limit == 'no') throw new egw_exception_no_permission_admin('Export disabled');
113 113
 		}
114 114
 	}
115 115
 	
@@ -118,15 +118,15 @@  discard block
 block discarded – undo
118 118
 	 *
119 119
 	 * @param array $_mapping egw_field_name => csv_field_name
120 120
 	 */
121
-	public function set_mapping( array &$_mapping) {
121
+	public function set_mapping(array &$_mapping) {
122 122
 		if ($this->num_of_records > 0) {
123 123
 			throw new Exception('Error: Field mapping can\'t be set during ongoing export!');
124 124
 		}
125
-		if($_mapping['all_custom_fields']) {
125
+		if ($_mapping['all_custom_fields']) {
126 126
 			// Field value is the appname, so we can pull the fields
127 127
 			$custom = config::get_customfields($_mapping['all_custom_fields']);
128 128
 			unset($_mapping['all_custom_fields']);
129
-			foreach($custom as $field => $info) {
129
+			foreach ($custom as $field => $info) {
130 130
 				$_mapping['#'.$field] = $this->csv_options['begin_with_fieldnames'] == 'label' ? $info['label'] : $field;
131 131
 			}
132 132
 		}
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	 *
140 140
 	 * @param array $_conversion
141 141
 	 */
142
-	public function set_conversion( array $_conversion) {
142
+	public function set_conversion(array $_conversion) {
143 143
 		$this->conversion = $_conversion;
144 144
 	}
145 145
 	
@@ -149,59 +149,59 @@  discard block
 block discarded – undo
149 149
 	 * @param importexport_iface_egw_record record
150 150
 	 * @return bool
151 151
 	 */
152
-	public function export_record( importexport_iface_egw_record $_record ) {
152
+	public function export_record(importexport_iface_egw_record $_record) {
153 153
 		$this->record = $_record;
154 154
 		$this->record_array = $_record->get_record_array();
155 155
 		
156 156
 		// begin with fieldnames ?
157
-		if ($this->num_of_records == 0 && $this->csv_options['begin_with_fieldnames'] ) {
158
-			if($this->csv_options['begin_with_fieldnames'] == 'label') {
157
+		if ($this->num_of_records == 0 && $this->csv_options['begin_with_fieldnames']) {
158
+			if ($this->csv_options['begin_with_fieldnames'] == 'label') {
159 159
 				// Load translations for app
160 160
 				list($appname, $part2) = explode('_', get_class($_record));
161
-				if(!$GLOBALS['egw_info']['apps'][$appname]) $appname .= $part2; // Handle apps with _ in the name
161
+				if (!$GLOBALS['egw_info']['apps'][$appname]) $appname .= $part2; // Handle apps with _ in the name
162 162
 
163 163
 				// Get translations from wizard, if possible
164
-				if(!$this->csv_options['no_header_translation'])
164
+				if (!$this->csv_options['no_header_translation'])
165 165
 				{
166 166
 					$backtrace = debug_backtrace();
167 167
 					$plugin = $backtrace[1]['class'];
168
-					$wizard_name = $appname . '_wizard_' . str_replace($appname . '_', '', $plugin);
168
+					$wizard_name = $appname.'_wizard_'.str_replace($appname.'_', '', $plugin);
169 169
 					try {
170 170
 						$wizard = new $wizard_name;
171 171
 						$fields = $wizard->get_export_fields();
172
-						foreach($this->mapping as $field => &$label)
172
+						foreach ($this->mapping as $field => &$label)
173 173
 						{
174
-							if($fields[$field])
174
+							if ($fields[$field])
175 175
 							{
176 176
 								$label = $label != $fields[$field] ? $fields[$field] : lang($label);
177 177
 							}
178 178
 							// Make sure no *
179
-							if(substr($label,-1) == '*') $label = substr($label,0,-1);
179
+							if (substr($label, -1) == '*') $label = substr($label, 0, -1);
180 180
 						}
181 181
 					} catch (Exception $e) {
182 182
 						translation::add_app($appname);
183
-						foreach($this->mapping as $field => &$label) {
183
+						foreach ($this->mapping as $field => &$label) {
184 184
 							$label = lang($label);
185 185
 						}
186 186
 					}
187 187
 				}
188 188
 			}
189
-			$mapping = ! empty( $this->mapping ) ? $this->mapping : array_keys ( $this->record_array );
190
-			self::fputcsv( $this->handle ,$mapping ,$this->csv_options['delimiter'], $this->csv_options['enclosure'] );
189
+			$mapping = !empty($this->mapping) ? $this->mapping : array_keys($this->record_array);
190
+			self::fputcsv($this->handle, $mapping, $this->csv_options['delimiter'], $this->csv_options['enclosure']);
191 191
 		}
192 192
 
193 193
 		// Check for limit
194
-		if($this->export_limit && $this->num_of_records >= $this->export_limit) {
194
+		if ($this->export_limit && $this->num_of_records >= $this->export_limit) {
195 195
 			return;
196 196
 		}
197 197
 		
198 198
 		// do conversions
199
-		if ( !empty( $this->conversion )) {
200
-			$this->record_array = importexport_helper_functions::conversion( $this->record_array, $this->conversion );
199
+		if (!empty($this->conversion)) {
200
+			$this->record_array = importexport_helper_functions::conversion($this->record_array, $this->conversion);
201 201
 		}
202 202
 		
203 203
 		// do fieldmapping
204
-		if ( !empty( $this->mapping ) ) {
204
+		if (!empty($this->mapping)) {
205 205
 			$record_data = $this->record_array;
206 206
 			$this->record_array = array();
207 207
 			foreach ($this->mapping as $egw_field => $csv_field) {
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 			}
210 210
 		}
211 211
 		
212
-		self::fputcsv( $this->handle, $this->record_array, $this->csv_options['delimiter'], $this->csv_options['enclosure'] );
212
+		self::fputcsv($this->handle, $this->record_array, $this->csv_options['delimiter'], $this->csv_options['enclosure']);
213 213
 		$this->num_of_records++;
214 214
 	}
215 215
 
@@ -233,13 +233,13 @@  discard block
 block discarded – undo
233 233
 	 * @return Array of fields to be added to list of fields needing conversion
234 234
 	 */
235 235
 	public static function convert_parse_custom_fields($appname, &$selects = array(), &$links = array(), &$methods = array()) {
236
-		if(!$appname) return;
236
+		if (!$appname) return;
237 237
 
238 238
 		$fields = array();
239 239
 		$custom = config::get_customfields($appname);
240
-		foreach($custom as $name => $c_field) {
241
-			$name = '#' . $name;
242
-			switch($c_field['type']) {
240
+		foreach ($custom as $name => $c_field) {
241
+			$name = '#'.$name;
242
+			switch ($c_field['type']) {
243 243
 				case 'date':
244 244
 					$fields['date'][] = $name;
245 245
 					break;
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 					$fields['select-account'][] = $name;
251 251
 					break;
252 252
 				case 'ajax_select':
253
-					if($c_field['values']['get_title']) {
253
+					if ($c_field['values']['get_title']) {
254 254
 						$methods[$name] = $c_field['values']['get_title'];
255 255
 						break;
256 256
 					}
@@ -264,8 +264,8 @@  discard block
 block discarded – undo
264 264
 					$selects[$name] = $c_field['values'];
265 265
 					break;
266 266
 				default:
267
-					list($type) = explode('-',$c_field['type'],2);
268
-					if(in_array($type, array_keys($GLOBALS['egw_info']['apps']))) {
267
+					list($type) = explode('-', $c_field['type'], 2);
268
+					if (in_array($type, array_keys($GLOBALS['egw_info']['apps']))) {
269 269
 						$fields['links'][] = $name;
270 270
 						$links[$name] = $c_field['type'];
271 271
 					}
@@ -284,18 +284,18 @@  discard block
 block discarded – undo
284 284
 	 * @parem fields List of field types => field names to be converted
285 285
 	 * @param appname Current appname if you want to do custom fields too
286 286
 	 */
287
-	public static function convert(importexport_iface_egw_record &$record, Array $fields = array(), $appname = null, $selects = array()) {
288
-		if($appname) {
289
-			if(!self::$cf_parse_cache[$appname]) {
287
+	public static function convert(importexport_iface_egw_record&$record, Array $fields = array(), $appname = null, $selects = array()) {
288
+		if ($appname) {
289
+			if (!self::$cf_parse_cache[$appname]) {
290 290
 				$c_fields = self::convert_parse_custom_fields($appname, $selects, $links, $methods);
291 291
 				self::$cf_parse_cache[$appname] = array($c_fields, $selects, $links, $methods);
292 292
 			}
293 293
 			list($c_fields, $c_selects, $links, $methods) = self::$cf_parse_cache[$appname];
294 294
 
295 295
 			// Add in any fields that are keys to another app
296
-			foreach((array)$fields['links'] as $link_field => $app)
296
+			foreach ((array)$fields['links'] as $link_field => $app)
297 297
 			{
298
-				if(is_numeric($link_field)) continue;
298
+				if (is_numeric($link_field)) continue;
299 299
 				$links[$link_field] = $app;
300 300
 				// Set it as a normal link field
301 301
 				$fields['links'][] = $link_field;
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
 			}
304 304
 
305 305
 			// Not quite a recursive merge, since only one level
306
-			foreach($fields as $type => &$list) {
307
-				if($c_fields[$type]) {
306
+			foreach ($fields as $type => &$list) {
307
+				if ($c_fields[$type]) {
308 308
 					$list = array_merge($c_fields[$type], $list);
309 309
 					unset($c_fields[$type]);
310 310
 				}
@@ -312,12 +312,12 @@  discard block
 block discarded – undo
312 312
 			$fields += $c_fields;
313 313
 			$selects += $c_selects;
314 314
 		}
315
-		foreach((array)$fields['select'] as $name) {
316
-			if($record->$name != null && is_array($selects) && $selects[$name]) {
315
+		foreach ((array)$fields['select'] as $name) {
316
+			if ($record->$name != null && is_array($selects) && $selects[$name]) {
317 317
 				$record->$name = explode(',', $record->$name);
318
-				if(is_array($record->$name)) {
318
+				if (is_array($record->$name)) {
319 319
 					$names = array();
320
-					foreach($record->$name as $_name) {
320
+					foreach ($record->$name as $_name) {
321 321
 						$names[] = lang($selects[$name][$_name]);
322 322
 					}
323 323
 					$record->$name = implode(', ', $names);
@@ -330,14 +330,14 @@  discard block
 block discarded – undo
330 330
 				$record->$name = '';
331 331
 			}
332 332
 		}
333
-		foreach((array)$fields['links'] as $name) {
334
-			if($record->$name) {
335
-				if(is_numeric($record->$name) && !$links[$name]) {
333
+		foreach ((array)$fields['links'] as $name) {
334
+			if ($record->$name) {
335
+				if (is_numeric($record->$name) && !$links[$name]) {
336 336
 					$link = egw_link::get_link($record->$name);
337 337
 					$links[$name] = ($link['link_app1'] == $appname ? $link['link_app2'] : $link['link_app1']);
338 338
 					$record->$name = ($link['link_app1'] == $appname ? $link['link_id2'] : $link['link_id1']);
339 339
 				}
340
-				if($links[$name]) {
340
+				if ($links[$name]) {
341 341
 					$record->$name = egw_link::title($links[$name], $record->$name);
342 342
 				}
343 343
 			}
@@ -346,12 +346,12 @@  discard block
 block discarded – undo
346 346
 				$record->$name = '';
347 347
 			}
348 348
 		}
349
-		foreach((array)$fields['select-account'] as $name) {
349
+		foreach ((array)$fields['select-account'] as $name) {
350 350
 			// Compare against null to deal with empty arrays
351 351
 			if ($record->$name !== null) {
352
-				if(is_array($record->$name)) {
352
+				if (is_array($record->$name)) {
353 353
 					$names = array();
354
-					foreach($record->$name as $_name) {
354
+					foreach ($record->$name as $_name) {
355 355
 						$names[] = common::grab_owner_name($_name);
356 356
 					}
357 357
 					$record->$name = implode(', ', $names);
@@ -364,64 +364,64 @@  discard block
 block discarded – undo
364 364
 				$record->$name = '';
365 365
 			}
366 366
 		}
367
-		foreach((array)$fields['select-bool'] as $name) {
368
-			if($record->$name !== null) {
367
+		foreach ((array)$fields['select-bool'] as $name) {
368
+			if ($record->$name !== null) {
369 369
 				$record->$name = $record->$name ? lang('Yes') : lang('No');
370 370
 			}
371 371
 		}
372
-		foreach((array)$fields['date-time'] as $name) {
372
+		foreach ((array)$fields['date-time'] as $name) {
373 373
 			//if ($record->$name) $record->$name = date('Y-m-d H:i:s',$record->$name); // Standard date format
374 374
 			if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string
375
-			if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'] . ' '.
376
-				($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '24' ? 'H:i:s' : 'h:i:s a'),$record->$name); // User date format
375
+			if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'].' '.
376
+				($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '24' ? 'H:i:s' : 'h:i:s a'), $record->$name); // User date format
377 377
 			if (!$record->$name) $record->$name = '';
378 378
 		}
379
-		foreach((array)$fields['date'] as $name) {
379
+		foreach ((array)$fields['date'] as $name) {
380 380
 			//if ($record->$name) $record->$name = date('Y-m-d',$record->$name); // Standard date format
381 381
 			if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string
382 382
 			if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], $record->$name); // User date format
383 383
 			if (!$record->$name) $record->$name = '';
384 384
 		}
385
-		foreach((array)$fields['float'] as $name)
385
+		foreach ((array)$fields['float'] as $name)
386 386
 		{
387
-			static $dec_separator,$thousands_separator;
387
+			static $dec_separator, $thousands_separator;
388 388
 			if (is_null($dec_separator))
389 389
 			{
390 390
 				$dec_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0];
391 391
 				if (empty($dec_separator)) $dec_separator = '.';
392 392
 				$thousands_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][1];
393 393
 			}
394
-			if($record->$name && (string)$record->$name != '')
394
+			if ($record->$name && (string)$record->$name != '')
395 395
 			{
396
-				if(!is_numeric($record->$name))
396
+				if (!is_numeric($record->$name))
397 397
 				{
398 398
 					$record->$name = floatval(str_replace($dec_separator, '.', preg_replace('/[^\d'.preg_quote($dec_separator).']/', '', $record->$name)));
399 399
 				}
400
-				$record->$name = number_format(str_replace(' ','',$record->$name), 2,
401
-					$dec_separator,$thousands_separator
400
+				$record->$name = number_format(str_replace(' ', '', $record->$name), 2,
401
+					$dec_separator, $thousands_separator
402 402
 				);
403 403
 			}
404 404
 		}
405 405
 
406 406
 		// Some custom methods for conversion
407
-		foreach((array)$methods as $name => $method) {
408
-			if($record->$name) $record->$name = ExecMethod($method, $record->$name);
407
+		foreach ((array)$methods as $name => $method) {
408
+			if ($record->$name) $record->$name = ExecMethod($method, $record->$name);
409 409
 		}
410 410
 
411 411
 		static $cat_object;
412
-		if(is_null($cat_object)) $cat_object = new categories(false,$appname);
413
-		foreach((array)$fields['select-cat'] as $name) {
414
-			if($record->$name) {
412
+		if (is_null($cat_object)) $cat_object = new categories(false, $appname);
413
+		foreach ((array)$fields['select-cat'] as $name) {
414
+			if ($record->$name) {
415 415
 				$cats = array();
416 416
 				$ids = is_array($record->$name) ? $record->$name : explode(',', $record->$name);
417
-				foreach($ids as $n => $cat_id) {
417
+				foreach ($ids as $n => $cat_id) {
418 418
 
419
-					if ($cat_id && $cat_object->check_perms(EGW_ACL_READ,$cat_id))
419
+					if ($cat_id && $cat_object->check_perms(EGW_ACL_READ, $cat_id))
420 420
 					{
421 421
 						$cats[] = $cat_object->id2name($cat_id);
422 422
 					}
423 423
 				}
424
-				$record->$name = implode(', ',$cats);
424
+				$record->$name = implode(', ', $cats);
425 425
 			}
426 426
 			else
427 427
 			{
@@ -448,18 +448,18 @@  discard block
 block discarded – undo
448 448
 	 * @param char $delimiter
449 449
 	 * @param char $enclosure
450 450
 	 */
451
-	protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure){
451
+	protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure) {
452 452
 		$string = "";
453 453
 		$writeDelimiter = false;
454
-		foreach($dataArray as $dataElement) {
455
-			if($writeDelimiter) $string .= $delimiter;
456
-			$string .= $enclosure . str_replace(array("\r\n", '"'), array("\n",'""'), $dataElement) . $enclosure;
454
+		foreach ($dataArray as $dataElement) {
455
+			if ($writeDelimiter) $string .= $delimiter;
456
+			$string .= $enclosure.str_replace(array("\r\n", '"'), array("\n", '""'), $dataElement).$enclosure;
457 457
 			$writeDelimiter = true;
458 458
 		}
459 459
 		$string .= "\n";
460 460
 		
461 461
 		// do charset translation
462
-		$string = $this->translation->convert( $string, $this->translation->charset(), $this->csv_charset );
462
+		$string = $this->translation->convert($string, $this->translation->charset(), $this->csv_charset);
463 463
 		
464 464
 		fwrite($filePointer, $string);
465 465
 			
Please login to merge, or discard this patch.
Braces   +180 added lines, -71 removed lines patch added patch discarded remove patch
@@ -94,22 +94,32 @@  discard block
 block discarded – undo
94 94
 	 * @param array _options options for specific backends
95 95
 	 * @return bool
96 96
 	 */
97
-	public function __construct( $_stream, array $_options ) {
98
-		if (!is_object($GLOBALS['egw']->translation)) {
97
+	public function __construct( $_stream, array $_options )
98
+	{
99
+		if (!is_object($GLOBALS['egw']->translation))
100
+		{
99 101
 			$GLOBALS['egw']->translation = new translation();
100 102
 		}
101 103
 		$this->translation = &$GLOBALS['egw']->translation;
102 104
 		$this->handle = $_stream;
103
-		if($_options['charset'] == 'user') $_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
105
+		if($_options['charset'] == 'user')
106
+		{
107
+			$_options['charset'] = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
108
+		}
104 109
 		$this->csv_charset = $_options['charset'] ? $_options['charset'] : 'utf-8';
105
-		if ( !empty( $_options ) ) {
110
+		if ( !empty( $_options ) )
111
+		{
106 112
 			$this->csv_options = array_merge( $this->csv_options, $_options );
107 113
 		}
108 114
 		//error_log(__METHOD__.__LINE__.array2string($_options['appname']));
109
-		if(!bo_merge::is_export_limit_excepted()) {
115
+		if(!bo_merge::is_export_limit_excepted())
116
+		{
110 117
 			$this->export_limit = bo_merge::getExportLimit($_options['appname']);
111 118
 			//error_log(__METHOD__.__LINE__.' app:'.$_options['appname'].' limit:'.$this->export_limit);
112
-			if($this->export_limit == 'no') throw new egw_exception_no_permission_admin('Export disabled');
119
+			if($this->export_limit == 'no')
120
+			{
121
+				throw new egw_exception_no_permission_admin('Export disabled');
122
+			}
113 123
 		}
114 124
 	}
115 125
 	
@@ -118,15 +128,19 @@  discard block
 block discarded – undo
118 128
 	 *
119 129
 	 * @param array $_mapping egw_field_name => csv_field_name
120 130
 	 */
121
-	public function set_mapping( array &$_mapping) {
122
-		if ($this->num_of_records > 0) {
131
+	public function set_mapping( array &$_mapping)
132
+	{
133
+		if ($this->num_of_records > 0)
134
+		{
123 135
 			throw new Exception('Error: Field mapping can\'t be set during ongoing export!');
124 136
 		}
125
-		if($_mapping['all_custom_fields']) {
137
+		if($_mapping['all_custom_fields'])
138
+		{
126 139
 			// Field value is the appname, so we can pull the fields
127 140
 			$custom = config::get_customfields($_mapping['all_custom_fields']);
128 141
 			unset($_mapping['all_custom_fields']);
129
-			foreach($custom as $field => $info) {
142
+			foreach($custom as $field => $info)
143
+			{
130 144
 				$_mapping['#'.$field] = $this->csv_options['begin_with_fieldnames'] == 'label' ? $info['label'] : $field;
131 145
 			}
132 146
 		}
@@ -139,7 +153,8 @@  discard block
 block discarded – undo
139 153
 	 *
140 154
 	 * @param array $_conversion
141 155
 	 */
142
-	public function set_conversion( array $_conversion) {
156
+	public function set_conversion( array $_conversion)
157
+	{
143 158
 		$this->conversion = $_conversion;
144 159
 	}
145 160
 	
@@ -149,16 +164,23 @@  discard block
 block discarded – undo
149 164
 	 * @param importexport_iface_egw_record record
150 165
 	 * @return bool
151 166
 	 */
152
-	public function export_record( importexport_iface_egw_record $_record ) {
167
+	public function export_record( importexport_iface_egw_record $_record )
168
+	{
153 169
 		$this->record = $_record;
154 170
 		$this->record_array = $_record->get_record_array();
155 171
 		
156 172
 		// begin with fieldnames ?
157
-		if ($this->num_of_records == 0 && $this->csv_options['begin_with_fieldnames'] ) {
158
-			if($this->csv_options['begin_with_fieldnames'] == 'label') {
173
+		if ($this->num_of_records == 0 && $this->csv_options['begin_with_fieldnames'] )
174
+		{
175
+			if($this->csv_options['begin_with_fieldnames'] == 'label')
176
+			{
159 177
 				// Load translations for app
160 178
 				list($appname, $part2) = explode('_', get_class($_record));
161
-				if(!$GLOBALS['egw_info']['apps'][$appname]) $appname .= $part2; // Handle apps with _ in the name
179
+				if(!$GLOBALS['egw_info']['apps'][$appname])
180
+				{
181
+					$appname .= $part2;
182
+				}
183
+				// Handle apps with _ in the name
162 184
 
163 185
 				// Get translations from wizard, if possible
164 186
 				if(!$this->csv_options['no_header_translation'])
@@ -176,11 +198,16 @@  discard block
 block discarded – undo
176 198
 								$label = $label != $fields[$field] ? $fields[$field] : lang($label);
177 199
 							}
178 200
 							// Make sure no *
179
-							if(substr($label,-1) == '*') $label = substr($label,0,-1);
201
+							if(substr($label,-1) == '*')
202
+							{
203
+								$label = substr($label,0,-1);
204
+							}
180 205
 						}
181
-					} catch (Exception $e) {
206
+					}
207
+					catch (Exception $e) {
182 208
 						translation::add_app($appname);
183
-						foreach($this->mapping as $field => &$label) {
209
+						foreach($this->mapping as $field => &$label)
210
+						{
184 211
 							$label = lang($label);
185 212
 						}
186 213
 					}
@@ -191,20 +218,24 @@  discard block
 block discarded – undo
191 218
 		}
192 219
 
193 220
 		// Check for limit
194
-		if($this->export_limit && $this->num_of_records >= $this->export_limit) {
221
+		if($this->export_limit && $this->num_of_records >= $this->export_limit)
222
+		{
195 223
 			return;
196 224
 		}
197 225
 		
198 226
 		// do conversions
199
-		if ( !empty( $this->conversion )) {
227
+		if ( !empty( $this->conversion ))
228
+		{
200 229
 			$this->record_array = importexport_helper_functions::conversion( $this->record_array, $this->conversion );
201 230
 		}
202 231
 		
203 232
 		// do fieldmapping
204
-		if ( !empty( $this->mapping ) ) {
233
+		if ( !empty( $this->mapping ) )
234
+		{
205 235
 			$record_data = $this->record_array;
206 236
 			$this->record_array = array();
207
-			foreach ($this->mapping as $egw_field => $csv_field) {
237
+			foreach ($this->mapping as $egw_field => $csv_field)
238
+			{
208 239
 				$this->record_array[$csv_field] = $record_data[$egw_field];
209 240
 			}
210 241
 		}
@@ -218,7 +249,8 @@  discard block
 block discarded – undo
218 249
 	 *
219 250
 	 * @return int
220 251
 	 */
221
-	public function get_num_of_records() {
252
+	public function get_num_of_records()
253
+	{
222 254
 		return $this->num_of_records;
223 255
 	}
224 256
 
@@ -232,14 +264,20 @@  discard block
 block discarded – undo
232 264
 	 *
233 265
 	 * @return Array of fields to be added to list of fields needing conversion
234 266
 	 */
235
-	public static function convert_parse_custom_fields($appname, &$selects = array(), &$links = array(), &$methods = array()) {
236
-		if(!$appname) return;
267
+	public static function convert_parse_custom_fields($appname, &$selects = array(), &$links = array(), &$methods = array())
268
+	{
269
+		if(!$appname)
270
+		{
271
+			return;
272
+		}
237 273
 
238 274
 		$fields = array();
239 275
 		$custom = config::get_customfields($appname);
240
-		foreach($custom as $name => $c_field) {
276
+		foreach($custom as $name => $c_field)
277
+		{
241 278
 			$name = '#' . $name;
242
-			switch($c_field['type']) {
279
+			switch($c_field['type'])
280
+			{
243 281
 				case 'date':
244 282
 					$fields['date'][] = $name;
245 283
 					break;
@@ -250,7 +288,8 @@  discard block
 block discarded – undo
250 288
 					$fields['select-account'][] = $name;
251 289
 					break;
252 290
 				case 'ajax_select':
253
-					if($c_field['values']['get_title']) {
291
+					if($c_field['values']['get_title'])
292
+					{
254 293
 						$methods[$name] = $c_field['values']['get_title'];
255 294
 						break;
256 295
 					}
@@ -265,7 +304,8 @@  discard block
 block discarded – undo
265 304
 					break;
266 305
 				default:
267 306
 					list($type) = explode('-',$c_field['type'],2);
268
-					if(in_array($type, array_keys($GLOBALS['egw_info']['apps']))) {
307
+					if(in_array($type, array_keys($GLOBALS['egw_info']['apps'])))
308
+					{
269 309
 						$fields['links'][] = $name;
270 310
 						$links[$name] = $c_field['type'];
271 311
 					}
@@ -284,9 +324,12 @@  discard block
 block discarded – undo
284 324
 	 * @parem fields List of field types => field names to be converted
285 325
 	 * @param appname Current appname if you want to do custom fields too
286 326
 	 */
287
-	public static function convert(importexport_iface_egw_record &$record, Array $fields = array(), $appname = null, $selects = array()) {
288
-		if($appname) {
289
-			if(!self::$cf_parse_cache[$appname]) {
327
+	public static function convert(importexport_iface_egw_record &$record, Array $fields = array(), $appname = null, $selects = array())
328
+	{
329
+		if($appname)
330
+		{
331
+			if(!self::$cf_parse_cache[$appname])
332
+			{
290 333
 				$c_fields = self::convert_parse_custom_fields($appname, $selects, $links, $methods);
291 334
 				self::$cf_parse_cache[$appname] = array($c_fields, $selects, $links, $methods);
292 335
 			}
@@ -295,7 +338,10 @@  discard block
 block discarded – undo
295 338
 			// Add in any fields that are keys to another app
296 339
 			foreach((array)$fields['links'] as $link_field => $app)
297 340
 			{
298
-				if(is_numeric($link_field)) continue;
341
+				if(is_numeric($link_field))
342
+				{
343
+					continue;
344
+				}
299 345
 				$links[$link_field] = $app;
300 346
 				// Set it as a normal link field
301 347
 				$fields['links'][] = $link_field;
@@ -303,8 +349,10 @@  discard block
 block discarded – undo
303 349
 			}
304 350
 
305 351
 			// Not quite a recursive merge, since only one level
306
-			foreach($fields as $type => &$list) {
307
-				if($c_fields[$type]) {
352
+			foreach($fields as $type => &$list)
353
+			{
354
+				if($c_fields[$type])
355
+				{
308 356
 					$list = array_merge($c_fields[$type], $list);
309 357
 					unset($c_fields[$type]);
310 358
 				}
@@ -312,16 +360,22 @@  discard block
 block discarded – undo
312 360
 			$fields += $c_fields;
313 361
 			$selects += $c_selects;
314 362
 		}
315
-		foreach((array)$fields['select'] as $name) {
316
-			if($record->$name != null && is_array($selects) && $selects[$name]) {
363
+		foreach((array)$fields['select'] as $name)
364
+		{
365
+			if($record->$name != null && is_array($selects) && $selects[$name])
366
+			{
317 367
 				$record->$name = explode(',', $record->$name);
318
-				if(is_array($record->$name)) {
368
+				if(is_array($record->$name))
369
+				{
319 370
 					$names = array();
320
-					foreach($record->$name as $_name) {
371
+					foreach($record->$name as $_name)
372
+					{
321 373
 						$names[] = lang($selects[$name][$_name]);
322 374
 					}
323 375
 					$record->$name = implode(', ', $names);
324
-				} else {
376
+				}
377
+				else
378
+				{
325 379
 					$record->$name = lang($selects[$name][$record->$name]);
326 380
 				}
327 381
 			}
@@ -330,14 +384,18 @@  discard block
 block discarded – undo
330 384
 				$record->$name = '';
331 385
 			}
332 386
 		}
333
-		foreach((array)$fields['links'] as $name) {
334
-			if($record->$name) {
335
-				if(is_numeric($record->$name) && !$links[$name]) {
387
+		foreach((array)$fields['links'] as $name)
388
+		{
389
+			if($record->$name)
390
+			{
391
+				if(is_numeric($record->$name) && !$links[$name])
392
+				{
336 393
 					$link = egw_link::get_link($record->$name);
337 394
 					$links[$name] = ($link['link_app1'] == $appname ? $link['link_app2'] : $link['link_app1']);
338 395
 					$record->$name = ($link['link_app1'] == $appname ? $link['link_id2'] : $link['link_id1']);
339 396
 				}
340
-				if($links[$name]) {
397
+				if($links[$name])
398
+				{
341 399
 					$record->$name = egw_link::title($links[$name], $record->$name);
342 400
 				}
343 401
 			}
@@ -346,16 +404,22 @@  discard block
 block discarded – undo
346 404
 				$record->$name = '';
347 405
 			}
348 406
 		}
349
-		foreach((array)$fields['select-account'] as $name) {
407
+		foreach((array)$fields['select-account'] as $name)
408
+		{
350 409
 			// Compare against null to deal with empty arrays
351
-			if ($record->$name !== null) {
352
-				if(is_array($record->$name)) {
410
+			if ($record->$name !== null)
411
+			{
412
+				if(is_array($record->$name))
413
+				{
353 414
 					$names = array();
354
-					foreach($record->$name as $_name) {
415
+					foreach($record->$name as $_name)
416
+					{
355 417
 						$names[] = common::grab_owner_name($_name);
356 418
 					}
357 419
 					$record->$name = implode(', ', $names);
358
-				} else {
420
+				}
421
+				else
422
+				{
359 423
 					$record->$name = common::grab_owner_name($record->$name);
360 424
 				}
361 425
 			}
@@ -364,23 +428,49 @@  discard block
 block discarded – undo
364 428
 				$record->$name = '';
365 429
 			}
366 430
 		}
367
-		foreach((array)$fields['select-bool'] as $name) {
368
-			if($record->$name !== null) {
431
+		foreach((array)$fields['select-bool'] as $name)
432
+		{
433
+			if($record->$name !== null)
434
+			{
369 435
 				$record->$name = $record->$name ? lang('Yes') : lang('No');
370 436
 			}
371 437
 		}
372
-		foreach((array)$fields['date-time'] as $name) {
438
+		foreach((array)$fields['date-time'] as $name)
439
+		{
373 440
 			//if ($record->$name) $record->$name = date('Y-m-d H:i:s',$record->$name); // Standard date format
374
-			if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string
375
-			if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'] . ' '.
376
-				($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '24' ? 'H:i:s' : 'h:i:s a'),$record->$name); // User date format
377
-			if (!$record->$name) $record->$name = '';
441
+			if ($record->$name && !is_numeric($record->$name))
442
+			{
443
+				$record->$name = strtotime($record->$name);
444
+			}
445
+			// Custom fields stored as string
446
+			if ($record->$name && is_numeric($record->$name))
447
+			{
448
+				$record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'] . ' '.
449
+				($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == '24' ? 'H:i:s' : 'h:i:s a'),$record->$name);
450
+			}
451
+			// User date format
452
+			if (!$record->$name)
453
+			{
454
+				$record->$name = '';
455
+			}
378 456
 		}
379
-		foreach((array)$fields['date'] as $name) {
457
+		foreach((array)$fields['date'] as $name)
458
+		{
380 459
 			//if ($record->$name) $record->$name = date('Y-m-d',$record->$name); // Standard date format
381
-			if ($record->$name && !is_numeric($record->$name)) $record->$name = strtotime($record->$name); // Custom fields stored as string
382
-			if ($record->$name && is_numeric($record->$name)) $record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], $record->$name); // User date format
383
-			if (!$record->$name) $record->$name = '';
460
+			if ($record->$name && !is_numeric($record->$name))
461
+			{
462
+				$record->$name = strtotime($record->$name);
463
+			}
464
+			// Custom fields stored as string
465
+			if ($record->$name && is_numeric($record->$name))
466
+			{
467
+				$record->$name = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], $record->$name);
468
+			}
469
+			// User date format
470
+			if (!$record->$name)
471
+			{
472
+				$record->$name = '';
473
+			}
384 474
 		}
385 475
 		foreach((array)$fields['float'] as $name)
386 476
 		{
@@ -388,7 +478,10 @@  discard block
 block discarded – undo
388 478
 			if (is_null($dec_separator))
389 479
 			{
390 480
 				$dec_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][0];
391
-				if (empty($dec_separator)) $dec_separator = '.';
481
+				if (empty($dec_separator))
482
+				{
483
+					$dec_separator = '.';
484
+				}
392 485
 				$thousands_separator = $GLOBALS['egw_info']['user']['preferences']['common']['number_format'][1];
393 486
 			}
394 487
 			if($record->$name && (string)$record->$name != '')
@@ -404,17 +497,27 @@  discard block
 block discarded – undo
404 497
 		}
405 498
 
406 499
 		// Some custom methods for conversion
407
-		foreach((array)$methods as $name => $method) {
408
-			if($record->$name) $record->$name = ExecMethod($method, $record->$name);
500
+		foreach((array)$methods as $name => $method)
501
+		{
502
+			if($record->$name)
503
+			{
504
+				$record->$name = ExecMethod($method, $record->$name);
505
+			}
409 506
 		}
410 507
 
411 508
 		static $cat_object;
412
-		if(is_null($cat_object)) $cat_object = new categories(false,$appname);
413
-		foreach((array)$fields['select-cat'] as $name) {
414
-			if($record->$name) {
509
+		if(is_null($cat_object))
510
+		{
511
+			$cat_object = new categories(false,$appname);
512
+		}
513
+		foreach((array)$fields['select-cat'] as $name)
514
+		{
515
+			if($record->$name)
516
+			{
415 517
 				$cats = array();
416 518
 				$ids = is_array($record->$name) ? $record->$name : explode(',', $record->$name);
417
-				foreach($ids as $n => $cat_id) {
519
+				foreach($ids as $n => $cat_id)
520
+				{
418 521
 
419 522
 					if ($cat_id && $cat_object->check_perms(EGW_ACL_READ,$cat_id))
420 523
 					{
@@ -435,7 +538,8 @@  discard block
 block discarded – undo
435 538
 	 *
436 539
 	 * @return
437 540
 	 */
438
-	public function __destruct() {
541
+	public function __destruct()
542
+	{
439 543
 		
440 544
 	}
441 545
 
@@ -448,11 +552,16 @@  discard block
 block discarded – undo
448 552
 	 * @param char $delimiter
449 553
 	 * @param char $enclosure
450 554
 	 */
451
-	protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure){
555
+	protected function fputcsv($filePointer, Array $dataArray, $delimiter, $enclosure)
556
+	{
452 557
 		$string = "";
453 558
 		$writeDelimiter = false;
454
-		foreach($dataArray as $dataElement) {
455
-			if($writeDelimiter) $string .= $delimiter;
559
+		foreach($dataArray as $dataElement)
560
+		{
561
+			if($writeDelimiter)
562
+			{
563
+				$string .= $delimiter;
564
+			}
456 565
 			$string .= $enclosure . str_replace(array("\r\n", '"'), array("\n",'""'), $dataElement) . $enclosure;
457 566
 			$writeDelimiter = true;
458 567
 		}
Please login to merge, or discard this patch.