@@ -28,7 +28,7 @@ |
||
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 | { |
@@ -34,7 +34,7 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -43,7 +43,6 @@ discard block |
||
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 |
||
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 | */ |
@@ -85,9 +85,13 @@ discard block |
||
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 |
||
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']; |
@@ -46,17 +46,17 @@ discard block |
||
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 |
||
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 |
||
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(' ',$cat['level']) . stripslashes($cat['name']); |
|
95 | + $s = str_repeat(' ', $cat['level']).stripslashes($cat['name']); |
|
96 | 96 | if ($cat['app_name'] == 'phpgw' || $cat['owner'] == '-1') |
97 | 97 | { |
98 | 98 | $s .= ' ♦'; |
@@ -100,7 +100,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -73,14 +73,14 @@ discard block |
||
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 |
||
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|null userid of cat admin or null for none set |
|
125 | - */ |
|
120 | + * gets userid of admin for given category |
|
121 | + * |
|
122 | + * @author Cornelius Weiss <[email protected]> |
|
123 | + * @param int $cat_id |
|
124 | + * @return int|null userid of cat admin or null for none set |
|
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 |
||
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'); |
@@ -28,9 +28,7 @@ discard block |
||
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 |
||
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 | { |
@@ -45,15 +45,15 @@ discard block |
||
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 |
||
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 | } |
@@ -16,7 +16,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -16,7 +16,7 @@ discard block |
||
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 |
||
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 |
||
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(); |
@@ -57,30 +57,30 @@ discard block |
||
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 |
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 { |
@@ -33,7 +33,7 @@ |
||
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 | { |
@@ -22,10 +22,10 @@ discard block |
||
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 |
||
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 |
||
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; |
@@ -51,7 +51,10 @@ discard block |
||
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 |
||
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; |
@@ -273,7 +273,7 @@ |
||
273 | 273 | * @param int &$success number of succeded actions |
274 | 274 | * @param int &$failed number of failed actions (not enought permissions) |
275 | 275 | * @param string &$action_msg translated verb for the actions, to be used in a message like %1 timesheets 'deleted' |
276 | - * @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup |
|
276 | + * @param string $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup |
|
277 | 277 | * @return boolean true if all actions succeded, false otherwise |
278 | 278 | */ |
279 | 279 | function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg) |
@@ -105,7 +105,9 @@ discard block |
||
105 | 105 | } |
106 | 106 | } |
107 | 107 | } |
108 | - } else { |
|
108 | + } |
|
109 | + else |
|
110 | + { |
|
109 | 111 | $msg = $content; |
110 | 112 | } |
111 | 113 | $content = array(); |
@@ -140,7 +142,8 @@ discard block |
||
140 | 142 | $content['nm']['options-filter2'][resources_bo::DELETED] = lang('Deleted'); |
141 | 143 | } |
142 | 144 | |
143 | - if($_GET['search']) { |
|
145 | + if($_GET['search']) |
|
146 | + { |
|
144 | 147 | $content['nm']['search'] = $_GET['search']; |
145 | 148 | } |
146 | 149 | if($_GET['view_accs_of']) |
@@ -305,7 +308,10 @@ discard block |
||
305 | 308 | foreach($checked as $n=>$id) |
306 | 309 | { |
307 | 310 | // Extra data |
308 | - if(!$id) continue; |
|
311 | + if(!$id) |
|
312 | + { |
|
313 | + continue; |
|
314 | + } |
|
309 | 315 | $resource = $this->bo->read($id); |
310 | 316 | $resource['deleted'] = null; |
311 | 317 | if($resource['accessory_of'] > 0) |
@@ -337,7 +343,10 @@ discard block |
||
337 | 343 | } |
338 | 344 | $success++; |
339 | 345 | } |
340 | - if($restored_accessories) $action_msg .= ", " . lang('%1 accessories restored',$restored_accessories); |
|
346 | + if($restored_accessories) |
|
347 | + { |
|
348 | + $action_msg .= ", " . lang('%1 accessories restored',$restored_accessories); |
|
349 | + } |
|
341 | 350 | break; |
342 | 351 | case 'delete': |
343 | 352 | $action_msg = lang('deleted'); |
@@ -345,7 +354,10 @@ discard block |
||
345 | 354 | foreach($checked as $n => &$id) |
346 | 355 | { |
347 | 356 | // Extra data |
348 | - if(!$id) continue; |
|
357 | + if(!$id) |
|
358 | + { |
|
359 | + continue; |
|
360 | + } |
|
349 | 361 | $resource = $this->bo->read($id); |
350 | 362 | if($settings == 'promote') |
351 | 363 | { |
@@ -371,7 +383,10 @@ discard block |
||
371 | 383 | |
372 | 384 | // Don't need to process these ones now |
373 | 385 | $checked_key = array_search($acc_id, $checked); |
374 | - if($checked_key !== false) unset($checked[$checked_key]); |
|
386 | + if($checked_key !== false) |
|
387 | + { |
|
388 | + unset($checked[$checked_key]); |
|
389 | + } |
|
375 | 390 | } |
376 | 391 | } |
377 | 392 | else |
@@ -401,7 +416,10 @@ discard block |
||
401 | 416 | $failed++; |
402 | 417 | } |
403 | 418 | } |
404 | - if($promoted_accessories) $action_msg .= ", " . lang('%1 accessories now resources',$promoted_accessories); |
|
419 | + if($promoted_accessories) |
|
420 | + { |
|
421 | + $action_msg .= ", " . lang('%1 accessories now resources',$promoted_accessories); |
|
422 | + } |
|
405 | 423 | break; |
406 | 424 | } |
407 | 425 | return $failed == 0; |
@@ -443,7 +461,10 @@ discard block |
||
443 | 461 | if($acc_count && $content['accessory_of'] != -1) |
444 | 462 | { |
445 | 463 | // Resource with accessories changed into accessory |
446 | - if($acc_count) $msg = lang('%1 accessories now resources',$acc_count); |
|
464 | + if($acc_count) |
|
465 | + { |
|
466 | + $msg = lang('%1 accessories now resources',$acc_count); |
|
467 | + } |
|
447 | 468 | } |
448 | 469 | } |
449 | 470 | else |
@@ -475,9 +496,18 @@ discard block |
||
475 | 496 | |
476 | 497 | $nm_session_data = Api\Cache::getSession('resources', 'index_nm'); |
477 | 498 | $res_id = is_numeric($content) ? (int)$content : $content['res_id']; |
478 | - if (isset($_GET['res_id'])) $res_id = $_GET['res_id']; |
|
479 | - if (isset($nm_session_data['filter2']) && $nm_session_data['filter2'] > 0) $accessory_of = $nm_session_data['filter2']; |
|
480 | - if (isset($_GET['accessory_of'])) $accessory_of = $_GET['accessory_of']; |
|
499 | + if (isset($_GET['res_id'])) |
|
500 | + { |
|
501 | + $res_id = $_GET['res_id']; |
|
502 | + } |
|
503 | + if (isset($nm_session_data['filter2']) && $nm_session_data['filter2'] > 0) |
|
504 | + { |
|
505 | + $accessory_of = $nm_session_data['filter2']; |
|
506 | + } |
|
507 | + if (isset($_GET['accessory_of'])) |
|
508 | + { |
|
509 | + $accessory_of = $_GET['accessory_of']; |
|
510 | + } |
|
481 | 511 | $content = array('res_id' => $res_id); |
482 | 512 | if ($res_id > 0) |
483 | 513 | { |
@@ -487,7 +517,9 @@ discard block |
||
487 | 517 | 'to_id' => $res_id, |
488 | 518 | 'to_app' => 'resources' |
489 | 519 | ); |
490 | - } elseif ($accessory_of > 0) { |
|
520 | + } |
|
521 | + elseif ($accessory_of > 0) |
|
522 | + { |
|
491 | 523 | // Pre-set according to parent |
492 | 524 | $owner = $this->bo->read($accessory_of); |
493 | 525 | if($owner['accessory_of'] > 0) |
@@ -498,16 +530,22 @@ discard block |
||
498 | 530 | } |
499 | 531 | $content['cat_id'] = $owner['cat_id']; |
500 | 532 | $content['bookable'] = true; |
501 | - } else { |
|
533 | + } |
|
534 | + else |
|
535 | + { |
|
502 | 536 | // New resource |
503 | 537 | $content['cat_id'] = $nm_session_data['filter']; |
504 | 538 | $content['bookable'] = true; |
505 | 539 | } |
506 | - if($msg) { |
|
540 | + if($msg) |
|
541 | + { |
|
507 | 542 | $content['msg'] = $msg; |
508 | 543 | } |
509 | 544 | |
510 | - if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']); |
|
545 | + if ($_GET['msg']) |
|
546 | + { |
|
547 | + $content['msg'] = strip_tags($_GET['msg']); |
|
548 | + } |
|
511 | 549 | |
512 | 550 | // some presetes |
513 | 551 | $content['resource_picture'] = $this->bo->get_picture($content['res_id'],false); |
@@ -545,7 +583,10 @@ discard block |
||
545 | 583 | ); |
546 | 584 | |
547 | 585 | $sel_options['accessory_of'] = array(-1 => lang('none')) + (array)$this->bo->link_query('',$search_options); |
548 | - if($res_id) unset($sel_options['accessory_of'][$res_id]); |
|
586 | + if($res_id) |
|
587 | + { |
|
588 | + unset($sel_options['accessory_of'][$res_id]); |
|
589 | + } |
|
549 | 590 | |
550 | 591 | // $content['general|page|pictures|links'] = 'resources.edit_tabs.page'; //debug |
551 | 592 |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | function __construct() |
38 | 38 | { |
39 | 39 | // print_r($GLOBALS['egw_info']); die(); |
40 | - $this->tmpl = new Etemplate('resources.show'); |
|
41 | - $this->bo = new resources_bo(); |
|
40 | + $this->tmpl = new Etemplate('resources.show'); |
|
41 | + $this->bo = new resources_bo(); |
|
42 | 42 | // $this->calui = CreateObject('resources.ui_calviews'); |
43 | 43 | } |
44 | 44 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param array $content content from eTemplate callback |
50 | 50 | * |
51 | 51 | */ |
52 | - function index($content='') |
|
52 | + function index($content = '') |
|
53 | 53 | { |
54 | 54 | if (is_array($content)) |
55 | 55 | { |
@@ -59,25 +59,25 @@ discard block |
||
59 | 59 | |
60 | 60 | if (isset($content['btn_delete_selected'])) |
61 | 61 | { |
62 | - foreach($content['nm']['rows'] as $row) |
|
62 | + foreach ($content['nm']['rows'] as $row) |
|
63 | 63 | { |
64 | - if($res_id = $row['checkbox'][0]) |
|
64 | + if ($res_id = $row['checkbox'][0]) |
|
65 | 65 | { |
66 | - $msg .= '<p>'. $this->bo->delete($res_id). '</p><br>'; |
|
66 | + $msg .= '<p>'.$this->bo->delete($res_id).'</p><br>'; |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | return $this->index($msg); |
70 | 70 | } |
71 | - foreach($content['nm']['rows'] as $row) |
|
71 | + foreach ($content['nm']['rows'] as $row) |
|
72 | 72 | { |
73 | - if(isset($row['delete'])) |
|
73 | + if (isset($row['delete'])) |
|
74 | 74 | { |
75 | - $res_id = array_search('pressed',$row['delete']); |
|
75 | + $res_id = array_search('pressed', $row['delete']); |
|
76 | 76 | return $this->index($this->bo->delete($res_id)); |
77 | 77 | } |
78 | - if(isset($row['view_acc'])) |
|
78 | + if (isset($row['view_acc'])) |
|
79 | 79 | { |
80 | - $sessiondata['filter2'] = array_search('pressed',$row['view_acc']); |
|
80 | + $sessiondata['filter2'] = array_search('pressed', $row['view_acc']); |
|
81 | 81 | Api\Cache::setSession('resources', 'index_nm', $sessiondata); |
82 | 82 | return $this->index(); |
83 | 83 | } |
@@ -90,18 +90,18 @@ discard block |
||
90 | 90 | } |
91 | 91 | else |
92 | 92 | { |
93 | - if ($this->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'], |
|
94 | - $success,$failed,$action_msg,'resources_index_nm',$msg)) |
|
93 | + if ($this->action($content['nm']['action'], $content['nm']['selected'], $content['nm']['select_all'], |
|
94 | + $success, $failed, $action_msg, 'resources_index_nm', $msg)) |
|
95 | 95 | { |
96 | - $msg .= lang('%1 resource(s) %2',$success,$action_msg); |
|
96 | + $msg .= lang('%1 resource(s) %2', $success, $action_msg); |
|
97 | 97 | } |
98 | - elseif(empty($msg)) |
|
98 | + elseif (empty($msg)) |
|
99 | 99 | { |
100 | - $msg .= lang('%1 resource(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); |
|
100 | + $msg .= lang('%1 resource(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed); |
|
101 | 101 | } |
102 | 102 | else |
103 | 103 | { |
104 | - $msg .= lang('%1 resource(s) %2, %3 failed',$success,$action_msg,$failed); |
|
104 | + $msg .= lang('%1 resource(s) %2, %3 failed', $success, $action_msg, $failed); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | } |
@@ -111,65 +111,65 @@ discard block |
||
111 | 111 | $content = array(); |
112 | 112 | $content['msg'] = $msg ? $msg : $_GET['msg']; |
113 | 113 | |
114 | - $content['nm']['get_rows'] = 'resources.resources_bo.get_rows'; |
|
114 | + $content['nm']['get_rows'] = 'resources.resources_bo.get_rows'; |
|
115 | 115 | $content['nm']['no_filter'] = False; |
116 | 116 | $content['nm']['filter_no_lang'] = true; |
117 | 117 | $content['nm']['no_cat'] = true; |
118 | 118 | $content['nm']['bottom_too'] = true; |
119 | 119 | $content['nm']['order'] = 'name'; |
120 | - $content['nm']['sort'] = 'ASC'; |
|
121 | - $content['nm']['store_state'] = 'get_rows'; |
|
120 | + $content['nm']['sort'] = 'ASC'; |
|
121 | + $content['nm']['store_state'] = 'get_rows'; |
|
122 | 122 | $content['nm']['row_id'] = 'res_id'; |
123 | 123 | $content['nm']['favorites'] = true; |
124 | 124 | |
125 | 125 | $nm_session_data = Api\Cache::getSession('resources', 'index_nm'); |
126 | - if($nm_session_data) |
|
126 | + if ($nm_session_data) |
|
127 | 127 | { |
128 | 128 | $content['nm'] = $nm_session_data; |
129 | 129 | } |
130 | - $content['nm']['options-filter']= array(''=>lang('all categories'))+(array)$this->bo->acl->get_cats(Acl::READ); |
|
130 | + $content['nm']['options-filter'] = array(''=>lang('all categories')) + (array)$this->bo->acl->get_cats(Acl::READ); |
|
131 | 131 | $content['nm']['options-filter2'] = resources_bo::$filter_options; |
132 | - if(!$content['nm']['filter2']) |
|
132 | + if (!$content['nm']['filter2']) |
|
133 | 133 | { |
134 | 134 | $content['nm']['filter2'] = key(resources_bo::$filter_options); |
135 | 135 | } |
136 | 136 | |
137 | 137 | $config = Api\Config::read('resources'); |
138 | - if($config['history']) |
|
138 | + if ($config['history']) |
|
139 | 139 | { |
140 | 140 | $content['nm']['options-filter2'][resources_bo::DELETED] = lang('Deleted'); |
141 | 141 | } |
142 | 142 | |
143 | - if($_GET['search']) { |
|
143 | + if ($_GET['search']) { |
|
144 | 144 | $content['nm']['search'] = $_GET['search']; |
145 | 145 | } |
146 | - if($_GET['view_accs_of']) |
|
146 | + if ($_GET['view_accs_of']) |
|
147 | 147 | { |
148 | 148 | $content['nm']['filter2'] = (int)$_GET['view_accs_of']; |
149 | 149 | } |
150 | - $content['nm']['actions'] = $this->get_actions(); |
|
150 | + $content['nm']['actions'] = $this->get_actions(); |
|
151 | 151 | $content['nm']['placeholder_actions'] = array('add'); |
152 | 152 | |
153 | 153 | // check if user is permitted to add resources |
154 | 154 | // If they can't read any categories, they won't be able to save it |
155 | - if(!$this->bo->acl->get_cats(Acl::ADD) || !$this->bo->acl->get_cats(Acl::READ)) |
|
155 | + if (!$this->bo->acl->get_cats(Acl::ADD) || !$this->bo->acl->get_cats(Acl::READ)) |
|
156 | 156 | { |
157 | 157 | $no_button['add'] = $no_button['nm']['add'] = true; |
158 | 158 | } |
159 | 159 | $no_button['back'] = true; |
160 | 160 | $GLOBALS['egw_info']['flags']['app_header'] = lang('resources'); |
161 | 161 | |
162 | - Framework::includeJS('.','resources','resources'); |
|
162 | + Framework::includeJS('.', 'resources', 'resources'); |
|
163 | 163 | |
164 | - if($content['nm']['filter2'] > 0) |
|
164 | + if ($content['nm']['filter2'] > 0) |
|
165 | 165 | { |
166 | 166 | $master = $this->bo->so->read(array('res_id' => $content['nm']['filter2'])); |
167 | 167 | $content['nm']['options-filter2'] = resources_bo::$filter_options + array( |
168 | - $master['res_id'] => lang('accessories of') . ' ' . $master['name'] |
|
168 | + $master['res_id'] => lang('accessories of').' '.$master['name'] |
|
169 | 169 | ); |
170 | - $content['nm']['get_rows'] = 'resources.resources_bo.get_rows'; |
|
171 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('resources') . ' - ' . lang('accessories of '). ' '. $master['name'] . |
|
172 | - ($master['short_description'] ? ' [' . $master['short_description'] . ']' : ''); |
|
170 | + $content['nm']['get_rows'] = 'resources.resources_bo.get_rows'; |
|
171 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('resources').' - '.lang('accessories of ').' '.$master['name']. |
|
172 | + ($master['short_description'] ? ' ['.$master['short_description'].']' : ''); |
|
173 | 173 | } |
174 | 174 | $preserv = $content; |
175 | 175 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | |
178 | 178 | Api\Cache::setSession('resources', 'index_nm', $content['nm']); |
179 | 179 | $this->tmpl->read('resources.show'); |
180 | - return $this->tmpl->exec('resources.resources_ui.index',$content,$sel_options,$no_button,$preserv); |
|
180 | + return $this->tmpl->exec('resources.resources_ui.index', $content, $sel_options, $no_button, $preserv); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -194,9 +194,9 @@ discard block |
||
194 | 194 | 'allowOnMultiple' => false, |
195 | 195 | 'url' => 'menuaction=resources.resources_ui.edit&res_id=$id', |
196 | 196 | 'popup' => Link::get_registry('resources', 'add_popup'), |
197 | - 'group' => $group=1, |
|
197 | + 'group' => $group = 1, |
|
198 | 198 | 'disableClass' => 'rowNoEdit', |
199 | - 'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.resources.viewEntry':'', |
|
199 | + 'onExecute' => Api\Header\UserAgent::mobile() ? 'javaScript:app.resources.viewEntry' : '', |
|
200 | 200 | 'mobileViewTemplate' => 'view?'.filemtime(Api\Etemplate\Widget\Template::rel2path('/resources/templates/mobile/view.xet')) |
201 | 201 | ), |
202 | 202 | 'add' => array( |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup |
279 | 279 | * @return boolean true if all actions succeded, false otherwise |
280 | 280 | */ |
281 | - function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg) |
|
281 | + function action($action, $checked, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg) |
|
282 | 282 | { |
283 | 283 | $success = $failed = 0; |
284 | 284 | if ($use_all) |
@@ -286,11 +286,11 @@ discard block |
||
286 | 286 | // get the whole selection |
287 | 287 | $query = is_array($session_name) ? $session_name : Api\Cache::getSession($session_name, 'session_data'); |
288 | 288 | |
289 | - @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
290 | - $query['num_rows'] = -1; // all |
|
291 | - $this->bo->get_rows($query,$resources,$readonlys); |
|
289 | + @set_time_limit(0); // switch off the execution time limit, as it's for big selections to small |
|
290 | + $query['num_rows'] = -1; // all |
|
291 | + $this->bo->get_rows($query, $resources, $readonlys); |
|
292 | 292 | $checked = array(); |
293 | - foreach($resources as $resource) |
|
293 | + foreach ($resources as $resource) |
|
294 | 294 | { |
295 | 295 | $checked[] = $resource['res_id']; |
296 | 296 | } |
@@ -300,17 +300,17 @@ discard block |
||
300 | 300 | // Dialogs to get options |
301 | 301 | list($action, $settings) = explode('_', $action, 2); |
302 | 302 | |
303 | - switch($action) |
|
303 | + switch ($action) |
|
304 | 304 | { |
305 | 305 | case 'restore': |
306 | 306 | $action_msg = lang('restored'); |
307 | - foreach($checked as $n=>$id) |
|
307 | + foreach ($checked as $n=>$id) |
|
308 | 308 | { |
309 | 309 | // Extra data |
310 | - if(!$id) continue; |
|
310 | + if (!$id) continue; |
|
311 | 311 | $resource = $this->bo->read($id); |
312 | 312 | $resource['deleted'] = null; |
313 | - if($resource['accessory_of'] > 0) |
|
313 | + if ($resource['accessory_of'] > 0) |
|
314 | 314 | { |
315 | 315 | /* |
316 | 316 | If restoring an accessory, and parent is deleted, and not in |
@@ -318,18 +318,18 @@ discard block |
||
318 | 318 | */ |
319 | 319 | $parent = $this->bo->read($resource['accessory_of']); |
320 | 320 | $checked_key = array_search($parent['res_id'], $checked); |
321 | - if($checked_key === false && $parent['deleted']) |
|
321 | + if ($checked_key === false && $parent['deleted']) |
|
322 | 322 | { |
323 | 323 | $resource['accessory_of'] = -1; |
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
327 | 327 | $this->bo->save($resource); |
328 | - if($settings == 'accessories') |
|
328 | + if ($settings == 'accessories') |
|
329 | 329 | { |
330 | 330 | // Restore accessories too |
331 | - $accessories = $this->bo->get_acc_list($id,true); |
|
332 | - foreach($accessories as $acc_id => $name) |
|
331 | + $accessories = $this->bo->get_acc_list($id, true); |
|
332 | + foreach ($accessories as $acc_id => $name) |
|
333 | 333 | { |
334 | 334 | $acc = $this->bo->read($acc_id); |
335 | 335 | $acc['deleted'] = null; |
@@ -339,20 +339,20 @@ discard block |
||
339 | 339 | } |
340 | 340 | $success++; |
341 | 341 | } |
342 | - if($restored_accessories) $action_msg .= ", " . lang('%1 accessories restored',$restored_accessories); |
|
342 | + if ($restored_accessories) $action_msg .= ", ".lang('%1 accessories restored', $restored_accessories); |
|
343 | 343 | break; |
344 | 344 | case 'delete': |
345 | 345 | $action_msg = lang('deleted'); |
346 | 346 | $promoted_accessories = 0; |
347 | - foreach($checked as $n => &$id) |
|
347 | + foreach ($checked as $n => &$id) |
|
348 | 348 | { |
349 | 349 | // Extra data |
350 | - if(!$id) continue; |
|
350 | + if (!$id) continue; |
|
351 | 351 | $resource = $this->bo->read($id); |
352 | - if($settings == 'promote') |
|
352 | + if ($settings == 'promote') |
|
353 | 353 | { |
354 | 354 | // Handle a selected accessory |
355 | - if($resource['accessory_of'] > 0) |
|
355 | + if ($resource['accessory_of'] > 0) |
|
356 | 356 | { |
357 | 357 | $resource['accessory_of'] = -1; |
358 | 358 | $this->bo->save($resource); |
@@ -361,8 +361,8 @@ discard block |
||
361 | 361 | } |
362 | 362 | |
363 | 363 | // Make associated accessories into resources - include deleted |
364 | - $accessories = $this->bo->get_acc_list($id,true); |
|
365 | - foreach($accessories as $acc_id => $name) |
|
364 | + $accessories = $this->bo->get_acc_list($id, true); |
|
365 | + foreach ($accessories as $acc_id => $name) |
|
366 | 366 | { |
367 | 367 | $acc = $this->bo->read($acc_id); |
368 | 368 | $acc['accessory_of'] = -1; |
@@ -373,19 +373,19 @@ discard block |
||
373 | 373 | |
374 | 374 | // Don't need to process these ones now |
375 | 375 | $checked_key = array_search($acc_id, $checked); |
376 | - if($checked_key !== false) unset($checked[$checked_key]); |
|
376 | + if ($checked_key !== false) unset($checked[$checked_key]); |
|
377 | 377 | } |
378 | 378 | } |
379 | 379 | else |
380 | 380 | { |
381 | 381 | // Remove checked accessories, deleting resource will remove them |
382 | 382 | // We get an error if we try to delete them after they're gone |
383 | - $accessories = $this->bo->get_acc_list($id,$resource['deleted']); |
|
383 | + $accessories = $this->bo->get_acc_list($id, $resource['deleted']); |
|
384 | 384 | |
385 | - foreach($accessories as $acc_id => $name) |
|
385 | + foreach ($accessories as $acc_id => $name) |
|
386 | 386 | { |
387 | 387 | $checked_key = array_search($acc_id, $checked); |
388 | - if($checked_key !== false) |
|
388 | + if ($checked_key !== false) |
|
389 | 389 | { |
390 | 390 | $success++; |
391 | 391 | unset($checked[$checked_key]); |
@@ -399,11 +399,11 @@ discard block |
||
399 | 399 | } |
400 | 400 | else |
401 | 401 | { |
402 | - $msg = $error . "\n"; |
|
402 | + $msg = $error."\n"; |
|
403 | 403 | $failed++; |
404 | 404 | } |
405 | 405 | } |
406 | - if($promoted_accessories) $action_msg .= ", " . lang('%1 accessories now resources',$promoted_accessories); |
|
406 | + if ($promoted_accessories) $action_msg .= ", ".lang('%1 accessories now resources', $promoted_accessories); |
|
407 | 407 | break; |
408 | 408 | } |
409 | 409 | return $failed == 0; |
@@ -415,13 +415,13 @@ discard block |
||
415 | 415 | * |
416 | 416 | * @param $content Content from the eTemplate Exec call or id on inital call |
417 | 417 | */ |
418 | - function edit($content=0,$accessory_of = -1) |
|
418 | + function edit($content = 0, $accessory_of = -1) |
|
419 | 419 | { |
420 | 420 | if (is_array($content)) |
421 | 421 | { |
422 | 422 | list($button) = @each($content['button']); |
423 | 423 | unset($content['button']); |
424 | - switch($button) |
|
424 | + switch ($button) |
|
425 | 425 | { |
426 | 426 | case 'save': |
427 | 427 | case 'apply': |
@@ -432,20 +432,20 @@ discard block |
||
432 | 432 | // // links are already saved by eTemplate |
433 | 433 | // unset($resource['link_to']['to_id']); |
434 | 434 | // } |
435 | - if($content['res_id']) |
|
435 | + if ($content['res_id']) |
|
436 | 436 | { |
437 | 437 | $acc_count = count($this->bo->get_acc_list($content['res_id'])); |
438 | 438 | } |
439 | 439 | $result = $this->bo->save($content); |
440 | 440 | |
441 | - if(is_numeric($result)) |
|
441 | + if (is_numeric($result)) |
|
442 | 442 | { |
443 | - $msg = lang('Resource %1 saved!',$result); |
|
443 | + $msg = lang('Resource %1 saved!', $result); |
|
444 | 444 | $content['res_id'] = $result; |
445 | - if($acc_count && $content['accessory_of'] != -1) |
|
445 | + if ($acc_count && $content['accessory_of'] != -1) |
|
446 | 446 | { |
447 | 447 | // Resource with accessories changed into accessory |
448 | - if($acc_count) $msg = lang('%1 accessories now resources',$acc_count); |
|
448 | + if ($acc_count) $msg = lang('%1 accessories now resources', $acc_count); |
|
449 | 449 | } |
450 | 450 | } |
451 | 451 | else |
@@ -456,9 +456,9 @@ discard block |
||
456 | 456 | break; |
457 | 457 | case 'delete': |
458 | 458 | unset($content['delete']); |
459 | - if(!$this->bo->delete($content['res_id'])) |
|
459 | + if (!$this->bo->delete($content['res_id'])) |
|
460 | 460 | { |
461 | - $msg = lang('Resource %1 deleted!',$content['res_id']); |
|
461 | + $msg = lang('Resource %1 deleted!', $content['res_id']); |
|
462 | 462 | } |
463 | 463 | else |
464 | 464 | { |
@@ -466,9 +466,9 @@ discard block |
||
466 | 466 | break; |
467 | 467 | } |
468 | 468 | } |
469 | - Framework::refresh_opener($msg, 'resources',$content['res_id'],($button == 'delete'?'delete':'edit')); |
|
469 | + Framework::refresh_opener($msg, 'resources', $content['res_id'], ($button == 'delete' ? 'delete' : 'edit')); |
|
470 | 470 | |
471 | - if($button != 'apply') |
|
471 | + if ($button != 'apply') |
|
472 | 472 | { |
473 | 473 | Framework::window_close(); |
474 | 474 | } |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | if ($res_id > 0) |
485 | 485 | { |
486 | 486 | $content = $this->bo->read($res_id); |
487 | - $content['picture_src'] = strpos($content['picture_src'],'.') !== false ? 'gen_src' : $content['picture_src']; |
|
487 | + $content['picture_src'] = strpos($content['picture_src'], '.') !== false ? 'gen_src' : $content['picture_src']; |
|
488 | 488 | $content['link_to'] = array( |
489 | 489 | 'to_id' => $res_id, |
490 | 490 | 'to_app' => 'resources' |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | } elseif ($accessory_of > 0) { |
493 | 493 | // Pre-set according to parent |
494 | 494 | $owner = $this->bo->read($accessory_of); |
495 | - if($owner['accessory_of'] > 0) |
|
495 | + if ($owner['accessory_of'] > 0) |
|
496 | 496 | { |
497 | 497 | // Accessory of accessory not allowed, grab parent resource |
498 | 498 | $accessory_of = $owner['accessory_of']; |
@@ -505,33 +505,32 @@ discard block |
||
505 | 505 | $content['cat_id'] = $nm_session_data['filter']; |
506 | 506 | $content['bookable'] = true; |
507 | 507 | } |
508 | - if($msg) { |
|
508 | + if ($msg) { |
|
509 | 509 | $content['msg'] = $msg; |
510 | 510 | } |
511 | 511 | |
512 | 512 | if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']); |
513 | 513 | |
514 | 514 | // some presetes |
515 | - $content['resource_picture'] = $this->bo->get_picture($content['res_id'],false); |
|
515 | + $content['resource_picture'] = $this->bo->get_picture($content['res_id'], false); |
|
516 | 516 | // Set original size picture |
517 | - $content['picture_original'] = $content['picture_src'] == 'own_src'? |
|
518 | - 'webdav.php/apps/resources/'.$content['res_id'].'/.picture.jpg': $this->bo->get_picture($content['res_id'],true); |
|
517 | + $content['picture_original'] = $content['picture_src'] == 'own_src' ? |
|
518 | + 'webdav.php/apps/resources/'.$content['res_id'].'/.picture.jpg' : $this->bo->get_picture($content['res_id'], true); |
|
519 | 519 | |
520 | 520 | $content['quantity'] = $content['quantity'] ? $content['quantity'] : 1; |
521 | 521 | $content['useable'] = $content['useable'] ? $content['useable'] : 1; |
522 | 522 | $content['accessory_of'] = $content['accessory_of'] ? $content['accessory_of'] : $accessory_of; |
523 | 523 | |
524 | - if($content['res_id'] && $content['accessory_of'] == -1) |
|
524 | + if ($content['res_id'] && $content['accessory_of'] == -1) |
|
525 | 525 | { |
526 | 526 | $content['acc_count'] = count($this->bo->get_acc_list($content['res_id'])); |
527 | 527 | } |
528 | 528 | $sel_options['status'] = resources_bo::$field2label; |
529 | 529 | |
530 | 530 | //$sel_options['gen_src_list'] = $this->bo->get_genpicturelist(); |
531 | - $sel_options['cat_id'] = $this->bo->acl->get_cats(Acl::ADD); |
|
532 | - $sel_options['cat_id'] = count($sel_options['cat_id']) == 1 ? $sel_options['cat_id'] : |
|
533 | - array('' => lang('select one')) + $sel_options['cat_id']; |
|
534 | - if($accessory_of > 0 || $content['accessory_of'] > 0) |
|
531 | + $sel_options['cat_id'] = $this->bo->acl->get_cats(Acl::ADD); |
|
532 | + $sel_options['cat_id'] = count($sel_options['cat_id']) == 1 ? $sel_options['cat_id'] : array('' => lang('select one')) + $sel_options['cat_id']; |
|
533 | + if ($accessory_of > 0 || $content['accessory_of'] > 0) |
|
535 | 534 | { |
536 | 535 | $content['accessory_of'] = $content['accessory_of'] ? $content['accessory_of'] : $accessory_of; |
537 | 536 | } |
@@ -546,19 +545,19 @@ discard block |
||
546 | 545 | ) |
547 | 546 | ); |
548 | 547 | |
549 | - $sel_options['accessory_of'] = array(-1 => lang('none')) + (array)$this->bo->link_query('',$search_options); |
|
550 | - if($res_id) unset($sel_options['accessory_of'][$res_id]); |
|
548 | + $sel_options['accessory_of'] = array(-1 => lang('none')) + (array)$this->bo->link_query('', $search_options); |
|
549 | + if ($res_id) unset($sel_options['accessory_of'][$res_id]); |
|
551 | 550 | |
552 | 551 | // $content['general|page|pictures|links'] = 'resources.edit_tabs.page'; //debug |
553 | 552 | |
554 | 553 | // Permissions |
555 | 554 | $read_only = array(); |
556 | - if($res_id && !$this->bo->acl->is_permitted($content['cat_id'],Acl::EDIT)) |
|
555 | + if ($res_id && !$this->bo->acl->is_permitted($content['cat_id'], Acl::EDIT)) |
|
557 | 556 | { |
558 | 557 | $read_only['__ALL__'] = true; |
559 | 558 | } |
560 | 559 | $config = Api\Config::read('resources'); |
561 | - if(!$this->bo->acl->is_permitted($content['cat_id'],Acl::DELETE) || |
|
560 | + if (!$this->bo->acl->is_permitted($content['cat_id'], Acl::DELETE) || |
|
562 | 561 | ($content['deleted'] && !$GLOBALS['egw_info']['user']['apps']['admin'] && $config['history'] == 'history')) |
563 | 562 | { |
564 | 563 | $read_only['delete'] = true; |
@@ -566,19 +565,19 @@ discard block |
||
566 | 565 | |
567 | 566 | // Can't make a resource with accessories an accessory |
568 | 567 | $read_only['accessory_of'] = $content['acc_count']; |
569 | - if($read_only['accessory_of']) |
|
568 | + if ($read_only['accessory_of']) |
|
570 | 569 | { |
571 | 570 | $content['accessory_label'] = lang('Remove accessories before changing Accessory of'); |
572 | 571 | } |
573 | 572 | |
574 | 573 | // Disable custom tab if there are no custom fields defined |
575 | - $read_only['tabs']['custom'] = !(Api\Storage\Customfields::get('resources',true)); |
|
576 | - $read_only['tabs']['history'] = ($content['history']['id'] != 0?false:true); |
|
574 | + $read_only['tabs']['custom'] = !(Api\Storage\Customfields::get('resources', true)); |
|
575 | + $read_only['tabs']['history'] = ($content['history']['id'] != 0 ?false:true); |
|
577 | 576 | |
578 | 577 | $preserv = $content; |
579 | 578 | |
580 | 579 | $this->tmpl->read('resources.edit'); |
581 | - return $this->tmpl->exec('resources.resources_ui.edit',$content,$sel_options,$read_only,$preserv,2); |
|
580 | + return $this->tmpl->exec('resources.resources_ui.edit', $content, $sel_options, $read_only, $preserv, 2); |
|
582 | 581 | } |
583 | 582 | |
584 | 583 | } |
@@ -316,6 +316,7 @@ |
||
316 | 316 | * Check if given package is installed via composer in EGroupware's vendor directory |
317 | 317 | * |
318 | 318 | * @param string $package package-name in composer notation eg. "pear-pear.horde.org/Horde_Imap_Client" or "pear-pear.php.net/Net_Sieve" |
319 | + * @return string|null |
|
319 | 320 | */ |
320 | 321 | function composer_check($package) |
321 | 322 | { |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | use EGroupware\Api; |
14 | 14 | |
15 | 15 | $run_by_webserver = !!$_SERVER['PHP_SELF']; |
16 | -$is_windows = strtoupper(substr(PHP_OS,0,3)) == 'WIN'; |
|
16 | +$is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'; |
|
17 | 17 | |
18 | 18 | if ($run_by_webserver) |
19 | 19 | { |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | $error_icon = '*** Error: '; |
42 | 42 | $warning_icon = '!!! Warning: '; |
43 | 43 | |
44 | - function lang($msg,$arg1=NULL,$arg2=NULL,$arg3=NULL,$arg4=NULL) |
|
44 | + function lang($msg, $arg1 = NULL, $arg2 = NULL, $arg3 = NULL, $arg4 = NULL) |
|
45 | 45 | { |
46 | - return is_null($arg1) ? $msg : str_replace(array('%1','%2','%3','%4'),array($arg1,$arg2,$arg3,$arg4),$msg); |
|
46 | + return is_null($arg1) ? $msg : str_replace(array('%1', '%2', '%3', '%4'), array($arg1, $arg2, $arg3, $arg4), $msg); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | 'func' => 'php_ini_check', |
80 | 80 | 'value' => 0, |
81 | 81 | 'verbose_value' => 'Off', |
82 | - 'warning' => lang('%1 is set to %2. This is NOT recommeded for a production system, as displayed error messages can contain passwords or other sensitive information!','display_errors',ini_get('display_errors')), |
|
82 | + 'warning' => lang('%1 is set to %2. This is NOT recommeded for a production system, as displayed error messages can contain passwords or other sensitive information!', 'display_errors', ini_get('display_errors')), |
|
83 | 83 | ), |
84 | 84 | 'memory_limit' => array( |
85 | 85 | 'func' => 'php_ini_check', |
86 | 86 | 'value' => '128M', |
87 | 87 | 'check' => '>=', |
88 | - 'error' => lang('memory_limit is set to less than %1: some applications of EGroupware need more than the recommend 8M, expect occasional failures','24M'), |
|
88 | + 'error' => lang('memory_limit is set to less than %1: some applications of EGroupware need more than the recommend 8M, expect occasional failures', '24M'), |
|
89 | 89 | 'change' => 'memory_limit = 24M' |
90 | 90 | ), |
91 | 91 | 'max_execution_time' => array( |
@@ -105,14 +105,14 @@ discard block |
||
105 | 105 | 'func' => 'php_ini_check', |
106 | 106 | 'value' => '8M', |
107 | 107 | 'check' => '>=', |
108 | - 'error' => lang('%1 is set to %2, you will NOT be able to upload or attach files bigger then that!','upload_max_filesize',ini_get('upload_max_filesize')), |
|
108 | + 'error' => lang('%1 is set to %2, you will NOT be able to upload or attach files bigger then that!', 'upload_max_filesize', ini_get('upload_max_filesize')), |
|
109 | 109 | 'change' => 'upload_max_filesize = 8M' |
110 | 110 | ), |
111 | 111 | 'post_max_size' => array( |
112 | 112 | 'func' => 'php_ini_check', |
113 | 113 | 'value' => '8M', |
114 | 114 | 'check' => '>=', |
115 | - 'error' => lang('%1 is set to %2, you will NOT be able to upload or attach files bigger then that!','post_max_size',ini_get('max_post_size')), |
|
115 | + 'error' => lang('%1 is set to %2, you will NOT be able to upload or attach files bigger then that!', 'post_max_size', ini_get('max_post_size')), |
|
116 | 116 | 'change' => 'post_max_size = 8M' |
117 | 117 | ), |
118 | 118 | 'allow_url_fopen' => array( |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | 'verbose_value' => '"System/Localtime"', |
139 | 139 | 'check' => '!=', |
140 | 140 | 'error' => lang('No VALID timezone set! ("%1" is NOT sufficient, you have to use a timezone identifer like "%2", see %3full list of valid identifers%4)', |
141 | - 'System/Localtime','Europe/Berlin','<a href="http://www.php.net/manual/en/timezones.php" target="_blank">','</a>'), |
|
141 | + 'System/Localtime', 'Europe/Berlin', '<a href="http://www.php.net/manual/en/timezones.php" target="_blank">', '</a>'), |
|
142 | 142 | ), |
143 | 143 | 'pdo' => array( |
144 | 144 | 'func' => 'extension_check', |
@@ -146,19 +146,19 @@ discard block |
||
146 | 146 | ), |
147 | 147 | 'mysqli' => array( |
148 | 148 | 'func' => 'extension_check', |
149 | - 'warning' => lang('The %1 extension is needed, if you plan to use a %2 database.','mysql','MySQL') |
|
149 | + 'warning' => lang('The %1 extension is needed, if you plan to use a %2 database.', 'mysql', 'MySQL') |
|
150 | 150 | ), |
151 | 151 | 'pdo_mysql' => array( |
152 | 152 | 'func' => 'extension_check', |
153 | - 'warning' => lang('The %1 extension is needed, if you plan to use a %2 database.','pdo_mysql','MySQL') |
|
153 | + 'warning' => lang('The %1 extension is needed, if you plan to use a %2 database.', 'pdo_mysql', 'MySQL') |
|
154 | 154 | ), |
155 | 155 | 'pgsql' => array( |
156 | 156 | 'func' => 'extension_check', |
157 | - 'warning' => lang('The %1 extension is needed, if you plan to use a %2 database.','pgsql','pgSQL') |
|
157 | + 'warning' => lang('The %1 extension is needed, if you plan to use a %2 database.', 'pgsql', 'pgSQL') |
|
158 | 158 | ), |
159 | 159 | 'pdo_pgsql' => array( |
160 | 160 | 'func' => 'extension_check', |
161 | - 'warning' => lang('The %1 extension is needed, if you plan to use a %2 database.','pdo_pgsql','pgSQL') |
|
161 | + 'warning' => lang('The %1 extension is needed, if you plan to use a %2 database.', 'pdo_pgsql', 'pgSQL') |
|
162 | 162 | ), |
163 | 163 | /* disable checks for other database extensions, as we are not really supporting them anymore |
164 | 164 | 'mssql' => array( |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | realpath('..') => array( |
203 | 203 | 'func' => 'permission_check', |
204 | 204 | 'is_world_writable' => False, |
205 | - 'only_if_exists' => true, // quitens "file does not exist" for doc symlinks in Debian to files outside open_basedir |
|
205 | + 'only_if_exists' => true, // quitens "file does not exist" for doc symlinks in Debian to files outside open_basedir |
|
206 | 206 | 'recursiv' => True |
207 | 207 | ), |
208 | 208 | realpath('../header.inc.php') => array( |
@@ -240,10 +240,10 @@ discard block |
||
240 | 240 | $sp_visible = true; |
241 | 241 | if (($open_basedir = ini_get('open_basedir')) && $open_basedir != 'none') |
242 | 242 | { |
243 | - foreach(explode(PATH_SEPARATOR,$open_basedir) as $dir) |
|
243 | + foreach (explode(PATH_SEPARATOR, $open_basedir) as $dir) |
|
244 | 244 | { |
245 | 245 | $dir = realpath($dir); |
246 | - if (($sp_visible = substr($session_path,0,strlen($dir)) == $dir)) break; |
|
246 | + if (($sp_visible = substr($session_path, 0, strlen($dir)) == $dir)) break; |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | if ($sp_visible) // only check if session_save_path is visible by webserver |
@@ -251,13 +251,13 @@ discard block |
||
251 | 251 | $checks[$session_path] = array( |
252 | 252 | 'func' => 'permission_check', |
253 | 253 | 'is_writable' => true, |
254 | - 'msg' => lang("Checking if php.ini setting session.save_path='%1' is writable by the webserver",session_save_path()), |
|
254 | + 'msg' => lang("Checking if php.ini setting session.save_path='%1' is writable by the webserver", session_save_path()), |
|
255 | 255 | 'error' => lang('You will NOT be able to log into EGroupware using PHP sessions: "session could not be verified" !!!'), |
256 | 256 | ); |
257 | 257 | } |
258 | 258 | } |
259 | 259 | $setup_info = $GLOBALS['egw_setup']->detection->get_versions(); |
260 | -foreach($setup_info as $app => $app_data) |
|
260 | +foreach ($setup_info as $app => $app_data) |
|
261 | 261 | { |
262 | 262 | if (!isset($app_data['check_install'])) continue; |
263 | 263 | |
@@ -265,9 +265,9 @@ discard block |
||
265 | 265 | { |
266 | 266 | if (isset($checks[$name])) |
267 | 267 | { |
268 | - if ($checks[$name] == $data) continue; // identical check --> ignore it |
|
268 | + if ($checks[$name] == $data) continue; // identical check --> ignore it |
|
269 | 269 | |
270 | - if ($data['func'] == 'pear_check' || in_array($data['func'],array('extension_check','php_ini_check')) && !isset($data['warning'])) |
|
270 | + if ($data['func'] == 'pear_check' || in_array($data['func'], array('extension_check', 'php_ini_check')) && !isset($data['warning'])) |
|
271 | 271 | { |
272 | 272 | if (isset($checks[$name]['from']) && $checks[$name]['from'] && !is_array($checks[$name]['from'])) |
273 | 273 | { |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | } |
276 | 276 | if (!isset($data['from'])) $data['from'] = $app; |
277 | 277 | if (!isset($checks[$name]['from']) || !is_array($checks[$name]['from'])) $checks[$name]['from'] = array(); |
278 | - if (!in_array($data['from'],$checks[$name]['from'])) $checks[$name]['from'][] = $data['from']; |
|
278 | + if (!in_array($data['from'], $checks[$name]['from'])) $checks[$name]['from'][] = $data['from']; |
|
279 | 279 | } |
280 | 280 | else |
281 | 281 | { |
@@ -291,9 +291,9 @@ discard block |
||
291 | 291 | } |
292 | 292 | } |
293 | 293 | $sorted_checks = array(); |
294 | -foreach(array('php_version','php_ini_check','extension_check','pear_check','gd_check','permission_check') as $func) |
|
294 | +foreach (array('php_version', 'php_ini_check', 'extension_check', 'pear_check', 'gd_check', 'permission_check') as $func) |
|
295 | 295 | { |
296 | - foreach($checks as $name => $data) |
|
296 | + foreach ($checks as $name => $data) |
|
297 | 297 | { |
298 | 298 | if ($data['func'] == $func) |
299 | 299 | { |
@@ -304,15 +304,15 @@ discard block |
||
304 | 304 | } |
305 | 305 | if ($checks) $sorted_checks += $checks; |
306 | 306 | |
307 | -function php_version($name,$args) |
|
307 | +function php_version($name, $args) |
|
308 | 308 | { |
309 | 309 | global $passed_icon, $error_icon; |
310 | - unset($name); // not used, but required by function signature |
|
310 | + unset($name); // not used, but required by function signature |
|
311 | 311 | |
312 | - $version_ok = version_compare(phpversion(),$args['value']) >= 0; |
|
312 | + $version_ok = version_compare(phpversion(), $args['value']) >= 0; |
|
313 | 313 | |
314 | 314 | echo '<div>'.($version_ok ? $passed_icon : $error_icon).' <span'.($version_ok ? '' : ' class="setup_error"').'>'. |
315 | - lang('Checking required PHP version %1 (recommended %2)',$args['verbose_value'],$args['recommended']).': '. |
|
315 | + lang('Checking required PHP version %1 (recommended %2)', $args['verbose_value'], $args['recommended']).': '. |
|
316 | 316 | phpversion().' ==> '.($version_ok ? lang('True') : lang('False'))."</span></div>\n"; |
317 | 317 | } |
318 | 318 | |
@@ -323,13 +323,13 @@ discard block |
||
323 | 323 | */ |
324 | 324 | function composer_check($package) |
325 | 325 | { |
326 | - static $installed=null; |
|
326 | + static $installed = null; |
|
327 | 327 | if (!isset($installed)) |
328 | 328 | { |
329 | 329 | $installed = array(); |
330 | - if (file_exists(EGW_SERVER_ROOT.'/vendor') && file_exists($json=EGW_SERVER_ROOT.'/vendor/composer/installed.json')) |
|
330 | + if (file_exists(EGW_SERVER_ROOT.'/vendor') && file_exists($json = EGW_SERVER_ROOT.'/vendor/composer/installed.json')) |
|
331 | 331 | { |
332 | - foreach(json_decode(file_get_contents($json), true) as $package_data) |
|
332 | + foreach (json_decode(file_get_contents($json), true) as $package_data) |
|
333 | 333 | { |
334 | 334 | $installed[strtolower($package_data['name'])] = $package_data['version']; |
335 | 335 | } |
@@ -345,9 +345,9 @@ discard block |
||
345 | 345 | * @param $channel =null use default or given channel |
346 | 346 | * @return array with package-name => version pairs, eg. array('Log' => '1.9.8','PEAR' => '1.4.11') |
347 | 347 | */ |
348 | -function get_installed_pear_packages($channel=null) |
|
348 | +function get_installed_pear_packages($channel = null) |
|
349 | 349 | { |
350 | - $pear_config = ''; // use the system default |
|
350 | + $pear_config = ''; // use the system default |
|
351 | 351 | // fix for SuSE having the pear.conf only for cli, will fail with open_basedir - no idea what to do then |
352 | 352 | if (@is_dir('/etc/php5/apache2') && !file_exists('/etc/php5/apache2/pear.conf') && @file_exists('/etc/php5/cli/pear.conf')) |
353 | 353 | { |
@@ -357,13 +357,13 @@ discard block |
||
357 | 357 | |
358 | 358 | if (!class_exists('PEAR_Config')) return false; |
359 | 359 | |
360 | - $config = new PEAR_Config('',$pear_config); |
|
360 | + $config = new PEAR_Config('', $pear_config); |
|
361 | 361 | //echo "<pre>config = ".print_r($config,true)."</pre>\n"; |
362 | 362 | |
363 | 363 | if (empty($channel)) $channel = $config->get('default_channel'); |
364 | 364 | //echo "<pre>channel = ".print_r($channel,true)."</pre>\n"; |
365 | 365 | |
366 | - if (!method_exists($config,'getRegistry')) return false; // PEAR version to old |
|
366 | + if (!method_exists($config, 'getRegistry')) return false; // PEAR version to old |
|
367 | 367 | |
368 | 368 | $reg = &$config->getRegistry(); |
369 | 369 | //echo "<pre>reg = ".print_r($reg,true)."</pre>\n"; |
@@ -372,11 +372,11 @@ discard block |
||
372 | 372 | // bug reported: http://pear.php.net/bugs/bug.php?id=11317 |
373 | 373 | if (!file_exists($reg->install_dir)) return false; |
374 | 374 | |
375 | - $installed = $reg->packageInfo(null,null,$channel); |
|
375 | + $installed = $reg->packageInfo(null, null, $channel); |
|
376 | 376 | |
377 | 377 | //echo "<pre>installed =".print_r($installed,true)."</pre>\n"; |
378 | 378 | $packages = array(); |
379 | - foreach($installed as $package) |
|
379 | + foreach ($installed as $package) |
|
380 | 380 | { |
381 | 381 | $name = isset($package['package']) ? $package['package'] : $package['name']; |
382 | 382 | $version = $package['version']; |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | return $packages; |
391 | 391 | } |
392 | 392 | |
393 | -function pear_check($package,$args) |
|
393 | +function pear_check($package, $args) |
|
394 | 394 | { |
395 | 395 | global $passed_icon, $warning_icon; |
396 | 396 | static $pear_available = null; |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | $found = $pear_available; |
435 | 435 | if ($pear_available && $package) |
436 | 436 | { |
437 | - $file = str_replace('_','/',$package == 'Mail_Mime' ? 'Mail_mime' : $package).'.php'; |
|
437 | + $file = str_replace('_', '/', $package == 'Mail_Mime' ? 'Mail_mime' : $package).'.php'; |
|
438 | 438 | |
439 | 439 | $found = @include_once($file); |
440 | 440 | |
@@ -443,16 +443,15 @@ discard block |
||
443 | 443 | } |
444 | 444 | } |
445 | 445 | // is the right version availible |
446 | - $available = $found && (!$min_version || version_compare($min_version,$version_available) <= 0); |
|
446 | + $available = $found && (!$min_version || version_compare($min_version, $version_available) <= 0); |
|
447 | 447 | echo '<div>'.($available ? $passed_icon : $warning_icon).' <span'.($available ? '' : ' class="setup_warning"').'>'. |
448 | - lang('Checking PEAR%1 is installed',($package?($channel?' '.$channel.'/':'::').$package:'').($min_version?" ($min_version)":'')).': '. |
|
449 | - ($available ? ($version_available ? $version_available : lang('True')) : |
|
450 | - ($found ? lang('Found, but unknown version') : lang('False')))."</span></div>\n"; |
|
448 | + lang('Checking PEAR%1 is installed', ($package ? ($channel ? ' '.$channel.'/' : '::').$package : '').($min_version ? " ($min_version)" : '')).': '. |
|
449 | + ($available ? ($version_available ? $version_available : lang('True')) : ($found ? lang('Found, but unknown version') : lang('False')))."</span></div>\n"; |
|
451 | 450 | |
452 | 451 | if (!$available) // give further info only if not availible |
453 | 452 | { |
454 | - echo '<div class="setup_info">' . lang('PEAR%1 is needed by: %2.',$package ? '::'.$package : '', |
|
455 | - is_array($args['from']) ? implode(', ',$args['from']) : $args['from']); |
|
453 | + echo '<div class="setup_info">'.lang('PEAR%1 is needed by: %2.', $package ? '::'.$package : '', |
|
454 | + is_array($args['from']) ? implode(', ', $args['from']) : $args['from']); |
|
456 | 455 | |
457 | 456 | // if using Composer, dont confuse user with PEAR ;-) |
458 | 457 | if (file_exists(EGW_SERVER_ROOT.'/vendor')) |
@@ -465,7 +464,7 @@ discard block |
||
465 | 464 | if (!$pear_available) |
466 | 465 | { |
467 | 466 | echo '<br/>'.lang('PEAR (%1) is a PHP repository and is usually in a package called %2.', |
468 | - '<a href="http://pear.php.net" target="_blank">pear.php.net</a>','php-pear'); |
|
467 | + '<a href="http://pear.php.net" target="_blank">pear.php.net</a>', 'php-pear'); |
|
469 | 468 | } |
470 | 469 | elseif ($package && !$found) |
471 | 470 | { |
@@ -475,12 +474,12 @@ discard block |
||
475 | 474 | } |
476 | 475 | elseif ($min_version && !$version_available) |
477 | 476 | { |
478 | - echo '<br/>'.lang('We could not determine the version of %1, please make sure it is at least %2',$package,$min_version); |
|
477 | + echo '<br/>'.lang('We could not determine the version of %1, please make sure it is at least %2', $package, $min_version); |
|
479 | 478 | } |
480 | - elseif ($min_version && version_compare($min_version,$version_available) > 0) |
|
479 | + elseif ($min_version && version_compare($min_version, $version_available) > 0) |
|
481 | 480 | { |
482 | 481 | echo '<br/>'.lang('Your installed version of %1 is %2, required is at least %3, please run: ', |
483 | - $package,$version_available,$min_version).' pear upgrade '.$package; |
|
482 | + $package, $version_available, $min_version).' pear upgrade '.$package; |
|
484 | 483 | } |
485 | 484 | echo '<br/>'.lang('Alternatively you can use %1Composer%2 to install all requirements at once. Downloading it and run:', |
486 | 485 | '<a href="https://getcomposer.org/" target="_blank">', '</a>'). |
@@ -493,26 +492,26 @@ discard block |
||
493 | 492 | return $available; |
494 | 493 | } |
495 | 494 | |
496 | -function extension_check($name,$args) |
|
495 | +function extension_check($name, $args) |
|
497 | 496 | { |
498 | 497 | //echo "<p>extension_check($name,".print_r($args,true).")</p>\n"; |
499 | 498 | global $passed_icon, $warning_icon, $is_windows; |
500 | 499 | |
501 | 500 | if (isset($args['win_only']) && $args['win_only'] && !$is_windows) |
502 | 501 | { |
503 | - return True; // check only under windows |
|
502 | + return True; // check only under windows |
|
504 | 503 | } |
505 | 504 | // we check for the existens of 'dl', as multithreaded webservers dont have it !!! |
506 | 505 | $available = check_load_extension($name); |
507 | 506 | |
508 | - echo '<div>'.($available ? $passed_icon : $warning_icon).' <span'.($available ? '' : ' class="setup_warning"').'>'.lang('Checking extension %1 is loaded or loadable',$name).': '.($available ? lang('True') : lang('False'))."</span></div>\n"; |
|
507 | + echo '<div>'.($available ? $passed_icon : $warning_icon).' <span'.($available ? '' : ' class="setup_warning"').'>'.lang('Checking extension %1 is loaded or loadable', $name).': '.($available ? lang('True') : lang('False'))."</span></div>\n"; |
|
509 | 508 | |
510 | 509 | if (!$available) |
511 | 510 | { |
512 | 511 | if (!isset($args['warning'])) |
513 | 512 | { |
514 | - $args['warning'] = lang('The %1 extension is needed from: %2.',$name, |
|
515 | - is_array($args['from']) ? implode(', ',$args['from']) : $args['from']); |
|
513 | + $args['warning'] = lang('The %1 extension is needed from: %2.', $name, |
|
514 | + is_array($args['from']) ? implode(', ', $args['from']) : $args['from']); |
|
516 | 515 | } |
517 | 516 | echo "<div class='setup_info'>".$args['warning'].'</div>'; |
518 | 517 | } |
@@ -521,20 +520,20 @@ discard block |
||
521 | 520 | return $available; |
522 | 521 | } |
523 | 522 | |
524 | -function function_check($name,$args) |
|
523 | +function function_check($name, $args) |
|
525 | 524 | { |
526 | 525 | global $passed_icon, $warning_icon; |
527 | 526 | |
528 | 527 | $available = function_exists($name); |
529 | 528 | |
530 | - echo '<div>'.($available ? $passed_icon : $warning_icon).' <span'.($available ? '' : ' class="setup_warning"').'>'.lang('Checking function %1 exists',$name).': '.($available ? lang('True') : lang('False'))."</span></div>\n"; |
|
529 | + echo '<div>'.($available ? $passed_icon : $warning_icon).' <span'.($available ? '' : ' class="setup_warning"').'>'.lang('Checking function %1 exists', $name).': '.($available ? lang('True') : lang('False'))."</span></div>\n"; |
|
531 | 530 | |
532 | 531 | if (!$available) |
533 | 532 | { |
534 | 533 | if (!isset($args['warning'])) |
535 | 534 | { |
536 | - $args['warning'] = lang('The function %1 is needed from: %2.',$name, |
|
537 | - is_array($args['from'] ? implode(', ',$args['from']) : $args['from'])); |
|
535 | + $args['warning'] = lang('The function %1 is needed from: %2.', $name, |
|
536 | + is_array($args['from'] ? implode(', ', $args['from']) : $args['from'])); |
|
538 | 537 | } |
539 | 538 | echo "<div class='setup_info'>".$args['warning'].'</div>'; |
540 | 539 | } |
@@ -543,33 +542,33 @@ discard block |
||
543 | 542 | return $available; |
544 | 543 | } |
545 | 544 | |
546 | -function verbosePerms( $in_Perms ) |
|
545 | +function verbosePerms($in_Perms) |
|
547 | 546 | { |
548 | - if($in_Perms & 0x1000) // FIFO pipe |
|
547 | + if ($in_Perms&0x1000) // FIFO pipe |
|
549 | 548 | { |
550 | 549 | $sP = 'p'; |
551 | 550 | } |
552 | - elseif($in_Perms & 0x2000) // Character special |
|
551 | + elseif ($in_Perms&0x2000) // Character special |
|
553 | 552 | { |
554 | 553 | $sP = 'c'; |
555 | 554 | } |
556 | - elseif($in_Perms & 0x4000) // Directory |
|
555 | + elseif ($in_Perms&0x4000) // Directory |
|
557 | 556 | { |
558 | 557 | $sP = 'd'; |
559 | 558 | } |
560 | - elseif($in_Perms & 0x6000) // Block special |
|
559 | + elseif ($in_Perms&0x6000) // Block special |
|
561 | 560 | { |
562 | 561 | $sP = 'b'; |
563 | 562 | } |
564 | - elseif($in_Perms & 0x8000) // Regular |
|
563 | + elseif ($in_Perms&0x8000) // Regular |
|
565 | 564 | { |
566 | 565 | $sP = '-'; |
567 | 566 | } |
568 | - elseif($in_Perms & 0xA000) // Symbolic Link |
|
567 | + elseif ($in_Perms&0xA000) // Symbolic Link |
|
569 | 568 | { |
570 | 569 | $sP = 'l'; |
571 | 570 | } |
572 | - elseif($in_Perms & 0xC000) // Socket |
|
571 | + elseif ($in_Perms&0xC000) // Socket |
|
573 | 572 | { |
574 | 573 | $sP = 's'; |
575 | 574 | } |
@@ -579,33 +578,30 @@ discard block |
||
579 | 578 | } |
580 | 579 | |
581 | 580 | // owner |
582 | - $sP .= (($in_Perms & 0x0100) ? 'r' : '-') . |
|
583 | - (($in_Perms & 0x0080) ? 'w' : '-') . |
|
584 | - (($in_Perms & 0x0040) ? (($in_Perms & 0x0800) ? 's' : 'x' ) : |
|
585 | - (($in_Perms & 0x0800) ? 'S' : '-')); |
|
581 | + $sP .= (($in_Perms&0x0100) ? 'r' : '-'). |
|
582 | + (($in_Perms&0x0080) ? 'w' : '-'). |
|
583 | + (($in_Perms&0x0040) ? (($in_Perms&0x0800) ? 's' : 'x') : (($in_Perms&0x0800) ? 'S' : '-')); |
|
586 | 584 | |
587 | 585 | // group |
588 | - $sP .= (($in_Perms & 0x0020) ? 'r' : '-') . |
|
589 | - (($in_Perms & 0x0010) ? 'w' : '-') . |
|
590 | - (($in_Perms & 0x0008) ? (($in_Perms & 0x0400) ? 's' : 'x' ) : |
|
591 | - (($in_Perms & 0x0400) ? 'S' : '-')); |
|
586 | + $sP .= (($in_Perms&0x0020) ? 'r' : '-'). |
|
587 | + (($in_Perms&0x0010) ? 'w' : '-'). |
|
588 | + (($in_Perms&0x0008) ? (($in_Perms&0x0400) ? 's' : 'x') : (($in_Perms&0x0400) ? 'S' : '-')); |
|
592 | 589 | |
593 | 590 | // world |
594 | - $sP .= (($in_Perms & 0x0004) ? 'r' : '-') . |
|
595 | - (($in_Perms & 0x0002) ? 'w' : '-') . |
|
596 | - (($in_Perms & 0x0001) ? (($in_Perms & 0x0200) ? 't' : 'x' ) : |
|
597 | - (($in_Perms & 0x0200) ? 'T' : '-')); |
|
591 | + $sP .= (($in_Perms&0x0004) ? 'r' : '-'). |
|
592 | + (($in_Perms&0x0002) ? 'w' : '-'). |
|
593 | + (($in_Perms&0x0001) ? (($in_Perms&0x0200) ? 't' : 'x') : (($in_Perms&0x0200) ? 'T' : '-')); |
|
598 | 594 | return $sP; |
599 | 595 | } |
600 | 596 | |
601 | -function permission_check($name,$args,$verbose=True) |
|
597 | +function permission_check($name, $args, $verbose = True) |
|
602 | 598 | { |
603 | - global $passed_icon, $error_icon, $warning_icon,$is_windows; |
|
599 | + global $passed_icon, $error_icon, $warning_icon, $is_windows; |
|
604 | 600 | //echo "<p>permision_check('$name',".print_r($args,True).",'$verbose')</p>\n"; |
605 | 601 | |
606 | 602 | // add a ../ for non-absolute pathes |
607 | 603 | $rel_name = $name; |
608 | - if ($name && substr($name,0,3) != '../' && $name[0] != '/' && $name[0] != '\\' && strpos($name,':') === false) |
|
604 | + if ($name && substr($name, 0, 3) != '../' && $name[0] != '/' && $name[0] != '\\' && strpos($name, ':') === false) |
|
609 | 605 | { |
610 | 606 | $name = '../'.$name; |
611 | 607 | } |
@@ -627,22 +623,22 @@ discard block |
||
627 | 623 | if (isset($args['is_readable'])) |
628 | 624 | { |
629 | 625 | $checks[] = lang('readable by the webserver'); |
630 | - $check_not = (!$args['is_readable']?lang('not'):''); |
|
626 | + $check_not = (!$args['is_readable'] ?lang('not') : ''); |
|
631 | 627 | } |
632 | 628 | if (isset($args['is_writable'])) |
633 | 629 | { |
634 | 630 | $checks[] = lang('writable by the webserver'); |
635 | - $check_not = (!$args['is_writable']?lang('not'):''); |
|
631 | + $check_not = (!$args['is_writable'] ?lang('not') : ''); |
|
636 | 632 | } |
637 | 633 | if (isset($args['is_world_readable'])) |
638 | 634 | { |
639 | 635 | $checks[] = lang('world readable'); |
640 | - $check_not = (!$args['is_world_readable']?lang('not'):''); |
|
636 | + $check_not = (!$args['is_world_readable'] ?lang('not') : ''); |
|
641 | 637 | } |
642 | 638 | if (isset($args['is_world_writable'])) |
643 | 639 | { |
644 | 640 | $checks[] = lang('world writable'); |
645 | - $check_not = (!$args['is_world_writable']?lang('not'):''); |
|
641 | + $check_not = (!$args['is_world_writable'] ?lang('not') : ''); |
|
646 | 642 | } |
647 | 643 | |
648 | 644 | if (isset($args['msg']) && ($msg = $args['msg'])) |
@@ -651,7 +647,7 @@ discard block |
||
651 | 647 | } |
652 | 648 | else |
653 | 649 | { |
654 | - $msg = lang('Checking file-permissions of %1 for %2 %3: %4',$rel_name,$check_not,implode(', ',$checks),$perms)."<br />\n"; |
|
650 | + $msg = lang('Checking file-permissions of %1 for %2 %3: %4', $rel_name, $check_not, implode(', ', $checks), $perms)."<br />\n"; |
|
655 | 651 | } |
656 | 652 | $extra_error_msg = ''; |
657 | 653 | if (isset($args['error']) && $args['error']) |
@@ -660,13 +656,13 @@ discard block |
||
660 | 656 | } |
661 | 657 | if (!file_exists($name)) |
662 | 658 | { |
663 | - echo '<div>'. $error_icon . '<span class="setup_error">' . $msg . lang('%1 does not exist !!!',$rel_name).$extra_error_msg."</span></div>\n"; |
|
659 | + echo '<div>'.$error_icon.'<span class="setup_error">'.$msg.lang('%1 does not exist !!!', $rel_name).$extra_error_msg."</span></div>\n"; |
|
664 | 660 | return False; |
665 | 661 | } |
666 | 662 | $warning = False; |
667 | 663 | if (!$GLOBALS['run_by_webserver'] && (@$args['is_readable'] || @$args['is_writable'])) |
668 | 664 | { |
669 | - echo $warning_icon.' '.$msg. lang('Check can only be performed, if called via a webserver, as the user-id/-name of the webserver is not known.')."\n"; |
|
665 | + echo $warning_icon.' '.$msg.lang('Check can only be performed, if called via a webserver, as the user-id/-name of the webserver is not known.')."\n"; |
|
670 | 666 | unset($args['is_readable']); |
671 | 667 | unset($args['is_writable']); |
672 | 668 | $warning = True; |
@@ -674,22 +670,22 @@ discard block |
||
674 | 670 | $Ok = True; |
675 | 671 | if (isset($args['is_writable']) && is_writable($name) != $args['is_writable']) |
676 | 672 | { |
677 | - echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.' '.lang('%1 is %2%3 !!!',$rel_name,$args['is_writable']?lang('not').' ':'',lang('writable by the webserver')).$extra_error_msg."</span></div>\n"; |
|
673 | + echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.' '.lang('%1 is %2%3 !!!', $rel_name, $args['is_writable'] ?lang('not').' ' : '', lang('writable by the webserver')).$extra_error_msg."</span></div>\n"; |
|
678 | 674 | $Ok = False; |
679 | 675 | } |
680 | 676 | if (isset($args['is_readable']) && is_readable($name) != $args['is_readable']) |
681 | 677 | { |
682 | - echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.' '.lang('%1 is %2%3 !!!',$rel_name,$args['is_readable']?lang('not').' ':'',lang('readable by the webserver')).$extra_error_msg."</span></div>\n"; |
|
678 | + echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.' '.lang('%1 is %2%3 !!!', $rel_name, $args['is_readable'] ?lang('not').' ' : '', lang('readable by the webserver')).$extra_error_msg."</span></div>\n"; |
|
683 | 679 | $Ok = False; |
684 | 680 | } |
685 | - if (!$is_windows && isset($args['is_world_readable']) && !(fileperms($name) & 04) == $args['is_world_readable']) |
|
681 | + if (!$is_windows && isset($args['is_world_readable']) && !(fileperms($name)&04) == $args['is_world_readable']) |
|
686 | 682 | { |
687 | - echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.' '.lang('%1 is %2%3 !!!',$rel_name,$args['is_world_readable']?lang('not').' ':'',lang('world readable')).$extra_error_msg."</span></div>\n"; |
|
683 | + echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.' '.lang('%1 is %2%3 !!!', $rel_name, $args['is_world_readable'] ?lang('not').' ' : '', lang('world readable')).$extra_error_msg."</span></div>\n"; |
|
688 | 684 | $Ok = False; |
689 | 685 | } |
690 | - if (!$is_windows && isset($args['is_world_writable']) && !(fileperms($name) & 02) == $args['is_world_writable']) |
|
686 | + if (!$is_windows && isset($args['is_world_writable']) && !(fileperms($name)&02) == $args['is_world_writable']) |
|
691 | 687 | { |
692 | - echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.' '.lang('%1 is %2%3 !!!',$rel_name,$args['is_world_writable']?lang('not').' ':'',lang('world writable')).$extra_error_msg."</span></div>\n"; |
|
688 | + echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.' '.lang('%1 is %2%3 !!!', $rel_name, $args['is_world_writable'] ?lang('not').' ' : '', lang('world writable')).$extra_error_msg."</span></div>\n"; |
|
693 | 689 | $Ok = False; |
694 | 690 | } |
695 | 691 | if ($Ok && !$warning && $verbose) |
@@ -701,16 +697,16 @@ discard block |
||
701 | 697 | if ($verbose) |
702 | 698 | { |
703 | 699 | @set_time_limit(0); |
704 | - echo "<div class='setup_info'>" . lang('This might take a while, please wait ...')."</div>\n"; |
|
700 | + echo "<div class='setup_info'>".lang('This might take a while, please wait ...')."</div>\n"; |
|
705 | 701 | flush(); |
706 | 702 | } |
707 | 703 | @set_time_limit(0); |
708 | 704 | $handle = @opendir($name); |
709 | - while($handle && ($file = readdir($handle))) |
|
705 | + while ($handle && ($file = readdir($handle))) |
|
710 | 706 | { |
711 | 707 | if ($file != '.' && $file != '..') |
712 | 708 | { |
713 | - $Ok = $Ok && permission_check(($name!='.'?$name.'/':'').$file,$args,False); |
|
709 | + $Ok = $Ok && permission_check(($name != '.' ? $name.'/' : '').$file, $args, False); |
|
714 | 710 | } |
715 | 711 | } |
716 | 712 | if ($handle) closedir($handle); |
@@ -723,12 +719,12 @@ discard block |
||
723 | 719 | function mk_value($value) |
724 | 720 | { |
725 | 721 | $matches = null; |
726 | - if (!preg_match('/^([0-9]+)([mk]+)$/i',$value,$matches)) return $value; |
|
722 | + if (!preg_match('/^([0-9]+)([mk]+)$/i', $value, $matches)) return $value; |
|
727 | 723 | |
728 | - return (strtolower($matches[2]) == 'm' ? 1024*1024 : 1024) * (int) $matches[1]; |
|
724 | + return (strtolower($matches[2]) == 'm' ? 1024 * 1024 : 1024) * (int)$matches[1]; |
|
729 | 725 | } |
730 | 726 | |
731 | -function php_ini_check($name,$args) |
|
727 | +function php_ini_check($name, $args) |
|
732 | 728 | { |
733 | 729 | global $passed_icon, $error_icon, $warning_icon, $is_windows; |
734 | 730 | |
@@ -746,20 +742,20 @@ discard block |
||
746 | 742 | { |
747 | 743 | case 'not set': |
748 | 744 | $check = lang('not set'); |
749 | - $result = !($ini_value & $args['value']); |
|
745 | + $result = !($ini_value&$args['value']); |
|
750 | 746 | break; |
751 | 747 | case 'set': |
752 | 748 | $check = lang('set'); |
753 | - $result = !!($ini_value & $args['value']); |
|
749 | + $result = !!($ini_value&$args['value']); |
|
754 | 750 | break; |
755 | 751 | case '>=': |
756 | - $result = !$ini_value || // value not used, eg. no memory limit |
|
757 | - (int) mk_value($ini_value) >= (int) mk_value($args['value']); |
|
752 | + $result = !$ini_value || // value not used, eg. no memory limit |
|
753 | + (int)mk_value($ini_value) >= (int)mk_value($args['value']); |
|
758 | 754 | break; |
759 | 755 | case 'contain': |
760 | 756 | $check = lang('contain'); |
761 | 757 | $sep = $is_windows ? '/[; ]+/' : '/[: ]+/'; |
762 | - $result = in_array($args['value'],preg_split($sep,$ini_value)); |
|
758 | + $result = in_array($args['value'], preg_split($sep, $ini_value)); |
|
763 | 759 | break; |
764 | 760 | case '!=': |
765 | 761 | $check = lang('set and not'); |
@@ -776,9 +772,9 @@ discard block |
||
776 | 772 | $tz = new DateTimeZone($ini_value); |
777 | 773 | unset($tz); |
778 | 774 | } |
779 | - catch(Exception $e) { |
|
775 | + catch (Exception $e) { |
|
780 | 776 | unset($e); |
781 | - $result = false; // no valid timezone |
|
777 | + $result = false; // no valid timezone |
|
782 | 778 | } |
783 | 779 | } |
784 | 780 | $msg = ' '.lang('Checking php.ini').": $name $check $verbose_value: <span class='setup_info'>ini_get('$name')='$ini_value'$ini_value_verbose</span>"; |
@@ -800,7 +796,7 @@ discard block |
||
800 | 796 | elseif (!isset($args['safe_mode'])) |
801 | 797 | { |
802 | 798 | echo "<div>".$warning_icon.' <span class="setup_warning">'.$msg.'</span><div class="setup_info">'. |
803 | - lang('%1 is needed by: %2.',$name,is_array($args['from']) ? implode(', ',$args['from']) : $args['from']) |
|
799 | + lang('%1 is needed by: %2.', $name, is_array($args['from']) ? implode(', ', $args['from']) : $args['from']) |
|
804 | 800 | ."</div></div>\n"; |
805 | 801 | } |
806 | 802 | if (isset($args['safe_mode']) && $safe_mode || @$args['change']) |
@@ -810,7 +806,7 @@ discard block |
||
810 | 806 | echo '<div>'.$error_icon.' <span class="setup_error">'.$msg.'</span></div>'; |
811 | 807 | } |
812 | 808 | echo "<div class='setup_error'>\n"; |
813 | - echo '*** '.lang('Please make the following change in your php.ini').' ('.get_php_ini().'): '.(@$args['safe_mode']?$args['safe_mode']:$args['change'])."<br />\n"; |
|
809 | + echo '*** '.lang('Please make the following change in your php.ini').' ('.get_php_ini().'): '.(@$args['safe_mode'] ? $args['safe_mode'] : $args['change'])."<br />\n"; |
|
814 | 810 | echo '*** '.lang('AND reload your webserver, so the above changes take effect !!!')."</div>\n"; |
815 | 811 | } |
816 | 812 | } |
@@ -825,16 +821,16 @@ discard block |
||
825 | 821 | ob_end_clean(); |
826 | 822 | |
827 | 823 | $found = null; |
828 | - return preg_match('/\(php.ini\).*<\/td><td[^>]*>([^ <]+)/',$phpinfo,$found) ? $found[1] : False; |
|
824 | + return preg_match('/\(php.ini\).*<\/td><td[^>]*>([^ <]+)/', $phpinfo, $found) ? $found[1] : False; |
|
829 | 825 | } |
830 | 826 | |
831 | 827 | function gd_check() |
832 | 828 | { |
833 | 829 | global $passed_icon, $warning_icon; |
834 | 830 | |
835 | - $available = (function_exists('imagecopyresampled') || function_exists('imagecopyresized')); |
|
831 | + $available = (function_exists('imagecopyresampled') || function_exists('imagecopyresized')); |
|
836 | 832 | |
837 | - echo "<div>".($available ? $passed_icon : $warning_icon).' <span'.($available?'':' class="setup_warning"').'>'.lang('Checking for GD support...').': '.($available ? lang('True') : lang('False'))."</span></div>\n"; |
|
833 | + echo "<div>".($available ? $passed_icon : $warning_icon).' <span'.($available ? '' : ' class="setup_warning"').'>'.lang('Checking for GD support...').': '.($available ? lang('True') : lang('False'))."</span></div>\n"; |
|
838 | 834 | |
839 | 835 | if (!$available) |
840 | 836 | { |
@@ -853,24 +849,24 @@ discard block |
||
853 | 849 | )); |
854 | 850 | $ConfigDomain = $_REQUEST['ConfigDomain']; |
855 | 851 | if (@$_GET['intro']) { |
856 | - if(($ConfigLang = setup::get_lang())) |
|
852 | + if (($ConfigLang = setup::get_lang())) |
|
857 | 853 | { |
858 | - $GLOBALS['egw_setup']->set_cookie('ConfigLang',$ConfigLang,(int) (time()+(1200*9)),'/'); |
|
854 | + $GLOBALS['egw_setup']->set_cookie('ConfigLang', $ConfigLang, (int)(time() + (1200 * 9)), '/'); |
|
859 | 855 | } |
860 | - $GLOBALS['egw_setup']->html->show_header(lang('Welcome to the EGroupware Installation'),False,'config'); |
|
856 | + $GLOBALS['egw_setup']->html->show_header(lang('Welcome to the EGroupware Installation'), False, 'config'); |
|
861 | 857 | echo '<h1>'.lang('Welcome to the EGroupware Installation')."</h1>\n"; |
862 | - if(!$ConfigLang) |
|
858 | + if (!$ConfigLang) |
|
863 | 859 | { |
864 | - echo '<p><form action="check_install.php?intro=1" method="Post">Please Select your language '.setup_html::lang_select(True,'en')."</form></p>\n"; |
|
860 | + echo '<p><form action="check_install.php?intro=1" method="Post">Please Select your language '.setup_html::lang_select(True, 'en')."</form></p>\n"; |
|
865 | 861 | } |
866 | 862 | echo '<p>'.lang('The first step in installing EGroupware is to ensure your environment has the necessary settings to correctly run the application.').'</p>'; |
867 | 863 | echo '<p>'.lang('We will now run a series of tests, which may take a few minutes. Click the link below to proceed.').'</p>'; |
868 | 864 | echo '<h3><a href="check_install.php">'.lang('Run installation tests').'</a></h3>'; |
869 | 865 | echo '<p><a href="manageheader.php">'.lang('Skip the installation tests (not recommended)')."</a></p>\n"; |
870 | - $setup_tpl->pparse('out','T_footer'); |
|
866 | + $setup_tpl->pparse('out', 'T_footer'); |
|
871 | 867 | exit; |
872 | 868 | } else { |
873 | - $GLOBALS['egw_setup']->html->show_header(lang('Checking the EGroupware Installation'),False,'config',$ConfigDomain ? $ConfigDomain . '(' . @$GLOBALS['egw_domain'][$ConfigDomain]['db_type'] . ')' : ''); |
|
869 | + $GLOBALS['egw_setup']->html->show_header(lang('Checking the EGroupware Installation'), False, 'config', $ConfigDomain ? $ConfigDomain.'('.@$GLOBALS['egw_domain'][$ConfigDomain]['db_type'].')' : ''); |
|
874 | 870 | echo '<h1>'.lang('Checking the EGroupware Installation')."</h1>\n"; |
875 | 871 | # echo "<pre style=\"text-align: left;\">\n";; |
876 | 872 | } |
@@ -884,7 +880,7 @@ discard block |
||
884 | 880 | $Ok = True; |
885 | 881 | foreach ($sorted_checks as $name => $args) |
886 | 882 | { |
887 | - $check_ok = $args['func']($name,$args); |
|
883 | + $check_ok = $args['func']($name, $args); |
|
888 | 884 | $Ok = $Ok && $check_ok; |
889 | 885 | } |
890 | 886 | |
@@ -896,9 +892,9 @@ discard block |
||
896 | 892 | { |
897 | 893 | if (!$Ok) |
898 | 894 | { |
899 | - echo '<h3>'.lang('Please fix the above errors (%1) and warnings(%2)',$error_icon,$warning_icon)."</h3>\n"; |
|
895 | + echo '<h3>'.lang('Please fix the above errors (%1) and warnings(%2)', $error_icon, $warning_icon)."</h3>\n"; |
|
900 | 896 | echo '<h3><a href="check_install.php">'.lang('Click here to re-run the installation tests')."</a></h3>\n"; |
901 | - echo '<h3>'.lang('or %1Continue to the Header Admin%2','<a href="manageheader.php">','</a>')."</h3>\n"; |
|
897 | + echo '<h3>'.lang('or %1Continue to the Header Admin%2', '<a href="manageheader.php">', '</a>')."</h3>\n"; |
|
902 | 898 | } |
903 | 899 | else |
904 | 900 | { |
@@ -910,10 +906,10 @@ discard block |
||
910 | 906 | echo '<h3>'; |
911 | 907 | if (!$Ok) |
912 | 908 | { |
913 | - echo lang('Please fix the above errors (%1) and warnings(%2)',$error_icon,$warning_icon).'. '; |
|
909 | + echo lang('Please fix the above errors (%1) and warnings(%2)', $error_icon, $warning_icon).'. '; |
|
914 | 910 | } |
915 | - echo '<br /><a href="'.str_replace('check_install.php','',@$_SERVER['HTTP_REFERER']).'">'.lang('Return to Setup')."</a></h3>\n"; |
|
911 | + echo '<br /><a href="'.str_replace('check_install.php', '', @$_SERVER['HTTP_REFERER']).'">'.lang('Return to Setup')."</a></h3>\n"; |
|
916 | 912 | } |
917 | - $setup_tpl->pparse('out','T_footer'); |
|
913 | + $setup_tpl->pparse('out', 'T_footer'); |
|
918 | 914 | //echo "</body>\n</html>\n"; |
919 | 915 | } |
@@ -243,10 +243,15 @@ discard block |
||
243 | 243 | foreach(explode(PATH_SEPARATOR,$open_basedir) as $dir) |
244 | 244 | { |
245 | 245 | $dir = realpath($dir); |
246 | - if (($sp_visible = substr($session_path,0,strlen($dir)) == $dir)) break; |
|
246 | + if (($sp_visible = substr($session_path,0,strlen($dir)) == $dir)) |
|
247 | + { |
|
248 | + break; |
|
249 | + } |
|
247 | 250 | } |
248 | 251 | } |
249 | - if ($sp_visible) // only check if session_save_path is visible by webserver |
|
252 | + if ($sp_visible) |
|
253 | + { |
|
254 | + // only check if session_save_path is visible by webserver |
|
250 | 255 | { |
251 | 256 | $checks[$session_path] = array( |
252 | 257 | 'func' => 'permission_check', |
@@ -255,17 +260,25 @@ discard block |
||
255 | 260 | 'error' => lang('You will NOT be able to log into EGroupware using PHP sessions: "session could not be verified" !!!'), |
256 | 261 | ); |
257 | 262 | } |
263 | + } |
|
258 | 264 | } |
259 | 265 | $setup_info = $GLOBALS['egw_setup']->detection->get_versions(); |
260 | 266 | foreach($setup_info as $app => $app_data) |
261 | 267 | { |
262 | - if (!isset($app_data['check_install'])) continue; |
|
268 | + if (!isset($app_data['check_install'])) |
|
269 | + { |
|
270 | + continue; |
|
271 | + } |
|
263 | 272 | |
264 | 273 | foreach ($app_data['check_install'] as $name => $data) |
265 | 274 | { |
266 | 275 | if (isset($checks[$name])) |
267 | 276 | { |
268 | - if ($checks[$name] == $data) continue; // identical check --> ignore it |
|
277 | + if ($checks[$name] == $data) |
|
278 | + { |
|
279 | + continue; |
|
280 | + } |
|
281 | + // identical check --> ignore it |
|
269 | 282 | |
270 | 283 | if ($data['func'] == 'pear_check' || in_array($data['func'],array('extension_check','php_ini_check')) && !isset($data['warning'])) |
271 | 284 | { |
@@ -273,9 +286,18 @@ discard block |
||
273 | 286 | { |
274 | 287 | $checks[$name]['from'] = array($checks[$name]['from']); |
275 | 288 | } |
276 | - if (!isset($data['from'])) $data['from'] = $app; |
|
277 | - if (!isset($checks[$name]['from']) || !is_array($checks[$name]['from'])) $checks[$name]['from'] = array(); |
|
278 | - if (!in_array($data['from'],$checks[$name]['from'])) $checks[$name]['from'][] = $data['from']; |
|
289 | + if (!isset($data['from'])) |
|
290 | + { |
|
291 | + $data['from'] = $app; |
|
292 | + } |
|
293 | + if (!isset($checks[$name]['from']) || !is_array($checks[$name]['from'])) |
|
294 | + { |
|
295 | + $checks[$name]['from'] = array(); |
|
296 | + } |
|
297 | + if (!in_array($data['from'],$checks[$name]['from'])) |
|
298 | + { |
|
299 | + $checks[$name]['from'][] = $data['from']; |
|
300 | + } |
|
279 | 301 | } |
280 | 302 | else |
281 | 303 | { |
@@ -284,7 +306,10 @@ discard block |
||
284 | 306 | } |
285 | 307 | else |
286 | 308 | { |
287 | - if (!isset($data['from'])) $data['from'] = $app; |
|
309 | + if (!isset($data['from'])) |
|
310 | + { |
|
311 | + $data['from'] = $app; |
|
312 | + } |
|
288 | 313 | $checks[$name] = $data; |
289 | 314 | } |
290 | 315 | //echo "added check $data[func]($name) for $app"; _debug_array($data); |
@@ -302,7 +327,10 @@ discard block |
||
302 | 327 | } |
303 | 328 | } |
304 | 329 | } |
305 | -if ($checks) $sorted_checks += $checks; |
|
330 | +if ($checks) |
|
331 | +{ |
|
332 | + $sorted_checks += $checks; |
|
333 | +} |
|
306 | 334 | |
307 | 335 | function php_version($name,$args) |
308 | 336 | { |
@@ -355,22 +383,35 @@ discard block |
||
355 | 383 | } |
356 | 384 | @include_once 'PEAR/Config.php'; |
357 | 385 | |
358 | - if (!class_exists('PEAR_Config')) return false; |
|
386 | + if (!class_exists('PEAR_Config')) |
|
387 | + { |
|
388 | + return false; |
|
389 | + } |
|
359 | 390 | |
360 | 391 | $config = new PEAR_Config('',$pear_config); |
361 | 392 | //echo "<pre>config = ".print_r($config,true)."</pre>\n"; |
362 | 393 | |
363 | - if (empty($channel)) $channel = $config->get('default_channel'); |
|
394 | + if (empty($channel)) |
|
395 | + { |
|
396 | + $channel = $config->get('default_channel'); |
|
397 | + } |
|
364 | 398 | //echo "<pre>channel = ".print_r($channel,true)."</pre>\n"; |
365 | 399 | |
366 | - if (!method_exists($config,'getRegistry')) return false; // PEAR version to old |
|
400 | + if (!method_exists($config,'getRegistry')) |
|
401 | + { |
|
402 | + return false; |
|
403 | + } |
|
404 | + // PEAR version to old |
|
367 | 405 | |
368 | 406 | $reg = &$config->getRegistry(); |
369 | 407 | //echo "<pre>reg = ".print_r($reg,true)."</pre>\n"; |
370 | 408 | |
371 | 409 | // a bug in pear causes an endless loop if the install-dir does not exist |
372 | 410 | // bug reported: http://pear.php.net/bugs/bug.php?id=11317 |
373 | - if (!file_exists($reg->install_dir)) return false; |
|
411 | + if (!file_exists($reg->install_dir)) |
|
412 | + { |
|
413 | + return false; |
|
414 | + } |
|
374 | 415 | |
375 | 416 | $installed = $reg->packageInfo(null,null,$channel); |
376 | 417 | |
@@ -380,7 +421,10 @@ discard block |
||
380 | 421 | { |
381 | 422 | $name = isset($package['package']) ? $package['package'] : $package['name']; |
382 | 423 | $version = $package['version']; |
383 | - if (is_array($version)) $version = $version['release']; |
|
424 | + if (is_array($version)) |
|
425 | + { |
|
426 | + $version = $version['release']; |
|
427 | + } |
|
384 | 428 | |
385 | 429 | $packages[$name] = $version; |
386 | 430 | //echo "<p>$name: ".print_r($package['version'],true)."</p>\n"; |
@@ -419,7 +463,10 @@ discard block |
||
419 | 463 | { |
420 | 464 | $pear_available = $found = true; |
421 | 465 | // check if package is installed |
422 | - if ($package && isset($pear_packages[$package])) $available = true; |
|
466 | + if ($package && isset($pear_packages[$package])) |
|
467 | + { |
|
468 | + $available = true; |
|
469 | + } |
|
423 | 470 | // check if it's the right version |
424 | 471 | $version_available = $pear_packages[$package ? $package : 'PEAR']; |
425 | 472 | } |
@@ -429,7 +476,10 @@ discard block |
||
429 | 476 | { |
430 | 477 | $pear_available = @include_once('PEAR.php'); |
431 | 478 | |
432 | - if (!class_exists('PEAR')) $pear_available = false; |
|
479 | + if (!class_exists('PEAR')) |
|
480 | + { |
|
481 | + $pear_available = false; |
|
482 | + } |
|
433 | 483 | } |
434 | 484 | $found = $pear_available; |
435 | 485 | if ($pear_available && $package) |
@@ -438,7 +488,10 @@ discard block |
||
438 | 488 | |
439 | 489 | $found = @include_once($file); |
440 | 490 | |
441 | - if (!class_exists($package)) $found = false; |
|
491 | + if (!class_exists($package)) |
|
492 | + { |
|
493 | + $found = false; |
|
494 | + } |
|
442 | 495 | } |
443 | 496 | } |
444 | 497 | } |
@@ -449,10 +502,13 @@ discard block |
||
449 | 502 | ($available ? ($version_available ? $version_available : lang('True')) : |
450 | 503 | ($found ? lang('Found, but unknown version') : lang('False')))."</span></div>\n"; |
451 | 504 | |
452 | - if (!$available) // give further info only if not availible |
|
505 | + if (!$available) |
|
506 | + { |
|
507 | + // give further info only if not availible |
|
453 | 508 | { |
454 | 509 | echo '<div class="setup_info">' . lang('PEAR%1 is needed by: %2.',$package ? '::'.$package : '', |
455 | 510 | is_array($args['from']) ? implode(', ',$args['from']) : $args['from']); |
511 | + } |
|
456 | 512 | |
457 | 513 | // if using Composer, dont confuse user with PEAR ;-) |
458 | 514 | if (file_exists(EGW_SERVER_ROOT.'/vendor')) |
@@ -545,34 +601,55 @@ discard block |
||
545 | 601 | |
546 | 602 | function verbosePerms( $in_Perms ) |
547 | 603 | { |
548 | - if($in_Perms & 0x1000) // FIFO pipe |
|
604 | + if($in_Perms & 0x1000) |
|
605 | + { |
|
606 | + // FIFO pipe |
|
549 | 607 | { |
550 | 608 | $sP = 'p'; |
551 | 609 | } |
552 | - elseif($in_Perms & 0x2000) // Character special |
|
610 | + } |
|
611 | + elseif($in_Perms & 0x2000) |
|
612 | + { |
|
613 | + // Character special |
|
553 | 614 | { |
554 | 615 | $sP = 'c'; |
555 | 616 | } |
556 | - elseif($in_Perms & 0x4000) // Directory |
|
617 | + } |
|
618 | + elseif($in_Perms & 0x4000) |
|
619 | + { |
|
620 | + // Directory |
|
557 | 621 | { |
558 | 622 | $sP = 'd'; |
559 | 623 | } |
560 | - elseif($in_Perms & 0x6000) // Block special |
|
624 | + } |
|
625 | + elseif($in_Perms & 0x6000) |
|
626 | + { |
|
627 | + // Block special |
|
561 | 628 | { |
562 | 629 | $sP = 'b'; |
563 | 630 | } |
564 | - elseif($in_Perms & 0x8000) // Regular |
|
631 | + } |
|
632 | + elseif($in_Perms & 0x8000) |
|
633 | + { |
|
634 | + // Regular |
|
565 | 635 | { |
566 | 636 | $sP = '-'; |
567 | 637 | } |
568 | - elseif($in_Perms & 0xA000) // Symbolic Link |
|
638 | + } |
|
639 | + elseif($in_Perms & 0xA000) |
|
640 | + { |
|
641 | + // Symbolic Link |
|
569 | 642 | { |
570 | 643 | $sP = 'l'; |
571 | 644 | } |
572 | - elseif($in_Perms & 0xC000) // Socket |
|
645 | + } |
|
646 | + elseif($in_Perms & 0xC000) |
|
647 | + { |
|
648 | + // Socket |
|
573 | 649 | { |
574 | 650 | $sP = 's'; |
575 | 651 | } |
652 | + } |
|
576 | 653 | else // UNKNOWN |
577 | 654 | { |
578 | 655 | $sP = 'u'; |
@@ -713,9 +790,15 @@ discard block |
||
713 | 790 | $Ok = $Ok && permission_check(($name!='.'?$name.'/':'').$file,$args,False); |
714 | 791 | } |
715 | 792 | } |
716 | - if ($handle) closedir($handle); |
|
793 | + if ($handle) |
|
794 | + { |
|
795 | + closedir($handle); |
|
796 | + } |
|
797 | + } |
|
798 | + if ($verbose) |
|
799 | + { |
|
800 | + echo "\n"; |
|
717 | 801 | } |
718 | - if ($verbose) echo "\n"; |
|
719 | 802 | |
720 | 803 | return $Ok; |
721 | 804 | } |
@@ -723,7 +806,10 @@ discard block |
||
723 | 806 | function mk_value($value) |
724 | 807 | { |
725 | 808 | $matches = null; |
726 | - if (!preg_match('/^([0-9]+)([mk]+)$/i',$value,$matches)) return $value; |
|
809 | + if (!preg_match('/^([0-9]+)([mk]+)$/i',$value,$matches)) |
|
810 | + { |
|
811 | + return $value; |
|
812 | + } |
|
727 | 813 | |
728 | 814 | return (strtolower($matches[2]) == 'm' ? 1024*1024 : 1024) * (int) $matches[1]; |
729 | 815 | } |
@@ -852,7 +938,8 @@ discard block |
||
852 | 938 | 'T_footer' => 'footer.tpl', |
853 | 939 | )); |
854 | 940 | $ConfigDomain = $_REQUEST['ConfigDomain']; |
855 | - if (@$_GET['intro']) { |
|
941 | + if (@$_GET['intro']) |
|
942 | + { |
|
856 | 943 | if(($ConfigLang = setup::get_lang())) |
857 | 944 | { |
858 | 945 | $GLOBALS['egw_setup']->set_cookie('ConfigLang',$ConfigLang,(int) (time()+(1200*9)),'/'); |
@@ -869,7 +956,9 @@ discard block |
||
869 | 956 | echo '<p><a href="manageheader.php">'.lang('Skip the installation tests (not recommended)')."</a></p>\n"; |
870 | 957 | $setup_tpl->pparse('out','T_footer'); |
871 | 958 | exit; |
872 | - } else { |
|
959 | + } |
|
960 | + else |
|
961 | + { |
|
873 | 962 | $GLOBALS['egw_setup']->html->show_header(lang('Checking the EGroupware Installation'),False,'config',$ConfigDomain ? $ConfigDomain . '(' . @$GLOBALS['egw_domain'][$ConfigDomain]['db_type'] . ')' : ''); |
874 | 963 | echo '<h1>'.lang('Checking the EGroupware Installation')."</h1>\n"; |
875 | 964 | # echo "<pre style=\"text-align: left;\">\n";; |
@@ -741,8 +741,8 @@ discard block |
||
741 | 741 | /** |
742 | 742 | * egw version checking, is param 1 < param 2 in phpgw versionspeak? |
743 | 743 | * @param $a phpgw version number to check if less than $b |
744 | - * @param $b phpgw version number to check $a against |
|
745 | - * @return True if $a < $b |
|
744 | + * @param string $b phpgw version number to check $a against |
|
745 | + * @return boolean if $a < $b |
|
746 | 746 | */ |
747 | 747 | function alessthanb($a,$b,$DEBUG=False) |
748 | 748 | { |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | * |
830 | 830 | * @param $a phpgw version number to check if more than $b |
831 | 831 | * @param $b phpgw version number to check $a against |
832 | - * @return True if $a < $b |
|
832 | + * @return boolean if $a < $b |
|
833 | 833 | */ |
834 | 834 | function amorethanb($a,$b,$DEBUG=False) |
835 | 835 | { |
@@ -1101,7 +1101,7 @@ discard block |
||
1101 | 1101 | * |
1102 | 1102 | * Dont use it to set group-membership, use set_memberships instead! |
1103 | 1103 | * |
1104 | - * @param string|array $apps app-names |
|
1104 | + * @param string $apps app-names |
|
1105 | 1105 | * @param string $location eg. "run" |
1106 | 1106 | * @param int|string $account accountid or account_lid |
1107 | 1107 | * @param int $rights rights to set, default 1 |
@@ -1147,7 +1147,7 @@ discard block |
||
1147 | 1147 | /** |
1148 | 1148 | * checks if one of the given tables exist, returns the first match |
1149 | 1149 | * |
1150 | - * @param array $tables array with possible table-names |
|
1150 | + * @param string[] $tables array with possible table-names |
|
1151 | 1151 | * @return string/boolean tablename or false |
1152 | 1152 | */ |
1153 | 1153 | function table_exist($tables,$force_refresh=False) |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
154 | - * Set the domain used for cookies |
|
155 | - * |
|
156 | - * @return string domain |
|
157 | - */ |
|
154 | + * Set the domain used for cookies |
|
155 | + * |
|
156 | + * @return string domain |
|
157 | + */ |
|
158 | 158 | static function cookiedomain() |
159 | 159 | { |
160 | 160 | // Use HTTP_X_FORWARDED_HOST if set, which is the case behind a none-transparent proxy |
@@ -175,12 +175,12 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
178 | - * Set a cookie |
|
179 | - * |
|
180 | - * @param string $cookiename name of cookie to be set |
|
181 | - * @param string $cookievalue value to be used, if unset cookie is cleared (optional) |
|
182 | - * @param int $cookietime when cookie should expire, 0 for session only (optional) |
|
183 | - */ |
|
178 | + * Set a cookie |
|
179 | + * |
|
180 | + * @param string $cookiename name of cookie to be set |
|
181 | + * @param string $cookievalue value to be used, if unset cookie is cleared (optional) |
|
182 | + * @param int $cookietime when cookie should expire, 0 for session only (optional) |
|
183 | + */ |
|
184 | 184 | function set_cookie($cookiename,$cookievalue='',$cookietime=0) |
185 | 185 | { |
186 | 186 | if(!isset($this->cookie_domain)) |
@@ -344,19 +344,19 @@ discard block |
||
344 | 344 | return true; |
345 | 345 | } |
346 | 346 | |
347 | - /** |
|
348 | - * check if username and password is valid |
|
349 | - * |
|
350 | - * this function compares the supplied and stored username and password |
|
351 | - * as any of the passwords can be clear text or md5 we convert them to md5 |
|
352 | - * internal and compare always the md5 hashs |
|
353 | - * |
|
354 | - * @param string $user the user supplied username |
|
355 | - * @param string $pw the user supplied password |
|
356 | - * @param string $conf_user the configured username |
|
357 | - * @param string $hash hash to check password agains (no {prefix} for plain and md5!) |
|
358 | - * @returns bool true on success |
|
359 | - */ |
|
347 | + /** |
|
348 | + * check if username and password is valid |
|
349 | + * |
|
350 | + * this function compares the supplied and stored username and password |
|
351 | + * as any of the passwords can be clear text or md5 we convert them to md5 |
|
352 | + * internal and compare always the md5 hashs |
|
353 | + * |
|
354 | + * @param string $user the user supplied username |
|
355 | + * @param string $pw the user supplied password |
|
356 | + * @param string $conf_user the configured username |
|
357 | + * @param string $hash hash to check password agains (no {prefix} for plain and md5!) |
|
358 | + * @returns bool true on success |
|
359 | + */ |
|
360 | 360 | static function check_auth($user, $pw, $conf_user, $hash) |
361 | 361 | { |
362 | 362 | if ($user !== $conf_user) |
@@ -728,10 +728,10 @@ discard block |
||
728 | 728 | } |
729 | 729 | |
730 | 730 | /** |
731 | - * call the hooks for a single application |
|
732 | - * |
|
733 | - * @param $location hook location - required |
|
734 | - * @param $appname application name - optional |
|
731 | + * call the hooks for a single application |
|
732 | + * |
|
733 | + * @param $location hook location - required |
|
734 | + * @param $appname application name - optional |
|
735 | 735 | */ |
736 | 736 | static function hook($location, $appname='') |
737 | 737 | { |
@@ -85,11 +85,20 @@ discard block |
||
85 | 85 | $this->detection = new setup_detection(); |
86 | 86 | $this->process = new setup_process(); |
87 | 87 | |
88 | - if (preg_match('/^[a-z0-9-]+$/i', $_REQUEST['system_charset'])) $this->system_charset = $_REQUEST['system_charset']; |
|
88 | + if (preg_match('/^[a-z0-9-]+$/i', $_REQUEST['system_charset'])) |
|
89 | + { |
|
90 | + $this->system_charset = $_REQUEST['system_charset']; |
|
91 | + } |
|
89 | 92 | |
90 | 93 | /* The setup application needs these */ |
91 | - if ($html) $this->html = new setup_html(); |
|
92 | - if ($translation) $this->translation = new setup_translation(); |
|
94 | + if ($html) |
|
95 | + { |
|
96 | + $this->html = new setup_html(); |
|
97 | + } |
|
98 | + if ($translation) |
|
99 | + { |
|
100 | + $this->translation = new setup_translation(); |
|
101 | + } |
|
93 | 102 | } |
94 | 103 | |
95 | 104 | /** |
@@ -132,12 +141,15 @@ discard block |
||
132 | 141 | $this->db_charset_was = $this->db->Link_ID->GetCharSet(); // needed for the update |
133 | 142 | |
134 | 143 | // we can NOT set the DB charset for mysql, if the api version < 1.0.1.019, as it would mess up the DB content!!! |
135 | - if (substr($this->db->Type,0,5) == 'mysql') // we need to check the api version |
|
144 | + if (substr($this->db->Type,0,5) == 'mysql') |
|
145 | + { |
|
146 | + // we need to check the api version |
|
136 | 147 | { |
137 | 148 | $api_version = $this->db->select($this->applications_table,'app_version',array( |
138 | 149 | 'app_name' => 'phpgwapi', |
139 | 150 | ),__LINE__,__FILE__)->fetchColumn(); |
140 | 151 | } |
152 | + } |
|
141 | 153 | if (!$api_version || !$this->alessthanb($api_version,'1.0.1.019')) |
142 | 154 | { |
143 | 155 | $this->db->Link_ID->SetCharSet($this->system_charset); |
@@ -206,7 +218,10 @@ discard block |
||
206 | 218 | } |
207 | 219 | else |
208 | 220 | { |
209 | - if (!isset($_SESSION)) self::session_start(); |
|
221 | + if (!isset($_SESSION)) |
|
222 | + { |
|
223 | + self::session_start(); |
|
224 | + } |
|
210 | 225 | $ConfigLang = $_SESSION['ConfigLang']; |
211 | 226 | } |
212 | 227 | $matches = null; |
@@ -260,7 +275,10 @@ discard block |
||
260 | 275 | // if called via HTTPS, only send cookie for https and only allow cookie access via HTTP (true) |
261 | 276 | !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off', true); |
262 | 277 | |
263 | - if (isset($_COOKIE[self::SESSIONID])) session_id($_COOKIE[self::SESSIONID]); |
|
278 | + if (isset($_COOKIE[self::SESSIONID])) |
|
279 | + { |
|
280 | + session_id($_COOKIE[self::SESSIONID]); |
|
281 | + } |
|
264 | 282 | |
265 | 283 | $ok = @session_start(); // suppress notice if session already started or warning in CLI |
266 | 284 | break; |
@@ -478,7 +496,10 @@ discard block |
||
478 | 496 | */ |
479 | 497 | function register_app($appname, $_enable=99, array $setup_info=null) |
480 | 498 | { |
481 | - if (!isset($setup_info)) $setup_info = $GLOBALS['setup_info']; |
|
499 | + if (!isset($setup_info)) |
|
500 | + { |
|
501 | + $setup_info = $GLOBALS['setup_info']; |
|
502 | + } |
|
482 | 503 | |
483 | 504 | if(!$appname) |
484 | 505 | { |
@@ -572,7 +593,10 @@ discard block |
||
572 | 593 | */ |
573 | 594 | function update_app($appname, array $setup_info=null) |
574 | 595 | { |
575 | - if (!isset($setup_info)) $setup_info = $GLOBALS['setup_info']; |
|
596 | + if (!isset($setup_info)) |
|
597 | + { |
|
598 | + $setup_info = $GLOBALS['setup_info']; |
|
599 | + } |
|
576 | 600 | |
577 | 601 | if(!$appname) |
578 | 602 | { |
@@ -724,7 +748,10 @@ discard block |
||
724 | 748 | { |
725 | 749 | $GLOBALS['settings'] = array(); |
726 | 750 | include_once($file); |
727 | - if ($GLOBALS['settings']) $settings = array_merge($settings,$GLOBALS['settings']); |
|
751 | + if ($GLOBALS['settings']) |
|
752 | + { |
|
753 | + $settings = array_merge($settings,$GLOBALS['settings']); |
|
754 | + } |
|
728 | 755 | } |
729 | 756 | $default = $forced = array(); |
730 | 757 | foreach($settings as $name => $setting) |
@@ -806,52 +833,72 @@ discard block |
||
806 | 833 | |
807 | 834 | for($i=0;$i<count($testa);$i++) |
808 | 835 | { |
809 | - if($DEBUG) { echo'<br>Checking if '. (int)$testa[$i] . ' is less than ' . (int)$testb[$i] . ' ...'; } |
|
836 | + if($DEBUG) |
|
837 | + { |
|
838 | +echo'<br>Checking if '. (int)$testa[$i] . ' is less than ' . (int)$testb[$i] . ' ...'; } |
|
810 | 839 | if((int)$testa[$i] < (int)$testb[$i]) |
811 | 840 | { |
812 | - if ($DEBUG) { echo ' yes.'; } |
|
841 | + if ($DEBUG) |
|
842 | + { |
|
843 | +echo ' yes.'; } |
|
813 | 844 | $less++; |
814 | 845 | if($i<3) |
815 | 846 | { |
816 | 847 | /* Ensure that this is definitely smaller */ |
817 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
848 | + if($DEBUG) |
|
849 | + { |
|
850 | +echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
818 | 851 | $less = 5; |
819 | 852 | break; |
820 | 853 | } |
821 | 854 | } |
822 | 855 | elseif((int)$testa[$i] > (int)$testb[$i]) |
823 | 856 | { |
824 | - if($DEBUG) { echo ' no.'; } |
|
857 | + if($DEBUG) |
|
858 | + { |
|
859 | +echo ' no.'; } |
|
825 | 860 | $less--; |
826 | 861 | if($i<2) |
827 | 862 | { |
828 | 863 | /* Ensure that this is definitely greater */ |
829 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
864 | + if($DEBUG) |
|
865 | + { |
|
866 | +echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
830 | 867 | $less = -5; |
831 | 868 | break; |
832 | 869 | } |
833 | 870 | } |
834 | 871 | else |
835 | 872 | { |
836 | - if($DEBUG) { echo ' no, they are equal or of different length.'; } |
|
873 | + if($DEBUG) |
|
874 | + { |
|
875 | +echo ' no, they are equal or of different length.'; } |
|
837 | 876 | // makes sure eg. '1.0.0' is counted less the '1.0.0.xxx' ! |
838 | 877 | $less = count($testa) < count($testb) ? 1 : 0; |
839 | 878 | } |
840 | 879 | } |
841 | - if($DEBUG) { echo '<br>Check value is: "'.$less.'"'; } |
|
880 | + if($DEBUG) |
|
881 | + { |
|
882 | +echo '<br>Check value is: "'.$less.'"'; } |
|
842 | 883 | if($less>0) |
843 | 884 | { |
844 | - if($DEBUG) { echo '<br>A is less than B'; } |
|
885 | + if($DEBUG) |
|
886 | + { |
|
887 | +echo '<br>A is less than B'; } |
|
845 | 888 | return True; |
846 | 889 | } |
847 | 890 | elseif($less<0) |
848 | 891 | { |
849 | - if($DEBUG) { echo '<br>A is greater than B'; } |
|
892 | + if($DEBUG) |
|
893 | + { |
|
894 | +echo '<br>A is greater than B'; } |
|
850 | 895 | return False; |
851 | 896 | } |
852 | 897 | else |
853 | 898 | { |
854 | - if($DEBUG) { echo '<br>A is equal to B'; } |
|
899 | + if($DEBUG) |
|
900 | + { |
|
901 | +echo '<br>A is equal to B'; } |
|
855 | 902 | return False; |
856 | 903 | } |
857 | 904 | } |
@@ -888,51 +935,71 @@ discard block |
||
888 | 935 | |
889 | 936 | for($i=0;$i<count($testa);$i++) |
890 | 937 | { |
891 | - if($DEBUG) { echo'<br>Checking if '. (int)$testa[$i] . ' is more than ' . (int)$testb[$i] . ' ...'; } |
|
938 | + if($DEBUG) |
|
939 | + { |
|
940 | +echo'<br>Checking if '. (int)$testa[$i] . ' is more than ' . (int)$testb[$i] . ' ...'; } |
|
892 | 941 | if((int)$testa[$i] > (int)$testb[$i]) |
893 | 942 | { |
894 | - if($DEBUG) { echo ' yes.'; } |
|
943 | + if($DEBUG) |
|
944 | + { |
|
945 | +echo ' yes.'; } |
|
895 | 946 | $less++; |
896 | 947 | if($i<3) |
897 | 948 | { |
898 | 949 | /* Ensure that this is definitely greater */ |
899 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
950 | + if($DEBUG) |
|
951 | + { |
|
952 | +echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
900 | 953 | $less = 5; |
901 | 954 | break; |
902 | 955 | } |
903 | 956 | } |
904 | 957 | elseif((int)$testa[$i] < (int)$testb[$i]) |
905 | 958 | { |
906 | - if($DEBUG) { echo ' no.'; } |
|
959 | + if($DEBUG) |
|
960 | + { |
|
961 | +echo ' no.'; } |
|
907 | 962 | $less--; |
908 | 963 | if($i<2) |
909 | 964 | { |
910 | 965 | /* Ensure that this is definitely smaller */ |
911 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
966 | + if($DEBUG) |
|
967 | + { |
|
968 | +echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
912 | 969 | $less = -5; |
913 | 970 | break; |
914 | 971 | } |
915 | 972 | } |
916 | 973 | else |
917 | 974 | { |
918 | - if($DEBUG) { echo ' no, they are equal.'; } |
|
975 | + if($DEBUG) |
|
976 | + { |
|
977 | +echo ' no, they are equal.'; } |
|
919 | 978 | $less = 0; |
920 | 979 | } |
921 | 980 | } |
922 | - if($DEBUG) { echo '<br>Check value is: "'.$less.'"'; } |
|
981 | + if($DEBUG) |
|
982 | + { |
|
983 | +echo '<br>Check value is: "'.$less.'"'; } |
|
923 | 984 | if($less>0) |
924 | 985 | { |
925 | - if($DEBUG) { echo '<br>A is greater than B'; } |
|
986 | + if($DEBUG) |
|
987 | + { |
|
988 | +echo '<br>A is greater than B'; } |
|
926 | 989 | return True; |
927 | 990 | } |
928 | 991 | elseif($less<0) |
929 | 992 | { |
930 | - if($DEBUG) { echo '<br>A is less than B'; } |
|
993 | + if($DEBUG) |
|
994 | + { |
|
995 | +echo '<br>A is less than B'; } |
|
931 | 996 | return False; |
932 | 997 | } |
933 | 998 | else |
934 | 999 | { |
935 | - if($DEBUG) { echo '<br>A is equal to B'; } |
|
1000 | + if($DEBUG) |
|
1001 | + { |
|
1002 | +echo '<br>A is equal to B'; } |
|
936 | 1003 | return False; |
937 | 1004 | } |
938 | 1005 | } |
@@ -969,7 +1036,10 @@ discard block |
||
969 | 1036 | echo "<p><b>".$e->getMessage()."</b></p>\n"; |
970 | 1037 | return false; |
971 | 1038 | } |
972 | - if (!isset($GLOBALS['egw']->accounts)) $GLOBALS['egw']->accounts = $this->accounts; |
|
1039 | + if (!isset($GLOBALS['egw']->accounts)) |
|
1040 | + { |
|
1041 | + $GLOBALS['egw']->accounts = $this->accounts; |
|
1042 | + } |
|
973 | 1043 | Api\Accounts::cache_invalidate(); // the cache is shared for all instances of the class |
974 | 1044 | } |
975 | 1045 | return true; |
@@ -1006,7 +1076,10 @@ discard block |
||
1006 | 1076 | $passwd = $_passwd; |
1007 | 1077 | if ($username == 'anonymous') |
1008 | 1078 | { |
1009 | - if (!isset($this->anonpw)) $this->anonpw = Api\Auth::randomstring(16); |
|
1079 | + if (!isset($this->anonpw)) |
|
1080 | + { |
|
1081 | + $this->anonpw = Api\Auth::randomstring(16); |
|
1082 | + } |
|
1010 | 1083 | $passwd = $anonpw = $this->anonpw; |
1011 | 1084 | } |
1012 | 1085 | |
@@ -1065,11 +1138,17 @@ discard block |
||
1065 | 1138 | 'account_lid' => $username, |
1066 | 1139 | )); |
1067 | 1140 | } |
1068 | - if ($primary_group) // only for users, NOT groups |
|
1141 | + if ($primary_group) |
|
1142 | + { |
|
1143 | + // only for users, NOT groups |
|
1069 | 1144 | { |
1070 | 1145 | $this->set_memberships(array($primary_group_id), $accountid); |
1146 | + } |
|
1071 | 1147 | |
1072 | - if (!$changepw) $this->add_acl('preferences','nopasswordchange',$accountid); |
|
1148 | + if (!$changepw) |
|
1149 | + { |
|
1150 | + $this->add_acl('preferences','nopasswordchange',$accountid); |
|
1151 | + } |
|
1073 | 1152 | } |
1074 | 1153 | //error_log("setup::add_account('$username','$first','$last',\$passwd,'$primary_group',$changepw,'$email') successfull created accountid=$accountid"); |
1075 | 1154 | return $accountid; |
@@ -1106,7 +1185,10 @@ discard block |
||
1106 | 1185 | function accounts_exist() |
1107 | 1186 | { |
1108 | 1187 | try { |
1109 | - if (!$this->setup_account_object()) return false; |
|
1188 | + if (!$this->setup_account_object()) |
|
1189 | + { |
|
1190 | + return false; |
|
1191 | + } |
|
1110 | 1192 | |
1111 | 1193 | $this->accounts->search(array( |
1112 | 1194 | 'type' => 'accounts', |
@@ -1193,9 +1275,15 @@ discard block |
||
1193 | 1275 | { |
1194 | 1276 | static $table_names = False; |
1195 | 1277 | |
1196 | - if (!$table_names || $force_refresh) $table_names = $this->db->table_names(); |
|
1278 | + if (!$table_names || $force_refresh) |
|
1279 | + { |
|
1280 | + $table_names = $this->db->table_names(); |
|
1281 | + } |
|
1197 | 1282 | |
1198 | - if (!$table_names) return false; |
|
1283 | + if (!$table_names) |
|
1284 | + { |
|
1285 | + return false; |
|
1286 | + } |
|
1199 | 1287 | |
1200 | 1288 | foreach($table_names as $data) |
1201 | 1289 | { |
@@ -1225,10 +1313,13 @@ discard block |
||
1225 | 1313 | { |
1226 | 1314 | $table = $this->table_exist($tables,$force_refresh); |
1227 | 1315 | |
1228 | - if ($table && $table != $this->$name) // only overwrite the default name, if we realy got one (important for new installs) |
|
1316 | + if ($table && $table != $this->$name) |
|
1317 | + { |
|
1318 | + // only overwrite the default name, if we realy got one (important for new installs) |
|
1229 | 1319 | { |
1230 | 1320 | $this->$name = $table; |
1231 | 1321 | } |
1322 | + } |
|
1232 | 1323 | //echo "<p>setup::set_table_names: $name = '{$this->$name}'</p>\n"; |
1233 | 1324 | } |
1234 | 1325 | } |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | */ |
73 | 73 | var $recommended_php_version = '7.0'; |
74 | 74 | |
75 | - function __construct($html=False, $translation=False) |
|
75 | + function __construct($html = False, $translation = False) |
|
76 | 76 | { |
77 | 77 | // setup us as $GLOBALS['egw_setup'], as this gets used in our sub-objects |
78 | - $GLOBALS['egw_setup'] =& $this; |
|
78 | + $GLOBALS['egw_setup'] = & $this; |
|
79 | 79 | |
80 | 80 | if (!is_object($GLOBALS['egw'])) |
81 | 81 | { |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | /** |
95 | 95 | * include api db class for the ConfigDomain and connect to the db |
96 | 96 | */ |
97 | - function loaddb($connect_and_setcharset=true) |
|
97 | + function loaddb($connect_and_setcharset = true) |
|
98 | 98 | { |
99 | - if(!isset($this->ConfigDomain) || empty($this->ConfigDomain)) |
|
99 | + if (!isset($this->ConfigDomain) || empty($this->ConfigDomain)) |
|
100 | 100 | { |
101 | 101 | $this->ConfigDomain = isset($_REQUEST['ConfigDomain']) ? $_REQUEST['ConfigDomain'] : $_POST['FormDomain']; |
102 | 102 | } |
@@ -120,24 +120,24 @@ discard block |
||
120 | 120 | if ($connect_and_setcharset) |
121 | 121 | { |
122 | 122 | try { |
123 | - $this->set_table_names(); // sets/checks config- and applications-table-name |
|
123 | + $this->set_table_names(); // sets/checks config- and applications-table-name |
|
124 | 124 | |
125 | 125 | // Set the DB's client charset if a system-charset is set |
126 | - if (($this->system_charset = $this->db->select($this->config_table,'config_value',array( |
|
126 | + if (($this->system_charset = $this->db->select($this->config_table, 'config_value', array( |
|
127 | 127 | 'config_app' => 'phpgwapi', |
128 | 128 | 'config_name' => 'system_charset', |
129 | - ),__LINE__,__FILE__)->fetchColumn())) |
|
129 | + ), __LINE__, __FILE__)->fetchColumn())) |
|
130 | 130 | { |
131 | - $this->db_charset_was = $this->db->Link_ID->GetCharSet(); // needed for the update |
|
131 | + $this->db_charset_was = $this->db->Link_ID->GetCharSet(); // needed for the update |
|
132 | 132 | |
133 | 133 | // we can NOT set the DB charset for mysql, if the api version < 1.0.1.019, as it would mess up the DB content!!! |
134 | - if (substr($this->db->Type,0,5) == 'mysql') // we need to check the api version |
|
134 | + if (substr($this->db->Type, 0, 5) == 'mysql') // we need to check the api version |
|
135 | 135 | { |
136 | - $api_version = $this->db->select($this->applications_table,'app_version',array( |
|
136 | + $api_version = $this->db->select($this->applications_table, 'app_version', array( |
|
137 | 137 | 'app_name' => 'phpgwapi', |
138 | - ),__LINE__,__FILE__)->fetchColumn(); |
|
138 | + ), __LINE__, __FILE__)->fetchColumn(); |
|
139 | 139 | } |
140 | - if (!$api_version || !$this->alessthanb($api_version,'1.0.1.019')) |
|
140 | + if (!$api_version || !$this->alessthanb($api_version, '1.0.1.019')) |
|
141 | 141 | { |
142 | 142 | $this->db->Link_ID->SetCharSet($this->system_charset); |
143 | 143 | } |
@@ -157,15 +157,15 @@ discard block |
||
157 | 157 | static function cookiedomain() |
158 | 158 | { |
159 | 159 | // Use HTTP_X_FORWARDED_HOST if set, which is the case behind a none-transparent proxy |
160 | - $cookie_domain = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']; |
|
160 | + $cookie_domain = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']; |
|
161 | 161 | |
162 | 162 | // remove port from HTTP_HOST |
163 | 163 | $arr = null; |
164 | - if (preg_match("/^(.*):(.*)$/",$cookie_domain,$arr)) |
|
164 | + if (preg_match("/^(.*):(.*)$/", $cookie_domain, $arr)) |
|
165 | 165 | { |
166 | 166 | $cookie_domain = $arr[1]; |
167 | 167 | } |
168 | - if (count(explode('.',$cookie_domain)) <= 1) |
|
168 | + if (count(explode('.', $cookie_domain)) <= 1) |
|
169 | 169 | { |
170 | 170 | // setcookie dont likes domains without dots, leaving it empty, gets setcookie to fill the domain in |
171 | 171 | $cookie_domain = ''; |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | * @param string $cookievalue value to be used, if unset cookie is cleared (optional) |
181 | 181 | * @param int $cookietime when cookie should expire, 0 for session only (optional) |
182 | 182 | */ |
183 | - function set_cookie($cookiename,$cookievalue='',$cookietime=0) |
|
183 | + function set_cookie($cookiename, $cookievalue = '', $cookietime = 0) |
|
184 | 184 | { |
185 | - if(!isset($this->cookie_domain)) |
|
185 | + if (!isset($this->cookie_domain)) |
|
186 | 186 | { |
187 | 187 | $this->cookie_domain = self::cookiedomain(); |
188 | 188 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * @param boolean $use_accept_language =false true: use Accept-Language header as fallback |
198 | 198 | * @return string |
199 | 199 | */ |
200 | - static function get_lang($use_accept_language=false) |
|
200 | + static function get_lang($use_accept_language = false) |
|
201 | 201 | { |
202 | 202 | if (isset($_POST['ConfigLang'])) |
203 | 203 | { |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | preg_match_all('/(^|,)([a-z-]+)/', strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']), $matches)) |
214 | 214 | { |
215 | 215 | $available = Api\Translation::get_available_langs(false); |
216 | - foreach($matches[2] as $lang) |
|
216 | + foreach ($matches[2] as $lang) |
|
217 | 217 | { |
218 | 218 | if (isset($available[$lang])) |
219 | 219 | { |
@@ -222,9 +222,9 @@ discard block |
||
222 | 222 | } |
223 | 223 | } |
224 | 224 | } |
225 | - if (!preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$ConfigLang)) |
|
225 | + if (!preg_match('/^[a-z]{2}(-[a-z]{2})?$/', $ConfigLang)) |
|
226 | 226 | { |
227 | - $ConfigLang = null; // not returning 'en', as it suppresses the language selection in check_install and manageheader |
|
227 | + $ConfigLang = null; // not returning 'en', as it suppresses the language selection in check_install and manageheader |
|
228 | 228 | } |
229 | 229 | //error_log(__METHOD__."() \$_POST['ConfigLang']=".array2string($_POST['ConfigLang']).", \$_SESSION['ConfigLang']=".array2string($_SESSION['ConfigLang']).", HTTP_ACCEPT_LANGUAGE=$_SERVER[HTTP_ACCEPT_LANGUAGE] --> returning ".array2string($ConfigLang)); |
230 | 230 | return $ConfigLang; |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | // make sure we have session extension available, otherwise fail with exception that we need it |
249 | 249 | check_load_extension('session', true); |
250 | 250 | |
251 | - switch(session_status()) |
|
251 | + switch (session_status()) |
|
252 | 252 | { |
253 | 253 | case PHP_SESSION_DISABLED: |
254 | 254 | throw new \ErrorException('EGroupware requires PHP session extension!'); |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | |
262 | 262 | if (isset($_COOKIE[self::SESSIONID])) session_id($_COOKIE[self::SESSIONID]); |
263 | 263 | |
264 | - $ok = @session_start(); // suppress notice if session already started or warning in CLI |
|
264 | + $ok = @session_start(); // suppress notice if session already started or warning in CLI |
|
265 | 265 | break; |
266 | 266 | case PHP_SESSION_ACTIVE: |
267 | 267 | $ok = true; |
@@ -277,12 +277,12 @@ discard block |
||
277 | 277 | * |
278 | 278 | * @param string $_auth_type ='config' 'config' or 'header' (caseinsensitiv) |
279 | 279 | */ |
280 | - function auth($_auth_type='config') |
|
280 | + function auth($_auth_type = 'config') |
|
281 | 281 | { |
282 | 282 | $auth_type = strtolower($_auth_type); |
283 | 283 | $GLOBALS['egw_info']['setup']['HeaderLoginMSG'] = $GLOBALS['egw_info']['setup']['ConfigLoginMSG'] = ''; |
284 | 284 | |
285 | - if(!$this->checkip(isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? |
|
285 | + if (!$this->checkip(isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? |
|
286 | 286 | $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'])) |
287 | 287 | { |
288 | 288 | //error_log(__METHOD__."('$auth_type') invalid IP"); |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | //error_log(__METHOD__."('$auth_type') \$_COOKIE['".self::SESSIONID."'] = ".array2string($_COOKIE[self::SESSIONID]).", \$_SESSION=".array2string($_SESSION).", \$_POST=".array2string($_POST)); |
296 | 296 | if (isset($_REQUEST['FormLogout'])) |
297 | 297 | { |
298 | - $this->set_cookie(self::SESSIONID, '', time()-86400); |
|
298 | + $this->set_cookie(self::SESSIONID, '', time() - 86400); |
|
299 | 299 | session_destroy(); |
300 | 300 | if ($_REQUEST['FormLogout'] == 'config') |
301 | 301 | { |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | { |
312 | 312 | return false; |
313 | 313 | } |
314 | - switch($auth_type) |
|
314 | + switch ($auth_type) |
|
315 | 315 | { |
316 | 316 | case 'config': |
317 | 317 | if (!isset($GLOBALS['egw_domain'][$_POST['FormDomain']]) || |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | //error_log(__METHOD__."('$auth_type') \$_COOKIE['".self::SESSIONID."'] = ".array2string($_COOKIE[self::SESSIONID]).", \$_SESSION=".array2string($_SESSION)); |
352 | 352 | if ($_SESSION['egw_last_action_time'] < time() - self::TIMEOUT) |
353 | 353 | { |
354 | - $this->set_cookie(self::SESSIONID, '', time()-86400); |
|
354 | + $this->set_cookie(self::SESSIONID, '', time() - 86400); |
|
355 | 355 | session_destroy(); |
356 | 356 | $GLOBALS['egw_info']['setup'][$_SESSION['egw_setup_auth_type'] == 'config' ? 'ConfigLoginMSG' : 'HeaderLoginMSG'] = |
357 | 357 | lang('Session expired'); |
@@ -406,37 +406,37 @@ discard block |
||
406 | 406 | * @param string $remoteip |
407 | 407 | * @return boolean |
408 | 408 | */ |
409 | - function checkip($remoteip='') |
|
409 | + function checkip($remoteip = '') |
|
410 | 410 | { |
411 | 411 | //echo "<p>setup::checkip($remoteip) against setup_acl='".$GLOBALS['egw_info']['server']['setup_acl']."'</p>\n"; |
412 | - $allowed_ips = explode(',',@$GLOBALS['egw_info']['server']['setup_acl']); |
|
413 | - if(empty($GLOBALS['egw_info']['server']['setup_acl']) || !is_array($allowed_ips)) |
|
412 | + $allowed_ips = explode(',', @$GLOBALS['egw_info']['server']['setup_acl']); |
|
413 | + if (empty($GLOBALS['egw_info']['server']['setup_acl']) || !is_array($allowed_ips)) |
|
414 | 414 | { |
415 | - return True; // no test |
|
415 | + return True; // no test |
|
416 | 416 | } |
417 | - $remotes = explode('.',$remoteip); |
|
418 | - foreach($allowed_ips as $value) |
|
417 | + $remotes = explode('.', $remoteip); |
|
418 | + foreach ($allowed_ips as $value) |
|
419 | 419 | { |
420 | - if (!preg_match('/^[0-9.]+$/',$value)) |
|
420 | + if (!preg_match('/^[0-9.]+$/', $value)) |
|
421 | 421 | { |
422 | - $value = gethostbyname($was=$value); // resolve domain-name, eg. a dyndns account |
|
422 | + $value = gethostbyname($was = $value); // resolve domain-name, eg. a dyndns account |
|
423 | 423 | //echo "resolving '$was' to '$value'<br>\n"; |
424 | 424 | } |
425 | - $values = explode('.',$value); |
|
426 | - for($i = 0; $i < count($values); ++$i) |
|
425 | + $values = explode('.', $value); |
|
426 | + for ($i = 0; $i < count($values); ++$i) |
|
427 | 427 | { |
428 | - if ((int) $values[$i] != (int) $remotes[$i]) |
|
428 | + if ((int)$values[$i] != (int)$remotes[$i]) |
|
429 | 429 | { |
430 | 430 | break; |
431 | 431 | } |
432 | 432 | } |
433 | 433 | if ($i == count($values)) |
434 | 434 | { |
435 | - return True; // match |
|
435 | + return True; // match |
|
436 | 436 | } |
437 | 437 | } |
438 | 438 | $GLOBALS['egw_info']['setup']['ConfigLoginMSG'] = lang('Invalid IP address').' '.$remoteip; |
439 | - error_log(__METHOD__.'-> checking IP failed:'.print_r($remoteip,true)); |
|
439 | + error_log(__METHOD__.'-> checking IP failed:'.print_r($remoteip, true)); |
|
440 | 440 | return False; |
441 | 441 | } |
442 | 442 | |
@@ -447,14 +447,14 @@ discard block |
||
447 | 447 | */ |
448 | 448 | function get_major($versionstring) |
449 | 449 | { |
450 | - if(!$versionstring) |
|
450 | + if (!$versionstring) |
|
451 | 451 | { |
452 | 452 | return False; |
453 | 453 | } |
454 | 454 | |
455 | - $version = str_replace('pre','.',$versionstring); |
|
456 | - $varray = explode('.',$version); |
|
457 | - $major = implode('.',array($varray[0],$varray[1],$varray[2])); |
|
455 | + $version = str_replace('pre', '.', $versionstring); |
|
456 | + $varray = explode('.', $version); |
|
457 | + $major = implode('.', array($varray[0], $varray[1], $varray[2])); |
|
458 | 458 | |
459 | 459 | return $major; |
460 | 460 | } |
@@ -475,69 +475,69 @@ discard block |
||
475 | 475 | * @param $_enable =99 set to True/False to override setup.inc.php setting |
476 | 476 | * @param array $setup_info =null default use $GLOBALS['setup_info'] |
477 | 477 | */ |
478 | - function register_app($appname, $_enable=99, array $setup_info=null) |
|
478 | + function register_app($appname, $_enable = 99, array $setup_info = null) |
|
479 | 479 | { |
480 | 480 | if (!isset($setup_info)) $setup_info = $GLOBALS['setup_info']; |
481 | 481 | |
482 | - if(!$appname) |
|
482 | + if (!$appname) |
|
483 | 483 | { |
484 | 484 | return False; |
485 | 485 | } |
486 | 486 | |
487 | - if($_enable == 99) |
|
487 | + if ($_enable == 99) |
|
488 | 488 | { |
489 | 489 | $_enable = $setup_info[$appname]['enable']; |
490 | 490 | } |
491 | 491 | $enable = (int)$_enable; |
492 | 492 | |
493 | - if($GLOBALS['DEBUG']) |
|
493 | + if ($GLOBALS['DEBUG']) |
|
494 | 494 | { |
495 | - echo '<br>register_app(): ' . $appname . ', version: ' . $setup_info[$appname]['version'] . ', tables: ' . implode(', ',$setup_info[$appname]['tables']) . '<br>'; |
|
495 | + echo '<br>register_app(): '.$appname.', version: '.$setup_info[$appname]['version'].', tables: '.implode(', ', $setup_info[$appname]['tables']).'<br>'; |
|
496 | 496 | // _debug_array($setup_info[$appname]); |
497 | 497 | } |
498 | 498 | |
499 | - if($setup_info[$appname]['version']) |
|
499 | + if ($setup_info[$appname]['version']) |
|
500 | 500 | { |
501 | - if($setup_info[$appname]['tables']) |
|
501 | + if ($setup_info[$appname]['tables']) |
|
502 | 502 | { |
503 | - $tables = implode(',',$setup_info[$appname]['tables']); |
|
503 | + $tables = implode(',', $setup_info[$appname]['tables']); |
|
504 | 504 | } |
505 | 505 | if ($setup_info[$appname]['tables_use_prefix'] == True) |
506 | 506 | { |
507 | - if($GLOBALS['DEBUG']) |
|
507 | + if ($GLOBALS['DEBUG']) |
|
508 | 508 | { |
509 | - echo "<br>$appname uses tables_use_prefix, storing ". $setup_info[$appname]['tables_prefix']." as prefix for tables\n"; |
|
509 | + echo "<br>$appname uses tables_use_prefix, storing ".$setup_info[$appname]['tables_prefix']." as prefix for tables\n"; |
|
510 | 510 | } |
511 | - $this->db->insert($this->config_table,array( |
|
511 | + $this->db->insert($this->config_table, array( |
|
512 | 512 | 'config_app' => $appname, |
513 | 513 | 'config_name' => $appname.'_tables_prefix', |
514 | 514 | 'config_value' => $setup_info[$appname]['tables_prefix'], |
515 | - ),False,__LINE__,__FILE__); |
|
515 | + ), False, __LINE__, __FILE__); |
|
516 | 516 | } |
517 | 517 | try { |
518 | - $this->db->insert($this->applications_table,array( |
|
518 | + $this->db->insert($this->applications_table, array( |
|
519 | 519 | 'app_name' => $appname, |
520 | 520 | 'app_enabled' => $enable, |
521 | 521 | 'app_order' => $setup_info[$appname]['app_order'], |
522 | - 'app_tables' => (string)$tables, // app_tables is NOT NULL |
|
522 | + 'app_tables' => (string)$tables, // app_tables is NOT NULL |
|
523 | 523 | 'app_version' => $setup_info[$appname]['version'], |
524 | 524 | 'app_index' => $setup_info[$appname]['index'], |
525 | 525 | 'app_icon' => $setup_info[$appname]['icon'], |
526 | 526 | 'app_icon_app' => $setup_info[$appname]['icon_app'], |
527 | - ),False,__LINE__,__FILE__); |
|
527 | + ), False, __LINE__, __FILE__); |
|
528 | 528 | } |
529 | 529 | catch (Api\Db\Exception\InvalidSql $e) |
530 | 530 | { |
531 | 531 | // ease update from pre 1.6 eg. 1.4 not having app_index, app_icon, app_icon_app columns |
532 | 532 | _egw_log_exception($e); |
533 | 533 | |
534 | - $this->db->insert($this->applications_table,array( |
|
534 | + $this->db->insert($this->applications_table, array( |
|
535 | 535 | 'app_name' => $appname, |
536 | 536 | 'app_enabled' => $enable, |
537 | 537 | 'app_order' => $setup_info[$appname]['app_order'], |
538 | - 'app_tables' => (string)$tables, // app_tables is NOT NULL |
|
538 | + 'app_tables' => (string)$tables, // app_tables is NOT NULL |
|
539 | 539 | 'app_version' => $setup_info[$appname]['version'], |
540 | - ),False,__LINE__,__FILE__); |
|
540 | + ), False, __LINE__, __FILE__); |
|
541 | 541 | } |
542 | 542 | Api\Egw\Applications::invalidate(); |
543 | 543 | } |
@@ -551,26 +551,26 @@ discard block |
||
551 | 551 | */ |
552 | 552 | function app_registered($appname) |
553 | 553 | { |
554 | - if(!$appname) |
|
554 | + if (!$appname) |
|
555 | 555 | { |
556 | 556 | return False; |
557 | 557 | } |
558 | 558 | |
559 | - if(@$GLOBALS['DEBUG']) |
|
559 | + if (@$GLOBALS['DEBUG']) |
|
560 | 560 | { |
561 | - echo '<br>app_registered(): checking ' . $appname . ', table: ' . $this->applications_table; |
|
561 | + echo '<br>app_registered(): checking '.$appname.', table: '.$this->applications_table; |
|
562 | 562 | // _debug_array($setup_info[$appname]); |
563 | 563 | } |
564 | 564 | |
565 | - if ($this->db->select($this->applications_table,'COUNT(*)',array('app_name' => $appname),__LINE__,__FILE__)->fetchColumn()) |
|
565 | + if ($this->db->select($this->applications_table, 'COUNT(*)', array('app_name' => $appname), __LINE__, __FILE__)->fetchColumn()) |
|
566 | 566 | { |
567 | - if(@$GLOBALS['DEBUG']) |
|
567 | + if (@$GLOBALS['DEBUG']) |
|
568 | 568 | { |
569 | 569 | echo '... app previously registered.'; |
570 | 570 | } |
571 | 571 | return True; |
572 | 572 | } |
573 | - if(@$GLOBALS['DEBUG']) |
|
573 | + if (@$GLOBALS['DEBUG']) |
|
574 | 574 | { |
575 | 575 | echo '... app not registered'; |
576 | 576 | } |
@@ -583,42 +583,42 @@ discard block |
||
583 | 583 | * @param string $appname Application 'name' with a matching $setup_info[$appname] array slice |
584 | 584 | * @param array $setup_info =null default use $GLOBALS['setup_info'] |
585 | 585 | */ |
586 | - function update_app($appname, array $setup_info=null) |
|
586 | + function update_app($appname, array $setup_info = null) |
|
587 | 587 | { |
588 | 588 | if (!isset($setup_info)) $setup_info = $GLOBALS['setup_info']; |
589 | 589 | |
590 | - if(!$appname) |
|
590 | + if (!$appname) |
|
591 | 591 | { |
592 | 592 | return False; |
593 | 593 | } |
594 | 594 | |
595 | - if($GLOBALS['DEBUG']) |
|
595 | + if ($GLOBALS['DEBUG']) |
|
596 | 596 | { |
597 | - echo '<br>update_app(): ' . $appname . ', version: ' . $setup_info[$appname]['currentver'] . ', table: ' . $this->applications_table . '<br>'; |
|
597 | + echo '<br>update_app(): '.$appname.', version: '.$setup_info[$appname]['currentver'].', table: '.$this->applications_table.'<br>'; |
|
598 | 598 | // _debug_array($setup_info[$appname]); |
599 | 599 | } |
600 | 600 | |
601 | - if(!$this->app_registered($appname)) |
|
601 | + if (!$this->app_registered($appname)) |
|
602 | 602 | { |
603 | 603 | return False; |
604 | 604 | } |
605 | 605 | |
606 | - if($setup_info[$appname]['version']) |
|
606 | + if ($setup_info[$appname]['version']) |
|
607 | 607 | { |
608 | 608 | //echo '<br>' . $setup_info[$appname]['version']; |
609 | - if($setup_info[$appname]['tables']) |
|
609 | + if ($setup_info[$appname]['tables']) |
|
610 | 610 | { |
611 | - $tables = implode(',',$setup_info[$appname]['tables']); |
|
611 | + $tables = implode(',', $setup_info[$appname]['tables']); |
|
612 | 612 | } |
613 | - $this->db->update($this->applications_table,array( |
|
613 | + $this->db->update($this->applications_table, array( |
|
614 | 614 | 'app_enabled' => $setup_info[$appname]['enable'], |
615 | 615 | 'app_order' => $setup_info[$appname]['app_order'], |
616 | - 'app_tables' => (string)$tables, // app_tables is NOT NULL |
|
616 | + 'app_tables' => (string)$tables, // app_tables is NOT NULL |
|
617 | 617 | 'app_version' => $setup_info[$appname]['version'], |
618 | 618 | 'app_index' => $setup_info[$appname]['index'], |
619 | 619 | 'app_icon' => $setup_info[$appname]['icon'], |
620 | 620 | 'app_icon_app' => $setup_info[$appname]['icon_app'], |
621 | - ),array('app_name'=>$appname),__LINE__,__FILE__); |
|
621 | + ), array('app_name'=>$appname), __LINE__, __FILE__); |
|
622 | 622 | |
623 | 623 | Api\Egw\Applications::invalidate(); |
624 | 624 | } |
@@ -633,20 +633,20 @@ discard block |
||
633 | 633 | */ |
634 | 634 | function update_app_version($setup_info, $appname, $tableschanged = True) |
635 | 635 | { |
636 | - if(!$appname) |
|
636 | + if (!$appname) |
|
637 | 637 | { |
638 | 638 | return False; |
639 | 639 | } |
640 | 640 | |
641 | - if($tableschanged == True) |
|
641 | + if ($tableschanged == True) |
|
642 | 642 | { |
643 | 643 | $GLOBALS['egw_info']['setup']['tableschanged'] = True; |
644 | 644 | } |
645 | - if($setup_info[$appname]['currentver']) |
|
645 | + if ($setup_info[$appname]['currentver']) |
|
646 | 646 | { |
647 | - $this->db->update($this->applications_table,array( |
|
647 | + $this->db->update($this->applications_table, array( |
|
648 | 648 | 'app_version' => $setup_info[$appname]['currentver'], |
649 | - ),array('app_name'=>$appname),__LINE__,__FILE__); |
|
649 | + ), array('app_name'=>$appname), __LINE__, __FILE__); |
|
650 | 650 | |
651 | 651 | Api\Egw\Applications::invalidate(); |
652 | 652 | } |
@@ -660,22 +660,22 @@ discard block |
||
660 | 660 | */ |
661 | 661 | function deregister_app($appname) |
662 | 662 | { |
663 | - if(!$appname) |
|
663 | + if (!$appname) |
|
664 | 664 | { |
665 | 665 | return False; |
666 | 666 | } |
667 | 667 | |
668 | 668 | // Remove categories |
669 | - $this->db->delete(Api\Categories::TABLE, array('cat_appname'=>$appname),__LINE__,__FILE__); |
|
669 | + $this->db->delete(Api\Categories::TABLE, array('cat_appname'=>$appname), __LINE__, __FILE__); |
|
670 | 670 | Api\Categories::invalidate_cache($appname); |
671 | 671 | |
672 | 672 | // Remove config, if we are not deinstalling old phpgwapi (as that's global api config!) |
673 | 673 | if ($appname != 'phpgwapi') |
674 | 674 | { |
675 | - $this->db->delete(Api\Config::TABLE, array('config_app'=>$appname),__LINE__,__FILE__); |
|
675 | + $this->db->delete(Api\Config::TABLE, array('config_app'=>$appname), __LINE__, __FILE__); |
|
676 | 676 | } |
677 | 677 | //echo 'DELETING application: ' . $appname; |
678 | - $this->db->delete($this->applications_table,array('app_name'=>$appname),__LINE__,__FILE__); |
|
678 | + $this->db->delete($this->applications_table, array('app_name'=>$appname), __LINE__, __FILE__); |
|
679 | 679 | |
680 | 680 | Api\Egw\Applications::invalidate(); |
681 | 681 | |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | */ |
691 | 691 | function register_hooks($appname) |
692 | 692 | { |
693 | - if(!$appname) |
|
693 | + if (!$appname) |
|
694 | 694 | { |
695 | 695 | return False; |
696 | 696 | } |
@@ -710,21 +710,21 @@ discard block |
||
710 | 710 | |
711 | 711 | if (!isset($setup_info) || !isset($setup_info['hooks'])) |
712 | 712 | { |
713 | - return false; // app not found or no hook |
|
713 | + return false; // app not found or no hook |
|
714 | 714 | } |
715 | 715 | $GLOBALS['settings'] = array(); |
716 | - $hook_data = array('location' => 'settings','setup' => true); |
|
716 | + $hook_data = array('location' => 'settings', 'setup' => true); |
|
717 | 717 | if (isset($setup_info['hooks']['settings'])) |
718 | 718 | { |
719 | - $settings = ExecMethod($setup_info['hooks']['settings'],$hook_data); |
|
719 | + $settings = ExecMethod($setup_info['hooks']['settings'], $hook_data); |
|
720 | 720 | } |
721 | - elseif(in_array('settings',$setup_info['hooks']) && file_exists($file = EGW_INCLUDE_ROOT.'/'.$appname.'/inc/hook_settings.inc.php')) |
|
721 | + elseif (in_array('settings', $setup_info['hooks']) && file_exists($file = EGW_INCLUDE_ROOT.'/'.$appname.'/inc/hook_settings.inc.php')) |
|
722 | 722 | { |
723 | 723 | include_once($file); |
724 | 724 | } |
725 | 725 | if (!isset($settings) || !is_array($settings)) |
726 | 726 | { |
727 | - $settings = $GLOBALS['settings']; // old file hook or not updated new hook |
|
727 | + $settings = $GLOBALS['settings']; // old file hook or not updated new hook |
|
728 | 728 | } |
729 | 729 | if (!is_array($settings) || !count($settings)) |
730 | 730 | { |
@@ -737,10 +737,10 @@ discard block |
||
737 | 737 | { |
738 | 738 | $GLOBALS['settings'] = array(); |
739 | 739 | include_once($file); |
740 | - if ($GLOBALS['settings']) $settings = array_merge($settings,$GLOBALS['settings']); |
|
740 | + if ($GLOBALS['settings']) $settings = array_merge($settings, $GLOBALS['settings']); |
|
741 | 741 | } |
742 | 742 | $default = $forced = array(); |
743 | - foreach($settings as $name => $setting) |
|
743 | + foreach ($settings as $name => $setting) |
|
744 | 744 | { |
745 | 745 | if (isset($setting['default'])) |
746 | 746 | { |
@@ -754,14 +754,14 @@ discard block |
||
754 | 754 | // store default/forced preferences, if any found |
755 | 755 | $preferences = new Api\Preferences(); |
756 | 756 | $preferences->read_repository(false); |
757 | - foreach(array( |
|
757 | + foreach (array( |
|
758 | 758 | 'default' => $default, |
759 | 759 | 'forced' => $forced, |
760 | 760 | ) as $type => $prefs) |
761 | 761 | { |
762 | 762 | if ($prefs) |
763 | 763 | { |
764 | - foreach($prefs as $name => $value) |
|
764 | + foreach ($prefs as $name => $value) |
|
765 | 765 | { |
766 | 766 | $preferences->add($appname == 'preferences' ? 'common' : $appname, $name, $value, $type); |
767 | 767 | } |
@@ -778,9 +778,9 @@ discard block |
||
778 | 778 | * @param $location hook location - required |
779 | 779 | * @param $appname application name - optional |
780 | 780 | */ |
781 | - static function hook($location, $appname='') |
|
781 | + static function hook($location, $appname = '') |
|
782 | 782 | { |
783 | - return Api\Hooks::single($location,$appname,True,True); |
|
783 | + return Api\Hooks::single($location, $appname, True, True); |
|
784 | 784 | } |
785 | 785 | |
786 | 786 | /** |
@@ -789,82 +789,82 @@ discard block |
||
789 | 789 | * @param $b phpgw version number to check $a against |
790 | 790 | * @return True if $a < $b |
791 | 791 | */ |
792 | - function alessthanb($a,$b,$DEBUG=False) |
|
792 | + function alessthanb($a, $b, $DEBUG = False) |
|
793 | 793 | { |
794 | - $num = array('1st','2nd','3rd','4th'); |
|
794 | + $num = array('1st', '2nd', '3rd', '4th'); |
|
795 | 795 | |
796 | - if($DEBUG) |
|
796 | + if ($DEBUG) |
|
797 | 797 | { |
798 | 798 | echo'<br>Input values: ' |
799 | 799 | . 'A="'.$a.'", B="'.$b.'"'; |
800 | 800 | } |
801 | - $newa = str_replace('pre','.',$a); |
|
802 | - $newb = str_replace('pre','.',$b); |
|
803 | - $testa = explode('.',$newa); |
|
804 | - if(@$testa[1] == '') |
|
801 | + $newa = str_replace('pre', '.', $a); |
|
802 | + $newb = str_replace('pre', '.', $b); |
|
803 | + $testa = explode('.', $newa); |
|
804 | + if (@$testa[1] == '') |
|
805 | 805 | { |
806 | 806 | $testa[1] = 0; |
807 | 807 | } |
808 | 808 | |
809 | - $testb = explode('.',$newb); |
|
810 | - if(@$testb[1] == '') |
|
809 | + $testb = explode('.', $newb); |
|
810 | + if (@$testb[1] == '') |
|
811 | 811 | { |
812 | 812 | $testb[1] = 0; |
813 | 813 | } |
814 | - if(@$testb[3] == '') |
|
814 | + if (@$testb[3] == '') |
|
815 | 815 | { |
816 | 816 | $testb[3] = 0; |
817 | 817 | } |
818 | 818 | $less = 0; |
819 | 819 | |
820 | - for($i=0;$i<count($testa);$i++) |
|
820 | + for ($i = 0; $i < count($testa); $i++) |
|
821 | 821 | { |
822 | - if($DEBUG) { echo'<br>Checking if '. (int)$testa[$i] . ' is less than ' . (int)$testb[$i] . ' ...'; } |
|
823 | - if((int)$testa[$i] < (int)$testb[$i]) |
|
822 | + if ($DEBUG) { echo'<br>Checking if '.(int)$testa[$i].' is less than '.(int)$testb[$i].' ...'; } |
|
823 | + if ((int)$testa[$i] < (int)$testb[$i]) |
|
824 | 824 | { |
825 | 825 | if ($DEBUG) { echo ' yes.'; } |
826 | 826 | $less++; |
827 | - if($i<3) |
|
827 | + if ($i < 3) |
|
828 | 828 | { |
829 | 829 | /* Ensure that this is definitely smaller */ |
830 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
830 | + if ($DEBUG) { echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
831 | 831 | $less = 5; |
832 | 832 | break; |
833 | 833 | } |
834 | 834 | } |
835 | - elseif((int)$testa[$i] > (int)$testb[$i]) |
|
835 | + elseif ((int)$testa[$i] > (int)$testb[$i]) |
|
836 | 836 | { |
837 | - if($DEBUG) { echo ' no.'; } |
|
837 | + if ($DEBUG) { echo ' no.'; } |
|
838 | 838 | $less--; |
839 | - if($i<2) |
|
839 | + if ($i < 2) |
|
840 | 840 | { |
841 | 841 | /* Ensure that this is definitely greater */ |
842 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
842 | + if ($DEBUG) { echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
843 | 843 | $less = -5; |
844 | 844 | break; |
845 | 845 | } |
846 | 846 | } |
847 | 847 | else |
848 | 848 | { |
849 | - if($DEBUG) { echo ' no, they are equal or of different length.'; } |
|
849 | + if ($DEBUG) { echo ' no, they are equal or of different length.'; } |
|
850 | 850 | // makes sure eg. '1.0.0' is counted less the '1.0.0.xxx' ! |
851 | 851 | $less = count($testa) < count($testb) ? 1 : 0; |
852 | 852 | } |
853 | 853 | } |
854 | - if($DEBUG) { echo '<br>Check value is: "'.$less.'"'; } |
|
855 | - if($less>0) |
|
854 | + if ($DEBUG) { echo '<br>Check value is: "'.$less.'"'; } |
|
855 | + if ($less > 0) |
|
856 | 856 | { |
857 | - if($DEBUG) { echo '<br>A is less than B'; } |
|
857 | + if ($DEBUG) { echo '<br>A is less than B'; } |
|
858 | 858 | return True; |
859 | 859 | } |
860 | - elseif($less<0) |
|
860 | + elseif ($less < 0) |
|
861 | 861 | { |
862 | - if($DEBUG) { echo '<br>A is greater than B'; } |
|
862 | + if ($DEBUG) { echo '<br>A is greater than B'; } |
|
863 | 863 | return False; |
864 | 864 | } |
865 | 865 | else |
866 | 866 | { |
867 | - if($DEBUG) { echo '<br>A is equal to B'; } |
|
867 | + if ($DEBUG) { echo '<br>A is equal to B'; } |
|
868 | 868 | return False; |
869 | 869 | } |
870 | 870 | } |
@@ -876,76 +876,76 @@ discard block |
||
876 | 876 | * @param $b phpgw version number to check $a against |
877 | 877 | * @return True if $a < $b |
878 | 878 | */ |
879 | - function amorethanb($a,$b,$DEBUG=False) |
|
879 | + function amorethanb($a, $b, $DEBUG = False) |
|
880 | 880 | { |
881 | - $num = array('1st','2nd','3rd','4th'); |
|
881 | + $num = array('1st', '2nd', '3rd', '4th'); |
|
882 | 882 | |
883 | - if($DEBUG) |
|
883 | + if ($DEBUG) |
|
884 | 884 | { |
885 | 885 | echo'<br>Input values: ' |
886 | 886 | . 'A="'.$a.'", B="'.$b.'"'; |
887 | 887 | } |
888 | - $newa = str_replace('pre','.',$a); |
|
889 | - $newb = str_replace('pre','.',$b); |
|
890 | - $testa = explode('.',$newa); |
|
891 | - if($testa[3] == '') |
|
888 | + $newa = str_replace('pre', '.', $a); |
|
889 | + $newb = str_replace('pre', '.', $b); |
|
890 | + $testa = explode('.', $newa); |
|
891 | + if ($testa[3] == '') |
|
892 | 892 | { |
893 | 893 | $testa[3] = 0; |
894 | 894 | } |
895 | - $testb = explode('.',$newb); |
|
896 | - if($testb[3] == '') |
|
895 | + $testb = explode('.', $newb); |
|
896 | + if ($testb[3] == '') |
|
897 | 897 | { |
898 | 898 | $testb[3] = 0; |
899 | 899 | } |
900 | 900 | $less = 0; |
901 | 901 | |
902 | - for($i=0;$i<count($testa);$i++) |
|
902 | + for ($i = 0; $i < count($testa); $i++) |
|
903 | 903 | { |
904 | - if($DEBUG) { echo'<br>Checking if '. (int)$testa[$i] . ' is more than ' . (int)$testb[$i] . ' ...'; } |
|
905 | - if((int)$testa[$i] > (int)$testb[$i]) |
|
904 | + if ($DEBUG) { echo'<br>Checking if '.(int)$testa[$i].' is more than '.(int)$testb[$i].' ...'; } |
|
905 | + if ((int)$testa[$i] > (int)$testb[$i]) |
|
906 | 906 | { |
907 | - if($DEBUG) { echo ' yes.'; } |
|
907 | + if ($DEBUG) { echo ' yes.'; } |
|
908 | 908 | $less++; |
909 | - if($i<3) |
|
909 | + if ($i < 3) |
|
910 | 910 | { |
911 | 911 | /* Ensure that this is definitely greater */ |
912 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
912 | + if ($DEBUG) { echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
913 | 913 | $less = 5; |
914 | 914 | break; |
915 | 915 | } |
916 | 916 | } |
917 | - elseif((int)$testa[$i] < (int)$testb[$i]) |
|
917 | + elseif ((int)$testa[$i] < (int)$testb[$i]) |
|
918 | 918 | { |
919 | - if($DEBUG) { echo ' no.'; } |
|
919 | + if ($DEBUG) { echo ' no.'; } |
|
920 | 920 | $less--; |
921 | - if($i<2) |
|
921 | + if ($i < 2) |
|
922 | 922 | { |
923 | 923 | /* Ensure that this is definitely smaller */ |
924 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
924 | + if ($DEBUG) { echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
925 | 925 | $less = -5; |
926 | 926 | break; |
927 | 927 | } |
928 | 928 | } |
929 | 929 | else |
930 | 930 | { |
931 | - if($DEBUG) { echo ' no, they are equal.'; } |
|
931 | + if ($DEBUG) { echo ' no, they are equal.'; } |
|
932 | 932 | $less = 0; |
933 | 933 | } |
934 | 934 | } |
935 | - if($DEBUG) { echo '<br>Check value is: "'.$less.'"'; } |
|
936 | - if($less>0) |
|
935 | + if ($DEBUG) { echo '<br>Check value is: "'.$less.'"'; } |
|
936 | + if ($less > 0) |
|
937 | 937 | { |
938 | - if($DEBUG) { echo '<br>A is greater than B'; } |
|
938 | + if ($DEBUG) { echo '<br>A is greater than B'; } |
|
939 | 939 | return True; |
940 | 940 | } |
941 | - elseif($less<0) |
|
941 | + elseif ($less < 0) |
|
942 | 942 | { |
943 | - if($DEBUG) { echo '<br>A is less than B'; } |
|
943 | + if ($DEBUG) { echo '<br>A is less than B'; } |
|
944 | 944 | return False; |
945 | 945 | } |
946 | 946 | else |
947 | 947 | { |
948 | - if($DEBUG) { echo '<br>A is equal to B'; } |
|
948 | + if ($DEBUG) { echo '<br>A is equal to B'; } |
|
949 | 949 | return False; |
950 | 950 | } |
951 | 951 | } |
@@ -957,7 +957,7 @@ discard block |
||
957 | 957 | */ |
958 | 958 | var $accounts; |
959 | 959 | |
960 | - function setup_account_object(array $config=array()) |
|
960 | + function setup_account_object(array $config = array()) |
|
961 | 961 | { |
962 | 962 | if (!isset($this->accounts) || $this->accounts->config || $config) |
963 | 963 | { |
@@ -968,9 +968,9 @@ discard block |
||
968 | 968 | if (!$config) |
969 | 969 | { |
970 | 970 | // load the configuration from the database |
971 | - foreach($this->db->select($this->config_table,'config_name,config_value', |
|
971 | + foreach ($this->db->select($this->config_table, 'config_name,config_value', |
|
972 | 972 | "config_name LIKE 'ads%' OR config_name LIKE 'ldap%' OR config_name LIKE 'account_%' OR config_name LIKE '%encryption%' OR config_name='auth_type'", |
973 | - __LINE__,__FILE__) as $row) |
|
973 | + __LINE__, __FILE__) as $row) |
|
974 | 974 | { |
975 | 975 | $GLOBALS['egw_info']['server'][$row['config_name']] = $config[$row['config_name']] = $row['config_value']; |
976 | 976 | } |
@@ -983,7 +983,7 @@ discard block |
||
983 | 983 | return false; |
984 | 984 | } |
985 | 985 | if (!isset($GLOBALS['egw']->accounts)) $GLOBALS['egw']->accounts = $this->accounts; |
986 | - Api\Accounts::cache_invalidate(); // the cache is shared for all instances of the class |
|
986 | + Api\Accounts::cache_invalidate(); // the cache is shared for all instances of the class |
|
987 | 987 | } |
988 | 988 | return true; |
989 | 989 | } |
@@ -1010,7 +1010,7 @@ discard block |
||
1010 | 1010 | * @param string &$anonpw=null on return password for anonymous user |
1011 | 1011 | * @return int the numerical user-id |
1012 | 1012 | */ |
1013 | - function add_account($username,$first,$last,$_passwd,$primary_group='Default',$changepw=False,$email='',&$anonpw=null) |
|
1013 | + function add_account($username, $first, $last, $_passwd, $primary_group = 'Default', $changepw = False, $email = '', &$anonpw = null) |
|
1014 | 1014 | { |
1015 | 1015 | $this->setup_account_object(); |
1016 | 1016 | |
@@ -1023,7 +1023,7 @@ discard block |
||
1023 | 1023 | $passwd = $anonpw = $this->anonpw; |
1024 | 1024 | } |
1025 | 1025 | |
1026 | - if(!($accountid = $this->accounts->name2id($username, 'account_lid', $primary_group ? 'u' : 'g'))) |
|
1026 | + if (!($accountid = $this->accounts->name2id($username, 'account_lid', $primary_group ? 'u' : 'g'))) |
|
1027 | 1027 | { |
1028 | 1028 | $account = array( |
1029 | 1029 | 'account_type' => $primary_group ? 'u' : 'g', |
@@ -1042,7 +1042,7 @@ discard block |
||
1042 | 1042 | $meta = $GLOBALS['egw_setup']->db->metadata('egw_accounts', true); |
1043 | 1043 | if (!isset($meta['meta']['account_description'])) |
1044 | 1044 | { |
1045 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_accounts','account_description',array( |
|
1045 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_accounts', 'account_description', array( |
|
1046 | 1046 | 'type' => 'varchar', |
1047 | 1047 | 'precision' => '255', |
1048 | 1048 | 'comment' => 'group description' |
@@ -1056,7 +1056,7 @@ discard block |
||
1056 | 1056 | } |
1057 | 1057 | } |
1058 | 1058 | // set password for existing account, if given and not '*unchanged*' |
1059 | - elseif($_passwd && $_passwd != '*unchanged*') |
|
1059 | + elseif ($_passwd && $_passwd != '*unchanged*') |
|
1060 | 1060 | { |
1061 | 1061 | try { |
1062 | 1062 | $auth = new Api\Auth; |
@@ -1094,7 +1094,7 @@ discard block |
||
1094 | 1094 | { |
1095 | 1095 | $this->set_memberships(array($primary_group_id), $accountid); |
1096 | 1096 | |
1097 | - if (!$changepw) $this->add_acl('preferences','nopasswordchange',$accountid); |
|
1097 | + if (!$changepw) $this->add_acl('preferences', 'nopasswordchange', $accountid); |
|
1098 | 1098 | } |
1099 | 1099 | //error_log("setup::add_account('$username','$first','$last',\$passwd,'$primary_group',$changepw,'$email') successfull created accountid=$accountid"); |
1100 | 1100 | return $accountid; |
@@ -1170,7 +1170,7 @@ discard block |
||
1170 | 1170 | * @param int|string $account accountid or account_lid |
1171 | 1171 | * @param int $rights rights to set, default 1 |
1172 | 1172 | */ |
1173 | - function add_acl($apps,$location,$account,$rights=1) |
|
1173 | + function add_acl($apps, $location, $account, $rights = 1) |
|
1174 | 1174 | { |
1175 | 1175 | //error_log("setup::add_acl(".(is_array($apps) ? "array('".implode("','",$apps)."')" : "'$apps'").",'$location',$account,$rights)"); |
1176 | 1176 | if (!is_numeric($account)) |
@@ -1178,32 +1178,32 @@ discard block |
||
1178 | 1178 | $this->setup_account_object(); |
1179 | 1179 | $account = $this->accounts->name2id($account); |
1180 | 1180 | } |
1181 | - if(!is_object($this->db)) |
|
1181 | + if (!is_object($this->db)) |
|
1182 | 1182 | { |
1183 | 1183 | $this->loaddb(); |
1184 | 1184 | } |
1185 | 1185 | |
1186 | - if(!is_array($apps)) |
|
1186 | + if (!is_array($apps)) |
|
1187 | 1187 | { |
1188 | 1188 | $apps = array($apps); |
1189 | 1189 | } |
1190 | - foreach($apps as $app) |
|
1190 | + foreach ($apps as $app) |
|
1191 | 1191 | { |
1192 | - $this->db->delete($this->acl_table,array( |
|
1192 | + $this->db->delete($this->acl_table, array( |
|
1193 | 1193 | 'acl_appname' => $app, |
1194 | 1194 | 'acl_location' => $location, |
1195 | 1195 | 'acl_account' => $account |
1196 | - ),__LINE__,__FILE__); |
|
1196 | + ), __LINE__, __FILE__); |
|
1197 | 1197 | |
1198 | - if ((int) $rights) |
|
1198 | + if ((int)$rights) |
|
1199 | 1199 | { |
1200 | - $this->db->insert($this->acl_table,array( |
|
1200 | + $this->db->insert($this->acl_table, array( |
|
1201 | 1201 | 'acl_rights' => $rights |
1202 | - ),array( |
|
1202 | + ), array( |
|
1203 | 1203 | 'acl_appname' => $app, |
1204 | 1204 | 'acl_location' => $location, |
1205 | 1205 | 'acl_account' => $account, |
1206 | - ),__LINE__,__FILE__); |
|
1206 | + ), __LINE__, __FILE__); |
|
1207 | 1207 | } |
1208 | 1208 | } |
1209 | 1209 | } |
@@ -1214,7 +1214,7 @@ discard block |
||
1214 | 1214 | * @param array $tables array with possible table-names |
1215 | 1215 | * @return string/boolean tablename or false |
1216 | 1216 | */ |
1217 | - function table_exist($tables,$force_refresh=False) |
|
1217 | + function table_exist($tables, $force_refresh = False) |
|
1218 | 1218 | { |
1219 | 1219 | static $table_names = False; |
1220 | 1220 | |
@@ -1222,9 +1222,9 @@ discard block |
||
1222 | 1222 | |
1223 | 1223 | if (!$table_names) return false; |
1224 | 1224 | |
1225 | - foreach($table_names as $data) |
|
1225 | + foreach ($table_names as $data) |
|
1226 | 1226 | { |
1227 | - if (($key = array_search($data['table_name'],$tables)) !== false) |
|
1227 | + if (($key = array_search($data['table_name'], $tables)) !== false) |
|
1228 | 1228 | { |
1229 | 1229 | return $tables[$key]; |
1230 | 1230 | } |
@@ -1237,18 +1237,18 @@ discard block |
||
1237 | 1237 | * |
1238 | 1238 | * Other tables can always use the most up to date name |
1239 | 1239 | */ |
1240 | - function set_table_names($force_refresh=False) |
|
1240 | + function set_table_names($force_refresh = False) |
|
1241 | 1241 | { |
1242 | - foreach(array( |
|
1243 | - 'config_table' => array('egw_config','phpgw_config','config'), |
|
1244 | - 'applications_table' => array('egw_applications','phpgw_applications','applications'), |
|
1245 | - 'accounts_table' => array('egw_accounts','phpgw_accounts'), |
|
1246 | - 'acl_table' => array('egw_acl','phpgw_acl'), |
|
1247 | - 'lang_table' => array('egw_lang','phpgw_lang','lang'), |
|
1248 | - 'languages_table' => array('egw_languages','phpgw_languages','languages'), |
|
1242 | + foreach (array( |
|
1243 | + 'config_table' => array('egw_config', 'phpgw_config', 'config'), |
|
1244 | + 'applications_table' => array('egw_applications', 'phpgw_applications', 'applications'), |
|
1245 | + 'accounts_table' => array('egw_accounts', 'phpgw_accounts'), |
|
1246 | + 'acl_table' => array('egw_acl', 'phpgw_acl'), |
|
1247 | + 'lang_table' => array('egw_lang', 'phpgw_lang', 'lang'), |
|
1248 | + 'languages_table' => array('egw_languages', 'phpgw_languages', 'languages'), |
|
1249 | 1249 | ) as $name => $tables) |
1250 | 1250 | { |
1251 | - $table = $this->table_exist($tables,$force_refresh); |
|
1251 | + $table = $this->table_exist($tables, $force_refresh); |
|
1252 | 1252 | |
1253 | 1253 | if ($table && $table != $this->$name) // only overwrite the default name, if we realy got one (important for new installs) |
1254 | 1254 | { |
@@ -35,7 +35,7 @@ |
||
35 | 35 | /** |
36 | 36 | * Constructor |
37 | 37 | * |
38 | - * @param string|array $sub_command ='create' 'create','edit','delete'(-domain) or array with all arguments |
|
38 | + * @param string $sub_command ='create' 'create','edit','delete'(-domain) or array with all arguments |
|
39 | 39 | * @param array $arguments =null comand line arguments |
40 | 40 | */ |
41 | 41 | function __construct($sub_command='create',$arguments=null) |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @param string|array $sub_command ='create' 'create','edit','delete'(-domain) or array with all arguments |
39 | 39 | * @param array $arguments =null comand line arguments |
40 | 40 | */ |
41 | - function __construct($sub_command='create',$arguments=null) |
|
41 | + function __construct($sub_command = 'create', $arguments = null) |
|
42 | 42 | { |
43 | 43 | if (!is_array($sub_command)) |
44 | 44 | { |
@@ -73,17 +73,17 @@ discard block |
||
73 | 73 | * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); |
74 | 74 | * @throws Exception('header.inc.php not found!'); |
75 | 75 | */ |
76 | - protected function exec($check_only=false) |
|
76 | + protected function exec($check_only = false) |
|
77 | 77 | { |
78 | 78 | if ($check_only && $this->remote_id) |
79 | 79 | { |
80 | - return true; // can only check locally |
|
80 | + return true; // can only check locally |
|
81 | 81 | } |
82 | 82 | if (!file_exists($this->header_path) || filesize($this->header_path) < 200) // redirect header in rpms is ~150 byte |
83 | 83 | { |
84 | 84 | if ($this->sub_command != 'create') |
85 | 85 | { |
86 | - throw new Api\Exception\WrongUserinput(lang('EGroupware configuration file (header.inc.php) does NOT exist.')."\n".lang('Use --create-header to create the configuration file (--usage gives more options).'),1); |
|
86 | + throw new Api\Exception\WrongUserinput(lang('EGroupware configuration file (header.inc.php) does NOT exist.')."\n".lang('Use --create-header to create the configuration file (--usage gives more options).'), 1); |
|
87 | 87 | } |
88 | 88 | $this->defaults(false); |
89 | 89 | } |
@@ -92,13 +92,13 @@ discard block |
||
92 | 92 | if ($this->sub_command == 'create') |
93 | 93 | { |
94 | 94 | throw new Api\Exception\WrongUserinput( |
95 | - lang('EGroupware configuration file header.inc.php already exists, you need to use --edit-header or delete it first!'),20); |
|
95 | + lang('EGroupware configuration file header.inc.php already exists, you need to use --edit-header or delete it first!'), 20); |
|
96 | 96 | } |
97 | 97 | if ($this->arguments) |
98 | 98 | { |
99 | - list($this->header_admin_password,$this->header_admin_user) = explode(',',$this->arguments[1]); |
|
99 | + list($this->header_admin_password, $this->header_admin_user) = explode(',', $this->arguments[1]); |
|
100 | 100 | } |
101 | - $this->check_setup_auth($this->header_admin_user,$this->header_admin_password); // no domain, we require header access! |
|
101 | + $this->check_setup_auth($this->header_admin_user, $this->header_admin_password); // no domain, we require header access! |
|
102 | 102 | |
103 | 103 | $GLOBALS['egw_info']['server']['server_root'] = EGW_SERVER_ROOT; |
104 | 104 | $GLOBALS['egw_info']['server']['include_root'] = EGW_INCLUDE_ROOT; |
@@ -125,17 +125,17 @@ discard block |
||
125 | 125 | echo '$GLOBALS[egw_info] = '; print_r($GLOBALS['egw_info']); |
126 | 126 | echo '$GLOBALS[egw_domain] = '; print_r($GLOBALS['egw_domain']); |
127 | 127 | } |
128 | - throw new Api\Exception\WrongUserinput(lang('Configuration errors:')."\n- ".implode("\n- ",$errors)."\n".lang("You need to fix the above errors, before the configuration file header.inc.php can be written!"),23); |
|
128 | + throw new Api\Exception\WrongUserinput(lang('Configuration errors:')."\n- ".implode("\n- ", $errors)."\n".lang("You need to fix the above errors, before the configuration file header.inc.php can be written!"), 23); |
|
129 | 129 | } |
130 | 130 | if ($check_only) |
131 | 131 | { |
132 | 132 | return true; |
133 | 133 | } |
134 | - $header = $this->generate($GLOBALS['egw_info'],$GLOBALS['egw_domain']); |
|
134 | + $header = $this->generate($GLOBALS['egw_info'], $GLOBALS['egw_domain']); |
|
135 | 135 | |
136 | 136 | if ($this->arguments) |
137 | 137 | { |
138 | - echo $header; // for cli, we echo the header |
|
138 | + echo $header; // for cli, we echo the header |
|
139 | 139 | } |
140 | 140 | if (file_exists($this->header_path) && is_writable($this->header_path) || is_writable(dirname($this->header_path)) || |
141 | 141 | function_exists('posix_getuid') && !posix_getuid()) // root has all rights |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | { |
145 | 145 | unlink($this->header_path); |
146 | 146 | } |
147 | - if (($f = fopen($this->header_path,'wb')) && fwrite($f,$header)) |
|
147 | + if (($f = fopen($this->header_path, 'wb')) && fwrite($f, $header)) |
|
148 | 148 | { |
149 | 149 | fclose($f); |
150 | 150 | return lang('header.inc.php successful written.'); |
151 | 151 | } |
152 | 152 | } |
153 | - throw new Api\Exception\NoPermission(lang("Failed writing configuration file header.inc.php, check the permissions !!!"),24); |
|
153 | + throw new Api\Exception\NoPermission(lang("Failed writing configuration file header.inc.php, check the permissions !!!"), 24); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | * @param array $args =null |
161 | 161 | * @return mixed |
162 | 162 | */ |
163 | - function __call($method,array $args=null) |
|
163 | + function __call($method, array $args = null) |
|
164 | 164 | { |
165 | - if (method_exists($this->setup_header,$method)) |
|
165 | + if (method_exists($this->setup_header, $method)) |
|
166 | 166 | { |
167 | - return call_user_func_array(array($this->setup_header,$method),$args); |
|
167 | + return call_user_func_array(array($this->setup_header, $method), $args); |
|
168 | 168 | } |
169 | 169 | } |
170 | 170 | |
@@ -189,21 +189,21 @@ discard block |
||
189 | 189 | '--session-type' => array( |
190 | 190 | 'sessions_type' => array( |
191 | 191 | 'type' => 'egw_info/server/', |
192 | - 'allowed' => array('php'=>'php4','php4'=>'php4','php-restore'=>'php4-restore','php4-restore'=>'php4-restore','db'=>'db'), |
|
192 | + 'allowed' => array('php'=>'php4', 'php4'=>'php4', 'php-restore'=>'php4-restore', 'php4-restore'=>'php4-restore', 'db'=>'db'), |
|
193 | 193 | ), |
194 | 194 | ), |
195 | 195 | '--session-handler' => array( |
196 | 196 | 'session_handler' => array( |
197 | 197 | 'type' => 'egw_info/server/', |
198 | - 'allowed' => array('files'=>'files','memcache'=>'memcache','db'=>'db'), |
|
198 | + 'allowed' => array('files'=>'files', 'memcache'=>'memcache', 'db'=>'db'), |
|
199 | 199 | ), |
200 | 200 | ), |
201 | - '--limit-access' => 'egw_info/server/setup_acl', // name used in setup |
|
202 | - '--setup-acl' => 'egw_info/server/setup_acl', // alias to match the real name |
|
201 | + '--limit-access' => 'egw_info/server/setup_acl', // name used in setup |
|
202 | + '--setup-acl' => 'egw_info/server/setup_acl', // alias to match the real name |
|
203 | 203 | '--mcrypt' => array( |
204 | 204 | 'mcrypt_enabled' => array( |
205 | 205 | 'type' => 'egw_info/server/', |
206 | - 'allowed' => array('on' => true,'off' => false), |
|
206 | + 'allowed' => array('on' => true, 'off' => false), |
|
207 | 207 | ), |
208 | 208 | 'mcrypt_iv' => 'egw_info/server/', |
209 | 209 | 'mcrypt' => 'egw_info/versions/mcrypt', |
@@ -211,13 +211,13 @@ discard block |
||
211 | 211 | '--domain-selectbox' => array( |
212 | 212 | 'show_domain_selectbox' => array( |
213 | 213 | 'type' => 'egw_info/server/', |
214 | - 'allowed' => array('on' => true,'off' => false), |
|
214 | + 'allowed' => array('on' => true, 'off' => false), |
|
215 | 215 | ), |
216 | 216 | ), |
217 | 217 | '--db-persistent' => array( |
218 | 218 | 'db_persistent' => array( |
219 | 219 | 'type' => 'egw_info/server/', |
220 | - 'allowed' => array('on' => true,'off' => false), |
|
220 | + 'allowed' => array('on' => true, 'off' => false), |
|
221 | 221 | ), |
222 | 222 | ), |
223 | 223 | '--domain' => array( |
@@ -239,17 +239,17 @@ discard block |
||
239 | 239 | */ |
240 | 240 | private function _parse_properties() |
241 | 241 | { |
242 | - foreach(self::$options as $arg => $option) |
|
242 | + foreach (self::$options as $arg => $option) |
|
243 | 243 | { |
244 | - foreach(is_array($option) ? $option : array($option => $option) as $name => $data) |
|
244 | + foreach (is_array($option) ? $option : array($option => $option) as $name => $data) |
|
245 | 245 | { |
246 | - if (strpos($name,'/') !== false) |
|
246 | + if (strpos($name, '/') !== false) |
|
247 | 247 | { |
248 | - $name = array_pop($parts = explode('/',$name)); |
|
248 | + $name = array_pop($parts = explode('/', $name)); |
|
249 | 249 | } |
250 | 250 | if (isset($this->$name)) |
251 | 251 | { |
252 | - $this->_parse_value($arg,$name,$data,$this->$name); |
|
252 | + $this->_parse_value($arg, $name, $data, $this->$name); |
|
253 | 253 | } |
254 | 254 | } |
255 | 255 | } |
@@ -261,9 +261,9 @@ discard block |
||
261 | 261 | private function _parse_cli_arguments() |
262 | 262 | { |
263 | 263 | $arguments = $this->arguments; |
264 | - while(($arg = array_shift($arguments))) |
|
264 | + while (($arg = array_shift($arguments))) |
|
265 | 265 | { |
266 | - $values = count($arguments) && substr($arguments[0],0,2) !== '--' ? array_shift($arguments) : 'on'; |
|
266 | + $values = count($arguments) && substr($arguments[0], 0, 2) !== '--' ? array_shift($arguments) : 'on'; |
|
267 | 267 | |
268 | 268 | if ($arg == '--delete-domain') |
269 | 269 | { |
@@ -273,18 +273,18 @@ discard block |
||
273 | 273 | |
274 | 274 | if (!isset(self::$options[$arg])) |
275 | 275 | { |
276 | - throw new Api\Exception\WrongUserinput(lang("Unknown option '%1' !!!",$arg),90); |
|
276 | + throw new Api\Exception\WrongUserinput(lang("Unknown option '%1' !!!", $arg), 90); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | $option = self::$options[$arg]; |
280 | - $vals = !is_array($option) ? array($values) : explode(',',$values); |
|
280 | + $vals = !is_array($option) ? array($values) : explode(',', $values); |
|
281 | 281 | if (!is_array($option)) $option = array($option => $option); |
282 | 282 | $n = 0; |
283 | - foreach($option as $name => $data) |
|
283 | + foreach ($option as $name => $data) |
|
284 | 284 | { |
285 | 285 | if ($n >= count($vals)) break; |
286 | 286 | |
287 | - $this->_parse_value($arg,$name,$data,$vals[$n++]); |
|
287 | + $this->_parse_value($arg, $name, $data, $vals[$n++]); |
|
288 | 288 | } |
289 | 289 | } |
290 | 290 | } |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | { |
299 | 299 | if (!isset($GLOBALS['egw_domain'][$domain])) |
300 | 300 | { |
301 | - throw new Api\Exception\WrongUserinput(lang("Domain '%1' does NOT exist !!!",$domain),92); |
|
301 | + throw new Api\Exception\WrongUserinput(lang("Domain '%1' does NOT exist !!!", $domain), 92); |
|
302 | 302 | } |
303 | 303 | unset($GLOBALS['egw_domain'][$domain]); |
304 | 304 | } |
@@ -311,9 +311,9 @@ discard block |
||
311 | 311 | * @param array/string $data string with type or array containing values for type, allowed |
312 | 312 | * @param mixed $value value to set |
313 | 313 | */ |
314 | - private function _parse_value($arg,$name,$data,$value) |
|
314 | + private function _parse_value($arg, $name, $data, $value) |
|
315 | 315 | { |
316 | - static $domain=null; |
|
316 | + static $domain = null; |
|
317 | 317 | |
318 | 318 | if (!is_array($data)) $data = array('type' => $data); |
319 | 319 | $type = $data['type']; |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | { |
323 | 323 | if (!isset($data['allowed'][$value])) |
324 | 324 | { |
325 | - throw new Api\Exception\WrongUserinput(lang("'%1' is not allowed as %2. arguments of option %3 !!!",$value,1,$arg),91); |
|
325 | + throw new Api\Exception\WrongUserinput(lang("'%1' is not allowed as %2. arguments of option %3 !!!", $value, 1, $arg), 91); |
|
326 | 326 | } |
327 | 327 | $value = $data['allowed'][$value]; |
328 | 328 | } |
@@ -331,15 +331,15 @@ discard block |
||
331 | 331 | $domain = $arg == '--domain' && !$value ? 'default' : $value; |
332 | 332 | if ($arg == '--domain' && (!isset($GLOBALS['egw_domain'][$domain]) || $this->sub_command == 'create')) |
333 | 333 | { |
334 | - $GLOBALS['egw_domain'][$domain] = $this->domain_defaults($GLOBALS['egw_info']['server']['header_admin_user'],$GLOBALS['egw_info']['server']['header_admin_password']); |
|
334 | + $GLOBALS['egw_domain'][$domain] = $this->domain_defaults($GLOBALS['egw_info']['server']['header_admin_user'], $GLOBALS['egw_info']['server']['header_admin_password']); |
|
335 | 335 | } |
336 | 336 | } |
337 | 337 | elseif ($value !== '') |
338 | 338 | { |
339 | - self::_set_value($GLOBALS,str_replace('@',$domain,$type),$name,$value); |
|
339 | + self::_set_value($GLOBALS, str_replace('@', $domain, $type), $name, $value); |
|
340 | 340 | if ($type == 'egw_info/server/server_root') |
341 | 341 | { |
342 | - self::_set_value($GLOBALS,'egw_info/server/include_root',$name,$value); |
|
342 | + self::_set_value($GLOBALS, 'egw_info/server/include_root', $name, $value); |
|
343 | 343 | } |
344 | 344 | } |
345 | 345 | } |
@@ -352,15 +352,15 @@ discard block |
||
352 | 352 | * @param string $name additional index to use if $index end with a slash |
353 | 353 | * @param mixed $value value to set |
354 | 354 | */ |
355 | - static private function _set_value(&$arr,$index,$name,$value) |
|
355 | + static private function _set_value(&$arr, $index, $name, $value) |
|
356 | 356 | { |
357 | - if (substr($index,-1) == '/') $index .= $name; |
|
357 | + if (substr($index, -1) == '/') $index .= $name; |
|
358 | 358 | |
359 | - $var =& $arr; |
|
360 | - foreach(explode('/',$index) as $name) |
|
359 | + $var = & $arr; |
|
360 | + foreach (explode('/', $index) as $name) |
|
361 | 361 | { |
362 | - $var =& $var[$name]; |
|
362 | + $var = & $var[$name]; |
|
363 | 363 | } |
364 | - if (true) $var = strpos($name,'passw') !== false ? md5($value) : $value; |
|
364 | + if (true) $var = strpos($name, 'passw') !== false ? md5($value) : $value; |
|
365 | 365 | } |
366 | 366 | } |
@@ -79,11 +79,14 @@ discard block |
||
79 | 79 | { |
80 | 80 | return true; // can only check locally |
81 | 81 | } |
82 | - if (!file_exists($this->header_path) || filesize($this->header_path) < 200) // redirect header in rpms is ~150 byte |
|
82 | + if (!file_exists($this->header_path) || filesize($this->header_path) < 200) |
|
83 | + { |
|
84 | + // redirect header in rpms is ~150 byte |
|
83 | 85 | { |
84 | 86 | if ($this->sub_command != 'create') |
85 | 87 | { |
86 | 88 | throw new Api\Exception\WrongUserinput(lang('EGroupware configuration file (header.inc.php) does NOT exist.')."\n".lang('Use --create-header to create the configuration file (--usage gives more options).'),1); |
89 | + } |
|
87 | 90 | } |
88 | 91 | $this->defaults(false); |
89 | 92 | } |
@@ -104,10 +107,13 @@ discard block |
||
104 | 107 | $GLOBALS['egw_info']['server']['include_root'] = EGW_INCLUDE_ROOT; |
105 | 108 | } |
106 | 109 | |
107 | - if ($this->arguments) // we have command line arguments |
|
110 | + if ($this->arguments) |
|
111 | + { |
|
112 | + // we have command line arguments |
|
108 | 113 | { |
109 | 114 | $this->_parse_cli_arguments(); |
110 | 115 | } |
116 | + } |
|
111 | 117 | elseif ($this->sub_command == 'delete') |
112 | 118 | { |
113 | 119 | self::_delete_domain($this->domain); |
@@ -138,11 +144,14 @@ discard block |
||
138 | 144 | echo $header; // for cli, we echo the header |
139 | 145 | } |
140 | 146 | if (file_exists($this->header_path) && is_writable($this->header_path) || is_writable(dirname($this->header_path)) || |
141 | - function_exists('posix_getuid') && !posix_getuid()) // root has all rights |
|
147 | + function_exists('posix_getuid') && !posix_getuid()) |
|
148 | + { |
|
149 | + // root has all rights |
|
142 | 150 | { |
143 | 151 | if (file_exists($this->header_path) && !is_writable($this->header_path)) |
144 | 152 | { |
145 | 153 | unlink($this->header_path); |
154 | + } |
|
146 | 155 | } |
147 | 156 | if (($f = fopen($this->header_path,'wb')) && fwrite($f,$header)) |
148 | 157 | { |
@@ -278,11 +287,17 @@ discard block |
||
278 | 287 | |
279 | 288 | $option = self::$options[$arg]; |
280 | 289 | $vals = !is_array($option) ? array($values) : explode(',',$values); |
281 | - if (!is_array($option)) $option = array($option => $option); |
|
290 | + if (!is_array($option)) |
|
291 | + { |
|
292 | + $option = array($option => $option); |
|
293 | + } |
|
282 | 294 | $n = 0; |
283 | 295 | foreach($option as $name => $data) |
284 | 296 | { |
285 | - if ($n >= count($vals)) break; |
|
297 | + if ($n >= count($vals)) |
|
298 | + { |
|
299 | + break; |
|
300 | + } |
|
286 | 301 | |
287 | 302 | $this->_parse_value($arg,$name,$data,$vals[$n++]); |
288 | 303 | } |
@@ -315,7 +330,10 @@ discard block |
||
315 | 330 | { |
316 | 331 | static $domain=null; |
317 | 332 | |
318 | - if (!is_array($data)) $data = array('type' => $data); |
|
333 | + if (!is_array($data)) |
|
334 | + { |
|
335 | + $data = array('type' => $data); |
|
336 | + } |
|
319 | 337 | $type = $data['type']; |
320 | 338 | |
321 | 339 | if (isset($data['allowed'])) |
@@ -354,13 +372,19 @@ discard block |
||
354 | 372 | */ |
355 | 373 | static private function _set_value(&$arr,$index,$name,$value) |
356 | 374 | { |
357 | - if (substr($index,-1) == '/') $index .= $name; |
|
375 | + if (substr($index,-1) == '/') |
|
376 | + { |
|
377 | + $index .= $name; |
|
378 | + } |
|
358 | 379 | |
359 | 380 | $var =& $arr; |
360 | 381 | foreach(explode('/',$index) as $name) |
361 | 382 | { |
362 | 383 | $var =& $var[$name]; |
363 | 384 | } |
364 | - if (true) $var = strpos($name,'passw') !== false ? md5($value) : $value; |
|
385 | + if (true) |
|
386 | + { |
|
387 | + $var = strpos($name,'passw') !== false ? md5($value) : $value; |
|
388 | + } |
|
365 | 389 | } |
366 | 390 | } |
@@ -19,9 +19,8 @@ |
||
19 | 19 | * Constructor |
20 | 20 | * |
21 | 21 | * @param string $domain string with domain-name or array with all arguments |
22 | - * @param string $config_user=null user to config the domain (or header_admin_user) |
|
23 | - * @param string $config_passwd=null pw of above user |
|
24 | - * @param boolean $verbose=false if true, echos out some status information during the run |
|
22 | + * @param string $config_user user to config the domain (or header_admin_user) |
|
23 | + * @param string $config_passwd pw of above user |
|
25 | 24 | */ |
26 | 25 | function __construct($domain,$config_user=null,$config_passwd=null) |
27 | 26 | { |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @param string $config_passwd=null pw of above user |
24 | 24 | * @param boolean $verbose=false if true, echos out some status information during the run |
25 | 25 | */ |
26 | - function __construct($domain,$config_user=null,$config_passwd=null) |
|
26 | + function __construct($domain, $config_user = null, $config_passwd = null) |
|
27 | 27 | { |
28 | 28 | if (!is_array($domain)) |
29 | 29 | { |
@@ -45,17 +45,17 @@ discard block |
||
45 | 45 | * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); |
46 | 46 | * @throws Exception('header.inc.php not found!'); |
47 | 47 | */ |
48 | - protected function exec($check_only=false) |
|
48 | + protected function exec($check_only = false) |
|
49 | 49 | { |
50 | - if ($check_only) return true; // nothing to check, no arguments ... |
|
50 | + if ($check_only) return true; // nothing to check, no arguments ... |
|
51 | 51 | |
52 | 52 | // instanciate setup object and check authorisation |
53 | - $this->check_setup_auth($this->config_user,$this->config_passwd,$this->domain); |
|
53 | + $this->check_setup_auth($this->config_user, $this->config_passwd, $this->domain); |
|
54 | 54 | |
55 | - $this->check_installed($this->domain,15,$this->verbose); |
|
55 | + $this->check_installed($this->domain, 15, $this->verbose); |
|
56 | 56 | |
57 | 57 | global $setup_info; |
58 | - foreach($setup_info as $appname => $info) |
|
58 | + foreach ($setup_info as $appname => $info) |
|
59 | 59 | { |
60 | 60 | if ($info['currentver']) self::$egw_setup->register_hooks($appname); |
61 | 61 | } |
@@ -47,7 +47,11 @@ discard block |
||
47 | 47 | */ |
48 | 48 | protected function exec($check_only=false) |
49 | 49 | { |
50 | - if ($check_only) return true; // nothing to check, no arguments ... |
|
50 | + if ($check_only) |
|
51 | + { |
|
52 | + return true; |
|
53 | + } |
|
54 | + // nothing to check, no arguments ... |
|
51 | 55 | |
52 | 56 | // instanciate setup object and check authorisation |
53 | 57 | $this->check_setup_auth($this->config_user,$this->config_passwd,$this->domain); |
@@ -57,7 +61,10 @@ discard block |
||
57 | 61 | global $setup_info; |
58 | 62 | foreach($setup_info as $appname => $info) |
59 | 63 | { |
60 | - if ($info['currentver']) self::$egw_setup->register_hooks($appname); |
|
64 | + if ($info['currentver']) |
|
65 | + { |
|
66 | + self::$egw_setup->register_hooks($appname); |
|
67 | + } |
|
61 | 68 | } |
62 | 69 | $this->restore_db(); |
63 | 70 |