@@ -176,6 +176,11 @@ discard block |
||
| 176 | 176 | return is_array($id) ? $links : ($links[$id] ? $links[$id] : array()); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | + /** |
|
| 180 | + * @param boolean $left |
|
| 181 | + * @param string $only_app |
|
| 182 | + * @param boolean $not_only |
|
| 183 | + */ |
|
| 179 | 184 | private static function _add2links($row,$left,$only_app,$not_only,array &$links) |
| 180 | 185 | { |
| 181 | 186 | $linked_app = $left ? $row['link_app2'] : $row['link_app1']; |
@@ -206,7 +211,7 @@ discard block |
||
| 206 | 211 | * @param string $id ='' id in $app, if no integer link_id given in $app_link_id |
| 207 | 212 | * @param string $app2 ='' appname of 2. endpoint of the link, if no integer link_id given in $app_link_id |
| 208 | 213 | * @param string $id2 ='' id in $app2, if no integer link_id given in $app_link_id |
| 209 | - * @return array with link-data or False |
|
| 214 | + * @return string with link-data or False |
|
| 210 | 215 | */ |
| 211 | 216 | static function get_link($app_link_id,$id='',$app2='',$id2='') |
| 212 | 217 | { |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | echo "<p>solink.link('$app1',$id1,'$app2',$id2,'$remark',$owner)</p>\n"; |
| 67 | 67 | } |
| 68 | 68 | if ($app1 == $app2 && $id1 == $id2 || |
| 69 | - $id1 == '' || $id2 == '' || $app1 == '' || $app2 == '') |
|
| 69 | + $id1 == '' || $id2 == '' || $app1 == '' || $app2 == '') |
|
| 70 | 70 | { |
| 71 | 71 | return False; // dont link to self or other nosense |
| 72 | 72 | } |
@@ -412,26 +412,26 @@ discard block |
||
| 412 | 412 | array('table'=>self::TABLE, |
| 413 | 413 | 'cols'=>'c.*,b.link_app1 AS app3,b.link_id1 AS id3,b.link_id AS link3', |
| 414 | 414 | 'where'=>'a.link_app1='.self::$db->quote($app).' AND c.link_app2='.self::$db->quote($target_app). |
| 415 | - (!$target_id ? '' : self::$db->expression(self::TABLE,' AND c.',array('link_id2' => $target_id))), |
|
| 416 | - 'join'=>" a |
|
| 415 | + (!$target_id ? '' : self::$db->expression(self::TABLE,' AND c.',array('link_id2' => $target_id))), |
|
| 416 | + 'join'=>" a |
|
| 417 | 417 | JOIN $table b ON a.link_id2=b.link_id1 AND a.link_app2=b.link_app1 |
| 418 | 418 | JOIN $table c ON a.link_id1=c.link_id1 AND a.link_app1=c.link_app1 AND a.link_id!=c.link_id AND c.link_app2=b.link_app2 AND c.link_id2=b.link_id2", |
| 419 | 419 | ), |
| 420 | 420 | // retrieve the type of links, where the relation is realized as timesheet->infolog/tracker and projectmanager->timesheet |
| 421 | 421 | array('table'=>self::TABLE, |
| 422 | 422 | 'cols'=>'b.link_id, b.link_app2 as app1, b.link_id2 as id1, b.link_app1 as app2, b.link_id1 as id2, b.link_remark,b.link_lastmod,b.link_owner,b.deleted,c.link_app1 AS app3,c.link_id1 AS id3,c.link_id AS link3', |
| 423 | - 'where'=>'a.link_app1='.self::$db->quote($app).' AND b.link_app1='.self::$db->quote($target_app). |
|
| 424 | - (!$target_id ? '' : self::$db->expression(self::TABLE,' AND b.',array('link_id1' => $target_id))), |
|
| 425 | - 'join'=>" a |
|
| 423 | + 'where'=>'a.link_app1='.self::$db->quote($app).' AND b.link_app1='.self::$db->quote($target_app). |
|
| 424 | + (!$target_id ? '' : self::$db->expression(self::TABLE,' AND b.',array('link_id1' => $target_id))), |
|
| 425 | + 'join'=>" a |
|
| 426 | 426 | JOIN $table b ON a.link_id1=b.link_id2 AND a.link_app1=b.link_app2 |
| 427 | 427 | JOIN $table c ON a.link_id2=c.link_id1 AND a.link_app2=c.link_app1 AND a.link_id!=c.link_id AND c.link_app2=b.link_app1 AND c.link_id2=b.link_id1", |
| 428 | 428 | ), |
| 429 | 429 | // retrieve the type of links, where the relation is realized as timesheet->projectmanager and infolog->timesheet |
| 430 | 430 | array('table'=>self::TABLE, |
| 431 | 431 | 'cols'=>'a.*,c.link_app1 AS app3,c.link_id1 AS id3,c.link_id AS link3', |
| 432 | - 'where'=>'a.link_app1='.self::$db->quote($app).' AND a.link_app2='.self::$db->quote($target_app). |
|
| 433 | - (!$target_id ? '' : self::$db->expression(self::TABLE,' AND a.',array('link_id2' => $target_id))), |
|
| 434 | - 'join'=>" a |
|
| 432 | + 'where'=>'a.link_app1='.self::$db->quote($app).' AND a.link_app2='.self::$db->quote($target_app). |
|
| 433 | + (!$target_id ? '' : self::$db->expression(self::TABLE,' AND a.',array('link_id2' => $target_id))), |
|
| 434 | + 'join'=>" a |
|
| 435 | 435 | JOIN $table b ON a.link_id1=b.link_id2 AND a.link_app1=b.link_app2 |
| 436 | 436 | JOIN $table c ON a.link_id2=c.link_id2 AND a.link_app2=c.link_app2 AND a.link_id!=c.link_id AND c.link_app1=b.link_app1 AND c.link_id1=b.link_id1", |
| 437 | 437 | ), |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * @param int $lastmod =0 timestamp of last modification (defaults to now=time()) |
| 60 | 60 | * @return int/boolean False (for db or param-error) or on success link_id (Please not the return-value of $id1) |
| 61 | 61 | */ |
| 62 | - static function link( $app1,&$id1,$app2,$id2='',$remark='',$owner=0,$lastmod=0 ) |
|
| 62 | + static function link($app1, &$id1, $app2, $id2 = '', $remark = '', $owner = 0, $lastmod = 0) |
|
| 63 | 63 | { |
| 64 | 64 | if (self::DEBUG) |
| 65 | 65 | { |
@@ -68,21 +68,21 @@ discard block |
||
| 68 | 68 | if ($app1 == $app2 && $id1 == $id2 || |
| 69 | 69 | $id1 == '' || $id2 == '' || $app1 == '' || $app2 == '') |
| 70 | 70 | { |
| 71 | - return False; // dont link to self or other nosense |
|
| 71 | + return False; // dont link to self or other nosense |
|
| 72 | 72 | } |
| 73 | - if (($link = self::get_link($app1,$id1,$app2,$id2))) |
|
| 73 | + if (($link = self::get_link($app1, $id1, $app2, $id2))) |
|
| 74 | 74 | { |
| 75 | 75 | if ($link['link_remark'] != $remark) |
| 76 | 76 | { |
| 77 | - self::update_remark($link['link_id'],$remark); |
|
| 77 | + self::update_remark($link['link_id'], $remark); |
|
| 78 | 78 | } |
| 79 | - return $link['link_id']; // link alread exist |
|
| 79 | + return $link['link_id']; // link alread exist |
|
| 80 | 80 | } |
| 81 | 81 | if (!$owner) |
| 82 | 82 | { |
| 83 | 83 | $owner = $GLOBALS['egw_info']['user']['account_id']; |
| 84 | 84 | } |
| 85 | - return self::$db->insert(self::TABLE,array( |
|
| 85 | + return self::$db->insert(self::TABLE, array( |
|
| 86 | 86 | 'link_app1' => $app1, |
| 87 | 87 | 'link_id1' => $id1, |
| 88 | 88 | 'link_app2' => $app2, |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | 'link_remark' => $remark, |
| 91 | 91 | 'link_lastmod' => $lastmod ? $lastmod : time(), |
| 92 | 92 | 'link_owner' => $owner, |
| 93 | - ),False,__LINE__,__FILE__) ? self::$db->get_last_insert_id(self::TABLE,'link_id') : false; |
|
| 93 | + ), False, __LINE__, __FILE__) ? self::$db->get_last_insert_id(self::TABLE, 'link_id') : false; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -100,14 +100,14 @@ discard block |
||
| 100 | 100 | * @param string $remark new text for the remark |
| 101 | 101 | * @return boolean true on success, else false |
| 102 | 102 | */ |
| 103 | - static function update_remark($link_id,$remark) |
|
| 103 | + static function update_remark($link_id, $remark) |
|
| 104 | 104 | { |
| 105 | - return self::$db->update(self::TABLE,array( |
|
| 105 | + return self::$db->update(self::TABLE, array( |
|
| 106 | 106 | 'link_remark' => $remark, |
| 107 | 107 | 'link_lastmod' => time(), |
| 108 | - ),array( |
|
| 108 | + ), array( |
|
| 109 | 109 | 'link_id' => $link_id, |
| 110 | - ),__LINE__,__FILE__); |
|
| 110 | + ), __LINE__, __FILE__); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -121,15 +121,15 @@ discard block |
||
| 121 | 121 | * @param int|array $limit =null number of entries to return, default null = all or array(offset, num_rows) to return num_rows starting from offset |
| 122 | 122 | * @return array id => links pairs if $id is an array or just the links (only_app: ids) or empty array if no matching links found |
| 123 | 123 | */ |
| 124 | - static function get_links($app, $id, $only_app='', $order='link_lastmod DESC', $deleted=false, $limit=null) |
|
| 124 | + static function get_links($app, $id, $only_app = '', $order = 'link_lastmod DESC', $deleted = false, $limit = null) |
|
| 125 | 125 | { |
| 126 | 126 | if (self::DEBUG) |
| 127 | 127 | { |
| 128 | - echo "<p>solink.get_links($app,".print_r($id,true).",$only_app,$order,$deleted)</p>\n"; |
|
| 128 | + echo "<p>solink.get_links($app,".print_r($id, true).",$only_app,$order,$deleted)</p>\n"; |
|
| 129 | 129 | } |
| 130 | 130 | if (($not_only = $only_app[0] == '!')) |
| 131 | 131 | { |
| 132 | - $only_app = substr($only_app,1); |
|
| 132 | + $only_app = substr($only_app, 1); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | $offset = false; |
@@ -137,32 +137,32 @@ discard block |
||
| 137 | 137 | { |
| 138 | 138 | list($offset, $limit) = $limit; |
| 139 | 139 | } |
| 140 | - elseif($limit) |
|
| 140 | + elseif ($limit) |
|
| 141 | 141 | { |
| 142 | 142 | $offset = 0; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | $links = array(); |
| 146 | 146 | try { |
| 147 | - foreach(self::$db->select(self::TABLE, '*', self::$db->expression(self::TABLE, '((', array( |
|
| 147 | + foreach (self::$db->select(self::TABLE, '*', self::$db->expression(self::TABLE, '((', array( |
|
| 148 | 148 | 'link_app1' => $app, |
| 149 | 149 | 'link_id1' => $id, |
| 150 | - ),') OR (',array( |
|
| 150 | + ), ') OR (', array( |
|
| 151 | 151 | 'link_app2' => $app, |
| 152 | 152 | 'link_id2' => $id, |
| 153 | - ),'))', |
|
| 153 | + ), '))', |
|
| 154 | 154 | $deleted ? '' : ' AND deleted IS NULL' |
| 155 | 155 | ), __LINE__, __FILE__, $offset, $order ? " ORDER BY $order" : '', 'phpgwapi', $limit) as $row) |
| 156 | 156 | { |
| 157 | 157 | // check if left side (1) is one of our targets --> add it |
| 158 | - if ($row['link_app1'] == $app && in_array($row['link_id1'],(array)$id)) |
|
| 158 | + if ($row['link_app1'] == $app && in_array($row['link_id1'], (array)$id)) |
|
| 159 | 159 | { |
| 160 | - self::_add2links($row,true,$only_app,$not_only,$links); |
|
| 160 | + self::_add2links($row, true, $only_app, $not_only, $links); |
|
| 161 | 161 | } |
| 162 | 162 | // check if right side (2) is one of our targets --> add it (both can be true for multiple targets!) |
| 163 | - if ($row['link_app2'] == $app && in_array($row['link_id2'],(array)$id)) |
|
| 163 | + if ($row['link_app2'] == $app && in_array($row['link_id2'], (array)$id)) |
|
| 164 | 164 | { |
| 165 | - self::_add2links($row,false,$only_app,$not_only,$links); |
|
| 165 | + self::_add2links($row, false, $only_app, $not_only, $links); |
|
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | // if query returns exactly limit rows, we assume there are more and therefore set self::$limit_exceeded |
@@ -170,18 +170,18 @@ discard block |
||
| 170 | 170 | } |
| 171 | 171 | // catch Illegal mix of collations (ascii_general_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=' (1267) |
| 172 | 172 | // caused by non-ascii chars compared with ascii field uid |
| 173 | - catch(Api\Db\Exception $e) { |
|
| 173 | + catch (Api\Db\Exception $e) { |
|
| 174 | 174 | _egw_log_exception($e); |
| 175 | 175 | } |
| 176 | 176 | return is_array($id) ? $links : ($links[$id] ? $links[$id] : array()); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - private static function _add2links($row,$left,$only_app,$not_only,array &$links) |
|
| 179 | + private static function _add2links($row, $left, $only_app, $not_only, array &$links) |
|
| 180 | 180 | { |
| 181 | 181 | $linked_app = $left ? $row['link_app2'] : $row['link_app1']; |
| 182 | 182 | $linked_id = $left ? $row['link_id2'] : $row['link_id1']; |
| 183 | 183 | $app_id = $left ? $row['link_id1'] : $row['link_id2']; |
| 184 | - list($app) = explode('-',$linked_app); |
|
| 184 | + list($app) = explode('-', $linked_app); |
|
| 185 | 185 | if ($only_app && $not_only == ($linked_app == $only_app) || !$GLOBALS['egw_info']['user']['apps'][$app]) |
| 186 | 186 | { |
| 187 | 187 | #echo "$linked_app == $only_app, ";var_dump($linked_app == $only_app);echo " ->dont return a link<br>"; |
@@ -208,13 +208,13 @@ discard block |
||
| 208 | 208 | * @param string $id2 ='' id in $app2, if no integer link_id given in $app_link_id |
| 209 | 209 | * @return array with link-data or False |
| 210 | 210 | */ |
| 211 | - static function get_link($app_link_id,$id='',$app2='',$id2='') |
|
| 211 | + static function get_link($app_link_id, $id = '', $app2 = '', $id2 = '') |
|
| 212 | 212 | { |
| 213 | 213 | if (self::DEBUG) |
| 214 | 214 | { |
| 215 | 215 | echo "<p>solink.get_link('$app_link_id',$id,'$app2','$id2')</p>\n"; |
| 216 | 216 | } |
| 217 | - if ((int) $app_link_id > 0) |
|
| 217 | + if ((int)$app_link_id > 0) |
|
| 218 | 218 | { |
| 219 | 219 | $where = array('link_id' => $app_link_id); |
| 220 | 220 | } |
@@ -224,24 +224,24 @@ discard block |
||
| 224 | 224 | { |
| 225 | 225 | return False; |
| 226 | 226 | } |
| 227 | - $where = self::$db->expression(self::TABLE,'(',array( |
|
| 227 | + $where = self::$db->expression(self::TABLE, '(', array( |
|
| 228 | 228 | 'link_app1' => $app_link_id, |
| 229 | 229 | 'link_id1' => $id, |
| 230 | 230 | 'link_app2' => $app2, |
| 231 | 231 | 'link_id2' => $id2, |
| 232 | - ),') OR (',array( |
|
| 232 | + ), ') OR (', array( |
|
| 233 | 233 | 'link_app2' => $app_link_id, |
| 234 | 234 | 'link_id2' => $id, |
| 235 | 235 | 'link_app1' => $app2, |
| 236 | 236 | 'link_id1' => $id2, |
| 237 | - ),')'); |
|
| 237 | + ), ')'); |
|
| 238 | 238 | } |
| 239 | 239 | try { |
| 240 | - return self::$db->select(self::TABLE,'*',$where,__LINE__,__FILE__)->fetch(ADODB_FETCH_ASSOC); |
|
| 240 | + return self::$db->select(self::TABLE, '*', $where, __LINE__, __FILE__)->fetch(ADODB_FETCH_ASSOC); |
|
| 241 | 241 | } |
| 242 | 242 | // catch Illegal mix of collations (ascii_general_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=' (1267) |
| 243 | 243 | // caused by non-ascii chars compared with ascii field uid |
| 244 | - catch(Api\Db\Exception $e) { |
|
| 244 | + catch (Api\Db\Exception $e) { |
|
| 245 | 245 | _egw_log_exception($e); |
| 246 | 246 | } |
| 247 | 247 | return false; |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | * @param boolean $hold_for_purge Don't really delete the link, just mark it as deleted and wait for final delete of linked entry |
| 260 | 260 | * @return array with deleted links |
| 261 | 261 | */ |
| 262 | - static function unlink($link_id,$app='',$id='',$owner=0,$app2='',$id2='',$hold_for_purge=false) |
|
| 262 | + static function unlink($link_id, $app = '', $id = '', $owner = 0, $app2 = '', $id2 = '', $hold_for_purge = false) |
|
| 263 | 263 | { |
| 264 | 264 | if (self::DEBUG) |
| 265 | 265 | { |
@@ -284,21 +284,21 @@ discard block |
||
| 284 | 284 | $check1['link_id1'] = $id; |
| 285 | 285 | $check2['link_id2'] = $id; |
| 286 | 286 | } |
| 287 | - $where = self::$db->expression(self::TABLE,'((',$check1,') OR (',$check2,'))'); |
|
| 287 | + $where = self::$db->expression(self::TABLE, '((', $check1, ') OR (', $check2, '))'); |
|
| 288 | 288 | } |
| 289 | 289 | elseif ($app != '' && $app2 != '') |
| 290 | 290 | { |
| 291 | - $where = self::$db->expression(self::TABLE,'(',array( |
|
| 291 | + $where = self::$db->expression(self::TABLE, '(', array( |
|
| 292 | 292 | 'link_app1' => $app, |
| 293 | 293 | 'link_id1' => $id, |
| 294 | 294 | 'link_app2' => $app2, |
| 295 | 295 | 'link_id2' => $id2, |
| 296 | - ),') OR (',array( |
|
| 296 | + ), ') OR (', array( |
|
| 297 | 297 | 'link_app1' => $app2, |
| 298 | 298 | 'link_id1' => $id2, |
| 299 | 299 | 'link_app2' => $app, |
| 300 | 300 | 'link_id2' => $id, |
| 301 | - ),')'); |
|
| 301 | + ), ')'); |
|
| 302 | 302 | } |
| 303 | 303 | if ($owner) |
| 304 | 304 | { |
@@ -308,25 +308,25 @@ discard block |
||
| 308 | 308 | } |
| 309 | 309 | $deleted = array(); |
| 310 | 310 | try { |
| 311 | - foreach(self::$db->select(self::TABLE,'*',$where,__LINE__,__FILE__) as $row) |
|
| 311 | + foreach (self::$db->select(self::TABLE, '*', $where, __LINE__, __FILE__) as $row) |
|
| 312 | 312 | { |
| 313 | 313 | $deleted[] = $row; |
| 314 | 314 | } |
| 315 | - if($hold_for_purge) |
|
| 315 | + if ($hold_for_purge) |
|
| 316 | 316 | { |
| 317 | - self::$db->update(self::TABLE,array( |
|
| 317 | + self::$db->update(self::TABLE, array( |
|
| 318 | 318 | 'deleted' => time(), |
| 319 | 319 | 'link_lastmod' => time(), |
| 320 | - ), $where, __LINE__,__FILE__); |
|
| 320 | + ), $where, __LINE__, __FILE__); |
|
| 321 | 321 | } |
| 322 | 322 | else |
| 323 | 323 | { |
| 324 | - self::$db->delete(self::TABLE,$where,__LINE__,__FILE__); |
|
| 324 | + self::$db->delete(self::TABLE, $where, __LINE__, __FILE__); |
|
| 325 | 325 | } |
| 326 | 326 | } |
| 327 | 327 | // catch Illegal mix of collations (ascii_general_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=' (1267) |
| 328 | 328 | // caused by non-ascii chars compared with ascii field uid |
| 329 | - catch(Api\Db\Exception $e) { |
|
| 329 | + catch (Api\Db\Exception $e) { |
|
| 330 | 330 | _egw_log_exception($e); |
| 331 | 331 | } |
| 332 | 332 | |
@@ -357,8 +357,8 @@ discard block |
||
| 357 | 357 | $check1['link_id1'] = $id; |
| 358 | 358 | $check2['link_id2'] = $id; |
| 359 | 359 | } |
| 360 | - $where = self::$db->expression(self::TABLE,'((',$check1,') OR (',$check2,'))'); |
|
| 361 | - self::$db->update(self::TABLE,array('deleted'=> null), $where, __LINE__,__FILE__); |
|
| 360 | + $where = self::$db->expression(self::TABLE, '((', $check1, ') OR (', $check2, '))'); |
|
| 361 | + self::$db->update(self::TABLE, array('deleted'=> null), $where, __LINE__, __FILE__); |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | /** |
@@ -371,13 +371,13 @@ discard block |
||
| 371 | 371 | * @param int $new_owner account_id of new owner |
| 372 | 372 | * @return int number of links changed |
| 373 | 373 | */ |
| 374 | - static function chown($owner,$new_owner) |
|
| 374 | + static function chown($owner, $new_owner) |
|
| 375 | 375 | { |
| 376 | - if ((int)$owner <= 0 || (int) $new_owner <= 0) |
|
| 376 | + if ((int)$owner <= 0 || (int)$new_owner <= 0) |
|
| 377 | 377 | { |
| 378 | 378 | return 0; |
| 379 | 379 | } |
| 380 | - self::$db->update(self::TABLE,array('owner'=>$new_owner),array('owner'=>$owner),__LINE__,__FILE__); |
|
| 380 | + self::$db->update(self::TABLE, array('owner'=>$new_owner), array('owner'=>$owner), __LINE__, __FILE__); |
|
| 381 | 381 | |
| 382 | 382 | return self::$db->affected_rows(); |
| 383 | 383 | } |
@@ -404,15 +404,15 @@ discard block |
||
| 404 | 404 | * @param int|array $limit =null number of entries to return, default null = all or array(offset, num_rows) to return num_rows starting from offset |
| 405 | 405 | * @return array with links from entries from $app to $target_app/$target_id plus the other (b) link_id/app/id in the keys 'link3'/'app3'/'id3' |
| 406 | 406 | */ |
| 407 | - static function get_3links($app, $target_app, $target_id=null, $just_app_ids=false, $order='link_lastmod DESC', $limit=null) |
|
| 407 | + static function get_3links($app, $target_app, $target_id = null, $just_app_ids = false, $order = 'link_lastmod DESC', $limit = null) |
|
| 408 | 408 | { |
| 409 | 409 | $table = self::TABLE; |
| 410 | - $arrayofselects=array( |
|
| 410 | + $arrayofselects = array( |
|
| 411 | 411 | // retrieve the type of links, where the relation is realized as timesheet->infolog/tracker via infolog->projectmanager to timesheet->projectmanager |
| 412 | 412 | array('table'=>self::TABLE, |
| 413 | 413 | 'cols'=>'c.*,b.link_app1 AS app3,b.link_id1 AS id3,b.link_id AS link3', |
| 414 | 414 | 'where'=>'a.link_app1='.self::$db->quote($app).' AND c.link_app2='.self::$db->quote($target_app). |
| 415 | - (!$target_id ? '' : self::$db->expression(self::TABLE,' AND c.',array('link_id2' => $target_id))), |
|
| 415 | + (!$target_id ? '' : self::$db->expression(self::TABLE, ' AND c.', array('link_id2' => $target_id))), |
|
| 416 | 416 | 'join'=>" a |
| 417 | 417 | JOIN $table b ON a.link_id2=b.link_id1 AND a.link_app2=b.link_app1 |
| 418 | 418 | JOIN $table c ON a.link_id1=c.link_id1 AND a.link_app1=c.link_app1 AND a.link_id!=c.link_id AND c.link_app2=b.link_app2 AND c.link_id2=b.link_id2", |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | array('table'=>self::TABLE, |
| 422 | 422 | 'cols'=>'b.link_id, b.link_app2 as app1, b.link_id2 as id1, b.link_app1 as app2, b.link_id1 as id2, b.link_remark,b.link_lastmod,b.link_owner,b.deleted,c.link_app1 AS app3,c.link_id1 AS id3,c.link_id AS link3', |
| 423 | 423 | 'where'=>'a.link_app1='.self::$db->quote($app).' AND b.link_app1='.self::$db->quote($target_app). |
| 424 | - (!$target_id ? '' : self::$db->expression(self::TABLE,' AND b.',array('link_id1' => $target_id))), |
|
| 424 | + (!$target_id ? '' : self::$db->expression(self::TABLE, ' AND b.', array('link_id1' => $target_id))), |
|
| 425 | 425 | 'join'=>" a |
| 426 | 426 | JOIN $table b ON a.link_id1=b.link_id2 AND a.link_app1=b.link_app2 |
| 427 | 427 | JOIN $table c ON a.link_id2=c.link_id1 AND a.link_app2=c.link_app1 AND a.link_id!=c.link_id AND c.link_app2=b.link_app1 AND c.link_id2=b.link_id1", |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | array('table'=>self::TABLE, |
| 431 | 431 | 'cols'=>'a.*,c.link_app1 AS app3,c.link_id1 AS id3,c.link_id AS link3', |
| 432 | 432 | 'where'=>'a.link_app1='.self::$db->quote($app).' AND a.link_app2='.self::$db->quote($target_app). |
| 433 | - (!$target_id ? '' : self::$db->expression(self::TABLE,' AND a.',array('link_id2' => $target_id))), |
|
| 433 | + (!$target_id ? '' : self::$db->expression(self::TABLE, ' AND a.', array('link_id2' => $target_id))), |
|
| 434 | 434 | 'join'=>" a |
| 435 | 435 | JOIN $table b ON a.link_id1=b.link_id2 AND a.link_app1=b.link_app2 |
| 436 | 436 | JOIN $table c ON a.link_id2=c.link_id2 AND a.link_app2=c.link_app2 AND a.link_id!=c.link_id AND c.link_app1=b.link_app1 AND c.link_id1=b.link_id1", |
@@ -442,17 +442,17 @@ discard block |
||
| 442 | 442 | { |
| 443 | 443 | list($offset, $limit) = $limit; |
| 444 | 444 | } |
| 445 | - elseif($limit) |
|
| 445 | + elseif ($limit) |
|
| 446 | 446 | { |
| 447 | 447 | $offset = 0; |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | $links = array(); |
| 451 | - foreach(self::$db->union($arrayofselects, __LINE__, __FILE__, $order, $offset, $limit) as $row) |
|
| 451 | + foreach (self::$db->union($arrayofselects, __LINE__, __FILE__, $order, $offset, $limit) as $row) |
|
| 452 | 452 | { |
| 453 | 453 | if ($just_app_ids) |
| 454 | 454 | { |
| 455 | - if ($row['link_app1'] == $target_app && (is_null($target_id) || in_array($row['link_id1'],(array)$target_id))) |
|
| 455 | + if ($row['link_app1'] == $target_app && (is_null($target_id) || in_array($row['link_id1'], (array)$target_id))) |
|
| 456 | 456 | { |
| 457 | 457 | $links[$row['link_id']] = $row['link_id2']; |
| 458 | 458 | } |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | } |
| 464 | 464 | else |
| 465 | 465 | { |
| 466 | - $links[] = Api\Db::strip_array_keys($row,'link_'); |
|
| 466 | + $links[] = Api\Db::strip_array_keys($row, 'link_'); |
|
| 467 | 467 | } |
| 468 | 468 | } |
| 469 | 469 | // if query returns exactly limit rows, we assume there are more and therefore set self::$limit_exceeded |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | */ |
| 478 | 478 | static function init_static( ) |
| 479 | 479 | { |
| 480 | - self::$db = $GLOBALS['egw']->db; |
|
| 480 | + self::$db = $GLOBALS['egw']->db; |
|
| 481 | 481 | } |
| 482 | 482 | } |
| 483 | 483 | Storage::init_static(); |
@@ -302,7 +302,10 @@ |
||
| 302 | 302 | } |
| 303 | 303 | if ($owner) |
| 304 | 304 | { |
| 305 | - if ($app) $where = array($where); |
|
| 305 | + if ($app) |
|
| 306 | + { |
|
| 307 | + $where = array($where); |
|
| 308 | + } |
|
| 306 | 309 | $where['link_owner'] = $owner; |
| 307 | 310 | } |
| 308 | 311 | } |
@@ -269,7 +269,7 @@ |
||
| 269 | 269 | { |
| 270 | 270 | $where = array('link_id' => $link_id); |
| 271 | 271 | } |
| 272 | - elseif ($app == '' AND $owner == '') |
|
| 272 | + elseif ($app == '' and $owner == '') |
|
| 273 | 273 | { |
| 274 | 274 | return 0; |
| 275 | 275 | } |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | * forceEAProfileLoad |
| 430 | 430 | * used to force the load of a specific emailadmin profile; we assume administrative use only (as of now) |
| 431 | 431 | * @param int $_profile_id |
| 432 | - * @return object instance of Mail (by reference) |
|
| 432 | + * @return Mail instance of Mail (by reference) |
|
| 433 | 433 | */ |
| 434 | 434 | public static function &forceEAProfileLoad($_profile_id) |
| 435 | 435 | { |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | /** |
| 705 | 705 | * Get all identities of given mailaccount |
| 706 | 706 | * |
| 707 | - * @param int|Mail\Account $account account-object or acc_id |
|
| 707 | + * @param integer $account account-object or acc_id |
|
| 708 | 708 | * @return array - array(email=>realname) |
| 709 | 709 | */ |
| 710 | 710 | function getAccountIdentities($account) |
@@ -1289,7 +1289,7 @@ discard block |
||
| 1289 | 1289 | * @param array $_filter filter to apply to getSortedList |
| 1290 | 1290 | * @param mixed $_thisUIDOnly = null, if given fetch the headers of this uid only (either one, or array of uids) |
| 1291 | 1291 | * @param boolean $_cacheResult = true try touse the cache of getSortedList |
| 1292 | - * @param mixed $_fetchPreviews = false (boolean/int) fetch part of the body of the messages requested (if integer the number is assumed to be the number of chars to be returned for preview; if set to true 300 chars are returned (when available)) |
|
| 1292 | + * @param boolean $_fetchPreviews = false (boolean/int) fetch part of the body of the messages requested (if integer the number is assumed to be the number of chars to be returned for preview; if set to true 300 chars are returned (when available)) |
|
| 1293 | 1293 | * @return array result as array(header=>array,total=>int,first=>int,last=>int) |
| 1294 | 1294 | */ |
| 1295 | 1295 | function getHeaders($_folderName, $_startMessage, $_numberOfMessages, $_sort, $_reverse, $_filter, $_thisUIDOnly=null, $_cacheResult=true, $_fetchPreviews=false) |
@@ -1866,6 +1866,7 @@ discard block |
||
| 1866 | 1866 | * |
| 1867 | 1867 | * @param mixed _sort the integer sort order / or a valid and handeled SORTSTRING (right now: UID/ARRIVAL/INTERNALDATE (->ARRIVAL)) |
| 1868 | 1868 | * @param bool _reverse wether to add REVERSE to the Sort String or not |
| 1869 | + * @param integer $_sort |
|
| 1869 | 1870 | * @return the sort sequence for horde search |
| 1870 | 1871 | */ |
| 1871 | 1872 | function _getSortString($_sort, $_reverse=false) |
@@ -2375,7 +2376,7 @@ discard block |
||
| 2375 | 2376 | * @param string _parent the parent foldername |
| 2376 | 2377 | * @param string _folderName the new foldername |
| 2377 | 2378 | * |
| 2378 | - * @return mixed name of the newly created folder or false on error |
|
| 2379 | + * @return string name of the newly created folder or false on error |
|
| 2379 | 2380 | * @throws Exception |
| 2380 | 2381 | */ |
| 2381 | 2382 | function renameFolder($_oldFolderName, $_parent, $_folderName) |
@@ -3247,7 +3248,7 @@ discard block |
||
| 3247 | 3248 | * @param string $_mailbox |
| 3248 | 3249 | * @param string $delimiter |
| 3249 | 3250 | * @param string $prefix |
| 3250 | - * @param string $reclevel 0, counter to keep track of the current recursionlevel |
|
| 3251 | + * @param integer $reclevel 0, counter to keep track of the current recursionlevel |
|
| 3251 | 3252 | * @return array of mailboxes |
| 3252 | 3253 | */ |
| 3253 | 3254 | function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel=0) |
@@ -3297,7 +3298,7 @@ discard block |
||
| 3297 | 3298 | * abstraction layer for getDraftFolder, getTemplateFolder, getTrashFolder and getSentFolder |
| 3298 | 3299 | * @param string $_type the type to fetch (Drafts|Template|Trash|Sent) |
| 3299 | 3300 | * @param boolean $_checkexistance trigger check for existance |
| 3300 | - * @param boolean& $created =null on return true: if folder was just created, false if not |
|
| 3301 | + * @param boolean $created =null on return true: if folder was just created, false if not |
|
| 3301 | 3302 | * @return mixed string or false |
| 3302 | 3303 | */ |
| 3303 | 3304 | function _getSpecialUseFolder($_type, $_checkexistance=TRUE, &$created=null) |
@@ -3429,7 +3430,7 @@ discard block |
||
| 3429 | 3430 | /** |
| 3430 | 3431 | * getTemplateFolder wrapper for _getSpecialUseFolder Type Template |
| 3431 | 3432 | * @param boolean $_checkexistance trigger check for existance |
| 3432 | - * @return mixed string or false |
|
| 3433 | + * @return string string or false |
|
| 3433 | 3434 | */ |
| 3434 | 3435 | function getTemplateFolder($_checkexistance=TRUE) |
| 3435 | 3436 | { |
@@ -3459,7 +3460,7 @@ discard block |
||
| 3459 | 3460 | /** |
| 3460 | 3461 | * getOutboxFolder wrapper for _getSpecialUseFolder Type Outbox |
| 3461 | 3462 | * @param boolean $_checkexistance trigger check for existance |
| 3462 | - * @return mixed string or false |
|
| 3463 | + * @return string string or false |
|
| 3463 | 3464 | */ |
| 3464 | 3465 | function getOutboxFolder($_checkexistance=TRUE) |
| 3465 | 3466 | { |
@@ -4298,7 +4299,7 @@ discard block |
||
| 4298 | 4299 | /** |
| 4299 | 4300 | * get part of the message, if its stucture is indicating its of multipart alternative style |
| 4300 | 4301 | * a wrapper for multipartmixed |
| 4301 | - * @param string/int $_uid the messageuid, |
|
| 4302 | + * @param integer $_uid the messageuid, |
|
| 4302 | 4303 | * @param Horde_Mime_Part $_structure structure for parsing |
| 4303 | 4304 | * @param string $_htmlMode how to display a message, html, plain text, ... |
| 4304 | 4305 | * @param boolean $_preserveSeen flag to preserve the seenflag by using body.peek |
@@ -4948,6 +4949,9 @@ discard block |
||
| 4948 | 4949 | return $message; |
| 4949 | 4950 | } |
| 4950 | 4951 | |
| 4952 | + /** |
|
| 4953 | + * @param integer $cols |
|
| 4954 | + */ |
|
| 4951 | 4955 | static function wordwrap($str, $cols, $cut, $dontbreaklinesstartingwith=false) |
| 4952 | 4956 | { |
| 4953 | 4957 | $lines = explode("\n", $str); |
@@ -5396,7 +5400,6 @@ discard block |
||
| 5396 | 5400 | * @param string $_partID = null |
| 5397 | 5401 | * @param string $_folder = null |
| 5398 | 5402 | * @param boolean $_preserveSeen = false flag to preserve the seenflag by using body.peek |
| 5399 | - * @param Horde_Imap_Client_Fetch_Query $fquery=null default query just structure |
|
| 5400 | 5403 | * @return Horde_Mime_Part |
| 5401 | 5404 | */ |
| 5402 | 5405 | function getStructure($_uid, $_partID=null, $_folder=null, $_preserveSeen=false) |
@@ -5987,6 +5990,7 @@ discard block |
||
| 5987 | 5990 | * @param preserveHTML flag to pass through to getdisplayableBody |
| 5988 | 5991 | * @param addHeaderSection flag to be able to supress headersection |
| 5989 | 5992 | * @param includeAttachments flag to be able to supress possible attachments |
| 5993 | + * @param Mail $mailClass |
|
| 5990 | 5994 | * @return array/bool with 'mailaddress'=>$mailaddress, |
| 5991 | 5995 | * 'subject'=>$subject, |
| 5992 | 5996 | * 'message'=>$message, |
@@ -6440,7 +6444,7 @@ discard block |
||
| 6440 | 6444 | * |
| 6441 | 6445 | * @param Mailer $_mailObject instance of the Mailer Object to be used |
| 6442 | 6446 | * @param string $_html2parse the html to parse and to be altered, if conditions meet |
| 6443 | - * @param $mail_bo mail bo object |
|
| 6447 | + * @param Mail $mail_bo mail bo object |
|
| 6444 | 6448 | * @return void |
| 6445 | 6449 | */ |
| 6446 | 6450 | static function processURL2InlineImages(Mailer $_mailObject, &$_html2parse, $mail_bo) |
@@ -6556,7 +6560,7 @@ discard block |
||
| 6556 | 6560 | * @param Storage\Merge Storage\Merge bo_merge object |
| 6557 | 6561 | * @param string $document the full filename |
| 6558 | 6562 | * @param array $SendAndMergeTocontacts array of contact ids |
| 6559 | - * @param string& $_folder (passed by reference) will set the folder used. must be set with a folder, but will hold modifications if |
|
| 6563 | + * @param string|null $_folder (passed by reference) will set the folder used. must be set with a folder, but will hold modifications if |
|
| 6560 | 6564 | * folder is modified |
| 6561 | 6565 | * @param string& $importID ID for the imported message, used by attachments to identify them unambiguously |
| 6562 | 6566 | * @return mixed array of messages with success and failed messages or exception |
@@ -6800,7 +6804,7 @@ discard block |
||
| 6800 | 6804 | /** |
| 6801 | 6805 | * Parses a message/rfc mail from file to the mailobject |
| 6802 | 6806 | * |
| 6803 | - * @param object $mailer instance of the SMTP Mailer Object |
|
| 6807 | + * @param Mailer $mailer instance of the SMTP Mailer Object |
|
| 6804 | 6808 | * @param string $tmpFileName string that points/leads to the file to be imported |
| 6805 | 6809 | * @throws Exception\NotFound if $fle is not found |
| 6806 | 6810 | */ |
@@ -6730,14 +6730,14 @@ |
||
| 6730 | 6730 | { |
| 6731 | 6731 | if ($this->folderExists($_folder,true)) |
| 6732 | 6732 | { |
| 6733 | - if($this->isSentFolder($_folder)) |
|
| 6733 | + if($this->isSentFolder($_folder)) |
|
| 6734 | 6734 | { |
| 6735 | - $flags = '\\Seen'; |
|
| 6736 | - } elseif($this->isDraftFolder($_folder)) { |
|
| 6737 | - $flags = '\\Draft'; |
|
| 6738 | - } else { |
|
| 6739 | - $flags = ''; |
|
| 6740 | - } |
|
| 6735 | + $flags = '\\Seen'; |
|
| 6736 | + } elseif($this->isDraftFolder($_folder)) { |
|
| 6737 | + $flags = '\\Draft'; |
|
| 6738 | + } else { |
|
| 6739 | + $flags = ''; |
|
| 6740 | + } |
|
| 6741 | 6741 | $savefailed = false; |
| 6742 | 6742 | try |
| 6743 | 6743 | { |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * |
| 122 | 122 | * @array |
| 123 | 123 | */ |
| 124 | - static $tidy_config = array('clean'=>false,'output-html'=>true,'join-classes'=>true,'join-styles'=>true,'show-body-only'=>"auto",'word-2000'=>true,'wrap'=>0); |
|
| 124 | + static $tidy_config = array('clean'=>false, 'output-html'=>true, 'join-classes'=>true, 'join-styles'=>true, 'show-body-only'=>"auto", 'word-2000'=>true, 'wrap'=>0); |
|
| 125 | 125 | |
| 126 | 126 | /** |
| 127 | 127 | * static used to configure htmLawed, for use with emails |
@@ -131,9 +131,9 @@ discard block |
||
| 131 | 131 | static $htmLawed_config = array('comment'=>1, //remove comments |
| 132 | 132 | 'make_tag_strict' => 3, // 3 is a new own config value, to indicate that transformation is to be performed, but don't transform font as size transformation of numeric sizes to keywords alters the intended result too much |
| 133 | 133 | 'keep_bad'=>2, //remove tags but keep element content (4 and 6 keep element content only if text (pcdata) is valid in parent element as per specs, this may lead to textloss if balance is switched on) |
| 134 | - 'balance'=>1,//turn off tag-balancing (config['balance']=>0). That will not introduce any security risk; only standards-compliant tag nesting check/filtering will be turned off (basic tag-balance will remain; i.e., there won't be any unclosed tag, etc., after filtering) |
|
| 134 | + 'balance'=>1, //turn off tag-balancing (config['balance']=>0). That will not introduce any security risk; only standards-compliant tag nesting check/filtering will be turned off (basic tag-balance will remain; i.e., there won't be any unclosed tag, etc., after filtering) |
|
| 135 | 135 | 'direct_list_nest' => 1, |
| 136 | - 'allow_for_inline' => array('table','div','li','p'),//block elements allowed for nesting when only inline is allowed; Example span does not allow block elements as table; table is the only element tested so far |
|
| 136 | + 'allow_for_inline' => array('table', 'div', 'li', 'p'), //block elements allowed for nesting when only inline is allowed; Example span does not allow block elements as table; table is the only element tested so far |
|
| 137 | 137 | // tidy eats away even some wanted whitespace, so we switch it off; |
| 138 | 138 | // we used it for its compacting and beautifying capabilities, which resulted in better html for further processing |
| 139 | 139 | 'tidy'=>0, |
@@ -148,13 +148,13 @@ discard block |
||
| 148 | 148 | * |
| 149 | 149 | * @array |
| 150 | 150 | */ |
| 151 | - static $aclShortCuts = array('' => array('label'=>'none','title'=>'The user has no rights whatsoever.'), |
|
| 152 | - 'lrs' => array('label'=>'readable','title'=>'Allows a user to read the contents of the mailbox.'), |
|
| 153 | - 'lprs' => array('label'=>'post','title'=>'Allows a user to read the mailbox and post to it through the delivery system by sending mail to the submission address of the mailbox.'), |
|
| 154 | - 'ilprs' => array('label'=>'append','title'=>'Allows a user to read the mailbox and append messages to it, either via IMAP or through the delivery system.'), |
|
| 155 | - 'cdilprsw' => array('label'=>'write','title'=>'Allows a user to read the maibox, post to it, append messages to it, and delete messages or the mailbox itself. The only right not given is the right to change the ACL of the mailbox.'), |
|
| 156 | - 'acdilprsw' => array('label'=>'all','title'=>'The user has all possible rights on the mailbox. This is usually granted to users only on the mailboxes they own.'), |
|
| 157 | - 'custom' => array('label'=>'custom','title'=>'User defined combination of rights for the ACL'), |
|
| 151 | + static $aclShortCuts = array('' => array('label'=>'none', 'title'=>'The user has no rights whatsoever.'), |
|
| 152 | + 'lrs' => array('label'=>'readable', 'title'=>'Allows a user to read the contents of the mailbox.'), |
|
| 153 | + 'lprs' => array('label'=>'post', 'title'=>'Allows a user to read the mailbox and post to it through the delivery system by sending mail to the submission address of the mailbox.'), |
|
| 154 | + 'ilprs' => array('label'=>'append', 'title'=>'Allows a user to read the mailbox and append messages to it, either via IMAP or through the delivery system.'), |
|
| 155 | + 'cdilprsw' => array('label'=>'write', 'title'=>'Allows a user to read the maibox, post to it, append messages to it, and delete messages or the mailbox itself. The only right not given is the right to change the ACL of the mailbox.'), |
|
| 156 | + 'acdilprsw' => array('label'=>'all', 'title'=>'The user has all possible rights on the mailbox. This is usually granted to users only on the mailboxes they own.'), |
|
| 157 | + 'custom' => array('label'=>'custom', 'title'=>'User defined combination of rights for the ACL'), |
|
| 158 | 158 | ); |
| 159 | 159 | |
| 160 | 160 | /** |
@@ -196,13 +196,13 @@ discard block |
||
| 196 | 196 | * @param boolean $_reuseCache = null if null it is set to the value of $_restoreSession |
| 197 | 197 | * @return Mail |
| 198 | 198 | */ |
| 199 | - public static function getInstance($_restoreSession=true, &$_profileID=0, $_validate=true, $_oldImapServerObject=false, $_reuseCache=null) |
|
| 199 | + public static function getInstance($_restoreSession = true, &$_profileID = 0, $_validate = true, $_oldImapServerObject = false, $_reuseCache = null) |
|
| 200 | 200 | { |
| 201 | 201 | //$_restoreSession=false; |
| 202 | 202 | if (is_null($_reuseCache)) $_reuseCache = $_restoreSession; |
| 203 | 203 | //error_log(__METHOD__.' ('.__LINE__.') '.' RestoreSession:'.$_restoreSession.' ProfileId:'.$_profileID.'/'.Mail\Account::get_default_acc_id().' for user:'.$GLOBALS['egw_info']['user']['account_lid'].' called from:'.function_backtrace()); |
| 204 | 204 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_oldImapServerObject)); |
| 205 | - self::$profileDefunct = Cache::getCache(Cache::INSTANCE,'email','profileDefunct'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),5*1); |
|
| 205 | + self::$profileDefunct = Cache::getCache(Cache::INSTANCE, 'email', 'profileDefunct'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 5 * 1); |
|
| 206 | 206 | if (isset(self::$profileDefunct[$_profileID]) && strlen(self::$profileDefunct[$_profileID])) |
| 207 | 207 | { |
| 208 | 208 | throw new Exception(__METHOD__." failed to instanciate Mail for Profile #$_profileID Reason:".self::$profileDefunct[$_profileID]); |
@@ -211,13 +211,13 @@ discard block |
||
| 211 | 211 | { |
| 212 | 212 | if (!is_object(self::$instances[$_profileID])) |
| 213 | 213 | { |
| 214 | - self::$instances[$_profileID] = new Mail('utf-8',false,$_profileID,false,$_reuseCache); |
|
| 214 | + self::$instances[$_profileID] = new Mail('utf-8', false, $_profileID, false, $_reuseCache); |
|
| 215 | 215 | } |
| 216 | 216 | self::$instances[$_profileID]->icServer = $_oldImapServerObject; |
| 217 | - self::$instances[$_profileID]->accountid= $_oldImapServerObject->ImapServerId; |
|
| 218 | - self::$instances[$_profileID]->profileID= $_oldImapServerObject->ImapServerId; |
|
| 217 | + self::$instances[$_profileID]->accountid = $_oldImapServerObject->ImapServerId; |
|
| 218 | + self::$instances[$_profileID]->profileID = $_oldImapServerObject->ImapServerId; |
|
| 219 | 219 | self::$instances[$_profileID]->mailPreferences = $GLOBALS['egw_info']['user']['preferences']['mail']; |
| 220 | - self::$instances[$_profileID]->htmlOptions = self::$instances[$_profileID]->mailPreferences['htmlOptions']; |
|
| 220 | + self::$instances[$_profileID]->htmlOptions = self::$instances[$_profileID]->mailPreferences['htmlOptions']; |
|
| 221 | 221 | return self::$instances[$_profileID]; |
| 222 | 222 | } |
| 223 | 223 | if ($_profileID == 0) |
@@ -230,14 +230,14 @@ discard block |
||
| 230 | 230 | { |
| 231 | 231 | $profileID = Mail\Account::get_default_acc_id(); |
| 232 | 232 | } |
| 233 | - if ($profileID!=$_profileID) $_restoreSession==false; |
|
| 234 | - $_profileID=$profileID; |
|
| 233 | + if ($profileID != $_profileID) $_restoreSession == false; |
|
| 234 | + $_profileID = $profileID; |
|
| 235 | 235 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' called with profileID==0 using '.$profileID.' instead->'.function_backtrace()); |
| 236 | 236 | } |
| 237 | 237 | // no validation or restoreSession for old ImapServer Object, just fetch it and return it |
| 238 | - if ($_oldImapServerObject===true) |
|
| 238 | + if ($_oldImapServerObject === true) |
|
| 239 | 239 | { |
| 240 | - return new Mail('utf-8',false,$_profileID,true,$_reuseCache); |
|
| 240 | + return new Mail('utf-8', false, $_profileID, true, $_reuseCache); |
|
| 241 | 241 | } |
| 242 | 242 | if ($_profileID != 0 && $_validate) |
| 243 | 243 | { |
@@ -257,9 +257,9 @@ discard block |
||
| 257 | 257 | //Cache::setSession('mail','activeProfileID',$_profileID); |
| 258 | 258 | } |
| 259 | 259 | //error_log(__METHOD__.' ('.__LINE__.') '.' RestoreSession:'.$_restoreSession.' ProfileId:'.$_profileID.' called from:'.function_backtrace()); |
| 260 | - if ($_profileID && (!isset(self::$instances[$_profileID]) || $_restoreSession===false)) |
|
| 260 | + if ($_profileID && (!isset(self::$instances[$_profileID]) || $_restoreSession === false)) |
|
| 261 | 261 | { |
| 262 | - self::$instances[$_profileID] = new Mail('utf-8',$_restoreSession,$_profileID,false,$_reuseCache); |
|
| 262 | + self::$instances[$_profileID] = new Mail('utf-8', $_restoreSession, $_profileID, false, $_reuseCache); |
|
| 263 | 263 | } |
| 264 | 264 | else |
| 265 | 265 | { |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | self::$instances[$_profileID]->ogServer = Mail\Account::read($_profileID)->smtpServer(); |
| 271 | 271 | // TODO: merge mailprefs into userprefs, for easy treatment |
| 272 | 272 | self::$instances[$_profileID]->mailPreferences = $GLOBALS['egw_info']['user']['preferences']['mail']; |
| 273 | - self::$instances[$_profileID]->htmlOptions = self::$instances[$_profileID]->mailPreferences['htmlOptions']; |
|
| 273 | + self::$instances[$_profileID]->htmlOptions = self::$instances[$_profileID]->mailPreferences['htmlOptions']; |
|
| 274 | 274 | } catch (\Exception $e) |
| 275 | 275 | { |
| 276 | 276 | $newprofileID = Mail\Account::get_default_acc_id(); |
@@ -278,15 +278,15 @@ discard block |
||
| 278 | 278 | error_log(__METHOD__.' ('.__LINE__.') '." Loading the Profile for ProfileID ".$_profileID.' failed for icServer; '.$e->getMessage().' Trigger new instance for Default-Profile '.$newprofileID.'. called from:'.function_backtrace()); |
| 279 | 279 | if ($newprofileID) |
| 280 | 280 | { |
| 281 | - self::$instances[$newprofileID] = new Mail('utf-8',false,$newprofileID,false,$_reuseCache); |
|
| 281 | + self::$instances[$newprofileID] = new Mail('utf-8', false, $newprofileID, false, $_reuseCache); |
|
| 282 | 282 | $_profileID = $newprofileID; |
| 283 | 283 | } |
| 284 | 284 | else |
| 285 | 285 | { |
| 286 | - throw new Exception(__METHOD__." failed to load the Profile for ProfileID for $_profileID with error:".$e->getMessage().($e->details?', '.$e->details:'')); |
|
| 286 | + throw new Exception(__METHOD__." failed to load the Profile for ProfileID for $_profileID with error:".$e->getMessage().($e->details ? ', '.$e->details : '')); |
|
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | - self::storeActiveProfileIDToPref(self::$instances[$_profileID]->icServer, $_profileID, $_validate ); |
|
| 289 | + self::storeActiveProfileIDToPref(self::$instances[$_profileID]->icServer, $_profileID, $_validate); |
|
| 290 | 290 | } |
| 291 | 291 | self::$instances[$_profileID]->profileID = $_profileID; |
| 292 | 292 | if (!isset(self::$instances[$_profileID]->idna2)) self::$instances[$_profileID]->idna2 = new Horde_Idna; |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | * @param boolean $_testConnection = 0 |
| 303 | 303 | * @return mixed $_profileID or false on failed ConnectionTest |
| 304 | 304 | */ |
| 305 | - public static function storeActiveProfileIDToPref($_icServerObject, $_profileID=0, $_testConnection=true) |
|
| 305 | + public static function storeActiveProfileIDToPref($_icServerObject, $_profileID = 0, $_testConnection = true) |
|
| 306 | 306 | { |
| 307 | 307 | if (isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']) && !empty($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'])) |
| 308 | 308 | { |
@@ -323,12 +323,12 @@ discard block |
||
| 323 | 323 | } |
| 324 | 324 | if ($oldProfileID != $_profileID) |
| 325 | 325 | { |
| 326 | - if ($oldProfileID && $_profileID==0) $_profileID = $oldProfileID; |
|
| 327 | - $GLOBALS['egw']->preferences->add('mail','ActiveProfileID',$_profileID,'user'); |
|
| 326 | + if ($oldProfileID && $_profileID == 0) $_profileID = $oldProfileID; |
|
| 327 | + $GLOBALS['egw']->preferences->add('mail', 'ActiveProfileID', $_profileID, 'user'); |
|
| 328 | 328 | // save prefs |
| 329 | 329 | $GLOBALS['egw']->preferences->save_repository(true); |
| 330 | 330 | $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $_profileID; |
| 331 | - Cache::setSession('mail','activeProfileID',$_profileID); |
|
| 331 | + Cache::setSession('mail', 'activeProfileID', $_profileID); |
|
| 332 | 332 | } |
| 333 | 333 | return $_profileID; |
| 334 | 334 | } |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | * @param int $_acc_id = 0 |
| 344 | 344 | * @return int validated acc_id -> either acc_id given, or first valid one |
| 345 | 345 | */ |
| 346 | - public static function validateProfileID($_acc_id=0) |
|
| 346 | + public static function validateProfileID($_acc_id = 0) |
|
| 347 | 347 | { |
| 348 | 348 | if ($_acc_id) |
| 349 | 349 | { |
@@ -362,7 +362,7 @@ discard block |
||
| 362 | 362 | } |
| 363 | 363 | // no account specified or specified account not found or not valid |
| 364 | 364 | // --> search existing account for first valid one and return that |
| 365 | - foreach(Mail\Account::search($only_current_user=true, 'acc_imap_host') as $acc_id => $imap_host) |
|
| 365 | + foreach (Mail\Account::search($only_current_user = true, 'acc_imap_host') as $acc_id => $imap_host) |
|
| 366 | 366 | { |
| 367 | 367 | if (!empty($imap_host) && ($account = Mail\Account::read($acc_id)) && $account->is_imap()) |
| 368 | 368 | { |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | * @param boolean $_oldImapServerObject = false |
| 385 | 385 | * @param boolean $_reuseCache = null if null it is set to the value of $_restoreSession |
| 386 | 386 | */ |
| 387 | - private function __construct($_displayCharset='utf-8',$_restoreSession=true, $_profileID=0, $_oldImapServerObject=false, $_reuseCache=null) |
|
| 387 | + private function __construct($_displayCharset = 'utf-8', $_restoreSession = true, $_profileID = 0, $_oldImapServerObject = false, $_reuseCache = null) |
|
| 388 | 388 | { |
| 389 | 389 | if (is_null($_reuseCache)) $_reuseCache = $_restoreSession; |
| 390 | 390 | if (!empty($_displayCharset)) self::$displayCharset = $_displayCharset; |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | $firstMessage = $this->sessionData['previewMessage']; |
| 405 | 405 | $this->sessionData = array(); |
| 406 | 406 | } |
| 407 | - if (!$_reuseCache) $this->forcePrefReload($_profileID,!$_reuseCache); |
|
| 407 | + if (!$_reuseCache) $this->forcePrefReload($_profileID, !$_reuseCache); |
|
| 408 | 408 | try |
| 409 | 409 | { |
| 410 | 410 | $this->profileID = self::validateProfileID($_profileID); |
@@ -418,11 +418,11 @@ discard block |
||
| 418 | 418 | throw new Exception(__METHOD__." failed to instanciate Mail for $_profileID / ".$this->profileID." with error:".$e->getMessage()); |
| 419 | 419 | } |
| 420 | 420 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($acc->imapServer())); |
| 421 | - $this->icServer = ($_oldImapServerObject?$acc->oldImapServer():$acc->imapServer()); |
|
| 421 | + $this->icServer = ($_oldImapServerObject ? $acc->oldImapServer() : $acc->imapServer()); |
|
| 422 | 422 | $this->ogServer = $acc->smtpServer(); |
| 423 | 423 | // TODO: merge mailprefs into userprefs, for easy treatment |
| 424 | 424 | $this->mailPreferences = $GLOBALS['egw_info']['user']['preferences']['mail']; |
| 425 | - $this->htmlOptions = $this->mailPreferences['htmlOptions']; |
|
| 425 | + $this->htmlOptions = $this->mailPreferences['htmlOptions']; |
|
| 426 | 426 | if (isset($this->icServer->ImapServerId) && !empty($this->icServer->ImapServerId)) |
| 427 | 427 | { |
| 428 | 428 | $_profileID = $this->profileID = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $this->icServer->ImapServerId; |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | public static function &forceEAProfileLoad($_profile_id) |
| 441 | 441 | { |
| 442 | 442 | self::unsetCachedObjects($_profile_id); |
| 443 | - $mail = self::getInstance(false, $_profile_id,false); |
|
| 443 | + $mail = self::getInstance(false, $_profile_id, false); |
|
| 444 | 444 | //_debug_array( $_profile_id); |
| 445 | 445 | $mail->icServer = Mail\Account::read($_profile_id)->imapServer(); |
| 446 | 446 | $mail->ogServer = Mail\Account::read($_profile_id)->smtpServer(); |
@@ -452,11 +452,11 @@ discard block |
||
| 452 | 452 | * @param int $_profile_id |
| 453 | 453 | * @param boolean $_resetFolderObjects |
| 454 | 454 | */ |
| 455 | - public static function forcePrefReload($_profile_id=null,$_resetFolderObjects=true) |
|
| 455 | + public static function forcePrefReload($_profile_id = null, $_resetFolderObjects = true) |
|
| 456 | 456 | { |
| 457 | 457 | // unset the mail_preferences session object, to force the reload/rebuild |
| 458 | - Cache::setSession('mail','mail_preferences',serialize(array())); |
|
| 459 | - Cache::setSession('emailadmin','session_data',serialize(array())); |
|
| 458 | + Cache::setSession('mail', 'mail_preferences', serialize(array())); |
|
| 459 | + Cache::setSession('emailadmin', 'session_data', serialize(array())); |
|
| 460 | 460 | if ($_resetFolderObjects) self::resetFolderObjectCache($_profile_id); |
| 461 | 461 | } |
| 462 | 462 | |
@@ -465,8 +465,8 @@ discard block |
||
| 465 | 465 | */ |
| 466 | 466 | function restoreSessionData() |
| 467 | 467 | { |
| 468 | - $this->sessionData = array();//Cache::getCache(Cache::SESSION,'mail','session_data',$callback=null,$callback_params=array(),$expiration=60*60*1); |
|
| 469 | - self::$activeFolderCache = Cache::getCache(Cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*10); |
|
| 468 | + $this->sessionData = array(); //Cache::getCache(Cache::SESSION,'mail','session_data',$callback=null,$callback_params=array(),$expiration=60*60*1); |
|
| 469 | + self::$activeFolderCache = Cache::getCache(Cache::INSTANCE, 'email', 'activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 470 | 470 | if (!empty(self::$activeFolderCache[$this->profileID])) $this->sessionData['mailbox'] = self::$activeFolderCache[$this->profileID]; |
| 471 | 471 | } |
| 472 | 472 | |
@@ -476,10 +476,10 @@ discard block |
||
| 476 | 476 | function saveSessionData() |
| 477 | 477 | { |
| 478 | 478 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string(array_keys($this->sessionData))); |
| 479 | - if (!empty($this->sessionData['mailbox'])) self::$activeFolderCache[$this->profileID]=$this->sessionData['mailbox']; |
|
| 479 | + if (!empty($this->sessionData['mailbox'])) self::$activeFolderCache[$this->profileID] = $this->sessionData['mailbox']; |
|
| 480 | 480 | if (isset(self::$activeFolderCache) && is_array(self::$activeFolderCache)) |
| 481 | 481 | { |
| 482 | - Cache::setCache(Cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),self::$activeFolderCache, 60*60*10); |
|
| 482 | + Cache::setCache(Cache::INSTANCE, 'email', 'activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']), self::$activeFolderCache, 60 * 60 * 10); |
|
| 483 | 483 | } |
| 484 | 484 | } |
| 485 | 485 | |
@@ -495,40 +495,40 @@ discard block |
||
| 495 | 495 | * @param int $_profileID = null default profile of user as returned by getUserDefaultProfileID |
| 496 | 496 | * @return void |
| 497 | 497 | */ |
| 498 | - static function unsetCachedObjects($_profileID=null) |
|
| 498 | + static function unsetCachedObjects($_profileID = null) |
|
| 499 | 499 | { |
| 500 | 500 | if (is_null($_profileID)) $_profileID = Mail\Account::get_default_acc_id(); |
| 501 | 501 | if (is_array($_profileID) && $_profileID['account_id']) $account_id = $_profileID['account_id']; |
| 502 | 502 | //error_log(__METHOD__.__LINE__.' called with ProfileID:'.array2string($_profileID).' from '.function_backtrace()); |
| 503 | - if (!is_array($_profileID) && (is_numeric($_profileID) || !(stripos($_profileID,'tracker_')===false))) |
|
| 503 | + if (!is_array($_profileID) && (is_numeric($_profileID) || !(stripos($_profileID, 'tracker_') === false))) |
|
| 504 | 504 | { |
| 505 | 505 | self::resetConnectionErrorCache($_profileID); |
| 506 | - $rawHeadersCache = Cache::getCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($account_id),$callback=null,$callback_params=array(),$expiration=60*60*1); |
|
| 506 | + $rawHeadersCache = Cache::getCache(Cache::INSTANCE, 'email', 'rawHeadersCache'.trim($account_id), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 1); |
|
| 507 | 507 | if (isset($rawHeadersCache[$_profileID])) |
| 508 | 508 | { |
| 509 | 509 | unset($rawHeadersCache[$_profileID]); |
| 510 | - Cache::setCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($account_id),$rawHeadersCache, $expiration=60*60*1); |
|
| 510 | + Cache::setCache(Cache::INSTANCE, 'email', 'rawHeadersCache'.trim($account_id), $rawHeadersCache, $expiration = 60 * 60 * 1); |
|
| 511 | 511 | } |
| 512 | - $HierarchyDelimiterCache = Cache::getCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($account_id),$callback=null,$callback_params=array(),$expiration=60*60*24*5); |
|
| 512 | + $HierarchyDelimiterCache = Cache::getCache(Cache::INSTANCE, 'email', 'HierarchyDelimiter'.trim($account_id), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 24 * 5); |
|
| 513 | 513 | if (isset($HierarchyDelimiterCache[$_profileID])) |
| 514 | 514 | { |
| 515 | 515 | unset($HierarchyDelimiterCache[$_profileID]); |
| 516 | - Cache::setCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($account_id),$HierarchyDelimiterCache, $expiration=60*60*24*5); |
|
| 516 | + Cache::setCache(Cache::INSTANCE, 'email', 'HierarchyDelimiter'.trim($account_id), $HierarchyDelimiterCache, $expiration = 60 * 60 * 24 * 5); |
|
| 517 | 517 | } |
| 518 | 518 | //reset folderObject cache, to trigger reload |
| 519 | 519 | self::resetFolderObjectCache($_profileID); |
| 520 | 520 | //reset counter of deleted messages per folder |
| 521 | - $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($account_id),$callback=null,$callback_params=array(),$expiration=60*60*1); |
|
| 521 | + $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($account_id), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 1); |
|
| 522 | 522 | if (isset($eMailListContainsDeletedMessages[$_profileID])) |
| 523 | 523 | { |
| 524 | 524 | unset($eMailListContainsDeletedMessages[$_profileID]); |
| 525 | - Cache::setCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($account_id),$eMailListContainsDeletedMessages, $expiration=60*60*1); |
|
| 525 | + Cache::setCache(Cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($account_id), $eMailListContainsDeletedMessages, $expiration = 60 * 60 * 1); |
|
| 526 | 526 | } |
| 527 | - $vacationCached = Cache::getCache(Cache::INSTANCE, 'email', 'vacationNotice'.trim($account_id),$callback=null,$callback_params=array(),$expiration=60*60*24*1); |
|
| 527 | + $vacationCached = Cache::getCache(Cache::INSTANCE, 'email', 'vacationNotice'.trim($account_id), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 24 * 1); |
|
| 528 | 528 | if (isset($vacationCached[$_profileID])) |
| 529 | 529 | { |
| 530 | 530 | unset($vacationCached[$_profileID]); |
| 531 | - Cache::setCache(Cache::INSTANCE,'email','vacationNotice'.trim($account_id),$vacationCached, $expiration=60*60*24*1); |
|
| 531 | + Cache::setCache(Cache::INSTANCE, 'email', 'vacationNotice'.trim($account_id), $vacationCached, $expiration = 60 * 60 * 24 * 1); |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | if (isset(self::$instances[$_profileID])) unset(self::$instances[$_profileID]); |
@@ -536,17 +536,17 @@ discard block |
||
| 536 | 536 | if (is_array($_profileID) && $_profileID['location'] == 'clear_cache') |
| 537 | 537 | { |
| 538 | 538 | // called via hook |
| 539 | - foreach($GLOBALS['egw']->accounts->search(array('type' => 'accounts','order' => 'account_lid')) as $account) |
|
| 539 | + foreach ($GLOBALS['egw']->accounts->search(array('type' => 'accounts', 'order' => 'account_lid')) as $account) |
|
| 540 | 540 | { |
| 541 | 541 | //error_log(__METHOD__.__LINE__.array2string($account)); |
| 542 | 542 | $account_id = $account['account_id']; |
| 543 | 543 | $_profileID = null; |
| 544 | - self::resetConnectionErrorCache($_profileID,$account_id); |
|
| 545 | - self::resetFolderObjectCache($_profileID,$account_id); |
|
| 546 | - Cache::setCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($account_id),array(), 60*60*1); |
|
| 547 | - Cache::setCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($account_id),array(), 60*60*24*5); |
|
| 548 | - Cache::setCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($account_id),array(), 60*60*1); |
|
| 549 | - Cache::setCache(Cache::INSTANCE,'email','vacationNotice'.trim($account_id),array(), 60*60*24*1); |
|
| 544 | + self::resetConnectionErrorCache($_profileID, $account_id); |
|
| 545 | + self::resetFolderObjectCache($_profileID, $account_id); |
|
| 546 | + Cache::setCache(Cache::INSTANCE, 'email', 'rawHeadersCache'.trim($account_id), array(), 60 * 60 * 1); |
|
| 547 | + Cache::setCache(Cache::INSTANCE, 'email', 'HierarchyDelimiter'.trim($account_id), array(), 60 * 60 * 24 * 5); |
|
| 548 | + Cache::setCache(Cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($account_id), array(), 60 * 60 * 1); |
|
| 549 | + Cache::setCache(Cache::INSTANCE, 'email', 'vacationNotice'.trim($account_id), array(), 60 * 60 * 24 * 1); |
|
| 550 | 550 | } |
| 551 | 551 | } |
| 552 | 552 | } |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | * @param int $_ImapServerId the profileID to look for |
| 558 | 558 | * @param int $account_id the egw account to look for |
| 559 | 559 | */ |
| 560 | - static function resetConnectionErrorCache($_ImapServerId=null,$account_id=null) |
|
| 560 | + static function resetConnectionErrorCache($_ImapServerId = null, $account_id = null) |
|
| 561 | 561 | { |
| 562 | 562 | //error_log(__METHOD__.' ('.__LINE__.') '.' for Profile:'.array2string($_ImapServerId) .' for user:'.trim($account_id)); |
| 563 | 563 | if (is_null($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id']; |
@@ -575,19 +575,19 @@ discard block |
||
| 575 | 575 | } |
| 576 | 576 | else |
| 577 | 577 | { |
| 578 | - $isConError = Cache::getCache(Cache::INSTANCE,'email','icServerSIEVE_connectionError'.trim($account_id)); |
|
| 578 | + $isConError = Cache::getCache(Cache::INSTANCE, 'email', 'icServerSIEVE_connectionError'.trim($account_id)); |
|
| 579 | 579 | if (isset($isConError[$_ImapServerId])) |
| 580 | 580 | { |
| 581 | 581 | unset($isConError[$_ImapServerId]); |
| 582 | 582 | } |
| 583 | - $waitOnFailure = Cache::getCache(Cache::INSTANCE,'email','ActiveSyncWaitOnFailure'.trim($account_id),null,array(),60*60*2); |
|
| 583 | + $waitOnFailure = Cache::getCache(Cache::INSTANCE, 'email', 'ActiveSyncWaitOnFailure'.trim($account_id), null, array(), 60 * 60 * 2); |
|
| 584 | 584 | if (isset($waitOnFailure[$_ImapServerId])) |
| 585 | 585 | { |
| 586 | 586 | unset($waitOnFailure[$_ImapServerId]); |
| 587 | 587 | } |
| 588 | 588 | } |
| 589 | - Cache::setCache(Cache::INSTANCE,'email','icServerSIEVE_connectionError'.trim($account_id),$isConError,60*15); |
|
| 590 | - Cache::setCache(Cache::INSTANCE,'email','ActiveSyncWaitOnFailure'.trim($account_id),$waitOnFailure,60*60*2); |
|
| 589 | + Cache::setCache(Cache::INSTANCE, 'email', 'icServerSIEVE_connectionError'.trim($account_id), $isConError, 60 * 15); |
|
| 590 | + Cache::setCache(Cache::INSTANCE, 'email', 'ActiveSyncWaitOnFailure'.trim($account_id), $waitOnFailure, 60 * 60 * 2); |
|
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | /** |
@@ -596,13 +596,13 @@ discard block |
||
| 596 | 596 | * @param int $_ImapServerId the profileID to look for |
| 597 | 597 | * @param int $account_id the egw account to look for |
| 598 | 598 | */ |
| 599 | - static function resetFolderObjectCache($_ImapServerId=null,$account_id=null) |
|
| 599 | + static function resetFolderObjectCache($_ImapServerId = null, $account_id = null) |
|
| 600 | 600 | { |
| 601 | 601 | //error_log(__METHOD__.' ('.__LINE__.') '.' called for Profile:'.array2string($_ImapServerId).'->'.function_backtrace()); |
| 602 | 602 | if (is_null($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id']; |
| 603 | 603 | // on [location] => verify_settings we coud either use [prefs] => Array([ActiveProfileID] => 9, .. as $_ImapServerId |
| 604 | 604 | // or treat it as not given. we try that path |
| 605 | - if (is_null($_ImapServerId)||is_array($_ImapServerId)) |
|
| 605 | + if (is_null($_ImapServerId) || is_array($_ImapServerId)) |
|
| 606 | 606 | { |
| 607 | 607 | $folders2return = array(); |
| 608 | 608 | $folderInfo = array(); |
@@ -611,12 +611,12 @@ discard block |
||
| 611 | 611 | } |
| 612 | 612 | else |
| 613 | 613 | { |
| 614 | - $folders2return = Cache::getCache(Cache::INSTANCE,'email','folderObjects'.trim($account_id),null,array(),60*60*1); |
|
| 614 | + $folders2return = Cache::getCache(Cache::INSTANCE, 'email', 'folderObjects'.trim($account_id), null, array(), 60 * 60 * 1); |
|
| 615 | 615 | if (!empty($folders2return) && isset($folders2return[$_ImapServerId])) |
| 616 | 616 | { |
| 617 | 617 | unset($folders2return[$_ImapServerId]); |
| 618 | 618 | } |
| 619 | - $folderInfo = Cache::getCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($account_id),null,array(),60*60*5); |
|
| 619 | + $folderInfo = Cache::getCache(Cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($account_id), null, array(), 60 * 60 * 5); |
|
| 620 | 620 | if (!empty($folderInfo) && isset($folderInfo[$_ImapServerId])) |
| 621 | 621 | { |
| 622 | 622 | unset($folderInfo[$_ImapServerId]); |
@@ -628,23 +628,23 @@ discard block |
||
| 628 | 628 | unset($lastFolderUsedForMove[$_ImapServerId]); |
| 629 | 629 | } |
| 630 | 630 | */ |
| 631 | - $folderBasicInfo = Cache::getCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($account_id),null,array(),60*60*1); |
|
| 631 | + $folderBasicInfo = Cache::getCache(Cache::INSTANCE, 'email', 'folderBasicInfo'.trim($account_id), null, array(), 60 * 60 * 1); |
|
| 632 | 632 | if (!empty($folderBasicInfo) && isset($folderBasicInfo[$_ImapServerId])) |
| 633 | 633 | { |
| 634 | 634 | unset($folderBasicInfo[$_ImapServerId]); |
| 635 | 635 | } |
| 636 | - $_specialUseFolders = Cache::getCache(Cache::INSTANCE,'email','specialUseFolders'.trim($account_id),null,array(),60*60*12); |
|
| 636 | + $_specialUseFolders = Cache::getCache(Cache::INSTANCE, 'email', 'specialUseFolders'.trim($account_id), null, array(), 60 * 60 * 12); |
|
| 637 | 637 | if (!empty($_specialUseFolders) && isset($_specialUseFolders[$_ImapServerId])) |
| 638 | 638 | { |
| 639 | 639 | unset($_specialUseFolders[$_ImapServerId]); |
| 640 | - self::$specialUseFolders=null; |
|
| 640 | + self::$specialUseFolders = null; |
|
| 641 | 641 | } |
| 642 | 642 | } |
| 643 | - Cache::setCache(Cache::INSTANCE,'email','folderObjects'.trim($account_id),$folders2return, 60*60*1); |
|
| 644 | - Cache::setCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($account_id),$folderInfo,60*60*5); |
|
| 643 | + Cache::setCache(Cache::INSTANCE, 'email', 'folderObjects'.trim($account_id), $folders2return, 60 * 60 * 1); |
|
| 644 | + Cache::setCache(Cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($account_id), $folderInfo, 60 * 60 * 5); |
|
| 645 | 645 | //Cache::setCache(Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($account_id),$lastFolderUsedForMove,$expiration=60*60*1); |
| 646 | - Cache::setCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($account_id),$folderBasicInfo,60*60*1); |
|
| 647 | - Cache::setCache(Cache::INSTANCE,'email','specialUseFolders'.trim($account_id),$_specialUseFolders,60*60*12); |
|
| 646 | + Cache::setCache(Cache::INSTANCE, 'email', 'folderBasicInfo'.trim($account_id), $folderBasicInfo, 60 * 60 * 1); |
|
| 647 | + Cache::setCache(Cache::INSTANCE, 'email', 'specialUseFolders'.trim($account_id), $_specialUseFolders, 60 * 60 * 12); |
|
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | /** |
@@ -665,15 +665,15 @@ discard block |
||
| 665 | 665 | * @param string $_profileID the ID of the mailaccount to check for identities, if null current mail-account is used |
| 666 | 666 | * @return array - array(email=>realname) |
| 667 | 667 | */ |
| 668 | - function getUserEMailAddresses($_profileID=null) |
|
| 668 | + function getUserEMailAddresses($_profileID = null) |
|
| 669 | 669 | { |
| 670 | - $acc = Mail\Account::read((!empty($_profileID)?$_profileID:$this->profileID)); |
|
| 670 | + $acc = Mail\Account::read((!empty($_profileID) ? $_profileID : $this->profileID)); |
|
| 671 | 671 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.array2string($acc)); |
| 672 | 672 | $identities = Mail\Account::identities($acc); |
| 673 | 673 | |
| 674 | 674 | $userEMailAdresses = array($acc['ident_email']=>$acc['ident_realname']); |
| 675 | 675 | |
| 676 | - foreach($identities as $ik => $ident) { |
|
| 676 | + foreach ($identities as $ik => $ident) { |
|
| 677 | 677 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident)); |
| 678 | 678 | $identity = Mail\Account::read_identity($ik); |
| 679 | 679 | if (!empty($identity['ident_email']) && !isset($userEMailAdresses[$identity['ident_email']])) $userEMailAdresses[$identity['ident_email']] = $identity['ident_realname']; |
@@ -688,19 +688,19 @@ discard block |
||
| 688 | 688 | * @param boolean $resolve_placeholders wether or not resolve possible placeholders in identities |
| 689 | 689 | * @return array - array(email=>realname) |
| 690 | 690 | */ |
| 691 | - static function getAllIdentities($_accountToSearch=null,$resolve_placeholders=false) |
|
| 691 | + static function getAllIdentities($_accountToSearch = null, $resolve_placeholders = false) |
|
| 692 | 692 | { |
| 693 | 693 | $userEMailAdresses = array(); |
| 694 | - foreach(Mail\Account::search($only_current_user=($_accountToSearch?$_accountToSearch:true), $just_name=true) as $acc_id => $identity_name) |
|
| 694 | + foreach (Mail\Account::search($only_current_user = ($_accountToSearch ? $_accountToSearch : true), $just_name = true) as $acc_id => $identity_name) |
|
| 695 | 695 | { |
| 696 | - $acc = Mail\Account::read($acc_id,($_accountToSearch?$_accountToSearch:null)); |
|
| 697 | - if (!$resolve_placeholders) $userEMailAdresses[$acc['ident_id']] = array('acc_id'=>$acc_id,'ident_id'=>$acc['ident_id'],'ident_email'=>$acc['ident_email'],'ident_org'=>$acc['ident_org'],'ident_realname'=>$acc['ident_realname'],'ident_signature'=>$acc['ident_signature'],'ident_name'=>$acc['ident_name']); |
|
| 696 | + $acc = Mail\Account::read($acc_id, ($_accountToSearch ? $_accountToSearch : null)); |
|
| 697 | + if (!$resolve_placeholders) $userEMailAdresses[$acc['ident_id']] = array('acc_id'=>$acc_id, 'ident_id'=>$acc['ident_id'], 'ident_email'=>$acc['ident_email'], 'ident_org'=>$acc['ident_org'], 'ident_realname'=>$acc['ident_realname'], 'ident_signature'=>$acc['ident_signature'], 'ident_name'=>$acc['ident_name']); |
|
| 698 | 698 | |
| 699 | - foreach(Mail\Account::identities($acc) as $ik => $ident) { |
|
| 699 | + foreach (Mail\Account::identities($acc) as $ik => $ident) { |
|
| 700 | 700 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident)); |
| 701 | - $identity = Mail\Account::read_identity($ik,$resolve_placeholders); |
|
| 701 | + $identity = Mail\Account::read_identity($ik, $resolve_placeholders); |
|
| 702 | 702 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($identity)); |
| 703 | - if (!isset($userEMailAdresses[$identity['ident_id']])) $userEMailAdresses[$identity['ident_id']] = array('acc_id'=>$acc_id,'ident_id'=>$identity['ident_id'],'ident_email'=>$identity['ident_email'],'ident_org'=>$identity['ident_org'],'ident_realname'=>$identity['ident_realname'],'ident_signature'=>$identity['ident_signature'],'ident_name'=>$identity['ident_name']); |
|
| 703 | + if (!isset($userEMailAdresses[$identity['ident_id']])) $userEMailAdresses[$identity['ident_id']] = array('acc_id'=>$acc_id, 'ident_id'=>$identity['ident_id'], 'ident_email'=>$identity['ident_email'], 'ident_org'=>$identity['ident_org'], 'ident_realname'=>$identity['ident_realname'], 'ident_signature'=>$identity['ident_signature'], 'ident_name'=>$identity['ident_name']); |
|
| 704 | 704 | } |
| 705 | 705 | } |
| 706 | 706 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($userEMailAdresses)); |
@@ -720,9 +720,9 @@ discard block |
||
| 720 | 720 | $account = Mail\Account::read($account); |
| 721 | 721 | } |
| 722 | 722 | $userEMailAdresses = array(); |
| 723 | - foreach(Mail\Account::identities($account, true, 'params') as $ik => $ident) { |
|
| 723 | + foreach (Mail\Account::identities($account, true, 'params') as $ik => $ident) { |
|
| 724 | 724 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident)); |
| 725 | - $identity = Mail\Account::read_identity($ik,true,null,$account); |
|
| 725 | + $identity = Mail\Account::read_identity($ik, true, null, $account); |
|
| 726 | 726 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($identity)); |
| 727 | 727 | // standardIdentity has ident_id==acc_id (as it is done within account->identities) |
| 728 | 728 | if (empty($identity['ident_id'])) $identity['ident_id'] = $identity['acc_id']; |
@@ -749,9 +749,9 @@ discard block |
||
| 749 | 749 | function getDefaultIdentity() |
| 750 | 750 | { |
| 751 | 751 | // retrieve the signature accociated with the identity |
| 752 | - $id = $this->getIdentitiesWithAccounts($_accountData=array()); |
|
| 753 | - foreach(Mail\Account::identities($_accountData[$this->profileID] ? |
|
| 754 | - $this->profileID : $_accountData[$id],false,'ident_id') as $accountData) |
|
| 752 | + $id = $this->getIdentitiesWithAccounts($_accountData = array()); |
|
| 753 | + foreach (Mail\Account::identities($_accountData[$this->profileID] ? |
|
| 754 | + $this->profileID : $_accountData[$id], false, 'ident_id') as $accountData) |
|
| 755 | 755 | { |
| 756 | 756 | return $accountData; |
| 757 | 757 | } |
@@ -767,13 +767,13 @@ discard block |
||
| 767 | 767 | { |
| 768 | 768 | // account select box |
| 769 | 769 | $selectedID = $this->profileID; |
| 770 | - $allAccountData = Mail\Account::search($only_current_user=true, false, null); |
|
| 770 | + $allAccountData = Mail\Account::search($only_current_user = true, false, null); |
|
| 771 | 771 | if ($allAccountData) { |
| 772 | - $rememberFirst=$selectedFound=null; |
|
| 772 | + $rememberFirst = $selectedFound = null; |
|
| 773 | 773 | foreach ($allAccountData as $tmpkey => $icServers) |
| 774 | 774 | { |
| 775 | 775 | if (is_null($rememberFirst)) $rememberFirst = $tmpkey; |
| 776 | - if ($tmpkey == $selectedID) $selectedFound=true; |
|
| 776 | + if ($tmpkey == $selectedID) $selectedFound = true; |
|
| 777 | 777 | //error_log(__METHOD__.' ('.__LINE__.') '.' Key:'.$tmpkey.'->'.array2string($icServers->acc_imap_host)); |
| 778 | 778 | $host = $icServers->acc_imap_host; |
| 779 | 779 | if (empty($host)) continue; |
@@ -781,7 +781,7 @@ discard block |
||
| 781 | 781 | //error_log(__METHOD__.' ('.__LINE__.') '.' Key:'.$tmpkey.'->'.array2string($identities[$icServers->acc_id])); |
| 782 | 782 | } |
| 783 | 783 | } |
| 784 | - return ($selectedFound?$selectedID:$rememberFirst); |
|
| 784 | + return ($selectedFound ? $selectedID : $rememberFirst); |
|
| 785 | 785 | } |
| 786 | 786 | |
| 787 | 787 | /** |
@@ -791,7 +791,7 @@ discard block |
||
| 791 | 791 | * @var boolean $fullString full or false=NamePart only is returned |
| 792 | 792 | * @return string - constructed of identity object data as defined in mailConfig |
| 793 | 793 | */ |
| 794 | - static function generateIdentityString($identity, $fullString=true) |
|
| 794 | + static function generateIdentityString($identity, $fullString = true) |
|
| 795 | 795 | { |
| 796 | 796 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($identity)); |
| 797 | 797 | //if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail'); |
@@ -802,16 +802,16 @@ discard block |
||
| 802 | 802 | { |
| 803 | 803 | case 'email'; |
| 804 | 804 | //$retData = str_replace('@',' ',$identity->emailAddress).($fullString===true?' <'.$identity->emailAddress.'>':''); |
| 805 | - $retData = $identity['ident_email'].($fullString===true?' <'.$identity['ident_email'].'>':''); |
|
| 805 | + $retData = $identity['ident_email'].($fullString === true ? ' <'.$identity['ident_email'].'>' : ''); |
|
| 806 | 806 | break; |
| 807 | 807 | case 'nameNemail'; |
| 808 | - $retData = (!empty($identity['ident_realname'])?$identity['ident_realname']:substr_replace($identity['ident_email'],'',strpos($identity['ident_email'],'@'))).($fullString===true?' <'.$identity['ident_email'].'>':''); |
|
| 808 | + $retData = (!empty($identity['ident_realname']) ? $identity['ident_realname'] : substr_replace($identity['ident_email'], '', strpos($identity['ident_email'], '@'))).($fullString === true ? ' <'.$identity['ident_email'].'>' : ''); |
|
| 809 | 809 | break; |
| 810 | 810 | case 'orgNemail'; |
| 811 | - $retData = (!empty($identity['ident_org'])?$identity['ident_org']:substr_replace($identity['ident_email'],'',0,strpos($identity['ident_email'],'@')+1)).($fullString===true?' <'.$identity['ident_email'].'>':''); |
|
| 811 | + $retData = (!empty($identity['ident_org']) ? $identity['ident_org'] : substr_replace($identity['ident_email'], '', 0, strpos($identity['ident_email'], '@') + 1)).($fullString === true ? ' <'.$identity['ident_email'].'>' : ''); |
|
| 812 | 812 | break; |
| 813 | 813 | default: |
| 814 | - $retData = $identity['ident_realname'].(!empty($identity['ident_org'])?' '.$identity['ident_org']:'').($fullString===true?' <'.$identity['ident_email'].'>':''); |
|
| 814 | + $retData = $identity['ident_realname'].(!empty($identity['ident_org']) ? ' '.$identity['ident_org'] : '').($fullString === true ? ' <'.$identity['ident_email'].'>' : ''); |
|
| 815 | 815 | } |
| 816 | 816 | return $retData; |
| 817 | 817 | } |
@@ -836,7 +836,7 @@ discard block |
||
| 836 | 836 | */ |
| 837 | 837 | function reopen($_foldername) |
| 838 | 838 | { |
| 839 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 839 | + if (self::$debugTimes) $starttime = microtime(true); |
|
| 840 | 840 | |
| 841 | 841 | //error_log(__METHOD__.' ('.__LINE__.') '."('$_foldername') ".function_backtrace()); |
| 842 | 842 | // TODO: trying to reduce traffic to the IMAP Server here, introduces problems with fetching the bodies of |
@@ -851,7 +851,7 @@ discard block |
||
| 851 | 851 | } |
| 852 | 852 | $folderOpened = $_foldername; |
| 853 | 853 | //} |
| 854 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'Folder:'.$_foldername,__METHOD__.' ('.__LINE__.') '); |
|
| 854 | + if (self::$debugTimes) self::logRunTimes($starttime, null, 'Folder:'.$_foldername, __METHOD__.' ('.__LINE__.') '); |
|
| 855 | 855 | } |
| 856 | 856 | |
| 857 | 857 | |
@@ -862,15 +862,15 @@ discard block |
||
| 862 | 862 | * @throws Horde_Imap_Client_Exception on connection error or authentication failure |
| 863 | 863 | * @throws InvalidArgumentException on missing credentials |
| 864 | 864 | */ |
| 865 | - function openConnection($_icServerID=0) |
|
| 865 | + function openConnection($_icServerID = 0) |
|
| 866 | 866 | { |
| 867 | 867 | //error_log( "-------------------------->open connection ".function_backtrace()); |
| 868 | 868 | //error_log(__METHOD__.' ('.__LINE__.') '.' ->'.array2string($this->icServer)); |
| 869 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 870 | - $mailbox=null; |
|
| 869 | + if (self::$debugTimes) $starttime = microtime(true); |
|
| 870 | + $mailbox = null; |
|
| 871 | 871 | try |
| 872 | 872 | { |
| 873 | - if(isset($this->sessionData['mailbox'])&&$this->folderExists($this->sessionData['mailbox'])) $mailbox = $this->sessionData['mailbox']; |
|
| 873 | + if (isset($this->sessionData['mailbox']) && $this->folderExists($this->sessionData['mailbox'])) $mailbox = $this->sessionData['mailbox']; |
|
| 874 | 874 | if (empty($mailbox)) $mailbox = $this->icServer->getCurrentMailbox(); |
| 875 | 875 | /* |
| 876 | 876 | if (isset(Mail\Imap::$supports_keywords[$_icServerID])) |
@@ -897,7 +897,7 @@ discard block |
||
| 897 | 897 | error_log(__METHOD__.' ('.__LINE__.') '."->open connection for Server with profileID:".$_icServerID." trying to examine ($mailbox) failed!".$e->getMessage()); |
| 898 | 898 | throw new Exception(__METHOD__." failed to ".__METHOD__." on Profile to $_icServerID while trying to examine $mailbox:".$e->getMessage()); |
| 899 | 899 | } |
| 900 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'ProfileID:'.$_icServerID,__METHOD__.' ('.__LINE__.') '); |
|
| 900 | + if (self::$debugTimes) self::logRunTimes($starttime, null, 'ProfileID:'.$_icServerID, __METHOD__.' ('.__LINE__.') '); |
|
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | /** |
@@ -918,7 +918,7 @@ discard block |
||
| 918 | 918 | try |
| 919 | 919 | { |
| 920 | 920 | $this->icServer->getCurrentMailbox(); |
| 921 | - if(!$this->icServer->hasCapability('QUOTA')) { |
|
| 921 | + if (!$this->icServer->hasCapability('QUOTA')) { |
|
| 922 | 922 | $quota = false; |
| 923 | 923 | return false; |
| 924 | 924 | } |
@@ -928,15 +928,15 @@ discard block |
||
| 928 | 928 | { |
| 929 | 929 | //error_log(__METHOD__.array2string($e)); |
| 930 | 930 | //error_log(__METHOD__." failed to fetch quota on ".$this->profileID.' Reason:'.$e->getMessage().($e->details?', '.$e->details:'')/*.function_backtrace()*/); |
| 931 | - if ($e->getCode()==102) |
|
| 931 | + if ($e->getCode() == 102) |
|
| 932 | 932 | { |
| 933 | - self::$profileDefunct[$this->profileID]=$e->getMessage().($e->details?', '.$e->details:''); |
|
| 934 | - Cache::setCache(Cache::INSTANCE,'email','profileDefunct'.trim($GLOBALS['egw_info']['user']['account_id']),self::$profileDefunct, $expiration=5*1); |
|
| 935 | - throw new Exception(__METHOD__." failed to fetch quota on ".$this->profileID.' Reason:'.$e->getMessage().($e->details?', '.$e->details:'')); |
|
| 933 | + self::$profileDefunct[$this->profileID] = $e->getMessage().($e->details ? ', '.$e->details : ''); |
|
| 934 | + Cache::setCache(Cache::INSTANCE, 'email', 'profileDefunct'.trim($GLOBALS['egw_info']['user']['account_id']), self::$profileDefunct, $expiration = 5 * 1); |
|
| 935 | + throw new Exception(__METHOD__." failed to fetch quota on ".$this->profileID.' Reason:'.$e->getMessage().($e->details ? ', '.$e->details : '')); |
|
| 936 | 936 | } |
| 937 | 937 | } |
| 938 | 938 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($quota)); |
| 939 | - if(is_array($quota)) { |
|
| 939 | + if (is_array($quota)) { |
|
| 940 | 940 | $quota = array( |
| 941 | 941 | 'usage' => $quota['USED'], |
| 942 | 942 | 'limit' => $quota['QMAX'], |
@@ -954,10 +954,10 @@ discard block |
||
| 954 | 954 | * |
| 955 | 955 | * @return int - timeout (either set or default 20/10) |
| 956 | 956 | */ |
| 957 | - static function getTimeOut($_use='IMAP') |
|
| 957 | + static function getTimeOut($_use = 'IMAP') |
|
| 958 | 958 | { |
| 959 | 959 | $timeout = $GLOBALS['egw_info']['user']['preferences']['mail']['connectionTimeout']; |
| 960 | - if (empty($timeout)) $timeout = ($_use=='SIEVE'?10:20); // this is the default value |
|
| 960 | + if (empty($timeout)) $timeout = ($_use == 'SIEVE' ? 10 : 20); // this is the default value |
|
| 961 | 961 | return $timeout; |
| 962 | 962 | } |
| 963 | 963 | |
@@ -978,18 +978,18 @@ discard block |
||
| 978 | 978 | if (is_null($nameSpace)) $nameSpace = $this->icServer->getNameSpaceArray(); |
| 979 | 979 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($nameSpace)); |
| 980 | 980 | if (is_array($nameSpace)) { |
| 981 | - foreach($nameSpace as $type => $singleNameSpaceArray) |
|
| 981 | + foreach ($nameSpace as $type => $singleNameSpaceArray) |
|
| 982 | 982 | { |
| 983 | 983 | foreach ($singleNameSpaceArray as $singleNameSpace) |
| 984 | 984 | { |
| 985 | 985 | $_foldersNameSpace = array(); |
| 986 | - if($type == 'personal' && $singleNameSpace['name'] == '#mh/' && ($this->folderExists('Mail')||$this->folderExists('INBOX'))) |
|
| 986 | + if ($type == 'personal' && $singleNameSpace['name'] == '#mh/' && ($this->folderExists('Mail') || $this->folderExists('INBOX'))) |
|
| 987 | 987 | { |
| 988 | 988 | $_foldersNameSpace['prefix_present'] = 'forced'; |
| 989 | 989 | // uw-imap server with mailbox prefix or dovecot maybe |
| 990 | - $_foldersNameSpace['prefix'] = ($this->folderExists('Mail')?'Mail':(!empty($singleNameSpace['name'])?$singleNameSpace['name']:'')); |
|
| 990 | + $_foldersNameSpace['prefix'] = ($this->folderExists('Mail') ? 'Mail' : (!empty($singleNameSpace['name']) ? $singleNameSpace['name'] : '')); |
|
| 991 | 991 | } |
| 992 | - elseif($type == 'personal' && ($singleNameSpace['name'] == '#mh/') && $this->folderExists('mail')) |
|
| 992 | + elseif ($type == 'personal' && ($singleNameSpace['name'] == '#mh/') && $this->folderExists('mail')) |
|
| 993 | 993 | { |
| 994 | 994 | $_foldersNameSpace['prefix_present'] = 'forced'; |
| 995 | 995 | // uw-imap server with mailbox prefix or dovecot maybe |
@@ -998,9 +998,9 @@ discard block |
||
| 998 | 998 | $_foldersNameSpace['prefix_present'] = !empty($singleNameSpace['name']); |
| 999 | 999 | $_foldersNameSpace['prefix'] = $singleNameSpace['name']; |
| 1000 | 1000 | } |
| 1001 | - $_foldersNameSpace['delimiter'] = ($singleNameSpace['delimiter']?$singleNameSpace['delimiter']:$delimiter); |
|
| 1001 | + $_foldersNameSpace['delimiter'] = ($singleNameSpace['delimiter'] ? $singleNameSpace['delimiter'] : $delimiter); |
|
| 1002 | 1002 | $_foldersNameSpace['type'] = $type; |
| 1003 | - $foldersNameSpace[] =$_foldersNameSpace; |
|
| 1003 | + $foldersNameSpace[] = $_foldersNameSpace; |
|
| 1004 | 1004 | } |
| 1005 | 1005 | //echo "############## $type->".print_r($foldersNameSpace[$type],true)." ###################<br>"; |
| 1006 | 1006 | } |
@@ -1018,10 +1018,10 @@ discard block |
||
| 1018 | 1018 | */ |
| 1019 | 1019 | function getFolderPrefixFromNamespace($nameSpace, $folderName) |
| 1020 | 1020 | { |
| 1021 | - foreach($nameSpace as &$singleNameSpace) |
|
| 1021 | + foreach ($nameSpace as &$singleNameSpace) |
|
| 1022 | 1022 | { |
| 1023 | 1023 | //if (substr($singleNameSpace['prefix'],0,strlen($folderName))==$folderName) return $singleNameSpace['prefix']; |
| 1024 | - if (substr($folderName,0,strlen($singleNameSpace['prefix']))==$singleNameSpace['prefix']) return $singleNameSpace['prefix']; |
|
| 1024 | + if (substr($folderName, 0, strlen($singleNameSpace['prefix'])) == $singleNameSpace['prefix']) return $singleNameSpace['prefix']; |
|
| 1025 | 1025 | } |
| 1026 | 1026 | return ""; |
| 1027 | 1027 | } |
@@ -1032,12 +1032,12 @@ discard block |
||
| 1032 | 1032 | * @var boolean $_useCache |
| 1033 | 1033 | * @return string the hierarchyDelimiter |
| 1034 | 1034 | */ |
| 1035 | - function getHierarchyDelimiter($_useCache=true) |
|
| 1035 | + function getHierarchyDelimiter($_useCache = true) |
|
| 1036 | 1036 | { |
| 1037 | 1037 | static $HierarchyDelimiter = null; |
| 1038 | - if (is_null($HierarchyDelimiter)) $HierarchyDelimiter = Cache::getCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5); |
|
| 1039 | - if ($_useCache===false) unset($HierarchyDelimiter[$this->icServer->ImapServerId]); |
|
| 1040 | - if (isset($HierarchyDelimiter[$this->icServer->ImapServerId])&&!empty($HierarchyDelimiter[$this->icServer->ImapServerId])) |
|
| 1038 | + if (is_null($HierarchyDelimiter)) $HierarchyDelimiter = Cache::getCache(Cache::INSTANCE, 'email', 'HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 24 * 5); |
|
| 1039 | + if ($_useCache === false) unset($HierarchyDelimiter[$this->icServer->ImapServerId]); |
|
| 1040 | + if (isset($HierarchyDelimiter[$this->icServer->ImapServerId]) && !empty($HierarchyDelimiter[$this->icServer->ImapServerId])) |
|
| 1041 | 1041 | { |
| 1042 | 1042 | return $HierarchyDelimiter[$this->icServer->ImapServerId]; |
| 1043 | 1043 | } |
@@ -1047,17 +1047,17 @@ discard block |
||
| 1047 | 1047 | $this->icServer->getCurrentMailbox(); |
| 1048 | 1048 | $HierarchyDelimiter[$this->icServer->ImapServerId] = $this->icServer->getDelimiter(); |
| 1049 | 1049 | } |
| 1050 | - catch(\Exception $e) |
|
| 1050 | + catch (\Exception $e) |
|
| 1051 | 1051 | { |
| 1052 | - if ($e->getCode()==102) |
|
| 1052 | + if ($e->getCode() == 102) |
|
| 1053 | 1053 | { |
| 1054 | - self::$profileDefunct[$this->profileID]=$e->getMessage().($e->details?', '.$e->details:''); |
|
| 1055 | - Cache::setCache(Cache::INSTANCE,'email','profileDefunct'.trim($GLOBALS['egw_info']['user']['account_id']),self::$profileDefunct, $expiration=5*1); |
|
| 1054 | + self::$profileDefunct[$this->profileID] = $e->getMessage().($e->details ? ', '.$e->details : ''); |
|
| 1055 | + Cache::setCache(Cache::INSTANCE, 'email', 'profileDefunct'.trim($GLOBALS['egw_info']['user']['account_id']), self::$profileDefunct, $expiration = 5 * 1); |
|
| 1056 | 1056 | } |
| 1057 | 1057 | unset($e); |
| 1058 | 1058 | $HierarchyDelimiter[$this->icServer->ImapServerId] = '/'; |
| 1059 | 1059 | } |
| 1060 | - Cache::setCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']),$HierarchyDelimiter, 60*60*24*5); |
|
| 1060 | + Cache::setCache(Cache::INSTANCE, 'email', 'HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']), $HierarchyDelimiter, 60 * 60 * 24 * 5); |
|
| 1061 | 1061 | return $HierarchyDelimiter[$this->icServer->ImapServerId]; |
| 1062 | 1062 | } |
| 1063 | 1063 | |
@@ -1070,7 +1070,7 @@ discard block |
||
| 1070 | 1070 | { |
| 1071 | 1071 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$this->icServer->ImapServerId.' Connected:'.$this->icServer->_connected); |
| 1072 | 1072 | static $_specialUseFolders = null; |
| 1073 | - if (is_null($_specialUseFolders)||empty($_specialUseFolders)) $_specialUseFolders = Cache::getCache(Cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5); |
|
| 1073 | + if (is_null($_specialUseFolders) || empty($_specialUseFolders)) $_specialUseFolders = Cache::getCache(Cache::INSTANCE, 'email', 'specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 24 * 5); |
|
| 1074 | 1074 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_trash)); |
| 1075 | 1075 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_sent)); |
| 1076 | 1076 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_draft)); |
@@ -1078,20 +1078,20 @@ discard block |
||
| 1078 | 1078 | self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId]; |
| 1079 | 1079 | if (isset($_specialUseFolders[$this->icServer->ImapServerId]) && !empty($_specialUseFolders[$this->icServer->ImapServerId])) |
| 1080 | 1080 | return $_specialUseFolders[$this->icServer->ImapServerId]; |
| 1081 | - $_specialUseFolders[$this->icServer->ImapServerId]=array(); |
|
| 1081 | + $_specialUseFolders[$this->icServer->ImapServerId] = array(); |
|
| 1082 | 1082 | //if (!empty($this->icServer->acc_folder_trash) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash])) |
| 1083 | - $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash]='Trash'; |
|
| 1083 | + $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash] = 'Trash'; |
|
| 1084 | 1084 | //if (!empty($this->icServer->acc_folder_draft) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_draft])) |
| 1085 | - $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_draft]='Drafts'; |
|
| 1085 | + $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_draft] = 'Drafts'; |
|
| 1086 | 1086 | //if (!empty($this->icServer->acc_folder_sent) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_sent])) |
| 1087 | - $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_sent]='Sent'; |
|
| 1087 | + $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_sent] = 'Sent'; |
|
| 1088 | 1088 | //if (!empty($this->icServer->acc_folder_template) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_template])) |
| 1089 | - $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_template]='Templates'; |
|
| 1090 | - $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_junk]='Junk'; |
|
| 1091 | - $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_archive]='Archive'; |
|
| 1089 | + $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_template] = 'Templates'; |
|
| 1090 | + $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_junk] = 'Junk'; |
|
| 1091 | + $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_archive] = 'Archive'; |
|
| 1092 | 1092 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_specialUseFolders));//.'<->'.array2string($this->icServer)); |
| 1093 | 1093 | self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId]; |
| 1094 | - Cache::setCache(Cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),$_specialUseFolders, 60*60*24*5); |
|
| 1094 | + Cache::setCache(Cache::INSTANCE, 'email', 'specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']), $_specialUseFolders, 60 * 60 * 24 * 5); |
|
| 1095 | 1095 | return $_specialUseFolders[$this->icServer->ImapServerId]; |
| 1096 | 1096 | } |
| 1097 | 1097 | |
@@ -1105,8 +1105,8 @@ discard block |
||
| 1105 | 1105 | function folderIsSelectable($folderToSelect) |
| 1106 | 1106 | { |
| 1107 | 1107 | $retval = true; |
| 1108 | - if($folderToSelect && ($folderStatus = $this->getFolderStatus($folderToSelect,false,true))) { |
|
| 1109 | - if (!empty($folderStatus['attributes']) && stripos(array2string($folderStatus['attributes']),'noselect')!==false) |
|
| 1108 | + if ($folderToSelect && ($folderStatus = $this->getFolderStatus($folderToSelect, false, true))) { |
|
| 1109 | + if (!empty($folderStatus['attributes']) && stripos(array2string($folderStatus['attributes']), 'noselect') !== false) |
|
| 1110 | 1110 | { |
| 1111 | 1111 | $retval = false; |
| 1112 | 1112 | } |
@@ -1126,7 +1126,7 @@ discard block |
||
| 1126 | 1126 | * |
| 1127 | 1127 | * @throws Exception |
| 1128 | 1128 | */ |
| 1129 | - function _getStatus($folderName,$ignoreStatusCache=false) |
|
| 1129 | + function _getStatus($folderName, $ignoreStatusCache = false) |
|
| 1130 | 1130 | { |
| 1131 | 1131 | static $folderStatus = null; |
| 1132 | 1132 | if (!$ignoreStatusCache && isset($folderStatus[$this->icServer->ImapServerId][$folderName])) |
@@ -1136,11 +1136,11 @@ discard block |
||
| 1136 | 1136 | } |
| 1137 | 1137 | try |
| 1138 | 1138 | { |
| 1139 | - $folderStatus[$this->icServer->ImapServerId][$folderName] = $this->icServer->getStatus($folderName,$ignoreStatusCache); |
|
| 1139 | + $folderStatus[$this->icServer->ImapServerId][$folderName] = $this->icServer->getStatus($folderName, $ignoreStatusCache); |
|
| 1140 | 1140 | } |
| 1141 | 1141 | catch (\Exception $e) |
| 1142 | 1142 | { |
| 1143 | - throw new Exception(__METHOD__.' ('.__LINE__.') '." failed for $folderName with error:".$e->getMessage().($e->details?', '.$e->details:'')); |
|
| 1143 | + throw new Exception(__METHOD__.' ('.__LINE__.') '." failed for $folderName with error:".$e->getMessage().($e->details ? ', '.$e->details : '')); |
|
| 1144 | 1144 | } |
| 1145 | 1145 | return $folderStatus[$this->icServer->ImapServerId][$folderName]; |
| 1146 | 1146 | } |
@@ -1156,10 +1156,10 @@ discard block |
||
| 1156 | 1156 | * @param fetchSubscribedInfo bool fetch Subscribed Info on folder |
| 1157 | 1157 | * @return array |
| 1158 | 1158 | */ |
| 1159 | - function getFolderStatus($_folderName,$ignoreStatusCache=false,$basicInfoOnly=false,$fetchSubscribedInfo=true) |
|
| 1159 | + function getFolderStatus($_folderName, $ignoreStatusCache = false, $basicInfoOnly = false, $fetchSubscribedInfo = true) |
|
| 1160 | 1160 | { |
| 1161 | 1161 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '." called with:$_folderName,$ignoreStatusCache,$basicInfoOnly"); |
| 1162 | - if (!is_string($_folderName) || empty($_folderName)||(isset(self::$profileDefunct[$this->profileID]) && strlen(self::$profileDefunct[$this->profileID]))) |
|
| 1162 | + if (!is_string($_folderName) || empty($_folderName) || (isset(self::$profileDefunct[$this->profileID]) && strlen(self::$profileDefunct[$this->profileID]))) |
|
| 1163 | 1163 | { |
| 1164 | 1164 | // something is wrong. Do not proceed. either no folder or profile is marked as defunct for this request |
| 1165 | 1165 | return false; |
@@ -1170,7 +1170,7 @@ discard block |
||
| 1170 | 1170 | { |
| 1171 | 1171 | $folderInfoCache = $folderBasicInfo[$this->profileID]; |
| 1172 | 1172 | } |
| 1173 | - if (isset($folderInfoCache[$_folderName]) && $ignoreStatusCache==false && $basicInfoOnly) return $folderInfoCache[$_folderName]; |
|
| 1173 | + if (isset($folderInfoCache[$_folderName]) && $ignoreStatusCache == false && $basicInfoOnly) return $folderInfoCache[$_folderName]; |
|
| 1174 | 1174 | $retValue = array(); |
| 1175 | 1175 | $retValue['subscribed'] = false; |
| 1176 | 1176 | /* |
@@ -1191,41 +1191,41 @@ discard block |
||
| 1191 | 1191 | { |
| 1192 | 1192 | //error_log(__METHOD__.array2string($e)); |
| 1193 | 1193 | //error_log(__METHOD__." failed to fetch Mailbox $_folderName on ".$this->profileID.' Reason:'.$e->getMessage().($e->details?', '.$e->details:'')/*.function_backtrace()*/); |
| 1194 | - self::$profileDefunct[$this->profileID]=$e->getMessage().($e->details?', '.$e->details:''); |
|
| 1195 | - Cache::setCache(Cache::INSTANCE,'email','profileDefunct'.trim($GLOBALS['egw_info']['user']['account_id']),self::$profileDefunct, $expiration=5*1); |
|
| 1196 | - throw new Exception(__METHOD__." failed to fetch Mailbox $_folderName on ".$this->profileID.' Reason:'.$e->getMessage().($e->details?', '.$e->details:'')); |
|
| 1194 | + self::$profileDefunct[$this->profileID] = $e->getMessage().($e->details ? ', '.$e->details : ''); |
|
| 1195 | + Cache::setCache(Cache::INSTANCE, 'email', 'profileDefunct'.trim($GLOBALS['egw_info']['user']['account_id']), self::$profileDefunct, $expiration = 5 * 1); |
|
| 1196 | + throw new Exception(__METHOD__." failed to fetch Mailbox $_folderName on ".$this->profileID.' Reason:'.$e->getMessage().($e->details ? ', '.$e->details : '')); |
|
| 1197 | 1197 | } |
| 1198 | 1198 | //error_log(__METHOD__.' ('.__LINE__.') '.$_folderName.' '.array2string($ret)); |
| 1199 | 1199 | if (is_array($ret)) |
| 1200 | 1200 | { |
| 1201 | 1201 | $retkeys = array_keys($ret); |
| 1202 | - if ($retkeys[0]==$_folderName) $folderInfoCache[$_folderName] = $ret[$retkeys[0]]; |
|
| 1202 | + if ($retkeys[0] == $_folderName) $folderInfoCache[$_folderName] = $ret[$retkeys[0]]; |
|
| 1203 | 1203 | } |
| 1204 | 1204 | else |
| 1205 | 1205 | { |
| 1206 | - $folderInfoCache[$_folderName]=false; |
|
| 1206 | + $folderInfoCache[$_folderName] = false; |
|
| 1207 | 1207 | } |
| 1208 | 1208 | } |
| 1209 | 1209 | $folderInfo = $folderInfoCache[$_folderName]; |
| 1210 | 1210 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($folderInfo).'->'.function_backtrace()); |
| 1211 | - if($ignoreStatusCache||!$folderInfo|| !is_array($folderInfo)) { |
|
| 1211 | + if ($ignoreStatusCache || !$folderInfo || !is_array($folderInfo)) { |
|
| 1212 | 1212 | try |
| 1213 | 1213 | { |
| 1214 | - $folderInfo = $this->_getStatus($_folderName,$ignoreStatusCache); |
|
| 1214 | + $folderInfo = $this->_getStatus($_folderName, $ignoreStatusCache); |
|
| 1215 | 1215 | } |
| 1216 | 1216 | catch (\Exception $e) |
| 1217 | 1217 | { |
| 1218 | 1218 | //error_log(__METHOD__.array2string($e)); |
| 1219 | - error_log(__METHOD__." failed to fetch status for $_folderName on ".$this->profileID.' Reason:'.$e->getMessage().($e->details?', '.$e->details:'')/*.function_backtrace()*/); |
|
| 1220 | - self::$profileDefunct[$this->profileID]=$e->getMessage().($e->details?', '.$e->details:''); |
|
| 1221 | - Cache::setCache(Cache::INSTANCE,'email','profileDefunct'.trim($GLOBALS['egw_info']['user']['account_id']),self::$profileDefunct, $expiration=5*1); |
|
| 1219 | + error_log(__METHOD__." failed to fetch status for $_folderName on ".$this->profileID.' Reason:'.$e->getMessage().($e->details ? ', '.$e->details : '')/*.function_backtrace()*/); |
|
| 1220 | + self::$profileDefunct[$this->profileID] = $e->getMessage().($e->details ? ', '.$e->details : ''); |
|
| 1221 | + Cache::setCache(Cache::INSTANCE, 'email', 'profileDefunct'.trim($GLOBALS['egw_info']['user']['account_id']), self::$profileDefunct, $expiration = 5 * 1); |
|
| 1222 | 1222 | //throw new Exception(__METHOD__." failed to fetch status for $_folderName on ".$this->profileID.' Reason:'.$e->getMessage().($e->details?', '.$e->details:'')); |
| 1223 | - $folderInfo=null; |
|
| 1223 | + $folderInfo = null; |
|
| 1224 | 1224 | } |
| 1225 | 1225 | if (!is_array($folderInfo)) |
| 1226 | 1226 | { |
| 1227 | 1227 | // no folder info, but there is a status returned for the folder: something is wrong, try to cope with it |
| 1228 | - $folderInfo = is_array($folderInfo)?$folderInfo:array('HIERACHY_DELIMITER'=>$this->getHierarchyDelimiter(), |
|
| 1228 | + $folderInfo = is_array($folderInfo) ? $folderInfo : array('HIERACHY_DELIMITER'=>$this->getHierarchyDelimiter(), |
|
| 1229 | 1229 | 'ATTRIBUTES' => ''); |
| 1230 | 1230 | if (!isset($folderInfo['HIERACHY_DELIMITER']) || empty($folderInfo['HIERACHY_DELIMITER']) || (isset($folderInfo['delimiter']) && empty($folderInfo['delimiter']))) |
| 1231 | 1231 | { |
@@ -1237,24 +1237,24 @@ discard block |
||
| 1237 | 1237 | #if(!is_array($folderInfo)) { |
| 1238 | 1238 | # return false; |
| 1239 | 1239 | #} |
| 1240 | - $retValue['delimiter'] = (isset($folderInfo['HIERACHY_DELIMITER']) && $folderInfo['HIERACHY_DELIMITER']?$folderInfo['HIERACHY_DELIMITER']:$folderInfo['delimiter']); |
|
| 1241 | - $retValue['attributes'] = (isset($folderInfo['ATTRIBUTES']) && $folderInfo['ATTRIBUTES']?$folderInfo['ATTRIBUTES']:$folderInfo['attributes']); |
|
| 1242 | - $shortNameParts = explode($retValue['delimiter'], $_folderName); |
|
| 1240 | + $retValue['delimiter'] = (isset($folderInfo['HIERACHY_DELIMITER']) && $folderInfo['HIERACHY_DELIMITER'] ? $folderInfo['HIERACHY_DELIMITER'] : $folderInfo['delimiter']); |
|
| 1241 | + $retValue['attributes'] = (isset($folderInfo['ATTRIBUTES']) && $folderInfo['ATTRIBUTES'] ? $folderInfo['ATTRIBUTES'] : $folderInfo['attributes']); |
|
| 1242 | + $shortNameParts = explode($retValue['delimiter'], $_folderName); |
|
| 1243 | 1243 | $retValue['shortName'] = array_pop($shortNameParts); |
| 1244 | 1244 | $retValue['displayName'] = $_folderName; |
| 1245 | - $retValue['shortDisplayName'] = $retValue['shortName']; |
|
| 1246 | - if(strtoupper($retValue['shortName']) == 'INBOX') { |
|
| 1247 | - $retValue['displayName'] = lang('INBOX'); |
|
| 1248 | - $retValue['shortDisplayName'] = lang('INBOX'); |
|
| 1245 | + $retValue['shortDisplayName'] = $retValue['shortName']; |
|
| 1246 | + if (strtoupper($retValue['shortName']) == 'INBOX') { |
|
| 1247 | + $retValue['displayName'] = lang('INBOX'); |
|
| 1248 | + $retValue['shortDisplayName'] = lang('INBOX'); |
|
| 1249 | 1249 | } |
| 1250 | 1250 | // translate the automatic Folders (Sent, Drafts, ...) like the INBOX |
| 1251 | - elseif (in_array($retValue['shortName'],self::$autoFolders)) |
|
| 1251 | + elseif (in_array($retValue['shortName'], self::$autoFolders)) |
|
| 1252 | 1252 | { |
| 1253 | 1253 | $retValue['displayName'] = $retValue['shortDisplayName'] = lang($retValue['shortName']); |
| 1254 | 1254 | } |
| 1255 | - if ($folderInfo) $folderBasicInfo[$this->profileID][$_folderName]=$retValue; |
|
| 1255 | + if ($folderInfo) $folderBasicInfo[$this->profileID][$_folderName] = $retValue; |
|
| 1256 | 1256 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$_folderName.array2string($retValue['attributes'])); |
| 1257 | - if ($basicInfoOnly || (isset($retValue['attributes']) && stripos(array2string($retValue['attributes']),'noselect')!==false)) |
|
| 1257 | + if ($basicInfoOnly || (isset($retValue['attributes']) && stripos(array2string($retValue['attributes']), 'noselect') !== false)) |
|
| 1258 | 1258 | { |
| 1259 | 1259 | return $retValue; |
| 1260 | 1260 | } |
@@ -1267,12 +1267,12 @@ discard block |
||
| 1267 | 1267 | if (is_null($nameSpace) || empty($nameSpace[$this->profileID])) $nameSpace[$this->profileID] = $this->_getNameSpaces(); |
| 1268 | 1268 | if (!empty($nameSpace[$this->profileID])) |
| 1269 | 1269 | { |
| 1270 | - $nsNoPersonal=array(); |
|
| 1271 | - foreach($nameSpace[$this->profileID] as &$ns) |
|
| 1270 | + $nsNoPersonal = array(); |
|
| 1271 | + foreach ($nameSpace[$this->profileID] as &$ns) |
|
| 1272 | 1272 | { |
| 1273 | - if ($ns['type']!='personal') $nsNoPersonal[]=$ns; |
|
| 1273 | + if ($ns['type'] != 'personal') $nsNoPersonal[] = $ns; |
|
| 1274 | 1274 | } |
| 1275 | - $nameSpace[$this->profileID]=$nsNoPersonal; |
|
| 1275 | + $nameSpace[$this->profileID] = $nsNoPersonal; |
|
| 1276 | 1276 | } |
| 1277 | 1277 | if (is_null($prefix) || empty($prefix[$this->profileID]) || empty($prefix[$this->profileID][$_folderName])) $prefix[$this->profileID][$_folderName] = $this->getFolderPrefixFromNamespace($nameSpace[$this->profileID], $_folderName); |
| 1278 | 1278 | |
@@ -1281,34 +1281,34 @@ discard block |
||
| 1281 | 1281 | $subscribedFolders[$this->profileID] = $this->icServer->listSubscribedMailboxes(); |
| 1282 | 1282 | } |
| 1283 | 1283 | |
| 1284 | - if($fetchSubscribedInfo && is_array($subscribedFolders[$this->profileID]) && in_array($_folderName,$subscribedFolders[$this->profileID])) { |
|
| 1284 | + if ($fetchSubscribedInfo && is_array($subscribedFolders[$this->profileID]) && in_array($_folderName, $subscribedFolders[$this->profileID])) { |
|
| 1285 | 1285 | $retValue['subscribed'] = true; |
| 1286 | 1286 | } |
| 1287 | 1287 | |
| 1288 | 1288 | try |
| 1289 | 1289 | { |
| 1290 | 1290 | //$folderStatus = $this->_getStatus($_folderName,$ignoreStatusCache); |
| 1291 | - $folderStatus = $this->getMailBoxCounters($_folderName,false); |
|
| 1292 | - $retValue['messages'] = $folderStatus['MESSAGES']; |
|
| 1291 | + $folderStatus = $this->getMailBoxCounters($_folderName, false); |
|
| 1292 | + $retValue['messages'] = $folderStatus['MESSAGES']; |
|
| 1293 | 1293 | $retValue['recent'] = $folderStatus['RECENT']; |
| 1294 | - $retValue['uidnext'] = $folderStatus['UIDNEXT']; |
|
| 1295 | - $retValue['uidvalidity'] = $folderStatus['UIDVALIDITY']; |
|
| 1294 | + $retValue['uidnext'] = $folderStatus['UIDNEXT']; |
|
| 1295 | + $retValue['uidvalidity'] = $folderStatus['UIDVALIDITY']; |
|
| 1296 | 1296 | $retValue['unseen'] = $folderStatus['UNSEEN']; |
| 1297 | 1297 | if (//$retValue['unseen']==0 && |
| 1298 | 1298 | (isset($this->mailPreferences['trustServersUnseenInfo']) && // some servers dont serve the UNSEEN information |
| 1299 | - $this->mailPreferences['trustServersUnseenInfo']==false) || |
|
| 1299 | + $this->mailPreferences['trustServersUnseenInfo'] == false) || |
|
| 1300 | 1300 | (isset($this->mailPreferences['trustServersUnseenInfo']) && |
| 1301 | - $this->mailPreferences['trustServersUnseenInfo']==2 && |
|
| 1302 | - $prefix[$this->profileID][$_folderName] != '' && stripos($_folderName,$prefix[$this->profileID][$_folderName]) !== false) |
|
| 1301 | + $this->mailPreferences['trustServersUnseenInfo'] == 2 && |
|
| 1302 | + $prefix[$this->profileID][$_folderName] != '' && stripos($_folderName, $prefix[$this->profileID][$_folderName]) !== false) |
|
| 1303 | 1303 | ) |
| 1304 | 1304 | { |
| 1305 | 1305 | //error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($prefix,true).' TS:'.$this->mailPreferences['trustServersUnseenInfo']); |
| 1306 | 1306 | // we filter for the combined status of unseen and undeleted, as this is what we show in list |
| 1307 | 1307 | try |
| 1308 | 1308 | { |
| 1309 | - $byUid=true; |
|
| 1310 | - $_reverse=1; |
|
| 1311 | - $sortResult = $this->getSortedList($_folderName, $_sort=0, $_reverse, array('status'=>array('UNSEEN','UNDELETED')),$byUid,false); |
|
| 1309 | + $byUid = true; |
|
| 1310 | + $_reverse = 1; |
|
| 1311 | + $sortResult = $this->getSortedList($_folderName, $_sort = 0, $_reverse, array('status'=>array('UNSEEN', 'UNDELETED')), $byUid, false); |
|
| 1312 | 1312 | $retValue['unseen'] = $sortResult['count']; |
| 1313 | 1313 | } |
| 1314 | 1314 | catch (\Exception $ee) |
@@ -1319,7 +1319,7 @@ discard block |
||
| 1319 | 1319 | } |
| 1320 | 1320 | catch (\Exception $e) |
| 1321 | 1321 | { |
| 1322 | - if (self::$debug) error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($e->getMessage(),true)); |
|
| 1322 | + if (self::$debug) error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($e->getMessage(), true)); |
|
| 1323 | 1323 | } |
| 1324 | 1324 | |
| 1325 | 1325 | return $retValue; |
@@ -1341,7 +1341,7 @@ discard block |
||
| 1341 | 1341 | * @param mixed $_fetchPreviews = false (boolean/int) fetch part of the body of the messages requested (if integer the number is assumed to be the number of chars to be returned for preview; if set to true 300 chars are returned (when available)) |
| 1342 | 1342 | * @return array result as array(header=>array,total=>int,first=>int,last=>int) |
| 1343 | 1343 | */ |
| 1344 | - function getHeaders($_folderName, $_startMessage, $_numberOfMessages, $_sort, $_reverse, $_filter, $_thisUIDOnly=null, $_cacheResult=true, $_fetchPreviews=false) |
|
| 1344 | + function getHeaders($_folderName, $_startMessage, $_numberOfMessages, $_sort, $_reverse, $_filter, $_thisUIDOnly = null, $_cacheResult = true, $_fetchPreviews = false) |
|
| 1345 | 1345 | { |
| 1346 | 1346 | //self::$debug=true; |
| 1347 | 1347 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.function_backtrace()); |
@@ -1354,7 +1354,7 @@ discard block |
||
| 1354 | 1354 | $rByUid = true; // try searching by uid. this var will be passed by reference to getSortedList, and may be set to false, if UID retrieval fails |
| 1355 | 1355 | #print "<pre>"; |
| 1356 | 1356 | #$this->icServer->setDebug(true); |
| 1357 | - $total=0; |
|
| 1357 | + $total = 0; |
|
| 1358 | 1358 | if ($_thisUIDOnly === null) |
| 1359 | 1359 | { |
| 1360 | 1360 | if (($_startMessage || $_numberOfMessages) && !isset($_filter['range'])) |
@@ -1367,24 +1367,24 @@ discard block |
||
| 1367 | 1367 | //$_filter['range'] ="$_startMessage:*"; |
| 1368 | 1368 | } |
| 1369 | 1369 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$_folderName, $_sort, $reverse, ".array2string($_filter).", $rByUid"); |
| 1370 | - if (self::$debug||self::$debugTimes) $starttime = microtime (true); |
|
| 1370 | + if (self::$debug || self::$debugTimes) $starttime = microtime(true); |
|
| 1371 | 1371 | //see this example below for a 12 week datefilter (since) |
| 1372 | 1372 | //$_filter = array('status'=>array('UNDELETED'),'type'=>"SINCE",'string'=> date("d-M-Y", $starttime-(3600*24*7*12))); |
| 1373 | 1373 | $_sortResult = $this->getSortedList($_folderName, $_sort, $reverse, $_filter, $rByUid, $_cacheResult); |
| 1374 | 1374 | $sortResult = $_sortResult['match']->ids; |
| 1375 | 1375 | //$modseq = $_sortResult['modseq']; |
| 1376 | 1376 | //error_log(__METHOD__.' ('.__LINE__.') '.'Modsequence:'.$modseq); |
| 1377 | - if (self::$debug||self::$debugTimes) self::logRunTimes($starttime,null,' call getSortedList for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_thisUIDOnly),__METHOD__.' ('.__LINE__.') '); |
|
| 1377 | + if (self::$debug || self::$debugTimes) self::logRunTimes($starttime, null, ' call getSortedList for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_thisUIDOnly), __METHOD__.' ('.__LINE__.') '); |
|
| 1378 | 1378 | |
| 1379 | 1379 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult)); |
| 1380 | 1380 | #$this->icServer->setDebug(false); |
| 1381 | 1381 | #print "</pre>"; |
| 1382 | 1382 | // nothing found |
| 1383 | - if(!is_array($sortResult) || empty($sortResult)) { |
|
| 1383 | + if (!is_array($sortResult) || empty($sortResult)) { |
|
| 1384 | 1384 | $retValue = array(); |
| 1385 | 1385 | $retValue['info']['total'] = 0; |
| 1386 | 1386 | $retValue['info']['first'] = 0; |
| 1387 | - $retValue['info']['last'] = 0; |
|
| 1387 | + $retValue['info']['last'] = 0; |
|
| 1388 | 1388 | return $retValue; |
| 1389 | 1389 | } |
| 1390 | 1390 | |
@@ -1392,54 +1392,54 @@ discard block |
||
| 1392 | 1392 | #_debug_array($sortResult); |
| 1393 | 1393 | #_debug_array(array_slice($sortResult, -5, -2)); |
| 1394 | 1394 | //error_log("REVERSE: $reverse"); |
| 1395 | - if($reverse === true) { |
|
| 1396 | - if ($_startMessage<=$total) |
|
| 1395 | + if ($reverse === true) { |
|
| 1396 | + if ($_startMessage <= $total) |
|
| 1397 | 1397 | { |
| 1398 | - $startMessage = $_startMessage-1; |
|
| 1398 | + $startMessage = $_startMessage - 1; |
|
| 1399 | 1399 | } |
| 1400 | 1400 | else |
| 1401 | 1401 | { |
| 1402 | 1402 | //error_log(__METHOD__.' ('.__LINE__.') '.' Start:'.$_startMessage.' NumberOfMessages:'.$_numberOfMessages.' Total:'.$total); |
| 1403 | - if ($_startMessage+$_numberOfMessages>$total) |
|
| 1403 | + if ($_startMessage + $_numberOfMessages > $total) |
|
| 1404 | 1404 | { |
| 1405 | - $numberOfMessages = $total%$_numberOfMessages; |
|
| 1405 | + $numberOfMessages = $total % $_numberOfMessages; |
|
| 1406 | 1406 | //$numberOfMessages = abs($_startMessage-$total-1); |
| 1407 | - if ($numberOfMessages>0 && $numberOfMessages<=$_numberOfMessages) $_numberOfMessages = $numberOfMessages; |
|
| 1407 | + if ($numberOfMessages > 0 && $numberOfMessages <= $_numberOfMessages) $_numberOfMessages = $numberOfMessages; |
|
| 1408 | 1408 | //error_log(__METHOD__.' ('.__LINE__.') '.' Start:'.$_startMessage.' NumberOfMessages:'.$_numberOfMessages.' Total:'.$total); |
| 1409 | 1409 | } |
| 1410 | - $startMessage=($total-$_numberOfMessages)-1; |
|
| 1410 | + $startMessage = ($total - $_numberOfMessages) - 1; |
|
| 1411 | 1411 | //$retValue['info']['first'] = $startMessage; |
| 1412 | 1412 | //$retValue['info']['last'] = $total; |
| 1413 | 1413 | |
| 1414 | 1414 | } |
| 1415 | - if ($startMessage+$_numberOfMessages>$total) |
|
| 1415 | + if ($startMessage + $_numberOfMessages > $total) |
|
| 1416 | 1416 | { |
| 1417 | - $_numberOfMessages = $_numberOfMessages-($total-($startMessage+$_numberOfMessages)); |
|
| 1417 | + $_numberOfMessages = $_numberOfMessages - ($total - ($startMessage + $_numberOfMessages)); |
|
| 1418 | 1418 | //$retValue['info']['first'] = $startMessage; |
| 1419 | 1419 | //$retValue['info']['last'] = $total; |
| 1420 | 1420 | } |
| 1421 | - if($startMessage > 0) { |
|
| 1422 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+$startMessage)).', '.-$startMessage.' Number of Messages:'.count($sortResult)); |
|
| 1423 | - $sortResult = array_slice($sortResult, -($_numberOfMessages+$startMessage), -$startMessage); |
|
| 1421 | + if ($startMessage > 0) { |
|
| 1422 | + if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages + $startMessage)).', '.-$startMessage.' Number of Messages:'.count($sortResult)); |
|
| 1423 | + $sortResult = array_slice($sortResult, -($_numberOfMessages + $startMessage), -$startMessage); |
|
| 1424 | 1424 | } else { |
| 1425 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+($_startMessage-1))).', AllTheRest, Number of Messages:'.count($sortResult)); |
|
| 1426 | - $sortResult = array_slice($sortResult, -($_numberOfMessages+($_startMessage-1))); |
|
| 1425 | + if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages + ($_startMessage - 1))).', AllTheRest, Number of Messages:'.count($sortResult)); |
|
| 1426 | + $sortResult = array_slice($sortResult, -($_numberOfMessages + ($_startMessage - 1))); |
|
| 1427 | 1427 | } |
| 1428 | 1428 | $sortResult = array_reverse($sortResult); |
| 1429 | 1429 | } else { |
| 1430 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.($_startMessage-1).', '.$_numberOfMessages.' Number of Messages:'.count($sortResult)); |
|
| 1431 | - $sortResult = array_slice($sortResult, $_startMessage-1, $_numberOfMessages); |
|
| 1430 | + if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.($_startMessage - 1).', '.$_numberOfMessages.' Number of Messages:'.count($sortResult)); |
|
| 1431 | + $sortResult = array_slice($sortResult, $_startMessage - 1, $_numberOfMessages); |
|
| 1432 | 1432 | } |
| 1433 | 1433 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult)); |
| 1434 | 1434 | } |
| 1435 | 1435 | else |
| 1436 | 1436 | { |
| 1437 | - $sortResult = (is_array($_thisUIDOnly) ? $_thisUIDOnly:(array)$_thisUIDOnly); |
|
| 1437 | + $sortResult = (is_array($_thisUIDOnly) ? $_thisUIDOnly : (array)$_thisUIDOnly); |
|
| 1438 | 1438 | } |
| 1439 | 1439 | |
| 1440 | 1440 | |
| 1441 | 1441 | // fetch the data for the selected messages |
| 1442 | - if (self::$debug||self::$debugTimes) $starttime = microtime(true); |
|
| 1442 | + if (self::$debug || self::$debugTimes) $starttime = microtime(true); |
|
| 1443 | 1443 | try |
| 1444 | 1444 | { |
| 1445 | 1445 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
@@ -1448,22 +1448,22 @@ discard block |
||
| 1448 | 1448 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
| 1449 | 1449 | |
| 1450 | 1450 | // Pre-cache the headers we want, 'fetchHeaders' is a label into the cache |
| 1451 | - $fquery->headers('fetchHeaders',array( |
|
| 1452 | - 'DISPOSITION-NOTIFICATION-TO','RETURN-RECEIPT-TO','X-CONFIRM-READING-TO', |
|
| 1453 | - 'DATE','SUBJECT','FROM','TO','CC','REPLY-TO', |
|
| 1451 | + $fquery->headers('fetchHeaders', array( |
|
| 1452 | + 'DISPOSITION-NOTIFICATION-TO', 'RETURN-RECEIPT-TO', 'X-CONFIRM-READING-TO', |
|
| 1453 | + 'DATE', 'SUBJECT', 'FROM', 'TO', 'CC', 'REPLY-TO', |
|
| 1454 | 1454 | 'X-PRIORITY' |
| 1455 | - ),array( |
|
| 1455 | + ), array( |
|
| 1456 | 1456 | // Cache headers, we'll look at them below |
| 1457 | - 'cache' => true,//$_cacheResult, |
|
| 1457 | + 'cache' => true, //$_cacheResult, |
|
| 1458 | 1458 | // Set peek so messages are not flagged as read |
| 1459 | 1459 | 'peek' => true |
| 1460 | 1460 | )); |
| 1461 | 1461 | $fquery->size(); |
| 1462 | 1462 | $fquery->structure(); |
| 1463 | 1463 | $fquery->flags(); |
| 1464 | - $fquery->imapDate();// needed to ensure getImapDate fetches the internaldate, not the current time |
|
| 1464 | + $fquery->imapDate(); // needed to ensure getImapDate fetches the internaldate, not the current time |
|
| 1465 | 1465 | // if $_fetchPreviews is activated fetch part of the messages too |
| 1466 | - if ($_fetchPreviews) $fquery->fullText(array('peek'=>true,'length'=>((int)$_fetchPreviews<5000?5000:$_fetchPreviews),'start'=>0)); |
|
| 1466 | + if ($_fetchPreviews) $fquery->fullText(array('peek'=>true, 'length'=>((int)$_fetchPreviews < 5000 ? 5000 : $_fetchPreviews), 'start'=>0)); |
|
| 1467 | 1467 | $headersNew = $this->icServer->fetch($_folderName, $fquery, array( |
| 1468 | 1468 | 'ids' => $uidsToFetch, |
| 1469 | 1469 | )); |
@@ -1474,9 +1474,9 @@ discard block |
||
| 1474 | 1474 | $headersNew = array(); |
| 1475 | 1475 | $sortResult = array(); |
| 1476 | 1476 | } |
| 1477 | - if (self::$debug||self::$debugTimes) |
|
| 1477 | + if (self::$debug || self::$debugTimes) |
|
| 1478 | 1478 | { |
| 1479 | - self::logRunTimes($starttime,null,'HordeFetch: for Folder:'.$_folderName.' Filter:'.array2string($_filter),__METHOD__.' ('.__LINE__.') '); |
|
| 1479 | + self::logRunTimes($starttime, null, 'HordeFetch: for Folder:'.$_folderName.' Filter:'.array2string($_filter), __METHOD__.' ('.__LINE__.') '); |
|
| 1480 | 1480 | if (self::$debug) |
| 1481 | 1481 | { |
| 1482 | 1482 | $queryString = implode(',', $sortResult); |
@@ -1486,27 +1486,27 @@ discard block |
||
| 1486 | 1486 | |
| 1487 | 1487 | $cnt = 0; |
| 1488 | 1488 | |
| 1489 | - foreach((array)$sortResult as $uid) { |
|
| 1489 | + foreach ((array)$sortResult as $uid) { |
|
| 1490 | 1490 | $sortOrder[$uid] = $cnt++; |
| 1491 | 1491 | } |
| 1492 | 1492 | |
| 1493 | 1493 | $count = 0; |
| 1494 | 1494 | if (is_object($headersNew)) { |
| 1495 | - if (self::$debug||self::$debugTimes) $starttime = microtime(true); |
|
| 1496 | - foreach($headersNew->ids() as $id) { |
|
| 1495 | + if (self::$debug || self::$debugTimes) $starttime = microtime(true); |
|
| 1496 | + foreach ($headersNew->ids() as $id) { |
|
| 1497 | 1497 | $_headerObject = $headersNew->get($id); |
| 1498 | 1498 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_headerObject)); |
| 1499 | 1499 | $headerObject = array(); |
| 1500 | 1500 | $bodyPreview = null; |
| 1501 | - $uid = $headerObject['UID']= ($_headerObject->getUid()?$_headerObject->getUid():$id); |
|
| 1501 | + $uid = $headerObject['UID'] = ($_headerObject->getUid() ? $_headerObject->getUid() : $id); |
|
| 1502 | 1502 | $headerObject['MSG_NUM'] = $_headerObject->getSeq(); |
| 1503 | 1503 | $headerObject['SIZE'] = $_headerObject->getSize(); |
| 1504 | 1504 | $headerObject['INTERNALDATE'] = $_headerObject->getImapDate(); |
| 1505 | 1505 | |
| 1506 | 1506 | // Get already cached headers, 'fetchHeaders' is a label matchimg above |
| 1507 | - $headerForPrio = $_headerObject->getHeaders('fetchHeaders',Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(); |
|
| 1507 | + $headerForPrio = $_headerObject->getHeaders('fetchHeaders', Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(); |
|
| 1508 | 1508 | // Try to fetch header with key='' as some servers might have no fetchHeaders index. e.g. yandex.com |
| 1509 | - if (empty($headerForPrio)) $headerForPrio = $_headerObject->getHeaders('',Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(); |
|
| 1509 | + if (empty($headerForPrio)) $headerForPrio = $_headerObject->getHeaders('', Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(); |
|
| 1510 | 1510 | //fetch the fullMsg part if all conditions match to be available in case $_headerObject->getHeaders returns |
| 1511 | 1511 | //nothing worthwhile (as it does for googlemail accounts, when preview is switched on |
| 1512 | 1512 | if ($_fetchPreviews) |
@@ -1514,16 +1514,16 @@ discard block |
||
| 1514 | 1514 | // on enabled preview $bodyPreview is needed lateron. fetched here, for fallback-reasons |
| 1515 | 1515 | // in case of failed Header-Retrieval |
| 1516 | 1516 | $bodyPreview = $_headerObject->getFullMsg(); |
| 1517 | - if (empty($headerForPrio)||(is_array($headerForPrio)&&count($headerForPrio)===1&&$headerForPrio[''])) |
|
| 1517 | + if (empty($headerForPrio) || (is_array($headerForPrio) && count($headerForPrio) === 1 && $headerForPrio[''])) |
|
| 1518 | 1518 | { |
| 1519 | 1519 | $length = strpos($bodyPreview, Horde_Mime_Part::RFC_EOL.Horde_Mime_Part::RFC_EOL); |
| 1520 | - if ($length===false) $length = strlen($bodyPreview); |
|
| 1521 | - $headerForPrio = Horde_Mime_Headers::parseHeaders(substr($bodyPreview, 0,$length))->toArray(); |
|
| 1520 | + if ($length === false) $length = strlen($bodyPreview); |
|
| 1521 | + $headerForPrio = Horde_Mime_Headers::parseHeaders(substr($bodyPreview, 0, $length))->toArray(); |
|
| 1522 | 1522 | } |
| 1523 | 1523 | } |
| 1524 | 1524 | $headerForPrio = array_change_key_case($headerForPrio, CASE_UPPER); |
| 1525 | 1525 | if (self::$debug) { |
| 1526 | - error_log(__METHOD__.' ('.__LINE__.') '.array2string($_headerObject).'UID:'.$_headerObject->getUid().' Size:'.$_headerObject->getSize().' Date:'.$_headerObject->getImapDate().'/'.DateTime::to($_headerObject->getImapDate(),'Y-m-d H:i:s')); |
|
| 1526 | + error_log(__METHOD__.' ('.__LINE__.') '.array2string($_headerObject).'UID:'.$_headerObject->getUid().' Size:'.$_headerObject->getSize().' Date:'.$_headerObject->getImapDate().'/'.DateTime::to($_headerObject->getImapDate(), 'Y-m-d H:i:s')); |
|
| 1527 | 1527 | error_log(__METHOD__.' ('.__LINE__.') '.array2string($headerForPrio)); |
| 1528 | 1528 | } |
| 1529 | 1529 | // message deleted from server but cache still reporting its existence ; may happen on QRESYNC with No permanent modsequences |
@@ -1532,22 +1532,22 @@ discard block |
||
| 1532 | 1532 | $total--; |
| 1533 | 1533 | continue; |
| 1534 | 1534 | } |
| 1535 | - if ( isset($headerForPrio['DISPOSITION-NOTIFICATION-TO']) ) { |
|
| 1535 | + if (isset($headerForPrio['DISPOSITION-NOTIFICATION-TO'])) { |
|
| 1536 | 1536 | $headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['DISPOSITION-NOTIFICATION-TO'])); |
| 1537 | - } else if ( isset($headerForPrio['RETURN-RECEIPT-TO']) ) { |
|
| 1537 | + } else if (isset($headerForPrio['RETURN-RECEIPT-TO'])) { |
|
| 1538 | 1538 | $headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['RETURN-RECEIPT-TO'])); |
| 1539 | - } else if ( isset($headerForPrio['X-CONFIRM-READING-TO']) ) { |
|
| 1539 | + } else if (isset($headerForPrio['X-CONFIRM-READING-TO'])) { |
|
| 1540 | 1540 | $headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['X-CONFIRM-READING-TO'])); |
| 1541 | 1541 | } /*else $sent_not = "";*/ |
| 1542 | 1542 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($headerObject)); |
| 1543 | 1543 | $headerObject['DATE'] = $headerForPrio['DATE']; |
| 1544 | - $headerObject['SUBJECT'] = (is_array($headerForPrio['SUBJECT'])?$headerForPrio['SUBJECT'][0]:$headerForPrio['SUBJECT']); |
|
| 1545 | - $headerObject['FROM'] = (array)($headerForPrio['FROM']?$headerForPrio['FROM']:($headerForPrio['REPLY-TO']?$headerForPrio['REPLY-TO']:$headerForPrio['RETURN-PATH'])); |
|
| 1544 | + $headerObject['SUBJECT'] = (is_array($headerForPrio['SUBJECT']) ? $headerForPrio['SUBJECT'][0] : $headerForPrio['SUBJECT']); |
|
| 1545 | + $headerObject['FROM'] = (array)($headerForPrio['FROM'] ? $headerForPrio['FROM'] : ($headerForPrio['REPLY-TO'] ? $headerForPrio['REPLY-TO'] : $headerForPrio['RETURN-PATH'])); |
|
| 1546 | 1546 | $headerObject['TO'] = (array)$headerForPrio['TO']; |
| 1547 | - $headerObject['CC'] = isset($headerForPrio['CC'])?(array)$headerForPrio['CC']:array(); |
|
| 1548 | - $headerObject['REPLY-TO'] = isset($headerForPrio['REPLY-TO'])?(array)$headerForPrio['REPLY-TO']:array(); |
|
| 1549 | - $headerObject['PRIORITY'] = isset($headerForPrio['X-PRIORITY'])?$headerForPrio['X-PRIORITY']:null; |
|
| 1550 | - foreach (array('FROM','TO','CC','REPLY-TO') as $key) |
|
| 1547 | + $headerObject['CC'] = isset($headerForPrio['CC']) ? (array)$headerForPrio['CC'] : array(); |
|
| 1548 | + $headerObject['REPLY-TO'] = isset($headerForPrio['REPLY-TO']) ? (array)$headerForPrio['REPLY-TO'] : array(); |
|
| 1549 | + $headerObject['PRIORITY'] = isset($headerForPrio['X-PRIORITY']) ? $headerForPrio['X-PRIORITY'] : null; |
|
| 1550 | + foreach (array('FROM', 'TO', 'CC', 'REPLY-TO') as $key) |
|
| 1551 | 1551 | { |
| 1552 | 1552 | $address = array(); |
| 1553 | 1553 | foreach ($headerObject[$key] as $k => $ad) |
@@ -1569,13 +1569,13 @@ discard block |
||
| 1569 | 1569 | foreach ($rfcAddr as $_rfcAddr) |
| 1570 | 1570 | { |
| 1571 | 1571 | if (!$_rfcAddr->valid) continue; // skip. not a valid address |
| 1572 | - $address[] = imap_rfc822_write_address($_rfcAddr->mailbox,$_rfcAddr->host,$_rfcAddr->personal); |
|
| 1572 | + $address[] = imap_rfc822_write_address($_rfcAddr->mailbox, $_rfcAddr->host, $_rfcAddr->personal); |
|
| 1573 | 1573 | } |
| 1574 | 1574 | } |
| 1575 | 1575 | $headerObject[$key] = $address; |
| 1576 | 1576 | } |
| 1577 | 1577 | $headerObject['FLAGS'] = $_headerObject->getFlags(); |
| 1578 | - $headerObject['BODYPREVIEW']=null; |
|
| 1578 | + $headerObject['BODYPREVIEW'] = null; |
|
| 1579 | 1579 | // this section fetches part of the message-body (if enabled) for some kind of preview |
| 1580 | 1580 | // if we fail to succeed, we fall back to the retrieval of the message-body with |
| 1581 | 1581 | // fetchPartContents (see below, when we iterate over the structure to determine the |
@@ -1587,17 +1587,17 @@ discard block |
||
| 1587 | 1587 | if (empty($bodyPreview)) $bodyPreview = $_headerObject->getFullMsg(); |
| 1588 | 1588 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($bodyPreview)); |
| 1589 | 1589 | $base = Horde_Mime_Part::parseMessage($bodyPreview); |
| 1590 | - foreach($base->partIterator() as $part) |
|
| 1590 | + foreach ($base->partIterator() as $part) |
|
| 1591 | 1591 | { |
| 1592 | 1592 | //error_log(__METHOD__.__LINE__.'Part:'.$part->getPrimaryType()); |
| 1593 | - if (empty($headerObject['BODYPREVIEW'])&&$part->getPrimaryType()== 'text') |
|
| 1593 | + if (empty($headerObject['BODYPREVIEW']) && $part->getPrimaryType() == 'text') |
|
| 1594 | 1594 | { |
| 1595 | 1595 | $charset = $part->getContentTypeParameter('charset'); |
| 1596 | 1596 | $buffer = Mail\Html::convertHTMLToText($part->toString(array( |
| 1597 | - 'encode' => Horde_Mime_Part::ENCODE_BINARY, // otherwise we cant recode charset |
|
| 1597 | + 'encode' => Horde_Mime_Part::ENCODE_BINARY, // otherwise we cant recode charset |
|
| 1598 | 1598 | )), $charset, 'utf-8'); |
| 1599 | - $headerObject['BODYPREVIEW']=trim(str_replace(array("\r\n","\r","\n"),' ',mb_substr(Translation::convert_jsonsafe($buffer),0,((int)$_fetchPreviews<300?300:$_fetchPreviews)))); |
|
| 1600 | - } elseif (empty($headerObject['BODYPREVIEW'])&&$part->getPrimaryType()== 'multipart') |
|
| 1599 | + $headerObject['BODYPREVIEW'] = trim(str_replace(array("\r\n", "\r", "\n"), ' ', mb_substr(Translation::convert_jsonsafe($buffer), 0, ((int)$_fetchPreviews < 300 ? 300 : $_fetchPreviews)))); |
|
| 1600 | + } elseif (empty($headerObject['BODYPREVIEW']) && $part->getPrimaryType() == 'multipart') |
|
| 1601 | 1601 | { |
| 1602 | 1602 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($part)); |
| 1603 | 1603 | } |
@@ -1608,12 +1608,12 @@ discard block |
||
| 1608 | 1608 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($headerObject)); |
| 1609 | 1609 | //error_log(__METHOD__.' ('.__LINE__.') '.' MimeMap:'.array2string($mailStructureObject->contentTypeMap())); |
| 1610 | 1610 | //foreach ($_headerObject->getStructure()->getParts() as $p => $part) |
| 1611 | - $headerObject['ATTACHMENTS']=null; |
|
| 1612 | - $skipParts=array(); |
|
| 1613 | - $messageMimeType=''; |
|
| 1611 | + $headerObject['ATTACHMENTS'] = null; |
|
| 1612 | + $skipParts = array(); |
|
| 1613 | + $messageMimeType = ''; |
|
| 1614 | 1614 | foreach ($mailStructureObject->contentTypeMap() as $mime_id => $mime_type) |
| 1615 | 1615 | { |
| 1616 | - if ($mime_id==0 || $messageMimeType==='') $messageMimeType = $mime_type; |
|
| 1616 | + if ($mime_id == 0 || $messageMimeType === '') $messageMimeType = $mime_type; |
|
| 1617 | 1617 | $part = $mailStructureObject->getPart($mime_id); |
| 1618 | 1618 | $partdisposition = $part->getDisposition(); |
| 1619 | 1619 | $partPrimaryType = $part->getPrimaryType(); |
@@ -1621,16 +1621,16 @@ discard block |
||
| 1621 | 1621 | // drawback here it is talking to the mailserver for each mail thus consuming |
| 1622 | 1622 | // more time than expected; so we call this section only when there is no |
| 1623 | 1623 | // bodypreview could be found (multipart/....) |
| 1624 | - if ($_fetchPreviews && empty($headerObject['BODYPREVIEW'])&&($partPrimaryType == 'text') && |
|
| 1624 | + if ($_fetchPreviews && empty($headerObject['BODYPREVIEW']) && ($partPrimaryType == 'text') && |
|
| 1625 | 1625 | ((intval($mime_id) === 1) || !$mime_id) && |
| 1626 | 1626 | ($partdisposition !== 'attachment')) { |
| 1627 | - $_structure=$part; |
|
| 1628 | - $this->fetchPartContents($uid, $_structure, false,true); |
|
| 1629 | - $headerObject['BODYPREVIEW']=trim(str_replace(array("\r\n","\r","\n"),' ',mb_substr(Mail\Html::convertHTMLToText($_structure->getContents()),0,((int)$_fetchPreviews<300?300:$_fetchPreviews)))); |
|
| 1630 | - $charSet=Translation::detect_encoding($headerObject['BODYPREVIEW']); |
|
| 1627 | + $_structure = $part; |
|
| 1628 | + $this->fetchPartContents($uid, $_structure, false, true); |
|
| 1629 | + $headerObject['BODYPREVIEW'] = trim(str_replace(array("\r\n", "\r", "\n"), ' ', mb_substr(Mail\Html::convertHTMLToText($_structure->getContents()), 0, ((int)$_fetchPreviews < 300 ? 300 : $_fetchPreviews)))); |
|
| 1630 | + $charSet = Translation::detect_encoding($headerObject['BODYPREVIEW']); |
|
| 1631 | 1631 | // add line breaks to $bodyParts |
| 1632 | 1632 | //error_log(__METHOD__.' ('.__LINE__.') '.' Charset:'.$bodyParts[$i]['charSet'].'->'.$bodyParts[$i]['body']); |
| 1633 | - $headerObject['BODYPREVIEW'] = Translation::convert_jsonsafe($headerObject['BODYPREVIEW'], $charSet); |
|
| 1633 | + $headerObject['BODYPREVIEW'] = Translation::convert_jsonsafe($headerObject['BODYPREVIEW'], $charSet); |
|
| 1634 | 1634 | //error_log(__METHOD__.__LINE__.$headerObject['BODYPREVIEW']); |
| 1635 | 1635 | } |
| 1636 | 1636 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.' Disp:'.$partdisposition.' Type:'.$partPrimaryType); |
@@ -1640,28 +1640,28 @@ discard block |
||
| 1640 | 1640 | // the presence of an cid does not necessarily indicate its inline. it may lack the needed |
| 1641 | 1641 | // link to show the image. Considering this: we "list" everything that matches the above criteria |
| 1642 | 1642 | // as attachment in order to not loose/miss information on our data |
| 1643 | - $partdisposition='attachment';//($partPrimaryType == 'image'&&!empty($cid)?'inline':'attachment'); |
|
| 1643 | + $partdisposition = 'attachment'; //($partPrimaryType == 'image'&&!empty($cid)?'inline':'attachment'); |
|
| 1644 | 1644 | } |
| 1645 | - if ($mime_type=='message/rfc822') |
|
| 1645 | + if ($mime_type == 'message/rfc822') |
|
| 1646 | 1646 | { |
| 1647 | 1647 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.':'.array2string($part->contentTypeMap())); |
| 1648 | - foreach($part->contentTypeMap() as $sub_id => $sub_type) { if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type;} |
|
| 1648 | + foreach ($part->contentTypeMap() as $sub_id => $sub_type) { if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type; } |
|
| 1649 | 1649 | } |
| 1650 | 1650 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.' Disp:'.$partdisposition.' Type:'.$partPrimaryType.' Skip:'.array2string($skipParts)); |
| 1651 | - if (array_key_exists($mime_id,$skipParts)) continue; |
|
| 1652 | - if ($partdisposition=='attachment' || |
|
| 1653 | - ($partdisposition=='inline'&&$partPrimaryType == 'image'&&$mime_type=='image/tiff') || // as we are not able to display tiffs |
|
| 1654 | - ($partdisposition=='inline'&&$partPrimaryType == 'image'&&empty($cid)) || |
|
| 1655 | - ($partdisposition=='inline' && $partPrimaryType != 'image' && $partPrimaryType != 'multipart' && $partPrimaryType != 'text')) |
|
| 1651 | + if (array_key_exists($mime_id, $skipParts)) continue; |
|
| 1652 | + if ($partdisposition == 'attachment' || |
|
| 1653 | + ($partdisposition == 'inline' && $partPrimaryType == 'image' && $mime_type == 'image/tiff') || // as we are not able to display tiffs |
|
| 1654 | + ($partdisposition == 'inline' && $partPrimaryType == 'image' && empty($cid)) || |
|
| 1655 | + ($partdisposition == 'inline' && $partPrimaryType != 'image' && $partPrimaryType != 'multipart' && $partPrimaryType != 'text')) |
|
| 1656 | 1656 | { |
| 1657 | - $headerObject['ATTACHMENTS'][$mime_id]=$part->getAllDispositionParameters(); |
|
| 1658 | - $headerObject['ATTACHMENTS'][$mime_id]['mimeType']=$mime_type; |
|
| 1659 | - $headerObject['ATTACHMENTS'][$mime_id]['uid']=$uid; |
|
| 1657 | + $headerObject['ATTACHMENTS'][$mime_id] = $part->getAllDispositionParameters(); |
|
| 1658 | + $headerObject['ATTACHMENTS'][$mime_id]['mimeType'] = $mime_type; |
|
| 1659 | + $headerObject['ATTACHMENTS'][$mime_id]['uid'] = $uid; |
|
| 1660 | 1660 | $headerObject['ATTACHMENTS'][$mime_id]['cid'] = $cid; |
| 1661 | - $headerObject['ATTACHMENTS'][$mime_id]['partID']=$mime_id; |
|
| 1662 | - if (!isset($headerObject['ATTACHMENTS'][$mime_id]['name']))$headerObject['ATTACHMENTS'][$mime_id]['name']=$part->getName(); |
|
| 1663 | - if (!strcasecmp($headerObject['ATTACHMENTS'][$mime_id]['name'],'winmail.dat') || |
|
| 1664 | - $headerObject['ATTACHMENTS'][$mime_id]['mimeType']=='application/ms-tnef') |
|
| 1661 | + $headerObject['ATTACHMENTS'][$mime_id]['partID'] = $mime_id; |
|
| 1662 | + if (!isset($headerObject['ATTACHMENTS'][$mime_id]['name']))$headerObject['ATTACHMENTS'][$mime_id]['name'] = $part->getName(); |
|
| 1663 | + if (!strcasecmp($headerObject['ATTACHMENTS'][$mime_id]['name'], 'winmail.dat') || |
|
| 1664 | + $headerObject['ATTACHMENTS'][$mime_id]['mimeType'] == 'application/ms-tnef') |
|
| 1665 | 1665 | { |
| 1666 | 1666 | $headerObject['ATTACHMENTS'][$mime_id]['is_winmail'] = true; |
| 1667 | 1667 | } |
@@ -1676,57 +1676,57 @@ discard block |
||
| 1676 | 1676 | if (empty($headerObject['UID'])) continue; |
| 1677 | 1677 | //$uid = ($rByUid ? $headerObject['UID'] : $headerObject['MSG_NUM']); |
| 1678 | 1678 | // make dates like "Mon, 23 Apr 2007 10:11:06 UT" working with strtotime |
| 1679 | - if(substr($headerObject['DATE'],-2) === 'UT') { |
|
| 1679 | + if (substr($headerObject['DATE'], -2) === 'UT') { |
|
| 1680 | 1680 | $headerObject['DATE'] .= 'C'; |
| 1681 | 1681 | } |
| 1682 | - if(substr($headerObject['INTERNALDATE'],-2) === 'UT') { |
|
| 1682 | + if (substr($headerObject['INTERNALDATE'], -2) === 'UT') { |
|
| 1683 | 1683 | $headerObject['INTERNALDATE'] .= 'C'; |
| 1684 | 1684 | } |
| 1685 | 1685 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$headerObject['SUBJECT'].'->'.$headerObject['DATE'].'<->'.$headerObject['INTERNALDATE'] .'#'); |
| 1686 | 1686 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$this->decode_subject($headerObject['SUBJECT']).'->'.$headerObject['DATE']); |
| 1687 | - if (isset($headerObject['ATTACHMENTS']) && count($headerObject['ATTACHMENTS'])) foreach ($headerObject['ATTACHMENTS'] as &$a) { $retValue['header'][$sortOrder[$uid]]['attachments'][]=$a;} |
|
| 1688 | - $retValue['header'][$sortOrder[$uid]]['subject'] = $this->decode_subject($headerObject['SUBJECT']); |
|
| 1689 | - $retValue['header'][$sortOrder[$uid]]['size'] = $headerObject['SIZE']; |
|
| 1690 | - $retValue['header'][$sortOrder[$uid]]['date'] = self::_strtotime(($headerObject['DATE']&&!($headerObject['DATE']=='NIL')?$headerObject['DATE']:$headerObject['INTERNALDATE']),'ts',true); |
|
| 1691 | - $retValue['header'][$sortOrder[$uid]]['internaldate']= self::_strtotime($headerObject['INTERNALDATE'],'ts',true); |
|
| 1692 | - $retValue['header'][$sortOrder[$uid]]['mimetype'] = $messageMimeType; |
|
| 1693 | - $retValue['header'][$sortOrder[$uid]]['id'] = $headerObject['MSG_NUM']; |
|
| 1694 | - $retValue['header'][$sortOrder[$uid]]['uid'] = $headerObject['UID']; |
|
| 1695 | - $retValue['header'][$sortOrder[$uid]]['bodypreview'] = $headerObject['BODYPREVIEW']; |
|
| 1696 | - $retValue['header'][$sortOrder[$uid]]['priority'] = ($headerObject['PRIORITY']?$headerObject['PRIORITY']:3); |
|
| 1687 | + if (isset($headerObject['ATTACHMENTS']) && count($headerObject['ATTACHMENTS'])) foreach ($headerObject['ATTACHMENTS'] as &$a) { $retValue['header'][$sortOrder[$uid]]['attachments'][] = $a; } |
|
| 1688 | + $retValue['header'][$sortOrder[$uid]]['subject'] = $this->decode_subject($headerObject['SUBJECT']); |
|
| 1689 | + $retValue['header'][$sortOrder[$uid]]['size'] = $headerObject['SIZE']; |
|
| 1690 | + $retValue['header'][$sortOrder[$uid]]['date'] = self::_strtotime(($headerObject['DATE'] && !($headerObject['DATE'] == 'NIL') ? $headerObject['DATE'] : $headerObject['INTERNALDATE']), 'ts', true); |
|
| 1691 | + $retValue['header'][$sortOrder[$uid]]['internaldate'] = self::_strtotime($headerObject['INTERNALDATE'], 'ts', true); |
|
| 1692 | + $retValue['header'][$sortOrder[$uid]]['mimetype'] = $messageMimeType; |
|
| 1693 | + $retValue['header'][$sortOrder[$uid]]['id'] = $headerObject['MSG_NUM']; |
|
| 1694 | + $retValue['header'][$sortOrder[$uid]]['uid'] = $headerObject['UID']; |
|
| 1695 | + $retValue['header'][$sortOrder[$uid]]['bodypreview'] = $headerObject['BODYPREVIEW']; |
|
| 1696 | + $retValue['header'][$sortOrder[$uid]]['priority'] = ($headerObject['PRIORITY'] ? $headerObject['PRIORITY'] : 3); |
|
| 1697 | 1697 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.array2string($retValue['header'][$sortOrder[$uid]])); |
| 1698 | 1698 | if (isset($headerObject['DISPOSITION-NOTIFICATION-TO'])) $retValue['header'][$sortOrder[$uid]]['disposition-notification-to'] = $headerObject['DISPOSITION-NOTIFICATION-TO']; |
| 1699 | 1699 | if (is_array($headerObject['FLAGS'])) { |
| 1700 | - $retValue['header'][$sortOrder[$uid]] = array_merge($retValue['header'][$sortOrder[$uid]],self::prepareFlagsArray($headerObject)); |
|
| 1700 | + $retValue['header'][$sortOrder[$uid]] = array_merge($retValue['header'][$sortOrder[$uid]], self::prepareFlagsArray($headerObject)); |
|
| 1701 | 1701 | } |
| 1702 | 1702 | //error_log(__METHOD__.' ('.__LINE__.') '.$headerObject['SUBJECT'].'->'.array2string($_headerObject->getEnvelope()->__get('from'))); |
| 1703 | - if(is_array($headerObject['FROM']) && $headerObject['FROM'][0]) { |
|
| 1704 | - $retValue['header'][$sortOrder[$uid]]['sender_address'] = self::decode_header($headerObject['FROM'][0],true); |
|
| 1703 | + if (is_array($headerObject['FROM']) && $headerObject['FROM'][0]) { |
|
| 1704 | + $retValue['header'][$sortOrder[$uid]]['sender_address'] = self::decode_header($headerObject['FROM'][0], true); |
|
| 1705 | 1705 | } |
| 1706 | - if(is_array($headerObject['REPLY-TO']) && $headerObject['REPLY-TO'][0]) { |
|
| 1707 | - $retValue['header'][$sortOrder[$uid]]['reply_to_address'] = self::decode_header($headerObject['REPLY-TO'][0],true); |
|
| 1706 | + if (is_array($headerObject['REPLY-TO']) && $headerObject['REPLY-TO'][0]) { |
|
| 1707 | + $retValue['header'][$sortOrder[$uid]]['reply_to_address'] = self::decode_header($headerObject['REPLY-TO'][0], true); |
|
| 1708 | 1708 | } |
| 1709 | - if(is_array($headerObject['TO']) && $headerObject['TO'][0]) { |
|
| 1710 | - $retValue['header'][$sortOrder[$uid]]['to_address'] = self::decode_header($headerObject['TO'][0],true); |
|
| 1711 | - if (count($headerObject['TO'])>1) |
|
| 1709 | + if (is_array($headerObject['TO']) && $headerObject['TO'][0]) { |
|
| 1710 | + $retValue['header'][$sortOrder[$uid]]['to_address'] = self::decode_header($headerObject['TO'][0], true); |
|
| 1711 | + if (count($headerObject['TO']) > 1) |
|
| 1712 | 1712 | { |
| 1713 | - $ki=0; |
|
| 1714 | - foreach($headerObject['TO'] as $k => $add) |
|
| 1713 | + $ki = 0; |
|
| 1714 | + foreach ($headerObject['TO'] as $k => $add) |
|
| 1715 | 1715 | { |
| 1716 | - if ($k==0) continue; |
|
| 1716 | + if ($k == 0) continue; |
|
| 1717 | 1717 | //error_log(__METHOD__.' ('.__LINE__.') '."-> $k:".array2string($add)); |
| 1718 | - $retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki] = self::decode_header($add,true); |
|
| 1718 | + $retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki] = self::decode_header($add, true); |
|
| 1719 | 1719 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki])); |
| 1720 | 1720 | $ki++; |
| 1721 | 1721 | } |
| 1722 | 1722 | } |
| 1723 | 1723 | } |
| 1724 | - if(is_array($headerObject['CC']) && count($headerObject['CC'])>0) { |
|
| 1725 | - $ki=0; |
|
| 1726 | - foreach($headerObject['CC'] as $k => $add) |
|
| 1724 | + if (is_array($headerObject['CC']) && count($headerObject['CC']) > 0) { |
|
| 1725 | + $ki = 0; |
|
| 1726 | + foreach ($headerObject['CC'] as $k => $add) |
|
| 1727 | 1727 | { |
| 1728 | 1728 | //error_log(__METHOD__.' ('.__LINE__.') '."-> $k:".array2string($add)); |
| 1729 | - $retValue['header'][$sortOrder[$uid]]['cc_addresses'][$ki] = self::decode_header($add,true); |
|
| 1729 | + $retValue['header'][$sortOrder[$uid]]['cc_addresses'][$ki] = self::decode_header($add, true); |
|
| 1730 | 1730 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki])); |
| 1731 | 1731 | $ki++; |
| 1732 | 1732 | } |
@@ -1735,27 +1735,27 @@ discard block |
||
| 1735 | 1735 | |
| 1736 | 1736 | $count++; |
| 1737 | 1737 | } |
| 1738 | - if (self::$debug||self::$debugTimes) self::logRunTimes($starttime,null,' fetching Headers and stuff for Folder:'.$_folderName,__METHOD__.' ('.__LINE__.') '); |
|
| 1738 | + if (self::$debug || self::$debugTimes) self::logRunTimes($starttime, null, ' fetching Headers and stuff for Folder:'.$_folderName, __METHOD__.' ('.__LINE__.') '); |
|
| 1739 | 1739 | //self::$debug=false; |
| 1740 | 1740 | // sort the messages to the requested displayorder |
| 1741 | - if(is_array($retValue['header'])) { |
|
| 1741 | + if (is_array($retValue['header'])) { |
|
| 1742 | 1742 | $countMessages = $total; |
| 1743 | 1743 | if (isset($_filter['range'])) $countMessages = self::$folderStatusCache[$this->profileID][$_folderName]['messages']; |
| 1744 | 1744 | ksort($retValue['header']); |
| 1745 | 1745 | $retValue['info']['total'] = $total; |
| 1746 | 1746 | //if ($_startMessage>$total) $_startMessage = $total-($count-1); |
| 1747 | 1747 | $retValue['info']['first'] = $_startMessage; |
| 1748 | - $retValue['info']['last'] = $_startMessage + $count - 1 ; |
|
| 1748 | + $retValue['info']['last'] = $_startMessage + $count - 1; |
|
| 1749 | 1749 | return $retValue; |
| 1750 | 1750 | } else { |
| 1751 | 1751 | $retValue = array(); |
| 1752 | 1752 | $retValue['info']['total'] = 0; |
| 1753 | 1753 | $retValue['info']['first'] = 0; |
| 1754 | - $retValue['info']['last'] = 0; |
|
| 1754 | + $retValue['info']['last'] = 0; |
|
| 1755 | 1755 | return $retValue; |
| 1756 | 1756 | } |
| 1757 | 1757 | } else { |
| 1758 | - if ($headersNew == null && empty($_thisUIDOnly)) error_log(__METHOD__." -> retrieval of Message Details to Query $queryString failed: ".print_r($headersNew,TRUE)); |
|
| 1758 | + if ($headersNew == null && empty($_thisUIDOnly)) error_log(__METHOD__." -> retrieval of Message Details to Query $queryString failed: ".print_r($headersNew, TRUE)); |
|
| 1759 | 1759 | $retValue = array(); |
| 1760 | 1760 | $retValue['info']['total'] = 0; |
| 1761 | 1761 | $retValue['info']['first'] = 0; |
@@ -1772,17 +1772,17 @@ discard block |
||
| 1772 | 1772 | */ |
| 1773 | 1773 | static function prepareFlagsArray($headerObject) |
| 1774 | 1774 | { |
| 1775 | - if (is_array($headerObject['FLAGS'])) $headerFlags = array_map('strtolower',$headerObject['FLAGS']); |
|
| 1775 | + if (is_array($headerObject['FLAGS'])) $headerFlags = array_map('strtolower', $headerObject['FLAGS']); |
|
| 1776 | 1776 | $retValue = array(); |
| 1777 | 1777 | $retValue['recent'] = in_array('\\recent', $headerFlags); |
| 1778 | 1778 | $retValue['flagged'] = in_array('\\flagged', $headerFlags); |
| 1779 | - $retValue['answered'] = in_array('\\answered', $headerFlags); |
|
| 1780 | - $retValue['forwarded'] = in_array('$forwarded', $headerFlags); |
|
| 1779 | + $retValue['answered'] = in_array('\\answered', $headerFlags); |
|
| 1780 | + $retValue['forwarded'] = in_array('$forwarded', $headerFlags); |
|
| 1781 | 1781 | $retValue['deleted'] = in_array('\\deleted', $headerFlags); |
| 1782 | - $retValue['seen'] = in_array('\\seen', $headerFlags); |
|
| 1783 | - $retValue['draft'] = in_array('\\draft', $headerFlags); |
|
| 1784 | - $retValue['mdnsent'] = in_array('$mdnsent', $headerFlags)||in_array('mdnsent', $headerFlags); |
|
| 1785 | - $retValue['mdnnotsent'] = in_array('$mdnnotsent', $headerFlags)||in_array('mdnnotsent', $headerFlags); |
|
| 1782 | + $retValue['seen'] = in_array('\\seen', $headerFlags); |
|
| 1783 | + $retValue['draft'] = in_array('\\draft', $headerFlags); |
|
| 1784 | + $retValue['mdnsent'] = in_array('$mdnsent', $headerFlags) || in_array('mdnsent', $headerFlags); |
|
| 1785 | + $retValue['mdnnotsent'] = in_array('$mdnnotsent', $headerFlags) || in_array('mdnnotsent', $headerFlags); |
|
| 1786 | 1786 | $retValue['label1'] = in_array('$label1', $headerFlags); |
| 1787 | 1787 | $retValue['label2'] = in_array('$label2', $headerFlags); |
| 1788 | 1788 | $retValue['label3'] = in_array('$label3', $headerFlags); |
@@ -1806,12 +1806,12 @@ discard block |
||
| 1806 | 1806 | * @param bool $setSession if set to true the session will be populated with the result of the query |
| 1807 | 1807 | * @return mixed bool/array false or array of ids |
| 1808 | 1808 | */ |
| 1809 | - function getSortedList($_folderName, $_sort, &$_reverse, $_filter, &$resultByUid=true, $setSession=true) |
|
| 1809 | + function getSortedList($_folderName, $_sort, &$_reverse, $_filter, &$resultByUid = true, $setSession = true) |
|
| 1810 | 1810 | { |
| 1811 | 1811 | static $cachedFolderStatus = null; |
| 1812 | 1812 | // in the past we needed examineMailbox to figure out if the server with the serverID support keywords |
| 1813 | 1813 | // this information is filled/provided by examineMailbox; but caching within one request seems o.k. |
| 1814 | - if (is_null($cachedFolderStatus) || !isset($cachedFolderStatus[$this->profileID][$_folderName]) ) |
|
| 1814 | + if (is_null($cachedFolderStatus) || !isset($cachedFolderStatus[$this->profileID][$_folderName])) |
|
| 1815 | 1815 | { |
| 1816 | 1816 | $folderStatus = $cachedFolderStatus[$this->profileID][$_folderName] = $this->icServer->examineMailbox($_folderName); |
| 1817 | 1817 | } |
@@ -1823,29 +1823,29 @@ discard block |
||
| 1823 | 1823 | //error_log(__METHOD__.' ('.__LINE__.') '.' Filter:'.array2string($_filter)); |
| 1824 | 1824 | $try2useCache = true; |
| 1825 | 1825 | static $eMailListContainsDeletedMessages = null; |
| 1826 | - if (is_null($eMailListContainsDeletedMessages)) $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 1826 | + if (is_null($eMailListContainsDeletedMessages)) $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 1); |
|
| 1827 | 1827 | // this indicates, that there is no Filter set, and the returned set/subset should not contain DELETED Messages, nor filtered for UNDELETED |
| 1828 | - if ($setSession==true && ((strpos(array2string($_filter), 'UNDELETED') === false && strpos(array2string($_filter), 'DELETED') === false))) |
|
| 1828 | + if ($setSession == true && ((strpos(array2string($_filter), 'UNDELETED') === false && strpos(array2string($_filter), 'DELETED') === false))) |
|
| 1829 | 1829 | { |
| 1830 | 1830 | if (self::$debugTimes) $starttime = microtime(true); |
| 1831 | - if (is_null($eMailListContainsDeletedMessages) || empty($eMailListContainsDeletedMessages[$this->profileID]) || empty($eMailListContainsDeletedMessages[$this->profileID][$_folderName])) $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 1832 | - $five=true; |
|
| 1833 | - $dReverse=1; |
|
| 1834 | - $deletedMessages = $this->getSortedList($_folderName, 0, $dReverse, array('status'=>array('DELETED')),$five,false); |
|
| 1831 | + if (is_null($eMailListContainsDeletedMessages) || empty($eMailListContainsDeletedMessages[$this->profileID]) || empty($eMailListContainsDeletedMessages[$this->profileID][$_folderName])) $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 1); |
|
| 1832 | + $five = true; |
|
| 1833 | + $dReverse = 1; |
|
| 1834 | + $deletedMessages = $this->getSortedList($_folderName, 0, $dReverse, array('status'=>array('DELETED')), $five, false); |
|
| 1835 | 1835 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') Found DeletedMessages:'.array2string($eMailListContainsDeletedMessages)); |
| 1836 | - $eMailListContainsDeletedMessages[$this->profileID][$_folderName] =$deletedMessages['count']; |
|
| 1837 | - Cache::setCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),$eMailListContainsDeletedMessages, 60*60*1); |
|
| 1838 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'setting eMailListContainsDeletedMessages for Profile:'.$this->profileID.' Folder:'.$_folderName.' to '.$eMailListContainsDeletedMessages[$this->profileID][$_folderName],__METHOD__.' ('.__LINE__.') '); //error_log(__METHOD__.' ('.__LINE__.') '.' Profile:'.$this->profileID.' Folder:'.$_folderName.' -> EXISTS/SessStat:'.array2string($folderStatus['MESSAGES']).'/'.self::$folderStatusCache[$this->profileID][$_folderName]['messages'].' ListContDelMsg/SessDeleted:'.$eMailListContainsDeletedMessages[$this->profileID][$_folderName].'/'.self::$folderStatusCache[$this->profileID][$_folderName]['deleted']); |
|
| 1836 | + $eMailListContainsDeletedMessages[$this->profileID][$_folderName] = $deletedMessages['count']; |
|
| 1837 | + Cache::setCache(Cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']), $eMailListContainsDeletedMessages, 60 * 60 * 1); |
|
| 1838 | + if (self::$debugTimes) self::logRunTimes($starttime, null, 'setting eMailListContainsDeletedMessages for Profile:'.$this->profileID.' Folder:'.$_folderName.' to '.$eMailListContainsDeletedMessages[$this->profileID][$_folderName], __METHOD__.' ('.__LINE__.') '); //error_log(__METHOD__.' ('.__LINE__.') '.' Profile:'.$this->profileID.' Folder:'.$_folderName.' -> EXISTS/SessStat:'.array2string($folderStatus['MESSAGES']).'/'.self::$folderStatusCache[$this->profileID][$_folderName]['messages'].' ListContDelMsg/SessDeleted:'.$eMailListContainsDeletedMessages[$this->profileID][$_folderName].'/'.self::$folderStatusCache[$this->profileID][$_folderName]['deleted']); |
|
| 1839 | 1839 | } |
| 1840 | 1840 | $try2useCache = false; |
| 1841 | 1841 | //self::$supportsORinQuery[$this->profileID]=true; |
| 1842 | 1842 | if (is_null(self::$supportsORinQuery) || !isset(self::$supportsORinQuery[$this->profileID])) |
| 1843 | 1843 | { |
| 1844 | - self::$supportsORinQuery = Cache::getCache(Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*10); |
|
| 1845 | - if (!isset(self::$supportsORinQuery[$this->profileID])) self::$supportsORinQuery[$this->profileID]=true; |
|
| 1844 | + self::$supportsORinQuery = Cache::getCache(Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 1845 | + if (!isset(self::$supportsORinQuery[$this->profileID])) self::$supportsORinQuery[$this->profileID] = true; |
|
| 1846 | 1846 | } |
| 1847 | 1847 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_filter).' SupportsOrInQuery:'.self::$supportsORinQuery[$this->profileID]); |
| 1848 | - $filter = $this->createIMAPFilter($_folderName, $_filter,self::$supportsORinQuery[$this->profileID]); |
|
| 1848 | + $filter = $this->createIMAPFilter($_folderName, $_filter, self::$supportsORinQuery[$this->profileID]); |
|
| 1849 | 1849 | if (self::$debug) |
| 1850 | 1850 | { |
| 1851 | 1851 | $query_str = $filter->build(); |
@@ -1853,14 +1853,14 @@ discard block |
||
| 1853 | 1853 | } |
| 1854 | 1854 | //_debug_array($filter); |
| 1855 | 1855 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($filter).'#'.array2string($this->icServer->capability())); |
| 1856 | - if($this->icServer->hasCapability('SORT')) { |
|
| 1856 | + if ($this->icServer->hasCapability('SORT')) { |
|
| 1857 | 1857 | // when using an orQuery and we sort by date. sort seems to fail on certain servers => ZIMBRA with Horde_Imap_Client |
| 1858 | 1858 | // thus we translate the search request from date to Horde_Imap_Client::SORT_SEQUENCE (which should be the same, if |
| 1859 | 1859 | // there is no messing with the dates) |
| 1860 | 1860 | //if (self::$supportsORinQuery[$this->profileID]&&$_sort=='date'&&$_filter['type']=='quick'&&!empty($_filter['string']))$_sort='INTERNALDATE'; |
| 1861 | 1861 | if (self::$debug) error_log(__METHOD__." Mailserver has SORT Capability, SortBy: ".array2string($_sort)." Reverse: $_reverse"); |
| 1862 | 1862 | $sortOrder = $this->_getSortString($_sort, $_reverse); |
| 1863 | - if ($_reverse && in_array(Horde_Imap_Client::SORT_REVERSE,$sortOrder)) $_reverse=false; // as we reversed the result already |
|
| 1863 | + if ($_reverse && in_array(Horde_Imap_Client::SORT_REVERSE, $sortOrder)) $_reverse = false; // as we reversed the result already |
|
| 1864 | 1864 | if (self::$debug) error_log(__METHOD__." Mailserver runs SORT: SortBy:".array2string($_sort)."->".array2string($sortOrder)." Filter: ".array2string($filter)); |
| 1865 | 1865 | try |
| 1866 | 1866 | { |
@@ -1868,24 +1868,24 @@ discard block |
||
| 1868 | 1868 | 'sort' => $sortOrder,)); |
| 1869 | 1869 | // if there is an Error, we assume that the server is not capable of sorting |
| 1870 | 1870 | } |
| 1871 | - catch(\Exception $e) |
|
| 1871 | + catch (\Exception $e) |
|
| 1872 | 1872 | { |
| 1873 | 1873 | //error_log(__METHOD__.'('.__LINE__.'):'.$e->getMessage()); |
| 1874 | 1874 | $resultByUid = false; |
| 1875 | 1875 | $sortOrder = array(Horde_Imap_Client::SORT_SEQUENCE); |
| 1876 | - if ($_reverse) array_unshift($sortOrder,Horde_Imap_Client::SORT_REVERSE); |
|
| 1876 | + if ($_reverse) array_unshift($sortOrder, Horde_Imap_Client::SORT_REVERSE); |
|
| 1877 | 1877 | try |
| 1878 | 1878 | { |
| 1879 | 1879 | $sortResult = $this->icServer->search($_folderName, $filter, array( |
| 1880 | 1880 | 'sort' => $sortOrder)); |
| 1881 | 1881 | } |
| 1882 | - catch(\Exception $e) |
|
| 1882 | + catch (\Exception $e) |
|
| 1883 | 1883 | { |
| 1884 | 1884 | error_log(__METHOD__.'('.__LINE__.'):'.$e->getMessage()); |
| 1885 | 1885 | $sortResult = self::$folderStatusCache[$this->profileID][$_folderName]['sortResult']; |
| 1886 | 1886 | } |
| 1887 | 1887 | } |
| 1888 | - if (self::$debug) error_log(__METHOD__.print_r($sortResult,true)); |
|
| 1888 | + if (self::$debug) error_log(__METHOD__.print_r($sortResult, true)); |
|
| 1889 | 1889 | } else { |
| 1890 | 1890 | if (self::$debug) error_log(__METHOD__." Mailserver has NO SORT Capability"); |
| 1891 | 1891 | //$sortOrder = array(Horde_Imap_Client::SORT_SEQUENCE); |
@@ -1895,12 +1895,12 @@ discard block |
||
| 1895 | 1895 | $sortResult = $this->icServer->search($_folderName, $filter, array()/*array( |
| 1896 | 1896 | 'sort' => $sortOrder)*/); |
| 1897 | 1897 | } |
| 1898 | - catch(\Exception $e) |
|
| 1898 | + catch (\Exception $e) |
|
| 1899 | 1899 | { |
| 1900 | 1900 | //error_log(__METHOD__.'('.__LINE__.'):'.$e->getMessage()); |
| 1901 | 1901 | // possible error OR Query. But Horde gives no detailed Info :-( |
| 1902 | - self::$supportsORinQuery[$this->profileID]=false; |
|
| 1903 | - Cache::setCache(Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),self::$supportsORinQuery,60*60*10); |
|
| 1902 | + self::$supportsORinQuery[$this->profileID] = false; |
|
| 1903 | + Cache::setCache(Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), self::$supportsORinQuery, 60 * 60 * 10); |
|
| 1904 | 1904 | if (self::$debug) error_log(__METHOD__.__LINE__." Mailserver seems to have NO OR Capability for Search:".$sortResult->message); |
| 1905 | 1905 | $filter = $this->createIMAPFilter($_folderName, $_filter, self::$supportsORinQuery[$this->profileID]); |
| 1906 | 1906 | try |
@@ -1908,25 +1908,25 @@ discard block |
||
| 1908 | 1908 | $sortResult = $this->icServer->search($_folderName, $filter, array()/*array( |
| 1909 | 1909 | 'sort' => $sortOrder)*/); |
| 1910 | 1910 | } |
| 1911 | - catch(\Exception $e) |
|
| 1911 | + catch (\Exception $e) |
|
| 1912 | 1912 | { |
| 1913 | 1913 | } |
| 1914 | 1914 | } |
| 1915 | - if(is_array($sortResult['match'])) { |
|
| 1915 | + if (is_array($sortResult['match'])) { |
|
| 1916 | 1916 | // not sure that this is going so succeed as $sortResult['match'] is a hordeObject |
| 1917 | 1917 | sort($sortResult['match'], SORT_NUMERIC); |
| 1918 | 1918 | } |
| 1919 | - if (self::$debug) error_log(__METHOD__." using Filter:".print_r($filter,true)." ->".print_r($sortResult,true)); |
|
| 1919 | + if (self::$debug) error_log(__METHOD__." using Filter:".print_r($filter, true)." ->".print_r($sortResult, true)); |
|
| 1920 | 1920 | } |
| 1921 | 1921 | if ($setSession) |
| 1922 | 1922 | { |
| 1923 | 1923 | self::$folderStatusCache[$this->profileID][$_folderName]['uidValidity'] = $folderStatus['UIDVALIDITY']; |
| 1924 | - self::$folderStatusCache[$this->profileID][$_folderName]['messages'] = $folderStatus['MESSAGES']; |
|
| 1924 | + self::$folderStatusCache[$this->profileID][$_folderName]['messages'] = $folderStatus['MESSAGES']; |
|
| 1925 | 1925 | self::$folderStatusCache[$this->profileID][$_folderName]['deleted'] = $eMailListContainsDeletedMessages[$this->profileID][$_folderName]; |
| 1926 | 1926 | self::$folderStatusCache[$this->profileID][$_folderName]['uidnext'] = $folderStatus['UIDNEXT']; |
| 1927 | - self::$folderStatusCache[$this->profileID][$_folderName]['filter'] = $_filter; |
|
| 1927 | + self::$folderStatusCache[$this->profileID][$_folderName]['filter'] = $_filter; |
|
| 1928 | 1928 | self::$folderStatusCache[$this->profileID][$_folderName]['sortResult'] = $sortResult; |
| 1929 | - self::$folderStatusCache[$this->profileID][$_folderName]['sort'] = $_sort; |
|
| 1929 | + self::$folderStatusCache[$this->profileID][$_folderName]['sort'] = $_sort; |
|
| 1930 | 1930 | } |
| 1931 | 1931 | //error_log(__METHOD__." using Filter:".print_r($filter,true)." ->".print_r($sortResult,true)); |
| 1932 | 1932 | //_debug_array($sortResult['match']->ids); |
@@ -1940,12 +1940,12 @@ discard block |
||
| 1940 | 1940 | * @param bool _reverse wether to add REVERSE to the Sort String or not |
| 1941 | 1941 | * @return the sort sequence for horde search |
| 1942 | 1942 | */ |
| 1943 | - function _getSortString($_sort, $_reverse=false) |
|
| 1943 | + function _getSortString($_sort, $_reverse = false) |
|
| 1944 | 1944 | { |
| 1945 | - $_reverse=false; |
|
| 1945 | + $_reverse = false; |
|
| 1946 | 1946 | if (is_numeric($_sort)) |
| 1947 | 1947 | { |
| 1948 | - switch($_sort) { |
|
| 1948 | + switch ($_sort) { |
|
| 1949 | 1949 | case 2: |
| 1950 | 1950 | $retValue = array(Horde_Imap_Client::SORT_FROM); |
| 1951 | 1951 | break; |
@@ -1967,7 +1967,7 @@ discard block |
||
| 1967 | 1967 | } |
| 1968 | 1968 | else |
| 1969 | 1969 | { |
| 1970 | - switch(strtoupper($_sort)) { |
|
| 1970 | + switch (strtoupper($_sort)) { |
|
| 1971 | 1971 | case 'FROMADDRESS': |
| 1972 | 1972 | $retValue = array(Horde_Imap_Client::SORT_FROM); |
| 1973 | 1973 | break; |
@@ -1993,7 +1993,7 @@ discard block |
||
| 1993 | 1993 | break; |
| 1994 | 1994 | } |
| 1995 | 1995 | } |
| 1996 | - if ($_reverse) array_unshift($retValue,Horde_Imap_Client::SORT_REVERSE); |
|
| 1996 | + if ($_reverse) array_unshift($retValue, Horde_Imap_Client::SORT_REVERSE); |
|
| 1997 | 1997 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.($_reverse?'REVERSE ':'').$_sort.'->'.$retValue); |
| 1998 | 1998 | return $retValue; |
| 1999 | 1999 | } |
@@ -2006,28 +2006,28 @@ discard block |
||
| 2006 | 2006 | * @param boolean $_supportsOrInQuery wether to use the OR Query on QuickSearch |
| 2007 | 2007 | * @return Horde_Imap_Client_Search_Query the IMAP filter |
| 2008 | 2008 | */ |
| 2009 | - function createIMAPFilter($_folder, $_criterias, $_supportsOrInQuery=true) |
|
| 2009 | + function createIMAPFilter($_folder, $_criterias, $_supportsOrInQuery = true) |
|
| 2010 | 2010 | { |
| 2011 | 2011 | $imapFilter = new Horde_Imap_Client_Search_Query(); |
| 2012 | 2012 | $imapFilter->charset('UTF-8'); |
| 2013 | 2013 | |
| 2014 | 2014 | //_debug_array($_criterias); |
| 2015 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' Criterias:'.(!is_array($_criterias)?" none -> returning":array2string($_criterias))); |
|
| 2016 | - if((!is_array($_criterias) || $_criterias['status']=='any') && |
|
| 2015 | + if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' Criterias:'.(!is_array($_criterias) ? " none -> returning" : array2string($_criterias))); |
|
| 2016 | + if ((!is_array($_criterias) || $_criterias['status'] == 'any') && |
|
| 2017 | 2017 | (!isset($_criterias['string']) || empty($_criterias['string'])) && |
| 2018 | - (!isset($_criterias['range'])|| empty($_criterias['range']) || |
|
| 2019 | - ( !empty($_criterias['range'])&& ($_criterias['range']!='BETWEEN' && empty($_criterias['date'])|| |
|
| 2020 | - ($_criterias['range']=='BETWEEN' && empty($_criterias['since'])&& empty($_criterias['before'])))))) |
|
| 2018 | + (!isset($_criterias['range']) || empty($_criterias['range']) || |
|
| 2019 | + (!empty($_criterias['range']) && ($_criterias['range'] != 'BETWEEN' && empty($_criterias['date']) || |
|
| 2020 | + ($_criterias['range'] == 'BETWEEN' && empty($_criterias['since']) && empty($_criterias['before'])))))) |
|
| 2021 | 2021 | { |
| 2022 | 2022 | //error_log(__METHOD__.' ('.__LINE__.') returning early Criterias:'.print_r($_criterias, true)); |
| 2023 | - $imapFilter->flag('DELETED', $set=false); |
|
| 2023 | + $imapFilter->flag('DELETED', $set = false); |
|
| 2024 | 2024 | return $imapFilter; |
| 2025 | 2025 | } |
| 2026 | 2026 | $queryValid = false; |
| 2027 | 2027 | // statusQuery MUST be placed first, as search for subject/mailbody and such is |
| 2028 | 2028 | // depending on charset. flagSearch is not BUT messes the charset if called afterwards |
| 2029 | 2029 | $statusQueryValid = false; |
| 2030 | - foreach((array)$_criterias['status'] as $k => $criteria) { |
|
| 2030 | + foreach ((array)$_criterias['status'] as $k => $criteria) { |
|
| 2031 | 2031 | $imapStatusFilter = new Horde_Imap_Client_Search_Query(); |
| 2032 | 2032 | $imapStatusFilter->charset('UTF-8'); |
| 2033 | 2033 | $criteria = strtoupper($criteria); |
@@ -2037,12 +2037,12 @@ discard block |
||
| 2037 | 2037 | case 'FLAGGED': |
| 2038 | 2038 | case 'RECENT': |
| 2039 | 2039 | case 'SEEN': |
| 2040 | - $imapStatusFilter->flag($criteria, $set=true); |
|
| 2041 | - $queryValid = $statusQueryValid =true; |
|
| 2040 | + $imapStatusFilter->flag($criteria, $set = true); |
|
| 2041 | + $queryValid = $statusQueryValid = true; |
|
| 2042 | 2042 | break; |
| 2043 | 2043 | case 'READ': |
| 2044 | - $imapStatusFilter->flag('SEEN', $set=true); |
|
| 2045 | - $queryValid = $statusQueryValid =true; |
|
| 2044 | + $imapStatusFilter->flag('SEEN', $set = true); |
|
| 2045 | + $queryValid = $statusQueryValid = true; |
|
| 2046 | 2046 | break; |
| 2047 | 2047 | case 'LABEL1': |
| 2048 | 2048 | case 'KEYWORD1': |
@@ -2054,38 +2054,38 @@ discard block |
||
| 2054 | 2054 | case 'KEYWORD4': |
| 2055 | 2055 | case 'LABEL5': |
| 2056 | 2056 | case 'KEYWORD5': |
| 2057 | - $imapStatusFilter->flag(str_ireplace('KEYWORD','$LABEL',$criteria), $set=true); |
|
| 2058 | - $queryValid = $statusQueryValid =true; |
|
| 2057 | + $imapStatusFilter->flag(str_ireplace('KEYWORD', '$LABEL', $criteria), $set = true); |
|
| 2058 | + $queryValid = $statusQueryValid = true; |
|
| 2059 | 2059 | break; |
| 2060 | 2060 | case 'NEW': |
| 2061 | - $imapStatusFilter->flag('RECENT', $set=true); |
|
| 2062 | - $imapStatusFilter->flag('SEEN', $set=false); |
|
| 2063 | - $queryValid = $statusQueryValid =true; |
|
| 2061 | + $imapStatusFilter->flag('RECENT', $set = true); |
|
| 2062 | + $imapStatusFilter->flag('SEEN', $set = false); |
|
| 2063 | + $queryValid = $statusQueryValid = true; |
|
| 2064 | 2064 | break; |
| 2065 | 2065 | case 'OLD': |
| 2066 | - $imapStatusFilter->flag('RECENT', $set=false); |
|
| 2067 | - $queryValid = $statusQueryValid =true; |
|
| 2066 | + $imapStatusFilter->flag('RECENT', $set = false); |
|
| 2067 | + $queryValid = $statusQueryValid = true; |
|
| 2068 | 2068 | break; |
| 2069 | 2069 | // operate only on system flags |
| 2070 | 2070 | // $systemflags = array( |
| 2071 | 2071 | // 'ANSWERED', 'DELETED', 'DRAFT', 'FLAGGED', 'RECENT', 'SEEN' |
| 2072 | 2072 | // ); |
| 2073 | 2073 | case 'UNANSWERED': |
| 2074 | - $imapStatusFilter->flag('ANSWERED', $set=false); |
|
| 2075 | - $queryValid = $statusQueryValid =true; |
|
| 2074 | + $imapStatusFilter->flag('ANSWERED', $set = false); |
|
| 2075 | + $queryValid = $statusQueryValid = true; |
|
| 2076 | 2076 | break; |
| 2077 | 2077 | case 'UNDELETED': |
| 2078 | - $imapFilter->flag('DELETED', $set=false); |
|
| 2078 | + $imapFilter->flag('DELETED', $set = false); |
|
| 2079 | 2079 | $queryValid = true; |
| 2080 | 2080 | break; |
| 2081 | 2081 | case 'UNFLAGGED': |
| 2082 | - $imapStatusFilter->flag('FLAGGED', $set=false); |
|
| 2083 | - $queryValid = $statusQueryValid =true; |
|
| 2082 | + $imapStatusFilter->flag('FLAGGED', $set = false); |
|
| 2083 | + $queryValid = $statusQueryValid = true; |
|
| 2084 | 2084 | break; |
| 2085 | 2085 | case 'UNREAD': |
| 2086 | 2086 | case 'UNSEEN': |
| 2087 | - $imapStatusFilter->flag('SEEN', $set=false); |
|
| 2088 | - $queryValid = $statusQueryValid =true; |
|
| 2087 | + $imapStatusFilter->flag('SEEN', $set = false); |
|
| 2088 | + $queryValid = $statusQueryValid = true; |
|
| 2089 | 2089 | break; |
| 2090 | 2090 | case 'UNLABEL1': |
| 2091 | 2091 | case 'UNKEYWORD1': |
@@ -2097,8 +2097,8 @@ discard block |
||
| 2097 | 2097 | case 'UNKEYWORD4': |
| 2098 | 2098 | case 'UNLABEL5': |
| 2099 | 2099 | case 'UNKEYWORD5': |
| 2100 | - $imapStatusFilter->flag(str_ireplace(array('UNKEYWORD','UNLABEL'),'$LABEL',$criteria), $set=false); |
|
| 2101 | - $queryValid = $statusQueryValid =true; |
|
| 2100 | + $imapStatusFilter->flag(str_ireplace(array('UNKEYWORD', 'UNLABEL'), '$LABEL', $criteria), $set = false); |
|
| 2101 | + $queryValid = $statusQueryValid = true; |
|
| 2102 | 2102 | break; |
| 2103 | 2103 | default: |
| 2104 | 2104 | $statusQueryValid = false; |
@@ -2114,20 +2114,20 @@ discard block |
||
| 2114 | 2114 | $imapSearchFilter = new Horde_Imap_Client_Search_Query(); |
| 2115 | 2115 | $imapSearchFilter->charset('UTF-8'); |
| 2116 | 2116 | |
| 2117 | - if(!empty($_criterias['string'])) { |
|
| 2117 | + if (!empty($_criterias['string'])) { |
|
| 2118 | 2118 | $criteria = strtoupper($_criterias['type']); |
| 2119 | 2119 | switch ($criteria) { |
| 2120 | 2120 | case 'BYDATE': |
| 2121 | 2121 | case 'QUICK': |
| 2122 | 2122 | case 'QUICKWITHCC': |
| 2123 | - $imapSearchFilter->headerText('SUBJECT', $_criterias['string'], $not=false); |
|
| 2123 | + $imapSearchFilter->headerText('SUBJECT', $_criterias['string'], $not = false); |
|
| 2124 | 2124 | //$imapSearchFilter->charset('UTF-8'); |
| 2125 | 2125 | $imapFilter2 = new Horde_Imap_Client_Search_Query(); |
| 2126 | 2126 | $imapFilter2->charset('UTF-8'); |
| 2127 | - if($this->isSentFolder($_folder)) { |
|
| 2128 | - $imapFilter2->headerText('TO', $_criterias['string'], $not=false); |
|
| 2127 | + if ($this->isSentFolder($_folder)) { |
|
| 2128 | + $imapFilter2->headerText('TO', $_criterias['string'], $not = false); |
|
| 2129 | 2129 | } else { |
| 2130 | - $imapFilter2->headerText('FROM', $_criterias['string'], $not=false); |
|
| 2130 | + $imapFilter2->headerText('FROM', $_criterias['string'], $not = false); |
|
| 2131 | 2131 | } |
| 2132 | 2132 | if ($_supportsOrInQuery) |
| 2133 | 2133 | { |
@@ -2137,31 +2137,31 @@ discard block |
||
| 2137 | 2137 | { |
| 2138 | 2138 | $imapSearchFilter->andSearch($imapFilter2); |
| 2139 | 2139 | } |
| 2140 | - if ($_supportsOrInQuery && $criteria=='QUICKWITHCC') |
|
| 2140 | + if ($_supportsOrInQuery && $criteria == 'QUICKWITHCC') |
|
| 2141 | 2141 | { |
| 2142 | 2142 | $imapFilter3 = new Horde_Imap_Client_Search_Query(); |
| 2143 | 2143 | $imapFilter3->charset('UTF-8'); |
| 2144 | - $imapFilter3->headerText('CC', $_criterias['string'], $not=false); |
|
| 2144 | + $imapFilter3->headerText('CC', $_criterias['string'], $not = false); |
|
| 2145 | 2145 | $imapSearchFilter->orSearch($imapFilter3); |
| 2146 | 2146 | } |
| 2147 | 2147 | $queryValid = true; |
| 2148 | 2148 | break; |
| 2149 | 2149 | case 'LARGER': |
| 2150 | 2150 | case 'SMALLER': |
| 2151 | - if (strlen(trim($_criterias['string'])) != strlen((float) trim($_criterias['string']))) |
|
| 2151 | + if (strlen(trim($_criterias['string'])) != strlen((float)trim($_criterias['string']))) |
|
| 2152 | 2152 | { |
| 2153 | 2153 | //examine string to evaluate size |
| 2154 | - $unit = strtoupper(trim(substr(trim($_criterias['string']),strlen((float) trim($_criterias['string']))))); |
|
| 2155 | - $multipleBy = array('KB'=>1024,'K'=>1024, |
|
| 2156 | - 'MB'=>1024*1000,'M'=>1024*1000, |
|
| 2157 | - 'GB'=>1024*1000*1000,'G'=>1024*1000*1000, |
|
| 2158 | - 'TB'=>1024*1000*1000*1000,'T'=>1024*1000*1000*1000); |
|
| 2159 | - $numberinBytes=(float)$_criterias['string']; |
|
| 2160 | - if (isset($multipleBy[$unit])) $numberinBytes=(float)$_criterias['string']*$multipleBy[$unit]; |
|
| 2154 | + $unit = strtoupper(trim(substr(trim($_criterias['string']), strlen((float)trim($_criterias['string']))))); |
|
| 2155 | + $multipleBy = array('KB'=>1024, 'K'=>1024, |
|
| 2156 | + 'MB'=>1024 * 1000, 'M'=>1024 * 1000, |
|
| 2157 | + 'GB'=>1024 * 1000 * 1000, 'G'=>1024 * 1000 * 1000, |
|
| 2158 | + 'TB'=>1024 * 1000 * 1000 * 1000, 'T'=>1024 * 1000 * 1000 * 1000); |
|
| 2159 | + $numberinBytes = (float)$_criterias['string']; |
|
| 2160 | + if (isset($multipleBy[$unit])) $numberinBytes = (float)$_criterias['string'] * $multipleBy[$unit]; |
|
| 2161 | 2161 | //error_log(__METHOD__.__LINE__.'#'.$_criterias['string'].'->'.(float)$_criterias['string'].'#'.$unit.' ='.$numberinBytes); |
| 2162 | - $_criterias['string']=$numberinBytes; |
|
| 2162 | + $_criterias['string'] = $numberinBytes; |
|
| 2163 | 2163 | } |
| 2164 | - $imapSearchFilter->size( $_criterias['string'], ($criteria=='LARGER'?true:false), $not=false); |
|
| 2164 | + $imapSearchFilter->size($_criterias['string'], ($criteria == 'LARGER' ? true : false), $not = false); |
|
| 2165 | 2165 | //$imapSearchFilter->charset('UTF-8'); |
| 2166 | 2166 | $queryValid = true; |
| 2167 | 2167 | break; |
@@ -2170,31 +2170,31 @@ discard block |
||
| 2170 | 2170 | case 'CC': |
| 2171 | 2171 | case 'BCC': |
| 2172 | 2172 | case 'SUBJECT': |
| 2173 | - $imapSearchFilter->headerText($criteria, $_criterias['string'], $not=false); |
|
| 2173 | + $imapSearchFilter->headerText($criteria, $_criterias['string'], $not = false); |
|
| 2174 | 2174 | //$imapSearchFilter->charset('UTF-8'); |
| 2175 | 2175 | $queryValid = true; |
| 2176 | 2176 | break; |
| 2177 | 2177 | case 'BODY': |
| 2178 | 2178 | case 'TEXT': |
| 2179 | - $imapSearchFilter->text($_criterias['string'],($criteria=='BODY'?true:false), $not=false); |
|
| 2179 | + $imapSearchFilter->text($_criterias['string'], ($criteria == 'BODY' ? true : false), $not = false); |
|
| 2180 | 2180 | //$imapSearchFilter->charset('UTF-8'); |
| 2181 | 2181 | $queryValid = true; |
| 2182 | 2182 | break; |
| 2183 | 2183 | case 'SINCE': |
| 2184 | - $imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_SINCE, $header=true, $not=false); |
|
| 2184 | + $imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_SINCE, $header = true, $not = false); |
|
| 2185 | 2185 | $queryValid = true; |
| 2186 | 2186 | break; |
| 2187 | 2187 | case 'BEFORE': |
| 2188 | - $imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header=true, $not=false); |
|
| 2188 | + $imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header = true, $not = false); |
|
| 2189 | 2189 | $queryValid = true; |
| 2190 | 2190 | break; |
| 2191 | 2191 | case 'ON': |
| 2192 | - $imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_ON, $header=true, $not=false); |
|
| 2192 | + $imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_ON, $header = true, $not = false); |
|
| 2193 | 2193 | $queryValid = true; |
| 2194 | 2194 | break; |
| 2195 | 2195 | } |
| 2196 | 2196 | } |
| 2197 | - if ($statusQueryValid && !$queryValid) $queryValid=true; |
|
| 2197 | + if ($statusQueryValid && !$queryValid) $queryValid = true; |
|
| 2198 | 2198 | if ($queryValid) $imapFilter->andSearch($imapSearchFilter); |
| 2199 | 2199 | |
| 2200 | 2200 | if (isset($_criterias['range']) && !empty($_criterias['range'])) |
@@ -2203,12 +2203,12 @@ discard block |
||
| 2203 | 2203 | $imapRangeFilter = new Horde_Imap_Client_Search_Query(); |
| 2204 | 2204 | $imapRangeFilter->charset('UTF-8'); |
| 2205 | 2205 | $criteria = strtoupper($_criterias['range']); |
| 2206 | - if ($_criterias['range'] == "BETWEEN" && isset($_criterias['since']) && isset($_criterias['before']) && $_criterias['since']==$_criterias['before']) |
|
| 2206 | + if ($_criterias['range'] == "BETWEEN" && isset($_criterias['since']) && isset($_criterias['before']) && $_criterias['since'] == $_criterias['before']) |
|
| 2207 | 2207 | { |
| 2208 | - $_criterias['date']=$_criterias['since']; |
|
| 2208 | + $_criterias['date'] = $_criterias['since']; |
|
| 2209 | 2209 | unset($_criterias['since']); |
| 2210 | 2210 | unset($_criterias['before']); |
| 2211 | - $criteria=$_criterias['range']='ON'; |
|
| 2211 | + $criteria = $_criterias['range'] = 'ON'; |
|
| 2212 | 2212 | } |
| 2213 | 2213 | switch ($criteria) { |
| 2214 | 2214 | case 'BETWEEN': |
@@ -2216,7 +2216,7 @@ discard block |
||
| 2216 | 2216 | //enddate |
| 2217 | 2217 | if ($_criterias['since']) |
| 2218 | 2218 | { |
| 2219 | - $imapRangeFilter->dateSearch(new DateTime($_criterias['since']), Horde_Imap_Client_Search_Query::DATE_SINCE, $header=true, $not=false); |
|
| 2219 | + $imapRangeFilter->dateSearch(new DateTime($_criterias['since']), Horde_Imap_Client_Search_Query::DATE_SINCE, $header = true, $not = false); |
|
| 2220 | 2220 | $rangeValid = true; |
| 2221 | 2221 | } |
| 2222 | 2222 | //startdate |
@@ -2225,28 +2225,28 @@ discard block |
||
| 2225 | 2225 | $imapRangeFilter2 = new Horde_Imap_Client_Search_Query(); |
| 2226 | 2226 | $imapRangeFilter2->charset('UTF-8'); |
| 2227 | 2227 | //our before (startdate) is inklusive, as we work with "d-M-Y", we must add a day |
| 2228 | - $_criterias['before'] = date("d-M-Y",DateTime::to($_criterias['before'],'ts')+(3600*24)); |
|
| 2229 | - $imapRangeFilter2->dateSearch(new DateTime($_criterias['before']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header=true, $not=false); |
|
| 2228 | + $_criterias['before'] = date("d-M-Y", DateTime::to($_criterias['before'], 'ts') + (3600 * 24)); |
|
| 2229 | + $imapRangeFilter2->dateSearch(new DateTime($_criterias['before']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header = true, $not = false); |
|
| 2230 | 2230 | $imapRangeFilter->andSearch($imapRangeFilter2); |
| 2231 | 2231 | $rangeValid = true; |
| 2232 | 2232 | } |
| 2233 | 2233 | break; |
| 2234 | 2234 | case 'SINCE'://enddate |
| 2235 | - $imapRangeFilter->dateSearch(new DateTime(($_criterias['since']?$_criterias['since']:$_criterias['date'])), Horde_Imap_Client_Search_Query::DATE_SINCE, $header=true, $not=false); |
|
| 2235 | + $imapRangeFilter->dateSearch(new DateTime(($_criterias['since'] ? $_criterias['since'] : $_criterias['date'])), Horde_Imap_Client_Search_Query::DATE_SINCE, $header = true, $not = false); |
|
| 2236 | 2236 | $rangeValid = true; |
| 2237 | 2237 | break; |
| 2238 | 2238 | case 'BEFORE'://startdate |
| 2239 | 2239 | //our before (startdate) is inklusive, as we work with "d-M-Y", we must add a day |
| 2240 | - $_criterias['before'] = date("d-M-Y",DateTime::to(($_criterias['before']?$_criterias['before']:$_criterias['date']),'ts')+(3600*24)); |
|
| 2241 | - $imapRangeFilter->dateSearch(new DateTime($_criterias['before']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header=true, $not=false); |
|
| 2240 | + $_criterias['before'] = date("d-M-Y", DateTime::to(($_criterias['before'] ? $_criterias['before'] : $_criterias['date']), 'ts') + (3600 * 24)); |
|
| 2241 | + $imapRangeFilter->dateSearch(new DateTime($_criterias['before']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header = true, $not = false); |
|
| 2242 | 2242 | $rangeValid = true; |
| 2243 | 2243 | break; |
| 2244 | 2244 | case 'ON': |
| 2245 | - $imapRangeFilter->dateSearch(new DateTime($_criterias['date']), Horde_Imap_Client_Search_Query::DATE_ON, $header=true, $not=false); |
|
| 2245 | + $imapRangeFilter->dateSearch(new DateTime($_criterias['date']), Horde_Imap_Client_Search_Query::DATE_ON, $header = true, $not = false); |
|
| 2246 | 2246 | $rangeValid = true; |
| 2247 | 2247 | break; |
| 2248 | 2248 | } |
| 2249 | - if ($rangeValid && !$queryValid) $queryValid=true; |
|
| 2249 | + if ($rangeValid && !$queryValid) $queryValid = true; |
|
| 2250 | 2250 | if ($rangeValid) $imapFilter->andSearch($imapRangeFilter); |
| 2251 | 2251 | } |
| 2252 | 2252 | if (self::$debug) |
@@ -2255,8 +2255,8 @@ discard block |
||
| 2255 | 2255 | $query_str = $imapFilter->build(); |
| 2256 | 2256 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$query_str['query'].' created by Criterias:'.(!is_array($_criterias)?" none -> returning":array2string($_criterias))); |
| 2257 | 2257 | } |
| 2258 | - if($queryValid==false) { |
|
| 2259 | - $imapFilter->flag('DELETED', $set=false); |
|
| 2258 | + if ($queryValid == false) { |
|
| 2259 | + $imapFilter->flag('DELETED', $set = false); |
|
| 2260 | 2260 | return $imapFilter; |
| 2261 | 2261 | } else { |
| 2262 | 2262 | return $imapFilter; |
@@ -2270,11 +2270,11 @@ discard block |
||
| 2270 | 2270 | * @param mixed/boolean $_tryIDNConversion (true/false AND FORCE): try IDN Conversion on domainparts of emailADRESSES |
| 2271 | 2271 | * @return mixed - based on the input type |
| 2272 | 2272 | */ |
| 2273 | - static function decode_header($_string, $_tryIDNConversion=false) |
|
| 2273 | + static function decode_header($_string, $_tryIDNConversion = false) |
|
| 2274 | 2274 | { |
| 2275 | 2275 | if (is_array($_string)) |
| 2276 | 2276 | { |
| 2277 | - foreach($_string as $k=>$v) |
|
| 2277 | + foreach ($_string as $k=>$v) |
|
| 2278 | 2278 | { |
| 2279 | 2279 | $_string[$k] = self::decode_header($v, $_tryIDNConversion); |
| 2280 | 2280 | } |
@@ -2282,18 +2282,18 @@ discard block |
||
| 2282 | 2282 | } |
| 2283 | 2283 | else |
| 2284 | 2284 | { |
| 2285 | - $_string = Mail\Html::decodeMailHeader($_string,self::$displayCharset); |
|
| 2285 | + $_string = Mail\Html::decodeMailHeader($_string, self::$displayCharset); |
|
| 2286 | 2286 | $test = @json_encode($_string); |
| 2287 | 2287 | //error_log(__METHOD__.__LINE__.' ->'.strlen($singleBodyPart['body']).' Error:'.json_last_error().'<- BodyPart:#'.$test.'#'); |
| 2288 | - if (($test=="null" || $test === false || is_null($test)) && strlen($_string)>0) |
|
| 2288 | + if (($test == "null" || $test === false || is_null($test)) && strlen($_string) > 0) |
|
| 2289 | 2289 | { |
| 2290 | 2290 | // try to fix broken utf8 |
| 2291 | 2291 | $x = utf8_encode($_string); |
| 2292 | 2292 | $test = @json_encode($x); |
| 2293 | - if (($test=="null" || $test === false || is_null($test)) && strlen($_string)>0) |
|
| 2293 | + if (($test == "null" || $test === false || is_null($test)) && strlen($_string) > 0) |
|
| 2294 | 2294 | { |
| 2295 | 2295 | // this should not be needed, unless something fails with charset detection/ wrong charset passed |
| 2296 | - $_string = (function_exists('mb_convert_encoding')?mb_convert_encoding($_string,'UTF-8','UTF-8'):(function_exists('iconv')?@iconv("UTF-8","UTF-8//IGNORE",$_string):$_string)); |
|
| 2296 | + $_string = (function_exists('mb_convert_encoding') ? mb_convert_encoding($_string, 'UTF-8', 'UTF-8') : (function_exists('iconv') ? @iconv("UTF-8", "UTF-8//IGNORE", $_string) : $_string)); |
|
| 2297 | 2297 | } |
| 2298 | 2298 | else |
| 2299 | 2299 | { |
@@ -2301,7 +2301,7 @@ discard block |
||
| 2301 | 2301 | } |
| 2302 | 2302 | } |
| 2303 | 2303 | |
| 2304 | - if ($_tryIDNConversion===true && stripos($_string,'@')!==false) |
|
| 2304 | + if ($_tryIDNConversion === true && stripos($_string, '@') !== false) |
|
| 2305 | 2305 | { |
| 2306 | 2306 | $rfcAddr = self::parseAddressList($_string); |
| 2307 | 2307 | $stringA = array(); |
@@ -2313,11 +2313,11 @@ discard block |
||
| 2313 | 2313 | $stringA = array(); |
| 2314 | 2314 | break; // skip idna conversion if we encounter an error here |
| 2315 | 2315 | } |
| 2316 | - $stringA[] = imap_rfc822_write_address($_rfcAddr->mailbox,Horde_Idna::decode($_rfcAddr->host),$_rfcAddr->personal); |
|
| 2316 | + $stringA[] = imap_rfc822_write_address($_rfcAddr->mailbox, Horde_Idna::decode($_rfcAddr->host), $_rfcAddr->personal); |
|
| 2317 | 2317 | } |
| 2318 | - if (!empty($stringA)) $_string = implode(',',$stringA); |
|
| 2318 | + if (!empty($stringA)) $_string = implode(',', $stringA); |
|
| 2319 | 2319 | } |
| 2320 | - if ($_tryIDNConversion==='FORCE') |
|
| 2320 | + if ($_tryIDNConversion === 'FORCE') |
|
| 2321 | 2321 | { |
| 2322 | 2322 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.$_string.'='.Horde_Idna::decode($_string)); |
| 2323 | 2323 | $_string = Horde_Idna::decode($_string); |
@@ -2333,17 +2333,17 @@ discard block |
||
| 2333 | 2333 | * @param boolean $decode try decoding |
| 2334 | 2334 | * @return mixed - based on the input type |
| 2335 | 2335 | */ |
| 2336 | - function decode_subject($_string,$decode=true) |
|
| 2336 | + function decode_subject($_string, $decode = true) |
|
| 2337 | 2337 | { |
| 2338 | 2338 | #$string = $_string; |
| 2339 | - if($_string=='NIL') |
|
| 2339 | + if ($_string == 'NIL') |
|
| 2340 | 2340 | { |
| 2341 | 2341 | return 'No Subject'; |
| 2342 | 2342 | } |
| 2343 | 2343 | if ($decode) $_string = self::decode_header($_string); |
| 2344 | 2344 | // make sure its utf-8 |
| 2345 | 2345 | $test = @json_encode($_string); |
| 2346 | - if (($test=="null" || $test === false || is_null($test)) && strlen($_string)>0) |
|
| 2346 | + if (($test == "null" || $test === false || is_null($test)) && strlen($_string) > 0) |
|
| 2347 | 2347 | { |
| 2348 | 2348 | $_string = utf8_encode($_string); |
| 2349 | 2349 | } |
@@ -2395,18 +2395,18 @@ discard block |
||
| 2395 | 2395 | function createFolder($_parent, $_folderName, &$_error) |
| 2396 | 2396 | { |
| 2397 | 2397 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."->"."$_parent, $_folderName called from:".function_backtrace()); |
| 2398 | - $parent = $_parent;//$this->_encodeFolderName($_parent); |
|
| 2399 | - $folderName = $_folderName;//$this->_encodeFolderName($_folderName); |
|
| 2398 | + $parent = $_parent; //$this->_encodeFolderName($_parent); |
|
| 2399 | + $folderName = $_folderName; //$this->_encodeFolderName($_folderName); |
|
| 2400 | 2400 | |
| 2401 | - if(empty($parent)) { |
|
| 2401 | + if (empty($parent)) { |
|
| 2402 | 2402 | $newFolderName = $folderName; |
| 2403 | 2403 | } else { |
| 2404 | 2404 | $HierarchyDelimiter = $this->getHierarchyDelimiter(); |
| 2405 | - $newFolderName = $parent . $HierarchyDelimiter . $folderName; |
|
| 2405 | + $newFolderName = $parent.$HierarchyDelimiter.$folderName; |
|
| 2406 | 2406 | } |
| 2407 | 2407 | if (empty($newFolderName)) return false; |
| 2408 | 2408 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.'->'.$newFolderName); |
| 2409 | - if ($this->folderExists($newFolderName,true)) |
|
| 2409 | + if ($this->folderExists($newFolderName, true)) |
|
| 2410 | 2410 | { |
| 2411 | 2411 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '." Folder $newFolderName already exists."); |
| 2412 | 2412 | return $newFolderName; |
@@ -2423,7 +2423,7 @@ discard block |
||
| 2423 | 2423 | } |
| 2424 | 2424 | catch (\Exception $e) |
| 2425 | 2425 | { |
| 2426 | - $_error = lang('Could not create Folder %1 Reason: %2',$newFolderName,$e->getMessage()); |
|
| 2426 | + $_error = lang('Could not create Folder %1 Reason: %2', $newFolderName, $e->getMessage()); |
|
| 2427 | 2427 | error_log(__METHOD__.' ('.__LINE__.') '.' create Folder '.$newFolderName.'->'.$e->getMessage().' ('.$e->details.') Namespace:'.array2string($this->icServer->getNameSpaces()).function_backtrace()); |
| 2428 | 2428 | return false; |
| 2429 | 2429 | } |
@@ -2452,15 +2452,15 @@ discard block |
||
| 2452 | 2452 | */ |
| 2453 | 2453 | function renameFolder($_oldFolderName, $_parent, $_folderName) |
| 2454 | 2454 | { |
| 2455 | - $oldFolderName = $_oldFolderName;//$this->_encodeFolderName($_oldFolderName); |
|
| 2456 | - $parent = $_parent;//$this->_encodeFolderName($_parent); |
|
| 2457 | - $folderName = $_folderName;//$this->_encodeFolderName($_folderName); |
|
| 2455 | + $oldFolderName = $_oldFolderName; //$this->_encodeFolderName($_oldFolderName); |
|
| 2456 | + $parent = $_parent; //$this->_encodeFolderName($_parent); |
|
| 2457 | + $folderName = $_folderName; //$this->_encodeFolderName($_folderName); |
|
| 2458 | 2458 | |
| 2459 | - if(empty($parent)) { |
|
| 2459 | + if (empty($parent)) { |
|
| 2460 | 2460 | $newFolderName = $folderName; |
| 2461 | 2461 | } else { |
| 2462 | 2462 | $HierarchyDelimiter = $this->getHierarchyDelimiter(); |
| 2463 | - $newFolderName = $parent . $HierarchyDelimiter . $folderName; |
|
| 2463 | + $newFolderName = $parent.$HierarchyDelimiter.$folderName; |
|
| 2464 | 2464 | } |
| 2465 | 2465 | if (self::$debug) error_log("create folder: $newFolderName"); |
| 2466 | 2466 | try |
@@ -2469,10 +2469,10 @@ discard block |
||
| 2469 | 2469 | } |
| 2470 | 2470 | catch (\Exception $e) |
| 2471 | 2471 | { |
| 2472 | - throw new Exception(__METHOD__." failed for $oldFolderName (rename to: $newFolderName) with error:".$e->getMessage());; |
|
| 2472 | + throw new Exception(__METHOD__." failed for $oldFolderName (rename to: $newFolderName) with error:".$e->getMessage()); ; |
|
| 2473 | 2473 | } |
| 2474 | 2474 | // clear FolderExistsInfoCache |
| 2475 | - Cache::setCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderInfo,60*60*5); |
|
| 2475 | + Cache::setCache(Cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']), $folderInfo, 60 * 60 * 5); |
|
| 2476 | 2476 | |
| 2477 | 2477 | return $newFolderName; |
| 2478 | 2478 | |
@@ -2491,15 +2491,15 @@ discard block |
||
| 2491 | 2491 | //$folderName = $this->_encodeFolderName($_folderName); |
| 2492 | 2492 | try |
| 2493 | 2493 | { |
| 2494 | - $this->icServer->subscribeMailbox($_folderName,false); |
|
| 2494 | + $this->icServer->subscribeMailbox($_folderName, false); |
|
| 2495 | 2495 | $this->icServer->deleteMailbox($_folderName); |
| 2496 | 2496 | } |
| 2497 | 2497 | catch (\Exception $e) |
| 2498 | 2498 | { |
| 2499 | - throw new Exception("Deleting Folder $_folderName failed! Error:".$e->getMessage());; |
|
| 2499 | + throw new Exception("Deleting Folder $_folderName failed! Error:".$e->getMessage()); ; |
|
| 2500 | 2500 | } |
| 2501 | 2501 | // clear FolderExistsInfoCache |
| 2502 | - Cache::setCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderInfo,60*60*5); |
|
| 2502 | + Cache::setCache(Cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']), $folderInfo, 60 * 60 * 5); |
|
| 2503 | 2503 | |
| 2504 | 2504 | return true; |
| 2505 | 2505 | } |
@@ -2534,10 +2534,10 @@ discard block |
||
| 2534 | 2534 | * |
| 2535 | 2535 | * @return array with folder objects. eg.: INBOX => {inbox object} |
| 2536 | 2536 | */ |
| 2537 | - function getFolderObjects($_subscribedOnly=false, $_getCounters=false, $_alwaysGetDefaultFolders=false,$_useCacheIfPossible=true) |
|
| 2537 | + function getFolderObjects($_subscribedOnly = false, $_getCounters = false, $_alwaysGetDefaultFolders = false, $_useCacheIfPossible = true) |
|
| 2538 | 2538 | { |
| 2539 | 2539 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' ServerID:'.$this->icServer->ImapServerId.", subscribedOnly:$_subscribedOnly, getCounters:$_getCounters, alwaysGetDefaultFolders:$_alwaysGetDefaultFolders, _useCacheIfPossible:$_useCacheIfPossible"); |
| 2540 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 2540 | + if (self::$debugTimes) $starttime = microtime(true); |
|
| 2541 | 2541 | static $folders2return; |
| 2542 | 2542 | //$_subscribedOnly=false; |
| 2543 | 2543 | // always use static on single request if info is available; |
@@ -2545,42 +2545,42 @@ discard block |
||
| 2545 | 2545 | // set $_useCacheIfPossible to false ! |
| 2546 | 2546 | if ($_useCacheIfPossible && isset($folders2return[$this->icServer->ImapServerId]) && !empty($folders2return[$this->icServer->ImapServerId])) |
| 2547 | 2547 | { |
| 2548 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'using static',__METHOD__.' ('.__LINE__.') '); |
|
| 2548 | + if (self::$debugTimes) self::logRunTimes($starttime, null, 'using static', __METHOD__.' ('.__LINE__.') '); |
|
| 2549 | 2549 | return $folders2return[$this->icServer->ImapServerId]; |
| 2550 | 2550 | } |
| 2551 | 2551 | |
| 2552 | - if ($_subscribedOnly && $_getCounters===false) |
|
| 2552 | + if ($_subscribedOnly && $_getCounters === false) |
|
| 2553 | 2553 | { |
| 2554 | - if (is_null($folders2return)) $folders2return = Cache::getCache(Cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 2554 | + if (is_null($folders2return)) $folders2return = Cache::getCache(Cache::INSTANCE, 'email', 'folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 1); |
|
| 2555 | 2555 | if ($_useCacheIfPossible && isset($folders2return[$this->icServer->ImapServerId]) && !empty($folders2return[$this->icServer->ImapServerId])) |
| 2556 | 2556 | { |
| 2557 | 2557 | //error_log(__METHOD__.' ('.__LINE__.') '.' using Cached folderObjects'.array2string($folders2return[$this->icServer->ImapServerId])); |
| 2558 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'from Cache',__METHOD__.' ('.__LINE__.') '); |
|
| 2558 | + if (self::$debugTimes) self::logRunTimes($starttime, null, 'from Cache', __METHOD__.' ('.__LINE__.') '); |
|
| 2559 | 2559 | return $folders2return[$this->icServer->ImapServerId]; |
| 2560 | 2560 | } |
| 2561 | 2561 | } |
| 2562 | 2562 | // use $folderBasicInfo for holding attributes and other basic folderinfo $folderBasicInfo[$this->icServer->ImapServerId] |
| 2563 | 2563 | static $folderBasicInfo; |
| 2564 | - if (is_null($folderBasicInfo)||!isset($folderBasicInfo[$this->icServer->ImapServerId])) $folderBasicInfo = Cache::getCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 2564 | + if (is_null($folderBasicInfo) || !isset($folderBasicInfo[$this->icServer->ImapServerId])) $folderBasicInfo = Cache::getCache(Cache::INSTANCE, 'email', 'folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 1); |
|
| 2565 | 2565 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string(array_keys($folderBasicInfo[$this->icServer->ImapServerId]))); |
| 2566 | 2566 | |
| 2567 | 2567 | $delimiter = $this->getHierarchyDelimiter(); |
| 2568 | 2568 | |
| 2569 | 2569 | $inboxData = new \stdClass; |
| 2570 | - $inboxData->name = 'INBOX'; |
|
| 2570 | + $inboxData->name = 'INBOX'; |
|
| 2571 | 2571 | $inboxData->folderName = 'INBOX'; |
| 2572 | - $inboxData->displayName = lang('INBOX'); |
|
| 2572 | + $inboxData->displayName = lang('INBOX'); |
|
| 2573 | 2573 | $inboxData->delimiter = $delimiter; |
| 2574 | - $inboxData->shortFolderName = 'INBOX'; |
|
| 2575 | - $inboxData->shortDisplayName = lang('INBOX'); |
|
| 2574 | + $inboxData->shortFolderName = 'INBOX'; |
|
| 2575 | + $inboxData->shortDisplayName = lang('INBOX'); |
|
| 2576 | 2576 | $inboxData->subscribed = true; |
| 2577 | - if($_getCounters == true) { |
|
| 2577 | + if ($_getCounters == true) { |
|
| 2578 | 2578 | $inboxData->counter = $this->getMailBoxCounters('INBOX'); |
| 2579 | 2579 | } |
| 2580 | 2580 | // force unsubscribed by preference showAllFoldersInFolderPane |
| 2581 | 2581 | if ($_subscribedOnly == true && |
| 2582 | 2582 | isset($this->mailPreferences['showAllFoldersInFolderPane']) && |
| 2583 | - $this->mailPreferences['showAllFoldersInFolderPane']==1) |
|
| 2583 | + $this->mailPreferences['showAllFoldersInFolderPane'] == 1) |
|
| 2584 | 2584 | { |
| 2585 | 2585 | $_subscribedOnly = false; |
| 2586 | 2586 | } |
@@ -2593,12 +2593,12 @@ discard block |
||
| 2593 | 2593 | //error_log(__METHOD__.__LINE__.array2string($nameSpace)); |
| 2594 | 2594 | if (is_array($nameSpace)) |
| 2595 | 2595 | { |
| 2596 | - foreach($nameSpace as $k => $singleNameSpace) { |
|
| 2596 | + foreach ($nameSpace as $k => $singleNameSpace) { |
|
| 2597 | 2597 | $type = $singleNameSpace['type']; |
| 2598 | 2598 | // the following line (assumption that for the same namespace the delimiter should be equal) may be wrong |
| 2599 | - $foldersNameSpace[$type]['delimiter'] = $singleNameSpace['delimiter']; |
|
| 2599 | + $foldersNameSpace[$type]['delimiter'] = $singleNameSpace['delimiter']; |
|
| 2600 | 2600 | |
| 2601 | - if(is_array($singleNameSpace)&&$fetchedAllInOneGo==false) { |
|
| 2601 | + if (is_array($singleNameSpace) && $fetchedAllInOneGo == false) { |
|
| 2602 | 2602 | // fetch and sort the subscribed folders |
| 2603 | 2603 | // we alway fetch the subscribed, as this provides the only way to tell |
| 2604 | 2604 | // if a folder is subscribed or not |
@@ -2606,22 +2606,22 @@ discard block |
||
| 2606 | 2606 | { |
| 2607 | 2607 | try |
| 2608 | 2608 | { |
| 2609 | - $subscribedMailboxes = $this->icServer->listSubscribedMailboxes('',0,true); |
|
| 2609 | + $subscribedMailboxes = $this->icServer->listSubscribedMailboxes('', 0, true); |
|
| 2610 | 2610 | if (!empty($subscribedMailboxes)) |
| 2611 | 2611 | { |
| 2612 | 2612 | $fetchedAllInOneGo = true; |
| 2613 | 2613 | } |
| 2614 | 2614 | else |
| 2615 | 2615 | { |
| 2616 | - $subscribedMailboxes = $this->icServer->listSubscribedMailboxes($singleNameSpace['prefix'],0,true); |
|
| 2616 | + $subscribedMailboxes = $this->icServer->listSubscribedMailboxes($singleNameSpace['prefix'], 0, true); |
|
| 2617 | 2617 | } |
| 2618 | 2618 | } |
| 2619 | - catch(Exception $e) |
|
| 2619 | + catch (Exception $e) |
|
| 2620 | 2620 | { |
| 2621 | 2621 | continue; |
| 2622 | 2622 | } |
| 2623 | 2623 | //echo "subscribedMailboxes";_debug_array($subscribedMailboxes); |
| 2624 | - $subscribedFoldersPerNS = (!empty($subscribedMailboxes)?array_keys($subscribedMailboxes):array()); |
|
| 2624 | + $subscribedFoldersPerNS = (!empty($subscribedMailboxes) ? array_keys($subscribedMailboxes) : array()); |
|
| 2625 | 2625 | //if (is_array($foldersNameSpace[$type]['subscribed'])) sort($foldersNameSpace[$type]['subscribed']); |
| 2626 | 2626 | //_debug_array($foldersNameSpace); |
| 2627 | 2627 | //error_log(__METHOD__.__LINE__.array2string($singleNameSpace).':#:'.array2string($subscribedFoldersPerNS)); |
@@ -2631,18 +2631,18 @@ discard block |
||
| 2631 | 2631 | foreach ($subscribedMailboxes as $k => $finfo) |
| 2632 | 2632 | { |
| 2633 | 2633 | //error_log(__METHOD__.__LINE__.$k.':#:'.array2string($finfo)); |
| 2634 | - $subscribedFoldersForCache[$this->icServer->ImapServerId][$k]= |
|
| 2635 | - $folderBasicInfo[$this->icServer->ImapServerId][$k]=array( |
|
| 2634 | + $subscribedFoldersForCache[$this->icServer->ImapServerId][$k] = |
|
| 2635 | + $folderBasicInfo[$this->icServer->ImapServerId][$k] = array( |
|
| 2636 | 2636 | 'MAILBOX'=>$finfo['MAILBOX'], |
| 2637 | 2637 | 'ATTRIBUTES'=>$finfo['ATTRIBUTES'], |
| 2638 | - 'delimiter'=>$finfo['delimiter'],//lowercase for some reason??? |
|
| 2639 | - 'SUBSCRIBED'=>$finfo['SUBSCRIBED'],//seeded by getMailboxes |
|
| 2638 | + 'delimiter'=>$finfo['delimiter'], //lowercase for some reason??? |
|
| 2639 | + 'SUBSCRIBED'=>$finfo['SUBSCRIBED'], //seeded by getMailboxes |
|
| 2640 | 2640 | ); |
| 2641 | - if (empty($foldersNameSpace[$type]['subscribed']) || !in_array($k,$foldersNameSpace[$type]['subscribed'])) |
|
| 2641 | + if (empty($foldersNameSpace[$type]['subscribed']) || !in_array($k, $foldersNameSpace[$type]['subscribed'])) |
|
| 2642 | 2642 | { |
| 2643 | 2643 | $foldersNameSpace[$type]['subscribed'][] = $k; |
| 2644 | 2644 | } |
| 2645 | - if (empty($foldersNameSpace[$type]['all']) || !in_array($k,$foldersNameSpace[$type]['all'])) |
|
| 2645 | + if (empty($foldersNameSpace[$type]['all']) || !in_array($k, $foldersNameSpace[$type]['all'])) |
|
| 2646 | 2646 | { |
| 2647 | 2647 | $foldersNameSpace[$type]['all'][] = $k; |
| 2648 | 2648 | } |
@@ -2665,7 +2665,7 @@ discard block |
||
| 2665 | 2665 | // that may produce problems, when encountering recursions probably |
| 2666 | 2666 | // horde is handling that, so we do not; keep that in mind! |
| 2667 | 2667 | //$allMailboxesExt = $this->icServer->getMailboxes($singleNameSpace['prefix'],2,true); |
| 2668 | - $allMailboxesExt = $this->icServer->getMailboxes($singleNameSpace['prefix'],0,true); |
|
| 2668 | + $allMailboxesExt = $this->icServer->getMailboxes($singleNameSpace['prefix'], 0, true); |
|
| 2669 | 2669 | } |
| 2670 | 2670 | catch (\Exception $e) |
| 2671 | 2671 | { |
@@ -2683,26 +2683,26 @@ discard block |
||
| 2683 | 2683 | foreach ($allMailboxesExt as $mbx) { |
| 2684 | 2684 | if (!isset($folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']])) |
| 2685 | 2685 | { |
| 2686 | - $folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']]=array( |
|
| 2686 | + $folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']] = array( |
|
| 2687 | 2687 | 'MAILBOX'=>$mbx['MAILBOX'], |
| 2688 | 2688 | 'ATTRIBUTES'=>$mbx['ATTRIBUTES'], |
| 2689 | - 'delimiter'=>$mbx['delimiter'],//lowercase for some reason??? |
|
| 2690 | - 'SUBSCRIBED'=>$mbx['SUBSCRIBED'],//seeded by getMailboxes |
|
| 2689 | + 'delimiter'=>$mbx['delimiter'], //lowercase for some reason??? |
|
| 2690 | + 'SUBSCRIBED'=>$mbx['SUBSCRIBED'], //seeded by getMailboxes |
|
| 2691 | 2691 | ); |
| 2692 | 2692 | if ($mbx['SUBSCRIBED'] && !isset($subscribedFoldersForCache[$this->icServer->ImapServerId][$mbx['MAILBOX']])) |
| 2693 | 2693 | { |
| 2694 | 2694 | $subscribedFoldersForCache[$this->icServer->ImapServerId][$mbx['MAILBOX']] = $folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']]; |
| 2695 | 2695 | } |
| 2696 | 2696 | } |
| 2697 | - if ($mbx['SUBSCRIBED'] && (empty($foldersNameSpace[$type]['subscribed']) || !in_array($mbx['MAILBOX'],$foldersNameSpace[$type]['subscribed']))) |
|
| 2697 | + if ($mbx['SUBSCRIBED'] && (empty($foldersNameSpace[$type]['subscribed']) || !in_array($mbx['MAILBOX'], $foldersNameSpace[$type]['subscribed']))) |
|
| 2698 | 2698 | { |
| 2699 | 2699 | $foldersNameSpace[$type]['subscribed'][] = $mbx['MAILBOX']; |
| 2700 | 2700 | } |
| 2701 | 2701 | //echo __METHOD__;_debug_array($mbx); |
| 2702 | 2702 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mbx)); |
| 2703 | - if (isset($allMailBoxesExtSorted[$mbx['MAILBOX']])|| |
|
| 2704 | - isset($allMailBoxesExtSorted[$mbx['MAILBOX'].$foldersNameSpace[$type]['delimiter']])|| |
|
| 2705 | - (substr($mbx['MAILBOX'],-1)==$foldersNameSpace[$type]['delimiter'] && isset($allMailBoxesExtSorted[substr($mbx['MAILBOX'],0,-1)])) |
|
| 2703 | + if (isset($allMailBoxesExtSorted[$mbx['MAILBOX']]) || |
|
| 2704 | + isset($allMailBoxesExtSorted[$mbx['MAILBOX'].$foldersNameSpace[$type]['delimiter']]) || |
|
| 2705 | + (substr($mbx['MAILBOX'], -1) == $foldersNameSpace[$type]['delimiter'] && isset($allMailBoxesExtSorted[substr($mbx['MAILBOX'], 0, -1)])) |
|
| 2706 | 2706 | ) continue; |
| 2707 | 2707 | |
| 2708 | 2708 | //echo '#'.$mbx['MAILBOX'].':'.array2string($mbx)."#<br>"; |
@@ -2712,7 +2712,7 @@ discard block |
||
| 2712 | 2712 | //_debug_array(array_keys($allMailBoxesExtSorted)); |
| 2713 | 2713 | $allMailboxes = array(); |
| 2714 | 2714 | foreach ((array)$allMailBoxesExtSorted as $mbx) { |
| 2715 | - if (!in_array($mbx['MAILBOX'],$allMailboxes)) $allMailboxes[] = $mbx['MAILBOX']; |
|
| 2715 | + if (!in_array($mbx['MAILBOX'], $allMailboxes)) $allMailboxes[] = $mbx['MAILBOX']; |
|
| 2716 | 2716 | //echo "Result:";_debug_array($allMailboxes); |
| 2717 | 2717 | } |
| 2718 | 2718 | $foldersNameSpace[$type]['all'] = $allMailboxes; |
@@ -2721,57 +2721,57 @@ discard block |
||
| 2721 | 2721 | } |
| 2722 | 2722 | } |
| 2723 | 2723 | //subscribed folders may be used in getFolderStatus |
| 2724 | - Cache::setCache(Cache::INSTANCE,'email','subscribedFolders'.trim($GLOBALS['egw_info']['user']['account_id']),$subscribedFoldersForCache,$expiration=60*60*1); |
|
| 2724 | + Cache::setCache(Cache::INSTANCE, 'email', 'subscribedFolders'.trim($GLOBALS['egw_info']['user']['account_id']), $subscribedFoldersForCache, $expiration = 60 * 60 * 1); |
|
| 2725 | 2725 | //echo "<br>FolderNameSpace To Process:";_debug_array($foldersNameSpace); |
| 2726 | 2726 | $autoFolderObjects = $folders = array(); |
| 2727 | 2727 | $autofolder_exists = array(); |
| 2728 | - foreach( array('personal', 'others', 'shared') as $type) { |
|
| 2729 | - if(isset($foldersNameSpace[$type])) { |
|
| 2730 | - if($_subscribedOnly) { |
|
| 2731 | - if( !empty($foldersNameSpace[$type]['subscribed']) ) $listOfFolders = $foldersNameSpace[$type]['subscribed']; |
|
| 2728 | + foreach (array('personal', 'others', 'shared') as $type) { |
|
| 2729 | + if (isset($foldersNameSpace[$type])) { |
|
| 2730 | + if ($_subscribedOnly) { |
|
| 2731 | + if (!empty($foldersNameSpace[$type]['subscribed'])) $listOfFolders = $foldersNameSpace[$type]['subscribed']; |
|
| 2732 | 2732 | } else { |
| 2733 | - if( !empty($foldersNameSpace[$type]['all'])) $listOfFolders = $foldersNameSpace[$type]['all']; |
|
| 2733 | + if (!empty($foldersNameSpace[$type]['all'])) $listOfFolders = $foldersNameSpace[$type]['all']; |
|
| 2734 | 2734 | } |
| 2735 | - foreach((array)$listOfFolders as $folderName) { |
|
| 2735 | + foreach ((array)$listOfFolders as $folderName) { |
|
| 2736 | 2736 | //echo "<br>FolderToCheck:$folderName<br>"; |
| 2737 | 2737 | //error_log(__METHOD__.__LINE__.'#Delimiter:'.$delimiter.':#'.$folderName); |
| 2738 | - if ($_subscribedOnly && empty($foldersNameSpace[$type]['all'])) continue;//when subscribedonly, we fetch all folders in one go. |
|
| 2739 | - if($_subscribedOnly && !(in_array($folderName, $foldersNameSpace[$type]['all'])||in_array($folderName.$foldersNameSpace[$type]['delimiter'], $foldersNameSpace[$type]['all']))) { |
|
| 2738 | + if ($_subscribedOnly && empty($foldersNameSpace[$type]['all'])) continue; //when subscribedonly, we fetch all folders in one go. |
|
| 2739 | + if ($_subscribedOnly && !(in_array($folderName, $foldersNameSpace[$type]['all']) || in_array($folderName.$foldersNameSpace[$type]['delimiter'], $foldersNameSpace[$type]['all']))) { |
|
| 2740 | 2740 | #echo "$folderName failed to be here <br>"; |
| 2741 | 2741 | continue; |
| 2742 | 2742 | } |
| 2743 | 2743 | if (isset($folders[$folderName])) continue; |
| 2744 | 2744 | if (isset($autoFolderObjects[$folderName])) continue; |
| 2745 | - if (empty($delimiter)||$delimiter != $foldersNameSpace[$type]['delimiter']) $delimiter = $foldersNameSpace[$type]['delimiter']; |
|
| 2745 | + if (empty($delimiter) || $delimiter != $foldersNameSpace[$type]['delimiter']) $delimiter = $foldersNameSpace[$type]['delimiter']; |
|
| 2746 | 2746 | $folderParts = explode($delimiter, $folderName); |
| 2747 | 2747 | $shortName = array_pop($folderParts); |
| 2748 | 2748 | |
| 2749 | 2749 | $folderObject = new \stdClass; |
| 2750 | - $folderObject->delimiter = $delimiter; |
|
| 2751 | - $folderObject->folderName = $folderName; |
|
| 2752 | - $folderObject->shortFolderName = $shortName; |
|
| 2753 | - if(!$_subscribedOnly) { |
|
| 2750 | + $folderObject->delimiter = $delimiter; |
|
| 2751 | + $folderObject->folderName = $folderName; |
|
| 2752 | + $folderObject->shortFolderName = $shortName; |
|
| 2753 | + if (!$_subscribedOnly) { |
|
| 2754 | 2754 | #echo $folderName."->".$type."<br>"; |
| 2755 | 2755 | #_debug_array($foldersNameSpace[$type]['subscribed']); |
| 2756 | 2756 | $folderObject->subscribed = in_array($folderName, (array)$foldersNameSpace[$type]['subscribed']); |
| 2757 | 2757 | } |
| 2758 | 2758 | |
| 2759 | - if($_getCounters == true) { |
|
| 2759 | + if ($_getCounters == true) { |
|
| 2760 | 2760 | //error_log(__METHOD__.' ('.__LINE__.') '.' getCounter forFolder:'.$folderName); |
| 2761 | 2761 | $folderObject->counter = $this->getMailBoxCounters($folderName); |
| 2762 | 2762 | } |
| 2763 | - if(strtoupper($folderName) == 'INBOX') { |
|
| 2763 | + if (strtoupper($folderName) == 'INBOX') { |
|
| 2764 | 2764 | $folderName = 'INBOX'; |
| 2765 | - $folderObject->folderName = 'INBOX'; |
|
| 2766 | - $folderObject->shortFolderName = 'INBOX'; |
|
| 2767 | - $folderObject->displayName = lang('INBOX'); |
|
| 2765 | + $folderObject->folderName = 'INBOX'; |
|
| 2766 | + $folderObject->shortFolderName = 'INBOX'; |
|
| 2767 | + $folderObject->displayName = lang('INBOX'); |
|
| 2768 | 2768 | $folderObject->shortDisplayName = lang('INBOX'); |
| 2769 | - $folderObject->subscribed = true; |
|
| 2769 | + $folderObject->subscribed = true; |
|
| 2770 | 2770 | // translate the automatic Folders (Sent, Drafts, ...) like the INBOX |
| 2771 | - } elseif (in_array($shortName,self::$autoFolders)) { |
|
| 2772 | - $tmpfolderparts = explode($delimiter,$folderObject->folderName); |
|
| 2771 | + } elseif (in_array($shortName, self::$autoFolders)) { |
|
| 2772 | + $tmpfolderparts = explode($delimiter, $folderObject->folderName); |
|
| 2773 | 2773 | array_pop($tmpfolderparts); |
| 2774 | - $folderObject->displayName = implode($delimiter,$tmpfolderparts).$delimiter.lang($shortName); |
|
| 2774 | + $folderObject->displayName = implode($delimiter, $tmpfolderparts).$delimiter.lang($shortName); |
|
| 2775 | 2775 | $folderObject->shortDisplayName = lang($shortName); |
| 2776 | 2776 | unset($tmpfolderparts); |
| 2777 | 2777 | } else { |
@@ -2779,13 +2779,13 @@ discard block |
||
| 2779 | 2779 | $folderObject->shortDisplayName = $shortName; |
| 2780 | 2780 | } |
| 2781 | 2781 | //$folderName = $folderName; |
| 2782 | - if (in_array($shortName,self::$autoFolders)&&self::searchValueInFolderObjects($shortName,$autoFolderObjects)===false) { |
|
| 2782 | + if (in_array($shortName, self::$autoFolders) && self::searchValueInFolderObjects($shortName, $autoFolderObjects) === false) { |
|
| 2783 | 2783 | $autoFolderObjects[$folderName] = $folderObject; |
| 2784 | 2784 | } else { |
| 2785 | 2785 | $folders[$folderName] = $folderObject; |
| 2786 | 2786 | } |
| 2787 | 2787 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$folderObject->folderName); |
| 2788 | - if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders (); |
|
| 2788 | + if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders(); |
|
| 2789 | 2789 | if (isset(self::$specialUseFolders[$folderName])) |
| 2790 | 2790 | { |
| 2791 | 2791 | $autofolder_exists[$folderName] = self::$specialUseFolders[$folderName]; |
@@ -2794,27 +2794,27 @@ discard block |
||
| 2794 | 2794 | } |
| 2795 | 2795 | } |
| 2796 | 2796 | if (is_array($autoFolderObjects) && !empty($autoFolderObjects)) { |
| 2797 | - uasort($autoFolderObjects,array($this,"sortByAutoFolderPos")); |
|
| 2797 | + uasort($autoFolderObjects, array($this, "sortByAutoFolderPos")); |
|
| 2798 | 2798 | } |
| 2799 | 2799 | // check if some standard folders are missing and need to be created |
| 2800 | 2800 | if (count($autofolder_exists) < count(self::$autoFolders) && $this->check_create_autofolders($autofolder_exists)) |
| 2801 | 2801 | { |
| 2802 | 2802 | // if new folders have been created, re-read folders ignoring the cache |
| 2803 | - return $this->getFolderObjects($_subscribedOnly, $_getCounters, $_alwaysGetDefaultFolders, false); // false = do NOT use cache |
|
| 2803 | + return $this->getFolderObjects($_subscribedOnly, $_getCounters, $_alwaysGetDefaultFolders, false); // false = do NOT use cache |
|
| 2804 | 2804 | } |
| 2805 | - if (is_array($folders)) uasort($folders,array($this,"sortByDisplayName")); |
|
| 2805 | + if (is_array($folders)) uasort($folders, array($this, "sortByDisplayName")); |
|
| 2806 | 2806 | //$folders2return = array_merge($autoFolderObjects,$folders); |
| 2807 | 2807 | //_debug_array($folders2return); #exit; |
| 2808 | - $folders2return[$this->icServer->ImapServerId] = array_merge((array)$inboxFolderObject,(array)$autoFolderObjects,(array)$folders); |
|
| 2809 | - if (($_subscribedOnly && $_getCounters===false) || |
|
| 2810 | - ($_subscribedOnly == false && $_getCounters===false && |
|
| 2808 | + $folders2return[$this->icServer->ImapServerId] = array_merge((array)$inboxFolderObject, (array)$autoFolderObjects, (array)$folders); |
|
| 2809 | + if (($_subscribedOnly && $_getCounters === false) || |
|
| 2810 | + ($_subscribedOnly == false && $_getCounters === false && |
|
| 2811 | 2811 | isset($this->mailPreferences['showAllFoldersInFolderPane']) && |
| 2812 | - $this->mailPreferences['showAllFoldersInFolderPane']==1)) |
|
| 2812 | + $this->mailPreferences['showAllFoldersInFolderPane'] == 1)) |
|
| 2813 | 2813 | { |
| 2814 | - Cache::setCache(Cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),$folders2return,$expiration=60*60*1); |
|
| 2814 | + Cache::setCache(Cache::INSTANCE, 'email', 'folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']), $folders2return, $expiration = 60 * 60 * 1); |
|
| 2815 | 2815 | } |
| 2816 | - Cache::setCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderBasicInfo,$expiration=60*60*1); |
|
| 2817 | - if (self::$debugTimes) self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') '); |
|
| 2816 | + Cache::setCache(Cache::INSTANCE, 'email', 'folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']), $folderBasicInfo, $expiration = 60 * 60 * 1); |
|
| 2817 | + if (self::$debugTimes) self::logRunTimes($starttime, null, function_backtrace(), __METHOD__.' ('.__LINE__.') '); |
|
| 2818 | 2818 | return $folders2return[$this->icServer->ImapServerId]; |
| 2819 | 2819 | } |
| 2820 | 2820 | |
@@ -2835,21 +2835,21 @@ discard block |
||
| 2835 | 2835 | * |
| 2836 | 2836 | * @return array arrays of folders |
| 2837 | 2837 | */ |
| 2838 | - function getFolderArrays ($_nodePath = null, $_onlyTopLevel = false, $_search= 2, $_subscribedOnly = false, $_getCounter = false) |
|
| 2838 | + function getFolderArrays($_nodePath = null, $_onlyTopLevel = false, $_search = 2, $_subscribedOnly = false, $_getCounter = false) |
|
| 2839 | 2839 | { |
| 2840 | 2840 | // delimiter |
| 2841 | 2841 | $delimiter = $this->getHierarchyDelimiter(); |
| 2842 | 2842 | |
| 2843 | - $folders = $nameSpace = array(); |
|
| 2843 | + $folders = $nameSpace = array(); |
|
| 2844 | 2844 | $nameSpaceTmp = $this->_getNameSpaces(); |
| 2845 | - foreach($nameSpaceTmp as $k => $singleNameSpace) { |
|
| 2846 | - $nameSpace[$singleNameSpace['type']]=$singleNameSpace; |
|
| 2845 | + foreach ($nameSpaceTmp as $k => $singleNameSpace) { |
|
| 2846 | + $nameSpace[$singleNameSpace['type']] = $singleNameSpace; |
|
| 2847 | 2847 | } |
| 2848 | 2848 | unset($nameSpaceTmp); |
| 2849 | 2849 | |
| 2850 | 2850 | //error_log(__METHOD__.__LINE__.array2string($nameSpace)); |
| 2851 | 2851 | // Get special use folders |
| 2852 | - if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders (); // Set self::$specialUseFolders |
|
| 2852 | + if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders(); // Set self::$specialUseFolders |
|
| 2853 | 2853 | // topLevelQueries generally ignore the $_search param. Except for Config::examineNamespace |
| 2854 | 2854 | if ($_onlyTopLevel) // top level leaves |
| 2855 | 2855 | { |
@@ -2860,20 +2860,20 @@ discard block |
||
| 2860 | 2860 | if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail'); |
| 2861 | 2861 | if (self::$mailConfig['examineNamespace']) |
| 2862 | 2862 | { |
| 2863 | - $prefixes=array(); |
|
| 2863 | + $prefixes = array(); |
|
| 2864 | 2864 | if (is_array($nameSpace)) |
| 2865 | 2865 | { |
| 2866 | - foreach($nameSpace as $k => $singleNameSpace) { |
|
| 2866 | + foreach ($nameSpace as $k => $singleNameSpace) { |
|
| 2867 | 2867 | $type = $singleNameSpace['type']; |
| 2868 | 2868 | |
| 2869 | - if(is_array($singleNameSpace) && $singleNameSpace['prefix']){ |
|
| 2869 | + if (is_array($singleNameSpace) && $singleNameSpace['prefix']) { |
|
| 2870 | 2870 | $prefixes[$type] = $singleNameSpace['prefix']; |
| 2871 | 2871 | //regard extra care for nameSpacequeries when configured AND respect $_search |
| 2872 | - $result = $this->icServer->getMailboxes($singleNameSpace['prefix'], $_search==0?0:2, true); |
|
| 2872 | + $result = $this->icServer->getMailboxes($singleNameSpace['prefix'], $_search == 0 ? 0 : 2, true); |
|
| 2873 | 2873 | if (is_array($result)) |
| 2874 | 2874 | { |
| 2875 | 2875 | ksort($result); |
| 2876 | - $topFolders = array_merge($topFolders,$result); |
|
| 2876 | + $topFolders = array_merge($topFolders, $result); |
|
| 2877 | 2877 | } |
| 2878 | 2878 | } |
| 2879 | 2879 | } |
@@ -2882,7 +2882,7 @@ discard block |
||
| 2882 | 2882 | |
| 2883 | 2883 | $autofolders = array(); |
| 2884 | 2884 | |
| 2885 | - foreach(self::$specialUseFolders as $path => $folder) |
|
| 2885 | + foreach (self::$specialUseFolders as $path => $folder) |
|
| 2886 | 2886 | { |
| 2887 | 2887 | if ($this->folderExists($path)) |
| 2888 | 2888 | { |
@@ -2890,9 +2890,9 @@ discard block |
||
| 2890 | 2890 | } |
| 2891 | 2891 | } |
| 2892 | 2892 | // Check if the special use folders are there, otherwise try to create them |
| 2893 | - if (count($autofolders) < count(self::$autoFolders) && $this->check_create_autofolders ($autofolders)) |
|
| 2893 | + if (count($autofolders) < count(self::$autoFolders) && $this->check_create_autofolders($autofolders)) |
|
| 2894 | 2894 | { |
| 2895 | - return $this->getFolderArrays ($_nodePath, $_onlyTopLevel, $_search, $_subscribedOnly, $_getCounter); |
|
| 2895 | + return $this->getFolderArrays($_nodePath, $_onlyTopLevel, $_search, $_subscribedOnly, $_getCounter); |
|
| 2896 | 2896 | } |
| 2897 | 2897 | |
| 2898 | 2898 | // now process topFolders for next level |
@@ -2900,13 +2900,13 @@ discard block |
||
| 2900 | 2900 | { |
| 2901 | 2901 | $pattern = "/\\".$delimiter."/"; |
| 2902 | 2902 | $reference = preg_replace($pattern, '', $node['MAILBOX']); |
| 2903 | - if(!empty($prefixes)) |
|
| 2903 | + if (!empty($prefixes)) |
|
| 2904 | 2904 | { |
| 2905 | 2905 | $reference = ''; |
| 2906 | - $tmpArray = explode($delimiter,$node['MAILBOX']); |
|
| 2907 | - foreach($tmpArray as $p) |
|
| 2906 | + $tmpArray = explode($delimiter, $node['MAILBOX']); |
|
| 2907 | + foreach ($tmpArray as $p) |
|
| 2908 | 2908 | { |
| 2909 | - $reference = empty($reference)?$p:$reference.$delimiter.$p; |
|
| 2909 | + $reference = empty($reference) ? $p : $reference.$delimiter.$p; |
|
| 2910 | 2910 | } |
| 2911 | 2911 | } |
| 2912 | 2912 | $mainFolder = $subFolders = array(); |
@@ -2942,19 +2942,19 @@ discard block |
||
| 2942 | 2942 | $nFolders [$path] = $folder; |
| 2943 | 2943 | } |
| 2944 | 2944 | } |
| 2945 | - if (is_array($aFolders)) uasort ($aFolders, array($this,'sortByAutofolder')); |
|
| 2945 | + if (is_array($aFolders)) uasort($aFolders, array($this, 'sortByAutofolder')); |
|
| 2946 | 2946 | //ksort($aFolders); |
| 2947 | 2947 | |
| 2948 | 2948 | // Sort none auto folders base on mailbox name |
| 2949 | - uasort($nFolders,array($this,'sortByMailbox')); |
|
| 2949 | + uasort($nFolders, array($this, 'sortByMailbox')); |
|
| 2950 | 2950 | |
| 2951 | - $subFolders = array_merge($aFolders,$nFolders); |
|
| 2951 | + $subFolders = array_merge($aFolders, $nFolders); |
|
| 2952 | 2952 | } |
| 2953 | 2953 | else |
| 2954 | 2954 | { |
| 2955 | 2955 | if (is_array($subFolders)) ksort($subFolders); |
| 2956 | 2956 | } |
| 2957 | - $folders = array_merge($folders,(array)$mainFolder, (array)$subFolders); |
|
| 2957 | + $folders = array_merge($folders, (array)$mainFolder, (array)$subFolders); |
|
| 2958 | 2958 | } |
| 2959 | 2959 | } |
| 2960 | 2960 | elseif ($_nodePath) // single node |
@@ -2981,9 +2981,9 @@ discard block |
||
| 2981 | 2981 | $folders = $this->icServer->getMailboxes($path, $_search, true); |
| 2982 | 2982 | } |
| 2983 | 2983 | |
| 2984 | - uasort($folders,array($this,'sortByMailbox'));//ksort($folders); |
|
| 2984 | + uasort($folders, array($this, 'sortByMailbox')); //ksort($folders); |
|
| 2985 | 2985 | } |
| 2986 | - elseif(!$_nodePath) // all |
|
| 2986 | + elseif (!$_nodePath) // all |
|
| 2987 | 2987 | { |
| 2988 | 2988 | if ($_subscribedOnly) |
| 2989 | 2989 | { |
@@ -2999,101 +2999,101 @@ discard block |
||
| 2999 | 2999 | { |
| 3000 | 3000 | // SORTING FOLDERS |
| 3001 | 3001 | //self::$debugTimes=true; |
| 3002 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 3002 | + if (self::$debugTimes) $starttime = microtime(true); |
|
| 3003 | 3003 | // Merge of all auto folders and specialusefolders |
| 3004 | 3004 | $autoFoldersTmp = array_unique((array_merge(self::$autoFolders, array_values(self::$specialUseFolders)))); |
| 3005 | - uasort($folders,array($this,'sortByMailbox'));//ksort($folders); |
|
| 3005 | + uasort($folders, array($this, 'sortByMailbox')); //ksort($folders); |
|
| 3006 | 3006 | $tmpFolders = $folders; |
| 3007 | - $inboxFolderObject=$inboxSubFolderObjects=$autoFolderObjects=$typeFolderObject=$mySpecialUseFolders=array(); |
|
| 3008 | - $googleMailFolderObject=$googleAutoFolderObjects=$googleSubFolderObjects=array(); |
|
| 3009 | - $isGoogleMail=false; |
|
| 3010 | - foreach($autoFoldersTmp as $afk=>$aF) |
|
| 3007 | + $inboxFolderObject = $inboxSubFolderObjects = $autoFolderObjects = $typeFolderObject = $mySpecialUseFolders = array(); |
|
| 3008 | + $googleMailFolderObject = $googleAutoFolderObjects = $googleSubFolderObjects = array(); |
|
| 3009 | + $isGoogleMail = false; |
|
| 3010 | + foreach ($autoFoldersTmp as $afk=>$aF) |
|
| 3011 | 3011 | { |
| 3012 | - if (!isset($mySpecialUseFolders[$aF]) && $aF) $mySpecialUseFolders[$aF]=$this->getFolderByType($aF,false); |
|
| 3012 | + if (!isset($mySpecialUseFolders[$aF]) && $aF) $mySpecialUseFolders[$aF] = $this->getFolderByType($aF, false); |
|
| 3013 | 3013 | //error_log($afk.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 3014 | 3014 | } |
| 3015 | 3015 | //error_log(array2string($mySpecialUseFolders)); |
| 3016 | 3016 | foreach ($tmpFolders as $k => $f) { |
| 3017 | - $sorted=false; |
|
| 3018 | - if (strtoupper(substr($k,0,5))=='INBOX') { |
|
| 3019 | - if (strtoupper($k)=='INBOX') { |
|
| 3017 | + $sorted = false; |
|
| 3018 | + if (strtoupper(substr($k, 0, 5)) == 'INBOX') { |
|
| 3019 | + if (strtoupper($k) == 'INBOX') { |
|
| 3020 | 3020 | //error_log(__METHOD__.__LINE__.':'.strtoupper(substr($k,0,5)).':'.$k); |
| 3021 | - $inboxFolderObject[$k]=$f; |
|
| 3021 | + $inboxFolderObject[$k] = $f; |
|
| 3022 | 3022 | unset($folders[$k]); |
| 3023 | - $sorted=true; |
|
| 3023 | + $sorted = true; |
|
| 3024 | 3024 | } else { |
| 3025 | - $isAutoFolder=false; |
|
| 3026 | - foreach($autoFoldersTmp as $afk=>$aF) |
|
| 3025 | + $isAutoFolder = false; |
|
| 3026 | + foreach ($autoFoldersTmp as $afk=>$aF) |
|
| 3027 | 3027 | { |
| 3028 | 3028 | //error_log(__METHOD__.__LINE__.$k.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 3029 | - if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
|
| 3030 | - ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter || //k may be child of an autofolder |
|
| 3031 | - stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder |
|
| 3029 | + if ($aF && strlen($mySpecialUseFolders[$aF]) && /*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
|
| 3030 | + ($mySpecialUseFolders[$aF] == $k || substr($k, 0, strlen($mySpecialUseFolders[$aF].$delimiter)) == $mySpecialUseFolders[$aF].$delimiter || //k may be child of an autofolder |
|
| 3031 | + stristr($mySpecialUseFolders[$aF], $k.$delimiter) !== false)) // k is parent of an autofolder |
|
| 3032 | 3032 | { |
| 3033 | 3033 | //error_log(__METHOD__.__LINE__.$k.'->'.$mySpecialUseFolders[$aF]); |
| 3034 | - $isAutoFolder=true; |
|
| 3035 | - $autoFolderObjects[$k]=$f; |
|
| 3034 | + $isAutoFolder = true; |
|
| 3035 | + $autoFolderObjects[$k] = $f; |
|
| 3036 | 3036 | break; |
| 3037 | 3037 | } |
| 3038 | 3038 | } |
| 3039 | - if ($isAutoFolder==false) $inboxSubFolderObjects[$k]=$f; |
|
| 3039 | + if ($isAutoFolder == false) $inboxSubFolderObjects[$k] = $f; |
|
| 3040 | 3040 | unset($folders[$k]); |
| 3041 | - $sorted=true; |
|
| 3041 | + $sorted = true; |
|
| 3042 | 3042 | } |
| 3043 | - } elseif (strtoupper(substr($k,0,13))=='[GOOGLE MAIL]') { |
|
| 3044 | - $isGoogleMail=true; |
|
| 3045 | - if (strtoupper($k)=='[GOOGLE MAIL]') { |
|
| 3046 | - $googleMailFolderObject[$k]=$f; |
|
| 3043 | + } elseif (strtoupper(substr($k, 0, 13)) == '[GOOGLE MAIL]') { |
|
| 3044 | + $isGoogleMail = true; |
|
| 3045 | + if (strtoupper($k) == '[GOOGLE MAIL]') { |
|
| 3046 | + $googleMailFolderObject[$k] = $f; |
|
| 3047 | 3047 | unset($folders[$k]); |
| 3048 | - $sorted=true; |
|
| 3048 | + $sorted = true; |
|
| 3049 | 3049 | } else { |
| 3050 | - $isAutoFolder=false; |
|
| 3051 | - foreach($autoFoldersTmp as $afk=>$aF) |
|
| 3050 | + $isAutoFolder = false; |
|
| 3051 | + foreach ($autoFoldersTmp as $afk=>$aF) |
|
| 3052 | 3052 | { |
| 3053 | 3053 | //error_log($k.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 3054 | - if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
|
| 3055 | - ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter|| //k may be child of an autofolder |
|
| 3056 | - stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder |
|
| 3054 | + if ($aF && strlen($mySpecialUseFolders[$aF]) && /*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
|
| 3055 | + ($mySpecialUseFolders[$aF] == $k || substr($k, 0, strlen($mySpecialUseFolders[$aF].$delimiter)) == $mySpecialUseFolders[$aF].$delimiter || //k may be child of an autofolder |
|
| 3056 | + stristr($mySpecialUseFolders[$aF], $k.$delimiter) !== false)) // k is parent of an autofolder |
|
| 3057 | 3057 | { |
| 3058 | 3058 | //error_log($k.'->'.$mySpecialUseFolders[$aF]); |
| 3059 | - $isAutoFolder=true; |
|
| 3060 | - $googleAutoFolderObjects[$k]=$f; |
|
| 3059 | + $isAutoFolder = true; |
|
| 3060 | + $googleAutoFolderObjects[$k] = $f; |
|
| 3061 | 3061 | break; |
| 3062 | 3062 | } |
| 3063 | 3063 | } |
| 3064 | - if ($isAutoFolder==false) $googleSubFolderObjects[$k]=$f; |
|
| 3064 | + if ($isAutoFolder == false) $googleSubFolderObjects[$k] = $f; |
|
| 3065 | 3065 | unset($folders[$k]); |
| 3066 | - $sorted=true; |
|
| 3066 | + $sorted = true; |
|
| 3067 | 3067 | } |
| 3068 | 3068 | } else { |
| 3069 | - $isAutoFolder=false; |
|
| 3070 | - foreach($autoFoldersTmp as $afk=>$aF) |
|
| 3069 | + $isAutoFolder = false; |
|
| 3070 | + foreach ($autoFoldersTmp as $afk=>$aF) |
|
| 3071 | 3071 | { |
| 3072 | 3072 | //error_log($k.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 3073 | - if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
|
| 3074 | - ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter|| //k may be child of an autofolder |
|
| 3075 | - stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder |
|
| 3073 | + if ($aF && strlen($mySpecialUseFolders[$aF]) && /*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
|
| 3074 | + ($mySpecialUseFolders[$aF] == $k || substr($k, 0, strlen($mySpecialUseFolders[$aF].$delimiter)) == $mySpecialUseFolders[$aF].$delimiter || //k may be child of an autofolder |
|
| 3075 | + stristr($mySpecialUseFolders[$aF], $k.$delimiter) !== false)) // k is parent of an autofolder |
|
| 3076 | 3076 | { |
| 3077 | 3077 | //error_log($k.'->'.$mySpecialUseFolders[$aF]); |
| 3078 | - $isAutoFolder=true; |
|
| 3079 | - $autoFolderObjects[$k]=$f; |
|
| 3078 | + $isAutoFolder = true; |
|
| 3079 | + $autoFolderObjects[$k] = $f; |
|
| 3080 | 3080 | unset($folders[$k]); |
| 3081 | - $sorted=true; |
|
| 3081 | + $sorted = true; |
|
| 3082 | 3082 | break; |
| 3083 | 3083 | } |
| 3084 | 3084 | } |
| 3085 | 3085 | } |
| 3086 | 3086 | |
| 3087 | - if ($sorted==false) |
|
| 3087 | + if ($sorted == false) |
|
| 3088 | 3088 | { |
| 3089 | - foreach(array('others','shared') as $type) |
|
| 3089 | + foreach (array('others', 'shared') as $type) |
|
| 3090 | 3090 | { |
| 3091 | - if ($nameSpace[$type]['prefix_present']&&$nameSpace[$type]['prefix']) |
|
| 3091 | + if ($nameSpace[$type]['prefix_present'] && $nameSpace[$type]['prefix']) |
|
| 3092 | 3092 | { |
| 3093 | - if (substr($k,0,strlen($nameSpace[$type]['prefix']))==$nameSpace[$type]['prefix']|| |
|
| 3094 | - substr($k,0,strlen($nameSpace[$type]['prefix'])-strlen($nameSpace[$type]['delimiter']))==substr($nameSpace[$type]['prefix'],0,strlen($nameSpace[$type]['delimiter'])*-1)) { |
|
| 3093 | + if (substr($k, 0, strlen($nameSpace[$type]['prefix'])) == $nameSpace[$type]['prefix'] || |
|
| 3094 | + substr($k, 0, strlen($nameSpace[$type]['prefix']) - strlen($nameSpace[$type]['delimiter'])) == substr($nameSpace[$type]['prefix'], 0, strlen($nameSpace[$type]['delimiter']) * -1)) { |
|
| 3095 | 3095 | //error_log(__METHOD__.__LINE__.':'.substr($k,0,strlen($nameSpace[$type]['prefix'])).':'.$k); |
| 3096 | - $typeFolderObject[$type][$k]=$f; |
|
| 3096 | + $typeFolderObject[$type][$k] = $f; |
|
| 3097 | 3097 | unset($folders[$k]); |
| 3098 | 3098 | } |
| 3099 | 3099 | } |
@@ -3104,40 +3104,40 @@ discard block |
||
| 3104 | 3104 | // avoid calling sortByAutoFolder as it is not regarding subfolders |
| 3105 | 3105 | $autoFolderObjectsTmp = $autoFolderObjects; |
| 3106 | 3106 | unset($autoFolderObjects); |
| 3107 | - uasort($autoFolderObjectsTmp, array($this,'sortByMailbox')); |
|
| 3108 | - foreach($autoFoldersTmp as $afk=>$aF) |
|
| 3107 | + uasort($autoFolderObjectsTmp, array($this, 'sortByMailbox')); |
|
| 3108 | + foreach ($autoFoldersTmp as $afk=>$aF) |
|
| 3109 | 3109 | { |
| 3110 | - foreach($autoFolderObjectsTmp as $k => $f) |
|
| 3110 | + foreach ($autoFolderObjectsTmp as $k => $f) |
|
| 3111 | 3111 | { |
| 3112 | - if($aF && ($mySpecialUseFolders[$aF]==$k || |
|
| 3113 | - substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter || |
|
| 3114 | - stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) |
|
| 3112 | + if ($aF && ($mySpecialUseFolders[$aF] == $k || |
|
| 3113 | + substr($k, 0, strlen($mySpecialUseFolders[$aF].$delimiter)) == $mySpecialUseFolders[$aF].$delimiter || |
|
| 3114 | + stristr($mySpecialUseFolders[$aF], $k.$delimiter) !== false)) |
|
| 3115 | 3115 | { |
| 3116 | - $autoFolderObjects[$k]=$f; |
|
| 3116 | + $autoFolderObjects[$k] = $f; |
|
| 3117 | 3117 | } |
| 3118 | 3118 | } |
| 3119 | 3119 | } |
| 3120 | 3120 | //error_log(__METHOD__.__LINE__.array2string($autoFolderObjects)); |
| 3121 | 3121 | if (!$isGoogleMail) { |
| 3122 | - $folders = array_merge($inboxFolderObject,$autoFolderObjects,(array)$inboxSubFolderObjects,(array)$folders,(array)$typeFolderObject['others'],(array)$typeFolderObject['shared']); |
|
| 3122 | + $folders = array_merge($inboxFolderObject, $autoFolderObjects, (array)$inboxSubFolderObjects, (array)$folders, (array)$typeFolderObject['others'], (array)$typeFolderObject['shared']); |
|
| 3123 | 3123 | } else { |
| 3124 | 3124 | // avoid calling sortByAutoFolder as it is not regarding subfolders |
| 3125 | 3125 | $gAutoFolderObjectsTmp = $googleAutoFolderObjects; |
| 3126 | 3126 | unset($googleAutoFolderObjects); |
| 3127 | - uasort($gAutoFolderObjectsTmp, array($this,'sortByMailbox')); |
|
| 3128 | - foreach($autoFoldersTmp as $afk=>$aF) |
|
| 3127 | + uasort($gAutoFolderObjectsTmp, array($this, 'sortByMailbox')); |
|
| 3128 | + foreach ($autoFoldersTmp as $afk=>$aF) |
|
| 3129 | 3129 | { |
| 3130 | - foreach($gAutoFolderObjectsTmp as $k => $f) |
|
| 3130 | + foreach ($gAutoFolderObjectsTmp as $k => $f) |
|
| 3131 | 3131 | { |
| 3132 | - if($aF && ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter)) |
|
| 3132 | + if ($aF && ($mySpecialUseFolders[$aF] == $k || substr($k, 0, strlen($mySpecialUseFolders[$aF].$delimiter)) == $mySpecialUseFolders[$aF].$delimiter)) |
|
| 3133 | 3133 | { |
| 3134 | - $googleAutoFolderObjects[$k]=$f; |
|
| 3134 | + $googleAutoFolderObjects[$k] = $f; |
|
| 3135 | 3135 | } |
| 3136 | 3136 | } |
| 3137 | 3137 | } |
| 3138 | - $folders = array_merge($inboxFolderObject,$autoFolderObjects,(array)$folders,(array)$googleMailFolderObject,$googleAutoFolderObjects,$googleSubFolderObjects,(array)$typeFolderObject['others'],(array)$typeFolderObject['shared']); |
|
| 3138 | + $folders = array_merge($inboxFolderObject, $autoFolderObjects, (array)$folders, (array)$googleMailFolderObject, $googleAutoFolderObjects, $googleSubFolderObjects, (array)$typeFolderObject['others'], (array)$typeFolderObject['shared']); |
|
| 3139 | 3139 | } |
| 3140 | - if (self::$debugTimes) self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') Sorting:'); |
|
| 3140 | + if (self::$debugTimes) self::logRunTimes($starttime, null, function_backtrace(), __METHOD__.' ('.__LINE__.') Sorting:'); |
|
| 3141 | 3141 | //self::$debugTimes=false; |
| 3142 | 3142 | } |
| 3143 | 3143 | // Get counter information and add them to each fetched folders array |
@@ -3159,10 +3159,10 @@ discard block |
||
| 3159 | 3159 | * @param array $autofolders_exists existing folders, no need to check their existance again |
| 3160 | 3160 | * @return int number of new folders created |
| 3161 | 3161 | */ |
| 3162 | - function check_create_autofolders(array $autofolders_exists=array()) |
|
| 3162 | + function check_create_autofolders(array $autofolders_exists = array()) |
|
| 3163 | 3163 | { |
| 3164 | 3164 | $num_created = 0; |
| 3165 | - foreach(self::$autoFolders as $folder) |
|
| 3165 | + foreach (self::$autoFolders as $folder) |
|
| 3166 | 3166 | { |
| 3167 | 3167 | $created = false; |
| 3168 | 3168 | if (!in_array($folder, $autofolders_exists) && $this->_getSpecialUseFolder($folder, true, $created) && |
@@ -3187,7 +3187,7 @@ discard block |
||
| 3187 | 3187 | $rv = false; |
| 3188 | 3188 | foreach ($haystack as $k => $v) |
| 3189 | 3189 | { |
| 3190 | - foreach($v as &$sv) {if (trim($sv)==trim($needle)) return $k;} |
|
| 3190 | + foreach ($v as &$sv) {if (trim($sv) == trim($needle)) return $k; } |
|
| 3191 | 3191 | } |
| 3192 | 3192 | return $rv; |
| 3193 | 3193 | } |
@@ -3200,9 +3200,9 @@ discard block |
||
| 3200 | 3200 | * @param array $b array of folders |
| 3201 | 3201 | * @return int expect values (0, 1 or -1) |
| 3202 | 3202 | */ |
| 3203 | - function sortByMailbox($a,$b) |
|
| 3203 | + function sortByMailbox($a, $b) |
|
| 3204 | 3204 | { |
| 3205 | - return strcasecmp($a['MAILBOX'],$b['MAILBOX']); |
|
| 3205 | + return strcasecmp($a['MAILBOX'], $b['MAILBOX']); |
|
| 3206 | 3206 | } |
| 3207 | 3207 | |
| 3208 | 3208 | /** |
@@ -3212,13 +3212,13 @@ discard block |
||
| 3212 | 3212 | * @param string $_hDelimiter hierarchy delimiter |
| 3213 | 3213 | * @return array returns an array of data extracted from given node path |
| 3214 | 3214 | */ |
| 3215 | - static function pathToFolderData ($_path, $_hDelimiter) |
|
| 3215 | + static function pathToFolderData($_path, $_hDelimiter) |
|
| 3216 | 3216 | { |
| 3217 | 3217 | if (!strpos($_path, self::DELIMITER)) $_path = self::DELIMITER.$_path; |
| 3218 | 3218 | list(,$path) = explode(self::DELIMITER, $_path); |
| 3219 | 3219 | $path_chain = $parts = explode($_hDelimiter, $path); |
| 3220 | 3220 | $name = array_pop($parts); |
| 3221 | - return array ( |
|
| 3221 | + return array( |
|
| 3222 | 3222 | 'name' => $name, |
| 3223 | 3223 | 'mailbox' => $path, |
| 3224 | 3224 | 'parent' => implode($_hDelimiter, $parts), |
@@ -3241,8 +3241,8 @@ discard block |
||
| 3241 | 3241 | // 0, 1 und -1 |
| 3242 | 3242 | $a = self::pathToFolderData($_a['MAILBOX'], $_a['delimiter']); |
| 3243 | 3243 | $b = self::pathToFolderData($_b['MAILBOX'], $_b['delimiter']); |
| 3244 | - $pos1 = array_search(trim($a['name']),self::$autoFolders); |
|
| 3245 | - $pos2 = array_search(trim($b['name']),self::$autoFolders); |
|
| 3244 | + $pos1 = array_search(trim($a['name']), self::$autoFolders); |
|
| 3245 | + $pos2 = array_search(trim($b['name']), self::$autoFolders); |
|
| 3246 | 3246 | if ($pos1 == $pos2) return 0; |
| 3247 | 3247 | return ($pos1 < $pos2) ? -1 : 1; |
| 3248 | 3248 | } |
@@ -3255,10 +3255,10 @@ discard block |
||
| 3255 | 3255 | * @param object $b array of folderobjects |
| 3256 | 3256 | * @return int expect values (0, 1 or -1) |
| 3257 | 3257 | */ |
| 3258 | - function sortByDisplayName($a,$b) |
|
| 3258 | + function sortByDisplayName($a, $b) |
|
| 3259 | 3259 | { |
| 3260 | 3260 | // 0, 1 und -1 |
| 3261 | - return strcasecmp($a->displayName,$b->displayName); |
|
| 3261 | + return strcasecmp($a->displayName, $b->displayName); |
|
| 3262 | 3262 | } |
| 3263 | 3263 | |
| 3264 | 3264 | /** |
@@ -3269,11 +3269,11 @@ discard block |
||
| 3269 | 3269 | * @param object $b array of folderobjects |
| 3270 | 3270 | * @return int expect values (0, 1 or -1) |
| 3271 | 3271 | */ |
| 3272 | - function sortByAutoFolderPos($a,$b) |
|
| 3272 | + function sortByAutoFolderPos($a, $b) |
|
| 3273 | 3273 | { |
| 3274 | 3274 | // 0, 1 und -1 |
| 3275 | - $pos1 = array_search(trim($a->shortFolderName),self::$autoFolders); |
|
| 3276 | - $pos2 = array_search(trim($b->shortFolderName),self::$autoFolders); |
|
| 3275 | + $pos1 = array_search(trim($a->shortFolderName), self::$autoFolders); |
|
| 3276 | + $pos2 = array_search(trim($b->shortFolderName), self::$autoFolders); |
|
| 3277 | 3277 | if ($pos1 == $pos2) return 0; |
| 3278 | 3278 | return ($pos1 < $pos2) ? -1 : 1; |
| 3279 | 3279 | } |
@@ -3286,7 +3286,7 @@ discard block |
||
| 3286 | 3286 | * @param boolean $_returnObject return the counters as object rather than an array |
| 3287 | 3287 | * @return mixed false or array of counters array(MESSAGES,UNSEEN,RECENT,UIDNEXT,UIDVALIDITY) or object |
| 3288 | 3288 | */ |
| 3289 | - function getMailBoxCounters($folderName,$_returnObject=true) |
|
| 3289 | + function getMailBoxCounters($folderName, $_returnObject = true) |
|
| 3290 | 3290 | { |
| 3291 | 3291 | try |
| 3292 | 3292 | { |
@@ -3298,9 +3298,9 @@ discard block |
||
| 3298 | 3298 | if (self::$debug) error_log(__METHOD__." returned FolderStatus for Folder $folderName:".$e->getMessage()); |
| 3299 | 3299 | return false; |
| 3300 | 3300 | } |
| 3301 | - if(is_array($folderStatus)) { |
|
| 3302 | - if ($_returnObject===false) return $folderStatus; |
|
| 3303 | - $status = new \stdClass; |
|
| 3301 | + if (is_array($folderStatus)) { |
|
| 3302 | + if ($_returnObject === false) return $folderStatus; |
|
| 3303 | + $status = new \stdClass; |
|
| 3304 | 3304 | $status->messages = $folderStatus['MESSAGES']; |
| 3305 | 3305 | $status->unseen = $folderStatus['UNSEEN']; |
| 3306 | 3306 | $status->recent = $folderStatus['RECENT']; |
@@ -3322,42 +3322,42 @@ discard block |
||
| 3322 | 3322 | * @param string $reclevel 0, counter to keep track of the current recursionlevel |
| 3323 | 3323 | * @return array of mailboxes |
| 3324 | 3324 | */ |
| 3325 | - function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel=0) |
|
| 3325 | + function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel = 0) |
|
| 3326 | 3326 | { |
| 3327 | 3327 | #echo __METHOD__." retrieve SubFolders for $_mailbox$delimiter <br>"; |
| 3328 | - $maxreclevel=25; |
|
| 3328 | + $maxreclevel = 25; |
|
| 3329 | 3329 | if ($reclevel > $maxreclevel) { |
| 3330 | - error_log( __METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter "); |
|
| 3330 | + error_log(__METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter "); |
|
| 3331 | 3331 | return array(); |
| 3332 | 3332 | } |
| 3333 | 3333 | $reclevel++; |
| 3334 | 3334 | // clean up double delimiters |
| 3335 | - $_mailbox = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$_mailbox); |
|
| 3335 | + $_mailbox = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter : $delimiter).'+~s', $delimiter, $_mailbox); |
|
| 3336 | 3336 | //get that mailbox in question |
| 3337 | - $mbx = $this->icServer->getMailboxes($_mailbox,1,true); |
|
| 3337 | + $mbx = $this->icServer->getMailboxes($_mailbox, 1, true); |
|
| 3338 | 3338 | $mbxkeys = array_keys($mbx); |
| 3339 | 3339 | #_debug_array($mbx); |
| 3340 | 3340 | //error_log(__METHOD__.' ('.__LINE__.') '.' Delimiter:'.array2string($delimiter)); |
| 3341 | 3341 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mbx)); |
| 3342 | 3342 | // Example: Array([INBOX/GaGa] => Array([MAILBOX] => INBOX/GaGa[ATTRIBUTES] => Array([0] => \\unmarked)[delimiter] => /)) |
| 3343 | - if (is_array($mbx[$mbxkeys[0]]["ATTRIBUTES"]) && (in_array('\HasChildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Haschildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\haschildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) { |
|
| 3343 | + if (is_array($mbx[$mbxkeys[0]]["ATTRIBUTES"]) && (in_array('\HasChildren', $mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Haschildren', $mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\haschildren', $mbx[$mbxkeys[0]]["ATTRIBUTES"]))) { |
|
| 3344 | 3344 | // if there are children fetch them |
| 3345 | 3345 | //echo $mbx[$mbxkeys[0]]['MAILBOX']."<br>"; |
| 3346 | 3346 | |
| 3347 | - $buff = $this->icServer->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'].($mbx[$mbxkeys[0]]['MAILBOX'] == $prefix ? '':$delimiter),2,false); |
|
| 3347 | + $buff = $this->icServer->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'].($mbx[$mbxkeys[0]]['MAILBOX'] == $prefix ? '' : $delimiter), 2, false); |
|
| 3348 | 3348 | //$buff = $this->icServer->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'],2,false); |
| 3349 | 3349 | //_debug_array($buff); |
| 3350 | 3350 | $allMailboxes = array(); |
| 3351 | 3351 | foreach ($buff as $mbxname) { |
| 3352 | 3352 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mbxname)); |
| 3353 | - $mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$mbxname['MAILBOX']); |
|
| 3353 | + $mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter : $delimiter).'+~s', $delimiter, $mbxname['MAILBOX']); |
|
| 3354 | 3354 | #echo "About to recur in level $reclevel:".$mbxname."<br>"; |
| 3355 | - if ( $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'] && $mbxname != $prefix && $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'].$delimiter) |
|
| 3355 | + if ($mbxname != $mbx[$mbxkeys[0]]['MAILBOX'] && $mbxname != $prefix && $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'].$delimiter) |
|
| 3356 | 3356 | { |
| 3357 | 3357 | $allMailboxes = array_merge($allMailboxes, self::getMailBoxesRecursive($mbxname, $delimiter, $prefix, $reclevel)); |
| 3358 | 3358 | } |
| 3359 | 3359 | } |
| 3360 | - if (!(in_array('\NoSelect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) $allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX']; |
|
| 3360 | + if (!(in_array('\NoSelect', $mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect', $mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect', $mbx[$mbxkeys[0]]["ATTRIBUTES"]))) $allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX']; |
|
| 3361 | 3361 | return $allMailboxes; |
| 3362 | 3362 | } else { |
| 3363 | 3363 | return array($_mailbox); |
@@ -3372,18 +3372,18 @@ discard block |
||
| 3372 | 3372 | * @param boolean& $created =null on return true: if folder was just created, false if not |
| 3373 | 3373 | * @return mixed string or false |
| 3374 | 3374 | */ |
| 3375 | - function _getSpecialUseFolder($_type, $_checkexistance=TRUE, &$created=null) |
|
| 3375 | + function _getSpecialUseFolder($_type, $_checkexistance = TRUE, &$created = null) |
|
| 3376 | 3376 | { |
| 3377 | 3377 | static $types = array( |
| 3378 | - 'Drafts' => array('profileKey'=>'acc_folder_draft','autoFolderName'=>'Drafts'), |
|
| 3379 | - 'Template' => array('profileKey'=>'acc_folder_template','autoFolderName'=>'Templates'), |
|
| 3380 | - 'Trash' => array('profileKey'=>'acc_folder_trash','autoFolderName'=>'Trash'), |
|
| 3381 | - 'Sent' => array('profileKey'=>'acc_folder_sent','autoFolderName'=>'Sent'), |
|
| 3382 | - 'Junk' => array('profileKey'=>'acc_folder_junk','autoFolderName'=>'Junk'), |
|
| 3383 | - 'Outbox' => array('profileKey'=>'acc_folder_outbox','autoFolderName'=>'Outbox'), |
|
| 3384 | - 'Archive' => array('profileKey'=>'acc_folder_archive','autoFolderName'=>'Archive'), |
|
| 3378 | + 'Drafts' => array('profileKey'=>'acc_folder_draft', 'autoFolderName'=>'Drafts'), |
|
| 3379 | + 'Template' => array('profileKey'=>'acc_folder_template', 'autoFolderName'=>'Templates'), |
|
| 3380 | + 'Trash' => array('profileKey'=>'acc_folder_trash', 'autoFolderName'=>'Trash'), |
|
| 3381 | + 'Sent' => array('profileKey'=>'acc_folder_sent', 'autoFolderName'=>'Sent'), |
|
| 3382 | + 'Junk' => array('profileKey'=>'acc_folder_junk', 'autoFolderName'=>'Junk'), |
|
| 3383 | + 'Outbox' => array('profileKey'=>'acc_folder_outbox', 'autoFolderName'=>'Outbox'), |
|
| 3384 | + 'Archive' => array('profileKey'=>'acc_folder_archive', 'autoFolderName'=>'Archive'), |
|
| 3385 | 3385 | ); |
| 3386 | - if ($_type == 'Templates') $_type = 'Template'; // for some reason self::$autofolders uses 'Templates'! |
|
| 3386 | + if ($_type == 'Templates') $_type = 'Template'; // for some reason self::$autofolders uses 'Templates'! |
|
| 3387 | 3387 | $created = false; |
| 3388 | 3388 | if (!isset($types[$_type])) |
| 3389 | 3389 | { |
@@ -3405,7 +3405,7 @@ discard block |
||
| 3405 | 3405 | } |
| 3406 | 3406 | // do not try to autocreate configured Archive-Folder. Return false if configured folder does not exist |
| 3407 | 3407 | if ($_type == 'Archive') { |
| 3408 | - if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true)) { |
|
| 3408 | + if ($_folderName && $_checkexistance && strtolower($_folderName) != 'none' && !$this->folderExists($_folderName, true)) { |
|
| 3409 | 3409 | return false; |
| 3410 | 3410 | } else { |
| 3411 | 3411 | return $_folderName; |
@@ -3413,38 +3413,38 @@ discard block |
||
| 3413 | 3413 | |
| 3414 | 3414 | } |
| 3415 | 3415 | // does the folder exist??? (is configured/preset, but non-existent) |
| 3416 | - if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true)) { |
|
| 3416 | + if ($_folderName && $_checkexistance && strtolower($_folderName) != 'none' && !$this->folderExists($_folderName, true)) { |
|
| 3417 | 3417 | try |
| 3418 | 3418 | { |
| 3419 | 3419 | $error = null; |
| 3420 | 3420 | if (($_folderName = $this->createFolder('', $_folderName, $error))) $created = true; |
| 3421 | 3421 | if ($error) error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error); |
| 3422 | 3422 | } |
| 3423 | - catch(Exception $e) |
|
| 3423 | + catch (Exception $e) |
|
| 3424 | 3424 | { |
| 3425 | 3425 | error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$e->getMessage().':'.function_backtrace()); |
| 3426 | 3426 | $_folderName = false; |
| 3427 | 3427 | } |
| 3428 | 3428 | } |
| 3429 | 3429 | // not sure yet if false is the correct behavior on none |
| 3430 | - if ($_folderName =='none') return 'none' ; //false; |
|
| 3430 | + if ($_folderName == 'none') return 'none'; //false; |
|
| 3431 | 3431 | //no (valid) folder found yet; try specialUseFolders |
| 3432 | - if (empty($_folderName) && is_array(self::$specialUseFolders) && ($f = array_search($_type,self::$specialUseFolders))) $_folderName = $f; |
|
| 3432 | + if (empty($_folderName) && is_array(self::$specialUseFolders) && ($f = array_search($_type, self::$specialUseFolders))) $_folderName = $f; |
|
| 3433 | 3433 | //no specialUseFolder; try some Defaults |
| 3434 | 3434 | if (empty($_folderName) && isset($types[$_type])) |
| 3435 | 3435 | { |
| 3436 | 3436 | $nameSpace = $this->_getNameSpaces(); |
| 3437 | - $prefix=''; |
|
| 3437 | + $prefix = ''; |
|
| 3438 | 3438 | foreach ($nameSpace as $nSp) |
| 3439 | 3439 | { |
| 3440 | - if ($nSp['type']=='personal') |
|
| 3440 | + if ($nSp['type'] == 'personal') |
|
| 3441 | 3441 | { |
| 3442 | 3442 | //error_log(__METHOD__.__LINE__.array2string($nSp)); |
| 3443 | 3443 | $prefix = $nSp['prefix']; |
| 3444 | 3444 | break; |
| 3445 | 3445 | } |
| 3446 | 3446 | } |
| 3447 | - if ($this->folderExists($prefix.$types[$_type]['autoFolderName'],true)) |
|
| 3447 | + if ($this->folderExists($prefix.$types[$_type]['autoFolderName'], true)) |
|
| 3448 | 3448 | { |
| 3449 | 3449 | $_folderName = $prefix.$types[$_type]['autoFolderName']; |
| 3450 | 3450 | } |
@@ -3453,11 +3453,11 @@ discard block |
||
| 3453 | 3453 | try |
| 3454 | 3454 | { |
| 3455 | 3455 | $error = null; |
| 3456 | - $this->createFolder('', $prefix.$types[$_type]['autoFolderName'],$error); |
|
| 3456 | + $this->createFolder('', $prefix.$types[$_type]['autoFolderName'], $error); |
|
| 3457 | 3457 | $_folderName = $prefix.$types[$_type]['autoFolderName']; |
| 3458 | 3458 | if ($error) error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error); |
| 3459 | 3459 | } |
| 3460 | - catch(Exception $e) |
|
| 3460 | + catch (Exception $e) |
|
| 3461 | 3461 | { |
| 3462 | 3462 | error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$e->getMessage()); |
| 3463 | 3463 | $_folderName = false; |
@@ -3473,7 +3473,7 @@ discard block |
||
| 3473 | 3473 | * @param boolean $_checkexistance trigger check for existance |
| 3474 | 3474 | * @return mixed string or false |
| 3475 | 3475 | */ |
| 3476 | - function getFolderByType($type, $_checkexistance=false) |
|
| 3476 | + function getFolderByType($type, $_checkexistance = false) |
|
| 3477 | 3477 | { |
| 3478 | 3478 | return $this->_getSpecialUseFolder($type, $_checkexistance); |
| 3479 | 3479 | } |
@@ -3483,7 +3483,7 @@ discard block |
||
| 3483 | 3483 | * @param boolean $_checkexistance trigger check for existance |
| 3484 | 3484 | * @return mixed string or false |
| 3485 | 3485 | */ |
| 3486 | - function getJunkFolder($_checkexistance=TRUE) |
|
| 3486 | + function getJunkFolder($_checkexistance = TRUE) |
|
| 3487 | 3487 | { |
| 3488 | 3488 | return $this->_getSpecialUseFolder('Junk', $_checkexistance); |
| 3489 | 3489 | } |
@@ -3493,7 +3493,7 @@ discard block |
||
| 3493 | 3493 | * @param boolean $_checkexistance trigger check for existance |
| 3494 | 3494 | * @return mixed string or false |
| 3495 | 3495 | */ |
| 3496 | - function getDraftFolder($_checkexistance=TRUE) |
|
| 3496 | + function getDraftFolder($_checkexistance = TRUE) |
|
| 3497 | 3497 | { |
| 3498 | 3498 | return $this->_getSpecialUseFolder('Drafts', $_checkexistance); |
| 3499 | 3499 | } |
@@ -3503,7 +3503,7 @@ discard block |
||
| 3503 | 3503 | * @param boolean $_checkexistance trigger check for existance |
| 3504 | 3504 | * @return mixed string or false |
| 3505 | 3505 | */ |
| 3506 | - function getTemplateFolder($_checkexistance=TRUE) |
|
| 3506 | + function getTemplateFolder($_checkexistance = TRUE) |
|
| 3507 | 3507 | { |
| 3508 | 3508 | return $this->_getSpecialUseFolder('Template', $_checkexistance); |
| 3509 | 3509 | } |
@@ -3513,7 +3513,7 @@ discard block |
||
| 3513 | 3513 | * @param boolean $_checkexistance trigger check for existance |
| 3514 | 3514 | * @return mixed string or false |
| 3515 | 3515 | */ |
| 3516 | - function getTrashFolder($_checkexistance=TRUE) |
|
| 3516 | + function getTrashFolder($_checkexistance = TRUE) |
|
| 3517 | 3517 | { |
| 3518 | 3518 | return $this->_getSpecialUseFolder('Trash', $_checkexistance); |
| 3519 | 3519 | } |
@@ -3523,7 +3523,7 @@ discard block |
||
| 3523 | 3523 | * @param boolean $_checkexistance trigger check for existance |
| 3524 | 3524 | * @return mixed string or false |
| 3525 | 3525 | */ |
| 3526 | - function getSentFolder($_checkexistance=TRUE) |
|
| 3526 | + function getSentFolder($_checkexistance = TRUE) |
|
| 3527 | 3527 | { |
| 3528 | 3528 | return $this->_getSpecialUseFolder('Sent', $_checkexistance); |
| 3529 | 3529 | } |
@@ -3533,7 +3533,7 @@ discard block |
||
| 3533 | 3533 | * @param boolean $_checkexistance trigger check for existance |
| 3534 | 3534 | * @return mixed string or false |
| 3535 | 3535 | */ |
| 3536 | - function getOutboxFolder($_checkexistance=TRUE) |
|
| 3536 | + function getOutboxFolder($_checkexistance = TRUE) |
|
| 3537 | 3537 | { |
| 3538 | 3538 | return $this->_getSpecialUseFolder('Outbox', $_checkexistance); |
| 3539 | 3539 | } |
@@ -3543,7 +3543,7 @@ discard block |
||
| 3543 | 3543 | * @param boolean $_checkexistance trigger check for existance . We do no autocreation for configured Archive folder |
| 3544 | 3544 | * @return mixed string or false |
| 3545 | 3545 | */ |
| 3546 | - function getArchiveFolder($_checkexistance=TRUE) |
|
| 3546 | + function getArchiveFolder($_checkexistance = TRUE) |
|
| 3547 | 3547 | { |
| 3548 | 3548 | return $this->_getSpecialUseFolder('Archive', $_checkexistance); |
| 3549 | 3549 | } |
@@ -3555,10 +3555,10 @@ discard block |
||
| 3555 | 3555 | * @param boolean $_exactMatch make the check more strict. return false if folder is subfolder only |
| 3556 | 3556 | * @return boolean |
| 3557 | 3557 | */ |
| 3558 | - function isSentFolder($_folderName, $_checkexistance=TRUE, $_exactMatch=false) |
|
| 3558 | + function isSentFolder($_folderName, $_checkexistance = TRUE, $_exactMatch = false) |
|
| 3559 | 3559 | { |
| 3560 | 3560 | $sentFolder = $this->getSentFolder($_checkexistance); |
| 3561 | - if(empty($sentFolder)) { |
|
| 3561 | + if (empty($sentFolder)) { |
|
| 3562 | 3562 | return false; |
| 3563 | 3563 | } |
| 3564 | 3564 | // does the folder exist??? |
@@ -3568,13 +3568,13 @@ discard block |
||
| 3568 | 3568 | |
| 3569 | 3569 | if ($_exactMatch) |
| 3570 | 3570 | { |
| 3571 | - if(false !== stripos($_folderName, $sentFolder)&& strlen($_folderName)==strlen($sentFolder)) { |
|
| 3571 | + if (false !== stripos($_folderName, $sentFolder) && strlen($_folderName) == strlen($sentFolder)) { |
|
| 3572 | 3572 | return true; |
| 3573 | 3573 | } else { |
| 3574 | 3574 | return false; |
| 3575 | 3575 | } |
| 3576 | 3576 | } else { |
| 3577 | - if(false !== stripos($_folderName, $sentFolder)) { |
|
| 3577 | + if (false !== stripos($_folderName, $sentFolder)) { |
|
| 3578 | 3578 | return true; |
| 3579 | 3579 | } else { |
| 3580 | 3580 | return false; |
@@ -3589,9 +3589,9 @@ discard block |
||
| 3589 | 3589 | * @param boolean $_exactMatch make the check more strict. return false if folder is subfolder only |
| 3590 | 3590 | * @return boolean |
| 3591 | 3591 | */ |
| 3592 | - function isOutbox($_folderName, $_checkexistance=TRUE, $_exactMatch=false) |
|
| 3592 | + function isOutbox($_folderName, $_checkexistance = TRUE, $_exactMatch = false) |
|
| 3593 | 3593 | { |
| 3594 | - if (stripos($_folderName, 'Outbox')===false) { |
|
| 3594 | + if (stripos($_folderName, 'Outbox') === false) { |
|
| 3595 | 3595 | return false; |
| 3596 | 3596 | } |
| 3597 | 3597 | // does the folder exist??? |
@@ -3599,13 +3599,13 @@ discard block |
||
| 3599 | 3599 | $outboxFolder = $this->getOutboxFolder($_checkexistance); |
| 3600 | 3600 | if ($_exactMatch) |
| 3601 | 3601 | { |
| 3602 | - if(false !== stripos($_folderName, $outboxFolder)&& strlen($_folderName)==strlen($outboxFolder)) { |
|
| 3602 | + if (false !== stripos($_folderName, $outboxFolder) && strlen($_folderName) == strlen($outboxFolder)) { |
|
| 3603 | 3603 | return true; |
| 3604 | 3604 | } else { |
| 3605 | 3605 | return false; |
| 3606 | 3606 | } |
| 3607 | 3607 | } else { |
| 3608 | - if(false !== stripos($_folderName, $outboxFolder)) { |
|
| 3608 | + if (false !== stripos($_folderName, $outboxFolder)) { |
|
| 3609 | 3609 | return true; |
| 3610 | 3610 | } else { |
| 3611 | 3611 | return false; |
@@ -3622,26 +3622,26 @@ discard block |
||
| 3622 | 3622 | * @param boolean $_exactMatch make the check more strict. return false if folder is subfolder only |
| 3623 | 3623 | * @return boolean |
| 3624 | 3624 | */ |
| 3625 | - function isDraftFolder($_folderName, $_checkexistance=TRUE, $_exactMatch=false) |
|
| 3625 | + function isDraftFolder($_folderName, $_checkexistance = TRUE, $_exactMatch = false) |
|
| 3626 | 3626 | { |
| 3627 | 3627 | $draftFolder = $this->getDraftFolder($_checkexistance); |
| 3628 | - if(empty($draftFolder)) { |
|
| 3628 | + if (empty($draftFolder)) { |
|
| 3629 | 3629 | return false; |
| 3630 | 3630 | } |
| 3631 | 3631 | // does the folder exist??? |
| 3632 | 3632 | if ($_checkexistance && !$this->folderExists($_folderName)) { |
| 3633 | 3633 | return false; |
| 3634 | 3634 | } |
| 3635 | - if (is_a($_folderName,"Horde_Imap_Client_Mailbox")) $_folderName = $_folderName->utf8; |
|
| 3635 | + if (is_a($_folderName, "Horde_Imap_Client_Mailbox")) $_folderName = $_folderName->utf8; |
|
| 3636 | 3636 | if ($_exactMatch) |
| 3637 | 3637 | { |
| 3638 | - if(false !== stripos($_folderName, $draftFolder)&& strlen($_folderName)==strlen($draftFolder)) { |
|
| 3638 | + if (false !== stripos($_folderName, $draftFolder) && strlen($_folderName) == strlen($draftFolder)) { |
|
| 3639 | 3639 | return true; |
| 3640 | 3640 | } else { |
| 3641 | 3641 | return false; |
| 3642 | 3642 | } |
| 3643 | 3643 | } else { |
| 3644 | - if(false !== stripos($_folderName, $draftFolder)) { |
|
| 3644 | + if (false !== stripos($_folderName, $draftFolder)) { |
|
| 3645 | 3645 | return true; |
| 3646 | 3646 | } else { |
| 3647 | 3647 | return false; |
@@ -3656,10 +3656,10 @@ discard block |
||
| 3656 | 3656 | * @param boolean $_exactMatch make the check more strict. return false if folder is subfolder only |
| 3657 | 3657 | * @return boolean |
| 3658 | 3658 | */ |
| 3659 | - function isTrashFolder($_folderName, $_checkexistance=TRUE, $_exactMatch=false) |
|
| 3659 | + function isTrashFolder($_folderName, $_checkexistance = TRUE, $_exactMatch = false) |
|
| 3660 | 3660 | { |
| 3661 | 3661 | $trashFolder = $this->getTrashFolder($_checkexistance); |
| 3662 | - if(empty($trashFolder)) { |
|
| 3662 | + if (empty($trashFolder)) { |
|
| 3663 | 3663 | return false; |
| 3664 | 3664 | } |
| 3665 | 3665 | // does the folder exist??? |
@@ -3669,13 +3669,13 @@ discard block |
||
| 3669 | 3669 | |
| 3670 | 3670 | if ($_exactMatch) |
| 3671 | 3671 | { |
| 3672 | - if(false !== stripos($_folderName, $trashFolder)&& strlen($_folderName)==strlen($trashFolder)) { |
|
| 3672 | + if (false !== stripos($_folderName, $trashFolder) && strlen($_folderName) == strlen($trashFolder)) { |
|
| 3673 | 3673 | return true; |
| 3674 | 3674 | } else { |
| 3675 | 3675 | return false; |
| 3676 | 3676 | } |
| 3677 | 3677 | } else { |
| 3678 | - if(false !== stripos($_folderName, $trashFolder)) { |
|
| 3678 | + if (false !== stripos($_folderName, $trashFolder)) { |
|
| 3679 | 3679 | return true; |
| 3680 | 3680 | } else { |
| 3681 | 3681 | return false; |
@@ -3690,10 +3690,10 @@ discard block |
||
| 3690 | 3690 | * @param boolean $_exactMatch make the check more strict. return false if folder is subfolder only |
| 3691 | 3691 | * @return boolean |
| 3692 | 3692 | */ |
| 3693 | - function isTemplateFolder($_folderName, $_checkexistance=TRUE, $_exactMatch=false) |
|
| 3693 | + function isTemplateFolder($_folderName, $_checkexistance = TRUE, $_exactMatch = false) |
|
| 3694 | 3694 | { |
| 3695 | 3695 | $templateFolder = $this->getTemplateFolder($_checkexistance); |
| 3696 | - if(empty($templateFolder)) { |
|
| 3696 | + if (empty($templateFolder)) { |
|
| 3697 | 3697 | return false; |
| 3698 | 3698 | } |
| 3699 | 3699 | // does the folder exist??? |
@@ -3702,13 +3702,13 @@ discard block |
||
| 3702 | 3702 | } |
| 3703 | 3703 | if ($_exactMatch) |
| 3704 | 3704 | { |
| 3705 | - if(false !== stripos($_folderName, $templateFolder)&& strlen($_folderName)==strlen($templateFolder)) { |
|
| 3705 | + if (false !== stripos($_folderName, $templateFolder) && strlen($_folderName) == strlen($templateFolder)) { |
|
| 3706 | 3706 | return true; |
| 3707 | 3707 | } else { |
| 3708 | 3708 | return false; |
| 3709 | 3709 | } |
| 3710 | 3710 | } else { |
| 3711 | - if(false !== stripos($_folderName, $templateFolder)) { |
|
| 3711 | + if (false !== stripos($_folderName, $templateFolder)) { |
|
| 3712 | 3712 | return true; |
| 3713 | 3713 | } else { |
| 3714 | 3714 | return false; |
@@ -3722,24 +3722,24 @@ discard block |
||
| 3722 | 3722 | * @param boolean $_forceCheck trigger check for existance on icServer |
| 3723 | 3723 | * @return mixed string or false |
| 3724 | 3724 | */ |
| 3725 | - function folderExists($_folder, $_forceCheck=false) |
|
| 3725 | + function folderExists($_folder, $_forceCheck = false) |
|
| 3726 | 3726 | { |
| 3727 | 3727 | static $folderInfo; |
| 3728 | 3728 | $forceCheck = $_forceCheck; |
| 3729 | 3729 | if (empty($_folder)) |
| 3730 | 3730 | { |
| 3731 | 3731 | // this error is more or less without significance, unless we force the check |
| 3732 | - if ($_forceCheck===true) error_log(__METHOD__.' ('.__LINE__.') '.' Called with empty Folder:'.$_folder.function_backtrace()); |
|
| 3732 | + if ($_forceCheck === true) error_log(__METHOD__.' ('.__LINE__.') '.' Called with empty Folder:'.$_folder.function_backtrace()); |
|
| 3733 | 3733 | return false; |
| 3734 | 3734 | } |
| 3735 | 3735 | // when check is not enforced , we assume a folder represented as Horde_Imap_Client_Mailbox as existing folder |
| 3736 | - if (is_a($_folder,"Horde_Imap_Client_Mailbox")&&$_forceCheck===false) return true; |
|
| 3737 | - if (is_a($_folder,"Horde_Imap_Client_Mailbox")) $_folder = $_folder->utf8; |
|
| 3736 | + if (is_a($_folder, "Horde_Imap_Client_Mailbox") && $_forceCheck === false) return true; |
|
| 3737 | + if (is_a($_folder, "Horde_Imap_Client_Mailbox")) $_folder = $_folder->utf8; |
|
| 3738 | 3738 | // reduce traffic within the Instance per User; Expire every 5 hours |
| 3739 | 3739 | //error_log(__METHOD__.' ('.__LINE__.') '.' Called with Folder:'.$_folder.function_backtrace()); |
| 3740 | - if (is_null($folderInfo)) $folderInfo = Cache::getCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*5); |
|
| 3740 | + if (is_null($folderInfo)) $folderInfo = Cache::getCache(Cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 5); |
|
| 3741 | 3741 | //error_log(__METHOD__.' ('.__LINE__.') '.'Cached Info on Folder:'.$_folder.' for Profile:'.$this->profileID.($forceCheck?'(forcedCheck)':'').':'.array2string($folderInfo)); |
| 3742 | - if (!empty($folderInfo) && isset($folderInfo[$this->profileID]) && isset($folderInfo[$this->profileID][$_folder]) && $forceCheck===false) |
|
| 3742 | + if (!empty($folderInfo) && isset($folderInfo[$this->profileID]) && isset($folderInfo[$this->profileID][$_folder]) && $forceCheck === false) |
|
| 3743 | 3743 | { |
| 3744 | 3744 | //error_log(__METHOD__.' ('.__LINE__.') '.' Using cached Info on Folder:'.$_folder.' for Profile:'.$this->profileID); |
| 3745 | 3745 | return $folderInfo[$this->profileID][$_folder]; |
@@ -3755,7 +3755,7 @@ discard block |
||
| 3755 | 3755 | |
| 3756 | 3756 | // does the folder exist??? |
| 3757 | 3757 | //error_log(__METHOD__."->Connected?".$this->icServer->_connected.", ".$_folder.", ".($forceCheck?' forceCheck activated':'dont check on server')); |
| 3758 | - if ( $forceCheck || empty($folderInfo) || !isset($folderInfo[$this->profileID]) || !isset($folderInfo[$this->profileID][$_folder])) { |
|
| 3758 | + if ($forceCheck || empty($folderInfo) || !isset($folderInfo[$this->profileID]) || !isset($folderInfo[$this->profileID][$_folder])) { |
|
| 3759 | 3759 | //error_log(__METHOD__."->NotConnected and forceCheck with profile:".$this->profileID); |
| 3760 | 3760 | //return false; |
| 3761 | 3761 | //try to connect |
@@ -3766,18 +3766,18 @@ discard block |
||
| 3766 | 3766 | } |
| 3767 | 3767 | catch (\Exception $e) |
| 3768 | 3768 | { |
| 3769 | - error_log(__METHOD__.__LINE__.$e->getMessage().($e->details?', '.$e->details:'')); |
|
| 3770 | - self::$profileDefunct[$this->profileID]=$e->getMessage().($e->details?', '.$e->details:''); |
|
| 3769 | + error_log(__METHOD__.__LINE__.$e->getMessage().($e->details ? ', '.$e->details : '')); |
|
| 3770 | + self::$profileDefunct[$this->profileID] = $e->getMessage().($e->details ? ', '.$e->details : ''); |
|
| 3771 | 3771 | $folderInfo[$this->profileID][$_folder] = false; |
| 3772 | 3772 | } |
| 3773 | 3773 | //error_log(__METHOD__.' ('.__LINE__.') '.' Folder Exists:'.$folderInfo[$this->profileID][$_folder].function_backtrace()); |
| 3774 | 3774 | |
| 3775 | - if(!empty($folderInfo) && isset($folderInfo[$this->profileID][$_folder]) && |
|
| 3775 | + if (!empty($folderInfo) && isset($folderInfo[$this->profileID][$_folder]) && |
|
| 3776 | 3776 | $folderInfo[$this->profileID][$_folder] !== true) |
| 3777 | 3777 | { |
| 3778 | 3778 | $folderInfo[$this->profileID][$_folder] = false; // set to false, whatever it was (to have a valid returnvalue for the static return) |
| 3779 | 3779 | } |
| 3780 | - Cache::setCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderInfo,$expiration=60*60*5); |
|
| 3780 | + Cache::setCache(Cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']), $folderInfo, $expiration = 60 * 60 * 5); |
|
| 3781 | 3781 | return (!empty($folderInfo) && isset($folderInfo[$this->profileID][$_folder]) ? $folderInfo[$this->profileID][$_folder] : false); |
| 3782 | 3782 | } |
| 3783 | 3783 | |
@@ -3790,14 +3790,14 @@ discard block |
||
| 3790 | 3790 | */ |
| 3791 | 3791 | function compressFolder($_folderName = false) |
| 3792 | 3792 | { |
| 3793 | - $folderName = ($_folderName ? $_folderName : $this->sessionData['mailbox']); |
|
| 3794 | - $deleteOptions = $GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions']; |
|
| 3795 | - $trashFolder = $this->getTrashFolder(); |
|
| 3793 | + $folderName = ($_folderName ? $_folderName : $this->sessionData['mailbox']); |
|
| 3794 | + $deleteOptions = $GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions']; |
|
| 3795 | + $trashFolder = $this->getTrashFolder(); |
|
| 3796 | 3796 | |
| 3797 | 3797 | $this->icServer->openMailbox($folderName); |
| 3798 | 3798 | |
| 3799 | - if(strtolower($folderName) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") { |
|
| 3800 | - $this->deleteMessages('all',$folderName,'remove_immediately'); |
|
| 3799 | + if (strtolower($folderName) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") { |
|
| 3800 | + $this->deleteMessages('all', $folderName, 'remove_immediately'); |
|
| 3801 | 3801 | } else { |
| 3802 | 3802 | $this->icServer->expunge($folderName); |
| 3803 | 3803 | } |
@@ -3813,19 +3813,19 @@ discard block |
||
| 3813 | 3813 | * @return bool true, as we do not handle return values yet |
| 3814 | 3814 | * @throws Exception |
| 3815 | 3815 | */ |
| 3816 | - function deleteMessages($_messageUID, $_folder=NULL, $_forceDeleteMethod='no') |
|
| 3816 | + function deleteMessages($_messageUID, $_folder = NULL, $_forceDeleteMethod = 'no') |
|
| 3817 | 3817 | { |
| 3818 | 3818 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.array2string($_folder).', '.$_forceDeleteMethod); |
| 3819 | 3819 | $oldMailbox = ''; |
| 3820 | 3820 | if (is_null($_folder) || empty($_folder)) $_folder = $this->sessionData['mailbox']; |
| 3821 | 3821 | if (empty($_messageUID)) |
| 3822 | 3822 | { |
| 3823 | - if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID)); |
|
| 3823 | + if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',', $_messageUID)); |
|
| 3824 | 3824 | return false; |
| 3825 | 3825 | } |
| 3826 | - elseif ($_messageUID==='all') |
|
| 3826 | + elseif ($_messageUID === 'all') |
|
| 3827 | 3827 | { |
| 3828 | - $_messageUID= null; |
|
| 3828 | + $_messageUID = null; |
|
| 3829 | 3829 | } |
| 3830 | 3830 | else |
| 3831 | 3831 | { |
@@ -3834,32 +3834,32 @@ discard block |
||
| 3834 | 3834 | $uidsToDelete->add($_messageUID); |
| 3835 | 3835 | } |
| 3836 | 3836 | $deleteOptions = $_forceDeleteMethod; // use forceDeleteMethod if not "no", or unknown method |
| 3837 | - if ($_forceDeleteMethod === 'no' || !in_array($_forceDeleteMethod,array('move_to_trash',"mark_as_deleted","remove_immediately"))) $deleteOptions = ($this->mailPreferences['deleteOptions']?$this->mailPreferences['deleteOptions']:"mark_as_deleted"); |
|
| 3837 | + if ($_forceDeleteMethod === 'no' || !in_array($_forceDeleteMethod, array('move_to_trash', "mark_as_deleted", "remove_immediately"))) $deleteOptions = ($this->mailPreferences['deleteOptions'] ? $this->mailPreferences['deleteOptions'] : "mark_as_deleted"); |
|
| 3838 | 3838 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.$_folder.'/'.$this->sessionData['mailbox'].' Option:'.$deleteOptions); |
| 3839 | 3839 | $trashFolder = $this->getTrashFolder(); |
| 3840 | - $draftFolder = $this->getDraftFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['draftFolder']; |
|
| 3840 | + $draftFolder = $this->getDraftFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['draftFolder']; |
|
| 3841 | 3841 | $templateFolder = $this->getTemplateFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['templateFolder']; |
| 3842 | - if((strtolower($_folder) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") || |
|
| 3842 | + if ((strtolower($_folder) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") || |
|
| 3843 | 3843 | (strtolower($_folder) == strtolower($draftFolder))) { |
| 3844 | 3844 | $deleteOptions = "remove_immediately"; |
| 3845 | 3845 | } |
| 3846 | - if($this->icServer->getCurrentMailbox() != $_folder) { |
|
| 3846 | + if ($this->icServer->getCurrentMailbox() != $_folder) { |
|
| 3847 | 3847 | $oldMailbox = $this->icServer->getCurrentMailbox(); |
| 3848 | 3848 | $this->icServer->openMailbox($_folder); |
| 3849 | 3849 | } |
| 3850 | 3850 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.$_folder.'/'.$this->sessionData['mailbox'].' Option:'.$deleteOptions); |
| 3851 | 3851 | $updateCache = false; |
| 3852 | - switch($deleteOptions) { |
|
| 3852 | + switch ($deleteOptions) { |
|
| 3853 | 3853 | case "move_to_trash": |
| 3854 | 3854 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 3855 | 3855 | $updateCache = true; |
| 3856 | - if(!empty($trashFolder)) { |
|
| 3856 | + if (!empty($trashFolder)) { |
|
| 3857 | 3857 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.implode(' : ', $_messageUID)); |
| 3858 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$trashFolder <= $_folder / ". $this->sessionData['mailbox']); |
|
| 3858 | + if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$trashFolder <= $_folder / ".$this->sessionData['mailbox']); |
|
| 3859 | 3859 | // copy messages |
| 3860 | 3860 | try |
| 3861 | 3861 | { |
| 3862 | - $this->icServer->copy($_folder, $trashFolder, array('ids'=>$uidsToDelete,'move'=>true)); |
|
| 3862 | + $this->icServer->copy($_folder, $trashFolder, array('ids'=>$uidsToDelete, 'move'=>true)); |
|
| 3863 | 3863 | } |
| 3864 | 3864 | catch (\Exception $e) |
| 3865 | 3865 | { |
@@ -3871,18 +3871,18 @@ discard block |
||
| 3871 | 3871 | case "mark_as_deleted": |
| 3872 | 3872 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 3873 | 3873 | // mark messages as deleted |
| 3874 | - if (is_null($_messageUID)) $_messageUID='all'; |
|
| 3875 | - foreach((array)$_messageUID as $key =>$uid) |
|
| 3874 | + if (is_null($_messageUID)) $_messageUID = 'all'; |
|
| 3875 | + foreach ((array)$_messageUID as $key =>$uid) |
|
| 3876 | 3876 | { |
| 3877 | 3877 | //flag messages, that are flagged for deletion as seen too |
| 3878 | 3878 | $this->flagMessages('read', $uid, $_folder); |
| 3879 | 3879 | $flags = $this->getFlags($uid); |
| 3880 | 3880 | $this->flagMessages('delete', $uid, $_folder); |
| 3881 | 3881 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($flags)); |
| 3882 | - if (strpos( array2string($flags),'Deleted')!==false) $undelete[] = $uid; |
|
| 3882 | + if (strpos(array2string($flags), 'Deleted') !== false) $undelete[] = $uid; |
|
| 3883 | 3883 | unset($flags); |
| 3884 | 3884 | } |
| 3885 | - foreach((array)$undelete as $key =>$uid) |
|
| 3885 | + foreach ((array)$undelete as $key =>$uid) |
|
| 3886 | 3886 | { |
| 3887 | 3887 | $this->flagMessages('undelete', $uid, $_folder); |
| 3888 | 3888 | } |
@@ -3891,14 +3891,14 @@ discard block |
||
| 3891 | 3891 | case "remove_immediately": |
| 3892 | 3892 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 3893 | 3893 | $updateCache = true; |
| 3894 | - if (is_null($_messageUID)) $_messageUID='all'; |
|
| 3894 | + if (is_null($_messageUID)) $_messageUID = 'all'; |
|
| 3895 | 3895 | if (is_object($_messageUID)) |
| 3896 | 3896 | { |
| 3897 | 3897 | $this->flagMessages('delete', $_messageUID, $_folder); |
| 3898 | 3898 | } |
| 3899 | 3899 | else |
| 3900 | 3900 | { |
| 3901 | - foreach((array)$_messageUID as $key =>$uid) |
|
| 3901 | + foreach ((array)$_messageUID as $key =>$uid) |
|
| 3902 | 3902 | { |
| 3903 | 3903 | //flag messages, that are flagged for deletion as seen too |
| 3904 | 3904 | $this->flagMessages('delete', $uid, $_folder); |
@@ -3908,7 +3908,7 @@ discard block |
||
| 3908 | 3908 | $this->icServer->expunge($_folder); |
| 3909 | 3909 | break; |
| 3910 | 3910 | } |
| 3911 | - if($oldMailbox != '') { |
|
| 3911 | + if ($oldMailbox != '') { |
|
| 3912 | 3912 | $this->icServer->openMailbox($oldMailbox); |
| 3913 | 3913 | } |
| 3914 | 3914 | |
@@ -3922,7 +3922,7 @@ discard block |
||
| 3922 | 3922 | * |
| 3923 | 3923 | * @return null/array flags |
| 3924 | 3924 | */ |
| 3925 | - function getFlags ($_messageUID) { |
|
| 3925 | + function getFlags($_messageUID) { |
|
| 3926 | 3926 | try |
| 3927 | 3927 | { |
| 3928 | 3928 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
@@ -3935,7 +3935,7 @@ discard block |
||
| 3935 | 3935 | 'ids' => $uidsToFetch, |
| 3936 | 3936 | )); |
| 3937 | 3937 | if (is_object($headersNew)) { |
| 3938 | - foreach($headersNew->ids() as $id) { |
|
| 3938 | + foreach ($headersNew->ids() as $id) { |
|
| 3939 | 3939 | $_headerObject = $headersNew->get($id); |
| 3940 | 3940 | $flags = $_headerObject->getFlags(); |
| 3941 | 3941 | } |
@@ -3958,22 +3958,22 @@ discard block |
||
| 3958 | 3958 | * |
| 3959 | 3959 | * @return null/boolean |
| 3960 | 3960 | */ |
| 3961 | - function getNotifyFlags ($_messageUID, $flags=null) |
|
| 3961 | + function getNotifyFlags($_messageUID, $flags = null) |
|
| 3962 | 3962 | { |
| 3963 | 3963 | if (self::$debug) error_log(__METHOD__.$_messageUID.' Flags:'.array2string($flags)); |
| 3964 | 3964 | try |
| 3965 | 3965 | { |
| 3966 | - if($flags===null) $flags = $this->getFlags($_messageUID); |
|
| 3966 | + if ($flags === null) $flags = $this->getFlags($_messageUID); |
|
| 3967 | 3967 | } |
| 3968 | 3968 | catch (\Exception $e) |
| 3969 | 3969 | { |
| 3970 | 3970 | return null; |
| 3971 | 3971 | } |
| 3972 | 3972 | |
| 3973 | - if ( stripos( array2string($flags),'MDNSent')!==false) |
|
| 3973 | + if (stripos(array2string($flags), 'MDNSent') !== false) |
|
| 3974 | 3974 | return true; |
| 3975 | 3975 | |
| 3976 | - if ( stripos( array2string($flags),'MDNnotSent')!==false) |
|
| 3976 | + if (stripos(array2string($flags), 'MDNnotSent') !== false) |
|
| 3977 | 3977 | return false; |
| 3978 | 3978 | |
| 3979 | 3979 | return null; |
@@ -3990,45 +3990,45 @@ discard block |
||
| 3990 | 3990 | * |
| 3991 | 3991 | * @return bool true, as we do not handle icserver->setFlags returnValue |
| 3992 | 3992 | */ |
| 3993 | - function flagMessages($_flag, $_messageUID,$_folder=NULL) |
|
| 3993 | + function flagMessages($_flag, $_messageUID, $_folder = NULL) |
|
| 3994 | 3994 | { |
| 3995 | 3995 | //error_log(__METHOD__.' ('.__LINE__.') '.'->' .$_flag." ".array2string($_messageUID).",$_folder /".$this->sessionData['mailbox']); |
| 3996 | 3996 | if (empty($_messageUID)) |
| 3997 | 3997 | { |
| 3998 | - if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID)); |
|
| 3998 | + if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',', $_messageUID)); |
|
| 3999 | 3999 | return false; |
| 4000 | 4000 | } |
| 4001 | - $this->icServer->openMailbox(($_folder?$_folder:$this->sessionData['mailbox'])); |
|
| 4001 | + $this->icServer->openMailbox(($_folder ? $_folder : $this->sessionData['mailbox'])); |
|
| 4002 | 4002 | $folder = $this->icServer->getCurrentMailbox(); |
| 4003 | - if (is_array($_messageUID)&& count($_messageUID)>50) |
|
| 4003 | + if (is_array($_messageUID) && count($_messageUID) > 50) |
|
| 4004 | 4004 | { |
| 4005 | - $count = $this->getMailBoxCounters($folder,true); |
|
| 4006 | - if ($count->messages == count($_messageUID)) $_messageUID='all'; |
|
| 4005 | + $count = $this->getMailBoxCounters($folder, true); |
|
| 4006 | + if ($count->messages == count($_messageUID)) $_messageUID = 'all'; |
|
| 4007 | 4007 | } |
| 4008 | 4008 | |
| 4009 | - if ($_messageUID==='all') |
|
| 4009 | + if ($_messageUID === 'all') |
|
| 4010 | 4010 | { |
| 4011 | 4011 | $messageUIDs = array('all'); |
| 4012 | 4012 | } |
| 4013 | 4013 | else |
| 4014 | 4014 | { |
| 4015 | 4015 | if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID; |
| 4016 | - $messageUIDs = array_chunk($_messageUID,50,true); |
|
| 4016 | + $messageUIDs = array_chunk($_messageUID, 50, true); |
|
| 4017 | 4017 | } |
| 4018 | 4018 | try |
| 4019 | 4019 | { |
| 4020 | - foreach($messageUIDs as &$uids) |
|
| 4020 | + foreach ($messageUIDs as &$uids) |
|
| 4021 | 4021 | { |
| 4022 | - if ($uids==='all') |
|
| 4022 | + if ($uids === 'all') |
|
| 4023 | 4023 | { |
| 4024 | - $uidsToModify=null; |
|
| 4024 | + $uidsToModify = null; |
|
| 4025 | 4025 | } |
| 4026 | 4026 | else |
| 4027 | 4027 | { |
| 4028 | 4028 | $uidsToModify = new Horde_Imap_Client_Ids(); |
| 4029 | 4029 | $uidsToModify->add($uids); |
| 4030 | 4030 | } |
| 4031 | - switch($_flag) { |
|
| 4031 | + switch ($_flag) { |
|
| 4032 | 4032 | case "delete": |
| 4033 | 4033 | $ret = $this->icServer->store($folder, array('add'=>array('\\Deleted'), 'ids'=> $uidsToModify)); |
| 4034 | 4034 | break; |
@@ -4052,7 +4052,7 @@ discard block |
||
| 4052 | 4052 | break; |
| 4053 | 4053 | case "unread": |
| 4054 | 4054 | case "unseen": |
| 4055 | - $ret = $this->icServer->store($folder, array('remove'=>array('\\Seen','\\Answered','$Forwarded'), 'ids'=> $uidsToModify)); |
|
| 4055 | + $ret = $this->icServer->store($folder, array('remove'=>array('\\Seen', '\\Answered', '$Forwarded'), 'ids'=> $uidsToModify)); |
|
| 4056 | 4056 | break; |
| 4057 | 4057 | case "mdnsent": |
| 4058 | 4058 | $ret = $this->icServer->store($folder, array('add'=>array('MDNSent'), 'ids'=> $uidsToModify)); |
@@ -4110,13 +4110,13 @@ discard block |
||
| 4110 | 4110 | } |
| 4111 | 4111 | } |
| 4112 | 4112 | } |
| 4113 | - catch(Exception $e) |
|
| 4113 | + catch (Exception $e) |
|
| 4114 | 4114 | { |
| 4115 | 4115 | error_log(__METHOD__.__LINE__.' Error, could not flag messages in folder '.$folder.' Reason:'.$e->getMessage()); |
| 4116 | 4116 | } |
| 4117 | 4117 | if ($folder instanceof Horde_Imap_Client_Mailbox) $_folder = $folder->utf8; |
| 4118 | 4118 | //error_log(__METHOD__.__LINE__.'#'.$this->icServer->ImapServerId.'#'.array2string($_folder).'#'); |
| 4119 | - self::$folderStatusCache[$this->icServer->ImapServerId][(!empty($_folder)?$_folder: $this->sessionData['mailbox'])]['uidValidity'] = 0; |
|
| 4119 | + self::$folderStatusCache[$this->icServer->ImapServerId][(!empty($_folder) ? $_folder : $this->sessionData['mailbox'])]['uidValidity'] = 0; |
|
| 4120 | 4120 | |
| 4121 | 4121 | //error_log(__METHOD__.' ('.__LINE__.') '.'->' .$_flag." ".array2string($_messageUID).",".($_folder?$_folder:$this->sessionData['mailbox'])); |
| 4122 | 4122 | return true; // as we do not catch/examine setFlags returnValue |
@@ -4137,19 +4137,19 @@ discard block |
||
| 4137 | 4137 | * @return mixed/bool true,false or new uid |
| 4138 | 4138 | * @throws Exception |
| 4139 | 4139 | */ |
| 4140 | - function moveMessages($_foldername, $_messageUID, $deleteAfterMove=true, $currentFolder = Null, $returnUIDs = false, $_sourceProfileID = Null, $_targetProfileID = Null) |
|
| 4140 | + function moveMessages($_foldername, $_messageUID, $deleteAfterMove = true, $currentFolder = Null, $returnUIDs = false, $_sourceProfileID = Null, $_targetProfileID = Null) |
|
| 4141 | 4141 | { |
| 4142 | - $source = Mail\Account::read(($_sourceProfileID?$_sourceProfileID:$this->icServer->ImapServerId))->imapServer(); |
|
| 4142 | + $source = Mail\Account::read(($_sourceProfileID ? $_sourceProfileID : $this->icServer->ImapServerId))->imapServer(); |
|
| 4143 | 4143 | //$deleteOptions = $GLOBALS['egw_info']["user"]["preferences"]["mail"]["deleteOptions"]; |
| 4144 | 4144 | if (empty($_messageUID)) |
| 4145 | 4145 | { |
| 4146 | - if (self::$debug) error_log(__METHOD__." no Message(s): ".implode(',',$_messageUID)); |
|
| 4146 | + if (self::$debug) error_log(__METHOD__." no Message(s): ".implode(',', $_messageUID)); |
|
| 4147 | 4147 | return false; |
| 4148 | 4148 | } |
| 4149 | - elseif ($_messageUID==='all') |
|
| 4149 | + elseif ($_messageUID === 'all') |
|
| 4150 | 4150 | { |
| 4151 | 4151 | //error_log(__METHOD__." all Message(s): ".implode(',',$_messageUID)); |
| 4152 | - $uidsToMove= null; |
|
| 4152 | + $uidsToMove = null; |
|
| 4153 | 4153 | } |
| 4154 | 4154 | else |
| 4155 | 4155 | { |
@@ -4158,7 +4158,7 @@ discard block |
||
| 4158 | 4158 | if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID; |
| 4159 | 4159 | $uidsToMove->add($_messageUID); |
| 4160 | 4160 | } |
| 4161 | - $sourceFolder = (!empty($currentFolder)?$currentFolder: $this->sessionData['mailbox']); |
|
| 4161 | + $sourceFolder = (!empty($currentFolder) ? $currentFolder : $this->sessionData['mailbox']); |
|
| 4162 | 4162 | //error_log(__METHOD__.__LINE__."$_targetProfileID !== ".array2string($source->ImapServerId)); |
| 4163 | 4163 | if (!is_null($_targetProfileID) && $_targetProfileID !== $source->ImapServerId) |
| 4164 | 4164 | { |
@@ -4178,19 +4178,19 @@ discard block |
||
| 4178 | 4178 | //error_log(__METHOD__.' ('.__LINE__.') '.' Sourceserver:'.$source->ImapServerId.' mailheaders:'.array2string($headersNew)); |
| 4179 | 4179 | |
| 4180 | 4180 | if (is_object($headersNew)) { |
| 4181 | - $c=0; |
|
| 4181 | + $c = 0; |
|
| 4182 | 4182 | $retUid = new Horde_Imap_Client_Ids(); |
| 4183 | 4183 | // we copy chunks of 5 to avoid too much memory and/or server stress |
| 4184 | 4184 | // some servers seem not to allow/support the appendig of multiple messages. so we are down to one |
| 4185 | - foreach($headersNew as &$_headerObject) { |
|
| 4185 | + foreach ($headersNew as &$_headerObject) { |
|
| 4186 | 4186 | $c++; |
| 4187 | 4187 | $flags = $_headerObject->getFlags(); //unseen status seems to be lost when retrieving the full message |
| 4188 | 4188 | $date = $_headerObject->getImapDate(); |
| 4189 | - $currentDate = new Horde_Imap_Client_DateTime(); |
|
| 4189 | + $currentDate = new Horde_Imap_Client_DateTime(); |
|
| 4190 | 4190 | // if the internal Date of the message equals the current date; try using the header date |
| 4191 | - if ($date==$currentDate) |
|
| 4191 | + if ($date == $currentDate) |
|
| 4192 | 4192 | { |
| 4193 | - $headerForPrio = array_change_key_case($_headerObject->getHeaderText(0,Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(), CASE_UPPER); |
|
| 4193 | + $headerForPrio = array_change_key_case($_headerObject->getHeaderText(0, Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(), CASE_UPPER); |
|
| 4194 | 4194 | //error_log(__METHOD__.__LINE__.'#'.array2string($date).'#'.array2string($currentDate).'#'.$headerForPrio['DATE']); |
| 4195 | 4195 | $date = new Horde_Imap_Client_DateTime($headerForPrio['DATE']); |
| 4196 | 4196 | //error_log(__METHOD__.__LINE__.'#'.array2string($date).'#'.array2string($currentDate).'#'); |
@@ -4199,20 +4199,20 @@ discard block |
||
| 4199 | 4199 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($flags)); |
| 4200 | 4200 | $body = $_headerObject->getFullMsg(); |
| 4201 | 4201 | $dataNflags[] = array('data'=>$body, 'flags'=>$flags, 'internaldate'=>$date); |
| 4202 | - if ($c==1) |
|
| 4202 | + if ($c == 1) |
|
| 4203 | 4203 | { |
| 4204 | 4204 | $target = Mail\Account::read($_targetProfileID)->imapServer(); |
| 4205 | 4205 | //error_log(__METHOD__.' ('.__LINE__.') '.' Sourceserver:'.$source->ImapServerId.' TargetServer:'.$_targetProfileID.' TargetFolderObject:'.array2string($_foldername)); |
| 4206 | 4206 | $foldername = $target->getMailbox($_foldername); |
| 4207 | 4207 | // make sure the target folder is open and ready |
| 4208 | 4208 | $target->openMailbox($foldername); |
| 4209 | - $ret = $target->append($foldername,$dataNflags); |
|
| 4209 | + $ret = $target->append($foldername, $dataNflags); |
|
| 4210 | 4210 | $retUid->add($ret); |
| 4211 | 4211 | unset($dataNflags); |
| 4212 | 4212 | // sleep 500 miliseconds; AS some sERVERs seem not to be capable of the load this is |
| 4213 | 4213 | // inflicting in them. they "reply" with an unspecific IMAP Error |
| 4214 | - time_nanosleep(0,500000); |
|
| 4215 | - $c=0; |
|
| 4214 | + time_nanosleep(0, 500000); |
|
| 4215 | + $c = 0; |
|
| 4216 | 4216 | } |
| 4217 | 4217 | } |
| 4218 | 4218 | if (isset($dataNflags)) |
@@ -4222,7 +4222,7 @@ discard block |
||
| 4222 | 4222 | $foldername = $target->getMailbox($_foldername); |
| 4223 | 4223 | // make sure the target folder is open and ready |
| 4224 | 4224 | $target->openMailbox($foldername); |
| 4225 | - $ret = $target->append($foldername,$dataNflags); |
|
| 4225 | + $ret = $target->append($foldername, $dataNflags); |
|
| 4226 | 4226 | $retUid->add($ret); |
| 4227 | 4227 | unset($dataNflags); |
| 4228 | 4228 | } |
@@ -4233,7 +4233,7 @@ discard block |
||
| 4233 | 4233 | { |
| 4234 | 4234 | $remember = $this->icServer; |
| 4235 | 4235 | $this->icServer = $source; |
| 4236 | - $this->deleteMessages($_messageUID, $sourceFolder, $_forceDeleteMethod='remove_immediately'); |
|
| 4236 | + $this->deleteMessages($_messageUID, $sourceFolder, $_forceDeleteMethod = 'remove_immediately'); |
|
| 4237 | 4237 | $this->icServer = $remember; |
| 4238 | 4238 | } |
| 4239 | 4239 | } |
@@ -4242,7 +4242,7 @@ discard block |
||
| 4242 | 4242 | { |
| 4243 | 4243 | try |
| 4244 | 4244 | { |
| 4245 | - $retUid = $source->copy($sourceFolder, $_foldername, array('ids'=>$uidsToMove,'move'=>$deleteAfterMove)); |
|
| 4245 | + $retUid = $source->copy($sourceFolder, $_foldername, array('ids'=>$uidsToMove, 'move'=>$deleteAfterMove)); |
|
| 4246 | 4246 | } |
| 4247 | 4247 | catch (exception $e) |
| 4248 | 4248 | { |
@@ -4262,19 +4262,19 @@ discard block |
||
| 4262 | 4262 | * @param string $format ='' if none is passed, use user prefs |
| 4263 | 4263 | * @return string returns the date as it is parseable by strtotime, or current timestamp if everything fails |
| 4264 | 4264 | */ |
| 4265 | - static function _strtotime($_date='', $format='', $convert2usertime=false) |
|
| 4265 | + static function _strtotime($_date = '', $format = '', $convert2usertime = false) |
|
| 4266 | 4266 | { |
| 4267 | 4267 | try { |
| 4268 | - $date = new DateTime($_date); // parse date & time including timezone (throws exception, if not parsable) |
|
| 4269 | - if ($convert2usertime) $date->setUser(); // convert to user-time |
|
| 4268 | + $date = new DateTime($_date); // parse date & time including timezone (throws exception, if not parsable) |
|
| 4269 | + if ($convert2usertime) $date->setUser(); // convert to user-time |
|
| 4270 | 4270 | $date2return = $date->format($format); |
| 4271 | 4271 | } |
| 4272 | - catch(\Exception $e) |
|
| 4272 | + catch (\Exception $e) |
|
| 4273 | 4273 | { |
| 4274 | - unset($e); // not used |
|
| 4274 | + unset($e); // not used |
|
| 4275 | 4275 | |
| 4276 | 4276 | // remove last space-separated part and retry |
| 4277 | - $parts = explode(' ',$_date); |
|
| 4277 | + $parts = explode(' ', $_date); |
|
| 4278 | 4278 | if (count($parts) > 1) |
| 4279 | 4279 | { |
| 4280 | 4280 | array_pop($parts); |
@@ -4295,12 +4295,12 @@ discard block |
||
| 4295 | 4295 | * @param mixed $_charset false or string -> Target charset, if false Mail displayCharset will be used |
| 4296 | 4296 | * @return string |
| 4297 | 4297 | */ |
| 4298 | - static function htmlentities($_string, $_charset=false) |
|
| 4298 | + static function htmlentities($_string, $_charset = false) |
|
| 4299 | 4299 | { |
| 4300 | 4300 | //setting the charset (if not given) |
| 4301 | - if ($_charset===false) $_charset = self::$displayCharset; |
|
| 4301 | + if ($_charset === false) $_charset = self::$displayCharset; |
|
| 4302 | 4302 | $string = @htmlentities($_string, ENT_QUOTES, $_charset, false); |
| 4303 | - if (empty($string) && !empty($_string)) $string = @htmlentities(Translation::convert($_string,Translation::detect_encoding($_string),$_charset),ENT_QUOTES | ENT_IGNORE,$_charset, false); |
|
| 4303 | + if (empty($string) && !empty($_string)) $string = @htmlentities(Translation::convert($_string, Translation::detect_encoding($_string), $_charset), ENT_QUOTES|ENT_IGNORE, $_charset, false); |
|
| 4304 | 4304 | return $string; |
| 4305 | 4305 | } |
| 4306 | 4306 | |
@@ -4317,21 +4317,21 @@ discard block |
||
| 4317 | 4317 | //$_html = str_replace("\t",' ',$_html); |
| 4318 | 4318 | //error_log(__METHOD__.__LINE__.':'.$_html); |
| 4319 | 4319 | //repair doubleencoded ampersands, and some stuff htmLawed stumbles upon with balancing switched on |
| 4320 | - $_html = str_replace(array('&amp;','<DIV><BR></DIV>',"<DIV> </DIV>",'<div> </div>','</td></font>','<br><td>','<tr></tr>','<o:p></o:p>','<o:p>','</o:p>'), |
|
| 4321 | - array('&', '<BR>', '<BR>', '<BR>', '</font></td>','<td>', '', '', '', ''),$_html); |
|
| 4320 | + $_html = str_replace(array('&amp;', '<DIV><BR></DIV>', "<DIV> </DIV>", '<div> </div>', '</td></font>', '<br><td>', '<tr></tr>', '<o:p></o:p>', '<o:p>', '</o:p>'), |
|
| 4321 | + array('&', '<BR>', '<BR>', '<BR>', '</font></td>', '<td>', '', '', '', ''), $_html); |
|
| 4322 | 4322 | //$_html = str_replace(array('&amp;'),array('&'),$_html); |
| 4323 | - if (stripos($_html,'style')!==false) Mail\Html::replaceTagsCompletley($_html,'style'); // clean out empty or pagewide style definitions / left over tags |
|
| 4324 | - if (stripos($_html,'head')!==false) Mail\Html::replaceTagsCompletley($_html,'head'); // Strip out stuff in head |
|
| 4323 | + if (stripos($_html, 'style') !== false) Mail\Html::replaceTagsCompletley($_html, 'style'); // clean out empty or pagewide style definitions / left over tags |
|
| 4324 | + if (stripos($_html, 'head') !== false) Mail\Html::replaceTagsCompletley($_html, 'head'); // Strip out stuff in head |
|
| 4325 | 4325 | //if (stripos($_html,'![if')!==false && stripos($_html,'<![endif]>')!==false) Mail\Html::replaceTagsCompletley($_html,'!\[if','<!\[endif\]>',false); // Strip out stuff in ifs |
| 4326 | 4326 | //if (stripos($_html,'!--[if')!==false && stripos($_html,'<![endif]-->')!==false) Mail\Html::replaceTagsCompletley($_html,'!--\[if','<!\[endif\]-->',false); // Strip out stuff in ifs |
| 4327 | 4327 | //error_log(__METHOD__.' ('.__LINE__.') '.$_html); |
| 4328 | 4328 | |
| 4329 | 4329 | if (get_magic_quotes_gpc() === 1) $_html = stripslashes($_html); |
| 4330 | 4330 | // Strip out doctype in head, as htmlLawed cannot handle it TODO: Consider extracting it and adding it afterwards |
| 4331 | - if (stripos($_html,'!doctype')!==false) Mail\Html::replaceTagsCompletley($_html,'!doctype'); |
|
| 4332 | - if (stripos($_html,'?xml:namespace')!==false) Mail\Html::replaceTagsCompletley($_html,'\?xml:namespace','/>',false); |
|
| 4333 | - if (stripos($_html,'?xml version')!==false) Mail\Html::replaceTagsCompletley($_html,'\?xml version','\?>',false); |
|
| 4334 | - if (strpos($_html,'!CURSOR')!==false) Mail\Html::replaceTagsCompletley($_html,'!CURSOR'); |
|
| 4331 | + if (stripos($_html, '!doctype') !== false) Mail\Html::replaceTagsCompletley($_html, '!doctype'); |
|
| 4332 | + if (stripos($_html, '?xml:namespace') !== false) Mail\Html::replaceTagsCompletley($_html, '\?xml:namespace', '/>', false); |
|
| 4333 | + if (stripos($_html, '?xml version') !== false) Mail\Html::replaceTagsCompletley($_html, '\?xml version', '\?>', false); |
|
| 4334 | + if (strpos($_html, '!CURSOR') !== false) Mail\Html::replaceTagsCompletley($_html, '!CURSOR'); |
|
| 4335 | 4335 | // htmLawed filter only the 'body' |
| 4336 | 4336 | //preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $_html, $matches); |
| 4337 | 4337 | //if ($matches[2]) |
@@ -4342,16 +4342,16 @@ discard block |
||
| 4342 | 4342 | // purify got switched to htmLawed |
| 4343 | 4343 | // some testcode to test purifying / htmlawed |
| 4344 | 4344 | //$_html = "<BLOCKQUOTE>hi <div> there </div> kram <br> </blockquote>".$_html; |
| 4345 | - $_html = Html\HtmLawed::purify($_html,self::$htmLawed_config,array(),true); |
|
| 4345 | + $_html = Html\HtmLawed::purify($_html, self::$htmLawed_config, array(), true); |
|
| 4346 | 4346 | //if ($hasOther) $_html = $matches[1]. $_html. $matches[3]; |
| 4347 | 4347 | // clean out comments , should not be needed as purify should do the job. |
| 4348 | 4348 | $search = array( |
| 4349 | - '@url\(http:\/\/[^\)].*?\)@si', // url calls e.g. in style definitions |
|
| 4350 | - '@<!--[\s\S]*?[ \t\n\r]*-->@', // Strip multi-line comments including CDATA |
|
| 4349 | + '@url\(http:\/\/[^\)].*?\)@si', // url calls e.g. in style definitions |
|
| 4350 | + '@<!--[\s\S]*?[ \t\n\r]*-->@', // Strip multi-line comments including CDATA |
|
| 4351 | 4351 | ); |
| 4352 | - $_html = preg_replace($search,"",$_html); |
|
| 4352 | + $_html = preg_replace($search, "", $_html); |
|
| 4353 | 4353 | // remove non printable chars |
| 4354 | - $_html = preg_replace('/([\000-\011])/','',$_html); |
|
| 4354 | + $_html = preg_replace('/([\000-\011])/', '', $_html); |
|
| 4355 | 4355 | //error_log(__METHOD__.':'.__LINE__.':'.$_html); |
| 4356 | 4356 | } |
| 4357 | 4357 | |
@@ -4368,12 +4368,12 @@ discard block |
||
| 4368 | 4368 | function getMimePartCharset($_mimePartObject) |
| 4369 | 4369 | { |
| 4370 | 4370 | //$charSet = 'iso-8859-1';//self::$displayCharset; //'iso-8859-1'; // self::displayCharset seems to be asmarter fallback than iso-8859-1 |
| 4371 | - $CharsetFound=false; |
|
| 4371 | + $CharsetFound = false; |
|
| 4372 | 4372 | //echo "#".$_mimePartObject->encoding.'#<br>'; |
| 4373 | - if(is_array($_mimePartObject->parameters)) { |
|
| 4374 | - if(isset($_mimePartObject->parameters['CHARSET'])) { |
|
| 4373 | + if (is_array($_mimePartObject->parameters)) { |
|
| 4374 | + if (isset($_mimePartObject->parameters['CHARSET'])) { |
|
| 4375 | 4375 | $charSet = $_mimePartObject->parameters['CHARSET']; |
| 4376 | - $CharsetFound=true; |
|
| 4376 | + $CharsetFound = true; |
|
| 4377 | 4377 | } |
| 4378 | 4378 | } |
| 4379 | 4379 | // this one is dirty, but until I find something that does the trick of detecting the encoding, .... |
@@ -4392,7 +4392,7 @@ discard block |
||
| 4392 | 4392 | function decodeMimePart($_mimeMessage, $_encoding, $_charset = '') |
| 4393 | 4393 | { |
| 4394 | 4394 | // decode the part |
| 4395 | - if (self::$debug) error_log(__METHOD__."() with $_encoding and $_charset:".print_r($_mimeMessage,true)); |
|
| 4395 | + if (self::$debug) error_log(__METHOD__."() with $_encoding and $_charset:".print_r($_mimeMessage, true)); |
|
| 4396 | 4396 | switch (strtoupper($_encoding)) |
| 4397 | 4397 | { |
| 4398 | 4398 | case 'BASE64': |
@@ -4432,10 +4432,10 @@ discard block |
||
| 4432 | 4432 | // sometimes there are 3 parts, when there is an ics/ical attached/included-> we want to show that |
| 4433 | 4433 | // as attachment AND as abstracted ical information (we use our notification style here). |
| 4434 | 4434 | $partText = $partCalendar = $partHTML = null; |
| 4435 | - if (self::$debug) _debug_array(array("METHOD"=>__METHOD__,"LINE"=>__LINE__,"STRUCTURE"=>$_structure)); |
|
| 4435 | + if (self::$debug) _debug_array(array("METHOD"=>__METHOD__, "LINE"=>__LINE__, "STRUCTURE"=>$_structure)); |
|
| 4436 | 4436 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 4437 | 4437 | $ignore_first_part = true; |
| 4438 | - foreach($_structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 4438 | + foreach ($_structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 4439 | 4439 | { |
| 4440 | 4440 | //error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") $mime_id: $mime_type"." ignoreFirstPart:".$ignore_first_part); |
| 4441 | 4441 | if (self::$debug) echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>"; |
@@ -4443,15 +4443,15 @@ discard block |
||
| 4443 | 4443 | if ($ignore_first_part) |
| 4444 | 4444 | { |
| 4445 | 4445 | $ignore_first_part = false; |
| 4446 | - continue; // ignore multipart/alternative itself |
|
| 4446 | + continue; // ignore multipart/alternative itself |
|
| 4447 | 4447 | } |
| 4448 | 4448 | |
| 4449 | 4449 | $mimePart = $_structure->getPart($mime_id); |
| 4450 | 4450 | |
| 4451 | - switch($mimePart->getPrimaryType()) |
|
| 4451 | + switch ($mimePart->getPrimaryType()) |
|
| 4452 | 4452 | { |
| 4453 | 4453 | case 'text': |
| 4454 | - switch($mimePart->getSubType()) |
|
| 4454 | + switch ($mimePart->getSubType()) |
|
| 4455 | 4455 | { |
| 4456 | 4456 | case 'plain': |
| 4457 | 4457 | if ($mimePart->getBytes() > 0) $partText = $mimePart; |
@@ -4464,7 +4464,7 @@ discard block |
||
| 4464 | 4464 | break; |
| 4465 | 4465 | |
| 4466 | 4466 | case 'multipart': |
| 4467 | - switch($mimePart->getSubType()) |
|
| 4467 | + switch ($mimePart->getSubType()) |
|
| 4468 | 4468 | { |
| 4469 | 4469 | case 'related': |
| 4470 | 4470 | case 'mixed': |
@@ -4486,13 +4486,13 @@ discard block |
||
| 4486 | 4486 | } |
| 4487 | 4487 | } |
| 4488 | 4488 | |
| 4489 | - switch($_htmlMode) |
|
| 4489 | + switch ($_htmlMode) |
|
| 4490 | 4490 | { |
| 4491 | 4491 | case 'html_only': |
| 4492 | 4492 | case 'always_display': |
| 4493 | 4493 | if ($partHTML) |
| 4494 | 4494 | { |
| 4495 | - switch($partHTML->getSubType()) |
|
| 4495 | + switch ($partHTML->getSubType()) |
|
| 4496 | 4496 | { |
| 4497 | 4497 | case 'related': |
| 4498 | 4498 | return $this->getMultipartRelated($_uid, $partHTML, $_htmlMode, $_preserveSeen); |
@@ -4504,7 +4504,7 @@ discard block |
||
| 4504 | 4504 | return $this->getTextPart($_uid, $partHTML, $_htmlMode, $_preserveSeen); |
| 4505 | 4505 | } |
| 4506 | 4506 | } |
| 4507 | - elseif ($partText && $_htmlMode=='always_display') |
|
| 4507 | + elseif ($partText && $_htmlMode == 'always_display') |
|
| 4508 | 4508 | { |
| 4509 | 4509 | return $this->getTextPart($_uid, $partText, $_htmlMode, $_preserveSeen); |
| 4510 | 4510 | } |
@@ -4550,7 +4550,7 @@ discard block |
||
| 4550 | 4550 | * @param array &$skipParts - passed by reference to have control/knowledge which parts are already fetched |
| 4551 | 4551 | * @return array containing the desired part |
| 4552 | 4552 | */ |
| 4553 | - function getMultipartMixed($_uid, Horde_Mime_Part $_structure, $_htmlMode, $_preserveSeen = false, &$skipParts=array()) |
|
| 4553 | + function getMultipartMixed($_uid, Horde_Mime_Part $_structure, $_htmlMode, $_preserveSeen = false, &$skipParts = array()) |
|
| 4554 | 4554 | { |
| 4555 | 4555 | if (self::$debug) echo __METHOD__."$_uid, $_htmlMode<br>"; |
| 4556 | 4556 | $bodyPart = array(); |
@@ -4559,7 +4559,7 @@ discard block |
||
| 4559 | 4559 | $ignore_first_part = true; |
| 4560 | 4560 | //$skipParts = array(); |
| 4561 | 4561 | //error_log(__METHOD__.__LINE__.array2string($_structure->contentTypeMap())); |
| 4562 | - foreach($_structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 4562 | + foreach ($_structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 4563 | 4563 | { |
| 4564 | 4564 | //error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") $mime_id: $mime_type"); |
| 4565 | 4565 | if (self::$debug) echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>"; |
@@ -4567,9 +4567,9 @@ discard block |
||
| 4567 | 4567 | { |
| 4568 | 4568 | $ignore_first_part = false; |
| 4569 | 4569 | //error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") SKIPPED FirstPart $mime_id: $mime_type"); |
| 4570 | - continue; // ignore multipart/mixed itself |
|
| 4570 | + continue; // ignore multipart/mixed itself |
|
| 4571 | 4571 | } |
| 4572 | - if (array_key_exists($mime_id,$skipParts)) |
|
| 4572 | + if (array_key_exists($mime_id, $skipParts)) |
|
| 4573 | 4573 | { |
| 4574 | 4574 | //error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") SKIPPED $mime_id: $mime_type"); |
| 4575 | 4575 | continue; |
@@ -4577,11 +4577,11 @@ discard block |
||
| 4577 | 4577 | |
| 4578 | 4578 | $part = $_structure->getPart($mime_id); |
| 4579 | 4579 | |
| 4580 | - switch($part->getPrimaryType()) |
|
| 4580 | + switch ($part->getPrimaryType()) |
|
| 4581 | 4581 | { |
| 4582 | 4582 | case 'multipart': |
| 4583 | 4583 | if ($part->getDisposition() == 'attachment') continue; |
| 4584 | - switch($part->getSubType()) |
|
| 4584 | + switch ($part->getSubType()) |
|
| 4585 | 4585 | { |
| 4586 | 4586 | case 'alternative': |
| 4587 | 4587 | return array($this->getMultipartAlternative($_uid, $part, $_htmlMode, $_preserveSeen)); |
@@ -4597,15 +4597,15 @@ discard block |
||
| 4597 | 4597 | } |
| 4598 | 4598 | break; |
| 4599 | 4599 | case 'application': |
| 4600 | - switch($part->getSubType()) |
|
| 4600 | + switch ($part->getSubType()) |
|
| 4601 | 4601 | { |
| 4602 | 4602 | case 'pgp-encrypted': |
| 4603 | - if (($part = $_structure->getPart($mime_id+1)) && |
|
| 4603 | + if (($part = $_structure->getPart($mime_id + 1)) && |
|
| 4604 | 4604 | $part->getType() == 'application/octet-stream') |
| 4605 | 4605 | { |
| 4606 | 4606 | $this->fetchPartContents($_uid, $part); |
| 4607 | - $skipParts[$mime_id]=$mime_type; |
|
| 4608 | - $skipParts[$mime_id+1]=$part->getType(); |
|
| 4607 | + $skipParts[$mime_id] = $mime_type; |
|
| 4608 | + $skipParts[$mime_id + 1] = $part->getType(); |
|
| 4609 | 4609 | $bodyPart[] = array( |
| 4610 | 4610 | 'body' => $part->getContents(array( |
| 4611 | 4611 | 'stream' => false, |
@@ -4619,15 +4619,15 @@ discard block |
||
| 4619 | 4619 | break; |
| 4620 | 4620 | |
| 4621 | 4621 | case 'text': |
| 4622 | - switch($part->getSubType()) |
|
| 4622 | + switch ($part->getSubType()) |
|
| 4623 | 4623 | { |
| 4624 | 4624 | case 'plain': |
| 4625 | 4625 | case 'html': |
| 4626 | 4626 | case 'calendar': // inline ics/ical files |
| 4627 | - if($part->getDisposition() != 'attachment') |
|
| 4627 | + if ($part->getDisposition() != 'attachment') |
|
| 4628 | 4628 | { |
| 4629 | 4629 | $bodyPart[] = $this->getTextPart($_uid, $part, $_htmlMode, $_preserveSeen); |
| 4630 | - $skipParts[$mime_id]=$mime_type; |
|
| 4630 | + $skipParts[$mime_id] = $mime_type; |
|
| 4631 | 4631 | } |
| 4632 | 4632 | //error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$part->type."/".$part->subType.' -> BodyPart:'.array2string($bodyPart[count($bodyPart)-1])); |
| 4633 | 4633 | break; |
@@ -4636,16 +4636,16 @@ discard block |
||
| 4636 | 4636 | |
| 4637 | 4637 | case 'message': |
| 4638 | 4638 | //skip attachments |
| 4639 | - if($part->getSubType() == 'delivery-status' && $part->getDisposition() != 'attachment') |
|
| 4639 | + if ($part->getSubType() == 'delivery-status' && $part->getDisposition() != 'attachment') |
|
| 4640 | 4640 | { |
| 4641 | 4641 | $bodyPart[] = $this->getTextPart($_uid, $part, $_htmlMode, $_preserveSeen); |
| 4642 | - $skipParts[$mime_id]=$mime_type; |
|
| 4642 | + $skipParts[$mime_id] = $mime_type; |
|
| 4643 | 4643 | } |
| 4644 | 4644 | // do not descend into attached Messages |
| 4645 | - if($part->getSubType() == 'rfc822' || $part->getDisposition() == 'attachment') |
|
| 4645 | + if ($part->getSubType() == 'rfc822' || $part->getDisposition() == 'attachment') |
|
| 4646 | 4646 | { |
| 4647 | 4647 | $skipParts[$mime_id.'.0'] = $mime_type; |
| 4648 | - foreach($part->contentTypeMap() as $sub_id => $sub_type){ $skipParts[$sub_id] = $sub_type;} |
|
| 4648 | + foreach ($part->contentTypeMap() as $sub_id => $sub_type) { $skipParts[$sub_id] = $sub_type; } |
|
| 4649 | 4649 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$_uid.' Part:'.$mime_id.':'.array2string($skipParts)); |
| 4650 | 4650 | //break 2; |
| 4651 | 4651 | } |
@@ -4686,13 +4686,13 @@ discard block |
||
| 4686 | 4686 | * @param boolean $_tryDecodingServerside = true; wether to try to fetch Data with BINARY instead of BODY |
| 4687 | 4687 | * @return string|resource |
| 4688 | 4688 | */ |
| 4689 | - function getBodyPart($_uid, $_partID=null, $_folder=null, $_preserveSeen=false, $_stream=false, &$_encoding=null, $_tryDecodingServerside=true) |
|
| 4689 | + function getBodyPart($_uid, $_partID = null, $_folder = null, $_preserveSeen = false, $_stream = false, &$_encoding = null, $_tryDecodingServerside = true) |
|
| 4690 | 4690 | { |
| 4691 | - if (self::$debug) error_log( __METHOD__.__LINE__."(".array2string($_uid).", $_partID, $_folder, $_preserveSeen, $_stream, $_encoding, $_tryDecodingServerside)"); |
|
| 4691 | + if (self::$debug) error_log(__METHOD__.__LINE__."(".array2string($_uid).", $_partID, $_folder, $_preserveSeen, $_stream, $_encoding, $_tryDecodingServerside)"); |
|
| 4692 | 4692 | |
| 4693 | 4693 | if (empty($_folder)) |
| 4694 | 4694 | { |
| 4695 | - $_folder = (isset($this->sessionData['mailbox'])&&$this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 4695 | + $_folder = (isset($this->sessionData['mailbox']) && $this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 4696 | 4696 | } |
| 4697 | 4697 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_folder).'/'.$this->icServer->getCurrentMailbox().'/'. $this->sessionData['mailbox']); |
| 4698 | 4698 | // querying contents of body part |
@@ -4703,11 +4703,11 @@ discard block |
||
| 4703 | 4703 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
| 4704 | 4704 | $fetchParams = array( |
| 4705 | 4705 | 'peek' => $_preserveSeen, |
| 4706 | - 'decode' => true, // try decode on server, does NOT neccessary work |
|
| 4706 | + 'decode' => true, // try decode on server, does NOT neccessary work |
|
| 4707 | 4707 | ); |
| 4708 | - if ($_tryDecodingServerside===false)// || ($_tryDecodingServerside&&$this->isDraftFolder($_folder))) |
|
| 4708 | + if ($_tryDecodingServerside === false)// || ($_tryDecodingServerside&&$this->isDraftFolder($_folder))) |
|
| 4709 | 4709 | { |
| 4710 | - $_tryDecodingServerside=false; |
|
| 4710 | + $_tryDecodingServerside = false; |
|
| 4711 | 4711 | $fetchParams = array( |
| 4712 | 4712 | 'peek' => $_preserveSeen, |
| 4713 | 4713 | ); |
@@ -4727,12 +4727,12 @@ discard block |
||
| 4727 | 4727 | } |
| 4728 | 4728 | // if we get an empty result, server may have trouble fetching data with UID FETCH $_uid (BINARY.PEEK[$_partID]) |
| 4729 | 4729 | // thus we trigger a second go with UID FETCH $_uid (BODY.PEEK[$_partID]) |
| 4730 | - if (empty($partToReturn)&&$_tryDecodingServerside===true) |
|
| 4730 | + if (empty($partToReturn) && $_tryDecodingServerside === true) |
|
| 4731 | 4731 | { |
| 4732 | 4732 | error_log(__METHOD__.__LINE__.' failed to fetch bodyPart in BINARY. Try BODY'); |
| 4733 | 4733 | $partToReturn = $this->getBodyPart($_uid, $_partID, $_folder, $_preserveSeen, $_stream, $_encoding, false); |
| 4734 | 4734 | } |
| 4735 | - return ($partToReturn?$partToReturn:null); |
|
| 4735 | + return ($partToReturn ? $partToReturn : null); |
|
| 4736 | 4736 | } |
| 4737 | 4737 | |
| 4738 | 4738 | /** |
@@ -4745,13 +4745,13 @@ discard block |
||
| 4745 | 4745 | * @param boolean $_stream = false true return a stream, false return string |
| 4746 | 4746 | * @return array containing the desired text part, mimeType and charset |
| 4747 | 4747 | */ |
| 4748 | - function getTextPart($_uid, Horde_Mime_Part $_structure, $_htmlMode='', $_preserveSeen=false, $_stream=false) |
|
| 4748 | + function getTextPart($_uid, Horde_Mime_Part $_structure, $_htmlMode = '', $_preserveSeen = false, $_stream = false) |
|
| 4749 | 4749 | { |
| 4750 | 4750 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.$_uid.':'.array2string($_structure).' '.function_backtrace()); |
| 4751 | 4751 | $bodyPart = array(); |
| 4752 | - if (self::$debug) _debug_array(array($_structure,function_backtrace())); |
|
| 4752 | + if (self::$debug) _debug_array(array($_structure, function_backtrace())); |
|
| 4753 | 4753 | |
| 4754 | - if($_structure->getSubType() == 'html' && !in_array($_htmlMode, array('html_only', 'always_display', 'only_if_no_text'))) |
|
| 4754 | + if ($_structure->getSubType() == 'html' && !in_array($_htmlMode, array('html_only', 'always_display', 'only_if_no_text'))) |
|
| 4755 | 4755 | { |
| 4756 | 4756 | $bodyPart = array( |
| 4757 | 4757 | 'error' => 1, |
@@ -4797,10 +4797,10 @@ discard block |
||
| 4797 | 4797 | * @param string $_folder folder to work on |
| 4798 | 4798 | * @return array containing the message body, mimeType and charset |
| 4799 | 4799 | */ |
| 4800 | - function getMessageBody($_uid, $_htmlOptions='', $_partID=null, Horde_Mime_Part $_structure=null, $_preserveSeen = false, $_folder = '') |
|
| 4800 | + function getMessageBody($_uid, $_htmlOptions = '', $_partID = null, Horde_Mime_Part $_structure = null, $_preserveSeen = false, $_folder = '') |
|
| 4801 | 4801 | { |
| 4802 | 4802 | if (self::$debug) echo __METHOD__."$_uid, $_htmlOptions, $_partID<br>"; |
| 4803 | - if($_htmlOptions != '') { |
|
| 4803 | + if ($_htmlOptions != '') { |
|
| 4804 | 4804 | $this->htmlOptions = $_htmlOptions; |
| 4805 | 4805 | } |
| 4806 | 4806 | if (empty($_folder)) |
@@ -4821,7 +4821,7 @@ discard block |
||
| 4821 | 4821 | return array( |
| 4822 | 4822 | array( |
| 4823 | 4823 | 'error' => 1, |
| 4824 | - 'body' => 'Error: Could not fetch structure on mail:'.$_uid." as $_htmlOptions". 'for Mailprofile'.$this->icServer->ImapServerId.' User:'.$GLOBALS['egw_info']['user']['account_lid'], |
|
| 4824 | + 'body' => 'Error: Could not fetch structure on mail:'.$_uid." as $_htmlOptions".'for Mailprofile'.$this->icServer->ImapServerId.' User:'.$GLOBALS['egw_info']['user']['account_lid'], |
|
| 4825 | 4825 | 'mimeType' => 'text/plain', |
| 4826 | 4826 | 'charSet' => self::$displayCharset, |
| 4827 | 4827 | ) |
@@ -4834,7 +4834,7 @@ discard block |
||
| 4834 | 4834 | //_debug_array($_structure->getMimeId()); exit; |
| 4835 | 4835 | } |
| 4836 | 4836 | |
| 4837 | - switch($_structure->getPrimaryType()) |
|
| 4837 | + switch ($_structure->getPrimaryType()) |
|
| 4838 | 4838 | { |
| 4839 | 4839 | case 'application': |
| 4840 | 4840 | return array( |
@@ -4846,7 +4846,7 @@ discard block |
||
| 4846 | 4846 | ); |
| 4847 | 4847 | |
| 4848 | 4848 | case 'multipart': |
| 4849 | - switch($_structure->getSubType()) |
|
| 4849 | + switch ($_structure->getSubType()) |
|
| 4850 | 4850 | { |
| 4851 | 4851 | case 'alternative': |
| 4852 | 4852 | $bodyParts = array($this->getMultipartAlternative($_uid, $_structure, $this->htmlOptions, $_preserveSeen)); |
@@ -4880,7 +4880,7 @@ discard block |
||
| 4880 | 4880 | $bodyPart = array(); |
| 4881 | 4881 | if ($_structure->getDisposition() != 'attachment') |
| 4882 | 4882 | { |
| 4883 | - switch($_structure->getSubType()) |
|
| 4883 | + switch ($_structure->getSubType()) |
|
| 4884 | 4884 | { |
| 4885 | 4885 | case 'calendar': |
| 4886 | 4886 | // this is handeled in getTextPart |
@@ -4896,11 +4896,11 @@ discard block |
||
| 4896 | 4896 | |
| 4897 | 4897 | case 'attachment': |
| 4898 | 4898 | case 'message': |
| 4899 | - switch($_structure->getSubType()) |
|
| 4899 | + switch ($_structure->getSubType()) |
|
| 4900 | 4900 | { |
| 4901 | 4901 | case 'rfc822': |
| 4902 | 4902 | $newStructure = $_structure->getParts(); |
| 4903 | - if (self::$debug) {echo __METHOD__." Message -> RFC -> NewStructure:"; _debug_array($newStructure[0]);} |
|
| 4903 | + if (self::$debug) {echo __METHOD__." Message -> RFC -> NewStructure:"; _debug_array($newStructure[0]); } |
|
| 4904 | 4904 | return self::normalizeBodyParts($this->getMessageBody($_uid, $_htmlOptions, $newStructure[0]->getMimeId(), $newStructure[0], $_preserveSeen, $_folder)); |
| 4905 | 4905 | } |
| 4906 | 4906 | break; |
@@ -4928,11 +4928,11 @@ discard block |
||
| 4928 | 4928 | { |
| 4929 | 4929 | if (is_array($_bodyParts)) |
| 4930 | 4930 | { |
| 4931 | - foreach($_bodyParts as $singleBodyPart) |
|
| 4931 | + foreach ($_bodyParts as $singleBodyPart) |
|
| 4932 | 4932 | { |
| 4933 | 4933 | if (!isset($singleBodyPart['body'])) { |
| 4934 | 4934 | $buff = self::normalizeBodyParts($singleBodyPart); |
| 4935 | - foreach ((array)$buff as $val) { $body2return[] = $val;} |
|
| 4935 | + foreach ((array)$buff as $val) { $body2return[] = $val; } |
|
| 4936 | 4936 | continue; |
| 4937 | 4937 | } |
| 4938 | 4938 | $body2return[] = $singleBodyPart; |
@@ -4953,14 +4953,14 @@ discard block |
||
| 4953 | 4953 | * @param boolean $useTidy switch to use tidy |
| 4954 | 4954 | * @return string a preformatted string with the mails converted to text |
| 4955 | 4955 | */ |
| 4956 | - static function &getdisplayableBody(&$mailClass, $bodyParts, $preserveHTML = false, $useTidy = true) |
|
| 4956 | + static function &getdisplayableBody(&$mailClass, $bodyParts, $preserveHTML = false, $useTidy = true) |
|
| 4957 | 4957 | { |
| 4958 | - $message=''; |
|
| 4959 | - for($i=0; $i<count($bodyParts); $i++) |
|
| 4958 | + $message = ''; |
|
| 4959 | + for ($i = 0; $i < count($bodyParts); $i++) |
|
| 4960 | 4960 | { |
| 4961 | 4961 | if (!isset($bodyParts[$i]['body'])) { |
| 4962 | 4962 | $bodyParts[$i]['body'] = self::getdisplayableBody($mailClass, $bodyParts[$i], $preserveHTML, $useTidy); |
| 4963 | - $message .= empty($bodyParts[$i]['body'])?'':$bodyParts[$i]['body']; |
|
| 4963 | + $message .= empty($bodyParts[$i]['body']) ? '' : $bodyParts[$i]['body']; |
|
| 4964 | 4964 | continue; |
| 4965 | 4965 | } |
| 4966 | 4966 | if (isset($bodyParts[$i]['error'])) continue; |
@@ -4985,32 +4985,32 @@ discard block |
||
| 4985 | 4985 | '(R)', |
| 4986 | 4986 | ); |
| 4987 | 4987 | |
| 4988 | - if(($bodyParts[$i]['mimeType'] == 'text/html' || $bodyParts[$i]['mimeType'] == 'text/plain') && |
|
| 4988 | + if (($bodyParts[$i]['mimeType'] == 'text/html' || $bodyParts[$i]['mimeType'] == 'text/plain') && |
|
| 4989 | 4989 | strtoupper($bodyParts[$i]['charSet']) != 'UTF-8') |
| 4990 | 4990 | { |
| 4991 | - $bodyParts[$i]['body'] = preg_replace($sar,$rar,$bodyParts[$i]['body']); |
|
| 4991 | + $bodyParts[$i]['body'] = preg_replace($sar, $rar, $bodyParts[$i]['body']); |
|
| 4992 | 4992 | } |
| 4993 | 4993 | |
| 4994 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Translation::detect_encoding($bodyParts[$i]['body']); |
|
| 4994 | + if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = Translation::detect_encoding($bodyParts[$i]['body']); |
|
| 4995 | 4995 | // add line breaks to $bodyParts |
| 4996 | 4996 | //error_log(__METHOD__.' ('.__LINE__.') '.' Charset:'.$bodyParts[$i]['charSet'].'->'.$bodyParts[$i]['body']); |
| 4997 | - $newBody = Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
|
| 4997 | + $newBody = Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
|
| 4998 | 4998 | //error_log(__METHOD__.' ('.__LINE__.') '.' MimeType:'.$bodyParts[$i]['mimeType'].'->'.$newBody); |
| 4999 | 4999 | $mailClass->activeMimeType = 'text/plain'; |
| 5000 | 5000 | if ($bodyParts[$i]['mimeType'] == 'text/html') { |
| 5001 | 5001 | $mailClass->activeMimeType = $bodyParts[$i]['mimeType']; |
| 5002 | 5002 | if (!$preserveHTML) |
| 5003 | 5003 | { |
| 5004 | - $alreadyHtmlLawed=false; |
|
| 5004 | + $alreadyHtmlLawed = false; |
|
| 5005 | 5005 | // as Translation::convert reduces \r\n to \n and purifier eats \n -> peplace it with a single space |
| 5006 | - $newBody = str_replace("\n"," ",$newBody); |
|
| 5006 | + $newBody = str_replace("\n", " ", $newBody); |
|
| 5007 | 5007 | // convert HTML to text, as we dont want HTML in infologs |
| 5008 | 5008 | if ($useTidy && extension_loaded('tidy')) |
| 5009 | 5009 | { |
| 5010 | 5010 | $tidy = new tidy(); |
| 5011 | - $cleaned = $tidy->repairString($newBody, self::$tidy_config,'utf8'); |
|
| 5011 | + $cleaned = $tidy->repairString($newBody, self::$tidy_config, 'utf8'); |
|
| 5012 | 5012 | // Found errors. Strip it all so there's some output |
| 5013 | - if($tidy->getStatus() == 2) |
|
| 5013 | + if ($tidy->getStatus() == 2) |
|
| 5014 | 5014 | { |
| 5015 | 5015 | error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$tidy->errorBuffer); |
| 5016 | 5016 | } |
@@ -5021,7 +5021,7 @@ discard block |
||
| 5021 | 5021 | if (!$preserveHTML) |
| 5022 | 5022 | { |
| 5023 | 5023 | // filter only the 'body', as we only want that part, if we throw away the html |
| 5024 | - preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array()); |
|
| 5024 | + preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array()); |
|
| 5025 | 5025 | if ($matches[2]) |
| 5026 | 5026 | { |
| 5027 | 5027 | $hasOther = true; |
@@ -5032,7 +5032,7 @@ discard block |
||
| 5032 | 5032 | else |
| 5033 | 5033 | { |
| 5034 | 5034 | // htmLawed filter only the 'body' |
| 5035 | - preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array()); |
|
| 5035 | + preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array()); |
|
| 5036 | 5036 | if ($matches[2]) |
| 5037 | 5037 | { |
| 5038 | 5038 | $hasOther = true; |
@@ -5041,17 +5041,17 @@ discard block |
||
| 5041 | 5041 | $htmLawed = new Html\HtmLawed(); |
| 5042 | 5042 | // the next line should not be needed, but produces better results on HTML 2 Text conversion, |
| 5043 | 5043 | // as we switched off HTMLaweds tidy functionality |
| 5044 | - $newBody = str_replace(array('&amp;','<DIV><BR></DIV>',"<DIV> </DIV>",'<div> </div>'),array('&','<BR>','<BR>','<BR>'),$newBody); |
|
| 5045 | - $newBody = $htmLawed->run($newBody,self::$htmLawed_config); |
|
| 5046 | - if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3]; |
|
| 5047 | - $alreadyHtmlLawed=true; |
|
| 5044 | + $newBody = str_replace(array('&amp;', '<DIV><BR></DIV>', "<DIV> </DIV>", '<div> </div>'), array('&', '<BR>', '<BR>', '<BR>'), $newBody); |
|
| 5045 | + $newBody = $htmLawed->run($newBody, self::$htmLawed_config); |
|
| 5046 | + if ($hasOther && $preserveHTML) $newBody = $matches[1].$newBody.$matches[3]; |
|
| 5047 | + $alreadyHtmlLawed = true; |
|
| 5048 | 5048 | } |
| 5049 | 5049 | //error_log(__METHOD__.' ('.__LINE__.') '.' after purify:'.$newBody); |
| 5050 | - if ($preserveHTML==false) $newBody = Mail\Html::convertHTMLToText($newBody,self::$displayCharset,true,true); |
|
| 5050 | + if ($preserveHTML == false) $newBody = Mail\Html::convertHTMLToText($newBody, self::$displayCharset, true, true); |
|
| 5051 | 5051 | //error_log(__METHOD__.' ('.__LINE__.') '.' after convertHTMLToText:'.$newBody); |
| 5052 | - if ($preserveHTML==false) $newBody = nl2br($newBody); // we need this, as htmLawed removes \r\n |
|
| 5052 | + if ($preserveHTML == false) $newBody = nl2br($newBody); // we need this, as htmLawed removes \r\n |
|
| 5053 | 5053 | /*if (!$alreadyHtmlLawed) */ $mailClass->getCleanHTML($newBody); // remove stuff we regard as unwanted |
| 5054 | - if ($preserveHTML==false) $newBody = str_replace("<br />","\r\n",$newBody); |
|
| 5054 | + if ($preserveHTML == false) $newBody = str_replace("<br />", "\r\n", $newBody); |
|
| 5055 | 5055 | //error_log(__METHOD__.' ('.__LINE__.') '.' after getClean:'.$newBody); |
| 5056 | 5056 | } |
| 5057 | 5057 | $message .= $newBody; |
@@ -5060,9 +5060,9 @@ discard block |
||
| 5060 | 5060 | //error_log(__METHOD__.' ('.__LINE__.') '.' Body(after specialchars):'.$newBody); |
| 5061 | 5061 | //use Mail\Html::convertHTMLToText instead of strip_tags, (even message is plain text) as strip_tags eats away too much |
| 5062 | 5062 | //$newBody = strip_tags($newBody); //we need to fix broken tags (or just stuff like "<800 USD/p" ) |
| 5063 | - $newBody = Mail\Html::convertHTMLToText($newBody,self::$displayCharset,false,false); |
|
| 5063 | + $newBody = Mail\Html::convertHTMLToText($newBody, self::$displayCharset, false, false); |
|
| 5064 | 5064 | //error_log(__METHOD__.' ('.__LINE__.') '.' Body(after strip tags):'.$newBody); |
| 5065 | - $newBody = htmlspecialchars_decode($newBody,ENT_QUOTES); |
|
| 5065 | + $newBody = htmlspecialchars_decode($newBody, ENT_QUOTES); |
|
| 5066 | 5066 | //error_log(__METHOD__.' ('.__LINE__.') '.' Body (after hmlspc_decode):'.$newBody); |
| 5067 | 5067 | $message .= $newBody; |
| 5068 | 5068 | //continue; |
@@ -5070,27 +5070,27 @@ discard block |
||
| 5070 | 5070 | return $message; |
| 5071 | 5071 | } |
| 5072 | 5072 | |
| 5073 | - static function wordwrap($str, $cols, $cut, $dontbreaklinesstartingwith=false) |
|
| 5073 | + static function wordwrap($str, $cols, $cut, $dontbreaklinesstartingwith = false) |
|
| 5074 | 5074 | { |
| 5075 | 5075 | $lines = explode("\n", $str); |
| 5076 | 5076 | $newStr = ''; |
| 5077 | - foreach($lines as $line) |
|
| 5077 | + foreach ($lines as $line) |
|
| 5078 | 5078 | { |
| 5079 | 5079 | // replace tabs by 8 space chars, or any tab only counts one char |
| 5080 | 5080 | //$line = str_replace("\t"," ",$line); |
| 5081 | 5081 | //$newStr .= wordwrap($line, $cols, $cut); |
| 5082 | - $allowedLength = $cols-strlen($cut); |
|
| 5082 | + $allowedLength = $cols - strlen($cut); |
|
| 5083 | 5083 | //dont try to break lines with links, chance is we mess up the text is way too big |
| 5084 | - if (strlen($line) > $allowedLength && stripos($line,'href=')===false && |
|
| 5085 | - ($dontbreaklinesstartingwith==false || |
|
| 5084 | + if (strlen($line) > $allowedLength && stripos($line, 'href=') === false && |
|
| 5085 | + ($dontbreaklinesstartingwith == false || |
|
| 5086 | 5086 | ($dontbreaklinesstartingwith && |
| 5087 | - strlen($dontbreaklinesstartingwith)>=1 && |
|
| 5088 | - substr($line,0,strlen($dontbreaklinesstartingwith)) != $dontbreaklinesstartingwith |
|
| 5087 | + strlen($dontbreaklinesstartingwith) >= 1 && |
|
| 5088 | + substr($line, 0, strlen($dontbreaklinesstartingwith)) != $dontbreaklinesstartingwith |
|
| 5089 | 5089 | ) |
| 5090 | 5090 | ) |
| 5091 | 5091 | ) |
| 5092 | 5092 | { |
| 5093 | - $s=explode(" ", $line); |
|
| 5093 | + $s = explode(" ", $line); |
|
| 5094 | 5094 | $line = ""; |
| 5095 | 5095 | $linecnt = 0; |
| 5096 | 5096 | foreach ($s as &$v) { |
@@ -5098,22 +5098,22 @@ discard block |
||
| 5098 | 5098 | // only break long words within the wordboundaries, |
| 5099 | 5099 | // but it may destroy links, so we check for href and dont do it if we find one |
| 5100 | 5100 | // we check for any html within the word, because we do not want to break html by accident |
| 5101 | - if($cnt > $allowedLength && stripos($v,'href=')===false && stripos($v,'onclick=')===false && $cnt == strlen(html_entity_decode($v))) |
|
| 5101 | + if ($cnt > $allowedLength && stripos($v, 'href=') === false && stripos($v, 'onclick=') === false && $cnt == strlen(html_entity_decode($v))) |
|
| 5102 | 5102 | { |
| 5103 | - $v=wordwrap($v, $allowedLength, $cut, true); |
|
| 5103 | + $v = wordwrap($v, $allowedLength, $cut, true); |
|
| 5104 | 5104 | } |
| 5105 | 5105 | // the rest should be broken at the start of the new word that exceeds the limit |
| 5106 | - if ($linecnt+$cnt > $allowedLength) { |
|
| 5107 | - $v=$cut.$v; |
|
| 5106 | + if ($linecnt + $cnt > $allowedLength) { |
|
| 5107 | + $v = $cut.$v; |
|
| 5108 | 5108 | #$linecnt = 0; |
| 5109 | - $linecnt =strlen($v)-strlen($cut); |
|
| 5109 | + $linecnt = strlen($v) - strlen($cut); |
|
| 5110 | 5110 | } else { |
| 5111 | 5111 | $linecnt += $cnt; |
| 5112 | 5112 | } |
| 5113 | 5113 | if (strlen($v)) $line .= (strlen($line) ? " " : "").$v; |
| 5114 | 5114 | } |
| 5115 | 5115 | } |
| 5116 | - $newStr .= $line . "\n"; |
|
| 5116 | + $newStr .= $line."\n"; |
|
| 5117 | 5117 | } |
| 5118 | 5118 | return $newStr; |
| 5119 | 5119 | } |
@@ -5128,12 +5128,12 @@ discard block |
||
| 5128 | 5128 | * @param boolean $_useHeaderInsteadOfEnvelope - force getMessageHeader method to be used for fetching Envelope Information |
| 5129 | 5129 | * @return array the message header |
| 5130 | 5130 | */ |
| 5131 | - function getMessageEnvelope($_uid, $_partID = '',$decode=false, $_folder='', $_useHeaderInsteadOfEnvelope=false) |
|
| 5131 | + function getMessageEnvelope($_uid, $_partID = '', $decode = false, $_folder = '', $_useHeaderInsteadOfEnvelope = false) |
|
| 5132 | 5132 | { |
| 5133 | 5133 | //error_log(__METHOD__.' ('.__LINE__.') '.":$_uid,$_partID,$decode,$_folder".function_backtrace()); |
| 5134 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5134 | + if (empty($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5135 | 5135 | //error_log(__METHOD__.' ('.__LINE__.') '.":$_uid,$_partID,$decode,$_folder"); |
| 5136 | - if((empty($_partID)||$_partID=='null')&&$_useHeaderInsteadOfEnvelope===false) { |
|
| 5136 | + if ((empty($_partID) || $_partID == 'null') && $_useHeaderInsteadOfEnvelope === false) { |
|
| 5137 | 5137 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5138 | 5138 | if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
| 5139 | 5139 | $uidsToFetch->add($_uid); |
@@ -5146,7 +5146,7 @@ discard block |
||
| 5146 | 5146 | 'ids' => $uidsToFetch, |
| 5147 | 5147 | )); |
| 5148 | 5148 | if (is_object($headersNew)) { |
| 5149 | - foreach($headersNew as &$_headerObject) { |
|
| 5149 | + foreach ($headersNew as &$_headerObject) { |
|
| 5150 | 5150 | $env = $_headerObject->getEnvelope(); |
| 5151 | 5151 | //_debug_array($envFields->singleFields()); |
| 5152 | 5152 | $singleFields = $envFields->singleFields(); |
@@ -5161,34 +5161,34 @@ discard block |
||
| 5161 | 5161 | case 'bcc': |
| 5162 | 5162 | case 'sender': |
| 5163 | 5163 | //error_log(__METHOD__.' ('.__LINE__.') '.$v.'->'.array2string($env->$v->addresses)); |
| 5164 | - $envelope[$v]=$env->$v->addresses; |
|
| 5164 | + $envelope[$v] = $env->$v->addresses; |
|
| 5165 | 5165 | $address = array(); |
| 5166 | 5166 | if (!is_array($envelope[$v])) break; |
| 5167 | 5167 | foreach ($envelope[$v] as $k => $ad) |
| 5168 | 5168 | { |
| 5169 | - if (stripos($ad,'@')===false) |
|
| 5169 | + if (stripos($ad, '@') === false) |
|
| 5170 | 5170 | { |
| 5171 | - $remember=$k; |
|
| 5171 | + $remember = $k; |
|
| 5172 | 5172 | } |
| 5173 | 5173 | else |
| 5174 | 5174 | { |
| 5175 | - $address[] = (!is_null($remember)?$envelope[$v][$remember].' ':'').$ad; |
|
| 5176 | - $remember=null; |
|
| 5175 | + $address[] = (!is_null($remember) ? $envelope[$v][$remember].' ' : '').$ad; |
|
| 5176 | + $remember = null; |
|
| 5177 | 5177 | } |
| 5178 | 5178 | } |
| 5179 | 5179 | $envelope[$v] = $address; |
| 5180 | 5180 | break; |
| 5181 | 5181 | case 'date': |
| 5182 | - $envelope[$v]=DateTime::to($env->$v); |
|
| 5182 | + $envelope[$v] = DateTime::to($env->$v); |
|
| 5183 | 5183 | break; |
| 5184 | 5184 | default: |
| 5185 | - $envelope[$v]=$env->$v; |
|
| 5185 | + $envelope[$v] = $env->$v; |
|
| 5186 | 5186 | } |
| 5187 | 5187 | } |
| 5188 | - $envelope['size']=$_headerObject->getSize(); |
|
| 5188 | + $envelope['size'] = $_headerObject->getSize(); |
|
| 5189 | 5189 | } |
| 5190 | 5190 | } |
| 5191 | - $envelope = array_change_key_case($envelope,CASE_UPPER); |
|
| 5191 | + $envelope = array_change_key_case($envelope, CASE_UPPER); |
|
| 5192 | 5192 | //if ($decode) _debug_array($envelope); |
| 5193 | 5193 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($envelope)); |
| 5194 | 5194 | if ($decode) |
@@ -5196,19 +5196,19 @@ discard block |
||
| 5196 | 5196 | foreach ($envelope as $key => $rvV) |
| 5197 | 5197 | { |
| 5198 | 5198 | //try idn conversion only on 'FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO' |
| 5199 | - $envelope[$key]=self::decode_header($rvV,in_array($key,array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO'))); |
|
| 5199 | + $envelope[$key] = self::decode_header($rvV, in_array($key, array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO'))); |
|
| 5200 | 5200 | } |
| 5201 | 5201 | } |
| 5202 | 5202 | return $envelope; |
| 5203 | 5203 | } else { |
| 5204 | 5204 | |
| 5205 | - $headers = $this->getMessageHeader($_uid, $_partID, true,true,$_folder); |
|
| 5205 | + $headers = $this->getMessageHeader($_uid, $_partID, true, true, $_folder); |
|
| 5206 | 5206 | |
| 5207 | 5207 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.array2string($headers)); |
| 5208 | 5208 | //_debug_array($headers); |
| 5209 | 5209 | $newData = array( |
| 5210 | 5210 | 'DATE' => $headers['DATE'], |
| 5211 | - 'SUBJECT' => ($decode ? self::decode_header($headers['SUBJECT']):$headers['SUBJECT']), |
|
| 5211 | + 'SUBJECT' => ($decode ? self::decode_header($headers['SUBJECT']) : $headers['SUBJECT']), |
|
| 5212 | 5212 | 'MESSAGE_ID' => $headers['MESSAGE-ID'] |
| 5213 | 5213 | ); |
| 5214 | 5214 | if (isset($headers['IN-REPLY-TO'])) $newData['IN-REPLY-TO'] = $headers['IN-REPLY-TO']; |
@@ -5219,11 +5219,11 @@ discard block |
||
| 5219 | 5219 | if (isset($headers['SIZE'])) $newData['SIZE'] = $headers['SIZE']; |
| 5220 | 5220 | //_debug_array($newData); |
| 5221 | 5221 | $recepientList = array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO'); |
| 5222 | - foreach($recepientList as $recepientType) { |
|
| 5223 | - if(isset($headers[$recepientType])) { |
|
| 5224 | - if ($decode) $headers[$recepientType] = self::decode_header($headers[$recepientType],true); |
|
| 5222 | + foreach ($recepientList as $recepientType) { |
|
| 5223 | + if (isset($headers[$recepientType])) { |
|
| 5224 | + if ($decode) $headers[$recepientType] = self::decode_header($headers[$recepientType], true); |
|
| 5225 | 5225 | //error_log(__METHOD__.__LINE__." ".$recepientType."->".array2string($headers[$recepientType])); |
| 5226 | - foreach(self::parseAddressList($headers[$recepientType]) as $singleAddress) { |
|
| 5226 | + foreach (self::parseAddressList($headers[$recepientType]) as $singleAddress) { |
|
| 5227 | 5227 | $addressData = array( |
| 5228 | 5228 | 'PERSONAL_NAME' => $singleAddress->personal ? $singleAddress->personal : 'NIL', |
| 5229 | 5229 | 'AT_DOMAIN_LIST' => $singleAddress->adl ? $singleAddress->adl : 'NIL', |
@@ -5231,15 +5231,15 @@ discard block |
||
| 5231 | 5231 | 'HOST_NAME' => $singleAddress->host ? $singleAddress->host : 'NIL', |
| 5232 | 5232 | 'EMAIL' => $singleAddress->host ? $singleAddress->mailbox.'@'.$singleAddress->host : $singleAddress->mailbox, |
| 5233 | 5233 | ); |
| 5234 | - if($addressData['PERSONAL_NAME'] != 'NIL') { |
|
| 5234 | + if ($addressData['PERSONAL_NAME'] != 'NIL') { |
|
| 5235 | 5235 | $addressData['RFC822_EMAIL'] = imap_rfc822_write_address($singleAddress->mailbox, $singleAddress->host, $singleAddress->personal); |
| 5236 | 5236 | } else { |
| 5237 | 5237 | $addressData['RFC822_EMAIL'] = 'NIL'; |
| 5238 | 5238 | } |
| 5239 | - $newData[$recepientType][] = ($addressData['RFC822_EMAIL']!='NIL'?$addressData['RFC822_EMAIL']:$addressData['EMAIL']);//$addressData; |
|
| 5239 | + $newData[$recepientType][] = ($addressData['RFC822_EMAIL'] != 'NIL' ? $addressData['RFC822_EMAIL'] : $addressData['EMAIL']); //$addressData; |
|
| 5240 | 5240 | } |
| 5241 | 5241 | } else { |
| 5242 | - if($recepientType == 'SENDER' || $recepientType == 'REPLY-TO') { |
|
| 5242 | + if ($recepientType == 'SENDER' || $recepientType == 'REPLY-TO') { |
|
| 5243 | 5243 | $newData[$recepientType] = $newData['FROM']; |
| 5244 | 5244 | } else { |
| 5245 | 5245 | $newData[$recepientType] = array(); |
@@ -5261,10 +5261,10 @@ discard block |
||
| 5261 | 5261 | * @param string $_folder folder to work on |
| 5262 | 5262 | * @return array|Horde_Mime_Headers message header as array or object |
| 5263 | 5263 | */ |
| 5264 | - function getMessageHeader($_uid, $_partID = '',$decode=false, $preserveUnSeen=false, $_folder='') |
|
| 5264 | + function getMessageHeader($_uid, $_partID = '', $decode = false, $preserveUnSeen = false, $_folder = '') |
|
| 5265 | 5265 | { |
| 5266 | 5266 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$_uid.', '.$_partID.', '.$decode.', '.$preserveUnSeen.', '.$_folder); |
| 5267 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5267 | + if (empty($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5268 | 5268 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5269 | 5269 | if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
| 5270 | 5270 | $uidsToFetch->add($_uid); |
@@ -5272,7 +5272,7 @@ discard block |
||
| 5272 | 5272 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
| 5273 | 5273 | if ($_partID != '') |
| 5274 | 5274 | { |
| 5275 | - $fquery->headerText(array('id'=>$_partID,'peek'=>$preserveUnSeen)); |
|
| 5275 | + $fquery->headerText(array('id'=>$_partID, 'peek'=>$preserveUnSeen)); |
|
| 5276 | 5276 | $fquery->structure(); |
| 5277 | 5277 | } |
| 5278 | 5278 | else |
@@ -5285,18 +5285,18 @@ discard block |
||
| 5285 | 5285 | 'ids' => $uidsToFetch, |
| 5286 | 5286 | )); |
| 5287 | 5287 | if (is_object($headersNew)) { |
| 5288 | - foreach($headersNew as $_fetchObject) |
|
| 5288 | + foreach ($headersNew as $_fetchObject) |
|
| 5289 | 5289 | { |
| 5290 | - $headers = $_fetchObject->getHeaderText(0,Horde_Imap_Client_Data_Fetch::HEADER_PARSE); |
|
| 5290 | + $headers = $_fetchObject->getHeaderText(0, Horde_Imap_Client_Data_Fetch::HEADER_PARSE); |
|
| 5291 | 5291 | if ($_partID != '') |
| 5292 | 5292 | { |
| 5293 | 5293 | $mailStructureObject = $_fetchObject->getStructure(); |
| 5294 | 5294 | foreach ($mailStructureObject->contentTypeMap() as $mime_id => $mime_type) |
| 5295 | 5295 | { |
| 5296 | - if ($mime_id==$_partID) |
|
| 5296 | + if ($mime_id == $_partID) |
|
| 5297 | 5297 | { |
| 5298 | 5298 | //error_log(__METHOD__.' ('.__LINE__.') '."$mime_id == $_partID".array2string($_headerObject->getHeaderText($mime_id,Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray())); |
| 5299 | - $headers = $_fetchObject->getHeaderText($mime_id,Horde_Imap_Client_Data_Fetch::HEADER_PARSE); |
|
| 5299 | + $headers = $_fetchObject->getHeaderText($mime_id, Horde_Imap_Client_Data_Fetch::HEADER_PARSE); |
|
| 5300 | 5300 | break; |
| 5301 | 5301 | } |
| 5302 | 5302 | } |
@@ -5309,15 +5309,15 @@ discard block |
||
| 5309 | 5309 | if (is_object($headers)) $headers->setUserAgent('EGroupware API '.$GLOBALS['egw_info']['server']['versions']['phpgwapi']); |
| 5310 | 5310 | return $headers; |
| 5311 | 5311 | } |
| 5312 | - $retValue = is_object($headers) ? $headers->toArray():array(); |
|
| 5312 | + $retValue = is_object($headers) ? $headers->toArray() : array(); |
|
| 5313 | 5313 | if ($size) $retValue['size'] = $size; |
| 5314 | 5314 | } |
| 5315 | - $retValue = array_change_key_case($retValue,CASE_UPPER); |
|
| 5315 | + $retValue = array_change_key_case($retValue, CASE_UPPER); |
|
| 5316 | 5316 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($retValue)); |
| 5317 | 5317 | // if SUBJECT is an array, use thelast one, as we assume something with the unfolding for the subject did not work |
| 5318 | 5318 | if (is_array($retValue['SUBJECT'])) |
| 5319 | 5319 | { |
| 5320 | - $retValue['SUBJECT'] = $retValue['SUBJECT'][count($retValue['SUBJECT'])-1]; |
|
| 5320 | + $retValue['SUBJECT'] = $retValue['SUBJECT'][count($retValue['SUBJECT']) - 1]; |
|
| 5321 | 5321 | } |
| 5322 | 5322 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.array2string($decode ? self::decode_header($retValue,true):$retValue)); |
| 5323 | 5323 | if ($decode) |
@@ -5325,7 +5325,7 @@ discard block |
||
| 5325 | 5325 | foreach ($retValue as $key => $rvV) |
| 5326 | 5326 | { |
| 5327 | 5327 | //try idn conversion only on 'FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO' |
| 5328 | - $retValue[$key]=self::decode_header($rvV,in_array($key,array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO'))); |
|
| 5328 | + $retValue[$key] = self::decode_header($rvV, in_array($key, array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO'))); |
|
| 5329 | 5329 | } |
| 5330 | 5330 | } |
| 5331 | 5331 | return $retValue; |
@@ -5342,14 +5342,14 @@ discard block |
||
| 5342 | 5342 | function getMessageRawHeader($_uid, $_partID = '', $_folder = '') |
| 5343 | 5343 | { |
| 5344 | 5344 | static $rawHeaders; |
| 5345 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5345 | + if (empty($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5346 | 5346 | //error_log(__METHOD__.' ('.__LINE__.') '." Try Using Cache for raw Header $_uid, $_partID in Folder $_folder"); |
| 5347 | 5347 | |
| 5348 | - if (is_null($rawHeaders)||!is_array($rawHeaders)) $rawHeaders = Cache::getCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 5349 | - if (isset($rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID)?'NIL':$_partID)])) |
|
| 5348 | + if (is_null($rawHeaders) || !is_array($rawHeaders)) $rawHeaders = Cache::getCache(Cache::INSTANCE, 'email', 'rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 1); |
|
| 5349 | + if (isset($rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)])) |
|
| 5350 | 5350 | { |
| 5351 | 5351 | //error_log(__METHOD__.' ('.__LINE__.') '." Using Cache for raw Header $_uid, $_partID in Folder $_folder"); |
| 5352 | - return $rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID)?'NIL':$_partID)]; |
|
| 5352 | + return $rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)]; |
|
| 5353 | 5353 | } |
| 5354 | 5354 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5355 | 5355 | $uid = $_uid; |
@@ -5359,7 +5359,7 @@ discard block |
||
| 5359 | 5359 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
| 5360 | 5360 | if ($_partID != '') |
| 5361 | 5361 | { |
| 5362 | - $fquery->headerText(array('id'=>$_partID,'peek'=>true)); |
|
| 5362 | + $fquery->headerText(array('id'=>$_partID, 'peek'=>true)); |
|
| 5363 | 5363 | $fquery->structure(); |
| 5364 | 5364 | } |
| 5365 | 5365 | else |
@@ -5370,14 +5370,14 @@ discard block |
||
| 5370 | 5370 | 'ids' => $uidsToFetch, |
| 5371 | 5371 | )); |
| 5372 | 5372 | if (is_object($headersNew)) { |
| 5373 | - foreach($headersNew as &$_headerObject) { |
|
| 5373 | + foreach ($headersNew as &$_headerObject) { |
|
| 5374 | 5374 | $retValue = $_headerObject->getHeaderText(); |
| 5375 | 5375 | if ($_partID != '') |
| 5376 | 5376 | { |
| 5377 | 5377 | $mailStructureObject = $_headerObject->getStructure(); |
| 5378 | 5378 | foreach ($mailStructureObject->contentTypeMap() as $mime_id => $mime_type) |
| 5379 | 5379 | { |
| 5380 | - if ($mime_id==$_partID) |
|
| 5380 | + if ($mime_id == $_partID) |
|
| 5381 | 5381 | { |
| 5382 | 5382 | $retValue = $_headerObject->getHeaderText($mime_id); |
| 5383 | 5383 | } |
@@ -5385,8 +5385,8 @@ discard block |
||
| 5385 | 5385 | } |
| 5386 | 5386 | } |
| 5387 | 5387 | } |
| 5388 | - $rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID)?'NIL':$_partID)]=$retValue; |
|
| 5389 | - Cache::setCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']),$rawHeaders,60*60*1); |
|
| 5388 | + $rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)] = $retValue; |
|
| 5389 | + Cache::setCache(Cache::INSTANCE, 'email', 'rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']), $rawHeaders, 60 * 60 * 1); |
|
| 5390 | 5390 | return $retValue; |
| 5391 | 5391 | } |
| 5392 | 5392 | |
@@ -5399,25 +5399,25 @@ discard block |
||
| 5399 | 5399 | { |
| 5400 | 5400 | $style = ''; |
| 5401 | 5401 | if (empty($_bodyParts)) return ""; |
| 5402 | - foreach((array)$_bodyParts as $singleBodyPart) { |
|
| 5402 | + foreach ((array)$_bodyParts as $singleBodyPart) { |
|
| 5403 | 5403 | if (!isset($singleBodyPart['body'])) { |
| 5404 | 5404 | $singleBodyPart['body'] = self::getStyles($singleBodyPart); |
| 5405 | 5405 | $style .= $singleBodyPart['body']; |
| 5406 | 5406 | continue; |
| 5407 | 5407 | } |
| 5408 | 5408 | |
| 5409 | - if ($singleBodyPart['charSet']===false) $singleBodyPart['charSet'] = Translation::detect_encoding($singleBodyPart['body']); |
|
| 5409 | + if ($singleBodyPart['charSet'] === false) $singleBodyPart['charSet'] = Translation::detect_encoding($singleBodyPart['body']); |
|
| 5410 | 5410 | $singleBodyPart['body'] = Translation::convert( |
| 5411 | 5411 | $singleBodyPart['body'], |
| 5412 | 5412 | strtolower($singleBodyPart['charSet']) |
| 5413 | 5413 | ); |
| 5414 | 5414 | $ct = 0; |
| 5415 | - $newStyle=array(); |
|
| 5416 | - if (stripos($singleBodyPart['body'],'<style')!==false) $ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $singleBodyPart['body'], $newStyle); |
|
| 5417 | - if ($ct>0) |
|
| 5415 | + $newStyle = array(); |
|
| 5416 | + if (stripos($singleBodyPart['body'], '<style') !== false) $ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $singleBodyPart['body'], $newStyle); |
|
| 5417 | + if ($ct > 0) |
|
| 5418 | 5418 | { |
| 5419 | 5419 | //error_log(__METHOD__.' ('.__LINE__.') '.'#'.$ct.'#'.array2string($newStyle)); |
| 5420 | - $style2buffer = implode('',$newStyle[0]); |
|
| 5420 | + $style2buffer = implode('', $newStyle[0]); |
|
| 5421 | 5421 | } |
| 5422 | 5422 | if ($style2buffer && strtoupper(self::$displayCharset) == 'UTF-8') |
| 5423 | 5423 | { |
@@ -5425,7 +5425,7 @@ discard block |
||
| 5425 | 5425 | $test = json_encode($style2buffer); |
| 5426 | 5426 | //error_log(__METHOD__.' ('.__LINE__.') '.'#'.$test.'# ->'.strlen($style2buffer).' Error:'.json_last_error()); |
| 5427 | 5427 | //if (json_last_error() != JSON_ERROR_NONE && strlen($style2buffer)>0) |
| 5428 | - if ($test=="null" && strlen($style2buffer)>0) |
|
| 5428 | + if ($test == "null" && strlen($style2buffer) > 0) |
|
| 5429 | 5429 | { |
| 5430 | 5430 | // this should not be needed, unless something fails with charset detection/ wrong charset passed |
| 5431 | 5431 | error_log(__METHOD__.' ('.__LINE__.') '.' Found Invalid sequence for utf-8 in CSS:'.$style2buffer.' Charset Reported:'.$singleBodyPart['charSet'].' Carset Detected:'.Translation::detect_encoding($style2buffer)); |
@@ -5436,19 +5436,19 @@ discard block |
||
| 5436 | 5436 | } |
| 5437 | 5437 | // clean out comments and stuff |
| 5438 | 5438 | $search = array( |
| 5439 | - '@url\(http:\/\/[^\)].*?\)@si', // url calls e.g. in style definitions |
|
| 5439 | + '@url\(http:\/\/[^\)].*?\)@si', // url calls e.g. in style definitions |
|
| 5440 | 5440 | // '@<!--[\s\S]*?[ \t\n\r]*-->@', // Strip multi-line comments including CDATA |
| 5441 | 5441 | // '@<!--[\s\S]*?[ \t\n\r]*--@', // Strip broken multi-line comments including CDATA |
| 5442 | 5442 | ); |
| 5443 | - $style = preg_replace($search,"",$style); |
|
| 5443 | + $style = preg_replace($search, "", $style); |
|
| 5444 | 5444 | |
| 5445 | 5445 | // CSS Security |
| 5446 | 5446 | // http://code.google.com/p/browsersec/wiki/Part1#Cascading_stylesheets |
| 5447 | - $css = preg_replace('/(javascript|expression|-moz-binding)/i','',$style); |
|
| 5448 | - if (stripos($css,'script')!==false) Mail\Html::replaceTagsCompletley($css,'script'); // Strip out script that may be included |
|
| 5447 | + $css = preg_replace('/(javascript|expression|-moz-binding)/i', '', $style); |
|
| 5448 | + if (stripos($css, 'script') !== false) Mail\Html::replaceTagsCompletley($css, 'script'); // Strip out script that may be included |
|
| 5449 | 5449 | // we need this, as styledefinitions are enclosed with curly brackets; and template stuff tries to replace everything between curly brackets that is having no horizontal whitespace |
| 5450 | 5450 | // as the comments as <!-- styledefinition --> in stylesheet are outdated, and ck-editor does not understand it, we remove it |
| 5451 | - $css = str_replace(array(':','<!--','-->'),array(': ','',''),$css); |
|
| 5451 | + $css = str_replace(array(':', '<!--', '-->'), array(': ', '', ''), $css); |
|
| 5452 | 5452 | //error_log(__METHOD__.' ('.__LINE__.') '.$css); |
| 5453 | 5453 | // TODO: we may have to strip urls and maybe comments and ifs |
| 5454 | 5454 | return $css; |
@@ -5463,16 +5463,16 @@ discard block |
||
| 5463 | 5463 | * @param boolean $_stream =false true: return a stream, false: return string, stream suppresses any caching |
| 5464 | 5464 | * @return string the message body |
| 5465 | 5465 | */ |
| 5466 | - function getMessageRawBody($_uid, $_partID = '', $_folder='', $_stream=false) |
|
| 5466 | + function getMessageRawBody($_uid, $_partID = '', $_folder = '', $_stream = false) |
|
| 5467 | 5467 | { |
| 5468 | 5468 | //TODO: caching einbauen static! |
| 5469 | 5469 | static $rawBody; |
| 5470 | 5470 | if (is_null($rawBody)) $rawBody = array(); |
| 5471 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5472 | - if (!$_stream && isset($rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID)?'NIL':$_partID)])) |
|
| 5471 | + if (empty($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5472 | + if (!$_stream && isset($rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)])) |
|
| 5473 | 5473 | { |
| 5474 | 5474 | //error_log(__METHOD__.' ('.__LINE__.') '." Using Cache for raw Body $_uid, $_partID in Folder $_folder"); |
| 5475 | - return $rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID)?'NIL':$_partID)]; |
|
| 5475 | + return $rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)]; |
|
| 5476 | 5476 | } |
| 5477 | 5477 | |
| 5478 | 5478 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
@@ -5485,13 +5485,13 @@ discard block |
||
| 5485 | 5485 | if ($_partID != '') |
| 5486 | 5486 | { |
| 5487 | 5487 | $fquery->structure(); |
| 5488 | - $fquery->bodyPart($_partID,array('peek'=>true)); |
|
| 5488 | + $fquery->bodyPart($_partID, array('peek'=>true)); |
|
| 5489 | 5489 | } |
| 5490 | 5490 | $headersNew = $this->icServer->fetch($_folder, $fquery, array( |
| 5491 | 5491 | 'ids' => $uidsToFetch, |
| 5492 | 5492 | )); |
| 5493 | 5493 | if (is_object($headersNew)) { |
| 5494 | - foreach($headersNew as &$_headerObject) { |
|
| 5494 | + foreach ($headersNew as &$_headerObject) { |
|
| 5495 | 5495 | $body = $_headerObject->getFullMsg($_stream); |
| 5496 | 5496 | if ($_partID != '') |
| 5497 | 5497 | { |
@@ -5499,7 +5499,7 @@ discard block |
||
| 5499 | 5499 | //_debug_array($mailStructureObject->contentTypeMap()); |
| 5500 | 5500 | foreach ($mailStructureObject->contentTypeMap() as $mime_id => $mime_type) |
| 5501 | 5501 | { |
| 5502 | - if ($mime_id==$_partID) |
|
| 5502 | + if ($mime_id == $_partID) |
|
| 5503 | 5503 | { |
| 5504 | 5504 | $body = $_headerObject->getBodyPart($mime_id, $_stream); |
| 5505 | 5505 | } |
@@ -5510,7 +5510,7 @@ discard block |
||
| 5510 | 5510 | //error_log(__METHOD__.' ('.__LINE__.') '."[$this->icServer->ImapServerId][$_folder][$_uid][".(empty($_partID)?'NIL':$_partID)."]"); |
| 5511 | 5511 | if (!$_stream) |
| 5512 | 5512 | { |
| 5513 | - $rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID)?'NIL':$_partID)] = $body; |
|
| 5513 | + $rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)] = $body; |
|
| 5514 | 5514 | } |
| 5515 | 5515 | return $body; |
| 5516 | 5516 | } |
@@ -5525,13 +5525,13 @@ discard block |
||
| 5525 | 5525 | * @param Horde_Imap_Client_Fetch_Query $fquery=null default query just structure |
| 5526 | 5526 | * @return Horde_Mime_Part |
| 5527 | 5527 | */ |
| 5528 | - function getStructure($_uid, $_partID=null, $_folder=null, $_preserveSeen=false) |
|
| 5528 | + function getStructure($_uid, $_partID = null, $_folder = null, $_preserveSeen = false) |
|
| 5529 | 5529 | { |
| 5530 | - if (self::$debug) error_log( __METHOD__.' ('.__LINE__.') '.":$_uid, $_partID"); |
|
| 5530 | + if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.":$_uid, $_partID"); |
|
| 5531 | 5531 | |
| 5532 | 5532 | if (empty($_folder)) |
| 5533 | 5533 | { |
| 5534 | - $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5534 | + $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5535 | 5535 | } |
| 5536 | 5536 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5537 | 5537 | if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
@@ -5549,7 +5549,7 @@ discard block |
||
| 5549 | 5549 | 'ids' => $uidsToFetch, |
| 5550 | 5550 | ))->first(); |
| 5551 | 5551 | |
| 5552 | - return is_object($mail)?$mail->getStructure():null; |
|
| 5552 | + return is_object($mail) ? $mail->getStructure() : null; |
|
| 5553 | 5553 | } |
| 5554 | 5554 | catch (\Exception $e) |
| 5555 | 5555 | { |
@@ -5572,14 +5572,14 @@ discard block |
||
| 5572 | 5572 | * @param string $_folder folder to work on |
| 5573 | 5573 | * @return array an array of information about the attachment: array of array(name, size, mimeType, partID, encoding) |
| 5574 | 5574 | */ |
| 5575 | - function getMessageAttachments($_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folder='') |
|
| 5575 | + function getMessageAttachments($_uid, $_partID = null, Horde_Mime_Part $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = false, $resolveTNEF = true, $_folder = '') |
|
| 5576 | 5576 | { |
| 5577 | - if (self::$debug) error_log( __METHOD__.":$_uid, $_partID"); |
|
| 5578 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5577 | + if (self::$debug) error_log(__METHOD__.":$_uid, $_partID"); |
|
| 5578 | + if (empty($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5579 | 5579 | $attachments = array(); |
| 5580 | 5580 | if (!isset($_structure)) |
| 5581 | 5581 | { |
| 5582 | - $_structure = $this->getStructure($_uid, $_partID,$_folder,true); |
|
| 5582 | + $_structure = $this->getStructure($_uid, $_partID, $_folder, true); |
|
| 5583 | 5583 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.print_r($_structure->contentTypeMap(),true)); |
| 5584 | 5584 | } |
| 5585 | 5585 | if (!$_structure || !$_structure->contentTypeMap()) return array(); |
@@ -5587,7 +5587,7 @@ discard block |
||
| 5587 | 5587 | $skipParts = array(); |
| 5588 | 5588 | $tnefParts = array(); |
| 5589 | 5589 | $skip = 0; |
| 5590 | - foreach($_structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 5590 | + foreach ($_structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 5591 | 5591 | { |
| 5592 | 5592 | // skip multipart/encrypted incl. its two sub-parts, as we show 2. sub-part as body to be decrypted client-side |
| 5593 | 5593 | if ($mime_type == 'multipart/encrypted') |
@@ -5595,7 +5595,7 @@ discard block |
||
| 5595 | 5595 | $skip = 2; |
| 5596 | 5596 | continue; |
| 5597 | 5597 | } |
| 5598 | - elseif($skip) |
|
| 5598 | + elseif ($skip) |
|
| 5599 | 5599 | { |
| 5600 | 5600 | $skip--; |
| 5601 | 5601 | continue; |
@@ -5609,10 +5609,10 @@ discard block |
||
| 5609 | 5609 | $partPrimaryType = $part->getPrimaryType(); |
| 5610 | 5610 | // we only want to retrieve the attachments of the current mail, not those of possible |
| 5611 | 5611 | // attached mails |
| 5612 | - if ($mime_type=='message/rfc822' && $_partID!=$mime_id) |
|
| 5612 | + if ($mime_type == 'message/rfc822' && $_partID != $mime_id) |
|
| 5613 | 5613 | { |
| 5614 | 5614 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.':'.array2string($part->contentTypeMap())); |
| 5615 | - foreach($part->contentTypeMap() as $sub_id => $sub_type) {if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type;} |
|
| 5615 | + foreach ($part->contentTypeMap() as $sub_id => $sub_type) {if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type; } |
|
| 5616 | 5616 | } |
| 5617 | 5617 | if (empty($partDisposition) && $partPrimaryType != 'multipart' && $partPrimaryType != 'text') |
| 5618 | 5618 | { |
@@ -5620,27 +5620,27 @@ discard block |
||
| 5620 | 5620 | // attachment with no link to show the attachment inline. |
| 5621 | 5621 | // Considering this: we "list" everything that matches the above criteria |
| 5622 | 5622 | // as attachment in order to not loose/miss information on our data |
| 5623 | - $partDisposition='attachment'; |
|
| 5623 | + $partDisposition = 'attachment'; |
|
| 5624 | 5624 | } |
| 5625 | 5625 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.' Part:'.$_partID.'->'.$mime_id.':'.array2string($skipParts)); |
| 5626 | - if (array_key_exists($mime_id,$skipParts)) continue; |
|
| 5626 | + if (array_key_exists($mime_id, $skipParts)) continue; |
|
| 5627 | 5627 | |
| 5628 | 5628 | if ($partDisposition == 'attachment' || |
| 5629 | - (($partDisposition == 'inline' || empty($partDisposition)) && $partPrimaryType == 'image' && $part->getContentId()=='') || |
|
| 5629 | + (($partDisposition == 'inline' || empty($partDisposition)) && $partPrimaryType == 'image' && $part->getContentId() == '') || |
|
| 5630 | 5630 | (($partDisposition == 'inline' || empty($partDisposition)) && $partPrimaryType != 'image' && $partPrimaryType != 'text' && $partPrimaryType != 'multipart') || |
| 5631 | - ($mime_type=='image/tiff') || //always fetch. even if $fetchEmbeddedImages is false. as we cannot display tiffs |
|
| 5631 | + ($mime_type == 'image/tiff') || //always fetch. even if $fetchEmbeddedImages is false. as we cannot display tiffs |
|
| 5632 | 5632 | ($fetchEmbeddedImages && ($partDisposition == 'inline' || empty($partDisposition)) && $partPrimaryType == 'image') || |
| 5633 | 5633 | ($fetchTextCalendar && $partPrimaryType == 'text' && $part->getSubType() == 'calendar')) |
| 5634 | 5634 | { |
| 5635 | 5635 | // if type is message/rfc822 and _partID is given, and MimeID equals partID |
| 5636 | 5636 | // we attempt to fetch "ourselves" |
| 5637 | - if ($_partID==$part->getMimeId() && $part->getPrimaryType()=='message') continue; |
|
| 5637 | + if ($_partID == $part->getMimeId() && $part->getPrimaryType() == 'message') continue; |
|
| 5638 | 5638 | $attachment = $part->getAllDispositionParameters(); |
| 5639 | 5639 | $attachment['disposition'] = $part->getDisposition(); |
| 5640 | 5640 | $attachment['mimeType'] = $mime_type; |
| 5641 | 5641 | $attachment['uid'] = $_uid; |
| 5642 | 5642 | $attachment['partID'] = $mime_id; |
| 5643 | - if (!isset($attachment['name'])||empty($attachment['name'])) $attachment['name'] = $part->getName(); |
|
| 5643 | + if (!isset($attachment['name']) || empty($attachment['name'])) $attachment['name'] = $part->getName(); |
|
| 5644 | 5644 | if ($fetchTextCalendar) |
| 5645 | 5645 | { |
| 5646 | 5646 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($part->getAllContentTypeParameters())); |
@@ -5650,11 +5650,11 @@ discard block |
||
| 5650 | 5650 | } |
| 5651 | 5651 | $attachment['size'] = $part->getBytes(); |
| 5652 | 5652 | if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
| 5653 | - if (empty($attachment['name'])) $attachment['name'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($mime_type); |
|
| 5653 | + if (empty($attachment['name'])) $attachment['name'] = (isset($attachment['cid']) && !empty($attachment['cid']) ? $attachment['cid'] : lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($mime_type); |
|
| 5654 | 5654 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.' Part:'.$_partID.'->'.$mime_id.':'.array2string($attachment)); |
| 5655 | 5655 | //typical winmail.dat attachment is |
| 5656 | 5656 | //Array([size] => 1462762[filename] => winmail.dat[mimeType] => application/ms-tnef[uid] => 100[partID] => 2[name] => winmail.dat) |
| 5657 | - if ($resolveTNEF && ($attachment['mimeType']=='application/ms-tnef' || !strcasecmp($attachment['name'],'winmail.dat'))) |
|
| 5657 | + if ($resolveTNEF && ($attachment['mimeType'] == 'application/ms-tnef' || !strcasecmp($attachment['name'], 'winmail.dat'))) |
|
| 5658 | 5658 | { |
| 5659 | 5659 | $tnefParts[] = $attachment; |
| 5660 | 5660 | } |
@@ -5669,31 +5669,31 @@ discard block |
||
| 5669 | 5669 | //error_log(__METHOD__.__LINE__.array2string($tnefParts)); |
| 5670 | 5670 | foreach ($tnefParts as $k => $tnp) |
| 5671 | 5671 | { |
| 5672 | - $tnefResolved=false; |
|
| 5673 | - $tnef_data = $this->getAttachment($tnp['uid'],$tnp['partID'],$k,false); |
|
| 5672 | + $tnefResolved = false; |
|
| 5673 | + $tnef_data = $this->getAttachment($tnp['uid'], $tnp['partID'], $k, false); |
|
| 5674 | 5674 | $myTnef = $this->tnef_decoder($tnef_data['attachment']); |
| 5675 | 5675 | //error_log(__METHOD__.__LINE__.array2string($myTnef->getParts())); |
| 5676 | 5676 | // Note: MimeId starts with 0, almost always, we cannot use that as winmail_id |
| 5677 | 5677 | // we need to build Something that meets the needs |
| 5678 | 5678 | if ($myTnef) |
| 5679 | 5679 | { |
| 5680 | - foreach($myTnef->getParts() as $mime_id => $part) |
|
| 5680 | + foreach ($myTnef->getParts() as $mime_id => $part) |
|
| 5681 | 5681 | { |
| 5682 | - $tnefResolved=true; |
|
| 5682 | + $tnefResolved = true; |
|
| 5683 | 5683 | $attachment = $part->getAllDispositionParameters(); |
| 5684 | 5684 | $attachment['disposition'] = $part->getDisposition(); |
| 5685 | 5685 | $attachment['mimeType'] = $part->getType(); |
| 5686 | 5686 | $attachment['uid'] = $tnp['uid']; |
| 5687 | 5687 | $attachment['partID'] = $tnp['partID']; |
| 5688 | 5688 | $attachment['is_winmail'] = $tnp['uid'].'@'.$tnp['partID'].'@'.$mime_id; |
| 5689 | - if (!isset($attachment['name'])||empty($attachment['name'])) $attachment['name'] = $part->getName(); |
|
| 5689 | + if (!isset($attachment['name']) || empty($attachment['name'])) $attachment['name'] = $part->getName(); |
|
| 5690 | 5690 | $attachment['size'] = $part->getBytes(); |
| 5691 | 5691 | if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
| 5692 | - if (empty($attachment['name'])) $attachment['name'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']); |
|
| 5692 | + if (empty($attachment['name'])) $attachment['name'] = (isset($attachment['cid']) && !empty($attachment['cid']) ? $attachment['cid'] : lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']); |
|
| 5693 | 5693 | $attachments[] = $attachment; |
| 5694 | 5694 | } |
| 5695 | 5695 | } |
| 5696 | - if ($tnefResolved===false) $attachments[]=$tnp; |
|
| 5696 | + if ($tnefResolved === false) $attachments[] = $tnp; |
|
| 5697 | 5697 | } |
| 5698 | 5698 | } |
| 5699 | 5699 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
@@ -5708,9 +5708,9 @@ discard block |
||
| 5708 | 5708 | * @return boolean|Horde_Mime_part Multipart/Mixed part decoded attachments | |
| 5709 | 5709 | * return false if there's no attachments or failure |
| 5710 | 5710 | */ |
| 5711 | - public function tnef_decoder( $data ) |
|
| 5711 | + public function tnef_decoder($data) |
|
| 5712 | 5712 | { |
| 5713 | - foreach(array('Horde_Compress', 'Horde_Icalendar', 'Horde_Mapi') as $class) |
|
| 5713 | + foreach (array('Horde_Compress', 'Horde_Icalendar', 'Horde_Mapi') as $class) |
|
| 5714 | 5714 | { |
| 5715 | 5715 | if (!class_exists($class)) |
| 5716 | 5716 | { |
@@ -5742,7 +5742,7 @@ discard block |
||
| 5742 | 5742 | $tmp_part->setContents($data['stream']); |
| 5743 | 5743 | $tmp_part->setDescription($data['name']); |
| 5744 | 5744 | |
| 5745 | - $type = $data['type'] . '/' . $data['subtype']; |
|
| 5745 | + $type = $data['type'].'/'.$data['subtype']; |
|
| 5746 | 5746 | if (in_array($type, array('application/octet-stream', 'application/base64'))) |
| 5747 | 5747 | { |
| 5748 | 5748 | $type = Horde_Mime_Magic::filenameToMIME($data['name']); |
@@ -5785,24 +5785,24 @@ discard block |
||
| 5785 | 5785 | * |
| 5786 | 5786 | * @return array returns an array of all resolved embeded attachments from winmail.dat |
| 5787 | 5787 | */ |
| 5788 | - function getTnefAttachments ($_uid, $_partID, $_stream=false) |
|
| 5788 | + function getTnefAttachments($_uid, $_partID, $_stream = false) |
|
| 5789 | 5789 | { |
| 5790 | - $tnef_data = $this->getAttachment($_uid, $_partID,0,false); |
|
| 5790 | + $tnef_data = $this->getAttachment($_uid, $_partID, 0, false); |
|
| 5791 | 5791 | $tnef_parts = $this->tnef_decoder($tnef_data['attachment']); |
| 5792 | 5792 | $attachments = array(); |
| 5793 | 5793 | if ($tnef_parts) |
| 5794 | 5794 | { |
| 5795 | - foreach($tnef_parts->getParts() as $mime_id => $part) |
|
| 5795 | + foreach ($tnef_parts->getParts() as $mime_id => $part) |
|
| 5796 | 5796 | { |
| 5797 | 5797 | |
| 5798 | 5798 | $attachment = $part->getAllDispositionParameters(); |
| 5799 | 5799 | $attachment['mimeType'] = $part->getType(); |
| 5800 | - if (!isset($attachment['filename'])||empty($attachment['filename'])) $attachment['filename'] = $part->getName(); |
|
| 5800 | + if (!isset($attachment['filename']) || empty($attachment['filename'])) $attachment['filename'] = $part->getName(); |
|
| 5801 | 5801 | if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
| 5802 | 5802 | if (empty($attachment['filename'])) |
| 5803 | 5803 | { |
| 5804 | - $attachment['filename'] = (isset($attachment['cid'])&&!empty($attachment['cid'])? |
|
| 5805 | - $attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']); |
|
| 5804 | + $attachment['filename'] = (isset($attachment['cid']) && !empty($attachment['cid']) ? |
|
| 5805 | + $attachment['cid'] : lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']); |
|
| 5806 | 5806 | } |
| 5807 | 5807 | |
| 5808 | 5808 | $attachment['attachment'] = $part->getContents(array('stream'=>$_stream)); |
@@ -5826,10 +5826,10 @@ discard block |
||
| 5826 | 5826 | * |
| 5827 | 5827 | * @return array |
| 5828 | 5828 | */ |
| 5829 | - function getAttachment($_uid, $_partID, $_winmail_nr=0, $_returnPart=true, $_stream=false, $_folder=null) |
|
| 5829 | + function getAttachment($_uid, $_partID, $_winmail_nr = 0, $_returnPart = true, $_stream = false, $_folder = null) |
|
| 5830 | 5830 | { |
| 5831 | 5831 | //error_log(__METHOD__.__LINE__."Uid:$_uid, PartId:$_partID, WinMailNr:$_winmail_nr, ReturnPart:$_returnPart, Stream:$_stream, Folder:$_folder".function_backtrace()); |
| 5832 | - if (!isset($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5832 | + if (!isset($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5833 | 5833 | |
| 5834 | 5834 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5835 | 5835 | if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
@@ -5842,36 +5842,36 @@ discard block |
||
| 5842 | 5842 | 'ids' => $uidsToFetch, |
| 5843 | 5843 | )); |
| 5844 | 5844 | if (is_object($headersNew)) { |
| 5845 | - foreach($headersNew as $id=>$_headerObject) { |
|
| 5845 | + foreach ($headersNew as $id=>$_headerObject) { |
|
| 5846 | 5846 | $body = $_headerObject->getFullMsg(); |
| 5847 | 5847 | if ($_partID != '') |
| 5848 | 5848 | { |
| 5849 | 5849 | $mailStructureObject = $_headerObject->getStructure(); |
| 5850 | 5850 | $mailStructureObject->contentTypeMap(); |
| 5851 | 5851 | $part = $mailStructureObject->getPart($_partID); |
| 5852 | - $partDisposition = ($part?$part->getDisposition():'failed'); |
|
| 5853 | - if ($partDisposition=='failed') |
|
| 5852 | + $partDisposition = ($part ? $part->getDisposition() : 'failed'); |
|
| 5853 | + if ($partDisposition == 'failed') |
|
| 5854 | 5854 | { |
| 5855 | 5855 | error_log(__METHOD__.'('.__LINE__.'):'.array2string($_uid).','.$_partID.' ID:'.$id.' HObject:'.array2string($_headerObject).' StructureObject:'.array2string($mailStructureObject->contentTypeMap()).'->'.function_backtrace()); |
| 5856 | 5856 | } |
| 5857 | 5857 | // if $partDisposition is empty, we assume attachment, and hope that the function |
| 5858 | 5858 | // itself is only triggered to fetch attachments |
| 5859 | - if (empty($partDisposition)) $partDisposition='attachment'; |
|
| 5860 | - if ($part && ($partDisposition=='attachment' || $partDisposition=='inline' || ($part->getPrimaryType() == 'text' && $part->getSubType() == 'calendar'))) |
|
| 5859 | + if (empty($partDisposition)) $partDisposition = 'attachment'; |
|
| 5860 | + if ($part && ($partDisposition == 'attachment' || $partDisposition == 'inline' || ($part->getPrimaryType() == 'text' && $part->getSubType() == 'calendar'))) |
|
| 5861 | 5861 | { |
| 5862 | 5862 | //$headerObject=$part->getAllDispositionParameters();//not used anywhere around here |
| 5863 | 5863 | $structure_mime = $part->getType(); |
| 5864 | 5864 | $filename = $part->getName(); |
| 5865 | 5865 | $charset = $part->getContentTypeParameter('charset'); |
| 5866 | 5866 | //$structure_bytes = $part->getBytes(); $structure_partID=$part->getMimeId(); error_log(__METHOD__.__LINE__." fetchPartContents(".array2string($_uid).", $structure_partID, $_stream, $_preserveSeen,$structure_mime)" ); |
| 5867 | - $this->fetchPartContents($_uid, $part, $_stream, $_preserveSeen=true,$structure_mime); |
|
| 5867 | + $this->fetchPartContents($_uid, $part, $_stream, $_preserveSeen = true, $structure_mime); |
|
| 5868 | 5868 | if ($_returnPart) return $part; |
| 5869 | 5869 | } |
| 5870 | 5870 | } |
| 5871 | 5871 | } |
| 5872 | 5872 | } |
| 5873 | 5873 | $ext = MimeMagic::mime2ext($structure_mime); |
| 5874 | - if ($ext && stripos($filename,'.')===false && stripos($filename,$ext)===false) $filename = trim($filename).'.'.$ext; |
|
| 5874 | + if ($ext && stripos($filename, '.') === false && stripos($filename, $ext) === false) $filename = trim($filename).'.'.$ext; |
|
| 5875 | 5875 | if (!$part) |
| 5876 | 5876 | { |
| 5877 | 5877 | throw new Exception\WrongParameter("Error: Could not fetch attachment for Uid=".array2string($_uid).", PartId=$_partID, WinMailNr=$_winmail_nr, folder=$_folder"); |
@@ -5889,20 +5889,20 @@ discard block |
||
| 5889 | 5889 | // try guessing the mimetype, if we get the application/octet-stream |
| 5890 | 5890 | if (strtolower($attachmentData['type']) == 'application/octet-stream') $attachmentData['type'] = MimeMagic::filename2mime($attachmentData['filename']); |
| 5891 | 5891 | # if the attachment holds a winmail number and is a winmail.dat then we have to handle that. |
| 5892 | - if ( $filename == 'winmail.dat' && $_winmail_nr) |
|
| 5892 | + if ($filename == 'winmail.dat' && $_winmail_nr) |
|
| 5893 | 5893 | { |
| 5894 | 5894 | //by now _uid is of type array |
| 5895 | - $tnefResolved=false; |
|
| 5896 | - $wantedPart=$_uid[0].'@'.$_partID; |
|
| 5895 | + $tnefResolved = false; |
|
| 5896 | + $wantedPart = $_uid[0].'@'.$_partID; |
|
| 5897 | 5897 | $myTnef = $this->tnef_decoder($attachmentData['attachment']); |
| 5898 | 5898 | //error_log(__METHOD__.__LINE__.array2string($myTnef->getParts())); |
| 5899 | 5899 | // Note: MimeId starts with 0, almost always, we cannot use that as winmail_id |
| 5900 | 5900 | // we need to build Something that meets the needs |
| 5901 | 5901 | if ($myTnef) |
| 5902 | 5902 | { |
| 5903 | - foreach($myTnef->getParts() as $mime_id => $part) |
|
| 5903 | + foreach ($myTnef->getParts() as $mime_id => $part) |
|
| 5904 | 5904 | { |
| 5905 | - $tnefResolved=true; |
|
| 5905 | + $tnefResolved = true; |
|
| 5906 | 5906 | $attachment = $part->getAllDispositionParameters(); |
| 5907 | 5907 | $attachment['mimeType'] = $part->getType(); |
| 5908 | 5908 | //error_log(__METHOD__.__LINE__.'#'.$mime_id.'#'.$filename.'#'.array2string($attachment)); |
@@ -5910,9 +5910,9 @@ discard block |
||
| 5910 | 5910 | if ($_winmail_nr == $wantedPart.'@'.$mime_id) |
| 5911 | 5911 | { |
| 5912 | 5912 | //error_log(__METHOD__.__LINE__.'#'.$structure_mime.'#'.$filename.'#'.array2string($attachment)); |
| 5913 | - if (!isset($attachment['filename'])||empty($attachment['filename'])) $attachment['filename'] = $part->getName(); |
|
| 5913 | + if (!isset($attachment['filename']) || empty($attachment['filename'])) $attachment['filename'] = $part->getName(); |
|
| 5914 | 5914 | if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
| 5915 | - if (empty($attachment['filename'])) $attachment['filename'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']); |
|
| 5915 | + if (empty($attachment['filename'])) $attachment['filename'] = (isset($attachment['cid']) && !empty($attachment['cid']) ? $attachment['cid'] : lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']); |
|
| 5916 | 5916 | $wmattach = $attachment; |
| 5917 | 5917 | $wmattach['attachment'] = $part->getContents(array('stream'=>$_stream)); |
| 5918 | 5918 | |
@@ -5922,7 +5922,7 @@ discard block |
||
| 5922 | 5922 | if ($tnefResolved) |
| 5923 | 5923 | { |
| 5924 | 5924 | $ext = MimeMagic::mime2ext($wmattach['mimeType']); |
| 5925 | - if ($ext && stripos($wmattach['filename'],'.')===false && stripos($wmattach['filename'],$ext)===false) $wmattach['filename'] = trim($wmattach['filename']).'.'.$ext; |
|
| 5925 | + if ($ext && stripos($wmattach['filename'], '.') === false && stripos($wmattach['filename'], $ext) === false) $wmattach['filename'] = trim($wmattach['filename']).'.'.$ext; |
|
| 5926 | 5926 | $attachmentData = array( |
| 5927 | 5927 | 'type' => $wmattach['mimeType'], |
| 5928 | 5928 | 'filename' => $wmattach['filename'], |
@@ -5946,21 +5946,21 @@ discard block |
||
| 5946 | 5946 | * true: |
| 5947 | 5947 | * @return Horde_Mime_Part |
| 5948 | 5948 | */ |
| 5949 | - function getAttachmentByCID($_uid, $_cid, $_part, $_stream=null) |
|
| 5949 | + function getAttachmentByCID($_uid, $_cid, $_part, $_stream = null) |
|
| 5950 | 5950 | { |
| 5951 | 5951 | // some static variables to avoid fetching the same mail multiple times |
| 5952 | - static $uid=null, $part=null, $structure=null; |
|
| 5952 | + static $uid = null, $part = null, $structure = null; |
|
| 5953 | 5953 | //error_log(__METHOD__.' ('.__LINE__.') '.":$_uid, $_cid, $_part"); |
| 5954 | 5954 | |
| 5955 | - if(empty($_cid)) return false; |
|
| 5955 | + if (empty($_cid)) return false; |
|
| 5956 | 5956 | |
| 5957 | 5957 | if ($_uid != $uid || $_part != $part) |
| 5958 | 5958 | { |
| 5959 | - $structure = $this->getStructure($uid=$_uid, $part=$_part); |
|
| 5959 | + $structure = $this->getStructure($uid = $_uid, $part = $_part); |
|
| 5960 | 5960 | } |
| 5961 | 5961 | /** @var Horde_Mime_Part */ |
| 5962 | 5962 | $attachment = null; |
| 5963 | - foreach($structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 5963 | + foreach ($structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 5964 | 5964 | { |
| 5965 | 5965 | $part = $structure->getPart($mime_id); |
| 5966 | 5966 | |
@@ -6012,16 +6012,16 @@ discard block |
||
| 6012 | 6012 | * @param string $_mimetype to decide wether to try to fetch part as binary or not |
| 6013 | 6013 | * @return Horde_Mime_Part |
| 6014 | 6014 | */ |
| 6015 | - public function fetchPartContents($_uid, Horde_Mime_Part $part=null, $_stream=false, $_preserveSeen=false, $_mimetype=null) |
|
| 6015 | + public function fetchPartContents($_uid, Horde_Mime_Part $part = null, $_stream = false, $_preserveSeen = false, $_mimetype = null) |
|
| 6016 | 6016 | { |
| 6017 | - if (is_null($part)) return null;//new Horde_Mime_Part; |
|
| 6017 | + if (is_null($part)) return null; //new Horde_Mime_Part; |
|
| 6018 | 6018 | $encoding = null; |
| 6019 | 6019 | $fetchAsBinary = true; |
| 6020 | - if ($_mimetype && strtolower($_mimetype)=='message/rfc822') $fetchAsBinary = false; |
|
| 6020 | + if ($_mimetype && strtolower($_mimetype) == 'message/rfc822') $fetchAsBinary = false; |
|
| 6021 | 6021 | // we need to set content on structure to decode transfer encoding |
| 6022 | 6022 | $part->setContents( |
| 6023 | 6023 | $this->getBodyPart($_uid, $part->getMimeId(), null, $_preserveSeen, $_stream, $encoding, $fetchAsBinary), |
| 6024 | - array('encoding' => (!$fetchAsBinary&&!$encoding?'8bit':$encoding))); |
|
| 6024 | + array('encoding' => (!$fetchAsBinary && !$encoding ? '8bit' : $encoding))); |
|
| 6025 | 6025 | |
| 6026 | 6026 | return $part; |
| 6027 | 6027 | } |
@@ -6039,17 +6039,17 @@ discard block |
||
| 6039 | 6039 | * @return the id of the message appended or exception |
| 6040 | 6040 | * @throws Exception\WrongUserinput |
| 6041 | 6041 | */ |
| 6042 | - function appendMessage($_folderName, $_header, $_body, $_flags='\\Recent') |
|
| 6042 | + function appendMessage($_folderName, $_header, $_body, $_flags = '\\Recent') |
|
| 6043 | 6043 | { |
| 6044 | 6044 | if (!is_resource($_header)) |
| 6045 | 6045 | { |
| 6046 | - if (stripos($_header,'message-id:')===false) |
|
| 6046 | + if (stripos($_header, 'message-id:') === false) |
|
| 6047 | 6047 | { |
| 6048 | 6048 | $_header = 'Message-ID: <'.self::getRandomString().'@localhost>'."\n".$_header; |
| 6049 | 6049 | } |
| 6050 | 6050 | //error_log(__METHOD__.' ('.__LINE__.') '."$_folderName, $_header, $_body, $_flags"); |
| 6051 | - $_header = ltrim(str_replace("\n","\r\n",$_header)); |
|
| 6052 | - $_header .= str_replace("\n","\r\n",$_body); |
|
| 6051 | + $_header = ltrim(str_replace("\n", "\r\n", $_header)); |
|
| 6052 | + $_header .= str_replace("\n", "\r\n", $_body); |
|
| 6053 | 6053 | } |
| 6054 | 6054 | // the recent flag is the default enforced here ; as we assume the _flags is always set, |
| 6055 | 6055 | // we default it to hordes default (Recent) (, other wise we should not pass the parameter |
@@ -6067,7 +6067,7 @@ discard block |
||
| 6067 | 6067 | // searched for the message-id then returning the uid found |
| 6068 | 6068 | //$dataNflags[] = array('data'=>array(array('t'=>'text','v'=>"$header"."$body")), 'flags'=>array($_flags)); |
| 6069 | 6069 | $dataNflags[] = array('data' => $_header, 'flags'=>array($_flags)); |
| 6070 | - $messageid = $this->icServer->append($_folderName,$dataNflags); |
|
| 6070 | + $messageid = $this->icServer->append($_folderName, $dataNflags); |
|
| 6071 | 6071 | } |
| 6072 | 6072 | catch (\Exception $e) |
| 6073 | 6073 | { |
@@ -6079,7 +6079,7 @@ discard block |
||
| 6079 | 6079 | //$messageid = true; // for debug reasons only |
| 6080 | 6080 | if ($messageid === true || empty($messageid)) // try to figure out the message uid |
| 6081 | 6081 | { |
| 6082 | - $list = $this->getHeaders($_folderName, $_startMessage=1, 1, 'INTERNALDATE', true, array(),null, false); |
|
| 6082 | + $list = $this->getHeaders($_folderName, $_startMessage = 1, 1, 'INTERNALDATE', true, array(), null, false); |
|
| 6083 | 6083 | if ($list) |
| 6084 | 6084 | { |
| 6085 | 6085 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' MessageUid:'.$messageid.' but found:'.array2string($list)); |
@@ -6119,27 +6119,27 @@ discard block |
||
| 6119 | 6119 | * 'attachments'=>$attachments, |
| 6120 | 6120 | * 'headers'=>$headers,; boolean false on failure |
| 6121 | 6121 | */ |
| 6122 | - static function get_mailcontent(&$mailClass,$uid,$partid='',$mailbox='', $preserveHTML = false, $addHeaderSection=true, $includeAttachments=true) |
|
| 6122 | + static function get_mailcontent(&$mailClass, $uid, $partid = '', $mailbox = '', $preserveHTML = false, $addHeaderSection = true, $includeAttachments = true) |
|
| 6123 | 6123 | { |
| 6124 | 6124 | //echo __METHOD__." called for $uid,$partid <br>"; |
| 6125 | - $headers = $mailClass->getMessageHeader($uid,$partid,true,false,$mailbox); |
|
| 6125 | + $headers = $mailClass->getMessageHeader($uid, $partid, true, false, $mailbox); |
|
| 6126 | 6126 | if (empty($headers)) return false; |
| 6127 | 6127 | // dont force retrieval of the textpart, let mailClass preferences decide |
| 6128 | - $bodyParts = $mailClass->getMessageBody($uid,($preserveHTML?'always_display':'only_if_no_text'),$partid,null,false,$mailbox); |
|
| 6128 | + $bodyParts = $mailClass->getMessageBody($uid, ($preserveHTML ? 'always_display' : 'only_if_no_text'), $partid, null, false, $mailbox); |
|
| 6129 | 6129 | // if we do not want HTML but there is no TextRepresentation with the message itself, try converting |
| 6130 | - if ( !$preserveHTML && $bodyParts[0]['mimeType']=='text/html') |
|
| 6130 | + if (!$preserveHTML && $bodyParts[0]['mimeType'] == 'text/html') |
|
| 6131 | 6131 | { |
| 6132 | - foreach($bodyParts as $i => $part) |
|
| 6132 | + foreach ($bodyParts as $i => $part) |
|
| 6133 | 6133 | { |
| 6134 | - if ($bodyParts[$i]['mimeType']=='text/html') |
|
| 6134 | + if ($bodyParts[$i]['mimeType'] == 'text/html') |
|
| 6135 | 6135 | { |
| 6136 | - $bodyParts[$i]['body'] = Mail\Html::convertHTMLToText($bodyParts[$i]['body'],$bodyParts[$i]['charSet'],true,$stripalltags=true); |
|
| 6137 | - $bodyParts[$i]['mimeType']='text/plain'; |
|
| 6136 | + $bodyParts[$i]['body'] = Mail\Html::convertHTMLToText($bodyParts[$i]['body'], $bodyParts[$i]['charSet'], true, $stripalltags = true); |
|
| 6137 | + $bodyParts[$i]['mimeType'] = 'text/plain'; |
|
| 6138 | 6138 | } |
| 6139 | 6139 | } |
| 6140 | 6140 | } |
| 6141 | 6141 | //error_log(array2string($bodyParts)); |
| 6142 | - $attachments = $includeAttachments?$mailClass->getMessageAttachments($uid,$partid,null,true,false,true,$mailbox):array(); |
|
| 6142 | + $attachments = $includeAttachments ? $mailClass->getMessageAttachments($uid, $partid, null, true, false, true, $mailbox) : array(); |
|
| 6143 | 6143 | |
| 6144 | 6144 | if ($mailClass->isSentFolder($mailbox)) $mailaddress = $headers['TO']; |
| 6145 | 6145 | elseif (isset($headers['FROM'])) $mailaddress = $headers['FROM']; |
@@ -6150,7 +6150,7 @@ discard block |
||
| 6150 | 6150 | |
| 6151 | 6151 | $message = self::getdisplayableBody($mailClass, $bodyParts, $preserveHTML); |
| 6152 | 6152 | if ($preserveHTML && $mailClass->activeMimeType == 'text/plain') $message = '<pre>'.$message.'</pre>'; |
| 6153 | - $headdata = ($addHeaderSection ? self::createHeaderInfoSection($headers, '',$preserveHTML) : ''); |
|
| 6153 | + $headdata = ($addHeaderSection ? self::createHeaderInfoSection($headers, '', $preserveHTML) : ''); |
|
| 6154 | 6154 | $message = $headdata.$message; |
| 6155 | 6155 | //echo __METHOD__.'<br>'; |
| 6156 | 6156 | //_debug_array($attachments); |
@@ -6166,25 +6166,25 @@ discard block |
||
| 6166 | 6166 | //_debug_array($mailClass->getMessageHeader($uid, $attachment['partID'])); |
| 6167 | 6167 | //_debug_array($mailClass->getMessageBody($uid,'', $attachment['partID'])); |
| 6168 | 6168 | //_debug_array($mailClass->getMessageAttachments($uid, $attachment['partID'])); |
| 6169 | - $mailcontent = self::get_mailcontent($mailClass,$uid,$attachment['partID'],$mailbox); |
|
| 6170 | - $headdata =''; |
|
| 6169 | + $mailcontent = self::get_mailcontent($mailClass, $uid, $attachment['partID'], $mailbox); |
|
| 6170 | + $headdata = ''; |
|
| 6171 | 6171 | if ($mailcontent['headers']) |
| 6172 | 6172 | { |
| 6173 | - $headdata = self::createHeaderInfoSection($mailcontent['headers'],'',$preserveHTML); |
|
| 6173 | + $headdata = self::createHeaderInfoSection($mailcontent['headers'], '', $preserveHTML); |
|
| 6174 | 6174 | } |
| 6175 | 6175 | if ($mailcontent['message']) |
| 6176 | 6176 | { |
| 6177 | - $tempname =tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_"); |
|
| 6177 | + $tempname = tempnam($GLOBALS['egw_info']['server']['temp_dir'], $GLOBALS['egw_info']['flags']['currentapp']."_"); |
|
| 6178 | 6178 | $attachedMessages[] = array( |
| 6179 | 6179 | 'type' => 'TEXT/PLAIN', |
| 6180 | 6180 | 'name' => $mailcontent['subject'].'.txt', |
| 6181 | 6181 | 'tmp_name' => $tempname, |
| 6182 | 6182 | ); |
| 6183 | - $tmpfile = fopen($tempname,'w'); |
|
| 6184 | - fwrite($tmpfile,$headdata.$mailcontent['message']); |
|
| 6183 | + $tmpfile = fopen($tempname, 'w'); |
|
| 6184 | + fwrite($tmpfile, $headdata.$mailcontent['message']); |
|
| 6185 | 6185 | fclose($tmpfile); |
| 6186 | 6186 | } |
| 6187 | - foreach($mailcontent['attachments'] as &$tmpval) |
|
| 6187 | + foreach ($mailcontent['attachments'] as &$tmpval) |
|
| 6188 | 6188 | { |
| 6189 | 6189 | $attachedMessages[] = $tmpval; |
| 6190 | 6190 | } |
@@ -6192,36 +6192,36 @@ discard block |
||
| 6192 | 6192 | } |
| 6193 | 6193 | else |
| 6194 | 6194 | { |
| 6195 | - $attachments[$num] = array_merge($attachments[$num],$mailClass->getAttachment($uid, $attachment['partID'],0,false,false)); |
|
| 6195 | + $attachments[$num] = array_merge($attachments[$num], $mailClass->getAttachment($uid, $attachment['partID'], 0, false, false)); |
|
| 6196 | 6196 | |
| 6197 | - if (empty($attachments[$num]['attachment'])&&$attachments[$num]['cid']) |
|
| 6197 | + if (empty($attachments[$num]['attachment']) && $attachments[$num]['cid']) |
|
| 6198 | 6198 | { |
| 6199 | - $c = $mailClass->getAttachmentByCID($uid, $attachment['cid'], $attachment['partID'],true); |
|
| 6199 | + $c = $mailClass->getAttachmentByCID($uid, $attachment['cid'], $attachment['partID'], true); |
|
| 6200 | 6200 | $attachments[$num]['attachment'] = $c->getContents(); |
| 6201 | 6201 | } |
| 6202 | 6202 | // no attempt to convert, if we dont know about the charset |
| 6203 | - if (isset($attachments[$num]['charset'])&&!empty($attachments[$num]['charset'])) { |
|
| 6203 | + if (isset($attachments[$num]['charset']) && !empty($attachments[$num]['charset'])) { |
|
| 6204 | 6204 | // we do not try guessing the charset, if it is not set |
| 6205 | 6205 | //if ($attachments[$num]['charset']===false) $attachments[$num]['charset'] = Translation::detect_encoding($attachments[$num]['attachment']); |
| 6206 | - Translation::convert($attachments[$num]['attachment'],$attachments[$num]['charset']); |
|
| 6206 | + Translation::convert($attachments[$num]['attachment'], $attachments[$num]['charset']); |
|
| 6207 | 6207 | } |
| 6208 | - if(in_array($attachments[$num]['name'], $file_list)) |
|
| 6208 | + if (in_array($attachments[$num]['name'], $file_list)) |
|
| 6209 | 6209 | { |
| 6210 | 6210 | $dupe_count[$attachments[$num]['name']]++; |
| 6211 | - $attachments[$num]['name'] = pathinfo($attachments[$num]['name'], PATHINFO_FILENAME) . |
|
| 6212 | - ' ('.($dupe_count[$attachments[$num]['name']] + 1).')' . '.' . |
|
| 6211 | + $attachments[$num]['name'] = pathinfo($attachments[$num]['name'], PATHINFO_FILENAME). |
|
| 6212 | + ' ('.($dupe_count[$attachments[$num]['name']] + 1).')'.'.'. |
|
| 6213 | 6213 | pathinfo($attachments[$num]['name'], PATHINFO_EXTENSION); |
| 6214 | 6214 | } |
| 6215 | 6215 | $attachments[$num]['type'] = $attachments[$num]['mimeType']; |
| 6216 | - $attachments[$num]['tmp_name'] = tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_"); |
|
| 6217 | - $tmpfile = fopen($attachments[$num]['tmp_name'],'w'); |
|
| 6218 | - fwrite($tmpfile,$attachments[$num]['attachment']); |
|
| 6216 | + $attachments[$num]['tmp_name'] = tempnam($GLOBALS['egw_info']['server']['temp_dir'], $GLOBALS['egw_info']['flags']['currentapp']."_"); |
|
| 6217 | + $tmpfile = fopen($attachments[$num]['tmp_name'], 'w'); |
|
| 6218 | + fwrite($tmpfile, $attachments[$num]['attachment']); |
|
| 6219 | 6219 | fclose($tmpfile); |
| 6220 | 6220 | $file_list[] = $attachments[$num]['name']; |
| 6221 | 6221 | unset($attachments[$num]['attachment']); |
| 6222 | 6222 | } |
| 6223 | 6223 | } |
| 6224 | - if (is_array($attachedMessages)) $attachments = array_merge($attachments,$attachedMessages); |
|
| 6224 | + if (is_array($attachedMessages)) $attachments = array_merge($attachments, $attachedMessages); |
|
| 6225 | 6225 | } |
| 6226 | 6226 | return array( |
| 6227 | 6227 | 'mailaddress'=>$mailaddress, |
@@ -6243,10 +6243,10 @@ discard block |
||
| 6243 | 6243 | { |
| 6244 | 6244 | $c = 0; |
| 6245 | 6245 | // use the standardIdentity |
| 6246 | - foreach($_identities as $key => $acc) { |
|
| 6247 | - if ($c==0) $identity = $acc; |
|
| 6246 | + foreach ($_identities as $key => $acc) { |
|
| 6247 | + if ($c == 0) $identity = $acc; |
|
| 6248 | 6248 | //error_log(__METHOD__.__LINE__." $key == $_profile_id "); |
| 6249 | - if ($key==$_profile_id) $identity = $acc; |
|
| 6249 | + if ($key == $_profile_id) $identity = $acc; |
|
| 6250 | 6250 | $c++; |
| 6251 | 6251 | } |
| 6252 | 6252 | return $identity; |
@@ -6258,29 +6258,29 @@ discard block |
||
| 6258 | 6258 | * @param bool createHTML do it with HTML breaks |
| 6259 | 6259 | * @return string a preformatted string with the information of the header worked into it |
| 6260 | 6260 | */ |
| 6261 | - static function createHeaderInfoSection($header,$headline='', $createHTML = false) |
|
| 6261 | + static function createHeaderInfoSection($header, $headline = '', $createHTML = false) |
|
| 6262 | 6262 | { |
| 6263 | 6263 | $headdata = null; |
| 6264 | 6264 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($header).function_backtrace()); |
| 6265 | - if ($header['SUBJECT']) $headdata = lang('subject').': '.$header['SUBJECT'].($createHTML?"<br />":"\n"); |
|
| 6266 | - if ($header['FROM']) $headdata .= lang('from').': '.self::convertAddressArrayToString($header['FROM'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6267 | - if ($header['SENDER']) $headdata .= lang('sender').': '.self::convertAddressArrayToString($header['SENDER'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6268 | - if ($header['TO']) $headdata .= lang('to').': '.self::convertAddressArrayToString($header['TO'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6269 | - if ($header['CC']) $headdata .= lang('cc').': '.self::convertAddressArrayToString($header['CC'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6270 | - if ($header['BCC']) $headdata .= lang('bcc').': '.self::convertAddressArrayToString($header['BCC'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6271 | - if ($header['DATE']) $headdata .= lang('date').': '.$header['DATE'].($createHTML?"<br />":"\n"); |
|
| 6272 | - if ($header['PRIORITY'] && $header['PRIORITY'] != 'normal') $headdata .= lang('priority').': '.$header['PRIORITY'].($createHTML?"<br />":"\n"); |
|
| 6273 | - if ($header['IMPORTANCE'] && $header['IMPORTANCE'] !='normal') $headdata .= lang('importance').': '.$header['IMPORTANCE'].($createHTML?"<br />":"\n"); |
|
| 6265 | + if ($header['SUBJECT']) $headdata = lang('subject').': '.$header['SUBJECT'].($createHTML ? "<br />" : "\n"); |
|
| 6266 | + if ($header['FROM']) $headdata .= lang('from').': '.self::convertAddressArrayToString($header['FROM'], $createHTML).($createHTML ? "<br />" : "\n"); |
|
| 6267 | + if ($header['SENDER']) $headdata .= lang('sender').': '.self::convertAddressArrayToString($header['SENDER'], $createHTML).($createHTML ? "<br />" : "\n"); |
|
| 6268 | + if ($header['TO']) $headdata .= lang('to').': '.self::convertAddressArrayToString($header['TO'], $createHTML).($createHTML ? "<br />" : "\n"); |
|
| 6269 | + if ($header['CC']) $headdata .= lang('cc').': '.self::convertAddressArrayToString($header['CC'], $createHTML).($createHTML ? "<br />" : "\n"); |
|
| 6270 | + if ($header['BCC']) $headdata .= lang('bcc').': '.self::convertAddressArrayToString($header['BCC'], $createHTML).($createHTML ? "<br />" : "\n"); |
|
| 6271 | + if ($header['DATE']) $headdata .= lang('date').': '.$header['DATE'].($createHTML ? "<br />" : "\n"); |
|
| 6272 | + if ($header['PRIORITY'] && $header['PRIORITY'] != 'normal') $headdata .= lang('priority').': '.$header['PRIORITY'].($createHTML ? "<br />" : "\n"); |
|
| 6273 | + if ($header['IMPORTANCE'] && $header['IMPORTANCE'] != 'normal') $headdata .= lang('importance').': '.$header['IMPORTANCE'].($createHTML ? "<br />" : "\n"); |
|
| 6274 | 6274 | //if ($mailcontent['headers']['ORGANIZATION']) $headdata .= lang('organization').': '.$mailcontent['headers']['ORGANIZATION']."\ |
| 6275 | 6275 | if (!empty($headdata)) |
| 6276 | 6276 | { |
| 6277 | - if (!empty($headline) && $headline != 'SUPPRESS') $headdata = "---------------------------- $headline ----------------------------".($createHTML?"<br />":"\n").$headdata; |
|
| 6278 | - if (empty($headline)) $headdata = ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):'').$headdata; |
|
| 6279 | - $headdata .= ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):''); |
|
| 6277 | + if (!empty($headline) && $headline != 'SUPPRESS') $headdata = "---------------------------- $headline ----------------------------".($createHTML ? "<br />" : "\n").$headdata; |
|
| 6278 | + if (empty($headline)) $headdata = ($headline != 'SUPPRESS' ? "--------------------------------------------------------".($createHTML ? "<br />" : "\n") : '').$headdata; |
|
| 6279 | + $headdata .= ($headline != 'SUPPRESS' ? "--------------------------------------------------------".($createHTML ? "<br />" : "\n") : ''); |
|
| 6280 | 6280 | } |
| 6281 | 6281 | else |
| 6282 | 6282 | { |
| 6283 | - $headdata = ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):''); |
|
| 6283 | + $headdata = ($headline != 'SUPPRESS' ? "--------------------------------------------------------".($createHTML ? "<br />" : "\n") : ''); |
|
| 6284 | 6284 | } |
| 6285 | 6285 | return $headdata; |
| 6286 | 6286 | } |
@@ -6293,8 +6293,8 @@ discard block |
||
| 6293 | 6293 | */ |
| 6294 | 6294 | static function adaptSubjectForImport($subject) |
| 6295 | 6295 | { |
| 6296 | - $subject = str_replace('$$','__',($subject?$subject:lang('(no subject)'))); |
|
| 6297 | - $subject = str_ireplace(array('[FWD]','[',']','{','}','<','>'),array('Fwd:',' ',' ',' ',' ',' ',' '),trim($subject)); |
|
| 6296 | + $subject = str_replace('$$', '__', ($subject ? $subject : lang('(no subject)'))); |
|
| 6297 | + $subject = str_ireplace(array('[FWD]', '[', ']', '{', '}', '<', '>'), array('Fwd:', ' ', ' ', ' ', ' ', ' ', ' '), trim($subject)); |
|
| 6298 | 6298 | return $subject; |
| 6299 | 6299 | } |
| 6300 | 6300 | |
@@ -6306,15 +6306,15 @@ discard block |
||
| 6306 | 6306 | static function convertAddressArrayToString($rfcAddressArray) |
| 6307 | 6307 | { |
| 6308 | 6308 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($rfcAddressArray)); |
| 6309 | - $returnAddr =''; |
|
| 6309 | + $returnAddr = ''; |
|
| 6310 | 6310 | if (is_array($rfcAddressArray)) |
| 6311 | 6311 | { |
| 6312 | - foreach((array)$rfcAddressArray as $addressData) { |
|
| 6312 | + foreach ((array)$rfcAddressArray as $addressData) { |
|
| 6313 | 6313 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($addressData)); |
| 6314 | - if($addressData['MAILBOX_NAME'] == 'NIL') { |
|
| 6314 | + if ($addressData['MAILBOX_NAME'] == 'NIL') { |
|
| 6315 | 6315 | continue; |
| 6316 | 6316 | } |
| 6317 | - if(strtolower($addressData['MAILBOX_NAME']) == 'undisclosed-recipients') { |
|
| 6317 | + if (strtolower($addressData['MAILBOX_NAME']) == 'undisclosed-recipients') { |
|
| 6318 | 6318 | continue; |
| 6319 | 6319 | } |
| 6320 | 6320 | if ($addressData['RFC822_EMAIL']) |
@@ -6323,7 +6323,7 @@ discard block |
||
| 6323 | 6323 | } |
| 6324 | 6324 | else |
| 6325 | 6325 | { |
| 6326 | - $emailaddress = ($addressData['PERSONAL_NAME']?$addressData['PERSONAL_NAME'].' <'.$addressData['EMAIL'].'>':$addressData['EMAIL']); |
|
| 6326 | + $emailaddress = ($addressData['PERSONAL_NAME'] ? $addressData['PERSONAL_NAME'].' <'.$addressData['EMAIL'].'>' : $addressData['EMAIL']); |
|
| 6327 | 6327 | $addressObjectA = self::parseAddressList($emailaddress); |
| 6328 | 6328 | } |
| 6329 | 6329 | $addressObject = $addressObjectA[0]; |
@@ -6332,10 +6332,10 @@ discard block |
||
| 6332 | 6332 | //$mb =(string)$addressObject->mailbox; |
| 6333 | 6333 | //$h = (string)$addressObject->host; |
| 6334 | 6334 | //$p = (string)$addressObject->personal; |
| 6335 | - $returnAddr .= (strlen($returnAddr)>0?',':''); |
|
| 6335 | + $returnAddr .= (strlen($returnAddr) > 0 ? ',' : ''); |
|
| 6336 | 6336 | //error_log(__METHOD__.' ('.__LINE__.') '.$p.' <'.$mb.'@'.$h.'>'); |
| 6337 | 6337 | $buff = imap_rfc822_write_address($addressObject->mailbox, Horde_Idna::decode($addressObject->host), $addressObject->personal); |
| 6338 | - $buff = str_replace(array('<','>','"\'','\'"'),array('[',']','"','"'),$buff); |
|
| 6338 | + $buff = str_replace(array('<', '>', '"\'', '\'"'), array('[', ']', '"', '"'), $buff); |
|
| 6339 | 6339 | //error_log(__METHOD__.' ('.__LINE__.') '.' Address: '.$returnAddr); |
| 6340 | 6340 | $returnAddr .= $buff; |
| 6341 | 6341 | } |
@@ -6343,8 +6343,8 @@ discard block |
||
| 6343 | 6343 | else |
| 6344 | 6344 | { |
| 6345 | 6345 | // do not mess with strings, return them untouched /* ToDo: validate string as Address */ |
| 6346 | - $rfcAddressArray = self::decode_header($rfcAddressArray,true); |
|
| 6347 | - $rfcAddressArray = str_replace(array('<','>','"\'','\'"'),array('[',']','"','"'),$rfcAddressArray); |
|
| 6346 | + $rfcAddressArray = self::decode_header($rfcAddressArray, true); |
|
| 6347 | + $rfcAddressArray = str_replace(array('<', '>', '"\'', '\'"'), array('[', ']', '"', '"'), $rfcAddressArray); |
|
| 6348 | 6348 | if (is_string($rfcAddressArray)) return $rfcAddressArray; |
| 6349 | 6349 | } |
| 6350 | 6350 | return $returnAddr; |
@@ -6358,12 +6358,12 @@ discard block |
||
| 6358 | 6358 | * @param string &$err error-message on error |
| 6359 | 6359 | * @return string/boolean merged content or false on error |
| 6360 | 6360 | */ |
| 6361 | - static function merge($content,$ids,$mimetype='') |
|
| 6361 | + static function merge($content, $ids, $mimetype = '') |
|
| 6362 | 6362 | { |
| 6363 | 6363 | $mergeobj = new Contacts\Merge(); |
| 6364 | 6364 | |
| 6365 | - if (empty($mimetype)) $mimetype = (strlen(strip_tags($content)) == strlen($content) ?'text/plain':'text/html'); |
|
| 6366 | - $rv = $mergeobj->merge_string($content,$ids,$err='',$mimetype, array(), self::$displayCharset); |
|
| 6365 | + if (empty($mimetype)) $mimetype = (strlen(strip_tags($content)) == strlen($content) ? 'text/plain' : 'text/html'); |
|
| 6366 | + $rv = $mergeobj->merge_string($content, $ids, $err = '', $mimetype, array(), self::$displayCharset); |
|
| 6367 | 6367 | if (empty($rv) && !empty($content) && !empty($err)) $rv = $content; |
| 6368 | 6368 | if (!empty($err) && !empty($content) && !empty($ids)) error_log(__METHOD__.' ('.__LINE__.') '.' Merge failed for Ids:'.array2string($ids).' ContentType:'.$mimetype.' Content:'.$content.' Reason:'.array2string($err)); |
| 6369 | 6369 | return $rv; |
@@ -6405,12 +6405,12 @@ discard block |
||
| 6405 | 6405 | else |
| 6406 | 6406 | settype($bytes, 'integer'); |
| 6407 | 6407 | |
| 6408 | - return $bytes . ' ' . $type ; |
|
| 6408 | + return $bytes.' '.$type; |
|
| 6409 | 6409 | } |
| 6410 | 6410 | |
| 6411 | 6411 | static function detect_qp(&$sting) { |
| 6412 | 6412 | $needle = '/(=[0-9][A-F])|(=[A-F][0-9])|(=[A-F][A-F])|(=[0-9][0-9])/'; |
| 6413 | - return preg_match("$needle",$string); |
|
| 6413 | + return preg_match("$needle", $string); |
|
| 6414 | 6414 | } |
| 6415 | 6415 | |
| 6416 | 6416 | /** |
@@ -6423,11 +6423,11 @@ discard block |
||
| 6423 | 6423 | * @param string $_methodNline - Information where the log was taken |
| 6424 | 6424 | * @return void |
| 6425 | 6425 | */ |
| 6426 | - static function logRunTimes($_starttime,$_endtime=null,$_message='',$_methodNline='') |
|
| 6426 | + static function logRunTimes($_starttime, $_endtime = null, $_message = '', $_methodNline = '') |
|
| 6427 | 6427 | { |
| 6428 | 6428 | if (is_null($_endtime)) $_endtime = microtime(true); |
| 6429 | 6429 | $usagetime = microtime(true) - $_starttime; |
| 6430 | - if (self::$debugTimes) error_log($_methodNline.' took:'.number_format($usagetime,5).'(s) '.($_message?'Details:'.$_message:'')); |
|
| 6430 | + if (self::$debugTimes) error_log($_methodNline.' took:'.number_format($usagetime, 5).'(s) '.($_message ? 'Details:'.$_message : '')); |
|
| 6431 | 6431 | } |
| 6432 | 6432 | |
| 6433 | 6433 | /** |
@@ -6440,9 +6440,9 @@ discard block |
||
| 6440 | 6440 | * |
| 6441 | 6441 | * @throws Exception\WrongUserinput |
| 6442 | 6442 | */ |
| 6443 | - static function checkFileBasics(&$_formData, $IDtoAddToFileName='', $reqMimeType='message/rfc822') |
|
| 6443 | + static function checkFileBasics(&$_formData, $IDtoAddToFileName = '', $reqMimeType = 'message/rfc822') |
|
| 6444 | 6444 | { |
| 6445 | - if (parse_url($_formData['file'],PHP_URL_SCHEME) == 'egw-data') return $_formData['file']; |
|
| 6445 | + if (parse_url($_formData['file'], PHP_URL_SCHEME) == 'egw-data') return $_formData['file']; |
|
| 6446 | 6446 | |
| 6447 | 6447 | //error_log(__METHOD__.__FILE__.array2string($_formData).' Id:'.$IDtoAddToFileName.' ReqMimeType:'.$reqMimeType); |
| 6448 | 6448 | $importfailed = $tmpFileName = false; |
@@ -6452,7 +6452,7 @@ discard block |
||
| 6452 | 6452 | $importfailed = true; |
| 6453 | 6453 | $alert_msg .= lang("Empty file %1 ignored.", $_formData['name']); |
| 6454 | 6454 | } |
| 6455 | - elseif (parse_url($_formData['file'],PHP_URL_SCHEME) == 'vfs' || is_uploaded_file($_formData['file']) || |
|
| 6455 | + elseif (parse_url($_formData['file'], PHP_URL_SCHEME) == 'vfs' || is_uploaded_file($_formData['file']) || |
|
| 6456 | 6456 | realpath(dirname($_formData['file'])) == realpath($GLOBALS['egw_info']['server']['temp_dir'])) |
| 6457 | 6457 | { |
| 6458 | 6458 | // ensure existance of eGW temp dir |
@@ -6460,7 +6460,7 @@ discard block |
||
| 6460 | 6460 | // and different from any other temp file location set in php.ini |
| 6461 | 6461 | if (!file_exists($GLOBALS['egw_info']['server']['temp_dir'])) |
| 6462 | 6462 | { |
| 6463 | - @mkdir($GLOBALS['egw_info']['server']['temp_dir'],0700); |
|
| 6463 | + @mkdir($GLOBALS['egw_info']['server']['temp_dir'], 0700); |
|
| 6464 | 6464 | } |
| 6465 | 6465 | |
| 6466 | 6466 | // if we were NOT able to create this temp directory, then make an ERROR report |
@@ -6487,14 +6487,14 @@ discard block |
||
| 6487 | 6487 | // maybe its application/octet-stream -> this may mean that we could not determine the type |
| 6488 | 6488 | // so we check for the suffix too |
| 6489 | 6489 | // trust vfs mime-types, trust the mimetype if it contains a method |
| 6490 | - if ((substr($_formData['file'],0,6) !== 'vfs://' || $_formData['type'] == 'application/octet-stream') && stripos($_formData['type'],'method=')===false) |
|
| 6490 | + if ((substr($_formData['file'], 0, 6) !== 'vfs://' || $_formData['type'] == 'application/octet-stream') && stripos($_formData['type'], 'method=') === false) |
|
| 6491 | 6491 | { |
| 6492 | - $buff = explode('.',$_formData['name']); |
|
| 6492 | + $buff = explode('.', $_formData['name']); |
|
| 6493 | 6493 | $suffix = ''; |
| 6494 | 6494 | if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
| 6495 | 6495 | if (!empty($suffix)) $sfxMimeType = MimeMagic::ext2mime($suffix); |
| 6496 | 6496 | if (!empty($suffix) && !empty($sfxMimeType) && |
| 6497 | - (strlen(trim($_formData['type']))==0 || (strtolower(trim($_formData['type'])) != $sfxMimeType))) |
|
| 6497 | + (strlen(trim($_formData['type'])) == 0 || (strtolower(trim($_formData['type'])) != $sfxMimeType))) |
|
| 6498 | 6498 | { |
| 6499 | 6499 | error_log(__METHOD__.' ('.__LINE__.') '.' Data:'.array2string($_formData)); |
| 6500 | 6500 | error_log(__METHOD__.' ('.__LINE__.') '.' Form reported Mimetype:'.$_formData['type'].' but seems to be:'.$sfxMimeType); |
@@ -6509,13 +6509,13 @@ discard block |
||
| 6509 | 6509 | if ($reqMimeType) |
| 6510 | 6510 | { |
| 6511 | 6511 | // so if PHP did not pass any file_type info, then substitute the rfc default value |
| 6512 | - if (substr(strtolower(trim($_formData['type'])),0,strlen($mime_type_default)) != $mime_type_default) |
|
| 6512 | + if (substr(strtolower(trim($_formData['type'])), 0, strlen($mime_type_default)) != $mime_type_default) |
|
| 6513 | 6513 | { |
| 6514 | 6514 | if (!(strtolower(trim($_formData['type'])) == "application/octet-stream" && $sfxMimeType == $reqMimeType)) |
| 6515 | 6515 | { |
| 6516 | 6516 | //error_log("Message rejected, no message/rfc. Is:".$_formData['type']); |
| 6517 | 6517 | $importfailed = true; |
| 6518 | - $alert_msg .= lang("File rejected, no %2. Is:%1",$_formData['type'],$reqMimeType); |
|
| 6518 | + $alert_msg .= lang("File rejected, no %2. Is:%1", $_formData['type'], $reqMimeType); |
|
| 6519 | 6519 | } |
| 6520 | 6520 | if ((strtolower(trim($_formData['type'])) != $reqMimeType && $sfxMimeType == $reqMimeType)) |
| 6521 | 6521 | { |
@@ -6524,17 +6524,17 @@ discard block |
||
| 6524 | 6524 | } |
| 6525 | 6525 | } |
| 6526 | 6526 | // as FreeBSD seems to have problems with the generated temp names we append some more random stuff |
| 6527 | - $randomString = chr(rand(65,90)).chr(rand(48,57)).chr(rand(65,90)).chr(rand(48,57)).chr(rand(65,90)); |
|
| 6527 | + $randomString = chr(rand(65, 90)).chr(rand(48, 57)).chr(rand(65, 90)).chr(rand(48, 57)).chr(rand(65, 90)); |
|
| 6528 | 6528 | $tmpFileName = $GLOBALS['egw_info']['user']['account_id']. |
| 6529 | 6529 | trim($IDtoAddToFileName).basename($_formData['file']).'_'.$randomString; |
| 6530 | 6530 | |
| 6531 | - if (parse_url($_formData['file'],PHP_URL_SCHEME) == 'vfs') |
|
| 6531 | + if (parse_url($_formData['file'], PHP_URL_SCHEME) == 'vfs') |
|
| 6532 | 6532 | { |
| 6533 | - $tmpFileName = $_formData['file']; // no need to store it somewhere |
|
| 6533 | + $tmpFileName = $_formData['file']; // no need to store it somewhere |
|
| 6534 | 6534 | } |
| 6535 | 6535 | elseif (is_uploaded_file($_formData['file'])) |
| 6536 | 6536 | { |
| 6537 | - move_uploaded_file($_formData['file'], $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmpFileName); // requirement for safe_mode! |
|
| 6537 | + move_uploaded_file($_formData['file'], $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmpFileName); // requirement for safe_mode! |
|
| 6538 | 6538 | } |
| 6539 | 6539 | else |
| 6540 | 6540 | { |
@@ -6543,7 +6543,7 @@ discard block |
||
| 6543 | 6543 | } else { |
| 6544 | 6544 | //error_log("Import of message ".$_formData['file']." failes to meet basic restrictions"); |
| 6545 | 6545 | $importfailed = true; |
| 6546 | - $alert_msg .= lang("Processing of file %1 failed. Failed to meet basic restrictions.",$_formData['name']); |
|
| 6546 | + $alert_msg .= lang("Processing of file %1 failed. Failed to meet basic restrictions.", $_formData['name']); |
|
| 6547 | 6547 | } |
| 6548 | 6548 | if ($importfailed == true) |
| 6549 | 6549 | { |
@@ -6551,7 +6551,7 @@ discard block |
||
| 6551 | 6551 | } |
| 6552 | 6552 | else |
| 6553 | 6553 | { |
| 6554 | - if (parse_url($tmpFileName,PHP_URL_SCHEME) == 'vfs') |
|
| 6554 | + if (parse_url($tmpFileName, PHP_URL_SCHEME) == 'vfs') |
|
| 6555 | 6555 | { |
| 6556 | 6556 | Vfs::load_wrapper('vfs'); |
| 6557 | 6557 | } |
@@ -6576,7 +6576,7 @@ discard block |
||
| 6576 | 6576 | $images = null; |
| 6577 | 6577 | if (preg_match_all("/(src|background)=\"(.*)\"/Ui", $_html2parse, $images) && isset($images[2])) |
| 6578 | 6578 | { |
| 6579 | - foreach($images[2] as $i => $url) |
|
| 6579 | + foreach ($images[2] as $i => $url) |
|
| 6580 | 6580 | { |
| 6581 | 6581 | //$isData = false; |
| 6582 | 6582 | $basedir = $data = ''; |
@@ -6588,20 +6588,20 @@ discard block |
||
| 6588 | 6588 | $filename = basename($url); |
| 6589 | 6589 | if (($directory = dirname($url)) == '.') $directory = ''; |
| 6590 | 6590 | $ext = pathinfo($filename, PATHINFO_EXTENSION); |
| 6591 | - $mimeType = MimeMagic::ext2mime($ext); |
|
| 6592 | - if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; } |
|
| 6591 | + $mimeType = MimeMagic::ext2mime($ext); |
|
| 6592 | + if (strlen($directory) > 1 && substr($directory, -1) != '/') { $directory .= '/'; } |
|
| 6593 | 6593 | $myUrl = $directory.$filename; |
| 6594 | - if ($myUrl[0]=='/') // local path -> we only allow path's that are available via http/https (or vfs) |
|
| 6594 | + if ($myUrl[0] == '/') // local path -> we only allow path's that are available via http/https (or vfs) |
|
| 6595 | 6595 | { |
| 6596 | - $basedir = ($_SERVER['HTTPS']?'https://':'http://'.$_SERVER['HTTP_HOST']); |
|
| 6596 | + $basedir = ($_SERVER['HTTPS'] ? 'https://' : 'http://'.$_SERVER['HTTP_HOST']); |
|
| 6597 | 6597 | } |
| 6598 | 6598 | // use vfs instead of url containing webdav.php |
| 6599 | 6599 | // ToDo: we should test if the webdav url is of our own scope, as we cannot handle foreign |
| 6600 | 6600 | // webdav.php urls as vfs |
| 6601 | - if (strpos($myUrl,'/webdav.php') !== false) // we have a webdav link, so we build a vfs/sqlfs link of it. |
|
| 6601 | + if (strpos($myUrl, '/webdav.php') !== false) // we have a webdav link, so we build a vfs/sqlfs link of it. |
|
| 6602 | 6602 | { |
| 6603 | 6603 | Vfs::load_wrapper('vfs'); |
| 6604 | - list(,$myUrl) = explode('/webdav.php',$myUrl,2); |
|
| 6604 | + list(,$myUrl) = explode('/webdav.php', $myUrl, 2); |
|
| 6605 | 6605 | $basedir = 'vfs://default'; |
| 6606 | 6606 | $needTempFile = false; |
| 6607 | 6607 | } |
@@ -6614,11 +6614,11 @@ discard block |
||
| 6614 | 6614 | // Strips the url and store it into a temp for further procss |
| 6615 | 6615 | $tmp_url = html_entity_decode($myUrl); |
| 6616 | 6616 | |
| 6617 | - parse_str(parse_url($tmp_url, PHP_URL_QUERY),$URI_params); |
|
| 6617 | + parse_str(parse_url($tmp_url, PHP_URL_QUERY), $URI_params); |
|
| 6618 | 6618 | if ($URI_params['mailbox'] && $URI_params['uid'] && $URI_params['cid']) |
| 6619 | 6619 | { |
| 6620 | 6620 | $mail_bo->reopen(base64_decode($URI_params['mailbox'])); |
| 6621 | - $attachment = $mail_bo->getAttachmentByCID($URI_params['uid'], base64_decode($URI_params['cid']),base64_decode($URI_params['partID']),true); |
|
| 6621 | + $attachment = $mail_bo->getAttachmentByCID($URI_params['uid'], base64_decode($URI_params['cid']), base64_decode($URI_params['partID']), true); |
|
| 6622 | 6622 | $mail_bo->closeConnection(); |
| 6623 | 6623 | if ($attachment) |
| 6624 | 6624 | { |
@@ -6629,32 +6629,32 @@ discard block |
||
| 6629 | 6629 | } |
| 6630 | 6630 | } |
| 6631 | 6631 | |
| 6632 | - if ( strlen($basedir) > 1 && substr($basedir,-1) != '/' && $myUrl[0]!='/') { $basedir .= '/'; } |
|
| 6633 | - if ($needTempFile && !$attachment && substr($myUrl,0,4) !== "http") $data = file_get_contents($basedir.urldecode($myUrl)); |
|
| 6632 | + if (strlen($basedir) > 1 && substr($basedir, -1) != '/' && $myUrl[0] != '/') { $basedir .= '/'; } |
|
| 6633 | + if ($needTempFile && !$attachment && substr($myUrl, 0, 4) !== "http") $data = file_get_contents($basedir.urldecode($myUrl)); |
|
| 6634 | 6634 | } |
| 6635 | - if (substr($url,0,strlen('data:'))=='data:') |
|
| 6635 | + if (substr($url, 0, strlen('data:')) == 'data:') |
|
| 6636 | 6636 | { |
| 6637 | 6637 | //error_log(__METHOD__.' ('.__LINE__.') '.' -> '.$i.': '.array2string($images[$i])); |
| 6638 | 6638 | // we only support base64 encoded data |
| 6639 | - $tmp = substr($url,strlen('data:')); |
|
| 6640 | - list($mimeType,$data_base64) = explode(';base64,',$tmp); |
|
| 6639 | + $tmp = substr($url, strlen('data:')); |
|
| 6640 | + list($mimeType, $data_base64) = explode(';base64,', $tmp); |
|
| 6641 | 6641 | $data = base64_decode($data_base64); |
| 6642 | 6642 | // FF currently does NOT add any mime-type |
| 6643 | 6643 | if (strtolower(substr($mimeType, 0, 6)) != 'image/') |
| 6644 | 6644 | { |
| 6645 | 6645 | $mimeType = MimeMagic::analyze_data($data); |
| 6646 | 6646 | } |
| 6647 | - list($what,$exactly) = explode('/',$mimeType); |
|
| 6647 | + list($what, $exactly) = explode('/', $mimeType); |
|
| 6648 | 6648 | $needTempFile = true; |
| 6649 | - $filename = ($what?$what:'data').$imageC++.'.'.$exactly; |
|
| 6649 | + $filename = ($what ? $what : 'data').$imageC++.'.'.$exactly; |
|
| 6650 | 6650 | } |
| 6651 | 6651 | if ($data || $needTempFile === false) |
| 6652 | 6652 | { |
| 6653 | 6653 | if ($needTempFile) |
| 6654 | 6654 | { |
| 6655 | - $attachment_file =tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_"); |
|
| 6656 | - $tmpfile = fopen($attachment_file,'w'); |
|
| 6657 | - fwrite($tmpfile,$data); |
|
| 6655 | + $attachment_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'], $GLOBALS['egw_info']['flags']['currentapp']."_"); |
|
| 6656 | + $tmpfile = fopen($attachment_file, 'w'); |
|
| 6657 | + fwrite($tmpfile, $data); |
|
| 6658 | 6658 | fclose($tmpfile); |
| 6659 | 6659 | } |
| 6660 | 6660 | else |
@@ -6665,7 +6665,7 @@ discard block |
||
| 6665 | 6665 | // (or similar) in all cases (when cut&paste). This may lead to more attached files, in case |
| 6666 | 6666 | // we use the same image multiple times, but, if we do this, we should try to detect that |
| 6667 | 6667 | // on upload. filename itself is not sufficient to determine the sameness of images |
| 6668 | - $cid = 'cid:' . md5($attachment_file); |
|
| 6668 | + $cid = 'cid:'.md5($attachment_file); |
|
| 6669 | 6669 | if ($_mailObject->AddEmbeddedImage($attachment_file, substr($cid, 4), urldecode($filename), $mimeType) !== null) |
| 6670 | 6670 | { |
| 6671 | 6671 | //$_html2parse = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $_html2parse); |
@@ -6687,10 +6687,10 @@ discard block |
||
| 6687 | 6687 | * @param string& $importID ID for the imported message, used by attachments to identify them unambiguously |
| 6688 | 6688 | * @return mixed array of messages with success and failed messages or exception |
| 6689 | 6689 | */ |
| 6690 | - function importMessageToMergeAndSend(Storage\Merge $bo_merge, $document, $SendAndMergeTocontacts, &$_folder, &$importID='') |
|
| 6690 | + function importMessageToMergeAndSend(Storage\Merge $bo_merge, $document, $SendAndMergeTocontacts, &$_folder, &$importID = '') |
|
| 6691 | 6691 | { |
| 6692 | 6692 | $importfailed = false; |
| 6693 | - $processStats = array('success'=>array(),'failed'=>array()); |
|
| 6693 | + $processStats = array('success'=>array(), 'failed'=>array()); |
|
| 6694 | 6694 | if (empty($SendAndMergeTocontacts)) |
| 6695 | 6695 | { |
| 6696 | 6696 | $importfailed = true; |
@@ -6731,7 +6731,7 @@ discard block |
||
| 6731 | 6731 | $_folder = $this->getSentFolder(); |
| 6732 | 6732 | } |
| 6733 | 6733 | $delimiter = $this->getHierarchyDelimiter(); |
| 6734 | - if($_folder=='INBOX'.$delimiter) $_folder='INBOX'; |
|
| 6734 | + if ($_folder == 'INBOX'.$delimiter) $_folder = 'INBOX'; |
|
| 6735 | 6735 | if ($importfailed === false) |
| 6736 | 6736 | { |
| 6737 | 6737 | $Subject = $mailObject->getHeader('Subject'); |
@@ -6749,9 +6749,9 @@ discard block |
||
| 6749 | 6749 | { |
| 6750 | 6750 | $mailObject->clearReplyTos(); |
| 6751 | 6751 | $activeMailProfiles = $this->mail->getAccountIdentities($this->profileID); |
| 6752 | - $activeMailProfile = self::getStandardIdentityForProfile($activeMailProfiles,$this->profileID); |
|
| 6752 | + $activeMailProfile = self::getStandardIdentityForProfile($activeMailProfiles, $this->profileID); |
|
| 6753 | 6753 | |
| 6754 | - $mailObject->addReplyTo(Horde_Idna::encode($activeMailProfile['ident_email']),Mail::generateIdentityString($activeMailProfile,false)); |
|
| 6754 | + $mailObject->addReplyTo(Horde_Idna::encode($activeMailProfile['ident_email']), Mail::generateIdentityString($activeMailProfile, false)); |
|
| 6755 | 6755 | } |
| 6756 | 6756 | foreach ($SendAndMergeTocontacts as $k => $val) |
| 6757 | 6757 | { |
@@ -6765,12 +6765,12 @@ discard block |
||
| 6765 | 6765 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mailObject)); |
| 6766 | 6766 | |
| 6767 | 6767 | // Parse destinations for placeholders |
| 6768 | - foreach(Mailer::$type2header as $type => $h) |
|
| 6768 | + foreach (Mailer::$type2header as $type => $h) |
|
| 6769 | 6769 | { |
| 6770 | 6770 | //error_log('ID ' . $val . ' ' .$type . ': ' . $mailObject->getHeader(Mailer::$type2header[$type]) . ' -> ' .$bo_merge->merge_string($mailObject->getHeader(Mailer::$type2header[$type]),$val,$e,'text/plain',array(),self::$displayCharset)); |
| 6771 | - $merged = $bo_merge->merge_string($mailObject->getHeader(Mailer::$type2header[$type]),$val,$e,'text/plain',array(),self::$displayCharset); |
|
| 6772 | - $mailObject->addAddress($merged,'',$type); |
|
| 6773 | - if($type == 'to') |
|
| 6771 | + $merged = $bo_merge->merge_string($mailObject->getHeader(Mailer::$type2header[$type]), $val, $e, 'text/plain', array(), self::$displayCharset); |
|
| 6772 | + $mailObject->addAddress($merged, '', $type); |
|
| 6773 | + if ($type == 'to') |
|
| 6774 | 6774 | { |
| 6775 | 6775 | $email = $merged; |
| 6776 | 6776 | } |
@@ -6783,26 +6783,26 @@ discard block |
||
| 6783 | 6783 | //error_log(__METHOD__.' ('.__LINE__.') '.' ID:'.$val.' Data:'.array2string($contact)); |
| 6784 | 6784 | $email = ($contact['email'] ? $contact['email'] : $contact['email_home']); |
| 6785 | 6785 | $nfn = ($contact['n_fn'] ? $contact['n_fn'] : $contact['n_given'].' '.$contact['n_family']); |
| 6786 | - if($email) |
|
| 6786 | + if ($email) |
|
| 6787 | 6787 | { |
| 6788 | 6788 | $mailObject->addAddress(Horde_Idna::encode($email), $nfn); |
| 6789 | 6789 | } |
| 6790 | 6790 | } |
| 6791 | 6791 | |
| 6792 | 6792 | $activeMailProfiles = $this->getAccountIdentities($this->profileID); |
| 6793 | - $activeMailProfile = self::getStandardIdentityForProfile($activeMailProfiles,$this->profileID); |
|
| 6793 | + $activeMailProfile = self::getStandardIdentityForProfile($activeMailProfiles, $this->profileID); |
|
| 6794 | 6794 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($activeMailProfile)); |
| 6795 | 6795 | $mailObject->setFrom($activeMailProfile['ident_email'], |
| 6796 | - self::generateIdentityString($activeMailProfile,false)); |
|
| 6796 | + self::generateIdentityString($activeMailProfile, false)); |
|
| 6797 | 6797 | |
| 6798 | 6798 | $mailObject->removeHeader('Message-ID'); |
| 6799 | 6799 | $mailObject->removeHeader('Date'); |
| 6800 | 6800 | $mailObject->clearCustomHeaders(); |
| 6801 | 6801 | $mailObject->addHeader('Subject', $bo_merge->merge_string($Subject, $val, $e, 'text/plain', array(), self::$displayCharset)); |
| 6802 | 6802 | //error_log(__METHOD__.' ('.__LINE__.') '.' ContentType:'.$mailObject->BodyContentType); |
| 6803 | - if($text_body) $text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 6803 | + if ($text_body) $text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset), array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 6804 | 6804 | //error_log(__METHOD__.' ('.__LINE__.') '.' Result:'.$mailObject->Body.' error:'.array2string($e)); |
| 6805 | - if($html_body) $html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 6805 | + if ($html_body) $html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset), array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 6806 | 6806 | |
| 6807 | 6807 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mailObject)); |
| 6808 | 6808 | // set a higher timeout for big messages |
@@ -6811,7 +6811,7 @@ discard block |
||
| 6811 | 6811 | try { |
| 6812 | 6812 | $mailObject->send(); |
| 6813 | 6813 | } |
| 6814 | - catch(Exception $e) { |
|
| 6814 | + catch (Exception $e) { |
|
| 6815 | 6815 | $sendOK = false; |
| 6816 | 6816 | $errorInfo = $e->getMessage(); |
| 6817 | 6817 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($errorInfo)); |
@@ -6825,41 +6825,41 @@ discard block |
||
| 6825 | 6825 | $mailObject->clearCustomHeaders(); |
| 6826 | 6826 | |
| 6827 | 6827 | // Parse destinations for placeholders |
| 6828 | - foreach(Mailer::$type2header as $type => $h) |
|
| 6828 | + foreach (Mailer::$type2header as $type => $h) |
|
| 6829 | 6829 | { |
| 6830 | - $merged = $bo_merge->merge_string($mailObject->getHeader(Mailer::$type2header[$type]),$val,$e,'text/plain',array(),self::$displayCharset); |
|
| 6830 | + $merged = $bo_merge->merge_string($mailObject->getHeader(Mailer::$type2header[$type]), $val, $e, 'text/plain', array(), self::$displayCharset); |
|
| 6831 | 6831 | //error_log($type . ': ' . $mailObject->getHeader(Mailer::$type2header[$type]) . ' -> ' .$merged); |
| 6832 | - $mailObject->addAddress(trim($merged,'"'),'',$type); |
|
| 6832 | + $mailObject->addAddress(trim($merged, '"'), '', $type); |
|
| 6833 | 6833 | } |
| 6834 | 6834 | |
| 6835 | 6835 | // No addresses from placeholders? Treat it as just a contact ID |
| 6836 | - if (count($mailObject->getAddresses('to',true)) == 0 && |
|
| 6836 | + if (count($mailObject->getAddresses('to', true)) == 0 && |
|
| 6837 | 6837 | is_numeric($val) || $GLOBALS['egw']->accounts->name2id($val)) // do the merge |
| 6838 | 6838 | { |
| 6839 | 6839 | $contact = $bo_merge->contacts->read($val); |
| 6840 | 6840 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($contact)); |
| 6841 | 6841 | $email = ($contact['email'] ? $contact['email'] : $contact['email_home']); |
| 6842 | 6842 | $nfn = ($contact['n_fn'] ? $contact['n_fn'] : $contact['n_given'].' '.$contact['n_family']); |
| 6843 | - if($email) |
|
| 6843 | + if ($email) |
|
| 6844 | 6844 | { |
| 6845 | 6845 | $mailObject->addAddress(Horde_Idna::encode($email), $nfn); |
| 6846 | 6846 | } |
| 6847 | 6847 | } |
| 6848 | 6848 | $mailObject->addHeader('Subject', $bo_merge->merge_string($Subject, $val, $e, 'text/plain', array(), self::$displayCharset)); |
| 6849 | 6849 | //error_log(__METHOD__.' ('.__LINE__.') '.' ContentType:'.$mailObject->BodyContentType); |
| 6850 | - if (!empty($Body)) $text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 6850 | + if (!empty($Body)) $text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset), array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 6851 | 6851 | //error_log(__METHOD__.' ('.__LINE__.') '.' Result:'.$mailObject->Body.' error:'.array2string($e)); |
| 6852 | - if (!empty($AltBody)) $html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 6852 | + if (!empty($AltBody)) $html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset), array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 6853 | 6853 | $_folder = $this->getDraftFolder(); |
| 6854 | 6854 | } |
| 6855 | 6855 | if ($sendOK || $openAsDraft) |
| 6856 | 6856 | { |
| 6857 | - if ($this->folderExists($_folder,true)) |
|
| 6857 | + if ($this->folderExists($_folder, true)) |
|
| 6858 | 6858 | { |
| 6859 | - if($this->isSentFolder($_folder)) |
|
| 6859 | + if ($this->isSentFolder($_folder)) |
|
| 6860 | 6860 | { |
| 6861 | 6861 | $flags = '\\Seen'; |
| 6862 | - } elseif($this->isDraftFolder($_folder)) { |
|
| 6862 | + } elseif ($this->isDraftFolder($_folder)) { |
|
| 6863 | 6863 | $flags = '\\Draft'; |
| 6864 | 6864 | } else { |
| 6865 | 6865 | $flags = ''; |
@@ -6867,7 +6867,7 @@ discard block |
||
| 6867 | 6867 | $savefailed = false; |
| 6868 | 6868 | try |
| 6869 | 6869 | { |
| 6870 | - $messageUid =$this->appendMessage($_folder, |
|
| 6870 | + $messageUid = $this->appendMessage($_folder, |
|
| 6871 | 6871 | $mailObject->getRaw(), |
| 6872 | 6872 | null, |
| 6873 | 6873 | $flags); |
@@ -6875,10 +6875,10 @@ discard block |
||
| 6875 | 6875 | catch (\Exception\WrongUserinput $e) |
| 6876 | 6876 | { |
| 6877 | 6877 | $savefailed = true; |
| 6878 | - $alert_msg .= lang("Save of message %1 failed. Could not save message to folder %2 due to: %3",$Subject,$_folder,$e->getMessage()); |
|
| 6878 | + $alert_msg .= lang("Save of message %1 failed. Could not save message to folder %2 due to: %3", $Subject, $_folder, $e->getMessage()); |
|
| 6879 | 6879 | } |
| 6880 | 6880 | // no send, save successful, and message_uid present |
| 6881 | - if ($savefailed===false && $messageUid && is_null($sendOK)) |
|
| 6881 | + if ($savefailed === false && $messageUid && is_null($sendOK)) |
|
| 6882 | 6882 | { |
| 6883 | 6883 | $importID = $messageUid; |
| 6884 | 6884 | $openComposeWindow = true; |
@@ -6887,20 +6887,20 @@ discard block |
||
| 6887 | 6887 | else |
| 6888 | 6888 | { |
| 6889 | 6889 | $savefailed = true; |
| 6890 | - $alert_msg .= lang("Saving of message %1 failed. Destination Folder %2 does not exist.",$Subject,$_folder); |
|
| 6890 | + $alert_msg .= lang("Saving of message %1 failed. Destination Folder %2 does not exist.", $Subject, $_folder); |
|
| 6891 | 6891 | } |
| 6892 | 6892 | if ($sendOK) |
| 6893 | 6893 | { |
| 6894 | - $processStats['success'][$val] = 'Send succeeded to '.$nfn.'<'.$email.'>'.($savefailed?' but failed to store to Folder:'.$_folder:''); |
|
| 6894 | + $processStats['success'][$val] = 'Send succeeded to '.$nfn.'<'.$email.'>'.($savefailed ? ' but failed to store to Folder:'.$_folder : ''); |
|
| 6895 | 6895 | } |
| 6896 | 6896 | else |
| 6897 | 6897 | { |
| 6898 | - if (!$openComposeWindow) $processStats['failed'][$val] = $errorInfo?$errorInfo:'Send failed to '.$nfn.'<'.$email.'> See error_log for details'; |
|
| 6898 | + if (!$openComposeWindow) $processStats['failed'][$val] = $errorInfo ? $errorInfo : 'Send failed to '.$nfn.'<'.$email.'> See error_log for details'; |
|
| 6899 | 6899 | } |
| 6900 | 6900 | } |
| 6901 | - if (!is_null($sendOK) && $sendOK===false && is_null($openComposeWindow)) |
|
| 6901 | + if (!is_null($sendOK) && $sendOK === false && is_null($openComposeWindow)) |
|
| 6902 | 6902 | { |
| 6903 | - $processStats['failed'][$val] = $errorInfo?$errorInfo:'Send failed to '.$nfn.'<'.$email.'> See error_log for details'; |
|
| 6903 | + $processStats['failed'][$val] = $errorInfo ? $errorInfo : 'Send failed to '.$nfn.'<'.$email.'> See error_log for details'; |
|
| 6904 | 6904 | } |
| 6905 | 6905 | } |
| 6906 | 6906 | } |
@@ -6970,19 +6970,18 @@ discard block |
||
| 6970 | 6970 | //error_log(__METHOD__.__LINE__.':'.array2string($structure)); |
| 6971 | 6971 | |
| 6972 | 6972 | // unfortunately parseMessage does NOT return parsed headers (we assume header is shorter then 8k) |
| 6973 | - $start = is_string($message) ? substr($message, 0, 8192) : |
|
| 6974 | - (fseek($message, 0, SEEK_SET) == -1 ? '' : fread($message, 8192)); |
|
| 6973 | + $start = is_string($message) ? substr($message, 0, 8192) : (fseek($message, 0, SEEK_SET) == -1 ? '' : fread($message, 8192)); |
|
| 6975 | 6974 | |
| 6976 | 6975 | $length = strpos($start, Horde_Mime_Part::RFC_EOL.Horde_Mime_Part::RFC_EOL); |
| 6977 | - if ($length===false) $length = strlen($start); |
|
| 6978 | - $headers = Horde_Mime_Headers::parseHeaders(substr($start, 0,$length)); |
|
| 6976 | + if ($length === false) $length = strlen($start); |
|
| 6977 | + $headers = Horde_Mime_Headers::parseHeaders(substr($start, 0, $length)); |
|
| 6979 | 6978 | |
| 6980 | - foreach($headers->toArray(array('nowrap' => true)) as $header => $value) |
|
| 6979 | + foreach ($headers->toArray(array('nowrap' => true)) as $header => $value) |
|
| 6981 | 6980 | { |
| 6982 | - foreach((array)$value as $n => $val) |
|
| 6981 | + foreach ((array)$value as $n => $val) |
|
| 6983 | 6982 | { |
| 6984 | 6983 | $overwrite = !$n; |
| 6985 | - switch($header) |
|
| 6984 | + switch ($header) |
|
| 6986 | 6985 | { |
| 6987 | 6986 | case 'Content-Transfer-Encoding': |
| 6988 | 6987 | //as we parse the message and this sets the part with a Content-Transfer-Encoding, we |
@@ -7003,7 +7002,7 @@ discard block |
||
| 7003 | 7002 | } |
| 7004 | 7003 | else |
| 7005 | 7004 | { |
| 7006 | - if (($type = gettype($message)) == 'object') $type = get_class ($message); |
|
| 7005 | + if (($type = gettype($message)) == 'object') $type = get_class($message); |
|
| 7007 | 7006 | throw new Exception\WrongParameter('Wrong parameter type for message: '.$type); |
| 7008 | 7007 | } |
| 7009 | 7008 | } |
@@ -7017,50 +7016,50 @@ discard block |
||
| 7017 | 7016 | * @param string $default_domain |
| 7018 | 7017 | * @return Horde_Mail_Rfc822_List iteratable Horde_Mail_Rfc822_Address objects with attributes mailbox, host, personal and valid |
| 7019 | 7018 | */ |
| 7020 | - public static function parseAddressList($addresses, $default_domain=null) |
|
| 7019 | + public static function parseAddressList($addresses, $default_domain = null) |
|
| 7021 | 7020 | { |
| 7022 | 7021 | $rfc822 = new Horde_Mail_Rfc822(); |
| 7023 | 7022 | $ret = $rfc822->parseAddressList($addresses, $default_domain ? array('default_domain' => $default_domain) : array()); |
| 7024 | 7023 | //error_log(__METHOD__.__LINE__.'#'.array2string($addresses).'#'.array2string($ret).'#'.$ret->count().'#'.$ret->count.function_backtrace()); |
| 7025 | - if ((empty($ret) || $ret->count()==0)&& is_string($addresses) && strlen($addresses)>0) |
|
| 7024 | + if ((empty($ret) || $ret->count() == 0) && is_string($addresses) && strlen($addresses) > 0) |
|
| 7026 | 7025 | { |
| 7027 | 7026 | $matches = array(); |
| 7028 | - preg_match_all("/[\w\.,-.,_.,0-9.]+@[\w\.,-.,_.,0-9.]+/",$addresses,$matches); |
|
| 7027 | + preg_match_all("/[\w\.,-.,_.,0-9.]+@[\w\.,-.,_.,0-9.]+/", $addresses, $matches); |
|
| 7029 | 7028 | //error_log(__METHOD__.__LINE__.array2string($matches)); |
| 7030 | - foreach ($matches[0] as &$match) {$match = trim($match,', ');} |
|
| 7031 | - $addresses = implode(',',$matches[0]); |
|
| 7029 | + foreach ($matches[0] as &$match) {$match = trim($match, ', '); } |
|
| 7030 | + $addresses = implode(',', $matches[0]); |
|
| 7032 | 7031 | //error_log(__METHOD__.__LINE__.array2string($addresses)); |
| 7033 | 7032 | $ret = $rfc822->parseAddressList($addresses, $default_domain ? array('default_domain' => $default_domain) : array()); |
| 7034 | 7033 | //error_log(__METHOD__.__LINE__.'#'.array2string($addresses).'#'.array2string($ret).'#'.$ret->count().'#'.$ret->count); |
| 7035 | 7034 | } |
| 7036 | - $previousFailed=false; |
|
| 7035 | + $previousFailed = false; |
|
| 7037 | 7036 | $ret2 = new Horde_Mail_Rfc822_List(); |
| 7038 | 7037 | // handle known problems on emailaddresses |
| 7039 | - foreach($ret as $i => $adr) |
|
| 7038 | + foreach ($ret as $i => $adr) |
|
| 7040 | 7039 | { |
| 7041 | 7040 | //mailaddresses enclosed in single quotes like '[email protected]' show up as 'me as mailbox and you.com' as host |
| 7042 | - if ($adr->mailbox && stripos($adr->mailbox,"'")== 0 && |
|
| 7043 | - $adr->host && stripos($adr->host,"'")== (strlen($adr->host) -1)) |
|
| 7041 | + if ($adr->mailbox && stripos($adr->mailbox, "'") == 0 && |
|
| 7042 | + $adr->host && stripos($adr->host, "'") == (strlen($adr->host) - 1)) |
|
| 7044 | 7043 | { |
| 7045 | - $adr->mailbox = str_replace("'","",$adr->mailbox); |
|
| 7046 | - $adr->host = str_replace("'","",$adr->host); |
|
| 7044 | + $adr->mailbox = str_replace("'", "", $adr->mailbox); |
|
| 7045 | + $adr->host = str_replace("'", "", $adr->host); |
|
| 7047 | 7046 | } |
| 7048 | 7047 | // no mailbox or host part as 'Xr\xc3\xa4hlyz, User <[email protected]>' is parsed as 2 addresses separated by ',' |
| 7049 | 7048 | //#'Xr\xc3\xa4hlyz, User <[email protected]>' |
| 7050 | 7049 | //#Horde_Mail_Rfc822_List Object([_data:protected] => Array( |
| 7051 | 7050 | //[0] => Horde_Mail_Rfc822_Address Object([comment] => Array()[mailbox] => Xr\xc3\xa4hlyz[_host:protected] => [_personal:protected] => ) |
| 7052 | 7051 | //[1] => Horde_Mail_Rfc822_Address Object([comment] => Array()[mailbox] => mailboxpart1.mailboxpart2[_host:protected] => youthost.com[_personal:protected] => User))[_filter:protected] => Array()[_ptr:protected] => )#2#, |
| 7053 | - if (strlen($adr->mailbox)==0||strlen($adr->host)==0) |
|
| 7052 | + if (strlen($adr->mailbox) == 0 || strlen($adr->host) == 0) |
|
| 7054 | 7053 | { |
| 7055 | - $remember = ($adr->mailbox?$adr->mailbox:($adr->host?$adr->host:'')); |
|
| 7056 | - $previousFailed=true; |
|
| 7054 | + $remember = ($adr->mailbox ? $adr->mailbox : ($adr->host ? $adr->host : '')); |
|
| 7055 | + $previousFailed = true; |
|
| 7057 | 7056 | //error_log(__METHOD__.__LINE__."('$addresses', $default_domain) parsed $i: mailbox=$adr->mailbox, host=$adr->host, personal=$adr->personal"); |
| 7058 | 7057 | } |
| 7059 | 7058 | else |
| 7060 | 7059 | { |
| 7061 | - if ($previousFailed && $remember) $adr->personal = $remember. ' ' . $adr->personal; |
|
| 7060 | + if ($previousFailed && $remember) $adr->personal = $remember.' '.$adr->personal; |
|
| 7062 | 7061 | $remember = ''; |
| 7063 | - $previousFailed=false; |
|
| 7062 | + $previousFailed = false; |
|
| 7064 | 7063 | //error_log(__METHOD__.__LINE__."('$addresses', $default_domain) parsed $i: mailbox=$adr->mailbox, host=$adr->host, personal=$adr->personal"); |
| 7065 | 7064 | $ret2->add($adr); |
| 7066 | 7065 | } |
@@ -7076,7 +7075,7 @@ discard block |
||
| 7076 | 7075 | * @param string $_folder |
| 7077 | 7076 | * @return boolean |
| 7078 | 7077 | */ |
| 7079 | - function sendMDN($uid,$_folder) |
|
| 7078 | + function sendMDN($uid, $_folder) |
|
| 7080 | 7079 | { |
| 7081 | 7080 | $acc = Mail\Account::read($this->profileID); |
| 7082 | 7081 | $identity = Mail\Account::read_identity($acc['ident_id'], true, null, $acc); |
@@ -7106,7 +7105,7 @@ discard block |
||
| 7106 | 7105 | */ |
| 7107 | 7106 | function addAccount($_hookValues) |
| 7108 | 7107 | { |
| 7109 | - error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!' . ' hookValue = '. $_hookValues); |
|
| 7108 | + error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!'.' hookValue = '.$_hookValues); |
|
| 7110 | 7109 | |
| 7111 | 7110 | } |
| 7112 | 7111 | |
@@ -7120,7 +7119,7 @@ discard block |
||
| 7120 | 7119 | */ |
| 7121 | 7120 | function deleteAccount($_hookValues) |
| 7122 | 7121 | { |
| 7123 | - error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!' . ' hookValue = '. $_hookValues); |
|
| 7122 | + error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!'.' hookValue = '.$_hookValues); |
|
| 7124 | 7123 | |
| 7125 | 7124 | } |
| 7126 | 7125 | |
@@ -7134,7 +7133,7 @@ discard block |
||
| 7134 | 7133 | */ |
| 7135 | 7134 | function updateAccount($_hookValues) |
| 7136 | 7135 | { |
| 7137 | - error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!' . ' hookValue = '. $_hookValues); |
|
| 7136 | + error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!'.' hookValue = '.$_hookValues); |
|
| 7138 | 7137 | |
| 7139 | 7138 | } |
| 7140 | 7139 | } |
@@ -199,7 +199,10 @@ discard block |
||
| 199 | 199 | public static function getInstance($_restoreSession=true, &$_profileID=0, $_validate=true, $_oldImapServerObject=false, $_reuseCache=null) |
| 200 | 200 | { |
| 201 | 201 | //$_restoreSession=false; |
| 202 | - if (is_null($_reuseCache)) $_reuseCache = $_restoreSession; |
|
| 202 | + if (is_null($_reuseCache)) |
|
| 203 | + { |
|
| 204 | + $_reuseCache = $_restoreSession; |
|
| 205 | + } |
|
| 203 | 206 | //error_log(__METHOD__.' ('.__LINE__.') '.' RestoreSession:'.$_restoreSession.' ProfileId:'.$_profileID.'/'.Mail\Account::get_default_acc_id().' for user:'.$GLOBALS['egw_info']['user']['account_lid'].' called from:'.function_backtrace()); |
| 204 | 207 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_oldImapServerObject)); |
| 205 | 208 | self::$profileDefunct = Cache::getCache(Cache::INSTANCE,'email','profileDefunct'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),5*1); |
@@ -230,9 +233,15 @@ discard block |
||
| 230 | 233 | { |
| 231 | 234 | $profileID = Mail\Account::get_default_acc_id(); |
| 232 | 235 | } |
| 233 | - if ($profileID!=$_profileID) $_restoreSession==false; |
|
| 236 | + if ($profileID!=$_profileID) |
|
| 237 | + { |
|
| 238 | + $_restoreSession==false; |
|
| 239 | + } |
|
| 234 | 240 | $_profileID=$profileID; |
| 235 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' called with profileID==0 using '.$profileID.' instead->'.function_backtrace()); |
|
| 241 | + if (self::$debug) |
|
| 242 | + { |
|
| 243 | + error_log(__METHOD__.' ('.__LINE__.') '.' called with profileID==0 using '.$profileID.' instead->'.function_backtrace()); |
|
| 244 | + } |
|
| 236 | 245 | } |
| 237 | 246 | // no validation or restoreSession for old ImapServer Object, just fetch it and return it |
| 238 | 247 | if ($_oldImapServerObject===true) |
@@ -271,7 +280,8 @@ discard block |
||
| 271 | 280 | // TODO: merge mailprefs into userprefs, for easy treatment |
| 272 | 281 | self::$instances[$_profileID]->mailPreferences = $GLOBALS['egw_info']['user']['preferences']['mail']; |
| 273 | 282 | self::$instances[$_profileID]->htmlOptions = self::$instances[$_profileID]->mailPreferences['htmlOptions']; |
| 274 | - } catch (\Exception $e) |
|
| 283 | + } |
|
| 284 | + catch (\Exception $e) |
|
| 275 | 285 | { |
| 276 | 286 | $newprofileID = Mail\Account::get_default_acc_id(); |
| 277 | 287 | // try loading the default profile for the user |
@@ -289,9 +299,15 @@ discard block |
||
| 289 | 299 | self::storeActiveProfileIDToPref(self::$instances[$_profileID]->icServer, $_profileID, $_validate ); |
| 290 | 300 | } |
| 291 | 301 | self::$instances[$_profileID]->profileID = $_profileID; |
| 292 | - if (!isset(self::$instances[$_profileID]->idna2)) self::$instances[$_profileID]->idna2 = new Horde_Idna; |
|
| 302 | + if (!isset(self::$instances[$_profileID]->idna2)) |
|
| 303 | + { |
|
| 304 | + self::$instances[$_profileID]->idna2 = new Horde_Idna; |
|
| 305 | + } |
|
| 293 | 306 | //if ($_profileID==0); error_log(__METHOD__.' ('.__LINE__.') '.' RestoreSession:'.$_restoreSession.' ProfileId:'.$_profileID); |
| 294 | - if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail'); |
|
| 307 | + if (is_null(self::$mailConfig)) |
|
| 308 | + { |
|
| 309 | + self::$mailConfig = Config::read('mail'); |
|
| 310 | + } |
|
| 295 | 311 | return self::$instances[$_profileID]; |
| 296 | 312 | } |
| 297 | 313 | |
@@ -316,14 +332,20 @@ discard block |
||
| 316 | 332 | } |
| 317 | 333 | catch (\Exception $e) |
| 318 | 334 | { |
| 319 | - if ($_profileID != Mail\Account::get_default_acc_id()) $_profileID = Mail\Account::get_default_acc_id(); |
|
| 335 | + if ($_profileID != Mail\Account::get_default_acc_id()) |
|
| 336 | + { |
|
| 337 | + $_profileID = Mail\Account::get_default_acc_id(); |
|
| 338 | + } |
|
| 320 | 339 | error_log(__METHOD__.__LINE__.' '.$e->getMessage()); |
| 321 | 340 | return false; |
| 322 | 341 | } |
| 323 | 342 | } |
| 324 | 343 | if ($oldProfileID != $_profileID) |
| 325 | 344 | { |
| 326 | - if ($oldProfileID && $_profileID==0) $_profileID = $oldProfileID; |
|
| 345 | + if ($oldProfileID && $_profileID==0) |
|
| 346 | + { |
|
| 347 | + $_profileID = $oldProfileID; |
|
| 348 | + } |
|
| 327 | 349 | $GLOBALS['egw']->preferences->add('mail','ActiveProfileID',$_profileID,'user'); |
| 328 | 350 | // save prefs |
| 329 | 351 | $GLOBALS['egw']->preferences->save_repository(true); |
@@ -353,11 +375,17 @@ discard block |
||
| 353 | 375 | { |
| 354 | 376 | return $_acc_id; |
| 355 | 377 | } |
| 356 | - if (self::$debug) error_log(__METHOD__."($_acc_id) account NOT valid, no imap-host!"); |
|
| 378 | + if (self::$debug) |
|
| 379 | + { |
|
| 380 | + error_log(__METHOD__."($_acc_id) account NOT valid, no imap-host!"); |
|
| 381 | + } |
|
| 357 | 382 | } |
| 358 | 383 | catch (\Exception $e) { |
| 359 | 384 | unset($e); |
| 360 | - if (self::$debug) error_log(__METHOD__."($_acc_id) account NOT found!"); |
|
| 385 | + if (self::$debug) |
|
| 386 | + { |
|
| 387 | + error_log(__METHOD__."($_acc_id) account NOT found!"); |
|
| 388 | + } |
|
| 361 | 389 | } |
| 362 | 390 | } |
| 363 | 391 | // no account specified or specified account not found or not valid |
@@ -366,11 +394,17 @@ discard block |
||
| 366 | 394 | { |
| 367 | 395 | if (!empty($imap_host) && ($account = Mail\Account::read($acc_id)) && $account->is_imap()) |
| 368 | 396 | { |
| 369 | - if (self::$debug && $_acc_id) error_log(__METHOD__."($_acc_id) using $acc_id instead"); |
|
| 397 | + if (self::$debug && $_acc_id) |
|
| 398 | + { |
|
| 399 | + error_log(__METHOD__."($_acc_id) using $acc_id instead"); |
|
| 400 | + } |
|
| 370 | 401 | return $acc_id; |
| 371 | 402 | } |
| 372 | 403 | } |
| 373 | - if (self::$debug) error_log(__METHOD__."($_acc_id) NO valid account found!"); |
|
| 404 | + if (self::$debug) |
|
| 405 | + { |
|
| 406 | + error_log(__METHOD__."($_acc_id) NO valid account found!"); |
|
| 407 | + } |
|
| 374 | 408 | return 0; |
| 375 | 409 | } |
| 376 | 410 | |
@@ -386,10 +420,19 @@ discard block |
||
| 386 | 420 | */ |
| 387 | 421 | private function __construct($_displayCharset='utf-8',$_restoreSession=true, $_profileID=0, $_oldImapServerObject=false, $_reuseCache=null) |
| 388 | 422 | { |
| 389 | - if (is_null($_reuseCache)) $_reuseCache = $_restoreSession; |
|
| 390 | - if (!empty($_displayCharset)) self::$displayCharset = $_displayCharset; |
|
| 423 | + if (is_null($_reuseCache)) |
|
| 424 | + { |
|
| 425 | + $_reuseCache = $_restoreSession; |
|
| 426 | + } |
|
| 427 | + if (!empty($_displayCharset)) |
|
| 428 | + { |
|
| 429 | + self::$displayCharset = $_displayCharset; |
|
| 430 | + } |
|
| 391 | 431 | // not nummeric, we assume we only want an empty class object |
| 392 | - if (!is_numeric($_profileID)) return true; |
|
| 432 | + if (!is_numeric($_profileID)) |
|
| 433 | + { |
|
| 434 | + return true; |
|
| 435 | + } |
|
| 393 | 436 | if ($_restoreSession) |
| 394 | 437 | { |
| 395 | 438 | //error_log(__METHOD__." Session restore ".function_backtrace()); |
@@ -404,7 +447,10 @@ discard block |
||
| 404 | 447 | $firstMessage = $this->sessionData['previewMessage']; |
| 405 | 448 | $this->sessionData = array(); |
| 406 | 449 | } |
| 407 | - if (!$_reuseCache) $this->forcePrefReload($_profileID,!$_reuseCache); |
|
| 450 | + if (!$_reuseCache) |
|
| 451 | + { |
|
| 452 | + $this->forcePrefReload($_profileID,!$_reuseCache); |
|
| 453 | + } |
|
| 408 | 454 | try |
| 409 | 455 | { |
| 410 | 456 | $this->profileID = self::validateProfileID($_profileID); |
@@ -428,7 +474,10 @@ discard block |
||
| 428 | 474 | $_profileID = $this->profileID = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $this->icServer->ImapServerId; |
| 429 | 475 | } |
| 430 | 476 | |
| 431 | - if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail'); |
|
| 477 | + if (is_null(self::$mailConfig)) |
|
| 478 | + { |
|
| 479 | + self::$mailConfig = Config::read('mail'); |
|
| 480 | + } |
|
| 432 | 481 | } |
| 433 | 482 | |
| 434 | 483 | /** |
@@ -457,7 +506,10 @@ discard block |
||
| 457 | 506 | // unset the mail_preferences session object, to force the reload/rebuild |
| 458 | 507 | Cache::setSession('mail','mail_preferences',serialize(array())); |
| 459 | 508 | Cache::setSession('emailadmin','session_data',serialize(array())); |
| 460 | - if ($_resetFolderObjects) self::resetFolderObjectCache($_profile_id); |
|
| 509 | + if ($_resetFolderObjects) |
|
| 510 | + { |
|
| 511 | + self::resetFolderObjectCache($_profile_id); |
|
| 512 | + } |
|
| 461 | 513 | } |
| 462 | 514 | |
| 463 | 515 | /** |
@@ -467,7 +519,10 @@ discard block |
||
| 467 | 519 | { |
| 468 | 520 | $this->sessionData = array();//Cache::getCache(Cache::SESSION,'mail','session_data',$callback=null,$callback_params=array(),$expiration=60*60*1); |
| 469 | 521 | self::$activeFolderCache = Cache::getCache(Cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*10); |
| 470 | - if (!empty(self::$activeFolderCache[$this->profileID])) $this->sessionData['mailbox'] = self::$activeFolderCache[$this->profileID]; |
|
| 522 | + if (!empty(self::$activeFolderCache[$this->profileID])) |
|
| 523 | + { |
|
| 524 | + $this->sessionData['mailbox'] = self::$activeFolderCache[$this->profileID]; |
|
| 525 | + } |
|
| 471 | 526 | } |
| 472 | 527 | |
| 473 | 528 | /** |
@@ -476,7 +531,10 @@ discard block |
||
| 476 | 531 | function saveSessionData() |
| 477 | 532 | { |
| 478 | 533 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string(array_keys($this->sessionData))); |
| 479 | - if (!empty($this->sessionData['mailbox'])) self::$activeFolderCache[$this->profileID]=$this->sessionData['mailbox']; |
|
| 534 | + if (!empty($this->sessionData['mailbox'])) |
|
| 535 | + { |
|
| 536 | + self::$activeFolderCache[$this->profileID]=$this->sessionData['mailbox']; |
|
| 537 | + } |
|
| 480 | 538 | if (isset(self::$activeFolderCache) && is_array(self::$activeFolderCache)) |
| 481 | 539 | { |
| 482 | 540 | Cache::setCache(Cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),self::$activeFolderCache, 60*60*10); |
@@ -497,8 +555,14 @@ discard block |
||
| 497 | 555 | */ |
| 498 | 556 | static function unsetCachedObjects($_profileID=null) |
| 499 | 557 | { |
| 500 | - if (is_null($_profileID)) $_profileID = Mail\Account::get_default_acc_id(); |
|
| 501 | - if (is_array($_profileID) && $_profileID['account_id']) $account_id = $_profileID['account_id']; |
|
| 558 | + if (is_null($_profileID)) |
|
| 559 | + { |
|
| 560 | + $_profileID = Mail\Account::get_default_acc_id(); |
|
| 561 | + } |
|
| 562 | + if (is_array($_profileID) && $_profileID['account_id']) |
|
| 563 | + { |
|
| 564 | + $account_id = $_profileID['account_id']; |
|
| 565 | + } |
|
| 502 | 566 | //error_log(__METHOD__.__LINE__.' called with ProfileID:'.array2string($_profileID).' from '.function_backtrace()); |
| 503 | 567 | if (!is_array($_profileID) && (is_numeric($_profileID) || !(stripos($_profileID,'tracker_')===false))) |
| 504 | 568 | { |
@@ -531,7 +595,10 @@ discard block |
||
| 531 | 595 | Cache::setCache(Cache::INSTANCE,'email','vacationNotice'.trim($account_id),$vacationCached, $expiration=60*60*24*1); |
| 532 | 596 | } |
| 533 | 597 | |
| 534 | - if (isset(self::$instances[$_profileID])) unset(self::$instances[$_profileID]); |
|
| 598 | + if (isset(self::$instances[$_profileID])) |
|
| 599 | + { |
|
| 600 | + unset(self::$instances[$_profileID]); |
|
| 601 | + } |
|
| 535 | 602 | } |
| 536 | 603 | if (is_array($_profileID) && $_profileID['location'] == 'clear_cache') |
| 537 | 604 | { |
@@ -560,7 +627,10 @@ discard block |
||
| 560 | 627 | static function resetConnectionErrorCache($_ImapServerId=null,$account_id=null) |
| 561 | 628 | { |
| 562 | 629 | //error_log(__METHOD__.' ('.__LINE__.') '.' for Profile:'.array2string($_ImapServerId) .' for user:'.trim($account_id)); |
| 563 | - if (is_null($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id']; |
|
| 630 | + if (is_null($account_id)) |
|
| 631 | + { |
|
| 632 | + $account_id = $GLOBALS['egw_info']['user']['account_id']; |
|
| 633 | + } |
|
| 564 | 634 | if (is_array($_ImapServerId)) |
| 565 | 635 | { |
| 566 | 636 | // called via hook |
@@ -599,7 +669,10 @@ discard block |
||
| 599 | 669 | static function resetFolderObjectCache($_ImapServerId=null,$account_id=null) |
| 600 | 670 | { |
| 601 | 671 | //error_log(__METHOD__.' ('.__LINE__.') '.' called for Profile:'.array2string($_ImapServerId).'->'.function_backtrace()); |
| 602 | - if (is_null($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id']; |
|
| 672 | + if (is_null($account_id)) |
|
| 673 | + { |
|
| 674 | + $account_id = $GLOBALS['egw_info']['user']['account_id']; |
|
| 675 | + } |
|
| 603 | 676 | // on [location] => verify_settings we coud either use [prefs] => Array([ActiveProfileID] => 9, .. as $_ImapServerId |
| 604 | 677 | // or treat it as not given. we try that path |
| 605 | 678 | if (is_null($_ImapServerId)||is_array($_ImapServerId)) |
@@ -673,10 +746,14 @@ discard block |
||
| 673 | 746 | |
| 674 | 747 | $userEMailAdresses = array($acc['ident_email']=>$acc['ident_realname']); |
| 675 | 748 | |
| 676 | - foreach($identities as $ik => $ident) { |
|
| 749 | + foreach($identities as $ik => $ident) |
|
| 750 | + { |
|
| 677 | 751 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident)); |
| 678 | 752 | $identity = Mail\Account::read_identity($ik); |
| 679 | - if (!empty($identity['ident_email']) && !isset($userEMailAdresses[$identity['ident_email']])) $userEMailAdresses[$identity['ident_email']] = $identity['ident_realname']; |
|
| 753 | + if (!empty($identity['ident_email']) && !isset($userEMailAdresses[$identity['ident_email']])) |
|
| 754 | + { |
|
| 755 | + $userEMailAdresses[$identity['ident_email']] = $identity['ident_realname']; |
|
| 756 | + } |
|
| 680 | 757 | } |
| 681 | 758 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($userEMailAdresses)); |
| 682 | 759 | return $userEMailAdresses; |
@@ -694,13 +771,20 @@ discard block |
||
| 694 | 771 | foreach(Mail\Account::search($only_current_user=($_accountToSearch?$_accountToSearch:true), $just_name=true) as $acc_id => $identity_name) |
| 695 | 772 | { |
| 696 | 773 | $acc = Mail\Account::read($acc_id,($_accountToSearch?$_accountToSearch:null)); |
| 697 | - if (!$resolve_placeholders) $userEMailAdresses[$acc['ident_id']] = array('acc_id'=>$acc_id,'ident_id'=>$acc['ident_id'],'ident_email'=>$acc['ident_email'],'ident_org'=>$acc['ident_org'],'ident_realname'=>$acc['ident_realname'],'ident_signature'=>$acc['ident_signature'],'ident_name'=>$acc['ident_name']); |
|
| 774 | + if (!$resolve_placeholders) |
|
| 775 | + { |
|
| 776 | + $userEMailAdresses[$acc['ident_id']] = array('acc_id'=>$acc_id,'ident_id'=>$acc['ident_id'],'ident_email'=>$acc['ident_email'],'ident_org'=>$acc['ident_org'],'ident_realname'=>$acc['ident_realname'],'ident_signature'=>$acc['ident_signature'],'ident_name'=>$acc['ident_name']); |
|
| 777 | + } |
|
| 698 | 778 | |
| 699 | - foreach(Mail\Account::identities($acc) as $ik => $ident) { |
|
| 779 | + foreach(Mail\Account::identities($acc) as $ik => $ident) |
|
| 780 | + { |
|
| 700 | 781 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident)); |
| 701 | 782 | $identity = Mail\Account::read_identity($ik,$resolve_placeholders); |
| 702 | 783 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($identity)); |
| 703 | - if (!isset($userEMailAdresses[$identity['ident_id']])) $userEMailAdresses[$identity['ident_id']] = array('acc_id'=>$acc_id,'ident_id'=>$identity['ident_id'],'ident_email'=>$identity['ident_email'],'ident_org'=>$identity['ident_org'],'ident_realname'=>$identity['ident_realname'],'ident_signature'=>$identity['ident_signature'],'ident_name'=>$identity['ident_name']); |
|
| 784 | + if (!isset($userEMailAdresses[$identity['ident_id']])) |
|
| 785 | + { |
|
| 786 | + $userEMailAdresses[$identity['ident_id']] = array('acc_id'=>$acc_id,'ident_id'=>$identity['ident_id'],'ident_email'=>$identity['ident_email'],'ident_org'=>$identity['ident_org'],'ident_realname'=>$identity['ident_realname'],'ident_signature'=>$identity['ident_signature'],'ident_name'=>$identity['ident_name']); |
|
| 787 | + } |
|
| 704 | 788 | } |
| 705 | 789 | } |
| 706 | 790 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($userEMailAdresses)); |
@@ -720,12 +804,16 @@ discard block |
||
| 720 | 804 | $account = Mail\Account::read($account); |
| 721 | 805 | } |
| 722 | 806 | $userEMailAdresses = array(); |
| 723 | - foreach(Mail\Account::identities($account, true, 'params') as $ik => $ident) { |
|
| 807 | + foreach(Mail\Account::identities($account, true, 'params') as $ik => $ident) |
|
| 808 | + { |
|
| 724 | 809 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident)); |
| 725 | 810 | $identity = Mail\Account::read_identity($ik,true,null,$account); |
| 726 | 811 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($identity)); |
| 727 | 812 | // standardIdentity has ident_id==acc_id (as it is done within account->identities) |
| 728 | - if (empty($identity['ident_id'])) $identity['ident_id'] = $identity['acc_id']; |
|
| 813 | + if (empty($identity['ident_id'])) |
|
| 814 | + { |
|
| 815 | + $identity['ident_id'] = $identity['acc_id']; |
|
| 816 | + } |
|
| 729 | 817 | if (!isset($userEMailAdresses[$identity['ident_id']])) |
| 730 | 818 | { |
| 731 | 819 | $userEMailAdresses[$identity['ident_id']] = array('acc_id'=>$identity['acc_id'], |
@@ -768,15 +856,25 @@ discard block |
||
| 768 | 856 | // account select box |
| 769 | 857 | $selectedID = $this->profileID; |
| 770 | 858 | $allAccountData = Mail\Account::search($only_current_user=true, false, null); |
| 771 | - if ($allAccountData) { |
|
| 859 | + if ($allAccountData) |
|
| 860 | + { |
|
| 772 | 861 | $rememberFirst=$selectedFound=null; |
| 773 | 862 | foreach ($allAccountData as $tmpkey => $icServers) |
| 774 | 863 | { |
| 775 | - if (is_null($rememberFirst)) $rememberFirst = $tmpkey; |
|
| 776 | - if ($tmpkey == $selectedID) $selectedFound=true; |
|
| 864 | + if (is_null($rememberFirst)) |
|
| 865 | + { |
|
| 866 | + $rememberFirst = $tmpkey; |
|
| 867 | + } |
|
| 868 | + if ($tmpkey == $selectedID) |
|
| 869 | + { |
|
| 870 | + $selectedFound=true; |
|
| 871 | + } |
|
| 777 | 872 | //error_log(__METHOD__.' ('.__LINE__.') '.' Key:'.$tmpkey.'->'.array2string($icServers->acc_imap_host)); |
| 778 | 873 | $host = $icServers->acc_imap_host; |
| 779 | - if (empty($host)) continue; |
|
| 874 | + if (empty($host)) |
|
| 875 | + { |
|
| 876 | + continue; |
|
| 877 | + } |
|
| 780 | 878 | $identities[$icServers->acc_id] = $icServers['ident_realname'].' '.$icServers['ident_org'].' <'.$icServers['ident_email'].'>'; |
| 781 | 879 | //error_log(__METHOD__.' ('.__LINE__.') '.' Key:'.$tmpkey.'->'.array2string($identities[$icServers->acc_id])); |
| 782 | 880 | } |
@@ -836,7 +934,10 @@ discard block |
||
| 836 | 934 | */ |
| 837 | 935 | function reopen($_foldername) |
| 838 | 936 | { |
| 839 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 937 | + if (self::$debugTimes) |
|
| 938 | + { |
|
| 939 | + $starttime = microtime (true); |
|
| 940 | + } |
|
| 840 | 941 | |
| 841 | 942 | //error_log(__METHOD__.' ('.__LINE__.') '."('$_foldername') ".function_backtrace()); |
| 842 | 943 | // TODO: trying to reduce traffic to the IMAP Server here, introduces problems with fetching the bodies of |
@@ -846,12 +947,16 @@ discard block |
||
| 846 | 947 | //{ |
| 847 | 948 | //error_log( __METHOD__.' ('.__LINE__.') '." $_foldername ".function_backtrace()); |
| 848 | 949 | //error_log(__METHOD__.' ('.__LINE__.') '.' Connected with icServer for Profile:'.$this->profileID.'?'.print_r($this->icServer->_connected,true)); |
| 849 | - if ($this->folderIsSelectable($_foldername)) { |
|
| 950 | + if ($this->folderIsSelectable($_foldername)) |
|
| 951 | + { |
|
| 850 | 952 | $this->icServer->openMailbox($_foldername); |
| 851 | 953 | } |
| 852 | 954 | $folderOpened = $_foldername; |
| 853 | 955 | //} |
| 854 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'Folder:'.$_foldername,__METHOD__.' ('.__LINE__.') '); |
|
| 956 | + if (self::$debugTimes) |
|
| 957 | + { |
|
| 958 | + self::logRunTimes($starttime,null,'Folder:'.$_foldername,__METHOD__.' ('.__LINE__.') '); |
|
| 959 | + } |
|
| 855 | 960 | } |
| 856 | 961 | |
| 857 | 962 | |
@@ -866,13 +971,22 @@ discard block |
||
| 866 | 971 | { |
| 867 | 972 | //error_log( "-------------------------->open connection ".function_backtrace()); |
| 868 | 973 | //error_log(__METHOD__.' ('.__LINE__.') '.' ->'.array2string($this->icServer)); |
| 869 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 974 | + if (self::$debugTimes) |
|
| 975 | + { |
|
| 976 | + $starttime = microtime (true); |
|
| 977 | + } |
|
| 870 | 978 | $mailbox=null; |
| 871 | 979 | try |
| 872 | 980 | { |
| 873 | - if(isset($this->sessionData['mailbox'])&&$this->folderExists($this->sessionData['mailbox'])) $mailbox = $this->sessionData['mailbox']; |
|
| 874 | - if (empty($mailbox)) $mailbox = $this->icServer->getCurrentMailbox(); |
|
| 875 | -/* |
|
| 981 | + if(isset($this->sessionData['mailbox'])&&$this->folderExists($this->sessionData['mailbox'])) |
|
| 982 | + { |
|
| 983 | + $mailbox = $this->sessionData['mailbox']; |
|
| 984 | + } |
|
| 985 | + if (empty($mailbox)) |
|
| 986 | + { |
|
| 987 | + $mailbox = $this->icServer->getCurrentMailbox(); |
|
| 988 | + } |
|
| 989 | + /* |
|
| 876 | 990 | if (isset(Mail\Imap::$supports_keywords[$_icServerID])) |
| 877 | 991 | { |
| 878 | 992 | $this->icServer->openMailbox($mailbox); |
@@ -897,7 +1011,10 @@ discard block |
||
| 897 | 1011 | error_log(__METHOD__.' ('.__LINE__.') '."->open connection for Server with profileID:".$_icServerID." trying to examine ($mailbox) failed!".$e->getMessage()); |
| 898 | 1012 | throw new Exception(__METHOD__." failed to ".__METHOD__." on Profile to $_icServerID while trying to examine $mailbox:".$e->getMessage()); |
| 899 | 1013 | } |
| 900 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'ProfileID:'.$_icServerID,__METHOD__.' ('.__LINE__.') '); |
|
| 1014 | + if (self::$debugTimes) |
|
| 1015 | + { |
|
| 1016 | + self::logRunTimes($starttime,null,'ProfileID:'.$_icServerID,__METHOD__.' ('.__LINE__.') '); |
|
| 1017 | + } |
|
| 901 | 1018 | } |
| 902 | 1019 | |
| 903 | 1020 | /** |
@@ -909,7 +1026,10 @@ discard block |
||
| 909 | 1026 | function getQuotaRoot() |
| 910 | 1027 | { |
| 911 | 1028 | static $quota; |
| 912 | - if (isset($quota)) return $quota; |
|
| 1029 | + if (isset($quota)) |
|
| 1030 | + { |
|
| 1031 | + return $quota; |
|
| 1032 | + } |
|
| 913 | 1033 | if (isset(self::$profileDefunct[$this->profileID]) && strlen(self::$profileDefunct[$this->profileID])) |
| 914 | 1034 | { |
| 915 | 1035 | // something is wrong. Do not proceed. either no folder or profile is marked as defunct for this request |
@@ -918,7 +1038,8 @@ discard block |
||
| 918 | 1038 | try |
| 919 | 1039 | { |
| 920 | 1040 | $this->icServer->getCurrentMailbox(); |
| 921 | - if(!$this->icServer->hasCapability('QUOTA')) { |
|
| 1041 | + if(!$this->icServer->hasCapability('QUOTA')) |
|
| 1042 | + { |
|
| 922 | 1043 | $quota = false; |
| 923 | 1044 | return false; |
| 924 | 1045 | } |
@@ -936,12 +1057,15 @@ discard block |
||
| 936 | 1057 | } |
| 937 | 1058 | } |
| 938 | 1059 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($quota)); |
| 939 | - if(is_array($quota)) { |
|
| 1060 | + if(is_array($quota)) |
|
| 1061 | + { |
|
| 940 | 1062 | $quota = array( |
| 941 | 1063 | 'usage' => $quota['USED'], |
| 942 | 1064 | 'limit' => $quota['QMAX'], |
| 943 | 1065 | ); |
| 944 | - } else { |
|
| 1066 | + } |
|
| 1067 | + else |
|
| 1068 | + { |
|
| 945 | 1069 | $quota = false; |
| 946 | 1070 | } |
| 947 | 1071 | return $quota; |
@@ -957,7 +1081,11 @@ discard block |
||
| 957 | 1081 | static function getTimeOut($_use='IMAP') |
| 958 | 1082 | { |
| 959 | 1083 | $timeout = $GLOBALS['egw_info']['user']['preferences']['mail']['connectionTimeout']; |
| 960 | - if (empty($timeout)) $timeout = ($_use=='SIEVE'?10:20); // this is the default value |
|
| 1084 | + if (empty($timeout)) |
|
| 1085 | + { |
|
| 1086 | + $timeout = ($_use=='SIEVE'?10:20); |
|
| 1087 | + } |
|
| 1088 | + // this is the default value |
|
| 961 | 1089 | return $timeout; |
| 962 | 1090 | } |
| 963 | 1091 | |
@@ -975,9 +1103,13 @@ discard block |
||
| 975 | 1103 | $foldersNameSpace = array(); |
| 976 | 1104 | $delimiter = $this->getHierarchyDelimiter(); |
| 977 | 1105 | // TODO: cache by $this->icServer->ImapServerId |
| 978 | - if (is_null($nameSpace)) $nameSpace = $this->icServer->getNameSpaceArray(); |
|
| 1106 | + if (is_null($nameSpace)) |
|
| 1107 | + { |
|
| 1108 | + $nameSpace = $this->icServer->getNameSpaceArray(); |
|
| 1109 | + } |
|
| 979 | 1110 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($nameSpace)); |
| 980 | - if (is_array($nameSpace)) { |
|
| 1111 | + if (is_array($nameSpace)) |
|
| 1112 | + { |
|
| 981 | 1113 | foreach($nameSpace as $type => $singleNameSpaceArray) |
| 982 | 1114 | { |
| 983 | 1115 | foreach ($singleNameSpaceArray as $singleNameSpace) |
@@ -994,7 +1126,9 @@ discard block |
||
| 994 | 1126 | $_foldersNameSpace['prefix_present'] = 'forced'; |
| 995 | 1127 | // uw-imap server with mailbox prefix or dovecot maybe |
| 996 | 1128 | $_foldersNameSpace['prefix'] = 'mail'; |
| 997 | - } else { |
|
| 1129 | + } |
|
| 1130 | + else |
|
| 1131 | + { |
|
| 998 | 1132 | $_foldersNameSpace['prefix_present'] = !empty($singleNameSpace['name']); |
| 999 | 1133 | $_foldersNameSpace['prefix'] = $singleNameSpace['name']; |
| 1000 | 1134 | } |
@@ -1021,7 +1155,10 @@ discard block |
||
| 1021 | 1155 | foreach($nameSpace as &$singleNameSpace) |
| 1022 | 1156 | { |
| 1023 | 1157 | //if (substr($singleNameSpace['prefix'],0,strlen($folderName))==$folderName) return $singleNameSpace['prefix']; |
| 1024 | - if (substr($folderName,0,strlen($singleNameSpace['prefix']))==$singleNameSpace['prefix']) return $singleNameSpace['prefix']; |
|
| 1158 | + if (substr($folderName,0,strlen($singleNameSpace['prefix']))==$singleNameSpace['prefix']) |
|
| 1159 | + { |
|
| 1160 | + return $singleNameSpace['prefix']; |
|
| 1161 | + } |
|
| 1025 | 1162 | } |
| 1026 | 1163 | return ""; |
| 1027 | 1164 | } |
@@ -1035,8 +1172,14 @@ discard block |
||
| 1035 | 1172 | function getHierarchyDelimiter($_useCache=true) |
| 1036 | 1173 | { |
| 1037 | 1174 | static $HierarchyDelimiter = null; |
| 1038 | - if (is_null($HierarchyDelimiter)) $HierarchyDelimiter = Cache::getCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5); |
|
| 1039 | - if ($_useCache===false) unset($HierarchyDelimiter[$this->icServer->ImapServerId]); |
|
| 1175 | + if (is_null($HierarchyDelimiter)) |
|
| 1176 | + { |
|
| 1177 | + $HierarchyDelimiter = Cache::getCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5); |
|
| 1178 | + } |
|
| 1179 | + if ($_useCache===false) |
|
| 1180 | + { |
|
| 1181 | + unset($HierarchyDelimiter[$this->icServer->ImapServerId]); |
|
| 1182 | + } |
|
| 1040 | 1183 | if (isset($HierarchyDelimiter[$this->icServer->ImapServerId])&&!empty($HierarchyDelimiter[$this->icServer->ImapServerId])) |
| 1041 | 1184 | { |
| 1042 | 1185 | return $HierarchyDelimiter[$this->icServer->ImapServerId]; |
@@ -1070,14 +1213,19 @@ discard block |
||
| 1070 | 1213 | { |
| 1071 | 1214 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$this->icServer->ImapServerId.' Connected:'.$this->icServer->_connected); |
| 1072 | 1215 | static $_specialUseFolders = null; |
| 1073 | - if (is_null($_specialUseFolders)||empty($_specialUseFolders)) $_specialUseFolders = Cache::getCache(Cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5); |
|
| 1216 | + if (is_null($_specialUseFolders)||empty($_specialUseFolders)) |
|
| 1217 | + { |
|
| 1218 | + $_specialUseFolders = Cache::getCache(Cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5); |
|
| 1219 | + } |
|
| 1074 | 1220 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_trash)); |
| 1075 | 1221 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_sent)); |
| 1076 | 1222 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_draft)); |
| 1077 | 1223 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_template)); |
| 1078 | 1224 | self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId]; |
| 1079 | 1225 | if (isset($_specialUseFolders[$this->icServer->ImapServerId]) && !empty($_specialUseFolders[$this->icServer->ImapServerId])) |
| 1080 | - return $_specialUseFolders[$this->icServer->ImapServerId]; |
|
| 1226 | + { |
|
| 1227 | + return $_specialUseFolders[$this->icServer->ImapServerId]; |
|
| 1228 | + } |
|
| 1081 | 1229 | $_specialUseFolders[$this->icServer->ImapServerId]=array(); |
| 1082 | 1230 | //if (!empty($this->icServer->acc_folder_trash) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash])) |
| 1083 | 1231 | $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash]='Trash'; |
@@ -1105,7 +1253,8 @@ discard block |
||
| 1105 | 1253 | function folderIsSelectable($folderToSelect) |
| 1106 | 1254 | { |
| 1107 | 1255 | $retval = true; |
| 1108 | - if($folderToSelect && ($folderStatus = $this->getFolderStatus($folderToSelect,false,true))) { |
|
| 1256 | + if($folderToSelect && ($folderStatus = $this->getFolderStatus($folderToSelect,false,true))) |
|
| 1257 | + { |
|
| 1109 | 1258 | if (!empty($folderStatus['attributes']) && stripos(array2string($folderStatus['attributes']),'noselect')!==false) |
| 1110 | 1259 | { |
| 1111 | 1260 | $retval = false; |
@@ -1158,7 +1307,10 @@ discard block |
||
| 1158 | 1307 | */ |
| 1159 | 1308 | function getFolderStatus($_folderName,$ignoreStatusCache=false,$basicInfoOnly=false,$fetchSubscribedInfo=true) |
| 1160 | 1309 | { |
| 1161 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '." called with:$_folderName,$ignoreStatusCache,$basicInfoOnly"); |
|
| 1310 | + if (self::$debug) |
|
| 1311 | + { |
|
| 1312 | + error_log(__METHOD__.' ('.__LINE__.') '." called with:$_folderName,$ignoreStatusCache,$basicInfoOnly"); |
|
| 1313 | + } |
|
| 1162 | 1314 | if (!is_string($_folderName) || empty($_folderName)||(isset(self::$profileDefunct[$this->profileID]) && strlen(self::$profileDefunct[$this->profileID]))) |
| 1163 | 1315 | { |
| 1164 | 1316 | // something is wrong. Do not proceed. either no folder or profile is marked as defunct for this request |
@@ -1170,7 +1322,10 @@ discard block |
||
| 1170 | 1322 | { |
| 1171 | 1323 | $folderInfoCache = $folderBasicInfo[$this->profileID]; |
| 1172 | 1324 | } |
| 1173 | - if (isset($folderInfoCache[$_folderName]) && $ignoreStatusCache==false && $basicInfoOnly) return $folderInfoCache[$_folderName]; |
|
| 1325 | + if (isset($folderInfoCache[$_folderName]) && $ignoreStatusCache==false && $basicInfoOnly) |
|
| 1326 | + { |
|
| 1327 | + return $folderInfoCache[$_folderName]; |
|
| 1328 | + } |
|
| 1174 | 1329 | $retValue = array(); |
| 1175 | 1330 | $retValue['subscribed'] = false; |
| 1176 | 1331 | /* |
@@ -1199,7 +1354,10 @@ discard block |
||
| 1199 | 1354 | if (is_array($ret)) |
| 1200 | 1355 | { |
| 1201 | 1356 | $retkeys = array_keys($ret); |
| 1202 | - if ($retkeys[0]==$_folderName) $folderInfoCache[$_folderName] = $ret[$retkeys[0]]; |
|
| 1357 | + if ($retkeys[0]==$_folderName) |
|
| 1358 | + { |
|
| 1359 | + $folderInfoCache[$_folderName] = $ret[$retkeys[0]]; |
|
| 1360 | + } |
|
| 1203 | 1361 | } |
| 1204 | 1362 | else |
| 1205 | 1363 | { |
@@ -1208,7 +1366,8 @@ discard block |
||
| 1208 | 1366 | } |
| 1209 | 1367 | $folderInfo = $folderInfoCache[$_folderName]; |
| 1210 | 1368 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($folderInfo).'->'.function_backtrace()); |
| 1211 | - if($ignoreStatusCache||!$folderInfo|| !is_array($folderInfo)) { |
|
| 1369 | + if($ignoreStatusCache||!$folderInfo|| !is_array($folderInfo)) |
|
| 1370 | + { |
|
| 1212 | 1371 | try |
| 1213 | 1372 | { |
| 1214 | 1373 | $folderInfo = $this->_getStatus($_folderName,$ignoreStatusCache); |
@@ -1243,7 +1402,8 @@ discard block |
||
| 1243 | 1402 | $retValue['shortName'] = array_pop($shortNameParts); |
| 1244 | 1403 | $retValue['displayName'] = $_folderName; |
| 1245 | 1404 | $retValue['shortDisplayName'] = $retValue['shortName']; |
| 1246 | - if(strtoupper($retValue['shortName']) == 'INBOX') { |
|
| 1405 | + if(strtoupper($retValue['shortName']) == 'INBOX') |
|
| 1406 | + { |
|
| 1247 | 1407 | $retValue['displayName'] = lang('INBOX'); |
| 1248 | 1408 | $retValue['shortDisplayName'] = lang('INBOX'); |
| 1249 | 1409 | } |
@@ -1252,7 +1412,10 @@ discard block |
||
| 1252 | 1412 | { |
| 1253 | 1413 | $retValue['displayName'] = $retValue['shortDisplayName'] = lang($retValue['shortName']); |
| 1254 | 1414 | } |
| 1255 | - if ($folderInfo) $folderBasicInfo[$this->profileID][$_folderName]=$retValue; |
|
| 1415 | + if ($folderInfo) |
|
| 1416 | + { |
|
| 1417 | + $folderBasicInfo[$this->profileID][$_folderName]=$retValue; |
|
| 1418 | + } |
|
| 1256 | 1419 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$_folderName.array2string($retValue['attributes'])); |
| 1257 | 1420 | if ($basicInfoOnly || (isset($retValue['attributes']) && stripos(array2string($retValue['attributes']),'noselect')!==false)) |
| 1258 | 1421 | { |
@@ -1264,24 +1427,34 @@ discard block |
||
| 1264 | 1427 | static $subscribedFolders = null; |
| 1265 | 1428 | static $nameSpace = null; |
| 1266 | 1429 | static $prefix = null; |
| 1267 | - if (is_null($nameSpace) || empty($nameSpace[$this->profileID])) $nameSpace[$this->profileID] = $this->_getNameSpaces(); |
|
| 1430 | + if (is_null($nameSpace) || empty($nameSpace[$this->profileID])) |
|
| 1431 | + { |
|
| 1432 | + $nameSpace[$this->profileID] = $this->_getNameSpaces(); |
|
| 1433 | + } |
|
| 1268 | 1434 | if (!empty($nameSpace[$this->profileID])) |
| 1269 | 1435 | { |
| 1270 | 1436 | $nsNoPersonal=array(); |
| 1271 | 1437 | foreach($nameSpace[$this->profileID] as &$ns) |
| 1272 | 1438 | { |
| 1273 | - if ($ns['type']!='personal') $nsNoPersonal[]=$ns; |
|
| 1439 | + if ($ns['type']!='personal') |
|
| 1440 | + { |
|
| 1441 | + $nsNoPersonal[]=$ns; |
|
| 1442 | + } |
|
| 1274 | 1443 | } |
| 1275 | 1444 | $nameSpace[$this->profileID]=$nsNoPersonal; |
| 1276 | 1445 | } |
| 1277 | - if (is_null($prefix) || empty($prefix[$this->profileID]) || empty($prefix[$this->profileID][$_folderName])) $prefix[$this->profileID][$_folderName] = $this->getFolderPrefixFromNamespace($nameSpace[$this->profileID], $_folderName); |
|
| 1446 | + if (is_null($prefix) || empty($prefix[$this->profileID]) || empty($prefix[$this->profileID][$_folderName])) |
|
| 1447 | + { |
|
| 1448 | + $prefix[$this->profileID][$_folderName] = $this->getFolderPrefixFromNamespace($nameSpace[$this->profileID], $_folderName); |
|
| 1449 | + } |
|
| 1278 | 1450 | |
| 1279 | 1451 | if ($fetchSubscribedInfo && is_null($subscribedFolders) || empty($subscribedFolders[$this->profileID])) |
| 1280 | 1452 | { |
| 1281 | 1453 | $subscribedFolders[$this->profileID] = $this->icServer->listSubscribedMailboxes(); |
| 1282 | 1454 | } |
| 1283 | 1455 | |
| 1284 | - if($fetchSubscribedInfo && is_array($subscribedFolders[$this->profileID]) && in_array($_folderName,$subscribedFolders[$this->profileID])) { |
|
| 1456 | + if($fetchSubscribedInfo && is_array($subscribedFolders[$this->profileID]) && in_array($_folderName,$subscribedFolders[$this->profileID])) |
|
| 1457 | + { |
|
| 1285 | 1458 | $retValue['subscribed'] = true; |
| 1286 | 1459 | } |
| 1287 | 1460 | |
@@ -1300,8 +1473,7 @@ discard block |
||
| 1300 | 1473 | (isset($this->mailPreferences['trustServersUnseenInfo']) && |
| 1301 | 1474 | $this->mailPreferences['trustServersUnseenInfo']==2 && |
| 1302 | 1475 | $prefix[$this->profileID][$_folderName] != '' && stripos($_folderName,$prefix[$this->profileID][$_folderName]) !== false) |
| 1303 | - ) |
|
| 1304 | - { |
|
| 1476 | + ) { |
|
| 1305 | 1477 | //error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($prefix,true).' TS:'.$this->mailPreferences['trustServersUnseenInfo']); |
| 1306 | 1478 | // we filter for the combined status of unseen and undeleted, as this is what we show in list |
| 1307 | 1479 | try |
@@ -1313,13 +1485,19 @@ discard block |
||
| 1313 | 1485 | } |
| 1314 | 1486 | catch (\Exception $ee) |
| 1315 | 1487 | { |
| 1316 | - if (self::$debug) error_log(__METHOD__." could not fetch/calculate unseen counter for $_folderName Reason:'".$ee->getMessage()."' but requested."); |
|
| 1488 | + if (self::$debug) |
|
| 1489 | + { |
|
| 1490 | + error_log(__METHOD__." could not fetch/calculate unseen counter for $_folderName Reason:'".$ee->getMessage()."' but requested."); |
|
| 1491 | + } |
|
| 1317 | 1492 | } |
| 1318 | 1493 | } |
| 1319 | 1494 | } |
| 1320 | 1495 | catch (\Exception $e) |
| 1321 | 1496 | { |
| 1322 | - if (self::$debug) error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($e->getMessage(),true)); |
|
| 1497 | + if (self::$debug) |
|
| 1498 | + { |
|
| 1499 | + error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($e->getMessage(),true)); |
|
| 1500 | + } |
|
| 1323 | 1501 | } |
| 1324 | 1502 | |
| 1325 | 1503 | return $retValue; |
@@ -1344,8 +1522,14 @@ discard block |
||
| 1344 | 1522 | function getHeaders($_folderName, $_startMessage, $_numberOfMessages, $_sort, $_reverse, $_filter, $_thisUIDOnly=null, $_cacheResult=true, $_fetchPreviews=false) |
| 1345 | 1523 | { |
| 1346 | 1524 | //self::$debug=true; |
| 1347 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.function_backtrace()); |
|
| 1348 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$_folderName,$_startMessage, $_numberOfMessages, $_sort, $_reverse, ".array2string($_filter).", $_thisUIDOnly"); |
|
| 1525 | + if (self::$debug) |
|
| 1526 | + { |
|
| 1527 | + error_log(__METHOD__.' ('.__LINE__.') '.function_backtrace()); |
|
| 1528 | + } |
|
| 1529 | + if (self::$debug) |
|
| 1530 | + { |
|
| 1531 | + error_log(__METHOD__.' ('.__LINE__.') '."$_folderName,$_startMessage, $_numberOfMessages, $_sort, $_reverse, ".array2string($_filter).", $_thisUIDOnly"); |
|
| 1532 | + } |
|
| 1349 | 1533 | $reverse = (bool)$_reverse; |
| 1350 | 1534 | // get the list of messages to fetch |
| 1351 | 1535 | $this->reopen($_folderName); |
@@ -1366,21 +1550,34 @@ discard block |
||
| 1366 | 1550 | //$_filter['range'] ="$start:$end"; |
| 1367 | 1551 | //$_filter['range'] ="$_startMessage:*"; |
| 1368 | 1552 | } |
| 1369 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$_folderName, $_sort, $reverse, ".array2string($_filter).", $rByUid"); |
|
| 1370 | - if (self::$debug||self::$debugTimes) $starttime = microtime (true); |
|
| 1553 | + if (self::$debug) |
|
| 1554 | + { |
|
| 1555 | + error_log(__METHOD__.' ('.__LINE__.') '."$_folderName, $_sort, $reverse, ".array2string($_filter).", $rByUid"); |
|
| 1556 | + } |
|
| 1557 | + if (self::$debug||self::$debugTimes) |
|
| 1558 | + { |
|
| 1559 | + $starttime = microtime (true); |
|
| 1560 | + } |
|
| 1371 | 1561 | //see this example below for a 12 week datefilter (since) |
| 1372 | 1562 | //$_filter = array('status'=>array('UNDELETED'),'type'=>"SINCE",'string'=> date("d-M-Y", $starttime-(3600*24*7*12))); |
| 1373 | 1563 | $_sortResult = $this->getSortedList($_folderName, $_sort, $reverse, $_filter, $rByUid, $_cacheResult); |
| 1374 | 1564 | $sortResult = $_sortResult['match']->ids; |
| 1375 | 1565 | //$modseq = $_sortResult['modseq']; |
| 1376 | 1566 | //error_log(__METHOD__.' ('.__LINE__.') '.'Modsequence:'.$modseq); |
| 1377 | - if (self::$debug||self::$debugTimes) self::logRunTimes($starttime,null,' call getSortedList for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_thisUIDOnly),__METHOD__.' ('.__LINE__.') '); |
|
| 1567 | + if (self::$debug||self::$debugTimes) |
|
| 1568 | + { |
|
| 1569 | + self::logRunTimes($starttime,null,' call getSortedList for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_thisUIDOnly),__METHOD__.' ('.__LINE__.') '); |
|
| 1570 | + } |
|
| 1378 | 1571 | |
| 1379 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult)); |
|
| 1572 | + if (self::$debug) |
|
| 1573 | + { |
|
| 1574 | + error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult)); |
|
| 1575 | + } |
|
| 1380 | 1576 | #$this->icServer->setDebug(false); |
| 1381 | 1577 | #print "</pre>"; |
| 1382 | 1578 | // nothing found |
| 1383 | - if(!is_array($sortResult) || empty($sortResult)) { |
|
| 1579 | + if(!is_array($sortResult) || empty($sortResult)) |
|
| 1580 | + { |
|
| 1384 | 1581 | $retValue = array(); |
| 1385 | 1582 | $retValue['info']['total'] = 0; |
| 1386 | 1583 | $retValue['info']['first'] = 0; |
@@ -1392,7 +1589,8 @@ discard block |
||
| 1392 | 1589 | #_debug_array($sortResult); |
| 1393 | 1590 | #_debug_array(array_slice($sortResult, -5, -2)); |
| 1394 | 1591 | //error_log("REVERSE: $reverse"); |
| 1395 | - if($reverse === true) { |
|
| 1592 | + if($reverse === true) |
|
| 1593 | + { |
|
| 1396 | 1594 | if ($_startMessage<=$total) |
| 1397 | 1595 | { |
| 1398 | 1596 | $startMessage = $_startMessage-1; |
@@ -1404,7 +1602,10 @@ discard block |
||
| 1404 | 1602 | { |
| 1405 | 1603 | $numberOfMessages = $total%$_numberOfMessages; |
| 1406 | 1604 | //$numberOfMessages = abs($_startMessage-$total-1); |
| 1407 | - if ($numberOfMessages>0 && $numberOfMessages<=$_numberOfMessages) $_numberOfMessages = $numberOfMessages; |
|
| 1605 | + if ($numberOfMessages>0 && $numberOfMessages<=$_numberOfMessages) |
|
| 1606 | + { |
|
| 1607 | + $_numberOfMessages = $numberOfMessages; |
|
| 1608 | + } |
|
| 1408 | 1609 | //error_log(__METHOD__.' ('.__LINE__.') '.' Start:'.$_startMessage.' NumberOfMessages:'.$_numberOfMessages.' Total:'.$total); |
| 1409 | 1610 | } |
| 1410 | 1611 | $startMessage=($total-$_numberOfMessages)-1; |
@@ -1418,19 +1619,36 @@ discard block |
||
| 1418 | 1619 | //$retValue['info']['first'] = $startMessage; |
| 1419 | 1620 | //$retValue['info']['last'] = $total; |
| 1420 | 1621 | } |
| 1421 | - if($startMessage > 0) { |
|
| 1422 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+$startMessage)).', '.-$startMessage.' Number of Messages:'.count($sortResult)); |
|
| 1622 | + if($startMessage > 0) |
|
| 1623 | + { |
|
| 1624 | + if (self::$debug) |
|
| 1625 | + { |
|
| 1626 | + error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+$startMessage)).', '.-$startMessage.' Number of Messages:'.count($sortResult)); |
|
| 1627 | + } |
|
| 1423 | 1628 | $sortResult = array_slice($sortResult, -($_numberOfMessages+$startMessage), -$startMessage); |
| 1424 | - } else { |
|
| 1425 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+($_startMessage-1))).', AllTheRest, Number of Messages:'.count($sortResult)); |
|
| 1629 | + } |
|
| 1630 | + else |
|
| 1631 | + { |
|
| 1632 | + if (self::$debug) |
|
| 1633 | + { |
|
| 1634 | + error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+($_startMessage-1))).', AllTheRest, Number of Messages:'.count($sortResult)); |
|
| 1635 | + } |
|
| 1426 | 1636 | $sortResult = array_slice($sortResult, -($_numberOfMessages+($_startMessage-1))); |
| 1427 | 1637 | } |
| 1428 | 1638 | $sortResult = array_reverse($sortResult); |
| 1429 | - } else { |
|
| 1430 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.($_startMessage-1).', '.$_numberOfMessages.' Number of Messages:'.count($sortResult)); |
|
| 1639 | + } |
|
| 1640 | + else |
|
| 1641 | + { |
|
| 1642 | + if (self::$debug) |
|
| 1643 | + { |
|
| 1644 | + error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.($_startMessage-1).', '.$_numberOfMessages.' Number of Messages:'.count($sortResult)); |
|
| 1645 | + } |
|
| 1431 | 1646 | $sortResult = array_slice($sortResult, $_startMessage-1, $_numberOfMessages); |
| 1432 | 1647 | } |
| 1433 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult)); |
|
| 1648 | + if (self::$debug) |
|
| 1649 | + { |
|
| 1650 | + error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult)); |
|
| 1651 | + } |
|
| 1434 | 1652 | } |
| 1435 | 1653 | else |
| 1436 | 1654 | { |
@@ -1439,7 +1657,10 @@ discard block |
||
| 1439 | 1657 | |
| 1440 | 1658 | |
| 1441 | 1659 | // fetch the data for the selected messages |
| 1442 | - if (self::$debug||self::$debugTimes) $starttime = microtime(true); |
|
| 1660 | + if (self::$debug||self::$debugTimes) |
|
| 1661 | + { |
|
| 1662 | + $starttime = microtime(true); |
|
| 1663 | + } |
|
| 1443 | 1664 | try |
| 1444 | 1665 | { |
| 1445 | 1666 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
@@ -1463,7 +1684,10 @@ discard block |
||
| 1463 | 1684 | $fquery->flags(); |
| 1464 | 1685 | $fquery->imapDate();// needed to ensure getImapDate fetches the internaldate, not the current time |
| 1465 | 1686 | // if $_fetchPreviews is activated fetch part of the messages too |
| 1466 | - if ($_fetchPreviews) $fquery->fullText(array('peek'=>true,'length'=>((int)$_fetchPreviews<5000?5000:$_fetchPreviews),'start'=>0)); |
|
| 1687 | + if ($_fetchPreviews) |
|
| 1688 | + { |
|
| 1689 | + $fquery->fullText(array('peek'=>true,'length'=>((int)$_fetchPreviews<5000?5000:$_fetchPreviews),'start'=>0)); |
|
| 1690 | + } |
|
| 1467 | 1691 | $headersNew = $this->icServer->fetch($_folderName, $fquery, array( |
| 1468 | 1692 | 'ids' => $uidsToFetch, |
| 1469 | 1693 | )); |
@@ -1486,14 +1710,20 @@ discard block |
||
| 1486 | 1710 | |
| 1487 | 1711 | $cnt = 0; |
| 1488 | 1712 | |
| 1489 | - foreach((array)$sortResult as $uid) { |
|
| 1713 | + foreach((array)$sortResult as $uid) |
|
| 1714 | + { |
|
| 1490 | 1715 | $sortOrder[$uid] = $cnt++; |
| 1491 | 1716 | } |
| 1492 | 1717 | |
| 1493 | 1718 | $count = 0; |
| 1494 | - if (is_object($headersNew)) { |
|
| 1495 | - if (self::$debug||self::$debugTimes) $starttime = microtime(true); |
|
| 1496 | - foreach($headersNew->ids() as $id) { |
|
| 1719 | + if (is_object($headersNew)) |
|
| 1720 | + { |
|
| 1721 | + if (self::$debug||self::$debugTimes) |
|
| 1722 | + { |
|
| 1723 | + $starttime = microtime(true); |
|
| 1724 | + } |
|
| 1725 | + foreach($headersNew->ids() as $id) |
|
| 1726 | + { |
|
| 1497 | 1727 | $_headerObject = $headersNew->get($id); |
| 1498 | 1728 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_headerObject)); |
| 1499 | 1729 | $headerObject = array(); |
@@ -1506,7 +1736,10 @@ discard block |
||
| 1506 | 1736 | // Get already cached headers, 'fetchHeaders' is a label matchimg above |
| 1507 | 1737 | $headerForPrio = $_headerObject->getHeaders('fetchHeaders',Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(); |
| 1508 | 1738 | // Try to fetch header with key='' as some servers might have no fetchHeaders index. e.g. yandex.com |
| 1509 | - if (empty($headerForPrio)) $headerForPrio = $_headerObject->getHeaders('',Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(); |
|
| 1739 | + if (empty($headerForPrio)) |
|
| 1740 | + { |
|
| 1741 | + $headerForPrio = $_headerObject->getHeaders('',Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(); |
|
| 1742 | + } |
|
| 1510 | 1743 | //fetch the fullMsg part if all conditions match to be available in case $_headerObject->getHeaders returns |
| 1511 | 1744 | //nothing worthwhile (as it does for googlemail accounts, when preview is switched on |
| 1512 | 1745 | if ($_fetchPreviews) |
@@ -1517,12 +1750,16 @@ discard block |
||
| 1517 | 1750 | if (empty($headerForPrio)||(is_array($headerForPrio)&&count($headerForPrio)===1&&$headerForPrio[''])) |
| 1518 | 1751 | { |
| 1519 | 1752 | $length = strpos($bodyPreview, Horde_Mime_Part::RFC_EOL.Horde_Mime_Part::RFC_EOL); |
| 1520 | - if ($length===false) $length = strlen($bodyPreview); |
|
| 1753 | + if ($length===false) |
|
| 1754 | + { |
|
| 1755 | + $length = strlen($bodyPreview); |
|
| 1756 | + } |
|
| 1521 | 1757 | $headerForPrio = Horde_Mime_Headers::parseHeaders(substr($bodyPreview, 0,$length))->toArray(); |
| 1522 | 1758 | } |
| 1523 | 1759 | } |
| 1524 | 1760 | $headerForPrio = array_change_key_case($headerForPrio, CASE_UPPER); |
| 1525 | - if (self::$debug) { |
|
| 1761 | + if (self::$debug) |
|
| 1762 | + { |
|
| 1526 | 1763 | error_log(__METHOD__.' ('.__LINE__.') '.array2string($_headerObject).'UID:'.$_headerObject->getUid().' Size:'.$_headerObject->getSize().' Date:'.$_headerObject->getImapDate().'/'.DateTime::to($_headerObject->getImapDate(),'Y-m-d H:i:s')); |
| 1527 | 1764 | error_log(__METHOD__.' ('.__LINE__.') '.array2string($headerForPrio)); |
| 1528 | 1765 | } |
@@ -1532,11 +1769,16 @@ discard block |
||
| 1532 | 1769 | $total--; |
| 1533 | 1770 | continue; |
| 1534 | 1771 | } |
| 1535 | - if ( isset($headerForPrio['DISPOSITION-NOTIFICATION-TO']) ) { |
|
| 1772 | + if ( isset($headerForPrio['DISPOSITION-NOTIFICATION-TO']) ) |
|
| 1773 | + { |
|
| 1536 | 1774 | $headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['DISPOSITION-NOTIFICATION-TO'])); |
| 1537 | - } else if ( isset($headerForPrio['RETURN-RECEIPT-TO']) ) { |
|
| 1775 | + } |
|
| 1776 | + else if ( isset($headerForPrio['RETURN-RECEIPT-TO']) ) |
|
| 1777 | + { |
|
| 1538 | 1778 | $headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['RETURN-RECEIPT-TO'])); |
| 1539 | - } else if ( isset($headerForPrio['X-CONFIRM-READING-TO']) ) { |
|
| 1779 | + } |
|
| 1780 | + else if ( isset($headerForPrio['X-CONFIRM-READING-TO']) ) |
|
| 1781 | + { |
|
| 1540 | 1782 | $headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['X-CONFIRM-READING-TO'])); |
| 1541 | 1783 | } /*else $sent_not = "";*/ |
| 1542 | 1784 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($headerObject)); |
@@ -1568,7 +1810,11 @@ discard block |
||
| 1568 | 1810 | $rfcAddr = self::parseAddressList($ad); // does some fixing of known problems too |
| 1569 | 1811 | foreach ($rfcAddr as $_rfcAddr) |
| 1570 | 1812 | { |
| 1571 | - if (!$_rfcAddr->valid) continue; // skip. not a valid address |
|
| 1813 | + if (!$_rfcAddr->valid) |
|
| 1814 | + { |
|
| 1815 | + continue; |
|
| 1816 | + } |
|
| 1817 | + // skip. not a valid address |
|
| 1572 | 1818 | $address[] = imap_rfc822_write_address($_rfcAddr->mailbox,$_rfcAddr->host,$_rfcAddr->personal); |
| 1573 | 1819 | } |
| 1574 | 1820 | } |
@@ -1584,7 +1830,10 @@ discard block |
||
| 1584 | 1830 | { |
| 1585 | 1831 | // $bodyPreview is populated at the beginning of the loop, as it may be |
| 1586 | 1832 | // needed to parse the Headers of the Message |
| 1587 | - if (empty($bodyPreview)) $bodyPreview = $_headerObject->getFullMsg(); |
|
| 1833 | + if (empty($bodyPreview)) |
|
| 1834 | + { |
|
| 1835 | + $bodyPreview = $_headerObject->getFullMsg(); |
|
| 1836 | + } |
|
| 1588 | 1837 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($bodyPreview)); |
| 1589 | 1838 | $base = Horde_Mime_Part::parseMessage($bodyPreview); |
| 1590 | 1839 | foreach($base->partIterator() as $part) |
@@ -1597,7 +1846,8 @@ discard block |
||
| 1597 | 1846 | 'encode' => Horde_Mime_Part::ENCODE_BINARY, // otherwise we cant recode charset |
| 1598 | 1847 | )), $charset, 'utf-8'); |
| 1599 | 1848 | $headerObject['BODYPREVIEW']=trim(str_replace(array("\r\n","\r","\n"),' ',mb_substr(Translation::convert_jsonsafe($buffer),0,((int)$_fetchPreviews<300?300:$_fetchPreviews)))); |
| 1600 | - } elseif (empty($headerObject['BODYPREVIEW'])&&$part->getPrimaryType()== 'multipart') |
|
| 1849 | + } |
|
| 1850 | + elseif (empty($headerObject['BODYPREVIEW'])&&$part->getPrimaryType()== 'multipart') |
|
| 1601 | 1851 | { |
| 1602 | 1852 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($part)); |
| 1603 | 1853 | } |
@@ -1613,7 +1863,10 @@ discard block |
||
| 1613 | 1863 | $messageMimeType=''; |
| 1614 | 1864 | foreach ($mailStructureObject->contentTypeMap() as $mime_id => $mime_type) |
| 1615 | 1865 | { |
| 1616 | - if ($mime_id==0 || $messageMimeType==='') $messageMimeType = $mime_type; |
|
| 1866 | + if ($mime_id==0 || $messageMimeType==='') |
|
| 1867 | + { |
|
| 1868 | + $messageMimeType = $mime_type; |
|
| 1869 | + } |
|
| 1617 | 1870 | $part = $mailStructureObject->getPart($mime_id); |
| 1618 | 1871 | $partdisposition = $part->getDisposition(); |
| 1619 | 1872 | $partPrimaryType = $part->getPrimaryType(); |
@@ -1623,7 +1876,8 @@ discard block |
||
| 1623 | 1876 | // bodypreview could be found (multipart/....) |
| 1624 | 1877 | if ($_fetchPreviews && empty($headerObject['BODYPREVIEW'])&&($partPrimaryType == 'text') && |
| 1625 | 1878 | ((intval($mime_id) === 1) || !$mime_id) && |
| 1626 | - ($partdisposition !== 'attachment')) { |
|
| 1879 | + ($partdisposition !== 'attachment')) |
|
| 1880 | + { |
|
| 1627 | 1881 | $_structure=$part; |
| 1628 | 1882 | $this->fetchPartContents($uid, $_structure, false,true); |
| 1629 | 1883 | $headerObject['BODYPREVIEW']=trim(str_replace(array("\r\n","\r","\n"),' ',mb_substr(Mail\Html::convertHTMLToText($_structure->getContents()),0,((int)$_fetchPreviews<300?300:$_fetchPreviews)))); |
@@ -1645,10 +1899,19 @@ discard block |
||
| 1645 | 1899 | if ($mime_type=='message/rfc822') |
| 1646 | 1900 | { |
| 1647 | 1901 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.':'.array2string($part->contentTypeMap())); |
| 1648 | - foreach($part->contentTypeMap() as $sub_id => $sub_type) { if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type;} |
|
| 1902 | + foreach($part->contentTypeMap() as $sub_id => $sub_type) |
|
| 1903 | + { |
|
| 1904 | +if ($sub_id != $mime_id) |
|
| 1905 | + { |
|
| 1906 | + $skipParts[$sub_id] = $sub_type; |
|
| 1907 | + } |
|
| 1908 | + } |
|
| 1649 | 1909 | } |
| 1650 | 1910 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.' Disp:'.$partdisposition.' Type:'.$partPrimaryType.' Skip:'.array2string($skipParts)); |
| 1651 | - if (array_key_exists($mime_id,$skipParts)) continue; |
|
| 1911 | + if (array_key_exists($mime_id,$skipParts)) |
|
| 1912 | + { |
|
| 1913 | + continue; |
|
| 1914 | + } |
|
| 1652 | 1915 | if ($partdisposition=='attachment' || |
| 1653 | 1916 | ($partdisposition=='inline'&&$partPrimaryType == 'image'&&$mime_type=='image/tiff') || // as we are not able to display tiffs |
| 1654 | 1917 | ($partdisposition=='inline'&&$partPrimaryType == 'image'&&empty($cid)) || |
@@ -1659,7 +1922,10 @@ discard block |
||
| 1659 | 1922 | $headerObject['ATTACHMENTS'][$mime_id]['uid']=$uid; |
| 1660 | 1923 | $headerObject['ATTACHMENTS'][$mime_id]['cid'] = $cid; |
| 1661 | 1924 | $headerObject['ATTACHMENTS'][$mime_id]['partID']=$mime_id; |
| 1662 | - if (!isset($headerObject['ATTACHMENTS'][$mime_id]['name']))$headerObject['ATTACHMENTS'][$mime_id]['name']=$part->getName(); |
|
| 1925 | + if (!isset($headerObject['ATTACHMENTS'][$mime_id]['name'])) |
|
| 1926 | + { |
|
| 1927 | + $headerObject['ATTACHMENTS'][$mime_id]['name']=$part->getName(); |
|
| 1928 | + } |
|
| 1663 | 1929 | if (!strcasecmp($headerObject['ATTACHMENTS'][$mime_id]['name'],'winmail.dat') || |
| 1664 | 1930 | $headerObject['ATTACHMENTS'][$mime_id]['mimeType']=='application/ms-tnef') |
| 1665 | 1931 | { |
@@ -1673,18 +1939,27 @@ discard block |
||
| 1673 | 1939 | //error_log(__METHOD__.' ('.__LINE__.') '.' FindBody (plain):'.array2string($mailStructureObject->findBody('plain'))); |
| 1674 | 1940 | //error_log(__METHOD__.' ('.__LINE__.') '.' FindBody (html):'.array2string($mailStructureObject->findBody('html'))); |
| 1675 | 1941 | //if($count == 0) error_log(__METHOD__.array2string($headerObject)); |
| 1676 | - if (empty($headerObject['UID'])) continue; |
|
| 1942 | + if (empty($headerObject['UID'])) |
|
| 1943 | + { |
|
| 1944 | + continue; |
|
| 1945 | + } |
|
| 1677 | 1946 | //$uid = ($rByUid ? $headerObject['UID'] : $headerObject['MSG_NUM']); |
| 1678 | 1947 | // make dates like "Mon, 23 Apr 2007 10:11:06 UT" working with strtotime |
| 1679 | - if(substr($headerObject['DATE'],-2) === 'UT') { |
|
| 1948 | + if(substr($headerObject['DATE'],-2) === 'UT') |
|
| 1949 | + { |
|
| 1680 | 1950 | $headerObject['DATE'] .= 'C'; |
| 1681 | 1951 | } |
| 1682 | - if(substr($headerObject['INTERNALDATE'],-2) === 'UT') { |
|
| 1952 | + if(substr($headerObject['INTERNALDATE'],-2) === 'UT') |
|
| 1953 | + { |
|
| 1683 | 1954 | $headerObject['INTERNALDATE'] .= 'C'; |
| 1684 | 1955 | } |
| 1685 | 1956 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$headerObject['SUBJECT'].'->'.$headerObject['DATE'].'<->'.$headerObject['INTERNALDATE'] .'#'); |
| 1686 | 1957 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$this->decode_subject($headerObject['SUBJECT']).'->'.$headerObject['DATE']); |
| 1687 | - if (isset($headerObject['ATTACHMENTS']) && count($headerObject['ATTACHMENTS'])) foreach ($headerObject['ATTACHMENTS'] as &$a) { $retValue['header'][$sortOrder[$uid]]['attachments'][]=$a;} |
|
| 1958 | + if (isset($headerObject['ATTACHMENTS']) && count($headerObject['ATTACHMENTS'])) |
|
| 1959 | + { |
|
| 1960 | + foreach ($headerObject['ATTACHMENTS'] as &$a) { $retValue['header'][$sortOrder[$uid]]['attachments'][]=$a; |
|
| 1961 | + } |
|
| 1962 | + } |
|
| 1688 | 1963 | $retValue['header'][$sortOrder[$uid]]['subject'] = $this->decode_subject($headerObject['SUBJECT']); |
| 1689 | 1964 | $retValue['header'][$sortOrder[$uid]]['size'] = $headerObject['SIZE']; |
| 1690 | 1965 | $retValue['header'][$sortOrder[$uid]]['date'] = self::_strtotime(($headerObject['DATE']&&!($headerObject['DATE']=='NIL')?$headerObject['DATE']:$headerObject['INTERNALDATE']),'ts',true); |
@@ -1695,25 +1970,35 @@ discard block |
||
| 1695 | 1970 | $retValue['header'][$sortOrder[$uid]]['bodypreview'] = $headerObject['BODYPREVIEW']; |
| 1696 | 1971 | $retValue['header'][$sortOrder[$uid]]['priority'] = ($headerObject['PRIORITY']?$headerObject['PRIORITY']:3); |
| 1697 | 1972 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.array2string($retValue['header'][$sortOrder[$uid]])); |
| 1698 | - if (isset($headerObject['DISPOSITION-NOTIFICATION-TO'])) $retValue['header'][$sortOrder[$uid]]['disposition-notification-to'] = $headerObject['DISPOSITION-NOTIFICATION-TO']; |
|
| 1699 | - if (is_array($headerObject['FLAGS'])) { |
|
| 1973 | + if (isset($headerObject['DISPOSITION-NOTIFICATION-TO'])) |
|
| 1974 | + { |
|
| 1975 | + $retValue['header'][$sortOrder[$uid]]['disposition-notification-to'] = $headerObject['DISPOSITION-NOTIFICATION-TO']; |
|
| 1976 | + } |
|
| 1977 | + if (is_array($headerObject['FLAGS'])) |
|
| 1978 | + { |
|
| 1700 | 1979 | $retValue['header'][$sortOrder[$uid]] = array_merge($retValue['header'][$sortOrder[$uid]],self::prepareFlagsArray($headerObject)); |
| 1701 | 1980 | } |
| 1702 | 1981 | //error_log(__METHOD__.' ('.__LINE__.') '.$headerObject['SUBJECT'].'->'.array2string($_headerObject->getEnvelope()->__get('from'))); |
| 1703 | - if(is_array($headerObject['FROM']) && $headerObject['FROM'][0]) { |
|
| 1982 | + if(is_array($headerObject['FROM']) && $headerObject['FROM'][0]) |
|
| 1983 | + { |
|
| 1704 | 1984 | $retValue['header'][$sortOrder[$uid]]['sender_address'] = self::decode_header($headerObject['FROM'][0],true); |
| 1705 | 1985 | } |
| 1706 | - if(is_array($headerObject['REPLY-TO']) && $headerObject['REPLY-TO'][0]) { |
|
| 1986 | + if(is_array($headerObject['REPLY-TO']) && $headerObject['REPLY-TO'][0]) |
|
| 1987 | + { |
|
| 1707 | 1988 | $retValue['header'][$sortOrder[$uid]]['reply_to_address'] = self::decode_header($headerObject['REPLY-TO'][0],true); |
| 1708 | 1989 | } |
| 1709 | - if(is_array($headerObject['TO']) && $headerObject['TO'][0]) { |
|
| 1990 | + if(is_array($headerObject['TO']) && $headerObject['TO'][0]) |
|
| 1991 | + { |
|
| 1710 | 1992 | $retValue['header'][$sortOrder[$uid]]['to_address'] = self::decode_header($headerObject['TO'][0],true); |
| 1711 | 1993 | if (count($headerObject['TO'])>1) |
| 1712 | 1994 | { |
| 1713 | 1995 | $ki=0; |
| 1714 | 1996 | foreach($headerObject['TO'] as $k => $add) |
| 1715 | 1997 | { |
| 1716 | - if ($k==0) continue; |
|
| 1998 | + if ($k==0) |
|
| 1999 | + { |
|
| 2000 | + continue; |
|
| 2001 | + } |
|
| 1717 | 2002 | //error_log(__METHOD__.' ('.__LINE__.') '."-> $k:".array2string($add)); |
| 1718 | 2003 | $retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki] = self::decode_header($add,true); |
| 1719 | 2004 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki])); |
@@ -1721,7 +2006,8 @@ discard block |
||
| 1721 | 2006 | } |
| 1722 | 2007 | } |
| 1723 | 2008 | } |
| 1724 | - if(is_array($headerObject['CC']) && count($headerObject['CC'])>0) { |
|
| 2009 | + if(is_array($headerObject['CC']) && count($headerObject['CC'])>0) |
|
| 2010 | + { |
|
| 1725 | 2011 | $ki=0; |
| 1726 | 2012 | foreach($headerObject['CC'] as $k => $add) |
| 1727 | 2013 | { |
@@ -1735,27 +2021,41 @@ discard block |
||
| 1735 | 2021 | |
| 1736 | 2022 | $count++; |
| 1737 | 2023 | } |
| 1738 | - if (self::$debug||self::$debugTimes) self::logRunTimes($starttime,null,' fetching Headers and stuff for Folder:'.$_folderName,__METHOD__.' ('.__LINE__.') '); |
|
| 2024 | + if (self::$debug||self::$debugTimes) |
|
| 2025 | + { |
|
| 2026 | + self::logRunTimes($starttime,null,' fetching Headers and stuff for Folder:'.$_folderName,__METHOD__.' ('.__LINE__.') '); |
|
| 2027 | + } |
|
| 1739 | 2028 | //self::$debug=false; |
| 1740 | 2029 | // sort the messages to the requested displayorder |
| 1741 | - if(is_array($retValue['header'])) { |
|
| 2030 | + if(is_array($retValue['header'])) |
|
| 2031 | + { |
|
| 1742 | 2032 | $countMessages = $total; |
| 1743 | - if (isset($_filter['range'])) $countMessages = self::$folderStatusCache[$this->profileID][$_folderName]['messages']; |
|
| 2033 | + if (isset($_filter['range'])) |
|
| 2034 | + { |
|
| 2035 | + $countMessages = self::$folderStatusCache[$this->profileID][$_folderName]['messages']; |
|
| 2036 | + } |
|
| 1744 | 2037 | ksort($retValue['header']); |
| 1745 | 2038 | $retValue['info']['total'] = $total; |
| 1746 | 2039 | //if ($_startMessage>$total) $_startMessage = $total-($count-1); |
| 1747 | 2040 | $retValue['info']['first'] = $_startMessage; |
| 1748 | 2041 | $retValue['info']['last'] = $_startMessage + $count - 1 ; |
| 1749 | 2042 | return $retValue; |
| 1750 | - } else { |
|
| 2043 | + } |
|
| 2044 | + else |
|
| 2045 | + { |
|
| 1751 | 2046 | $retValue = array(); |
| 1752 | 2047 | $retValue['info']['total'] = 0; |
| 1753 | 2048 | $retValue['info']['first'] = 0; |
| 1754 | 2049 | $retValue['info']['last'] = 0; |
| 1755 | 2050 | return $retValue; |
| 1756 | 2051 | } |
| 1757 | - } else { |
|
| 1758 | - if ($headersNew == null && empty($_thisUIDOnly)) error_log(__METHOD__." -> retrieval of Message Details to Query $queryString failed: ".print_r($headersNew,TRUE)); |
|
| 2052 | + } |
|
| 2053 | + else |
|
| 2054 | + { |
|
| 2055 | + if ($headersNew == null && empty($_thisUIDOnly)) |
|
| 2056 | + { |
|
| 2057 | + error_log(__METHOD__." -> retrieval of Message Details to Query $queryString failed: ".print_r($headersNew,TRUE)); |
|
| 2058 | + } |
|
| 1759 | 2059 | $retValue = array(); |
| 1760 | 2060 | $retValue['info']['total'] = 0; |
| 1761 | 2061 | $retValue['info']['first'] = 0; |
@@ -1772,7 +2072,10 @@ discard block |
||
| 1772 | 2072 | */ |
| 1773 | 2073 | static function prepareFlagsArray($headerObject) |
| 1774 | 2074 | { |
| 1775 | - if (is_array($headerObject['FLAGS'])) $headerFlags = array_map('strtolower',$headerObject['FLAGS']); |
|
| 2075 | + if (is_array($headerObject['FLAGS'])) |
|
| 2076 | + { |
|
| 2077 | + $headerFlags = array_map('strtolower',$headerObject['FLAGS']); |
|
| 2078 | + } |
|
| 1776 | 2079 | $retValue = array(); |
| 1777 | 2080 | $retValue['recent'] = in_array('\\recent', $headerFlags); |
| 1778 | 2081 | $retValue['flagged'] = in_array('\\flagged', $headerFlags); |
@@ -1823,26 +2126,45 @@ discard block |
||
| 1823 | 2126 | //error_log(__METHOD__.' ('.__LINE__.') '.' Filter:'.array2string($_filter)); |
| 1824 | 2127 | $try2useCache = true; |
| 1825 | 2128 | static $eMailListContainsDeletedMessages = null; |
| 1826 | - if (is_null($eMailListContainsDeletedMessages)) $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 2129 | + if (is_null($eMailListContainsDeletedMessages)) |
|
| 2130 | + { |
|
| 2131 | + $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 2132 | + } |
|
| 1827 | 2133 | // this indicates, that there is no Filter set, and the returned set/subset should not contain DELETED Messages, nor filtered for UNDELETED |
| 1828 | 2134 | if ($setSession==true && ((strpos(array2string($_filter), 'UNDELETED') === false && strpos(array2string($_filter), 'DELETED') === false))) |
| 1829 | 2135 | { |
| 1830 | - if (self::$debugTimes) $starttime = microtime(true); |
|
| 1831 | - if (is_null($eMailListContainsDeletedMessages) || empty($eMailListContainsDeletedMessages[$this->profileID]) || empty($eMailListContainsDeletedMessages[$this->profileID][$_folderName])) $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 2136 | + if (self::$debugTimes) |
|
| 2137 | + { |
|
| 2138 | + $starttime = microtime(true); |
|
| 2139 | + } |
|
| 2140 | + if (is_null($eMailListContainsDeletedMessages) || empty($eMailListContainsDeletedMessages[$this->profileID]) || empty($eMailListContainsDeletedMessages[$this->profileID][$_folderName])) |
|
| 2141 | + { |
|
| 2142 | + $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 2143 | + } |
|
| 1832 | 2144 | $five=true; |
| 1833 | 2145 | $dReverse=1; |
| 1834 | 2146 | $deletedMessages = $this->getSortedList($_folderName, 0, $dReverse, array('status'=>array('DELETED')),$five,false); |
| 1835 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') Found DeletedMessages:'.array2string($eMailListContainsDeletedMessages)); |
|
| 1836 | - $eMailListContainsDeletedMessages[$this->profileID][$_folderName] =$deletedMessages['count']; |
|
| 1837 | - Cache::setCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),$eMailListContainsDeletedMessages, 60*60*1); |
|
| 1838 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'setting eMailListContainsDeletedMessages for Profile:'.$this->profileID.' Folder:'.$_folderName.' to '.$eMailListContainsDeletedMessages[$this->profileID][$_folderName],__METHOD__.' ('.__LINE__.') '); //error_log(__METHOD__.' ('.__LINE__.') '.' Profile:'.$this->profileID.' Folder:'.$_folderName.' -> EXISTS/SessStat:'.array2string($folderStatus['MESSAGES']).'/'.self::$folderStatusCache[$this->profileID][$_folderName]['messages'].' ListContDelMsg/SessDeleted:'.$eMailListContainsDeletedMessages[$this->profileID][$_folderName].'/'.self::$folderStatusCache[$this->profileID][$_folderName]['deleted']); |
|
| 2147 | + if (self::$debug) |
|
| 2148 | + { |
|
| 2149 | + error_log(__METHOD__.' ('.__LINE__.') Found DeletedMessages:'.array2string($eMailListContainsDeletedMessages)); |
|
| 2150 | + } |
|
| 2151 | + $eMailListContainsDeletedMessages[$this->profileID][$_folderName] =$deletedMessages['count']; |
|
| 2152 | + Cache::setCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),$eMailListContainsDeletedMessages, 60*60*1); |
|
| 2153 | + if (self::$debugTimes) |
|
| 2154 | + { |
|
| 2155 | + self::logRunTimes($starttime,null,'setting eMailListContainsDeletedMessages for Profile:'.$this->profileID.' Folder:'.$_folderName.' to '.$eMailListContainsDeletedMessages[$this->profileID][$_folderName],__METHOD__.' ('.__LINE__.') '); |
|
| 2156 | + } |
|
| 2157 | + //error_log(__METHOD__.' ('.__LINE__.') '.' Profile:'.$this->profileID.' Folder:'.$_folderName.' -> EXISTS/SessStat:'.array2string($folderStatus['MESSAGES']).'/'.self::$folderStatusCache[$this->profileID][$_folderName]['messages'].' ListContDelMsg/SessDeleted:'.$eMailListContainsDeletedMessages[$this->profileID][$_folderName].'/'.self::$folderStatusCache[$this->profileID][$_folderName]['deleted']); |
|
| 1839 | 2158 | } |
| 1840 | 2159 | $try2useCache = false; |
| 1841 | 2160 | //self::$supportsORinQuery[$this->profileID]=true; |
| 1842 | 2161 | if (is_null(self::$supportsORinQuery) || !isset(self::$supportsORinQuery[$this->profileID])) |
| 1843 | 2162 | { |
| 1844 | 2163 | self::$supportsORinQuery = Cache::getCache(Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*10); |
| 1845 | - if (!isset(self::$supportsORinQuery[$this->profileID])) self::$supportsORinQuery[$this->profileID]=true; |
|
| 2164 | + if (!isset(self::$supportsORinQuery[$this->profileID])) |
|
| 2165 | + { |
|
| 2166 | + self::$supportsORinQuery[$this->profileID]=true; |
|
| 2167 | + } |
|
| 1846 | 2168 | } |
| 1847 | 2169 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_filter).' SupportsOrInQuery:'.self::$supportsORinQuery[$this->profileID]); |
| 1848 | 2170 | $filter = $this->createIMAPFilter($_folderName, $_filter,self::$supportsORinQuery[$this->profileID]); |
@@ -1853,15 +2175,26 @@ discard block |
||
| 1853 | 2175 | } |
| 1854 | 2176 | //_debug_array($filter); |
| 1855 | 2177 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($filter).'#'.array2string($this->icServer->capability())); |
| 1856 | - if($this->icServer->hasCapability('SORT')) { |
|
| 2178 | + if($this->icServer->hasCapability('SORT')) |
|
| 2179 | + { |
|
| 1857 | 2180 | // when using an orQuery and we sort by date. sort seems to fail on certain servers => ZIMBRA with Horde_Imap_Client |
| 1858 | 2181 | // thus we translate the search request from date to Horde_Imap_Client::SORT_SEQUENCE (which should be the same, if |
| 1859 | 2182 | // there is no messing with the dates) |
| 1860 | 2183 | //if (self::$supportsORinQuery[$this->profileID]&&$_sort=='date'&&$_filter['type']=='quick'&&!empty($_filter['string']))$_sort='INTERNALDATE'; |
| 1861 | - if (self::$debug) error_log(__METHOD__." Mailserver has SORT Capability, SortBy: ".array2string($_sort)." Reverse: $_reverse"); |
|
| 2184 | + if (self::$debug) |
|
| 2185 | + { |
|
| 2186 | + error_log(__METHOD__." Mailserver has SORT Capability, SortBy: ".array2string($_sort)." Reverse: $_reverse"); |
|
| 2187 | + } |
|
| 1862 | 2188 | $sortOrder = $this->_getSortString($_sort, $_reverse); |
| 1863 | - if ($_reverse && in_array(Horde_Imap_Client::SORT_REVERSE,$sortOrder)) $_reverse=false; // as we reversed the result already |
|
| 1864 | - if (self::$debug) error_log(__METHOD__." Mailserver runs SORT: SortBy:".array2string($_sort)."->".array2string($sortOrder)." Filter: ".array2string($filter)); |
|
| 2189 | + if ($_reverse && in_array(Horde_Imap_Client::SORT_REVERSE,$sortOrder)) |
|
| 2190 | + { |
|
| 2191 | + $_reverse=false; |
|
| 2192 | + } |
|
| 2193 | + // as we reversed the result already |
|
| 2194 | + if (self::$debug) |
|
| 2195 | + { |
|
| 2196 | + error_log(__METHOD__." Mailserver runs SORT: SortBy:".array2string($_sort)."->".array2string($sortOrder)." Filter: ".array2string($filter)); |
|
| 2197 | + } |
|
| 1865 | 2198 | try |
| 1866 | 2199 | { |
| 1867 | 2200 | $sortResult = $this->icServer->search($_folderName, $filter, array( |
@@ -1873,7 +2206,10 @@ discard block |
||
| 1873 | 2206 | //error_log(__METHOD__.'('.__LINE__.'):'.$e->getMessage()); |
| 1874 | 2207 | $resultByUid = false; |
| 1875 | 2208 | $sortOrder = array(Horde_Imap_Client::SORT_SEQUENCE); |
| 1876 | - if ($_reverse) array_unshift($sortOrder,Horde_Imap_Client::SORT_REVERSE); |
|
| 2209 | + if ($_reverse) |
|
| 2210 | + { |
|
| 2211 | + array_unshift($sortOrder,Horde_Imap_Client::SORT_REVERSE); |
|
| 2212 | + } |
|
| 1877 | 2213 | try |
| 1878 | 2214 | { |
| 1879 | 2215 | $sortResult = $this->icServer->search($_folderName, $filter, array( |
@@ -1885,9 +2221,17 @@ discard block |
||
| 1885 | 2221 | $sortResult = self::$folderStatusCache[$this->profileID][$_folderName]['sortResult']; |
| 1886 | 2222 | } |
| 1887 | 2223 | } |
| 1888 | - if (self::$debug) error_log(__METHOD__.print_r($sortResult,true)); |
|
| 1889 | - } else { |
|
| 1890 | - if (self::$debug) error_log(__METHOD__." Mailserver has NO SORT Capability"); |
|
| 2224 | + if (self::$debug) |
|
| 2225 | + { |
|
| 2226 | + error_log(__METHOD__.print_r($sortResult,true)); |
|
| 2227 | + } |
|
| 2228 | + } |
|
| 2229 | + else |
|
| 2230 | + { |
|
| 2231 | + if (self::$debug) |
|
| 2232 | + { |
|
| 2233 | + error_log(__METHOD__." Mailserver has NO SORT Capability"); |
|
| 2234 | + } |
|
| 1891 | 2235 | //$sortOrder = array(Horde_Imap_Client::SORT_SEQUENCE); |
| 1892 | 2236 | //if ($_reverse) array_unshift($sortOrder,Horde_Imap_Client::SORT_REVERSE); |
| 1893 | 2237 | try |
@@ -1901,7 +2245,10 @@ discard block |
||
| 1901 | 2245 | // possible error OR Query. But Horde gives no detailed Info :-( |
| 1902 | 2246 | self::$supportsORinQuery[$this->profileID]=false; |
| 1903 | 2247 | Cache::setCache(Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),self::$supportsORinQuery,60*60*10); |
| 1904 | - if (self::$debug) error_log(__METHOD__.__LINE__." Mailserver seems to have NO OR Capability for Search:".$sortResult->message); |
|
| 2248 | + if (self::$debug) |
|
| 2249 | + { |
|
| 2250 | + error_log(__METHOD__.__LINE__." Mailserver seems to have NO OR Capability for Search:".$sortResult->message); |
|
| 2251 | + } |
|
| 1905 | 2252 | $filter = $this->createIMAPFilter($_folderName, $_filter, self::$supportsORinQuery[$this->profileID]); |
| 1906 | 2253 | try |
| 1907 | 2254 | { |
@@ -1912,11 +2259,15 @@ discard block |
||
| 1912 | 2259 | { |
| 1913 | 2260 | } |
| 1914 | 2261 | } |
| 1915 | - if(is_array($sortResult['match'])) { |
|
| 2262 | + if(is_array($sortResult['match'])) |
|
| 2263 | + { |
|
| 1916 | 2264 | // not sure that this is going so succeed as $sortResult['match'] is a hordeObject |
| 1917 | 2265 | sort($sortResult['match'], SORT_NUMERIC); |
| 1918 | 2266 | } |
| 1919 | - if (self::$debug) error_log(__METHOD__." using Filter:".print_r($filter,true)." ->".print_r($sortResult,true)); |
|
| 2267 | + if (self::$debug) |
|
| 2268 | + { |
|
| 2269 | + error_log(__METHOD__." using Filter:".print_r($filter,true)." ->".print_r($sortResult,true)); |
|
| 2270 | + } |
|
| 1920 | 2271 | } |
| 1921 | 2272 | if ($setSession) |
| 1922 | 2273 | { |
@@ -1945,7 +2296,8 @@ discard block |
||
| 1945 | 2296 | $_reverse=false; |
| 1946 | 2297 | if (is_numeric($_sort)) |
| 1947 | 2298 | { |
| 1948 | - switch($_sort) { |
|
| 2299 | + switch($_sort) |
|
| 2300 | + { |
|
| 1949 | 2301 | case 2: |
| 1950 | 2302 | $retValue = array(Horde_Imap_Client::SORT_FROM); |
| 1951 | 2303 | break; |
@@ -1967,7 +2319,8 @@ discard block |
||
| 1967 | 2319 | } |
| 1968 | 2320 | else |
| 1969 | 2321 | { |
| 1970 | - switch(strtoupper($_sort)) { |
|
| 2322 | + switch(strtoupper($_sort)) |
|
| 2323 | + { |
|
| 1971 | 2324 | case 'FROMADDRESS': |
| 1972 | 2325 | $retValue = array(Horde_Imap_Client::SORT_FROM); |
| 1973 | 2326 | break; |
@@ -1993,7 +2346,10 @@ discard block |
||
| 1993 | 2346 | break; |
| 1994 | 2347 | } |
| 1995 | 2348 | } |
| 1996 | - if ($_reverse) array_unshift($retValue,Horde_Imap_Client::SORT_REVERSE); |
|
| 2349 | + if ($_reverse) |
|
| 2350 | + { |
|
| 2351 | + array_unshift($retValue,Horde_Imap_Client::SORT_REVERSE); |
|
| 2352 | + } |
|
| 1997 | 2353 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.($_reverse?'REVERSE ':'').$_sort.'->'.$retValue); |
| 1998 | 2354 | return $retValue; |
| 1999 | 2355 | } |
@@ -2012,7 +2368,10 @@ discard block |
||
| 2012 | 2368 | $imapFilter->charset('UTF-8'); |
| 2013 | 2369 | |
| 2014 | 2370 | //_debug_array($_criterias); |
| 2015 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' Criterias:'.(!is_array($_criterias)?" none -> returning":array2string($_criterias))); |
|
| 2371 | + if (self::$debug) |
|
| 2372 | + { |
|
| 2373 | + error_log(__METHOD__.' ('.__LINE__.') '.' Criterias:'.(!is_array($_criterias)?" none -> returning":array2string($_criterias))); |
|
| 2374 | + } |
|
| 2016 | 2375 | if((!is_array($_criterias) || $_criterias['status']=='any') && |
| 2017 | 2376 | (!isset($_criterias['string']) || empty($_criterias['string'])) && |
| 2018 | 2377 | (!isset($_criterias['range'])|| empty($_criterias['range']) || |
@@ -2027,11 +2386,13 @@ discard block |
||
| 2027 | 2386 | // statusQuery MUST be placed first, as search for subject/mailbody and such is |
| 2028 | 2387 | // depending on charset. flagSearch is not BUT messes the charset if called afterwards |
| 2029 | 2388 | $statusQueryValid = false; |
| 2030 | - foreach((array)$_criterias['status'] as $k => $criteria) { |
|
| 2389 | + foreach((array)$_criterias['status'] as $k => $criteria) |
|
| 2390 | + { |
|
| 2031 | 2391 | $imapStatusFilter = new Horde_Imap_Client_Search_Query(); |
| 2032 | 2392 | $imapStatusFilter->charset('UTF-8'); |
| 2033 | 2393 | $criteria = strtoupper($criteria); |
| 2034 | - switch ($criteria) { |
|
| 2394 | + switch ($criteria) |
|
| 2395 | + { |
|
| 2035 | 2396 | case 'ANSWERED': |
| 2036 | 2397 | case 'DELETED': |
| 2037 | 2398 | case 'FLAGGED': |
@@ -2114,9 +2475,11 @@ discard block |
||
| 2114 | 2475 | $imapSearchFilter = new Horde_Imap_Client_Search_Query(); |
| 2115 | 2476 | $imapSearchFilter->charset('UTF-8'); |
| 2116 | 2477 | |
| 2117 | - if(!empty($_criterias['string'])) { |
|
| 2478 | + if(!empty($_criterias['string'])) |
|
| 2479 | + { |
|
| 2118 | 2480 | $criteria = strtoupper($_criterias['type']); |
| 2119 | - switch ($criteria) { |
|
| 2481 | + switch ($criteria) |
|
| 2482 | + { |
|
| 2120 | 2483 | case 'BYDATE': |
| 2121 | 2484 | case 'QUICK': |
| 2122 | 2485 | case 'QUICKWITHCC': |
@@ -2124,9 +2487,12 @@ discard block |
||
| 2124 | 2487 | //$imapSearchFilter->charset('UTF-8'); |
| 2125 | 2488 | $imapFilter2 = new Horde_Imap_Client_Search_Query(); |
| 2126 | 2489 | $imapFilter2->charset('UTF-8'); |
| 2127 | - if($this->isSentFolder($_folder)) { |
|
| 2490 | + if($this->isSentFolder($_folder)) |
|
| 2491 | + { |
|
| 2128 | 2492 | $imapFilter2->headerText('TO', $_criterias['string'], $not=false); |
| 2129 | - } else { |
|
| 2493 | + } |
|
| 2494 | + else |
|
| 2495 | + { |
|
| 2130 | 2496 | $imapFilter2->headerText('FROM', $_criterias['string'], $not=false); |
| 2131 | 2497 | } |
| 2132 | 2498 | if ($_supportsOrInQuery) |
@@ -2157,7 +2523,10 @@ discard block |
||
| 2157 | 2523 | 'GB'=>1024*1000*1000,'G'=>1024*1000*1000, |
| 2158 | 2524 | 'TB'=>1024*1000*1000*1000,'T'=>1024*1000*1000*1000); |
| 2159 | 2525 | $numberinBytes=(float)$_criterias['string']; |
| 2160 | - if (isset($multipleBy[$unit])) $numberinBytes=(float)$_criterias['string']*$multipleBy[$unit]; |
|
| 2526 | + if (isset($multipleBy[$unit])) |
|
| 2527 | + { |
|
| 2528 | + $numberinBytes=(float)$_criterias['string']*$multipleBy[$unit]; |
|
| 2529 | + } |
|
| 2161 | 2530 | //error_log(__METHOD__.__LINE__.'#'.$_criterias['string'].'->'.(float)$_criterias['string'].'#'.$unit.' ='.$numberinBytes); |
| 2162 | 2531 | $_criterias['string']=$numberinBytes; |
| 2163 | 2532 | } |
@@ -2194,8 +2563,14 @@ discard block |
||
| 2194 | 2563 | break; |
| 2195 | 2564 | } |
| 2196 | 2565 | } |
| 2197 | - if ($statusQueryValid && !$queryValid) $queryValid=true; |
|
| 2198 | - if ($queryValid) $imapFilter->andSearch($imapSearchFilter); |
|
| 2566 | + if ($statusQueryValid && !$queryValid) |
|
| 2567 | + { |
|
| 2568 | + $queryValid=true; |
|
| 2569 | + } |
|
| 2570 | + if ($queryValid) |
|
| 2571 | + { |
|
| 2572 | + $imapFilter->andSearch($imapSearchFilter); |
|
| 2573 | + } |
|
| 2199 | 2574 | |
| 2200 | 2575 | if (isset($_criterias['range']) && !empty($_criterias['range'])) |
| 2201 | 2576 | { |
@@ -2210,7 +2585,8 @@ discard block |
||
| 2210 | 2585 | unset($_criterias['before']); |
| 2211 | 2586 | $criteria=$_criterias['range']='ON'; |
| 2212 | 2587 | } |
| 2213 | - switch ($criteria) { |
|
| 2588 | + switch ($criteria) |
|
| 2589 | + { |
|
| 2214 | 2590 | case 'BETWEEN': |
| 2215 | 2591 | //try to be smart about missing |
| 2216 | 2592 | //enddate |
@@ -2246,8 +2622,14 @@ discard block |
||
| 2246 | 2622 | $rangeValid = true; |
| 2247 | 2623 | break; |
| 2248 | 2624 | } |
| 2249 | - if ($rangeValid && !$queryValid) $queryValid=true; |
|
| 2250 | - if ($rangeValid) $imapFilter->andSearch($imapRangeFilter); |
|
| 2625 | + if ($rangeValid && !$queryValid) |
|
| 2626 | + { |
|
| 2627 | + $queryValid=true; |
|
| 2628 | + } |
|
| 2629 | + if ($rangeValid) |
|
| 2630 | + { |
|
| 2631 | + $imapFilter->andSearch($imapRangeFilter); |
|
| 2632 | + } |
|
| 2251 | 2633 | } |
| 2252 | 2634 | if (self::$debug) |
| 2253 | 2635 | { |
@@ -2255,10 +2637,13 @@ discard block |
||
| 2255 | 2637 | $query_str = $imapFilter->build(); |
| 2256 | 2638 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$query_str['query'].' created by Criterias:'.(!is_array($_criterias)?" none -> returning":array2string($_criterias))); |
| 2257 | 2639 | } |
| 2258 | - if($queryValid==false) { |
|
| 2640 | + if($queryValid==false) |
|
| 2641 | + { |
|
| 2259 | 2642 | $imapFilter->flag('DELETED', $set=false); |
| 2260 | 2643 | return $imapFilter; |
| 2261 | - } else { |
|
| 2644 | + } |
|
| 2645 | + else |
|
| 2646 | + { |
|
| 2262 | 2647 | return $imapFilter; |
| 2263 | 2648 | } |
| 2264 | 2649 | } |
@@ -2315,7 +2700,10 @@ discard block |
||
| 2315 | 2700 | } |
| 2316 | 2701 | $stringA[] = imap_rfc822_write_address($_rfcAddr->mailbox,Horde_Idna::decode($_rfcAddr->host),$_rfcAddr->personal); |
| 2317 | 2702 | } |
| 2318 | - if (!empty($stringA)) $_string = implode(',',$stringA); |
|
| 2703 | + if (!empty($stringA)) |
|
| 2704 | + { |
|
| 2705 | + $_string = implode(',',$stringA); |
|
| 2706 | + } |
|
| 2319 | 2707 | } |
| 2320 | 2708 | if ($_tryIDNConversion==='FORCE') |
| 2321 | 2709 | { |
@@ -2340,7 +2728,10 @@ discard block |
||
| 2340 | 2728 | { |
| 2341 | 2729 | return 'No Subject'; |
| 2342 | 2730 | } |
| 2343 | - if ($decode) $_string = self::decode_header($_string); |
|
| 2731 | + if ($decode) |
|
| 2732 | + { |
|
| 2733 | + $_string = self::decode_header($_string); |
|
| 2734 | + } |
|
| 2344 | 2735 | // make sure its utf-8 |
| 2345 | 2736 | $test = @json_encode($_string); |
| 2346 | 2737 | if (($test=="null" || $test === false || is_null($test)) && strlen($_string)>0) |
@@ -2378,7 +2769,8 @@ discard block |
||
| 2378 | 2769 | * @param string _parent the parent foldername |
| 2379 | 2770 | * @return ISO-8859-1 / UTF7-IMAP encoded string |
| 2380 | 2771 | */ |
| 2381 | - function _encodeFolderName($_folderName) { |
|
| 2772 | + function _encodeFolderName($_folderName) |
|
| 2773 | + { |
|
| 2382 | 2774 | return Translation::convert($_folderName, self::$displayCharset, 'ISO-8859-1'); |
| 2383 | 2775 | #return Translation::convert($_folderName, self::$displayCharset, 'UTF7-IMAP'); |
| 2384 | 2776 | } |
@@ -2394,21 +2786,36 @@ discard block |
||
| 2394 | 2786 | */ |
| 2395 | 2787 | function createFolder($_parent, $_folderName, &$_error) |
| 2396 | 2788 | { |
| 2397 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."->"."$_parent, $_folderName called from:".function_backtrace()); |
|
| 2789 | + if (self::$debug) |
|
| 2790 | + { |
|
| 2791 | + error_log(__METHOD__.' ('.__LINE__.') '."->"."$_parent, $_folderName called from:".function_backtrace()); |
|
| 2792 | + } |
|
| 2398 | 2793 | $parent = $_parent;//$this->_encodeFolderName($_parent); |
| 2399 | 2794 | $folderName = $_folderName;//$this->_encodeFolderName($_folderName); |
| 2400 | 2795 | |
| 2401 | - if(empty($parent)) { |
|
| 2796 | + if(empty($parent)) |
|
| 2797 | + { |
|
| 2402 | 2798 | $newFolderName = $folderName; |
| 2403 | - } else { |
|
| 2799 | + } |
|
| 2800 | + else |
|
| 2801 | + { |
|
| 2404 | 2802 | $HierarchyDelimiter = $this->getHierarchyDelimiter(); |
| 2405 | 2803 | $newFolderName = $parent . $HierarchyDelimiter . $folderName; |
| 2406 | 2804 | } |
| 2407 | - if (empty($newFolderName)) return false; |
|
| 2408 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.'->'.$newFolderName); |
|
| 2805 | + if (empty($newFolderName)) |
|
| 2806 | + { |
|
| 2807 | + return false; |
|
| 2808 | + } |
|
| 2809 | + if (self::$debug) |
|
| 2810 | + { |
|
| 2811 | + error_log(__METHOD__.' ('.__LINE__.') '.'->'.$newFolderName); |
|
| 2812 | + } |
|
| 2409 | 2813 | if ($this->folderExists($newFolderName,true)) |
| 2410 | 2814 | { |
| 2411 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '." Folder $newFolderName already exists."); |
|
| 2815 | + if (self::$debug) |
|
| 2816 | + { |
|
| 2817 | + error_log(__METHOD__.' ('.__LINE__.') '." Folder $newFolderName already exists."); |
|
| 2818 | + } |
|
| 2412 | 2819 | return $newFolderName; |
| 2413 | 2820 | } |
| 2414 | 2821 | try |
@@ -2456,13 +2863,19 @@ discard block |
||
| 2456 | 2863 | $parent = $_parent;//$this->_encodeFolderName($_parent); |
| 2457 | 2864 | $folderName = $_folderName;//$this->_encodeFolderName($_folderName); |
| 2458 | 2865 | |
| 2459 | - if(empty($parent)) { |
|
| 2866 | + if(empty($parent)) |
|
| 2867 | + { |
|
| 2460 | 2868 | $newFolderName = $folderName; |
| 2461 | - } else { |
|
| 2869 | + } |
|
| 2870 | + else |
|
| 2871 | + { |
|
| 2462 | 2872 | $HierarchyDelimiter = $this->getHierarchyDelimiter(); |
| 2463 | 2873 | $newFolderName = $parent . $HierarchyDelimiter . $folderName; |
| 2464 | 2874 | } |
| 2465 | - if (self::$debug) error_log("create folder: $newFolderName"); |
|
| 2875 | + if (self::$debug) |
|
| 2876 | + { |
|
| 2877 | + error_log("create folder: $newFolderName"); |
|
| 2878 | + } |
|
| 2466 | 2879 | try |
| 2467 | 2880 | { |
| 2468 | 2881 | $this->icServer->renameMailbox($oldFolderName, $newFolderName); |
@@ -2536,8 +2949,14 @@ discard block |
||
| 2536 | 2949 | */ |
| 2537 | 2950 | function getFolderObjects($_subscribedOnly=false, $_getCounters=false, $_alwaysGetDefaultFolders=false,$_useCacheIfPossible=true) |
| 2538 | 2951 | { |
| 2539 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' ServerID:'.$this->icServer->ImapServerId.", subscribedOnly:$_subscribedOnly, getCounters:$_getCounters, alwaysGetDefaultFolders:$_alwaysGetDefaultFolders, _useCacheIfPossible:$_useCacheIfPossible"); |
|
| 2540 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 2952 | + if (self::$debug) |
|
| 2953 | + { |
|
| 2954 | + error_log(__METHOD__.' ('.__LINE__.') '.' ServerID:'.$this->icServer->ImapServerId.", subscribedOnly:$_subscribedOnly, getCounters:$_getCounters, alwaysGetDefaultFolders:$_alwaysGetDefaultFolders, _useCacheIfPossible:$_useCacheIfPossible"); |
|
| 2955 | + } |
|
| 2956 | + if (self::$debugTimes) |
|
| 2957 | + { |
|
| 2958 | + $starttime = microtime (true); |
|
| 2959 | + } |
|
| 2541 | 2960 | static $folders2return; |
| 2542 | 2961 | //$_subscribedOnly=false; |
| 2543 | 2962 | // always use static on single request if info is available; |
@@ -2545,23 +2964,35 @@ discard block |
||
| 2545 | 2964 | // set $_useCacheIfPossible to false ! |
| 2546 | 2965 | if ($_useCacheIfPossible && isset($folders2return[$this->icServer->ImapServerId]) && !empty($folders2return[$this->icServer->ImapServerId])) |
| 2547 | 2966 | { |
| 2548 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'using static',__METHOD__.' ('.__LINE__.') '); |
|
| 2967 | + if (self::$debugTimes) |
|
| 2968 | + { |
|
| 2969 | + self::logRunTimes($starttime,null,'using static',__METHOD__.' ('.__LINE__.') '); |
|
| 2970 | + } |
|
| 2549 | 2971 | return $folders2return[$this->icServer->ImapServerId]; |
| 2550 | 2972 | } |
| 2551 | 2973 | |
| 2552 | 2974 | if ($_subscribedOnly && $_getCounters===false) |
| 2553 | 2975 | { |
| 2554 | - if (is_null($folders2return)) $folders2return = Cache::getCache(Cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 2976 | + if (is_null($folders2return)) |
|
| 2977 | + { |
|
| 2978 | + $folders2return = Cache::getCache(Cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 2979 | + } |
|
| 2555 | 2980 | if ($_useCacheIfPossible && isset($folders2return[$this->icServer->ImapServerId]) && !empty($folders2return[$this->icServer->ImapServerId])) |
| 2556 | 2981 | { |
| 2557 | 2982 | //error_log(__METHOD__.' ('.__LINE__.') '.' using Cached folderObjects'.array2string($folders2return[$this->icServer->ImapServerId])); |
| 2558 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'from Cache',__METHOD__.' ('.__LINE__.') '); |
|
| 2983 | + if (self::$debugTimes) |
|
| 2984 | + { |
|
| 2985 | + self::logRunTimes($starttime,null,'from Cache',__METHOD__.' ('.__LINE__.') '); |
|
| 2986 | + } |
|
| 2559 | 2987 | return $folders2return[$this->icServer->ImapServerId]; |
| 2560 | 2988 | } |
| 2561 | 2989 | } |
| 2562 | 2990 | // use $folderBasicInfo for holding attributes and other basic folderinfo $folderBasicInfo[$this->icServer->ImapServerId] |
| 2563 | 2991 | static $folderBasicInfo; |
| 2564 | - if (is_null($folderBasicInfo)||!isset($folderBasicInfo[$this->icServer->ImapServerId])) $folderBasicInfo = Cache::getCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 2992 | + if (is_null($folderBasicInfo)||!isset($folderBasicInfo[$this->icServer->ImapServerId])) |
|
| 2993 | + { |
|
| 2994 | + $folderBasicInfo = Cache::getCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 2995 | + } |
|
| 2565 | 2996 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string(array_keys($folderBasicInfo[$this->icServer->ImapServerId]))); |
| 2566 | 2997 | |
| 2567 | 2998 | $delimiter = $this->getHierarchyDelimiter(); |
@@ -2574,7 +3005,8 @@ discard block |
||
| 2574 | 3005 | $inboxData->shortFolderName = 'INBOX'; |
| 2575 | 3006 | $inboxData->shortDisplayName = lang('INBOX'); |
| 2576 | 3007 | $inboxData->subscribed = true; |
| 2577 | - if($_getCounters == true) { |
|
| 3008 | + if($_getCounters == true) |
|
| 3009 | + { |
|
| 2578 | 3010 | $inboxData->counter = $this->getMailBoxCounters('INBOX'); |
| 2579 | 3011 | } |
| 2580 | 3012 | // force unsubscribed by preference showAllFoldersInFolderPane |
@@ -2593,12 +3025,14 @@ discard block |
||
| 2593 | 3025 | //error_log(__METHOD__.__LINE__.array2string($nameSpace)); |
| 2594 | 3026 | if (is_array($nameSpace)) |
| 2595 | 3027 | { |
| 2596 | - foreach($nameSpace as $k => $singleNameSpace) { |
|
| 3028 | + foreach($nameSpace as $k => $singleNameSpace) |
|
| 3029 | + { |
|
| 2597 | 3030 | $type = $singleNameSpace['type']; |
| 2598 | 3031 | // the following line (assumption that for the same namespace the delimiter should be equal) may be wrong |
| 2599 | 3032 | $foldersNameSpace[$type]['delimiter'] = $singleNameSpace['delimiter']; |
| 2600 | 3033 | |
| 2601 | - if(is_array($singleNameSpace)&&$fetchedAllInOneGo==false) { |
|
| 3034 | + if(is_array($singleNameSpace)&&$fetchedAllInOneGo==false) |
|
| 3035 | + { |
|
| 2602 | 3036 | // fetch and sort the subscribed folders |
| 2603 | 3037 | // we alway fetch the subscribed, as this provides the only way to tell |
| 2604 | 3038 | // if a folder is subscribed or not |
@@ -2649,8 +3083,12 @@ discard block |
||
| 2649 | 3083 | } |
| 2650 | 3084 | } |
| 2651 | 3085 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$type.'->'.array2string($foldersNameSpace[$type]['subscribed'])); |
| 2652 | - if (!is_array($foldersNameSpace[$type]['all'])) $foldersNameSpace[$type]['all'] = array(); |
|
| 2653 | - if ($_subscribedOnly == true && !empty($foldersNameSpace[$type]['subscribed'])) { |
|
| 3086 | + if (!is_array($foldersNameSpace[$type]['all'])) |
|
| 3087 | + { |
|
| 3088 | + $foldersNameSpace[$type]['all'] = array(); |
|
| 3089 | + } |
|
| 3090 | + if ($_subscribedOnly == true && !empty($foldersNameSpace[$type]['subscribed'])) |
|
| 3091 | + { |
|
| 2654 | 3092 | continue; |
| 2655 | 3093 | } |
| 2656 | 3094 | |
@@ -2680,7 +3118,8 @@ discard block |
||
| 2680 | 3118 | } |
| 2681 | 3119 | |
| 2682 | 3120 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$type.'->'.array2string($allMailboxesExt)); |
| 2683 | - foreach ($allMailboxesExt as $mbx) { |
|
| 3121 | + foreach ($allMailboxesExt as $mbx) |
|
| 3122 | + { |
|
| 2684 | 3123 | if (!isset($folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']])) |
| 2685 | 3124 | { |
| 2686 | 3125 | $folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']]=array( |
@@ -2703,20 +3142,33 @@ discard block |
||
| 2703 | 3142 | if (isset($allMailBoxesExtSorted[$mbx['MAILBOX']])|| |
| 2704 | 3143 | isset($allMailBoxesExtSorted[$mbx['MAILBOX'].$foldersNameSpace[$type]['delimiter']])|| |
| 2705 | 3144 | (substr($mbx['MAILBOX'],-1)==$foldersNameSpace[$type]['delimiter'] && isset($allMailBoxesExtSorted[substr($mbx['MAILBOX'],0,-1)])) |
| 2706 | - ) continue; |
|
| 3145 | + ) |
|
| 3146 | + { |
|
| 3147 | + continue; |
|
| 3148 | + } |
|
| 2707 | 3149 | |
| 2708 | 3150 | //echo '#'.$mbx['MAILBOX'].':'.array2string($mbx)."#<br>"; |
| 2709 | 3151 | $allMailBoxesExtSorted[$mbx['MAILBOX']] = $mbx; |
| 2710 | 3152 | } |
| 2711 | - if (is_array($allMailBoxesExtSorted)) ksort($allMailBoxesExtSorted); |
|
| 3153 | + if (is_array($allMailBoxesExtSorted)) |
|
| 3154 | + { |
|
| 3155 | + ksort($allMailBoxesExtSorted); |
|
| 3156 | + } |
|
| 2712 | 3157 | //_debug_array(array_keys($allMailBoxesExtSorted)); |
| 2713 | 3158 | $allMailboxes = array(); |
| 2714 | - foreach ((array)$allMailBoxesExtSorted as $mbx) { |
|
| 2715 | - if (!in_array($mbx['MAILBOX'],$allMailboxes)) $allMailboxes[] = $mbx['MAILBOX']; |
|
| 3159 | + foreach ((array)$allMailBoxesExtSorted as $mbx) |
|
| 3160 | + { |
|
| 3161 | + if (!in_array($mbx['MAILBOX'],$allMailboxes)) |
|
| 3162 | + { |
|
| 3163 | + $allMailboxes[] = $mbx['MAILBOX']; |
|
| 3164 | + } |
|
| 2716 | 3165 | //echo "Result:";_debug_array($allMailboxes); |
| 2717 | 3166 | } |
| 2718 | 3167 | $foldersNameSpace[$type]['all'] = $allMailboxes; |
| 2719 | - if (is_array($foldersNameSpace[$type]['all'])) sort($foldersNameSpace[$type]['all']); |
|
| 3168 | + if (is_array($foldersNameSpace[$type]['all'])) |
|
| 3169 | + { |
|
| 3170 | + sort($foldersNameSpace[$type]['all']); |
|
| 3171 | + } |
|
| 2720 | 3172 | } |
| 2721 | 3173 | } |
| 2722 | 3174 | } |
@@ -2725,24 +3177,50 @@ discard block |
||
| 2725 | 3177 | //echo "<br>FolderNameSpace To Process:";_debug_array($foldersNameSpace); |
| 2726 | 3178 | $autoFolderObjects = $folders = array(); |
| 2727 | 3179 | $autofolder_exists = array(); |
| 2728 | - foreach( array('personal', 'others', 'shared') as $type) { |
|
| 2729 | - if(isset($foldersNameSpace[$type])) { |
|
| 2730 | - if($_subscribedOnly) { |
|
| 2731 | - if( !empty($foldersNameSpace[$type]['subscribed']) ) $listOfFolders = $foldersNameSpace[$type]['subscribed']; |
|
| 2732 | - } else { |
|
| 2733 | - if( !empty($foldersNameSpace[$type]['all'])) $listOfFolders = $foldersNameSpace[$type]['all']; |
|
| 2734 | - } |
|
| 2735 | - foreach((array)$listOfFolders as $folderName) { |
|
| 3180 | + foreach( array('personal', 'others', 'shared') as $type) |
|
| 3181 | + { |
|
| 3182 | + if(isset($foldersNameSpace[$type])) |
|
| 3183 | + { |
|
| 3184 | + if($_subscribedOnly) |
|
| 3185 | + { |
|
| 3186 | + if( !empty($foldersNameSpace[$type]['subscribed']) ) |
|
| 3187 | + { |
|
| 3188 | + $listOfFolders = $foldersNameSpace[$type]['subscribed']; |
|
| 3189 | + } |
|
| 3190 | + } |
|
| 3191 | + else |
|
| 3192 | + { |
|
| 3193 | + if( !empty($foldersNameSpace[$type]['all'])) |
|
| 3194 | + { |
|
| 3195 | + $listOfFolders = $foldersNameSpace[$type]['all']; |
|
| 3196 | + } |
|
| 3197 | + } |
|
| 3198 | + foreach((array)$listOfFolders as $folderName) |
|
| 3199 | + { |
|
| 2736 | 3200 | //echo "<br>FolderToCheck:$folderName<br>"; |
| 2737 | 3201 | //error_log(__METHOD__.__LINE__.'#Delimiter:'.$delimiter.':#'.$folderName); |
| 2738 | - if ($_subscribedOnly && empty($foldersNameSpace[$type]['all'])) continue;//when subscribedonly, we fetch all folders in one go. |
|
| 2739 | - if($_subscribedOnly && !(in_array($folderName, $foldersNameSpace[$type]['all'])||in_array($folderName.$foldersNameSpace[$type]['delimiter'], $foldersNameSpace[$type]['all']))) { |
|
| 3202 | + if ($_subscribedOnly && empty($foldersNameSpace[$type]['all'])) |
|
| 3203 | + { |
|
| 3204 | + continue; |
|
| 3205 | + } |
|
| 3206 | + //when subscribedonly, we fetch all folders in one go. |
|
| 3207 | + if($_subscribedOnly && !(in_array($folderName, $foldersNameSpace[$type]['all'])||in_array($folderName.$foldersNameSpace[$type]['delimiter'], $foldersNameSpace[$type]['all']))) |
|
| 3208 | + { |
|
| 2740 | 3209 | #echo "$folderName failed to be here <br>"; |
| 2741 | 3210 | continue; |
| 2742 | 3211 | } |
| 2743 | - if (isset($folders[$folderName])) continue; |
|
| 2744 | - if (isset($autoFolderObjects[$folderName])) continue; |
|
| 2745 | - if (empty($delimiter)||$delimiter != $foldersNameSpace[$type]['delimiter']) $delimiter = $foldersNameSpace[$type]['delimiter']; |
|
| 3212 | + if (isset($folders[$folderName])) |
|
| 3213 | + { |
|
| 3214 | + continue; |
|
| 3215 | + } |
|
| 3216 | + if (isset($autoFolderObjects[$folderName])) |
|
| 3217 | + { |
|
| 3218 | + continue; |
|
| 3219 | + } |
|
| 3220 | + if (empty($delimiter)||$delimiter != $foldersNameSpace[$type]['delimiter']) |
|
| 3221 | + { |
|
| 3222 | + $delimiter = $foldersNameSpace[$type]['delimiter']; |
|
| 3223 | + } |
|
| 2746 | 3224 | $folderParts = explode($delimiter, $folderName); |
| 2747 | 3225 | $shortName = array_pop($folderParts); |
| 2748 | 3226 | |
@@ -2750,17 +3228,20 @@ discard block |
||
| 2750 | 3228 | $folderObject->delimiter = $delimiter; |
| 2751 | 3229 | $folderObject->folderName = $folderName; |
| 2752 | 3230 | $folderObject->shortFolderName = $shortName; |
| 2753 | - if(!$_subscribedOnly) { |
|
| 3231 | + if(!$_subscribedOnly) |
|
| 3232 | + { |
|
| 2754 | 3233 | #echo $folderName."->".$type."<br>"; |
| 2755 | 3234 | #_debug_array($foldersNameSpace[$type]['subscribed']); |
| 2756 | 3235 | $folderObject->subscribed = in_array($folderName, (array)$foldersNameSpace[$type]['subscribed']); |
| 2757 | 3236 | } |
| 2758 | 3237 | |
| 2759 | - if($_getCounters == true) { |
|
| 3238 | + if($_getCounters == true) |
|
| 3239 | + { |
|
| 2760 | 3240 | //error_log(__METHOD__.' ('.__LINE__.') '.' getCounter forFolder:'.$folderName); |
| 2761 | 3241 | $folderObject->counter = $this->getMailBoxCounters($folderName); |
| 2762 | 3242 | } |
| 2763 | - if(strtoupper($folderName) == 'INBOX') { |
|
| 3243 | + if(strtoupper($folderName) == 'INBOX') |
|
| 3244 | + { |
|
| 2764 | 3245 | $folderName = 'INBOX'; |
| 2765 | 3246 | $folderObject->folderName = 'INBOX'; |
| 2766 | 3247 | $folderObject->shortFolderName = 'INBOX'; |
@@ -2768,24 +3249,34 @@ discard block |
||
| 2768 | 3249 | $folderObject->shortDisplayName = lang('INBOX'); |
| 2769 | 3250 | $folderObject->subscribed = true; |
| 2770 | 3251 | // translate the automatic Folders (Sent, Drafts, ...) like the INBOX |
| 2771 | - } elseif (in_array($shortName,self::$autoFolders)) { |
|
| 3252 | + } |
|
| 3253 | + elseif (in_array($shortName,self::$autoFolders)) |
|
| 3254 | + { |
|
| 2772 | 3255 | $tmpfolderparts = explode($delimiter,$folderObject->folderName); |
| 2773 | 3256 | array_pop($tmpfolderparts); |
| 2774 | 3257 | $folderObject->displayName = implode($delimiter,$tmpfolderparts).$delimiter.lang($shortName); |
| 2775 | 3258 | $folderObject->shortDisplayName = lang($shortName); |
| 2776 | 3259 | unset($tmpfolderparts); |
| 2777 | - } else { |
|
| 3260 | + } |
|
| 3261 | + else |
|
| 3262 | + { |
|
| 2778 | 3263 | $folderObject->displayName = $folderObject->folderName; |
| 2779 | 3264 | $folderObject->shortDisplayName = $shortName; |
| 2780 | 3265 | } |
| 2781 | 3266 | //$folderName = $folderName; |
| 2782 | - if (in_array($shortName,self::$autoFolders)&&self::searchValueInFolderObjects($shortName,$autoFolderObjects)===false) { |
|
| 3267 | + if (in_array($shortName,self::$autoFolders)&&self::searchValueInFolderObjects($shortName,$autoFolderObjects)===false) |
|
| 3268 | + { |
|
| 2783 | 3269 | $autoFolderObjects[$folderName] = $folderObject; |
| 2784 | - } else { |
|
| 3270 | + } |
|
| 3271 | + else |
|
| 3272 | + { |
|
| 2785 | 3273 | $folders[$folderName] = $folderObject; |
| 2786 | 3274 | } |
| 2787 | 3275 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$folderObject->folderName); |
| 2788 | - if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders (); |
|
| 3276 | + if (!isset(self::$specialUseFolders)) |
|
| 3277 | + { |
|
| 3278 | + $this->getSpecialUseFolders (); |
|
| 3279 | + } |
|
| 2789 | 3280 | if (isset(self::$specialUseFolders[$folderName])) |
| 2790 | 3281 | { |
| 2791 | 3282 | $autofolder_exists[$folderName] = self::$specialUseFolders[$folderName]; |
@@ -2793,7 +3284,8 @@ discard block |
||
| 2793 | 3284 | } |
| 2794 | 3285 | } |
| 2795 | 3286 | } |
| 2796 | - if (is_array($autoFolderObjects) && !empty($autoFolderObjects)) { |
|
| 3287 | + if (is_array($autoFolderObjects) && !empty($autoFolderObjects)) |
|
| 3288 | + { |
|
| 2797 | 3289 | uasort($autoFolderObjects,array($this,"sortByAutoFolderPos")); |
| 2798 | 3290 | } |
| 2799 | 3291 | // check if some standard folders are missing and need to be created |
@@ -2802,7 +3294,10 @@ discard block |
||
| 2802 | 3294 | // if new folders have been created, re-read folders ignoring the cache |
| 2803 | 3295 | return $this->getFolderObjects($_subscribedOnly, $_getCounters, $_alwaysGetDefaultFolders, false); // false = do NOT use cache |
| 2804 | 3296 | } |
| 2805 | - if (is_array($folders)) uasort($folders,array($this,"sortByDisplayName")); |
|
| 3297 | + if (is_array($folders)) |
|
| 3298 | + { |
|
| 3299 | + uasort($folders,array($this,"sortByDisplayName")); |
|
| 3300 | + } |
|
| 2806 | 3301 | //$folders2return = array_merge($autoFolderObjects,$folders); |
| 2807 | 3302 | //_debug_array($folders2return); #exit; |
| 2808 | 3303 | $folders2return[$this->icServer->ImapServerId] = array_merge((array)$inboxFolderObject,(array)$autoFolderObjects,(array)$folders); |
@@ -2814,7 +3309,10 @@ discard block |
||
| 2814 | 3309 | Cache::setCache(Cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),$folders2return,$expiration=60*60*1); |
| 2815 | 3310 | } |
| 2816 | 3311 | Cache::setCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderBasicInfo,$expiration=60*60*1); |
| 2817 | - if (self::$debugTimes) self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') '); |
|
| 3312 | + if (self::$debugTimes) |
|
| 3313 | + { |
|
| 3314 | + self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') '); |
|
| 3315 | + } |
|
| 2818 | 3316 | return $folders2return[$this->icServer->ImapServerId]; |
| 2819 | 3317 | } |
| 2820 | 3318 | |
@@ -2842,31 +3340,44 @@ discard block |
||
| 2842 | 3340 | |
| 2843 | 3341 | $folders = $nameSpace = array(); |
| 2844 | 3342 | $nameSpaceTmp = $this->_getNameSpaces(); |
| 2845 | - foreach($nameSpaceTmp as $k => $singleNameSpace) { |
|
| 3343 | + foreach($nameSpaceTmp as $k => $singleNameSpace) |
|
| 3344 | + { |
|
| 2846 | 3345 | $nameSpace[$singleNameSpace['type']]=$singleNameSpace; |
| 2847 | 3346 | } |
| 2848 | 3347 | unset($nameSpaceTmp); |
| 2849 | 3348 | |
| 2850 | 3349 | //error_log(__METHOD__.__LINE__.array2string($nameSpace)); |
| 2851 | 3350 | // Get special use folders |
| 2852 | - if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders (); // Set self::$specialUseFolders |
|
| 3351 | + if (!isset(self::$specialUseFolders)) |
|
| 3352 | + { |
|
| 3353 | + $this->getSpecialUseFolders (); |
|
| 3354 | + } |
|
| 3355 | + // Set self::$specialUseFolders |
|
| 2853 | 3356 | // topLevelQueries generally ignore the $_search param. Except for Config::examineNamespace |
| 2854 | - if ($_onlyTopLevel) // top level leaves |
|
| 3357 | + if ($_onlyTopLevel) |
|
| 3358 | + { |
|
| 3359 | + // top level leaves |
|
| 2855 | 3360 | { |
| 2856 | 3361 | // Get top mailboxes of icServer |
| 2857 | 3362 | $topFolders = $this->icServer->getMailboxes("", 2, true); |
| 3363 | + } |
|
| 2858 | 3364 | // Trigger examination of namespace to retrieve |
| 2859 | 3365 | // folders located in other and shared; needed only for some servers |
| 2860 | - if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail'); |
|
| 3366 | + if (is_null(self::$mailConfig)) |
|
| 3367 | + { |
|
| 3368 | + self::$mailConfig = Config::read('mail'); |
|
| 3369 | + } |
|
| 2861 | 3370 | if (self::$mailConfig['examineNamespace']) |
| 2862 | 3371 | { |
| 2863 | 3372 | $prefixes=array(); |
| 2864 | 3373 | if (is_array($nameSpace)) |
| 2865 | 3374 | { |
| 2866 | - foreach($nameSpace as $k => $singleNameSpace) { |
|
| 3375 | + foreach($nameSpace as $k => $singleNameSpace) |
|
| 3376 | + { |
|
| 2867 | 3377 | $type = $singleNameSpace['type']; |
| 2868 | 3378 | |
| 2869 | - if(is_array($singleNameSpace) && $singleNameSpace['prefix']){ |
|
| 3379 | + if(is_array($singleNameSpace) && $singleNameSpace['prefix']) |
|
| 3380 | + { |
|
| 2870 | 3381 | $prefixes[$type] = $singleNameSpace['prefix']; |
| 2871 | 3382 | //regard extra care for nameSpacequeries when configured AND respect $_search |
| 2872 | 3383 | $result = $this->icServer->getMailboxes($singleNameSpace['prefix'], $_search==0?0:2, true); |
@@ -2942,7 +3453,10 @@ discard block |
||
| 2942 | 3453 | $nFolders [$path] = $folder; |
| 2943 | 3454 | } |
| 2944 | 3455 | } |
| 2945 | - if (is_array($aFolders)) uasort ($aFolders, array($this,'sortByAutofolder')); |
|
| 3456 | + if (is_array($aFolders)) |
|
| 3457 | + { |
|
| 3458 | + uasort ($aFolders, array($this,'sortByAutofolder')); |
|
| 3459 | + } |
|
| 2946 | 3460 | //ksort($aFolders); |
| 2947 | 3461 | |
| 2948 | 3462 | // Sort none auto folders base on mailbox name |
@@ -2952,12 +3466,17 @@ discard block |
||
| 2952 | 3466 | } |
| 2953 | 3467 | else |
| 2954 | 3468 | { |
| 2955 | - if (is_array($subFolders)) ksort($subFolders); |
|
| 3469 | + if (is_array($subFolders)) |
|
| 3470 | + { |
|
| 3471 | + ksort($subFolders); |
|
| 3472 | + } |
|
| 2956 | 3473 | } |
| 2957 | 3474 | $folders = array_merge($folders,(array)$mainFolder, (array)$subFolders); |
| 2958 | 3475 | } |
| 2959 | 3476 | } |
| 2960 | - elseif ($_nodePath) // single node |
|
| 3477 | + elseif ($_nodePath) |
|
| 3478 | + { |
|
| 3479 | + // single node |
|
| 2961 | 3480 | { |
| 2962 | 3481 | switch ($_search) |
| 2963 | 3482 | { |
@@ -2965,6 +3484,7 @@ discard block |
||
| 2965 | 3484 | case 0: |
| 2966 | 3485 | case 2: |
| 2967 | 3486 | $path = $_nodePath.''.$delimiter; |
| 3487 | + } |
|
| 2968 | 3488 | break; |
| 2969 | 3489 | // Node itself |
| 2970 | 3490 | // shouldn't contain next level delimiter |
@@ -2983,11 +3503,14 @@ discard block |
||
| 2983 | 3503 | |
| 2984 | 3504 | uasort($folders,array($this,'sortByMailbox'));//ksort($folders); |
| 2985 | 3505 | } |
| 2986 | - elseif(!$_nodePath) // all |
|
| 3506 | + elseif(!$_nodePath) |
|
| 3507 | + { |
|
| 3508 | + // all |
|
| 2987 | 3509 | { |
| 2988 | 3510 | if ($_subscribedOnly) |
| 2989 | 3511 | { |
| 2990 | 3512 | $folders = $this->icServer->listSubscribedMailboxes('', 0, true); |
| 3513 | + } |
|
| 2991 | 3514 | } |
| 2992 | 3515 | else |
| 2993 | 3516 | { |
@@ -2999,7 +3522,10 @@ discard block |
||
| 2999 | 3522 | { |
| 3000 | 3523 | // SORTING FOLDERS |
| 3001 | 3524 | //self::$debugTimes=true; |
| 3002 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 3525 | + if (self::$debugTimes) |
|
| 3526 | + { |
|
| 3527 | + $starttime = microtime (true); |
|
| 3528 | + } |
|
| 3003 | 3529 | // Merge of all auto folders and specialusefolders |
| 3004 | 3530 | $autoFoldersTmp = array_unique((array_merge(self::$autoFolders, array_values(self::$specialUseFolders)))); |
| 3005 | 3531 | uasort($folders,array($this,'sortByMailbox'));//ksort($folders); |
@@ -3009,73 +3535,103 @@ discard block |
||
| 3009 | 3535 | $isGoogleMail=false; |
| 3010 | 3536 | foreach($autoFoldersTmp as $afk=>$aF) |
| 3011 | 3537 | { |
| 3012 | - if (!isset($mySpecialUseFolders[$aF]) && $aF) $mySpecialUseFolders[$aF]=$this->getFolderByType($aF,false); |
|
| 3538 | + if (!isset($mySpecialUseFolders[$aF]) && $aF) |
|
| 3539 | + { |
|
| 3540 | + $mySpecialUseFolders[$aF]=$this->getFolderByType($aF,false); |
|
| 3541 | + } |
|
| 3013 | 3542 | //error_log($afk.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 3014 | 3543 | } |
| 3015 | 3544 | //error_log(array2string($mySpecialUseFolders)); |
| 3016 | - foreach ($tmpFolders as $k => $f) { |
|
| 3545 | + foreach ($tmpFolders as $k => $f) |
|
| 3546 | + { |
|
| 3017 | 3547 | $sorted=false; |
| 3018 | - if (strtoupper(substr($k,0,5))=='INBOX') { |
|
| 3019 | - if (strtoupper($k)=='INBOX') { |
|
| 3548 | + if (strtoupper(substr($k,0,5))=='INBOX') |
|
| 3549 | + { |
|
| 3550 | + if (strtoupper($k)=='INBOX') |
|
| 3551 | + { |
|
| 3020 | 3552 | //error_log(__METHOD__.__LINE__.':'.strtoupper(substr($k,0,5)).':'.$k); |
| 3021 | 3553 | $inboxFolderObject[$k]=$f; |
| 3022 | 3554 | unset($folders[$k]); |
| 3023 | 3555 | $sorted=true; |
| 3024 | - } else { |
|
| 3556 | + } |
|
| 3557 | + else |
|
| 3558 | + { |
|
| 3025 | 3559 | $isAutoFolder=false; |
| 3026 | 3560 | foreach($autoFoldersTmp as $afk=>$aF) |
| 3027 | 3561 | { |
| 3028 | 3562 | //error_log(__METHOD__.__LINE__.$k.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 3029 | 3563 | if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
| 3030 | 3564 | ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter || //k may be child of an autofolder |
| 3031 | - stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder |
|
| 3565 | + stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) |
|
| 3566 | + { |
|
| 3567 | + // k is parent of an autofolder |
|
| 3032 | 3568 | { |
| 3033 | 3569 | //error_log(__METHOD__.__LINE__.$k.'->'.$mySpecialUseFolders[$aF]); |
| 3034 | 3570 | $isAutoFolder=true; |
| 3571 | + } |
|
| 3035 | 3572 | $autoFolderObjects[$k]=$f; |
| 3036 | 3573 | break; |
| 3037 | 3574 | } |
| 3038 | 3575 | } |
| 3039 | - if ($isAutoFolder==false) $inboxSubFolderObjects[$k]=$f; |
|
| 3576 | + if ($isAutoFolder==false) |
|
| 3577 | + { |
|
| 3578 | + $inboxSubFolderObjects[$k]=$f; |
|
| 3579 | + } |
|
| 3040 | 3580 | unset($folders[$k]); |
| 3041 | 3581 | $sorted=true; |
| 3042 | 3582 | } |
| 3043 | - } elseif (strtoupper(substr($k,0,13))=='[GOOGLE MAIL]') { |
|
| 3583 | + } |
|
| 3584 | + elseif (strtoupper(substr($k,0,13))=='[GOOGLE MAIL]') |
|
| 3585 | + { |
|
| 3044 | 3586 | $isGoogleMail=true; |
| 3045 | - if (strtoupper($k)=='[GOOGLE MAIL]') { |
|
| 3587 | + if (strtoupper($k)=='[GOOGLE MAIL]') |
|
| 3588 | + { |
|
| 3046 | 3589 | $googleMailFolderObject[$k]=$f; |
| 3047 | 3590 | unset($folders[$k]); |
| 3048 | 3591 | $sorted=true; |
| 3049 | - } else { |
|
| 3592 | + } |
|
| 3593 | + else |
|
| 3594 | + { |
|
| 3050 | 3595 | $isAutoFolder=false; |
| 3051 | 3596 | foreach($autoFoldersTmp as $afk=>$aF) |
| 3052 | 3597 | { |
| 3053 | 3598 | //error_log($k.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 3054 | 3599 | if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
| 3055 | 3600 | ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter|| //k may be child of an autofolder |
| 3056 | - stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder |
|
| 3601 | + stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) |
|
| 3602 | + { |
|
| 3603 | + // k is parent of an autofolder |
|
| 3057 | 3604 | { |
| 3058 | 3605 | //error_log($k.'->'.$mySpecialUseFolders[$aF]); |
| 3059 | 3606 | $isAutoFolder=true; |
| 3607 | + } |
|
| 3060 | 3608 | $googleAutoFolderObjects[$k]=$f; |
| 3061 | 3609 | break; |
| 3062 | 3610 | } |
| 3063 | 3611 | } |
| 3064 | - if ($isAutoFolder==false) $googleSubFolderObjects[$k]=$f; |
|
| 3612 | + if ($isAutoFolder==false) |
|
| 3613 | + { |
|
| 3614 | + $googleSubFolderObjects[$k]=$f; |
|
| 3615 | + } |
|
| 3065 | 3616 | unset($folders[$k]); |
| 3066 | 3617 | $sorted=true; |
| 3067 | 3618 | } |
| 3068 | - } else { |
|
| 3619 | + } |
|
| 3620 | + else |
|
| 3621 | + { |
|
| 3069 | 3622 | $isAutoFolder=false; |
| 3070 | 3623 | foreach($autoFoldersTmp as $afk=>$aF) |
| 3071 | 3624 | { |
| 3072 | 3625 | //error_log($k.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 3073 | 3626 | if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
| 3074 | 3627 | ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter|| //k may be child of an autofolder |
| 3075 | - stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder |
|
| 3628 | + stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) |
|
| 3629 | + { |
|
| 3630 | + // k is parent of an autofolder |
|
| 3076 | 3631 | { |
| 3077 | 3632 | //error_log($k.'->'.$mySpecialUseFolders[$aF]); |
| 3078 | 3633 | $isAutoFolder=true; |
| 3634 | + } |
|
| 3079 | 3635 | $autoFolderObjects[$k]=$f; |
| 3080 | 3636 | unset($folders[$k]); |
| 3081 | 3637 | $sorted=true; |
@@ -3091,7 +3647,8 @@ discard block |
||
| 3091 | 3647 | if ($nameSpace[$type]['prefix_present']&&$nameSpace[$type]['prefix']) |
| 3092 | 3648 | { |
| 3093 | 3649 | if (substr($k,0,strlen($nameSpace[$type]['prefix']))==$nameSpace[$type]['prefix']|| |
| 3094 | - substr($k,0,strlen($nameSpace[$type]['prefix'])-strlen($nameSpace[$type]['delimiter']))==substr($nameSpace[$type]['prefix'],0,strlen($nameSpace[$type]['delimiter'])*-1)) { |
|
| 3650 | + substr($k,0,strlen($nameSpace[$type]['prefix'])-strlen($nameSpace[$type]['delimiter']))==substr($nameSpace[$type]['prefix'],0,strlen($nameSpace[$type]['delimiter'])*-1)) |
|
| 3651 | + { |
|
| 3095 | 3652 | //error_log(__METHOD__.__LINE__.':'.substr($k,0,strlen($nameSpace[$type]['prefix'])).':'.$k); |
| 3096 | 3653 | $typeFolderObject[$type][$k]=$f; |
| 3097 | 3654 | unset($folders[$k]); |
@@ -3118,9 +3675,12 @@ discard block |
||
| 3118 | 3675 | } |
| 3119 | 3676 | } |
| 3120 | 3677 | //error_log(__METHOD__.__LINE__.array2string($autoFolderObjects)); |
| 3121 | - if (!$isGoogleMail) { |
|
| 3678 | + if (!$isGoogleMail) |
|
| 3679 | + { |
|
| 3122 | 3680 | $folders = array_merge($inboxFolderObject,$autoFolderObjects,(array)$inboxSubFolderObjects,(array)$folders,(array)$typeFolderObject['others'],(array)$typeFolderObject['shared']); |
| 3123 | - } else { |
|
| 3681 | + } |
|
| 3682 | + else |
|
| 3683 | + { |
|
| 3124 | 3684 | // avoid calling sortByAutoFolder as it is not regarding subfolders |
| 3125 | 3685 | $gAutoFolderObjectsTmp = $googleAutoFolderObjects; |
| 3126 | 3686 | unset($googleAutoFolderObjects); |
@@ -3137,7 +3697,10 @@ discard block |
||
| 3137 | 3697 | } |
| 3138 | 3698 | $folders = array_merge($inboxFolderObject,$autoFolderObjects,(array)$folders,(array)$googleMailFolderObject,$googleAutoFolderObjects,$googleSubFolderObjects,(array)$typeFolderObject['others'],(array)$typeFolderObject['shared']); |
| 3139 | 3699 | } |
| 3140 | - if (self::$debugTimes) self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') Sorting:'); |
|
| 3700 | + if (self::$debugTimes) |
|
| 3701 | + { |
|
| 3702 | + self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') Sorting:'); |
|
| 3703 | + } |
|
| 3141 | 3704 | //self::$debugTimes=false; |
| 3142 | 3705 | } |
| 3143 | 3706 | // Get counter information and add them to each fetched folders array |
@@ -3187,7 +3750,13 @@ discard block |
||
| 3187 | 3750 | $rv = false; |
| 3188 | 3751 | foreach ($haystack as $k => $v) |
| 3189 | 3752 | { |
| 3190 | - foreach($v as &$sv) {if (trim($sv)==trim($needle)) return $k;} |
|
| 3753 | + foreach($v as &$sv) |
|
| 3754 | + { |
|
| 3755 | +if (trim($sv)==trim($needle)) |
|
| 3756 | + { |
|
| 3757 | + return $k; |
|
| 3758 | + } |
|
| 3759 | + } |
|
| 3191 | 3760 | } |
| 3192 | 3761 | return $rv; |
| 3193 | 3762 | } |
@@ -3214,7 +3783,10 @@ discard block |
||
| 3214 | 3783 | */ |
| 3215 | 3784 | static function pathToFolderData ($_path, $_hDelimiter) |
| 3216 | 3785 | { |
| 3217 | - if (!strpos($_path, self::DELIMITER)) $_path = self::DELIMITER.$_path; |
|
| 3786 | + if (!strpos($_path, self::DELIMITER)) |
|
| 3787 | + { |
|
| 3788 | + $_path = self::DELIMITER.$_path; |
|
| 3789 | + } |
|
| 3218 | 3790 | list(,$path) = explode(self::DELIMITER, $_path); |
| 3219 | 3791 | $path_chain = $parts = explode($_hDelimiter, $path); |
| 3220 | 3792 | $name = array_pop($parts); |
@@ -3243,7 +3815,10 @@ discard block |
||
| 3243 | 3815 | $b = self::pathToFolderData($_b['MAILBOX'], $_b['delimiter']); |
| 3244 | 3816 | $pos1 = array_search(trim($a['name']),self::$autoFolders); |
| 3245 | 3817 | $pos2 = array_search(trim($b['name']),self::$autoFolders); |
| 3246 | - if ($pos1 == $pos2) return 0; |
|
| 3818 | + if ($pos1 == $pos2) |
|
| 3819 | + { |
|
| 3820 | + return 0; |
|
| 3821 | + } |
|
| 3247 | 3822 | return ($pos1 < $pos2) ? -1 : 1; |
| 3248 | 3823 | } |
| 3249 | 3824 | |
@@ -3274,7 +3849,10 @@ discard block |
||
| 3274 | 3849 | // 0, 1 und -1 |
| 3275 | 3850 | $pos1 = array_search(trim($a->shortFolderName),self::$autoFolders); |
| 3276 | 3851 | $pos2 = array_search(trim($b->shortFolderName),self::$autoFolders); |
| 3277 | - if ($pos1 == $pos2) return 0; |
|
| 3852 | + if ($pos1 == $pos2) |
|
| 3853 | + { |
|
| 3854 | + return 0; |
|
| 3855 | + } |
|
| 3278 | 3856 | return ($pos1 < $pos2) ? -1 : 1; |
| 3279 | 3857 | } |
| 3280 | 3858 | |
@@ -3295,11 +3873,18 @@ discard block |
||
| 3295 | 3873 | } |
| 3296 | 3874 | catch (\Exception $e) |
| 3297 | 3875 | { |
| 3298 | - if (self::$debug) error_log(__METHOD__." returned FolderStatus for Folder $folderName:".$e->getMessage()); |
|
| 3876 | + if (self::$debug) |
|
| 3877 | + { |
|
| 3878 | + error_log(__METHOD__." returned FolderStatus for Folder $folderName:".$e->getMessage()); |
|
| 3879 | + } |
|
| 3299 | 3880 | return false; |
| 3300 | 3881 | } |
| 3301 | - if(is_array($folderStatus)) { |
|
| 3302 | - if ($_returnObject===false) return $folderStatus; |
|
| 3882 | + if(is_array($folderStatus)) |
|
| 3883 | + { |
|
| 3884 | + if ($_returnObject===false) |
|
| 3885 | + { |
|
| 3886 | + return $folderStatus; |
|
| 3887 | + } |
|
| 3303 | 3888 | $status = new \stdClass; |
| 3304 | 3889 | $status->messages = $folderStatus['MESSAGES']; |
| 3305 | 3890 | $status->unseen = $folderStatus['UNSEEN']; |
@@ -3326,7 +3911,8 @@ discard block |
||
| 3326 | 3911 | { |
| 3327 | 3912 | #echo __METHOD__." retrieve SubFolders for $_mailbox$delimiter <br>"; |
| 3328 | 3913 | $maxreclevel=25; |
| 3329 | - if ($reclevel > $maxreclevel) { |
|
| 3914 | + if ($reclevel > $maxreclevel) |
|
| 3915 | + { |
|
| 3330 | 3916 | error_log( __METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter "); |
| 3331 | 3917 | return array(); |
| 3332 | 3918 | } |
@@ -3340,7 +3926,8 @@ discard block |
||
| 3340 | 3926 | //error_log(__METHOD__.' ('.__LINE__.') '.' Delimiter:'.array2string($delimiter)); |
| 3341 | 3927 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mbx)); |
| 3342 | 3928 | // Example: Array([INBOX/GaGa] => Array([MAILBOX] => INBOX/GaGa[ATTRIBUTES] => Array([0] => \\unmarked)[delimiter] => /)) |
| 3343 | - if (is_array($mbx[$mbxkeys[0]]["ATTRIBUTES"]) && (in_array('\HasChildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Haschildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\haschildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) { |
|
| 3929 | + if (is_array($mbx[$mbxkeys[0]]["ATTRIBUTES"]) && (in_array('\HasChildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Haschildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\haschildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) |
|
| 3930 | + { |
|
| 3344 | 3931 | // if there are children fetch them |
| 3345 | 3932 | //echo $mbx[$mbxkeys[0]]['MAILBOX']."<br>"; |
| 3346 | 3933 | |
@@ -3348,7 +3935,8 @@ discard block |
||
| 3348 | 3935 | //$buff = $this->icServer->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'],2,false); |
| 3349 | 3936 | //_debug_array($buff); |
| 3350 | 3937 | $allMailboxes = array(); |
| 3351 | - foreach ($buff as $mbxname) { |
|
| 3938 | + foreach ($buff as $mbxname) |
|
| 3939 | + { |
|
| 3352 | 3940 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mbxname)); |
| 3353 | 3941 | $mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$mbxname['MAILBOX']); |
| 3354 | 3942 | #echo "About to recur in level $reclevel:".$mbxname."<br>"; |
@@ -3357,9 +3945,14 @@ discard block |
||
| 3357 | 3945 | $allMailboxes = array_merge($allMailboxes, self::getMailBoxesRecursive($mbxname, $delimiter, $prefix, $reclevel)); |
| 3358 | 3946 | } |
| 3359 | 3947 | } |
| 3360 | - if (!(in_array('\NoSelect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) $allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX']; |
|
| 3948 | + if (!(in_array('\NoSelect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) |
|
| 3949 | + { |
|
| 3950 | + $allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX']; |
|
| 3951 | + } |
|
| 3361 | 3952 | return $allMailboxes; |
| 3362 | - } else { |
|
| 3953 | + } |
|
| 3954 | + else |
|
| 3955 | + { |
|
| 3363 | 3956 | return array($_mailbox); |
| 3364 | 3957 | } |
| 3365 | 3958 | } |
@@ -3383,14 +3976,21 @@ discard block |
||
| 3383 | 3976 | 'Outbox' => array('profileKey'=>'acc_folder_outbox','autoFolderName'=>'Outbox'), |
| 3384 | 3977 | 'Archive' => array('profileKey'=>'acc_folder_archive','autoFolderName'=>'Archive'), |
| 3385 | 3978 | ); |
| 3386 | - if ($_type == 'Templates') $_type = 'Template'; // for some reason self::$autofolders uses 'Templates'! |
|
| 3979 | + if ($_type == 'Templates') |
|
| 3980 | + { |
|
| 3981 | + $_type = 'Template'; |
|
| 3982 | + } |
|
| 3983 | + // for some reason self::$autofolders uses 'Templates'! |
|
| 3387 | 3984 | $created = false; |
| 3388 | 3985 | if (!isset($types[$_type])) |
| 3389 | 3986 | { |
| 3390 | 3987 | error_log(__METHOD__.' ('.__LINE__.') '.' '.$_type.' not supported for '.__METHOD__); |
| 3391 | 3988 | return false; |
| 3392 | 3989 | } |
| 3393 | - if (is_null(self::$specialUseFolders) || empty(self::$specialUseFolders)) self::$specialUseFolders = $this->getSpecialUseFolders(); |
|
| 3990 | + if (is_null(self::$specialUseFolders) || empty(self::$specialUseFolders)) |
|
| 3991 | + { |
|
| 3992 | + self::$specialUseFolders = $this->getSpecialUseFolders(); |
|
| 3993 | + } |
|
| 3394 | 3994 | |
| 3395 | 3995 | //highest precedence |
| 3396 | 3996 | try |
@@ -3400,25 +4000,39 @@ discard block |
||
| 3400 | 4000 | catch (\Exception $e) |
| 3401 | 4001 | { |
| 3402 | 4002 | // we know that outbox is not supported, but we use this here, as we autocreate expected SpecialUseFolders in this function |
| 3403 | - if ($_type != 'Outbox') error_log(__METHOD__.' ('.__LINE__.') '.' Failed to retrieve Folder'.$_folderName." for ".array2string($types[$_type]).":".$e->getMessage()); |
|
| 4003 | + if ($_type != 'Outbox') |
|
| 4004 | + { |
|
| 4005 | + error_log(__METHOD__.' ('.__LINE__.') '.' Failed to retrieve Folder'.$_folderName." for ".array2string($types[$_type]).":".$e->getMessage()); |
|
| 4006 | + } |
|
| 3404 | 4007 | $_folderName = false; |
| 3405 | 4008 | } |
| 3406 | 4009 | // do not try to autocreate configured Archive-Folder. Return false if configured folder does not exist |
| 3407 | - if ($_type == 'Archive') { |
|
| 3408 | - if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true)) { |
|
| 4010 | + if ($_type == 'Archive') |
|
| 4011 | + { |
|
| 4012 | + if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true)) |
|
| 4013 | + { |
|
| 3409 | 4014 | return false; |
| 3410 | - } else { |
|
| 4015 | + } |
|
| 4016 | + else |
|
| 4017 | + { |
|
| 3411 | 4018 | return $_folderName; |
| 3412 | 4019 | } |
| 3413 | 4020 | |
| 3414 | 4021 | } |
| 3415 | 4022 | // does the folder exist??? (is configured/preset, but non-existent) |
| 3416 | - if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true)) { |
|
| 4023 | + if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true)) |
|
| 4024 | + { |
|
| 3417 | 4025 | try |
| 3418 | 4026 | { |
| 3419 | 4027 | $error = null; |
| 3420 | - if (($_folderName = $this->createFolder('', $_folderName, $error))) $created = true; |
|
| 3421 | - if ($error) error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error); |
|
| 4028 | + if (($_folderName = $this->createFolder('', $_folderName, $error))) |
|
| 4029 | + { |
|
| 4030 | + $created = true; |
|
| 4031 | + } |
|
| 4032 | + if ($error) |
|
| 4033 | + { |
|
| 4034 | + error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error); |
|
| 4035 | + } |
|
| 3422 | 4036 | } |
| 3423 | 4037 | catch(Exception $e) |
| 3424 | 4038 | { |
@@ -3427,9 +4041,16 @@ discard block |
||
| 3427 | 4041 | } |
| 3428 | 4042 | } |
| 3429 | 4043 | // not sure yet if false is the correct behavior on none |
| 3430 | - if ($_folderName =='none') return 'none' ; //false; |
|
| 4044 | + if ($_folderName =='none') |
|
| 4045 | + { |
|
| 4046 | + return 'none' ; |
|
| 4047 | + } |
|
| 4048 | + //false; |
|
| 3431 | 4049 | //no (valid) folder found yet; try specialUseFolders |
| 3432 | - if (empty($_folderName) && is_array(self::$specialUseFolders) && ($f = array_search($_type,self::$specialUseFolders))) $_folderName = $f; |
|
| 4050 | + if (empty($_folderName) && is_array(self::$specialUseFolders) && ($f = array_search($_type,self::$specialUseFolders))) |
|
| 4051 | + { |
|
| 4052 | + $_folderName = $f; |
|
| 4053 | + } |
|
| 3433 | 4054 | //no specialUseFolder; try some Defaults |
| 3434 | 4055 | if (empty($_folderName) && isset($types[$_type])) |
| 3435 | 4056 | { |
@@ -3455,7 +4076,10 @@ discard block |
||
| 3455 | 4076 | $error = null; |
| 3456 | 4077 | $this->createFolder('', $prefix.$types[$_type]['autoFolderName'],$error); |
| 3457 | 4078 | $_folderName = $prefix.$types[$_type]['autoFolderName']; |
| 3458 | - if ($error) error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error); |
|
| 4079 | + if ($error) |
|
| 4080 | + { |
|
| 4081 | + error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error); |
|
| 4082 | + } |
|
| 3459 | 4083 | } |
| 3460 | 4084 | catch(Exception $e) |
| 3461 | 4085 | { |
@@ -3558,25 +4182,35 @@ discard block |
||
| 3558 | 4182 | function isSentFolder($_folderName, $_checkexistance=TRUE, $_exactMatch=false) |
| 3559 | 4183 | { |
| 3560 | 4184 | $sentFolder = $this->getSentFolder($_checkexistance); |
| 3561 | - if(empty($sentFolder)) { |
|
| 4185 | + if(empty($sentFolder)) |
|
| 4186 | + { |
|
| 3562 | 4187 | return false; |
| 3563 | 4188 | } |
| 3564 | 4189 | // does the folder exist??? |
| 3565 | - if ($_checkexistance && !$this->folderExists($_folderName)) { |
|
| 4190 | + if ($_checkexistance && !$this->folderExists($_folderName)) |
|
| 4191 | + { |
|
| 3566 | 4192 | return false; |
| 3567 | 4193 | } |
| 3568 | 4194 | |
| 3569 | 4195 | if ($_exactMatch) |
| 3570 | 4196 | { |
| 3571 | - if(false !== stripos($_folderName, $sentFolder)&& strlen($_folderName)==strlen($sentFolder)) { |
|
| 4197 | + if(false !== stripos($_folderName, $sentFolder)&& strlen($_folderName)==strlen($sentFolder)) |
|
| 4198 | + { |
|
| 3572 | 4199 | return true; |
| 3573 | - } else { |
|
| 4200 | + } |
|
| 4201 | + else |
|
| 4202 | + { |
|
| 3574 | 4203 | return false; |
| 3575 | 4204 | } |
| 3576 | - } else { |
|
| 3577 | - if(false !== stripos($_folderName, $sentFolder)) { |
|
| 4205 | + } |
|
| 4206 | + else |
|
| 4207 | + { |
|
| 4208 | + if(false !== stripos($_folderName, $sentFolder)) |
|
| 4209 | + { |
|
| 3578 | 4210 | return true; |
| 3579 | - } else { |
|
| 4211 | + } |
|
| 4212 | + else |
|
| 4213 | + { |
|
| 3580 | 4214 | return false; |
| 3581 | 4215 | } |
| 3582 | 4216 | } |
@@ -3591,23 +4225,33 @@ discard block |
||
| 3591 | 4225 | */ |
| 3592 | 4226 | function isOutbox($_folderName, $_checkexistance=TRUE, $_exactMatch=false) |
| 3593 | 4227 | { |
| 3594 | - if (stripos($_folderName, 'Outbox')===false) { |
|
| 4228 | + if (stripos($_folderName, 'Outbox')===false) |
|
| 4229 | + { |
|
| 3595 | 4230 | return false; |
| 3596 | 4231 | } |
| 3597 | 4232 | // does the folder exist??? |
| 3598 | - if ($_checkexistance && $GLOBALS['egw_info']['user']['apps']['activesync'] && !$this->folderExists($_folderName)) { |
|
| 4233 | + if ($_checkexistance && $GLOBALS['egw_info']['user']['apps']['activesync'] && !$this->folderExists($_folderName)) |
|
| 4234 | + { |
|
| 3599 | 4235 | $outboxFolder = $this->getOutboxFolder($_checkexistance); |
| 3600 | 4236 | if ($_exactMatch) |
| 3601 | 4237 | { |
| 3602 | - if(false !== stripos($_folderName, $outboxFolder)&& strlen($_folderName)==strlen($outboxFolder)) { |
|
| 4238 | + if(false !== stripos($_folderName, $outboxFolder)&& strlen($_folderName)==strlen($outboxFolder)) |
|
| 4239 | + { |
|
| 3603 | 4240 | return true; |
| 3604 | - } else { |
|
| 4241 | + } |
|
| 4242 | + else |
|
| 4243 | + { |
|
| 3605 | 4244 | return false; |
| 3606 | 4245 | } |
| 3607 | - } else { |
|
| 3608 | - if(false !== stripos($_folderName, $outboxFolder)) { |
|
| 4246 | + } |
|
| 4247 | + else |
|
| 4248 | + { |
|
| 4249 | + if(false !== stripos($_folderName, $outboxFolder)) |
|
| 4250 | + { |
|
| 3609 | 4251 | return true; |
| 3610 | - } else { |
|
| 4252 | + } |
|
| 4253 | + else |
|
| 4254 | + { |
|
| 3611 | 4255 | return false; |
| 3612 | 4256 | } |
| 3613 | 4257 | } |
@@ -3625,25 +4269,38 @@ discard block |
||
| 3625 | 4269 | function isDraftFolder($_folderName, $_checkexistance=TRUE, $_exactMatch=false) |
| 3626 | 4270 | { |
| 3627 | 4271 | $draftFolder = $this->getDraftFolder($_checkexistance); |
| 3628 | - if(empty($draftFolder)) { |
|
| 4272 | + if(empty($draftFolder)) |
|
| 4273 | + { |
|
| 3629 | 4274 | return false; |
| 3630 | 4275 | } |
| 3631 | 4276 | // does the folder exist??? |
| 3632 | - if ($_checkexistance && !$this->folderExists($_folderName)) { |
|
| 4277 | + if ($_checkexistance && !$this->folderExists($_folderName)) |
|
| 4278 | + { |
|
| 3633 | 4279 | return false; |
| 3634 | 4280 | } |
| 3635 | - if (is_a($_folderName,"Horde_Imap_Client_Mailbox")) $_folderName = $_folderName->utf8; |
|
| 3636 | - if ($_exactMatch) |
|
| 4281 | + if (is_a($_folderName,"Horde_Imap_Client_Mailbox")) |
|
| 4282 | + { |
|
| 4283 | + $_folderName = $_folderName->utf8; |
|
| 4284 | + } |
|
| 4285 | + if ($_exactMatch) |
|
| 4286 | + { |
|
| 4287 | + if(false !== stripos($_folderName, $draftFolder)&& strlen($_folderName)==strlen($draftFolder)) |
|
| 4288 | + { |
|
| 4289 | + return true; |
|
| 4290 | + } |
|
| 4291 | + else |
|
| 4292 | + { |
|
| 4293 | + return false; |
|
| 4294 | + } |
|
| 4295 | + } |
|
| 4296 | + else |
|
| 3637 | 4297 | { |
| 3638 | - if(false !== stripos($_folderName, $draftFolder)&& strlen($_folderName)==strlen($draftFolder)) { |
|
| 4298 | + if(false !== stripos($_folderName, $draftFolder)) |
|
| 4299 | + { |
|
| 3639 | 4300 | return true; |
| 3640 | - } else { |
|
| 3641 | - return false; |
|
| 3642 | 4301 | } |
| 3643 | - } else { |
|
| 3644 | - if(false !== stripos($_folderName, $draftFolder)) { |
|
| 3645 | - return true; |
|
| 3646 | - } else { |
|
| 4302 | + else |
|
| 4303 | + { |
|
| 3647 | 4304 | return false; |
| 3648 | 4305 | } |
| 3649 | 4306 | } |
@@ -3659,25 +4316,35 @@ discard block |
||
| 3659 | 4316 | function isTrashFolder($_folderName, $_checkexistance=TRUE, $_exactMatch=false) |
| 3660 | 4317 | { |
| 3661 | 4318 | $trashFolder = $this->getTrashFolder($_checkexistance); |
| 3662 | - if(empty($trashFolder)) { |
|
| 4319 | + if(empty($trashFolder)) |
|
| 4320 | + { |
|
| 3663 | 4321 | return false; |
| 3664 | 4322 | } |
| 3665 | 4323 | // does the folder exist??? |
| 3666 | - if ($_checkexistance && !$this->folderExists($_folderName)) { |
|
| 4324 | + if ($_checkexistance && !$this->folderExists($_folderName)) |
|
| 4325 | + { |
|
| 3667 | 4326 | return false; |
| 3668 | 4327 | } |
| 3669 | 4328 | |
| 3670 | 4329 | if ($_exactMatch) |
| 3671 | 4330 | { |
| 3672 | - if(false !== stripos($_folderName, $trashFolder)&& strlen($_folderName)==strlen($trashFolder)) { |
|
| 4331 | + if(false !== stripos($_folderName, $trashFolder)&& strlen($_folderName)==strlen($trashFolder)) |
|
| 4332 | + { |
|
| 3673 | 4333 | return true; |
| 3674 | - } else { |
|
| 4334 | + } |
|
| 4335 | + else |
|
| 4336 | + { |
|
| 3675 | 4337 | return false; |
| 3676 | 4338 | } |
| 3677 | - } else { |
|
| 3678 | - if(false !== stripos($_folderName, $trashFolder)) { |
|
| 4339 | + } |
|
| 4340 | + else |
|
| 4341 | + { |
|
| 4342 | + if(false !== stripos($_folderName, $trashFolder)) |
|
| 4343 | + { |
|
| 3679 | 4344 | return true; |
| 3680 | - } else { |
|
| 4345 | + } |
|
| 4346 | + else |
|
| 4347 | + { |
|
| 3681 | 4348 | return false; |
| 3682 | 4349 | } |
| 3683 | 4350 | } |
@@ -3693,24 +4360,34 @@ discard block |
||
| 3693 | 4360 | function isTemplateFolder($_folderName, $_checkexistance=TRUE, $_exactMatch=false) |
| 3694 | 4361 | { |
| 3695 | 4362 | $templateFolder = $this->getTemplateFolder($_checkexistance); |
| 3696 | - if(empty($templateFolder)) { |
|
| 4363 | + if(empty($templateFolder)) |
|
| 4364 | + { |
|
| 3697 | 4365 | return false; |
| 3698 | 4366 | } |
| 3699 | 4367 | // does the folder exist??? |
| 3700 | - if ($_checkexistance && !$this->folderExists($_folderName)) { |
|
| 4368 | + if ($_checkexistance && !$this->folderExists($_folderName)) |
|
| 4369 | + { |
|
| 3701 | 4370 | return false; |
| 3702 | 4371 | } |
| 3703 | 4372 | if ($_exactMatch) |
| 3704 | 4373 | { |
| 3705 | - if(false !== stripos($_folderName, $templateFolder)&& strlen($_folderName)==strlen($templateFolder)) { |
|
| 4374 | + if(false !== stripos($_folderName, $templateFolder)&& strlen($_folderName)==strlen($templateFolder)) |
|
| 4375 | + { |
|
| 3706 | 4376 | return true; |
| 3707 | - } else { |
|
| 4377 | + } |
|
| 4378 | + else |
|
| 4379 | + { |
|
| 3708 | 4380 | return false; |
| 3709 | 4381 | } |
| 3710 | - } else { |
|
| 3711 | - if(false !== stripos($_folderName, $templateFolder)) { |
|
| 4382 | + } |
|
| 4383 | + else |
|
| 4384 | + { |
|
| 4385 | + if(false !== stripos($_folderName, $templateFolder)) |
|
| 4386 | + { |
|
| 3712 | 4387 | return true; |
| 3713 | - } else { |
|
| 4388 | + } |
|
| 4389 | + else |
|
| 4390 | + { |
|
| 3714 | 4391 | return false; |
| 3715 | 4392 | } |
| 3716 | 4393 | } |
@@ -3729,15 +4406,27 @@ discard block |
||
| 3729 | 4406 | if (empty($_folder)) |
| 3730 | 4407 | { |
| 3731 | 4408 | // this error is more or less without significance, unless we force the check |
| 3732 | - if ($_forceCheck===true) error_log(__METHOD__.' ('.__LINE__.') '.' Called with empty Folder:'.$_folder.function_backtrace()); |
|
| 4409 | + if ($_forceCheck===true) |
|
| 4410 | + { |
|
| 4411 | + error_log(__METHOD__.' ('.__LINE__.') '.' Called with empty Folder:'.$_folder.function_backtrace()); |
|
| 4412 | + } |
|
| 3733 | 4413 | return false; |
| 3734 | 4414 | } |
| 3735 | 4415 | // when check is not enforced , we assume a folder represented as Horde_Imap_Client_Mailbox as existing folder |
| 3736 | - if (is_a($_folder,"Horde_Imap_Client_Mailbox")&&$_forceCheck===false) return true; |
|
| 3737 | - if (is_a($_folder,"Horde_Imap_Client_Mailbox")) $_folder = $_folder->utf8; |
|
| 4416 | + if (is_a($_folder,"Horde_Imap_Client_Mailbox")&&$_forceCheck===false) |
|
| 4417 | + { |
|
| 4418 | + return true; |
|
| 4419 | + } |
|
| 4420 | + if (is_a($_folder,"Horde_Imap_Client_Mailbox")) |
|
| 4421 | + { |
|
| 4422 | + $_folder = $_folder->utf8; |
|
| 4423 | + } |
|
| 3738 | 4424 | // reduce traffic within the Instance per User; Expire every 5 hours |
| 3739 | 4425 | //error_log(__METHOD__.' ('.__LINE__.') '.' Called with Folder:'.$_folder.function_backtrace()); |
| 3740 | - if (is_null($folderInfo)) $folderInfo = Cache::getCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*5); |
|
| 4426 | + if (is_null($folderInfo)) |
|
| 4427 | + { |
|
| 4428 | + $folderInfo = Cache::getCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*5); |
|
| 4429 | + } |
|
| 3741 | 4430 | //error_log(__METHOD__.' ('.__LINE__.') '.'Cached Info on Folder:'.$_folder.' for Profile:'.$this->profileID.($forceCheck?'(forcedCheck)':'').':'.array2string($folderInfo)); |
| 3742 | 4431 | if (!empty($folderInfo) && isset($folderInfo[$this->profileID]) && isset($folderInfo[$this->profileID][$_folder]) && $forceCheck===false) |
| 3743 | 4432 | { |
@@ -3755,7 +4444,8 @@ discard block |
||
| 3755 | 4444 | |
| 3756 | 4445 | // does the folder exist??? |
| 3757 | 4446 | //error_log(__METHOD__."->Connected?".$this->icServer->_connected.", ".$_folder.", ".($forceCheck?' forceCheck activated':'dont check on server')); |
| 3758 | - if ( $forceCheck || empty($folderInfo) || !isset($folderInfo[$this->profileID]) || !isset($folderInfo[$this->profileID][$_folder])) { |
|
| 4447 | + if ( $forceCheck || empty($folderInfo) || !isset($folderInfo[$this->profileID]) || !isset($folderInfo[$this->profileID][$_folder])) |
|
| 4448 | + { |
|
| 3759 | 4449 | //error_log(__METHOD__."->NotConnected and forceCheck with profile:".$this->profileID); |
| 3760 | 4450 | //return false; |
| 3761 | 4451 | //try to connect |
@@ -3796,9 +4486,12 @@ discard block |
||
| 3796 | 4486 | |
| 3797 | 4487 | $this->icServer->openMailbox($folderName); |
| 3798 | 4488 | |
| 3799 | - if(strtolower($folderName) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") { |
|
| 4489 | + if(strtolower($folderName) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") |
|
| 4490 | + { |
|
| 3800 | 4491 | $this->deleteMessages('all',$folderName,'remove_immediately'); |
| 3801 | - } else { |
|
| 4492 | + } |
|
| 4493 | + else |
|
| 4494 | + { |
|
| 3802 | 4495 | $this->icServer->expunge($folderName); |
| 3803 | 4496 | } |
| 3804 | 4497 | } |
@@ -3817,10 +4510,16 @@ discard block |
||
| 3817 | 4510 | { |
| 3818 | 4511 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.array2string($_folder).', '.$_forceDeleteMethod); |
| 3819 | 4512 | $oldMailbox = ''; |
| 3820 | - if (is_null($_folder) || empty($_folder)) $_folder = $this->sessionData['mailbox']; |
|
| 4513 | + if (is_null($_folder) || empty($_folder)) |
|
| 4514 | + { |
|
| 4515 | + $_folder = $this->sessionData['mailbox']; |
|
| 4516 | + } |
|
| 3821 | 4517 | if (empty($_messageUID)) |
| 3822 | 4518 | { |
| 3823 | - if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID)); |
|
| 4519 | + if (self::$debug) |
|
| 4520 | + { |
|
| 4521 | + error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID)); |
|
| 4522 | + } |
|
| 3824 | 4523 | return false; |
| 3825 | 4524 | } |
| 3826 | 4525 | elseif ($_messageUID==='all') |
@@ -3830,32 +4529,48 @@ discard block |
||
| 3830 | 4529 | else |
| 3831 | 4530 | { |
| 3832 | 4531 | $uidsToDelete = new Horde_Imap_Client_Ids(); |
| 3833 | - if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID; |
|
| 4532 | + if (!(is_object($_messageUID) || is_array($_messageUID))) |
|
| 4533 | + { |
|
| 4534 | + $_messageUID = (array)$_messageUID; |
|
| 4535 | + } |
|
| 3834 | 4536 | $uidsToDelete->add($_messageUID); |
| 3835 | 4537 | } |
| 3836 | 4538 | $deleteOptions = $_forceDeleteMethod; // use forceDeleteMethod if not "no", or unknown method |
| 3837 | - if ($_forceDeleteMethod === 'no' || !in_array($_forceDeleteMethod,array('move_to_trash',"mark_as_deleted","remove_immediately"))) $deleteOptions = ($this->mailPreferences['deleteOptions']?$this->mailPreferences['deleteOptions']:"mark_as_deleted"); |
|
| 4539 | + if ($_forceDeleteMethod === 'no' || !in_array($_forceDeleteMethod,array('move_to_trash',"mark_as_deleted","remove_immediately"))) |
|
| 4540 | + { |
|
| 4541 | + $deleteOptions = ($this->mailPreferences['deleteOptions']?$this->mailPreferences['deleteOptions']:"mark_as_deleted"); |
|
| 4542 | + } |
|
| 3838 | 4543 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.$_folder.'/'.$this->sessionData['mailbox'].' Option:'.$deleteOptions); |
| 3839 | 4544 | $trashFolder = $this->getTrashFolder(); |
| 3840 | 4545 | $draftFolder = $this->getDraftFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['draftFolder']; |
| 3841 | 4546 | $templateFolder = $this->getTemplateFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['templateFolder']; |
| 3842 | 4547 | if((strtolower($_folder) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") || |
| 3843 | - (strtolower($_folder) == strtolower($draftFolder))) { |
|
| 4548 | + (strtolower($_folder) == strtolower($draftFolder))) |
|
| 4549 | + { |
|
| 3844 | 4550 | $deleteOptions = "remove_immediately"; |
| 3845 | 4551 | } |
| 3846 | - if($this->icServer->getCurrentMailbox() != $_folder) { |
|
| 4552 | + if($this->icServer->getCurrentMailbox() != $_folder) |
|
| 4553 | + { |
|
| 3847 | 4554 | $oldMailbox = $this->icServer->getCurrentMailbox(); |
| 3848 | 4555 | $this->icServer->openMailbox($_folder); |
| 3849 | 4556 | } |
| 3850 | 4557 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.$_folder.'/'.$this->sessionData['mailbox'].' Option:'.$deleteOptions); |
| 3851 | 4558 | $updateCache = false; |
| 3852 | - switch($deleteOptions) { |
|
| 4559 | + switch($deleteOptions) |
|
| 4560 | + { |
|
| 3853 | 4561 | case "move_to_trash": |
| 3854 | 4562 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 3855 | 4563 | $updateCache = true; |
| 3856 | - if(!empty($trashFolder)) { |
|
| 3857 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.implode(' : ', $_messageUID)); |
|
| 3858 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$trashFolder <= $_folder / ". $this->sessionData['mailbox']); |
|
| 4564 | + if(!empty($trashFolder)) |
|
| 4565 | + { |
|
| 4566 | + if (self::$debug) |
|
| 4567 | + { |
|
| 4568 | + error_log(__METHOD__.' ('.__LINE__.') '.implode(' : ', $_messageUID)); |
|
| 4569 | + } |
|
| 4570 | + if (self::$debug) |
|
| 4571 | + { |
|
| 4572 | + error_log(__METHOD__.' ('.__LINE__.') '."$trashFolder <= $_folder / ". $this->sessionData['mailbox']); |
|
| 4573 | + } |
|
| 3859 | 4574 | // copy messages |
| 3860 | 4575 | try |
| 3861 | 4576 | { |
@@ -3871,7 +4586,10 @@ discard block |
||
| 3871 | 4586 | case "mark_as_deleted": |
| 3872 | 4587 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 3873 | 4588 | // mark messages as deleted |
| 3874 | - if (is_null($_messageUID)) $_messageUID='all'; |
|
| 4589 | + if (is_null($_messageUID)) |
|
| 4590 | + { |
|
| 4591 | + $_messageUID='all'; |
|
| 4592 | + } |
|
| 3875 | 4593 | foreach((array)$_messageUID as $key =>$uid) |
| 3876 | 4594 | { |
| 3877 | 4595 | //flag messages, that are flagged for deletion as seen too |
@@ -3879,7 +4597,10 @@ discard block |
||
| 3879 | 4597 | $flags = $this->getFlags($uid); |
| 3880 | 4598 | $this->flagMessages('delete', $uid, $_folder); |
| 3881 | 4599 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($flags)); |
| 3882 | - if (strpos( array2string($flags),'Deleted')!==false) $undelete[] = $uid; |
|
| 4600 | + if (strpos( array2string($flags),'Deleted')!==false) |
|
| 4601 | + { |
|
| 4602 | + $undelete[] = $uid; |
|
| 4603 | + } |
|
| 3883 | 4604 | unset($flags); |
| 3884 | 4605 | } |
| 3885 | 4606 | foreach((array)$undelete as $key =>$uid) |
@@ -3891,7 +4612,10 @@ discard block |
||
| 3891 | 4612 | case "remove_immediately": |
| 3892 | 4613 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 3893 | 4614 | $updateCache = true; |
| 3894 | - if (is_null($_messageUID)) $_messageUID='all'; |
|
| 4615 | + if (is_null($_messageUID)) |
|
| 4616 | + { |
|
| 4617 | + $_messageUID='all'; |
|
| 4618 | + } |
|
| 3895 | 4619 | if (is_object($_messageUID)) |
| 3896 | 4620 | { |
| 3897 | 4621 | $this->flagMessages('delete', $_messageUID, $_folder); |
@@ -3908,7 +4632,8 @@ discard block |
||
| 3908 | 4632 | $this->icServer->expunge($_folder); |
| 3909 | 4633 | break; |
| 3910 | 4634 | } |
| 3911 | - if($oldMailbox != '') { |
|
| 4635 | + if($oldMailbox != '') |
|
| 4636 | + { |
|
| 3912 | 4637 | $this->icServer->openMailbox($oldMailbox); |
| 3913 | 4638 | } |
| 3914 | 4639 | |
@@ -3922,11 +4647,15 @@ discard block |
||
| 3922 | 4647 | * |
| 3923 | 4648 | * @return null/array flags |
| 3924 | 4649 | */ |
| 3925 | - function getFlags ($_messageUID) { |
|
| 4650 | + function getFlags ($_messageUID) |
|
| 4651 | + { |
|
| 3926 | 4652 | try |
| 3927 | 4653 | { |
| 3928 | 4654 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 3929 | - if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID; |
|
| 4655 | + if (!(is_object($_messageUID) || is_array($_messageUID))) |
|
| 4656 | + { |
|
| 4657 | + $_messageUID = (array)$_messageUID; |
|
| 4658 | + } |
|
| 3930 | 4659 | $uidsToFetch->add($_messageUID); |
| 3931 | 4660 | $_folderName = $this->icServer->getCurrentMailbox(); |
| 3932 | 4661 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
@@ -3934,8 +4663,10 @@ discard block |
||
| 3934 | 4663 | $headersNew = $this->icServer->fetch($_folderName, $fquery, array( |
| 3935 | 4664 | 'ids' => $uidsToFetch, |
| 3936 | 4665 | )); |
| 3937 | - if (is_object($headersNew)) { |
|
| 3938 | - foreach($headersNew->ids() as $id) { |
|
| 4666 | + if (is_object($headersNew)) |
|
| 4667 | + { |
|
| 4668 | + foreach($headersNew->ids() as $id) |
|
| 4669 | + { |
|
| 3939 | 4670 | $_headerObject = $headersNew->get($id); |
| 3940 | 4671 | $flags = $_headerObject->getFlags(); |
| 3941 | 4672 | } |
@@ -3960,10 +4691,16 @@ discard block |
||
| 3960 | 4691 | */ |
| 3961 | 4692 | function getNotifyFlags ($_messageUID, $flags=null) |
| 3962 | 4693 | { |
| 3963 | - if (self::$debug) error_log(__METHOD__.$_messageUID.' Flags:'.array2string($flags)); |
|
| 4694 | + if (self::$debug) |
|
| 4695 | + { |
|
| 4696 | + error_log(__METHOD__.$_messageUID.' Flags:'.array2string($flags)); |
|
| 4697 | + } |
|
| 3964 | 4698 | try |
| 3965 | 4699 | { |
| 3966 | - if($flags===null) $flags = $this->getFlags($_messageUID); |
|
| 4700 | + if($flags===null) |
|
| 4701 | + { |
|
| 4702 | + $flags = $this->getFlags($_messageUID); |
|
| 4703 | + } |
|
| 3967 | 4704 | } |
| 3968 | 4705 | catch (\Exception $e) |
| 3969 | 4706 | { |
@@ -3971,10 +4708,14 @@ discard block |
||
| 3971 | 4708 | } |
| 3972 | 4709 | |
| 3973 | 4710 | if ( stripos( array2string($flags),'MDNSent')!==false) |
| 3974 | - return true; |
|
| 4711 | + { |
|
| 4712 | + return true; |
|
| 4713 | + } |
|
| 3975 | 4714 | |
| 3976 | 4715 | if ( stripos( array2string($flags),'MDNnotSent')!==false) |
| 3977 | - return false; |
|
| 4716 | + { |
|
| 4717 | + return false; |
|
| 4718 | + } |
|
| 3978 | 4719 | |
| 3979 | 4720 | return null; |
| 3980 | 4721 | } |
@@ -3995,7 +4736,10 @@ discard block |
||
| 3995 | 4736 | //error_log(__METHOD__.' ('.__LINE__.') '.'->' .$_flag." ".array2string($_messageUID).",$_folder /".$this->sessionData['mailbox']); |
| 3996 | 4737 | if (empty($_messageUID)) |
| 3997 | 4738 | { |
| 3998 | - if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID)); |
|
| 4739 | + if (self::$debug) |
|
| 4740 | + { |
|
| 4741 | + error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID)); |
|
| 4742 | + } |
|
| 3999 | 4743 | return false; |
| 4000 | 4744 | } |
| 4001 | 4745 | $this->icServer->openMailbox(($_folder?$_folder:$this->sessionData['mailbox'])); |
@@ -4003,7 +4747,10 @@ discard block |
||
| 4003 | 4747 | if (is_array($_messageUID)&& count($_messageUID)>50) |
| 4004 | 4748 | { |
| 4005 | 4749 | $count = $this->getMailBoxCounters($folder,true); |
| 4006 | - if ($count->messages == count($_messageUID)) $_messageUID='all'; |
|
| 4750 | + if ($count->messages == count($_messageUID)) |
|
| 4751 | + { |
|
| 4752 | + $_messageUID='all'; |
|
| 4753 | + } |
|
| 4007 | 4754 | } |
| 4008 | 4755 | |
| 4009 | 4756 | if ($_messageUID==='all') |
@@ -4012,7 +4759,10 @@ discard block |
||
| 4012 | 4759 | } |
| 4013 | 4760 | else |
| 4014 | 4761 | { |
| 4015 | - if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID; |
|
| 4762 | + if (!(is_object($_messageUID) || is_array($_messageUID))) |
|
| 4763 | + { |
|
| 4764 | + $_messageUID = (array)$_messageUID; |
|
| 4765 | + } |
|
| 4016 | 4766 | $messageUIDs = array_chunk($_messageUID,50,true); |
| 4017 | 4767 | } |
| 4018 | 4768 | try |
@@ -4028,7 +4778,8 @@ discard block |
||
| 4028 | 4778 | $uidsToModify = new Horde_Imap_Client_Ids(); |
| 4029 | 4779 | $uidsToModify->add($uids); |
| 4030 | 4780 | } |
| 4031 | - switch($_flag) { |
|
| 4781 | + switch($_flag) |
|
| 4782 | + { |
|
| 4032 | 4783 | case "delete": |
| 4033 | 4784 | $ret = $this->icServer->store($folder, array('add'=>array('\\Deleted'), 'ids'=> $uidsToModify)); |
| 4034 | 4785 | break; |
@@ -4114,7 +4865,10 @@ discard block |
||
| 4114 | 4865 | { |
| 4115 | 4866 | error_log(__METHOD__.__LINE__.' Error, could not flag messages in folder '.$folder.' Reason:'.$e->getMessage()); |
| 4116 | 4867 | } |
| 4117 | - if ($folder instanceof Horde_Imap_Client_Mailbox) $_folder = $folder->utf8; |
|
| 4868 | + if ($folder instanceof Horde_Imap_Client_Mailbox) |
|
| 4869 | + { |
|
| 4870 | + $_folder = $folder->utf8; |
|
| 4871 | + } |
|
| 4118 | 4872 | //error_log(__METHOD__.__LINE__.'#'.$this->icServer->ImapServerId.'#'.array2string($_folder).'#'); |
| 4119 | 4873 | self::$folderStatusCache[$this->icServer->ImapServerId][(!empty($_folder)?$_folder: $this->sessionData['mailbox'])]['uidValidity'] = 0; |
| 4120 | 4874 | |
@@ -4143,7 +4897,10 @@ discard block |
||
| 4143 | 4897 | //$deleteOptions = $GLOBALS['egw_info']["user"]["preferences"]["mail"]["deleteOptions"]; |
| 4144 | 4898 | if (empty($_messageUID)) |
| 4145 | 4899 | { |
| 4146 | - if (self::$debug) error_log(__METHOD__." no Message(s): ".implode(',',$_messageUID)); |
|
| 4900 | + if (self::$debug) |
|
| 4901 | + { |
|
| 4902 | + error_log(__METHOD__." no Message(s): ".implode(',',$_messageUID)); |
|
| 4903 | + } |
|
| 4147 | 4904 | return false; |
| 4148 | 4905 | } |
| 4149 | 4906 | elseif ($_messageUID==='all') |
@@ -4155,7 +4912,10 @@ discard block |
||
| 4155 | 4912 | { |
| 4156 | 4913 | //error_log(__METHOD__." Message(s): ".implode(',',$_messageUID)); |
| 4157 | 4914 | $uidsToMove = new Horde_Imap_Client_Ids(); |
| 4158 | - if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID; |
|
| 4915 | + if (!(is_object($_messageUID) || is_array($_messageUID))) |
|
| 4916 | + { |
|
| 4917 | + $_messageUID = (array)$_messageUID; |
|
| 4918 | + } |
|
| 4159 | 4919 | $uidsToMove->add($_messageUID); |
| 4160 | 4920 | } |
| 4161 | 4921 | $sourceFolder = (!empty($currentFolder)?$currentFolder: $this->sessionData['mailbox']); |
@@ -4177,12 +4937,14 @@ discard block |
||
| 4177 | 4937 | |
| 4178 | 4938 | //error_log(__METHOD__.' ('.__LINE__.') '.' Sourceserver:'.$source->ImapServerId.' mailheaders:'.array2string($headersNew)); |
| 4179 | 4939 | |
| 4180 | - if (is_object($headersNew)) { |
|
| 4940 | + if (is_object($headersNew)) |
|
| 4941 | + { |
|
| 4181 | 4942 | $c=0; |
| 4182 | 4943 | $retUid = new Horde_Imap_Client_Ids(); |
| 4183 | 4944 | // we copy chunks of 5 to avoid too much memory and/or server stress |
| 4184 | 4945 | // some servers seem not to allow/support the appendig of multiple messages. so we are down to one |
| 4185 | - foreach($headersNew as &$_headerObject) { |
|
| 4946 | + foreach($headersNew as &$_headerObject) |
|
| 4947 | + { |
|
| 4186 | 4948 | $c++; |
| 4187 | 4949 | $flags = $_headerObject->getFlags(); //unseen status seems to be lost when retrieving the full message |
| 4188 | 4950 | $date = $_headerObject->getImapDate(); |
@@ -4266,7 +5028,11 @@ discard block |
||
| 4266 | 5028 | { |
| 4267 | 5029 | try { |
| 4268 | 5030 | $date = new DateTime($_date); // parse date & time including timezone (throws exception, if not parsable) |
| 4269 | - if ($convert2usertime) $date->setUser(); // convert to user-time |
|
| 5031 | + if ($convert2usertime) |
|
| 5032 | + { |
|
| 5033 | + $date->setUser(); |
|
| 5034 | + } |
|
| 5035 | + // convert to user-time |
|
| 4270 | 5036 | $date2return = $date->format($format); |
| 4271 | 5037 | } |
| 4272 | 5038 | catch(\Exception $e) |
@@ -4298,9 +5064,15 @@ discard block |
||
| 4298 | 5064 | static function htmlentities($_string, $_charset=false) |
| 4299 | 5065 | { |
| 4300 | 5066 | //setting the charset (if not given) |
| 4301 | - if ($_charset===false) $_charset = self::$displayCharset; |
|
| 5067 | + if ($_charset===false) |
|
| 5068 | + { |
|
| 5069 | + $_charset = self::$displayCharset; |
|
| 5070 | + } |
|
| 4302 | 5071 | $string = @htmlentities($_string, ENT_QUOTES, $_charset, false); |
| 4303 | - if (empty($string) && !empty($_string)) $string = @htmlentities(Translation::convert($_string,Translation::detect_encoding($_string),$_charset),ENT_QUOTES | ENT_IGNORE,$_charset, false); |
|
| 5072 | + if (empty($string) && !empty($_string)) |
|
| 5073 | + { |
|
| 5074 | + $string = @htmlentities(Translation::convert($_string,Translation::detect_encoding($_string),$_charset),ENT_QUOTES | ENT_IGNORE,$_charset, false); |
|
| 5075 | + } |
|
| 4304 | 5076 | return $string; |
| 4305 | 5077 | } |
| 4306 | 5078 | |
@@ -4320,18 +5092,41 @@ discard block |
||
| 4320 | 5092 | $_html = str_replace(array('&amp;','<DIV><BR></DIV>',"<DIV> </DIV>",'<div> </div>','</td></font>','<br><td>','<tr></tr>','<o:p></o:p>','<o:p>','</o:p>'), |
| 4321 | 5093 | array('&', '<BR>', '<BR>', '<BR>', '</font></td>','<td>', '', '', '', ''),$_html); |
| 4322 | 5094 | //$_html = str_replace(array('&amp;'),array('&'),$_html); |
| 4323 | - if (stripos($_html,'style')!==false) Mail\Html::replaceTagsCompletley($_html,'style'); // clean out empty or pagewide style definitions / left over tags |
|
| 4324 | - if (stripos($_html,'head')!==false) Mail\Html::replaceTagsCompletley($_html,'head'); // Strip out stuff in head |
|
| 5095 | + if (stripos($_html,'style')!==false) |
|
| 5096 | + { |
|
| 5097 | + Mail\Html::replaceTagsCompletley($_html,'style'); |
|
| 5098 | + } |
|
| 5099 | + // clean out empty or pagewide style definitions / left over tags |
|
| 5100 | + if (stripos($_html,'head')!==false) |
|
| 5101 | + { |
|
| 5102 | + Mail\Html::replaceTagsCompletley($_html,'head'); |
|
| 5103 | + } |
|
| 5104 | + // Strip out stuff in head |
|
| 4325 | 5105 | //if (stripos($_html,'![if')!==false && stripos($_html,'<![endif]>')!==false) Mail\Html::replaceTagsCompletley($_html,'!\[if','<!\[endif\]>',false); // Strip out stuff in ifs |
| 4326 | 5106 | //if (stripos($_html,'!--[if')!==false && stripos($_html,'<![endif]-->')!==false) Mail\Html::replaceTagsCompletley($_html,'!--\[if','<!\[endif\]-->',false); // Strip out stuff in ifs |
| 4327 | 5107 | //error_log(__METHOD__.' ('.__LINE__.') '.$_html); |
| 4328 | 5108 | |
| 4329 | - if (get_magic_quotes_gpc() === 1) $_html = stripslashes($_html); |
|
| 5109 | + if (get_magic_quotes_gpc() === 1) |
|
| 5110 | + { |
|
| 5111 | + $_html = stripslashes($_html); |
|
| 5112 | + } |
|
| 4330 | 5113 | // Strip out doctype in head, as htmlLawed cannot handle it TODO: Consider extracting it and adding it afterwards |
| 4331 | - if (stripos($_html,'!doctype')!==false) Mail\Html::replaceTagsCompletley($_html,'!doctype'); |
|
| 4332 | - if (stripos($_html,'?xml:namespace')!==false) Mail\Html::replaceTagsCompletley($_html,'\?xml:namespace','/>',false); |
|
| 4333 | - if (stripos($_html,'?xml version')!==false) Mail\Html::replaceTagsCompletley($_html,'\?xml version','\?>',false); |
|
| 4334 | - if (strpos($_html,'!CURSOR')!==false) Mail\Html::replaceTagsCompletley($_html,'!CURSOR'); |
|
| 5114 | + if (stripos($_html,'!doctype')!==false) |
|
| 5115 | + { |
|
| 5116 | + Mail\Html::replaceTagsCompletley($_html,'!doctype'); |
|
| 5117 | + } |
|
| 5118 | + if (stripos($_html,'?xml:namespace')!==false) |
|
| 5119 | + { |
|
| 5120 | + Mail\Html::replaceTagsCompletley($_html,'\?xml:namespace','/>',false); |
|
| 5121 | + } |
|
| 5122 | + if (stripos($_html,'?xml version')!==false) |
|
| 5123 | + { |
|
| 5124 | + Mail\Html::replaceTagsCompletley($_html,'\?xml version','\?>',false); |
|
| 5125 | + } |
|
| 5126 | + if (strpos($_html,'!CURSOR')!==false) |
|
| 5127 | + { |
|
| 5128 | + Mail\Html::replaceTagsCompletley($_html,'!CURSOR'); |
|
| 5129 | + } |
|
| 4335 | 5130 | // htmLawed filter only the 'body' |
| 4336 | 5131 | //preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $_html, $matches); |
| 4337 | 5132 | //if ($matches[2]) |
@@ -4370,8 +5165,10 @@ discard block |
||
| 4370 | 5165 | //$charSet = 'iso-8859-1';//self::$displayCharset; //'iso-8859-1'; // self::displayCharset seems to be asmarter fallback than iso-8859-1 |
| 4371 | 5166 | $CharsetFound=false; |
| 4372 | 5167 | //echo "#".$_mimePartObject->encoding.'#<br>'; |
| 4373 | - if(is_array($_mimePartObject->parameters)) { |
|
| 4374 | - if(isset($_mimePartObject->parameters['CHARSET'])) { |
|
| 5168 | + if(is_array($_mimePartObject->parameters)) |
|
| 5169 | + { |
|
| 5170 | + if(isset($_mimePartObject->parameters['CHARSET'])) |
|
| 5171 | + { |
|
| 4375 | 5172 | $charSet = $_mimePartObject->parameters['CHARSET']; |
| 4376 | 5173 | $CharsetFound=true; |
| 4377 | 5174 | } |
@@ -4392,7 +5189,10 @@ discard block |
||
| 4392 | 5189 | function decodeMimePart($_mimeMessage, $_encoding, $_charset = '') |
| 4393 | 5190 | { |
| 4394 | 5191 | // decode the part |
| 4395 | - if (self::$debug) error_log(__METHOD__."() with $_encoding and $_charset:".print_r($_mimeMessage,true)); |
|
| 5192 | + if (self::$debug) |
|
| 5193 | + { |
|
| 5194 | + error_log(__METHOD__."() with $_encoding and $_charset:".print_r($_mimeMessage,true)); |
|
| 5195 | + } |
|
| 4396 | 5196 | switch (strtoupper($_encoding)) |
| 4397 | 5197 | { |
| 4398 | 5198 | case 'BASE64': |
@@ -4432,13 +5232,19 @@ discard block |
||
| 4432 | 5232 | // sometimes there are 3 parts, when there is an ics/ical attached/included-> we want to show that |
| 4433 | 5233 | // as attachment AND as abstracted ical information (we use our notification style here). |
| 4434 | 5234 | $partText = $partCalendar = $partHTML = null; |
| 4435 | - if (self::$debug) _debug_array(array("METHOD"=>__METHOD__,"LINE"=>__LINE__,"STRUCTURE"=>$_structure)); |
|
| 5235 | + if (self::$debug) |
|
| 5236 | + { |
|
| 5237 | + _debug_array(array("METHOD"=>__METHOD__,"LINE"=>__LINE__,"STRUCTURE"=>$_structure)); |
|
| 5238 | + } |
|
| 4436 | 5239 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 4437 | 5240 | $ignore_first_part = true; |
| 4438 | 5241 | foreach($_structure->contentTypeMap() as $mime_id => $mime_type) |
| 4439 | 5242 | { |
| 4440 | 5243 | //error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") $mime_id: $mime_type"." ignoreFirstPart:".$ignore_first_part); |
| 4441 | - if (self::$debug) echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>"; |
|
| 5244 | + if (self::$debug) |
|
| 5245 | + { |
|
| 5246 | + echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>"; |
|
| 5247 | + } |
|
| 4442 | 5248 | |
| 4443 | 5249 | if ($ignore_first_part) |
| 4444 | 5250 | { |
@@ -4454,11 +5260,17 @@ discard block |
||
| 4454 | 5260 | switch($mimePart->getSubType()) |
| 4455 | 5261 | { |
| 4456 | 5262 | case 'plain': |
| 4457 | - if ($mimePart->getBytes() > 0) $partText = $mimePart; |
|
| 5263 | + if ($mimePart->getBytes() > 0) |
|
| 5264 | + { |
|
| 5265 | + $partText = $mimePart; |
|
| 5266 | + } |
|
| 4458 | 5267 | break; |
| 4459 | 5268 | |
| 4460 | 5269 | case 'html': |
| 4461 | - if ($mimePart->getBytes() > 0) $partHTML = $mimePart; |
|
| 5270 | + if ($mimePart->getBytes() > 0) |
|
| 5271 | + { |
|
| 5272 | + $partHTML = $mimePart; |
|
| 5273 | + } |
|
| 4462 | 5274 | break; |
| 4463 | 5275 | } |
| 4464 | 5276 | break; |
@@ -4471,7 +5283,10 @@ discard block |
||
| 4471 | 5283 | if (count($mimePart->getParts()) > 1) |
| 4472 | 5284 | { |
| 4473 | 5285 | // in a multipart alternative we treat the multipart/related as html part |
| 4474 | - if (self::$debug) error_log(__METHOD__." process MULTIPART/".$mimePart->getSubType()." with array as subparts"); |
|
| 5286 | + if (self::$debug) |
|
| 5287 | + { |
|
| 5288 | + error_log(__METHOD__." process MULTIPART/".$mimePart->getSubType()." with array as subparts"); |
|
| 5289 | + } |
|
| 4475 | 5290 | $partHTML = $mimePart; |
| 4476 | 5291 | break 3; // GET OUT OF LOOP, will be processed according to type |
| 4477 | 5292 | } |
@@ -4552,9 +5367,15 @@ discard block |
||
| 4552 | 5367 | */ |
| 4553 | 5368 | function getMultipartMixed($_uid, Horde_Mime_Part $_structure, $_htmlMode, $_preserveSeen = false, &$skipParts=array()) |
| 4554 | 5369 | { |
| 4555 | - if (self::$debug) echo __METHOD__."$_uid, $_htmlMode<br>"; |
|
| 5370 | + if (self::$debug) |
|
| 5371 | + { |
|
| 5372 | + echo __METHOD__."$_uid, $_htmlMode<br>"; |
|
| 5373 | + } |
|
| 4556 | 5374 | $bodyPart = array(); |
| 4557 | - if (self::$debug) _debug_array($_structure); |
|
| 5375 | + if (self::$debug) |
|
| 5376 | + { |
|
| 5377 | + _debug_array($_structure); |
|
| 5378 | + } |
|
| 4558 | 5379 | |
| 4559 | 5380 | $ignore_first_part = true; |
| 4560 | 5381 | //$skipParts = array(); |
@@ -4562,7 +5383,10 @@ discard block |
||
| 4562 | 5383 | foreach($_structure->contentTypeMap() as $mime_id => $mime_type) |
| 4563 | 5384 | { |
| 4564 | 5385 | //error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") $mime_id: $mime_type"); |
| 4565 | - if (self::$debug) echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>"; |
|
| 5386 | + if (self::$debug) |
|
| 5387 | + { |
|
| 5388 | + echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>"; |
|
| 5389 | + } |
|
| 4566 | 5390 | if ($ignore_first_part) |
| 4567 | 5391 | { |
| 4568 | 5392 | $ignore_first_part = false; |
@@ -4580,7 +5404,10 @@ discard block |
||
| 4580 | 5404 | switch($part->getPrimaryType()) |
| 4581 | 5405 | { |
| 4582 | 5406 | case 'multipart': |
| 4583 | - if ($part->getDisposition() == 'attachment') continue; |
|
| 5407 | + if ($part->getDisposition() == 'attachment') |
|
| 5408 | + { |
|
| 5409 | + continue; |
|
| 5410 | + } |
|
| 4584 | 5411 | switch($part->getSubType()) |
| 4585 | 5412 | { |
| 4586 | 5413 | case 'alternative': |
@@ -4645,7 +5472,9 @@ discard block |
||
| 4645 | 5472 | if($part->getSubType() == 'rfc822' || $part->getDisposition() == 'attachment') |
| 4646 | 5473 | { |
| 4647 | 5474 | $skipParts[$mime_id.'.0'] = $mime_type; |
| 4648 | - foreach($part->contentTypeMap() as $sub_id => $sub_type){ $skipParts[$sub_id] = $sub_type;} |
|
| 5475 | + foreach($part->contentTypeMap() as $sub_id => $sub_type) |
|
| 5476 | + { |
|
| 5477 | +$skipParts[$sub_id] = $sub_type;} |
|
| 4649 | 5478 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$_uid.' Part:'.$mime_id.':'.array2string($skipParts)); |
| 4650 | 5479 | //break 2; |
| 4651 | 5480 | } |
@@ -4688,7 +5517,10 @@ discard block |
||
| 4688 | 5517 | */ |
| 4689 | 5518 | function getBodyPart($_uid, $_partID=null, $_folder=null, $_preserveSeen=false, $_stream=false, &$_encoding=null, $_tryDecodingServerside=true) |
| 4690 | 5519 | { |
| 4691 | - if (self::$debug) error_log( __METHOD__.__LINE__."(".array2string($_uid).", $_partID, $_folder, $_preserveSeen, $_stream, $_encoding, $_tryDecodingServerside)"); |
|
| 5520 | + if (self::$debug) |
|
| 5521 | + { |
|
| 5522 | + error_log( __METHOD__.__LINE__."(".array2string($_uid).", $_partID, $_folder, $_preserveSeen, $_stream, $_encoding, $_tryDecodingServerside)"); |
|
| 5523 | + } |
|
| 4692 | 5524 | |
| 4693 | 5525 | if (empty($_folder)) |
| 4694 | 5526 | { |
@@ -4697,7 +5529,10 @@ discard block |
||
| 4697 | 5529 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_folder).'/'.$this->icServer->getCurrentMailbox().'/'. $this->sessionData['mailbox']); |
| 4698 | 5530 | // querying contents of body part |
| 4699 | 5531 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 4700 | - if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
|
| 5532 | + if (!(is_object($_uid) || is_array($_uid))) |
|
| 5533 | + { |
|
| 5534 | + $_uid = (array)$_uid; |
|
| 5535 | + } |
|
| 4701 | 5536 | $uidsToFetch->add($_uid); |
| 4702 | 5537 | |
| 4703 | 5538 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
@@ -4705,9 +5540,12 @@ discard block |
||
| 4705 | 5540 | 'peek' => $_preserveSeen, |
| 4706 | 5541 | 'decode' => true, // try decode on server, does NOT neccessary work |
| 4707 | 5542 | ); |
| 4708 | - if ($_tryDecodingServerside===false)// || ($_tryDecodingServerside&&$this->isDraftFolder($_folder))) |
|
| 5543 | + if ($_tryDecodingServerside===false) |
|
| 5544 | + { |
|
| 5545 | + // || ($_tryDecodingServerside&&$this->isDraftFolder($_folder))) |
|
| 4709 | 5546 | { |
| 4710 | 5547 | $_tryDecodingServerside=false; |
| 5548 | + } |
|
| 4711 | 5549 | $fetchParams = array( |
| 4712 | 5550 | 'peek' => $_preserveSeen, |
| 4713 | 5551 | ); |
@@ -4749,7 +5587,10 @@ discard block |
||
| 4749 | 5587 | { |
| 4750 | 5588 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.$_uid.':'.array2string($_structure).' '.function_backtrace()); |
| 4751 | 5589 | $bodyPart = array(); |
| 4752 | - if (self::$debug) _debug_array(array($_structure,function_backtrace())); |
|
| 5590 | + if (self::$debug) |
|
| 5591 | + { |
|
| 5592 | + _debug_array(array($_structure,function_backtrace())); |
|
| 5593 | + } |
|
| 4753 | 5594 | |
| 4754 | 5595 | if($_structure->getSubType() == 'html' && !in_array($_htmlMode, array('html_only', 'always_display', 'only_if_no_text'))) |
| 4755 | 5596 | { |
@@ -4799,8 +5640,12 @@ discard block |
||
| 4799 | 5640 | */ |
| 4800 | 5641 | function getMessageBody($_uid, $_htmlOptions='', $_partID=null, Horde_Mime_Part $_structure=null, $_preserveSeen = false, $_folder = '') |
| 4801 | 5642 | { |
| 4802 | - if (self::$debug) echo __METHOD__."$_uid, $_htmlOptions, $_partID<br>"; |
|
| 4803 | - if($_htmlOptions != '') { |
|
| 5643 | + if (self::$debug) |
|
| 5644 | + { |
|
| 5645 | + echo __METHOD__."$_uid, $_htmlOptions, $_partID<br>"; |
|
| 5646 | + } |
|
| 5647 | + if($_htmlOptions != '') |
|
| 5648 | + { |
|
| 4804 | 5649 | $this->htmlOptions = $_htmlOptions; |
| 4805 | 5650 | } |
| 4806 | 5651 | if (empty($_folder)) |
@@ -4889,7 +5734,9 @@ discard block |
||
| 4889 | 5734 | default: |
| 4890 | 5735 | $bodyPart = array($this->getTextPart($_uid, $_structure, $this->htmlOptions, $_preserveSeen)); |
| 4891 | 5736 | } |
| 4892 | - } else { |
|
| 5737 | + } |
|
| 5738 | + else |
|
| 5739 | + { |
|
| 4893 | 5740 | // what if the structure->disposition is attachment ,... |
| 4894 | 5741 | } |
| 4895 | 5742 | return self::normalizeBodyParts($bodyPart); |
@@ -4900,13 +5747,18 @@ discard block |
||
| 4900 | 5747 | { |
| 4901 | 5748 | case 'rfc822': |
| 4902 | 5749 | $newStructure = $_structure->getParts(); |
| 4903 | - if (self::$debug) {echo __METHOD__." Message -> RFC -> NewStructure:"; _debug_array($newStructure[0]);} |
|
| 5750 | + if (self::$debug) |
|
| 5751 | + { |
|
| 5752 | +echo __METHOD__." Message -> RFC -> NewStructure:"; _debug_array($newStructure[0]);} |
|
| 4904 | 5753 | return self::normalizeBodyParts($this->getMessageBody($_uid, $_htmlOptions, $newStructure[0]->getMimeId(), $newStructure[0], $_preserveSeen, $_folder)); |
| 4905 | 5754 | } |
| 4906 | 5755 | break; |
| 4907 | 5756 | |
| 4908 | 5757 | default: |
| 4909 | - if (self::$debug) _debug_array($_structure); |
|
| 5758 | + if (self::$debug) |
|
| 5759 | + { |
|
| 5760 | + _debug_array($_structure); |
|
| 5761 | + } |
|
| 4910 | 5762 | return array( |
| 4911 | 5763 | array( |
| 4912 | 5764 | 'body' => lang('The mimeparser can not parse this message.').$_structure->getType(), |
@@ -4930,9 +5782,12 @@ discard block |
||
| 4930 | 5782 | { |
| 4931 | 5783 | foreach($_bodyParts as $singleBodyPart) |
| 4932 | 5784 | { |
| 4933 | - if (!isset($singleBodyPart['body'])) { |
|
| 5785 | + if (!isset($singleBodyPart['body'])) |
|
| 5786 | + { |
|
| 4934 | 5787 | $buff = self::normalizeBodyParts($singleBodyPart); |
| 4935 | - foreach ((array)$buff as $val) { $body2return[] = $val;} |
|
| 5788 | + foreach ((array)$buff as $val) |
|
| 5789 | + { |
|
| 5790 | +$body2return[] = $val;} |
|
| 4936 | 5791 | continue; |
| 4937 | 5792 | } |
| 4938 | 5793 | $body2return[] = $singleBodyPart; |
@@ -4958,13 +5813,20 @@ discard block |
||
| 4958 | 5813 | $message=''; |
| 4959 | 5814 | for($i=0; $i<count($bodyParts); $i++) |
| 4960 | 5815 | { |
| 4961 | - if (!isset($bodyParts[$i]['body'])) { |
|
| 5816 | + if (!isset($bodyParts[$i]['body'])) |
|
| 5817 | + { |
|
| 4962 | 5818 | $bodyParts[$i]['body'] = self::getdisplayableBody($mailClass, $bodyParts[$i], $preserveHTML, $useTidy); |
| 4963 | 5819 | $message .= empty($bodyParts[$i]['body'])?'':$bodyParts[$i]['body']; |
| 4964 | 5820 | continue; |
| 4965 | 5821 | } |
| 4966 | - if (isset($bodyParts[$i]['error'])) continue; |
|
| 4967 | - if (empty($bodyParts[$i]['body'])) continue; |
|
| 5822 | + if (isset($bodyParts[$i]['error'])) |
|
| 5823 | + { |
|
| 5824 | + continue; |
|
| 5825 | + } |
|
| 5826 | + if (empty($bodyParts[$i]['body'])) |
|
| 5827 | + { |
|
| 5828 | + continue; |
|
| 5829 | + } |
|
| 4968 | 5830 | // some characterreplacements, as they fail to translate |
| 4969 | 5831 | $sar = array( |
| 4970 | 5832 | '@(\x84|\x93|\x94)@', |
@@ -4991,13 +5853,17 @@ discard block |
||
| 4991 | 5853 | $bodyParts[$i]['body'] = preg_replace($sar,$rar,$bodyParts[$i]['body']); |
| 4992 | 5854 | } |
| 4993 | 5855 | |
| 4994 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Translation::detect_encoding($bodyParts[$i]['body']); |
|
| 5856 | + if ($bodyParts[$i]['charSet']===false) |
|
| 5857 | + { |
|
| 5858 | + $bodyParts[$i]['charSet'] = Translation::detect_encoding($bodyParts[$i]['body']); |
|
| 5859 | + } |
|
| 4995 | 5860 | // add line breaks to $bodyParts |
| 4996 | 5861 | //error_log(__METHOD__.' ('.__LINE__.') '.' Charset:'.$bodyParts[$i]['charSet'].'->'.$bodyParts[$i]['body']); |
| 4997 | 5862 | $newBody = Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
| 4998 | 5863 | //error_log(__METHOD__.' ('.__LINE__.') '.' MimeType:'.$bodyParts[$i]['mimeType'].'->'.$newBody); |
| 4999 | 5864 | $mailClass->activeMimeType = 'text/plain'; |
| 5000 | - if ($bodyParts[$i]['mimeType'] == 'text/html') { |
|
| 5865 | + if ($bodyParts[$i]['mimeType'] == 'text/html') |
|
| 5866 | + { |
|
| 5001 | 5867 | $mailClass->activeMimeType = $bodyParts[$i]['mimeType']; |
| 5002 | 5868 | if (!$preserveHTML) |
| 5003 | 5869 | { |
@@ -5043,15 +5909,28 @@ discard block |
||
| 5043 | 5909 | // as we switched off HTMLaweds tidy functionality |
| 5044 | 5910 | $newBody = str_replace(array('&amp;','<DIV><BR></DIV>',"<DIV> </DIV>",'<div> </div>'),array('&','<BR>','<BR>','<BR>'),$newBody); |
| 5045 | 5911 | $newBody = $htmLawed->run($newBody,self::$htmLawed_config); |
| 5046 | - if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3]; |
|
| 5912 | + if ($hasOther && $preserveHTML) |
|
| 5913 | + { |
|
| 5914 | + $newBody = $matches[1]. $newBody. $matches[3]; |
|
| 5915 | + } |
|
| 5047 | 5916 | $alreadyHtmlLawed=true; |
| 5048 | 5917 | } |
| 5049 | 5918 | //error_log(__METHOD__.' ('.__LINE__.') '.' after purify:'.$newBody); |
| 5050 | - if ($preserveHTML==false) $newBody = Mail\Html::convertHTMLToText($newBody,self::$displayCharset,true,true); |
|
| 5919 | + if ($preserveHTML==false) |
|
| 5920 | + { |
|
| 5921 | + $newBody = Mail\Html::convertHTMLToText($newBody,self::$displayCharset,true,true); |
|
| 5922 | + } |
|
| 5051 | 5923 | //error_log(__METHOD__.' ('.__LINE__.') '.' after convertHTMLToText:'.$newBody); |
| 5052 | - if ($preserveHTML==false) $newBody = nl2br($newBody); // we need this, as htmLawed removes \r\n |
|
| 5924 | + if ($preserveHTML==false) |
|
| 5925 | + { |
|
| 5926 | + $newBody = nl2br($newBody); |
|
| 5927 | + } |
|
| 5928 | + // we need this, as htmLawed removes \r\n |
|
| 5053 | 5929 | /*if (!$alreadyHtmlLawed) */ $mailClass->getCleanHTML($newBody); // remove stuff we regard as unwanted |
| 5054 | - if ($preserveHTML==false) $newBody = str_replace("<br />","\r\n",$newBody); |
|
| 5930 | + if ($preserveHTML==false) |
|
| 5931 | + { |
|
| 5932 | + $newBody = str_replace("<br />","\r\n",$newBody); |
|
| 5933 | + } |
|
| 5055 | 5934 | //error_log(__METHOD__.' ('.__LINE__.') '.' after getClean:'.$newBody); |
| 5056 | 5935 | } |
| 5057 | 5936 | $message .= $newBody; |
@@ -5088,12 +5967,12 @@ discard block |
||
| 5088 | 5967 | substr($line,0,strlen($dontbreaklinesstartingwith)) != $dontbreaklinesstartingwith |
| 5089 | 5968 | ) |
| 5090 | 5969 | ) |
| 5091 | - ) |
|
| 5092 | - { |
|
| 5970 | + ) { |
|
| 5093 | 5971 | $s=explode(" ", $line); |
| 5094 | 5972 | $line = ""; |
| 5095 | 5973 | $linecnt = 0; |
| 5096 | - foreach ($s as &$v) { |
|
| 5974 | + foreach ($s as &$v) |
|
| 5975 | + { |
|
| 5097 | 5976 | $cnt = strlen($v); |
| 5098 | 5977 | // only break long words within the wordboundaries, |
| 5099 | 5978 | // but it may destroy links, so we check for href and dont do it if we find one |
@@ -5103,14 +5982,20 @@ discard block |
||
| 5103 | 5982 | $v=wordwrap($v, $allowedLength, $cut, true); |
| 5104 | 5983 | } |
| 5105 | 5984 | // the rest should be broken at the start of the new word that exceeds the limit |
| 5106 | - if ($linecnt+$cnt > $allowedLength) { |
|
| 5985 | + if ($linecnt+$cnt > $allowedLength) |
|
| 5986 | + { |
|
| 5107 | 5987 | $v=$cut.$v; |
| 5108 | 5988 | #$linecnt = 0; |
| 5109 | 5989 | $linecnt =strlen($v)-strlen($cut); |
| 5110 | - } else { |
|
| 5990 | + } |
|
| 5991 | + else |
|
| 5992 | + { |
|
| 5111 | 5993 | $linecnt += $cnt; |
| 5112 | 5994 | } |
| 5113 | - if (strlen($v)) $line .= (strlen($line) ? " " : "").$v; |
|
| 5995 | + if (strlen($v)) |
|
| 5996 | + { |
|
| 5997 | + $line .= (strlen($line) ? " " : "").$v; |
|
| 5998 | + } |
|
| 5114 | 5999 | } |
| 5115 | 6000 | } |
| 5116 | 6001 | $newStr .= $line . "\n"; |
@@ -5131,11 +6016,18 @@ discard block |
||
| 5131 | 6016 | function getMessageEnvelope($_uid, $_partID = '',$decode=false, $_folder='', $_useHeaderInsteadOfEnvelope=false) |
| 5132 | 6017 | { |
| 5133 | 6018 | //error_log(__METHOD__.' ('.__LINE__.') '.":$_uid,$_partID,$decode,$_folder".function_backtrace()); |
| 5134 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6019 | + if (empty($_folder)) |
|
| 6020 | + { |
|
| 6021 | + $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6022 | + } |
|
| 5135 | 6023 | //error_log(__METHOD__.' ('.__LINE__.') '.":$_uid,$_partID,$decode,$_folder"); |
| 5136 | - if((empty($_partID)||$_partID=='null')&&$_useHeaderInsteadOfEnvelope===false) { |
|
| 6024 | + if((empty($_partID)||$_partID=='null')&&$_useHeaderInsteadOfEnvelope===false) |
|
| 6025 | + { |
|
| 5137 | 6026 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5138 | - if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
|
| 6027 | + if (!(is_object($_uid) || is_array($_uid))) |
|
| 6028 | + { |
|
| 6029 | + $_uid = (array)$_uid; |
|
| 6030 | + } |
|
| 5139 | 6031 | $uidsToFetch->add($_uid); |
| 5140 | 6032 | |
| 5141 | 6033 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
@@ -5145,8 +6037,10 @@ discard block |
||
| 5145 | 6037 | $headersNew = $this->icServer->fetch($_folder, $fquery, array( |
| 5146 | 6038 | 'ids' => $uidsToFetch, |
| 5147 | 6039 | )); |
| 5148 | - if (is_object($headersNew)) { |
|
| 5149 | - foreach($headersNew as &$_headerObject) { |
|
| 6040 | + if (is_object($headersNew)) |
|
| 6041 | + { |
|
| 6042 | + foreach($headersNew as &$_headerObject) |
|
| 6043 | + { |
|
| 5150 | 6044 | $env = $_headerObject->getEnvelope(); |
| 5151 | 6045 | //_debug_array($envFields->singleFields()); |
| 5152 | 6046 | $singleFields = $envFields->singleFields(); |
@@ -5163,7 +6057,10 @@ discard block |
||
| 5163 | 6057 | //error_log(__METHOD__.' ('.__LINE__.') '.$v.'->'.array2string($env->$v->addresses)); |
| 5164 | 6058 | $envelope[$v]=$env->$v->addresses; |
| 5165 | 6059 | $address = array(); |
| 5166 | - if (!is_array($envelope[$v])) break; |
|
| 6060 | + if (!is_array($envelope[$v])) |
|
| 6061 | + { |
|
| 6062 | + break; |
|
| 6063 | + } |
|
| 5167 | 6064 | foreach ($envelope[$v] as $k => $ad) |
| 5168 | 6065 | { |
| 5169 | 6066 | if (stripos($ad,'@')===false) |
@@ -5200,7 +6097,9 @@ discard block |
||
| 5200 | 6097 | } |
| 5201 | 6098 | } |
| 5202 | 6099 | return $envelope; |
| 5203 | - } else { |
|
| 6100 | + } |
|
| 6101 | + else |
|
| 6102 | + { |
|
| 5204 | 6103 | |
| 5205 | 6104 | $headers = $this->getMessageHeader($_uid, $_partID, true,true,$_folder); |
| 5206 | 6105 | |
@@ -5211,19 +6110,43 @@ discard block |
||
| 5211 | 6110 | 'SUBJECT' => ($decode ? self::decode_header($headers['SUBJECT']):$headers['SUBJECT']), |
| 5212 | 6111 | 'MESSAGE_ID' => $headers['MESSAGE-ID'] |
| 5213 | 6112 | ); |
| 5214 | - if (isset($headers['IN-REPLY-TO'])) $newData['IN-REPLY-TO'] = $headers['IN-REPLY-TO']; |
|
| 5215 | - if (isset($headers['REFERENCES'])) $newData['REFERENCES'] = $headers['REFERENCES']; |
|
| 5216 | - if (isset($headers['THREAD-TOPIC'])) $newData['THREAD-TOPIC'] = $headers['THREAD-TOPIC']; |
|
| 5217 | - if (isset($headers['THREAD-INDEX'])) $newData['THREAD-INDEX'] = $headers['THREAD-INDEX']; |
|
| 5218 | - if (isset($headers['LIST-ID'])) $newData['LIST-ID'] = $headers['LIST-ID']; |
|
| 5219 | - if (isset($headers['SIZE'])) $newData['SIZE'] = $headers['SIZE']; |
|
| 6113 | + if (isset($headers['IN-REPLY-TO'])) |
|
| 6114 | + { |
|
| 6115 | + $newData['IN-REPLY-TO'] = $headers['IN-REPLY-TO']; |
|
| 6116 | + } |
|
| 6117 | + if (isset($headers['REFERENCES'])) |
|
| 6118 | + { |
|
| 6119 | + $newData['REFERENCES'] = $headers['REFERENCES']; |
|
| 6120 | + } |
|
| 6121 | + if (isset($headers['THREAD-TOPIC'])) |
|
| 6122 | + { |
|
| 6123 | + $newData['THREAD-TOPIC'] = $headers['THREAD-TOPIC']; |
|
| 6124 | + } |
|
| 6125 | + if (isset($headers['THREAD-INDEX'])) |
|
| 6126 | + { |
|
| 6127 | + $newData['THREAD-INDEX'] = $headers['THREAD-INDEX']; |
|
| 6128 | + } |
|
| 6129 | + if (isset($headers['LIST-ID'])) |
|
| 6130 | + { |
|
| 6131 | + $newData['LIST-ID'] = $headers['LIST-ID']; |
|
| 6132 | + } |
|
| 6133 | + if (isset($headers['SIZE'])) |
|
| 6134 | + { |
|
| 6135 | + $newData['SIZE'] = $headers['SIZE']; |
|
| 6136 | + } |
|
| 5220 | 6137 | //_debug_array($newData); |
| 5221 | 6138 | $recepientList = array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO'); |
| 5222 | - foreach($recepientList as $recepientType) { |
|
| 5223 | - if(isset($headers[$recepientType])) { |
|
| 5224 | - if ($decode) $headers[$recepientType] = self::decode_header($headers[$recepientType],true); |
|
| 6139 | + foreach($recepientList as $recepientType) |
|
| 6140 | + { |
|
| 6141 | + if(isset($headers[$recepientType])) |
|
| 6142 | + { |
|
| 6143 | + if ($decode) |
|
| 6144 | + { |
|
| 6145 | + $headers[$recepientType] = self::decode_header($headers[$recepientType],true); |
|
| 6146 | + } |
|
| 5225 | 6147 | //error_log(__METHOD__.__LINE__." ".$recepientType."->".array2string($headers[$recepientType])); |
| 5226 | - foreach(self::parseAddressList($headers[$recepientType]) as $singleAddress) { |
|
| 6148 | + foreach(self::parseAddressList($headers[$recepientType]) as $singleAddress) |
|
| 6149 | + { |
|
| 5227 | 6150 | $addressData = array( |
| 5228 | 6151 | 'PERSONAL_NAME' => $singleAddress->personal ? $singleAddress->personal : 'NIL', |
| 5229 | 6152 | 'AT_DOMAIN_LIST' => $singleAddress->adl ? $singleAddress->adl : 'NIL', |
@@ -5231,17 +6154,25 @@ discard block |
||
| 5231 | 6154 | 'HOST_NAME' => $singleAddress->host ? $singleAddress->host : 'NIL', |
| 5232 | 6155 | 'EMAIL' => $singleAddress->host ? $singleAddress->mailbox.'@'.$singleAddress->host : $singleAddress->mailbox, |
| 5233 | 6156 | ); |
| 5234 | - if($addressData['PERSONAL_NAME'] != 'NIL') { |
|
| 6157 | + if($addressData['PERSONAL_NAME'] != 'NIL') |
|
| 6158 | + { |
|
| 5235 | 6159 | $addressData['RFC822_EMAIL'] = imap_rfc822_write_address($singleAddress->mailbox, $singleAddress->host, $singleAddress->personal); |
| 5236 | - } else { |
|
| 6160 | + } |
|
| 6161 | + else |
|
| 6162 | + { |
|
| 5237 | 6163 | $addressData['RFC822_EMAIL'] = 'NIL'; |
| 5238 | 6164 | } |
| 5239 | 6165 | $newData[$recepientType][] = ($addressData['RFC822_EMAIL']!='NIL'?$addressData['RFC822_EMAIL']:$addressData['EMAIL']);//$addressData; |
| 5240 | 6166 | } |
| 5241 | - } else { |
|
| 5242 | - if($recepientType == 'SENDER' || $recepientType == 'REPLY-TO') { |
|
| 6167 | + } |
|
| 6168 | + else |
|
| 6169 | + { |
|
| 6170 | + if($recepientType == 'SENDER' || $recepientType == 'REPLY-TO') |
|
| 6171 | + { |
|
| 5243 | 6172 | $newData[$recepientType] = $newData['FROM']; |
| 5244 | - } else { |
|
| 6173 | + } |
|
| 6174 | + else |
|
| 6175 | + { |
|
| 5245 | 6176 | $newData[$recepientType] = array(); |
| 5246 | 6177 | } |
| 5247 | 6178 | } |
@@ -5264,9 +6195,15 @@ discard block |
||
| 5264 | 6195 | function getMessageHeader($_uid, $_partID = '',$decode=false, $preserveUnSeen=false, $_folder='') |
| 5265 | 6196 | { |
| 5266 | 6197 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$_uid.', '.$_partID.', '.$decode.', '.$preserveUnSeen.', '.$_folder); |
| 5267 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6198 | + if (empty($_folder)) |
|
| 6199 | + { |
|
| 6200 | + $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6201 | + } |
|
| 5268 | 6202 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5269 | - if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
|
| 6203 | + if (!(is_object($_uid) || is_array($_uid))) |
|
| 6204 | + { |
|
| 6205 | + $_uid = (array)$_uid; |
|
| 6206 | + } |
|
| 5270 | 6207 | $uidsToFetch->add($_uid); |
| 5271 | 6208 | |
| 5272 | 6209 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
@@ -5284,7 +6221,8 @@ discard block |
||
| 5284 | 6221 | $headersNew = $this->icServer->fetch($_folder, $fquery, array( |
| 5285 | 6222 | 'ids' => $uidsToFetch, |
| 5286 | 6223 | )); |
| 5287 | - if (is_object($headersNew)) { |
|
| 6224 | + if (is_object($headersNew)) |
|
| 6225 | + { |
|
| 5288 | 6226 | foreach($headersNew as $_fetchObject) |
| 5289 | 6227 | { |
| 5290 | 6228 | $headers = $_fetchObject->getHeaderText(0,Horde_Imap_Client_Data_Fetch::HEADER_PARSE); |
@@ -5306,11 +6244,17 @@ discard block |
||
| 5306 | 6244 | } |
| 5307 | 6245 | if ($decode === 'object') |
| 5308 | 6246 | { |
| 5309 | - if (is_object($headers)) $headers->setUserAgent('EGroupware API '.$GLOBALS['egw_info']['server']['versions']['phpgwapi']); |
|
| 6247 | + if (is_object($headers)) |
|
| 6248 | + { |
|
| 6249 | + $headers->setUserAgent('EGroupware API '.$GLOBALS['egw_info']['server']['versions']['phpgwapi']); |
|
| 6250 | + } |
|
| 5310 | 6251 | return $headers; |
| 5311 | 6252 | } |
| 5312 | 6253 | $retValue = is_object($headers) ? $headers->toArray():array(); |
| 5313 | - if ($size) $retValue['size'] = $size; |
|
| 6254 | + if ($size) |
|
| 6255 | + { |
|
| 6256 | + $retValue['size'] = $size; |
|
| 6257 | + } |
|
| 5314 | 6258 | } |
| 5315 | 6259 | $retValue = array_change_key_case($retValue,CASE_UPPER); |
| 5316 | 6260 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($retValue)); |
@@ -5342,10 +6286,16 @@ discard block |
||
| 5342 | 6286 | function getMessageRawHeader($_uid, $_partID = '', $_folder = '') |
| 5343 | 6287 | { |
| 5344 | 6288 | static $rawHeaders; |
| 5345 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6289 | + if (empty($_folder)) |
|
| 6290 | + { |
|
| 6291 | + $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6292 | + } |
|
| 5346 | 6293 | //error_log(__METHOD__.' ('.__LINE__.') '." Try Using Cache for raw Header $_uid, $_partID in Folder $_folder"); |
| 5347 | 6294 | |
| 5348 | - if (is_null($rawHeaders)||!is_array($rawHeaders)) $rawHeaders = Cache::getCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 6295 | + if (is_null($rawHeaders)||!is_array($rawHeaders)) |
|
| 6296 | + { |
|
| 6297 | + $rawHeaders = Cache::getCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 6298 | + } |
|
| 5349 | 6299 | if (isset($rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID)?'NIL':$_partID)])) |
| 5350 | 6300 | { |
| 5351 | 6301 | //error_log(__METHOD__.' ('.__LINE__.') '." Using Cache for raw Header $_uid, $_partID in Folder $_folder"); |
@@ -5353,7 +6303,10 @@ discard block |
||
| 5353 | 6303 | } |
| 5354 | 6304 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5355 | 6305 | $uid = $_uid; |
| 5356 | - if (!(is_object($_uid) || is_array($_uid))) $uid = (array)$_uid; |
|
| 6306 | + if (!(is_object($_uid) || is_array($_uid))) |
|
| 6307 | + { |
|
| 6308 | + $uid = (array)$_uid; |
|
| 6309 | + } |
|
| 5357 | 6310 | $uidsToFetch->add($uid); |
| 5358 | 6311 | |
| 5359 | 6312 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
@@ -5369,8 +6322,10 @@ discard block |
||
| 5369 | 6322 | $headersNew = $this->icServer->fetch($_folder, $fquery, array( |
| 5370 | 6323 | 'ids' => $uidsToFetch, |
| 5371 | 6324 | )); |
| 5372 | - if (is_object($headersNew)) { |
|
| 5373 | - foreach($headersNew as &$_headerObject) { |
|
| 6325 | + if (is_object($headersNew)) |
|
| 6326 | + { |
|
| 6327 | + foreach($headersNew as &$_headerObject) |
|
| 6328 | + { |
|
| 5374 | 6329 | $retValue = $_headerObject->getHeaderText(); |
| 5375 | 6330 | if ($_partID != '') |
| 5376 | 6331 | { |
@@ -5398,22 +6353,33 @@ discard block |
||
| 5398 | 6353 | static function &getStyles($_bodyParts) |
| 5399 | 6354 | { |
| 5400 | 6355 | $style = ''; |
| 5401 | - if (empty($_bodyParts)) return ""; |
|
| 5402 | - foreach((array)$_bodyParts as $singleBodyPart) { |
|
| 5403 | - if (!isset($singleBodyPart['body'])) { |
|
| 6356 | + if (empty($_bodyParts)) |
|
| 6357 | + { |
|
| 6358 | + return ""; |
|
| 6359 | + } |
|
| 6360 | + foreach((array)$_bodyParts as $singleBodyPart) |
|
| 6361 | + { |
|
| 6362 | + if (!isset($singleBodyPart['body'])) |
|
| 6363 | + { |
|
| 5404 | 6364 | $singleBodyPart['body'] = self::getStyles($singleBodyPart); |
| 5405 | 6365 | $style .= $singleBodyPart['body']; |
| 5406 | 6366 | continue; |
| 5407 | 6367 | } |
| 5408 | 6368 | |
| 5409 | - if ($singleBodyPart['charSet']===false) $singleBodyPart['charSet'] = Translation::detect_encoding($singleBodyPart['body']); |
|
| 6369 | + if ($singleBodyPart['charSet']===false) |
|
| 6370 | + { |
|
| 6371 | + $singleBodyPart['charSet'] = Translation::detect_encoding($singleBodyPart['body']); |
|
| 6372 | + } |
|
| 5410 | 6373 | $singleBodyPart['body'] = Translation::convert( |
| 5411 | 6374 | $singleBodyPart['body'], |
| 5412 | 6375 | strtolower($singleBodyPart['charSet']) |
| 5413 | 6376 | ); |
| 5414 | 6377 | $ct = 0; |
| 5415 | 6378 | $newStyle=array(); |
| 5416 | - if (stripos($singleBodyPart['body'],'<style')!==false) $ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $singleBodyPart['body'], $newStyle); |
|
| 6379 | + if (stripos($singleBodyPart['body'],'<style')!==false) |
|
| 6380 | + { |
|
| 6381 | + $ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $singleBodyPart['body'], $newStyle); |
|
| 6382 | + } |
|
| 5417 | 6383 | if ($ct>0) |
| 5418 | 6384 | { |
| 5419 | 6385 | //error_log(__METHOD__.' ('.__LINE__.') '.'#'.$ct.'#'.array2string($newStyle)); |
@@ -5445,7 +6411,11 @@ discard block |
||
| 5445 | 6411 | // CSS Security |
| 5446 | 6412 | // http://code.google.com/p/browsersec/wiki/Part1#Cascading_stylesheets |
| 5447 | 6413 | $css = preg_replace('/(javascript|expression|-moz-binding)/i','',$style); |
| 5448 | - if (stripos($css,'script')!==false) Mail\Html::replaceTagsCompletley($css,'script'); // Strip out script that may be included |
|
| 6414 | + if (stripos($css,'script')!==false) |
|
| 6415 | + { |
|
| 6416 | + Mail\Html::replaceTagsCompletley($css,'script'); |
|
| 6417 | + } |
|
| 6418 | + // Strip out script that may be included |
|
| 5449 | 6419 | // we need this, as styledefinitions are enclosed with curly brackets; and template stuff tries to replace everything between curly brackets that is having no horizontal whitespace |
| 5450 | 6420 | // as the comments as <!-- styledefinition --> in stylesheet are outdated, and ck-editor does not understand it, we remove it |
| 5451 | 6421 | $css = str_replace(array(':','<!--','-->'),array(': ','',''),$css); |
@@ -5467,8 +6437,14 @@ discard block |
||
| 5467 | 6437 | { |
| 5468 | 6438 | //TODO: caching einbauen static! |
| 5469 | 6439 | static $rawBody; |
| 5470 | - if (is_null($rawBody)) $rawBody = array(); |
|
| 5471 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6440 | + if (is_null($rawBody)) |
|
| 6441 | + { |
|
| 6442 | + $rawBody = array(); |
|
| 6443 | + } |
|
| 6444 | + if (empty($_folder)) |
|
| 6445 | + { |
|
| 6446 | + $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6447 | + } |
|
| 5472 | 6448 | if (!$_stream && isset($rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID)?'NIL':$_partID)])) |
| 5473 | 6449 | { |
| 5474 | 6450 | //error_log(__METHOD__.' ('.__LINE__.') '." Using Cache for raw Body $_uid, $_partID in Folder $_folder"); |
@@ -5477,7 +6453,10 @@ discard block |
||
| 5477 | 6453 | |
| 5478 | 6454 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5479 | 6455 | $uid = $_uid; |
| 5480 | - if (!(is_object($_uid) || is_array($_uid))) $uid = (array)$_uid; |
|
| 6456 | + if (!(is_object($_uid) || is_array($_uid))) |
|
| 6457 | + { |
|
| 6458 | + $uid = (array)$_uid; |
|
| 6459 | + } |
|
| 5481 | 6460 | $uidsToFetch->add($uid); |
| 5482 | 6461 | |
| 5483 | 6462 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
@@ -5490,8 +6469,10 @@ discard block |
||
| 5490 | 6469 | $headersNew = $this->icServer->fetch($_folder, $fquery, array( |
| 5491 | 6470 | 'ids' => $uidsToFetch, |
| 5492 | 6471 | )); |
| 5493 | - if (is_object($headersNew)) { |
|
| 5494 | - foreach($headersNew as &$_headerObject) { |
|
| 6472 | + if (is_object($headersNew)) |
|
| 6473 | + { |
|
| 6474 | + foreach($headersNew as &$_headerObject) |
|
| 6475 | + { |
|
| 5495 | 6476 | $body = $_headerObject->getFullMsg($_stream); |
| 5496 | 6477 | if ($_partID != '') |
| 5497 | 6478 | { |
@@ -5527,14 +6508,20 @@ discard block |
||
| 5527 | 6508 | */ |
| 5528 | 6509 | function getStructure($_uid, $_partID=null, $_folder=null, $_preserveSeen=false) |
| 5529 | 6510 | { |
| 5530 | - if (self::$debug) error_log( __METHOD__.' ('.__LINE__.') '.":$_uid, $_partID"); |
|
| 6511 | + if (self::$debug) |
|
| 6512 | + { |
|
| 6513 | + error_log( __METHOD__.' ('.__LINE__.') '.":$_uid, $_partID"); |
|
| 6514 | + } |
|
| 5531 | 6515 | |
| 5532 | 6516 | if (empty($_folder)) |
| 5533 | 6517 | { |
| 5534 | 6518 | $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
| 5535 | 6519 | } |
| 5536 | 6520 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5537 | - if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
|
| 6521 | + if (!(is_object($_uid) || is_array($_uid))) |
|
| 6522 | + { |
|
| 6523 | + $_uid = (array)$_uid; |
|
| 6524 | + } |
|
| 5538 | 6525 | $uidsToFetch->add($_uid); |
| 5539 | 6526 | try |
| 5540 | 6527 | { |
@@ -5543,7 +6530,10 @@ discard block |
||
| 5543 | 6530 | // $fquery->envelope(); |
| 5544 | 6531 | // $fquery->size(); |
| 5545 | 6532 | $_fquery->structure(); |
| 5546 | - if ($_partID) $_fquery->bodyPart($_partID, array('peek' => $_preserveSeen)); |
|
| 6533 | + if ($_partID) |
|
| 6534 | + { |
|
| 6535 | + $_fquery->bodyPart($_partID, array('peek' => $_preserveSeen)); |
|
| 6536 | + } |
|
| 5547 | 6537 | |
| 5548 | 6538 | $mail = $this->icServer->fetch($_folder, $_fquery, array( |
| 5549 | 6539 | 'ids' => $uidsToFetch, |
@@ -5574,16 +6564,28 @@ discard block |
||
| 5574 | 6564 | */ |
| 5575 | 6565 | function getMessageAttachments($_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folder='') |
| 5576 | 6566 | { |
| 5577 | - if (self::$debug) error_log( __METHOD__.":$_uid, $_partID"); |
|
| 5578 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6567 | + if (self::$debug) |
|
| 6568 | + { |
|
| 6569 | + error_log( __METHOD__.":$_uid, $_partID"); |
|
| 6570 | + } |
|
| 6571 | + if (empty($_folder)) |
|
| 6572 | + { |
|
| 6573 | + $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6574 | + } |
|
| 5579 | 6575 | $attachments = array(); |
| 5580 | 6576 | if (!isset($_structure)) |
| 5581 | 6577 | { |
| 5582 | 6578 | $_structure = $this->getStructure($_uid, $_partID,$_folder,true); |
| 5583 | 6579 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.print_r($_structure->contentTypeMap(),true)); |
| 5584 | 6580 | } |
| 5585 | - if (!$_structure || !$_structure->contentTypeMap()) return array(); |
|
| 5586 | - if (!empty($_partID)) $_structure = $_structure->getPart($_partID); |
|
| 6581 | + if (!$_structure || !$_structure->contentTypeMap()) |
|
| 6582 | + { |
|
| 6583 | + return array(); |
|
| 6584 | + } |
|
| 6585 | + if (!empty($_partID)) |
|
| 6586 | + { |
|
| 6587 | + $_structure = $_structure->getPart($_partID); |
|
| 6588 | + } |
|
| 5587 | 6589 | $skipParts = array(); |
| 5588 | 6590 | $tnefParts = array(); |
| 5589 | 6591 | $skip = 0; |
@@ -5612,7 +6614,13 @@ discard block |
||
| 5612 | 6614 | if ($mime_type=='message/rfc822' && $_partID!=$mime_id) |
| 5613 | 6615 | { |
| 5614 | 6616 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.':'.array2string($part->contentTypeMap())); |
| 5615 | - foreach($part->contentTypeMap() as $sub_id => $sub_type) {if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type;} |
|
| 6617 | + foreach($part->contentTypeMap() as $sub_id => $sub_type) |
|
| 6618 | + { |
|
| 6619 | +if ($sub_id != $mime_id) |
|
| 6620 | + { |
|
| 6621 | + $skipParts[$sub_id] = $sub_type; |
|
| 6622 | + } |
|
| 6623 | + } |
|
| 5616 | 6624 | } |
| 5617 | 6625 | if (empty($partDisposition) && $partPrimaryType != 'multipart' && $partPrimaryType != 'text') |
| 5618 | 6626 | { |
@@ -5623,7 +6631,10 @@ discard block |
||
| 5623 | 6631 | $partDisposition='attachment'; |
| 5624 | 6632 | } |
| 5625 | 6633 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.' Part:'.$_partID.'->'.$mime_id.':'.array2string($skipParts)); |
| 5626 | - if (array_key_exists($mime_id,$skipParts)) continue; |
|
| 6634 | + if (array_key_exists($mime_id,$skipParts)) |
|
| 6635 | + { |
|
| 6636 | + continue; |
|
| 6637 | + } |
|
| 5627 | 6638 | |
| 5628 | 6639 | if ($partDisposition == 'attachment' || |
| 5629 | 6640 | (($partDisposition == 'inline' || empty($partDisposition)) && $partPrimaryType == 'image' && $part->getContentId()=='') || |
@@ -5634,23 +6645,41 @@ discard block |
||
| 5634 | 6645 | { |
| 5635 | 6646 | // if type is message/rfc822 and _partID is given, and MimeID equals partID |
| 5636 | 6647 | // we attempt to fetch "ourselves" |
| 5637 | - if ($_partID==$part->getMimeId() && $part->getPrimaryType()=='message') continue; |
|
| 6648 | + if ($_partID==$part->getMimeId() && $part->getPrimaryType()=='message') |
|
| 6649 | + { |
|
| 6650 | + continue; |
|
| 6651 | + } |
|
| 5638 | 6652 | $attachment = $part->getAllDispositionParameters(); |
| 5639 | 6653 | $attachment['disposition'] = $part->getDisposition(); |
| 5640 | 6654 | $attachment['mimeType'] = $mime_type; |
| 5641 | 6655 | $attachment['uid'] = $_uid; |
| 5642 | 6656 | $attachment['partID'] = $mime_id; |
| 5643 | - if (!isset($attachment['name'])||empty($attachment['name'])) $attachment['name'] = $part->getName(); |
|
| 6657 | + if (!isset($attachment['name'])||empty($attachment['name'])) |
|
| 6658 | + { |
|
| 6659 | + $attachment['name'] = $part->getName(); |
|
| 6660 | + } |
|
| 5644 | 6661 | if ($fetchTextCalendar) |
| 5645 | 6662 | { |
| 5646 | 6663 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($part->getAllContentTypeParameters())); |
| 5647 | 6664 | $method = $part->getContentTypeParameter('method'); |
| 5648 | - if ($method) $attachment['method'] = $method; |
|
| 5649 | - if (!isset($attachment['name'])) $attachment['name'] = 'event.ics'; |
|
| 6665 | + if ($method) |
|
| 6666 | + { |
|
| 6667 | + $attachment['method'] = $method; |
|
| 6668 | + } |
|
| 6669 | + if (!isset($attachment['name'])) |
|
| 6670 | + { |
|
| 6671 | + $attachment['name'] = 'event.ics'; |
|
| 6672 | + } |
|
| 5650 | 6673 | } |
| 5651 | 6674 | $attachment['size'] = $part->getBytes(); |
| 5652 | - if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
|
| 5653 | - if (empty($attachment['name'])) $attachment['name'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($mime_type); |
|
| 6675 | + if (($cid = $part->getContentId())) |
|
| 6676 | + { |
|
| 6677 | + $attachment['cid'] = $cid; |
|
| 6678 | + } |
|
| 6679 | + if (empty($attachment['name'])) |
|
| 6680 | + { |
|
| 6681 | + $attachment['name'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($mime_type); |
|
| 6682 | + } |
|
| 5654 | 6683 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.' Part:'.$_partID.'->'.$mime_id.':'.array2string($attachment)); |
| 5655 | 6684 | //typical winmail.dat attachment is |
| 5656 | 6685 | //Array([size] => 1462762[filename] => winmail.dat[mimeType] => application/ms-tnef[uid] => 100[partID] => 2[name] => winmail.dat) |
@@ -5686,14 +6715,26 @@ discard block |
||
| 5686 | 6715 | $attachment['uid'] = $tnp['uid']; |
| 5687 | 6716 | $attachment['partID'] = $tnp['partID']; |
| 5688 | 6717 | $attachment['is_winmail'] = $tnp['uid'].'@'.$tnp['partID'].'@'.$mime_id; |
| 5689 | - if (!isset($attachment['name'])||empty($attachment['name'])) $attachment['name'] = $part->getName(); |
|
| 6718 | + if (!isset($attachment['name'])||empty($attachment['name'])) |
|
| 6719 | + { |
|
| 6720 | + $attachment['name'] = $part->getName(); |
|
| 6721 | + } |
|
| 5690 | 6722 | $attachment['size'] = $part->getBytes(); |
| 5691 | - if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
|
| 5692 | - if (empty($attachment['name'])) $attachment['name'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']); |
|
| 6723 | + if (($cid = $part->getContentId())) |
|
| 6724 | + { |
|
| 6725 | + $attachment['cid'] = $cid; |
|
| 6726 | + } |
|
| 6727 | + if (empty($attachment['name'])) |
|
| 6728 | + { |
|
| 6729 | + $attachment['name'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']); |
|
| 6730 | + } |
|
| 5693 | 6731 | $attachments[] = $attachment; |
| 5694 | 6732 | } |
| 5695 | 6733 | } |
| 5696 | - if ($tnefResolved===false) $attachments[]=$tnp; |
|
| 6734 | + if ($tnefResolved===false) |
|
| 6735 | + { |
|
| 6736 | + $attachments[]=$tnp; |
|
| 6737 | + } |
|
| 5697 | 6738 | } |
| 5698 | 6739 | } |
| 5699 | 6740 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
@@ -5797,8 +6838,14 @@ discard block |
||
| 5797 | 6838 | |
| 5798 | 6839 | $attachment = $part->getAllDispositionParameters(); |
| 5799 | 6840 | $attachment['mimeType'] = $part->getType(); |
| 5800 | - if (!isset($attachment['filename'])||empty($attachment['filename'])) $attachment['filename'] = $part->getName(); |
|
| 5801 | - if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
|
| 6841 | + if (!isset($attachment['filename'])||empty($attachment['filename'])) |
|
| 6842 | + { |
|
| 6843 | + $attachment['filename'] = $part->getName(); |
|
| 6844 | + } |
|
| 6845 | + if (($cid = $part->getContentId())) |
|
| 6846 | + { |
|
| 6847 | + $attachment['cid'] = $cid; |
|
| 6848 | + } |
|
| 5802 | 6849 | if (empty($attachment['filename'])) |
| 5803 | 6850 | { |
| 5804 | 6851 | $attachment['filename'] = (isset($attachment['cid'])&&!empty($attachment['cid'])? |
@@ -5810,7 +6857,10 @@ discard block |
||
| 5810 | 6857 | $attachments[$_uid.'@'.$_partID.'@'.$mime_id] = $attachment; |
| 5811 | 6858 | } |
| 5812 | 6859 | } |
| 5813 | - if (!is_array($attachments)) return false; |
|
| 6860 | + if (!is_array($attachments)) |
|
| 6861 | + { |
|
| 6862 | + return false; |
|
| 6863 | + } |
|
| 5814 | 6864 | return $attachments; |
| 5815 | 6865 | } |
| 5816 | 6866 | |
@@ -5829,10 +6879,16 @@ discard block |
||
| 5829 | 6879 | function getAttachment($_uid, $_partID, $_winmail_nr=0, $_returnPart=true, $_stream=false, $_folder=null) |
| 5830 | 6880 | { |
| 5831 | 6881 | //error_log(__METHOD__.__LINE__."Uid:$_uid, PartId:$_partID, WinMailNr:$_winmail_nr, ReturnPart:$_returnPart, Stream:$_stream, Folder:$_folder".function_backtrace()); |
| 5832 | - if (!isset($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6882 | + if (!isset($_folder)) |
|
| 6883 | + { |
|
| 6884 | + $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6885 | + } |
|
| 5833 | 6886 | |
| 5834 | 6887 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5835 | - if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
|
| 6888 | + if (!(is_object($_uid) || is_array($_uid))) |
|
| 6889 | + { |
|
| 6890 | + $_uid = (array)$_uid; |
|
| 6891 | + } |
|
| 5836 | 6892 | $uidsToFetch->add($_uid); |
| 5837 | 6893 | |
| 5838 | 6894 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
@@ -5841,8 +6897,10 @@ discard block |
||
| 5841 | 6897 | $headersNew = $this->icServer->fetch($_folder, $fquery, array( |
| 5842 | 6898 | 'ids' => $uidsToFetch, |
| 5843 | 6899 | )); |
| 5844 | - if (is_object($headersNew)) { |
|
| 5845 | - foreach($headersNew as $id=>$_headerObject) { |
|
| 6900 | + if (is_object($headersNew)) |
|
| 6901 | + { |
|
| 6902 | + foreach($headersNew as $id=>$_headerObject) |
|
| 6903 | + { |
|
| 5846 | 6904 | $body = $_headerObject->getFullMsg(); |
| 5847 | 6905 | if ($_partID != '') |
| 5848 | 6906 | { |
@@ -5856,7 +6914,10 @@ discard block |
||
| 5856 | 6914 | } |
| 5857 | 6915 | // if $partDisposition is empty, we assume attachment, and hope that the function |
| 5858 | 6916 | // itself is only triggered to fetch attachments |
| 5859 | - if (empty($partDisposition)) $partDisposition='attachment'; |
|
| 6917 | + if (empty($partDisposition)) |
|
| 6918 | + { |
|
| 6919 | + $partDisposition='attachment'; |
|
| 6920 | + } |
|
| 5860 | 6921 | if ($part && ($partDisposition=='attachment' || $partDisposition=='inline' || ($part->getPrimaryType() == 'text' && $part->getSubType() == 'calendar'))) |
| 5861 | 6922 | { |
| 5862 | 6923 | //$headerObject=$part->getAllDispositionParameters();//not used anywhere around here |
@@ -5865,13 +6926,19 @@ discard block |
||
| 5865 | 6926 | $charset = $part->getContentTypeParameter('charset'); |
| 5866 | 6927 | //$structure_bytes = $part->getBytes(); $structure_partID=$part->getMimeId(); error_log(__METHOD__.__LINE__." fetchPartContents(".array2string($_uid).", $structure_partID, $_stream, $_preserveSeen,$structure_mime)" ); |
| 5867 | 6928 | $this->fetchPartContents($_uid, $part, $_stream, $_preserveSeen=true,$structure_mime); |
| 5868 | - if ($_returnPart) return $part; |
|
| 6929 | + if ($_returnPart) |
|
| 6930 | + { |
|
| 6931 | + return $part; |
|
| 6932 | + } |
|
| 5869 | 6933 | } |
| 5870 | 6934 | } |
| 5871 | 6935 | } |
| 5872 | 6936 | } |
| 5873 | 6937 | $ext = MimeMagic::mime2ext($structure_mime); |
| 5874 | - if ($ext && stripos($filename,'.')===false && stripos($filename,$ext)===false) $filename = trim($filename).'.'.$ext; |
|
| 6938 | + if ($ext && stripos($filename,'.')===false && stripos($filename,$ext)===false) |
|
| 6939 | + { |
|
| 6940 | + $filename = trim($filename).'.'.$ext; |
|
| 6941 | + } |
|
| 5875 | 6942 | if (!$part) |
| 5876 | 6943 | { |
| 5877 | 6944 | throw new Exception\WrongParameter("Error: Could not fetch attachment for Uid=".array2string($_uid).", PartId=$_partID, WinMailNr=$_winmail_nr, folder=$_folder"); |
@@ -5887,7 +6954,10 @@ discard block |
||
| 5887 | 6954 | ); |
| 5888 | 6955 | |
| 5889 | 6956 | // try guessing the mimetype, if we get the application/octet-stream |
| 5890 | - if (strtolower($attachmentData['type']) == 'application/octet-stream') $attachmentData['type'] = MimeMagic::filename2mime($attachmentData['filename']); |
|
| 6957 | + if (strtolower($attachmentData['type']) == 'application/octet-stream') |
|
| 6958 | + { |
|
| 6959 | + $attachmentData['type'] = MimeMagic::filename2mime($attachmentData['filename']); |
|
| 6960 | + } |
|
| 5891 | 6961 | # if the attachment holds a winmail number and is a winmail.dat then we have to handle that. |
| 5892 | 6962 | if ( $filename == 'winmail.dat' && $_winmail_nr) |
| 5893 | 6963 | { |
@@ -5910,9 +6980,18 @@ discard block |
||
| 5910 | 6980 | if ($_winmail_nr == $wantedPart.'@'.$mime_id) |
| 5911 | 6981 | { |
| 5912 | 6982 | //error_log(__METHOD__.__LINE__.'#'.$structure_mime.'#'.$filename.'#'.array2string($attachment)); |
| 5913 | - if (!isset($attachment['filename'])||empty($attachment['filename'])) $attachment['filename'] = $part->getName(); |
|
| 5914 | - if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
|
| 5915 | - if (empty($attachment['filename'])) $attachment['filename'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']); |
|
| 6983 | + if (!isset($attachment['filename'])||empty($attachment['filename'])) |
|
| 6984 | + { |
|
| 6985 | + $attachment['filename'] = $part->getName(); |
|
| 6986 | + } |
|
| 6987 | + if (($cid = $part->getContentId())) |
|
| 6988 | + { |
|
| 6989 | + $attachment['cid'] = $cid; |
|
| 6990 | + } |
|
| 6991 | + if (empty($attachment['filename'])) |
|
| 6992 | + { |
|
| 6993 | + $attachment['filename'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']); |
|
| 6994 | + } |
|
| 5916 | 6995 | $wmattach = $attachment; |
| 5917 | 6996 | $wmattach['attachment'] = $part->getContents(array('stream'=>$_stream)); |
| 5918 | 6997 | |
@@ -5922,7 +7001,10 @@ discard block |
||
| 5922 | 7001 | if ($tnefResolved) |
| 5923 | 7002 | { |
| 5924 | 7003 | $ext = MimeMagic::mime2ext($wmattach['mimeType']); |
| 5925 | - if ($ext && stripos($wmattach['filename'],'.')===false && stripos($wmattach['filename'],$ext)===false) $wmattach['filename'] = trim($wmattach['filename']).'.'.$ext; |
|
| 7004 | + if ($ext && stripos($wmattach['filename'],'.')===false && stripos($wmattach['filename'],$ext)===false) |
|
| 7005 | + { |
|
| 7006 | + $wmattach['filename'] = trim($wmattach['filename']).'.'.$ext; |
|
| 7007 | + } |
|
| 5926 | 7008 | $attachmentData = array( |
| 5927 | 7009 | 'type' => $wmattach['mimeType'], |
| 5928 | 7010 | 'filename' => $wmattach['filename'], |
@@ -5952,7 +7034,10 @@ discard block |
||
| 5952 | 7034 | static $uid=null, $part=null, $structure=null; |
| 5953 | 7035 | //error_log(__METHOD__.' ('.__LINE__.') '.":$_uid, $_cid, $_part"); |
| 5954 | 7036 | |
| 5955 | - if(empty($_cid)) return false; |
|
| 7037 | + if(empty($_cid)) |
|
| 7038 | + { |
|
| 7039 | + return false; |
|
| 7040 | + } |
|
| 5956 | 7041 | |
| 5957 | 7042 | if ($_uid != $uid || $_part != $part) |
| 5958 | 7043 | { |
@@ -5977,13 +7062,19 @@ discard block |
||
| 5977 | 7062 | $attachment = $part; |
| 5978 | 7063 | } |
| 5979 | 7064 | // everything else we only consider after we checked all |
| 5980 | - if (!isset($attachment)) $attachment = $part; |
|
| 7065 | + if (!isset($attachment)) |
|
| 7066 | + { |
|
| 7067 | + $attachment = $part; |
|
| 7068 | + } |
|
| 5981 | 7069 | // do we want content fetched, can be done later, if not needed |
| 5982 | 7070 | if (isset($_stream)) |
| 5983 | 7071 | { |
| 5984 | 7072 | $this->fetchPartContents($_uid, $attachment, $_stream); |
| 5985 | 7073 | } |
| 5986 | - if (isset($attachment)) break; |
|
| 7074 | + if (isset($attachment)) |
|
| 7075 | + { |
|
| 7076 | + break; |
|
| 7077 | + } |
|
| 5987 | 7078 | } |
| 5988 | 7079 | } |
| 5989 | 7080 | // set name as filename, if not set |
@@ -6014,10 +7105,17 @@ discard block |
||
| 6014 | 7105 | */ |
| 6015 | 7106 | public function fetchPartContents($_uid, Horde_Mime_Part $part=null, $_stream=false, $_preserveSeen=false, $_mimetype=null) |
| 6016 | 7107 | { |
| 6017 | - if (is_null($part)) return null;//new Horde_Mime_Part; |
|
| 7108 | + if (is_null($part)) |
|
| 7109 | + { |
|
| 7110 | + return null; |
|
| 7111 | + } |
|
| 7112 | + //new Horde_Mime_Part; |
|
| 6018 | 7113 | $encoding = null; |
| 6019 | 7114 | $fetchAsBinary = true; |
| 6020 | - if ($_mimetype && strtolower($_mimetype)=='message/rfc822') $fetchAsBinary = false; |
|
| 7115 | + if ($_mimetype && strtolower($_mimetype)=='message/rfc822') |
|
| 7116 | + { |
|
| 7117 | + $fetchAsBinary = false; |
|
| 7118 | + } |
|
| 6021 | 7119 | // we need to set content on structure to decode transfer encoding |
| 6022 | 7120 | $part->setContents( |
| 6023 | 7121 | $this->getBodyPart($_uid, $part->getMimeId(), null, $_preserveSeen, $_stream, $encoding, $fetchAsBinary), |
@@ -6054,7 +7152,10 @@ discard block |
||
| 6054 | 7152 | // the recent flag is the default enforced here ; as we assume the _flags is always set, |
| 6055 | 7153 | // we default it to hordes default (Recent) (, other wise we should not pass the parameter |
| 6056 | 7154 | // for flags at all) |
| 6057 | - if (empty($_flags)) $_flags = '\\Recent'; |
|
| 7155 | + if (empty($_flags)) |
|
| 7156 | + { |
|
| 7157 | + $_flags = '\\Recent'; |
|
| 7158 | + } |
|
| 6058 | 7159 | //if (!is_array($_flags) && stripos($_flags,',')!==false) $_flags=explode(',',$_flags); |
| 6059 | 7160 | //if (!is_array($_flags)) $_flags = (array) $_flags; |
| 6060 | 7161 | try |
@@ -6071,18 +7172,27 @@ discard block |
||
| 6071 | 7172 | } |
| 6072 | 7173 | catch (\Exception $e) |
| 6073 | 7174 | { |
| 6074 | - if (self::$debug) error_log("Could not append Message: ".$e->getMessage()); |
|
| 7175 | + if (self::$debug) |
|
| 7176 | + { |
|
| 7177 | + error_log("Could not append Message: ".$e->getMessage()); |
|
| 7178 | + } |
|
| 6075 | 7179 | throw new Exception\WrongUserinput(lang("Could not append Message:").' '.$e->getMessage().': '.$e->details); |
| 6076 | 7180 | //return false; |
| 6077 | 7181 | } |
| 6078 | 7182 | //error_log(__METHOD__.' ('.__LINE__.') '.' appended UID:'.$messageid); |
| 6079 | 7183 | //$messageid = true; // for debug reasons only |
| 6080 | - if ($messageid === true || empty($messageid)) // try to figure out the message uid |
|
| 7184 | + if ($messageid === true || empty($messageid)) |
|
| 7185 | + { |
|
| 7186 | + // try to figure out the message uid |
|
| 6081 | 7187 | { |
| 6082 | 7188 | $list = $this->getHeaders($_folderName, $_startMessage=1, 1, 'INTERNALDATE', true, array(),null, false); |
| 7189 | + } |
|
| 6083 | 7190 | if ($list) |
| 6084 | 7191 | { |
| 6085 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' MessageUid:'.$messageid.' but found:'.array2string($list)); |
|
| 7192 | + if (self::$debug) |
|
| 7193 | + { |
|
| 7194 | + error_log(__METHOD__.' ('.__LINE__.') '.' MessageUid:'.$messageid.' but found:'.array2string($list)); |
|
| 7195 | + } |
|
| 6086 | 7196 | $messageid = $list['header'][0]['uid']; |
| 6087 | 7197 | } |
| 6088 | 7198 | } |
@@ -6123,7 +7233,10 @@ discard block |
||
| 6123 | 7233 | { |
| 6124 | 7234 | //echo __METHOD__." called for $uid,$partid <br>"; |
| 6125 | 7235 | $headers = $mailClass->getMessageHeader($uid,$partid,true,false,$mailbox); |
| 6126 | - if (empty($headers)) return false; |
|
| 7236 | + if (empty($headers)) |
|
| 7237 | + { |
|
| 7238 | + return false; |
|
| 7239 | + } |
|
| 6127 | 7240 | // dont force retrieval of the textpart, let mailClass preferences decide |
| 6128 | 7241 | $bodyParts = $mailClass->getMessageBody($uid,($preserveHTML?'always_display':'only_if_no_text'),$partid,null,false,$mailbox); |
| 6129 | 7242 | // if we do not want HTML but there is no TextRepresentation with the message itself, try converting |
@@ -6141,15 +7254,30 @@ discard block |
||
| 6141 | 7254 | //error_log(array2string($bodyParts)); |
| 6142 | 7255 | $attachments = $includeAttachments?$mailClass->getMessageAttachments($uid,$partid,null,true,false,true,$mailbox):array(); |
| 6143 | 7256 | |
| 6144 | - if ($mailClass->isSentFolder($mailbox)) $mailaddress = $headers['TO']; |
|
| 6145 | - elseif (isset($headers['FROM'])) $mailaddress = $headers['FROM']; |
|
| 6146 | - elseif (isset($headers['SENDER'])) $mailaddress = $headers['SENDER']; |
|
| 6147 | - if (isset($headers['CC'])) $mailaddress .= ','.$headers['CC']; |
|
| 7257 | + if ($mailClass->isSentFolder($mailbox)) |
|
| 7258 | + { |
|
| 7259 | + $mailaddress = $headers['TO']; |
|
| 7260 | + } |
|
| 7261 | + elseif (isset($headers['FROM'])) |
|
| 7262 | + { |
|
| 7263 | + $mailaddress = $headers['FROM']; |
|
| 7264 | + } |
|
| 7265 | + elseif (isset($headers['SENDER'])) |
|
| 7266 | + { |
|
| 7267 | + $mailaddress = $headers['SENDER']; |
|
| 7268 | + } |
|
| 7269 | + if (isset($headers['CC'])) |
|
| 7270 | + { |
|
| 7271 | + $mailaddress .= ','.$headers['CC']; |
|
| 7272 | + } |
|
| 6148 | 7273 | //_debug_array(array($headers,$mailaddress)); |
| 6149 | 7274 | $subject = $headers['SUBJECT']; |
| 6150 | 7275 | |
| 6151 | 7276 | $message = self::getdisplayableBody($mailClass, $bodyParts, $preserveHTML); |
| 6152 | - if ($preserveHTML && $mailClass->activeMimeType == 'text/plain') $message = '<pre>'.$message.'</pre>'; |
|
| 7277 | + if ($preserveHTML && $mailClass->activeMimeType == 'text/plain') |
|
| 7278 | + { |
|
| 7279 | + $message = '<pre>'.$message.'</pre>'; |
|
| 7280 | + } |
|
| 6153 | 7281 | $headdata = ($addHeaderSection ? self::createHeaderInfoSection($headers, '',$preserveHTML) : ''); |
| 6154 | 7282 | $message = $headdata.$message; |
| 6155 | 7283 | //echo __METHOD__.'<br>'; |
@@ -6200,7 +7328,8 @@ discard block |
||
| 6200 | 7328 | $attachments[$num]['attachment'] = $c->getContents(); |
| 6201 | 7329 | } |
| 6202 | 7330 | // no attempt to convert, if we dont know about the charset |
| 6203 | - if (isset($attachments[$num]['charset'])&&!empty($attachments[$num]['charset'])) { |
|
| 7331 | + if (isset($attachments[$num]['charset'])&&!empty($attachments[$num]['charset'])) |
|
| 7332 | + { |
|
| 6204 | 7333 | // we do not try guessing the charset, if it is not set |
| 6205 | 7334 | //if ($attachments[$num]['charset']===false) $attachments[$num]['charset'] = Translation::detect_encoding($attachments[$num]['attachment']); |
| 6206 | 7335 | Translation::convert($attachments[$num]['attachment'],$attachments[$num]['charset']); |
@@ -6221,7 +7350,10 @@ discard block |
||
| 6221 | 7350 | unset($attachments[$num]['attachment']); |
| 6222 | 7351 | } |
| 6223 | 7352 | } |
| 6224 | - if (is_array($attachedMessages)) $attachments = array_merge($attachments,$attachedMessages); |
|
| 7353 | + if (is_array($attachedMessages)) |
|
| 7354 | + { |
|
| 7355 | + $attachments = array_merge($attachments,$attachedMessages); |
|
| 7356 | + } |
|
| 6225 | 7357 | } |
| 6226 | 7358 | return array( |
| 6227 | 7359 | 'mailaddress'=>$mailaddress, |
@@ -6243,10 +7375,17 @@ discard block |
||
| 6243 | 7375 | { |
| 6244 | 7376 | $c = 0; |
| 6245 | 7377 | // use the standardIdentity |
| 6246 | - foreach($_identities as $key => $acc) { |
|
| 6247 | - if ($c==0) $identity = $acc; |
|
| 7378 | + foreach($_identities as $key => $acc) |
|
| 7379 | + { |
|
| 7380 | + if ($c==0) |
|
| 7381 | + { |
|
| 7382 | + $identity = $acc; |
|
| 7383 | + } |
|
| 6248 | 7384 | //error_log(__METHOD__.__LINE__." $key == $_profile_id "); |
| 6249 | - if ($key==$_profile_id) $identity = $acc; |
|
| 7385 | + if ($key==$_profile_id) |
|
| 7386 | + { |
|
| 7387 | + $identity = $acc; |
|
| 7388 | + } |
|
| 6250 | 7389 | $c++; |
| 6251 | 7390 | } |
| 6252 | 7391 | return $identity; |
@@ -6262,20 +7401,53 @@ discard block |
||
| 6262 | 7401 | { |
| 6263 | 7402 | $headdata = null; |
| 6264 | 7403 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($header).function_backtrace()); |
| 6265 | - if ($header['SUBJECT']) $headdata = lang('subject').': '.$header['SUBJECT'].($createHTML?"<br />":"\n"); |
|
| 6266 | - if ($header['FROM']) $headdata .= lang('from').': '.self::convertAddressArrayToString($header['FROM'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6267 | - if ($header['SENDER']) $headdata .= lang('sender').': '.self::convertAddressArrayToString($header['SENDER'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6268 | - if ($header['TO']) $headdata .= lang('to').': '.self::convertAddressArrayToString($header['TO'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6269 | - if ($header['CC']) $headdata .= lang('cc').': '.self::convertAddressArrayToString($header['CC'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6270 | - if ($header['BCC']) $headdata .= lang('bcc').': '.self::convertAddressArrayToString($header['BCC'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6271 | - if ($header['DATE']) $headdata .= lang('date').': '.$header['DATE'].($createHTML?"<br />":"\n"); |
|
| 6272 | - if ($header['PRIORITY'] && $header['PRIORITY'] != 'normal') $headdata .= lang('priority').': '.$header['PRIORITY'].($createHTML?"<br />":"\n"); |
|
| 6273 | - if ($header['IMPORTANCE'] && $header['IMPORTANCE'] !='normal') $headdata .= lang('importance').': '.$header['IMPORTANCE'].($createHTML?"<br />":"\n"); |
|
| 7404 | + if ($header['SUBJECT']) |
|
| 7405 | + { |
|
| 7406 | + $headdata = lang('subject').': '.$header['SUBJECT'].($createHTML?"<br />":"\n"); |
|
| 7407 | + } |
|
| 7408 | + if ($header['FROM']) |
|
| 7409 | + { |
|
| 7410 | + $headdata .= lang('from').': '.self::convertAddressArrayToString($header['FROM'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 7411 | + } |
|
| 7412 | + if ($header['SENDER']) |
|
| 7413 | + { |
|
| 7414 | + $headdata .= lang('sender').': '.self::convertAddressArrayToString($header['SENDER'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 7415 | + } |
|
| 7416 | + if ($header['TO']) |
|
| 7417 | + { |
|
| 7418 | + $headdata .= lang('to').': '.self::convertAddressArrayToString($header['TO'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 7419 | + } |
|
| 7420 | + if ($header['CC']) |
|
| 7421 | + { |
|
| 7422 | + $headdata .= lang('cc').': '.self::convertAddressArrayToString($header['CC'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 7423 | + } |
|
| 7424 | + if ($header['BCC']) |
|
| 7425 | + { |
|
| 7426 | + $headdata .= lang('bcc').': '.self::convertAddressArrayToString($header['BCC'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 7427 | + } |
|
| 7428 | + if ($header['DATE']) |
|
| 7429 | + { |
|
| 7430 | + $headdata .= lang('date').': '.$header['DATE'].($createHTML?"<br />":"\n"); |
|
| 7431 | + } |
|
| 7432 | + if ($header['PRIORITY'] && $header['PRIORITY'] != 'normal') |
|
| 7433 | + { |
|
| 7434 | + $headdata .= lang('priority').': '.$header['PRIORITY'].($createHTML?"<br />":"\n"); |
|
| 7435 | + } |
|
| 7436 | + if ($header['IMPORTANCE'] && $header['IMPORTANCE'] !='normal') |
|
| 7437 | + { |
|
| 7438 | + $headdata .= lang('importance').': '.$header['IMPORTANCE'].($createHTML?"<br />":"\n"); |
|
| 7439 | + } |
|
| 6274 | 7440 | //if ($mailcontent['headers']['ORGANIZATION']) $headdata .= lang('organization').': '.$mailcontent['headers']['ORGANIZATION']."\ |
| 6275 | 7441 | if (!empty($headdata)) |
| 6276 | 7442 | { |
| 6277 | - if (!empty($headline) && $headline != 'SUPPRESS') $headdata = "---------------------------- $headline ----------------------------".($createHTML?"<br />":"\n").$headdata; |
|
| 6278 | - if (empty($headline)) $headdata = ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):'').$headdata; |
|
| 7443 | + if (!empty($headline) && $headline != 'SUPPRESS') |
|
| 7444 | + { |
|
| 7445 | + $headdata = "---------------------------- $headline ----------------------------".($createHTML?"<br />":"\n").$headdata; |
|
| 7446 | + } |
|
| 7447 | + if (empty($headline)) |
|
| 7448 | + { |
|
| 7449 | + $headdata = ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):'').$headdata; |
|
| 7450 | + } |
|
| 6279 | 7451 | $headdata .= ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):''); |
| 6280 | 7452 | } |
| 6281 | 7453 | else |
@@ -6309,12 +7481,15 @@ discard block |
||
| 6309 | 7481 | $returnAddr =''; |
| 6310 | 7482 | if (is_array($rfcAddressArray)) |
| 6311 | 7483 | { |
| 6312 | - foreach((array)$rfcAddressArray as $addressData) { |
|
| 7484 | + foreach((array)$rfcAddressArray as $addressData) |
|
| 7485 | + { |
|
| 6313 | 7486 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($addressData)); |
| 6314 | - if($addressData['MAILBOX_NAME'] == 'NIL') { |
|
| 7487 | + if($addressData['MAILBOX_NAME'] == 'NIL') |
|
| 7488 | + { |
|
| 6315 | 7489 | continue; |
| 6316 | 7490 | } |
| 6317 | - if(strtolower($addressData['MAILBOX_NAME']) == 'undisclosed-recipients') { |
|
| 7491 | + if(strtolower($addressData['MAILBOX_NAME']) == 'undisclosed-recipients') |
|
| 7492 | + { |
|
| 6318 | 7493 | continue; |
| 6319 | 7494 | } |
| 6320 | 7495 | if ($addressData['RFC822_EMAIL']) |
@@ -6328,7 +7503,10 @@ discard block |
||
| 6328 | 7503 | } |
| 6329 | 7504 | $addressObject = $addressObjectA[0]; |
| 6330 | 7505 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($addressObject)); |
| 6331 | - if (!$addressObject->valid) continue; |
|
| 7506 | + if (!$addressObject->valid) |
|
| 7507 | + { |
|
| 7508 | + continue; |
|
| 7509 | + } |
|
| 6332 | 7510 | //$mb =(string)$addressObject->mailbox; |
| 6333 | 7511 | //$h = (string)$addressObject->host; |
| 6334 | 7512 | //$p = (string)$addressObject->personal; |
@@ -6345,7 +7523,10 @@ discard block |
||
| 6345 | 7523 | // do not mess with strings, return them untouched /* ToDo: validate string as Address */ |
| 6346 | 7524 | $rfcAddressArray = self::decode_header($rfcAddressArray,true); |
| 6347 | 7525 | $rfcAddressArray = str_replace(array('<','>','"\'','\'"'),array('[',']','"','"'),$rfcAddressArray); |
| 6348 | - if (is_string($rfcAddressArray)) return $rfcAddressArray; |
|
| 7526 | + if (is_string($rfcAddressArray)) |
|
| 7527 | + { |
|
| 7528 | + return $rfcAddressArray; |
|
| 7529 | + } |
|
| 6349 | 7530 | } |
| 6350 | 7531 | return $returnAddr; |
| 6351 | 7532 | } |
@@ -6362,10 +7543,19 @@ discard block |
||
| 6362 | 7543 | { |
| 6363 | 7544 | $mergeobj = new Contacts\Merge(); |
| 6364 | 7545 | |
| 6365 | - if (empty($mimetype)) $mimetype = (strlen(strip_tags($content)) == strlen($content) ?'text/plain':'text/html'); |
|
| 7546 | + if (empty($mimetype)) |
|
| 7547 | + { |
|
| 7548 | + $mimetype = (strlen(strip_tags($content)) == strlen($content) ?'text/plain':'text/html'); |
|
| 7549 | + } |
|
| 6366 | 7550 | $rv = $mergeobj->merge_string($content,$ids,$err='',$mimetype, array(), self::$displayCharset); |
| 6367 | - if (empty($rv) && !empty($content) && !empty($err)) $rv = $content; |
|
| 6368 | - if (!empty($err) && !empty($content) && !empty($ids)) error_log(__METHOD__.' ('.__LINE__.') '.' Merge failed for Ids:'.array2string($ids).' ContentType:'.$mimetype.' Content:'.$content.' Reason:'.array2string($err)); |
|
| 7551 | + if (empty($rv) && !empty($content) && !empty($err)) |
|
| 7552 | + { |
|
| 7553 | + $rv = $content; |
|
| 7554 | + } |
|
| 7555 | + if (!empty($err) && !empty($content) && !empty($ids)) |
|
| 7556 | + { |
|
| 7557 | + error_log(__METHOD__.' ('.__LINE__.') '.' Merge failed for Ids:'.array2string($ids).' ContentType:'.$mimetype.' Content:'.$content.' Reason:'.array2string($err)); |
|
| 7558 | + } |
|
| 6369 | 7559 | return $rv; |
| 6370 | 7560 | } |
| 6371 | 7561 | |
@@ -6402,13 +7592,15 @@ discard block |
||
| 6402 | 7592 | settype($bytes, 'integer'); |
| 6403 | 7593 | $bytes /= 10; |
| 6404 | 7594 | } |
| 6405 | - else |
|
| 6406 | - settype($bytes, 'integer'); |
|
| 7595 | + else { |
|
| 7596 | + settype($bytes, 'integer'); |
|
| 7597 | + } |
|
| 6407 | 7598 | |
| 6408 | 7599 | return $bytes . ' ' . $type ; |
| 6409 | 7600 | } |
| 6410 | 7601 | |
| 6411 | - static function detect_qp(&$sting) { |
|
| 7602 | + static function detect_qp(&$sting) |
|
| 7603 | + { |
|
| 6412 | 7604 | $needle = '/(=[0-9][A-F])|(=[A-F][0-9])|(=[A-F][A-F])|(=[0-9][0-9])/'; |
| 6413 | 7605 | return preg_match("$needle",$string); |
| 6414 | 7606 | } |
@@ -6425,9 +7617,15 @@ discard block |
||
| 6425 | 7617 | */ |
| 6426 | 7618 | static function logRunTimes($_starttime,$_endtime=null,$_message='',$_methodNline='') |
| 6427 | 7619 | { |
| 6428 | - if (is_null($_endtime)) $_endtime = microtime(true); |
|
| 7620 | + if (is_null($_endtime)) |
|
| 7621 | + { |
|
| 7622 | + $_endtime = microtime(true); |
|
| 7623 | + } |
|
| 6429 | 7624 | $usagetime = microtime(true) - $_starttime; |
| 6430 | - if (self::$debugTimes) error_log($_methodNline.' took:'.number_format($usagetime,5).'(s) '.($_message?'Details:'.$_message:'')); |
|
| 7625 | + if (self::$debugTimes) |
|
| 7626 | + { |
|
| 7627 | + error_log($_methodNline.' took:'.number_format($usagetime,5).'(s) '.($_message?'Details:'.$_message:'')); |
|
| 7628 | + } |
|
| 6431 | 7629 | } |
| 6432 | 7630 | |
| 6433 | 7631 | /** |
@@ -6442,7 +7640,10 @@ discard block |
||
| 6442 | 7640 | */ |
| 6443 | 7641 | static function checkFileBasics(&$_formData, $IDtoAddToFileName='', $reqMimeType='message/rfc822') |
| 6444 | 7642 | { |
| 6445 | - if (parse_url($_formData['file'],PHP_URL_SCHEME) == 'egw-data') return $_formData['file']; |
|
| 7643 | + if (parse_url($_formData['file'],PHP_URL_SCHEME) == 'egw-data') |
|
| 7644 | + { |
|
| 7645 | + return $_formData['file']; |
|
| 7646 | + } |
|
| 6446 | 7647 | |
| 6447 | 7648 | //error_log(__METHOD__.__FILE__.array2string($_formData).' Id:'.$IDtoAddToFileName.' ReqMimeType:'.$reqMimeType); |
| 6448 | 7649 | $importfailed = $tmpFileName = false; |
@@ -6491,8 +7692,15 @@ discard block |
||
| 6491 | 7692 | { |
| 6492 | 7693 | $buff = explode('.',$_formData['name']); |
| 6493 | 7694 | $suffix = ''; |
| 6494 | - if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
|
| 6495 | - if (!empty($suffix)) $sfxMimeType = MimeMagic::ext2mime($suffix); |
|
| 7695 | + if (is_array($buff)) |
|
| 7696 | + { |
|
| 7697 | + $suffix = array_pop($buff); |
|
| 7698 | + } |
|
| 7699 | + // take the last extension to check with ext2mime |
|
| 7700 | + if (!empty($suffix)) |
|
| 7701 | + { |
|
| 7702 | + $sfxMimeType = MimeMagic::ext2mime($suffix); |
|
| 7703 | + } |
|
| 6496 | 7704 | if (!empty($suffix) && !empty($sfxMimeType) && |
| 6497 | 7705 | (strlen(trim($_formData['type']))==0 || (strtolower(trim($_formData['type'])) != $sfxMimeType))) |
| 6498 | 7706 | { |
@@ -6540,7 +7748,9 @@ discard block |
||
| 6540 | 7748 | { |
| 6541 | 7749 | rename($_formData['file'], $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmpFileName); |
| 6542 | 7750 | } |
| 6543 | - } else { |
|
| 7751 | + } |
|
| 7752 | + else |
|
| 7753 | + { |
|
| 6544 | 7754 | //error_log("Import of message ".$_formData['file']." failes to meet basic restrictions"); |
| 6545 | 7755 | $importfailed = true; |
| 6546 | 7756 | $alert_msg .= lang("Processing of file %1 failed. Failed to meet basic restrictions.",$_formData['name']); |
@@ -6586,21 +7796,32 @@ discard block |
||
| 6586 | 7796 | if (substr($url, 0, 5) !== 'data:') |
| 6587 | 7797 | { |
| 6588 | 7798 | $filename = basename($url); |
| 6589 | - if (($directory = dirname($url)) == '.') $directory = ''; |
|
| 7799 | + if (($directory = dirname($url)) == '.') |
|
| 7800 | + { |
|
| 7801 | + $directory = ''; |
|
| 7802 | + } |
|
| 6590 | 7803 | $ext = pathinfo($filename, PATHINFO_EXTENSION); |
| 6591 | 7804 | $mimeType = MimeMagic::ext2mime($ext); |
| 6592 | - if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; } |
|
| 7805 | + if ( strlen($directory) > 1 && substr($directory,-1) != '/') |
|
| 7806 | + { |
|
| 7807 | +$directory .= '/'; } |
|
| 6593 | 7808 | $myUrl = $directory.$filename; |
| 6594 | - if ($myUrl[0]=='/') // local path -> we only allow path's that are available via http/https (or vfs) |
|
| 7809 | + if ($myUrl[0]=='/') |
|
| 7810 | + { |
|
| 7811 | + // local path -> we only allow path's that are available via http/https (or vfs) |
|
| 6595 | 7812 | { |
| 6596 | 7813 | $basedir = ($_SERVER['HTTPS']?'https://':'http://'.$_SERVER['HTTP_HOST']); |
| 6597 | 7814 | } |
| 7815 | + } |
|
| 6598 | 7816 | // use vfs instead of url containing webdav.php |
| 6599 | 7817 | // ToDo: we should test if the webdav url is of our own scope, as we cannot handle foreign |
| 6600 | 7818 | // webdav.php urls as vfs |
| 6601 | - if (strpos($myUrl,'/webdav.php') !== false) // we have a webdav link, so we build a vfs/sqlfs link of it. |
|
| 7819 | + if (strpos($myUrl,'/webdav.php') !== false) |
|
| 7820 | + { |
|
| 7821 | + // we have a webdav link, so we build a vfs/sqlfs link of it. |
|
| 6602 | 7822 | { |
| 6603 | 7823 | Vfs::load_wrapper('vfs'); |
| 7824 | + } |
|
| 6604 | 7825 | list(,$myUrl) = explode('/webdav.php',$myUrl,2); |
| 6605 | 7826 | $basedir = 'vfs://default'; |
| 6606 | 7827 | $needTempFile = false; |
@@ -6629,8 +7850,13 @@ discard block |
||
| 6629 | 7850 | } |
| 6630 | 7851 | } |
| 6631 | 7852 | |
| 6632 | - if ( strlen($basedir) > 1 && substr($basedir,-1) != '/' && $myUrl[0]!='/') { $basedir .= '/'; } |
|
| 6633 | - if ($needTempFile && !$attachment && substr($myUrl,0,4) !== "http") $data = file_get_contents($basedir.urldecode($myUrl)); |
|
| 7853 | + if ( strlen($basedir) > 1 && substr($basedir,-1) != '/' && $myUrl[0]!='/') |
|
| 7854 | + { |
|
| 7855 | +$basedir .= '/'; } |
|
| 7856 | + if ($needTempFile && !$attachment && substr($myUrl,0,4) !== "http") |
|
| 7857 | + { |
|
| 7858 | + $data = file_get_contents($basedir.urldecode($myUrl)); |
|
| 7859 | + } |
|
| 6634 | 7860 | } |
| 6635 | 7861 | if (substr($url,0,strlen('data:'))=='data:') |
| 6636 | 7862 | { |
@@ -6731,7 +7957,10 @@ discard block |
||
| 6731 | 7957 | $_folder = $this->getSentFolder(); |
| 6732 | 7958 | } |
| 6733 | 7959 | $delimiter = $this->getHierarchyDelimiter(); |
| 6734 | - if($_folder=='INBOX'.$delimiter) $_folder='INBOX'; |
|
| 7960 | + if($_folder=='INBOX'.$delimiter) |
|
| 7961 | + { |
|
| 7962 | + $_folder='INBOX'; |
|
| 7963 | + } |
|
| 6735 | 7964 | if ($importfailed === false) |
| 6736 | 7965 | { |
| 6737 | 7966 | $Subject = $mailObject->getHeader('Subject'); |
@@ -6760,7 +7989,9 @@ discard block |
||
| 6760 | 7989 | //error_log(__METHOD__.' ('.__LINE__.') '.' Id To Merge:'.$val); |
| 6761 | 7990 | if (/*$GLOBALS['egw_info']['flags']['currentapp'] == 'addressbook' &&*/ |
| 6762 | 7991 | count($SendAndMergeTocontacts) > 1 && $val && |
| 6763 | - (is_numeric($val) || $GLOBALS['egw']->accounts->name2id($val))) // do the merge |
|
| 7992 | + (is_numeric($val) || $GLOBALS['egw']->accounts->name2id($val))) |
|
| 7993 | + { |
|
| 7994 | + // do the merge |
|
| 6764 | 7995 | { |
| 6765 | 7996 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mailObject)); |
| 6766 | 7997 | |
@@ -6769,6 +8000,7 @@ discard block |
||
| 6769 | 8000 | { |
| 6770 | 8001 | //error_log('ID ' . $val . ' ' .$type . ': ' . $mailObject->getHeader(Mailer::$type2header[$type]) . ' -> ' .$bo_merge->merge_string($mailObject->getHeader(Mailer::$type2header[$type]),$val,$e,'text/plain',array(),self::$displayCharset)); |
| 6771 | 8002 | $merged = $bo_merge->merge_string($mailObject->getHeader(Mailer::$type2header[$type]),$val,$e,'text/plain',array(),self::$displayCharset); |
| 8003 | + } |
|
| 6772 | 8004 | $mailObject->addAddress($merged,'',$type); |
| 6773 | 8005 | if($type == 'to') |
| 6774 | 8006 | { |
@@ -6800,9 +8032,15 @@ discard block |
||
| 6800 | 8032 | $mailObject->clearCustomHeaders(); |
| 6801 | 8033 | $mailObject->addHeader('Subject', $bo_merge->merge_string($Subject, $val, $e, 'text/plain', array(), self::$displayCharset)); |
| 6802 | 8034 | //error_log(__METHOD__.' ('.__LINE__.') '.' ContentType:'.$mailObject->BodyContentType); |
| 6803 | - if($text_body) $text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 8035 | + if($text_body) |
|
| 8036 | + { |
|
| 8037 | + $text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 8038 | + } |
|
| 6804 | 8039 | //error_log(__METHOD__.' ('.__LINE__.') '.' Result:'.$mailObject->Body.' error:'.array2string($e)); |
| 6805 | - if($html_body) $html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 8040 | + if($html_body) |
|
| 8041 | + { |
|
| 8042 | + $html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 8043 | + } |
|
| 6806 | 8044 | |
| 6807 | 8045 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mailObject)); |
| 6808 | 8046 | // set a higher timeout for big messages |
@@ -6817,9 +8055,12 @@ discard block |
||
| 6817 | 8055 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($errorInfo)); |
| 6818 | 8056 | } |
| 6819 | 8057 | } |
| 6820 | - elseif (!$k) // 1. entry, further entries will fail for apps other then addressbook |
|
| 8058 | + elseif (!$k) |
|
| 8059 | + { |
|
| 8060 | + // 1. entry, further entries will fail for apps other then addressbook |
|
| 6821 | 8061 | { |
| 6822 | 8062 | $openAsDraft = true; |
| 8063 | + } |
|
| 6823 | 8064 | $mailObject->removeHeader('Message-ID'); |
| 6824 | 8065 | $mailObject->removeHeader('Date'); |
| 6825 | 8066 | $mailObject->clearCustomHeaders(); |
@@ -6834,9 +8075,12 @@ discard block |
||
| 6834 | 8075 | |
| 6835 | 8076 | // No addresses from placeholders? Treat it as just a contact ID |
| 6836 | 8077 | if (count($mailObject->getAddresses('to',true)) == 0 && |
| 6837 | - is_numeric($val) || $GLOBALS['egw']->accounts->name2id($val)) // do the merge |
|
| 8078 | + is_numeric($val) || $GLOBALS['egw']->accounts->name2id($val)) |
|
| 8079 | + { |
|
| 8080 | + // do the merge |
|
| 6838 | 8081 | { |
| 6839 | 8082 | $contact = $bo_merge->contacts->read($val); |
| 8083 | + } |
|
| 6840 | 8084 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($contact)); |
| 6841 | 8085 | $email = ($contact['email'] ? $contact['email'] : $contact['email_home']); |
| 6842 | 8086 | $nfn = ($contact['n_fn'] ? $contact['n_fn'] : $contact['n_given'].' '.$contact['n_family']); |
@@ -6847,9 +8091,15 @@ discard block |
||
| 6847 | 8091 | } |
| 6848 | 8092 | $mailObject->addHeader('Subject', $bo_merge->merge_string($Subject, $val, $e, 'text/plain', array(), self::$displayCharset)); |
| 6849 | 8093 | //error_log(__METHOD__.' ('.__LINE__.') '.' ContentType:'.$mailObject->BodyContentType); |
| 6850 | - if (!empty($Body)) $text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 8094 | + if (!empty($Body)) |
|
| 8095 | + { |
|
| 8096 | + $text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 8097 | + } |
|
| 6851 | 8098 | //error_log(__METHOD__.' ('.__LINE__.') '.' Result:'.$mailObject->Body.' error:'.array2string($e)); |
| 6852 | - if (!empty($AltBody)) $html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 8099 | + if (!empty($AltBody)) |
|
| 8100 | + { |
|
| 8101 | + $html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 8102 | + } |
|
| 6853 | 8103 | $_folder = $this->getDraftFolder(); |
| 6854 | 8104 | } |
| 6855 | 8105 | if ($sendOK || $openAsDraft) |
@@ -6857,11 +8107,15 @@ discard block |
||
| 6857 | 8107 | if ($this->folderExists($_folder,true)) |
| 6858 | 8108 | { |
| 6859 | 8109 | if($this->isSentFolder($_folder)) |
| 6860 | - { |
|
| 8110 | + { |
|
| 6861 | 8111 | $flags = '\\Seen'; |
| 6862 | - } elseif($this->isDraftFolder($_folder)) { |
|
| 8112 | + } |
|
| 8113 | + elseif($this->isDraftFolder($_folder)) |
|
| 8114 | + { |
|
| 6863 | 8115 | $flags = '\\Draft'; |
| 6864 | - } else { |
|
| 8116 | + } |
|
| 8117 | + else |
|
| 8118 | + { |
|
| 6865 | 8119 | $flags = ''; |
| 6866 | 8120 | } |
| 6867 | 8121 | $savefailed = false; |
@@ -6895,7 +8149,10 @@ discard block |
||
| 6895 | 8149 | } |
| 6896 | 8150 | else |
| 6897 | 8151 | { |
| 6898 | - if (!$openComposeWindow) $processStats['failed'][$val] = $errorInfo?$errorInfo:'Send failed to '.$nfn.'<'.$email.'> See error_log for details'; |
|
| 8152 | + if (!$openComposeWindow) |
|
| 8153 | + { |
|
| 8154 | + $processStats['failed'][$val] = $errorInfo?$errorInfo:'Send failed to '.$nfn.'<'.$email.'> See error_log for details'; |
|
| 8155 | + } |
|
| 6899 | 8156 | } |
| 6900 | 8157 | } |
| 6901 | 8158 | if (!is_null($sendOK) && $sendOK===false && is_null($openComposeWindow)) |
@@ -6943,7 +8200,10 @@ discard block |
||
| 6943 | 8200 | $tmpFileName = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($tmpFileName); |
| 6944 | 8201 | break; |
| 6945 | 8202 | } |
| 6946 | - if (!isset($message)) $message = fopen($tmpFileName, 'r'); |
|
| 8203 | + if (!isset($message)) |
|
| 8204 | + { |
|
| 8205 | + $message = fopen($tmpFileName, 'r'); |
|
| 8206 | + } |
|
| 6947 | 8207 | |
| 6948 | 8208 | if (!$message) |
| 6949 | 8209 | { |
@@ -6974,7 +8234,10 @@ discard block |
||
| 6974 | 8234 | (fseek($message, 0, SEEK_SET) == -1 ? '' : fread($message, 8192)); |
| 6975 | 8235 | |
| 6976 | 8236 | $length = strpos($start, Horde_Mime_Part::RFC_EOL.Horde_Mime_Part::RFC_EOL); |
| 6977 | - if ($length===false) $length = strlen($start); |
|
| 8237 | + if ($length===false) |
|
| 8238 | + { |
|
| 8239 | + $length = strlen($start); |
|
| 8240 | + } |
|
| 6978 | 8241 | $headers = Horde_Mime_Headers::parseHeaders(substr($start, 0,$length)); |
| 6979 | 8242 | |
| 6980 | 8243 | foreach($headers->toArray(array('nowrap' => true)) as $header => $value) |
@@ -7003,7 +8266,10 @@ discard block |
||
| 7003 | 8266 | } |
| 7004 | 8267 | else |
| 7005 | 8268 | { |
| 7006 | - if (($type = gettype($message)) == 'object') $type = get_class ($message); |
|
| 8269 | + if (($type = gettype($message)) == 'object') |
|
| 8270 | + { |
|
| 8271 | + $type = get_class ($message); |
|
| 8272 | + } |
|
| 7007 | 8273 | throw new Exception\WrongParameter('Wrong parameter type for message: '.$type); |
| 7008 | 8274 | } |
| 7009 | 8275 | } |
@@ -7027,7 +8293,9 @@ discard block |
||
| 7027 | 8293 | $matches = array(); |
| 7028 | 8294 | preg_match_all("/[\w\.,-.,_.,0-9.]+@[\w\.,-.,_.,0-9.]+/",$addresses,$matches); |
| 7029 | 8295 | //error_log(__METHOD__.__LINE__.array2string($matches)); |
| 7030 | - foreach ($matches[0] as &$match) {$match = trim($match,', ');} |
|
| 8296 | + foreach ($matches[0] as &$match) |
|
| 8297 | + { |
|
| 8298 | +$match = trim($match,', ');} |
|
| 7031 | 8299 | $addresses = implode(',',$matches[0]); |
| 7032 | 8300 | //error_log(__METHOD__.__LINE__.array2string($addresses)); |
| 7033 | 8301 | $ret = $rfc822->parseAddressList($addresses, $default_domain ? array('default_domain' => $default_domain) : array()); |
@@ -7058,7 +8326,10 @@ discard block |
||
| 7058 | 8326 | } |
| 7059 | 8327 | else |
| 7060 | 8328 | { |
| 7061 | - if ($previousFailed && $remember) $adr->personal = $remember. ' ' . $adr->personal; |
|
| 8329 | + if ($previousFailed && $remember) |
|
| 8330 | + { |
|
| 8331 | + $adr->personal = $remember. ' ' . $adr->personal; |
|
| 8332 | + } |
|
| 7062 | 8333 | $remember = ''; |
| 7063 | 8334 | $previousFailed=false; |
| 7064 | 8335 | //error_log(__METHOD__.__LINE__."('$addresses', $default_domain) parsed $i: mailbox=$adr->mailbox, host=$adr->host, personal=$adr->personal"); |
@@ -7080,7 +8351,10 @@ discard block |
||
| 7080 | 8351 | { |
| 7081 | 8352 | $acc = Mail\Account::read($this->profileID); |
| 7082 | 8353 | $identity = Mail\Account::read_identity($acc['ident_id'], true, null, $acc); |
| 7083 | - if (self::$debug) error_log(__METHOD__.__LINE__.array2string($identity)); |
|
| 8354 | + if (self::$debug) |
|
| 8355 | + { |
|
| 8356 | + error_log(__METHOD__.__LINE__.array2string($identity)); |
|
| 8357 | + } |
|
| 7084 | 8358 | $headers = $this->getMessageHeader($uid, '', 'object', true, $_folder); |
| 7085 | 8359 | |
| 7086 | 8360 | $mdn = new Horde_Mime_Mdn($headers); |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | * @param boolean $replace_placeholders =false should placeholders like {{n_fn}} be replaced |
| 487 | 487 | * @param string $field ='name' what to return as value: "ident_(realname|org|email|signature)" or default "name"=result from identity_name |
| 488 | 488 | * @param int $user =null account_id to use if not current user |
| 489 | - * @return Iterator ident_id => identity_name of identity |
|
| 489 | + * @return Api\Db\CallbackIterator ident_id => identity_name of identity |
|
| 490 | 490 | */ |
| 491 | 491 | public static function identities($account, $replace_placeholders=true, $field='name', $user=null) |
| 492 | 492 | { |
@@ -795,7 +795,7 @@ discard block |
||
| 795 | 795 | * |
| 796 | 796 | * To get $this->params you need to call getUserData before! It is never automatically loaded. |
| 797 | 797 | * |
| 798 | - * @param type $name |
|
| 798 | + * @param string $name |
|
| 799 | 799 | * @return mixed |
| 800 | 800 | */ |
| 801 | 801 | public function __get($name) |
@@ -819,8 +819,8 @@ discard block |
||
| 819 | 819 | /** |
| 820 | 820 | * Give read access to protected parameters in $this->params |
| 821 | 821 | * |
| 822 | - * @param type $name |
|
| 823 | - * @return mixed |
|
| 822 | + * @param string $name |
|
| 823 | + * @return boolean |
|
| 824 | 824 | */ |
| 825 | 825 | public function __isset($name) |
| 826 | 826 | { |
@@ -1340,10 +1340,10 @@ discard block |
||
| 1340 | 1340 | * @param boolean|string $just_name =true true: return self::identity_name, false: return Account objects, |
| 1341 | 1341 | * string with attribute-name: return that attribute, eg. acc_imap_host or 'params' to return all attributes as array |
| 1342 | 1342 | * @param string $order_by ='acc_name ASC' |
| 1343 | - * @param int|boolean $offset =false offset or false to return all |
|
| 1343 | + * @param boolean $offset =false offset or false to return all |
|
| 1344 | 1344 | * @param int $num_rows =0 number of rows to return, 0=default from prefs (if $offset !== false) |
| 1345 | 1345 | * @param boolean $replace_placeholders =true should placeholders like {{n_fn}} be replaced |
| 1346 | - * @return Iterator with acc_id => acc_name or Account objects |
|
| 1346 | + * @return Api\Db\CallbackIterator with acc_id => acc_name or Account objects |
|
| 1347 | 1347 | */ |
| 1348 | 1348 | public static function search($only_current_user=true, $just_name=true, $order_by=null, $offset=false, $num_rows=0, $replace_placeholders=true) |
| 1349 | 1349 | { |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | /** |
| 198 | 198 | * Path to log smtp comunication to or null to not log |
| 199 | 199 | */ |
| 200 | - const SMTP_DEBUG_LOG = null;//'/tmp/smtp.log'; |
|
| 200 | + const SMTP_DEBUG_LOG = null; //'/tmp/smtp.log'; |
|
| 201 | 201 | |
| 202 | 202 | /** |
| 203 | 203 | * Instanciated account object by acc_id, read acts as singelton |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | * @param int $called_for=null if set access to given user (without smtp credentials!), |
| 246 | 246 | * default current user AND read username/password from current users session |
| 247 | 247 | */ |
| 248 | - /*protected*/ function __construct(array $params, $called_for=null) |
|
| 248 | + /*protected*/ function __construct(array $params, $called_for = null) |
|
| 249 | 249 | { |
| 250 | 250 | // read credentials from database |
| 251 | 251 | $params += Credentials::read($params['acc_id'], null, $called_for ? array(0, $called_for) : $called_for); |
@@ -274,16 +274,16 @@ discard block |
||
| 274 | 274 | public static function ssl2secure($ssl) |
| 275 | 275 | { |
| 276 | 276 | $secure = false; |
| 277 | - switch($ssl & ~self::SSL_VERIFY) |
|
| 277 | + switch ($ssl&~self::SSL_VERIFY) |
|
| 278 | 278 | { |
| 279 | 279 | case self::SSL_STARTTLS: |
| 280 | - $secure = 'tls'; // Horde uses 'tls' for STARTTLS, not ssl connection with tls version >= 1 and no sslv2/3 |
|
| 280 | + $secure = 'tls'; // Horde uses 'tls' for STARTTLS, not ssl connection with tls version >= 1 and no sslv2/3 |
|
| 281 | 281 | break; |
| 282 | 282 | case self::SSL_SSL: |
| 283 | 283 | $secure = 'ssl'; |
| 284 | 284 | break; |
| 285 | 285 | case self::SSL_TLS: |
| 286 | - $secure = 'tlsv1'; // since Horde_Imap_Client-1.16.0 requiring Horde_Socket_Client-1.1.0 |
|
| 286 | + $secure = 'tlsv1'; // since Horde_Imap_Client-1.16.0 requiring Horde_Socket_Client-1.1.0 |
|
| 287 | 287 | break; |
| 288 | 288 | } |
| 289 | 289 | return $secure; |
@@ -312,15 +312,15 @@ discard block |
||
| 312 | 312 | $this->params = array_merge($this->params, $data); |
| 313 | 313 | } |
| 314 | 314 | } |
| 315 | - catch(Horde_Imap_Client_Exception $e) { |
|
| 315 | + catch (Horde_Imap_Client_Exception $e) { |
|
| 316 | 316 | unset($e); |
| 317 | 317 | // ignore eg. connection errors |
| 318 | 318 | } |
| 319 | - catch(\InvalidArgumentException $e) { |
|
| 319 | + catch (\InvalidArgumentException $e) { |
|
| 320 | 320 | unset($e); |
| 321 | 321 | // ignore eg. missing admin user |
| 322 | 322 | } |
| 323 | - $this->params += array_fill_keys(self::$user_data, null); // make sure all keys exist now |
|
| 323 | + $this->params += array_fill_keys(self::$user_data, null); // make sure all keys exist now |
|
| 324 | 324 | |
| 325 | 325 | return (array)$data + (array)$smtp_data; |
| 326 | 326 | } |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | * @param int $_timeout =null timeout in secs, if none given fmail pref or default of 20 is used |
| 355 | 355 | * @return Imap |
| 356 | 356 | */ |
| 357 | - public function imapServer($_adminConnection=false, $_timeout=null) |
|
| 357 | + public function imapServer($_adminConnection = false, $_timeout = null) |
|
| 358 | 358 | { |
| 359 | 359 | if (!isset($this->imapServer) || $this->imapServer->isAdminConnection !== $_adminConnection) |
| 360 | 360 | { |
@@ -378,11 +378,11 @@ discard block |
||
| 378 | 378 | * (matters only for imap servers managed by EGroupware!) |
| 379 | 379 | * @return boolean |
| 380 | 380 | */ |
| 381 | - public function is_imap($try_connect=true) |
|
| 381 | + public function is_imap($try_connect = true) |
|
| 382 | 382 | { |
| 383 | 383 | if (empty($this->acc_imap_host) || empty($this->acc_imap_username) || empty($this->acc_imap_password)) |
| 384 | 384 | { |
| 385 | - return false; // no imap host or credentials |
|
| 385 | + return false; // no imap host or credentials |
|
| 386 | 386 | } |
| 387 | 387 | // if we are not managing the mail-server, we do NOT need to check deliveryMode and accountStatus |
| 388 | 388 | if ($this->acc_smtp_type == __NAMESPACE__.'\\Smtp') |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | $this->smtpServer->editForwardingAddress = false; |
| 420 | 420 | $this->smtpServer->host = $this->params['acc_smtp_host']; |
| 421 | 421 | $this->smtpServer->port = $this->params['acc_smtp_port']; |
| 422 | - switch($this->params['acc_smtp_ssl']) |
|
| 422 | + switch ($this->params['acc_smtp_ssl']) |
|
| 423 | 423 | { |
| 424 | 424 | case self::SSL_TLS: |
| 425 | 425 | $this->smtpServer->host = 'tlsv1://'.$this->smtpServer->host; |
@@ -449,16 +449,16 @@ discard block |
||
| 449 | 449 | if (!isset($this->smtpTransport)) |
| 450 | 450 | { |
| 451 | 451 | $secure = false; |
| 452 | - switch($this->acc_smtp_ssl & ~self::SSL_VERIFY) |
|
| 452 | + switch ($this->acc_smtp_ssl&~self::SSL_VERIFY) |
|
| 453 | 453 | { |
| 454 | 454 | case self::SSL_STARTTLS: |
| 455 | - $secure = 'tls'; // Horde uses 'tls' for STARTTLS, not ssl connection with tls version >= 1 and no sslv2/3 |
|
| 455 | + $secure = 'tls'; // Horde uses 'tls' for STARTTLS, not ssl connection with tls version >= 1 and no sslv2/3 |
|
| 456 | 456 | break; |
| 457 | 457 | case self::SSL_SSL: |
| 458 | 458 | $secure = 'ssl'; |
| 459 | 459 | break; |
| 460 | 460 | case self::SSL_TLS: |
| 461 | - $secure = 'tlsv1'; // since Horde_Smtp-1.3.0 requiring Horde_Socket_Client-1.1.0 |
|
| 461 | + $secure = 'tlsv1'; // since Horde_Smtp-1.3.0 requiring Horde_Socket_Client-1.1.0 |
|
| 462 | 462 | break; |
| 463 | 463 | } |
| 464 | 464 | // Horde use locale for translation of error messages |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | * @param int $user =null account_id to use if not current user |
| 489 | 489 | * @return Iterator ident_id => identity_name of identity |
| 490 | 490 | */ |
| 491 | - public static function identities($account, $replace_placeholders=true, $field='name', $user=null) |
|
| 491 | + public static function identities($account, $replace_placeholders = true, $field = 'name', $user = null) |
|
| 492 | 492 | { |
| 493 | 493 | if (!isset($user)) $user = $GLOBALS['egw_info']['user']['account_id']; |
| 494 | 494 | $acc_id = is_scalar($account) ? $account : $account['acc_id']; |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | } |
| 539 | 539 | return self::identity_name($row, $replace_placeholders); |
| 540 | 540 | }, array(), |
| 541 | - function($row) { return $row['ident_id'];}); |
|
| 541 | + function($row) { return $row['ident_id']; }); |
|
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | /** |
@@ -581,17 +581,17 @@ discard block |
||
| 581 | 581 | * @return array acc_id:ident_id:email => rfc822 address pairs, eg. '1:1:[email protected]' => 'Ralf Becker Stylite AG <[email protected]>' |
| 582 | 582 | * @todo add aliases for manged mail servers |
| 583 | 583 | */ |
| 584 | - public static function rfc822_addresses($formatter=null) |
|
| 584 | + public static function rfc822_addresses($formatter = null) |
|
| 585 | 585 | { |
| 586 | 586 | if (!$formatter || !is_callable($formatter)) |
| 587 | 587 | { |
| 588 | 588 | $formatter = 'self::rfc822'; |
| 589 | 589 | } |
| 590 | 590 | $addresses = array(); |
| 591 | - foreach(self::search(true, false) as $acc_id => $account) |
|
| 591 | + foreach (self::search(true, false) as $acc_id => $account) |
|
| 592 | 592 | { |
| 593 | - $added = false; // make sure each account get's at least added once, even if it uses an identical email address |
|
| 594 | - foreach(self::identities($account, true, 'params') as $identity) |
|
| 593 | + $added = false; // make sure each account get's at least added once, even if it uses an identical email address |
|
| 594 | + foreach (self::identities($account, true, 'params') as $identity) |
|
| 595 | 595 | { |
| 596 | 596 | if (($address = call_user_func($formatter, $identity)) && (!$added || !in_array($address, $addresses))) |
| 597 | 597 | { |
@@ -625,7 +625,7 @@ discard block |
||
| 625 | 625 | } |
| 626 | 626 | return $cmp; |
| 627 | 627 | }); |
| 628 | - foreach($identities as &$identity) |
|
| 628 | + foreach ($identities as &$identity) |
|
| 629 | 629 | { |
| 630 | 630 | $identity = self::identity_name($identity); |
| 631 | 631 | } |
@@ -642,16 +642,16 @@ discard block |
||
| 642 | 642 | * @param int $account_id =null account_id of user, or current user |
| 643 | 643 | * @return array with modified fields |
| 644 | 644 | */ |
| 645 | - public static function replace_placeholders($identity, $account_id=null) |
|
| 645 | + public static function replace_placeholders($identity, $account_id = null) |
|
| 646 | 646 | { |
| 647 | - static $fields = array('ident_name','ident_realname','ident_org','ident_email','ident_signature'); |
|
| 647 | + static $fields = array('ident_name', 'ident_realname', 'ident_org', 'ident_email', 'ident_signature'); |
|
| 648 | 648 | |
| 649 | 649 | if (!is_array($identity) && !is_a($identity, 'Account')) |
| 650 | 650 | { |
| 651 | 651 | throw new Api\Exception\WrongParameter(__METHOD__."() requires an identity or account as first parameter!"); |
| 652 | 652 | } |
| 653 | 653 | $to_replace = array(); |
| 654 | - foreach($fields as $name) |
|
| 654 | + foreach ($fields as $name) |
|
| 655 | 655 | { |
| 656 | 656 | if (strpos($identity[$name], '{{') !== false || strpos($identity[$name], '$$') !== false) |
| 657 | 657 | { |
@@ -660,10 +660,10 @@ discard block |
||
| 660 | 660 | } |
| 661 | 661 | if ($to_replace) |
| 662 | 662 | { |
| 663 | - static $merge=null; |
|
| 663 | + static $merge = null; |
|
| 664 | 664 | if (!isset($merge)) $merge = new Api\Contacts\Merge(); |
| 665 | 665 | if (!isset($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id']; |
| 666 | - foreach($to_replace as $name => &$value) |
|
| 666 | + foreach ($to_replace as $name => &$value) |
|
| 667 | 667 | { |
| 668 | 668 | $err = null; |
| 669 | 669 | $value = $merge->merge_string($value, |
@@ -685,7 +685,7 @@ discard block |
||
| 685 | 685 | * @return array |
| 686 | 686 | * @throws Api\Exception\NotFound |
| 687 | 687 | */ |
| 688 | - public static function read_identity($ident_id, $replace_placeholders=false, $user=null, $account=null) |
|
| 688 | + public static function read_identity($ident_id, $replace_placeholders = false, $user = null, $account = null) |
|
| 689 | 689 | { |
| 690 | 690 | if (($account && $account['ident_id'] == $ident_id)) |
| 691 | 691 | { |
@@ -755,8 +755,7 @@ discard block |
||
| 755 | 755 | 'ident_org' => $identity['ident_org'], |
| 756 | 756 | 'ident_email' => $identity['ident_email'], |
| 757 | 757 | 'ident_signature' => $identity['ident_signature'], |
| 758 | - 'account_id' => self::is_multiple($identity) ? 0 : |
|
| 759 | - (is_array($identity['account_id']) ? $identity['account_id'][0] : $identity['account_id']), |
|
| 758 | + 'account_id' => self::is_multiple($identity) ? 0 : (is_array($identity['account_id']) ? $identity['account_id'][0] : $identity['account_id']), |
|
| 760 | 759 | ); |
| 761 | 760 | if ($identity['ident_id'] > 0) |
| 762 | 761 | { |
@@ -800,7 +799,7 @@ discard block |
||
| 800 | 799 | */ |
| 801 | 800 | public function __get($name) |
| 802 | 801 | { |
| 803 | - switch($name) |
|
| 802 | + switch ($name) |
|
| 804 | 803 | { |
| 805 | 804 | case 'acc_imap_administration': // no longer stored in database |
| 806 | 805 | return !empty($this->params['acc_imap_admin_username']); |
@@ -824,7 +823,7 @@ discard block |
||
| 824 | 823 | */ |
| 825 | 824 | public function __isset($name) |
| 826 | 825 | { |
| 827 | - switch($name) |
|
| 826 | + switch ($name) |
|
| 828 | 827 | { |
| 829 | 828 | case 'acc_imap_administration': // no longer stored in database |
| 830 | 829 | return true; |
@@ -914,11 +913,11 @@ discard block |
||
| 914 | 913 | { |
| 915 | 914 | // check if account is for current user, if not deny access |
| 916 | 915 | $memberships = self::memberships(); |
| 917 | - $memberships[] = ''; // edit uses '' for everyone |
|
| 916 | + $memberships[] = ''; // edit uses '' for everyone |
|
| 918 | 917 | |
| 919 | 918 | if (array_intersect((array)$account['account_id'], $memberships)) |
| 920 | 919 | { |
| 921 | - switch($rights) |
|
| 920 | + switch ($rights) |
|
| 922 | 921 | { |
| 923 | 922 | case Api\Acl::READ: |
| 924 | 923 | $access = true; |
@@ -963,7 +962,7 @@ discard block |
||
| 963 | 962 | * @return email_account |
| 964 | 963 | * @throws Api\Exception\NotFound if account was not found (or not valid for current user) |
| 965 | 964 | */ |
| 966 | - public static function read($acc_id, $called_for=null) |
|
| 965 | + public static function read($acc_id, $called_for = null) |
|
| 967 | 966 | { |
| 968 | 967 | //error_log(__METHOD__."($acc_id, ".array2string($called_for).")"); |
| 969 | 968 | // some caching, but only for regular usage/users |
@@ -981,7 +980,7 @@ discard block |
||
| 981 | 980 | //error_log(__METHOD__."($acc_id) created instance from cached data"); |
| 982 | 981 | return self::$instances[$acc_id] = new Account(self::$cache[$acc_id]); |
| 983 | 982 | } |
| 984 | - $data =& self::$cache[$acc_id]; |
|
| 983 | + $data = & self::$cache[$acc_id]; |
|
| 985 | 984 | } |
| 986 | 985 | $where = array(self::TABLE.'.acc_id='.(int)$acc_id); |
| 987 | 986 | if (!isset($called_for) || $called_for !== '0') |
@@ -1005,7 +1004,7 @@ discard block |
||
| 1005 | 1004 | if (!$valid_account_id_sql) |
| 1006 | 1005 | { |
| 1007 | 1006 | $data['account_id'] = array(); |
| 1008 | - foreach(self::$db->select(self::VALID_TABLE, 'account_id', array('acc_id' => $acc_id), |
|
| 1007 | + foreach (self::$db->select(self::VALID_TABLE, 'account_id', array('acc_id' => $acc_id), |
|
| 1009 | 1008 | __LINE__, __FILE__, false, '', self::APP) as $row) |
| 1010 | 1009 | { |
| 1011 | 1010 | $data['account_id'][] = $row['account_id']; |
@@ -1017,7 +1016,7 @@ discard block |
||
| 1017 | 1016 | if (!isset($called_for)) |
| 1018 | 1017 | { |
| 1019 | 1018 | //error_log(__METHOD__."($acc_id) creating instance and caching data read from db"); |
| 1020 | - $ret =& self::$instances[$acc_id]; |
|
| 1019 | + $ret = & self::$instances[$acc_id]; |
|
| 1021 | 1020 | } |
| 1022 | 1021 | return $ret = new Account($data, $called_for); |
| 1023 | 1022 | } |
@@ -1030,7 +1029,7 @@ discard block |
||
| 1030 | 1029 | */ |
| 1031 | 1030 | protected static function db2data(array $data) |
| 1032 | 1031 | { |
| 1033 | - foreach(array('acc_sieve_enabled','acc_further_identities','acc_user_editable','acc_smtp_auth_session','acc_user_forward') as $name) |
|
| 1032 | + foreach (array('acc_sieve_enabled', 'acc_further_identities', 'acc_user_editable', 'acc_smtp_auth_session', 'acc_user_forward') as $name) |
|
| 1034 | 1033 | { |
| 1035 | 1034 | if (isset($data[$name])) |
| 1036 | 1035 | { |
@@ -1129,16 +1128,16 @@ discard block |
||
| 1129 | 1128 | * @throws Api\Exception\WrongParameter if called static without data-array |
| 1130 | 1129 | * @throws Api\Db\Exception |
| 1131 | 1130 | */ |
| 1132 | - public static function write(array $data, $user=null) |
|
| 1131 | + public static function write(array $data, $user = null) |
|
| 1133 | 1132 | { |
| 1134 | 1133 | //error_log(__METHOD__."(".array2string($data).")"); |
| 1135 | 1134 | $data['acc_modifier'] = $GLOBALS['egw_info']['user']['account_id']; |
| 1136 | 1135 | $data['acc_modified'] = time(); |
| 1137 | 1136 | |
| 1138 | 1137 | // remove redundant namespace to fit into column |
| 1139 | - $ns_len = strlen(__NAMESPACE__)+1; |
|
| 1138 | + $ns_len = strlen(__NAMESPACE__) + 1; |
|
| 1140 | 1139 | $backup = array(); |
| 1141 | - foreach(array('acc_smtp_type', 'acc_imap_type') as $attr) |
|
| 1140 | + foreach (array('acc_smtp_type', 'acc_imap_type') as $attr) |
|
| 1142 | 1141 | { |
| 1143 | 1142 | if (substr($data[$attr], 0, $ns_len) == __NAMESPACE__.'\\') |
| 1144 | 1143 | { |
@@ -1152,7 +1151,7 @@ discard block |
||
| 1152 | 1151 | { |
| 1153 | 1152 | // set not set values which, are NOT NULL and therefore would give an SQL error |
| 1154 | 1153 | $td = self::$db->get_table_definitions('api', self::TABLE); |
| 1155 | - foreach($td['fd'] as $col => $def) |
|
| 1154 | + foreach ($td['fd'] as $col => $def) |
|
| 1156 | 1155 | { |
| 1157 | 1156 | if (!isset($data[$col]) && $def['nullable'] === false && !isset($def['default'])) |
| 1158 | 1157 | { |
@@ -1189,19 +1188,19 @@ discard block |
||
| 1189 | 1188 | $old_account_ids = array(); |
| 1190 | 1189 | if ($where) |
| 1191 | 1190 | { |
| 1192 | - foreach(self::$db->select(self::VALID_TABLE, 'account_id', $where, |
|
| 1191 | + foreach (self::$db->select(self::VALID_TABLE, 'account_id', $where, |
|
| 1193 | 1192 | __LINE__, __FILE__, false, '', self::APP) as $row) |
| 1194 | 1193 | { |
| 1195 | 1194 | $old_account_ids[] = $row['account_id']; |
| 1196 | 1195 | } |
| 1197 | 1196 | if (($ids_to_remove = array_diff($old_account_ids, (array)$data['account_id']))) |
| 1198 | 1197 | { |
| 1199 | - self::$db->delete(self::VALID_TABLE, $where+array( |
|
| 1198 | + self::$db->delete(self::VALID_TABLE, $where + array( |
|
| 1200 | 1199 | 'account_id' => $ids_to_remove, |
| 1201 | 1200 | ), __LINE__, __FILE__, self::APP); |
| 1202 | 1201 | } |
| 1203 | 1202 | } |
| 1204 | - foreach((array)$data['account_id'] as $account_id) |
|
| 1203 | + foreach ((array)$data['account_id'] as $account_id) |
|
| 1205 | 1204 | { |
| 1206 | 1205 | if (!in_array($account_id, $old_account_ids)) |
| 1207 | 1206 | { |
@@ -1238,8 +1237,7 @@ discard block |
||
| 1238 | 1237 | } |
| 1239 | 1238 | |
| 1240 | 1239 | // store notification folders |
| 1241 | - Notifications::write($data['acc_id'], $data['notify_save_default'] ? 0 : |
|
| 1242 | - ($data['called_for'] ? $data['called_for'] : $GLOBALS['egw_info']['user']['account_id']), |
|
| 1240 | + Notifications::write($data['acc_id'], $data['notify_save_default'] ? 0 : ($data['called_for'] ? $data['called_for'] : $GLOBALS['egw_info']['user']['account_id']), |
|
| 1243 | 1241 | (array)$data['notify_folders']); |
| 1244 | 1242 | |
| 1245 | 1243 | // store domain of an account for all user like before as "mail_suffix" config |
@@ -1265,7 +1263,7 @@ discard block |
||
| 1265 | 1263 | * @param int $account_id =null |
| 1266 | 1264 | * @return boolean |
| 1267 | 1265 | */ |
| 1268 | - protected static function credentials_valid_for($account, $account_id=null) |
|
| 1266 | + protected static function credentials_valid_for($account, $account_id = null) |
|
| 1269 | 1267 | { |
| 1270 | 1268 | if (!isset($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id']; |
| 1271 | 1269 | |
@@ -1291,7 +1289,7 @@ discard block |
||
| 1291 | 1289 | * @param int $account_id =null user or group |
| 1292 | 1290 | * @return int number of deleted mail accounts or null if only user-data was deleted and no full mail accounts |
| 1293 | 1291 | */ |
| 1294 | - public static function delete($acc_id, $account_id=null) |
|
| 1292 | + public static function delete($acc_id, $account_id = null) |
|
| 1295 | 1293 | { |
| 1296 | 1294 | if (is_array($acc_id) || $acc_id > 0) |
| 1297 | 1295 | { |
@@ -1302,7 +1300,7 @@ discard block |
||
| 1302 | 1300 | self::$db->delete(self::TABLE, array('acc_id' => $acc_id), __LINE__, __FILE__, self::APP); |
| 1303 | 1301 | |
| 1304 | 1302 | // invalidate caches |
| 1305 | - foreach((array)$acc_id as $acc_id) |
|
| 1303 | + foreach ((array)$acc_id as $acc_id) |
|
| 1306 | 1304 | { |
| 1307 | 1305 | self::cache_invalidate($acc_id); |
| 1308 | 1306 | } |
@@ -1321,7 +1319,7 @@ discard block |
||
| 1321 | 1319 | self::$db->delete(self::IDENTITIES_TABLE, array('account_id' => $account_id), __LINE__, __FILE__, self::APP); |
| 1322 | 1320 | // find profiles not belonging to anyone else and delete them |
| 1323 | 1321 | $acc_ids = array(); |
| 1324 | - foreach(self::$db->select(self::TABLE, self::TABLE.'.acc_id', 'account_id IS NULL', __LINE__, __FILE__, |
|
| 1322 | + foreach (self::$db->select(self::TABLE, self::TABLE.'.acc_id', 'account_id IS NULL', __LINE__, __FILE__, |
|
| 1325 | 1323 | false, 'GROUP BY '.self::TABLE.'.acc_id', self::APP, 0, 'LEFT '.self::VALID_JOIN) as $row) |
| 1326 | 1324 | { |
| 1327 | 1325 | $acc_ids[] = $row['acc_id']; |
@@ -1345,7 +1343,7 @@ discard block |
||
| 1345 | 1343 | * @param boolean $replace_placeholders =true should placeholders like {{n_fn}} be replaced |
| 1346 | 1344 | * @return Iterator with acc_id => acc_name or Account objects |
| 1347 | 1345 | */ |
| 1348 | - public static function search($only_current_user=true, $just_name=true, $order_by=null, $offset=false, $num_rows=0, $replace_placeholders=true) |
|
| 1346 | + public static function search($only_current_user = true, $just_name = true, $order_by = null, $offset = false, $num_rows = 0, $replace_placeholders = true) |
|
| 1349 | 1347 | { |
| 1350 | 1348 | //error_log(__METHOD__."($only_current_user, $just_name, '$order_by', $offset, $num_rows)"); |
| 1351 | 1349 | $where = array(); |
@@ -1391,19 +1389,19 @@ discard block |
||
| 1391 | 1389 | $cols[] = self::ADMIN_COL; |
| 1392 | 1390 | $join .= ' '.self::ADMIN_JOIN; |
| 1393 | 1391 | } |
| 1394 | - $rs = self::$db->select(self::TABLE, $cols, $where, __LINE__, __FILE__, |
|
| 1392 | + $rs = self::$db->select(self::TABLE, $cols, $where, __LINE__, __FILE__, |
|
| 1395 | 1393 | $offset, Api\Storage::fix_group_by_columns($group_by, $cols, self::TABLE, 'acc_id').' ORDER BY '.$order_by, |
| 1396 | 1394 | self::APP, $num_rows, $join); |
| 1397 | 1395 | |
| 1398 | 1396 | $ids = array(); |
| 1399 | - foreach($rs as $row) |
|
| 1397 | + foreach ($rs as $row) |
|
| 1400 | 1398 | { |
| 1401 | 1399 | $row = self::db2data($row); |
| 1402 | 1400 | |
| 1403 | 1401 | if ($only_current_user === true) |
| 1404 | 1402 | { |
| 1405 | 1403 | //error_log(__METHOD__."(TRUE, $just_name) caching data for acc_id=$row[acc_id]"); |
| 1406 | - self::$search_cache[$cache_key][$row['acc_id']] =& self::$cache[$row['acc_id']]; |
|
| 1404 | + self::$search_cache[$cache_key][$row['acc_id']] = & self::$cache[$row['acc_id']]; |
|
| 1407 | 1405 | self::$cache[$row['acc_id']] = $row; |
| 1408 | 1406 | } |
| 1409 | 1407 | else |
@@ -1415,14 +1413,14 @@ discard block |
||
| 1415 | 1413 | // fetch valid_id, if not yet fetched |
| 1416 | 1414 | if (!$valid_account_id_sql && $ids) |
| 1417 | 1415 | { |
| 1418 | - foreach(self::$db->select(self::VALID_TABLE, 'account_id', array('acc_id' => $ids), |
|
| 1416 | + foreach (self::$db->select(self::VALID_TABLE, 'account_id', array('acc_id' => $ids), |
|
| 1419 | 1417 | __LINE__, __FILE__, false, '', self::APP) as $row) |
| 1420 | 1418 | { |
| 1421 | 1419 | self::$cache[$row['acc_id']]['account_id'][] = $row['account_id']; |
| 1422 | 1420 | } |
| 1423 | 1421 | } |
| 1424 | 1422 | } |
| 1425 | - if (is_null(self::$search_cache[$cache_key])) self::$search_cache[$cache_key]=array(); |
|
| 1423 | + if (is_null(self::$search_cache[$cache_key])) self::$search_cache[$cache_key] = array(); |
|
| 1426 | 1424 | return new Api\Db\CallbackIterator(new \ArrayIterator(self::$search_cache[$cache_key]), |
| 1427 | 1425 | // process each row |
| 1428 | 1426 | function($row) use ($just_name, $replace_placeholders, $account_id) |
@@ -1456,11 +1454,11 @@ discard block |
||
| 1456 | 1454 | * @param boolean $log_no_default =true true: error_log if no default found, false be silent |
| 1457 | 1455 | * @return Account|null |
| 1458 | 1456 | */ |
| 1459 | - static function get_default($smtp=false, $return_id=false, $log_no_default=true) |
|
| 1457 | + static function get_default($smtp = false, $return_id = false, $log_no_default = true) |
|
| 1460 | 1458 | { |
| 1461 | 1459 | try |
| 1462 | 1460 | { |
| 1463 | - foreach(self::search(true, 'params') as $acc_id => $params) |
|
| 1461 | + foreach (self::search(true, 'params') as $acc_id => $params) |
|
| 1464 | 1462 | { |
| 1465 | 1463 | if ($smtp) |
| 1466 | 1464 | { |
@@ -1507,7 +1505,7 @@ discard block |
||
| 1507 | 1505 | * @param boolean $smtp =false false: usable for IMAP, true: usable for SMTP |
| 1508 | 1506 | * @return int |
| 1509 | 1507 | */ |
| 1510 | - static function get_default_acc_id($smtp=false) |
|
| 1508 | + static function get_default_acc_id($smtp = false) |
|
| 1511 | 1509 | { |
| 1512 | 1510 | return self::get_default($smtp, true); |
| 1513 | 1511 | } |
@@ -1520,7 +1518,7 @@ discard block |
||
| 1520 | 1518 | * @param int $account_id =null account_id of user we are called for |
| 1521 | 1519 | * @return string with htmlencoded angle brackets |
| 1522 | 1520 | */ |
| 1523 | - public static function identity_name($account, $replace_placeholders=true, $account_id=null) |
|
| 1521 | + public static function identity_name($account, $replace_placeholders = true, $account_id = null) |
|
| 1524 | 1522 | { |
| 1525 | 1523 | if ($replace_placeholders) |
| 1526 | 1524 | { |
@@ -1547,7 +1545,7 @@ discard block |
||
| 1547 | 1545 | { |
| 1548 | 1546 | if (!isset($account['acc_imap_username'])) |
| 1549 | 1547 | { |
| 1550 | - $account += Credentials::read($account['acc_id'], null, ($account_id?array($account_id, 0):null)); |
|
| 1548 | + $account += Credentials::read($account['acc_id'], null, ($account_id ? array($account_id, 0) : null)); |
|
| 1551 | 1549 | } |
| 1552 | 1550 | if (empty($account['acc_imap_username']) && $account['acc_imap_logintype'] && |
| 1553 | 1551 | (!isset($account_id) || $account_id == $GLOBALS['egw_info']['user']['account_id'])) |
@@ -1566,7 +1564,7 @@ discard block |
||
| 1566 | 1564 | $account['ident_email'] = $account['acc_imap_username']; |
| 1567 | 1565 | } |
| 1568 | 1566 | } |
| 1569 | - catch(\Exception $e) { |
|
| 1567 | + catch (\Exception $e) { |
|
| 1570 | 1568 | _egw_log_exception($e); |
| 1571 | 1569 | } |
| 1572 | 1570 | |
@@ -1583,7 +1581,7 @@ discard block |
||
| 1583 | 1581 | { |
| 1584 | 1582 | $name .= ' <'.$account['ident_email'].'>'; |
| 1585 | 1583 | } |
| 1586 | - elseif(strpos($account['acc_imap_username'], '@') !== false) |
|
| 1584 | + elseif (strpos($account['acc_imap_username'], '@') !== false) |
|
| 1587 | 1585 | { |
| 1588 | 1586 | $name .= ' <'.$account['acc_imap_username'].'>'; |
| 1589 | 1587 | } |
@@ -1606,8 +1604,7 @@ discard block |
||
| 1606 | 1604 | */ |
| 1607 | 1605 | public static function is_multiple($account) |
| 1608 | 1606 | { |
| 1609 | - $is_multiple = !is_array($account['account_id']) ? $account['account_id'] <= 0 : |
|
| 1610 | - (count($account['account_id']) > 1 || $account['account_id'][0] <= 0); |
|
| 1607 | + $is_multiple = !is_array($account['account_id']) ? $account['account_id'] <= 0 : (count($account['account_id']) > 1 || $account['account_id'][0] <= 0); |
|
| 1611 | 1608 | //error_log(__METHOD__."(account_id=".array2string($account['account_id']).") returning ".array2string($is_multiple)); |
| 1612 | 1609 | return $is_multiple; |
| 1613 | 1610 | } |
@@ -1628,13 +1625,13 @@ discard block |
||
| 1628 | 1625 | * @param type $user |
| 1629 | 1626 | * @return array |
| 1630 | 1627 | */ |
| 1631 | - protected static function memberships($user=null) |
|
| 1628 | + protected static function memberships($user = null) |
|
| 1632 | 1629 | { |
| 1633 | 1630 | if (!$user) $user = $GLOBALS['egw_info']['user']['account_id']; |
| 1634 | 1631 | |
| 1635 | 1632 | $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
| 1636 | 1633 | $memberships[] = $user; |
| 1637 | - $memberships[] = 0; // marks accounts valid for everyone |
|
| 1634 | + $memberships[] = 0; // marks accounts valid for everyone |
|
| 1638 | 1635 | |
| 1639 | 1636 | return $memberships; |
| 1640 | 1637 | } |
@@ -360,8 +360,14 @@ discard block |
||
| 360 | 360 | { |
| 361 | 361 | // make sure mbstring.func_overload=0 |
| 362 | 362 | static $func_overload = null; |
| 363 | - if (is_null($func_overload)) $func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0; |
|
| 364 | - if ($func_overload) throw new Api\Exception\AssertionFailed('Fatal Error: EGroupware requires mbstring.func_overload=0 set in your php.ini!'); |
|
| 363 | + if (is_null($func_overload)) |
|
| 364 | + { |
|
| 365 | + $func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0; |
|
| 366 | + } |
|
| 367 | + if ($func_overload) |
|
| 368 | + { |
|
| 369 | + throw new Api\Exception\AssertionFailed('Fatal Error: EGroupware requires mbstring.func_overload=0 set in your php.ini!'); |
|
| 370 | + } |
|
| 365 | 371 | |
| 366 | 372 | $class = $this->params['acc_imap_type']; |
| 367 | 373 | $this->imapServer = new $class($this->params, $_adminConnection, $_timeout); |
@@ -490,7 +496,10 @@ discard block |
||
| 490 | 496 | */ |
| 491 | 497 | public static function identities($account, $replace_placeholders=true, $field='name', $user=null) |
| 492 | 498 | { |
| 493 | - if (!isset($user)) $user = $GLOBALS['egw_info']['user']['account_id']; |
|
| 499 | + if (!isset($user)) |
|
| 500 | + { |
|
| 501 | + $user = $GLOBALS['egw_info']['user']['account_id']; |
|
| 502 | + } |
|
| 494 | 503 | $acc_id = is_scalar($account) ? $account : $account['acc_id']; |
| 495 | 504 | |
| 496 | 505 | $cols = array('ident_id', 'ident_name', 'ident_realname', 'ident_org', 'ident_email', 'ident_signature', 'acc_id', 'acc_imap_username', 'acc_imap_logintype', 'acc_domain'); |
@@ -528,8 +537,14 @@ discard block |
||
| 528 | 537 | // fill an empty ident_realname or ident_email of current user with data from user account |
| 529 | 538 | if ($replace_placeholders && (!isset($user) || $user == $GLOBALS['egw_info']['user']['acount_id'])) |
| 530 | 539 | { |
| 531 | - if (empty($row['ident_realname'])) $row['ident_realname'] = $GLOBALS['egw_info']['user']['account_fullname']; |
|
| 532 | - if (empty($row['ident_email'])) $row['ident_email'] = $GLOBALS['egw_info']['user']['account_email']; |
|
| 540 | + if (empty($row['ident_realname'])) |
|
| 541 | + { |
|
| 542 | + $row['ident_realname'] = $GLOBALS['egw_info']['user']['account_fullname']; |
|
| 543 | + } |
|
| 544 | + if (empty($row['ident_email'])) |
|
| 545 | + { |
|
| 546 | + $row['ident_email'] = $GLOBALS['egw_info']['user']['account_email']; |
|
| 547 | + } |
|
| 533 | 548 | } |
| 534 | 549 | if ($field != 'name') |
| 535 | 550 | { |
@@ -538,7 +553,9 @@ discard block |
||
| 538 | 553 | } |
| 539 | 554 | return self::identity_name($row, $replace_placeholders); |
| 540 | 555 | }, array(), |
| 541 | - function($row) { return $row['ident_id'];}); |
|
| 556 | + function($row) |
|
| 557 | + { |
|
| 558 | +return $row['ident_id'];}); |
|
| 542 | 559 | } |
| 543 | 560 | |
| 544 | 561 | /** |
@@ -554,10 +571,13 @@ discard block |
||
| 554 | 571 | { |
| 555 | 572 | $address .= ($address && $identity['ident_org'] ? ' ' : '').$identity['ident_org']; |
| 556 | 573 | } |
| 557 | - if (strpos($address, ',') !== false) // need to quote comma |
|
| 574 | + if (strpos($address, ',') !== false) |
|
| 575 | + { |
|
| 576 | + // need to quote comma |
|
| 558 | 577 | { |
| 559 | 578 | $address = '"'.str_replace('"', '\\"', $address).'"'; |
| 560 | 579 | } |
| 580 | + } |
|
| 561 | 581 | if (!strpos($identity['ident_email'], '@')) |
| 562 | 582 | { |
| 563 | 583 | $address = null; |
@@ -661,8 +681,14 @@ discard block |
||
| 661 | 681 | if ($to_replace) |
| 662 | 682 | { |
| 663 | 683 | static $merge=null; |
| 664 | - if (!isset($merge)) $merge = new Api\Contacts\Merge(); |
|
| 665 | - if (!isset($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id']; |
|
| 684 | + if (!isset($merge)) |
|
| 685 | + { |
|
| 686 | + $merge = new Api\Contacts\Merge(); |
|
| 687 | + } |
|
| 688 | + if (!isset($account_id)) |
|
| 689 | + { |
|
| 690 | + $account_id = $GLOBALS['egw_info']['user']['account_id']; |
|
| 691 | + } |
|
| 666 | 692 | foreach($to_replace as $name => &$value) |
| 667 | 693 | { |
| 668 | 694 | $err = null; |
@@ -1083,7 +1109,10 @@ discard block |
||
| 1083 | 1109 | } |
| 1084 | 1110 | |
| 1085 | 1111 | // fetch the IMAP / incomming server data |
| 1086 | - if (!class_exists($data['acc_smtp_type'])) $data['acc_smtp_type'] = __NAMESPACE__.'\\Smtp'; |
|
| 1112 | + if (!class_exists($data['acc_smtp_type'])) |
|
| 1113 | + { |
|
| 1114 | + $data['acc_smtp_type'] = __NAMESPACE__.'\\Smtp'; |
|
| 1115 | + } |
|
| 1087 | 1116 | } |
| 1088 | 1117 | } |
| 1089 | 1118 | return $data; |
@@ -1115,7 +1144,10 @@ discard block |
||
| 1115 | 1144 | } |
| 1116 | 1145 | |
| 1117 | 1146 | // fetch the IMAP / incomming server data |
| 1118 | - if (!class_exists($imap_type)) $imap_type = __NAMESPACE__.'\\Imap'; |
|
| 1147 | + if (!class_exists($imap_type)) |
|
| 1148 | + { |
|
| 1149 | + $imap_type = __NAMESPACE__.'\\Imap'; |
|
| 1150 | + } |
|
| 1119 | 1151 | |
| 1120 | 1152 | return $imap_type; |
| 1121 | 1153 | } |
@@ -1168,7 +1200,10 @@ discard block |
||
| 1168 | 1200 | $data['acc_id'] = self::$db->get_last_insert_id(self::TABLE, 'acc_id'); |
| 1169 | 1201 | } |
| 1170 | 1202 | // restore namespace in class-names |
| 1171 | - if ($backup) $data = array_merge($data, $backup); |
|
| 1203 | + if ($backup) |
|
| 1204 | + { |
|
| 1205 | + $data = array_merge($data, $backup); |
|
| 1206 | + } |
|
| 1172 | 1207 | |
| 1173 | 1208 | // store identity |
| 1174 | 1209 | $new_ident_id = self::save_identity($data); |
@@ -1279,7 +1314,10 @@ discard block |
||
| 1279 | 1314 | */ |
| 1280 | 1315 | protected static function credentials_valid_for($account, $account_id=null) |
| 1281 | 1316 | { |
| 1282 | - if (!isset($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id']; |
|
| 1317 | + if (!isset($account_id)) |
|
| 1318 | + { |
|
| 1319 | + $account_id = $GLOBALS['egw_info']['user']['account_id']; |
|
| 1320 | + } |
|
| 1283 | 1321 | |
| 1284 | 1322 | // if account valid for multiple users |
| 1285 | 1323 | if (self::is_multiple($account)) |
@@ -1398,9 +1436,12 @@ discard block |
||
| 1398 | 1436 | $cols[] = $valid_account_id_sql.' AS account_id'; |
| 1399 | 1437 | $join .= ' '.self::ALL_VALID_JOIN; |
| 1400 | 1438 | } |
| 1401 | - if ($just_name == 'params') // join in acc_imap_admin_username |
|
| 1439 | + if ($just_name == 'params') |
|
| 1440 | + { |
|
| 1441 | + // join in acc_imap_admin_username |
|
| 1402 | 1442 | { |
| 1403 | 1443 | $cols[] = self::ADMIN_COL; |
| 1444 | + } |
|
| 1404 | 1445 | $join .= ' '.self::ADMIN_JOIN; |
| 1405 | 1446 | } |
| 1406 | 1447 | $rs = self::$db->select(self::TABLE, $cols, $where, __LINE__, __FILE__, |
@@ -1434,7 +1475,10 @@ discard block |
||
| 1434 | 1475 | } |
| 1435 | 1476 | } |
| 1436 | 1477 | } |
| 1437 | - if (is_null(self::$search_cache[$cache_key])) self::$search_cache[$cache_key]=array(); |
|
| 1478 | + if (is_null(self::$search_cache[$cache_key])) |
|
| 1479 | + { |
|
| 1480 | + self::$search_cache[$cache_key]=array(); |
|
| 1481 | + } |
|
| 1438 | 1482 | return new Api\Db\CallbackIterator(new \ArrayIterator(self::$search_cache[$cache_key]), |
| 1439 | 1483 | // process each row |
| 1440 | 1484 | function($row) use ($just_name, $replace_placeholders, $account_id) |
@@ -1476,12 +1520,18 @@ discard block |
||
| 1476 | 1520 | { |
| 1477 | 1521 | if ($smtp) |
| 1478 | 1522 | { |
| 1479 | - if (!$params['acc_smtp_host'] || !$params['acc_smtp_port']) continue; |
|
| 1523 | + if (!$params['acc_smtp_host'] || !$params['acc_smtp_port']) |
|
| 1524 | + { |
|
| 1525 | + continue; |
|
| 1526 | + } |
|
| 1480 | 1527 | // check requirement of session, which is not available in async service! |
| 1481 | 1528 | if (isset($GLOBALS['egw_info']['flags']['async-service']) || |
| 1482 | - empty($GLOBALS['egw_info']['user']['account_id'])) // happens during login when notifying about blocked accounts |
|
| 1529 | + empty($GLOBALS['egw_info']['user']['account_id'])) |
|
| 1530 | + { |
|
| 1531 | + // happens during login when notifying about blocked accounts |
|
| 1483 | 1532 | { |
| 1484 | 1533 | if ($params['acc_smtp_auth_session']) continue; |
| 1534 | + } |
|
| 1485 | 1535 | // may fail because of smtp only profile, or no session password, etc |
| 1486 | 1536 | try |
| 1487 | 1537 | { |
@@ -1492,15 +1542,24 @@ discard block |
||
| 1492 | 1542 | unset($x); |
| 1493 | 1543 | continue; |
| 1494 | 1544 | } |
| 1495 | - if (Credentials::isUser($account->acc_smtp_pw_enc)) continue; |
|
| 1545 | + if (Credentials::isUser($account->acc_smtp_pw_enc)) |
|
| 1546 | + { |
|
| 1547 | + continue; |
|
| 1548 | + } |
|
| 1496 | 1549 | } |
| 1497 | 1550 | } |
| 1498 | 1551 | else |
| 1499 | 1552 | { |
| 1500 | - if (!$params['acc_imap_host'] || !$params['acc_imap_port']) continue; |
|
| 1553 | + if (!$params['acc_imap_host'] || !$params['acc_imap_port']) |
|
| 1554 | + { |
|
| 1555 | + continue; |
|
| 1556 | + } |
|
| 1501 | 1557 | $account = new Account($params); |
| 1502 | 1558 | // continue if we have either no imap username or password |
| 1503 | - if (!$account->is_imap()) continue; |
|
| 1559 | + if (!$account->is_imap()) |
|
| 1560 | + { |
|
| 1561 | + continue; |
|
| 1562 | + } |
|
| 1504 | 1563 | } |
| 1505 | 1564 | return $return_id ? $acc_id : (isset($account) && $account->acc_id == $acc_id ? |
| 1506 | 1565 | $account : new Account($params)); |
@@ -1508,7 +1567,10 @@ discard block |
||
| 1508 | 1567 | } |
| 1509 | 1568 | catch (\Exception $e) |
| 1510 | 1569 | { |
| 1511 | - if ($log_no_default) error_log(__METHOD__.__LINE__.' Error no Default available.'.$e->getMessage()); |
|
| 1570 | + if ($log_no_default) |
|
| 1571 | + { |
|
| 1572 | + error_log(__METHOD__.__LINE__.' Error no Default available.'.$e->getMessage()); |
|
| 1573 | + } |
|
| 1512 | 1574 | } |
| 1513 | 1575 | return null; |
| 1514 | 1576 | } |
@@ -1570,8 +1632,14 @@ discard block |
||
| 1570 | 1632 | // fill an empty ident_realname or ident_email of current user with data from user account |
| 1571 | 1633 | if ($replace_placeholders && (!isset($account_id) || $account_id == $GLOBALS['egw_info']['user']['acount_id'])) |
| 1572 | 1634 | { |
| 1573 | - if (empty($account['ident_realname'])) $account['ident_realname'] = $GLOBALS['egw_info']['user']['account_fullname']; |
|
| 1574 | - if (empty($account['ident_email'])) $account['ident_email'] = $GLOBALS['egw_info']['user']['account_email']; |
|
| 1635 | + if (empty($account['ident_realname'])) |
|
| 1636 | + { |
|
| 1637 | + $account['ident_realname'] = $GLOBALS['egw_info']['user']['account_fullname']; |
|
| 1638 | + } |
|
| 1639 | + if (empty($account['ident_email'])) |
|
| 1640 | + { |
|
| 1641 | + $account['ident_email'] = $GLOBALS['egw_info']['user']['account_email']; |
|
| 1642 | + } |
|
| 1575 | 1643 | } |
| 1576 | 1644 | if (empty($account['ident_email']) && !empty($account['acc_imap_username']) && strpos($account['acc_imap_username'], '@') !== false) |
| 1577 | 1645 | { |
@@ -1642,7 +1710,10 @@ discard block |
||
| 1642 | 1710 | */ |
| 1643 | 1711 | protected static function memberships($user=null) |
| 1644 | 1712 | { |
| 1645 | - if (!$user) $user = $GLOBALS['egw_info']['user']['account_id']; |
|
| 1713 | + if (!$user) |
|
| 1714 | + { |
|
| 1715 | + $user = $GLOBALS['egw_info']['user']['account_id']; |
|
| 1716 | + } |
|
| 1646 | 1717 | |
| 1647 | 1718 | $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
| 1648 | 1719 | $memberships[] = $user; |
@@ -36,9 +36,6 @@ discard block |
||
| 36 | 36 | * Hook called before an account get deleted |
| 37 | 37 | * |
| 38 | 38 | * @param array $data |
| 39 | - * @param int $data['account_id'] numerical id |
|
| 40 | - * @param string $data['account_lid'] account-name |
|
| 41 | - * @param int $data['new_owner'] account-id of new owner, or false if data should get deleted |
|
| 42 | 39 | */ |
| 43 | 40 | static function deleteaccount(array $data) |
| 44 | 41 | { |
@@ -52,8 +49,6 @@ discard block |
||
| 52 | 49 | * Hook called before a group get deleted |
| 53 | 50 | * |
| 54 | 51 | * @param array $data |
| 55 | - * @param int $data['account_id'] numerical id |
|
| 56 | - * @param string $data['account_name'] account-name |
|
| 57 | 52 | */ |
| 58 | 53 | static function deletegroup(array $data) |
| 59 | 54 | { |
@@ -64,9 +59,6 @@ discard block |
||
| 64 | 59 | * Hook called when an account get added or edited |
| 65 | 60 | * |
| 66 | 61 | * @param array $data |
| 67 | - * @param int $data['account_id'] numerical id |
|
| 68 | - * @param string $data['account_lid'] account-name |
|
| 69 | - * @param string $data['account_email'] email |
|
| 70 | 62 | */ |
| 71 | 63 | static function addaccount(array $data) |
| 72 | 64 | { |
@@ -32,14 +32,14 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Hook called before an account get deleted |
|
| 37 | - * |
|
| 38 | - * @param array $data |
|
| 39 | - * @param int $data['account_id'] numerical id |
|
| 40 | - * @param string $data['account_lid'] account-name |
|
| 41 | - * @param int $data['new_owner'] account-id of new owner, or false if data should get deleted |
|
| 42 | - */ |
|
| 35 | + /** |
|
| 36 | + * Hook called before an account get deleted |
|
| 37 | + * |
|
| 38 | + * @param array $data |
|
| 39 | + * @param int $data['account_id'] numerical id |
|
| 40 | + * @param string $data['account_lid'] account-name |
|
| 41 | + * @param int $data['new_owner'] account-id of new owner, or false if data should get deleted |
|
| 42 | + */ |
|
| 43 | 43 | static function deleteaccount(array $data) |
| 44 | 44 | { |
| 45 | 45 | self::run_plugin_hooks('deleteAccount', $data); |
@@ -48,25 +48,25 @@ discard block |
||
| 48 | 48 | Account::delete(0, $data['account_id']); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Hook called before a group get deleted |
|
| 53 | - * |
|
| 54 | - * @param array $data |
|
| 55 | - * @param int $data['account_id'] numerical id |
|
| 56 | - * @param string $data['account_name'] account-name |
|
| 57 | - */ |
|
| 51 | + /** |
|
| 52 | + * Hook called before a group get deleted |
|
| 53 | + * |
|
| 54 | + * @param array $data |
|
| 55 | + * @param int $data['account_id'] numerical id |
|
| 56 | + * @param string $data['account_name'] account-name |
|
| 57 | + */ |
|
| 58 | 58 | static function deletegroup(array $data) |
| 59 | 59 | { |
| 60 | 60 | Account::delete(0, $data['account_id']); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | - * Hook called when an account get added or edited |
|
| 65 | - * |
|
| 66 | - * @param array $data |
|
| 67 | - * @param int $data['account_id'] numerical id |
|
| 68 | - * @param string $data['account_lid'] account-name |
|
| 69 | - * @param string $data['account_email'] email |
|
| 64 | + * Hook called when an account get added or edited |
|
| 65 | + * |
|
| 66 | + * @param array $data |
|
| 67 | + * @param int $data['account_id'] numerical id |
|
| 68 | + * @param string $data['account_lid'] account-name |
|
| 69 | + * @param string $data['account_email'] email |
|
| 70 | 70 | */ |
| 71 | 71 | static function addaccount(array $data) |
| 72 | 72 | { |
@@ -82,9 +82,9 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | protected static function run_plugin_hooks($method, array $data) |
| 84 | 84 | { |
| 85 | - foreach(Account::search((int)$data['account_id'], 'params') as $params) |
|
| 85 | + foreach (Account::search((int)$data['account_id'], 'params') as $params) |
|
| 86 | 86 | { |
| 87 | - if (!Account::is_multiple($params)) continue; // no need to waste time on personal accounts |
|
| 87 | + if (!Account::is_multiple($params)) continue; // no need to waste time on personal accounts |
|
| 88 | 88 | |
| 89 | 89 | try { |
| 90 | 90 | $account = new Account($params); |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | $imap->$method($data); |
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | - catch(\Exception $e) { |
|
| 103 | + catch (\Exception $e) { |
|
| 104 | 104 | _egw_log_exception($e); |
| 105 | 105 | // ignore exception, without stalling other hooks |
| 106 | 106 | } |
@@ -84,7 +84,11 @@ |
||
| 84 | 84 | { |
| 85 | 85 | foreach(Account::search((int)$data['account_id'], 'params') as $params) |
| 86 | 86 | { |
| 87 | - if (!Account::is_multiple($params)) continue; // no need to waste time on personal accounts |
|
| 87 | + if (!Account::is_multiple($params)) |
|
| 88 | + { |
|
| 89 | + continue; |
|
| 90 | + } |
|
| 91 | + // no need to waste time on personal accounts |
|
| 88 | 92 | |
| 89 | 93 | try { |
| 90 | 94 | $account = new Account($params); |
@@ -227,7 +227,7 @@ |
||
| 227 | 227 | * @param string $displayCharset : charset to use; should be a valid charset |
| 228 | 228 | * @param bool $stripcrl : flag to indicate for the removal of all crlf \r\n |
| 229 | 229 | * @param bool $stripalltags : flag to indicate wether or not to strip $_html from all remaining tags |
| 230 | - * @return text $_html : the modified text. |
|
| 230 | + * @return string $_html : the modified text. |
|
| 231 | 231 | */ |
| 232 | 232 | static function convertHTMLToText($_html,$displayCharset=false,$stripcrl=false,$stripalltags=true) |
| 233 | 233 | { |
@@ -28,17 +28,17 @@ discard block |
||
| 28 | 28 | * @param integer $reclevel param to control recursive calls (to prevent endless recursion) |
| 29 | 29 | * @return string |
| 30 | 30 | */ |
| 31 | - static function decodeMailHeader($_string, $displayCharset='utf-8', $reclevel=0) |
|
| 31 | + static function decodeMailHeader($_string, $displayCharset = 'utf-8', $reclevel = 0) |
|
| 32 | 32 | { |
| 33 | - $maxreclevel=25; |
|
| 33 | + $maxreclevel = 25; |
|
| 34 | 34 | if ($reclevel > $maxreclevel) { |
| 35 | - error_log( __METHOD__.__LINE__." Recursion Level Exeeded ($reclevel) while decoding $_string "); |
|
| 35 | + error_log(__METHOD__.__LINE__." Recursion Level Exeeded ($reclevel) while decoding $_string "); |
|
| 36 | 36 | return $_string; |
| 37 | 37 | } |
| 38 | 38 | $reclevel++; |
| 39 | 39 | |
| 40 | 40 | //error_log(__FILE__.','.__METHOD__.':'."called with $_string and CHARSET $displayCharset"); |
| 41 | - if(function_exists('imap_mime_header_decode')) |
|
| 41 | + if (function_exists('imap_mime_header_decode')) |
|
| 42 | 42 | { |
| 43 | 43 | // some characterreplacements, as they fail to translate |
| 44 | 44 | $sar = array( |
@@ -60,23 +60,23 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | $string = preg_replace('/\?=\s+=\?/', '?= =?', $_string); |
| 62 | 62 | |
| 63 | - $elements=imap_mime_header_decode($string); |
|
| 63 | + $elements = imap_mime_header_decode($string); |
|
| 64 | 64 | |
| 65 | 65 | $convertAtEnd = false; |
| 66 | - foreach((array)$elements as $element) |
|
| 66 | + foreach ((array)$elements as $element) |
|
| 67 | 67 | { |
| 68 | 68 | if ($element->charset == 'default') $element->charset = Api\Translation::detect_encoding($element->text); |
| 69 | 69 | if ($element->charset != 'x-unknown') |
| 70 | 70 | { |
| 71 | - if( strtoupper($element->charset) != 'UTF-8') $element->text = preg_replace($sar,$rar,$element->text); |
|
| 71 | + if (strtoupper($element->charset) != 'UTF-8') $element->text = preg_replace($sar, $rar, $element->text); |
|
| 72 | 72 | // check if there is a possible nested encoding; make sure that the inputstring and the decoded result are different to avoid loops |
| 73 | - $openTags = substr_count($element->text,'?='); |
|
| 74 | - if(preg_match('/\?=.+=\?/', $element->text) && $openTags>0 && $openTags==substr_count($element->text,'=?') && $element->text != $_string) |
|
| 73 | + $openTags = substr_count($element->text, '?='); |
|
| 74 | + if (preg_match('/\?=.+=\?/', $element->text) && $openTags > 0 && $openTags == substr_count($element->text, '=?') && $element->text != $_string) |
|
| 75 | 75 | { |
| 76 | 76 | $element->text = self::decodeMailHeader($element->text, $element->charset, $reclevel); |
| 77 | 77 | $element->charset = $displayCharset; |
| 78 | 78 | } |
| 79 | - $newString .= Api\Translation::convert($element->text,$element->charset); |
|
| 79 | + $newString .= Api\Translation::convert($element->text, $element->charset); |
|
| 80 | 80 | } |
| 81 | 81 | else |
| 82 | 82 | { |
@@ -84,34 +84,34 @@ discard block |
||
| 84 | 84 | $convertAtEnd = true; |
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | - if ($convertAtEnd) $newString = self::decodeMailHeader($newString,$displayCharset,$reclevel); |
|
| 88 | - return preg_replace('/([\000-\012\015\016\020-\037\075])/','',$newString); |
|
| 87 | + if ($convertAtEnd) $newString = self::decodeMailHeader($newString, $displayCharset, $reclevel); |
|
| 88 | + return preg_replace('/([\000-\012\015\016\020-\037\075])/', '', $newString); |
|
| 89 | 89 | } |
| 90 | - elseif(function_exists(mb_decode_mimeheader)) |
|
| 90 | + elseif (function_exists(mb_decode_mimeheader)) |
|
| 91 | 91 | { |
| 92 | 92 | $matches = null; |
| 93 | - if(preg_match_all('/=\?.*\?Q\?.*\?=/iU', $string=$_string, $matches)) |
|
| 93 | + if (preg_match_all('/=\?.*\?Q\?.*\?=/iU', $string = $_string, $matches)) |
|
| 94 | 94 | { |
| 95 | - foreach($matches[0] as $match) |
|
| 95 | + foreach ($matches[0] as $match) |
|
| 96 | 96 | { |
| 97 | 97 | $fixedMatch = str_replace('_', ' ', $match); |
| 98 | 98 | $string = str_replace($match, $fixedMatch, $string); |
| 99 | 99 | } |
| 100 | - $string = str_replace('=?ISO8859-','=?ISO-8859-', |
|
| 101 | - str_replace('=?windows-1258','=?ISO-8859-1',$string)); |
|
| 100 | + $string = str_replace('=?ISO8859-', '=?ISO-8859-', |
|
| 101 | + str_replace('=?windows-1258', '=?ISO-8859-1', $string)); |
|
| 102 | 102 | } |
| 103 | 103 | $string = mb_decode_mimeheader($string); |
| 104 | - return preg_replace('/([\000-\012\015\016\020-\037\075])/','',$string); |
|
| 104 | + return preg_replace('/([\000-\012\015\016\020-\037\075])/', '', $string); |
|
| 105 | 105 | } |
| 106 | - elseif(function_exists(iconv_mime_decode)) |
|
| 106 | + elseif (function_exists(iconv_mime_decode)) |
|
| 107 | 107 | { |
| 108 | 108 | // continue decoding also if an error occurs |
| 109 | 109 | $string = @iconv_mime_decode($_string, 2, $displayCharset); |
| 110 | - return preg_replace('/([\000-\012\015\016\020-\037\075])/','',$string); |
|
| 110 | + return preg_replace('/([\000-\012\015\016\020-\037\075])/', '', $string); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | // no decoding function available |
| 114 | - return preg_replace('/([\000-\012\015\016\020-\037\075])/','',$_string); |
|
| 114 | + return preg_replace('/([\000-\012\015\016\020-\037\075])/', '', $_string); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -124,15 +124,15 @@ discard block |
||
| 124 | 124 | { |
| 125 | 125 | //error_log($text); |
| 126 | 126 | //replace CRLF with something other to be preserved via preg_replace as CRLF seems to vanish |
| 127 | - $text2 = str_replace("\r\n",'<#cr-lf#>',$text); |
|
| 127 | + $text2 = str_replace("\r\n", '<#cr-lf#>', $text); |
|
| 128 | 128 | // replace emailaddresses eclosed in <> (eg.: <[email protected]>) with the emailaddress only (e.g: [email protected]) |
| 129 | - $text3 = preg_replace("/(<|<a href=\")*(mailto:([\w\.,-.,_.,0-9.]+)(@)([\w\.,-.,_.,0-9.]+))(>|>)*/i","$2 ", $text2); |
|
| 129 | + $text3 = preg_replace("/(<|<a href=\")*(mailto:([\w\.,-.,_.,0-9.]+)(@)([\w\.,-.,_.,0-9.]+))(>|>)*/i", "$2 ", $text2); |
|
| 130 | 130 | //$text = preg_replace_callback("/(<|<a href=\")*(mailto:([\w\.,-.,_.,0-9.]+)(@)([\w\.,-.,_.,0-9.]+))(>|>)*/i",'self::transform_mailto2text',$text); |
| 131 | 131 | //$text = preg_replace('~<a[^>]+href=\"(mailto:)+([^"]+)\"[^>]*>~si','$2 ',$text); |
| 132 | - $text4 = preg_replace_callback('~<a[^>]+href=\"(mailto:)+([^"]+)\"[^>]*>([ @\w\.,-.,_.,0-9.]+)<\/a>~si','self::transform_mailto2text',$text3); |
|
| 133 | - $text5 = preg_replace("/(([\w\.,-.,_.,0-9.]+)(@)([\w\.,-.,_.,0-9.]+))( |\s)*(<\/a>)*( |\s)*(>|>)*/i","$1 ", $text4); |
|
| 134 | - $text6 = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i","$2 ", $text5); |
|
| 135 | - $text = str_replace('<#cr-lf#>',"\r\n",$text6); |
|
| 132 | + $text4 = preg_replace_callback('~<a[^>]+href=\"(mailto:)+([^"]+)\"[^>]*>([ @\w\.,-.,_.,0-9.]+)<\/a>~si', 'self::transform_mailto2text', $text3); |
|
| 133 | + $text5 = preg_replace("/(([\w\.,-.,_.,0-9.]+)(@)([\w\.,-.,_.,0-9.]+))( |\s)*(<\/a>)*( |\s)*(>|>)*/i", "$1 ", $text4); |
|
| 134 | + $text6 = preg_replace("/(<|<)*(([\w\.,-.,_.,0-9.]+)@([\w\.,-.,_.,0-9.]+))(>|>)*/i", "$2 ", $text5); |
|
| 135 | + $text = str_replace('<#cr-lf#>', "\r\n", $text6); |
|
| 136 | 136 | return 1; |
| 137 | 137 | } |
| 138 | 138 | |
@@ -146,11 +146,11 @@ discard block |
||
| 146 | 146 | * or if you want the string to be matched as is |
| 147 | 147 | * @return void the modified text is passed via reference |
| 148 | 148 | */ |
| 149 | - static function replaceTagsCompletley(&$_body,$tag,$endtag='',$addbracesforendtag=true) |
|
| 149 | + static function replaceTagsCompletley(&$_body, $tag, $endtag = '', $addbracesforendtag = true) |
|
| 150 | 150 | { |
| 151 | 151 | if ($tag) $tag = strtolower($tag); |
| 152 | 152 | $singleton = false; |
| 153 | - if ($endtag=='/>') $singleton =true; |
|
| 153 | + if ($endtag == '/>') $singleton = true; |
|
| 154 | 154 | if ($endtag == '' || empty($endtag) || !isset($endtag)) |
| 155 | 155 | { |
| 156 | 156 | $endtag = $tag; |
@@ -163,31 +163,31 @@ discard block |
||
| 163 | 163 | if ($singleton) |
| 164 | 164 | { |
| 165 | 165 | //$_body = preg_replace('~<'.$tag.'[^>].*? '.$endtag.'~simU','',$_body); |
| 166 | - $_body = preg_replace('~<?'.$tag.'[^>].* '.$endtag.'~simU','',$_body); // we are in Ungreedy mode, so we expect * to be ungreedy without specifying ? |
|
| 166 | + $_body = preg_replace('~<?'.$tag.'[^>].* '.$endtag.'~simU', '', $_body); // we are in Ungreedy mode, so we expect * to be ungreedy without specifying ? |
|
| 167 | 167 | } |
| 168 | 168 | else |
| 169 | 169 | { |
| 170 | - $found=null; |
|
| 171 | - if ($addbracesforendtag === true ) |
|
| 170 | + $found = null; |
|
| 171 | + if ($addbracesforendtag === true) |
|
| 172 | 172 | { |
| 173 | - if (stripos($_body,'<'.$tag)!==false) $ct = preg_match_all('#<'.$tag.'(?:\s.*)?>(.+)</'.$endtag.'>#isU', $_body, $found); |
|
| 174 | - if ($ct>0) |
|
| 173 | + if (stripos($_body, '<'.$tag) !== false) $ct = preg_match_all('#<'.$tag.'(?:\s.*)?>(.+)</'.$endtag.'>#isU', $_body, $found); |
|
| 174 | + if ($ct > 0) |
|
| 175 | 175 | { |
| 176 | 176 | //error_log(__METHOD__.__LINE__.array2string($found[0])); |
| 177 | 177 | // only replace what we have found |
| 178 | - $_body = str_ireplace($found[0],'',$_body); |
|
| 178 | + $_body = str_ireplace($found[0], '', $_body); |
|
| 179 | 179 | } |
| 180 | 180 | // remove left over tags, unfinished ones, and so on |
| 181 | - $_body = preg_replace('~<'.$tag.'[^>]*?>~si','',$_body); |
|
| 181 | + $_body = preg_replace('~<'.$tag.'[^>]*?>~si', '', $_body); |
|
| 182 | 182 | } |
| 183 | - if ($addbracesforendtag === false ) |
|
| 183 | + if ($addbracesforendtag === false) |
|
| 184 | 184 | { |
| 185 | - if (stripos($_body,'<'.$tag)!==false) $ct = preg_match_all('#<'.$tag.'(?:\s.*)?>(.+)'.$endtag.'#isU', $_body, $found); |
|
| 186 | - if ($ct>0) |
|
| 185 | + if (stripos($_body, '<'.$tag) !== false) $ct = preg_match_all('#<'.$tag.'(?:\s.*)?>(.+)'.$endtag.'#isU', $_body, $found); |
|
| 186 | + if ($ct > 0) |
|
| 187 | 187 | { |
| 188 | 188 | //error_log(__METHOD__.__LINE__.array2string($found[0])); |
| 189 | 189 | // only replace what we have found |
| 190 | - $_body = str_ireplace($found[0],'',$_body); |
|
| 190 | + $_body = str_ireplace($found[0], '', $_body); |
|
| 191 | 191 | } |
| 192 | 192 | /* |
| 193 | 193 | $_body = preg_replace('~<'.$tag.'[^>]*?>(.*?)'.$endtag.'~simU','',$_body); |
@@ -205,9 +205,9 @@ discard block |
||
| 205 | 205 | // this is the actual url |
| 206 | 206 | $matches[2] = trim(strip_tags($matches[2])); |
| 207 | 207 | $matches[3] = trim(strip_tags($matches[3])); |
| 208 | - $matches[2] = str_replace(array('%40','%20'),array('@',' '),$matches[2]); |
|
| 209 | - $matches[3] = str_replace(array('%40','%20'),array('@',' '),$matches[3]); |
|
| 210 | - return $matches[1].$matches[2].($matches[2]==$matches[3]?' ':' -> '.$matches[3].' '); |
|
| 208 | + $matches[2] = str_replace(array('%40', '%20'), array('@', ' '), $matches[2]); |
|
| 209 | + $matches[3] = str_replace(array('%40', '%20'), array('@', ' '), $matches[3]); |
|
| 210 | + return $matches[1].$matches[2].($matches[2] == $matches[3] ? ' ' : ' -> '.$matches[3].' '); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | static function transform_url2text($matches) |
@@ -216,9 +216,9 @@ discard block |
||
| 216 | 216 | $linkTextislink = false; |
| 217 | 217 | // this is the actual url |
| 218 | 218 | $matches[2] = trim(strip_tags($matches[2])); |
| 219 | - if ($matches[2]==$matches[1]) $linkTextislink = true; |
|
| 220 | - $matches[1] = str_replace(' ','%20',$matches[1]); |
|
| 221 | - return ($linkTextislink?' ':'[ ').$matches[1].($linkTextislink?'':' -> '.$matches[2]).($linkTextislink?' ':' ]'); |
|
| 219 | + if ($matches[2] == $matches[1]) $linkTextislink = true; |
|
| 220 | + $matches[1] = str_replace(' ', '%20', $matches[1]); |
|
| 221 | + return ($linkTextislink ? ' ' : '[ ').$matches[1].($linkTextislink ? '' : ' -> '.$matches[2]).($linkTextislink ? ' ' : ' ]'); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | /** |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * @param bool $stripalltags : flag to indicate wether or not to strip $_html from all remaining tags |
| 230 | 230 | * @return text $_html : the modified text. |
| 231 | 231 | */ |
| 232 | - static function convertHTMLToText($_html,$displayCharset=false,$stripcrl=false,$stripalltags=true) |
|
| 232 | + static function convertHTMLToText($_html, $displayCharset = false, $stripcrl = false, $stripalltags = true) |
|
| 233 | 233 | { |
| 234 | 234 | // assume input isHTML, but test the input anyway, because, |
| 235 | 235 | // if it is not, we may not want to strip whitespace |
@@ -245,27 +245,27 @@ discard block |
||
| 245 | 245 | #print "<pre>"; print htmlspecialchars($_html); |
| 246 | 246 | #print "</pre>"; |
| 247 | 247 | #print "<hr>"; |
| 248 | - if (stripos($_html,'style')!==false) self::replaceTagsCompletley($_html,'style'); // clean out empty or pagewide style definitions / left over tags |
|
| 249 | - if (stripos($_html,'head')!==false) self::replaceTagsCompletley($_html,'head'); // Strip out stuff in head |
|
| 250 | - if (stripos($_html,'![if')!==false && stripos($_html,'<![endif]>')!==false) self::replaceTagsCompletley($_html,'!\[if','<!\[endif\]>',false); // Strip out stuff in ifs |
|
| 251 | - if (stripos($_html,'!--[if')!==false && stripos($_html,'<![endif]-->')!==false) self::replaceTagsCompletley($_html,'!--\[if','<!\[endif\]-->',false); // Strip out stuff in ifs |
|
| 252 | - $Rules = array ('@<script[^>]*?>.*?</script>@siU', // Strip out javascript |
|
| 253 | - '@&(quot|#34);@i', // Replace HTML entities |
|
| 254 | - '@&(amp|#38);@i', // Ampersand & |
|
| 255 | - '@&(lt|#60);@i', // Less Than < |
|
| 256 | - '@&(gt|#62);@i', // Greater Than > |
|
| 257 | - '@&(nbsp|#160);@i', // Non Breaking Space |
|
| 258 | - '@&(iexcl|#161);@i', // Inverted Exclamation point |
|
| 259 | - '@&(cent|#162);@i', // Cent |
|
| 260 | - '@&(pound|#163);@i', // Pound |
|
| 261 | - '@&(copy|#169);@i', // Copyright |
|
| 262 | - '@&(reg|#174);@i', // Registered |
|
| 263 | - '@&(trade|#8482);@i', // trade |
|
| 264 | - '@'@i', // singleQuote |
|
| 265 | - '@(\xc2\xa0)@', // nbsp or tab (encoded windows-style) |
|
| 266 | - '@(\xe2\x80\x8b)@', // ZERO WIDTH SPACE |
|
| 248 | + if (stripos($_html, 'style') !== false) self::replaceTagsCompletley($_html, 'style'); // clean out empty or pagewide style definitions / left over tags |
|
| 249 | + if (stripos($_html, 'head') !== false) self::replaceTagsCompletley($_html, 'head'); // Strip out stuff in head |
|
| 250 | + if (stripos($_html, '![if') !== false && stripos($_html, '<![endif]>') !== false) self::replaceTagsCompletley($_html, '!\[if', '<!\[endif\]>', false); // Strip out stuff in ifs |
|
| 251 | + if (stripos($_html, '!--[if') !== false && stripos($_html, '<![endif]-->') !== false) self::replaceTagsCompletley($_html, '!--\[if', '<!\[endif\]-->', false); // Strip out stuff in ifs |
|
| 252 | + $Rules = array('@<script[^>]*?>.*?</script>@siU', // Strip out javascript |
|
| 253 | + '@&(quot|#34);@i', // Replace HTML entities |
|
| 254 | + '@&(amp|#38);@i', // Ampersand & |
|
| 255 | + '@&(lt|#60);@i', // Less Than < |
|
| 256 | + '@&(gt|#62);@i', // Greater Than > |
|
| 257 | + '@&(nbsp|#160);@i', // Non Breaking Space |
|
| 258 | + '@&(iexcl|#161);@i', // Inverted Exclamation point |
|
| 259 | + '@&(cent|#162);@i', // Cent |
|
| 260 | + '@&(pound|#163);@i', // Pound |
|
| 261 | + '@&(copy|#169);@i', // Copyright |
|
| 262 | + '@&(reg|#174);@i', // Registered |
|
| 263 | + '@&(trade|#8482);@i', // trade |
|
| 264 | + '@'@i', // singleQuote |
|
| 265 | + '@(\xc2\xa0)@', // nbsp or tab (encoded windows-style) |
|
| 266 | + '@(\xe2\x80\x8b)@', // ZERO WIDTH SPACE |
|
| 267 | 267 | ); |
| 268 | - $Replace = array ('', |
|
| 268 | + $Replace = array('', |
|
| 269 | 269 | '"', |
| 270 | 270 | '#amper#sand#', |
| 271 | 271 | '<', |
@@ -274,9 +274,9 @@ discard block |
||
| 274 | 274 | chr(161), |
| 275 | 275 | chr(162), |
| 276 | 276 | chr(163), |
| 277 | - '(C)',//chr(169),// copyrighgt |
|
| 278 | - '(R)',//chr(174),// registered |
|
| 279 | - '(TM)',// trade |
|
| 277 | + '(C)', //chr(169),// copyrighgt |
|
| 278 | + '(R)', //chr(174),// registered |
|
| 279 | + '(TM)', // trade |
|
| 280 | 280 | "'", |
| 281 | 281 | ' ', |
| 282 | 282 | '', |
@@ -284,27 +284,27 @@ discard block |
||
| 284 | 284 | $_html = preg_replace($Rules, $Replace, $_html); |
| 285 | 285 | |
| 286 | 286 | // removing carriage return linefeeds, preserve those enclosed in <pre> </pre> tags |
| 287 | - if ($stripcrl === true ) |
|
| 287 | + if ($stripcrl === true) |
|
| 288 | 288 | { |
| 289 | - if (stripos($_html,'<pre ')!==false || stripos($_html,'<pre>')!==false) |
|
| 289 | + if (stripos($_html, '<pre ') !== false || stripos($_html, '<pre>') !== false) |
|
| 290 | 290 | { |
| 291 | 291 | $contentArr = self::splithtmlByPRE($_html); |
| 292 | 292 | foreach ($contentArr as $k =>&$elem) |
| 293 | 293 | { |
| 294 | - if (stripos($elem,'<pre ')===false && stripos($elem,'<pre>')===false) |
|
| 294 | + if (stripos($elem, '<pre ') === false && stripos($elem, '<pre>') === false) |
|
| 295 | 295 | { |
| 296 | 296 | //$elem = str_replace('@(\r\n)@i',' ',$elem); |
| 297 | - $elem = str_replace(array("\r\n","\n"),($isHTML?'':' '),$elem); |
|
| 297 | + $elem = str_replace(array("\r\n", "\n"), ($isHTML ? '' : ' '), $elem); |
|
| 298 | 298 | } |
| 299 | 299 | } |
| 300 | - $_html = implode('',$contentArr); |
|
| 300 | + $_html = implode('', $contentArr); |
|
| 301 | 301 | } |
| 302 | 302 | else |
| 303 | 303 | { |
| 304 | - $_html = str_replace(array("\r\n","\n"),($isHTML?'':' '),$_html); |
|
| 304 | + $_html = str_replace(array("\r\n", "\n"), ($isHTML ? '' : ' '), $_html); |
|
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | - $tags = array ( |
|
| 307 | + $tags = array( |
|
| 308 | 308 | 0 => '~<h[123][^>]*>\r*\n*~si', |
| 309 | 309 | 1 => '~<h[456][^>]*>\r*\n*~si', |
| 310 | 310 | 2 => '~<table[^>]*>\r*\n*~si', |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | 17 => '/<([1234567890])/', |
| 326 | 326 | 18 => '/>([1234567890])/', |
| 327 | 327 | ); |
| 328 | - $Replace = array ( |
|
| 328 | + $Replace = array( |
|
| 329 | 329 | 0 => "\r\n", |
| 330 | 330 | 1 => "\r\n", |
| 331 | 331 | 2 => "\r\n", |
@@ -346,112 +346,112 @@ discard block |
||
| 346 | 346 | 17 => '#lower#than#$1', |
| 347 | 347 | 18 => '#greater#than#$1', |
| 348 | 348 | ); |
| 349 | - $_html = preg_replace($tags,$Replace,$_html); |
|
| 350 | - $_html = preg_replace('~</t(d|h)>\s*<t(d|h)[^>]*>~si',' - ',$_html); |
|
| 351 | - $_html = preg_replace('~<img[^>]+>~s','',$_html); |
|
| 349 | + $_html = preg_replace($tags, $Replace, $_html); |
|
| 350 | + $_html = preg_replace('~</t(d|h)>\s*<t(d|h)[^>]*>~si', ' - ', $_html); |
|
| 351 | + $_html = preg_replace('~<img[^>]+>~s', '', $_html); |
|
| 352 | 352 | // replace emailaddresses eclosed in <> (eg.: <[email protected]>) with the emailaddress only (e.g: [email protected]) |
| 353 | 353 | self::replaceEmailAdresses($_html); |
| 354 | 354 | //convert hrefs to description -> URL |
| 355 | 355 | //$_html = preg_replace('~<a[^>]+href=\"([^"]+)\"[^>]*>(.*)</a>~si','[$2 -> $1]',$_html); |
| 356 | - $_html = preg_replace_callback('~<a[^>]+href=\"([^"]+)\"[^>]*>(.*?)</a>~si','self::transform_url2text',$_html); |
|
| 356 | + $_html = preg_replace_callback('~<a[^>]+href=\"([^"]+)\"[^>]*>(.*?)</a>~si', 'self::transform_url2text', $_html); |
|
| 357 | 357 | |
| 358 | 358 | // reducing double \r\n to single ones, dont mess with pre sections |
| 359 | 359 | if ($stripcrl === true && $isHTML) |
| 360 | 360 | { |
| 361 | - if (stripos($_html,'<pre ')!==false || stripos($_html,'<pre>')!==false) |
|
| 361 | + if (stripos($_html, '<pre ') !== false || stripos($_html, '<pre>') !== false) |
|
| 362 | 362 | { |
| 363 | 363 | $contentArr = self::splithtmlByPRE($_html); |
| 364 | 364 | foreach ($contentArr as $k =>&$elem) |
| 365 | 365 | { |
| 366 | - if (stripos($elem,'<pre ')===false && stripos($elem,'<pre>')===false) |
|
| 366 | + if (stripos($elem, '<pre ') === false && stripos($elem, '<pre>') === false) |
|
| 367 | 367 | { |
| 368 | 368 | //this is supposed to strip out all remaining stuff in tags, this is sometimes taking out whole sections off content |
| 369 | - if ( $stripalltags ) { |
|
| 370 | - $_html = preg_replace('~<[^>^@]+>~s','',$_html); |
|
| 369 | + if ($stripalltags) { |
|
| 370 | + $_html = preg_replace('~<[^>^@]+>~s', '', $_html); |
|
| 371 | 371 | } |
| 372 | 372 | // strip out whitespace inbetween CR/LF |
| 373 | 373 | $elem = preg_replace('~\r\n\s+\r\n~si', "\r\n\r\n", $elem); |
| 374 | 374 | // strip out / reduce exess CR/LF |
| 375 | - $elem = preg_replace('~\r\n{3,}~si',"\r\n\r\n",$elem); |
|
| 375 | + $elem = preg_replace('~\r\n{3,}~si', "\r\n\r\n", $elem); |
|
| 376 | 376 | } |
| 377 | 377 | } |
| 378 | - $_html = implode('',$contentArr); |
|
| 378 | + $_html = implode('', $contentArr); |
|
| 379 | 379 | } |
| 380 | 380 | else |
| 381 | 381 | { |
| 382 | 382 | //this is supposed to strip out all remaining stuff in tags, this is sometimes taking out whole sections off content |
| 383 | - if ( $stripalltags ) { |
|
| 384 | - $_html = preg_replace('~<[^>^@]+>~s','',$_html); |
|
| 383 | + if ($stripalltags) { |
|
| 384 | + $_html = preg_replace('~<[^>^@]+>~s', '', $_html); |
|
| 385 | 385 | } |
| 386 | 386 | // strip out whitespace inbetween CR/LF |
| 387 | 387 | $_html = preg_replace('~\r\n\s+\r\n~si', "\r\n\r\n", $_html); |
| 388 | 388 | // strip out / reduce exess CR/LF |
| 389 | - $_html = preg_replace('~(\r\n){3,}~si',"\r\n\r\n",$_html); |
|
| 389 | + $_html = preg_replace('~(\r\n){3,}~si', "\r\n\r\n", $_html); |
|
| 390 | 390 | } |
| 391 | 391 | } |
| 392 | 392 | //this is supposed to strip out all remaining stuff in tags, this is sometimes taking out whole sections off content |
| 393 | - if ( $stripalltags ) { |
|
| 394 | - $_html = preg_replace('~<[^>^@]+>~s','',$_html); |
|
| 393 | + if ($stripalltags) { |
|
| 394 | + $_html = preg_replace('~<[^>^@]+>~s', '', $_html); |
|
| 395 | 395 | //$_html = strip_tags($_html, '<a>'); |
| 396 | 396 | } |
| 397 | 397 | // reducing spaces (not for input that was plain text from the beginning) |
| 398 | - if ($isHTML) $_html = preg_replace('~ +~s',' ',$_html); |
|
| 398 | + if ($isHTML) $_html = preg_replace('~ +~s', ' ', $_html); |
|
| 399 | 399 | // restoring ampersands |
| 400 | - $_html = str_replace('#amper#sand#','&',$_html); |
|
| 400 | + $_html = str_replace('#amper#sand#', '&', $_html); |
|
| 401 | 401 | // restoring lower|greater[or equal] than |
| 402 | - $_html = str_replace('#lowerorequal#than#','<=',$_html); |
|
| 403 | - $_html = str_replace('#greaterorequal#than#','>=',$_html); |
|
| 404 | - $_html = str_replace('#lower#than#','<',$_html); |
|
| 405 | - $_html = str_replace('#greater#than#','>',$_html); |
|
| 402 | + $_html = str_replace('#lowerorequal#than#', '<=', $_html); |
|
| 403 | + $_html = str_replace('#greaterorequal#than#', '>=', $_html); |
|
| 404 | + $_html = str_replace('#lower#than#', '<', $_html); |
|
| 405 | + $_html = str_replace('#greater#than#', '>', $_html); |
|
| 406 | 406 | //error_log(__METHOD__.__LINE__.' Charset:'.$displayCharset.' -> '.$_html); |
| 407 | 407 | $_html = html_entity_decode($_html, ENT_COMPAT, $displayCharset); |
| 408 | 408 | //error_log(__METHOD__.__LINE__.' Charset:'.$displayCharset.' After html_entity_decode: -> '.$_html); |
| 409 | 409 | //self::replaceEmailAdresses($_html); |
| 410 | 410 | $pos = strpos($_html, 'blockquote'); |
| 411 | 411 | //error_log("convert HTML2Text: $_html"); |
| 412 | - if($pos === false) { |
|
| 412 | + if ($pos === false) { |
|
| 413 | 413 | return $_html; |
| 414 | 414 | } else { |
| 415 | 415 | $indent = 0; |
| 416 | 416 | $indentString = ''; |
| 417 | 417 | |
| 418 | 418 | $quoteParts = preg_split('/#blockquote#type#cite#/', $_html, -1, PREG_SPLIT_OFFSET_CAPTURE); |
| 419 | - foreach($quoteParts as $quotePart) { |
|
| 420 | - if($quotePart[1] > 0) { |
|
| 419 | + foreach ($quoteParts as $quotePart) { |
|
| 420 | + if ($quotePart[1] > 0) { |
|
| 421 | 421 | $indent++; |
| 422 | 422 | $indentString .= '>'; |
| 423 | 423 | } |
| 424 | 424 | $quoteParts2 = preg_split('/#blockquote#end#cite#/', $quotePart[0], -1, PREG_SPLIT_OFFSET_CAPTURE); |
| 425 | 425 | |
| 426 | - foreach($quoteParts2 as $quotePart2) { |
|
| 427 | - if($quotePart2[1] > 0) { |
|
| 426 | + foreach ($quoteParts2 as $quotePart2) { |
|
| 427 | + if ($quotePart2[1] > 0) { |
|
| 428 | 428 | $indent--; |
| 429 | 429 | $indentString = substr($indentString, 0, $indent); |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | $quoteParts3 = explode("\r\n", $quotePart2[0]); |
| 433 | 433 | |
| 434 | - foreach($quoteParts3 as $quotePart3) { |
|
| 434 | + foreach ($quoteParts3 as $quotePart3) { |
|
| 435 | 435 | //error_log(__METHOD__.__LINE__.'Line:'.$quotePart3); |
| 436 | - $allowedLength = 76-strlen("\r\n$indentString"); |
|
| 436 | + $allowedLength = 76 - strlen("\r\n$indentString"); |
|
| 437 | 437 | // only break lines, if not already indented |
| 438 | - if (substr($quotePart3,0,strlen($indentString)) != $indentString) |
|
| 438 | + if (substr($quotePart3, 0, strlen($indentString)) != $indentString) |
|
| 439 | 439 | { |
| 440 | 440 | if (strlen($quotePart3) > $allowedLength) { |
| 441 | - $s=explode(" ", $quotePart3); |
|
| 441 | + $s = explode(" ", $quotePart3); |
|
| 442 | 442 | $quotePart3 = ""; |
| 443 | 443 | $linecnt = 0; |
| 444 | 444 | foreach ($s as $k=>$v) { |
| 445 | 445 | $cnt = strlen($v); |
| 446 | 446 | // only break long words within the wordboundaries, |
| 447 | 447 | // but it may destroy links, so we check for href and dont do it if we find it |
| 448 | - if($cnt > $allowedLength && stripos($v,'href=')===false) { |
|
| 448 | + if ($cnt > $allowedLength && stripos($v, 'href=') === false) { |
|
| 449 | 449 | //error_log(__METHOD__.__LINE__.'LongWordFound:'.$v); |
| 450 | - $v=wordwrap($v, $allowedLength, "\r\n$indentString", true); |
|
| 450 | + $v = wordwrap($v, $allowedLength, "\r\n$indentString", true); |
|
| 451 | 451 | } |
| 452 | 452 | // the rest should be broken at the start of the new word that exceeds the limit |
| 453 | - if ($linecnt+$cnt > $allowedLength) { |
|
| 454 | - $v="\r\n$indentString$v"; |
|
| 453 | + if ($linecnt + $cnt > $allowedLength) { |
|
| 454 | + $v = "\r\n$indentString$v"; |
|
| 455 | 455 | //error_log(__METHOD__.__LINE__.'breaking here:'.$v); |
| 456 | 456 | $linecnt = 0; |
| 457 | 457 | } else { |
@@ -462,11 +462,11 @@ discard block |
||
| 462 | 462 | } |
| 463 | 463 | } |
| 464 | 464 | //error_log(__METHOD__.__LINE__.'partString to return:'.$indentString . $quotePart3); |
| 465 | - $asciiTextBuff[] = $indentString . $quotePart3 ; |
|
| 465 | + $asciiTextBuff[] = $indentString.$quotePart3; |
|
| 466 | 466 | } |
| 467 | 467 | } |
| 468 | 468 | } |
| 469 | - return implode("\r\n",$asciiTextBuff); |
|
| 469 | + return implode("\r\n", $asciiTextBuff); |
|
| 470 | 470 | } |
| 471 | 471 | } |
| 472 | 472 | |
@@ -479,30 +479,30 @@ discard block |
||
| 479 | 479 | static function splithtmlByPRE($html) |
| 480 | 480 | { |
| 481 | 481 | $searchFor = '<pre '; |
| 482 | - $pos = stripos($html,$searchFor); |
|
| 483 | - if ($pos===false) |
|
| 482 | + $pos = stripos($html, $searchFor); |
|
| 483 | + if ($pos === false) |
|
| 484 | 484 | { |
| 485 | 485 | $searchFor = '<pre>'; |
| 486 | - $pos = stripos($html,$searchFor); |
|
| 486 | + $pos = stripos($html, $searchFor); |
|
| 487 | 487 | } |
| 488 | 488 | if ($pos === false) |
| 489 | 489 | { |
| 490 | 490 | return $html; |
| 491 | 491 | } |
| 492 | - $html2ret[] = substr($html,0,$pos); |
|
| 493 | - while ($pos!==false) |
|
| 492 | + $html2ret[] = substr($html, 0, $pos); |
|
| 493 | + while ($pos !== false) |
|
| 494 | 494 | { |
| 495 | - $endofpre = stripos($html,'</pre>',$pos); |
|
| 496 | - $length = $endofpre-$pos+6; |
|
| 497 | - $html2ret[] = substr($html,$pos,$length); |
|
| 495 | + $endofpre = stripos($html, '</pre>', $pos); |
|
| 496 | + $length = $endofpre - $pos + 6; |
|
| 497 | + $html2ret[] = substr($html, $pos, $length); |
|
| 498 | 498 | $searchFor = '<pre '; |
| 499 | - $pos = stripos($html,$searchFor, $endofpre+6); |
|
| 500 | - if ($pos===false) |
|
| 499 | + $pos = stripos($html, $searchFor, $endofpre + 6); |
|
| 500 | + if ($pos === false) |
|
| 501 | 501 | { |
| 502 | 502 | $searchFor = '<pre>'; |
| 503 | - $pos = stripos($html,$searchFor, $endofpre+6); |
|
| 503 | + $pos = stripos($html, $searchFor, $endofpre + 6); |
|
| 504 | 504 | } |
| 505 | - $html2ret[] = ($pos ? substr($html,$endofpre+6,$pos-($endofpre+6)): substr($html,$endofpre+6)); |
|
| 505 | + $html2ret[] = ($pos ? substr($html, $endofpre + 6, $pos - ($endofpre + 6)) : substr($html, $endofpre + 6)); |
|
| 506 | 506 | //$pos=false; |
| 507 | 507 | } |
| 508 | 508 | //error_log(__METHOD__.__LINE__.array2string($html2ret)); |
@@ -31,7 +31,8 @@ discard block |
||
| 31 | 31 | static function decodeMailHeader($_string, $displayCharset='utf-8', $reclevel=0) |
| 32 | 32 | { |
| 33 | 33 | $maxreclevel=25; |
| 34 | - if ($reclevel > $maxreclevel) { |
|
| 34 | + if ($reclevel > $maxreclevel) |
|
| 35 | + { |
|
| 35 | 36 | error_log( __METHOD__.__LINE__." Recursion Level Exeeded ($reclevel) while decoding $_string "); |
| 36 | 37 | return $_string; |
| 37 | 38 | } |
@@ -65,10 +66,16 @@ discard block |
||
| 65 | 66 | $convertAtEnd = false; |
| 66 | 67 | foreach((array)$elements as $element) |
| 67 | 68 | { |
| 68 | - if ($element->charset == 'default') $element->charset = Api\Translation::detect_encoding($element->text); |
|
| 69 | + if ($element->charset == 'default') |
|
| 70 | + { |
|
| 71 | + $element->charset = Api\Translation::detect_encoding($element->text); |
|
| 72 | + } |
|
| 69 | 73 | if ($element->charset != 'x-unknown') |
| 70 | 74 | { |
| 71 | - if( strtoupper($element->charset) != 'UTF-8') $element->text = preg_replace($sar,$rar,$element->text); |
|
| 75 | + if( strtoupper($element->charset) != 'UTF-8') |
|
| 76 | + { |
|
| 77 | + $element->text = preg_replace($sar,$rar,$element->text); |
|
| 78 | + } |
|
| 72 | 79 | // check if there is a possible nested encoding; make sure that the inputstring and the decoded result are different to avoid loops |
| 73 | 80 | $openTags = substr_count($element->text,'?='); |
| 74 | 81 | if(preg_match('/\?=.+=\?/', $element->text) && $openTags>0 && $openTags==substr_count($element->text,'=?') && $element->text != $_string) |
@@ -84,7 +91,10 @@ discard block |
||
| 84 | 91 | $convertAtEnd = true; |
| 85 | 92 | } |
| 86 | 93 | } |
| 87 | - if ($convertAtEnd) $newString = self::decodeMailHeader($newString,$displayCharset,$reclevel); |
|
| 94 | + if ($convertAtEnd) |
|
| 95 | + { |
|
| 96 | + $newString = self::decodeMailHeader($newString,$displayCharset,$reclevel); |
|
| 97 | + } |
|
| 88 | 98 | return preg_replace('/([\000-\012\015\016\020-\037\075])/','',$newString); |
| 89 | 99 | } |
| 90 | 100 | elseif(function_exists(mb_decode_mimeheader)) |
@@ -148,18 +158,27 @@ discard block |
||
| 148 | 158 | */ |
| 149 | 159 | static function replaceTagsCompletley(&$_body,$tag,$endtag='',$addbracesforendtag=true) |
| 150 | 160 | { |
| 151 | - if ($tag) $tag = strtolower($tag); |
|
| 161 | + if ($tag) |
|
| 162 | + { |
|
| 163 | + $tag = strtolower($tag); |
|
| 164 | + } |
|
| 152 | 165 | $singleton = false; |
| 153 | - if ($endtag=='/>') $singleton =true; |
|
| 166 | + if ($endtag=='/>') |
|
| 167 | + { |
|
| 168 | + $singleton =true; |
|
| 169 | + } |
|
| 154 | 170 | if ($endtag == '' || empty($endtag) || !isset($endtag)) |
| 155 | 171 | { |
| 156 | 172 | $endtag = $tag; |
| 157 | - } else { |
|
| 173 | + } |
|
| 174 | + else |
|
| 175 | + { |
|
| 158 | 176 | $endtag = strtolower($endtag); |
| 159 | 177 | //error_log(__METHOD__.' Using EndTag:'.$endtag); |
| 160 | 178 | } |
| 161 | 179 | // strip tags out of the message completely with their content |
| 162 | - if ($_body) { |
|
| 180 | + if ($_body) |
|
| 181 | + { |
|
| 163 | 182 | if ($singleton) |
| 164 | 183 | { |
| 165 | 184 | //$_body = preg_replace('~<'.$tag.'[^>].*? '.$endtag.'~simU','',$_body); |
@@ -170,7 +189,10 @@ discard block |
||
| 170 | 189 | $found=null; |
| 171 | 190 | if ($addbracesforendtag === true ) |
| 172 | 191 | { |
| 173 | - if (stripos($_body,'<'.$tag)!==false) $ct = preg_match_all('#<'.$tag.'(?:\s.*)?>(.+)</'.$endtag.'>#isU', $_body, $found); |
|
| 192 | + if (stripos($_body,'<'.$tag)!==false) |
|
| 193 | + { |
|
| 194 | + $ct = preg_match_all('#<'.$tag.'(?:\s.*)?>(.+)</'.$endtag.'>#isU', $_body, $found); |
|
| 195 | + } |
|
| 174 | 196 | if ($ct>0) |
| 175 | 197 | { |
| 176 | 198 | //error_log(__METHOD__.__LINE__.array2string($found[0])); |
@@ -182,7 +204,10 @@ discard block |
||
| 182 | 204 | } |
| 183 | 205 | if ($addbracesforendtag === false ) |
| 184 | 206 | { |
| 185 | - if (stripos($_body,'<'.$tag)!==false) $ct = preg_match_all('#<'.$tag.'(?:\s.*)?>(.+)'.$endtag.'#isU', $_body, $found); |
|
| 207 | + if (stripos($_body,'<'.$tag)!==false) |
|
| 208 | + { |
|
| 209 | + $ct = preg_match_all('#<'.$tag.'(?:\s.*)?>(.+)'.$endtag.'#isU', $_body, $found); |
|
| 210 | + } |
|
| 186 | 211 | if ($ct>0) |
| 187 | 212 | { |
| 188 | 213 | //error_log(__METHOD__.__LINE__.array2string($found[0])); |
@@ -216,7 +241,10 @@ discard block |
||
| 216 | 241 | $linkTextislink = false; |
| 217 | 242 | // this is the actual url |
| 218 | 243 | $matches[2] = trim(strip_tags($matches[2])); |
| 219 | - if ($matches[2]==$matches[1]) $linkTextislink = true; |
|
| 244 | + if ($matches[2]==$matches[1]) |
|
| 245 | + { |
|
| 246 | + $linkTextislink = true; |
|
| 247 | + } |
|
| 220 | 248 | $matches[1] = str_replace(' ','%20',$matches[1]); |
| 221 | 249 | return ($linkTextislink?' ':'[ ').$matches[1].($linkTextislink?'':' -> '.$matches[2]).($linkTextislink?' ':' ]'); |
| 222 | 250 | } |
@@ -239,16 +267,35 @@ discard block |
||
| 239 | 267 | $isHTML = false; |
| 240 | 268 | // return $_html; // maybe we should not proceed at all |
| 241 | 269 | } |
| 242 | - if ($displayCharset === false) $displayCharset = Api\Translation::charset(); |
|
| 270 | + if ($displayCharset === false) |
|
| 271 | + { |
|
| 272 | + $displayCharset = Api\Translation::charset(); |
|
| 273 | + } |
|
| 243 | 274 | //error_log(__METHOD__.$_html); |
| 244 | 275 | #print '<hr>'; |
| 245 | 276 | #print "<pre>"; print htmlspecialchars($_html); |
| 246 | 277 | #print "</pre>"; |
| 247 | 278 | #print "<hr>"; |
| 248 | - if (stripos($_html,'style')!==false) self::replaceTagsCompletley($_html,'style'); // clean out empty or pagewide style definitions / left over tags |
|
| 249 | - if (stripos($_html,'head')!==false) self::replaceTagsCompletley($_html,'head'); // Strip out stuff in head |
|
| 250 | - if (stripos($_html,'![if')!==false && stripos($_html,'<![endif]>')!==false) self::replaceTagsCompletley($_html,'!\[if','<!\[endif\]>',false); // Strip out stuff in ifs |
|
| 251 | - if (stripos($_html,'!--[if')!==false && stripos($_html,'<![endif]-->')!==false) self::replaceTagsCompletley($_html,'!--\[if','<!\[endif\]-->',false); // Strip out stuff in ifs |
|
| 279 | + if (stripos($_html,'style')!==false) |
|
| 280 | + { |
|
| 281 | + self::replaceTagsCompletley($_html,'style'); |
|
| 282 | + } |
|
| 283 | + // clean out empty or pagewide style definitions / left over tags |
|
| 284 | + if (stripos($_html,'head')!==false) |
|
| 285 | + { |
|
| 286 | + self::replaceTagsCompletley($_html,'head'); |
|
| 287 | + } |
|
| 288 | + // Strip out stuff in head |
|
| 289 | + if (stripos($_html,'![if')!==false && stripos($_html,'<![endif]>')!==false) |
|
| 290 | + { |
|
| 291 | + self::replaceTagsCompletley($_html,'!\[if','<!\[endif\]>',false); |
|
| 292 | + } |
|
| 293 | + // Strip out stuff in ifs |
|
| 294 | + if (stripos($_html,'!--[if')!==false && stripos($_html,'<![endif]-->')!==false) |
|
| 295 | + { |
|
| 296 | + self::replaceTagsCompletley($_html,'!--\[if','<!\[endif\]-->',false); |
|
| 297 | + } |
|
| 298 | + // Strip out stuff in ifs |
|
| 252 | 299 | $Rules = array ('@<script[^>]*?>.*?</script>@siU', // Strip out javascript |
| 253 | 300 | '@&(quot|#34);@i', // Replace HTML entities |
| 254 | 301 | '@&(amp|#38);@i', // Ampersand & |
@@ -366,7 +413,8 @@ discard block |
||
| 366 | 413 | if (stripos($elem,'<pre ')===false && stripos($elem,'<pre>')===false) |
| 367 | 414 | { |
| 368 | 415 | //this is supposed to strip out all remaining stuff in tags, this is sometimes taking out whole sections off content |
| 369 | - if ( $stripalltags ) { |
|
| 416 | + if ( $stripalltags ) |
|
| 417 | + { |
|
| 370 | 418 | $_html = preg_replace('~<[^>^@]+>~s','',$_html); |
| 371 | 419 | } |
| 372 | 420 | // strip out whitespace inbetween CR/LF |
@@ -380,7 +428,8 @@ discard block |
||
| 380 | 428 | else |
| 381 | 429 | { |
| 382 | 430 | //this is supposed to strip out all remaining stuff in tags, this is sometimes taking out whole sections off content |
| 383 | - if ( $stripalltags ) { |
|
| 431 | + if ( $stripalltags ) |
|
| 432 | + { |
|
| 384 | 433 | $_html = preg_replace('~<[^>^@]+>~s','',$_html); |
| 385 | 434 | } |
| 386 | 435 | // strip out whitespace inbetween CR/LF |
@@ -390,12 +439,16 @@ discard block |
||
| 390 | 439 | } |
| 391 | 440 | } |
| 392 | 441 | //this is supposed to strip out all remaining stuff in tags, this is sometimes taking out whole sections off content |
| 393 | - if ( $stripalltags ) { |
|
| 442 | + if ( $stripalltags ) |
|
| 443 | + { |
|
| 394 | 444 | $_html = preg_replace('~<[^>^@]+>~s','',$_html); |
| 395 | 445 | //$_html = strip_tags($_html, '<a>'); |
| 396 | 446 | } |
| 397 | 447 | // reducing spaces (not for input that was plain text from the beginning) |
| 398 | - if ($isHTML) $_html = preg_replace('~ +~s',' ',$_html); |
|
| 448 | + if ($isHTML) |
|
| 449 | + { |
|
| 450 | + $_html = preg_replace('~ +~s',' ',$_html); |
|
| 451 | + } |
|
| 399 | 452 | // restoring ampersands |
| 400 | 453 | $_html = str_replace('#amper#sand#','&',$_html); |
| 401 | 454 | // restoring lower|greater[or equal] than |
@@ -409,55 +462,72 @@ discard block |
||
| 409 | 462 | //self::replaceEmailAdresses($_html); |
| 410 | 463 | $pos = strpos($_html, 'blockquote'); |
| 411 | 464 | //error_log("convert HTML2Text: $_html"); |
| 412 | - if($pos === false) { |
|
| 465 | + if($pos === false) |
|
| 466 | + { |
|
| 413 | 467 | return $_html; |
| 414 | - } else { |
|
| 468 | + } |
|
| 469 | + else |
|
| 470 | + { |
|
| 415 | 471 | $indent = 0; |
| 416 | 472 | $indentString = ''; |
| 417 | 473 | |
| 418 | 474 | $quoteParts = preg_split('/#blockquote#type#cite#/', $_html, -1, PREG_SPLIT_OFFSET_CAPTURE); |
| 419 | - foreach($quoteParts as $quotePart) { |
|
| 420 | - if($quotePart[1] > 0) { |
|
| 475 | + foreach($quoteParts as $quotePart) |
|
| 476 | + { |
|
| 477 | + if($quotePart[1] > 0) |
|
| 478 | + { |
|
| 421 | 479 | $indent++; |
| 422 | 480 | $indentString .= '>'; |
| 423 | 481 | } |
| 424 | 482 | $quoteParts2 = preg_split('/#blockquote#end#cite#/', $quotePart[0], -1, PREG_SPLIT_OFFSET_CAPTURE); |
| 425 | 483 | |
| 426 | - foreach($quoteParts2 as $quotePart2) { |
|
| 427 | - if($quotePart2[1] > 0) { |
|
| 484 | + foreach($quoteParts2 as $quotePart2) |
|
| 485 | + { |
|
| 486 | + if($quotePart2[1] > 0) |
|
| 487 | + { |
|
| 428 | 488 | $indent--; |
| 429 | 489 | $indentString = substr($indentString, 0, $indent); |
| 430 | 490 | } |
| 431 | 491 | |
| 432 | 492 | $quoteParts3 = explode("\r\n", $quotePart2[0]); |
| 433 | 493 | |
| 434 | - foreach($quoteParts3 as $quotePart3) { |
|
| 494 | + foreach($quoteParts3 as $quotePart3) |
|
| 495 | + { |
|
| 435 | 496 | //error_log(__METHOD__.__LINE__.'Line:'.$quotePart3); |
| 436 | 497 | $allowedLength = 76-strlen("\r\n$indentString"); |
| 437 | 498 | // only break lines, if not already indented |
| 438 | 499 | if (substr($quotePart3,0,strlen($indentString)) != $indentString) |
| 439 | 500 | { |
| 440 | - if (strlen($quotePart3) > $allowedLength) { |
|
| 501 | + if (strlen($quotePart3) > $allowedLength) |
|
| 502 | + { |
|
| 441 | 503 | $s=explode(" ", $quotePart3); |
| 442 | 504 | $quotePart3 = ""; |
| 443 | 505 | $linecnt = 0; |
| 444 | - foreach ($s as $k=>$v) { |
|
| 506 | + foreach ($s as $k=>$v) |
|
| 507 | + { |
|
| 445 | 508 | $cnt = strlen($v); |
| 446 | 509 | // only break long words within the wordboundaries, |
| 447 | 510 | // but it may destroy links, so we check for href and dont do it if we find it |
| 448 | - if($cnt > $allowedLength && stripos($v,'href=')===false) { |
|
| 511 | + if($cnt > $allowedLength && stripos($v,'href=')===false) |
|
| 512 | + { |
|
| 449 | 513 | //error_log(__METHOD__.__LINE__.'LongWordFound:'.$v); |
| 450 | 514 | $v=wordwrap($v, $allowedLength, "\r\n$indentString", true); |
| 451 | 515 | } |
| 452 | 516 | // the rest should be broken at the start of the new word that exceeds the limit |
| 453 | - if ($linecnt+$cnt > $allowedLength) { |
|
| 517 | + if ($linecnt+$cnt > $allowedLength) |
|
| 518 | + { |
|
| 454 | 519 | $v="\r\n$indentString$v"; |
| 455 | 520 | //error_log(__METHOD__.__LINE__.'breaking here:'.$v); |
| 456 | 521 | $linecnt = 0; |
| 457 | - } else { |
|
| 522 | + } |
|
| 523 | + else |
|
| 524 | + { |
|
| 458 | 525 | $linecnt += $cnt; |
| 459 | 526 | } |
| 460 | - if (strlen($v)) $quotePart3 .= (strlen($quotePart3) ? " " : "").$v; |
|
| 527 | + if (strlen($v)) |
|
| 528 | + { |
|
| 529 | + $quotePart3 .= (strlen($quotePart3) ? " " : "").$v; |
|
| 530 | + } |
|
| 461 | 531 | } |
| 462 | 532 | } |
| 463 | 533 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | * Construtor |
| 141 | 141 | * |
| 142 | 142 | * @param array |
| 143 | - * @param bool|int|string $_adminConnection create admin connection if true or account_id or imap username |
|
| 143 | + * @param boolean|string $_adminConnection create admin connection if true or account_id or imap username |
|
| 144 | 144 | * @param int $_timeout =null timeout in secs, if none given fmail pref or default of 20 is used |
| 145 | 145 | * @return void |
| 146 | 146 | */ |
@@ -564,7 +564,7 @@ discard block |
||
| 564 | 564 | * Returns an array containing the names of the selected mailboxes |
| 565 | 565 | * |
| 566 | 566 | * @param string $reference base mailbox to start the search (default is current mailbox) |
| 567 | - * @param string $restriction_search false or 0 means return all mailboxes |
|
| 567 | + * @param integer $restriction_search false or 0 means return all mailboxes |
|
| 568 | 568 | * true or 1 return only the mailbox that contains that exact name |
| 569 | 569 | * 2 return all mailboxes in that hierarchy level |
| 570 | 570 | * @param string $returnAttributes true means return an assoc array containing mailbox names and mailbox attributes |
@@ -648,7 +648,7 @@ discard block |
||
| 648 | 648 | * Returns an array containing the names of the subscribed selected mailboxes |
| 649 | 649 | * |
| 650 | 650 | * @param string $reference base mailbox to start the search |
| 651 | - * @param string $restriction_search false or 0 means return all mailboxes |
|
| 651 | + * @param integer $restriction_search false or 0 means return all mailboxes |
|
| 652 | 652 | * true or 1 return only the mailbox that contains that exact name |
| 653 | 653 | * 2 return all mailboxes in that hierarchy level |
| 654 | 654 | * @param string $returnAttributes true means return an assoc array containing mailbox names and mailbox attributes |
@@ -716,7 +716,7 @@ discard block |
||
| 716 | 716 | * Returns an array containing the names of the selected unsubscribed mailboxes |
| 717 | 717 | * |
| 718 | 718 | * @param string $reference base mailbox to start the search |
| 719 | - * @param string $restriction_search false or 0 means return all mailboxes |
|
| 719 | + * @param integer $restriction_search false or 0 means return all mailboxes |
|
| 720 | 720 | * true or 1 return only the mailbox that contains that exact name |
| 721 | 721 | * 2 return all mailboxes in that hierarchy level |
| 722 | 722 | * |
@@ -894,6 +894,7 @@ discard block |
||
| 894 | 894 | * |
| 895 | 895 | * @var array $_nameSpace |
| 896 | 896 | * @var string $_folderName |
| 897 | + * @param string $_folderName |
|
| 897 | 898 | * @return string the prefix (may be an empty string) |
| 898 | 899 | */ |
| 899 | 900 | static function getFolderPrefixFromNamespace($_nameSpace, $_folderName) |
@@ -912,7 +913,7 @@ discard block |
||
| 912 | 913 | * @param string $_mailbox |
| 913 | 914 | * @param string $delimiter |
| 914 | 915 | * @param string $prefix |
| 915 | - * @param string $reclevel = 0, counter to keep track of the current recursionlevel |
|
| 916 | + * @param integer $reclevel = 0, counter to keep track of the current recursionlevel |
|
| 916 | 917 | * @return array of mailboxes |
| 917 | 918 | */ |
| 918 | 919 | function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel=0) |
@@ -1344,7 +1345,7 @@ discard block |
||
| 1344 | 1345 | /** |
| 1345 | 1346 | * Get vacation message for given user |
| 1346 | 1347 | * |
| 1347 | - * @param int|string $_euser nummeric account_id or imap username |
|
| 1348 | + * @param string|null $_euser nummeric account_id or imap username |
|
| 1348 | 1349 | * @param string $_scriptName =null |
| 1349 | 1350 | * @throws Exception on connection error or authentication failure |
| 1350 | 1351 | * @return array |
@@ -580,16 +580,16 @@ discard block |
||
| 580 | 580 | $mailbox = ''; |
| 581 | 581 | if ( is_int( $restriction_search ) ){ |
| 582 | 582 | switch ( $restriction_search ) { |
| 583 | - case 0: |
|
| 584 | - $searchstring = $reference."*"; |
|
| 585 | - break; |
|
| 586 | - case 1: |
|
| 587 | - $mailbox = $searchstring = $reference; |
|
| 588 | - //$reference = '%'; |
|
| 589 | - break; |
|
| 590 | - case 2: |
|
| 591 | - $searchstring = $reference."%"; |
|
| 592 | - break; |
|
| 583 | + case 0: |
|
| 584 | + $searchstring = $reference."*"; |
|
| 585 | + break; |
|
| 586 | + case 1: |
|
| 587 | + $mailbox = $searchstring = $reference; |
|
| 588 | + //$reference = '%'; |
|
| 589 | + break; |
|
| 590 | + case 2: |
|
| 591 | + $searchstring = $reference."%"; |
|
| 592 | + break; |
|
| 593 | 593 | } |
| 594 | 594 | }else{ |
| 595 | 595 | if ( is_string( $restriction_search ) ){ |
@@ -664,16 +664,16 @@ discard block |
||
| 664 | 664 | $mailbox = ''; |
| 665 | 665 | if ( is_int( $restriction_search ) ){ |
| 666 | 666 | switch ( $restriction_search ) { |
| 667 | - case 0: |
|
| 668 | - $searchstring = $reference."*"; |
|
| 669 | - break; |
|
| 670 | - case 1: |
|
| 671 | - $mailbox = $searchstring = $reference; |
|
| 672 | - //$reference = '%'; |
|
| 673 | - break; |
|
| 674 | - case 2: |
|
| 675 | - $searchstring = $reference."%"; |
|
| 676 | - break; |
|
| 667 | + case 0: |
|
| 668 | + $searchstring = $reference."*"; |
|
| 669 | + break; |
|
| 670 | + case 1: |
|
| 671 | + $mailbox = $searchstring = $reference; |
|
| 672 | + //$reference = '%'; |
|
| 673 | + break; |
|
| 674 | + case 2: |
|
| 675 | + $searchstring = $reference."%"; |
|
| 676 | + break; |
|
| 677 | 677 | } |
| 678 | 678 | }else{ |
| 679 | 679 | if ( is_string( $restriction_search ) ){ |
@@ -730,16 +730,16 @@ discard block |
||
| 730 | 730 | |
| 731 | 731 | if ( is_int( $restriction_search ) ){ |
| 732 | 732 | switch ( $restriction_search ) { |
| 733 | - case 0: |
|
| 734 | - $mailbox = $reference."*"; |
|
| 735 | - break; |
|
| 736 | - case 1: |
|
| 737 | - $mailbox = $reference; |
|
| 738 | - $reference = '%'; |
|
| 739 | - break; |
|
| 740 | - case 2: |
|
| 741 | - $mailbox = "%"; |
|
| 742 | - break; |
|
| 733 | + case 0: |
|
| 734 | + $mailbox = $reference."*"; |
|
| 735 | + break; |
|
| 736 | + case 1: |
|
| 737 | + $mailbox = $reference; |
|
| 738 | + $reference = '%'; |
|
| 739 | + break; |
|
| 740 | + case 2: |
|
| 741 | + $mailbox = "%"; |
|
| 742 | + break; |
|
| 743 | 743 | } |
| 744 | 744 | }else{ |
| 745 | 745 | if ( is_string( $restriction_search ) ){ |
@@ -156,7 +156,10 @@ discard block |
||
| 156 | 156 | $this->loginType = $this->params['acc_imap_logintype']; |
| 157 | 157 | $this->domainName = $this->params['acc_domain']; |
| 158 | 158 | |
| 159 | - if (is_null($_timeout)) $_timeout = $this->params['acc_imap_timeout']?$this->params['acc_imap_timeout']:self::getTimeOut (); |
|
| 159 | + if (is_null($_timeout)) |
|
| 160 | + { |
|
| 161 | + $_timeout = $this->params['acc_imap_timeout']?$this->params['acc_imap_timeout']:self::getTimeOut (); |
|
| 162 | + } |
|
| 160 | 163 | |
| 161 | 164 | // Horde use locale for translation of error messages |
| 162 | 165 | Api\Preferences::setlocale(LC_MESSAGES); |
@@ -167,7 +170,10 @@ discard block |
||
| 167 | 170 | { |
| 168 | 171 | $username = $this->getMailBoxUserName($username); |
| 169 | 172 | } |
| 170 | - if ($_adminConnection) $this->adminConnection($username); |
|
| 173 | + if ($_adminConnection) |
|
| 174 | + { |
|
| 175 | + $this->adminConnection($username); |
|
| 176 | + } |
|
| 171 | 177 | $parent_params = array( |
| 172 | 178 | 'username' => $this->params[$_adminConnection ? 'acc_imap_admin_username' : 'acc_imap_username'], |
| 173 | 179 | 'password' => $this->params[$_adminConnection ? 'acc_imap_admin_password' : 'acc_imap_password'], |
@@ -303,7 +309,11 @@ discard block |
||
| 303 | 309 | static function getTimeOut($_use='IMAP') |
| 304 | 310 | { |
| 305 | 311 | $timeout = $GLOBALS['egw_info']['user']['preferences']['mail']['connectionTimeout']; |
| 306 | - if (empty($timeout) || !($timeout > 0)) $timeout = $_use == 'SIEVE' ? 10 : 20; // this is the default value |
|
| 312 | + if (empty($timeout) || !($timeout > 0)) |
|
| 313 | + { |
|
| 314 | + $timeout = $_use == 'SIEVE' ? 10 : 20; |
|
| 315 | + } |
|
| 316 | + // this is the default value |
|
| 307 | 317 | return $timeout; |
| 308 | 318 | } |
| 309 | 319 | |
@@ -366,7 +376,8 @@ discard block |
||
| 366 | 376 | */ |
| 367 | 377 | function encodeFolderName($_folderName) |
| 368 | 378 | { |
| 369 | - if($this->mbAvailable) { |
|
| 379 | + if($this->mbAvailable) |
|
| 380 | + { |
|
| 370 | 381 | return mb_convert_encoding($_folderName, "UTF7-IMAP", Api\Translation::charset()); |
| 371 | 382 | } |
| 372 | 383 | |
@@ -384,14 +395,21 @@ discard block |
||
| 384 | 395 | function getMailbox($mailbox) |
| 385 | 396 | { |
| 386 | 397 | $mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_ALL); |
| 387 | - if (empty($mailboxes)) $mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_UNSUBSCRIBED); |
|
| 398 | + if (empty($mailboxes)) |
|
| 399 | + { |
|
| 400 | + $mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_UNSUBSCRIBED); |
|
| 401 | + } |
|
| 388 | 402 | //error_log(__METHOD__.__LINE__.'->'.$mailbox.'/'.array2string($mailboxes)); |
| 389 | 403 | $mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes); |
| 390 | 404 | //_debug_array($mboxes->count()); |
| 391 | 405 | foreach ($mboxes->getIterator() as $k =>$box) |
| 392 | 406 | { |
| 393 | 407 | //error_log(__METHOD__.__LINE__.'->'.$k); |
| 394 | - if ($k!='user' && $k != '' && $k==$mailbox) return $box['mailbox']; //_debug_array(array($k => $client->status($k))); |
|
| 408 | + if ($k!='user' && $k != '' && $k==$mailbox) |
|
| 409 | + { |
|
| 410 | + return $box['mailbox']; |
|
| 411 | + } |
|
| 412 | + //_debug_array(array($k => $client->status($k))); |
|
| 395 | 413 | } |
| 396 | 414 | return ($this->mailboxExist($mailbox)?$mailbox:false); |
| 397 | 415 | } |
@@ -460,8 +478,14 @@ discard block |
||
| 460 | 478 | //throw new egw_exception(__METHOD__.' ('.__LINE__.") failed to ".__METHOD__." :".$e->getMessage()); |
| 461 | 479 | unset($e); |
| 462 | 480 | } |
| 463 | - if (!empty($mailbox)) return $mailbox['mailbox']; |
|
| 464 | - if (empty($mailbox) && $this->mailboxExist('INBOX')) return 'INBOX'; |
|
| 481 | + if (!empty($mailbox)) |
|
| 482 | + { |
|
| 483 | + return $mailbox['mailbox']; |
|
| 484 | + } |
|
| 485 | + if (empty($mailbox) && $this->mailboxExist('INBOX')) |
|
| 486 | + { |
|
| 487 | + return 'INBOX'; |
|
| 488 | + } |
|
| 465 | 489 | return null; |
| 466 | 490 | } |
| 467 | 491 | |
@@ -531,7 +555,10 @@ discard block |
||
| 531 | 555 | )); |
| 532 | 556 | |
| 533 | 557 | $flags = Horde_Imap_Client::STATUS_ALL; |
| 534 | - if ($ignoreStatusCache) $flags |= Horde_Imap_Client::STATUS_FORCE_REFRESH; |
|
| 558 | + if ($ignoreStatusCache) |
|
| 559 | + { |
|
| 560 | + $flags |= Horde_Imap_Client::STATUS_FORCE_REFRESH; |
|
| 561 | + } |
|
| 535 | 562 | |
| 536 | 563 | $mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes); |
| 537 | 564 | //error_log(__METHOD__.__LINE__.array2string($mboxes->count())); |
@@ -574,12 +601,15 @@ discard block |
||
| 574 | 601 | */ |
| 575 | 602 | function getMailboxes($reference = '' , $restriction_search = 0, $returnAttributes = false) |
| 576 | 603 | { |
| 577 | - if ( is_bool($restriction_search) ){ |
|
| 604 | + if ( is_bool($restriction_search) ) |
|
| 605 | + { |
|
| 578 | 606 | $restriction_search = (int) $restriction_search; |
| 579 | 607 | } |
| 580 | 608 | $mailbox = ''; |
| 581 | - if ( is_int( $restriction_search ) ){ |
|
| 582 | - switch ( $restriction_search ) { |
|
| 609 | + if ( is_int( $restriction_search ) ) |
|
| 610 | + { |
|
| 611 | + switch ( $restriction_search ) |
|
| 612 | + { |
|
| 583 | 613 | case 0: |
| 584 | 614 | $searchstring = $reference."*"; |
| 585 | 615 | break; |
@@ -591,8 +621,11 @@ discard block |
||
| 591 | 621 | $searchstring = $reference."%"; |
| 592 | 622 | break; |
| 593 | 623 | } |
| 594 | - }else{ |
|
| 595 | - if ( is_string( $restriction_search ) ){ |
|
| 624 | + } |
|
| 625 | + else |
|
| 626 | + { |
|
| 627 | + if ( is_string( $restriction_search ) ) |
|
| 628 | + { |
|
| 596 | 629 | $mailbox = $searchstring = $restriction_search; |
| 597 | 630 | } |
| 598 | 631 | } |
@@ -658,12 +691,15 @@ discard block |
||
| 658 | 691 | */ |
| 659 | 692 | function listSubscribedMailboxes($reference = '' , $restriction_search = 0, $returnAttributes = false) |
| 660 | 693 | { |
| 661 | - if ( is_bool($restriction_search) ){ |
|
| 694 | + if ( is_bool($restriction_search) ) |
|
| 695 | + { |
|
| 662 | 696 | $restriction_search = (int) $restriction_search; |
| 663 | 697 | } |
| 664 | 698 | $mailbox = ''; |
| 665 | - if ( is_int( $restriction_search ) ){ |
|
| 666 | - switch ( $restriction_search ) { |
|
| 699 | + if ( is_int( $restriction_search ) ) |
|
| 700 | + { |
|
| 701 | + switch ( $restriction_search ) |
|
| 702 | + { |
|
| 667 | 703 | case 0: |
| 668 | 704 | $searchstring = $reference."*"; |
| 669 | 705 | break; |
@@ -675,8 +711,11 @@ discard block |
||
| 675 | 711 | $searchstring = $reference."%"; |
| 676 | 712 | break; |
| 677 | 713 | } |
| 678 | - }else{ |
|
| 679 | - if ( is_string( $restriction_search ) ){ |
|
| 714 | + } |
|
| 715 | + else |
|
| 716 | + { |
|
| 717 | + if ( is_string( $restriction_search ) ) |
|
| 718 | + { |
|
| 680 | 719 | $mailbox = $searchstring = $restriction_search; |
| 681 | 720 | } |
| 682 | 721 | } |
@@ -724,12 +763,15 @@ discard block |
||
| 724 | 763 | */ |
| 725 | 764 | function listUnSubscribedMailboxes($reference = '' , $restriction_search = 0) |
| 726 | 765 | { |
| 727 | - if ( is_bool($restriction_search) ){ |
|
| 766 | + if ( is_bool($restriction_search) ) |
|
| 767 | + { |
|
| 728 | 768 | $restriction_search = (int) $restriction_search; |
| 729 | 769 | } |
| 730 | 770 | |
| 731 | - if ( is_int( $restriction_search ) ){ |
|
| 732 | - switch ( $restriction_search ) { |
|
| 771 | + if ( is_int( $restriction_search ) ) |
|
| 772 | + { |
|
| 773 | + switch ( $restriction_search ) |
|
| 774 | + { |
|
| 733 | 775 | case 0: |
| 734 | 776 | $mailbox = $reference."*"; |
| 735 | 777 | break; |
@@ -741,8 +783,11 @@ discard block |
||
| 741 | 783 | $mailbox = "%"; |
| 742 | 784 | break; |
| 743 | 785 | } |
| 744 | - }else{ |
|
| 745 | - if ( is_string( $restriction_search ) ){ |
|
| 786 | + } |
|
| 787 | + else |
|
| 788 | + { |
|
| 789 | + if ( is_string( $restriction_search ) ) |
|
| 790 | + { |
|
| 746 | 791 | $mailbox = $restriction_search; |
| 747 | 792 | } |
| 748 | 793 | } |
@@ -761,7 +806,10 @@ discard block |
||
| 761 | 806 | foreach ($unsubscribed as $box) |
| 762 | 807 | { |
| 763 | 808 | //error_log(__METHOD__.__LINE__.' Box:'.$k.'->'.array2string($box['mailbox']->utf8)); |
| 764 | - if (!in_array($box['mailbox']->utf8,$sret) && $box['mailbox']->utf8!='INBOX') $ret[]=$box['mailbox']->utf8; |
|
| 809 | + if (!in_array($box['mailbox']->utf8,$sret) && $box['mailbox']->utf8!='INBOX') |
|
| 810 | + { |
|
| 811 | + $ret[]=$box['mailbox']->utf8; |
|
| 812 | + } |
|
| 765 | 813 | } |
| 766 | 814 | return $ret; |
| 767 | 815 | } |
@@ -775,10 +823,16 @@ discard block |
||
| 775 | 823 | */ |
| 776 | 824 | function examineMailbox($mailbox, $flags=null) |
| 777 | 825 | { |
| 778 | - if ($mailbox=='') return false; |
|
| 826 | + if ($mailbox=='') |
|
| 827 | + { |
|
| 828 | + return false; |
|
| 829 | + } |
|
| 779 | 830 | $mailboxes = $this->listMailboxes($mailbox); |
| 780 | 831 | |
| 781 | - if (is_null($flags)) $flags = Horde_Imap_Client::STATUS_ALL | Horde_Imap_Client::STATUS_FLAGS | Horde_Imap_Client::STATUS_PERMFLAGS; |
|
| 832 | + if (is_null($flags)) |
|
| 833 | + { |
|
| 834 | + $flags = Horde_Imap_Client::STATUS_ALL | Horde_Imap_Client::STATUS_FLAGS | Horde_Imap_Client::STATUS_PERMFLAGS; |
|
| 835 | + } |
|
| 782 | 836 | |
| 783 | 837 | $mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes); |
| 784 | 838 | //_debug_array($mboxes->count()); |
@@ -860,7 +914,10 @@ discard block |
||
| 860 | 914 | } |
| 861 | 915 | catch (\Exception $e) |
| 862 | 916 | { |
| 863 | - if ($this->debug) error_log(__METHOD__.__LINE__.' error querying for capability:'.$capability.' ->'.$e->getMessage()); |
|
| 917 | + if ($this->debug) |
|
| 918 | + { |
|
| 919 | + error_log(__METHOD__.__LINE__.' error querying for capability:'.$capability.' ->'.$e->getMessage()); |
|
| 920 | + } |
|
| 864 | 921 | return false; |
| 865 | 922 | } |
| 866 | 923 | if (!is_array($cap)) |
@@ -900,7 +957,10 @@ discard block |
||
| 900 | 957 | { |
| 901 | 958 | foreach($_nameSpace as &$singleNameSpace) |
| 902 | 959 | { |
| 903 | - if (substr($_folderName,0,strlen($singleNameSpace['prefix'])) == $singleNameSpace['prefix']) return $singleNameSpace['prefix']; |
|
| 960 | + if (substr($_folderName,0,strlen($singleNameSpace['prefix'])) == $singleNameSpace['prefix']) |
|
| 961 | + { |
|
| 962 | + return $singleNameSpace['prefix']; |
|
| 963 | + } |
|
| 904 | 964 | } |
| 905 | 965 | return ""; |
| 906 | 966 | } |
@@ -917,7 +977,8 @@ discard block |
||
| 917 | 977 | */ |
| 918 | 978 | function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel=0) |
| 919 | 979 | { |
| 920 | - if ($reclevel > 25) { |
|
| 980 | + if ($reclevel > 25) |
|
| 981 | + { |
|
| 921 | 982 | error_log( __METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter "); |
| 922 | 983 | return array(); |
| 923 | 984 | } |
@@ -933,7 +994,8 @@ discard block |
||
| 933 | 994 | { |
| 934 | 995 | $buff = $this->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'].($mbx[$mbxkeys[0]]['MAILBOX'] == $prefix ? '':$delimiter),2,false); |
| 935 | 996 | $allMailboxes = array(); |
| 936 | - foreach ($buff as $mbxname) { |
|
| 997 | + foreach ($buff as $mbxname) |
|
| 998 | + { |
|
| 937 | 999 | $mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$mbxname['MAILBOX']); |
| 938 | 1000 | #echo "About to recur in level $reclevel:".$mbxname."<br>"; |
| 939 | 1001 | if ( $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'] && $mbxname != $prefix && $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'].$delimiter) |
@@ -941,7 +1003,10 @@ discard block |
||
| 941 | 1003 | $allMailboxes = array_merge($allMailboxes, self::getMailBoxesRecursive($mbxname, $delimiter, $prefix, $reclevel)); |
| 942 | 1004 | } |
| 943 | 1005 | } |
| 944 | - if (!(in_array('\NoSelect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) $allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX']; |
|
| 1006 | + if (!(in_array('\NoSelect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) |
|
| 1007 | + { |
|
| 1008 | + $allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX']; |
|
| 1009 | + } |
|
| 945 | 1010 | return $allMailboxes; |
| 946 | 1011 | } |
| 947 | 1012 | else |
@@ -963,9 +1028,16 @@ discard block |
||
| 963 | 1028 | static $nameSpace=null; |
| 964 | 1029 | $foldersNameSpace = array(); |
| 965 | 1030 | $delimiter = $this->getDelimiter(); |
| 966 | - if (empty($delimiter)) $delimiter='/'; |
|
| 967 | - if (is_null($nameSpace)) $nameSpace = $this->getNameSpaceArray(); |
|
| 968 | - if (is_array($nameSpace)) { |
|
| 1031 | + if (empty($delimiter)) |
|
| 1032 | + { |
|
| 1033 | + $delimiter='/'; |
|
| 1034 | + } |
|
| 1035 | + if (is_null($nameSpace)) |
|
| 1036 | + { |
|
| 1037 | + $nameSpace = $this->getNameSpaceArray(); |
|
| 1038 | + } |
|
| 1039 | + if (is_array($nameSpace)) |
|
| 1040 | + { |
|
| 969 | 1041 | foreach($nameSpace as $type => $singleNameSpaceArray) |
| 970 | 1042 | { |
| 971 | 1043 | foreach ($singleNameSpaceArray as $singleNameSpace) |
@@ -982,7 +1054,9 @@ discard block |
||
| 982 | 1054 | $_foldersNameSpace['prefix_present'] = 'forced'; |
| 983 | 1055 | // uw-imap server with mailbox prefix or dovecot maybe |
| 984 | 1056 | $_foldersNameSpace['prefix'] = 'mail'; |
| 985 | - } else { |
|
| 1057 | + } |
|
| 1058 | + else |
|
| 1059 | + { |
|
| 986 | 1060 | $_foldersNameSpace['prefix_present'] = !empty($singleNameSpace['name']); |
| 987 | 1061 | $_foldersNameSpace['prefix'] = $singleNameSpace['name']; |
| 988 | 1062 | } |
@@ -1022,7 +1096,10 @@ discard block |
||
| 1022 | 1096 | $namespaces = $this->getNamespaces(); |
| 1023 | 1097 | foreach ($namespaces as $nsp) |
| 1024 | 1098 | { |
| 1025 | - if ($nsp['type']==$type && $nsp['delimiter']) return $nsp['delimiter']; |
|
| 1099 | + if ($nsp['type']==$type && $nsp['delimiter']) |
|
| 1100 | + { |
|
| 1101 | + return $nsp['delimiter']; |
|
| 1102 | + } |
|
| 1026 | 1103 | } |
| 1027 | 1104 | return "/"; |
| 1028 | 1105 | } |
@@ -1131,12 +1208,14 @@ discard block |
||
| 1131 | 1208 | { |
| 1132 | 1209 | $nameSpaces = $this->getNameSpaceArray(); |
| 1133 | 1210 | |
| 1134 | - if(!isset($nameSpaces['others'])) { |
|
| 1211 | + if(!isset($nameSpaces['others'])) |
|
| 1212 | + { |
|
| 1135 | 1213 | return false; |
| 1136 | 1214 | } |
| 1137 | 1215 | |
| 1138 | 1216 | $username = $this->getMailBoxUserName($_username); |
| 1139 | - if($this->loginType == 'vmailmgr' || $this->loginType == 'email' || $this->loginType == 'uidNumber') { |
|
| 1217 | + if($this->loginType == 'vmailmgr' || $this->loginType == 'email' || $this->loginType == 'uidNumber') |
|
| 1218 | + { |
|
| 1140 | 1219 | $username .= '@'. $this->domainName; |
| 1141 | 1220 | } |
| 1142 | 1221 | |
@@ -1288,7 +1367,10 @@ discard block |
||
| 1288 | 1367 | */ |
| 1289 | 1368 | public function __call($name,array $params=null) |
| 1290 | 1369 | { |
| 1291 | - if ($this->debug) error_log(__METHOD__.'->'.$name.' with params:'.array2string($params)); |
|
| 1370 | + if ($this->debug) |
|
| 1371 | + { |
|
| 1372 | + error_log(__METHOD__.'->'.$name.' with params:'.array2string($params)); |
|
| 1373 | + } |
|
| 1292 | 1374 | switch($name) |
| 1293 | 1375 | { |
| 1294 | 1376 | case 'installScript': |
@@ -1323,7 +1405,10 @@ discard block |
||
| 1323 | 1405 | */ |
| 1324 | 1406 | public function setVacationUser($_euser, array $_vacation, $_scriptName=null) |
| 1325 | 1407 | { |
| 1326 | - if ($this->debug) error_log(__METHOD__.' User:'.array2string($_euser).' Scriptname:'.array2string($_scriptName).' VacationMessage:'.array2string($_vacation)); |
|
| 1408 | + if ($this->debug) |
|
| 1409 | + { |
|
| 1410 | + error_log(__METHOD__.' User:'.array2string($_euser).' Scriptname:'.array2string($_scriptName).' VacationMessage:'.array2string($_vacation)); |
|
| 1411 | + } |
|
| 1327 | 1412 | |
| 1328 | 1413 | if (is_numeric($_euser)) |
| 1329 | 1414 | { |
@@ -1351,7 +1436,10 @@ discard block |
||
| 1351 | 1436 | */ |
| 1352 | 1437 | public function getVacationUser($_euser, $_scriptName=null) |
| 1353 | 1438 | { |
| 1354 | - if ($this->debug) error_log(__METHOD__.' User:'.array2string($_euser)); |
|
| 1439 | + if ($this->debug) |
|
| 1440 | + { |
|
| 1441 | + error_log(__METHOD__.' User:'.array2string($_euser)); |
|
| 1442 | + } |
|
| 1355 | 1443 | |
| 1356 | 1444 | if (is_numeric($_euser)) |
| 1357 | 1445 | { |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | static public $default_params = array( |
| 67 | 67 | //'debug' => '/tmp/imap.log', // uncomment to log communitcation with IMAP server |
| 68 | 68 | //'debug_literal' => true, // uncomment to log mail contents returned by IMAP server |
| 69 | - 'cache' => true, // default caching via Cache / Api\Cache |
|
| 69 | + 'cache' => true, // default caching via Cache / Api\Cache |
|
| 70 | 70 | ); |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * @param int $_timeout =null timeout in secs, if none given fmail pref or default of 20 is used |
| 145 | 145 | * @return void |
| 146 | 146 | */ |
| 147 | - function __construct(array $params, $_adminConnection=false, $_timeout=null) |
|
| 147 | + function __construct(array $params, $_adminConnection = false, $_timeout = null) |
|
| 148 | 148 | { |
| 149 | 149 | if (function_exists('mb_convert_encoding')) |
| 150 | 150 | { |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | $this->loginType = $this->params['acc_imap_logintype']; |
| 157 | 157 | $this->domainName = $this->params['acc_domain']; |
| 158 | 158 | |
| 159 | - if (is_null($_timeout)) $_timeout = $this->params['acc_imap_timeout']?$this->params['acc_imap_timeout']:self::getTimeOut (); |
|
| 159 | + if (is_null($_timeout)) $_timeout = $this->params['acc_imap_timeout'] ? $this->params['acc_imap_timeout'] : self::getTimeOut(); |
|
| 160 | 160 | |
| 161 | 161 | // Horde use locale for translation of error messages |
| 162 | 162 | Api\Preferences::setlocale(LC_MESSAGES); |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | 'port' => $this->params['acc_imap_port'], |
| 176 | 176 | 'secure' => Account::ssl2secure($this->params['acc_imap_ssl']), |
| 177 | 177 | 'timeout' => $_timeout, |
| 178 | - )+self::$default_params; |
|
| 178 | + ) + self::$default_params; |
|
| 179 | 179 | |
| 180 | 180 | if ($parent_params['cache'] === true) |
| 181 | 181 | { |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | // as we have no way to tell this apart we ignore BINARY this affects |
| 200 | 200 | // Horde_Imap_Client_Fetch_Query::bodyPart for its fetch parameter decode=true is ignored |
| 201 | 201 | // (other functionality depending on BINARY is, of cause, affected too) |
| 202 | - $parent_params['capability_ignore']= array_merge((array)$parent_params['capability_ignore'],array('BINARY')); |
|
| 202 | + $parent_params['capability_ignore'] = array_merge((array)$parent_params['capability_ignore'], array('BINARY')); |
|
| 203 | 203 | break; |
| 204 | 204 | } |
| 205 | 205 | parent::__construct($parent_params); |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | * |
| 213 | 213 | * @param string $_username =true create an admin connection for given user or $this->acc_imap_username |
| 214 | 214 | */ |
| 215 | - function adminConnection($_username=true) |
|
| 215 | + function adminConnection($_username = true) |
|
| 216 | 216 | { |
| 217 | 217 | if ($this->isAdminConnection !== $_username) |
| 218 | 218 | { |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * @param string $_username =null create an admin connection for given user or $this->acc_imap_username |
| 230 | 230 | * @throws Horde_IMAP_Client_Exception |
| 231 | 231 | */ |
| 232 | - public function checkAdminConnection($_username=true) |
|
| 232 | + public function checkAdminConnection($_username = true) |
|
| 233 | 233 | { |
| 234 | 234 | if ($this->acc_imap_administration) |
| 235 | 235 | { |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | * |
| 244 | 244 | * @var array |
| 245 | 245 | */ |
| 246 | - protected $run_on_login=array(); |
|
| 246 | + protected $run_on_login = array(); |
|
| 247 | 247 | |
| 248 | 248 | /** |
| 249 | 249 | * Run given function on successful login |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | * @param callable $func |
| 252 | 252 | * @param array $params =array() |
| 253 | 253 | */ |
| 254 | - public function runOnLogin($func, array $params=array()) |
|
| 254 | + public function runOnLogin($func, array $params = array()) |
|
| 255 | 255 | { |
| 256 | 256 | $this->run_on_login[] = array($func, $params); |
| 257 | 257 | } |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | { |
| 266 | 266 | parent::login(); |
| 267 | 267 | |
| 268 | - foreach($this->run_on_login as $key => $data) |
|
| 268 | + foreach ($this->run_on_login as $key => $data) |
|
| 269 | 269 | { |
| 270 | 270 | call_user_func_array($data[0], $data[1]); |
| 271 | 271 | |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | */ |
| 282 | 282 | public function __get($name) |
| 283 | 283 | { |
| 284 | - switch($name) |
|
| 284 | + switch ($name) |
|
| 285 | 285 | { |
| 286 | 286 | case 'acc_imap_administration': |
| 287 | 287 | return !empty($this->params['acc_imap_admin_username']); |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | { |
| 300 | 300 | return $this->$name; |
| 301 | 301 | } |
| 302 | - if (array_key_exists($name,$this->params)) |
|
| 302 | + if (array_key_exists($name, $this->params)) |
|
| 303 | 303 | { |
| 304 | 304 | return $this->params[$name]; |
| 305 | 305 | } |
@@ -320,9 +320,9 @@ discard block |
||
| 320 | 320 | * @deprecated allready called by constructor automatic, parameters must be passed to constructor! |
| 321 | 321 | * @throws Api\Exception\WrongParameter |
| 322 | 322 | */ |
| 323 | - function openConnection($_adminConnection=false, $_timeout=null) |
|
| 323 | + function openConnection($_adminConnection = false, $_timeout = null) |
|
| 324 | 324 | { |
| 325 | - unset($_timeout); // not used |
|
| 325 | + unset($_timeout); // not used |
|
| 326 | 326 | if ($_adminConnection !== $this->params['adminConnection']) |
| 327 | 327 | { |
| 328 | 328 | throw new Api\Exception\WrongParameter('need to set parameters on calling Account->imapServer()!'); |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | * @param string _use decide if the use is for IMAP or SIEVE, by now only the default differs |
| 336 | 336 | * @return int - timeout (either set or default 20/10) |
| 337 | 337 | */ |
| 338 | - static function getTimeOut($_use='IMAP') |
|
| 338 | + static function getTimeOut($_use = 'IMAP') |
|
| 339 | 339 | { |
| 340 | 340 | $timeout = $GLOBALS['egw_info']['user']['preferences']['mail']['connectionTimeout']; |
| 341 | 341 | if (empty($timeout) || !($timeout > 0)) $timeout = $_use == 'SIEVE' ? 10 : 20; // this is the default value |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | */ |
| 361 | 361 | function addAccount($_hookValues) |
| 362 | 362 | { |
| 363 | - unset($_hookValues); // not used |
|
| 363 | + unset($_hookValues); // not used |
|
| 364 | 364 | return true; |
| 365 | 365 | } |
| 366 | 366 | |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | */ |
| 373 | 373 | function updateAccount($_hookValues) |
| 374 | 374 | { |
| 375 | - unset($_hookValues); // not used |
|
| 375 | + unset($_hookValues); // not used |
|
| 376 | 376 | return true; |
| 377 | 377 | } |
| 378 | 378 | |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | */ |
| 385 | 385 | function deleteAccount($_hookValues) |
| 386 | 386 | { |
| 387 | - unset($_hookValues); // not used |
|
| 387 | + unset($_hookValues); // not used |
|
| 388 | 388 | return true; |
| 389 | 389 | } |
| 390 | 390 | |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | */ |
| 402 | 402 | function encodeFolderName($_folderName) |
| 403 | 403 | { |
| 404 | - if($this->mbAvailable) { |
|
| 404 | + if ($this->mbAvailable) { |
|
| 405 | 405 | return mb_convert_encoding($_folderName, "UTF7-IMAP", Api\Translation::charset()); |
| 406 | 406 | } |
| 407 | 407 | |
@@ -418,17 +418,17 @@ discard block |
||
| 418 | 418 | */ |
| 419 | 419 | function getMailbox($mailbox) |
| 420 | 420 | { |
| 421 | - $mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_ALL); |
|
| 422 | - if (empty($mailboxes)) $mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_UNSUBSCRIBED); |
|
| 421 | + $mailboxes = $this->listMailboxes($mailbox, Horde_Imap_Client::MBOX_ALL); |
|
| 422 | + if (empty($mailboxes)) $mailboxes = $this->listMailboxes($mailbox, Horde_Imap_Client::MBOX_UNSUBSCRIBED); |
|
| 423 | 423 | //error_log(__METHOD__.__LINE__.'->'.$mailbox.'/'.array2string($mailboxes)); |
| 424 | 424 | $mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes); |
| 425 | 425 | //_debug_array($mboxes->count()); |
| 426 | 426 | foreach ($mboxes->getIterator() as $k =>$box) |
| 427 | 427 | { |
| 428 | 428 | //error_log(__METHOD__.__LINE__.'->'.$k); |
| 429 | - if ($k!='user' && $k != '' && $k==$mailbox) return $box['mailbox']; //_debug_array(array($k => $client->status($k))); |
|
| 429 | + if ($k != 'user' && $k != '' && $k == $mailbox) return $box['mailbox']; //_debug_array(array($k => $client->status($k))); |
|
| 430 | 430 | } |
| 431 | - return ($this->mailboxExist($mailbox)?$mailbox:false); |
|
| 431 | + return ($this->mailboxExist($mailbox) ? $mailbox : false); |
|
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | /** |
@@ -444,23 +444,23 @@ discard block |
||
| 444 | 444 | //error_log(__METHOD__.__LINE__.':'.$mailbox); |
| 445 | 445 | $currentMailbox = $this->currentMailbox(); |
| 446 | 446 | } |
| 447 | - catch(\Exception $e) |
|
| 447 | + catch (\Exception $e) |
|
| 448 | 448 | { |
| 449 | 449 | //error_log(__METHOD__.__LINE__.' failed detecting currentMailbox:'.$currentMailbox.':'.$e->getMessage()); |
| 450 | - $currentMailbox=null; |
|
| 450 | + $currentMailbox = null; |
|
| 451 | 451 | unset($e); |
| 452 | 452 | } |
| 453 | 453 | try |
| 454 | 454 | { |
| 455 | 455 | //error_log(__METHOD__.__LINE__.':'.$mailbox); |
| 456 | 456 | $this->openMailbox($mailbox); |
| 457 | - $returnvalue=true; |
|
| 457 | + $returnvalue = true; |
|
| 458 | 458 | } |
| 459 | - catch(\Exception $e) |
|
| 459 | + catch (\Exception $e) |
|
| 460 | 460 | { |
| 461 | 461 | //error_log(__METHOD__.__LINE__.' failed opening:'.$mailbox.':'.$e->getMessage().' Called by:'.function_backtrace()); |
| 462 | 462 | unset($e); |
| 463 | - $returnvalue=false; |
|
| 463 | + $returnvalue = false; |
|
| 464 | 464 | } |
| 465 | 465 | if (!empty($currentMailbox) && $currentMailbox['mailbox'] != $mailbox) |
| 466 | 466 | { |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | //error_log(__METHOD__.__LINE__.':'.$currentMailbox .'<->'.$mailbox); |
| 470 | 470 | $this->openMailbox($currentMailbox['mailbox']); |
| 471 | 471 | } |
| 472 | - catch(\Exception $e) |
|
| 472 | + catch (\Exception $e) |
|
| 473 | 473 | { |
| 474 | 474 | //error_log(__METHOD__.__LINE__.' failed reopening:'.$currentMailbox.':'.$e->getMessage()); |
| 475 | 475 | unset($e); |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | { |
| 490 | 490 | $mailbox = $this->currentMailbox(); |
| 491 | 491 | } |
| 492 | - catch(\Exception $e) |
|
| 492 | + catch (\Exception $e) |
|
| 493 | 493 | { |
| 494 | 494 | error_log(__METHOD__.' ('.__LINE__.') failed fetching currentMailbox:'.$e->getMessage()); |
| 495 | 495 | //throw new egw_exception(__METHOD__.' ('.__LINE__.") failed to ".__METHOD__." :".$e->getMessage()); |
@@ -507,16 +507,16 @@ discard block |
||
| 507 | 507 | */ |
| 508 | 508 | function getSpecialUseFolders() |
| 509 | 509 | { |
| 510 | - $mailboxes = $this->getMailboxes('',0,true); |
|
| 510 | + $mailboxes = $this->getMailboxes('', 0, true); |
|
| 511 | 511 | $suF = array(); |
| 512 | 512 | foreach ($mailboxes as $box) |
| 513 | 513 | { |
| 514 | - if ($box['MAILBOX']!='user' && $box['MAILBOX'] != '') |
|
| 514 | + if ($box['MAILBOX'] != 'user' && $box['MAILBOX'] != '') |
|
| 515 | 515 | { |
| 516 | 516 | //error_log(__METHOD__.__LINE__.$k.'->'.array2string($box)); |
| 517 | - if (isset($box['ATTRIBUTES'])&&!empty($box['ATTRIBUTES'])&& |
|
| 518 | - stripos(strtolower(array2string($box['ATTRIBUTES'])),'\noselect')=== false&& |
|
| 519 | - stripos(strtolower(array2string($box['ATTRIBUTES'])),'\nonexistent')=== false) |
|
| 517 | + if (isset($box['ATTRIBUTES']) && !empty($box['ATTRIBUTES']) && |
|
| 518 | + stripos(strtolower(array2string($box['ATTRIBUTES'])), '\noselect') === false && |
|
| 519 | + stripos(strtolower(array2string($box['ATTRIBUTES'])), '\nonexistent') === false) |
|
| 520 | 520 | { |
| 521 | 521 | $suF[$box['MAILBOX']] = $box; |
| 522 | 522 | } |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | $status = $this->status($mailbox); |
| 539 | 539 | foreach ($status as $key => $v) |
| 540 | 540 | { |
| 541 | - $_status[strtoupper($key)]=$v; |
|
| 541 | + $_status[strtoupper($key)] = $v; |
|
| 542 | 542 | } |
| 543 | 543 | return $_status; |
| 544 | 544 | } |
@@ -556,9 +556,9 @@ discard block |
||
| 556 | 556 | * @param ignoreStatusCache bool ignore the cache used for counters |
| 557 | 557 | * @return array with counters |
| 558 | 558 | */ |
| 559 | - function getStatus($mailbox, $ignoreStatusCache=false) |
|
| 559 | + function getStatus($mailbox, $ignoreStatusCache = false) |
|
| 560 | 560 | { |
| 561 | - $mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_ALL,array( |
|
| 561 | + $mailboxes = $this->listMailboxes($mailbox, Horde_Imap_Client::MBOX_ALL, array( |
|
| 562 | 562 | 'attributes'=>true, |
| 563 | 563 | 'children'=>true, //child info |
| 564 | 564 | 'delimiter'=>true, |
@@ -572,16 +572,16 @@ discard block |
||
| 572 | 572 | //error_log(__METHOD__.__LINE__.array2string($mboxes->count())); |
| 573 | 573 | foreach ($mboxes->getIterator() as $k =>$box) |
| 574 | 574 | { |
| 575 | - if ($k!='user' && $k != '' && $k==$mailbox) |
|
| 575 | + if ($k != 'user' && $k != '' && $k == $mailbox) |
|
| 576 | 576 | { |
| 577 | - if (stripos(array2string($box['attributes']),'\noselect')=== false) |
|
| 577 | + if (stripos(array2string($box['attributes']), '\noselect') === false) |
|
| 578 | 578 | { |
| 579 | 579 | $status = $this->status($k, $flags); |
| 580 | 580 | foreach ($status as $key => $v) |
| 581 | 581 | { |
| 582 | - $_status[strtoupper($key)]=$v; |
|
| 582 | + $_status[strtoupper($key)] = $v; |
|
| 583 | 583 | } |
| 584 | - $_status['HIERACHY_DELIMITER'] = $_status['delimiter'] = ($box['delimiter']?$box['delimiter']:$this->getDelimiter('personal')); |
|
| 584 | + $_status['HIERACHY_DELIMITER'] = $_status['delimiter'] = ($box['delimiter'] ? $box['delimiter'] : $this->getDelimiter('personal')); |
|
| 585 | 585 | $_status['ATTRIBUTES'] = $box['attributes']; |
| 586 | 586 | //error_log(__METHOD__.__LINE__.$k.'->'.array2string($_status)); |
| 587 | 587 | return $_status; |
@@ -607,14 +607,14 @@ discard block |
||
| 607 | 607 | * |
| 608 | 608 | * @return mixed array of mailboxes |
| 609 | 609 | */ |
| 610 | - function getMailboxes($reference = '' , $restriction_search = 0, $returnAttributes = false) |
|
| 610 | + function getMailboxes($reference = '', $restriction_search = 0, $returnAttributes = false) |
|
| 611 | 611 | { |
| 612 | - if ( is_bool($restriction_search) ){ |
|
| 613 | - $restriction_search = (int) $restriction_search; |
|
| 612 | + if (is_bool($restriction_search)) { |
|
| 613 | + $restriction_search = (int)$restriction_search; |
|
| 614 | 614 | } |
| 615 | 615 | $mailbox = ''; |
| 616 | - if ( is_int( $restriction_search ) ){ |
|
| 617 | - switch ( $restriction_search ) { |
|
| 616 | + if (is_int($restriction_search)) { |
|
| 617 | + switch ($restriction_search) { |
|
| 618 | 618 | case 0: |
| 619 | 619 | $searchstring = $reference."*"; |
| 620 | 620 | break; |
@@ -626,8 +626,8 @@ discard block |
||
| 626 | 626 | $searchstring = $reference."%"; |
| 627 | 627 | break; |
| 628 | 628 | } |
| 629 | - }else{ |
|
| 630 | - if ( is_string( $restriction_search ) ){ |
|
| 629 | + } else { |
|
| 630 | + if (is_string($restriction_search)) { |
|
| 631 | 631 | $mailbox = $searchstring = $restriction_search; |
| 632 | 632 | } |
| 633 | 633 | } |
@@ -640,35 +640,35 @@ discard block |
||
| 640 | 640 | 'special_use'=>true, |
| 641 | 641 | 'sort'=>true, |
| 642 | 642 | ); |
| 643 | - if ($returnAttributes==false) |
|
| 643 | + if ($returnAttributes == false) |
|
| 644 | 644 | { |
| 645 | 645 | unset($options['attributes']); |
| 646 | 646 | unset($options['children']); |
| 647 | 647 | unset($options['special_use']); |
| 648 | 648 | } |
| 649 | - $mailboxes = $this->listMailboxes($searchstring,Horde_Imap_Client::MBOX_ALL, $options); |
|
| 649 | + $mailboxes = $this->listMailboxes($searchstring, Horde_Imap_Client::MBOX_ALL, $options); |
|
| 650 | 650 | //$mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes); |
| 651 | 651 | //_debug_array($mboxes->count()); |
| 652 | 652 | foreach ((array)$mailboxes as $k =>$box) |
| 653 | 653 | { |
| 654 | 654 | //error_log(__METHOD__.__LINE__.' Box:'.$k.'->'.array2string($box)); |
| 655 | - $ret[$k]=array('MAILBOX'=>$k,'ATTRIBUTES'=>$box['attributes'],'delimiter'=>($box['delimiter']?$box['delimiter']:$this->getDelimiter('personal')),'SUBSCRIBED'=>true); |
|
| 655 | + $ret[$k] = array('MAILBOX'=>$k, 'ATTRIBUTES'=>$box['attributes'], 'delimiter'=>($box['delimiter'] ? $box['delimiter'] : $this->getDelimiter('personal')), 'SUBSCRIBED'=>true); |
|
| 656 | 656 | } |
| 657 | 657 | // for unknown reasons on ALL, UNSUBSCRIBED are not returned |
| 658 | 658 | //always fetch unsubscribed, think about only fetching it when $options['attributes'] is set |
| 659 | 659 | //but then allMailboxes are not all, .... |
| 660 | 660 | //if (!empty($mailbox) && !isset($ret[$mailbox])) |
| 661 | 661 | { |
| 662 | - $unsub_mailboxes = $this->listMailboxes($searchstring,Horde_Imap_Client::MBOX_UNSUBSCRIBED, $options); |
|
| 662 | + $unsub_mailboxes = $this->listMailboxes($searchstring, Horde_Imap_Client::MBOX_UNSUBSCRIBED, $options); |
|
| 663 | 663 | //$mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes); |
| 664 | 664 | //_debug_array($mboxes->count()); |
| 665 | 665 | //error_log(__METHOD__.__LINE__.' '.$mailbox.':'.count((array)$mailboxes).'->'.function_backtrace()); |
| 666 | 666 | foreach ((array)$unsub_mailboxes as $k =>$box) |
| 667 | 667 | { |
| 668 | 668 | //error_log(__METHOD__.__LINE__.' Box:'.$k.' already In?'.array_key_exists($k,$boxexists).'->'.array2string($box)); |
| 669 | - if(!array_key_exists($k,$ret)) |
|
| 669 | + if (!array_key_exists($k, $ret)) |
|
| 670 | 670 | { |
| 671 | - $ret[$k]=array('MAILBOX'=>$k,'ATTRIBUTES'=>$box['attributes'],'delimiter'=>($box['delimiter']?$box['delimiter']:$this->getDelimiter('personal')),'SUBSCRIBED'=>false); |
|
| 671 | + $ret[$k] = array('MAILBOX'=>$k, 'ATTRIBUTES'=>$box['attributes'], 'delimiter'=>($box['delimiter'] ? $box['delimiter'] : $this->getDelimiter('personal')), 'SUBSCRIBED'=>false); |
|
| 672 | 672 | } |
| 673 | 673 | else |
| 674 | 674 | { |
@@ -691,14 +691,14 @@ discard block |
||
| 691 | 691 | * |
| 692 | 692 | * @return mixed array of mailboxes |
| 693 | 693 | */ |
| 694 | - function listSubscribedMailboxes($reference = '' , $restriction_search = 0, $returnAttributes = false) |
|
| 694 | + function listSubscribedMailboxes($reference = '', $restriction_search = 0, $returnAttributes = false) |
|
| 695 | 695 | { |
| 696 | - if ( is_bool($restriction_search) ){ |
|
| 697 | - $restriction_search = (int) $restriction_search; |
|
| 696 | + if (is_bool($restriction_search)) { |
|
| 697 | + $restriction_search = (int)$restriction_search; |
|
| 698 | 698 | } |
| 699 | 699 | $mailbox = ''; |
| 700 | - if ( is_int( $restriction_search ) ){ |
|
| 701 | - switch ( $restriction_search ) { |
|
| 700 | + if (is_int($restriction_search)) { |
|
| 701 | + switch ($restriction_search) { |
|
| 702 | 702 | case 0: |
| 703 | 703 | $searchstring = $reference."*"; |
| 704 | 704 | break; |
@@ -710,8 +710,8 @@ discard block |
||
| 710 | 710 | $searchstring = $reference."%"; |
| 711 | 711 | break; |
| 712 | 712 | } |
| 713 | - }else{ |
|
| 714 | - if ( is_string( $restriction_search ) ){ |
|
| 713 | + } else { |
|
| 714 | + if (is_string($restriction_search)) { |
|
| 715 | 715 | $mailbox = $searchstring = $restriction_search; |
| 716 | 716 | } |
| 717 | 717 | } |
@@ -723,25 +723,25 @@ discard block |
||
| 723 | 723 | 'special_use'=>true, |
| 724 | 724 | 'sort'=>true, |
| 725 | 725 | ); |
| 726 | - if ($returnAttributes==false) |
|
| 726 | + if ($returnAttributes == false) |
|
| 727 | 727 | { |
| 728 | 728 | unset($options['attributes']); |
| 729 | 729 | unset($options['children']); |
| 730 | 730 | unset($options['special_use']); |
| 731 | 731 | } |
| 732 | - $mailboxes = $this->listMailboxes($searchstring,Horde_Imap_Client::MBOX_SUBSCRIBED_EXISTS, $options); |
|
| 732 | + $mailboxes = $this->listMailboxes($searchstring, Horde_Imap_Client::MBOX_SUBSCRIBED_EXISTS, $options); |
|
| 733 | 733 | //$mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes); |
| 734 | 734 | //_debug_array($mboxes->count()); |
| 735 | 735 | foreach ((array)$mailboxes as $k =>$box) |
| 736 | 736 | { |
| 737 | 737 | //error_log(__METHOD__.__LINE__.' Searched for:'.$mailbox.' got Box:'.$k.'->'.array2string($box).function_backtrace()); |
| 738 | - if ($returnAttributes==false) |
|
| 738 | + if ($returnAttributes == false) |
|
| 739 | 739 | { |
| 740 | - $ret[]=$k; |
|
| 740 | + $ret[] = $k; |
|
| 741 | 741 | } |
| 742 | 742 | else |
| 743 | 743 | { |
| 744 | - $ret[$k]=array('MAILBOX'=>$k,'ATTRIBUTES'=>$box['attributes'],'delimiter'=>($box['delimiter']?$box['delimiter']:$this->getDelimiter('personal')),'SUBSCRIBED'=>true); |
|
| 744 | + $ret[$k] = array('MAILBOX'=>$k, 'ATTRIBUTES'=>$box['attributes'], 'delimiter'=>($box['delimiter'] ? $box['delimiter'] : $this->getDelimiter('personal')), 'SUBSCRIBED'=>true); |
|
| 745 | 745 | } |
| 746 | 746 | } |
| 747 | 747 | return $ret; |
@@ -757,14 +757,14 @@ discard block |
||
| 757 | 757 | * |
| 758 | 758 | * @return mixed array of mailboxes |
| 759 | 759 | */ |
| 760 | - function listUnSubscribedMailboxes($reference = '' , $restriction_search = 0) |
|
| 760 | + function listUnSubscribedMailboxes($reference = '', $restriction_search = 0) |
|
| 761 | 761 | { |
| 762 | - if ( is_bool($restriction_search) ){ |
|
| 763 | - $restriction_search = (int) $restriction_search; |
|
| 762 | + if (is_bool($restriction_search)) { |
|
| 763 | + $restriction_search = (int)$restriction_search; |
|
| 764 | 764 | } |
| 765 | 765 | |
| 766 | - if ( is_int( $restriction_search ) ){ |
|
| 767 | - switch ( $restriction_search ) { |
|
| 766 | + if (is_int($restriction_search)) { |
|
| 767 | + switch ($restriction_search) { |
|
| 768 | 768 | case 0: |
| 769 | 769 | $mailbox = $reference."*"; |
| 770 | 770 | break; |
@@ -776,8 +776,8 @@ discard block |
||
| 776 | 776 | $mailbox = "%"; |
| 777 | 777 | break; |
| 778 | 778 | } |
| 779 | - }else{ |
|
| 780 | - if ( is_string( $restriction_search ) ){ |
|
| 779 | + } else { |
|
| 780 | + if (is_string($restriction_search)) { |
|
| 781 | 781 | $mailbox = $restriction_search; |
| 782 | 782 | } |
| 783 | 783 | } |
@@ -786,17 +786,17 @@ discard block |
||
| 786 | 786 | 'sort'=>true, |
| 787 | 787 | //'flat'=>true, |
| 788 | 788 | ); |
| 789 | - $mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_SUBSCRIBED_EXISTS, $options); |
|
| 789 | + $mailboxes = $this->listMailboxes($mailbox, Horde_Imap_Client::MBOX_SUBSCRIBED_EXISTS, $options); |
|
| 790 | 790 | foreach ($mailboxes as $box) |
| 791 | 791 | { |
| 792 | 792 | //error_log(__METHOD__.__LINE__.' Box:'.$k.'->'.array2string($box['mailbox']->utf8)); |
| 793 | - $sret[]=$box['mailbox']->utf8; |
|
| 793 | + $sret[] = $box['mailbox']->utf8; |
|
| 794 | 794 | } |
| 795 | - $unsubscribed = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_UNSUBSCRIBED, $options); |
|
| 795 | + $unsubscribed = $this->listMailboxes($mailbox, Horde_Imap_Client::MBOX_UNSUBSCRIBED, $options); |
|
| 796 | 796 | foreach ($unsubscribed as $box) |
| 797 | 797 | { |
| 798 | 798 | //error_log(__METHOD__.__LINE__.' Box:'.$k.'->'.array2string($box['mailbox']->utf8)); |
| 799 | - if (!in_array($box['mailbox']->utf8,$sret) && $box['mailbox']->utf8!='INBOX') $ret[]=$box['mailbox']->utf8; |
|
| 799 | + if (!in_array($box['mailbox']->utf8, $sret) && $box['mailbox']->utf8 != 'INBOX') $ret[] = $box['mailbox']->utf8; |
|
| 800 | 800 | } |
| 801 | 801 | return $ret; |
| 802 | 802 | } |
@@ -808,12 +808,12 @@ discard block |
||
| 808 | 808 | * @param int $flags =null default Horde_Imap_Client::STATUS_ALL | Horde_Imap_Client::STATUS_FLAGS | Horde_Imap_Client::STATUS_PERMFLAGS |
| 809 | 809 | * @return array of counters for mailbox |
| 810 | 810 | */ |
| 811 | - function examineMailbox($mailbox, $flags=null) |
|
| 811 | + function examineMailbox($mailbox, $flags = null) |
|
| 812 | 812 | { |
| 813 | - if ($mailbox=='') return false; |
|
| 813 | + if ($mailbox == '') return false; |
|
| 814 | 814 | $mailboxes = $this->listMailboxes($mailbox); |
| 815 | 815 | |
| 816 | - if (is_null($flags)) $flags = Horde_Imap_Client::STATUS_ALL | Horde_Imap_Client::STATUS_FLAGS | Horde_Imap_Client::STATUS_PERMFLAGS; |
|
| 816 | + if (is_null($flags)) $flags = Horde_Imap_Client::STATUS_ALL|Horde_Imap_Client::STATUS_FLAGS|Horde_Imap_Client::STATUS_PERMFLAGS; |
|
| 817 | 817 | |
| 818 | 818 | $mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes); |
| 819 | 819 | //_debug_array($mboxes->count()); |
@@ -821,18 +821,18 @@ discard block |
||
| 821 | 821 | { |
| 822 | 822 | //error_log(__METHOD__.__LINE__.array2string($box)); |
| 823 | 823 | unset($box); |
| 824 | - if ($k!='user' && $k != '' && $k==$mailbox) |
|
| 824 | + if ($k != 'user' && $k != '' && $k == $mailbox) |
|
| 825 | 825 | { |
| 826 | 826 | $status = $this->status($k, $flags); |
| 827 | 827 | //error_log(__METHOD__.__LINE__.array2string($status)); |
| 828 | 828 | foreach ($status as $key => $v) |
| 829 | 829 | { |
| 830 | - $_status[strtoupper($key)]=$v; |
|
| 830 | + $_status[strtoupper($key)] = $v; |
|
| 831 | 831 | } |
| 832 | - if ($flags & (Horde_Imap_Client::STATUS_FLAGS|Horde_Imap_Client::STATUS_PERMFLAGS)) |
|
| 832 | + if ($flags&(Horde_Imap_Client::STATUS_FLAGS|Horde_Imap_Client::STATUS_PERMFLAGS)) |
|
| 833 | 833 | { |
| 834 | 834 | self::$supports_keywords[$this->ImapServerId] = stripos(implode('', $status['flags']), '$label') !== false || |
| 835 | - in_array('\\*', $status['permflags']); // arbitrary keyswords also allow keywords |
|
| 835 | + in_array('\\*', $status['permflags']); // arbitrary keyswords also allow keywords |
|
| 836 | 836 | } |
| 837 | 837 | return $_status; |
| 838 | 838 | } |
@@ -871,7 +871,7 @@ discard block |
||
| 871 | 871 | */ |
| 872 | 872 | function hasCapability($capability) |
| 873 | 873 | { |
| 874 | - if ($capability=='SUPPORTS_KEYWORDS') |
|
| 874 | + if ($capability == 'SUPPORTS_KEYWORDS') |
|
| 875 | 875 | { |
| 876 | 876 | // if pseudo-flag is not set, call examineMailbox now to set it (no STATUS_ALL = counters necessary) |
| 877 | 877 | if (!isset(self::$supports_keywords[$this->ImapServerId])) |
@@ -883,7 +883,7 @@ discard block |
||
| 883 | 883 | catch (\Exception $e) |
| 884 | 884 | { |
| 885 | 885 | error_log(__METHOD__.__LINE__.' (examineServer for detection) '.$capability.'->'.array2string(self::$supports_keywords).' failed '.function_backtrace()); |
| 886 | - self::$supports_keywords[$this->ImapServerId]=false; |
|
| 886 | + self::$supports_keywords[$this->ImapServerId] = false; |
|
| 887 | 887 | } |
| 888 | 888 | } |
| 889 | 889 | //error_log(__METHOD__.__LINE__.' '.$capability.'->'.array2string(self::$supports_keywords).' '.function_backtrace()); |
@@ -933,9 +933,9 @@ discard block |
||
| 933 | 933 | */ |
| 934 | 934 | static function getFolderPrefixFromNamespace($_nameSpace, $_folderName) |
| 935 | 935 | { |
| 936 | - foreach($_nameSpace as &$singleNameSpace) |
|
| 936 | + foreach ($_nameSpace as &$singleNameSpace) |
|
| 937 | 937 | { |
| 938 | - if (substr($_folderName,0,strlen($singleNameSpace['prefix'])) == $singleNameSpace['prefix']) return $singleNameSpace['prefix']; |
|
| 938 | + if (substr($_folderName, 0, strlen($singleNameSpace['prefix'])) == $singleNameSpace['prefix']) return $singleNameSpace['prefix']; |
|
| 939 | 939 | } |
| 940 | 940 | return ""; |
| 941 | 941 | } |
@@ -950,33 +950,33 @@ discard block |
||
| 950 | 950 | * @param string $reclevel = 0, counter to keep track of the current recursionlevel |
| 951 | 951 | * @return array of mailboxes |
| 952 | 952 | */ |
| 953 | - function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel=0) |
|
| 953 | + function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel = 0) |
|
| 954 | 954 | { |
| 955 | 955 | if ($reclevel > 25) { |
| 956 | - error_log( __METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter "); |
|
| 956 | + error_log(__METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter "); |
|
| 957 | 957 | return array(); |
| 958 | 958 | } |
| 959 | 959 | $reclevel++; |
| 960 | 960 | // clean up double delimiters |
| 961 | - $mailbox = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$_mailbox); |
|
| 961 | + $mailbox = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter : $delimiter).'+~s', $delimiter, $_mailbox); |
|
| 962 | 962 | //get that mailbox in question |
| 963 | - $mbx = $this->getMailboxes($mailbox,1,true); |
|
| 963 | + $mbx = $this->getMailboxes($mailbox, 1, true); |
|
| 964 | 964 | $mbxkeys = array_keys($mbx); |
| 965 | 965 | |
| 966 | 966 | // Example: Array([INBOX/GaGa] => Array([MAILBOX] => INBOX/GaGa[ATTRIBUTES] => Array([0] => \\unmarked)[delimiter] => /)) |
| 967 | - if (is_array($mbx[$mbxkeys[0]]["ATTRIBUTES"]) && (in_array('\HasChildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Haschildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\haschildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) |
|
| 967 | + if (is_array($mbx[$mbxkeys[0]]["ATTRIBUTES"]) && (in_array('\HasChildren', $mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Haschildren', $mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\haschildren', $mbx[$mbxkeys[0]]["ATTRIBUTES"]))) |
|
| 968 | 968 | { |
| 969 | - $buff = $this->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'].($mbx[$mbxkeys[0]]['MAILBOX'] == $prefix ? '':$delimiter),2,false); |
|
| 969 | + $buff = $this->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'].($mbx[$mbxkeys[0]]['MAILBOX'] == $prefix ? '' : $delimiter), 2, false); |
|
| 970 | 970 | $allMailboxes = array(); |
| 971 | 971 | foreach ($buff as $mbxname) { |
| 972 | - $mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$mbxname['MAILBOX']); |
|
| 972 | + $mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter : $delimiter).'+~s', $delimiter, $mbxname['MAILBOX']); |
|
| 973 | 973 | #echo "About to recur in level $reclevel:".$mbxname."<br>"; |
| 974 | - if ( $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'] && $mbxname != $prefix && $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'].$delimiter) |
|
| 974 | + if ($mbxname != $mbx[$mbxkeys[0]]['MAILBOX'] && $mbxname != $prefix && $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'].$delimiter) |
|
| 975 | 975 | { |
| 976 | 976 | $allMailboxes = array_merge($allMailboxes, self::getMailBoxesRecursive($mbxname, $delimiter, $prefix, $reclevel)); |
| 977 | 977 | } |
| 978 | 978 | } |
| 979 | - if (!(in_array('\NoSelect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) $allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX']; |
|
| 979 | + if (!(in_array('\NoSelect', $mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect', $mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect', $mbx[$mbxkeys[0]]["ATTRIBUTES"]))) $allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX']; |
|
| 980 | 980 | return $allMailboxes; |
| 981 | 981 | } |
| 982 | 982 | else |
@@ -995,24 +995,24 @@ discard block |
||
| 995 | 995 | */ |
| 996 | 996 | function getNameSpace() |
| 997 | 997 | { |
| 998 | - static $nameSpace=null; |
|
| 998 | + static $nameSpace = null; |
|
| 999 | 999 | $foldersNameSpace = array(); |
| 1000 | 1000 | $delimiter = $this->getDelimiter(); |
| 1001 | - if (empty($delimiter)) $delimiter='/'; |
|
| 1001 | + if (empty($delimiter)) $delimiter = '/'; |
|
| 1002 | 1002 | if (is_null($nameSpace)) $nameSpace = $this->getNameSpaceArray(); |
| 1003 | 1003 | if (is_array($nameSpace)) { |
| 1004 | - foreach($nameSpace as $type => $singleNameSpaceArray) |
|
| 1004 | + foreach ($nameSpace as $type => $singleNameSpaceArray) |
|
| 1005 | 1005 | { |
| 1006 | 1006 | foreach ($singleNameSpaceArray as $singleNameSpace) |
| 1007 | 1007 | { |
| 1008 | 1008 | $_foldersNameSpace = array(); |
| 1009 | - if($type == 'personal' && $singleNameSpace['name'] == '#mh/' && ($this->folderExists('Mail')||$this->folderExists('INBOX'))) |
|
| 1009 | + if ($type == 'personal' && $singleNameSpace['name'] == '#mh/' && ($this->folderExists('Mail') || $this->folderExists('INBOX'))) |
|
| 1010 | 1010 | { |
| 1011 | 1011 | $_foldersNameSpace['prefix_present'] = 'forced'; |
| 1012 | 1012 | // uw-imap server with mailbox prefix or dovecot maybe |
| 1013 | - $_foldersNameSpace['prefix'] = ($this->folderExists('Mail')?'Mail':(!empty($singleNameSpace['name'])?$singleNameSpace['name']:'')); |
|
| 1013 | + $_foldersNameSpace['prefix'] = ($this->folderExists('Mail') ? 'Mail' : (!empty($singleNameSpace['name']) ? $singleNameSpace['name'] : '')); |
|
| 1014 | 1014 | } |
| 1015 | - elseif($type == 'personal' && ($singleNameSpace['name'] == '#mh/') && $this->folderExists('mail')) |
|
| 1015 | + elseif ($type == 'personal' && ($singleNameSpace['name'] == '#mh/') && $this->folderExists('mail')) |
|
| 1016 | 1016 | { |
| 1017 | 1017 | $_foldersNameSpace['prefix_present'] = 'forced'; |
| 1018 | 1018 | // uw-imap server with mailbox prefix or dovecot maybe |
@@ -1021,9 +1021,9 @@ discard block |
||
| 1021 | 1021 | $_foldersNameSpace['prefix_present'] = !empty($singleNameSpace['name']); |
| 1022 | 1022 | $_foldersNameSpace['prefix'] = $singleNameSpace['name']; |
| 1023 | 1023 | } |
| 1024 | - $_foldersNameSpace['delimiter'] = ($singleNameSpace['delimiter']?$singleNameSpace['delimiter']:$delimiter); |
|
| 1024 | + $_foldersNameSpace['delimiter'] = ($singleNameSpace['delimiter'] ? $singleNameSpace['delimiter'] : $delimiter); |
|
| 1025 | 1025 | $_foldersNameSpace['type'] = $type; |
| 1026 | - $foldersNameSpace[] =$_foldersNameSpace; |
|
| 1026 | + $foldersNameSpace[] = $_foldersNameSpace; |
|
| 1027 | 1027 | } |
| 1028 | 1028 | } |
| 1029 | 1029 | } |
@@ -1035,29 +1035,29 @@ discard block |
||
| 1035 | 1035 | * @param mixed _type (1=personal, 2=user/other, 3=shared) |
| 1036 | 1036 | * @return string the delimimiter |
| 1037 | 1037 | */ |
| 1038 | - function getDelimiter($_type=1) |
|
| 1038 | + function getDelimiter($_type = 1) |
|
| 1039 | 1039 | { |
| 1040 | 1040 | switch ($_type) |
| 1041 | 1041 | { |
| 1042 | 1042 | case 'user': |
| 1043 | 1043 | case 'other': |
| 1044 | 1044 | case 2: |
| 1045 | - $type=2; |
|
| 1045 | + $type = 2; |
|
| 1046 | 1046 | break; |
| 1047 | 1047 | case 'shared': |
| 1048 | 1048 | case '': |
| 1049 | 1049 | case 3: |
| 1050 | - $type=3; |
|
| 1050 | + $type = 3; |
|
| 1051 | 1051 | break; |
| 1052 | 1052 | case 'personal': |
| 1053 | 1053 | case 1: |
| 1054 | 1054 | default: |
| 1055 | - $type=1; |
|
| 1055 | + $type = 1; |
|
| 1056 | 1056 | } |
| 1057 | 1057 | $namespaces = $this->getNamespaces(); |
| 1058 | 1058 | foreach ($namespaces as $nsp) |
| 1059 | 1059 | { |
| 1060 | - if ($nsp['type']==$type && $nsp['delimiter']) return $nsp['delimiter']; |
|
| 1060 | + if ($nsp['type'] == $type && $nsp['delimiter']) return $nsp['delimiter']; |
|
| 1061 | 1061 | } |
| 1062 | 1062 | return "/"; |
| 1063 | 1063 | } |
@@ -1094,11 +1094,11 @@ discard block |
||
| 1094 | 1094 | switch ($this->loginType) |
| 1095 | 1095 | { |
| 1096 | 1096 | case 'email': |
| 1097 | - $accountemail = $GLOBALS['egw']->accounts->id2name($accountID,'account_email'); |
|
| 1097 | + $accountemail = $GLOBALS['egw']->accounts->id2name($accountID, 'account_email'); |
|
| 1098 | 1098 | //$accountemail = $GLOBALS['egw']->accounts->read($GLOBALS['egw']->accounts->name2id($_username,'account_email')); |
| 1099 | 1099 | if (!empty($accountemail)) |
| 1100 | 1100 | { |
| 1101 | - list($lusername,$domain) = explode('@',$accountemail,2); |
|
| 1101 | + list($lusername, $domain) = explode('@', $accountemail, 2); |
|
| 1102 | 1102 | if (strtolower($domain) == strtolower($this->domainName) && !empty($lusername)) |
| 1103 | 1103 | { |
| 1104 | 1104 | $_username = $lusername; |
@@ -1117,8 +1117,8 @@ discard block |
||
| 1117 | 1117 | if (empty($this->loginType)) |
| 1118 | 1118 | { |
| 1119 | 1119 | // try to figure out by params['acc_imap_username'] |
| 1120 | - list($lusername,$domain) = explode('@',$this->params['acc_imap_username'],2); |
|
| 1121 | - if (strpos($_username,'@')===false && !empty($domain) && !empty($lusername)) |
|
| 1120 | + list($lusername, $domain) = explode('@', $this->params['acc_imap_username'], 2); |
|
| 1121 | + if (strpos($_username, '@') === false && !empty($domain) && !empty($lusername)) |
|
| 1122 | 1122 | { |
| 1123 | 1123 | $_username = $_username.'@'.$domain; |
| 1124 | 1124 | } |
@@ -1162,20 +1162,20 @@ discard block |
||
| 1162 | 1162 | * @param string $_folderName='' |
| 1163 | 1163 | * @return string utf-7 encoded (done in getMailboxName) |
| 1164 | 1164 | */ |
| 1165 | - function getUserMailboxString($_username, $_folderName='') |
|
| 1165 | + function getUserMailboxString($_username, $_folderName = '') |
|
| 1166 | 1166 | { |
| 1167 | 1167 | $nameSpaces = $this->getNameSpaceArray(); |
| 1168 | 1168 | |
| 1169 | - if(!isset($nameSpaces['others'])) { |
|
| 1169 | + if (!isset($nameSpaces['others'])) { |
|
| 1170 | 1170 | return false; |
| 1171 | 1171 | } |
| 1172 | 1172 | |
| 1173 | 1173 | $username = $this->getMailBoxUserName($_username); |
| 1174 | - if($this->loginType == 'vmailmgr' || $this->loginType == 'email' || $this->loginType == 'uidNumber') { |
|
| 1175 | - $username .= '@'. $this->domainName; |
|
| 1174 | + if ($this->loginType == 'vmailmgr' || $this->loginType == 'email' || $this->loginType == 'uidNumber') { |
|
| 1175 | + $username .= '@'.$this->domainName; |
|
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | - $mailboxString = $nameSpaces['others'][0]['name'] . $username . (!empty($_folderName) ? ($nameSpaces['others'][0]['delimiter']?$nameSpaces['others'][0]['delimiter']:'/') . $_folderName : ''); |
|
| 1178 | + $mailboxString = $nameSpaces['others'][0]['name'].$username.(!empty($_folderName) ? ($nameSpaces['others'][0]['delimiter'] ? $nameSpaces['others'][0]['delimiter'] : '/').$_folderName : ''); |
|
| 1179 | 1179 | |
| 1180 | 1180 | return $mailboxString; |
| 1181 | 1181 | } |
@@ -1194,7 +1194,7 @@ discard block |
||
| 1194 | 1194 | ); |
| 1195 | 1195 | //error_log(__METHOD__.__LINE__.array2string($types)); |
| 1196 | 1196 | $result = array(); |
| 1197 | - foreach($this->getNamespaces() as $data) |
|
| 1197 | + foreach ($this->getNamespaces() as $data) |
|
| 1198 | 1198 | { |
| 1199 | 1199 | //error_log(__METHOD__.__LINE__.array2string($data)); |
| 1200 | 1200 | if (isset($types[$data['type']])) |
@@ -1204,7 +1204,7 @@ discard block |
||
| 1204 | 1204 | 'name' => $data['name'], |
| 1205 | 1205 | 'prefix' => $data['name'], |
| 1206 | 1206 | 'prefix_present' => !empty($data['name']), |
| 1207 | - 'delimiter' => ($data['delimiter']?$data['delimiter']:'/'), |
|
| 1207 | + 'delimiter' => ($data['delimiter'] ? $data['delimiter'] : '/'), |
|
| 1208 | 1208 | ); |
| 1209 | 1209 | } |
| 1210 | 1210 | } |
@@ -1225,7 +1225,7 @@ discard block |
||
| 1225 | 1225 | { |
| 1226 | 1226 | if ($qInfo['storage']) |
| 1227 | 1227 | { |
| 1228 | - return array('USED'=>$qInfo['storage']['usage'],'QMAX'=>$qInfo['storage']['limit']); |
|
| 1228 | + return array('USED'=>$qInfo['storage']['usage'], 'QMAX'=>$qInfo['storage']['limit']); |
|
| 1229 | 1229 | } |
| 1230 | 1230 | } |
| 1231 | 1231 | return false; |
@@ -1239,7 +1239,7 @@ discard block |
||
| 1239 | 1239 | * @param string $_what - what to retrieve either limit/QMAX, usage/USED or ALL is supported |
| 1240 | 1240 | * @return int|array|boolean the quota for specified user (by what) or array with values for "limit" and "usage", or false |
| 1241 | 1241 | */ |
| 1242 | - function getQuotaByUser($_username, $_what='QMAX') |
|
| 1242 | + function getQuotaByUser($_username, $_what = 'QMAX') |
|
| 1243 | 1243 | { |
| 1244 | 1244 | $mailboxName = $this->getUserMailboxString($_username); |
| 1245 | 1245 | $storageQuota = $this->getQuotaRoot($mailboxName); |
@@ -1248,7 +1248,7 @@ discard block |
||
| 1248 | 1248 | if (is_array($storageQuota) && isset($storageQuota[$mailboxName]) && is_array($storageQuota[$mailboxName]) && |
| 1249 | 1249 | isset($storageQuota[$mailboxName]['storage']) && is_array($storageQuota[$mailboxName]['storage'])) |
| 1250 | 1250 | { |
| 1251 | - switch($_what) |
|
| 1251 | + switch ($_what) |
|
| 1252 | 1252 | { |
| 1253 | 1253 | case 'QMAX': |
| 1254 | 1254 | $_what = 'limit'; |
@@ -1274,7 +1274,7 @@ discard block |
||
| 1274 | 1274 | */ |
| 1275 | 1275 | function getUserData($_username) |
| 1276 | 1276 | { |
| 1277 | - unset($_username); // not used |
|
| 1277 | + unset($_username); // not used |
|
| 1278 | 1278 | return array(); |
| 1279 | 1279 | } |
| 1280 | 1280 | |
@@ -1287,7 +1287,7 @@ discard block |
||
| 1287 | 1287 | */ |
| 1288 | 1288 | function setUserData($_username, $_quota) |
| 1289 | 1289 | { |
| 1290 | - unset($_username, $_quota); // not used |
|
| 1290 | + unset($_username, $_quota); // not used |
|
| 1291 | 1291 | return true; |
| 1292 | 1292 | } |
| 1293 | 1293 | |
@@ -1321,10 +1321,10 @@ discard block |
||
| 1321 | 1321 | * @param array $params |
| 1322 | 1322 | * @throws Api\Exception\WrongParameter |
| 1323 | 1323 | */ |
| 1324 | - public function __call($name,array $params=null) |
|
| 1324 | + public function __call($name, array $params = null) |
|
| 1325 | 1325 | { |
| 1326 | 1326 | if ($this->debug) error_log(__METHOD__.'->'.$name.' with params:'.array2string($params)); |
| 1327 | - switch($name) |
|
| 1327 | + switch ($name) |
|
| 1328 | 1328 | { |
| 1329 | 1329 | case 'installScript': |
| 1330 | 1330 | case 'getScript': |
@@ -1339,9 +1339,9 @@ discard block |
||
| 1339 | 1339 | if (is_null($this->sieve)) |
| 1340 | 1340 | { |
| 1341 | 1341 | $this->sieve = new Sieve($this); |
| 1342 | - $this->error =& $this->sieve->error; |
|
| 1342 | + $this->error = & $this->sieve->error; |
|
| 1343 | 1343 | } |
| 1344 | - $ret = call_user_func_array(array($this->sieve,$name),$params); |
|
| 1344 | + $ret = call_user_func_array(array($this->sieve, $name), $params); |
|
| 1345 | 1345 | //error_log(__CLASS__.'->'.$name.'('.array2string($params).') returns '.array2string($ret)); |
| 1346 | 1346 | return $ret; |
| 1347 | 1347 | } |
@@ -1356,7 +1356,7 @@ discard block |
||
| 1356 | 1356 | * @param string $_scriptName =null |
| 1357 | 1357 | * @return boolean |
| 1358 | 1358 | */ |
| 1359 | - public function setVacationUser($_euser, array $_vacation, $_scriptName=null) |
|
| 1359 | + public function setVacationUser($_euser, array $_vacation, $_scriptName = null) |
|
| 1360 | 1360 | { |
| 1361 | 1361 | if ($this->debug) error_log(__METHOD__.' User:'.array2string($_euser).' Scriptname:'.array2string($_scriptName).' VacationMessage:'.array2string($_vacation)); |
| 1362 | 1362 | |
@@ -1368,8 +1368,8 @@ discard block |
||
| 1368 | 1368 | { |
| 1369 | 1369 | $this->adminConnection($_euser); |
| 1370 | 1370 | $this->sieve = new Sieve($this, $_euser, $_scriptName); |
| 1371 | - $this->scriptName =& $this->sieve->scriptName; |
|
| 1372 | - $this->error =& $this->sieve->error; |
|
| 1371 | + $this->scriptName = & $this->sieve->scriptName; |
|
| 1372 | + $this->error = & $this->sieve->error; |
|
| 1373 | 1373 | } |
| 1374 | 1374 | $ret = $this->setVacation($_vacation, $_scriptName); |
| 1375 | 1375 | |
@@ -1384,7 +1384,7 @@ discard block |
||
| 1384 | 1384 | * @throws Exception on connection error or authentication failure |
| 1385 | 1385 | * @return array |
| 1386 | 1386 | */ |
| 1387 | - public function getVacationUser($_euser, $_scriptName=null) |
|
| 1387 | + public function getVacationUser($_euser, $_scriptName = null) |
|
| 1388 | 1388 | { |
| 1389 | 1389 | if ($this->debug) error_log(__METHOD__.' User:'.array2string($_euser)); |
| 1390 | 1390 | |
@@ -1396,8 +1396,8 @@ discard block |
||
| 1396 | 1396 | { |
| 1397 | 1397 | $this->adminConnection($_euser); |
| 1398 | 1398 | $this->sieve = new Sieve($this, $_euser, $_scriptName); |
| 1399 | - $this->error =& $this->sieve->error; |
|
| 1400 | - $this->scriptName =& $this->sieve->scriptName; |
|
| 1399 | + $this->error = & $this->sieve->error; |
|
| 1400 | + $this->scriptName = & $this->sieve->scriptName; |
|
| 1401 | 1401 | } |
| 1402 | 1402 | return $this->sieve->getVacation(); |
| 1403 | 1403 | } |
@@ -1417,7 +1417,7 @@ discard block |
||
| 1417 | 1417 | */ |
| 1418 | 1418 | public static function init_static() |
| 1419 | 1419 | { |
| 1420 | - self::$supports_keywords =& Api\Cache::getSession (__CLASS__, 'supports_keywords'); |
|
| 1420 | + self::$supports_keywords = & Api\Cache::getSession(__CLASS__, 'supports_keywords'); |
|
| 1421 | 1421 | } |
| 1422 | 1422 | } |
| 1423 | 1423 | Imap::init_static(); |
@@ -121,6 +121,7 @@ |
||
| 121 | 121 | * @param bool $_adminConnection create admin connection if true |
| 122 | 122 | * @param int $_timeout =null timeout in secs, if none given fmail pref or default of 20 is used |
| 123 | 123 | * @throws Exception on error |
| 124 | + * @return void |
|
| 124 | 125 | */ |
| 125 | 126 | function openConnection($_adminConnection=false, $_timeout=null); |
| 126 | 127 | |
@@ -14,9 +14,9 @@ discard block |
||
| 14 | 14 | namespace EGroupware\Api\Mail\Imap; |
| 15 | 15 | |
| 16 | 16 | define('IMAP_NAMESPACE_PERSONAL', 'personal'); |
| 17 | -define('IMAP_NAMESPACE_OTHERS' , 'others'); |
|
| 18 | -define('IMAP_NAMESPACE_SHARED' , 'shared'); |
|
| 19 | -define('IMAP_NAMESPACE_ALL' , 'all'); |
|
| 17 | +define('IMAP_NAMESPACE_OTHERS', 'others'); |
|
| 18 | +define('IMAP_NAMESPACE_SHARED', 'shared'); |
|
| 19 | +define('IMAP_NAMESPACE_ALL', 'all'); |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * This class holds all information about the imap connection. |
@@ -87,7 +87,7 @@ 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 | 92 | /** |
| 93 | 93 | * get list of namespaces |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | * @param string $_what - what to retrieve either QMAX, USED or ALL is supported |
| 104 | 104 | * @return mixed the quota for specified user (by what) or array with all available Quota Information, or false |
| 105 | 105 | */ |
| 106 | - function getQuotaByUser($_username, $_what='QMAX'); |
|
| 106 | + function getQuotaByUser($_username, $_what = 'QMAX'); |
|
| 107 | 107 | |
| 108 | 108 | /** |
| 109 | 109 | * returns information about a user |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | * @param int $_timeout =null timeout in secs, if none given fmail pref or default of 20 is used |
| 123 | 123 | * @throws Exception on error |
| 124 | 124 | */ |
| 125 | - function openConnection($_adminConnection=false, $_timeout=null); |
|
| 125 | + function openConnection($_adminConnection = false, $_timeout = null); |
|
| 126 | 126 | |
| 127 | 127 | /** |
| 128 | 128 | * set userdata |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @param string $_scriptName =null |
| 150 | 150 | * @return boolean |
| 151 | 151 | */ |
| 152 | - public function setVacationUser($_euser, array $_vacation, $_scriptName=null); |
|
| 152 | + public function setVacationUser($_euser, array $_vacation, $_scriptName = null); |
|
| 153 | 153 | |
| 154 | 154 | /** |
| 155 | 155 | * Get vacation message for given user |
@@ -159,5 +159,5 @@ discard block |
||
| 159 | 159 | * @throws Exception on connection error or authentication failure |
| 160 | 160 | * @return array |
| 161 | 161 | */ |
| 162 | - public function getVacationUser($_euser, $_scriptName=null); |
|
| 162 | + public function getVacationUser($_euser, $_scriptName = null); |
|
| 163 | 163 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | /** |
| 83 | 83 | * Constructor |
| 84 | 84 | * |
| 85 | - * @param array|Imap $params =array() |
|
| 85 | + * @param Imap $params =array() |
|
| 86 | 86 | */ |
| 87 | 87 | function __construct($params=array()) |
| 88 | 88 | { |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | * |
| 166 | 166 | * @param array $_emailNotification |
| 167 | 167 | * @param string $_scriptName |
| 168 | - * @return Script |
|
| 168 | + * @return boolean |
|
| 169 | 169 | */ |
| 170 | 170 | function setEmailNotification(array $_emailNotification, $_scriptName=null) |
| 171 | 171 | { |
@@ -37,28 +37,28 @@ discard block |
||
| 37 | 37 | var $icServer; |
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | - * @var string name of active script queried from Sieve server |
|
| 41 | - */ |
|
| 40 | + * @var string name of active script queried from Sieve server |
|
| 41 | + */ |
|
| 42 | 42 | var $scriptName; |
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | - * @var $rules containing the rules |
|
| 46 | - */ |
|
| 45 | + * @var $rules containing the rules |
|
| 46 | + */ |
|
| 47 | 47 | var $rules; |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | - * @var $vacation containing the vacation |
|
| 51 | - */ |
|
| 50 | + * @var $vacation containing the vacation |
|
| 51 | + */ |
|
| 52 | 52 | var $vacation; |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | - * @var $emailNotification containing the emailNotification |
|
| 56 | - */ |
|
| 55 | + * @var $emailNotification containing the emailNotification |
|
| 56 | + */ |
|
| 57 | 57 | var $emailNotification; |
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | - * @var object $error the last PEAR error object |
|
| 61 | - */ |
|
| 60 | + * @var object $error the last PEAR error object |
|
| 61 | + */ |
|
| 62 | 62 | var $error; |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -170,11 +170,11 @@ discard block |
||
| 170 | 170 | function setEmailNotification(array $_emailNotification, $_scriptName=null) |
| 171 | 171 | { |
| 172 | 172 | if ($_emailNotification['externalEmail'] == '' || !preg_match("/\@/",$_emailNotification['externalEmail'])) { |
| 173 | - $_emailNotification['status'] = 'off'; |
|
| 174 | - $_emailNotification['externalEmail'] = ''; |
|
| 175 | - } |
|
| 173 | + $_emailNotification['status'] = 'off'; |
|
| 174 | + $_emailNotification['externalEmail'] = ''; |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | - $script = $this->retrieveRules($_scriptName); |
|
| 177 | + $script = $this->retrieveRules($_scriptName); |
|
| 178 | 178 | $script->emailNotification = $_emailNotification; |
| 179 | 179 | $ret = $script->updateScript($this); |
| 180 | 180 | $this->error = $script->errstr; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * |
| 85 | 85 | * @param array|Imap $params =array() |
| 86 | 86 | */ |
| 87 | - function __construct($params=array()) |
|
| 87 | + function __construct($params = array()) |
|
| 88 | 88 | { |
| 89 | 89 | if (is_a($params, __NAMESPACE__.'\\Imap')) |
| 90 | 90 | { |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | } |
| 100 | 100 | parent::__construct($params); |
| 101 | 101 | |
| 102 | - $this->displayCharset = Translation::charset(); |
|
| 102 | + $this->displayCharset = Translation::charset(); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | function getRules() |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * @param string $_scriptName |
| 131 | 131 | * @param boolean $utf7imap_fileinto =false true: encode foldernames with utf7imap, default utf8 |
| 132 | 132 | */ |
| 133 | - function setRules(array $_rules, $_scriptName=null, $utf7imap_fileinto=false) |
|
| 133 | + function setRules(array $_rules, $_scriptName = null, $utf7imap_fileinto = false) |
|
| 134 | 134 | { |
| 135 | 135 | $script = $this->retrieveRules($_scriptName); |
| 136 | 136 | $script->debug = $this->debug; |
@@ -146,11 +146,11 @@ discard block |
||
| 146 | 146 | * @param array $_vacation |
| 147 | 147 | * @param string $_scriptName |
| 148 | 148 | */ |
| 149 | - function setVacation(array $_vacation, $_scriptName=null) |
|
| 149 | + function setVacation(array $_vacation, $_scriptName = null) |
|
| 150 | 150 | { |
| 151 | 151 | if ($this->debug) |
| 152 | 152 | { |
| 153 | - error_log(__METHOD__ . "($_scriptName," . print_r($_vacation, true) . ')'); |
|
| 153 | + error_log(__METHOD__."($_scriptName,".print_r($_vacation, true).')'); |
|
| 154 | 154 | } |
| 155 | 155 | $script = $this->retrieveRules($_scriptName); |
| 156 | 156 | $script->debug = $this->debug; |
@@ -167,9 +167,9 @@ discard block |
||
| 167 | 167 | * @param string $_scriptName |
| 168 | 168 | * @return Script |
| 169 | 169 | */ |
| 170 | - function setEmailNotification(array $_emailNotification, $_scriptName=null) |
|
| 170 | + function setEmailNotification(array $_emailNotification, $_scriptName = null) |
|
| 171 | 171 | { |
| 172 | - if ($_emailNotification['externalEmail'] == '' || !preg_match("/\@/",$_emailNotification['externalEmail'])) { |
|
| 172 | + if ($_emailNotification['externalEmail'] == '' || !preg_match("/\@/", $_emailNotification['externalEmail'])) { |
|
| 173 | 173 | $_emailNotification['status'] = 'off'; |
| 174 | 174 | $_emailNotification['externalEmail'] = ''; |
| 175 | 175 | } |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | * @param string $_scriptName |
| 188 | 188 | * @return Script |
| 189 | 189 | */ |
| 190 | - function retrieveRules($_scriptName=null) |
|
| 190 | + function retrieveRules($_scriptName = null) |
|
| 191 | 191 | { |
| 192 | 192 | if (!$_scriptName) |
| 193 | 193 | { |
@@ -197,8 +197,8 @@ discard block |
||
| 197 | 197 | try { |
| 198 | 198 | $this->scriptName = $this->getActive(); |
| 199 | 199 | } |
| 200 | - catch(Exception $e) { |
|
| 201 | - unset($e); // ignore NOTEXISTS exception |
|
| 200 | + catch (Exception $e) { |
|
| 201 | + unset($e); // ignore NOTEXISTS exception |
|
| 202 | 202 | } |
| 203 | 203 | if (empty($this->scriptName)) |
| 204 | 204 | { |
@@ -213,11 +213,11 @@ discard block |
||
| 213 | 213 | $script->retrieveRules($this); |
| 214 | 214 | } |
| 215 | 215 | catch (\Exception $e) { |
| 216 | - unset($e); // ignore not found script exception |
|
| 216 | + unset($e); // ignore not found script exception |
|
| 217 | 217 | } |
| 218 | - $this->rules =& $script->rules; |
|
| 219 | - $this->vacation =& $script->vacation; |
|
| 220 | - $this->emailNotification =& $script->emailNotification; // Added email notifications |
|
| 218 | + $this->rules = & $script->rules; |
|
| 219 | + $this->vacation = & $script->vacation; |
|
| 220 | + $this->emailNotification = & $script->emailNotification; // Added email notifications |
|
| 221 | 221 | |
| 222 | 222 | return $script; |
| 223 | 223 | } |
@@ -104,21 +104,30 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | function getRules() |
| 106 | 106 | { |
| 107 | - if (!isset($this->rules)) $this->retrieveRules(); |
|
| 107 | + if (!isset($this->rules)) |
|
| 108 | + { |
|
| 109 | + $this->retrieveRules(); |
|
| 110 | + } |
|
| 108 | 111 | |
| 109 | 112 | return $this->rules; |
| 110 | 113 | } |
| 111 | 114 | |
| 112 | 115 | function getVacation() |
| 113 | 116 | { |
| 114 | - if (!isset($this->rules)) $this->retrieveRules(); |
|
| 117 | + if (!isset($this->rules)) |
|
| 118 | + { |
|
| 119 | + $this->retrieveRules(); |
|
| 120 | + } |
|
| 115 | 121 | |
| 116 | 122 | return $this->vacation; |
| 117 | 123 | } |
| 118 | 124 | |
| 119 | 125 | function getEmailNotification() |
| 120 | 126 | { |
| 121 | - if (!isset($this->rules)) $this->retrieveRules(); |
|
| 127 | + if (!isset($this->rules)) |
|
| 128 | + { |
|
| 129 | + $this->retrieveRules(); |
|
| 130 | + } |
|
| 122 | 131 | |
| 123 | 132 | return $this->emailNotification; |
| 124 | 133 | } |
@@ -169,7 +178,8 @@ discard block |
||
| 169 | 178 | */ |
| 170 | 179 | function setEmailNotification(array $_emailNotification, $_scriptName=null) |
| 171 | 180 | { |
| 172 | - if ($_emailNotification['externalEmail'] == '' || !preg_match("/\@/",$_emailNotification['externalEmail'])) { |
|
| 181 | + if ($_emailNotification['externalEmail'] == '' || !preg_match("/\@/",$_emailNotification['externalEmail'])) |
|
| 182 | + { |
|
| 173 | 183 | $_emailNotification['status'] = 'off'; |
| 174 | 184 | $_emailNotification['externalEmail'] = ''; |
| 175 | 185 | } |
@@ -156,7 +156,7 @@ |
||
| 156 | 156 | /** |
| 157 | 157 | * Get the data of a given user |
| 158 | 158 | * |
| 159 | - * @param int|string $user numerical account-id, account-name or email address |
|
| 159 | + * @param integer $user numerical account-id, account-name or email address |
|
| 160 | 160 | * @param boolean $match_uid_at_domain =true true: uid@domain matches, false only an email or alias address matches |
| 161 | 161 | * @return array with values for keys 'mailLocalAddress', 'mailAlternateAddress' (array), 'mailForwardingAddress' (array), |
| 162 | 162 | * 'accountStatus' ("active"), 'quotaLimit' and 'deliveryMode' ("forwardOnly") |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @param string $defaultDomain =null |
| 81 | 81 | */ |
| 82 | - function __construct($defaultDomain=null) |
|
| 82 | + function __construct($defaultDomain = null) |
|
| 83 | 83 | { |
| 84 | 84 | $this->defaultDomain = $defaultDomain ? $defaultDomain : $GLOBALS['egw_info']['server']['mail_suffix']; |
| 85 | 85 | |
@@ -104,12 +104,10 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | function addAccount($_hookValues) |
| 106 | 106 | { |
| 107 | - $mailLocalAddress = $_hookValues['account_email'] ? $_hookValues['account_email'] : |
|
| 108 | - Api\Accounts::email($_hookValues['account_firstname'], |
|
| 109 | - $_hookValues['account_lastname'],$_hookValues['account_lid'],$this->defaultDomain); |
|
| 107 | + $mailLocalAddress = $_hookValues['account_email'] ? $_hookValues['account_email'] : Api\Accounts::email($_hookValues['account_firstname'], |
|
| 108 | + $_hookValues['account_lastname'], $_hookValues['account_lid'], $this->defaultDomain); |
|
| 110 | 109 | |
| 111 | - $account_id = !empty($_hookValues['account_id']) ? $_hookValues['account_id'] : |
|
| 112 | - $this->accounts->name2id($_hookValues['account_lid'], 'account_lid', 'u'); |
|
| 110 | + $account_id = !empty($_hookValues['account_id']) ? $_hookValues['account_id'] : $this->accounts->name2id($_hookValues['account_lid'], 'account_lid', 'u'); |
|
| 113 | 111 | |
| 114 | 112 | if ($this->accounts->exists($account_id) != 1) |
| 115 | 113 | { |
@@ -126,7 +124,7 @@ discard block |
||
| 126 | 124 | */ |
| 127 | 125 | function deleteAccount($_hookValues) |
| 128 | 126 | { |
| 129 | - unset($_hookValues); // not used, but required by function signature |
|
| 127 | + unset($_hookValues); // not used, but required by function signature |
|
| 130 | 128 | |
| 131 | 129 | return true; |
| 132 | 130 | } |
@@ -139,12 +137,12 @@ discard block |
||
| 139 | 137 | */ |
| 140 | 138 | function getAccountEmailAddress($_accountName) |
| 141 | 139 | { |
| 142 | - $emailAddresses = array(); |
|
| 140 | + $emailAddresses = array(); |
|
| 143 | 141 | |
| 144 | 142 | if (($account_id = $this->accounts->name2id($_accountName, 'account_lid', 'u'))) |
| 145 | 143 | { |
| 146 | - $realName = trim($GLOBALS['egw_info']['user']['account_firstname'] . (!empty($GLOBALS['egw_info']['user']['account_firstname']) ? ' ' : '') . $GLOBALS['egw_info']['user']['account_lastname']); |
|
| 147 | - $emailAddresses[] = array ( |
|
| 144 | + $realName = trim($GLOBALS['egw_info']['user']['account_firstname'].(!empty($GLOBALS['egw_info']['user']['account_firstname']) ? ' ' : '').$GLOBALS['egw_info']['user']['account_lastname']); |
|
| 145 | + $emailAddresses[] = array( |
|
| 148 | 146 | 'name' => $realName, |
| 149 | 147 | 'address' => $this->accounts->id2name($account_id, 'account_email'), |
| 150 | 148 | 'type' => 'default', |
@@ -161,9 +159,9 @@ discard block |
||
| 161 | 159 | * @return array with values for keys 'mailLocalAddress', 'mailAlternateAddress' (array), 'mailForwardingAddress' (array), |
| 162 | 160 | * 'accountStatus' ("active"), 'quotaLimit' and 'deliveryMode' ("forwardOnly") |
| 163 | 161 | */ |
| 164 | - function getUserData($user, $match_uid_at_domain=false) |
|
| 162 | + function getUserData($user, $match_uid_at_domain = false) |
|
| 165 | 163 | { |
| 166 | - unset($user, $match_uid_at_domain); // not used, but required by function signature |
|
| 164 | + unset($user, $match_uid_at_domain); // not used, but required by function signature |
|
| 167 | 165 | |
| 168 | 166 | $userData = array(); |
| 169 | 167 | |
@@ -201,9 +199,9 @@ discard block |
||
| 201 | 199 | * @return boolean true on success, false on error writing to ldap |
| 202 | 200 | */ |
| 203 | 201 | function setUserData($_uidnumber, array $_mailAlternateAddress, array $_mailForwardingAddress, $_deliveryMode, |
| 204 | - $_accountStatus, $_mailLocalAddress, $_quota, $_forwarding_only=false, $_setMailbox=null) |
|
| 202 | + $_accountStatus, $_mailLocalAddress, $_quota, $_forwarding_only = false, $_setMailbox = null) |
|
| 205 | 203 | { |
| 206 | - unset($_uidnumber, $_mailAlternateAddress, $_mailForwardingAddress, // not used, but require by function signature |
|
| 204 | + unset($_uidnumber, $_mailAlternateAddress, $_mailForwardingAddress, // not used, but require by function signature |
|
| 207 | 205 | $_deliveryMode, $_accountStatus, $_mailLocalAddress, $_quota, $_forwarding_only, $_setMailbox); |
| 208 | 206 | |
| 209 | 207 | return true; |
@@ -217,7 +215,7 @@ discard block |
||
| 217 | 215 | */ |
| 218 | 216 | function updateAccount($_hookValues) |
| 219 | 217 | { |
| 220 | - unset($_hookValues); // not used, but required by function signature |
|
| 218 | + unset($_hookValues); // not used, but required by function signature |
|
| 221 | 219 | |
| 222 | 220 | return true; |
| 223 | 221 | } |
@@ -233,15 +231,15 @@ discard block |
||
| 233 | 231 | * default use $this->loginType |
| 234 | 232 | * @return string |
| 235 | 233 | */ |
| 236 | - /*static*/ public function mailbox_addr($account,$domain=null,$mail_login_type=null) |
|
| 234 | + /*static*/ public function mailbox_addr($account, $domain = null, $mail_login_type = null) |
|
| 237 | 235 | { |
| 238 | 236 | if (is_null($domain)) $domain = $this->defaultDomain; |
| 239 | 237 | if (is_null($mail_login_type)) $mail_login_type = $this->loginType; |
| 240 | 238 | |
| 241 | - switch($mail_login_type) |
|
| 239 | + switch ($mail_login_type) |
|
| 242 | 240 | { |
| 243 | 241 | case 'email': |
| 244 | - $mbox = is_array($account) ? $account['account_email'] : $GLOBALS['egw']->accounts->id2name($account,'account_email'); |
|
| 242 | + $mbox = is_array($account) ? $account['account_email'] : $GLOBALS['egw']->accounts->id2name($account, 'account_email'); |
|
| 245 | 243 | break; |
| 246 | 244 | |
| 247 | 245 | case 'uidNumber': |
@@ -235,8 +235,14 @@ discard block |
||
| 235 | 235 | */ |
| 236 | 236 | /*static*/ public function mailbox_addr($account,$domain=null,$mail_login_type=null) |
| 237 | 237 | { |
| 238 | - if (is_null($domain)) $domain = $this->defaultDomain; |
|
| 239 | - if (is_null($mail_login_type)) $mail_login_type = $this->loginType; |
|
| 238 | + if (is_null($domain)) |
|
| 239 | + { |
|
| 240 | + $domain = $this->defaultDomain; |
|
| 241 | + } |
|
| 242 | + if (is_null($mail_login_type)) |
|
| 243 | + { |
|
| 244 | + $mail_login_type = $this->loginType; |
|
| 245 | + } |
|
| 240 | 246 | |
| 241 | 247 | switch($mail_login_type) |
| 242 | 248 | { |
@@ -245,7 +251,10 @@ discard block |
||
| 245 | 251 | break; |
| 246 | 252 | |
| 247 | 253 | case 'uidNumber': |
| 248 | - if (is_array($account)) $account = $account['account_id']; |
|
| 254 | + if (is_array($account)) |
|
| 255 | + { |
|
| 256 | + $account = $account['account_id']; |
|
| 257 | + } |
|
| 249 | 258 | $mbox = 'u'.$account.'@'.$domain; |
| 250 | 259 | break; |
| 251 | 260 | |