Completed
Push — 14.2 ( ebfddb...2a0133 )
by Hadi
130:14 queued 111:10
created
addressbook/inc/class.addressbook_contactform.inc.php 3 patches
Doc Comments   +11 added lines, -15 removed lines patch added patch discarded remove patch
@@ -30,14 +30,12 @@  discard block
 block discarded – undo
30 30
 	/**
31 31
 	 * Shows the contactform and stores the submitted data
32 32
 	 *
33
-	 * @param array $content=null submitted eTemplate content
34
-	 * @param int $addressbook=null int owner-id of addressbook to save contacts too
35
-	 * @param array $fields=null field-names to show
36
-	 * @param string $msg=null message to show after submitting the form
37
-	 * @param string $email=null comma-separated email addresses
38
-	 * @param string $tpl_name=null custom etemplate to use
39
-	 * @param string $subject=null subject for email
40
-	 * @param string $copytoreceiver=false send a copy of notification to receiver
33
+	 * @param array $content submitted eTemplate content
34
+	 * @param int $addressbook int owner-id of addressbook to save contacts too
35
+	 * @param array $fields field-names to show
36
+	 * @param string $tpl_name custom etemplate to use
37
+	 * @param string $subject subject for email
38
+	 * @param string $copytoreceiver send a copy of notification to receiver
41 39
 	 * @return string html content
42 40
 	 */
43 41
 	function display(array $content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array())
@@ -49,13 +47,11 @@  discard block
 block discarded – undo
49 47
 	 * Shows the contactform and stores the submitted data ($content is a var parameter, eg. for extending classes)
50 48
 	 *
51 49
 	 * @param array &$content=null submitted eTemplate content
52
-	 * @param int $addressbook=null int owner-id of addressbook to save contacts too
53
-	 * @param array $fields=null field-names to show
54
-	 * @param string $msg=null message to show after submitting the form
55
-	 * @param string $email=null comma-separated email addresses
56
-	 * @param string $tpl_name=null custom etemplate to use
57
-	 * @param string $subject=null subject for email
58
-	 * @param string $copytoreceiver=false send a copy of notification to receiver
50
+	 * @param int $addressbook int owner-id of addressbook to save contacts too
51
+	 * @param array $fields field-names to show
52
+	 * @param string $tpl_name custom etemplate to use
53
+	 * @param string $subject subject for email
54
+	 * @param string $copytoreceiver send a copy of notification to receiver
59 55
 	 * @return string html content
60 56
 	 */
61 57
 	function display_var(array &$content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array())
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 	 * @param string $copytoreceiver=false send a copy of notification to receiver
37 37
 	 * @return string html content
38 38
 	 */
39
-	function display(array $content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array())
39
+	function display(array $content = null, $addressbook = null, $fields = null, $msg = null, $email = null, $tpl_name = null, $subject = null, $copytoreceiver = false, $sel_options = array())
40 40
 	{
41
-		return $this->display_var($content,$addressbook,$fields,$msg,$email,$tpl_name,$subject,$copytoreceiver,$sel_options);
41
+		return $this->display_var($content, $addressbook, $fields, $msg, $email, $tpl_name, $subject, $copytoreceiver, $sel_options);
42 42
 	}
43 43
 
44 44
 	/**
@@ -54,23 +54,23 @@  discard block
 block discarded – undo
54 54
 	 * @param string $copytoreceiver=false send a copy of notification to receiver
55 55
 	 * @return string html content
56 56
 	 */
57
-	function display_var(array &$content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array())
57
+	function display_var(array &$content = null, $addressbook = null, $fields = null, $msg = null, $email = null, $tpl_name = null, $subject = null, $copytoreceiver = false, $sel_options = array())
58 58
 	{
59 59
 		#error_log( "<p>addressbook_contactform::display(".print_r($content,true).",$addressbook,".print_r($fields,true).",$msg,$tpl_name)</p>\n");
60
-		if (empty($tpl_name) && !empty($content['tpl_form_name'])) $tpl_name =$content['tpl_form_name'];
60
+		if (empty($tpl_name) && !empty($content['tpl_form_name'])) $tpl_name = $content['tpl_form_name'];
61 61
 		$tpl = new etemplate($tpl_name ? $tpl_name : 'addressbook.contactform');
62 62
 		// initializing some fields
63
-		if (!$fields) $fields = array('org_name','n_fn','email','tel_work','url','note','captcha');
63
+		if (!$fields) $fields = array('org_name', 'n_fn', 'email', 'tel_work', 'url', 'note', 'captcha');
64 64
 		$submitted = false;
65 65
 		// check if submitted
66 66
 		if (is_array($content))
67 67
 		{
68
-			if ((isset($content['captcha_result']) && $content['captcha'] != $content['captcha_result']) ||	// no correct captcha OR
69
-				(time() - $content['start_time'] < 10 &&				// bot indicator (less then 10 sec to fill out the form and
68
+			if ((isset($content['captcha_result']) && $content['captcha'] != $content['captcha_result']) || // no correct captcha OR
69
+				(time() - $content['start_time'] < 10 && // bot indicator (less then 10 sec to fill out the form and
70 70
 				!$GLOBALS['egw_info']['etemplate']['java_script']))	// javascript disabled)
71 71
 			{
72 72
 				$submitted = "truebutfalse";
73
-				$tpl->set_validation_error('captcha',lang('Wrong - try again ...'));
73
+				$tpl->set_validation_error('captcha', lang('Wrong - try again ...'));
74 74
 			}
75 75
 			elseif ($content['submitit'])
76 76
 			{
@@ -78,11 +78,11 @@  discard block
 block discarded – undo
78 78
 				$contact = new addressbook_bo();
79 79
 				if ($content['owner'])	// save the contact in the addressbook
80 80
 				{
81
-					$content['private'] = 0;	// in case default_private is set
81
+					$content['private'] = 0; // in case default_private is set
82 82
 					if (($id = $contact->save($content)))
83 83
 					{
84 84
 						// check for fileuploads and attach the found files
85
-						foreach($content as $name => $value)
85
+						foreach ($content as $name => $value)
86 86
 						{
87 87
 							if (is_array($value) && isset($value['tmp_name']) && is_readable($value['tmp_name']))
88 88
 							{
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 								// edit rights for the addressbook used to store the new entry,
92 92
 								// which is clearly not wanted securitywise
93 93
 								egw_vfs::$is_root = true;
94
-								egw_link::link('addressbook',$id,egw_link::VFS_APPNAME,$value,$name);
94
+								egw_link::link('addressbook', $id, egw_link::VFS_APPNAME, $value, $name);
95 95
 								egw_vfs::$is_root = false;
96 96
 							}
97 97
 						}
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 						require_once(EGW_INCLUDE_ROOT.'/addressbook/inc/class.addressbook_tracking.inc.php');
112 112
 						$tracking = new addressbook_tracking($contact);
113 113
 					}
114
-					if ($tracking->do_notifications($contact->data2db($content),null))
114
+					if ($tracking->do_notifications($contact->data2db($content), null))
115 115
 					{
116 116
 						return '<p align="center">'.$content['msg'].'</p>';
117 117
 					}
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 			$preserv['email_copytoreceiver'] = $copytoreceiver;
135 135
 			#if (!$fields) $fields = array('org_name','n_fn','email','tel_work','url','note','captcha');
136 136
 			$custom = 1;
137
-			foreach($fields as $name)
137
+			foreach ($fields as $name)
138 138
 			{
139 139
 				if ($name[0] == '#')	// custom field
140 140
 				{
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
 					}
146 146
 					$content['show']['custom'.$custom] = true;
147 147
 					$content['customfield'][$custom] = $name;
148
-					$content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label'];
148
+					$content['customlabel'][$custom] = $contact->customfields[substr($name, 1)]['label'];
149 149
 					++$custom;
150 150
 				}
151
-				elseif($name == 'adr_one_locality')
151
+				elseif ($name == 'adr_one_locality')
152 152
 				{
153 153
 					if (!($content['show'][$name] = $GLOBALS['egw_info']['user']['preferences']['addressbook']['addr_format']))
154 154
 					{
@@ -169,18 +169,18 @@  discard block
 block discarded – undo
169 169
 			unset($content['submitit']);
170 170
 			$custom = 1;
171 171
 			// fieldnames are "defined" by the commit attempt, that way, we do not have to remember them
172
-			foreach($content as $name => $value) {
173
-				$preserv[$name]=$value;
172
+			foreach ($content as $name => $value) {
173
+				$preserv[$name] = $value;
174 174
 				if ($name[0] == '#')     // custom field
175 175
 				{
176 176
 					static $contact;
177 177
 					if (is_null($contact)) $contact = new addressbook_bo();
178 178
 					$content['show']['custom'.$custom] = true;
179 179
 					$content['customfield'][$custom] = $name;
180
-					$content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label'];
180
+					$content['customlabel'][$custom] = $contact->customfields[substr($name, 1)]['label'];
181 181
 					++$custom;
182 182
 				}
183
-				elseif($name == 'adr_one_locality')
183
+				elseif ($name == 'adr_one_locality')
184 184
 				{
185 185
 					if (!($content['show'][$name] = $GLOBALS['egw_info']['user']['preferences']['addressbook']['addr_format']))
186 186
 					{
@@ -201,17 +201,17 @@  discard block
 block discarded – undo
201 201
 		if ($msg) $preserv['msg'] = $msg;
202 202
 
203 203
 		// a simple calculation captcha
204
-		$num1 = rand(1,99);
205
-		$num2 = rand(1,99);
204
+		$num1 = rand(1, 99);
205
+		$num2 = rand(1, 99);
206 206
 		if ($num2 > $num1)	// keep the result positive
207 207
 		{
208 208
 			$n = $num1; $num1 = $num2; $num2 = $n;
209 209
 		}
210
-		if (in_array('captcha',$fields))
210
+		if (in_array('captcha', $fields))
211 211
 		{
212
-			$content['captcha_task'] = sprintf('%d - %d =',$num1,$num2);
213
-			$preserv['captcha_result'] = $num1-$num2;
212
+			$content['captcha_task'] = sprintf('%d - %d =', $num1, $num2);
213
+			$preserv['captcha_result'] = $num1 - $num2;
214 214
 		}
215
-		return $tpl->exec($this->callback,$content,$sel_options,array(),$preserv);
215
+		return $tpl->exec($this->callback, $content, $sel_options, array(), $preserv);
216 216
 	}
217 217
 }
Please login to merge, or discard this patch.
Braces   +46 added lines, -13 removed lines patch added patch discarded remove patch
@@ -57,28 +57,41 @@  discard block
 block discarded – undo
57 57
 	function display_var(array &$content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array())
58 58
 	{
59 59
 		#error_log( "<p>addressbook_contactform::display(".print_r($content,true).",$addressbook,".print_r($fields,true).",$msg,$tpl_name)</p>\n");
60
-		if (empty($tpl_name) && !empty($content['tpl_form_name'])) $tpl_name =$content['tpl_form_name'];
60
+		if (empty($tpl_name) && !empty($content['tpl_form_name']))
61
+		{
62
+			$tpl_name =$content['tpl_form_name'];
63
+		}
61 64
 		$tpl = new etemplate($tpl_name ? $tpl_name : 'addressbook.contactform');
62 65
 		// initializing some fields
63
-		if (!$fields) $fields = array('org_name','n_fn','email','tel_work','url','note','captcha');
66
+		if (!$fields)
67
+		{
68
+			$fields = array('org_name','n_fn','email','tel_work','url','note','captcha');
69
+		}
64 70
 		$submitted = false;
65 71
 		// check if submitted
66 72
 		if (is_array($content))
67 73
 		{
68 74
 			if ((isset($content['captcha_result']) && $content['captcha'] != $content['captcha_result']) ||	// no correct captcha OR
69 75
 				(time() - $content['start_time'] < 10 &&				// bot indicator (less then 10 sec to fill out the form and
70
-				!$GLOBALS['egw_info']['etemplate']['java_script']))	// javascript disabled)
76
+				!$GLOBALS['egw_info']['etemplate']['java_script']))
77
+			{
78
+				// javascript disabled)
71 79
 			{
72 80
 				$submitted = "truebutfalse";
81
+			}
73 82
 				$tpl->set_validation_error('captcha',lang('Wrong - try again ...'));
74 83
 			}
75 84
 			elseif ($content['submitit'])
76 85
 			{
77 86
 				$submitted = true;
78 87
 				$contact = new addressbook_bo();
79
-				if ($content['owner'])	// save the contact in the addressbook
88
+				if ($content['owner'])
89
+				{
90
+					// save the contact in the addressbook
80 91
 				{
81
-					$content['private'] = 0;	// in case default_private is set
92
+					$content['private'] = 0;
93
+				}
94
+				// in case default_private is set
82 95
 					if (($id = $contact->save($content)))
83 96
 					{
84 97
 						// check for fileuploads and attach the found files
@@ -136,9 +149,12 @@  discard block
 block discarded – undo
136 149
 			$custom = 1;
137 150
 			foreach($fields as $name)
138 151
 			{
139
-				if ($name[0] == '#')	// custom field
152
+				if ($name[0] == '#')
153
+				{
154
+					// custom field
140 155
 				{
141 156
 					static $contact;
157
+				}
142 158
 					if (is_null($contact))
143 159
 					{
144 160
 						$contact = new addressbook_bo();
@@ -169,12 +185,19 @@  discard block
 block discarded – undo
169 185
 			unset($content['submitit']);
170 186
 			$custom = 1;
171 187
 			// fieldnames are "defined" by the commit attempt, that way, we do not have to remember them
172
-			foreach($content as $name => $value) {
188
+			foreach($content as $name => $value)
189
+			{
173 190
 				$preserv[$name]=$value;
174
-				if ($name[0] == '#')     // custom field
191
+				if ($name[0] == '#')
192
+				{
193
+					// custom field
175 194
 				{
176 195
 					static $contact;
177
-					if (is_null($contact)) $contact = new addressbook_bo();
196
+				}
197
+					if (is_null($contact))
198
+					{
199
+						$contact = new addressbook_bo();
200
+					}
178 201
 					$content['show']['custom'.$custom] = true;
179 202
 					$content['customfield'][$custom] = $name;
180 203
 					$content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label'];
@@ -197,15 +220,25 @@  discard block
 block discarded – undo
197 220
 		}
198 221
 		$content['addr_format'] = $GLOBALS['egw_info']['user']['preferences']['addressbook']['addr_format'];
199 222
 
200
-		if ($addressbook) $preserv['owner'] = $addressbook;
201
-		if ($msg) $preserv['msg'] = $msg;
223
+		if ($addressbook)
224
+		{
225
+			$preserv['owner'] = $addressbook;
226
+		}
227
+		if ($msg)
228
+		{
229
+			$preserv['msg'] = $msg;
230
+		}
202 231
 
203 232
 		// a simple calculation captcha
204 233
 		$num1 = rand(1,99);
205 234
 		$num2 = rand(1,99);
206
-		if ($num2 > $num1)	// keep the result positive
235
+		if ($num2 > $num1)
236
+		{
237
+			// keep the result positive
207 238
 		{
208
-			$n = $num1; $num1 = $num2; $num2 = $n;
239
+			$n = $num1;
240
+		}
241
+		$num1 = $num2; $num2 = $n;
209 242
 		}
210 243
 		if (in_array('captcha',$fields))
211 244
 		{
Please login to merge, or discard this patch.
addressbook/inc/class.addressbook_export_contacts_csv.inc.php 5 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
 	/**
37 37
 	 * Exports records as defined in $_definition
38 38
 	 *
39
-	 * @param egw_record $_definition
39
+	 * @param importexport_definition $_definition
40 40
 	 */
41 41
 	public function export( $_stream, importexport_definition $_definition) {
42 42
 
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -365,10 +365,10 @@  discard block
 block discarded – undo
365 365
 	}
366 366
 
367 367
 	/**
368
-	* Convert some internal data to something with more meaning
369
-	*
370
-	* Dates, times, user IDs, category IDs
371
-	*/
368
+	 * Convert some internal data to something with more meaning
369
+	 *
370
+	 * Dates, times, user IDs, category IDs
371
+	 */
372 372
 	public static function convert(addressbook_egw_record &$record, $options) {
373 373
 
374 374
 		if ($record->tel_prefer) {
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 	 * Adjust automatically generated filter fields
437 437
 	 */
438 438
 	public function get_filter_fields(Array &$filters)
439
-    {
439
+	{
440 440
 		unset($filters['last_event']);
441 441
 		unset($filters['next_event']);
442 442
 		foreach($filters as $field_name => &$settings)
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -435,7 +435,7 @@
 block discarded – undo
435 435
 	/**
436 436
 	 * Adjust automatically generated filter fields
437 437
 	 */
438
-	public function get_filter_fields(Array &$filters)
438
+	public function get_filter_fields(array &$filters)
439 439
     {
440 440
 		unset($filters['last_event']);
441 441
 		unset($filters['next_event']);
Please login to merge, or discard this patch.
Spacing   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -21,13 +21,13 @@  discard block
 block discarded – undo
21 21
 	 * Constants used for exploding categories & multi-selectboxes into seperate fields
22 22
 	 */
23 23
 	const NO_EXPLODE = False;
24
-	const MAIN_CATS = 'main_cats';	// Only the top-level categories get their own field
25
-	const EACH_CAT = 'each_cat';	// Every category gets its own field
26
-	const EXPLODE = 'explode';	// For [custom] multi-selects, each option gets its own field
24
+	const MAIN_CATS = 'main_cats'; // Only the top-level categories get their own field
25
+	const EACH_CAT = 'each_cat'; // Every category gets its own field
26
+	const EXPLODE = 'explode'; // For [custom] multi-selects, each option gets its own field
27 27
 
28 28
 	public function __construct()
29 29
 	{
30
-		$this->ui= new addressbook_ui();
30
+		$this->ui = new addressbook_ui();
31 31
 		$this->get_selects();
32 32
 	}
33 33
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @param egw_record $_definition
38 38
 	 */
39
-	public function export( $_stream, importexport_definition $_definition) {
39
+	public function export($_stream, importexport_definition $_definition) {
40 40
 
41 41
 		$options = $_definition->plugin_options;
42 42
 		$this->export_object = $export_object = new importexport_export_csv($_stream, (array)$options);
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
 
46 46
 		// Addressbook defines its own export imits
47 47
 		$limit_exception = bo_merge::is_export_limit_excepted();
48
-		$export_limit = bo_merge::getExportLimit($app='addressbook');
48
+		$export_limit = bo_merge::getExportLimit($app = 'addressbook');
49 49
 		if (!$limit_exception) $export_object->export_limit = $export_limit; // we may not need that after all
50
-		if($export_limit == 'no' && !$limit_exception) {
50
+		if ($export_limit == 'no' && !$limit_exception) {
51 51
 			return;
52 52
 		}
53 53
 
@@ -57,18 +57,18 @@  discard block
 block discarded – undo
57 57
 
58 58
 		if ($options['selection'] == 'search') {
59 59
 			// uicontacts selection with checkbox 'use_all'
60
-			$query = $GLOBALS['egw']->session->appsession('index','addressbook');
61
-			$query['num_rows'] = -1;	// all
62
-			$query['csv_export'] = true;	// so get_rows method _can_ produce different content or not store state in the session
60
+			$query = $GLOBALS['egw']->session->appsession('index', 'addressbook');
61
+			$query['num_rows'] = -1; // all
62
+			$query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session
63 63
 			$query['order'] = 'contact_id';
64
-			if(!array_key_exists('filter',$query)) $query['filter'] = $GLOBALS['egw_info']['user']['account_id'];
65
-			$this->ui->get_rows($query,$selection,$readonlys, true);	// only return the ids
64
+			if (!array_key_exists('filter', $query)) $query['filter'] = $GLOBALS['egw_info']['user']['account_id'];
65
+			$this->ui->get_rows($query, $selection, $readonlys, true); // only return the ids
66 66
 		}
67
-		elseif ( $options['selection'] == 'all' ) {
67
+		elseif ($options['selection'] == 'all') {
68 68
 			if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) {
69 69
 				$col_filter['account_id'] = null;
70 70
 			}
71
-			$selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$col_filter);
71
+			$selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '', '', false, 'AND', false, $col_filter);
72 72
 			//$uicontacts->get_rows($query,$selection,$readonlys,true);
73 73
 		}
74 74
 		elseif ($options['selection'] == 'filter')
@@ -79,90 +79,90 @@  discard block
 block discarded – undo
79 79
 			$query = array();
80 80
 
81 81
 			// Handle ranges
82
-			foreach($filter as $field => $value)
82
+			foreach ($filter as $field => $value)
83 83
 			{
84
-				if($field == 'cat_id')
84
+				if ($field == 'cat_id')
85 85
 				{
86
-					$query['col_filter'][$field] = implode(',',$value);
86
+					$query['col_filter'][$field] = implode(',', $value);
87 87
 					continue;
88 88
 				}
89 89
 
90 90
 				// Birthdays in addressbook are formatted Y-m-d
91
-				if($field == 'bday')
91
+				if ($field == 'bday')
92 92
 				{
93
-					if($value['from'])
93
+					if ($value['from'])
94 94
 					{
95
-						$query['col_filter'][] = "contact_bday >= " . $GLOBALS['egw']->db->quote(date('Y-m-d', (int)$value['from']));
95
+						$query['col_filter'][] = "contact_bday >= ".$GLOBALS['egw']->db->quote(date('Y-m-d', (int)$value['from']));
96 96
 					}
97
-					if($value['to'])
97
+					if ($value['to'])
98 98
 					{
99
-						$query['col_filter'][] = "contact_bday <= " . $GLOBALS['egw']->db->quote(date('Y-m-d', (int)$value['to']));
99
+						$query['col_filter'][] = "contact_bday <= ".$GLOBALS['egw']->db->quote(date('Y-m-d', (int)$value['to']));
100 100
 					}
101 101
 					continue;
102 102
 				}
103 103
 				// Custom fields & listed exceptions are not filtered with contact_ prefix
104
-				if(strpos($field, '#') !== 0 && !in_array($field, array('tid','owner')))
104
+				if (strpos($field, '#') !== 0 && !in_array($field, array('tid', 'owner')))
105 105
 				{
106 106
 					$field = 'contact_'.$field;
107 107
 				}
108 108
 				$query['col_filter'][$field] = $value;
109
-				if(!is_array($value) || (!$value['from'] && !$value['to'])) continue;
109
+				if (!is_array($value) || (!$value['from'] && !$value['to'])) continue;
110 110
 
111 111
 				// Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10)
112
-				if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from'];
113
-				if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to'];
112
+				if ($value['from']) $query['col_filter'][] = "$field >= ".(int)$value['from'];
113
+				if ($value['to']) $query['col_filter'][] = "$field <= ".(int)$value['to'];
114 114
 				unset($query['col_filter'][$field]);
115 115
 			}
116
-			$selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$query['col_filter']);
116
+			$selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '', '', false, 'AND', false, $query['col_filter']);
117 117
 		}
118 118
 		else
119 119
 		{
120
-			$selection = explode(',',$options['selection']);
120
+			$selection = explode(',', $options['selection']);
121 121
 		}
122
-		if(!is_array($selection))
122
+		if (!is_array($selection))
123 123
 		{
124 124
 			$selection = array();
125 125
 		}
126 126
 		$GLOBALS['egw_info']['flags']['currentapp'] = $old_app;
127 127
 
128
-		if(bo_merge::hasExportLimit($export_limit) && !$limit_exception) {
128
+		if (bo_merge::hasExportLimit($export_limit) && !$limit_exception) {
129 129
 			$selection = array_slice($selection, 0, $export_limit);
130 130
 		}
131 131
 
132
-		if($options['explode_multiselects']) {
132
+		if ($options['explode_multiselects']) {
133 133
 			$customfields = config::get_customfields('addressbook');
134 134
 			$additional_fields = array();
135 135
 			$cat_obj = new categories('', 'addressbook');
136
-			foreach($options['explode_multiselects'] as $field => $explode) {
137
-				switch($explode['explode']) {
136
+			foreach ($options['explode_multiselects'] as $field => $explode) {
137
+				switch ($explode['explode']) {
138 138
 					case self::MAIN_CATS:
139
-						$cats = $cat_obj->return_array('mains', 0, false,'','ASC','',true);
140
-						foreach($cats as $settings) {
139
+						$cats = $cat_obj->return_array('mains', 0, false, '', 'ASC', '', true);
140
+						foreach ($cats as $settings) {
141 141
 							$additional_fields[$field][$settings['id']] = array(
142 142
 								'count' => 0,
143 143
 								'label' => $settings['name'],
144 144
 								'subs' => array(),
145 145
 							);
146 146
 							$subs = $cat_obj->return_sorted_array(0, False, '', 'ASC', 'cat_name', True, $settings['id']);
147
-							foreach($subs as $sub) {
147
+							foreach ($subs as $sub) {
148 148
 								$name = $sub['name'];
149 149
 								$path = $sub;
150
-								while($path['parent'] != $settings['id']) {
150
+								while ($path['parent'] != $settings['id']) {
151 151
 									$path = $cat_obj->read($path['parent']);
152
-									$name = $path['name'] . '/' . $name;
152
+									$name = $path['name'].'/'.$name;
153 153
 								}
154 154
 								$additional_fields[$field][$settings['id']]['subs'][$sub['id']] = $name;
155 155
 							}
156 156
 						}
157 157
 						break;
158 158
 					case self::EACH_CAT:
159
-						$cats = $cat_obj->return_array('all', 0, false,'','ASC','',true);
160
-						foreach($cats as $settings) {
159
+						$cats = $cat_obj->return_array('all', 0, false, '', 'ASC', '', true);
160
+						foreach ($cats as $settings) {
161 161
 							$name = $settings['name'];
162 162
 							$path = $settings;
163
-							while($path['level'] != 0) {
163
+							while ($path['level'] != 0) {
164 164
 								$path = $cat_obj->read($path['parent']);
165
-								$name = $path['name'] . '/' . $name;
165
+								$name = $path['name'].'/'.$name;
166 166
 							}
167 167
 							$additional_fields[$field][$settings['id']] = array(
168 168
 								'count' => 0,
@@ -173,10 +173,10 @@  discard block
 block discarded – undo
173 173
 					case self::EXPLODE:
174 174
 						// Only works for custom fields
175 175
 						$index = substr($field, 1);
176
-						foreach($customfields[$index]['values'] as $key => $value) {
176
+						foreach ($customfields[$index]['values'] as $key => $value) {
177 177
 							$additional_fields[$field][$key] = array(
178 178
 								'count' => 0,
179
-								'label' => $customfields[$index]['label'] . ': ' . $value,
179
+								'label' => $customfields[$index]['label'].': '.$value,
180 180
 							);
181 181
 						}
182 182
 						break;
@@ -185,29 +185,29 @@  discard block
 block discarded – undo
185 185
 
186 186
 			// Check records to see if additional fields are actually used
187 187
 			foreach ($selection as $_contact) {
188
-				if(is_array($_contact) && array_key_exists('photo', $_contact)) {
188
+				if (is_array($_contact) && array_key_exists('photo', $_contact)) {
189 189
 					unset($_contact['photo']);
190 190
 				}
191
-				if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) {
191
+				if (is_array($_contact) && count($_contact) == 1 && $_contact['id']) {
192 192
 					$_contact = $_contact['id'];
193 193
 				}
194
-				if(is_array($_contact) && $_contact['id']) {
194
+				if (is_array($_contact) && $_contact['id']) {
195 195
 					$contact = new addressbook_egw_record();
196 196
 					$contact->set_record($_contact);
197 197
 				} else {
198 198
 					$contact = new addressbook_egw_record($_contact);
199 199
 				}
200
-				foreach($additional_fields as $field => &$values) {
201
-					if(!$contact->$field) continue;
202
-					foreach($values as $value => &$settings) {
203
-						if(!is_array($contact->$field)) {
200
+				foreach ($additional_fields as $field => &$values) {
201
+					if (!$contact->$field) continue;
202
+					foreach ($values as $value => &$settings) {
203
+						if (!is_array($contact->$field)) {
204 204
 							$contact->$field = explode(',', $contact->$field);
205 205
 						}
206
-						if(is_array($contact->$field) && in_array($value, $contact->$field)) {
206
+						if (is_array($contact->$field) && in_array($value, $contact->$field)) {
207 207
 							$settings['count']++;
208
-						} elseif($contact->$field == $value) {
208
+						} elseif ($contact->$field == $value) {
209 209
 							$settings['count']++;
210
-						} elseif($options['explode_multiselects'][$field]['explode'] == self::MAIN_CATS && array_intersect($contact->$field, array_keys($settings['subs']))) {
210
+						} elseif ($options['explode_multiselects'][$field]['explode'] == self::MAIN_CATS && array_intersect($contact->$field, array_keys($settings['subs']))) {
211 211
 							$settings['count']++;
212 212
 						}
213 213
 					}
@@ -219,18 +219,18 @@  discard block
 block discarded – undo
219 219
 			unset($settings);
220 220
 
221 221
 			// Add additional columns
222
-			foreach($additional_fields as $field => $additional_values) {
222
+			foreach ($additional_fields as $field => $additional_values) {
223 223
 				// Remove original
224 224
 				unset($options['mapping'][$field]);
225 225
 				// Add exploded
226 226
 				$field_count = 0;
227
-				foreach($additional_values as $value => $settings) {
228
-					if($settings['count'] > 0) {
227
+				foreach ($additional_values as $value => $settings) {
228
+					if ($settings['count'] > 0) {
229 229
 						$field_count += $settings['count'];
230 230
 						$options['mapping'][$field.'-'.$value] = $settings['label'];
231 231
 					}
232 232
 				}
233
-				if($field_count > 0) {
233
+				if ($field_count > 0) {
234 234
 					// Set some options for converting
235 235
 					$options['explode_multiselects'][$field]['values'] = $additional_values;
236 236
 				} else {
@@ -243,12 +243,12 @@  discard block
 block discarded – undo
243 243
 		$export_object->set_mapping($options['mapping']);
244 244
 		
245 245
 		// Add in last/next event, if needed
246
-		if($options['mapping']['last_date'] || $options['mapping']['next_date'])
246
+		if ($options['mapping']['last_date'] || $options['mapping']['next_date'])
247 247
 		{
248 248
 			$contact_ids = array();
249
-			foreach($selection as $_contact)
249
+			foreach ($selection as $_contact)
250 250
 			{
251
-				if(is_array($_contact) && $_contact['id'])
251
+				if (is_array($_contact) && $_contact['id'])
252 252
 				{
253 253
 					$contact_ids[] = $_contact['id'];
254 254
 				}
@@ -263,20 +263,20 @@  discard block
 block discarded – undo
263 263
 		// $options['selection'] is array of identifiers as this plugin doesn't
264 264
 		// support other selectors atm.
265 265
 		foreach ($selection as $_contact) {
266
-			if(is_array($_contact) && array_key_exists('photo', $_contact)) {
266
+			if (is_array($_contact) && array_key_exists('photo', $_contact)) {
267 267
 				unset($_contact['photo']);
268 268
 			}
269
-			if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) {
269
+			if (is_array($_contact) && count($_contact) == 1 && $_contact['id']) {
270 270
 				$_contact = $_contact['id'];
271 271
 			}
272
-			if(is_array($_contact) && $_contact['id']) {
272
+			if (is_array($_contact) && $_contact['id']) {
273 273
 				$contact = new addressbook_egw_record();
274 274
 				$contact->set_record($_contact);
275 275
 			} else {
276 276
 				$contact = new addressbook_egw_record($_contact);
277 277
 			}
278 278
 
279
-			if($events && $events[$contact->id])
279
+			if ($events && $events[$contact->id])
280 280
 			{
281 281
 				// NB: last_date and next_date are used instead of last_event & next_event
282 282
 				// to avoid automatic conversion - we want to export link title, not date-time
@@ -285,12 +285,12 @@  discard block
 block discarded – undo
285 285
 			}
286 286
 			// Some conversion
287 287
 			$this->convert($contact, $options);
288
-			if($options['convert']) {
289
-				importexport_export_csv::convert($contact, addressbook_egw_record::$types, 'addressbook',$this->selects);
288
+			if ($options['convert']) {
289
+				importexport_export_csv::convert($contact, addressbook_egw_record::$types, 'addressbook', $this->selects);
290 290
 			} else {
291 291
 				// Implode arrays, so they don't say 'Array'
292
-				foreach($contact->get_record_array() as $key => $value) {
293
-					if(is_array($value)) $contact->$key = implode(',', $value);
292
+				foreach ($contact->get_record_array() as $key => $value) {
293
+					if (is_array($value)) $contact->$key = implode(',', $value);
294 294
 				}
295 295
 			}
296 296
 
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 	 */
338 338
 	public function get_filename()
339 339
 	{
340
-		if(is_object($this->export_object) && $this->export_object->get_num_of_records() == 1)
340
+		if (is_object($this->export_object) && $this->export_object->get_num_of_records() == 1)
341 341
 		{
342 342
 			return $this->export_object->record->get_title();
343 343
 		}
@@ -368,26 +368,26 @@  discard block
 block discarded – undo
368 368
 	*
369 369
 	* Dates, times, user IDs, category IDs
370 370
 	*/
371
-	public static function convert(addressbook_egw_record &$record, $options) {
371
+	public static function convert(addressbook_egw_record&$record, $options) {
372 372
 
373 373
 		if ($record->tel_prefer) {
374 374
 			$field = $record->tel_prefer;
375 375
 			$record->tel_prefer = $record->$field;
376 376
 		}
377 377
 
378
-		if(!is_array($options['explode_multiselects']))
378
+		if (!is_array($options['explode_multiselects']))
379 379
 		{
380 380
 			return;
381 381
 		}
382
-		foreach((array)$options['explode_multiselects'] as $field => $explode_settings) {
383
-			if(!is_array($record->$field)) $record->$field = explode(',', $record->$field);
384
-			foreach((array)$explode_settings['values'] as $value => $settings) {
382
+		foreach ((array)$options['explode_multiselects'] as $field => $explode_settings) {
383
+			if (!is_array($record->$field)) $record->$field = explode(',', $record->$field);
384
+			foreach ((array)$explode_settings['values'] as $value => $settings) {
385 385
 				$field_name = "$field-$value";
386 386
 				$record->$field_name = array();
387
-				if(is_array($record->$field) && in_array($value, $record->$field) || $record->$field == $value) {
388
-					if($explode_settings['explode'] != self::MAIN_CATS) {
387
+				if (is_array($record->$field) && in_array($value, $record->$field) || $record->$field == $value) {
388
+					if ($explode_settings['explode'] != self::MAIN_CATS) {
389 389
 						$record->$field_name = $options['convert'] ? lang('Yes') : true;
390
-					} elseif($options['convert']) {
390
+					} elseif ($options['convert']) {
391 391
 						// 3 part assign due to magic get method
392 392
 						$record_value = $record->$field_name;
393 393
 						$record_value[] = $settings['label'];
@@ -396,16 +396,16 @@  discard block
 block discarded – undo
396 396
 						$record->$field_name = $value;
397 397
 					}
398 398
 				}
399
-				if($explode_settings['explode'] == self::MAIN_CATS && count(array_intersect($record->$field, array_keys($settings['subs'])))) {
399
+				if ($explode_settings['explode'] == self::MAIN_CATS && count(array_intersect($record->$field, array_keys($settings['subs'])))) {
400 400
 					// 3 part assign due to magic get method
401 401
 					$record_value = $record->$field_name;
402
-					if(!is_array($record_value)) $record_value = array($record_value);
403
-					foreach(array_intersect($record->$field, array_keys($settings['subs'])) as $sub_id) {
402
+					if (!is_array($record_value)) $record_value = array($record_value);
403
+					foreach (array_intersect($record->$field, array_keys($settings['subs'])) as $sub_id) {
404 404
 						$record_value[] = $options['convert'] ? $settings['subs'][$sub_id] : $sub_id;
405 405
 					}
406 406
 					$record->$field_name = $record_value;
407 407
 				}
408
-				if(is_array($record->$field_name)) $record->$field_name = implode(($options['convert'] ? ', ' : ','), $record->$field_name);
408
+				if (is_array($record->$field_name)) $record->$field_name = implode(($options['convert'] ? ', ' : ','), $record->$field_name);
409 409
 			}
410 410
 		}
411 411
 	}
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 		$this->selects = array(
417 417
 			'tid' => array('n' => 'Contact')
418 418
 		);
419
-		foreach($this->ui->content_types as $tid => $data)
419
+		foreach ($this->ui->content_types as $tid => $data)
420 420
 		{
421 421
 			$this->selects['tid'][$tid] = $data['name'];
422 422
 		}
@@ -429,9 +429,9 @@  discard block
 block discarded – undo
429 429
     {
430 430
 		unset($filters['last_event']);
431 431
 		unset($filters['next_event']);
432
-		foreach($filters as $field_name => &$settings)
432
+		foreach ($filters as $field_name => &$settings)
433 433
 		{
434
-			if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
434
+			if ($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
435 435
 		}
436 436
 		$filters['owner'] = array(
437 437
 			'name'		=> 'owner',
Please login to merge, or discard this patch.
Braces   +166 added lines, -68 removed lines patch added patch discarded remove patch
@@ -14,7 +14,8 @@  discard block
 block discarded – undo
14 14
 /**
15 15
  * export plugin of addressbook
16 16
  */
17
-class addressbook_export_contacts_csv implements importexport_iface_export_plugin {
17
+class addressbook_export_contacts_csv implements importexport_iface_export_plugin
18
+{
18 19
 
19 20
 
20 21
 	/**
@@ -36,7 +37,8 @@  discard block
 block discarded – undo
36 37
 	 *
37 38
 	 * @param egw_record $_definition
38 39
 	 */
39
-	public function export( $_stream, importexport_definition $_definition) {
40
+	public function export( $_stream, importexport_definition $_definition)
41
+	{
40 42
 
41 43
 		$options = $_definition->plugin_options;
42 44
 		$this->export_object = $export_object = new importexport_export_csv($_stream, (array)$options);
@@ -46,8 +48,13 @@  discard block
 block discarded – undo
46 48
 		// Addressbook defines its own export imits
47 49
 		$limit_exception = bo_merge::is_export_limit_excepted();
48 50
 		$export_limit = bo_merge::getExportLimit($app='addressbook');
49
-		if (!$limit_exception) $export_object->export_limit = $export_limit; // we may not need that after all
50
-		if($export_limit == 'no' && !$limit_exception) {
51
+		if (!$limit_exception)
52
+		{
53
+			$export_object->export_limit = $export_limit;
54
+		}
55
+		// we may not need that after all
56
+		if($export_limit == 'no' && !$limit_exception)
57
+		{
51 58
 			return;
52 59
 		}
53 60
 
@@ -55,17 +62,23 @@  discard block
 block discarded – undo
55 62
 		$old_app = $GLOBALS['egw_info']['flags']['currentapp'];
56 63
 		$GLOBALS['egw_info']['flags']['currentapp'] = 'addressbook';
57 64
 
58
-		if ($options['selection'] == 'search') {
65
+		if ($options['selection'] == 'search')
66
+		{
59 67
 			// uicontacts selection with checkbox 'use_all'
60 68
 			$query = $GLOBALS['egw']->session->appsession('index','addressbook');
61 69
 			$query['num_rows'] = -1;	// all
62 70
 			$query['csv_export'] = true;	// so get_rows method _can_ produce different content or not store state in the session
63 71
 			$query['order'] = 'contact_id';
64
-			if(!array_key_exists('filter',$query)) $query['filter'] = $GLOBALS['egw_info']['user']['account_id'];
72
+			if(!array_key_exists('filter',$query))
73
+			{
74
+				$query['filter'] = $GLOBALS['egw_info']['user']['account_id'];
75
+			}
65 76
 			$this->ui->get_rows($query,$selection,$readonlys, true);	// only return the ids
66 77
 		}
67
-		elseif ( $options['selection'] == 'all' ) {
68
-			if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) {
78
+		elseif ( $options['selection'] == 'all' )
79
+		{
80
+			if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'])
81
+			{
69 82
 				$col_filter['account_id'] = null;
70 83
 			}
71 84
 			$selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$col_filter);
@@ -106,11 +119,20 @@  discard block
 block discarded – undo
106 119
 					$field = 'contact_'.$field;
107 120
 				}
108 121
 				$query['col_filter'][$field] = $value;
109
-				if(!is_array($value) || (!$value['from'] && !$value['to'])) continue;
122
+				if(!is_array($value) || (!$value['from'] && !$value['to']))
123
+				{
124
+					continue;
125
+				}
110 126
 
111 127
 				// Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10)
112
-				if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from'];
113
-				if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to'];
128
+				if($value['from'])
129
+				{
130
+					$query['col_filter'][] = "$field >= " . (int)$value['from'];
131
+				}
132
+				if($value['to'])
133
+				{
134
+					$query['col_filter'][] = "$field <= " . (int)$value['to'];
135
+				}
114 136
 				unset($query['col_filter'][$field]);
115 137
 			}
116 138
 			$selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$query['col_filter']);
@@ -125,29 +147,36 @@  discard block
 block discarded – undo
125 147
 		}
126 148
 		$GLOBALS['egw_info']['flags']['currentapp'] = $old_app;
127 149
 
128
-		if(bo_merge::hasExportLimit($export_limit) && !$limit_exception) {
150
+		if(bo_merge::hasExportLimit($export_limit) && !$limit_exception)
151
+		{
129 152
 			$selection = array_slice($selection, 0, $export_limit);
130 153
 		}
131 154
 
132
-		if($options['explode_multiselects']) {
155
+		if($options['explode_multiselects'])
156
+		{
133 157
 			$customfields = config::get_customfields('addressbook');
134 158
 			$additional_fields = array();
135 159
 			$cat_obj = new categories('', 'addressbook');
136
-			foreach($options['explode_multiselects'] as $field => $explode) {
137
-				switch($explode['explode']) {
160
+			foreach($options['explode_multiselects'] as $field => $explode)
161
+			{
162
+				switch($explode['explode'])
163
+				{
138 164
 					case self::MAIN_CATS:
139 165
 						$cats = $cat_obj->return_array('mains', 0, false,'','ASC','',true);
140
-						foreach($cats as $settings) {
166
+						foreach($cats as $settings)
167
+						{
141 168
 							$additional_fields[$field][$settings['id']] = array(
142 169
 								'count' => 0,
143 170
 								'label' => $settings['name'],
144 171
 								'subs' => array(),
145 172
 							);
146 173
 							$subs = $cat_obj->return_sorted_array(0, False, '', 'ASC', 'cat_name', True, $settings['id']);
147
-							foreach($subs as $sub) {
174
+							foreach($subs as $sub)
175
+							{
148 176
 								$name = $sub['name'];
149 177
 								$path = $sub;
150
-								while($path['parent'] != $settings['id']) {
178
+								while($path['parent'] != $settings['id'])
179
+								{
151 180
 									$path = $cat_obj->read($path['parent']);
152 181
 									$name = $path['name'] . '/' . $name;
153 182
 								}
@@ -157,10 +186,12 @@  discard block
 block discarded – undo
157 186
 						break;
158 187
 					case self::EACH_CAT:
159 188
 						$cats = $cat_obj->return_array('all', 0, false,'','ASC','',true);
160
-						foreach($cats as $settings) {
189
+						foreach($cats as $settings)
190
+						{
161 191
 							$name = $settings['name'];
162 192
 							$path = $settings;
163
-							while($path['level'] != 0) {
193
+							while($path['level'] != 0)
194
+							{
164 195
 								$path = $cat_obj->read($path['parent']);
165 196
 								$name = $path['name'] . '/' . $name;
166 197
 							}
@@ -173,7 +204,8 @@  discard block
 block discarded – undo
173 204
 					case self::EXPLODE:
174 205
 						// Only works for custom fields
175 206
 						$index = substr($field, 1);
176
-						foreach($customfields[$index]['values'] as $key => $value) {
207
+						foreach($customfields[$index]['values'] as $key => $value)
208
+						{
177 209
 							$additional_fields[$field][$key] = array(
178 210
 								'count' => 0,
179 211
 								'label' => $customfields[$index]['label'] . ': ' . $value,
@@ -184,30 +216,47 @@  discard block
 block discarded – undo
184 216
 			}
185 217
 
186 218
 			// Check records to see if additional fields are actually used
187
-			foreach ($selection as $_contact) {
188
-				if(is_array($_contact) && array_key_exists('photo', $_contact)) {
219
+			foreach ($selection as $_contact)
220
+			{
221
+				if(is_array($_contact) && array_key_exists('photo', $_contact))
222
+				{
189 223
 					unset($_contact['photo']);
190 224
 				}
191
-				if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) {
225
+				if(is_array($_contact) && count($_contact) == 1 && $_contact['id'])
226
+				{
192 227
 					$_contact = $_contact['id'];
193 228
 				}
194
-				if(is_array($_contact) && $_contact['id']) {
229
+				if(is_array($_contact) && $_contact['id'])
230
+				{
195 231
 					$contact = new addressbook_egw_record();
196 232
 					$contact->set_record($_contact);
197
-				} else {
233
+				}
234
+				else
235
+				{
198 236
 					$contact = new addressbook_egw_record($_contact);
199 237
 				}
200
-				foreach($additional_fields as $field => &$values) {
201
-					if(!$contact->$field) continue;
202
-					foreach($values as $value => &$settings) {
203
-						if(!is_array($contact->$field)) {
238
+				foreach($additional_fields as $field => &$values)
239
+				{
240
+					if(!$contact->$field)
241
+					{
242
+						continue;
243
+					}
244
+					foreach($values as $value => &$settings)
245
+					{
246
+						if(!is_array($contact->$field))
247
+						{
204 248
 							$contact->$field = explode(',', $contact->$field);
205 249
 						}
206
-						if(is_array($contact->$field) && in_array($value, $contact->$field)) {
250
+						if(is_array($contact->$field) && in_array($value, $contact->$field))
251
+						{
207 252
 							$settings['count']++;
208
-						} elseif($contact->$field == $value) {
253
+						}
254
+						elseif($contact->$field == $value)
255
+						{
209 256
 							$settings['count']++;
210
-						} elseif($options['explode_multiselects'][$field]['explode'] == self::MAIN_CATS && array_intersect($contact->$field, array_keys($settings['subs']))) {
257
+						}
258
+						elseif($options['explode_multiselects'][$field]['explode'] == self::MAIN_CATS && array_intersect($contact->$field, array_keys($settings['subs'])))
259
+						{
211 260
 							$settings['count']++;
212 261
 						}
213 262
 					}
@@ -219,21 +268,27 @@  discard block
 block discarded – undo
219 268
 			unset($settings);
220 269
 
221 270
 			// Add additional columns
222
-			foreach($additional_fields as $field => $additional_values) {
271
+			foreach($additional_fields as $field => $additional_values)
272
+			{
223 273
 				// Remove original
224 274
 				unset($options['mapping'][$field]);
225 275
 				// Add exploded
226 276
 				$field_count = 0;
227
-				foreach($additional_values as $value => $settings) {
228
-					if($settings['count'] > 0) {
277
+				foreach($additional_values as $value => $settings)
278
+				{
279
+					if($settings['count'] > 0)
280
+					{
229 281
 						$field_count += $settings['count'];
230 282
 						$options['mapping'][$field.'-'.$value] = $settings['label'];
231 283
 					}
232 284
 				}
233
-				if($field_count > 0) {
285
+				if($field_count > 0)
286
+				{
234 287
 					// Set some options for converting
235 288
 					$options['explode_multiselects'][$field]['values'] = $additional_values;
236
-				} else {
289
+				}
290
+				else
291
+				{
237 292
 					// Don't need this anymore
238 293
 					unset($options['explode_multiselects'][$field]);
239 294
 				}
@@ -262,17 +317,23 @@  discard block
 block discarded – undo
262 317
 
263 318
 		// $options['selection'] is array of identifiers as this plugin doesn't
264 319
 		// support other selectors atm.
265
-		foreach ($selection as $_contact) {
266
-			if(is_array($_contact) && array_key_exists('photo', $_contact)) {
320
+		foreach ($selection as $_contact)
321
+		{
322
+			if(is_array($_contact) && array_key_exists('photo', $_contact))
323
+			{
267 324
 				unset($_contact['photo']);
268 325
 			}
269
-			if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) {
326
+			if(is_array($_contact) && count($_contact) == 1 && $_contact['id'])
327
+			{
270 328
 				$_contact = $_contact['id'];
271 329
 			}
272
-			if(is_array($_contact) && $_contact['id']) {
330
+			if(is_array($_contact) && $_contact['id'])
331
+			{
273 332
 				$contact = new addressbook_egw_record();
274 333
 				$contact->set_record($_contact);
275
-			} else {
334
+			}
335
+			else
336
+			{
276 337
 				$contact = new addressbook_egw_record($_contact);
277 338
 			}
278 339
 
@@ -285,12 +346,19 @@  discard block
 block discarded – undo
285 346
 			}
286 347
 			// Some conversion
287 348
 			$this->convert($contact, $options);
288
-			if($options['convert']) {
349
+			if($options['convert'])
350
+			{
289 351
 				importexport_export_csv::convert($contact, addressbook_egw_record::$types, 'addressbook',$this->selects);
290
-			} else {
352
+			}
353
+			else
354
+			{
291 355
 				// Implode arrays, so they don't say 'Array'
292
-				foreach($contact->get_record_array() as $key => $value) {
293
-					if(is_array($value)) $contact->$key = implode(',', $value);
356
+				foreach($contact->get_record_array() as $key => $value)
357
+				{
358
+					if(is_array($value))
359
+					{
360
+						$contact->$key = implode(',', $value);
361
+					}
294 362
 				}
295 363
 			}
296 364
 
@@ -305,7 +373,8 @@  discard block
 block discarded – undo
305 373
 	 *
306 374
 	 * @return string name
307 375
 	 */
308
-	public static function get_name() {
376
+	public static function get_name()
377
+	{
309 378
 		return lang('Addressbook CSV export');
310 379
 	}
311 380
 
@@ -314,7 +383,8 @@  discard block
 block discarded – undo
314 383
 	 *
315 384
 	 * @return string descriprion
316 385
 	 */
317
-	public static function get_description() {
386
+	public static function get_description()
387
+	{
318 388
 		return lang("Exports contacts from your Addressbook into a CSV File.");
319 389
 	}
320 390
 
@@ -323,11 +393,13 @@  discard block
 block discarded – undo
323 393
 	 *
324 394
 	 * @return string suffix
325 395
 	 */
326
-	public static function get_filesuffix() {
396
+	public static function get_filesuffix()
397
+	{
327 398
 		return 'csv';
328 399
 	}
329 400
 
330
-	public static function get_mimetype() {
401
+	public static function get_mimetype()
402
+	{
331 403
 		return 'text/csv';
332 404
 	}
333 405
 
@@ -350,14 +422,16 @@  discard block
 block discarded – undo
350 422
 	 *
351 423
 	 * @return string html
352 424
 	 */
353
-	public function get_options_etpl() {
425
+	public function get_options_etpl()
426
+	{
354 427
 	}
355 428
 
356 429
 	/**
357 430
 	 * returns slectors of this plugin via xajax
358 431
 	 *
359 432
 	 */
360
-	public function get_selectors_etpl() {
433
+	public function get_selectors_etpl()
434
+	{
361 435
 		return array(
362 436
 			'name'		=> 'importexport.export_csv_selectors',
363 437
 		);
@@ -368,9 +442,11 @@  discard block
 block discarded – undo
368 442
 	*
369 443
 	* Dates, times, user IDs, category IDs
370 444
 	*/
371
-	public static function convert(addressbook_egw_record &$record, $options) {
445
+	public static function convert(addressbook_egw_record &$record, $options)
446
+	{
372 447
 
373
-		if ($record->tel_prefer) {
448
+		if ($record->tel_prefer)
449
+		{
374 450
 			$field = $record->tel_prefer;
375 451
 			$record->tel_prefer = $record->$field;
376 452
 		}
@@ -379,33 +455,52 @@  discard block
 block discarded – undo
379 455
 		{
380 456
 			return;
381 457
 		}
382
-		foreach((array)$options['explode_multiselects'] as $field => $explode_settings) {
383
-			if(!is_array($record->$field)) $record->$field = explode(',', $record->$field);
384
-			foreach((array)$explode_settings['values'] as $value => $settings) {
458
+		foreach((array)$options['explode_multiselects'] as $field => $explode_settings)
459
+		{
460
+			if(!is_array($record->$field))
461
+			{
462
+				$record->$field = explode(',', $record->$field);
463
+			}
464
+			foreach((array)$explode_settings['values'] as $value => $settings)
465
+			{
385 466
 				$field_name = "$field-$value";
386 467
 				$record->$field_name = array();
387
-				if(is_array($record->$field) && in_array($value, $record->$field) || $record->$field == $value) {
388
-					if($explode_settings['explode'] != self::MAIN_CATS) {
468
+				if(is_array($record->$field) && in_array($value, $record->$field) || $record->$field == $value)
469
+				{
470
+					if($explode_settings['explode'] != self::MAIN_CATS)
471
+					{
389 472
 						$record->$field_name = $options['convert'] ? lang('Yes') : true;
390
-					} elseif($options['convert']) {
473
+					}
474
+					elseif($options['convert'])
475
+					{
391 476
 						// 3 part assign due to magic get method
392 477
 						$record_value = $record->$field_name;
393 478
 						$record_value[] = $settings['label'];
394 479
 						$record->$field_name = $record_value;
395
-					} else {
480
+					}
481
+					else
482
+					{
396 483
 						$record->$field_name = $value;
397 484
 					}
398 485
 				}
399
-				if($explode_settings['explode'] == self::MAIN_CATS && count(array_intersect($record->$field, array_keys($settings['subs'])))) {
486
+				if($explode_settings['explode'] == self::MAIN_CATS && count(array_intersect($record->$field, array_keys($settings['subs']))))
487
+				{
400 488
 					// 3 part assign due to magic get method
401 489
 					$record_value = $record->$field_name;
402
-					if(!is_array($record_value)) $record_value = array($record_value);
403
-					foreach(array_intersect($record->$field, array_keys($settings['subs'])) as $sub_id) {
490
+					if(!is_array($record_value))
491
+					{
492
+						$record_value = array($record_value);
493
+					}
494
+					foreach(array_intersect($record->$field, array_keys($settings['subs'])) as $sub_id)
495
+					{
404 496
 						$record_value[] = $options['convert'] ? $settings['subs'][$sub_id] : $sub_id;
405 497
 					}
406 498
 					$record->$field_name = $record_value;
407 499
 				}
408
-				if(is_array($record->$field_name)) $record->$field_name = implode(($options['convert'] ? ', ' : ','), $record->$field_name);
500
+				if(is_array($record->$field_name))
501
+				{
502
+					$record->$field_name = implode(($options['convert'] ? ', ' : ','), $record->$field_name);
503
+				}
409 504
 			}
410 505
 		}
411 506
 	}
@@ -426,12 +521,15 @@  discard block
 block discarded – undo
426 521
 	 * Adjust automatically generated filter fields
427 522
 	 */
428 523
 	public function get_filter_fields(Array &$filters)
429
-    {
524
+	{
430 525
 		unset($filters['last_event']);
431 526
 		unset($filters['next_event']);
432 527
 		foreach($filters as $field_name => &$settings)
433 528
 		{
434
-			if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
529
+			if($this->selects[$field_name])
530
+			{
531
+				$settings['values'] = $this->selects[$field_name];
532
+			}
435 533
 		}
436 534
 		$filters['owner'] = array(
437 535
 			'name'		=> 'owner',
Please login to merge, or discard this patch.
addressbook/inc/class.addressbook_import_contacts_csv.inc.php 4 patches
Doc Comments   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -44,9 +44,7 @@  discard block
 block discarded – undo
44 44
 
45 45
 	/**
46 46
 	 * imports entries according to given definition object.
47
-	 * @param resource $_stream
48
-	 * @param string $_charset
49
-	 * @param definition $_definition
47
+	 * @param importexport_definition $_definition
50 48
 	 */
51 49
 	public function init(importexport_definition &$_definition ) {
52 50
 
@@ -84,7 +82,7 @@  discard block
 block discarded – undo
84 82
 	 *
85 83
 	 * Updates the count of actions taken
86 84
 	 *
87
-	 * @return boolean success
85
+	 * @return null|boolean success
88 86
 	 */
89 87
 	protected function import_record(importexport_iface_egw_record &$record, &$import_csv)
90 88
 	{
Please login to merge, or discard this patch.
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
 	private $bocontacts;
30 30
 
31 31
 	/**
32
-	* For figuring out if a contact has changed
33
-	*/
32
+	 * For figuring out if a contact has changed
33
+	 */
34 34
 	protected $tracking;
35 35
 
36 36
 	/**
@@ -377,39 +377,39 @@  discard block
 block discarded – undo
377 377
 	}
378 378
 
379 379
 	/**
380
-        * Returns warnings that were encountered during importing
381
-        * Maximum of one warning message per record, but you can append if you need to
382
-        *
383
-        * @return Array (
384
-        *       record_# => warning message
385
-        *       )
386
-        */
387
-        public function get_warnings() {
380
+	 * Returns warnings that were encountered during importing
381
+	 * Maximum of one warning message per record, but you can append if you need to
382
+	 *
383
+	 * @return Array (
384
+	 *       record_# => warning message
385
+	 *       )
386
+	 */
387
+		public function get_warnings() {
388 388
 		return $this->warnings;
389 389
 	}
390 390
 
391 391
 	/**
392
-        * Returns errors that were encountered during importing
393
-        * Maximum of one error message per record, but you can append if you need to
394
-        *
395
-        * @return Array (
396
-        *       record_# => error message
397
-        *       )
398
-        */
399
-        public function get_errors() {
392
+	 * Returns errors that were encountered during importing
393
+	 * Maximum of one error message per record, but you can append if you need to
394
+	 *
395
+	 * @return Array (
396
+	 *       record_# => error message
397
+	 *       )
398
+	 */
399
+		public function get_errors() {
400 400
 		return $this->errors;
401 401
 	}
402 402
 
403 403
 	/**
404
-        * Returns a list of actions taken, and the number of records for that action.
405
-        * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
406
-        *
407
-        * @return Array (
408
-        *       action => record count
409
-        * )
410
-        */
411
-        public function get_results() {
412
-                return $this->results;
413
-        }
404
+	 * Returns a list of actions taken, and the number of records for that action.
405
+	 * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
406
+	 *
407
+	 * @return Array (
408
+	 *       action => record count
409
+	 * )
410
+	 */
411
+		public function get_results() {
412
+				return $this->results;
413
+		}
414 414
 } // end of iface_export_plugin
415 415
 ?>
Please login to merge, or discard this patch.
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@  discard block
 block discarded – undo
14 14
 /**
15 15
  * class import_csv for addressbook
16 16
  */
17
-class addressbook_import_contacts_csv extends importexport_basic_import_csv  {
17
+class addressbook_import_contacts_csv extends importexport_basic_import_csv {
18 18
 
19 19
 	/**
20 20
 	 * conditions for actions
21 21
 	 *
22 22
 	 * @var array
23 23
 	 */
24
-	protected static $conditions = array( 'exists', 'equal' );
24
+	protected static $conditions = array('exists', 'equal');
25 25
 
26 26
 	/**
27 27
 	 * @var bocontacts
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 * @param string $_charset
46 46
 	 * @param definition $_definition
47 47
 	 */
48
-	public function init(importexport_definition &$_definition ) {
48
+	public function init(importexport_definition&$_definition) {
49 49
 
50 50
 		// fetch the addressbook bo
51 51
 		$this->bocontacts = new addressbook_bo();
@@ -56,17 +56,17 @@  discard block
 block discarded – undo
56 56
 		$this->lookups = array(
57 57
 			'tid' => array('n'=>'contact')
58 58
 		);
59
-		foreach($this->bocontacts->content_types as $tid => $data)
59
+		foreach ($this->bocontacts->content_types as $tid => $data)
60 60
 		{
61 61
 			$this->lookups['tid'][$tid] = $data['name'];
62 62
 		}
63 63
 
64 64
 		// set contact owner
65
-		$contact_owner = isset( $_definition->plugin_options['contact_owner'] ) ?
65
+		$contact_owner = isset($_definition->plugin_options['contact_owner']) ?
66 66
 			$_definition->plugin_options['contact_owner'] : $this->user;
67 67
 
68 68
 		// Import into importer's personal addressbook
69
-		if($contact_owner == 'personal')
69
+		if ($contact_owner == 'personal')
70 70
 		{
71 71
 			$contact_owner = $this->user;
72 72
 		}
@@ -83,15 +83,15 @@  discard block
 block discarded – undo
83 83
 	 *
84 84
 	 * @return boolean success
85 85
 	 */
86
-	protected function import_record(importexport_iface_egw_record &$record, &$import_csv)
86
+	protected function import_record(importexport_iface_egw_record&$record, &$import_csv)
87 87
 	{
88 88
 
89 89
 		// Set owner, unless it's supposed to come from CSV file
90
-		if($this->definition->plugin_options['owner_from_csv'] && $record->owner) {
91
-			if(!is_numeric($record->owner)) {
90
+		if ($this->definition->plugin_options['owner_from_csv'] && $record->owner) {
91
+			if (!is_numeric($record->owner)) {
92 92
 				// Automatically handle text owner without explicit translation
93 93
 				$new_owner = importexport_helper_functions::account_name2id($record->owner);
94
-				if($new_owner == '') {
94
+				if ($new_owner == '') {
95 95
 					$this->errors[$import_csv->get_current_position()] = lang(
96 96
 						'Unable to convert "%1" to account ID.  Using plugin setting (%2) for owner.',
97 97
 						$record->owner,
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 		}
108 108
 
109 109
 		// Check that owner (addressbook) is allowed
110
-		if(!array_key_exists($record->owner, $this->bocontacts->get_addressbooks()))
110
+		if (!array_key_exists($record->owner, $this->bocontacts->get_addressbooks()))
111 111
 		{
112 112
 			$this->errors[$import_csv->get_current_position()] = lang("Unable to import into %1, using %2",
113 113
 				common::grab_owner_name($record->owner),
@@ -118,18 +118,18 @@  discard block
 block discarded – undo
118 118
 
119 119
 		// Do not allow owner == 0 (accounts) without an account_id
120 120
 		// It causes the contact to be filed as an account, and can't delete
121
-		if(!$record->owner && !$record->account_id)
121
+		if (!$record->owner && !$record->account_id)
122 122
 		{
123 123
 			$record->owner = $GLOBALS['egw_info']['user']['account_id'];
124 124
 		}
125 125
 
126 126
 		// Do not import into non-existing type, warn and change
127
-		if(!$record->tid || !$this->lookups['tid'][$record->tid])
127
+		if (!$record->tid || !$this->lookups['tid'][$record->tid])
128 128
 		{
129 129
 			// Avoid lots of warnings about type (2 types are contact and deleted)
130
-			if(!$this->type_warned || count($this->lookups['tid']) == 2 )
130
+			if (!$this->type_warned || count($this->lookups['tid']) == 2)
131 131
 			{
132
-				$this->warnings[$import_csv->get_current_position()] = lang('Unknown type %1, imported as %2',$record->tid,lang($this->lookups['tid']['n']));
132
+				$this->warnings[$import_csv->get_current_position()] = lang('Unknown type %1, imported as %2', $record->tid, lang($this->lookups['tid']['n']));
133 133
 				$this->type_warned = true;
134 134
 			}
135 135
 			$record->tid = 'n';
@@ -138,45 +138,45 @@  discard block
 block discarded – undo
138 138
 		// Also handle categories in their own field
139 139
 		$record_array = $record->get_record_array();
140 140
 		$more_categories = array();
141
-		foreach($this->definition->plugin_options['field_mapping'] as $number => $field_name) {
142
-			if(!array_key_exists($field_name, $record_array) ||
143
-				substr($field_name,0,3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') continue;
141
+		foreach ($this->definition->plugin_options['field_mapping'] as $number => $field_name) {
142
+			if (!array_key_exists($field_name, $record_array) ||
143
+				substr($field_name, 0, 3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') continue;
144 144
 			list($cat, $cat_id) = explode('-', $field_name);
145
-			if(is_numeric($record->$field_name) && $record->$field_name != 1) {
145
+			if (is_numeric($record->$field_name) && $record->$field_name != 1) {
146 146
 				// Column has a single category ID
147 147
 				$more_categories[] = $record->$field_name;
148
-			} elseif($record->$field_name == '1' ||
148
+			} elseif ($record->$field_name == '1' ||
149 149
 				(!is_numeric($record->$field_name) && strtolower($record->$field_name) == strtolower(lang('Yes')))) {
150 150
 				// Each category got its own column.  '1' is the database value, lang('yes') is the human value
151 151
 				$more_categories[] = $cat_id;
152 152
 			} else {
153 153
 				// Text categories
154
-				$more_categories = array_merge($more_categories, importexport_helper_functions::cat_name2id(is_array($record->$field_name) ? $record->$field_name : explode(',',$record->$field_name), $cat_id));
154
+				$more_categories = array_merge($more_categories, importexport_helper_functions::cat_name2id(is_array($record->$field_name) ? $record->$field_name : explode(',', $record->$field_name), $cat_id));
155 155
 			}
156 156
 		}
157
-		if(count($more_categories) > 0) $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',',$record->cat_id), $more_categories);
157
+		if (count($more_categories) > 0) $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',', $record->cat_id), $more_categories);
158 158
 
159 159
 		// Private set but missing causes hidden entries
160
-		if(array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) unset($record->private);
160
+		if (array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) unset($record->private);
161 161
 
162 162
 		// Format birthday as backend requires - converter should give timestamp
163
-		if($record->bday && is_numeric($record->bday))
163
+		if ($record->bday && is_numeric($record->bday))
164 164
 		{
165 165
 			$time = new egw_time($record->bday);
166 166
 			$record->bday = $time->format('Y-m-d');
167 167
 		}
168 168
 
169
-		if ( $this->definition->plugin_options['conditions'] ) {
170
-			foreach ( $this->definition->plugin_options['conditions'] as $condition ) {
169
+		if ($this->definition->plugin_options['conditions']) {
170
+			foreach ($this->definition->plugin_options['conditions'] as $condition) {
171 171
 				$contacts = array();
172
-				switch ( $condition['type'] ) {
172
+				switch ($condition['type']) {
173 173
 					// exists
174 174
 					case 'exists' :
175
-						if($record_array[$condition['string']]) {
176
-							$searchcondition = array( $condition['string'] => $record_array[$condition['string']]);
175
+						if ($record_array[$condition['string']]) {
176
+							$searchcondition = array($condition['string'] => $record_array[$condition['string']]);
177 177
 							// if we use account_id for the condition, we need to set the owner for filtering, as this
178 178
 							// enables addressbook_so to decide what backend is to be used
179
-							if ($condition['string']=='account_id') $searchcondition['owner']=0;
179
+							if ($condition['string'] == 'account_id') $searchcondition['owner'] = 0;
180 180
 							$contacts = $this->bocontacts->search(
181 181
 								//array( $condition['string'] => $record[$condition['string']],),
182 182
 								'',
@@ -185,37 +185,37 @@  discard block
 block discarded – undo
185 185
 								$searchcondition
186 186
 							);
187 187
 						}
188
-						if ( is_array( $contacts ) && count( array_keys( $contacts ) ) >= 1 ) {
188
+						if (is_array($contacts) && count(array_keys($contacts)) >= 1) {
189 189
 							// apply action to all contacts matching this exists condition
190 190
 							$action = $condition['true'];
191
-							foreach ( (array)$contacts as $contact ) {
191
+							foreach ((array)$contacts as $contact) {
192 192
 								$record->id = $contact['id'];
193
-								if ( $this->definition->plugin_options['update_cats'] == 'add' ) {
194
-									if ( !is_array( $contact['cat_id'] ) ) $contact['cat_id'] = explode( ',', $contact['cat_id'] );
195
-									if ( !is_array( $record_array['cat_id'] ) ) $record->cat_id = explode( ',', $record->cat_id );
196
-									$record->cat_id = implode( ',', array_unique( array_merge( $record->cat_id, $contact['cat_id'] ) ) );
193
+								if ($this->definition->plugin_options['update_cats'] == 'add') {
194
+									if (!is_array($contact['cat_id'])) $contact['cat_id'] = explode(',', $contact['cat_id']);
195
+									if (!is_array($record_array['cat_id'])) $record->cat_id = explode(',', $record->cat_id);
196
+									$record->cat_id = implode(',', array_unique(array_merge($record->cat_id, $contact['cat_id'])));
197 197
 								}
198
-								$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
198
+								$success = $this->action($action['action'], $record, $import_csv->get_current_position());
199 199
 							}
200 200
 						} else {
201 201
 							$action = $condition['false'];
202
-							$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
202
+							$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
203 203
 						}
204 204
 						break;
205 205
 					case 'equal':
206 206
 						// Match on field
207 207
 						$result = $this->equal($record, $condition, $matches);
208
-						if($result)
208
+						if ($result)
209 209
 						{
210 210
 							// Apply true action to any matching records found
211 211
 							$action = $condition['true'];
212
-							$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
212
+							$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
213 213
 						}
214 214
 						else
215 215
 						{
216 216
 							// Apply false action if no matching records found
217 217
 							$action = $condition['false'];
218
-							$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
218
+							$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
219 219
 						}
220 220
 						break;
221 221
 
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 			}
229 229
 		} else {
230 230
 			// unconditional insert
231
-			$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
231
+			$success = $this->action('insert', $record, $import_csv->get_current_position());
232 232
 		}
233 233
 		return $success;
234 234
 	}
@@ -240,21 +240,21 @@  discard block
 block discarded – undo
240 240
 	 * @param importexport_iface_egw_record $record contact data for the action
241 241
 	 * @return bool success or not
242 242
 	 */
243
-	protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) {
243
+	protected function action($_action, importexport_iface_egw_record&$record, $record_num = 0) {
244 244
 		$_data = $record->get_record_array();
245 245
 		switch ($_action) {
246 246
 			case 'none' :
247 247
 				return true;
248 248
 			case 'delete':
249
-				if($_data['id'])
249
+				if ($_data['id'])
250 250
 				{
251
-					if ( $this->dry_run ) {
251
+					if ($this->dry_run) {
252 252
 						//print_r($_data);
253 253
 						$this->results[$_action]++;
254 254
 						return true;
255 255
 					}
256 256
 					$result = $this->bocontacts->delete($_data);
257
-					if($result && $result === true)
257
+					if ($result && $result === true)
258 258
 					{
259 259
 						$this->results[$_action]++;
260 260
 					}
@@ -269,13 +269,13 @@  discard block
 block discarded – undo
269 269
 				// Only update if there are changes
270 270
 				$old = $this->bocontacts->read($_data['id']);
271 271
 				// if we get countrycodes as countryname, try to translate them -> the rest should be handled by bo classes.
272
-				foreach(array('adr_one_', 'adr_two_') as $c_prefix) {
273
-					if (strlen(trim($_data[$c_prefix.'countryname']))==2) $_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']),$translated=true);
272
+				foreach (array('adr_one_', 'adr_two_') as $c_prefix) {
273
+					if (strlen(trim($_data[$c_prefix.'countryname'])) == 2) $_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']), $translated = true);
274 274
 				}
275 275
 				// Don't change a user account into a contact
276
-				if($old['owner'] == 0) {
276
+				if ($old['owner'] == 0) {
277 277
 					unset($_data['owner']);
278
-				} elseif(!$this->definition->plugin_options['change_owner']) {
278
+				} elseif (!$this->definition->plugin_options['change_owner']) {
279 279
 					// Don't change addressbook of an existing contact
280 280
 					unset($_data['owner']);
281 281
 				}
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 				// Merge to deal with fields not in import record
284 284
 				$_data = array_merge($old, $_data);
285 285
 				$changed = $this->tracking->changed_fields($_data, $old);
286
-				if(count($changed) == 0) {
286
+				if (count($changed) == 0) {
287 287
 					return true;
288 288
 				} else {
289 289
 					//error_log(__METHOD__.__LINE__.array2string($changed).' Old:'.$old['adr_one_countryname'].' ('.$old['adr_one_countrycode'].') New:'.$_data['adr_one_countryname'].' ('.$_data['adr_one_countryname'].')');
@@ -294,22 +294,22 @@  discard block
 block discarded – undo
294 294
 
295 295
 				// Fall through
296 296
 			case 'insert' :
297
-				if($_action == 'insert') {
297
+				if ($_action == 'insert') {
298 298
 					// Addressbook backend doesn't like inserting with ID specified, it screws up the owner & etag
299 299
 					unset($_data['id']);
300 300
 				}
301
-				if(!isset($_data['org_name'])) {
301
+				if (!isset($_data['org_name'])) {
302 302
 					// org_name is a trigger to update n_fileas
303 303
 					$_data['org_name'] = '';
304 304
 				}
305 305
 
306
-				if ( $this->dry_run ) {
306
+				if ($this->dry_run) {
307 307
 					//print_r($_data);
308 308
 					$this->results[$_action]++;
309 309
 					return true;
310 310
 				} else {
311
-					$result = $this->bocontacts->save( $_data, $this->is_admin);
312
-					if(!$result) {
311
+					$result = $this->bocontacts->save($_data, $this->is_admin);
312
+					if (!$result) {
313 313
 						$this->errors[$record_num] = $this->bocontacts->error;
314 314
 					} else {
315 315
 						$this->results[$_action]++;
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 					return $result;
320 320
 				}
321 321
 			default:
322
-				throw new egw_exception('Unsupported action: '. $_action);
322
+				throw new egw_exception('Unsupported action: '.$_action);
323 323
 			
324 324
 		}
325 325
 	}
Please login to merge, or discard this patch.
Braces   +127 added lines, -51 removed lines patch added patch discarded remove patch
@@ -14,7 +14,8 @@  discard block
 block discarded – undo
14 14
 /**
15 15
  * class import_csv for addressbook
16 16
  */
17
-class addressbook_import_contacts_csv extends importexport_basic_import_csv  {
17
+class addressbook_import_contacts_csv extends importexport_basic_import_csv
18
+{
18 19
 
19 20
 	/**
20 21
 	 * conditions for actions
@@ -45,7 +46,8 @@  discard block
 block discarded – undo
45 46
 	 * @param string $_charset
46 47
 	 * @param definition $_definition
47 48
 	 */
48
-	public function init(importexport_definition &$_definition ) {
49
+	public function init(importexport_definition &$_definition )
50
+	{
49 51
 
50 52
 		// fetch the addressbook bo
51 53
 		$this->bocontacts = new addressbook_bo();
@@ -87,22 +89,29 @@  discard block
 block discarded – undo
87 89
 	{
88 90
 
89 91
 		// Set owner, unless it's supposed to come from CSV file
90
-		if($this->definition->plugin_options['owner_from_csv'] && $record->owner) {
91
-			if(!is_numeric($record->owner)) {
92
+		if($this->definition->plugin_options['owner_from_csv'] && $record->owner)
93
+		{
94
+			if(!is_numeric($record->owner))
95
+			{
92 96
 				// Automatically handle text owner without explicit translation
93 97
 				$new_owner = importexport_helper_functions::account_name2id($record->owner);
94
-				if($new_owner == '') {
98
+				if($new_owner == '')
99
+				{
95 100
 					$this->errors[$import_csv->get_current_position()] = lang(
96 101
 						'Unable to convert "%1" to account ID.  Using plugin setting (%2) for owner.',
97 102
 						$record->owner,
98 103
 						common::grab_owner_name($this->user)
99 104
 					);
100 105
 					$record->owner = $this->user;
101
-				} else {
106
+				}
107
+				else
108
+				{
102 109
 					$record->owner = $new_owner;
103 110
 				}
104 111
 			}
105
-		} else {
112
+		}
113
+		else
114
+		{
106 115
 			$record->owner = $this->user;
107 116
 		}
108 117
 
@@ -138,26 +147,41 @@  discard block
 block discarded – undo
138 147
 		// Also handle categories in their own field
139 148
 		$record_array = $record->get_record_array();
140 149
 		$more_categories = array();
141
-		foreach($this->definition->plugin_options['field_mapping'] as $number => $field_name) {
150
+		foreach($this->definition->plugin_options['field_mapping'] as $number => $field_name)
151
+		{
142 152
 			if(!array_key_exists($field_name, $record_array) ||
143
-				substr($field_name,0,3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') continue;
153
+				substr($field_name,0,3) != 'cat' || !$record->$field_name || $field_name == 'cat_id')
154
+			{
155
+				continue;
156
+			}
144 157
 			list($cat, $cat_id) = explode('-', $field_name);
145
-			if(is_numeric($record->$field_name) && $record->$field_name != 1) {
158
+			if(is_numeric($record->$field_name) && $record->$field_name != 1)
159
+			{
146 160
 				// Column has a single category ID
147 161
 				$more_categories[] = $record->$field_name;
148
-			} elseif($record->$field_name == '1' ||
149
-				(!is_numeric($record->$field_name) && strtolower($record->$field_name) == strtolower(lang('Yes')))) {
162
+			}
163
+			elseif($record->$field_name == '1' ||
164
+				(!is_numeric($record->$field_name) && strtolower($record->$field_name) == strtolower(lang('Yes'))))
165
+			{
150 166
 				// Each category got its own column.  '1' is the database value, lang('yes') is the human value
151 167
 				$more_categories[] = $cat_id;
152
-			} else {
168
+			}
169
+			else
170
+			{
153 171
 				// Text categories
154 172
 				$more_categories = array_merge($more_categories, importexport_helper_functions::cat_name2id(is_array($record->$field_name) ? $record->$field_name : explode(',',$record->$field_name), $cat_id));
155 173
 			}
156 174
 		}
157
-		if(count($more_categories) > 0) $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',',$record->cat_id), $more_categories);
175
+		if(count($more_categories) > 0)
176
+		{
177
+			$record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',',$record->cat_id), $more_categories);
178
+		}
158 179
 
159 180
 		// Private set but missing causes hidden entries
160
-		if(array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) unset($record->private);
181
+		if(array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == ''))
182
+		{
183
+			unset($record->private);
184
+		}
161 185
 
162 186
 		// Format birthday as backend requires - converter should give timestamp
163 187
 		if($record->bday && is_numeric($record->bday))
@@ -166,17 +190,24 @@  discard block
 block discarded – undo
166 190
 			$record->bday = $time->format('Y-m-d');
167 191
 		}
168 192
 
169
-		if ( $this->definition->plugin_options['conditions'] ) {
170
-			foreach ( $this->definition->plugin_options['conditions'] as $condition ) {
193
+		if ( $this->definition->plugin_options['conditions'] )
194
+		{
195
+			foreach ( $this->definition->plugin_options['conditions'] as $condition )
196
+			{
171 197
 				$contacts = array();
172
-				switch ( $condition['type'] ) {
198
+				switch ( $condition['type'] )
199
+				{
173 200
 					// exists
174 201
 					case 'exists' :
175
-						if($record_array[$condition['string']]) {
202
+						if($record_array[$condition['string']])
203
+						{
176 204
 							$searchcondition = array( $condition['string'] => $record_array[$condition['string']]);
177 205
 							// if we use account_id for the condition, we need to set the owner for filtering, as this
178 206
 							// enables addressbook_so to decide what backend is to be used
179
-							if ($condition['string']=='account_id') $searchcondition['owner']=0;
207
+							if ($condition['string']=='account_id')
208
+							{
209
+								$searchcondition['owner']=0;
210
+							}
180 211
 							$contacts = $this->bocontacts->search(
181 212
 								//array( $condition['string'] => $record[$condition['string']],),
182 213
 								'',
@@ -185,19 +216,30 @@  discard block
 block discarded – undo
185 216
 								$searchcondition
186 217
 							);
187 218
 						}
188
-						if ( is_array( $contacts ) && count( array_keys( $contacts ) ) >= 1 ) {
219
+						if ( is_array( $contacts ) && count( array_keys( $contacts ) ) >= 1 )
220
+						{
189 221
 							// apply action to all contacts matching this exists condition
190 222
 							$action = $condition['true'];
191
-							foreach ( (array)$contacts as $contact ) {
223
+							foreach ( (array)$contacts as $contact )
224
+							{
192 225
 								$record->id = $contact['id'];
193
-								if ( $this->definition->plugin_options['update_cats'] == 'add' ) {
194
-									if ( !is_array( $contact['cat_id'] ) ) $contact['cat_id'] = explode( ',', $contact['cat_id'] );
195
-									if ( !is_array( $record_array['cat_id'] ) ) $record->cat_id = explode( ',', $record->cat_id );
226
+								if ( $this->definition->plugin_options['update_cats'] == 'add' )
227
+								{
228
+									if ( !is_array( $contact['cat_id'] ) )
229
+									{
230
+										$contact['cat_id'] = explode( ',', $contact['cat_id'] );
231
+									}
232
+									if ( !is_array( $record_array['cat_id'] ) )
233
+									{
234
+										$record->cat_id = explode( ',', $record->cat_id );
235
+									}
196 236
 									$record->cat_id = implode( ',', array_unique( array_merge( $record->cat_id, $contact['cat_id'] ) ) );
197 237
 								}
198 238
 								$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
199 239
 							}
200
-						} else {
240
+						}
241
+						else
242
+						{
201 243
 							$action = $condition['false'];
202 244
 							$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
203 245
 						}
@@ -224,9 +266,14 @@  discard block
 block discarded – undo
224 266
 						die('condition / action not supported!!!');
225 267
 						break;
226 268
 				}
227
-				if ($action['stop']) break;
269
+				if ($action['stop'])
270
+				{
271
+					break;
272
+				}
228 273
 			}
229
-		} else {
274
+		}
275
+		else
276
+		{
230 277
 			// unconditional insert
231 278
 			$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
232 279
 		}
@@ -240,15 +287,18 @@  discard block
 block discarded – undo
240 287
 	 * @param importexport_iface_egw_record $record contact data for the action
241 288
 	 * @return bool success or not
242 289
 	 */
243
-	protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) {
290
+	protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 )
291
+	{
244 292
 		$_data = $record->get_record_array();
245
-		switch ($_action) {
293
+		switch ($_action)
294
+		{
246 295
 			case 'none' :
247 296
 				return true;
248 297
 			case 'delete':
249 298
 				if($_data['id'])
250 299
 				{
251
-					if ( $this->dry_run ) {
300
+					if ( $this->dry_run )
301
+					{
252 302
 						//print_r($_data);
253 303
 						$this->results[$_action]++;
254 304
 						return true;
@@ -269,13 +319,20 @@  discard block
 block discarded – undo
269 319
 				// Only update if there are changes
270 320
 				$old = $this->bocontacts->read($_data['id']);
271 321
 				// if we get countrycodes as countryname, try to translate them -> the rest should be handled by bo classes.
272
-				foreach(array('adr_one_', 'adr_two_') as $c_prefix) {
273
-					if (strlen(trim($_data[$c_prefix.'countryname']))==2) $_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']),$translated=true);
322
+				foreach(array('adr_one_', 'adr_two_') as $c_prefix)
323
+				{
324
+					if (strlen(trim($_data[$c_prefix.'countryname']))==2)
325
+					{
326
+						$_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']),$translated=true);
327
+					}
274 328
 				}
275 329
 				// Don't change a user account into a contact
276
-				if($old['owner'] == 0) {
330
+				if($old['owner'] == 0)
331
+				{
277 332
 					unset($_data['owner']);
278
-				} elseif(!$this->definition->plugin_options['change_owner']) {
333
+				}
334
+				elseif(!$this->definition->plugin_options['change_owner'])
335
+				{
279 336
 					// Don't change addressbook of an existing contact
280 337
 					unset($_data['owner']);
281 338
 				}
@@ -283,9 +340,12 @@  discard block
 block discarded – undo
283 340
 				// Merge to deal with fields not in import record
284 341
 				$_data = array_merge($old, $_data);
285 342
 				$changed = $this->tracking->changed_fields($_data, $old);
286
-				if(count($changed) == 0) {
343
+				if(count($changed) == 0)
344
+				{
287 345
 					return true;
288
-				} else {
346
+				}
347
+				else
348
+				{
289 349
 					//error_log(__METHOD__.__LINE__.array2string($changed).' Old:'.$old['adr_one_countryname'].' ('.$old['adr_one_countrycode'].') New:'.$_data['adr_one_countryname'].' ('.$_data['adr_one_countryname'].')');
290 350
 				}
291 351
 				
@@ -294,24 +354,32 @@  discard block
 block discarded – undo
294 354
 
295 355
 				// Fall through
296 356
 			case 'insert' :
297
-				if($_action == 'insert') {
357
+				if($_action == 'insert')
358
+				{
298 359
 					// Addressbook backend doesn't like inserting with ID specified, it screws up the owner & etag
299 360
 					unset($_data['id']);
300 361
 				}
301
-				if(!isset($_data['org_name'])) {
362
+				if(!isset($_data['org_name']))
363
+				{
302 364
 					// org_name is a trigger to update n_fileas
303 365
 					$_data['org_name'] = '';
304 366
 				}
305 367
 
306
-				if ( $this->dry_run ) {
368
+				if ( $this->dry_run )
369
+				{
307 370
 					//print_r($_data);
308 371
 					$this->results[$_action]++;
309 372
 					return true;
310
-				} else {
373
+				}
374
+				else
375
+				{
311 376
 					$result = $this->bocontacts->save( $_data, $this->is_admin);
312
-					if(!$result) {
377
+					if(!$result)
378
+					{
313 379
 						$this->errors[$record_num] = $this->bocontacts->error;
314
-					} else {
380
+					}
381
+					else
382
+					{
315 383
 						$this->results[$_action]++;
316 384
 						// This does nothing (yet?) but update the identifier
317 385
 						$record->save($result);
@@ -329,7 +397,8 @@  discard block
 block discarded – undo
329 397
 	 *
330 398
 	 * @return string name
331 399
 	 */
332
-	public static function get_name() {
400
+	public static function get_name()
401
+	{
333 402
 		return lang('Addressbook CSV import');
334 403
 	}
335 404
 
@@ -338,7 +407,8 @@  discard block
 block discarded – undo
338 407
 	 *
339 408
 	 * @return string descriprion
340 409
 	 */
341
-	public static function get_description() {
410
+	public static function get_description()
411
+	{
342 412
 		return lang("Imports contacts into your Addressbook from a CSV File. CSV means 'Comma Seperated Values'. However in the options Tab you can also choose other seperators.");
343 413
 	}
344 414
 
@@ -347,7 +417,8 @@  discard block
 block discarded – undo
347 417
 	 *
348 418
 	 * @return string suffix (comma seperated)
349 419
 	 */
350
-	public static function get_filesuffix() {
420
+	public static function get_filesuffix()
421
+	{
351 422
 		return 'csv';
352 423
 	}
353 424
 
@@ -363,7 +434,8 @@  discard block
 block discarded – undo
363 434
 	 * 		preserv		=> array,
364 435
 	 * )
365 436
 	 */
366
-	public function get_options_etpl() {
437
+	public function get_options_etpl()
438
+	{
367 439
 		// lets do it!
368 440
 	}
369 441
 
@@ -372,7 +444,8 @@  discard block
 block discarded – undo
372 444
 	 *
373 445
 	 * @return string etemplate name
374 446
 	 */
375
-	public function get_selectors_etpl() {
447
+	public function get_selectors_etpl()
448
+	{
376 449
 		// lets do it!
377 450
 	}
378 451
 
@@ -384,7 +457,8 @@  discard block
 block discarded – undo
384 457
         *       record_# => warning message
385 458
         *       )
386 459
         */
387
-        public function get_warnings() {
460
+        public function get_warnings()
461
+        {
388 462
 		return $this->warnings;
389 463
 	}
390 464
 
@@ -396,7 +470,8 @@  discard block
 block discarded – undo
396 470
         *       record_# => error message
397 471
         *       )
398 472
         */
399
-        public function get_errors() {
473
+        public function get_errors()
474
+        {
400 475
 		return $this->errors;
401 476
 	}
402 477
 
@@ -408,7 +483,8 @@  discard block
 block discarded – undo
408 483
         *       action => record count
409 484
         * )
410 485
         */
411
-        public function get_results() {
486
+        public function get_results()
487
+        {
412 488
                 return $this->results;
413 489
         }
414 490
 } // end of iface_export_plugin
Please login to merge, or discard this patch.
admin/inc/class.admin_accesslog.inc.php 3 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -255,11 +255,10 @@
 block discarded – undo
255 255
 	 *
256 256
 	 * @param type $action
257 257
 	 * @param type $checked
258
-	 * @param type $use_all
259 258
 	 * @param type $success
260 259
 	 * @param int $failed
261 260
 	 * @param type $action_msg
262
-	 * @return type number of failed
261
+	 * @return boolean number of failed
263 262
 	 */
264 263
 	function action($action,$checked,&$success,&$failed,&$action_msg)
265 264
 	{
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	function __construct()
49 49
 	{
50
-		$this->so = new so_sql(self::APP,self::TABLE,null,'',true);
50
+		$this->so = new so_sql(self::APP, self::TABLE, null, '', true);
51 51
 		$this->so->timestamps = array('li', 'lo', 'session_dla', 'notification_heartbeat');
52 52
 	}
53 53
 
@@ -60,19 +60,19 @@  discard block
 block discarded – undo
60 60
 	 * @param array &$readonlys eg. to disable buttons based on acl, not use here, maybe in a derived class
61 61
 	 * @return int total number of rows
62 62
 	 */
63
-	function get_rows($query,&$rows,&$readonlys)
63
+	function get_rows($query, &$rows, &$readonlys)
64 64
 	{
65 65
 		$heartbeat_limit = egw_session::heartbeat_limit();
66 66
 
67 67
 		if ($query['session_list'])	// filter active sessions
68 68
 		{
69
-			$query['col_filter']['lo'] = null;	// not logged out
69
+			$query['col_filter']['lo'] = null; // not logged out
70 70
 			$query['col_filter'][0] = 'session_dla > '.(int)(time() - $GLOBALS['egw_info']['server']['sessions_timeout']);
71
-			switch((string)$query['session_list'])
71
+			switch ((string)$query['session_list'])
72 72
 			{
73 73
 				case 'active':	// remove status != 'active', eg. CalDAV/eSync
74 74
 					$query['col_filter'][1] = "notification_heartbeat > $heartbeat_limit";
75
-					$query['col_filter'][3] = "session_php NOT LIKE '% %'";	// remove blocked, bad login, etc
75
+					$query['col_filter'][3] = "session_php NOT LIKE '% %'"; // remove blocked, bad login, etc
76 76
 					break;
77 77
 				default:
78 78
 					$query['col_filter'][1] = "(notification_heartbeat IS NULL OR notification_heartbeat > $heartbeat_limit)";
@@ -80,20 +80,20 @@  discard block
 block discarded – undo
80 80
 			}
81 81
 			$query['col_filter'][2] = 'account_id>0';
82 82
 		}
83
-		$total = $this->so->get_rows($query,$rows,$readonlys);
83
+		$total = $this->so->get_rows($query, $rows, $readonlys);
84 84
 
85 85
 		$heartbeat_limit_user = egw_time::server2user($heartbeat_limit, 'ts');
86 86
 
87
-		foreach($rows as &$row)
87
+		foreach ($rows as &$row)
88 88
 		{
89 89
 			$row['sessionstatus'] = 'success';
90 90
 			if ($row['notification_heartbeat'] > $heartbeat_limit_user)
91 91
 			{
92 92
 				$row['sessionstatus'] = 'active';
93 93
 			}
94
-			if (stripos($row['session_php'],'blocked') !== false ||
95
-				stripos($row['session_php'],'bad login') !== false ||
96
-				strpos($row['session_php'],' ') !== false)
94
+			if (stripos($row['session_php'], 'blocked') !== false ||
95
+				stripos($row['session_php'], 'bad login') !== false ||
96
+				strpos($row['session_php'], ' ') !== false)
97 97
 			{
98 98
 				$row['sessionstatus'] = $row['session_php'];
99 99
 			}
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 				$row['sessionstatus'] = 'logged out';
103 103
 			}
104 104
 			// eg. for bad login or password
105
-			if (!$row['account_id']) $row['alt_loginid'] = ($row['loginid']?$row['loginid']:lang('none'));
105
+			if (!$row['account_id']) $row['alt_loginid'] = ($row['loginid'] ? $row['loginid'] : lang('none'));
106 106
 
107 107
 			// do not allow to kill or select own session
108 108
 			if ($GLOBALS['egw']->session->sessionid_access_log == $row['sessionid'] && $query['session_list'])
@@ -110,13 +110,13 @@  discard block
 block discarded – undo
110 110
 				$row['class'] .= ' rowNoDelete ';
111 111
 			}
112 112
 			// do not allow to delete access log off active sessions
113
-			if (!$row['lo'] && $row['session_dla'] > time()-$GLOBALS['egw_info']['server']['sessions_timeout'] &&
113
+			if (!$row['lo'] && $row['session_dla'] > time() - $GLOBALS['egw_info']['server']['sessions_timeout'] &&
114 114
 				in_array($row['sessionstatus'], array('active', 'success')) && !$query['session_list'])
115 115
 			{
116 116
 				$row['class'] .= ' rowNoDelete ';
117 117
 			}
118 118
 			$row['sessionstatus'] = lang($row['sessionstatus']);
119
-			unset($row['session_php']);	// for security reasons, do NOT give real PHP sessionid to UI
119
+			unset($row['session_php']); // for security reasons, do NOT give real PHP sessionid to UI
120 120
 		}
121 121
 		if ($query['session_list'])
122 122
 		{
@@ -136,33 +136,33 @@  discard block
 block discarded – undo
136 136
 	 * @param string $msg =''
137 137
 	 * @param boolean $sessions_list =false
138 138
 	 */
139
-	function index(array $content=null, $msg='', $sessions_list=false)
139
+	function index(array $content = null, $msg = '', $sessions_list = false)
140 140
 	{
141 141
 
142 142
 		if (is_array($content)) $sessions_list = $content['nm']['session_list'];
143 143
 
144 144
 		// check if user has access to requested functionality
145
-		if ($GLOBALS['egw']->acl->check($sessions_list ? 'current_sessions' : 'access_log_acces',1,'admin'))
145
+		if ($GLOBALS['egw']->acl->check($sessions_list ? 'current_sessions' : 'access_log_acces', 1, 'admin'))
146 146
 		{
147 147
 			$GLOBALS['egw']->redirect_link('/index.php');
148 148
 		}
149 149
 
150
-		if(!isset($content))
150
+		if (!isset($content))
151 151
 		{
152 152
 			$content['nm'] = array(
153
-				'get_rows'       =>	'admin.admin_accesslog.get_rows',	// I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
154
-				'no_filter'      => True,	// I  disable the 1. filter
155
-				'no_filter2'     => True,	// I  disable the 2. filter (params are the same as for filter)
156
-				'no_cat'         => True,	// I  disable the cat-selectbox
157
-				'header_left'    =>	false,	// I  template to show left of the range-value, left-aligned (optional)
158
-				'header_right'   =>	false,	// I  template to show right of the range-value, right-aligned (optional)
159
-				'never_hide'     => True,	// I  never hide the nextmatch-line if less then maxmatch entries
160
-				'lettersearch'   => false,	// I  show a lettersearch
161
-				'start'          =>	0,		// IO position in list
162
-				'order'          =>	'li',	// IO name of the column to sort after (optional for the sortheaders)
163
-				'sort'           =>	'DESC',	// IO direction of the sort: 'ASC' or 'DESC'
153
+				'get_rows'       =>	'admin.admin_accesslog.get_rows', // I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
154
+				'no_filter'      => True, // I  disable the 1. filter
155
+				'no_filter2'     => True, // I  disable the 2. filter (params are the same as for filter)
156
+				'no_cat'         => True, // I  disable the cat-selectbox
157
+				'header_left'    =>	false, // I  template to show left of the range-value, left-aligned (optional)
158
+				'header_right'   =>	false, // I  template to show right of the range-value, right-aligned (optional)
159
+				'never_hide'     => True, // I  never hide the nextmatch-line if less then maxmatch entries
160
+				'lettersearch'   => false, // I  show a lettersearch
161
+				'start'          =>	0, // IO position in list
162
+				'order'          =>	'li', // IO name of the column to sort after (optional for the sortheaders)
163
+				'sort'           =>	'DESC', // IO direction of the sort: 'ASC' or 'DESC'
164 164
 				//'default_cols'   => 	// I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
165
-				'csv_fields'     =>	false,	// I  false=disable csv export, true or unset=enable it with auto-detected fieldnames,
165
+				'csv_fields'     =>	false, // I  false=disable csv export, true or unset=enable it with auto-detected fieldnames,
166 166
 								//or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type)
167 167
 				'actions'		=> $this->get_actions($sessions_list),
168 168
 				'placeholder_actions' => false,
@@ -193,12 +193,12 @@  discard block
 block discarded – undo
193 193
 					'col_filter' => $content['nm']['col_filter']
194 194
 				);
195 195
 
196
-				@set_time_limit(0);			// switch off the execution time limit, as it's for big selections to small
197
-				$query['num_rows'] = -1;	// all
196
+				@set_time_limit(0); // switch off the execution time limit, as it's for big selections to small
197
+				$query['num_rows'] = -1; // all
198 198
 				$all = $readonlys = array();
199
-				$this->get_rows($query,$all,$readonlys);
199
+				$this->get_rows($query, $all, $readonlys);
200 200
 				$content['nm']['selected'] = array();
201
-				foreach($all as $session)
201
+				foreach ($all as $session)
202 202
 				{
203 203
 					$content['nm']['selected'][] = $session[$content['nm']['row_id']];
204 204
 				}
@@ -210,19 +210,19 @@  discard block
 block discarded – undo
210 210
 			else
211 211
 			{
212 212
 				$success = $failed = $action = $action_msg = null;
213
-				if ($this->action($content['nm']['action'],$content['nm']['selected']
214
-					,$success,$failed,$action_msg,$msg))
213
+				if ($this->action($content['nm']['action'], $content['nm']['selected']
214
+					,$success, $failed, $action_msg, $msg))
215 215
 				{ // In case of action success
216 216
 					switch ($action_msg)
217 217
 					{
218 218
 						case'deleted':
219
-							$msg = lang('%1 log entries deleted.',$success);
219
+							$msg = lang('%1 log entries deleted.', $success);
220 220
 							break;
221 221
 						case'killed':
222
-							$msg = lang('%1 sessions killed',$success);
222
+							$msg = lang('%1 sessions killed', $success);
223 223
 					}
224 224
 				}
225
-				elseif($failed) // In case of action failiure
225
+				elseif ($failed) // In case of action failiure
226 226
 				{
227 227
 					switch ($action_msg)
228 228
 					{
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 		$content['msg'] = $msg;
240 240
 		$content['percent'] = 100.0 * $GLOBALS['egw']->db->query(
241 241
 			'SELECT ((SELECT COUNT(*) FROM '.self::TABLE.' WHERE lo != 0) / COUNT(*)) FROM '.self::TABLE,
242
-			__LINE__,__FILE__)->fetchColumn();
242
+			__LINE__, __FILE__)->fetchColumn();
243 243
 
244 244
 		$tmpl = new etemplate_new('admin.accesslog');
245 245
 		$tmpl->exec('admin.admin_accesslog.index', $content, array(), $readonlys, array(
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 	 * @param type $action_msg
259 259
 	 * @return type number of failed
260 260
 	 */
261
-	function action($action,$checked,&$success,&$failed,&$action_msg)
261
+	function action($action, $checked, &$success, &$failed, &$action_msg)
262 262
 	{
263 263
 		$success = $failed = 0;
264 264
 		//error_log(__METHOD__.'selected:' . array2string($checked). 'action:' . $action);
@@ -266,14 +266,14 @@  discard block
 block discarded – undo
266 266
 		{
267 267
 			case "delete":
268 268
 				$action_msg = "deleted";
269
-				$del_msg= $this->so->delete(array('sessionid' => $checked));
269
+				$del_msg = $this->so->delete(array('sessionid' => $checked));
270 270
 				if ($checked && $del_msg)
271 271
 				{
272 272
 					$success = $del_msg;
273 273
 				}
274 274
 				else
275 275
 				{
276
-					$failed ++;
276
+					$failed++;
277 277
 				}
278 278
 				break;
279 279
 			case "kill":
@@ -281,19 +281,19 @@  discard block
 block discarded – undo
281 281
 				$sessionid = $checked;
282 282
 				if (($key = array_search($GLOBALS['egw']->session->sessionid_access_log, $sessionid)))
283 283
 				{
284
-						unset($sessionid[$key]);	// dont allow to kill own sessions
284
+						unset($sessionid[$key]); // dont allow to kill own sessions
285 285
 				}
286
-				if ($GLOBALS['egw']->acl->check('current_sessions',8,'admin'))
286
+				if ($GLOBALS['egw']->acl->check('current_sessions', 8, 'admin'))
287 287
 				{
288
-					$failed ++;
288
+					$failed++;
289 289
 				}
290 290
 				else
291 291
 				{
292
-					foreach((array)$sessionid as $id)
292
+					foreach ((array)$sessionid as $id)
293 293
 					{
294 294
 						$GLOBALS['egw']->session->destroy($id);
295 295
 					}
296
-					$success= count($sessionid);
296
+					$success = count($sessionid);
297 297
 				}
298 298
 				break;
299 299
 		}
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 		if ($sessions_list)
314 314
 		{
315 315
 		//	error_log(__METHOD__. $sessions_list);
316
-			$actions= array(
316
+			$actions = array(
317 317
 				'kill' => array(
318 318
 					'caption' => 'Kill',
319 319
 					'confirm' => 'Kill this session',
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 		}
327 327
 		else
328 328
 		{
329
-			$actions= array(
329
+			$actions = array(
330 330
 				'delete' => array(
331 331
 					'caption' => 'Delete',
332 332
 					'confirm' => 'Delete this entry',
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 	 * @param array $content =null
359 359
 	 * @param string $msg =''
360 360
 	 */
361
-	function sessions(array $content=null, $msg='')
361
+	function sessions(array $content = null, $msg = '')
362 362
 	{
363 363
 		return $this->index($content, $msg, true);
364 364
 	}
Please login to merge, or discard this patch.
Braces   +22 added lines, -7 removed lines patch added patch discarded remove patch
@@ -64,9 +64,13 @@  discard block
 block discarded – undo
64 64
 	{
65 65
 		$heartbeat_limit = egw_session::heartbeat_limit();
66 66
 
67
-		if ($query['session_list'])	// filter active sessions
67
+		if ($query['session_list'])
68
+		{
69
+			// filter active sessions
68 70
 		{
69
-			$query['col_filter']['lo'] = null;	// not logged out
71
+			$query['col_filter']['lo'] = null;
72
+		}
73
+		// not logged out
70 74
 			$query['col_filter'][0] = 'session_dla > '.(int)(time() - $GLOBALS['egw_info']['server']['sessions_timeout']);
71 75
 			switch((string)$query['session_list'])
72 76
 			{
@@ -97,12 +101,16 @@  discard block
 block discarded – undo
97 101
 			{
98 102
 				$row['sessionstatus'] = $row['session_php'];
99 103
 			}
100
-			if ($row['lo']) {
104
+			if ($row['lo'])
105
+			{
101 106
 				$row['total'] = ($row['lo'] - $row['li']) / 60;
102 107
 				$row['sessionstatus'] = 'logged out';
103 108
 			}
104 109
 			// eg. for bad login or password
105
-			if (!$row['account_id']) $row['alt_loginid'] = ($row['loginid']?$row['loginid']:lang('none'));
110
+			if (!$row['account_id'])
111
+			{
112
+				$row['alt_loginid'] = ($row['loginid']?$row['loginid']:lang('none'));
113
+			}
106 114
 
107 115
 			// do not allow to kill or select own session
108 116
 			if ($GLOBALS['egw']->session->sessionid_access_log == $row['sessionid'] && $query['session_list'])
@@ -139,7 +147,10 @@  discard block
 block discarded – undo
139 147
 	function index(array $content=null, $msg='', $sessions_list=false)
140 148
 	{
141 149
 
142
-		if (is_array($content)) $sessions_list = $content['nm']['session_list'];
150
+		if (is_array($content))
151
+		{
152
+			$sessions_list = $content['nm']['session_list'];
153
+		}
143 154
 
144 155
 		// check if user has access to requested functionality
145 156
 		if ($GLOBALS['egw']->acl->check($sessions_list ? 'current_sessions' : 'access_log_acces',1,'admin'))
@@ -212,7 +223,8 @@  discard block
 block discarded – undo
212 223
 				$success = $failed = $action = $action_msg = null;
213 224
 				if ($this->action($content['nm']['action'],$content['nm']['selected']
214 225
 					,$success,$failed,$action_msg,$msg))
215
-				{ // In case of action success
226
+				{
227
+// In case of action success
216 228
 					switch ($action_msg)
217 229
 					{
218 230
 						case'deleted':
@@ -222,12 +234,15 @@  discard block
 block discarded – undo
222 234
 							$msg = lang('%1 sessions killed',$success);
223 235
 					}
224 236
 				}
225
-				elseif($failed) // In case of action failiure
237
+				elseif($failed)
238
+				{
239
+					// In case of action failiure
226 240
 				{
227 241
 					switch ($action_msg)
228 242
 					{
229 243
 						case'deleted':
230 244
 							$msg = lang('Error deleting log entry!');
245
+				}
231 246
 							break;
232 247
 						case'killed':
233 248
 							$msg = lang('Permission denied!');
Please login to merge, or discard this patch.
admin/inc/class.admin_categories.inc.php 3 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -679,6 +679,8 @@
 block discarded – undo
679 679
 	 * @param int &$failed number of failed actions (not enought permissions)
680 680
 	 * @param string &$action_msg translated verb for the actions, to be used in a message like '%1 entries deleted'
681 681
 	 * @param array $query get_rows parameter
682
+	 * @param integer $success
683
+	 * @param integer $failed
682 684
 	 * @return boolean true if all actions succeded, false otherwise
683 685
 	 */
684 686
 	function action($_action, $checked, $use_all, &$success, &$failed, &$action_msg, array $query)
Please login to merge, or discard this patch.
Spacing   +127 added lines, -128 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		{
58 58
 			throw new egw_exception_no_permission_admin();
59 59
 		}
60
-		if ($GLOBALS['egw']->acl->check('global_categorie',1,'admin'))
60
+		if ($GLOBALS['egw']->acl->check('global_categorie', 1, 'admin'))
61 61
 		{
62 62
 			$GLOBALS['egw']->redirect_link('/index.php');
63 63
 		}
@@ -71,12 +71,12 @@  discard block
 block discarded – undo
71 71
 	{
72 72
 		if (is_null(self::$acl_search))
73 73
 		{
74
-			self::$acl_search = !$GLOBALS['egw']->acl->check('global_categorie',2,'admin');
75
-			self::$acl_add    = !$GLOBALS['egw']->acl->check('global_categorie',4,'admin');
76
-			self::$acl_view   = !$GLOBALS['egw']->acl->check('global_categorie',8,'admin');
77
-			self::$acl_edit   = !$GLOBALS['egw']->acl->check('global_categorie',16,'admin');
78
-			self::$acl_delete = !$GLOBALS['egw']->acl->check('global_categorie',32,'admin');
79
-			self::$acl_add_sub= !$GLOBALS['egw']->acl->check('global_categorie',64,'admin');
74
+			self::$acl_search = !$GLOBALS['egw']->acl->check('global_categorie', 2, 'admin');
75
+			self::$acl_add    = !$GLOBALS['egw']->acl->check('global_categorie', 4, 'admin');
76
+			self::$acl_view   = !$GLOBALS['egw']->acl->check('global_categorie', 8, 'admin');
77
+			self::$acl_edit   = !$GLOBALS['egw']->acl->check('global_categorie', 16, 'admin');
78
+			self::$acl_delete = !$GLOBALS['egw']->acl->check('global_categorie', 32, 'admin');
79
+			self::$acl_add_sub = !$GLOBALS['egw']->acl->check('global_categorie', 64, 'admin');
80 80
 		}
81 81
 	}
82 82
 
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
86 86
 	 * @param array $content = null
87 87
 	 * @param string $msg = ''
88 88
 	 */
89
-	public function edit(array $content=null,$msg='')
89
+	public function edit(array $content = null, $msg = '')
90 90
 	{
91 91
 		// read the session, as the global_cats param is stored with it.
92
-		$appname = $content['appname'] ? $content['appname'] : ($_GET['appname']?$_GET['appname']:categories::GLOBAL_APPNAME);
93
-		$session = egw_cache::getSession(__CLASS__.$appname,'nm');
92
+		$appname = $content['appname'] ? $content['appname'] : ($_GET['appname'] ? $_GET['appname'] : categories::GLOBAL_APPNAME);
93
+		$session = egw_cache::getSession(__CLASS__.$appname, 'nm');
94 94
 		unset($session);
95 95
 		if (!isset($content))
96 96
 		{
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 				($content = categories::read($_GET['cat_id']))))
99 99
 			{
100 100
 				$content = array('data' => array());
101
-				if(isset($_GET['parent']) && $_GET['parent'] > 0)
101
+				if (isset($_GET['parent']) && $_GET['parent'] > 0)
102 102
 				{
103 103
 					// Sub-category - set some defaults from parent
104 104
 					$content['parent'] = (int)$_GET['parent'];
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 					$appname = categories::GLOBAL_APPNAME;
115 115
 				}
116 116
 			}
117
-			elseif ($content['appname'] != $appname || !self::$acl_edit || ( $content['owner'] != $GLOBALS['egw_info']['user']['account_id'] && $this->appname != 'admin'))
117
+			elseif ($content['appname'] != $appname || !self::$acl_edit || ($content['owner'] != $GLOBALS['egw_info']['user']['account_id'] && $this->appname != 'admin'))
118 118
 			{
119 119
 				// only allow to view category
120 120
 				$readonlys['__ALL__'] = true;
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
 		}
125 125
 		elseif ($content['button'] || $content['delete'])
126 126
 		{
127
-			$cats = new categories($content['owner'] ? $content['owner'] : categories::GLOBAL_ACCOUNT,$content['appname']);
127
+			$cats = new categories($content['owner'] ? $content['owner'] : categories::GLOBAL_ACCOUNT, $content['appname']);
128 128
 
129 129
 			if ($content['delete']['delete'] || $content['delete']['subs'])
130 130
 			{
131 131
 				$button = 'delete';
132
-				$delete_subs = $content['delete']['subs']?true:false;
132
+				$delete_subs = $content['delete']['subs'] ? true : false;
133 133
 			}
134 134
 			else
135 135
 			{
@@ -140,29 +140,29 @@  discard block
 block discarded – undo
140 140
 
141 141
 			$refresh_app = $this->appname == 'preferences' ? $content['appname'] : $this->appname;
142 142
 
143
-			switch($button)
143
+			switch ($button)
144 144
 			{
145 145
 				case 'save':
146 146
 				case 'apply':
147
-					if(is_array($content['owner'])) $content['owner'] = implode(',',$content['owner']);
148
-					if($content['owner'] == '') $content['owner'] = 0;
147
+					if (is_array($content['owner'])) $content['owner'] = implode(',', $content['owner']);
148
+					if ($content['owner'] == '') $content['owner'] = 0;
149 149
 					if ($content['id'] && self::$acl_edit)
150 150
 					{
151 151
 
152 152
 						// If color changed, we need to do an edit 'refresh' instead of 'update'
153 153
 						// to reload the whole nextmatch instead of just the row
154
-						$data = $cats->id2name($content['id'],'data');
154
+						$data = $cats->id2name($content['id'], 'data');
155 155
 						$change_color = ($data['color'] != $content['data']['color']);
156 156
 						// Nicely reload just the category window / iframe
157
-						if($change_color)
157
+						if ($change_color)
158 158
 						{
159
-							if(egw_json_response::isJSONResponse())
159
+							if (egw_json_response::isJSONResponse())
160 160
 							{
161 161
 								// Update category styles
162
-								egw_json_response::get()->apply('opener.egw.includeCSS',array(categories::css($refresh_app == 'admin' ? categories::GLOBAL_APPNAME : $refresh_app)));
163
-								if($this->appname != 'admin')
162
+								egw_json_response::get()->apply('opener.egw.includeCSS', array(categories::css($refresh_app == 'admin' ? categories::GLOBAL_APPNAME : $refresh_app)));
163
+								if ($this->appname != 'admin')
164 164
 								{
165
-									egw_json_response::get()->apply('opener.egw.show_preferences',array(
165
+									egw_json_response::get()->apply('opener.egw.show_preferences', array(
166 166
 										'cats',
167 167
 										$this->appname == 'admin' ? categories::GLOBAL_APPNAME : array($refresh_app)
168 168
 									));
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 								else
172 172
 								{
173 173
 									categories::css($refresh_app == 'admin' ? categories::GLOBAL_APPNAME : $refresh_app);
174
-									egw_json_response::get()->apply('opener.app.admin.load',array(
174
+									egw_json_response::get()->apply('opener.app.admin.load', array(
175 175
 										egw_framework::link('/index.php', array(
176 176
 											'menuaction' => $this->list_link,
177 177
 											'appname' => $appname
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 						}
193 193
 						catch (egw_exception_wrong_userinput $e)
194 194
 						{
195
-							$msg = lang('Unwilling to save category with current settings. Check for inconsistency:').$e->getMessage();	// display conflicts etc.
195
+							$msg = lang('Unwilling to save category with current settings. Check for inconsistency:').$e->getMessage(); // display conflicts etc.
196 196
 						}
197 197
 					}
198 198
 					elseif (!$content['id'] && (
@@ -217,10 +217,10 @@  discard block
 block discarded – undo
217 217
 				case 'delete':
218 218
 					if (self::$acl_delete)
219 219
 					{
220
-						$cats->delete($content['id'],$delete_subs,!$delete_subs);
220
+						$cats->delete($content['id'], $delete_subs, !$delete_subs);
221 221
 						$msg = lang('Category deleted.');
222 222
 
223
-						egw_framework::refresh_opener($msg, $refresh_app, $content['id'],'delete', $this->appname);
223
+						egw_framework::refresh_opener($msg, $refresh_app, $content['id'], 'delete', $this->appname);
224 224
 						egw_framework::window_close();
225 225
 						return;
226 226
 					}
@@ -234,19 +234,19 @@  discard block
 block discarded – undo
234 234
 			egw_framework::refresh_opener($msg, $change_color ? null : $refresh_app, $content['id'], $change_color ? null : 'update', $this->appname);
235 235
 		}
236 236
 		$content['msg'] = $msg;
237
-		if(!$content['appname']) $content['appname'] = $appname;
238
-		if($content['data']['icon'])
237
+		if (!$content['appname']) $content['appname'] = $appname;
238
+		if ($content['data']['icon'])
239 239
 		{
240
-			$content['icon_url'] = $content['base_url'] . $content['data']['icon'];
240
+			$content['icon_url'] = $content['base_url'].$content['data']['icon'];
241 241
 		}
242 242
 
243 243
 		$sel_options['icon'] = self::get_icons();
244 244
 		$sel_options['owner'] = array();
245 245
 
246 246
 		// User's category - add current value to be able to preserve owner
247
-		if(!$content['id'])
247
+		if (!$content['id'])
248 248
 		{
249
-			if($this->appname != 'admin')
249
+			if ($this->appname != 'admin')
250 250
 			{
251 251
 				$content['owner'] = $GLOBALS['egw_info']['user']['account_id'];
252 252
 			}
@@ -256,35 +256,35 @@  discard block
 block discarded – undo
256 256
 			}
257 257
 		}
258 258
 
259
-		if($this->appname != 'admin' && $content['owner'] > 0 )
259
+		if ($this->appname != 'admin' && $content['owner'] > 0)
260 260
 		{
261 261
 			$sel_options['owner'][$content['owner']] = common::grab_owner_name($content['owner']);
262 262
 		}
263 263
 		// Add 'All users', in case owner is readonlys
264
-		if($content['id'] && $content['owner'] == 0)
264
+		if ($content['id'] && $content['owner'] == 0)
265 265
 		{
266 266
 			$sel_options['owner'][0] = lang('All users');
267 267
 		}
268
-		if($this->appname == 'admin' || ($content['id'] && !((int)$content['owner'] > 0)))
268
+		if ($this->appname == 'admin' || ($content['id'] && !((int)$content['owner'] > 0)))
269 269
 		{
270
-			if($content['owner'] > 0)
270
+			if ($content['owner'] > 0)
271 271
 			{
272 272
 				$content['msg'] .= "\n".lang('owner "%1" removed, please select group-owner', common::grab_owner_name($content['owner']));
273 273
 				$content['owner'] = 0;
274 274
 			}
275 275
 			$sel_options['owner'][0] = lang('All users');
276 276
 			$accs = $GLOBALS['egw']->accounts->get_list('groups');
277
-			foreach($accs as $acc)
277
+			foreach ($accs as $acc)
278 278
 			{
279 279
 				if ($acc['account_type'] == 'g')
280 280
 				{
281
-					$sel_options['owner'][$acc['account_id']] = ExecMethod2('etemplate.select_widget.accountInfo',$acc['account_id'],$acc);
281
+					$sel_options['owner'][$acc['account_id']] = ExecMethod2('etemplate.select_widget.accountInfo', $acc['account_id'], $acc);
282 282
 				}
283 283
 			}
284 284
 			$content['no_private'] = true;
285 285
 		}
286 286
 
287
-		if($this->appname == 'admin')
287
+		if ($this->appname == 'admin')
288 288
 		{
289 289
 			$content['access'] = 'public';
290 290
 			// Allow admins access to all categories as parent
@@ -295,17 +295,17 @@  discard block
 block discarded – undo
295 295
 			$readonlys['access'] = $content['owner'] != $GLOBALS['egw_info']['user']['account_id'];
296 296
 		}
297 297
 
298
-		egw_framework::validate_file('.','global_categories','admin');
298
+		egw_framework::validate_file('.', 'global_categories', 'admin');
299 299
 
300
-		$readonlys['button[delete]'] = !$content['id'] || !self::$acl_delete ||		// cant delete not yet saved category
300
+		$readonlys['button[delete]'] = !$content['id'] || !self::$acl_delete || // cant delete not yet saved category
301 301
 			$appname != $content['appname'] || // Can't edit a category from a different app
302 302
 			 ($this->appname != 'admin' && $content['owner'] != $GLOBALS['egw_info']['user']['account_id']);
303 303
 		// Make sure $content['owner'] is an array otherwise it wont show up values in the multiselectbox
304
-		if (!is_array($content['owner'])) $content['owner'] = explode(',',$content['owner']);
304
+		if (!is_array($content['owner'])) $content['owner'] = explode(',', $content['owner']);
305 305
 		$tmpl = new etemplate_new('admin.categories.edit');
306
-		$tmpl->exec($this->edit_link,$content,$sel_options,$readonlys,$content+array(
306
+		$tmpl->exec($this->edit_link, $content, $sel_options, $readonlys, $content + array(
307 307
 			'old_parent' => $content['old_parent'] ? $content['old_parent'] : $content['parent'], 'appname' => $appname
308
-		),2);
308
+		), 2);
309 309
 	}
310 310
 
311 311
 	/**
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 	 * @param string $icon = '' filename
315 315
 	 * @return string url
316 316
 	 */
317
-	static function icon_url($icon='')
317
+	static function icon_url($icon = '')
318 318
 	{
319 319
 		return $GLOBALS['egw_info']['server']['webserver_url'].self::ICON_PATH.'/'.$icon;
320 320
 	}
@@ -329,9 +329,9 @@  discard block
 block discarded – undo
329 329
 		$dir = dir(EGW_SERVER_ROOT.self::ICON_PATH);
330 330
 		$icons = array();
331 331
 		$matches = null;
332
-		while(($file = $dir->read()))
332
+		while (($file = $dir->read()))
333 333
 		{
334
-			if (preg_match('/^(.*)\\.(png|gif|jpe?g)$/i',$file,$matches))
334
+			if (preg_match('/^(.*)\\.(png|gif|jpe?g)$/i', $file, $matches))
335 335
 			{
336 336
 				$icons[$file] = ucfirst($matches[1]);
337 337
 			}
@@ -350,13 +350,13 @@  discard block
 block discarded – undo
350 350
 	 * @param array &$readonlys eg. to disable buttons based on acl, not use here, maybe in a derived class
351 351
 	 * @return int total number of rows
352 352
 	 */
353
-	public function get_rows(&$query,&$rows,&$readonlys)
353
+	public function get_rows(&$query, &$rows, &$readonlys)
354 354
 	{
355 355
 		self::init_static();
356 356
 
357 357
 		$filter = array();
358 358
 		$globalcat = ($query['filter'] === categories::GLOBAL_ACCOUNT || !$query['filter']);
359
-		if (isset($query['global_cats']) && $query['global_cats']===false)
359
+		if (isset($query['global_cats']) && $query['global_cats'] === false)
360 360
 		{
361 361
 			$globalcat = false;
362 362
 		}
@@ -364,49 +364,49 @@  discard block
 block discarded – undo
364 364
 		// new column-filter access has highest priority
365 365
 		if (!empty($query['col_filter']['access']))$filter['access'] = $query['col_filter']['access'];
366 366
 
367
-		egw_cache::setSession(__CLASS__.$query['appname'],'nm',$query);
367
+		egw_cache::setSession(__CLASS__.$query['appname'], 'nm', $query);
368 368
 
369
-		if($query['filter'] > 0 || $query['col_filter']['owner'])
369
+		if ($query['filter'] > 0 || $query['col_filter']['owner'])
370 370
 		{
371 371
 			$owner = $query['col_filter']['owner'] ? $query['col_filter']['owner'] : $query['filter'];
372 372
 		}
373
-		if($query['col_filter']['app'])
373
+		if ($query['col_filter']['app'])
374 374
 		{
375 375
 			$filter['appname'] = $query['col_filter']['app'];
376 376
 		}
377
-		$GLOBALS['egw']->categories = $cats = new categories($filter['owner'],$query['appname']);
378
-		$globals = isset($GLOBALS['egw_info']['user']['apps']['admin']) ? 'all_no_acl' : $globalcat;	// ignore acl only for admins
377
+		$GLOBALS['egw']->categories = $cats = new categories($filter['owner'], $query['appname']);
378
+		$globals = isset($GLOBALS['egw_info']['user']['apps']['admin']) ? 'all_no_acl' : $globalcat; // ignore acl only for admins
379 379
 		$parent = $query['search'] ? false : 0;
380
-		$rows = $cats->return_sorted_array($query['start'],false,$query['search'],$query['sort'],$query['order'],$globals,$parent,true,$filter);
380
+		$rows = $cats->return_sorted_array($query['start'], false, $query['search'], $query['sort'], $query['order'], $globals, $parent, true, $filter);
381 381
 		$count = $cats->total_records;
382
-		foreach($rows as $key => &$row)
382
+		foreach ($rows as $key => &$row)
383 383
 		{
384
-			$row['owner'] = explode(',',$row['owner']);
385
-			if(($owner && !in_array($owner, $row['owner'])) || ((string)$query['filter'] === (string)categories::GLOBAL_ACCOUNT && $row['owner'][0] > 0))
384
+			$row['owner'] = explode(',', $row['owner']);
385
+			if (($owner && !in_array($owner, $row['owner'])) || ((string)$query['filter'] === (string)categories::GLOBAL_ACCOUNT && $row['owner'][0] > 0))
386 386
 			{
387 387
 				unset($rows[$key]);
388 388
 				$count--;
389 389
 				continue;
390 390
 			}
391 391
 
392
-			$row['level_spacer'] = str_repeat('&nbsp; &nbsp; ',$row['level']);
392
+			$row['level_spacer'] = str_repeat('&nbsp; &nbsp; ', $row['level']);
393 393
 
394 394
 			if ($row['data']['icon']) $row['icon_url'] = self::icon_url($row['data']['icon']);
395 395
 
396 396
 			$row['subs'] = count($row['children']);
397 397
 
398 398
 			$row['class'] = 'level'.$row['level'];
399
-			if($row['owner'][0] > 0 && !$GLOBALS['egw_info']['user']['apps']['admin'] && $row['owner'][0] != $GLOBALS['egw_info']['user']['account_id'])
399
+			if ($row['owner'][0] > 0 && !$GLOBALS['egw_info']['user']['apps']['admin'] && $row['owner'][0] != $GLOBALS['egw_info']['user']['account_id'])
400 400
 			{
401 401
 				$row['class'] .= ' rowNoEdit rowNoDelete ';
402 402
 			}
403 403
 			else if (!$GLOBALS['egw_info']['user']['apps']['admin'])
404 404
 			{
405
-				if(!$cats->check_perms(EGW_ACL_EDIT, $row['id']) || !self::$acl_edit)
405
+				if (!$cats->check_perms(EGW_ACL_EDIT, $row['id']) || !self::$acl_edit)
406 406
 				{
407 407
 					$row['class'] .= ' rowNoEdit';
408 408
 				}
409
-				if(!$cats->check_perms(EGW_ACL_DELETE, $row['id']) || !self::$acl_delete ||
409
+				if (!$cats->check_perms(EGW_ACL_DELETE, $row['id']) || !self::$acl_delete ||
410 410
 					// Only admins can delete globals
411 411
 					$cats->is_global($row['id']) && !$GLOBALS['egw_info']['user']['apps']['admin'])
412 412
 				{
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 				}
415 415
 			}
416 416
 			// Can only edit (via context menu) categories for the selected app (backend restriction)
417
-			if($row['appname'] != $query['appname'] || (array_sum($row['owner']) > 0))
417
+			if ($row['appname'] != $query['appname'] || (array_sum($row['owner']) > 0))
418 418
 			{
419 419
 				$row['class'] .= ' rowNoEdit ';
420 420
 			}
@@ -442,60 +442,60 @@  discard block
 block discarded – undo
442 442
 	 * @param array $content = null
443 443
 	 * @param string $msg = ''
444 444
 	 */
445
-	public function index(array $content=null,$msg='')
445
+	public function index(array $content = null, $msg = '')
446 446
 	{
447 447
 		//_debug_array($_GET);
448
-		if ($this->appname != 'admin') translation::add_app('admin');	// need admin translations
448
+		if ($this->appname != 'admin') translation::add_app('admin'); // need admin translations
449 449
 
450
-		if(!isset($content))
450
+		if (!isset($content))
451 451
 		{
452 452
 			if (isset($_GET['msg'])) $msg = $_GET['msg'];
453 453
 
454 454
 			$appname = categories::GLOBAL_APPNAME;
455
-			foreach(array($content['nm']['appname'], $_GET['cats_app'], $_GET['appname']) as $field)
455
+			foreach (array($content['nm']['appname'], $_GET['cats_app'], $_GET['appname']) as $field)
456 456
 			{
457
-				if($field)
457
+				if ($field)
458 458
 				{
459 459
 					$appname = $field;
460 460
 					break;
461 461
 				}
462 462
 			}
463
-			$content['nm'] = egw_cache::getSession(__CLASS__.$appname,'nm');
463
+			$content['nm'] = egw_cache::getSession(__CLASS__.$appname, 'nm');
464 464
 			if (!is_array($content['nm']))
465 465
 			{
466 466
 				$content['nm'] = array(
467
-					'get_rows'       =>	$this->get_rows,	// I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
467
+					'get_rows'       =>	$this->get_rows, // I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
468 468
 					'options-filter' => array(
469 469
 						'' => lang('All categories'),
470 470
 						categories::GLOBAL_ACCOUNT => lang('Global categories'),
471 471
 						$GLOBALS['egw_info']['user']['account_id'] => lang('Own categories'),
472 472
 					),
473
-					'no_filter2'     => True,	// I  disable the 2. filter (params are the same as for filter)
474
-					'no_cat'         => True,	// I  disable the cat-selectbox
475
-					'header_left'    =>	false,	// I  template to show left of the range-value, left-aligned (optional)
476
-					'header_right'   =>	false,	// I  template to show right of the range-value, right-aligned (optional)
477
-					'never_hide'     => True,	// I  never hide the nextmatch-line if less then maxmatch entries
478
-					'lettersearch'   => false,	// I  show a lettersearch
479
-					'start'          =>	0,		// IO position in list
480
-					'order'          =>	'name',	// IO name of the column to sort after (optional for the sortheaders)
481
-					'sort'           =>	'ASC',	// IO direction of the sort: 'ASC' or 'DESC'
482
-					'default_cols'   => '!color,last_mod,subs,legacy_actions',	// I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
483
-					'csv_fields'     =>	false,	// I  false=disable csv export, true or unset=enable it with auto-detected fieldnames,
473
+					'no_filter2'     => True, // I  disable the 2. filter (params are the same as for filter)
474
+					'no_cat'         => True, // I  disable the cat-selectbox
475
+					'header_left'    =>	false, // I  template to show left of the range-value, left-aligned (optional)
476
+					'header_right'   =>	false, // I  template to show right of the range-value, right-aligned (optional)
477
+					'never_hide'     => True, // I  never hide the nextmatch-line if less then maxmatch entries
478
+					'lettersearch'   => false, // I  show a lettersearch
479
+					'start'          =>	0, // IO position in list
480
+					'order'          =>	'name', // IO name of the column to sort after (optional for the sortheaders)
481
+					'sort'           =>	'ASC', // IO direction of the sort: 'ASC' or 'DESC'
482
+					'default_cols'   => '!color,last_mod,subs,legacy_actions', // I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
483
+					'csv_fields'     =>	false, // I  false=disable csv export, true or unset=enable it with auto-detected fieldnames,
484 484
 									//or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type)
485 485
 					'no_search'      => !self::$acl_search,
486 486
 					'row_id'         => 'id',
487 487
 					'dataStorePrefix' => 'categories' // Avoid conflict with user list when in admin
488 488
 				);
489
-				$content['nm']['filter'] = $this->appname == 'admin'?categories::GLOBAL_ACCOUNT:$GLOBALS['egw_info']['user']['account_id'];
489
+				$content['nm']['filter'] = $this->appname == 'admin' ? categories::GLOBAL_ACCOUNT : $GLOBALS['egw_info']['user']['account_id'];
490 490
 			}
491 491
 			else
492 492
 			{
493
-				$content['nm']['start']=0;
493
+				$content['nm']['start'] = 0;
494 494
 			}
495 495
 			$content['nm']['appname'] = $appname = $_GET['appname'] ? $_GET['appname'] : $appname;
496 496
 			$content['nm']['actions'] = $this->get_actions($appname);
497 497
 			// switch filter off for super-global categories
498
-			if($appname == 'phpgw')
498
+			if ($appname == 'phpgw')
499 499
 			{
500 500
 				$content['nm']['no_filter'] = true;
501 501
 				// Make sure filter is set properly, could be different if user was looking at something else
@@ -503,18 +503,18 @@  discard block
 block discarded – undo
503 503
 			}
504 504
 
505 505
 			$content['nm']['global_cats'] = true;
506
-			if (isset($_GET['global_cats']) && empty($_GET['global_cats'] ))
506
+			if (isset($_GET['global_cats']) && empty($_GET['global_cats']))
507 507
 			{
508 508
 				$content['nm']['global_cats'] = false;
509 509
 			}
510 510
 		}
511
-		elseif($content['nm']['action'])
511
+		elseif ($content['nm']['action'])
512 512
 		{
513 513
 			$appname = $content['nm']['appname'];
514 514
 			// Old buttons
515
-			foreach(array('delete') as $button)
515
+			foreach (array('delete') as $button)
516 516
 			{
517
-				if(isset($content['nm']['rows'][$button]))
517
+				if (isset($content['nm']['rows'][$button]))
518 518
 				{
519 519
 					list($id) = @each($content['nm']['rows'][$button]);
520 520
 					$content['nm']['action'] = $button;
@@ -529,39 +529,39 @@  discard block
 block discarded – undo
529 529
 			else
530 530
 			{
531 531
 				// Action has an additional action - add / delete, etc.  Buttons named <multi-action>_action[action_name]
532
-				if(in_array($content['nm']['action'], array('owner')))
532
+				if (in_array($content['nm']['action'], array('owner')))
533 533
 				{
534 534
 					$action = $content['nm']['action'];
535 535
 					if ($content[$action.'_popup'])
536 536
 					{
537
-						$content = array_merge($content,$content[$action.'_popup']);
537
+						$content = array_merge($content, $content[$action.'_popup']);
538 538
 					}
539
-					$content['nm']['action'] .= '_' . key($content[$action . '_action']);
539
+					$content['nm']['action'] .= '_'.key($content[$action.'_action']);
540 540
 
541
-					if(is_array($content[$action]))
541
+					if (is_array($content[$action]))
542 542
 					{
543
-						$content[$action] = implode(',',$content[$action]);
543
+						$content[$action] = implode(',', $content[$action]);
544 544
 					}
545
-					$content['nm']['action'] .= '_' . $content[$action];
545
+					$content['nm']['action'] .= '_'.$content[$action];
546 546
 				}
547 547
 				$success = $failed = 0;
548 548
 				$action_msg = null;
549
-				if ($this->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'],
550
-					$success,$failed,$action_msg,$content['nm']))
549
+				if ($this->action($content['nm']['action'], $content['nm']['selected'], $content['nm']['select_all'],
550
+					$success, $failed, $action_msg, $content['nm']))
551 551
 				{
552
-					$msg .= lang('%1 category(s) %2',$success,$action_msg);
552
+					$msg .= lang('%1 category(s) %2', $success, $action_msg);
553 553
 				}
554
-				elseif(empty($msg))
554
+				elseif (empty($msg))
555 555
 				{
556
-					$msg .= lang('%1 category(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
556
+					$msg .= lang('%1 category(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed);
557 557
 				}
558 558
 				egw_framework::refresh_opener($msg, $this->appname);
559 559
 				$msg = '';
560 560
 			}
561 561
 		}
562 562
 		$content['msg'] = $msg;
563
-		$content['nm']['add_link']= egw_framework::link('/index.php','menuaction='.$this->add_link . '&cat_id=&appname='.$appname);
564
-		$content['edit_link']= $this->edit_link.'&appname='.$appname;
563
+		$content['nm']['add_link'] = egw_framework::link('/index.php', 'menuaction='.$this->add_link.'&cat_id=&appname='.$appname);
564
+		$content['edit_link'] = $this->edit_link.'&appname='.$appname;
565 565
 		$content['owner'] = '';
566 566
 
567 567
 		$sel_options['appname'] = $this->get_app_list();
@@ -576,39 +576,39 @@  discard block
 block discarded – undo
576 576
 
577 577
 		$sel_options['owner'][0] = lang('All users');
578 578
 		$accs = $GLOBALS['egw']->accounts->get_list('groups');
579
-		foreach($accs as $acc)
579
+		foreach ($accs as $acc)
580 580
 		{
581 581
 			if ($acc['account_type'] == 'g')
582 582
 			{
583
-				$sel_options['owner'][$acc['account_id']] = ExecMethod2('etemplate.select_widget.accountInfo',$acc['account_id'],$acc);
583
+				$sel_options['owner'][$acc['account_id']] = ExecMethod2('etemplate.select_widget.accountInfo', $acc['account_id'], $acc);
584 584
 			}
585 585
 		}
586 586
 
587 587
 		$readonlys['add'] = !self::$acl_add;
588
-		if(!$GLOBALS['egw_info']['user']['apps']['admin'])
588
+		if (!$GLOBALS['egw_info']['user']['apps']['admin'])
589 589
 		{
590 590
 			$readonlys['nm']['rows']['owner'] = true;
591 591
 			$readonlys['nm']['col_filter']['owner'] = true;
592 592
 		}
593
-		if($appname == categories::GLOBAL_APPNAME) {
593
+		if ($appname == categories::GLOBAL_APPNAME) {
594 594
 			$sel_options['app'] = array(''=>'');
595 595
 			$readonlys['nm']['rows']['app'] = true;
596 596
 		}
597 597
 
598 598
 		$tmpl = new etemplate_new('admin.categories.index');
599 599
 
600
-		if($tmpl instanceof etemplate_widget_template)
600
+		if ($tmpl instanceof etemplate_widget_template)
601 601
 		{
602 602
 			// Category styles
603 603
 			categories::css($appname);
604 604
 		}
605 605
 
606
-		$tmpl->exec($this->list_link,$content,$sel_options,$readonlys,array(
606
+		$tmpl->exec($this->list_link, $content, $sel_options, $readonlys, array(
607 607
 			'nm' => $content['nm'],
608 608
 		));
609 609
 	}
610 610
 
611
-	protected function get_actions($appname=categories::GLOBAL_APPNAME) {
611
+	protected function get_actions($appname = categories::GLOBAL_APPNAME) {
612 612
 
613 613
 		$actions = array(
614 614
 			'open' => array(        // does edit if allowed, otherwise view
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
 				'allowOnMultiple' => false,
618 618
 				'url' => 'menuaction='.$this->edit_link.'&cat_id=$id&appname='.$appname,
619 619
 				'popup' => '600x380',
620
-				'group' => $group=1,
620
+				'group' => $group = 1,
621 621
 			),
622 622
 			'add' => array(
623 623
 				'caption' => 'Add',
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
 			),
653 653
 		);
654 654
 
655
-		if(!$GLOBALS['egw_info']['user']['apps']['admin'])
655
+		if (!$GLOBALS['egw_info']['user']['apps']['admin'])
656 656
 		{
657 657
 			unset($actions['owner']);
658 658
 		}
@@ -678,14 +678,14 @@  discard block
 block discarded – undo
678 678
 		$success = $failed = 0;
679 679
 		if ($use_all)
680 680
 		{
681
-			@set_time_limit(0);                     // switch off the execution time limit, as it's for big selections to small
682
-			$query['num_rows'] = -1;        // all
681
+			@set_time_limit(0); // switch off the execution time limit, as it's for big selections to small
682
+			$query['num_rows'] = -1; // all
683 683
 			$result = $readonlys = array();
684
-			$this->get_rows($query,$result,$readonlys);
684
+			$this->get_rows($query, $result, $readonlys);
685 685
 			$checked = array();
686
-			foreach($result as $key => $info)
686
+			foreach ($result as $key => $info)
687 687
 			{
688
-				if(is_numeric($key))
688
+				if (is_numeric($key))
689 689
 				{
690 690
 					$checked[] = $info['id'];
691 691
 				}
@@ -693,19 +693,19 @@  discard block
 block discarded – undo
693 693
 		}
694 694
 		$owner = $query['col_filter']['owner'] ? $query['col_filter']['owner'] : $query['filter'];
695 695
 		$app = $query['col_filter']['app'] ? $query['col_filter']['app'] : $query['appname'];
696
-		$cats = new categories($owner,$app);
696
+		$cats = new categories($owner, $app);
697 697
 
698 698
 		list($action, $settings) = explode('_', $_action, 2);
699 699
 
700
-		switch($action)
700
+		switch ($action)
701 701
 		{
702 702
 			case 'delete':
703 703
 				$action_msg = lang('deleted');
704
-				foreach($checked as $id)
704
+				foreach ($checked as $id)
705 705
 				{
706
-					if($cats->check_perms(EGW_ACL_DELETE, $id, (boolean)$GLOBALS['egw_info']['user']['apps']['admin']))
706
+					if ($cats->check_perms(EGW_ACL_DELETE, $id, (boolean)$GLOBALS['egw_info']['user']['apps']['admin']))
707 707
 					{
708
-						$cats->delete($id,$settings == 'sub',$settings != 'sub');
708
+						$cats->delete($id, $settings == 'sub', $settings != 'sub');
709 709
 						$success++;
710 710
 					}
711 711
 					else
@@ -719,20 +719,19 @@  discard block
 block discarded – undo
719 719
 				list($add_remove, $ids_csv) = explode('_', $settings, 2);
720 720
 				$ids = explode(',', $ids_csv);
721 721
 				// Adding 'All users' removes all the others
722
-				if($add_remove == 'add' && array_search(categories::GLOBAL_ACCOUNT,$ids) !== false) $ids = array(categories::GLOBAL_ACCOUNT);
722
+				if ($add_remove == 'add' && array_search(categories::GLOBAL_ACCOUNT, $ids) !== false) $ids = array(categories::GLOBAL_ACCOUNT);
723 723
 
724
-				foreach($checked as $id)
724
+				foreach ($checked as $id)
725 725
 				{
726 726
 					if (!$data = $cats->read($id)) continue;
727
-					$data['owner'] = explode(',',$data['owner']);
728
-					if(array_search(categories::GLOBAL_ACCOUNT,$data['owner']) !== false || $data['owner'][0] > 0)
727
+					$data['owner'] = explode(',', $data['owner']);
728
+					if (array_search(categories::GLOBAL_ACCOUNT, $data['owner']) !== false || $data['owner'][0] > 0)
729 729
 					{
730 730
 						$data['owner'] = array();
731 731
 					}
732 732
 					$data['owner'] = $add_remove == 'add' ?
733
-						$ids == array(categories::GLOBAL_ACCOUNT) ? $ids : array_merge($data['owner'],$ids) :
734
-						array_diff($data['owner'],$ids);
735
-					$data['owner'] = implode(',',array_unique($data['owner']));
733
+						$ids == array(categories::GLOBAL_ACCOUNT) ? $ids : array_merge($data['owner'], $ids) : array_diff($data['owner'], $ids);
734
+					$data['owner'] = implode(',', array_unique($data['owner']));
736 735
 
737 736
 					if ($cats->edit($data))
738 737
 					{
@@ -763,7 +762,7 @@  discard block
 block discarded – undo
763 762
 				continue;
764 763
 			}
765 764
 			// Skip apps that don't show in the app bar, they [usually] don't have categories
766
-			if($data['status'] > 1 || in_array($app, array('home','admin','felamimail','sitemgr','sitemgr-link'))) continue;
765
+			if ($data['status'] > 1 || in_array($app, array('home', 'admin', 'felamimail', 'sitemgr', 'sitemgr-link'))) continue;
767 766
 			if ($GLOBALS['egw_info']['user']['apps'][$app])
768 767
 			{
769 768
 				$apps[$app] = $data['title'] ? $data['title'] : lang($app);
Please login to merge, or discard this patch.
Braces   +64 added lines, -17 removed lines patch added patch discarded remove patch
@@ -144,8 +144,14 @@  discard block
 block discarded – undo
144 144
 			{
145 145
 				case 'save':
146 146
 				case 'apply':
147
-					if(is_array($content['owner'])) $content['owner'] = implode(',',$content['owner']);
148
-					if($content['owner'] == '') $content['owner'] = 0;
147
+					if(is_array($content['owner']))
148
+					{
149
+						$content['owner'] = implode(',',$content['owner']);
150
+					}
151
+					if($content['owner'] == '')
152
+					{
153
+						$content['owner'] = 0;
154
+					}
149 155
 					if ($content['id'] && self::$acl_edit)
150 156
 					{
151 157
 
@@ -234,7 +240,10 @@  discard block
 block discarded – undo
234 240
 			egw_framework::refresh_opener($msg, $change_color ? null : $refresh_app, $content['id'], $change_color ? null : 'update', $this->appname);
235 241
 		}
236 242
 		$content['msg'] = $msg;
237
-		if(!$content['appname']) $content['appname'] = $appname;
243
+		if(!$content['appname'])
244
+		{
245
+			$content['appname'] = $appname;
246
+		}
238 247
 		if($content['data']['icon'])
239 248
 		{
240 249
 			$content['icon_url'] = $content['base_url'] . $content['data']['icon'];
@@ -290,7 +299,9 @@  discard block
 block discarded – undo
290 299
 			// Allow admins access to all categories as parent
291 300
 			$content['all_cats'] = 'all_no_acl';
292 301
 			$readonlys['owner'] = false;
293
-		} else {
302
+		}
303
+		else
304
+		{
294 305
 			$readonlys['owner'] = true;
295 306
 			$readonlys['access'] = $content['owner'] != $GLOBALS['egw_info']['user']['account_id'];
296 307
 		}
@@ -301,7 +312,10 @@  discard block
 block discarded – undo
301 312
 			$appname != $content['appname'] || // Can't edit a category from a different app
302 313
 			 ($this->appname != 'admin' && $content['owner'] != $GLOBALS['egw_info']['user']['account_id']);
303 314
 		// Make sure $content['owner'] is an array otherwise it wont show up values in the multiselectbox
304
-		if (!is_array($content['owner'])) $content['owner'] = explode(',',$content['owner']);
315
+		if (!is_array($content['owner']))
316
+		{
317
+			$content['owner'] = explode(',',$content['owner']);
318
+		}
305 319
 		$tmpl = new etemplate_new('admin.categories.edit');
306 320
 		$tmpl->exec($this->edit_link,$content,$sel_options,$readonlys,$content+array(
307 321
 			'old_parent' => $content['old_parent'] ? $content['old_parent'] : $content['parent'], 'appname' => $appname
@@ -360,9 +374,15 @@  discard block
 block discarded – undo
360 374
 		{
361 375
 			$globalcat = false;
362 376
 		}
363
-		if ($globalcat && $query['filter']) $filter['access'] = 'public';
377
+		if ($globalcat && $query['filter'])
378
+		{
379
+			$filter['access'] = 'public';
380
+		}
364 381
 		// new column-filter access has highest priority
365
-		if (!empty($query['col_filter']['access']))$filter['access'] = $query['col_filter']['access'];
382
+		if (!empty($query['col_filter']['access']))
383
+		{
384
+			$filter['access'] = $query['col_filter']['access'];
385
+		}
366 386
 
367 387
 		egw_cache::setSession(__CLASS__.$query['appname'],'nm',$query);
368 388
 
@@ -391,7 +411,10 @@  discard block
 block discarded – undo
391 411
 
392 412
 			$row['level_spacer'] = str_repeat('&nbsp; &nbsp; ',$row['level']);
393 413
 
394
-			if ($row['data']['icon']) $row['icon_url'] = self::icon_url($row['data']['icon']);
414
+			if ($row['data']['icon'])
415
+			{
416
+				$row['icon_url'] = self::icon_url($row['data']['icon']);
417
+			}
395 418
 
396 419
 			$row['subs'] = count($row['children']);
397 420
 
@@ -422,13 +445,19 @@  discard block
 block discarded – undo
422 445
 			$readonlys['nm']["add[$row[id]]"]    = !self::$acl_add_sub;
423 446
 			$readonlys['nm']["delete[$row[id]]"] = !self::$acl_delete;
424 447
 		}
425
-		if (true) $rows = $count <= $query['num_rows'] ? array_values($rows) : array_slice($rows, $query['start'], $query['num_rows']);
448
+		if (true)
449
+		{
450
+			$rows = $count <= $query['num_rows'] ? array_values($rows) : array_slice($rows, $query['start'], $query['num_rows']);
451
+		}
426 452
 		// make appname available for actions
427 453
 		$rows['appname'] = $query['appname'];
428 454
 		$rows['edit_link'] = $this->edit_link;
429 455
 
430 456
 		// disable access column for global categories
431
-		if ($GLOBALS['egw_info']['flags']['currentapp'] == 'admin') $rows['no_access'] = true;
457
+		if ($GLOBALS['egw_info']['flags']['currentapp'] == 'admin')
458
+		{
459
+			$rows['no_access'] = true;
460
+		}
432 461
 
433 462
 		$GLOBALS['egw_info']['flags']['app_header'] = lang($this->appname).' - '.lang('categories').
434 463
 			($query['appname'] != categories::GLOBAL_APPNAME ? ': '.lang($query['appname']) : '');
@@ -445,11 +474,18 @@  discard block
 block discarded – undo
445 474
 	public function index(array $content=null,$msg='')
446 475
 	{
447 476
 		//_debug_array($_GET);
448
-		if ($this->appname != 'admin') translation::add_app('admin');	// need admin translations
477
+		if ($this->appname != 'admin')
478
+		{
479
+			translation::add_app('admin');
480
+		}
481
+		// need admin translations
449 482
 
450 483
 		if(!isset($content))
451 484
 		{
452
-			if (isset($_GET['msg'])) $msg = $_GET['msg'];
485
+			if (isset($_GET['msg']))
486
+			{
487
+				$msg = $_GET['msg'];
488
+			}
453 489
 
454 490
 			$appname = categories::GLOBAL_APPNAME;
455 491
 			foreach(array($content['nm']['appname'], $_GET['cats_app'], $_GET['appname']) as $field)
@@ -590,7 +626,8 @@  discard block
 block discarded – undo
590 626
 			$readonlys['nm']['rows']['owner'] = true;
591 627
 			$readonlys['nm']['col_filter']['owner'] = true;
592 628
 		}
593
-		if($appname == categories::GLOBAL_APPNAME) {
629
+		if($appname == categories::GLOBAL_APPNAME)
630
+		{
594 631
 			$sel_options['app'] = array(''=>'');
595 632
 			$readonlys['nm']['rows']['app'] = true;
596 633
 		}
@@ -608,7 +645,8 @@  discard block
 block discarded – undo
608 645
 		));
609 646
 	}
610 647
 
611
-	protected function get_actions($appname=categories::GLOBAL_APPNAME) {
648
+	protected function get_actions($appname=categories::GLOBAL_APPNAME)
649
+	{
612 650
 
613 651
 		$actions = array(
614 652
 			'open' => array(        // does edit if allowed, otherwise view
@@ -719,11 +757,17 @@  discard block
 block discarded – undo
719 757
 				list($add_remove, $ids_csv) = explode('_', $settings, 2);
720 758
 				$ids = explode(',', $ids_csv);
721 759
 				// Adding 'All users' removes all the others
722
-				if($add_remove == 'add' && array_search(categories::GLOBAL_ACCOUNT,$ids) !== false) $ids = array(categories::GLOBAL_ACCOUNT);
760
+				if($add_remove == 'add' && array_search(categories::GLOBAL_ACCOUNT,$ids) !== false)
761
+				{
762
+					$ids = array(categories::GLOBAL_ACCOUNT);
763
+				}
723 764
 
724 765
 				foreach($checked as $id)
725 766
 				{
726
-					if (!$data = $cats->read($id)) continue;
767
+					if (!$data = $cats->read($id))
768
+					{
769
+						continue;
770
+					}
727 771
 					$data['owner'] = explode(',',$data['owner']);
728 772
 					if(array_search(categories::GLOBAL_ACCOUNT,$data['owner']) !== false || $data['owner'][0] > 0)
729 773
 					{
@@ -763,7 +807,10 @@  discard block
 block discarded – undo
763 807
 				continue;
764 808
 			}
765 809
 			// Skip apps that don't show in the app bar, they [usually] don't have categories
766
-			if($data['status'] > 1 || in_array($app, array('home','admin','felamimail','sitemgr','sitemgr-link'))) continue;
810
+			if($data['status'] > 1 || in_array($app, array('home','admin','felamimail','sitemgr','sitemgr-link')))
811
+			{
812
+				continue;
813
+			}
767 814
 			if ($GLOBALS['egw_info']['user']['apps'][$app])
768 815
 			{
769 816
 				$apps[$app] = $data['title'] ? $data['title'] : lang($app);
Please login to merge, or discard this patch.
admin/inc/class.admin_export_groups_csv.inc.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	/**
20 20
 	 * Exports records as defined in $_definition
21 21
 	 *
22
-	 * @param egw_record $_definition
22
+	 * @param importexport_definition $_definition
23 23
 	 */
24 24
 	public function export( $_stream, importexport_definition $_definition) {
25 25
 		$options = $_definition->plugin_options;
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 * return html for options.
89 89
 	 * this way the plugin has all opportunities for options tab
90 90
 	 *
91
-	 * @return string html
91
+	 * @return boolean html
92 92
 	 */
93 93
 	public function get_options_etpl() {
94 94
 		return false;
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -81,8 +81,8 @@
 block discarded – undo
81 81
 	}
82 82
 
83 83
 	public static function get_mimetype() {
84
-                return 'text/csv';
85
-        }
84
+				return 'text/csv';
85
+		}
86 86
 
87 87
 	/**
88 88
 	 * return html for options.
Please login to merge, or discard this patch.
Braces   +29 added lines, -13 removed lines patch added patch discarded remove patch
@@ -14,14 +14,16 @@  discard block
 block discarded – undo
14 14
 /**
15 15
  * Export users plugin
16 16
  */
17
-class admin_export_groups_csv implements importexport_iface_export_plugin {
17
+class admin_export_groups_csv implements importexport_iface_export_plugin
18
+{
18 19
 
19 20
 	/**
20 21
 	 * Exports records as defined in $_definition
21 22
 	 *
22 23
 	 * @param egw_record $_definition
23 24
 	 */
24
-	public function export( $_stream, importexport_definition $_definition) {
25
+	public function export( $_stream, importexport_definition $_definition)
26
+	{
25 27
 		$options = $_definition->plugin_options;
26 28
 
27 29
 		$selection = array();
@@ -40,14 +42,22 @@  discard block
 block discarded – undo
40 42
 		);
41 43
 
42 44
 		// $_record is an array, that's what search() returns
43
-		foreach ($selection as $_record) {
45
+		foreach ($selection as $_record)
46
+		{
44 47
 			$record = new admin_egw_group_record($_record);
45
-			if($options['convert']) {
48
+			if($options['convert'])
49
+			{
46 50
 				importexport_export_csv::convert($record, admin_egw_group_record::$types, 'admin', $lookups);
47
-			} else {
51
+			}
52
+			else
53
+			{
48 54
 				// Implode arrays, so they don't say 'Array'
49
-				foreach($record->get_record_array() as $key => $value) {
50
-					if(is_array($value)) $record->$key = implode(',', $value);
55
+				foreach($record->get_record_array() as $key => $value)
56
+				{
57
+					if(is_array($value))
58
+					{
59
+						$record->$key = implode(',', $value);
60
+					}
51 61
 				}
52 62
  			}
53 63
 			$export_object->export_record($record);
@@ -60,7 +70,8 @@  discard block
 block discarded – undo
60 70
 	 *
61 71
 	 * @return string name
62 72
 	 */
63
-	public static function get_name() {
73
+	public static function get_name()
74
+	{
64 75
 		return lang('Group CSV export');
65 76
 	}
66 77
 
@@ -69,7 +80,8 @@  discard block
 block discarded – undo
69 80
 	 *
70 81
 	 * @return string descriprion
71 82
 	 */
72
-	public static function get_description() {
83
+	public static function get_description()
84
+	{
73 85
 		return lang("Exports groups into a CSV File. ");
74 86
 	}
75 87
 
@@ -78,11 +90,13 @@  discard block
 block discarded – undo
78 90
 	 *
79 91
 	 * @return string suffix
80 92
 	 */
81
-	public static function get_filesuffix() {
93
+	public static function get_filesuffix()
94
+	{
82 95
 		return 'csv';
83 96
 	}
84 97
 
85
-	public static function get_mimetype() {
98
+	public static function get_mimetype()
99
+	{
86 100
                 return 'text/csv';
87 101
         }
88 102
 
@@ -92,7 +106,8 @@  discard block
 block discarded – undo
92 106
 	 *
93 107
 	 * @return string html
94 108
 	 */
95
-	public function get_options_etpl() {
109
+	public function get_options_etpl()
110
+	{
96 111
 		return false;
97 112
 	}
98 113
 
@@ -100,7 +115,8 @@  discard block
 block discarded – undo
100 115
 	 * returns slectors of this plugin via xajax
101 116
 	 *
102 117
 	 */
103
-	public function get_selectors_etpl() {
118
+	public function get_selectors_etpl()
119
+	{
104 120
 		return array(
105 121
 			'preserv' => array('no_error_for_no_selection'),
106 122
 		);
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param egw_record $_definition
23 23
 	 */
24
-	public function export( $_stream, importexport_definition $_definition) {
24
+	public function export($_stream, importexport_definition $_definition) {
25 25
 		$options = $_definition->plugin_options;
26 26
 
27 27
 		$selection = array();
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
 		// $_record is an array, that's what search() returns
43 43
 		foreach ($selection as $_record) {
44 44
 			$record = new admin_egw_group_record($_record);
45
-			if($options['convert']) {
45
+			if ($options['convert']) {
46 46
 				importexport_export_csv::convert($record, admin_egw_group_record::$types, 'admin', $lookups);
47 47
 			} else {
48 48
 				// Implode arrays, so they don't say 'Array'
49
-				foreach($record->get_record_array() as $key => $value) {
50
-					if(is_array($value)) $record->$key = implode(',', $value);
49
+				foreach ($record->get_record_array() as $key => $value) {
50
+					if (is_array($value)) $record->$key = implode(',', $value);
51 51
 				}
52 52
  			}
53 53
 			$export_object->export_record($record);
Please login to merge, or discard this patch.
admin/inc/class.admin_import_groups_csv.inc.php 4 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -77,8 +77,7 @@
 block discarded – undo
77 77
 	/**
78 78
 	 * imports entries according to given definition object.
79 79
 	 * @param resource $_stream
80
-	 * @param string $_charset
81
-	 * @param definition $_definition
80
+	 * @param importexport_definition $_definition
82 81
 	 */
83 82
 	public function import( $_stream, importexport_definition $_definition ) {
84 83
 		$import_csv = new importexport_import_csv( $_stream, array(
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -15,15 +15,15 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * class import_csv for admin (groups)
17 17
  */
18
-class admin_import_groups_csv implements importexport_iface_import_plugin  {
18
+class admin_import_groups_csv implements importexport_iface_import_plugin {
19 19
 
20 20
 	private static $plugin_options = array(
21
-		'fieldsep', 		// char
22
-		'charset', 		// string
21
+		'fieldsep', // char
22
+		'charset', // string
23 23
 		'num_header_lines', // int number of header lines
24 24
 		'field_conversion', // array( $csv_col_num => conversion)
25
-		'field_mapping',	// array( $csv_col_num => adb_filed)
26
-		'conditions',		/* => array containing condition arrays:
25
+		'field_mapping', // array( $csv_col_num => adb_filed)
26
+		'conditions', /* => array containing condition arrays:
27 27
 				'type' => exists, // exists
28 28
 				'string' => '#kundennummer',
29 29
 				'true' => array(
@@ -40,14 +40,14 @@  discard block
 block discarded – undo
40 40
 	/**
41 41
 	 * actions which could be done to data entries
42 42
 	 */
43
-	protected static $actions = array( 'none', 'update', 'create', 'delete');
43
+	protected static $actions = array('none', 'update', 'create', 'delete');
44 44
 
45 45
 	/**
46 46
 	 * conditions for actions
47 47
 	 *
48 48
 	 * @var array
49 49
 	 */
50
-	protected static $conditions = array( 'exists' );
50
+	protected static $conditions = array('exists');
51 51
 
52 52
 	/**
53 53
 	 * @var definition
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
 	 * @param string $_charset
81 81
 	 * @param definition $_definition
82 82
 	 */
83
-	public function import( $_stream, importexport_definition $_definition ) {
84
-		$import_csv = new importexport_import_csv( $_stream, array(
83
+	public function import($_stream, importexport_definition $_definition) {
84
+		$import_csv = new importexport_import_csv($_stream, array(
85 85
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
86 86
 			'charset' => $_definition->plugin_options['charset'],
87 87
 		));
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		$this->definition = $_definition;
90 90
 
91 91
 		// dry run?
92
-		$this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] :  false;
92
+		$this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false;
93 93
 
94 94
 		// set FieldMapping.
95 95
 		$import_csv->mapping = $_definition->plugin_options['field_mapping'];
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
 		$import_csv->conversion = $_definition->plugin_options['field_conversion'];
99 99
 
100 100
 		//check if file has a header lines
101
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) {
101
+		if (isset($_definition->plugin_options['num_header_lines']) && $_definition->plugin_options['num_header_lines'] > 0) {
102 102
 			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
103
-		} elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
103
+		} elseif (isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
104 104
 			// First method is preferred
105 105
 			$import_csv->skip_records(1);
106 106
 		}
@@ -112,22 +112,22 @@  discard block
 block discarded – undo
112 112
 		// Failures
113 113
 		$this->errors = array();
114 114
 
115
-		while ( $record = $import_csv->get_record() ) {
115
+		while ($record = $import_csv->get_record()) {
116 116
 			$success = false;
117 117
 			// don't import empty records
118
-			if( count( array_unique( $record ) ) < 2 ) continue;
118
+			if (count(array_unique($record)) < 2) continue;
119 119
 
120 120
 			importexport_import_csv::convert($record, admin_egw_group_record::$types, 'admin');
121 121
 
122
-			if ( $_definition->plugin_options['conditions'] ) {
123
-				foreach ( $_definition->plugin_options['conditions'] as $condition ) {
124
-					switch ( $condition['type'] ) {
122
+			if ($_definition->plugin_options['conditions']) {
123
+				foreach ($_definition->plugin_options['conditions'] as $condition) {
124
+					switch ($condition['type']) {
125 125
 						// exists
126 126
 						case 'exists' :
127 127
 							$accounts = array();
128 128
 
129 129
 							// Skip the search if the field is empty
130
-							if($record[$condition['string']] !== '') {
130
+							if ($record[$condition['string']] !== '') {
131 131
 
132 132
 								$accounts = $GLOBALS['egw']->accounts->search(array(
133 133
 									'type' => 'groups',
@@ -136,25 +136,25 @@  discard block
 block discarded – undo
136 136
 								));
137 137
 							}
138 138
 							// Search looks in the given field, but doesn't do an exact match
139
-							foreach ( (array)$accounts as $key => $account )
139
+							foreach ((array)$accounts as $key => $account)
140 140
 							{
141
-								if($account[$condition['string']] != $record[$condition['string']]) unset($accounts[$key]);
141
+								if ($account[$condition['string']] != $record[$condition['string']]) unset($accounts[$key]);
142 142
 							}
143
-							if ( is_array( $accounts ) && count( $accounts ) >= 1 ) {
143
+							if (is_array($accounts) && count($accounts) >= 1) {
144 144
 								$account = current($accounts);
145 145
 								// apply action to all contacts matching this exists condition
146 146
 								$action = $condition['true'];
147
-								foreach ( (array)$accounts as $account ) {
147
+								foreach ((array)$accounts as $account) {
148 148
 									// Read full account, and copy needed info for accounts->save()
149 149
 									$account = $GLOBALS['egw']->accounts->read($account['account_id']);
150 150
 									$record['account_id'] = $account['account_id'];
151 151
 									$record['account_firstname'] = $account['account_firstname'];
152 152
 									$record['account_lastname'] = $account['account_lastname'];
153
-									$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
153
+									$success = $this->action($action['action'], $record, $import_csv->get_current_position());
154 154
 								}
155 155
 							} else {
156 156
 								$action = $condition['false'];
157
-								$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
157
+								$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
158 158
 							}
159 159
 							break;
160 160
 
@@ -167,9 +167,9 @@  discard block
 block discarded – undo
167 167
 				}
168 168
 			} else {
169 169
 				// unconditional insert
170
-				$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
170
+				$success = $this->action('insert', $record, $import_csv->get_current_position());
171 171
 			}
172
-			if($success) $count++;
172
+			if ($success) $count++;
173 173
 		}
174 174
 		return $count;
175 175
 	}
@@ -181,18 +181,18 @@  discard block
 block discarded – undo
181 181
 	 * @param array $_data contact data for the action
182 182
 	 * @return bool success or not
183 183
 	 */
184
-	private function action ( $_action, $_data, $record_num = 0 ) {
184
+	private function action($_action, $_data, $record_num = 0) {
185 185
 		switch ($_action) {
186 186
 			case 'none' :
187 187
 				return true;
188 188
 			case 'update' :
189 189
 			case 'create' :
190
-				if(count($_data['account_members']) < 1) {
190
+				if (count($_data['account_members']) < 1) {
191 191
 					$this->errors[$record_num] = lang('You must select at least one group member.');
192 192
 					return false;
193 193
 				}
194 194
 				$command = new admin_cmd_edit_group($_action == 'create' ? false : $_data['account_lid'], $_data);
195
-				if($this->dry_run) {
195
+				if ($this->dry_run) {
196 196
 					$this->results[$_action]++;
197 197
 					return true;
198 198
 				}
Please login to merge, or discard this patch.
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
 	protected $errors = array();
70 70
 
71 71
 	/**
72
-         * List of actions, and how many times that action was taken
73
-         */
74
-        protected $results = array();
72
+	 * List of actions, and how many times that action was taken
73
+	 */
74
+		protected $results = array();
75 75
 
76 76
 	/**
77 77
 	 * imports entries according to given definition object.
@@ -262,39 +262,39 @@  discard block
 block discarded – undo
262 262
 	}
263 263
 
264 264
 	/**
265
-	* Returns warnings that were encountered during importing
266
-	* Maximum of one warning message per record, but you can concatenate them if you need to
267
-	*
268
-	* @return Array (
269
-	*       record_# => warning message
270
-	*       )
271
-	*/
265
+	 * Returns warnings that were encountered during importing
266
+	 * Maximum of one warning message per record, but you can concatenate them if you need to
267
+	 *
268
+	 * @return Array (
269
+	 *       record_# => warning message
270
+	 *       )
271
+	 */
272 272
 	public function get_warnings() {
273 273
 		return $this->warnings;
274 274
 	}
275 275
 
276 276
 	/**
277
-        * Returns errors that were encountered during importing
278
-        * Maximum of one error message per record, but you can append if you need to
279
-        *
280
-        * @return Array (
281
-        *       record_# => error message
282
-        *       )
283
-        */
284
-        public function get_errors() {
277
+	 * Returns errors that were encountered during importing
278
+	 * Maximum of one error message per record, but you can append if you need to
279
+	 *
280
+	 * @return Array (
281
+	 *       record_# => error message
282
+	 *       )
283
+	 */
284
+		public function get_errors() {
285 285
 		return $this->errors;
286 286
 	}
287 287
 
288 288
 	/**
289
-        * Returns a list of actions taken, and the number of records for that action.
290
-        * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
291
-        *
292
-        * @return Array (
293
-        *       action => record count
294
-        * )
295
-        */
296
-        public function get_results() {
297
-                return $this->results;
298
-        }
289
+	 * Returns a list of actions taken, and the number of records for that action.
290
+	 * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
291
+	 *
292
+	 * @return Array (
293
+	 *       action => record count
294
+	 * )
295
+	 */
296
+		public function get_results() {
297
+				return $this->results;
298
+		}
299 299
 } // end of iface_export_plugin
300 300
 ?>
Please login to merge, or discard this patch.
Braces   +71 added lines, -30 removed lines patch added patch discarded remove patch
@@ -14,7 +14,8 @@  discard block
 block discarded – undo
14 14
 /**
15 15
  * class import_csv for admin (groups)
16 16
  */
17
-class admin_import_groups_csv implements importexport_iface_import_plugin  {
17
+class admin_import_groups_csv implements importexport_iface_import_plugin
18
+{
18 19
 
19 20
 	private static $plugin_options = array(
20 21
 		'fieldsep', 		// char
@@ -79,7 +80,8 @@  discard block
 block discarded – undo
79 80
 	 * @param string $_charset
80 81
 	 * @param definition $_definition
81 82
 	 */
82
-	public function import( $_stream, importexport_definition $_definition ) {
83
+	public function import( $_stream, importexport_definition $_definition )
84
+	{
83 85
 		$import_csv = new importexport_import_csv( $_stream, array(
84 86
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
85 87
 			'charset' => $_definition->plugin_options['charset'],
@@ -97,9 +99,12 @@  discard block
 block discarded – undo
97 99
 		$import_csv->conversion = $_definition->plugin_options['field_conversion'];
98 100
 
99 101
 		//check if file has a header lines
100
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) {
102
+		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0)
103
+		{
101 104
 			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
102
-		} elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
105
+		}
106
+		elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line'])
107
+		{
103 108
 			// First method is preferred
104 109
 			$import_csv->skip_records(1);
105 110
 		}
@@ -111,22 +116,30 @@  discard block
 block discarded – undo
111 116
 		// Failures
112 117
 		$this->errors = array();
113 118
 
114
-		while ( $record = $import_csv->get_record() ) {
119
+		while ( $record = $import_csv->get_record() )
120
+		{
115 121
 			$success = false;
116 122
 			// don't import empty records
117
-			if( count( array_unique( $record ) ) < 2 ) continue;
123
+			if( count( array_unique( $record ) ) < 2 )
124
+			{
125
+				continue;
126
+			}
118 127
 
119 128
 			importexport_import_csv::convert($record, admin_egw_group_record::$types, 'admin');
120 129
 
121
-			if ( $_definition->plugin_options['conditions'] ) {
122
-				foreach ( $_definition->plugin_options['conditions'] as $condition ) {
123
-					switch ( $condition['type'] ) {
130
+			if ( $_definition->plugin_options['conditions'] )
131
+			{
132
+				foreach ( $_definition->plugin_options['conditions'] as $condition )
133
+				{
134
+					switch ( $condition['type'] )
135
+					{
124 136
 						// exists
125 137
 						case 'exists' :
126 138
 							$accounts = array();
127 139
 
128 140
 							// Skip the search if the field is empty
129
-							if($record[$condition['string']] !== '') {
141
+							if($record[$condition['string']] !== '')
142
+							{
130 143
 							
131 144
 								$accounts = $GLOBALS['egw']->accounts->search(array(
132 145
 									'type' => 'groups',
@@ -137,13 +150,18 @@  discard block
 block discarded – undo
137 150
 							// Search looks in the given field, but doesn't do an exact match
138 151
 							foreach ( (array)$accounts as $key => $account )
139 152
 							{
140
-								if($account[$condition['string']] != $record[$condition['string']]) unset($accounts[$key]);
153
+								if($account[$condition['string']] != $record[$condition['string']])
154
+								{
155
+									unset($accounts[$key]);
156
+								}
141 157
 							}
142
-							if ( is_array( $accounts ) && count( $accounts ) >= 1 ) {
158
+							if ( is_array( $accounts ) && count( $accounts ) >= 1 )
159
+							{
143 160
 								$account = current($accounts);
144 161
 								// apply action to all contacts matching this exists condition
145 162
 								$action = $condition['true'];
146
-								foreach ( (array)$accounts as $account ) {
163
+								foreach ( (array)$accounts as $account )
164
+								{
147 165
 									// Read full account, and copy needed info for accounts->save()
148 166
 									$account = $GLOBALS['egw']->accounts->read($account['account_id']);
149 167
 									$record['account_id'] = $account['account_id'];
@@ -151,7 +169,9 @@  discard block
 block discarded – undo
151 169
 									$record['account_lastname'] = $account['account_lastname'];
152 170
 									$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
153 171
 								}
154
-							} else {
172
+							}
173
+							else
174
+							{
155 175
 								$action = $condition['false'];
156 176
 								$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
157 177
 							}
@@ -162,13 +182,21 @@  discard block
 block discarded – undo
162 182
 							die('condition / action not supported!!!');
163 183
 							break;
164 184
 					}
165
-					if ($action['last']) break;
185
+					if ($action['last'])
186
+					{
187
+						break;
188
+					}
166 189
 				}
167
-			} else {
190
+			}
191
+			else
192
+			{
168 193
 				// unconditional insert
169 194
 				$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
170 195
 			}
171
-			if($success) $count++;
196
+			if($success)
197
+			{
198
+				$count++;
199
+			}
172 200
 		}
173 201
 		return $count;
174 202
 	}
@@ -180,24 +208,29 @@  discard block
 block discarded – undo
180 208
 	 * @param array $_data contact data for the action
181 209
 	 * @return bool success or not
182 210
 	 */
183
-	private function action ( $_action, $_data, $record_num = 0 ) {
184
-		switch ($_action) {
211
+	private function action ( $_action, $_data, $record_num = 0 )
212
+	{
213
+		switch ($_action)
214
+		{
185 215
 			case 'none' :
186 216
 				return true;
187 217
 			case 'update' :
188 218
 			case 'create' :
189
-				if(count($_data['account_members']) < 1) {
219
+				if(count($_data['account_members']) < 1)
220
+				{
190 221
 					$this->errors[$record_num] = lang('You must select at least one group member.');
191 222
 					return false;
192 223
 				}
193 224
 				$command = new admin_cmd_edit_group($_action == 'create' ? false : $_data['account_lid'], $_data);
194
-				if($this->dry_run) {
225
+				if($this->dry_run)
226
+				{
195 227
 					$this->results[$_action]++;
196 228
 					return true;
197 229
 				}
198 230
 				try {
199 231
 					$command->run();
200
-				} catch (Exception $e) {
232
+				}
233
+				catch (Exception $e) {
201 234
 					$this->errors[$record_num] = $e->getMessage();
202 235
 					return false;
203 236
 				}
@@ -214,7 +247,8 @@  discard block
 block discarded – undo
214 247
 	 *
215 248
 	 * @return string name
216 249
 	 */
217
-	public static function get_name() {
250
+	public static function get_name()
251
+	{
218 252
 		return lang('Group CSV import');
219 253
 	}
220 254
 
@@ -223,7 +257,8 @@  discard block
 block discarded – undo
223 257
 	 *
224 258
 	 * @return string descriprion
225 259
 	 */
226
-	public static function get_description() {
260
+	public static function get_description()
261
+	{
227 262
 		return lang("Creates / updates user groups from CSV file");
228 263
 	}
229 264
 
@@ -232,7 +267,8 @@  discard block
 block discarded – undo
232 267
 	 *
233 268
 	 * @return string suffix (comma seperated)
234 269
 	 */
235
-	public static function get_filesuffix() {
270
+	public static function get_filesuffix()
271
+	{
236 272
 		return 'csv';
237 273
 	}
238 274
 
@@ -248,7 +284,8 @@  discard block
 block discarded – undo
248 284
 	 * 		preserv		=> array,
249 285
 	 * )
250 286
 	 */
251
-	public function get_options_etpl() {
287
+	public function get_options_etpl()
288
+	{
252 289
 		// lets do it!
253 290
 	}
254 291
 
@@ -257,7 +294,8 @@  discard block
 block discarded – undo
257 294
 	 *
258 295
 	 * @return string etemplate name
259 296
 	 */
260
-	public function get_selectors_etpl() {
297
+	public function get_selectors_etpl()
298
+	{
261 299
 		// lets do it!
262 300
 	}
263 301
 
@@ -269,7 +307,8 @@  discard block
 block discarded – undo
269 307
 	*       record_# => warning message
270 308
 	*       )
271 309
 	*/
272
-	public function get_warnings() {
310
+	public function get_warnings()
311
+	{
273 312
 		return $this->warnings;
274 313
 	}
275 314
 
@@ -281,7 +320,8 @@  discard block
 block discarded – undo
281 320
         *       record_# => error message
282 321
         *       )
283 322
         */
284
-        public function get_errors() {
323
+        public function get_errors()
324
+        {
285 325
 		return $this->errors;
286 326
 	}
287 327
 
@@ -293,7 +333,8 @@  discard block
 block discarded – undo
293 333
         *       action => record count
294 334
         * )
295 335
         */
296
-        public function get_results() {
336
+        public function get_results()
337
+        {
297 338
                 return $this->results;
298 339
         }
299 340
 } // end of iface_export_plugin
Please login to merge, or discard this patch.
admin/inc/class.admin_statistics.inc.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -291,7 +291,7 @@
 block discarded – undo
291 291
 	 * Check if next submission is due, in which case we call submit and NOT return to the admin hook
292 292
 	 *
293 293
 	 * @param boolean $redirect should we redirect or return true
294
-	 * @return boolean true if statistic submission is due
294
+	 * @return boolean|null true if statistic submission is due
295 295
 	 */
296 296
 	public static function check($redirect=true)
297 297
 	{
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	const SUBMIT_URL = 'https://www.egroupware.org/usage-statistic';
27 27
 	const STATISTIC_URL = 'http://www.egroupware.org/usage-statistic';
28 28
 
29
-	const SUBMISION_RATE = 2592000;	// 30 days
29
+	const SUBMISION_RATE = 2592000; // 30 days
30 30
 
31 31
 	/**
32 32
 	 * Which methods of this class can be called as menuation
@@ -42,27 +42,27 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @param array $_content =null
44 44
 	 */
45
-	public function submit($_content=null)
45
+	public function submit($_content = null)
46 46
 	{
47 47
 		if (is_array($_content))
48 48
 		{
49 49
 			$config = new config(self::CONFIG_APP);
50 50
 			if ($_content['postpone'])
51 51
 			{
52
-				config::save_value(self::CONFIG_POSTPONE_SUBMIT,time()+$_content['postpone'],self::CONFIG_APP);
52
+				config::save_value(self::CONFIG_POSTPONE_SUBMIT, time() + $_content['postpone'], self::CONFIG_APP);
53 53
 				$what = 'postpone';
54 54
 			}
55
-			elseif(!$_content['cancel'])
55
+			elseif (!$_content['cancel'])
56 56
 			{
57
-				config::save_value(self::CONFIG_LAST_SUBMIT,time(),self::CONFIG_APP);
58
-				config::save_value(self::CONFIG_SUBMIT_ID,empty($_content['submit_id']) ? '***none***' : $_content['submit_id'],self::CONFIG_APP);
59
-				config::save_value(self::CONFIG_COUNTRY,empty($_content['country']) ? '***multinational***' : $_content['country'],self::CONFIG_APP);
60
-				config::save_value(self::CONFIG_USAGE_TYPE,$_content['usage_type'],self::CONFIG_APP);
61
-				config::save_value(self::CONFIG_INSTALL_TYPE,$_content['install_type'],self::CONFIG_APP);
62
-				config::save_value(self::CONFIG_POSTPONE_SUBMIT,null,self::CONFIG_APP);	// remove evtl. postpone time
57
+				config::save_value(self::CONFIG_LAST_SUBMIT, time(), self::CONFIG_APP);
58
+				config::save_value(self::CONFIG_SUBMIT_ID, empty($_content['submit_id']) ? '***none***' : $_content['submit_id'], self::CONFIG_APP);
59
+				config::save_value(self::CONFIG_COUNTRY, empty($_content['country']) ? '***multinational***' : $_content['country'], self::CONFIG_APP);
60
+				config::save_value(self::CONFIG_USAGE_TYPE, $_content['usage_type'], self::CONFIG_APP);
61
+				config::save_value(self::CONFIG_INSTALL_TYPE, $_content['install_type'], self::CONFIG_APP);
62
+				config::save_value(self::CONFIG_POSTPONE_SUBMIT, null, self::CONFIG_APP); // remove evtl. postpone time
63 63
 				$what = 'submitted';
64 64
 			}
65
-			egw::redirect_link('/admin/index.php','ajax=true&statistics='.($what ? $what : 'canceled'),'admin');
65
+			egw::redirect_link('/admin/index.php', 'ajax=true&statistics='.($what ? $what : 'canceled'), 'admin');
66 66
 		}
67 67
 		$sel_options['usage_type'] = array(
68 68
 			'commercial'   => lang('Commercial: all sorts of companies'),
@@ -82,19 +82,19 @@  discard block
 block discarded – undo
82 82
 		$sel_options['postpone'] = array(
83 83
 			//10 => '10 secs',
84 84
 			3600 => lang('one hour'),
85
-			2*3600 => lang('two hours'),
86
-			24*3600 => lang('one day'),
87
-			2*24*3600 => lang('two days'),
88
-			7*24*3600 => lang('one week'),
89
-			14*24*3600 => lang('two weeks'),
90
-			30*24*3600 => lang('one month'),
91
-			60*24*3600 => lang('two months'),
85
+			2 * 3600 => lang('two hours'),
86
+			24 * 3600 => lang('one day'),
87
+			2 * 24 * 3600 => lang('two days'),
88
+			7 * 24 * 3600 => lang('one week'),
89
+			14 * 24 * 3600 => lang('two weeks'),
90
+			30 * 24 * 3600 => lang('one month'),
91
+			60 * 24 * 3600 => lang('two months'),
92 92
 		);
93 93
 		$config = config::read(self::CONFIG_APP);
94 94
 		//_debug_array($config);
95
-		$content = array_merge(self::gather_data(),array(
95
+		$content = array_merge(self::gather_data(), array(
96 96
 			'statistic_url' => self::STATISTIC_URL,
97
-			'submit_host' => parse_url(self::SUBMIT_URL,PHP_URL_HOST),
97
+			'submit_host' => parse_url(self::SUBMIT_URL, PHP_URL_HOST),
98 98
 			'submit_url'  => self::SUBMIT_URL,
99 99
 			'last_submitted' => $config[self::CONFIG_LAST_SUBMIT],
100 100
 		));
@@ -121,12 +121,12 @@  discard block
 block discarded – undo
121 121
 			$sel_options['install_type'] = array($content['install_type'] => $sel_options['install_type'][$content['install_type']]);
122 122
 		}
123 123
 		// else default to previous type
124
-		elseif($config[self::CONFIG_INSTALL_TYPE])
124
+		elseif ($config[self::CONFIG_INSTALL_TYPE])
125 125
 		{
126 126
 			$content['install_type'] = $config[self::CONFIG_INSTALL_TYPE];
127 127
 		}
128 128
 		// check if we are due for a new submission
129
-		if (!isset($config[self::CONFIG_LAST_SUBMIT]) || $config[self::CONFIG_LAST_SUBMIT ] <= time()-self::SUBMISION_RATE)
129
+		if (!isset($config[self::CONFIG_LAST_SUBMIT]) || $config[self::CONFIG_LAST_SUBMIT] <= time() - self::SUBMISION_RATE)
130 130
 		{
131 131
 			// clear etemplate_exec_id and replace form.action, before submitting the form
132 132
 			$content['onclick'] = "return app.admin.submit_statistic(this.form,'$content[submit_url]');";
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
 		{
136 136
 			$readonlys['submit'] = $readonlys['postpone'] = true;
137 137
 			$content['msg'] = lang('Your last submission was less then %1 days ago!',
138
-				ceil((time()-$config[self::CONFIG_LAST_SUBMIT])/24/3600));
138
+				ceil((time() - $config[self::CONFIG_LAST_SUBMIT]) / 24 / 3600));
139 139
 		}
140 140
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('Submit statistic information');
141 141
 		$tmpl = new etemplate_new('admin.statistics');
142
-		$tmpl->exec('admin.admin_statistics.submit',$content,$sel_options,$readonlys);
142
+		$tmpl->exec('admin.admin_statistics.submit', $content, $sel_options, $readonlys);
143 143
 	}
144 144
 
145 145
 	/**
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 			$data['version'] .= ' '.$GLOBALS['egw_info']['apps']['stylite']['version'].'EPL';
163 163
 		}
164 164
 		// sessions in the last 30 days
165
-		$data['sessions'] = $GLOBALS['egw']->db->query('SELECT COUNT(*) FROM egw_access_log WHERE li > '.(time()-30*24*3600))->fetchColumn();
165
+		$data['sessions'] = $GLOBALS['egw']->db->query('SELECT COUNT(*) FROM egw_access_log WHERE li > '.(time() - 30 * 24 * 3600))->fetchColumn();
166 166
 
167 167
 		// total accounts from accounts table or ldap
168 168
 		$GLOBALS['egw']->accounts->search(array(
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
 		// @ required to get ride of warning, if files are outside of open_basedir
177 177
 		if (@file_exists($file = '/etc/SuSE-release') || @file_exists($file = '/etc/redhat-release') || @file_exists($file = '/etc/debian_version'))
178 178
 		{
179
-			$data['os'] .= ': '.str_replace(array("\n","\r"),'',implode(',',file($file)));
179
+			$data['os'] .= ': '.str_replace(array("\n", "\r"), '', implode(',', file($file)));
180 180
 		}
181
-		if(file_exists(EGW_INCLUDE_ROOT.'/.git'))
181
+		if (file_exists(EGW_INCLUDE_ROOT.'/.git'))
182 182
 		{
183 183
 			$data['install_type'] = 'git';
184 184
 		}
@@ -186,22 +186,22 @@  discard block
 block discarded – undo
186 186
 		{
187 187
 			$data['install_type'] = 'svn';
188 188
 		}
189
-		elseif(EGW_INCLUDE_ROOT == '/usr/share/egroupware' && PHP_OS == 'Linux' && is_link('/usr/share/egroupware/header.inc.php'))
189
+		elseif (EGW_INCLUDE_ROOT == '/usr/share/egroupware' && PHP_OS == 'Linux' && is_link('/usr/share/egroupware/header.inc.php'))
190 190
 		{
191 191
 			$data['install_type'] = 'package';
192 192
 		}
193
-		foreach(array_keys($GLOBALS['egw_info']['apps']) as $app)
193
+		foreach (array_keys($GLOBALS['egw_info']['apps']) as $app)
194 194
 		{
195
-			if (in_array($app,array(
196
-				'admin','phpgwapi','emailadmin','sambaadmin','developer_tools',
197
-				'home','preferences','etemplate','registration','manual','egw-pear',
195
+			if (in_array($app, array(
196
+				'admin', 'phpgwapi', 'emailadmin', 'sambaadmin', 'developer_tools',
197
+				'home', 'preferences', 'etemplate', 'registration', 'manual', 'egw-pear',
198 198
 			)))
199 199
 			{
200
-				continue;	// --> ignore to not submit too much
200
+				continue; // --> ignore to not submit too much
201 201
 			}
202 202
 			if (($users = self::gather_app_users($app)))	// ignore apps noone is allowed to run
203 203
 			{
204
-				$data['apps'][$app] = $app.':'.round(100.0*$users/$data['users']).'%';
204
+				$data['apps'][$app] = $app.':'.round(100.0 * $users / $data['users']).'%';
205 205
 				if (($entries = self::gather_app_entries($app)))
206 206
 				{
207 207
 					$data['apps'][$app] .= ':'.$entries;
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 			}
210 210
 		}
211 211
 		ksort($data['apps']);
212
-		$data['apps'] = implode("\n",$data['apps']);
212
+		$data['apps'] = implode("\n", $data['apps']);
213 213
 
214 214
 		return $data;
215 215
 	}
@@ -223,17 +223,17 @@  discard block
 block discarded – undo
223 223
 	static function gather_app_users($app)
224 224
 	{
225 225
 		$users = array();
226
-		if (($access = $GLOBALS['egw']->acl->get_ids_for_location('run',1,$app)))
226
+		if (($access = $GLOBALS['egw']->acl->get_ids_for_location('run', 1, $app)))
227 227
 		{
228
-			foreach($access as $uid)
228
+			foreach ($access as $uid)
229 229
 			{
230 230
 				if ($uid > 0)
231 231
 				{
232 232
 					$users[] = $uid;
233 233
 				}
234
-				elseif (($members = $GLOBALS['egw']->accounts->members($uid,true)))
234
+				elseif (($members = $GLOBALS['egw']->accounts->members($uid, true)))
235 235
 				{
236
-					$users = array_merge($users,$members);
236
+					$users = array_merge($users, $members);
237 237
 				}
238 238
 			}
239 239
 			$users = array_unique($users);
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 			'infolog'     => 'egw_infolog',
258 258
 			'filemanager' => 'egw_sqlfs',
259 259
 			'gallery'     => 'g2_Item',
260
-			'news_admin'  => 'egw_news WHERE news_submittedby > 0',	// exclude imported rss feeds
260
+			'news_admin'  => 'egw_news WHERE news_submittedby > 0', // exclude imported rss feeds
261 261
 			'polls'       => 'egw_polls',
262 262
 			'projectmanager' => 'egw_pm_projects',
263 263
 			'phpbrain'    => 'egw_kb_articles',
@@ -275,8 +275,8 @@  discard block
 block discarded – undo
275 275
 				$entries = (int)$GLOBALS['egw']->db->query('SELECT COUNT(*) FROM '.$table)->fetchColumn();
276 276
 				//echo "$app ($table): $entries<br />\n";
277 277
 			}
278
-			catch(egw_exception_db $e) {
279
-				unset($e);	// not used
278
+			catch (egw_exception_db $e) {
279
+				unset($e); // not used
280 280
 				$entries = null;
281 281
 			}
282 282
 		}
@@ -289,19 +289,19 @@  discard block
 block discarded – undo
289 289
 	 * @param boolean $redirect should we redirect or return true
290 290
 	 * @return boolean true if statistic submission is due
291 291
 	 */
292
-	public static function check($redirect=true)
292
+	public static function check($redirect = true)
293 293
 	{
294 294
 		$config = config::read(self::CONFIG_APP);
295 295
 
296 296
 		if (isset($config[self::CONFIG_POSTPONE_SUBMIT]) && $config[self::CONFIG_POSTPONE_SUBMIT] > time() ||
297
-			isset($config[self::CONFIG_LAST_SUBMIT ]) && $config[self::CONFIG_LAST_SUBMIT ] > time()-self::SUBMISION_RATE)
297
+			isset($config[self::CONFIG_LAST_SUBMIT]) && $config[self::CONFIG_LAST_SUBMIT] > time() - self::SUBMISION_RATE)
298 298
 		{
299 299
 			return false;
300 300
 		}
301 301
 		if (!$redirect) return true;
302 302
 
303 303
 		//die('Due for new statistics submission: last_submit='.$config[self::CONFIG_LAST_SUBMIT ].', postpone='.$config[self::CONFIG_POSTPONE_SUBMIT].', '.function_backtrace());
304
-		egw::redirect_link('/index.php',array(
304
+		egw::redirect_link('/index.php', array(
305 305
 			'menuaction' => 'admin.admin_ui.index',
306 306
 			'ajax' => 'true',
307 307
 			'load' => 'admin.admin_statistics.submit',
Please login to merge, or discard this patch.
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -199,9 +199,12 @@  discard block
 block discarded – undo
199 199
 			{
200 200
 				continue;	// --> ignore to not submit too much
201 201
 			}
202
-			if (($users = self::gather_app_users($app)))	// ignore apps noone is allowed to run
202
+			if (($users = self::gather_app_users($app)))
203
+			{
204
+				// ignore apps noone is allowed to run
203 205
 			{
204 206
 				$data['apps'][$app] = $app.':'.round(100.0*$users/$data['users']).'%';
207
+			}
205 208
 				if (($entries = self::gather_app_entries($app)))
206 209
 				{
207 210
 					$data['apps'][$app] .= ':'.$entries;
@@ -298,7 +301,10 @@  discard block
 block discarded – undo
298 301
 		{
299 302
 			return false;
300 303
 		}
301
-		if (!$redirect) return true;
304
+		if (!$redirect)
305
+		{
306
+			return true;
307
+		}
302 308
 
303 309
 		//die('Due for new statistics submission: last_submit='.$config[self::CONFIG_LAST_SUBMIT ].', postpone='.$config[self::CONFIG_POSTPONE_SUBMIT].', '.function_backtrace());
304 310
 		egw::redirect_link('/index.php',array(
Please login to merge, or discard this patch.
admin/inc/class.admin_ui.inc.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -491,6 +491,10 @@
 block discarded – undo
491 491
 	protected static function call_hook()
492 492
 	{
493 493
 		self::$hook_data = array();
494
+
495
+		/**
496
+		 * @param string $appname
497
+		 */
494 498
 		function display_section($appname,$file,$file2=False)
495 499
 		{
496 500
 			admin_ui::$hook_data[$appname] = $file2 ? $file2 : $file;
Please login to merge, or discard this patch.
Spacing   +31 added lines, -35 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @param array $content
37 37
 	 */
38
-	public function index(array $content=null)
38
+	public function index(array $content = null)
39 39
 	{
40 40
 		if (admin_statistics::check(false))
41 41
 		{
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 		//$content['msg'] = 'Hi Ralf ;-)';
62 62
 		$sel_options['tree'] = $this->tree_data();
63 63
 		$sel_options['filter'] = array('' => lang('All'));
64
-		foreach(self::$accounts->search(array(
64
+		foreach (self::$accounts->search(array(
65 65
 			'type' => 'groups',
66 66
 			'start' => false,
67 67
 			'order' => 'account_lid',
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		}
93 93
 		else
94 94
 		{
95
-			$content['iframe'] = 'about:blank';	// we show accounts-list be default now
95
+			$content['iframe'] = 'about:blank'; // we show accounts-list be default now
96 96
 		}
97 97
 
98 98
 		$tpl->exec('admin.admin_ui.index', $content, $sel_options);
@@ -113,11 +113,11 @@  discard block
 block discarded – undo
113 113
 				'caption' => 'Show members',
114 114
 				'enableId' => '^/groups/-\\d+',
115 115
 				'default' => true,
116
-				'group' => $group=1,
116
+				'group' => $group = 1,
117 117
 			),
118 118
 			'add' => array(
119 119
 				'group' => $group,
120
-			)+$user_actions['add'],
120
+			) + $user_actions['add'],
121 121
 			'acl' => array(
122 122
 				'onExecute' => 'javaScript:app.admin.group',
123 123
 				'caption' => 'Access control',
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 				'group' => 2,
129 129
 			),
130 130
 		);
131
-		if (!$GLOBALS['egw']->acl->check('account_access',64,'admin'))	// no rights to set ACL-rights
131
+		if (!$GLOBALS['egw']->acl->check('account_access', 64, 'admin'))	// no rights to set ACL-rights
132 132
 		{
133 133
 			$actions['deny'] = array(
134 134
 				'caption'   => 'Deny access',
@@ -139,16 +139,16 @@  discard block
 block discarded – undo
139 139
 				'group'     => 2,
140 140
 			);
141 141
 		}
142
-		$group = 5;	// allow to place actions in different groups by hook, this is the default
142
+		$group = 5; // allow to place actions in different groups by hook, this is the default
143 143
 		// supporting both old way using $GLOBALS['menuData'] and new just returning data in hook
144 144
 		$apps = array_unique(array_merge(array('admin'), $GLOBALS['egw']->hooks->hook_implemented('edit_group')));
145
-		foreach($apps as $app)
145
+		foreach ($apps as $app)
146 146
 		{
147 147
 			$GLOBALS['menuData'] = $data = array();
148 148
 			$data = $GLOBALS['egw']->hooks->single('edit_group', $app);
149 149
 			if (!is_array($data)) $data = $GLOBALS['menuData'];
150 150
 			//error_log(__METHOD__."() app $app returned ".array2string($data));
151
-			foreach($data as $item)
151
+			foreach ($data as $item)
152 152
 			{
153 153
 				// allow hook to return "real" actions, but still support legacy: description, url, extradata, options
154 154
 				if (empty($item['caption']))
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 					'default' => true,
200 200
 					'allowOnMultiple' => false,
201 201
 					'onExecute' => 'javaScript:app.admin.account',
202
-					'group' => $group=0,
202
+					'group' => $group = 0,
203 203
 				),
204 204
 				'add' => array(
205 205
 					'caption' => 'Add user',
@@ -210,25 +210,25 @@  discard block
 block discarded – undo
210 210
 			// generate urls for add/edit accounts via addressbook
211 211
 			$edit = egw_link::get_registry('addressbook', 'edit');
212 212
 			$edit['account_id'] = '$id';
213
-			foreach($edit as $name => $val)
213
+			foreach ($edit as $name => $val)
214 214
 			{
215 215
 				$actions['edit']['url'] .= ($actions['edit']['url'] ? '&' : '').$name.'='.$val;
216 216
 			}
217 217
 			unset($edit['account_id']);
218 218
 			$edit['owner'] = 0;
219
-			foreach($edit as $name => $val)
219
+			foreach ($edit as $name => $val)
220 220
 			{
221 221
 				$actions['add']['url'] .= ($actions['edit']['url'] ? '&' : '').$name.'='.$val;
222 222
 			}
223 223
 			++$group;
224 224
 			// supporting both old way using $GLOBALS['menuData'] and new just returning data in hook
225 225
 			$apps = array_unique(array_merge(array('admin'), $GLOBALS['egw']->hooks->hook_implemented('edit_user')));
226
-			foreach($apps as $app)
226
+			foreach ($apps as $app)
227 227
 			{
228 228
 				$GLOBALS['menuData'] = $data = array();
229 229
 				$data = $GLOBALS['egw']->hooks->single('edit_user', $app);
230 230
 				if (!is_array($data)) $data = $GLOBALS['menuData'];
231
-				foreach($data as $item)
231
+				foreach ($data as $item)
232 232
 				{
233 233
 					// allow hook to return "real" actions, but still support legacy: description, url, extradata, options
234 234
 					if (empty($item['caption']))
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	 * @param array &$rows=null
278 278
 	 * @return int total number of rows available
279 279
 	 */
280
-	public static function get_users(array $query, array &$rows=null)
280
+	public static function get_users(array $query, array &$rows = null)
281 281
 	{
282 282
 		$params = array(
283 283
 			'type' => (int)$query['filter'] ? (int)$query['filter'] : 'accounts',
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 			$params['query'] = $query['searchletter'];
293 293
 			$params['query_type'] = 'start';
294 294
 		}
295
-		elseif($query['search'])
295
+		elseif ($query['search'])
296 296
 		{
297 297
 			$params['query'] = $query['search'];
298 298
 			$params['query_type'] = 'all';
@@ -301,13 +301,10 @@  discard block
 block discarded – undo
301 301
 		$rows = array_values(self::$accounts->search($params));
302 302
 		//error_log(__METHOD__."() accounts->search(".array2string($params).") total=".self::$accounts->total);
303 303
 
304
-		foreach($rows as &$row)
304
+		foreach ($rows as &$row)
305 305
 		{
306 306
 			$row['status'] = self::$accounts->is_expired($row) ?
307
-				lang('Expired').' '.egw_time::to($row['account_expires'], true) :
308
-					(!self::$accounts->is_active($row) ? lang('Disabled') :
309
-						($row['account_expires'] != -1 ? lang('Expires').' '.egw_time::to($row['account_expires'], true) :
310
-							lang('Enabled')));
307
+				lang('Expired').' '.egw_time::to($row['account_expires'], true) : (!self::$accounts->is_active($row) ? lang('Disabled') : ($row['account_expires'] != -1 ? lang('Expires').' '.egw_time::to($row['account_expires'], true) : lang('Enabled')));
311 308
 
312 309
 			if (!self::$accounts->is_active($row)) $row['status_class'] = 'adminAccountInactive';
313 310
 		}
@@ -348,14 +345,14 @@  discard block
 block discarded – undo
348 345
 		if ($root == '/')
349 346
 		{
350 347
 			$hook_data = self::call_hook();
351
-			foreach($hook_data as $app => $app_data)
348
+			foreach ($hook_data as $app => $app_data)
352 349
 			{
353
-				if(!is_array($app_data))
350
+				if (!is_array($app_data))
354 351
 				{
355 352
 					// Application has no data
356 353
 					continue;
357 354
 				}
358
-				foreach($app_data as $text => $data)
355
+				foreach ($app_data as $text => $data)
359 356
 				{
360 357
 					if (!is_array($data))
361 358
 					{
@@ -386,18 +383,17 @@  discard block
 block discarded – undo
386 383
 						}
387 384
 					}
388 385
 					unset($data['icon']);
389
-					$parent =& $tree['item'];
386
+					$parent = & $tree['item'];
390 387
 					$parts = explode('/', $data['id']);
391
-					if ($data['id'][0] == '/') array_shift($parts);	// remove root
388
+					if ($data['id'][0] == '/') array_shift($parts); // remove root
392 389
 					array_pop($parts);
393 390
 					$path = '';
394
-					foreach($parts as $part)
391
+					foreach ($parts as $part)
395 392
 					{
396 393
 						$path .= ($path == '/' ? '' : '/').$part;
397 394
 						if (!isset($parent[$path]))
398 395
 						{
399
-							$icon = etemplate_widget_tree::imagePath($part == 'apps' ? common::image('phpgwapi', 'home') :
400
-								(($i=common::image($part, 'navbar')) ? $i : common::image('phpgwapi', 'nonav')));
396
+							$icon = etemplate_widget_tree::imagePath($part == 'apps' ? common::image('phpgwapi', 'home') : (($i = common::image($part, 'navbar')) ? $i : common::image('phpgwapi', 'nonav')));
401 397
 							$parent[$path] = array(
402 398
 								'id' => $path,
403 399
 								'text' => $part == 'apps' ? lang('Applications') : lang($part),
@@ -409,7 +405,7 @@  discard block
 block discarded – undo
409 405
 							);
410 406
 							if ($path == '/admin') $parent[$path]['open'] = true;
411 407
 						}
412
-						$parent =& $parent[$path]['item'];
408
+						$parent = & $parent[$path]['item'];
413 409
 					}
414 410
 					$data['text'] = lang($data['text']);
415 411
 					if (!empty($data['tooltip'])) $data['tooltip'] = lang($data['tooltip']);
@@ -421,7 +417,7 @@  discard block
 block discarded – undo
421 417
 		}
422 418
 		elseif ($root == '/groups')
423 419
 		{
424
-			foreach($GLOBALS['egw']->accounts->search(array(
420
+			foreach ($GLOBALS['egw']->accounts->search(array(
425 421
 				'type' => 'groups',
426 422
 				'order' => 'account_lid',
427 423
 				'sort' => 'ASC',
@@ -448,8 +444,8 @@  discard block
 block discarded – undo
448 444
 	private static function fix_userdata(array $data)
449 445
 	{
450 446
 		// store link as userdata, maybe we should store everything not directly understood by tree this way ...
451
-		foreach(array_diff_key($data, array_flip(array(
452
-			'id','text','tooltip','im0','im1','im2','item','child','select','open','call',
447
+		foreach (array_diff_key($data, array_flip(array(
448
+			'id', 'text', 'tooltip', 'im0', 'im1', 'im2', 'item', 'child', 'select', 'open', 'call',
453 449
 		))) as $name => $content)
454 450
 		{
455 451
 			$data['userdata'][] = array(
@@ -469,7 +465,7 @@  discard block
 block discarded – undo
469 465
 	private static function strip_item_keys(array &$items)
470 466
 	{
471 467
 		$items = array_values($items);
472
-		foreach($items as &$item)
468
+		foreach ($items as &$item)
473 469
 		{
474 470
 			if (is_array($item) && isset($item['item']))
475 471
 			{
@@ -487,7 +483,7 @@  discard block
 block discarded – undo
487 483
 	protected static function call_hook()
488 484
 	{
489 485
 		self::$hook_data = array();
490
-		function display_section($appname,$file,$file2=False)
486
+		function display_section($appname, $file, $file2 = False)
491 487
 		{
492 488
 			admin_ui::$hook_data[$appname] = $file2 ? $file2 : $file;
493 489
 			//error_log(__METHOD__."(".array2string(func_get_args()).")");
Please login to merge, or discard this patch.
Braces   +85 added lines, -21 removed lines patch added patch discarded remove patch
@@ -43,7 +43,10 @@  discard block
 block discarded – undo
43 43
 		}
44 44
 		$tpl = new etemplate_new('admin.index');
45 45
 
46
-		if (!is_array($content)) $content = array();
46
+		if (!is_array($content))
47
+		{
48
+			$content = array();
49
+		}
47 50
 		$content['nm'] = array(
48 51
 			'get_rows' => 'admin_ui::get_users',
49 52
 			'no_cat' => true,
@@ -128,7 +131,9 @@  discard block
 block discarded – undo
128 131
 				'group' => 2,
129 132
 			),
130 133
 		);
131
-		if (!$GLOBALS['egw']->acl->check('account_access',64,'admin'))	// no rights to set ACL-rights
134
+		if (!$GLOBALS['egw']->acl->check('account_access',64,'admin'))
135
+		{
136
+			// no rights to set ACL-rights
132 137
 		{
133 138
 			$actions['deny'] = array(
134 139
 				'caption'   => 'Deny access',
@@ -139,6 +144,7 @@  discard block
 block discarded – undo
139 144
 				'group'     => 2,
140 145
 			);
141 146
 		}
147
+		}
142 148
 		$group = 5;	// allow to place actions in different groups by hook, this is the default
143 149
 		// supporting both old way using $GLOBALS['menuData'] and new just returning data in hook
144 150
 		$apps = array_unique(array_merge(array('admin'), $GLOBALS['egw']->hooks->hook_implemented('edit_group')));
@@ -146,7 +152,10 @@  discard block
 block discarded – undo
146 152
 		{
147 153
 			$GLOBALS['menuData'] = $data = array();
148 154
 			$data = $GLOBALS['egw']->hooks->single('edit_group', $app);
149
-			if (!is_array($data)) $data = $GLOBALS['menuData'];
155
+			if (!is_array($data))
156
+			{
157
+				$data = $GLOBALS['menuData'];
158
+			}
150 159
 			//error_log(__METHOD__."() app $app returned ".array2string($data));
151 160
 			foreach($data as $item)
152 161
 			{
@@ -166,15 +175,33 @@  discard block
 block discarded – undo
166 175
 					{
167 176
 						$item['popup'] = $matches[2].'x'.$matches[3];
168 177
 						$item['onExecute'] = 'javaScript:nm_action';
169
-						if (isset($matches[5])) $item['tooltip'] = $matches[5];
178
+						if (isset($matches[5]))
179
+						{
180
+							$item['tooltip'] = $matches[5];
181
+						}
170 182
 						unset($item['options']);
171 183
 					}
172 184
 				}
173
-				if (empty($item['icon'])) $item['icon'] = $app.'/navbar';
174
-				if (empty($item['group'])) $item['group'] = $group;
175
-				if (empty($item['onExecute'])) $item['onExecute'] = 'javaScript:app.admin.group';
176
-				if (!isset($item['allowOnMultiple'])) $item['allowOnMultiple'] = false;
177
-				if (!isset($item['enableId'])) $item['enableId'] = '^/groups/-\\d+';
185
+				if (empty($item['icon']))
186
+				{
187
+					$item['icon'] = $app.'/navbar';
188
+				}
189
+				if (empty($item['group']))
190
+				{
191
+					$item['group'] = $group;
192
+				}
193
+				if (empty($item['onExecute']))
194
+				{
195
+					$item['onExecute'] = 'javaScript:app.admin.group';
196
+				}
197
+				if (!isset($item['allowOnMultiple']))
198
+				{
199
+					$item['allowOnMultiple'] = false;
200
+				}
201
+				if (!isset($item['enableId']))
202
+				{
203
+					$item['enableId'] = '^/groups/-\\d+';
204
+				}
178 205
 
179 206
 				$actions[$item['id']] = $item;
180 207
 			}
@@ -227,7 +254,10 @@  discard block
 block discarded – undo
227 254
 			{
228 255
 				$GLOBALS['menuData'] = $data = array();
229 256
 				$data = $GLOBALS['egw']->hooks->single('edit_user', $app);
230
-				if (!is_array($data)) $data = $GLOBALS['menuData'];
257
+				if (!is_array($data))
258
+				{
259
+					$data = $GLOBALS['menuData'];
260
+				}
231 261
 				foreach($data as $item)
232 262
 				{
233 263
 					// allow hook to return "real" actions, but still support legacy: description, url, extradata, options
@@ -245,15 +275,30 @@  discard block
 block discarded – undo
245 275
 						if ($item['options'] && preg_match('/(egw_openWindowCentered2?|window.open)\([^)]+,(\d+),(\d+).*(title="([^"]+)")?/', $item['options'], $matches))
246 276
 						{
247 277
 							$item['popup'] = $matches[2].'x'.$matches[3];
248
-							if (isset($matches[5])) $item['tooltip'] = $matches[5];
278
+							if (isset($matches[5]))
279
+							{
280
+								$item['tooltip'] = $matches[5];
281
+							}
249 282
 							unset($item['options']);
250 283
 						}
251 284
 					}
252
-					if (empty($item['icon'])) $item['icon'] = $app.'/navbar';
253
-					if (empty($item['group'])) $item['group'] = $group;
254
-					if (empty($item['onExecute'])) $item['onExecute'] = $item['popup'] ?
285
+					if (empty($item['icon']))
286
+					{
287
+						$item['icon'] = $app.'/navbar';
288
+					}
289
+					if (empty($item['group']))
290
+					{
291
+						$item['group'] = $group;
292
+					}
293
+					if (empty($item['onExecute']))
294
+					{
295
+						$item['onExecute'] = $item['popup'] ?
255 296
 						'javaScript:nm_action' : 'javaScript:app.admin.iframe_location';
256
-					if (!isset($item['allowOnMultiple'])) $item['allowOnMultiple'] = false;
297
+					}
298
+					if (!isset($item['allowOnMultiple']))
299
+					{
300
+						$item['allowOnMultiple'] = false;
301
+					}
257 302
 
258 303
 					$actions[$item['id']] = $item;
259 304
 				}
@@ -309,7 +354,10 @@  discard block
 block discarded – undo
309 354
 						($row['account_expires'] != -1 ? lang('Expires').' '.egw_time::to($row['account_expires'], true) :
310 355
 							lang('Enabled')));
311 356
 
312
-			if (!self::$accounts->is_active($row)) $row['status_class'] = 'adminAccountInactive';
357
+			if (!self::$accounts->is_active($row))
358
+			{
359
+				$row['status_class'] = 'adminAccountInactive';
360
+			}
313 361
 		}
314 362
 
315 363
 		return self::$accounts->total;
@@ -363,7 +411,10 @@  discard block
 block discarded – undo
363 411
 							'link' => $data,
364 412
 						);
365 413
 					}
366
-					if (empty($data['text'])) $data['text'] = $text;
414
+					if (empty($data['text']))
415
+					{
416
+						$data['text'] = $text;
417
+					}
367 418
 					if (empty($data['id']))
368 419
 					{
369 420
 						$data['id'] = $root.($app == 'admin' ? 'admin' : 'apps/'.$app).'/';
@@ -388,7 +439,11 @@  discard block
 block discarded – undo
388 439
 					unset($data['icon']);
389 440
 					$parent =& $tree['item'];
390 441
 					$parts = explode('/', $data['id']);
391
-					if ($data['id'][0] == '/') array_shift($parts);	// remove root
442
+					if ($data['id'][0] == '/')
443
+					{
444
+						array_shift($parts);
445
+					}
446
+					// remove root
392 447
 					array_pop($parts);
393 448
 					$path = '';
394 449
 					foreach($parts as $part)
@@ -407,14 +462,23 @@  discard block
 block discarded – undo
407 462
 								'item' => array(),
408 463
 								'child' => 1,
409 464
 							);
410
-							if ($path == '/admin') $parent[$path]['open'] = true;
465
+							if ($path == '/admin')
466
+							{
467
+								$parent[$path]['open'] = true;
468
+							}
411 469
 						}
412 470
 						$parent =& $parent[$path]['item'];
413 471
 					}
414 472
 					$data['text'] = lang($data['text']);
415
-					if (!empty($data['tooltip'])) $data['tooltip'] = lang($data['tooltip']);
473
+					if (!empty($data['tooltip']))
474
+					{
475
+						$data['tooltip'] = lang($data['tooltip']);
476
+					}
416 477
 					// make sure keys are unique, as we overwrite tree entries otherwise
417
-					if (isset($parent[$data['id']])) $data['id'] .= md5($data['link']);
478
+					if (isset($parent[$data['id']]))
479
+					{
480
+						$data['id'] .= md5($data['link']);
481
+					}
418 482
 					$parent[$data['id']] = self::fix_userdata($data);
419 483
 				}
420 484
 			}
Please login to merge, or discard this patch.