Passed
Push — 17.1 ( 431f3f...4dae72 )
by Ralf
01:23 queued 12s
created
admin/inc/class.admin_hooks.inc.php 2 patches
Braces   +18 added lines, -5 removed lines patch added patch discarded remove patch
@@ -148,7 +148,10 @@  discard block
 block discarded – undo
148 148
 			{
149 149
 				foreach($file as &$url)
150 150
 				{
151
-					if (is_array($url) && $url['link']) $url = $url['link'];
151
+					if (is_array($url) && $url['link'])
152
+					{
153
+						$url = $url['link'];
154
+					}
152 155
 				}
153 156
 				display_sidebox($appname,lang('Admin'),$file);
154 157
 			}
@@ -168,9 +171,13 @@  discard block
 block discarded – undo
168 171
 
169 172
 		Api\Image::invalidate();
170 173
 
171
-		if (method_exists($GLOBALS['egw'],'invalidate_session_cache'))	// Egw object in setup is limited
174
+		if (method_exists($GLOBALS['egw'],'invalidate_session_cache'))
172 175
 		{
173
-			$GLOBALS['egw']->invalidate_session_cache();	// in case with cache the egw_info array in the session
176
+			// Egw object in setup is limited
177
+		{
178
+			$GLOBALS['egw']->invalidate_session_cache();
179
+		}
180
+		// in case with cache the egw_info array in the session
174 181
 		}
175 182
 		// allow apps to hook into "Admin >> Clear cache and register hooks"
176 183
 		Api\Hooks::process('clear_cache', array(), true);
@@ -195,7 +202,9 @@  discard block
 block discarded – undo
195 202
 			'icon' => 'lock',
196 203
 		);
197 204
 
198
-		if (!$GLOBALS['egw']->acl->check('current_sessions',1,'admin'))	// no rights to view
205
+		if (!$GLOBALS['egw']->acl->check('current_sessions',1,'admin'))
206
+		{
207
+			// no rights to view
199 208
 		{
200 209
 			$actions[] = array(
201 210
 				'description' => 'Login History',
@@ -204,8 +213,11 @@  discard block
 block discarded – undo
204 213
 				'icon'        => 'timesheet',
205 214
 			);
206 215
 		}
216
+		}
207 217
 
208
-		if (!$GLOBALS['egw']->acl->check('account_access',64,'admin'))	// no rights to set ACL-rights
218
+		if (!$GLOBALS['egw']->acl->check('account_access',64,'admin'))
219
+		{
220
+			// no rights to set ACL-rights
209 221
 		{
210 222
 			$actions[] = array(
211 223
 				'description' => 'Deny access',
@@ -214,6 +226,7 @@  discard block
 block discarded – undo
214 226
 				'icon'        => 'cancel',
215 227
 			);
216 228
 		}
229
+		}
217 230
 
218 231
 		// currently no way to deny Admins access to administrate mail
219 232
 		// we could add a deny check as for other admin functionality
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -50,57 +50,57 @@  discard block
 block discarded – undo
50 50
 				'link' => false,
51 51
 				'icon' => false
52 52
 			);
53
-			display_sidebox($appname,lang('Admin'),$file);
53
+			display_sidebox($appname, lang('Admin'), $file);
54 54
 			return;
55 55
 		}
56 56
 		if ($GLOBALS['egw_info']['user']['apps']['admin'])
57 57
 		{
58 58
 
59
-			if (! $GLOBALS['egw']->acl->check('site_config_acce',1,'admin'))
59
+			if (!$GLOBALS['egw']->acl->check('site_config_acce', 1, 'admin'))
60 60
 			{
61
-				$file['Site Configuration']         = Egw::link('/index.php','menuaction=admin.admin_config.index&appname=admin&ajax=true');
61
+				$file['Site Configuration'] = Egw::link('/index.php', 'menuaction=admin.admin_config.index&appname=admin&ajax=true');
62 62
 			}
63 63
 
64
-			if (! $GLOBALS['egw']->acl->check('account_access',1,'admin'))
64
+			if (!$GLOBALS['egw']->acl->check('account_access', 1, 'admin'))
65 65
 			{
66
-				$file['User Accounts']              = array(
66
+				$file['User Accounts'] = array(
67 67
 					'id' => '/accounts',
68 68
 					'icon' => Api\Image::find('addressbook', 'accounts'),
69 69
 				);
70 70
 			}
71 71
 
72
-			if (! $GLOBALS['egw']->acl->check('account_access',16,'admin'))
72
+			if (!$GLOBALS['egw']->acl->check('account_access', 16, 'admin'))
73 73
 			{
74
-				$file['Bulk password reset']        = Egw::link('/index.php','menuaction=admin.admin_passwordreset.index&ajax=true');
74
+				$file['Bulk password reset'] = Egw::link('/index.php', 'menuaction=admin.admin_passwordreset.index&ajax=true');
75 75
 			}
76 76
 
77
-			if (! $GLOBALS['egw']->acl->check('group_access',1,'admin'))
77
+			if (!$GLOBALS['egw']->acl->check('group_access', 1, 'admin'))
78 78
 			{
79
-				$file['User Groups']                = array(
79
+				$file['User Groups'] = array(
80 80
 					'id' => '/groups',
81 81
 					'icon' => Api\Image::find('addressbook', 'group'),
82 82
 					'child' => 1,
83 83
 				);
84 84
 			}
85 85
 
86
-			if (! $GLOBALS['egw']->acl->check('global_categorie',1,'admin'))
86
+			if (!$GLOBALS['egw']->acl->check('global_categorie', 1, 'admin'))
87 87
 			{
88
-				$file['Global Categories']          = Egw::link('/index.php','menuaction=admin.admin_categories.index&appname=phpgw&ajax=true');
88
+				$file['Global Categories'] = Egw::link('/index.php', 'menuaction=admin.admin_categories.index&appname=phpgw&ajax=true');
89 89
 			}
90 90
 
91
-			if (!$GLOBALS['egw']->acl->check('mainscreen_messa',1,'admin') || !$GLOBALS['egw']->acl->check('mainscreen_messa',2,'admin'))
91
+			if (!$GLOBALS['egw']->acl->check('mainscreen_messa', 1, 'admin') || !$GLOBALS['egw']->acl->check('mainscreen_messa', 2, 'admin'))
92 92
 			{
93
-				$file['Change Main Screen Message'] = Egw::link('/index.php','menuaction=admin.admin_messages.index');
93
+				$file['Change Main Screen Message'] = Egw::link('/index.php', 'menuaction=admin.admin_messages.index');
94 94
 			}
95 95
 
96
-			if (! $GLOBALS['egw']->acl->check('current_sessions',1,'admin'))
96
+			if (!$GLOBALS['egw']->acl->check('current_sessions', 1, 'admin'))
97 97
 			{
98
-				$file['View Sessions'] = Egw::link('/index.php','menuaction=admin.admin_accesslog.sessions&ajax=true');
98
+				$file['View Sessions'] = Egw::link('/index.php', 'menuaction=admin.admin_accesslog.sessions&ajax=true');
99 99
 			}
100 100
 
101
-			if (! $GLOBALS['egw']->acl->check('access_log_acces',1,'admin'))
101
+			if (!$GLOBALS['egw']->acl->check('access_log_acces', 1, 'admin'))
102 102
 			{
103
-				$file['View Access Log'] = Egw::link('/index.php','menuaction=admin.admin_accesslog.index&ajax=true');
103
+				$file['View Access Log'] = Egw::link('/index.php', 'menuaction=admin.admin_accesslog.index&ajax=true');
104 104
 			}
105 105
 
106 106
 			/* disable old EGroupware error_log, as it is not used anymore
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 				$file['View Error Log']  = Egw::link('/index.php','menuaction=admin.uilog.list_log');
110 110
 			}*/
111 111
 
112
-			if (! $GLOBALS['egw']->acl->check('applications_acc',16,'admin'))
112
+			if (!$GLOBALS['egw']->acl->check('applications_acc', 16, 'admin'))
113 113
 			{
114 114
 				$file['Clear cache and register hooks'] = array(
115 115
 					'id' => 'admin/clear_cache',
@@ -118,38 +118,38 @@  discard block
 block discarded – undo
118 118
 				 );
119 119
 			}
120 120
 
121
-			if (! $GLOBALS['egw']->acl->check('asyncservice_acc',1,'admin'))
121
+			if (!$GLOBALS['egw']->acl->check('asyncservice_acc', 1, 'admin'))
122 122
 			{
123
-				$file['Asynchronous timed services'] = Egw::link('/index.php','menuaction=admin.admin_asyncservice.index');
123
+				$file['Asynchronous timed services'] = Egw::link('/index.php', 'menuaction=admin.admin_asyncservice.index');
124 124
 			}
125 125
 
126
-			if (! $GLOBALS['egw']->acl->check('db_backup_access',1,'admin'))
126
+			if (!$GLOBALS['egw']->acl->check('db_backup_access', 1, 'admin'))
127 127
 			{
128
-				$file['DB backup and restore'] = Egw::link('/index.php','menuaction=admin.admin_db_backup.index');
128
+				$file['DB backup and restore'] = Egw::link('/index.php', 'menuaction=admin.admin_db_backup.index');
129 129
 			}
130 130
 
131
-			if (! $GLOBALS['egw']->acl->check('info_access',1,'admin'))
131
+			if (!$GLOBALS['egw']->acl->check('info_access', 1, 'admin'))
132 132
 			{
133
-				$file['phpInfo']         = "javascript:egw.openPopup('" . Egw::link('/admin/phpinfo.php','',false) . "',960,600,'phpinfoWindow')";
133
+				$file['phpInfo'] = "javascript:egw.openPopup('".Egw::link('/admin/phpinfo.php', '', false)."',960,600,'phpinfoWindow')";
134 134
 			}
135
-			$file['Admin queue and history'] = Egw::link('/index.php','menuaction=admin.admin_cmds.index&ajax=true');
136
-			$file['Remote administration instances'] = Egw::link('/index.php','menuaction=admin.admin_cmds.remotes&ajax=true');
137
-			$file['Custom translation'] = Egw::link('/index.php','menuaction=admin.admin_customtranslation.index');
138
-			$file['Changelog and versions'] = Egw::link('/index.php','menuaction=api.EGroupware\\Api\\Framework\\About.index&ajax=true');
135
+			$file['Admin queue and history'] = Egw::link('/index.php', 'menuaction=admin.admin_cmds.index&ajax=true');
136
+			$file['Remote administration instances'] = Egw::link('/index.php', 'menuaction=admin.admin_cmds.remotes&ajax=true');
137
+			$file['Custom translation'] = Egw::link('/index.php', 'menuaction=admin.admin_customtranslation.index');
138
+			$file['Changelog and versions'] = Egw::link('/index.php', 'menuaction=api.EGroupware\\Api\\Framework\\About.index&ajax=true');
139 139
 
140
-			$file['Submit statistic information'] = Egw::link('/index.php','menuaction=admin.admin_statistics.submit');
140
+			$file['Submit statistic information'] = Egw::link('/index.php', 'menuaction=admin.admin_statistics.submit');
141 141
 
142 142
 			if ($location == 'admin')
143 143
 			{
144
-				display_section($appname,$file);
144
+				display_section($appname, $file);
145 145
 			}
146 146
 			else
147 147
 			{
148
-				foreach($file as &$url)
148
+				foreach ($file as &$url)
149 149
 				{
150 150
 					if (is_array($url) && $url['link']) $url = $url['link'];
151 151
 				}
152
-				display_sidebox($appname,lang('Admin'),$file);
152
+				display_sidebox($appname, lang('Admin'), $file);
153 153
 			}
154 154
 		}
155 155
 	}
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	function ajax_clear_cache()
161 161
 	{
162
-		if ($GLOBALS['egw']->acl->check('applications_acc',16,'admin'))
162
+		if ($GLOBALS['egw']->acl->check('applications_acc', 16, 'admin'))
163 163
 		{
164 164
 			$GLOBALS['egw']->redirect_link('/index.php');
165 165
 		}
@@ -167,9 +167,9 @@  discard block
 block discarded – undo
167 167
 
168 168
 		Api\Image::invalidate();
169 169
 
170
-		if (method_exists($GLOBALS['egw'],'invalidate_session_cache'))	// Egw object in setup is limited
170
+		if (method_exists($GLOBALS['egw'], 'invalidate_session_cache'))	// Egw object in setup is limited
171 171
 		{
172
-			$GLOBALS['egw']->invalidate_session_cache();	// in case with cache the egw_info array in the session
172
+			$GLOBALS['egw']->invalidate_session_cache(); // in case with cache the egw_info array in the session
173 173
 		}
174 174
 		// allow apps to hook into "Admin >> Clear cache and register hooks"
175 175
 		Api\Hooks::process('clear_cache', array(), true);
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 			'icon' => 'lock',
195 195
 		);
196 196
 
197
-		if (!$GLOBALS['egw']->acl->check('current_sessions',1,'admin'))	// no rights to view
197
+		if (!$GLOBALS['egw']->acl->check('current_sessions', 1, 'admin'))	// no rights to view
198 198
 		{
199 199
 			$actions[] = array(
200 200
 				'description' => 'Login History',
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 			);
205 205
 		}
206 206
 
207
-		if (!$GLOBALS['egw']->acl->check('account_access',64,'admin'))	// no rights to set ACL-rights
207
+		if (!$GLOBALS['egw']->acl->check('account_access', 64, 'admin'))	// no rights to set ACL-rights
208 208
 		{
209 209
 			$actions[] = array(
210 210
 				'description' => 'Deny access',
@@ -228,18 +228,18 @@  discard block
 block discarded – undo
228 228
 			$emailadmin = Api\Mail\Account::get_default();
229 229
 			if ($emailadmin->acc_smtp_type && $emailadmin->acc_smtp_type !== 'EGroupware\Api\Mail\Smtp')
230 230
 			{
231
-				$actions[] = array (
231
+				$actions[] = array(
232 232
 					'id'       => 'mail_activeAccounts',
233 233
 					'caption'  => '(de)activate mail accounts',
234 234
 					'icon'    => 'mail/navbar',
235
-					'children' => array (
236
-						'active' => array (
235
+					'children' => array(
236
+						'active' => array(
237 237
 							'caption'		  => 'activate',
238 238
 							'onExecute'	  	  => 'javaScript:app.admin.emailadminActiveAccounts',
239 239
 							'icon'			  => 'check',
240 240
 							'allowOnMultiple' => true
241 241
 						),
242
-						'inactive' => array (
242
+						'inactive' => array(
243 243
 							'caption'		  => 'deactivate',
244 244
 							'onExecute'		  => 'javaScript:app.admin.emailadminActiveAccounts',
245 245
 							'icon'			  => 'bullet',
Please login to merge, or discard this patch.
timesheet/inc/class.timesheet_export_csv.inc.php 4 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -161,7 +161,7 @@
 block discarded – undo
161 161
 	/**
162 162
 	 * Adjust the automatically generated filter fields
163 163
 	 */
164
-	public function get_filter_fields(Array &$filters)
164
+	public function get_filter_fields(array &$filters)
165 165
 	{
166 166
 		foreach($filters as $field_name => &$settings)
167 167
 		{
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -30,55 +30,55 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @param egw_record $_definition
32 32
 	 */
33
-	public function export( $_stream, importexport_definition $_definition)
33
+	public function export($_stream, importexport_definition $_definition)
34 34
 	{
35 35
 		$options = $_definition->plugin_options;
36 36
 
37 37
 		$this->ui = new timesheet_ui();
38 38
 		$selection = array();
39 39
 
40
-		if($options['selection'] == 'search')
40
+		if ($options['selection'] == 'search')
41 41
 		{
42 42
 			$query = Api\Cache::getSession(TIMESHEET_APP, 'index');
43
-			$query['num_rows'] = -1;	// all records
44
-			$query['csv_export'] = true;	// so get_rows method _can_ produce different content or not store state in the session
45
-			$this->ui->get_rows($query,$selection,$readonlys,true);	// true = only return the id's
43
+			$query['num_rows'] = -1; // all records
44
+			$query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session
45
+			$this->ui->get_rows($query, $selection, $readonlys, true); // true = only return the id's
46 46
 		}
47
-		elseif($options['selection'] == 'all')
47
+		elseif ($options['selection'] == 'all')
48 48
 		{
49 49
 			$query = array(
50 50
 				'num_rows' => -1,
51
-				'csv_export' => true,	// so get_rows method _can_ produce different content or not store state in the session
51
+				'csv_export' => true, // so get_rows method _can_ produce different content or not store state in the session
52 52
 			);
53
-			$this->ui->get_rows($query,$selection,$readonlys,true);	// true = only return the id's
53
+			$this->ui->get_rows($query, $selection, $readonlys, true); // true = only return the id's
54 54
 		}
55
-		else if($options['selection'] == 'filter')
55
+		else if ($options['selection'] == 'filter')
56 56
 		{
57 57
 			$fields = importexport_helper_functions::get_filter_fields($_definition->application, $this);
58 58
 			$filter = $_definition->filter;
59 59
 			$query = array(
60 60
 				'num_rows' => -1,
61
-				'csv_export' => true,	// so get_rows method _can_ produce different content or not store state in the session
61
+				'csv_export' => true, // so get_rows method _can_ produce different content or not store state in the session
62 62
 				'col_filter' => array()
63 63
 			);
64 64
 
65 65
 			// Handle ranges
66
-			foreach($filter as $field => $value)
66
+			foreach ($filter as $field => $value)
67 67
 			{
68
-				if($field == 'cat_id')
68
+				if ($field == 'cat_id')
69 69
 				{
70 70
 					$query['cat_id'] = $value;
71 71
 					continue;
72 72
 				}
73 73
 				$query['col_filter'][$field] = $value;
74
-				if(!is_array($value) || (!$value['from'] && !$value['to'])) continue;
74
+				if (!is_array($value) || (!$value['from'] && !$value['to'])) continue;
75 75
 
76 76
 				// Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10)
77
-				if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from'];
78
-				if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to'];
77
+				if ($value['from']) $query['col_filter'][] = "$field >= ".(int)$value['from'];
78
+				if ($value['to']) $query['col_filter'][] = "$field <= ".(int)$value['to'];
79 79
 				unset($query['col_filter'][$field]);
80 80
 			}
81
-			$this->ui->get_rows($query,$selection,$readonlys,true);	// true = only return the id's
81
+			$this->ui->get_rows($query, $selection, $readonlys, true); // true = only return the id's
82 82
 		}
83 83
 
84 84
 
@@ -91,16 +91,16 @@  discard block
 block discarded – undo
91 91
 		foreach ($selection as $identifier)
92 92
 		{
93 93
 			$record = new timesheet_egw_record($identifier);
94
-			if($options['convert'])
94
+			if ($options['convert'])
95 95
 			{
96 96
 				importexport_export_csv::convert($record, timesheet_egw_record::$types, 'timesheet', $this->selects);
97 97
 			}
98 98
 			else
99 99
 			{
100 100
 				// Implode arrays, so they don't say 'Array'
101
-				foreach($record->get_record_array() as $key => $value)
101
+				foreach ($record->get_record_array() as $key => $value)
102 102
 				{
103
-					if(is_array($value)) $record->$key = implode(',', $value);
103
+					if (is_array($value)) $record->$key = implode(',', $value);
104 104
 				}
105 105
  			}
106 106
 			$export_object->export_record($record);
@@ -176,11 +176,11 @@  discard block
 block discarded – undo
176 176
 	public function get_selects()
177 177
 	{
178 178
 		$this->selects = array(
179
-			'ts_status'	=>	$this->ui->status_labels+array(lang('No status'))
179
+			'ts_status'	=>	$this->ui->status_labels + array(lang('No status'))
180 180
 		);
181
-		foreach($this->selects['ts_status'] as &$status)
181
+		foreach ($this->selects['ts_status'] as &$status)
182 182
 		{
183
-			$status = str_replace('&nbsp;','',$status); // Remove &nbsp;
183
+			$status = str_replace('&nbsp;', '', $status); // Remove &nbsp;
184 184
 		}
185 185
 
186 186
 	}
@@ -189,9 +189,9 @@  discard block
 block discarded – undo
189 189
 	 */
190 190
 	public function get_filter_fields(Array &$filters)
191 191
 	{
192
-		foreach($filters as $field_name => &$settings)
192
+		foreach ($filters as $field_name => &$settings)
193 193
 		{
194
-			if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
194
+			if ($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
195 195
 		}
196 196
 	}
197 197
 
Please login to merge, or discard this patch.
Braces   +20 added lines, -5 removed lines patch added patch discarded remove patch
@@ -71,11 +71,20 @@  discard block
 block discarded – undo
71 71
 					continue;
72 72
 				}
73 73
 				$query['col_filter'][$field] = $value;
74
-				if(!is_array($value) || (!$value['from'] && !$value['to'])) continue;
74
+				if(!is_array($value) || (!$value['from'] && !$value['to']))
75
+				{
76
+					continue;
77
+				}
75 78
 
76 79
 				// Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10)
77
-				if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from'];
78
-				if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to'];
80
+				if($value['from'])
81
+				{
82
+					$query['col_filter'][] = "$field >= " . (int)$value['from'];
83
+				}
84
+				if($value['to'])
85
+				{
86
+					$query['col_filter'][] = "$field <= " . (int)$value['to'];
87
+				}
79 88
 				unset($query['col_filter'][$field]);
80 89
 			}
81 90
 			$this->ui->get_rows($query,$selection,$readonlys,true);	// true = only return the id's
@@ -100,7 +109,10 @@  discard block
 block discarded – undo
100 109
 				// Implode arrays, so they don't say 'Array'
101 110
 				foreach($record->get_record_array() as $key => $value)
102 111
 				{
103
-					if(is_array($value)) $record->$key = implode(',', $value);
112
+					if(is_array($value))
113
+					{
114
+						$record->$key = implode(',', $value);
115
+					}
104 116
 				}
105 117
  			}
106 118
 			$export_object->export_record($record);
@@ -191,7 +203,10 @@  discard block
 block discarded – undo
191 203
 	{
192 204
 		foreach($filters as $field_name => &$settings)
193 205
 		{
194
-			if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
206
+			if($this->selects[$field_name])
207
+			{
208
+				$settings['values'] = $this->selects[$field_name];
209
+			}
195 210
 		}
196 211
 	}
197 212
 
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	/**
24 24
 	 * Exports records as defined in $_definition
25 25
 	 *
26
-	 * @param egw_record $_definition
26
+	 * @param importexport_definition $_definition
27 27
 	 */
28 28
 	public function export( $_stream, importexport_definition $_definition)
29 29
 	{
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 *
145 145
 	 * @param $definition Specific definition
146 146
 	 *
147
-	 * @return array (
147
+	 * @return boolean (
148 148
 	 * 		name 		=> string,
149 149
 	 * 		content		=> array,
150 150
 	 * 		sel_options	=> array,
Please login to merge, or discard this patch.
timesheet/inc/class.timesheet_ui.inc.php 4 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -942,7 +942,7 @@
 block discarded – undo
942 942
 	 *
943 943
 	 * @return array see nextmatch_widget::egw_actions()
944 944
 	 */
945
-	public function get_actions(Array $query)
945
+	public function get_actions(array $query)
946 946
 	{
947 947
 		$actions = array(
948 948
 			'open' => array(	// does edit if allowed, otherwise view
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -273,7 +273,7 @@
 block discarded – undo
273 273
 	 * @param int &$success number of succeded actions
274 274
 	 * @param int &$failed number of failed actions (not enought permissions)
275 275
 	 * @param string &$action_msg translated verb for the actions, to be used in a message like %1 timesheets 'deleted'
276
-	 * @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup
276
+	 * @param string $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup
277 277
 	 * @return boolean true if all actions succeded, false otherwise
278 278
 	 */
279 279
 	function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg)
Please login to merge, or discard this patch.
Braces   +177 added lines, -45 removed lines patch added patch discarded remove patch
@@ -63,7 +63,10 @@  discard block
 block discarded – undo
63 63
 		$etpl = new Etemplate('timesheet.edit');
64 64
 		if (!is_array($content))
65 65
 		{
66
-			if ($_GET['msg']) $msg = strip_tags($_GET['msg']);
66
+			if ($_GET['msg'])
67
+			{
68
+				$msg = strip_tags($_GET['msg']);
69
+			}
67 70
 
68 71
 			if ($view || (int)$_GET['ts_id'])
69 72
 			{
@@ -130,23 +133,32 @@  discard block
 block discarded – undo
130 133
 				$content['ts_description'] = $content['ts_description_short'];
131 134
 			}
132 135
 			// we only need 2 out of 3 values from start-, end-time or duration (the date in ts_start is always required!)
133
-			if (isset($content['start_time']))		// start-time specified
136
+			if (isset($content['start_time']))
137
+			{
138
+				// start-time specified
134 139
 			{
135 140
 				//$content['ts_start'] += $content['start_time'];
136 141
 				$start = new Api\DateTime($content['ts_start']);
142
+			}
137 143
 				$start_time = explode(':',$content['start_time']);
138 144
 				$start->setTime($start_time[0],$start_time[1]);
139 145
 				$content['ts_start'] = $start->format('ts');
140 146
 			}
141
-			if (isset($content['end_time']))		// end-time specified
147
+			if (isset($content['end_time']))
148
+			{
149
+				// end-time specified
142 150
 			{
143 151
 				$end = new Api\DateTime($content['ts_start']);
152
+			}
144 153
 				$end_time = explode(':',$content['end_time']);
145 154
 				$end->setTime($end_time[0],$end_time[1]);
146 155
 			}
147
-			if ($end && $start)	// start- & end-time --> calculate the duration
156
+			if ($end && $start)
157
+			{
158
+				// start- & end-time --> calculate the duration
148 159
 			{
149 160
 				$content['ts_duration'] = ($end->format('ts') - $start->format('ts')) / 60;
161
+			}
150 162
 				// check if negative duration is caused by wrap over midnight
151 163
 				if ($content['ts_duration'] < 0 && $content['ts_duration'] > -24*60)
152 164
 				{
@@ -154,12 +166,18 @@  discard block
 block discarded – undo
154 166
 				}
155 167
 				//echo "<p>end_time=$content[end_time], start_time=$content[start_time] --> duration=$content[ts_duration]</p>\n";
156 168
 			}
157
-			elseif ($content['ts_duration'] && $end)	// no start, calculate from end and duration
169
+			elseif ($content['ts_duration'] && $end)
170
+			{
171
+				// no start, calculate from end and duration
158 172
 			{
159 173
 				$content['ts_start'] = $end->format('ts') - 60*$content['ts_duration'];
174
+			}
160 175
 				//echo "<p>end_time=$content[end_time], duration=$content[ts_duration] --> ts_start=$content[ts_start]=".Api\DateTime::to($content['ts_start'])."</p>\n";
161 176
 			}
162
-			if ($content['ts_duration'] > 0) unset($content['end_time']);
177
+			if ($content['ts_duration'] > 0)
178
+			{
179
+				unset($content['end_time']);
180
+			}
163 181
 			// now we only deal with start (date+time) and duration
164 182
 			list($button) = @each($content['button']);
165 183
 			$view = $content['view'];
@@ -173,7 +191,10 @@  discard block
 block discarded – undo
173 191
 			switch($button)
174 192
 			{
175 193
 				case 'edit':
176
-					if ($this->check_acl(Acl::EDIT) && !$only_admin_edit) $view = false;
194
+					if ($this->check_acl(Acl::EDIT) && !$only_admin_edit)
195
+					{
196
+						$view = false;
197
+					}
177 198
 					break;
178 199
 
179 200
 				case 'undelete':
@@ -187,12 +208,15 @@  discard block
 block discarded – undo
187 208
 				case 'save':
188 209
 				case 'save_new':
189 210
 				case 'apply':
190
-					if (($this->data['ts_quantity'] === '' || $this->ts_viewtype == 'short') && $this->data['ts_duration'])	// set the quantity (in h) from the duration (in min)
211
+					if (($this->data['ts_quantity'] === '' || $this->ts_viewtype == 'short') && $this->data['ts_duration'])
212
+					{
213
+						// set the quantity (in h) from the duration (in min)
191 214
 					{
192 215
 						// We need to keep the actual value of ts_quantity when we are storing it, as it is used in price calculation
193 216
 						// and rounding it causes miscalculation on prices
194 217
 						$this->data['ts_quantity'] = $this->data['ts_duration'] / 60.0;
195 218
 					}
219
+					}
196 220
 					if ($this->data['ts_quantity'] === '')
197 221
 					{
198 222
 						$etpl->set_validation_error('ts_quantity',lang('Field must not be empty !!!'));
@@ -226,7 +250,11 @@  discard block
 block discarded – undo
226 250
 							unset($content['ts_project_blur']);
227 251
 						}
228 252
 					}
229
-					if ($etpl->validation_errors()) break;	// the user need to fix the error, before we can save the entry
253
+					if ($etpl->validation_errors())
254
+					{
255
+						break;
256
+					}
257
+					// the user need to fix the error, before we can save the entry
230 258
 
231 259
 					// account for changed project --> remove old one from links and add new one
232 260
 					if ((int) $this->data['pm_id'] != (int) $this->data['old_pm_id'])
@@ -270,14 +298,20 @@  discard block
 block discarded – undo
270 298
 						}
271 299
 					}
272 300
 					Framework::refresh_opener($msg, 'timesheet', $this->data['ts_id'], $content['ts_id'] ? 'edit' : 'add');
273
-					if ($button == 'apply') break;
301
+					if ($button == 'apply')
302
+					{
303
+						break;
304
+					}
274 305
 					if ($button == 'save_new')
275 306
 					{
276 307
 						$msg .= ', '.lang('creating new entry');		// giving some feedback to the user
277 308
 
278
-						if (!is_array($content['link_to']['to_id']))	// set links again, so new entry gets the same links as the existing one
309
+						if (!is_array($content['link_to']['to_id']))
310
+						{
311
+							// set links again, so new entry gets the same links as the existing one
279 312
 						{
280 313
 							$content['link_to']['to_id'] = 0;
314
+						}
281 315
 							foreach(Link::get_links(TIMESHEET_APP,$this->data['ts_id'],'!'.Link::VFS_APPNAME) as $link)
282 316
 							{
283 317
 								Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$link['app'],$link['id'],$link['remark']);
@@ -345,12 +379,15 @@  discard block
 block discarded – undo
345 379
 			foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
346 380
 			{
347 381
 				$link_id = $link_ids[$n];
348
-				if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))	// gard against XSS
382
+				if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))
383
+				{
384
+					// gard against XSS
349 385
 				{
350 386
 					switch ($link_app)
351 387
 					{
352 388
 						case 'projectmanager':
353 389
 							$links[] = $link_id;
390
+				}
354 391
 							// fall-through;
355 392
 						default:
356 393
 							if(!$n)
@@ -362,8 +399,14 @@  discard block
 block discarded – undo
362 399
 								{
363 400
 									foreach((array)$set['link_app'] as $i => $l_app)
364 401
 									{
365
-										if (($l_id=$set['link_id'][$i])) Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$l_app,$l_id);
366
-										if ($l_app == 'projectmanager') $links[] = $l_id;
402
+										if (($l_id=$set['link_id'][$i]))
403
+										{
404
+											Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$l_app,$l_id);
405
+										}
406
+										if ($l_app == 'projectmanager')
407
+										{
408
+											$links[] = $l_id;
409
+										}
367 410
 									}
368 411
 									unset($set['link_app']);
369 412
 									unset($set['link_id']);
@@ -464,8 +507,16 @@  discard block
 block discarded – undo
464 507
 				$etpl->setElementAttribute('pm_id','blur',$content['ts_project']);
465 508
 			}
466 509
 		}
467
-		if (!$this->customfields) $readonlys['tabs']['customfields'] = true;	// suppress tab if there are not customfields
468
-		if (!$this->data['ts_id']) $readonlys['tabs']['history']    = true;   //suppress history for the first loading without ID
510
+		if (!$this->customfields)
511
+		{
512
+			$readonlys['tabs']['customfields'] = true;
513
+		}
514
+		// suppress tab if there are not customfields
515
+		if (!$this->data['ts_id'])
516
+		{
517
+			$readonlys['tabs']['history']    = true;
518
+		}
519
+		//suppress history for the first loading without ID
469 520
 
470 521
 		return $etpl->exec(TIMESHEET_APP.'.timesheet_ui.edit',$content,$sel_options,$readonlys,$preserv,2);
471 522
 	}
@@ -478,7 +529,10 @@  discard block
 block discarded – undo
478 529
 	 */
479 530
 	function datetime2time($datetime)
480 531
 	{
481
-		if (!$datetime) return 0;
532
+		if (!$datetime)
533
+		{
534
+			return 0;
535
+		}
482 536
 
483 537
 		return $datetime - mktime(0,0,0,date('m',$datetime),date('d',$datetime),date('Y',$datetime));
484 538
 	}
@@ -524,7 +578,10 @@  discard block
 block discarded – undo
524 578
 			}
525 579
 			// show week-sums, if we are week-aligned (show full weeks)?
526 580
 			$week_start_day = $GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'];
527
-			if (!$week_start_day) $week_start_day = 'Sunday';
581
+			if (!$week_start_day)
582
+			{
583
+				$week_start_day = 'Sunday';
584
+			}
528 585
 			switch($week_start_day)
529 586
 			{
530 587
 				case 'Sunday': $week_end_day = 'Saturday'; break;
@@ -545,7 +602,10 @@  discard block
 block discarded – undo
545 602
 			}
546 603
 		}
547 604
 		//echo "<p align=right>show_sums=".print_r($this->show_sums,true)."</p>\n";
548
-		if (!$id_only && !$query_in['csv_export']) Api\Cache::setSession(TIMESHEET_APP, 'index', $query_in);
605
+		if (!$id_only && !$query_in['csv_export'])
606
+		{
607
+			Api\Cache::setSession(TIMESHEET_APP, 'index', $query_in);
608
+		}
549 609
 
550 610
 		// Refresh actions (undelete needs this)
551 611
 		$query_in['actions'] = $this->get_actions($query_in);
@@ -553,8 +613,14 @@  discard block
 block discarded – undo
553 613
 		$query = $query_in;	// keep the original query
554 614
 		$query['enddate'] = $end_date;
555 615
 
556
-		if($this->ts_viewtype == 'short') $query_in['options-selectcols'] = array('ts_quantity'=>false,'ts_unitprice'=>false,'ts_total'=>false);
557
-		if ($query['no_status']) $query_in['options-selectcols']['ts_status'] = false;
616
+		if($this->ts_viewtype == 'short')
617
+		{
618
+			$query_in['options-selectcols'] = array('ts_quantity'=>false,'ts_unitprice'=>false,'ts_total'=>false);
619
+		}
620
+		if ($query['no_status'])
621
+		{
622
+			$query_in['options-selectcols']['ts_status'] = false;
623
+		}
558 624
 
559 625
 		//_debug_array($query['col_filter']);
560 626
 		//echo "PM Integration:".$this->pm_integration.'<br>';
@@ -567,8 +633,14 @@  discard block
 block discarded – undo
567 633
 		{
568 634
 			//$query['col_filter']['ts_id'] = Link::get_links('projectmanager',$query['col_filter']['pm_id'],'timesheet');
569 635
 			$query['col_filter']['ts_id'] = $this->get_ts_links($query['col_filter']['pm_id']);
570
-			if (empty($query['col_filter']['ts_id'])) $query['col_filter']['ts_id'] = -1;
571
-			if (!$query['col_filter']['ts_id']) $query['col_filter']['ts_id'] = 0;
636
+			if (empty($query['col_filter']['ts_id']))
637
+			{
638
+				$query['col_filter']['ts_id'] = -1;
639
+			}
640
+			if (!$query['col_filter']['ts_id'])
641
+			{
642
+				$query['col_filter']['ts_id'] = 0;
643
+			}
572 644
 		}
573 645
 		if ((string)$query['col_filter']['pm_id'] != '' && (string)$query['col_filter']['pm_id'] == '0')
574 646
 		{
@@ -640,10 +712,13 @@  discard block
 block discarded – undo
640 712
 			$cats = $GLOBALS['egw']->categories->return_all_children((int)$query['cat_id']);
641 713
 			$query['col_filter']['cat_id'] = count($cats) > 1 ? $cats : $query['cat_id'];
642 714
 		}
643
-		elseif ((string)$query['cat_id'] == '0')	// no category
715
+		elseif ((string)$query['cat_id'] == '0')
716
+		{
717
+			// no category
644 718
 		{
645 719
 			$query['col_filter']['cat_id'] = null;
646 720
 		}
721
+		}
647 722
 		else	// all cats --> no filter
648 723
 		{
649 724
 			unset($query['col_filter']['cat_id']);
@@ -654,7 +729,10 @@  discard block
 block discarded – undo
654 729
 			$GLOBALS['egw_info']['flags']['app_header'] .= ': '.Api\Accounts::username($query['col_filter']['ts_owner']);
655 730
 			#if ($GLOBALS['egw']->accounts->get_type($query['col_filter']['ts_owner']) == 'g') $GLOBALS['egw_info']['flags']['app_header'] .= ' '. lang("and its members");
656 731
 			#_debug_array($GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'],true));
657
-			if ($query['col_filter']['ts_owner']<0) $query['col_filter']['ts_owner'] = array_merge(array($query['col_filter']['ts_owner']),$GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'],true));
732
+			if ($query['col_filter']['ts_owner']<0)
733
+			{
734
+				$query['col_filter']['ts_owner'] = array_merge(array($query['col_filter']['ts_owner']),$GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'],true));
735
+			}
658 736
 		}
659 737
 		else
660 738
 		{
@@ -667,10 +745,13 @@  discard block
 block discarded – undo
667 745
 			// generate a meaningful app-header / report title
668 746
 			if ($this->show_sums['month'])
669 747
 			{
670
-				if ((int)$start[1] == 1 && (int) $end[1] == 12)		// whole year(s)
748
+				if ((int)$start[1] == 1 && (int) $end[1] == 12)
749
+				{
750
+					// whole year(s)
671 751
 				{
672 752
 					$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . $start[0] . ($start[0] != $end[0] ? ' - '.$end[0] : '');
673 753
 				}
754
+				}
674 755
 				else
675 756
 				{
676 757
 					$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . lang(date('F',$query['startdate']+12*60*60)) . ' ' . $start[0];
@@ -712,7 +793,10 @@  discard block
 block discarded – undo
712 793
 		$ids = array();
713 794
 		foreach($rows as &$row)
714 795
 		{
715
-			if ($row['ts_id'] > 0) $ids[] = $row['ts_id'];
796
+			if ($row['ts_id'] > 0)
797
+			{
798
+				$ids[] = $row['ts_id'];
799
+			}
716 800
 		}
717 801
 		if ($id_only)
718 802
 		{
@@ -742,12 +826,19 @@  discard block
 block discarded – undo
742 826
 		$have_cats = false;
743 827
 		foreach($rows as &$row)
744 828
 		{
745
-			if ($row['cat_id']) $have_cats = true;
829
+			if ($row['cat_id'])
830
+			{
831
+				$have_cats = true;
832
+			}
746 833
 
747 834
 			$row['class'] = 'row';
748
-			if ($row['ts_id'] <= 0)	// sums
835
+			if ($row['ts_id'] <= 0)
749 836
 			{
750
-				if ($query['sort'] == 'ASC') $row['ts_start'] -= 7200;	// fix for DSL change
837
+				// sums
838
+			{
839
+				if ($query['sort'] == 'ASC') $row['ts_start'] -= 7200;
840
+			}
841
+			// fix for DSL change
751 842
 
752 843
 				// Remove fake modified date, it breaks nextmatch checks
753 844
 				unset($row['ts_modified']);
@@ -775,7 +866,10 @@  discard block
 block discarded – undo
775 866
 						break;
776 867
 				}
777 868
 				$row['ts_start'] = $row['ts_unitprice'] = '';
778
-				if (!$this->quantity_sum) $row['ts_quantity'] = '';
869
+				if (!$this->quantity_sum)
870
+				{
871
+					$row['ts_quantity'] = '';
872
+				}
779 873
 				$row['class'] = 'th rowNoEdit rowNoDelete rowNoUndelete';
780 874
 				$row['titleClass'] = 'timesheet_titleSum';
781 875
 				continue;
@@ -817,11 +911,17 @@  discard block
 block discarded – undo
817 911
 				}
818 912
 			}
819 913
 
820
-			if(!$row['titleClass']) $row['titleClass'] = 'timesheet_titleDetails';
914
+			if(!$row['titleClass'])
915
+			{
916
+				$row['titleClass'] = 'timesheet_titleDetails';
917
+			}
821 918
 
822 919
 		}
823 920
 		$rows['no_cat_id'] = (!$have_cats || $query['cat_id']);
824
-		if ($query['col_filter']['ts_owner']) $rows['ownerClass'] = 'noPrint';
921
+		if ($query['col_filter']['ts_owner'])
922
+		{
923
+			$rows['ownerClass'] = 'noPrint';
924
+		}
825 925
 		$rows['no_owner_col'] = $query['no_owner_col'];
826 926
 		if(is_string($query['selectcols']))
827 927
 		{
@@ -839,13 +939,23 @@  discard block
 block discarded – undo
839 939
 		if (!$rows['ts_viewtype'])
840 940
 		{
841 941
 			#_debug_array($query['selectcols']);
842
-			if(!is_array($query['selectcols'])){
942
+			if(!is_array($query['selectcols']))
943
+			{
843 944
 				$query['selectcols'] = explode(',',$query['selectcols']);
844 945
 			}
845 946
 			#ts_quantity,ts_unitprice,ts_total
846
-			if ($query['selectcols'] && in_array('ts_quantity_quantity',$query['selectcols'])===false) $rows['no_ts_quantity'] = 1;
847
-			if ($query['selectcols'] && in_array('ts_unitprice', $query['selectcols'])===false) $rows['no_ts_unitprice'] = 1;
848
-			if ($query['selectcols'] && in_array('ts_total_price',$query['selectcols'])===false) $rows['no_ts_total'] = 1;
947
+			if ($query['selectcols'] && in_array('ts_quantity_quantity',$query['selectcols'])===false)
948
+			{
949
+				$rows['no_ts_quantity'] = 1;
950
+			}
951
+			if ($query['selectcols'] && in_array('ts_unitprice', $query['selectcols'])===false)
952
+			{
953
+				$rows['no_ts_unitprice'] = 1;
954
+			}
955
+			if ($query['selectcols'] && in_array('ts_total_price',$query['selectcols'])===false)
956
+			{
957
+				$rows['no_ts_total'] = 1;
958
+			}
849 959
 		}
850 960
 		$rows['no_ts_status'] = in_array('ts_status', $query['selectcols']) === false && !$this->config_data['history'] ||
851 961
 			$query['no_status'];
@@ -868,7 +978,10 @@  discard block
 block discarded – undo
868 978
 	{
869 979
 		$etpl = new Etemplate('timesheet.index');
870 980
 
871
-		if ($_GET['msg']) $msg = $_GET['msg'];
981
+		if ($_GET['msg'])
982
+		{
983
+			$msg = $_GET['msg'];
984
+		}
872 985
 		if ($content['nm']['rows']['delete'])
873 986
 		{
874 987
 			list($ts_id) = each($content['nm']['rows']['delete']);
@@ -881,9 +994,12 @@  discard block
 block discarded – undo
881 994
 				$msg = lang('Error deleting the entry!!!');
882 995
 			}
883 996
 		}
884
-		if (is_array($content) && isset($content['nm']['rows']['document']))  // handle insert in default document button like an action
997
+		if (is_array($content) && isset($content['nm']['rows']['document']))
998
+		{
999
+			// handle insert in default document button like an action
885 1000
 		{
886 1001
 			list($id) = @each($content['nm']['rows']['document']);
1002
+		}
887 1003
 			$content['nm']['action'] = 'document';
888 1004
 			$content['nm']['selected'] = array($id);
889 1005
 		}
@@ -957,7 +1073,10 @@  discard block
 block discarded – undo
957 1073
 		}
958 1074
 		$read_grants = $this->grant_list(Acl::READ);
959 1075
 		$content['nm']['no_owner_col'] = count($read_grants) == 1;
960
-		if ($GLOBALS['egw_info']['user']['preferences']['timesheet']['nextmatch-timesheet.index.rows']) $content['nm']['selectcols'] = $GLOBALS['egw_info']['user']['preferences']['timesheet']['nextmatch-timesheet.index.rows'];
1076
+		if ($GLOBALS['egw_info']['user']['preferences']['timesheet']['nextmatch-timesheet.index.rows'])
1077
+		{
1078
+			$content['nm']['selectcols'] = $GLOBALS['egw_info']['user']['preferences']['timesheet']['nextmatch-timesheet.index.rows'];
1079
+		}
961 1080
 		$sel_options = array(
962 1081
 			'ts_owner'   => $read_grants,
963 1082
 			'pm_id'      => array(lang('No project')),
@@ -974,7 +1093,10 @@  discard block
 block discarded – undo
974 1093
 		if ($this->pm_integration != 'full')
975 1094
 		{
976 1095
 			$projects =& $this->query_list('ts_project');
977
-			if (!is_array($projects)) $projects = array();
1096
+			if (!is_array($projects))
1097
+			{
1098
+				$projects = array();
1099
+			}
978 1100
 			$sel_options['ts_project'] = $projects + array(lang('No project'));
979 1101
 		}
980 1102
 
@@ -1192,7 +1314,8 @@  discard block
 block discarded – undo
1192 1314
 			case 'cat':
1193 1315
 				$cat_name = Api\Categories::id2name($settings);
1194 1316
 				$action_msg = lang('changed category to %1', $cat_name);
1195
-				foreach((array)$checked as $n => $id) {
1317
+				foreach((array)$checked as $n => $id)
1318
+				{
1196 1319
 					if (($entry = $this->read($id)) &&
1197 1320
 						($entry['cat_id'] = $settings) &&
1198 1321
 						$this->save($entry) == 0)
@@ -1207,7 +1330,10 @@  discard block
 block discarded – undo
1207 1330
 				break;
1208 1331
 
1209 1332
 			case 'document':
1210
-				if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['timesheet']['default_document'];
1333
+				if (!$settings)
1334
+				{
1335
+					$settings = $GLOBALS['egw_info']['user']['preferences']['timesheet']['default_document'];
1336
+				}
1211 1337
 				$document_merge = new timesheet_merge();
1212 1338
 				$msg = $document_merge->download($settings, $checked, '', $GLOBALS['egw_info']['user']['preferences']['timesheet']['document_dir']);
1213 1339
 				$failed = count($checked);
@@ -1259,7 +1385,10 @@  discard block
 block discarded – undo
1259 1385
 						$this->load_statuses();
1260 1386
 						$msg .= lang('Status updated.');
1261 1387
 					}
1262
-					if ($button == 'apply') break;
1388
+					if ($button == 'apply')
1389
+					{
1390
+						break;
1391
+					}
1263 1392
 					// fall-through
1264 1393
 				case 'cancel':
1265 1394
 					$GLOBALS['egw']->redirect_link('/admin/index.php', null, 'admin');
@@ -1337,7 +1466,10 @@  discard block
 block discarded – undo
1337 1466
 		$this->data['ts_owner'] = !(int)$this->data['ts_owner'] || !$this->check_acl(Acl::ADD,NULL,$this->data['ts_owner']) ? $this->user : $this->data['ts_owner'];
1338 1467
 
1339 1468
 		// Copy links
1340
-		if(!is_array($this->data['link_to'])) $this->data['link_to'] = array();
1469
+		if(!is_array($this->data['link_to']))
1470
+		{
1471
+			$this->data['link_to'] = array();
1472
+		}
1341 1473
 		$this->data['link_to']['to_app'] = 'timesheet';
1342 1474
 		$this->data['link_to']['to_id'] = 0;
1343 1475
 
Please login to merge, or discard this patch.
Spacing   +182 added lines, -185 removed lines patch added patch discarded remove patch
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 
56 56
 	function view()
57 57
 	{
58
-		$this->edit(null,true);
58
+		$this->edit(null, true);
59 59
 	}
60 60
 
61
-	function edit($content = null,$view = false)
61
+	function edit($content = null, $view = false)
62 62
 	{
63 63
 		$etpl = new Etemplate('timesheet.edit');
64 64
 		if (!is_array($content))
@@ -80,35 +80,34 @@  discard block
 block discarded – undo
80 80
 			{
81 81
 				$this->data = array(
82 82
 					'ts_start' => $this->today,
83
-					'start_time' => '',	// force empty start-time
84
-					'end_time' => Api\DateTime::to($this->now,'H:i'),
83
+					'start_time' => '', // force empty start-time
84
+					'end_time' => Api\DateTime::to($this->now, 'H:i'),
85 85
 					'ts_owner' => $GLOBALS['egw_info']['user']['account_id'],
86
-					'cat_id'   => (int) $_REQUEST['cat_id'],
86
+					'cat_id'   => (int)$_REQUEST['cat_id'],
87 87
 					'ts_status'=> $GLOBALS['egw_info']['user']['preferences']['timesheet']['predefined_status'],
88 88
 					'ts_project' => $_REQUEST['ts_project'],
89 89
 					'ts_title_blur' => $_REQUEST['ts_project'],
90 90
 				);
91
-				if(!is_numeric($_REQUEST['ts_project']))
91
+				if (!is_numeric($_REQUEST['ts_project']))
92 92
 				{
93 93
 					$this->data['pm_id'] = $this->find_pm_id($_REQUEST['ts_project']);
94 94
 				}
95 95
 			}
96 96
 			$matches = null;
97
-			$referer = preg_match('/menuaction=([^&]+)/',$_SERVER['HTTP_REFERER'],$matches) ? $matches[1] :
98
-				(strpos($_SERVER['HTTP_REFERER'],'/infolog/index.php') !== false ? 'infolog.infolog_ui.index' : TIMESHEET_APP.'.timesheet_ui.index');
97
+			$referer = preg_match('/menuaction=([^&]+)/', $_SERVER['HTTP_REFERER'], $matches) ? $matches[1] : (strpos($_SERVER['HTTP_REFERER'], '/infolog/index.php') !== false ? 'infolog.infolog_ui.index' : TIMESHEET_APP.'.timesheet_ui.index');
99 98
 
100
-			if($_GET['action'] == 'copy')
99
+			if ($_GET['action'] == 'copy')
101 100
 			{
102 101
 				$this->create_copy();
103
-				$msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry(TIMESHEET_APP,'entry')));
102
+				$msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry(TIMESHEET_APP, 'entry')));
104 103
 			}
105 104
 			if (!$this->check_statusForEditRights($this->data))
106 105
 			{
107
-				$view = true;  //only admin can edit with this status
106
+				$view = true; //only admin can edit with this status
108 107
 				$only_admin_edit = true;
109 108
 				$msg = lang('only Admin can edit this status');
110 109
 			}
111
-			if(!$this->data['ts_project_blur'])
110
+			if (!$this->data['ts_project_blur'])
112 111
 			{
113 112
 				$this->data['ts_project_blur'] = $this->data['pm_id'] ? Link::title('projectmanager', $this->data['pm_id']) : '';
114 113
 			}
@@ -120,7 +119,7 @@  discard block
 block discarded – undo
120 119
 			{
121 120
 				if ($this->status_labels_config[$content['ts_status']]['admin'])
122 121
 				{
123
-					$view = true;  //only admin can edit with this status
122
+					$view = true; //only admin can edit with this status
124 123
 					$only_admin_edit = true;
125 124
 					$msg = lang('only Admin can edit this status');
126 125
 				}
@@ -134,29 +133,29 @@  discard block
 block discarded – undo
134 133
 			{
135 134
 				//$content['ts_start'] += $content['start_time'];
136 135
 				$start = new Api\DateTime($content['ts_start']);
137
-				$start_time = explode(':',$content['start_time']);
138
-				$start->setTime($start_time[0],$start_time[1]);
136
+				$start_time = explode(':', $content['start_time']);
137
+				$start->setTime($start_time[0], $start_time[1]);
139 138
 				$content['ts_start'] = $start->format('ts');
140 139
 			}
141 140
 			if (isset($content['end_time']))		// end-time specified
142 141
 			{
143 142
 				$end = new Api\DateTime($content['ts_start']);
144
-				$end_time = explode(':',$content['end_time']);
145
-				$end->setTime($end_time[0],$end_time[1]);
143
+				$end_time = explode(':', $content['end_time']);
144
+				$end->setTime($end_time[0], $end_time[1]);
146 145
 			}
147 146
 			if ($end && $start)	// start- & end-time --> calculate the duration
148 147
 			{
149 148
 				$content['ts_duration'] = ($end->format('ts') - $start->format('ts')) / 60;
150 149
 				// check if negative duration is caused by wrap over midnight
151
-				if ($content['ts_duration'] < 0 && $content['ts_duration'] > -24*60)
150
+				if ($content['ts_duration'] < 0 && $content['ts_duration'] > -24 * 60)
152 151
 				{
153
-					$content['ts_duration'] += 24*60;
152
+					$content['ts_duration'] += 24 * 60;
154 153
 				}
155 154
 				//echo "<p>end_time=$content[end_time], start_time=$content[start_time] --> duration=$content[ts_duration]</p>\n";
156 155
 			}
157 156
 			elseif ($content['ts_duration'] && $end)	// no start, calculate from end and duration
158 157
 			{
159
-				$content['ts_start'] = $end->format('ts') - 60*$content['ts_duration'];
158
+				$content['ts_start'] = $end->format('ts') - 60 * $content['ts_duration'];
160 159
 				//echo "<p>end_time=$content[end_time], duration=$content[ts_duration] --> ts_start=$content[ts_start]=".Api\DateTime::to($content['ts_start'])."</p>\n";
161 160
 			}
162 161
 			if ($content['ts_duration'] > 0) unset($content['end_time']);
@@ -166,18 +165,18 @@  discard block
 block discarded – undo
166 165
 			$referer = $content['referer'];
167 166
 			$content['ts_project_blur'] = $content['pm_id'] ? Link::title('projectmanager', $content['pm_id']) : '';
168 167
 			$this->data = $content;
169
-			foreach(array('button','view','referer','tabs','start_time') as $key)
168
+			foreach (array('button', 'view', 'referer', 'tabs', 'start_time') as $key)
170 169
 			{
171 170
 				unset($this->data[$key]);
172 171
 			}
173
-			switch($button)
172
+			switch ($button)
174 173
 			{
175 174
 				case 'edit':
176 175
 					if ($this->check_acl(Acl::EDIT) && !$only_admin_edit) $view = false;
177 176
 					break;
178 177
 
179 178
 				case 'undelete':
180
-					if($content['ts_status'] == self::DELETED_STATUS)
179
+					if ($content['ts_status'] == self::DELETED_STATUS)
181 180
 					{
182 181
 						unset($content['ts_status']);
183 182
 						$this->data['ts_status'] = '';
@@ -195,18 +194,17 @@  discard block
 block discarded – undo
195 194
 					}
196 195
 					if ($this->data['ts_quantity'] === '')
197 196
 					{
198
-						$etpl->set_validation_error('ts_quantity',lang('Field must not be empty !!!'));
197
+						$etpl->set_validation_error('ts_quantity', lang('Field must not be empty !!!'));
199 198
 					}
200 199
 					if ($this->data['ts_duration'] < 0)
201 200
 					{
202
-						$etpl->set_validation_error('start_time',lang('Starttime has to be before endtime !!!'));
201
+						$etpl->set_validation_error('start_time', lang('Starttime has to be before endtime !!!'));
203 202
 					}
204 203
 					// set ts_title to ts_project if short viewtype (title is not editable)
205
-					if($this->ts_viewtype == 'short')
204
+					if ($this->ts_viewtype == 'short')
206 205
 					{
207 206
 						$this->data['ts_title'] = $this->data['ts_project'] = $this->data['pm_id'] ?
208
-								Link::title('projectmanager', $this->data['pm_id']) :
209
-								$this->data['ts_project'];
207
+								Link::title('projectmanager', $this->data['pm_id']) : $this->data['ts_project'];
210 208
 					}
211 209
 					if (!$this->data['ts_title'])
212 210
 					{
@@ -215,9 +213,9 @@  discard block
 block discarded – undo
215 213
 
216 214
 						if (!$this->data['ts_title'])
217 215
 						{
218
-							$etpl->set_validation_error('ts_title',lang('Field must not be empty !!!'));
216
+							$etpl->set_validation_error('ts_title', lang('Field must not be empty !!!'));
219 217
 						}
220
-						elseif($button != 'save_new')
218
+						elseif ($button != 'save_new')
221 219
 						{
222 220
 							// remove title-blur for same behavior after apply, as for opening the saved entry again
223 221
 							unset($this->data['ts_title_blur']);
@@ -226,26 +224,26 @@  discard block
 block discarded – undo
226 224
 							unset($content['ts_project_blur']);
227 225
 						}
228 226
 					}
229
-					if ($etpl->validation_errors()) break;	// the user need to fix the error, before we can save the entry
227
+					if ($etpl->validation_errors()) break; // the user need to fix the error, before we can save the entry
230 228
 
231 229
 					// account for changed project --> remove old one from links and add new one
232
-					if ((int) $this->data['pm_id'] != (int) $this->data['old_pm_id'])
230
+					if ((int)$this->data['pm_id'] != (int)$this->data['old_pm_id'])
233 231
 					{
234 232
 						// update links accordingly
235 233
 						if ($this->data['pm_id'])
236 234
 						{
237
-							Link::link(TIMESHEET_APP,$content['link_to']['to_id'],'projectmanager',$this->data['pm_id']);
235
+							Link::link(TIMESHEET_APP, $content['link_to']['to_id'], 'projectmanager', $this->data['pm_id']);
238 236
 						}
239 237
 						if ($this->data['old_pm_id'])
240 238
 						{
241
-							Link::unlink2(0,TIMESHEET_APP,$content['link_to']['to_id'],0,'projectmanager',$this->data['old_pm_id']);
239
+							Link::unlink2(0, TIMESHEET_APP, $content['link_to']['to_id'], 0, 'projectmanager', $this->data['old_pm_id']);
242 240
 							unset($this->data['old_pm_id']);
243 241
 						}
244 242
 					}
245 243
 					// check if we are linked to a project, but that is NOT set as project
246 244
 					if (!$this->data['pm_id'] && is_array($content['link_to']['to_id']))
247 245
 					{
248
-						foreach($content['link_to']['to_id'] as $data)
246
+						foreach ($content['link_to']['to_id'] as $data)
249 247
 						{
250 248
 							if ($data['app'] == 'projectmanager')
251 249
 							{
@@ -266,32 +264,32 @@  discard block
 block discarded – undo
266 264
 						$msg = lang('Entry saved');
267 265
 						if (is_array($content['link_to']['to_id']) && count($content['link_to']['to_id']))
268 266
 						{
269
-							Link::link(TIMESHEET_APP,$this->data['ts_id'],$content['link_to']['to_id']);
267
+							Link::link(TIMESHEET_APP, $this->data['ts_id'], $content['link_to']['to_id']);
270 268
 						}
271 269
 					}
272 270
 					Framework::refresh_opener($msg, 'timesheet', $this->data['ts_id'], $content['ts_id'] ? 'edit' : 'add');
273 271
 					if ($button == 'apply') break;
274 272
 					if ($button == 'save_new')
275 273
 					{
276
-						$msg .= ', '.lang('creating new entry');		// giving some feedback to the user
274
+						$msg .= ', '.lang('creating new entry'); // giving some feedback to the user
277 275
 
278 276
 						if (!is_array($content['link_to']['to_id']))	// set links again, so new entry gets the same links as the existing one
279 277
 						{
280 278
 							$content['link_to']['to_id'] = 0;
281
-							foreach(Link::get_links(TIMESHEET_APP,$this->data['ts_id'],'!'.Link::VFS_APPNAME) as $link)
279
+							foreach (Link::get_links(TIMESHEET_APP, $this->data['ts_id'], '!'.Link::VFS_APPNAME) as $link)
282 280
 							{
283
-								Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$link['app'],$link['id'],$link['remark']);
281
+								Link::link(TIMESHEET_APP, $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']);
284 282
 							}
285 283
 						}
286 284
 						// create a new entry
287 285
 						$this->data['ts_start'] += 60 * $this->data['ts_duration'];
288
-						foreach(array('ts_id','ts_title','ts_description','ts_duration','ts_quantity','ts_modified','ts_modifier','link_to') as $name)
286
+						foreach (array('ts_id', 'ts_title', 'ts_description', 'ts_duration', 'ts_quantity', 'ts_modified', 'ts_modifier', 'link_to') as $name)
289 287
 						{
290 288
 							unset($this->data[$name]);
291 289
 						}
292 290
 						// save the selected project, to delete the project-link, if the user changes the project
293 291
 						$this->data['old_pm_id'] = $this->data['pm_id'];
294
-						if($this->pm_integration == 'none')
292
+						if ($this->pm_integration == 'none')
295 293
 						{
296 294
 							unset($this->data['pm_id']);
297 295
 						}
@@ -309,7 +307,7 @@  discard block
 block discarded – undo
309 307
 						else
310 308
 						{
311 309
 							$msg = lang('Error deleting the entry!!!');
312
-							break;	// dont close window
310
+							break; // dont close window
313 311
 						}
314 312
 					}
315 313
 					// fall-through for save
@@ -322,17 +320,16 @@  discard block
 block discarded – undo
322 320
 			'referer' => $referer,
323 321
 			'ts_title_blur' => $content['ts_title_blur'],
324 322
 		);
325
-		$content = array_merge($this->data,array(
323
+		$content = array_merge($this->data, array(
326 324
 			'msg'  => $msg,
327 325
 			'view' => $view,
328 326
 			'tabs'  => $content['tabs'],
329 327
 			'link_to' => array(
330
-				'to_id' => $this->data['ts_id'] ? $this->data['ts_id'] :
331
-					($this->data['link_to']['to_id'] ? $this->data['link_to']['to_id'] : $content['link_to']['to_id']),
328
+				'to_id' => $this->data['ts_id'] ? $this->data['ts_id'] : ($this->data['link_to']['to_id'] ? $this->data['link_to']['to_id'] : $content['link_to']['to_id']),
332 329
 				'to_app' => TIMESHEET_APP,
333 330
 			),
334
-			'ts_quantity_blur' => $this->data['ts_duration'] ? round($this->data['ts_duration'] / 60.0,3) : '',
335
-			'ts_quantity' => $this->data['ts_duration']/60.0 == $this->data['ts_quantity'] ? null : $this->data['ts_quantity'],
331
+			'ts_quantity_blur' => $this->data['ts_duration'] ? round($this->data['ts_duration'] / 60.0, 3) : '',
332
+			'ts_quantity' => $this->data['ts_duration'] / 60.0 == $this->data['ts_quantity'] ? null : $this->data['ts_quantity'],
336 333
 			'start_time' => isset($this->data['start_time']) ? $this->data['start_time'] : $this->data['ts_start'],
337 334
 			'pm_integration' => $this->pm_integration,
338 335
 			'no_ts_status' => !$this->status_labels && ($this->data['ts_status'] != self::DELETED_STATUS),
@@ -342,10 +339,10 @@  discard block
 block discarded – undo
342 339
 		if (!$this->data['ts_id'] && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id']) && !is_array($content['link_to']['to_id']))
343 340
 		{
344 341
 			$link_ids = is_array($_REQUEST['link_id']) ? $_REQUEST['link_id'] : array($_REQUEST['link_id']);
345
-			foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
342
+			foreach (is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
346 343
 			{
347 344
 				$link_id = $link_ids[$n];
348
-				if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))	// gard against XSS
345
+				if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i', $link_app.':'.$link_id))	// gard against XSS
349 346
 				{
350 347
 					switch ($link_app)
351 348
 					{
@@ -353,37 +350,37 @@  discard block
 block discarded – undo
353 350
 							$links[] = $link_id;
354 351
 							// fall-through;
355 352
 						default:
356
-							if(!$n)
353
+							if (!$n)
357 354
 							{
358 355
 								// get title from first linked app
359
-								$preserv['ts_title_blur'] = Link::title($link_app,$link_id);
356
+								$preserv['ts_title_blur'] = Link::title($link_app, $link_id);
360 357
 								// ask first linked app via "timesheet_set" hook, for further data to set, incl. links
361
-								if (($set = Api\Hooks::single(array('location'=>'timesheet_set','id'=>$link_id),$link_app)))
358
+								if (($set = Api\Hooks::single(array('location'=>'timesheet_set', 'id'=>$link_id), $link_app)))
362 359
 								{
363
-									foreach((array)$set['link_app'] as $i => $l_app)
360
+									foreach ((array)$set['link_app'] as $i => $l_app)
364 361
 									{
365
-										if (($l_id=$set['link_id'][$i])) Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$l_app,$l_id);
362
+										if (($l_id = $set['link_id'][$i])) Link::link(TIMESHEET_APP, $content['link_to']['to_id'], $l_app, $l_id);
366 363
 										if ($l_app == 'projectmanager') $links[] = $l_id;
367 364
 									}
368 365
 									unset($set['link_app']);
369 366
 									unset($set['link_id']);
370 367
 
371
-									$content = array_merge($content,$set);
368
+									$content = array_merge($content, $set);
372 369
 								}
373 370
 							}
374 371
 							break;
375 372
 					}
376
-					if($link_app == 'calendar')
373
+					if ($link_app == 'calendar')
377 374
 					{
378 375
 						list($link_id) = explode(':', $link_id);
379 376
 					}
380
-					Link::link(TIMESHEET_APP,$content['link_to']['to_id'],$link_app,$link_id);
377
+					Link::link(TIMESHEET_APP, $content['link_to']['to_id'], $link_app, $link_id);
381 378
 				}
382 379
 			}
383 380
 		}
384 381
 		elseif ($this->data['ts_id'])
385 382
 		{
386
-			$links = Link::get_links(TIMESHEET_APP,$this->data['ts_id'],'projectmanager');
383
+			$links = Link::get_links(TIMESHEET_APP, $this->data['ts_id'], 'projectmanager');
387 384
 		}
388 385
 		// make all linked projects availible for the pm-pricelist widget, to be able to choose prices from all
389 386
 		$content['all_pm_ids'] = array_values($links);
@@ -417,7 +414,7 @@  discard block
 block discarded – undo
417 414
 		$content['ts_title_blur'] = $preserv['ts_title_blur'] ? $preserv['ts_title_blur'] : $content['ts_project_blur'];
418 415
 		$readonlys = array(
419 416
 			'button[delete]'   => !$this->data['ts_id'] || !$this->check_acl(Acl::DELETE) ||
420
-				$this->data['ts_status'] == self::DELETED_STATUS ||$only_admin_edit ,
417
+				$this->data['ts_status'] == self::DELETED_STATUS || $only_admin_edit,
421 418
 			'button[undelete]' => $this->data['ts_status'] != self::DELETED_STATUS,
422 419
 			'button[edit]'     => !$view || !$this->check_acl(Acl::EDIT) || $only_admin_edit,
423 420
 			'button[save]'     => $view,
@@ -427,7 +424,7 @@  discard block
 block discarded – undo
427 424
 
428 425
 		if ($view)
429 426
 		{
430
-			foreach(array_merge(array_keys($this->data),array('pm_id','pl_id','link_to')) as $key)
427
+			foreach (array_merge(array_keys($this->data), array('pm_id', 'pl_id', 'link_to')) as $key)
431 428
 			{
432 429
 				$readonlys[$key] = true;
433 430
 			}
@@ -444,9 +441,9 @@  discard block
 block discarded – undo
444 441
 		{
445 442
 			$edit_grants[$content['ts_owner']] = Api\Accounts::username($content['ts_owner']);
446 443
 		}
447
-		$sel_options['ts_owner']  = $edit_grants;
448
-		$sel_options['ts_status']  = $this->get_status_labels($only_admin_edit);
449
-		if($this->config_data['history'] && $content['ts_status'] == self::DELETED_STATUS)
444
+		$sel_options['ts_owner'] = $edit_grants;
445
+		$sel_options['ts_status'] = $this->get_status_labels($only_admin_edit);
446
+		if ($this->config_data['history'] && $content['ts_status'] == self::DELETED_STATUS)
450 447
 		{
451 448
 			$sel_options['ts_status'][self::DELETED_STATUS] = 'Deleted';
452 449
 		}
@@ -456,23 +453,23 @@  discard block
 block discarded – undo
456 453
 		// supress unknow widget 'projectmanager-*', if projectmanager is not installed or old
457 454
 		if (!@file_exists(EGW_INCLUDE_ROOT.'/projectmanager/inc/class.projectmanager_widget.inc.php'))
458 455
 		{
459
-			$etpl->set_cell_attribute('pm_id','disabled',true);
460
-			$etpl->set_cell_attribute('pl_id','disabled',true);
456
+			$etpl->set_cell_attribute('pm_id', 'disabled', true);
457
+			$etpl->set_cell_attribute('pl_id', 'disabled', true);
461 458
 		}
462 459
 
463
-		if($this->ts_viewtype == 'short')
460
+		if ($this->ts_viewtype == 'short')
464 461
 		{
465 462
 			$content['ts_viewtype'] = $readonlys['tabs']['notes'] = true;
466 463
 			$content['ts_description_short'] = $content['ts_description'];
467
-			if(!$content['pm_id'] && $this->pm_integration != 'full' && $content['ts_project'])
464
+			if (!$content['pm_id'] && $this->pm_integration != 'full' && $content['ts_project'])
468 465
 			{
469
-				$etpl->setElementAttribute('pm_id','blur',$content['ts_project']);
466
+				$etpl->setElementAttribute('pm_id', 'blur', $content['ts_project']);
470 467
 			}
471 468
 		}
472
-		if (!$this->customfields) $readonlys['tabs']['customfields'] = true;	// suppress tab if there are not customfields
473
-		if (!$this->data['ts_id']) $readonlys['tabs']['history']    = true;   //suppress history for the first loading without ID
469
+		if (!$this->customfields) $readonlys['tabs']['customfields'] = true; // suppress tab if there are not customfields
470
+		if (!$this->data['ts_id']) $readonlys['tabs']['history'] = true; //suppress history for the first loading without ID
474 471
 
475
-		return $etpl->exec(TIMESHEET_APP.'.timesheet_ui.edit',$content,$sel_options,$readonlys,$preserv,2);
472
+		return $etpl->exec(TIMESHEET_APP.'.timesheet_ui.edit', $content, $sel_options, $readonlys, $preserv, 2);
476 473
 	}
477 474
 
478 475
 	/**
@@ -485,7 +482,7 @@  discard block
 block discarded – undo
485 482
 	{
486 483
 		if (!$datetime) return 0;
487 484
 
488
-		return $datetime - mktime(0,0,0,date('m',$datetime),date('d',$datetime),date('Y',$datetime));
485
+		return $datetime - mktime(0, 0, 0, date('m', $datetime), date('d', $datetime), date('Y', $datetime));
489 486
 	}
490 487
 
491 488
 	/**
@@ -499,23 +496,23 @@  discard block
 block discarded – undo
499 496
 	 * @param boolean $id_only if true only return (via $rows) an array of contact-ids, dont save state to session
500 497
 	 * @return int total number of contacts matching the selection
501 498
 	 */
502
-	function get_rows(&$query_in,&$rows,&$readonlys,$id_only=false)
499
+	function get_rows(&$query_in, &$rows, &$readonlys, $id_only = false)
503 500
 	{
504 501
 		$this->show_sums = false;
505 502
 		$end_date = false;
506 503
 
507 504
 		// Date filter
508
-		if($query_in['filter'] === 'custom')
505
+		if ($query_in['filter'] === 'custom')
509 506
 		{
510 507
 			$end_date = $query_in['enddate'] ? $query_in['enddate'] : false;
511 508
 			$query_in['startdate'] = $query_in['startdate'] ? $query_in['startdate'] : 1;
512 509
 		}
513
-		$date_filter = $this->date_filter($query_in['filter'],$query_in['startdate'],$end_date);
510
+		$date_filter = $this->date_filter($query_in['filter'], $query_in['startdate'], $end_date);
514 511
 
515 512
 		if ($query_in['startdate'])
516 513
 		{
517
-			$start = explode('-',date('Y-m-d',$query_in['startdate']+12*60*60));
518
-			$end   = explode('-',date('Y-m-d',$end_date ? $end_date : $query_in['startdate']+7.5*24*60*60));
514
+			$start = explode('-', date('Y-m-d', $query_in['startdate'] + 12 * 60 * 60));
515
+			$end   = explode('-', date('Y-m-d', $end_date ? $end_date : $query_in['startdate'] + 7.5 * 24 * 60 * 60));
519 516
 
520 517
 			// show year-sums, if we are year-aligned (show full years)?
521 518
 			if ((int)$start[2] == 1 && (int)$start[1] == 1 && (int)$end[2] == 31 && (int)$end[1] == 12)
@@ -523,28 +520,28 @@  discard block
 block discarded – undo
523 520
 				$this->show_sums[] = 'year';
524 521
 			}
525 522
 			// show month-sums, if we are month-aligned (show full monthes)?
526
-			if ((int)$start[2] == 1 && (int)$end[2] == (int)date('d',mktime(12,0,0,$end[1]+1,0,$end[0])))
523
+			if ((int)$start[2] == 1 && (int)$end[2] == (int)date('d', mktime(12, 0, 0, $end[1] + 1, 0, $end[0])))
527 524
 			{
528 525
 				$this->show_sums[] = 'month';
529 526
 			}
530 527
 			// show week-sums, if we are week-aligned (show full weeks)?
531 528
 			$week_start_day = $GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'];
532 529
 			if (!$week_start_day) $week_start_day = 'Sunday';
533
-			switch($week_start_day)
530
+			switch ($week_start_day)
534 531
 			{
535 532
 				case 'Sunday': $week_end_day = 'Saturday'; break;
536 533
 				case 'Monday': $week_end_day = 'Sunday'; break;
537 534
 				case 'Saturday': $week_end_day = 'Friday'; break;
538 535
 			}
539
-			$filter_start_day = date('l',$query_in['startdate']+12*60*60);
540
-			$filter_end_day   = $end_date ? date('l',$end_date+12*60*60) : false;
536
+			$filter_start_day = date('l', $query_in['startdate'] + 12 * 60 * 60);
537
+			$filter_end_day   = $end_date ? date('l', $end_date + 12 * 60 * 60) : false;
541 538
 			//echo "<p align=right>prefs: $week_start_day - $week_end_day, filter: $filter_start_day - $filter_end_day</p>\n";
542 539
 			if ($filter_start_day == $week_start_day && (!$filter_end_day || $filter_end_day == $week_end_day))
543 540
 			{
544 541
 				$this->show_sums[] = 'week';
545 542
 			}
546 543
 			// show day-sums, if range <= 5 weeks
547
-			if (!$end_date || $end_date - $query_in['startdate'] < 36*24*60*60)
544
+			if (!$end_date || $end_date - $query_in['startdate'] < 36 * 24 * 60 * 60)
548 545
 			{
549 546
 				$this->show_sums[] = 'day';
550 547
 			}
@@ -555,10 +552,10 @@  discard block
 block discarded – undo
555 552
 		// Refresh actions (undelete needs this)
556 553
 		$query_in['actions'] = $this->get_actions($query_in);
557 554
 
558
-		$query = $query_in;	// keep the original query
555
+		$query = $query_in; // keep the original query
559 556
 		$query['enddate'] = $end_date;
560 557
 
561
-		if($this->ts_viewtype == 'short') $query_in['options-selectcols'] = array('ts_quantity'=>false,'ts_unitprice'=>false,'ts_total'=>false);
558
+		if ($this->ts_viewtype == 'short') $query_in['options-selectcols'] = array('ts_quantity'=>false, 'ts_unitprice'=>false, 'ts_total'=>false);
562 559
 		if ($query['no_status']) $query_in['options-selectcols']['ts_status'] = false;
563 560
 
564 561
 		//_debug_array($query['col_filter']);
@@ -585,18 +582,18 @@  discard block
 block discarded – undo
585 582
 		// handle linked filter (show only entries linked to a certain other entry)
586 583
 		if ($query['col_filter']['linked'])
587 584
 		{
588
-			if(!is_array($query['col_filter']['linked']))
585
+			if (!is_array($query['col_filter']['linked']))
589 586
 			{
590
-				list($app,$id) = explode(':',$query['col_filter']['linked']);
587
+				list($app, $id) = explode(':', $query['col_filter']['linked']);
591 588
 			}
592 589
 			else
593 590
 			{
594 591
 				$app = $query['col_filter']['linked']['app'];
595 592
 				$id = $query['col_filter']['linked']['id'];
596 593
 			}
597
-			if (!($links = Link::get_links($app,$id,'timesheet')))
594
+			if (!($links = Link::get_links($app, $id, 'timesheet')))
598 595
 			{
599
-				$rows = array();	// no infologs linked to project --> no rows to return
596
+				$rows = array(); // no infologs linked to project --> no rows to return
600 597
 				return 0;
601 598
 			}
602 599
 			if (!$query['col_filter']['ts_id'])
@@ -604,9 +601,9 @@  discard block
 block discarded – undo
604 601
 				$query['col_filter']['ts_id'] = array_values(array_unique($links));
605 602
 			}
606 603
 			// allow to combine with other filters using ts_id --> intersect ids
607
-			elseif (!($query['col_filter']['ts_id'] = array_intersect((array)$query['col_filter']['ts_id'],array_values(array_unique($links)))))
604
+			elseif (!($query['col_filter']['ts_id'] = array_intersect((array)$query['col_filter']['ts_id'], array_values(array_unique($links)))))
608 605
 			{
609
-				$rows = array();	// no infologs linked to project --> no rows to return
606
+				$rows = array(); // no infologs linked to project --> no rows to return
610 607
 				return 0;
611 608
 			}
612 609
 		}
@@ -630,13 +627,13 @@  discard block
 block discarded – undo
630 627
 			{
631 628
 				if (isset($this->status_labels_substatus['2level'][$status_id]))
632 629
 				{
633
-					$query['col_filter']['ts_status'] = array_merge($query['col_filter']['ts_status'],$this->status_labels_substatus[$status_id]);
630
+					$query['col_filter']['ts_status'] = array_merge($query['col_filter']['ts_status'], $this->status_labels_substatus[$status_id]);
634 631
 				}
635 632
 			}
636 633
 		}
637 634
 		if ((int)$query['filter2'] != (int)$GLOBALS['egw_info']['user']['preferences'][TIMESHEET_APP]['show_details'])
638 635
 		{
639
-			$GLOBALS['egw']->preferences->add(TIMESHEET_APP,'show_details',(int)$query['filter2']);
636
+			$GLOBALS['egw']->preferences->add(TIMESHEET_APP, 'show_details', (int)$query['filter2']);
640 637
 			$GLOBALS['egw']->preferences->save_repository(true);
641 638
 		}
642 639
 		// category filter: cat_id or ''=All cats or 0=No cat
@@ -659,7 +656,7 @@  discard block
 block discarded – undo
659 656
 			$GLOBALS['egw_info']['flags']['app_header'] .= ': '.Api\Accounts::username($query['col_filter']['ts_owner']);
660 657
 			#if ($GLOBALS['egw']->accounts->get_type($query['col_filter']['ts_owner']) == 'g') $GLOBALS['egw_info']['flags']['app_header'] .= ' '. lang("and its members");
661 658
 			#_debug_array($GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'],true));
662
-			if ($query['col_filter']['ts_owner']<0) $query['col_filter']['ts_owner'] = array_merge(array($query['col_filter']['ts_owner']),$GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'],true));
659
+			if ($query['col_filter']['ts_owner'] < 0) $query['col_filter']['ts_owner'] = array_merge(array($query['col_filter']['ts_owner']), $GLOBALS['egw']->accounts->members($query['col_filter']['ts_owner'], true));
663 660
 		}
664 661
 		else
665 662
 		{
@@ -672,60 +669,60 @@  discard block
 block discarded – undo
672 669
 			// generate a meaningful app-header / report title
673 670
 			if ($this->show_sums['month'])
674 671
 			{
675
-				if ((int)$start[1] == 1 && (int) $end[1] == 12)		// whole year(s)
672
+				if ((int)$start[1] == 1 && (int)$end[1] == 12)		// whole year(s)
676 673
 				{
677
-					$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . $start[0] . ($start[0] != $end[0] ? ' - '.$end[0] : '');
674
+					$GLOBALS['egw_info']['flags']['app_header'] .= ': '.$start[0].($start[0] != $end[0] ? ' - '.$end[0] : '');
678 675
 				}
679 676
 				else
680 677
 				{
681
-					$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . lang(date('F',$query['startdate']+12*60*60)) . ' ' . $start[0];
678
+					$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang(date('F', $query['startdate'] + 12 * 60 * 60)).' '.$start[0];
682 679
 					if ($start[0] != $end[0] || $start[1] != $end[1])
683 680
 					{
684
-						$GLOBALS['egw_info']['flags']['app_header'] .= ' - ' . lang(date('F',$query['enddate']+12*60*60)) . ' ' . $end[0];
681
+						$GLOBALS['egw_info']['flags']['app_header'] .= ' - '.lang(date('F', $query['enddate'] + 12 * 60 * 60)).' '.$end[0];
685 682
 					}
686 683
 				}
687 684
 			}
688 685
 			elseif ($this->show_sums['week'])
689 686
 			{
690
-				$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . lang('week') . ' ' . date('W',$query['startdate']+36*60*60) . '/' . $start[0];
691
-				if ($query['enddate'] && $query['enddate'] - $query['startdate'] > 10*24*60*60)
687
+				$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang('week').' '.date('W', $query['startdate'] + 36 * 60 * 60).'/'.$start[0];
688
+				if ($query['enddate'] && $query['enddate'] - $query['startdate'] > 10 * 24 * 60 * 60)
692 689
 				{
693
-					$GLOBALS['egw_info']['flags']['app_header'] .= ' - ' . date('W',$query['enddate']-36*60*60) . '/' . $end[0];
690
+					$GLOBALS['egw_info']['flags']['app_header'] .= ' - '.date('W', $query['enddate'] - 36 * 60 * 60).'/'.$end[0];
694 691
 				}
695 692
 			}
696 693
 			elseif ($query['startdate'])
697 694
 			{
698 695
 				$df = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
699
-				$GLOBALS['egw_info']['flags']['app_header'] .= ': ' . Api\DateTime::to($query['startdate']+12*60*60, $df);
696
+				$GLOBALS['egw_info']['flags']['app_header'] .= ': '.Api\DateTime::to($query['startdate'] + 12 * 60 * 60, $df);
700 697
 				if ($start != $end)
701 698
 				{
702
-					$GLOBALS['egw_info']['flags']['app_header'] .= ' - '.Api\DateTime::to($query['enddate'] ? $query['enddate']+12*60*60:'now', $df);
699
+					$GLOBALS['egw_info']['flags']['app_header'] .= ' - '.Api\DateTime::to($query['enddate'] ? $query['enddate'] + 12 * 60 * 60 : 'now', $df);
703 700
 				}
704 701
 			}
705 702
 		}
706 703
 		// Update start / end dates for custom
707
-		if($query_in['filter'] != 'custom' && Api\Json\Response::isJSONResponse())
704
+		if ($query_in['filter'] != 'custom' && Api\Json\Response::isJSONResponse())
708 705
 		{
709 706
 			Api\Json\Response::get()->call(
710 707
 				'app.timesheet.update_timespan',
711
-				Api\DateTime::to($query['startdate'] ? $query['startdate'] : 'now' , Api\DateTime::ET2),
708
+				Api\DateTime::to($query['startdate'] ? $query['startdate'] : 'now', Api\DateTime::ET2),
712 709
 				$query['filter'] ? Api\DateTime::to($query['enddate'], Api\DateTime::ET2) : null
713 710
 			);
714 711
 		}
715
-		$total = parent::get_rows($query,$rows,$readonlys);
712
+		$total = parent::get_rows($query, $rows, $readonlys);
716 713
 
717 714
 		$ids = array();
718
-		foreach($rows as &$row)
715
+		foreach ($rows as &$row)
719 716
 		{
720 717
 			if ($row['ts_id'] > 0) $ids[] = $row['ts_id'];
721 718
 		}
722 719
 		if ($id_only)
723 720
 		{
724 721
 			$rows = $ids;
725
-			return $this->total;	// no need to set other fields or $readonlys
722
+			return $this->total; // no need to set other fields or $readonlys
726 723
 		}
727 724
 		$links = array();
728
-		$links3 = Link::get_links_multiple(TIMESHEET_APP,$ids,true,'projectmanager');	// only check for pm links!
725
+		$links3 = Link::get_links_multiple(TIMESHEET_APP, $ids, true, 'projectmanager'); // only check for pm links!
729 726
 		//as the full array is expected, we must supply the missing but needed (since expected further down) information
730 727
 		if (is_array($links3))
731 728
 		{
@@ -745,14 +742,14 @@  discard block
 block discarded – undo
745 742
 
746 743
 		$readonlys = array();
747 744
 		$have_cats = false;
748
-		foreach($rows as &$row)
745
+		foreach ($rows as &$row)
749 746
 		{
750 747
 			if ($row['cat_id']) $have_cats = true;
751 748
 
752 749
 			$row['class'] = 'row';
753 750
 			if ($row['ts_id'] <= 0)	// sums
754 751
 			{
755
-				if ($query['sort'] == 'ASC') $row['ts_start'] -= 7200;	// fix for DSL change
752
+				if ($query['sort'] == 'ASC') $row['ts_start'] -= 7200; // fix for DSL change
756 753
 
757 754
 				// Remove fake modified date, it breaks nextmatch checks
758 755
 				unset($row['ts_modified']);
@@ -760,22 +757,22 @@  discard block
 block discarded – undo
760 757
 				// Set flag to avoid actions on these rows
761 758
 				$row['no_actions'] = true;
762 759
 
763
-				switch($row['ts_id'])
760
+				switch ($row['ts_id'])
764 761
 				{
765 762
 					case 0:	// day-sum
766
-						$row['ts_title'] = lang('Sum %1:',lang(date('l',$row['ts_start'])).' '.Api\DateTime::to($row['ts_start'], $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']));
763
+						$row['ts_title'] = lang('Sum %1:', lang(date('l', $row['ts_start'])).' '.Api\DateTime::to($row['ts_start'], $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']));
767 764
 						$row['ts_id'] = 'sum-day-'.$row['ts_start'];
768 765
 						break;
769 766
 					case -1:	// week-sum
770
-						$row['ts_title'] = lang('Sum %1:',lang('week').' '.substr($row['ts_week'],4).'/'.substr($row['ts_week'],0,4));
767
+						$row['ts_title'] = lang('Sum %1:', lang('week').' '.substr($row['ts_week'], 4).'/'.substr($row['ts_week'], 0, 4));
771 768
 						$row['ts_id'] = 'sum-week-'.$row['ts_week'];
772 769
 						break;
773 770
 					case -2:	// month-sum
774
-						$row['ts_title'] = lang('Sum %1:',lang(date('F',$row['ts_start'])).' '.substr($row['ts_month'],0,4));
771
+						$row['ts_title'] = lang('Sum %1:', lang(date('F', $row['ts_start'])).' '.substr($row['ts_month'], 0, 4));
775 772
 						$row['ts_id'] = 'sum-month-'.$row['ts_month'];
776 773
 						break;
777 774
 					case -3:	// year-sum
778
-						$row['ts_title'] = lang('Sum %1:',$row['ts_year']);
775
+						$row['ts_title'] = lang('Sum %1:', $row['ts_year']);
779 776
 						$row['ts_id'] = 'sum-year-'.$row['ts_year'];
780 777
 						break;
781 778
 				}
@@ -785,11 +782,11 @@  discard block
 block discarded – undo
785 782
 				$row['titleClass'] = 'timesheet_titleSum';
786 783
 				continue;
787 784
 			}
788
-			if($row['ts_quantity'])
785
+			if ($row['ts_quantity'])
789 786
 			{
790 787
 				$row['ts_quantity'] = round($row['ts_quantity'], 2);
791 788
 			}
792
-			if (!$this->check_acl(Acl::EDIT,$row))
789
+			if (!$this->check_acl(Acl::EDIT, $row))
793 790
 			{
794 791
 				$row['class'] .= ' rowNoEdit ';
795 792
 			}
@@ -797,21 +794,21 @@  discard block
 block discarded – undo
797 794
 			{
798 795
 				$row['class'] .= ' rowNoEdit ';
799 796
 			}
800
-			if (!$this->check_acl(Acl::DELETE,$row))
797
+			if (!$this->check_acl(Acl::DELETE, $row))
801 798
 			{
802 799
 				$row['class'] .= ' rowNoDelete ';
803 800
 			}
804
-			if($row['ts_status'] != self::DELETED_STATUS)
801
+			if ($row['ts_status'] != self::DELETED_STATUS)
805 802
 			{
806 803
 				$row['class'] .= ' rowNoUndelete ';
807 804
 			}
808 805
 			if ($query['col_filter']['ts_project'])
809 806
 			{
810
-				unset($row['ts_project']);	// dont need or want to show it
807
+				unset($row['ts_project']); // dont need or want to show it
811 808
 			}
812 809
 			elseif ($links[$row['ts_id']])
813 810
 			{
814
-				foreach($links[$row['ts_id']] as $link)
811
+				foreach ($links[$row['ts_id']] as $link)
815 812
 				{
816 813
 					if ($link['app'] == 'projectmanager')
817 814
 					{
@@ -822,13 +819,13 @@  discard block
 block discarded – undo
822 819
 				}
823 820
 			}
824 821
 
825
-			if(!$row['titleClass']) $row['titleClass'] = 'timesheet_titleDetails';
822
+			if (!$row['titleClass']) $row['titleClass'] = 'timesheet_titleDetails';
826 823
 
827 824
 		}
828 825
 		$rows['no_cat_id'] = (!$have_cats || $query['cat_id']);
829 826
 		if ($query['col_filter']['ts_owner']) $rows['ownerClass'] = 'noPrint';
830 827
 		$rows['no_owner_col'] = $query['no_owner_col'];
831
-		if(is_string($query['selectcols']))
828
+		if (is_string($query['selectcols']))
832 829
 		{
833 830
 			$query['selectcols'] = explode(',', $query['selectcols']);
834 831
 		}
@@ -840,17 +837,17 @@  discard block
 block discarded – undo
840 837
 		$rows += $this->summary;
841 838
 
842 839
 		$rows['pm_integration'] = $this->pm_integration;
843
-		$rows['ts_viewtype'] =  $rows['no_ts_quantity'] =  $rows['no_ts_unitprice'] =  $rows['no_ts_total'] = $this->ts_viewtype == 'short';
840
+		$rows['ts_viewtype'] = $rows['no_ts_quantity'] = $rows['no_ts_unitprice'] = $rows['no_ts_total'] = $this->ts_viewtype == 'short';
844 841
 		if (!$rows['ts_viewtype'])
845 842
 		{
846 843
 			#_debug_array($query['selectcols']);
847
-			if(!is_array($query['selectcols'])){
848
-				$query['selectcols'] = explode(',',$query['selectcols']);
844
+			if (!is_array($query['selectcols'])) {
845
+				$query['selectcols'] = explode(',', $query['selectcols']);
849 846
 			}
850 847
 			#ts_quantity,ts_unitprice,ts_total
851
-			if ($query['selectcols'] && in_array('ts_quantity_quantity',$query['selectcols'])===false) $rows['no_ts_quantity'] = 1;
852
-			if ($query['selectcols'] && in_array('ts_unitprice', $query['selectcols'])===false) $rows['no_ts_unitprice'] = 1;
853
-			if ($query['selectcols'] && in_array('ts_total_price',$query['selectcols'])===false) $rows['no_ts_total'] = 1;
848
+			if ($query['selectcols'] && in_array('ts_quantity_quantity', $query['selectcols']) === false) $rows['no_ts_quantity'] = 1;
849
+			if ($query['selectcols'] && in_array('ts_unitprice', $query['selectcols']) === false) $rows['no_ts_unitprice'] = 1;
850
+			if ($query['selectcols'] && in_array('ts_total_price', $query['selectcols']) === false) $rows['no_ts_total'] = 1;
854 851
 		}
855 852
 		$rows['no_ts_status'] = in_array('ts_status', $query['selectcols']) === false && !$this->config_data['history'] ||
856 853
 			$query['no_status'];
@@ -869,7 +866,7 @@  discard block
 block discarded – undo
869 866
 	 * @param array $content
870 867
 	 * @param string $msg
871 868
 	 */
872
-	function index($content = null,$msg='')
869
+	function index($content = null, $msg = '')
873 870
 	{
874 871
 		$etpl = new Etemplate('timesheet.index');
875 872
 
@@ -906,14 +903,14 @@  discard block
 block discarded – undo
906 903
 			else
907 904
 			{
908 905
 				$success = $failed = $action_msg = null;
909
-				if ($this->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'],
910
-					$success,$failed,$action_msg,'index',$msg))
906
+				if ($this->action($content['nm']['action'], $content['nm']['selected'], $content['nm']['select_all'],
907
+					$success, $failed, $action_msg, 'index', $msg))
911 908
 				{
912
-					$msg .= lang('%1 timesheets(s) %2',$success,$action_msg);
909
+					$msg .= lang('%1 timesheets(s) %2', $success, $action_msg);
913 910
 				}
914
-				elseif(empty($msg))
911
+				elseif (empty($msg))
915 912
 				{
916
-					$msg .= lang('%1 timesheets(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
913
+					$msg .= lang('%1 timesheets(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed);
917 914
 				}
918 915
 			}
919 916
 		}
@@ -925,7 +922,7 @@  discard block
 block discarded – undo
925 922
 		if (!is_array($content['nm']))
926 923
 		{
927 924
 			$date_filters = array('All');
928
-			foreach(array_keys($this->date_filters) as $name)
925
+			foreach (array_keys($this->date_filters) as $name)
929 926
 			{
930 927
 				$date_filters[$name] = $name;
931 928
 			}
@@ -934,26 +931,26 @@  discard block
 block discarded – undo
934 931
 			$content['nm'] = array(
935 932
 				'get_rows'       =>	TIMESHEET_APP.'.timesheet_ui.get_rows',
936 933
 				'options-filter' => $date_filters,
937
-				'options-filter2' => array('No details','Details'),
938
-				'order'          =>	'ts_start',// IO name of the column to sort after (optional for the sortheaders)
939
-				'sort'           =>	'DESC',// IO direction of the sort: 'ASC' or 'DESC'
934
+				'options-filter2' => array('No details', 'Details'),
935
+				'order'          =>	'ts_start', // IO name of the column to sort after (optional for the sortheaders)
936
+				'sort'           =>	'DESC', // IO direction of the sort: 'ASC' or 'DESC'
940 937
 				'filter_onchange' => "app.timesheet.filter_change();",
941 938
 				'filter2_onchange' => "app.timesheet.filter2_change();",
942 939
 				'filter2'        => (int)$GLOBALS['egw_info']['user']['preferences'][TIMESHEET_APP]['show_details'],
943 940
 				'row_id'         => 'ts_id',
944 941
 				'row_modified'   => 'ts_modified',
945 942
 				//'actions'        => $this->get_actions(),
946
-				'default_cols'   => '!legacy_actions',	// switch legacy actions column and row off by default
943
+				'default_cols'   => '!legacy_actions', // switch legacy actions column and row off by default
947 944
 				'pm_integration' => $this->pm_integration,
948 945
 				'placeholder_actions' => array('add')
949 946
 			);
950 947
 		}
951 948
 
952
-		if($_GET['search'])
949
+		if ($_GET['search'])
953 950
 		{
954 951
 			$content['nm']['search'] = $_GET['search'];
955 952
 		}
956
-		if($_GET['link_app'] && Link::get_registry($_GET['link_app'], 'query') && $_GET['link_id'])
953
+		if ($_GET['link_app'] && Link::get_registry($_GET['link_app'], 'query') && $_GET['link_id'])
957 954
 		{
958 955
 			$content['nm']['col_filter']['linked'] = array(
959 956
 				'app' => $_GET['link_app'],
@@ -967,25 +964,25 @@  discard block
 block discarded – undo
967 964
 			'ts_owner'   => $read_grants,
968 965
 			'pm_id'      => array(lang('No project')),
969 966
 			'cat_id'     => array(array('value' => '', 'label' => lang('all categories')), array('value' => 0, 'label'=>lang('None'))),
970
-			'ts_status'  => $this->status_labels+array(lang('No status')),
967
+			'ts_status'  => $this->status_labels + array(lang('No status')),
971 968
 		);
972
-		if($this->config_data['history'])
969
+		if ($this->config_data['history'])
973 970
 		{
974 971
 			$sel_options['ts_status'][self::DELETED_STATUS] = 'Deleted';
975 972
 		}
976
-		$content['nm']['no_status'] = count($sel_options['ts_status']) <= 1;	// 1 because of 'No status'
977
-		$content['nm']['favorites'] = true;		//Enable favorite
973
+		$content['nm']['no_status'] = count($sel_options['ts_status']) <= 1; // 1 because of 'No status'
974
+		$content['nm']['favorites'] = true; //Enable favorite
978 975
 
979 976
 		if ($this->pm_integration != 'full')
980 977
 		{
981
-			$projects =& $this->query_list('ts_project');
978
+			$projects = & $this->query_list('ts_project');
982 979
 			if (!is_array($projects)) $projects = array();
983 980
 			$sel_options['ts_project'] = $projects + array(lang('No project'));
984 981
 		}
985 982
 
986 983
 		// dont show [Export] button if app is not availible to the user or we are on php4
987
-		$readonlys['export'] = !$GLOBALS['egw_info']['user']['apps']['importexport'] || (int) phpversion() < 5;
988
-		return $etpl->exec(TIMESHEET_APP.'.timesheet_ui.index',$content,$sel_options,$readonlys);
984
+		$readonlys['export'] = !$GLOBALS['egw_info']['user']['apps']['importexport'] || (int)phpversion() < 5;
985
+		return $etpl->exec(TIMESHEET_APP.'.timesheet_ui.index', $content, $sel_options, $readonlys);
989 986
 	}
990 987
 
991 988
 	/**
@@ -1004,9 +1001,9 @@  discard block
 block discarded – undo
1004 1001
 				'allowOnMultiple' => false,
1005 1002
 				'url' => 'menuaction=timesheet.timesheet_ui.edit&ts_id=$id',
1006 1003
 				'popup' => Link::get_registry('timesheet', 'add_popup'),
1007
-				'group' => $group=1,
1004
+				'group' => $group = 1,
1008 1005
 				'disableClass' => 'th',
1009
-				'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.timesheet.viewEntry':'',
1006
+				'onExecute' => Api\Header\UserAgent::mobile() ? 'javaScript:app.timesheet.viewEntry' : '',
1010 1007
 				'mobileViewTemplate' => 'view?'.filemtime(Api\Etemplate\Widget\Template::rel2path('/timesheet/templates/mobile/view.xet'))
1011 1008
 			),
1012 1009
 /*
@@ -1046,7 +1043,7 @@  discard block
 block discarded – undo
1046 1043
 				)
1047 1044
 			),
1048 1045
 			'cat' => Etemplate\Widget\Nextmatch::category_action(
1049
-				'timesheet',++$group,'Change category','cat_'
1046
+				'timesheet', ++$group, 'Change category', 'cat_'
1050 1047
 			),
1051 1048
 			'status' => array(
1052 1049
 				'icon' => 'apply',
@@ -1098,7 +1095,7 @@  discard block
 block discarded – undo
1098 1095
 			);
1099 1096
 		}
1100 1097
 		// enable additonal edit check for following actions, if they are generally available
1101
-		foreach(array('cat','status') as $action)
1098
+		foreach (array('cat', 'status') as $action)
1102 1099
 		{
1103 1100
 			if ($actions[$action]['enabled'])
1104 1101
 			{
@@ -1121,7 +1118,7 @@  discard block
 block discarded – undo
1121 1118
 	 * @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup
1122 1119
 	 * @return boolean true if all actions succeded, false otherwise
1123 1120
 	 */
1124
-	function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg)
1121
+	function action($action, $checked, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg)
1125 1122
 	{
1126 1123
 		$success = $failed = 0;
1127 1124
 		if ($use_all)
@@ -1131,17 +1128,17 @@  discard block
 block discarded – undo
1131 1128
 
1132 1129
 			if ($use_all)
1133 1130
 			{
1134
-				@set_time_limit(0);			// switch off the execution time limit, as it's for big selections to small
1135
-				$query['num_rows'] = -1;	// all
1131
+				@set_time_limit(0); // switch off the execution time limit, as it's for big selections to small
1132
+				$query['num_rows'] = -1; // all
1136 1133
 				$readonlys = null;
1137
-				$this->get_rows($query,$checked,$readonlys,true);	// true = only return the id's
1134
+				$this->get_rows($query, $checked, $readonlys, true); // true = only return the id's
1138 1135
 			}
1139 1136
 		}
1140 1137
 		//error_log(__METHOD__."('$action', ".array2string($checked).', '.array2string($use_all).",,, '$session_name')");
1141 1138
 
1142
-		if (substr($action,0,9) == 'to_status')
1139
+		if (substr($action, 0, 9) == 'to_status')
1143 1140
 		{
1144
-			$to_status = (int)substr($action,10);
1141
+			$to_status = (int)substr($action, 10);
1145 1142
 			$action = 'to_status';
1146 1143
 		}
1147 1144
 		else
@@ -1150,11 +1147,11 @@  discard block
 block discarded – undo
1150 1147
 			list($action, $settings) = explode('_', $action, 2);
1151 1148
 		}
1152 1149
 
1153
-		switch($action)
1150
+		switch ($action)
1154 1151
 		{
1155 1152
 			case 'delete':
1156 1153
 				$action_msg = lang('deleted');
1157
-				foreach((array)$checked as $n => $id)
1154
+				foreach ((array)$checked as $n => $id)
1158 1155
 				{
1159 1156
 					if ($this->delete($id))
1160 1157
 					{
@@ -1167,10 +1164,10 @@  discard block
 block discarded – undo
1167 1164
 				}
1168 1165
 				break;
1169 1166
 			case 'undelete':
1170
-				$action_msg =lang('recovered');
1171
-				foreach((array)$checked as $n => $id)
1167
+				$action_msg = lang('recovered');
1168
+				foreach ((array)$checked as $n => $id)
1172 1169
 				{
1173
-					if ($this->set_status($id,''))
1170
+					if ($this->set_status($id, ''))
1174 1171
 					{
1175 1172
 						$success++;
1176 1173
 					}
@@ -1181,10 +1178,10 @@  discard block
 block discarded – undo
1181 1178
 				}
1182 1179
 				break;
1183 1180
 			case 'to_status':
1184
-				$action_msg =lang('changed status');
1185
-				foreach((array)$checked as $n => $id)
1181
+				$action_msg = lang('changed status');
1182
+				foreach ((array)$checked as $n => $id)
1186 1183
 				{
1187
-					if ($this->set_status($id,$to_status))
1184
+					if ($this->set_status($id, $to_status))
1188 1185
 					{
1189 1186
 						$success++;
1190 1187
 					}
@@ -1197,7 +1194,7 @@  discard block
 block discarded – undo
1197 1194
 			case 'cat':
1198 1195
 				$cat_name = Api\Categories::id2name($settings);
1199 1196
 				$action_msg = lang('changed category to %1', $cat_name);
1200
-				foreach((array)$checked as $n => $id) {
1197
+				foreach ((array)$checked as $n => $id) {
1201 1198
 					if (($entry = $this->read($id)) &&
1202 1199
 						($entry['cat_id'] = $settings) &&
1203 1200
 						$this->save($entry) == 0)
@@ -1228,7 +1225,7 @@  discard block
 block discarded – undo
1228 1225
 	 * @param conetnt
1229 1226
 	 * @param view
1230 1227
 	 */
1231
-	function editstatus($content = null,$msg='')
1228
+	function editstatus($content = null, $msg = '')
1232 1229
 	{
1233 1230
 		// this function requires admin rights
1234 1231
 		$GLOBALS['egw_info']['flags']['admin_only'] = true;
@@ -1239,13 +1236,13 @@  discard block
 block discarded – undo
1239 1236
 			list($button) = @each($content['button']);
1240 1237
 			unset ($content['button']);
1241 1238
 
1242
-			switch($button)
1239
+			switch ($button)
1243 1240
 			{
1244 1241
 				case 'delete':
1245 1242
 					break;
1246 1243
 				case 'apply':
1247 1244
 				case 'save':
1248
-					foreach($content['statis'] as &$cat)
1245
+					foreach ($content['statis'] as &$cat)
1249 1246
 					{
1250 1247
 						$id = $cat['id'];
1251 1248
 						if (($cat ['name'] !== $this->status_labels_config[$id]) && ($cat ['name'] !== '') || ($cat ['parent'] !== $this->status_labels_config[$id]['parent']) && ($cat ['parent'] !== ''))
@@ -1259,7 +1256,7 @@  discard block
 block discarded – undo
1259 1256
 					}
1260 1257
 					if ($need_update)
1261 1258
 					{
1262
-						Api\Config::save_value('status_labels',$this->status_labels_config,TIMESHEET_APP);
1259
+						Api\Config::save_value('status_labels', $this->status_labels_config, TIMESHEET_APP);
1263 1260
 						$this->config_data = Api\Config::read(TIMESHEET_APP);
1264 1261
 						$this->load_statuses();
1265 1262
 						$msg .= lang('Status updated.');
@@ -1276,7 +1273,7 @@  discard block
 block discarded – undo
1276 1273
 			if (isset($this->status_labels_config[$id]))
1277 1274
 			{
1278 1275
 				unset($this->status_labels_config[$id]);
1279
-				Api\Config::save_value('status_labels',$this->status_labels_config,TIMESHEET_APP);
1276
+				Api\Config::save_value('status_labels', $this->status_labels_config, TIMESHEET_APP);
1280 1277
 				unset($this->status_labels[$id]);
1281 1278
 				$msg .= lang('Status deleted.');
1282 1279
 			}
@@ -1285,12 +1282,12 @@  discard block
 block discarded – undo
1285 1282
 		$i = 1;
1286 1283
 		$max_id = 0;
1287 1284
 		unset($content['statis']);
1288
-		foreach($this->status_labels_config as $id => $label)
1285
+		foreach ($this->status_labels_config as $id => $label)
1289 1286
 		{
1290
-			$content['statis'][$i]['name']= $label['name'];
1291
-			$content['statis'][$i]['id']= $id;
1292
-			$content['statis'][$i]['parent']= $label['parent'];
1293
-			$content['statis'][$i]['admin']= $label['admin'];
1287
+			$content['statis'][$i]['name'] = $label['name'];
1288
+			$content['statis'][$i]['id'] = $id;
1289
+			$content['statis'][$i]['parent'] = $label['parent'];
1290
+			$content['statis'][$i]['admin'] = $label['admin'];
1294 1291
 			$i++;
1295 1292
 			$max_id = max($id, $max_id);
1296 1293
 		}
@@ -1302,7 +1299,7 @@  discard block
 block discarded – undo
1302 1299
 		$preserv = $content;
1303 1300
 		$sel_options['parent'] = $this->status_labels;
1304 1301
 		$etpl = new Etemplate('timesheet.editstatus');
1305
-		$etpl->exec('timesheet.timesheet_ui.editstatus',$content,$sel_options,array(),$preserv);
1302
+		$etpl->exec('timesheet.timesheet_ui.editstatus', $content, $sel_options, array(), $preserv);
1306 1303
 	}
1307 1304
 
1308 1305
 	/**
@@ -1313,14 +1310,14 @@  discard block
 block discarded – undo
1313 1310
 	protected function find_pm_id($project)
1314 1311
 	{
1315 1312
 		list($pm_number, $pm_title) = explode(': ', $project, 2);
1316
-		if(!$pm_number || !$pm_title)
1313
+		if (!$pm_number || !$pm_title)
1317 1314
 		{
1318 1315
 			return false;
1319 1316
 		}
1320 1317
 
1321 1318
 		$pm = new projectmanager_bo();
1322 1319
 		$pm_ids = $pm->search(array('pm_number' => $pm_number, 'pm_title' => $pm_title));
1323
-		if($pm_ids && count($pm_ids) >= 1)
1320
+		if ($pm_ids && count($pm_ids) >= 1)
1324 1321
 		{
1325 1322
 			return $pm_ids[0]['pm_id'];
1326 1323
 		}
@@ -1336,17 +1333,17 @@  discard block
 block discarded – undo
1336 1333
 		$original_id = $this->data['ts_id'];
1337 1334
 		unset($this->data['ts_id']);
1338 1335
 
1339
-		$this->data['ts_title'] = lang('Copy of:') . ' ' .$this->data['ts_title'];
1336
+		$this->data['ts_title'] = lang('Copy of:').' '.$this->data['ts_title'];
1340 1337
 		unset($this->data['ts_modified']);
1341 1338
 		unset($this->data['ts_modifier']);
1342
-		$this->data['ts_owner'] = !(int)$this->data['ts_owner'] || !$this->check_acl(Acl::ADD,NULL,$this->data['ts_owner']) ? $this->user : $this->data['ts_owner'];
1339
+		$this->data['ts_owner'] = !(int)$this->data['ts_owner'] || !$this->check_acl(Acl::ADD, NULL, $this->data['ts_owner']) ? $this->user : $this->data['ts_owner'];
1343 1340
 
1344 1341
 		// Copy links
1345
-		if(!is_array($this->data['link_to'])) $this->data['link_to'] = array();
1342
+		if (!is_array($this->data['link_to'])) $this->data['link_to'] = array();
1346 1343
 		$this->data['link_to']['to_app'] = 'timesheet';
1347 1344
 		$this->data['link_to']['to_id'] = 0;
1348 1345
 
1349
-		foreach(Link::get_links($this->data['link_to']['to_app'], $original_id) as $link)
1346
+		foreach (Link::get_links($this->data['link_to']['to_app'], $original_id) as $link)
1350 1347
 		{
1351 1348
 			if ($link['app'] != Link::VFS_APPNAME)
1352 1349
 			{
Please login to merge, or discard this patch.
timesheet/inc/class.timesheet_favorite_portlet.inc.php 4 patches
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -96,9 +96,12 @@
 block discarded – undo
96 96
 
97 97
 		// This is just copy+pasted from timesheet_ui line 816, but we don't want
98 98
 		// the etemplate exec to fire again.
99
-		if (is_array($content) && isset($content['nm']['rows']['document']))  // handle insert in default document button like an action
99
+		if (is_array($content) && isset($content['nm']['rows']['document']))
100
+		{
101
+			// handle insert in default document button like an action
100 102
 		{
101 103
 			list($id) = @each($content['nm']['rows']['document']);
104
+		}
102 105
 			$content['nm']['action'] = 'document';
103 106
 			$content['nm']['selected'] = array($id);
104 107
 		}
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
 	 * Construct the portlet
24 24
 	 *
25 25
 	 */
26
-	public function __construct(Array &$context = array(), &$need_reload = false)
26
+	public function __construct(array &$context = array(), &$need_reload = false)
27 27
 	{
28 28
 		$context['appname'] = 'timesheet';
29 29
 
Please login to merge, or discard this patch.
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -92,8 +92,6 @@
 block discarded – undo
92 92
 	 * Here we need to handle any incoming data.  Setup is done in the constructor,
93 93
 	 * output is handled by parent.
94 94
 	 *
95
-	 * @param type $id
96
-	 * @param Etemplate $etemplate
97 95
 	 */
98 96
 	public static function process($content = array())
99 97
 	{
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 		$context['appname'] = 'timesheet';
29 29
 
30 30
 		// Let parent handle the basic stuff
31
-		parent::__construct($context,$need_reload);
31
+		parent::__construct($context, $need_reload);
32 32
 
33 33
 		$this->context['template'] = 'timesheet.index.rows';
34 34
 		$this->nm_settings += array(
@@ -47,19 +47,19 @@  discard block
 block discarded – undo
47 47
 		$ui = new timesheet_ui();
48 48
 
49 49
 		$date_filters = array('All');
50
-		foreach(array_keys($ui->date_filters) as $name)
50
+		foreach (array_keys($ui->date_filters) as $name)
51 51
 		{
52 52
 			$date_filters[$name] = $name;
53 53
 		}
54 54
 		$date_filters['custom'] = 'custom';
55 55
 		$this->context['sel_options']['filter'] = $date_filters;
56
-		$this->context['sel_options']['filter2'] = array('No details','Details');
56
+		$this->context['sel_options']['filter2'] = array('No details', 'Details');
57 57
 		$read_grants = $ui->grant_list(Acl::READ);
58 58
 		$this->context['sel_options'] += array(
59 59
 			'ts_owner'   => $read_grants,
60 60
 			'pm_id'      => array(lang('No project')),
61 61
 			'cat_id'     => array(array('value' => '', 'label' => lang('all')), array('value' => 0, 'label'=>lang('None'))),
62
-			'ts_status'  => $ui->status_labels+array(lang('No status')),
62
+			'ts_status'  => $ui->status_labels + array(lang('No status')),
63 63
 		);
64 64
 		$this->nm_settings['actions'] = $ui->get_actions($this->nm_settings);
65 65
 
@@ -112,29 +112,29 @@  discard block
 block discarded – undo
112 112
 			if (!count($content['nm']['selected']) && !$content['nm']['select_all'])
113 113
 			{
114 114
 				$msg = lang('You need to select some entries first!');
115
-				Api\Json\Response::get()->apply('egw.message',array($msg,'error'));
115
+				Api\Json\Response::get()->apply('egw.message', array($msg, 'error'));
116 116
 			}
117 117
 			else
118 118
 			{
119 119
 				$success = $failed = $action_msg = null;
120
-				if ($ui->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'],
121
-					$success,$failed,$action_msg,'index',$msg))
120
+				if ($ui->action($content['nm']['action'], $content['nm']['selected'], $content['nm']['select_all'],
121
+					$success, $failed, $action_msg, 'index', $msg))
122 122
 				{
123
-					$msg .= lang('%1 timesheets(s) %2',$success,$action_msg);
123
+					$msg .= lang('%1 timesheets(s) %2', $success, $action_msg);
124 124
 
125
-					Api\Json\Response::get()->apply('egw.message',array($msg,'success'));
126
-					foreach($content['nm']['selected'] as &$id)
125
+					Api\Json\Response::get()->apply('egw.message', array($msg, 'success'));
126
+					foreach ($content['nm']['selected'] as &$id)
127 127
 					{
128 128
 						$id = 'timesheet::'.$id;
129 129
 					}
130 130
 					// Directly request an update - this will get timesheet tab too
131
-					Api\Json\Response::get()->apply('egw.dataRefreshUIDs',array($content['nm']['selected']));
131
+					Api\Json\Response::get()->apply('egw.dataRefreshUIDs', array($content['nm']['selected']));
132 132
 				}
133
-				elseif(empty($msg))
133
+				elseif (empty($msg))
134 134
 				{
135
-					$msg .= lang('%1 timesheets(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
135
+					$msg .= lang('%1 timesheets(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed);
136 136
 				}
137
-				Api\Json\Response::get()->apply('egw.message',array($msg,'error'));
137
+				Api\Json\Response::get()->apply('egw.message', array($msg, 'error'));
138 138
 			}
139 139
 		}
140 140
 	}
Please login to merge, or discard this patch.
timesheet/inc/class.timesheet_hooks.inc.php 3 patches
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -156,7 +156,10 @@
 block discarded – undo
156 156
 	static function settings()
157 157
 	{
158 158
 		$settings = array();
159
-		if (is_null(self::$timesheet_bo)) self::$timesheet_bo = new timesheet_bo();
159
+		if (is_null(self::$timesheet_bo))
160
+		{
161
+			self::$timesheet_bo = new timesheet_bo();
162
+		}
160 163
 		if (self::$timesheet_bo->status_labels)
161 164
 		{
162 165
 			$settings['predefined_status'] = array(
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 
19 19
 if (!defined('TIMESHEET_APP'))
20 20
 {
21
-	define('TIMESHEET_APP','timesheet');
21
+	define('TIMESHEET_APP', 'timesheet');
22 22
 }
23 23
 
24 24
 /**
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 */
43 43
 	static function search_link($location)
44 44
 	{
45
-		unset($location);	// not used, but required by function signature
45
+		unset($location); // not used, but required by function signature
46 46
 
47 47
 		return array(
48 48
 			'query' => TIMESHEET_APP.'.timesheet_bo.link_query',
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 			'add_id'     => 'link_id',
66 66
 			'add_popup'  => '630x480',
67 67
 			'file_access'=> TIMESHEET_APP.'.timesheet_bo.file_access',
68
-			'file_access_user' => true,	// file_access supports 4th parameter $user
68
+			'file_access_user' => true, // file_access supports 4th parameter $user
69 69
 			'notify'     => TIMESHEET_APP.'.timesheet_bo.notify',
70 70
 			'merge' => true,
71 71
 		);
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
 	 */
82 82
 	static function cumulate($param)
83 83
 	{
84
-		$links = Link::get_3links(TIMESHEET_APP,'projectmanager',$param['pm_id']);
84
+		$links = Link::get_3links(TIMESHEET_APP, 'projectmanager', $param['pm_id']);
85 85
 
86 86
 		$rows = array();
87
-		foreach($links as $link)
87
+		foreach ($links as $link)
88 88
 		{
89 89
 			$rows[$link['id']] = array(
90 90
 				'pm_id'       => $link['id2'],
@@ -116,39 +116,39 @@  discard block
 block discarded – undo
116 116
 			display_sidebox($appname, lang('Favorites'), Framework\Favorites::list_favorites($appname));
117 117
 
118 118
 			$file = array(
119
-				'Timesheet list' => Egw::link('/index.php',array(
119
+				'Timesheet list' => Egw::link('/index.php', array(
120 120
 					'menuaction' => 'timesheet.timesheet_ui.index',
121 121
 					'ajax' => 'true')),
122 122
 				array(
123
-					'text' => lang('Add %1',lang(Link::get_registry($appname, 'entry'))),
123
+					'text' => lang('Add %1', lang(Link::get_registry($appname, 'entry'))),
124 124
 					'no_lang' => true,
125 125
 					'link' => "javascript:egw.open('','$appname','add')"
126 126
 				),
127 127
 			);
128
-			$file['Placeholders'] = Egw::link('/index.php','menuaction=timesheet.timesheet_merge.show_replacements');
129
-			display_sidebox($appname,$GLOBALS['egw_info']['apps'][$appname]['title'].' '.lang('Menu'),$file);
128
+			$file['Placeholders'] = Egw::link('/index.php', 'menuaction=timesheet.timesheet_merge.show_replacements');
129
+			display_sidebox($appname, $GLOBALS['egw_info']['apps'][$appname]['title'].' '.lang('Menu'), $file);
130 130
 		}
131 131
 
132 132
 		if ($GLOBALS['egw_info']['user']['apps']['admin'])
133 133
 		{
134 134
 			$file = Array(
135
-				'Site Configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname=' . $appname,'&ajax=true'),
136
-				'Custom fields' => Egw::link('/index.php','menuaction=admin.admin_customfields.index&appname='.$appname.'&use_private=1&ajax=true'),
137
-				'Global Categories'  => Egw::link('/index.php',array(
135
+				'Site Configuration' => Egw::link('/index.php', 'menuaction=admin.admin_config.index&appname='.$appname, '&ajax=true'),
136
+				'Custom fields' => Egw::link('/index.php', 'menuaction=admin.admin_customfields.index&appname='.$appname.'&use_private=1&ajax=true'),
137
+				'Global Categories'  => Egw::link('/index.php', array(
138 138
 					'menuaction' => 'admin.admin_categories.index',
139 139
 					'appname'    => $appname,
140 140
 					'global_cats'=> True,
141 141
 					'ajax' => 'true',
142 142
 				)),
143
-				'Edit Status' => Egw::link('/index.php','menuaction=timesheet.timesheet_ui.editstatus&ajax=true'),
143
+				'Edit Status' => Egw::link('/index.php', 'menuaction=timesheet.timesheet_ui.editstatus&ajax=true'),
144 144
 			);
145 145
 			if ($location == 'admin')
146 146
 			{
147
-				display_section($appname,$file);
147
+				display_section($appname, $file);
148 148
 			}
149 149
 			else
150 150
 			{
151
-				display_sidebox($appname,lang('Admin'),$file);
151
+				display_sidebox($appname, lang('Admin'), $file);
152 152
 			}
153 153
 		}
154 154
 	}
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
 				'size'   => 60,
182 182
 				'label'  => 'Default document to insert entries',
183 183
 				'name'   => 'default_document',
184
-				'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('timesheet')).' '.
184
+				'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('timesheet')).' '.
185 185
 					lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'ts_title').' '.
186
-					lang('The following document-types are supported:'). implode(',',Api\Storage\Merge::get_file_extensions()),
186
+					lang('The following document-types are supported:').implode(',', Api\Storage\Merge::get_file_extensions()),
187 187
 				'run_lang' => false,
188 188
 				'xmlrpc' => True,
189 189
 				'admin'  => False,
@@ -194,8 +194,8 @@  discard block
 block discarded – undo
194 194
 				'label'  => 'Directory with documents to insert entries',
195 195
 				'name'   => 'document_dir',
196 196
 				'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('timesheet')).' '.
197
-					lang('The document can contain placeholder like {{%1}}, to be replaced with the data.','ts_title').' '.
198
-					lang('The following document-types are supported:'). implode(',',Api\Storage\Merge::get_file_extensions()),
197
+					lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'ts_title').' '.
198
+					lang('The following document-types are supported:').implode(',', Api\Storage\Merge::get_file_extensions()),
199 199
 				'run_lang' => false,
200 200
 				'xmlrpc' => True,
201 201
 				'admin'  => False,
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 	 */
255 255
 	public static function acl_rights($params)
256 256
 	{
257
-		unset($params);	// not used, but required by function signature
257
+		unset($params); // not used, but required by function signature
258 258
 
259 259
 		return array(
260 260
 			Acl::READ    => 'read',
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 */
272 272
 	public static function categories($data)
273 273
 	{
274
-		unset($data);	// not used, but required by function signature
274
+		unset($data); // not used, but required by function signature
275 275
 
276 276
 		return true;
277 277
 	}
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@
 block discarded – undo
131 131
 
132 132
 		if ($GLOBALS['egw_info']['user']['apps']['admin'])
133 133
 		{
134
-			$file = Array(
134
+			$file = array(
135 135
 				'Site Configuration' => Egw::link('/index.php','menuaction=admin.admin_config.index&appname=' . $appname,'&ajax=true'),
136 136
 				'Custom fields' => Egw::link('/index.php','menuaction=admin.admin_customfields.index&appname='.$appname.'&use_private=1&ajax=true'),
137 137
 				'Global Categories'  => Egw::link('/index.php',array(
Please login to merge, or discard this patch.
notifications/inc/class.notifications_iface.inc.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,8 @@
 block discarded – undo
12 12
 /**
13 13
  * Instant user notification
14 14
  */
15
-interface notifications_iface {
15
+interface notifications_iface
16
+{
16 17
 
17 18
 	/**
18 19
 	 * constructor
Please login to merge, or discard this patch.
mail/profile.php 2 patches
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,10 @@  discard block
 block discarded – undo
43 43
 // switching off caching by default
44 44
 // if caching is enabled mail_times will always provit from previous running horde_times!
45 45
 $cache = isset($_GET['cache']) && $_GET['cache'];
46
-if (!$cache) unset(emailadmin_imap::$default_params['cache']);
46
+if (!$cache)
47
+{
48
+	unset(emailadmin_imap::$default_params['cache']);
49
+}
47 50
 
48 51
 $accounttime = microtime(true);
49 52
 
@@ -106,7 +109,8 @@  discard block
 block discarded – undo
106 109
 	}
107 110
 	stream_set_timeout($stream, 20);
108 111
 
109
-	if (function_exists('stream_set_read_buffer')) {
112
+	if (function_exists('stream_set_read_buffer'))
113
+	{
110 114
 		stream_set_read_buffer($stream, 0);
111 115
 	}
112 116
 	stream_set_write_buffer($stream, 0);
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
 Header('Content-Type: application/json; charset=utf-8');
63 63
 echo json_encode($times, JSON_PRETTY_PRINT);
64 64
 
65
-function php_times($account, array &$times, $prefix='php_')
65
+function php_times($account, array &$times, $prefix = 'php_')
66 66
 {
67 67
 	$starttime = microtime(true);
68
-	switch($account->acc_imap_ssl & ~emailadmin_account::SSL_VERIFY)
68
+	switch ($account->acc_imap_ssl & ~emailadmin_account::SSL_VERIFY)
69 69
 	{
70 70
 		case emailadmin_account::SSL_SSL:
71 71
 			$schema = 'ssl';
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	}
81 81
 	$error_number = $error_string = null;
82 82
 	$stream = stream_socket_client(
83
-		$schema . '://' . $account->acc_imap_host . ':' . $account->acc_imap_port,
83
+		$schema.'://'.$account->acc_imap_host.':'.$account->acc_imap_port,
84 84
 		$error_number,
85 85
 		$error_string,
86 86
 		20,
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	unset($connect_response, $starttls_response, $login_response, $error_number, $error_string);
129 129
 }
130 130
 
131
-function mail_times($acc_id, array &$times, $prefix='mail_')
131
+function mail_times($acc_id, array &$times, $prefix = 'mail_')
132 132
 {
133 133
 	global $cache;
134 134
 	$starttime = microtime(true);
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	$mail_ui->mail_bo->icServer->logout();
184 184
 }
185 185
 
186
-function horde_times(emailadmin_account $account, array &$times, $prefix='horde_')
186
+function horde_times(emailadmin_account $account, array &$times, $prefix = 'horde_')
187 187
 {
188 188
 	$starttime = microtime(true);
189 189
 	$imap = $account->imapServer();
@@ -215,12 +215,12 @@  discard block
 block discarded – undo
215 215
 	$imap->logout();
216 216
 }
217 217
 
218
-function horde_fetch(Horde_Imap_Client_Socket $client, $mailbox='INBOX')
218
+function horde_fetch(Horde_Imap_Client_Socket $client, $mailbox = 'INBOX')
219 219
 {
220 220
 	$squery = new Horde_Imap_Client_Search_Query();
221 221
 	// using a date filter to limit returned uids, gives huge speed improvement on big mailboxes, because less uids returned
222 222
 	//$squery->dateSearch(new DateTime('-30days'), Horde_Imap_Client_Search_Query::DATE_SINCE, false, false);
223
-	$squery->flag('DELETED', $set=false);
223
+	$squery->flag('DELETED', $set = false);
224 224
 	$sorted = $client->search($mailbox, $squery, array(
225 225
 		'sort' => array(Horde_Imap_Client::SORT_REVERSE, Horde_Imap_Client::SORT_SEQUENCE),
226 226
 	));
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	$first20uids->add(array_slice($sorted['match']->ids, 0, 20));
230 230
 
231 231
 	$fquery = new Horde_Imap_Client_Fetch_Query();
232
-	$fquery->headers('headers', array('Subject', 'From', 'To', 'Cc', 'Date'), array('peek' => true,'cache' => true));
232
+	$fquery->headers('headers', array('Subject', 'From', 'To', 'Cc', 'Date'), array('peek' => true, 'cache' => true));
233 233
 	$fquery->structure();
234 234
 	$fquery->flags();
235 235
 	$fquery->imapDate();
Please login to merge, or discard this patch.
mail/inc/class.mail_bo.inc.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,4 +19,6 @@
 block discarded – undo
19 19
  *
20 20
  * @deprecated use Api\Mail
21 21
  */
22
-class mail_bo extends Mail {}
22
+class mail_bo extends Mail
23
+{
24
+}
Please login to merge, or discard this patch.
mail/inc/class.mail_ui.inc.php 5 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1811,7 +1811,7 @@
 block discarded – undo
1811 1811
 
1812 1812
 			$data["class"] = implode(' ', $css_styles);
1813 1813
 			//translate style-classes back to flags
1814
-			$data['flags'] = Array();
1814
+			$data['flags'] = array();
1815 1815
 			if ($header['seen']) $data["flags"]['read'] = 'read';
1816 1816
 			foreach ($css_styles as &$flag) {
1817 1817
 				if ($flag!='mail')
Please login to merge, or discard this patch.
Doc Comments   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1726,7 +1726,7 @@  discard block
 block discarded – undo
1726 1726
 	 * function splitRowID - split the rowID into its parts
1727 1727
 	 *
1728 1728
 	 * @param string $_rowID string - a colon separated string in the form accountID:profileID:folder:message_uid
1729
-	 * @return array populated named result array (accountID,profileID,folder,msgUID)
1729
+	 * @return string populated named result array (accountID,profileID,folder,msgUID)
1730 1730
 	 */
1731 1731
 	static function splitRowID($_rowID)
1732 1732
 	{
@@ -1812,9 +1812,9 @@  discard block
 block discarded – undo
1812 1812
 	 * function header2gridelements - to populate the grid elements with the collected Data
1813 1813
 	 *
1814 1814
 	 * @param array $_headers headerdata to process
1815
-	 * @param array $cols cols to populate
1815
+	 * @param string[] $cols cols to populate
1816 1816
 	 * @param array $_folderName to ensure the uniqueness of the uid over all folders
1817
-	 * @param array $_folderType used to determine if we need to populate from/to
1817
+	 * @param integer $_folderType used to determine if we need to populate from/to
1818 1818
 	 * @return array populated result array
1819 1819
 	 */
1820 1820
 	public function header2gridelements($_headers, $cols, $_folderName, $_folderType=0)
@@ -2274,7 +2274,7 @@  discard block
 block discarded – undo
2274 2274
 
2275 2275
 	/**
2276 2276
 	 * Export stored smime certificate in database
2277
-	 * @return boolean return false if not successful
2277
+	 * @return false|null return false if not successful
2278 2278
 	 */
2279 2279
 	function smimeExportCert()
2280 2280
 	{
@@ -3230,6 +3230,9 @@  discard block
 block discarded – undo
3230 3230
 		return $GLOBALS['egw']->framework->header();
3231 3231
 	}
3232 3232
 
3233
+	/**
3234
+	 * @param string $body
3235
+	 */
3233 3236
 	function showBody(&$body, $print=true,$fullPageTags=true)
3234 3237
 	{
3235 3238
 		$BeginBody = '<div class="mailDisplayBody">
@@ -3673,7 +3676,7 @@  discard block
 block discarded – undo
3673 3676
 	 * @param string $_folder (passed by reference) will set the folder used. must be set with a folder, but will hold modifications if
3674 3677
 	 *					folder is modified
3675 3678
 	 * @param string $importID ID for the imported message, used by attachments to identify them unambiguously
3676
-	 * @return mixed $messageUID or exception
3679
+	 * @return string $messageUID or exception
3677 3680
 	 */
3678 3681
 	function importMessageToFolder($_formData,&$_folder,$importID='')
3679 3682
 	{
@@ -3834,7 +3837,7 @@  discard block
 block discarded – undo
3834 3837
 	 *
3835 3838
 	 * @param string _messageID UID
3836 3839
 	 *
3837
-	 * @return xajax response
3840
+	 * @return string|null response
3838 3841
 	 */
3839 3842
 	function loadEmailBody($_messageID=null,$_partID=null,$_htmloptions=null)
3840 3843
 	{
@@ -4381,7 +4384,7 @@  discard block
 block discarded – undo
4381 4384
 	 * ajax_deleteFolder - its called via json, so the function must start with ajax (or the class-name must contain ajax)
4382 4385
 	 * @param string $_folderName folder to delete
4383 4386
 	 * @param boolean $_return = false wheter return the success value (true) or send response to client (false)
4384
-	 * @return nothing
4387
+	 * @return boolean|null
4385 4388
 	 */
4386 4389
 	function ajax_deleteFolder($_folderName, $_return = false)
4387 4390
 	{
@@ -5150,8 +5153,9 @@  discard block
 block discarded – undo
5150 5153
 	 * @param string _move2ArchiveMarker marker to indicate if a move 2 archive was triggered
5151 5154
 	 * @param boolean _return if true the function will return the result instead of
5152 5155
 	 * responding to client
5156
+	 * @param string $_folderName
5153 5157
 	 *
5154
-	 * @return xajax response
5158
+	 * @return string|null response
5155 5159
 	 */
5156 5160
 	function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove='copy', $_move2ArchiveMarker='_', $_return = false)
5157 5161
 	{
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -3510,7 +3510,7 @@  discard block
 block discarded – undo
3510 3510
 		 * @param string $_partID
3511 3511
 		 * @param string $_type
3512 3512
 		 * @return string|boolean returns the replace
3513
-		*/
3513
+		 */
3514 3514
 		$replace_callback = function ($matches) use ($_mailbox,$_uid, $_partID,  $_type, $_link_callback)
3515 3515
 		{
3516 3516
 			if (!$_type)	return false;
@@ -3635,10 +3635,10 @@  discard block
 block discarded – undo
3635 3635
 			try
3636 3636
 			{
3637 3637
 				$messageUid = $this->importMessageToFolder($file,$destination,$importID);
3638
-			    $linkData = array
3639
-			    (
3638
+				$linkData = array
3639
+				(
3640 3640
 					'id' => $this->createRowID($destination, $messageUid, true),
3641
-			    );
3641
+				);
3642 3642
 			}
3643 3643
 			catch (Api\Exception\WrongUserinput $e)
3644 3644
 			{
@@ -3808,7 +3808,7 @@  discard block
 block discarded – undo
3808 3808
 			$messageUid = $this->importMessageToFolder($formData,$draftFolder,$importID);
3809 3809
 			$linkData = array
3810 3810
 			(
3811
-		        'menuaction'    => ($mode=='display'?'mail.mail_ui.displayMessage':'mail.mail_compose.composeFromDraft'),
3811
+				'menuaction'    => ($mode=='display'?'mail.mail_ui.displayMessage':'mail.mail_compose.composeFromDraft'),
3812 3812
 				'id'		=> $this->createRowID($draftFolder,$messageUid,true),
3813 3813
 				'deleteDraftOnClose' => 1,
3814 3814
 			);
Please login to merge, or discard this patch.
Spacing   +825 added lines, -832 removed lines patch added patch discarded remove patch
@@ -40,8 +40,7 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @var array
42 42
 	 */
43
-	var $public_functions = array
44
-	(
43
+	var $public_functions = array(
45 44
 		'index' => True,
46 45
 		'displayHeader'	=> True,
47 46
 		'displayMessage'	=> True,
@@ -92,17 +91,17 @@  discard block
 block discarded – undo
92 91
 	 * @var array
93 92
 	 */
94 93
 	var $searchTypes = array(
95
-		'quick'		=> 'quicksearch',	// lang('quicksearch')
96
-		'quickwithcc'=> 'quicksearch (with cc)',	// lang('quicksearch (with cc)')
97
-		'subject'	=> 'subject',		// lang('subject')
98
-		'body'		=> 'message body',	// lang('message body')
99
-		'from'		=> 'from',			// lang('from')
100
-		'to'		=> 'to',			// lang('to')
101
-		'cc'		=> 'cc',			// lang('cc')
102
-		'text'		=> 'whole message',	// lang('whole message')
103
-		'larger'		=> 'greater than',	// lang('greater than')
104
-		'smaller'		=> 'less than',	// lang('less than')
105
-		'bydate' 	=> 'Selected date range (with quicksearch)',// lang('Selected date range (with quicksearch)')
94
+		'quick'		=> 'quicksearch', // lang('quicksearch')
95
+		'quickwithcc'=> 'quicksearch (with cc)', // lang('quicksearch (with cc)')
96
+		'subject'	=> 'subject', // lang('subject')
97
+		'body'		=> 'message body', // lang('message body')
98
+		'from'		=> 'from', // lang('from')
99
+		'to'		=> 'to', // lang('to')
100
+		'cc'		=> 'cc', // lang('cc')
101
+		'text'		=> 'whole message', // lang('whole message')
102
+		'larger'		=> 'greater than', // lang('greater than')
103
+		'smaller'		=> 'less than', // lang('less than')
104
+		'bydate' 	=> 'Selected date range (with quicksearch)', // lang('Selected date range (with quicksearch)')
106 105
 	);
107 106
 
108 107
 	/**
@@ -111,12 +110,12 @@  discard block
 block discarded – undo
111 110
 	 * @var array
112 111
 	 */
113 112
 	var $statusTypes = array(
114
-		'any'		=> 'any status',// lang('any status')
115
-		'flagged'	=> 'flagged',	// lang('flagged')
116
-		'unseen'	=> 'unread',	// lang('unread')
117
-		'answered'	=> 'replied',	// lang('replied')
118
-		'seen'		=> 'read',		// lang('read')
119
-		'deleted'	=> 'deleted',	// lang('deleted')
113
+		'any'		=> 'any status', // lang('any status')
114
+		'flagged'	=> 'flagged', // lang('flagged')
115
+		'unseen'	=> 'unread', // lang('unread')
116
+		'answered'	=> 'replied', // lang('replied')
117
+		'seen'		=> 'read', // lang('read')
118
+		'deleted'	=> 'deleted', // lang('deleted')
120 119
 	);
121 120
 
122 121
 	/**
@@ -124,12 +123,12 @@  discard block
 block discarded – undo
124 123
 	 *
125 124
 	 * @param boolean $run_constructor =true false: no not run constructor and therefore do NOT connect to imap server
126 125
 	 */
127
-	function __construct($run_constructor=true)
126
+	function __construct($run_constructor = true)
128 127
 	{
129 128
 		$this->mail_tree = new mail_tree($this);
130 129
 		if (!$run_constructor) return;
131 130
 
132
-		if (Mail::$debugTimes) $starttime = microtime (true);
131
+		if (Mail::$debugTimes) $starttime = microtime(true);
133 132
 		// no autohide of the sidebox, as we use it for folderlist now.
134 133
 		unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']);
135 134
 
@@ -145,13 +144,13 @@  discard block
 block discarded – undo
145 144
 		}
146 145
 
147 146
 		try {
148
-			$this->mail_bo = Mail::getInstance(true,self::$icServerID, true, false, true);
147
+			$this->mail_bo = Mail::getInstance(true, self::$icServerID, true, false, true);
149 148
 			if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
150 149
 			//error_log(__METHOD__.__LINE__.array2string($this->mail_bo->icServer));
151 150
 
152 151
 			// RegEx to minimize extra openConnection
153 152
 			$needle = '/^(?!mail)/';
154
-			if (!preg_match($needle,$_GET['menuaction']) && !Api\Json\Request::isJSONRequest())
153
+			if (!preg_match($needle, $_GET['menuaction']) && !Api\Json\Request::isJSONRequest())
155 154
 			{
156 155
 				//error_log(__METHOD__.__LINE__.' Fetched IC Server openConnection:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
157 156
 				//openConnection gathers SpecialUseFolderInformation and Delimiter Info
@@ -164,12 +163,12 @@  discard block
 block discarded – undo
164 163
 			if (Api\Json\Request::isJSONRequest() && $_GET['menuaction'] != 'mail.mail_ui.index')
165 164
 			{
166 165
 				$response = Api\Json\Response::get();
167
-				$response->call('egw.message',$e->getMessage(),'error');
166
+				$response->call('egw.message', $e->getMessage(), 'error');
168 167
 			}
169 168
 			// redirect to mail wizard to handle it (redirect works for ajax too), unless index is called. we want the sidebox
170
-			if ($_GET['menuaction'] != 'mail.mail_ui.index') self::callWizard($e->getMessage(),true,'error',false);
169
+			if ($_GET['menuaction'] != 'mail.mail_ui.index') self::callWizard($e->getMessage(), true, 'error', false);
171 170
 		}
172
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
171
+		if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, '', __METHOD__.__LINE__);
173 172
 	}
174 173
 
175 174
 	/**
@@ -179,10 +178,10 @@  discard block
 block discarded – undo
179 178
 	 * @param boolean $exit If true, will call exit() after opening the wizardpopup
180 179
 	 * @param string $msg_type = 'success' message type
181 180
 	 */
182
-	static function callWizard($message, $exit=true, $msg_type='success',$reset_sidebox_on_index=true)
181
+	static function callWizard($message, $exit = true, $msg_type = 'success', $reset_sidebox_on_index = true)
183 182
 	{
184 183
 		//error_log(__METHOD__."('$message', $exit) ".function_backtrace());
185
-		$linkData=(self::$icServerID ? array(
184
+		$linkData = (self::$icServerID ? array(
186 185
 				'menuaction' => 'mail.mail_wizard.edit',
187 186
 				'acc_id' => self::$icServerID,
188 187
 			) : array(
@@ -196,11 +195,11 @@  discard block
 block discarded – undo
196 195
 		{
197 196
 			$response = Api\Json\Response::get();
198 197
 			$windowName = "editMailAccount".self::$icServerID;
199
-			$response->call("egw.open_link", Egw::link('/index.php', $linkData), $windowName, "600x480",null,true);
198
+			$response->call("egw.open_link", Egw::link('/index.php', $linkData), $windowName, "600x480", null, true);
200 199
 			Framework::message($message, 'error');
201 200
 			if ($_GET['menuaction'] == 'mail.mail_ui.index' && $reset_sidebox_on_index)
202 201
 			{
203
-				$response->call('framework.setSidebox','mail',array(),'md5');
202
+				$response->call('framework.setSidebox', 'mail', array(), 'md5');
204 203
 			}
205 204
 			if ($exit)
206 205
 			{
@@ -210,8 +209,8 @@  discard block
 block discarded – undo
210 209
 		else	// regular GET request eg. in idots template
211 210
 		{
212 211
 			$windowName = "editMailAccount".self::$icServerID;
213
-			Framework::popup(Framework::link('/index.php',$linkData),$windowName);
214
-			$GLOBALS['egw']->framework->render($message,'',true);
212
+			Framework::popup(Framework::link('/index.php', $linkData), $windowName);
213
+			$GLOBALS['egw']->framework->render($message, '', true);
215 214
 			if ($exit)
216 215
 			{
217 216
 				exit();
@@ -227,9 +226,9 @@  discard block
 block discarded – undo
227 226
 	 *
228 227
 	 * @throws Api\Exception
229 228
 	 */
230
-	function changeProfile($_icServerID,$unsetCache=false)
229
+	function changeProfile($_icServerID, $unsetCache = false)
231 230
 	{
232
-		if (Mail::$debugTimes) $starttime = microtime (true);
231
+		if (Mail::$debugTimes) $starttime = microtime(true);
233 232
 		if (self::$icServerID != $_icServerID)
234 233
 		{
235 234
 			self::$icServerID = $_icServerID;
@@ -237,35 +236,35 @@  discard block
 block discarded – undo
237 236
 		if (Mail::$debug) error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID);
238 237
 
239 238
 		if ($unsetCache) Mail::unsetCachedObjects(self::$icServerID);
240
-		$this->mail_bo = Mail::getInstance(false,self::$icServerID,true, false, true);
239
+		$this->mail_bo = Mail::getInstance(false, self::$icServerID, true, false, true);
241 240
 		if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
242 241
 		// no icServer Object: something failed big time
243
-		if (!isset($this->mail_bo) || !isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId<>$_icServerID)
242
+		if (!isset($this->mail_bo) || !isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId <> $_icServerID)
244 243
 		{
245 244
 			self::$icServerID = $_icServerID;
246 245
 			throw new Api\Exception('Profile change failed!');
247 246
 		}
248 247
 
249 248
 		// save session varchar
250
-		$oldicServerID =& Api\Cache::getSession('mail','activeProfileID');
249
+		$oldicServerID = & Api\Cache::getSession('mail', 'activeProfileID');
251 250
 		if ($oldicServerID <> self::$icServerID) $this->mail_bo->openConnection(self::$icServerID);
252 251
 		if (true) $oldicServerID = self::$icServerID;
253
-		if (!Mail::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true ))
252
+		if (!Mail::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true))
254 253
 		{
255 254
 			throw new Api\Exception(__METHOD__." failed to change Profile to $_icServerID");
256 255
 		}
257 256
 
258
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
257
+		if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, '', __METHOD__.__LINE__);
259 258
 	}
260 259
 
261 260
 	/**
262 261
 	 * Ajax function to request next branch of a tree branch
263 262
 	 */
264
-	static function ajax_tree_autoloading ($_id = null)
263
+	static function ajax_tree_autoloading($_id = null)
265 264
 	{
266 265
 		$mail_ui = new mail_ui();
267 266
 		$id = $_id ? $_id : $_GET['id'];
268
-		Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id,'',1,false));
267
+		Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id, '', 1, false));
269 268
 	}
270 269
 
271 270
 	/**
@@ -274,11 +273,11 @@  discard block
 block discarded – undo
274 273
 	 * @param array $content
275 274
 	 * @param type $msg
276 275
 	 */
277
-	function subscription(array $content=null ,$msg=null)
276
+	function subscription(array $content = null, $msg = null)
278 277
 	{
279 278
 		$stmpl = new Etemplate('mail.subscribe');
280 279
 
281
-		if(is_array($content))
280
+		if (is_array($content))
282 281
 		{
283 282
 			$profileId = $content['profileId'];
284 283
 		}
@@ -288,14 +287,14 @@  discard block
 block discarded – undo
288 287
 		}
289 288
 		// Initial tree's options, the rest would be loaded dynamicaly by autoloading,
290 289
 		// triggered from client-side. Also, we keep this here as
291
-		$sel_options['foldertree'] =  $this->mail_tree->getTree(null,$profileId,1,true,false,true);
290
+		$sel_options['foldertree'] = $this->mail_tree->getTree(null, $profileId, 1, true, false, true);
292 291
 
293 292
 		//Get all subscribed folders
294 293
 		// as getting all subscribed folders is very fast operation
295 294
 		// we can use it to get a comparison base for folders which
296 295
 		// got subscribed or unsubscribed by the user
297 296
 		try {
298
-			$subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('',0,true);
297
+			$subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('', 0, true);
299 298
 		} catch (Exception $ex) {
300 299
 			Framework::message($ex->getMessage());
301 300
 		}
@@ -306,7 +305,7 @@  discard block
 block discarded – undo
306 305
 
307 306
 			foreach ($subscribed as $folder)
308 307
 			{
309
-				$folderName = $profileId . self::$delimiter . $folder['MAILBOX'];
308
+				$folderName = $profileId.self::$delimiter.$folder['MAILBOX'];
310 309
 				array_push($content['foldertree'], $folderName);
311 310
 			}
312 311
 		}
@@ -320,9 +319,9 @@  discard block
 block discarded – undo
320 319
 				{
321 320
 					// do not let user (un)subscribe namespace roots eg. "other", "user" or "INBOX", same for tree-root/account itself
322 321
 					$namespace_roots = array($profileId);
323
-					foreach($this->mail_bo->_getNameSpaces() as $namespace)
322
+					foreach ($this->mail_bo->_getNameSpaces() as $namespace)
324 323
 					{
325
-						$namespace_roots[] = $profileId . self::$delimiter . str_replace($namespace['delimiter'], '', $namespace['prefix']);
324
+						$namespace_roots[] = $profileId.self::$delimiter.str_replace($namespace['delimiter'], '', $namespace['prefix']);
326 325
 					}
327 326
 					$to_unsubscribe = $to_subscribe = array();
328 327
 					foreach ($content['foldertree'] as $path => $value)
@@ -330,7 +329,7 @@  discard block
 block discarded – undo
330 329
 						list(,$node) = explode($profileId.self::$delimiter, $path);
331 330
 						if ($node)
332 331
 						{
333
-							if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe []= $node;
332
+							if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe [] = $node;
334 333
 							if (is_array($subscribed) && !$subscribed[$node] && $value['value']) $to_subscribe [] = $node;
335 334
 							if ($value['value']) $cont[] = $path;
336 335
 						}
@@ -340,7 +339,7 @@  discard block
 block discarded – undo
340 339
 					// set foldertree options to basic node in order to avoid initial autoloading
341 340
 					// from client side, as no options would trigger that.
342 341
 					$sel_options['foldertree'] = array('id' => '0', 'item'=> array());
343
-					foreach(array_merge($to_subscribe, $to_unsubscribe) as $mailbox)
342
+					foreach (array_merge($to_subscribe, $to_unsubscribe) as $mailbox)
344 343
 					{
345 344
 						if (in_array($profileId.self::$delimiter.$mailbox, $namespace_roots, true))
346 345
 						{
@@ -376,18 +375,18 @@  discard block
 block discarded – undo
376 375
 						}
377 376
 					}
378 377
 					// update foldertree in main window
379
-					$parentFolder='INBOX';
378
+					$parentFolder = 'INBOX';
380 379
 					$refreshData = array(
381 380
 						$profileId => lang($parentFolder),
382 381
 					);
383 382
 					$response = Api\Json\Response::get();
384
-					foreach($refreshData as $folder => &$name)
383
+					foreach ($refreshData as $folder => &$name)
385 384
 					{
386
-						$name = $this->mail_tree->getTree($folder, $profileId,1,true,true,true);
385
+						$name = $this->mail_tree->getTree($folder, $profileId, 1, true, true, true);
387 386
 					}
388 387
 					// give success/error message to opener and popup itself
389 388
 					//$response->call('opener.app.mail.subscription_refresh',$refreshData);
390
-					$response->call('opener.app.mail.mail_reloadNode',$refreshData);
389
+					$response->call('opener.app.mail.mail_reloadNode', $refreshData);
391 390
 
392 391
 					Framework::refresh_opener($msg, 'mail', null, null, null, null, null, $msg_type);
393 392
 					if ($button == 'apply')
@@ -407,7 +406,7 @@  discard block
 block discarded – undo
407 406
 
408 407
 		$readonlys = array();
409 408
 
410
-		$stmpl->exec('mail.mail_ui.subscription', $content,$sel_options,$readonlys,$preserv,2);
409
+		$stmpl->exec('mail.mail_ui.subscription', $content, $sel_options, $readonlys, $preserv, 2);
411 410
 	}
412 411
 
413 412
 	/**
@@ -416,13 +415,13 @@  discard block
 block discarded – undo
416 415
 	 * @param array $content
417 416
 	 * @param string $msg
418 417
 	 */
419
-	function index(array $content=null,$msg=null)
418
+	function index(array $content = null, $msg = null)
420 419
 	{
421 420
 		//error_log(__METHOD__.__LINE__.array2string($content));
422
-		try	{
421
+		try {
423 422
 				if (!isset($this->mail_bo)) throw new Api\Exception\WrongUserinput(lang('Initialization of mail failed. Please use the Wizard to cope with the problem.'));
424 423
 				//error_log(__METHOD__.__LINE__.function_backtrace());
425
-				if (Mail::$debugTimes) $starttime = microtime (true);
424
+				if (Mail::$debugTimes) $starttime = microtime(true);
426 425
 				$this->mail_bo->restoreSessionData();
427 426
 				$sessionFolder = $this->mail_bo->sessionData['mailbox'];
428 427
 				if ($this->mail_bo->folderExists($sessionFolder))
@@ -443,26 +442,26 @@  discard block
 block discarded – undo
443 442
 					{
444 443
 						// These only set on first load
445 444
 						$content[self::$nm_index] = array(
446
-							'filter'         => 'any',	// filter is used to choose the mailbox
447
-							'lettersearch'   => false,	// I  show a lettersearch
448
-							'searchletter'   =>	false,	// I0 active letter of the lettersearch or false for [all]
449
-							'start'          =>	0,		// IO position in list
450
-							'order'          =>	'date',	// IO name of the column to sort after (optional for the sortheaders)
451
-							'sort'           =>	'DESC',	// IO direction of the sort: 'ASC' or 'DESC'
445
+							'filter'         => 'any', // filter is used to choose the mailbox
446
+							'lettersearch'   => false, // I  show a lettersearch
447
+							'searchletter'   =>	false, // I0 active letter of the lettersearch or false for [all]
448
+							'start'          =>	0, // IO position in list
449
+							'order'          =>	'date', // IO name of the column to sort after (optional for the sortheaders)
450
+							'sort'           =>	'DESC', // IO direction of the sort: 'ASC' or 'DESC'
452 451
 						);
453 452
 					}
454 453
 					if (Api\Header\UserAgent::mobile()) $content[self::$nm_index]['header_row'] = 'mail.index.header_right';
455 454
 				}
456 455
 
457 456
 				// These must always be set, even if $content is an array
458
-				$content[self::$nm_index]['cat_is_select'] = true;    // Category select is just a normal selectbox
459
-				$content[self::$nm_index]['no_filter2'] = false;       // Disable second filter
457
+				$content[self::$nm_index]['cat_is_select'] = true; // Category select is just a normal selectbox
458
+				$content[self::$nm_index]['no_filter2'] = false; // Disable second filter
460 459
 				$content[self::$nm_index]['actions'] = self::get_actions();
461
-				$content[self::$nm_index]['row_id'] = 'row_id';	     // is a concatenation of trim($GLOBALS['egw_info']['user']['account_id']):profileID:base64_encode(FOLDERNAME):uid
460
+				$content[self::$nm_index]['row_id'] = 'row_id'; // is a concatenation of trim($GLOBALS['egw_info']['user']['account_id']):profileID:base64_encode(FOLDERNAME):uid
462 461
 				$content[self::$nm_index]['placeholder_actions'] = array('composeasnew');
463 462
 				$content[self::$nm_index]['get_rows'] = 'mail_ui::get_rows';
464
-				$content[self::$nm_index]['num_rows'] = 0;      // Do not send any rows with initial request
465
-				$content[self::$nm_index]['default_cols'] = 'status,attachments,subject,address,date,size';	// I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
463
+				$content[self::$nm_index]['num_rows'] = 0; // Do not send any rows with initial request
464
+				$content[self::$nm_index]['default_cols'] = 'status,attachments,subject,address,date,size'; // I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
466 465
 				$content[self::$nm_index]['csv_fields'] = false;
467 466
 				if ($msg)
468 467
 				{
@@ -474,11 +473,11 @@  discard block
 block discarded – undo
474 473
 					unset($content['msg']);
475 474
 				}
476 475
 				// call getQuotaRoot asynchronously in getRows by initiating a client Server roundtrip
477
-				$quota = false;//$this->mail_bo->getQuotaRoot();
478
-				if($quota !== false && $quota['limit'] != 'NOT SET') {
476
+				$quota = false; //$this->mail_bo->getQuotaRoot();
477
+				if ($quota !== false && $quota['limit'] != 'NOT SET') {
479 478
 					$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
480 479
 					$content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text'];
481
-					$content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] =  (string)$quotainfo['percent'];
480
+					$content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent'];
482 481
 					$content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class'];
483 482
 					$content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "";
484 483
 				} else {
@@ -488,27 +487,27 @@  discard block
 block discarded – undo
488 487
 				}
489 488
 
490 489
 				//$zstarttime = microtime (true);
491
-				$sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'],!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
490
+				$sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'], !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
492 491
 				//$zendtime = microtime(true) - $zstarttime;
493 492
 				//error_log(__METHOD__.__LINE__. " time used: ".$zendtime);
494
-				$content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.(!empty($this->mail_bo->sessionData['mailbox'])?$this->mail_bo->sessionData['mailbox']:'INBOX');
493
+				$content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.(!empty($this->mail_bo->sessionData['mailbox']) ? $this->mail_bo->sessionData['mailbox'] : 'INBOX');
495 494
 				// since we are connected,(and selected the folder) we check for capabilities SUPPORTS_KEYWORDS to eventually add the keyword filters
496
-				if ( $this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
495
+				if ($this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
497 496
 				{
498
-					$this->statusTypes = array_merge($this->statusTypes,array(
499
-						'keyword1'	=> 'important',//lang('important'),
500
-						'keyword2'	=> 'job',	//lang('job'),
501
-						'keyword3'	=> 'personal',//lang('personal'),
502
-						'keyword4'	=> 'to do',	//lang('to do'),
503
-						'keyword5'	=> 'later',	//lang('later'),
497
+					$this->statusTypes = array_merge($this->statusTypes, array(
498
+						'keyword1'	=> 'important', //lang('important'),
499
+						'keyword2'	=> 'job', //lang('job'),
500
+						'keyword3'	=> 'personal', //lang('personal'),
501
+						'keyword4'	=> 'to do', //lang('to do'),
502
+						'keyword5'	=> 'later', //lang('later'),
504 503
 					));
505 504
 				}
506 505
 				else
507 506
 				{
508
-					$keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5');
509
-					foreach($keywords as &$k)
507
+					$keywords = array('keyword1', 'keyword2', 'keyword3', 'keyword4', 'keyword5');
508
+					foreach ($keywords as &$k)
510 509
 					{
511
-						if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]);
510
+						if (array_key_exists($k, $this->statusTypes)) unset($this->statusTypes[$k]);
512 511
 					}
513 512
 				}
514 513
 
@@ -519,8 +518,8 @@  discard block
 block discarded – undo
519 518
 
520 519
 				if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
521 520
 				{
522
-					Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
523
-					if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
521
+					Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
522
+					if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true;
524 523
 				}
525 524
 				if (!Mail::$supportsORinQuery[$this->mail_bo->profileID])
526 525
 				{
@@ -532,14 +531,14 @@  discard block
 block discarded – undo
532 531
 				//error_log(__METHOD__.__LINE__.array2string($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']));
533 532
 				$content[self::$nm_index]['cat_id'] = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType'];
534 533
 				$sel_options['filter'] = $this->statusTypes;
535
-				$sel_options['filter2'] = array(''=>lang('No Sneak Preview in list'),1=>lang('Sneak Preview in list'));
534
+				$sel_options['filter2'] = array(''=>lang('No Sneak Preview in list'), 1=>lang('Sneak Preview in list'));
536 535
 				$content[self::$nm_index]['filter2'] = $GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails'];
537 536
 
538 537
 				$etpl = new Etemplate('mail.index');
539 538
 				//apply infolog_filter_change javascript method (hide/show of date filter form) over onchange filter
540 539
 				$content[self::$nm_index]['cat_id_onchange'] = "app.mail.mail_searchtype_change()";
541 540
 				// set the actions on tree
542
-				$etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $this->get_tree_actions());
541
+				$etpl->setElementAttribute(self::$nm_index.'[foldertree]', 'actions', $this->get_tree_actions());
543 542
 
544 543
 				// sending preview toolbar actions
545 544
 				if ($content['mailSplitter']) $etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions());
@@ -550,28 +549,28 @@  discard block
 block discarded – undo
550 549
 				//we use the category "filter" option as specifier where we want to search (quick, subject, from, to, etc. ....)
551 550
 				if (empty($content[self::$nm_index]['cat_id']) || empty($content[self::$nm_index]['search']))
552 551
 				{
553
-					$content[self::$nm_index]['cat_id']=($content[self::$nm_index]['cat_id']?(!Mail::$supportsORinQuery[$this->mail_bo->profileID]&&($content[self::$nm_index]['cat_id']=='quick'||$content[self::$nm_index]['cat_id']=='quickwithcc')?'subject':$content[self::$nm_index]['cat_id']):(Mail::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject'));
552
+					$content[self::$nm_index]['cat_id'] = ($content[self::$nm_index]['cat_id'] ? (!Mail::$supportsORinQuery[$this->mail_bo->profileID] && ($content[self::$nm_index]['cat_id'] == 'quick' || $content[self::$nm_index]['cat_id'] == 'quickwithcc') ? 'subject' : $content[self::$nm_index]['cat_id']) : (Mail::$supportsORinQuery[$this->mail_bo->profileID] ? 'quick' : 'subject'));
554 553
 				}
555 554
 				$readonlys = $preserv = array();
556
-				if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
555
+				if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, '', __METHOD__.__LINE__);
557 556
 		}
558 557
 		catch (Exception $e)
559 558
 		{
560 559
 			// do not exit here. mail-tree should be build. if we exit here, we never get there.
561
-			error_log(__METHOD__.__LINE__.$e->getMessage().($e->details?', '.$e->details:'').' Menuaction:'.$_GET['menuaction'].'.'.function_backtrace());
560
+			error_log(__METHOD__.__LINE__.$e->getMessage().($e->details ? ', '.$e->details : '').' Menuaction:'.$_GET['menuaction'].'.'.function_backtrace());
562 561
 			if (isset($this->mail_bo))
563 562
 			{
564 563
 				if (empty($etpl))
565 564
 				{
566
-					$sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'],!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
565
+					$sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'], !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
567 566
 					$etpl = new Etemplate('mail.index');
568 567
 				}
569
-				$etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $this->get_tree_actions(false));
568
+				$etpl->setElementAttribute(self::$nm_index.'[foldertree]', 'actions', $this->get_tree_actions(false));
570 569
 			}
571 570
 			$readonlys = $preserv = array();
572
-			if (empty($content)) $content=array();
571
+			if (empty($content)) $content = array();
573 572
 
574
-			self::callWizard($e->getMessage().($e->details?', '.$e->details:''),(isset($this->mail_bo)?false:true), 'error',false);
573
+			self::callWizard($e->getMessage().($e->details ? ', '.$e->details : ''), (isset($this->mail_bo) ?false:true), 'error', false);
575 574
 			//return false;
576 575
 		}
577 576
 		switch ($this->mail_bo->mailPreferences['previewPane'])
@@ -590,7 +589,7 @@  discard block
 block discarded – undo
590 589
 			default:
591 590
 				$etpl->setElementAttribute('mailSplitter', 'orientation', 'v');
592 591
 		}
593
-		return $etpl->exec('mail.mail_ui.index',$content,$sel_options,$readonlys,$preserv);
592
+		return $etpl->exec('mail.mail_ui.index', $content, $sel_options, $readonlys, $preserv);
594 593
 	}
595 594
 
596 595
 	/**
@@ -600,11 +599,11 @@  discard block
 block discarded – undo
600 599
 	 * @param {boolean} $imap_actions set to false if you want to avoid to talk to the imap-server
601 600
 	 * @return array
602 601
 	 */
603
-	function get_tree_actions($imap_actions=true)
602
+	function get_tree_actions($imap_actions = true)
604 603
 	{
605 604
 		// Start at 2 so auto-added copy+paste actions show up as second group
606 605
 		// Needed because there's no 'select all' action to push things down
607
-		$group=1;
606
+		$group = 1;
608 607
 		// Set tree actions
609 608
 		$tree_actions = array(
610 609
 			'drop_move_mail' => array(
@@ -686,12 +685,12 @@  discard block
 block discarded – undo
686 685
 				'onExecute' => 'javaScript:app.mail.edit_sieve',
687 686
 
688 687
 				'enabled'	=> 'javaScript:app.mail.sieve_enabled',
689
-				'icon' => 'mail/filter',	// funnel
688
+				'icon' => 'mail/filter', // funnel
690 689
 				'hideOnMobile' => true
691 690
 			),
692 691
 			'vacation' => array(
693 692
 				'caption' => 'Vacation notice',
694
-				'icon' => 'mail/navbar',	// mail as in admin
693
+				'icon' => 'mail/navbar', // mail as in admin
695 694
 				'onExecute' => 'javaScript:app.mail.edit_vacation',
696 695
 				'enabled'	=> 'javaScript:app.mail.sieve_enabled',
697 696
 			),
@@ -732,8 +731,8 @@  discard block
 block discarded – undo
732 731
 			unset($tree_actions['subscribe']);
733 732
 			unset($tree_actions['unsubscribe']);
734 733
 		}
735
-		++$group;	// put delete in own group
736
-		switch($GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions'])
734
+		++$group; // put delete in own group
735
+		switch ($GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions'])
737 736
 		{
738 737
 			case 'move_to_trash':
739 738
 				$tree_actions['empty_trash'] = array(
@@ -752,7 +751,7 @@  discard block
 block discarded – undo
752 751
 				);
753 752
 				break;
754 753
 		}
755
-		$junkFolder = ($imap_actions?$this->mail_bo->getJunkFolder():null);
754
+		$junkFolder = ($imap_actions ? $this->mail_bo->getJunkFolder() : null);
756 755
 
757 756
 		//error_log(__METHOD__.__LINE__.$junkFolder);
758 757
 		if ($junkFolder && !empty($junkFolder))
@@ -765,8 +764,8 @@  discard block
 block discarded – undo
765 764
 				'group'	=> $group,
766 765
 			);
767 766
 		}
768
-		$tree_actions['sieve']['group']	= $tree_actions['vacation']['group'] = ++$group;	// new group for filter
769
-		$tree_actions['edit_account']['group'] = $tree_actions['edit_acl']['group']	= ++$group;
767
+		$tree_actions['sieve']['group'] = $tree_actions['vacation']['group'] = ++$group; // new group for filter
768
+		$tree_actions['edit_account']['group'] = $tree_actions['edit_acl']['group'] = ++$group;
770 769
 
771 770
 
772 771
 		// enforce global (group-specific) ACL
@@ -801,17 +800,17 @@  discard block
 block discarded – undo
801 800
 	 * @param {string} $_folderName name of mailbox needs to be subcribe or unsubscribed
802 801
 	 * @param {boolean} $_status set true for subscribe and false to unsubscribe
803 802
 	 */
804
-	public function ajax_foldersubscription($_acc_id,$_folderName, $_status)
803
+	public function ajax_foldersubscription($_acc_id, $_folderName, $_status)
805 804
 	{
806 805
 		//Change the Mail object to related profileId
807 806
 		$this->changeProfile($_acc_id);
808
-		try{
807
+		try {
809 808
 			$this->mail_bo->icServer->subscribeMailbox($_folderName, $_status);
810 809
 			$this->mail_bo->resetFolderObjectCache($_acc_id);
811
-			$this->ajax_reloadNode($_acc_id,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
810
+			$this->ajax_reloadNode($_acc_id, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
812 811
 		} catch (Horde_Imap_Client_Exception $ex) {
813
-			error_log(__METHOD__.__LINE__."()". lang('Folder %1 %2 failed because of %3!',$_folderName,$_status?'subscribed':'unsubscribed', $ex));
814
-			Framework::message(lang('Folder %1 %2 failed!',$_folderName,$_status));
812
+			error_log(__METHOD__.__LINE__."()".lang('Folder %1 %2 failed because of %3!', $_folderName, $_status ? 'subscribed' : 'unsubscribed', $ex));
813
+			Framework::message(lang('Folder %1 %2 failed!', $_folderName, $_status));
815 814
 		}
816 815
 	}
817 816
 
@@ -823,25 +822,25 @@  discard block
 block discarded – undo
823 822
 	 * @param string $_nodeID if of node whose children are requested
824 823
 	 * @param boolean $_subscribedOnly flag to tell whether to fetch all or only subscribed (default)
825 824
 	 */
826
-	public function ajax_foldertree($_nodeID = null,$_subscribedOnly=null)
825
+	public function ajax_foldertree($_nodeID = null, $_subscribedOnly = null)
827 826
 	{
828 827
 		$nodeID = $_GET['id'];
829 828
 		if (!is_null($_nodeID)) $nodeID = $_nodeID;
830
-		$subscribedOnly = (bool)(!is_null($_subscribedOnly)?$_subscribedOnly:!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
829
+		$subscribedOnly = (bool)(!is_null($_subscribedOnly) ? $_subscribedOnly : !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
831 830
 		$fetchCounters = !is_null($_nodeID);
832
-		list($_profileID,$_folderName) = explode(self::$delimiter,$nodeID,2);
831
+		list($_profileID, $_folderName) = explode(self::$delimiter, $nodeID, 2);
833 832
 
834 833
 		if (!empty($_folderName)) $fetchCounters = true;
835 834
 
836 835
 		// Check if it is called for refresh root
837 836
 		// then we need to reinitialized the index tree
838
-		if(!$nodeID && !$_profileID)
837
+		if (!$nodeID && !$_profileID)
839 838
 		{
840
-			$data = $this->mail_tree->getInitialIndexTree(null,null,null,null,true,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
839
+			$data = $this->mail_tree->getInitialIndexTree(null, null, null, null, true, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
841 840
 		}
842 841
 		else
843 842
 		{
844
-			$data = $this->mail_tree->getTree($nodeID,$_profileID,0, false,$subscribedOnly,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
843
+			$data = $this->mail_tree->getTree($nodeID, $_profileID, 0, false, $subscribedOnly, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
845 844
 		}
846 845
 		if (!is_null($_nodeID)) return $data;
847 846
 		Etemplate\Widget\Tree::send_quote_json($data);
@@ -857,17 +856,17 @@  discard block
 block discarded – undo
857 856
 	 */
858 857
 	static function findNode($_out, $_nodeID, $childElements = false)
859 858
 	{
860
-		foreach($_out['item'] as $node)
859
+		foreach ($_out['item'] as $node)
861 860
 		{
862
-			if (strcmp($node['id'],$_nodeID)===0)
861
+			if (strcmp($node['id'], $_nodeID) === 0)
863 862
 			{
864 863
 				//error_log(__METHOD__.__LINE__.':'.$_nodeID.'->'.$node['id']);
865
-				return ($childElements?$node['item']:$node);
864
+				return ($childElements ? $node['item'] : $node);
866 865
 			}
867
-			elseif (is_array($node['item']) && strncmp($node['id'],$_nodeID,strlen($node['id']))===0 && strlen($_nodeID)>strlen($node['id']))
866
+			elseif (is_array($node['item']) && strncmp($node['id'], $_nodeID, strlen($node['id'])) === 0 && strlen($_nodeID) > strlen($node['id']))
868 867
 			{
869 868
 				//error_log(__METHOD__.__LINE__.' descend into '.$node['id']);
870
-				return self::findNode($node,$_nodeID,$childElements);
869
+				return self::findNode($node, $_nodeID, $childElements);
871 870
 			}
872 871
 		}
873 872
 	}
@@ -970,11 +969,11 @@  discard block
 block discarded – undo
970 969
 
971 970
 		if ($refresh)
972 971
 		{
973
-			$response->data([implode('\n',$msg),$messages]);
972
+			$response->data([implode('\n', $msg), $messages]);
974 973
 		}
975 974
 		else
976 975
 		{
977
-			$response->apply('egw.message',[implode('\n',$msg)]);
976
+			$response->apply('egw.message', [implode('\n', $msg)]);
978 977
 		}
979 978
 	}
980 979
 
@@ -983,22 +982,22 @@  discard block
 block discarded – undo
983 982
 	 *
984 983
 	 * @return array actions
985 984
 	 */
986
-	public function getSpamActions ()
985
+	public function getSpamActions()
987 986
 	{
988
-		$actions = array (
989
-			'spamfilter' => array (
987
+		$actions = array(
988
+			'spamfilter' => array(
990 989
 				'caption'	=> 'Spam',
991 990
 				'icon'		=> 'dhtmlxtree/MailFolderJunk',
992 991
 				'allowOnMultiple' => true,
993
-				'children'	=> array (
994
-					'spam' => array (
992
+				'children'	=> array(
993
+					'spam' => array(
995 994
 						'caption'	=> 'Report as Spam',
996 995
 						'icon'		=> 'dhtmlxtree/MailFolderJunk',
997 996
 						'onExecute' => 'javaScript:app.mail.spam_actions',
998 997
 						'hint'		=> 'Report this email content as Spam - spam solutions like spamTitan will learn',
999 998
 						'allowOnMultiple' => true
1000 999
 					),
1001
-					'ham' => array (
1000
+					'ham' => array(
1002 1001
 						'caption'	=> 'Report as Ham',
1003 1002
 						'icon'		=> 'dhtmlxtree/MailFolderHam',
1004 1003
 						'onExecute' => 'javaScript:app.mail.spam_actions',
@@ -1025,7 +1024,7 @@  discard block
 block discarded – undo
1025 1024
 	 */
1026 1025
 	private function get_actions()
1027 1026
 	{
1028
-		static $accArray=array(); // buffer identity names on single request
1027
+		static $accArray = array(); // buffer identity names on single request
1029 1028
 		// duplicated from mail_hooks
1030 1029
 		static $deleteOptions = array(
1031 1030
 			'move_to_trash'		=> 'move to trash',
@@ -1036,12 +1035,12 @@  discard block
 block discarded – undo
1036 1035
 		$lastFolderUsedForMove = null;
1037 1036
 		$moveactions = array();
1038 1037
 		$archiveFolder = $this->mail_bo->getArchiveFolder();
1039
-		$lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1);
1038
+		$lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 1);
1040 1039
 		//error_log(__METHOD__.__LINE__." StoredFolders->".array2string($lastFoldersUsedForMoveCont));
1041 1040
 		//error_log(__METHOD__.__LINE__.' ProfileId:'.$this->mail_bo->profileID." StoredFolders->(".count($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]).") ".array2string($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]));
1042 1041
 		if (is_null($accArray))
1043 1042
 		{
1044
-			foreach(Mail\Account::search($only_current_user=true, false) as $acc_id => $accountObj)
1043
+			foreach (Mail\Account::search($only_current_user = true, false) as $acc_id => $accountObj)
1045 1044
 			{
1046 1045
 				//error_log(__METHOD__.__LINE__.array2string($accountObj));
1047 1046
 				if (!$accountObj->is_imap())
@@ -1049,22 +1048,22 @@  discard block
 block discarded – undo
1049 1048
 					// not to be used for IMAP Foldertree, as there is no Imap host
1050 1049
 					continue;
1051 1050
 				}
1052
-				$identity_name = Mail\Account::identity_name($accountObj,true,$GLOBALS['egw_info']['user']['acount_id']);
1053
-				$accArray[$acc_id] = str_replace(array('<','>'),array('[',']'),$identity_name);// as angle brackets are quoted, display in Javascript messages when used is ugly, so use square brackets instead
1051
+				$identity_name = Mail\Account::identity_name($accountObj, true, $GLOBALS['egw_info']['user']['acount_id']);
1052
+				$accArray[$acc_id] = str_replace(array('<', '>'), array('[', ']'), $identity_name); // as angle brackets are quoted, display in Javascript messages when used is ugly, so use square brackets instead
1054 1053
 			}
1055 1054
 		}
1056
-		if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont=array();
1055
+		if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont = array();
1057 1056
 		foreach (array_keys($lastFoldersUsedForMoveCont) as $pid)
1058 1057
 		{
1059
-			if ($this->mail_bo->profileID==$pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]))
1058
+			if ($this->mail_bo->profileID == $pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]))
1060 1059
 			{
1061 1060
 				$_folder = $this->mail_bo->icServer->getCurrentMailbox();
1062 1061
 				//error_log(__METHOD__.__LINE__.' '.$_folder."<->".$lastFoldersUsedForMoveCont[$this->mail_bo->profileID].function_backtrace());
1063
-				$counter =1;
1062
+				$counter = 1;
1064 1063
 				foreach ($lastFoldersUsedForMoveCont[$this->mail_bo->profileID] as $i => $lastFolderUsedForMoveCont)
1065 1064
 				{
1066 1065
 					$moveaction = 'move_';
1067
-					if ($_folder!=$i)
1066
+					if ($_folder != $i)
1068 1067
 					{
1069 1068
 						$moveaction .= $lastFolderUsedForMoveCont;
1070 1069
 						//error_log(__METHOD__.__LINE__.'#'.$moveaction);
@@ -1075,7 +1074,7 @@  discard block
 block discarded – undo
1075 1074
 							$fS['profileName'] = $accArray[$this->mail_bo->profileID];
1076 1075
 							$fS['shortDisplayName'] = $i;
1077 1076
 							$moveactions[$moveaction] = $fS;
1078
-							$counter ++;
1077
+							$counter++;
1079 1078
 						}
1080 1079
 						else
1081 1080
 						{
@@ -1085,9 +1084,9 @@  discard block
 block discarded – undo
1085 1084
 					}
1086 1085
 				}
1087 1086
 			}
1088
-			elseif ($this->mail_bo->profileID!=$pid && isset($lastFoldersUsedForMoveCont[$pid]) && !empty($lastFoldersUsedForMoveCont[$pid]))
1087
+			elseif ($this->mail_bo->profileID != $pid && isset($lastFoldersUsedForMoveCont[$pid]) && !empty($lastFoldersUsedForMoveCont[$pid]))
1089 1088
 			{
1090
-				$counter =1;
1089
+				$counter = 1;
1091 1090
 				foreach ($lastFoldersUsedForMoveCont[$pid] as $i => $lastFolderUsedForMoveCont)
1092 1091
 				{
1093 1092
 					//error_log(__METHOD__.__LINE__."$i => $lastFolderUsedForMoveCont");
@@ -1100,19 +1099,19 @@  discard block
 block discarded – undo
1100 1099
 						$fS['profileName'] = $accArray[$pid];
1101 1100
 						$fS['shortDisplayName'] = $i;
1102 1101
 						$moveactions[$moveaction] = $fS;
1103
-						$counter ++;
1102
+						$counter++;
1104 1103
 					}
1105 1104
 				}
1106 1105
 			}
1107 1106
 		}
1108
-		Api\Cache::setCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFoldersUsedForMoveCont, $expiration=60*60*1);
1107
+		Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), $lastFoldersUsedForMoveCont, $expiration = 60 * 60 * 1);
1109 1108
 		$group = 0;
1110
-		$actions =  array(
1109
+		$actions = array(
1111 1110
 			'open' => array(
1112 1111
 				'caption' => lang('Open'),
1113 1112
 				'icon' => 'view',
1114 1113
 				'group' => ++$group,
1115
-				'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.mail.mobileView':'javaScript:app.mail.mail_open',
1114
+				'onExecute' => Api\Header\UserAgent::mobile() ? 'javaScript:app.mail.mobileView' : 'javaScript:app.mail.mail_open',
1116 1115
 				'allowOnMultiple' => false,
1117 1116
 				'default' => true,
1118 1117
 				'mobileViewTemplate' => 'view?'.filemtime(Api\Etemplate\Widget\Template::rel2path('/mail/templates/mobile/view.xet'))
@@ -1167,20 +1166,20 @@  discard block
 block discarded – undo
1167 1166
 				'allowOnMultiple' => false,
1168 1167
 			)
1169 1168
 		);
1170
-		$macounter=0;
1169
+		$macounter = 0;
1171 1170
 		if (!empty($moveactions))
1172 1171
 		{
1173 1172
 			//error_log(__METHOD__.__LINE__.array2string($moveactions));
1174
-			$children=array();
1175
-			$pID=0;
1173
+			$children = array();
1174
+			$pID = 0;
1176 1175
 			foreach ($moveactions as $moveaction => $lastFolderUsedForMove)
1177 1176
 			{
1178
-				$group = ($pID != $lastFolderUsedForMove['profileID'] && $macounter>0? $group+1 : $group);
1177
+				$group = ($pID != $lastFolderUsedForMove['profileID'] && $macounter > 0 ? $group + 1 : $group);
1179 1178
 				//error_log(__METHOD__.__LINE__."#$pID != ".$lastFolderUsedForMove['profileID']."#".$macounter.'#'.$groupCounter.'#');
1180 1179
 				$children = array_merge($children,
1181 1180
 					array(
1182 1181
 						$moveaction => array(
1183
-							'caption' => (!empty($lastFolderUsedForMove['profileName'])?$lastFolderUsedForMove['profileName']:'('.$lastFolderUsedForMove['profileID'].')').': '.(isset($lastFolderUsedForMove['shortDisplayName'])?$lastFolderUsedForMove['shortDisplayName']:''),
1182
+							'caption' => (!empty($lastFolderUsedForMove['profileName']) ? $lastFolderUsedForMove['profileName'] : '('.$lastFolderUsedForMove['profileID'].')').': '.(isset($lastFolderUsedForMove['shortDisplayName']) ? $lastFolderUsedForMove['shortDisplayName'] : ''),
1184 1183
 							'icon' => 'move',
1185 1184
 							'group' => $group,
1186 1185
 							'onExecute' => 'javaScript:app.mail.mail_move2folder',
@@ -1191,7 +1190,7 @@  discard block
 block discarded – undo
1191 1190
 				$pID = $lastFolderUsedForMove['profileID'];
1192 1191
 				$macounter++;
1193 1192
 			}
1194
-			$actions['moveto'] =	array(
1193
+			$actions['moveto'] = array(
1195 1194
 				'caption' => lang('Move selected to'),
1196 1195
 				'icon' => 'move',
1197 1196
 				'group' => $group,
@@ -1239,7 +1238,7 @@  discard block
 block discarded – undo
1239 1238
 				'icon' => 'tracker/navbar',
1240 1239
 				'onExecute' => 'javaScript:app.mail.mail_integrate',
1241 1240
 				'popup' => Link::get_registry('tracker', 'add_popup'),
1242
-				'mail_import' => Api\Hooks::single(array('location' => 'mail_import'),'tracker'),
1241
+				'mail_import' => Api\Hooks::single(array('location' => 'mail_import'), 'tracker'),
1243 1242
 				'allowOnMultiple' => false,
1244 1243
 			),
1245 1244
 			'calendar' => array(
@@ -1463,25 +1462,25 @@  discard block
 block discarded – undo
1463 1462
 	 * @param array &$rows
1464 1463
 	 * @param array &$readonlys
1465 1464
 	 */
1466
-	public static function get_rows(&$query,&$rows,&$readonlys)
1465
+	public static function get_rows(&$query, &$rows, &$readonlys)
1467 1466
 	{
1468
-		unset($readonlys);	// not used, but required by function signature
1467
+		unset($readonlys); // not used, but required by function signature
1469 1468
 
1470 1469
 		// handle possible profile change in get_rows
1471 1470
 		if (!empty($query['selectedFolder']))
1472 1471
 		{
1473
-			list($_profileID,$folderName) = explode(self::$delimiter, $query['selectedFolder'], 2);
1472
+			list($_profileID, $folderName) = explode(self::$delimiter, $query['selectedFolder'], 2);
1474 1473
 			if (is_numeric(($_profileID)) && $_profileID != $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'])
1475 1474
 			{
1476 1475
 				try {
1477
-					$mail_ui = new mail_ui(false);	// do NOT run constructor, as we change profile anyway
1476
+					$mail_ui = new mail_ui(false); // do NOT run constructor, as we change profile anyway
1478 1477
 					$mail_ui->changeProfile($_profileID);
1479 1478
 					$query['actions'] = $mail_ui->get_actions();
1480 1479
 				}
1481
-				catch(Exception $e)
1480
+				catch (Exception $e)
1482 1481
 				{
1483 1482
 					unset($e);
1484
-					$rows=array();
1483
+					$rows = array();
1485 1484
 					return 0;
1486 1485
 				}
1487 1486
 				if (empty($folderName)) $query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX';
@@ -1491,12 +1490,12 @@  discard block
 block discarded – undo
1491 1490
 		{
1492 1491
 			try
1493 1492
 			{
1494
-				$mail_ui = new mail_ui(true);	// run constructor for current profile
1493
+				$mail_ui = new mail_ui(true); // run constructor for current profile
1495 1494
 			}
1496
-			catch(Exception $e)
1495
+			catch (Exception $e)
1497 1496
 			{
1498 1497
 				unset($e);
1499
-				$rows=array();
1498
+				$rows = array();
1500 1499
 				return 0;
1501 1500
 			}
1502 1501
 			if (empty($query['selectedFolder'])) $query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX';
@@ -1507,66 +1506,66 @@  discard block
 block discarded – undo
1507 1506
 		//$query['search'] is the phrase in the searchbox
1508 1507
 
1509 1508
 		$mail_ui->mail_bo->restoreSessionData();
1510
-		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder'];
1509
+		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox'] = $query['selectedFolder'];
1511 1510
 
1512 1511
 		$sRToFetch = null;
1513
-		list($_profileID,$_folderName) = explode(self::$delimiter,$query['selectedFolder'],2);
1514
-		if (strpos($_folderName,self::$delimiter)!==false)
1512
+		list($_profileID, $_folderName) = explode(self::$delimiter, $query['selectedFolder'], 2);
1513
+		if (strpos($_folderName, self::$delimiter) !== false)
1515 1514
 		{
1516
-			list($app,$_profileID,$_folderName) = explode(self::$delimiter,$_folderName,3);
1515
+			list($app, $_profileID, $_folderName) = explode(self::$delimiter, $_folderName, 3);
1517 1516
 			unset($app);
1518 1517
 		}
1519 1518
 		//save selected Folder to sessionData (mailbox)->currentFolder
1520
-		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$_folderName;
1521
-		$toSchema = false;//decides to select list schema with column to selected (if false fromaddress is default)
1519
+		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox'] = $_folderName;
1520
+		$toSchema = false; //decides to select list schema with column to selected (if false fromaddress is default)
1522 1521
 		if ($mail_ui->mail_bo->folderExists($_folderName))
1523 1522
 		{
1524
-			$toSchema = $mail_ui->mail_bo->isDraftFolder($_folderName,false)||$mail_ui->mail_bo->isSentFolder($_folderName,false)||$mail_ui->mail_bo->isTemplateFolder($_folderName,false);
1523
+			$toSchema = $mail_ui->mail_bo->isDraftFolder($_folderName, false) || $mail_ui->mail_bo->isSentFolder($_folderName, false) || $mail_ui->mail_bo->isTemplateFolder($_folderName, false);
1525 1524
 		}
1526 1525
 		else
1527 1526
 		{
1528 1527
 			// take the extra time on failure
1529
-			if (!$mail_ui->mail_bo->folderExists($_folderName,true))
1528
+			if (!$mail_ui->mail_bo->folderExists($_folderName, true))
1530 1529
 			{
1531 1530
 				//error_log(__METHOD__.__LINE__.' Test on Folder:'.$_folderName.' failed; Using INBOX instead');
1532
-				$query['selectedFolder']=$mail_ui->mail_bo->sessionData['mailbox']=$_folderName='INBOX';
1531
+				$query['selectedFolder'] = $mail_ui->mail_bo->sessionData['mailbox'] = $_folderName = 'INBOX';
1533 1532
 			}
1534 1533
 		}
1535 1534
 		$rowsFetched['messages'] = null;
1536
-		$offset = $query['start']+1; // we always start with 1
1535
+		$offset = $query['start'] + 1; // we always start with 1
1537 1536
 		$maxMessages = $query['num_rows'];
1538 1537
 		//error_log(__METHOD__.__LINE__.array2string($query));
1539
-		$sort = ($query['order']=='address'?($toSchema?'toaddress':'fromaddress'):$query['order']);
1540
-		if (!empty($query['search'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate']))))
1538
+		$sort = ($query['order'] == 'address' ? ($toSchema ? 'toaddress' : 'fromaddress') : $query['order']);
1539
+		if (!empty($query['search']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate']))))
1541 1540
 		{
1542 1541
 			if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]))
1543 1542
 			{
1544
-				Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
1543
+				Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
1545 1544
 				if (!isset(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]))
1546 1545
 				{
1547
-					Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]=true;
1546
+					Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] = true;
1548 1547
 				}
1549 1548
 			}
1550 1549
 			//error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']);
1551 1550
 			$cutoffdate = $cutoffdate2 = null;
1552
-			if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
1553
-			if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
1551
+			if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate
1552
+			if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate
1554 1553
 			//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
1555 1554
 			$filter = array(
1556
-				'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
1557
-				'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')),
1555
+				'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ?lang('quicksearch') : lang('subject')),
1556
+				'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')),
1558 1557
 				'string' => $query['search'],
1559 1558
 				'status' => 'any',
1560 1559
 				//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
1561 1560
 			);
1562
-			if ($query['enddate']||$query['startdate']) {
1561
+			if ($query['enddate'] || $query['startdate']) {
1563 1562
 				$filter['range'] = "BETWEEN";
1564 1563
 				if ($cutoffdate) {
1565
-					$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
1564
+					$filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate);
1566 1565
 					if (empty($cutoffdate2)) $filter['range'] = "SINCE";
1567 1566
 				}
1568 1567
 				if ($cutoffdate2) {
1569
-					$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
1568
+					$filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2);
1570 1569
 					if (empty($cutoffdate)) $filter['range'] = "BEFORE";
1571 1570
 				}
1572 1571
 			}
@@ -1579,17 +1578,17 @@  discard block
 block discarded – undo
1579 1578
 		{
1580 1579
 			$filter['status'] = $query['filter'];
1581 1580
 		}
1582
-		$reverse = ($query['sort']=='ASC'?false:true);
1581
+		$reverse = ($query['sort'] == 'ASC' ?false:true);
1583 1582
 		$prefchanged = false;
1584
-		if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']) || ($query['cat_id'] !=$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']))
1583
+		if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']) || ($query['cat_id'] != $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']))
1585 1584
 		{
1586 1585
 			//error_log(__METHOD__.__LINE__.' Changing userPref ActivesearchType:'.$query['cat_id']);
1587
-			$GLOBALS['egw']->preferences->add('mail','ActiveSearchType',$query['cat_id'],'user');
1586
+			$GLOBALS['egw']->preferences->add('mail', 'ActiveSearchType', $query['cat_id'], 'user');
1588 1587
 			$prefchanged = true;
1589 1588
 		}
1590
-		if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']) || ($query['filter2'] !=$GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']))
1589
+		if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']) || ($query['filter2'] != $GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']))
1591 1590
 		{
1592
-			$GLOBALS['egw']->preferences->add('mail','ShowDetails',$query['filter2'],'user');
1591
+			$GLOBALS['egw']->preferences->add('mail', 'ShowDetails', $query['filter2'], 'user');
1593 1592
 			$prefchanged = true;
1594 1593
 		}
1595 1594
 		if ($prefchanged)
@@ -1620,13 +1619,13 @@  discard block
 block discarded – undo
1620 1619
 				$rowsFetched['messages'] = $_sR['count'];
1621 1620
 				$ids = $_sR['match']->ids;
1622 1621
 				// if $sR is false, something failed fundamentally
1623
-				if($reverse === true) $ids = ($ids===false?array():array_reverse((array)$ids));
1624
-				$sR = array_slice((array)$ids,($offset==0?0:$offset-1),$maxMessages); // we need only $maxMessages of uids
1625
-				$sRToFetch = $sR;//array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids
1622
+				if ($reverse === true) $ids = ($ids === false ? array() : array_reverse((array)$ids));
1623
+				$sR = array_slice((array)$ids, ($offset == 0 ? 0 : $offset - 1), $maxMessages); // we need only $maxMessages of uids
1624
+				$sRToFetch = $sR; //array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids
1626 1625
 				//error_log(__METHOD__.__LINE__.' Rows fetched (UID only):'.count($sR).' Data:'.array2string($sR));
1627 1626
 				$maxMessages = 75;
1628 1627
 				$sortResultwH['header'] = array();
1629
-				if (count($sRToFetch)>0)
1628
+				if (count($sRToFetch) > 0)
1630 1629
 				{
1631 1630
 					//error_log(__METHOD__.__LINE__.' Headers to fetch with UIDs:'.count($sRToFetch).' Data:'.array2string($sRToFetch));
1632 1631
 					$sortResult = array();
@@ -1640,7 +1639,7 @@  discard block
 block discarded – undo
1640 1639
 						$filter,
1641 1640
 						$sRToFetch,
1642 1641
 						true, //cacheResult
1643
-						($query['filter2']?true:false) // fetchPreview
1642
+						($query['filter2'] ?true:false) // fetchPreview
1644 1643
 					);
1645 1644
 				}
1646 1645
 			}
@@ -1657,30 +1656,30 @@  discard block
 block discarded – undo
1657 1656
 					$filter,
1658 1657
 					null, // this uids only
1659 1658
 					true, // cacheResult
1660
-					($query['filter2']?true:false) // fetchPreview
1659
+					($query['filter2'] ?true:false) // fetchPreview
1661 1660
 				);
1662 1661
 				$rowsFetched['messages'] = $sortResultwH['info']['total'];
1663 1662
 			}
1664 1663
 		}
1665 1664
 		catch (Exception $e)
1666 1665
 		{
1667
-			$sortResultwH=array();
1668
-			$sR=array();
1666
+			$sortResultwH = array();
1667
+			$sR = array();
1669 1668
 			self::callWizard($e->getMessage(), false, 'error');
1670 1669
 		}
1671 1670
 		$response = Api\Json\Response::get();
1672 1671
 		// unlock immediately after fetching the rows
1673
-		if (stripos($_GET['menuaction'],'ajax_get_rows')!==false)
1672
+		if (stripos($_GET['menuaction'], 'ajax_get_rows') !== false)
1674 1673
 		{
1675 1674
 			//error_log(__METHOD__.__LINE__.' unlock tree ->'.$_GET['menuaction']);
1676 1675
 			$response->call('app.mail.unlock_tree');
1677 1676
 		}
1678 1677
 
1679
-		if (is_array($sR) && count($sR)>0)
1678
+		if (is_array($sR) && count($sR) > 0)
1680 1679
 		{
1681 1680
 			foreach ((array)$sR as $key => $v)
1682 1681
 			{
1683
-				if (array_key_exists($key,(array)$sortResultwH['header'])==true)
1682
+				if (array_key_exists($key, (array)$sortResultwH['header']) == true)
1684 1683
 				{
1685 1684
 					$sortResult['header'][] = $sortResultwH['header'][$key];
1686 1685
 				}
@@ -1698,16 +1697,16 @@  discard block
 block discarded – undo
1698 1697
 		if (empty($rowsFetched['messages'])) $rowsFetched['messages'] = $rowsFetched['rowsFetched'];
1699 1698
 
1700 1699
 		//error_log(__METHOD__.__LINE__.' Rows fetched:'.$rowsFetched.' Data:'.array2string($sortResult));
1701
-		$cols = array('row_id','uid','status','attachments','subject','address','toaddress','fromaddress','ccaddress','additionaltoaddress','date','size','modified','bodypreview', 'security');
1702
-		if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE') unset($cols[0]);
1703
-		$rows = $mail_ui->header2gridelements($sortResult['header'],$cols, $_folderName, $folderType=$toSchema);
1700
+		$cols = array('row_id', 'uid', 'status', 'attachments', 'subject', 'address', 'toaddress', 'fromaddress', 'ccaddress', 'additionaltoaddress', 'date', 'size', 'modified', 'bodypreview', 'security');
1701
+		if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode'] == 'EGW_SELECTMODE_TOGGLE') unset($cols[0]);
1702
+		$rows = $mail_ui->header2gridelements($sortResult['header'], $cols, $_folderName, $folderType = $toSchema);
1704 1703
 
1705 1704
 		// Save the session (since we are committing session) at the end
1706 1705
 		// to make sure all necessary data are stored in session.
1707 1706
 		// e.g.: Link:: get_data which is used to read attachments data.
1708 1707
 		$mail_ui->mail_bo->saveSessionData();
1709 1708
 
1710
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__);
1709
+		if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, 'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'], __METHOD__.__LINE__);
1711 1710
 		return $rowsFetched['messages'];
1712 1711
 	}
1713 1712
 
@@ -1719,7 +1718,7 @@  discard block
 block discarded – undo
1719 1718
 	 * @param boolean $_prependApp to indicate that the app 'mail' is to be used for creating the rowID
1720 1719
 	 * @return string - a colon separated string in the form [app:]accountID:profileID:folder:message_uid
1721 1720
 	 */
1722
-	function createRowID($_folderName, $message_uid, $_prependApp=false)
1721
+	function createRowID($_folderName, $message_uid, $_prependApp = false)
1723 1722
 	{
1724 1723
 		return self::generateRowID($this->mail_bo->profileID, $_folderName, $message_uid, $_prependApp);
1725 1724
 	}
@@ -1733,9 +1732,9 @@  discard block
 block discarded – undo
1733 1732
 	 * @param boolean $_prependApp to indicate that the app 'mail' is to be used for creating the rowID
1734 1733
 	 * @return string - a colon separated string in the form [app:]accountID:profileID:folder:message_uid
1735 1734
 	 */
1736
-	static function generateRowID($_profileID, $_folderName, $message_uid, $_prependApp=false)
1735
+	static function generateRowID($_profileID, $_folderName, $message_uid, $_prependApp = false)
1737 1736
 	{
1738
-		return ($_prependApp?'mail'.self::$delimiter:'').trim($GLOBALS['egw_info']['user']['account_id']).self::$delimiter.$_profileID.self::$delimiter.base64_encode($_folderName).self::$delimiter.$message_uid;
1737
+		return ($_prependApp ? 'mail'.self::$delimiter : '').trim($GLOBALS['egw_info']['user']['account_id']).self::$delimiter.$_profileID.self::$delimiter.base64_encode($_folderName).self::$delimiter.$message_uid;
1739 1738
 	}
1740 1739
 
1741 1740
 	/**
@@ -1746,13 +1745,13 @@  discard block
 block discarded – undo
1746 1745
 	 */
1747 1746
 	static function splitRowID($_rowID)
1748 1747
 	{
1749
-		$res = explode(self::$delimiter,$_rowID);
1748
+		$res = explode(self::$delimiter, $_rowID);
1750 1749
 		// as a rowID is perceeded by app::, should be mail!
1751 1750
 		//error_log(__METHOD__.__LINE__.array2string($res).' [0] isInt:'.is_int($res[0]).' [0] isNumeric:'.is_numeric($res[0]).' [0] isString:'.is_string($res[0]).' Count:'.count($res));
1752
-		if (count($res)==4 && is_numeric($res[0]) )
1751
+		if (count($res) == 4 && is_numeric($res[0]))
1753 1752
 		{
1754 1753
 			// we have an own created rowID; prepend app=mail
1755
-			array_unshift($res,'mail');
1754
+			array_unshift($res, 'mail');
1756 1755
 		}
1757 1756
 		return array('app'=>$res[0], 'accountID'=>$res[1], 'profileID'=>$res[2], 'folder'=>base64_decode($res[3]), 'msgUID'=>$res[4]);
1758 1757
 	}
@@ -1766,60 +1765,60 @@  discard block
 block discarded – undo
1766 1765
 	{
1767 1766
 		$actions = $this->get_actions();
1768 1767
 		$arrActions = array('composeasnew', 'reply', 'reply_all', 'forward', 'flagged', 'delete', 'print',
1769
-			'infolog', 'tracker', 'calendar', 'save', 'view', 'read', 'label1',	'label2', 'label3',	'label4', 'label5','spam', 'ham');
1770
-		foreach( $arrActions as &$act)
1768
+			'infolog', 'tracker', 'calendar', 'save', 'view', 'read', 'label1', 'label2', 'label3', 'label4', 'label5', 'spam', 'ham');
1769
+		foreach ($arrActions as &$act)
1771 1770
 		{
1772 1771
 			//error_log(__METHOD__.__LINE__.' '.$act.'->'.array2string($actions[$act]));
1773 1772
 			switch ($act)
1774 1773
 			{
1775 1774
 				case 'forward':
1776
-					$actionsenabled[$act]=$actions[$act];
1775
+					$actionsenabled[$act] = $actions[$act];
1777 1776
 					break;
1778 1777
 				case 'save':
1779
-					$actionsenabled[$act]=$actions[$act];
1778
+					$actionsenabled[$act] = $actions[$act];
1780 1779
 
1781 1780
 					break;
1782 1781
 				case 'view':
1783
-					$actionsenabled[$act]=$actions[$act];
1782
+					$actionsenabled[$act] = $actions[$act];
1784 1783
 					break;
1785 1784
 				case 'flagged':
1786
-					$actionsenabled[$act]= $actions['mark']['children'][$act];
1785
+					$actionsenabled[$act] = $actions['mark']['children'][$act];
1787 1786
 					break;
1788 1787
 				case 'read':
1789
-					$actionsenabled[$act]= $actions['mark']['children'][$act];
1788
+					$actionsenabled[$act] = $actions['mark']['children'][$act];
1790 1789
 					break;
1791 1790
 				case 'label1':
1792 1791
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('important');
1793
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1792
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1794 1793
 					break;
1795 1794
 				case 'label2':
1796 1795
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('job');
1797
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1796
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1798 1797
 					break;
1799 1798
 				case 'label3':
1800 1799
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('personal');
1801
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1800
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1802 1801
 					break;
1803 1802
 				case 'label4':
1804 1803
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('to do');
1805
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1804
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1806 1805
 					break;
1807 1806
 				case 'label5':
1808 1807
 					$actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('later');
1809
-					$actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act];
1808
+					$actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act];
1810 1809
 					break;
1811 1810
 				case 'ham':
1812 1811
 				case 'spam':
1813
-					$actionsenabled[$act]= $actions['spamfilter']['children'][$act];
1812
+					$actionsenabled[$act] = $actions['spamfilter']['children'][$act];
1814 1813
 					break;
1815 1814
 				default:
1816
-					if (isset($actions[$act])) $actionsenabled[$act]=$actions[$act];
1815
+					if (isset($actions[$act])) $actionsenabled[$act] = $actions[$act];
1817 1816
 			}
1818 1817
 		}
1819 1818
 		unset($actionsenabled['drag_mail']);
1820 1819
 		//error_log(array2string($actionsenabled['view']));
1821
-		unset($actionsenabled['view']['children']['openastext']);//not supported in preview
1822
-		unset($actionsenabled['view']['children']['openashtml']);//not supported in preview
1820
+		unset($actionsenabled['view']['children']['openastext']); //not supported in preview
1821
+		unset($actionsenabled['view']['children']['openashtml']); //not supported in preview
1823 1822
 
1824 1823
 		return $actionsenabled;
1825 1824
 	}
@@ -1833,51 +1832,51 @@  discard block
 block discarded – undo
1833 1832
 	 * @param array $_folderType used to determine if we need to populate from/to
1834 1833
 	 * @return array populated result array
1835 1834
 	 */
1836
-	public function header2gridelements($_headers, $cols, $_folderName, $_folderType=0)
1835
+	public function header2gridelements($_headers, $cols, $_folderName, $_folderType = 0)
1837 1836
 	{
1838 1837
 		if (Mail::$debugTimes) $starttime = microtime(true);
1839 1838
 		$rv = array();
1840
-		$i=0;
1841
-		foreach((array)$_headers as $header)
1839
+		$i = 0;
1840
+		foreach ((array)$_headers as $header)
1842 1841
 		{
1843 1842
 			$i++;
1844 1843
 			$data = array();
1845 1844
 			//error_log(__METHOD__.array2string($header));
1846 1845
 			$message_uid = $header['uid'];
1847 1846
 			$data['uid'] = $message_uid;
1848
-			$data['row_id']=$this->createRowID($_folderName,$message_uid);
1847
+			$data['row_id'] = $this->createRowID($_folderName, $message_uid);
1849 1848
 
1850 1849
 			if ($header['smimeType'])
1851 1850
 			{
1852
-				$data['smime'] = Mail\Smime::isSmimeSignatureOnly($header['smimeType'])?
1851
+				$data['smime'] = Mail\Smime::isSmimeSignatureOnly($header['smimeType']) ?
1853 1852
 				Mail\Smime::TYPE_SIGN : Mail\Smime::TYPE_ENCRYPT;
1854 1853
 			}
1855 1854
 
1856 1855
 			$flags = "";
1857
-			if(!empty($header['recent'])) $flags .= "R";
1858
-			if(!empty($header['flagged'])) $flags .= "F";
1859
-			if(!empty($header['answered'])) $flags .= "A";
1860
-			if(!empty($header['forwarded'])) $flags .= "W";
1861
-			if(!empty($header['deleted'])) $flags .= "D";
1862
-			if(!empty($header['seen'])) $flags .= "S";
1863
-			if(!empty($header['label1'])) $flags .= "1";
1864
-			if(!empty($header['label2'])) $flags .= "2";
1865
-			if(!empty($header['label3'])) $flags .= "3";
1866
-			if(!empty($header['label4'])) $flags .= "4";
1867
-			if(!empty($header['label5'])) $flags .= "5";
1856
+			if (!empty($header['recent'])) $flags .= "R";
1857
+			if (!empty($header['flagged'])) $flags .= "F";
1858
+			if (!empty($header['answered'])) $flags .= "A";
1859
+			if (!empty($header['forwarded'])) $flags .= "W";
1860
+			if (!empty($header['deleted'])) $flags .= "D";
1861
+			if (!empty($header['seen'])) $flags .= "S";
1862
+			if (!empty($header['label1'])) $flags .= "1";
1863
+			if (!empty($header['label2'])) $flags .= "2";
1864
+			if (!empty($header['label3'])) $flags .= "3";
1865
+			if (!empty($header['label4'])) $flags .= "4";
1866
+			if (!empty($header['label5'])) $flags .= "5";
1868 1867
 
1869 1868
 			$data["status"] = "<span class=\"status_img\"></span>";
1870 1869
 			//error_log(__METHOD__.array2string($header).' Flags:'.$flags);
1871 1870
 
1872 1871
 			// the css for this row
1873
-			$is_recent=false;
1872
+			$is_recent = false;
1874 1873
 			$css_styles = array("mail");
1875 1874
 			if ($header['deleted']) {
1876 1875
 				$css_styles[] = 'deleted';
1877 1876
 			}
1878 1877
 			if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded'])) {
1879 1878
 				$css_styles[] = 'recent';
1880
-				$is_recent=true;
1879
+				$is_recent = true;
1881 1880
 			}
1882 1881
 			if ($header['priority'] < 3) {
1883 1882
 				$css_styles[] = 'prio_high';
@@ -1915,19 +1914,19 @@  discard block
 block discarded – undo
1915 1914
 			if (in_array("subject", $cols))
1916 1915
 			{
1917 1916
 				// filter out undisplayable characters
1918
-				$search = array('[\016]','[\017]',
1919
-					'[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]',
1920
-					'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
1917
+				$search = array('[\016]', '[\017]',
1918
+					'[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]',
1919
+					'[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]');
1921 1920
 				$replace = '';
1922 1921
 
1923
-				$header['subject'] = preg_replace($search,$replace,$header['subject']);
1922
+				$header['subject'] = preg_replace($search, $replace, $header['subject']);
1924 1923
 				// curly brackets get messed up by the template!
1925 1924
 
1926 1925
 				if (!empty($header['subject'])) {
1927 1926
 					// make the subject shorter if it is to long
1928 1927
 					$subject = $header['subject'];
1929 1928
 				} else {
1930
-					$subject = '('. lang('no subject') .')';
1929
+					$subject = '('.lang('no subject').')';
1931 1930
 				}
1932 1931
 
1933 1932
 				$data["subject"] = $subject; // the mailsubject
@@ -1941,22 +1940,22 @@  discard block
 block discarded – undo
1941 1940
 						'multipart/mixed', 'multipart/signed', 'multipart/related', 'multipart/report',
1942 1941
 						'text/calendar', 'text/html', 'multipart/alternative',
1943 1942
 					)) ||
1944
-					substr($header['mimetype'],0,11) == 'application' ||
1945
-					substr($header['mimetype'],0,5) == 'audio' ||
1946
-					substr($header['mimetype'],0,5) == 'video'))
1943
+					substr($header['mimetype'], 0, 11) == 'application' ||
1944
+					substr($header['mimetype'], 0, 5) == 'audio' ||
1945
+					substr($header['mimetype'], 0, 5) == 'video'))
1947 1946
 				{
1948
-					$image = Api\Html::image('mail','attach');
1949
-					$datarowid = $this->createRowID($_folderName,$message_uid,true);
1947
+					$image = Api\Html::image('mail', 'attach');
1948
+					$datarowid = $this->createRowID($_folderName, $message_uid, true);
1950 1949
 					$attachments = $header['attachments'];
1951 1950
 					if (count($attachments) == 1)
1952 1951
 					{
1953
-						$image = Api\Html::image('mail','attach',$attachments[0]['name'].(!empty($attachments[0]['mimeType'])?' ('.$attachments[0]['mimeType'].')':''));
1952
+						$image = Api\Html::image('mail', 'attach', $attachments[0]['name'].(!empty($attachments[0]['mimeType']) ? ' ('.$attachments[0]['mimeType'].')' : ''));
1954 1953
 					}
1955 1954
 					else
1956 1955
 					{
1957
-						$image = Api\Html::image('mail','attach',lang('%1 attachments',count($attachments)));
1956
+						$image = Api\Html::image('mail', 'attach', lang('%1 attachments', count($attachments)));
1958 1957
 					}
1959
-					$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'],$_folderName);
1958
+					$imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'], $_folderName);
1960 1959
 
1961 1960
 					$attachmentFlag = $image;
1962 1961
 				}
@@ -1968,21 +1967,21 @@  discard block
 block discarded – undo
1968 1967
 				// show priority flag
1969 1968
 				if ($header['priority'] < 3)
1970 1969
 				{
1971
-					 $image = Api\Html::image('mail','prio_high');
1970
+					 $image = Api\Html::image('mail', 'prio_high');
1972 1971
 				}
1973 1972
 				elseif ($header['priority'] > 3)
1974 1973
 				{
1975
-					$image = Api\Html::image('mail','prio_low');
1974
+					$image = Api\Html::image('mail', 'prio_low');
1976 1975
 				}
1977 1976
 				else
1978 1977
 				{
1979 1978
 					$image = '';
1980 1979
 				}
1981 1980
 				// show a flag for flagged messages
1982
-				$imageflagged ='';
1981
+				$imageflagged = '';
1983 1982
 				if ($header['flagged'])
1984 1983
 				{
1985
-					$imageflagged = Api\Html::image('mail','unread_flagged_small');
1984
+					$imageflagged = Api\Html::image('mail', 'unread_flagged_small');
1986 1985
 				}
1987 1986
 				$data["attachments"] = $image.$attachmentFlag.$imageflagged; // icon for attachments available
1988 1987
 			}
@@ -1991,7 +1990,7 @@  discard block
 block discarded – undo
1991 1990
 			if (in_array("toaddress", $cols))
1992 1991
 			{
1993 1992
 				// sent or drafts or template folder means foldertype > 0, use to address instead of from
1994
-				$data["toaddress"] = $header['to_address'];//Mail::htmlentities($header['to_address'],$this->charset);
1993
+				$data["toaddress"] = $header['to_address']; //Mail::htmlentities($header['to_address'],$this->charset);
1995 1994
 			}
1996 1995
 
1997 1996
 			if (in_array("additionaltoaddress", $cols))
@@ -2025,29 +2024,29 @@  discard block
 block discarded – undo
2025 2024
 			$data['flags'] = Array();
2026 2025
 			if ($header['seen']) $data["flags"]['read'] = 'read';
2027 2026
 			foreach ($css_styles as &$flag) {
2028
-				if ($flag!='mail')
2027
+				if ($flag != 'mail')
2029 2028
 				{
2030
-					if ($flag=='labelone') {$data["flags"]['label1'] = 'label1';}
2031
-					elseif ($flag=='labeltwo') {$data["flags"]['label2'] = 'label2';}
2032
-					elseif ($flag=='labelthree') {$data["flags"]['label3'] = 'label3';}
2033
-					elseif ($flag=='labelfour') {$data["flags"]['label4'] = 'label4';}
2034
-					elseif ($flag=='labelfive') {$data["flags"]['label5'] = 'label5';}
2035
-					elseif ($flag=='unseen') {unset($data["flags"]['read']);}
2029
+					if ($flag == 'labelone') {$data["flags"]['label1'] = 'label1'; }
2030
+					elseif ($flag == 'labeltwo') {$data["flags"]['label2'] = 'label2'; }
2031
+					elseif ($flag == 'labelthree') {$data["flags"]['label3'] = 'label3'; }
2032
+					elseif ($flag == 'labelfour') {$data["flags"]['label4'] = 'label4'; }
2033
+					elseif ($flag == 'labelfive') {$data["flags"]['label5'] = 'label5'; }
2034
+					elseif ($flag == 'unseen') {unset($data["flags"]['read']); }
2036 2035
 					else $data["flags"][$flag] = $flag;
2037 2036
 				}
2038 2037
 			}
2039 2038
 			if ($header['disposition-notification-to']) $data['dispositionnotificationto'] = $header['disposition-notification-to'];
2040
-			if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']);
2039
+			if (($header['mdnsent'] || $header['mdnnotsent']|$header['seen']) && isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']);
2041 2040
 			$data['attachmentsBlock'] = $imageHTMLBlock;
2042
-			$data['address'] = ($_folderType?$data["toaddress"]:$data["fromaddress"]);
2043
-			if (in_array("bodypreview", $cols)&&$header['bodypreview'])
2041
+			$data['address'] = ($_folderType ? $data["toaddress"] : $data["fromaddress"]);
2042
+			if (in_array("bodypreview", $cols) && $header['bodypreview'])
2044 2043
 			{
2045 2044
 				$data["bodypreview"] = $header['bodypreview'];
2046 2045
 			}
2047 2046
 			$rv[] = $data;
2048 2047
 			//error_log(__METHOD__.__LINE__.array2string($data));
2049 2048
 		}
2050
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__);
2049
+		if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, 'Folder:'.$_folderName, __METHOD__.__LINE__);
2051 2050
 
2052 2051
 		// ToDo: call this ONLY if labels change
2053 2052
 		Etemplate\Widget::setElementAttribute('toolbar', 'actions', $this->get_toolbar_actions());
@@ -2062,8 +2061,8 @@  discard block
 block discarded – undo
2062 2061
 	 */
2063 2062
 	function displayHeader()
2064 2063
 	{
2065
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
2066
-		if(isset($_GET['part'])) $partID = $_GET['part'];
2064
+		if (isset($_GET['id'])) $rowID = $_GET['id'];
2065
+		if (isset($_GET['part'])) $partID = $_GET['part'];
2067 2066
 
2068 2067
 		$hA = self::splitRowID($rowID);
2069 2068
 		$uid = $hA['msgUID'];
@@ -2077,17 +2076,17 @@  discard block
 block discarded – undo
2077 2076
 		}
2078 2077
 
2079 2078
 		$this->mail_bo->reopen($mailbox);
2080
-		$headers_in	= $this->mail_bo->getMessageRawHeader($uid, $partID);
2079
+		$headers_in = $this->mail_bo->getMessageRawHeader($uid, $partID);
2081 2080
 
2082 2081
 		// add line breaks to $rawheaders
2083
-		$newRawHeaders = explode("\n",$headers_in);
2082
+		$newRawHeaders = explode("\n", $headers_in);
2084 2083
 		reset($newRawHeaders);
2085 2084
 
2086 2085
 		// reset $rawheaders
2087
-		$rawheaders 	= "";
2086
+		$rawheaders = "";
2088 2087
 		// create it new, with good line breaks
2089 2088
 		reset($newRawHeaders);
2090
-		while(list($key,$value) = @each($newRawHeaders)) {
2089
+		while (list($key, $value) = @each($newRawHeaders)) {
2091 2090
 			$rawheaders .= wordwrap($value, 90, "\n     ");
2092 2091
 		}
2093 2092
 
@@ -2099,7 +2098,7 @@  discard block
 block discarded – undo
2099 2098
 		}
2100 2099
 
2101 2100
 		header('Content-type: text/html; charset=iso-8859-1');
2102
-		print '<pre>'. htmlspecialchars($rawheaders, ENT_NOQUOTES, 'iso-8859-1') .'</pre>';
2101
+		print '<pre>'.htmlspecialchars($rawheaders, ENT_NOQUOTES, 'iso-8859-1').'</pre>';
2103 2102
 
2104 2103
 	}
2105 2104
 
@@ -2112,10 +2111,10 @@  discard block
 block discarded – undo
2112 2111
 	{
2113 2112
 		if (is_null($_requesteddata)) $_requesteddata = $_GET;
2114 2113
 
2115
-		$preventRedirect=false;
2116
-		if(isset($_requesteddata['id'])) $rowID	= $_requesteddata['id'];
2117
-		if(isset($_requesteddata['part'])) $partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null;
2118
-		if(isset($_requesteddata['mode'])) $preventRedirect   = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false);
2114
+		$preventRedirect = false;
2115
+		if (isset($_requesteddata['id'])) $rowID = $_requesteddata['id'];
2116
+		if (isset($_requesteddata['part'])) $partID = $_requesteddata['part'] != 'null' ? $_requesteddata['part'] : null;
2117
+		if (isset($_requesteddata['mode'])) $preventRedirect = (($_requesteddata['mode'] == 'display' || $_requesteddata['mode'] == 'print') ?true:false);
2119 2118
 
2120 2119
 		$hA = self::splitRowID($rowID);
2121 2120
 		$uid = $hA['msgUID'];
@@ -2139,32 +2138,32 @@  discard block
 block discarded – undo
2139 2138
 		}
2140 2139
 		if (!$preventRedirect && ($this->mail_bo->isDraftFolder($mailbox) || $this->mail_bo->isTemplateFolder($mailbox)))
2141 2140
 		{
2142
-			Egw::redirect_link('/index.php',array('menuaction'=>'mail.mail_compose.compose','id'=>$rowID,'from'=>'composefromdraft'));
2141
+			Egw::redirect_link('/index.php', array('menuaction'=>'mail.mail_compose.compose', 'id'=>$rowID, 'from'=>'composefromdraft'));
2143 2142
 		}
2144 2143
 		$this->mail_bo->reopen($mailbox);
2145 2144
 		// retrieve the flags of the message, before touching it.
2146 2145
 		try
2147 2146
 		{
2148
-			$headers	= $this->mail_bo->getMessageHeader($uid, $partID,true,true,$mailbox);
2147
+			$headers = $this->mail_bo->getMessageHeader($uid, $partID, true, true, $mailbox);
2149 2148
 		}
2150 2149
 		catch (Api\Exception $e)
2151 2150
 		{
2152 2151
 			$error_msg[] = lang("ERROR: Message could not be displayed.");
2153
-			$error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3",$mailbox,$uid,$partID);
2152
+			$error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3", $mailbox, $uid, $partID);
2154 2153
 			Framework::message($e->getMessage(), 'error');
2155 2154
 		}
2156 2155
 		if (!empty($uid)) $this->mail_bo->getFlags($uid);
2157
-		$envelope	= $this->mail_bo->getMessageEnvelope($uid, $partID,true,$mailbox);
2156
+		$envelope = $this->mail_bo->getMessageEnvelope($uid, $partID, true, $mailbox);
2158 2157
 		//error_log(__METHOD__.__LINE__.array2string($envelope));
2159
-		$this->mail_bo->getMessageRawHeader($uid, $partID,$mailbox);
2158
+		$this->mail_bo->getMessageRawHeader($uid, $partID, $mailbox);
2160 2159
 		$fetchEmbeddedImages = false;
2161 2160
 		// if we are in HTML so its likely that we should show the embedded images; as a result
2162 2161
 		// we do NOT want to see those, that are embedded in the list of attachments
2163
-		if ($htmlOptions !='always_display') $fetchEmbeddedImages = true;
2164
-		try{
2165
-			$attachments = $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages,true,true,$mailbox);
2162
+		if ($htmlOptions != 'always_display') $fetchEmbeddedImages = true;
2163
+		try {
2164
+			$attachments = $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages, true, true, $mailbox);
2166 2165
 		}
2167
-		catch(Mail\Smime\PassphraseMissing $e)
2166
+		catch (Mail\Smime\PassphraseMissing $e)
2168 2167
 		{
2169 2168
 			//continue
2170 2169
 		}
@@ -2172,53 +2171,53 @@  discard block
 block discarded – undo
2172 2171
 		//error_log(__METHOD__.__LINE__.array2string($attachments));
2173 2172
 		$attachmentHTMLBlock = self::createAttachmentBlock($attachments, $rowID, $uid, $mailbox);
2174 2173
 
2175
-		$nonDisplayAbleCharacters = array('[\016]','[\017]',
2176
-				'[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]',
2177
-				'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
2174
+		$nonDisplayAbleCharacters = array('[\016]', '[\017]',
2175
+				'[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]',
2176
+				'[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]');
2178 2177
 
2179 2178
 		//error_log(__METHOD__.__LINE__.$mailBody);
2180 2179
 		$this->mail_bo->closeConnection();
2181 2180
 		//$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed
2182 2181
 		$etpl = new Etemplate('mail.display');
2183
-		$subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters,'',$envelope['SUBJECT']),false);
2182
+		$subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters, '', $envelope['SUBJECT']), false);
2184 2183
 
2185 2184
 		// Set up data for taglist widget(s)
2186
-		if ($envelope['FROM']==$envelope['SENDER']) unset($envelope['SENDER']);
2185
+		if ($envelope['FROM'] == $envelope['SENDER']) unset($envelope['SENDER']);
2187 2186
 		$sel_options = array();
2188
-		foreach(array('SENDER','FROM','TO','CC','BCC') as $field)
2187
+		foreach (array('SENDER', 'FROM', 'TO', 'CC', 'BCC') as $field)
2189 2188
 		{
2190 2189
 			if (!isset($envelope[$field])) continue;
2191
-			foreach($envelope[$field] as $field_data)
2190
+			foreach ($envelope[$field] as $field_data)
2192 2191
 			{
2193 2192
 				//error_log(__METHOD__.__LINE__.array2string($field_data));
2194 2193
 				$content[$field][] = $field_data;
2195 2194
 				$sel_options[$field][] = array(
2196 2195
 					// taglist requires these - not optional
2197 2196
 					'id' => $field_data,
2198
-					'label' => str_replace('"',"'",$field_data),
2197
+					'label' => str_replace('"', "'", $field_data),
2199 2198
 				);
2200 2199
 			}
2201 2200
 		}
2202 2201
 		$actionsenabled = $this->getDisplayToolbarActions();
2203 2202
 		$content['displayToolbaractions'] = json_encode($actionsenabled);
2204 2203
 		if (empty($subject)) $subject = lang('no subject');
2205
-		$content['msg'] = (is_array($error_msg)?implode("<br>",$error_msg):$error_msg);
2204
+		$content['msg'] = (is_array($error_msg) ?implode("<br>", $error_msg) : $error_msg);
2206 2205
 		// Send mail ID so we can use it for actions
2207 2206
 		$content['mail_id'] = $rowID;
2208 2207
 		if (!is_array($headers) || !isset($headers['DATE']))
2209 2208
 		{
2210
-			$headers['DATE'] = (is_array($envelope)&&$envelope['DATE']?$envelope['DATE']:'');
2209
+			$headers['DATE'] = (is_array($envelope) && $envelope['DATE'] ? $envelope['DATE'] : '');
2211 2210
 		}
2212
-		$content['mail_displaydate'] = Mail::_strtotime($headers['DATE'],'ts',true);
2211
+		$content['mail_displaydate'] = Mail::_strtotime($headers['DATE'], 'ts', true);
2213 2212
 		$content['mail_displaysubject'] = $subject;
2214
-		$linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody","_messageID"=>$rowID);
2215
-		if (!empty($partID)) $linkData['_partID']=$partID;
2216
-		if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions']=$htmlOptions;
2217
-		$content['mailDisplayBodySrc'] = Egw::link('/index.php',$linkData);
2213
+		$linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody", "_messageID"=>$rowID);
2214
+		if (!empty($partID)) $linkData['_partID'] = $partID;
2215
+		if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions'] = $htmlOptions;
2216
+		$content['mailDisplayBodySrc'] = Egw::link('/index.php', $linkData);
2218 2217
 		$content['mail_displayattachments'] = $attachmentHTMLBlock;
2219
-		$content['mail_id']=$rowID;
2220
-		$content['mailDisplayContainerClass']=(count($attachments)?"mailDisplayContainer mailDisplayContainerFixedHeight":"mailDisplayContainer mailDisplayContainerFullHeight");
2221
-		$content['mailDisplayAttachmentsClass']=(count($attachments)?"mailDisplayAttachments":"mail_DisplayNone");
2218
+		$content['mail_id'] = $rowID;
2219
+		$content['mailDisplayContainerClass'] = (count($attachments) ? "mailDisplayContainer mailDisplayContainerFixedHeight" : "mailDisplayContainer mailDisplayContainerFullHeight");
2220
+		$content['mailDisplayAttachmentsClass'] = (count($attachments) ? "mailDisplayAttachments" : "mail_DisplayNone");
2222 2221
 
2223 2222
 		// DRAG attachments actions
2224 2223
 		$etpl->setElementAttribute('mail_displayattachments', 'actions', array(
@@ -2235,7 +2234,7 @@  discard block
 block discarded – undo
2235 2234
 			$this->changeProfile($rememberServerID);
2236 2235
 		}
2237 2236
 
2238
-		$etpl->exec('mail.mail_ui.displayMessage',$content,$sel_options,$readonlys,$preserv,2);
2237
+		$etpl->exec('mail.mail_ui.displayMessage', $content, $sel_options, $readonlys, $preserv, 2);
2239 2238
 	}
2240 2239
 
2241 2240
 	/**
@@ -2244,7 +2243,7 @@  discard block
 block discarded – undo
2244 2243
 	 * @todo: Once we have socket push implemented we should
2245 2244
 	 * remove this function plus its client side companion.
2246 2245
 	 */
2247
-	function ajax_smimeAttachmentsChecker ()
2246
+	function ajax_smimeAttachmentsChecker()
2248 2247
 	{
2249 2248
 		$response = Api\Json\Response::get();
2250 2249
 		$response->data(true);
@@ -2254,7 +2253,7 @@  discard block
 block discarded – undo
2254 2253
 	 * Adds certificate to relevant contact
2255 2254
 	 * @param array $_metadata data of sender's certificate
2256 2255
 	 */
2257
-	function ajax_smimeAddCertToContact ($_metadata)
2256
+	function ajax_smimeAddCertToContact($_metadata)
2258 2257
 	{
2259 2258
 		$response = Api\Json\Response::get();
2260 2259
 		$ab = new addressbook_bo();
@@ -2267,12 +2266,12 @@  discard block
 block discarded – undo
2267 2266
 	 *
2268 2267
 	 * @param array $_data
2269 2268
 	 */
2270
-	function ajax_smimeGenCertificate ($_data)
2269
+	function ajax_smimeGenCertificate($_data)
2271 2270
 	{
2272 2271
 		$smime = new Mail\Smime();
2273 2272
 		$response = Api\Json\Response::get();
2274 2273
 		// fields need to be excluded from data
2275
-		$discards = array ('passphrase', 'passphraseConf', 'ca', 'validity');
2274
+		$discards = array('passphrase', 'passphraseConf', 'ca', 'validity');
2276 2275
 		$ca = $_data['ca'];
2277 2276
 		$passphrase = $_data['passphrase'];
2278 2277
 		foreach (array_keys($_data) as $key)
@@ -2300,16 +2299,16 @@  discard block
 block discarded – undo
2300 2299
 	/**
2301 2300
 	 * Build actions for display toolbar
2302 2301
 	 */
2303
-	function getDisplayToolbarActions ()
2302
+	function getDisplayToolbarActions()
2304 2303
 	{
2305 2304
 		$actions = $this->get_toolbar_actions();
2306
-		$actions['mark']['children']['flagged']=array(
2305
+		$actions['mark']['children']['flagged'] = array(
2307 2306
 			'group' => $actions['mark']['children']['flagged']['group'],
2308 2307
 			'caption' => 'Flagged',
2309 2308
 			'icon' => 'unread_flagged_small',
2310 2309
 			'onExecute' => 'javaScript:app.mail.mail_flag',
2311 2310
 		);
2312
-		$actions['mark']['children']['unflagged']=array(
2311
+		$actions['mark']['children']['unflagged'] = array(
2313 2312
 			'group' => $actions['mark']['children']['flagged']['group'],
2314 2313
 			'caption' => 'Unflagged',
2315 2314
 			'icon' => 'read_flagged_small',
@@ -2321,9 +2320,9 @@  discard block
 block discarded – undo
2321 2320
 		$compose = $actions['composeasnew'];
2322 2321
 		unset($actions['composeasnew']);
2323 2322
 
2324
-		$actions2 = array_reverse($actions,true);
2325
-		$actions2['composeasnew']= $compose;
2326
-		return array_reverse($actions2,true);
2323
+		$actions2 = array_reverse($actions, true);
2324
+		$actions2['composeasnew'] = $compose;
2325
+		return array_reverse($actions2, true);
2327 2326
 	}
2328 2327
 
2329 2328
 	/**
@@ -2336,9 +2335,9 @@  discard block
 block discarded – undo
2336 2335
 	 * @param boolean $_returnFullHTML flag wether to return HTML or data array
2337 2336
 	 * @return array|string data array or html or empty string
2338 2337
 	 */
2339
-	static function createAttachmentBlock($attachments, $rowID, $uid, $mailbox,$_returnFullHTML=false)
2338
+	static function createAttachmentBlock($attachments, $rowID, $uid, $mailbox, $_returnFullHTML = false)
2340 2339
 	{
2341
-		$attachmentHTMLBlock='';
2340
+		$attachmentHTMLBlock = '';
2342 2341
 		$attachmentHTML = array();
2343 2342
 
2344 2343
 		// skip message/delivery-status and set a title for original eml file
@@ -2356,12 +2355,12 @@  discard block
 block discarded – undo
2356 2355
 			foreach ($attachments as $key => $value)
2357 2356
 			{
2358 2357
 				if (Mail\Smime::isSmime($value['mimeType'])) continue;
2359
-				$attachmentHTML[$key]['filename']= ($value['name'] ? ( $value['filename'] ? $value['filename'] : $value['name'] ) : lang('(no subject)'));
2360
-				$attachmentHTML[$key]['filename'] = Api\Translation::convert_jsonsafe($attachmentHTML[$key]['filename'],'utf-8');
2358
+				$attachmentHTML[$key]['filename'] = ($value['name'] ? ($value['filename'] ? $value['filename'] : $value['name']) : lang('(no subject)'));
2359
+				$attachmentHTML[$key]['filename'] = Api\Translation::convert_jsonsafe($attachmentHTML[$key]['filename'], 'utf-8');
2361 2360
 				//error_log(array2string($value));
2362 2361
 				//error_log(strtoupper($value['mimeType']) .'<->'. Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']));
2363
-				if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) $value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']);
2364
-				$attachmentHTML[$key]['type']=$value['mimeType'];
2362
+				if (strtoupper($value['mimeType'] == 'APPLICATION/OCTET-STREAM')) $value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']);
2363
+				$attachmentHTML[$key]['type'] = $value['mimeType'];
2365 2364
 				$attachmentHTML[$key]['mimetype'] = Api\MimeMagic::mime2label($value['mimeType']);
2366 2365
 				$hA = self::splitRowID($rowID);
2367 2366
 				$uid = $hA['msgUID'];
@@ -2371,29 +2370,28 @@  discard block
 block discarded – undo
2371 2370
 				$attachmentHTML[$key]['mime_data'] = Link::set_data($value['mimeType'], 'EGroupware\\Api\\Mail::getAttachmentAccount', array(
2372 2371
 					$acc_id, $mailbox, $uid, $value['partID'], $value['is_winmail'], true
2373 2372
 				));
2374
-				$attachmentHTML[$key]['size']=Vfs::hsize($value['size']);
2375
-				$attachmentHTML[$key]['attachment_number']=$key;
2376
-				$attachmentHTML[$key]['partID']=$value['partID'];
2373
+				$attachmentHTML[$key]['size'] = Vfs::hsize($value['size']);
2374
+				$attachmentHTML[$key]['attachment_number'] = $key;
2375
+				$attachmentHTML[$key]['partID'] = $value['partID'];
2377 2376
 				$attachmentHTML[$key]['mail_id'] = $rowID;
2378
-				$attachmentHTML[$key]['winmailFlag']=$value['is_winmail'];
2377
+				$attachmentHTML[$key]['winmailFlag'] = $value['is_winmail'];
2379 2378
 				$attachmentHTML[$key]['classSaveAllPossiblyDisabled'] = "mail_DisplayNone";
2380 2379
 				$attachmentHTML[$key]['smime_type'] = $value['smime_type'];
2381 2380
 				// reset mode array as it should be considered differently for
2382 2381
 				// each attachment
2383 2382
 				$mode = array();
2384
-				switch(strtoupper($value['mimeType']))
2383
+				switch (strtoupper($value['mimeType']))
2385 2384
 				{
2386 2385
 					case 'MESSAGE/RFC822':
2387
-						$linkData = array
2388
-						(
2386
+						$linkData = array(
2389 2387
 							'menuaction'	=> 'mail.mail_ui.displayMessage',
2390 2388
 							'mode'		=> 'display', //message/rfc822 attachments should be opened in display mode
2391 2389
 							'id'		=> $rowID,
2392 2390
 							'part'		=> $value['partID'],
2393 2391
 							'is_winmail'    => $value['is_winmail']
2394 2392
 						);
2395
-						$windowName = 'displayMessage_'. $rowID.'_'.$value['partID'];
2396
-						$linkView = "egw_openWindowCentered('".Egw::link('/index.php',$linkData)."','$windowName',700,egw_getWindowOuterHeight());";
2393
+						$windowName = 'displayMessage_'.$rowID.'_'.$value['partID'];
2394
+						$linkView = "egw_openWindowCentered('".Egw::link('/index.php', $linkData)."','$windowName',700,egw_getWindowOuterHeight());";
2397 2395
 						break;
2398 2396
 					case 'IMAGE/JPEG':
2399 2397
 					case 'IMAGE/PNG':
@@ -2409,7 +2407,7 @@  discard block
 block discarded – undo
2409 2407
 					case 'TEXT/HTML':
2410 2408
 					case 'TEXT/DIRECTORY':
2411 2409
 						$sfxMimeType = $value['mimeType'];
2412
-						$buff = explode('.',$value['name']);
2410
+						$buff = explode('.', $value['name']);
2413 2411
 						$suffix = '';
2414 2412
 						if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
2415 2413
 						if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
@@ -2422,37 +2420,35 @@  discard block
 block discarded – undo
2422 2420
 					case 'TEXT/VCARD':
2423 2421
 					case 'TEXT/CALENDAR':
2424 2422
 					case 'TEXT/X-VCALENDAR':
2425
-						$linkData = array_merge(array
2426
-						(
2423
+						$linkData = array_merge(array(
2427 2424
 							'menuaction'	=> 'mail.mail_ui.getAttachment',
2428 2425
 							'id'		=> $rowID,
2429 2426
 							'part'		=> $value['partID'],
2430 2427
 							'is_winmail'=> $value['is_winmail'],
2431 2428
 							'mailbox'   => base64_encode($mailbox),
2432 2429
 							'smime_type' => $value['smime_type']
2433
-						) , $mode);
2434
-						$windowName = 'displayAttachment_'. $uid;
2430
+						), $mode);
2431
+						$windowName = 'displayAttachment_'.$uid;
2435 2432
 						$reg = '800x600';
2436 2433
 						// handle calendar/vcard
2437
-						if (strtoupper($value['mimeType'])=='TEXT/CALENDAR')
2434
+						if (strtoupper($value['mimeType']) == 'TEXT/CALENDAR')
2438 2435
 						{
2439
-							$windowName = 'displayEvent_'. $rowID;
2440
-							$reg2 = Link::get_registry('calendar','view_popup');
2441
-							$attachmentHTML[$key]['popup']=(!empty($reg2) ? $reg2 : $reg);
2436
+							$windowName = 'displayEvent_'.$rowID;
2437
+							$reg2 = Link::get_registry('calendar', 'view_popup');
2438
+							$attachmentHTML[$key]['popup'] = (!empty($reg2) ? $reg2 : $reg);
2442 2439
 						}
2443
-						if (strtoupper($value['mimeType'])=='TEXT/X-VCARD' || strtoupper($value['mimeType'])=='TEXT/VCARD')
2440
+						if (strtoupper($value['mimeType']) == 'TEXT/X-VCARD' || strtoupper($value['mimeType']) == 'TEXT/VCARD')
2444 2441
 						{
2445
-							$windowName = 'displayContact_'. $rowID;
2446
-							$reg2 = Link::get_registry('addressbook','add_popup');
2447
-							$attachmentHTML[$key]['popup']=(!empty($reg2) ? $reg2 : $reg);
2442
+							$windowName = 'displayContact_'.$rowID;
2443
+							$reg2 = Link::get_registry('addressbook', 'add_popup');
2444
+							$attachmentHTML[$key]['popup'] = (!empty($reg2) ? $reg2 : $reg);
2448 2445
 						}
2449 2446
 						// apply to action
2450
-						list($width,$height) = explode('x',(!empty($reg2) ? $reg2 : $reg));
2451
-						$linkView = "egw_openWindowCentered('".Egw::link('/index.php',$linkData)."','$windowName',$width,$height);";
2447
+						list($width, $height) = explode('x', (!empty($reg2) ? $reg2 : $reg));
2448
+						$linkView = "egw_openWindowCentered('".Egw::link('/index.php', $linkData)."','$windowName',$width,$height);";
2452 2449
 						break;
2453 2450
 					default:
2454
-						$linkData = array
2455
-						(
2451
+						$linkData = array(
2456 2452
 							'menuaction'	=> 'mail.mail_ui.getAttachment',
2457 2453
 							'id'		=> $rowID,
2458 2454
 							'part'		=> $value['partID'],
@@ -2460,13 +2456,13 @@  discard block
 block discarded – undo
2460 2456
 							'mailbox'   => base64_encode($mailbox),
2461 2457
 							'smime_type' => $value['smime_type']
2462 2458
 						);
2463
-						$linkView = "window.location.href = '".Egw::link('/index.php',$linkData)."';";
2459
+						$linkView = "window.location.href = '".Egw::link('/index.php', $linkData)."';";
2464 2460
 						break;
2465 2461
 				}
2466 2462
 				// we either use mime_data for server-side supported mime-types or mime_url for client-side or download
2467 2463
 				if (empty($attachmentHTML[$key]['mime_data']))
2468 2464
 				{
2469
-					$attachmentHTML[$key]['mime_url'] = Egw::link('/index.php',$linkData);
2465
+					$attachmentHTML[$key]['mime_url'] = Egw::link('/index.php', $linkData);
2470 2466
 					unset($attachmentHTML[$key]['mime_data']);
2471 2467
 				}
2472 2468
 				$attachmentHTML[$key]['windowName'] = $windowName;
@@ -2476,8 +2472,7 @@  discard block
 block discarded – undo
2476 2472
 					($value['name'] ? $value['name'] : lang('(no subject)')).
2477 2473
 					'</b></a>';
2478 2474
 
2479
-				$linkData = array
2480
-				(
2475
+				$linkData = array(
2481 2476
 					'menuaction'	=> 'mail.mail_ui.getAttachment',
2482 2477
 					'mode'		=> 'save',
2483 2478
 					'id'		=> $rowID,
@@ -2486,7 +2481,7 @@  discard block
 block discarded – undo
2486 2481
 					'mailbox'   => base64_encode($mailbox),
2487 2482
 					'smime_type' => $value['smime_type']
2488 2483
 				);
2489
-				$attachmentHTML[$key]['link_save'] ="<a href='".Egw::link('/index.php',$linkData)."' title='".$attachmentHTML[$key]['filename']."'>".Api\Html::image('mail','fileexport')."</a>";
2484
+				$attachmentHTML[$key]['link_save'] = "<a href='".Egw::link('/index.php', $linkData)."' title='".$attachmentHTML[$key]['filename']."'>".Api\Html::image('mail', 'fileexport')."</a>";
2490 2485
 				// add save-all and download zip icon for first attachment only
2491 2486
 				// if more than one attachments.
2492 2487
 				if ($key == 0 && count($attachments) > 1)
@@ -2494,7 +2489,7 @@  discard block
 block discarded – undo
2494 2489
 					$attachmentHTML[$key]['classSaveAllPossiblyDisabled'] = "";
2495 2490
 				}
2496 2491
 			}
2497
-			$attachmentHTMLBlock="<table width='100%'>";
2492
+			$attachmentHTMLBlock = "<table width='100%'>";
2498 2493
 			foreach ((array)$attachmentHTML as $row)
2499 2494
 			{
2500 2495
 				$attachmentHTMLBlock .= "<tr><td><div class='useEllipsis'>".$row['link_view'].'</div></td>';
@@ -2512,7 +2507,7 @@  discard block
 block discarded – undo
2512 2507
 				unset($attachmentHTML[$ikey]['link_save']);
2513 2508
 			}
2514 2509
 		}
2515
-		return ($_returnFullHTML?$attachmentHTMLBlock:$attachmentHTML);
2510
+		return ($_returnFullHTML ? $attachmentHTMLBlock : $attachmentHTML);
2516 2511
 	}
2517 2512
 
2518 2513
 	/**
@@ -2523,7 +2518,7 @@  discard block
 block discarded – undo
2523 2518
 	 */
2524 2519
 	function gatherVacation($cachedVacations = array())
2525 2520
 	{
2526
-		$isVacationEnabled = $this->mail_bo->icServer->acc_sieve_enabled && ($this->mail_bo->icServer->acc_sieve_host||$this->mail_bo->icServer->acc_imap_host);
2521
+		$isVacationEnabled = $this->mail_bo->icServer->acc_sieve_enabled && ($this->mail_bo->icServer->acc_sieve_host || $this->mail_bo->icServer->acc_imap_host);
2527 2522
 		//error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation));
2528 2523
 
2529 2524
 		if ($isVacationEnabled)
@@ -2536,7 +2531,7 @@  discard block
 block discarded – undo
2536 2531
 
2537 2532
 				$cachedVacations = array($sieveServer->acc_id => $vacation) + (array)$cachedVacations;
2538 2533
 				// Set vacation to the instance cache for particular account with expiration of one day
2539
-				Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations, 60*60*24);
2534
+				Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations, 60 * 60 * 24);
2540 2535
 			}
2541 2536
 			catch (PEAR_Exception $ex)
2542 2537
 			{
@@ -2562,35 +2557,35 @@  discard block
 block discarded – undo
2562 2557
 	 */
2563 2558
 	function quotaDisplay($_usage, $_limit)
2564 2559
 	{
2565
-		$percent = $_limit == 0 ? 100 : round(($_usage*100)/$_limit);
2566
-		$limit = Mail::show_readable_size($_limit*1024);
2567
-		$usage = Mail::show_readable_size($_usage*1024);
2560
+		$percent = $_limit == 0 ? 100 : round(($_usage * 100) / $_limit);
2561
+		$limit = Mail::show_readable_size($_limit * 1024);
2562
+		$usage = Mail::show_readable_size($_usage * 1024);
2568 2563
 
2569 2564
 		if ($_limit > 0)
2570 2565
 		{
2571
-			$text = $usage .'/'.$limit;
2566
+			$text = $usage.'/'.$limit;
2572 2567
 			switch ($percent)
2573 2568
 			{
2574 2569
 				case ($percent > 90):
2575
-					$class ='mail-index_QuotaRed';
2570
+					$class = 'mail-index_QuotaRed';
2576 2571
 					break;
2577 2572
 				case ($percent > 80):
2578
-					$class ='mail-index_QuotaYellow';
2573
+					$class = 'mail-index_QuotaYellow';
2579 2574
 					break;
2580 2575
 				default:
2581
-					$class ='mail-index_QuotaGreen';
2576
+					$class = 'mail-index_QuotaGreen';
2582 2577
 			}
2583 2578
 		}
2584 2579
 		else
2585 2580
 		{
2586 2581
 			$text = $usage;
2587
-			$class ='mail-index_QuotaGreen';
2582
+			$class = 'mail-index_QuotaGreen';
2588 2583
 		}
2589
-		return array (
2584
+		return array(
2590 2585
 			'class'		=> $class,
2591
-			'text'		=> lang('Quota: %1',$text),
2586
+			'text'		=> lang('Quota: %1', $text),
2592 2587
 			'percent'	=> $percent,
2593
-			'freespace'	=> $_limit*1024 - $_usage*1024
2588
+			'freespace'	=> $_limit * 1024 - $_usage * 1024
2594 2589
 		);
2595 2590
 	}
2596 2591
 
@@ -2604,12 +2599,12 @@  discard block
 block discarded – undo
2604 2599
 		$uid	= $_GET['uid'];
2605 2600
 		$cid	= base64_decode($_GET['cid']);
2606 2601
 		$partID = urldecode($_GET['partID']);
2607
-		if (!empty($_GET['mailbox'])) $mailbox  = base64_decode($_GET['mailbox']);
2602
+		if (!empty($_GET['mailbox'])) $mailbox = base64_decode($_GET['mailbox']);
2608 2603
 
2609 2604
 		//error_log(__METHOD__.__LINE__.":$uid, $cid, $partID");
2610 2605
 		$this->mail_bo->reopen($mailbox);
2611 2606
 
2612
-		$attachment = $this->mail_bo->getAttachmentByCID($uid, $cid, $partID, true);	// true get contents as stream
2607
+		$attachment = $this->mail_bo->getAttachmentByCID($uid, $cid, $partID, true); // true get contents as stream
2613 2608
 
2614 2609
 		$this->mail_bo->closeConnection();
2615 2610
 
@@ -2617,8 +2612,8 @@  discard block
 block discarded – undo
2617 2612
 
2618 2613
 		if ($attachment)
2619 2614
 		{
2620
-			header("Content-Type: ". $attachment->getType());
2621
-			header('Content-Disposition: inline; filename="'. $attachment->getDispositionParameter('filename') .'"');
2615
+			header("Content-Type: ".$attachment->getType());
2616
+			header('Content-Disposition: inline; filename="'.$attachment->getDispositionParameter('filename').'"');
2622 2617
 			//header("Expires: 0");
2623 2618
 			// the next headers are for IE and SSL
2624 2619
 			//header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
@@ -2636,7 +2631,7 @@  discard block
 block discarded – undo
2636 2631
 
2637 2632
 	function getAttachment()
2638 2633
 	{
2639
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
2634
+		if (isset($_GET['id'])) $rowID = $_GET['id'];
2640 2635
 
2641 2636
 		$hA = self::splitRowID($rowID);
2642 2637
 		$uid = $hA['msgUID'];
@@ -2648,11 +2643,11 @@  discard block
 block discarded – undo
2648 2643
 			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
2649 2644
 			$this->changeProfile($icServerID);
2650 2645
 		}
2651
-		$part		= $_GET['part'];
2646
+		$part = $_GET['part'];
2652 2647
 		$is_winmail = $_GET['is_winmail'] ? $_GET['is_winmail'] : 0;
2653 2648
 
2654 2649
 		$this->mail_bo->reopen($mailbox);
2655
-		$attachment = $this->mail_bo->getAttachment($uid,$part,$is_winmail,false);
2650
+		$attachment = $this->mail_bo->getAttachment($uid, $part, $is_winmail, false);
2656 2651
 		$this->mail_bo->closeConnection();
2657 2652
 		if ($rememberServerID != $this->mail_bo->profileID)
2658 2653
 		{
@@ -2667,7 +2662,7 @@  discard block
 block discarded – undo
2667 2662
 			if (strtoupper($attachment['type']) == 'TEXT/DIRECTORY' || empty($attachment['type']))
2668 2663
 			{
2669 2664
 				$sfxMimeType = $attachment['type'];
2670
-				$buff = explode('.',$attachment['filename']);
2665
+				$buff = explode('.', $attachment['filename']);
2671 2666
 				$suffix = '';
2672 2667
 				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
2673 2668
 				if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
@@ -2679,10 +2674,10 @@  discard block
 block discarded – undo
2679 2674
 			{
2680 2675
 				//error_log(__METHOD__."about to call calendar_ical");
2681 2676
 				$calendar_ical = new calendar_ical();
2682
-				$eventid = $calendar_ical->search($attachment['attachment'],-1);
2677
+				$eventid = $calendar_ical->search($attachment['attachment'], -1);
2683 2678
 				//error_log(__METHOD__.array2string($eventid));
2684 2679
 				if (!$eventid) $eventid = -1;
2685
-				$event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true,0,'',null,$attachment['charset']);
2680
+				$event = $calendar_ical->importVCal($attachment['attachment'], (is_array($eventid) ? $eventid[0] : $eventid), null, true, 0, '', null, $attachment['charset']);
2686 2681
 				//error_log(__METHOD__.$event);
2687 2682
 				if ((int)$event > 0)
2688 2683
 				{
@@ -2690,7 +2685,7 @@  discard block
 block discarded – undo
2690 2685
 						'menuaction'      => 'calendar.calendar_uiforms.edit',
2691 2686
 						'cal_id'      => $event,
2692 2687
 					);
2693
-					Egw::redirect_link('../index.php',$vars);
2688
+					Egw::redirect_link('../index.php', $vars);
2694 2689
 				}
2695 2690
 				//Import failed, download content anyway
2696 2691
 			}
@@ -2705,13 +2700,13 @@  discard block
 block discarded – undo
2705 2700
 				{
2706 2701
 					$vcard['uid'] = trim($vcard['uid']);
2707 2702
 					//error_log(__METHOD__.__LINE__.print_r($vcard,true));
2708
-					$contact = $addressbook_vcal->find_contact($vcard,false);
2703
+					$contact = $addressbook_vcal->find_contact($vcard, false);
2709 2704
 				}
2710 2705
 				if (!$contact) $contact = null;
2711 2706
 				// if there are not enough fields in the vcard (or the parser was unable to correctly parse the vcard (as of VERSION:3.0 created by MSO))
2712
-				if ($contact || count($vcard)>2)
2707
+				if ($contact || count($vcard) > 2)
2713 2708
 				{
2714
-					$contact = $addressbook_vcal->addVCard($attachment['attachment'],(is_array($contact)?array_shift($contact):$contact),true,$attachment['charset']);
2709
+					$contact = $addressbook_vcal->addVCard($attachment['attachment'], (is_array($contact) ?array_shift($contact) : $contact), true, $attachment['charset']);
2715 2710
 				}
2716 2711
 				if ((int)$contact > 0)
2717 2712
 				{
@@ -2719,14 +2714,14 @@  discard block
 block discarded – undo
2719 2714
 						'menuaction'	=> 'addressbook.addressbook_ui.edit',
2720 2715
 						'contact_id'	=> $contact,
2721 2716
 					);
2722
-					Egw::redirect_link('../index.php',$vars);
2717
+					Egw::redirect_link('../index.php', $vars);
2723 2718
 				}
2724 2719
 				//Import failed, download content anyway
2725 2720
 			}
2726 2721
 		}
2727 2722
 		//error_log(__METHOD__.__LINE__.'->'.array2string($attachment));
2728
-		$filename = ($attachment['name']?$attachment['name']:($attachment['filename']?$attachment['filename']:$mailbox.'_uid'.$uid.'_part'.$part));
2729
-		Api\Header\Content::safe($attachment['attachment'], $filename, $attachment['type'], $size=0, True, $_GET['mode'] == "save");
2723
+		$filename = ($attachment['name'] ? $attachment['name'] : ($attachment['filename'] ? $attachment['filename'] : $mailbox.'_uid'.$uid.'_part'.$part));
2724
+		Api\Header\Content::safe($attachment['attachment'], $filename, $attachment['type'], $size = 0, True, $_GET['mode'] == "save");
2730 2725
 		echo $attachment['attachment'];
2731 2726
 
2732 2727
 		exit();
@@ -2741,9 +2736,9 @@  discard block
 block discarded – undo
2741 2736
 	function saveMessage()
2742 2737
 	{
2743 2738
 		$display = false;
2744
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
2745
-		if(isset($_GET['part'])) $partID = $_GET['part'];
2746
-		if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager')) $display	= $_GET['location'];
2739
+		if (isset($_GET['id'])) $rowID = $_GET['id'];
2740
+		if (isset($_GET['part'])) $partID = $_GET['part'];
2741
+		if (isset($_GET['location']) && ($_GET['location'] == 'display' || $_GET['location'] == 'filemanager')) $display = $_GET['location'];
2747 2742
 
2748 2743
 		$hA = self::splitRowID($rowID);
2749 2744
 		$uid = $hA['msgUID'];
@@ -2771,16 +2766,16 @@  discard block
 block discarded – undo
2771 2766
 		if (!$display)
2772 2767
 		{
2773 2768
 			$headers = Horde_Mime_Headers::parseHeaders($message);
2774
-			$subject = str_replace('$$','__',Mail::decode_header($headers['SUBJECT']));
2769
+			$subject = str_replace('$$', '__', Mail::decode_header($headers['SUBJECT']));
2775 2770
 			$subject = mail_bo::clean_subject_for_filename($subject);
2776
-			Api\Header\Content::safe($message, $subject.".eml", $mime='message/rfc822', $size=0, true, true);
2771
+			Api\Header\Content::safe($message, $subject.".eml", $mime = 'message/rfc822', $size = 0, true, true);
2777 2772
 			echo $message;
2778 2773
 		}
2779 2774
 		else
2780 2775
 		{
2781 2776
 			$subject = mail_bo::clean_subject_for_filename($subject);
2782
-			Api\Header\Content::safe($message, $subject.".eml", $mime='text/html', $size=0, true, false);
2783
-			print '<pre>'. htmlspecialchars($message, ENT_NOQUOTES|ENT_SUBSTITUTE, 'utf-8') .'</pre>';
2777
+			Api\Header\Content::safe($message, $subject.".eml", $mime = 'text/html', $size = 0, true, false);
2778
+			print '<pre>'.htmlspecialchars($message, ENT_NOQUOTES|ENT_SUBSTITUTE, 'utf-8').'</pre>';
2784 2779
 		}
2785 2780
 	}
2786 2781
 
@@ -2794,7 +2789,7 @@  discard block
 block discarded – undo
2794 2789
 	 *			)
2795 2790
 	 * @param string $path path to save the emails
2796 2791
 	 */
2797
-	function ajax_vfsSave ($params,$path)
2792
+	function ajax_vfsSave($params, $path)
2798 2793
 	{
2799 2794
 		$response = Api\Json\Response::get();
2800 2795
 
@@ -2822,11 +2817,11 @@  discard block
 block discarded – undo
2822 2817
 	 *			'success' => BOOLEAN
2823 2818
 	 *		)
2824 2819
 	 */
2825
-	function vfsSaveMessages($ids,$path)
2820
+	function vfsSaveMessages($ids, $path)
2826 2821
 	{
2827 2822
 		// add mail translation
2828 2823
 		Api\Translation::add_app('mail');
2829
-		$res = array ();
2824
+		$res = array();
2830 2825
 
2831 2826
 		// extract dir from the path
2832 2827
 		$dir = Vfs::is_dir($path) ? $path : Vfs::dirname($path);
@@ -2834,14 +2829,14 @@  discard block
 block discarded – undo
2834 2829
 		// exit if user has no right to the dir
2835 2830
 		if (!Vfs::is_writable($dir))
2836 2831
 		{
2837
-			return array (
2838
-				'msg' => lang('%1 is NOT writable by you!',$path),
2832
+			return array(
2833
+				'msg' => lang('%1 is NOT writable by you!', $path),
2839 2834
 				'success' => false
2840 2835
 			);
2841 2836
 		}
2842 2837
 
2843 2838
 		$preservedServerID = $this->mail_bo->profileID;
2844
-		foreach((array)$ids as $id)
2839
+		foreach ((array)$ids as $id)
2845 2840
 		{
2846 2841
 			$hA = self::splitRowID($id);
2847 2842
 			$uid = $hA['msgUID'];
@@ -2851,17 +2846,17 @@  discard block
 block discarded – undo
2851 2846
 			{
2852 2847
 				$this->changeProfile($icServerID);
2853 2848
 			}
2854
-			$message = $this->mail_bo->getMessageRawBody($uid, $partID='', $mailbox);
2849
+			$message = $this->mail_bo->getMessageRawBody($uid, $partID = '', $mailbox);
2855 2850
 
2856 2851
 			// is multiple messages
2857 2852
 			if (Vfs::is_dir($path))
2858 2853
 			{
2859
-				$headers = $this->mail_bo->getMessageHeader($uid,$partID,true,false,$mailbox);
2860
-				$file = $dir . '/'.mail_bo::clean_subject_for_filename($headers['SUBJECT']).'.eml';
2854
+				$headers = $this->mail_bo->getMessageHeader($uid, $partID, true, false, $mailbox);
2855
+				$file = $dir.'/'.mail_bo::clean_subject_for_filename($headers['SUBJECT']).'.eml';
2861 2856
 			}
2862 2857
 			else
2863 2858
 			{
2864
-				$file = $dir . '/' . mail_bo::clean_subject_for_filename(str_replace($dir.'/', '', $path));
2859
+				$file = $dir.'/'.mail_bo::clean_subject_for_filename(str_replace($dir.'/', '', $path));
2865 2860
 			}
2866 2861
 
2867 2862
 			// Check if file already exists, then try to assign a none existance filename
@@ -2871,14 +2866,14 @@  discard block
 block discarded – undo
2871 2866
 			{
2872 2867
 				$tmp_file = $file;
2873 2868
 				$pathinfo = pathinfo(Vfs::basename($tmp_file));
2874
-				$tmp_file = $dir . '/' . $pathinfo['filename'] . '(' . $counter . ')' . '.' . $pathinfo['extension'];
2869
+				$tmp_file = $dir.'/'.$pathinfo['filename'].'('.$counter.')'.'.'.$pathinfo['extension'];
2875 2870
 				$counter++;
2876 2871
 			}
2877 2872
 			$file = $tmp_file;
2878 2873
 
2879
-			if (!($fp = Vfs::fopen($file,'wb')) || !fwrite($fp,$message))
2874
+			if (!($fp = Vfs::fopen($file, 'wb')) || !fwrite($fp, $message))
2880 2875
 			{
2881
-				$res['msg'] = lang('Error saving %1!',$file);
2876
+				$res['msg'] = lang('Error saving %1!', $file);
2882 2877
 				$res['success'] = false;
2883 2878
 			}
2884 2879
 			else
@@ -2888,10 +2883,10 @@  discard block
 block discarded – undo
2888 2883
 			if ($fp) fclose($fp);
2889 2884
 			if ($res['success'])
2890 2885
 			{
2891
-				unset($headers['SUBJECT']);//already in filename
2886
+				unset($headers['SUBJECT']); //already in filename
2892 2887
 				$infoSection = Mail::createHeaderInfoSection($headers, 'SUPPRESS', false);
2893
-				$props = array(array('name' => 'comment','val' => $infoSection));
2894
-				Vfs::proppatch($file,$props);
2888
+				$props = array(array('name' => 'comment', 'val' => $infoSection));
2889
+				Vfs::proppatch($file, $props);
2895 2890
 			}
2896 2891
 		}
2897 2892
 		if ($preservedServerID != $this->mail_bo->profileID)
@@ -2914,9 +2909,9 @@  discard block
 block discarded – undo
2914 2909
 	 *			'success' => BOOLEAN
2915 2910
 	 *		)
2916 2911
 	 */
2917
-	function vfsSaveAttachments($ids,$path)
2912
+	function vfsSaveAttachments($ids, $path)
2918 2913
 	{
2919
-		$res = array (
2914
+		$res = array(
2920 2915
 			'msg' => lang('Attachment has been saved successfully.'),
2921 2916
 			'success' => true
2922 2917
 		);
@@ -2929,13 +2924,13 @@  discard block
 block discarded – undo
2929 2924
 		{
2930 2925
 			$dir = Vfs::dirname($path);
2931 2926
 			// Need to deal with any ? here, or basename will truncate
2932
-			$filename = mail_bo::clean_subject_for_filename(str_replace('?','_',Vfs::basename($path)));
2927
+			$filename = mail_bo::clean_subject_for_filename(str_replace('?', '_', Vfs::basename($path)));
2933 2928
 		}
2934 2929
 
2935 2930
 		if (!Vfs::is_writable($dir))
2936 2931
 		{
2937
-			return array (
2938
-				'msg' => lang('%1 is NOT writable by you!',$path),
2932
+			return array(
2933
+				'msg' => lang('%1 is NOT writable by you!', $path),
2939 2934
 				'success' => false
2940 2935
 			);
2941 2936
 		}
@@ -2948,12 +2943,12 @@  discard block
 block discarded – undo
2948 2943
 		 *
2949 2944
 		 * @return array an array of parameters
2950 2945
 		 */
2951
-		$getParams = function ($id) {
2952
-			list($app,$user,$serverID,$mailbox,$uid,$part,$is_winmail,$name) = explode('::',$id,8);
2953
-			$lId = implode('::',array($app,$user,$serverID,$mailbox,$uid));
2946
+		$getParams = function($id) {
2947
+			list($app, $user, $serverID, $mailbox, $uid, $part, $is_winmail, $name) = explode('::', $id, 8);
2948
+			$lId = implode('::', array($app, $user, $serverID, $mailbox, $uid));
2954 2949
 			$hA = mail_ui::splitRowID($lId);
2955 2950
 			return array(
2956
-				'is_winmail' => $is_winmail == "null" || !$is_winmail?false:$is_winmail,
2951
+				'is_winmail' => $is_winmail == "null" || !$is_winmail ?false:$is_winmail,
2957 2952
 				'user' => $user,
2958 2953
 				'name' => $name,
2959 2954
 				'part' => $part,
@@ -2965,7 +2960,7 @@  discard block
 block discarded – undo
2965 2960
 
2966 2961
 		//Examine the first attachment to see if attachment
2967 2962
 		//is winmail.dat embedded attachments.
2968
-		$p = $getParams((is_array($ids)?$ids[0]:$ids));
2963
+		$p = $getParams((is_array($ids) ? $ids[0] : $ids));
2969 2964
 		if ($p['is_winmail'])
2970 2965
 		{
2971 2966
 			if ($p['icServer'] && $p['icServer'] != $this->mail_bo->profileID)
@@ -2976,10 +2971,10 @@  discard block
 block discarded – undo
2976 2971
 			// retrieve all embedded attachments at once
2977 2972
 			// avoids to fetch heavy winmail.dat content
2978 2973
 			// for each file.
2979
-			$attachments = $this->mail_bo->getTnefAttachments($p['uid'],$p['part']);
2974
+			$attachments = $this->mail_bo->getTnefAttachments($p['uid'], $p['part']);
2980 2975
 		}
2981 2976
 
2982
-		foreach((array)$ids as $id)
2977
+		foreach ((array)$ids as $id)
2983 2978
 		{
2984 2979
 			$params = $getParams($id);
2985 2980
 
@@ -3002,15 +2997,15 @@  discard block
 block discarded – undo
3002 2997
 				}
3003 2998
 				else
3004 2999
 				{
3005
-					$attachment = $this->mail_bo->getAttachment($params['uid'],$params['part'],$params['is_winmail'],false);
3000
+					$attachment = $this->mail_bo->getAttachment($params['uid'], $params['part'], $params['is_winmail'], false);
3006 3001
 				}
3007 3002
 			}
3008 3003
 			else
3009 3004
 			{
3010
-				$attachment = $this->mail_bo->getAttachment($params['uid'],$params['part'],$params['is_winmail'],false);
3005
+				$attachment = $this->mail_bo->getAttachment($params['uid'], $params['part'], $params['is_winmail'], false);
3011 3006
 			}
3012 3007
 
3013
-			$file = $dir. '/' . ($filename ? $filename : mail_bo::clean_subject_for_filename($attachment['filename']));
3008
+			$file = $dir.'/'.($filename ? $filename : mail_bo::clean_subject_for_filename($attachment['filename']));
3014 3009
 
3015 3010
 			$counter = 1;
3016 3011
 			$tmp_file = $file;
@@ -3018,15 +3013,15 @@  discard block
 block discarded – undo
3018 3013
 			{
3019 3014
 				$tmp_file = $file;
3020 3015
 				$pathinfo = pathinfo(Vfs::basename($tmp_file));
3021
-				$tmp_file = $dir . '/' . $pathinfo['filename'] . '(' . $counter . ')' . '.' . $pathinfo['extension'];
3016
+				$tmp_file = $dir.'/'.$pathinfo['filename'].'('.$counter.')'.'.'.$pathinfo['extension'];
3022 3017
 				$counter++;
3023 3018
 			}
3024 3019
 			$file = $tmp_file;
3025 3020
 
3026
-			if (!($fp = Vfs::fopen($file,'wb')) ||
3027
-				!fwrite($fp,$attachment['attachment']))
3021
+			if (!($fp = Vfs::fopen($file, 'wb')) ||
3022
+				!fwrite($fp, $attachment['attachment']))
3028 3023
 			{
3029
-				$res['msg'] = lang('Error saving %1!',$file);
3024
+				$res['msg'] = lang('Error saving %1!', $file);
3030 3025
 				$res['success'] = false;
3031 3026
 			}
3032 3027
 			if ($fp)
@@ -3049,14 +3044,14 @@  discard block
 block discarded – undo
3049 3044
 	 * Zip all attachments and send to user
3050 3045
 	 * @param string $message_id = null
3051 3046
 	 */
3052
-	function download_zip($message_id=null)
3047
+	function download_zip($message_id = null)
3053 3048
 	{
3054 3049
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
3055 3050
 		// First, get all attachment IDs
3056
-		if(isset($_GET['id'])) $message_id	= $_GET['id'];
3051
+		if (isset($_GET['id'])) $message_id = $_GET['id'];
3057 3052
 		//error_log(__METHOD__.__LINE__.$message_id);
3058 3053
 		$rememberServerID = $this->mail_bo->profileID;
3059
-		if(!is_numeric($message_id))
3054
+		if (!is_numeric($message_id))
3060 3055
 		{
3061 3056
 			$hA = self::splitRowID($message_id);
3062 3057
 			$message_id = $hA['msgUID'];
@@ -3074,18 +3069,18 @@  discard block
 block discarded – undo
3074 3069
 		}
3075 3070
 		// always fetch all, even inline (images)
3076 3071
 		$fetchEmbeddedImages = true;
3077
-		$attachments = $this->mail_bo->getMessageAttachments($message_id,null, null, $fetchEmbeddedImages, true,true,$mailbox);
3072
+		$attachments = $this->mail_bo->getMessageAttachments($message_id, null, null, $fetchEmbeddedImages, true, true, $mailbox);
3078 3073
 		// put them in VFS so they can be zipped
3079
-		$header = $this->mail_bo->getMessageHeader($message_id,'',true,false,$mailbox);
3074
+		$header = $this->mail_bo->getMessageHeader($message_id, '', true, false, $mailbox);
3080 3075
 		//get_home_dir may fetch the users startfolder if set; if not writeable, action will fail. TODO: use temp_dir
3081 3076
 		$homedir = '/home/'.$GLOBALS['egw_info']['user']['account_lid'];
3082
-		$temp_path = $homedir/*Vfs::get_home_dir()*/ . "/.mail_$message_id";
3083
-		if(Vfs::is_dir($temp_path)) Vfs::remove ($temp_path);
3077
+		$temp_path = $homedir/*Vfs::get_home_dir()*/."/.mail_$message_id";
3078
+		if (Vfs::is_dir($temp_path)) Vfs::remove($temp_path);
3084 3079
 
3085 3080
 		// Add subject to path, so it gets used as the file name, replacing ':'
3086 3081
 		// as it seems to cause an error
3087
-		$path = $temp_path . '/' . ($header['SUBJECT'] ? Vfs::encodePathComponent(mail_bo::clean_subject_for_filename(str_replace(':','-', $header['SUBJECT']))) : lang('mail')) .'/';
3088
-		if(!Vfs::mkdir($path, 0700, true))
3082
+		$path = $temp_path.'/'.($header['SUBJECT'] ? Vfs::encodePathComponent(mail_bo::clean_subject_for_filename(str_replace(':', '-', $header['SUBJECT']))) : lang('mail')).'/';
3083
+		if (!Vfs::mkdir($path, 0700, true))
3089 3084
 		{
3090 3085
 			echo "Unable to open temp directory $path";
3091 3086
 			return;
@@ -3094,11 +3089,11 @@  discard block
 block discarded – undo
3094 3089
 		$file_list = array();
3095 3090
 		$dupe_count = array();
3096 3091
 		$this->mail_bo->reopen($mailbox);
3097
-		if ($attachments[0]['is_winmail'] && $attachments[0]['is_winmail']!='null')
3092
+		if ($attachments[0]['is_winmail'] && $attachments[0]['is_winmail'] != 'null')
3098 3093
 		{
3099
-			$tnefAttachments = $this->mail_bo->getTnefAttachments($message_id, $attachments[0]['partID'],true);
3094
+			$tnefAttachments = $this->mail_bo->getTnefAttachments($message_id, $attachments[0]['partID'], true);
3100 3095
 		}
3101
-		foreach($attachments as $file)
3096
+		foreach ($attachments as $file)
3102 3097
 		{
3103 3098
 			if ($file['is_winmail'])
3104 3099
 			{
@@ -3111,25 +3106,25 @@  discard block
 block discarded – undo
3111 3106
 			}
3112 3107
 			else
3113 3108
 			{
3114
-				$attachment = $this->mail_bo->getAttachment($message_id,$file['partID'],$file['is_winmail'],false,true);
3109
+				$attachment = $this->mail_bo->getAttachment($message_id, $file['partID'], $file['is_winmail'], false, true);
3115 3110
 			}
3116
-			$success=true;
3111
+			$success = true;
3117 3112
 			if (empty($file['filename'])) $file['filename'] = $file['name'];
3118
-			if(in_array($path.$file['filename'], $file_list))
3113
+			if (in_array($path.$file['filename'], $file_list))
3119 3114
 			{
3120 3115
 				$dupe_count[$path.$file['filename']]++;
3121
-				$file['filename'] = pathinfo($file['filename'], PATHINFO_FILENAME) .
3122
-					' ('.($dupe_count[$path.$file['filename']] + 1).')' . '.' .
3116
+				$file['filename'] = pathinfo($file['filename'], PATHINFO_FILENAME).
3117
+					' ('.($dupe_count[$path.$file['filename']] + 1).')'.'.'.
3123 3118
 					pathinfo($file['filename'], PATHINFO_EXTENSION);
3124 3119
 			}
3125 3120
 			// Strip special characters to make sure the files are visible for all OS (windows has issues)
3126 3121
 			$target_name = mail_bo::clean_subject_for_filename(iconv($file['charset'] ? $file['charset'] : $GLOBALS['egw_info']['server']['system_charset'], 'ASCII//IGNORE', $file['filename']));
3127 3122
 
3128
-			if (!($fp = Vfs::fopen($path.$target_name,'wb')) ||
3123
+			if (!($fp = Vfs::fopen($path.$target_name, 'wb')) ||
3129 3124
 				!(!fseek($attachment['attachment'], 0, SEEK_SET) && stream_copy_to_stream($attachment['attachment'], $fp)))
3130 3125
 			{
3131
-				$success=false;
3132
-				Framework::message("Unable to zip {$target_name}",'error');
3126
+				$success = false;
3127
+				Framework::message("Unable to zip {$target_name}", 'error');
3133 3128
 			}
3134 3129
 			if ($success) $file_list[] = $path.$target_name;
3135 3130
 			if ($fp) fclose($fp);
@@ -3150,7 +3145,7 @@  discard block
 block discarded – undo
3150 3145
 		exit();
3151 3146
 	}
3152 3147
 
3153
-	function get_load_email_data($uid, $partID, $mailbox,$htmlOptions=null, $smimePassphrase = '')
3148
+	function get_load_email_data($uid, $partID, $mailbox, $htmlOptions = null, $smimePassphrase = '')
3154 3149
 	{
3155 3150
 		// seems to be needed, as if we open a mail from notification popup that is
3156 3151
 		// located in a different folder, we experience: could not parse message
@@ -3176,7 +3171,7 @@  discard block
 block discarded – undo
3176 3171
 			if (($smime = $structure->getMetadata('X-EGroupware-Smime')))
3177 3172
 			{
3178 3173
 				$acc_smime = Mail\Smime::get_acc_smime($this->mail_bo->profileID);
3179
-				$attachments = $this->mail_bo->getMessageAttachments($uid, $partID, $structure,true,false,true, $mailbox);
3174
+				$attachments = $this->mail_bo->getMessageAttachments($uid, $partID, $structure, true, false, true, $mailbox);
3180 3175
 				$push = new Api\Json\Push($GLOBALS['egw_info']['user']['account_id']);
3181 3176
 				if (!empty($acc_smime) && !empty($smime['addtocontact'])) $push->call('app.mail.smime_certAddToContact', $smime);
3182 3177
 				if (is_array($attachments))
@@ -3186,7 +3181,7 @@  discard block
 block discarded – undo
3186 3181
 				$push->call('app.mail.set_smimeFlags', $smime);
3187 3182
 			}
3188 3183
 		}
3189
-		catch(Mail\Smime\PassphraseMissing $e)
3184
+		catch (Mail\Smime\PassphraseMissing $e)
3190 3185
 		{
3191 3186
 			$acc_smime = Mail\Smime::get_acc_smime($this->mail_bo->profileID);
3192 3187
 			if (empty($acc_smime))
@@ -3214,7 +3209,7 @@  discard block
 block discarded – undo
3214 3209
 			return $smimeHtml;
3215 3210
 		}
3216 3211
 		$calendar_part = null;
3217
-		$bodyParts	= $this->mail_bo->getMessageBody($uid, ($htmlOptions?$htmlOptions:''), $partID, $structure, false, $mailbox, $calendar_part);
3212
+		$bodyParts = $this->mail_bo->getMessageBody($uid, ($htmlOptions ? $htmlOptions : ''), $partID, $structure, false, $mailbox, $calendar_part);
3218 3213
 
3219 3214
 		// for meeting requests (multipart alternative with text/calendar part) let calendar render it
3220 3215
 		if ($calendar_part && isset($GLOBALS['egw_info']['user']['apps']['calendar']))
@@ -3229,7 +3224,7 @@  discard block
 block discarded – undo
3229 3224
 			$this->mail_bo->htmlOptions = $bufferHtmlOptions;
3230 3225
 			Api\Translation::add_app('calendar');
3231 3226
 			return ExecMethod('calendar.calendar_uiforms.meeting',
3232
-				array('event'=>null,'msg'=>'','useSession'=>true)
3227
+				array('event'=>null, 'msg'=>'', 'useSession'=>true)
3233 3228
 			);
3234 3229
 		}
3235 3230
 		if (!$smime)
@@ -3239,20 +3234,20 @@  discard block
 block discarded – undo
3239 3234
 		// Compose the content of the frame
3240 3235
 		$frameHtml =
3241 3236
 			$this->get_email_header($this->mail_bo->getStyles($bodyParts)).
3242
-			$this->showBody($this->getdisplayableBody($bodyParts,true,false), false);
3237
+			$this->showBody($this->getdisplayableBody($bodyParts, true, false), false);
3243 3238
 		//IE10 eats away linebreaks preceeded by a whitespace in PRE sections
3244
-		$frameHtml = str_replace(" \r\n","\r\n",$frameHtml);
3239
+		$frameHtml = str_replace(" \r\n", "\r\n", $frameHtml);
3245 3240
 		$this->mail_bo->htmlOptions = $bufferHtmlOptions;
3246 3241
 
3247 3242
 		return $frameHtml;
3248 3243
 	}
3249 3244
 
3250
-	static function get_email_header($additionalStyle='')
3245
+	static function get_email_header($additionalStyle = '')
3251 3246
 	{
3252 3247
 		// egw_info[flags][css] already include <style> tags
3253 3248
 		$GLOBALS['egw_info']['flags']['css'] = preg_replace('|</?style[^>]*>|i', '', $additionalStyle);
3254
-		$GLOBALS['egw_info']['flags']['nofooter']=true;
3255
-		$GLOBALS['egw_info']['flags']['nonavbar']=true;
3249
+		$GLOBALS['egw_info']['flags']['nofooter'] = true;
3250
+		$GLOBALS['egw_info']['flags']['nonavbar'] = true;
3256 3251
 		// do NOT include any default CSS
3257 3252
 		Framework::includeCSS('mail', 'preview', true, true);
3258 3253
 
@@ -3263,35 +3258,35 @@  discard block
 block discarded – undo
3263 3258
 		return $GLOBALS['egw']->framework->header();
3264 3259
 	}
3265 3260
 
3266
-	function showBody(&$body, $print=true,$fullPageTags=true)
3261
+	function showBody(&$body, $print = true, $fullPageTags = true)
3267 3262
 	{
3268 3263
 		$BeginBody = '<div class="mailDisplayBody">
3269 3264
 <table width="100%" style="table-layout:fixed"><tr><td class="td_display">';
3270 3265
 
3271 3266
 		$EndBody = '</td></tr></table></div>';
3272 3267
 		if ($fullPageTags) $EndBody .= "</body></html>";
3273
-		if ($print)	{
3274
-			print $BeginBody. $body .$EndBody;
3268
+		if ($print) {
3269
+			print $BeginBody.$body.$EndBody;
3275 3270
 		} else {
3276
-			return $BeginBody. $body .$EndBody;
3271
+			return $BeginBody.$body.$EndBody;
3277 3272
 		}
3278 3273
 	}
3279 3274
 
3280
-	function &getdisplayableBody($_bodyParts,$modifyURI=true,$useTidy = true)
3275
+	function &getdisplayableBody($_bodyParts, $modifyURI = true, $useTidy = true)
3281 3276
 	{
3282
-		$bodyParts	= $_bodyParts;
3277
+		$bodyParts = $_bodyParts;
3283 3278
 
3284
-		$nonDisplayAbleCharacters = array('[\016]','[\017]',
3285
-				'[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]',
3286
-				'[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]');
3279
+		$nonDisplayAbleCharacters = array('[\016]', '[\017]',
3280
+				'[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]',
3281
+				'[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]');
3287 3282
 
3288 3283
 		$body = '';
3289 3284
 
3290 3285
 		//error_log(__METHOD__.array2string($bodyParts)); //exit;
3291 3286
 		if (empty($bodyParts)) return "";
3292
-		foreach((array)$bodyParts as $singleBodyPart) {
3287
+		foreach ((array)$bodyParts as $singleBodyPart) {
3293 3288
 			if (!isset($singleBodyPart['body'])) {
3294
-				$singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart,$modifyURI,$useTidy);
3289
+				$singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart, $modifyURI, $useTidy);
3295 3290
 				$body .= $singleBodyPart['body'];
3296 3291
 				continue;
3297 3292
 			}
@@ -3301,7 +3296,7 @@  discard block
 block discarded – undo
3301 3296
 				$body .= '';
3302 3297
 				continue;
3303 3298
 			}
3304
-			if(!empty($body)) {
3299
+			if (!empty($body)) {
3305 3300
 				$body .= '<hr style="border:dotted 1px silver;">';
3306 3301
 			}
3307 3302
 			//error_log($singleBodyPart['body']);
@@ -3326,28 +3321,28 @@  discard block
 block discarded – undo
3326 3321
 				'(R)',
3327 3322
 			);
3328 3323
 
3329
-			if(($singleBodyPart['mimeType'] == 'text/html' || $singleBodyPart['mimeType'] == 'text/plain') &&
3324
+			if (($singleBodyPart['mimeType'] == 'text/html' || $singleBodyPart['mimeType'] == 'text/plain') &&
3330 3325
 				strtoupper($singleBodyPart['charSet']) != 'UTF-8')
3331 3326
 			{
3332
-				$singleBodyPart['body'] = preg_replace($sar,$rar,$singleBodyPart['body']);
3327
+				$singleBodyPart['body'] = preg_replace($sar, $rar, $singleBodyPart['body']);
3333 3328
 			}
3334 3329
 			//error_log(__METHOD__.__LINE__.'reports:'.$singleBodyPart['charSet']);
3335
-			if ($singleBodyPart['charSet']=='us-ascii')
3330
+			if ($singleBodyPart['charSet'] == 'us-ascii')
3336 3331
 			{
3337
-				$orgCharSet=$singleBodyPart['charSet'];
3332
+				$orgCharSet = $singleBodyPart['charSet'];
3338 3333
 				$singleBodyPart['charSet'] = Api\Translation::detect_encoding($singleBodyPart['body']);
3339 3334
 				error_log(__METHOD__.__LINE__.'reports:'.$orgCharSet.' but seems to be:'.$singleBodyPart['charSet']);
3340 3335
 			}
3341
-			$singleBodyPart['body'] = Api\Translation::convert_jsonsafe($singleBodyPart['body'],$singleBodyPart['charSet']);
3336
+			$singleBodyPart['body'] = Api\Translation::convert_jsonsafe($singleBodyPart['body'], $singleBodyPart['charSet']);
3342 3337
 			//error_log(__METHOD__.__LINE__.array2string($singleBodyPart));
3343
-			if($singleBodyPart['mimeType'] == 'text/plain')
3338
+			if ($singleBodyPart['mimeType'] == 'text/plain')
3344 3339
 			{
3345
-				$newBody	= @htmlentities($singleBodyPart['body'],ENT_QUOTES, strtoupper(Mail::$displayCharset));
3340
+				$newBody = @htmlentities($singleBodyPart['body'], ENT_QUOTES, strtoupper(Mail::$displayCharset));
3346 3341
 				//error_log(__METHOD__.__LINE__.'..'.$newBody);
3347 3342
 				// if empty and charset is utf8 try sanitizing the string in question
3348
-				if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(Mail::$displayCharset));
3343
+				if (empty($newBody) && strtolower($singleBodyPart['charSet']) == 'utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']), ENT_QUOTES, strtoupper(Mail::$displayCharset));
3349 3344
 				// if the conversion to htmlentities fails somehow, try without specifying the charset, which defaults to iso-
3350
-				if (empty($newBody)) $newBody    = htmlentities($singleBodyPart['body'],ENT_QUOTES);
3345
+				if (empty($newBody)) $newBody = htmlentities($singleBodyPart['body'], ENT_QUOTES);
3351 3346
 
3352 3347
 				// search http[s] links and make them as links available again
3353 3348
 				// to understand what's going on here, have a look at
@@ -3375,20 +3370,20 @@  discard block
 block discarded – undo
3375 3370
 				// since we do not display the message as HTML anymore we may want to insert good linebreaking (for visibility).
3376 3371
 				//error_log(__METHOD__.__LINE__.'..'.$newBody);
3377 3372
 				// dont break lines that start with > (&gt; as the text was processed with htmlentities before)
3378
-				$newBody	= "<pre>".Mail::wordwrap($newBody,90,"\n",'&gt;')."</pre>";
3373
+				$newBody = "<pre>".Mail::wordwrap($newBody, 90, "\n", '&gt;')."</pre>";
3379 3374
 			}
3380 3375
 			else
3381 3376
 			{
3382
-				$alreadyHtmlLawed=false;
3383
-				$newBody	= $singleBodyPart['body'];
3377
+				$alreadyHtmlLawed = false;
3378
+				$newBody = $singleBodyPart['body'];
3384 3379
 				//TODO:$newBody	= $this->highlightQuotes($newBody);
3385 3380
 				#error_log(print_r($newBody,true));
3386 3381
 				if ($useTidy && extension_loaded('tidy'))
3387 3382
 				{
3388 3383
 					$tidy = new tidy();
3389
-					$cleaned = $tidy->repairString($newBody, Mail::$tidy_config,'utf8');
3384
+					$cleaned = $tidy->repairString($newBody, Mail::$tidy_config, 'utf8');
3390 3385
 					// Found errors. Strip it all so there's some output
3391
-					if($tidy->getStatus() == 2)
3386
+					if ($tidy->getStatus() == 2)
3392 3387
 					{
3393 3388
 						error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$tidy->errorBuffer);
3394 3389
 					}
@@ -3399,7 +3394,7 @@  discard block
 block discarded – undo
3399 3394
 					if (!$preserveHTML)	// ToDo KL: $preserveHTML is NOT initialised, so always if is dead code
3400 3395
 					{
3401 3396
 						// filter only the 'body', as we only want that part, if we throw away the Api\Html
3402
-						preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array());
3397
+						preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array());
3403 3398
 						if ($matches[2])
3404 3399
 						{
3405 3400
 							$hasOther = true;
@@ -3410,7 +3405,7 @@  discard block
 block discarded – undo
3410 3405
 				else
3411 3406
 				{
3412 3407
 					// htmLawed filter only the 'body'
3413
-					preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array());
3408
+					preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array());
3414 3409
 					if ($matches[2])
3415 3410
 					{
3416 3411
 						$hasOther = true;
@@ -3419,10 +3414,10 @@  discard block
 block discarded – undo
3419 3414
 					$htmLawed = new Api\Html\HtmLawed();
3420 3415
 					// the next line should not be needed, but produces better results on HTML 2 Text conversion,
3421 3416
 					// as we switched off HTMLaweds tidy functionality
3422
-					$newBody = str_replace(array('&amp;amp;','<DIV><BR></DIV>',"<DIV>&nbsp;</DIV>",'<div>&nbsp;</div>'),array('&amp;','<BR>','<BR>','<BR>'),$newBody);
3423
-					$newBody = $htmLawed->run($newBody,Mail::$htmLawed_config);
3424
-					if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3];
3425
-					$alreadyHtmlLawed=true;
3417
+					$newBody = str_replace(array('&amp;amp;', '<DIV><BR></DIV>', "<DIV>&nbsp;</DIV>", '<div>&nbsp;</div>'), array('&amp;', '<BR>', '<BR>', '<BR>'), $newBody);
3418
+					$newBody = $htmLawed->run($newBody, Mail::$htmLawed_config);
3419
+					if ($hasOther && $preserveHTML) $newBody = $matches[1].$newBody.$matches[3];
3420
+					$alreadyHtmlLawed = true;
3426 3421
 				}
3427 3422
 				// do the cleanup, set for the use of purifier
3428 3423
 				//$newBodyBuff = $newBody;
@@ -3444,8 +3439,8 @@  discard block
 block discarded – undo
3444 3439
 				}
3445 3440
 */
3446 3441
 				// removes stuff between http and ?http
3447
-				$Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))';    // only http:// gets removed, other protocolls are shown
3448
-				$newBody = preg_replace('~'.$Protocol.'[^>]*\?'.$Protocol.'~sim','$1',$newBody); // removes stuff between http:// and ?http://
3442
+				$Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))'; // only http:// gets removed, other protocolls are shown
3443
+				$newBody = preg_replace('~'.$Protocol.'[^>]*\?'.$Protocol.'~sim', '$1', $newBody); // removes stuff between http:// and ?http://
3449 3444
 				// TRANSFORM MAILTO LINKS TO EMAILADDRESS ONLY, WILL BE SUBSTITUTED BY parseEmail TO CLICKABLE LINK
3450 3445
 				$newBody = preg_replace('/(?<!"|href=|href\s=\s|href=\s|href\s=)'.'mailto:([a-z0-9._-]+)@([a-z0-9_-]+)\.([a-z0-9._-]+)/i',
3451 3446
 					"\\1@\\2.\\3",
@@ -3458,7 +3453,7 @@  discard block
 block discarded – undo
3458 3453
 				// create links for inline images
3459 3454
 				if ($modifyURI)
3460 3455
 				{
3461
-					$newBody = self::resolve_inline_images ($newBody, $this->mailbox, $this->uid, $this->partID);
3456
+					$newBody = self::resolve_inline_images($newBody, $this->mailbox, $this->uid, $this->partID);
3462 3457
 				}
3463 3458
 				// email addresses / mailto links get now activated on client-side
3464 3459
 			}
@@ -3470,7 +3465,7 @@  discard block
 block discarded – undo
3470 3465
 		$body = preg_replace("/(\\\\\\\\)([\w,\\\\,-]+)/i",
3471 3466
 			"<a href=\"file:$1$2\" target=\"_blank\"><font color=\"blue\">$1$2</font></a>", $body);
3472 3467
 
3473
-		$body = preg_replace($nonDisplayAbleCharacters,'',$body);
3468
+		$body = preg_replace($nonDisplayAbleCharacters, '', $body);
3474 3469
 
3475 3470
 		return $body;
3476 3471
 	}
@@ -3485,7 +3480,7 @@  discard block
 block discarded – undo
3485 3480
 	 * @param string $_messageType = 'html', message type is either html or plain
3486 3481
 	 * @return string message body including all CID images replaced
3487 3482
 	 */
3488
-	public static function resolve_inline_images ($_body,$_mailbox, $_uid, $_partID, $_messageType = 'html')
3483
+	public static function resolve_inline_images($_body, $_mailbox, $_uid, $_partID, $_messageType = 'html')
3489 3484
 	{
3490 3485
 		if ($_messageType === 'plain')
3491 3486
 		{
@@ -3493,7 +3488,7 @@  discard block
 block discarded – undo
3493 3488
 		}
3494 3489
 		else
3495 3490
 		{
3496
-			foreach(array('src','url','background') as $type)
3491
+			foreach (array('src', 'url', 'background') as $type)
3497 3492
 			{
3498 3493
 				$_body = self::resolve_inline_image_byType($_body, $_mailbox, $_uid, $_partID, $type);
3499 3494
 			}
@@ -3514,16 +3509,16 @@  discard block
 block discarded – undo
3514 3509
 	 *	not provided, a default (using mail) will be used.
3515 3510
 	 * @return string returns body content including all CID replacements
3516 3511
 	 */
3517
-	public static function resolve_inline_image_byType ($_body,$_mailbox, $_uid, $_partID, $_type ='src', callable $_link_callback = null)
3512
+	public static function resolve_inline_image_byType($_body, $_mailbox, $_uid, $_partID, $_type = 'src', callable $_link_callback = null)
3518 3513
 	{
3519 3514
 		/**
3520 3515
 		 * Callback to generate the link
3521 3516
 		 */
3522
-		if(is_null($_link_callback))
3517
+		if (is_null($_link_callback))
3523 3518
 		{
3524 3519
 			$_link_callback = function($_cid) use ($_mailbox, $_uid, $_partID)
3525 3520
 			{
3526
-				$linkData = array (
3521
+				$linkData = array(
3527 3522
 					'menuaction'    => 'mail.mail_ui.displayImage',
3528 3523
 					'uid'		=> $_uid,
3529 3524
 					'mailbox'	=> base64_encode($_mailbox),
@@ -3544,7 +3539,7 @@  discard block
 block discarded – undo
3544 3539
 		 * @param string $_type
3545 3540
 		 * @return string|boolean returns the replace
3546 3541
 		*/
3547
-		$replace_callback = function ($matches) use ($_mailbox,$_uid, $_partID,  $_type, $_link_callback)
3542
+		$replace_callback = function($matches) use ($_mailbox, $_uid, $_partID, $_type, $_link_callback)
3548 3543
 		{
3549 3544
 			if (!$_type)	return false;
3550 3545
 			$CID = '';
@@ -3566,7 +3561,7 @@  discard block
 block discarded – undo
3566 3561
 					break;
3567 3562
 			}
3568 3563
 
3569
-			static $cache = array();	// some caching, if mails containing the same image multiple times
3564
+			static $cache = array(); // some caching, if mails containing the same image multiple times
3570 3565
 
3571 3566
 			if (is_array($matches) && $CID)
3572 3567
 			{
@@ -3576,7 +3571,7 @@  discard block
 block discarded – undo
3576 3571
 				{
3577 3572
 					if (!isset($cache[$imageURL]))
3578 3573
 					{
3579
-						if ($_type !="background" && !$imageURL)
3574
+						if ($_type != "background" && !$imageURL)
3580 3575
 						{
3581 3576
 							$bo = Mail::getInstance(false, mail_ui::$icServerID);
3582 3577
 							$attachment = $bo->getAttachmentByCID($_uid, $CID, $_partID);
@@ -3617,16 +3612,16 @@  discard block
 block discarded – undo
3617 3612
 		};
3618 3613
 
3619 3614
 		// return new body content base on chosen type
3620
-		switch($_type)
3615
+		switch ($_type)
3621 3616
 		{
3622 3617
 			case"plain":
3623
-				return preg_replace_callback("/\[cid:(.*)\]/iU",$replace_callback,$_body);
3618
+				return preg_replace_callback("/\[cid:(.*)\]/iU", $replace_callback, $_body);
3624 3619
 			case "src":
3625
-				return preg_replace_callback("/src=(\"|\')cid:(.*)(\"|\')/iU",$replace_callback,$_body);
3620
+				return preg_replace_callback("/src=(\"|\')cid:(.*)(\"|\')/iU", $replace_callback, $_body);
3626 3621
 			case "url":
3627
-				return preg_replace_callback("/url\(cid:(.*)\);/iU",$replace_callback,$_body);
3622
+				return preg_replace_callback("/url\(cid:(.*)\);/iU", $replace_callback, $_body);
3628 3623
 			case "background":
3629
-				return preg_replace_callback("/background=(\"|\')cid:(.*)(\"|\')/iU",$replace_callback,$_body);
3624
+				return preg_replace_callback("/background=(\"|\')cid:(.*)(\"|\')/iU", $replace_callback, $_body);
3630 3625
 		}
3631 3626
 	}
3632 3627
 
@@ -3634,7 +3629,7 @@  discard block
 block discarded – undo
3634 3629
 	 * importMessage
3635 3630
 	 * @param array $content = null an array of content
3636 3631
 	 */
3637
-	function importMessage($content=null)
3632
+	function importMessage($content = null)
3638 3633
 	{
3639 3634
 		//error_log(__METHOD__.__LINE__.$this->mail_bo->getDraftFolder());
3640 3635
 
@@ -3656,7 +3651,7 @@  discard block
 block discarded – undo
3656 3651
 			}
3657 3652
 			$destination = $content['FOLDER'][0];
3658 3653
 
3659
-			if (stripos($destination,self::$delimiter)!==false) list($icServerID,$destination) = explode(self::$delimiter,$destination,2);
3654
+			if (stripos($destination, self::$delimiter) !== false) list($icServerID, $destination) = explode(self::$delimiter, $destination, 2);
3660 3655
 			if ($icServerID && $icServerID != $this->mail_bo->profileID)
3661 3656
 			{
3662 3657
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -3667,16 +3662,15 @@  discard block
 block discarded – undo
3667 3662
 			$importFailed = false;
3668 3663
 			try
3669 3664
 			{
3670
-				$messageUid = $this->importMessageToFolder($file,$destination,$importID);
3671
-			    $linkData = array
3672
-			    (
3665
+				$messageUid = $this->importMessageToFolder($file, $destination, $importID);
3666
+			    $linkData = array(
3673 3667
 					'id' => $this->createRowID($destination, $messageUid, true),
3674 3668
 			    );
3675 3669
 			}
3676 3670
 			catch (Api\Exception\WrongUserinput $e)
3677 3671
 			{
3678
-					$importFailed=true;
3679
-					$content['msg']		= $e->getMessage();
3672
+					$importFailed = true;
3673
+					$content['msg'] = $e->getMessage();
3680 3674
 			}
3681 3675
 			if (!$importFailed)
3682 3676
 			{
@@ -3686,16 +3680,16 @@  discard block
 block discarded – undo
3686 3680
 			}
3687 3681
 		}
3688 3682
 		if (!is_array($content)) $content = array();
3689
-		if (empty($content['FOLDER'])) $content['FOLDER']=(array)$this->mail_bo->getDraftFolder();
3683
+		if (empty($content['FOLDER'])) $content['FOLDER'] = (array)$this->mail_bo->getDraftFolder();
3690 3684
 		if (!empty($content['FOLDER']))
3691 3685
 		{
3692 3686
 			$compose = new mail_compose();
3693
-			$sel_options['FOLDER'] = $compose->ajax_searchFolder(0,true);
3687
+			$sel_options['FOLDER'] = $compose->ajax_searchFolder(0, true);
3694 3688
 		}
3695 3689
 
3696 3690
 		$etpl = new Etemplate('mail.importMessage');
3697
-		$etpl->setElementAttribute('uploadForImport','onFinish','app.mail.uploadForImport');
3698
-		$etpl->exec('mail.mail_ui.importMessage',$content,$sel_options,array(),array(),2);
3691
+		$etpl->setElementAttribute('uploadForImport', 'onFinish', 'app.mail.uploadForImport');
3692
+		$etpl->exec('mail.mail_ui.importMessage', $content, $sel_options, array(), array(), 2);
3699 3693
 	}
3700 3694
 
3701 3695
 	/**
@@ -3707,7 +3701,7 @@  discard block
 block discarded – undo
3707 3701
 	 * @param string $importID ID for the imported message, used by attachments to identify them unambiguously
3708 3702
 	 * @return mixed $messageUID or exception
3709 3703
 	 */
3710
-	function importMessageToFolder($_formData,&$_folder,$importID='')
3704
+	function importMessageToFolder($_formData, &$_folder, $importID = '')
3711 3705
 	{
3712 3706
 		$importfailed = false;
3713 3707
 		//error_log(__METHOD__.__LINE__.array2string($_formData));
@@ -3715,7 +3709,7 @@  discard block
 block discarded – undo
3715 3709
 		// check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.)
3716 3710
 		try
3717 3711
 		{
3718
-			$tmpFileName = Mail::checkFileBasics($_formData,$importID);
3712
+			$tmpFileName = Mail::checkFileBasics($_formData, $importID);
3719 3713
 		}
3720 3714
 		catch (Api\Exception\WrongUserinput $e)
3721 3715
 		{
@@ -3739,29 +3733,29 @@  discard block
 block discarded – undo
3739 3733
 			if (empty($_folder))
3740 3734
 			{
3741 3735
 				$importfailed = true;
3742
-				$alert_msg .= lang("Import of message %1 failed. Destination Folder not set.",$_formData['name']);
3736
+				$alert_msg .= lang("Import of message %1 failed. Destination Folder not set.", $_formData['name']);
3743 3737
 			}
3744 3738
 			$delimiter = $this->mail_bo->getHierarchyDelimiter();
3745
-			if($_folder=='INBOX'.$delimiter) $_folder='INBOX';
3739
+			if ($_folder == 'INBOX'.$delimiter) $_folder = 'INBOX';
3746 3740
 			if ($importfailed === false)
3747 3741
 			{
3748
-				if ($this->mail_bo->folderExists($_folder,true)) {
3742
+				if ($this->mail_bo->folderExists($_folder, true)) {
3749 3743
 					try
3750 3744
 					{
3751 3745
 						$messageUid = $this->mail_bo->appendMessage($_folder,
3752 3746
 							$mailObject->getRaw(),
3753
-							null,'\\Seen');
3747
+							null, '\\Seen');
3754 3748
 					}
3755 3749
 					catch (Api\Exception\WrongUserinput $e)
3756 3750
 					{
3757 3751
 						$importfailed = true;
3758
-						$alert_msg .= lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$_formData['name'],$_folder,$e->getMessage());
3752
+						$alert_msg .= lang("Import of message %1 failed. Could not save message to folder %2 due to: %3", $_formData['name'], $_folder, $e->getMessage());
3759 3753
 					}
3760 3754
 				}
3761 3755
 				else
3762 3756
 				{
3763 3757
 					$importfailed = true;
3764
-					$alert_msg .= lang("Import of message %1 failed. Destination Folder %2 does not exist.",$_formData['name'],$_folder);
3758
+					$alert_msg .= lang("Import of message %1 failed. Destination Folder %2 does not exist.", $_formData['name'], $_folder);
3765 3759
 				}
3766 3760
 			}
3767 3761
 		}
@@ -3787,9 +3781,9 @@  discard block
 block discarded – undo
3787 3781
 	 *								 $formData['size']	= 2136;
3788 3782
 	 * @return void
3789 3783
 	 */
3790
-	function importMessageFromVFS2DraftAndEdit($formData='')
3784
+	function importMessageFromVFS2DraftAndEdit($formData = '')
3791 3785
 	{
3792
-		$this->importMessageFromVFS2DraftAndDisplay($formData,'edit');
3786
+		$this->importMessageFromVFS2DraftAndDisplay($formData, 'edit');
3793 3787
 	}
3794 3788
 
3795 3789
 	/**
@@ -3804,7 +3798,7 @@  discard block
 block discarded – undo
3804 3798
 	 * @param string $mode mode to open ImportedMessage display and edit are supported
3805 3799
 	 * @return void
3806 3800
 	 */
3807
-	function importMessageFromVFS2DraftAndDisplay($formData='',$mode='display')
3801
+	function importMessageFromVFS2DraftAndDisplay($formData = '', $mode = 'display')
3808 3802
 	{
3809 3803
 		if (empty($formData)) if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData'];
3810 3804
 		//error_log(__METHOD__.__LINE__.':'.array2string($formData).' Mode:'.$mode.'->'.function_backtrace());
@@ -3817,43 +3811,42 @@  discard block
 block discarded – undo
3817 3811
 			$formData['file'] = 'egw-data://'.$formData['data'];
3818 3812
 		}
3819 3813
 		// name should be set to meet the requirements of checkFileBasics
3820
-		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['name']))
3814
+		if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && empty($formData['name']))
3821 3815
 		{
3822
-			$buff = explode('/',$formData['file']);
3816
+			$buff = explode('/', $formData['file']);
3823 3817
 			if (is_array($buff)) $formData['name'] = array_pop($buff); // take the last part as name
3824 3818
 		}
3825 3819
 		// type should be set to meet the requirements of checkFileBasics
3826
-		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['type']))
3820
+		if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && empty($formData['type']))
3827 3821
 		{
3828
-			$buff = explode('.',$formData['file']);
3822
+			$buff = explode('.', $formData['file']);
3829 3823
 			$suffix = '';
3830 3824
 			if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
3831 3825
 			if (!empty($suffix)) $formData['type'] = Api\MimeMagic::ext2mime($suffix);
3832 3826
 		}
3833 3827
 		// size should be set to meet the requirements of checkFileBasics
3834
-		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && !isset($formData['size']))
3828
+		if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && !isset($formData['size']))
3835 3829
 		{
3836 3830
 			$formData['size'] = strlen($formData['file']); // set some size, to meet requirements of checkFileBasics
3837 3831
 		}
3838 3832
 		try
3839 3833
 		{
3840
-			$messageUid = $this->importMessageToFolder($formData,$draftFolder,$importID);
3841
-			$linkData = array
3842
-			(
3843
-		        'menuaction'    => ($mode=='display'?'mail.mail_ui.displayMessage':'mail.mail_compose.composeFromDraft'),
3844
-				'id'		=> $this->createRowID($draftFolder,$messageUid,true),
3834
+			$messageUid = $this->importMessageToFolder($formData, $draftFolder, $importID);
3835
+			$linkData = array(
3836
+		        'menuaction'    => ($mode == 'display' ? 'mail.mail_ui.displayMessage' : 'mail.mail_compose.composeFromDraft'),
3837
+				'id'		=> $this->createRowID($draftFolder, $messageUid, true),
3845 3838
 				'deleteDraftOnClose' => 1,
3846 3839
 			);
3847
-			if ($mode!='display')
3840
+			if ($mode != 'display')
3848 3841
 			{
3849 3842
 				unset($linkData['deleteDraftOnClose']);
3850
-				$linkData['method']	='importMessageToMergeAndSend';
3843
+				$linkData['method'] = 'importMessageToMergeAndSend';
3851 3844
 			}
3852 3845
 			else
3853 3846
 			{
3854
-				$linkData['mode']=$mode;
3847
+				$linkData['mode'] = $mode;
3855 3848
 			}
3856
-			Egw::redirect_link('/index.php',$linkData);
3849
+			Egw::redirect_link('/index.php', $linkData);
3857 3850
 		}
3858 3851
 		catch (Api\Exception\WrongUserinput $e)
3859 3852
 		{
@@ -3868,13 +3861,13 @@  discard block
 block discarded – undo
3868 3861
 	 *
3869 3862
 	 * @return xajax response
3870 3863
 	 */
3871
-	function loadEmailBody($_messageID=null,$_partID=null,$_htmloptions=null)
3864
+	function loadEmailBody($_messageID = null, $_partID = null, $_htmloptions = null)
3872 3865
 	{
3873 3866
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
3874 3867
 		if (!$_messageID && !empty($_GET['_messageID'])) $_messageID = $_GET['_messageID'];
3875 3868
 		if (!$_partID && !empty($_GET['_partID'])) $_partID = $_GET['_partID'];
3876 3869
 		if (!$_htmloptions && !empty($_GET['_htmloptions'])) $_htmloptions = $_GET['_htmloptions'];
3877
-		if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions");
3870
+		if (Mail::$debug) error_log(__METHOD__."->".print_r($_messageID, true).",$_partID,$_htmloptions");
3878 3871
 		if (empty($_messageID)) return "";
3879 3872
 		$uidA = self::splitRowID($_messageID);
3880 3873
 		$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
@@ -3888,7 +3881,7 @@  discard block
 block discarded – undo
3888 3881
 			$this->changeProfile($icServerID);
3889 3882
 		}
3890 3883
 
3891
-		$bodyResponse = $this->get_load_email_data($messageID,$_partID,$folder,$_htmloptions, $_POST['smime_passphrase']);
3884
+		$bodyResponse = $this->get_load_email_data($messageID, $_partID, $folder, $_htmloptions, $_POST['smime_passphrase']);
3892 3885
 		//error_log(array2string($bodyResponse));
3893 3886
 		echo $bodyResponse;
3894 3887
 
@@ -3910,7 +3903,7 @@  discard block
 block discarded – undo
3910 3903
 			$oA = array();
3911 3904
 			foreach ($_folder as $_folderName)
3912 3905
 			{
3913
-				list($profileID,$folderName) = explode(self::$delimiter,$_folderName,2);
3906
+				list($profileID, $folderName) = explode(self::$delimiter, $_folderName, 2);
3914 3907
 				if (is_numeric($profileID))
3915 3908
 				{
3916 3909
 					if ($profileID != $this->mail_bo->profileID) continue; // only current connection
@@ -3918,20 +3911,20 @@  discard block
 block discarded – undo
3918 3911
 					{
3919 3912
 						try
3920 3913
 						{
3921
-							$fS = $this->mail_bo->getFolderStatus($folderName,false,false,false);
3914
+							$fS = $this->mail_bo->getFolderStatus($folderName, false, false, false);
3922 3915
 						}
3923 3916
 						catch (Exception $e)
3924 3917
 						{
3925
-							if (Mail::$debug) error_log(__METHOD__,' ()'.$e->getMessage ());
3918
+							if (Mail::$debug) error_log(__METHOD__, ' ()'.$e->getMessage());
3926 3919
 							continue;
3927 3920
 						}
3928
-						if (in_array($fS['shortDisplayName'],Mail::$autoFolders)) $fS['shortDisplayName']=lang($fS['shortDisplayName']);
3921
+						if (in_array($fS['shortDisplayName'], Mail::$autoFolders)) $fS['shortDisplayName'] = lang($fS['shortDisplayName']);
3929 3922
 						//error_log(__METHOD__.__LINE__.array2string($fS));
3930 3923
 						if ($fS['unseen'])
3931 3924
 						{
3932 3925
 							$oA[$_folderName] = $fS['shortDisplayName'].' ('.$fS['unseen'].')';
3933 3926
 						}
3934
-						if ($fS['unseen']==0 && $fS['shortDisplayName'])
3927
+						if ($fS['unseen'] == 0 && $fS['shortDisplayName'])
3935 3928
 						{
3936 3929
 							$oA[$_folderName] = $fS['shortDisplayName'];
3937 3930
 						}
@@ -3942,7 +3935,7 @@  discard block
 block discarded – undo
3942 3935
 			if ($oA)
3943 3936
 			{
3944 3937
 				$response = Api\Json\Response::get();
3945
-				$response->call('app.mail.mail_setFolderStatus',$oA);
3938
+				$response->call('app.mail.mail_setFolderStatus', $oA);
3946 3939
 			}
3947 3940
 		}
3948 3941
 	}
@@ -3956,13 +3949,13 @@  discard block
 block discarded – undo
3956 3949
 	 */
3957 3950
 	function ajax_addFolder($_parent, $_new)
3958 3951
 	{
3959
-		$error='';
3952
+		$error = '';
3960 3953
 		$created = false;
3961 3954
 		$response = Api\Json\Response::get();
3962 3955
 		$del = $this->mail_bo->getHierarchyDelimiter(false);
3963 3956
 		if (strpos($_new, $del) !== FALSE)
3964 3957
 		{
3965
-			return $response->call('egw.message', lang('failed to rename %1 ! Reason: %2 is not allowed!',$_parent, $del));
3958
+			return $response->call('egw.message', lang('failed to rename %1 ! Reason: %2 is not allowed!', $_parent, $del));
3966 3959
 		}
3967 3960
 		if ($_parent)
3968 3961
 		{
@@ -3970,15 +3963,15 @@  discard block
 block discarded – undo
3970 3963
 			//the conversion is handeled by horde, frontend interaction is all utf-8
3971 3964
 			$new = $this->mail_bo->decodeEntityFolderName($_new);
3972 3965
 
3973
-			list($profileID,$p_no_delimiter) = explode(self::$delimiter,$parent,2);
3966
+			list($profileID, $p_no_delimiter) = explode(self::$delimiter, $parent, 2);
3974 3967
 
3975 3968
 			if (is_numeric($profileID))
3976 3969
 			{
3977
-				if ($profileID != $this->mail_bo->profileID) $this->changeProfile ($profileID);
3970
+				if ($profileID != $this->mail_bo->profileID) $this->changeProfile($profileID);
3978 3971
 				$delimiter = $this->mail_bo->getHierarchyDelimiter(false);
3979
-				$parts = explode($delimiter,$new);
3972
+				$parts = explode($delimiter, $new);
3980 3973
 
3981
-				if (!!empty($parent)) $folderStatus = $this->mail_bo->getFolderStatus($parent,false);
3974
+				if (!!empty($parent)) $folderStatus = $this->mail_bo->getFolderStatus($parent, false);
3982 3975
 
3983 3976
 				//open the INBOX
3984 3977
 				$this->mail_bo->reopen('INBOX');
@@ -3987,22 +3980,22 @@  discard block
 block discarded – undo
3987 3980
 				if (!empty($parts))
3988 3981
 				{
3989 3982
 					$counter = 0;
3990
-					foreach($parts as $subTree)
3983
+					foreach ($parts as $subTree)
3991 3984
 					{
3992 3985
 						$err = null;
3993
-						if(($new = $this->mail_bo->createFolder($p_no_delimiter, $subTree, $err)))
3986
+						if (($new = $this->mail_bo->createFolder($p_no_delimiter, $subTree, $err)))
3994 3987
 						{
3995 3988
 							$counter++;
3996 3989
 							if (!$p_no_delimiter)
3997 3990
 							{
3998
-								$status = $this->mail_bo->getFolderStatus($new,false, true, true);
3991
+								$status = $this->mail_bo->getFolderStatus($new, false, true, true);
3999 3992
 								if (!$status['subscribed'])
4000 3993
 								{
4001 3994
 									try
4002 3995
 									{
4003
-										$this->mail_bo->icServer->subscribeMailbox ('INBOX'.$delimiter.$new);
3996
+										$this->mail_bo->icServer->subscribeMailbox('INBOX'.$delimiter.$new);
4004 3997
 									}
4005
-									catch(Horde_Imap_Client_Exception $e)
3998
+									catch (Horde_Imap_Client_Exception $e)
4006 3999
 									{
4007 4000
 										$error = Lang('Folder %1 has been created successfully,'.
4008 4001
 												' although the subscription failed because of %2', $new, $e->getMessage());
@@ -4023,16 +4016,16 @@  discard block
 block discarded – undo
4023 4016
 							}
4024 4017
 						}
4025 4018
 					}
4026
-					if ($counter == count($parts)) $created=true;
4019
+					if ($counter == count($parts)) $created = true;
4027 4020
 				}
4028 4021
 				if (!empty($new)) $this->mail_bo->reopen($new);
4029 4022
 			}
4030 4023
 
4031 4024
 
4032
-			if ($created===true && $error =='')
4025
+			if ($created === true && $error == '')
4033 4026
 			{
4034 4027
 				$this->mail_bo->resetFolderObjectCache($profileID);
4035
-				if ( $folderStatus['shortDisplayName'])
4028
+				if ($folderStatus['shortDisplayName'])
4036 4029
 				{
4037 4030
 					$nodeInfo = array($parent=>$folderStatus['shortDisplayName']);
4038 4031
 				}
@@ -4040,13 +4033,13 @@  discard block
 block discarded – undo
4040 4033
 				{
4041 4034
 					$nodeInfo = array($profileID=>lang('INBOX'));
4042 4035
 				}
4043
-				$response->call('app.mail.mail_reloadNode',$nodeInfo);
4036
+				$response->call('app.mail.mail_reloadNode', $nodeInfo);
4044 4037
 			}
4045 4038
 			else
4046 4039
 			{
4047 4040
 				if ($error)
4048 4041
 				{
4049
-					$response->call('egw.message',$error);
4042
+					$response->call('egw.message', $error);
4050 4043
 				}
4051 4044
 			}
4052 4045
 		}
@@ -4069,7 +4062,7 @@  discard block
 block discarded – undo
4069 4062
 		$del = $this->mail_bo->getHierarchyDelimiter(false);
4070 4063
 		if (strpos($_newName, $del) !== FALSE)
4071 4064
 		{
4072
-			return $response->call('egw.message', lang('failed to rename %1 ! Reason: %2 is not allowed!',$_folderName, $del));
4065
+			return $response->call('egw.message', lang('failed to rename %1 ! Reason: %2 is not allowed!', $_folderName, $del));
4073 4066
 		}
4074 4067
 
4075 4068
 		if ($_folderName)
@@ -4079,22 +4072,22 @@  discard block
 block discarded – undo
4079 4072
 			$_newName = $this->mail_bo->decodeEntityFolderName($_newName);
4080 4073
 
4081 4074
 			$oA = array();
4082
-			list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
4075
+			list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
4083 4076
 			$hasChildren = false;
4084 4077
 			if (is_numeric($profileID))
4085 4078
 			{
4086
-				if ($profileID != $this->mail_bo->profileID) $this->changeProfile ($profileID);
4087
-				$pA = explode($del,$folderName);
4079
+				if ($profileID != $this->mail_bo->profileID) $this->changeProfile($profileID);
4080
+				$pA = explode($del, $folderName);
4088 4081
 				array_pop($pA);
4089
-				$parentFolder = implode($del,$pA);
4090
-				if (strtoupper($folderName)!= 'INBOX')
4082
+				$parentFolder = implode($del, $pA);
4083
+				if (strtoupper($folderName) != 'INBOX')
4091 4084
 				{
4092 4085
 					//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
4093
-					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false);
4086
+					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false);
4094 4087
 					//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
4095
-					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false)
4088
+					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false)
4096 4089
 					{
4097
-						$hasChildren=true; // translates to: hasChildren -> dynamicLoading
4090
+						$hasChildren = true; // translates to: hasChildren -> dynamicLoading
4098 4091
 						$delimiter = $this->mail_bo->getHierarchyDelimiter();
4099 4092
 						$nameSpace = $this->mail_bo->_getNameSpaces();
4100 4093
 						$prefix = $this->mail_bo->getFolderPrefixFromNamespace($nameSpace, $folderName);
@@ -4111,7 +4104,7 @@  discard block
 block discarded – undo
4111 4104
 							else
4112 4105
 							{
4113 4106
 								$rv = $this->mail_bo->icServer->subscribeMailbox($folder, false);
4114
-								$fragments[$profileID.self::$delimiter.$folder] = substr($folder,strlen($folderName));
4107
+								$fragments[$profileID.self::$delimiter.$folder] = substr($folder, strlen($folderName));
4115 4108
 							}
4116 4109
 						}
4117 4110
 						//error_log(__METHOD__.__LINE__.' Fetched Subfolders->'.array2string($fragments));
@@ -4121,7 +4114,7 @@  discard block
 block discarded – undo
4121 4114
 					$success = false;
4122 4115
 					try
4123 4116
 					{
4124
-						if(($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName)))
4117
+						if (($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName)))
4125 4118
 						{
4126 4119
 							$this->mail_bo->resetFolderObjectCache($profileID);
4127 4120
 							//enforce the subscription to the newly named server, as it seems to fail for names with umlauts
@@ -4132,11 +4125,11 @@  discard block
 block discarded – undo
4132 4125
 					}
4133 4126
 					catch (Exception $e)
4134 4127
 					{
4135
-						$newFolderName=$folderName;
4128
+						$newFolderName = $folderName;
4136 4129
 						$msg = $e->getMessage();
4137 4130
 					}
4138 4131
 					$this->mail_bo->reopen($newFolderName);
4139
-					$fS = $this->mail_bo->getFolderStatus($newFolderName,false);
4132
+					$fS = $this->mail_bo->getFolderStatus($newFolderName, false);
4140 4133
 					//error_log(__METHOD__.__LINE__.array2string($fS));
4141 4134
 					if ($hasChildren)
4142 4135
 					{
@@ -4167,12 +4160,12 @@  discard block
 block discarded – undo
4167 4160
 					{
4168 4161
 						$oA[$_folderName]['desc'] = $fS['shortDisplayName'];
4169 4162
 					}
4170
-					foreach($fragments as $oldFolderName => $fragment)
4163
+					foreach ($fragments as $oldFolderName => $fragment)
4171 4164
 					{
4172 4165
 						//error_log(__METHOD__.__LINE__.':'.$oldFolderName.'->'.$profileID.self::$delimiter.$newFolderName.$fragment);
4173 4166
 						$oA[$oldFolderName]['id'] = $profileID.self::$delimiter.$newFolderName.$fragment;
4174 4167
 						$oA[$oldFolderName]['olddesc'] = '#skip-user-interaction-message#';
4175
-						$fS = $this->mail_bo->getFolderStatus($newFolderName.$fragment,false);
4168
+						$fS = $this->mail_bo->getFolderStatus($newFolderName.$fragment, false);
4176 4169
 						if ($fS['unseen'])
4177 4170
 						{
4178 4171
 							$oA[$oldFolderName]['desc'] = $fS['shortDisplayName'].' ('.$fS['unseen'].')';
@@ -4185,20 +4178,20 @@  discard block
 block discarded – undo
4185 4178
 					}
4186 4179
 				}
4187 4180
 			}
4188
-			if ($folderName==$this->mail_bo->sessionData['mailbox'])
4181
+			if ($folderName == $this->mail_bo->sessionData['mailbox'])
4189 4182
 			{
4190
-				$this->mail_bo->sessionData['mailbox']=$newFolderName;
4183
+				$this->mail_bo->sessionData['mailbox'] = $newFolderName;
4191 4184
 				$this->mail_bo->saveSessionData();
4192 4185
 			}
4193 4186
 			//error_log(__METHOD__.__LINE__.array2string($oA));
4194 4187
 			$response = Api\Json\Response::get();
4195 4188
 			if ($oA && $success)
4196 4189
 			{
4197
-				$response->call('app.mail.mail_setLeaf',$oA);
4190
+				$response->call('app.mail.mail_setLeaf', $oA);
4198 4191
 			}
4199 4192
 			else
4200 4193
 			{
4201
-				$response->call('egw.refresh',lang('failed to rename %1 ! Reason: %2',$oldFolderName,$msg),'mail');
4194
+				$response->call('egw.refresh', lang('failed to rename %1 ! Reason: %2', $oldFolderName, $msg), 'mail');
4202 4195
 			}
4203 4196
 		}
4204 4197
 	}
@@ -4210,12 +4203,12 @@  discard block
 block discarded – undo
4210 4203
 	 * @param boolean $_subscribedOnly = true
4211 4204
 	 * @return void
4212 4205
 	 */
4213
-	function ajax_reloadNode($_folderName,$_subscribedOnly=true)
4206
+	function ajax_reloadNode($_folderName, $_subscribedOnly = true)
4214 4207
 	{
4215 4208
 		Api\Translation::add_app('mail');
4216 4209
 		$oldPrefForSubscribedOnly = !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'];
4217 4210
 		$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4218
-		list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
4211
+		list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
4219 4212
 		if ($profileID != $this->mail_bo->profileID) $this->changeProfile($profileID);
4220 4213
 
4221 4214
 		// if pref and required mode dont match -> reset the folderObject cache to ensure
@@ -4224,13 +4217,13 @@  discard block
 block discarded – undo
4224 4217
 
4225 4218
 		if (!empty($folderName))
4226 4219
 		{
4227
-			$parentFolder=(!empty($folderName)?$folderName:'INBOX');
4228
-			$folderInfo = $this->mail_bo->getFolderStatus($parentFolder,false,false,false);
4220
+			$parentFolder = (!empty($folderName) ? $folderName : 'INBOX');
4221
+			$folderInfo = $this->mail_bo->getFolderStatus($parentFolder, false, false, false);
4229 4222
 			if ($folderInfo['unseen'])
4230 4223
 			{
4231 4224
 				$folderInfo['shortDisplayName'] = $folderInfo['shortDisplayName'].' ('.$folderInfo['unseen'].')';
4232 4225
 			}
4233
-			if ($folderInfo['unseen']==0 && $folderInfo['shortDisplayName'])
4226
+			if ($folderInfo['unseen'] == 0 && $folderInfo['shortDisplayName'])
4234 4227
 			{
4235 4228
 				$folderInfo['shortDisplayName'] = $folderInfo['shortDisplayName'];
4236 4229
 			}
@@ -4246,11 +4239,11 @@  discard block
 block discarded – undo
4246 4239
 		}
4247 4240
 		// Send full info back in the response
4248 4241
 		$response = Api\Json\Response::get();
4249
-		foreach($refreshData as $folder => &$name)
4242
+		foreach ($refreshData as $folder => &$name)
4250 4243
 		{
4251
-			$name = $this->mail_tree->getTree($folder,$profileID,1,false, $_subscribedOnly,true);
4244
+			$name = $this->mail_tree->getTree($folder, $profileID, 1, false, $_subscribedOnly, true);
4252 4245
 		}
4253
-		$response->call('app.mail.mail_reloadNode',$refreshData);
4246
+		$response->call('app.mail.mail_reloadNode', $refreshData);
4254 4247
 
4255 4248
 	}
4256 4249
 
@@ -4266,7 +4259,7 @@  discard block
 block discarded – undo
4266 4259
 	 * @param type $_rowid row id from nm
4267 4260
 	 *
4268 4261
 	 */
4269
-	function ajax_resolveWinmail ($_rowid)
4262
+	function ajax_resolveWinmail($_rowid)
4270 4263
 	{
4271 4264
 		$response = Api\Json\Response::get();
4272 4265
 
@@ -4274,7 +4267,7 @@  discard block
 block discarded – undo
4274 4267
 		$uid = $idParts['msgUID'];
4275 4268
 		$mbox = $idParts['folder'];
4276 4269
 
4277
-		$attachments = $this->mail_bo->getMessageAttachments($uid, null, null, false,true,true,$mbox);
4270
+		$attachments = $this->mail_bo->getMessageAttachments($uid, null, null, false, true, true, $mbox);
4278 4271
 		if (is_array($attachments))
4279 4272
 		{
4280 4273
 			$attachments = $this->createAttachmentBlock($attachments, $_rowid, $uid, $mbox, false);
@@ -4301,31 +4294,31 @@  discard block
 block discarded – undo
4301 4294
 		{
4302 4295
 			$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4303 4296
 			$_newLocation2 = $this->mail_bo->decodeEntityFolderName($_target);
4304
-			list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
4305
-			list($newProfileID,$_newLocation) = explode(self::$delimiter,$_newLocation2,2);
4297
+			list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
4298
+			list($newProfileID, $_newLocation) = explode(self::$delimiter, $_newLocation2, 2);
4306 4299
 			if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID) $this->changeProfile($profileID);
4307 4300
 			$del = $this->mail_bo->getHierarchyDelimiter(false);
4308 4301
 			$hasChildren = false;
4309 4302
 			if (is_numeric($profileID))
4310 4303
 			{
4311
-				$pA = explode($del,$folderName);
4304
+				$pA = explode($del, $folderName);
4312 4305
 				$namePart = array_pop($pA);
4313 4306
 				$_newName = $namePart;
4314
-				$oldParentFolder = implode($del,$pA);
4307
+				$oldParentFolder = implode($del, $pA);
4315 4308
 				$parentFolder = $_newLocation;
4316 4309
 
4317
-				if (strtoupper($folderName)!= 'INBOX' &&
4310
+				if (strtoupper($folderName) != 'INBOX' &&
4318 4311
 					(($oldParentFolder === $parentFolder) || //$oldParentFolder == $parentFolder means move on same level
4319 4312
 					(($oldParentFolder != $parentFolder &&
4320
-					strlen($parentFolder)>0 && strlen($folderName)>0 &&
4321
-					strpos($parentFolder,$folderName)===false)))) // indicates that we move the older up the tree within its own branch
4313
+					strlen($parentFolder) > 0 && strlen($folderName) > 0 &&
4314
+					strpos($parentFolder, $folderName) === false)))) // indicates that we move the older up the tree within its own branch
4322 4315
 				{
4323 4316
 					//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
4324
-					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false);
4317
+					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false, false, false);
4325 4318
 					//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
4326
-					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false)
4319
+					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false)
4327 4320
 					{
4328
-						$hasChildren=true; // translates to: hasChildren -> dynamicLoading
4321
+						$hasChildren = true; // translates to: hasChildren -> dynamicLoading
4329 4322
 						$delimiter = $this->mail_bo->getHierarchyDelimiter();
4330 4323
 						$nameSpace = $this->mail_bo->_getNameSpaces();
4331 4324
 						$prefix = $this->mail_bo->getFolderPrefixFromNamespace($nameSpace, $folderName);
@@ -4350,7 +4343,7 @@  discard block
 block discarded – undo
4350 4343
 					$success = false;
4351 4344
 					try
4352 4345
 					{
4353
-						if(($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName)))
4346
+						if (($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName)))
4354 4347
 						{
4355 4348
 							$this->mail_bo->resetFolderObjectCache($profileID);
4356 4349
 							//enforce the subscription to the newly named server, as it seems to fail for names with umlauts
@@ -4362,11 +4355,11 @@  discard block
 block discarded – undo
4362 4355
 					}
4363 4356
 					catch (Exception $e)
4364 4357
 					{
4365
-						$newFolderName=$folderName;
4358
+						$newFolderName = $folderName;
4366 4359
 						$msg = $e->getMessage();
4367 4360
 					}
4368 4361
 					$this->mail_bo->reopen($parentFolder);
4369
-					$this->mail_bo->getFolderStatus($parentFolder,false,false,false);
4362
+					$this->mail_bo->getFolderStatus($parentFolder, false, false, false);
4370 4363
 					//error_log(__METHOD__.__LINE__.array2string($fS));
4371 4364
 					if ($hasChildren)
4372 4365
 					{
@@ -4387,9 +4380,9 @@  discard block
 block discarded – undo
4387 4380
 					}
4388 4381
 				}
4389 4382
 			}
4390
-			if ($folderName==$this->mail_bo->sessionData['mailbox'])
4383
+			if ($folderName == $this->mail_bo->sessionData['mailbox'])
4391 4384
 			{
4392
-				$this->mail_bo->sessionData['mailbox']=$newFolderName;
4385
+				$this->mail_bo->sessionData['mailbox'] = $newFolderName;
4393 4386
 				$this->mail_bo->saveSessionData();
4394 4387
 			}
4395 4388
 			//error_log(__METHOD__.__LINE__.array2string($oA));
@@ -4398,26 +4391,26 @@  discard block
 block discarded – undo
4398 4391
 			{
4399 4392
 				Api\Translation::add_app('mail');
4400 4393
 
4401
-				$oldFolderInfo = $this->mail_bo->getFolderStatus($oldParentFolder,false,false,false);
4402
-				$folderInfo = $this->mail_bo->getFolderStatus($parentFolder,false,false,false);
4394
+				$oldFolderInfo = $this->mail_bo->getFolderStatus($oldParentFolder, false, false, false);
4395
+				$folderInfo = $this->mail_bo->getFolderStatus($parentFolder, false, false, false);
4403 4396
 				$refreshData = array(
4404 4397
 					$profileID.self::$delimiter.$oldParentFolder=>$oldFolderInfo['shortDisplayName'],
4405 4398
 					$profileID.self::$delimiter.$parentFolder=>$folderInfo['shortDisplayName']);
4406 4399
 				// if we move the folder within the same parent-branch of the tree, there is no need no refresh the upper part
4407
-				if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]);
4408
-				if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]);
4400
+				if (strlen($parentFolder) > strlen($oldParentFolder) && strpos($parentFolder, $oldParentFolder) !== false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]);
4401
+				if (count($refreshData) > 1 && strlen($oldParentFolder) > strlen($parentFolder) && strpos($oldParentFolder, $parentFolder) !== false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]);
4409 4402
 
4410 4403
 				// Send full info back in the response
4411
-				foreach($refreshData as $folder => &$name)
4404
+				foreach ($refreshData as $folder => &$name)
4412 4405
 				{
4413
-					$name = $this->mail_tree->getTree($folder,$profileID,1,false,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'],true);
4406
+					$name = $this->mail_tree->getTree($folder, $profileID, 1, false, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'], true);
4414 4407
 				}
4415
-				$response->call('app.mail.mail_reloadNode',$refreshData);
4408
+				$response->call('app.mail.mail_reloadNode', $refreshData);
4416 4409
 
4417 4410
 			}
4418 4411
 			else
4419 4412
 			{
4420
-				$response->call('egw.refresh',lang('failed to move %1 ! Reason: %2',$folderName,$msg),'mail');
4413
+				$response->call('egw.refresh', lang('failed to move %1 ! Reason: %2', $folderName, $msg), 'mail');
4421 4414
 			}
4422 4415
 		}
4423 4416
 	}
@@ -4436,24 +4429,24 @@  discard block
 block discarded – undo
4436 4429
 		{
4437 4430
 			$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4438 4431
 			$oA = array();
4439
-			list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
4440
-			if (is_numeric($profileID) && $profileID != $this->mail_bo->profileID) $this->changeProfile ($profileID);
4432
+			list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
4433
+			if (is_numeric($profileID) && $profileID != $this->mail_bo->profileID) $this->changeProfile($profileID);
4441 4434
 			$del = $this->mail_bo->getHierarchyDelimiter(false);
4442 4435
 			$hasChildren = false;
4443 4436
 			if (is_numeric($profileID))
4444 4437
 			{
4445
-				$pA = explode($del,$folderName);
4438
+				$pA = explode($del, $folderName);
4446 4439
 				array_pop($pA);
4447
-				if (strtoupper($folderName)!= 'INBOX')
4440
+				if (strtoupper($folderName) != 'INBOX')
4448 4441
 				{
4449 4442
 					//error_log(__METHOD__.__LINE__."$folderName,  implode($del,$pA), $_newName");
4450 4443
 					$oA = array();
4451 4444
 					$subFolders = array();
4452
-					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false);
4445
+					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false, false, false);
4453 4446
 					//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
4454
-					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false)
4447
+					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false)
4455 4448
 					{
4456
-						$hasChildren=true; // translates to: hasChildren -> dynamicLoading
4449
+						$hasChildren = true; // translates to: hasChildren -> dynamicLoading
4457 4450
 						$ftD = array();
4458 4451
 						$delimiter = $this->mail_bo->getHierarchyDelimiter();
4459 4452
 						$nameSpace = $this->mail_bo->_getNameSpaces();
@@ -4463,24 +4456,24 @@  discard block
 block discarded – undo
4463 4456
 						//error_log(__METHOD__.__LINE__.'->'."$folderName, $delimiter, $prefix");
4464 4457
 						foreach ($subFolders as $k => $f)
4465 4458
 						{
4466
-							$ftD[substr_count($f,$delimiter)][]=$f;
4459
+							$ftD[substr_count($f, $delimiter)][] = $f;
4467 4460
 						}
4468
-						krsort($ftD,SORT_NUMERIC);//sort per level
4461
+						krsort($ftD, SORT_NUMERIC); //sort per level
4469 4462
 						//we iterate per level of depth of the subtree, deepest nesting is to be deleted first, and then up the tree
4470
-						foreach($ftD as $k => $lc)//collection per level
4463
+						foreach ($ftD as $k => $lc)//collection per level
4471 4464
 						{
4472
-							foreach($lc as $f)//folders contained in that level
4465
+							foreach ($lc as $f)//folders contained in that level
4473 4466
 							{
4474 4467
 								try
4475 4468
 								{
4476 4469
 									//error_log(__METHOD__.__LINE__.array2string($f).'<->'.$folderName);
4477 4470
 									$this->mail_bo->deleteFolder($f);
4478 4471
 									$success = true;
4479
-									if ($f==$folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName'];
4472
+									if ($f == $folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName'];
4480 4473
 								}
4481 4474
 								catch (Exception $e)
4482 4475
 								{
4483
-									$msg .= ($msg?' ':'').lang("Failed to delete %1. Server responded:",$f).$e->getMessage();
4476
+									$msg .= ($msg ? ' ' : '').lang("Failed to delete %1. Server responded:", $f).$e->getMessage();
4484 4477
 									$success = false;
4485 4478
 								}
4486 4479
 							}
@@ -4511,11 +4504,11 @@  discard block
 block discarded – undo
4511 4504
 			if ($success)
4512 4505
 			{
4513 4506
 				//error_log(__METHOD__.__LINE__.array2string($oA));
4514
-				$response->call('app.mail.mail_removeLeaf',$oA);
4507
+				$response->call('app.mail.mail_removeLeaf', $oA);
4515 4508
 			}
4516 4509
 			else
4517 4510
 			{
4518
-				$response->call('egw.refresh',lang('failed to delete %1 ! Reason: %2',$oldFolderInfo['shortDisplayName'],$msg),'mail');
4511
+				$response->call('egw.refresh', lang('failed to delete %1 ! Reason: %2', $oldFolderInfo['shortDisplayName'], $msg), 'mail');
4519 4512
 			}
4520 4513
 		}
4521 4514
 	}
@@ -4529,7 +4522,7 @@  discard block
 block discarded – undo
4529 4522
 	 * @param bool $getFolders The client needs the folders for the profile
4530 4523
 	 * @return nothing
4531 4524
 	 */
4532
-	public static function ajax_changeProfile($icServerID, $getFolders = true, $exec_id=null)
4525
+	public static function ajax_changeProfile($icServerID, $getFolders = true, $exec_id = null)
4533 4526
 	{
4534 4527
 		$response = Api\Json\Response::get();
4535 4528
 
@@ -4537,7 +4530,7 @@  discard block
 block discarded – undo
4537 4530
 
4538 4531
 		if ($icServerID && $icServerID != $previous_id)
4539 4532
 		{
4540
-			$mail_ui = new mail_ui(false);	// do NOT run constructor, as we call changeProfile anyway
4533
+			$mail_ui = new mail_ui(false); // do NOT run constructor, as we call changeProfile anyway
4541 4534
 			try
4542 4535
 			{
4543 4536
 				$mail_ui->changeProfile($icServerID);
@@ -4553,12 +4546,12 @@  discard block
 block discarded – undo
4553 4546
 				}
4554 4547
 			}
4555 4548
 			catch (Exception $e) {
4556
-				self::callWizard($e->getMessage(),true, 'error');
4549
+				self::callWizard($e->getMessage(), true, 'error');
4557 4550
 			}
4558 4551
 		}
4559 4552
 		else
4560 4553
 		{
4561
-			$mail_ui = new mail_ui(true);	// run constructor
4554
+			$mail_ui = new mail_ui(true); // run constructor
4562 4555
 		}
4563 4556
 	}
4564 4557
 
@@ -4569,7 +4562,7 @@  discard block
 block discarded – undo
4569 4562
 	 *						if other than active profile; nothing is done!
4570 4563
 	 * @return nothing
4571 4564
 	 */
4572
-	public static function ajax_refreshVacationNotice($icServerID=null)
4565
+	public static function ajax_refreshVacationNotice($icServerID = null)
4573 4566
 	{
4574 4567
 		//Get vacation from cache if it's available
4575 4568
 		$cachedVacations = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid']);
@@ -4587,28 +4580,28 @@  discard block
 block discarded – undo
4587 4580
 
4588 4581
 				$vacation = $mail->gatherVacation($cachedVacations);
4589 4582
 			} catch (Exception $e) {
4590
-				$vacation=false;
4583
+				$vacation = false;
4591 4584
 				error_log(__METHOD__.__LINE__." ".$e->getMessage());
4592 4585
 				unset($e);
4593 4586
 			}
4594 4587
 		}
4595 4588
 
4596
-		if($vacation) {
4597
-			if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date'))
4589
+		if ($vacation) {
4590
+			if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status'] == 'by_date'))
4598 4591
 			{
4599 4592
 				$dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
4600 4593
 				$refreshData['vacationnotice'] = lang('Vacation notice is active');
4601
-				$refreshData['vacationrange'] = ($vacation['status']=='by_date'? Api\DateTime::server2user($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.Api\DateTime::server2user($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):'');
4602
-				if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time())$refreshData = '';
4594
+				$refreshData['vacationrange'] = ($vacation['status'] == 'by_date' ? Api\DateTime::server2user($vacation['start_date'], $dtfrmt, true).($vacation['end_date'] > $vacation['start_date'] ? '->'.Api\DateTime::server2user($vacation['end_date'] + 24 * 3600 - 1, $dtfrmt, true) : '') : '');
4595
+				if ($vacation['status'] == 'by_date' && $vacation['end_date'] + 24 * 3600 < time())$refreshData = '';
4603 4596
 			}
4604 4597
 		}
4605
-		if ($vacation==false)
4598
+		if ($vacation == false)
4606 4599
 		{
4607
-			$refreshData['vacationnotice'] =  '';
4608
-			$refreshData['vacationrange'] =  '';
4600
+			$refreshData['vacationnotice'] = '';
4601
+			$refreshData['vacationrange'] = '';
4609 4602
 		}
4610 4603
 		$response = Api\Json\Response::get();
4611
-		$response->call('app.mail.mail_refreshVacationNotice',$refreshData);
4604
+		$response->call('app.mail.mail_refreshVacationNotice', $refreshData);
4612 4605
 	}
4613 4606
 
4614 4607
 	/**
@@ -4618,43 +4611,43 @@  discard block
 block discarded – undo
4618 4611
 	 *						if other than active profile; nothing is done!
4619 4612
 	 * @return nothing
4620 4613
 	 */
4621
-	function ajax_refreshFilters($icServerID=null)
4614
+	function ajax_refreshFilters($icServerID = null)
4622 4615
 	{
4623 4616
 		//error_log(__METHOD__.__LINE__.array2string($icServerId));
4624 4617
 		if (empty($icServerID)) $icServerID = $this->mail_bo->profileID;
4625 4618
 		if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4626 4619
 		{
4627
-			Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4628
-			if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
4620
+			Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
4621
+			if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true;
4629 4622
 		}
4630 4623
 		if (!Mail::$supportsORinQuery[$this->mail_bo->profileID])
4631 4624
 		{
4632 4625
 			unset($this->searchTypes['quick']);
4633 4626
 			unset($this->searchTypes['quickwithcc']);
4634 4627
 		}
4635
-		if ( $this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
4628
+		if ($this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS'))
4636 4629
 		{
4637
-			$this->statusTypes = array_merge($this->statusTypes,array(
4638
-				'keyword1'	=> 'important',//lang('important'),
4639
-				'keyword2'	=> 'job',	//lang('job'),
4640
-				'keyword3'	=> 'personal',//lang('personal'),
4641
-				'keyword4'	=> 'to do',	//lang('to do'),
4642
-				'keyword5'	=> 'later',	//lang('later'),
4630
+			$this->statusTypes = array_merge($this->statusTypes, array(
4631
+				'keyword1'	=> 'important', //lang('important'),
4632
+				'keyword2'	=> 'job', //lang('job'),
4633
+				'keyword3'	=> 'personal', //lang('personal'),
4634
+				'keyword4'	=> 'to do', //lang('to do'),
4635
+				'keyword5'	=> 'later', //lang('later'),
4643 4636
 			));
4644 4637
 		}
4645 4638
 		else
4646 4639
 		{
4647
-			$keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5');
4648
-			foreach($keywords as &$k)
4640
+			$keywords = array('keyword1', 'keyword2', 'keyword3', 'keyword4', 'keyword5');
4641
+			foreach ($keywords as &$k)
4649 4642
 			{
4650
-				if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]);
4643
+				if (array_key_exists($k, $this->statusTypes)) unset($this->statusTypes[$k]);
4651 4644
 			}
4652 4645
 		}
4653 4646
 
4654 4647
 		$response = Api\Json\Response::get();
4655
-		$response->call('app.mail.mail_refreshCatIdOptions',$this->searchTypes);
4656
-		$response->call('app.mail.mail_refreshFilterOptions',$this->statusTypes);
4657
-		$response->call('app.mail.mail_refreshFilter2Options',array(''=>lang('No Sneak Preview in list'),1=>lang('Sneak Preview in list')));
4648
+		$response->call('app.mail.mail_refreshCatIdOptions', $this->searchTypes);
4649
+		$response->call('app.mail.mail_refreshFilterOptions', $this->statusTypes);
4650
+		$response->call('app.mail.mail_refreshFilter2Options', array(''=>lang('No Sneak Preview in list'), 1=>lang('Sneak Preview in list')));
4658 4651
 
4659 4652
 	}
4660 4653
 
@@ -4666,7 +4659,7 @@  discard block
 block discarded – undo
4666 4659
 	 * @param string $icServerID = null
4667 4660
 	 *
4668 4661
 	 */
4669
-	function ajax_refreshQuotaDisplay($icServerID=null)
4662
+	function ajax_refreshQuotaDisplay($icServerID = null)
4670 4663
 	{
4671 4664
 		Api\Translation::add_app('mail');
4672 4665
 		if (is_null($icServerID)) $icServerID = $this->mail_bo->profileID;
@@ -4684,23 +4677,23 @@  discard block
 block discarded – undo
4684 4677
 			unset($e);
4685 4678
 		}
4686 4679
 
4687
-		if($quota !== false && $quota['limit'] != 'NOT SET') {
4680
+		if ($quota !== false && $quota['limit'] != 'NOT SET') {
4688 4681
 			$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
4689
-			$quotaMin = ceil($quotainfo['freespace']/pow(1024, 2));
4682
+			$quotaMin = ceil($quotainfo['freespace'] / pow(1024, 2));
4690 4683
 			$quota_limit_warning = isset(mail::$mailConfig['quota_limit_warning']) ? mail::$mailConfig['quota_limit_warning'] : 30;
4691
-			$content = array (
4684
+			$content = array(
4692 4685
 				'quota'				=> $quotainfo['text'],
4693 4686
 				'quotainpercent'	=> (string)$quotainfo['percent'],
4694 4687
 				'quotaclass'		=> $quotainfo['class'],
4695 4688
 				'quotanotsupported'	=> "",
4696 4689
 				'profileid'			=> $icServerID,
4697
-				'quotawarning'		=> $quotaMin <  $quota_limit_warning ? true : false,
4690
+				'quotawarning'		=> $quotaMin < $quota_limit_warning ? true : false,
4698 4691
 				'quotafreespace'	=> Mail::show_readable_size($quotainfo['freespace'])
4699 4692
 			);
4700 4693
 		}
4701 4694
 		else
4702 4695
 		{
4703
-			$content = array (
4696
+			$content = array(
4704 4697
 				'quota'				=> lang("Quota not provided by server"),
4705 4698
 				'quotaclass'		=> "mail_DisplayNone",
4706 4699
 				'quotanotsupported'	=> "mail_DisplayNone"
@@ -4716,7 +4709,7 @@  discard block
 block discarded – undo
4716 4709
 			}
4717 4710
 		}
4718 4711
 		$response = Api\Json\Response::get();
4719
-		$response->call('app.mail.mail_setQuotaDisplay',array('data'=>$content));
4712
+		$response->call('app.mail.mail_setQuotaDisplay', array('data'=>$content));
4720 4713
 	}
4721 4714
 
4722 4715
 	/**
@@ -4738,34 +4731,34 @@  discard block
 block discarded – undo
4738 4731
 			$this->changeProfile($icServerID);
4739 4732
 		}
4740 4733
 		$junkFolder = $this->mail_bo->getJunkFolder();
4741
-		if(!empty($junkFolder)) {
4734
+		if (!empty($junkFolder)) {
4742 4735
 			if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder)
4743 4736
 			{
4744 4737
 				// Lock the tree if the active folder is junk folder
4745 4738
 				$response->call('app.mail.lock_tree');
4746 4739
 			}
4747
-			$this->mail_bo->deleteMessages('all',$junkFolder,'remove_immediately');
4740
+			$this->mail_bo->deleteMessages('all', $junkFolder, 'remove_immediately');
4748 4741
 
4749 4742
 			$heirarchyDelimeter = $this->mail_bo->getHierarchyDelimiter(true);
4750
-			$fShortName =  array_pop(explode($heirarchyDelimeter, $junkFolder));
4743
+			$fShortName = array_pop(explode($heirarchyDelimeter, $junkFolder));
4751 4744
 			$fStatus = array(
4752 4745
 				$icServerID.self::$delimiter.$junkFolder => lang($fShortName)
4753 4746
 			);
4754 4747
 			//Call to reset folder status counter, after junkFolder triggered not from Junk folder
4755 4748
 			//-as we don't have junk folder specific information available on client-side we need to deal with it on server
4756
-			$response->call('app.mail.mail_setFolderStatus',$fStatus);
4749
+			$response->call('app.mail.mail_setFolderStatus', $fStatus);
4757 4750
 		}
4758 4751
 		if ($rememberServerID != $this->mail_bo->profileID)
4759 4752
 		{
4760
-			$oldFolderInfo = $this->mail_bo->getFolderStatus($junkFolder,false,false,false);
4761
-			$response->call('egw.message',lang('empty junk'));
4762
-			$response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$junkFolder=>$oldFolderInfo['shortDisplayName']));
4753
+			$oldFolderInfo = $this->mail_bo->getFolderStatus($junkFolder, false, false, false);
4754
+			$response->call('egw.message', lang('empty junk'));
4755
+			$response->call('app.mail.mail_reloadNode', array($icServerID.self::$delimiter.$junkFolder=>$oldFolderInfo['shortDisplayName']));
4763 4756
 			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID);
4764 4757
 			$this->changeProfile($rememberServerID);
4765 4758
 		}
4766 4759
 		else if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder)
4767 4760
 		{
4768
-			$response->call('egw.refresh',lang('empty junk'),'mail');
4761
+			$response->call('egw.refresh', lang('empty junk'), 'mail');
4769 4762
 		}
4770 4763
 	}
4771 4764
 
@@ -4788,7 +4781,7 @@  discard block
 block discarded – undo
4788 4781
 			$this->changeProfile($icServerID);
4789 4782
 		}
4790 4783
 		$trashFolder = $this->mail_bo->getTrashFolder();
4791
-		if(!empty($trashFolder)) {
4784
+		if (!empty($trashFolder)) {
4792 4785
 			if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder)
4793 4786
 			{
4794 4787
 				// Lock the tree if the active folder is Trash folder
@@ -4797,25 +4790,25 @@  discard block
 block discarded – undo
4797 4790
 			$this->mail_bo->compressFolder($trashFolder);
4798 4791
 
4799 4792
 			$heirarchyDelimeter = $this->mail_bo->getHierarchyDelimiter(true);
4800
-			$fShortName =  array_pop(explode($heirarchyDelimeter, $trashFolder));
4793
+			$fShortName = array_pop(explode($heirarchyDelimeter, $trashFolder));
4801 4794
 			$fStatus = array(
4802 4795
 				$icServerID.self::$delimiter.$trashFolder => lang($fShortName)
4803 4796
 			);
4804 4797
 			//Call to reset folder status counter, after emptyTrash triggered not from Trash folder
4805 4798
 			//-as we don't have trash folder specific information available on client-side we need to deal with it on server
4806
-			$response->call('app.mail.mail_setFolderStatus',$fStatus);
4799
+			$response->call('app.mail.mail_setFolderStatus', $fStatus);
4807 4800
 		}
4808 4801
 		if ($rememberServerID != $this->mail_bo->profileID)
4809 4802
 		{
4810
-			$oldFolderInfo = $this->mail_bo->getFolderStatus($trashFolder,false,false,false);
4811
-			$response->call('egw.message',lang('empty trash'));
4812
-			$response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$trashFolder=>$oldFolderInfo['shortDisplayName']));
4803
+			$oldFolderInfo = $this->mail_bo->getFolderStatus($trashFolder, false, false, false);
4804
+			$response->call('egw.message', lang('empty trash'));
4805
+			$response->call('app.mail.mail_reloadNode', array($icServerID.self::$delimiter.$trashFolder=>$oldFolderInfo['shortDisplayName']));
4813 4806
 			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID);
4814 4807
 			$this->changeProfile($rememberServerID);
4815 4808
 		}
4816 4809
 		else if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder)
4817 4810
 		{
4818
-			$response->call('egw.refresh',lang('empty trash'),'mail');
4811
+			$response->call('egw.refresh', lang('empty trash'), 'mail');
4819 4812
 		}
4820 4813
 	}
4821 4814
 
@@ -4832,7 +4825,7 @@  discard block
 block discarded – undo
4832 4825
 
4833 4826
 		$this->mail_bo->restoreSessionData();
4834 4827
 		$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4835
-		list($icServerID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
4828
+		list($icServerID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2);
4836 4829
 
4837 4830
 		if (empty($folderName)) $folderName = $this->mail_bo->sessionData['mailbox'];
4838 4831
 		if ($this->mail_bo->folderExists($folderName))
@@ -4843,7 +4836,7 @@  discard block
 block discarded – undo
4843 4836
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
4844 4837
 				$this->changeProfile($icServerID);
4845 4838
 			}
4846
-			if(!empty($_folderName)) {
4839
+			if (!empty($_folderName)) {
4847 4840
 				$this->mail_bo->compressFolder($folderName);
4848 4841
 			}
4849 4842
 			if ($rememberServerID != $this->mail_bo->profileID)
@@ -4852,7 +4845,7 @@  discard block
 block discarded – undo
4852 4845
 				$this->changeProfile($rememberServerID);
4853 4846
 			}
4854 4847
 			$response = Api\Json\Response::get();
4855
-			$response->call('egw.refresh',lang('compress folder').': '.$folderName,'mail');
4848
+			$response->call('egw.refresh', lang('compress folder').': '.$folderName, 'mail');
4856 4849
 		}
4857 4850
 	}
4858 4851
 
@@ -4865,10 +4858,10 @@  discard block
 block discarded – undo
4865 4858
 	 */
4866 4859
 	function ajax_sendMDN($_messageList)
4867 4860
 	{
4868
-		if(Mail::$debug) error_log(__METHOD__."->".array2string($_messageList));
4861
+		if (Mail::$debug) error_log(__METHOD__."->".array2string($_messageList));
4869 4862
 		$uidA = self::splitRowID($_messageList['msg'][0]);
4870 4863
 		$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
4871
-		$this->mail_bo->sendMDN($uidA['msgUID'],$folder);
4864
+		$this->mail_bo->sendMDN($uidA['msgUID'], $folder);
4872 4865
 	}
4873 4866
 
4874 4867
 	/**
@@ -4880,14 +4873,14 @@  discard block
 block discarded – undo
4880 4873
 	 *
4881 4874
 	 * @return xajax response
4882 4875
 	 */
4883
-	function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse=true)
4876
+	function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse = true)
4884 4877
 	{
4885
-		if(Mail::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList));
4878
+		if (Mail::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList));
4886 4879
 		Api\Translation::add_app('mail');
4887
-		$alreadyFlagged=false;
4888
-		$flag2check='';
4880
+		$alreadyFlagged = false;
4881
+		$flag2check = '';
4889 4882
 		$filter2toggle = $query = array();
4890
-		if ($_messageList=='all' || !empty($_messageList['msg']))
4883
+		if ($_messageList == 'all' || !empty($_messageList['msg']))
4891 4884
 		{
4892 4885
 			if (isset($_messageList['all']) && $_messageList['all'])
4893 4886
 			{
@@ -4897,34 +4890,34 @@  discard block
 block discarded – undo
4897 4890
 				if (isset($_messageList['activeFilters']) && $_messageList['activeFilters'])
4898 4891
 				{
4899 4892
 					$query = $_messageList['activeFilters'];
4900
-					if (!empty($query['search']) || !empty($query['filter'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate']))))
4893
+					if (!empty($query['search']) || !empty($query['filter']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate']))))
4901 4894
 					{
4902 4895
 						//([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any
4903 4896
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4904 4897
 						{
4905
-							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4906
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
4898
+							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
4899
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true;
4907 4900
 						}
4908 4901
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']);
4909 4902
 						$cutoffdate = $cutoffdate2 = null;
4910
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
4911
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
4903
+						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate
4904
+						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate
4912 4905
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
4913 4906
 						$filter = array(
4914
-							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
4915
-							'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')),
4907
+							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ?lang('quicksearch') : lang('subject')),
4908
+							'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')),
4916 4909
 							'string' => $query['search'],
4917
-							'status' => 'any',//this is a status change. status will be manipulated later on
4910
+							'status' => 'any', //this is a status change. status will be manipulated later on
4918 4911
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
4919 4912
 						);
4920
-						if ($query['enddate']||$query['startdate']) {
4913
+						if ($query['enddate'] || $query['startdate']) {
4921 4914
 							$filter['range'] = "BETWEEN";
4922 4915
 							if ($cutoffdate) {
4923
-								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
4916
+								$filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate);
4924 4917
 								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
4925 4918
 							}
4926 4919
 							if ($cutoffdate2) {
4927
-								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
4920
+								$filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2);
4928 4921
 								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
4929 4922
 							}
4930 4923
 						}
@@ -4937,12 +4930,12 @@  discard block
 block discarded – undo
4937 4930
 					// flags read,flagged,label1,label2,label3,label4,label5 can be toggled: handle this when all mails in a folder
4938 4931
 					// should be affected serverside. here.
4939 4932
 					$messageList = $messageListForToggle = array();
4940
-					$flag2check = ($_flag=='read'?'seen':$_flag);
4941
-					if (in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) &&
4942
-						!($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false))
4933
+					$flag2check = ($_flag == 'read' ? 'seen' : $_flag);
4934
+					if (in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) &&
4935
+						!($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false))
4943 4936
 					{
4944 4937
 						$filter2toggle['status'] = array('un'.$_flag);
4945
-						if ($query['filter'] && $query['filter']!='any')
4938
+						if ($query['filter'] && $query['filter'] != 'any')
4946 4939
 						{
4947 4940
 							$filter2toggle['status'][] = $query['filter'];
4948 4941
 						}
@@ -4956,7 +4949,7 @@  discard block
 block discarded – undo
4956 4949
 						);
4957 4950
 						$messageListForToggle = $_sRt['match']->ids;
4958 4951
 						$filter['status'] = array($_flag);
4959
-						if ($query['filter'] && $query['filter'] !='any')
4952
+						if ($query['filter'] && $query['filter'] != 'any')
4960 4953
 						{
4961 4954
 							$filter['status'][] = $query['filter'];
4962 4955
 						}
@@ -4969,37 +4962,37 @@  discard block
 block discarded – undo
4969 4962
 							false
4970 4963
 						);
4971 4964
 						$messageList = $_sR['match']->ids;
4972
-						if (count($messageListForToggle)>0)
4965
+						if (count($messageListForToggle) > 0)
4973 4966
 						{
4974 4967
 							$flag2set = (strtolower($_flag));
4975
-							if(Mail::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle));
4976
-							$this->mail_bo->flagMessages($flag2set, $messageListForToggle,$folder);
4968
+							if (Mail::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle));
4969
+							$this->mail_bo->flagMessages($flag2set, $messageListForToggle, $folder);
4977 4970
 						}
4978
-						if (count($messageList)>0)
4971
+						if (count($messageList) > 0)
4979 4972
 						{
4980 4973
 							$flag2set = 'un'.$_flag;
4981
-							if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList));
4982
-							$this->mail_bo->flagMessages($flag2set, $messageList,$folder);
4974
+							if (Mail::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList));
4975
+							$this->mail_bo->flagMessages($flag2set, $messageList, $folder);
4983 4976
 						}
4984
-						$alreadyFlagged=true;
4977
+						$alreadyFlagged = true;
4985 4978
 					}
4986 4979
 					elseif (!empty($filter) &&
4987
-						(!in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) ||
4988
-						(in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) &&
4989
-						($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false))))
4980
+						(!in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) ||
4981
+						(in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) &&
4982
+						($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false))))
4990 4983
 					{
4991
-						if ($query['filter'] && $query['filter'] !='any')
4984
+						if ($query['filter'] && $query['filter'] != 'any')
4992 4985
 						{
4993 4986
 							$filter['status'] = $query['filter'];
4994 4987
 							// since we toggle and we toggle by the filtered flag we must must change _flag
4995
-							$_flag = ($query['filter']=='unseen' && $_flag=='read' ? 'read' : ($query['filter']=='seen'&& $_flag=='read'?'unread':($_flag==$query['filter']?'un'.$_flag:$_flag)));
4988
+							$_flag = ($query['filter'] == 'unseen' && $_flag == 'read' ? 'read' : ($query['filter'] == 'seen' && $_flag == 'read' ? 'unread' : ($_flag == $query['filter'] ? 'un'.$_flag : $_flag)));
4996 4989
 						}
4997
-						if(Mail::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter));
4990
+						if (Mail::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter));
4998 4991
 						$rByUid = true;
4999 4992
 						$reverse = 1;
5000 4993
 						$_sR = $this->mail_bo->getSortedList(
5001 4994
 							$folder,
5002
-							$sort=0,
4995
+							$sort = 0,
5003 4996
 							$reverse,
5004 4997
 							$filter,
5005 4998
 							$rByUid,
@@ -5011,8 +5004,8 @@  discard block
 block discarded – undo
5011 5004
 					}
5012 5005
 					else
5013 5006
 					{
5014
-						if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter));
5015
-						$alreadyFlagged=true;
5007
+						if (Mail::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter));
5008
+						$alreadyFlagged = true;
5016 5009
 						$uidA = self::splitRowID($_messageList['msg'][0]);
5017 5010
 						$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
5018 5011
 						$this->mail_bo->flagMessages($_flag, 'all', $folder);
@@ -5026,41 +5019,41 @@  discard block
 block discarded – undo
5026 5019
 			}
5027 5020
 			if (!$alreadyFlagged)
5028 5021
 			{
5029
-				foreach($_messageList['msg'] as $rowID)
5022
+				foreach ($_messageList['msg'] as $rowID)
5030 5023
 				{
5031 5024
 					$hA = self::splitRowID($rowID);
5032 5025
 					$messageList[] = $hA['msgUID'];
5033 5026
 				}
5034
-				if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList)));
5035
-				$this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList),$folder);
5027
+				if (Mail::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all' : $messageList)));
5028
+				$this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all' : $messageList), $folder);
5036 5029
 			}
5037 5030
 		}
5038 5031
 		else
5039 5032
 		{
5040
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5033
+			if (Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5041 5034
 		}
5042 5035
 
5043 5036
 		if ($_sendJsonResponse)
5044 5037
 		{
5045
-			$flag=array(
5046
-				'label1'	=> 'important',//lang('important'),
5047
-				'label2'	=> 'job',	//lang('job'),
5048
-				'label3'	=> 'personal',//lang('personal'),
5049
-				'label4'	=> 'to do',	//lang('to do'),
5050
-				'label5'	=> 'later',	//lang('later'),
5038
+			$flag = array(
5039
+				'label1'	=> 'important', //lang('important'),
5040
+				'label2'	=> 'job', //lang('job'),
5041
+				'label3'	=> 'personal', //lang('personal'),
5042
+				'label4'	=> 'to do', //lang('to do'),
5043
+				'label5'	=> 'later', //lang('later'),
5051 5044
 			);
5052 5045
 			$response = Api\Json\Response::get();
5053 5046
 			if (isset($_messageList['msg']) && $_messageList['popup'])
5054 5047
 			{
5055
-				$response->call('egw.refresh',lang('flagged %1 messages as %2 in %3',$_messageList['msg'],lang(($flag[$_flag]?$flag[$_flag]:$_flag)),$folder),'mail', $_messageList['msg'], 'update');
5048
+				$response->call('egw.refresh', lang('flagged %1 messages as %2 in %3', $_messageList['msg'], lang(($flag[$_flag] ? $flag[$_flag] : $_flag)), $folder), 'mail', $_messageList['msg'], 'update');
5056 5049
 			}
5057
-			else if ((isset($_messageList['all']) && $_messageList['all']) || ($query['filter'] && ($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false)))
5050
+			else if ((isset($_messageList['all']) && $_messageList['all']) || ($query['filter'] && ($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false)))
5058 5051
 			{
5059
-				$response->call('egw.refresh',lang('flagged %1 messages as %2 in %3',(isset($_messageList['all']) && $_messageList['all']?lang('all'):count($_messageList['msg'])),lang(($flag[$_flag]?$flag[$_flag]:$_flag)),$folder),'mail');
5052
+				$response->call('egw.refresh', lang('flagged %1 messages as %2 in %3', (isset($_messageList['all']) && $_messageList['all'] ?lang('all') : count($_messageList['msg'])), lang(($flag[$_flag] ? $flag[$_flag] : $_flag)), $folder), 'mail');
5060 5053
 			}
5061 5054
 			else
5062 5055
 			{
5063
-				$response->call('egw.message',lang('flagged %1 messages as %2 in %3',(isset($_messageList['all']) && $_messageList['all']?lang('all'):count($_messageList['msg'])),lang(($flag[$_flag]?$flag[$_flag]:$_flag)),$folder));
5056
+				$response->call('egw.message', lang('flagged %1 messages as %2 in %3', (isset($_messageList['all']) && $_messageList['all'] ?lang('all') : count($_messageList['msg'])), lang(($flag[$_flag] ? $flag[$_flag] : $_flag)), $folder));
5064 5057
 			}
5065 5058
 		}
5066 5059
 	}
@@ -5072,12 +5065,12 @@  discard block
 block discarded – undo
5072 5065
 	 * @param string _forceDeleteMethod - method of deletion to be enforced
5073 5066
 	 * @return xajax response
5074 5067
 	 */
5075
-	function ajax_deleteMessages($_messageList,$_forceDeleteMethod=null)
5068
+	function ajax_deleteMessages($_messageList, $_forceDeleteMethod = null)
5076 5069
 	{
5077
-		if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod);
5070
+		if (Mail::$debug) error_log(__METHOD__."->".print_r($_messageList, true).' Method:'.$_forceDeleteMethod);
5078 5071
 		$error = null;
5079
-		$filtered =  false;
5080
-		if ($_messageList=='all' || !empty($_messageList['msg']))
5072
+		$filtered = false;
5073
+		if ($_messageList == 'all' || !empty($_messageList['msg']))
5081 5074
 		{
5082 5075
 			if (isset($_messageList['all']) && $_messageList['all'])
5083 5076
 			{
@@ -5087,34 +5080,34 @@  discard block
 block discarded – undo
5087 5080
 				if (isset($_messageList['activeFilters']) && $_messageList['activeFilters'])
5088 5081
 				{
5089 5082
 					$query = $_messageList['activeFilters'];
5090
-					if (!empty($query['search']) || !empty($query['filter'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate']))))
5083
+					if (!empty($query['search']) || !empty($query['filter']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate']))))
5091 5084
 					{
5092 5085
 						//([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any
5093 5086
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
5094 5087
 						{
5095
-							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
5096
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5088
+							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
5089
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true;
5097 5090
 						}
5098
-						$filtered =  true;
5091
+						$filtered = true;
5099 5092
 						$cutoffdate = $cutoffdate2 = null;
5100
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
5101
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
5093
+						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate
5094
+						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate
5102 5095
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
5103 5096
 						$filter = array(
5104
-							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
5105
-							'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')),
5097
+							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ?lang('quicksearch') : lang('subject')),
5098
+							'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')),
5106 5099
 							'string' => $query['search'],
5107
-							'status' => (!empty($query['filter'])?$query['filter']:'any'),
5100
+							'status' => (!empty($query['filter']) ? $query['filter'] : 'any'),
5108 5101
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
5109 5102
 						);
5110
-						if ($query['enddate']||$query['startdate']) {
5103
+						if ($query['enddate'] || $query['startdate']) {
5111 5104
 							$filter['range'] = "BETWEEN";
5112 5105
 							if ($cutoffdate) {
5113
-								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
5106
+								$filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate);
5114 5107
 								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
5115 5108
 							}
5116 5109
 							if ($cutoffdate2) {
5117
-								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
5110
+								$filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2);
5118 5111
 								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
5119 5112
 							}
5120 5113
 						}
@@ -5128,7 +5121,7 @@  discard block
 block discarded – undo
5128 5121
 					$rByUid = true;
5129 5122
 					$_sR = $this->mail_bo->getSortedList(
5130 5123
 						$folder,
5131
-						$sort=0,
5124
+						$sort = 0,
5132 5125
 						$reverse,
5133 5126
 						$filter,
5134 5127
 						$rByUid,
@@ -5138,23 +5131,23 @@  discard block
 block discarded – undo
5138 5131
 				}
5139 5132
 				else
5140 5133
 				{
5141
-					$messageList='all';
5134
+					$messageList = 'all';
5142 5135
 				}
5143 5136
 				try
5144 5137
 				{
5145 5138
 					//error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod);
5146
-					$this->mail_bo->deleteMessages(($messageList=='all' ? 'all':$messageList),$folder,(empty($_forceDeleteMethod)?'no':$_forceDeleteMethod));
5139
+					$this->mail_bo->deleteMessages(($messageList == 'all' ? 'all' : $messageList), $folder, (empty($_forceDeleteMethod) ? 'no' : $_forceDeleteMethod));
5147 5140
 				}
5148 5141
 				catch (Api\Exception $e)
5149 5142
 				{
5150
-					$error = str_replace('"',"'",$e->getMessage());
5143
+					$error = str_replace('"', "'", $e->getMessage());
5151 5144
 				}
5152 5145
 			}
5153 5146
 			else
5154 5147
 			{
5155 5148
 				$uidA = self::splitRowID($_messageList['msg'][0]);
5156 5149
 				$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
5157
-				foreach($_messageList['msg'] as $rowID)
5150
+				foreach ($_messageList['msg'] as $rowID)
5158 5151
 				{
5159 5152
 					$hA = self::splitRowID($rowID);
5160 5153
 					$messageList[] = $hA['msgUID'];
@@ -5162,27 +5155,27 @@  discard block
 block discarded – undo
5162 5155
 				try
5163 5156
 				{
5164 5157
 					//error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod);
5165
-					$this->mail_bo->deleteMessages($messageList,$folder,(empty($_forceDeleteMethod)?'no':$_forceDeleteMethod));
5158
+					$this->mail_bo->deleteMessages($messageList, $folder, (empty($_forceDeleteMethod) ? 'no' : $_forceDeleteMethod));
5166 5159
 				}
5167 5160
 				catch (Api\Exception $e)
5168 5161
 				{
5169
-					$error = str_replace('"',"'",$e->getMessage());
5162
+					$error = str_replace('"', "'", $e->getMessage());
5170 5163
 				}
5171 5164
 			}
5172 5165
 			$response = Api\Json\Response::get();
5173 5166
 			if (empty($error))
5174 5167
 			{
5175
-				$response->call('app.mail.mail_deleteMessagesShowResult',array('egw_message'=>lang('deleted %1 messages in %2',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($_messageList['msg'])),$folder),'msg'=>$_messageList['msg']));
5168
+				$response->call('app.mail.mail_deleteMessagesShowResult', array('egw_message'=>lang('deleted %1 messages in %2', ($messageList == 'all' || $_messageList['all'] ? ($filtered ?lang('all filtered') : lang('all')) : count($_messageList['msg'])), $folder), 'msg'=>$_messageList['msg']));
5176 5169
 			}
5177 5170
 			else
5178 5171
 			{
5179
-				$error = str_replace('\n',"\n",lang('mailserver reported:\n%1 \ndo you want to proceed by deleting the selected messages immediately (click ok)?\nif not, please try to empty your trashfolder before continuing. (click cancel)',$error));
5180
-				$response->call('app.mail.mail_retryForcedDelete',array('response'=>$error,'messageList'=>$_messageList));
5172
+				$error = str_replace('\n', "\n", lang('mailserver reported:\n%1 \ndo you want to proceed by deleting the selected messages immediately (click ok)?\nif not, please try to empty your trashfolder before continuing. (click cancel)', $error));
5173
+				$response->call('app.mail.mail_retryForcedDelete', array('response'=>$error, 'messageList'=>$_messageList));
5181 5174
 			}
5182 5175
 		}
5183 5176
 		else
5184 5177
 		{
5185
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5178
+			if (Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5186 5179
 		}
5187 5180
 	}
5188 5181
 
@@ -5198,48 +5191,48 @@  discard block
 block discarded – undo
5198 5191
 	 *
5199 5192
 	 * @return xajax response
5200 5193
 	 */
5201
-	function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove='copy', $_move2ArchiveMarker='_', $_return = false)
5194
+	function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove = 'copy', $_move2ArchiveMarker = '_', $_return = false)
5202 5195
 	{
5203
-		if(Mail::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker);
5196
+		if (Mail::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList, true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker);
5204 5197
 		Api\Translation::add_app('mail');
5205 5198
 		$folderName = $this->mail_bo->decodeEntityFolderName($_folderName);
5206 5199
 		// only copy or move are supported as method
5207
-		if (!($_copyOrMove=='copy' || $_copyOrMove=='move')) $_copyOrMove='copy';
5208
-		list($targetProfileID,$targetFolder) = explode(self::$delimiter,$folderName,2);
5200
+		if (!($_copyOrMove == 'copy' || $_copyOrMove == 'move')) $_copyOrMove = 'copy';
5201
+		list($targetProfileID, $targetFolder) = explode(self::$delimiter, $folderName, 2);
5209 5202
 		// check if move2archive was called with the correct archiveFolder
5210 5203
 		$archiveFolder = $this->mail_bo->getArchiveFolder();
5211
-		if ($_move2ArchiveMarker=='2' && $targetFolder != $archiveFolder)
5204
+		if ($_move2ArchiveMarker == '2' && $targetFolder != $archiveFolder)
5212 5205
 		{
5213 5206
 			error_log(__METHOD__.__LINE__."#Move to Archive called with:"."$targetProfileID,$targetFolder");
5214 5207
 			$targetProfileID = $this->mail_bo->profileID;
5215 5208
 			$targetFolder = $archiveFolder;
5216 5209
 			error_log(__METHOD__.__LINE__."#Fixed ArchiveFolder:"."$targetProfileID,$targetFolder");
5217 5210
 		}
5218
-		$lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1);
5211
+		$lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 1);
5219 5212
 		$changeFolderActions = false;
5220 5213
 		//error_log(__METHOD__.__LINE__."#"."$targetProfileID,$targetFolder");
5221 5214
 		//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont));
5222 5215
 		if (!isset($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]))
5223 5216
 		{
5224 5217
 			//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]));
5225
-			if ($lastFoldersUsedForMoveCont[$targetProfileID] && count($lastFoldersUsedForMoveCont[$targetProfileID])>3)
5218
+			if ($lastFoldersUsedForMoveCont[$targetProfileID] && count($lastFoldersUsedForMoveCont[$targetProfileID]) > 3)
5226 5219
 			{
5227 5220
 				$keys = array_keys($lastFoldersUsedForMoveCont[$targetProfileID]);
5228
-				foreach( $keys as &$f)
5221
+				foreach ($keys as &$f)
5229 5222
 				{
5230
-					if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]);
5223
+					if (count($lastFoldersUsedForMoveCont[$targetProfileID]) > 9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]);
5231 5224
 					else break;
5232 5225
 				}
5233 5226
 				//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID]));
5234 5227
 			}
5235 5228
 			//error_log(__METHOD__.__LINE__."#"."$targetProfileID,$targetFolder = $_folderName");
5236
-			$lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]=$folderName;
5229
+			$lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder] = $folderName;
5237 5230
 			$changeFolderActions = true;
5238 5231
 		}
5239 5232
 		$filtered = false;
5240
-		if ($_messageList=='all' || !empty($_messageList['msg']))
5233
+		if ($_messageList == 'all' || !empty($_messageList['msg']))
5241 5234
 		{
5242
-			$error=false;
5235
+			$error = false;
5243 5236
 			if (isset($_messageList['all']) && $_messageList['all'])
5244 5237
 			{
5245 5238
 				// we have both messageIds AND allFlag folder information
@@ -5249,34 +5242,34 @@  discard block
 block discarded – undo
5249 5242
 				if (isset($_messageList['activeFilters']) && $_messageList['activeFilters'])
5250 5243
 				{
5251 5244
 					$query = $_messageList['activeFilters'];
5252
-					if (!empty($query['search']) || !empty($query['filter'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate']))))
5245
+					if (!empty($query['search']) || !empty($query['filter']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate']))))
5253 5246
 					{
5254 5247
 						//([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any
5255 5248
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
5256 5249
 						{
5257
-							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
5258
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5250
+							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10);
5251
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true;
5259 5252
 						}
5260 5253
 						$filtered = true;
5261 5254
 						$cutoffdate = $cutoffdate2 = null;
5262
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
5263
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
5255
+						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate
5256
+						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate
5264 5257
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
5265 5258
 						$filter = array(
5266
-							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
5267
-							'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')),
5259
+							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ?lang('quicksearch') : lang('subject')),
5260
+							'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')),
5268 5261
 							'string' => $query['search'],
5269
-							'status' => (!empty($query['filter'])?$query['filter']:'any'),
5262
+							'status' => (!empty($query['filter']) ? $query['filter'] : 'any'),
5270 5263
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
5271 5264
 						);
5272
-						if ($query['enddate']||$query['startdate']) {
5265
+						if ($query['enddate'] || $query['startdate']) {
5273 5266
 							$filter['range'] = "BETWEEN";
5274 5267
 							if ($cutoffdate) {
5275
-								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
5268
+								$filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate);
5276 5269
 								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
5277 5270
 							}
5278 5271
 							if ($cutoffdate2) {
5279
-								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
5272
+								$filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2);
5280 5273
 								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
5281 5274
 							}
5282 5275
 						}
@@ -5289,70 +5282,70 @@  discard block
 block discarded – undo
5289 5282
 					$rByUid = true;
5290 5283
 					$_sR = $this->mail_bo->getSortedList(
5291 5284
 						$folder,
5292
-						$sort=0,
5285
+						$sort = 0,
5293 5286
 						$reverse,
5294 5287
 						$filter,
5295
-						$rByUid=true,
5288
+						$rByUid = true,
5296 5289
 						false
5297 5290
 					);
5298 5291
 					$messageList = $_sR['match']->ids;
5299
-					foreach($messageList as $uID)
5292
+					foreach ($messageList as $uID)
5300 5293
 					{
5301 5294
 						//error_log(__METHOD__.__LINE__.$uID);
5302
-						if ($_copyOrMove=='move')
5295
+						if ($_copyOrMove == 'move')
5303 5296
 						{
5304
-							$messageListForRefresh[] = self::generateRowID($sourceProfileID, $folderName, $uID, $_prependApp=false);
5297
+							$messageListForRefresh[] = self::generateRowID($sourceProfileID, $folderName, $uID, $_prependApp = false);
5305 5298
 						}
5306 5299
 					}
5307 5300
 				}
5308 5301
 				else
5309 5302
 				{
5310
-					$messageList='all';
5303
+					$messageList = 'all';
5311 5304
 				}
5312 5305
 				try
5313 5306
 				{
5314 5307
 					//error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod.' '.$targetProfileID.'/'.$sourceProfileID);
5315
-					$this->mail_bo->moveMessages($targetFolder,$messageList,($_copyOrMove=='copy'?false:true),$folder,false,$sourceProfileID,($targetProfileID!=$sourceProfileID?$targetProfileID:null));
5308
+					$this->mail_bo->moveMessages($targetFolder, $messageList, ($_copyOrMove == 'copy' ?false:true), $folder, false, $sourceProfileID, ($targetProfileID != $sourceProfileID ? $targetProfileID : null));
5316 5309
 				}
5317 5310
 				catch (Api\Exception $e)
5318 5311
 				{
5319
-					$error = str_replace('"',"'",$e->getMessage());
5312
+					$error = str_replace('"', "'", $e->getMessage());
5320 5313
 				}
5321 5314
 			}
5322 5315
 			else
5323 5316
 			{
5324 5317
 				$messageList = array();
5325
-				while(count($_messageList['msg']) > 0)
5318
+				while (count($_messageList['msg']) > 0)
5326 5319
 				{
5327 5320
 					$uidA = self::splitRowID($_messageList['msg'][0]);
5328 5321
 					$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
5329 5322
 					$sourceProfileID = $uidA['profileID'];
5330 5323
 					$moveList = array();
5331
-					foreach($_messageList['msg'] as $rowID)
5324
+					foreach ($_messageList['msg'] as $rowID)
5332 5325
 					{
5333 5326
 						$hA = self::splitRowID($rowID);
5334 5327
 
5335 5328
 						// If folder changes, stop and move what we've got
5336
-						if($hA['folder'] != $folder) break;
5329
+						if ($hA['folder'] != $folder) break;
5337 5330
 
5338 5331
 						array_shift($_messageList['msg']);
5339 5332
 						$messageList[] = $hA['msgUID'];
5340 5333
 						$moveList[] = $hA['msgUID'];
5341
-						if ($_copyOrMove=='move')
5334
+						if ($_copyOrMove == 'move')
5342 5335
 						{
5343
-							$helpvar = explode(self::$delimiter,$rowID);
5336
+							$helpvar = explode(self::$delimiter, $rowID);
5344 5337
 							array_shift($helpvar);
5345
-							$messageListForRefresh[]= implode(self::$delimiter,$helpvar);
5338
+							$messageListForRefresh[] = implode(self::$delimiter, $helpvar);
5346 5339
 						}
5347 5340
 					}
5348 5341
 					try
5349 5342
 					{
5350 5343
 						//error_log(__METHOD__.__LINE__."->".print_r($moveList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod.' '.$targetProfileID.'/'.$sourceProfileID);
5351
-						$this->mail_bo->moveMessages($targetFolder,$moveList,($_copyOrMove=='copy'?false:true),$folder,false,$sourceProfileID,($targetProfileID!=$sourceProfileID?$targetProfileID:null));
5344
+						$this->mail_bo->moveMessages($targetFolder, $moveList, ($_copyOrMove == 'copy' ?false:true), $folder, false, $sourceProfileID, ($targetProfileID != $sourceProfileID ? $targetProfileID : null));
5352 5345
 					}
5353 5346
 					catch (Api\Exception $e)
5354 5347
 					{
5355
-						$error = str_replace('"',"'",$e->getMessage());
5348
+						$error = str_replace('"', "'", $e->getMessage());
5356 5349
 					}
5357 5350
 				}
5358 5351
 			}
@@ -5366,34 +5359,34 @@  discard block
 block discarded – undo
5366 5359
 					$changeFolderActions = true;
5367 5360
 				}
5368 5361
 				if ($_return) return $error;
5369
-				$response->call('egw.message',$error,"error");
5362
+				$response->call('egw.message', $error, "error");
5370 5363
 			}
5371 5364
 			else
5372 5365
 			{
5373
-				if ($_copyOrMove=='copy')
5366
+				if ($_copyOrMove == 'copy')
5374 5367
 				{
5375
-					$msg = lang('copied %1 message(s) from %2 to %3',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($messageList)),$folder,$targetFolder);
5368
+					$msg = lang('copied %1 message(s) from %2 to %3', ($messageList == 'all' || $_messageList['all'] ? ($filtered ?lang('all filtered') : lang('all')) : count($messageList)), $folder, $targetFolder);
5376 5369
 					if ($_return) return $msg;
5377
-					$response->call('egw.message',$msg);
5370
+					$response->call('egw.message', $msg);
5378 5371
 				}
5379 5372
 				else
5380 5373
 				{
5381
-					$msg = lang('moved %1 message(s) from %2 to %3',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($messageList)),$folder,$targetFolder);
5374
+					$msg = lang('moved %1 message(s) from %2 to %3', ($messageList == 'all' || $_messageList['all'] ? ($filtered ?lang('all filtered') : lang('all')) : count($messageList)), $folder, $targetFolder);
5382 5375
 					if ($_return) return $msg;
5383
-					$response->call('egw.refresh',$msg,'mail',$messageListForRefresh,'delete');
5376
+					$response->call('egw.refresh', $msg, 'mail', $messageListForRefresh, 'delete');
5384 5377
 				}
5385 5378
 			}
5386 5379
 			if ($changeFolderActions == true)
5387 5380
 			{
5388 5381
 				//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont));
5389
-				Api\Cache::setCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFoldersUsedForMoveCont, $expiration=60*60*1);
5382
+				Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), $lastFoldersUsedForMoveCont, $expiration = 60 * 60 * 1);
5390 5383
 				$actionsnew = Etemplate\Widget\Nextmatch::egw_actions(self::get_actions());
5391
-				$response->call('app.mail.mail_rebuildActionsOnList',$actionsnew);
5384
+				$response->call('app.mail.mail_rebuildActionsOnList', $actionsnew);
5392 5385
 			}
5393 5386
 		}
5394 5387
 		else
5395 5388
 		{
5396
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5389
+			if (Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5397 5390
 		}
5398 5391
 	}
5399 5392
 
@@ -5403,11 +5396,11 @@  discard block
 block discarded – undo
5403 5396
 	 *
5404 5397
 	 * @param type $_id
5405 5398
 	 */
5406
-	function ajax_folderMgmtTree_autoloading ($_id = null)
5399
+	function ajax_folderMgmtTree_autoloading($_id = null)
5407 5400
 	{
5408 5401
 		$mail_ui = new mail_ui();
5409
-		$id = $_id? $_id : $_GET['id'];
5410
-		Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id,'',1,true,false,false,false));
5402
+		$id = $_id ? $_id : $_GET['id'];
5403
+		Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id, '', 1, true, false, false, false));
5411 5404
 	}
5412 5405
 
5413 5406
 	/**
@@ -5415,15 +5408,15 @@  discard block
 block discarded – undo
5415 5408
 	 *
5416 5409
 	 * @param array $content content of dialog
5417 5410
 	 */
5418
-	function folderManagement (array $content = null)
5411
+	function folderManagement(array $content = null)
5419 5412
 	{
5420 5413
 		$dtmpl = new Etemplate('mail.folder_management');
5421
-		$profileID = $_GET['acc_id']? $_GET['acc_id']: $content['acc_id'];
5422
-		$sel_options['tree'] = $this->mail_tree->getTree(null,$profileID, 1, true, false, false);
5414
+		$profileID = $_GET['acc_id'] ? $_GET['acc_id'] : $content['acc_id'];
5415
+		$sel_options['tree'] = $this->mail_tree->getTree(null, $profileID, 1, true, false, false);
5423 5416
 
5424 5417
 		if (!is_array($content))
5425 5418
 		{
5426
-			$content = array ('acc_id' => $profileID);
5419
+			$content = array('acc_id' => $profileID);
5427 5420
 		}
5428 5421
 
5429 5422
 		$readonlys = array();
@@ -5431,7 +5424,7 @@  discard block
 block discarded – undo
5431 5424
 		$preserv = array(
5432 5425
 			'acc_id' => $content['acc_id'] // preserve acc id to be used in client-side
5433 5426
 		);
5434
-		$dtmpl->exec('mail.mail_ui.folderManagement', $content,$sel_options,$readonlys,$preserv,2);
5427
+		$dtmpl->exec('mail.mail_ui.folderManagement', $content, $sel_options, $readonlys, $preserv, 2);
5435 5428
 	}
5436 5429
 
5437 5430
 	/**
@@ -5441,11 +5434,11 @@  discard block
 block discarded – undo
5441 5434
 	 *
5442 5435
 	 * @param type $_folderName
5443 5436
 	 */
5444
-	function ajax_folderMgmt_delete ($_folderName)
5437
+	function ajax_folderMgmt_delete($_folderName)
5445 5438
 	{
5446 5439
 		if ($_folderName)
5447 5440
 		{
5448
-			$success = $this->ajax_deleteFolder($_folderName,true);
5441
+			$success = $this->ajax_deleteFolder($_folderName, true);
5449 5442
 			$response = Api\Json\Response::get();
5450 5443
 			list(,$folderName) = explode(self::$delimiter, $_folderName);
5451 5444
 			if ($success)
@@ -5454,7 +5447,7 @@  discard block
 block discarded – undo
5454 5447
 			}
5455 5448
 			else
5456 5449
 			{
5457
-				$res = lang("Failed to delete %1",$folderName);
5450
+				$res = lang("Failed to delete %1", $folderName);
5458 5451
 			}
5459 5452
 			$response->data($res);
5460 5453
 		}
Please login to merge, or discard this patch.
Braces   +909 added lines, -250 removed lines patch added patch discarded remove patch
@@ -127,9 +127,15 @@  discard block
 block discarded – undo
127 127
 	function __construct($run_constructor=true)
128 128
 	{
129 129
 		$this->mail_tree = new mail_tree($this);
130
-		if (!$run_constructor) return;
130
+		if (!$run_constructor)
131
+		{
132
+			return;
133
+		}
131 134
 
132
-		if (Mail::$debugTimes) $starttime = microtime (true);
135
+		if (Mail::$debugTimes)
136
+		{
137
+			$starttime = microtime (true);
138
+		}
133 139
 		// no autohide of the sidebox, as we use it for folderlist now.
134 140
 		unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']);
135 141
 
@@ -140,13 +146,19 @@  discard block
 block discarded – undo
140 146
 		if ($_GET["resetConnection"])
141 147
 		{
142 148
 			unset($_GET["resetConnection"]);
143
-			if (Mail::$debug) error_log(__METHOD__.__LINE__.' Connection Reset triggered: for Profile with ID:'.self::$icServerID);
149
+			if (Mail::$debug)
150
+			{
151
+				error_log(__METHOD__.__LINE__.' Connection Reset triggered: for Profile with ID:'.self::$icServerID);
152
+			}
144 153
 			Mail::unsetCachedObjects(self::$icServerID);
145 154
 		}
146 155
 
147 156
 		try {
148 157
 			$this->mail_bo = Mail::getInstance(true,self::$icServerID, true, false, true);
149
-			if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
158
+			if (Mail::$debug)
159
+			{
160
+				error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
161
+			}
150 162
 			//error_log(__METHOD__.__LINE__.array2string($this->mail_bo->icServer));
151 163
 
152 164
 			// RegEx to minimize extra openConnection
@@ -167,9 +179,15 @@  discard block
 block discarded – undo
167 179
 				$response->call('egw.message',$e->getMessage(),'error');
168 180
 			}
169 181
 			// redirect to mail wizard to handle it (redirect works for ajax too), unless index is called. we want the sidebox
170
-			if ($_GET['menuaction'] != 'mail.mail_ui.index') self::callWizard($e->getMessage(),true,'error',false);
182
+			if ($_GET['menuaction'] != 'mail.mail_ui.index')
183
+			{
184
+				self::callWizard($e->getMessage(),true,'error',false);
185
+			}
186
+		}
187
+		if (Mail::$debugTimes)
188
+		{
189
+			Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
171 190
 		}
172
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
173 191
 	}
174 192
 
175 193
 	/**
@@ -229,16 +247,28 @@  discard block
 block discarded – undo
229 247
 	 */
230 248
 	function changeProfile($_icServerID,$unsetCache=false)
231 249
 	{
232
-		if (Mail::$debugTimes) $starttime = microtime (true);
250
+		if (Mail::$debugTimes)
251
+		{
252
+			$starttime = microtime (true);
253
+		}
233 254
 		if (self::$icServerID != $_icServerID)
234 255
 		{
235 256
 			self::$icServerID = $_icServerID;
236 257
 		}
237
-		if (Mail::$debug) error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID);
258
+		if (Mail::$debug)
259
+		{
260
+			error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID);
261
+		}
238 262
 
239
-		if ($unsetCache) Mail::unsetCachedObjects(self::$icServerID);
263
+		if ($unsetCache)
264
+		{
265
+			Mail::unsetCachedObjects(self::$icServerID);
266
+		}
240 267
 		$this->mail_bo = Mail::getInstance(false,self::$icServerID,true, false, true);
241
-		if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
268
+		if (Mail::$debug)
269
+		{
270
+			error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace());
271
+		}
242 272
 		// no icServer Object: something failed big time
243 273
 		if (!isset($this->mail_bo) || !isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId<>$_icServerID)
244 274
 		{
@@ -248,14 +278,23 @@  discard block
 block discarded – undo
248 278
 
249 279
 		// save session varchar
250 280
 		$oldicServerID =& Api\Cache::getSession('mail','activeProfileID');
251
-		if ($oldicServerID <> self::$icServerID) $this->mail_bo->openConnection(self::$icServerID);
252
-		if (true) $oldicServerID = self::$icServerID;
281
+		if ($oldicServerID <> self::$icServerID)
282
+		{
283
+			$this->mail_bo->openConnection(self::$icServerID);
284
+		}
285
+		if (true)
286
+		{
287
+			$oldicServerID = self::$icServerID;
288
+		}
253 289
 		if (!Mail::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true ))
254 290
 		{
255 291
 			throw new Api\Exception(__METHOD__." failed to change Profile to $_icServerID");
256 292
 		}
257 293
 
258
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
294
+		if (Mail::$debugTimes)
295
+		{
296
+			Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
297
+		}
259 298
 	}
260 299
 
261 300
 	/**
@@ -296,7 +335,8 @@  discard block
 block discarded – undo
296 335
 		// got subscribed or unsubscribed by the user
297 336
 		try {
298 337
 			$subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('',0,true);
299
-		} catch (Exception $ex) {
338
+		}
339
+		catch (Exception $ex) {
300 340
 			Framework::message($ex->getMessage());
301 341
 		}
302 342
 
@@ -330,9 +370,18 @@  discard block
 block discarded – undo
330 370
 						list(,$node) = explode($profileId.self::$delimiter, $path);
331 371
 						if ($node)
332 372
 						{
333
-							if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe []= $node;
334
-							if (is_array($subscribed) && !$subscribed[$node] && $value['value']) $to_subscribe [] = $node;
335
-							if ($value['value']) $cont[] = $path;
373
+							if (is_array($subscribed) && $subscribed[$node] && !$value['value'])
374
+							{
375
+								$to_unsubscribe []= $node;
376
+							}
377
+							if (is_array($subscribed) && !$subscribed[$node] && $value['value'])
378
+							{
379
+								$to_subscribe [] = $node;
380
+							}
381
+							if ($value['value'])
382
+							{
383
+								$cont[] = $path;
384
+							}
336 385
 						}
337 386
 
338 387
 					}
@@ -420,9 +469,15 @@  discard block
 block discarded – undo
420 469
 	{
421 470
 		//error_log(__METHOD__.__LINE__.array2string($content));
422 471
 		try	{
423
-				if (!isset($this->mail_bo)) throw new Api\Exception\WrongUserinput(lang('Initialization of mail failed. Please use the Wizard to cope with the problem.'));
472
+				if (!isset($this->mail_bo))
473
+				{
474
+					throw new Api\Exception\WrongUserinput(lang('Initialization of mail failed. Please use the Wizard to cope with the problem.'));
475
+				}
424 476
 				//error_log(__METHOD__.__LINE__.function_backtrace());
425
-				if (Mail::$debugTimes) $starttime = microtime (true);
477
+				if (Mail::$debugTimes)
478
+				{
479
+					$starttime = microtime (true);
480
+				}
426 481
 				$this->mail_bo->restoreSessionData();
427 482
 				$sessionFolder = $this->mail_bo->sessionData['mailbox'];
428 483
 				if ($this->mail_bo->folderExists($sessionFolder))
@@ -451,7 +506,10 @@  discard block
 block discarded – undo
451 506
 							'sort'           =>	'DESC',	// IO direction of the sort: 'ASC' or 'DESC'
452 507
 						);
453 508
 					}
454
-					if (Api\Header\UserAgent::mobile()) $content[self::$nm_index]['header_row'] = 'mail.index.header_right';
509
+					if (Api\Header\UserAgent::mobile())
510
+					{
511
+						$content[self::$nm_index]['header_row'] = 'mail.index.header_right';
512
+					}
455 513
 				}
456 514
 
457 515
 				// These must always be set, even if $content is an array
@@ -475,13 +533,16 @@  discard block
 block discarded – undo
475 533
 				}
476 534
 				// call getQuotaRoot asynchronously in getRows by initiating a client Server roundtrip
477 535
 				$quota = false;//$this->mail_bo->getQuotaRoot();
478
-				if($quota !== false && $quota['limit'] != 'NOT SET') {
536
+				if($quota !== false && $quota['limit'] != 'NOT SET')
537
+				{
479 538
 					$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
480 539
 					$content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text'];
481 540
 					$content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] =  (string)$quotainfo['percent'];
482 541
 					$content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class'];
483 542
 					$content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "";
484
-				} else {
543
+				}
544
+				else
545
+				{
485 546
 					$content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = lang("Quota not provided by server");
486 547
 					$content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = "mail_DisplayNone";
487 548
 					$content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone";
@@ -508,19 +569,31 @@  discard block
 block discarded – undo
508 569
 					$keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5');
509 570
 					foreach($keywords as &$k)
510 571
 					{
511
-						if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]);
572
+						if (array_key_exists($k,$this->statusTypes))
573
+						{
574
+							unset($this->statusTypes[$k]);
575
+						}
512 576
 					}
513 577
 				}
514 578
 
515
-				if (!isset($content[self::$nm_index]['foldertree'])) $content[self::$nm_index]['foldertree'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
516
-				if (!isset($content[self::$nm_index]['selectedFolder'])) $content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
579
+				if (!isset($content[self::$nm_index]['foldertree']))
580
+				{
581
+					$content[self::$nm_index]['foldertree'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
582
+				}
583
+				if (!isset($content[self::$nm_index]['selectedFolder']))
584
+				{
585
+					$content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
586
+				}
517 587
 
518 588
 				$content[self::$nm_index]['foldertree'] = $content[self::$nm_index]['selectedFolder'];
519 589
 
520 590
 				if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
521 591
 				{
522 592
 					Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
523
-					if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
593
+					if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
594
+					{
595
+						Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
596
+					}
524 597
 				}
525 598
 				if (!Mail::$supportsORinQuery[$this->mail_bo->profileID])
526 599
 				{
@@ -542,10 +615,16 @@  discard block
 block discarded – undo
542 615
 				$etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $this->get_tree_actions());
543 616
 
544 617
 				// sending preview toolbar actions
545
-				if ($content['mailSplitter']) $etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions());
618
+				if ($content['mailSplitter'])
619
+				{
620
+					$etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions());
621
+				}
546 622
 
547 623
 				// We need to send toolbar actions to client-side because view template needs them
548
-				if (Api\Header\UserAgent::mobile()) $sel_options['toolbar'] = $this->get_toolbar_actions();
624
+				if (Api\Header\UserAgent::mobile())
625
+				{
626
+					$sel_options['toolbar'] = $this->get_toolbar_actions();
627
+				}
549 628
 
550 629
 				//we use the category "filter" option as specifier where we want to search (quick, subject, from, to, etc. ....)
551 630
 				if (empty($content[self::$nm_index]['cat_id']) || empty($content[self::$nm_index]['search']))
@@ -553,7 +632,10 @@  discard block
 block discarded – undo
553 632
 					$content[self::$nm_index]['cat_id']=($content[self::$nm_index]['cat_id']?(!Mail::$supportsORinQuery[$this->mail_bo->profileID]&&($content[self::$nm_index]['cat_id']=='quick'||$content[self::$nm_index]['cat_id']=='quickwithcc')?'subject':$content[self::$nm_index]['cat_id']):(Mail::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject'));
554 633
 				}
555 634
 				$readonlys = $preserv = array();
556
-				if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
635
+				if (Mail::$debugTimes)
636
+				{
637
+					Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__);
638
+				}
557 639
 		}
558 640
 		catch (Exception $e)
559 641
 		{
@@ -569,7 +651,10 @@  discard block
 block discarded – undo
569 651
 				$etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $this->get_tree_actions(false));
570 652
 			}
571 653
 			$readonlys = $preserv = array();
572
-			if (empty($content)) $content=array();
654
+			if (empty($content))
655
+			{
656
+				$content=array();
657
+			}
573 658
 
574 659
 			self::callWizard($e->getMessage().($e->details?', '.$e->details:''),(isset($this->mail_bo)?false:true), 'error',false);
575 660
 			//return false;
@@ -809,7 +894,8 @@  discard block
 block discarded – undo
809 894
 			$this->mail_bo->icServer->subscribeMailbox($_folderName, $_status);
810 895
 			$this->mail_bo->resetFolderObjectCache($_acc_id);
811 896
 			$this->ajax_reloadNode($_acc_id,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
812
-		} catch (Horde_Imap_Client_Exception $ex) {
897
+		}
898
+		catch (Horde_Imap_Client_Exception $ex) {
813 899
 			error_log(__METHOD__.__LINE__."()". lang('Folder %1 %2 failed because of %3!',$_folderName,$_status?'subscribed':'unsubscribed', $ex));
814 900
 			Framework::message(lang('Folder %1 %2 failed!',$_folderName,$_status));
815 901
 		}
@@ -826,12 +912,18 @@  discard block
 block discarded – undo
826 912
 	public function ajax_foldertree($_nodeID = null,$_subscribedOnly=null)
827 913
 	{
828 914
 		$nodeID = $_GET['id'];
829
-		if (!is_null($_nodeID)) $nodeID = $_nodeID;
915
+		if (!is_null($_nodeID))
916
+		{
917
+			$nodeID = $_nodeID;
918
+		}
830 919
 		$subscribedOnly = (bool)(!is_null($_subscribedOnly)?$_subscribedOnly:!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
831 920
 		$fetchCounters = !is_null($_nodeID);
832 921
 		list($_profileID,$_folderName) = explode(self::$delimiter,$nodeID,2);
833 922
 
834
-		if (!empty($_folderName)) $fetchCounters = true;
923
+		if (!empty($_folderName))
924
+		{
925
+			$fetchCounters = true;
926
+		}
835 927
 
836 928
 		// Check if it is called for refresh root
837 929
 		// then we need to reinitialized the index tree
@@ -843,7 +935,10 @@  discard block
 block discarded – undo
843 935
 		{
844 936
 			$data = $this->mail_tree->getTree($nodeID,$_profileID,0, false,$subscribedOnly,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']);
845 937
 		}
846
-		if (!is_null($_nodeID)) return $data;
938
+		if (!is_null($_nodeID))
939
+		{
940
+			return $data;
941
+		}
847 942
 		Etemplate\Widget\Tree::send_quote_json($data);
848 943
 	}
849 944
 
@@ -1053,7 +1148,10 @@  discard block
 block discarded – undo
1053 1148
 				$accArray[$acc_id] = str_replace(array('<','>'),array('[',']'),$identity_name);// as angle brackets are quoted, display in Javascript messages when used is ugly, so use square brackets instead
1054 1149
 			}
1055 1150
 		}
1056
-		if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont=array();
1151
+		if (!is_array($lastFoldersUsedForMoveCont))
1152
+		{
1153
+			$lastFoldersUsedForMoveCont=array();
1154
+		}
1057 1155
 		foreach (array_keys($lastFoldersUsedForMoveCont) as $pid)
1058 1156
 		{
1059 1157
 			if ($this->mail_bo->profileID==$pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]))
@@ -1069,9 +1167,12 @@  discard block
 block discarded – undo
1069 1167
 						$moveaction .= $lastFolderUsedForMoveCont;
1070 1168
 						//error_log(__METHOD__.__LINE__.'#'.$moveaction);
1071 1169
 						//error_log(__METHOD__.__LINE__.'#'.$currentArchiveActionKey);
1072
-						if ($this->mail_bo->folderExists($i)) // only 10 entries per mailaccount.Control this on setting the buffered folders
1170
+						if ($this->mail_bo->folderExists($i))
1171
+						{
1172
+							// only 10 entries per mailaccount.Control this on setting the buffered folders
1073 1173
 						{
1074 1174
 							$fS['profileID'] = $this->mail_bo->profileID;
1175
+						}
1075 1176
 							$fS['profileName'] = $accArray[$this->mail_bo->profileID];
1076 1177
 							$fS['shortDisplayName'] = $i;
1077 1178
 							$moveactions[$moveaction] = $fS;
@@ -1091,9 +1192,12 @@  discard block
 block discarded – undo
1091 1192
 				foreach ($lastFoldersUsedForMoveCont[$pid] as $i => $lastFolderUsedForMoveCont)
1092 1193
 				{
1093 1194
 					//error_log(__METHOD__.__LINE__."$i => $lastFolderUsedForMoveCont");
1094
-					if (!empty($lastFolderUsedForMoveCont)) // only 10 entries per mailaccount.Control this on setting the buffered folders
1195
+					if (!empty($lastFolderUsedForMoveCont))
1196
+					{
1197
+						// only 10 entries per mailaccount.Control this on setting the buffered folders
1095 1198
 					{
1096 1199
 						$moveaction = 'move_'.$lastFolderUsedForMoveCont;
1200
+					}
1097 1201
 						//error_log(__METHOD__.__LINE__.'#'.$moveaction);
1098 1202
 						$fS = array();
1099 1203
 						$fS['profileID'] = $pid;
@@ -1198,7 +1302,9 @@  discard block
 block discarded – undo
1198 1302
 				'children' => $children,
1199 1303
 			);
1200 1304
 
1201
-		} else {
1305
+		}
1306
+		else
1307
+		{
1202 1308
 			$group++;
1203 1309
 		}
1204 1310
 		$spam_actions = $this->getSpamActions();
@@ -1484,7 +1590,10 @@  discard block
 block discarded – undo
1484 1590
 					$rows=array();
1485 1591
 					return 0;
1486 1592
 				}
1487
-				if (empty($folderName)) $query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX';
1593
+				if (empty($folderName))
1594
+				{
1595
+					$query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX';
1596
+				}
1488 1597
 			}
1489 1598
 		}
1490 1599
 		if (!isset($mail_ui))
@@ -1499,15 +1608,24 @@  discard block
 block discarded – undo
1499 1608
 				$rows=array();
1500 1609
 				return 0;
1501 1610
 			}
1502
-			if (empty($query['selectedFolder'])) $query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX';
1611
+			if (empty($query['selectedFolder']))
1612
+			{
1613
+				$query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX';
1614
+			}
1503 1615
 		}
1504 1616
 		//error_log(__METHOD__.__LINE__.' SelectedFolder:'.$query['selectedFolder'].' Start:'.$query['start'].' NumRows:'.$query['num_rows'].array2string($query['order']).'->'.array2string($query['sort']));
1505 1617
 		//Mail::$debugTimes=true;
1506
-		if (Mail::$debugTimes) $starttime = microtime(true);
1618
+		if (Mail::$debugTimes)
1619
+		{
1620
+			$starttime = microtime(true);
1621
+		}
1507 1622
 		//$query['search'] is the phrase in the searchbox
1508 1623
 
1509 1624
 		$mail_ui->mail_bo->restoreSessionData();
1510
-		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder'];
1625
+		if (isset($query['selectedFolder']))
1626
+		{
1627
+			$mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder'];
1628
+		}
1511 1629
 
1512 1630
 		$sRToFetch = null;
1513 1631
 		list($_profileID,$_folderName) = explode(self::$delimiter,$query['selectedFolder'],2);
@@ -1517,7 +1635,10 @@  discard block
 block discarded – undo
1517 1635
 			unset($app);
1518 1636
 		}
1519 1637
 		//save selected Folder to sessionData (mailbox)->currentFolder
1520
-		if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$_folderName;
1638
+		if (isset($query['selectedFolder']))
1639
+		{
1640
+			$mail_ui->mail_bo->sessionData['mailbox']=$_folderName;
1641
+		}
1521 1642
 		$toSchema = false;//decides to select list schema with column to selected (if false fromaddress is default)
1522 1643
 		if ($mail_ui->mail_bo->folderExists($_folderName))
1523 1644
 		{
@@ -1549,8 +1670,16 @@  discard block
 block discarded – undo
1549 1670
 			}
1550 1671
 			//error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']);
1551 1672
 			$cutoffdate = $cutoffdate2 = null;
1552
-			if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
1553
-			if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
1673
+			if ($query['startdate'])
1674
+			{
1675
+				$cutoffdate = Api\DateTime::to($query['startdate'],'ts');
1676
+			}
1677
+			//SINCE, enddate
1678
+			if ($query['enddate'])
1679
+			{
1680
+				$cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');
1681
+			}
1682
+			//BEFORE, startdate
1554 1683
 			//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
1555 1684
 			$filter = array(
1556 1685
 				'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
@@ -1559,15 +1688,24 @@  discard block
 block discarded – undo
1559 1688
 				'status' => 'any',
1560 1689
 				//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
1561 1690
 			);
1562
-			if ($query['enddate']||$query['startdate']) {
1691
+			if ($query['enddate']||$query['startdate'])
1692
+			{
1563 1693
 				$filter['range'] = "BETWEEN";
1564
-				if ($cutoffdate) {
1694
+				if ($cutoffdate)
1695
+				{
1565 1696
 					$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
1566
-					if (empty($cutoffdate2)) $filter['range'] = "SINCE";
1697
+					if (empty($cutoffdate2))
1698
+					{
1699
+						$filter['range'] = "SINCE";
1700
+					}
1567 1701
 				}
1568
-				if ($cutoffdate2) {
1702
+				if ($cutoffdate2)
1703
+				{
1569 1704
 					$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
1570
-					if (empty($cutoffdate)) $filter['range'] = "BEFORE";
1705
+					if (empty($cutoffdate))
1706
+					{
1707
+						$filter['range'] = "BEFORE";
1708
+					}
1571 1709
 				}
1572 1710
 			}
1573 1711
 		}
@@ -1620,7 +1758,10 @@  discard block
 block discarded – undo
1620 1758
 				$rowsFetched['messages'] = $_sR['count'];
1621 1759
 				$ids = $_sR['match']->ids;
1622 1760
 				// if $sR is false, something failed fundamentally
1623
-				if($reverse === true) $ids = ($ids===false?array():array_reverse((array)$ids));
1761
+				if($reverse === true)
1762
+				{
1763
+					$ids = ($ids===false?array():array_reverse((array)$ids));
1764
+				}
1624 1765
 				$sR = array_slice((array)$ids,($offset==0?0:$offset-1),$maxMessages); // we need only $maxMessages of uids
1625 1766
 				$sRToFetch = $sR;//array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids
1626 1767
 				//error_log(__METHOD__.__LINE__.' Rows fetched (UID only):'.count($sR).' Data:'.array2string($sR));
@@ -1686,7 +1827,10 @@  discard block
 block discarded – undo
1686 1827
 				}
1687 1828
 				else
1688 1829
 				{
1689
-					if (!empty($v)) $sortResult['header'][] = array('uid'=>$v);
1830
+					if (!empty($v))
1831
+					{
1832
+						$sortResult['header'][] = array('uid'=>$v);
1833
+					}
1690 1834
 				}
1691 1835
 			}
1692 1836
 		}
@@ -1695,11 +1839,17 @@  discard block
 block discarded – undo
1695 1839
 			$sortResult = $sortResultwH;
1696 1840
 		}
1697 1841
 		$rowsFetched['rowsFetched'] = $sortResult['header'] ? count($sortResult['header']) : 0;
1698
-		if (empty($rowsFetched['messages'])) $rowsFetched['messages'] = $rowsFetched['rowsFetched'];
1842
+		if (empty($rowsFetched['messages']))
1843
+		{
1844
+			$rowsFetched['messages'] = $rowsFetched['rowsFetched'];
1845
+		}
1699 1846
 
1700 1847
 		//error_log(__METHOD__.__LINE__.' Rows fetched:'.$rowsFetched.' Data:'.array2string($sortResult));
1701 1848
 		$cols = array('row_id','uid','status','attachments','subject','address','toaddress','fromaddress','ccaddress','additionaltoaddress','date','size','modified','bodypreview', 'security');
1702
-		if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE') unset($cols[0]);
1849
+		if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE')
1850
+		{
1851
+			unset($cols[0]);
1852
+		}
1703 1853
 		$rows = $mail_ui->header2gridelements($sortResult['header'],$cols, $_folderName, $folderType=$toSchema);
1704 1854
 
1705 1855
 		// Save the session (since we are committing session) at the end
@@ -1707,7 +1857,10 @@  discard block
 block discarded – undo
1707 1857
 		// e.g.: Link:: get_data which is used to read attachments data.
1708 1858
 		$mail_ui->mail_bo->saveSessionData();
1709 1859
 
1710
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__);
1860
+		if (Mail::$debugTimes)
1861
+		{
1862
+			Mail::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__);
1863
+		}
1711 1864
 		return $rowsFetched['messages'];
1712 1865
 	}
1713 1866
 
@@ -1813,7 +1966,10 @@  discard block
 block discarded – undo
1813 1966
 					$actionsenabled[$act]= $actions['spamfilter']['children'][$act];
1814 1967
 					break;
1815 1968
 				default:
1816
-					if (isset($actions[$act])) $actionsenabled[$act]=$actions[$act];
1969
+					if (isset($actions[$act]))
1970
+					{
1971
+						$actionsenabled[$act]=$actions[$act];
1972
+					}
1817 1973
 			}
1818 1974
 		}
1819 1975
 		unset($actionsenabled['drag_mail']);
@@ -1835,7 +1991,10 @@  discard block
 block discarded – undo
1835 1991
 	 */
1836 1992
 	public function header2gridelements($_headers, $cols, $_folderName, $_folderType=0)
1837 1993
 	{
1838
-		if (Mail::$debugTimes) $starttime = microtime(true);
1994
+		if (Mail::$debugTimes)
1995
+		{
1996
+			$starttime = microtime(true);
1997
+		}
1839 1998
 		$rv = array();
1840 1999
 		$i=0;
1841 2000
 		foreach((array)$_headers as $header)
@@ -1854,17 +2013,50 @@  discard block
 block discarded – undo
1854 2013
 			}
1855 2014
 
1856 2015
 			$flags = "";
1857
-			if(!empty($header['recent'])) $flags .= "R";
1858
-			if(!empty($header['flagged'])) $flags .= "F";
1859
-			if(!empty($header['answered'])) $flags .= "A";
1860
-			if(!empty($header['forwarded'])) $flags .= "W";
1861
-			if(!empty($header['deleted'])) $flags .= "D";
1862
-			if(!empty($header['seen'])) $flags .= "S";
1863
-			if(!empty($header['label1'])) $flags .= "1";
1864
-			if(!empty($header['label2'])) $flags .= "2";
1865
-			if(!empty($header['label3'])) $flags .= "3";
1866
-			if(!empty($header['label4'])) $flags .= "4";
1867
-			if(!empty($header['label5'])) $flags .= "5";
2016
+			if(!empty($header['recent']))
2017
+			{
2018
+				$flags .= "R";
2019
+			}
2020
+			if(!empty($header['flagged']))
2021
+			{
2022
+				$flags .= "F";
2023
+			}
2024
+			if(!empty($header['answered']))
2025
+			{
2026
+				$flags .= "A";
2027
+			}
2028
+			if(!empty($header['forwarded']))
2029
+			{
2030
+				$flags .= "W";
2031
+			}
2032
+			if(!empty($header['deleted']))
2033
+			{
2034
+				$flags .= "D";
2035
+			}
2036
+			if(!empty($header['seen']))
2037
+			{
2038
+				$flags .= "S";
2039
+			}
2040
+			if(!empty($header['label1']))
2041
+			{
2042
+				$flags .= "1";
2043
+			}
2044
+			if(!empty($header['label2']))
2045
+			{
2046
+				$flags .= "2";
2047
+			}
2048
+			if(!empty($header['label3']))
2049
+			{
2050
+				$flags .= "3";
2051
+			}
2052
+			if(!empty($header['label4']))
2053
+			{
2054
+				$flags .= "4";
2055
+			}
2056
+			if(!empty($header['label5']))
2057
+			{
2058
+				$flags .= "5";
2059
+			}
1868 2060
 
1869 2061
 			$data["status"] = "<span class=\"status_img\"></span>";
1870 2062
 			//error_log(__METHOD__.array2string($header).' Flags:'.$flags);
@@ -1872,41 +2064,53 @@  discard block
 block discarded – undo
1872 2064
 			// the css for this row
1873 2065
 			$is_recent=false;
1874 2066
 			$css_styles = array("mail");
1875
-			if ($header['deleted']) {
2067
+			if ($header['deleted'])
2068
+			{
1876 2069
 				$css_styles[] = 'deleted';
1877 2070
 			}
1878
-			if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded'])) {
2071
+			if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded']))
2072
+			{
1879 2073
 				$css_styles[] = 'recent';
1880 2074
 				$is_recent=true;
1881 2075
 			}
1882
-			if ($header['priority'] < 3) {
2076
+			if ($header['priority'] < 3)
2077
+			{
1883 2078
 				$css_styles[] = 'prio_high';
1884 2079
 			}
1885
-			if ($header['flagged']) {
2080
+			if ($header['flagged'])
2081
+			{
1886 2082
 				$css_styles[] = 'flagged';
1887 2083
 			}
1888
-			if (!$header['seen']) {
2084
+			if (!$header['seen'])
2085
+			{
1889 2086
 				$css_styles[] = 'unseen'; // different status image for recent // solved via css !important
1890 2087
 			}
1891
-			if ($header['answered']) {
2088
+			if ($header['answered'])
2089
+			{
1892 2090
 				$css_styles[] = 'replied';
1893 2091
 			}
1894
-			if ($header['forwarded']) {
2092
+			if ($header['forwarded'])
2093
+			{
1895 2094
 				$css_styles[] = 'forwarded';
1896 2095
 			}
1897
-			if ($header['label1']) {
2096
+			if ($header['label1'])
2097
+			{
1898 2098
 				$css_styles[] = 'labelone';
1899 2099
 			}
1900
-			if ($header['label2']) {
2100
+			if ($header['label2'])
2101
+			{
1901 2102
 				$css_styles[] = 'labeltwo';
1902 2103
 			}
1903
-			if ($header['label3']) {
2104
+			if ($header['label3'])
2105
+			{
1904 2106
 				$css_styles[] = 'labelthree';
1905 2107
 			}
1906
-			if ($header['label4']) {
2108
+			if ($header['label4'])
2109
+			{
1907 2110
 				$css_styles[] = 'labelfour';
1908 2111
 			}
1909
-			if ($header['label5']) {
2112
+			if ($header['label5'])
2113
+			{
1910 2114
 				$css_styles[] = 'labelfive';
1911 2115
 			}
1912 2116
 
@@ -1923,10 +2127,13 @@  discard block
 block discarded – undo
1923 2127
 				$header['subject'] = preg_replace($search,$replace,$header['subject']);
1924 2128
 				// curly brackets get messed up by the template!
1925 2129
 
1926
-				if (!empty($header['subject'])) {
2130
+				if (!empty($header['subject']))
2131
+				{
1927 2132
 					// make the subject shorter if it is to long
1928 2133
 					$subject = $header['subject'];
1929
-				} else {
2134
+				}
2135
+				else
2136
+				{
1930 2137
 					$subject = '('. lang('no subject') .')';
1931 2138
 				}
1932 2139
 
@@ -2018,26 +2225,53 @@  discard block
 block discarded – undo
2018 2225
 			}
2019 2226
 
2020 2227
 			if (in_array("size", $cols))
2021
-				$data["size"] = $header['size']; /// size
2228
+			{
2229
+							$data["size"] = $header['size'];
2230
+			}
2231
+			/// size
2022 2232
 
2023 2233
 			$data["class"] = implode(' ', $css_styles);
2024 2234
 			//translate style-classes back to flags
2025 2235
 			$data['flags'] = Array();
2026
-			if ($header['seen']) $data["flags"]['read'] = 'read';
2027
-			foreach ($css_styles as &$flag) {
2236
+			if ($header['seen'])
2237
+			{
2238
+				$data["flags"]['read'] = 'read';
2239
+			}
2240
+			foreach ($css_styles as &$flag)
2241
+			{
2028 2242
 				if ($flag!='mail')
2029 2243
 				{
2030
-					if ($flag=='labelone') {$data["flags"]['label1'] = 'label1';}
2031
-					elseif ($flag=='labeltwo') {$data["flags"]['label2'] = 'label2';}
2032
-					elseif ($flag=='labelthree') {$data["flags"]['label3'] = 'label3';}
2033
-					elseif ($flag=='labelfour') {$data["flags"]['label4'] = 'label4';}
2034
-					elseif ($flag=='labelfive') {$data["flags"]['label5'] = 'label5';}
2035
-					elseif ($flag=='unseen') {unset($data["flags"]['read']);}
2036
-					else $data["flags"][$flag] = $flag;
2244
+					if ($flag=='labelone')
2245
+					{
2246
+$data["flags"]['label1'] = 'label1';}
2247
+					elseif ($flag=='labeltwo')
2248
+					{
2249
+$data["flags"]['label2'] = 'label2';}
2250
+					elseif ($flag=='labelthree')
2251
+					{
2252
+$data["flags"]['label3'] = 'label3';}
2253
+					elseif ($flag=='labelfour')
2254
+					{
2255
+$data["flags"]['label4'] = 'label4';}
2256
+					elseif ($flag=='labelfive')
2257
+					{
2258
+$data["flags"]['label5'] = 'label5';}
2259
+					elseif ($flag=='unseen')
2260
+					{
2261
+unset($data["flags"]['read']);}
2262
+					else {
2263
+						$data["flags"][$flag] = $flag;
2264
+					}
2037 2265
 				}
2038 2266
 			}
2039
-			if ($header['disposition-notification-to']) $data['dispositionnotificationto'] = $header['disposition-notification-to'];
2040
-			if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']);
2267
+			if ($header['disposition-notification-to'])
2268
+			{
2269
+				$data['dispositionnotificationto'] = $header['disposition-notification-to'];
2270
+			}
2271
+			if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto']))
2272
+			{
2273
+				unset($data['dispositionnotificationto']);
2274
+			}
2041 2275
 			$data['attachmentsBlock'] = $imageHTMLBlock;
2042 2276
 			$data['address'] = ($_folderType?$data["toaddress"]:$data["fromaddress"]);
2043 2277
 			if (in_array("bodypreview", $cols)&&$header['bodypreview'])
@@ -2047,7 +2281,10 @@  discard block
 block discarded – undo
2047 2281
 			$rv[] = $data;
2048 2282
 			//error_log(__METHOD__.__LINE__.array2string($data));
2049 2283
 		}
2050
-		if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__);
2284
+		if (Mail::$debugTimes)
2285
+		{
2286
+			Mail::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__);
2287
+		}
2051 2288
 
2052 2289
 		// ToDo: call this ONLY if labels change
2053 2290
 		Etemplate\Widget::setElementAttribute('toolbar', 'actions', $this->get_toolbar_actions());
@@ -2062,8 +2299,14 @@  discard block
 block discarded – undo
2062 2299
 	 */
2063 2300
 	function displayHeader()
2064 2301
 	{
2065
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
2066
-		if(isset($_GET['part'])) $partID = $_GET['part'];
2302
+		if(isset($_GET['id']))
2303
+		{
2304
+			$rowID	= $_GET['id'];
2305
+		}
2306
+		if(isset($_GET['part']))
2307
+		{
2308
+			$partID = $_GET['part'];
2309
+		}
2067 2310
 
2068 2311
 		$hA = self::splitRowID($rowID);
2069 2312
 		$uid = $hA['msgUID'];
@@ -2087,7 +2330,8 @@  discard block
 block discarded – undo
2087 2330
 		$rawheaders 	= "";
2088 2331
 		// create it new, with good line breaks
2089 2332
 		reset($newRawHeaders);
2090
-		while(list($key,$value) = @each($newRawHeaders)) {
2333
+		while(list($key,$value) = @each($newRawHeaders))
2334
+		{
2091 2335
 			$rawheaders .= wordwrap($value, 90, "\n     ");
2092 2336
 		}
2093 2337
 
@@ -2110,12 +2354,24 @@  discard block
 block discarded – undo
2110 2354
 	 */
2111 2355
 	function displayMessage($_requesteddata = null)
2112 2356
 	{
2113
-		if (is_null($_requesteddata)) $_requesteddata = $_GET;
2357
+		if (is_null($_requesteddata))
2358
+		{
2359
+			$_requesteddata = $_GET;
2360
+		}
2114 2361
 
2115 2362
 		$preventRedirect=false;
2116
-		if(isset($_requesteddata['id'])) $rowID	= $_requesteddata['id'];
2117
-		if(isset($_requesteddata['part'])) $partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null;
2118
-		if(isset($_requesteddata['mode'])) $preventRedirect   = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false);
2363
+		if(isset($_requesteddata['id']))
2364
+		{
2365
+			$rowID	= $_requesteddata['id'];
2366
+		}
2367
+		if(isset($_requesteddata['part']))
2368
+		{
2369
+			$partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null;
2370
+		}
2371
+		if(isset($_requesteddata['mode']))
2372
+		{
2373
+			$preventRedirect   = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false);
2374
+		}
2119 2375
 
2120 2376
 		$hA = self::splitRowID($rowID);
2121 2377
 		$uid = $hA['msgUID'];
@@ -2128,8 +2384,14 @@  discard block
 block discarded – undo
2128 2384
 			$this->changeProfile($icServerID);
2129 2385
 		}
2130 2386
 		$htmlOptions = $this->mail_bo->htmlOptions;
2131
-		if (!empty($_requesteddata['tryastext'])) $htmlOptions  = "only_if_no_text";
2132
-		if (!empty($_requesteddata['tryashtml'])) $htmlOptions  = "always_display";
2387
+		if (!empty($_requesteddata['tryastext']))
2388
+		{
2389
+			$htmlOptions  = "only_if_no_text";
2390
+		}
2391
+		if (!empty($_requesteddata['tryashtml']))
2392
+		{
2393
+			$htmlOptions  = "always_display";
2394
+		}
2133 2395
 
2134 2396
 		//error_log(__METHOD__.__LINE__.array2string($hA));
2135 2397
 		if (($this->mail_bo->isDraftFolder($mailbox)) && $_requesteddata['mode'] == 'print')
@@ -2153,14 +2415,20 @@  discard block
 block discarded – undo
2153 2415
 			$error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3",$mailbox,$uid,$partID);
2154 2416
 			Framework::message($e->getMessage(), 'error');
2155 2417
 		}
2156
-		if (!empty($uid)) $this->mail_bo->getFlags($uid);
2418
+		if (!empty($uid))
2419
+		{
2420
+			$this->mail_bo->getFlags($uid);
2421
+		}
2157 2422
 		$envelope	= $this->mail_bo->getMessageEnvelope($uid, $partID,true,$mailbox);
2158 2423
 		//error_log(__METHOD__.__LINE__.array2string($envelope));
2159 2424
 		$this->mail_bo->getMessageRawHeader($uid, $partID,$mailbox);
2160 2425
 		$fetchEmbeddedImages = false;
2161 2426
 		// if we are in HTML so its likely that we should show the embedded images; as a result
2162 2427
 		// we do NOT want to see those, that are embedded in the list of attachments
2163
-		if ($htmlOptions !='always_display') $fetchEmbeddedImages = true;
2428
+		if ($htmlOptions !='always_display')
2429
+		{
2430
+			$fetchEmbeddedImages = true;
2431
+		}
2164 2432
 		try{
2165 2433
 			$attachments = $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages,true,true,$mailbox);
2166 2434
 		}
@@ -2183,11 +2451,17 @@  discard block
 block discarded – undo
2183 2451
 		$subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters,'',$envelope['SUBJECT']),false);
2184 2452
 
2185 2453
 		// Set up data for taglist widget(s)
2186
-		if ($envelope['FROM']==$envelope['SENDER']) unset($envelope['SENDER']);
2454
+		if ($envelope['FROM']==$envelope['SENDER'])
2455
+		{
2456
+			unset($envelope['SENDER']);
2457
+		}
2187 2458
 		$sel_options = array();
2188 2459
 		foreach(array('SENDER','FROM','TO','CC','BCC') as $field)
2189 2460
 		{
2190
-			if (!isset($envelope[$field])) continue;
2461
+			if (!isset($envelope[$field]))
2462
+			{
2463
+				continue;
2464
+			}
2191 2465
 			foreach($envelope[$field] as $field_data)
2192 2466
 			{
2193 2467
 				//error_log(__METHOD__.__LINE__.array2string($field_data));
@@ -2201,7 +2475,10 @@  discard block
 block discarded – undo
2201 2475
 		}
2202 2476
 		$actionsenabled = $this->getDisplayToolbarActions();
2203 2477
 		$content['displayToolbaractions'] = json_encode($actionsenabled);
2204
-		if (empty($subject)) $subject = lang('no subject');
2478
+		if (empty($subject))
2479
+		{
2480
+			$subject = lang('no subject');
2481
+		}
2205 2482
 		$content['msg'] = (is_array($error_msg)?implode("<br>",$error_msg):$error_msg);
2206 2483
 		// Send mail ID so we can use it for actions
2207 2484
 		$content['mail_id'] = $rowID;
@@ -2212,8 +2489,14 @@  discard block
 block discarded – undo
2212 2489
 		$content['mail_displaydate'] = Mail::_strtotime($headers['DATE'],'ts',true);
2213 2490
 		$content['mail_displaysubject'] = $subject;
2214 2491
 		$linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody","_messageID"=>$rowID);
2215
-		if (!empty($partID)) $linkData['_partID']=$partID;
2216
-		if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions']=$htmlOptions;
2492
+		if (!empty($partID))
2493
+		{
2494
+			$linkData['_partID']=$partID;
2495
+		}
2496
+		if ($htmlOptions != $this->mail_bo->htmlOptions)
2497
+		{
2498
+			$linkData['_htmloptions']=$htmlOptions;
2499
+		}
2217 2500
 		$content['mailDisplayBodySrc'] = Egw::link('/index.php',$linkData);
2218 2501
 		$content['mail_displayattachments'] = $attachmentHTMLBlock;
2219 2502
 		$content['mail_id']=$rowID;
@@ -2277,7 +2560,10 @@  discard block
 block discarded – undo
2277 2560
 		$passphrase = $_data['passphrase'];
2278 2561
 		foreach (array_keys($_data) as $key)
2279 2562
 		{
2280
-			if (empty($_data[$key]) || in_array($key, $discards)) unset($_data[$key]);
2563
+			if (empty($_data[$key]) || in_array($key, $discards))
2564
+			{
2565
+				unset($_data[$key]);
2566
+			}
2281 2567
 		}
2282 2568
 		$response->data($smime->generate_certificate($_data, $ca, null, $passphrase, $_data['validity']));
2283 2569
 	}
@@ -2288,7 +2574,10 @@  discard block
 block discarded – undo
2288 2574
 	 */
2289 2575
 	function smimeExportCert()
2290 2576
 	{
2291
-		if (empty($_GET['acc_id'])) return false;
2577
+		if (empty($_GET['acc_id']))
2578
+		{
2579
+			return false;
2580
+		}
2292 2581
 		$acc_smime = Mail\Smime::get_acc_smime($_GET['acc_id']);
2293 2582
 		$length = 0;
2294 2583
 		$mime = 'application/x-pkcs12';
@@ -2352,15 +2641,22 @@  discard block
 block discarded – undo
2352 2641
 			}
2353 2642
 		}
2354 2643
 
2355
-		if (is_array($attachments) && count($attachments) > 0) {
2644
+		if (is_array($attachments) && count($attachments) > 0)
2645
+		{
2356 2646
 			foreach ($attachments as $key => $value)
2357 2647
 			{
2358
-				if (Mail\Smime::isSmime($value['mimeType'])) continue;
2648
+				if (Mail\Smime::isSmime($value['mimeType']))
2649
+				{
2650
+					continue;
2651
+				}
2359 2652
 				$attachmentHTML[$key]['filename']= ($value['name'] ? ( $value['filename'] ? $value['filename'] : $value['name'] ) : lang('(no subject)'));
2360 2653
 				$attachmentHTML[$key]['filename'] = Api\Translation::convert_jsonsafe($attachmentHTML[$key]['filename'],'utf-8');
2361 2654
 				//error_log(array2string($value));
2362 2655
 				//error_log(strtoupper($value['mimeType']) .'<->'. Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']));
2363
-				if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) $value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']);
2656
+				if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM'))
2657
+				{
2658
+					$value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']);
2659
+				}
2364 2660
 				$attachmentHTML[$key]['type']=$value['mimeType'];
2365 2661
 				$attachmentHTML[$key]['mimetype'] = Api\MimeMagic::mime2label($value['mimeType']);
2366 2662
 				$hA = self::splitRowID($rowID);
@@ -2411,8 +2707,15 @@  discard block
 block discarded – undo
2411 2707
 						$sfxMimeType = $value['mimeType'];
2412 2708
 						$buff = explode('.',$value['name']);
2413 2709
 						$suffix = '';
2414
-						if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
2415
-						if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2710
+						if (is_array($buff))
2711
+						{
2712
+							$suffix = array_pop($buff);
2713
+						}
2714
+						// take the last extension to check with ext2mime
2715
+						if (!empty($suffix))
2716
+						{
2717
+							$sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2718
+						}
2416 2719
 						if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD')
2417 2720
 						{
2418 2721
 							$attachments[$key]['mimeType'] = $sfxMimeType;
@@ -2604,7 +2907,10 @@  discard block
 block discarded – undo
2604 2907
 		$uid	= $_GET['uid'];
2605 2908
 		$cid	= base64_decode($_GET['cid']);
2606 2909
 		$partID = urldecode($_GET['partID']);
2607
-		if (!empty($_GET['mailbox'])) $mailbox  = base64_decode($_GET['mailbox']);
2910
+		if (!empty($_GET['mailbox']))
2911
+		{
2912
+			$mailbox  = base64_decode($_GET['mailbox']);
2913
+		}
2608 2914
 
2609 2915
 		//error_log(__METHOD__.__LINE__.":$uid, $cid, $partID");
2610 2916
 		$this->mail_bo->reopen($mailbox);
@@ -2636,7 +2942,10 @@  discard block
 block discarded – undo
2636 2942
 
2637 2943
 	function getAttachment()
2638 2944
 	{
2639
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
2945
+		if(isset($_GET['id']))
2946
+		{
2947
+			$rowID	= $_GET['id'];
2948
+		}
2640 2949
 
2641 2950
 		$hA = self::splitRowID($rowID);
2642 2951
 		$uid = $hA['msgUID'];
@@ -2669,10 +2978,20 @@  discard block
 block discarded – undo
2669 2978
 				$sfxMimeType = $attachment['type'];
2670 2979
 				$buff = explode('.',$attachment['filename']);
2671 2980
 				$suffix = '';
2672
-				if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
2673
-				if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2981
+				if (is_array($buff))
2982
+				{
2983
+					$suffix = array_pop($buff);
2984
+				}
2985
+				// take the last extension to check with ext2mime
2986
+				if (!empty($suffix))
2987
+				{
2988
+					$sfxMimeType = Api\MimeMagic::ext2mime($suffix);
2989
+				}
2674 2990
 				$attachment['type'] = $sfxMimeType;
2675
-				if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') $attachment['type'] = strtoupper($sfxMimeType);
2991
+				if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD')
2992
+				{
2993
+					$attachment['type'] = strtoupper($sfxMimeType);
2994
+				}
2676 2995
 			}
2677 2996
 			//error_log(__METHOD__.print_r($attachment,true));
2678 2997
 			if (strtoupper($attachment['type']) == 'TEXT/CALENDAR' || strtoupper($attachment['type']) == 'TEXT/X-VCALENDAR')
@@ -2681,7 +3000,10 @@  discard block
 block discarded – undo
2681 3000
 				$calendar_ical = new calendar_ical();
2682 3001
 				$eventid = $calendar_ical->search($attachment['attachment'],-1);
2683 3002
 				//error_log(__METHOD__.array2string($eventid));
2684
-				if (!$eventid) $eventid = -1;
3003
+				if (!$eventid)
3004
+				{
3005
+					$eventid = -1;
3006
+				}
2685 3007
 				$event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true,0,'',null,$attachment['charset']);
2686 3008
 				//error_log(__METHOD__.$event);
2687 3009
 				if ((int)$event > 0)
@@ -2707,7 +3029,10 @@  discard block
 block discarded – undo
2707 3029
 					//error_log(__METHOD__.__LINE__.print_r($vcard,true));
2708 3030
 					$contact = $addressbook_vcal->find_contact($vcard,false);
2709 3031
 				}
2710
-				if (!$contact) $contact = null;
3032
+				if (!$contact)
3033
+				{
3034
+					$contact = null;
3035
+				}
2711 3036
 				// if there are not enough fields in the vcard (or the parser was unable to correctly parse the vcard (as of VERSION:3.0 created by MSO))
2712 3037
 				if ($contact || count($vcard)>2)
2713 3038
 				{
@@ -2741,9 +3066,18 @@  discard block
 block discarded – undo
2741 3066
 	function saveMessage()
2742 3067
 	{
2743 3068
 		$display = false;
2744
-		if(isset($_GET['id'])) $rowID	= $_GET['id'];
2745
-		if(isset($_GET['part'])) $partID = $_GET['part'];
2746
-		if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager')) $display	= $_GET['location'];
3069
+		if(isset($_GET['id']))
3070
+		{
3071
+			$rowID	= $_GET['id'];
3072
+		}
3073
+		if(isset($_GET['part']))
3074
+		{
3075
+			$partID = $_GET['part'];
3076
+		}
3077
+		if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager'))
3078
+		{
3079
+			$display	= $_GET['location'];
3080
+		}
2747 3081
 
2748 3082
 		$hA = self::splitRowID($rowID);
2749 3083
 		$uid = $hA['msgUID'];
@@ -2885,7 +3219,10 @@  discard block
 block discarded – undo
2885 3219
 			{
2886 3220
 				$res['success'] = true;
2887 3221
 			}
2888
-			if ($fp) fclose($fp);
3222
+			if ($fp)
3223
+			{
3224
+				fclose($fp);
3225
+			}
2889 3226
 			if ($res['success'])
2890 3227
 			{
2891 3228
 				unset($headers['SUBJECT']);//already in filename
@@ -2948,7 +3285,8 @@  discard block
 block discarded – undo
2948 3285
 		 *
2949 3286
 		 * @return array an array of parameters
2950 3287
 		 */
2951
-		$getParams = function ($id) {
3288
+		$getParams = function ($id)
3289
+		{
2952 3290
 			list($app,$user,$serverID,$mailbox,$uid,$part,$is_winmail,$name) = explode('::',$id,8);
2953 3291
 			$lId = implode('::',array($app,$user,$serverID,$mailbox,$uid));
2954 3292
 			$hA = mail_ui::splitRowID($lId);
@@ -2997,7 +3335,10 @@  discard block
 block discarded – undo
2997 3335
 					// Try to find the right content for file id
2998 3336
 					foreach ($attachments as $key => $val)
2999 3337
 					{
3000
-						if ($key == $params['is_winmail']) $attachment = $val;
3338
+						if ($key == $params['is_winmail'])
3339
+						{
3340
+							$attachment = $val;
3341
+						}
3001 3342
 					}
3002 3343
 				}
3003 3344
 				else
@@ -3053,7 +3394,10 @@  discard block
 block discarded – undo
3053 3394
 	{
3054 3395
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
3055 3396
 		// First, get all attachment IDs
3056
-		if(isset($_GET['id'])) $message_id	= $_GET['id'];
3397
+		if(isset($_GET['id']))
3398
+		{
3399
+			$message_id	= $_GET['id'];
3400
+		}
3057 3401
 		//error_log(__METHOD__.__LINE__.$message_id);
3058 3402
 		$rememberServerID = $this->mail_bo->profileID;
3059 3403
 		if(!is_numeric($message_id))
@@ -3080,7 +3424,10 @@  discard block
 block discarded – undo
3080 3424
 		//get_home_dir may fetch the users startfolder if set; if not writeable, action will fail. TODO: use temp_dir
3081 3425
 		$homedir = '/home/'.$GLOBALS['egw_info']['user']['account_lid'];
3082 3426
 		$temp_path = $homedir/*Vfs::get_home_dir()*/ . "/.mail_$message_id";
3083
-		if(Vfs::is_dir($temp_path)) Vfs::remove ($temp_path);
3427
+		if(Vfs::is_dir($temp_path))
3428
+		{
3429
+			Vfs::remove ($temp_path);
3430
+		}
3084 3431
 
3085 3432
 		// Add subject to path, so it gets used as the file name, replacing ':'
3086 3433
 		// as it seems to cause an error
@@ -3106,7 +3453,10 @@  discard block
 block discarded – undo
3106 3453
 				foreach ($tnefAttachments as $key => $val)
3107 3454
 				{
3108 3455
 					error_log(__METHOD__.' winmail = '.$key);
3109
-					if ($key == $file['is_winmail']) $attachment = $val;
3456
+					if ($key == $file['is_winmail'])
3457
+					{
3458
+						$attachment = $val;
3459
+					}
3110 3460
 				}
3111 3461
 			}
3112 3462
 			else
@@ -3114,7 +3464,10 @@  discard block
 block discarded – undo
3114 3464
 				$attachment = $this->mail_bo->getAttachment($message_id,$file['partID'],$file['is_winmail'],false,true);
3115 3465
 			}
3116 3466
 			$success=true;
3117
-			if (empty($file['filename'])) $file['filename'] = $file['name'];
3467
+			if (empty($file['filename']))
3468
+			{
3469
+				$file['filename'] = $file['name'];
3470
+			}
3118 3471
 			if(in_array($path.$file['filename'], $file_list))
3119 3472
 			{
3120 3473
 				$dupe_count[$path.$file['filename']]++;
@@ -3131,8 +3484,14 @@  discard block
 block discarded – undo
3131 3484
 				$success=false;
3132 3485
 				Framework::message("Unable to zip {$target_name}",'error');
3133 3486
 			}
3134
-			if ($success) $file_list[] = $path.$target_name;
3135
-			if ($fp) fclose($fp);
3487
+			if ($success)
3488
+			{
3489
+				$file_list[] = $path.$target_name;
3490
+			}
3491
+			if ($fp)
3492
+			{
3493
+				fclose($fp);
3494
+			}
3136 3495
 		}
3137 3496
 		$this->mail_bo->closeConnection();
3138 3497
 		if ($rememberServerID != $this->mail_bo->profileID)
@@ -3159,7 +3518,10 @@  discard block
 block discarded – undo
3159 3518
 		$this->uid = $uid;
3160 3519
 		$this->partID = $partID;
3161 3520
 		$bufferHtmlOptions = $this->mail_bo->htmlOptions;
3162
-		if (empty($htmlOptions)) $htmlOptions = $this->mail_bo->htmlOptions;
3521
+		if (empty($htmlOptions))
3522
+		{
3523
+			$htmlOptions = $this->mail_bo->htmlOptions;
3524
+		}
3163 3525
 		// fetching structure now, to supply it to getMessageBody and getMessageAttachment, so it does not get fetched twice
3164 3526
 		try
3165 3527
 		{
@@ -3178,7 +3540,10 @@  discard block
 block discarded – undo
3178 3540
 				$acc_smime = Mail\Smime::get_acc_smime($this->mail_bo->profileID);
3179 3541
 				$attachments = $this->mail_bo->getMessageAttachments($uid, $partID, $structure,true,false,true, $mailbox);
3180 3542
 				$push = new Api\Json\Push($GLOBALS['egw_info']['user']['account_id']);
3181
-				if (!empty($acc_smime) && !empty($smime['addtocontact'])) $push->call('app.mail.smime_certAddToContact', $smime);
3543
+				if (!empty($acc_smime) && !empty($smime['addtocontact']))
3544
+				{
3545
+					$push->call('app.mail.smime_certAddToContact', $smime);
3546
+				}
3182 3547
 				if (is_array($attachments))
3183 3548
 				{
3184 3549
 					$push->call('app.mail.set_smimeAttachments', $this->createAttachmentBlock($attachments, $_GET['_messageID'], $uid, $mailbox));
@@ -3269,10 +3634,16 @@  discard block
 block discarded – undo
3269 3634
 <table width="100%" style="table-layout:fixed"><tr><td class="td_display">';
3270 3635
 
3271 3636
 		$EndBody = '</td></tr></table></div>';
3272
-		if ($fullPageTags) $EndBody .= "</body></html>";
3273
-		if ($print)	{
3637
+		if ($fullPageTags)
3638
+		{
3639
+			$EndBody .= "</body></html>";
3640
+		}
3641
+		if ($print)
3642
+		{
3274 3643
 			print $BeginBody. $body .$EndBody;
3275
-		} else {
3644
+		}
3645
+		else
3646
+		{
3276 3647
 			return $BeginBody. $body .$EndBody;
3277 3648
 		}
3278 3649
 	}
@@ -3288,9 +3659,14 @@  discard block
 block discarded – undo
3288 3659
 		$body = '';
3289 3660
 
3290 3661
 		//error_log(__METHOD__.array2string($bodyParts)); //exit;
3291
-		if (empty($bodyParts)) return "";
3292
-		foreach((array)$bodyParts as $singleBodyPart) {
3293
-			if (!isset($singleBodyPart['body'])) {
3662
+		if (empty($bodyParts))
3663
+		{
3664
+			return "";
3665
+		}
3666
+		foreach((array)$bodyParts as $singleBodyPart)
3667
+		{
3668
+			if (!isset($singleBodyPart['body']))
3669
+			{
3294 3670
 				$singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart,$modifyURI,$useTidy);
3295 3671
 				$body .= $singleBodyPart['body'];
3296 3672
 				continue;
@@ -3301,7 +3677,8 @@  discard block
 block discarded – undo
3301 3677
 				$body .= '';
3302 3678
 				continue;
3303 3679
 			}
3304
-			if(!empty($body)) {
3680
+			if(!empty($body))
3681
+			{
3305 3682
 				$body .= '<hr style="border:dotted 1px silver;">';
3306 3683
 			}
3307 3684
 			//error_log($singleBodyPart['body']);
@@ -3345,16 +3722,25 @@  discard block
 block discarded – undo
3345 3722
 				$newBody	= @htmlentities($singleBodyPart['body'],ENT_QUOTES, strtoupper(Mail::$displayCharset));
3346 3723
 				//error_log(__METHOD__.__LINE__.'..'.$newBody);
3347 3724
 				// if empty and charset is utf8 try sanitizing the string in question
3348
-				if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(Mail::$displayCharset));
3725
+				if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8')
3726
+				{
3727
+					$newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(Mail::$displayCharset));
3728
+				}
3349 3729
 				// if the conversion to htmlentities fails somehow, try without specifying the charset, which defaults to iso-
3350
-				if (empty($newBody)) $newBody    = htmlentities($singleBodyPart['body'],ENT_QUOTES);
3730
+				if (empty($newBody))
3731
+				{
3732
+					$newBody    = htmlentities($singleBodyPart['body'],ENT_QUOTES);
3733
+				}
3351 3734
 
3352 3735
 				// search http[s] links and make them as links available again
3353 3736
 				// to understand what's going on here, have a look at
3354 3737
 				// http://www.php.net/manual/en/function.preg-replace.php
3355 3738
 
3356 3739
 				// create links for websites
3357
-				if ($modifyURI) $newBody = Api\Html::activate_links($newBody);
3740
+				if ($modifyURI)
3741
+				{
3742
+					$newBody = Api\Html::activate_links($newBody);
3743
+				}
3358 3744
 				//error_log(__METHOD__.__LINE__.'..'.$newBody);
3359 3745
 				// redirect links for websites if you use no cookies
3360 3746
 				#if (!($GLOBALS['egw_info']['server']['usecookies']))
@@ -3396,10 +3782,13 @@  discard block
 block discarded – undo
3396 3782
 					{
3397 3783
 						$newBody = $cleaned;
3398 3784
 					}
3399
-					if (!$preserveHTML)	// ToDo KL: $preserveHTML is NOT initialised, so always if is dead code
3785
+					if (!$preserveHTML)
3786
+					{
3787
+						// ToDo KL: $preserveHTML is NOT initialised, so always if is dead code
3400 3788
 					{
3401 3789
 						// filter only the 'body', as we only want that part, if we throw away the Api\Html
3402 3790
 						preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array());
3791
+					}
3403 3792
 						if ($matches[2])
3404 3793
 						{
3405 3794
 							$hasOther = true;
@@ -3421,7 +3810,10 @@  discard block
 block discarded – undo
3421 3810
 					// as we switched off HTMLaweds tidy functionality
3422 3811
 					$newBody = str_replace(array('&amp;amp;','<DIV><BR></DIV>',"<DIV>&nbsp;</DIV>",'<div>&nbsp;</div>'),array('&amp;','<BR>','<BR>','<BR>'),$newBody);
3423 3812
 					$newBody = $htmLawed->run($newBody,Mail::$htmLawed_config);
3424
-					if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3];
3813
+					if ($hasOther && $preserveHTML)
3814
+					{
3815
+						$newBody = $matches[1]. $newBody. $matches[3];
3816
+					}
3425 3817
 					$alreadyHtmlLawed=true;
3426 3818
 				}
3427 3819
 				// do the cleanup, set for the use of purifier
@@ -3546,7 +3938,10 @@  discard block
 block discarded – undo
3546 3938
 		*/
3547 3939
 		$replace_callback = function ($matches) use ($_mailbox,$_uid, $_partID,  $_type, $_link_callback)
3548 3940
 		{
3549
-			if (!$_type)	return false;
3941
+			if (!$_type)
3942
+			{
3943
+				return false;
3944
+			}
3550 3945
 			$CID = '';
3551 3946
 			// Build up matches according to selected type
3552 3947
 			switch ($_type)
@@ -3582,9 +3977,12 @@  discard block
 block discarded – undo
3582 3977
 							$attachment = $bo->getAttachmentByCID($_uid, $CID, $_partID);
3583 3978
 
3584 3979
 							// only use data uri for "smaller" images, as otherwise the first display of the mail takes to long
3585
-							if (($attachment instanceof Horde_Mime_Part) && $attachment->getBytes() < 8192)	// msie=8 allows max 32k data uris
3980
+							if (($attachment instanceof Horde_Mime_Part) && $attachment->getBytes() < 8192)
3981
+							{
3982
+								// msie=8 allows max 32k data uris
3586 3983
 							{
3587 3984
 								$bo->fetchPartContents($_uid, $attachment);
3985
+							}
3588 3986
 								$cache[$imageURL] = 'data:'.$attachment->getType().';base64,'.base64_encode($attachment->getContents());
3589 3987
 							}
3590 3988
 							else
@@ -3656,7 +4054,10 @@  discard block
 block discarded – undo
3656 4054
 			}
3657 4055
 			$destination = $content['FOLDER'][0];
3658 4056
 
3659
-			if (stripos($destination,self::$delimiter)!==false) list($icServerID,$destination) = explode(self::$delimiter,$destination,2);
4057
+			if (stripos($destination,self::$delimiter)!==false)
4058
+			{
4059
+				list($icServerID,$destination) = explode(self::$delimiter,$destination,2);
4060
+			}
3660 4061
 			if ($icServerID && $icServerID != $this->mail_bo->profileID)
3661 4062
 			{
3662 4063
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -3685,8 +4086,14 @@  discard block
 block discarded – undo
3685 4086
 				return;
3686 4087
 			}
3687 4088
 		}
3688
-		if (!is_array($content)) $content = array();
3689
-		if (empty($content['FOLDER'])) $content['FOLDER']=(array)$this->mail_bo->getDraftFolder();
4089
+		if (!is_array($content))
4090
+		{
4091
+			$content = array();
4092
+		}
4093
+		if (empty($content['FOLDER']))
4094
+		{
4095
+			$content['FOLDER']=(array)$this->mail_bo->getDraftFolder();
4096
+		}
3690 4097
 		if (!empty($content['FOLDER']))
3691 4098
 		{
3692 4099
 			$compose = new mail_compose();
@@ -3711,7 +4118,10 @@  discard block
 block discarded – undo
3711 4118
 	{
3712 4119
 		$importfailed = false;
3713 4120
 		//error_log(__METHOD__.__LINE__.array2string($_formData));
3714
-		if (empty($_formData['file'])) $_formData['file'] = $_formData['tmp_name'];
4121
+		if (empty($_formData['file']))
4122
+		{
4123
+			$_formData['file'] = $_formData['tmp_name'];
4124
+		}
3715 4125
 		// check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.)
3716 4126
 		try
3717 4127
 		{
@@ -3742,10 +4152,14 @@  discard block
 block discarded – undo
3742 4152
 				$alert_msg .= lang("Import of message %1 failed. Destination Folder not set.",$_formData['name']);
3743 4153
 			}
3744 4154
 			$delimiter = $this->mail_bo->getHierarchyDelimiter();
3745
-			if($_folder=='INBOX'.$delimiter) $_folder='INBOX';
4155
+			if($_folder=='INBOX'.$delimiter)
4156
+			{
4157
+				$_folder='INBOX';
4158
+			}
3746 4159
 			if ($importfailed === false)
3747 4160
 			{
3748
-				if ($this->mail_bo->folderExists($_folder,true)) {
4161
+				if ($this->mail_bo->folderExists($_folder,true))
4162
+				{
3749 4163
 					try
3750 4164
 					{
3751 4165
 						$messageUid = $this->mail_bo->appendMessage($_folder,
@@ -3806,7 +4220,10 @@  discard block
 block discarded – undo
3806 4220
 	 */
3807 4221
 	function importMessageFromVFS2DraftAndDisplay($formData='',$mode='display')
3808 4222
 	{
3809
-		if (empty($formData)) if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData'];
4223
+		if (empty($formData))
4224
+		{
4225
+			if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData'];
4226
+		}
3810 4227
 		//error_log(__METHOD__.__LINE__.':'.array2string($formData).' Mode:'.$mode.'->'.function_backtrace());
3811 4228
 		$draftFolder = $this->mail_bo->getDraftFolder(false);
3812 4229
 		$importID = Mail::getRandomString();
@@ -3820,15 +4237,26 @@  discard block
 block discarded – undo
3820 4237
 		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['name']))
3821 4238
 		{
3822 4239
 			$buff = explode('/',$formData['file']);
3823
-			if (is_array($buff)) $formData['name'] = array_pop($buff); // take the last part as name
4240
+			if (is_array($buff))
4241
+			{
4242
+				$formData['name'] = array_pop($buff);
4243
+			}
4244
+			// take the last part as name
3824 4245
 		}
3825 4246
 		// type should be set to meet the requirements of checkFileBasics
3826 4247
 		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['type']))
3827 4248
 		{
3828 4249
 			$buff = explode('.',$formData['file']);
3829 4250
 			$suffix = '';
3830
-			if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime
3831
-			if (!empty($suffix)) $formData['type'] = Api\MimeMagic::ext2mime($suffix);
4251
+			if (is_array($buff))
4252
+			{
4253
+				$suffix = array_pop($buff);
4254
+			}
4255
+			// take the last extension to check with ext2mime
4256
+			if (!empty($suffix))
4257
+			{
4258
+				$formData['type'] = Api\MimeMagic::ext2mime($suffix);
4259
+			}
3832 4260
 		}
3833 4261
 		// size should be set to meet the requirements of checkFileBasics
3834 4262
 		if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && !isset($formData['size']))
@@ -3871,17 +4299,35 @@  discard block
 block discarded – undo
3871 4299
 	function loadEmailBody($_messageID=null,$_partID=null,$_htmloptions=null)
3872 4300
 	{
3873 4301
 		//error_log(__METHOD__.__LINE__.array2string($_GET));
3874
-		if (!$_messageID && !empty($_GET['_messageID'])) $_messageID = $_GET['_messageID'];
3875
-		if (!$_partID && !empty($_GET['_partID'])) $_partID = $_GET['_partID'];
3876
-		if (!$_htmloptions && !empty($_GET['_htmloptions'])) $_htmloptions = $_GET['_htmloptions'];
3877
-		if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions");
3878
-		if (empty($_messageID)) return "";
4302
+		if (!$_messageID && !empty($_GET['_messageID']))
4303
+		{
4304
+			$_messageID = $_GET['_messageID'];
4305
+		}
4306
+		if (!$_partID && !empty($_GET['_partID']))
4307
+		{
4308
+			$_partID = $_GET['_partID'];
4309
+		}
4310
+		if (!$_htmloptions && !empty($_GET['_htmloptions']))
4311
+		{
4312
+			$_htmloptions = $_GET['_htmloptions'];
4313
+		}
4314
+		if(Mail::$debug)
4315
+		{
4316
+			error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions");
4317
+		}
4318
+		if (empty($_messageID))
4319
+		{
4320
+			return "";
4321
+		}
3879 4322
 		$uidA = self::splitRowID($_messageID);
3880 4323
 		$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
3881 4324
 		$messageID = $uidA['msgUID'];
3882 4325
 		$icServerID = $uidA['profileID'];
3883 4326
 		//something went wrong. there is a $_messageID but no $messageID: means $_messageID is crippeled
3884
-		if (empty($messageID)) return "";
4327
+		if (empty($messageID))
4328
+		{
4329
+			return "";
4330
+		}
3885 4331
 		if ($icServerID && $icServerID != $this->mail_bo->profileID)
3886 4332
 		{
3887 4333
 			//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
@@ -3913,7 +4359,11 @@  discard block
 block discarded – undo
3913 4359
 				list($profileID,$folderName) = explode(self::$delimiter,$_folderName,2);
3914 4360
 				if (is_numeric($profileID))
3915 4361
 				{
3916
-					if ($profileID != $this->mail_bo->profileID) continue; // only current connection
4362
+					if ($profileID != $this->mail_bo->profileID)
4363
+					{
4364
+						continue;
4365
+					}
4366
+					// only current connection
3917 4367
 					if ($folderName)
3918 4368
 					{
3919 4369
 						try
@@ -3922,10 +4372,16 @@  discard block
 block discarded – undo
3922 4372
 						}
3923 4373
 						catch (Exception $e)
3924 4374
 						{
3925
-							if (Mail::$debug) error_log(__METHOD__,' ()'.$e->getMessage ());
4375
+							if (Mail::$debug)
4376
+							{
4377
+								error_log(__METHOD__,' ()'.$e->getMessage ());
4378
+							}
3926 4379
 							continue;
3927 4380
 						}
3928
-						if (in_array($fS['shortDisplayName'],Mail::$autoFolders)) $fS['shortDisplayName']=lang($fS['shortDisplayName']);
4381
+						if (in_array($fS['shortDisplayName'],Mail::$autoFolders))
4382
+						{
4383
+							$fS['shortDisplayName']=lang($fS['shortDisplayName']);
4384
+						}
3929 4385
 						//error_log(__METHOD__.__LINE__.array2string($fS));
3930 4386
 						if ($fS['unseen'])
3931 4387
 						{
@@ -3974,11 +4430,17 @@  discard block
 block discarded – undo
3974 4430
 
3975 4431
 			if (is_numeric($profileID))
3976 4432
 			{
3977
-				if ($profileID != $this->mail_bo->profileID) $this->changeProfile ($profileID);
4433
+				if ($profileID != $this->mail_bo->profileID)
4434
+				{
4435
+					$this->changeProfile ($profileID);
4436
+				}
3978 4437
 				$delimiter = $this->mail_bo->getHierarchyDelimiter(false);
3979 4438
 				$parts = explode($delimiter,$new);
3980 4439
 
3981
-				if (!!empty($parent)) $folderStatus = $this->mail_bo->getFolderStatus($parent,false);
4440
+				if (!!empty($parent))
4441
+				{
4442
+					$folderStatus = $this->mail_bo->getFolderStatus($parent,false);
4443
+				}
3982 4444
 
3983 4445
 				//open the INBOX
3984 4446
 				$this->mail_bo->reopen('INBOX');
@@ -4015,7 +4477,10 @@  discard block
 block discarded – undo
4015 4477
 							if (!$p_no_delimiter)
4016 4478
 							{
4017 4479
 								$new = $this->mail_bo->createFolder('INBOX', $subTree, $err);
4018
-								if ($new) $counter++;
4480
+								if ($new)
4481
+								{
4482
+									$counter++;
4483
+								}
4019 4484
 							}
4020 4485
 							else
4021 4486
 							{
@@ -4023,9 +4488,15 @@  discard block
 block discarded – undo
4023 4488
 							}
4024 4489
 						}
4025 4490
 					}
4026
-					if ($counter == count($parts)) $created=true;
4491
+					if ($counter == count($parts))
4492
+					{
4493
+						$created=true;
4494
+					}
4495
+				}
4496
+				if (!empty($new))
4497
+				{
4498
+					$this->mail_bo->reopen($new);
4027 4499
 				}
4028
-				if (!empty($new)) $this->mail_bo->reopen($new);
4029 4500
 			}
4030 4501
 
4031 4502
 
@@ -4050,7 +4521,8 @@  discard block
 block discarded – undo
4050 4521
 				}
4051 4522
 			}
4052 4523
 		}
4053
-		else {
4524
+		else
4525
+		{
4054 4526
 			error_log(__METHOD__.__LINE__."()"."This function needs a parent folder to work!");
4055 4527
 		}
4056 4528
 	}
@@ -4063,7 +4535,10 @@  discard block
 block discarded – undo
4063 4535
 	 */
4064 4536
 	function ajax_renameFolder($_folderName, $_newName)
4065 4537
 	{
4066
-		if (Mail::$debug) error_log(__METHOD__.__LINE__.' OldFolderName:'.array2string($_folderName).' NewName:'.array2string($_newName));
4538
+		if (Mail::$debug)
4539
+		{
4540
+			error_log(__METHOD__.__LINE__.' OldFolderName:'.array2string($_folderName).' NewName:'.array2string($_newName));
4541
+		}
4067 4542
 		//error_log(__METHOD__.__LINE__.array2string($oA));
4068 4543
 		$response = Api\Json\Response::get();
4069 4544
 		$del = $this->mail_bo->getHierarchyDelimiter(false);
@@ -4083,7 +4558,10 @@  discard block
 block discarded – undo
4083 4558
 			$hasChildren = false;
4084 4559
 			if (is_numeric($profileID))
4085 4560
 			{
4086
-				if ($profileID != $this->mail_bo->profileID) $this->changeProfile ($profileID);
4561
+				if ($profileID != $this->mail_bo->profileID)
4562
+				{
4563
+					$this->changeProfile ($profileID);
4564
+				}
4087 4565
 				$pA = explode($del,$folderName);
4088 4566
 				array_pop($pA);
4089 4567
 				$parentFolder = implode($del,$pA);
@@ -4216,11 +4694,17 @@  discard block
 block discarded – undo
4216 4694
 		$oldPrefForSubscribedOnly = !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'];
4217 4695
 		$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4218 4696
 		list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
4219
-		if ($profileID != $this->mail_bo->profileID) $this->changeProfile($profileID);
4697
+		if ($profileID != $this->mail_bo->profileID)
4698
+		{
4699
+			$this->changeProfile($profileID);
4700
+		}
4220 4701
 
4221 4702
 		// if pref and required mode dont match -> reset the folderObject cache to ensure
4222 4703
 		// that we get what we request
4223
-		if ($_subscribedOnly != $oldPrefForSubscribedOnly) $this->mail_bo->resetFolderObjectCache($profileID);
4704
+		if ($_subscribedOnly != $oldPrefForSubscribedOnly)
4705
+		{
4706
+			$this->mail_bo->resetFolderObjectCache($profileID);
4707
+		}
4224 4708
 
4225 4709
 		if (!empty($folderName))
4226 4710
 		{
@@ -4296,14 +4780,20 @@  discard block
 block discarded – undo
4296 4780
 	 */
4297 4781
 	function ajax_MoveFolder($_folderName, $_target)
4298 4782
 	{
4299
-		if (Mail::$debug) error_log(__METHOD__.__LINE__."Move Folder: $_folderName to Target: $_target");
4783
+		if (Mail::$debug)
4784
+		{
4785
+			error_log(__METHOD__.__LINE__."Move Folder: $_folderName to Target: $_target");
4786
+		}
4300 4787
 		if ($_folderName)
4301 4788
 		{
4302 4789
 			$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4303 4790
 			$_newLocation2 = $this->mail_bo->decodeEntityFolderName($_target);
4304 4791
 			list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
4305 4792
 			list($newProfileID,$_newLocation) = explode(self::$delimiter,$_newLocation2,2);
4306
-			if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID) $this->changeProfile($profileID);
4793
+			if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID)
4794
+			{
4795
+				$this->changeProfile($profileID);
4796
+			}
4307 4797
 			$del = $this->mail_bo->getHierarchyDelimiter(false);
4308 4798
 			$hasChildren = false;
4309 4799
 			if (is_numeric($profileID))
@@ -4318,10 +4808,13 @@  discard block
 block discarded – undo
4318 4808
 					(($oldParentFolder === $parentFolder) || //$oldParentFolder == $parentFolder means move on same level
4319 4809
 					(($oldParentFolder != $parentFolder &&
4320 4810
 					strlen($parentFolder)>0 && strlen($folderName)>0 &&
4321
-					strpos($parentFolder,$folderName)===false)))) // indicates that we move the older up the tree within its own branch
4811
+					strpos($parentFolder,$folderName)===false))))
4812
+				{
4813
+					// indicates that we move the older up the tree within its own branch
4322 4814
 				{
4323 4815
 					//error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName");
4324 4816
 					$oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false);
4817
+				}
4325 4818
 					//error_log(__METHOD__.__LINE__.array2string($oldFolderInfo));
4326 4819
 					if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false)
4327 4820
 					{
@@ -4404,8 +4897,14 @@  discard block
 block discarded – undo
4404 4897
 					$profileID.self::$delimiter.$oldParentFolder=>$oldFolderInfo['shortDisplayName'],
4405 4898
 					$profileID.self::$delimiter.$parentFolder=>$folderInfo['shortDisplayName']);
4406 4899
 				// if we move the folder within the same parent-branch of the tree, there is no need no refresh the upper part
4407
-				if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]);
4408
-				if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]);
4900
+				if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false)
4901
+				{
4902
+					unset($refreshData[$profileID.self::$delimiter.$parentFolder]);
4903
+				}
4904
+				if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false)
4905
+				{
4906
+					unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]);
4907
+				}
4409 4908
 
4410 4909
 				// Send full info back in the response
4411 4910
 				foreach($refreshData as $folder => &$name)
@@ -4437,7 +4936,10 @@  discard block
 block discarded – undo
4437 4936
 			$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4438 4937
 			$oA = array();
4439 4938
 			list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
4440
-			if (is_numeric($profileID) && $profileID != $this->mail_bo->profileID) $this->changeProfile ($profileID);
4939
+			if (is_numeric($profileID) && $profileID != $this->mail_bo->profileID)
4940
+			{
4941
+				$this->changeProfile ($profileID);
4942
+			}
4441 4943
 			$del = $this->mail_bo->getHierarchyDelimiter(false);
4442 4944
 			$hasChildren = false;
4443 4945
 			if (is_numeric($profileID))
@@ -4467,7 +4969,9 @@  discard block
 block discarded – undo
4467 4969
 						}
4468 4970
 						krsort($ftD,SORT_NUMERIC);//sort per level
4469 4971
 						//we iterate per level of depth of the subtree, deepest nesting is to be deleted first, and then up the tree
4470
-						foreach($ftD as $k => $lc)//collection per level
4972
+						foreach($ftD as $k => $lc)
4973
+						{
4974
+							//collection per level
4471 4975
 						{
4472 4976
 							foreach($lc as $f)//folders contained in that level
4473 4977
 							{
@@ -4475,8 +4979,12 @@  discard block
 block discarded – undo
4475 4979
 								{
4476 4980
 									//error_log(__METHOD__.__LINE__.array2string($f).'<->'.$folderName);
4477 4981
 									$this->mail_bo->deleteFolder($f);
4982
+						}
4478 4983
 									$success = true;
4479
-									if ($f==$folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName'];
4984
+									if ($f==$folderName)
4985
+									{
4986
+										$oA[$_folderName] = $oldFolderInfo['shortDisplayName'];
4987
+									}
4480 4988
 								}
4481 4989
 								catch (Exception $e)
4482 4990
 								{
@@ -4506,7 +5014,10 @@  discard block
 block discarded – undo
4506 5014
 					$msg = lang("refused to delete folder INBOX");
4507 5015
 				}
4508 5016
 			}
4509
-			if ($_return) return $success;
5017
+			if ($_return)
5018
+			{
5019
+				return $success;
5020
+			}
4510 5021
 			$response = Api\Json\Response::get();
4511 5022
 			if ($success)
4512 5023
 			{
@@ -4582,24 +5093,35 @@  discard block
 block discarded – undo
4582 5093
 				// Create mail app object
4583 5094
 				$mail = new mail_ui();
4584 5095
 
4585
-				if (empty($icServerID)) $icServerID = $mail->Mail->profileID;
4586
-				if ($icServerID != $mail->Mail->profileID) return;
5096
+				if (empty($icServerID))
5097
+				{
5098
+					$icServerID = $mail->Mail->profileID;
5099
+				}
5100
+				if ($icServerID != $mail->Mail->profileID)
5101
+				{
5102
+					return;
5103
+				}
4587 5104
 
4588 5105
 				$vacation = $mail->gatherVacation($cachedVacations);
4589
-			} catch (Exception $e) {
5106
+			}
5107
+			catch (Exception $e) {
4590 5108
 				$vacation=false;
4591 5109
 				error_log(__METHOD__.__LINE__." ".$e->getMessage());
4592 5110
 				unset($e);
4593 5111
 			}
4594 5112
 		}
4595 5113
 
4596
-		if($vacation) {
5114
+		if($vacation)
5115
+		{
4597 5116
 			if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date'))
4598 5117
 			{
4599 5118
 				$dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
4600 5119
 				$refreshData['vacationnotice'] = lang('Vacation notice is active');
4601 5120
 				$refreshData['vacationrange'] = ($vacation['status']=='by_date'? Api\DateTime::server2user($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.Api\DateTime::server2user($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):'');
4602
-				if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time())$refreshData = '';
5121
+				if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time())
5122
+				{
5123
+					$refreshData = '';
5124
+				}
4603 5125
 			}
4604 5126
 		}
4605 5127
 		if ($vacation==false)
@@ -4621,11 +5143,17 @@  discard block
 block discarded – undo
4621 5143
 	function ajax_refreshFilters($icServerID=null)
4622 5144
 	{
4623 5145
 		//error_log(__METHOD__.__LINE__.array2string($icServerId));
4624
-		if (empty($icServerID)) $icServerID = $this->mail_bo->profileID;
5146
+		if (empty($icServerID))
5147
+		{
5148
+			$icServerID = $this->mail_bo->profileID;
5149
+		}
4625 5150
 		if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4626 5151
 		{
4627 5152
 			Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4628
-			if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5153
+			if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
5154
+			{
5155
+				Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5156
+			}
4629 5157
 		}
4630 5158
 		if (!Mail::$supportsORinQuery[$this->mail_bo->profileID])
4631 5159
 		{
@@ -4647,7 +5175,10 @@  discard block
 block discarded – undo
4647 5175
 			$keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5');
4648 5176
 			foreach($keywords as &$k)
4649 5177
 			{
4650
-				if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]);
5178
+				if (array_key_exists($k,$this->statusTypes))
5179
+				{
5180
+					unset($this->statusTypes[$k]);
5181
+				}
4651 5182
 			}
4652 5183
 		}
4653 5184
 
@@ -4669,7 +5200,10 @@  discard block
 block discarded – undo
4669 5200
 	function ajax_refreshQuotaDisplay($icServerID=null)
4670 5201
 	{
4671 5202
 		Api\Translation::add_app('mail');
4672
-		if (is_null($icServerID)) $icServerID = $this->mail_bo->profileID;
5203
+		if (is_null($icServerID))
5204
+		{
5205
+			$icServerID = $this->mail_bo->profileID;
5206
+		}
4673 5207
 		$rememberServerID = $this->mail_bo->profileID;
4674 5208
 		try
4675 5209
 		{
@@ -4678,13 +5212,15 @@  discard block
 block discarded – undo
4678 5212
 				$this->changeProfile($icServerID);
4679 5213
 			}
4680 5214
 			$quota = $this->mail_bo->getQuotaRoot();
4681
-		} catch (Exception $e) {
5215
+		}
5216
+		catch (Exception $e) {
4682 5217
 			$quota['limit'] = 'NOT SET';
4683 5218
 			error_log(__METHOD__.__LINE__." ".$e->getMessage());
4684 5219
 			unset($e);
4685 5220
 		}
4686 5221
 
4687
-		if($quota !== false && $quota['limit'] != 'NOT SET') {
5222
+		if($quota !== false && $quota['limit'] != 'NOT SET')
5223
+		{
4688 5224
 			$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
4689 5225
 			$quotaMin = ceil($quotainfo['freespace']/pow(1024, 2));
4690 5226
 			$quota_limit_warning = isset(mail::$mailConfig['quota_limit_warning']) ? mail::$mailConfig['quota_limit_warning'] : 30;
@@ -4711,7 +5247,8 @@  discard block
 block discarded – undo
4711 5247
 			try
4712 5248
 			{
4713 5249
 				$this->changeProfile($rememberServerID);
4714
-			} catch (Exception $e) {
5250
+			}
5251
+			catch (Exception $e) {
4715 5252
 				unset($e);
4716 5253
 			}
4717 5254
 		}
@@ -4738,7 +5275,8 @@  discard block
 block discarded – undo
4738 5275
 			$this->changeProfile($icServerID);
4739 5276
 		}
4740 5277
 		$junkFolder = $this->mail_bo->getJunkFolder();
4741
-		if(!empty($junkFolder)) {
5278
+		if(!empty($junkFolder))
5279
+		{
4742 5280
 			if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder)
4743 5281
 			{
4744 5282
 				// Lock the tree if the active folder is junk folder
@@ -4788,7 +5326,8 @@  discard block
 block discarded – undo
4788 5326
 			$this->changeProfile($icServerID);
4789 5327
 		}
4790 5328
 		$trashFolder = $this->mail_bo->getTrashFolder();
4791
-		if(!empty($trashFolder)) {
5329
+		if(!empty($trashFolder))
5330
+		{
4792 5331
 			if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder)
4793 5332
 			{
4794 5333
 				// Lock the tree if the active folder is Trash folder
@@ -4834,7 +5373,10 @@  discard block
 block discarded – undo
4834 5373
 		$decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName);
4835 5374
 		list($icServerID,$folderName) = explode(self::$delimiter,$decodedFolderName,2);
4836 5375
 
4837
-		if (empty($folderName)) $folderName = $this->mail_bo->sessionData['mailbox'];
5376
+		if (empty($folderName))
5377
+		{
5378
+			$folderName = $this->mail_bo->sessionData['mailbox'];
5379
+		}
4838 5380
 		if ($this->mail_bo->folderExists($folderName))
4839 5381
 		{
4840 5382
 			$rememberServerID = $this->mail_bo->profileID;
@@ -4843,7 +5385,8 @@  discard block
 block discarded – undo
4843 5385
 				//error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID);
4844 5386
 				$this->changeProfile($icServerID);
4845 5387
 			}
4846
-			if(!empty($_folderName)) {
5388
+			if(!empty($_folderName))
5389
+			{
4847 5390
 				$this->mail_bo->compressFolder($folderName);
4848 5391
 			}
4849 5392
 			if ($rememberServerID != $this->mail_bo->profileID)
@@ -4865,7 +5408,10 @@  discard block
 block discarded – undo
4865 5408
 	 */
4866 5409
 	function ajax_sendMDN($_messageList)
4867 5410
 	{
4868
-		if(Mail::$debug) error_log(__METHOD__."->".array2string($_messageList));
5411
+		if(Mail::$debug)
5412
+		{
5413
+			error_log(__METHOD__."->".array2string($_messageList));
5414
+		}
4869 5415
 		$uidA = self::splitRowID($_messageList['msg'][0]);
4870 5416
 		$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
4871 5417
 		$this->mail_bo->sendMDN($uidA['msgUID'],$folder);
@@ -4882,7 +5428,10 @@  discard block
 block discarded – undo
4882 5428
 	 */
4883 5429
 	function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse=true)
4884 5430
 	{
4885
-		if(Mail::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList));
5431
+		if(Mail::$debug)
5432
+		{
5433
+			error_log(__METHOD__."->".$_flag.':'.array2string($_messageList));
5434
+		}
4886 5435
 		Api\Translation::add_app('mail');
4887 5436
 		$alreadyFlagged=false;
4888 5437
 		$flag2check='';
@@ -4903,12 +5452,23 @@  discard block
 block discarded – undo
4903 5452
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
4904 5453
 						{
4905 5454
 							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
4906
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5455
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
5456
+							{
5457
+								Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5458
+							}
4907 5459
 						}
4908 5460
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']);
4909 5461
 						$cutoffdate = $cutoffdate2 = null;
4910
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
4911
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
5462
+						if ($query['startdate'])
5463
+						{
5464
+							$cutoffdate = Api\DateTime::to($query['startdate'],'ts');
5465
+						}
5466
+						//SINCE, enddate
5467
+						if ($query['enddate'])
5468
+						{
5469
+							$cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');
5470
+						}
5471
+						//BEFORE, startdate
4912 5472
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
4913 5473
 						$filter = array(
4914 5474
 							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
@@ -4917,15 +5477,24 @@  discard block
 block discarded – undo
4917 5477
 							'status' => 'any',//this is a status change. status will be manipulated later on
4918 5478
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
4919 5479
 						);
4920
-						if ($query['enddate']||$query['startdate']) {
5480
+						if ($query['enddate']||$query['startdate'])
5481
+						{
4921 5482
 							$filter['range'] = "BETWEEN";
4922
-							if ($cutoffdate) {
5483
+							if ($cutoffdate)
5484
+							{
4923 5485
 								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
4924
-								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
5486
+								if (empty($cutoffdate2))
5487
+								{
5488
+									$filter['range'] = "SINCE";
5489
+								}
4925 5490
 							}
4926
-							if ($cutoffdate2) {
5491
+							if ($cutoffdate2)
5492
+							{
4927 5493
 								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
4928
-								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
5494
+								if (empty($cutoffdate))
5495
+								{
5496
+									$filter['range'] = "BEFORE";
5497
+								}
4929 5498
 							}
4930 5499
 						}
4931 5500
 						$filter2toggle = $filter;
@@ -4972,13 +5541,19 @@  discard block
 block discarded – undo
4972 5541
 						if (count($messageListForToggle)>0)
4973 5542
 						{
4974 5543
 							$flag2set = (strtolower($_flag));
4975
-							if(Mail::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle));
5544
+							if(Mail::$debug)
5545
+							{
5546
+								error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle));
5547
+							}
4976 5548
 							$this->mail_bo->flagMessages($flag2set, $messageListForToggle,$folder);
4977 5549
 						}
4978 5550
 						if (count($messageList)>0)
4979 5551
 						{
4980 5552
 							$flag2set = 'un'.$_flag;
4981
-							if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList));
5553
+							if(Mail::$debug)
5554
+							{
5555
+								error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList));
5556
+							}
4982 5557
 							$this->mail_bo->flagMessages($flag2set, $messageList,$folder);
4983 5558
 						}
4984 5559
 						$alreadyFlagged=true;
@@ -4994,7 +5569,10 @@  discard block
 block discarded – undo
4994 5569
 							// since we toggle and we toggle by the filtered flag we must must change _flag
4995 5570
 							$_flag = ($query['filter']=='unseen' && $_flag=='read' ? 'read' : ($query['filter']=='seen'&& $_flag=='read'?'unread':($_flag==$query['filter']?'un'.$_flag:$_flag)));
4996 5571
 						}
4997
-						if(Mail::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter));
5572
+						if(Mail::$debug)
5573
+						{
5574
+							error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter));
5575
+						}
4998 5576
 						$rByUid = true;
4999 5577
 						$reverse = 1;
5000 5578
 						$_sR = $this->mail_bo->getSortedList(
@@ -5011,7 +5589,10 @@  discard block
 block discarded – undo
5011 5589
 					}
5012 5590
 					else
5013 5591
 					{
5014
-						if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter));
5592
+						if(Mail::$debug)
5593
+						{
5594
+							error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter));
5595
+						}
5015 5596
 						$alreadyFlagged=true;
5016 5597
 						$uidA = self::splitRowID($_messageList['msg'][0]);
5017 5598
 						$folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder
@@ -5031,13 +5612,19 @@  discard block
 block discarded – undo
5031 5612
 					$hA = self::splitRowID($rowID);
5032 5613
 					$messageList[] = $hA['msgUID'];
5033 5614
 				}
5034
-				if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList)));
5615
+				if(Mail::$debug)
5616
+				{
5617
+					error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList)));
5618
+				}
5035 5619
 				$this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList),$folder);
5036 5620
 			}
5037 5621
 		}
5038 5622
 		else
5039 5623
 		{
5040
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5624
+			if(Mail::$debug)
5625
+			{
5626
+				error_log(__METHOD__."-> No messages selected.");
5627
+			}
5041 5628
 		}
5042 5629
 
5043 5630
 		if ($_sendJsonResponse)
@@ -5074,7 +5661,10 @@  discard block
 block discarded – undo
5074 5661
 	 */
5075 5662
 	function ajax_deleteMessages($_messageList,$_forceDeleteMethod=null)
5076 5663
 	{
5077
-		if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod);
5664
+		if(Mail::$debug)
5665
+		{
5666
+			error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod);
5667
+		}
5078 5668
 		$error = null;
5079 5669
 		$filtered =  false;
5080 5670
 		if ($_messageList=='all' || !empty($_messageList['msg']))
@@ -5093,12 +5683,23 @@  discard block
 block discarded – undo
5093 5683
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
5094 5684
 						{
5095 5685
 							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
5096
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5686
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
5687
+							{
5688
+								Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5689
+							}
5097 5690
 						}
5098 5691
 						$filtered =  true;
5099 5692
 						$cutoffdate = $cutoffdate2 = null;
5100
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
5101
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
5693
+						if ($query['startdate'])
5694
+						{
5695
+							$cutoffdate = Api\DateTime::to($query['startdate'],'ts');
5696
+						}
5697
+						//SINCE, enddate
5698
+						if ($query['enddate'])
5699
+						{
5700
+							$cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');
5701
+						}
5702
+						//BEFORE, startdate
5102 5703
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
5103 5704
 						$filter = array(
5104 5705
 							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
@@ -5107,15 +5708,24 @@  discard block
 block discarded – undo
5107 5708
 							'status' => (!empty($query['filter'])?$query['filter']:'any'),
5108 5709
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
5109 5710
 						);
5110
-						if ($query['enddate']||$query['startdate']) {
5711
+						if ($query['enddate']||$query['startdate'])
5712
+						{
5111 5713
 							$filter['range'] = "BETWEEN";
5112
-							if ($cutoffdate) {
5714
+							if ($cutoffdate)
5715
+							{
5113 5716
 								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
5114
-								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
5717
+								if (empty($cutoffdate2))
5718
+								{
5719
+									$filter['range'] = "SINCE";
5720
+								}
5115 5721
 							}
5116
-							if ($cutoffdate2) {
5722
+							if ($cutoffdate2)
5723
+							{
5117 5724
 								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
5118
-								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
5725
+								if (empty($cutoffdate))
5726
+								{
5727
+									$filter['range'] = "BEFORE";
5728
+								}
5119 5729
 							}
5120 5730
 						}
5121 5731
 					}
@@ -5182,7 +5792,10 @@  discard block
 block discarded – undo
5182 5792
 		}
5183 5793
 		else
5184 5794
 		{
5185
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
5795
+			if(Mail::$debug)
5796
+			{
5797
+				error_log(__METHOD__."-> No messages selected.");
5798
+			}
5186 5799
 		}
5187 5800
 	}
5188 5801
 
@@ -5200,11 +5813,17 @@  discard block
 block discarded – undo
5200 5813
 	 */
5201 5814
 	function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove='copy', $_move2ArchiveMarker='_', $_return = false)
5202 5815
 	{
5203
-		if(Mail::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker);
5816
+		if(Mail::$debug)
5817
+		{
5818
+			error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker);
5819
+		}
5204 5820
 		Api\Translation::add_app('mail');
5205 5821
 		$folderName = $this->mail_bo->decodeEntityFolderName($_folderName);
5206 5822
 		// only copy or move are supported as method
5207
-		if (!($_copyOrMove=='copy' || $_copyOrMove=='move')) $_copyOrMove='copy';
5823
+		if (!($_copyOrMove=='copy' || $_copyOrMove=='move'))
5824
+		{
5825
+			$_copyOrMove='copy';
5826
+		}
5208 5827
 		list($targetProfileID,$targetFolder) = explode(self::$delimiter,$folderName,2);
5209 5828
 		// check if move2archive was called with the correct archiveFolder
5210 5829
 		$archiveFolder = $this->mail_bo->getArchiveFolder();
@@ -5227,8 +5846,13 @@  discard block
 block discarded – undo
5227 5846
 				$keys = array_keys($lastFoldersUsedForMoveCont[$targetProfileID]);
5228 5847
 				foreach( $keys as &$f)
5229 5848
 				{
5230
-					if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]);
5231
-					else break;
5849
+					if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9)
5850
+					{
5851
+						unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]);
5852
+					}
5853
+					else {
5854
+						break;
5855
+					}
5232 5856
 				}
5233 5857
 				//error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID]));
5234 5858
 			}
@@ -5255,12 +5879,23 @@  discard block
 block discarded – undo
5255 5879
 						if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
5256 5880
 						{
5257 5881
 							Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10);
5258
-							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5882
+							if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID]))
5883
+							{
5884
+								Mail::$supportsORinQuery[$this->mail_bo->profileID]=true;
5885
+							}
5259 5886
 						}
5260 5887
 						$filtered = true;
5261 5888
 						$cutoffdate = $cutoffdate2 = null;
5262
-						if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate
5263
-						if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate
5889
+						if ($query['startdate'])
5890
+						{
5891
+							$cutoffdate = Api\DateTime::to($query['startdate'],'ts');
5892
+						}
5893
+						//SINCE, enddate
5894
+						if ($query['enddate'])
5895
+						{
5896
+							$cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');
5897
+						}
5898
+						//BEFORE, startdate
5264 5899
 						//error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate);
5265 5900
 						$filter = array(
5266 5901
 							'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')),
@@ -5269,15 +5904,24 @@  discard block
 block discarded – undo
5269 5904
 							'status' => (!empty($query['filter'])?$query['filter']:'any'),
5270 5905
 							//'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2)
5271 5906
 						);
5272
-						if ($query['enddate']||$query['startdate']) {
5907
+						if ($query['enddate']||$query['startdate'])
5908
+						{
5273 5909
 							$filter['range'] = "BETWEEN";
5274
-							if ($cutoffdate) {
5910
+							if ($cutoffdate)
5911
+							{
5275 5912
 								$filter[(empty($cutoffdate2)?'date':'since')] =  date("d-M-Y", $cutoffdate);
5276
-								if (empty($cutoffdate2)) $filter['range'] = "SINCE";
5913
+								if (empty($cutoffdate2))
5914
+								{
5915
+									$filter['range'] = "SINCE";
5916
+								}
5277 5917
 							}
5278
-							if ($cutoffdate2) {
5918
+							if ($cutoffdate2)
5919
+							{
5279 5920
 								$filter[(empty($cutoffdate)?'date':'before')] =  date("d-M-Y", $cutoffdate2);
5280
-								if (empty($cutoffdate)) $filter['range'] = "BEFORE";
5921
+								if (empty($cutoffdate))
5922
+								{
5923
+									$filter['range'] = "BEFORE";
5924
+								}
5281 5925
 							}
5282 5926
 						}
5283 5927
 					}
@@ -5333,7 +5977,10 @@  discard block
 block discarded – undo
5333 5977
 						$hA = self::splitRowID($rowID);
5334 5978
 
5335 5979
 						// If folder changes, stop and move what we've got
5336
-						if($hA['folder'] != $folder) break;
5980
+						if($hA['folder'] != $folder)
5981
+						{
5982
+							break;
5983
+						}
5337 5984
 
5338 5985
 						array_shift($_messageList['msg']);
5339 5986
 						$messageList[] = $hA['msgUID'];
@@ -5365,7 +6012,10 @@  discard block
 block discarded – undo
5365 6012
 					unset($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]);
5366 6013
 					$changeFolderActions = true;
5367 6014
 				}
5368
-				if ($_return) return $error;
6015
+				if ($_return)
6016
+				{
6017
+					return $error;
6018
+				}
5369 6019
 				$response->call('egw.message',$error,"error");
5370 6020
 			}
5371 6021
 			else
@@ -5373,13 +6023,19 @@  discard block
 block discarded – undo
5373 6023
 				if ($_copyOrMove=='copy')
5374 6024
 				{
5375 6025
 					$msg = lang('copied %1 message(s) from %2 to %3',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($messageList)),$folder,$targetFolder);
5376
-					if ($_return) return $msg;
6026
+					if ($_return)
6027
+					{
6028
+						return $msg;
6029
+					}
5377 6030
 					$response->call('egw.message',$msg);
5378 6031
 				}
5379 6032
 				else
5380 6033
 				{
5381 6034
 					$msg = lang('moved %1 message(s) from %2 to %3',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($messageList)),$folder,$targetFolder);
5382
-					if ($_return) return $msg;
6035
+					if ($_return)
6036
+					{
6037
+						return $msg;
6038
+					}
5383 6039
 					$response->call('egw.refresh',$msg,'mail',$messageListForRefresh,'delete');
5384 6040
 				}
5385 6041
 			}
@@ -5393,7 +6049,10 @@  discard block
 block discarded – undo
5393 6049
 		}
5394 6050
 		else
5395 6051
 		{
5396
-			if(Mail::$debug) error_log(__METHOD__."-> No messages selected.");
6052
+			if(Mail::$debug)
6053
+			{
6054
+				error_log(__METHOD__."-> No messages selected.");
6055
+			}
5397 6056
 		}
5398 6057
 	}
5399 6058
 
Please login to merge, or discard this patch.