@@ -29,25 +29,25 @@ discard block |
||
29 | 29 | * true: always return svg, false: never return svg (current default), null: browser dependent, see svg_usable() |
30 | 30 | * @return string url of image or null if not found |
31 | 31 | */ |
32 | - static function find($app,$image,$extension='',$_svg=false) |
|
32 | + static function find($app, $image, $extension = '', $_svg = false) |
|
33 | 33 | { |
34 | 34 | $svg = Header\UserAgent::mobile() ? null : $_svg; // ATM we use svg icons only for mobile theme |
35 | 35 | static $image_map_no_svg = null, $image_map_svg = null; |
36 | - if (is_null($svg)) $svg = self::svg_usable (); |
|
36 | + if (is_null($svg)) $svg = self::svg_usable(); |
|
37 | 37 | if ($svg) |
38 | 38 | { |
39 | - $image_map =& $image_map_svg; |
|
39 | + $image_map = & $image_map_svg; |
|
40 | 40 | } |
41 | 41 | else |
42 | 42 | { |
43 | - $image_map =& $image_map_no_svg; |
|
43 | + $image_map = & $image_map_no_svg; |
|
44 | 44 | } |
45 | 45 | if (is_null($image_map)) $image_map = self::map(null, $svg); |
46 | 46 | |
47 | 47 | // array of images in descending precedence |
48 | 48 | if (is_array($image)) |
49 | 49 | { |
50 | - foreach($image as $img) |
|
50 | + foreach ($image as $img) |
|
51 | 51 | { |
52 | 52 | if (($url = self::find($app, $img, $extension))) |
53 | 53 | { |
@@ -66,16 +66,16 @@ discard block |
||
66 | 66 | return $webserver_url.$image_map['vfs'][$image.$extension]; |
67 | 67 | } |
68 | 68 | // then app specific ones |
69 | - if(isset($image_map[$app][$image.$extension])) |
|
69 | + if (isset($image_map[$app][$image.$extension])) |
|
70 | 70 | { |
71 | 71 | return $webserver_url.$image_map[$app][$image.$extension]; |
72 | 72 | } |
73 | 73 | // then api |
74 | - if(isset($image_map['api'][$image.$extension])) |
|
74 | + if (isset($image_map['api'][$image.$extension])) |
|
75 | 75 | { |
76 | 76 | return $webserver_url.$image_map['api'][$image.$extension]; |
77 | 77 | } |
78 | - if(isset($image_map['phpgwapi'][$image.$extension])) |
|
78 | + if (isset($image_map['phpgwapi'][$image.$extension])) |
|
79 | 79 | { |
80 | 80 | return $webserver_url.$image_map['phpgwapi'][$image.$extension]; |
81 | 81 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @param string &$name on return basename without extension |
99 | 99 | * @return string extension without dot, eg. 'php' |
100 | 100 | */ |
101 | - protected static function get_extension($path, &$name=null) |
|
101 | + protected static function get_extension($path, &$name = null) |
|
102 | 102 | { |
103 | 103 | $parts = explode('.', basename($path)); |
104 | 104 | $ext = array_pop($parts); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * @param boolean $svg =null prefer svg images, default for all browsers but IE<9 |
131 | 131 | * @return array of application => image-name => full path |
132 | 132 | */ |
133 | - public static function map($template_set=null, $svg=null) |
|
133 | + public static function map($template_set = null, $svg = null) |
|
134 | 134 | { |
135 | 135 | if (is_null($template_set)) |
136 | 136 | { |
@@ -149,17 +149,17 @@ discard block |
||
149 | 149 | //$starttime = microtime(true); |
150 | 150 | |
151 | 151 | // priority: : PNG->JPG->GIF |
152 | - $img_types = array('png','jpg','gif','ico'); |
|
152 | + $img_types = array('png', 'jpg', 'gif', 'ico'); |
|
153 | 153 | |
154 | 154 | // if we want svg, prepend it to img-types |
155 | - if ($svg) array_unshift ($img_types, 'svg'); |
|
155 | + if ($svg) array_unshift($img_types, 'svg'); |
|
156 | 156 | |
157 | 157 | $map = array(); |
158 | - foreach(scandir(EGW_SERVER_ROOT) as $app) |
|
158 | + foreach (scandir(EGW_SERVER_ROOT) as $app) |
|
159 | 159 | { |
160 | 160 | if ($app[0] == '.' || !is_dir(EGW_SERVER_ROOT.'/'.$app) || !file_exists(EGW_SERVER_ROOT.'/'.$app.'/templates')) continue; |
161 | 161 | |
162 | - $app_map =& $map[$app]; |
|
162 | + $app_map = & $map[$app]; |
|
163 | 163 | if (true) $app_map = array(); |
164 | 164 | $imagedirs = array(); |
165 | 165 | if (Header\UserAgent::mobile()) |
@@ -177,16 +177,16 @@ discard block |
||
177 | 177 | if ($template_set != 'idots') $imagedirs[] = '/'.$app.'/templates/idots/images'; |
178 | 178 | $imagedirs[] = '/'.$app.'/templates/default/images'; |
179 | 179 | |
180 | - foreach($imagedirs as $imagedir) |
|
180 | + foreach ($imagedirs as $imagedir) |
|
181 | 181 | { |
182 | 182 | if (!file_exists($dir = EGW_SERVER_ROOT.$imagedir) || !is_readable($dir)) continue; |
183 | 183 | |
184 | - foreach(scandir($dir) as $img) |
|
184 | + foreach (scandir($dir) as $img) |
|
185 | 185 | { |
186 | 186 | if ($img[0] == '.') continue; |
187 | 187 | |
188 | 188 | $subdir = null; |
189 | - foreach(is_dir($dir.'/'.$img) ? scandir($dir.'/'.($subdir=$img)) : (array) $img as $img) |
|
189 | + foreach (is_dir($dir.'/'.$img) ? scandir($dir.'/'.($subdir = $img)) : (array)$img as $img) |
|
190 | 190 | { |
191 | 191 | $name = null; |
192 | 192 | if (!in_array($ext = self::get_extension($img, $name), $img_types) || empty($name)) continue; |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | } |
202 | 202 | } |
203 | 203 | } |
204 | - $app_map =& $map['vfs']; |
|
204 | + $app_map = & $map['vfs']; |
|
205 | 205 | if (true) $app_map = array(); |
206 | 206 | if (($dir = $GLOBALS['egw_info']['server']['vfs_image_dir']) && Vfs::file_exists($dir) && Vfs::is_readable($dir)) |
207 | 207 | { |
208 | - foreach(Vfs::find($dir) as $img) |
|
208 | + foreach (Vfs::find($dir) as $img) |
|
209 | 209 | { |
210 | 210 | if (!in_array($ext = self::get_extension($img, $name), $img_types) || empty($name)) continue; |
211 | 211 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | return $map; |
221 | 221 | } |
222 | 222 | //error_log(__METHOD__."('$template_set') took ".(microtime(true)-$starttime).' secs'); |
223 | - Cache::setInstance(__CLASS__, $cache_name, $map, 86400); // cache for one day |
|
223 | + Cache::setInstance(__CLASS__, $cache_name, $map, 86400); // cache for one day |
|
224 | 224 | //echo "<p>template_set=".array2string($template_set)."</p>\n"; _debug_array($map); |
225 | 225 | return $map; |
226 | 226 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | $templates[] = $template_set; |
237 | 237 | } |
238 | 238 | //error_log(__METHOD__."() for templates ".array2string($templates)); |
239 | - foreach($templates as $template_set) |
|
239 | + foreach ($templates as $template_set) |
|
240 | 240 | { |
241 | 241 | Cache::unsetInstance(__CLASS__, 'image_map_'.$template_set); |
242 | 242 | Cache::unsetInstance(__CLASS__, 'image_map_'.$template_set.'_svg'); |
@@ -33,7 +33,10 @@ discard block |
||
33 | 33 | { |
34 | 34 | $svg = Header\UserAgent::mobile() ? null : $_svg; // ATM we use svg icons only for mobile theme |
35 | 35 | static $image_map_no_svg = null, $image_map_svg = null; |
36 | - if (is_null($svg)) $svg = self::svg_usable (); |
|
36 | + if (is_null($svg)) |
|
37 | + { |
|
38 | + $svg = self::svg_usable (); |
|
39 | + } |
|
37 | 40 | if ($svg) |
38 | 41 | { |
39 | 42 | $image_map =& $image_map_svg; |
@@ -42,7 +45,10 @@ discard block |
||
42 | 45 | { |
43 | 46 | $image_map =& $image_map_no_svg; |
44 | 47 | } |
45 | - if (is_null($image_map)) $image_map = self::map(null, $svg); |
|
48 | + if (is_null($image_map)) |
|
49 | + { |
|
50 | + $image_map = self::map(null, $svg); |
|
51 | + } |
|
46 | 52 | |
47 | 53 | // array of images in descending precedence |
48 | 54 | if (is_array($image)) |
@@ -152,15 +158,24 @@ discard block |
||
152 | 158 | $img_types = array('png','jpg','gif','ico'); |
153 | 159 | |
154 | 160 | // if we want svg, prepend it to img-types |
155 | - if ($svg) array_unshift ($img_types, 'svg'); |
|
161 | + if ($svg) |
|
162 | + { |
|
163 | + array_unshift ($img_types, 'svg'); |
|
164 | + } |
|
156 | 165 | |
157 | 166 | $map = array(); |
158 | 167 | foreach(scandir(EGW_SERVER_ROOT) as $app) |
159 | 168 | { |
160 | - if ($app[0] == '.' || !is_dir(EGW_SERVER_ROOT.'/'.$app) || !file_exists(EGW_SERVER_ROOT.'/'.$app.'/templates')) continue; |
|
169 | + if ($app[0] == '.' || !is_dir(EGW_SERVER_ROOT.'/'.$app) || !file_exists(EGW_SERVER_ROOT.'/'.$app.'/templates')) |
|
170 | + { |
|
171 | + continue; |
|
172 | + } |
|
161 | 173 | |
162 | 174 | $app_map =& $map[$app]; |
163 | - if (true) $app_map = array(); |
|
175 | + if (true) |
|
176 | + { |
|
177 | + $app_map = array(); |
|
178 | + } |
|
164 | 179 | $imagedirs = array(); |
165 | 180 | if (Header\UserAgent::mobile()) |
166 | 181 | { |
@@ -174,24 +189,39 @@ discard block |
||
174 | 189 | { |
175 | 190 | $imagedirs[] = '/'.$app.'/templates/'.$template_set.'/images'; |
176 | 191 | } |
177 | - if ($template_set != 'idots') $imagedirs[] = '/'.$app.'/templates/idots/images'; |
|
192 | + if ($template_set != 'idots') |
|
193 | + { |
|
194 | + $imagedirs[] = '/'.$app.'/templates/idots/images'; |
|
195 | + } |
|
178 | 196 | $imagedirs[] = '/'.$app.'/templates/default/images'; |
179 | 197 | |
180 | 198 | foreach($imagedirs as $imagedir) |
181 | 199 | { |
182 | - if (!file_exists($dir = EGW_SERVER_ROOT.$imagedir) || !is_readable($dir)) continue; |
|
200 | + if (!file_exists($dir = EGW_SERVER_ROOT.$imagedir) || !is_readable($dir)) |
|
201 | + { |
|
202 | + continue; |
|
203 | + } |
|
183 | 204 | |
184 | 205 | foreach(scandir($dir) as $img) |
185 | 206 | { |
186 | - if ($img[0] == '.') continue; |
|
207 | + if ($img[0] == '.') |
|
208 | + { |
|
209 | + continue; |
|
210 | + } |
|
187 | 211 | |
188 | 212 | $subdir = null; |
189 | 213 | foreach(is_dir($dir.'/'.$img) ? scandir($dir.'/'.($subdir=$img)) : (array) $img as $img) |
190 | 214 | { |
191 | 215 | $name = null; |
192 | - if (!in_array($ext = self::get_extension($img, $name), $img_types) || empty($name)) continue; |
|
216 | + if (!in_array($ext = self::get_extension($img, $name), $img_types) || empty($name)) |
|
217 | + { |
|
218 | + continue; |
|
219 | + } |
|
193 | 220 | |
194 | - if (isset($subdir)) $name = $subdir.'/'.$name; |
|
221 | + if (isset($subdir)) |
|
222 | + { |
|
223 | + $name = $subdir.'/'.$name; |
|
224 | + } |
|
195 | 225 | |
196 | 226 | if (!isset($app_map[$name]) || array_search($ext, $img_types) < array_search(self::get_extension($app_map[$name]), $img_types)) |
197 | 227 | { |
@@ -202,12 +232,18 @@ discard block |
||
202 | 232 | } |
203 | 233 | } |
204 | 234 | $app_map =& $map['vfs']; |
205 | - if (true) $app_map = array(); |
|
235 | + if (true) |
|
236 | + { |
|
237 | + $app_map = array(); |
|
238 | + } |
|
206 | 239 | if (($dir = $GLOBALS['egw_info']['server']['vfs_image_dir']) && Vfs::file_exists($dir) && Vfs::is_readable($dir)) |
207 | 240 | { |
208 | 241 | foreach(Vfs::find($dir) as $img) |
209 | 242 | { |
210 | - if (!in_array($ext = self::get_extension($img, $name), $img_types) || empty($name)) continue; |
|
243 | + if (!in_array($ext = self::get_extension($img, $name), $img_types) || empty($name)) |
|
244 | + { |
|
245 | + continue; |
|
246 | + } |
|
211 | 247 | |
212 | 248 | if (!isset($app_map[$name]) || array_search($ext, $img_types) < array_search(self::get_extension($app_map[$name]), $img_types)) |
213 | 249 | { |
@@ -23,17 +23,17 @@ discard block |
||
23 | 23 | */ |
24 | 24 | class Script |
25 | 25 | { |
26 | - var $name; /* filename of script. */ |
|
27 | - var $script; /* full ascii text of script from server. */ |
|
28 | - var $size; /* size of script in bytes. */ |
|
29 | - var $so; /* boolean: is it safe to overwrite script? |
|
26 | + var $name; /* filename of script. */ |
|
27 | + var $script; /* full ascii text of script from server. */ |
|
28 | + var $size; /* size of script in bytes. */ |
|
29 | + var $so; /* boolean: is it safe to overwrite script? |
|
30 | 30 | * only safe if we recognise encoding. */ |
31 | - var $mode; /* basic or advanced. Smartsieve can only read/write basic. */ |
|
32 | - var $rules; /* array of sieve rules. */ |
|
33 | - var $vacation; /* vacation settings. */ |
|
31 | + var $mode; /* basic or advanced. Smartsieve can only read/write basic. */ |
|
32 | + var $rules; /* array of sieve rules. */ |
|
33 | + var $vacation; /* vacation settings. */ |
|
34 | 34 | var $emailNotification; /* email notification settings. */ |
35 | - var $pcount; /* highest priority value in ruleset. */ |
|
36 | - var $errstr; /* error text. */ |
|
35 | + var $pcount; /* highest priority value in ruleset. */ |
|
36 | + var $errstr; /* error text. */ |
|
37 | 37 | /** |
38 | 38 | * Body transform content types |
39 | 39 | * |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @var boolean |
56 | 56 | */ |
57 | - var $debug=false; |
|
57 | + var $debug = false; |
|
58 | 58 | |
59 | 59 | // class constructor |
60 | - function __construct ($scriptname) |
|
60 | + function __construct($scriptname) |
|
61 | 61 | { |
62 | 62 | $this->name = $scriptname; |
63 | 63 | $this->script = ''; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @param Sieve $connection |
79 | 79 | * @return boolean true, if script written successfull |
80 | 80 | */ |
81 | - function retrieveRules (Sieve $connection) |
|
81 | + function retrieveRules(Sieve $connection) |
|
82 | 82 | { |
83 | 83 | #global $_SESSION; |
84 | 84 | $continuebit = 1; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $keepbit = 8; |
88 | 88 | $regexbit = 128; |
89 | 89 | |
90 | - if (!isset($this->name)){ |
|
90 | + if (!isset($this->name)) { |
|
91 | 91 | $this->errstr = 'retrieveRules: no script name specified'; |
92 | 92 | if ($this->debug) error_log(__CLASS__.'::'.__METHOD__.": no script name specified"); |
93 | 93 | return false; |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $script = $connection->getScript($this->name); |
104 | 104 | #print "<br>AAA: Script is ". htmlentities($script) ."<br>"; |
105 | 105 | |
106 | - $lines = preg_split("/\n/",$script); //,PREG_SPLIT_NO_EMPTY); |
|
106 | + $lines = preg_split("/\n/", $script); //,PREG_SPLIT_NO_EMPTY); |
|
107 | 107 | |
108 | 108 | $rules = array(); |
109 | 109 | $vacation = array(); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | /* next line should be the recognised encoded head. if not, the script |
113 | 113 | * is of an unrecognised format, and we should not overwrite it. */ |
114 | 114 | $line1 = array_shift($lines); |
115 | - if (!preg_match("/^# ?Mail(.*)rules for/", $line1)){ |
|
115 | + if (!preg_match("/^# ?Mail(.*)rules for/", $line1)) { |
|
116 | 116 | $this->errstr = 'retrieveRules: encoding not recognised'; |
117 | 117 | $this->so = false; |
118 | 118 | if ($this->debug) error_log(__CLASS__.'::'.__METHOD__.": encoding not recognised"); |
@@ -125,63 +125,63 @@ discard block |
||
125 | 125 | while (isset($line)) |
126 | 126 | { |
127 | 127 | $matches = null; |
128 | - if (preg_match("/^ *#(#PSEUDO|rule|vacation|mode|notify)/i",$line,$matches)) |
|
128 | + if (preg_match("/^ *#(#PSEUDO|rule|vacation|mode|notify)/i", $line, $matches)) |
|
129 | 129 | { |
130 | 130 | $line = rtrim($line); |
131 | - switch ($matches[1]){ |
|
131 | + switch ($matches[1]) { |
|
132 | 132 | case "rule": |
133 | - $bits = explode("&&", $line); |
|
133 | + $bits = explode("&&", $line); |
|
134 | 134 | $rule = array(); |
135 | - $rule['priority'] = $bits[1]; |
|
135 | + $rule['priority'] = $bits[1]; |
|
136 | 136 | $rule['status'] = $bits[2]; |
137 | - $rule['from'] = stripslashes($bits[3]); |
|
138 | - $rule['to'] = stripslashes($bits[4]); |
|
137 | + $rule['from'] = stripslashes($bits[3]); |
|
138 | + $rule['to'] = stripslashes($bits[4]); |
|
139 | 139 | $rule['subject'] = stripslashes($bits[5]); |
140 | 140 | $rule['action'] = $bits[6]; |
141 | 141 | $rule['action_arg'] = $bits[7]; |
142 | 142 | // <crnl>s will be encoded as \\n. undo this. |
143 | - $rule['action_arg'] = preg_replace("/\\\\n/","\r\n",$rule['action_arg']); |
|
143 | + $rule['action_arg'] = preg_replace("/\\\\n/", "\r\n", $rule['action_arg']); |
|
144 | 144 | $rule['action_arg'] = stripslashes($rule['action_arg']); |
145 | - $rule['flg'] = $bits[8]; // bitwise flag |
|
146 | - $rule['field'] = stripslashes($bits[9]); |
|
147 | - $rule['field_val'] = stripslashes($bits[10]); |
|
148 | - $rule['size'] = $bits[11]; |
|
149 | - $rule['continue'] = ($bits[8] & $continuebit); |
|
150 | - $rule['gthan'] = ($bits[8] & $sizebit); // use 'greater than' |
|
151 | - $rule['anyof'] = ($bits[8] & $anyofbit); |
|
152 | - $rule['keep'] = ($bits[8] & $keepbit); |
|
153 | - $rule['regexp'] = ($bits[8] & $regexbit); |
|
145 | + $rule['flg'] = $bits[8]; // bitwise flag |
|
146 | + $rule['field'] = stripslashes($bits[9]); |
|
147 | + $rule['field_val'] = stripslashes($bits[10]); |
|
148 | + $rule['size'] = $bits[11]; |
|
149 | + $rule['continue'] = ($bits[8]&$continuebit); |
|
150 | + $rule['gthan'] = ($bits[8]&$sizebit); // use 'greater than' |
|
151 | + $rule['anyof'] = ($bits[8]&$anyofbit); |
|
152 | + $rule['keep'] = ($bits[8]&$keepbit); |
|
153 | + $rule['regexp'] = ($bits[8]&$regexbit); |
|
154 | 154 | $rule['bodytransform'] = ($bits[12]); |
155 | 155 | $rule['field_bodytransform'] = ($bits[13]); |
156 | 156 | $rule['ctype'] = ($bits[14]); |
157 | 157 | $rule['field_ctype_val'] = ($bits[15]); |
158 | - $rule['unconditional'] = 0; |
|
158 | + $rule['unconditional'] = 0; |
|
159 | 159 | if (!$rule['from'] && !$rule['to'] && !$rule['subject'] && |
160 | 160 | !$rule['field'] && !$rule['size'] && $rule['action']) { |
161 | 161 | $rule['unconditional'] = 1; |
162 | 162 | } |
163 | 163 | |
164 | - array_push($rules,$rule); |
|
164 | + array_push($rules, $rule); |
|
165 | 165 | |
166 | 166 | if ($rule['priority'] > $this->pcount) { |
167 | 167 | $this->pcount = $rule['priority']; |
168 | 168 | } |
169 | 169 | break; |
170 | 170 | case "vacation" : |
171 | - if (preg_match("/^ *#vacation&&(.*)&&(.*)&&(.*)&&(.*)&&(.*)/i",$line,$bits) || |
|
172 | - preg_match("/^ *#vacation&&(.*)&&(.*)&&(.*)&&(.*)/i",$line,$bits)) { |
|
171 | + if (preg_match("/^ *#vacation&&(.*)&&(.*)&&(.*)&&(.*)&&(.*)/i", $line, $bits) || |
|
172 | + preg_match("/^ *#vacation&&(.*)&&(.*)&&(.*)&&(.*)/i", $line, $bits)) { |
|
173 | 173 | $vacation['days'] = $bits[1]; |
174 | - $vaddresslist = preg_replace("/\"|\s/","",$bits[2]); |
|
175 | - $vaddresses = preg_split("/,/",$vaddresslist); |
|
174 | + $vaddresslist = preg_replace("/\"|\s/", "", $bits[2]); |
|
175 | + $vaddresses = preg_split("/,/", $vaddresslist); |
|
176 | 176 | $vacation['text'] = $bits[3]; |
177 | 177 | |
178 | 178 | // <crnl>s will be encoded as \\n. undo this. |
179 | - $vacation['text'] = preg_replace("/\\\\n/","\r\n",$vacation['text']); |
|
179 | + $vacation['text'] = preg_replace("/\\\\n/", "\r\n", $vacation['text']); |
|
180 | 180 | |
181 | - if (strpos($bits[4],'-')!== false) |
|
181 | + if (strpos($bits[4], '-') !== false) |
|
182 | 182 | { |
183 | 183 | $vacation['status'] = 'by_date'; |
184 | - list($vacation['start_date'],$vacation['end_date']) = explode('-',$bits[4]); |
|
184 | + list($vacation['start_date'], $vacation['end_date']) = explode('-', $bits[4]); |
|
185 | 185 | } |
186 | 186 | else |
187 | 187 | { |
@@ -193,14 +193,14 @@ discard block |
||
193 | 193 | } |
194 | 194 | break; |
195 | 195 | case "notify": |
196 | - if (preg_match("/^ *#notify&&(.*)&&(.*)&&(.*)/i",$line,$bits)) { |
|
196 | + if (preg_match("/^ *#notify&&(.*)&&(.*)&&(.*)/i", $line, $bits)) { |
|
197 | 197 | $emailNotification['status'] = $bits[1]; |
198 | 198 | $emailNotification['externalEmail'] = $bits[2]; |
199 | 199 | $emailNotification['displaySubject'] = $bits[3]; |
200 | 200 | } |
201 | 201 | break; |
202 | 202 | case "mode" : |
203 | - if (preg_match("/^ *#mode&&(.*)/i",$line,$bits)){ |
|
203 | + if (preg_match("/^ *#mode&&(.*)/i", $line, $bits)) { |
|
204 | 204 | if ($bits[1] == 'basic') |
205 | 205 | $this->mode = 'basic'; |
206 | 206 | elseif ($bits[1] == 'advanced') |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | $this->vacation = $vacation; |
219 | 219 | if (!$connection->hasExtension('vacation')) $this->vacation = false; |
220 | 220 | $this->emailNotification = $emailNotification; // Added email notifications |
221 | - if ($this->debug) error_log(__CLASS__.'::'.__METHOD__.": Script succesful retrieved: ".print_r($vacation,true)); |
|
221 | + if ($this->debug) error_log(__CLASS__.'::'.__METHOD__.": Script succesful retrieved: ".print_r($vacation, true)); |
|
222 | 222 | |
223 | 223 | return true; |
224 | 224 | } |
@@ -230,10 +230,10 @@ discard block |
||
230 | 230 | * @param Sieve $connection |
231 | 231 | * @param boolean $utf7imap_fileinto =false true: encode foldernames with utf7imap, default utf8 |
232 | 232 | */ |
233 | - function updateScript (Sieve $connection, $utf7imap_fileinto=false) |
|
233 | + function updateScript(Sieve $connection, $utf7imap_fileinto = false) |
|
234 | 234 | { |
235 | 235 | #global $_SESSION,$default,$sieve; |
236 | - global $default,$sieve; |
|
236 | + global $default, $sieve; |
|
237 | 237 | |
238 | 238 | $activerules = 0; |
239 | 239 | $regexused = 0; |
@@ -241,13 +241,13 @@ discard block |
||
241 | 241 | $rejectused = 0; |
242 | 242 | $vacation_active = false; |
243 | 243 | |
244 | - $username = $GLOBALS['egw_info']['user']['account_lid']; |
|
245 | - $version = $GLOBALS['egw_info']['apps']['mail']['version']; |
|
244 | + $username = $GLOBALS['egw_info']['user']['account_lid']; |
|
245 | + $version = $GLOBALS['egw_info']['apps']['mail']['version']; |
|
246 | 246 | |
247 | 247 | //include "$default->lib_dir/version.php"; |
248 | 248 | |
249 | 249 | // lets generate the main body of the script from our rules |
250 | - $enotify = $variables= $supportsbody = false; |
|
250 | + $enotify = $variables = $supportsbody = false; |
|
251 | 251 | if ($connection->hasExtension('enotify')) $enotify = true; |
252 | 252 | if ($connection->hasExtension('variables')) $variables = true; |
253 | 253 | if ($connection->hasExtension('body')) $supportsbody = true; |
@@ -276,83 +276,83 @@ discard block |
||
276 | 276 | |
277 | 277 | if (!$rule['unconditional']) { |
278 | 278 | if (!$continue) $newruletext .= "els"; |
279 | - $newruletext .= "if " . $anyall . " ("; |
|
279 | + $newruletext .= "if ".$anyall." ("; |
|
280 | 280 | if ($rule['from']) { |
281 | - if (preg_match("/^\s*!/", $rule['from'])){ |
|
281 | + if (preg_match("/^\s*!/", $rule['from'])) { |
|
282 | 282 | $newruletext .= 'not '; |
283 | - $rule['from'] = preg_replace("/^\s*!/","",$rule['from']); |
|
283 | + $rule['from'] = preg_replace("/^\s*!/", "", $rule['from']); |
|
284 | 284 | } |
285 | 285 | $match = ':contains'; |
286 | 286 | if (preg_match("/\*|\?/", $rule['from'])) $match = ':matches'; |
287 | 287 | if ($rule['regexp']) $match = ':regex'; |
288 | - $newruletext .= "address " . $match . " [\"From\"]"; |
|
289 | - $newruletext .= " \"" . addslashes($rule['from']) . "\""; |
|
288 | + $newruletext .= "address ".$match." [\"From\"]"; |
|
289 | + $newruletext .= " \"".addslashes($rule['from'])."\""; |
|
290 | 290 | $started = 1; |
291 | 291 | } |
292 | 292 | if ($rule['to']) { |
293 | 293 | if ($started) $newruletext .= ", "; |
294 | - if (preg_match("/^\s*!/", $rule['to'])){ |
|
294 | + if (preg_match("/^\s*!/", $rule['to'])) { |
|
295 | 295 | $newruletext .= 'not '; |
296 | - $rule['to'] = preg_replace("/^\s*!/","",$rule['to']); |
|
296 | + $rule['to'] = preg_replace("/^\s*!/", "", $rule['to']); |
|
297 | 297 | } |
298 | 298 | $match = ':contains'; |
299 | 299 | if (preg_match("/\*|\?/", $rule['to'])) $match = ':matches'; |
300 | 300 | if ($rule['regexp']) $match = ':regex'; |
301 | - $newruletext .= "address " . $match . " [\"To\",\"TO\",\"Cc\",\"CC\"]"; |
|
302 | - $newruletext .= " \"" . addslashes($rule['to']) . "\""; |
|
301 | + $newruletext .= "address ".$match." [\"To\",\"TO\",\"Cc\",\"CC\"]"; |
|
302 | + $newruletext .= " \"".addslashes($rule['to'])."\""; |
|
303 | 303 | $started = 1; |
304 | 304 | } |
305 | 305 | if ($rule['subject']) { |
306 | 306 | if ($started) $newruletext .= ", "; |
307 | - if (preg_match("/^\s*!/", $rule['subject'])){ |
|
307 | + if (preg_match("/^\s*!/", $rule['subject'])) { |
|
308 | 308 | $newruletext .= 'not '; |
309 | - $rule['subject'] = preg_replace("/^\s*!/","",$rule['subject']); |
|
309 | + $rule['subject'] = preg_replace("/^\s*!/", "", $rule['subject']); |
|
310 | 310 | } |
311 | 311 | $match = ':contains'; |
312 | 312 | if (preg_match("/\*|\?/", $rule['subject'])) $match = ':matches'; |
313 | 313 | if ($rule['regexp']) $match = ':regex'; |
314 | - $newruletext .= "header " . $match . " \"subject\""; |
|
315 | - $newruletext .= " \"" . addslashes($rule['subject']) . "\""; |
|
314 | + $newruletext .= "header ".$match." \"subject\""; |
|
315 | + $newruletext .= " \"".addslashes($rule['subject'])."\""; |
|
316 | 316 | $started = 1; |
317 | 317 | } |
318 | 318 | if ($rule['field'] && $rule['field_val']) { |
319 | 319 | if ($started) $newruletext .= ", "; |
320 | - if (preg_match("/^\s*!/", $rule['field_val'])){ |
|
320 | + if (preg_match("/^\s*!/", $rule['field_val'])) { |
|
321 | 321 | $newruletext .= 'not '; |
322 | - $rule['field_val'] = preg_replace("/^\s*!/","",$rule['field_val']); |
|
322 | + $rule['field_val'] = preg_replace("/^\s*!/", "", $rule['field_val']); |
|
323 | 323 | } |
324 | 324 | $match = ':contains'; |
325 | 325 | if (preg_match("/\*|\?/", $rule['field_val'])) $match = ':matches'; |
326 | 326 | if ($rule['regexp']) $match = ':regex'; |
327 | - $newruletext .= "header " . $match . " \"" . addslashes($rule['field']) . "\""; |
|
328 | - $newruletext .= " \"" . addslashes($rule['field_val']) . "\""; |
|
327 | + $newruletext .= "header ".$match." \"".addslashes($rule['field'])."\""; |
|
328 | + $newruletext .= " \"".addslashes($rule['field_val'])."\""; |
|
329 | 329 | $started = 1; |
330 | 330 | } |
331 | 331 | if ($rule['size']) { |
332 | 332 | $xthan = " :under "; |
333 | 333 | if ($rule['gthan']) $xthan = " :over "; |
334 | 334 | if ($started) $newruletext .= ", "; |
335 | - $newruletext .= "size " . $xthan . $rule['size'] . "K"; |
|
335 | + $newruletext .= "size ".$xthan.$rule['size']."K"; |
|
336 | 336 | $started = 1; |
337 | 337 | } |
338 | - if ($supportsbody){ |
|
339 | - if (!empty($rule['field_bodytransform'])){ |
|
338 | + if ($supportsbody) { |
|
339 | + if (!empty($rule['field_bodytransform'])) { |
|
340 | 340 | if ($started) $newruletext .= ", "; |
341 | - $btransform = " :raw "; |
|
341 | + $btransform = " :raw "; |
|
342 | 342 | $match = ' :contains'; |
343 | 343 | if ($rule['bodytransform']) $btransform = " :text "; |
344 | 344 | if (preg_match("/\*|\?/", $rule['field_bodytransform'])) $match = ':matches'; |
345 | 345 | if ($rule['regexp']) $match = ':regex'; |
346 | - $newruletext .= "body " . $btransform . $match . " \"" . $rule['field_bodytransform'] . "\""; |
|
346 | + $newruletext .= "body ".$btransform.$match." \"".$rule['field_bodytransform']."\""; |
|
347 | 347 | $started = 1; |
348 | 348 | |
349 | 349 | } |
350 | - if ($rule['ctype']!= '0' && !empty($rule['ctype'])){ |
|
350 | + if ($rule['ctype'] != '0' && !empty($rule['ctype'])) { |
|
351 | 351 | if ($started) $newruletext .= ", "; |
352 | 352 | $btransform_ctype = self::$btransform_ctype_array[$rule['ctype']]; |
353 | 353 | $ctype_subtype = ""; |
354 | 354 | if ($rule['field_ctype_val']) $ctype_subtype = "/"; |
355 | - $newruletext .= "body :content " . " \"" . $btransform_ctype . $ctype_subtype . $rule['field_ctype_val'] . "\"" . " :contains \"\""; |
|
355 | + $newruletext .= "body :content "." \"".$btransform_ctype.$ctype_subtype.$rule['field_ctype_val']."\""." :contains \"\""; |
|
356 | 356 | $started = 1; |
357 | 357 | //error_log(__CLASS__."::".__METHOD__.array2string(Script::$btransform_ctype_array)); |
358 | 358 | } |
@@ -363,21 +363,21 @@ discard block |
||
363 | 363 | |
364 | 364 | if (!$rule['unconditional']) $newruletext .= ") {\n\t"; |
365 | 365 | |
366 | - if (preg_match("/folder/i",$rule['action'])) { |
|
367 | - $newruletext .= "fileinto \"" . ($utf7imap_fileinto ? |
|
368 | - Translation::convert($rule['action_arg'],'utf-8', 'utf7-imap') : $rule['action_arg']) . "\";"; |
|
366 | + if (preg_match("/folder/i", $rule['action'])) { |
|
367 | + $newruletext .= "fileinto \"".($utf7imap_fileinto ? |
|
368 | + Translation::convert($rule['action_arg'], 'utf-8', 'utf7-imap') : $rule['action_arg'])."\";"; |
|
369 | 369 | } |
370 | - if (preg_match("/reject/i",$rule['action'])) { |
|
371 | - $newruletext .= "reject text: \n" . $rule['action_arg'] . "\n.\n;"; |
|
370 | + if (preg_match("/reject/i", $rule['action'])) { |
|
371 | + $newruletext .= "reject text: \n".$rule['action_arg']."\n.\n;"; |
|
372 | 372 | $rejectused = 1; |
373 | 373 | } |
374 | - if (preg_match("/address/i",$rule['action'])) { |
|
375 | - foreach(preg_split('/, ?/',$rule['action_arg']) as $addr) |
|
374 | + if (preg_match("/address/i", $rule['action'])) { |
|
375 | + foreach (preg_split('/, ?/', $rule['action_arg']) as $addr) |
|
376 | 376 | { |
377 | 377 | $newruletext .= "\tredirect \"".trim($addr)."\";\n"; |
378 | 378 | } |
379 | 379 | } |
380 | - if (preg_match("/discard/i",$rule['action'])) { |
|
380 | + if (preg_match("/discard/i", $rule['action'])) { |
|
381 | 381 | $newruletext .= "discard;"; |
382 | 382 | } |
383 | 383 | if ($rule['keep']) $newruletext .= "\n\tkeep;"; |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | if ($rule['continue']) $continue = 1; |
388 | 388 | if ($rule['unconditional']) $continue = 1; |
389 | 389 | |
390 | - $newscriptbody .= $newruletext . "\n\n"; |
|
390 | + $newscriptbody .= $newruletext."\n\n"; |
|
391 | 391 | |
392 | 392 | } // end 'if ! ENABLED' |
393 | 393 | } |
@@ -396,32 +396,32 @@ discard block |
||
396 | 396 | |
397 | 397 | if ($this->vacation) { |
398 | 398 | $vacation = $this->vacation; |
399 | - if (!$vacation['days']) $vacation['days'] = ($default->vacation_days ? $default->vacation_days:''); |
|
400 | - if (!$vacation['text']) $vacation['text'] = ($default->vacation_text ? $default->vacation_text:''); |
|
399 | + if (!$vacation['days']) $vacation['days'] = ($default->vacation_days ? $default->vacation_days : ''); |
|
400 | + if (!$vacation['text']) $vacation['text'] = ($default->vacation_text ? $default->vacation_text : ''); |
|
401 | 401 | if (!$vacation['status']) $vacation['status'] = 'on'; |
402 | 402 | |
403 | 403 | // filter out invalid addresses. |
404 | 404 | $ok_vaddrs = array(); |
405 | - foreach($vacation['addresses'] as $addr){ |
|
406 | - if ($addr != '' && preg_match("/\@/",$addr)) |
|
407 | - array_push($ok_vaddrs,$addr); |
|
405 | + foreach ($vacation['addresses'] as $addr) { |
|
406 | + if ($addr != '' && preg_match("/\@/", $addr)) |
|
407 | + array_push($ok_vaddrs, $addr); |
|
408 | 408 | } |
409 | 409 | $vacation['addresses'] = $ok_vaddrs; |
410 | 410 | |
411 | - if (!$vacation['addresses'][0]){ |
|
412 | - $defaultaddr = $sieve->user . '@' . $sieve->maildomain; |
|
413 | - array_push($vacation['addresses'],$defaultaddr); |
|
411 | + if (!$vacation['addresses'][0]) { |
|
412 | + $defaultaddr = $sieve->user.'@'.$sieve->maildomain; |
|
413 | + array_push($vacation['addresses'], $defaultaddr); |
|
414 | 414 | } |
415 | - if (($vacation['status'] == 'on' && strlen(trim($vacation['text']))>0)|| $vacation['status'] == 'by_date' && |
|
416 | - $vacation['start_date'] <= time() && time() < $vacation['end_date']+24*3600) // +24*3600 to include the end_date day |
|
415 | + if (($vacation['status'] == 'on' && strlen(trim($vacation['text'])) > 0) || $vacation['status'] == 'by_date' && |
|
416 | + $vacation['start_date'] <= time() && time() < $vacation['end_date'] + 24 * 3600) // +24*3600 to include the end_date day |
|
417 | 417 | { |
418 | 418 | if (trim($vacation['forwards'])) { |
419 | 419 | $if = array(); |
420 | - foreach($vacation['addresses'] as $addr) { |
|
420 | + foreach ($vacation['addresses'] as $addr) { |
|
421 | 421 | $if[] = 'address :contains ["To","TO","Cc","CC"] "'.trim($addr).'"'; |
422 | 422 | } |
423 | - $newscriptbody .= 'if anyof ('.implode(', ',$if).") {\n"; |
|
424 | - foreach(preg_split('/, ?/',$vacation['forwards']) as $addr) { |
|
423 | + $newscriptbody .= 'if anyof ('.implode(', ', $if).") {\n"; |
|
424 | + foreach (preg_split('/, ?/', $vacation['forwards']) as $addr) { |
|
425 | 425 | $newscriptbody .= "\tredirect \"".trim($addr)."\";\n"; |
426 | 426 | } |
427 | 427 | $newscriptbody .= "\tkeep;\n}\n"; |
@@ -442,11 +442,11 @@ discard block |
||
442 | 442 | $newscriptbody .= "if header :contains ".'"X-Spam-Status" '.'"YES"'."{\n\tstop;\n}\n"; //stop vacation reply if it is spam |
443 | 443 | } |
444 | 444 | } |
445 | - $newscriptbody .= "vacation :days " . $vacation['days'] . " :addresses ["; |
|
445 | + $newscriptbody .= "vacation :days ".$vacation['days']." :addresses ["; |
|
446 | 446 | $first = 1; |
447 | 447 | foreach ($vacation['addresses'] as $vaddress) { |
448 | 448 | if (!$first) $newscriptbody .= ", "; |
449 | - $newscriptbody .= "\"" . trim($vaddress) . "\""; |
|
449 | + $newscriptbody .= "\"".trim($vaddress)."\""; |
|
450 | 450 | $first = 0; |
451 | 451 | } |
452 | 452 | $message = $vacation['text']; |
@@ -454,12 +454,12 @@ discard block |
||
454 | 454 | { |
455 | 455 | $format_date = 'd M Y'; // see to it, that there is always a format, because if it is missing - no date will be output |
456 | 456 | if (!empty($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'])) $format_date = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']; |
457 | - $message = str_replace(array('$$start$$','$$end$$'),array( |
|
458 | - date($format_date,$vacation['start_date']), |
|
459 | - date($format_date,$vacation['end_date']), |
|
460 | - ),$message); |
|
457 | + $message = str_replace(array('$$start$$', '$$end$$'), array( |
|
458 | + date($format_date, $vacation['start_date']), |
|
459 | + date($format_date, $vacation['end_date']), |
|
460 | + ), $message); |
|
461 | 461 | } |
462 | - $newscriptbody .= "] text:\n" . $message . "\n.\n;\n\n"; |
|
462 | + $newscriptbody .= "] text:\n".$message."\n.\n;\n\n"; |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | // update with any changes. |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | |
473 | 473 | // format notification body |
474 | 474 | $egw_site_title = $GLOBALS['egw_info']['server']['site_title']; |
475 | - if ($enotify==true) |
|
475 | + if ($enotify == true) |
|
476 | 476 | { |
477 | 477 | $notification_body = lang("You have received a new message on the")." {$egw_site_title}"; |
478 | 478 | if ($variables) |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | } |
489 | 489 | else |
490 | 490 | { |
491 | - $notification_body ="[SIEVE] ".$notification_body; |
|
491 | + $notification_body = "[SIEVE] ".$notification_body; |
|
492 | 492 | } |
493 | 493 | $newscriptbody .= 'notify :message "'.$notification_body.'"'."\n\t".'"mailto:'.$notification_email.'";'."\n"; |
494 | 494 | //$newscriptbody .= 'notify :message "'.$notification_body.'" :method "mailto" :options "'.$notification_email.'?subject='.$notification_subject.'";'."\n"; |
@@ -512,8 +512,8 @@ discard block |
||
512 | 512 | // generate the script head |
513 | 513 | |
514 | 514 | $newscripthead = ""; |
515 | - $newscripthead .= "#Mail filter rules for " . $username . "\n"; |
|
516 | - $newscripthead .= '#Generated by ' . $username . ' using Mail ' . $version . ' ' . date($default->script_date_format); |
|
515 | + $newscripthead .= "#Mail filter rules for ".$username."\n"; |
|
516 | + $newscripthead .= '#Generated by '.$username.' using Mail '.$version.' '.date($default->script_date_format); |
|
517 | 517 | $newscripthead .= "\n"; |
518 | 518 | |
519 | 519 | if ($activerules) { |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | $newscripthead .= ",\"vacation\""; |
525 | 525 | } |
526 | 526 | if ($supportsbody) $newscripthead .= ",\"body\""; |
527 | - if ($this->emailNotification && $this->emailNotification['status'] == 'on') $newscripthead .= ',"'.($enotify?'e':'').'notify"'.($variables?',"variables"':''); // Added email notifications |
|
527 | + if ($this->emailNotification && $this->emailNotification['status'] == 'on') $newscripthead .= ',"'.($enotify ? 'e' : '').'notify"'.($variables ? ',"variables"' : ''); // Added email notifications |
|
528 | 528 | $newscripthead .= "];\n\n"; |
529 | 529 | } else { |
530 | 530 | // no active rules, but might still have an active vacation rule |
@@ -533,17 +533,17 @@ discard block |
||
533 | 533 | { |
534 | 534 | $newscripthead .= "require [\"vacation\""; |
535 | 535 | if ($regexsupported && $regexused) $newscripthead .= ",\"regex\""; |
536 | - $closeRequired=true; |
|
536 | + $closeRequired = true; |
|
537 | 537 | } |
538 | 538 | if ($this->emailNotification && $this->emailNotification['status'] == 'on') |
539 | 539 | { |
540 | 540 | if ($this->vacation && $vacation_active) |
541 | 541 | { |
542 | - $newscripthead .= ",\"".($enotify?'e':'')."notify\"".($variables?',"variables"':'')."];\n\n"; // Added email notifications |
|
542 | + $newscripthead .= ",\"".($enotify ? 'e' : '')."notify\"".($variables ? ',"variables"' : '')."];\n\n"; // Added email notifications |
|
543 | 543 | } |
544 | 544 | else |
545 | 545 | { |
546 | - $newscripthead .= "require [\"".($enotify?'e':'')."notify\"".($variables?',"variables"':'')."];\n\n"; // Added email notifications |
|
546 | + $newscripthead .= "require [\"".($enotify ? 'e' : '')."notify\"".($variables ? ',"variables"' : '')."];\n\n"; // Added email notifications |
|
547 | 547 | } |
548 | 548 | } |
549 | 549 | if ($closeRequired) $newscripthead .= "];\n\n"; |
@@ -559,16 +559,16 @@ discard block |
||
559 | 559 | if ($rule['status'] != 'DELETED') { |
560 | 560 | $rule['action_arg'] = addslashes($rule['action_arg']); |
561 | 561 | // we need to handle \r\n here. |
562 | - $rule['action_arg'] = preg_replace("/\r?\n/","\\n",$rule['action_arg']); |
|
562 | + $rule['action_arg'] = preg_replace("/\r?\n/", "\\n", $rule['action_arg']); |
|
563 | 563 | /* reset priority value. note: we only do this |
564 | 564 | * for compatibility with Websieve. */ |
565 | 565 | $rule['priority'] = $pcount; |
566 | - $newscriptfoot .= "#rule&&" . $rule['priority'] . "&&" . $rule['status'] . "&&" . |
|
567 | - addslashes($rule['from']) . "&&" . addslashes($rule['to']) . "&&" . addslashes($rule['subject']) . "&&" . $rule['action'] . "&&" . |
|
568 | - $rule['action_arg'] . "&&" . $rule['flg'] . "&&" . addslashes($rule['field']) . "&&" . addslashes($rule['field_val']) . "&&" . $rule['size']; |
|
569 | - if ($supportsbody && (!empty($rule['field_bodytransform']) || ($rule['ctype']!= '0' && !empty($rule['ctype'])))) $newscriptfoot .= "&&" . $rule['bodytransform'] . "&&" . $rule['field_bodytransform']. "&&" . $rule['ctype'] . "&&" . $rule['field_ctype_val']; |
|
566 | + $newscriptfoot .= "#rule&&".$rule['priority']."&&".$rule['status']."&&". |
|
567 | + addslashes($rule['from'])."&&".addslashes($rule['to'])."&&".addslashes($rule['subject'])."&&".$rule['action']."&&". |
|
568 | + $rule['action_arg']."&&".$rule['flg']."&&".addslashes($rule['field'])."&&".addslashes($rule['field_val'])."&&".$rule['size']; |
|
569 | + if ($supportsbody && (!empty($rule['field_bodytransform']) || ($rule['ctype'] != '0' && !empty($rule['ctype'])))) $newscriptfoot .= "&&".$rule['bodytransform']."&&".$rule['field_bodytransform']."&&".$rule['ctype']."&&".$rule['field_ctype_val']; |
|
570 | 570 | $newscriptfoot .= "\n"; |
571 | - $pcount = $pcount+2; |
|
571 | + $pcount = $pcount + 2; |
|
572 | 572 | //error_log(__CLASS__."::".__METHOD__.__LINE__.array2string($newscriptfoot)); |
573 | 573 | } |
574 | 574 | } |
@@ -576,28 +576,28 @@ discard block |
||
576 | 576 | if ($this->vacation) |
577 | 577 | { |
578 | 578 | $vacation = $this->vacation; |
579 | - $newscriptfoot .= "#vacation&&" . $vacation['days'] . "&&"; |
|
579 | + $newscriptfoot .= "#vacation&&".$vacation['days']."&&"; |
|
580 | 580 | $first = 1; |
581 | 581 | foreach ($vacation['addresses'] as $address) { |
582 | 582 | if (!$first) $newscriptfoot .= ", "; |
583 | - $newscriptfoot .= "\"" . trim($address) . "\""; |
|
583 | + $newscriptfoot .= "\"".trim($address)."\""; |
|
584 | 584 | $first = 0; |
585 | 585 | } |
586 | 586 | |
587 | - $vacation['text'] = preg_replace("/\r?\n/","\\n",$vacation['text']); |
|
588 | - $newscriptfoot .= "&&" . $vacation['text'] . "&&" . |
|
589 | - ($vacation['status']=='by_date' ? $vacation['start_date'].'-'.$vacation['end_date'] : $vacation['status']); |
|
590 | - if ($vacation['forwards']) $newscriptfoot .= '&&' . $vacation['forwards']; |
|
587 | + $vacation['text'] = preg_replace("/\r?\n/", "\\n", $vacation['text']); |
|
588 | + $newscriptfoot .= "&&".$vacation['text']."&&". |
|
589 | + ($vacation['status'] == 'by_date' ? $vacation['start_date'].'-'.$vacation['end_date'] : $vacation['status']); |
|
590 | + if ($vacation['forwards']) $newscriptfoot .= '&&'.$vacation['forwards']; |
|
591 | 591 | $newscriptfoot .= "\n"; |
592 | 592 | } |
593 | 593 | if ($this->emailNotification) { |
594 | 594 | $emailNotification = $this->emailNotification; |
595 | - $newscriptfoot .= "#notify&&" . $emailNotification['status'] . "&&" . $emailNotification['externalEmail'] . "&&" . $emailNotification['displaySubject'] . "\n"; |
|
595 | + $newscriptfoot .= "#notify&&".$emailNotification['status']."&&".$emailNotification['externalEmail']."&&".$emailNotification['displaySubject']."\n"; |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | $newscriptfoot .= "#mode&&basic\n"; |
599 | 599 | |
600 | - $newscript = $newscripthead . $newscriptbody . $newscriptfoot; |
|
600 | + $newscript = $newscripthead.$newscriptbody.$newscriptfoot; |
|
601 | 601 | $this->script = $newscript; |
602 | 602 | //error_log(__METHOD__.__LINE__.array2string($newscript)); |
603 | 603 | //print "<pre>$newscript</pre>"; exit; |
@@ -606,8 +606,8 @@ discard block |
||
606 | 606 | $connection->installScript($this->name, $newscript, true); |
607 | 607 | } |
608 | 608 | catch (\Exception $e) { |
609 | - $this->errstr = 'updateScript: putscript failed: ' . $e->getMessage().($e->details?': '.$e->details:''); |
|
610 | - if ($regexused&&!$regexsupported) $this->errstr .= " REGEX is not an supported CAPABILITY"; |
|
609 | + $this->errstr = 'updateScript: putscript failed: '.$e->getMessage().($e->details ? ': '.$e->details : ''); |
|
610 | + if ($regexused && !$regexsupported) $this->errstr .= " REGEX is not an supported CAPABILITY"; |
|
611 | 611 | error_log(__METHOD__.__LINE__.' # Error: ->'.$this->errstr); |
612 | 612 | error_log(__METHOD__.__LINE__.' # ScriptName:'.$this->name.' Script:'.$newscript); |
613 | 613 | error_log(__METHOD__.__LINE__.' # Instance='.$GLOBALS['egw_info']['user']['domain'].', User='.$GLOBALS['egw_info']['user']['account_lid']); |
@@ -87,9 +87,13 @@ discard block |
||
87 | 87 | $keepbit = 8; |
88 | 88 | $regexbit = 128; |
89 | 89 | |
90 | - if (!isset($this->name)){ |
|
90 | + if (!isset($this->name)) |
|
91 | + { |
|
91 | 92 | $this->errstr = 'retrieveRules: no script name specified'; |
92 | - if ($this->debug) error_log(__CLASS__.'::'.__METHOD__.": no script name specified"); |
|
93 | + if ($this->debug) |
|
94 | + { |
|
95 | + error_log(__CLASS__.'::'.__METHOD__.": no script name specified"); |
|
96 | + } |
|
93 | 97 | return false; |
94 | 98 | } |
95 | 99 | |
@@ -112,10 +116,14 @@ discard block |
||
112 | 116 | /* next line should be the recognised encoded head. if not, the script |
113 | 117 | * is of an unrecognised format, and we should not overwrite it. */ |
114 | 118 | $line1 = array_shift($lines); |
115 | - if (!preg_match("/^# ?Mail(.*)rules for/", $line1)){ |
|
119 | + if (!preg_match("/^# ?Mail(.*)rules for/", $line1)) |
|
120 | + { |
|
116 | 121 | $this->errstr = 'retrieveRules: encoding not recognised'; |
117 | 122 | $this->so = false; |
118 | - if ($this->debug) error_log(__CLASS__.'::'.__METHOD__.": encoding not recognised"); |
|
123 | + if ($this->debug) |
|
124 | + { |
|
125 | + error_log(__CLASS__.'::'.__METHOD__.": encoding not recognised"); |
|
126 | + } |
|
119 | 127 | return false; |
120 | 128 | } |
121 | 129 | $this->so = true; |
@@ -128,7 +136,8 @@ discard block |
||
128 | 136 | if (preg_match("/^ *#(#PSEUDO|rule|vacation|mode|notify)/i",$line,$matches)) |
129 | 137 | { |
130 | 138 | $line = rtrim($line); |
131 | - switch ($matches[1]){ |
|
139 | + switch ($matches[1]) |
|
140 | + { |
|
132 | 141 | case "rule": |
133 | 142 | $bits = explode("&&", $line); |
134 | 143 | $rule = array(); |
@@ -157,19 +166,22 @@ discard block |
||
157 | 166 | $rule['field_ctype_val'] = ($bits[15]); |
158 | 167 | $rule['unconditional'] = 0; |
159 | 168 | if (!$rule['from'] && !$rule['to'] && !$rule['subject'] && |
160 | - !$rule['field'] && !$rule['size'] && $rule['action']) { |
|
169 | + !$rule['field'] && !$rule['size'] && $rule['action']) |
|
170 | + { |
|
161 | 171 | $rule['unconditional'] = 1; |
162 | 172 | } |
163 | 173 | |
164 | 174 | array_push($rules,$rule); |
165 | 175 | |
166 | - if ($rule['priority'] > $this->pcount) { |
|
176 | + if ($rule['priority'] > $this->pcount) |
|
177 | + { |
|
167 | 178 | $this->pcount = $rule['priority']; |
168 | 179 | } |
169 | 180 | break; |
170 | 181 | case "vacation" : |
171 | 182 | if (preg_match("/^ *#vacation&&(.*)&&(.*)&&(.*)&&(.*)&&(.*)/i",$line,$bits) || |
172 | - preg_match("/^ *#vacation&&(.*)&&(.*)&&(.*)&&(.*)/i",$line,$bits)) { |
|
183 | + preg_match("/^ *#vacation&&(.*)&&(.*)&&(.*)&&(.*)/i",$line,$bits)) |
|
184 | + { |
|
173 | 185 | $vacation['days'] = $bits[1]; |
174 | 186 | $vaddresslist = preg_replace("/\"|\s/","",$bits[2]); |
175 | 187 | $vaddresses = preg_split("/,/",$vaddresslist); |
@@ -193,20 +205,27 @@ discard block |
||
193 | 205 | } |
194 | 206 | break; |
195 | 207 | case "notify": |
196 | - if (preg_match("/^ *#notify&&(.*)&&(.*)&&(.*)/i",$line,$bits)) { |
|
208 | + if (preg_match("/^ *#notify&&(.*)&&(.*)&&(.*)/i",$line,$bits)) |
|
209 | + { |
|
197 | 210 | $emailNotification['status'] = $bits[1]; |
198 | 211 | $emailNotification['externalEmail'] = $bits[2]; |
199 | 212 | $emailNotification['displaySubject'] = $bits[3]; |
200 | 213 | } |
201 | 214 | break; |
202 | 215 | case "mode" : |
203 | - if (preg_match("/^ *#mode&&(.*)/i",$line,$bits)){ |
|
216 | + if (preg_match("/^ *#mode&&(.*)/i",$line,$bits)) |
|
217 | + { |
|
204 | 218 | if ($bits[1] == 'basic') |
205 | - $this->mode = 'basic'; |
|
219 | + { |
|
220 | + $this->mode = 'basic'; |
|
221 | + } |
|
206 | 222 | elseif ($bits[1] == 'advanced') |
207 | - $this->mode = 'advanced'; |
|
208 | - else |
|
209 | - $this->mode = 'unknown'; |
|
223 | + { |
|
224 | + $this->mode = 'advanced'; |
|
225 | + } |
|
226 | + else { |
|
227 | + $this->mode = 'unknown'; |
|
228 | + } |
|
210 | 229 | } |
211 | 230 | } |
212 | 231 | } |
@@ -216,9 +235,15 @@ discard block |
||
216 | 235 | $this->script = $script; |
217 | 236 | $this->rules = $rules; |
218 | 237 | $this->vacation = $vacation; |
219 | - if (!$connection->hasExtension('vacation')) $this->vacation = false; |
|
238 | + if (!$connection->hasExtension('vacation')) |
|
239 | + { |
|
240 | + $this->vacation = false; |
|
241 | + } |
|
220 | 242 | $this->emailNotification = $emailNotification; // Added email notifications |
221 | - if ($this->debug) error_log(__CLASS__.'::'.__METHOD__.": Script succesful retrieved: ".print_r($vacation,true)); |
|
243 | + if ($this->debug) |
|
244 | + { |
|
245 | + error_log(__CLASS__.'::'.__METHOD__.": Script succesful retrieved: ".print_r($vacation,true)); |
|
246 | + } |
|
222 | 247 | |
223 | 248 | return true; |
224 | 249 | } |
@@ -248,110 +273,206 @@ discard block |
||
248 | 273 | |
249 | 274 | // lets generate the main body of the script from our rules |
250 | 275 | $enotify = $variables= $supportsbody = false; |
251 | - if ($connection->hasExtension('enotify')) $enotify = true; |
|
252 | - if ($connection->hasExtension('variables')) $variables = true; |
|
253 | - if ($connection->hasExtension('body')) $supportsbody = true; |
|
254 | - if (!$connection->hasExtension('vacation')) $this->vacation = false; |
|
255 | - if (!$connection->hasExtension('regex')) $regexsupported = false; |
|
276 | + if ($connection->hasExtension('enotify')) |
|
277 | + { |
|
278 | + $enotify = true; |
|
279 | + } |
|
280 | + if ($connection->hasExtension('variables')) |
|
281 | + { |
|
282 | + $variables = true; |
|
283 | + } |
|
284 | + if ($connection->hasExtension('body')) |
|
285 | + { |
|
286 | + $supportsbody = true; |
|
287 | + } |
|
288 | + if (!$connection->hasExtension('vacation')) |
|
289 | + { |
|
290 | + $this->vacation = false; |
|
291 | + } |
|
292 | + if (!$connection->hasExtension('regex')) |
|
293 | + { |
|
294 | + $regexsupported = false; |
|
295 | + } |
|
256 | 296 | |
257 | 297 | $newscriptbody = ""; |
258 | 298 | $continue = 1; |
259 | 299 | |
260 | - foreach ($this->rules as $rule) { |
|
300 | + foreach ($this->rules as $rule) |
|
301 | + { |
|
261 | 302 | $newruletext = ""; |
262 | 303 | |
263 | 304 | // don't print this rule if disabled. |
264 | - if ($rule['status'] != 'ENABLED') { |
|
265 | - } else { |
|
305 | + if ($rule['status'] != 'ENABLED') |
|
306 | + { |
|
307 | + } |
|
308 | + else |
|
309 | + { |
|
266 | 310 | $activerules = 1; |
267 | 311 | |
268 | 312 | // conditions |
269 | 313 | |
270 | 314 | $anyall = "allof"; |
271 | - if ($rule['anyof']) $anyall = "anyof"; |
|
272 | - if ($rule['regexp']) { |
|
315 | + if ($rule['anyof']) |
|
316 | + { |
|
317 | + $anyall = "anyof"; |
|
318 | + } |
|
319 | + if ($rule['regexp']) |
|
320 | + { |
|
273 | 321 | $regexused = 1; |
274 | 322 | } |
275 | 323 | $started = 0; |
276 | 324 | |
277 | - if (!$rule['unconditional']) { |
|
278 | - if (!$continue) $newruletext .= "els"; |
|
325 | + if (!$rule['unconditional']) |
|
326 | + { |
|
327 | + if (!$continue) |
|
328 | + { |
|
329 | + $newruletext .= "els"; |
|
330 | + } |
|
279 | 331 | $newruletext .= "if " . $anyall . " ("; |
280 | - if ($rule['from']) { |
|
281 | - if (preg_match("/^\s*!/", $rule['from'])){ |
|
332 | + if ($rule['from']) |
|
333 | + { |
|
334 | + if (preg_match("/^\s*!/", $rule['from'])) |
|
335 | + { |
|
282 | 336 | $newruletext .= 'not '; |
283 | 337 | $rule['from'] = preg_replace("/^\s*!/","",$rule['from']); |
284 | 338 | } |
285 | 339 | $match = ':contains'; |
286 | - if (preg_match("/\*|\?/", $rule['from'])) $match = ':matches'; |
|
287 | - if ($rule['regexp']) $match = ':regex'; |
|
340 | + if (preg_match("/\*|\?/", $rule['from'])) |
|
341 | + { |
|
342 | + $match = ':matches'; |
|
343 | + } |
|
344 | + if ($rule['regexp']) |
|
345 | + { |
|
346 | + $match = ':regex'; |
|
347 | + } |
|
288 | 348 | $newruletext .= "address " . $match . " [\"From\"]"; |
289 | 349 | $newruletext .= " \"" . addslashes($rule['from']) . "\""; |
290 | 350 | $started = 1; |
291 | 351 | } |
292 | - if ($rule['to']) { |
|
293 | - if ($started) $newruletext .= ", "; |
|
294 | - if (preg_match("/^\s*!/", $rule['to'])){ |
|
352 | + if ($rule['to']) |
|
353 | + { |
|
354 | + if ($started) |
|
355 | + { |
|
356 | + $newruletext .= ", "; |
|
357 | + } |
|
358 | + if (preg_match("/^\s*!/", $rule['to'])) |
|
359 | + { |
|
295 | 360 | $newruletext .= 'not '; |
296 | 361 | $rule['to'] = preg_replace("/^\s*!/","",$rule['to']); |
297 | 362 | } |
298 | 363 | $match = ':contains'; |
299 | - if (preg_match("/\*|\?/", $rule['to'])) $match = ':matches'; |
|
300 | - if ($rule['regexp']) $match = ':regex'; |
|
364 | + if (preg_match("/\*|\?/", $rule['to'])) |
|
365 | + { |
|
366 | + $match = ':matches'; |
|
367 | + } |
|
368 | + if ($rule['regexp']) |
|
369 | + { |
|
370 | + $match = ':regex'; |
|
371 | + } |
|
301 | 372 | $newruletext .= "address " . $match . " [\"To\",\"TO\",\"Cc\",\"CC\"]"; |
302 | 373 | $newruletext .= " \"" . addslashes($rule['to']) . "\""; |
303 | 374 | $started = 1; |
304 | 375 | } |
305 | - if ($rule['subject']) { |
|
306 | - if ($started) $newruletext .= ", "; |
|
307 | - if (preg_match("/^\s*!/", $rule['subject'])){ |
|
376 | + if ($rule['subject']) |
|
377 | + { |
|
378 | + if ($started) |
|
379 | + { |
|
380 | + $newruletext .= ", "; |
|
381 | + } |
|
382 | + if (preg_match("/^\s*!/", $rule['subject'])) |
|
383 | + { |
|
308 | 384 | $newruletext .= 'not '; |
309 | 385 | $rule['subject'] = preg_replace("/^\s*!/","",$rule['subject']); |
310 | 386 | } |
311 | 387 | $match = ':contains'; |
312 | - if (preg_match("/\*|\?/", $rule['subject'])) $match = ':matches'; |
|
313 | - if ($rule['regexp']) $match = ':regex'; |
|
388 | + if (preg_match("/\*|\?/", $rule['subject'])) |
|
389 | + { |
|
390 | + $match = ':matches'; |
|
391 | + } |
|
392 | + if ($rule['regexp']) |
|
393 | + { |
|
394 | + $match = ':regex'; |
|
395 | + } |
|
314 | 396 | $newruletext .= "header " . $match . " \"subject\""; |
315 | 397 | $newruletext .= " \"" . addslashes($rule['subject']) . "\""; |
316 | 398 | $started = 1; |
317 | 399 | } |
318 | - if ($rule['field'] && $rule['field_val']) { |
|
319 | - if ($started) $newruletext .= ", "; |
|
320 | - if (preg_match("/^\s*!/", $rule['field_val'])){ |
|
400 | + if ($rule['field'] && $rule['field_val']) |
|
401 | + { |
|
402 | + if ($started) |
|
403 | + { |
|
404 | + $newruletext .= ", "; |
|
405 | + } |
|
406 | + if (preg_match("/^\s*!/", $rule['field_val'])) |
|
407 | + { |
|
321 | 408 | $newruletext .= 'not '; |
322 | 409 | $rule['field_val'] = preg_replace("/^\s*!/","",$rule['field_val']); |
323 | 410 | } |
324 | 411 | $match = ':contains'; |
325 | - if (preg_match("/\*|\?/", $rule['field_val'])) $match = ':matches'; |
|
326 | - if ($rule['regexp']) $match = ':regex'; |
|
412 | + if (preg_match("/\*|\?/", $rule['field_val'])) |
|
413 | + { |
|
414 | + $match = ':matches'; |
|
415 | + } |
|
416 | + if ($rule['regexp']) |
|
417 | + { |
|
418 | + $match = ':regex'; |
|
419 | + } |
|
327 | 420 | $newruletext .= "header " . $match . " \"" . addslashes($rule['field']) . "\""; |
328 | 421 | $newruletext .= " \"" . addslashes($rule['field_val']) . "\""; |
329 | 422 | $started = 1; |
330 | 423 | } |
331 | - if ($rule['size']) { |
|
424 | + if ($rule['size']) |
|
425 | + { |
|
332 | 426 | $xthan = " :under "; |
333 | - if ($rule['gthan']) $xthan = " :over "; |
|
334 | - if ($started) $newruletext .= ", "; |
|
427 | + if ($rule['gthan']) |
|
428 | + { |
|
429 | + $xthan = " :over "; |
|
430 | + } |
|
431 | + if ($started) |
|
432 | + { |
|
433 | + $newruletext .= ", "; |
|
434 | + } |
|
335 | 435 | $newruletext .= "size " . $xthan . $rule['size'] . "K"; |
336 | 436 | $started = 1; |
337 | 437 | } |
338 | - if ($supportsbody){ |
|
339 | - if (!empty($rule['field_bodytransform'])){ |
|
340 | - if ($started) $newruletext .= ", "; |
|
438 | + if ($supportsbody) |
|
439 | + { |
|
440 | + if (!empty($rule['field_bodytransform'])) |
|
441 | + { |
|
442 | + if ($started) |
|
443 | + { |
|
444 | + $newruletext .= ", "; |
|
445 | + } |
|
341 | 446 | $btransform = " :raw "; |
342 | 447 | $match = ' :contains'; |
343 | - if ($rule['bodytransform']) $btransform = " :text "; |
|
344 | - if (preg_match("/\*|\?/", $rule['field_bodytransform'])) $match = ':matches'; |
|
345 | - if ($rule['regexp']) $match = ':regex'; |
|
448 | + if ($rule['bodytransform']) |
|
449 | + { |
|
450 | + $btransform = " :text "; |
|
451 | + } |
|
452 | + if (preg_match("/\*|\?/", $rule['field_bodytransform'])) |
|
453 | + { |
|
454 | + $match = ':matches'; |
|
455 | + } |
|
456 | + if ($rule['regexp']) |
|
457 | + { |
|
458 | + $match = ':regex'; |
|
459 | + } |
|
346 | 460 | $newruletext .= "body " . $btransform . $match . " \"" . $rule['field_bodytransform'] . "\""; |
347 | 461 | $started = 1; |
348 | 462 | |
349 | 463 | } |
350 | - if ($rule['ctype']!= '0' && !empty($rule['ctype'])){ |
|
351 | - if ($started) $newruletext .= ", "; |
|
464 | + if ($rule['ctype']!= '0' && !empty($rule['ctype'])) |
|
465 | + { |
|
466 | + if ($started) |
|
467 | + { |
|
468 | + $newruletext .= ", "; |
|
469 | + } |
|
352 | 470 | $btransform_ctype = self::$btransform_ctype_array[$rule['ctype']]; |
353 | 471 | $ctype_subtype = ""; |
354 | - if ($rule['field_ctype_val']) $ctype_subtype = "/"; |
|
472 | + if ($rule['field_ctype_val']) |
|
473 | + { |
|
474 | + $ctype_subtype = "/"; |
|
475 | + } |
|
355 | 476 | $newruletext .= "body :content " . " \"" . $btransform_ctype . $ctype_subtype . $rule['field_ctype_val'] . "\"" . " :contains \"\""; |
356 | 477 | $started = 1; |
357 | 478 | //error_log(__CLASS__."::".__METHOD__.array2string(Script::$btransform_ctype_array)); |
@@ -361,31 +482,50 @@ discard block |
||
361 | 482 | |
362 | 483 | // actions |
363 | 484 | |
364 | - if (!$rule['unconditional']) $newruletext .= ") {\n\t"; |
|
485 | + if (!$rule['unconditional']) |
|
486 | + { |
|
487 | + $newruletext .= ") {\n\t"; |
|
488 | + } |
|
365 | 489 | |
366 | - if (preg_match("/folder/i",$rule['action'])) { |
|
490 | + if (preg_match("/folder/i",$rule['action'])) |
|
491 | + { |
|
367 | 492 | $newruletext .= "fileinto \"" . ($utf7imap_fileinto ? |
368 | 493 | Translation::convert($rule['action_arg'],'utf-8', 'utf7-imap') : $rule['action_arg']) . "\";"; |
369 | 494 | } |
370 | - if (preg_match("/reject/i",$rule['action'])) { |
|
495 | + if (preg_match("/reject/i",$rule['action'])) |
|
496 | + { |
|
371 | 497 | $newruletext .= "reject text: \n" . $rule['action_arg'] . "\n.\n;"; |
372 | 498 | $rejectused = 1; |
373 | 499 | } |
374 | - if (preg_match("/address/i",$rule['action'])) { |
|
500 | + if (preg_match("/address/i",$rule['action'])) |
|
501 | + { |
|
375 | 502 | foreach(preg_split('/, ?/',$rule['action_arg']) as $addr) |
376 | 503 | { |
377 | 504 | $newruletext .= "\tredirect \"".trim($addr)."\";\n"; |
378 | 505 | } |
379 | 506 | } |
380 | - if (preg_match("/discard/i",$rule['action'])) { |
|
507 | + if (preg_match("/discard/i",$rule['action'])) |
|
508 | + { |
|
381 | 509 | $newruletext .= "discard;"; |
382 | 510 | } |
383 | - if ($rule['keep']) $newruletext .= "\n\tkeep;"; |
|
384 | - if (!$rule['unconditional']) $newruletext .= "\n}"; |
|
511 | + if ($rule['keep']) |
|
512 | + { |
|
513 | + $newruletext .= "\n\tkeep;"; |
|
514 | + } |
|
515 | + if (!$rule['unconditional']) |
|
516 | + { |
|
517 | + $newruletext .= "\n}"; |
|
518 | + } |
|
385 | 519 | |
386 | 520 | $continue = 0; |
387 | - if ($rule['continue']) $continue = 1; |
|
388 | - if ($rule['unconditional']) $continue = 1; |
|
521 | + if ($rule['continue']) |
|
522 | + { |
|
523 | + $continue = 1; |
|
524 | + } |
|
525 | + if ($rule['unconditional']) |
|
526 | + { |
|
527 | + $continue = 1; |
|
528 | + } |
|
389 | 529 | |
390 | 530 | $newscriptbody .= $newruletext . "\n\n"; |
391 | 531 | |
@@ -394,34 +534,53 @@ discard block |
||
394 | 534 | |
395 | 535 | // vacation rule |
396 | 536 | |
397 | - if ($this->vacation) { |
|
537 | + if ($this->vacation) |
|
538 | + { |
|
398 | 539 | $vacation = $this->vacation; |
399 | - if (!$vacation['days']) $vacation['days'] = ($default->vacation_days ? $default->vacation_days:''); |
|
400 | - if (!$vacation['text']) $vacation['text'] = ($default->vacation_text ? $default->vacation_text:''); |
|
401 | - if (!$vacation['status']) $vacation['status'] = 'on'; |
|
540 | + if (!$vacation['days']) |
|
541 | + { |
|
542 | + $vacation['days'] = ($default->vacation_days ? $default->vacation_days:''); |
|
543 | + } |
|
544 | + if (!$vacation['text']) |
|
545 | + { |
|
546 | + $vacation['text'] = ($default->vacation_text ? $default->vacation_text:''); |
|
547 | + } |
|
548 | + if (!$vacation['status']) |
|
549 | + { |
|
550 | + $vacation['status'] = 'on'; |
|
551 | + } |
|
402 | 552 | |
403 | 553 | // filter out invalid addresses. |
404 | 554 | $ok_vaddrs = array(); |
405 | - foreach($vacation['addresses'] as $addr){ |
|
555 | + foreach($vacation['addresses'] as $addr) |
|
556 | + { |
|
406 | 557 | if ($addr != '' && preg_match("/\@/",$addr)) |
407 | - array_push($ok_vaddrs,$addr); |
|
558 | + { |
|
559 | + array_push($ok_vaddrs,$addr); |
|
560 | + } |
|
408 | 561 | } |
409 | 562 | $vacation['addresses'] = $ok_vaddrs; |
410 | 563 | |
411 | - if (!$vacation['addresses'][0]){ |
|
564 | + if (!$vacation['addresses'][0]) |
|
565 | + { |
|
412 | 566 | $defaultaddr = $sieve->user . '@' . $sieve->maildomain; |
413 | 567 | array_push($vacation['addresses'],$defaultaddr); |
414 | 568 | } |
415 | 569 | if (($vacation['status'] == 'on' && strlen(trim($vacation['text']))>0)|| $vacation['status'] == 'by_date' && |
416 | - $vacation['start_date'] <= time() && time() < $vacation['end_date']+24*3600) // +24*3600 to include the end_date day |
|
570 | + $vacation['start_date'] <= time() && time() < $vacation['end_date']+24*3600) |
|
571 | + { |
|
572 | + // +24*3600 to include the end_date day |
|
417 | 573 | { |
418 | 574 | if (trim($vacation['forwards'])) { |
419 | 575 | $if = array(); |
420 | - foreach($vacation['addresses'] as $addr) { |
|
576 | + } |
|
577 | + foreach($vacation['addresses'] as $addr) |
|
578 | + { |
|
421 | 579 | $if[] = 'address :contains ["To","TO","Cc","CC"] "'.trim($addr).'"'; |
422 | 580 | } |
423 | 581 | $newscriptbody .= 'if anyof ('.implode(', ',$if).") {\n"; |
424 | - foreach(preg_split('/, ?/',$vacation['forwards']) as $addr) { |
|
582 | + foreach(preg_split('/, ?/',$vacation['forwards']) as $addr) |
|
583 | + { |
|
425 | 584 | $newscriptbody .= "\tredirect \"".trim($addr)."\";\n"; |
426 | 585 | } |
427 | 586 | $newscriptbody .= "\tkeep;\n}\n"; |
@@ -444,8 +603,12 @@ discard block |
||
444 | 603 | } |
445 | 604 | $newscriptbody .= "vacation :days " . $vacation['days'] . " :addresses ["; |
446 | 605 | $first = 1; |
447 | - foreach ($vacation['addresses'] as $vaddress) { |
|
448 | - if (!$first) $newscriptbody .= ", "; |
|
606 | + foreach ($vacation['addresses'] as $vaddress) |
|
607 | + { |
|
608 | + if (!$first) |
|
609 | + { |
|
610 | + $newscriptbody .= ", "; |
|
611 | + } |
|
449 | 612 | $newscriptbody .= "\"" . trim($vaddress) . "\""; |
450 | 613 | $first = 0; |
451 | 614 | } |
@@ -453,7 +616,10 @@ discard block |
||
453 | 616 | if ($vacation['start_date'] || $vacation['end_date']) |
454 | 617 | { |
455 | 618 | $format_date = 'd M Y'; // see to it, that there is always a format, because if it is missing - no date will be output |
456 | - if (!empty($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'])) $format_date = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']; |
|
619 | + if (!empty($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'])) |
|
620 | + { |
|
621 | + $format_date = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']; |
|
622 | + } |
|
457 | 623 | $message = str_replace(array('$$start$$','$$end$$'),array( |
458 | 624 | date($format_date,$vacation['start_date']), |
459 | 625 | date($format_date,$vacation['end_date']), |
@@ -466,7 +632,8 @@ discard block |
||
466 | 632 | $this->vacation = $vacation; |
467 | 633 | } |
468 | 634 | |
469 | - if ($this->emailNotification && $this->emailNotification['status'] == 'on') { |
|
635 | + if ($this->emailNotification && $this->emailNotification['status'] == 'on') |
|
636 | + { |
|
470 | 637 | // format notification email header components |
471 | 638 | $notification_email = $this->emailNotification['externalEmail']; |
472 | 639 | |
@@ -479,7 +646,8 @@ discard block |
||
479 | 646 | { |
480 | 647 | $notification_body .= ", "; |
481 | 648 | $notification_body .= 'From: ${from}'; |
482 | - if ($this->emailNotification['displaySubject']) { |
|
649 | + if ($this->emailNotification['displaySubject']) |
|
650 | + { |
|
483 | 651 | $notification_body .= ', Subject: ${subject}'; |
484 | 652 | } |
485 | 653 | //$notification_body .= 'Size: $size$'."\n"; |
@@ -498,7 +666,8 @@ discard block |
||
498 | 666 | $notification_body = lang("You have received a new message on the")." {$egw_site_title}"."\n"; |
499 | 667 | $notification_body .= "\n"; |
500 | 668 | $notification_body .= 'From: $from$'."\n"; |
501 | - if ($this->emailNotification['displaySubject']) { |
|
669 | + if ($this->emailNotification['displaySubject']) |
|
670 | + { |
|
502 | 671 | $notification_body .= 'Subject: $subject$'."\n"; |
503 | 672 | } |
504 | 673 | //$notification_body .= 'Size: $size$'."\n"; |
@@ -516,23 +685,43 @@ discard block |
||
516 | 685 | $newscripthead .= '#Generated by ' . $username . ' using Mail ' . $version . ' ' . date($default->script_date_format); |
517 | 686 | $newscripthead .= "\n"; |
518 | 687 | |
519 | - if ($activerules) { |
|
688 | + if ($activerules) |
|
689 | + { |
|
520 | 690 | $newscripthead .= "require [\"fileinto\""; |
521 | - if ($regexsupported && $regexused) $newscripthead .= ",\"regex\""; |
|
522 | - if ($rejectused) $newscripthead .= ",\"reject\""; |
|
523 | - if ($this->vacation && $vacation_active) { |
|
691 | + if ($regexsupported && $regexused) |
|
692 | + { |
|
693 | + $newscripthead .= ",\"regex\""; |
|
694 | + } |
|
695 | + if ($rejectused) |
|
696 | + { |
|
697 | + $newscripthead .= ",\"reject\""; |
|
698 | + } |
|
699 | + if ($this->vacation && $vacation_active) |
|
700 | + { |
|
524 | 701 | $newscripthead .= ",\"vacation\""; |
525 | 702 | } |
526 | - if ($supportsbody) $newscripthead .= ",\"body\""; |
|
527 | - if ($this->emailNotification && $this->emailNotification['status'] == 'on') $newscripthead .= ',"'.($enotify?'e':'').'notify"'.($variables?',"variables"':''); // Added email notifications |
|
703 | + if ($supportsbody) |
|
704 | + { |
|
705 | + $newscripthead .= ",\"body\""; |
|
706 | + } |
|
707 | + if ($this->emailNotification && $this->emailNotification['status'] == 'on') |
|
708 | + { |
|
709 | + $newscripthead .= ',"'.($enotify?'e':'').'notify"'.($variables?',"variables"':''); |
|
710 | + } |
|
711 | + // Added email notifications |
|
528 | 712 | $newscripthead .= "];\n\n"; |
529 | - } else { |
|
713 | + } |
|
714 | + else |
|
715 | + { |
|
530 | 716 | // no active rules, but might still have an active vacation rule |
531 | 717 | $closeRequired = false; |
532 | 718 | if ($this->vacation && $vacation_active) |
533 | 719 | { |
534 | 720 | $newscripthead .= "require [\"vacation\""; |
535 | - if ($regexsupported && $regexused) $newscripthead .= ",\"regex\""; |
|
721 | + if ($regexsupported && $regexused) |
|
722 | + { |
|
723 | + $newscripthead .= ",\"regex\""; |
|
724 | + } |
|
536 | 725 | $closeRequired=true; |
537 | 726 | } |
538 | 727 | if ($this->emailNotification && $this->emailNotification['status'] == 'on') |
@@ -546,7 +735,10 @@ discard block |
||
546 | 735 | $newscripthead .= "require [\"".($enotify?'e':'')."notify\"".($variables?',"variables"':'')."];\n\n"; // Added email notifications |
547 | 736 | } |
548 | 737 | } |
549 | - if ($closeRequired) $newscripthead .= "];\n\n"; |
|
738 | + if ($closeRequired) |
|
739 | + { |
|
740 | + $newscripthead .= "];\n\n"; |
|
741 | + } |
|
550 | 742 | } |
551 | 743 | |
552 | 744 | // generate the encoded script foot |
@@ -554,9 +746,11 @@ discard block |
||
554 | 746 | $newscriptfoot = ""; |
555 | 747 | $pcount = 1; |
556 | 748 | $newscriptfoot .= "##PSEUDO script start\n"; |
557 | - foreach ($this->rules as $rule) { |
|
749 | + foreach ($this->rules as $rule) |
|
750 | + { |
|
558 | 751 | // only add rule to foot if status != deleted. this is how we delete a rule. |
559 | - if ($rule['status'] != 'DELETED') { |
|
752 | + if ($rule['status'] != 'DELETED') |
|
753 | + { |
|
560 | 754 | $rule['action_arg'] = addslashes($rule['action_arg']); |
561 | 755 | // we need to handle \r\n here. |
562 | 756 | $rule['action_arg'] = preg_replace("/\r?\n/","\\n",$rule['action_arg']); |
@@ -566,7 +760,10 @@ discard block |
||
566 | 760 | $newscriptfoot .= "#rule&&" . $rule['priority'] . "&&" . $rule['status'] . "&&" . |
567 | 761 | addslashes($rule['from']) . "&&" . addslashes($rule['to']) . "&&" . addslashes($rule['subject']) . "&&" . $rule['action'] . "&&" . |
568 | 762 | $rule['action_arg'] . "&&" . $rule['flg'] . "&&" . addslashes($rule['field']) . "&&" . addslashes($rule['field_val']) . "&&" . $rule['size']; |
569 | - if ($supportsbody && (!empty($rule['field_bodytransform']) || ($rule['ctype']!= '0' && !empty($rule['ctype'])))) $newscriptfoot .= "&&" . $rule['bodytransform'] . "&&" . $rule['field_bodytransform']. "&&" . $rule['ctype'] . "&&" . $rule['field_ctype_val']; |
|
763 | + if ($supportsbody && (!empty($rule['field_bodytransform']) || ($rule['ctype']!= '0' && !empty($rule['ctype'])))) |
|
764 | + { |
|
765 | + $newscriptfoot .= "&&" . $rule['bodytransform'] . "&&" . $rule['field_bodytransform']. "&&" . $rule['ctype'] . "&&" . $rule['field_ctype_val']; |
|
766 | + } |
|
570 | 767 | $newscriptfoot .= "\n"; |
571 | 768 | $pcount = $pcount+2; |
572 | 769 | //error_log(__CLASS__."::".__METHOD__.__LINE__.array2string($newscriptfoot)); |
@@ -578,8 +775,12 @@ discard block |
||
578 | 775 | $vacation = $this->vacation; |
579 | 776 | $newscriptfoot .= "#vacation&&" . $vacation['days'] . "&&"; |
580 | 777 | $first = 1; |
581 | - foreach ($vacation['addresses'] as $address) { |
|
582 | - if (!$first) $newscriptfoot .= ", "; |
|
778 | + foreach ($vacation['addresses'] as $address) |
|
779 | + { |
|
780 | + if (!$first) |
|
781 | + { |
|
782 | + $newscriptfoot .= ", "; |
|
783 | + } |
|
583 | 784 | $newscriptfoot .= "\"" . trim($address) . "\""; |
584 | 785 | $first = 0; |
585 | 786 | } |
@@ -587,10 +788,14 @@ discard block |
||
587 | 788 | $vacation['text'] = preg_replace("/\r?\n/","\\n",$vacation['text']); |
588 | 789 | $newscriptfoot .= "&&" . $vacation['text'] . "&&" . |
589 | 790 | ($vacation['status']=='by_date' ? $vacation['start_date'].'-'.$vacation['end_date'] : $vacation['status']); |
590 | - if ($vacation['forwards']) $newscriptfoot .= '&&' . $vacation['forwards']; |
|
791 | + if ($vacation['forwards']) |
|
792 | + { |
|
793 | + $newscriptfoot .= '&&' . $vacation['forwards']; |
|
794 | + } |
|
591 | 795 | $newscriptfoot .= "\n"; |
592 | 796 | } |
593 | - if ($this->emailNotification) { |
|
797 | + if ($this->emailNotification) |
|
798 | + { |
|
594 | 799 | $emailNotification = $this->emailNotification; |
595 | 800 | $newscriptfoot .= "#notify&&" . $emailNotification['status'] . "&&" . $emailNotification['externalEmail'] . "&&" . $emailNotification['displaySubject'] . "\n"; |
596 | 801 | } |
@@ -607,7 +812,10 @@ discard block |
||
607 | 812 | } |
608 | 813 | catch (\Exception $e) { |
609 | 814 | $this->errstr = 'updateScript: putscript failed: ' . $e->getMessage().($e->details?': '.$e->details:''); |
610 | - if ($regexused&&!$regexsupported) $this->errstr .= " REGEX is not an supported CAPABILITY"; |
|
815 | + if ($regexused&&!$regexsupported) |
|
816 | + { |
|
817 | + $this->errstr .= " REGEX is not an supported CAPABILITY"; |
|
818 | + } |
|
611 | 819 | error_log(__METHOD__.__LINE__.' # Error: ->'.$this->errstr); |
612 | 820 | error_log(__METHOD__.__LINE__.' # ScriptName:'.$this->name.' Script:'.$newscript); |
613 | 821 | error_log(__METHOD__.__LINE__.' # Instance='.$GLOBALS['egw_info']['user']['domain'].', User='.$GLOBALS['egw_info']['user']['account_lid']); |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | function deleteAccount($_hookValues) |
63 | 63 | { |
64 | 64 | // some precausion to really delete just _one_ account |
65 | - if (strpos($_hookValues['account_lid'],'%') !== false || |
|
66 | - strpos($_hookValues['account_lid'],'*') !== false) |
|
65 | + if (strpos($_hookValues['account_lid'], '%') !== false || |
|
66 | + strpos($_hookValues['account_lid'], '*') !== false) |
|
67 | 67 | { |
68 | 68 | return false; |
69 | 69 | } |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | * @return string $username='%' username containing wildcards, default '%' for all users of a domain |
79 | 79 | * @return int|boolean number of deleted mailboxes on success or false on error |
80 | 80 | */ |
81 | - function deleteUsers($username='%') |
|
81 | + function deleteUsers($username = '%') |
|
82 | 82 | { |
83 | - if(!$this->acc_imap_administration || empty($username)) |
|
83 | + if (!$this->acc_imap_administration || empty($username)) |
|
84 | 84 | { |
85 | 85 | return false; |
86 | 86 | } |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | $mboxes = (array)$this->getMailboxes($mailboxName, 1); |
95 | 95 | //error_log(__METHOD__."('$username') getMailboxes('$reference','$username$restriction') = ".array2string($mboxes)); |
96 | 96 | |
97 | - foreach(array_keys($mboxes) as $mbox) |
|
97 | + foreach (array_keys($mboxes) as $mbox) |
|
98 | 98 | { |
99 | 99 | // give the admin account the rights to delete this mailbox |
100 | 100 | $this->setACL($mbox, $this->acc_imap_admin_username, array('rights' => 'aeiklprstwx')); |
101 | 101 | $this->deleteMailbox($mbox); |
102 | 102 | } |
103 | 103 | } |
104 | - catch(Horde_Imap_Client_Exception $e) { |
|
104 | + catch (Horde_Imap_Client_Exception $e) { |
|
105 | 105 | _egw_log_exception($e); |
106 | 106 | $this->disconnect(); |
107 | 107 | return false; |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | if ($_username !== $GLOBALS['egw_info']['user']['account_lid']) $this->adminConnection(); |
125 | 125 | $userData = array(); |
126 | 126 | |
127 | - if(($quota = $this->getQuotaByUser($_username,'ALL'))) |
|
127 | + if (($quota = $this->getQuotaByUser($_username, 'ALL'))) |
|
128 | 128 | { |
129 | 129 | $userData['quotaLimit'] = (int)($quota['limit'] / 1024); |
130 | 130 | $userData['quotaUsed'] = (int)($quota['usage'] / 1024); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | */ |
146 | 146 | function setUserData($_username, $_quota) |
147 | 147 | { |
148 | - if(!$this->acc_imap_administration) |
|
148 | + if (!$this->acc_imap_administration) |
|
149 | 149 | { |
150 | 150 | return false; |
151 | 151 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | |
156 | 156 | $mailboxName = $this->getUserMailboxString($_username); |
157 | 157 | |
158 | - $this->setQuota($mailboxName, array('STORAGE' => (int)$_quota > 0 ? (int)$_quota*1024 : -1)); |
|
158 | + $this->setQuota($mailboxName, array('STORAGE' => (int)$_quota > 0 ? (int)$_quota * 1024 : -1)); |
|
159 | 159 | |
160 | 160 | $this->disconnect(); |
161 | 161 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | */ |
170 | 170 | function updateAccount($_hookValues) |
171 | 171 | { |
172 | - if(!$this->acc_imap_administration) |
|
172 | + if (!$this->acc_imap_administration) |
|
173 | 173 | { |
174 | 174 | return false; |
175 | 175 | } |
@@ -182,14 +182,14 @@ discard block |
||
182 | 182 | // make sure we use the correct username here. |
183 | 183 | $username = $this->getMailBoxUserName($_hookValues['account_lid']); |
184 | 184 | $folderInfo = $this->getMailboxes('', $mailboxName, true); |
185 | - if(empty($folderInfo)) |
|
185 | + if (empty($folderInfo)) |
|
186 | 186 | { |
187 | 187 | try { |
188 | 188 | $this->createMailbox($mailboxName); |
189 | 189 | $this->setACL($mailboxName, $username, array('rights' => 'aeiklprstwx')); |
190 | 190 | // create defined folders and subscribe them (have to use user-credentials to subscribe!) |
191 | 191 | $userimap = null; |
192 | - foreach($this->params as $name => $value) |
|
192 | + foreach ($this->params as $name => $value) |
|
193 | 193 | { |
194 | 194 | if (substr($name, 0, 11) == 'acc_folder_' && !empty($value)) |
195 | 195 | { |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | } |
207 | 207 | if (isset($userimap)) $userimap->logout(); |
208 | 208 | } |
209 | - catch(Horde_Imap_Client_Exception $e) { |
|
209 | + catch (Horde_Imap_Client_Exception $e) { |
|
210 | 210 | _egw_log_exception($e); |
211 | 211 | } |
212 | 212 | } |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | * @param array $params |
221 | 221 | * @throws Exception |
222 | 222 | */ |
223 | - public function __call($name,array $params=null) |
|
223 | + public function __call($name, array $params = null) |
|
224 | 224 | { |
225 | - switch($name) |
|
225 | + switch ($name) |
|
226 | 226 | { |
227 | 227 | case 'setRules': // call setRules with 3. param of true, to enable utf7imap fileinto for Cyrus |
228 | 228 | $params += array(null, null, true); |
@@ -121,7 +121,10 @@ discard block |
||
121 | 121 | function getUserData($_username) |
122 | 122 | { |
123 | 123 | // no need to switch to admin-connection for reading quota of current user |
124 | - if ($_username !== $GLOBALS['egw_info']['user']['account_lid']) $this->adminConnection(); |
|
124 | + if ($_username !== $GLOBALS['egw_info']['user']['account_lid']) |
|
125 | + { |
|
126 | + $this->adminConnection(); |
|
127 | + } |
|
125 | 128 | $userData = array(); |
126 | 129 | |
127 | 130 | if(($quota = $this->getQuotaByUser($_username,'ALL'))) |
@@ -131,7 +134,10 @@ discard block |
||
131 | 134 | } |
132 | 135 | //error_log(__LINE__.': '.__METHOD__."('$_username') quota=".array2string($quota).' returning '.array2string($userData)); |
133 | 136 | |
134 | - if ($_username !== $GLOBALS['egw_info']['user']['account_lid']) $this->disconnect(); |
|
137 | + if ($_username !== $GLOBALS['egw_info']['user']['account_lid']) |
|
138 | + { |
|
139 | + $this->disconnect(); |
|
140 | + } |
|
135 | 141 | |
136 | 142 | return $userData; |
137 | 143 | } |
@@ -204,7 +210,10 @@ discard block |
||
204 | 210 | $userimap->subscribeMailbox($value); |
205 | 211 | } |
206 | 212 | } |
207 | - if (isset($userimap)) $userimap->logout(); |
|
213 | + if (isset($userimap)) |
|
214 | + { |
|
215 | + $userimap->logout(); |
|
216 | + } |
|
208 | 217 | } |
209 | 218 | catch(Horde_Imap_Client_Exception $e) { |
210 | 219 | _egw_log_exception($e); |
@@ -47,16 +47,16 @@ discard block |
||
47 | 47 | |
48 | 48 | $ds = Ldap::factory(); |
49 | 49 | |
50 | - if(!is_resource($ds)) { |
|
50 | + if (!is_resource($ds)) { |
|
51 | 51 | return false; |
52 | 52 | } |
53 | 53 | |
54 | - $filter = '(&(objectclass=posixaccount)(uid='. $_username .')(dbmailGID='. sprintf("%u", crc32($GLOBALS['egw_info']['server']['install_id'])) .'))'; |
|
54 | + $filter = '(&(objectclass=posixaccount)(uid='.$_username.')(dbmailGID='.sprintf("%u", crc32($GLOBALS['egw_info']['server']['install_id'])).'))'; |
|
55 | 55 | $justthese = array('dn', 'objectclass', 'mailQuota'); |
56 | - if(($sri = ldap_search($ds, $GLOBALS['egw_info']['server']['ldap_context'], $filter, $justthese))) { |
|
56 | + if (($sri = ldap_search($ds, $GLOBALS['egw_info']['server']['ldap_context'], $filter, $justthese))) { |
|
57 | 57 | |
58 | - if(($info = ldap_get_entries($ds, $sri))) { |
|
59 | - if(isset($info[0]['mailquota'][0])) { |
|
58 | + if (($info = ldap_get_entries($ds, $sri))) { |
|
59 | + if (isset($info[0]['mailquota'][0])) { |
|
60 | 60 | $userData['quotaLimit'] = $info[0]['mailquota'][0] / 1048576; |
61 | 61 | } |
62 | 62 | } |
@@ -66,40 +66,40 @@ discard block |
||
66 | 66 | |
67 | 67 | function updateAccount($_hookValues) |
68 | 68 | { |
69 | - if(!$uidnumber = (int)$_hookValues['account_id']) { |
|
69 | + if (!$uidnumber = (int)$_hookValues['account_id']) { |
|
70 | 70 | return false; |
71 | 71 | } |
72 | 72 | |
73 | 73 | $ds = Ldap::factory(); |
74 | 74 | |
75 | - if(!is_resource($ds)) { |
|
75 | + if (!is_resource($ds)) { |
|
76 | 76 | return false; |
77 | 77 | } |
78 | 78 | |
79 | - $filter = '(&(objectclass=posixaccount)(uidnumber='. $uidnumber .'))'; |
|
80 | - $justthese = array('dn', 'objectclass', 'dbmailUID', 'dbmailGID', 'mail'); |
|
79 | + $filter = '(&(objectclass=posixaccount)(uidnumber='.$uidnumber.'))'; |
|
80 | + $justthese = array('dn', 'objectclass', 'dbmailUID', 'dbmailGID', 'mail'); |
|
81 | 81 | $sri = ldap_search($ds, $GLOBALS['egw_info']['server']['ldap_context'], $filter, $justthese); |
82 | 82 | |
83 | - if(($info = ldap_get_entries($ds, $sri))) { |
|
84 | - if((!in_array('dbmailuser',$info[0]['objectclass']) && !in_array('dbmailUser',$info[0]['objectclass'])) && $info[0]['mail']) { |
|
83 | + if (($info = ldap_get_entries($ds, $sri))) { |
|
84 | + if ((!in_array('dbmailuser', $info[0]['objectclass']) && !in_array('dbmailUser', $info[0]['objectclass'])) && $info[0]['mail']) { |
|
85 | 85 | $newData['objectclass'] = $info[0]['objectclass']; |
86 | 86 | unset($newData['objectclass']['count']); |
87 | 87 | $newData['objectclass'][] = 'dbmailuser'; |
88 | 88 | sort($newData['objectclass']); |
89 | 89 | $newData['dbmailGID'] = sprintf("%u", crc32($GLOBALS['egw_info']['server']['install_id'])); |
90 | - $newData['dbmailUID'] = (!empty($this->domainName)) ? $_hookValues['account_lid'] .'@'. $this->domainName : $_hookValues['account_lid']; |
|
90 | + $newData['dbmailUID'] = (!empty($this->domainName)) ? $_hookValues['account_lid'].'@'.$this->domainName : $_hookValues['account_lid']; |
|
91 | 91 | |
92 | - if(!ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
92 | + if (!ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
93 | 93 | #print ldap_error($ds); |
94 | 94 | } |
95 | 95 | |
96 | 96 | return true; |
97 | 97 | } else { |
98 | 98 | $newData = array(); |
99 | - $newData['dbmailUID'] = (!empty($this->domainName)) ? $_hookValues['account_lid'] .'@'. $this->domainName : $_hookValues['account_lid']; |
|
99 | + $newData['dbmailUID'] = (!empty($this->domainName)) ? $_hookValues['account_lid'].'@'.$this->domainName : $_hookValues['account_lid']; |
|
100 | 100 | $newData['dbmailGID'] = sprintf("%u", crc32($GLOBALS['egw_info']['server']['install_id'])); |
101 | 101 | |
102 | - if(!ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
102 | + if (!ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
103 | 103 | print ldap_error($ds); |
104 | 104 | _debug_array($newData); |
105 | 105 | exit; |
@@ -115,63 +115,63 @@ discard block |
||
115 | 115 | { |
116 | 116 | $ds = Ldap::factory(); |
117 | 117 | |
118 | - if(!is_resource($ds)) { |
|
118 | + if (!is_resource($ds)) { |
|
119 | 119 | return false; |
120 | 120 | } |
121 | 121 | |
122 | - $filter = '(&(objectclass=posixaccount)(uid='. $_username .'))'; |
|
123 | - $justthese = array('dn', 'objectclass', 'dbmailGID', 'dbmailUID', 'mail'); |
|
122 | + $filter = '(&(objectclass=posixaccount)(uid='.$_username.'))'; |
|
123 | + $justthese = array('dn', 'objectclass', 'dbmailGID', 'dbmailUID', 'mail'); |
|
124 | 124 | $sri = ldap_search($ds, $GLOBALS['egw_info']['server']['ldap_context'], $filter, $justthese); |
125 | 125 | |
126 | - if(($info = ldap_get_entries($ds, $sri))) { |
|
126 | + if (($info = ldap_get_entries($ds, $sri))) { |
|
127 | 127 | $validLDAPConfig = false; |
128 | - if(in_array('dbmailuser',$info[0]['objectclass']) || in_array('dbmailUser',$info[0]['objectclass'])) { |
|
128 | + if (in_array('dbmailuser', $info[0]['objectclass']) || in_array('dbmailUser', $info[0]['objectclass'])) { |
|
129 | 129 | $validLDAPConfig = true; |
130 | 130 | } |
131 | 131 | |
132 | - if(!in_array('dbmailuser',$info[0]['objectclass']) && !in_array('dbmailUser',$info[0]['objectclass']) && $info[0]['mail']) { |
|
132 | + if (!in_array('dbmailuser', $info[0]['objectclass']) && !in_array('dbmailUser', $info[0]['objectclass']) && $info[0]['mail']) { |
|
133 | 133 | $newData['objectclass'] = $info[0]['objectclass']; |
134 | 134 | unset($newData['objectclass']['count']); |
135 | 135 | $newData['objectclass'][] = 'dbmailUser'; |
136 | 136 | sort($newData['objectclass']); |
137 | 137 | $newData['dbmailGID'] = sprintf("%u", crc32($GLOBALS['egw_info']['server']['install_id'])); |
138 | - $newData['dbmailUID'] = (!empty($this->domainName)) ? $_username .'@'. $this->domainName : $_username; |
|
138 | + $newData['dbmailUID'] = (!empty($this->domainName)) ? $_username.'@'.$this->domainName : $_username; |
|
139 | 139 | |
140 | - if(ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
140 | + if (ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
141 | 141 | $validLDAPConfig = true; |
142 | 142 | } |
143 | 143 | } else { |
144 | - if ((in_array('dbmailuser',$info[0]['objectclass']) || in_array('dbmailUser',$info[0]['objectclass'])) && !$info[0]['dbmailuid']) { |
|
144 | + if ((in_array('dbmailuser', $info[0]['objectclass']) || in_array('dbmailUser', $info[0]['objectclass'])) && !$info[0]['dbmailuid']) { |
|
145 | 145 | $newData = array(); |
146 | - $newData['dbmailUID'] = (!empty($this->domainName)) ? $_username .'@'. $this->domainName : $_username; |
|
146 | + $newData['dbmailUID'] = (!empty($this->domainName)) ? $_username.'@'.$this->domainName : $_username; |
|
147 | 147 | |
148 | - if(!ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
148 | + if (!ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
149 | 149 | #print ldap_error($ds); |
150 | 150 | #return false; |
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | - if ((in_array('dbmailuser',$info[0]['objectclass']) || in_array('dbmailUser',$info[0]['objectclass'])) && !$info[0]['dbmailgid']) { |
|
154 | + if ((in_array('dbmailuser', $info[0]['objectclass']) || in_array('dbmailUser', $info[0]['objectclass'])) && !$info[0]['dbmailgid']) { |
|
155 | 155 | $newData = array(); |
156 | - $newData['dbmailGID'] = sprintf("%u", crc32($GLOBALS['egw_info']['server']['install_id'])); |
|
156 | + $newData['dbmailGID'] = sprintf("%u", crc32($GLOBALS['egw_info']['server']['install_id'])); |
|
157 | 157 | |
158 | - if(!ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
158 | + if (!ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
159 | 159 | #print ldap_error($ds); |
160 | 160 | #return false; |
161 | 161 | } |
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | - if($validLDAPConfig) { |
|
165 | + if ($validLDAPConfig) { |
|
166 | 166 | $newData = array(); |
167 | 167 | |
168 | - if((int)$_quota >= 0) { |
|
168 | + if ((int)$_quota >= 0) { |
|
169 | 169 | $newData['mailQuota'] = (int)$_quota * 1048576; |
170 | 170 | } else { |
171 | 171 | $newData['mailQuota'] = array(); |
172 | 172 | } |
173 | 173 | |
174 | - if(!ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
174 | + if (!ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
175 | 175 | #print ldap_error($ds); |
176 | 176 | return false; |
177 | 177 | } |
@@ -47,16 +47,20 @@ discard block |
||
47 | 47 | |
48 | 48 | $ds = Ldap::factory(); |
49 | 49 | |
50 | - if(!is_resource($ds)) { |
|
50 | + if(!is_resource($ds)) |
|
51 | + { |
|
51 | 52 | return false; |
52 | 53 | } |
53 | 54 | |
54 | 55 | $filter = '(&(objectclass=posixaccount)(uid='. $_username .')(dbmailGID='. sprintf("%u", crc32($GLOBALS['egw_info']['server']['install_id'])) .'))'; |
55 | 56 | $justthese = array('dn', 'objectclass', 'mailQuota'); |
56 | - if(($sri = ldap_search($ds, $GLOBALS['egw_info']['server']['ldap_context'], $filter, $justthese))) { |
|
57 | + if(($sri = ldap_search($ds, $GLOBALS['egw_info']['server']['ldap_context'], $filter, $justthese))) |
|
58 | + { |
|
57 | 59 | |
58 | - if(($info = ldap_get_entries($ds, $sri))) { |
|
59 | - if(isset($info[0]['mailquota'][0])) { |
|
60 | + if(($info = ldap_get_entries($ds, $sri))) |
|
61 | + { |
|
62 | + if(isset($info[0]['mailquota'][0])) |
|
63 | + { |
|
60 | 64 | $userData['quotaLimit'] = $info[0]['mailquota'][0] / 1048576; |
61 | 65 | } |
62 | 66 | } |
@@ -66,13 +70,15 @@ discard block |
||
66 | 70 | |
67 | 71 | function updateAccount($_hookValues) |
68 | 72 | { |
69 | - if(!$uidnumber = (int)$_hookValues['account_id']) { |
|
73 | + if(!$uidnumber = (int)$_hookValues['account_id']) |
|
74 | + { |
|
70 | 75 | return false; |
71 | 76 | } |
72 | 77 | |
73 | 78 | $ds = Ldap::factory(); |
74 | 79 | |
75 | - if(!is_resource($ds)) { |
|
80 | + if(!is_resource($ds)) |
|
81 | + { |
|
76 | 82 | return false; |
77 | 83 | } |
78 | 84 | |
@@ -80,8 +86,10 @@ discard block |
||
80 | 86 | $justthese = array('dn', 'objectclass', 'dbmailUID', 'dbmailGID', 'mail'); |
81 | 87 | $sri = ldap_search($ds, $GLOBALS['egw_info']['server']['ldap_context'], $filter, $justthese); |
82 | 88 | |
83 | - if(($info = ldap_get_entries($ds, $sri))) { |
|
84 | - if((!in_array('dbmailuser',$info[0]['objectclass']) && !in_array('dbmailUser',$info[0]['objectclass'])) && $info[0]['mail']) { |
|
89 | + if(($info = ldap_get_entries($ds, $sri))) |
|
90 | + { |
|
91 | + if((!in_array('dbmailuser',$info[0]['objectclass']) && !in_array('dbmailUser',$info[0]['objectclass'])) && $info[0]['mail']) |
|
92 | + { |
|
85 | 93 | $newData['objectclass'] = $info[0]['objectclass']; |
86 | 94 | unset($newData['objectclass']['count']); |
87 | 95 | $newData['objectclass'][] = 'dbmailuser'; |
@@ -89,17 +97,21 @@ discard block |
||
89 | 97 | $newData['dbmailGID'] = sprintf("%u", crc32($GLOBALS['egw_info']['server']['install_id'])); |
90 | 98 | $newData['dbmailUID'] = (!empty($this->domainName)) ? $_hookValues['account_lid'] .'@'. $this->domainName : $_hookValues['account_lid']; |
91 | 99 | |
92 | - if(!ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
100 | + if(!ldap_modify($ds, $info[0]['dn'], $newData)) |
|
101 | + { |
|
93 | 102 | #print ldap_error($ds); |
94 | 103 | } |
95 | 104 | |
96 | 105 | return true; |
97 | - } else { |
|
106 | + } |
|
107 | + else |
|
108 | + { |
|
98 | 109 | $newData = array(); |
99 | 110 | $newData['dbmailUID'] = (!empty($this->domainName)) ? $_hookValues['account_lid'] .'@'. $this->domainName : $_hookValues['account_lid']; |
100 | 111 | $newData['dbmailGID'] = sprintf("%u", crc32($GLOBALS['egw_info']['server']['install_id'])); |
101 | 112 | |
102 | - if(!ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
113 | + if(!ldap_modify($ds, $info[0]['dn'], $newData)) |
|
114 | + { |
|
103 | 115 | print ldap_error($ds); |
104 | 116 | _debug_array($newData); |
105 | 117 | exit; |
@@ -115,7 +127,8 @@ discard block |
||
115 | 127 | { |
116 | 128 | $ds = Ldap::factory(); |
117 | 129 | |
118 | - if(!is_resource($ds)) { |
|
130 | + if(!is_resource($ds)) |
|
131 | + { |
|
119 | 132 | return false; |
120 | 133 | } |
121 | 134 | |
@@ -123,13 +136,16 @@ discard block |
||
123 | 136 | $justthese = array('dn', 'objectclass', 'dbmailGID', 'dbmailUID', 'mail'); |
124 | 137 | $sri = ldap_search($ds, $GLOBALS['egw_info']['server']['ldap_context'], $filter, $justthese); |
125 | 138 | |
126 | - if(($info = ldap_get_entries($ds, $sri))) { |
|
139 | + if(($info = ldap_get_entries($ds, $sri))) |
|
140 | + { |
|
127 | 141 | $validLDAPConfig = false; |
128 | - if(in_array('dbmailuser',$info[0]['objectclass']) || in_array('dbmailUser',$info[0]['objectclass'])) { |
|
142 | + if(in_array('dbmailuser',$info[0]['objectclass']) || in_array('dbmailUser',$info[0]['objectclass'])) |
|
143 | + { |
|
129 | 144 | $validLDAPConfig = true; |
130 | 145 | } |
131 | 146 | |
132 | - if(!in_array('dbmailuser',$info[0]['objectclass']) && !in_array('dbmailUser',$info[0]['objectclass']) && $info[0]['mail']) { |
|
147 | + if(!in_array('dbmailuser',$info[0]['objectclass']) && !in_array('dbmailUser',$info[0]['objectclass']) && $info[0]['mail']) |
|
148 | + { |
|
133 | 149 | $newData['objectclass'] = $info[0]['objectclass']; |
134 | 150 | unset($newData['objectclass']['count']); |
135 | 151 | $newData['objectclass'][] = 'dbmailUser'; |
@@ -137,41 +153,53 @@ discard block |
||
137 | 153 | $newData['dbmailGID'] = sprintf("%u", crc32($GLOBALS['egw_info']['server']['install_id'])); |
138 | 154 | $newData['dbmailUID'] = (!empty($this->domainName)) ? $_username .'@'. $this->domainName : $_username; |
139 | 155 | |
140 | - if(ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
156 | + if(ldap_modify($ds, $info[0]['dn'], $newData)) |
|
157 | + { |
|
141 | 158 | $validLDAPConfig = true; |
142 | 159 | } |
143 | - } else { |
|
144 | - if ((in_array('dbmailuser',$info[0]['objectclass']) || in_array('dbmailUser',$info[0]['objectclass'])) && !$info[0]['dbmailuid']) { |
|
160 | + } |
|
161 | + else |
|
162 | + { |
|
163 | + if ((in_array('dbmailuser',$info[0]['objectclass']) || in_array('dbmailUser',$info[0]['objectclass'])) && !$info[0]['dbmailuid']) |
|
164 | + { |
|
145 | 165 | $newData = array(); |
146 | 166 | $newData['dbmailUID'] = (!empty($this->domainName)) ? $_username .'@'. $this->domainName : $_username; |
147 | 167 | |
148 | - if(!ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
168 | + if(!ldap_modify($ds, $info[0]['dn'], $newData)) |
|
169 | + { |
|
149 | 170 | #print ldap_error($ds); |
150 | 171 | #return false; |
151 | 172 | } |
152 | 173 | } |
153 | 174 | |
154 | - if ((in_array('dbmailuser',$info[0]['objectclass']) || in_array('dbmailUser',$info[0]['objectclass'])) && !$info[0]['dbmailgid']) { |
|
175 | + if ((in_array('dbmailuser',$info[0]['objectclass']) || in_array('dbmailUser',$info[0]['objectclass'])) && !$info[0]['dbmailgid']) |
|
176 | + { |
|
155 | 177 | $newData = array(); |
156 | 178 | $newData['dbmailGID'] = sprintf("%u", crc32($GLOBALS['egw_info']['server']['install_id'])); |
157 | 179 | |
158 | - if(!ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
180 | + if(!ldap_modify($ds, $info[0]['dn'], $newData)) |
|
181 | + { |
|
159 | 182 | #print ldap_error($ds); |
160 | 183 | #return false; |
161 | 184 | } |
162 | 185 | } |
163 | 186 | } |
164 | 187 | |
165 | - if($validLDAPConfig) { |
|
188 | + if($validLDAPConfig) |
|
189 | + { |
|
166 | 190 | $newData = array(); |
167 | 191 | |
168 | - if((int)$_quota >= 0) { |
|
192 | + if((int)$_quota >= 0) |
|
193 | + { |
|
169 | 194 | $newData['mailQuota'] = (int)$_quota * 1048576; |
170 | - } else { |
|
195 | + } |
|
196 | + else |
|
197 | + { |
|
171 | 198 | $newData['mailQuota'] = array(); |
172 | 199 | } |
173 | 200 | |
174 | - if(!ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
201 | + if(!ldap_modify($ds, $info[0]['dn'], $newData)) |
|
202 | + { |
|
175 | 203 | #print ldap_error($ds); |
176 | 204 | return false; |
177 | 205 | } |
@@ -47,16 +47,16 @@ discard block |
||
47 | 47 | |
48 | 48 | $ds = Ldap::factory(); |
49 | 49 | |
50 | - if(!is_resource($ds)) { |
|
50 | + if (!is_resource($ds)) { |
|
51 | 51 | return false; |
52 | 52 | } |
53 | 53 | |
54 | - $filter = '(&(objectclass=posixaccount)(uid='. $_username .')(qmailGID='. sprintf("%u", crc32($GLOBALS['egw_info']['server']['install_id'])) .'))'; |
|
54 | + $filter = '(&(objectclass=posixaccount)(uid='.$_username.')(qmailGID='.sprintf("%u", crc32($GLOBALS['egw_info']['server']['install_id'])).'))'; |
|
55 | 55 | $justthese = array('dn', 'objectclass', 'mailQuota'); |
56 | - if(($sri = ldap_search($ds, $GLOBALS['egw_info']['server']['ldap_context'], $filter, $justthese))) { |
|
56 | + if (($sri = ldap_search($ds, $GLOBALS['egw_info']['server']['ldap_context'], $filter, $justthese))) { |
|
57 | 57 | |
58 | - if(($info = ldap_get_entries($ds, $sri))) { |
|
59 | - if(isset($info[0]['mailquota'][0])) { |
|
58 | + if (($info = ldap_get_entries($ds, $sri))) { |
|
59 | + if (isset($info[0]['mailquota'][0])) { |
|
60 | 60 | $userData['quotaLimit'] = $info[0]['mailquota'][0] / 1048576; |
61 | 61 | } |
62 | 62 | } |
@@ -65,27 +65,27 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | function updateAccount($_hookValues) { |
68 | - if(!$uidnumber = (int)$_hookValues['account_id']) { |
|
68 | + if (!$uidnumber = (int)$_hookValues['account_id']) { |
|
69 | 69 | return false; |
70 | 70 | } |
71 | 71 | |
72 | 72 | $ds = Ldap::factory(); |
73 | 73 | |
74 | - if(!is_resource($ds)) { |
|
74 | + if (!is_resource($ds)) { |
|
75 | 75 | return false; |
76 | 76 | } |
77 | 77 | |
78 | - $filter = '(&(objectclass=posixaccount)(uidnumber='. $uidnumber .'))'; |
|
79 | - $justthese = array('dn', 'objectclass', 'qmailUID', 'qmailGID', 'mail'); |
|
78 | + $filter = '(&(objectclass=posixaccount)(uidnumber='.$uidnumber.'))'; |
|
79 | + $justthese = array('dn', 'objectclass', 'qmailUID', 'qmailGID', 'mail'); |
|
80 | 80 | $sri = ldap_search($ds, $GLOBALS['egw_info']['server']['ldap_context'], $filter, $justthese); |
81 | 81 | |
82 | - if(($info = ldap_get_entries($ds, $sri))) { |
|
83 | - if(!in_array('qmailuser',$info[0]['objectclass']) && $info[0]['email']) { |
|
82 | + if (($info = ldap_get_entries($ds, $sri))) { |
|
83 | + if (!in_array('qmailuser', $info[0]['objectclass']) && $info[0]['email']) { |
|
84 | 84 | $newData['objectclass'] = $info[0]['objectclass']; |
85 | 85 | unset($newData['objectclass']['count']); |
86 | 86 | $newData['objectclass'][] = 'qmailuser'; |
87 | 87 | sort($newData['objectclass']); |
88 | - $newData['qmailGID'] = sprintf("%u", crc32($GLOBALS['egw_info']['server']['install_id'])); |
|
88 | + $newData['qmailGID'] = sprintf("%u", crc32($GLOBALS['egw_info']['server']['install_id'])); |
|
89 | 89 | #$newData['qmailUID'] = (!empty($this->domainName)) ? $_username .'@'. $this->domainName : $_username; |
90 | 90 | |
91 | 91 | ldap_modify($ds, $info[0]['dn'], $newData); |
@@ -93,10 +93,10 @@ discard block |
||
93 | 93 | return true; |
94 | 94 | } else { |
95 | 95 | $newData = array(); |
96 | - $newData['qmailGID'] = sprintf("%u", crc32($GLOBALS['egw_info']['server']['install_id'])); |
|
96 | + $newData['qmailGID'] = sprintf("%u", crc32($GLOBALS['egw_info']['server']['install_id'])); |
|
97 | 97 | #$newData['qmailUID'] = (!empty($this->domainName)) ? $_username .'@'. $this->domainName : $_username; |
98 | 98 | |
99 | - if(!ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
99 | + if (!ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
100 | 100 | #print ldap_error($ds); |
101 | 101 | #return false; |
102 | 102 | } |
@@ -109,30 +109,30 @@ discard block |
||
109 | 109 | function setUserData($_username, $_quota) { |
110 | 110 | $ds = Ldap::factory(); |
111 | 111 | |
112 | - if(!is_resource($ds)) { |
|
112 | + if (!is_resource($ds)) { |
|
113 | 113 | return false; |
114 | 114 | } |
115 | 115 | |
116 | - $filter = '(&(objectclass=posixaccount)(uid='. $_username .'))'; |
|
117 | - $justthese = array('dn', 'objectclass', 'qmailGID', 'mail'); |
|
116 | + $filter = '(&(objectclass=posixaccount)(uid='.$_username.'))'; |
|
117 | + $justthese = array('dn', 'objectclass', 'qmailGID', 'mail'); |
|
118 | 118 | $sri = ldap_search($ds, $GLOBALS['egw_info']['server']['ldap_context'], $filter, $justthese); |
119 | 119 | |
120 | - if(($info = ldap_get_entries($ds, $sri))) { |
|
120 | + if (($info = ldap_get_entries($ds, $sri))) { |
|
121 | 121 | #_debug_array($info); |
122 | - if(!in_array('qmailuser',$info[0]['objectclass']) && $info[0]['email']) { |
|
122 | + if (!in_array('qmailuser', $info[0]['objectclass']) && $info[0]['email']) { |
|
123 | 123 | $newData['objectclass'] = $info[0]['objectclass']; |
124 | 124 | unset($newData['objectclass']['count']); |
125 | 125 | $newData['objectclass'][] = 'qmailuser'; |
126 | 126 | sort($newData['objectclass']); |
127 | - $newData['qmailGID'] = sprintf("%u", crc32($GLOBALS['egw_info']['server']['install_id'])); |
|
127 | + $newData['qmailGID'] = sprintf("%u", crc32($GLOBALS['egw_info']['server']['install_id'])); |
|
128 | 128 | |
129 | 129 | ldap_modify($ds, $info[0]['dn'], $newData); |
130 | 130 | } else { |
131 | - if (in_array('qmailuser',$info[0]['objectclass']) && !$info[0]['qmailgid']) { |
|
131 | + if (in_array('qmailuser', $info[0]['objectclass']) && !$info[0]['qmailgid']) { |
|
132 | 132 | $newData = array(); |
133 | - $newData['qmailGID'] = sprintf("%u", crc32($GLOBALS['egw_info']['server']['install_id'])); |
|
133 | + $newData['qmailGID'] = sprintf("%u", crc32($GLOBALS['egw_info']['server']['install_id'])); |
|
134 | 134 | |
135 | - if(!ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
135 | + if (!ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
136 | 136 | #print ldap_error($ds); |
137 | 137 | #return false; |
138 | 138 | } |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | |
142 | 142 | $newData = array(); |
143 | 143 | |
144 | - if((int)$_quota >= 0) { |
|
144 | + if ((int)$_quota >= 0) { |
|
145 | 145 | $newData['mailQuota'] = (int)$_quota * 1048576; |
146 | 146 | } else { |
147 | 147 | $newData['mailQuota'] = array(); |
148 | 148 | } |
149 | 149 | |
150 | - if(!ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
150 | + if (!ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
151 | 151 | #print ldap_error($ds); |
152 | 152 | return false; |
153 | 153 | } |
@@ -47,16 +47,20 @@ discard block |
||
47 | 47 | |
48 | 48 | $ds = Ldap::factory(); |
49 | 49 | |
50 | - if(!is_resource($ds)) { |
|
50 | + if(!is_resource($ds)) |
|
51 | + { |
|
51 | 52 | return false; |
52 | 53 | } |
53 | 54 | |
54 | 55 | $filter = '(&(objectclass=posixaccount)(uid='. $_username .')(qmailGID='. sprintf("%u", crc32($GLOBALS['egw_info']['server']['install_id'])) .'))'; |
55 | 56 | $justthese = array('dn', 'objectclass', 'mailQuota'); |
56 | - if(($sri = ldap_search($ds, $GLOBALS['egw_info']['server']['ldap_context'], $filter, $justthese))) { |
|
57 | + if(($sri = ldap_search($ds, $GLOBALS['egw_info']['server']['ldap_context'], $filter, $justthese))) |
|
58 | + { |
|
57 | 59 | |
58 | - if(($info = ldap_get_entries($ds, $sri))) { |
|
59 | - if(isset($info[0]['mailquota'][0])) { |
|
60 | + if(($info = ldap_get_entries($ds, $sri))) |
|
61 | + { |
|
62 | + if(isset($info[0]['mailquota'][0])) |
|
63 | + { |
|
60 | 64 | $userData['quotaLimit'] = $info[0]['mailquota'][0] / 1048576; |
61 | 65 | } |
62 | 66 | } |
@@ -64,14 +68,17 @@ discard block |
||
64 | 68 | return $userData; |
65 | 69 | } |
66 | 70 | |
67 | - function updateAccount($_hookValues) { |
|
68 | - if(!$uidnumber = (int)$_hookValues['account_id']) { |
|
71 | + function updateAccount($_hookValues) |
|
72 | + { |
|
73 | + if(!$uidnumber = (int)$_hookValues['account_id']) |
|
74 | + { |
|
69 | 75 | return false; |
70 | 76 | } |
71 | 77 | |
72 | 78 | $ds = Ldap::factory(); |
73 | 79 | |
74 | - if(!is_resource($ds)) { |
|
80 | + if(!is_resource($ds)) |
|
81 | + { |
|
75 | 82 | return false; |
76 | 83 | } |
77 | 84 | |
@@ -79,8 +86,10 @@ discard block |
||
79 | 86 | $justthese = array('dn', 'objectclass', 'qmailUID', 'qmailGID', 'mail'); |
80 | 87 | $sri = ldap_search($ds, $GLOBALS['egw_info']['server']['ldap_context'], $filter, $justthese); |
81 | 88 | |
82 | - if(($info = ldap_get_entries($ds, $sri))) { |
|
83 | - if(!in_array('qmailuser',$info[0]['objectclass']) && $info[0]['email']) { |
|
89 | + if(($info = ldap_get_entries($ds, $sri))) |
|
90 | + { |
|
91 | + if(!in_array('qmailuser',$info[0]['objectclass']) && $info[0]['email']) |
|
92 | + { |
|
84 | 93 | $newData['objectclass'] = $info[0]['objectclass']; |
85 | 94 | unset($newData['objectclass']['count']); |
86 | 95 | $newData['objectclass'][] = 'qmailuser'; |
@@ -91,12 +100,15 @@ discard block |
||
91 | 100 | ldap_modify($ds, $info[0]['dn'], $newData); |
92 | 101 | |
93 | 102 | return true; |
94 | - } else { |
|
103 | + } |
|
104 | + else |
|
105 | + { |
|
95 | 106 | $newData = array(); |
96 | 107 | $newData['qmailGID'] = sprintf("%u", crc32($GLOBALS['egw_info']['server']['install_id'])); |
97 | 108 | #$newData['qmailUID'] = (!empty($this->domainName)) ? $_username .'@'. $this->domainName : $_username; |
98 | 109 | |
99 | - if(!ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
110 | + if(!ldap_modify($ds, $info[0]['dn'], $newData)) |
|
111 | + { |
|
100 | 112 | #print ldap_error($ds); |
101 | 113 | #return false; |
102 | 114 | } |
@@ -106,10 +118,12 @@ discard block |
||
106 | 118 | return false; |
107 | 119 | } |
108 | 120 | |
109 | - function setUserData($_username, $_quota) { |
|
121 | + function setUserData($_username, $_quota) |
|
122 | + { |
|
110 | 123 | $ds = Ldap::factory(); |
111 | 124 | |
112 | - if(!is_resource($ds)) { |
|
125 | + if(!is_resource($ds)) |
|
126 | + { |
|
113 | 127 | return false; |
114 | 128 | } |
115 | 129 | |
@@ -117,9 +131,11 @@ discard block |
||
117 | 131 | $justthese = array('dn', 'objectclass', 'qmailGID', 'mail'); |
118 | 132 | $sri = ldap_search($ds, $GLOBALS['egw_info']['server']['ldap_context'], $filter, $justthese); |
119 | 133 | |
120 | - if(($info = ldap_get_entries($ds, $sri))) { |
|
134 | + if(($info = ldap_get_entries($ds, $sri))) |
|
135 | + { |
|
121 | 136 | #_debug_array($info); |
122 | - if(!in_array('qmailuser',$info[0]['objectclass']) && $info[0]['email']) { |
|
137 | + if(!in_array('qmailuser',$info[0]['objectclass']) && $info[0]['email']) |
|
138 | + { |
|
123 | 139 | $newData['objectclass'] = $info[0]['objectclass']; |
124 | 140 | unset($newData['objectclass']['count']); |
125 | 141 | $newData['objectclass'][] = 'qmailuser'; |
@@ -127,12 +143,16 @@ discard block |
||
127 | 143 | $newData['qmailGID'] = sprintf("%u", crc32($GLOBALS['egw_info']['server']['install_id'])); |
128 | 144 | |
129 | 145 | ldap_modify($ds, $info[0]['dn'], $newData); |
130 | - } else { |
|
131 | - if (in_array('qmailuser',$info[0]['objectclass']) && !$info[0]['qmailgid']) { |
|
146 | + } |
|
147 | + else |
|
148 | + { |
|
149 | + if (in_array('qmailuser',$info[0]['objectclass']) && !$info[0]['qmailgid']) |
|
150 | + { |
|
132 | 151 | $newData = array(); |
133 | 152 | $newData['qmailGID'] = sprintf("%u", crc32($GLOBALS['egw_info']['server']['install_id'])); |
134 | 153 | |
135 | - if(!ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
154 | + if(!ldap_modify($ds, $info[0]['dn'], $newData)) |
|
155 | + { |
|
136 | 156 | #print ldap_error($ds); |
137 | 157 | #return false; |
138 | 158 | } |
@@ -141,13 +161,17 @@ discard block |
||
141 | 161 | |
142 | 162 | $newData = array(); |
143 | 163 | |
144 | - if((int)$_quota >= 0) { |
|
164 | + if((int)$_quota >= 0) |
|
165 | + { |
|
145 | 166 | $newData['mailQuota'] = (int)$_quota * 1048576; |
146 | - } else { |
|
167 | + } |
|
168 | + else |
|
169 | + { |
|
147 | 170 | $newData['mailQuota'] = array(); |
148 | 171 | } |
149 | 172 | |
150 | - if(!ldap_modify($ds, $info[0]['dn'], $newData)) { |
|
173 | + if(!ldap_modify($ds, $info[0]['dn'], $newData)) |
|
174 | + { |
|
151 | 175 | #print ldap_error($ds); |
152 | 176 | return false; |
153 | 177 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @var string |
58 | 58 | */ |
59 | - var $user_home; // = '/var/dovecot/imap/%d/%u'; |
|
59 | + var $user_home; // = '/var/dovecot/imap/%d/%u'; |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Ensure we use an admin connection |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @param string $_username =true create an admin connection for given user or $this->acc_imap_username |
67 | 67 | */ |
68 | - function adminConnection($_username=true) |
|
68 | + function adminConnection($_username = true) |
|
69 | 69 | { |
70 | 70 | // generate admin user name of $username |
71 | 71 | if (($pos = strpos($this->acc_imap_admin_username, '*')) !== false) // remove evtl. set username |
72 | 72 | { |
73 | - $this->params['acc_imap_admin_username'] = substr($this->acc_imap_admin_username, $pos+1); |
|
73 | + $this->params['acc_imap_admin_username'] = substr($this->acc_imap_admin_username, $pos + 1); |
|
74 | 74 | } |
75 | 75 | $this->params['acc_imap_admin_username'] = (is_string($_username) ? $_username : $this->acc_imap_username). |
76 | 76 | '*'.$this->acc_imap_admin_username; |
@@ -87,16 +87,16 @@ discard block |
||
87 | 87 | * @param string $_folderName ='' |
88 | 88 | * @return string utf-7 encoded (done in getMailboxName) |
89 | 89 | */ |
90 | - function getUserMailboxString($_username, $_folderName='') |
|
90 | + function getUserMailboxString($_username, $_folderName = '') |
|
91 | 91 | { |
92 | - unset($_username); // not used, but required by function signature |
|
92 | + unset($_username); // not used, but required by function signature |
|
93 | 93 | |
94 | 94 | $mailboxString = 'INBOX'; |
95 | 95 | |
96 | 96 | if (!empty($_folderName)) |
97 | 97 | { |
98 | 98 | $nameSpaces = $this->getNameSpaceArray(); |
99 | - $mailboxString .= $nameSpaces['others'][0]['delimiter'] . $_folderName; |
|
99 | + $mailboxString .= $nameSpaces['others'][0]['delimiter'].$_folderName; |
|
100 | 100 | } |
101 | 101 | return $mailboxString; |
102 | 102 | } |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | function deleteAccount($_hookValues) |
120 | 120 | { |
121 | 121 | // some precausion to really delete just _one_ account |
122 | - if (strpos($_hookValues['account_lid'],'%') !== false || |
|
123 | - strpos($_hookValues['account_lid'],'*') !== false) |
|
122 | + if (strpos($_hookValues['account_lid'], '%') !== false || |
|
123 | + strpos($_hookValues['account_lid'], '*') !== false) |
|
124 | 124 | { |
125 | 125 | return false; |
126 | 126 | } |
@@ -135,9 +135,9 @@ discard block |
||
135 | 135 | * @return string $username='%' username containing wildcards, default '%' for all users of a domain |
136 | 136 | * @return int|boolean number of deleted mailboxes on success or false on error |
137 | 137 | */ |
138 | - function deleteUsers($username='%') |
|
138 | + function deleteUsers($username = '%') |
|
139 | 139 | { |
140 | - if(!$this->acc_imap_administration || empty($username)) |
|
140 | + if (!$this->acc_imap_administration || empty($username)) |
|
141 | 141 | { |
142 | 142 | return false; |
143 | 143 | } |
@@ -155,9 +155,9 @@ discard block |
||
155 | 155 | { |
156 | 156 | throw new Api\Exception\AssertionFailed("user_home='$this->user_home' contains no domain-part '%d'!"); |
157 | 157 | } |
158 | - $home = strtr(substr($this->user_home, 0, $pos+2), $replace); |
|
158 | + $home = strtr(substr($this->user_home, 0, $pos + 2), $replace); |
|
159 | 159 | |
160 | - $ret = count(scandir($home))-2; |
|
160 | + $ret = count(scandir($home)) - 2; |
|
161 | 161 | } |
162 | 162 | else |
163 | 163 | { |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | { |
184 | 184 | if (is_dir($path)) |
185 | 185 | { |
186 | - foreach(scandir($path) as $file) |
|
186 | + foreach (scandir($path) as $file) |
|
187 | 187 | { |
188 | 188 | if ($file == '.' || $file == '..') continue; |
189 | 189 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | return false; |
202 | 202 | } |
203 | 203 | } |
204 | - elseif(!unlink($path)) |
|
204 | + elseif (!unlink($path)) |
|
205 | 205 | { |
206 | 206 | return false; |
207 | 207 | } |
@@ -235,10 +235,10 @@ discard block |
||
235 | 235 | |
236 | 236 | $userData = array(); |
237 | 237 | // we are authenticated with master but for current user |
238 | - if(($quota = $this->getStorageQuotaRoot('INBOX'))) |
|
238 | + if (($quota = $this->getStorageQuotaRoot('INBOX'))) |
|
239 | 239 | { |
240 | - $userData['quotaLimit'] = (int) ($quota['QMAX'] / 1024); |
|
241 | - $userData['quotaUsed'] = (int) ($quota['USED'] / 1024); |
|
240 | + $userData['quotaLimit'] = (int)($quota['QMAX'] / 1024); |
|
241 | + $userData['quotaUsed'] = (int)($quota['USED'] / 1024); |
|
242 | 242 | } |
243 | 243 | $this->username = $bufferUsername; |
244 | 244 | $this->loginName = $bufferLoginName; |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | */ |
261 | 261 | function setUserData($_username, $_quota) |
262 | 262 | { |
263 | - unset($_username); unset($_quota); // not used, but required by function signature |
|
263 | + unset($_username); unset($_quota); // not used, but required by function signature |
|
264 | 264 | |
265 | 265 | return true; |
266 | 266 | } |
@@ -272,9 +272,9 @@ discard block |
||
272 | 272 | */ |
273 | 273 | function updateAccount($_hookValues) |
274 | 274 | { |
275 | - unset($_hookValues); // not used, but required by function signature |
|
275 | + unset($_hookValues); // not used, but required by function signature |
|
276 | 276 | |
277 | - if(!$this->acc_imap_administration) |
|
277 | + if (!$this->acc_imap_administration) |
|
278 | 278 | { |
279 | 279 | return false; |
280 | 280 | } |
@@ -68,10 +68,13 @@ discard block |
||
68 | 68 | function adminConnection($_username=true) |
69 | 69 | { |
70 | 70 | // generate admin user name of $username |
71 | - if (($pos = strpos($this->acc_imap_admin_username, '*')) !== false) // remove evtl. set username |
|
71 | + if (($pos = strpos($this->acc_imap_admin_username, '*')) !== false) |
|
72 | + { |
|
73 | + // remove evtl. set username |
|
72 | 74 | { |
73 | 75 | $this->params['acc_imap_admin_username'] = substr($this->acc_imap_admin_username, $pos+1); |
74 | 76 | } |
77 | + } |
|
75 | 78 | $this->params['acc_imap_admin_username'] = (is_string($_username) ? $_username : $this->acc_imap_username). |
76 | 79 | '*'.$this->acc_imap_admin_username; |
77 | 80 | |
@@ -185,7 +188,10 @@ discard block |
||
185 | 188 | { |
186 | 189 | foreach(scandir($path) as $file) |
187 | 190 | { |
188 | - if ($file == '.' || $file == '..') continue; |
|
191 | + if ($file == '.' || $file == '..') |
|
192 | + { |
|
193 | + continue; |
|
194 | + } |
|
189 | 195 | |
190 | 196 | if (is_dir($path)) |
191 | 197 | { |
@@ -217,8 +223,14 @@ discard block |
||
217 | 223 | */ |
218 | 224 | function getUserData($_username) |
219 | 225 | { |
220 | - if (isset($this->username)) $bufferUsername = $this->username; |
|
221 | - if (isset($this->loginName)) $bufferLoginName = $this->loginName; |
|
226 | + if (isset($this->username)) |
|
227 | + { |
|
228 | + $bufferUsername = $this->username; |
|
229 | + } |
|
230 | + if (isset($this->loginName)) |
|
231 | + { |
|
232 | + $bufferLoginName = $this->loginName; |
|
233 | + } |
|
222 | 234 | $this->username = $this->loginName = $_username; |
223 | 235 | |
224 | 236 | // now disconnect to be able to reestablish the connection with the targetUser while we go on |
@@ -29,15 +29,15 @@ discard block |
||
29 | 29 | */ |
30 | 30 | const LEVEL = Api\Cache::INSTANCE; |
31 | 31 | |
32 | - /** |
|
33 | - * Retrieve cached data. |
|
34 | - * |
|
35 | - * @param string $key Object ID to query. |
|
36 | - * @param integer $lifetime Lifetime of the object in seconds. |
|
37 | - * |
|
38 | - * @return mixed Cached data, or false if none was found. |
|
39 | - */ |
|
40 | - public function get($key, $lifetime = 0) |
|
32 | + /** |
|
33 | + * Retrieve cached data. |
|
34 | + * |
|
35 | + * @param string $key Object ID to query. |
|
36 | + * @param integer $lifetime Lifetime of the object in seconds. |
|
37 | + * |
|
38 | + * @return mixed Cached data, or false if none was found. |
|
39 | + */ |
|
40 | + public function get($key, $lifetime = 0) |
|
41 | 41 | { |
42 | 42 | unset($lifetime); // not (yet) used, but required by function signature |
43 | 43 | |
@@ -46,54 +46,54 @@ discard block |
||
46 | 46 | return !is_null($ret) ? $ret : false; |
47 | 47 | } |
48 | 48 | |
49 | - /** |
|
50 | - * Store an object in the cache. |
|
51 | - * |
|
52 | - * @param string $key Object ID used as the caching key. |
|
53 | - * @param mixed $data Data to store in the cache. |
|
54 | - * @param integer $lifetime Object lifetime - i.e. the time before the |
|
55 | - * data becomes available for garbage |
|
56 | - * collection. If 0 will not be GC'd. |
|
57 | - */ |
|
58 | - public function set($key, $data, $lifetime = 0) |
|
49 | + /** |
|
50 | + * Store an object in the cache. |
|
51 | + * |
|
52 | + * @param string $key Object ID used as the caching key. |
|
53 | + * @param mixed $data Data to store in the cache. |
|
54 | + * @param integer $lifetime Object lifetime - i.e. the time before the |
|
55 | + * data becomes available for garbage |
|
56 | + * collection. If 0 will not be GC'd. |
|
57 | + */ |
|
58 | + public function set($key, $data, $lifetime = 0) |
|
59 | 59 | { |
60 | 60 | Api\Cache::setCache(self::LEVEL, 'mail', $key, $data, $lifetime); |
61 | 61 | } |
62 | 62 | |
63 | - /** |
|
64 | - * Checks if a given key exists in the cache, valid for the given |
|
65 | - * lifetime. |
|
66 | - * |
|
67 | - * @param string $key Cache key to check. |
|
68 | - * @param integer $lifetime Lifetime of the key in seconds. |
|
69 | - * |
|
70 | - * @return boolean Existence. |
|
71 | - */ |
|
72 | - public function exists($key, $lifetime = 0) |
|
63 | + /** |
|
64 | + * Checks if a given key exists in the cache, valid for the given |
|
65 | + * lifetime. |
|
66 | + * |
|
67 | + * @param string $key Cache key to check. |
|
68 | + * @param integer $lifetime Lifetime of the key in seconds. |
|
69 | + * |
|
70 | + * @return boolean Existence. |
|
71 | + */ |
|
72 | + public function exists($key, $lifetime = 0) |
|
73 | 73 | { |
74 | 74 | unset($lifetime); // not (yet) used, but required by function signature |
75 | 75 | |
76 | 76 | return !is_null(Api\Cache::getCache(self::LEVEL, 'mail', $key)); |
77 | 77 | } |
78 | 78 | |
79 | - /** |
|
80 | - * Expire any existing data for the given key. |
|
81 | - * |
|
82 | - * @param string $key Cache key to expire. |
|
83 | - * |
|
84 | - * @return boolean Success or failure. |
|
85 | - */ |
|
86 | - public function expire($key) |
|
79 | + /** |
|
80 | + * Expire any existing data for the given key. |
|
81 | + * |
|
82 | + * @param string $key Cache key to expire. |
|
83 | + * |
|
84 | + * @return boolean Success or failure. |
|
85 | + */ |
|
86 | + public function expire($key) |
|
87 | 87 | { |
88 | 88 | Api\Cache::unsetCache(self::LEVEL, 'mail', $key); |
89 | 89 | } |
90 | 90 | |
91 | - /** |
|
92 | - * Clears all data from the cache. |
|
93 | - * |
|
94 | - * @throws Horde_Cache_Exception |
|
95 | - */ |
|
96 | - public function clear() |
|
91 | + /** |
|
92 | + * Clears all data from the cache. |
|
93 | + * |
|
94 | + * @throws Horde_Cache_Exception |
|
95 | + */ |
|
96 | + public function clear() |
|
97 | 97 | { |
98 | 98 | Api\Cache::flush(self::LEVEL, self::APP); |
99 | 99 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function get($key, $lifetime = 0) |
41 | 41 | { |
42 | - unset($lifetime); // not (yet) used, but required by function signature |
|
42 | + unset($lifetime); // not (yet) used, but required by function signature |
|
43 | 43 | |
44 | 44 | $ret = Api\Cache::getCache(self::LEVEL, 'mail', $key); |
45 | 45 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function exists($key, $lifetime = 0) |
73 | 73 | { |
74 | - unset($lifetime); // not (yet) used, but required by function signature |
|
74 | + unset($lifetime); // not (yet) used, but required by function signature |
|
75 | 75 | |
76 | 76 | return !is_null(Api\Cache::getCache(self::LEVEL, 'mail', $key)); |
77 | 77 | } |
@@ -81,7 +81,7 @@ |
||
81 | 81 | * |
82 | 82 | * @param string $key Cache key to expire. |
83 | 83 | * |
84 | - * @return boolean Success or failure. |
|
84 | + * @return boolean|null Success or failure. |
|
85 | 85 | */ |
86 | 86 | public function expire($key) |
87 | 87 | { |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @return mixed Cached data, or false if none was found. |
39 | 39 | */ |
40 | 40 | public function get($key, $lifetime = 0) |
41 | - { |
|
41 | + { |
|
42 | 42 | unset($lifetime); // not (yet) used, but required by function signature |
43 | 43 | |
44 | 44 | $ret = Api\Cache::getCache(self::LEVEL, 'mail', $key); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * collection. If 0 will not be GC'd. |
57 | 57 | */ |
58 | 58 | public function set($key, $data, $lifetime = 0) |
59 | - { |
|
59 | + { |
|
60 | 60 | Api\Cache::setCache(self::LEVEL, 'mail', $key, $data, $lifetime); |
61 | 61 | } |
62 | 62 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return boolean Existence. |
71 | 71 | */ |
72 | 72 | public function exists($key, $lifetime = 0) |
73 | - { |
|
73 | + { |
|
74 | 74 | unset($lifetime); // not (yet) used, but required by function signature |
75 | 75 | |
76 | 76 | return !is_null(Api\Cache::getCache(self::LEVEL, 'mail', $key)); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @return boolean Success or failure. |
85 | 85 | */ |
86 | 86 | public function expire($key) |
87 | - { |
|
87 | + { |
|
88 | 88 | Api\Cache::unsetCache(self::LEVEL, 'mail', $key); |
89 | 89 | } |
90 | 90 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @throws Horde_Cache_Exception |
95 | 95 | */ |
96 | 96 | public function clear() |
97 | - { |
|
97 | + { |
|
98 | 98 | Api\Cache::flush(self::LEVEL, self::APP); |
99 | 99 | } |
100 | 100 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | */ |
134 | 134 | protected function getLdapConnection() |
135 | 135 | { |
136 | - static $ldap=null; |
|
136 | + static $ldap = null; |
|
137 | 137 | |
138 | 138 | if (is_null($ldap)) |
139 | 139 | { |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @param string $defaultDomain =null |
153 | 153 | */ |
154 | - function __construct($defaultDomain=null) |
|
154 | + function __construct($defaultDomain = null) |
|
155 | 155 | { |
156 | 156 | parent::__construct($defaultDomain); |
157 | 157 |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * Primary mail address required as an alias too: true or false |
52 | 52 | */ |
53 | - const REQUIRE_MAIL_AS_ALIAS=false; |
|
53 | + const REQUIRE_MAIL_AS_ALIAS = false; |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * Attribute for forwards OR false if not possible |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | function addAccountExtra(array $_hookValues, array $allValues, array &$newData) |
97 | 97 | { |
98 | - unset($_hookValues); // not used, but required by function signature |
|
98 | + unset($_hookValues); // not used, but required by function signature |
|
99 | 99 | |
100 | 100 | if (empty($allValues['univentionmailhomeserver'][0]) && $newData[self::MAIL_ENABLE_ATTR]) |
101 | 101 | { |