Completed
Push — 16.1 ( 7ccc73...046888 )
by Nathan
64:46 queued 51:15
created
notifications/inc/class.notifications_popup.inc.php 4 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -121,7 +121,6 @@
 block discarded – undo
121 121
 	 * saves notification into database so that the client can fetch it from there
122 122
 	 *
123 123
 	 * @param string $_message
124
-	 * @param array $_user_sessions
125 124
 	 */
126 125
 	private function save( $_message ) {
127 126
 		$result = $this->db->insert( self::_notification_table, array(
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
 	 */
84 84
 	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) {
85 85
 		//error_log(__METHOD__."(".array2string($_sender).', '.array2string($_recipient).', '.array2string($config).',...)');
86
-		if(!is_object($_sender)) { throw new Exception("no sender given."); }
87
-		if(!is_object($_recipient)) { throw new Exception("no recipient given."); }
86
+		if (!is_object($_sender)) { throw new Exception("no sender given."); }
87
+		if (!is_object($_recipient)) { throw new Exception("no recipient given."); }
88 88
 		$this->sender = $_sender;
89 89
 		$this->recipient = $_recipient;
90 90
 		$this->config = $_config;
@@ -102,19 +102,19 @@  discard block
 block discarded – undo
102 102
 	 */
103 103
 	public function send(array $_messages, $_subject = false, $_links = false, $_attachments = false)
104 104
 	{
105
-		unset($_attachments);	// not used
105
+		unset($_attachments); // not used
106 106
 		// Check access log to see if user is still logged in
107
-		if ( !Api\Session::notifications_active($this->recipient->account_id) )
107
+		if (!Api\Session::notifications_active($this->recipient->account_id))
108 108
 		{
109 109
 			throw new Exception("User {$this->recipient->account_lid} isn't online. Can't send notification via popup");
110 110
 		}
111 111
 
112
-		$message = 	$this->render_infos($_subject)
112
+		$message = $this->render_infos($_subject)
113 113
 					.Api\Html::hr()
114
-					.(isset($_messages['popup'])&&!empty($_messages['popup'])?$_messages['popup']:$_messages['html'])
114
+					.(isset($_messages['popup']) && !empty($_messages['popup']) ? $_messages['popup'] : $_messages['html'])
115 115
 					.$this->render_links($_links);
116 116
 
117
-		$this->save( $message );
117
+		$this->save($message);
118 118
 	}
119 119
 
120 120
 	/**
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
 	 * @param string $_message
124 124
 	 * @param array $_user_sessions
125 125
 	 */
126
-	private function save( $_message ) {
127
-		$result = $this->db->insert( self::_notification_table, array(
126
+	private function save($_message) {
127
+		$result = $this->db->insert(self::_notification_table, array(
128 128
 			'account_id'     => $this->recipient->account_id,
129 129
 			'notify_message' => $_message,
130 130
 			'notify_type'	 => self::_type
131
-			), false,__LINE__,__FILE__,self::_appname);
131
+			), false, __LINE__, __FILE__, self::_appname);
132 132
 		if ($result === false) throw new Exception("Can't save notification into SQL table");
133 133
 	}
134 134
 
@@ -140,25 +140,25 @@  discard block
 block discarded – undo
140 140
 	 * @return string html rendered link(s) as complete string with jspopup or a new window
141 141
 	 */
142 142
 	private function render_links($_links = false) {
143
-		if(!is_array($_links) || count($_links) == 0) { return false; }
143
+		if (!is_array($_links) || count($_links) == 0) { return false; }
144 144
 		$newline = "<br />";
145 145
 
146 146
 		$rendered_links = array();
147
-		foreach($_links as $link) {
148
-			if(!$link->popup) { $link->view['no_popup'] = 1; }
147
+		foreach ($_links as $link) {
148
+			if (!$link->popup) { $link->view['no_popup'] = 1; }
149 149
 
150 150
 			// do not expose sensitive data
151
-			$url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',
151
+			$url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/', '',
152 152
 				Api\Html::link('/index.php', $link->view));
153 153
 			// extract application-icon from menuaction
154
-			if($link->view['menuaction']) {
155
-				$menuaction_arr = explode('.',$link->view['menuaction']);
154
+			if ($link->view['menuaction']) {
155
+				$menuaction_arr = explode('.', $link->view['menuaction']);
156 156
 				$application = $menuaction_arr[0];
157
-				$image = $application ? Api\Html::image($application,'navbar',$link->text,'align="middle" style="width: 24px; margin-right: 0.5em;"') : '';
157
+				$image = $application ? Api\Html::image($application, 'navbar', $link->text, 'align="middle" style="width: 24px; margin-right: 0.5em;"') : '';
158 158
 			} else {
159 159
 				$image = '';
160 160
 			}
161
-			if($link->popup && !$GLOBALS['egw_info']['user']['preferences']['notifications']['external_mailclient'])
161
+			if ($link->popup && !$GLOBALS['egw_info']['user']['preferences']['notifications']['external_mailclient'])
162 162
 			{
163 163
 				$data = array(
164 164
 					"data-app = '{$link->app}'",
@@ -167,14 +167,14 @@  discard block
 block discarded – undo
167 167
 					"data-popup = '{$link->popup}'"
168 168
 				);
169 169
 
170
-				$rendered_links[] = Api\Html::div($image.$link->text,implode(' ',$data),'link');
170
+				$rendered_links[] = Api\Html::div($image.$link->text, implode(' ', $data), 'link');
171 171
 			} else {
172
-				$rendered_links[] = Api\Html::div('<a href="'.$url.'" target="_blank">'.$image.$link->text.'</a>','','link');
172
+				$rendered_links[] = Api\Html::div('<a href="'.$url.'" target="_blank">'.$image.$link->text.'</a>', '', 'link');
173 173
 			}
174 174
 
175 175
 		}
176
-		if(count($rendered_links) > 0) {
177
-			return Api\Html::hr().Api\Html::bold(lang('Linked entries:')).$newline.implode($newline,$rendered_links);
176
+		if (count($rendered_links) > 0) {
177
+			return Api\Html::hr().Api\Html::bold(lang('Linked entries:')).$newline.implode($newline, $rendered_links);
178 178
 		}
179 179
 	}
180 180
 
@@ -187,9 +187,9 @@  discard block
 block discarded – undo
187 187
 	 * @param int $height =400 height of the window
188 188
 	 * @return string javascript (using single quotes)
189 189
 	 */
190
-	private function jspopup($link,$target='_blank',$width=750,$height=410)
190
+	private function jspopup($link, $target = '_blank', $width = 750, $height = 410)
191 191
 	{
192
-		if($GLOBALS['egw_info']['user']['preferences']['notifications']['external_mailclient'])
192
+		if ($GLOBALS['egw_info']['user']['preferences']['notifications']['external_mailclient'])
193 193
 		{
194 194
 			return 'window.open('.($link == 'this.href' ? $link : "'".$link."'").','.
195 195
 				($target == 'this.target' ? $target : "'".$target."'").",$width,$height,'yes')";
@@ -213,8 +213,8 @@  discard block
 block discarded – undo
213 213
 
214 214
 		$sender = $this->sender->account_fullname ? $this->sender->account_fullname : $this->sender_account_email;
215 215
 		$infos[] = lang('Message from').': '.$sender;
216
-		if(!empty($_subject)) { $infos[] = Api\Html::bold($_subject); }
217
-		return implode($newline,$infos);
216
+		if (!empty($_subject)) { $infos[] = Api\Html::bold($_subject); }
217
+		return implode($newline, $infos);
218 218
 	}
219 219
 
220 220
 	/**
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
 	 * @param settings array with keys account_id and new_owner (new_owner is optional)
224 224
 	 */
225 225
 	public static function deleteaccount($settings) {
226
-		$GLOBALS['egw']->db->delete( self::_notification_table, array(
226
+		$GLOBALS['egw']->db->delete(self::_notification_table, array(
227 227
 			'account_id'	=> $settings['account_id']
228
-		),__LINE__,__FILE__,self::_appname);
228
+		), __LINE__, __FILE__, self::_appname);
229 229
 	}
230 230
 }
Please login to merge, or discard this patch.
Braces   +43 added lines, -17 removed lines patch added patch discarded remove patch
@@ -21,7 +21,8 @@  discard block
 block discarded – undo
21 21
  * out the table to look if there is a notificaton for this
22 22
  * client. The second stage is done in class.notifications_ajax.inc.php
23 23
  */
24
-class notifications_popup implements notifications_iface {
24
+class notifications_popup implements notifications_iface
25
+{
25 26
 
26 27
 	/**
27 28
 	 * Appname
@@ -81,10 +82,15 @@  discard block
 block discarded – undo
81 82
 	 * @param object $_config
82 83
 	 * @param object $_preferences
83 84
 	 */
84
-	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) {
85
+	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null)
86
+	{
85 87
 		//error_log(__METHOD__."(".array2string($_sender).', '.array2string($_recipient).', '.array2string($config).',...)');
86
-		if(!is_object($_sender)) { throw new Exception("no sender given."); }
87
-		if(!is_object($_recipient)) { throw new Exception("no recipient given."); }
88
+		if(!is_object($_sender))
89
+		{
90
+throw new Exception("no sender given."); }
91
+		if(!is_object($_recipient))
92
+		{
93
+throw new Exception("no recipient given."); }
88 94
 		$this->sender = $_sender;
89 95
 		$this->recipient = $_recipient;
90 96
 		$this->config = $_config;
@@ -123,13 +129,17 @@  discard block
 block discarded – undo
123 129
 	 * @param string $_message
124 130
 	 * @param array $_user_sessions
125 131
 	 */
126
-	private function save( $_message ) {
132
+	private function save( $_message )
133
+	{
127 134
 		$result = $this->db->insert( self::_notification_table, array(
128 135
 			'account_id'     => $this->recipient->account_id,
129 136
 			'notify_message' => $_message,
130 137
 			'notify_type'	 => self::_type
131 138
 			), false,__LINE__,__FILE__,self::_appname);
132
-		if ($result === false) throw new Exception("Can't save notification into SQL table");
139
+		if ($result === false)
140
+		{
141
+			throw new Exception("Can't save notification into SQL table");
142
+		}
133 143
 	}
134 144
 
135 145
 	/**
@@ -139,23 +149,32 @@  discard block
 block discarded – undo
139 149
 	 * @param array $_links
140 150
 	 * @return string html rendered link(s) as complete string with jspopup or a new window
141 151
 	 */
142
-	private function render_links($_links = false) {
143
-		if(!is_array($_links) || count($_links) == 0) { return false; }
152
+	private function render_links($_links = false)
153
+	{
154
+		if(!is_array($_links) || count($_links) == 0)
155
+		{
156
+return false; }
144 157
 		$newline = "<br />";
145 158
 
146 159
 		$rendered_links = array();
147
-		foreach($_links as $link) {
148
-			if(!$link->popup) { $link->view['no_popup'] = 1; }
160
+		foreach($_links as $link)
161
+		{
162
+			if(!$link->popup)
163
+			{
164
+$link->view['no_popup'] = 1; }
149 165
 
150 166
 			// do not expose sensitive data
151 167
 			$url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',
152 168
 				Api\Html::link('/index.php', $link->view));
153 169
 			// extract application-icon from menuaction
154
-			if($link->view['menuaction']) {
170
+			if($link->view['menuaction'])
171
+			{
155 172
 				$menuaction_arr = explode('.',$link->view['menuaction']);
156 173
 				$application = $menuaction_arr[0];
157 174
 				$image = $application ? Api\Html::image($application,'navbar',$link->text,'align="middle" style="width: 24px; margin-right: 0.5em;"') : '';
158
-			} else {
175
+			}
176
+			else
177
+			{
159 178
 				$image = '';
160 179
 			}
161 180
 			if($link->popup && !$GLOBALS['egw_info']['user']['preferences']['notifications']['external_mailclient'])
@@ -168,12 +187,15 @@  discard block
 block discarded – undo
168 187
 				);
169 188
 
170 189
 				$rendered_links[] = Api\Html::div($image.$link->text,implode(' ',$data),'link');
171
-			} else {
190
+			}
191
+			else
192
+			{
172 193
 				$rendered_links[] = Api\Html::div('<a href="'.$url.'" target="_blank">'.$image.$link->text.'</a>','','link');
173 194
 			}
174 195
 
175 196
 		}
176
-		if(count($rendered_links) > 0) {
197
+		if(count($rendered_links) > 0)
198
+		{
177 199
 			return Api\Html::hr().Api\Html::bold(lang('Linked entries:')).$newline.implode($newline,$rendered_links);
178 200
 		}
179 201
 	}
@@ -207,13 +229,16 @@  discard block
 block discarded – undo
207 229
 	 * @param string $_subject
208 230
 	 * @return string html rendered info as complete string
209 231
 	 */
210
-	private function render_infos($_subject = false) {
232
+	private function render_infos($_subject = false)
233
+	{
211 234
 		$infos = array();
212 235
 		$newline = "<br />";
213 236
 
214 237
 		$sender = $this->sender->account_fullname ? $this->sender->account_fullname : $this->sender_account_email;
215 238
 		$infos[] = lang('Message from').': '.$sender;
216
-		if(!empty($_subject)) { $infos[] = Api\Html::bold($_subject); }
239
+		if(!empty($_subject))
240
+		{
241
+$infos[] = Api\Html::bold($_subject); }
217 242
 		return implode($newline,$infos);
218 243
 	}
219 244
 
@@ -222,7 +247,8 @@  discard block
 block discarded – undo
222 247
 	 *
223 248
 	 * @param settings array with keys account_id and new_owner (new_owner is optional)
224 249
 	 */
225
-	public static function deleteaccount($settings) {
250
+	public static function deleteaccount($settings)
251
+	{
226 252
 		$GLOBALS['egw']->db->delete( self::_notification_table, array(
227 253
 			'account_id'	=> $settings['account_id']
228 254
 		),__LINE__,__FILE__,self::_appname);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@
 block discarded – undo
106 106
 		// Check access log to see if user is still logged in
107 107
 		if ( !Api\Session::notifications_active($this->recipient->account_id) )
108 108
 		{
109
-			throw new Exception("User {$this->recipient->account_lid} isn't online. Can't send notification via popup");
109
+			throw new Exception("user {$this->recipient->account_lid} isn't online. Can't send notification via popup");
110 110
 		}
111 111
 
112 112
 		$message = 	$this->render_infos($_subject)
Please login to merge, or discard this patch.
notifications/inc/class.notifications_winpopup.inc.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 * checks for a valid IPv4-address without CIDR notation
156 156
 	 *
157 157
 	 * @param string $_ip
158
-	 * @return true or false
158
+	 * @return integer or false
159 159
 	 */
160 160
 	private function valid_ip($_ip) {
161 161
 		return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$_ip);
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 * renders additional info from subject
166 166
 	 *
167 167
 	 * @param string $_subject
168
-	 * @return plain rendered info as complete string
168
+	 * @return string|false rendered info as complete string
169 169
 	 */
170 170
 	private function render_infos($_subject = false) {
171 171
 		$newline = "\n";
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
 	 * @param object $_preferences
82 82
 	 */
83 83
 	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) {
84
-		if(!is_object($_sender)) { throw new Exception("no sender given."); }
85
-		if(!is_object($_recipient)) { throw new Exception("no recipient given."); }
86
-		if(!$this->netbios_command) {
87
-			throw new Exception(	'Winpopup plugin not configured yet. Skipped sending notification message. '.
84
+		if (!is_object($_sender)) { throw new Exception("no sender given."); }
85
+		if (!is_object($_recipient)) { throw new Exception("no recipient given."); }
86
+		if (!$this->netbios_command) {
87
+			throw new Exception('Winpopup plugin not configured yet. Skipped sending notification message. '.
88 88
 									'Please check var "netbios_command" in winpopup backend '.
89
-									'('.EGW_INCLUDE_ROOT. '/'. self::_appname. '/inc/class.notifications_winpopup.inc.php).');
89
+									'('.EGW_INCLUDE_ROOT.'/'.self::_appname.'/inc/class.notifications_winpopup.inc.php).');
90 90
 		}
91 91
 		$this->sender = $_sender;
92 92
 		$this->recipient = $_recipient;
@@ -104,19 +104,19 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	public function send(array $_messages, $_subject = false, $_links = false, $_attachments = false)
106 106
 	{
107
-		unset($_links, $_attachments);	// not used
107
+		unset($_links, $_attachments); // not used
108 108
 
109 109
 		$user_sessions = array();
110 110
 		foreach (Api\Session::session_list(0, 'asc', 'session_dla', true) as $session) {
111
-			if ($session['session_lid'] == $this->recipient->account_lid. '@'. $GLOBALS['egw_info']['user']['domain']) {
112
-				if($this->valid_ip($session['session_ip'])) {
111
+			if ($session['session_lid'] == $this->recipient->account_lid.'@'.$GLOBALS['egw_info']['user']['domain']) {
112
+				if ($this->valid_ip($session['session_ip'])) {
113 113
 					$user_sessions[] = $session['session_ip'];
114 114
 				}
115 115
 			}
116 116
 		}
117
-		if ( empty($user_sessions) ) throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup");
117
+		if (empty($user_sessions)) throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup");
118 118
 
119
-		$this->send_winpopup( $this->render_infos($_subject).$_messages['plain'], $user_sessions );
119
+		$this->send_winpopup($this->render_infos($_subject).$_messages['plain'], $user_sessions);
120 120
 		return true;
121 121
 	}
122 122
 
@@ -126,15 +126,15 @@  discard block
 block discarded – undo
126 126
 	 * @param string $_message
127 127
 	 * @param array $_user_sessions
128 128
 	 */
129
-	private function send_winpopup( $_message, array $_user_sessions ) {
130
-		foreach($_user_sessions as $user_session) {
131
-			$ip_octets=explode(".",$user_session);
129
+	private function send_winpopup($_message, array $_user_sessions) {
130
+		foreach ($_user_sessions as $user_session) {
131
+			$ip_octets = explode(".", $user_session);
132 132
 			// format the ip_octets to 3 digits each
133
-			foreach($ip_octets as $id=>$ip_octet) {
134
-				if(strlen($ip_octet)==1) { $ip_octets[$id] = '00'.$ip_octet; }
135
-				if(strlen($ip_octet)==2) { $ip_octets[$id] = '0'.$ip_octet; }
133
+			foreach ($ip_octets as $id=>$ip_octet) {
134
+				if (strlen($ip_octet) == 1) { $ip_octets[$id] = '00'.$ip_octet; }
135
+				if (strlen($ip_octet) == 2) { $ip_octets[$id] = '0'.$ip_octet; }
136 136
 			}
137
-			$placeholders = array(	'/\[MESSAGE\]/' => escapeshellarg($_message), // prevent code injection
137
+			$placeholders = array('/\[MESSAGE\]/' => escapeshellarg($_message), // prevent code injection
138 138
 									'/\[1\]/' => $ip_octets[0],
139 139
 									'/\[2\]/' => $ip_octets[1],
140 140
 									'/\[3\]/' => $ip_octets[2],
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 									);
145 145
 			$command = preg_replace(array_keys($placeholders), $placeholders, $this->netbios_command);
146 146
 			$output = $returncode = null;
147
-			exec($command,$output,$returncode);
148
-			if($returncode != 0) {
147
+			exec($command, $output, $returncode);
148
+			if ($returncode != 0) {
149 149
 				throw new Exception("Failed sending notification message via winpopup. Error while executing the specified command.");
150 150
 			}
151 151
 		}
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 * @return true or false
159 159
 	 */
160 160
 	private function valid_ip($_ip) {
161
-		return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$_ip);
161
+		return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$', $_ip);
162 162
 	}
163 163
 
164 164
 	/**
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	 */
170 170
 	private function render_infos($_subject = false) {
171 171
 		$newline = "\n";
172
-		if(!empty($_subject)) { return $_subject.$newline; }
172
+		if (!empty($_subject)) { return $_subject.$newline; }
173 173
 		return false;
174 174
 	}
175 175
 }
176 176
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +43 added lines, -18 removed lines patch added patch discarded remove patch
@@ -15,7 +15,8 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * User notification via winpopup.
17 17
  */
18
-class notifications_winpopup implements notifications_iface {
18
+class notifications_winpopup implements notifications_iface
19
+{
19 20
 
20 21
 	/**
21 22
 	 * Appname
@@ -80,10 +81,16 @@  discard block
 block discarded – undo
80 81
 	 * @param object $_config
81 82
 	 * @param object $_preferences
82 83
 	 */
83
-	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) {
84
-		if(!is_object($_sender)) { throw new Exception("no sender given."); }
85
-		if(!is_object($_recipient)) { throw new Exception("no recipient given."); }
86
-		if(!$this->netbios_command) {
84
+	public function __construct($_sender, $_recipient, $_config = null, $_preferences = null)
85
+	{
86
+		if(!is_object($_sender))
87
+		{
88
+throw new Exception("no sender given."); }
89
+		if(!is_object($_recipient))
90
+		{
91
+throw new Exception("no recipient given."); }
92
+		if(!$this->netbios_command)
93
+		{
87 94
 			throw new Exception(	'Winpopup plugin not configured yet. Skipped sending notification message. '.
88 95
 									'Please check var "netbios_command" in winpopup backend '.
89 96
 									'('.EGW_INCLUDE_ROOT. '/'. self::_appname. '/inc/class.notifications_winpopup.inc.php).');
@@ -107,14 +114,20 @@  discard block
 block discarded – undo
107 114
 		unset($_links, $_attachments);	// not used
108 115
 
109 116
 		$user_sessions = array();
110
-		foreach (Api\Session::session_list(0, 'asc', 'session_dla', true) as $session) {
111
-			if ($session['session_lid'] == $this->recipient->account_lid. '@'. $GLOBALS['egw_info']['user']['domain']) {
112
-				if($this->valid_ip($session['session_ip'])) {
117
+		foreach (Api\Session::session_list(0, 'asc', 'session_dla', true) as $session)
118
+		{
119
+			if ($session['session_lid'] == $this->recipient->account_lid. '@'. $GLOBALS['egw_info']['user']['domain'])
120
+			{
121
+				if($this->valid_ip($session['session_ip']))
122
+				{
113 123
 					$user_sessions[] = $session['session_ip'];
114 124
 				}
115 125
 			}
116 126
 		}
117
-		if ( empty($user_sessions) ) throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup");
127
+		if ( empty($user_sessions) )
128
+		{
129
+			throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup");
130
+		}
118 131
 
119 132
 		$this->send_winpopup( $this->render_infos($_subject).$_messages['plain'], $user_sessions );
120 133
 		return true;
@@ -126,13 +139,20 @@  discard block
 block discarded – undo
126 139
 	 * @param string $_message
127 140
 	 * @param array $_user_sessions
128 141
 	 */
129
-	private function send_winpopup( $_message, array $_user_sessions ) {
130
-		foreach($_user_sessions as $user_session) {
142
+	private function send_winpopup( $_message, array $_user_sessions )
143
+	{
144
+		foreach($_user_sessions as $user_session)
145
+		{
131 146
 			$ip_octets=explode(".",$user_session);
132 147
 			// format the ip_octets to 3 digits each
133
-			foreach($ip_octets as $id=>$ip_octet) {
134
-				if(strlen($ip_octet)==1) { $ip_octets[$id] = '00'.$ip_octet; }
135
-				if(strlen($ip_octet)==2) { $ip_octets[$id] = '0'.$ip_octet; }
148
+			foreach($ip_octets as $id=>$ip_octet)
149
+			{
150
+				if(strlen($ip_octet)==1)
151
+				{
152
+$ip_octets[$id] = '00'.$ip_octet; }
153
+				if(strlen($ip_octet)==2)
154
+				{
155
+$ip_octets[$id] = '0'.$ip_octet; }
136 156
 			}
137 157
 			$placeholders = array(	'/\[MESSAGE\]/' => escapeshellarg($_message), // prevent code injection
138 158
 									'/\[1\]/' => $ip_octets[0],
@@ -145,7 +165,8 @@  discard block
 block discarded – undo
145 165
 			$command = preg_replace(array_keys($placeholders), $placeholders, $this->netbios_command);
146 166
 			$output = $returncode = null;
147 167
 			exec($command,$output,$returncode);
148
-			if($returncode != 0) {
168
+			if($returncode != 0)
169
+			{
149 170
 				throw new Exception("Failed sending notification message via winpopup. Error while executing the specified command.");
150 171
 			}
151 172
 		}
@@ -157,7 +178,8 @@  discard block
 block discarded – undo
157 178
 	 * @param string $_ip
158 179
 	 * @return true or false
159 180
 	 */
160
-	private function valid_ip($_ip) {
181
+	private function valid_ip($_ip)
182
+	{
161 183
 		return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$_ip);
162 184
 	}
163 185
 
@@ -167,9 +189,12 @@  discard block
 block discarded – undo
167 189
 	 * @param string $_subject
168 190
 	 * @return plain rendered info as complete string
169 191
 	 */
170
-	private function render_infos($_subject = false) {
192
+	private function render_infos($_subject = false)
193
+	{
171 194
 		$newline = "\n";
172
-		if(!empty($_subject)) { return $_subject.$newline; }
195
+		if(!empty($_subject))
196
+		{
197
+return $_subject.$newline; }
173 198
 		return false;
174 199
 	}
175 200
 }
176 201
\ No newline at end of file
Please login to merge, or discard this patch.
pixelegg/inc/class.pixelegg_framework.inc.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
 	 * Overwritten to load our slider.js
56 56
 	 *
57 57
 	 * @param array $extra
58
-	 * @return type
58
+	 * @return string|null
59 59
 	 */
60 60
 	function header(array $extra=array())
61 61
 	{
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
 	 *
42 42
 	 * @param string $template ='pixelegg' name of the template
43 43
 	 */
44
-	function __construct($template=self::APP)
44
+	function __construct($template = self::APP)
45 45
 	{
46
-		parent::__construct($template);		// call the constructor of the extended class
46
+		parent::__construct($template); // call the constructor of the extended class
47 47
 
48 48
 		// search 'mobile' dirs first
49
-		if (Api\Header\UserAgent::mobile()) array_unshift ($this->template_dirs, 'mobile');
49
+		if (Api\Header\UserAgent::mobile()) array_unshift($this->template_dirs, 'mobile');
50 50
 	}
51 51
 
52 52
 	/**
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 * @param array $extra
58 58
 	 * @return type
59 59
 	 */
60
-	function header(array $extra=array())
60
+	function header(array $extra = array())
61 61
 	{
62 62
 		// load our slider.js, but only if framework requested
63 63
 		if (!self::$header_done && $_GET['cd'] === 'yes' &&
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
 	{
80 80
 		if ($color[0] == '#') $color = ltrim($color, '#');
81 81
 
82
-		$R = hexdec(substr($color,0,2));
83
-		$G = hexdec(substr($color,2,2));
84
-		$B = hexdec(substr($color,4,2));
82
+		$R = hexdec(substr($color, 0, 2));
83
+		$G = hexdec(substr($color, 2, 2));
84
+		$B = hexdec(substr($color, 4, 2));
85 85
 
86 86
 		$Rs = round($R * (100 + $percent) / 100);
87 87
 		$Gs = round($G * (100 + $percent) / 100);
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	{
105 105
 		$ret = parent::_get_css();
106 106
 		// color to use
107
-		$color = str_replace('custom',$GLOBALS['egw_info']['user']['preferences']['common']['template_custom_color'],
107
+		$color = str_replace('custom', $GLOBALS['egw_info']['user']['preferences']['common']['template_custom_color'],
108 108
 			$GLOBALS['egw_info']['user']['preferences']['common']['template_color']);
109 109
 
110 110
 		// Create a dark variant of the color
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 			$loginbox_color = $color_darker;
130 130
 		}
131 131
 
132
-		if (preg_match('/^(#[0-9A-F]+|[A-Z]+)$/i',$color))	// a little xss check
132
+		if (preg_match('/^(#[0-9A-F]+|[A-Z]+)$/i', $color))	// a little xss check
133 133
 		{
134 134
 			if (!Api\Header\UserAgent::mobile())
135 135
 			{
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 	 * @param string $extra_vars for login url
207 207
 	 * @param string $change_passwd =null string with message to render input fields for password change
208 208
 	 */
209
-	function login_screen($extra_vars, $change_passwd=null)
209
+	function login_screen($extra_vars, $change_passwd = null)
210 210
 	{
211 211
 		if (empty($GLOBALS['loginscreenmessage']))
212 212
 		{
Please login to merge, or discard this patch.
Braces   +24 added lines, -6 removed lines patch added patch discarded remove patch
@@ -46,7 +46,10 @@  discard block
 block discarded – undo
46 46
 		parent::__construct($template);		// call the constructor of the extended class
47 47
 
48 48
 		// search 'mobile' dirs first
49
-		if (Api\Header\UserAgent::mobile()) array_unshift ($this->template_dirs, 'mobile');
49
+		if (Api\Header\UserAgent::mobile())
50
+		{
51
+			array_unshift ($this->template_dirs, 'mobile');
52
+		}
50 53
 	}
51 54
 
52 55
 	/**
@@ -77,7 +80,10 @@  discard block
 block discarded – undo
77 80
 	 */
78 81
 	function _color_shader($color, $percent)
79 82
 	{
80
-		if ($color[0] == '#') $color = ltrim($color, '#');
83
+		if ($color[0] == '#')
84
+		{
85
+			$color = ltrim($color, '#');
86
+		}
81 87
 
82 88
 		$R = hexdec(substr($color,0,2));
83 89
 		$G = hexdec(substr($color,2,2));
@@ -87,9 +93,18 @@  discard block
 block discarded – undo
87 93
 		$Gs = round($G * (100 + $percent) / 100);
88 94
 		$Bs = round($B * (100 + $percent) / 100);
89 95
 
90
-		if ($Rs > 255) $Rs = 255;
91
-		if ($Gs > 255) $Gs = 255;
92
-		if ($Bs > 255) $Bs = 255;
96
+		if ($Rs > 255)
97
+		{
98
+			$Rs = 255;
99
+		}
100
+		if ($Gs > 255)
101
+		{
102
+			$Gs = 255;
103
+		}
104
+		if ($Bs > 255)
105
+		{
106
+			$Bs = 255;
107
+		}
93 108
 
94 109
 		return '#'.sprintf('%02X%02X%02X', $Rs, $Gs, $Bs);
95 110
 	}
@@ -129,7 +144,9 @@  discard block
 block discarded – undo
129 144
 			$loginbox_color = $color_darker;
130 145
 		}
131 146
 
132
-		if (preg_match('/^(#[0-9A-F]+|[A-Z]+)$/i',$color))	// a little xss check
147
+		if (preg_match('/^(#[0-9A-F]+|[A-Z]+)$/i',$color))
148
+		{
149
+			// a little xss check
133 150
 		{
134 151
 			if (!Api\Header\UserAgent::mobile())
135 152
 			{
@@ -168,6 +185,7 @@  discard block
 block discarded – undo
168 185
 
169 186
 
170 187
 ";
188
+		}
171 189
 				if ($GLOBALS['egw_info']['user']['preferences']['common']['theme'] == 'traditional')
172 190
 				{
173 191
 					$ret['app_css'] .= ".dialogFooterToolbar {background-color: $color !important;}";
Please login to merge, or discard this patch.
preferences/inc/class.preferences_settings.inc.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -292,7 +292,7 @@
 block discarded – undo
292 292
 	 * @param array &$sel_options
293 293
 	 * @param array &$readonlys
294 294
 	 * @param array &$types on return setting-name => setting-type
295
-	 * @param etemplate $tpl
295
+	 * @param Etemplate $tpl
296 296
 	 * @throws Api\Exception\WrongParameter
297 297
 	 * @return array content
298 298
 	 */
Please login to merge, or discard this patch.
Spacing   +56 added lines, -57 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 * @param array $content =null
46 46
 	 * @param string $msg =''
47 47
 	 */
48
-	function index(array $content=null, $msg='')
48
+	function index(array $content = null, $msg = '')
49 49
 	{
50 50
 		$tpl = new Etemplate('preferences.settings');
51 51
 		if (!is_array($content))
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 			{
71 71
 				list($button) = each($content['button']);
72 72
 				$appname = $content['old_appname'] ? $content['old_appname'] : 'common';
73
-				switch($button)
73
+				switch ($button)
74 74
 				{
75 75
 					case 'save':
76 76
 					case 'apply':
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
 						{
80 80
 							throw new Api\Exception\NoPermission\Admin;
81 81
 						}
82
-						list($type,$account_id) = explode(':', $content['old_type']);
82
+						list($type, $account_id) = explode(':', $content['old_type']);
83 83
 						// merge prefs of all tabs together again
84 84
 						$prefs = array();
85
-						foreach($content as $name => $val)
85
+						foreach ($content as $name => $val)
86 86
 						{
87 87
 							if (is_array($val) && strpos($name, 'tab') === 0)
88 88
 							{
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 						$old_values = array_intersect_key($GLOBALS['egw_info']['user']['preferences']['common'], array_flip($require_reload));
101 101
 
102 102
 						$attribute = $type == 'group' ? 'user' : $type;
103
-						if (!($msg=$this->process_array($GLOBALS['egw']->preferences->$attribute, $prefs, $content['types'], $appname, $attribute)))
103
+						if (!($msg = $this->process_array($GLOBALS['egw']->preferences->$attribute, $prefs, $content['types'], $appname, $attribute)))
104 104
 						{
105 105
 							$msg_type = 'success';
106 106
 							$msg = lang('Preferences saved.');
@@ -124,14 +124,14 @@  discard block
 block discarded – undo
124 124
 						// update client-side Api\Preferences in response
125 125
 						Framework::ajax_get_preference($appname);
126 126
 				}
127
-				if (in_array($button, array('save','cancel')))
127
+				if (in_array($button, array('save', 'cancel')))
128 128
 				{
129 129
 					Api\Json\Response::get()->call('egw.message', $msg, $msg_type);
130 130
 					Framework::window_close();
131 131
 				}
132 132
 			}
133 133
 			$appname = $content['appname'] ? $content['appname'] : 'common';
134
-			list($type,$account_id) = explode(':', $content['type']);
134
+			list($type, $account_id) = explode(':', $content['type']);
135 135
 			//_debug_array($prefs);
136 136
 		}
137 137
 		if ($account_id && $account_id != $GLOBALS['egw']->preferences->get_account_id())
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 		$preserve['current_app'] = $content['current_app'];
151 151
 		$GLOBALS['egw_info']['flags']['currentapp'] = $content['current_app'] == 'common' ?
152 152
 			'preferences' : $content['current_app'];
153
-		Framework::includeCSS('preferences','app');
153
+		Framework::includeCSS('preferences', 'app');
154 154
 
155 155
 		// if not just saved, call validation before, to be able to show failed validation of current prefs
156 156
 		if (!isset($button))
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	 * @param boolean $only_verify =false
183 183
 	 * @return string with verification error or null on success
184 184
 	 */
185
-	function process_array(array &$repository, array $values, array $types, $appname, $type, $only_verify=false)
185
+	function process_array(array &$repository, array $values, array $types, $appname, $type, $only_verify = false)
186 186
 	{
187 187
 		//fetch application specific settings from a hook
188 188
 		$settings = Api\Hooks::single(array(
@@ -195,10 +195,10 @@  discard block
 block discarded – undo
195 195
 
196 196
 		unset($prefs['']);
197 197
 		//_debug_array($values);exit;
198
-		foreach($values as $var => $value)
198
+		foreach ($values as $var => $value)
199 199
 		{
200 200
 			// type specific validation
201
-			switch((string)$types[$var])
201
+			switch ((string)$types[$var])
202 202
 			{
203 203
 				case 'password':	// dont write empty password-fields
204 204
 					if (empty($value)) continue 2;
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 						// empty is always allowed
212 212
 
213 213
 						// If forced, empty == not set
214
-						if($type == 'forced')
214
+						if ($type == 'forced')
215 215
 						{
216 216
 							unset($prefs[$var]);
217 217
 							// need to call preferences::delete, to also set affective prefs!
@@ -223,19 +223,19 @@  discard block
 block discarded – undo
223 223
 					{
224 224
 						if ($value[0] != '/' || !Vfs::stat($value) || Vfs::is_dir($value))
225 225
 						{
226
-							$error = lang('%1 is no existing vfs file!',htmlspecialchars($value));
226
+							$error = lang('%1 is no existing vfs file!', htmlspecialchars($value));
227 227
 						}
228 228
 					}
229 229
 					else
230 230
 					{
231 231
 						// split multiple comma or whitespace separated directories
232 232
 						// to still allow space or comma in dirnames, we also use the trailing slash of all pathes to split
233
-						foreach($types[$var] == 'vfs_dir' ? array($value) : preg_split('/[,\s]+\//', $value) as $n => $dir)
233
+						foreach ($types[$var] == 'vfs_dir' ? array($value) : preg_split('/[,\s]+\//', $value) as $n => $dir)
234 234
 						{
235
-							if ($n) $dir = '/'.$dir;	// re-adding trailing slash removed by split
235
+							if ($n) $dir = '/'.$dir; // re-adding trailing slash removed by split
236 236
 							if ($dir[0] != '/' || !Vfs::stat($dir) || !Vfs::is_dir($dir))
237 237
 							{
238
-								$error .= ($error ? ' ' : '').lang('%1 is no existing vfs directory!',$dir);
238
+								$error .= ($error ? ' ' : '').lang('%1 is no existing vfs directory!', $dir);
239 239
 							}
240 240
 						}
241 241
 					}
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 
250 250
 			if (isset($value) && $value !== '' && $value !== '**NULL**' && $value !== array())
251 251
 			{
252
-				if (is_array($value) && !$settings[$var]['no_sel_options']) $value = implode(',',$value);	// multiselect
252
+				if (is_array($value) && !$settings[$var]['no_sel_options']) $value = implode(',', $value); // multiselect
253 253
 
254 254
 				$prefs[$var] = $value;
255 255
 
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 		// if you return something else than False, it is treated as an error-msg and
270 270
 		// displayed to the user (the prefs are not saved)
271 271
 		//
272
-		if(($error .= Api\Hooks::single(array(
272
+		if (($error .= Api\Hooks::single(array(
273 273
 				'location' => 'verify_settings',
274 274
 				'prefs'    => &$repository[$appname],
275 275
 				'type'     => $type,
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 			return $error;
282 282
 		}
283 283
 
284
-		if (!$only_verify) $GLOBALS['egw']->preferences->save_repository(True,$type);
284
+		if (!$only_verify) $GLOBALS['egw']->preferences->save_repository(True, $type);
285 285
 
286 286
 		// certain common prefs (language, template, ...) require the session to be re-created
287 287
 		if ($appname == 'common' && !$only_verify)
@@ -317,19 +317,19 @@  discard block
 block discarded – undo
317 317
 		$sel_options = $readonlys = $content = $tabs = array();
318 318
 		// disable all but first tab and name current tab "tab1", for apps not using sections
319 319
 		$tab = 'tab1';
320
-		foreach($this->settings as $setting)
320
+		foreach ($this->settings as $setting)
321 321
 		{
322 322
 			if (!is_array($setting)) continue;
323 323
 			if ($type != 'forced' && (string)$GLOBALS['egw']->preferences->forced[$appname][$setting['name']] !== '')
324 324
 			{
325
-				continue;	// forced preferences are not displayed, unless we edit them
325
+				continue; // forced preferences are not displayed, unless we edit them
326 326
 			}
327 327
 			$types[$setting['name']] = $old_type = $setting['type'];
328 328
 
329
-			switch($old_type)
329
+			switch ($old_type)
330 330
 			{
331 331
 				case 'section':
332
-					$tab = 'tab'.(1+count($tabs));
332
+					$tab = 'tab'.(1 + count($tabs));
333 333
 					$tabs[] = array(
334 334
 						'id' => $tab,
335 335
 						'template' => 'preferences.settings.tab1',
@@ -344,24 +344,24 @@  discard block
 block discarded – undo
344 344
 					if (is_array($setting['values'])) $vars += $setting['values'];
345 345
 					$GLOBALS['egw']->preferences->{$attribute}[$appname][$setting['name']] =
346 346
 						$GLOBALS['egw']->preferences->lang_notify($GLOBALS['egw']->preferences->{$attribute}[$appname][$setting['name']], $vars);
347
-					$types[$setting['name']] = $vars;	// store vars for re-translation, instead type "notify"
347
+					$types[$setting['name']] = $vars; // store vars for re-translation, instead type "notify"
348 348
 					if ($setting['help'] && ($setting['run_lang'] || !isset($setting['run_lang'])))
349 349
 					{
350 350
 						$setting['help'] = lang($setting['help']);
351 351
 					}
352 352
 					$setting['help'] .= '<p><b>'.lang('Substitutions and their meanings:').'</b>';
353
-					foreach($vars as $var => $var_help)
353
+					foreach ($vars as $var => $var_help)
354 354
 					{
355 355
 						$lname = ($lname = lang($var)) == $var.'*' ? $var : $lname;
356 356
 						$setting['help'] .= "<br>\n".'<b>$$'.$lname.'$$</b>: '.$var_help;
357 357
 					}
358 358
 					$setting['help'] .= "</p>\n";
359
-					$setting['run_lang'] = false;	// already done now
359
+					$setting['run_lang'] = false; // already done now
360 360
 					// handle as textarea
361 361
 				case 'textarea':
362 362
 					$setting['type'] = is_a($tpl, 'etemplate') ? 'textarea' : 'textbox';
363 363
 					$tpl->setElementAttribute($tab.'['.$setting['name'].']', 'multiline', 'true');
364
-					$tpl->setElementAttribute($tab. '[' . $setting['name'] . ']','width', '99%' );
364
+					$tpl->setElementAttribute($tab.'['.$setting['name'].']', 'width', '99%');
365 365
 					// anyway setting via css: width: 99%, height: 5em
366 366
 					// for old eT use size attribute
367 367
 					if (is_a($tpl, 'etemplate') && (!empty($setting['cols']) || !empty($setting['rows'])))
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 				case 'multiselect':
384 384
 					$setting['type'] = 'select';
385 385
 					$tpl->setElementAttribute($tab.'['.$setting['name'].']', 'rows', 5);
386
-					if (!isset($setting['size'])) $setting['size'] = '5';	// old eT
386
+					if (!isset($setting['size'])) $setting['size'] = '5'; // old eT
387 387
 					break;
388 388
 				case 'color':
389 389
 					$setting['type'] = 'colorpicker';
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 				case 'date-duration':
392 392
 					if (!isset($setting['size'])) $setting['size'] = 'm,dhm,24,1';
393 393
 					$attrs = explode(',', $setting['size']);
394
-					foreach(array("data_format","display_format", "hours_per_day", "empty_not_0", "short_labels") as $n => $name)
394
+					foreach (array("data_format", "display_format", "hours_per_day", "empty_not_0", "short_labels") as $n => $name)
395 395
 					{
396 396
 						if ((string)$attrs[$n] !== '') $tpl->setElementAttribute($tab.'['.$setting['name'].']', $name, $attrs[$n]);
397 397
 					}
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 				case 'taglist':
400 400
 					if ($setting['no_sel_options'])
401 401
 					{
402
-						$tpl->setElementAttribute ($tab.'['.$setting['name'].']', 'autocomplete_url', '');
402
+						$tpl->setElementAttribute($tab.'['.$setting['name'].']', 'autocomplete_url', '');
403 403
 					}
404 404
 					break;
405 405
 			}
@@ -408,17 +408,17 @@  discard block
 block discarded – undo
408 408
 			{
409 409
 				if ($old_type != 'multiselect' && $old_type != 'notify')
410 410
 				{
411
-					switch($type)
411
+					switch ($type)
412 412
 					{
413 413
 						case 'user':
414
-							$setting['values'] = array('' => lang('Use default'))+$setting['values'];
414
+							$setting['values'] = array('' => lang('Use default')) + $setting['values'];
415 415
 							break;
416 416
 						case 'default':
417 417
 						case 'group':
418
-							$setting['values'] = array('' => lang('No default'))+$setting['values'];
418
+							$setting['values'] = array('' => lang('No default')) + $setting['values'];
419 419
 							break;
420 420
 						case 'forced';
421
-							$setting['values'] = array('**NULL**' => lang('Users choice'))+$setting['values'];
421
+							$setting['values'] = array('**NULL**' => lang('Users choice')) + $setting['values'];
422 422
 							break;
423 423
 					}
424 424
 				}
@@ -427,8 +427,7 @@  discard block
 block discarded – undo
427 427
 			if ($type == 'user')
428 428
 			{
429 429
 				$default = $GLOBALS['egw']->preferences->group[$appname][$setting['name']] ?
430
-					$GLOBALS['egw']->preferences->group[$appname][$setting['name']] :
431
-					$GLOBALS['egw']->preferences->default[$appname][$setting['name']];
430
+					$GLOBALS['egw']->preferences->group[$appname][$setting['name']] : $GLOBALS['egw']->preferences->default[$appname][$setting['name']];
432 431
 
433 432
 				// replace default value(s) for selectboxes with selectbox labels
434 433
 				if (isset($setting['values']) && is_array($setting['values']))
@@ -448,7 +447,7 @@  discard block
 block discarded – undo
448 447
 				'name' => $setting['name'],
449 448
 				'type' => $setting['type'],
450 449
 				'label' => preg_replace('|<br[ /]*>|i', "\n", $setting['label']),
451
-				'help' => lang($setting['help']),	// is html
450
+				'help' => lang($setting['help']), // is html
452 451
 				'default' => !empty($default) ? lang('Default').': '.$default : null,
453 452
 				'onchange' => $setting['onchange'],
454 453
 			);
@@ -473,7 +472,7 @@  discard block
 block discarded – undo
473 472
 
474 473
 		$content['appname'] = $appname;
475 474
 		$sel_options['appname'] = array();
476
-		foreach(Api\Hooks::implemented('settings') as $app)
475
+		foreach (Api\Hooks::implemented('settings') as $app)
477 476
 		{
478 477
 			if ($app != 'preferences' && $GLOBALS['egw_info']['user']['apps'][$app])
479 478
 			{
@@ -499,7 +498,7 @@  discard block
 block discarded – undo
499 498
 				$user_apps = $GLOBALS['egw']->acl->get_user_applications($id);
500 499
 				$sel_options['appname'] = array_intersect_key($sel_options['appname'], $user_apps);
501 500
 			}
502
-			foreach($GLOBALS['egw']->accounts->search(array('type' => 'groups', 'order' => 'account_lid')) as $account_id => $group)
501
+			foreach ($GLOBALS['egw']->accounts->search(array('type' => 'groups', 'order' => 'account_lid')) as $account_id => $group)
503 502
 			{
504 503
 				$sel_options['type']['group:'.$account_id] = lang('Preferences').' '.Api\Accounts::format_username($group['account_lid'], '', '', $account_id);
505 504
 			}
@@ -522,7 +521,7 @@  discard block
 block discarded – undo
522 521
 	 * @param boolean $lang =true
523 522
 	 * @return string comma-separated and translated labels
524 523
 	 */
525
-	protected static function get_default_label($default, array $values, $lang=true)
524
+	protected static function get_default_label($default, array $values, $lang = true)
526 525
 	{
527 526
 		// explode comma-separated multiple default values
528 527
 		if (!is_array($default) && !isset($values[$default]) && strpos($default, ',') !== false)
@@ -533,7 +532,7 @@  discard block
 block discarded – undo
533 532
 		{
534 533
 			$labels = (array)$default;
535 534
 		}
536
-		foreach($labels as &$def)
535
+		foreach ($labels as &$def)
537 536
 		{
538 537
 			if (isset($values[$def]))
539 538
 			{
@@ -541,7 +540,7 @@  discard block
 block discarded – undo
541 540
 			}
542 541
 			else	// value could be in an optgroup
543 542
 			{
544
-				foreach($values as $value)
543
+				foreach ($values as $value)
545 544
 				{
546 545
 					if (is_array($value) && !isset($value['label']) && isset($value[$def]))
547 546
 					{
@@ -567,16 +566,16 @@  discard block
 block discarded – undo
567 566
 	 * @param int|string $account_id =null account_id for user or group prefs, or "forced" or "default"
568 567
 	 * @return boolean
569 568
 	 */
570
-	protected function call_hook($appname, $type='user', $account_id=null)
569
+	protected function call_hook($appname, $type = 'user', $account_id = null)
571 570
 	{
572 571
 		$this->appname = $appname == 'common' ? 'preferences' : $appname;
573 572
 
574 573
 		// Set framework here to make sure we get the right settings for user's [newly] selected template
575 574
 		$GLOBALS['egw_info']['server']['template_set'] = $GLOBALS['egw']->preferences->data['common']['template_set'];
576 575
 		Api\Translation::add_app($this->appname);
577
-		if($this->appname != 'preferences')
576
+		if ($this->appname != 'preferences')
578 577
 		{
579
-			Api\Translation::add_app('preferences');	// we need the prefs translations too
578
+			Api\Translation::add_app('preferences'); // we need the prefs translations too
580 579
 		}
581 580
 
582 581
 		// make type available, to hooks from Egw\Applications can use it, eg. activesync
@@ -585,7 +584,7 @@  discard block
 block discarded – undo
585 584
 			'type' => $type,
586 585
 			'account_id' => $account_id,
587 586
 		);
588
-		$GLOBALS['type'] = $type;	// old global variable
587
+		$GLOBALS['type'] = $type; // old global variable
589 588
 
590 589
 		// calling app specific settings hook
591 590
 		$settings = Api\Hooks::single($hook_data, $this->appname);
@@ -594,30 +593,30 @@  discard block
 block discarded – undo
594 593
 		{
595 594
 			$this->settings = array_merge($this->settings, $settings);
596 595
 		}
597
-		elseif(isset($GLOBALS['settings']) && is_array($GLOBALS['settings']) && $GLOBALS['settings'])
596
+		elseif (isset($GLOBALS['settings']) && is_array($GLOBALS['settings']) && $GLOBALS['settings'])
598 597
 		{
599 598
 			$this->settings = array_merge($this->settings, $GLOBALS['settings']);
600 599
 		}
601 600
 		else
602 601
 		{
603
-			return False;	// no settings returned
602
+			return False; // no settings returned
604 603
 		}
605 604
 
606 605
 		// calling settings hook all apps can answer (for a specific app)
607 606
 		$hook_data['location'] = 'settings_'.$this->appname;
608
-		foreach(Api\Hooks::process($hook_data, $this->appname,true) as $settings)
607
+		foreach (Api\Hooks::process($hook_data, $this->appname, true) as $settings)
609 608
 		{
610 609
 			if (isset($settings) && is_array($settings) && $settings)
611 610
 			{
612
-				$this->settings = array_merge($this->settings,$settings);
611
+				$this->settings = array_merge($this->settings, $settings);
613 612
 			}
614 613
 		}
615 614
 		/* Remove ui-only settings */
616
-		if($this->xmlrpc)
615
+		if ($this->xmlrpc)
617 616
 		{
618
-			foreach($this->settings as $key => $valarray)
617
+			foreach ($this->settings as $key => $valarray)
619 618
 			{
620
-				if(!$valarray['xmlrpc'])
619
+				if (!$valarray['xmlrpc'])
621 620
 				{
622 621
 					unset($this->settings[$key]);
623 622
 				}
@@ -629,10 +628,10 @@  discard block
 block discarded – undo
629 628
 			 This is not handled by the hooks class and is only valid if not using xml-rpc.
630 629
 			*/
631 630
 			$tmpl_settings = EGW_SERVER_ROOT.$GLOBALS['egw']->framework->template_dir.'/hook_settings.inc.php';
632
-			if($this->appname == 'preferences' && file_exists($tmpl_settings))
631
+			if ($this->appname == 'preferences' && file_exists($tmpl_settings))
633 632
 			{
634 633
 				include($tmpl_settings);
635
-				$this->settings = array_merge($this->settings,$GLOBALS['settings']);
634
+				$this->settings = array_merge($this->settings, $GLOBALS['settings']);
636 635
 			}
637 636
 		}
638 637
 		// check if we have a default/forced value from the settings hook,
@@ -653,9 +652,9 @@  discard block
 block discarded – undo
653 652
 		}
654 653
 		if ($need_update)
655 654
 		{
656
-			$GLOBALS['egw']->preferences->save_repository(false,'default',true);
655
+			$GLOBALS['egw']->preferences->save_repository(false, 'default', true);
657 656
 		}
658
-		if($this->debug)
657
+		if ($this->debug)
659 658
 		{
660 659
 			_debug_array($this->settings);
661 660
 		}
Please login to merge, or discard this patch.
Braces   +67 added lines, -16 removed lines patch added patch discarded remove patch
@@ -164,9 +164,15 @@  discard block
 block discarded – undo
164 164
 		$data = $this->get_content($appname, $type, $sel_options, $readonlys, $preserve['types'], $tpl);
165 165
 		$preserve['appname'] = $preserve['old_appname'] = $data['appname'];
166 166
 		$preserve['type'] = $preserve['old_type'] = $data['type'];
167
-		if (isset($old_tab)) $data['tabs'] = $old_tab;
167
+		if (isset($old_tab))
168
+		{
169
+			$data['tabs'] = $old_tab;
170
+		}
168 171
 
169
-		if ($msg) Framework::message($msg, $msg_type ? $msg_type : 'error');
172
+		if ($msg)
173
+		{
174
+			Framework::message($msg, $msg_type ? $msg_type : 'error');
175
+		}
170 176
 
171 177
 		$tpl->exec('preferences.preferences_settings.index', $data, $sel_options, $readonlys, $preserve, 2);
172 178
 	}
@@ -201,7 +207,10 @@  discard block
 block discarded – undo
201 207
 			switch((string)$types[$var])
202 208
 			{
203 209
 				case 'password':	// dont write empty password-fields
204
-					if (empty($value)) continue 2;
210
+					if (empty($value))
211
+					{
212
+						continue 2;
213
+					}
205 214
 					break;
206 215
 				case 'vfs_file':
207 216
 				case 'vfs_dir':
@@ -215,7 +224,10 @@  discard block
 block discarded – undo
215 224
 						{
216 225
 							unset($prefs[$var]);
217 226
 							// need to call preferences::delete, to also set affective prefs!
218
-							if (!$only_verify) $GLOBALS['egw']->preferences->delete($appname, $var, $type);
227
+							if (!$only_verify)
228
+							{
229
+								$GLOBALS['egw']->preferences->delete($appname, $var, $type);
230
+							}
219 231
 							continue 2;
220 232
 						}
221 233
 					}
@@ -232,7 +244,11 @@  discard block
 block discarded – undo
232 244
 						// to still allow space or comma in dirnames, we also use the trailing slash of all pathes to split
233 245
 						foreach($types[$var] == 'vfs_dir' ? array($value) : preg_split('/[,\s]+\//', $value) as $n => $dir)
234 246
 						{
235
-							if ($n) $dir = '/'.$dir;	// re-adding trailing slash removed by split
247
+							if ($n)
248
+							{
249
+								$dir = '/'.$dir;
250
+							}
251
+							// re-adding trailing slash removed by split
236 252
 							if ($dir[0] != '/' || !Vfs::stat($dir) || !Vfs::is_dir($dir))
237 253
 							{
238 254
 								$error .= ($error ? ' ' : '').lang('%1 is no existing vfs directory!',$dir);
@@ -249,19 +265,29 @@  discard block
 block discarded – undo
249 265
 
250 266
 			if (isset($value) && $value !== '' && $value !== '**NULL**' && $value !== array())
251 267
 			{
252
-				if (is_array($value) && !$settings[$var]['no_sel_options']) $value = implode(',',$value);	// multiselect
268
+				if (is_array($value) && !$settings[$var]['no_sel_options'])
269
+				{
270
+					$value = implode(',',$value);
271
+				}
272
+				// multiselect
253 273
 
254 274
 				$prefs[$var] = $value;
255 275
 
256 276
 				// need to call preferences::add, to also set affective prefs!
257
-				if (!$only_verify) $GLOBALS['egw']->preferences->add($appname, $var, $prefs[$var], $type);
277
+				if (!$only_verify)
278
+				{
279
+					$GLOBALS['egw']->preferences->add($appname, $var, $prefs[$var], $type);
280
+				}
258 281
 			}
259 282
 			else
260 283
 			{
261 284
 				unset($prefs[$var]);
262 285
 
263 286
 				// need to call preferences::delete, to also set affective prefs!
264
-				if (!$only_verify) $GLOBALS['egw']->preferences->delete($appname, $var, $type);
287
+				if (!$only_verify)
288
+				{
289
+					$GLOBALS['egw']->preferences->delete($appname, $var, $type);
290
+				}
265 291
 			}
266 292
 		}
267 293
 
@@ -281,7 +307,10 @@  discard block
 block discarded – undo
281 307
 			return $error;
282 308
 		}
283 309
 
284
-		if (!$only_verify) $GLOBALS['egw']->preferences->save_repository(True,$type);
310
+		if (!$only_verify)
311
+		{
312
+			$GLOBALS['egw']->preferences->save_repository(True,$type);
313
+		}
285 314
 
286 315
 		// certain common prefs (language, template, ...) require the session to be re-created
287 316
 		if ($appname == 'common' && !$only_verify)
@@ -319,7 +348,10 @@  discard block
 block discarded – undo
319 348
 		$tab = 'tab1';
320 349
 		foreach($this->settings as $setting)
321 350
 		{
322
-			if (!is_array($setting)) continue;
351
+			if (!is_array($setting))
352
+			{
353
+				continue;
354
+			}
323 355
 			if ($type != 'forced' && (string)$GLOBALS['egw']->preferences->forced[$appname][$setting['name']] !== '')
324 356
 			{
325 357
 				continue;	// forced preferences are not displayed, unless we edit them
@@ -341,7 +373,10 @@  discard block
 block discarded – undo
341 373
 
342 374
 				case 'notify':
343 375
 					$vars = $GLOBALS['egw']->preferences->vars;
344
-					if (is_array($setting['values'])) $vars += $setting['values'];
376
+					if (is_array($setting['values']))
377
+					{
378
+						$vars += $setting['values'];
379
+					}
345 380
 					$GLOBALS['egw']->preferences->{$attribute}[$appname][$setting['name']] =
346 381
 						$GLOBALS['egw']->preferences->lang_notify($GLOBALS['egw']->preferences->{$attribute}[$appname][$setting['name']], $vars);
347 382
 					$types[$setting['name']] = $vars;	// store vars for re-translation, instead type "notify"
@@ -383,17 +418,27 @@  discard block
 block discarded – undo
383 418
 				case 'multiselect':
384 419
 					$setting['type'] = 'select';
385 420
 					$tpl->setElementAttribute($tab.'['.$setting['name'].']', 'rows', 5);
386
-					if (!isset($setting['size'])) $setting['size'] = '5';	// old eT
421
+					if (!isset($setting['size']))
422
+					{
423
+						$setting['size'] = '5';
424
+					}
425
+					// old eT
387 426
 					break;
388 427
 				case 'color':
389 428
 					$setting['type'] = 'colorpicker';
390 429
 					break;
391 430
 				case 'date-duration':
392
-					if (!isset($setting['size'])) $setting['size'] = 'm,dhm,24,1';
431
+					if (!isset($setting['size']))
432
+					{
433
+						$setting['size'] = 'm,dhm,24,1';
434
+					}
393 435
 					$attrs = explode(',', $setting['size']);
394 436
 					foreach(array("data_format","display_format", "hours_per_day", "empty_not_0", "short_labels") as $n => $name)
395 437
 					{
396
-						if ((string)$attrs[$n] !== '') $tpl->setElementAttribute($tab.'['.$setting['name'].']', $name, $attrs[$n]);
438
+						if ((string)$attrs[$n] !== '')
439
+						{
440
+							$tpl->setElementAttribute($tab.'['.$setting['name'].']', $name, $attrs[$n]);
441
+						}
397 442
 					}
398 443
 					break;
399 444
 				case 'taglist':
@@ -435,10 +480,13 @@  discard block
 block discarded – undo
435 480
 				{
436 481
 					$default = self::get_default_label($default, $setting['values']);
437 482
 				}
438
-				if (is_array($types[$setting['name']]))	// translate the substitution names
483
+				if (is_array($types[$setting['name']]))
484
+				{
485
+					// translate the substitution names
439 486
 				{
440 487
 					$default = $GLOBALS['egw']->preferences->lang_notify($default, $types[$setting['name']]);
441 488
 				}
489
+				}
442 490
 			}
443 491
 			if ($setting['help'] && ($setting['run_lang'] || !isset($setting['run_lang'])))
444 492
 			{
@@ -550,7 +598,10 @@  discard block
 block discarded – undo
550 598
 					}
551 599
 				}
552 600
 			}
553
-			if ($lang) $def = lang($def);
601
+			if ($lang)
602
+			{
603
+				$def = lang($def);
604
+			}
554 605
 		}
555 606
 		$label = implode(', ', $labels);
556 607
 		//error_log(__METHOD__."(".array2string($default).', '.array2string($values).") returning $label");
Please login to merge, or discard this patch.
redirect.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -24,6 +24,10 @@
 block discarded – undo
24 24
 
25 25
 	if(!function_exists('html_entity_decode'))
26 26
 	{
27
+
28
+		/**
29
+		 * @param integer $quote_style
30
+		 */
27 31
 		function html_entity_decode($given_html, $quote_style = ENT_QUOTES)
28 32
 		{
29 33
 			$trans_table = array_flip(get_html_translation_table( HTML_SPECIALCHARS, $quote_style));
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -22,11 +22,11 @@  discard block
 block discarded – undo
22 22
 	  "<a href=\"$webserverURL/redirect.php?go=".htmlentities(urlencode('http://www.egroupware.org')).'">'
23 23
 	*/
24 24
 
25
-	if(!function_exists('html_entity_decode'))
25
+	if (!function_exists('html_entity_decode'))
26 26
 	{
27 27
 		function html_entity_decode($given_html, $quote_style = ENT_QUOTES)
28 28
 		{
29
-			$trans_table = array_flip(get_html_translation_table( HTML_SPECIALCHARS, $quote_style));
29
+			$trans_table = array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style));
30 30
 			$trans_table['&#39;'] = "'";
31 31
 			return(strtr($given_html, $trans_table));
32 32
 		}
@@ -45,17 +45,17 @@  discard block
 block discarded – undo
45 45
 
46 46
 	/* Only allow redirects from inside this eGroupware installation. */
47 47
 	$valid_referer = array();
48
-	$path = preg_replace('/\/[^\/]*$/','',$_SERVER['PHP_SELF']) . '/';
48
+	$path = preg_replace('/\/[^\/]*$/', '', $_SERVER['PHP_SELF']).'/';
49 49
 	array_push($valid_referer, $path);
50
-	array_push($valid_referer, ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['SERVER_ADDR'] . $path);
51
-	array_push($valid_referer, ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . $path);
50
+	array_push($valid_referer, ($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['SERVER_ADDR'].$path);
51
+	array_push($valid_referer, ($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['SERVER_NAME'].$path);
52 52
 
53 53
 	$referrer = trim($_SERVER['HTTP_REFERER']);
54 54
 	if ((!isset($_SERVER['HTTP_REFERER'])) || (empty($referrer)))
55 55
 	{
56 56
 		echo "Only usable from within eGroupware.\n";
57 57
 	}
58
-	else if($_GET['go'])
58
+	else if ($_GET['go'])
59 59
 	{
60 60
 		$allow = false;
61 61
 		foreach ($valid_referer as $urlRoot)
@@ -69,15 +69,15 @@  discard block
 block discarded – undo
69 69
 		}
70 70
 		if ($allow)
71 71
 		{
72
-			$url= html_entity_decode(urldecode($_GET['go']));
72
+			$url = html_entity_decode(urldecode($_GET['go']));
73 73
 			unset($_GET['go']);
74 74
 			/* Only add "&" if there is something to append. */
75 75
 			if (!empty($_GET))
76 76
 			{
77
-				$url=$url."&".http_build_query($_GET);
77
+				$url = $url."&".http_build_query($_GET);
78 78
 			}
79 79
 
80
-			Header('Location: ' . html_entity_decode(urldecode($url)));
80
+			Header('Location: '.html_entity_decode(urldecode($url)));
81 81
 			exit;
82 82
 		}
83 83
 		else
Please login to merge, or discard this patch.
remote.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
  * Create a session or if the user has no account return authenticate header and 401 Unauthorized
29 29
  *
30 30
  * @param array &$account
31
- * @return int session-id
31
+ * @return string session-id
32 32
  */
33 33
 function check_access(&$account)
34 34
 {
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 {
35 35
 	if (isset($_GET['auth']))
36 36
 	{
37
-		list($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']) = explode(':',base64_decode($_GET['auth']),2);
37
+		list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':', base64_decode($_GET['auth']), 2);
38 38
 	}
39 39
 	return Api\Header\Authenticate::autocreate_session_callback($account);
40 40
 }
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
 		'noheader'  => True,
46 46
 		'currentapp' => preg_match('|/remote.php/webdav/apps/([A-Za-z0-9_-]+)/|', $_SERVER['REQUEST_URI'], $matches) ? $matches[1] : 'filemanager',
47 47
 		'autocreate_session_callback' => 'check_access',
48
-		'no_exception_handler' => 'basic_auth',	// we use a basic auth exception handler (sends exception message as basic auth realm)
49
-		'auth_realm' => 'EGroupware WebDAV server',	// cant use Vfs\WebDAV::REALM as autoloading and include path not yet setup!
48
+		'no_exception_handler' => 'basic_auth', // we use a basic auth exception handler (sends exception message as basic auth realm)
49
+		'auth_realm' => 'EGroupware WebDAV server', // cant use Vfs\WebDAV::REALM as autoloading and include path not yet setup!
50 50
 	)
51 51
 );
52 52
 
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
 
75 75
 // temporary mount ownCloud default /clientsync as /home/$user, if not explicitly mounted
76 76
 // so ownCloud dir contains users home-dir by default
77
-if (strpos($_SERVER['REQUEST_URI'],'/remote.php/webdav/clientsync') !== false &&
78
-	($fstab=Vfs::mount()) && !isset($fstab['/clientsync']))
77
+if (strpos($_SERVER['REQUEST_URI'], '/remote.php/webdav/clientsync') !== false &&
78
+	($fstab = Vfs::mount()) && !isset($fstab['/clientsync']))
79 79
 {
80 80
 	$is_root_backup = Vfs::$is_root;
81 81
 	Vfs::$is_root = true;
82
-	$ok = Vfs::mount($url='vfs://default/home/$user', $clientsync='/clientsync', null, false);
82
+	$ok = Vfs::mount($url = 'vfs://default/home/$user', $clientsync = '/clientsync', null, false);
83 83
 	Vfs::$is_root = $is_root_backup;
84 84
 	//error_log("mounting ownCloud default '$clientsync' as '$url' ".($ok ? 'successful' : 'failed!'));
85 85
 }
Please login to merge, or discard this patch.
resources/inc/class.resources_acl_bo.inc.php 4 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,6 @@  discard block
 block discarded – undo
43 43
 	/**
44 44
 	 * Constructor
45 45
 	 *
46
-	 * @param int $user=null account_id of user whos rights to return, or null for current user
47 46
 	 * @param boolean $session
48 47
 	 */
49 48
 	function __construct($session=False, $user=null)
@@ -77,7 +76,7 @@  discard block
 block discarded – undo
77 76
 	*
78 77
 	* @author Cornelius Weiss <[email protected]>
79 78
 	* @param int $perm_type one of Acl::READ, Acl::ADD, Acl::EDIT, Acl::DELETE, self::DIRECT_BOOKING
80
-	* @param int $parent_id=0 cat_id of parent to return only children of that category
79
+	* @param int $parent_id cat_id of parent to return only children of that category
81 80
 	* @return array cat_id => cat_name
82 81
 	* TODO mark subcats and so on!
83 82
 	*/
Please login to merge, or discard this patch.
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -73,14 +73,14 @@  discard block
 block discarded – undo
73 73
 	}
74 74
 
75 75
 	/**
76
-	* get list of cats where current user has given rights
77
-	*
78
-	* @author Cornelius Weiss <[email protected]>
79
-	* @param int $perm_type one of Acl::READ, Acl::ADD, Acl::EDIT, Acl::DELETE, self::DIRECT_BOOKING
80
-	* @param int $parent_id=0 cat_id of parent to return only children of that category
81
-	* @return array cat_id => cat_name
82
-	* TODO mark subcats and so on!
83
-	*/
76
+	 * get list of cats where current user has given rights
77
+	 *
78
+	 * @author Cornelius Weiss <[email protected]>
79
+	 * @param int $perm_type one of Acl::READ, Acl::ADD, Acl::EDIT, Acl::DELETE, self::DIRECT_BOOKING
80
+	 * @param int $parent_id=0 cat_id of parent to return only children of that category
81
+	 * @return array cat_id => cat_name
82
+	 * TODO mark subcats and so on!
83
+	 */
84 84
 	function get_cats($perm_type,$parent_id=0)
85 85
 	{
86 86
 		$cats = $this->egw_cats->return_sorted_array(0,false,'','','',true,$parent_id);
@@ -105,24 +105,24 @@  discard block
 block discarded – undo
105 105
 
106 106
 
107 107
 	/**
108
-	* gets name of category
109
-	*
110
-	* @author Lukas Weiss <[email protected]>
111
-	* @param int $cat_id
112
-	* @return mixed name of category
113
-	*/
108
+	 * gets name of category
109
+	 *
110
+	 * @author Lukas Weiss <[email protected]>
111
+	 * @param int $cat_id
112
+	 * @return mixed name of category
113
+	 */
114 114
 	static public function get_cat_name($cat_id)
115 115
 	{
116 116
 		return $GLOBALS['egw']->categories->id2name($cat_id);
117 117
 	}
118 118
 
119 119
 	/**
120
-	* gets userid of admin for given category
121
-	*
122
-	* @author Cornelius Weiss <[email protected]>
123
-	* @param int $cat_id
124
-	* @return int userid of cat admin
125
-	*/
120
+	 * gets userid of admin for given category
121
+	 *
122
+	 * @author Cornelius Weiss <[email protected]>
123
+	 * @param int $cat_id
124
+	 * @return int userid of cat admin
125
+	 */
126 126
 	static public function get_cat_admin($cat_id)
127 127
 	{
128 128
 		$cat_rights = self::get_rights($cat_id);
@@ -194,11 +194,11 @@  discard block
 block discarded – undo
194 194
 	}
195 195
 
196 196
 	/**
197
-	* gets all rights from all user for given cat
198
-	*
199
-	* @param int $cat_id
200
-	* @return array userid => right
201
-	*/
197
+	 * gets all rights from all user for given cat
198
+	 *
199
+	 * @param int $cat_id
200
+	 * @return array userid => right
201
+	 */
202 202
 	static public function get_rights($cat_id)
203 203
 	{
204 204
 		return $GLOBALS['egw']->acl->get_all_rights('L'.$cat_id,'resources');
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -85,9 +85,13 @@  discard block
 block discarded – undo
85 85
 	{
86 86
 		$cats = $this->egw_cats->return_sorted_array(0,false,'','','',true,$parent_id);
87 87
 		#_debug_array($cats);
88
-		if (!is_array($cats)) $cats = array();
88
+		if (!is_array($cats))
89
+		{
90
+			$cats = array();
91
+		}
89 92
 		$perm_cats = array();
90
-		foreach($cats as $key=>$cat) {
93
+		foreach($cats as $key=>$cat)
94
+		{
91 95
 			#echo "key:$key"._debug_array($value)."<br>";
92 96
 			#_debug_array($cat)."hier<br>";
93 97
 			if($this->is_permitted($cat['id'],$perm_type))
@@ -215,14 +219,18 @@  discard block
 block discarded – undo
215 219
 			'order' => $this->order,
216 220
 			'limit' => $this->limit,
217 221
 		);
218
-		if($this->debug) { echo '<br>Read:'; _debug_array($data); }
222
+		if($this->debug)
223
+		{
224
+echo '<br>Read:'; _debug_array($data); }
219 225
 		Api\Cache::setSession('resources_acl', 'session_data', $data);
220 226
 	}
221 227
 
222 228
 	function read_sessiondata()
223 229
 	{
224 230
 		$data = Api\Cache::getSession('resources_acl', 'session_data');
225
-		if($this->debug) { echo '<br>Read:'; _debug_array($data); }
231
+		if($this->debug)
232
+		{
233
+echo '<br>Read:'; _debug_array($data); }
226 234
 
227 235
 		$this->start  = $data['start'];
228 236
 		$this->query  = $data['query'];
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -46,17 +46,17 @@  discard block
 block discarded – undo
46 46
 	 * @param int $user=null account_id of user whos rights to return, or null for current user
47 47
 	 * @param boolean $session
48 48
 	 */
49
-	function __construct($session=False, $user=null)
49
+	function __construct($session = False, $user = null)
50 50
 	{
51 51
 		$this->egw_cats = new Api\Categories($user, 'resources');
52 52
 		$this->debug = False;
53 53
 
54 54
 		//all this is only needed when called from uiacl.
55
-		if($session)
55
+		if ($session)
56 56
 		{
57 57
 			$this->read_sessiondata();
58 58
 			$this->use_session = True;
59
-			foreach(array('start','query','sort','order') as $var)
59
+			foreach (array('start', 'query', 'sort', 'order') as $var)
60 60
 			{
61 61
 				if (isset($_POST[$var]))
62 62
 				{
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 				}
69 69
 			}
70 70
 			$this->save_sessiondata();
71
-			$this->cats = $this->egw_cats->return_sorted_array(0,false,'','','',true);
71
+			$this->cats = $this->egw_cats->return_sorted_array(0, false, '', '', '', true);
72 72
 		}
73 73
 	}
74 74
 
@@ -81,18 +81,18 @@  discard block
 block discarded – undo
81 81
 	* @return array cat_id => cat_name
82 82
 	* TODO mark subcats and so on!
83 83
 	*/
84
-	function get_cats($perm_type,$parent_id=0)
84
+	function get_cats($perm_type, $parent_id = 0)
85 85
 	{
86
-		$cats = $this->egw_cats->return_sorted_array(0,false,'','','',true,$parent_id);
86
+		$cats = $this->egw_cats->return_sorted_array(0, false, '', '', '', true, $parent_id);
87 87
 		#_debug_array($cats);
88 88
 		if (!is_array($cats)) $cats = array();
89 89
 		$perm_cats = array();
90
-		foreach($cats as $key=>$cat) {
90
+		foreach ($cats as $key=>$cat) {
91 91
 			#echo "key:$key"._debug_array($value)."<br>";
92 92
 			#_debug_array($cat)."hier<br>";
93
-			if($this->is_permitted($cat['id'],$perm_type))
93
+			if ($this->is_permitted($cat['id'], $perm_type))
94 94
 			{
95
-				$s = str_repeat('&nbsp; ',$cat['level']) . stripslashes($cat['name']);
95
+				$s = str_repeat('&nbsp; ', $cat['level']).stripslashes($cat['name']);
96 96
 				if ($cat['app_name'] == 'phpgw' || $cat['owner'] == '-1')
97 97
 				{
98 98
 					$s .= ' &#9830;';
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 				$perm_cats[$cat['id']] = $s;
101 101
 			}
102 102
 		}
103
-		return isset($perm_cats)?$perm_cats:array();
103
+		return isset($perm_cats) ? $perm_cats : array();
104 104
 	}
105 105
 
106 106
 
@@ -128,13 +128,13 @@  discard block
 block discarded – undo
128 128
 		$cat_rights = self::get_rights($cat_id);
129 129
 		foreach ($cat_rights as $userid => $right)
130 130
 		{
131
-			if ($right & self::CAT_ADMIN)
131
+			if ($right&self::CAT_ADMIN)
132 132
 			{
133 133
 				return $userid;
134 134
 			}
135 135
 		}
136 136
 		// check for an inherited cat admin
137
-		if (($parent = $GLOBALS['egw']->categories->id2name($cat_id,'parent')))
137
+		if (($parent = $GLOBALS['egw']->categories->id2name($cat_id, 'parent')))
138 138
 		{
139 139
 			return self::get_cat_admin($parent);
140 140
 		}
@@ -161,10 +161,10 @@  discard block
 block discarded – undo
161 161
 		{
162 162
 			if (is_null(self::$resource_acl))
163 163
 			{
164
-				self::$resource_acl = $GLOBALS['egw']->acl->get_all_location_rights($GLOBALS['egw_info']['user']['account_id'],'resources',true);
164
+				self::$resource_acl = $GLOBALS['egw']->acl->get_all_location_rights($GLOBALS['egw_info']['user']['account_id'], 'resources', true);
165 165
 			}
166 166
 			self::$permissions[$cat_id] = (int)self::$resource_acl['L'.$cat_id];
167
-			if (($parent = $GLOBALS['egw']->categories->id2name($cat_id,'parent')))
167
+			if (($parent = $GLOBALS['egw']->categories->id2name($cat_id, 'parent')))
168 168
 			{
169 169
 				self::$permissions[$cat_id] |= self::get_permissions($parent);
170 170
 			}
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	 * @param int $right
183 183
 	 * @return boolean user is permitted or not for right
184 184
 	 */
185
-	static public function is_permitted($cat_id,$right)
185
+	static public function is_permitted($cat_id, $right)
186 186
 	{
187 187
 		if (!isset(self::$permissions[$cat_id]))
188 188
 		{
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 		}
191 191
 		//echo "<p>".__METHOD__."($cat_id,$right) = ".self::$permissions[$cat_id]." & $right = ".(self::$permissions[$cat_id] & $right)."</p>\n";
192 192
 
193
-		return (boolean) (self::$permissions[$cat_id] & $right);
193
+		return (boolean)(self::$permissions[$cat_id]&$right);
194 194
 	}
195 195
 
196 196
 	/**
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	*/
202 202
 	static public function get_rights($cat_id)
203 203
 	{
204
-		return $GLOBALS['egw']->acl->get_all_rights('L'.$cat_id,'resources');
204
+		return $GLOBALS['egw']->acl->get_all_rights('L'.$cat_id, 'resources');
205 205
 	}
206 206
 
207 207
 
@@ -215,14 +215,14 @@  discard block
 block discarded – undo
215 215
 			'order' => $this->order,
216 216
 			'limit' => $this->limit,
217 217
 		);
218
-		if($this->debug) { echo '<br>Read:'; _debug_array($data); }
218
+		if ($this->debug) { echo '<br>Read:'; _debug_array($data); }
219 219
 		Api\Cache::setSession('resources_acl', 'session_data', $data);
220 220
 	}
221 221
 
222 222
 	function read_sessiondata()
223 223
 	{
224 224
 		$data = Api\Cache::getSession('resources_acl', 'session_data');
225
-		if($this->debug) { echo '<br>Read:'; _debug_array($data); }
225
+		if ($this->debug) { echo '<br>Read:'; _debug_array($data); }
226 226
 
227 227
 		$this->start  = $data['start'];
228 228
 		$this->query  = $data['query'];
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 		$this->limit = $data['limit'];
232 232
 	}
233 233
 
234
-	public static function set_rights($cat_id,$read,$write,$calread,$calbook,$admin)
234
+	public static function set_rights($cat_id, $read, $write, $calread, $calbook, $admin)
235 235
 	{
236 236
 		// Clear cache
237 237
 		unset(self::$permissions[$cat_id]);
@@ -242,19 +242,19 @@  discard block
 block discarded – undo
242 242
 		$calbookcat = $calbook ? $calbook : array();
243 243
 		$admincat = $admin ? $admin : array();
244 244
 
245
-		$GLOBALS['egw']->acl->delete_repository('resources','L' . $cat_id,false);
245
+		$GLOBALS['egw']->acl->delete_repository('resources', 'L'.$cat_id, false);
246 246
 
247
-		foreach(array_unique(array_merge($readcat, $writecat, $calreadcat, $calbookcat, $admincat)) as $account_id)
247
+		foreach (array_unique(array_merge($readcat, $writecat, $calreadcat, $calbookcat, $admincat)) as $account_id)
248 248
 		{
249 249
 			$rights = false;
250
-			$rights = in_array($account_id,$readcat) ? ($rights | Acl::READ) : false;
251
-			$rights = in_array($account_id,$writecat) ? ($rights | Acl::READ | Acl::ADD | Acl::EDIT | Acl::DELETE): $rights;
252
-			$rights = in_array($account_id,$calreadcat) ? ($rights | self::CAL_READ) : $rights;
253
-			$rights = in_array($account_id,$calbookcat) ? ($rights | self::DIRECT_BOOKING | self::CAL_READ) : $rights;
254
-			$rights = in_array($account_id,$admincat) ? ($rights = 511) : $rights;
250
+			$rights = in_array($account_id, $readcat) ? ($rights|Acl::READ) : false;
251
+			$rights = in_array($account_id, $writecat) ? ($rights|Acl::READ|Acl::ADD|Acl::EDIT|Acl::DELETE) : $rights;
252
+			$rights = in_array($account_id, $calreadcat) ? ($rights|self::CAL_READ) : $rights;
253
+			$rights = in_array($account_id, $calbookcat) ? ($rights|self::DIRECT_BOOKING|self::CAL_READ) : $rights;
254
+			$rights = in_array($account_id, $admincat) ? ($rights = 511) : $rights;
255 255
 			if ($rights)
256 256
 			{
257
-				$GLOBALS['egw']->acl->add_repository('resources','L'.$cat_id,$account_id,$rights);
257
+				$GLOBALS['egw']->acl->add_repository('resources', 'L'.$cat_id, $account_id, $rights);
258 258
 			}
259 259
 		}
260 260
 	}
Please login to merge, or discard this patch.
resources/inc/class.resources_import_csv.inc.php 4 patches
Doc Comments   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -28,9 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
 	/**
30 30
 	 * imports entries according to given definition object.
31
-	 * @param resource $_stream
32
-	 * @param string $_charset
33
-	 * @param definition $_definition
31
+	 * @param importexport_definition $_definition
34 32
 	 */
35 33
 	public function init(importexport_definition $_definition ) {
36 34
 
@@ -52,7 +50,7 @@  discard block
 block discarded – undo
52 50
 	*
53 51
 	* Updates the count of actions taken
54 52
 	*
55
-	* @return boolean success
53
+	* @return null|boolean success
56 54
 	*/
57 55
 	protected function import_record(importexport_iface_egw_record &$record, &$import_csv)
58 56
 	{
Please login to merge, or discard this patch.
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -45,15 +45,15 @@  discard block
 block discarded – undo
45 45
 	}
46 46
 
47 47
 	/**
48
-	* Import a single record
49
-	*
50
-	* You don't need to worry about mappings or translations, they've been done already.
51
-	* You do need to handle the conditions and the actions taken.
52
-	*
53
-	* Updates the count of actions taken
54
-	*
55
-	* @return boolean success
56
-	*/
48
+	 * Import a single record
49
+	 *
50
+	 * You don't need to worry about mappings or translations, they've been done already.
51
+	 * You do need to handle the conditions and the actions taken.
52
+	 *
53
+	 * Updates the count of actions taken
54
+	 *
55
+	 * @return boolean success
56
+	 */
57 57
 	protected function import_record(importexport_iface_egw_record &$record, &$import_csv)
58 58
 	{
59 59
 		// Check for an un-matched accessory of, try again on just name
@@ -250,14 +250,14 @@  discard block
 block discarded – undo
250 250
 	}
251 251
 
252 252
 	/**
253
-        * Returns warnings that were encountered during importing
254
-        * Maximum of one warning message per record, but you can append if you need to
255
-        *
256
-        * @return Array (
257
-        *       record_# => warning message
258
-        *       )
259
-        */
260
-        public function get_warnings() {
253
+	 * Returns warnings that were encountered during importing
254
+	 * Maximum of one warning message per record, but you can append if you need to
255
+	 *
256
+	 * @return Array (
257
+	 *       record_# => warning message
258
+	 *       )
259
+	 */
260
+		public function get_warnings() {
261 261
 		return $this->warnings;
262 262
 	}
263 263
 }
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 /**
17 17
  * class to import resources from CSV
18 18
  */
19
-class resources_import_csv extends importexport_basic_import_csv  {
19
+class resources_import_csv extends importexport_basic_import_csv {
20 20
 
21 21
 
22 22
 	/**
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @var array
26 26
 	 */
27
-	protected static $conditions = array( 'exists' );
27
+	protected static $conditions = array('exists');
28 28
 
29 29
 	/**
30 30
 	 * imports entries according to given definition object.
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 * @param string $_charset
33 33
 	 * @param definition $_definition
34 34
 	 */
35
-	public function init(importexport_definition $_definition ) {
35
+	public function init(importexport_definition $_definition) {
36 36
 
37 37
 		// fetch the resource bo
38 38
 		$this->bo = new resources_bo();
@@ -54,33 +54,33 @@  discard block
 block discarded – undo
54 54
 	*
55 55
 	* @return boolean success
56 56
 	*/
57
-	protected function import_record(importexport_iface_egw_record &$record, &$import_csv)
57
+	protected function import_record(importexport_iface_egw_record&$record, &$import_csv)
58 58
 	{
59 59
 		// Check for an un-matched accessory of, try again on just name
60
-		if(!is_numeric($record->accessory_of))
60
+		if (!is_numeric($record->accessory_of))
61 61
 		{
62 62
 			$accessory_of = $record->accessory_of;
63 63
 
64 64
 			// Look for exact match in just name
65
-			$results = $this->bo->so->search(array('name' => $record->accessory_of),array('res_id','name'));
66
-			if(count($results) >= 1)
65
+			$results = $this->bo->so->search(array('name' => $record->accessory_of), array('res_id', 'name'));
66
+			if (count($results) >= 1)
67 67
 			{
68 68
 				// More than 1 result?  Bad names.  Pick one.
69
-				foreach($results as $result)
69
+				foreach ($results as $result)
70 70
 				{
71
-					if($result['name'] == $record->accessory_of)
71
+					if ($result['name'] == $record->accessory_of)
72 72
 					{
73 73
 						$record->accessory_of = $result['res_id'];
74 74
 						break;
75 75
 					}
76 76
 				}
77
-				if(is_numeric($record->accessory_of))
77
+				if (is_numeric($record->accessory_of))
78 78
 				{
79 79
 					// Import/Export conversion gave a warning, so cancel it
80
-					$pattern = lang('Unable to link to %1 "%2"',lang('resources'),$accessory_of) . ' - ('.lang('too many matches') . '|'.lang('no matches') . ')';
80
+					$pattern = lang('Unable to link to %1 "%2"', lang('resources'), $accessory_of).' - ('.lang('too many matches').'|'.lang('no matches').')';
81 81
 					$this->warnings[$import_csv->get_current_position()] = preg_replace($pattern, '', $this->warnings[$import_csv->get_current_position()], 1);
82 82
 					// If that was the only warning, clear it for this row
83
-					if(trim($this->warnings[$import_csv->get_current_position()]) == '')
83
+					if (trim($this->warnings[$import_csv->get_current_position()]) == '')
84 84
 					{
85 85
 						unset($this->warnings[$import_csv->get_current_position()]);
86 86
 					}
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		// Check for a new category, it needs permissions set
93 93
 		$category = $GLOBALS['egw']->categories->read($record->cat_id);
94 94
 
95
-		if($category['last_mod'] >= $this->start_time) {
95
+		if ($category['last_mod'] >= $this->start_time) {
96 96
 			// New category.  Give read & write permissions to the current user's default group
97 97
 			$this->acl_bo->set_rights($record['cat_id'],
98 98
 				array($GLOBALS['egw_info']['user']['account_primary_group']),
@@ -104,37 +104,37 @@  discard block
 block discarded – undo
104 104
 			// Refresh ACL
105 105
 			//$GLOBALS['egw']->acl->read_repository();
106 106
 		}
107
-		if(!$record->accessory_of) $record->accessory_of = -1;
107
+		if (!$record->accessory_of) $record->accessory_of = -1;
108 108
 		//error_log(__METHOD__.__LINE__.array2string($_definition->plugin_options['conditions']));
109 109
 		if ($this->definition->plugin_options['conditions']) {
110 110
 
111
-			foreach ( $this->definition->plugin_options['conditions'] as $condition ) {
111
+			foreach ($this->definition->plugin_options['conditions'] as $condition) {
112 112
 				$results = array();
113
-				switch ( $condition['type'] ) {
113
+				switch ($condition['type']) {
114 114
 					// exists
115 115
 					case 'exists' :
116
-						if($record->{$condition['string']}) {
116
+						if ($record->{$condition['string']}) {
117 117
 							$results = $this->bo->so->search(
118
-								array( $condition['string'] => $record->{$condition['string']}),
118
+								array($condition['string'] => $record->{$condition['string']}),
119 119
 								False
120 120
 							);
121 121
 						}
122 122
 
123
-						if ( is_array( $results ) && count( array_keys( $results )) >= 1) {
123
+						if (is_array($results) && count(array_keys($results)) >= 1) {
124 124
 							// apply action to all contacts matching this exists condition
125 125
 							$action = $condition['true'];
126
-							foreach ( (array)$results as $resource ) {
126
+							foreach ((array)$results as $resource) {
127 127
 								$record->res_id = $resource['res_id'];
128
-								if ( $_definition->plugin_options['update_cats'] == 'add' ) {
129
-									if ( !is_array( $resource['cat_id'] ) ) $resource['cat_id'] = explode( ',', $resource['cat_id'] );
130
-									if ( !is_array( $record->cat_id ) ) $record->cat_id = explode( ',', $record->cat_id );
131
-									$record->cat_id = implode( ',', array_unique( array_merge( $record->cat_id, $resource['cat_id'] ) ) );
128
+								if ($_definition->plugin_options['update_cats'] == 'add') {
129
+									if (!is_array($resource['cat_id'])) $resource['cat_id'] = explode(',', $resource['cat_id']);
130
+									if (!is_array($record->cat_id)) $record->cat_id = explode(',', $record->cat_id);
131
+									$record->cat_id = implode(',', array_unique(array_merge($record->cat_id, $resource['cat_id'])));
132 132
 								}
133
-								$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
133
+								$success = $this->action($action['action'], $record, $import_csv->get_current_position());
134 134
 							}
135 135
 						} else {
136 136
 							$action = $condition['false'];
137
-							$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
137
+							$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
138 138
 						}
139 139
 						break;
140 140
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 			}
148 148
 		} else {
149 149
 			// unconditional insert
150
-			$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
150
+			$success = $this->action('insert', $record, $import_csv->get_current_position());
151 151
 		}
152 152
 		return $success;
153 153
 	}
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	 * @param importexport_iface_egw_record $record Entry record
160 160
 	 * @return bool success or not
161 161
 	 */
162
-	protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) {
162
+	protected function action($_action, importexport_iface_egw_record&$record, $record_num = 0) {
163 163
 		$_data = $record->get_record_array();
164 164
 		switch ($_action) {
165 165
 			case 'none' :
@@ -173,17 +173,17 @@  discard block
 block discarded – undo
173 173
 
174 174
 				// Fall through
175 175
 			case 'insert' :
176
-				if($_action == 'insert') {
176
+				if ($_action == 'insert') {
177 177
 					// Backend doesn't like inserting with ID specified, it can overwrite
178 178
 					unset($_data['res_id']);
179 179
 				}
180
-				if ( $this->dry_run ) {
180
+				if ($this->dry_run) {
181 181
 					//print_r($_data);
182 182
 					$this->results[$_action]++;
183 183
 					return true;
184 184
 				} else {
185
-					$result = $this->bo->save( $_data );
186
-					if($result && !is_numeric($result)) {
185
+					$result = $this->bo->save($_data);
186
+					if ($result && !is_numeric($result)) {
187 187
 						$this->errors[$record_num] = $result;
188 188
 						return false;
189 189
 					} else {
Please login to merge, or discard this patch.
Braces   +70 added lines, -29 removed lines patch added patch discarded remove patch
@@ -16,7 +16,8 @@  discard block
 block discarded – undo
16 16
 /**
17 17
  * class to import resources from CSV
18 18
  */
19
-class resources_import_csv extends importexport_basic_import_csv  {
19
+class resources_import_csv extends importexport_basic_import_csv
20
+{
20 21
 
21 22
 
22 23
 	/**
@@ -32,7 +33,8 @@  discard block
 block discarded – undo
32 33
 	 * @param string $_charset
33 34
 	 * @param definition $_definition
34 35
 	 */
35
-	public function init(importexport_definition $_definition ) {
36
+	public function init(importexport_definition $_definition )
37
+	{
36 38
 
37 39
 		// fetch the resource bo
38 40
 		$this->bo = new resources_bo();
@@ -92,7 +94,8 @@  discard block
 block discarded – undo
92 94
 		// Check for a new category, it needs permissions set
93 95
 		$category = $GLOBALS['egw']->categories->read($record->cat_id);
94 96
 
95
-		if($category['last_mod'] >= $this->start_time) {
97
+		if($category['last_mod'] >= $this->start_time)
98
+		{
96 99
 			// New category.  Give read & write permissions to the current user's default group
97 100
 			$this->acl_bo->set_rights($record['cat_id'],
98 101
 				array($GLOBALS['egw_info']['user']['account_primary_group']),
@@ -104,35 +107,53 @@  discard block
 block discarded – undo
104 107
 			// Refresh ACL
105 108
 			//$GLOBALS['egw']->acl->read_repository();
106 109
 		}
107
-		if(!$record->accessory_of) $record->accessory_of = -1;
110
+		if(!$record->accessory_of)
111
+		{
112
+			$record->accessory_of = -1;
113
+		}
108 114
 		//error_log(__METHOD__.__LINE__.array2string($_definition->plugin_options['conditions']));
109
-		if ($this->definition->plugin_options['conditions']) {
115
+		if ($this->definition->plugin_options['conditions'])
116
+		{
110 117
 
111
-			foreach ( $this->definition->plugin_options['conditions'] as $condition ) {
118
+			foreach ( $this->definition->plugin_options['conditions'] as $condition )
119
+			{
112 120
 				$results = array();
113
-				switch ( $condition['type'] ) {
121
+				switch ( $condition['type'] )
122
+				{
114 123
 					// exists
115 124
 					case 'exists' :
116
-						if($record->{$condition['string']}) {
125
+						if($record->{$condition['string']})
126
+						{
117 127
 							$results = $this->bo->so->search(
118 128
 								array( $condition['string'] => $record->{$condition['string']}),
119 129
 								False
120 130
 							);
121 131
 						}
122 132
 
123
-						if ( is_array( $results ) && count( array_keys( $results )) >= 1) {
133
+						if ( is_array( $results ) && count( array_keys( $results )) >= 1)
134
+						{
124 135
 							// apply action to all contacts matching this exists condition
125 136
 							$action = $condition['true'];
126
-							foreach ( (array)$results as $resource ) {
137
+							foreach ( (array)$results as $resource )
138
+							{
127 139
 								$record->res_id = $resource['res_id'];
128
-								if ( $_definition->plugin_options['update_cats'] == 'add' ) {
129
-									if ( !is_array( $resource['cat_id'] ) ) $resource['cat_id'] = explode( ',', $resource['cat_id'] );
130
-									if ( !is_array( $record->cat_id ) ) $record->cat_id = explode( ',', $record->cat_id );
140
+								if ( $_definition->plugin_options['update_cats'] == 'add' )
141
+								{
142
+									if ( !is_array( $resource['cat_id'] ) )
143
+									{
144
+										$resource['cat_id'] = explode( ',', $resource['cat_id'] );
145
+									}
146
+									if ( !is_array( $record->cat_id ) )
147
+									{
148
+										$record->cat_id = explode( ',', $record->cat_id );
149
+									}
131 150
 									$record->cat_id = implode( ',', array_unique( array_merge( $record->cat_id, $resource['cat_id'] ) ) );
132 151
 								}
133 152
 								$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
134 153
 							}
135
-						} else {
154
+						}
155
+						else
156
+						{
136 157
 							$action = $condition['false'];
137 158
 							$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
138 159
 						}
@@ -143,9 +164,14 @@  discard block
 block discarded – undo
143 164
 						die('condition / action not supported!!!');
144 165
 						break;
145 166
 				}
146
-				if ($action['last']) break;
167
+				if ($action['last'])
168
+				{
169
+					break;
170
+				}
147 171
 			}
148
-		} else {
172
+		}
173
+		else
174
+		{
149 175
 			// unconditional insert
150 176
 			$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
151 177
 		}
@@ -159,9 +185,11 @@  discard block
 block discarded – undo
159 185
 	 * @param importexport_iface_egw_record $record Entry record
160 186
 	 * @return bool success or not
161 187
 	 */
162
-	protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) {
188
+	protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 )
189
+	{
163 190
 		$_data = $record->get_record_array();
164
-		switch ($_action) {
191
+		switch ($_action)
192
+		{
165 193
 			case 'none' :
166 194
 				return true;
167 195
 			case 'update' :
@@ -173,20 +201,27 @@  discard block
 block discarded – undo
173 201
 
174 202
 				// Fall through
175 203
 			case 'insert' :
176
-				if($_action == 'insert') {
204
+				if($_action == 'insert')
205
+				{
177 206
 					// Backend doesn't like inserting with ID specified, it can overwrite
178 207
 					unset($_data['res_id']);
179 208
 				}
180
-				if ( $this->dry_run ) {
209
+				if ( $this->dry_run )
210
+				{
181 211
 					//print_r($_data);
182 212
 					$this->results[$_action]++;
183 213
 					return true;
184
-				} else {
214
+				}
215
+				else
216
+				{
185 217
 					$result = $this->bo->save( $_data );
186
-					if($result && !is_numeric($result)) {
218
+					if($result && !is_numeric($result))
219
+					{
187 220
 						$this->errors[$record_num] = $result;
188 221
 						return false;
189
-					} else {
222
+					}
223
+					else
224
+					{
190 225
 						$this->results[$_action]++;
191 226
 						return true;
192 227
 					}
@@ -202,7 +237,8 @@  discard block
 block discarded – undo
202 237
 	 *
203 238
 	 * @return string name
204 239
 	 */
205
-	public static function get_name() {
240
+	public static function get_name()
241
+	{
206 242
 		return lang('Resources CSV import');
207 243
 	}
208 244
 
@@ -211,7 +247,8 @@  discard block
 block discarded – undo
211 247
 	 *
212 248
 	 * @return string descriprion
213 249
 	 */
214
-	public static function get_description() {
250
+	public static function get_description()
251
+	{
215 252
 		return lang("Imports a list of resources from a CSV file.");
216 253
 	}
217 254
 
@@ -220,7 +257,8 @@  discard block
 block discarded – undo
220 257
 	 *
221 258
 	 * @return string suffix (comma seperated)
222 259
 	 */
223
-	public static function get_filesuffix() {
260
+	public static function get_filesuffix()
261
+	{
224 262
 		return 'csv';
225 263
 	}
226 264
 
@@ -236,7 +274,8 @@  discard block
 block discarded – undo
236 274
 	 * 		preserv		=> array,
237 275
 	 * )
238 276
 	 */
239
-	public function get_options_etpl() {
277
+	public function get_options_etpl()
278
+	{
240 279
 		// lets do it!
241 280
 	}
242 281
 
@@ -245,7 +284,8 @@  discard block
 block discarded – undo
245 284
 	 *
246 285
 	 * @return string etemplate name
247 286
 	 */
248
-	public function get_selectors_etpl() {
287
+	public function get_selectors_etpl()
288
+	{
249 289
 		// lets do it!
250 290
 	}
251 291
 
@@ -257,7 +297,8 @@  discard block
 block discarded – undo
257 297
         *       record_# => warning message
258 298
         *       )
259 299
         */
260
-        public function get_warnings() {
300
+        public function get_warnings()
301
+        {
261 302
 		return $this->warnings;
262 303
 	}
263 304
 }
Please login to merge, or discard this patch.
resources/inc/class.resources_so.inc.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
 	 *
34 34
 	 * @param string $key key of value to get
35 35
 	 * @param int $res_id resource id
36
-	 * @return mixed value of key and resource, false if key or id not found.
36
+	 * @return integer value of key and resource, false if key or id not found.
37 37
 	 */
38 38
 	function get_value($key,$res_id)
39 39
 	{
Please login to merge, or discard this patch.
Spacing   +6 added lines, -7 removed lines patch added patch discarded remove patch
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
22 22
 {
23 23
 	function __construct()
24 24
 	{
25
-		parent::__construct('resources','egw_resources', 'egw_resources_extra', '',
26
-			'extra_name', 'extra_value', 'extra_id' );
25
+		parent::__construct('resources', 'egw_resources', 'egw_resources_extra', '',
26
+			'extra_name', 'extra_value', 'extra_id');
27 27
 
28
-		$this->columns_to_search = array('name','short_description','inventory_number','long_description','location');
28
+		$this->columns_to_search = array('name', 'short_description', 'inventory_number', 'long_description', 'location');
29 29
 	}
30 30
 
31 31
 	/**
@@ -35,10 +35,9 @@  discard block
 block discarded – undo
35 35
 	 * @param int $res_id resource id
36 36
 	 * @return mixed value of key and resource, false if key or id not found.
37 37
 	 */
38
-	function get_value($key,$res_id)
38
+	function get_value($key, $res_id)
39 39
 	{
40
-		return $res_id == $this->data['res_id'] ? $this->data[$key] :
41
-			$this->db->select($this->table_name,$key,array('res_id' => $res_id),__LINE__,__FILE__)->fetchColumn();
40
+		return $res_id == $this->data['res_id'] ? $this->data[$key] : $this->db->select($this->table_name, $key, array('res_id' => $res_id), __LINE__, __FILE__)->fetchColumn();
42 41
 	}
43 42
 
44 43
 	/**
@@ -90,7 +89,7 @@  discard block
 block discarded – undo
90 89
 	function save($resource)
91 90
 	{
92 91
 		$this->data = $resource;
93
-		if(parent::save() != 0) return false;
92
+		if (parent::save() != 0) return false;
94 93
 		$res_id = $this->data['res_id'];
95 94
 
96 95
 		return $res_id;
Please login to merge, or discard this patch.
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,7 +51,10 @@  discard block
 block discarded – undo
51 51
 	 */
52 52
 	function read($res_id)
53 53
 	{
54
-		if (is_array($res_id) && count($res_id) == 1 && isset($res_id['res_id'])) $res_id = $res_id['res_id'];
54
+		if (is_array($res_id) && count($res_id) == 1 && isset($res_id['res_id']))
55
+		{
56
+			$res_id = $res_id['res_id'];
57
+		}
55 58
 
56 59
 		/*if (!is_array($res_id) && $res_id == $this->data['res_id'])
57 60
 		{
@@ -90,7 +93,10 @@  discard block
 block discarded – undo
90 93
 	function save($resource)
91 94
 	{
92 95
 		$this->data = $resource;
93
-		if(parent::save() != 0) return false;
96
+		if(parent::save() != 0)
97
+		{
98
+			return false;
99
+		}
94 100
 		$res_id = $this->data['res_id'];
95 101
 
96 102
 		return $res_id;
Please login to merge, or discard this patch.