@@ -40,8 +40,7 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @var array |
| 42 | 42 | */ |
| 43 | - var $public_functions = array |
|
| 44 | - ( |
|
| 43 | + var $public_functions = array( |
|
| 45 | 44 | 'index' => True, |
| 46 | 45 | 'displayHeader' => True, |
| 47 | 46 | 'displayMessage' => True, |
@@ -92,17 +91,17 @@ discard block |
||
| 92 | 91 | * @var array |
| 93 | 92 | */ |
| 94 | 93 | var $searchTypes = array( |
| 95 | - 'quick' => 'quicksearch', // lang('quicksearch') |
|
| 96 | - 'quickwithcc'=> 'quicksearch (with cc)', // lang('quicksearch (with cc)') |
|
| 97 | - 'subject' => 'subject', // lang('subject') |
|
| 98 | - 'body' => 'message body', // lang('message body') |
|
| 99 | - 'from' => 'from', // lang('from') |
|
| 100 | - 'to' => 'to', // lang('to') |
|
| 101 | - 'cc' => 'cc', // lang('cc') |
|
| 102 | - 'text' => 'whole message', // lang('whole message') |
|
| 103 | - 'larger' => 'greater than', // lang('greater than') |
|
| 104 | - 'smaller' => 'less than', // lang('less than') |
|
| 105 | - 'bydate' => 'Selected date range (with quicksearch)',// lang('Selected date range (with quicksearch)') |
|
| 94 | + 'quick' => 'quicksearch', // lang('quicksearch') |
|
| 95 | + 'quickwithcc'=> 'quicksearch (with cc)', // lang('quicksearch (with cc)') |
|
| 96 | + 'subject' => 'subject', // lang('subject') |
|
| 97 | + 'body' => 'message body', // lang('message body') |
|
| 98 | + 'from' => 'from', // lang('from') |
|
| 99 | + 'to' => 'to', // lang('to') |
|
| 100 | + 'cc' => 'cc', // lang('cc') |
|
| 101 | + 'text' => 'whole message', // lang('whole message') |
|
| 102 | + 'larger' => 'greater than', // lang('greater than') |
|
| 103 | + 'smaller' => 'less than', // lang('less than') |
|
| 104 | + 'bydate' => 'Selected date range (with quicksearch)', // lang('Selected date range (with quicksearch)') |
|
| 106 | 105 | ); |
| 107 | 106 | |
| 108 | 107 | /** |
@@ -111,12 +110,12 @@ discard block |
||
| 111 | 110 | * @var array |
| 112 | 111 | */ |
| 113 | 112 | var $statusTypes = array( |
| 114 | - 'any' => 'any status',// lang('any status') |
|
| 115 | - 'flagged' => 'flagged', // lang('flagged') |
|
| 116 | - 'unseen' => 'unread', // lang('unread') |
|
| 117 | - 'answered' => 'replied', // lang('replied') |
|
| 118 | - 'seen' => 'read', // lang('read') |
|
| 119 | - 'deleted' => 'deleted', // lang('deleted') |
|
| 113 | + 'any' => 'any status', // lang('any status') |
|
| 114 | + 'flagged' => 'flagged', // lang('flagged') |
|
| 115 | + 'unseen' => 'unread', // lang('unread') |
|
| 116 | + 'answered' => 'replied', // lang('replied') |
|
| 117 | + 'seen' => 'read', // lang('read') |
|
| 118 | + 'deleted' => 'deleted', // lang('deleted') |
|
| 120 | 119 | ); |
| 121 | 120 | |
| 122 | 121 | /** |
@@ -124,12 +123,12 @@ discard block |
||
| 124 | 123 | * |
| 125 | 124 | * @param boolean $run_constructor =true false: no not run constructor and therefore do NOT connect to imap server |
| 126 | 125 | */ |
| 127 | - function __construct($run_constructor=true) |
|
| 126 | + function __construct($run_constructor = true) |
|
| 128 | 127 | { |
| 129 | 128 | $this->mail_tree = new mail_tree($this); |
| 130 | 129 | if (!$run_constructor) return; |
| 131 | 130 | |
| 132 | - if (Mail::$debugTimes) $starttime = microtime (true); |
|
| 131 | + if (Mail::$debugTimes) $starttime = microtime(true); |
|
| 133 | 132 | // no autohide of the sidebox, as we use it for folderlist now. |
| 134 | 133 | unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']); |
| 135 | 134 | |
@@ -145,13 +144,13 @@ discard block |
||
| 145 | 144 | } |
| 146 | 145 | |
| 147 | 146 | try { |
| 148 | - $this->mail_bo = Mail::getInstance(true,self::$icServerID, true, false, true); |
|
| 147 | + $this->mail_bo = Mail::getInstance(true, self::$icServerID, true, false, true); |
|
| 149 | 148 | if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace()); |
| 150 | 149 | //error_log(__METHOD__.__LINE__.array2string($this->mail_bo->icServer)); |
| 151 | 150 | |
| 152 | 151 | // RegEx to minimize extra openConnection |
| 153 | 152 | $needle = '/^(?!mail)/'; |
| 154 | - if (!preg_match($needle,$_GET['menuaction']) && !Api\Json\Request::isJSONRequest()) |
|
| 153 | + if (!preg_match($needle, $_GET['menuaction']) && !Api\Json\Request::isJSONRequest()) |
|
| 155 | 154 | { |
| 156 | 155 | //error_log(__METHOD__.__LINE__.' Fetched IC Server openConnection:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace()); |
| 157 | 156 | //openConnection gathers SpecialUseFolderInformation and Delimiter Info |
@@ -161,9 +160,9 @@ discard block |
||
| 161 | 160 | catch (Exception $e) |
| 162 | 161 | { |
| 163 | 162 | // redirect to mail wizard to handle it (redirect works for ajax too) |
| 164 | - self::callWizard($e->getMessage(),true,'error'); |
|
| 163 | + self::callWizard($e->getMessage(), true, 'error'); |
|
| 165 | 164 | } |
| 166 | - if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 165 | + if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, '', __METHOD__.__LINE__); |
|
| 167 | 166 | } |
| 168 | 167 | |
| 169 | 168 | /** |
@@ -173,10 +172,10 @@ discard block |
||
| 173 | 172 | * @param boolean $exit If true, will call exit() after opening the wizardpopup |
| 174 | 173 | * @param string $msg_type = 'success' message type |
| 175 | 174 | */ |
| 176 | - static function callWizard($message, $exit=true, $msg_type='success') |
|
| 175 | + static function callWizard($message, $exit = true, $msg_type = 'success') |
|
| 177 | 176 | { |
| 178 | 177 | //error_log(__METHOD__."('$message', $exit) ".function_backtrace()); |
| 179 | - $linkData=(self::$icServerID ? array( |
|
| 178 | + $linkData = (self::$icServerID ? array( |
|
| 180 | 179 | 'menuaction' => 'mail.mail_wizard.edit', |
| 181 | 180 | 'acc_id' => self::$icServerID, |
| 182 | 181 | ) : array( |
@@ -190,11 +189,11 @@ discard block |
||
| 190 | 189 | { |
| 191 | 190 | $response = Api\Json\Response::get(); |
| 192 | 191 | $windowName = "editMailAccount".self::$icServerID; |
| 193 | - $response->call("egw.open_link", Egw::link('/index.php', $linkData), $windowName, "600x480",null,true); |
|
| 192 | + $response->call("egw.open_link", Egw::link('/index.php', $linkData), $windowName, "600x480", null, true); |
|
| 194 | 193 | Framework::message($message, 'error'); |
| 195 | 194 | if ($_GET['menuaction'] == 'mail.mail_ui.index') |
| 196 | 195 | { |
| 197 | - $response->call('framework.setSidebox','mail',array(),'md5'); |
|
| 196 | + $response->call('framework.setSidebox', 'mail', array(), 'md5'); |
|
| 198 | 197 | } |
| 199 | 198 | if ($exit) |
| 200 | 199 | { |
@@ -203,8 +202,8 @@ discard block |
||
| 203 | 202 | } |
| 204 | 203 | else // regular GET request eg. in idots template |
| 205 | 204 | { |
| 206 | - Framework::popup(Framework::link('/index.php',$linkData)); |
|
| 207 | - $GLOBALS['egw']->framework->render($message,'',true); |
|
| 205 | + Framework::popup(Framework::link('/index.php', $linkData)); |
|
| 206 | + $GLOBALS['egw']->framework->render($message, '', true); |
|
| 208 | 207 | if ($exit) |
| 209 | 208 | { |
| 210 | 209 | exit(); |
@@ -220,9 +219,9 @@ discard block |
||
| 220 | 219 | * |
| 221 | 220 | * @throws Api\Exception |
| 222 | 221 | */ |
| 223 | - function changeProfile($_icServerID,$unsetCache=false) |
|
| 222 | + function changeProfile($_icServerID, $unsetCache = false) |
|
| 224 | 223 | { |
| 225 | - if (Mail::$debugTimes) $starttime = microtime (true); |
|
| 224 | + if (Mail::$debugTimes) $starttime = microtime(true); |
|
| 226 | 225 | if (self::$icServerID != $_icServerID) |
| 227 | 226 | { |
| 228 | 227 | self::$icServerID = $_icServerID; |
@@ -230,35 +229,35 @@ discard block |
||
| 230 | 229 | if (Mail::$debug) error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID); |
| 231 | 230 | |
| 232 | 231 | if ($unsetCache) Mail::unsetCachedObjects(self::$icServerID); |
| 233 | - $this->mail_bo = Mail::getInstance(false,self::$icServerID,true, false, true); |
|
| 232 | + $this->mail_bo = Mail::getInstance(false, self::$icServerID, true, false, true); |
|
| 234 | 233 | if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace()); |
| 235 | 234 | // no icServer Object: something failed big time |
| 236 | - if (!isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId<>$_icServerID) |
|
| 235 | + if (!isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId <> $_icServerID) |
|
| 237 | 236 | { |
| 238 | 237 | self::$icServerID = $_icServerID; |
| 239 | 238 | throw new Api\Exception('Profile change failed!'); |
| 240 | 239 | } |
| 241 | 240 | |
| 242 | 241 | // save session varchar |
| 243 | - $oldicServerID =& Api\Cache::getSession('mail','activeProfileID'); |
|
| 242 | + $oldicServerID = & Api\Cache::getSession('mail', 'activeProfileID'); |
|
| 244 | 243 | if ($oldicServerID <> self::$icServerID) $this->mail_bo->openConnection(self::$icServerID); |
| 245 | 244 | if (true) $oldicServerID = self::$icServerID; |
| 246 | - if (!Mail::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true )) |
|
| 245 | + if (!Mail::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true)) |
|
| 247 | 246 | { |
| 248 | 247 | throw new Api\Exception(__METHOD__." failed to change Profile to $_icServerID"); |
| 249 | 248 | } |
| 250 | 249 | |
| 251 | - if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 250 | + if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, '', __METHOD__.__LINE__); |
|
| 252 | 251 | } |
| 253 | 252 | |
| 254 | 253 | /** |
| 255 | 254 | * Ajax function to request next branch of a tree branch |
| 256 | 255 | */ |
| 257 | - static function ajax_tree_autoloading ($_id = null) |
|
| 256 | + static function ajax_tree_autoloading($_id = null) |
|
| 258 | 257 | { |
| 259 | 258 | $mail_ui = new mail_ui(); |
| 260 | 259 | $id = $_id ? $_id : $_GET['id']; |
| 261 | - Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id,'',1,false)); |
|
| 260 | + Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id, '', 1, false)); |
|
| 262 | 261 | } |
| 263 | 262 | |
| 264 | 263 | /** |
@@ -267,11 +266,11 @@ discard block |
||
| 267 | 266 | * @param array $content |
| 268 | 267 | * @param type $msg |
| 269 | 268 | */ |
| 270 | - function subscription(array $content=null ,$msg=null) |
|
| 269 | + function subscription(array $content = null, $msg = null) |
|
| 271 | 270 | { |
| 272 | 271 | $stmpl = new Etemplate('mail.subscribe'); |
| 273 | 272 | |
| 274 | - if(is_array($content)) |
|
| 273 | + if (is_array($content)) |
|
| 275 | 274 | { |
| 276 | 275 | $profileId = $content['profileId']; |
| 277 | 276 | } |
@@ -281,14 +280,14 @@ discard block |
||
| 281 | 280 | } |
| 282 | 281 | // Initial tree's options, the rest would be loaded dynamicaly by autoloading, |
| 283 | 282 | // triggered from client-side. Also, we keep this here as |
| 284 | - $sel_options['foldertree'] = $this->mail_tree->getTree(null,$profileId,1,true,false,true); |
|
| 283 | + $sel_options['foldertree'] = $this->mail_tree->getTree(null, $profileId, 1, true, false, true); |
|
| 285 | 284 | |
| 286 | 285 | //Get all subscribed folders |
| 287 | 286 | // as getting all subscribed folders is very fast operation |
| 288 | 287 | // we can use it to get a comparison base for folders which |
| 289 | 288 | // got subscribed or unsubscribed by the user |
| 290 | 289 | try { |
| 291 | - $subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('',0,true); |
|
| 290 | + $subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('', 0, true); |
|
| 292 | 291 | } catch (Exception $ex) { |
| 293 | 292 | Framework::message($ex->getMessage()); |
| 294 | 293 | } |
@@ -299,7 +298,7 @@ discard block |
||
| 299 | 298 | |
| 300 | 299 | foreach ($subscribed as $folder) |
| 301 | 300 | { |
| 302 | - $folderName = $profileId . self::$delimiter . $folder['MAILBOX']; |
|
| 301 | + $folderName = $profileId.self::$delimiter.$folder['MAILBOX']; |
|
| 303 | 302 | array_push($content['foldertree'], $folderName); |
| 304 | 303 | } |
| 305 | 304 | } |
@@ -313,9 +312,9 @@ discard block |
||
| 313 | 312 | { |
| 314 | 313 | // do not let user (un)subscribe namespace roots eg. "other", "user" or "INBOX", same for tree-root/account itself |
| 315 | 314 | $namespace_roots = array($profileId); |
| 316 | - foreach($this->mail_bo->_getNameSpaces() as $namespace) |
|
| 315 | + foreach ($this->mail_bo->_getNameSpaces() as $namespace) |
|
| 317 | 316 | { |
| 318 | - $namespace_roots[] = $profileId . self::$delimiter . str_replace($namespace['delimiter'], '', $namespace['prefix']); |
|
| 317 | + $namespace_roots[] = $profileId.self::$delimiter.str_replace($namespace['delimiter'], '', $namespace['prefix']); |
|
| 319 | 318 | } |
| 320 | 319 | $to_unsubscribe = $to_subscribe = array(); |
| 321 | 320 | foreach ($content['foldertree'] as $path => $value) |
@@ -323,7 +322,7 @@ discard block |
||
| 323 | 322 | list(,$node) = explode($profileId.self::$delimiter, $path); |
| 324 | 323 | if ($node) |
| 325 | 324 | { |
| 326 | - if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe []= $node; |
|
| 325 | + if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe [] = $node; |
|
| 327 | 326 | if (is_array($subscribed) && !$subscribed[$node] && $value['value']) $to_subscribe [] = $node; |
| 328 | 327 | if ($value['value']) $cont[] = $path; |
| 329 | 328 | } |
@@ -333,7 +332,7 @@ discard block |
||
| 333 | 332 | // set foldertree options to basic node in order to avoid initial autoloading |
| 334 | 333 | // from client side, as no options would trigger that. |
| 335 | 334 | $sel_options['foldertree'] = array('id' => '0', 'item'=> array()); |
| 336 | - foreach(array_merge($to_subscribe, $to_unsubscribe) as $mailbox) |
|
| 335 | + foreach (array_merge($to_subscribe, $to_unsubscribe) as $mailbox) |
|
| 337 | 336 | { |
| 338 | 337 | if (in_array($profileId.self::$delimiter.$mailbox, $namespace_roots, true)) |
| 339 | 338 | { |
@@ -369,18 +368,18 @@ discard block |
||
| 369 | 368 | } |
| 370 | 369 | } |
| 371 | 370 | // update foldertree in main window |
| 372 | - $parentFolder='INBOX'; |
|
| 371 | + $parentFolder = 'INBOX'; |
|
| 373 | 372 | $refreshData = array( |
| 374 | 373 | $profileId => lang($parentFolder), |
| 375 | 374 | ); |
| 376 | 375 | $response = Api\Json\Response::get(); |
| 377 | - foreach($refreshData as $folder => &$name) |
|
| 376 | + foreach ($refreshData as $folder => &$name) |
|
| 378 | 377 | { |
| 379 | - $name = $this->mail_tree->getTree($folder, $profileId,1,true,true,true); |
|
| 378 | + $name = $this->mail_tree->getTree($folder, $profileId, 1, true, true, true); |
|
| 380 | 379 | } |
| 381 | 380 | // give success/error message to opener and popup itself |
| 382 | 381 | //$response->call('opener.app.mail.subscription_refresh',$refreshData); |
| 383 | - $response->call('opener.app.mail.mail_reloadNode',$refreshData); |
|
| 382 | + $response->call('opener.app.mail.mail_reloadNode', $refreshData); |
|
| 384 | 383 | |
| 385 | 384 | Framework::refresh_opener($msg, 'mail', null, null, null, null, null, $msg_type); |
| 386 | 385 | if ($button == 'apply') |
@@ -400,7 +399,7 @@ discard block |
||
| 400 | 399 | |
| 401 | 400 | $readonlys = array(); |
| 402 | 401 | |
| 403 | - $stmpl->exec('mail.mail_ui.subscription', $content,$sel_options,$readonlys,$preserv,2); |
|
| 402 | + $stmpl->exec('mail.mail_ui.subscription', $content, $sel_options, $readonlys, $preserv, 2); |
|
| 404 | 403 | } |
| 405 | 404 | |
| 406 | 405 | /** |
@@ -409,12 +408,12 @@ discard block |
||
| 409 | 408 | * @param array $content |
| 410 | 409 | * @param string $msg |
| 411 | 410 | */ |
| 412 | - function index(array $content=null,$msg=null) |
|
| 411 | + function index(array $content = null, $msg = null) |
|
| 413 | 412 | { |
| 414 | 413 | //error_log(__METHOD__.__LINE__.array2string($content)); |
| 415 | - try { |
|
| 414 | + try { |
|
| 416 | 415 | //error_log(__METHOD__.__LINE__.function_backtrace()); |
| 417 | - if (Mail::$debugTimes) $starttime = microtime (true); |
|
| 416 | + if (Mail::$debugTimes) $starttime = microtime(true); |
|
| 418 | 417 | $this->mail_bo->restoreSessionData(); |
| 419 | 418 | $sessionFolder = $this->mail_bo->sessionData['mailbox']; |
| 420 | 419 | if ($this->mail_bo->folderExists($sessionFolder)) |
@@ -435,20 +434,20 @@ discard block |
||
| 435 | 434 | { |
| 436 | 435 | // These only set on first load |
| 437 | 436 | $content[self::$nm_index] = array( |
| 438 | - 'filter' => 'any', // filter is used to choose the mailbox |
|
| 439 | - 'lettersearch' => false, // I show a lettersearch |
|
| 440 | - 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
| 441 | - 'start' => 0, // IO position in list |
|
| 442 | - 'order' => 'date', // IO name of the column to sort after (optional for the sortheaders) |
|
| 443 | - 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 437 | + 'filter' => 'any', // filter is used to choose the mailbox |
|
| 438 | + 'lettersearch' => false, // I show a lettersearch |
|
| 439 | + 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
| 440 | + 'start' => 0, // IO position in list |
|
| 441 | + 'order' => 'date', // IO name of the column to sort after (optional for the sortheaders) |
|
| 442 | + 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 444 | 443 | ); |
| 445 | 444 | } |
| 446 | 445 | if (Api\Header\UserAgent::mobile()) $content[self::$nm_index]['header_row'] = 'mail.index.header_right'; |
| 447 | 446 | } |
| 448 | 447 | |
| 449 | 448 | // These must always be set, even if $content is an array |
| 450 | - $content[self::$nm_index]['cat_is_select'] = true; // Category select is just a normal selectbox |
|
| 451 | - $content[self::$nm_index]['no_filter2'] = false; // Disable second filter |
|
| 449 | + $content[self::$nm_index]['cat_is_select'] = true; // Category select is just a normal selectbox |
|
| 450 | + $content[self::$nm_index]['no_filter2'] = false; // Disable second filter |
|
| 452 | 451 | try |
| 453 | 452 | { |
| 454 | 453 | $content[self::$nm_index]['actions'] = self::get_actions(); |
@@ -456,15 +455,15 @@ discard block |
||
| 456 | 455 | catch (Exception $e) |
| 457 | 456 | { |
| 458 | 457 | // do not exit here. mail-tree should be build. if we exit here, we never get there |
| 459 | - self::callWizard($e->getMessage().($e->details?', '.$e->details:''),false, 'error'); |
|
| 458 | + self::callWizard($e->getMessage().($e->details ? ', '.$e->details : ''), false, 'error'); |
|
| 460 | 459 | unset($e); |
| 461 | 460 | //return false; |
| 462 | 461 | } |
| 463 | - $content[self::$nm_index]['row_id'] = 'row_id'; // is a concatenation of trim($GLOBALS['egw_info']['user']['account_id']):profileID:base64_encode(FOLDERNAME):uid |
|
| 462 | + $content[self::$nm_index]['row_id'] = 'row_id'; // is a concatenation of trim($GLOBALS['egw_info']['user']['account_id']):profileID:base64_encode(FOLDERNAME):uid |
|
| 464 | 463 | $content[self::$nm_index]['placeholder_actions'] = array('composeasnew'); |
| 465 | 464 | $content[self::$nm_index]['get_rows'] = 'mail_ui::get_rows'; |
| 466 | - $content[self::$nm_index]['num_rows'] = 0; // Do not send any rows with initial request |
|
| 467 | - $content[self::$nm_index]['default_cols'] = 'status,attachments,subject,address,date,size'; // I columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns |
|
| 465 | + $content[self::$nm_index]['num_rows'] = 0; // Do not send any rows with initial request |
|
| 466 | + $content[self::$nm_index]['default_cols'] = 'status,attachments,subject,address,date,size'; // I columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns |
|
| 468 | 467 | $content[self::$nm_index]['csv_fields'] = false; |
| 469 | 468 | if ($msg) |
| 470 | 469 | { |
@@ -476,11 +475,11 @@ discard block |
||
| 476 | 475 | unset($content['msg']); |
| 477 | 476 | } |
| 478 | 477 | // call getQuotaRoot asynchronously in getRows by initiating a client Server roundtrip |
| 479 | - $quota = false;//$this->mail_bo->getQuotaRoot(); |
|
| 480 | - if($quota !== false && $quota['limit'] != 'NOT SET') { |
|
| 478 | + $quota = false; //$this->mail_bo->getQuotaRoot(); |
|
| 479 | + if ($quota !== false && $quota['limit'] != 'NOT SET') { |
|
| 481 | 480 | $quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']); |
| 482 | 481 | $content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text']; |
| 483 | - $content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent']; |
|
| 482 | + $content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent']; |
|
| 484 | 483 | $content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class']; |
| 485 | 484 | $content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = ""; |
| 486 | 485 | } else { |
@@ -489,43 +488,43 @@ discard block |
||
| 489 | 488 | $content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone"; |
| 490 | 489 | } |
| 491 | 490 | // call gatherVacation asynchronously in getRows by initiating a client Server roundtrip |
| 492 | - $vacation = false;//$this->gatherVacation(); |
|
| 491 | + $vacation = false; //$this->gatherVacation(); |
|
| 493 | 492 | //error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation)); |
| 494 | - if($vacation) { |
|
| 495 | - if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date' && $vacation['end_date'] > time())) |
|
| 493 | + if ($vacation) { |
|
| 494 | + if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status'] == 'by_date' && $vacation['end_date'] > time())) |
|
| 496 | 495 | { |
| 497 | 496 | $dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']/*.' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat']!='24'?'h:i a':'H:i')*/; |
| 498 | 497 | $content[self::$nm_index]['vacationnotice'] = $sel_options[self::$nm_index]['vacationnotice'] = lang('Vacation notice is active'); |
| 499 | - $content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = ($vacation['status']=='by_date'? Api\DateTime::server2user($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.Api\DateTime::server2user($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):''); |
|
| 498 | + $content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = ($vacation['status'] == 'by_date' ? Api\DateTime::server2user($vacation['start_date'], $dtfrmt, true).($vacation['end_date'] > $vacation['start_date'] ? '->'.Api\DateTime::server2user($vacation['end_date'] + 24 * 3600 - 1, $dtfrmt, true) : '') : ''); |
|
| 500 | 499 | } |
| 501 | 500 | } |
| 502 | - if ($vacation==false) |
|
| 501 | + if ($vacation == false) |
|
| 503 | 502 | { |
| 504 | 503 | $content[self::$nm_index]['vacationnotice'] = $sel_options[self::$nm_index]['vacationnotice'] = ''; |
| 505 | 504 | $content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = ''; |
| 506 | 505 | } |
| 507 | 506 | //$zstarttime = microtime (true); |
| 508 | - $sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'],!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 507 | + $sel_options[self::$nm_index]['foldertree'] = $this->mail_tree->getInitialIndexTree(null, $this->mail_bo->profileID, null, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'], !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 509 | 508 | //$zendtime = microtime(true) - $zstarttime; |
| 510 | 509 | //error_log(__METHOD__.__LINE__. " time used: ".$zendtime); |
| 511 | - $content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.(!empty($this->mail_bo->sessionData['mailbox'])?$this->mail_bo->sessionData['mailbox']:'INBOX'); |
|
| 510 | + $content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.(!empty($this->mail_bo->sessionData['mailbox']) ? $this->mail_bo->sessionData['mailbox'] : 'INBOX'); |
|
| 512 | 511 | // since we are connected,(and selected the folder) we check for capabilities SUPPORTS_KEYWORDS to eventually add the keyword filters |
| 513 | - if ( $this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS')) |
|
| 512 | + if ($this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS')) |
|
| 514 | 513 | { |
| 515 | - $this->statusTypes = array_merge($this->statusTypes,array( |
|
| 516 | - 'keyword1' => 'important',//lang('important'), |
|
| 517 | - 'keyword2' => 'job', //lang('job'), |
|
| 518 | - 'keyword3' => 'personal',//lang('personal'), |
|
| 519 | - 'keyword4' => 'to do', //lang('to do'), |
|
| 520 | - 'keyword5' => 'later', //lang('later'), |
|
| 514 | + $this->statusTypes = array_merge($this->statusTypes, array( |
|
| 515 | + 'keyword1' => 'important', //lang('important'), |
|
| 516 | + 'keyword2' => 'job', //lang('job'), |
|
| 517 | + 'keyword3' => 'personal', //lang('personal'), |
|
| 518 | + 'keyword4' => 'to do', //lang('to do'), |
|
| 519 | + 'keyword5' => 'later', //lang('later'), |
|
| 521 | 520 | )); |
| 522 | 521 | } |
| 523 | 522 | else |
| 524 | 523 | { |
| 525 | - $keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5'); |
|
| 526 | - foreach($keywords as &$k) |
|
| 524 | + $keywords = array('keyword1', 'keyword2', 'keyword3', 'keyword4', 'keyword5'); |
|
| 525 | + foreach ($keywords as &$k) |
|
| 527 | 526 | { |
| 528 | - if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]); |
|
| 527 | + if (array_key_exists($k, $this->statusTypes)) unset($this->statusTypes[$k]); |
|
| 529 | 528 | } |
| 530 | 529 | } |
| 531 | 530 | |
@@ -536,8 +535,8 @@ discard block |
||
| 536 | 535 | |
| 537 | 536 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
| 538 | 537 | { |
| 539 | - Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
|
| 540 | - if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 538 | + Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 539 | + if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true; |
|
| 541 | 540 | } |
| 542 | 541 | if (!Mail::$supportsORinQuery[$this->mail_bo->profileID]) |
| 543 | 542 | { |
@@ -549,7 +548,7 @@ discard block |
||
| 549 | 548 | //error_log(__METHOD__.__LINE__.array2string($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType'])); |
| 550 | 549 | $content[self::$nm_index]['cat_id'] = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']; |
| 551 | 550 | $sel_options['filter'] = $this->statusTypes; |
| 552 | - $sel_options['filter2'] = array(''=>lang('No details'),1=>lang('Details')); |
|
| 551 | + $sel_options['filter2'] = array(''=>lang('No details'), 1=>lang('Details')); |
|
| 553 | 552 | $content[self::$nm_index]['filter2'] = $GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']; |
| 554 | 553 | |
| 555 | 554 | $etpl = new Etemplate('mail.index'); |
@@ -557,7 +556,7 @@ discard block |
||
| 557 | 556 | $content[self::$nm_index]['cat_id_onchange'] = "app.mail.mail_searchtype_change()"; |
| 558 | 557 | // Start at 2 so auto-added copy+paste actions show up as second group |
| 559 | 558 | // Needed because there's no 'select all' action to push things down |
| 560 | - $group=1; |
|
| 559 | + $group = 1; |
|
| 561 | 560 | // Set tree actions |
| 562 | 561 | $tree_actions = array( |
| 563 | 562 | 'drop_move_mail' => array( |
@@ -638,12 +637,12 @@ discard block |
||
| 638 | 637 | 'onExecute' => 'javaScript:app.mail.edit_sieve', |
| 639 | 638 | |
| 640 | 639 | 'enabled' => 'javaScript:app.mail.sieve_enabled', |
| 641 | - 'icon' => 'mail/filter', // funnel |
|
| 640 | + 'icon' => 'mail/filter', // funnel |
|
| 642 | 641 | 'hideOnMobile' => true |
| 643 | 642 | ), |
| 644 | 643 | 'vacation' => array( |
| 645 | 644 | 'caption' => 'Vacation notice', |
| 646 | - 'icon' => 'mail/navbar', // mail as in admin |
|
| 645 | + 'icon' => 'mail/navbar', // mail as in admin |
|
| 647 | 646 | 'onExecute' => 'javaScript:app.mail.edit_vacation', |
| 648 | 647 | 'enabled' => 'javaScript:app.mail.sieve_enabled', |
| 649 | 648 | ), |
@@ -684,8 +683,8 @@ discard block |
||
| 684 | 683 | unset($tree_actions['subscribe']); |
| 685 | 684 | unset($tree_actions['unsubscribe']); |
| 686 | 685 | } |
| 687 | - ++$group; // put delete in own group |
|
| 688 | - switch($GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions']) |
|
| 686 | + ++$group; // put delete in own group |
|
| 687 | + switch ($GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions']) |
|
| 689 | 688 | { |
| 690 | 689 | case 'move_to_trash': |
| 691 | 690 | $tree_actions['empty_trash'] = array( |
@@ -717,8 +716,8 @@ discard block |
||
| 717 | 716 | 'group' => $group, |
| 718 | 717 | ); |
| 719 | 718 | } |
| 720 | - $tree_actions['sieve']['group'] = $tree_actions['vacation']['group'] = ++$group; // new group for filter |
|
| 721 | - $tree_actions['edit_account']['group'] = $tree_actions['edit_acl']['group'] = ++$group; |
|
| 719 | + $tree_actions['sieve']['group'] = $tree_actions['vacation']['group'] = ++$group; // new group for filter |
|
| 720 | + $tree_actions['edit_account']['group'] = $tree_actions['edit_acl']['group'] = ++$group; |
|
| 722 | 721 | |
| 723 | 722 | |
| 724 | 723 | // enforce global (group-specific) ACL |
@@ -744,7 +743,7 @@ discard block |
||
| 744 | 743 | // to existing folders, it should only affect add/rename/move/delete |
| 745 | 744 | } |
| 746 | 745 | |
| 747 | - $etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $tree_actions); |
|
| 746 | + $etpl->setElementAttribute(self::$nm_index.'[foldertree]', 'actions', $tree_actions); |
|
| 748 | 747 | |
| 749 | 748 | // sending preview toolbar actions |
| 750 | 749 | if ($content['mailSplitter']) $etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions()); |
@@ -755,22 +754,22 @@ discard block |
||
| 755 | 754 | //we use the category "filter" option as specifier where we want to search (quick, subject, from, to, etc. ....) |
| 756 | 755 | if (empty($content[self::$nm_index]['cat_id']) || empty($content[self::$nm_index]['search'])) |
| 757 | 756 | { |
| 758 | - $content[self::$nm_index]['cat_id']=($content[self::$nm_index]['cat_id']?(!Mail::$supportsORinQuery[$this->mail_bo->profileID]&&($content[self::$nm_index]['cat_id']=='quick'||$content[self::$nm_index]['cat_id']=='quickwithcc')?'subject':$content[self::$nm_index]['cat_id']):(Mail::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject')); |
|
| 757 | + $content[self::$nm_index]['cat_id'] = ($content[self::$nm_index]['cat_id'] ? (!Mail::$supportsORinQuery[$this->mail_bo->profileID] && ($content[self::$nm_index]['cat_id'] == 'quick' || $content[self::$nm_index]['cat_id'] == 'quickwithcc') ? 'subject' : $content[self::$nm_index]['cat_id']) : (Mail::$supportsORinQuery[$this->mail_bo->profileID] ? 'quick' : 'subject')); |
|
| 759 | 758 | } |
| 760 | 759 | $readonlys = $preserv = array(); |
| 761 | - if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 760 | + if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, '', __METHOD__.__LINE__); |
|
| 762 | 761 | } |
| 763 | 762 | catch (Exception $e) |
| 764 | 763 | { |
| 765 | 764 | // do not exit here. mail-tree should be build. if we exit here, we never get there |
| 766 | - error_log(__METHOD__.__LINE__.$e->getMessage().($e->details?', '.$e->details:'')); |
|
| 767 | - self::callWizard(__METHOD__.$e->getMessage().$e->getMessage().($e->details?', '.$e->details:''),false, 'error'); |
|
| 765 | + error_log(__METHOD__.__LINE__.$e->getMessage().($e->details ? ', '.$e->details : '')); |
|
| 766 | + self::callWizard(__METHOD__.$e->getMessage().$e->getMessage().($e->details ? ', '.$e->details : ''), false, 'error'); |
|
| 768 | 767 | //return false; |
| 769 | 768 | } |
| 770 | 769 | // Check preview pane is enabled, then show spliter |
| 771 | 770 | if ($this->mail_bo->mailPreferences['previewPane']) $etpl->setElementAttribute('mail.index.spliter', 'template', 'mail.index.nospliter'); |
| 772 | 771 | |
| 773 | - return $etpl->exec('mail.mail_ui.index',$content,$sel_options,$readonlys,$preserv); |
|
| 772 | + return $etpl->exec('mail.mail_ui.index', $content, $sel_options, $readonlys, $preserv); |
|
| 774 | 773 | } |
| 775 | 774 | |
| 776 | 775 | /** |
@@ -780,19 +779,19 @@ discard block |
||
| 780 | 779 | * @param {string} $_folderName name of mailbox needs to be subcribe or unsubscribed |
| 781 | 780 | * @param {boolean} $_status set true for subscribe and false to unsubscribe |
| 782 | 781 | */ |
| 783 | - public function ajax_foldersubscription($_acc_id,$_folderName, $_status) |
|
| 782 | + public function ajax_foldersubscription($_acc_id, $_folderName, $_status) |
|
| 784 | 783 | { |
| 785 | 784 | //Change the Mail object to related profileId |
| 786 | 785 | $this->changeProfile($_acc_id); |
| 787 | 786 | |
| 788 | - if($this->mail_bo->icServer->subscribeMailbox($_folderName, $_status)) |
|
| 787 | + if ($this->mail_bo->icServer->subscribeMailbox($_folderName, $_status)) |
|
| 789 | 788 | { |
| 790 | 789 | $this->mail_bo->resetFolderObjectCache($_acc_id); |
| 791 | - $this->ajax_reloadNode($_acc_id,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 790 | + $this->ajax_reloadNode($_acc_id, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 792 | 791 | } |
| 793 | 792 | else |
| 794 | 793 | { |
| 795 | - error_log(__METHOD__.__LINE__."()". lang('Folder %1 %2 failed!',$_folderName,$_status?'subscribed':'unsubscribed')); |
|
| 794 | + error_log(__METHOD__.__LINE__."()".lang('Folder %1 %2 failed!', $_folderName, $_status ? 'subscribed' : 'unsubscribed')); |
|
| 796 | 795 | } |
| 797 | 796 | } |
| 798 | 797 | |
@@ -804,25 +803,25 @@ discard block |
||
| 804 | 803 | * @param string $_nodeID if of node whos children are requested |
| 805 | 804 | * @param boolean $_subscribedOnly flag to tell wether to fetch all or only subscribed (default) |
| 806 | 805 | */ |
| 807 | - public function ajax_foldertree($_nodeID = null,$_subscribedOnly=null) |
|
| 806 | + public function ajax_foldertree($_nodeID = null, $_subscribedOnly = null) |
|
| 808 | 807 | { |
| 809 | 808 | $nodeID = $_GET['id']; |
| 810 | 809 | if (!is_null($_nodeID)) $nodeID = $_nodeID; |
| 811 | - $subscribedOnly = (bool)(!is_null($_subscribedOnly)?$_subscribedOnly:!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 810 | + $subscribedOnly = (bool)(!is_null($_subscribedOnly) ? $_subscribedOnly : !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 812 | 811 | $fetchCounters = !is_null($_nodeID); |
| 813 | - list($_profileID,$_folderName) = explode(self::$delimiter,$nodeID,2); |
|
| 812 | + list($_profileID, $_folderName) = explode(self::$delimiter, $nodeID, 2); |
|
| 814 | 813 | |
| 815 | 814 | if (!empty($_folderName)) $fetchCounters = true; |
| 816 | 815 | |
| 817 | 816 | // Check if it is called for refresh root |
| 818 | 817 | // then we need to reinitialized the index tree |
| 819 | - if(!$nodeID && !$_profileID) |
|
| 818 | + if (!$nodeID && !$_profileID) |
|
| 820 | 819 | { |
| 821 | - $data = $this->mail_tree->getInitialIndexTree(null,null,null,null,true,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 820 | + $data = $this->mail_tree->getInitialIndexTree(null, null, null, null, true, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 822 | 821 | } |
| 823 | 822 | else |
| 824 | 823 | { |
| 825 | - $data = $this->mail_tree->getTree($nodeID,$_profileID,0, false,$subscribedOnly,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 824 | + $data = $this->mail_tree->getTree($nodeID, $_profileID, 0, false, $subscribedOnly, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 826 | 825 | } |
| 827 | 826 | if (!is_null($_nodeID)) return $data; |
| 828 | 827 | Etemplate\Widget\Tree::send_quote_json($data); |
@@ -838,17 +837,17 @@ discard block |
||
| 838 | 837 | */ |
| 839 | 838 | static function findNode($_out, $_nodeID, $childElements = false) |
| 840 | 839 | { |
| 841 | - foreach($_out['item'] as $node) |
|
| 840 | + foreach ($_out['item'] as $node) |
|
| 842 | 841 | { |
| 843 | - if (strcmp($node['id'],$_nodeID)===0) |
|
| 842 | + if (strcmp($node['id'], $_nodeID) === 0) |
|
| 844 | 843 | { |
| 845 | 844 | //error_log(__METHOD__.__LINE__.':'.$_nodeID.'->'.$node['id']); |
| 846 | - return ($childElements?$node['item']:$node); |
|
| 845 | + return ($childElements ? $node['item'] : $node); |
|
| 847 | 846 | } |
| 848 | - elseif (is_array($node['item']) && strncmp($node['id'],$_nodeID,strlen($node['id']))===0 && strlen($_nodeID)>strlen($node['id'])) |
|
| 847 | + elseif (is_array($node['item']) && strncmp($node['id'], $_nodeID, strlen($node['id'])) === 0 && strlen($_nodeID) > strlen($node['id'])) |
|
| 849 | 848 | { |
| 850 | 849 | //error_log(__METHOD__.__LINE__.' descend into '.$node['id']); |
| 851 | - return self::findNode($node,$_nodeID,$childElements); |
|
| 850 | + return self::findNode($node, $_nodeID, $childElements); |
|
| 852 | 851 | } |
| 853 | 852 | } |
| 854 | 853 | } |
@@ -862,7 +861,7 @@ discard block |
||
| 862 | 861 | */ |
| 863 | 862 | private function get_actions() |
| 864 | 863 | { |
| 865 | - static $accArray=array(); // buffer identity names on single request |
|
| 864 | + static $accArray = array(); // buffer identity names on single request |
|
| 866 | 865 | // duplicated from mail_hooks |
| 867 | 866 | static $deleteOptions = array( |
| 868 | 867 | 'move_to_trash' => 'move to trash', |
@@ -873,12 +872,12 @@ discard block |
||
| 873 | 872 | $lastFolderUsedForMove = null; |
| 874 | 873 | $moveactions = array(); |
| 875 | 874 | $archiveFolder = $this->mail_bo->getArchiveFolder(); |
| 876 | - $lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1); |
|
| 875 | + $lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 1); |
|
| 877 | 876 | //error_log(__METHOD__.__LINE__." StoredFolders->".array2string($lastFoldersUsedForMoveCont)); |
| 878 | 877 | //error_log(__METHOD__.__LINE__.' ProfileId:'.$this->mail_bo->profileID." StoredFolders->(".count($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]).") ".array2string($lastFoldersUsedForMoveCont[$this->mail_bo->profileID])); |
| 879 | 878 | if (is_null($accArray)) |
| 880 | 879 | { |
| 881 | - foreach(Mail\Account::search($only_current_user=true, false) as $acc_id => $accountObj) |
|
| 880 | + foreach (Mail\Account::search($only_current_user = true, false) as $acc_id => $accountObj) |
|
| 882 | 881 | { |
| 883 | 882 | //error_log(__METHOD__.__LINE__.array2string($accountObj)); |
| 884 | 883 | if (!$accountObj->is_imap()) |
@@ -886,22 +885,22 @@ discard block |
||
| 886 | 885 | // not to be used for IMAP Foldertree, as there is no Imap host |
| 887 | 886 | continue; |
| 888 | 887 | } |
| 889 | - $identity_name = Mail\Account::identity_name($accountObj,true,$GLOBALS['egw_info']['user']['acount_id']); |
|
| 890 | - $accArray[$acc_id] = str_replace(array('<','>'),array('[',']'),$identity_name);// as angle brackets are quoted, display in Javascript messages when used is ugly, so use square brackets instead |
|
| 888 | + $identity_name = Mail\Account::identity_name($accountObj, true, $GLOBALS['egw_info']['user']['acount_id']); |
|
| 889 | + $accArray[$acc_id] = str_replace(array('<', '>'), array('[', ']'), $identity_name); // as angle brackets are quoted, display in Javascript messages when used is ugly, so use square brackets instead |
|
| 891 | 890 | } |
| 892 | 891 | } |
| 893 | - if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont=array(); |
|
| 892 | + if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont = array(); |
|
| 894 | 893 | foreach (array_keys($lastFoldersUsedForMoveCont) as $pid) |
| 895 | 894 | { |
| 896 | - if ($this->mail_bo->profileID==$pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID])) |
|
| 895 | + if ($this->mail_bo->profileID == $pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID])) |
|
| 897 | 896 | { |
| 898 | 897 | $_folder = $this->mail_bo->icServer->getCurrentMailbox(); |
| 899 | 898 | //error_log(__METHOD__.__LINE__.' '.$_folder."<->".$lastFoldersUsedForMoveCont[$this->mail_bo->profileID].function_backtrace()); |
| 900 | - $counter =1; |
|
| 899 | + $counter = 1; |
|
| 901 | 900 | foreach ($lastFoldersUsedForMoveCont[$this->mail_bo->profileID] as $i => $lastFolderUsedForMoveCont) |
| 902 | 901 | { |
| 903 | 902 | $moveaction = 'move_'; |
| 904 | - if ($_folder!=$i) |
|
| 903 | + if ($_folder != $i) |
|
| 905 | 904 | { |
| 906 | 905 | $moveaction .= $lastFolderUsedForMoveCont; |
| 907 | 906 | //error_log(__METHOD__.__LINE__.'#'.$moveaction); |
@@ -912,7 +911,7 @@ discard block |
||
| 912 | 911 | $fS['profileName'] = $accArray[$this->mail_bo->profileID]; |
| 913 | 912 | $fS['shortDisplayName'] = $i; |
| 914 | 913 | $moveactions[$moveaction] = $fS; |
| 915 | - $counter ++; |
|
| 914 | + $counter++; |
|
| 916 | 915 | } |
| 917 | 916 | else |
| 918 | 917 | { |
@@ -922,9 +921,9 @@ discard block |
||
| 922 | 921 | } |
| 923 | 922 | } |
| 924 | 923 | } |
| 925 | - elseif ($this->mail_bo->profileID!=$pid && isset($lastFoldersUsedForMoveCont[$pid]) && !empty($lastFoldersUsedForMoveCont[$pid])) |
|
| 924 | + elseif ($this->mail_bo->profileID != $pid && isset($lastFoldersUsedForMoveCont[$pid]) && !empty($lastFoldersUsedForMoveCont[$pid])) |
|
| 926 | 925 | { |
| 927 | - $counter =1; |
|
| 926 | + $counter = 1; |
|
| 928 | 927 | foreach ($lastFoldersUsedForMoveCont[$pid] as $i => $lastFolderUsedForMoveCont) |
| 929 | 928 | { |
| 930 | 929 | //error_log(__METHOD__.__LINE__."$i => $lastFolderUsedForMoveCont"); |
@@ -937,19 +936,19 @@ discard block |
||
| 937 | 936 | $fS['profileName'] = $accArray[$pid]; |
| 938 | 937 | $fS['shortDisplayName'] = $i; |
| 939 | 938 | $moveactions[$moveaction] = $fS; |
| 940 | - $counter ++; |
|
| 939 | + $counter++; |
|
| 941 | 940 | } |
| 942 | 941 | } |
| 943 | 942 | } |
| 944 | 943 | } |
| 945 | - Api\Cache::setCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFoldersUsedForMoveCont, $expiration=60*60*1); |
|
| 944 | + Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), $lastFoldersUsedForMoveCont, $expiration = 60 * 60 * 1); |
|
| 946 | 945 | $group = 0; |
| 947 | - $actions = array( |
|
| 946 | + $actions = array( |
|
| 948 | 947 | 'open' => array( |
| 949 | 948 | 'caption' => lang('Open'), |
| 950 | 949 | 'icon' => 'view', |
| 951 | 950 | 'group' => ++$group, |
| 952 | - 'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.mail.mobileView':'javaScript:app.mail.mail_open', |
|
| 951 | + 'onExecute' => Api\Header\UserAgent::mobile() ? 'javaScript:app.mail.mobileView' : 'javaScript:app.mail.mail_open', |
|
| 953 | 952 | 'allowOnMultiple' => false, |
| 954 | 953 | 'default' => true, |
| 955 | 954 | 'mobileViewTemplate' => 'view?'.filemtime(Api\Etemplate\Widget\Template::rel2path('/mail/templates/mobile/view.xet')) |
@@ -1002,20 +1001,20 @@ discard block |
||
| 1002 | 1001 | 'allowOnMultiple' => false, |
| 1003 | 1002 | ) |
| 1004 | 1003 | ); |
| 1005 | - $macounter=0; |
|
| 1004 | + $macounter = 0; |
|
| 1006 | 1005 | if (!empty($moveactions)) |
| 1007 | 1006 | { |
| 1008 | 1007 | //error_log(__METHOD__.__LINE__.array2string($moveactions)); |
| 1009 | - $children=array(); |
|
| 1010 | - $pID=0; |
|
| 1008 | + $children = array(); |
|
| 1009 | + $pID = 0; |
|
| 1011 | 1010 | foreach ($moveactions as $moveaction => $lastFolderUsedForMove) |
| 1012 | 1011 | { |
| 1013 | - $group = ($pID != $lastFolderUsedForMove['profileID'] && $macounter>0? $group+1 : $group); |
|
| 1012 | + $group = ($pID != $lastFolderUsedForMove['profileID'] && $macounter > 0 ? $group + 1 : $group); |
|
| 1014 | 1013 | //error_log(__METHOD__.__LINE__."#$pID != ".$lastFolderUsedForMove['profileID']."#".$macounter.'#'.$groupCounter.'#'); |
| 1015 | 1014 | $children = array_merge($children, |
| 1016 | 1015 | array( |
| 1017 | 1016 | $moveaction => array( |
| 1018 | - 'caption' => (!empty($lastFolderUsedForMove['profileName'])?$lastFolderUsedForMove['profileName']:'('.$lastFolderUsedForMove['profileID'].')').': '.(isset($lastFolderUsedForMove['shortDisplayName'])?$lastFolderUsedForMove['shortDisplayName']:''), |
|
| 1017 | + 'caption' => (!empty($lastFolderUsedForMove['profileName']) ? $lastFolderUsedForMove['profileName'] : '('.$lastFolderUsedForMove['profileID'].')').': '.(isset($lastFolderUsedForMove['shortDisplayName']) ? $lastFolderUsedForMove['shortDisplayName'] : ''), |
|
| 1019 | 1018 | 'icon' => 'move', |
| 1020 | 1019 | 'group' => $group, |
| 1021 | 1020 | 'onExecute' => 'javaScript:app.mail.mail_move2folder', |
@@ -1026,7 +1025,7 @@ discard block |
||
| 1026 | 1025 | $pID = $lastFolderUsedForMove['profileID']; |
| 1027 | 1026 | $macounter++; |
| 1028 | 1027 | } |
| 1029 | - $actions['moveto'] = array( |
|
| 1028 | + $actions['moveto'] = array( |
|
| 1030 | 1029 | 'caption' => lang('Move selected to'), |
| 1031 | 1030 | 'icon' => 'move', |
| 1032 | 1031 | 'group' => $group, |
@@ -1069,7 +1068,7 @@ discard block |
||
| 1069 | 1068 | 'icon' => 'tracker/navbar', |
| 1070 | 1069 | 'onExecute' => 'javaScript:app.mail.mail_integrate', |
| 1071 | 1070 | 'popup' => Link::get_registry('tracker', 'add_popup'), |
| 1072 | - 'mail_import' => Api\Hooks::single(array('location' => 'mail_import'),'tracker'), |
|
| 1071 | + 'mail_import' => Api\Hooks::single(array('location' => 'mail_import'), 'tracker'), |
|
| 1073 | 1072 | 'allowOnMultiple' => false, |
| 1074 | 1073 | ), |
| 1075 | 1074 | 'calendar' => array( |
@@ -1288,24 +1287,24 @@ discard block |
||
| 1288 | 1287 | * @param array &$rows |
| 1289 | 1288 | * @param array &$readonlys |
| 1290 | 1289 | */ |
| 1291 | - public static function get_rows(&$query,&$rows,&$readonlys) |
|
| 1290 | + public static function get_rows(&$query, &$rows, &$readonlys) |
|
| 1292 | 1291 | { |
| 1293 | - unset($readonlys); // not used, but required by function signature |
|
| 1292 | + unset($readonlys); // not used, but required by function signature |
|
| 1294 | 1293 | |
| 1295 | 1294 | // handle possible profile change in get_rows |
| 1296 | 1295 | if (!empty($query['selectedFolder'])) |
| 1297 | 1296 | { |
| 1298 | - list($_profileID,$folderName) = explode(self::$delimiter, $query['selectedFolder'], 2); |
|
| 1297 | + list($_profileID, $folderName) = explode(self::$delimiter, $query['selectedFolder'], 2); |
|
| 1299 | 1298 | if (is_numeric(($_profileID)) && $_profileID != $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']) |
| 1300 | 1299 | { |
| 1301 | 1300 | try { |
| 1302 | - $mail_ui = new mail_ui(false); // do NOT run constructor, as we change profile anyway |
|
| 1301 | + $mail_ui = new mail_ui(false); // do NOT run constructor, as we change profile anyway |
|
| 1303 | 1302 | $mail_ui->changeProfile($_profileID); |
| 1304 | 1303 | $query['actions'] = $mail_ui->get_actions(); |
| 1305 | 1304 | } |
| 1306 | - catch(Exception $e) |
|
| 1305 | + catch (Exception $e) |
|
| 1307 | 1306 | { |
| 1308 | - $rows=array(); |
|
| 1307 | + $rows = array(); |
|
| 1309 | 1308 | return 0; |
| 1310 | 1309 | } |
| 1311 | 1310 | if (empty($folderName)) $query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX'; |
@@ -1313,7 +1312,7 @@ discard block |
||
| 1313 | 1312 | } |
| 1314 | 1313 | if (!isset($mail_ui)) |
| 1315 | 1314 | { |
| 1316 | - $mail_ui = new mail_ui(true); // run constructor for current profile |
|
| 1315 | + $mail_ui = new mail_ui(true); // run constructor for current profile |
|
| 1317 | 1316 | if (empty($query['selectedFolder'])) $query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX'; |
| 1318 | 1317 | } |
| 1319 | 1318 | //error_log(__METHOD__.__LINE__.' SelectedFolder:'.$query['selectedFolder'].' Start:'.$query['start'].' NumRows:'.$query['num_rows'].array2string($query['order']).'->'.array2string($query['sort'])); |
@@ -1322,68 +1321,68 @@ discard block |
||
| 1322 | 1321 | //$query['search'] is the phrase in the searchbox |
| 1323 | 1322 | |
| 1324 | 1323 | $mail_ui->mail_bo->restoreSessionData(); |
| 1325 | - if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder']; |
|
| 1324 | + if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox'] = $query['selectedFolder']; |
|
| 1326 | 1325 | $mail_ui->mail_bo->saveSessionData(); |
| 1327 | 1326 | |
| 1328 | 1327 | $sRToFetch = null; |
| 1329 | - list($_profileID,$_folderName) = explode(self::$delimiter,$query['selectedFolder'],2); |
|
| 1330 | - if (strpos($_folderName,self::$delimiter)!==false) |
|
| 1328 | + list($_profileID, $_folderName) = explode(self::$delimiter, $query['selectedFolder'], 2); |
|
| 1329 | + if (strpos($_folderName, self::$delimiter) !== false) |
|
| 1331 | 1330 | { |
| 1332 | - list($app,$_profileID,$_folderName) = explode(self::$delimiter,$_folderName,3); |
|
| 1331 | + list($app, $_profileID, $_folderName) = explode(self::$delimiter, $_folderName, 3); |
|
| 1333 | 1332 | unset($app); |
| 1334 | 1333 | } |
| 1335 | 1334 | //save selected Folder to sessionData (mailbox)->currentFolder |
| 1336 | - if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$_folderName; |
|
| 1337 | - $toSchema = false;//decides to select list schema with column to selected (if false fromaddress is default) |
|
| 1335 | + if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox'] = $_folderName; |
|
| 1336 | + $toSchema = false; //decides to select list schema with column to selected (if false fromaddress is default) |
|
| 1338 | 1337 | if ($mail_ui->mail_bo->folderExists($_folderName)) |
| 1339 | 1338 | { |
| 1340 | - $toSchema = $mail_ui->mail_bo->isDraftFolder($_folderName,false)||$mail_ui->mail_bo->isSentFolder($_folderName,false)||$mail_ui->mail_bo->isTemplateFolder($_folderName,false); |
|
| 1339 | + $toSchema = $mail_ui->mail_bo->isDraftFolder($_folderName, false) || $mail_ui->mail_bo->isSentFolder($_folderName, false) || $mail_ui->mail_bo->isTemplateFolder($_folderName, false); |
|
| 1341 | 1340 | } |
| 1342 | 1341 | else |
| 1343 | 1342 | { |
| 1344 | 1343 | // take the extra time on failure |
| 1345 | - if (!$mail_ui->mail_bo->folderExists($_folderName,true)) |
|
| 1344 | + if (!$mail_ui->mail_bo->folderExists($_folderName, true)) |
|
| 1346 | 1345 | { |
| 1347 | 1346 | //error_log(__METHOD__.__LINE__.' Test on Folder:'.$_folderName.' failed; Using INBOX instead'); |
| 1348 | - $query['selectedFolder']=$mail_ui->mail_bo->sessionData['mailbox']=$_folderName='INBOX'; |
|
| 1347 | + $query['selectedFolder'] = $mail_ui->mail_bo->sessionData['mailbox'] = $_folderName = 'INBOX'; |
|
| 1349 | 1348 | } |
| 1350 | 1349 | } |
| 1351 | 1350 | $mail_ui->mail_bo->saveSessionData(); |
| 1352 | 1351 | $rowsFetched['messages'] = null; |
| 1353 | - $offset = $query['start']+1; // we always start with 1 |
|
| 1352 | + $offset = $query['start'] + 1; // we always start with 1 |
|
| 1354 | 1353 | $maxMessages = $query['num_rows']; |
| 1355 | 1354 | //error_log(__METHOD__.__LINE__.array2string($query)); |
| 1356 | - $sort = ($query['order']=='address'?($toSchema?'toaddress':'fromaddress'):$query['order']); |
|
| 1357 | - if (!empty($query['search'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate'])))) |
|
| 1355 | + $sort = ($query['order'] == 'address' ? ($toSchema ? 'toaddress' : 'fromaddress') : $query['order']); |
|
| 1356 | + if (!empty($query['search']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate'])))) |
|
| 1358 | 1357 | { |
| 1359 | 1358 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID])) |
| 1360 | 1359 | { |
| 1361 | - Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
|
| 1360 | + Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 1362 | 1361 | if (!isset(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID])) |
| 1363 | 1362 | { |
| 1364 | - Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]=true; |
|
| 1363 | + Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] = true; |
|
| 1365 | 1364 | } |
| 1366 | 1365 | } |
| 1367 | 1366 | //error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']); |
| 1368 | 1367 | $cutoffdate = $cutoffdate2 = null; |
| 1369 | - if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate |
|
| 1370 | - if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate |
|
| 1368 | + if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate |
|
| 1369 | + if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate |
|
| 1371 | 1370 | //error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate); |
| 1372 | 1371 | $filter = array( |
| 1373 | - 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')), |
|
| 1374 | - 'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')), |
|
| 1372 | + 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')), |
|
| 1373 | + 'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')), |
|
| 1375 | 1374 | 'string' => $query['search'], |
| 1376 | 1375 | 'status' => 'any', |
| 1377 | 1376 | //'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2) |
| 1378 | 1377 | ); |
| 1379 | - if ($query['enddate']||$query['startdate']) { |
|
| 1378 | + if ($query['enddate'] || $query['startdate']) { |
|
| 1380 | 1379 | $filter['range'] = "BETWEEN"; |
| 1381 | 1380 | if ($cutoffdate) { |
| 1382 | - $filter[(empty($cutoffdate2)?'date':'since')] = date("d-M-Y", $cutoffdate); |
|
| 1381 | + $filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate); |
|
| 1383 | 1382 | if (empty($cutoffdate2)) $filter['range'] = "SINCE"; |
| 1384 | 1383 | } |
| 1385 | 1384 | if ($cutoffdate2) { |
| 1386 | - $filter[(empty($cutoffdate)?'date':'before')] = date("d-M-Y", $cutoffdate2); |
|
| 1385 | + $filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2); |
|
| 1387 | 1386 | if (empty($cutoffdate)) $filter['range'] = "BEFORE"; |
| 1388 | 1387 | } |
| 1389 | 1388 | } |
@@ -1396,17 +1395,17 @@ discard block |
||
| 1396 | 1395 | { |
| 1397 | 1396 | $filter['status'] = $query['filter']; |
| 1398 | 1397 | } |
| 1399 | - $reverse = ($query['sort']=='ASC'?false:true); |
|
| 1398 | + $reverse = ($query['sort'] == 'ASC' ? false : true); |
|
| 1400 | 1399 | $prefchanged = false; |
| 1401 | - if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']) || ($query['cat_id'] !=$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType'])) |
|
| 1400 | + if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']) || ($query['cat_id'] != $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType'])) |
|
| 1402 | 1401 | { |
| 1403 | 1402 | //error_log(__METHOD__.__LINE__.' Changing userPref ActivesearchType:'.$query['cat_id']); |
| 1404 | - $GLOBALS['egw']->preferences->add('mail','ActiveSearchType',$query['cat_id'],'user'); |
|
| 1403 | + $GLOBALS['egw']->preferences->add('mail', 'ActiveSearchType', $query['cat_id'], 'user'); |
|
| 1405 | 1404 | $prefchanged = true; |
| 1406 | 1405 | } |
| 1407 | - if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']) || ($query['filter2'] !=$GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails'])) |
|
| 1406 | + if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']) || ($query['filter2'] != $GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails'])) |
|
| 1408 | 1407 | { |
| 1409 | - $GLOBALS['egw']->preferences->add('mail','ShowDetails',$query['filter2'],'user'); |
|
| 1408 | + $GLOBALS['egw']->preferences->add('mail', 'ShowDetails', $query['filter2'], 'user'); |
|
| 1410 | 1409 | $prefchanged = true; |
| 1411 | 1410 | } |
| 1412 | 1411 | if ($prefchanged) |
@@ -1431,18 +1430,18 @@ discard block |
||
| 1431 | 1430 | $sort, |
| 1432 | 1431 | $reverse, |
| 1433 | 1432 | $filter, |
| 1434 | - $rByUid=true |
|
| 1433 | + $rByUid = true |
|
| 1435 | 1434 | ); |
| 1436 | 1435 | $rowsFetched['messages'] = $_sR['count']; |
| 1437 | 1436 | $ids = $_sR['match']->ids; |
| 1438 | 1437 | // if $sR is false, something failed fundamentally |
| 1439 | - if($reverse === true) $ids = ($ids===false?array():array_reverse((array)$ids)); |
|
| 1440 | - $sR = array_slice((array)$ids,($offset==0?0:$offset-1),$maxMessages); // we need only $maxMessages of uids |
|
| 1441 | - $sRToFetch = $sR;//array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids |
|
| 1438 | + if ($reverse === true) $ids = ($ids === false ? array() : array_reverse((array)$ids)); |
|
| 1439 | + $sR = array_slice((array)$ids, ($offset == 0 ? 0 : $offset - 1), $maxMessages); // we need only $maxMessages of uids |
|
| 1440 | + $sRToFetch = $sR; //array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids |
|
| 1442 | 1441 | //error_log(__METHOD__.__LINE__.' Rows fetched (UID only):'.count($sR).' Data:'.array2string($sR)); |
| 1443 | 1442 | $maxMessages = 75; |
| 1444 | 1443 | $sortResultwH['header'] = array(); |
| 1445 | - if (count($sRToFetch)>0) |
|
| 1444 | + if (count($sRToFetch) > 0) |
|
| 1446 | 1445 | { |
| 1447 | 1446 | //error_log(__METHOD__.__LINE__.' Headers to fetch with UIDs:'.count($sRToFetch).' Data:'.array2string($sRToFetch)); |
| 1448 | 1447 | $sortResult = array(); |
@@ -1456,7 +1455,7 @@ discard block |
||
| 1456 | 1455 | $filter, |
| 1457 | 1456 | $sRToFetch, |
| 1458 | 1457 | true, //cacheResult |
| 1459 | - ($query['filter2']?true:false) // fetchPreview |
|
| 1458 | + ($query['filter2'] ? true : false) // fetchPreview |
|
| 1460 | 1459 | ); |
| 1461 | 1460 | } |
| 1462 | 1461 | } |
@@ -1473,30 +1472,30 @@ discard block |
||
| 1473 | 1472 | $filter, |
| 1474 | 1473 | null, // this uids only |
| 1475 | 1474 | true, // cacheResult |
| 1476 | - ($query['filter2']?true:false) // fetchPreview |
|
| 1475 | + ($query['filter2'] ? true : false) // fetchPreview |
|
| 1477 | 1476 | ); |
| 1478 | 1477 | $rowsFetched['messages'] = $sortResultwH['info']['total']; |
| 1479 | 1478 | } |
| 1480 | 1479 | } |
| 1481 | 1480 | catch (Exception $e) |
| 1482 | 1481 | { |
| 1483 | - $sortResultwH=array(); |
|
| 1484 | - $sR=array(); |
|
| 1482 | + $sortResultwH = array(); |
|
| 1483 | + $sR = array(); |
|
| 1485 | 1484 | self::callWizard($e->getMessage(), false, 'error'); |
| 1486 | 1485 | } |
| 1487 | 1486 | $response = Api\Json\Response::get(); |
| 1488 | 1487 | // unlock immediately after fetching the rows |
| 1489 | - if (stripos($_GET['menuaction'],'ajax_get_rows')!==false) |
|
| 1488 | + if (stripos($_GET['menuaction'], 'ajax_get_rows') !== false) |
|
| 1490 | 1489 | { |
| 1491 | 1490 | //error_log(__METHOD__.__LINE__.' unlock tree ->'.$_GET['menuaction']); |
| 1492 | 1491 | $response->call('app.mail.unlock_tree'); |
| 1493 | 1492 | } |
| 1494 | 1493 | |
| 1495 | - if (is_array($sR) && count($sR)>0) |
|
| 1494 | + if (is_array($sR) && count($sR) > 0) |
|
| 1496 | 1495 | { |
| 1497 | 1496 | foreach ((array)$sR as $key => $v) |
| 1498 | 1497 | { |
| 1499 | - if (array_key_exists($key,(array)$sortResultwH['header'])==true) |
|
| 1498 | + if (array_key_exists($key, (array)$sortResultwH['header']) == true) |
|
| 1500 | 1499 | { |
| 1501 | 1500 | $sortResult['header'][] = $sortResultwH['header'][$key]; |
| 1502 | 1501 | } |
@@ -1514,12 +1513,12 @@ discard block |
||
| 1514 | 1513 | if (empty($rowsFetched['messages'])) $rowsFetched['messages'] = $rowsFetched['rowsFetched']; |
| 1515 | 1514 | |
| 1516 | 1515 | //error_log(__METHOD__.__LINE__.' Rows fetched:'.$rowsFetched.' Data:'.array2string($sortResult)); |
| 1517 | - $cols = array('row_id','uid','status','attachments','subject','address','toaddress','fromaddress','ccaddress','additionaltoaddress','date','size','modified','bodypreview'); |
|
| 1518 | - if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE') unset($cols[0]); |
|
| 1519 | - $rows = $mail_ui->header2gridelements($sortResult['header'],$cols, $_folderName, $folderType=$toSchema); |
|
| 1516 | + $cols = array('row_id', 'uid', 'status', 'attachments', 'subject', 'address', 'toaddress', 'fromaddress', 'ccaddress', 'additionaltoaddress', 'date', 'size', 'modified', 'bodypreview'); |
|
| 1517 | + if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode'] == 'EGW_SELECTMODE_TOGGLE') unset($cols[0]); |
|
| 1518 | + $rows = $mail_ui->header2gridelements($sortResult['header'], $cols, $_folderName, $folderType = $toSchema); |
|
| 1520 | 1519 | //error_log(__METHOD__.__LINE__.array2string($rows)); |
| 1521 | 1520 | |
| 1522 | - if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__); |
|
| 1521 | + if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, 'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'], __METHOD__.__LINE__); |
|
| 1523 | 1522 | return $rowsFetched['messages']; |
| 1524 | 1523 | } |
| 1525 | 1524 | |
@@ -1531,7 +1530,7 @@ discard block |
||
| 1531 | 1530 | * @param boolean $_prependApp to indicate that the app 'mail' is to be used for creating the rowID |
| 1532 | 1531 | * @return string - a colon separated string in the form [app:]accountID:profileID:folder:message_uid |
| 1533 | 1532 | */ |
| 1534 | - function createRowID($_folderName, $message_uid, $_prependApp=false) |
|
| 1533 | + function createRowID($_folderName, $message_uid, $_prependApp = false) |
|
| 1535 | 1534 | { |
| 1536 | 1535 | return self::generateRowID($this->mail_bo->profileID, $_folderName, $message_uid, $_prependApp); |
| 1537 | 1536 | } |
@@ -1545,9 +1544,9 @@ discard block |
||
| 1545 | 1544 | * @param boolean $_prependApp to indicate that the app 'mail' is to be used for creating the rowID |
| 1546 | 1545 | * @return string - a colon separated string in the form [app:]accountID:profileID:folder:message_uid |
| 1547 | 1546 | */ |
| 1548 | - static function generateRowID($_profileID, $_folderName, $message_uid, $_prependApp=false) |
|
| 1547 | + static function generateRowID($_profileID, $_folderName, $message_uid, $_prependApp = false) |
|
| 1549 | 1548 | { |
| 1550 | - return ($_prependApp?'mail'.self::$delimiter:'').trim($GLOBALS['egw_info']['user']['account_id']).self::$delimiter.$_profileID.self::$delimiter.base64_encode($_folderName).self::$delimiter.$message_uid; |
|
| 1549 | + return ($_prependApp ? 'mail'.self::$delimiter : '').trim($GLOBALS['egw_info']['user']['account_id']).self::$delimiter.$_profileID.self::$delimiter.base64_encode($_folderName).self::$delimiter.$message_uid; |
|
| 1551 | 1550 | } |
| 1552 | 1551 | |
| 1553 | 1552 | /** |
@@ -1558,13 +1557,13 @@ discard block |
||
| 1558 | 1557 | */ |
| 1559 | 1558 | static function splitRowID($_rowID) |
| 1560 | 1559 | { |
| 1561 | - $res = explode(self::$delimiter,$_rowID); |
|
| 1560 | + $res = explode(self::$delimiter, $_rowID); |
|
| 1562 | 1561 | // as a rowID is perceeded by app::, should be mail! |
| 1563 | 1562 | //error_log(__METHOD__.__LINE__.array2string($res).' [0] isInt:'.is_int($res[0]).' [0] isNumeric:'.is_numeric($res[0]).' [0] isString:'.is_string($res[0]).' Count:'.count($res)); |
| 1564 | - if (count($res)==4 && is_numeric($res[0]) ) |
|
| 1563 | + if (count($res) == 4 && is_numeric($res[0])) |
|
| 1565 | 1564 | { |
| 1566 | 1565 | // we have an own created rowID; prepend app=mail |
| 1567 | - array_unshift($res,'mail'); |
|
| 1566 | + array_unshift($res, 'mail'); |
|
| 1568 | 1567 | } |
| 1569 | 1568 | return array('app'=>$res[0], 'accountID'=>$res[1], 'profileID'=>$res[2], 'folder'=>base64_decode($res[3]), 'msgUID'=>$res[4]); |
| 1570 | 1569 | } |
@@ -1578,56 +1577,56 @@ discard block |
||
| 1578 | 1577 | { |
| 1579 | 1578 | $actions = $this->get_actions(); |
| 1580 | 1579 | $arrActions = array('composeasnew', 'reply', 'reply_all', 'forward', 'flagged', 'delete', 'print', |
| 1581 | - 'infolog', 'tracker', 'calendar', 'save', 'view', 'read', 'label1', 'label2', 'label3', 'label4', 'label5'); |
|
| 1582 | - foreach( $arrActions as &$act) |
|
| 1580 | + 'infolog', 'tracker', 'calendar', 'save', 'view', 'read', 'label1', 'label2', 'label3', 'label4', 'label5'); |
|
| 1581 | + foreach ($arrActions as &$act) |
|
| 1583 | 1582 | { |
| 1584 | 1583 | //error_log(__METHOD__.__LINE__.' '.$act.'->'.array2string($actions[$act])); |
| 1585 | 1584 | switch ($act) |
| 1586 | 1585 | { |
| 1587 | 1586 | case 'forward': |
| 1588 | - $actionsenabled[$act]=$actions[$act]; |
|
| 1587 | + $actionsenabled[$act] = $actions[$act]; |
|
| 1589 | 1588 | break; |
| 1590 | 1589 | case 'save': |
| 1591 | - $actionsenabled[$act]=$actions[$act]; |
|
| 1590 | + $actionsenabled[$act] = $actions[$act]; |
|
| 1592 | 1591 | |
| 1593 | 1592 | break; |
| 1594 | 1593 | case 'view': |
| 1595 | - $actionsenabled[$act]=$actions[$act]; |
|
| 1594 | + $actionsenabled[$act] = $actions[$act]; |
|
| 1596 | 1595 | break; |
| 1597 | 1596 | case 'flagged': |
| 1598 | - $actionsenabled[$act]= $actions['mark']['children'][$act]; |
|
| 1597 | + $actionsenabled[$act] = $actions['mark']['children'][$act]; |
|
| 1599 | 1598 | break; |
| 1600 | 1599 | case 'read': |
| 1601 | - $actionsenabled[$act]= $actions['mark']['children'][$act]; |
|
| 1600 | + $actionsenabled[$act] = $actions['mark']['children'][$act]; |
|
| 1602 | 1601 | break; |
| 1603 | 1602 | case 'label1': |
| 1604 | 1603 | $actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('important'); |
| 1605 | - $actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1604 | + $actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1606 | 1605 | break; |
| 1607 | 1606 | case 'label2': |
| 1608 | 1607 | $actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('job'); |
| 1609 | - $actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1608 | + $actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1610 | 1609 | break; |
| 1611 | 1610 | case 'label3': |
| 1612 | 1611 | $actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('personal'); |
| 1613 | - $actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1612 | + $actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1614 | 1613 | break; |
| 1615 | 1614 | case 'label4': |
| 1616 | 1615 | $actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('to do'); |
| 1617 | - $actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1616 | + $actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1618 | 1617 | break; |
| 1619 | 1618 | case 'label5': |
| 1620 | 1619 | $actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('later'); |
| 1621 | - $actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1620 | + $actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1622 | 1621 | break; |
| 1623 | 1622 | default: |
| 1624 | - if (isset($actions[$act])) $actionsenabled[$act]=$actions[$act]; |
|
| 1623 | + if (isset($actions[$act])) $actionsenabled[$act] = $actions[$act]; |
|
| 1625 | 1624 | } |
| 1626 | 1625 | } |
| 1627 | 1626 | unset($actionsenabled['drag_mail']); |
| 1628 | 1627 | //error_log(array2string($actionsenabled['view'])); |
| 1629 | - unset($actionsenabled['view']['children']['openastext']);//not supported in preview |
|
| 1630 | - unset($actionsenabled['view']['children']['openashtml']);//not supported in preview |
|
| 1628 | + unset($actionsenabled['view']['children']['openastext']); //not supported in preview |
|
| 1629 | + unset($actionsenabled['view']['children']['openashtml']); //not supported in preview |
|
| 1631 | 1630 | |
| 1632 | 1631 | return $actionsenabled; |
| 1633 | 1632 | } |
@@ -1641,45 +1640,45 @@ discard block |
||
| 1641 | 1640 | * @param array $_folderType used to determine if we need to populate from/to |
| 1642 | 1641 | * @return array populated result array |
| 1643 | 1642 | */ |
| 1644 | - public function header2gridelements($_headers, $cols, $_folderName, $_folderType=0) |
|
| 1643 | + public function header2gridelements($_headers, $cols, $_folderName, $_folderType = 0) |
|
| 1645 | 1644 | { |
| 1646 | 1645 | if (Mail::$debugTimes) $starttime = microtime(true); |
| 1647 | 1646 | $rv = array(); |
| 1648 | - $i=0; |
|
| 1649 | - foreach((array)$_headers as $header) |
|
| 1647 | + $i = 0; |
|
| 1648 | + foreach ((array)$_headers as $header) |
|
| 1650 | 1649 | { |
| 1651 | 1650 | $i++; |
| 1652 | 1651 | $data = array(); |
| 1653 | 1652 | //error_log(__METHOD__.array2string($header)); |
| 1654 | 1653 | $message_uid = $header['uid']; |
| 1655 | 1654 | $data['uid'] = $message_uid; |
| 1656 | - $data['row_id']=$this->createRowID($_folderName,$message_uid); |
|
| 1655 | + $data['row_id'] = $this->createRowID($_folderName, $message_uid); |
|
| 1657 | 1656 | |
| 1658 | 1657 | $flags = ""; |
| 1659 | - if(!empty($header['recent'])) $flags .= "R"; |
|
| 1660 | - if(!empty($header['flagged'])) $flags .= "F"; |
|
| 1661 | - if(!empty($header['answered'])) $flags .= "A"; |
|
| 1662 | - if(!empty($header['forwarded'])) $flags .= "W"; |
|
| 1663 | - if(!empty($header['deleted'])) $flags .= "D"; |
|
| 1664 | - if(!empty($header['seen'])) $flags .= "S"; |
|
| 1665 | - if(!empty($header['label1'])) $flags .= "1"; |
|
| 1666 | - if(!empty($header['label2'])) $flags .= "2"; |
|
| 1667 | - if(!empty($header['label3'])) $flags .= "3"; |
|
| 1668 | - if(!empty($header['label4'])) $flags .= "4"; |
|
| 1669 | - if(!empty($header['label5'])) $flags .= "5"; |
|
| 1658 | + if (!empty($header['recent'])) $flags .= "R"; |
|
| 1659 | + if (!empty($header['flagged'])) $flags .= "F"; |
|
| 1660 | + if (!empty($header['answered'])) $flags .= "A"; |
|
| 1661 | + if (!empty($header['forwarded'])) $flags .= "W"; |
|
| 1662 | + if (!empty($header['deleted'])) $flags .= "D"; |
|
| 1663 | + if (!empty($header['seen'])) $flags .= "S"; |
|
| 1664 | + if (!empty($header['label1'])) $flags .= "1"; |
|
| 1665 | + if (!empty($header['label2'])) $flags .= "2"; |
|
| 1666 | + if (!empty($header['label3'])) $flags .= "3"; |
|
| 1667 | + if (!empty($header['label4'])) $flags .= "4"; |
|
| 1668 | + if (!empty($header['label5'])) $flags .= "5"; |
|
| 1670 | 1669 | |
| 1671 | 1670 | $data["status"] = "<span class=\"status_img\"></span>"; |
| 1672 | 1671 | //error_log(__METHOD__.array2string($header).' Flags:'.$flags); |
| 1673 | 1672 | |
| 1674 | 1673 | // the css for this row |
| 1675 | - $is_recent=false; |
|
| 1674 | + $is_recent = false; |
|
| 1676 | 1675 | $css_styles = array("mail"); |
| 1677 | 1676 | if ($header['deleted']) { |
| 1678 | 1677 | $css_styles[] = 'deleted'; |
| 1679 | 1678 | } |
| 1680 | 1679 | if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded'])) { |
| 1681 | 1680 | $css_styles[] = 'recent'; |
| 1682 | - $is_recent=true; |
|
| 1681 | + $is_recent = true; |
|
| 1683 | 1682 | } |
| 1684 | 1683 | if ($header['priority'] < 3) { |
| 1685 | 1684 | $css_styles[] = 'prio_high'; |
@@ -1717,19 +1716,19 @@ discard block |
||
| 1717 | 1716 | if (in_array("subject", $cols)) |
| 1718 | 1717 | { |
| 1719 | 1718 | // filter out undisplayable characters |
| 1720 | - $search = array('[\016]','[\017]', |
|
| 1721 | - '[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]', |
|
| 1722 | - '[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]'); |
|
| 1719 | + $search = array('[\016]', '[\017]', |
|
| 1720 | + '[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]', |
|
| 1721 | + '[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]'); |
|
| 1723 | 1722 | $replace = ''; |
| 1724 | 1723 | |
| 1725 | - $header['subject'] = preg_replace($search,$replace,$header['subject']); |
|
| 1724 | + $header['subject'] = preg_replace($search, $replace, $header['subject']); |
|
| 1726 | 1725 | // curly brackets get messed up by the template! |
| 1727 | 1726 | |
| 1728 | 1727 | if (!empty($header['subject'])) { |
| 1729 | 1728 | // make the subject shorter if it is to long |
| 1730 | 1729 | $subject = $header['subject']; |
| 1731 | 1730 | } else { |
| 1732 | - $subject = '('. lang('no subject') .')'; |
|
| 1731 | + $subject = '('.lang('no subject').')'; |
|
| 1733 | 1732 | } |
| 1734 | 1733 | |
| 1735 | 1734 | $data["subject"] = $subject; // the mailsubject |
@@ -1739,53 +1738,53 @@ discard block |
||
| 1739 | 1738 | //error_log(__METHOD__.__LINE__.array2string($header)); |
| 1740 | 1739 | if (in_array("attachments", $cols)) |
| 1741 | 1740 | { |
| 1742 | - if($header['mimetype'] == 'multipart/mixed' || |
|
| 1741 | + if ($header['mimetype'] == 'multipart/mixed' || |
|
| 1743 | 1742 | $header['mimetype'] == 'multipart/signed' || |
| 1744 | 1743 | $header['mimetype'] == 'multipart/related' || |
| 1745 | 1744 | $header['mimetype'] == 'multipart/report' || |
| 1746 | 1745 | $header['mimetype'] == 'text/calendar' || |
| 1747 | 1746 | $header['mimetype'] == 'text/html' || |
| 1748 | - substr($header['mimetype'],0,11) == 'application' || |
|
| 1749 | - substr($header['mimetype'],0,5) == 'audio' || |
|
| 1750 | - substr($header['mimetype'],0,5) == 'video' || |
|
| 1747 | + substr($header['mimetype'], 0, 11) == 'application' || |
|
| 1748 | + substr($header['mimetype'], 0, 5) == 'audio' || |
|
| 1749 | + substr($header['mimetype'], 0, 5) == 'video' || |
|
| 1751 | 1750 | $header['mimetype'] == 'multipart/alternative') |
| 1752 | 1751 | { |
| 1753 | - $image = Api\Html::image('mail','attach'); |
|
| 1752 | + $image = Api\Html::image('mail', 'attach'); |
|
| 1754 | 1753 | $imageHTMLBlock = ''; |
| 1755 | - $datarowid = $this->createRowID($_folderName,$message_uid,true); |
|
| 1754 | + $datarowid = $this->createRowID($_folderName, $message_uid, true); |
|
| 1756 | 1755 | $attachments = $header['attachments']; |
| 1757 | - if (count($attachments)<1) |
|
| 1756 | + if (count($attachments) < 1) |
|
| 1758 | 1757 | { |
| 1759 | 1758 | $image = ' '; |
| 1760 | 1759 | } |
| 1761 | - if (count($attachments)==1) |
|
| 1760 | + if (count($attachments) == 1) |
|
| 1762 | 1761 | { |
| 1763 | - $imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'],$_folderName); |
|
| 1764 | - $image = Api\Html::image('mail','attach',$attachments[0]['name'].(!empty($attachments[0]['mimeType'])?' ('.$attachments[0]['mimeType'].')':'')); |
|
| 1762 | + $imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'], $_folderName); |
|
| 1763 | + $image = Api\Html::image('mail', 'attach', $attachments[0]['name'].(!empty($attachments[0]['mimeType']) ? ' ('.$attachments[0]['mimeType'].')' : '')); |
|
| 1765 | 1764 | } |
| 1766 | - if (count($attachments)>1) |
|
| 1765 | + if (count($attachments) > 1) |
|
| 1767 | 1766 | { |
| 1768 | - $imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'],$_folderName); |
|
| 1769 | - $image = Api\Html::image('mail','attach',lang('%1 attachments',count($attachments))); |
|
| 1767 | + $imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'], $_folderName); |
|
| 1768 | + $image = Api\Html::image('mail', 'attach', lang('%1 attachments', count($attachments))); |
|
| 1770 | 1769 | } |
| 1771 | 1770 | |
| 1772 | 1771 | $attachmentFlag = $image; |
| 1773 | 1772 | } else { |
| 1774 | - $attachmentFlag =' '; |
|
| 1773 | + $attachmentFlag = ' '; |
|
| 1775 | 1774 | } |
| 1776 | 1775 | // show priority flag |
| 1777 | 1776 | if ($header['priority'] < 3) { |
| 1778 | - $image = Api\Html::image('mail','prio_high'); |
|
| 1777 | + $image = Api\Html::image('mail', 'prio_high'); |
|
| 1779 | 1778 | } elseif ($header['priority'] > 3) { |
| 1780 | - $image = Api\Html::image('mail','prio_low'); |
|
| 1779 | + $image = Api\Html::image('mail', 'prio_low'); |
|
| 1781 | 1780 | } else { |
| 1782 | 1781 | $image = ''; |
| 1783 | 1782 | } |
| 1784 | 1783 | // show a flag for flagged messages |
| 1785 | - $imageflagged =''; |
|
| 1784 | + $imageflagged = ''; |
|
| 1786 | 1785 | if ($header['flagged']) |
| 1787 | 1786 | { |
| 1788 | - $imageflagged = Api\Html::image('mail','unread_flagged_small'); |
|
| 1787 | + $imageflagged = Api\Html::image('mail', 'unread_flagged_small'); |
|
| 1789 | 1788 | } |
| 1790 | 1789 | $data["attachments"] = $image.$attachmentFlag.$imageflagged; // icon for attachments available |
| 1791 | 1790 | } |
@@ -1794,7 +1793,7 @@ discard block |
||
| 1794 | 1793 | if (in_array("toaddress", $cols)) |
| 1795 | 1794 | { |
| 1796 | 1795 | // sent or drafts or template folder means foldertype > 0, use to address instead of from |
| 1797 | - $data["toaddress"] = $header['to_address'];//Mail::htmlentities($header['to_address'],$this->charset); |
|
| 1796 | + $data["toaddress"] = $header['to_address']; //Mail::htmlentities($header['to_address'],$this->charset); |
|
| 1798 | 1797 | } |
| 1799 | 1798 | |
| 1800 | 1799 | if (in_array("additionaltoaddress", $cols)) |
@@ -1827,29 +1826,29 @@ discard block |
||
| 1827 | 1826 | $data['flags'] = Array(); |
| 1828 | 1827 | if ($header['seen']) $data["flags"]['read'] = 'read'; |
| 1829 | 1828 | foreach ($css_styles as &$flag) { |
| 1830 | - if ($flag!='mail') |
|
| 1829 | + if ($flag != 'mail') |
|
| 1831 | 1830 | { |
| 1832 | - if ($flag=='labelone') {$data["flags"]['label1'] = 'label1';} |
|
| 1833 | - elseif ($flag=='labeltwo') {$data["flags"]['label2'] = 'label2';} |
|
| 1834 | - elseif ($flag=='labelthree') {$data["flags"]['label3'] = 'label3';} |
|
| 1835 | - elseif ($flag=='labelfour') {$data["flags"]['label4'] = 'label4';} |
|
| 1836 | - elseif ($flag=='labelfive') {$data["flags"]['label5'] = 'label5';} |
|
| 1837 | - elseif ($flag=='unseen') {unset($data["flags"]['read']);} |
|
| 1831 | + if ($flag == 'labelone') {$data["flags"]['label1'] = 'label1'; } |
|
| 1832 | + elseif ($flag == 'labeltwo') {$data["flags"]['label2'] = 'label2'; } |
|
| 1833 | + elseif ($flag == 'labelthree') {$data["flags"]['label3'] = 'label3'; } |
|
| 1834 | + elseif ($flag == 'labelfour') {$data["flags"]['label4'] = 'label4'; } |
|
| 1835 | + elseif ($flag == 'labelfive') {$data["flags"]['label5'] = 'label5'; } |
|
| 1836 | + elseif ($flag == 'unseen') {unset($data["flags"]['read']); } |
|
| 1838 | 1837 | else $data["flags"][$flag] = $flag; |
| 1839 | 1838 | } |
| 1840 | 1839 | } |
| 1841 | 1840 | if ($header['disposition-notification-to']) $data['dispositionnotificationto'] = $header['disposition-notification-to']; |
| 1842 | - if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']); |
|
| 1841 | + if (($header['mdnsent'] || $header['mdnnotsent']|$header['seen']) && isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']); |
|
| 1843 | 1842 | $data['attachmentsBlock'] = $imageHTMLBlock; |
| 1844 | - $data['address'] = ($_folderType?$data["toaddress"]:$data["fromaddress"]); |
|
| 1845 | - if (in_array("bodypreview", $cols)&&$header['bodypreview']) |
|
| 1843 | + $data['address'] = ($_folderType ? $data["toaddress"] : $data["fromaddress"]); |
|
| 1844 | + if (in_array("bodypreview", $cols) && $header['bodypreview']) |
|
| 1846 | 1845 | { |
| 1847 | 1846 | $data["bodypreview"] = $header['bodypreview']; |
| 1848 | 1847 | } |
| 1849 | 1848 | $rv[] = $data; |
| 1850 | 1849 | //error_log(__METHOD__.__LINE__.array2string($data)); |
| 1851 | 1850 | } |
| 1852 | - if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__); |
|
| 1851 | + if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, 'Folder:'.$_folderName, __METHOD__.__LINE__); |
|
| 1853 | 1852 | |
| 1854 | 1853 | // ToDo: call this ONLY if labels change |
| 1855 | 1854 | Etemplate\Widget::setElementAttribute('toolbar', 'actions', $this->get_toolbar_actions()); |
@@ -1864,8 +1863,8 @@ discard block |
||
| 1864 | 1863 | */ |
| 1865 | 1864 | function displayHeader() |
| 1866 | 1865 | { |
| 1867 | - if(isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 1868 | - if(isset($_GET['part'])) $partID = $_GET['part']; |
|
| 1866 | + if (isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 1867 | + if (isset($_GET['part'])) $partID = $_GET['part']; |
|
| 1869 | 1868 | |
| 1870 | 1869 | $hA = self::splitRowID($rowID); |
| 1871 | 1870 | $uid = $hA['msgUID']; |
@@ -1879,17 +1878,17 @@ discard block |
||
| 1879 | 1878 | } |
| 1880 | 1879 | |
| 1881 | 1880 | $this->mail_bo->reopen($mailbox); |
| 1882 | - $headers_in = $this->mail_bo->getMessageRawHeader($uid, $partID); |
|
| 1881 | + $headers_in = $this->mail_bo->getMessageRawHeader($uid, $partID); |
|
| 1883 | 1882 | |
| 1884 | 1883 | // add line breaks to $rawheaders |
| 1885 | - $newRawHeaders = explode("\n",$headers_in); |
|
| 1884 | + $newRawHeaders = explode("\n", $headers_in); |
|
| 1886 | 1885 | reset($newRawHeaders); |
| 1887 | 1886 | |
| 1888 | 1887 | // reset $rawheaders |
| 1889 | - $rawheaders = ""; |
|
| 1888 | + $rawheaders = ""; |
|
| 1890 | 1889 | // create it new, with good line breaks |
| 1891 | 1890 | reset($newRawHeaders); |
| 1892 | - while(list($key,$value) = @each($newRawHeaders)) { |
|
| 1891 | + while (list($key, $value) = @each($newRawHeaders)) { |
|
| 1893 | 1892 | $rawheaders .= wordwrap($value, 90, "\n "); |
| 1894 | 1893 | } |
| 1895 | 1894 | |
@@ -1901,7 +1900,7 @@ discard block |
||
| 1901 | 1900 | } |
| 1902 | 1901 | |
| 1903 | 1902 | header('Content-type: text/html; charset=iso-8859-1'); |
| 1904 | - print '<pre>'. htmlspecialchars($rawheaders, ENT_NOQUOTES, 'iso-8859-1') .'</pre>'; |
|
| 1903 | + print '<pre>'.htmlspecialchars($rawheaders, ENT_NOQUOTES, 'iso-8859-1').'</pre>'; |
|
| 1905 | 1904 | |
| 1906 | 1905 | } |
| 1907 | 1906 | |
@@ -1914,10 +1913,10 @@ discard block |
||
| 1914 | 1913 | { |
| 1915 | 1914 | if (is_null($_requesteddata)) $_requesteddata = $_GET; |
| 1916 | 1915 | |
| 1917 | - $preventRedirect=false; |
|
| 1918 | - if(isset($_requesteddata['id'])) $rowID = $_requesteddata['id']; |
|
| 1919 | - if(isset($_requesteddata['part'])) $partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null; |
|
| 1920 | - if(isset($_requesteddata['mode'])) $preventRedirect = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false); |
|
| 1916 | + $preventRedirect = false; |
|
| 1917 | + if (isset($_requesteddata['id'])) $rowID = $_requesteddata['id']; |
|
| 1918 | + if (isset($_requesteddata['part'])) $partID = $_requesteddata['part'] != 'null' ? $_requesteddata['part'] : null; |
|
| 1919 | + if (isset($_requesteddata['mode'])) $preventRedirect = (($_requesteddata['mode'] == 'display' || $_requesteddata['mode'] == 'print') ? true : false); |
|
| 1921 | 1920 | |
| 1922 | 1921 | $hA = self::splitRowID($rowID); |
| 1923 | 1922 | $uid = $hA['msgUID']; |
@@ -1941,79 +1940,79 @@ discard block |
||
| 1941 | 1940 | } |
| 1942 | 1941 | if (!$preventRedirect && ($this->mail_bo->isDraftFolder($mailbox) || $this->mail_bo->isTemplateFolder($mailbox))) |
| 1943 | 1942 | { |
| 1944 | - Egw::redirect_link('/index.php',array('menuaction'=>'mail.mail_compose.compose','id'=>$rowID,'from'=>'composefromdraft')); |
|
| 1943 | + Egw::redirect_link('/index.php', array('menuaction'=>'mail.mail_compose.compose', 'id'=>$rowID, 'from'=>'composefromdraft')); |
|
| 1945 | 1944 | } |
| 1946 | 1945 | $this->mail_bo->reopen($mailbox); |
| 1947 | 1946 | // retrieve the flags of the message, before touching it. |
| 1948 | 1947 | try |
| 1949 | 1948 | { |
| 1950 | - $headers = $this->mail_bo->getMessageHeader($uid, $partID,true,true,$mailbox); |
|
| 1949 | + $headers = $this->mail_bo->getMessageHeader($uid, $partID, true, true, $mailbox); |
|
| 1951 | 1950 | } |
| 1952 | 1951 | catch (Api\Exception $e) |
| 1953 | 1952 | { |
| 1954 | 1953 | $error_msg[] = lang("ERROR: Message could not be displayed."); |
| 1955 | - $error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3",$mailbox,$uid,$partID); |
|
| 1954 | + $error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3", $mailbox, $uid, $partID); |
|
| 1956 | 1955 | Framework::message($e->getMessage(), 'error'); |
| 1957 | 1956 | } |
| 1958 | 1957 | if (!empty($uid)) $this->mail_bo->getFlags($uid); |
| 1959 | - $envelope = $this->mail_bo->getMessageEnvelope($uid, $partID,true,$mailbox); |
|
| 1958 | + $envelope = $this->mail_bo->getMessageEnvelope($uid, $partID, true, $mailbox); |
|
| 1960 | 1959 | //error_log(__METHOD__.__LINE__.array2string($envelope)); |
| 1961 | - $this->mail_bo->getMessageRawHeader($uid, $partID,$mailbox); |
|
| 1960 | + $this->mail_bo->getMessageRawHeader($uid, $partID, $mailbox); |
|
| 1962 | 1961 | $fetchEmbeddedImages = false; |
| 1963 | 1962 | // if we are in HTML so its likely that we should show the embedded images; as a result |
| 1964 | 1963 | // we do NOT want to see those, that are embedded in the list of attachments |
| 1965 | - if ($htmlOptions !='always_display') $fetchEmbeddedImages = true; |
|
| 1966 | - $attachments = $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages,true,true,$mailbox); |
|
| 1964 | + if ($htmlOptions != 'always_display') $fetchEmbeddedImages = true; |
|
| 1965 | + $attachments = $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages, true, true, $mailbox); |
|
| 1967 | 1966 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
| 1968 | 1967 | $attachmentHTMLBlock = self::createAttachmentBlock($attachments, $rowID, $uid, $mailbox); |
| 1969 | 1968 | |
| 1970 | - $nonDisplayAbleCharacters = array('[\016]','[\017]', |
|
| 1971 | - '[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]', |
|
| 1972 | - '[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]'); |
|
| 1969 | + $nonDisplayAbleCharacters = array('[\016]', '[\017]', |
|
| 1970 | + '[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]', |
|
| 1971 | + '[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]'); |
|
| 1973 | 1972 | |
| 1974 | 1973 | //error_log(__METHOD__.__LINE__.$mailBody); |
| 1975 | 1974 | $this->mail_bo->closeConnection(); |
| 1976 | 1975 | //$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed |
| 1977 | 1976 | $etpl = new Etemplate('mail.display'); |
| 1978 | - $subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters,'',$envelope['SUBJECT']),false); |
|
| 1977 | + $subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters, '', $envelope['SUBJECT']), false); |
|
| 1979 | 1978 | |
| 1980 | 1979 | // Set up data for taglist widget(s) |
| 1981 | - if ($envelope['FROM']==$envelope['SENDER']) unset($envelope['SENDER']); |
|
| 1980 | + if ($envelope['FROM'] == $envelope['SENDER']) unset($envelope['SENDER']); |
|
| 1982 | 1981 | $sel_options = array(); |
| 1983 | - foreach(array('SENDER','FROM','TO','CC','BCC') as $field) |
|
| 1982 | + foreach (array('SENDER', 'FROM', 'TO', 'CC', 'BCC') as $field) |
|
| 1984 | 1983 | { |
| 1985 | 1984 | if (!isset($envelope[$field])) continue; |
| 1986 | - foreach($envelope[$field] as $field_data) |
|
| 1985 | + foreach ($envelope[$field] as $field_data) |
|
| 1987 | 1986 | { |
| 1988 | 1987 | //error_log(__METHOD__.__LINE__.array2string($field_data)); |
| 1989 | 1988 | $content[$field][] = $field_data; |
| 1990 | 1989 | $sel_options[$field][] = array( |
| 1991 | 1990 | // taglist requires these - not optional |
| 1992 | 1991 | 'id' => $field_data, |
| 1993 | - 'label' => str_replace('"',"'",$field_data), |
|
| 1992 | + 'label' => str_replace('"', "'", $field_data), |
|
| 1994 | 1993 | ); |
| 1995 | 1994 | } |
| 1996 | 1995 | } |
| 1997 | 1996 | $actionsenabled = $this->getDisplayToolbarActions(); |
| 1998 | 1997 | $content['displayToolbaractions'] = json_encode($actionsenabled); |
| 1999 | 1998 | if (empty($subject)) $subject = lang('no subject'); |
| 2000 | - $content['msg'] = (is_array($error_msg)?implode("<br>",$error_msg):$error_msg); |
|
| 1999 | + $content['msg'] = (is_array($error_msg) ? implode("<br>", $error_msg) : $error_msg); |
|
| 2001 | 2000 | // Send mail ID so we can use it for actions |
| 2002 | 2001 | $content['mail_id'] = $rowID; |
| 2003 | 2002 | if (!is_array($headers) || !isset($headers['DATE'])) |
| 2004 | 2003 | { |
| 2005 | - $headers['DATE'] = (is_array($envelope)&&$envelope['DATE']?$envelope['DATE']:''); |
|
| 2004 | + $headers['DATE'] = (is_array($envelope) && $envelope['DATE'] ? $envelope['DATE'] : ''); |
|
| 2006 | 2005 | } |
| 2007 | - $content['mail_displaydate'] = Mail::_strtotime($headers['DATE'],'ts',true); |
|
| 2006 | + $content['mail_displaydate'] = Mail::_strtotime($headers['DATE'], 'ts', true); |
|
| 2008 | 2007 | $content['mail_displaysubject'] = $subject; |
| 2009 | - $linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody","_messageID"=>$rowID); |
|
| 2010 | - if (!empty($partID)) $linkData['_partID']=$partID; |
|
| 2011 | - if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions']=$htmlOptions; |
|
| 2012 | - $content['mailDisplayBodySrc'] = Egw::link('/index.php',$linkData); |
|
| 2008 | + $linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody", "_messageID"=>$rowID); |
|
| 2009 | + if (!empty($partID)) $linkData['_partID'] = $partID; |
|
| 2010 | + if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions'] = $htmlOptions; |
|
| 2011 | + $content['mailDisplayBodySrc'] = Egw::link('/index.php', $linkData); |
|
| 2013 | 2012 | $content['mail_displayattachments'] = $attachmentHTMLBlock; |
| 2014 | - $content['mail_id']=$rowID; |
|
| 2015 | - $content['mailDisplayContainerClass']=(count($attachments)?"mailDisplayContainer mailDisplayContainerFixedHeight":"mailDisplayContainer mailDisplayContainerFullHeight"); |
|
| 2016 | - $content['mailDisplayAttachmentsClass']=(count($attachments)?"mailDisplayAttachments":"mail_DisplayNone"); |
|
| 2013 | + $content['mail_id'] = $rowID; |
|
| 2014 | + $content['mailDisplayContainerClass'] = (count($attachments) ? "mailDisplayContainer mailDisplayContainerFixedHeight" : "mailDisplayContainer mailDisplayContainerFullHeight"); |
|
| 2015 | + $content['mailDisplayAttachmentsClass'] = (count($attachments) ? "mailDisplayAttachments" : "mail_DisplayNone"); |
|
| 2017 | 2016 | |
| 2018 | 2017 | // DRAG attachments actions |
| 2019 | 2018 | $etpl->setElementAttribute('mail_displayattachments', 'actions', array( |
@@ -2030,22 +2029,22 @@ discard block |
||
| 2030 | 2029 | $this->changeProfile($rememberServerID); |
| 2031 | 2030 | } |
| 2032 | 2031 | |
| 2033 | - $etpl->exec('mail.mail_ui.displayMessage',$content,$sel_options,$readonlys,$preserv,2); |
|
| 2032 | + $etpl->exec('mail.mail_ui.displayMessage', $content, $sel_options, $readonlys, $preserv, 2); |
|
| 2034 | 2033 | } |
| 2035 | 2034 | |
| 2036 | 2035 | /** |
| 2037 | 2036 | * Build actions for display toolbar |
| 2038 | 2037 | */ |
| 2039 | - function getDisplayToolbarActions () |
|
| 2038 | + function getDisplayToolbarActions() |
|
| 2040 | 2039 | { |
| 2041 | 2040 | $actions = $this->get_toolbar_actions(); |
| 2042 | - $actions['mark']['children']['flagged']=array( |
|
| 2041 | + $actions['mark']['children']['flagged'] = array( |
|
| 2043 | 2042 | 'group' => $actions['mark']['children']['flagged']['group'], |
| 2044 | 2043 | 'caption' => 'Flagged', |
| 2045 | 2044 | 'icon' => 'unread_flagged_small', |
| 2046 | 2045 | 'onExecute' => 'javaScript:app.mail.mail_flag', |
| 2047 | 2046 | ); |
| 2048 | - $actions['mark']['children']['unflagged']=array( |
|
| 2047 | + $actions['mark']['children']['unflagged'] = array( |
|
| 2049 | 2048 | 'group' => $actions['mark']['children']['flagged']['group'], |
| 2050 | 2049 | 'caption' => 'Unflagged', |
| 2051 | 2050 | 'icon' => 'read_flagged_small', |
@@ -2057,9 +2056,9 @@ discard block |
||
| 2057 | 2056 | $compose = $actions['composeasnew']; |
| 2058 | 2057 | unset($actions['composeasnew']); |
| 2059 | 2058 | |
| 2060 | - $actions2 = array_reverse($actions,true); |
|
| 2061 | - $actions2['composeasnew']= $compose; |
|
| 2062 | - return array_reverse($actions2,true); |
|
| 2059 | + $actions2 = array_reverse($actions, true); |
|
| 2060 | + $actions2['composeasnew'] = $compose; |
|
| 2061 | + return array_reverse($actions2, true); |
|
| 2063 | 2062 | } |
| 2064 | 2063 | |
| 2065 | 2064 | /** |
@@ -2072,22 +2071,22 @@ discard block |
||
| 2072 | 2071 | * @param boolean $_returnFullHTML flag wether to return HTML or data array |
| 2073 | 2072 | * @return array|string data array or html or empty string |
| 2074 | 2073 | */ |
| 2075 | - static function createAttachmentBlock($attachments, $rowID, $uid, $mailbox,$_returnFullHTML=false) |
|
| 2074 | + static function createAttachmentBlock($attachments, $rowID, $uid, $mailbox, $_returnFullHTML = false) |
|
| 2076 | 2075 | { |
| 2077 | - $attachmentHTMLBlock=''; |
|
| 2076 | + $attachmentHTMLBlock = ''; |
|
| 2078 | 2077 | $attachmentHTML = array(); |
| 2079 | 2078 | if (is_array($attachments) && count($attachments) > 0) { |
| 2080 | - $url_img_vfs = Api\Html::image('filemanager','navbar', lang('Filemanager'), ' height="16"'); |
|
| 2081 | - $url_img_vfs_save_all = Api\Html::image('mail','save_all', lang('Save all')); |
|
| 2079 | + $url_img_vfs = Api\Html::image('filemanager', 'navbar', lang('Filemanager'), ' height="16"'); |
|
| 2080 | + $url_img_vfs_save_all = Api\Html::image('mail', 'save_all', lang('Save all')); |
|
| 2082 | 2081 | |
| 2083 | 2082 | foreach ($attachments as $key => $value) |
| 2084 | 2083 | { |
| 2085 | - $attachmentHTML[$key]['filename']= ($value['name'] ? ( $value['filename'] ? $value['filename'] : $value['name'] ) : lang('(no subject)')); |
|
| 2086 | - $attachmentHTML[$key]['filename'] = Api\Translation::convert_jsonsafe($attachmentHTML[$key]['filename'],'utf-8'); |
|
| 2084 | + $attachmentHTML[$key]['filename'] = ($value['name'] ? ($value['filename'] ? $value['filename'] : $value['name']) : lang('(no subject)')); |
|
| 2085 | + $attachmentHTML[$key]['filename'] = Api\Translation::convert_jsonsafe($attachmentHTML[$key]['filename'], 'utf-8'); |
|
| 2087 | 2086 | //error_log(array2string($value)); |
| 2088 | 2087 | //error_log(strtoupper($value['mimeType']) .'<->'. Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename'])); |
| 2089 | - if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) $value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']); |
|
| 2090 | - $attachmentHTML[$key]['type']=$value['mimeType']; |
|
| 2088 | + if (strtoupper($value['mimeType'] == 'APPLICATION/OCTET-STREAM')) $value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']); |
|
| 2089 | + $attachmentHTML[$key]['type'] = $value['mimeType']; |
|
| 2091 | 2090 | $attachmentHTML[$key]['mimetype'] = Api\MimeMagic::mime2label($value['mimeType']); |
| 2092 | 2091 | $hA = self::splitRowID($rowID); |
| 2093 | 2092 | $uid = $hA['msgUID']; |
@@ -2097,26 +2096,25 @@ discard block |
||
| 2097 | 2096 | $attachmentHTML[$key]['mime_data'] = Link::set_data($value['mimeType'], 'EGroupware\\Api\\Mail::getAttachmentAccount', array( |
| 2098 | 2097 | $acc_id, $mailbox, $uid, $value['partID'], $value['is_winmail'], true |
| 2099 | 2098 | )); |
| 2100 | - $attachmentHTML[$key]['size']=Vfs::hsize($value['size']); |
|
| 2101 | - $attachmentHTML[$key]['attachment_number']=$key; |
|
| 2102 | - $attachmentHTML[$key]['partID']=$value['partID']; |
|
| 2099 | + $attachmentHTML[$key]['size'] = Vfs::hsize($value['size']); |
|
| 2100 | + $attachmentHTML[$key]['attachment_number'] = $key; |
|
| 2101 | + $attachmentHTML[$key]['partID'] = $value['partID']; |
|
| 2103 | 2102 | $attachmentHTML[$key]['mail_id'] = $rowID; |
| 2104 | - $attachmentHTML[$key]['winmailFlag']=$value['is_winmail']; |
|
| 2103 | + $attachmentHTML[$key]['winmailFlag'] = $value['is_winmail']; |
|
| 2105 | 2104 | $attachmentHTML[$key]['classSaveAllPossiblyDisabled'] = "mail_DisplayNone"; |
| 2106 | 2105 | |
| 2107 | - switch(strtoupper($value['mimeType'])) |
|
| 2106 | + switch (strtoupper($value['mimeType'])) |
|
| 2108 | 2107 | { |
| 2109 | 2108 | case 'MESSAGE/RFC822': |
| 2110 | - $linkData = array |
|
| 2111 | - ( |
|
| 2109 | + $linkData = array( |
|
| 2112 | 2110 | 'menuaction' => 'mail.mail_ui.displayMessage', |
| 2113 | 2111 | 'mode' => 'display', //message/rfc822 attachments should be opened in display mode |
| 2114 | 2112 | 'id' => $rowID, |
| 2115 | 2113 | 'part' => $value['partID'], |
| 2116 | 2114 | 'is_winmail' => $value['is_winmail'] |
| 2117 | 2115 | ); |
| 2118 | - $windowName = 'displayMessage_'. $rowID.'_'.$value['partID']; |
|
| 2119 | - $linkView = "egw_openWindowCentered('".Egw::link('/index.php',$linkData)."','$windowName',700,egw_getWindowOuterHeight());"; |
|
| 2116 | + $windowName = 'displayMessage_'.$rowID.'_'.$value['partID']; |
|
| 2117 | + $linkView = "egw_openWindowCentered('".Egw::link('/index.php', $linkData)."','$windowName',700,egw_getWindowOuterHeight());"; |
|
| 2120 | 2118 | break; |
| 2121 | 2119 | case 'IMAGE/JPEG': |
| 2122 | 2120 | case 'IMAGE/PNG': |
@@ -2127,7 +2125,7 @@ discard block |
||
| 2127 | 2125 | case 'TEXT/HTML': |
| 2128 | 2126 | case 'TEXT/DIRECTORY': |
| 2129 | 2127 | $sfxMimeType = $value['mimeType']; |
| 2130 | - $buff = explode('.',$value['name']); |
|
| 2128 | + $buff = explode('.', $value['name']); |
|
| 2131 | 2129 | $suffix = ''; |
| 2132 | 2130 | if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
| 2133 | 2131 | if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix); |
@@ -2140,49 +2138,47 @@ discard block |
||
| 2140 | 2138 | case 'TEXT/VCARD': |
| 2141 | 2139 | case 'TEXT/CALENDAR': |
| 2142 | 2140 | case 'TEXT/X-VCALENDAR': |
| 2143 | - $linkData = array |
|
| 2144 | - ( |
|
| 2141 | + $linkData = array( |
|
| 2145 | 2142 | 'menuaction' => 'mail.mail_ui.getAttachment', |
| 2146 | 2143 | 'id' => $rowID, |
| 2147 | 2144 | 'part' => $value['partID'], |
| 2148 | 2145 | 'is_winmail' => $value['is_winmail'], |
| 2149 | 2146 | 'mailbox' => base64_encode($mailbox), |
| 2150 | 2147 | ); |
| 2151 | - $windowName = 'displayAttachment_'. $uid; |
|
| 2148 | + $windowName = 'displayAttachment_'.$uid; |
|
| 2152 | 2149 | $reg = '800x600'; |
| 2153 | 2150 | // handle calendar/vcard |
| 2154 | - if (strtoupper($value['mimeType'])=='TEXT/CALENDAR') |
|
| 2151 | + if (strtoupper($value['mimeType']) == 'TEXT/CALENDAR') |
|
| 2155 | 2152 | { |
| 2156 | - $windowName = 'displayEvent_'. $rowID; |
|
| 2157 | - $reg2 = Link::get_registry('calendar','view_popup'); |
|
| 2158 | - $attachmentHTML[$key]['popup']=(!empty($reg2) ? $reg2 : $reg); |
|
| 2153 | + $windowName = 'displayEvent_'.$rowID; |
|
| 2154 | + $reg2 = Link::get_registry('calendar', 'view_popup'); |
|
| 2155 | + $attachmentHTML[$key]['popup'] = (!empty($reg2) ? $reg2 : $reg); |
|
| 2159 | 2156 | } |
| 2160 | - if (strtoupper($value['mimeType'])=='TEXT/X-VCARD' || strtoupper($value['mimeType'])=='TEXT/VCARD') |
|
| 2157 | + if (strtoupper($value['mimeType']) == 'TEXT/X-VCARD' || strtoupper($value['mimeType']) == 'TEXT/VCARD') |
|
| 2161 | 2158 | { |
| 2162 | - $windowName = 'displayContact_'. $rowID; |
|
| 2163 | - $reg2 = Link::get_registry('addressbook','add_popup'); |
|
| 2164 | - $attachmentHTML[$key]['popup']=(!empty($reg2) ? $reg2 : $reg); |
|
| 2159 | + $windowName = 'displayContact_'.$rowID; |
|
| 2160 | + $reg2 = Link::get_registry('addressbook', 'add_popup'); |
|
| 2161 | + $attachmentHTML[$key]['popup'] = (!empty($reg2) ? $reg2 : $reg); |
|
| 2165 | 2162 | } |
| 2166 | 2163 | // apply to action |
| 2167 | - list($width,$height) = explode('x',(!empty($reg2) ? $reg2 : $reg)); |
|
| 2168 | - $linkView = "egw_openWindowCentered('".Egw::link('/index.php',$linkData)."','$windowName',$width,$height);"; |
|
| 2164 | + list($width, $height) = explode('x', (!empty($reg2) ? $reg2 : $reg)); |
|
| 2165 | + $linkView = "egw_openWindowCentered('".Egw::link('/index.php', $linkData)."','$windowName',$width,$height);"; |
|
| 2169 | 2166 | break; |
| 2170 | 2167 | default: |
| 2171 | - $linkData = array |
|
| 2172 | - ( |
|
| 2168 | + $linkData = array( |
|
| 2173 | 2169 | 'menuaction' => 'mail.mail_ui.getAttachment', |
| 2174 | 2170 | 'id' => $rowID, |
| 2175 | 2171 | 'part' => $value['partID'], |
| 2176 | 2172 | 'is_winmail' => $value['is_winmail'], |
| 2177 | 2173 | 'mailbox' => base64_encode($mailbox), |
| 2178 | 2174 | ); |
| 2179 | - $linkView = "window.location.href = '".Egw::link('/index.php',$linkData)."';"; |
|
| 2175 | + $linkView = "window.location.href = '".Egw::link('/index.php', $linkData)."';"; |
|
| 2180 | 2176 | break; |
| 2181 | 2177 | } |
| 2182 | 2178 | // we either use mime_data for server-side supported mime-types or mime_url for client-side or download |
| 2183 | 2179 | if (empty($attachmentHTML[$key]['mime_data'])) |
| 2184 | 2180 | { |
| 2185 | - $attachmentHTML[$key]['mime_url'] = Egw::link('/index.php',$linkData); |
|
| 2181 | + $attachmentHTML[$key]['mime_url'] = Egw::link('/index.php', $linkData); |
|
| 2186 | 2182 | unset($attachmentHTML[$key]['mime_data']); |
| 2187 | 2183 | } |
| 2188 | 2184 | $attachmentHTML[$key]['windowName'] = $windowName; |
@@ -2192,8 +2188,7 @@ discard block |
||
| 2192 | 2188 | ($value['name'] ? $value['name'] : lang('(no subject)')). |
| 2193 | 2189 | '</b></a>'; |
| 2194 | 2190 | |
| 2195 | - $linkData = array |
|
| 2196 | - ( |
|
| 2191 | + $linkData = array( |
|
| 2197 | 2192 | 'menuaction' => 'mail.mail_ui.getAttachment', |
| 2198 | 2193 | 'mode' => 'save', |
| 2199 | 2194 | 'id' => $rowID, |
@@ -2201,11 +2196,11 @@ discard block |
||
| 2201 | 2196 | 'is_winmail' => $value['is_winmail'], |
| 2202 | 2197 | 'mailbox' => base64_encode($mailbox), |
| 2203 | 2198 | ); |
| 2204 | - $attachmentHTML[$key]['link_save'] ="<a href='".Egw::link('/index.php',$linkData)."' title='".$attachmentHTML[$key]['filename']."'>".Api\Html::image('mail','fileexport')."</a>"; |
|
| 2199 | + $attachmentHTML[$key]['link_save'] = "<a href='".Egw::link('/index.php', $linkData)."' title='".$attachmentHTML[$key]['filename']."'>".Api\Html::image('mail', 'fileexport')."</a>"; |
|
| 2205 | 2200 | |
| 2206 | 2201 | if ($GLOBALS['egw_info']['user']['apps']['filemanager']) |
| 2207 | 2202 | { |
| 2208 | - $link_vfs_save = Egw::link('/index.php',array( |
|
| 2203 | + $link_vfs_save = Egw::link('/index.php', array( |
|
| 2209 | 2204 | 'menuaction' => 'filemanager.filemanager_select.select', |
| 2210 | 2205 | 'mode' => 'saveas', |
| 2211 | 2206 | 'name' => $value['name'], |
@@ -2224,19 +2219,19 @@ discard block |
||
| 2224 | 2219 | //$rowID |
| 2225 | 2220 | $ids["id[$ikey]"] = $rowID.'::'.$value['partID'].'::'.$value['is_winmail'].'::'.$value['name']; |
| 2226 | 2221 | } |
| 2227 | - $link_vfs_save = Egw::link('/index.php',array( |
|
| 2222 | + $link_vfs_save = Egw::link('/index.php', array( |
|
| 2228 | 2223 | 'menuaction' => 'filemanager.filemanager_select.select', |
| 2229 | 2224 | 'mode' => 'select-dir', |
| 2230 | 2225 | 'method' => 'mail.mail_ui.vfsSaveAttachment', |
| 2231 | 2226 | 'label' => lang('Save all'), |
| 2232 | - )+$ids); |
|
| 2227 | + ) + $ids); |
|
| 2233 | 2228 | $vfs_save .= "<a href='#' onclick=\"egw_openWindowCentered('$link_vfs_save','vfs_save_attachment','640','530',window.outerWidth/2,window.outerHeight/2); return false;\">$url_img_vfs_save_all</a>"; |
| 2234 | 2229 | } |
| 2235 | 2230 | $attachmentHTML[$key]['link_save'] .= $vfs_save; |
| 2236 | 2231 | //error_log(__METHOD__.__LINE__.$attachmentHTML[$key]['link_save']); |
| 2237 | 2232 | } |
| 2238 | 2233 | } |
| 2239 | - $attachmentHTMLBlock="<table width='100%'>"; |
|
| 2234 | + $attachmentHTMLBlock = "<table width='100%'>"; |
|
| 2240 | 2235 | foreach ((array)$attachmentHTML as $row) |
| 2241 | 2236 | { |
| 2242 | 2237 | $attachmentHTMLBlock .= "<tr><td><div class='useEllipsis'>".$row['link_view'].'</div></td>'; |
@@ -2254,7 +2249,7 @@ discard block |
||
| 2254 | 2249 | unset($attachmentHTML[$ikey]['link_save']); |
| 2255 | 2250 | } |
| 2256 | 2251 | } |
| 2257 | - return ($_returnFullHTML?$attachmentHTMLBlock:$attachmentHTML); |
|
| 2252 | + return ($_returnFullHTML ? $attachmentHTMLBlock : $attachmentHTML); |
|
| 2258 | 2253 | } |
| 2259 | 2254 | |
| 2260 | 2255 | /** |
@@ -2265,7 +2260,7 @@ discard block |
||
| 2265 | 2260 | */ |
| 2266 | 2261 | function gatherVacation($cachedVacations = array()) |
| 2267 | 2262 | { |
| 2268 | - $isVacationEnabled = $this->mail_bo->icServer->acc_sieve_enabled && ($this->mail_bo->icServer->acc_sieve_host||$this->mail_bo->icServer->acc_imap_host); |
|
| 2263 | + $isVacationEnabled = $this->mail_bo->icServer->acc_sieve_enabled && ($this->mail_bo->icServer->acc_sieve_host || $this->mail_bo->icServer->acc_imap_host); |
|
| 2269 | 2264 | //error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation)); |
| 2270 | 2265 | |
| 2271 | 2266 | if ($isVacationEnabled) |
@@ -2278,7 +2273,7 @@ discard block |
||
| 2278 | 2273 | |
| 2279 | 2274 | $cachedVacations = array($sieveServer->acc_id => $vacation) + (array)$cachedVacations; |
| 2280 | 2275 | // Set vacation to the instance cache for particular account with expiration of one day |
| 2281 | - Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations, 60*60*24); |
|
| 2276 | + Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations, 60 * 60 * 24); |
|
| 2282 | 2277 | } |
| 2283 | 2278 | catch (PEAR_Exception $ex) |
| 2284 | 2279 | { |
@@ -2299,36 +2294,36 @@ discard block |
||
| 2299 | 2294 | function quotaDisplay($_usage, $_limit) |
| 2300 | 2295 | { |
| 2301 | 2296 | |
| 2302 | - if($_limit == 0) { |
|
| 2303 | - $quotaPercent=100; |
|
| 2297 | + if ($_limit == 0) { |
|
| 2298 | + $quotaPercent = 100; |
|
| 2304 | 2299 | } else { |
| 2305 | - $quotaPercent=round(($_usage*100)/$_limit); |
|
| 2300 | + $quotaPercent = round(($_usage * 100) / $_limit); |
|
| 2306 | 2301 | } |
| 2307 | 2302 | |
| 2308 | - $quotaLimit=Mail::show_readable_size($_limit*1024); |
|
| 2309 | - $quotaUsage=Mail::show_readable_size($_usage*1024); |
|
| 2303 | + $quotaLimit = Mail::show_readable_size($_limit * 1024); |
|
| 2304 | + $quotaUsage = Mail::show_readable_size($_usage * 1024); |
|
| 2310 | 2305 | |
| 2311 | 2306 | |
| 2312 | - if($quotaPercent > 90 && $_limit>0) { |
|
| 2313 | - $quotaBG='mail-index_QuotaRed'; |
|
| 2314 | - } elseif($quotaPercent > 80 && $_limit>0) { |
|
| 2315 | - $quotaBG='mail-index_QuotaYellow'; |
|
| 2307 | + if ($quotaPercent > 90 && $_limit > 0) { |
|
| 2308 | + $quotaBG = 'mail-index_QuotaRed'; |
|
| 2309 | + } elseif ($quotaPercent > 80 && $_limit > 0) { |
|
| 2310 | + $quotaBG = 'mail-index_QuotaYellow'; |
|
| 2316 | 2311 | } else { |
| 2317 | - $quotaBG='mail-index_QuotaGreen'; |
|
| 2312 | + $quotaBG = 'mail-index_QuotaGreen'; |
|
| 2318 | 2313 | } |
| 2319 | 2314 | |
| 2320 | - if($_limit > 0) { |
|
| 2321 | - $quotaText = $quotaUsage .'/'.$quotaLimit; |
|
| 2315 | + if ($_limit > 0) { |
|
| 2316 | + $quotaText = $quotaUsage.'/'.$quotaLimit; |
|
| 2322 | 2317 | } else { |
| 2323 | 2318 | $quotaText = $quotaUsage; |
| 2324 | 2319 | } |
| 2325 | 2320 | |
| 2326 | - if($quotaPercent > 50) { |
|
| 2321 | + if ($quotaPercent > 50) { |
|
| 2327 | 2322 | } else { |
| 2328 | 2323 | } |
| 2329 | 2324 | $quota['class'] = $quotaBG; |
| 2330 | - $quota['text'] = lang('Quota: %1',$quotaText); |
|
| 2331 | - $quota['percent'] = (string)round(($_usage*100)/$_limit); |
|
| 2325 | + $quota['text'] = lang('Quota: %1', $quotaText); |
|
| 2326 | + $quota['percent'] = (string)round(($_usage * 100) / $_limit); |
|
| 2332 | 2327 | return $quota; |
| 2333 | 2328 | } |
| 2334 | 2329 | |
@@ -2342,12 +2337,12 @@ discard block |
||
| 2342 | 2337 | $uid = $_GET['uid']; |
| 2343 | 2338 | $cid = base64_decode($_GET['cid']); |
| 2344 | 2339 | $partID = urldecode($_GET['partID']); |
| 2345 | - if (!empty($_GET['mailbox'])) $mailbox = base64_decode($_GET['mailbox']); |
|
| 2340 | + if (!empty($_GET['mailbox'])) $mailbox = base64_decode($_GET['mailbox']); |
|
| 2346 | 2341 | |
| 2347 | 2342 | //error_log(__METHOD__.__LINE__.":$uid, $cid, $partID"); |
| 2348 | 2343 | $this->mail_bo->reopen($mailbox); |
| 2349 | 2344 | |
| 2350 | - $attachment = $this->mail_bo->getAttachmentByCID($uid, $cid, $partID, true); // true get contents as stream |
|
| 2345 | + $attachment = $this->mail_bo->getAttachmentByCID($uid, $cid, $partID, true); // true get contents as stream |
|
| 2351 | 2346 | |
| 2352 | 2347 | $this->mail_bo->closeConnection(); |
| 2353 | 2348 | |
@@ -2355,8 +2350,8 @@ discard block |
||
| 2355 | 2350 | |
| 2356 | 2351 | if ($attachment) |
| 2357 | 2352 | { |
| 2358 | - header("Content-Type: ". $attachment->getType()); |
|
| 2359 | - header('Content-Disposition: inline; filename="'. $attachment->getDispositionParameter('filename') .'"'); |
|
| 2353 | + header("Content-Type: ".$attachment->getType()); |
|
| 2354 | + header('Content-Disposition: inline; filename="'.$attachment->getDispositionParameter('filename').'"'); |
|
| 2360 | 2355 | //header("Expires: 0"); |
| 2361 | 2356 | // the next headers are for IE and SSL |
| 2362 | 2357 | //header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
@@ -2374,7 +2369,7 @@ discard block |
||
| 2374 | 2369 | |
| 2375 | 2370 | function getAttachment() |
| 2376 | 2371 | { |
| 2377 | - if(isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 2372 | + if (isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 2378 | 2373 | |
| 2379 | 2374 | $hA = self::splitRowID($rowID); |
| 2380 | 2375 | $uid = $hA['msgUID']; |
@@ -2386,11 +2381,11 @@ discard block |
||
| 2386 | 2381 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
| 2387 | 2382 | $this->changeProfile($icServerID); |
| 2388 | 2383 | } |
| 2389 | - $part = $_GET['part']; |
|
| 2384 | + $part = $_GET['part']; |
|
| 2390 | 2385 | $is_winmail = $_GET['is_winmail'] ? $_GET['is_winmail'] : 0; |
| 2391 | 2386 | |
| 2392 | 2387 | $this->mail_bo->reopen($mailbox); |
| 2393 | - $attachment = $this->mail_bo->getAttachment($uid,$part,$is_winmail,false); |
|
| 2388 | + $attachment = $this->mail_bo->getAttachment($uid, $part, $is_winmail, false); |
|
| 2394 | 2389 | $this->mail_bo->closeConnection(); |
| 2395 | 2390 | if ($rememberServerID != $this->mail_bo->profileID) |
| 2396 | 2391 | { |
@@ -2405,7 +2400,7 @@ discard block |
||
| 2405 | 2400 | if (strtoupper($attachment['type']) == 'TEXT/DIRECTORY' || empty($attachment['type'])) |
| 2406 | 2401 | { |
| 2407 | 2402 | $sfxMimeType = $attachment['type']; |
| 2408 | - $buff = explode('.',$attachment['filename']); |
|
| 2403 | + $buff = explode('.', $attachment['filename']); |
|
| 2409 | 2404 | $suffix = ''; |
| 2410 | 2405 | if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
| 2411 | 2406 | if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix); |
@@ -2417,10 +2412,10 @@ discard block |
||
| 2417 | 2412 | { |
| 2418 | 2413 | //error_log(__METHOD__."about to call calendar_ical"); |
| 2419 | 2414 | $calendar_ical = new calendar_ical(); |
| 2420 | - $eventid = $calendar_ical->search($attachment['attachment'],-1); |
|
| 2415 | + $eventid = $calendar_ical->search($attachment['attachment'], -1); |
|
| 2421 | 2416 | //error_log(__METHOD__.array2string($eventid)); |
| 2422 | 2417 | if (!$eventid) $eventid = -1; |
| 2423 | - $event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true,0,'',null,$attachment['charset']); |
|
| 2418 | + $event = $calendar_ical->importVCal($attachment['attachment'], (is_array($eventid) ? $eventid[0] : $eventid), null, true, 0, '', null, $attachment['charset']); |
|
| 2424 | 2419 | //error_log(__METHOD__.$event); |
| 2425 | 2420 | if ((int)$event > 0) |
| 2426 | 2421 | { |
@@ -2428,7 +2423,7 @@ discard block |
||
| 2428 | 2423 | 'menuaction' => 'calendar.calendar_uiforms.edit', |
| 2429 | 2424 | 'cal_id' => $event, |
| 2430 | 2425 | ); |
| 2431 | - Egw::redirect_link('../index.php',$vars); |
|
| 2426 | + Egw::redirect_link('../index.php', $vars); |
|
| 2432 | 2427 | } |
| 2433 | 2428 | //Import failed, download content anyway |
| 2434 | 2429 | } |
@@ -2443,13 +2438,13 @@ discard block |
||
| 2443 | 2438 | { |
| 2444 | 2439 | $vcard['uid'] = trim($vcard['uid']); |
| 2445 | 2440 | //error_log(__METHOD__.__LINE__.print_r($vcard,true)); |
| 2446 | - $contact = $addressbook_vcal->find_contact($vcard,false); |
|
| 2441 | + $contact = $addressbook_vcal->find_contact($vcard, false); |
|
| 2447 | 2442 | } |
| 2448 | 2443 | if (!$contact) $contact = null; |
| 2449 | 2444 | // if there are not enough fields in the vcard (or the parser was unable to correctly parse the vcard (as of VERSION:3.0 created by MSO)) |
| 2450 | - if ($contact || count($vcard)>2) |
|
| 2445 | + if ($contact || count($vcard) > 2) |
|
| 2451 | 2446 | { |
| 2452 | - $contact = $addressbook_vcal->addVCard($attachment['attachment'],(is_array($contact)?array_shift($contact):$contact),true,$attachment['charset']); |
|
| 2447 | + $contact = $addressbook_vcal->addVCard($attachment['attachment'], (is_array($contact) ? array_shift($contact) : $contact), true, $attachment['charset']); |
|
| 2453 | 2448 | } |
| 2454 | 2449 | if ((int)$contact > 0) |
| 2455 | 2450 | { |
@@ -2457,14 +2452,14 @@ discard block |
||
| 2457 | 2452 | 'menuaction' => 'addressbook.addressbook_ui.edit', |
| 2458 | 2453 | 'contact_id' => $contact, |
| 2459 | 2454 | ); |
| 2460 | - Egw::redirect_link('../index.php',$vars); |
|
| 2455 | + Egw::redirect_link('../index.php', $vars); |
|
| 2461 | 2456 | } |
| 2462 | 2457 | //Import failed, download content anyway |
| 2463 | 2458 | } |
| 2464 | 2459 | } |
| 2465 | 2460 | //error_log(__METHOD__.__LINE__.'->'.array2string($attachment)); |
| 2466 | - $filename = ($attachment['name']?$attachment['name']:($attachment['filename']?$attachment['filename']:$mailbox.'_uid'.$uid.'_part'.$part)); |
|
| 2467 | - Api\Header\Content::safe($attachment['attachment'], $filename, $attachment['type'], $size=0, True, $_GET['mode'] == "save"); |
|
| 2461 | + $filename = ($attachment['name'] ? $attachment['name'] : ($attachment['filename'] ? $attachment['filename'] : $mailbox.'_uid'.$uid.'_part'.$part)); |
|
| 2462 | + Api\Header\Content::safe($attachment['attachment'], $filename, $attachment['type'], $size = 0, True, $_GET['mode'] == "save"); |
|
| 2468 | 2463 | echo $attachment['attachment']; |
| 2469 | 2464 | |
| 2470 | 2465 | exit(); |
@@ -2479,9 +2474,9 @@ discard block |
||
| 2479 | 2474 | function saveMessage() |
| 2480 | 2475 | { |
| 2481 | 2476 | $display = false; |
| 2482 | - if(isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 2483 | - if(isset($_GET['part'])) $partID = $_GET['part']; |
|
| 2484 | - if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager')) $display = $_GET['location']; |
|
| 2477 | + if (isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 2478 | + if (isset($_GET['part'])) $partID = $_GET['part']; |
|
| 2479 | + if (isset($_GET['location']) && ($_GET['location'] == 'display' || $_GET['location'] == 'filemanager')) $display = $_GET['location']; |
|
| 2485 | 2480 | |
| 2486 | 2481 | $hA = self::splitRowID($rowID); |
| 2487 | 2482 | $uid = $hA['msgUID']; |
@@ -2509,14 +2504,14 @@ discard block |
||
| 2509 | 2504 | if (!$display) |
| 2510 | 2505 | { |
| 2511 | 2506 | $headers = Horde_Mime_Headers::parseHeaders($message); |
| 2512 | - $subject = str_replace('$$','__',Mail::decode_header($headers['SUBJECT'])); |
|
| 2513 | - Api\Header\Content::safe($message, $subject.".eml", $mime='message/rfc822', $size=0, true, true); |
|
| 2507 | + $subject = str_replace('$$', '__', Mail::decode_header($headers['SUBJECT'])); |
|
| 2508 | + Api\Header\Content::safe($message, $subject.".eml", $mime = 'message/rfc822', $size = 0, true, true); |
|
| 2514 | 2509 | echo $message; |
| 2515 | 2510 | } |
| 2516 | 2511 | else |
| 2517 | 2512 | { |
| 2518 | - Api\Header\Content::safe($message, $subject.".eml", $mime='text/html', $size=0, true, false); |
|
| 2519 | - print '<pre>'. htmlspecialchars($message, ENT_NOQUOTES|ENT_SUBSTITUTE, 'utf-8') .'</pre>'; |
|
| 2513 | + Api\Header\Content::safe($message, $subject.".eml", $mime = 'text/html', $size = 0, true, false); |
|
| 2514 | + print '<pre>'.htmlspecialchars($message, ENT_NOQUOTES|ENT_SUBSTITUTE, 'utf-8').'</pre>'; |
|
| 2520 | 2515 | } |
| 2521 | 2516 | } |
| 2522 | 2517 | |
@@ -2528,18 +2523,18 @@ discard block |
||
| 2528 | 2523 | * @param boolean $close Return javascript to close the window |
| 2529 | 2524 | * @return string|boolean javascript eg. to close the selector window if $close is true, or success/fail if $close is false |
| 2530 | 2525 | */ |
| 2531 | - function vfsSaveMessage($ids,$path, $close = true) |
|
| 2526 | + function vfsSaveMessage($ids, $path, $close = true) |
|
| 2532 | 2527 | { |
| 2533 | 2528 | //error_log(__METHOD__.' IDs:'.array2string($ids).' SaveToPath:'.$path); |
| 2534 | 2529 | |
| 2535 | 2530 | if (is_array($ids) && !Vfs::is_writable($path) || !is_array($ids) && !Vfs::is_writable(dirname($path))) |
| 2536 | 2531 | { |
| 2537 | - return 'alert("'.addslashes(lang('%1 is NOT writable by you!',$path)).'"); Egw(window).close();'; |
|
| 2532 | + return 'alert("'.addslashes(lang('%1 is NOT writable by you!', $path)).'"); Egw(window).close();'; |
|
| 2538 | 2533 | } |
| 2539 | 2534 | Api\Translation::add_app('mail'); |
| 2540 | 2535 | |
| 2541 | 2536 | $rememberServerID = $this->mail_bo->profileID; |
| 2542 | - foreach((array)$ids as $id) |
|
| 2537 | + foreach ((array)$ids as $id) |
|
| 2543 | 2538 | { |
| 2544 | 2539 | $hA = self::splitRowID($id); |
| 2545 | 2540 | $uid = $hA['msgUID']; |
@@ -2550,20 +2545,20 @@ discard block |
||
| 2550 | 2545 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
| 2551 | 2546 | $this->changeProfile($icServerID); |
| 2552 | 2547 | } |
| 2553 | - $message = $this->mail_bo->getMessageRawBody($uid, $partID='', $mailbox); |
|
| 2554 | - $err=null; |
|
| 2555 | - if(Vfs::is_dir($path)) |
|
| 2548 | + $message = $this->mail_bo->getMessageRawBody($uid, $partID = '', $mailbox); |
|
| 2549 | + $err = null; |
|
| 2550 | + if (Vfs::is_dir($path)) |
|
| 2556 | 2551 | { |
| 2557 | - $headers = $this->mail_bo->getMessageHeader($uid,$partID,true,false,$mailbox); |
|
| 2558 | - $file = $path . '/'.preg_replace('/[\f\n\t\v\\:*#?<>\|]/',"_",$headers['SUBJECT']).'.eml'; |
|
| 2552 | + $headers = $this->mail_bo->getMessageHeader($uid, $partID, true, false, $mailbox); |
|
| 2553 | + $file = $path.'/'.preg_replace('/[\f\n\t\v\\:*#?<>\|]/', "_", $headers['SUBJECT']).'.eml'; |
|
| 2559 | 2554 | } |
| 2560 | 2555 | else |
| 2561 | 2556 | { |
| 2562 | 2557 | $file = $path; |
| 2563 | 2558 | } |
| 2564 | - if (!($fp = Vfs::fopen($file,'wb')) || !fwrite($fp,$message)) |
|
| 2559 | + if (!($fp = Vfs::fopen($file, 'wb')) || !fwrite($fp, $message)) |
|
| 2565 | 2560 | { |
| 2566 | - $err .= lang('Error saving %1!',$file); |
|
| 2561 | + $err .= lang('Error saving %1!', $file); |
|
| 2567 | 2562 | $succeeded = false; |
| 2568 | 2563 | } |
| 2569 | 2564 | else |
@@ -2573,10 +2568,10 @@ discard block |
||
| 2573 | 2568 | if ($fp) fclose($fp); |
| 2574 | 2569 | if ($succeeded) |
| 2575 | 2570 | { |
| 2576 | - unset($headers['SUBJECT']);//already in filename |
|
| 2571 | + unset($headers['SUBJECT']); //already in filename |
|
| 2577 | 2572 | $infoSection = Mail::createHeaderInfoSection($headers, 'SUPPRESS', false); |
| 2578 | - $props = array(array('name' => 'comment','val' => $infoSection)); |
|
| 2579 | - Vfs::proppatch($file,$props); |
|
| 2573 | + $props = array(array('name' => 'comment', 'val' => $infoSection)); |
|
| 2574 | + Vfs::proppatch($file, $props); |
|
| 2580 | 2575 | } |
| 2581 | 2576 | } |
| 2582 | 2577 | if ($rememberServerID != $this->mail_bo->profileID) |
@@ -2585,9 +2580,9 @@ discard block |
||
| 2585 | 2580 | $this->changeProfile($rememberServerID); |
| 2586 | 2581 | } |
| 2587 | 2582 | |
| 2588 | - if($close) |
|
| 2583 | + if ($close) |
|
| 2589 | 2584 | { |
| 2590 | - Framework::window_close(($err?$err:null)); |
|
| 2585 | + Framework::window_close(($err ? $err : null)); |
|
| 2591 | 2586 | } |
| 2592 | 2587 | else |
| 2593 | 2588 | { |
@@ -2602,15 +2597,15 @@ discard block |
||
| 2602 | 2597 | * @param string $path path in vfs (no Vfs::PREFIX!), only directory for multiple id's ($ids is an array) |
| 2603 | 2598 | * @return string javascript eg. to close the selector window |
| 2604 | 2599 | */ |
| 2605 | - function vfsSaveAttachment($ids,$path) |
|
| 2600 | + function vfsSaveAttachment($ids, $path) |
|
| 2606 | 2601 | { |
| 2607 | 2602 | //error_log(__METHOD__.__LINE__.'("'.array2string($ids).'","'.$path."\")');"); |
| 2608 | 2603 | |
| 2609 | 2604 | if (is_array($ids) && !Vfs::is_writable($path) || !is_array($ids) && !Vfs::is_writable(dirname($path))) |
| 2610 | 2605 | { |
| 2611 | - return 'alert("'.addslashes(lang('%1 is NOT writable by you!',$path)).'"); Egw(window).close();'; |
|
| 2606 | + return 'alert("'.addslashes(lang('%1 is NOT writable by you!', $path)).'"); Egw(window).close();'; |
|
| 2612 | 2607 | } |
| 2613 | - $err=null; |
|
| 2608 | + $err = null; |
|
| 2614 | 2609 | $dupe_count = array(); |
| 2615 | 2610 | $rememberServerID = $this->mail_bo->profileID; |
| 2616 | 2611 | |
@@ -2620,12 +2615,12 @@ discard block |
||
| 2620 | 2615 | * |
| 2621 | 2616 | * @return array an array of parameters |
| 2622 | 2617 | */ |
| 2623 | - $getParams = function ($id) { |
|
| 2624 | - list($app,$user,$serverID,$mailbox,$uid,$part,$is_winmail,$name) = explode('::',$id,8); |
|
| 2625 | - $lId = implode('::',array($app,$user,$serverID,$mailbox,$uid)); |
|
| 2618 | + $getParams = function($id) { |
|
| 2619 | + list($app, $user, $serverID, $mailbox, $uid, $part, $is_winmail, $name) = explode('::', $id, 8); |
|
| 2620 | + $lId = implode('::', array($app, $user, $serverID, $mailbox, $uid)); |
|
| 2626 | 2621 | $hA = mail_ui::splitRowID($lId); |
| 2627 | 2622 | return array( |
| 2628 | - 'is_winmail' => $is_winmail == "null" || !$is_winmail?false:$is_winmail, |
|
| 2623 | + 'is_winmail' => $is_winmail == "null" || !$is_winmail ? false : $is_winmail, |
|
| 2629 | 2624 | 'user' => $user, |
| 2630 | 2625 | 'name' => $name, |
| 2631 | 2626 | 'part' => $part, |
@@ -2637,8 +2632,8 @@ discard block |
||
| 2637 | 2632 | |
| 2638 | 2633 | //Examine the first attachment to see if attachment |
| 2639 | 2634 | //is winmail.dat embedded attachments. |
| 2640 | - $isMultipleDownload=is_array($ids); |
|
| 2641 | - $p = $getParams((is_array($ids)?$ids[0]:$ids)); |
|
| 2635 | + $isMultipleDownload = is_array($ids); |
|
| 2636 | + $p = $getParams((is_array($ids) ? $ids[0] : $ids)); |
|
| 2642 | 2637 | if ($p['is_winmail']) |
| 2643 | 2638 | { |
| 2644 | 2639 | if ($p['icServer'] && $p['icServer'] != $this->mail_bo->profileID) |
@@ -2649,14 +2644,14 @@ discard block |
||
| 2649 | 2644 | // Retrive all embedded attachments at once |
| 2650 | 2645 | // avoids to fetch heavy winmail.dat content |
| 2651 | 2646 | // for each file. |
| 2652 | - $attachments = $this->mail_bo->getTnefAttachments($p['uid'],$p['part']); |
|
| 2647 | + $attachments = $this->mail_bo->getTnefAttachments($p['uid'], $p['part']); |
|
| 2653 | 2648 | } |
| 2654 | 2649 | |
| 2655 | - foreach((array)$ids as $id) |
|
| 2650 | + foreach ((array)$ids as $id) |
|
| 2656 | 2651 | { |
| 2657 | 2652 | $params = $getParams($id); |
| 2658 | 2653 | // when downloading a single file, name is not set |
| 2659 | - if (!$params['name']&&isset($_GET['name'])&&!$isMultipleDownload) $params['name'] = $_GET['name']; |
|
| 2654 | + if (!$params['name'] && isset($_GET['name']) && !$isMultipleDownload) $params['name'] = $_GET['name']; |
|
| 2660 | 2655 | if ($params['icServer'] && $params['icServer'] != $this->mail_bo->profileID) |
| 2661 | 2656 | { |
| 2662 | 2657 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
@@ -2674,25 +2669,25 @@ discard block |
||
| 2674 | 2669 | } |
| 2675 | 2670 | else |
| 2676 | 2671 | { |
| 2677 | - $attachment = $this->mail_bo->getAttachment($params['uid'],$params['part'],$params['is_winmail'],false); |
|
| 2672 | + $attachment = $this->mail_bo->getAttachment($params['uid'], $params['part'], $params['is_winmail'], false); |
|
| 2678 | 2673 | } |
| 2679 | 2674 | |
| 2680 | 2675 | $file = $params['name']; |
| 2681 | 2676 | // when $isMultipleDownload the path holds no filename |
| 2682 | - while(Vfs::file_exists($path.($file && $isMultipleDownload ? '/'.$file : ''))) |
|
| 2677 | + while (Vfs::file_exists($path.($file && $isMultipleDownload ? '/'.$file : ''))) |
|
| 2683 | 2678 | { |
| 2684 | 2679 | $dupe_count[$params['name']]++; |
| 2685 | - $file = pathinfo($params['name'], PATHINFO_FILENAME) . |
|
| 2686 | - ' ('.($dupe_count[$params['name']] + 1).')' . '.' . |
|
| 2680 | + $file = pathinfo($params['name'], PATHINFO_FILENAME). |
|
| 2681 | + ' ('.($dupe_count[$params['name']] + 1).')'.'.'. |
|
| 2687 | 2682 | pathinfo($params['name'], PATHINFO_EXTENSION); |
| 2688 | 2683 | } |
| 2689 | 2684 | $params['name'] = $file; |
| 2690 | 2685 | //error_log(__METHOD__.__LINE__.array2string($attachment)); |
| 2691 | 2686 | // when $isMultipleDownload the path holds no filename |
| 2692 | - if (!($fp = Vfs::fopen($file=$path.($params['name'] && $isMultipleDownload ? '/'.$params['name'] : ''),'wb')) || |
|
| 2693 | - !fwrite($fp,$attachment['attachment'])) |
|
| 2687 | + if (!($fp = Vfs::fopen($file = $path.($params['name'] && $isMultipleDownload ? '/'.$params['name'] : ''), 'wb')) || |
|
| 2688 | + !fwrite($fp, $attachment['attachment'])) |
|
| 2694 | 2689 | { |
| 2695 | - $err .= lang('Error saving %1!',$file); |
|
| 2690 | + $err .= lang('Error saving %1!', $file); |
|
| 2696 | 2691 | } |
| 2697 | 2692 | if ($fp) |
| 2698 | 2693 | { |
@@ -2705,21 +2700,21 @@ discard block |
||
| 2705 | 2700 | //error_log(__METHOD__.__LINE__.' change Profile back to where we came from ->'.$rememberServerID); |
| 2706 | 2701 | $this->changeProfile($rememberServerID); |
| 2707 | 2702 | } |
| 2708 | - Framework::window_close(($err?$err:null)); |
|
| 2703 | + Framework::window_close(($err ? $err : null)); |
|
| 2709 | 2704 | } |
| 2710 | 2705 | |
| 2711 | 2706 | /** |
| 2712 | 2707 | * Zip all attachments and send to user |
| 2713 | 2708 | * @param string $message_id = null |
| 2714 | 2709 | */ |
| 2715 | - function download_zip($message_id=null) |
|
| 2710 | + function download_zip($message_id = null) |
|
| 2716 | 2711 | { |
| 2717 | 2712 | //error_log(__METHOD__.__LINE__.array2string($_GET)); |
| 2718 | 2713 | // First, get all attachment IDs |
| 2719 | - if(isset($_GET['id'])) $message_id = $_GET['id']; |
|
| 2714 | + if (isset($_GET['id'])) $message_id = $_GET['id']; |
|
| 2720 | 2715 | //error_log(__METHOD__.__LINE__.$message_id); |
| 2721 | 2716 | $rememberServerID = $this->mail_bo->profileID; |
| 2722 | - if(!is_numeric($message_id)) |
|
| 2717 | + if (!is_numeric($message_id)) |
|
| 2723 | 2718 | { |
| 2724 | 2719 | $hA = self::splitRowID($message_id); |
| 2725 | 2720 | $message_id = $hA['msgUID']; |
@@ -2737,30 +2732,30 @@ discard block |
||
| 2737 | 2732 | } |
| 2738 | 2733 | // always fetch all, even inline (images) |
| 2739 | 2734 | $fetchEmbeddedImages = true; |
| 2740 | - $attachments = $this->mail_bo->getMessageAttachments($message_id,null, null, $fetchEmbeddedImages, true,true,$mailbox); |
|
| 2735 | + $attachments = $this->mail_bo->getMessageAttachments($message_id, null, null, $fetchEmbeddedImages, true, true, $mailbox); |
|
| 2741 | 2736 | // put them in VFS so they can be zipped |
| 2742 | - $header = $this->mail_bo->getMessageHeader($message_id,'',true,false,$mailbox); |
|
| 2737 | + $header = $this->mail_bo->getMessageHeader($message_id, '', true, false, $mailbox); |
|
| 2743 | 2738 | //get_home_dir may fetch the users startfolder if set; if not writeable, action will fail. TODO: use temp_dir |
| 2744 | 2739 | $homedir = '/home/'.$GLOBALS['egw_info']['user']['account_lid']; |
| 2745 | - $temp_path = $homedir/*Vfs::get_home_dir()*/ . "/.mail_$message_id"; |
|
| 2746 | - if(Vfs::is_dir($temp_path)) Vfs::remove ($temp_path); |
|
| 2740 | + $temp_path = $homedir/*Vfs::get_home_dir()*/."/.mail_$message_id"; |
|
| 2741 | + if (Vfs::is_dir($temp_path)) Vfs::remove($temp_path); |
|
| 2747 | 2742 | |
| 2748 | 2743 | // Add subject to path, so it gets used as the file name |
| 2749 | - $path = $temp_path . '/' . ($header['SUBJECT'] ? Vfs::encodePathComponent($header['SUBJECT']) : lang('mail')) .'/'; |
|
| 2750 | - if(!Vfs::mkdir($path, 0700, true)) |
|
| 2744 | + $path = $temp_path.'/'.($header['SUBJECT'] ? Vfs::encodePathComponent($header['SUBJECT']) : lang('mail')).'/'; |
|
| 2745 | + if (!Vfs::mkdir($path, 0700, true)) |
|
| 2751 | 2746 | { |
| 2752 | - Framework::message("Unable to open temp directory $path",'error'); |
|
| 2747 | + Framework::message("Unable to open temp directory $path", 'error'); |
|
| 2753 | 2748 | return; |
| 2754 | 2749 | } |
| 2755 | 2750 | |
| 2756 | 2751 | $file_list = array(); |
| 2757 | 2752 | $dupe_count = array(); |
| 2758 | 2753 | $this->mail_bo->reopen($mailbox); |
| 2759 | - if ($attachments[0]['is_winmail'] && $attachments[0]['is_winmail']!='null') |
|
| 2754 | + if ($attachments[0]['is_winmail'] && $attachments[0]['is_winmail'] != 'null') |
|
| 2760 | 2755 | { |
| 2761 | - $tnefAttachments = $this->mail_bo->getTnefAttachments($message_id, $attachments[0]['partID'],true); |
|
| 2756 | + $tnefAttachments = $this->mail_bo->getTnefAttachments($message_id, $attachments[0]['partID'], true); |
|
| 2762 | 2757 | } |
| 2763 | - foreach($attachments as $file) |
|
| 2758 | + foreach ($attachments as $file) |
|
| 2764 | 2759 | { |
| 2765 | 2760 | if ($file['is_winmail']) |
| 2766 | 2761 | { |
@@ -2773,22 +2768,22 @@ discard block |
||
| 2773 | 2768 | } |
| 2774 | 2769 | else |
| 2775 | 2770 | { |
| 2776 | - $attachment = $this->mail_bo->getAttachment($message_id,$file['partID'],$file['is_winmail'],false,true); |
|
| 2771 | + $attachment = $this->mail_bo->getAttachment($message_id, $file['partID'], $file['is_winmail'], false, true); |
|
| 2777 | 2772 | } |
| 2778 | - $success=true; |
|
| 2773 | + $success = true; |
|
| 2779 | 2774 | if (empty($file['filename'])) $file['filename'] = $file['name']; |
| 2780 | - if(in_array($path.$file['filename'], $file_list)) |
|
| 2775 | + if (in_array($path.$file['filename'], $file_list)) |
|
| 2781 | 2776 | { |
| 2782 | 2777 | $dupe_count[$path.$file['filename']]++; |
| 2783 | - $file['filename'] = pathinfo($file['filename'], PATHINFO_FILENAME) . |
|
| 2784 | - ' ('.($dupe_count[$path.$file['filename']] + 1).')' . '.' . |
|
| 2778 | + $file['filename'] = pathinfo($file['filename'], PATHINFO_FILENAME). |
|
| 2779 | + ' ('.($dupe_count[$path.$file['filename']] + 1).')'.'.'. |
|
| 2785 | 2780 | pathinfo($file['filename'], PATHINFO_EXTENSION); |
| 2786 | 2781 | } |
| 2787 | - if (!($fp = Vfs::fopen($path.$file['filename'],'wb')) || |
|
| 2782 | + if (!($fp = Vfs::fopen($path.$file['filename'], 'wb')) || |
|
| 2788 | 2783 | !(!fseek($attachment['attachment'], 0, SEEK_SET) && stream_copy_to_stream($attachment['attachment'], $fp))) |
| 2789 | 2784 | { |
| 2790 | - $success=false; |
|
| 2791 | - Framework::message("Unable to zip {$file['filename']}",'error'); |
|
| 2785 | + $success = false; |
|
| 2786 | + Framework::message("Unable to zip {$file['filename']}", 'error'); |
|
| 2792 | 2787 | } |
| 2793 | 2788 | if ($success) $file_list[] = $path.$file['filename']; |
| 2794 | 2789 | if ($fp) fclose($fp); |
@@ -2809,7 +2804,7 @@ discard block |
||
| 2809 | 2804 | exit(); |
| 2810 | 2805 | } |
| 2811 | 2806 | |
| 2812 | - function get_load_email_data($uid, $partID, $mailbox,$htmlOptions=null) |
|
| 2807 | + function get_load_email_data($uid, $partID, $mailbox, $htmlOptions = null) |
|
| 2813 | 2808 | { |
| 2814 | 2809 | // seems to be needed, as if we open a mail from notification popup that is |
| 2815 | 2810 | // located in a different folder, we experience: could not parse message |
@@ -2821,19 +2816,19 @@ discard block |
||
| 2821 | 2816 | if (empty($htmlOptions)) $htmlOptions = $this->mail_bo->htmlOptions; |
| 2822 | 2817 | // fetching structure now, to supply it to getMessageBody and getMessageAttachment, so it does not get fetched twice |
| 2823 | 2818 | $structure = $this->mail_bo->getStructure($uid, $partID, $mailbox, false); |
| 2824 | - $bodyParts = $this->mail_bo->getMessageBody($uid, ($htmlOptions?$htmlOptions:''), $partID, $structure, false, $mailbox); |
|
| 2819 | + $bodyParts = $this->mail_bo->getMessageBody($uid, ($htmlOptions ? $htmlOptions : ''), $partID, $structure, false, $mailbox); |
|
| 2825 | 2820 | |
| 2826 | 2821 | //error_log(__METHOD__.__LINE__.array2string($bodyParts)); |
| 2827 | 2822 | // attachments here are only fetched to determine if there is a meeting request |
| 2828 | 2823 | // and if. use the appropriate action. so we do not need embedded images |
| 2829 | 2824 | $fetchEmbeddedImages = false; |
| 2830 | - $attachments = (array)$this->mail_bo->getMessageAttachments($uid, $partID, $structure, $fetchEmbeddedImages, true,true,$mailbox); |
|
| 2825 | + $attachments = (array)$this->mail_bo->getMessageAttachments($uid, $partID, $structure, $fetchEmbeddedImages, true, true, $mailbox); |
|
| 2831 | 2826 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
| 2832 | 2827 | foreach ($attachments as &$attach) |
| 2833 | 2828 | { |
| 2834 | 2829 | if (strtolower($attach['mimeType']) == 'text/calendar' && |
| 2835 | 2830 | isset($GLOBALS['egw_info']['user']['apps']['calendar']) && |
| 2836 | - ($attachment = $this->mail_bo->getAttachment($uid, $attach['partID'],$attach['is_winmail'],(strtolower($attach['mimeType']) == 'text/calendar'?false:true)))) |
|
| 2831 | + ($attachment = $this->mail_bo->getAttachment($uid, $attach['partID'], $attach['is_winmail'], (strtolower($attach['mimeType']) == 'text/calendar' ? false : true)))) |
|
| 2837 | 2832 | { |
| 2838 | 2833 | //error_log(__METHOD__.__LINE__.array2string($attachment)); |
| 2839 | 2834 | Api\Cache::setSession('calendar', 'ical', array( |
@@ -2844,28 +2839,28 @@ discard block |
||
| 2844 | 2839 | )); |
| 2845 | 2840 | $this->mail_bo->htmlOptions = $bufferHtmlOptions; |
| 2846 | 2841 | Api\Translation::add_app('calendar'); |
| 2847 | - return ExecMethod( 'calendar.calendar_uiforms.meeting', |
|
| 2848 | - array('event'=>null,'msg'=>'','useSession'=>true) |
|
| 2842 | + return ExecMethod('calendar.calendar_uiforms.meeting', |
|
| 2843 | + array('event'=>null, 'msg'=>'', 'useSession'=>true) |
|
| 2849 | 2844 | ); |
| 2850 | 2845 | } |
| 2851 | 2846 | } |
| 2852 | 2847 | // Compose the content of the frame |
| 2853 | 2848 | $frameHtml = |
| 2854 | 2849 | $this->get_email_header($this->mail_bo->getStyles($bodyParts)). |
| 2855 | - $this->showBody($this->getdisplayableBody($bodyParts,true,false), false); |
|
| 2850 | + $this->showBody($this->getdisplayableBody($bodyParts, true, false), false); |
|
| 2856 | 2851 | //IE10 eats away linebreaks preceeded by a whitespace in PRE sections |
| 2857 | - $frameHtml = str_replace(" \r\n","\r\n",$frameHtml); |
|
| 2852 | + $frameHtml = str_replace(" \r\n", "\r\n", $frameHtml); |
|
| 2858 | 2853 | $this->mail_bo->htmlOptions = $bufferHtmlOptions; |
| 2859 | 2854 | |
| 2860 | 2855 | return $frameHtml; |
| 2861 | 2856 | } |
| 2862 | 2857 | |
| 2863 | - static function get_email_header($additionalStyle='') |
|
| 2858 | + static function get_email_header($additionalStyle = '') |
|
| 2864 | 2859 | { |
| 2865 | 2860 | // egw_info[flags][css] already include <style> tags |
| 2866 | 2861 | $GLOBALS['egw_info']['flags']['css'] = preg_replace('|</?style[^>]*>|i', '', $additionalStyle); |
| 2867 | - $GLOBALS['egw_info']['flags']['nofooter']=true; |
|
| 2868 | - $GLOBALS['egw_info']['flags']['nonavbar']=true; |
|
| 2862 | + $GLOBALS['egw_info']['flags']['nofooter'] = true; |
|
| 2863 | + $GLOBALS['egw_info']['flags']['nonavbar'] = true; |
|
| 2869 | 2864 | // do NOT include any default CSS |
| 2870 | 2865 | Framework::includeCSS('mail', 'preview', true, true); |
| 2871 | 2866 | |
@@ -2876,35 +2871,35 @@ discard block |
||
| 2876 | 2871 | return $GLOBALS['egw']->framework->header(); |
| 2877 | 2872 | } |
| 2878 | 2873 | |
| 2879 | - function showBody(&$body, $print=true,$fullPageTags=true) |
|
| 2874 | + function showBody(&$body, $print = true, $fullPageTags = true) |
|
| 2880 | 2875 | { |
| 2881 | 2876 | $BeginBody = '<div class="mailDisplayBody"> |
| 2882 | 2877 | <table width="100%" style="table-layout:fixed"><tr><td class="td_display">'; |
| 2883 | 2878 | |
| 2884 | 2879 | $EndBody = '</td></tr></table></div>'; |
| 2885 | 2880 | if ($fullPageTags) $EndBody .= "</body></html>"; |
| 2886 | - if ($print) { |
|
| 2887 | - print $BeginBody. $body .$EndBody; |
|
| 2881 | + if ($print) { |
|
| 2882 | + print $BeginBody.$body.$EndBody; |
|
| 2888 | 2883 | } else { |
| 2889 | - return $BeginBody. $body .$EndBody; |
|
| 2884 | + return $BeginBody.$body.$EndBody; |
|
| 2890 | 2885 | } |
| 2891 | 2886 | } |
| 2892 | 2887 | |
| 2893 | - function &getdisplayableBody($_bodyParts,$modifyURI=true,$useTidy = true) |
|
| 2888 | + function &getdisplayableBody($_bodyParts, $modifyURI = true, $useTidy = true) |
|
| 2894 | 2889 | { |
| 2895 | - $bodyParts = $_bodyParts; |
|
| 2890 | + $bodyParts = $_bodyParts; |
|
| 2896 | 2891 | |
| 2897 | - $nonDisplayAbleCharacters = array('[\016]','[\017]', |
|
| 2898 | - '[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]', |
|
| 2899 | - '[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]'); |
|
| 2892 | + $nonDisplayAbleCharacters = array('[\016]', '[\017]', |
|
| 2893 | + '[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]', |
|
| 2894 | + '[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]'); |
|
| 2900 | 2895 | |
| 2901 | 2896 | $body = ''; |
| 2902 | 2897 | |
| 2903 | 2898 | //error_log(__METHOD__.array2string($bodyParts)); //exit; |
| 2904 | 2899 | if (empty($bodyParts)) return ""; |
| 2905 | - foreach((array)$bodyParts as $singleBodyPart) { |
|
| 2900 | + foreach ((array)$bodyParts as $singleBodyPart) { |
|
| 2906 | 2901 | if (!isset($singleBodyPart['body'])) { |
| 2907 | - $singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart,$modifyURI,$useTidy); |
|
| 2902 | + $singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart, $modifyURI, $useTidy); |
|
| 2908 | 2903 | $body .= $singleBodyPart['body']; |
| 2909 | 2904 | continue; |
| 2910 | 2905 | } |
@@ -2914,7 +2909,7 @@ discard block |
||
| 2914 | 2909 | $body .= ''; |
| 2915 | 2910 | continue; |
| 2916 | 2911 | } |
| 2917 | - if(!empty($body)) { |
|
| 2912 | + if (!empty($body)) { |
|
| 2918 | 2913 | $body .= '<hr style="border:dotted 1px silver;">'; |
| 2919 | 2914 | } |
| 2920 | 2915 | //error_log($singleBodyPart['body']); |
@@ -2939,22 +2934,22 @@ discard block |
||
| 2939 | 2934 | '(R)', |
| 2940 | 2935 | ); |
| 2941 | 2936 | |
| 2942 | - if(($singleBodyPart['mimeType'] == 'text/html' || $singleBodyPart['mimeType'] == 'text/plain') && |
|
| 2937 | + if (($singleBodyPart['mimeType'] == 'text/html' || $singleBodyPart['mimeType'] == 'text/plain') && |
|
| 2943 | 2938 | strtoupper($singleBodyPart['charSet']) != 'UTF-8') |
| 2944 | 2939 | { |
| 2945 | - $singleBodyPart['body'] = preg_replace($sar,$rar,$singleBodyPart['body']); |
|
| 2940 | + $singleBodyPart['body'] = preg_replace($sar, $rar, $singleBodyPart['body']); |
|
| 2946 | 2941 | } |
| 2947 | 2942 | //error_log(__METHOD__.__LINE__.'reports:'.$singleBodyPart['charSet']); |
| 2948 | - $singleBodyPart['body'] = Api\Translation::convert_jsonsafe($singleBodyPart['body'],$singleBodyPart['charSet']); |
|
| 2943 | + $singleBodyPart['body'] = Api\Translation::convert_jsonsafe($singleBodyPart['body'], $singleBodyPart['charSet']); |
|
| 2949 | 2944 | //error_log(__METHOD__.__LINE__.array2string($singleBodyPart)); |
| 2950 | - if($singleBodyPart['mimeType'] == 'text/plain') |
|
| 2945 | + if ($singleBodyPart['mimeType'] == 'text/plain') |
|
| 2951 | 2946 | { |
| 2952 | - $newBody = @htmlentities($singleBodyPart['body'],ENT_QUOTES, strtoupper(Mail::$displayCharset)); |
|
| 2947 | + $newBody = @htmlentities($singleBodyPart['body'], ENT_QUOTES, strtoupper(Mail::$displayCharset)); |
|
| 2953 | 2948 | //error_log(__METHOD__.__LINE__.'..'.$newBody); |
| 2954 | 2949 | // if empty and charset is utf8 try sanitizing the string in question |
| 2955 | - if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(Mail::$displayCharset)); |
|
| 2950 | + if (empty($newBody) && strtolower($singleBodyPart['charSet']) == 'utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']), ENT_QUOTES, strtoupper(Mail::$displayCharset)); |
|
| 2956 | 2951 | // if the conversion to htmlentities fails somehow, try without specifying the charset, which defaults to iso- |
| 2957 | - if (empty($newBody)) $newBody = htmlentities($singleBodyPart['body'],ENT_QUOTES); |
|
| 2952 | + if (empty($newBody)) $newBody = htmlentities($singleBodyPart['body'], ENT_QUOTES); |
|
| 2958 | 2953 | |
| 2959 | 2954 | // search http[s] links and make them as links available again |
| 2960 | 2955 | // to understand what's going on here, have a look at |
@@ -2982,20 +2977,20 @@ discard block |
||
| 2982 | 2977 | // since we do not display the message as HTML anymore we may want to insert good linebreaking (for visibility). |
| 2983 | 2978 | //error_log(__METHOD__.__LINE__.'..'.$newBody); |
| 2984 | 2979 | // dont break lines that start with > (> as the text was processed with htmlentities before) |
| 2985 | - $newBody = "<pre>".Mail::wordwrap($newBody,90,"\n",'>')."</pre>"; |
|
| 2980 | + $newBody = "<pre>".Mail::wordwrap($newBody, 90, "\n", '>')."</pre>"; |
|
| 2986 | 2981 | } |
| 2987 | 2982 | else |
| 2988 | 2983 | { |
| 2989 | - $alreadyHtmlLawed=false; |
|
| 2990 | - $newBody = $singleBodyPart['body']; |
|
| 2984 | + $alreadyHtmlLawed = false; |
|
| 2985 | + $newBody = $singleBodyPart['body']; |
|
| 2991 | 2986 | //TODO:$newBody = $this->highlightQuotes($newBody); |
| 2992 | 2987 | #error_log(print_r($newBody,true)); |
| 2993 | 2988 | if ($useTidy && extension_loaded('tidy')) |
| 2994 | 2989 | { |
| 2995 | 2990 | $tidy = new tidy(); |
| 2996 | - $cleaned = $tidy->repairString($newBody, Mail::$tidy_config,'utf8'); |
|
| 2991 | + $cleaned = $tidy->repairString($newBody, Mail::$tidy_config, 'utf8'); |
|
| 2997 | 2992 | // Found errors. Strip it all so there's some output |
| 2998 | - if($tidy->getStatus() == 2) |
|
| 2993 | + if ($tidy->getStatus() == 2) |
|
| 2999 | 2994 | { |
| 3000 | 2995 | error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$tidy->errorBuffer); |
| 3001 | 2996 | } |
@@ -3006,7 +3001,7 @@ discard block |
||
| 3006 | 3001 | if (!$preserveHTML) // ToDo KL: $preserveHTML is NOT initialised, so always if is dead code |
| 3007 | 3002 | { |
| 3008 | 3003 | // filter only the 'body', as we only want that part, if we throw away the Api\Html |
| 3009 | - preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array()); |
|
| 3004 | + preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array()); |
|
| 3010 | 3005 | if ($matches[2]) |
| 3011 | 3006 | { |
| 3012 | 3007 | $hasOther = true; |
@@ -3017,7 +3012,7 @@ discard block |
||
| 3017 | 3012 | else |
| 3018 | 3013 | { |
| 3019 | 3014 | // htmLawed filter only the 'body' |
| 3020 | - preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array()); |
|
| 3015 | + preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array()); |
|
| 3021 | 3016 | if ($matches[2]) |
| 3022 | 3017 | { |
| 3023 | 3018 | $hasOther = true; |
@@ -3026,10 +3021,10 @@ discard block |
||
| 3026 | 3021 | $htmLawed = new Api\Html\HtmLawed(); |
| 3027 | 3022 | // the next line should not be needed, but produces better results on HTML 2 Text conversion, |
| 3028 | 3023 | // as we switched off HTMLaweds tidy functionality |
| 3029 | - $newBody = str_replace(array('&amp;','<DIV><BR></DIV>',"<DIV> </DIV>",'<div> </div>'),array('&','<BR>','<BR>','<BR>'),$newBody); |
|
| 3030 | - $newBody = $htmLawed->run($newBody,Mail::$htmLawed_config); |
|
| 3031 | - if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3]; |
|
| 3032 | - $alreadyHtmlLawed=true; |
|
| 3024 | + $newBody = str_replace(array('&amp;', '<DIV><BR></DIV>', "<DIV> </DIV>", '<div> </div>'), array('&', '<BR>', '<BR>', '<BR>'), $newBody); |
|
| 3025 | + $newBody = $htmLawed->run($newBody, Mail::$htmLawed_config); |
|
| 3026 | + if ($hasOther && $preserveHTML) $newBody = $matches[1].$newBody.$matches[3]; |
|
| 3027 | + $alreadyHtmlLawed = true; |
|
| 3033 | 3028 | } |
| 3034 | 3029 | // do the cleanup, set for the use of purifier |
| 3035 | 3030 | //$newBodyBuff = $newBody; |
@@ -3051,8 +3046,8 @@ discard block |
||
| 3051 | 3046 | } |
| 3052 | 3047 | */ |
| 3053 | 3048 | // removes stuff between http and ?http |
| 3054 | - $Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))'; // only http:// gets removed, other protocolls are shown |
|
| 3055 | - $newBody = preg_replace('~'.$Protocol.'[^>]*\?'.$Protocol.'~sim','$1',$newBody); // removes stuff between http:// and ?http:// |
|
| 3049 | + $Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))'; // only http:// gets removed, other protocolls are shown |
|
| 3050 | + $newBody = preg_replace('~'.$Protocol.'[^>]*\?'.$Protocol.'~sim', '$1', $newBody); // removes stuff between http:// and ?http:// |
|
| 3056 | 3051 | // TRANSFORM MAILTO LINKS TO EMAILADDRESS ONLY, WILL BE SUBSTITUTED BY parseEmail TO CLICKABLE LINK |
| 3057 | 3052 | $newBody = preg_replace('/(?<!"|href=|href\s=\s|href=\s|href\s=)'.'mailto:([a-z0-9._-]+)@([a-z0-9_-]+)\.([a-z0-9._-]+)/i', |
| 3058 | 3053 | "\\1@\\2.\\3", |
@@ -3065,7 +3060,7 @@ discard block |
||
| 3065 | 3060 | // create links for inline images |
| 3066 | 3061 | if ($modifyURI) |
| 3067 | 3062 | { |
| 3068 | - $newBody = self::resolve_inline_images ($newBody, $this->mailbox, $this->uid, $this->partID); |
|
| 3063 | + $newBody = self::resolve_inline_images($newBody, $this->mailbox, $this->uid, $this->partID); |
|
| 3069 | 3064 | } |
| 3070 | 3065 | // email addresses / mailto links get now activated on client-side |
| 3071 | 3066 | } |
@@ -3077,7 +3072,7 @@ discard block |
||
| 3077 | 3072 | $body = preg_replace("/(\\\\\\\\)([\w,\\\\,-]+)/i", |
| 3078 | 3073 | "<a href=\"file:$1$2\" target=\"_blank\"><font color=\"blue\">$1$2</font></a>", $body); |
| 3079 | 3074 | |
| 3080 | - $body = preg_replace($nonDisplayAbleCharacters,'',$body); |
|
| 3075 | + $body = preg_replace($nonDisplayAbleCharacters, '', $body); |
|
| 3081 | 3076 | |
| 3082 | 3077 | return $body; |
| 3083 | 3078 | } |
@@ -3092,7 +3087,7 @@ discard block |
||
| 3092 | 3087 | * @param string $_messageType = 'html', message type is either html or plain |
| 3093 | 3088 | * @return string message body including all CID images replaced |
| 3094 | 3089 | */ |
| 3095 | - public static function resolve_inline_images ($_body,$_mailbox, $_uid, $_partID, $_messageType = 'html') |
|
| 3090 | + public static function resolve_inline_images($_body, $_mailbox, $_uid, $_partID, $_messageType = 'html') |
|
| 3096 | 3091 | { |
| 3097 | 3092 | if ($_messageType === 'plain') |
| 3098 | 3093 | { |
@@ -3100,7 +3095,7 @@ discard block |
||
| 3100 | 3095 | } |
| 3101 | 3096 | else |
| 3102 | 3097 | { |
| 3103 | - foreach(array('src','url','background') as $type) |
|
| 3098 | + foreach (array('src', 'url', 'background') as $type) |
|
| 3104 | 3099 | { |
| 3105 | 3100 | $_body = self::resolve_inline_image_byType($_body, $_mailbox, $_uid, $_partID, $type); |
| 3106 | 3101 | } |
@@ -3119,7 +3114,7 @@ discard block |
||
| 3119 | 3114 | * - types: {plain|src|url|background} |
| 3120 | 3115 | * @return string returns body content including all CID replacements |
| 3121 | 3116 | */ |
| 3122 | - public static function resolve_inline_image_byType ($_body,$_mailbox, $_uid, $_partID, $_type ='src') |
|
| 3117 | + public static function resolve_inline_image_byType($_body, $_mailbox, $_uid, $_partID, $_type = 'src') |
|
| 3123 | 3118 | { |
| 3124 | 3119 | /** |
| 3125 | 3120 | * Callback for preg_replace_callback function |
@@ -3131,7 +3126,7 @@ discard block |
||
| 3131 | 3126 | * @param string $_type |
| 3132 | 3127 | * @return string|boolean returns the replace |
| 3133 | 3128 | */ |
| 3134 | - $replace_callback = function ($matches) use ($_mailbox,$_uid, $_partID, $_type) |
|
| 3129 | + $replace_callback = function($matches) use ($_mailbox, $_uid, $_partID, $_type) |
|
| 3135 | 3130 | { |
| 3136 | 3131 | if (!$_type) return false; |
| 3137 | 3132 | $CID = ''; |
@@ -3153,11 +3148,11 @@ discard block |
||
| 3153 | 3148 | break; |
| 3154 | 3149 | } |
| 3155 | 3150 | |
| 3156 | - static $cache = array(); // some caching, if mails containing the same image multiple times |
|
| 3151 | + static $cache = array(); // some caching, if mails containing the same image multiple times |
|
| 3157 | 3152 | |
| 3158 | 3153 | if (is_array($matches) && $CID) |
| 3159 | 3154 | { |
| 3160 | - $linkData = array ( |
|
| 3155 | + $linkData = array( |
|
| 3161 | 3156 | 'menuaction' => 'mail.mail_ui.displayImage', |
| 3162 | 3157 | 'uid' => $_uid, |
| 3163 | 3158 | 'mailbox' => base64_encode($_mailbox), |
@@ -3170,7 +3165,7 @@ discard block |
||
| 3170 | 3165 | { |
| 3171 | 3166 | if (!isset($cache[$imageURL])) |
| 3172 | 3167 | { |
| 3173 | - if ($_type !="background") |
|
| 3168 | + if ($_type != "background") |
|
| 3174 | 3169 | { |
| 3175 | 3170 | $bo = Mail::getInstance(false, mail_ui::$icServerID); |
| 3176 | 3171 | $attachment = $bo->getAttachmentByCID($_uid, $CID, $_partID); |
@@ -3211,16 +3206,16 @@ discard block |
||
| 3211 | 3206 | }; |
| 3212 | 3207 | |
| 3213 | 3208 | // return new body content base on chosen type |
| 3214 | - switch($_type) |
|
| 3209 | + switch ($_type) |
|
| 3215 | 3210 | { |
| 3216 | 3211 | case"plain": |
| 3217 | - return preg_replace_callback("/\[cid:(.*)\]/iU",$replace_callback,$_body); |
|
| 3212 | + return preg_replace_callback("/\[cid:(.*)\]/iU", $replace_callback, $_body); |
|
| 3218 | 3213 | case "src": |
| 3219 | - return preg_replace_callback("/src=(\"|\')cid:(.*)(\"|\')/iU",$replace_callback,$_body); |
|
| 3214 | + return preg_replace_callback("/src=(\"|\')cid:(.*)(\"|\')/iU", $replace_callback, $_body); |
|
| 3220 | 3215 | case "url": |
| 3221 | - return preg_replace_callback("/url\(cid:(.*)\);/iU",$replace_callback,$_body); |
|
| 3216 | + return preg_replace_callback("/url\(cid:(.*)\);/iU", $replace_callback, $_body); |
|
| 3222 | 3217 | case "background": |
| 3223 | - return preg_replace_callback("/background=(\"|\')cid:(.*)(\"|\')/iU",$replace_callback,$_body); |
|
| 3218 | + return preg_replace_callback("/background=(\"|\')cid:(.*)(\"|\')/iU", $replace_callback, $_body); |
|
| 3224 | 3219 | } |
| 3225 | 3220 | } |
| 3226 | 3221 | |
@@ -3228,7 +3223,7 @@ discard block |
||
| 3228 | 3223 | * importMessage |
| 3229 | 3224 | * @param array $content = null an array of content |
| 3230 | 3225 | */ |
| 3231 | - function importMessage($content=null) |
|
| 3226 | + function importMessage($content = null) |
|
| 3232 | 3227 | { |
| 3233 | 3228 | //error_log(__METHOD__.__LINE__.$this->mail_bo->getDraftFolder()); |
| 3234 | 3229 | |
@@ -3250,7 +3245,7 @@ discard block |
||
| 3250 | 3245 | } |
| 3251 | 3246 | $destination = $content['FOLDER'][0]; |
| 3252 | 3247 | |
| 3253 | - if (stripos($destination,self::$delimiter)!==false) list($icServerID,$destination) = explode(self::$delimiter,$destination,2); |
|
| 3248 | + if (stripos($destination, self::$delimiter) !== false) list($icServerID, $destination) = explode(self::$delimiter, $destination, 2); |
|
| 3254 | 3249 | if ($icServerID && $icServerID != $this->mail_bo->profileID) |
| 3255 | 3250 | { |
| 3256 | 3251 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
@@ -3261,32 +3256,31 @@ discard block |
||
| 3261 | 3256 | $importFailed = false; |
| 3262 | 3257 | try |
| 3263 | 3258 | { |
| 3264 | - $messageUid = $this->importMessageToFolder($file,$destination,$importID); |
|
| 3265 | - $linkData = array |
|
| 3266 | - ( |
|
| 3259 | + $messageUid = $this->importMessageToFolder($file, $destination, $importID); |
|
| 3260 | + $linkData = array( |
|
| 3267 | 3261 | 'id' => $this->createRowID($destination, $messageUid, true), |
| 3268 | 3262 | ); |
| 3269 | 3263 | } |
| 3270 | 3264 | catch (Api\Exception\WrongUserinput $e) |
| 3271 | 3265 | { |
| 3272 | - $importFailed=true; |
|
| 3273 | - $content['msg'] = $e->getMessage(); |
|
| 3266 | + $importFailed = true; |
|
| 3267 | + $content['msg'] = $e->getMessage(); |
|
| 3274 | 3268 | } |
| 3275 | 3269 | if (!$importFailed) |
| 3276 | 3270 | { |
| 3277 | 3271 | list($width, $height) = explode('x', Link::get_registry('mail', 'add_popup')); |
| 3278 | 3272 | if ($width > 0 && $height > 0) Api\Json\Response::get()->call('resizeTo', $width, $height); |
| 3279 | - ExecMethod2('mail.mail_ui.displayMessage',$linkData); |
|
| 3273 | + ExecMethod2('mail.mail_ui.displayMessage', $linkData); |
|
| 3280 | 3274 | return; |
| 3281 | 3275 | } |
| 3282 | 3276 | } |
| 3283 | 3277 | if (!is_array($content)) $content = array(); |
| 3284 | - if (empty($content['FOLDER'])) $content['FOLDER']=(array)$this->mail_bo->getDraftFolder(); |
|
| 3285 | - if (!empty($content['FOLDER'])) $sel_options['FOLDER']=mail_compose::ajax_searchFolder(0,true); |
|
| 3278 | + if (empty($content['FOLDER'])) $content['FOLDER'] = (array)$this->mail_bo->getDraftFolder(); |
|
| 3279 | + if (!empty($content['FOLDER'])) $sel_options['FOLDER'] = mail_compose::ajax_searchFolder(0, true); |
|
| 3286 | 3280 | |
| 3287 | 3281 | $etpl = new Etemplate('mail.importMessage'); |
| 3288 | - $etpl->setElementAttribute('uploadForImport','onFinish','app.mail.uploadForImport'); |
|
| 3289 | - $etpl->exec('mail.mail_ui.importMessage',$content,$sel_options,array(),array(),2); |
|
| 3282 | + $etpl->setElementAttribute('uploadForImport', 'onFinish', 'app.mail.uploadForImport'); |
|
| 3283 | + $etpl->exec('mail.mail_ui.importMessage', $content, $sel_options, array(), array(), 2); |
|
| 3290 | 3284 | } |
| 3291 | 3285 | |
| 3292 | 3286 | /** |
@@ -3298,7 +3292,7 @@ discard block |
||
| 3298 | 3292 | * @param string $importID ID for the imported message, used by attachments to identify them unambiguously |
| 3299 | 3293 | * @return mixed $messageUID or exception |
| 3300 | 3294 | */ |
| 3301 | - function importMessageToFolder($_formData,&$_folder,$importID='') |
|
| 3295 | + function importMessageToFolder($_formData, &$_folder, $importID = '') |
|
| 3302 | 3296 | { |
| 3303 | 3297 | $importfailed = false; |
| 3304 | 3298 | //error_log(__METHOD__.__LINE__.array2string($_formData)); |
@@ -3306,7 +3300,7 @@ discard block |
||
| 3306 | 3300 | // check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.) |
| 3307 | 3301 | try |
| 3308 | 3302 | { |
| 3309 | - $tmpFileName = Mail::checkFileBasics($_formData,$importID); |
|
| 3303 | + $tmpFileName = Mail::checkFileBasics($_formData, $importID); |
|
| 3310 | 3304 | } |
| 3311 | 3305 | catch (Api\Exception\WrongUserinput $e) |
| 3312 | 3306 | { |
@@ -3330,29 +3324,29 @@ discard block |
||
| 3330 | 3324 | if (empty($_folder)) |
| 3331 | 3325 | { |
| 3332 | 3326 | $importfailed = true; |
| 3333 | - $alert_msg .= lang("Import of message %1 failed. Destination Folder not set.",$_formData['name']); |
|
| 3327 | + $alert_msg .= lang("Import of message %1 failed. Destination Folder not set.", $_formData['name']); |
|
| 3334 | 3328 | } |
| 3335 | 3329 | $delimiter = $this->mail_bo->getHierarchyDelimiter(); |
| 3336 | - if($_folder=='INBOX'.$delimiter) $_folder='INBOX'; |
|
| 3330 | + if ($_folder == 'INBOX'.$delimiter) $_folder = 'INBOX'; |
|
| 3337 | 3331 | if ($importfailed === false) |
| 3338 | 3332 | { |
| 3339 | - if ($this->mail_bo->folderExists($_folder,true)) { |
|
| 3333 | + if ($this->mail_bo->folderExists($_folder, true)) { |
|
| 3340 | 3334 | try |
| 3341 | 3335 | { |
| 3342 | 3336 | $messageUid = $this->mail_bo->appendMessage($_folder, |
| 3343 | 3337 | $mailObject->getRaw(), |
| 3344 | - null,'\\Seen'); |
|
| 3338 | + null, '\\Seen'); |
|
| 3345 | 3339 | } |
| 3346 | 3340 | catch (Api\Exception\WrongUserinput $e) |
| 3347 | 3341 | { |
| 3348 | 3342 | $importfailed = true; |
| 3349 | - $alert_msg .= lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$_formData['name'],$_folder,$e->getMessage()); |
|
| 3343 | + $alert_msg .= lang("Import of message %1 failed. Could not save message to folder %2 due to: %3", $_formData['name'], $_folder, $e->getMessage()); |
|
| 3350 | 3344 | } |
| 3351 | 3345 | } |
| 3352 | 3346 | else |
| 3353 | 3347 | { |
| 3354 | 3348 | $importfailed = true; |
| 3355 | - $alert_msg .= lang("Import of message %1 failed. Destination Folder %2 does not exist.",$_formData['name'],$_folder); |
|
| 3349 | + $alert_msg .= lang("Import of message %1 failed. Destination Folder %2 does not exist.", $_formData['name'], $_folder); |
|
| 3356 | 3350 | } |
| 3357 | 3351 | } |
| 3358 | 3352 | } |
@@ -3378,9 +3372,9 @@ discard block |
||
| 3378 | 3372 | * $formData['size'] = 2136; |
| 3379 | 3373 | * @return void |
| 3380 | 3374 | */ |
| 3381 | - function importMessageFromVFS2DraftAndEdit($formData='') |
|
| 3375 | + function importMessageFromVFS2DraftAndEdit($formData = '') |
|
| 3382 | 3376 | { |
| 3383 | - $this->importMessageFromVFS2DraftAndDisplay($formData,'edit'); |
|
| 3377 | + $this->importMessageFromVFS2DraftAndDisplay($formData, 'edit'); |
|
| 3384 | 3378 | } |
| 3385 | 3379 | |
| 3386 | 3380 | /** |
@@ -3395,7 +3389,7 @@ discard block |
||
| 3395 | 3389 | * @param string $mode mode to open ImportedMessage display and edit are supported |
| 3396 | 3390 | * @return void |
| 3397 | 3391 | */ |
| 3398 | - function importMessageFromVFS2DraftAndDisplay($formData='',$mode='display') |
|
| 3392 | + function importMessageFromVFS2DraftAndDisplay($formData = '', $mode = 'display') |
|
| 3399 | 3393 | { |
| 3400 | 3394 | if (empty($formData)) if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData']; |
| 3401 | 3395 | //error_log(__METHOD__.__LINE__.':'.array2string($formData).' Mode:'.$mode.'->'.function_backtrace()); |
@@ -3408,43 +3402,42 @@ discard block |
||
| 3408 | 3402 | $formData['file'] = 'egw-data://'.$formData['data']; |
| 3409 | 3403 | } |
| 3410 | 3404 | // name should be set to meet the requirements of checkFileBasics |
| 3411 | - if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['name'])) |
|
| 3405 | + if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && empty($formData['name'])) |
|
| 3412 | 3406 | { |
| 3413 | - $buff = explode('/',$formData['file']); |
|
| 3407 | + $buff = explode('/', $formData['file']); |
|
| 3414 | 3408 | if (is_array($buff)) $formData['name'] = array_pop($buff); // take the last part as name |
| 3415 | 3409 | } |
| 3416 | 3410 | // type should be set to meet the requirements of checkFileBasics |
| 3417 | - if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['type'])) |
|
| 3411 | + if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && empty($formData['type'])) |
|
| 3418 | 3412 | { |
| 3419 | - $buff = explode('.',$formData['file']); |
|
| 3413 | + $buff = explode('.', $formData['file']); |
|
| 3420 | 3414 | $suffix = ''; |
| 3421 | 3415 | if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
| 3422 | 3416 | if (!empty($suffix)) $formData['type'] = Api\MimeMagic::ext2mime($suffix); |
| 3423 | 3417 | } |
| 3424 | 3418 | // size should be set to meet the requirements of checkFileBasics |
| 3425 | - if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && !isset($formData['size'])) |
|
| 3419 | + if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && !isset($formData['size'])) |
|
| 3426 | 3420 | { |
| 3427 | 3421 | $formData['size'] = strlen($formData['file']); // set some size, to meet requirements of checkFileBasics |
| 3428 | 3422 | } |
| 3429 | 3423 | try |
| 3430 | 3424 | { |
| 3431 | - $messageUid = $this->importMessageToFolder($formData,$draftFolder,$importID); |
|
| 3432 | - $linkData = array |
|
| 3433 | - ( |
|
| 3434 | - 'menuaction' => ($mode=='display'?'mail.mail_ui.displayMessage':'mail.mail_compose.composeFromDraft'), |
|
| 3435 | - 'id' => $this->createRowID($draftFolder,$messageUid,true), |
|
| 3425 | + $messageUid = $this->importMessageToFolder($formData, $draftFolder, $importID); |
|
| 3426 | + $linkData = array( |
|
| 3427 | + 'menuaction' => ($mode == 'display' ? 'mail.mail_ui.displayMessage' : 'mail.mail_compose.composeFromDraft'), |
|
| 3428 | + 'id' => $this->createRowID($draftFolder, $messageUid, true), |
|
| 3436 | 3429 | 'deleteDraftOnClose' => 1, |
| 3437 | 3430 | ); |
| 3438 | - if ($mode!='display') |
|
| 3431 | + if ($mode != 'display') |
|
| 3439 | 3432 | { |
| 3440 | 3433 | unset($linkData['deleteDraftOnClose']); |
| 3441 | - $linkData['method'] ='importMessageToMergeAndSend'; |
|
| 3434 | + $linkData['method'] = 'importMessageToMergeAndSend'; |
|
| 3442 | 3435 | } |
| 3443 | 3436 | else |
| 3444 | 3437 | { |
| 3445 | - $linkData['mode']=$mode; |
|
| 3438 | + $linkData['mode'] = $mode; |
|
| 3446 | 3439 | } |
| 3447 | - Egw::redirect_link('/index.php',$linkData); |
|
| 3440 | + Egw::redirect_link('/index.php', $linkData); |
|
| 3448 | 3441 | } |
| 3449 | 3442 | catch (Api\Exception\WrongUserinput $e) |
| 3450 | 3443 | { |
@@ -3459,13 +3452,13 @@ discard block |
||
| 3459 | 3452 | * |
| 3460 | 3453 | * @return xajax response |
| 3461 | 3454 | */ |
| 3462 | - function loadEmailBody($_messageID=null,$_partID=null,$_htmloptions=null) |
|
| 3455 | + function loadEmailBody($_messageID = null, $_partID = null, $_htmloptions = null) |
|
| 3463 | 3456 | { |
| 3464 | 3457 | //error_log(__METHOD__.__LINE__.array2string($_GET)); |
| 3465 | 3458 | if (!$_messageID && !empty($_GET['_messageID'])) $_messageID = $_GET['_messageID']; |
| 3466 | 3459 | if (!$_partID && !empty($_GET['_partID'])) $_partID = $_GET['_partID']; |
| 3467 | 3460 | if (!$_htmloptions && !empty($_GET['_htmloptions'])) $_htmloptions = $_GET['_htmloptions']; |
| 3468 | - if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions"); |
|
| 3461 | + if (Mail::$debug) error_log(__METHOD__."->".print_r($_messageID, true).",$_partID,$_htmloptions"); |
|
| 3469 | 3462 | if (empty($_messageID)) return ""; |
| 3470 | 3463 | $uidA = self::splitRowID($_messageID); |
| 3471 | 3464 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
@@ -3479,7 +3472,7 @@ discard block |
||
| 3479 | 3472 | $this->changeProfile($icServerID); |
| 3480 | 3473 | } |
| 3481 | 3474 | |
| 3482 | - $bodyResponse = $this->get_load_email_data($messageID,$_partID,$folder,$_htmloptions); |
|
| 3475 | + $bodyResponse = $this->get_load_email_data($messageID, $_partID, $folder, $_htmloptions); |
|
| 3483 | 3476 | Api\Session::cache_control(true); |
| 3484 | 3477 | //error_log(array2string($bodyResponse)); |
| 3485 | 3478 | echo $bodyResponse; |
@@ -3508,7 +3501,7 @@ discard block |
||
| 3508 | 3501 | $oA = array(); |
| 3509 | 3502 | foreach ($_folder as $_folderName) |
| 3510 | 3503 | { |
| 3511 | - list($profileID,$folderName) = explode(self::$delimiter,$_folderName,2); |
|
| 3504 | + list($profileID, $folderName) = explode(self::$delimiter, $_folderName, 2); |
|
| 3512 | 3505 | if (is_numeric($profileID)) |
| 3513 | 3506 | { |
| 3514 | 3507 | if ($profileID != $this->mail_bo->profileID) continue; // only current connection |
@@ -3516,19 +3509,19 @@ discard block |
||
| 3516 | 3509 | { |
| 3517 | 3510 | try |
| 3518 | 3511 | { |
| 3519 | - $fS = $this->mail_bo->getFolderStatus($folderName,false,false,false); |
|
| 3512 | + $fS = $this->mail_bo->getFolderStatus($folderName, false, false, false); |
|
| 3520 | 3513 | } |
| 3521 | 3514 | catch (Exception $e) |
| 3522 | 3515 | { |
| 3523 | 3516 | continue; |
| 3524 | 3517 | } |
| 3525 | - if (in_array($fS['shortDisplayName'],Mail::$autoFolders)) $fS['shortDisplayName']=lang($fS['shortDisplayName']); |
|
| 3518 | + if (in_array($fS['shortDisplayName'], Mail::$autoFolders)) $fS['shortDisplayName'] = lang($fS['shortDisplayName']); |
|
| 3526 | 3519 | //error_log(__METHOD__.__LINE__.array2string($fS)); |
| 3527 | 3520 | if ($fS['unseen']) |
| 3528 | 3521 | { |
| 3529 | 3522 | $oA[$_folderName] = $fS['shortDisplayName'].' ('.$fS['unseen'].')'; |
| 3530 | 3523 | } |
| 3531 | - if ($fS['unseen']==0 && $fS['shortDisplayName']) |
|
| 3524 | + if ($fS['unseen'] == 0 && $fS['shortDisplayName']) |
|
| 3532 | 3525 | { |
| 3533 | 3526 | $oA[$_folderName] = $fS['shortDisplayName']; |
| 3534 | 3527 | } |
@@ -3539,7 +3532,7 @@ discard block |
||
| 3539 | 3532 | if ($oA) |
| 3540 | 3533 | { |
| 3541 | 3534 | $response = Api\Json\Response::get(); |
| 3542 | - $response->call('app.mail.mail_setFolderStatus',$oA); |
|
| 3535 | + $response->call('app.mail.mail_setFolderStatus', $oA); |
|
| 3543 | 3536 | } |
| 3544 | 3537 | } |
| 3545 | 3538 | } |
@@ -3553,14 +3546,14 @@ discard block |
||
| 3553 | 3546 | function ajax_addFolder($_parentFolderName, $_newName) |
| 3554 | 3547 | { |
| 3555 | 3548 | //error_log(__METHOD__.__LINE__.' ParentFolderName:'.array2string($_parentFolderName).' NewName/Folder:'.array2string($_newName)); |
| 3556 | - $errorMessage=''; |
|
| 3549 | + $errorMessage = ''; |
|
| 3557 | 3550 | if ($_parentFolderName) |
| 3558 | 3551 | { |
| 3559 | 3552 | $created = false; |
| 3560 | 3553 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_parentFolderName); |
| 3561 | 3554 | //the conversion is handeled by horde, frontend interaction is all utf-8 |
| 3562 | 3555 | $_newName = $this->mail_bo->decodeEntityFolderName($_newName); |
| 3563 | - list($profileID,$parentFolderName) = explode(self::$delimiter,$decodedFolderName,2); |
|
| 3556 | + list($profileID, $parentFolderName) = explode(self::$delimiter, $decodedFolderName, 2); |
|
| 3564 | 3557 | if (is_numeric($profileID)) |
| 3565 | 3558 | { |
| 3566 | 3559 | if ($profileID != $this->mail_bo->profileID) return; // only current connection |
@@ -3600,10 +3593,10 @@ discard block |
||
| 3600 | 3593 | |
| 3601 | 3594 | if (empty($del)) $del = $this->mail_bo->getHierarchyDelimiter(false); |
| 3602 | 3595 | */ |
| 3603 | - $nA = explode($del,$_newName); |
|
| 3596 | + $nA = explode($del, $_newName); |
|
| 3604 | 3597 | |
| 3605 | 3598 | //error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName"); |
| 3606 | - if (!!empty($parentFolderName)) $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName,false); |
|
| 3599 | + if (!!empty($parentFolderName)) $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName, false); |
|
| 3607 | 3600 | //error_log(__METHOD__.__LINE__.array2string($oldFolderInfo)); |
| 3608 | 3601 | |
| 3609 | 3602 | $this->mail_bo->reopen('INBOX'); |
@@ -3611,11 +3604,11 @@ discard block |
||
| 3611 | 3604 | // if newName has delimiter ($del) in it, we need to create the subtree |
| 3612 | 3605 | if (!empty($nA)) |
| 3613 | 3606 | { |
| 3614 | - $c=0; |
|
| 3615 | - foreach($nA as $sTName) |
|
| 3607 | + $c = 0; |
|
| 3608 | + foreach ($nA as $sTName) |
|
| 3616 | 3609 | { |
| 3617 | - $error=null; |
|
| 3618 | - if(($parentFolderName = $this->mail_bo->createFolder($parentFolderName, $sTName, $error))) |
|
| 3610 | + $error = null; |
|
| 3611 | + if (($parentFolderName = $this->mail_bo->createFolder($parentFolderName, $sTName, $error))) |
|
| 3619 | 3612 | { |
| 3620 | 3613 | $c++; |
| 3621 | 3614 | } |
@@ -3624,16 +3617,16 @@ discard block |
||
| 3624 | 3617 | $errorMessage .= $error; |
| 3625 | 3618 | } |
| 3626 | 3619 | } |
| 3627 | - if ($c==count($nA)) $created=true; |
|
| 3620 | + if ($c == count($nA)) $created = true; |
|
| 3628 | 3621 | } |
| 3629 | 3622 | if (!empty($parentName)) $this->mail_bo->reopen($parentName); |
| 3630 | 3623 | } |
| 3631 | 3624 | //error_log(__METHOD__.__LINE__.array2string($oA)); |
| 3632 | - if ($created===true) |
|
| 3625 | + if ($created === true) |
|
| 3633 | 3626 | { |
| 3634 | 3627 | $this->mail_bo->resetFolderObjectCache($profileID); |
| 3635 | 3628 | $response = Api\Json\Response::get(); |
| 3636 | - if ( $oldFolderInfo['shortDisplayName']) |
|
| 3629 | + if ($oldFolderInfo['shortDisplayName']) |
|
| 3637 | 3630 | { |
| 3638 | 3631 | $nodeInfo = array($_parentFolderName=>$oldFolderInfo['shortDisplayName']); |
| 3639 | 3632 | } |
@@ -3641,14 +3634,14 @@ discard block |
||
| 3641 | 3634 | { |
| 3642 | 3635 | $nodeInfo = array($profileID=>lang('INBOX')); |
| 3643 | 3636 | } |
| 3644 | - $response->call('app.mail.mail_reloadNode',$nodeInfo); |
|
| 3637 | + $response->call('app.mail.mail_reloadNode', $nodeInfo); |
|
| 3645 | 3638 | } |
| 3646 | 3639 | else |
| 3647 | 3640 | { |
| 3648 | 3641 | if ($errorMessage) |
| 3649 | 3642 | { |
| 3650 | 3643 | $response = Api\Json\Response::get(); |
| 3651 | - $response->call('egw.message',$errorMessage); |
|
| 3644 | + $response->call('egw.message', $errorMessage); |
|
| 3652 | 3645 | } |
| 3653 | 3646 | } |
| 3654 | 3647 | } |
@@ -3670,22 +3663,22 @@ discard block |
||
| 3670 | 3663 | $_newName = $this->mail_bo->decodeEntityFolderName($_newName); |
| 3671 | 3664 | $del = $this->mail_bo->getHierarchyDelimiter(false); |
| 3672 | 3665 | $oA = array(); |
| 3673 | - list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
|
| 3666 | + list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2); |
|
| 3674 | 3667 | $hasChildren = false; |
| 3675 | 3668 | if (is_numeric($profileID)) |
| 3676 | 3669 | { |
| 3677 | 3670 | if ($profileID != $this->mail_bo->profileID) return; // only current connection |
| 3678 | - $pA = explode($del,$folderName); |
|
| 3671 | + $pA = explode($del, $folderName); |
|
| 3679 | 3672 | array_pop($pA); |
| 3680 | - $parentFolder = implode($del,$pA); |
|
| 3681 | - if (strtoupper($folderName)!= 'INBOX') |
|
| 3673 | + $parentFolder = implode($del, $pA); |
|
| 3674 | + if (strtoupper($folderName) != 'INBOX') |
|
| 3682 | 3675 | { |
| 3683 | 3676 | //error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName"); |
| 3684 | - $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false); |
|
| 3677 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false); |
|
| 3685 | 3678 | //error_log(__METHOD__.__LINE__.array2string($oldFolderInfo)); |
| 3686 | - if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false) |
|
| 3679 | + if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false) |
|
| 3687 | 3680 | { |
| 3688 | - $hasChildren=true; // translates to: hasChildren -> dynamicLoading |
|
| 3681 | + $hasChildren = true; // translates to: hasChildren -> dynamicLoading |
|
| 3689 | 3682 | $delimiter = $this->mail_bo->getHierarchyDelimiter(); |
| 3690 | 3683 | $nameSpace = $this->mail_bo->_getNameSpaces(); |
| 3691 | 3684 | $prefix = $this->mail_bo->getFolderPrefixFromNamespace($nameSpace, $folderName); |
@@ -3702,7 +3695,7 @@ discard block |
||
| 3702 | 3695 | else |
| 3703 | 3696 | { |
| 3704 | 3697 | $rv = $this->mail_bo->icServer->subscribeMailbox($folder, false); |
| 3705 | - $fragments[$profileID.self::$delimiter.$folder] = substr($folder,strlen($folderName)); |
|
| 3698 | + $fragments[$profileID.self::$delimiter.$folder] = substr($folder, strlen($folderName)); |
|
| 3706 | 3699 | } |
| 3707 | 3700 | } |
| 3708 | 3701 | //error_log(__METHOD__.__LINE__.' Fetched Subfolders->'.array2string($fragments)); |
@@ -3712,7 +3705,7 @@ discard block |
||
| 3712 | 3705 | $success = false; |
| 3713 | 3706 | try |
| 3714 | 3707 | { |
| 3715 | - if(($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName))) |
|
| 3708 | + if (($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName))) |
|
| 3716 | 3709 | { |
| 3717 | 3710 | $this->mail_bo->resetFolderObjectCache($profileID); |
| 3718 | 3711 | //enforce the subscription to the newly named server, as it seems to fail for names with umlauts |
@@ -3723,11 +3716,11 @@ discard block |
||
| 3723 | 3716 | } |
| 3724 | 3717 | catch (Exception $e) |
| 3725 | 3718 | { |
| 3726 | - $newFolderName=$folderName; |
|
| 3719 | + $newFolderName = $folderName; |
|
| 3727 | 3720 | $msg = $e->getMessage(); |
| 3728 | 3721 | } |
| 3729 | 3722 | $this->mail_bo->reopen($newFolderName); |
| 3730 | - $fS = $this->mail_bo->getFolderStatus($newFolderName,false); |
|
| 3723 | + $fS = $this->mail_bo->getFolderStatus($newFolderName, false); |
|
| 3731 | 3724 | //error_log(__METHOD__.__LINE__.array2string($fS)); |
| 3732 | 3725 | if ($hasChildren) |
| 3733 | 3726 | { |
@@ -3758,12 +3751,12 @@ discard block |
||
| 3758 | 3751 | { |
| 3759 | 3752 | $oA[$_folderName]['desc'] = $fS['shortDisplayName']; |
| 3760 | 3753 | } |
| 3761 | - foreach($fragments as $oldFolderName => $fragment) |
|
| 3754 | + foreach ($fragments as $oldFolderName => $fragment) |
|
| 3762 | 3755 | { |
| 3763 | 3756 | //error_log(__METHOD__.__LINE__.':'.$oldFolderName.'->'.$profileID.self::$delimiter.$newFolderName.$fragment); |
| 3764 | 3757 | $oA[$oldFolderName]['id'] = $profileID.self::$delimiter.$newFolderName.$fragment; |
| 3765 | 3758 | $oA[$oldFolderName]['olddesc'] = '#skip-user-interaction-message#'; |
| 3766 | - $fS = $this->mail_bo->getFolderStatus($newFolderName.$fragment,false); |
|
| 3759 | + $fS = $this->mail_bo->getFolderStatus($newFolderName.$fragment, false); |
|
| 3767 | 3760 | if ($fS['unseen']) |
| 3768 | 3761 | { |
| 3769 | 3762 | $oA[$oldFolderName]['desc'] = $fS['shortDisplayName'].' ('.$fS['unseen'].')'; |
@@ -3776,20 +3769,20 @@ discard block |
||
| 3776 | 3769 | } |
| 3777 | 3770 | } |
| 3778 | 3771 | } |
| 3779 | - if ($folderName==$this->mail_bo->sessionData['mailbox']) |
|
| 3772 | + if ($folderName == $this->mail_bo->sessionData['mailbox']) |
|
| 3780 | 3773 | { |
| 3781 | - $this->mail_bo->sessionData['mailbox']=$newFolderName; |
|
| 3774 | + $this->mail_bo->sessionData['mailbox'] = $newFolderName; |
|
| 3782 | 3775 | $this->mail_bo->saveSessionData(); |
| 3783 | 3776 | } |
| 3784 | 3777 | //error_log(__METHOD__.__LINE__.array2string($oA)); |
| 3785 | 3778 | $response = Api\Json\Response::get(); |
| 3786 | 3779 | if ($oA && $success) |
| 3787 | 3780 | { |
| 3788 | - $response->call('app.mail.mail_setLeaf',$oA); |
|
| 3781 | + $response->call('app.mail.mail_setLeaf', $oA); |
|
| 3789 | 3782 | } |
| 3790 | 3783 | else |
| 3791 | 3784 | { |
| 3792 | - $response->call('egw.refresh',lang('failed to rename %1 ! Reason: %2',$oldFolderName,$msg),'mail'); |
|
| 3785 | + $response->call('egw.refresh', lang('failed to rename %1 ! Reason: %2', $oldFolderName, $msg), 'mail'); |
|
| 3793 | 3786 | } |
| 3794 | 3787 | } |
| 3795 | 3788 | } |
@@ -3801,7 +3794,7 @@ discard block |
||
| 3801 | 3794 | * @param boolean $_subscribedOnly = true |
| 3802 | 3795 | * @return void |
| 3803 | 3796 | */ |
| 3804 | - function ajax_reloadNode($_folderName,$_subscribedOnly=true) |
|
| 3797 | + function ajax_reloadNode($_folderName, $_subscribedOnly = true) |
|
| 3805 | 3798 | { |
| 3806 | 3799 | Api\Translation::add_app('mail'); |
| 3807 | 3800 | $oldPrefForSubscribedOnly = !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']; |
@@ -3812,20 +3805,20 @@ discard block |
||
| 3812 | 3805 | |
| 3813 | 3806 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 3814 | 3807 | $this->mail_bo->getHierarchyDelimiter(false); |
| 3815 | - list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
|
| 3808 | + list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2); |
|
| 3816 | 3809 | // if pref and required mode dont match -> reset the folderObject cache to ensure |
| 3817 | 3810 | // that we get what we request |
| 3818 | 3811 | if ($_subscribedOnly != $oldPrefForSubscribedOnly) $this->mail_bo->resetFolderObjectCache($profileID); |
| 3819 | 3812 | if ($profileID != $this->mail_bo->profileID) return; // only current connection |
| 3820 | 3813 | if (!empty($folderName)) |
| 3821 | 3814 | { |
| 3822 | - $parentFolder=(!empty($folderName)?$folderName:'INBOX'); |
|
| 3823 | - $folderInfo = $this->mail_bo->getFolderStatus($parentFolder,false,false,false); |
|
| 3815 | + $parentFolder = (!empty($folderName) ? $folderName : 'INBOX'); |
|
| 3816 | + $folderInfo = $this->mail_bo->getFolderStatus($parentFolder, false, false, false); |
|
| 3824 | 3817 | if ($folderInfo['unseen']) |
| 3825 | 3818 | { |
| 3826 | 3819 | $folderInfo['shortDisplayName'] = $folderInfo['shortDisplayName'].' ('.$folderInfo['unseen'].')'; |
| 3827 | 3820 | } |
| 3828 | - if ($folderInfo['unseen']==0 && $folderInfo['shortDisplayName']) |
|
| 3821 | + if ($folderInfo['unseen'] == 0 && $folderInfo['shortDisplayName']) |
|
| 3829 | 3822 | { |
| 3830 | 3823 | $folderInfo['shortDisplayName'] = $folderInfo['shortDisplayName']; |
| 3831 | 3824 | } |
@@ -3841,11 +3834,11 @@ discard block |
||
| 3841 | 3834 | } |
| 3842 | 3835 | // Send full info back in the response |
| 3843 | 3836 | $response = Api\Json\Response::get(); |
| 3844 | - foreach($refreshData as $folder => &$name) |
|
| 3837 | + foreach ($refreshData as $folder => &$name) |
|
| 3845 | 3838 | { |
| 3846 | - $name = $this->mail_tree->getTree($folder,$profileID,1,false, $_subscribedOnly,true); |
|
| 3839 | + $name = $this->mail_tree->getTree($folder, $profileID, 1, false, $_subscribedOnly, true); |
|
| 3847 | 3840 | } |
| 3848 | - $response->call('app.mail.mail_reloadNode',$refreshData); |
|
| 3841 | + $response->call('app.mail.mail_reloadNode', $refreshData); |
|
| 3849 | 3842 | |
| 3850 | 3843 | } |
| 3851 | 3844 | |
@@ -3861,7 +3854,7 @@ discard block |
||
| 3861 | 3854 | * @param type $_rowid row id from nm |
| 3862 | 3855 | * |
| 3863 | 3856 | */ |
| 3864 | - function ajax_resolveWinmail ($_rowid) |
|
| 3857 | + function ajax_resolveWinmail($_rowid) |
|
| 3865 | 3858 | { |
| 3866 | 3859 | $response = Api\Json\Response::get(); |
| 3867 | 3860 | |
@@ -3869,7 +3862,7 @@ discard block |
||
| 3869 | 3862 | $uid = $idParts['msgUID']; |
| 3870 | 3863 | $mbox = $idParts['folder']; |
| 3871 | 3864 | |
| 3872 | - $attachments = $this->mail_bo->getMessageAttachments($uid, null, null, false,true,true,$mbox); |
|
| 3865 | + $attachments = $this->mail_bo->getMessageAttachments($uid, null, null, false, true, true, $mbox); |
|
| 3873 | 3866 | if (is_array($attachments)) |
| 3874 | 3867 | { |
| 3875 | 3868 | $attachments = $this->createAttachmentBlock($attachments, $_rowid, $uid, $mbox, false); |
@@ -3897,30 +3890,30 @@ discard block |
||
| 3897 | 3890 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 3898 | 3891 | $_newLocation2 = $this->mail_bo->decodeEntityFolderName($_target); |
| 3899 | 3892 | $del = $this->mail_bo->getHierarchyDelimiter(false); |
| 3900 | - list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
|
| 3901 | - list($newProfileID,$_newLocation) = explode(self::$delimiter,$_newLocation2,2); |
|
| 3893 | + list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2); |
|
| 3894 | + list($newProfileID, $_newLocation) = explode(self::$delimiter, $_newLocation2, 2); |
|
| 3902 | 3895 | $hasChildren = false; |
| 3903 | 3896 | if (is_numeric($profileID)) |
| 3904 | 3897 | { |
| 3905 | 3898 | if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID) return; // only current connection |
| 3906 | - $pA = explode($del,$folderName); |
|
| 3899 | + $pA = explode($del, $folderName); |
|
| 3907 | 3900 | $namePart = array_pop($pA); |
| 3908 | 3901 | $_newName = $namePart; |
| 3909 | - $oldParentFolder = implode($del,$pA); |
|
| 3902 | + $oldParentFolder = implode($del, $pA); |
|
| 3910 | 3903 | $parentFolder = $_newLocation; |
| 3911 | 3904 | |
| 3912 | - if (strtoupper($folderName)!= 'INBOX' && |
|
| 3905 | + if (strtoupper($folderName) != 'INBOX' && |
|
| 3913 | 3906 | (($oldParentFolder === $parentFolder) || //$oldParentFolder == $parentFolder means move on same level |
| 3914 | 3907 | (($oldParentFolder != $parentFolder && |
| 3915 | - strlen($parentFolder)>0 && strlen($folderName)>0 && |
|
| 3916 | - strpos($parentFolder,$folderName)===false)))) // indicates that we move the older up the tree within its own branch |
|
| 3908 | + strlen($parentFolder) > 0 && strlen($folderName) > 0 && |
|
| 3909 | + strpos($parentFolder, $folderName) === false)))) // indicates that we move the older up the tree within its own branch |
|
| 3917 | 3910 | { |
| 3918 | 3911 | //error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName"); |
| 3919 | - $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false); |
|
| 3912 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false, false, false); |
|
| 3920 | 3913 | //error_log(__METHOD__.__LINE__.array2string($oldFolderInfo)); |
| 3921 | - if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false) |
|
| 3914 | + if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false) |
|
| 3922 | 3915 | { |
| 3923 | - $hasChildren=true; // translates to: hasChildren -> dynamicLoading |
|
| 3916 | + $hasChildren = true; // translates to: hasChildren -> dynamicLoading |
|
| 3924 | 3917 | $delimiter = $this->mail_bo->getHierarchyDelimiter(); |
| 3925 | 3918 | $nameSpace = $this->mail_bo->_getNameSpaces(); |
| 3926 | 3919 | $prefix = $this->mail_bo->getFolderPrefixFromNamespace($nameSpace, $folderName); |
@@ -3945,7 +3938,7 @@ discard block |
||
| 3945 | 3938 | $success = false; |
| 3946 | 3939 | try |
| 3947 | 3940 | { |
| 3948 | - if(($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName))) |
|
| 3941 | + if (($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName))) |
|
| 3949 | 3942 | { |
| 3950 | 3943 | $this->mail_bo->resetFolderObjectCache($profileID); |
| 3951 | 3944 | //enforce the subscription to the newly named server, as it seems to fail for names with umlauts |
@@ -3957,11 +3950,11 @@ discard block |
||
| 3957 | 3950 | } |
| 3958 | 3951 | catch (Exception $e) |
| 3959 | 3952 | { |
| 3960 | - $newFolderName=$folderName; |
|
| 3953 | + $newFolderName = $folderName; |
|
| 3961 | 3954 | $msg = $e->getMessage(); |
| 3962 | 3955 | } |
| 3963 | 3956 | $this->mail_bo->reopen($parentFolder); |
| 3964 | - $this->mail_bo->getFolderStatus($parentFolder,false,false,false); |
|
| 3957 | + $this->mail_bo->getFolderStatus($parentFolder, false, false, false); |
|
| 3965 | 3958 | //error_log(__METHOD__.__LINE__.array2string($fS)); |
| 3966 | 3959 | if ($hasChildren) |
| 3967 | 3960 | { |
@@ -3982,9 +3975,9 @@ discard block |
||
| 3982 | 3975 | } |
| 3983 | 3976 | } |
| 3984 | 3977 | } |
| 3985 | - if ($folderName==$this->mail_bo->sessionData['mailbox']) |
|
| 3978 | + if ($folderName == $this->mail_bo->sessionData['mailbox']) |
|
| 3986 | 3979 | { |
| 3987 | - $this->mail_bo->sessionData['mailbox']=$newFolderName; |
|
| 3980 | + $this->mail_bo->sessionData['mailbox'] = $newFolderName; |
|
| 3988 | 3981 | $this->mail_bo->saveSessionData(); |
| 3989 | 3982 | } |
| 3990 | 3983 | //error_log(__METHOD__.__LINE__.array2string($oA)); |
@@ -3993,26 +3986,26 @@ discard block |
||
| 3993 | 3986 | { |
| 3994 | 3987 | Api\Translation::add_app('mail'); |
| 3995 | 3988 | |
| 3996 | - $oldFolderInfo = $this->mail_bo->getFolderStatus($oldParentFolder,false,false,false); |
|
| 3997 | - $folderInfo = $this->mail_bo->getFolderStatus($parentFolder,false,false,false); |
|
| 3989 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($oldParentFolder, false, false, false); |
|
| 3990 | + $folderInfo = $this->mail_bo->getFolderStatus($parentFolder, false, false, false); |
|
| 3998 | 3991 | $refreshData = array( |
| 3999 | 3992 | $profileID.self::$delimiter.$oldParentFolder=>$oldFolderInfo['shortDisplayName'], |
| 4000 | 3993 | $profileID.self::$delimiter.$parentFolder=>$folderInfo['shortDisplayName']); |
| 4001 | 3994 | // if we move the folder within the same parent-branch of the tree, there is no need no refresh the upper part |
| 4002 | - if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]); |
|
| 4003 | - if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]); |
|
| 3995 | + if (strlen($parentFolder) > strlen($oldParentFolder) && strpos($parentFolder, $oldParentFolder) !== false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]); |
|
| 3996 | + if (count($refreshData) > 1 && strlen($oldParentFolder) > strlen($parentFolder) && strpos($oldParentFolder, $parentFolder) !== false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]); |
|
| 4004 | 3997 | |
| 4005 | 3998 | // Send full info back in the response |
| 4006 | - foreach($refreshData as $folder => &$name) |
|
| 3999 | + foreach ($refreshData as $folder => &$name) |
|
| 4007 | 4000 | { |
| 4008 | - $name = $this->mail_tree->getTree($folder,$profileID,1,false,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'],true); |
|
| 4001 | + $name = $this->mail_tree->getTree($folder, $profileID, 1, false, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'], true); |
|
| 4009 | 4002 | } |
| 4010 | - $response->call('app.mail.mail_reloadNode',$refreshData); |
|
| 4003 | + $response->call('app.mail.mail_reloadNode', $refreshData); |
|
| 4011 | 4004 | |
| 4012 | 4005 | } |
| 4013 | 4006 | else |
| 4014 | 4007 | { |
| 4015 | - $response->call('egw.refresh',lang('failed to move %1 ! Reason: %2',$folderName,$msg),'mail'); |
|
| 4008 | + $response->call('egw.refresh', lang('failed to move %1 ! Reason: %2', $folderName, $msg), 'mail'); |
|
| 4016 | 4009 | } |
| 4017 | 4010 | } |
| 4018 | 4011 | } |
@@ -4032,23 +4025,23 @@ discard block |
||
| 4032 | 4025 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 4033 | 4026 | $del = $this->mail_bo->getHierarchyDelimiter(false); |
| 4034 | 4027 | $oA = array(); |
| 4035 | - list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
|
| 4028 | + list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2); |
|
| 4036 | 4029 | $hasChildren = false; |
| 4037 | 4030 | if (is_numeric($profileID)) |
| 4038 | 4031 | { |
| 4039 | 4032 | if ($profileID != $this->mail_bo->profileID) return; // only current connection |
| 4040 | - $pA = explode($del,$folderName); |
|
| 4033 | + $pA = explode($del, $folderName); |
|
| 4041 | 4034 | array_pop($pA); |
| 4042 | - if (strtoupper($folderName)!= 'INBOX') |
|
| 4035 | + if (strtoupper($folderName) != 'INBOX') |
|
| 4043 | 4036 | { |
| 4044 | 4037 | //error_log(__METHOD__.__LINE__."$folderName, implode($del,$pA), $_newName"); |
| 4045 | 4038 | $oA = array(); |
| 4046 | 4039 | $subFolders = array(); |
| 4047 | - $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false); |
|
| 4040 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false, false, false); |
|
| 4048 | 4041 | //error_log(__METHOD__.__LINE__.array2string($oldFolderInfo)); |
| 4049 | - if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false) |
|
| 4042 | + if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false) |
|
| 4050 | 4043 | { |
| 4051 | - $hasChildren=true; // translates to: hasChildren -> dynamicLoading |
|
| 4044 | + $hasChildren = true; // translates to: hasChildren -> dynamicLoading |
|
| 4052 | 4045 | $ftD = array(); |
| 4053 | 4046 | $delimiter = $this->mail_bo->getHierarchyDelimiter(); |
| 4054 | 4047 | $nameSpace = $this->mail_bo->_getNameSpaces(); |
@@ -4058,24 +4051,24 @@ discard block |
||
| 4058 | 4051 | //error_log(__METHOD__.__LINE__.'->'."$folderName, $delimiter, $prefix"); |
| 4059 | 4052 | foreach ($subFolders as $k => $f) |
| 4060 | 4053 | { |
| 4061 | - $ftD[substr_count($f,$delimiter)][]=$f; |
|
| 4054 | + $ftD[substr_count($f, $delimiter)][] = $f; |
|
| 4062 | 4055 | } |
| 4063 | - krsort($ftD,SORT_NUMERIC);//sort per level |
|
| 4056 | + krsort($ftD, SORT_NUMERIC); //sort per level |
|
| 4064 | 4057 | //we iterate per level of depth of the subtree, deepest nesting is to be deleted first, and then up the tree |
| 4065 | - foreach($ftD as $k => $lc)//collection per level |
|
| 4058 | + foreach ($ftD as $k => $lc)//collection per level |
|
| 4066 | 4059 | { |
| 4067 | - foreach($lc as $f)//folders contained in that level |
|
| 4060 | + foreach ($lc as $f)//folders contained in that level |
|
| 4068 | 4061 | { |
| 4069 | 4062 | try |
| 4070 | 4063 | { |
| 4071 | 4064 | //error_log(__METHOD__.__LINE__.array2string($f).'<->'.$folderName); |
| 4072 | 4065 | $this->mail_bo->deleteFolder($f); |
| 4073 | 4066 | $success = true; |
| 4074 | - if ($f==$folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName']; |
|
| 4067 | + if ($f == $folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName']; |
|
| 4075 | 4068 | } |
| 4076 | 4069 | catch (Exception $e) |
| 4077 | 4070 | { |
| 4078 | - $msg .= ($msg?' ':'').lang("Failed to delete %1. Server responded:",$f).$e->getMessage(); |
|
| 4071 | + $msg .= ($msg ? ' ' : '').lang("Failed to delete %1. Server responded:", $f).$e->getMessage(); |
|
| 4079 | 4072 | $success = false; |
| 4080 | 4073 | } |
| 4081 | 4074 | } |
@@ -4106,11 +4099,11 @@ discard block |
||
| 4106 | 4099 | if ($success) |
| 4107 | 4100 | { |
| 4108 | 4101 | //error_log(__METHOD__.__LINE__.array2string($oA)); |
| 4109 | - $response->call('app.mail.mail_removeLeaf',$oA); |
|
| 4102 | + $response->call('app.mail.mail_removeLeaf', $oA); |
|
| 4110 | 4103 | } |
| 4111 | 4104 | else |
| 4112 | 4105 | { |
| 4113 | - $response->call('egw.refresh',lang('failed to delete %1 ! Reason: %2',$oldFolderInfo['shortDisplayName'],$msg),'mail'); |
|
| 4106 | + $response->call('egw.refresh', lang('failed to delete %1 ! Reason: %2', $oldFolderInfo['shortDisplayName'], $msg), 'mail'); |
|
| 4114 | 4107 | } |
| 4115 | 4108 | } |
| 4116 | 4109 | } |
@@ -4124,7 +4117,7 @@ discard block |
||
| 4124 | 4117 | * @param bool $getFolders The client needs the folders for the profile |
| 4125 | 4118 | * @return nothing |
| 4126 | 4119 | */ |
| 4127 | - public static function ajax_changeProfile($icServerID, $getFolders = true, $exec_id=null) |
|
| 4120 | + public static function ajax_changeProfile($icServerID, $getFolders = true, $exec_id = null) |
|
| 4128 | 4121 | { |
| 4129 | 4122 | $response = Api\Json\Response::get(); |
| 4130 | 4123 | |
@@ -4132,7 +4125,7 @@ discard block |
||
| 4132 | 4125 | |
| 4133 | 4126 | if ($icServerID && $icServerID != $previous_id) |
| 4134 | 4127 | { |
| 4135 | - $mail_ui = new mail_ui(false); // do NOT run constructor, as we call changeProfile anyway |
|
| 4128 | + $mail_ui = new mail_ui(false); // do NOT run constructor, as we call changeProfile anyway |
|
| 4136 | 4129 | try |
| 4137 | 4130 | { |
| 4138 | 4131 | $mail_ui->changeProfile($icServerID); |
@@ -4148,23 +4141,23 @@ discard block |
||
| 4148 | 4141 | } |
| 4149 | 4142 | } |
| 4150 | 4143 | catch (Exception $e) { |
| 4151 | - self::callWizard($e->getMessage(),true, 'error'); |
|
| 4144 | + self::callWizard($e->getMessage(), true, 'error'); |
|
| 4152 | 4145 | } |
| 4153 | 4146 | } |
| 4154 | 4147 | else |
| 4155 | 4148 | { |
| 4156 | - $mail_ui = new mail_ui(true); // run constructor |
|
| 4149 | + $mail_ui = new mail_ui(true); // run constructor |
|
| 4157 | 4150 | } |
| 4158 | 4151 | |
| 4159 | 4152 | // Send full info back in the response |
| 4160 | - if($getFolders) |
|
| 4153 | + if ($getFolders) |
|
| 4161 | 4154 | { |
| 4162 | 4155 | Api\Translation::add_app('mail'); |
| 4163 | 4156 | |
| 4164 | 4157 | $refreshData = array( |
| 4165 | - $icServerID => $mail_ui->mail_tree->getTree(null,$icServerID,1,false,!$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane'],!$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane']) |
|
| 4158 | + $icServerID => $mail_ui->mail_tree->getTree(null, $icServerID, 1, false, !$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane'], !$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane']) |
|
| 4166 | 4159 | ); |
| 4167 | - $response->call('app.mail.mail_reloadNode',$refreshData); |
|
| 4160 | + $response->call('app.mail.mail_reloadNode', $refreshData); |
|
| 4168 | 4161 | } |
| 4169 | 4162 | } |
| 4170 | 4163 | |
@@ -4175,7 +4168,7 @@ discard block |
||
| 4175 | 4168 | * if other than active profile; nothing is done! |
| 4176 | 4169 | * @return nothing |
| 4177 | 4170 | */ |
| 4178 | - public static function ajax_refreshVacationNotice($icServerID=null) |
|
| 4171 | + public static function ajax_refreshVacationNotice($icServerID = null) |
|
| 4179 | 4172 | { |
| 4180 | 4173 | //Get vacation from cache if it's available |
| 4181 | 4174 | $cachedVacations = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid']); |
@@ -4192,22 +4185,22 @@ discard block |
||
| 4192 | 4185 | $vacation = $mail->gatherVacation($cachedVacations); |
| 4193 | 4186 | } |
| 4194 | 4187 | |
| 4195 | - if($vacation) { |
|
| 4196 | - if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date')) |
|
| 4188 | + if ($vacation) { |
|
| 4189 | + if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status'] == 'by_date')) |
|
| 4197 | 4190 | { |
| 4198 | 4191 | $dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']; |
| 4199 | 4192 | $refreshData['vacationnotice'] = lang('Vacation notice is active'); |
| 4200 | - $refreshData['vacationrange'] = ($vacation['status']=='by_date'? Api\DateTime::server2user($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.Api\DateTime::server2user($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):''); |
|
| 4201 | - if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time())$refreshData = ''; |
|
| 4193 | + $refreshData['vacationrange'] = ($vacation['status'] == 'by_date' ? Api\DateTime::server2user($vacation['start_date'], $dtfrmt, true).($vacation['end_date'] > $vacation['start_date'] ? '->'.Api\DateTime::server2user($vacation['end_date'] + 24 * 3600 - 1, $dtfrmt, true) : '') : ''); |
|
| 4194 | + if ($vacation['status'] == 'by_date' && $vacation['end_date'] + 24 * 3600 < time())$refreshData = ''; |
|
| 4202 | 4195 | } |
| 4203 | 4196 | } |
| 4204 | - if ($vacation==false) |
|
| 4197 | + if ($vacation == false) |
|
| 4205 | 4198 | { |
| 4206 | - $refreshData['vacationnotice'] = ''; |
|
| 4207 | - $refreshData['vacationrange'] = ''; |
|
| 4199 | + $refreshData['vacationnotice'] = ''; |
|
| 4200 | + $refreshData['vacationrange'] = ''; |
|
| 4208 | 4201 | } |
| 4209 | 4202 | $response = Api\Json\Response::get(); |
| 4210 | - $response->call('app.mail.mail_refreshVacationNotice',$refreshData); |
|
| 4203 | + $response->call('app.mail.mail_refreshVacationNotice', $refreshData); |
|
| 4211 | 4204 | } |
| 4212 | 4205 | |
| 4213 | 4206 | /** |
@@ -4217,43 +4210,43 @@ discard block |
||
| 4217 | 4210 | * if other than active profile; nothing is done! |
| 4218 | 4211 | * @return nothing |
| 4219 | 4212 | */ |
| 4220 | - function ajax_refreshFilters($icServerID=null) |
|
| 4213 | + function ajax_refreshFilters($icServerID = null) |
|
| 4221 | 4214 | { |
| 4222 | 4215 | //error_log(__METHOD__.__LINE__.array2string($icServerId)); |
| 4223 | 4216 | if (empty($icServerID)) $icServerID = $this->mail_bo->profileID; |
| 4224 | 4217 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
| 4225 | 4218 | { |
| 4226 | - Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
|
| 4227 | - if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 4219 | + Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 4220 | + if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true; |
|
| 4228 | 4221 | } |
| 4229 | 4222 | if (!Mail::$supportsORinQuery[$this->mail_bo->profileID]) |
| 4230 | 4223 | { |
| 4231 | 4224 | unset($this->searchTypes['quick']); |
| 4232 | 4225 | unset($this->searchTypes['quickwithcc']); |
| 4233 | 4226 | } |
| 4234 | - if ( $this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS')) |
|
| 4227 | + if ($this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS')) |
|
| 4235 | 4228 | { |
| 4236 | - $this->statusTypes = array_merge($this->statusTypes,array( |
|
| 4237 | - 'keyword1' => 'important',//lang('important'), |
|
| 4238 | - 'keyword2' => 'job', //lang('job'), |
|
| 4239 | - 'keyword3' => 'personal',//lang('personal'), |
|
| 4240 | - 'keyword4' => 'to do', //lang('to do'), |
|
| 4241 | - 'keyword5' => 'later', //lang('later'), |
|
| 4229 | + $this->statusTypes = array_merge($this->statusTypes, array( |
|
| 4230 | + 'keyword1' => 'important', //lang('important'), |
|
| 4231 | + 'keyword2' => 'job', //lang('job'), |
|
| 4232 | + 'keyword3' => 'personal', //lang('personal'), |
|
| 4233 | + 'keyword4' => 'to do', //lang('to do'), |
|
| 4234 | + 'keyword5' => 'later', //lang('later'), |
|
| 4242 | 4235 | )); |
| 4243 | 4236 | } |
| 4244 | 4237 | else |
| 4245 | 4238 | { |
| 4246 | - $keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5'); |
|
| 4247 | - foreach($keywords as &$k) |
|
| 4239 | + $keywords = array('keyword1', 'keyword2', 'keyword3', 'keyword4', 'keyword5'); |
|
| 4240 | + foreach ($keywords as &$k) |
|
| 4248 | 4241 | { |
| 4249 | - if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]); |
|
| 4242 | + if (array_key_exists($k, $this->statusTypes)) unset($this->statusTypes[$k]); |
|
| 4250 | 4243 | } |
| 4251 | 4244 | } |
| 4252 | 4245 | |
| 4253 | 4246 | $response = Api\Json\Response::get(); |
| 4254 | - $response->call('app.mail.mail_refreshCatIdOptions',$this->searchTypes); |
|
| 4255 | - $response->call('app.mail.mail_refreshFilterOptions',$this->statusTypes); |
|
| 4256 | - $response->call('app.mail.mail_refreshFilter2Options',array(''=>lang('No details'),1=>lang('Details'))); |
|
| 4247 | + $response->call('app.mail.mail_refreshCatIdOptions', $this->searchTypes); |
|
| 4248 | + $response->call('app.mail.mail_refreshFilterOptions', $this->statusTypes); |
|
| 4249 | + $response->call('app.mail.mail_refreshFilter2Options', array(''=>lang('No details'), 1=>lang('Details'))); |
|
| 4257 | 4250 | |
| 4258 | 4251 | } |
| 4259 | 4252 | |
@@ -4262,7 +4255,7 @@ discard block |
||
| 4262 | 4255 | * |
| 4263 | 4256 | * @return nothing |
| 4264 | 4257 | */ |
| 4265 | - function ajax_refreshQuotaDisplay($icServerID=null) |
|
| 4258 | + function ajax_refreshQuotaDisplay($icServerID = null) |
|
| 4266 | 4259 | { |
| 4267 | 4260 | //error_log(__METHOD__.__LINE__.array2string($icServerID)); |
| 4268 | 4261 | Api\Translation::add_app('mail'); |
@@ -4282,10 +4275,10 @@ discard block |
||
| 4282 | 4275 | unset($e); |
| 4283 | 4276 | } |
| 4284 | 4277 | |
| 4285 | - if($quota !== false && $quota['limit'] != 'NOT SET') { |
|
| 4278 | + if ($quota !== false && $quota['limit'] != 'NOT SET') { |
|
| 4286 | 4279 | $quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']); |
| 4287 | 4280 | $content['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text']; |
| 4288 | - $content['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent']; |
|
| 4281 | + $content['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent']; |
|
| 4289 | 4282 | $content['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class']; |
| 4290 | 4283 | $content['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = ""; |
| 4291 | 4284 | } else { |
@@ -4299,7 +4292,7 @@ discard block |
||
| 4299 | 4292 | $this->changeProfile($rememberServerID); |
| 4300 | 4293 | } |
| 4301 | 4294 | $response = Api\Json\Response::get(); |
| 4302 | - $response->call('app.mail.mail_setQuotaDisplay',array('data'=>$content)); |
|
| 4295 | + $response->call('app.mail.mail_setQuotaDisplay', array('data'=>$content)); |
|
| 4303 | 4296 | } |
| 4304 | 4297 | |
| 4305 | 4298 | /** |
@@ -4321,34 +4314,34 @@ discard block |
||
| 4321 | 4314 | $this->changeProfile($icServerID); |
| 4322 | 4315 | } |
| 4323 | 4316 | $junkFolder = $this->mail_bo->getJunkFolder(); |
| 4324 | - if(!empty($junkFolder)) { |
|
| 4317 | + if (!empty($junkFolder)) { |
|
| 4325 | 4318 | if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder) |
| 4326 | 4319 | { |
| 4327 | 4320 | // Lock the tree if the active folder is junk folder |
| 4328 | 4321 | $response->call('app.mail.lock_tree'); |
| 4329 | 4322 | } |
| 4330 | - $this->mail_bo->deleteMessages('all',$junkFolder,'remove_immediately'); |
|
| 4323 | + $this->mail_bo->deleteMessages('all', $junkFolder, 'remove_immediately'); |
|
| 4331 | 4324 | |
| 4332 | 4325 | $heirarchyDelimeter = $this->mail_bo->getHierarchyDelimiter(true); |
| 4333 | - $fShortName = array_pop(explode($heirarchyDelimeter, $junkFolder)); |
|
| 4326 | + $fShortName = array_pop(explode($heirarchyDelimeter, $junkFolder)); |
|
| 4334 | 4327 | $fStatus = array( |
| 4335 | 4328 | $icServerID.self::$delimiter.$junkFolder => lang($fShortName) |
| 4336 | 4329 | ); |
| 4337 | 4330 | //Call to reset folder status counter, after junkFolder triggered not from Junk folder |
| 4338 | 4331 | //-as we don't have junk folder specific information available on client-side we need to deal with it on server |
| 4339 | - $response->call('app.mail.mail_setFolderStatus',$fStatus); |
|
| 4332 | + $response->call('app.mail.mail_setFolderStatus', $fStatus); |
|
| 4340 | 4333 | } |
| 4341 | 4334 | if ($rememberServerID != $this->mail_bo->profileID) |
| 4342 | 4335 | { |
| 4343 | - $oldFolderInfo = $this->mail_bo->getFolderStatus($junkFolder,false,false,false); |
|
| 4344 | - $response->call('egw.message',lang('empty junk')); |
|
| 4345 | - $response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$junkFolder=>$oldFolderInfo['shortDisplayName'])); |
|
| 4336 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($junkFolder, false, false, false); |
|
| 4337 | + $response->call('egw.message', lang('empty junk')); |
|
| 4338 | + $response->call('app.mail.mail_reloadNode', array($icServerID.self::$delimiter.$junkFolder=>$oldFolderInfo['shortDisplayName'])); |
|
| 4346 | 4339 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID); |
| 4347 | 4340 | $this->changeProfile($rememberServerID); |
| 4348 | 4341 | } |
| 4349 | 4342 | else if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder) |
| 4350 | 4343 | { |
| 4351 | - $response->call('egw.refresh',lang('empty junk'),'mail'); |
|
| 4344 | + $response->call('egw.refresh', lang('empty junk'), 'mail'); |
|
| 4352 | 4345 | } |
| 4353 | 4346 | } |
| 4354 | 4347 | |
@@ -4371,7 +4364,7 @@ discard block |
||
| 4371 | 4364 | $this->changeProfile($icServerID); |
| 4372 | 4365 | } |
| 4373 | 4366 | $trashFolder = $this->mail_bo->getTrashFolder(); |
| 4374 | - if(!empty($trashFolder)) { |
|
| 4367 | + if (!empty($trashFolder)) { |
|
| 4375 | 4368 | if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder) |
| 4376 | 4369 | { |
| 4377 | 4370 | // Lock the tree if the active folder is Trash folder |
@@ -4380,25 +4373,25 @@ discard block |
||
| 4380 | 4373 | $this->mail_bo->compressFolder($trashFolder); |
| 4381 | 4374 | |
| 4382 | 4375 | $heirarchyDelimeter = $this->mail_bo->getHierarchyDelimiter(true); |
| 4383 | - $fShortName = array_pop(explode($heirarchyDelimeter, $trashFolder)); |
|
| 4376 | + $fShortName = array_pop(explode($heirarchyDelimeter, $trashFolder)); |
|
| 4384 | 4377 | $fStatus = array( |
| 4385 | 4378 | $icServerID.self::$delimiter.$trashFolder => lang($fShortName) |
| 4386 | 4379 | ); |
| 4387 | 4380 | //Call to reset folder status counter, after emptyTrash triggered not from Trash folder |
| 4388 | 4381 | //-as we don't have trash folder specific information available on client-side we need to deal with it on server |
| 4389 | - $response->call('app.mail.mail_setFolderStatus',$fStatus); |
|
| 4382 | + $response->call('app.mail.mail_setFolderStatus', $fStatus); |
|
| 4390 | 4383 | } |
| 4391 | 4384 | if ($rememberServerID != $this->mail_bo->profileID) |
| 4392 | 4385 | { |
| 4393 | - $oldFolderInfo = $this->mail_bo->getFolderStatus($trashFolder,false,false,false); |
|
| 4394 | - $response->call('egw.message',lang('empty trash')); |
|
| 4395 | - $response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$trashFolder=>$oldFolderInfo['shortDisplayName'])); |
|
| 4386 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($trashFolder, false, false, false); |
|
| 4387 | + $response->call('egw.message', lang('empty trash')); |
|
| 4388 | + $response->call('app.mail.mail_reloadNode', array($icServerID.self::$delimiter.$trashFolder=>$oldFolderInfo['shortDisplayName'])); |
|
| 4396 | 4389 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID); |
| 4397 | 4390 | $this->changeProfile($rememberServerID); |
| 4398 | 4391 | } |
| 4399 | 4392 | else if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder) |
| 4400 | 4393 | { |
| 4401 | - $response->call('egw.refresh',lang('empty trash'),'mail'); |
|
| 4394 | + $response->call('egw.refresh', lang('empty trash'), 'mail'); |
|
| 4402 | 4395 | } |
| 4403 | 4396 | } |
| 4404 | 4397 | |
@@ -4415,7 +4408,7 @@ discard block |
||
| 4415 | 4408 | |
| 4416 | 4409 | $this->mail_bo->restoreSessionData(); |
| 4417 | 4410 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 4418 | - list($icServerID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
|
| 4411 | + list($icServerID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2); |
|
| 4419 | 4412 | |
| 4420 | 4413 | if (empty($folderName)) $folderName = $this->mail_bo->sessionData['mailbox']; |
| 4421 | 4414 | if ($this->mail_bo->folderExists($folderName)) |
@@ -4426,7 +4419,7 @@ discard block |
||
| 4426 | 4419 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
| 4427 | 4420 | $this->changeProfile($icServerID); |
| 4428 | 4421 | } |
| 4429 | - if(!empty($_folderName)) { |
|
| 4422 | + if (!empty($_folderName)) { |
|
| 4430 | 4423 | $this->mail_bo->compressFolder($folderName); |
| 4431 | 4424 | } |
| 4432 | 4425 | if ($rememberServerID != $this->mail_bo->profileID) |
@@ -4435,7 +4428,7 @@ discard block |
||
| 4435 | 4428 | $this->changeProfile($rememberServerID); |
| 4436 | 4429 | } |
| 4437 | 4430 | $response = Api\Json\Response::get(); |
| 4438 | - $response->call('egw.refresh',lang('compress folder').': '.$folderName,'mail'); |
|
| 4431 | + $response->call('egw.refresh', lang('compress folder').': '.$folderName, 'mail'); |
|
| 4439 | 4432 | } |
| 4440 | 4433 | } |
| 4441 | 4434 | |
@@ -4448,10 +4441,10 @@ discard block |
||
| 4448 | 4441 | */ |
| 4449 | 4442 | function ajax_sendMDN($_messageList) |
| 4450 | 4443 | { |
| 4451 | - if(Mail::$debug) error_log(__METHOD__."->".array2string($_messageList)); |
|
| 4444 | + if (Mail::$debug) error_log(__METHOD__."->".array2string($_messageList)); |
|
| 4452 | 4445 | $uidA = self::splitRowID($_messageList['msg'][0]); |
| 4453 | 4446 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
| 4454 | - $this->mail_bo->sendMDN($uidA['msgUID'],$folder); |
|
| 4447 | + $this->mail_bo->sendMDN($uidA['msgUID'], $folder); |
|
| 4455 | 4448 | } |
| 4456 | 4449 | |
| 4457 | 4450 | /** |
@@ -4463,14 +4456,14 @@ discard block |
||
| 4463 | 4456 | * |
| 4464 | 4457 | * @return xajax response |
| 4465 | 4458 | */ |
| 4466 | - function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse=true) |
|
| 4459 | + function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse = true) |
|
| 4467 | 4460 | { |
| 4468 | - if(Mail::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList)); |
|
| 4461 | + if (Mail::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList)); |
|
| 4469 | 4462 | Api\Translation::add_app('mail'); |
| 4470 | - $alreadyFlagged=false; |
|
| 4471 | - $flag2check=''; |
|
| 4463 | + $alreadyFlagged = false; |
|
| 4464 | + $flag2check = ''; |
|
| 4472 | 4465 | $filter2toggle = $query = array(); |
| 4473 | - if ($_messageList=='all' || !empty($_messageList['msg'])) |
|
| 4466 | + if ($_messageList == 'all' || !empty($_messageList['msg'])) |
|
| 4474 | 4467 | { |
| 4475 | 4468 | if (isset($_messageList['all']) && $_messageList['all']) |
| 4476 | 4469 | { |
@@ -4480,34 +4473,34 @@ discard block |
||
| 4480 | 4473 | if (isset($_messageList['activeFilters']) && $_messageList['activeFilters']) |
| 4481 | 4474 | { |
| 4482 | 4475 | $query = $_messageList['activeFilters']; |
| 4483 | - if (!empty($query['search']) || !empty($query['filter'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate'])))) |
|
| 4476 | + if (!empty($query['search']) || !empty($query['filter']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate'])))) |
|
| 4484 | 4477 | { |
| 4485 | 4478 | //([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any |
| 4486 | 4479 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
| 4487 | 4480 | { |
| 4488 | - Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
|
| 4489 | - if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 4481 | + Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 4482 | + if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true; |
|
| 4490 | 4483 | } |
| 4491 | 4484 | //error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']); |
| 4492 | 4485 | $cutoffdate = $cutoffdate2 = null; |
| 4493 | - if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate |
|
| 4494 | - if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate |
|
| 4486 | + if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate |
|
| 4487 | + if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate |
|
| 4495 | 4488 | //error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate); |
| 4496 | 4489 | $filter = array( |
| 4497 | - 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')), |
|
| 4498 | - 'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')), |
|
| 4490 | + 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')), |
|
| 4491 | + 'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')), |
|
| 4499 | 4492 | 'string' => $query['search'], |
| 4500 | - 'status' => 'any',//this is a status change. status will be manipulated later on |
|
| 4493 | + 'status' => 'any', //this is a status change. status will be manipulated later on |
|
| 4501 | 4494 | //'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2) |
| 4502 | 4495 | ); |
| 4503 | - if ($query['enddate']||$query['startdate']) { |
|
| 4496 | + if ($query['enddate'] || $query['startdate']) { |
|
| 4504 | 4497 | $filter['range'] = "BETWEEN"; |
| 4505 | 4498 | if ($cutoffdate) { |
| 4506 | - $filter[(empty($cutoffdate2)?'date':'since')] = date("d-M-Y", $cutoffdate); |
|
| 4499 | + $filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate); |
|
| 4507 | 4500 | if (empty($cutoffdate2)) $filter['range'] = "SINCE"; |
| 4508 | 4501 | } |
| 4509 | 4502 | if ($cutoffdate2) { |
| 4510 | - $filter[(empty($cutoffdate)?'date':'before')] = date("d-M-Y", $cutoffdate2); |
|
| 4503 | + $filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2); |
|
| 4511 | 4504 | if (empty($cutoffdate)) $filter['range'] = "BEFORE"; |
| 4512 | 4505 | } |
| 4513 | 4506 | } |
@@ -4520,70 +4513,70 @@ discard block |
||
| 4520 | 4513 | // flags read,flagged,label1,label2,label3,label4,label5 can be toggled: handle this when all mails in a folder |
| 4521 | 4514 | // should be affected serverside. here. |
| 4522 | 4515 | $messageList = $messageListForToggle = array(); |
| 4523 | - $flag2check = ($_flag=='read'?'seen':$_flag); |
|
| 4524 | - if (in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) && |
|
| 4525 | - !($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false)) |
|
| 4516 | + $flag2check = ($_flag == 'read' ? 'seen' : $_flag); |
|
| 4517 | + if (in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) && |
|
| 4518 | + !($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false)) |
|
| 4526 | 4519 | { |
| 4527 | 4520 | $filter2toggle['status'] = array('un'.$_flag); |
| 4528 | - if ($query['filter'] && $query['filter']!='any') |
|
| 4521 | + if ($query['filter'] && $query['filter'] != 'any') |
|
| 4529 | 4522 | { |
| 4530 | 4523 | $filter2toggle['status'][] = $query['filter']; |
| 4531 | 4524 | } |
| 4532 | 4525 | $_sRt = $this->mail_bo->getSortedList( |
| 4533 | 4526 | $folder, |
| 4534 | - $sort=0, |
|
| 4535 | - $reverse=1, |
|
| 4527 | + $sort = 0, |
|
| 4528 | + $reverse = 1, |
|
| 4536 | 4529 | $filter2toggle, |
| 4537 | - $rByUid=true, |
|
| 4530 | + $rByUid = true, |
|
| 4538 | 4531 | false |
| 4539 | 4532 | ); |
| 4540 | 4533 | $messageListForToggle = $_sRt['match']->ids; |
| 4541 | 4534 | $filter['status'] = array($_flag); |
| 4542 | - if ($query['filter'] && $query['filter'] !='any') |
|
| 4535 | + if ($query['filter'] && $query['filter'] != 'any') |
|
| 4543 | 4536 | { |
| 4544 | 4537 | $filter['status'][] = $query['filter']; |
| 4545 | 4538 | } |
| 4546 | 4539 | $_sR = $this->mail_bo->getSortedList( |
| 4547 | 4540 | $folder, |
| 4548 | - $sort=0, |
|
| 4549 | - $reverse=1, |
|
| 4541 | + $sort = 0, |
|
| 4542 | + $reverse = 1, |
|
| 4550 | 4543 | $filter, |
| 4551 | - $rByUid=true, |
|
| 4544 | + $rByUid = true, |
|
| 4552 | 4545 | false |
| 4553 | 4546 | ); |
| 4554 | 4547 | $messageList = $_sR['match']->ids; |
| 4555 | - if (count($messageListForToggle)>0) |
|
| 4548 | + if (count($messageListForToggle) > 0) |
|
| 4556 | 4549 | { |
| 4557 | 4550 | $flag2set = (strtolower($_flag)); |
| 4558 | - if(Mail::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle)); |
|
| 4559 | - $this->mail_bo->flagMessages($flag2set, $messageListForToggle,$folder); |
|
| 4551 | + if (Mail::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle)); |
|
| 4552 | + $this->mail_bo->flagMessages($flag2set, $messageListForToggle, $folder); |
|
| 4560 | 4553 | } |
| 4561 | - if (count($messageList)>0) |
|
| 4554 | + if (count($messageList) > 0) |
|
| 4562 | 4555 | { |
| 4563 | 4556 | $flag2set = 'un'.$_flag; |
| 4564 | - if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList)); |
|
| 4565 | - $this->mail_bo->flagMessages($flag2set, $messageList,$folder); |
|
| 4557 | + if (Mail::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList)); |
|
| 4558 | + $this->mail_bo->flagMessages($flag2set, $messageList, $folder); |
|
| 4566 | 4559 | } |
| 4567 | - $alreadyFlagged=true; |
|
| 4560 | + $alreadyFlagged = true; |
|
| 4568 | 4561 | } |
| 4569 | 4562 | elseif (!empty($filter) && |
| 4570 | - (!in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) || |
|
| 4571 | - (in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) && |
|
| 4572 | - ($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false)))) |
|
| 4563 | + (!in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) || |
|
| 4564 | + (in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) && |
|
| 4565 | + ($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false)))) |
|
| 4573 | 4566 | { |
| 4574 | - if ($query['filter'] && $query['filter'] !='any') |
|
| 4567 | + if ($query['filter'] && $query['filter'] != 'any') |
|
| 4575 | 4568 | { |
| 4576 | 4569 | $filter['status'] = $query['filter']; |
| 4577 | 4570 | // since we toggle and we toggle by the filtered flag we must must change _flag |
| 4578 | - $_flag = ($query['filter']=='unseen' && $_flag=='read' ? 'read' : ($query['filter']=='seen'&& $_flag=='read'?'unread':($_flag==$query['filter']?'un'.$_flag:$_flag))); |
|
| 4571 | + $_flag = ($query['filter'] == 'unseen' && $_flag == 'read' ? 'read' : ($query['filter'] == 'seen' && $_flag == 'read' ? 'unread' : ($_flag == $query['filter'] ? 'un'.$_flag : $_flag))); |
|
| 4579 | 4572 | } |
| 4580 | - if(Mail::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter)); |
|
| 4573 | + if (Mail::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter)); |
|
| 4581 | 4574 | $_sR = $this->mail_bo->getSortedList( |
| 4582 | 4575 | $folder, |
| 4583 | - $sort=0, |
|
| 4584 | - $reverse=1, |
|
| 4576 | + $sort = 0, |
|
| 4577 | + $reverse = 1, |
|
| 4585 | 4578 | $filter, |
| 4586 | - $rByUid=true, |
|
| 4579 | + $rByUid = true, |
|
| 4587 | 4580 | false |
| 4588 | 4581 | ); |
| 4589 | 4582 | $messageList = $_sR['match']->ids; |
@@ -4592,8 +4585,8 @@ discard block |
||
| 4592 | 4585 | } |
| 4593 | 4586 | else |
| 4594 | 4587 | { |
| 4595 | - if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter)); |
|
| 4596 | - $alreadyFlagged=true; |
|
| 4588 | + if (Mail::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter)); |
|
| 4589 | + $alreadyFlagged = true; |
|
| 4597 | 4590 | $uidA = self::splitRowID($_messageList['msg'][0]); |
| 4598 | 4591 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
| 4599 | 4592 | $this->mail_bo->flagMessages($_flag, 'all', $folder); |
@@ -4607,41 +4600,41 @@ discard block |
||
| 4607 | 4600 | } |
| 4608 | 4601 | if (!$alreadyFlagged) |
| 4609 | 4602 | { |
| 4610 | - foreach($_messageList['msg'] as $rowID) |
|
| 4603 | + foreach ($_messageList['msg'] as $rowID) |
|
| 4611 | 4604 | { |
| 4612 | 4605 | $hA = self::splitRowID($rowID); |
| 4613 | 4606 | $messageList[] = $hA['msgUID']; |
| 4614 | 4607 | } |
| 4615 | - if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList))); |
|
| 4616 | - $this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList),$folder); |
|
| 4608 | + if (Mail::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all' : $messageList))); |
|
| 4609 | + $this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all' : $messageList), $folder); |
|
| 4617 | 4610 | } |
| 4618 | 4611 | } |
| 4619 | 4612 | else |
| 4620 | 4613 | { |
| 4621 | - if(Mail::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 4614 | + if (Mail::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 4622 | 4615 | } |
| 4623 | 4616 | |
| 4624 | 4617 | if ($_sendJsonResponse) |
| 4625 | 4618 | { |
| 4626 | - $flag=array( |
|
| 4627 | - 'label1' => 'important',//lang('important'), |
|
| 4628 | - 'label2' => 'job', //lang('job'), |
|
| 4629 | - 'label3' => 'personal',//lang('personal'), |
|
| 4630 | - 'label4' => 'to do', //lang('to do'), |
|
| 4631 | - 'label5' => 'later', //lang('later'), |
|
| 4619 | + $flag = array( |
|
| 4620 | + 'label1' => 'important', //lang('important'), |
|
| 4621 | + 'label2' => 'job', //lang('job'), |
|
| 4622 | + 'label3' => 'personal', //lang('personal'), |
|
| 4623 | + 'label4' => 'to do', //lang('to do'), |
|
| 4624 | + 'label5' => 'later', //lang('later'), |
|
| 4632 | 4625 | ); |
| 4633 | 4626 | $response = Api\Json\Response::get(); |
| 4634 | 4627 | if (isset($_messageList['msg']) && $_messageList['popup']) |
| 4635 | 4628 | { |
| 4636 | - $response->call('egw.refresh',lang('flagged %1 messages as %2 in %3',$_messageList['msg'],lang(($flag[$_flag]?$flag[$_flag]:$_flag)),$folder),'mail', $_messageList['msg'], 'update'); |
|
| 4629 | + $response->call('egw.refresh', lang('flagged %1 messages as %2 in %3', $_messageList['msg'], lang(($flag[$_flag] ? $flag[$_flag] : $_flag)), $folder), 'mail', $_messageList['msg'], 'update'); |
|
| 4637 | 4630 | } |
| 4638 | - else if ((isset($_messageList['all']) && $_messageList['all']) || ($query['filter'] && ($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false))) |
|
| 4631 | + else if ((isset($_messageList['all']) && $_messageList['all']) || ($query['filter'] && ($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false))) |
|
| 4639 | 4632 | { |
| 4640 | - $response->call('egw.refresh',lang('flagged %1 messages as %2 in %3',(isset($_messageList['all']) && $_messageList['all']?lang('all'):count($_messageList['msg'])),lang(($flag[$_flag]?$flag[$_flag]:$_flag)),$folder),'mail'); |
|
| 4633 | + $response->call('egw.refresh', lang('flagged %1 messages as %2 in %3', (isset($_messageList['all']) && $_messageList['all'] ? lang('all') : count($_messageList['msg'])), lang(($flag[$_flag] ? $flag[$_flag] : $_flag)), $folder), 'mail'); |
|
| 4641 | 4634 | } |
| 4642 | 4635 | else |
| 4643 | 4636 | { |
| 4644 | - $response->call('egw.message',lang('flagged %1 messages as %2 in %3',(isset($_messageList['all']) && $_messageList['all']?lang('all'):count($_messageList['msg'])),lang(($flag[$_flag]?$flag[$_flag]:$_flag)),$folder)); |
|
| 4637 | + $response->call('egw.message', lang('flagged %1 messages as %2 in %3', (isset($_messageList['all']) && $_messageList['all'] ? lang('all') : count($_messageList['msg'])), lang(($flag[$_flag] ? $flag[$_flag] : $_flag)), $folder)); |
|
| 4645 | 4638 | } |
| 4646 | 4639 | } |
| 4647 | 4640 | } |
@@ -4653,12 +4646,12 @@ discard block |
||
| 4653 | 4646 | * @param string _forceDeleteMethod - method of deletion to be enforced |
| 4654 | 4647 | * @return xajax response |
| 4655 | 4648 | */ |
| 4656 | - function ajax_deleteMessages($_messageList,$_forceDeleteMethod=null) |
|
| 4649 | + function ajax_deleteMessages($_messageList, $_forceDeleteMethod = null) |
|
| 4657 | 4650 | { |
| 4658 | - if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod); |
|
| 4651 | + if (Mail::$debug) error_log(__METHOD__."->".print_r($_messageList, true).' Method:'.$_forceDeleteMethod); |
|
| 4659 | 4652 | $error = null; |
| 4660 | - $filtered = false; |
|
| 4661 | - if ($_messageList=='all' || !empty($_messageList['msg'])) |
|
| 4653 | + $filtered = false; |
|
| 4654 | + if ($_messageList == 'all' || !empty($_messageList['msg'])) |
|
| 4662 | 4655 | { |
| 4663 | 4656 | if (isset($_messageList['all']) && $_messageList['all']) |
| 4664 | 4657 | { |
@@ -4668,34 +4661,34 @@ discard block |
||
| 4668 | 4661 | if (isset($_messageList['activeFilters']) && $_messageList['activeFilters']) |
| 4669 | 4662 | { |
| 4670 | 4663 | $query = $_messageList['activeFilters']; |
| 4671 | - if (!empty($query['search']) || !empty($query['filter'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate'])))) |
|
| 4664 | + if (!empty($query['search']) || !empty($query['filter']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate'])))) |
|
| 4672 | 4665 | { |
| 4673 | 4666 | //([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any |
| 4674 | 4667 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
| 4675 | 4668 | { |
| 4676 | - Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
|
| 4677 | - if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 4669 | + Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 4670 | + if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true; |
|
| 4678 | 4671 | } |
| 4679 | - $filtered = true; |
|
| 4672 | + $filtered = true; |
|
| 4680 | 4673 | $cutoffdate = $cutoffdate2 = null; |
| 4681 | - if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate |
|
| 4682 | - if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate |
|
| 4674 | + if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate |
|
| 4675 | + if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate |
|
| 4683 | 4676 | //error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate); |
| 4684 | 4677 | $filter = array( |
| 4685 | - 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')), |
|
| 4686 | - 'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')), |
|
| 4678 | + 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')), |
|
| 4679 | + 'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')), |
|
| 4687 | 4680 | 'string' => $query['search'], |
| 4688 | - 'status' => (!empty($query['filter'])?$query['filter']:'any'), |
|
| 4681 | + 'status' => (!empty($query['filter']) ? $query['filter'] : 'any'), |
|
| 4689 | 4682 | //'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2) |
| 4690 | 4683 | ); |
| 4691 | - if ($query['enddate']||$query['startdate']) { |
|
| 4684 | + if ($query['enddate'] || $query['startdate']) { |
|
| 4692 | 4685 | $filter['range'] = "BETWEEN"; |
| 4693 | 4686 | if ($cutoffdate) { |
| 4694 | - $filter[(empty($cutoffdate2)?'date':'since')] = date("d-M-Y", $cutoffdate); |
|
| 4687 | + $filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate); |
|
| 4695 | 4688 | if (empty($cutoffdate2)) $filter['range'] = "SINCE"; |
| 4696 | 4689 | } |
| 4697 | 4690 | if ($cutoffdate2) { |
| 4698 | - $filter[(empty($cutoffdate)?'date':'before')] = date("d-M-Y", $cutoffdate2); |
|
| 4691 | + $filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2); |
|
| 4699 | 4692 | if (empty($cutoffdate)) $filter['range'] = "BEFORE"; |
| 4700 | 4693 | } |
| 4701 | 4694 | } |
@@ -4709,7 +4702,7 @@ discard block |
||
| 4709 | 4702 | $rByUid = true; |
| 4710 | 4703 | $_sR = $this->mail_bo->getSortedList( |
| 4711 | 4704 | $folder, |
| 4712 | - $sort=0, |
|
| 4705 | + $sort = 0, |
|
| 4713 | 4706 | $reverse, |
| 4714 | 4707 | $filter, |
| 4715 | 4708 | $rByUid, |
@@ -4719,23 +4712,23 @@ discard block |
||
| 4719 | 4712 | } |
| 4720 | 4713 | else |
| 4721 | 4714 | { |
| 4722 | - $messageList='all'; |
|
| 4715 | + $messageList = 'all'; |
|
| 4723 | 4716 | } |
| 4724 | 4717 | try |
| 4725 | 4718 | { |
| 4726 | 4719 | //error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod); |
| 4727 | - $this->mail_bo->deleteMessages(($messageList=='all' ? 'all':$messageList),$folder,(empty($_forceDeleteMethod)?'no':$_forceDeleteMethod)); |
|
| 4720 | + $this->mail_bo->deleteMessages(($messageList == 'all' ? 'all' : $messageList), $folder, (empty($_forceDeleteMethod) ? 'no' : $_forceDeleteMethod)); |
|
| 4728 | 4721 | } |
| 4729 | 4722 | catch (Api\Exception $e) |
| 4730 | 4723 | { |
| 4731 | - $error = str_replace('"',"'",$e->getMessage()); |
|
| 4724 | + $error = str_replace('"', "'", $e->getMessage()); |
|
| 4732 | 4725 | } |
| 4733 | 4726 | } |
| 4734 | 4727 | else |
| 4735 | 4728 | { |
| 4736 | 4729 | $uidA = self::splitRowID($_messageList['msg'][0]); |
| 4737 | 4730 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
| 4738 | - foreach($_messageList['msg'] as $rowID) |
|
| 4731 | + foreach ($_messageList['msg'] as $rowID) |
|
| 4739 | 4732 | { |
| 4740 | 4733 | $hA = self::splitRowID($rowID); |
| 4741 | 4734 | $messageList[] = $hA['msgUID']; |
@@ -4743,27 +4736,27 @@ discard block |
||
| 4743 | 4736 | try |
| 4744 | 4737 | { |
| 4745 | 4738 | //error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod); |
| 4746 | - $this->mail_bo->deleteMessages($messageList,$folder,(empty($_forceDeleteMethod)?'no':$_forceDeleteMethod)); |
|
| 4739 | + $this->mail_bo->deleteMessages($messageList, $folder, (empty($_forceDeleteMethod) ? 'no' : $_forceDeleteMethod)); |
|
| 4747 | 4740 | } |
| 4748 | 4741 | catch (Api\Exception $e) |
| 4749 | 4742 | { |
| 4750 | - $error = str_replace('"',"'",$e->getMessage()); |
|
| 4743 | + $error = str_replace('"', "'", $e->getMessage()); |
|
| 4751 | 4744 | } |
| 4752 | 4745 | } |
| 4753 | 4746 | $response = Api\Json\Response::get(); |
| 4754 | 4747 | if (empty($error)) |
| 4755 | 4748 | { |
| 4756 | - $response->call('app.mail.mail_deleteMessagesShowResult',array('egw_message'=>lang('deleted %1 messages in %2',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($_messageList['msg'])),$folder),'msg'=>$_messageList['msg'])); |
|
| 4749 | + $response->call('app.mail.mail_deleteMessagesShowResult', array('egw_message'=>lang('deleted %1 messages in %2', ($messageList == 'all' || $_messageList['all'] ? ($filtered ? lang('all filtered') : lang('all')) : count($_messageList['msg'])), $folder), 'msg'=>$_messageList['msg'])); |
|
| 4757 | 4750 | } |
| 4758 | 4751 | else |
| 4759 | 4752 | { |
| 4760 | - $error = str_replace('\n',"\n",lang('mailserver reported:\n%1 \ndo you want to proceed by deleting the selected messages immediately (click ok)?\nif not, please try to empty your trashfolder before continuing. (click cancel)',$error)); |
|
| 4761 | - $response->call('app.mail.mail_retryForcedDelete',array('response'=>$error,'messageList'=>$_messageList)); |
|
| 4753 | + $error = str_replace('\n', "\n", lang('mailserver reported:\n%1 \ndo you want to proceed by deleting the selected messages immediately (click ok)?\nif not, please try to empty your trashfolder before continuing. (click cancel)', $error)); |
|
| 4754 | + $response->call('app.mail.mail_retryForcedDelete', array('response'=>$error, 'messageList'=>$_messageList)); |
|
| 4762 | 4755 | } |
| 4763 | 4756 | } |
| 4764 | 4757 | else |
| 4765 | 4758 | { |
| 4766 | - if(Mail::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 4759 | + if (Mail::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 4767 | 4760 | } |
| 4768 | 4761 | } |
| 4769 | 4762 | |
@@ -4777,48 +4770,48 @@ discard block |
||
| 4777 | 4770 | * |
| 4778 | 4771 | * @return xajax response |
| 4779 | 4772 | */ |
| 4780 | - function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove='copy', $_move2ArchiveMarker='_') |
|
| 4773 | + function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove = 'copy', $_move2ArchiveMarker = '_') |
|
| 4781 | 4774 | { |
| 4782 | - if(Mail::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker); |
|
| 4775 | + if (Mail::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList, true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker); |
|
| 4783 | 4776 | Api\Translation::add_app('mail'); |
| 4784 | 4777 | $folderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 4785 | 4778 | // only copy or move are supported as method |
| 4786 | - if (!($_copyOrMove=='copy' || $_copyOrMove=='move')) $_copyOrMove='copy'; |
|
| 4787 | - list($targetProfileID,$targetFolder) = explode(self::$delimiter,$folderName,2); |
|
| 4779 | + if (!($_copyOrMove == 'copy' || $_copyOrMove == 'move')) $_copyOrMove = 'copy'; |
|
| 4780 | + list($targetProfileID, $targetFolder) = explode(self::$delimiter, $folderName, 2); |
|
| 4788 | 4781 | // check if move2archive was called with the correct archiveFolder |
| 4789 | 4782 | $archiveFolder = $this->mail_bo->getArchiveFolder(); |
| 4790 | - if ($_move2ArchiveMarker=='2' && $targetFolder != $archiveFolder) |
|
| 4783 | + if ($_move2ArchiveMarker == '2' && $targetFolder != $archiveFolder) |
|
| 4791 | 4784 | { |
| 4792 | 4785 | error_log(__METHOD__.__LINE__."#Move to Archive called with:"."$targetProfileID,$targetFolder"); |
| 4793 | 4786 | $targetProfileID = $this->mail_bo->profileID; |
| 4794 | 4787 | $targetFolder = $archiveFolder; |
| 4795 | 4788 | error_log(__METHOD__.__LINE__."#Fixed ArchiveFolder:"."$targetProfileID,$targetFolder"); |
| 4796 | 4789 | } |
| 4797 | - $lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1); |
|
| 4790 | + $lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 1); |
|
| 4798 | 4791 | $changeFolderActions = false; |
| 4799 | 4792 | //error_log(__METHOD__.__LINE__."#"."$targetProfileID,$targetFolder"); |
| 4800 | 4793 | //error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont)); |
| 4801 | 4794 | if (!isset($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder])) |
| 4802 | 4795 | { |
| 4803 | 4796 | //error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder])); |
| 4804 | - if ($lastFoldersUsedForMoveCont[$targetProfileID] && count($lastFoldersUsedForMoveCont[$targetProfileID])>3) |
|
| 4797 | + if ($lastFoldersUsedForMoveCont[$targetProfileID] && count($lastFoldersUsedForMoveCont[$targetProfileID]) > 3) |
|
| 4805 | 4798 | { |
| 4806 | 4799 | $keys = array_keys($lastFoldersUsedForMoveCont[$targetProfileID]); |
| 4807 | - foreach( $keys as &$f) |
|
| 4800 | + foreach ($keys as &$f) |
|
| 4808 | 4801 | { |
| 4809 | - if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]); |
|
| 4802 | + if (count($lastFoldersUsedForMoveCont[$targetProfileID]) > 9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]); |
|
| 4810 | 4803 | else break; |
| 4811 | 4804 | } |
| 4812 | 4805 | //error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID])); |
| 4813 | 4806 | } |
| 4814 | 4807 | //error_log(__METHOD__.__LINE__."#"."$targetProfileID,$targetFolder = $_folderName"); |
| 4815 | - $lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]=$folderName; |
|
| 4808 | + $lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder] = $folderName; |
|
| 4816 | 4809 | $changeFolderActions = true; |
| 4817 | 4810 | } |
| 4818 | 4811 | $filtered = false; |
| 4819 | - if ($_messageList=='all' || !empty($_messageList['msg'])) |
|
| 4812 | + if ($_messageList == 'all' || !empty($_messageList['msg'])) |
|
| 4820 | 4813 | { |
| 4821 | - $error=false; |
|
| 4814 | + $error = false; |
|
| 4822 | 4815 | if (isset($_messageList['all']) && $_messageList['all']) |
| 4823 | 4816 | { |
| 4824 | 4817 | // we have both messageIds AND allFlag folder information |
@@ -4828,34 +4821,34 @@ discard block |
||
| 4828 | 4821 | if (isset($_messageList['activeFilters']) && $_messageList['activeFilters']) |
| 4829 | 4822 | { |
| 4830 | 4823 | $query = $_messageList['activeFilters']; |
| 4831 | - if (!empty($query['search']) || !empty($query['filter'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate'])))) |
|
| 4824 | + if (!empty($query['search']) || !empty($query['filter']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate'])))) |
|
| 4832 | 4825 | { |
| 4833 | 4826 | //([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any |
| 4834 | 4827 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
| 4835 | 4828 | { |
| 4836 | - Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
|
| 4837 | - if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 4829 | + Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 4830 | + if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true; |
|
| 4838 | 4831 | } |
| 4839 | 4832 | $filtered = true; |
| 4840 | 4833 | $cutoffdate = $cutoffdate2 = null; |
| 4841 | - if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate |
|
| 4842 | - if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate |
|
| 4834 | + if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate |
|
| 4835 | + if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate |
|
| 4843 | 4836 | //error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate); |
| 4844 | 4837 | $filter = array( |
| 4845 | - 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')), |
|
| 4846 | - 'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')), |
|
| 4838 | + 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')), |
|
| 4839 | + 'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')), |
|
| 4847 | 4840 | 'string' => $query['search'], |
| 4848 | - 'status' => (!empty($query['filter'])?$query['filter']:'any'), |
|
| 4841 | + 'status' => (!empty($query['filter']) ? $query['filter'] : 'any'), |
|
| 4849 | 4842 | //'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2) |
| 4850 | 4843 | ); |
| 4851 | - if ($query['enddate']||$query['startdate']) { |
|
| 4844 | + if ($query['enddate'] || $query['startdate']) { |
|
| 4852 | 4845 | $filter['range'] = "BETWEEN"; |
| 4853 | 4846 | if ($cutoffdate) { |
| 4854 | - $filter[(empty($cutoffdate2)?'date':'since')] = date("d-M-Y", $cutoffdate); |
|
| 4847 | + $filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate); |
|
| 4855 | 4848 | if (empty($cutoffdate2)) $filter['range'] = "SINCE"; |
| 4856 | 4849 | } |
| 4857 | 4850 | if ($cutoffdate2) { |
| 4858 | - $filter[(empty($cutoffdate)?'date':'before')] = date("d-M-Y", $cutoffdate2); |
|
| 4851 | + $filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2); |
|
| 4859 | 4852 | if (empty($cutoffdate)) $filter['range'] = "BEFORE"; |
| 4860 | 4853 | } |
| 4861 | 4854 | } |
@@ -4868,70 +4861,70 @@ discard block |
||
| 4868 | 4861 | $rByUid = true; |
| 4869 | 4862 | $_sR = $this->mail_bo->getSortedList( |
| 4870 | 4863 | $folder, |
| 4871 | - $sort=0, |
|
| 4864 | + $sort = 0, |
|
| 4872 | 4865 | $reverse, |
| 4873 | 4866 | $filter, |
| 4874 | - $rByUid=true, |
|
| 4867 | + $rByUid = true, |
|
| 4875 | 4868 | false |
| 4876 | 4869 | ); |
| 4877 | 4870 | $messageList = $_sR['match']->ids; |
| 4878 | - foreach($messageList as $uID) |
|
| 4871 | + foreach ($messageList as $uID) |
|
| 4879 | 4872 | { |
| 4880 | 4873 | //error_log(__METHOD__.__LINE__.$uID); |
| 4881 | - if ($_copyOrMove=='move') |
|
| 4874 | + if ($_copyOrMove == 'move') |
|
| 4882 | 4875 | { |
| 4883 | - $messageListForRefresh[] = self::generateRowID($sourceProfileID, $folderName, $uID, $_prependApp=false); |
|
| 4876 | + $messageListForRefresh[] = self::generateRowID($sourceProfileID, $folderName, $uID, $_prependApp = false); |
|
| 4884 | 4877 | } |
| 4885 | 4878 | } |
| 4886 | 4879 | } |
| 4887 | 4880 | else |
| 4888 | 4881 | { |
| 4889 | - $messageList='all'; |
|
| 4882 | + $messageList = 'all'; |
|
| 4890 | 4883 | } |
| 4891 | 4884 | try |
| 4892 | 4885 | { |
| 4893 | 4886 | //error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod.' '.$targetProfileID.'/'.$sourceProfileID); |
| 4894 | - $this->mail_bo->moveMessages($targetFolder,$messageList,($_copyOrMove=='copy'?false:true),$folder,false,$sourceProfileID,($targetProfileID!=$sourceProfileID?$targetProfileID:null)); |
|
| 4887 | + $this->mail_bo->moveMessages($targetFolder, $messageList, ($_copyOrMove == 'copy' ? false : true), $folder, false, $sourceProfileID, ($targetProfileID != $sourceProfileID ? $targetProfileID : null)); |
|
| 4895 | 4888 | } |
| 4896 | 4889 | catch (Api\Exception $e) |
| 4897 | 4890 | { |
| 4898 | - $error = str_replace('"',"'",$e->getMessage()); |
|
| 4891 | + $error = str_replace('"', "'", $e->getMessage()); |
|
| 4899 | 4892 | } |
| 4900 | 4893 | } |
| 4901 | 4894 | else |
| 4902 | 4895 | { |
| 4903 | 4896 | $messageList = array(); |
| 4904 | - while(count($_messageList['msg']) > 0) |
|
| 4897 | + while (count($_messageList['msg']) > 0) |
|
| 4905 | 4898 | { |
| 4906 | 4899 | $uidA = self::splitRowID($_messageList['msg'][0]); |
| 4907 | 4900 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
| 4908 | 4901 | $sourceProfileID = $uidA['profileID']; |
| 4909 | 4902 | $moveList = array(); |
| 4910 | - foreach($_messageList['msg'] as $rowID) |
|
| 4903 | + foreach ($_messageList['msg'] as $rowID) |
|
| 4911 | 4904 | { |
| 4912 | 4905 | $hA = self::splitRowID($rowID); |
| 4913 | 4906 | |
| 4914 | 4907 | // If folder changes, stop and move what we've got |
| 4915 | - if($hA['folder'] != $folder) break; |
|
| 4908 | + if ($hA['folder'] != $folder) break; |
|
| 4916 | 4909 | |
| 4917 | 4910 | array_shift($_messageList['msg']); |
| 4918 | 4911 | $messageList[] = $hA['msgUID']; |
| 4919 | 4912 | $moveList[] = $hA['msgUID']; |
| 4920 | - if ($_copyOrMove=='move') |
|
| 4913 | + if ($_copyOrMove == 'move') |
|
| 4921 | 4914 | { |
| 4922 | - $helpvar = explode(self::$delimiter,$rowID); |
|
| 4915 | + $helpvar = explode(self::$delimiter, $rowID); |
|
| 4923 | 4916 | array_shift($helpvar); |
| 4924 | - $messageListForRefresh[]= implode(self::$delimiter,$helpvar); |
|
| 4917 | + $messageListForRefresh[] = implode(self::$delimiter, $helpvar); |
|
| 4925 | 4918 | } |
| 4926 | 4919 | } |
| 4927 | 4920 | try |
| 4928 | 4921 | { |
| 4929 | 4922 | //error_log(__METHOD__.__LINE__."->".print_r($moveList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod.' '.$targetProfileID.'/'.$sourceProfileID); |
| 4930 | - $this->mail_bo->moveMessages($targetFolder,$moveList,($_copyOrMove=='copy'?false:true),$folder,false,$sourceProfileID,($targetProfileID!=$sourceProfileID?$targetProfileID:null)); |
|
| 4923 | + $this->mail_bo->moveMessages($targetFolder, $moveList, ($_copyOrMove == 'copy' ? false : true), $folder, false, $sourceProfileID, ($targetProfileID != $sourceProfileID ? $targetProfileID : null)); |
|
| 4931 | 4924 | } |
| 4932 | 4925 | catch (Api\Exception $e) |
| 4933 | 4926 | { |
| 4934 | - $error = str_replace('"',"'",$e->getMessage()); |
|
| 4927 | + $error = str_replace('"', "'", $e->getMessage()); |
|
| 4935 | 4928 | } |
| 4936 | 4929 | } |
| 4937 | 4930 | } |
@@ -4944,30 +4937,30 @@ discard block |
||
| 4944 | 4937 | unset($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]); |
| 4945 | 4938 | $changeFolderActions = true; |
| 4946 | 4939 | } |
| 4947 | - $response->call('egw.message',$error,"error"); |
|
| 4940 | + $response->call('egw.message', $error, "error"); |
|
| 4948 | 4941 | } |
| 4949 | 4942 | else |
| 4950 | 4943 | { |
| 4951 | - if ($_copyOrMove=='copy') |
|
| 4944 | + if ($_copyOrMove == 'copy') |
|
| 4952 | 4945 | { |
| 4953 | - $response->call('egw.message',lang('copied %1 message(s) from %2 to %3',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($messageList)),$folder,$targetFolder)); |
|
| 4946 | + $response->call('egw.message', lang('copied %1 message(s) from %2 to %3', ($messageList == 'all' || $_messageList['all'] ? ($filtered ? lang('all filtered') : lang('all')) : count($messageList)), $folder, $targetFolder)); |
|
| 4954 | 4947 | } |
| 4955 | 4948 | else |
| 4956 | 4949 | { |
| 4957 | - $response->call('egw.refresh',lang('moved %1 message(s) from %2 to %3',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($messageList)),$folder,$targetFolder),'mail',$messageListForRefresh,'delete'); |
|
| 4950 | + $response->call('egw.refresh', lang('moved %1 message(s) from %2 to %3', ($messageList == 'all' || $_messageList['all'] ? ($filtered ? lang('all filtered') : lang('all')) : count($messageList)), $folder, $targetFolder), 'mail', $messageListForRefresh, 'delete'); |
|
| 4958 | 4951 | } |
| 4959 | 4952 | } |
| 4960 | 4953 | if ($changeFolderActions == true) |
| 4961 | 4954 | { |
| 4962 | 4955 | //error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont)); |
| 4963 | - Api\Cache::setCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFoldersUsedForMoveCont, $expiration=60*60*1); |
|
| 4956 | + Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), $lastFoldersUsedForMoveCont, $expiration = 60 * 60 * 1); |
|
| 4964 | 4957 | $actionsnew = Etemplate\Widget\Nextmatch::egw_actions(self::get_actions()); |
| 4965 | - $response->call('app.mail.mail_rebuildActionsOnList',$actionsnew); |
|
| 4958 | + $response->call('app.mail.mail_rebuildActionsOnList', $actionsnew); |
|
| 4966 | 4959 | } |
| 4967 | 4960 | } |
| 4968 | 4961 | else |
| 4969 | 4962 | { |
| 4970 | - if(Mail::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 4963 | + if (Mail::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 4971 | 4964 | } |
| 4972 | 4965 | } |
| 4973 | 4966 | |
@@ -4977,11 +4970,11 @@ discard block |
||
| 4977 | 4970 | * |
| 4978 | 4971 | * @param type $_id |
| 4979 | 4972 | */ |
| 4980 | - function ajax_folderMgmtTree_autoloading ($_id = null) |
|
| 4973 | + function ajax_folderMgmtTree_autoloading($_id = null) |
|
| 4981 | 4974 | { |
| 4982 | 4975 | $mail_ui = new mail_ui(); |
| 4983 | - $id = $_id? $_id : $_GET['id']; |
|
| 4984 | - Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id,'',1,true,false,false,false)); |
|
| 4976 | + $id = $_id ? $_id : $_GET['id']; |
|
| 4977 | + Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id, '', 1, true, false, false, false)); |
|
| 4985 | 4978 | } |
| 4986 | 4979 | |
| 4987 | 4980 | /** |
@@ -4989,15 +4982,15 @@ discard block |
||
| 4989 | 4982 | * |
| 4990 | 4983 | * @param array $content content of dialog |
| 4991 | 4984 | */ |
| 4992 | - function folderManagement (array $content = null) |
|
| 4985 | + function folderManagement(array $content = null) |
|
| 4993 | 4986 | { |
| 4994 | 4987 | $dtmpl = new Etemplate('mail.folder_management'); |
| 4995 | - $profileID = $_GET['acc_id']? $_GET['acc_id']: $content['acc_id']; |
|
| 4996 | - $sel_options['tree'] = $this->mail_tree->getTree(null,$profileID, 1, true, false, false); |
|
| 4988 | + $profileID = $_GET['acc_id'] ? $_GET['acc_id'] : $content['acc_id']; |
|
| 4989 | + $sel_options['tree'] = $this->mail_tree->getTree(null, $profileID, 1, true, false, false); |
|
| 4997 | 4990 | |
| 4998 | 4991 | if (!is_array($content)) |
| 4999 | 4992 | { |
| 5000 | - $content = array ('acc_id' => $profileID); |
|
| 4993 | + $content = array('acc_id' => $profileID); |
|
| 5001 | 4994 | } |
| 5002 | 4995 | |
| 5003 | 4996 | $readonlys = array(); |
@@ -5005,7 +4998,7 @@ discard block |
||
| 5005 | 4998 | $preserv = array( |
| 5006 | 4999 | 'acc_id' => $content['acc_id'] // preserve acc id to be used in client-side |
| 5007 | 5000 | ); |
| 5008 | - $dtmpl->exec('mail.mail_ui.folderManagement', $content,$sel_options,$readonlys,$preserv,2); |
|
| 5001 | + $dtmpl->exec('mail.mail_ui.folderManagement', $content, $sel_options, $readonlys, $preserv, 2); |
|
| 5009 | 5002 | } |
| 5010 | 5003 | |
| 5011 | 5004 | /** |
@@ -5015,11 +5008,11 @@ discard block |
||
| 5015 | 5008 | * |
| 5016 | 5009 | * @param type $_folderName |
| 5017 | 5010 | */ |
| 5018 | - function ajax_folderMgmt_delete ($_folderName) |
|
| 5011 | + function ajax_folderMgmt_delete($_folderName) |
|
| 5019 | 5012 | { |
| 5020 | 5013 | if ($_folderName) |
| 5021 | 5014 | { |
| 5022 | - $success = $this->ajax_deleteFolder($_folderName,true); |
|
| 5015 | + $success = $this->ajax_deleteFolder($_folderName, true); |
|
| 5023 | 5016 | $response = Api\Json\Response::get(); |
| 5024 | 5017 | list(,$folderName) = explode(self::$delimiter, $_folderName); |
| 5025 | 5018 | if ($success) |
@@ -5028,7 +5021,7 @@ discard block |
||
| 5028 | 5021 | } |
| 5029 | 5022 | else |
| 5030 | 5023 | { |
| 5031 | - $res = lang("Failed to delete %1",$folderName); |
|
| 5024 | + $res = lang("Failed to delete %1", $folderName); |
|
| 5032 | 5025 | } |
| 5033 | 5026 | $response->data($res); |
| 5034 | 5027 | } |
@@ -127,9 +127,15 @@ discard block |
||
| 127 | 127 | function __construct($run_constructor=true) |
| 128 | 128 | { |
| 129 | 129 | $this->mail_tree = new mail_tree($this); |
| 130 | - if (!$run_constructor) return; |
|
| 130 | + if (!$run_constructor) |
|
| 131 | + { |
|
| 132 | + return; |
|
| 133 | + } |
|
| 131 | 134 | |
| 132 | - if (Mail::$debugTimes) $starttime = microtime (true); |
|
| 135 | + if (Mail::$debugTimes) |
|
| 136 | + { |
|
| 137 | + $starttime = microtime (true); |
|
| 138 | + } |
|
| 133 | 139 | // no autohide of the sidebox, as we use it for folderlist now. |
| 134 | 140 | unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']); |
| 135 | 141 | |
@@ -140,13 +146,19 @@ discard block |
||
| 140 | 146 | if ($_GET["resetConnection"]) |
| 141 | 147 | { |
| 142 | 148 | unset($_GET["resetConnection"]); |
| 143 | - if (Mail::$debug) error_log(__METHOD__.__LINE__.' Connection Reset triggered: for Profile with ID:'.self::$icServerID); |
|
| 149 | + if (Mail::$debug) |
|
| 150 | + { |
|
| 151 | + error_log(__METHOD__.__LINE__.' Connection Reset triggered: for Profile with ID:'.self::$icServerID); |
|
| 152 | + } |
|
| 144 | 153 | Mail::unsetCachedObjects(self::$icServerID); |
| 145 | 154 | } |
| 146 | 155 | |
| 147 | 156 | try { |
| 148 | 157 | $this->mail_bo = Mail::getInstance(true,self::$icServerID, true, false, true); |
| 149 | - if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace()); |
|
| 158 | + if (Mail::$debug) |
|
| 159 | + { |
|
| 160 | + error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace()); |
|
| 161 | + } |
|
| 150 | 162 | //error_log(__METHOD__.__LINE__.array2string($this->mail_bo->icServer)); |
| 151 | 163 | |
| 152 | 164 | // RegEx to minimize extra openConnection |
@@ -163,7 +175,10 @@ discard block |
||
| 163 | 175 | // redirect to mail wizard to handle it (redirect works for ajax too) |
| 164 | 176 | self::callWizard($e->getMessage(),true,'error'); |
| 165 | 177 | } |
| 166 | - if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 178 | + if (Mail::$debugTimes) |
|
| 179 | + { |
|
| 180 | + Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 181 | + } |
|
| 167 | 182 | } |
| 168 | 183 | |
| 169 | 184 | /** |
@@ -222,16 +237,28 @@ discard block |
||
| 222 | 237 | */ |
| 223 | 238 | function changeProfile($_icServerID,$unsetCache=false) |
| 224 | 239 | { |
| 225 | - if (Mail::$debugTimes) $starttime = microtime (true); |
|
| 240 | + if (Mail::$debugTimes) |
|
| 241 | + { |
|
| 242 | + $starttime = microtime (true); |
|
| 243 | + } |
|
| 226 | 244 | if (self::$icServerID != $_icServerID) |
| 227 | 245 | { |
| 228 | 246 | self::$icServerID = $_icServerID; |
| 229 | 247 | } |
| 230 | - if (Mail::$debug) error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID); |
|
| 248 | + if (Mail::$debug) |
|
| 249 | + { |
|
| 250 | + error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID); |
|
| 251 | + } |
|
| 231 | 252 | |
| 232 | - if ($unsetCache) Mail::unsetCachedObjects(self::$icServerID); |
|
| 253 | + if ($unsetCache) |
|
| 254 | + { |
|
| 255 | + Mail::unsetCachedObjects(self::$icServerID); |
|
| 256 | + } |
|
| 233 | 257 | $this->mail_bo = Mail::getInstance(false,self::$icServerID,true, false, true); |
| 234 | - if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace()); |
|
| 258 | + if (Mail::$debug) |
|
| 259 | + { |
|
| 260 | + error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace()); |
|
| 261 | + } |
|
| 235 | 262 | // no icServer Object: something failed big time |
| 236 | 263 | if (!isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId<>$_icServerID) |
| 237 | 264 | { |
@@ -241,14 +268,23 @@ discard block |
||
| 241 | 268 | |
| 242 | 269 | // save session varchar |
| 243 | 270 | $oldicServerID =& Api\Cache::getSession('mail','activeProfileID'); |
| 244 | - if ($oldicServerID <> self::$icServerID) $this->mail_bo->openConnection(self::$icServerID); |
|
| 245 | - if (true) $oldicServerID = self::$icServerID; |
|
| 271 | + if ($oldicServerID <> self::$icServerID) |
|
| 272 | + { |
|
| 273 | + $this->mail_bo->openConnection(self::$icServerID); |
|
| 274 | + } |
|
| 275 | + if (true) |
|
| 276 | + { |
|
| 277 | + $oldicServerID = self::$icServerID; |
|
| 278 | + } |
|
| 246 | 279 | if (!Mail::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true )) |
| 247 | 280 | { |
| 248 | 281 | throw new Api\Exception(__METHOD__." failed to change Profile to $_icServerID"); |
| 249 | 282 | } |
| 250 | 283 | |
| 251 | - if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 284 | + if (Mail::$debugTimes) |
|
| 285 | + { |
|
| 286 | + Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 287 | + } |
|
| 252 | 288 | } |
| 253 | 289 | |
| 254 | 290 | /** |
@@ -289,7 +325,8 @@ discard block |
||
| 289 | 325 | // got subscribed or unsubscribed by the user |
| 290 | 326 | try { |
| 291 | 327 | $subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('',0,true); |
| 292 | - } catch (Exception $ex) { |
|
| 328 | + } |
|
| 329 | + catch (Exception $ex) { |
|
| 293 | 330 | Framework::message($ex->getMessage()); |
| 294 | 331 | } |
| 295 | 332 | |
@@ -323,9 +360,18 @@ discard block |
||
| 323 | 360 | list(,$node) = explode($profileId.self::$delimiter, $path); |
| 324 | 361 | if ($node) |
| 325 | 362 | { |
| 326 | - if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe []= $node; |
|
| 327 | - if (is_array($subscribed) && !$subscribed[$node] && $value['value']) $to_subscribe [] = $node; |
|
| 328 | - if ($value['value']) $cont[] = $path; |
|
| 363 | + if (is_array($subscribed) && $subscribed[$node] && !$value['value']) |
|
| 364 | + { |
|
| 365 | + $to_unsubscribe []= $node; |
|
| 366 | + } |
|
| 367 | + if (is_array($subscribed) && !$subscribed[$node] && $value['value']) |
|
| 368 | + { |
|
| 369 | + $to_subscribe [] = $node; |
|
| 370 | + } |
|
| 371 | + if ($value['value']) |
|
| 372 | + { |
|
| 373 | + $cont[] = $path; |
|
| 374 | + } |
|
| 329 | 375 | } |
| 330 | 376 | |
| 331 | 377 | } |
@@ -414,7 +460,10 @@ discard block |
||
| 414 | 460 | //error_log(__METHOD__.__LINE__.array2string($content)); |
| 415 | 461 | try { |
| 416 | 462 | //error_log(__METHOD__.__LINE__.function_backtrace()); |
| 417 | - if (Mail::$debugTimes) $starttime = microtime (true); |
|
| 463 | + if (Mail::$debugTimes) |
|
| 464 | + { |
|
| 465 | + $starttime = microtime (true); |
|
| 466 | + } |
|
| 418 | 467 | $this->mail_bo->restoreSessionData(); |
| 419 | 468 | $sessionFolder = $this->mail_bo->sessionData['mailbox']; |
| 420 | 469 | if ($this->mail_bo->folderExists($sessionFolder)) |
@@ -443,7 +492,10 @@ discard block |
||
| 443 | 492 | 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' |
| 444 | 493 | ); |
| 445 | 494 | } |
| 446 | - if (Api\Header\UserAgent::mobile()) $content[self::$nm_index]['header_row'] = 'mail.index.header_right'; |
|
| 495 | + if (Api\Header\UserAgent::mobile()) |
|
| 496 | + { |
|
| 497 | + $content[self::$nm_index]['header_row'] = 'mail.index.header_right'; |
|
| 498 | + } |
|
| 447 | 499 | } |
| 448 | 500 | |
| 449 | 501 | // These must always be set, even if $content is an array |
@@ -477,13 +529,16 @@ discard block |
||
| 477 | 529 | } |
| 478 | 530 | // call getQuotaRoot asynchronously in getRows by initiating a client Server roundtrip |
| 479 | 531 | $quota = false;//$this->mail_bo->getQuotaRoot(); |
| 480 | - if($quota !== false && $quota['limit'] != 'NOT SET') { |
|
| 532 | + if($quota !== false && $quota['limit'] != 'NOT SET') |
|
| 533 | + { |
|
| 481 | 534 | $quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']); |
| 482 | 535 | $content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text']; |
| 483 | 536 | $content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent']; |
| 484 | 537 | $content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class']; |
| 485 | 538 | $content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = ""; |
| 486 | - } else { |
|
| 539 | + } |
|
| 540 | + else |
|
| 541 | + { |
|
| 487 | 542 | $content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = lang("Quota not provided by server"); |
| 488 | 543 | $content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = "mail_DisplayNone"; |
| 489 | 544 | $content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone"; |
@@ -491,7 +546,8 @@ discard block |
||
| 491 | 546 | // call gatherVacation asynchronously in getRows by initiating a client Server roundtrip |
| 492 | 547 | $vacation = false;//$this->gatherVacation(); |
| 493 | 548 | //error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation)); |
| 494 | - if($vacation) { |
|
| 549 | + if($vacation) |
|
| 550 | + { |
|
| 495 | 551 | if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date' && $vacation['end_date'] > time())) |
| 496 | 552 | { |
| 497 | 553 | $dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']/*.' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat']!='24'?'h:i a':'H:i')*/; |
@@ -525,19 +581,31 @@ discard block |
||
| 525 | 581 | $keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5'); |
| 526 | 582 | foreach($keywords as &$k) |
| 527 | 583 | { |
| 528 | - if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]); |
|
| 584 | + if (array_key_exists($k,$this->statusTypes)) |
|
| 585 | + { |
|
| 586 | + unset($this->statusTypes[$k]); |
|
| 587 | + } |
|
| 529 | 588 | } |
| 530 | 589 | } |
| 531 | 590 | |
| 532 | - if (!isset($content[self::$nm_index]['foldertree'])) $content[self::$nm_index]['foldertree'] = $this->mail_bo->profileID.self::$delimiter.'INBOX'; |
|
| 533 | - if (!isset($content[self::$nm_index]['selectedFolder'])) $content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.'INBOX'; |
|
| 591 | + if (!isset($content[self::$nm_index]['foldertree'])) |
|
| 592 | + { |
|
| 593 | + $content[self::$nm_index]['foldertree'] = $this->mail_bo->profileID.self::$delimiter.'INBOX'; |
|
| 594 | + } |
|
| 595 | + if (!isset($content[self::$nm_index]['selectedFolder'])) |
|
| 596 | + { |
|
| 597 | + $content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.'INBOX'; |
|
| 598 | + } |
|
| 534 | 599 | |
| 535 | 600 | $content[self::$nm_index]['foldertree'] = $content[self::$nm_index]['selectedFolder']; |
| 536 | 601 | |
| 537 | 602 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
| 538 | 603 | { |
| 539 | 604 | Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
| 540 | - if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 605 | + if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
|
| 606 | + { |
|
| 607 | + Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 608 | + } |
|
| 541 | 609 | } |
| 542 | 610 | if (!Mail::$supportsORinQuery[$this->mail_bo->profileID]) |
| 543 | 611 | { |
@@ -747,10 +815,16 @@ discard block |
||
| 747 | 815 | $etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $tree_actions); |
| 748 | 816 | |
| 749 | 817 | // sending preview toolbar actions |
| 750 | - if ($content['mailSplitter']) $etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions()); |
|
| 818 | + if ($content['mailSplitter']) |
|
| 819 | + { |
|
| 820 | + $etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions()); |
|
| 821 | + } |
|
| 751 | 822 | |
| 752 | 823 | // We need to send toolbar actions to client-side because view template needs them |
| 753 | - if (Api\Header\UserAgent::mobile()) $sel_options['toolbar'] = $this->get_toolbar_actions(); |
|
| 824 | + if (Api\Header\UserAgent::mobile()) |
|
| 825 | + { |
|
| 826 | + $sel_options['toolbar'] = $this->get_toolbar_actions(); |
|
| 827 | + } |
|
| 754 | 828 | |
| 755 | 829 | //we use the category "filter" option as specifier where we want to search (quick, subject, from, to, etc. ....) |
| 756 | 830 | if (empty($content[self::$nm_index]['cat_id']) || empty($content[self::$nm_index]['search'])) |
@@ -758,7 +832,10 @@ discard block |
||
| 758 | 832 | $content[self::$nm_index]['cat_id']=($content[self::$nm_index]['cat_id']?(!Mail::$supportsORinQuery[$this->mail_bo->profileID]&&($content[self::$nm_index]['cat_id']=='quick'||$content[self::$nm_index]['cat_id']=='quickwithcc')?'subject':$content[self::$nm_index]['cat_id']):(Mail::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject')); |
| 759 | 833 | } |
| 760 | 834 | $readonlys = $preserv = array(); |
| 761 | - if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 835 | + if (Mail::$debugTimes) |
|
| 836 | + { |
|
| 837 | + Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 838 | + } |
|
| 762 | 839 | } |
| 763 | 840 | catch (Exception $e) |
| 764 | 841 | { |
@@ -768,7 +845,10 @@ discard block |
||
| 768 | 845 | //return false; |
| 769 | 846 | } |
| 770 | 847 | // Check preview pane is enabled, then show spliter |
| 771 | - if ($this->mail_bo->mailPreferences['previewPane']) $etpl->setElementAttribute('mail.index.spliter', 'template', 'mail.index.nospliter'); |
|
| 848 | + if ($this->mail_bo->mailPreferences['previewPane']) |
|
| 849 | + { |
|
| 850 | + $etpl->setElementAttribute('mail.index.spliter', 'template', 'mail.index.nospliter'); |
|
| 851 | + } |
|
| 772 | 852 | |
| 773 | 853 | return $etpl->exec('mail.mail_ui.index',$content,$sel_options,$readonlys,$preserv); |
| 774 | 854 | } |
@@ -807,12 +887,18 @@ discard block |
||
| 807 | 887 | public function ajax_foldertree($_nodeID = null,$_subscribedOnly=null) |
| 808 | 888 | { |
| 809 | 889 | $nodeID = $_GET['id']; |
| 810 | - if (!is_null($_nodeID)) $nodeID = $_nodeID; |
|
| 890 | + if (!is_null($_nodeID)) |
|
| 891 | + { |
|
| 892 | + $nodeID = $_nodeID; |
|
| 893 | + } |
|
| 811 | 894 | $subscribedOnly = (bool)(!is_null($_subscribedOnly)?$_subscribedOnly:!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
| 812 | 895 | $fetchCounters = !is_null($_nodeID); |
| 813 | 896 | list($_profileID,$_folderName) = explode(self::$delimiter,$nodeID,2); |
| 814 | 897 | |
| 815 | - if (!empty($_folderName)) $fetchCounters = true; |
|
| 898 | + if (!empty($_folderName)) |
|
| 899 | + { |
|
| 900 | + $fetchCounters = true; |
|
| 901 | + } |
|
| 816 | 902 | |
| 817 | 903 | // Check if it is called for refresh root |
| 818 | 904 | // then we need to reinitialized the index tree |
@@ -824,7 +910,10 @@ discard block |
||
| 824 | 910 | { |
| 825 | 911 | $data = $this->mail_tree->getTree($nodeID,$_profileID,0, false,$subscribedOnly,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
| 826 | 912 | } |
| 827 | - if (!is_null($_nodeID)) return $data; |
|
| 913 | + if (!is_null($_nodeID)) |
|
| 914 | + { |
|
| 915 | + return $data; |
|
| 916 | + } |
|
| 828 | 917 | Etemplate\Widget\Tree::send_quote_json($data); |
| 829 | 918 | } |
| 830 | 919 | |
@@ -890,7 +979,10 @@ discard block |
||
| 890 | 979 | $accArray[$acc_id] = str_replace(array('<','>'),array('[',']'),$identity_name);// as angle brackets are quoted, display in Javascript messages when used is ugly, so use square brackets instead |
| 891 | 980 | } |
| 892 | 981 | } |
| 893 | - if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont=array(); |
|
| 982 | + if (!is_array($lastFoldersUsedForMoveCont)) |
|
| 983 | + { |
|
| 984 | + $lastFoldersUsedForMoveCont=array(); |
|
| 985 | + } |
|
| 894 | 986 | foreach (array_keys($lastFoldersUsedForMoveCont) as $pid) |
| 895 | 987 | { |
| 896 | 988 | if ($this->mail_bo->profileID==$pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID])) |
@@ -906,9 +998,12 @@ discard block |
||
| 906 | 998 | $moveaction .= $lastFolderUsedForMoveCont; |
| 907 | 999 | //error_log(__METHOD__.__LINE__.'#'.$moveaction); |
| 908 | 1000 | //error_log(__METHOD__.__LINE__.'#'.$currentArchiveActionKey); |
| 909 | - if ($this->mail_bo->folderExists($i)) // only 10 entries per mailaccount.Control this on setting the buffered folders |
|
| 1001 | + if ($this->mail_bo->folderExists($i)) |
|
| 1002 | + { |
|
| 1003 | + // only 10 entries per mailaccount.Control this on setting the buffered folders |
|
| 910 | 1004 | { |
| 911 | 1005 | $fS['profileID'] = $this->mail_bo->profileID; |
| 1006 | + } |
|
| 912 | 1007 | $fS['profileName'] = $accArray[$this->mail_bo->profileID]; |
| 913 | 1008 | $fS['shortDisplayName'] = $i; |
| 914 | 1009 | $moveactions[$moveaction] = $fS; |
@@ -928,9 +1023,12 @@ discard block |
||
| 928 | 1023 | foreach ($lastFoldersUsedForMoveCont[$pid] as $i => $lastFolderUsedForMoveCont) |
| 929 | 1024 | { |
| 930 | 1025 | //error_log(__METHOD__.__LINE__."$i => $lastFolderUsedForMoveCont"); |
| 931 | - if (!empty($lastFolderUsedForMoveCont)) // only 10 entries per mailaccount.Control this on setting the buffered folders |
|
| 1026 | + if (!empty($lastFolderUsedForMoveCont)) |
|
| 1027 | + { |
|
| 1028 | + // only 10 entries per mailaccount.Control this on setting the buffered folders |
|
| 932 | 1029 | { |
| 933 | 1030 | $moveaction = 'move_'.$lastFolderUsedForMoveCont; |
| 1031 | + } |
|
| 934 | 1032 | //error_log(__METHOD__.__LINE__.'#'.$moveaction); |
| 935 | 1033 | $fS = array(); |
| 936 | 1034 | $fS['profileID'] = $pid; |
@@ -1033,7 +1131,9 @@ discard block |
||
| 1033 | 1131 | 'children' => $children, |
| 1034 | 1132 | ); |
| 1035 | 1133 | |
| 1036 | - } else { |
|
| 1134 | + } |
|
| 1135 | + else |
|
| 1136 | + { |
|
| 1037 | 1137 | $group++; |
| 1038 | 1138 | } |
| 1039 | 1139 | |
@@ -1308,21 +1408,33 @@ discard block |
||
| 1308 | 1408 | $rows=array(); |
| 1309 | 1409 | return 0; |
| 1310 | 1410 | } |
| 1311 | - if (empty($folderName)) $query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX'; |
|
| 1411 | + if (empty($folderName)) |
|
| 1412 | + { |
|
| 1413 | + $query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX'; |
|
| 1414 | + } |
|
| 1312 | 1415 | } |
| 1313 | 1416 | } |
| 1314 | 1417 | if (!isset($mail_ui)) |
| 1315 | 1418 | { |
| 1316 | 1419 | $mail_ui = new mail_ui(true); // run constructor for current profile |
| 1317 | - if (empty($query['selectedFolder'])) $query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX'; |
|
| 1420 | + if (empty($query['selectedFolder'])) |
|
| 1421 | + { |
|
| 1422 | + $query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX'; |
|
| 1423 | + } |
|
| 1318 | 1424 | } |
| 1319 | 1425 | //error_log(__METHOD__.__LINE__.' SelectedFolder:'.$query['selectedFolder'].' Start:'.$query['start'].' NumRows:'.$query['num_rows'].array2string($query['order']).'->'.array2string($query['sort'])); |
| 1320 | 1426 | //Mail::$debugTimes=true; |
| 1321 | - if (Mail::$debugTimes) $starttime = microtime(true); |
|
| 1427 | + if (Mail::$debugTimes) |
|
| 1428 | + { |
|
| 1429 | + $starttime = microtime(true); |
|
| 1430 | + } |
|
| 1322 | 1431 | //$query['search'] is the phrase in the searchbox |
| 1323 | 1432 | |
| 1324 | 1433 | $mail_ui->mail_bo->restoreSessionData(); |
| 1325 | - if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder']; |
|
| 1434 | + if (isset($query['selectedFolder'])) |
|
| 1435 | + { |
|
| 1436 | + $mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder']; |
|
| 1437 | + } |
|
| 1326 | 1438 | $mail_ui->mail_bo->saveSessionData(); |
| 1327 | 1439 | |
| 1328 | 1440 | $sRToFetch = null; |
@@ -1333,7 +1445,10 @@ discard block |
||
| 1333 | 1445 | unset($app); |
| 1334 | 1446 | } |
| 1335 | 1447 | //save selected Folder to sessionData (mailbox)->currentFolder |
| 1336 | - if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$_folderName; |
|
| 1448 | + if (isset($query['selectedFolder'])) |
|
| 1449 | + { |
|
| 1450 | + $mail_ui->mail_bo->sessionData['mailbox']=$_folderName; |
|
| 1451 | + } |
|
| 1337 | 1452 | $toSchema = false;//decides to select list schema with column to selected (if false fromaddress is default) |
| 1338 | 1453 | if ($mail_ui->mail_bo->folderExists($_folderName)) |
| 1339 | 1454 | { |
@@ -1366,8 +1481,16 @@ discard block |
||
| 1366 | 1481 | } |
| 1367 | 1482 | //error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']); |
| 1368 | 1483 | $cutoffdate = $cutoffdate2 = null; |
| 1369 | - if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate |
|
| 1370 | - if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate |
|
| 1484 | + if ($query['startdate']) |
|
| 1485 | + { |
|
| 1486 | + $cutoffdate = Api\DateTime::to($query['startdate'],'ts'); |
|
| 1487 | + } |
|
| 1488 | + //SINCE, enddate |
|
| 1489 | + if ($query['enddate']) |
|
| 1490 | + { |
|
| 1491 | + $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts'); |
|
| 1492 | + } |
|
| 1493 | + //BEFORE, startdate |
|
| 1371 | 1494 | //error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate); |
| 1372 | 1495 | $filter = array( |
| 1373 | 1496 | 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')), |
@@ -1376,15 +1499,24 @@ discard block |
||
| 1376 | 1499 | 'status' => 'any', |
| 1377 | 1500 | //'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2) |
| 1378 | 1501 | ); |
| 1379 | - if ($query['enddate']||$query['startdate']) { |
|
| 1502 | + if ($query['enddate']||$query['startdate']) |
|
| 1503 | + { |
|
| 1380 | 1504 | $filter['range'] = "BETWEEN"; |
| 1381 | - if ($cutoffdate) { |
|
| 1505 | + if ($cutoffdate) |
|
| 1506 | + { |
|
| 1382 | 1507 | $filter[(empty($cutoffdate2)?'date':'since')] = date("d-M-Y", $cutoffdate); |
| 1383 | - if (empty($cutoffdate2)) $filter['range'] = "SINCE"; |
|
| 1508 | + if (empty($cutoffdate2)) |
|
| 1509 | + { |
|
| 1510 | + $filter['range'] = "SINCE"; |
|
| 1511 | + } |
|
| 1384 | 1512 | } |
| 1385 | - if ($cutoffdate2) { |
|
| 1513 | + if ($cutoffdate2) |
|
| 1514 | + { |
|
| 1386 | 1515 | $filter[(empty($cutoffdate)?'date':'before')] = date("d-M-Y", $cutoffdate2); |
| 1387 | - if (empty($cutoffdate)) $filter['range'] = "BEFORE"; |
|
| 1516 | + if (empty($cutoffdate)) |
|
| 1517 | + { |
|
| 1518 | + $filter['range'] = "BEFORE"; |
|
| 1519 | + } |
|
| 1388 | 1520 | } |
| 1389 | 1521 | } |
| 1390 | 1522 | } |
@@ -1436,7 +1568,10 @@ discard block |
||
| 1436 | 1568 | $rowsFetched['messages'] = $_sR['count']; |
| 1437 | 1569 | $ids = $_sR['match']->ids; |
| 1438 | 1570 | // if $sR is false, something failed fundamentally |
| 1439 | - if($reverse === true) $ids = ($ids===false?array():array_reverse((array)$ids)); |
|
| 1571 | + if($reverse === true) |
|
| 1572 | + { |
|
| 1573 | + $ids = ($ids===false?array():array_reverse((array)$ids)); |
|
| 1574 | + } |
|
| 1440 | 1575 | $sR = array_slice((array)$ids,($offset==0?0:$offset-1),$maxMessages); // we need only $maxMessages of uids |
| 1441 | 1576 | $sRToFetch = $sR;//array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids |
| 1442 | 1577 | //error_log(__METHOD__.__LINE__.' Rows fetched (UID only):'.count($sR).' Data:'.array2string($sR)); |
@@ -1502,7 +1637,10 @@ discard block |
||
| 1502 | 1637 | } |
| 1503 | 1638 | else |
| 1504 | 1639 | { |
| 1505 | - if (!empty($v)) $sortResult['header'][] = array('uid'=>$v); |
|
| 1640 | + if (!empty($v)) |
|
| 1641 | + { |
|
| 1642 | + $sortResult['header'][] = array('uid'=>$v); |
|
| 1643 | + } |
|
| 1506 | 1644 | } |
| 1507 | 1645 | } |
| 1508 | 1646 | } |
@@ -1511,15 +1649,24 @@ discard block |
||
| 1511 | 1649 | $sortResult = $sortResultwH; |
| 1512 | 1650 | } |
| 1513 | 1651 | $rowsFetched['rowsFetched'] = count($sortResult['header']); |
| 1514 | - if (empty($rowsFetched['messages'])) $rowsFetched['messages'] = $rowsFetched['rowsFetched']; |
|
| 1652 | + if (empty($rowsFetched['messages'])) |
|
| 1653 | + { |
|
| 1654 | + $rowsFetched['messages'] = $rowsFetched['rowsFetched']; |
|
| 1655 | + } |
|
| 1515 | 1656 | |
| 1516 | 1657 | //error_log(__METHOD__.__LINE__.' Rows fetched:'.$rowsFetched.' Data:'.array2string($sortResult)); |
| 1517 | 1658 | $cols = array('row_id','uid','status','attachments','subject','address','toaddress','fromaddress','ccaddress','additionaltoaddress','date','size','modified','bodypreview'); |
| 1518 | - if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE') unset($cols[0]); |
|
| 1659 | + if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE') |
|
| 1660 | + { |
|
| 1661 | + unset($cols[0]); |
|
| 1662 | + } |
|
| 1519 | 1663 | $rows = $mail_ui->header2gridelements($sortResult['header'],$cols, $_folderName, $folderType=$toSchema); |
| 1520 | 1664 | //error_log(__METHOD__.__LINE__.array2string($rows)); |
| 1521 | 1665 | |
| 1522 | - if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__); |
|
| 1666 | + if (Mail::$debugTimes) |
|
| 1667 | + { |
|
| 1668 | + Mail::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__); |
|
| 1669 | + } |
|
| 1523 | 1670 | return $rowsFetched['messages']; |
| 1524 | 1671 | } |
| 1525 | 1672 | |
@@ -1621,7 +1768,10 @@ discard block |
||
| 1621 | 1768 | $actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act]; |
| 1622 | 1769 | break; |
| 1623 | 1770 | default: |
| 1624 | - if (isset($actions[$act])) $actionsenabled[$act]=$actions[$act]; |
|
| 1771 | + if (isset($actions[$act])) |
|
| 1772 | + { |
|
| 1773 | + $actionsenabled[$act]=$actions[$act]; |
|
| 1774 | + } |
|
| 1625 | 1775 | } |
| 1626 | 1776 | } |
| 1627 | 1777 | unset($actionsenabled['drag_mail']); |
@@ -1643,7 +1793,10 @@ discard block |
||
| 1643 | 1793 | */ |
| 1644 | 1794 | public function header2gridelements($_headers, $cols, $_folderName, $_folderType=0) |
| 1645 | 1795 | { |
| 1646 | - if (Mail::$debugTimes) $starttime = microtime(true); |
|
| 1796 | + if (Mail::$debugTimes) |
|
| 1797 | + { |
|
| 1798 | + $starttime = microtime(true); |
|
| 1799 | + } |
|
| 1647 | 1800 | $rv = array(); |
| 1648 | 1801 | $i=0; |
| 1649 | 1802 | foreach((array)$_headers as $header) |
@@ -1656,17 +1809,50 @@ discard block |
||
| 1656 | 1809 | $data['row_id']=$this->createRowID($_folderName,$message_uid); |
| 1657 | 1810 | |
| 1658 | 1811 | $flags = ""; |
| 1659 | - if(!empty($header['recent'])) $flags .= "R"; |
|
| 1660 | - if(!empty($header['flagged'])) $flags .= "F"; |
|
| 1661 | - if(!empty($header['answered'])) $flags .= "A"; |
|
| 1662 | - if(!empty($header['forwarded'])) $flags .= "W"; |
|
| 1663 | - if(!empty($header['deleted'])) $flags .= "D"; |
|
| 1664 | - if(!empty($header['seen'])) $flags .= "S"; |
|
| 1665 | - if(!empty($header['label1'])) $flags .= "1"; |
|
| 1666 | - if(!empty($header['label2'])) $flags .= "2"; |
|
| 1667 | - if(!empty($header['label3'])) $flags .= "3"; |
|
| 1668 | - if(!empty($header['label4'])) $flags .= "4"; |
|
| 1669 | - if(!empty($header['label5'])) $flags .= "5"; |
|
| 1812 | + if(!empty($header['recent'])) |
|
| 1813 | + { |
|
| 1814 | + $flags .= "R"; |
|
| 1815 | + } |
|
| 1816 | + if(!empty($header['flagged'])) |
|
| 1817 | + { |
|
| 1818 | + $flags .= "F"; |
|
| 1819 | + } |
|
| 1820 | + if(!empty($header['answered'])) |
|
| 1821 | + { |
|
| 1822 | + $flags .= "A"; |
|
| 1823 | + } |
|
| 1824 | + if(!empty($header['forwarded'])) |
|
| 1825 | + { |
|
| 1826 | + $flags .= "W"; |
|
| 1827 | + } |
|
| 1828 | + if(!empty($header['deleted'])) |
|
| 1829 | + { |
|
| 1830 | + $flags .= "D"; |
|
| 1831 | + } |
|
| 1832 | + if(!empty($header['seen'])) |
|
| 1833 | + { |
|
| 1834 | + $flags .= "S"; |
|
| 1835 | + } |
|
| 1836 | + if(!empty($header['label1'])) |
|
| 1837 | + { |
|
| 1838 | + $flags .= "1"; |
|
| 1839 | + } |
|
| 1840 | + if(!empty($header['label2'])) |
|
| 1841 | + { |
|
| 1842 | + $flags .= "2"; |
|
| 1843 | + } |
|
| 1844 | + if(!empty($header['label3'])) |
|
| 1845 | + { |
|
| 1846 | + $flags .= "3"; |
|
| 1847 | + } |
|
| 1848 | + if(!empty($header['label4'])) |
|
| 1849 | + { |
|
| 1850 | + $flags .= "4"; |
|
| 1851 | + } |
|
| 1852 | + if(!empty($header['label5'])) |
|
| 1853 | + { |
|
| 1854 | + $flags .= "5"; |
|
| 1855 | + } |
|
| 1670 | 1856 | |
| 1671 | 1857 | $data["status"] = "<span class=\"status_img\"></span>"; |
| 1672 | 1858 | //error_log(__METHOD__.array2string($header).' Flags:'.$flags); |
@@ -1674,41 +1860,53 @@ discard block |
||
| 1674 | 1860 | // the css for this row |
| 1675 | 1861 | $is_recent=false; |
| 1676 | 1862 | $css_styles = array("mail"); |
| 1677 | - if ($header['deleted']) { |
|
| 1863 | + if ($header['deleted']) |
|
| 1864 | + { |
|
| 1678 | 1865 | $css_styles[] = 'deleted'; |
| 1679 | 1866 | } |
| 1680 | - if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded'])) { |
|
| 1867 | + if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded'])) |
|
| 1868 | + { |
|
| 1681 | 1869 | $css_styles[] = 'recent'; |
| 1682 | 1870 | $is_recent=true; |
| 1683 | 1871 | } |
| 1684 | - if ($header['priority'] < 3) { |
|
| 1872 | + if ($header['priority'] < 3) |
|
| 1873 | + { |
|
| 1685 | 1874 | $css_styles[] = 'prio_high'; |
| 1686 | 1875 | } |
| 1687 | - if ($header['flagged']) { |
|
| 1876 | + if ($header['flagged']) |
|
| 1877 | + { |
|
| 1688 | 1878 | $css_styles[] = 'flagged'; |
| 1689 | 1879 | } |
| 1690 | - if (!$header['seen']) { |
|
| 1880 | + if (!$header['seen']) |
|
| 1881 | + { |
|
| 1691 | 1882 | $css_styles[] = 'unseen'; // different status image for recent // solved via css !important |
| 1692 | 1883 | } |
| 1693 | - if ($header['answered']) { |
|
| 1884 | + if ($header['answered']) |
|
| 1885 | + { |
|
| 1694 | 1886 | $css_styles[] = 'replied'; |
| 1695 | 1887 | } |
| 1696 | - if ($header['forwarded']) { |
|
| 1888 | + if ($header['forwarded']) |
|
| 1889 | + { |
|
| 1697 | 1890 | $css_styles[] = 'forwarded'; |
| 1698 | 1891 | } |
| 1699 | - if ($header['label1']) { |
|
| 1892 | + if ($header['label1']) |
|
| 1893 | + { |
|
| 1700 | 1894 | $css_styles[] = 'labelone'; |
| 1701 | 1895 | } |
| 1702 | - if ($header['label2']) { |
|
| 1896 | + if ($header['label2']) |
|
| 1897 | + { |
|
| 1703 | 1898 | $css_styles[] = 'labeltwo'; |
| 1704 | 1899 | } |
| 1705 | - if ($header['label3']) { |
|
| 1900 | + if ($header['label3']) |
|
| 1901 | + { |
|
| 1706 | 1902 | $css_styles[] = 'labelthree'; |
| 1707 | 1903 | } |
| 1708 | - if ($header['label4']) { |
|
| 1904 | + if ($header['label4']) |
|
| 1905 | + { |
|
| 1709 | 1906 | $css_styles[] = 'labelfour'; |
| 1710 | 1907 | } |
| 1711 | - if ($header['label5']) { |
|
| 1908 | + if ($header['label5']) |
|
| 1909 | + { |
|
| 1712 | 1910 | $css_styles[] = 'labelfive'; |
| 1713 | 1911 | } |
| 1714 | 1912 | |
@@ -1725,10 +1923,13 @@ discard block |
||
| 1725 | 1923 | $header['subject'] = preg_replace($search,$replace,$header['subject']); |
| 1726 | 1924 | // curly brackets get messed up by the template! |
| 1727 | 1925 | |
| 1728 | - if (!empty($header['subject'])) { |
|
| 1926 | + if (!empty($header['subject'])) |
|
| 1927 | + { |
|
| 1729 | 1928 | // make the subject shorter if it is to long |
| 1730 | 1929 | $subject = $header['subject']; |
| 1731 | - } else { |
|
| 1930 | + } |
|
| 1931 | + else |
|
| 1932 | + { |
|
| 1732 | 1933 | $subject = '('. lang('no subject') .')'; |
| 1733 | 1934 | } |
| 1734 | 1935 | |
@@ -1770,15 +1971,22 @@ discard block |
||
| 1770 | 1971 | } |
| 1771 | 1972 | |
| 1772 | 1973 | $attachmentFlag = $image; |
| 1773 | - } else { |
|
| 1974 | + } |
|
| 1975 | + else |
|
| 1976 | + { |
|
| 1774 | 1977 | $attachmentFlag =' '; |
| 1775 | 1978 | } |
| 1776 | 1979 | // show priority flag |
| 1777 | - if ($header['priority'] < 3) { |
|
| 1980 | + if ($header['priority'] < 3) |
|
| 1981 | + { |
|
| 1778 | 1982 | $image = Api\Html::image('mail','prio_high'); |
| 1779 | - } elseif ($header['priority'] > 3) { |
|
| 1983 | + } |
|
| 1984 | + elseif ($header['priority'] > 3) |
|
| 1985 | + { |
|
| 1780 | 1986 | $image = Api\Html::image('mail','prio_low'); |
| 1781 | - } else { |
|
| 1987 | + } |
|
| 1988 | + else |
|
| 1989 | + { |
|
| 1782 | 1990 | $image = ''; |
| 1783 | 1991 | } |
| 1784 | 1992 | // show a flag for flagged messages |
@@ -1820,26 +2028,53 @@ discard block |
||
| 1820 | 2028 | } |
| 1821 | 2029 | |
| 1822 | 2030 | if (in_array("size", $cols)) |
| 1823 | - $data["size"] = $header['size']; /// size |
|
| 2031 | + { |
|
| 2032 | + $data["size"] = $header['size']; |
|
| 2033 | + } |
|
| 2034 | + /// size |
|
| 1824 | 2035 | |
| 1825 | 2036 | $data["class"] = implode(' ', $css_styles); |
| 1826 | 2037 | //translate style-classes back to flags |
| 1827 | 2038 | $data['flags'] = Array(); |
| 1828 | - if ($header['seen']) $data["flags"]['read'] = 'read'; |
|
| 1829 | - foreach ($css_styles as &$flag) { |
|
| 2039 | + if ($header['seen']) |
|
| 2040 | + { |
|
| 2041 | + $data["flags"]['read'] = 'read'; |
|
| 2042 | + } |
|
| 2043 | + foreach ($css_styles as &$flag) |
|
| 2044 | + { |
|
| 1830 | 2045 | if ($flag!='mail') |
| 1831 | 2046 | { |
| 1832 | - if ($flag=='labelone') {$data["flags"]['label1'] = 'label1';} |
|
| 1833 | - elseif ($flag=='labeltwo') {$data["flags"]['label2'] = 'label2';} |
|
| 1834 | - elseif ($flag=='labelthree') {$data["flags"]['label3'] = 'label3';} |
|
| 1835 | - elseif ($flag=='labelfour') {$data["flags"]['label4'] = 'label4';} |
|
| 1836 | - elseif ($flag=='labelfive') {$data["flags"]['label5'] = 'label5';} |
|
| 1837 | - elseif ($flag=='unseen') {unset($data["flags"]['read']);} |
|
| 1838 | - else $data["flags"][$flag] = $flag; |
|
| 2047 | + if ($flag=='labelone') |
|
| 2048 | + { |
|
| 2049 | +$data["flags"]['label1'] = 'label1';} |
|
| 2050 | + elseif ($flag=='labeltwo') |
|
| 2051 | + { |
|
| 2052 | +$data["flags"]['label2'] = 'label2';} |
|
| 2053 | + elseif ($flag=='labelthree') |
|
| 2054 | + { |
|
| 2055 | +$data["flags"]['label3'] = 'label3';} |
|
| 2056 | + elseif ($flag=='labelfour') |
|
| 2057 | + { |
|
| 2058 | +$data["flags"]['label4'] = 'label4';} |
|
| 2059 | + elseif ($flag=='labelfive') |
|
| 2060 | + { |
|
| 2061 | +$data["flags"]['label5'] = 'label5';} |
|
| 2062 | + elseif ($flag=='unseen') |
|
| 2063 | + { |
|
| 2064 | +unset($data["flags"]['read']);} |
|
| 2065 | + else { |
|
| 2066 | + $data["flags"][$flag] = $flag; |
|
| 2067 | + } |
|
| 1839 | 2068 | } |
| 1840 | 2069 | } |
| 1841 | - if ($header['disposition-notification-to']) $data['dispositionnotificationto'] = $header['disposition-notification-to']; |
|
| 1842 | - if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']); |
|
| 2070 | + if ($header['disposition-notification-to']) |
|
| 2071 | + { |
|
| 2072 | + $data['dispositionnotificationto'] = $header['disposition-notification-to']; |
|
| 2073 | + } |
|
| 2074 | + if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto'])) |
|
| 2075 | + { |
|
| 2076 | + unset($data['dispositionnotificationto']); |
|
| 2077 | + } |
|
| 1843 | 2078 | $data['attachmentsBlock'] = $imageHTMLBlock; |
| 1844 | 2079 | $data['address'] = ($_folderType?$data["toaddress"]:$data["fromaddress"]); |
| 1845 | 2080 | if (in_array("bodypreview", $cols)&&$header['bodypreview']) |
@@ -1849,7 +2084,10 @@ discard block |
||
| 1849 | 2084 | $rv[] = $data; |
| 1850 | 2085 | //error_log(__METHOD__.__LINE__.array2string($data)); |
| 1851 | 2086 | } |
| 1852 | - if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__); |
|
| 2087 | + if (Mail::$debugTimes) |
|
| 2088 | + { |
|
| 2089 | + Mail::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__); |
|
| 2090 | + } |
|
| 1853 | 2091 | |
| 1854 | 2092 | // ToDo: call this ONLY if labels change |
| 1855 | 2093 | Etemplate\Widget::setElementAttribute('toolbar', 'actions', $this->get_toolbar_actions()); |
@@ -1864,8 +2102,14 @@ discard block |
||
| 1864 | 2102 | */ |
| 1865 | 2103 | function displayHeader() |
| 1866 | 2104 | { |
| 1867 | - if(isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 1868 | - if(isset($_GET['part'])) $partID = $_GET['part']; |
|
| 2105 | + if(isset($_GET['id'])) |
|
| 2106 | + { |
|
| 2107 | + $rowID = $_GET['id']; |
|
| 2108 | + } |
|
| 2109 | + if(isset($_GET['part'])) |
|
| 2110 | + { |
|
| 2111 | + $partID = $_GET['part']; |
|
| 2112 | + } |
|
| 1869 | 2113 | |
| 1870 | 2114 | $hA = self::splitRowID($rowID); |
| 1871 | 2115 | $uid = $hA['msgUID']; |
@@ -1889,7 +2133,8 @@ discard block |
||
| 1889 | 2133 | $rawheaders = ""; |
| 1890 | 2134 | // create it new, with good line breaks |
| 1891 | 2135 | reset($newRawHeaders); |
| 1892 | - while(list($key,$value) = @each($newRawHeaders)) { |
|
| 2136 | + while(list($key,$value) = @each($newRawHeaders)) |
|
| 2137 | + { |
|
| 1893 | 2138 | $rawheaders .= wordwrap($value, 90, "\n "); |
| 1894 | 2139 | } |
| 1895 | 2140 | |
@@ -1912,12 +2157,24 @@ discard block |
||
| 1912 | 2157 | */ |
| 1913 | 2158 | function displayMessage($_requesteddata = null) |
| 1914 | 2159 | { |
| 1915 | - if (is_null($_requesteddata)) $_requesteddata = $_GET; |
|
| 2160 | + if (is_null($_requesteddata)) |
|
| 2161 | + { |
|
| 2162 | + $_requesteddata = $_GET; |
|
| 2163 | + } |
|
| 1916 | 2164 | |
| 1917 | 2165 | $preventRedirect=false; |
| 1918 | - if(isset($_requesteddata['id'])) $rowID = $_requesteddata['id']; |
|
| 1919 | - if(isset($_requesteddata['part'])) $partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null; |
|
| 1920 | - if(isset($_requesteddata['mode'])) $preventRedirect = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false); |
|
| 2166 | + if(isset($_requesteddata['id'])) |
|
| 2167 | + { |
|
| 2168 | + $rowID = $_requesteddata['id']; |
|
| 2169 | + } |
|
| 2170 | + if(isset($_requesteddata['part'])) |
|
| 2171 | + { |
|
| 2172 | + $partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null; |
|
| 2173 | + } |
|
| 2174 | + if(isset($_requesteddata['mode'])) |
|
| 2175 | + { |
|
| 2176 | + $preventRedirect = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false); |
|
| 2177 | + } |
|
| 1921 | 2178 | |
| 1922 | 2179 | $hA = self::splitRowID($rowID); |
| 1923 | 2180 | $uid = $hA['msgUID']; |
@@ -1930,8 +2187,14 @@ discard block |
||
| 1930 | 2187 | $this->changeProfile($icServerID); |
| 1931 | 2188 | } |
| 1932 | 2189 | $htmlOptions = $this->mail_bo->htmlOptions; |
| 1933 | - if (!empty($_requesteddata['tryastext'])) $htmlOptions = "only_if_no_text"; |
|
| 1934 | - if (!empty($_requesteddata['tryashtml'])) $htmlOptions = "always_display"; |
|
| 2190 | + if (!empty($_requesteddata['tryastext'])) |
|
| 2191 | + { |
|
| 2192 | + $htmlOptions = "only_if_no_text"; |
|
| 2193 | + } |
|
| 2194 | + if (!empty($_requesteddata['tryashtml'])) |
|
| 2195 | + { |
|
| 2196 | + $htmlOptions = "always_display"; |
|
| 2197 | + } |
|
| 1935 | 2198 | |
| 1936 | 2199 | //error_log(__METHOD__.__LINE__.array2string($hA)); |
| 1937 | 2200 | if (($this->mail_bo->isDraftFolder($mailbox)) && $_requesteddata['mode'] == 'print') |
@@ -1955,14 +2218,20 @@ discard block |
||
| 1955 | 2218 | $error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3",$mailbox,$uid,$partID); |
| 1956 | 2219 | Framework::message($e->getMessage(), 'error'); |
| 1957 | 2220 | } |
| 1958 | - if (!empty($uid)) $this->mail_bo->getFlags($uid); |
|
| 2221 | + if (!empty($uid)) |
|
| 2222 | + { |
|
| 2223 | + $this->mail_bo->getFlags($uid); |
|
| 2224 | + } |
|
| 1959 | 2225 | $envelope = $this->mail_bo->getMessageEnvelope($uid, $partID,true,$mailbox); |
| 1960 | 2226 | //error_log(__METHOD__.__LINE__.array2string($envelope)); |
| 1961 | 2227 | $this->mail_bo->getMessageRawHeader($uid, $partID,$mailbox); |
| 1962 | 2228 | $fetchEmbeddedImages = false; |
| 1963 | 2229 | // if we are in HTML so its likely that we should show the embedded images; as a result |
| 1964 | 2230 | // we do NOT want to see those, that are embedded in the list of attachments |
| 1965 | - if ($htmlOptions !='always_display') $fetchEmbeddedImages = true; |
|
| 2231 | + if ($htmlOptions !='always_display') |
|
| 2232 | + { |
|
| 2233 | + $fetchEmbeddedImages = true; |
|
| 2234 | + } |
|
| 1966 | 2235 | $attachments = $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages,true,true,$mailbox); |
| 1967 | 2236 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
| 1968 | 2237 | $attachmentHTMLBlock = self::createAttachmentBlock($attachments, $rowID, $uid, $mailbox); |
@@ -1978,11 +2247,17 @@ discard block |
||
| 1978 | 2247 | $subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters,'',$envelope['SUBJECT']),false); |
| 1979 | 2248 | |
| 1980 | 2249 | // Set up data for taglist widget(s) |
| 1981 | - if ($envelope['FROM']==$envelope['SENDER']) unset($envelope['SENDER']); |
|
| 2250 | + if ($envelope['FROM']==$envelope['SENDER']) |
|
| 2251 | + { |
|
| 2252 | + unset($envelope['SENDER']); |
|
| 2253 | + } |
|
| 1982 | 2254 | $sel_options = array(); |
| 1983 | 2255 | foreach(array('SENDER','FROM','TO','CC','BCC') as $field) |
| 1984 | 2256 | { |
| 1985 | - if (!isset($envelope[$field])) continue; |
|
| 2257 | + if (!isset($envelope[$field])) |
|
| 2258 | + { |
|
| 2259 | + continue; |
|
| 2260 | + } |
|
| 1986 | 2261 | foreach($envelope[$field] as $field_data) |
| 1987 | 2262 | { |
| 1988 | 2263 | //error_log(__METHOD__.__LINE__.array2string($field_data)); |
@@ -1996,7 +2271,10 @@ discard block |
||
| 1996 | 2271 | } |
| 1997 | 2272 | $actionsenabled = $this->getDisplayToolbarActions(); |
| 1998 | 2273 | $content['displayToolbaractions'] = json_encode($actionsenabled); |
| 1999 | - if (empty($subject)) $subject = lang('no subject'); |
|
| 2274 | + if (empty($subject)) |
|
| 2275 | + { |
|
| 2276 | + $subject = lang('no subject'); |
|
| 2277 | + } |
|
| 2000 | 2278 | $content['msg'] = (is_array($error_msg)?implode("<br>",$error_msg):$error_msg); |
| 2001 | 2279 | // Send mail ID so we can use it for actions |
| 2002 | 2280 | $content['mail_id'] = $rowID; |
@@ -2007,8 +2285,14 @@ discard block |
||
| 2007 | 2285 | $content['mail_displaydate'] = Mail::_strtotime($headers['DATE'],'ts',true); |
| 2008 | 2286 | $content['mail_displaysubject'] = $subject; |
| 2009 | 2287 | $linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody","_messageID"=>$rowID); |
| 2010 | - if (!empty($partID)) $linkData['_partID']=$partID; |
|
| 2011 | - if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions']=$htmlOptions; |
|
| 2288 | + if (!empty($partID)) |
|
| 2289 | + { |
|
| 2290 | + $linkData['_partID']=$partID; |
|
| 2291 | + } |
|
| 2292 | + if ($htmlOptions != $this->mail_bo->htmlOptions) |
|
| 2293 | + { |
|
| 2294 | + $linkData['_htmloptions']=$htmlOptions; |
|
| 2295 | + } |
|
| 2012 | 2296 | $content['mailDisplayBodySrc'] = Egw::link('/index.php',$linkData); |
| 2013 | 2297 | $content['mail_displayattachments'] = $attachmentHTMLBlock; |
| 2014 | 2298 | $content['mail_id']=$rowID; |
@@ -2076,7 +2360,8 @@ discard block |
||
| 2076 | 2360 | { |
| 2077 | 2361 | $attachmentHTMLBlock=''; |
| 2078 | 2362 | $attachmentHTML = array(); |
| 2079 | - if (is_array($attachments) && count($attachments) > 0) { |
|
| 2363 | + if (is_array($attachments) && count($attachments) > 0) |
|
| 2364 | + { |
|
| 2080 | 2365 | $url_img_vfs = Api\Html::image('filemanager','navbar', lang('Filemanager'), ' height="16"'); |
| 2081 | 2366 | $url_img_vfs_save_all = Api\Html::image('mail','save_all', lang('Save all')); |
| 2082 | 2367 | |
@@ -2086,7 +2371,10 @@ discard block |
||
| 2086 | 2371 | $attachmentHTML[$key]['filename'] = Api\Translation::convert_jsonsafe($attachmentHTML[$key]['filename'],'utf-8'); |
| 2087 | 2372 | //error_log(array2string($value)); |
| 2088 | 2373 | //error_log(strtoupper($value['mimeType']) .'<->'. Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename'])); |
| 2089 | - if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) $value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']); |
|
| 2374 | + if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) |
|
| 2375 | + { |
|
| 2376 | + $value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']); |
|
| 2377 | + } |
|
| 2090 | 2378 | $attachmentHTML[$key]['type']=$value['mimeType']; |
| 2091 | 2379 | $attachmentHTML[$key]['mimetype'] = Api\MimeMagic::mime2label($value['mimeType']); |
| 2092 | 2380 | $hA = self::splitRowID($rowID); |
@@ -2129,8 +2417,15 @@ discard block |
||
| 2129 | 2417 | $sfxMimeType = $value['mimeType']; |
| 2130 | 2418 | $buff = explode('.',$value['name']); |
| 2131 | 2419 | $suffix = ''; |
| 2132 | - if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
|
| 2133 | - if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix); |
|
| 2420 | + if (is_array($buff)) |
|
| 2421 | + { |
|
| 2422 | + $suffix = array_pop($buff); |
|
| 2423 | + } |
|
| 2424 | + // take the last extension to check with ext2mime |
|
| 2425 | + if (!empty($suffix)) |
|
| 2426 | + { |
|
| 2427 | + $sfxMimeType = Api\MimeMagic::ext2mime($suffix); |
|
| 2428 | + } |
|
| 2134 | 2429 | if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') |
| 2135 | 2430 | { |
| 2136 | 2431 | $attachments[$key]['mimeType'] = $sfxMimeType; |
@@ -2299,9 +2594,12 @@ discard block |
||
| 2299 | 2594 | function quotaDisplay($_usage, $_limit) |
| 2300 | 2595 | { |
| 2301 | 2596 | |
| 2302 | - if($_limit == 0) { |
|
| 2597 | + if($_limit == 0) |
|
| 2598 | + { |
|
| 2303 | 2599 | $quotaPercent=100; |
| 2304 | - } else { |
|
| 2600 | + } |
|
| 2601 | + else |
|
| 2602 | + { |
|
| 2305 | 2603 | $quotaPercent=round(($_usage*100)/$_limit); |
| 2306 | 2604 | } |
| 2307 | 2605 | |
@@ -2309,22 +2607,33 @@ discard block |
||
| 2309 | 2607 | $quotaUsage=Mail::show_readable_size($_usage*1024); |
| 2310 | 2608 | |
| 2311 | 2609 | |
| 2312 | - if($quotaPercent > 90 && $_limit>0) { |
|
| 2610 | + if($quotaPercent > 90 && $_limit>0) |
|
| 2611 | + { |
|
| 2313 | 2612 | $quotaBG='mail-index_QuotaRed'; |
| 2314 | - } elseif($quotaPercent > 80 && $_limit>0) { |
|
| 2613 | + } |
|
| 2614 | + elseif($quotaPercent > 80 && $_limit>0) |
|
| 2615 | + { |
|
| 2315 | 2616 | $quotaBG='mail-index_QuotaYellow'; |
| 2316 | - } else { |
|
| 2617 | + } |
|
| 2618 | + else |
|
| 2619 | + { |
|
| 2317 | 2620 | $quotaBG='mail-index_QuotaGreen'; |
| 2318 | 2621 | } |
| 2319 | 2622 | |
| 2320 | - if($_limit > 0) { |
|
| 2623 | + if($_limit > 0) |
|
| 2624 | + { |
|
| 2321 | 2625 | $quotaText = $quotaUsage .'/'.$quotaLimit; |
| 2322 | - } else { |
|
| 2626 | + } |
|
| 2627 | + else |
|
| 2628 | + { |
|
| 2323 | 2629 | $quotaText = $quotaUsage; |
| 2324 | 2630 | } |
| 2325 | 2631 | |
| 2326 | - if($quotaPercent > 50) { |
|
| 2327 | - } else { |
|
| 2632 | + if($quotaPercent > 50) |
|
| 2633 | + { |
|
| 2634 | + } |
|
| 2635 | + else |
|
| 2636 | + { |
|
| 2328 | 2637 | } |
| 2329 | 2638 | $quota['class'] = $quotaBG; |
| 2330 | 2639 | $quota['text'] = lang('Quota: %1',$quotaText); |
@@ -2342,7 +2651,10 @@ discard block |
||
| 2342 | 2651 | $uid = $_GET['uid']; |
| 2343 | 2652 | $cid = base64_decode($_GET['cid']); |
| 2344 | 2653 | $partID = urldecode($_GET['partID']); |
| 2345 | - if (!empty($_GET['mailbox'])) $mailbox = base64_decode($_GET['mailbox']); |
|
| 2654 | + if (!empty($_GET['mailbox'])) |
|
| 2655 | + { |
|
| 2656 | + $mailbox = base64_decode($_GET['mailbox']); |
|
| 2657 | + } |
|
| 2346 | 2658 | |
| 2347 | 2659 | //error_log(__METHOD__.__LINE__.":$uid, $cid, $partID"); |
| 2348 | 2660 | $this->mail_bo->reopen($mailbox); |
@@ -2374,7 +2686,10 @@ discard block |
||
| 2374 | 2686 | |
| 2375 | 2687 | function getAttachment() |
| 2376 | 2688 | { |
| 2377 | - if(isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 2689 | + if(isset($_GET['id'])) |
|
| 2690 | + { |
|
| 2691 | + $rowID = $_GET['id']; |
|
| 2692 | + } |
|
| 2378 | 2693 | |
| 2379 | 2694 | $hA = self::splitRowID($rowID); |
| 2380 | 2695 | $uid = $hA['msgUID']; |
@@ -2407,10 +2722,20 @@ discard block |
||
| 2407 | 2722 | $sfxMimeType = $attachment['type']; |
| 2408 | 2723 | $buff = explode('.',$attachment['filename']); |
| 2409 | 2724 | $suffix = ''; |
| 2410 | - if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
|
| 2411 | - if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix); |
|
| 2725 | + if (is_array($buff)) |
|
| 2726 | + { |
|
| 2727 | + $suffix = array_pop($buff); |
|
| 2728 | + } |
|
| 2729 | + // take the last extension to check with ext2mime |
|
| 2730 | + if (!empty($suffix)) |
|
| 2731 | + { |
|
| 2732 | + $sfxMimeType = Api\MimeMagic::ext2mime($suffix); |
|
| 2733 | + } |
|
| 2412 | 2734 | $attachment['type'] = $sfxMimeType; |
| 2413 | - if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') $attachment['type'] = strtoupper($sfxMimeType); |
|
| 2735 | + if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') |
|
| 2736 | + { |
|
| 2737 | + $attachment['type'] = strtoupper($sfxMimeType); |
|
| 2738 | + } |
|
| 2414 | 2739 | } |
| 2415 | 2740 | //error_log(__METHOD__.print_r($attachment,true)); |
| 2416 | 2741 | if (strtoupper($attachment['type']) == 'TEXT/CALENDAR' || strtoupper($attachment['type']) == 'TEXT/X-VCALENDAR') |
@@ -2419,7 +2744,10 @@ discard block |
||
| 2419 | 2744 | $calendar_ical = new calendar_ical(); |
| 2420 | 2745 | $eventid = $calendar_ical->search($attachment['attachment'],-1); |
| 2421 | 2746 | //error_log(__METHOD__.array2string($eventid)); |
| 2422 | - if (!$eventid) $eventid = -1; |
|
| 2747 | + if (!$eventid) |
|
| 2748 | + { |
|
| 2749 | + $eventid = -1; |
|
| 2750 | + } |
|
| 2423 | 2751 | $event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true,0,'',null,$attachment['charset']); |
| 2424 | 2752 | //error_log(__METHOD__.$event); |
| 2425 | 2753 | if ((int)$event > 0) |
@@ -2445,7 +2773,10 @@ discard block |
||
| 2445 | 2773 | //error_log(__METHOD__.__LINE__.print_r($vcard,true)); |
| 2446 | 2774 | $contact = $addressbook_vcal->find_contact($vcard,false); |
| 2447 | 2775 | } |
| 2448 | - if (!$contact) $contact = null; |
|
| 2776 | + if (!$contact) |
|
| 2777 | + { |
|
| 2778 | + $contact = null; |
|
| 2779 | + } |
|
| 2449 | 2780 | // if there are not enough fields in the vcard (or the parser was unable to correctly parse the vcard (as of VERSION:3.0 created by MSO)) |
| 2450 | 2781 | if ($contact || count($vcard)>2) |
| 2451 | 2782 | { |
@@ -2479,9 +2810,18 @@ discard block |
||
| 2479 | 2810 | function saveMessage() |
| 2480 | 2811 | { |
| 2481 | 2812 | $display = false; |
| 2482 | - if(isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 2483 | - if(isset($_GET['part'])) $partID = $_GET['part']; |
|
| 2484 | - if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager')) $display = $_GET['location']; |
|
| 2813 | + if(isset($_GET['id'])) |
|
| 2814 | + { |
|
| 2815 | + $rowID = $_GET['id']; |
|
| 2816 | + } |
|
| 2817 | + if(isset($_GET['part'])) |
|
| 2818 | + { |
|
| 2819 | + $partID = $_GET['part']; |
|
| 2820 | + } |
|
| 2821 | + if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager')) |
|
| 2822 | + { |
|
| 2823 | + $display = $_GET['location']; |
|
| 2824 | + } |
|
| 2485 | 2825 | |
| 2486 | 2826 | $hA = self::splitRowID($rowID); |
| 2487 | 2827 | $uid = $hA['msgUID']; |
@@ -2570,7 +2910,10 @@ discard block |
||
| 2570 | 2910 | { |
| 2571 | 2911 | $succeeded = true; |
| 2572 | 2912 | } |
| 2573 | - if ($fp) fclose($fp); |
|
| 2913 | + if ($fp) |
|
| 2914 | + { |
|
| 2915 | + fclose($fp); |
|
| 2916 | + } |
|
| 2574 | 2917 | if ($succeeded) |
| 2575 | 2918 | { |
| 2576 | 2919 | unset($headers['SUBJECT']);//already in filename |
@@ -2620,7 +2963,8 @@ discard block |
||
| 2620 | 2963 | * |
| 2621 | 2964 | * @return array an array of parameters |
| 2622 | 2965 | */ |
| 2623 | - $getParams = function ($id) { |
|
| 2966 | + $getParams = function ($id) |
|
| 2967 | + { |
|
| 2624 | 2968 | list($app,$user,$serverID,$mailbox,$uid,$part,$is_winmail,$name) = explode('::',$id,8); |
| 2625 | 2969 | $lId = implode('::',array($app,$user,$serverID,$mailbox,$uid)); |
| 2626 | 2970 | $hA = mail_ui::splitRowID($lId); |
@@ -2656,7 +3000,10 @@ discard block |
||
| 2656 | 3000 | { |
| 2657 | 3001 | $params = $getParams($id); |
| 2658 | 3002 | // when downloading a single file, name is not set |
| 2659 | - if (!$params['name']&&isset($_GET['name'])&&!$isMultipleDownload) $params['name'] = $_GET['name']; |
|
| 3003 | + if (!$params['name']&&isset($_GET['name'])&&!$isMultipleDownload) |
|
| 3004 | + { |
|
| 3005 | + $params['name'] = $_GET['name']; |
|
| 3006 | + } |
|
| 2660 | 3007 | if ($params['icServer'] && $params['icServer'] != $this->mail_bo->profileID) |
| 2661 | 3008 | { |
| 2662 | 3009 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
@@ -2669,7 +3016,10 @@ discard block |
||
| 2669 | 3016 | // Try to find the right content for file id |
| 2670 | 3017 | foreach ($attachments as $key => $val) |
| 2671 | 3018 | { |
| 2672 | - if ($key == $params['is_winmail']) $attachment = $val; |
|
| 3019 | + if ($key == $params['is_winmail']) |
|
| 3020 | + { |
|
| 3021 | + $attachment = $val; |
|
| 3022 | + } |
|
| 2673 | 3023 | } |
| 2674 | 3024 | } |
| 2675 | 3025 | else |
@@ -2716,7 +3066,10 @@ discard block |
||
| 2716 | 3066 | { |
| 2717 | 3067 | //error_log(__METHOD__.__LINE__.array2string($_GET)); |
| 2718 | 3068 | // First, get all attachment IDs |
| 2719 | - if(isset($_GET['id'])) $message_id = $_GET['id']; |
|
| 3069 | + if(isset($_GET['id'])) |
|
| 3070 | + { |
|
| 3071 | + $message_id = $_GET['id']; |
|
| 3072 | + } |
|
| 2720 | 3073 | //error_log(__METHOD__.__LINE__.$message_id); |
| 2721 | 3074 | $rememberServerID = $this->mail_bo->profileID; |
| 2722 | 3075 | if(!is_numeric($message_id)) |
@@ -2743,7 +3096,10 @@ discard block |
||
| 2743 | 3096 | //get_home_dir may fetch the users startfolder if set; if not writeable, action will fail. TODO: use temp_dir |
| 2744 | 3097 | $homedir = '/home/'.$GLOBALS['egw_info']['user']['account_lid']; |
| 2745 | 3098 | $temp_path = $homedir/*Vfs::get_home_dir()*/ . "/.mail_$message_id"; |
| 2746 | - if(Vfs::is_dir($temp_path)) Vfs::remove ($temp_path); |
|
| 3099 | + if(Vfs::is_dir($temp_path)) |
|
| 3100 | + { |
|
| 3101 | + Vfs::remove ($temp_path); |
|
| 3102 | + } |
|
| 2747 | 3103 | |
| 2748 | 3104 | // Add subject to path, so it gets used as the file name |
| 2749 | 3105 | $path = $temp_path . '/' . ($header['SUBJECT'] ? Vfs::encodePathComponent($header['SUBJECT']) : lang('mail')) .'/'; |
@@ -2768,7 +3124,10 @@ discard block |
||
| 2768 | 3124 | foreach ($tnefAttachments as $key => $val) |
| 2769 | 3125 | { |
| 2770 | 3126 | error_log(__METHOD__.' winmail = '.$key); |
| 2771 | - if ($key == $file['is_winmail']) $attachment = $val; |
|
| 3127 | + if ($key == $file['is_winmail']) |
|
| 3128 | + { |
|
| 3129 | + $attachment = $val; |
|
| 3130 | + } |
|
| 2772 | 3131 | } |
| 2773 | 3132 | } |
| 2774 | 3133 | else |
@@ -2776,7 +3135,10 @@ discard block |
||
| 2776 | 3135 | $attachment = $this->mail_bo->getAttachment($message_id,$file['partID'],$file['is_winmail'],false,true); |
| 2777 | 3136 | } |
| 2778 | 3137 | $success=true; |
| 2779 | - if (empty($file['filename'])) $file['filename'] = $file['name']; |
|
| 3138 | + if (empty($file['filename'])) |
|
| 3139 | + { |
|
| 3140 | + $file['filename'] = $file['name']; |
|
| 3141 | + } |
|
| 2780 | 3142 | if(in_array($path.$file['filename'], $file_list)) |
| 2781 | 3143 | { |
| 2782 | 3144 | $dupe_count[$path.$file['filename']]++; |
@@ -2790,8 +3152,14 @@ discard block |
||
| 2790 | 3152 | $success=false; |
| 2791 | 3153 | Framework::message("Unable to zip {$file['filename']}",'error'); |
| 2792 | 3154 | } |
| 2793 | - if ($success) $file_list[] = $path.$file['filename']; |
|
| 2794 | - if ($fp) fclose($fp); |
|
| 3155 | + if ($success) |
|
| 3156 | + { |
|
| 3157 | + $file_list[] = $path.$file['filename']; |
|
| 3158 | + } |
|
| 3159 | + if ($fp) |
|
| 3160 | + { |
|
| 3161 | + fclose($fp); |
|
| 3162 | + } |
|
| 2795 | 3163 | } |
| 2796 | 3164 | $this->mail_bo->closeConnection(); |
| 2797 | 3165 | if ($rememberServerID != $this->mail_bo->profileID) |
@@ -2818,7 +3186,10 @@ discard block |
||
| 2818 | 3186 | $this->uid = $uid; |
| 2819 | 3187 | $this->partID = $partID; |
| 2820 | 3188 | $bufferHtmlOptions = $this->mail_bo->htmlOptions; |
| 2821 | - if (empty($htmlOptions)) $htmlOptions = $this->mail_bo->htmlOptions; |
|
| 3189 | + if (empty($htmlOptions)) |
|
| 3190 | + { |
|
| 3191 | + $htmlOptions = $this->mail_bo->htmlOptions; |
|
| 3192 | + } |
|
| 2822 | 3193 | // fetching structure now, to supply it to getMessageBody and getMessageAttachment, so it does not get fetched twice |
| 2823 | 3194 | $structure = $this->mail_bo->getStructure($uid, $partID, $mailbox, false); |
| 2824 | 3195 | $bodyParts = $this->mail_bo->getMessageBody($uid, ($htmlOptions?$htmlOptions:''), $partID, $structure, false, $mailbox); |
@@ -2882,10 +3253,16 @@ discard block |
||
| 2882 | 3253 | <table width="100%" style="table-layout:fixed"><tr><td class="td_display">'; |
| 2883 | 3254 | |
| 2884 | 3255 | $EndBody = '</td></tr></table></div>'; |
| 2885 | - if ($fullPageTags) $EndBody .= "</body></html>"; |
|
| 2886 | - if ($print) { |
|
| 3256 | + if ($fullPageTags) |
|
| 3257 | + { |
|
| 3258 | + $EndBody .= "</body></html>"; |
|
| 3259 | + } |
|
| 3260 | + if ($print) |
|
| 3261 | + { |
|
| 2887 | 3262 | print $BeginBody. $body .$EndBody; |
| 2888 | - } else { |
|
| 3263 | + } |
|
| 3264 | + else |
|
| 3265 | + { |
|
| 2889 | 3266 | return $BeginBody. $body .$EndBody; |
| 2890 | 3267 | } |
| 2891 | 3268 | } |
@@ -2901,9 +3278,14 @@ discard block |
||
| 2901 | 3278 | $body = ''; |
| 2902 | 3279 | |
| 2903 | 3280 | //error_log(__METHOD__.array2string($bodyParts)); //exit; |
| 2904 | - if (empty($bodyParts)) return ""; |
|
| 2905 | - foreach((array)$bodyParts as $singleBodyPart) { |
|
| 2906 | - if (!isset($singleBodyPart['body'])) { |
|
| 3281 | + if (empty($bodyParts)) |
|
| 3282 | + { |
|
| 3283 | + return ""; |
|
| 3284 | + } |
|
| 3285 | + foreach((array)$bodyParts as $singleBodyPart) |
|
| 3286 | + { |
|
| 3287 | + if (!isset($singleBodyPart['body'])) |
|
| 3288 | + { |
|
| 2907 | 3289 | $singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart,$modifyURI,$useTidy); |
| 2908 | 3290 | $body .= $singleBodyPart['body']; |
| 2909 | 3291 | continue; |
@@ -2914,7 +3296,8 @@ discard block |
||
| 2914 | 3296 | $body .= ''; |
| 2915 | 3297 | continue; |
| 2916 | 3298 | } |
| 2917 | - if(!empty($body)) { |
|
| 3299 | + if(!empty($body)) |
|
| 3300 | + { |
|
| 2918 | 3301 | $body .= '<hr style="border:dotted 1px silver;">'; |
| 2919 | 3302 | } |
| 2920 | 3303 | //error_log($singleBodyPart['body']); |
@@ -2952,16 +3335,25 @@ discard block |
||
| 2952 | 3335 | $newBody = @htmlentities($singleBodyPart['body'],ENT_QUOTES, strtoupper(Mail::$displayCharset)); |
| 2953 | 3336 | //error_log(__METHOD__.__LINE__.'..'.$newBody); |
| 2954 | 3337 | // if empty and charset is utf8 try sanitizing the string in question |
| 2955 | - if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(Mail::$displayCharset)); |
|
| 3338 | + if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8') |
|
| 3339 | + { |
|
| 3340 | + $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(Mail::$displayCharset)); |
|
| 3341 | + } |
|
| 2956 | 3342 | // if the conversion to htmlentities fails somehow, try without specifying the charset, which defaults to iso- |
| 2957 | - if (empty($newBody)) $newBody = htmlentities($singleBodyPart['body'],ENT_QUOTES); |
|
| 3343 | + if (empty($newBody)) |
|
| 3344 | + { |
|
| 3345 | + $newBody = htmlentities($singleBodyPart['body'],ENT_QUOTES); |
|
| 3346 | + } |
|
| 2958 | 3347 | |
| 2959 | 3348 | // search http[s] links and make them as links available again |
| 2960 | 3349 | // to understand what's going on here, have a look at |
| 2961 | 3350 | // http://www.php.net/manual/en/function.preg-replace.php |
| 2962 | 3351 | |
| 2963 | 3352 | // create links for websites |
| 2964 | - if ($modifyURI) $newBody = Api\Html::activate_links($newBody); |
|
| 3353 | + if ($modifyURI) |
|
| 3354 | + { |
|
| 3355 | + $newBody = Api\Html::activate_links($newBody); |
|
| 3356 | + } |
|
| 2965 | 3357 | //error_log(__METHOD__.__LINE__.'..'.$newBody); |
| 2966 | 3358 | // redirect links for websites if you use no cookies |
| 2967 | 3359 | #if (!($GLOBALS['egw_info']['server']['usecookies'])) |
@@ -3003,10 +3395,13 @@ discard block |
||
| 3003 | 3395 | { |
| 3004 | 3396 | $newBody = $cleaned; |
| 3005 | 3397 | } |
| 3006 | - if (!$preserveHTML) // ToDo KL: $preserveHTML is NOT initialised, so always if is dead code |
|
| 3398 | + if (!$preserveHTML) |
|
| 3399 | + { |
|
| 3400 | + // ToDo KL: $preserveHTML is NOT initialised, so always if is dead code |
|
| 3007 | 3401 | { |
| 3008 | 3402 | // filter only the 'body', as we only want that part, if we throw away the Api\Html |
| 3009 | 3403 | preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array()); |
| 3404 | + } |
|
| 3010 | 3405 | if ($matches[2]) |
| 3011 | 3406 | { |
| 3012 | 3407 | $hasOther = true; |
@@ -3028,7 +3423,10 @@ discard block |
||
| 3028 | 3423 | // as we switched off HTMLaweds tidy functionality |
| 3029 | 3424 | $newBody = str_replace(array('&amp;','<DIV><BR></DIV>',"<DIV> </DIV>",'<div> </div>'),array('&','<BR>','<BR>','<BR>'),$newBody); |
| 3030 | 3425 | $newBody = $htmLawed->run($newBody,Mail::$htmLawed_config); |
| 3031 | - if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3]; |
|
| 3426 | + if ($hasOther && $preserveHTML) |
|
| 3427 | + { |
|
| 3428 | + $newBody = $matches[1]. $newBody. $matches[3]; |
|
| 3429 | + } |
|
| 3032 | 3430 | $alreadyHtmlLawed=true; |
| 3033 | 3431 | } |
| 3034 | 3432 | // do the cleanup, set for the use of purifier |
@@ -3133,7 +3531,10 @@ discard block |
||
| 3133 | 3531 | */ |
| 3134 | 3532 | $replace_callback = function ($matches) use ($_mailbox,$_uid, $_partID, $_type) |
| 3135 | 3533 | { |
| 3136 | - if (!$_type) return false; |
|
| 3534 | + if (!$_type) |
|
| 3535 | + { |
|
| 3536 | + return false; |
|
| 3537 | + } |
|
| 3137 | 3538 | $CID = ''; |
| 3138 | 3539 | // Build up matches according to selected type |
| 3139 | 3540 | switch ($_type) |
@@ -3176,9 +3577,12 @@ discard block |
||
| 3176 | 3577 | $attachment = $bo->getAttachmentByCID($_uid, $CID, $_partID); |
| 3177 | 3578 | |
| 3178 | 3579 | // only use data uri for "smaller" images, as otherwise the first display of the mail takes to long |
| 3179 | - if (($attachment instanceof Horde_Mime_Part) && $attachment->getBytes() < 8192) // msie=8 allows max 32k data uris |
|
| 3580 | + if (($attachment instanceof Horde_Mime_Part) && $attachment->getBytes() < 8192) |
|
| 3581 | + { |
|
| 3582 | + // msie=8 allows max 32k data uris |
|
| 3180 | 3583 | { |
| 3181 | 3584 | $bo->fetchPartContents($_uid, $attachment); |
| 3585 | + } |
|
| 3182 | 3586 | $cache[$imageURL] = 'data:'.$attachment->getType().';base64,'.base64_encode($attachment->getContents()); |
| 3183 | 3587 | } |
| 3184 | 3588 | else |
@@ -3250,7 +3654,10 @@ discard block |
||
| 3250 | 3654 | } |
| 3251 | 3655 | $destination = $content['FOLDER'][0]; |
| 3252 | 3656 | |
| 3253 | - if (stripos($destination,self::$delimiter)!==false) list($icServerID,$destination) = explode(self::$delimiter,$destination,2); |
|
| 3657 | + if (stripos($destination,self::$delimiter)!==false) |
|
| 3658 | + { |
|
| 3659 | + list($icServerID,$destination) = explode(self::$delimiter,$destination,2); |
|
| 3660 | + } |
|
| 3254 | 3661 | if ($icServerID && $icServerID != $this->mail_bo->profileID) |
| 3255 | 3662 | { |
| 3256 | 3663 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
@@ -3275,14 +3682,26 @@ discard block |
||
| 3275 | 3682 | if (!$importFailed) |
| 3276 | 3683 | { |
| 3277 | 3684 | list($width, $height) = explode('x', Link::get_registry('mail', 'add_popup')); |
| 3278 | - if ($width > 0 && $height > 0) Api\Json\Response::get()->call('resizeTo', $width, $height); |
|
| 3685 | + if ($width > 0 && $height > 0) |
|
| 3686 | + { |
|
| 3687 | + Api\Json\Response::get()->call('resizeTo', $width, $height); |
|
| 3688 | + } |
|
| 3279 | 3689 | ExecMethod2('mail.mail_ui.displayMessage',$linkData); |
| 3280 | 3690 | return; |
| 3281 | 3691 | } |
| 3282 | 3692 | } |
| 3283 | - if (!is_array($content)) $content = array(); |
|
| 3284 | - if (empty($content['FOLDER'])) $content['FOLDER']=(array)$this->mail_bo->getDraftFolder(); |
|
| 3285 | - if (!empty($content['FOLDER'])) $sel_options['FOLDER']=mail_compose::ajax_searchFolder(0,true); |
|
| 3693 | + if (!is_array($content)) |
|
| 3694 | + { |
|
| 3695 | + $content = array(); |
|
| 3696 | + } |
|
| 3697 | + if (empty($content['FOLDER'])) |
|
| 3698 | + { |
|
| 3699 | + $content['FOLDER']=(array)$this->mail_bo->getDraftFolder(); |
|
| 3700 | + } |
|
| 3701 | + if (!empty($content['FOLDER'])) |
|
| 3702 | + { |
|
| 3703 | + $sel_options['FOLDER']=mail_compose::ajax_searchFolder(0,true); |
|
| 3704 | + } |
|
| 3286 | 3705 | |
| 3287 | 3706 | $etpl = new Etemplate('mail.importMessage'); |
| 3288 | 3707 | $etpl->setElementAttribute('uploadForImport','onFinish','app.mail.uploadForImport'); |
@@ -3302,7 +3721,10 @@ discard block |
||
| 3302 | 3721 | { |
| 3303 | 3722 | $importfailed = false; |
| 3304 | 3723 | //error_log(__METHOD__.__LINE__.array2string($_formData)); |
| 3305 | - if (empty($_formData['file'])) $_formData['file'] = $_formData['tmp_name']; |
|
| 3724 | + if (empty($_formData['file'])) |
|
| 3725 | + { |
|
| 3726 | + $_formData['file'] = $_formData['tmp_name']; |
|
| 3727 | + } |
|
| 3306 | 3728 | // check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.) |
| 3307 | 3729 | try |
| 3308 | 3730 | { |
@@ -3333,10 +3755,14 @@ discard block |
||
| 3333 | 3755 | $alert_msg .= lang("Import of message %1 failed. Destination Folder not set.",$_formData['name']); |
| 3334 | 3756 | } |
| 3335 | 3757 | $delimiter = $this->mail_bo->getHierarchyDelimiter(); |
| 3336 | - if($_folder=='INBOX'.$delimiter) $_folder='INBOX'; |
|
| 3758 | + if($_folder=='INBOX'.$delimiter) |
|
| 3759 | + { |
|
| 3760 | + $_folder='INBOX'; |
|
| 3761 | + } |
|
| 3337 | 3762 | if ($importfailed === false) |
| 3338 | 3763 | { |
| 3339 | - if ($this->mail_bo->folderExists($_folder,true)) { |
|
| 3764 | + if ($this->mail_bo->folderExists($_folder,true)) |
|
| 3765 | + { |
|
| 3340 | 3766 | try |
| 3341 | 3767 | { |
| 3342 | 3768 | $messageUid = $this->mail_bo->appendMessage($_folder, |
@@ -3397,7 +3823,10 @@ discard block |
||
| 3397 | 3823 | */ |
| 3398 | 3824 | function importMessageFromVFS2DraftAndDisplay($formData='',$mode='display') |
| 3399 | 3825 | { |
| 3400 | - if (empty($formData)) if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData']; |
|
| 3826 | + if (empty($formData)) |
|
| 3827 | + { |
|
| 3828 | + if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData']; |
|
| 3829 | + } |
|
| 3401 | 3830 | //error_log(__METHOD__.__LINE__.':'.array2string($formData).' Mode:'.$mode.'->'.function_backtrace()); |
| 3402 | 3831 | $draftFolder = $this->mail_bo->getDraftFolder(false); |
| 3403 | 3832 | $importID = Mail::getRandomString(); |
@@ -3411,15 +3840,26 @@ discard block |
||
| 3411 | 3840 | if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['name'])) |
| 3412 | 3841 | { |
| 3413 | 3842 | $buff = explode('/',$formData['file']); |
| 3414 | - if (is_array($buff)) $formData['name'] = array_pop($buff); // take the last part as name |
|
| 3843 | + if (is_array($buff)) |
|
| 3844 | + { |
|
| 3845 | + $formData['name'] = array_pop($buff); |
|
| 3846 | + } |
|
| 3847 | + // take the last part as name |
|
| 3415 | 3848 | } |
| 3416 | 3849 | // type should be set to meet the requirements of checkFileBasics |
| 3417 | 3850 | if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['type'])) |
| 3418 | 3851 | { |
| 3419 | 3852 | $buff = explode('.',$formData['file']); |
| 3420 | 3853 | $suffix = ''; |
| 3421 | - if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
|
| 3422 | - if (!empty($suffix)) $formData['type'] = Api\MimeMagic::ext2mime($suffix); |
|
| 3854 | + if (is_array($buff)) |
|
| 3855 | + { |
|
| 3856 | + $suffix = array_pop($buff); |
|
| 3857 | + } |
|
| 3858 | + // take the last extension to check with ext2mime |
|
| 3859 | + if (!empty($suffix)) |
|
| 3860 | + { |
|
| 3861 | + $formData['type'] = Api\MimeMagic::ext2mime($suffix); |
|
| 3862 | + } |
|
| 3423 | 3863 | } |
| 3424 | 3864 | // size should be set to meet the requirements of checkFileBasics |
| 3425 | 3865 | if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && !isset($formData['size'])) |
@@ -3462,17 +3902,35 @@ discard block |
||
| 3462 | 3902 | function loadEmailBody($_messageID=null,$_partID=null,$_htmloptions=null) |
| 3463 | 3903 | { |
| 3464 | 3904 | //error_log(__METHOD__.__LINE__.array2string($_GET)); |
| 3465 | - if (!$_messageID && !empty($_GET['_messageID'])) $_messageID = $_GET['_messageID']; |
|
| 3466 | - if (!$_partID && !empty($_GET['_partID'])) $_partID = $_GET['_partID']; |
|
| 3467 | - if (!$_htmloptions && !empty($_GET['_htmloptions'])) $_htmloptions = $_GET['_htmloptions']; |
|
| 3468 | - if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions"); |
|
| 3469 | - if (empty($_messageID)) return ""; |
|
| 3905 | + if (!$_messageID && !empty($_GET['_messageID'])) |
|
| 3906 | + { |
|
| 3907 | + $_messageID = $_GET['_messageID']; |
|
| 3908 | + } |
|
| 3909 | + if (!$_partID && !empty($_GET['_partID'])) |
|
| 3910 | + { |
|
| 3911 | + $_partID = $_GET['_partID']; |
|
| 3912 | + } |
|
| 3913 | + if (!$_htmloptions && !empty($_GET['_htmloptions'])) |
|
| 3914 | + { |
|
| 3915 | + $_htmloptions = $_GET['_htmloptions']; |
|
| 3916 | + } |
|
| 3917 | + if(Mail::$debug) |
|
| 3918 | + { |
|
| 3919 | + error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions"); |
|
| 3920 | + } |
|
| 3921 | + if (empty($_messageID)) |
|
| 3922 | + { |
|
| 3923 | + return ""; |
|
| 3924 | + } |
|
| 3470 | 3925 | $uidA = self::splitRowID($_messageID); |
| 3471 | 3926 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
| 3472 | 3927 | $messageID = $uidA['msgUID']; |
| 3473 | 3928 | $icServerID = $uidA['profileID']; |
| 3474 | 3929 | //something went wrong. there is a $_messageID but no $messageID: means $_messageID is crippeled |
| 3475 | - if (empty($messageID)) return ""; |
|
| 3930 | + if (empty($messageID)) |
|
| 3931 | + { |
|
| 3932 | + return ""; |
|
| 3933 | + } |
|
| 3476 | 3934 | if ($icServerID && $icServerID != $this->mail_bo->profileID) |
| 3477 | 3935 | { |
| 3478 | 3936 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
@@ -3501,7 +3959,8 @@ discard block |
||
| 3501 | 3959 | try |
| 3502 | 3960 | { |
| 3503 | 3961 | $this->mail_bo->getHierarchyDelimiter(false); |
| 3504 | - } catch (Exception $e) |
|
| 3962 | + } |
|
| 3963 | + catch (Exception $e) |
|
| 3505 | 3964 | { |
| 3506 | 3965 | continue; |
| 3507 | 3966 | } |
@@ -3511,7 +3970,11 @@ discard block |
||
| 3511 | 3970 | list($profileID,$folderName) = explode(self::$delimiter,$_folderName,2); |
| 3512 | 3971 | if (is_numeric($profileID)) |
| 3513 | 3972 | { |
| 3514 | - if ($profileID != $this->mail_bo->profileID) continue; // only current connection |
|
| 3973 | + if ($profileID != $this->mail_bo->profileID) |
|
| 3974 | + { |
|
| 3975 | + continue; |
|
| 3976 | + } |
|
| 3977 | + // only current connection |
|
| 3515 | 3978 | if ($folderName) |
| 3516 | 3979 | { |
| 3517 | 3980 | try |
@@ -3522,7 +3985,10 @@ discard block |
||
| 3522 | 3985 | { |
| 3523 | 3986 | continue; |
| 3524 | 3987 | } |
| 3525 | - if (in_array($fS['shortDisplayName'],Mail::$autoFolders)) $fS['shortDisplayName']=lang($fS['shortDisplayName']); |
|
| 3988 | + if (in_array($fS['shortDisplayName'],Mail::$autoFolders)) |
|
| 3989 | + { |
|
| 3990 | + $fS['shortDisplayName']=lang($fS['shortDisplayName']); |
|
| 3991 | + } |
|
| 3526 | 3992 | //error_log(__METHOD__.__LINE__.array2string($fS)); |
| 3527 | 3993 | if ($fS['unseen']) |
| 3528 | 3994 | { |
@@ -3563,7 +4029,11 @@ discard block |
||
| 3563 | 4029 | list($profileID,$parentFolderName) = explode(self::$delimiter,$decodedFolderName,2); |
| 3564 | 4030 | if (is_numeric($profileID)) |
| 3565 | 4031 | { |
| 3566 | - if ($profileID != $this->mail_bo->profileID) return; // only current connection |
|
| 4032 | + if ($profileID != $this->mail_bo->profileID) |
|
| 4033 | + { |
|
| 4034 | + return; |
|
| 4035 | + } |
|
| 4036 | + // only current connection |
|
| 3567 | 4037 | $del = $this->mail_bo->getHierarchyDelimiter(false); |
| 3568 | 4038 | //$del = $prefix = ''; |
| 3569 | 4039 | //$nameSpace = $this->mail_bo->_getNameSpaces(); |
@@ -3603,7 +4073,10 @@ discard block |
||
| 3603 | 4073 | $nA = explode($del,$_newName); |
| 3604 | 4074 | |
| 3605 | 4075 | //error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName"); |
| 3606 | - if (!!empty($parentFolderName)) $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName,false); |
|
| 4076 | + if (!!empty($parentFolderName)) |
|
| 4077 | + { |
|
| 4078 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName,false); |
|
| 4079 | + } |
|
| 3607 | 4080 | //error_log(__METHOD__.__LINE__.array2string($oldFolderInfo)); |
| 3608 | 4081 | |
| 3609 | 4082 | $this->mail_bo->reopen('INBOX'); |
@@ -3624,9 +4097,15 @@ discard block |
||
| 3624 | 4097 | $errorMessage .= $error; |
| 3625 | 4098 | } |
| 3626 | 4099 | } |
| 3627 | - if ($c==count($nA)) $created=true; |
|
| 4100 | + if ($c==count($nA)) |
|
| 4101 | + { |
|
| 4102 | + $created=true; |
|
| 4103 | + } |
|
| 4104 | + } |
|
| 4105 | + if (!empty($parentName)) |
|
| 4106 | + { |
|
| 4107 | + $this->mail_bo->reopen($parentName); |
|
| 3628 | 4108 | } |
| 3629 | - if (!empty($parentName)) $this->mail_bo->reopen($parentName); |
|
| 3630 | 4109 | } |
| 3631 | 4110 | //error_log(__METHOD__.__LINE__.array2string($oA)); |
| 3632 | 4111 | if ($created===true) |
@@ -3662,7 +4141,10 @@ discard block |
||
| 3662 | 4141 | */ |
| 3663 | 4142 | function ajax_renameFolder($_folderName, $_newName) |
| 3664 | 4143 | { |
| 3665 | - if (Mail::$debug) error_log(__METHOD__.__LINE__.' OldFolderName:'.array2string($_folderName).' NewName:'.array2string($_newName)); |
|
| 4144 | + if (Mail::$debug) |
|
| 4145 | + { |
|
| 4146 | + error_log(__METHOD__.__LINE__.' OldFolderName:'.array2string($_folderName).' NewName:'.array2string($_newName)); |
|
| 4147 | + } |
|
| 3666 | 4148 | if ($_folderName) |
| 3667 | 4149 | { |
| 3668 | 4150 | Api\Translation::add_app('mail'); |
@@ -3674,7 +4156,11 @@ discard block |
||
| 3674 | 4156 | $hasChildren = false; |
| 3675 | 4157 | if (is_numeric($profileID)) |
| 3676 | 4158 | { |
| 3677 | - if ($profileID != $this->mail_bo->profileID) return; // only current connection |
|
| 4159 | + if ($profileID != $this->mail_bo->profileID) |
|
| 4160 | + { |
|
| 4161 | + return; |
|
| 4162 | + } |
|
| 4163 | + // only current connection |
|
| 3678 | 4164 | $pA = explode($del,$folderName); |
| 3679 | 4165 | array_pop($pA); |
| 3680 | 4166 | $parentFolder = implode($del,$pA); |
@@ -3815,8 +4301,15 @@ discard block |
||
| 3815 | 4301 | list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
| 3816 | 4302 | // if pref and required mode dont match -> reset the folderObject cache to ensure |
| 3817 | 4303 | // that we get what we request |
| 3818 | - if ($_subscribedOnly != $oldPrefForSubscribedOnly) $this->mail_bo->resetFolderObjectCache($profileID); |
|
| 3819 | - if ($profileID != $this->mail_bo->profileID) return; // only current connection |
|
| 4304 | + if ($_subscribedOnly != $oldPrefForSubscribedOnly) |
|
| 4305 | + { |
|
| 4306 | + $this->mail_bo->resetFolderObjectCache($profileID); |
|
| 4307 | + } |
|
| 4308 | + if ($profileID != $this->mail_bo->profileID) |
|
| 4309 | + { |
|
| 4310 | + return; |
|
| 4311 | + } |
|
| 4312 | + // only current connection |
|
| 3820 | 4313 | if (!empty($folderName)) |
| 3821 | 4314 | { |
| 3822 | 4315 | $parentFolder=(!empty($folderName)?$folderName:'INBOX'); |
@@ -3891,7 +4384,10 @@ discard block |
||
| 3891 | 4384 | */ |
| 3892 | 4385 | function ajax_MoveFolder($_folderName, $_target) |
| 3893 | 4386 | { |
| 3894 | - if (Mail::$debug) error_log(__METHOD__.__LINE__."Move Folder: $_folderName to Target: $_target"); |
|
| 4387 | + if (Mail::$debug) |
|
| 4388 | + { |
|
| 4389 | + error_log(__METHOD__.__LINE__."Move Folder: $_folderName to Target: $_target"); |
|
| 4390 | + } |
|
| 3895 | 4391 | if ($_folderName) |
| 3896 | 4392 | { |
| 3897 | 4393 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
@@ -3902,7 +4398,11 @@ discard block |
||
| 3902 | 4398 | $hasChildren = false; |
| 3903 | 4399 | if (is_numeric($profileID)) |
| 3904 | 4400 | { |
| 3905 | - if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID) return; // only current connection |
|
| 4401 | + if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID) |
|
| 4402 | + { |
|
| 4403 | + return; |
|
| 4404 | + } |
|
| 4405 | + // only current connection |
|
| 3906 | 4406 | $pA = explode($del,$folderName); |
| 3907 | 4407 | $namePart = array_pop($pA); |
| 3908 | 4408 | $_newName = $namePart; |
@@ -3913,10 +4413,13 @@ discard block |
||
| 3913 | 4413 | (($oldParentFolder === $parentFolder) || //$oldParentFolder == $parentFolder means move on same level |
| 3914 | 4414 | (($oldParentFolder != $parentFolder && |
| 3915 | 4415 | strlen($parentFolder)>0 && strlen($folderName)>0 && |
| 3916 | - strpos($parentFolder,$folderName)===false)))) // indicates that we move the older up the tree within its own branch |
|
| 4416 | + strpos($parentFolder,$folderName)===false)))) |
|
| 4417 | + { |
|
| 4418 | + // indicates that we move the older up the tree within its own branch |
|
| 3917 | 4419 | { |
| 3918 | 4420 | //error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName"); |
| 3919 | 4421 | $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false); |
| 4422 | + } |
|
| 3920 | 4423 | //error_log(__METHOD__.__LINE__.array2string($oldFolderInfo)); |
| 3921 | 4424 | if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false) |
| 3922 | 4425 | { |
@@ -3999,8 +4502,14 @@ discard block |
||
| 3999 | 4502 | $profileID.self::$delimiter.$oldParentFolder=>$oldFolderInfo['shortDisplayName'], |
| 4000 | 4503 | $profileID.self::$delimiter.$parentFolder=>$folderInfo['shortDisplayName']); |
| 4001 | 4504 | // if we move the folder within the same parent-branch of the tree, there is no need no refresh the upper part |
| 4002 | - if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]); |
|
| 4003 | - if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]); |
|
| 4505 | + if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false) |
|
| 4506 | + { |
|
| 4507 | + unset($refreshData[$profileID.self::$delimiter.$parentFolder]); |
|
| 4508 | + } |
|
| 4509 | + if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false) |
|
| 4510 | + { |
|
| 4511 | + unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]); |
|
| 4512 | + } |
|
| 4004 | 4513 | |
| 4005 | 4514 | // Send full info back in the response |
| 4006 | 4515 | foreach($refreshData as $folder => &$name) |
@@ -4036,7 +4545,11 @@ discard block |
||
| 4036 | 4545 | $hasChildren = false; |
| 4037 | 4546 | if (is_numeric($profileID)) |
| 4038 | 4547 | { |
| 4039 | - if ($profileID != $this->mail_bo->profileID) return; // only current connection |
|
| 4548 | + if ($profileID != $this->mail_bo->profileID) |
|
| 4549 | + { |
|
| 4550 | + return; |
|
| 4551 | + } |
|
| 4552 | + // only current connection |
|
| 4040 | 4553 | $pA = explode($del,$folderName); |
| 4041 | 4554 | array_pop($pA); |
| 4042 | 4555 | if (strtoupper($folderName)!= 'INBOX') |
@@ -4062,7 +4575,9 @@ discard block |
||
| 4062 | 4575 | } |
| 4063 | 4576 | krsort($ftD,SORT_NUMERIC);//sort per level |
| 4064 | 4577 | //we iterate per level of depth of the subtree, deepest nesting is to be deleted first, and then up the tree |
| 4065 | - foreach($ftD as $k => $lc)//collection per level |
|
| 4578 | + foreach($ftD as $k => $lc) |
|
| 4579 | + { |
|
| 4580 | + //collection per level |
|
| 4066 | 4581 | { |
| 4067 | 4582 | foreach($lc as $f)//folders contained in that level |
| 4068 | 4583 | { |
@@ -4070,8 +4585,12 @@ discard block |
||
| 4070 | 4585 | { |
| 4071 | 4586 | //error_log(__METHOD__.__LINE__.array2string($f).'<->'.$folderName); |
| 4072 | 4587 | $this->mail_bo->deleteFolder($f); |
| 4588 | + } |
|
| 4073 | 4589 | $success = true; |
| 4074 | - if ($f==$folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName']; |
|
| 4590 | + if ($f==$folderName) |
|
| 4591 | + { |
|
| 4592 | + $oA[$_folderName] = $oldFolderInfo['shortDisplayName']; |
|
| 4593 | + } |
|
| 4075 | 4594 | } |
| 4076 | 4595 | catch (Exception $e) |
| 4077 | 4596 | { |
@@ -4101,7 +4620,10 @@ discard block |
||
| 4101 | 4620 | $msg = lang("refused to delete folder INBOX"); |
| 4102 | 4621 | } |
| 4103 | 4622 | } |
| 4104 | - if ($_return) return $success; |
|
| 4623 | + if ($_return) |
|
| 4624 | + { |
|
| 4625 | + return $success; |
|
| 4626 | + } |
|
| 4105 | 4627 | $response = Api\Json\Response::get(); |
| 4106 | 4628 | if ($success) |
| 4107 | 4629 | { |
@@ -4186,19 +4708,29 @@ discard block |
||
| 4186 | 4708 | // Create mail app object |
| 4187 | 4709 | $mail = new mail_ui(); |
| 4188 | 4710 | |
| 4189 | - if (empty($icServerID)) $icServerID = $mail->Mail->profileID; |
|
| 4190 | - if ($icServerID != $mail->Mail->profileID) return; |
|
| 4711 | + if (empty($icServerID)) |
|
| 4712 | + { |
|
| 4713 | + $icServerID = $mail->Mail->profileID; |
|
| 4714 | + } |
|
| 4715 | + if ($icServerID != $mail->Mail->profileID) |
|
| 4716 | + { |
|
| 4717 | + return; |
|
| 4718 | + } |
|
| 4191 | 4719 | |
| 4192 | 4720 | $vacation = $mail->gatherVacation($cachedVacations); |
| 4193 | 4721 | } |
| 4194 | 4722 | |
| 4195 | - if($vacation) { |
|
| 4723 | + if($vacation) |
|
| 4724 | + { |
|
| 4196 | 4725 | if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date')) |
| 4197 | 4726 | { |
| 4198 | 4727 | $dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']; |
| 4199 | 4728 | $refreshData['vacationnotice'] = lang('Vacation notice is active'); |
| 4200 | 4729 | $refreshData['vacationrange'] = ($vacation['status']=='by_date'? Api\DateTime::server2user($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.Api\DateTime::server2user($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):''); |
| 4201 | - if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time())$refreshData = ''; |
|
| 4730 | + if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time()) |
|
| 4731 | + { |
|
| 4732 | + $refreshData = ''; |
|
| 4733 | + } |
|
| 4202 | 4734 | } |
| 4203 | 4735 | } |
| 4204 | 4736 | if ($vacation==false) |
@@ -4220,11 +4752,17 @@ discard block |
||
| 4220 | 4752 | function ajax_refreshFilters($icServerID=null) |
| 4221 | 4753 | { |
| 4222 | 4754 | //error_log(__METHOD__.__LINE__.array2string($icServerId)); |
| 4223 | - if (empty($icServerID)) $icServerID = $this->mail_bo->profileID; |
|
| 4755 | + if (empty($icServerID)) |
|
| 4756 | + { |
|
| 4757 | + $icServerID = $this->mail_bo->profileID; |
|
| 4758 | + } |
|
| 4224 | 4759 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
| 4225 | 4760 | { |
| 4226 | 4761 | Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
| 4227 | - if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 4762 | + if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
|
| 4763 | + { |
|
| 4764 | + Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 4765 | + } |
|
| 4228 | 4766 | } |
| 4229 | 4767 | if (!Mail::$supportsORinQuery[$this->mail_bo->profileID]) |
| 4230 | 4768 | { |
@@ -4246,7 +4784,10 @@ discard block |
||
| 4246 | 4784 | $keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5'); |
| 4247 | 4785 | foreach($keywords as &$k) |
| 4248 | 4786 | { |
| 4249 | - if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]); |
|
| 4787 | + if (array_key_exists($k,$this->statusTypes)) |
|
| 4788 | + { |
|
| 4789 | + unset($this->statusTypes[$k]); |
|
| 4790 | + } |
|
| 4250 | 4791 | } |
| 4251 | 4792 | } |
| 4252 | 4793 | |
@@ -4266,7 +4807,10 @@ discard block |
||
| 4266 | 4807 | { |
| 4267 | 4808 | //error_log(__METHOD__.__LINE__.array2string($icServerID)); |
| 4268 | 4809 | Api\Translation::add_app('mail'); |
| 4269 | - if (is_null($icServerID)) $icServerID = $this->mail_bo->profileID; |
|
| 4810 | + if (is_null($icServerID)) |
|
| 4811 | + { |
|
| 4812 | + $icServerID = $this->mail_bo->profileID; |
|
| 4813 | + } |
|
| 4270 | 4814 | $rememberServerID = $this->mail_bo->profileID; |
| 4271 | 4815 | if ($icServerID && $icServerID != $this->mail_bo->profileID) |
| 4272 | 4816 | { |
@@ -4276,19 +4820,23 @@ discard block |
||
| 4276 | 4820 | try |
| 4277 | 4821 | { |
| 4278 | 4822 | $quota = $this->mail_bo->getQuotaRoot(); |
| 4279 | - } catch (Exception $e) { |
|
| 4823 | + } |
|
| 4824 | + catch (Exception $e) { |
|
| 4280 | 4825 | $quota['limit'] = 'NOT SET'; |
| 4281 | 4826 | error_log(__METHOD__.__LINE__." ".$e->getMessage()); |
| 4282 | 4827 | unset($e); |
| 4283 | 4828 | } |
| 4284 | 4829 | |
| 4285 | - if($quota !== false && $quota['limit'] != 'NOT SET') { |
|
| 4830 | + if($quota !== false && $quota['limit'] != 'NOT SET') |
|
| 4831 | + { |
|
| 4286 | 4832 | $quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']); |
| 4287 | 4833 | $content['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text']; |
| 4288 | 4834 | $content['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent']; |
| 4289 | 4835 | $content['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class']; |
| 4290 | 4836 | $content['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = ""; |
| 4291 | - } else { |
|
| 4837 | + } |
|
| 4838 | + else |
|
| 4839 | + { |
|
| 4292 | 4840 | $content['quota'] = $sel_options[self::$nm_index]['quota'] = lang("Quota not provided by server"); |
| 4293 | 4841 | $content['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = "mail_DisplayNone"; |
| 4294 | 4842 | $content['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone"; |
@@ -4321,7 +4869,8 @@ discard block |
||
| 4321 | 4869 | $this->changeProfile($icServerID); |
| 4322 | 4870 | } |
| 4323 | 4871 | $junkFolder = $this->mail_bo->getJunkFolder(); |
| 4324 | - if(!empty($junkFolder)) { |
|
| 4872 | + if(!empty($junkFolder)) |
|
| 4873 | + { |
|
| 4325 | 4874 | if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder) |
| 4326 | 4875 | { |
| 4327 | 4876 | // Lock the tree if the active folder is junk folder |
@@ -4371,7 +4920,8 @@ discard block |
||
| 4371 | 4920 | $this->changeProfile($icServerID); |
| 4372 | 4921 | } |
| 4373 | 4922 | $trashFolder = $this->mail_bo->getTrashFolder(); |
| 4374 | - if(!empty($trashFolder)) { |
|
| 4923 | + if(!empty($trashFolder)) |
|
| 4924 | + { |
|
| 4375 | 4925 | if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder) |
| 4376 | 4926 | { |
| 4377 | 4927 | // Lock the tree if the active folder is Trash folder |
@@ -4417,7 +4967,10 @@ discard block |
||
| 4417 | 4967 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 4418 | 4968 | list($icServerID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
| 4419 | 4969 | |
| 4420 | - if (empty($folderName)) $folderName = $this->mail_bo->sessionData['mailbox']; |
|
| 4970 | + if (empty($folderName)) |
|
| 4971 | + { |
|
| 4972 | + $folderName = $this->mail_bo->sessionData['mailbox']; |
|
| 4973 | + } |
|
| 4421 | 4974 | if ($this->mail_bo->folderExists($folderName)) |
| 4422 | 4975 | { |
| 4423 | 4976 | $rememberServerID = $this->mail_bo->profileID; |
@@ -4426,7 +4979,8 @@ discard block |
||
| 4426 | 4979 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
| 4427 | 4980 | $this->changeProfile($icServerID); |
| 4428 | 4981 | } |
| 4429 | - if(!empty($_folderName)) { |
|
| 4982 | + if(!empty($_folderName)) |
|
| 4983 | + { |
|
| 4430 | 4984 | $this->mail_bo->compressFolder($folderName); |
| 4431 | 4985 | } |
| 4432 | 4986 | if ($rememberServerID != $this->mail_bo->profileID) |
@@ -4448,7 +5002,10 @@ discard block |
||
| 4448 | 5002 | */ |
| 4449 | 5003 | function ajax_sendMDN($_messageList) |
| 4450 | 5004 | { |
| 4451 | - if(Mail::$debug) error_log(__METHOD__."->".array2string($_messageList)); |
|
| 5005 | + if(Mail::$debug) |
|
| 5006 | + { |
|
| 5007 | + error_log(__METHOD__."->".array2string($_messageList)); |
|
| 5008 | + } |
|
| 4452 | 5009 | $uidA = self::splitRowID($_messageList['msg'][0]); |
| 4453 | 5010 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
| 4454 | 5011 | $this->mail_bo->sendMDN($uidA['msgUID'],$folder); |
@@ -4465,7 +5022,10 @@ discard block |
||
| 4465 | 5022 | */ |
| 4466 | 5023 | function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse=true) |
| 4467 | 5024 | { |
| 4468 | - if(Mail::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList)); |
|
| 5025 | + if(Mail::$debug) |
|
| 5026 | + { |
|
| 5027 | + error_log(__METHOD__."->".$_flag.':'.array2string($_messageList)); |
|
| 5028 | + } |
|
| 4469 | 5029 | Api\Translation::add_app('mail'); |
| 4470 | 5030 | $alreadyFlagged=false; |
| 4471 | 5031 | $flag2check=''; |
@@ -4486,12 +5046,23 @@ discard block |
||
| 4486 | 5046 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
| 4487 | 5047 | { |
| 4488 | 5048 | Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
| 4489 | - if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 5049 | + if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
|
| 5050 | + { |
|
| 5051 | + Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 5052 | + } |
|
| 4490 | 5053 | } |
| 4491 | 5054 | //error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']); |
| 4492 | 5055 | $cutoffdate = $cutoffdate2 = null; |
| 4493 | - if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate |
|
| 4494 | - if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate |
|
| 5056 | + if ($query['startdate']) |
|
| 5057 | + { |
|
| 5058 | + $cutoffdate = Api\DateTime::to($query['startdate'],'ts'); |
|
| 5059 | + } |
|
| 5060 | + //SINCE, enddate |
|
| 5061 | + if ($query['enddate']) |
|
| 5062 | + { |
|
| 5063 | + $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts'); |
|
| 5064 | + } |
|
| 5065 | + //BEFORE, startdate |
|
| 4495 | 5066 | //error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate); |
| 4496 | 5067 | $filter = array( |
| 4497 | 5068 | 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')), |
@@ -4500,15 +5071,24 @@ discard block |
||
| 4500 | 5071 | 'status' => 'any',//this is a status change. status will be manipulated later on |
| 4501 | 5072 | //'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2) |
| 4502 | 5073 | ); |
| 4503 | - if ($query['enddate']||$query['startdate']) { |
|
| 5074 | + if ($query['enddate']||$query['startdate']) |
|
| 5075 | + { |
|
| 4504 | 5076 | $filter['range'] = "BETWEEN"; |
| 4505 | - if ($cutoffdate) { |
|
| 5077 | + if ($cutoffdate) |
|
| 5078 | + { |
|
| 4506 | 5079 | $filter[(empty($cutoffdate2)?'date':'since')] = date("d-M-Y", $cutoffdate); |
| 4507 | - if (empty($cutoffdate2)) $filter['range'] = "SINCE"; |
|
| 5080 | + if (empty($cutoffdate2)) |
|
| 5081 | + { |
|
| 5082 | + $filter['range'] = "SINCE"; |
|
| 5083 | + } |
|
| 4508 | 5084 | } |
| 4509 | - if ($cutoffdate2) { |
|
| 5085 | + if ($cutoffdate2) |
|
| 5086 | + { |
|
| 4510 | 5087 | $filter[(empty($cutoffdate)?'date':'before')] = date("d-M-Y", $cutoffdate2); |
| 4511 | - if (empty($cutoffdate)) $filter['range'] = "BEFORE"; |
|
| 5088 | + if (empty($cutoffdate)) |
|
| 5089 | + { |
|
| 5090 | + $filter['range'] = "BEFORE"; |
|
| 5091 | + } |
|
| 4512 | 5092 | } |
| 4513 | 5093 | } |
| 4514 | 5094 | $filter2toggle = $filter; |
@@ -4555,13 +5135,19 @@ discard block |
||
| 4555 | 5135 | if (count($messageListForToggle)>0) |
| 4556 | 5136 | { |
| 4557 | 5137 | $flag2set = (strtolower($_flag)); |
| 4558 | - if(Mail::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle)); |
|
| 5138 | + if(Mail::$debug) |
|
| 5139 | + { |
|
| 5140 | + error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle)); |
|
| 5141 | + } |
|
| 4559 | 5142 | $this->mail_bo->flagMessages($flag2set, $messageListForToggle,$folder); |
| 4560 | 5143 | } |
| 4561 | 5144 | if (count($messageList)>0) |
| 4562 | 5145 | { |
| 4563 | 5146 | $flag2set = 'un'.$_flag; |
| 4564 | - if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList)); |
|
| 5147 | + if(Mail::$debug) |
|
| 5148 | + { |
|
| 5149 | + error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList)); |
|
| 5150 | + } |
|
| 4565 | 5151 | $this->mail_bo->flagMessages($flag2set, $messageList,$folder); |
| 4566 | 5152 | } |
| 4567 | 5153 | $alreadyFlagged=true; |
@@ -4577,7 +5163,10 @@ discard block |
||
| 4577 | 5163 | // since we toggle and we toggle by the filtered flag we must must change _flag |
| 4578 | 5164 | $_flag = ($query['filter']=='unseen' && $_flag=='read' ? 'read' : ($query['filter']=='seen'&& $_flag=='read'?'unread':($_flag==$query['filter']?'un'.$_flag:$_flag))); |
| 4579 | 5165 | } |
| 4580 | - if(Mail::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter)); |
|
| 5166 | + if(Mail::$debug) |
|
| 5167 | + { |
|
| 5168 | + error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter)); |
|
| 5169 | + } |
|
| 4581 | 5170 | $_sR = $this->mail_bo->getSortedList( |
| 4582 | 5171 | $folder, |
| 4583 | 5172 | $sort=0, |
@@ -4592,7 +5181,10 @@ discard block |
||
| 4592 | 5181 | } |
| 4593 | 5182 | else |
| 4594 | 5183 | { |
| 4595 | - if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter)); |
|
| 5184 | + if(Mail::$debug) |
|
| 5185 | + { |
|
| 5186 | + error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter)); |
|
| 5187 | + } |
|
| 4596 | 5188 | $alreadyFlagged=true; |
| 4597 | 5189 | $uidA = self::splitRowID($_messageList['msg'][0]); |
| 4598 | 5190 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
@@ -4612,13 +5204,19 @@ discard block |
||
| 4612 | 5204 | $hA = self::splitRowID($rowID); |
| 4613 | 5205 | $messageList[] = $hA['msgUID']; |
| 4614 | 5206 | } |
| 4615 | - if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList))); |
|
| 5207 | + if(Mail::$debug) |
|
| 5208 | + { |
|
| 5209 | + error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList))); |
|
| 5210 | + } |
|
| 4616 | 5211 | $this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList),$folder); |
| 4617 | 5212 | } |
| 4618 | 5213 | } |
| 4619 | 5214 | else |
| 4620 | 5215 | { |
| 4621 | - if(Mail::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 5216 | + if(Mail::$debug) |
|
| 5217 | + { |
|
| 5218 | + error_log(__METHOD__."-> No messages selected."); |
|
| 5219 | + } |
|
| 4622 | 5220 | } |
| 4623 | 5221 | |
| 4624 | 5222 | if ($_sendJsonResponse) |
@@ -4655,7 +5253,10 @@ discard block |
||
| 4655 | 5253 | */ |
| 4656 | 5254 | function ajax_deleteMessages($_messageList,$_forceDeleteMethod=null) |
| 4657 | 5255 | { |
| 4658 | - if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod); |
|
| 5256 | + if(Mail::$debug) |
|
| 5257 | + { |
|
| 5258 | + error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod); |
|
| 5259 | + } |
|
| 4659 | 5260 | $error = null; |
| 4660 | 5261 | $filtered = false; |
| 4661 | 5262 | if ($_messageList=='all' || !empty($_messageList['msg'])) |
@@ -4674,12 +5275,23 @@ discard block |
||
| 4674 | 5275 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
| 4675 | 5276 | { |
| 4676 | 5277 | Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
| 4677 | - if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 5278 | + if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
|
| 5279 | + { |
|
| 5280 | + Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 5281 | + } |
|
| 4678 | 5282 | } |
| 4679 | 5283 | $filtered = true; |
| 4680 | 5284 | $cutoffdate = $cutoffdate2 = null; |
| 4681 | - if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate |
|
| 4682 | - if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate |
|
| 5285 | + if ($query['startdate']) |
|
| 5286 | + { |
|
| 5287 | + $cutoffdate = Api\DateTime::to($query['startdate'],'ts'); |
|
| 5288 | + } |
|
| 5289 | + //SINCE, enddate |
|
| 5290 | + if ($query['enddate']) |
|
| 5291 | + { |
|
| 5292 | + $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts'); |
|
| 5293 | + } |
|
| 5294 | + //BEFORE, startdate |
|
| 4683 | 5295 | //error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate); |
| 4684 | 5296 | $filter = array( |
| 4685 | 5297 | 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')), |
@@ -4688,15 +5300,24 @@ discard block |
||
| 4688 | 5300 | 'status' => (!empty($query['filter'])?$query['filter']:'any'), |
| 4689 | 5301 | //'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2) |
| 4690 | 5302 | ); |
| 4691 | - if ($query['enddate']||$query['startdate']) { |
|
| 5303 | + if ($query['enddate']||$query['startdate']) |
|
| 5304 | + { |
|
| 4692 | 5305 | $filter['range'] = "BETWEEN"; |
| 4693 | - if ($cutoffdate) { |
|
| 5306 | + if ($cutoffdate) |
|
| 5307 | + { |
|
| 4694 | 5308 | $filter[(empty($cutoffdate2)?'date':'since')] = date("d-M-Y", $cutoffdate); |
| 4695 | - if (empty($cutoffdate2)) $filter['range'] = "SINCE"; |
|
| 5309 | + if (empty($cutoffdate2)) |
|
| 5310 | + { |
|
| 5311 | + $filter['range'] = "SINCE"; |
|
| 5312 | + } |
|
| 4696 | 5313 | } |
| 4697 | - if ($cutoffdate2) { |
|
| 5314 | + if ($cutoffdate2) |
|
| 5315 | + { |
|
| 4698 | 5316 | $filter[(empty($cutoffdate)?'date':'before')] = date("d-M-Y", $cutoffdate2); |
| 4699 | - if (empty($cutoffdate)) $filter['range'] = "BEFORE"; |
|
| 5317 | + if (empty($cutoffdate)) |
|
| 5318 | + { |
|
| 5319 | + $filter['range'] = "BEFORE"; |
|
| 5320 | + } |
|
| 4700 | 5321 | } |
| 4701 | 5322 | } |
| 4702 | 5323 | } |
@@ -4763,7 +5384,10 @@ discard block |
||
| 4763 | 5384 | } |
| 4764 | 5385 | else |
| 4765 | 5386 | { |
| 4766 | - if(Mail::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 5387 | + if(Mail::$debug) |
|
| 5388 | + { |
|
| 5389 | + error_log(__METHOD__."-> No messages selected."); |
|
| 5390 | + } |
|
| 4767 | 5391 | } |
| 4768 | 5392 | } |
| 4769 | 5393 | |
@@ -4779,11 +5403,17 @@ discard block |
||
| 4779 | 5403 | */ |
| 4780 | 5404 | function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove='copy', $_move2ArchiveMarker='_') |
| 4781 | 5405 | { |
| 4782 | - if(Mail::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker); |
|
| 5406 | + if(Mail::$debug) |
|
| 5407 | + { |
|
| 5408 | + error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker); |
|
| 5409 | + } |
|
| 4783 | 5410 | Api\Translation::add_app('mail'); |
| 4784 | 5411 | $folderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 4785 | 5412 | // only copy or move are supported as method |
| 4786 | - if (!($_copyOrMove=='copy' || $_copyOrMove=='move')) $_copyOrMove='copy'; |
|
| 5413 | + if (!($_copyOrMove=='copy' || $_copyOrMove=='move')) |
|
| 5414 | + { |
|
| 5415 | + $_copyOrMove='copy'; |
|
| 5416 | + } |
|
| 4787 | 5417 | list($targetProfileID,$targetFolder) = explode(self::$delimiter,$folderName,2); |
| 4788 | 5418 | // check if move2archive was called with the correct archiveFolder |
| 4789 | 5419 | $archiveFolder = $this->mail_bo->getArchiveFolder(); |
@@ -4806,8 +5436,13 @@ discard block |
||
| 4806 | 5436 | $keys = array_keys($lastFoldersUsedForMoveCont[$targetProfileID]); |
| 4807 | 5437 | foreach( $keys as &$f) |
| 4808 | 5438 | { |
| 4809 | - if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]); |
|
| 4810 | - else break; |
|
| 5439 | + if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9) |
|
| 5440 | + { |
|
| 5441 | + unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]); |
|
| 5442 | + } |
|
| 5443 | + else { |
|
| 5444 | + break; |
|
| 5445 | + } |
|
| 4811 | 5446 | } |
| 4812 | 5447 | //error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID])); |
| 4813 | 5448 | } |
@@ -4834,12 +5469,23 @@ discard block |
||
| 4834 | 5469 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
| 4835 | 5470 | { |
| 4836 | 5471 | Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
| 4837 | - if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 5472 | + if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
|
| 5473 | + { |
|
| 5474 | + Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 5475 | + } |
|
| 4838 | 5476 | } |
| 4839 | 5477 | $filtered = true; |
| 4840 | 5478 | $cutoffdate = $cutoffdate2 = null; |
| 4841 | - if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate |
|
| 4842 | - if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate |
|
| 5479 | + if ($query['startdate']) |
|
| 5480 | + { |
|
| 5481 | + $cutoffdate = Api\DateTime::to($query['startdate'],'ts'); |
|
| 5482 | + } |
|
| 5483 | + //SINCE, enddate |
|
| 5484 | + if ($query['enddate']) |
|
| 5485 | + { |
|
| 5486 | + $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts'); |
|
| 5487 | + } |
|
| 5488 | + //BEFORE, startdate |
|
| 4843 | 5489 | //error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate); |
| 4844 | 5490 | $filter = array( |
| 4845 | 5491 | 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')), |
@@ -4848,15 +5494,24 @@ discard block |
||
| 4848 | 5494 | 'status' => (!empty($query['filter'])?$query['filter']:'any'), |
| 4849 | 5495 | //'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2) |
| 4850 | 5496 | ); |
| 4851 | - if ($query['enddate']||$query['startdate']) { |
|
| 5497 | + if ($query['enddate']||$query['startdate']) |
|
| 5498 | + { |
|
| 4852 | 5499 | $filter['range'] = "BETWEEN"; |
| 4853 | - if ($cutoffdate) { |
|
| 5500 | + if ($cutoffdate) |
|
| 5501 | + { |
|
| 4854 | 5502 | $filter[(empty($cutoffdate2)?'date':'since')] = date("d-M-Y", $cutoffdate); |
| 4855 | - if (empty($cutoffdate2)) $filter['range'] = "SINCE"; |
|
| 5503 | + if (empty($cutoffdate2)) |
|
| 5504 | + { |
|
| 5505 | + $filter['range'] = "SINCE"; |
|
| 5506 | + } |
|
| 4856 | 5507 | } |
| 4857 | - if ($cutoffdate2) { |
|
| 5508 | + if ($cutoffdate2) |
|
| 5509 | + { |
|
| 4858 | 5510 | $filter[(empty($cutoffdate)?'date':'before')] = date("d-M-Y", $cutoffdate2); |
| 4859 | - if (empty($cutoffdate)) $filter['range'] = "BEFORE"; |
|
| 5511 | + if (empty($cutoffdate)) |
|
| 5512 | + { |
|
| 5513 | + $filter['range'] = "BEFORE"; |
|
| 5514 | + } |
|
| 4860 | 5515 | } |
| 4861 | 5516 | } |
| 4862 | 5517 | } |
@@ -4912,7 +5567,10 @@ discard block |
||
| 4912 | 5567 | $hA = self::splitRowID($rowID); |
| 4913 | 5568 | |
| 4914 | 5569 | // If folder changes, stop and move what we've got |
| 4915 | - if($hA['folder'] != $folder) break; |
|
| 5570 | + if($hA['folder'] != $folder) |
|
| 5571 | + { |
|
| 5572 | + break; |
|
| 5573 | + } |
|
| 4916 | 5574 | |
| 4917 | 5575 | array_shift($_messageList['msg']); |
| 4918 | 5576 | $messageList[] = $hA['msgUID']; |
@@ -4967,7 +5625,10 @@ discard block |
||
| 4967 | 5625 | } |
| 4968 | 5626 | else |
| 4969 | 5627 | { |
| 4970 | - if(Mail::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 5628 | + if(Mail::$debug) |
|
| 5629 | + { |
|
| 5630 | + error_log(__METHOD__."-> No messages selected."); |
|
| 5631 | + } |
|
| 4971 | 5632 | } |
| 4972 | 5633 | } |
| 4973 | 5634 | |
@@ -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,27 +196,27 @@ 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 | - if (isset(self::$profileDefunct[$_profileID]) && self::$profileDefunct[$_profileID]===true) |
|
| 205 | + if (isset(self::$profileDefunct[$_profileID]) && self::$profileDefunct[$_profileID] === true) |
|
| 206 | 206 | { |
| 207 | - throw new Exception(__METHOD__." failed to instanciate Mail for $_profileID / ".$this->profileID." with error:".$e->getMessage().($e->details?', '.$e->details:'')); |
|
| 207 | + throw new Exception(__METHOD__." failed to instanciate Mail for $_profileID / ".$this->profileID." with error:".$e->getMessage().($e->details ? ', '.$e->details : '')); |
|
| 208 | 208 | } |
| 209 | 209 | if ($_oldImapServerObject instanceof Mail\Imap) |
| 210 | 210 | { |
| 211 | 211 | if (!is_object(self::$instances[$_profileID])) |
| 212 | 212 | { |
| 213 | - self::$instances[$_profileID] = new Mail('utf-8',false,$_profileID,false,$_reuseCache); |
|
| 213 | + self::$instances[$_profileID] = new Mail('utf-8', false, $_profileID, false, $_reuseCache); |
|
| 214 | 214 | } |
| 215 | 215 | self::$instances[$_profileID]->icServer = $_oldImapServerObject; |
| 216 | - self::$instances[$_profileID]->accountid= $_oldImapServerObject->ImapServerId; |
|
| 217 | - self::$instances[$_profileID]->profileID= $_oldImapServerObject->ImapServerId; |
|
| 216 | + self::$instances[$_profileID]->accountid = $_oldImapServerObject->ImapServerId; |
|
| 217 | + self::$instances[$_profileID]->profileID = $_oldImapServerObject->ImapServerId; |
|
| 218 | 218 | self::$instances[$_profileID]->mailPreferences = $GLOBALS['egw_info']['user']['preferences']['mail']; |
| 219 | - self::$instances[$_profileID]->htmlOptions = self::$instances[$_profileID]->mailPreferences['htmlOptions']; |
|
| 219 | + self::$instances[$_profileID]->htmlOptions = self::$instances[$_profileID]->mailPreferences['htmlOptions']; |
|
| 220 | 220 | return self::$instances[$_profileID]; |
| 221 | 221 | } |
| 222 | 222 | if ($_profileID == 0) |
@@ -229,14 +229,14 @@ discard block |
||
| 229 | 229 | { |
| 230 | 230 | $profileID = Mail\Account::get_default_acc_id(); |
| 231 | 231 | } |
| 232 | - if ($profileID!=$_profileID) $_restoreSession==false; |
|
| 233 | - $_profileID=$profileID; |
|
| 232 | + if ($profileID != $_profileID) $_restoreSession == false; |
|
| 233 | + $_profileID = $profileID; |
|
| 234 | 234 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' called with profileID==0 using '.$profileID.' instead->'.function_backtrace()); |
| 235 | 235 | } |
| 236 | 236 | // no validation or restoreSession for old ImapServer Object, just fetch it and return it |
| 237 | - if ($_oldImapServerObject===true) |
|
| 237 | + if ($_oldImapServerObject === true) |
|
| 238 | 238 | { |
| 239 | - return new Mail('utf-8',false,$_profileID,true,$_reuseCache); |
|
| 239 | + return new Mail('utf-8', false, $_profileID, true, $_reuseCache); |
|
| 240 | 240 | } |
| 241 | 241 | if ($_profileID != 0 && $_validate) |
| 242 | 242 | { |
@@ -256,9 +256,9 @@ discard block |
||
| 256 | 256 | //Cache::setSession('mail','activeProfileID',$_profileID); |
| 257 | 257 | } |
| 258 | 258 | //error_log(__METHOD__.' ('.__LINE__.') '.' RestoreSession:'.$_restoreSession.' ProfileId:'.$_profileID.' called from:'.function_backtrace()); |
| 259 | - if ($_profileID && (!isset(self::$instances[$_profileID]) || $_restoreSession===false)) |
|
| 259 | + if ($_profileID && (!isset(self::$instances[$_profileID]) || $_restoreSession === false)) |
|
| 260 | 260 | { |
| 261 | - self::$instances[$_profileID] = new Mail('utf-8',$_restoreSession,$_profileID,false,$_reuseCache); |
|
| 261 | + self::$instances[$_profileID] = new Mail('utf-8', $_restoreSession, $_profileID, false, $_reuseCache); |
|
| 262 | 262 | } |
| 263 | 263 | else |
| 264 | 264 | { |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | self::$instances[$_profileID]->ogServer = Mail\Account::read($_profileID)->smtpServer(); |
| 270 | 270 | // TODO: merge mailprefs into userprefs, for easy treatment |
| 271 | 271 | self::$instances[$_profileID]->mailPreferences = $GLOBALS['egw_info']['user']['preferences']['mail']; |
| 272 | - self::$instances[$_profileID]->htmlOptions = self::$instances[$_profileID]->mailPreferences['htmlOptions']; |
|
| 272 | + self::$instances[$_profileID]->htmlOptions = self::$instances[$_profileID]->mailPreferences['htmlOptions']; |
|
| 273 | 273 | } catch (\Exception $e) |
| 274 | 274 | { |
| 275 | 275 | $newprofileID = Mail\Account::get_default_acc_id(); |
@@ -277,15 +277,15 @@ discard block |
||
| 277 | 277 | 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()); |
| 278 | 278 | if ($newprofileID) |
| 279 | 279 | { |
| 280 | - self::$instances[$newprofileID] = new Mail('utf-8',false,$newprofileID,false,$_reuseCache); |
|
| 280 | + self::$instances[$newprofileID] = new Mail('utf-8', false, $newprofileID, false, $_reuseCache); |
|
| 281 | 281 | $_profileID = $newprofileID; |
| 282 | 282 | } |
| 283 | 283 | else |
| 284 | 284 | { |
| 285 | - throw new Exception(__METHOD__." failed to load the Profile for ProfileID for $_profileID / ".$this->profileID." with error:".$e->getMessage().($e->details?', '.$e->details:'')); |
|
| 285 | + throw new Exception(__METHOD__." failed to load the Profile for ProfileID for $_profileID / ".$this->profileID." with error:".$e->getMessage().($e->details ? ', '.$e->details : '')); |
|
| 286 | 286 | } |
| 287 | 287 | } |
| 288 | - self::storeActiveProfileIDToPref(self::$instances[$_profileID]->icServer, $_profileID, $_validate ); |
|
| 288 | + self::storeActiveProfileIDToPref(self::$instances[$_profileID]->icServer, $_profileID, $_validate); |
|
| 289 | 289 | } |
| 290 | 290 | self::$instances[$_profileID]->profileID = $_profileID; |
| 291 | 291 | if (!isset(self::$instances[$_profileID]->idna2)) self::$instances[$_profileID]->idna2 = new Horde_Idna; |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | * @param boolean $_testConnection = 0 |
| 302 | 302 | * @return mixed $_profileID or false on failed ConnectionTest |
| 303 | 303 | */ |
| 304 | - public static function storeActiveProfileIDToPref($_icServerObject, $_profileID=0, $_testConnection=true) |
|
| 304 | + public static function storeActiveProfileIDToPref($_icServerObject, $_profileID = 0, $_testConnection = true) |
|
| 305 | 305 | { |
| 306 | 306 | if (isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']) && !empty($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'])) |
| 307 | 307 | { |
@@ -322,12 +322,12 @@ discard block |
||
| 322 | 322 | } |
| 323 | 323 | if ($oldProfileID != $_profileID) |
| 324 | 324 | { |
| 325 | - if ($oldProfileID && $_profileID==0) $_profileID = $oldProfileID; |
|
| 326 | - $GLOBALS['egw']->preferences->add('mail','ActiveProfileID',$_profileID,'user'); |
|
| 325 | + if ($oldProfileID && $_profileID == 0) $_profileID = $oldProfileID; |
|
| 326 | + $GLOBALS['egw']->preferences->add('mail', 'ActiveProfileID', $_profileID, 'user'); |
|
| 327 | 327 | // save prefs |
| 328 | 328 | $GLOBALS['egw']->preferences->save_repository(true); |
| 329 | 329 | $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $_profileID; |
| 330 | - Cache::setSession('mail','activeProfileID',$_profileID); |
|
| 330 | + Cache::setSession('mail', 'activeProfileID', $_profileID); |
|
| 331 | 331 | } |
| 332 | 332 | return $_profileID; |
| 333 | 333 | } |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | * @param int $_acc_id = 0 |
| 343 | 343 | * @return int validated acc_id -> either acc_id given, or first valid one |
| 344 | 344 | */ |
| 345 | - public static function validateProfileID($_acc_id=0) |
|
| 345 | + public static function validateProfileID($_acc_id = 0) |
|
| 346 | 346 | { |
| 347 | 347 | if ($_acc_id) |
| 348 | 348 | { |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | } |
| 362 | 362 | // no account specified or specified account not found or not valid |
| 363 | 363 | // --> search existing account for first valid one and return that |
| 364 | - foreach(Mail\Account::search($only_current_user=true, 'acc_imap_host') as $acc_id => $imap_host) |
|
| 364 | + foreach (Mail\Account::search($only_current_user = true, 'acc_imap_host') as $acc_id => $imap_host) |
|
| 365 | 365 | { |
| 366 | 366 | if (!empty($imap_host) && ($account = Mail\Account::read($acc_id)) && $account->is_imap()) |
| 367 | 367 | { |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | * @param boolean $_oldImapServerObject = false |
| 384 | 384 | * @param boolean $_reuseCache = null if null it is set to the value of $_restoreSession |
| 385 | 385 | */ |
| 386 | - private function __construct($_displayCharset='utf-8',$_restoreSession=true, $_profileID=0, $_oldImapServerObject=false, $_reuseCache=null) |
|
| 386 | + private function __construct($_displayCharset = 'utf-8', $_restoreSession = true, $_profileID = 0, $_oldImapServerObject = false, $_reuseCache = null) |
|
| 387 | 387 | { |
| 388 | 388 | if (is_null($_reuseCache)) $_reuseCache = $_restoreSession; |
| 389 | 389 | if (!empty($_displayCharset)) self::$displayCharset = $_displayCharset; |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | $firstMessage = $this->sessionData['previewMessage']; |
| 404 | 404 | $this->sessionData = array(); |
| 405 | 405 | } |
| 406 | - if (!$_reuseCache) $this->forcePrefReload($_profileID,!$_reuseCache); |
|
| 406 | + if (!$_reuseCache) $this->forcePrefReload($_profileID, !$_reuseCache); |
|
| 407 | 407 | try |
| 408 | 408 | { |
| 409 | 409 | $this->profileID = self::validateProfileID($_profileID); |
@@ -417,11 +417,11 @@ discard block |
||
| 417 | 417 | throw new Exception(__METHOD__." failed to instanciate Mail for $_profileID / ".$this->profileID." with error:".$e->getMessage()); |
| 418 | 418 | } |
| 419 | 419 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($acc->imapServer())); |
| 420 | - $this->icServer = ($_oldImapServerObject?$acc->oldImapServer():$acc->imapServer()); |
|
| 420 | + $this->icServer = ($_oldImapServerObject ? $acc->oldImapServer() : $acc->imapServer()); |
|
| 421 | 421 | $this->ogServer = $acc->smtpServer(); |
| 422 | 422 | // TODO: merge mailprefs into userprefs, for easy treatment |
| 423 | 423 | $this->mailPreferences = $GLOBALS['egw_info']['user']['preferences']['mail']; |
| 424 | - $this->htmlOptions = $this->mailPreferences['htmlOptions']; |
|
| 424 | + $this->htmlOptions = $this->mailPreferences['htmlOptions']; |
|
| 425 | 425 | if (isset($this->icServer->ImapServerId) && !empty($this->icServer->ImapServerId)) |
| 426 | 426 | { |
| 427 | 427 | $_profileID = $this->profileID = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $this->icServer->ImapServerId; |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | public static function &forceEAProfileLoad($_profile_id) |
| 440 | 440 | { |
| 441 | 441 | self::unsetCachedObjects($_profile_id); |
| 442 | - $mail = self::getInstance(false, $_profile_id,false); |
|
| 442 | + $mail = self::getInstance(false, $_profile_id, false); |
|
| 443 | 443 | //_debug_array( $_profile_id); |
| 444 | 444 | $mail->icServer = Mail\Account::read($_profile_id)->imapServer(); |
| 445 | 445 | $mail->ogServer = Mail\Account::read($_profile_id)->smtpServer(); |
@@ -451,11 +451,11 @@ discard block |
||
| 451 | 451 | * @param int $_profile_id |
| 452 | 452 | * @param boolean $_resetFolderObjects |
| 453 | 453 | */ |
| 454 | - public static function forcePrefReload($_profile_id=null,$_resetFolderObjects=true) |
|
| 454 | + public static function forcePrefReload($_profile_id = null, $_resetFolderObjects = true) |
|
| 455 | 455 | { |
| 456 | 456 | // unset the mail_preferences session object, to force the reload/rebuild |
| 457 | - Cache::setSession('mail','mail_preferences',serialize(array())); |
|
| 458 | - Cache::setSession('emailadmin','session_data',serialize(array())); |
|
| 457 | + Cache::setSession('mail', 'mail_preferences', serialize(array())); |
|
| 458 | + Cache::setSession('emailadmin', 'session_data', serialize(array())); |
|
| 459 | 459 | if ($_resetFolderObjects) self::resetFolderObjectCache($_profile_id); |
| 460 | 460 | } |
| 461 | 461 | |
@@ -464,8 +464,8 @@ discard block |
||
| 464 | 464 | */ |
| 465 | 465 | function restoreSessionData() |
| 466 | 466 | { |
| 467 | - $this->sessionData = array();//Cache::getCache(Cache::SESSION,'mail','session_data',$callback=null,$callback_params=array(),$expiration=60*60*1); |
|
| 468 | - self::$activeFolderCache = Cache::getCache(Cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*10); |
|
| 467 | + $this->sessionData = array(); //Cache::getCache(Cache::SESSION,'mail','session_data',$callback=null,$callback_params=array(),$expiration=60*60*1); |
|
| 468 | + self::$activeFolderCache = Cache::getCache(Cache::INSTANCE, 'email', 'activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 469 | 469 | if (!empty(self::$activeFolderCache[$this->profileID])) $this->sessionData['mailbox'] = self::$activeFolderCache[$this->profileID]; |
| 470 | 470 | } |
| 471 | 471 | |
@@ -475,10 +475,10 @@ discard block |
||
| 475 | 475 | function saveSessionData() |
| 476 | 476 | { |
| 477 | 477 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string(array_keys($this->sessionData))); |
| 478 | - if (!empty($this->sessionData['mailbox'])) self::$activeFolderCache[$this->profileID]=$this->sessionData['mailbox']; |
|
| 478 | + if (!empty($this->sessionData['mailbox'])) self::$activeFolderCache[$this->profileID] = $this->sessionData['mailbox']; |
|
| 479 | 479 | if (isset(self::$activeFolderCache) && is_array(self::$activeFolderCache)) |
| 480 | 480 | { |
| 481 | - Cache::setCache(Cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),self::$activeFolderCache, 60*60*10); |
|
| 481 | + Cache::setCache(Cache::INSTANCE, 'email', 'activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']), self::$activeFolderCache, 60 * 60 * 10); |
|
| 482 | 482 | } |
| 483 | 483 | } |
| 484 | 484 | |
@@ -494,40 +494,40 @@ discard block |
||
| 494 | 494 | * @param int $_profileID = null default profile of user as returned by getUserDefaultProfileID |
| 495 | 495 | * @return void |
| 496 | 496 | */ |
| 497 | - static function unsetCachedObjects($_profileID=null) |
|
| 497 | + static function unsetCachedObjects($_profileID = null) |
|
| 498 | 498 | { |
| 499 | 499 | if (is_null($_profileID)) $_profileID = Mail\Account::get_default_acc_id(); |
| 500 | 500 | if (is_array($_profileID) && $_profileID['account_id']) $account_id = $_profileID['account_id']; |
| 501 | 501 | //error_log(__METHOD__.__LINE__.' called with ProfileID:'.array2string($_profileID).' from '.function_backtrace()); |
| 502 | - if (!is_array($_profileID) && (is_numeric($_profileID) || !(stripos($_profileID,'tracker_')===false))) |
|
| 502 | + if (!is_array($_profileID) && (is_numeric($_profileID) || !(stripos($_profileID, 'tracker_') === false))) |
|
| 503 | 503 | { |
| 504 | 504 | self::resetConnectionErrorCache($_profileID); |
| 505 | - $rawHeadersCache = Cache::getCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($account_id),$callback=null,$callback_params=array(),$expiration=60*60*1); |
|
| 505 | + $rawHeadersCache = Cache::getCache(Cache::INSTANCE, 'email', 'rawHeadersCache'.trim($account_id), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 1); |
|
| 506 | 506 | if (isset($rawHeadersCache[$_profileID])) |
| 507 | 507 | { |
| 508 | 508 | unset($rawHeadersCache[$_profileID]); |
| 509 | - Cache::setCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($account_id),$rawHeadersCache, $expiration=60*60*1); |
|
| 509 | + Cache::setCache(Cache::INSTANCE, 'email', 'rawHeadersCache'.trim($account_id), $rawHeadersCache, $expiration = 60 * 60 * 1); |
|
| 510 | 510 | } |
| 511 | - $HierarchyDelimiterCache = Cache::getCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($account_id),$callback=null,$callback_params=array(),$expiration=60*60*24*5); |
|
| 511 | + $HierarchyDelimiterCache = Cache::getCache(Cache::INSTANCE, 'email', 'HierarchyDelimiter'.trim($account_id), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 24 * 5); |
|
| 512 | 512 | if (isset($HierarchyDelimiterCache[$_profileID])) |
| 513 | 513 | { |
| 514 | 514 | unset($HierarchyDelimiterCache[$_profileID]); |
| 515 | - Cache::setCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($account_id),$HierarchyDelimiterCache, $expiration=60*60*24*5); |
|
| 515 | + Cache::setCache(Cache::INSTANCE, 'email', 'HierarchyDelimiter'.trim($account_id), $HierarchyDelimiterCache, $expiration = 60 * 60 * 24 * 5); |
|
| 516 | 516 | } |
| 517 | 517 | //reset folderObject cache, to trigger reload |
| 518 | 518 | self::resetFolderObjectCache($_profileID); |
| 519 | 519 | //reset counter of deleted messages per folder |
| 520 | - $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($account_id),$callback=null,$callback_params=array(),$expiration=60*60*1); |
|
| 520 | + $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($account_id), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 1); |
|
| 521 | 521 | if (isset($eMailListContainsDeletedMessages[$_profileID])) |
| 522 | 522 | { |
| 523 | 523 | unset($eMailListContainsDeletedMessages[$_profileID]); |
| 524 | - Cache::setCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($account_id),$eMailListContainsDeletedMessages, $expiration=60*60*1); |
|
| 524 | + Cache::setCache(Cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($account_id), $eMailListContainsDeletedMessages, $expiration = 60 * 60 * 1); |
|
| 525 | 525 | } |
| 526 | - $vacationCached = Cache::getCache(Cache::INSTANCE, 'email', 'vacationNotice'.trim($account_id),$callback=null,$callback_params=array(),$expiration=60*60*24*1); |
|
| 526 | + $vacationCached = Cache::getCache(Cache::INSTANCE, 'email', 'vacationNotice'.trim($account_id), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 24 * 1); |
|
| 527 | 527 | if (isset($vacationCached[$_profileID])) |
| 528 | 528 | { |
| 529 | 529 | unset($vacationCached[$_profileID]); |
| 530 | - Cache::setCache(Cache::INSTANCE,'email','vacationNotice'.trim($account_id),$vacationCached, $expiration=60*60*24*1); |
|
| 530 | + Cache::setCache(Cache::INSTANCE, 'email', 'vacationNotice'.trim($account_id), $vacationCached, $expiration = 60 * 60 * 24 * 1); |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | if (isset(self::$instances[$_profileID])) unset(self::$instances[$_profileID]); |
@@ -535,17 +535,17 @@ discard block |
||
| 535 | 535 | if (is_array($_profileID) && $_profileID['location'] == 'clear_cache') |
| 536 | 536 | { |
| 537 | 537 | // called via hook |
| 538 | - foreach($GLOBALS['egw']->accounts->search(array('type' => 'accounts','order' => 'account_lid')) as $account) |
|
| 538 | + foreach ($GLOBALS['egw']->accounts->search(array('type' => 'accounts', 'order' => 'account_lid')) as $account) |
|
| 539 | 539 | { |
| 540 | 540 | //error_log(__METHOD__.__LINE__.array2string($account)); |
| 541 | 541 | $account_id = $account['account_id']; |
| 542 | 542 | $_profileID = null; |
| 543 | - self::resetConnectionErrorCache($_profileID,$account_id); |
|
| 544 | - self::resetFolderObjectCache($_profileID,$account_id); |
|
| 545 | - Cache::setCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($account_id),array(), 60*60*1); |
|
| 546 | - Cache::setCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($account_id),array(), 60*60*24*5); |
|
| 547 | - Cache::setCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($account_id),array(), 60*60*1); |
|
| 548 | - Cache::setCache(Cache::INSTANCE,'email','vacationNotice'.trim($account_id),array(), 60*60*24*1); |
|
| 543 | + self::resetConnectionErrorCache($_profileID, $account_id); |
|
| 544 | + self::resetFolderObjectCache($_profileID, $account_id); |
|
| 545 | + Cache::setCache(Cache::INSTANCE, 'email', 'rawHeadersCache'.trim($account_id), array(), 60 * 60 * 1); |
|
| 546 | + Cache::setCache(Cache::INSTANCE, 'email', 'HierarchyDelimiter'.trim($account_id), array(), 60 * 60 * 24 * 5); |
|
| 547 | + Cache::setCache(Cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($account_id), array(), 60 * 60 * 1); |
|
| 548 | + Cache::setCache(Cache::INSTANCE, 'email', 'vacationNotice'.trim($account_id), array(), 60 * 60 * 24 * 1); |
|
| 549 | 549 | } |
| 550 | 550 | } |
| 551 | 551 | } |
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | * @param int $_ImapServerId the profileID to look for |
| 557 | 557 | * @param int $account_id the egw account to look for |
| 558 | 558 | */ |
| 559 | - static function resetConnectionErrorCache($_ImapServerId=null,$account_id=null) |
|
| 559 | + static function resetConnectionErrorCache($_ImapServerId = null, $account_id = null) |
|
| 560 | 560 | { |
| 561 | 561 | //error_log(__METHOD__.' ('.__LINE__.') '.' for Profile:'.array2string($_ImapServerId) .' for user:'.trim($account_id)); |
| 562 | 562 | if (is_null($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id']; |
@@ -574,19 +574,19 @@ discard block |
||
| 574 | 574 | } |
| 575 | 575 | else |
| 576 | 576 | { |
| 577 | - $isConError = Cache::getCache(Cache::INSTANCE,'email','icServerSIEVE_connectionError'.trim($account_id)); |
|
| 577 | + $isConError = Cache::getCache(Cache::INSTANCE, 'email', 'icServerSIEVE_connectionError'.trim($account_id)); |
|
| 578 | 578 | if (isset($isConError[$_ImapServerId])) |
| 579 | 579 | { |
| 580 | 580 | unset($isConError[$_ImapServerId]); |
| 581 | 581 | } |
| 582 | - $waitOnFailure = Cache::getCache(Cache::INSTANCE,'email','ActiveSyncWaitOnFailure'.trim($account_id),null,array(),60*60*2); |
|
| 582 | + $waitOnFailure = Cache::getCache(Cache::INSTANCE, 'email', 'ActiveSyncWaitOnFailure'.trim($account_id), null, array(), 60 * 60 * 2); |
|
| 583 | 583 | if (isset($waitOnFailure[$_ImapServerId])) |
| 584 | 584 | { |
| 585 | 585 | unset($waitOnFailure[$_ImapServerId]); |
| 586 | 586 | } |
| 587 | 587 | } |
| 588 | - Cache::setCache(Cache::INSTANCE,'email','icServerSIEVE_connectionError'.trim($account_id),$isConError,60*15); |
|
| 589 | - Cache::setCache(Cache::INSTANCE,'email','ActiveSyncWaitOnFailure'.trim($account_id),$waitOnFailure,60*60*2); |
|
| 588 | + Cache::setCache(Cache::INSTANCE, 'email', 'icServerSIEVE_connectionError'.trim($account_id), $isConError, 60 * 15); |
|
| 589 | + Cache::setCache(Cache::INSTANCE, 'email', 'ActiveSyncWaitOnFailure'.trim($account_id), $waitOnFailure, 60 * 60 * 2); |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | /** |
@@ -595,13 +595,13 @@ discard block |
||
| 595 | 595 | * @param int $_ImapServerId the profileID to look for |
| 596 | 596 | * @param int $account_id the egw account to look for |
| 597 | 597 | */ |
| 598 | - static function resetFolderObjectCache($_ImapServerId=null,$account_id=null) |
|
| 598 | + static function resetFolderObjectCache($_ImapServerId = null, $account_id = null) |
|
| 599 | 599 | { |
| 600 | 600 | //error_log(__METHOD__.' ('.__LINE__.') '.' called for Profile:'.array2string($_ImapServerId).'->'.function_backtrace()); |
| 601 | 601 | if (is_null($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id']; |
| 602 | 602 | // on [location] => verify_settings we coud either use [prefs] => Array([ActiveProfileID] => 9, .. as $_ImapServerId |
| 603 | 603 | // or treat it as not given. we try that path |
| 604 | - if (is_null($_ImapServerId)||is_array($_ImapServerId)) |
|
| 604 | + if (is_null($_ImapServerId) || is_array($_ImapServerId)) |
|
| 605 | 605 | { |
| 606 | 606 | $folders2return = array(); |
| 607 | 607 | $folderInfo = array(); |
@@ -610,12 +610,12 @@ discard block |
||
| 610 | 610 | } |
| 611 | 611 | else |
| 612 | 612 | { |
| 613 | - $folders2return = Cache::getCache(Cache::INSTANCE,'email','folderObjects'.trim($account_id),null,array(),60*60*1); |
|
| 613 | + $folders2return = Cache::getCache(Cache::INSTANCE, 'email', 'folderObjects'.trim($account_id), null, array(), 60 * 60 * 1); |
|
| 614 | 614 | if (!empty($folders2return) && isset($folders2return[$_ImapServerId])) |
| 615 | 615 | { |
| 616 | 616 | unset($folders2return[$_ImapServerId]); |
| 617 | 617 | } |
| 618 | - $folderInfo = Cache::getCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($account_id),null,array(),60*60*5); |
|
| 618 | + $folderInfo = Cache::getCache(Cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($account_id), null, array(), 60 * 60 * 5); |
|
| 619 | 619 | if (!empty($folderInfo) && isset($folderInfo[$_ImapServerId])) |
| 620 | 620 | { |
| 621 | 621 | unset($folderInfo[$_ImapServerId]); |
@@ -627,23 +627,23 @@ discard block |
||
| 627 | 627 | unset($lastFolderUsedForMove[$_ImapServerId]); |
| 628 | 628 | } |
| 629 | 629 | */ |
| 630 | - $folderBasicInfo = Cache::getCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($account_id),null,array(),60*60*1); |
|
| 630 | + $folderBasicInfo = Cache::getCache(Cache::INSTANCE, 'email', 'folderBasicInfo'.trim($account_id), null, array(), 60 * 60 * 1); |
|
| 631 | 631 | if (!empty($folderBasicInfo) && isset($folderBasicInfo[$_ImapServerId])) |
| 632 | 632 | { |
| 633 | 633 | unset($folderBasicInfo[$_ImapServerId]); |
| 634 | 634 | } |
| 635 | - $_specialUseFolders = Cache::getCache(Cache::INSTANCE,'email','specialUseFolders'.trim($account_id),null,array(),60*60*12); |
|
| 635 | + $_specialUseFolders = Cache::getCache(Cache::INSTANCE, 'email', 'specialUseFolders'.trim($account_id), null, array(), 60 * 60 * 12); |
|
| 636 | 636 | if (!empty($_specialUseFolders) && isset($_specialUseFolders[$_ImapServerId])) |
| 637 | 637 | { |
| 638 | 638 | unset($_specialUseFolders[$_ImapServerId]); |
| 639 | - self::$specialUseFolders=null; |
|
| 639 | + self::$specialUseFolders = null; |
|
| 640 | 640 | } |
| 641 | 641 | } |
| 642 | - Cache::setCache(Cache::INSTANCE,'email','folderObjects'.trim($account_id),$folders2return, 60*60*1); |
|
| 643 | - Cache::setCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($account_id),$folderInfo,60*60*5); |
|
| 642 | + Cache::setCache(Cache::INSTANCE, 'email', 'folderObjects'.trim($account_id), $folders2return, 60 * 60 * 1); |
|
| 643 | + Cache::setCache(Cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($account_id), $folderInfo, 60 * 60 * 5); |
|
| 644 | 644 | //Cache::setCache(Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($account_id),$lastFolderUsedForMove,$expiration=60*60*1); |
| 645 | - Cache::setCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($account_id),$folderBasicInfo,60*60*1); |
|
| 646 | - Cache::setCache(Cache::INSTANCE,'email','specialUseFolders'.trim($account_id),$_specialUseFolders,60*60*12); |
|
| 645 | + Cache::setCache(Cache::INSTANCE, 'email', 'folderBasicInfo'.trim($account_id), $folderBasicInfo, 60 * 60 * 1); |
|
| 646 | + Cache::setCache(Cache::INSTANCE, 'email', 'specialUseFolders'.trim($account_id), $_specialUseFolders, 60 * 60 * 12); |
|
| 647 | 647 | } |
| 648 | 648 | |
| 649 | 649 | /** |
@@ -664,15 +664,15 @@ discard block |
||
| 664 | 664 | * @param string $_profileID the ID of the mailaccount to check for identities, if null current mail-account is used |
| 665 | 665 | * @return array - array(email=>realname) |
| 666 | 666 | */ |
| 667 | - function getUserEMailAddresses($_profileID=null) |
|
| 667 | + function getUserEMailAddresses($_profileID = null) |
|
| 668 | 668 | { |
| 669 | - $acc = Mail\Account::read((!empty($_profileID)?$_profileID:$this->profileID)); |
|
| 669 | + $acc = Mail\Account::read((!empty($_profileID) ? $_profileID : $this->profileID)); |
|
| 670 | 670 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.array2string($acc)); |
| 671 | 671 | $identities = Mail\Account::identities($acc); |
| 672 | 672 | |
| 673 | 673 | $userEMailAdresses = array($acc['ident_email']=>$acc['ident_realname']); |
| 674 | 674 | |
| 675 | - foreach($identities as $ik => $ident) { |
|
| 675 | + foreach ($identities as $ik => $ident) { |
|
| 676 | 676 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident)); |
| 677 | 677 | $identity = Mail\Account::read_identity($ik); |
| 678 | 678 | if (!empty($identity['ident_email']) && !isset($userEMailAdresses[$identity['ident_email']])) $userEMailAdresses[$identity['ident_email']] = $identity['ident_realname']; |
@@ -687,19 +687,19 @@ discard block |
||
| 687 | 687 | * @param boolean $resolve_placeholders wether or not resolve possible placeholders in identities |
| 688 | 688 | * @return array - array(email=>realname) |
| 689 | 689 | */ |
| 690 | - static function getAllIdentities($_accountToSearch=null,$resolve_placeholders=false) |
|
| 690 | + static function getAllIdentities($_accountToSearch = null, $resolve_placeholders = false) |
|
| 691 | 691 | { |
| 692 | 692 | $userEMailAdresses = array(); |
| 693 | - foreach(Mail\Account::search($only_current_user=($_accountToSearch?$_accountToSearch:true), $just_name=true) as $acc_id => $identity_name) |
|
| 693 | + foreach (Mail\Account::search($only_current_user = ($_accountToSearch ? $_accountToSearch : true), $just_name = true) as $acc_id => $identity_name) |
|
| 694 | 694 | { |
| 695 | - $acc = Mail\Account::read($acc_id,($_accountToSearch?$_accountToSearch:null)); |
|
| 696 | - 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']); |
|
| 695 | + $acc = Mail\Account::read($acc_id, ($_accountToSearch ? $_accountToSearch : null)); |
|
| 696 | + 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']); |
|
| 697 | 697 | |
| 698 | - foreach(Mail\Account::identities($acc) as $ik => $ident) { |
|
| 698 | + foreach (Mail\Account::identities($acc) as $ik => $ident) { |
|
| 699 | 699 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident)); |
| 700 | - $identity = Mail\Account::read_identity($ik,$resolve_placeholders); |
|
| 700 | + $identity = Mail\Account::read_identity($ik, $resolve_placeholders); |
|
| 701 | 701 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($identity)); |
| 702 | - 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']); |
|
| 702 | + 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 | 703 | } |
| 704 | 704 | } |
| 705 | 705 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($userEMailAdresses)); |
@@ -719,9 +719,9 @@ discard block |
||
| 719 | 719 | $account = Mail\Account::read($account); |
| 720 | 720 | } |
| 721 | 721 | $userEMailAdresses = array(); |
| 722 | - foreach(Mail\Account::identities($account, true, 'params') as $ik => $ident) { |
|
| 722 | + foreach (Mail\Account::identities($account, true, 'params') as $ik => $ident) { |
|
| 723 | 723 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident)); |
| 724 | - $identity = Mail\Account::read_identity($ik,true,null,$account); |
|
| 724 | + $identity = Mail\Account::read_identity($ik, true, null, $account); |
|
| 725 | 725 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($identity)); |
| 726 | 726 | // standardIdentity has ident_id==acc_id (as it is done within account->identities) |
| 727 | 727 | if (empty($identity['ident_id'])) $identity['ident_id'] = $identity['acc_id']; |
@@ -748,9 +748,9 @@ discard block |
||
| 748 | 748 | function getDefaultIdentity() |
| 749 | 749 | { |
| 750 | 750 | // retrieve the signature accociated with the identity |
| 751 | - $id = $this->getIdentitiesWithAccounts($_accountData=array()); |
|
| 752 | - foreach(Mail\Account::identities($_accountData[$this->profileID] ? |
|
| 753 | - $this->profileID : $_accountData[$id],false,'ident_id') as $accountData) |
|
| 751 | + $id = $this->getIdentitiesWithAccounts($_accountData = array()); |
|
| 752 | + foreach (Mail\Account::identities($_accountData[$this->profileID] ? |
|
| 753 | + $this->profileID : $_accountData[$id], false, 'ident_id') as $accountData) |
|
| 754 | 754 | { |
| 755 | 755 | return $accountData; |
| 756 | 756 | } |
@@ -766,13 +766,13 @@ discard block |
||
| 766 | 766 | { |
| 767 | 767 | // account select box |
| 768 | 768 | $selectedID = $this->profileID; |
| 769 | - $allAccountData = Mail\Account::search($only_current_user=true, false, null); |
|
| 769 | + $allAccountData = Mail\Account::search($only_current_user = true, false, null); |
|
| 770 | 770 | if ($allAccountData) { |
| 771 | - $rememberFirst=$selectedFound=null; |
|
| 771 | + $rememberFirst = $selectedFound = null; |
|
| 772 | 772 | foreach ($allAccountData as $tmpkey => $icServers) |
| 773 | 773 | { |
| 774 | 774 | if (is_null($rememberFirst)) $rememberFirst = $tmpkey; |
| 775 | - if ($tmpkey == $selectedID) $selectedFound=true; |
|
| 775 | + if ($tmpkey == $selectedID) $selectedFound = true; |
|
| 776 | 776 | //error_log(__METHOD__.' ('.__LINE__.') '.' Key:'.$tmpkey.'->'.array2string($icServers->acc_imap_host)); |
| 777 | 777 | $host = $icServers->acc_imap_host; |
| 778 | 778 | if (empty($host)) continue; |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | //error_log(__METHOD__.' ('.__LINE__.') '.' Key:'.$tmpkey.'->'.array2string($identities[$icServers->acc_id])); |
| 781 | 781 | } |
| 782 | 782 | } |
| 783 | - return ($selectedFound?$selectedID:$rememberFirst); |
|
| 783 | + return ($selectedFound ? $selectedID : $rememberFirst); |
|
| 784 | 784 | } |
| 785 | 785 | |
| 786 | 786 | /** |
@@ -790,7 +790,7 @@ discard block |
||
| 790 | 790 | * @var boolean $fullString full or false=NamePart only is returned |
| 791 | 791 | * @return string - constructed of identity object data as defined in mailConfig |
| 792 | 792 | */ |
| 793 | - static function generateIdentityString($identity, $fullString=true) |
|
| 793 | + static function generateIdentityString($identity, $fullString = true) |
|
| 794 | 794 | { |
| 795 | 795 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($identity)); |
| 796 | 796 | //if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail'); |
@@ -801,16 +801,16 @@ discard block |
||
| 801 | 801 | { |
| 802 | 802 | case 'email'; |
| 803 | 803 | //$retData = str_replace('@',' ',$identity->emailAddress).($fullString===true?' <'.$identity->emailAddress.'>':''); |
| 804 | - $retData = $identity['ident_email'].($fullString===true?' <'.$identity['ident_email'].'>':''); |
|
| 804 | + $retData = $identity['ident_email'].($fullString === true ? ' <'.$identity['ident_email'].'>' : ''); |
|
| 805 | 805 | break; |
| 806 | 806 | case 'nameNemail'; |
| 807 | - $retData = (!empty($identity['ident_realname'])?$identity['ident_realname']:substr_replace($identity['ident_email'],'',strpos($identity['ident_email'],'@'))).($fullString===true?' <'.$identity['ident_email'].'>':''); |
|
| 807 | + $retData = (!empty($identity['ident_realname']) ? $identity['ident_realname'] : substr_replace($identity['ident_email'], '', strpos($identity['ident_email'], '@'))).($fullString === true ? ' <'.$identity['ident_email'].'>' : ''); |
|
| 808 | 808 | break; |
| 809 | 809 | case 'orgNemail'; |
| 810 | - $retData = (!empty($identity['ident_org'])?$identity['ident_org']:substr_replace($identity['ident_email'],'',0,strpos($identity['ident_email'],'@')+1)).($fullString===true?' <'.$identity['ident_email'].'>':''); |
|
| 810 | + $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 | 811 | break; |
| 812 | 812 | default: |
| 813 | - $retData = $identity['ident_realname'].(!empty($identity['ident_org'])?' '.$identity['ident_org']:'').($fullString===true?' <'.$identity['ident_email'].'>':''); |
|
| 813 | + $retData = $identity['ident_realname'].(!empty($identity['ident_org']) ? ' '.$identity['ident_org'] : '').($fullString === true ? ' <'.$identity['ident_email'].'>' : ''); |
|
| 814 | 814 | } |
| 815 | 815 | return $retData; |
| 816 | 816 | } |
@@ -835,7 +835,7 @@ discard block |
||
| 835 | 835 | */ |
| 836 | 836 | function reopen($_foldername) |
| 837 | 837 | { |
| 838 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 838 | + if (self::$debugTimes) $starttime = microtime(true); |
|
| 839 | 839 | |
| 840 | 840 | //error_log(__METHOD__.' ('.__LINE__.') '."('$_foldername') ".function_backtrace()); |
| 841 | 841 | // TODO: trying to reduce traffic to the IMAP Server here, introduces problems with fetching the bodies of |
@@ -850,7 +850,7 @@ discard block |
||
| 850 | 850 | } |
| 851 | 851 | $folderOpened = $_foldername; |
| 852 | 852 | //} |
| 853 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'Folder:'.$_foldername,__METHOD__.' ('.__LINE__.') '); |
|
| 853 | + if (self::$debugTimes) self::logRunTimes($starttime, null, 'Folder:'.$_foldername, __METHOD__.' ('.__LINE__.') '); |
|
| 854 | 854 | } |
| 855 | 855 | |
| 856 | 856 | |
@@ -861,15 +861,15 @@ discard block |
||
| 861 | 861 | * @throws Horde_Imap_Client_Exception on connection error or authentication failure |
| 862 | 862 | * @throws InvalidArgumentException on missing credentials |
| 863 | 863 | */ |
| 864 | - function openConnection($_icServerID=0) |
|
| 864 | + function openConnection($_icServerID = 0) |
|
| 865 | 865 | { |
| 866 | 866 | //error_log( "-------------------------->open connection ".function_backtrace()); |
| 867 | 867 | //error_log(__METHOD__.' ('.__LINE__.') '.' ->'.array2string($this->icServer)); |
| 868 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 869 | - $mailbox=null; |
|
| 868 | + if (self::$debugTimes) $starttime = microtime(true); |
|
| 869 | + $mailbox = null; |
|
| 870 | 870 | try |
| 871 | 871 | { |
| 872 | - if(isset($this->sessionData['mailbox'])&&$this->folderExists($this->sessionData['mailbox'])) $mailbox = $this->sessionData['mailbox']; |
|
| 872 | + if (isset($this->sessionData['mailbox']) && $this->folderExists($this->sessionData['mailbox'])) $mailbox = $this->sessionData['mailbox']; |
|
| 873 | 873 | if (empty($mailbox)) $mailbox = $this->icServer->getCurrentMailbox(); |
| 874 | 874 | /* |
| 875 | 875 | if (isset(Mail\Imap::$supports_keywords[$_icServerID])) |
@@ -896,7 +896,7 @@ discard block |
||
| 896 | 896 | error_log(__METHOD__.' ('.__LINE__.') '."->open connection for Server with profileID:".$_icServerID." trying to examine ($mailbox) failed!".$e->getMessage()); |
| 897 | 897 | throw new Exception(__METHOD__." failed to ".__METHOD__." on Profile to $_icServerID while trying to examine $mailbox:".$e->getMessage()); |
| 898 | 898 | } |
| 899 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'ProfileID:'.$_icServerID,__METHOD__.' ('.__LINE__.') '); |
|
| 899 | + if (self::$debugTimes) self::logRunTimes($starttime, null, 'ProfileID:'.$_icServerID, __METHOD__.' ('.__LINE__.') '); |
|
| 900 | 900 | } |
| 901 | 901 | |
| 902 | 902 | /** |
@@ -909,7 +909,7 @@ discard block |
||
| 909 | 909 | { |
| 910 | 910 | static $quota; |
| 911 | 911 | if (isset($quota)) return $quota; |
| 912 | - if (isset(self::$profileDefunct[$this->profileID]) && self::$profileDefunct[$this->profileID]===true) |
|
| 912 | + if (isset(self::$profileDefunct[$this->profileID]) && self::$profileDefunct[$this->profileID] === true) |
|
| 913 | 913 | { |
| 914 | 914 | // something is wrong. Do not proceed. either no folder or profile is marked as defunct for this request |
| 915 | 915 | return false; |
@@ -917,7 +917,7 @@ discard block |
||
| 917 | 917 | try |
| 918 | 918 | { |
| 919 | 919 | $this->icServer->getCurrentMailbox(); |
| 920 | - if(!$this->icServer->hasCapability('QUOTA')) { |
|
| 920 | + if (!$this->icServer->hasCapability('QUOTA')) { |
|
| 921 | 921 | $quota = false; |
| 922 | 922 | return false; |
| 923 | 923 | } |
@@ -927,14 +927,14 @@ discard block |
||
| 927 | 927 | { |
| 928 | 928 | //error_log(__METHOD__.array2string($e)); |
| 929 | 929 | //error_log(__METHOD__." failed to fetch quota on ".$this->profileID.' Reason:'.$e->getMessage().($e->details?', '.$e->details:'')/*.function_backtrace()*/); |
| 930 | - if ($e->getCode()==102) |
|
| 930 | + if ($e->getCode() == 102) |
|
| 931 | 931 | { |
| 932 | - self::$profileDefunct[$this->profileID]=true; |
|
| 933 | - throw new Exception(__METHOD__." failed to fetch quota on ".$this->profileID.' Reason:'.$e->getMessage().($e->details?', '.$e->details:'')); |
|
| 932 | + self::$profileDefunct[$this->profileID] = true; |
|
| 933 | + throw new Exception(__METHOD__." failed to fetch quota on ".$this->profileID.' Reason:'.$e->getMessage().($e->details ? ', '.$e->details : '')); |
|
| 934 | 934 | } |
| 935 | 935 | } |
| 936 | 936 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($quota)); |
| 937 | - if(is_array($quota)) { |
|
| 937 | + if (is_array($quota)) { |
|
| 938 | 938 | $quota = array( |
| 939 | 939 | 'usage' => $quota['USED'], |
| 940 | 940 | 'limit' => $quota['QMAX'], |
@@ -952,10 +952,10 @@ discard block |
||
| 952 | 952 | * |
| 953 | 953 | * @return int - timeout (either set or default 20/10) |
| 954 | 954 | */ |
| 955 | - static function getTimeOut($_use='IMAP') |
|
| 955 | + static function getTimeOut($_use = 'IMAP') |
|
| 956 | 956 | { |
| 957 | 957 | $timeout = $GLOBALS['egw_info']['user']['preferences']['mail']['connectionTimeout']; |
| 958 | - if (empty($timeout)) $timeout = ($_use=='SIEVE'?10:20); // this is the default value |
|
| 958 | + if (empty($timeout)) $timeout = ($_use == 'SIEVE' ? 10 : 20); // this is the default value |
|
| 959 | 959 | return $timeout; |
| 960 | 960 | } |
| 961 | 961 | |
@@ -976,18 +976,18 @@ discard block |
||
| 976 | 976 | if (is_null($nameSpace)) $nameSpace = $this->icServer->getNameSpaceArray(); |
| 977 | 977 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($nameSpace)); |
| 978 | 978 | if (is_array($nameSpace)) { |
| 979 | - foreach($nameSpace as $type => $singleNameSpaceArray) |
|
| 979 | + foreach ($nameSpace as $type => $singleNameSpaceArray) |
|
| 980 | 980 | { |
| 981 | 981 | foreach ($singleNameSpaceArray as $singleNameSpace) |
| 982 | 982 | { |
| 983 | 983 | $_foldersNameSpace = array(); |
| 984 | - if($type == 'personal' && $singleNameSpace['name'] == '#mh/' && ($this->folderExists('Mail')||$this->folderExists('INBOX'))) |
|
| 984 | + if ($type == 'personal' && $singleNameSpace['name'] == '#mh/' && ($this->folderExists('Mail') || $this->folderExists('INBOX'))) |
|
| 985 | 985 | { |
| 986 | 986 | $_foldersNameSpace['prefix_present'] = 'forced'; |
| 987 | 987 | // uw-imap server with mailbox prefix or dovecot maybe |
| 988 | - $_foldersNameSpace['prefix'] = ($this->folderExists('Mail')?'Mail':(!empty($singleNameSpace['name'])?$singleNameSpace['name']:'')); |
|
| 988 | + $_foldersNameSpace['prefix'] = ($this->folderExists('Mail') ? 'Mail' : (!empty($singleNameSpace['name']) ? $singleNameSpace['name'] : '')); |
|
| 989 | 989 | } |
| 990 | - elseif($type == 'personal' && ($singleNameSpace['name'] == '#mh/') && $this->folderExists('mail')) |
|
| 990 | + elseif ($type == 'personal' && ($singleNameSpace['name'] == '#mh/') && $this->folderExists('mail')) |
|
| 991 | 991 | { |
| 992 | 992 | $_foldersNameSpace['prefix_present'] = 'forced'; |
| 993 | 993 | // uw-imap server with mailbox prefix or dovecot maybe |
@@ -996,9 +996,9 @@ discard block |
||
| 996 | 996 | $_foldersNameSpace['prefix_present'] = !empty($singleNameSpace['name']); |
| 997 | 997 | $_foldersNameSpace['prefix'] = $singleNameSpace['name']; |
| 998 | 998 | } |
| 999 | - $_foldersNameSpace['delimiter'] = ($singleNameSpace['delimiter']?$singleNameSpace['delimiter']:$delimiter); |
|
| 999 | + $_foldersNameSpace['delimiter'] = ($singleNameSpace['delimiter'] ? $singleNameSpace['delimiter'] : $delimiter); |
|
| 1000 | 1000 | $_foldersNameSpace['type'] = $type; |
| 1001 | - $foldersNameSpace[] =$_foldersNameSpace; |
|
| 1001 | + $foldersNameSpace[] = $_foldersNameSpace; |
|
| 1002 | 1002 | } |
| 1003 | 1003 | //echo "############## $type->".print_r($foldersNameSpace[$type],true)." ###################<br>"; |
| 1004 | 1004 | } |
@@ -1016,10 +1016,10 @@ discard block |
||
| 1016 | 1016 | */ |
| 1017 | 1017 | function getFolderPrefixFromNamespace($nameSpace, $folderName) |
| 1018 | 1018 | { |
| 1019 | - foreach($nameSpace as &$singleNameSpace) |
|
| 1019 | + foreach ($nameSpace as &$singleNameSpace) |
|
| 1020 | 1020 | { |
| 1021 | 1021 | //if (substr($singleNameSpace['prefix'],0,strlen($folderName))==$folderName) return $singleNameSpace['prefix']; |
| 1022 | - if (substr($folderName,0,strlen($singleNameSpace['prefix']))==$singleNameSpace['prefix']) return $singleNameSpace['prefix']; |
|
| 1022 | + if (substr($folderName, 0, strlen($singleNameSpace['prefix'])) == $singleNameSpace['prefix']) return $singleNameSpace['prefix']; |
|
| 1023 | 1023 | } |
| 1024 | 1024 | return ""; |
| 1025 | 1025 | } |
@@ -1030,12 +1030,12 @@ discard block |
||
| 1030 | 1030 | * @var boolean $_useCache |
| 1031 | 1031 | * @return string the hierarchyDelimiter |
| 1032 | 1032 | */ |
| 1033 | - function getHierarchyDelimiter($_useCache=true) |
|
| 1033 | + function getHierarchyDelimiter($_useCache = true) |
|
| 1034 | 1034 | { |
| 1035 | 1035 | static $HierarchyDelimiter = null; |
| 1036 | - if (is_null($HierarchyDelimiter)) $HierarchyDelimiter = Cache::getCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5); |
|
| 1037 | - if ($_useCache===false) unset($HierarchyDelimiter[$this->icServer->ImapServerId]); |
|
| 1038 | - if (isset($HierarchyDelimiter[$this->icServer->ImapServerId])&&!empty($HierarchyDelimiter[$this->icServer->ImapServerId])) |
|
| 1036 | + if (is_null($HierarchyDelimiter)) $HierarchyDelimiter = Cache::getCache(Cache::INSTANCE, 'email', 'HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 24 * 5); |
|
| 1037 | + if ($_useCache === false) unset($HierarchyDelimiter[$this->icServer->ImapServerId]); |
|
| 1038 | + if (isset($HierarchyDelimiter[$this->icServer->ImapServerId]) && !empty($HierarchyDelimiter[$this->icServer->ImapServerId])) |
|
| 1039 | 1039 | { |
| 1040 | 1040 | return $HierarchyDelimiter[$this->icServer->ImapServerId]; |
| 1041 | 1041 | } |
@@ -1045,13 +1045,13 @@ discard block |
||
| 1045 | 1045 | $this->icServer->getCurrentMailbox(); |
| 1046 | 1046 | $HierarchyDelimiter[$this->icServer->ImapServerId] = $this->icServer->getDelimiter(); |
| 1047 | 1047 | } |
| 1048 | - catch(\Exception $e) |
|
| 1048 | + catch (\Exception $e) |
|
| 1049 | 1049 | { |
| 1050 | - if ($e->getCode()==102) self::$profileDefunct[$this->profileID]=true; |
|
| 1050 | + if ($e->getCode() == 102) self::$profileDefunct[$this->profileID] = true; |
|
| 1051 | 1051 | unset($e); |
| 1052 | 1052 | $HierarchyDelimiter[$this->icServer->ImapServerId] = '/'; |
| 1053 | 1053 | } |
| 1054 | - Cache::setCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']),$HierarchyDelimiter, 60*60*24*5); |
|
| 1054 | + Cache::setCache(Cache::INSTANCE, 'email', 'HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']), $HierarchyDelimiter, 60 * 60 * 24 * 5); |
|
| 1055 | 1055 | return $HierarchyDelimiter[$this->icServer->ImapServerId]; |
| 1056 | 1056 | } |
| 1057 | 1057 | |
@@ -1064,7 +1064,7 @@ discard block |
||
| 1064 | 1064 | { |
| 1065 | 1065 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$this->icServer->ImapServerId.' Connected:'.$this->icServer->_connected); |
| 1066 | 1066 | static $_specialUseFolders = null; |
| 1067 | - 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); |
|
| 1067 | + 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); |
|
| 1068 | 1068 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_trash)); |
| 1069 | 1069 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_sent)); |
| 1070 | 1070 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_draft)); |
@@ -1072,20 +1072,20 @@ discard block |
||
| 1072 | 1072 | self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId]; |
| 1073 | 1073 | if (isset($_specialUseFolders[$this->icServer->ImapServerId]) && !empty($_specialUseFolders[$this->icServer->ImapServerId])) |
| 1074 | 1074 | return $_specialUseFolders[$this->icServer->ImapServerId]; |
| 1075 | - $_specialUseFolders[$this->icServer->ImapServerId]=array(); |
|
| 1075 | + $_specialUseFolders[$this->icServer->ImapServerId] = array(); |
|
| 1076 | 1076 | //if (!empty($this->icServer->acc_folder_trash) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash])) |
| 1077 | - $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash]='Trash'; |
|
| 1077 | + $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash] = 'Trash'; |
|
| 1078 | 1078 | //if (!empty($this->icServer->acc_folder_draft) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_draft])) |
| 1079 | - $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_draft]='Drafts'; |
|
| 1079 | + $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_draft] = 'Drafts'; |
|
| 1080 | 1080 | //if (!empty($this->icServer->acc_folder_sent) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_sent])) |
| 1081 | - $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_sent]='Sent'; |
|
| 1081 | + $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_sent] = 'Sent'; |
|
| 1082 | 1082 | //if (!empty($this->icServer->acc_folder_template) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_template])) |
| 1083 | - $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_template]='Templates'; |
|
| 1084 | - $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_junk]='Junk'; |
|
| 1085 | - $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_archive]='Archive'; |
|
| 1083 | + $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_template] = 'Templates'; |
|
| 1084 | + $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_junk] = 'Junk'; |
|
| 1085 | + $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_archive] = 'Archive'; |
|
| 1086 | 1086 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_specialUseFolders));//.'<->'.array2string($this->icServer)); |
| 1087 | 1087 | self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId]; |
| 1088 | - Cache::setCache(Cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),$_specialUseFolders, 60*60*24*5); |
|
| 1088 | + Cache::setCache(Cache::INSTANCE, 'email', 'specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']), $_specialUseFolders, 60 * 60 * 24 * 5); |
|
| 1089 | 1089 | return $_specialUseFolders[$this->icServer->ImapServerId]; |
| 1090 | 1090 | } |
| 1091 | 1091 | |
@@ -1099,8 +1099,8 @@ discard block |
||
| 1099 | 1099 | function folderIsSelectable($folderToSelect) |
| 1100 | 1100 | { |
| 1101 | 1101 | $retval = true; |
| 1102 | - if($folderToSelect && ($folderStatus = $this->getFolderStatus($folderToSelect,false,true))) { |
|
| 1103 | - if (!empty($folderStatus['attributes']) && stripos(array2string($folderStatus['attributes']),'noselect')!==false) |
|
| 1102 | + if ($folderToSelect && ($folderStatus = $this->getFolderStatus($folderToSelect, false, true))) { |
|
| 1103 | + if (!empty($folderStatus['attributes']) && stripos(array2string($folderStatus['attributes']), 'noselect') !== false) |
|
| 1104 | 1104 | { |
| 1105 | 1105 | $retval = false; |
| 1106 | 1106 | } |
@@ -1120,7 +1120,7 @@ discard block |
||
| 1120 | 1120 | * |
| 1121 | 1121 | * @throws Exception |
| 1122 | 1122 | */ |
| 1123 | - function _getStatus($folderName,$ignoreStatusCache=false) |
|
| 1123 | + function _getStatus($folderName, $ignoreStatusCache = false) |
|
| 1124 | 1124 | { |
| 1125 | 1125 | static $folderStatus = null; |
| 1126 | 1126 | if (!$ignoreStatusCache && isset($folderStatus[$this->icServer->ImapServerId][$folderName])) |
@@ -1130,11 +1130,11 @@ discard block |
||
| 1130 | 1130 | } |
| 1131 | 1131 | try |
| 1132 | 1132 | { |
| 1133 | - $folderStatus[$this->icServer->ImapServerId][$folderName] = $this->icServer->getStatus($folderName,$ignoreStatusCache); |
|
| 1133 | + $folderStatus[$this->icServer->ImapServerId][$folderName] = $this->icServer->getStatus($folderName, $ignoreStatusCache); |
|
| 1134 | 1134 | } |
| 1135 | 1135 | catch (\Exception $e) |
| 1136 | 1136 | { |
| 1137 | - throw new Exception(__METHOD__.' ('.__LINE__.') '." failed for $folderName with error:".$e->getMessage().($e->details?', '.$e->details:'')); |
|
| 1137 | + throw new Exception(__METHOD__.' ('.__LINE__.') '." failed for $folderName with error:".$e->getMessage().($e->details ? ', '.$e->details : '')); |
|
| 1138 | 1138 | } |
| 1139 | 1139 | return $folderStatus[$this->icServer->ImapServerId][$folderName]; |
| 1140 | 1140 | } |
@@ -1150,10 +1150,10 @@ discard block |
||
| 1150 | 1150 | * @param fetchSubscribedInfo bool fetch Subscribed Info on folder |
| 1151 | 1151 | * @return array |
| 1152 | 1152 | */ |
| 1153 | - function getFolderStatus($_folderName,$ignoreStatusCache=false,$basicInfoOnly=false,$fetchSubscribedInfo=true) |
|
| 1153 | + function getFolderStatus($_folderName, $ignoreStatusCache = false, $basicInfoOnly = false, $fetchSubscribedInfo = true) |
|
| 1154 | 1154 | { |
| 1155 | 1155 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '." called with:$_folderName,$ignoreStatusCache,$basicInfoOnly"); |
| 1156 | - if (!is_string($_folderName) || empty($_folderName)||(isset(self::$profileDefunct[$this->profileID]) && self::$profileDefunct[$this->profileID]===true)) |
|
| 1156 | + if (!is_string($_folderName) || empty($_folderName) || (isset(self::$profileDefunct[$this->profileID]) && self::$profileDefunct[$this->profileID] === true)) |
|
| 1157 | 1157 | { |
| 1158 | 1158 | // something is wrong. Do not proceed. either no folder or profile is marked as defunct for this request |
| 1159 | 1159 | return false; |
@@ -1164,7 +1164,7 @@ discard block |
||
| 1164 | 1164 | { |
| 1165 | 1165 | $folderInfoCache = $folderBasicInfo[$this->profileID]; |
| 1166 | 1166 | } |
| 1167 | - if (isset($folderInfoCache[$_folderName]) && $ignoreStatusCache==false && $basicInfoOnly) return $folderInfoCache[$_folderName]; |
|
| 1167 | + if (isset($folderInfoCache[$_folderName]) && $ignoreStatusCache == false && $basicInfoOnly) return $folderInfoCache[$_folderName]; |
|
| 1168 | 1168 | $retValue = array(); |
| 1169 | 1169 | $retValue['subscribed'] = false; |
| 1170 | 1170 | /* |
@@ -1185,39 +1185,39 @@ discard block |
||
| 1185 | 1185 | { |
| 1186 | 1186 | //error_log(__METHOD__.array2string($e)); |
| 1187 | 1187 | //error_log(__METHOD__." failed to fetch Mailbox $_folderName on ".$this->profileID.' Reason:'.$e->getMessage().($e->details?', '.$e->details:'')/*.function_backtrace()*/); |
| 1188 | - self::$profileDefunct[$this->profileID]=true; |
|
| 1189 | - throw new Exception(__METHOD__." failed to fetch Mailbox $_folderName on ".$this->profileID.' Reason:'.$e->getMessage().($e->details?', '.$e->details:'')); |
|
| 1188 | + self::$profileDefunct[$this->profileID] = true; |
|
| 1189 | + throw new Exception(__METHOD__." failed to fetch Mailbox $_folderName on ".$this->profileID.' Reason:'.$e->getMessage().($e->details ? ', '.$e->details : '')); |
|
| 1190 | 1190 | } |
| 1191 | 1191 | //error_log(__METHOD__.' ('.__LINE__.') '.$_folderName.' '.array2string($ret)); |
| 1192 | 1192 | if (is_array($ret)) |
| 1193 | 1193 | { |
| 1194 | 1194 | $retkeys = array_keys($ret); |
| 1195 | - if ($retkeys[0]==$_folderName) $folderInfoCache[$_folderName] = $ret[$retkeys[0]]; |
|
| 1195 | + if ($retkeys[0] == $_folderName) $folderInfoCache[$_folderName] = $ret[$retkeys[0]]; |
|
| 1196 | 1196 | } |
| 1197 | 1197 | else |
| 1198 | 1198 | { |
| 1199 | - $folderInfoCache[$_folderName]=false; |
|
| 1199 | + $folderInfoCache[$_folderName] = false; |
|
| 1200 | 1200 | } |
| 1201 | 1201 | } |
| 1202 | 1202 | $folderInfo = $folderInfoCache[$_folderName]; |
| 1203 | 1203 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($folderInfo).'->'.function_backtrace()); |
| 1204 | - if($ignoreStatusCache||!$folderInfo|| !is_array($folderInfo)) { |
|
| 1204 | + if ($ignoreStatusCache || !$folderInfo || !is_array($folderInfo)) { |
|
| 1205 | 1205 | try |
| 1206 | 1206 | { |
| 1207 | - $folderInfo = $this->_getStatus($_folderName,$ignoreStatusCache); |
|
| 1207 | + $folderInfo = $this->_getStatus($_folderName, $ignoreStatusCache); |
|
| 1208 | 1208 | } |
| 1209 | 1209 | catch (\Exception $e) |
| 1210 | 1210 | { |
| 1211 | 1211 | //error_log(__METHOD__.array2string($e)); |
| 1212 | - error_log(__METHOD__." failed to fetch status for $_folderName on ".$this->profileID.' Reason:'.$e->getMessage().($e->details?', '.$e->details:'')/*.function_backtrace()*/); |
|
| 1213 | - self::$profileDefunct[$this->profileID]=true; |
|
| 1212 | + error_log(__METHOD__." failed to fetch status for $_folderName on ".$this->profileID.' Reason:'.$e->getMessage().($e->details ? ', '.$e->details : '')/*.function_backtrace()*/); |
|
| 1213 | + self::$profileDefunct[$this->profileID] = true; |
|
| 1214 | 1214 | //throw new Exception(__METHOD__." failed to fetch status for $_folderName on ".$this->profileID.' Reason:'.$e->getMessage().($e->details?', '.$e->details:'')); |
| 1215 | - $folderInfo=null; |
|
| 1215 | + $folderInfo = null; |
|
| 1216 | 1216 | } |
| 1217 | 1217 | if (!is_array($folderInfo)) |
| 1218 | 1218 | { |
| 1219 | 1219 | // no folder info, but there is a status returned for the folder: something is wrong, try to cope with it |
| 1220 | - $folderInfo = is_array($folderInfo)?$folderInfo:array('HIERACHY_DELIMITER'=>$this->getHierarchyDelimiter(), |
|
| 1220 | + $folderInfo = is_array($folderInfo) ? $folderInfo : array('HIERACHY_DELIMITER'=>$this->getHierarchyDelimiter(), |
|
| 1221 | 1221 | 'ATTRIBUTES' => ''); |
| 1222 | 1222 | if (!isset($folderInfo['HIERACHY_DELIMITER']) || empty($folderInfo['HIERACHY_DELIMITER']) || (isset($folderInfo['delimiter']) && empty($folderInfo['delimiter']))) |
| 1223 | 1223 | { |
@@ -1229,24 +1229,24 @@ discard block |
||
| 1229 | 1229 | #if(!is_array($folderInfo)) { |
| 1230 | 1230 | # return false; |
| 1231 | 1231 | #} |
| 1232 | - $retValue['delimiter'] = (isset($folderInfo['HIERACHY_DELIMITER']) && $folderInfo['HIERACHY_DELIMITER']?$folderInfo['HIERACHY_DELIMITER']:$folderInfo['delimiter']); |
|
| 1233 | - $retValue['attributes'] = (isset($folderInfo['ATTRIBUTES']) && $folderInfo['ATTRIBUTES']?$folderInfo['ATTRIBUTES']:$folderInfo['attributes']); |
|
| 1234 | - $shortNameParts = explode($retValue['delimiter'], $_folderName); |
|
| 1232 | + $retValue['delimiter'] = (isset($folderInfo['HIERACHY_DELIMITER']) && $folderInfo['HIERACHY_DELIMITER'] ? $folderInfo['HIERACHY_DELIMITER'] : $folderInfo['delimiter']); |
|
| 1233 | + $retValue['attributes'] = (isset($folderInfo['ATTRIBUTES']) && $folderInfo['ATTRIBUTES'] ? $folderInfo['ATTRIBUTES'] : $folderInfo['attributes']); |
|
| 1234 | + $shortNameParts = explode($retValue['delimiter'], $_folderName); |
|
| 1235 | 1235 | $retValue['shortName'] = array_pop($shortNameParts); |
| 1236 | 1236 | $retValue['displayName'] = $_folderName; |
| 1237 | - $retValue['shortDisplayName'] = $retValue['shortName']; |
|
| 1238 | - if(strtoupper($retValue['shortName']) == 'INBOX') { |
|
| 1239 | - $retValue['displayName'] = lang('INBOX'); |
|
| 1240 | - $retValue['shortDisplayName'] = lang('INBOX'); |
|
| 1237 | + $retValue['shortDisplayName'] = $retValue['shortName']; |
|
| 1238 | + if (strtoupper($retValue['shortName']) == 'INBOX') { |
|
| 1239 | + $retValue['displayName'] = lang('INBOX'); |
|
| 1240 | + $retValue['shortDisplayName'] = lang('INBOX'); |
|
| 1241 | 1241 | } |
| 1242 | 1242 | // translate the automatic Folders (Sent, Drafts, ...) like the INBOX |
| 1243 | - elseif (in_array($retValue['shortName'],self::$autoFolders)) |
|
| 1243 | + elseif (in_array($retValue['shortName'], self::$autoFolders)) |
|
| 1244 | 1244 | { |
| 1245 | 1245 | $retValue['displayName'] = $retValue['shortDisplayName'] = lang($retValue['shortName']); |
| 1246 | 1246 | } |
| 1247 | - if ($folderInfo) $folderBasicInfo[$this->profileID][$_folderName]=$retValue; |
|
| 1247 | + if ($folderInfo) $folderBasicInfo[$this->profileID][$_folderName] = $retValue; |
|
| 1248 | 1248 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$_folderName.array2string($retValue['attributes'])); |
| 1249 | - if ($basicInfoOnly || (isset($retValue['attributes']) && stripos(array2string($retValue['attributes']),'noselect')!==false)) |
|
| 1249 | + if ($basicInfoOnly || (isset($retValue['attributes']) && stripos(array2string($retValue['attributes']), 'noselect') !== false)) |
|
| 1250 | 1250 | { |
| 1251 | 1251 | return $retValue; |
| 1252 | 1252 | } |
@@ -1259,12 +1259,12 @@ discard block |
||
| 1259 | 1259 | if (is_null($nameSpace) || empty($nameSpace[$this->profileID])) $nameSpace[$this->profileID] = $this->_getNameSpaces(); |
| 1260 | 1260 | if (!empty($nameSpace[$this->profileID])) |
| 1261 | 1261 | { |
| 1262 | - $nsNoPersonal=array(); |
|
| 1263 | - foreach($nameSpace[$this->profileID] as &$ns) |
|
| 1262 | + $nsNoPersonal = array(); |
|
| 1263 | + foreach ($nameSpace[$this->profileID] as &$ns) |
|
| 1264 | 1264 | { |
| 1265 | - if ($ns['type']!='personal') $nsNoPersonal[]=$ns; |
|
| 1265 | + if ($ns['type'] != 'personal') $nsNoPersonal[] = $ns; |
|
| 1266 | 1266 | } |
| 1267 | - $nameSpace[$this->profileID]=$nsNoPersonal; |
|
| 1267 | + $nameSpace[$this->profileID] = $nsNoPersonal; |
|
| 1268 | 1268 | } |
| 1269 | 1269 | if (is_null($prefix) || empty($prefix[$this->profileID]) || empty($prefix[$this->profileID][$_folderName])) $prefix[$this->profileID][$_folderName] = $this->getFolderPrefixFromNamespace($nameSpace[$this->profileID], $_folderName); |
| 1270 | 1270 | |
@@ -1273,32 +1273,32 @@ discard block |
||
| 1273 | 1273 | $subscribedFolders[$this->profileID] = $this->icServer->listSubscribedMailboxes(); |
| 1274 | 1274 | } |
| 1275 | 1275 | |
| 1276 | - if($fetchSubscribedInfo && is_array($subscribedFolders[$this->profileID]) && in_array($_folderName,$subscribedFolders[$this->profileID])) { |
|
| 1276 | + if ($fetchSubscribedInfo && is_array($subscribedFolders[$this->profileID]) && in_array($_folderName, $subscribedFolders[$this->profileID])) { |
|
| 1277 | 1277 | $retValue['subscribed'] = true; |
| 1278 | 1278 | } |
| 1279 | 1279 | |
| 1280 | 1280 | try |
| 1281 | 1281 | { |
| 1282 | 1282 | //$folderStatus = $this->_getStatus($_folderName,$ignoreStatusCache); |
| 1283 | - $folderStatus = $this->getMailBoxCounters($_folderName,false); |
|
| 1284 | - $retValue['messages'] = $folderStatus['MESSAGES']; |
|
| 1283 | + $folderStatus = $this->getMailBoxCounters($_folderName, false); |
|
| 1284 | + $retValue['messages'] = $folderStatus['MESSAGES']; |
|
| 1285 | 1285 | $retValue['recent'] = $folderStatus['RECENT']; |
| 1286 | - $retValue['uidnext'] = $folderStatus['UIDNEXT']; |
|
| 1287 | - $retValue['uidvalidity'] = $folderStatus['UIDVALIDITY']; |
|
| 1286 | + $retValue['uidnext'] = $folderStatus['UIDNEXT']; |
|
| 1287 | + $retValue['uidvalidity'] = $folderStatus['UIDVALIDITY']; |
|
| 1288 | 1288 | $retValue['unseen'] = $folderStatus['UNSEEN']; |
| 1289 | 1289 | if (//$retValue['unseen']==0 && |
| 1290 | 1290 | (isset($this->mailPreferences['trustServersUnseenInfo']) && // some servers dont serve the UNSEEN information |
| 1291 | - $this->mailPreferences['trustServersUnseenInfo']==false) || |
|
| 1291 | + $this->mailPreferences['trustServersUnseenInfo'] == false) || |
|
| 1292 | 1292 | (isset($this->mailPreferences['trustServersUnseenInfo']) && |
| 1293 | - $this->mailPreferences['trustServersUnseenInfo']==2 && |
|
| 1294 | - $prefix[$this->profileID][$_folderName] != '' && stripos($_folderName,$prefix[$this->profileID][$_folderName]) !== false) |
|
| 1293 | + $this->mailPreferences['trustServersUnseenInfo'] == 2 && |
|
| 1294 | + $prefix[$this->profileID][$_folderName] != '' && stripos($_folderName, $prefix[$this->profileID][$_folderName]) !== false) |
|
| 1295 | 1295 | ) |
| 1296 | 1296 | { |
| 1297 | 1297 | //error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($prefix,true).' TS:'.$this->mailPreferences['trustServersUnseenInfo']); |
| 1298 | 1298 | // we filter for the combined status of unseen and undeleted, as this is what we show in list |
| 1299 | 1299 | try |
| 1300 | 1300 | { |
| 1301 | - $sortResult = $this->getSortedList($_folderName, $_sort=0, $_reverse=1, array('status'=>array('UNSEEN','UNDELETED')),$byUid=true,false); |
|
| 1301 | + $sortResult = $this->getSortedList($_folderName, $_sort = 0, $_reverse = 1, array('status'=>array('UNSEEN', 'UNDELETED')), $byUid = true, false); |
|
| 1302 | 1302 | $retValue['unseen'] = $sortResult['count']; |
| 1303 | 1303 | } |
| 1304 | 1304 | catch (\Exception $ee) |
@@ -1309,7 +1309,7 @@ discard block |
||
| 1309 | 1309 | } |
| 1310 | 1310 | catch (\Exception $e) |
| 1311 | 1311 | { |
| 1312 | - if (self::$debug) error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($e->getMessage(),true)); |
|
| 1312 | + if (self::$debug) error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($e->getMessage(), true)); |
|
| 1313 | 1313 | } |
| 1314 | 1314 | |
| 1315 | 1315 | return $retValue; |
@@ -1331,7 +1331,7 @@ discard block |
||
| 1331 | 1331 | * @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)) |
| 1332 | 1332 | * @return array result as array(header=>array,total=>int,first=>int,last=>int) |
| 1333 | 1333 | */ |
| 1334 | - function getHeaders($_folderName, $_startMessage, $_numberOfMessages, $_sort, $_reverse, $_filter, $_thisUIDOnly=null, $_cacheResult=true, $_fetchPreviews=false) |
|
| 1334 | + function getHeaders($_folderName, $_startMessage, $_numberOfMessages, $_sort, $_reverse, $_filter, $_thisUIDOnly = null, $_cacheResult = true, $_fetchPreviews = false) |
|
| 1335 | 1335 | { |
| 1336 | 1336 | //self::$debug=true; |
| 1337 | 1337 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.function_backtrace()); |
@@ -1344,7 +1344,7 @@ discard block |
||
| 1344 | 1344 | $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 |
| 1345 | 1345 | #print "<pre>"; |
| 1346 | 1346 | #$this->icServer->setDebug(true); |
| 1347 | - $total=0; |
|
| 1347 | + $total = 0; |
|
| 1348 | 1348 | if ($_thisUIDOnly === null) |
| 1349 | 1349 | { |
| 1350 | 1350 | if (($_startMessage || $_numberOfMessages) && !isset($_filter['range'])) |
@@ -1357,24 +1357,24 @@ discard block |
||
| 1357 | 1357 | //$_filter['range'] ="$_startMessage:*"; |
| 1358 | 1358 | } |
| 1359 | 1359 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$_folderName, $_sort, $reverse, ".array2string($_filter).", $rByUid"); |
| 1360 | - if (self::$debug||self::$debugTimes) $starttime = microtime (true); |
|
| 1360 | + if (self::$debug || self::$debugTimes) $starttime = microtime(true); |
|
| 1361 | 1361 | //see this example below for a 12 week datefilter (since) |
| 1362 | 1362 | //$_filter = array('status'=>array('UNDELETED'),'type'=>"SINCE",'string'=> date("d-M-Y", $starttime-(3600*24*7*12))); |
| 1363 | 1363 | $_sortResult = $this->getSortedList($_folderName, $_sort, $reverse, $_filter, $rByUid, $_cacheResult); |
| 1364 | 1364 | $sortResult = $_sortResult['match']->ids; |
| 1365 | 1365 | //$modseq = $_sortResult['modseq']; |
| 1366 | 1366 | //error_log(__METHOD__.' ('.__LINE__.') '.'Modsequence:'.$modseq); |
| 1367 | - if (self::$debug||self::$debugTimes) self::logRunTimes($starttime,null,' call getSortedList for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_thisUIDOnly),__METHOD__.' ('.__LINE__.') '); |
|
| 1367 | + if (self::$debug || self::$debugTimes) self::logRunTimes($starttime, null, ' call getSortedList for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_thisUIDOnly), __METHOD__.' ('.__LINE__.') '); |
|
| 1368 | 1368 | |
| 1369 | 1369 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult)); |
| 1370 | 1370 | #$this->icServer->setDebug(false); |
| 1371 | 1371 | #print "</pre>"; |
| 1372 | 1372 | // nothing found |
| 1373 | - if(!is_array($sortResult) || empty($sortResult)) { |
|
| 1373 | + if (!is_array($sortResult) || empty($sortResult)) { |
|
| 1374 | 1374 | $retValue = array(); |
| 1375 | 1375 | $retValue['info']['total'] = 0; |
| 1376 | 1376 | $retValue['info']['first'] = 0; |
| 1377 | - $retValue['info']['last'] = 0; |
|
| 1377 | + $retValue['info']['last'] = 0; |
|
| 1378 | 1378 | return $retValue; |
| 1379 | 1379 | } |
| 1380 | 1380 | |
@@ -1382,54 +1382,54 @@ discard block |
||
| 1382 | 1382 | #_debug_array($sortResult); |
| 1383 | 1383 | #_debug_array(array_slice($sortResult, -5, -2)); |
| 1384 | 1384 | //error_log("REVERSE: $reverse"); |
| 1385 | - if($reverse === true) { |
|
| 1386 | - if ($_startMessage<=$total) |
|
| 1385 | + if ($reverse === true) { |
|
| 1386 | + if ($_startMessage <= $total) |
|
| 1387 | 1387 | { |
| 1388 | - $startMessage = $_startMessage-1; |
|
| 1388 | + $startMessage = $_startMessage - 1; |
|
| 1389 | 1389 | } |
| 1390 | 1390 | else |
| 1391 | 1391 | { |
| 1392 | 1392 | //error_log(__METHOD__.' ('.__LINE__.') '.' Start:'.$_startMessage.' NumberOfMessages:'.$_numberOfMessages.' Total:'.$total); |
| 1393 | - if ($_startMessage+$_numberOfMessages>$total) |
|
| 1393 | + if ($_startMessage + $_numberOfMessages > $total) |
|
| 1394 | 1394 | { |
| 1395 | - $numberOfMessages = $total%$_numberOfMessages; |
|
| 1395 | + $numberOfMessages = $total % $_numberOfMessages; |
|
| 1396 | 1396 | //$numberOfMessages = abs($_startMessage-$total-1); |
| 1397 | - if ($numberOfMessages>0 && $numberOfMessages<=$_numberOfMessages) $_numberOfMessages = $numberOfMessages; |
|
| 1397 | + if ($numberOfMessages > 0 && $numberOfMessages <= $_numberOfMessages) $_numberOfMessages = $numberOfMessages; |
|
| 1398 | 1398 | //error_log(__METHOD__.' ('.__LINE__.') '.' Start:'.$_startMessage.' NumberOfMessages:'.$_numberOfMessages.' Total:'.$total); |
| 1399 | 1399 | } |
| 1400 | - $startMessage=($total-$_numberOfMessages)-1; |
|
| 1400 | + $startMessage = ($total - $_numberOfMessages) - 1; |
|
| 1401 | 1401 | //$retValue['info']['first'] = $startMessage; |
| 1402 | 1402 | //$retValue['info']['last'] = $total; |
| 1403 | 1403 | |
| 1404 | 1404 | } |
| 1405 | - if ($startMessage+$_numberOfMessages>$total) |
|
| 1405 | + if ($startMessage + $_numberOfMessages > $total) |
|
| 1406 | 1406 | { |
| 1407 | - $_numberOfMessages = $_numberOfMessages-($total-($startMessage+$_numberOfMessages)); |
|
| 1407 | + $_numberOfMessages = $_numberOfMessages - ($total - ($startMessage + $_numberOfMessages)); |
|
| 1408 | 1408 | //$retValue['info']['first'] = $startMessage; |
| 1409 | 1409 | //$retValue['info']['last'] = $total; |
| 1410 | 1410 | } |
| 1411 | - if($startMessage > 0) { |
|
| 1412 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+$startMessage)).', '.-$startMessage.' Number of Messages:'.count($sortResult)); |
|
| 1413 | - $sortResult = array_slice($sortResult, -($_numberOfMessages+$startMessage), -$startMessage); |
|
| 1411 | + if ($startMessage > 0) { |
|
| 1412 | + if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages + $startMessage)).', '.-$startMessage.' Number of Messages:'.count($sortResult)); |
|
| 1413 | + $sortResult = array_slice($sortResult, -($_numberOfMessages + $startMessage), -$startMessage); |
|
| 1414 | 1414 | } else { |
| 1415 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+($_startMessage-1))).', AllTheRest, Number of Messages:'.count($sortResult)); |
|
| 1416 | - $sortResult = array_slice($sortResult, -($_numberOfMessages+($_startMessage-1))); |
|
| 1415 | + if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages + ($_startMessage - 1))).', AllTheRest, Number of Messages:'.count($sortResult)); |
|
| 1416 | + $sortResult = array_slice($sortResult, -($_numberOfMessages + ($_startMessage - 1))); |
|
| 1417 | 1417 | } |
| 1418 | 1418 | $sortResult = array_reverse($sortResult); |
| 1419 | 1419 | } else { |
| 1420 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.($_startMessage-1).', '.$_numberOfMessages.' Number of Messages:'.count($sortResult)); |
|
| 1421 | - $sortResult = array_slice($sortResult, $_startMessage-1, $_numberOfMessages); |
|
| 1420 | + if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.($_startMessage - 1).', '.$_numberOfMessages.' Number of Messages:'.count($sortResult)); |
|
| 1421 | + $sortResult = array_slice($sortResult, $_startMessage - 1, $_numberOfMessages); |
|
| 1422 | 1422 | } |
| 1423 | 1423 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult)); |
| 1424 | 1424 | } |
| 1425 | 1425 | else |
| 1426 | 1426 | { |
| 1427 | - $sortResult = (is_array($_thisUIDOnly) ? $_thisUIDOnly:(array)$_thisUIDOnly); |
|
| 1427 | + $sortResult = (is_array($_thisUIDOnly) ? $_thisUIDOnly : (array)$_thisUIDOnly); |
|
| 1428 | 1428 | } |
| 1429 | 1429 | |
| 1430 | 1430 | |
| 1431 | 1431 | // fetch the data for the selected messages |
| 1432 | - if (self::$debug||self::$debugTimes) $starttime = microtime(true); |
|
| 1432 | + if (self::$debug || self::$debugTimes) $starttime = microtime(true); |
|
| 1433 | 1433 | try |
| 1434 | 1434 | { |
| 1435 | 1435 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
@@ -1438,22 +1438,22 @@ discard block |
||
| 1438 | 1438 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
| 1439 | 1439 | |
| 1440 | 1440 | // Pre-cache the headers we want, 'fetchHeaders' is a label into the cache |
| 1441 | - $fquery->headers('fetchHeaders',array( |
|
| 1442 | - 'DISPOSITION-NOTIFICATION-TO','RETURN-RECEIPT-TO','X-CONFIRM-READING-TO', |
|
| 1443 | - 'DATE','SUBJECT','FROM','TO','CC', |
|
| 1441 | + $fquery->headers('fetchHeaders', array( |
|
| 1442 | + 'DISPOSITION-NOTIFICATION-TO', 'RETURN-RECEIPT-TO', 'X-CONFIRM-READING-TO', |
|
| 1443 | + 'DATE', 'SUBJECT', 'FROM', 'TO', 'CC', |
|
| 1444 | 1444 | 'X-PRIORITY' |
| 1445 | - ),array( |
|
| 1445 | + ), array( |
|
| 1446 | 1446 | // Cache headers, we'll look at them below |
| 1447 | - 'cache' => true,//$_cacheResult, |
|
| 1447 | + 'cache' => true, //$_cacheResult, |
|
| 1448 | 1448 | // Set peek so messages are not flagged as read |
| 1449 | 1449 | 'peek' => true |
| 1450 | 1450 | )); |
| 1451 | 1451 | $fquery->size(); |
| 1452 | 1452 | $fquery->structure(); |
| 1453 | 1453 | $fquery->flags(); |
| 1454 | - $fquery->imapDate();// needed to ensure getImapDate fetches the internaldate, not the current time |
|
| 1454 | + $fquery->imapDate(); // needed to ensure getImapDate fetches the internaldate, not the current time |
|
| 1455 | 1455 | // if $_fetchPreviews is activated fetch part of the messages too |
| 1456 | - if ($_fetchPreviews) $fquery->fullText(array('peek'=>true,'length'=>((int)$_fetchPreviews<5000?5000:$_fetchPreviews),'start'=>0)); |
|
| 1456 | + if ($_fetchPreviews) $fquery->fullText(array('peek'=>true, 'length'=>((int)$_fetchPreviews < 5000 ? 5000 : $_fetchPreviews), 'start'=>0)); |
|
| 1457 | 1457 | $headersNew = $this->icServer->fetch($_folderName, $fquery, array( |
| 1458 | 1458 | 'ids' => $uidsToFetch, |
| 1459 | 1459 | )); |
@@ -1464,9 +1464,9 @@ discard block |
||
| 1464 | 1464 | $headersNew = array(); |
| 1465 | 1465 | $sortResult = array(); |
| 1466 | 1466 | } |
| 1467 | - if (self::$debug||self::$debugTimes) |
|
| 1467 | + if (self::$debug || self::$debugTimes) |
|
| 1468 | 1468 | { |
| 1469 | - self::logRunTimes($starttime,null,'HordeFetch: for Folder:'.$_folderName.' Filter:'.array2string($_filter),__METHOD__.' ('.__LINE__.') '); |
|
| 1469 | + self::logRunTimes($starttime, null, 'HordeFetch: for Folder:'.$_folderName.' Filter:'.array2string($_filter), __METHOD__.' ('.__LINE__.') '); |
|
| 1470 | 1470 | if (self::$debug) |
| 1471 | 1471 | { |
| 1472 | 1472 | $queryString = implode(',', $sortResult); |
@@ -1476,27 +1476,27 @@ discard block |
||
| 1476 | 1476 | |
| 1477 | 1477 | $cnt = 0; |
| 1478 | 1478 | |
| 1479 | - foreach((array)$sortResult as $uid) { |
|
| 1479 | + foreach ((array)$sortResult as $uid) { |
|
| 1480 | 1480 | $sortOrder[$uid] = $cnt++; |
| 1481 | 1481 | } |
| 1482 | 1482 | |
| 1483 | 1483 | $count = 0; |
| 1484 | 1484 | if (is_object($headersNew)) { |
| 1485 | - if (self::$debug||self::$debugTimes) $starttime = microtime(true); |
|
| 1486 | - foreach($headersNew->ids() as $id) { |
|
| 1485 | + if (self::$debug || self::$debugTimes) $starttime = microtime(true); |
|
| 1486 | + foreach ($headersNew->ids() as $id) { |
|
| 1487 | 1487 | $_headerObject = $headersNew->get($id); |
| 1488 | 1488 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_headerObject)); |
| 1489 | 1489 | $headerObject = array(); |
| 1490 | 1490 | $bodyPreview = null; |
| 1491 | - $uid = $headerObject['UID']= ($_headerObject->getUid()?$_headerObject->getUid():$id); |
|
| 1491 | + $uid = $headerObject['UID'] = ($_headerObject->getUid() ? $_headerObject->getUid() : $id); |
|
| 1492 | 1492 | $headerObject['MSG_NUM'] = $_headerObject->getSeq(); |
| 1493 | 1493 | $headerObject['SIZE'] = $_headerObject->getSize(); |
| 1494 | 1494 | $headerObject['INTERNALDATE'] = $_headerObject->getImapDate(); |
| 1495 | 1495 | |
| 1496 | 1496 | // Get already cached headers, 'fetchHeaders' is a label matchimg above |
| 1497 | - $headerForPrio = $_headerObject->getHeaders('fetchHeaders',Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(); |
|
| 1497 | + $headerForPrio = $_headerObject->getHeaders('fetchHeaders', Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(); |
|
| 1498 | 1498 | // Try to fetch header with key='' as some servers might have no fetchHeaders index. e.g. yandex.com |
| 1499 | - if (empty($headerForPrio)) $headerForPrio = $_headerObject->getHeaders('',Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(); |
|
| 1499 | + if (empty($headerForPrio)) $headerForPrio = $_headerObject->getHeaders('', Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(); |
|
| 1500 | 1500 | //fetch the fullMsg part if all conditions match to be available in case $_headerObject->getHeaders returns |
| 1501 | 1501 | //nothing worthwhile (as it does for googlemail accounts, when preview is switched on |
| 1502 | 1502 | if ($_fetchPreviews) |
@@ -1504,16 +1504,16 @@ discard block |
||
| 1504 | 1504 | // on enabled preview $bodyPreview is needed lateron. fetched here, for fallback-reasons |
| 1505 | 1505 | // in case of failed Header-Retrieval |
| 1506 | 1506 | $bodyPreview = $_headerObject->getFullMsg(); |
| 1507 | - if (empty($headerForPrio)||(is_array($headerForPrio)&&count($headerForPrio)===1&&$headerForPrio[''])) |
|
| 1507 | + if (empty($headerForPrio) || (is_array($headerForPrio) && count($headerForPrio) === 1 && $headerForPrio[''])) |
|
| 1508 | 1508 | { |
| 1509 | 1509 | $length = strpos($bodyPreview, Horde_Mime_Part::RFC_EOL.Horde_Mime_Part::RFC_EOL); |
| 1510 | - if ($length===false) $length = strlen($bodyPreview); |
|
| 1511 | - $headerForPrio = Horde_Mime_Headers::parseHeaders(substr($bodyPreview, 0,$length))->toArray(); |
|
| 1510 | + if ($length === false) $length = strlen($bodyPreview); |
|
| 1511 | + $headerForPrio = Horde_Mime_Headers::parseHeaders(substr($bodyPreview, 0, $length))->toArray(); |
|
| 1512 | 1512 | } |
| 1513 | 1513 | } |
| 1514 | 1514 | $headerForPrio = array_change_key_case($headerForPrio, CASE_UPPER); |
| 1515 | 1515 | if (self::$debug) { |
| 1516 | - 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')); |
|
| 1516 | + 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')); |
|
| 1517 | 1517 | error_log(__METHOD__.' ('.__LINE__.') '.array2string($headerForPrio)); |
| 1518 | 1518 | } |
| 1519 | 1519 | // message deleted from server but cache still reporting its existence ; may happen on QRESYNC with No permanent modsequences |
@@ -1522,21 +1522,21 @@ discard block |
||
| 1522 | 1522 | $total--; |
| 1523 | 1523 | continue; |
| 1524 | 1524 | } |
| 1525 | - if ( isset($headerForPrio['DISPOSITION-NOTIFICATION-TO']) ) { |
|
| 1525 | + if (isset($headerForPrio['DISPOSITION-NOTIFICATION-TO'])) { |
|
| 1526 | 1526 | $headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['DISPOSITION-NOTIFICATION-TO'])); |
| 1527 | - } else if ( isset($headerForPrio['RETURN-RECEIPT-TO']) ) { |
|
| 1527 | + } else if (isset($headerForPrio['RETURN-RECEIPT-TO'])) { |
|
| 1528 | 1528 | $headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['RETURN-RECEIPT-TO'])); |
| 1529 | - } else if ( isset($headerForPrio['X-CONFIRM-READING-TO']) ) { |
|
| 1529 | + } else if (isset($headerForPrio['X-CONFIRM-READING-TO'])) { |
|
| 1530 | 1530 | $headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['X-CONFIRM-READING-TO'])); |
| 1531 | 1531 | } /*else $sent_not = "";*/ |
| 1532 | 1532 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($headerObject)); |
| 1533 | 1533 | $headerObject['DATE'] = $headerForPrio['DATE']; |
| 1534 | - $headerObject['SUBJECT'] = (is_array($headerForPrio['SUBJECT'])?$headerForPrio['SUBJECT'][0]:$headerForPrio['SUBJECT']); |
|
| 1535 | - $headerObject['FROM'] = (array)($headerForPrio['FROM']?$headerForPrio['FROM']:($headerForPrio['REPLY-TO']?$headerForPrio['REPLY-TO']:$headerForPrio['RETURN-PATH'])); |
|
| 1534 | + $headerObject['SUBJECT'] = (is_array($headerForPrio['SUBJECT']) ? $headerForPrio['SUBJECT'][0] : $headerForPrio['SUBJECT']); |
|
| 1535 | + $headerObject['FROM'] = (array)($headerForPrio['FROM'] ? $headerForPrio['FROM'] : ($headerForPrio['REPLY-TO'] ? $headerForPrio['REPLY-TO'] : $headerForPrio['RETURN-PATH'])); |
|
| 1536 | 1536 | $headerObject['TO'] = (array)$headerForPrio['TO']; |
| 1537 | - $headerObject['CC'] = isset($headerForPrio['CC'])?(array)$headerForPrio['CC']:array(); |
|
| 1538 | - $headerObject['PRIORITY'] = isset($headerForPrio['X-PRIORITY'])?$headerForPrio['X-PRIORITY']:null; |
|
| 1539 | - foreach (array('FROM','TO','CC') as $key) |
|
| 1537 | + $headerObject['CC'] = isset($headerForPrio['CC']) ? (array)$headerForPrio['CC'] : array(); |
|
| 1538 | + $headerObject['PRIORITY'] = isset($headerForPrio['X-PRIORITY']) ? $headerForPrio['X-PRIORITY'] : null; |
|
| 1539 | + foreach (array('FROM', 'TO', 'CC') as $key) |
|
| 1540 | 1540 | { |
| 1541 | 1541 | $address = array(); |
| 1542 | 1542 | foreach ($headerObject[$key] as $k => $ad) |
@@ -1558,13 +1558,13 @@ discard block |
||
| 1558 | 1558 | foreach ($rfcAddr as $_rfcAddr) |
| 1559 | 1559 | { |
| 1560 | 1560 | if (!$_rfcAddr->valid) continue; // skip. not a valid address |
| 1561 | - $address[] = imap_rfc822_write_address($_rfcAddr->mailbox,$_rfcAddr->host,$_rfcAddr->personal); |
|
| 1561 | + $address[] = imap_rfc822_write_address($_rfcAddr->mailbox, $_rfcAddr->host, $_rfcAddr->personal); |
|
| 1562 | 1562 | } |
| 1563 | 1563 | } |
| 1564 | 1564 | $headerObject[$key] = $address; |
| 1565 | 1565 | } |
| 1566 | 1566 | $headerObject['FLAGS'] = $_headerObject->getFlags(); |
| 1567 | - $headerObject['BODYPREVIEW']=null; |
|
| 1567 | + $headerObject['BODYPREVIEW'] = null; |
|
| 1568 | 1568 | // this section fetches part of the message-body (if enabled) for some kind of preview |
| 1569 | 1569 | // if we fail to succeed, we fall back to the retrieval of the message-body with |
| 1570 | 1570 | // fetchPartContents (see below, when we iterate over the structure to determine the |
@@ -1576,17 +1576,17 @@ discard block |
||
| 1576 | 1576 | if (empty($bodyPreview)) $bodyPreview = $_headerObject->getFullMsg(); |
| 1577 | 1577 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($bodyPreview)); |
| 1578 | 1578 | $base = Horde_Mime_Part::parseMessage($bodyPreview); |
| 1579 | - foreach($base->partIterator() as $part) |
|
| 1579 | + foreach ($base->partIterator() as $part) |
|
| 1580 | 1580 | { |
| 1581 | 1581 | //error_log(__METHOD__.__LINE__.'Part:'.$part->getPrimaryType()); |
| 1582 | - if (empty($headerObject['BODYPREVIEW'])&&$part->getPrimaryType()== 'text') |
|
| 1582 | + if (empty($headerObject['BODYPREVIEW']) && $part->getPrimaryType() == 'text') |
|
| 1583 | 1583 | { |
| 1584 | 1584 | $charset = $part->getContentTypeParameter('charset'); |
| 1585 | 1585 | $buffer = Mail\Html::convertHTMLToText($part->toString(array( |
| 1586 | - 'encode' => Horde_Mime_Part::ENCODE_BINARY, // otherwise we cant recode charset |
|
| 1586 | + 'encode' => Horde_Mime_Part::ENCODE_BINARY, // otherwise we cant recode charset |
|
| 1587 | 1587 | )), $charset, 'utf-8'); |
| 1588 | - $headerObject['BODYPREVIEW']=trim(str_replace(array("\r\n","\r","\n"),' ',mb_substr(Translation::convert_jsonsafe($buffer),0,((int)$_fetchPreviews<300?300:$_fetchPreviews)))); |
|
| 1589 | - } elseif (empty($headerObject['BODYPREVIEW'])&&$part->getPrimaryType()== 'multipart') |
|
| 1588 | + $headerObject['BODYPREVIEW'] = trim(str_replace(array("\r\n", "\r", "\n"), ' ', mb_substr(Translation::convert_jsonsafe($buffer), 0, ((int)$_fetchPreviews < 300 ? 300 : $_fetchPreviews)))); |
|
| 1589 | + } elseif (empty($headerObject['BODYPREVIEW']) && $part->getPrimaryType() == 'multipart') |
|
| 1590 | 1590 | { |
| 1591 | 1591 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($part)); |
| 1592 | 1592 | } |
@@ -1597,12 +1597,12 @@ discard block |
||
| 1597 | 1597 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($headerObject)); |
| 1598 | 1598 | //error_log(__METHOD__.' ('.__LINE__.') '.' MimeMap:'.array2string($mailStructureObject->contentTypeMap())); |
| 1599 | 1599 | //foreach ($_headerObject->getStructure()->getParts() as $p => $part) |
| 1600 | - $headerObject['ATTACHMENTS']=null; |
|
| 1601 | - $skipParts=array(); |
|
| 1602 | - $messageMimeType=''; |
|
| 1600 | + $headerObject['ATTACHMENTS'] = null; |
|
| 1601 | + $skipParts = array(); |
|
| 1602 | + $messageMimeType = ''; |
|
| 1603 | 1603 | foreach ($mailStructureObject->contentTypeMap() as $mime_id => $mime_type) |
| 1604 | 1604 | { |
| 1605 | - if ($mime_id==0 || $messageMimeType==='') $messageMimeType = $mime_type; |
|
| 1605 | + if ($mime_id == 0 || $messageMimeType === '') $messageMimeType = $mime_type; |
|
| 1606 | 1606 | $part = $mailStructureObject->getPart($mime_id); |
| 1607 | 1607 | $partdisposition = $part->getDisposition(); |
| 1608 | 1608 | $partPrimaryType = $part->getPrimaryType(); |
@@ -1610,16 +1610,16 @@ discard block |
||
| 1610 | 1610 | // drawback here it is talking to the mailserver for each mail thus consuming |
| 1611 | 1611 | // more time than expected; so we call this section only when there is no |
| 1612 | 1612 | // bodypreview could be found (multipart/....) |
| 1613 | - if ($_fetchPreviews && empty($headerObject['BODYPREVIEW'])&&($partPrimaryType == 'text') && |
|
| 1613 | + if ($_fetchPreviews && empty($headerObject['BODYPREVIEW']) && ($partPrimaryType == 'text') && |
|
| 1614 | 1614 | ((intval($mime_id) === 1) || !$mime_id) && |
| 1615 | 1615 | ($partdisposition !== 'attachment')) { |
| 1616 | - $_structure=$part; |
|
| 1617 | - $this->fetchPartContents($uid, $_structure, false,true); |
|
| 1618 | - $headerObject['BODYPREVIEW']=trim(str_replace(array("\r\n","\r","\n"),' ',mb_substr(Mail\Html::convertHTMLToText($_structure->getContents()),0,((int)$_fetchPreviews<300?300:$_fetchPreviews)))); |
|
| 1619 | - $charSet=Translation::detect_encoding($headerObject['BODYPREVIEW']); |
|
| 1616 | + $_structure = $part; |
|
| 1617 | + $this->fetchPartContents($uid, $_structure, false, true); |
|
| 1618 | + $headerObject['BODYPREVIEW'] = trim(str_replace(array("\r\n", "\r", "\n"), ' ', mb_substr(Mail\Html::convertHTMLToText($_structure->getContents()), 0, ((int)$_fetchPreviews < 300 ? 300 : $_fetchPreviews)))); |
|
| 1619 | + $charSet = Translation::detect_encoding($headerObject['BODYPREVIEW']); |
|
| 1620 | 1620 | // add line breaks to $bodyParts |
| 1621 | 1621 | //error_log(__METHOD__.' ('.__LINE__.') '.' Charset:'.$bodyParts[$i]['charSet'].'->'.$bodyParts[$i]['body']); |
| 1622 | - $headerObject['BODYPREVIEW'] = Translation::convert_jsonsafe($headerObject['BODYPREVIEW'], $charSet); |
|
| 1622 | + $headerObject['BODYPREVIEW'] = Translation::convert_jsonsafe($headerObject['BODYPREVIEW'], $charSet); |
|
| 1623 | 1623 | //error_log(__METHOD__.__LINE__.$headerObject['BODYPREVIEW']); |
| 1624 | 1624 | } |
| 1625 | 1625 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.' Disp:'.$partdisposition.' Type:'.$partPrimaryType); |
@@ -1629,28 +1629,28 @@ discard block |
||
| 1629 | 1629 | // the presence of an cid does not necessarily indicate its inline. it may lack the needed |
| 1630 | 1630 | // link to show the image. Considering this: we "list" everything that matches the above criteria |
| 1631 | 1631 | // as attachment in order to not loose/miss information on our data |
| 1632 | - $partdisposition='attachment';//($partPrimaryType == 'image'&&!empty($cid)?'inline':'attachment'); |
|
| 1632 | + $partdisposition = 'attachment'; //($partPrimaryType == 'image'&&!empty($cid)?'inline':'attachment'); |
|
| 1633 | 1633 | } |
| 1634 | - if ($mime_type=='message/rfc822') |
|
| 1634 | + if ($mime_type == 'message/rfc822') |
|
| 1635 | 1635 | { |
| 1636 | 1636 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.':'.array2string($part->contentTypeMap())); |
| 1637 | - foreach($part->contentTypeMap() as $sub_id => $sub_type) { if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type;} |
|
| 1637 | + foreach ($part->contentTypeMap() as $sub_id => $sub_type) { if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type; } |
|
| 1638 | 1638 | } |
| 1639 | 1639 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.' Disp:'.$partdisposition.' Type:'.$partPrimaryType.' Skip:'.array2string($skipParts)); |
| 1640 | - if (array_key_exists($mime_id,$skipParts)) continue; |
|
| 1641 | - if ($partdisposition=='attachment' || |
|
| 1642 | - ($partdisposition=='inline'&&$partPrimaryType == 'image'&&$mime_type=='image/tiff') || // as we are not able to display tiffs |
|
| 1643 | - ($partdisposition=='inline'&&$partPrimaryType == 'image'&&empty($cid)) || |
|
| 1644 | - ($partdisposition=='inline' && $partPrimaryType != 'image' && $partPrimaryType != 'multipart' && $partPrimaryType != 'text')) |
|
| 1640 | + if (array_key_exists($mime_id, $skipParts)) continue; |
|
| 1641 | + if ($partdisposition == 'attachment' || |
|
| 1642 | + ($partdisposition == 'inline' && $partPrimaryType == 'image' && $mime_type == 'image/tiff') || // as we are not able to display tiffs |
|
| 1643 | + ($partdisposition == 'inline' && $partPrimaryType == 'image' && empty($cid)) || |
|
| 1644 | + ($partdisposition == 'inline' && $partPrimaryType != 'image' && $partPrimaryType != 'multipart' && $partPrimaryType != 'text')) |
|
| 1645 | 1645 | { |
| 1646 | - $headerObject['ATTACHMENTS'][$mime_id]=$part->getAllDispositionParameters(); |
|
| 1647 | - $headerObject['ATTACHMENTS'][$mime_id]['mimeType']=$mime_type; |
|
| 1648 | - $headerObject['ATTACHMENTS'][$mime_id]['uid']=$uid; |
|
| 1646 | + $headerObject['ATTACHMENTS'][$mime_id] = $part->getAllDispositionParameters(); |
|
| 1647 | + $headerObject['ATTACHMENTS'][$mime_id]['mimeType'] = $mime_type; |
|
| 1648 | + $headerObject['ATTACHMENTS'][$mime_id]['uid'] = $uid; |
|
| 1649 | 1649 | $headerObject['ATTACHMENTS'][$mime_id]['cid'] = $cid; |
| 1650 | - $headerObject['ATTACHMENTS'][$mime_id]['partID']=$mime_id; |
|
| 1651 | - if (!isset($headerObject['ATTACHMENTS'][$mime_id]['name']))$headerObject['ATTACHMENTS'][$mime_id]['name']=$part->getName(); |
|
| 1652 | - if (!strcasecmp($headerObject['ATTACHMENTS'][$mime_id]['name'],'winmail.dat') || |
|
| 1653 | - $headerObject['ATTACHMENTS'][$mime_id]['mimeType']=='application/ms-tnef') |
|
| 1650 | + $headerObject['ATTACHMENTS'][$mime_id]['partID'] = $mime_id; |
|
| 1651 | + if (!isset($headerObject['ATTACHMENTS'][$mime_id]['name']))$headerObject['ATTACHMENTS'][$mime_id]['name'] = $part->getName(); |
|
| 1652 | + if (!strcasecmp($headerObject['ATTACHMENTS'][$mime_id]['name'], 'winmail.dat') || |
|
| 1653 | + $headerObject['ATTACHMENTS'][$mime_id]['mimeType'] == 'application/ms-tnef') |
|
| 1654 | 1654 | { |
| 1655 | 1655 | $headerObject['ATTACHMENTS'][$mime_id]['is_winmail'] = true; |
| 1656 | 1656 | } |
@@ -1665,54 +1665,54 @@ discard block |
||
| 1665 | 1665 | if (empty($headerObject['UID'])) continue; |
| 1666 | 1666 | //$uid = ($rByUid ? $headerObject['UID'] : $headerObject['MSG_NUM']); |
| 1667 | 1667 | // make dates like "Mon, 23 Apr 2007 10:11:06 UT" working with strtotime |
| 1668 | - if(substr($headerObject['DATE'],-2) === 'UT') { |
|
| 1668 | + if (substr($headerObject['DATE'], -2) === 'UT') { |
|
| 1669 | 1669 | $headerObject['DATE'] .= 'C'; |
| 1670 | 1670 | } |
| 1671 | - if(substr($headerObject['INTERNALDATE'],-2) === 'UT') { |
|
| 1671 | + if (substr($headerObject['INTERNALDATE'], -2) === 'UT') { |
|
| 1672 | 1672 | $headerObject['INTERNALDATE'] .= 'C'; |
| 1673 | 1673 | } |
| 1674 | 1674 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$headerObject['SUBJECT'].'->'.$headerObject['DATE'].'<->'.$headerObject['INTERNALDATE'] .'#'); |
| 1675 | 1675 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$this->decode_subject($headerObject['SUBJECT']).'->'.$headerObject['DATE']); |
| 1676 | - if (isset($headerObject['ATTACHMENTS']) && count($headerObject['ATTACHMENTS'])) foreach ($headerObject['ATTACHMENTS'] as &$a) { $retValue['header'][$sortOrder[$uid]]['attachments'][]=$a;} |
|
| 1677 | - $retValue['header'][$sortOrder[$uid]]['subject'] = $this->decode_subject($headerObject['SUBJECT']); |
|
| 1678 | - $retValue['header'][$sortOrder[$uid]]['size'] = $headerObject['SIZE']; |
|
| 1679 | - $retValue['header'][$sortOrder[$uid]]['date'] = self::_strtotime(($headerObject['DATE']&&!($headerObject['DATE']=='NIL')?$headerObject['DATE']:$headerObject['INTERNALDATE']),'ts',true); |
|
| 1680 | - $retValue['header'][$sortOrder[$uid]]['internaldate']= self::_strtotime($headerObject['INTERNALDATE'],'ts',true); |
|
| 1681 | - $retValue['header'][$sortOrder[$uid]]['mimetype'] = $messageMimeType; |
|
| 1682 | - $retValue['header'][$sortOrder[$uid]]['id'] = $headerObject['MSG_NUM']; |
|
| 1683 | - $retValue['header'][$sortOrder[$uid]]['uid'] = $headerObject['UID']; |
|
| 1684 | - $retValue['header'][$sortOrder[$uid]]['bodypreview'] = $headerObject['BODYPREVIEW']; |
|
| 1685 | - $retValue['header'][$sortOrder[$uid]]['priority'] = ($headerObject['PRIORITY']?$headerObject['PRIORITY']:3); |
|
| 1676 | + if (isset($headerObject['ATTACHMENTS']) && count($headerObject['ATTACHMENTS'])) foreach ($headerObject['ATTACHMENTS'] as &$a) { $retValue['header'][$sortOrder[$uid]]['attachments'][] = $a; } |
|
| 1677 | + $retValue['header'][$sortOrder[$uid]]['subject'] = $this->decode_subject($headerObject['SUBJECT']); |
|
| 1678 | + $retValue['header'][$sortOrder[$uid]]['size'] = $headerObject['SIZE']; |
|
| 1679 | + $retValue['header'][$sortOrder[$uid]]['date'] = self::_strtotime(($headerObject['DATE'] && !($headerObject['DATE'] == 'NIL') ? $headerObject['DATE'] : $headerObject['INTERNALDATE']), 'ts', true); |
|
| 1680 | + $retValue['header'][$sortOrder[$uid]]['internaldate'] = self::_strtotime($headerObject['INTERNALDATE'], 'ts', true); |
|
| 1681 | + $retValue['header'][$sortOrder[$uid]]['mimetype'] = $messageMimeType; |
|
| 1682 | + $retValue['header'][$sortOrder[$uid]]['id'] = $headerObject['MSG_NUM']; |
|
| 1683 | + $retValue['header'][$sortOrder[$uid]]['uid'] = $headerObject['UID']; |
|
| 1684 | + $retValue['header'][$sortOrder[$uid]]['bodypreview'] = $headerObject['BODYPREVIEW']; |
|
| 1685 | + $retValue['header'][$sortOrder[$uid]]['priority'] = ($headerObject['PRIORITY'] ? $headerObject['PRIORITY'] : 3); |
|
| 1686 | 1686 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.array2string($retValue['header'][$sortOrder[$uid]])); |
| 1687 | 1687 | if (isset($headerObject['DISPOSITION-NOTIFICATION-TO'])) $retValue['header'][$sortOrder[$uid]]['disposition-notification-to'] = $headerObject['DISPOSITION-NOTIFICATION-TO']; |
| 1688 | 1688 | if (is_array($headerObject['FLAGS'])) { |
| 1689 | - $retValue['header'][$sortOrder[$uid]] = array_merge($retValue['header'][$sortOrder[$uid]],self::prepareFlagsArray($headerObject)); |
|
| 1689 | + $retValue['header'][$sortOrder[$uid]] = array_merge($retValue['header'][$sortOrder[$uid]], self::prepareFlagsArray($headerObject)); |
|
| 1690 | 1690 | } |
| 1691 | 1691 | //error_log(__METHOD__.' ('.__LINE__.') '.$headerObject['SUBJECT'].'->'.array2string($_headerObject->getEnvelope()->__get('from'))); |
| 1692 | - if(is_array($headerObject['FROM']) && $headerObject['FROM'][0]) { |
|
| 1693 | - $retValue['header'][$sortOrder[$uid]]['sender_address'] = self::decode_header($headerObject['FROM'][0],true); |
|
| 1692 | + if (is_array($headerObject['FROM']) && $headerObject['FROM'][0]) { |
|
| 1693 | + $retValue['header'][$sortOrder[$uid]]['sender_address'] = self::decode_header($headerObject['FROM'][0], true); |
|
| 1694 | 1694 | } |
| 1695 | - if(is_array($headerObject['TO']) && $headerObject['TO'][0]) { |
|
| 1696 | - $retValue['header'][$sortOrder[$uid]]['to_address'] = self::decode_header($headerObject['TO'][0],true); |
|
| 1697 | - if (count($headerObject['TO'])>1) |
|
| 1695 | + if (is_array($headerObject['TO']) && $headerObject['TO'][0]) { |
|
| 1696 | + $retValue['header'][$sortOrder[$uid]]['to_address'] = self::decode_header($headerObject['TO'][0], true); |
|
| 1697 | + if (count($headerObject['TO']) > 1) |
|
| 1698 | 1698 | { |
| 1699 | - $ki=0; |
|
| 1700 | - foreach($headerObject['TO'] as $k => $add) |
|
| 1699 | + $ki = 0; |
|
| 1700 | + foreach ($headerObject['TO'] as $k => $add) |
|
| 1701 | 1701 | { |
| 1702 | - if ($k==0) continue; |
|
| 1702 | + if ($k == 0) continue; |
|
| 1703 | 1703 | //error_log(__METHOD__.' ('.__LINE__.') '."-> $k:".array2string($add)); |
| 1704 | - $retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki] = self::decode_header($add,true); |
|
| 1704 | + $retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki] = self::decode_header($add, true); |
|
| 1705 | 1705 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki])); |
| 1706 | 1706 | $ki++; |
| 1707 | 1707 | } |
| 1708 | 1708 | } |
| 1709 | 1709 | } |
| 1710 | - if(is_array($headerObject['CC']) && count($headerObject['CC'])>0) { |
|
| 1711 | - $ki=0; |
|
| 1712 | - foreach($headerObject['CC'] as $k => $add) |
|
| 1710 | + if (is_array($headerObject['CC']) && count($headerObject['CC']) > 0) { |
|
| 1711 | + $ki = 0; |
|
| 1712 | + foreach ($headerObject['CC'] as $k => $add) |
|
| 1713 | 1713 | { |
| 1714 | 1714 | //error_log(__METHOD__.' ('.__LINE__.') '."-> $k:".array2string($add)); |
| 1715 | - $retValue['header'][$sortOrder[$uid]]['cc_addresses'][$ki] = self::decode_header($add,true); |
|
| 1715 | + $retValue['header'][$sortOrder[$uid]]['cc_addresses'][$ki] = self::decode_header($add, true); |
|
| 1716 | 1716 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki])); |
| 1717 | 1717 | $ki++; |
| 1718 | 1718 | } |
@@ -1721,27 +1721,27 @@ discard block |
||
| 1721 | 1721 | |
| 1722 | 1722 | $count++; |
| 1723 | 1723 | } |
| 1724 | - if (self::$debug||self::$debugTimes) self::logRunTimes($starttime,null,' fetching Headers and stuff for Folder:'.$_folderName,__METHOD__.' ('.__LINE__.') '); |
|
| 1724 | + if (self::$debug || self::$debugTimes) self::logRunTimes($starttime, null, ' fetching Headers and stuff for Folder:'.$_folderName, __METHOD__.' ('.__LINE__.') '); |
|
| 1725 | 1725 | //self::$debug=false; |
| 1726 | 1726 | // sort the messages to the requested displayorder |
| 1727 | - if(is_array($retValue['header'])) { |
|
| 1727 | + if (is_array($retValue['header'])) { |
|
| 1728 | 1728 | $countMessages = $total; |
| 1729 | 1729 | if (isset($_filter['range'])) $countMessages = self::$folderStatusCache[$this->profileID][$_folderName]['messages']; |
| 1730 | 1730 | ksort($retValue['header']); |
| 1731 | 1731 | $retValue['info']['total'] = $total; |
| 1732 | 1732 | //if ($_startMessage>$total) $_startMessage = $total-($count-1); |
| 1733 | 1733 | $retValue['info']['first'] = $_startMessage; |
| 1734 | - $retValue['info']['last'] = $_startMessage + $count - 1 ; |
|
| 1734 | + $retValue['info']['last'] = $_startMessage + $count - 1; |
|
| 1735 | 1735 | return $retValue; |
| 1736 | 1736 | } else { |
| 1737 | 1737 | $retValue = array(); |
| 1738 | 1738 | $retValue['info']['total'] = 0; |
| 1739 | 1739 | $retValue['info']['first'] = 0; |
| 1740 | - $retValue['info']['last'] = 0; |
|
| 1740 | + $retValue['info']['last'] = 0; |
|
| 1741 | 1741 | return $retValue; |
| 1742 | 1742 | } |
| 1743 | 1743 | } else { |
| 1744 | - if ($headersNew == null && empty($_thisUIDOnly)) error_log(__METHOD__." -> retrieval of Message Details to Query $queryString failed: ".print_r($headersNew,TRUE)); |
|
| 1744 | + if ($headersNew == null && empty($_thisUIDOnly)) error_log(__METHOD__." -> retrieval of Message Details to Query $queryString failed: ".print_r($headersNew, TRUE)); |
|
| 1745 | 1745 | $retValue = array(); |
| 1746 | 1746 | $retValue['info']['total'] = 0; |
| 1747 | 1747 | $retValue['info']['first'] = 0; |
@@ -1758,17 +1758,17 @@ discard block |
||
| 1758 | 1758 | */ |
| 1759 | 1759 | static function prepareFlagsArray($headerObject) |
| 1760 | 1760 | { |
| 1761 | - if (is_array($headerObject['FLAGS'])) $headerFlags = array_map('strtolower',$headerObject['FLAGS']); |
|
| 1761 | + if (is_array($headerObject['FLAGS'])) $headerFlags = array_map('strtolower', $headerObject['FLAGS']); |
|
| 1762 | 1762 | $retValue = array(); |
| 1763 | 1763 | $retValue['recent'] = in_array('\\recent', $headerFlags); |
| 1764 | 1764 | $retValue['flagged'] = in_array('\\flagged', $headerFlags); |
| 1765 | - $retValue['answered'] = in_array('\\answered', $headerFlags); |
|
| 1766 | - $retValue['forwarded'] = in_array('$forwarded', $headerFlags); |
|
| 1765 | + $retValue['answered'] = in_array('\\answered', $headerFlags); |
|
| 1766 | + $retValue['forwarded'] = in_array('$forwarded', $headerFlags); |
|
| 1767 | 1767 | $retValue['deleted'] = in_array('\\deleted', $headerFlags); |
| 1768 | - $retValue['seen'] = in_array('\\seen', $headerFlags); |
|
| 1769 | - $retValue['draft'] = in_array('\\draft', $headerFlags); |
|
| 1770 | - $retValue['mdnsent'] = in_array('$mdnsent', $headerFlags)||in_array('mdnsent', $headerFlags); |
|
| 1771 | - $retValue['mdnnotsent'] = in_array('$mdnnotsent', $headerFlags)||in_array('mdnnotsent', $headerFlags); |
|
| 1768 | + $retValue['seen'] = in_array('\\seen', $headerFlags); |
|
| 1769 | + $retValue['draft'] = in_array('\\draft', $headerFlags); |
|
| 1770 | + $retValue['mdnsent'] = in_array('$mdnsent', $headerFlags) || in_array('mdnsent', $headerFlags); |
|
| 1771 | + $retValue['mdnnotsent'] = in_array('$mdnnotsent', $headerFlags) || in_array('mdnnotsent', $headerFlags); |
|
| 1772 | 1772 | $retValue['label1'] = in_array('$label1', $headerFlags); |
| 1773 | 1773 | $retValue['label2'] = in_array('$label2', $headerFlags); |
| 1774 | 1774 | $retValue['label3'] = in_array('$label3', $headerFlags); |
@@ -1792,12 +1792,12 @@ discard block |
||
| 1792 | 1792 | * @param bool $setSession if set to true the session will be populated with the result of the query |
| 1793 | 1793 | * @return mixed bool/array false or array of ids |
| 1794 | 1794 | */ |
| 1795 | - function getSortedList($_folderName, $_sort, &$_reverse, $_filter, &$resultByUid=true, $setSession=true) |
|
| 1795 | + function getSortedList($_folderName, $_sort, &$_reverse, $_filter, &$resultByUid = true, $setSession = true) |
|
| 1796 | 1796 | { |
| 1797 | 1797 | static $cachedFolderStatus = null; |
| 1798 | 1798 | // in the past we needed examineMailbox to figure out if the server with the serverID support keywords |
| 1799 | 1799 | // this information is filled/provided by examineMailbox; but caching within one request seems o.k. |
| 1800 | - if (is_null($cachedFolderStatus) || !isset($cachedFolderStatus[$this->profileID][$_folderName]) ) |
|
| 1800 | + if (is_null($cachedFolderStatus) || !isset($cachedFolderStatus[$this->profileID][$_folderName])) |
|
| 1801 | 1801 | { |
| 1802 | 1802 | $folderStatus = $cachedFolderStatus[$this->profileID][$_folderName] = $this->icServer->examineMailbox($_folderName); |
| 1803 | 1803 | } |
@@ -1809,27 +1809,27 @@ discard block |
||
| 1809 | 1809 | //error_log(__METHOD__.' ('.__LINE__.') '.' Filter:'.array2string($_filter)); |
| 1810 | 1810 | $try2useCache = true; |
| 1811 | 1811 | static $eMailListContainsDeletedMessages = null; |
| 1812 | - if (is_null($eMailListContainsDeletedMessages)) $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 1812 | + if (is_null($eMailListContainsDeletedMessages)) $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 1); |
|
| 1813 | 1813 | // this indicates, that there is no Filter set, and the returned set/subset should not contain DELETED Messages, nor filtered for UNDELETED |
| 1814 | - if ($setSession==true && ((strpos(array2string($_filter), 'UNDELETED') === false && strpos(array2string($_filter), 'DELETED') === false))) |
|
| 1814 | + if ($setSession == true && ((strpos(array2string($_filter), 'UNDELETED') === false && strpos(array2string($_filter), 'DELETED') === false))) |
|
| 1815 | 1815 | { |
| 1816 | 1816 | if (self::$debugTimes) $starttime = microtime(true); |
| 1817 | - 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); |
|
| 1818 | - $deletedMessages = $this->getSortedList($_folderName, 0, $three=1, array('status'=>array('DELETED')),$five=true,false); |
|
| 1817 | + 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); |
|
| 1818 | + $deletedMessages = $this->getSortedList($_folderName, 0, $three = 1, array('status'=>array('DELETED')), $five = true, false); |
|
| 1819 | 1819 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') Found DeletedMessages:'.array2string($eMailListContainsDeletedMessages)); |
| 1820 | - $eMailListContainsDeletedMessages[$this->profileID][$_folderName] =$deletedMessages['count']; |
|
| 1821 | - Cache::setCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),$eMailListContainsDeletedMessages, 60*60*1); |
|
| 1822 | - 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']); |
|
| 1820 | + $eMailListContainsDeletedMessages[$this->profileID][$_folderName] = $deletedMessages['count']; |
|
| 1821 | + Cache::setCache(Cache::INSTANCE, 'email', 'eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']), $eMailListContainsDeletedMessages, 60 * 60 * 1); |
|
| 1822 | + 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']); |
|
| 1823 | 1823 | } |
| 1824 | 1824 | $try2useCache = false; |
| 1825 | 1825 | //self::$supportsORinQuery[$this->profileID]=true; |
| 1826 | 1826 | if (is_null(self::$supportsORinQuery) || !isset(self::$supportsORinQuery[$this->profileID])) |
| 1827 | 1827 | { |
| 1828 | - self::$supportsORinQuery = Cache::getCache(Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*10); |
|
| 1829 | - if (!isset(self::$supportsORinQuery[$this->profileID])) self::$supportsORinQuery[$this->profileID]=true; |
|
| 1828 | + self::$supportsORinQuery = Cache::getCache(Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 1829 | + if (!isset(self::$supportsORinQuery[$this->profileID])) self::$supportsORinQuery[$this->profileID] = true; |
|
| 1830 | 1830 | } |
| 1831 | 1831 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_filter).' SupportsOrInQuery:'.self::$supportsORinQuery[$this->profileID]); |
| 1832 | - $filter = $this->createIMAPFilter($_folderName, $_filter,self::$supportsORinQuery[$this->profileID]); |
|
| 1832 | + $filter = $this->createIMAPFilter($_folderName, $_filter, self::$supportsORinQuery[$this->profileID]); |
|
| 1833 | 1833 | if (self::$debug) |
| 1834 | 1834 | { |
| 1835 | 1835 | $query_str = $filter->build(); |
@@ -1837,14 +1837,14 @@ discard block |
||
| 1837 | 1837 | } |
| 1838 | 1838 | //_debug_array($filter); |
| 1839 | 1839 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($filter).'#'.array2string($this->icServer->capability())); |
| 1840 | - if($this->icServer->hasCapability('SORT')) { |
|
| 1840 | + if ($this->icServer->hasCapability('SORT')) { |
|
| 1841 | 1841 | // when using an orQuery and we sort by date. sort seems to fail on certain servers => ZIMBRA with Horde_Imap_Client |
| 1842 | 1842 | // thus we translate the search request from date to Horde_Imap_Client::SORT_SEQUENCE (which should be the same, if |
| 1843 | 1843 | // there is no messing with the dates) |
| 1844 | 1844 | //if (self::$supportsORinQuery[$this->profileID]&&$_sort=='date'&&$_filter['type']=='quick'&&!empty($_filter['string']))$_sort='INTERNALDATE'; |
| 1845 | 1845 | if (self::$debug) error_log(__METHOD__." Mailserver has SORT Capability, SortBy: ".array2string($_sort)." Reverse: $_reverse"); |
| 1846 | 1846 | $sortOrder = $this->_getSortString($_sort, $_reverse); |
| 1847 | - if ($_reverse && in_array(Horde_Imap_Client::SORT_REVERSE,$sortOrder)) $_reverse=false; // as we reversed the result already |
|
| 1847 | + if ($_reverse && in_array(Horde_Imap_Client::SORT_REVERSE, $sortOrder)) $_reverse = false; // as we reversed the result already |
|
| 1848 | 1848 | if (self::$debug) error_log(__METHOD__." Mailserver runs SORT: SortBy:".array2string($_sort)."->".array2string($sortOrder)." Filter: ".array2string($filter)); |
| 1849 | 1849 | try |
| 1850 | 1850 | { |
@@ -1852,24 +1852,24 @@ discard block |
||
| 1852 | 1852 | 'sort' => $sortOrder,)); |
| 1853 | 1853 | // if there is an Error, we assume that the server is not capable of sorting |
| 1854 | 1854 | } |
| 1855 | - catch(\Exception $e) |
|
| 1855 | + catch (\Exception $e) |
|
| 1856 | 1856 | { |
| 1857 | 1857 | //error_log(__METHOD__.'('.__LINE__.'):'.$e->getMessage()); |
| 1858 | 1858 | $resultByUid = false; |
| 1859 | 1859 | $sortOrder = array(Horde_Imap_Client::SORT_SEQUENCE); |
| 1860 | - if ($_reverse) array_unshift($sortOrder,Horde_Imap_Client::SORT_REVERSE); |
|
| 1860 | + if ($_reverse) array_unshift($sortOrder, Horde_Imap_Client::SORT_REVERSE); |
|
| 1861 | 1861 | try |
| 1862 | 1862 | { |
| 1863 | 1863 | $sortResult = $this->icServer->search($_folderName, $filter, array( |
| 1864 | 1864 | 'sort' => $sortOrder)); |
| 1865 | 1865 | } |
| 1866 | - catch(\Exception $e) |
|
| 1866 | + catch (\Exception $e) |
|
| 1867 | 1867 | { |
| 1868 | 1868 | error_log(__METHOD__.'('.__LINE__.'):'.$e->getMessage()); |
| 1869 | 1869 | $sortResult = self::$folderStatusCache[$this->profileID][$_folderName]['sortResult']; |
| 1870 | 1870 | } |
| 1871 | 1871 | } |
| 1872 | - if (self::$debug) error_log(__METHOD__.print_r($sortResult,true)); |
|
| 1872 | + if (self::$debug) error_log(__METHOD__.print_r($sortResult, true)); |
|
| 1873 | 1873 | } else { |
| 1874 | 1874 | if (self::$debug) error_log(__METHOD__." Mailserver has NO SORT Capability"); |
| 1875 | 1875 | //$sortOrder = array(Horde_Imap_Client::SORT_SEQUENCE); |
@@ -1879,12 +1879,12 @@ discard block |
||
| 1879 | 1879 | $sortResult = $this->icServer->search($_folderName, $filter, array()/*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 | // possible error OR Query. But Horde gives no detailed Info :-( |
| 1886 | - self::$supportsORinQuery[$this->profileID]=false; |
|
| 1887 | - Cache::setCache(Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),self::$supportsORinQuery,60*60*10); |
|
| 1886 | + self::$supportsORinQuery[$this->profileID] = false; |
|
| 1887 | + Cache::setCache(Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), self::$supportsORinQuery, 60 * 60 * 10); |
|
| 1888 | 1888 | if (self::$debug) error_log(__METHOD__.__LINE__." Mailserver seems to have NO OR Capability for Search:".$sortResult->message); |
| 1889 | 1889 | $filter = $this->createIMAPFilter($_folderName, $_filter, self::$supportsORinQuery[$this->profileID]); |
| 1890 | 1890 | try |
@@ -1892,25 +1892,25 @@ discard block |
||
| 1892 | 1892 | $sortResult = $this->icServer->search($_folderName, $filter, array()/*array( |
| 1893 | 1893 | 'sort' => $sortOrder)*/); |
| 1894 | 1894 | } |
| 1895 | - catch(\Exception $e) |
|
| 1895 | + catch (\Exception $e) |
|
| 1896 | 1896 | { |
| 1897 | 1897 | } |
| 1898 | 1898 | } |
| 1899 | - if(is_array($sortResult['match'])) { |
|
| 1899 | + if (is_array($sortResult['match'])) { |
|
| 1900 | 1900 | // not sure that this is going so succeed as $sortResult['match'] is a hordeObject |
| 1901 | 1901 | sort($sortResult['match'], SORT_NUMERIC); |
| 1902 | 1902 | } |
| 1903 | - if (self::$debug) error_log(__METHOD__." using Filter:".print_r($filter,true)." ->".print_r($sortResult,true)); |
|
| 1903 | + if (self::$debug) error_log(__METHOD__." using Filter:".print_r($filter, true)." ->".print_r($sortResult, true)); |
|
| 1904 | 1904 | } |
| 1905 | 1905 | if ($setSession) |
| 1906 | 1906 | { |
| 1907 | 1907 | self::$folderStatusCache[$this->profileID][$_folderName]['uidValidity'] = $folderStatus['UIDVALIDITY']; |
| 1908 | - self::$folderStatusCache[$this->profileID][$_folderName]['messages'] = $folderStatus['MESSAGES']; |
|
| 1908 | + self::$folderStatusCache[$this->profileID][$_folderName]['messages'] = $folderStatus['MESSAGES']; |
|
| 1909 | 1909 | self::$folderStatusCache[$this->profileID][$_folderName]['deleted'] = $eMailListContainsDeletedMessages[$this->profileID][$_folderName]; |
| 1910 | 1910 | self::$folderStatusCache[$this->profileID][$_folderName]['uidnext'] = $folderStatus['UIDNEXT']; |
| 1911 | - self::$folderStatusCache[$this->profileID][$_folderName]['filter'] = $_filter; |
|
| 1911 | + self::$folderStatusCache[$this->profileID][$_folderName]['filter'] = $_filter; |
|
| 1912 | 1912 | self::$folderStatusCache[$this->profileID][$_folderName]['sortResult'] = $sortResult; |
| 1913 | - self::$folderStatusCache[$this->profileID][$_folderName]['sort'] = $_sort; |
|
| 1913 | + self::$folderStatusCache[$this->profileID][$_folderName]['sort'] = $_sort; |
|
| 1914 | 1914 | } |
| 1915 | 1915 | //error_log(__METHOD__." using Filter:".print_r($filter,true)." ->".print_r($sortResult,true)); |
| 1916 | 1916 | //_debug_array($sortResult['match']->ids); |
@@ -1924,12 +1924,12 @@ discard block |
||
| 1924 | 1924 | * @param bool _reverse wether to add REVERSE to the Sort String or not |
| 1925 | 1925 | * @return the sort sequence for horde search |
| 1926 | 1926 | */ |
| 1927 | - function _getSortString($_sort, $_reverse=false) |
|
| 1927 | + function _getSortString($_sort, $_reverse = false) |
|
| 1928 | 1928 | { |
| 1929 | - $_reverse=false; |
|
| 1929 | + $_reverse = false; |
|
| 1930 | 1930 | if (is_numeric($_sort)) |
| 1931 | 1931 | { |
| 1932 | - switch($_sort) { |
|
| 1932 | + switch ($_sort) { |
|
| 1933 | 1933 | case 2: |
| 1934 | 1934 | $retValue = array(Horde_Imap_Client::SORT_FROM); |
| 1935 | 1935 | break; |
@@ -1951,7 +1951,7 @@ discard block |
||
| 1951 | 1951 | } |
| 1952 | 1952 | else |
| 1953 | 1953 | { |
| 1954 | - switch(strtoupper($_sort)) { |
|
| 1954 | + switch (strtoupper($_sort)) { |
|
| 1955 | 1955 | case 'FROMADDRESS': |
| 1956 | 1956 | $retValue = array(Horde_Imap_Client::SORT_FROM); |
| 1957 | 1957 | break; |
@@ -1977,7 +1977,7 @@ discard block |
||
| 1977 | 1977 | break; |
| 1978 | 1978 | } |
| 1979 | 1979 | } |
| 1980 | - if ($_reverse) array_unshift($retValue,Horde_Imap_Client::SORT_REVERSE); |
|
| 1980 | + if ($_reverse) array_unshift($retValue, Horde_Imap_Client::SORT_REVERSE); |
|
| 1981 | 1981 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.($_reverse?'REVERSE ':'').$_sort.'->'.$retValue); |
| 1982 | 1982 | return $retValue; |
| 1983 | 1983 | } |
@@ -1990,28 +1990,28 @@ discard block |
||
| 1990 | 1990 | * @param boolean $_supportsOrInQuery wether to use the OR Query on QuickSearch |
| 1991 | 1991 | * @return Horde_Imap_Client_Search_Query the IMAP filter |
| 1992 | 1992 | */ |
| 1993 | - function createIMAPFilter($_folder, $_criterias, $_supportsOrInQuery=true) |
|
| 1993 | + function createIMAPFilter($_folder, $_criterias, $_supportsOrInQuery = true) |
|
| 1994 | 1994 | { |
| 1995 | 1995 | $imapFilter = new Horde_Imap_Client_Search_Query(); |
| 1996 | 1996 | $imapFilter->charset('UTF-8'); |
| 1997 | 1997 | |
| 1998 | 1998 | //_debug_array($_criterias); |
| 1999 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' Criterias:'.(!is_array($_criterias)?" none -> returning":array2string($_criterias))); |
|
| 2000 | - if((!is_array($_criterias) || $_criterias['status']=='any') && |
|
| 1999 | + if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' Criterias:'.(!is_array($_criterias) ? " none -> returning" : array2string($_criterias))); |
|
| 2000 | + if ((!is_array($_criterias) || $_criterias['status'] == 'any') && |
|
| 2001 | 2001 | (!isset($_criterias['string']) || empty($_criterias['string'])) && |
| 2002 | - (!isset($_criterias['range'])|| empty($_criterias['range']) || |
|
| 2003 | - ( !empty($_criterias['range'])&& ($_criterias['range']!='BETWEEN' && empty($_criterias['date'])|| |
|
| 2004 | - ($_criterias['range']=='BETWEEN' && empty($_criterias['since'])&& empty($_criterias['before'])))))) |
|
| 2002 | + (!isset($_criterias['range']) || empty($_criterias['range']) || |
|
| 2003 | + (!empty($_criterias['range']) && ($_criterias['range'] != 'BETWEEN' && empty($_criterias['date']) || |
|
| 2004 | + ($_criterias['range'] == 'BETWEEN' && empty($_criterias['since']) && empty($_criterias['before'])))))) |
|
| 2005 | 2005 | { |
| 2006 | 2006 | //error_log(__METHOD__.' ('.__LINE__.') returning early Criterias:'.print_r($_criterias, true)); |
| 2007 | - $imapFilter->flag('DELETED', $set=false); |
|
| 2007 | + $imapFilter->flag('DELETED', $set = false); |
|
| 2008 | 2008 | return $imapFilter; |
| 2009 | 2009 | } |
| 2010 | 2010 | $queryValid = false; |
| 2011 | 2011 | // statusQuery MUST be placed first, as search for subject/mailbody and such is |
| 2012 | 2012 | // depending on charset. flagSearch is not BUT messes the charset if called afterwards |
| 2013 | 2013 | $statusQueryValid = false; |
| 2014 | - foreach((array)$_criterias['status'] as $k => $criteria) { |
|
| 2014 | + foreach ((array)$_criterias['status'] as $k => $criteria) { |
|
| 2015 | 2015 | $imapStatusFilter = new Horde_Imap_Client_Search_Query(); |
| 2016 | 2016 | $imapStatusFilter->charset('UTF-8'); |
| 2017 | 2017 | $criteria = strtoupper($criteria); |
@@ -2021,12 +2021,12 @@ discard block |
||
| 2021 | 2021 | case 'FLAGGED': |
| 2022 | 2022 | case 'RECENT': |
| 2023 | 2023 | case 'SEEN': |
| 2024 | - $imapStatusFilter->flag($criteria, $set=true); |
|
| 2025 | - $queryValid = $statusQueryValid =true; |
|
| 2024 | + $imapStatusFilter->flag($criteria, $set = true); |
|
| 2025 | + $queryValid = $statusQueryValid = true; |
|
| 2026 | 2026 | break; |
| 2027 | 2027 | case 'READ': |
| 2028 | - $imapStatusFilter->flag('SEEN', $set=true); |
|
| 2029 | - $queryValid = $statusQueryValid =true; |
|
| 2028 | + $imapStatusFilter->flag('SEEN', $set = true); |
|
| 2029 | + $queryValid = $statusQueryValid = true; |
|
| 2030 | 2030 | break; |
| 2031 | 2031 | case 'LABEL1': |
| 2032 | 2032 | case 'KEYWORD1': |
@@ -2038,38 +2038,38 @@ discard block |
||
| 2038 | 2038 | case 'KEYWORD4': |
| 2039 | 2039 | case 'LABEL5': |
| 2040 | 2040 | case 'KEYWORD5': |
| 2041 | - $imapStatusFilter->flag(str_ireplace('KEYWORD','$LABEL',$criteria), $set=true); |
|
| 2042 | - $queryValid = $statusQueryValid =true; |
|
| 2041 | + $imapStatusFilter->flag(str_ireplace('KEYWORD', '$LABEL', $criteria), $set = true); |
|
| 2042 | + $queryValid = $statusQueryValid = true; |
|
| 2043 | 2043 | break; |
| 2044 | 2044 | case 'NEW': |
| 2045 | - $imapStatusFilter->flag('RECENT', $set=true); |
|
| 2046 | - $imapStatusFilter->flag('SEEN', $set=false); |
|
| 2047 | - $queryValid = $statusQueryValid =true; |
|
| 2045 | + $imapStatusFilter->flag('RECENT', $set = true); |
|
| 2046 | + $imapStatusFilter->flag('SEEN', $set = false); |
|
| 2047 | + $queryValid = $statusQueryValid = true; |
|
| 2048 | 2048 | break; |
| 2049 | 2049 | case 'OLD': |
| 2050 | - $imapStatusFilter->flag('RECENT', $set=false); |
|
| 2051 | - $queryValid = $statusQueryValid =true; |
|
| 2050 | + $imapStatusFilter->flag('RECENT', $set = false); |
|
| 2051 | + $queryValid = $statusQueryValid = true; |
|
| 2052 | 2052 | break; |
| 2053 | 2053 | // operate only on system flags |
| 2054 | 2054 | // $systemflags = array( |
| 2055 | 2055 | // 'ANSWERED', 'DELETED', 'DRAFT', 'FLAGGED', 'RECENT', 'SEEN' |
| 2056 | 2056 | // ); |
| 2057 | 2057 | case 'UNANSWERED': |
| 2058 | - $imapStatusFilter->flag('ANSWERED', $set=false); |
|
| 2059 | - $queryValid = $statusQueryValid =true; |
|
| 2058 | + $imapStatusFilter->flag('ANSWERED', $set = false); |
|
| 2059 | + $queryValid = $statusQueryValid = true; |
|
| 2060 | 2060 | break; |
| 2061 | 2061 | case 'UNDELETED': |
| 2062 | - $imapFilter->flag('DELETED', $set=false); |
|
| 2062 | + $imapFilter->flag('DELETED', $set = false); |
|
| 2063 | 2063 | $queryValid = true; |
| 2064 | 2064 | break; |
| 2065 | 2065 | case 'UNFLAGGED': |
| 2066 | - $imapStatusFilter->flag('FLAGGED', $set=false); |
|
| 2067 | - $queryValid = $statusQueryValid =true; |
|
| 2066 | + $imapStatusFilter->flag('FLAGGED', $set = false); |
|
| 2067 | + $queryValid = $statusQueryValid = true; |
|
| 2068 | 2068 | break; |
| 2069 | 2069 | case 'UNREAD': |
| 2070 | 2070 | case 'UNSEEN': |
| 2071 | - $imapStatusFilter->flag('SEEN', $set=false); |
|
| 2072 | - $queryValid = $statusQueryValid =true; |
|
| 2071 | + $imapStatusFilter->flag('SEEN', $set = false); |
|
| 2072 | + $queryValid = $statusQueryValid = true; |
|
| 2073 | 2073 | break; |
| 2074 | 2074 | case 'UNLABEL1': |
| 2075 | 2075 | case 'UNKEYWORD1': |
@@ -2081,8 +2081,8 @@ discard block |
||
| 2081 | 2081 | case 'UNKEYWORD4': |
| 2082 | 2082 | case 'UNLABEL5': |
| 2083 | 2083 | case 'UNKEYWORD5': |
| 2084 | - $imapStatusFilter->flag(str_ireplace(array('UNKEYWORD','UNLABEL'),'$LABEL',$criteria), $set=false); |
|
| 2085 | - $queryValid = $statusQueryValid =true; |
|
| 2084 | + $imapStatusFilter->flag(str_ireplace(array('UNKEYWORD', 'UNLABEL'), '$LABEL', $criteria), $set = false); |
|
| 2085 | + $queryValid = $statusQueryValid = true; |
|
| 2086 | 2086 | break; |
| 2087 | 2087 | default: |
| 2088 | 2088 | $statusQueryValid = false; |
@@ -2098,20 +2098,20 @@ discard block |
||
| 2098 | 2098 | $imapSearchFilter = new Horde_Imap_Client_Search_Query(); |
| 2099 | 2099 | $imapSearchFilter->charset('UTF-8'); |
| 2100 | 2100 | |
| 2101 | - if(!empty($_criterias['string'])) { |
|
| 2101 | + if (!empty($_criterias['string'])) { |
|
| 2102 | 2102 | $criteria = strtoupper($_criterias['type']); |
| 2103 | 2103 | switch ($criteria) { |
| 2104 | 2104 | case 'BYDATE': |
| 2105 | 2105 | case 'QUICK': |
| 2106 | 2106 | case 'QUICKWITHCC': |
| 2107 | - $imapSearchFilter->headerText('SUBJECT', $_criterias['string'], $not=false); |
|
| 2107 | + $imapSearchFilter->headerText('SUBJECT', $_criterias['string'], $not = false); |
|
| 2108 | 2108 | //$imapSearchFilter->charset('UTF-8'); |
| 2109 | 2109 | $imapFilter2 = new Horde_Imap_Client_Search_Query(); |
| 2110 | 2110 | $imapFilter2->charset('UTF-8'); |
| 2111 | - if($this->isSentFolder($_folder)) { |
|
| 2112 | - $imapFilter2->headerText('TO', $_criterias['string'], $not=false); |
|
| 2111 | + if ($this->isSentFolder($_folder)) { |
|
| 2112 | + $imapFilter2->headerText('TO', $_criterias['string'], $not = false); |
|
| 2113 | 2113 | } else { |
| 2114 | - $imapFilter2->headerText('FROM', $_criterias['string'], $not=false); |
|
| 2114 | + $imapFilter2->headerText('FROM', $_criterias['string'], $not = false); |
|
| 2115 | 2115 | } |
| 2116 | 2116 | if ($_supportsOrInQuery) |
| 2117 | 2117 | { |
@@ -2121,31 +2121,31 @@ discard block |
||
| 2121 | 2121 | { |
| 2122 | 2122 | $imapSearchFilter->andSearch($imapFilter2); |
| 2123 | 2123 | } |
| 2124 | - if ($_supportsOrInQuery && $criteria=='QUICKWITHCC') |
|
| 2124 | + if ($_supportsOrInQuery && $criteria == 'QUICKWITHCC') |
|
| 2125 | 2125 | { |
| 2126 | 2126 | $imapFilter3 = new Horde_Imap_Client_Search_Query(); |
| 2127 | 2127 | $imapFilter3->charset('UTF-8'); |
| 2128 | - $imapFilter3->headerText('CC', $_criterias['string'], $not=false); |
|
| 2128 | + $imapFilter3->headerText('CC', $_criterias['string'], $not = false); |
|
| 2129 | 2129 | $imapSearchFilter->orSearch($imapFilter3); |
| 2130 | 2130 | } |
| 2131 | 2131 | $queryValid = true; |
| 2132 | 2132 | break; |
| 2133 | 2133 | case 'LARGER': |
| 2134 | 2134 | case 'SMALLER': |
| 2135 | - if (strlen(trim($_criterias['string'])) != strlen((float) trim($_criterias['string']))) |
|
| 2135 | + if (strlen(trim($_criterias['string'])) != strlen((float)trim($_criterias['string']))) |
|
| 2136 | 2136 | { |
| 2137 | 2137 | //examine string to evaluate size |
| 2138 | - $unit = strtoupper(trim(substr(trim($_criterias['string']),strlen((float) trim($_criterias['string']))))); |
|
| 2139 | - $multipleBy = array('KB'=>1024,'K'=>1024, |
|
| 2140 | - 'MB'=>1024*1000,'M'=>1024*1000, |
|
| 2141 | - 'GB'=>1024*1000*1000,'G'=>1024*1000*1000, |
|
| 2142 | - 'TB'=>1024*1000*1000*1000,'T'=>1024*1000*1000*1000); |
|
| 2143 | - $numberinBytes=(float)$_criterias['string']; |
|
| 2144 | - if (isset($multipleBy[$unit])) $numberinBytes=(float)$_criterias['string']*$multipleBy[$unit]; |
|
| 2138 | + $unit = strtoupper(trim(substr(trim($_criterias['string']), strlen((float)trim($_criterias['string']))))); |
|
| 2139 | + $multipleBy = array('KB'=>1024, 'K'=>1024, |
|
| 2140 | + 'MB'=>1024 * 1000, 'M'=>1024 * 1000, |
|
| 2141 | + 'GB'=>1024 * 1000 * 1000, 'G'=>1024 * 1000 * 1000, |
|
| 2142 | + 'TB'=>1024 * 1000 * 1000 * 1000, 'T'=>1024 * 1000 * 1000 * 1000); |
|
| 2143 | + $numberinBytes = (float)$_criterias['string']; |
|
| 2144 | + if (isset($multipleBy[$unit])) $numberinBytes = (float)$_criterias['string'] * $multipleBy[$unit]; |
|
| 2145 | 2145 | //error_log(__METHOD__.__LINE__.'#'.$_criterias['string'].'->'.(float)$_criterias['string'].'#'.$unit.' ='.$numberinBytes); |
| 2146 | - $_criterias['string']=$numberinBytes; |
|
| 2146 | + $_criterias['string'] = $numberinBytes; |
|
| 2147 | 2147 | } |
| 2148 | - $imapSearchFilter->size( $_criterias['string'], ($criteria=='LARGER'?true:false), $not=false); |
|
| 2148 | + $imapSearchFilter->size($_criterias['string'], ($criteria == 'LARGER' ? true : false), $not = false); |
|
| 2149 | 2149 | //$imapSearchFilter->charset('UTF-8'); |
| 2150 | 2150 | $queryValid = true; |
| 2151 | 2151 | break; |
@@ -2154,31 +2154,31 @@ discard block |
||
| 2154 | 2154 | case 'CC': |
| 2155 | 2155 | case 'BCC': |
| 2156 | 2156 | case 'SUBJECT': |
| 2157 | - $imapSearchFilter->headerText($criteria, $_criterias['string'], $not=false); |
|
| 2157 | + $imapSearchFilter->headerText($criteria, $_criterias['string'], $not = false); |
|
| 2158 | 2158 | //$imapSearchFilter->charset('UTF-8'); |
| 2159 | 2159 | $queryValid = true; |
| 2160 | 2160 | break; |
| 2161 | 2161 | case 'BODY': |
| 2162 | 2162 | case 'TEXT': |
| 2163 | - $imapSearchFilter->text($_criterias['string'],($criteria=='BODY'?true:false), $not=false); |
|
| 2163 | + $imapSearchFilter->text($_criterias['string'], ($criteria == 'BODY' ? true : false), $not = false); |
|
| 2164 | 2164 | //$imapSearchFilter->charset('UTF-8'); |
| 2165 | 2165 | $queryValid = true; |
| 2166 | 2166 | break; |
| 2167 | 2167 | case 'SINCE': |
| 2168 | - $imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_SINCE, $header=true, $not=false); |
|
| 2168 | + $imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_SINCE, $header = true, $not = false); |
|
| 2169 | 2169 | $queryValid = true; |
| 2170 | 2170 | break; |
| 2171 | 2171 | case 'BEFORE': |
| 2172 | - $imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header=true, $not=false); |
|
| 2172 | + $imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header = true, $not = false); |
|
| 2173 | 2173 | $queryValid = true; |
| 2174 | 2174 | break; |
| 2175 | 2175 | case 'ON': |
| 2176 | - $imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_ON, $header=true, $not=false); |
|
| 2176 | + $imapSearchFilter->dateSearch(new DateTime($_criterias['string']), Horde_Imap_Client_Search_Query::DATE_ON, $header = true, $not = false); |
|
| 2177 | 2177 | $queryValid = true; |
| 2178 | 2178 | break; |
| 2179 | 2179 | } |
| 2180 | 2180 | } |
| 2181 | - if ($statusQueryValid && !$queryValid) $queryValid=true; |
|
| 2181 | + if ($statusQueryValid && !$queryValid) $queryValid = true; |
|
| 2182 | 2182 | if ($queryValid) $imapFilter->andSearch($imapSearchFilter); |
| 2183 | 2183 | |
| 2184 | 2184 | if (isset($_criterias['range']) && !empty($_criterias['range'])) |
@@ -2187,12 +2187,12 @@ discard block |
||
| 2187 | 2187 | $imapRangeFilter = new Horde_Imap_Client_Search_Query(); |
| 2188 | 2188 | $imapRangeFilter->charset('UTF-8'); |
| 2189 | 2189 | $criteria = strtoupper($_criterias['range']); |
| 2190 | - if ($_criterias['range'] == "BETWEEN" && isset($_criterias['since']) && isset($_criterias['before']) && $_criterias['since']==$_criterias['before']) |
|
| 2190 | + if ($_criterias['range'] == "BETWEEN" && isset($_criterias['since']) && isset($_criterias['before']) && $_criterias['since'] == $_criterias['before']) |
|
| 2191 | 2191 | { |
| 2192 | - $_criterias['date']=$_criterias['since']; |
|
| 2192 | + $_criterias['date'] = $_criterias['since']; |
|
| 2193 | 2193 | unset($_criterias['since']); |
| 2194 | 2194 | unset($_criterias['before']); |
| 2195 | - $criteria=$_criterias['range']='ON'; |
|
| 2195 | + $criteria = $_criterias['range'] = 'ON'; |
|
| 2196 | 2196 | } |
| 2197 | 2197 | switch ($criteria) { |
| 2198 | 2198 | case 'BETWEEN': |
@@ -2200,7 +2200,7 @@ discard block |
||
| 2200 | 2200 | //enddate |
| 2201 | 2201 | if ($_criterias['since']) |
| 2202 | 2202 | { |
| 2203 | - $imapRangeFilter->dateSearch(new DateTime($_criterias['since']), Horde_Imap_Client_Search_Query::DATE_SINCE, $header=true, $not=false); |
|
| 2203 | + $imapRangeFilter->dateSearch(new DateTime($_criterias['since']), Horde_Imap_Client_Search_Query::DATE_SINCE, $header = true, $not = false); |
|
| 2204 | 2204 | $rangeValid = true; |
| 2205 | 2205 | } |
| 2206 | 2206 | //startdate |
@@ -2209,28 +2209,28 @@ discard block |
||
| 2209 | 2209 | $imapRangeFilter2 = new Horde_Imap_Client_Search_Query(); |
| 2210 | 2210 | $imapRangeFilter2->charset('UTF-8'); |
| 2211 | 2211 | //our before (startdate) is inklusive, as we work with "d-M-Y", we must add a day |
| 2212 | - $_criterias['before'] = date("d-M-Y",DateTime::to($_criterias['before'],'ts')+(3600*24)); |
|
| 2213 | - $imapRangeFilter2->dateSearch(new DateTime($_criterias['before']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header=true, $not=false); |
|
| 2212 | + $_criterias['before'] = date("d-M-Y", DateTime::to($_criterias['before'], 'ts') + (3600 * 24)); |
|
| 2213 | + $imapRangeFilter2->dateSearch(new DateTime($_criterias['before']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header = true, $not = false); |
|
| 2214 | 2214 | $imapRangeFilter->andSearch($imapRangeFilter2); |
| 2215 | 2215 | $rangeValid = true; |
| 2216 | 2216 | } |
| 2217 | 2217 | break; |
| 2218 | 2218 | case 'SINCE'://enddate |
| 2219 | - $imapRangeFilter->dateSearch(new DateTime(($_criterias['since']?$_criterias['since']:$_criterias['date'])), Horde_Imap_Client_Search_Query::DATE_SINCE, $header=true, $not=false); |
|
| 2219 | + $imapRangeFilter->dateSearch(new DateTime(($_criterias['since'] ? $_criterias['since'] : $_criterias['date'])), Horde_Imap_Client_Search_Query::DATE_SINCE, $header = true, $not = false); |
|
| 2220 | 2220 | $rangeValid = true; |
| 2221 | 2221 | break; |
| 2222 | 2222 | case 'BEFORE'://startdate |
| 2223 | 2223 | //our before (startdate) is inklusive, as we work with "d-M-Y", we must add a day |
| 2224 | - $_criterias['before'] = date("d-M-Y",DateTime::to(($_criterias['before']?$_criterias['before']:$_criterias['date']),'ts')+(3600*24)); |
|
| 2225 | - $imapRangeFilter->dateSearch(new DateTime($_criterias['before']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header=true, $not=false); |
|
| 2224 | + $_criterias['before'] = date("d-M-Y", DateTime::to(($_criterias['before'] ? $_criterias['before'] : $_criterias['date']), 'ts') + (3600 * 24)); |
|
| 2225 | + $imapRangeFilter->dateSearch(new DateTime($_criterias['before']), Horde_Imap_Client_Search_Query::DATE_BEFORE, $header = true, $not = false); |
|
| 2226 | 2226 | $rangeValid = true; |
| 2227 | 2227 | break; |
| 2228 | 2228 | case 'ON': |
| 2229 | - $imapRangeFilter->dateSearch(new DateTime($_criterias['date']), Horde_Imap_Client_Search_Query::DATE_ON, $header=true, $not=false); |
|
| 2229 | + $imapRangeFilter->dateSearch(new DateTime($_criterias['date']), Horde_Imap_Client_Search_Query::DATE_ON, $header = true, $not = false); |
|
| 2230 | 2230 | $rangeValid = true; |
| 2231 | 2231 | break; |
| 2232 | 2232 | } |
| 2233 | - if ($rangeValid && !$queryValid) $queryValid=true; |
|
| 2233 | + if ($rangeValid && !$queryValid) $queryValid = true; |
|
| 2234 | 2234 | if ($rangeValid) $imapFilter->andSearch($imapRangeFilter); |
| 2235 | 2235 | } |
| 2236 | 2236 | if (self::$debug) |
@@ -2239,8 +2239,8 @@ discard block |
||
| 2239 | 2239 | $query_str = $imapFilter->build(); |
| 2240 | 2240 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$query_str['query'].' created by Criterias:'.(!is_array($_criterias)?" none -> returning":array2string($_criterias))); |
| 2241 | 2241 | } |
| 2242 | - if($queryValid==false) { |
|
| 2243 | - $imapFilter->flag('DELETED', $set=false); |
|
| 2242 | + if ($queryValid == false) { |
|
| 2243 | + $imapFilter->flag('DELETED', $set = false); |
|
| 2244 | 2244 | return $imapFilter; |
| 2245 | 2245 | } else { |
| 2246 | 2246 | return $imapFilter; |
@@ -2254,11 +2254,11 @@ discard block |
||
| 2254 | 2254 | * @param mixed/boolean $_tryIDNConversion (true/false AND FORCE): try IDN Conversion on domainparts of emailADRESSES |
| 2255 | 2255 | * @return mixed - based on the input type |
| 2256 | 2256 | */ |
| 2257 | - static function decode_header($_string, $_tryIDNConversion=false) |
|
| 2257 | + static function decode_header($_string, $_tryIDNConversion = false) |
|
| 2258 | 2258 | { |
| 2259 | 2259 | if (is_array($_string)) |
| 2260 | 2260 | { |
| 2261 | - foreach($_string as $k=>$v) |
|
| 2261 | + foreach ($_string as $k=>$v) |
|
| 2262 | 2262 | { |
| 2263 | 2263 | $_string[$k] = self::decode_header($v, $_tryIDNConversion); |
| 2264 | 2264 | } |
@@ -2266,18 +2266,18 @@ discard block |
||
| 2266 | 2266 | } |
| 2267 | 2267 | else |
| 2268 | 2268 | { |
| 2269 | - $_string = Mail\Html::decodeMailHeader($_string,self::$displayCharset); |
|
| 2269 | + $_string = Mail\Html::decodeMailHeader($_string, self::$displayCharset); |
|
| 2270 | 2270 | $test = @json_encode($_string); |
| 2271 | 2271 | //error_log(__METHOD__.__LINE__.' ->'.strlen($singleBodyPart['body']).' Error:'.json_last_error().'<- BodyPart:#'.$test.'#'); |
| 2272 | - if (($test=="null" || $test === false || is_null($test)) && strlen($_string)>0) |
|
| 2272 | + if (($test == "null" || $test === false || is_null($test)) && strlen($_string) > 0) |
|
| 2273 | 2273 | { |
| 2274 | 2274 | // try to fix broken utf8 |
| 2275 | 2275 | $x = utf8_encode($_string); |
| 2276 | 2276 | $test = @json_encode($x); |
| 2277 | - if (($test=="null" || $test === false || is_null($test)) && strlen($_string)>0) |
|
| 2277 | + if (($test == "null" || $test === false || is_null($test)) && strlen($_string) > 0) |
|
| 2278 | 2278 | { |
| 2279 | 2279 | // this should not be needed, unless something fails with charset detection/ wrong charset passed |
| 2280 | - $_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)); |
|
| 2280 | + $_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)); |
|
| 2281 | 2281 | } |
| 2282 | 2282 | else |
| 2283 | 2283 | { |
@@ -2285,7 +2285,7 @@ discard block |
||
| 2285 | 2285 | } |
| 2286 | 2286 | } |
| 2287 | 2287 | |
| 2288 | - if ($_tryIDNConversion===true && stripos($_string,'@')!==false) |
|
| 2288 | + if ($_tryIDNConversion === true && stripos($_string, '@') !== false) |
|
| 2289 | 2289 | { |
| 2290 | 2290 | $rfcAddr = self::parseAddressList($_string); |
| 2291 | 2291 | $stringA = array(); |
@@ -2297,11 +2297,11 @@ discard block |
||
| 2297 | 2297 | $stringA = array(); |
| 2298 | 2298 | break; // skip idna conversion if we encounter an error here |
| 2299 | 2299 | } |
| 2300 | - $stringA[] = imap_rfc822_write_address($_rfcAddr->mailbox,Horde_Idna::decode($_rfcAddr->host),$_rfcAddr->personal); |
|
| 2300 | + $stringA[] = imap_rfc822_write_address($_rfcAddr->mailbox, Horde_Idna::decode($_rfcAddr->host), $_rfcAddr->personal); |
|
| 2301 | 2301 | } |
| 2302 | - if (!empty($stringA)) $_string = implode(',',$stringA); |
|
| 2302 | + if (!empty($stringA)) $_string = implode(',', $stringA); |
|
| 2303 | 2303 | } |
| 2304 | - if ($_tryIDNConversion==='FORCE') |
|
| 2304 | + if ($_tryIDNConversion === 'FORCE') |
|
| 2305 | 2305 | { |
| 2306 | 2306 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.$_string.'='.Horde_Idna::decode($_string)); |
| 2307 | 2307 | $_string = Horde_Idna::decode($_string); |
@@ -2317,17 +2317,17 @@ discard block |
||
| 2317 | 2317 | * @param boolean $decode try decoding |
| 2318 | 2318 | * @return mixed - based on the input type |
| 2319 | 2319 | */ |
| 2320 | - function decode_subject($_string,$decode=true) |
|
| 2320 | + function decode_subject($_string, $decode = true) |
|
| 2321 | 2321 | { |
| 2322 | 2322 | #$string = $_string; |
| 2323 | - if($_string=='NIL') |
|
| 2323 | + if ($_string == 'NIL') |
|
| 2324 | 2324 | { |
| 2325 | 2325 | return 'No Subject'; |
| 2326 | 2326 | } |
| 2327 | 2327 | if ($decode) $_string = self::decode_header($_string); |
| 2328 | 2328 | // make sure its utf-8 |
| 2329 | 2329 | $test = @json_encode($_string); |
| 2330 | - if (($test=="null" || $test === false || is_null($test)) && strlen($_string)>0) |
|
| 2330 | + if (($test == "null" || $test === false || is_null($test)) && strlen($_string) > 0) |
|
| 2331 | 2331 | { |
| 2332 | 2332 | $_string = utf8_encode($_string); |
| 2333 | 2333 | } |
@@ -2379,18 +2379,18 @@ discard block |
||
| 2379 | 2379 | function createFolder($_parent, $_folderName, &$_error) |
| 2380 | 2380 | { |
| 2381 | 2381 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."->"."$_parent, $_folderName called from:".function_backtrace()); |
| 2382 | - $parent = $_parent;//$this->_encodeFolderName($_parent); |
|
| 2383 | - $folderName = $_folderName;//$this->_encodeFolderName($_folderName); |
|
| 2382 | + $parent = $_parent; //$this->_encodeFolderName($_parent); |
|
| 2383 | + $folderName = $_folderName; //$this->_encodeFolderName($_folderName); |
|
| 2384 | 2384 | |
| 2385 | - if(empty($parent)) { |
|
| 2385 | + if (empty($parent)) { |
|
| 2386 | 2386 | $newFolderName = $folderName; |
| 2387 | 2387 | } else { |
| 2388 | 2388 | $HierarchyDelimiter = $this->getHierarchyDelimiter(); |
| 2389 | - $newFolderName = $parent . $HierarchyDelimiter . $folderName; |
|
| 2389 | + $newFolderName = $parent.$HierarchyDelimiter.$folderName; |
|
| 2390 | 2390 | } |
| 2391 | 2391 | if (empty($newFolderName)) return false; |
| 2392 | 2392 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.'->'.$newFolderName); |
| 2393 | - if ($this->folderExists($newFolderName,true)) |
|
| 2393 | + if ($this->folderExists($newFolderName, true)) |
|
| 2394 | 2394 | { |
| 2395 | 2395 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '." Folder $newFolderName already exists."); |
| 2396 | 2396 | return $newFolderName; |
@@ -2407,7 +2407,7 @@ discard block |
||
| 2407 | 2407 | } |
| 2408 | 2408 | catch (\Exception $e) |
| 2409 | 2409 | { |
| 2410 | - $_error = lang('Could not create Folder %1 Reason: %2',$newFolderName,$e->getMessage()); |
|
| 2410 | + $_error = lang('Could not create Folder %1 Reason: %2', $newFolderName, $e->getMessage()); |
|
| 2411 | 2411 | error_log(__METHOD__.' ('.__LINE__.') '.' create Folder '.$newFolderName.'->'.$e->getMessage().' ('.$e->details.') Namespace:'.array2string($this->icServer->getNameSpaces()).function_backtrace()); |
| 2412 | 2412 | return false; |
| 2413 | 2413 | } |
@@ -2436,15 +2436,15 @@ discard block |
||
| 2436 | 2436 | */ |
| 2437 | 2437 | function renameFolder($_oldFolderName, $_parent, $_folderName) |
| 2438 | 2438 | { |
| 2439 | - $oldFolderName = $_oldFolderName;//$this->_encodeFolderName($_oldFolderName); |
|
| 2440 | - $parent = $_parent;//$this->_encodeFolderName($_parent); |
|
| 2441 | - $folderName = $_folderName;//$this->_encodeFolderName($_folderName); |
|
| 2439 | + $oldFolderName = $_oldFolderName; //$this->_encodeFolderName($_oldFolderName); |
|
| 2440 | + $parent = $_parent; //$this->_encodeFolderName($_parent); |
|
| 2441 | + $folderName = $_folderName; //$this->_encodeFolderName($_folderName); |
|
| 2442 | 2442 | |
| 2443 | - if(empty($parent)) { |
|
| 2443 | + if (empty($parent)) { |
|
| 2444 | 2444 | $newFolderName = $folderName; |
| 2445 | 2445 | } else { |
| 2446 | 2446 | $HierarchyDelimiter = $this->getHierarchyDelimiter(); |
| 2447 | - $newFolderName = $parent . $HierarchyDelimiter . $folderName; |
|
| 2447 | + $newFolderName = $parent.$HierarchyDelimiter.$folderName; |
|
| 2448 | 2448 | } |
| 2449 | 2449 | if (self::$debug) error_log("create folder: $newFolderName"); |
| 2450 | 2450 | try |
@@ -2453,10 +2453,10 @@ discard block |
||
| 2453 | 2453 | } |
| 2454 | 2454 | catch (\Exception $e) |
| 2455 | 2455 | { |
| 2456 | - throw new Exception(__METHOD__." failed for $oldFolderName (rename to: $newFolderName) with error:".$e->getMessage());; |
|
| 2456 | + throw new Exception(__METHOD__." failed for $oldFolderName (rename to: $newFolderName) with error:".$e->getMessage()); ; |
|
| 2457 | 2457 | } |
| 2458 | 2458 | // clear FolderExistsInfoCache |
| 2459 | - Cache::setCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderInfo,60*60*5); |
|
| 2459 | + Cache::setCache(Cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']), $folderInfo, 60 * 60 * 5); |
|
| 2460 | 2460 | |
| 2461 | 2461 | return $newFolderName; |
| 2462 | 2462 | |
@@ -2475,15 +2475,15 @@ discard block |
||
| 2475 | 2475 | //$folderName = $this->_encodeFolderName($_folderName); |
| 2476 | 2476 | try |
| 2477 | 2477 | { |
| 2478 | - $this->icServer->subscribeMailbox($_folderName,false); |
|
| 2478 | + $this->icServer->subscribeMailbox($_folderName, false); |
|
| 2479 | 2479 | $this->icServer->deleteMailbox($_folderName); |
| 2480 | 2480 | } |
| 2481 | 2481 | catch (\Exception $e) |
| 2482 | 2482 | { |
| 2483 | - throw new Exception("Deleting Folder $_folderName failed! Error:".$e->getMessage());; |
|
| 2483 | + throw new Exception("Deleting Folder $_folderName failed! Error:".$e->getMessage()); ; |
|
| 2484 | 2484 | } |
| 2485 | 2485 | // clear FolderExistsInfoCache |
| 2486 | - Cache::setCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderInfo,60*60*5); |
|
| 2486 | + Cache::setCache(Cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']), $folderInfo, 60 * 60 * 5); |
|
| 2487 | 2487 | |
| 2488 | 2488 | return true; |
| 2489 | 2489 | } |
@@ -2518,10 +2518,10 @@ discard block |
||
| 2518 | 2518 | * |
| 2519 | 2519 | * @return array with folder objects. eg.: INBOX => {inbox object} |
| 2520 | 2520 | */ |
| 2521 | - function getFolderObjects($_subscribedOnly=false, $_getCounters=false, $_alwaysGetDefaultFolders=false,$_useCacheIfPossible=true) |
|
| 2521 | + function getFolderObjects($_subscribedOnly = false, $_getCounters = false, $_alwaysGetDefaultFolders = false, $_useCacheIfPossible = true) |
|
| 2522 | 2522 | { |
| 2523 | 2523 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' ServerID:'.$this->icServer->ImapServerId.", subscribedOnly:$_subscribedOnly, getCounters:$_getCounters, alwaysGetDefaultFolders:$_alwaysGetDefaultFolders, _useCacheIfPossible:$_useCacheIfPossible"); |
| 2524 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 2524 | + if (self::$debugTimes) $starttime = microtime(true); |
|
| 2525 | 2525 | static $folders2return; |
| 2526 | 2526 | //$_subscribedOnly=false; |
| 2527 | 2527 | // always use static on single request if info is available; |
@@ -2529,42 +2529,42 @@ discard block |
||
| 2529 | 2529 | // set $_useCacheIfPossible to false ! |
| 2530 | 2530 | if ($_useCacheIfPossible && isset($folders2return[$this->icServer->ImapServerId]) && !empty($folders2return[$this->icServer->ImapServerId])) |
| 2531 | 2531 | { |
| 2532 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'using static',__METHOD__.' ('.__LINE__.') '); |
|
| 2532 | + if (self::$debugTimes) self::logRunTimes($starttime, null, 'using static', __METHOD__.' ('.__LINE__.') '); |
|
| 2533 | 2533 | return $folders2return[$this->icServer->ImapServerId]; |
| 2534 | 2534 | } |
| 2535 | 2535 | |
| 2536 | - if ($_subscribedOnly && $_getCounters===false) |
|
| 2536 | + if ($_subscribedOnly && $_getCounters === false) |
|
| 2537 | 2537 | { |
| 2538 | - if (is_null($folders2return)) $folders2return = Cache::getCache(Cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 2538 | + if (is_null($folders2return)) $folders2return = Cache::getCache(Cache::INSTANCE, 'email', 'folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 1); |
|
| 2539 | 2539 | if ($_useCacheIfPossible && isset($folders2return[$this->icServer->ImapServerId]) && !empty($folders2return[$this->icServer->ImapServerId])) |
| 2540 | 2540 | { |
| 2541 | 2541 | //error_log(__METHOD__.' ('.__LINE__.') '.' using Cached folderObjects'.array2string($folders2return[$this->icServer->ImapServerId])); |
| 2542 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'from Cache',__METHOD__.' ('.__LINE__.') '); |
|
| 2542 | + if (self::$debugTimes) self::logRunTimes($starttime, null, 'from Cache', __METHOD__.' ('.__LINE__.') '); |
|
| 2543 | 2543 | return $folders2return[$this->icServer->ImapServerId]; |
| 2544 | 2544 | } |
| 2545 | 2545 | } |
| 2546 | 2546 | // use $folderBasicInfo for holding attributes and other basic folderinfo $folderBasicInfo[$this->icServer->ImapServerId] |
| 2547 | 2547 | static $folderBasicInfo; |
| 2548 | - 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); |
|
| 2548 | + 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); |
|
| 2549 | 2549 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string(array_keys($folderBasicInfo[$this->icServer->ImapServerId]))); |
| 2550 | 2550 | |
| 2551 | 2551 | $delimiter = $this->getHierarchyDelimiter(); |
| 2552 | 2552 | |
| 2553 | 2553 | $inboxData = new \stdClass; |
| 2554 | - $inboxData->name = 'INBOX'; |
|
| 2554 | + $inboxData->name = 'INBOX'; |
|
| 2555 | 2555 | $inboxData->folderName = 'INBOX'; |
| 2556 | - $inboxData->displayName = lang('INBOX'); |
|
| 2556 | + $inboxData->displayName = lang('INBOX'); |
|
| 2557 | 2557 | $inboxData->delimiter = $delimiter; |
| 2558 | - $inboxData->shortFolderName = 'INBOX'; |
|
| 2559 | - $inboxData->shortDisplayName = lang('INBOX'); |
|
| 2558 | + $inboxData->shortFolderName = 'INBOX'; |
|
| 2559 | + $inboxData->shortDisplayName = lang('INBOX'); |
|
| 2560 | 2560 | $inboxData->subscribed = true; |
| 2561 | - if($_getCounters == true) { |
|
| 2561 | + if ($_getCounters == true) { |
|
| 2562 | 2562 | $inboxData->counter = $this->getMailBoxCounters('INBOX'); |
| 2563 | 2563 | } |
| 2564 | 2564 | // force unsubscribed by preference showAllFoldersInFolderPane |
| 2565 | 2565 | if ($_subscribedOnly == true && |
| 2566 | 2566 | isset($this->mailPreferences['showAllFoldersInFolderPane']) && |
| 2567 | - $this->mailPreferences['showAllFoldersInFolderPane']==1) |
|
| 2567 | + $this->mailPreferences['showAllFoldersInFolderPane'] == 1) |
|
| 2568 | 2568 | { |
| 2569 | 2569 | $_subscribedOnly = false; |
| 2570 | 2570 | } |
@@ -2577,12 +2577,12 @@ discard block |
||
| 2577 | 2577 | //error_log(__METHOD__.__LINE__.array2string($nameSpace)); |
| 2578 | 2578 | if (is_array($nameSpace)) |
| 2579 | 2579 | { |
| 2580 | - foreach($nameSpace as $k => $singleNameSpace) { |
|
| 2580 | + foreach ($nameSpace as $k => $singleNameSpace) { |
|
| 2581 | 2581 | $type = $singleNameSpace['type']; |
| 2582 | 2582 | // the following line (assumption that for the same namespace the delimiter should be equal) may be wrong |
| 2583 | - $foldersNameSpace[$type]['delimiter'] = $singleNameSpace['delimiter']; |
|
| 2583 | + $foldersNameSpace[$type]['delimiter'] = $singleNameSpace['delimiter']; |
|
| 2584 | 2584 | |
| 2585 | - if(is_array($singleNameSpace)&&$fetchedAllInOneGo==false) { |
|
| 2585 | + if (is_array($singleNameSpace) && $fetchedAllInOneGo == false) { |
|
| 2586 | 2586 | // fetch and sort the subscribed folders |
| 2587 | 2587 | // we alway fetch the subscribed, as this provides the only way to tell |
| 2588 | 2588 | // if a folder is subscribed or not |
@@ -2590,22 +2590,22 @@ discard block |
||
| 2590 | 2590 | { |
| 2591 | 2591 | try |
| 2592 | 2592 | { |
| 2593 | - $subscribedMailboxes = $this->icServer->listSubscribedMailboxes('',0,true); |
|
| 2593 | + $subscribedMailboxes = $this->icServer->listSubscribedMailboxes('', 0, true); |
|
| 2594 | 2594 | if (!empty($subscribedMailboxes)) |
| 2595 | 2595 | { |
| 2596 | 2596 | $fetchedAllInOneGo = true; |
| 2597 | 2597 | } |
| 2598 | 2598 | else |
| 2599 | 2599 | { |
| 2600 | - $subscribedMailboxes = $this->icServer->listSubscribedMailboxes($singleNameSpace['prefix'],0,true); |
|
| 2600 | + $subscribedMailboxes = $this->icServer->listSubscribedMailboxes($singleNameSpace['prefix'], 0, true); |
|
| 2601 | 2601 | } |
| 2602 | 2602 | } |
| 2603 | - catch(Exception $e) |
|
| 2603 | + catch (Exception $e) |
|
| 2604 | 2604 | { |
| 2605 | 2605 | continue; |
| 2606 | 2606 | } |
| 2607 | 2607 | //echo "subscribedMailboxes";_debug_array($subscribedMailboxes); |
| 2608 | - $subscribedFoldersPerNS = (!empty($subscribedMailboxes)?array_keys($subscribedMailboxes):array()); |
|
| 2608 | + $subscribedFoldersPerNS = (!empty($subscribedMailboxes) ? array_keys($subscribedMailboxes) : array()); |
|
| 2609 | 2609 | //if (is_array($foldersNameSpace[$type]['subscribed'])) sort($foldersNameSpace[$type]['subscribed']); |
| 2610 | 2610 | //_debug_array($foldersNameSpace); |
| 2611 | 2611 | //error_log(__METHOD__.__LINE__.array2string($singleNameSpace).':#:'.array2string($subscribedFoldersPerNS)); |
@@ -2615,18 +2615,18 @@ discard block |
||
| 2615 | 2615 | foreach ($subscribedMailboxes as $k => $finfo) |
| 2616 | 2616 | { |
| 2617 | 2617 | //error_log(__METHOD__.__LINE__.$k.':#:'.array2string($finfo)); |
| 2618 | - $subscribedFoldersForCache[$this->icServer->ImapServerId][$k]= |
|
| 2619 | - $folderBasicInfo[$this->icServer->ImapServerId][$k]=array( |
|
| 2618 | + $subscribedFoldersForCache[$this->icServer->ImapServerId][$k] = |
|
| 2619 | + $folderBasicInfo[$this->icServer->ImapServerId][$k] = array( |
|
| 2620 | 2620 | 'MAILBOX'=>$finfo['MAILBOX'], |
| 2621 | 2621 | 'ATTRIBUTES'=>$finfo['ATTRIBUTES'], |
| 2622 | - 'delimiter'=>$finfo['delimiter'],//lowercase for some reason??? |
|
| 2623 | - 'SUBSCRIBED'=>$finfo['SUBSCRIBED'],//seeded by getMailboxes |
|
| 2622 | + 'delimiter'=>$finfo['delimiter'], //lowercase for some reason??? |
|
| 2623 | + 'SUBSCRIBED'=>$finfo['SUBSCRIBED'], //seeded by getMailboxes |
|
| 2624 | 2624 | ); |
| 2625 | - if (empty($foldersNameSpace[$type]['subscribed']) || !in_array($k,$foldersNameSpace[$type]['subscribed'])) |
|
| 2625 | + if (empty($foldersNameSpace[$type]['subscribed']) || !in_array($k, $foldersNameSpace[$type]['subscribed'])) |
|
| 2626 | 2626 | { |
| 2627 | 2627 | $foldersNameSpace[$type]['subscribed'][] = $k; |
| 2628 | 2628 | } |
| 2629 | - if (empty($foldersNameSpace[$type]['all']) || !in_array($k,$foldersNameSpace[$type]['all'])) |
|
| 2629 | + if (empty($foldersNameSpace[$type]['all']) || !in_array($k, $foldersNameSpace[$type]['all'])) |
|
| 2630 | 2630 | { |
| 2631 | 2631 | $foldersNameSpace[$type]['all'][] = $k; |
| 2632 | 2632 | } |
@@ -2649,7 +2649,7 @@ discard block |
||
| 2649 | 2649 | // that may produce problems, when encountering recursions probably |
| 2650 | 2650 | // horde is handling that, so we do not; keep that in mind! |
| 2651 | 2651 | //$allMailboxesExt = $this->icServer->getMailboxes($singleNameSpace['prefix'],2,true); |
| 2652 | - $allMailboxesExt = $this->icServer->getMailboxes($singleNameSpace['prefix'],0,true); |
|
| 2652 | + $allMailboxesExt = $this->icServer->getMailboxes($singleNameSpace['prefix'], 0, true); |
|
| 2653 | 2653 | } |
| 2654 | 2654 | catch (\Exception $e) |
| 2655 | 2655 | { |
@@ -2667,26 +2667,26 @@ discard block |
||
| 2667 | 2667 | foreach ($allMailboxesExt as $mbx) { |
| 2668 | 2668 | if (!isset($folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']])) |
| 2669 | 2669 | { |
| 2670 | - $folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']]=array( |
|
| 2670 | + $folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']] = array( |
|
| 2671 | 2671 | 'MAILBOX'=>$mbx['MAILBOX'], |
| 2672 | 2672 | 'ATTRIBUTES'=>$mbx['ATTRIBUTES'], |
| 2673 | - 'delimiter'=>$mbx['delimiter'],//lowercase for some reason??? |
|
| 2674 | - 'SUBSCRIBED'=>$mbx['SUBSCRIBED'],//seeded by getMailboxes |
|
| 2673 | + 'delimiter'=>$mbx['delimiter'], //lowercase for some reason??? |
|
| 2674 | + 'SUBSCRIBED'=>$mbx['SUBSCRIBED'], //seeded by getMailboxes |
|
| 2675 | 2675 | ); |
| 2676 | 2676 | if ($mbx['SUBSCRIBED'] && !isset($subscribedFoldersForCache[$this->icServer->ImapServerId][$mbx['MAILBOX']])) |
| 2677 | 2677 | { |
| 2678 | 2678 | $subscribedFoldersForCache[$this->icServer->ImapServerId][$mbx['MAILBOX']] = $folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']]; |
| 2679 | 2679 | } |
| 2680 | 2680 | } |
| 2681 | - if ($mbx['SUBSCRIBED'] && (empty($foldersNameSpace[$type]['subscribed']) || !in_array($mbx['MAILBOX'],$foldersNameSpace[$type]['subscribed']))) |
|
| 2681 | + if ($mbx['SUBSCRIBED'] && (empty($foldersNameSpace[$type]['subscribed']) || !in_array($mbx['MAILBOX'], $foldersNameSpace[$type]['subscribed']))) |
|
| 2682 | 2682 | { |
| 2683 | 2683 | $foldersNameSpace[$type]['subscribed'][] = $mbx['MAILBOX']; |
| 2684 | 2684 | } |
| 2685 | 2685 | //echo __METHOD__;_debug_array($mbx); |
| 2686 | 2686 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mbx)); |
| 2687 | - if (isset($allMailBoxesExtSorted[$mbx['MAILBOX']])|| |
|
| 2688 | - isset($allMailBoxesExtSorted[$mbx['MAILBOX'].$foldersNameSpace[$type]['delimiter']])|| |
|
| 2689 | - (substr($mbx['MAILBOX'],-1)==$foldersNameSpace[$type]['delimiter'] && isset($allMailBoxesExtSorted[substr($mbx['MAILBOX'],0,-1)])) |
|
| 2687 | + if (isset($allMailBoxesExtSorted[$mbx['MAILBOX']]) || |
|
| 2688 | + isset($allMailBoxesExtSorted[$mbx['MAILBOX'].$foldersNameSpace[$type]['delimiter']]) || |
|
| 2689 | + (substr($mbx['MAILBOX'], -1) == $foldersNameSpace[$type]['delimiter'] && isset($allMailBoxesExtSorted[substr($mbx['MAILBOX'], 0, -1)])) |
|
| 2690 | 2690 | ) continue; |
| 2691 | 2691 | |
| 2692 | 2692 | //echo '#'.$mbx['MAILBOX'].':'.array2string($mbx)."#<br>"; |
@@ -2696,7 +2696,7 @@ discard block |
||
| 2696 | 2696 | //_debug_array(array_keys($allMailBoxesExtSorted)); |
| 2697 | 2697 | $allMailboxes = array(); |
| 2698 | 2698 | foreach ((array)$allMailBoxesExtSorted as $mbx) { |
| 2699 | - if (!in_array($mbx['MAILBOX'],$allMailboxes)) $allMailboxes[] = $mbx['MAILBOX']; |
|
| 2699 | + if (!in_array($mbx['MAILBOX'], $allMailboxes)) $allMailboxes[] = $mbx['MAILBOX']; |
|
| 2700 | 2700 | //echo "Result:";_debug_array($allMailboxes); |
| 2701 | 2701 | } |
| 2702 | 2702 | $foldersNameSpace[$type]['all'] = $allMailboxes; |
@@ -2705,57 +2705,57 @@ discard block |
||
| 2705 | 2705 | } |
| 2706 | 2706 | } |
| 2707 | 2707 | //subscribed folders may be used in getFolderStatus |
| 2708 | - Cache::setCache(Cache::INSTANCE,'email','subscribedFolders'.trim($GLOBALS['egw_info']['user']['account_id']),$subscribedFoldersForCache,$expiration=60*60*1); |
|
| 2708 | + Cache::setCache(Cache::INSTANCE, 'email', 'subscribedFolders'.trim($GLOBALS['egw_info']['user']['account_id']), $subscribedFoldersForCache, $expiration = 60 * 60 * 1); |
|
| 2709 | 2709 | //echo "<br>FolderNameSpace To Process:";_debug_array($foldersNameSpace); |
| 2710 | 2710 | $autoFolderObjects = $folders = array(); |
| 2711 | 2711 | $autofolder_exists = array(); |
| 2712 | - foreach( array('personal', 'others', 'shared') as $type) { |
|
| 2713 | - if(isset($foldersNameSpace[$type])) { |
|
| 2714 | - if($_subscribedOnly) { |
|
| 2715 | - if( !empty($foldersNameSpace[$type]['subscribed']) ) $listOfFolders = $foldersNameSpace[$type]['subscribed']; |
|
| 2712 | + foreach (array('personal', 'others', 'shared') as $type) { |
|
| 2713 | + if (isset($foldersNameSpace[$type])) { |
|
| 2714 | + if ($_subscribedOnly) { |
|
| 2715 | + if (!empty($foldersNameSpace[$type]['subscribed'])) $listOfFolders = $foldersNameSpace[$type]['subscribed']; |
|
| 2716 | 2716 | } else { |
| 2717 | - if( !empty($foldersNameSpace[$type]['all'])) $listOfFolders = $foldersNameSpace[$type]['all']; |
|
| 2717 | + if (!empty($foldersNameSpace[$type]['all'])) $listOfFolders = $foldersNameSpace[$type]['all']; |
|
| 2718 | 2718 | } |
| 2719 | - foreach((array)$listOfFolders as $folderName) { |
|
| 2719 | + foreach ((array)$listOfFolders as $folderName) { |
|
| 2720 | 2720 | //echo "<br>FolderToCheck:$folderName<br>"; |
| 2721 | 2721 | //error_log(__METHOD__.__LINE__.'#Delimiter:'.$delimiter.':#'.$folderName); |
| 2722 | - if ($_subscribedOnly && empty($foldersNameSpace[$type]['all'])) continue;//when subscribedonly, we fetch all folders in one go. |
|
| 2723 | - if($_subscribedOnly && !(in_array($folderName, $foldersNameSpace[$type]['all'])||in_array($folderName.$foldersNameSpace[$type]['delimiter'], $foldersNameSpace[$type]['all']))) { |
|
| 2722 | + if ($_subscribedOnly && empty($foldersNameSpace[$type]['all'])) continue; //when subscribedonly, we fetch all folders in one go. |
|
| 2723 | + if ($_subscribedOnly && !(in_array($folderName, $foldersNameSpace[$type]['all']) || in_array($folderName.$foldersNameSpace[$type]['delimiter'], $foldersNameSpace[$type]['all']))) { |
|
| 2724 | 2724 | #echo "$folderName failed to be here <br>"; |
| 2725 | 2725 | continue; |
| 2726 | 2726 | } |
| 2727 | 2727 | if (isset($folders[$folderName])) continue; |
| 2728 | 2728 | if (isset($autoFolderObjects[$folderName])) continue; |
| 2729 | - if (empty($delimiter)||$delimiter != $foldersNameSpace[$type]['delimiter']) $delimiter = $foldersNameSpace[$type]['delimiter']; |
|
| 2729 | + if (empty($delimiter) || $delimiter != $foldersNameSpace[$type]['delimiter']) $delimiter = $foldersNameSpace[$type]['delimiter']; |
|
| 2730 | 2730 | $folderParts = explode($delimiter, $folderName); |
| 2731 | 2731 | $shortName = array_pop($folderParts); |
| 2732 | 2732 | |
| 2733 | 2733 | $folderObject = new \stdClass; |
| 2734 | - $folderObject->delimiter = $delimiter; |
|
| 2735 | - $folderObject->folderName = $folderName; |
|
| 2736 | - $folderObject->shortFolderName = $shortName; |
|
| 2737 | - if(!$_subscribedOnly) { |
|
| 2734 | + $folderObject->delimiter = $delimiter; |
|
| 2735 | + $folderObject->folderName = $folderName; |
|
| 2736 | + $folderObject->shortFolderName = $shortName; |
|
| 2737 | + if (!$_subscribedOnly) { |
|
| 2738 | 2738 | #echo $folderName."->".$type."<br>"; |
| 2739 | 2739 | #_debug_array($foldersNameSpace[$type]['subscribed']); |
| 2740 | 2740 | $folderObject->subscribed = in_array($folderName, (array)$foldersNameSpace[$type]['subscribed']); |
| 2741 | 2741 | } |
| 2742 | 2742 | |
| 2743 | - if($_getCounters == true) { |
|
| 2743 | + if ($_getCounters == true) { |
|
| 2744 | 2744 | //error_log(__METHOD__.' ('.__LINE__.') '.' getCounter forFolder:'.$folderName); |
| 2745 | 2745 | $folderObject->counter = $this->getMailBoxCounters($folderName); |
| 2746 | 2746 | } |
| 2747 | - if(strtoupper($folderName) == 'INBOX') { |
|
| 2747 | + if (strtoupper($folderName) == 'INBOX') { |
|
| 2748 | 2748 | $folderName = 'INBOX'; |
| 2749 | - $folderObject->folderName = 'INBOX'; |
|
| 2750 | - $folderObject->shortFolderName = 'INBOX'; |
|
| 2751 | - $folderObject->displayName = lang('INBOX'); |
|
| 2749 | + $folderObject->folderName = 'INBOX'; |
|
| 2750 | + $folderObject->shortFolderName = 'INBOX'; |
|
| 2751 | + $folderObject->displayName = lang('INBOX'); |
|
| 2752 | 2752 | $folderObject->shortDisplayName = lang('INBOX'); |
| 2753 | - $folderObject->subscribed = true; |
|
| 2753 | + $folderObject->subscribed = true; |
|
| 2754 | 2754 | // translate the automatic Folders (Sent, Drafts, ...) like the INBOX |
| 2755 | - } elseif (in_array($shortName,self::$autoFolders)) { |
|
| 2756 | - $tmpfolderparts = explode($delimiter,$folderObject->folderName); |
|
| 2755 | + } elseif (in_array($shortName, self::$autoFolders)) { |
|
| 2756 | + $tmpfolderparts = explode($delimiter, $folderObject->folderName); |
|
| 2757 | 2757 | array_pop($tmpfolderparts); |
| 2758 | - $folderObject->displayName = implode($delimiter,$tmpfolderparts).$delimiter.lang($shortName); |
|
| 2758 | + $folderObject->displayName = implode($delimiter, $tmpfolderparts).$delimiter.lang($shortName); |
|
| 2759 | 2759 | $folderObject->shortDisplayName = lang($shortName); |
| 2760 | 2760 | unset($tmpfolderparts); |
| 2761 | 2761 | } else { |
@@ -2763,13 +2763,13 @@ discard block |
||
| 2763 | 2763 | $folderObject->shortDisplayName = $shortName; |
| 2764 | 2764 | } |
| 2765 | 2765 | //$folderName = $folderName; |
| 2766 | - if (in_array($shortName,self::$autoFolders)&&self::searchValueInFolderObjects($shortName,$autoFolderObjects)===false) { |
|
| 2766 | + if (in_array($shortName, self::$autoFolders) && self::searchValueInFolderObjects($shortName, $autoFolderObjects) === false) { |
|
| 2767 | 2767 | $autoFolderObjects[$folderName] = $folderObject; |
| 2768 | 2768 | } else { |
| 2769 | 2769 | $folders[$folderName] = $folderObject; |
| 2770 | 2770 | } |
| 2771 | 2771 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$folderObject->folderName); |
| 2772 | - if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders (); |
|
| 2772 | + if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders(); |
|
| 2773 | 2773 | if (isset(self::$specialUseFolders[$folderName])) |
| 2774 | 2774 | { |
| 2775 | 2775 | $autofolder_exists[$folderName] = self::$specialUseFolders[$folderName]; |
@@ -2778,27 +2778,27 @@ discard block |
||
| 2778 | 2778 | } |
| 2779 | 2779 | } |
| 2780 | 2780 | if (is_array($autoFolderObjects) && !empty($autoFolderObjects)) { |
| 2781 | - uasort($autoFolderObjects,array($this,"sortByAutoFolderPos")); |
|
| 2781 | + uasort($autoFolderObjects, array($this, "sortByAutoFolderPos")); |
|
| 2782 | 2782 | } |
| 2783 | 2783 | // check if some standard folders are missing and need to be created |
| 2784 | 2784 | if (count($autofolder_exists) < count(self::$autoFolders) && $this->check_create_autofolders($autofolder_exists)) |
| 2785 | 2785 | { |
| 2786 | 2786 | // if new folders have been created, re-read folders ignoring the cache |
| 2787 | - return $this->getFolderObjects($_subscribedOnly, $_getCounters, $_alwaysGetDefaultFolders, false); // false = do NOT use cache |
|
| 2787 | + return $this->getFolderObjects($_subscribedOnly, $_getCounters, $_alwaysGetDefaultFolders, false); // false = do NOT use cache |
|
| 2788 | 2788 | } |
| 2789 | - if (is_array($folders)) uasort($folders,array($this,"sortByDisplayName")); |
|
| 2789 | + if (is_array($folders)) uasort($folders, array($this, "sortByDisplayName")); |
|
| 2790 | 2790 | //$folders2return = array_merge($autoFolderObjects,$folders); |
| 2791 | 2791 | //_debug_array($folders2return); #exit; |
| 2792 | - $folders2return[$this->icServer->ImapServerId] = array_merge((array)$inboxFolderObject,(array)$autoFolderObjects,(array)$folders); |
|
| 2793 | - if (($_subscribedOnly && $_getCounters===false) || |
|
| 2794 | - ($_subscribedOnly == false && $_getCounters===false && |
|
| 2792 | + $folders2return[$this->icServer->ImapServerId] = array_merge((array)$inboxFolderObject, (array)$autoFolderObjects, (array)$folders); |
|
| 2793 | + if (($_subscribedOnly && $_getCounters === false) || |
|
| 2794 | + ($_subscribedOnly == false && $_getCounters === false && |
|
| 2795 | 2795 | isset($this->mailPreferences['showAllFoldersInFolderPane']) && |
| 2796 | - $this->mailPreferences['showAllFoldersInFolderPane']==1)) |
|
| 2796 | + $this->mailPreferences['showAllFoldersInFolderPane'] == 1)) |
|
| 2797 | 2797 | { |
| 2798 | - Cache::setCache(Cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),$folders2return,$expiration=60*60*1); |
|
| 2798 | + Cache::setCache(Cache::INSTANCE, 'email', 'folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']), $folders2return, $expiration = 60 * 60 * 1); |
|
| 2799 | 2799 | } |
| 2800 | - Cache::setCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderBasicInfo,$expiration=60*60*1); |
|
| 2801 | - if (self::$debugTimes) self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') '); |
|
| 2800 | + Cache::setCache(Cache::INSTANCE, 'email', 'folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']), $folderBasicInfo, $expiration = 60 * 60 * 1); |
|
| 2801 | + if (self::$debugTimes) self::logRunTimes($starttime, null, function_backtrace(), __METHOD__.' ('.__LINE__.') '); |
|
| 2802 | 2802 | return $folders2return[$this->icServer->ImapServerId]; |
| 2803 | 2803 | } |
| 2804 | 2804 | |
@@ -2819,21 +2819,21 @@ discard block |
||
| 2819 | 2819 | * |
| 2820 | 2820 | * @return array arrays of folders |
| 2821 | 2821 | */ |
| 2822 | - function getFolderArrays ($_nodePath = null, $_onlyTopLevel = false, $_search= 2, $_subscribedOnly = false, $_getCounter = false) |
|
| 2822 | + function getFolderArrays($_nodePath = null, $_onlyTopLevel = false, $_search = 2, $_subscribedOnly = false, $_getCounter = false) |
|
| 2823 | 2823 | { |
| 2824 | 2824 | // delimiter |
| 2825 | 2825 | $delimiter = $this->getHierarchyDelimiter(); |
| 2826 | 2826 | |
| 2827 | - $folders = $nameSpace = array(); |
|
| 2827 | + $folders = $nameSpace = array(); |
|
| 2828 | 2828 | $nameSpaceTmp = $this->_getNameSpaces(); |
| 2829 | - foreach($nameSpaceTmp as $k => $singleNameSpace) { |
|
| 2830 | - $nameSpace[$singleNameSpace['type']]=$singleNameSpace; |
|
| 2829 | + foreach ($nameSpaceTmp as $k => $singleNameSpace) { |
|
| 2830 | + $nameSpace[$singleNameSpace['type']] = $singleNameSpace; |
|
| 2831 | 2831 | } |
| 2832 | 2832 | unset($nameSpaceTmp); |
| 2833 | 2833 | |
| 2834 | 2834 | //error_log(__METHOD__.__LINE__.array2string($nameSpace)); |
| 2835 | 2835 | // Get special use folders |
| 2836 | - if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders (); // Set self::$specialUseFolders |
|
| 2836 | + if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders(); // Set self::$specialUseFolders |
|
| 2837 | 2837 | // topLevelQueries generally ignore the $_search param. Except for Config::examineNamespace |
| 2838 | 2838 | if ($_onlyTopLevel) // top level leaves |
| 2839 | 2839 | { |
@@ -2844,20 +2844,20 @@ discard block |
||
| 2844 | 2844 | if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail'); |
| 2845 | 2845 | if (self::$mailConfig['examineNamespace']) |
| 2846 | 2846 | { |
| 2847 | - $prefixes=array(); |
|
| 2847 | + $prefixes = array(); |
|
| 2848 | 2848 | if (is_array($nameSpace)) |
| 2849 | 2849 | { |
| 2850 | - foreach($nameSpace as $k => $singleNameSpace) { |
|
| 2850 | + foreach ($nameSpace as $k => $singleNameSpace) { |
|
| 2851 | 2851 | $type = $singleNameSpace['type']; |
| 2852 | 2852 | |
| 2853 | - if(is_array($singleNameSpace) && $singleNameSpace['prefix']){ |
|
| 2853 | + if (is_array($singleNameSpace) && $singleNameSpace['prefix']) { |
|
| 2854 | 2854 | $prefixes[$type] = $singleNameSpace['prefix']; |
| 2855 | 2855 | //regard extra care for nameSpacequeries when configured AND respect $_search |
| 2856 | - $result = $this->icServer->getMailboxes($singleNameSpace['prefix'], $_search==0?0:2, true); |
|
| 2856 | + $result = $this->icServer->getMailboxes($singleNameSpace['prefix'], $_search == 0 ? 0 : 2, true); |
|
| 2857 | 2857 | if (is_array($result)) |
| 2858 | 2858 | { |
| 2859 | 2859 | ksort($result); |
| 2860 | - $topFolders = array_merge($topFolders,$result); |
|
| 2860 | + $topFolders = array_merge($topFolders, $result); |
|
| 2861 | 2861 | } |
| 2862 | 2862 | } |
| 2863 | 2863 | } |
@@ -2866,7 +2866,7 @@ discard block |
||
| 2866 | 2866 | |
| 2867 | 2867 | $autofolders = array(); |
| 2868 | 2868 | |
| 2869 | - foreach(self::$specialUseFolders as $path => $folder) |
|
| 2869 | + foreach (self::$specialUseFolders as $path => $folder) |
|
| 2870 | 2870 | { |
| 2871 | 2871 | if ($this->folderExists($path)) |
| 2872 | 2872 | { |
@@ -2874,9 +2874,9 @@ discard block |
||
| 2874 | 2874 | } |
| 2875 | 2875 | } |
| 2876 | 2876 | // Check if the special use folders are there, otherwise try to create them |
| 2877 | - if (count($autofolders) < count(self::$autoFolders) && $this->check_create_autofolders ($autofolders)) |
|
| 2877 | + if (count($autofolders) < count(self::$autoFolders) && $this->check_create_autofolders($autofolders)) |
|
| 2878 | 2878 | { |
| 2879 | - return $this->getFolderArrays ($_nodePath, $_onlyTopLevel, $_search, $_subscribedOnly, $_getCounter); |
|
| 2879 | + return $this->getFolderArrays($_nodePath, $_onlyTopLevel, $_search, $_subscribedOnly, $_getCounter); |
|
| 2880 | 2880 | } |
| 2881 | 2881 | |
| 2882 | 2882 | // now process topFolders for next level |
@@ -2884,13 +2884,13 @@ discard block |
||
| 2884 | 2884 | { |
| 2885 | 2885 | $pattern = "/\\".$delimiter."/"; |
| 2886 | 2886 | $reference = preg_replace($pattern, '', $node['MAILBOX']); |
| 2887 | - if(!empty($prefixes)) |
|
| 2887 | + if (!empty($prefixes)) |
|
| 2888 | 2888 | { |
| 2889 | 2889 | $reference = ''; |
| 2890 | - $tmpArray = explode($delimiter,$node['MAILBOX']); |
|
| 2891 | - foreach($tmpArray as $p) |
|
| 2890 | + $tmpArray = explode($delimiter, $node['MAILBOX']); |
|
| 2891 | + foreach ($tmpArray as $p) |
|
| 2892 | 2892 | { |
| 2893 | - $reference = empty($reference)?$p:$reference.$delimiter.$p; |
|
| 2893 | + $reference = empty($reference) ? $p : $reference.$delimiter.$p; |
|
| 2894 | 2894 | } |
| 2895 | 2895 | } |
| 2896 | 2896 | $mainFolder = $subFolders = array(); |
@@ -2926,19 +2926,19 @@ discard block |
||
| 2926 | 2926 | $nFolders [$path] = $folder; |
| 2927 | 2927 | } |
| 2928 | 2928 | } |
| 2929 | - if (is_array($aFolders)) uasort ($aFolders, array($this,'sortByAutofolder')); |
|
| 2929 | + if (is_array($aFolders)) uasort($aFolders, array($this, 'sortByAutofolder')); |
|
| 2930 | 2930 | //ksort($aFolders); |
| 2931 | 2931 | |
| 2932 | 2932 | // Sort none auto folders base on mailbox name |
| 2933 | - uasort($nFolders,array($this,'sortByMailbox')); |
|
| 2933 | + uasort($nFolders, array($this, 'sortByMailbox')); |
|
| 2934 | 2934 | |
| 2935 | - $subFolders = array_merge($aFolders,$nFolders); |
|
| 2935 | + $subFolders = array_merge($aFolders, $nFolders); |
|
| 2936 | 2936 | } |
| 2937 | 2937 | else |
| 2938 | 2938 | { |
| 2939 | 2939 | if (is_array($subFolders)) ksort($subFolders); |
| 2940 | 2940 | } |
| 2941 | - $folders = array_merge($folders,(array)$mainFolder, (array)$subFolders); |
|
| 2941 | + $folders = array_merge($folders, (array)$mainFolder, (array)$subFolders); |
|
| 2942 | 2942 | } |
| 2943 | 2943 | } |
| 2944 | 2944 | elseif ($_nodePath) // single node |
@@ -2965,9 +2965,9 @@ discard block |
||
| 2965 | 2965 | $folders = $this->icServer->getMailboxes($path, $_search, true); |
| 2966 | 2966 | } |
| 2967 | 2967 | |
| 2968 | - uasort($folders,array($this,'sortByMailbox'));//ksort($folders); |
|
| 2968 | + uasort($folders, array($this, 'sortByMailbox')); //ksort($folders); |
|
| 2969 | 2969 | } |
| 2970 | - elseif(!$_nodePath) // all |
|
| 2970 | + elseif (!$_nodePath) // all |
|
| 2971 | 2971 | { |
| 2972 | 2972 | if ($_subscribedOnly) |
| 2973 | 2973 | { |
@@ -2983,101 +2983,101 @@ discard block |
||
| 2983 | 2983 | { |
| 2984 | 2984 | // SORTING FOLDERS |
| 2985 | 2985 | //self::$debugTimes=true; |
| 2986 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 2986 | + if (self::$debugTimes) $starttime = microtime(true); |
|
| 2987 | 2987 | // Merge of all auto folders and specialusefolders |
| 2988 | 2988 | $autoFoldersTmp = array_unique((array_merge(self::$autoFolders, array_values(self::$specialUseFolders)))); |
| 2989 | - uasort($folders,array($this,'sortByMailbox'));//ksort($folders); |
|
| 2989 | + uasort($folders, array($this, 'sortByMailbox')); //ksort($folders); |
|
| 2990 | 2990 | $tmpFolders = $folders; |
| 2991 | - $inboxFolderObject=$inboxSubFolderObjects=$autoFolderObjects=$typeFolderObject=$mySpecialUseFolders=array(); |
|
| 2992 | - $googleMailFolderObject=$googleAutoFolderObjects=$googleSubFolderObjects=array(); |
|
| 2993 | - $isGoogleMail=false; |
|
| 2994 | - foreach($autoFoldersTmp as $afk=>$aF) |
|
| 2991 | + $inboxFolderObject = $inboxSubFolderObjects = $autoFolderObjects = $typeFolderObject = $mySpecialUseFolders = array(); |
|
| 2992 | + $googleMailFolderObject = $googleAutoFolderObjects = $googleSubFolderObjects = array(); |
|
| 2993 | + $isGoogleMail = false; |
|
| 2994 | + foreach ($autoFoldersTmp as $afk=>$aF) |
|
| 2995 | 2995 | { |
| 2996 | - if (!isset($mySpecialUseFolders[$aF]) && $aF) $mySpecialUseFolders[$aF]=$this->getFolderByType($aF,false); |
|
| 2996 | + if (!isset($mySpecialUseFolders[$aF]) && $aF) $mySpecialUseFolders[$aF] = $this->getFolderByType($aF, false); |
|
| 2997 | 2997 | //error_log($afk.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 2998 | 2998 | } |
| 2999 | 2999 | //error_log(array2string($mySpecialUseFolders)); |
| 3000 | 3000 | foreach ($tmpFolders as $k => $f) { |
| 3001 | - $sorted=false; |
|
| 3002 | - if (strtoupper(substr($k,0,5))=='INBOX') { |
|
| 3003 | - if (strtoupper($k)=='INBOX') { |
|
| 3001 | + $sorted = false; |
|
| 3002 | + if (strtoupper(substr($k, 0, 5)) == 'INBOX') { |
|
| 3003 | + if (strtoupper($k) == 'INBOX') { |
|
| 3004 | 3004 | //error_log(__METHOD__.__LINE__.':'.strtoupper(substr($k,0,5)).':'.$k); |
| 3005 | - $inboxFolderObject[$k]=$f; |
|
| 3005 | + $inboxFolderObject[$k] = $f; |
|
| 3006 | 3006 | unset($folders[$k]); |
| 3007 | - $sorted=true; |
|
| 3007 | + $sorted = true; |
|
| 3008 | 3008 | } else { |
| 3009 | - $isAutoFolder=false; |
|
| 3010 | - foreach($autoFoldersTmp as $afk=>$aF) |
|
| 3009 | + $isAutoFolder = false; |
|
| 3010 | + foreach ($autoFoldersTmp as $afk=>$aF) |
|
| 3011 | 3011 | { |
| 3012 | 3012 | //error_log(__METHOD__.__LINE__.$k.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 3013 | - if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
|
| 3014 | - ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter || //k may be child of an autofolder |
|
| 3015 | - stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder |
|
| 3013 | + if ($aF && strlen($mySpecialUseFolders[$aF]) && /*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
|
| 3014 | + ($mySpecialUseFolders[$aF] == $k || substr($k, 0, strlen($mySpecialUseFolders[$aF].$delimiter)) == $mySpecialUseFolders[$aF].$delimiter || //k may be child of an autofolder |
|
| 3015 | + stristr($mySpecialUseFolders[$aF], $k.$delimiter) !== false)) // k is parent of an autofolder |
|
| 3016 | 3016 | { |
| 3017 | 3017 | //error_log(__METHOD__.__LINE__.$k.'->'.$mySpecialUseFolders[$aF]); |
| 3018 | - $isAutoFolder=true; |
|
| 3019 | - $autoFolderObjects[$k]=$f; |
|
| 3018 | + $isAutoFolder = true; |
|
| 3019 | + $autoFolderObjects[$k] = $f; |
|
| 3020 | 3020 | break; |
| 3021 | 3021 | } |
| 3022 | 3022 | } |
| 3023 | - if ($isAutoFolder==false) $inboxSubFolderObjects[$k]=$f; |
|
| 3023 | + if ($isAutoFolder == false) $inboxSubFolderObjects[$k] = $f; |
|
| 3024 | 3024 | unset($folders[$k]); |
| 3025 | - $sorted=true; |
|
| 3025 | + $sorted = true; |
|
| 3026 | 3026 | } |
| 3027 | - } elseif (strtoupper(substr($k,0,13))=='[GOOGLE MAIL]') { |
|
| 3028 | - $isGoogleMail=true; |
|
| 3029 | - if (strtoupper($k)=='[GOOGLE MAIL]') { |
|
| 3030 | - $googleMailFolderObject[$k]=$f; |
|
| 3027 | + } elseif (strtoupper(substr($k, 0, 13)) == '[GOOGLE MAIL]') { |
|
| 3028 | + $isGoogleMail = true; |
|
| 3029 | + if (strtoupper($k) == '[GOOGLE MAIL]') { |
|
| 3030 | + $googleMailFolderObject[$k] = $f; |
|
| 3031 | 3031 | unset($folders[$k]); |
| 3032 | - $sorted=true; |
|
| 3032 | + $sorted = true; |
|
| 3033 | 3033 | } else { |
| 3034 | - $isAutoFolder=false; |
|
| 3035 | - foreach($autoFoldersTmp as $afk=>$aF) |
|
| 3034 | + $isAutoFolder = false; |
|
| 3035 | + foreach ($autoFoldersTmp as $afk=>$aF) |
|
| 3036 | 3036 | { |
| 3037 | 3037 | //error_log($k.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 3038 | - if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
|
| 3039 | - ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter|| //k may be child of an autofolder |
|
| 3040 | - stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder |
|
| 3038 | + if ($aF && strlen($mySpecialUseFolders[$aF]) && /*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
|
| 3039 | + ($mySpecialUseFolders[$aF] == $k || substr($k, 0, strlen($mySpecialUseFolders[$aF].$delimiter)) == $mySpecialUseFolders[$aF].$delimiter || //k may be child of an autofolder |
|
| 3040 | + stristr($mySpecialUseFolders[$aF], $k.$delimiter) !== false)) // k is parent of an autofolder |
|
| 3041 | 3041 | { |
| 3042 | 3042 | //error_log($k.'->'.$mySpecialUseFolders[$aF]); |
| 3043 | - $isAutoFolder=true; |
|
| 3044 | - $googleAutoFolderObjects[$k]=$f; |
|
| 3043 | + $isAutoFolder = true; |
|
| 3044 | + $googleAutoFolderObjects[$k] = $f; |
|
| 3045 | 3045 | break; |
| 3046 | 3046 | } |
| 3047 | 3047 | } |
| 3048 | - if ($isAutoFolder==false) $googleSubFolderObjects[$k]=$f; |
|
| 3048 | + if ($isAutoFolder == false) $googleSubFolderObjects[$k] = $f; |
|
| 3049 | 3049 | unset($folders[$k]); |
| 3050 | - $sorted=true; |
|
| 3050 | + $sorted = true; |
|
| 3051 | 3051 | } |
| 3052 | 3052 | } else { |
| 3053 | - $isAutoFolder=false; |
|
| 3054 | - foreach($autoFoldersTmp as $afk=>$aF) |
|
| 3053 | + $isAutoFolder = false; |
|
| 3054 | + foreach ($autoFoldersTmp as $afk=>$aF) |
|
| 3055 | 3055 | { |
| 3056 | 3056 | //error_log($k.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 3057 | - if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
|
| 3058 | - ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter|| //k may be child of an autofolder |
|
| 3059 | - stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder |
|
| 3057 | + if ($aF && strlen($mySpecialUseFolders[$aF]) && /*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
|
| 3058 | + ($mySpecialUseFolders[$aF] == $k || substr($k, 0, strlen($mySpecialUseFolders[$aF].$delimiter)) == $mySpecialUseFolders[$aF].$delimiter || //k may be child of an autofolder |
|
| 3059 | + stristr($mySpecialUseFolders[$aF], $k.$delimiter) !== false)) // k is parent of an autofolder |
|
| 3060 | 3060 | { |
| 3061 | 3061 | //error_log($k.'->'.$mySpecialUseFolders[$aF]); |
| 3062 | - $isAutoFolder=true; |
|
| 3063 | - $autoFolderObjects[$k]=$f; |
|
| 3062 | + $isAutoFolder = true; |
|
| 3063 | + $autoFolderObjects[$k] = $f; |
|
| 3064 | 3064 | unset($folders[$k]); |
| 3065 | - $sorted=true; |
|
| 3065 | + $sorted = true; |
|
| 3066 | 3066 | break; |
| 3067 | 3067 | } |
| 3068 | 3068 | } |
| 3069 | 3069 | } |
| 3070 | 3070 | |
| 3071 | - if ($sorted==false) |
|
| 3071 | + if ($sorted == false) |
|
| 3072 | 3072 | { |
| 3073 | - foreach(array('others','shared') as $type) |
|
| 3073 | + foreach (array('others', 'shared') as $type) |
|
| 3074 | 3074 | { |
| 3075 | - if ($nameSpace[$type]['prefix_present']&&$nameSpace[$type]['prefix']) |
|
| 3075 | + if ($nameSpace[$type]['prefix_present'] && $nameSpace[$type]['prefix']) |
|
| 3076 | 3076 | { |
| 3077 | - if (substr($k,0,strlen($nameSpace[$type]['prefix']))==$nameSpace[$type]['prefix']|| |
|
| 3078 | - substr($k,0,strlen($nameSpace[$type]['prefix'])-strlen($nameSpace[$type]['delimiter']))==substr($nameSpace[$type]['prefix'],0,strlen($nameSpace[$type]['delimiter'])*-1)) { |
|
| 3077 | + if (substr($k, 0, strlen($nameSpace[$type]['prefix'])) == $nameSpace[$type]['prefix'] || |
|
| 3078 | + substr($k, 0, strlen($nameSpace[$type]['prefix']) - strlen($nameSpace[$type]['delimiter'])) == substr($nameSpace[$type]['prefix'], 0, strlen($nameSpace[$type]['delimiter']) * -1)) { |
|
| 3079 | 3079 | //error_log(__METHOD__.__LINE__.':'.substr($k,0,strlen($nameSpace[$type]['prefix'])).':'.$k); |
| 3080 | - $typeFolderObject[$type][$k]=$f; |
|
| 3080 | + $typeFolderObject[$type][$k] = $f; |
|
| 3081 | 3081 | unset($folders[$k]); |
| 3082 | 3082 | } |
| 3083 | 3083 | } |
@@ -3088,40 +3088,40 @@ discard block |
||
| 3088 | 3088 | // avoid calling sortByAutoFolder as it is not regarding subfolders |
| 3089 | 3089 | $autoFolderObjectsTmp = $autoFolderObjects; |
| 3090 | 3090 | unset($autoFolderObjects); |
| 3091 | - uasort($autoFolderObjectsTmp, array($this,'sortByMailbox')); |
|
| 3092 | - foreach($autoFoldersTmp as $afk=>$aF) |
|
| 3091 | + uasort($autoFolderObjectsTmp, array($this, 'sortByMailbox')); |
|
| 3092 | + foreach ($autoFoldersTmp as $afk=>$aF) |
|
| 3093 | 3093 | { |
| 3094 | - foreach($autoFolderObjectsTmp as $k => $f) |
|
| 3094 | + foreach ($autoFolderObjectsTmp as $k => $f) |
|
| 3095 | 3095 | { |
| 3096 | - if($aF && ($mySpecialUseFolders[$aF]==$k || |
|
| 3097 | - substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter || |
|
| 3098 | - stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) |
|
| 3096 | + if ($aF && ($mySpecialUseFolders[$aF] == $k || |
|
| 3097 | + substr($k, 0, strlen($mySpecialUseFolders[$aF].$delimiter)) == $mySpecialUseFolders[$aF].$delimiter || |
|
| 3098 | + stristr($mySpecialUseFolders[$aF], $k.$delimiter) !== false)) |
|
| 3099 | 3099 | { |
| 3100 | - $autoFolderObjects[$k]=$f; |
|
| 3100 | + $autoFolderObjects[$k] = $f; |
|
| 3101 | 3101 | } |
| 3102 | 3102 | } |
| 3103 | 3103 | } |
| 3104 | 3104 | //error_log(__METHOD__.__LINE__.array2string($autoFolderObjects)); |
| 3105 | 3105 | if (!$isGoogleMail) { |
| 3106 | - $folders = array_merge($inboxFolderObject,$autoFolderObjects,(array)$inboxSubFolderObjects,(array)$folders,(array)$typeFolderObject['others'],(array)$typeFolderObject['shared']); |
|
| 3106 | + $folders = array_merge($inboxFolderObject, $autoFolderObjects, (array)$inboxSubFolderObjects, (array)$folders, (array)$typeFolderObject['others'], (array)$typeFolderObject['shared']); |
|
| 3107 | 3107 | } else { |
| 3108 | 3108 | // avoid calling sortByAutoFolder as it is not regarding subfolders |
| 3109 | 3109 | $gAutoFolderObjectsTmp = $googleAutoFolderObjects; |
| 3110 | 3110 | unset($googleAutoFolderObjects); |
| 3111 | - uasort($gAutoFolderObjectsTmp, array($this,'sortByMailbox')); |
|
| 3112 | - foreach($autoFoldersTmp as $afk=>$aF) |
|
| 3111 | + uasort($gAutoFolderObjectsTmp, array($this, 'sortByMailbox')); |
|
| 3112 | + foreach ($autoFoldersTmp as $afk=>$aF) |
|
| 3113 | 3113 | { |
| 3114 | - foreach($gAutoFolderObjectsTmp as $k => $f) |
|
| 3114 | + foreach ($gAutoFolderObjectsTmp as $k => $f) |
|
| 3115 | 3115 | { |
| 3116 | - if($aF && ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter)) |
|
| 3116 | + if ($aF && ($mySpecialUseFolders[$aF] == $k || substr($k, 0, strlen($mySpecialUseFolders[$aF].$delimiter)) == $mySpecialUseFolders[$aF].$delimiter)) |
|
| 3117 | 3117 | { |
| 3118 | - $googleAutoFolderObjects[$k]=$f; |
|
| 3118 | + $googleAutoFolderObjects[$k] = $f; |
|
| 3119 | 3119 | } |
| 3120 | 3120 | } |
| 3121 | 3121 | } |
| 3122 | - $folders = array_merge($inboxFolderObject,$autoFolderObjects,(array)$folders,(array)$googleMailFolderObject,$googleAutoFolderObjects,$googleSubFolderObjects,(array)$typeFolderObject['others'],(array)$typeFolderObject['shared']); |
|
| 3122 | + $folders = array_merge($inboxFolderObject, $autoFolderObjects, (array)$folders, (array)$googleMailFolderObject, $googleAutoFolderObjects, $googleSubFolderObjects, (array)$typeFolderObject['others'], (array)$typeFolderObject['shared']); |
|
| 3123 | 3123 | } |
| 3124 | - if (self::$debugTimes) self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') Sorting:'); |
|
| 3124 | + if (self::$debugTimes) self::logRunTimes($starttime, null, function_backtrace(), __METHOD__.' ('.__LINE__.') Sorting:'); |
|
| 3125 | 3125 | //self::$debugTimes=false; |
| 3126 | 3126 | } |
| 3127 | 3127 | // Get counter information and add them to each fetched folders array |
@@ -3143,10 +3143,10 @@ discard block |
||
| 3143 | 3143 | * @param array $autofolders_exists existing folders, no need to check their existance again |
| 3144 | 3144 | * @return int number of new folders created |
| 3145 | 3145 | */ |
| 3146 | - function check_create_autofolders(array $autofolders_exists=array()) |
|
| 3146 | + function check_create_autofolders(array $autofolders_exists = array()) |
|
| 3147 | 3147 | { |
| 3148 | 3148 | $num_created = 0; |
| 3149 | - foreach(self::$autoFolders as $folder) |
|
| 3149 | + foreach (self::$autoFolders as $folder) |
|
| 3150 | 3150 | { |
| 3151 | 3151 | $created = false; |
| 3152 | 3152 | if (!in_array($folder, $autofolders_exists) && $this->_getSpecialUseFolder($folder, true, $created) && |
@@ -3171,7 +3171,7 @@ discard block |
||
| 3171 | 3171 | $rv = false; |
| 3172 | 3172 | foreach ($haystack as $k => $v) |
| 3173 | 3173 | { |
| 3174 | - foreach($v as &$sv) {if (trim($sv)==trim($needle)) return $k;} |
|
| 3174 | + foreach ($v as &$sv) {if (trim($sv) == trim($needle)) return $k; } |
|
| 3175 | 3175 | } |
| 3176 | 3176 | return $rv; |
| 3177 | 3177 | } |
@@ -3184,9 +3184,9 @@ discard block |
||
| 3184 | 3184 | * @param array $b array of folders |
| 3185 | 3185 | * @return int expect values (0, 1 or -1) |
| 3186 | 3186 | */ |
| 3187 | - function sortByMailbox($a,$b) |
|
| 3187 | + function sortByMailbox($a, $b) |
|
| 3188 | 3188 | { |
| 3189 | - return strcasecmp($a['MAILBOX'],$b['MAILBOX']); |
|
| 3189 | + return strcasecmp($a['MAILBOX'], $b['MAILBOX']); |
|
| 3190 | 3190 | } |
| 3191 | 3191 | |
| 3192 | 3192 | /** |
@@ -3196,13 +3196,13 @@ discard block |
||
| 3196 | 3196 | * @param string $_hDelimiter hierarchy delimiter |
| 3197 | 3197 | * @return array returns an array of data extracted from given node path |
| 3198 | 3198 | */ |
| 3199 | - static function pathToFolderData ($_path, $_hDelimiter) |
|
| 3199 | + static function pathToFolderData($_path, $_hDelimiter) |
|
| 3200 | 3200 | { |
| 3201 | 3201 | if (!strpos($_path, self::DELIMITER)) $_path = self::DELIMITER.$_path; |
| 3202 | 3202 | list(,$path) = explode(self::DELIMITER, $_path); |
| 3203 | 3203 | $path_chain = $parts = explode($_hDelimiter, $path); |
| 3204 | 3204 | $name = array_pop($parts); |
| 3205 | - return array ( |
|
| 3205 | + return array( |
|
| 3206 | 3206 | 'name' => $name, |
| 3207 | 3207 | 'mailbox' => $path, |
| 3208 | 3208 | 'parent' => implode($_hDelimiter, $parts), |
@@ -3225,8 +3225,8 @@ discard block |
||
| 3225 | 3225 | // 0, 1 und -1 |
| 3226 | 3226 | $a = self::pathToFolderData($_a['MAILBOX'], $_a['delimiter']); |
| 3227 | 3227 | $b = self::pathToFolderData($_b['MAILBOX'], $_b['delimiter']); |
| 3228 | - $pos1 = array_search(trim($a['name']),self::$autoFolders); |
|
| 3229 | - $pos2 = array_search(trim($b['name']),self::$autoFolders); |
|
| 3228 | + $pos1 = array_search(trim($a['name']), self::$autoFolders); |
|
| 3229 | + $pos2 = array_search(trim($b['name']), self::$autoFolders); |
|
| 3230 | 3230 | if ($pos1 == $pos2) return 0; |
| 3231 | 3231 | return ($pos1 < $pos2) ? -1 : 1; |
| 3232 | 3232 | } |
@@ -3239,10 +3239,10 @@ discard block |
||
| 3239 | 3239 | * @param object $b array of folderobjects |
| 3240 | 3240 | * @return int expect values (0, 1 or -1) |
| 3241 | 3241 | */ |
| 3242 | - function sortByDisplayName($a,$b) |
|
| 3242 | + function sortByDisplayName($a, $b) |
|
| 3243 | 3243 | { |
| 3244 | 3244 | // 0, 1 und -1 |
| 3245 | - return strcasecmp($a->displayName,$b->displayName); |
|
| 3245 | + return strcasecmp($a->displayName, $b->displayName); |
|
| 3246 | 3246 | } |
| 3247 | 3247 | |
| 3248 | 3248 | /** |
@@ -3253,11 +3253,11 @@ discard block |
||
| 3253 | 3253 | * @param object $b array of folderobjects |
| 3254 | 3254 | * @return int expect values (0, 1 or -1) |
| 3255 | 3255 | */ |
| 3256 | - function sortByAutoFolderPos($a,$b) |
|
| 3256 | + function sortByAutoFolderPos($a, $b) |
|
| 3257 | 3257 | { |
| 3258 | 3258 | // 0, 1 und -1 |
| 3259 | - $pos1 = array_search(trim($a->shortFolderName),self::$autoFolders); |
|
| 3260 | - $pos2 = array_search(trim($b->shortFolderName),self::$autoFolders); |
|
| 3259 | + $pos1 = array_search(trim($a->shortFolderName), self::$autoFolders); |
|
| 3260 | + $pos2 = array_search(trim($b->shortFolderName), self::$autoFolders); |
|
| 3261 | 3261 | if ($pos1 == $pos2) return 0; |
| 3262 | 3262 | return ($pos1 < $pos2) ? -1 : 1; |
| 3263 | 3263 | } |
@@ -3270,7 +3270,7 @@ discard block |
||
| 3270 | 3270 | * @param boolean $_returnObject return the counters as object rather than an array |
| 3271 | 3271 | * @return mixed false or array of counters array(MESSAGES,UNSEEN,RECENT,UIDNEXT,UIDVALIDITY) or object |
| 3272 | 3272 | */ |
| 3273 | - function getMailBoxCounters($folderName,$_returnObject=true) |
|
| 3273 | + function getMailBoxCounters($folderName, $_returnObject = true) |
|
| 3274 | 3274 | { |
| 3275 | 3275 | try |
| 3276 | 3276 | { |
@@ -3282,9 +3282,9 @@ discard block |
||
| 3282 | 3282 | if (self::$debug) error_log(__METHOD__." returned FolderStatus for Folder $folderName:".$e->getMessage()); |
| 3283 | 3283 | return false; |
| 3284 | 3284 | } |
| 3285 | - if(is_array($folderStatus)) { |
|
| 3286 | - if ($_returnObject===false) return $folderStatus; |
|
| 3287 | - $status = new \stdClass; |
|
| 3285 | + if (is_array($folderStatus)) { |
|
| 3286 | + if ($_returnObject === false) return $folderStatus; |
|
| 3287 | + $status = new \stdClass; |
|
| 3288 | 3288 | $status->messages = $folderStatus['MESSAGES']; |
| 3289 | 3289 | $status->unseen = $folderStatus['UNSEEN']; |
| 3290 | 3290 | $status->recent = $folderStatus['RECENT']; |
@@ -3306,42 +3306,42 @@ discard block |
||
| 3306 | 3306 | * @param string $reclevel 0, counter to keep track of the current recursionlevel |
| 3307 | 3307 | * @return array of mailboxes |
| 3308 | 3308 | */ |
| 3309 | - function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel=0) |
|
| 3309 | + function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel = 0) |
|
| 3310 | 3310 | { |
| 3311 | 3311 | #echo __METHOD__." retrieve SubFolders for $_mailbox$delimiter <br>"; |
| 3312 | - $maxreclevel=25; |
|
| 3312 | + $maxreclevel = 25; |
|
| 3313 | 3313 | if ($reclevel > $maxreclevel) { |
| 3314 | - error_log( __METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter "); |
|
| 3314 | + error_log(__METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter "); |
|
| 3315 | 3315 | return array(); |
| 3316 | 3316 | } |
| 3317 | 3317 | $reclevel++; |
| 3318 | 3318 | // clean up double delimiters |
| 3319 | - $_mailbox = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$_mailbox); |
|
| 3319 | + $_mailbox = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter : $delimiter).'+~s', $delimiter, $_mailbox); |
|
| 3320 | 3320 | //get that mailbox in question |
| 3321 | - $mbx = $this->icServer->getMailboxes($_mailbox,1,true); |
|
| 3321 | + $mbx = $this->icServer->getMailboxes($_mailbox, 1, true); |
|
| 3322 | 3322 | $mbxkeys = array_keys($mbx); |
| 3323 | 3323 | #_debug_array($mbx); |
| 3324 | 3324 | //error_log(__METHOD__.' ('.__LINE__.') '.' Delimiter:'.array2string($delimiter)); |
| 3325 | 3325 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mbx)); |
| 3326 | 3326 | // Example: Array([INBOX/GaGa] => Array([MAILBOX] => INBOX/GaGa[ATTRIBUTES] => Array([0] => \\unmarked)[delimiter] => /)) |
| 3327 | - 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"]))) { |
|
| 3327 | + 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"]))) { |
|
| 3328 | 3328 | // if there are children fetch them |
| 3329 | 3329 | //echo $mbx[$mbxkeys[0]]['MAILBOX']."<br>"; |
| 3330 | 3330 | |
| 3331 | - $buff = $this->icServer->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'].($mbx[$mbxkeys[0]]['MAILBOX'] == $prefix ? '':$delimiter),2,false); |
|
| 3331 | + $buff = $this->icServer->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'].($mbx[$mbxkeys[0]]['MAILBOX'] == $prefix ? '' : $delimiter), 2, false); |
|
| 3332 | 3332 | //$buff = $this->icServer->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'],2,false); |
| 3333 | 3333 | //_debug_array($buff); |
| 3334 | 3334 | $allMailboxes = array(); |
| 3335 | 3335 | foreach ($buff as $mbxname) { |
| 3336 | 3336 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mbxname)); |
| 3337 | - $mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$mbxname['MAILBOX']); |
|
| 3337 | + $mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter : $delimiter).'+~s', $delimiter, $mbxname['MAILBOX']); |
|
| 3338 | 3338 | #echo "About to recur in level $reclevel:".$mbxname."<br>"; |
| 3339 | - if ( $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'] && $mbxname != $prefix && $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'].$delimiter) |
|
| 3339 | + if ($mbxname != $mbx[$mbxkeys[0]]['MAILBOX'] && $mbxname != $prefix && $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'].$delimiter) |
|
| 3340 | 3340 | { |
| 3341 | 3341 | $allMailboxes = array_merge($allMailboxes, self::getMailBoxesRecursive($mbxname, $delimiter, $prefix, $reclevel)); |
| 3342 | 3342 | } |
| 3343 | 3343 | } |
| 3344 | - 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']; |
|
| 3344 | + 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']; |
|
| 3345 | 3345 | return $allMailboxes; |
| 3346 | 3346 | } else { |
| 3347 | 3347 | return array($_mailbox); |
@@ -3356,18 +3356,18 @@ discard block |
||
| 3356 | 3356 | * @param boolean& $created =null on return true: if folder was just created, false if not |
| 3357 | 3357 | * @return mixed string or false |
| 3358 | 3358 | */ |
| 3359 | - function _getSpecialUseFolder($_type, $_checkexistance=TRUE, &$created=null) |
|
| 3359 | + function _getSpecialUseFolder($_type, $_checkexistance = TRUE, &$created = null) |
|
| 3360 | 3360 | { |
| 3361 | 3361 | static $types = array( |
| 3362 | - 'Drafts' => array('profileKey'=>'acc_folder_draft','autoFolderName'=>'Drafts'), |
|
| 3363 | - 'Template' => array('profileKey'=>'acc_folder_template','autoFolderName'=>'Templates'), |
|
| 3364 | - 'Trash' => array('profileKey'=>'acc_folder_trash','autoFolderName'=>'Trash'), |
|
| 3365 | - 'Sent' => array('profileKey'=>'acc_folder_sent','autoFolderName'=>'Sent'), |
|
| 3366 | - 'Junk' => array('profileKey'=>'acc_folder_junk','autoFolderName'=>'Junk'), |
|
| 3367 | - 'Outbox' => array('profileKey'=>'acc_folder_outbox','autoFolderName'=>'Outbox'), |
|
| 3368 | - 'Archive' => array('profileKey'=>'acc_folder_archive','autoFolderName'=>'Archive'), |
|
| 3362 | + 'Drafts' => array('profileKey'=>'acc_folder_draft', 'autoFolderName'=>'Drafts'), |
|
| 3363 | + 'Template' => array('profileKey'=>'acc_folder_template', 'autoFolderName'=>'Templates'), |
|
| 3364 | + 'Trash' => array('profileKey'=>'acc_folder_trash', 'autoFolderName'=>'Trash'), |
|
| 3365 | + 'Sent' => array('profileKey'=>'acc_folder_sent', 'autoFolderName'=>'Sent'), |
|
| 3366 | + 'Junk' => array('profileKey'=>'acc_folder_junk', 'autoFolderName'=>'Junk'), |
|
| 3367 | + 'Outbox' => array('profileKey'=>'acc_folder_outbox', 'autoFolderName'=>'Outbox'), |
|
| 3368 | + 'Archive' => array('profileKey'=>'acc_folder_archive', 'autoFolderName'=>'Archive'), |
|
| 3369 | 3369 | ); |
| 3370 | - if ($_type == 'Templates') $_type = 'Template'; // for some reason self::$autofolders uses 'Templates'! |
|
| 3370 | + if ($_type == 'Templates') $_type = 'Template'; // for some reason self::$autofolders uses 'Templates'! |
|
| 3371 | 3371 | $created = false; |
| 3372 | 3372 | if (!isset($types[$_type])) |
| 3373 | 3373 | { |
@@ -3389,7 +3389,7 @@ discard block |
||
| 3389 | 3389 | } |
| 3390 | 3390 | // do not try to autocreate configured Archive-Folder. Return false if configured folder does not exist |
| 3391 | 3391 | if ($_type == 'Archive') { |
| 3392 | - if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true)) { |
|
| 3392 | + if ($_folderName && $_checkexistance && strtolower($_folderName) != 'none' && !$this->folderExists($_folderName, true)) { |
|
| 3393 | 3393 | return false; |
| 3394 | 3394 | } else { |
| 3395 | 3395 | return $_folderName; |
@@ -3397,38 +3397,38 @@ discard block |
||
| 3397 | 3397 | |
| 3398 | 3398 | } |
| 3399 | 3399 | // does the folder exist??? (is configured/preset, but non-existent) |
| 3400 | - if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true)) { |
|
| 3400 | + if ($_folderName && $_checkexistance && strtolower($_folderName) != 'none' && !$this->folderExists($_folderName, true)) { |
|
| 3401 | 3401 | try |
| 3402 | 3402 | { |
| 3403 | 3403 | $error = null; |
| 3404 | 3404 | if (($_folderName = $this->createFolder('', $_folderName, $error))) $created = true; |
| 3405 | 3405 | if ($error) error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error); |
| 3406 | 3406 | } |
| 3407 | - catch(Exception $e) |
|
| 3407 | + catch (Exception $e) |
|
| 3408 | 3408 | { |
| 3409 | 3409 | error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$e->getMessage().':'.function_backtrace()); |
| 3410 | 3410 | $_folderName = false; |
| 3411 | 3411 | } |
| 3412 | 3412 | } |
| 3413 | 3413 | // not sure yet if false is the correct behavior on none |
| 3414 | - if ($_folderName =='none') return 'none' ; //false; |
|
| 3414 | + if ($_folderName == 'none') return 'none'; //false; |
|
| 3415 | 3415 | //no (valid) folder found yet; try specialUseFolders |
| 3416 | - if (empty($_folderName) && is_array(self::$specialUseFolders) && ($f = array_search($_type,self::$specialUseFolders))) $_folderName = $f; |
|
| 3416 | + if (empty($_folderName) && is_array(self::$specialUseFolders) && ($f = array_search($_type, self::$specialUseFolders))) $_folderName = $f; |
|
| 3417 | 3417 | //no specialUseFolder; try some Defaults |
| 3418 | 3418 | if (empty($_folderName) && isset($types[$_type])) |
| 3419 | 3419 | { |
| 3420 | 3420 | $nameSpace = $this->_getNameSpaces(); |
| 3421 | - $prefix=''; |
|
| 3421 | + $prefix = ''; |
|
| 3422 | 3422 | foreach ($nameSpace as $nSp) |
| 3423 | 3423 | { |
| 3424 | - if ($nSp['type']=='personal') |
|
| 3424 | + if ($nSp['type'] == 'personal') |
|
| 3425 | 3425 | { |
| 3426 | 3426 | //error_log(__METHOD__.__LINE__.array2string($nSp)); |
| 3427 | 3427 | $prefix = $nSp['prefix']; |
| 3428 | 3428 | break; |
| 3429 | 3429 | } |
| 3430 | 3430 | } |
| 3431 | - if ($this->folderExists($prefix.$types[$_type]['autoFolderName'],true)) |
|
| 3431 | + if ($this->folderExists($prefix.$types[$_type]['autoFolderName'], true)) |
|
| 3432 | 3432 | { |
| 3433 | 3433 | $_folderName = $prefix.$types[$_type]['autoFolderName']; |
| 3434 | 3434 | } |
@@ -3437,11 +3437,11 @@ discard block |
||
| 3437 | 3437 | try |
| 3438 | 3438 | { |
| 3439 | 3439 | $error = null; |
| 3440 | - $this->createFolder('', $prefix.$types[$_type]['autoFolderName'],$error); |
|
| 3440 | + $this->createFolder('', $prefix.$types[$_type]['autoFolderName'], $error); |
|
| 3441 | 3441 | $_folderName = $prefix.$types[$_type]['autoFolderName']; |
| 3442 | 3442 | if ($error) error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error); |
| 3443 | 3443 | } |
| 3444 | - catch(Exception $e) |
|
| 3444 | + catch (Exception $e) |
|
| 3445 | 3445 | { |
| 3446 | 3446 | error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$e->getMessage()); |
| 3447 | 3447 | $_folderName = false; |
@@ -3457,7 +3457,7 @@ discard block |
||
| 3457 | 3457 | * @param boolean $_checkexistance trigger check for existance |
| 3458 | 3458 | * @return mixed string or false |
| 3459 | 3459 | */ |
| 3460 | - function getFolderByType($type, $_checkexistance=false) |
|
| 3460 | + function getFolderByType($type, $_checkexistance = false) |
|
| 3461 | 3461 | { |
| 3462 | 3462 | return $this->_getSpecialUseFolder($type, $_checkexistance); |
| 3463 | 3463 | } |
@@ -3467,7 +3467,7 @@ discard block |
||
| 3467 | 3467 | * @param boolean $_checkexistance trigger check for existance |
| 3468 | 3468 | * @return mixed string or false |
| 3469 | 3469 | */ |
| 3470 | - function getJunkFolder($_checkexistance=TRUE) |
|
| 3470 | + function getJunkFolder($_checkexistance = TRUE) |
|
| 3471 | 3471 | { |
| 3472 | 3472 | return $this->_getSpecialUseFolder('Junk', $_checkexistance); |
| 3473 | 3473 | } |
@@ -3477,7 +3477,7 @@ discard block |
||
| 3477 | 3477 | * @param boolean $_checkexistance trigger check for existance |
| 3478 | 3478 | * @return mixed string or false |
| 3479 | 3479 | */ |
| 3480 | - function getDraftFolder($_checkexistance=TRUE) |
|
| 3480 | + function getDraftFolder($_checkexistance = TRUE) |
|
| 3481 | 3481 | { |
| 3482 | 3482 | return $this->_getSpecialUseFolder('Drafts', $_checkexistance); |
| 3483 | 3483 | } |
@@ -3487,7 +3487,7 @@ discard block |
||
| 3487 | 3487 | * @param boolean $_checkexistance trigger check for existance |
| 3488 | 3488 | * @return mixed string or false |
| 3489 | 3489 | */ |
| 3490 | - function getTemplateFolder($_checkexistance=TRUE) |
|
| 3490 | + function getTemplateFolder($_checkexistance = TRUE) |
|
| 3491 | 3491 | { |
| 3492 | 3492 | return $this->_getSpecialUseFolder('Template', $_checkexistance); |
| 3493 | 3493 | } |
@@ -3497,7 +3497,7 @@ discard block |
||
| 3497 | 3497 | * @param boolean $_checkexistance trigger check for existance |
| 3498 | 3498 | * @return mixed string or false |
| 3499 | 3499 | */ |
| 3500 | - function getTrashFolder($_checkexistance=TRUE) |
|
| 3500 | + function getTrashFolder($_checkexistance = TRUE) |
|
| 3501 | 3501 | { |
| 3502 | 3502 | return $this->_getSpecialUseFolder('Trash', $_checkexistance); |
| 3503 | 3503 | } |
@@ -3507,7 +3507,7 @@ discard block |
||
| 3507 | 3507 | * @param boolean $_checkexistance trigger check for existance |
| 3508 | 3508 | * @return mixed string or false |
| 3509 | 3509 | */ |
| 3510 | - function getSentFolder($_checkexistance=TRUE) |
|
| 3510 | + function getSentFolder($_checkexistance = TRUE) |
|
| 3511 | 3511 | { |
| 3512 | 3512 | return $this->_getSpecialUseFolder('Sent', $_checkexistance); |
| 3513 | 3513 | } |
@@ -3517,7 +3517,7 @@ discard block |
||
| 3517 | 3517 | * @param boolean $_checkexistance trigger check for existance |
| 3518 | 3518 | * @return mixed string or false |
| 3519 | 3519 | */ |
| 3520 | - function getOutboxFolder($_checkexistance=TRUE) |
|
| 3520 | + function getOutboxFolder($_checkexistance = TRUE) |
|
| 3521 | 3521 | { |
| 3522 | 3522 | return $this->_getSpecialUseFolder('Outbox', $_checkexistance); |
| 3523 | 3523 | } |
@@ -3527,7 +3527,7 @@ discard block |
||
| 3527 | 3527 | * @param boolean $_checkexistance trigger check for existance . We do no autocreation for configured Archive folder |
| 3528 | 3528 | * @return mixed string or false |
| 3529 | 3529 | */ |
| 3530 | - function getArchiveFolder($_checkexistance=TRUE) |
|
| 3530 | + function getArchiveFolder($_checkexistance = TRUE) |
|
| 3531 | 3531 | { |
| 3532 | 3532 | return $this->_getSpecialUseFolder('Archive', $_checkexistance); |
| 3533 | 3533 | } |
@@ -3538,10 +3538,10 @@ discard block |
||
| 3538 | 3538 | * @param boolean $_checkexistance trigger check for existance |
| 3539 | 3539 | * @return boolean |
| 3540 | 3540 | */ |
| 3541 | - function isSentFolder($_folderName, $_checkexistance=TRUE) |
|
| 3541 | + function isSentFolder($_folderName, $_checkexistance = TRUE) |
|
| 3542 | 3542 | { |
| 3543 | 3543 | $sentFolder = $this->getSentFolder($_checkexistance); |
| 3544 | - if(empty($sentFolder)) { |
|
| 3544 | + if (empty($sentFolder)) { |
|
| 3545 | 3545 | return false; |
| 3546 | 3546 | } |
| 3547 | 3547 | // does the folder exist??? |
@@ -3549,7 +3549,7 @@ discard block |
||
| 3549 | 3549 | return false; |
| 3550 | 3550 | } |
| 3551 | 3551 | |
| 3552 | - if(false !== stripos($_folderName, $sentFolder)) { |
|
| 3552 | + if (false !== stripos($_folderName, $sentFolder)) { |
|
| 3553 | 3553 | return true; |
| 3554 | 3554 | } else { |
| 3555 | 3555 | return false; |
@@ -3562,15 +3562,15 @@ discard block |
||
| 3562 | 3562 | * @param boolean $_checkexistance trigger check for existance |
| 3563 | 3563 | * @return boolean |
| 3564 | 3564 | */ |
| 3565 | - function isOutbox($_folderName, $_checkexistance=TRUE) |
|
| 3565 | + function isOutbox($_folderName, $_checkexistance = TRUE) |
|
| 3566 | 3566 | { |
| 3567 | - if (stripos($_folderName, 'Outbox')===false) { |
|
| 3567 | + if (stripos($_folderName, 'Outbox') === false) { |
|
| 3568 | 3568 | return false; |
| 3569 | 3569 | } |
| 3570 | 3570 | // does the folder exist??? |
| 3571 | 3571 | if ($_checkexistance && $GLOBALS['egw_info']['user']['apps']['activesync'] && !$this->folderExists($_folderName)) { |
| 3572 | 3572 | $outboxFolder = $this->getOutboxFolder($_checkexistance); |
| 3573 | - if(false !== stripos($_folderName, $outboxFolder)) { |
|
| 3573 | + if (false !== stripos($_folderName, $outboxFolder)) { |
|
| 3574 | 3574 | return true; |
| 3575 | 3575 | } else { |
| 3576 | 3576 | return false; |
@@ -3585,18 +3585,18 @@ discard block |
||
| 3585 | 3585 | * @param boolean $_checkexistance trigger check for existance |
| 3586 | 3586 | * @return boolean |
| 3587 | 3587 | */ |
| 3588 | - function isDraftFolder($_folderName, $_checkexistance=TRUE) |
|
| 3588 | + function isDraftFolder($_folderName, $_checkexistance = TRUE) |
|
| 3589 | 3589 | { |
| 3590 | 3590 | $draftFolder = $this->getDraftFolder($_checkexistance); |
| 3591 | - if(empty($draftFolder)) { |
|
| 3591 | + if (empty($draftFolder)) { |
|
| 3592 | 3592 | return false; |
| 3593 | 3593 | } |
| 3594 | 3594 | // does the folder exist??? |
| 3595 | 3595 | if ($_checkexistance && !$this->folderExists($_folderName)) { |
| 3596 | 3596 | return false; |
| 3597 | 3597 | } |
| 3598 | - if (is_a($_folderName,"Horde_Imap_Client_Mailbox")) $_folderName = $_folderName->utf8; |
|
| 3599 | - if(false !== stripos($_folderName, $draftFolder)) { |
|
| 3598 | + if (is_a($_folderName, "Horde_Imap_Client_Mailbox")) $_folderName = $_folderName->utf8; |
|
| 3599 | + if (false !== stripos($_folderName, $draftFolder)) { |
|
| 3600 | 3600 | return true; |
| 3601 | 3601 | } else { |
| 3602 | 3602 | return false; |
@@ -3609,10 +3609,10 @@ discard block |
||
| 3609 | 3609 | * @param boolean $_checkexistance trigger check for existance |
| 3610 | 3610 | * @return boolean |
| 3611 | 3611 | */ |
| 3612 | - function isTrashFolder($_folderName, $_checkexistance=TRUE) |
|
| 3612 | + function isTrashFolder($_folderName, $_checkexistance = TRUE) |
|
| 3613 | 3613 | { |
| 3614 | 3614 | $trashFolder = $this->getTrashFolder($_checkexistance); |
| 3615 | - if(empty($trashFolder)) { |
|
| 3615 | + if (empty($trashFolder)) { |
|
| 3616 | 3616 | return false; |
| 3617 | 3617 | } |
| 3618 | 3618 | // does the folder exist??? |
@@ -3620,7 +3620,7 @@ discard block |
||
| 3620 | 3620 | return false; |
| 3621 | 3621 | } |
| 3622 | 3622 | |
| 3623 | - if(false !== stripos($_folderName, $trashFolder)) { |
|
| 3623 | + if (false !== stripos($_folderName, $trashFolder)) { |
|
| 3624 | 3624 | return true; |
| 3625 | 3625 | } else { |
| 3626 | 3626 | return false; |
@@ -3633,10 +3633,10 @@ discard block |
||
| 3633 | 3633 | * @param boolean $_checkexistance trigger check for existance |
| 3634 | 3634 | * @return boolean |
| 3635 | 3635 | */ |
| 3636 | - function isTemplateFolder($_folderName, $_checkexistance=TRUE) |
|
| 3636 | + function isTemplateFolder($_folderName, $_checkexistance = TRUE) |
|
| 3637 | 3637 | { |
| 3638 | 3638 | $templateFolder = $this->getTemplateFolder($_checkexistance); |
| 3639 | - if(empty($templateFolder)) { |
|
| 3639 | + if (empty($templateFolder)) { |
|
| 3640 | 3640 | return false; |
| 3641 | 3641 | } |
| 3642 | 3642 | // does the folder exist??? |
@@ -3644,7 +3644,7 @@ discard block |
||
| 3644 | 3644 | return false; |
| 3645 | 3645 | } |
| 3646 | 3646 | |
| 3647 | - if(false !== stripos($_folderName, $templateFolder)) { |
|
| 3647 | + if (false !== stripos($_folderName, $templateFolder)) { |
|
| 3648 | 3648 | return true; |
| 3649 | 3649 | } else { |
| 3650 | 3650 | return false; |
@@ -3657,24 +3657,24 @@ discard block |
||
| 3657 | 3657 | * @param boolean $_forceCheck trigger check for existance on icServer |
| 3658 | 3658 | * @return mixed string or false |
| 3659 | 3659 | */ |
| 3660 | - function folderExists($_folder, $_forceCheck=false) |
|
| 3660 | + function folderExists($_folder, $_forceCheck = false) |
|
| 3661 | 3661 | { |
| 3662 | 3662 | static $folderInfo; |
| 3663 | 3663 | $forceCheck = $_forceCheck; |
| 3664 | 3664 | if (empty($_folder)) |
| 3665 | 3665 | { |
| 3666 | 3666 | // this error is more or less without significance, unless we force the check |
| 3667 | - if ($_forceCheck===true) error_log(__METHOD__.' ('.__LINE__.') '.' Called with empty Folder:'.$_folder.function_backtrace()); |
|
| 3667 | + if ($_forceCheck === true) error_log(__METHOD__.' ('.__LINE__.') '.' Called with empty Folder:'.$_folder.function_backtrace()); |
|
| 3668 | 3668 | return false; |
| 3669 | 3669 | } |
| 3670 | 3670 | // when check is not enforced , we assume a folder represented as Horde_Imap_Client_Mailbox as existing folder |
| 3671 | - if (is_a($_folder,"Horde_Imap_Client_Mailbox")&&$_forceCheck===false) return true; |
|
| 3672 | - if (is_a($_folder,"Horde_Imap_Client_Mailbox")) $_folder = $_folder->utf8; |
|
| 3671 | + if (is_a($_folder, "Horde_Imap_Client_Mailbox") && $_forceCheck === false) return true; |
|
| 3672 | + if (is_a($_folder, "Horde_Imap_Client_Mailbox")) $_folder = $_folder->utf8; |
|
| 3673 | 3673 | // reduce traffic within the Instance per User; Expire every 5 hours |
| 3674 | 3674 | //error_log(__METHOD__.' ('.__LINE__.') '.' Called with Folder:'.$_folder.function_backtrace()); |
| 3675 | - if (is_null($folderInfo)) $folderInfo = Cache::getCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*5); |
|
| 3675 | + if (is_null($folderInfo)) $folderInfo = Cache::getCache(Cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 5); |
|
| 3676 | 3676 | //error_log(__METHOD__.' ('.__LINE__.') '.'Cached Info on Folder:'.$_folder.' for Profile:'.$this->profileID.($forceCheck?'(forcedCheck)':'').':'.array2string($folderInfo)); |
| 3677 | - if (!empty($folderInfo) && isset($folderInfo[$this->profileID]) && isset($folderInfo[$this->profileID][$_folder]) && $forceCheck===false) |
|
| 3677 | + if (!empty($folderInfo) && isset($folderInfo[$this->profileID]) && isset($folderInfo[$this->profileID][$_folder]) && $forceCheck === false) |
|
| 3678 | 3678 | { |
| 3679 | 3679 | //error_log(__METHOD__.' ('.__LINE__.') '.' Using cached Info on Folder:'.$_folder.' for Profile:'.$this->profileID); |
| 3680 | 3680 | return $folderInfo[$this->profileID][$_folder]; |
@@ -3690,7 +3690,7 @@ discard block |
||
| 3690 | 3690 | |
| 3691 | 3691 | // does the folder exist??? |
| 3692 | 3692 | //error_log(__METHOD__."->Connected?".$this->icServer->_connected.", ".$_folder.", ".($forceCheck?' forceCheck activated':'dont check on server')); |
| 3693 | - if ( $forceCheck || empty($folderInfo) || !isset($folderInfo[$this->profileID]) || !isset($folderInfo[$this->profileID][$_folder])) { |
|
| 3693 | + if ($forceCheck || empty($folderInfo) || !isset($folderInfo[$this->profileID]) || !isset($folderInfo[$this->profileID][$_folder])) { |
|
| 3694 | 3694 | //error_log(__METHOD__."->NotConnected and forceCheck with profile:".$this->profileID); |
| 3695 | 3695 | //return false; |
| 3696 | 3696 | //try to connect |
@@ -3701,18 +3701,18 @@ discard block |
||
| 3701 | 3701 | } |
| 3702 | 3702 | catch (\Exception $e) |
| 3703 | 3703 | { |
| 3704 | - error_log(__METHOD__.__LINE__.$e->getMessage().($e->details?', '.$e->details:'')); |
|
| 3705 | - self::$profileDefunct[$this->profileID]=true; |
|
| 3704 | + error_log(__METHOD__.__LINE__.$e->getMessage().($e->details ? ', '.$e->details : '')); |
|
| 3705 | + self::$profileDefunct[$this->profileID] = true; |
|
| 3706 | 3706 | $folderInfo[$this->profileID][$_folder] = false; |
| 3707 | 3707 | } |
| 3708 | 3708 | //error_log(__METHOD__.' ('.__LINE__.') '.' Folder Exists:'.$folderInfo[$this->profileID][$_folder].function_backtrace()); |
| 3709 | 3709 | |
| 3710 | - if(!empty($folderInfo) && isset($folderInfo[$this->profileID][$_folder]) && |
|
| 3710 | + if (!empty($folderInfo) && isset($folderInfo[$this->profileID][$_folder]) && |
|
| 3711 | 3711 | $folderInfo[$this->profileID][$_folder] !== true) |
| 3712 | 3712 | { |
| 3713 | 3713 | $folderInfo[$this->profileID][$_folder] = false; // set to false, whatever it was (to have a valid returnvalue for the static return) |
| 3714 | 3714 | } |
| 3715 | - Cache::setCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderInfo,$expiration=60*60*5); |
|
| 3715 | + Cache::setCache(Cache::INSTANCE, 'email', 'icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']), $folderInfo, $expiration = 60 * 60 * 5); |
|
| 3716 | 3716 | return (!empty($folderInfo) && isset($folderInfo[$this->profileID][$_folder]) ? $folderInfo[$this->profileID][$_folder] : false); |
| 3717 | 3717 | } |
| 3718 | 3718 | |
@@ -3725,14 +3725,14 @@ discard block |
||
| 3725 | 3725 | */ |
| 3726 | 3726 | function compressFolder($_folderName = false) |
| 3727 | 3727 | { |
| 3728 | - $folderName = ($_folderName ? $_folderName : $this->sessionData['mailbox']); |
|
| 3729 | - $deleteOptions = $GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions']; |
|
| 3730 | - $trashFolder = $this->getTrashFolder(); |
|
| 3728 | + $folderName = ($_folderName ? $_folderName : $this->sessionData['mailbox']); |
|
| 3729 | + $deleteOptions = $GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions']; |
|
| 3730 | + $trashFolder = $this->getTrashFolder(); |
|
| 3731 | 3731 | |
| 3732 | 3732 | $this->icServer->openMailbox($folderName); |
| 3733 | 3733 | |
| 3734 | - if(strtolower($folderName) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") { |
|
| 3735 | - $this->deleteMessages('all',$folderName,'remove_immediately'); |
|
| 3734 | + if (strtolower($folderName) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") { |
|
| 3735 | + $this->deleteMessages('all', $folderName, 'remove_immediately'); |
|
| 3736 | 3736 | } else { |
| 3737 | 3737 | $this->icServer->expunge($folderName); |
| 3738 | 3738 | } |
@@ -3748,19 +3748,19 @@ discard block |
||
| 3748 | 3748 | * @return bool true, as we do not handle return values yet |
| 3749 | 3749 | * @throws Exception |
| 3750 | 3750 | */ |
| 3751 | - function deleteMessages($_messageUID, $_folder=NULL, $_forceDeleteMethod='no') |
|
| 3751 | + function deleteMessages($_messageUID, $_folder = NULL, $_forceDeleteMethod = 'no') |
|
| 3752 | 3752 | { |
| 3753 | 3753 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.array2string($_folder).', '.$_forceDeleteMethod); |
| 3754 | 3754 | $oldMailbox = ''; |
| 3755 | 3755 | if (is_null($_folder) || empty($_folder)) $_folder = $this->sessionData['mailbox']; |
| 3756 | 3756 | if (empty($_messageUID)) |
| 3757 | 3757 | { |
| 3758 | - if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID)); |
|
| 3758 | + if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',', $_messageUID)); |
|
| 3759 | 3759 | return false; |
| 3760 | 3760 | } |
| 3761 | - elseif ($_messageUID==='all') |
|
| 3761 | + elseif ($_messageUID === 'all') |
|
| 3762 | 3762 | { |
| 3763 | - $_messageUID= null; |
|
| 3763 | + $_messageUID = null; |
|
| 3764 | 3764 | } |
| 3765 | 3765 | else |
| 3766 | 3766 | { |
@@ -3769,32 +3769,32 @@ discard block |
||
| 3769 | 3769 | $uidsToDelete->add($_messageUID); |
| 3770 | 3770 | } |
| 3771 | 3771 | $deleteOptions = $_forceDeleteMethod; // use forceDeleteMethod if not "no", or unknown method |
| 3772 | - 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"); |
|
| 3772 | + 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"); |
|
| 3773 | 3773 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.$_folder.'/'.$this->sessionData['mailbox'].' Option:'.$deleteOptions); |
| 3774 | 3774 | $trashFolder = $this->getTrashFolder(); |
| 3775 | - $draftFolder = $this->getDraftFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['draftFolder']; |
|
| 3775 | + $draftFolder = $this->getDraftFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['draftFolder']; |
|
| 3776 | 3776 | $templateFolder = $this->getTemplateFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['templateFolder']; |
| 3777 | - if((strtolower($_folder) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") || |
|
| 3777 | + if ((strtolower($_folder) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") || |
|
| 3778 | 3778 | (strtolower($_folder) == strtolower($draftFolder))) { |
| 3779 | 3779 | $deleteOptions = "remove_immediately"; |
| 3780 | 3780 | } |
| 3781 | - if($this->icServer->getCurrentMailbox() != $_folder) { |
|
| 3781 | + if ($this->icServer->getCurrentMailbox() != $_folder) { |
|
| 3782 | 3782 | $oldMailbox = $this->icServer->getCurrentMailbox(); |
| 3783 | 3783 | $this->icServer->openMailbox($_folder); |
| 3784 | 3784 | } |
| 3785 | 3785 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.$_folder.'/'.$this->sessionData['mailbox'].' Option:'.$deleteOptions); |
| 3786 | 3786 | $updateCache = false; |
| 3787 | - switch($deleteOptions) { |
|
| 3787 | + switch ($deleteOptions) { |
|
| 3788 | 3788 | case "move_to_trash": |
| 3789 | 3789 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 3790 | 3790 | $updateCache = true; |
| 3791 | - if(!empty($trashFolder)) { |
|
| 3791 | + if (!empty($trashFolder)) { |
|
| 3792 | 3792 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.implode(' : ', $_messageUID)); |
| 3793 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$trashFolder <= $_folder / ". $this->sessionData['mailbox']); |
|
| 3793 | + if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$trashFolder <= $_folder / ".$this->sessionData['mailbox']); |
|
| 3794 | 3794 | // copy messages |
| 3795 | 3795 | try |
| 3796 | 3796 | { |
| 3797 | - $this->icServer->copy($_folder, $trashFolder, array('ids'=>$uidsToDelete,'move'=>true)); |
|
| 3797 | + $this->icServer->copy($_folder, $trashFolder, array('ids'=>$uidsToDelete, 'move'=>true)); |
|
| 3798 | 3798 | } |
| 3799 | 3799 | catch (\Exception $e) |
| 3800 | 3800 | { |
@@ -3806,18 +3806,18 @@ discard block |
||
| 3806 | 3806 | case "mark_as_deleted": |
| 3807 | 3807 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 3808 | 3808 | // mark messages as deleted |
| 3809 | - if (is_null($_messageUID)) $_messageUID='all'; |
|
| 3810 | - foreach((array)$_messageUID as $key =>$uid) |
|
| 3809 | + if (is_null($_messageUID)) $_messageUID = 'all'; |
|
| 3810 | + foreach ((array)$_messageUID as $key =>$uid) |
|
| 3811 | 3811 | { |
| 3812 | 3812 | //flag messages, that are flagged for deletion as seen too |
| 3813 | 3813 | $this->flagMessages('read', $uid, $_folder); |
| 3814 | 3814 | $flags = $this->getFlags($uid); |
| 3815 | 3815 | $this->flagMessages('delete', $uid, $_folder); |
| 3816 | 3816 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($flags)); |
| 3817 | - if (strpos( array2string($flags),'Deleted')!==false) $undelete[] = $uid; |
|
| 3817 | + if (strpos(array2string($flags), 'Deleted') !== false) $undelete[] = $uid; |
|
| 3818 | 3818 | unset($flags); |
| 3819 | 3819 | } |
| 3820 | - foreach((array)$undelete as $key =>$uid) |
|
| 3820 | + foreach ((array)$undelete as $key =>$uid) |
|
| 3821 | 3821 | { |
| 3822 | 3822 | $this->flagMessages('undelete', $uid, $_folder); |
| 3823 | 3823 | } |
@@ -3826,14 +3826,14 @@ discard block |
||
| 3826 | 3826 | case "remove_immediately": |
| 3827 | 3827 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 3828 | 3828 | $updateCache = true; |
| 3829 | - if (is_null($_messageUID)) $_messageUID='all'; |
|
| 3829 | + if (is_null($_messageUID)) $_messageUID = 'all'; |
|
| 3830 | 3830 | if (is_object($_messageUID)) |
| 3831 | 3831 | { |
| 3832 | 3832 | $this->flagMessages('delete', $_messageUID, $_folder); |
| 3833 | 3833 | } |
| 3834 | 3834 | else |
| 3835 | 3835 | { |
| 3836 | - foreach((array)$_messageUID as $key =>$uid) |
|
| 3836 | + foreach ((array)$_messageUID as $key =>$uid) |
|
| 3837 | 3837 | { |
| 3838 | 3838 | //flag messages, that are flagged for deletion as seen too |
| 3839 | 3839 | $this->flagMessages('delete', $uid, $_folder); |
@@ -3843,7 +3843,7 @@ discard block |
||
| 3843 | 3843 | $this->icServer->expunge($_folder); |
| 3844 | 3844 | break; |
| 3845 | 3845 | } |
| 3846 | - if($oldMailbox != '') { |
|
| 3846 | + if ($oldMailbox != '') { |
|
| 3847 | 3847 | $this->icServer->openMailbox($oldMailbox); |
| 3848 | 3848 | } |
| 3849 | 3849 | |
@@ -3857,7 +3857,7 @@ discard block |
||
| 3857 | 3857 | * |
| 3858 | 3858 | * @return null/array flags |
| 3859 | 3859 | */ |
| 3860 | - function getFlags ($_messageUID) { |
|
| 3860 | + function getFlags($_messageUID) { |
|
| 3861 | 3861 | try |
| 3862 | 3862 | { |
| 3863 | 3863 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
@@ -3870,7 +3870,7 @@ discard block |
||
| 3870 | 3870 | 'ids' => $uidsToFetch, |
| 3871 | 3871 | )); |
| 3872 | 3872 | if (is_object($headersNew)) { |
| 3873 | - foreach($headersNew->ids() as $id) { |
|
| 3873 | + foreach ($headersNew->ids() as $id) { |
|
| 3874 | 3874 | $_headerObject = $headersNew->get($id); |
| 3875 | 3875 | $flags = $_headerObject->getFlags(); |
| 3876 | 3876 | } |
@@ -3893,22 +3893,22 @@ discard block |
||
| 3893 | 3893 | * |
| 3894 | 3894 | * @return null/boolean |
| 3895 | 3895 | */ |
| 3896 | - function getNotifyFlags ($_messageUID, $flags=null) |
|
| 3896 | + function getNotifyFlags($_messageUID, $flags = null) |
|
| 3897 | 3897 | { |
| 3898 | 3898 | if (self::$debug) error_log(__METHOD__.$_messageUID.' Flags:'.array2string($flags)); |
| 3899 | 3899 | try |
| 3900 | 3900 | { |
| 3901 | - if($flags===null) $flags = $this->getFlags($_messageUID); |
|
| 3901 | + if ($flags === null) $flags = $this->getFlags($_messageUID); |
|
| 3902 | 3902 | } |
| 3903 | 3903 | catch (\Exception $e) |
| 3904 | 3904 | { |
| 3905 | 3905 | return null; |
| 3906 | 3906 | } |
| 3907 | 3907 | |
| 3908 | - if ( stripos( array2string($flags),'MDNSent')!==false) |
|
| 3908 | + if (stripos(array2string($flags), 'MDNSent') !== false) |
|
| 3909 | 3909 | return true; |
| 3910 | 3910 | |
| 3911 | - if ( stripos( array2string($flags),'MDNnotSent')!==false) |
|
| 3911 | + if (stripos(array2string($flags), 'MDNnotSent') !== false) |
|
| 3912 | 3912 | return false; |
| 3913 | 3913 | |
| 3914 | 3914 | return null; |
@@ -3925,45 +3925,45 @@ discard block |
||
| 3925 | 3925 | * |
| 3926 | 3926 | * @return bool true, as we do not handle icserver->setFlags returnValue |
| 3927 | 3927 | */ |
| 3928 | - function flagMessages($_flag, $_messageUID,$_folder=NULL) |
|
| 3928 | + function flagMessages($_flag, $_messageUID, $_folder = NULL) |
|
| 3929 | 3929 | { |
| 3930 | 3930 | //error_log(__METHOD__.' ('.__LINE__.') '.'->' .$_flag." ".array2string($_messageUID).",$_folder /".$this->sessionData['mailbox']); |
| 3931 | 3931 | if (empty($_messageUID)) |
| 3932 | 3932 | { |
| 3933 | - if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID)); |
|
| 3933 | + if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',', $_messageUID)); |
|
| 3934 | 3934 | return false; |
| 3935 | 3935 | } |
| 3936 | - $this->icServer->openMailbox(($_folder?$_folder:$this->sessionData['mailbox'])); |
|
| 3936 | + $this->icServer->openMailbox(($_folder ? $_folder : $this->sessionData['mailbox'])); |
|
| 3937 | 3937 | $folder = $this->icServer->getCurrentMailbox(); |
| 3938 | - if (is_array($_messageUID)&& count($_messageUID)>50) |
|
| 3938 | + if (is_array($_messageUID) && count($_messageUID) > 50) |
|
| 3939 | 3939 | { |
| 3940 | - $count = $this->getMailBoxCounters($folder,true); |
|
| 3941 | - if ($count->messages == count($_messageUID)) $_messageUID='all'; |
|
| 3940 | + $count = $this->getMailBoxCounters($folder, true); |
|
| 3941 | + if ($count->messages == count($_messageUID)) $_messageUID = 'all'; |
|
| 3942 | 3942 | } |
| 3943 | 3943 | |
| 3944 | - if ($_messageUID==='all') |
|
| 3944 | + if ($_messageUID === 'all') |
|
| 3945 | 3945 | { |
| 3946 | 3946 | $messageUIDs = array('all'); |
| 3947 | 3947 | } |
| 3948 | 3948 | else |
| 3949 | 3949 | { |
| 3950 | 3950 | if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID; |
| 3951 | - $messageUIDs = array_chunk($_messageUID,50,true); |
|
| 3951 | + $messageUIDs = array_chunk($_messageUID, 50, true); |
|
| 3952 | 3952 | } |
| 3953 | 3953 | try |
| 3954 | 3954 | { |
| 3955 | - foreach($messageUIDs as &$uids) |
|
| 3955 | + foreach ($messageUIDs as &$uids) |
|
| 3956 | 3956 | { |
| 3957 | - if ($uids==='all') |
|
| 3957 | + if ($uids === 'all') |
|
| 3958 | 3958 | { |
| 3959 | - $uidsToModify=null; |
|
| 3959 | + $uidsToModify = null; |
|
| 3960 | 3960 | } |
| 3961 | 3961 | else |
| 3962 | 3962 | { |
| 3963 | 3963 | $uidsToModify = new Horde_Imap_Client_Ids(); |
| 3964 | 3964 | $uidsToModify->add($uids); |
| 3965 | 3965 | } |
| 3966 | - switch($_flag) { |
|
| 3966 | + switch ($_flag) { |
|
| 3967 | 3967 | case "delete": |
| 3968 | 3968 | $ret = $this->icServer->store($folder, array('add'=>array('\\Deleted'), 'ids'=> $uidsToModify)); |
| 3969 | 3969 | break; |
@@ -3987,7 +3987,7 @@ discard block |
||
| 3987 | 3987 | break; |
| 3988 | 3988 | case "unread": |
| 3989 | 3989 | case "unseen": |
| 3990 | - $ret = $this->icServer->store($folder, array('remove'=>array('\\Seen','\\Answered','$Forwarded'), 'ids'=> $uidsToModify)); |
|
| 3990 | + $ret = $this->icServer->store($folder, array('remove'=>array('\\Seen', '\\Answered', '$Forwarded'), 'ids'=> $uidsToModify)); |
|
| 3991 | 3991 | break; |
| 3992 | 3992 | case "mdnsent": |
| 3993 | 3993 | $ret = $this->icServer->store($folder, array('add'=>array('MDNSent'), 'ids'=> $uidsToModify)); |
@@ -4045,13 +4045,13 @@ discard block |
||
| 4045 | 4045 | } |
| 4046 | 4046 | } |
| 4047 | 4047 | } |
| 4048 | - catch(Exception $e) |
|
| 4048 | + catch (Exception $e) |
|
| 4049 | 4049 | { |
| 4050 | 4050 | error_log(__METHOD__.__LINE__.' Error, could not flag messages in folder '.$folder.' Reason:'.$e->getMessage()); |
| 4051 | 4051 | } |
| 4052 | 4052 | if ($folder instanceof Horde_Imap_Client_Mailbox) $_folder = $folder->utf8; |
| 4053 | 4053 | //error_log(__METHOD__.__LINE__.'#'.$this->icServer->ImapServerId.'#'.array2string($_folder).'#'); |
| 4054 | - self::$folderStatusCache[$this->icServer->ImapServerId][(!empty($_folder)?$_folder: $this->sessionData['mailbox'])]['uidValidity'] = 0; |
|
| 4054 | + self::$folderStatusCache[$this->icServer->ImapServerId][(!empty($_folder) ? $_folder : $this->sessionData['mailbox'])]['uidValidity'] = 0; |
|
| 4055 | 4055 | |
| 4056 | 4056 | //error_log(__METHOD__.' ('.__LINE__.') '.'->' .$_flag." ".array2string($_messageUID).",".($_folder?$_folder:$this->sessionData['mailbox'])); |
| 4057 | 4057 | return true; // as we do not catch/examine setFlags returnValue |
@@ -4072,19 +4072,19 @@ discard block |
||
| 4072 | 4072 | * @return mixed/bool true,false or new uid |
| 4073 | 4073 | * @throws Exception |
| 4074 | 4074 | */ |
| 4075 | - function moveMessages($_foldername, $_messageUID, $deleteAfterMove=true, $currentFolder = Null, $returnUIDs = false, $_sourceProfileID = Null, $_targetProfileID = Null) |
|
| 4075 | + function moveMessages($_foldername, $_messageUID, $deleteAfterMove = true, $currentFolder = Null, $returnUIDs = false, $_sourceProfileID = Null, $_targetProfileID = Null) |
|
| 4076 | 4076 | { |
| 4077 | - $source = Mail\Account::read(($_sourceProfileID?$_sourceProfileID:$this->icServer->ImapServerId))->imapServer(); |
|
| 4077 | + $source = Mail\Account::read(($_sourceProfileID ? $_sourceProfileID : $this->icServer->ImapServerId))->imapServer(); |
|
| 4078 | 4078 | //$deleteOptions = $GLOBALS['egw_info']["user"]["preferences"]["mail"]["deleteOptions"]; |
| 4079 | 4079 | if (empty($_messageUID)) |
| 4080 | 4080 | { |
| 4081 | - if (self::$debug) error_log(__METHOD__." no Message(s): ".implode(',',$_messageUID)); |
|
| 4081 | + if (self::$debug) error_log(__METHOD__." no Message(s): ".implode(',', $_messageUID)); |
|
| 4082 | 4082 | return false; |
| 4083 | 4083 | } |
| 4084 | - elseif ($_messageUID==='all') |
|
| 4084 | + elseif ($_messageUID === 'all') |
|
| 4085 | 4085 | { |
| 4086 | 4086 | //error_log(__METHOD__." all Message(s): ".implode(',',$_messageUID)); |
| 4087 | - $uidsToMove= null; |
|
| 4087 | + $uidsToMove = null; |
|
| 4088 | 4088 | } |
| 4089 | 4089 | else |
| 4090 | 4090 | { |
@@ -4093,7 +4093,7 @@ discard block |
||
| 4093 | 4093 | if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID; |
| 4094 | 4094 | $uidsToMove->add($_messageUID); |
| 4095 | 4095 | } |
| 4096 | - $sourceFolder = (!empty($currentFolder)?$currentFolder: $this->sessionData['mailbox']); |
|
| 4096 | + $sourceFolder = (!empty($currentFolder) ? $currentFolder : $this->sessionData['mailbox']); |
|
| 4097 | 4097 | //error_log(__METHOD__.__LINE__."$_targetProfileID !== ".array2string($source->ImapServerId)); |
| 4098 | 4098 | if (!is_null($_targetProfileID) && $_targetProfileID !== $source->ImapServerId) |
| 4099 | 4099 | { |
@@ -4113,19 +4113,19 @@ discard block |
||
| 4113 | 4113 | //error_log(__METHOD__.' ('.__LINE__.') '.' Sourceserver:'.$source->ImapServerId.' mailheaders:'.array2string($headersNew)); |
| 4114 | 4114 | |
| 4115 | 4115 | if (is_object($headersNew)) { |
| 4116 | - $c=0; |
|
| 4116 | + $c = 0; |
|
| 4117 | 4117 | $retUid = new Horde_Imap_Client_Ids(); |
| 4118 | 4118 | // we copy chunks of 5 to avoid too much memory and/or server stress |
| 4119 | 4119 | // some servers seem not to allow/support the appendig of multiple messages. so we are down to one |
| 4120 | - foreach($headersNew as &$_headerObject) { |
|
| 4120 | + foreach ($headersNew as &$_headerObject) { |
|
| 4121 | 4121 | $c++; |
| 4122 | 4122 | $flags = $_headerObject->getFlags(); //unseen status seems to be lost when retrieving the full message |
| 4123 | 4123 | $date = $_headerObject->getImapDate(); |
| 4124 | - $currentDate = new Horde_Imap_Client_DateTime(); |
|
| 4124 | + $currentDate = new Horde_Imap_Client_DateTime(); |
|
| 4125 | 4125 | // if the internal Date of the message equals the current date; try using the header date |
| 4126 | - if ($date==$currentDate) |
|
| 4126 | + if ($date == $currentDate) |
|
| 4127 | 4127 | { |
| 4128 | - $headerForPrio = array_change_key_case($_headerObject->getHeaderText(0,Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(), CASE_UPPER); |
|
| 4128 | + $headerForPrio = array_change_key_case($_headerObject->getHeaderText(0, Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(), CASE_UPPER); |
|
| 4129 | 4129 | //error_log(__METHOD__.__LINE__.'#'.array2string($date).'#'.array2string($currentDate).'#'.$headerForPrio['DATE']); |
| 4130 | 4130 | $date = new Horde_Imap_Client_DateTime($headerForPrio['DATE']); |
| 4131 | 4131 | //error_log(__METHOD__.__LINE__.'#'.array2string($date).'#'.array2string($currentDate).'#'); |
@@ -4134,20 +4134,20 @@ discard block |
||
| 4134 | 4134 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($flags)); |
| 4135 | 4135 | $body = $_headerObject->getFullMsg(); |
| 4136 | 4136 | $dataNflags[] = array('data'=>$body, 'flags'=>$flags, 'internaldate'=>$date); |
| 4137 | - if ($c==1) |
|
| 4137 | + if ($c == 1) |
|
| 4138 | 4138 | { |
| 4139 | 4139 | $target = Mail\Account::read($_targetProfileID)->imapServer(); |
| 4140 | 4140 | //error_log(__METHOD__.' ('.__LINE__.') '.' Sourceserver:'.$source->ImapServerId.' TargetServer:'.$_targetProfileID.' TargetFolderObject:'.array2string($_foldername)); |
| 4141 | 4141 | $foldername = $target->getMailbox($_foldername); |
| 4142 | 4142 | // make sure the target folder is open and ready |
| 4143 | 4143 | $target->openMailbox($foldername); |
| 4144 | - $ret = $target->append($foldername,$dataNflags); |
|
| 4144 | + $ret = $target->append($foldername, $dataNflags); |
|
| 4145 | 4145 | $retUid->add($ret); |
| 4146 | 4146 | unset($dataNflags); |
| 4147 | 4147 | // sleep 500 miliseconds; AS some sERVERs seem not to be capable of the load this is |
| 4148 | 4148 | // inflicting in them. they "reply" with an unspecific IMAP Error |
| 4149 | - time_nanosleep(0,500000); |
|
| 4150 | - $c=0; |
|
| 4149 | + time_nanosleep(0, 500000); |
|
| 4150 | + $c = 0; |
|
| 4151 | 4151 | } |
| 4152 | 4152 | } |
| 4153 | 4153 | if (isset($dataNflags)) |
@@ -4157,7 +4157,7 @@ discard block |
||
| 4157 | 4157 | $foldername = $target->getMailbox($_foldername); |
| 4158 | 4158 | // make sure the target folder is open and ready |
| 4159 | 4159 | $target->openMailbox($foldername); |
| 4160 | - $ret = $target->append($foldername,$dataNflags); |
|
| 4160 | + $ret = $target->append($foldername, $dataNflags); |
|
| 4161 | 4161 | $retUid->add($ret); |
| 4162 | 4162 | unset($dataNflags); |
| 4163 | 4163 | } |
@@ -4168,7 +4168,7 @@ discard block |
||
| 4168 | 4168 | { |
| 4169 | 4169 | $remember = $this->icServer; |
| 4170 | 4170 | $this->icServer = $source; |
| 4171 | - $this->deleteMessages($_messageUID, $sourceFolder, $_forceDeleteMethod='remove_immediately'); |
|
| 4171 | + $this->deleteMessages($_messageUID, $sourceFolder, $_forceDeleteMethod = 'remove_immediately'); |
|
| 4172 | 4172 | $this->icServer = $remember; |
| 4173 | 4173 | } |
| 4174 | 4174 | } |
@@ -4177,7 +4177,7 @@ discard block |
||
| 4177 | 4177 | { |
| 4178 | 4178 | try |
| 4179 | 4179 | { |
| 4180 | - $retUid = $source->copy($sourceFolder, $_foldername, array('ids'=>$uidsToMove,'move'=>$deleteAfterMove)); |
|
| 4180 | + $retUid = $source->copy($sourceFolder, $_foldername, array('ids'=>$uidsToMove, 'move'=>$deleteAfterMove)); |
|
| 4181 | 4181 | } |
| 4182 | 4182 | catch (exception $e) |
| 4183 | 4183 | { |
@@ -4197,19 +4197,19 @@ discard block |
||
| 4197 | 4197 | * @param string $format ='' if none is passed, use user prefs |
| 4198 | 4198 | * @return string returns the date as it is parseable by strtotime, or current timestamp if everything fails |
| 4199 | 4199 | */ |
| 4200 | - static function _strtotime($_date='', $format='', $convert2usertime=false) |
|
| 4200 | + static function _strtotime($_date = '', $format = '', $convert2usertime = false) |
|
| 4201 | 4201 | { |
| 4202 | 4202 | try { |
| 4203 | - $date = new DateTime($_date); // parse date & time including timezone (throws exception, if not parsable) |
|
| 4204 | - if ($convert2usertime) $date->setUser(); // convert to user-time |
|
| 4203 | + $date = new DateTime($_date); // parse date & time including timezone (throws exception, if not parsable) |
|
| 4204 | + if ($convert2usertime) $date->setUser(); // convert to user-time |
|
| 4205 | 4205 | $date2return = $date->format($format); |
| 4206 | 4206 | } |
| 4207 | - catch(\Exception $e) |
|
| 4207 | + catch (\Exception $e) |
|
| 4208 | 4208 | { |
| 4209 | - unset($e); // not used |
|
| 4209 | + unset($e); // not used |
|
| 4210 | 4210 | |
| 4211 | 4211 | // remove last space-separated part and retry |
| 4212 | - $parts = explode(' ',$_date); |
|
| 4212 | + $parts = explode(' ', $_date); |
|
| 4213 | 4213 | if (count($parts) > 1) |
| 4214 | 4214 | { |
| 4215 | 4215 | array_pop($parts); |
@@ -4230,12 +4230,12 @@ discard block |
||
| 4230 | 4230 | * @param mixed $_charset false or string -> Target charset, if false Mail displayCharset will be used |
| 4231 | 4231 | * @return string |
| 4232 | 4232 | */ |
| 4233 | - static function htmlentities($_string, $_charset=false) |
|
| 4233 | + static function htmlentities($_string, $_charset = false) |
|
| 4234 | 4234 | { |
| 4235 | 4235 | //setting the charset (if not given) |
| 4236 | - if ($_charset===false) $_charset = self::$displayCharset; |
|
| 4236 | + if ($_charset === false) $_charset = self::$displayCharset; |
|
| 4237 | 4237 | $string = @htmlentities($_string, ENT_QUOTES, $_charset, false); |
| 4238 | - if (empty($string) && !empty($_string)) $string = @htmlentities(Translation::convert($_string,Translation::detect_encoding($_string),$_charset),ENT_QUOTES | ENT_IGNORE,$_charset, false); |
|
| 4238 | + if (empty($string) && !empty($_string)) $string = @htmlentities(Translation::convert($_string, Translation::detect_encoding($_string), $_charset), ENT_QUOTES|ENT_IGNORE, $_charset, false); |
|
| 4239 | 4239 | return $string; |
| 4240 | 4240 | } |
| 4241 | 4241 | |
@@ -4252,21 +4252,21 @@ discard block |
||
| 4252 | 4252 | //$_html = str_replace("\t",' ',$_html); |
| 4253 | 4253 | //error_log(__METHOD__.__LINE__.':'.$_html); |
| 4254 | 4254 | //repair doubleencoded ampersands, and some stuff htmLawed stumbles upon with balancing switched on |
| 4255 | - $_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>'), |
|
| 4256 | - array('&', '<BR>', '<BR>', '<BR>', '</font></td>','<td>', '', '', '', ''),$_html); |
|
| 4255 | + $_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>'), |
|
| 4256 | + array('&', '<BR>', '<BR>', '<BR>', '</font></td>', '<td>', '', '', '', ''), $_html); |
|
| 4257 | 4257 | //$_html = str_replace(array('&amp;'),array('&'),$_html); |
| 4258 | - if (stripos($_html,'style')!==false) Mail\Html::replaceTagsCompletley($_html,'style'); // clean out empty or pagewide style definitions / left over tags |
|
| 4259 | - if (stripos($_html,'head')!==false) Mail\Html::replaceTagsCompletley($_html,'head'); // Strip out stuff in head |
|
| 4258 | + if (stripos($_html, 'style') !== false) Mail\Html::replaceTagsCompletley($_html, 'style'); // clean out empty or pagewide style definitions / left over tags |
|
| 4259 | + if (stripos($_html, 'head') !== false) Mail\Html::replaceTagsCompletley($_html, 'head'); // Strip out stuff in head |
|
| 4260 | 4260 | //if (stripos($_html,'![if')!==false && stripos($_html,'<![endif]>')!==false) Mail\Html::replaceTagsCompletley($_html,'!\[if','<!\[endif\]>',false); // Strip out stuff in ifs |
| 4261 | 4261 | //if (stripos($_html,'!--[if')!==false && stripos($_html,'<![endif]-->')!==false) Mail\Html::replaceTagsCompletley($_html,'!--\[if','<!\[endif\]-->',false); // Strip out stuff in ifs |
| 4262 | 4262 | //error_log(__METHOD__.' ('.__LINE__.') '.$_html); |
| 4263 | 4263 | |
| 4264 | 4264 | if (get_magic_quotes_gpc() === 1) $_html = stripslashes($_html); |
| 4265 | 4265 | // Strip out doctype in head, as htmlLawed cannot handle it TODO: Consider extracting it and adding it afterwards |
| 4266 | - if (stripos($_html,'!doctype')!==false) Mail\Html::replaceTagsCompletley($_html,'!doctype'); |
|
| 4267 | - if (stripos($_html,'?xml:namespace')!==false) Mail\Html::replaceTagsCompletley($_html,'\?xml:namespace','/>',false); |
|
| 4268 | - if (stripos($_html,'?xml version')!==false) Mail\Html::replaceTagsCompletley($_html,'\?xml version','\?>',false); |
|
| 4269 | - if (strpos($_html,'!CURSOR')!==false) Mail\Html::replaceTagsCompletley($_html,'!CURSOR'); |
|
| 4266 | + if (stripos($_html, '!doctype') !== false) Mail\Html::replaceTagsCompletley($_html, '!doctype'); |
|
| 4267 | + if (stripos($_html, '?xml:namespace') !== false) Mail\Html::replaceTagsCompletley($_html, '\?xml:namespace', '/>', false); |
|
| 4268 | + if (stripos($_html, '?xml version') !== false) Mail\Html::replaceTagsCompletley($_html, '\?xml version', '\?>', false); |
|
| 4269 | + if (strpos($_html, '!CURSOR') !== false) Mail\Html::replaceTagsCompletley($_html, '!CURSOR'); |
|
| 4270 | 4270 | // htmLawed filter only the 'body' |
| 4271 | 4271 | //preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $_html, $matches); |
| 4272 | 4272 | //if ($matches[2]) |
@@ -4277,16 +4277,16 @@ discard block |
||
| 4277 | 4277 | // purify got switched to htmLawed |
| 4278 | 4278 | // some testcode to test purifying / htmlawed |
| 4279 | 4279 | //$_html = "<BLOCKQUOTE>hi <div> there </div> kram <br> </blockquote>".$_html; |
| 4280 | - $_html = Html\HtmLawed::purify($_html,self::$htmLawed_config,array(),true); |
|
| 4280 | + $_html = Html\HtmLawed::purify($_html, self::$htmLawed_config, array(), true); |
|
| 4281 | 4281 | //if ($hasOther) $_html = $matches[1]. $_html. $matches[3]; |
| 4282 | 4282 | // clean out comments , should not be needed as purify should do the job. |
| 4283 | 4283 | $search = array( |
| 4284 | - '@url\(http:\/\/[^\)].*?\)@si', // url calls e.g. in style definitions |
|
| 4285 | - '@<!--[\s\S]*?[ \t\n\r]*-->@', // Strip multi-line comments including CDATA |
|
| 4284 | + '@url\(http:\/\/[^\)].*?\)@si', // url calls e.g. in style definitions |
|
| 4285 | + '@<!--[\s\S]*?[ \t\n\r]*-->@', // Strip multi-line comments including CDATA |
|
| 4286 | 4286 | ); |
| 4287 | - $_html = preg_replace($search,"",$_html); |
|
| 4287 | + $_html = preg_replace($search, "", $_html); |
|
| 4288 | 4288 | // remove non printable chars |
| 4289 | - $_html = preg_replace('/([\000-\011])/','',$_html); |
|
| 4289 | + $_html = preg_replace('/([\000-\011])/', '', $_html); |
|
| 4290 | 4290 | //error_log(__METHOD__.':'.__LINE__.':'.$_html); |
| 4291 | 4291 | } |
| 4292 | 4292 | |
@@ -4303,12 +4303,12 @@ discard block |
||
| 4303 | 4303 | function getMimePartCharset($_mimePartObject) |
| 4304 | 4304 | { |
| 4305 | 4305 | //$charSet = 'iso-8859-1';//self::$displayCharset; //'iso-8859-1'; // self::displayCharset seems to be asmarter fallback than iso-8859-1 |
| 4306 | - $CharsetFound=false; |
|
| 4306 | + $CharsetFound = false; |
|
| 4307 | 4307 | //echo "#".$_mimePartObject->encoding.'#<br>'; |
| 4308 | - if(is_array($_mimePartObject->parameters)) { |
|
| 4309 | - if(isset($_mimePartObject->parameters['CHARSET'])) { |
|
| 4308 | + if (is_array($_mimePartObject->parameters)) { |
|
| 4309 | + if (isset($_mimePartObject->parameters['CHARSET'])) { |
|
| 4310 | 4310 | $charSet = $_mimePartObject->parameters['CHARSET']; |
| 4311 | - $CharsetFound=true; |
|
| 4311 | + $CharsetFound = true; |
|
| 4312 | 4312 | } |
| 4313 | 4313 | } |
| 4314 | 4314 | // this one is dirty, but until I find something that does the trick of detecting the encoding, .... |
@@ -4327,7 +4327,7 @@ discard block |
||
| 4327 | 4327 | function decodeMimePart($_mimeMessage, $_encoding, $_charset = '') |
| 4328 | 4328 | { |
| 4329 | 4329 | // decode the part |
| 4330 | - if (self::$debug) error_log(__METHOD__."() with $_encoding and $_charset:".print_r($_mimeMessage,true)); |
|
| 4330 | + if (self::$debug) error_log(__METHOD__."() with $_encoding and $_charset:".print_r($_mimeMessage, true)); |
|
| 4331 | 4331 | switch (strtoupper($_encoding)) |
| 4332 | 4332 | { |
| 4333 | 4333 | case 'BASE64': |
@@ -4367,10 +4367,10 @@ discard block |
||
| 4367 | 4367 | // sometimes there are 3 parts, when there is an ics/ical attached/included-> we want to show that |
| 4368 | 4368 | // as attachment AND as abstracted ical information (we use our notification style here). |
| 4369 | 4369 | $partText = $partCalendar = $partHTML = null; |
| 4370 | - if (self::$debug) _debug_array(array("METHOD"=>__METHOD__,"LINE"=>__LINE__,"STRUCTURE"=>$_structure)); |
|
| 4370 | + if (self::$debug) _debug_array(array("METHOD"=>__METHOD__, "LINE"=>__LINE__, "STRUCTURE"=>$_structure)); |
|
| 4371 | 4371 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 4372 | 4372 | $ignore_first_part = true; |
| 4373 | - foreach($_structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 4373 | + foreach ($_structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 4374 | 4374 | { |
| 4375 | 4375 | //error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") $mime_id: $mime_type"." ignoreFirstPart:".$ignore_first_part); |
| 4376 | 4376 | if (self::$debug) echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>"; |
@@ -4378,15 +4378,15 @@ discard block |
||
| 4378 | 4378 | if ($ignore_first_part) |
| 4379 | 4379 | { |
| 4380 | 4380 | $ignore_first_part = false; |
| 4381 | - continue; // ignore multipart/alternative itself |
|
| 4381 | + continue; // ignore multipart/alternative itself |
|
| 4382 | 4382 | } |
| 4383 | 4383 | |
| 4384 | 4384 | $mimePart = $_structure->getPart($mime_id); |
| 4385 | 4385 | |
| 4386 | - switch($mimePart->getPrimaryType()) |
|
| 4386 | + switch ($mimePart->getPrimaryType()) |
|
| 4387 | 4387 | { |
| 4388 | 4388 | case 'text': |
| 4389 | - switch($mimePart->getSubType()) |
|
| 4389 | + switch ($mimePart->getSubType()) |
|
| 4390 | 4390 | { |
| 4391 | 4391 | case 'plain': |
| 4392 | 4392 | if ($mimePart->getBytes() > 0) $partText = $mimePart; |
@@ -4399,7 +4399,7 @@ discard block |
||
| 4399 | 4399 | break; |
| 4400 | 4400 | |
| 4401 | 4401 | case 'multipart': |
| 4402 | - switch($mimePart->getSubType()) |
|
| 4402 | + switch ($mimePart->getSubType()) |
|
| 4403 | 4403 | { |
| 4404 | 4404 | case 'related': |
| 4405 | 4405 | case 'mixed': |
@@ -4421,13 +4421,13 @@ discard block |
||
| 4421 | 4421 | } |
| 4422 | 4422 | } |
| 4423 | 4423 | |
| 4424 | - switch($_htmlMode) |
|
| 4424 | + switch ($_htmlMode) |
|
| 4425 | 4425 | { |
| 4426 | 4426 | case 'html_only': |
| 4427 | 4427 | case 'always_display': |
| 4428 | 4428 | if ($partHTML) |
| 4429 | 4429 | { |
| 4430 | - switch($partHTML->getSubType()) |
|
| 4430 | + switch ($partHTML->getSubType()) |
|
| 4431 | 4431 | { |
| 4432 | 4432 | case 'related': |
| 4433 | 4433 | return $this->getMultipartRelated($_uid, $partHTML, $_htmlMode, $_preserveSeen); |
@@ -4439,7 +4439,7 @@ discard block |
||
| 4439 | 4439 | return $this->getTextPart($_uid, $partHTML, $_htmlMode, $_preserveSeen); |
| 4440 | 4440 | } |
| 4441 | 4441 | } |
| 4442 | - elseif ($partText && $_htmlMode=='always_display') |
|
| 4442 | + elseif ($partText && $_htmlMode == 'always_display') |
|
| 4443 | 4443 | { |
| 4444 | 4444 | return $this->getTextPart($_uid, $partText, $_htmlMode, $_preserveSeen); |
| 4445 | 4445 | } |
@@ -4485,7 +4485,7 @@ discard block |
||
| 4485 | 4485 | * @param array &$skipParts - passed by reference to have control/knowledge which parts are already fetched |
| 4486 | 4486 | * @return array containing the desired part |
| 4487 | 4487 | */ |
| 4488 | - function getMultipartMixed($_uid, Horde_Mime_Part $_structure, $_htmlMode, $_preserveSeen = false, &$skipParts=array()) |
|
| 4488 | + function getMultipartMixed($_uid, Horde_Mime_Part $_structure, $_htmlMode, $_preserveSeen = false, &$skipParts = array()) |
|
| 4489 | 4489 | { |
| 4490 | 4490 | if (self::$debug) echo __METHOD__."$_uid, $_htmlMode<br>"; |
| 4491 | 4491 | $bodyPart = array(); |
@@ -4494,7 +4494,7 @@ discard block |
||
| 4494 | 4494 | $ignore_first_part = true; |
| 4495 | 4495 | //$skipParts = array(); |
| 4496 | 4496 | //error_log(__METHOD__.__LINE__.array2string($_structure->contentTypeMap())); |
| 4497 | - foreach($_structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 4497 | + foreach ($_structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 4498 | 4498 | { |
| 4499 | 4499 | //error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") $mime_id: $mime_type"); |
| 4500 | 4500 | if (self::$debug) echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>"; |
@@ -4502,9 +4502,9 @@ discard block |
||
| 4502 | 4502 | { |
| 4503 | 4503 | $ignore_first_part = false; |
| 4504 | 4504 | //error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") SKIPPED FirstPart $mime_id: $mime_type"); |
| 4505 | - continue; // ignore multipart/mixed itself |
|
| 4505 | + continue; // ignore multipart/mixed itself |
|
| 4506 | 4506 | } |
| 4507 | - if (array_key_exists($mime_id,$skipParts)) |
|
| 4507 | + if (array_key_exists($mime_id, $skipParts)) |
|
| 4508 | 4508 | { |
| 4509 | 4509 | //error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") SKIPPED $mime_id: $mime_type"); |
| 4510 | 4510 | continue; |
@@ -4512,11 +4512,11 @@ discard block |
||
| 4512 | 4512 | |
| 4513 | 4513 | $part = $_structure->getPart($mime_id); |
| 4514 | 4514 | |
| 4515 | - switch($part->getPrimaryType()) |
|
| 4515 | + switch ($part->getPrimaryType()) |
|
| 4516 | 4516 | { |
| 4517 | 4517 | case 'multipart': |
| 4518 | 4518 | if ($part->getDisposition() == 'attachment') continue; |
| 4519 | - switch($part->getSubType()) |
|
| 4519 | + switch ($part->getSubType()) |
|
| 4520 | 4520 | { |
| 4521 | 4521 | case 'alternative': |
| 4522 | 4522 | return array($this->getMultipartAlternative($_uid, $part, $_htmlMode, $_preserveSeen)); |
@@ -4532,15 +4532,15 @@ discard block |
||
| 4532 | 4532 | } |
| 4533 | 4533 | break; |
| 4534 | 4534 | case 'application': |
| 4535 | - switch($part->getSubType()) |
|
| 4535 | + switch ($part->getSubType()) |
|
| 4536 | 4536 | { |
| 4537 | 4537 | case 'pgp-encrypted': |
| 4538 | - if (($part = $_structure->getPart($mime_id+1)) && |
|
| 4538 | + if (($part = $_structure->getPart($mime_id + 1)) && |
|
| 4539 | 4539 | $part->getType() == 'application/octet-stream') |
| 4540 | 4540 | { |
| 4541 | 4541 | $this->fetchPartContents($_uid, $part); |
| 4542 | - $skipParts[$mime_id]=$mime_type; |
|
| 4543 | - $skipParts[$mime_id+1]=$part->getType(); |
|
| 4542 | + $skipParts[$mime_id] = $mime_type; |
|
| 4543 | + $skipParts[$mime_id + 1] = $part->getType(); |
|
| 4544 | 4544 | $bodyPart[] = array( |
| 4545 | 4545 | 'body' => $part->getContents(array( |
| 4546 | 4546 | 'stream' => false, |
@@ -4554,15 +4554,15 @@ discard block |
||
| 4554 | 4554 | break; |
| 4555 | 4555 | |
| 4556 | 4556 | case 'text': |
| 4557 | - switch($part->getSubType()) |
|
| 4557 | + switch ($part->getSubType()) |
|
| 4558 | 4558 | { |
| 4559 | 4559 | case 'plain': |
| 4560 | 4560 | case 'html': |
| 4561 | 4561 | case 'calendar': // inline ics/ical files |
| 4562 | - if($part->getDisposition() != 'attachment') |
|
| 4562 | + if ($part->getDisposition() != 'attachment') |
|
| 4563 | 4563 | { |
| 4564 | 4564 | $bodyPart[] = $this->getTextPart($_uid, $part, $_htmlMode, $_preserveSeen); |
| 4565 | - $skipParts[$mime_id]=$mime_type; |
|
| 4565 | + $skipParts[$mime_id] = $mime_type; |
|
| 4566 | 4566 | } |
| 4567 | 4567 | //error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$part->type."/".$part->subType.' -> BodyPart:'.array2string($bodyPart[count($bodyPart)-1])); |
| 4568 | 4568 | break; |
@@ -4571,16 +4571,16 @@ discard block |
||
| 4571 | 4571 | |
| 4572 | 4572 | case 'message': |
| 4573 | 4573 | //skip attachments |
| 4574 | - if($part->getSubType() == 'delivery-status' && $part->getDisposition() != 'attachment') |
|
| 4574 | + if ($part->getSubType() == 'delivery-status' && $part->getDisposition() != 'attachment') |
|
| 4575 | 4575 | { |
| 4576 | 4576 | $bodyPart[] = $this->getTextPart($_uid, $part, $_htmlMode, $_preserveSeen); |
| 4577 | - $skipParts[$mime_id]=$mime_type; |
|
| 4577 | + $skipParts[$mime_id] = $mime_type; |
|
| 4578 | 4578 | } |
| 4579 | 4579 | // do not descend into attached Messages |
| 4580 | - if($part->getSubType() == 'rfc822' || $part->getDisposition() == 'attachment') |
|
| 4580 | + if ($part->getSubType() == 'rfc822' || $part->getDisposition() == 'attachment') |
|
| 4581 | 4581 | { |
| 4582 | 4582 | $skipParts[$mime_id.'.0'] = $mime_type; |
| 4583 | - foreach($part->contentTypeMap() as $sub_id => $sub_type){ $skipParts[$sub_id] = $sub_type;} |
|
| 4583 | + foreach ($part->contentTypeMap() as $sub_id => $sub_type) { $skipParts[$sub_id] = $sub_type; } |
|
| 4584 | 4584 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$_uid.' Part:'.$mime_id.':'.array2string($skipParts)); |
| 4585 | 4585 | //break 2; |
| 4586 | 4586 | } |
@@ -4621,13 +4621,13 @@ discard block |
||
| 4621 | 4621 | * @param boolean $_tryDecodingServerside = true; wether to try to fetch Data with BINARY instead of BODY |
| 4622 | 4622 | * @return string|resource |
| 4623 | 4623 | */ |
| 4624 | - function getBodyPart($_uid, $_partID=null, $_folder=null, $_preserveSeen=false, $_stream=false, &$_encoding=null, $_tryDecodingServerside=true) |
|
| 4624 | + function getBodyPart($_uid, $_partID = null, $_folder = null, $_preserveSeen = false, $_stream = false, &$_encoding = null, $_tryDecodingServerside = true) |
|
| 4625 | 4625 | { |
| 4626 | - if (self::$debug) error_log( __METHOD__.__LINE__."(".array2string($_uid).", $_partID, $_folder, $_preserveSeen, $_stream, $_encoding, $_tryDecodingServerside)"); |
|
| 4626 | + if (self::$debug) error_log(__METHOD__.__LINE__."(".array2string($_uid).", $_partID, $_folder, $_preserveSeen, $_stream, $_encoding, $_tryDecodingServerside)"); |
|
| 4627 | 4627 | |
| 4628 | 4628 | if (empty($_folder)) |
| 4629 | 4629 | { |
| 4630 | - $_folder = (isset($this->sessionData['mailbox'])&&$this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 4630 | + $_folder = (isset($this->sessionData['mailbox']) && $this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 4631 | 4631 | } |
| 4632 | 4632 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_folder).'/'.$this->icServer->getCurrentMailbox().'/'. $this->sessionData['mailbox']); |
| 4633 | 4633 | // querying contents of body part |
@@ -4638,11 +4638,11 @@ discard block |
||
| 4638 | 4638 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
| 4639 | 4639 | $fetchParams = array( |
| 4640 | 4640 | 'peek' => $_preserveSeen, |
| 4641 | - 'decode' => true, // try decode on server, does NOT neccessary work |
|
| 4641 | + 'decode' => true, // try decode on server, does NOT neccessary work |
|
| 4642 | 4642 | ); |
| 4643 | - if ($_tryDecodingServerside===false)// || ($_tryDecodingServerside&&$this->isDraftFolder($_folder))) |
|
| 4643 | + if ($_tryDecodingServerside === false)// || ($_tryDecodingServerside&&$this->isDraftFolder($_folder))) |
|
| 4644 | 4644 | { |
| 4645 | - $_tryDecodingServerside=false; |
|
| 4645 | + $_tryDecodingServerside = false; |
|
| 4646 | 4646 | $fetchParams = array( |
| 4647 | 4647 | 'peek' => $_preserveSeen, |
| 4648 | 4648 | ); |
@@ -4662,12 +4662,12 @@ discard block |
||
| 4662 | 4662 | } |
| 4663 | 4663 | // if we get an empty result, server may have trouble fetching data with UID FETCH $_uid (BINARY.PEEK[$_partID]) |
| 4664 | 4664 | // thus we trigger a second go with UID FETCH $_uid (BODY.PEEK[$_partID]) |
| 4665 | - if (empty($partToReturn)&&$_tryDecodingServerside===true) |
|
| 4665 | + if (empty($partToReturn) && $_tryDecodingServerside === true) |
|
| 4666 | 4666 | { |
| 4667 | 4667 | error_log(__METHOD__.__LINE__.' failed to fetch bodyPart in BINARY. Try BODY'); |
| 4668 | 4668 | $partToReturn = $this->getBodyPart($_uid, $_partID, $_folder, $_preserveSeen, $_stream, $_encoding, false); |
| 4669 | 4669 | } |
| 4670 | - return ($partToReturn?$partToReturn:null); |
|
| 4670 | + return ($partToReturn ? $partToReturn : null); |
|
| 4671 | 4671 | } |
| 4672 | 4672 | |
| 4673 | 4673 | /** |
@@ -4680,13 +4680,13 @@ discard block |
||
| 4680 | 4680 | * @param boolean $_stream = false true return a stream, false return string |
| 4681 | 4681 | * @return array containing the desired text part, mimeType and charset |
| 4682 | 4682 | */ |
| 4683 | - function getTextPart($_uid, Horde_Mime_Part $_structure, $_htmlMode='', $_preserveSeen=false, $_stream=false) |
|
| 4683 | + function getTextPart($_uid, Horde_Mime_Part $_structure, $_htmlMode = '', $_preserveSeen = false, $_stream = false) |
|
| 4684 | 4684 | { |
| 4685 | 4685 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.$_uid.':'.array2string($_structure).' '.function_backtrace()); |
| 4686 | 4686 | $bodyPart = array(); |
| 4687 | - if (self::$debug) _debug_array(array($_structure,function_backtrace())); |
|
| 4687 | + if (self::$debug) _debug_array(array($_structure, function_backtrace())); |
|
| 4688 | 4688 | |
| 4689 | - if($_structure->getSubType() == 'html' && !in_array($_htmlMode, array('html_only', 'always_display', 'only_if_no_text'))) |
|
| 4689 | + if ($_structure->getSubType() == 'html' && !in_array($_htmlMode, array('html_only', 'always_display', 'only_if_no_text'))) |
|
| 4690 | 4690 | { |
| 4691 | 4691 | $bodyPart = array( |
| 4692 | 4692 | 'error' => 1, |
@@ -4732,10 +4732,10 @@ discard block |
||
| 4732 | 4732 | * @param string $_folder folder to work on |
| 4733 | 4733 | * @return array containing the message body, mimeType and charset |
| 4734 | 4734 | */ |
| 4735 | - function getMessageBody($_uid, $_htmlOptions='', $_partID=null, Horde_Mime_Part $_structure=null, $_preserveSeen = false, $_folder = '') |
|
| 4735 | + function getMessageBody($_uid, $_htmlOptions = '', $_partID = null, Horde_Mime_Part $_structure = null, $_preserveSeen = false, $_folder = '') |
|
| 4736 | 4736 | { |
| 4737 | 4737 | if (self::$debug) echo __METHOD__."$_uid, $_htmlOptions, $_partID<br>"; |
| 4738 | - if($_htmlOptions != '') { |
|
| 4738 | + if ($_htmlOptions != '') { |
|
| 4739 | 4739 | $this->htmlOptions = $_htmlOptions; |
| 4740 | 4740 | } |
| 4741 | 4741 | if (empty($_folder)) |
@@ -4756,7 +4756,7 @@ discard block |
||
| 4756 | 4756 | return array( |
| 4757 | 4757 | array( |
| 4758 | 4758 | 'error' => 1, |
| 4759 | - 'body' => 'Error: Could not fetch structure on mail:'.$_uid." as $_htmlOptions". 'for Mailprofile'.$this->icServer->ImapServerId.' User:'.$GLOBALS['egw_info']['user']['account_lid'], |
|
| 4759 | + 'body' => 'Error: Could not fetch structure on mail:'.$_uid." as $_htmlOptions".'for Mailprofile'.$this->icServer->ImapServerId.' User:'.$GLOBALS['egw_info']['user']['account_lid'], |
|
| 4760 | 4760 | 'mimeType' => 'text/plain', |
| 4761 | 4761 | 'charSet' => self::$displayCharset, |
| 4762 | 4762 | ) |
@@ -4769,7 +4769,7 @@ discard block |
||
| 4769 | 4769 | //_debug_array($_structure->getMimeId()); exit; |
| 4770 | 4770 | } |
| 4771 | 4771 | |
| 4772 | - switch($_structure->getPrimaryType()) |
|
| 4772 | + switch ($_structure->getPrimaryType()) |
|
| 4773 | 4773 | { |
| 4774 | 4774 | case 'application': |
| 4775 | 4775 | return array( |
@@ -4781,7 +4781,7 @@ discard block |
||
| 4781 | 4781 | ); |
| 4782 | 4782 | |
| 4783 | 4783 | case 'multipart': |
| 4784 | - switch($_structure->getSubType()) |
|
| 4784 | + switch ($_structure->getSubType()) |
|
| 4785 | 4785 | { |
| 4786 | 4786 | case 'alternative': |
| 4787 | 4787 | $bodyParts = array($this->getMultipartAlternative($_uid, $_structure, $this->htmlOptions, $_preserveSeen)); |
@@ -4815,7 +4815,7 @@ discard block |
||
| 4815 | 4815 | $bodyPart = array(); |
| 4816 | 4816 | if ($_structure->getDisposition() != 'attachment') |
| 4817 | 4817 | { |
| 4818 | - switch($_structure->getSubType()) |
|
| 4818 | + switch ($_structure->getSubType()) |
|
| 4819 | 4819 | { |
| 4820 | 4820 | case 'calendar': |
| 4821 | 4821 | // this is handeled in getTextPart |
@@ -4831,11 +4831,11 @@ discard block |
||
| 4831 | 4831 | |
| 4832 | 4832 | case 'attachment': |
| 4833 | 4833 | case 'message': |
| 4834 | - switch($_structure->getSubType()) |
|
| 4834 | + switch ($_structure->getSubType()) |
|
| 4835 | 4835 | { |
| 4836 | 4836 | case 'rfc822': |
| 4837 | 4837 | $newStructure = $_structure->getParts(); |
| 4838 | - if (self::$debug) {echo __METHOD__." Message -> RFC -> NewStructure:"; _debug_array($newStructure[0]);} |
|
| 4838 | + if (self::$debug) {echo __METHOD__." Message -> RFC -> NewStructure:"; _debug_array($newStructure[0]); } |
|
| 4839 | 4839 | return self::normalizeBodyParts($this->getMessageBody($_uid, $_htmlOptions, $newStructure[0]->getMimeId(), $newStructure[0], $_preserveSeen, $_folder)); |
| 4840 | 4840 | } |
| 4841 | 4841 | break; |
@@ -4863,11 +4863,11 @@ discard block |
||
| 4863 | 4863 | { |
| 4864 | 4864 | if (is_array($_bodyParts)) |
| 4865 | 4865 | { |
| 4866 | - foreach($_bodyParts as $singleBodyPart) |
|
| 4866 | + foreach ($_bodyParts as $singleBodyPart) |
|
| 4867 | 4867 | { |
| 4868 | 4868 | if (!isset($singleBodyPart['body'])) { |
| 4869 | 4869 | $buff = self::normalizeBodyParts($singleBodyPart); |
| 4870 | - foreach ((array)$buff as $val) { $body2return[] = $val;} |
|
| 4870 | + foreach ((array)$buff as $val) { $body2return[] = $val; } |
|
| 4871 | 4871 | continue; |
| 4872 | 4872 | } |
| 4873 | 4873 | $body2return[] = $singleBodyPart; |
@@ -4888,14 +4888,14 @@ discard block |
||
| 4888 | 4888 | * @param boolean $useTidy switch to use tidy |
| 4889 | 4889 | * @return string a preformatted string with the mails converted to text |
| 4890 | 4890 | */ |
| 4891 | - static function &getdisplayableBody(&$mailClass, $bodyParts, $preserveHTML = false, $useTidy = true) |
|
| 4891 | + static function &getdisplayableBody(&$mailClass, $bodyParts, $preserveHTML = false, $useTidy = true) |
|
| 4892 | 4892 | { |
| 4893 | - $message=''; |
|
| 4894 | - for($i=0; $i<count($bodyParts); $i++) |
|
| 4893 | + $message = ''; |
|
| 4894 | + for ($i = 0; $i < count($bodyParts); $i++) |
|
| 4895 | 4895 | { |
| 4896 | 4896 | if (!isset($bodyParts[$i]['body'])) { |
| 4897 | 4897 | $bodyParts[$i]['body'] = self::getdisplayableBody($mailClass, $bodyParts[$i], $preserveHTML, $useTidy); |
| 4898 | - $message .= empty($bodyParts[$i]['body'])?'':$bodyParts[$i]['body']; |
|
| 4898 | + $message .= empty($bodyParts[$i]['body']) ? '' : $bodyParts[$i]['body']; |
|
| 4899 | 4899 | continue; |
| 4900 | 4900 | } |
| 4901 | 4901 | if (isset($bodyParts[$i]['error'])) continue; |
@@ -4920,32 +4920,32 @@ discard block |
||
| 4920 | 4920 | '(R)', |
| 4921 | 4921 | ); |
| 4922 | 4922 | |
| 4923 | - if(($bodyParts[$i]['mimeType'] == 'text/html' || $bodyParts[$i]['mimeType'] == 'text/plain') && |
|
| 4923 | + if (($bodyParts[$i]['mimeType'] == 'text/html' || $bodyParts[$i]['mimeType'] == 'text/plain') && |
|
| 4924 | 4924 | strtoupper($bodyParts[$i]['charSet']) != 'UTF-8') |
| 4925 | 4925 | { |
| 4926 | - $bodyParts[$i]['body'] = preg_replace($sar,$rar,$bodyParts[$i]['body']); |
|
| 4926 | + $bodyParts[$i]['body'] = preg_replace($sar, $rar, $bodyParts[$i]['body']); |
|
| 4927 | 4927 | } |
| 4928 | 4928 | |
| 4929 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Translation::detect_encoding($bodyParts[$i]['body']); |
|
| 4929 | + if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = Translation::detect_encoding($bodyParts[$i]['body']); |
|
| 4930 | 4930 | // add line breaks to $bodyParts |
| 4931 | 4931 | //error_log(__METHOD__.' ('.__LINE__.') '.' Charset:'.$bodyParts[$i]['charSet'].'->'.$bodyParts[$i]['body']); |
| 4932 | - $newBody = Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
|
| 4932 | + $newBody = Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
|
| 4933 | 4933 | //error_log(__METHOD__.' ('.__LINE__.') '.' MimeType:'.$bodyParts[$i]['mimeType'].'->'.$newBody); |
| 4934 | 4934 | $mailClass->activeMimeType = 'text/plain'; |
| 4935 | 4935 | if ($bodyParts[$i]['mimeType'] == 'text/html') { |
| 4936 | 4936 | $mailClass->activeMimeType = $bodyParts[$i]['mimeType']; |
| 4937 | 4937 | if (!$preserveHTML) |
| 4938 | 4938 | { |
| 4939 | - $alreadyHtmlLawed=false; |
|
| 4939 | + $alreadyHtmlLawed = false; |
|
| 4940 | 4940 | // as Translation::convert reduces \r\n to \n and purifier eats \n -> peplace it with a single space |
| 4941 | - $newBody = str_replace("\n"," ",$newBody); |
|
| 4941 | + $newBody = str_replace("\n", " ", $newBody); |
|
| 4942 | 4942 | // convert HTML to text, as we dont want HTML in infologs |
| 4943 | 4943 | if ($useTidy && extension_loaded('tidy')) |
| 4944 | 4944 | { |
| 4945 | 4945 | $tidy = new tidy(); |
| 4946 | - $cleaned = $tidy->repairString($newBody, self::$tidy_config,'utf8'); |
|
| 4946 | + $cleaned = $tidy->repairString($newBody, self::$tidy_config, 'utf8'); |
|
| 4947 | 4947 | // Found errors. Strip it all so there's some output |
| 4948 | - if($tidy->getStatus() == 2) |
|
| 4948 | + if ($tidy->getStatus() == 2) |
|
| 4949 | 4949 | { |
| 4950 | 4950 | error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$tidy->errorBuffer); |
| 4951 | 4951 | } |
@@ -4956,7 +4956,7 @@ discard block |
||
| 4956 | 4956 | if (!$preserveHTML) |
| 4957 | 4957 | { |
| 4958 | 4958 | // filter only the 'body', as we only want that part, if we throw away the html |
| 4959 | - preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array()); |
|
| 4959 | + preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array()); |
|
| 4960 | 4960 | if ($matches[2]) |
| 4961 | 4961 | { |
| 4962 | 4962 | $hasOther = true; |
@@ -4967,7 +4967,7 @@ discard block |
||
| 4967 | 4967 | else |
| 4968 | 4968 | { |
| 4969 | 4969 | // htmLawed filter only the 'body' |
| 4970 | - preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array()); |
|
| 4970 | + preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array()); |
|
| 4971 | 4971 | if ($matches[2]) |
| 4972 | 4972 | { |
| 4973 | 4973 | $hasOther = true; |
@@ -4976,17 +4976,17 @@ discard block |
||
| 4976 | 4976 | $htmLawed = new Html\HtmLawed(); |
| 4977 | 4977 | // the next line should not be needed, but produces better results on HTML 2 Text conversion, |
| 4978 | 4978 | // as we switched off HTMLaweds tidy functionality |
| 4979 | - $newBody = str_replace(array('&amp;','<DIV><BR></DIV>',"<DIV> </DIV>",'<div> </div>'),array('&','<BR>','<BR>','<BR>'),$newBody); |
|
| 4980 | - $newBody = $htmLawed->run($newBody,self::$htmLawed_config); |
|
| 4981 | - if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3]; |
|
| 4982 | - $alreadyHtmlLawed=true; |
|
| 4979 | + $newBody = str_replace(array('&amp;', '<DIV><BR></DIV>', "<DIV> </DIV>", '<div> </div>'), array('&', '<BR>', '<BR>', '<BR>'), $newBody); |
|
| 4980 | + $newBody = $htmLawed->run($newBody, self::$htmLawed_config); |
|
| 4981 | + if ($hasOther && $preserveHTML) $newBody = $matches[1].$newBody.$matches[3]; |
|
| 4982 | + $alreadyHtmlLawed = true; |
|
| 4983 | 4983 | } |
| 4984 | 4984 | //error_log(__METHOD__.' ('.__LINE__.') '.' after purify:'.$newBody); |
| 4985 | - if ($preserveHTML==false) $newBody = Mail\Html::convertHTMLToText($newBody,self::$displayCharset,true,true); |
|
| 4985 | + if ($preserveHTML == false) $newBody = Mail\Html::convertHTMLToText($newBody, self::$displayCharset, true, true); |
|
| 4986 | 4986 | //error_log(__METHOD__.' ('.__LINE__.') '.' after convertHTMLToText:'.$newBody); |
| 4987 | - if ($preserveHTML==false) $newBody = nl2br($newBody); // we need this, as htmLawed removes \r\n |
|
| 4987 | + if ($preserveHTML == false) $newBody = nl2br($newBody); // we need this, as htmLawed removes \r\n |
|
| 4988 | 4988 | /*if (!$alreadyHtmlLawed) */ $mailClass->getCleanHTML($newBody); // remove stuff we regard as unwanted |
| 4989 | - if ($preserveHTML==false) $newBody = str_replace("<br />","\r\n",$newBody); |
|
| 4989 | + if ($preserveHTML == false) $newBody = str_replace("<br />", "\r\n", $newBody); |
|
| 4990 | 4990 | //error_log(__METHOD__.' ('.__LINE__.') '.' after getClean:'.$newBody); |
| 4991 | 4991 | } |
| 4992 | 4992 | $message .= $newBody; |
@@ -4995,9 +4995,9 @@ discard block |
||
| 4995 | 4995 | //error_log(__METHOD__.' ('.__LINE__.') '.' Body(after specialchars):'.$newBody); |
| 4996 | 4996 | //use Mail\Html::convertHTMLToText instead of strip_tags, (even message is plain text) as strip_tags eats away too much |
| 4997 | 4997 | //$newBody = strip_tags($newBody); //we need to fix broken tags (or just stuff like "<800 USD/p" ) |
| 4998 | - $newBody = Mail\Html::convertHTMLToText($newBody,self::$displayCharset,false,false); |
|
| 4998 | + $newBody = Mail\Html::convertHTMLToText($newBody, self::$displayCharset, false, false); |
|
| 4999 | 4999 | //error_log(__METHOD__.' ('.__LINE__.') '.' Body(after strip tags):'.$newBody); |
| 5000 | - $newBody = htmlspecialchars_decode($newBody,ENT_QUOTES); |
|
| 5000 | + $newBody = htmlspecialchars_decode($newBody, ENT_QUOTES); |
|
| 5001 | 5001 | //error_log(__METHOD__.' ('.__LINE__.') '.' Body (after hmlspc_decode):'.$newBody); |
| 5002 | 5002 | $message .= $newBody; |
| 5003 | 5003 | //continue; |
@@ -5005,27 +5005,27 @@ discard block |
||
| 5005 | 5005 | return $message; |
| 5006 | 5006 | } |
| 5007 | 5007 | |
| 5008 | - static function wordwrap($str, $cols, $cut, $dontbreaklinesstartingwith=false) |
|
| 5008 | + static function wordwrap($str, $cols, $cut, $dontbreaklinesstartingwith = false) |
|
| 5009 | 5009 | { |
| 5010 | 5010 | $lines = explode("\n", $str); |
| 5011 | 5011 | $newStr = ''; |
| 5012 | - foreach($lines as $line) |
|
| 5012 | + foreach ($lines as $line) |
|
| 5013 | 5013 | { |
| 5014 | 5014 | // replace tabs by 8 space chars, or any tab only counts one char |
| 5015 | 5015 | //$line = str_replace("\t"," ",$line); |
| 5016 | 5016 | //$newStr .= wordwrap($line, $cols, $cut); |
| 5017 | - $allowedLength = $cols-strlen($cut); |
|
| 5017 | + $allowedLength = $cols - strlen($cut); |
|
| 5018 | 5018 | //dont try to break lines with links, chance is we mess up the text is way too big |
| 5019 | - if (strlen($line) > $allowedLength && stripos($line,'href=')===false && |
|
| 5020 | - ($dontbreaklinesstartingwith==false || |
|
| 5019 | + if (strlen($line) > $allowedLength && stripos($line, 'href=') === false && |
|
| 5020 | + ($dontbreaklinesstartingwith == false || |
|
| 5021 | 5021 | ($dontbreaklinesstartingwith && |
| 5022 | - strlen($dontbreaklinesstartingwith)>=1 && |
|
| 5023 | - substr($line,0,strlen($dontbreaklinesstartingwith)) != $dontbreaklinesstartingwith |
|
| 5022 | + strlen($dontbreaklinesstartingwith) >= 1 && |
|
| 5023 | + substr($line, 0, strlen($dontbreaklinesstartingwith)) != $dontbreaklinesstartingwith |
|
| 5024 | 5024 | ) |
| 5025 | 5025 | ) |
| 5026 | 5026 | ) |
| 5027 | 5027 | { |
| 5028 | - $s=explode(" ", $line); |
|
| 5028 | + $s = explode(" ", $line); |
|
| 5029 | 5029 | $line = ""; |
| 5030 | 5030 | $linecnt = 0; |
| 5031 | 5031 | foreach ($s as &$v) { |
@@ -5033,22 +5033,22 @@ discard block |
||
| 5033 | 5033 | // only break long words within the wordboundaries, |
| 5034 | 5034 | // but it may destroy links, so we check for href and dont do it if we find one |
| 5035 | 5035 | // we check for any html within the word, because we do not want to break html by accident |
| 5036 | - if($cnt > $allowedLength && stripos($v,'href=')===false && stripos($v,'onclick=')===false && $cnt == strlen(html_entity_decode($v))) |
|
| 5036 | + if ($cnt > $allowedLength && stripos($v, 'href=') === false && stripos($v, 'onclick=') === false && $cnt == strlen(html_entity_decode($v))) |
|
| 5037 | 5037 | { |
| 5038 | - $v=wordwrap($v, $allowedLength, $cut, true); |
|
| 5038 | + $v = wordwrap($v, $allowedLength, $cut, true); |
|
| 5039 | 5039 | } |
| 5040 | 5040 | // the rest should be broken at the start of the new word that exceeds the limit |
| 5041 | - if ($linecnt+$cnt > $allowedLength) { |
|
| 5042 | - $v=$cut.$v; |
|
| 5041 | + if ($linecnt + $cnt > $allowedLength) { |
|
| 5042 | + $v = $cut.$v; |
|
| 5043 | 5043 | #$linecnt = 0; |
| 5044 | - $linecnt =strlen($v)-strlen($cut); |
|
| 5044 | + $linecnt = strlen($v) - strlen($cut); |
|
| 5045 | 5045 | } else { |
| 5046 | 5046 | $linecnt += $cnt; |
| 5047 | 5047 | } |
| 5048 | 5048 | if (strlen($v)) $line .= (strlen($line) ? " " : "").$v; |
| 5049 | 5049 | } |
| 5050 | 5050 | } |
| 5051 | - $newStr .= $line . "\n"; |
|
| 5051 | + $newStr .= $line."\n"; |
|
| 5052 | 5052 | } |
| 5053 | 5053 | return $newStr; |
| 5054 | 5054 | } |
@@ -5063,12 +5063,12 @@ discard block |
||
| 5063 | 5063 | * @param boolean $_useHeaderInsteadOfEnvelope - force getMessageHeader method to be used for fetching Envelope Information |
| 5064 | 5064 | * @return array the message header |
| 5065 | 5065 | */ |
| 5066 | - function getMessageEnvelope($_uid, $_partID = '',$decode=false, $_folder='', $_useHeaderInsteadOfEnvelope=false) |
|
| 5066 | + function getMessageEnvelope($_uid, $_partID = '', $decode = false, $_folder = '', $_useHeaderInsteadOfEnvelope = false) |
|
| 5067 | 5067 | { |
| 5068 | 5068 | //error_log(__METHOD__.' ('.__LINE__.') '.":$_uid,$_partID,$decode,$_folder".function_backtrace()); |
| 5069 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5069 | + if (empty($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5070 | 5070 | //error_log(__METHOD__.' ('.__LINE__.') '.":$_uid,$_partID,$decode,$_folder"); |
| 5071 | - if((empty($_partID)||$_partID=='null')&&$_useHeaderInsteadOfEnvelope===false) { |
|
| 5071 | + if ((empty($_partID) || $_partID == 'null') && $_useHeaderInsteadOfEnvelope === false) { |
|
| 5072 | 5072 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5073 | 5073 | if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
| 5074 | 5074 | $uidsToFetch->add($_uid); |
@@ -5081,7 +5081,7 @@ discard block |
||
| 5081 | 5081 | 'ids' => $uidsToFetch, |
| 5082 | 5082 | )); |
| 5083 | 5083 | if (is_object($headersNew)) { |
| 5084 | - foreach($headersNew as &$_headerObject) { |
|
| 5084 | + foreach ($headersNew as &$_headerObject) { |
|
| 5085 | 5085 | $env = $_headerObject->getEnvelope(); |
| 5086 | 5086 | //_debug_array($envFields->singleFields()); |
| 5087 | 5087 | $singleFields = $envFields->singleFields(); |
@@ -5096,34 +5096,34 @@ discard block |
||
| 5096 | 5096 | case 'bcc': |
| 5097 | 5097 | case 'sender': |
| 5098 | 5098 | //error_log(__METHOD__.' ('.__LINE__.') '.$v.'->'.array2string($env->$v->addresses)); |
| 5099 | - $envelope[$v]=$env->$v->addresses; |
|
| 5099 | + $envelope[$v] = $env->$v->addresses; |
|
| 5100 | 5100 | $address = array(); |
| 5101 | 5101 | if (!is_array($envelope[$v])) break; |
| 5102 | 5102 | foreach ($envelope[$v] as $k => $ad) |
| 5103 | 5103 | { |
| 5104 | - if (stripos($ad,'@')===false) |
|
| 5104 | + if (stripos($ad, '@') === false) |
|
| 5105 | 5105 | { |
| 5106 | - $remember=$k; |
|
| 5106 | + $remember = $k; |
|
| 5107 | 5107 | } |
| 5108 | 5108 | else |
| 5109 | 5109 | { |
| 5110 | - $address[] = (!is_null($remember)?$envelope[$v][$remember].' ':'').$ad; |
|
| 5111 | - $remember=null; |
|
| 5110 | + $address[] = (!is_null($remember) ? $envelope[$v][$remember].' ' : '').$ad; |
|
| 5111 | + $remember = null; |
|
| 5112 | 5112 | } |
| 5113 | 5113 | } |
| 5114 | 5114 | $envelope[$v] = $address; |
| 5115 | 5115 | break; |
| 5116 | 5116 | case 'date': |
| 5117 | - $envelope[$v]=DateTime::to($env->$v); |
|
| 5117 | + $envelope[$v] = DateTime::to($env->$v); |
|
| 5118 | 5118 | break; |
| 5119 | 5119 | default: |
| 5120 | - $envelope[$v]=$env->$v; |
|
| 5120 | + $envelope[$v] = $env->$v; |
|
| 5121 | 5121 | } |
| 5122 | 5122 | } |
| 5123 | - $envelope['size']=$_headerObject->getSize(); |
|
| 5123 | + $envelope['size'] = $_headerObject->getSize(); |
|
| 5124 | 5124 | } |
| 5125 | 5125 | } |
| 5126 | - $envelope = array_change_key_case($envelope,CASE_UPPER); |
|
| 5126 | + $envelope = array_change_key_case($envelope, CASE_UPPER); |
|
| 5127 | 5127 | //if ($decode) _debug_array($envelope); |
| 5128 | 5128 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($envelope)); |
| 5129 | 5129 | if ($decode) |
@@ -5131,19 +5131,19 @@ discard block |
||
| 5131 | 5131 | foreach ($envelope as $key => $rvV) |
| 5132 | 5132 | { |
| 5133 | 5133 | //try idn conversion only on 'FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO' |
| 5134 | - $envelope[$key]=self::decode_header($rvV,in_array($key,array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO'))); |
|
| 5134 | + $envelope[$key] = self::decode_header($rvV, in_array($key, array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO'))); |
|
| 5135 | 5135 | } |
| 5136 | 5136 | } |
| 5137 | 5137 | return $envelope; |
| 5138 | 5138 | } else { |
| 5139 | 5139 | |
| 5140 | - $headers = $this->getMessageHeader($_uid, $_partID, true,true,$_folder); |
|
| 5140 | + $headers = $this->getMessageHeader($_uid, $_partID, true, true, $_folder); |
|
| 5141 | 5141 | |
| 5142 | 5142 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.array2string($headers)); |
| 5143 | 5143 | //_debug_array($headers); |
| 5144 | 5144 | $newData = array( |
| 5145 | 5145 | 'DATE' => $headers['DATE'], |
| 5146 | - 'SUBJECT' => ($decode ? self::decode_header($headers['SUBJECT']):$headers['SUBJECT']), |
|
| 5146 | + 'SUBJECT' => ($decode ? self::decode_header($headers['SUBJECT']) : $headers['SUBJECT']), |
|
| 5147 | 5147 | 'MESSAGE_ID' => $headers['MESSAGE-ID'] |
| 5148 | 5148 | ); |
| 5149 | 5149 | if (isset($headers['IN-REPLY-TO'])) $newData['IN-REPLY-TO'] = $headers['IN-REPLY-TO']; |
@@ -5154,11 +5154,11 @@ discard block |
||
| 5154 | 5154 | if (isset($headers['SIZE'])) $newData['SIZE'] = $headers['SIZE']; |
| 5155 | 5155 | //_debug_array($newData); |
| 5156 | 5156 | $recepientList = array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO'); |
| 5157 | - foreach($recepientList as $recepientType) { |
|
| 5158 | - if(isset($headers[$recepientType])) { |
|
| 5159 | - if ($decode) $headers[$recepientType] = self::decode_header($headers[$recepientType],true); |
|
| 5157 | + foreach ($recepientList as $recepientType) { |
|
| 5158 | + if (isset($headers[$recepientType])) { |
|
| 5159 | + if ($decode) $headers[$recepientType] = self::decode_header($headers[$recepientType], true); |
|
| 5160 | 5160 | //error_log(__METHOD__.__LINE__." ".$recepientType."->".array2string($headers[$recepientType])); |
| 5161 | - foreach(self::parseAddressList($headers[$recepientType]) as $singleAddress) { |
|
| 5161 | + foreach (self::parseAddressList($headers[$recepientType]) as $singleAddress) { |
|
| 5162 | 5162 | $addressData = array( |
| 5163 | 5163 | 'PERSONAL_NAME' => $singleAddress->personal ? $singleAddress->personal : 'NIL', |
| 5164 | 5164 | 'AT_DOMAIN_LIST' => $singleAddress->adl ? $singleAddress->adl : 'NIL', |
@@ -5166,15 +5166,15 @@ discard block |
||
| 5166 | 5166 | 'HOST_NAME' => $singleAddress->host ? $singleAddress->host : 'NIL', |
| 5167 | 5167 | 'EMAIL' => $singleAddress->host ? $singleAddress->mailbox.'@'.$singleAddress->host : $singleAddress->mailbox, |
| 5168 | 5168 | ); |
| 5169 | - if($addressData['PERSONAL_NAME'] != 'NIL') { |
|
| 5169 | + if ($addressData['PERSONAL_NAME'] != 'NIL') { |
|
| 5170 | 5170 | $addressData['RFC822_EMAIL'] = imap_rfc822_write_address($singleAddress->mailbox, $singleAddress->host, $singleAddress->personal); |
| 5171 | 5171 | } else { |
| 5172 | 5172 | $addressData['RFC822_EMAIL'] = 'NIL'; |
| 5173 | 5173 | } |
| 5174 | - $newData[$recepientType][] = ($addressData['RFC822_EMAIL']!='NIL'?$addressData['RFC822_EMAIL']:$addressData['EMAIL']);//$addressData; |
|
| 5174 | + $newData[$recepientType][] = ($addressData['RFC822_EMAIL'] != 'NIL' ? $addressData['RFC822_EMAIL'] : $addressData['EMAIL']); //$addressData; |
|
| 5175 | 5175 | } |
| 5176 | 5176 | } else { |
| 5177 | - if($recepientType == 'SENDER' || $recepientType == 'REPLY-TO') { |
|
| 5177 | + if ($recepientType == 'SENDER' || $recepientType == 'REPLY-TO') { |
|
| 5178 | 5178 | $newData[$recepientType] = $newData['FROM']; |
| 5179 | 5179 | } else { |
| 5180 | 5180 | $newData[$recepientType] = array(); |
@@ -5196,10 +5196,10 @@ discard block |
||
| 5196 | 5196 | * @param string $_folder folder to work on |
| 5197 | 5197 | * @return array|Horde_Mime_Headers message header as array or object |
| 5198 | 5198 | */ |
| 5199 | - function getMessageHeader($_uid, $_partID = '',$decode=false, $preserveUnSeen=false, $_folder='') |
|
| 5199 | + function getMessageHeader($_uid, $_partID = '', $decode = false, $preserveUnSeen = false, $_folder = '') |
|
| 5200 | 5200 | { |
| 5201 | 5201 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$_uid.', '.$_partID.', '.$decode.', '.$preserveUnSeen.', '.$_folder); |
| 5202 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5202 | + if (empty($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5203 | 5203 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5204 | 5204 | if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
| 5205 | 5205 | $uidsToFetch->add($_uid); |
@@ -5207,7 +5207,7 @@ discard block |
||
| 5207 | 5207 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
| 5208 | 5208 | if ($_partID != '') |
| 5209 | 5209 | { |
| 5210 | - $fquery->headerText(array('id'=>$_partID,'peek'=>$preserveUnSeen)); |
|
| 5210 | + $fquery->headerText(array('id'=>$_partID, 'peek'=>$preserveUnSeen)); |
|
| 5211 | 5211 | $fquery->structure(); |
| 5212 | 5212 | } |
| 5213 | 5213 | else |
@@ -5220,18 +5220,18 @@ discard block |
||
| 5220 | 5220 | 'ids' => $uidsToFetch, |
| 5221 | 5221 | )); |
| 5222 | 5222 | if (is_object($headersNew)) { |
| 5223 | - foreach($headersNew as $_fetchObject) |
|
| 5223 | + foreach ($headersNew as $_fetchObject) |
|
| 5224 | 5224 | { |
| 5225 | - $headers = $_fetchObject->getHeaderText(0,Horde_Imap_Client_Data_Fetch::HEADER_PARSE); |
|
| 5225 | + $headers = $_fetchObject->getHeaderText(0, Horde_Imap_Client_Data_Fetch::HEADER_PARSE); |
|
| 5226 | 5226 | if ($_partID != '') |
| 5227 | 5227 | { |
| 5228 | 5228 | $mailStructureObject = $_fetchObject->getStructure(); |
| 5229 | 5229 | foreach ($mailStructureObject->contentTypeMap() as $mime_id => $mime_type) |
| 5230 | 5230 | { |
| 5231 | - if ($mime_id==$_partID) |
|
| 5231 | + if ($mime_id == $_partID) |
|
| 5232 | 5232 | { |
| 5233 | 5233 | //error_log(__METHOD__.' ('.__LINE__.') '."$mime_id == $_partID".array2string($_headerObject->getHeaderText($mime_id,Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray())); |
| 5234 | - $headers = $_fetchObject->getHeaderText($mime_id,Horde_Imap_Client_Data_Fetch::HEADER_PARSE); |
|
| 5234 | + $headers = $_fetchObject->getHeaderText($mime_id, Horde_Imap_Client_Data_Fetch::HEADER_PARSE); |
|
| 5235 | 5235 | break; |
| 5236 | 5236 | } |
| 5237 | 5237 | } |
@@ -5244,15 +5244,15 @@ discard block |
||
| 5244 | 5244 | if (is_object($headers)) $headers->setUserAgent('EGroupware API '.$GLOBALS['egw_info']['server']['versions']['phpgwapi']); |
| 5245 | 5245 | return $headers; |
| 5246 | 5246 | } |
| 5247 | - $retValue = is_object($headers) ? $headers->toArray():array(); |
|
| 5247 | + $retValue = is_object($headers) ? $headers->toArray() : array(); |
|
| 5248 | 5248 | if ($size) $retValue['size'] = $size; |
| 5249 | 5249 | } |
| 5250 | - $retValue = array_change_key_case($retValue,CASE_UPPER); |
|
| 5250 | + $retValue = array_change_key_case($retValue, CASE_UPPER); |
|
| 5251 | 5251 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($retValue)); |
| 5252 | 5252 | // if SUBJECT is an array, use thelast one, as we assume something with the unfolding for the subject did not work |
| 5253 | 5253 | if (is_array($retValue['SUBJECT'])) |
| 5254 | 5254 | { |
| 5255 | - $retValue['SUBJECT'] = $retValue['SUBJECT'][count($retValue['SUBJECT'])-1]; |
|
| 5255 | + $retValue['SUBJECT'] = $retValue['SUBJECT'][count($retValue['SUBJECT']) - 1]; |
|
| 5256 | 5256 | } |
| 5257 | 5257 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.array2string($decode ? self::decode_header($retValue,true):$retValue)); |
| 5258 | 5258 | if ($decode) |
@@ -5260,7 +5260,7 @@ discard block |
||
| 5260 | 5260 | foreach ($retValue as $key => $rvV) |
| 5261 | 5261 | { |
| 5262 | 5262 | //try idn conversion only on 'FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO' |
| 5263 | - $retValue[$key]=self::decode_header($rvV,in_array($key,array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO'))); |
|
| 5263 | + $retValue[$key] = self::decode_header($rvV, in_array($key, array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO'))); |
|
| 5264 | 5264 | } |
| 5265 | 5265 | } |
| 5266 | 5266 | return $retValue; |
@@ -5277,14 +5277,14 @@ discard block |
||
| 5277 | 5277 | function getMessageRawHeader($_uid, $_partID = '', $_folder = '') |
| 5278 | 5278 | { |
| 5279 | 5279 | static $rawHeaders; |
| 5280 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5280 | + if (empty($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5281 | 5281 | //error_log(__METHOD__.' ('.__LINE__.') '." Try Using Cache for raw Header $_uid, $_partID in Folder $_folder"); |
| 5282 | 5282 | |
| 5283 | - 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); |
|
| 5284 | - if (isset($rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID)?'NIL':$_partID)])) |
|
| 5283 | + 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); |
|
| 5284 | + if (isset($rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)])) |
|
| 5285 | 5285 | { |
| 5286 | 5286 | //error_log(__METHOD__.' ('.__LINE__.') '." Using Cache for raw Header $_uid, $_partID in Folder $_folder"); |
| 5287 | - return $rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID)?'NIL':$_partID)]; |
|
| 5287 | + return $rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)]; |
|
| 5288 | 5288 | } |
| 5289 | 5289 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5290 | 5290 | $uid = $_uid; |
@@ -5294,7 +5294,7 @@ discard block |
||
| 5294 | 5294 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
| 5295 | 5295 | if ($_partID != '') |
| 5296 | 5296 | { |
| 5297 | - $fquery->headerText(array('id'=>$_partID,'peek'=>true)); |
|
| 5297 | + $fquery->headerText(array('id'=>$_partID, 'peek'=>true)); |
|
| 5298 | 5298 | $fquery->structure(); |
| 5299 | 5299 | } |
| 5300 | 5300 | else |
@@ -5305,14 +5305,14 @@ discard block |
||
| 5305 | 5305 | 'ids' => $uidsToFetch, |
| 5306 | 5306 | )); |
| 5307 | 5307 | if (is_object($headersNew)) { |
| 5308 | - foreach($headersNew as &$_headerObject) { |
|
| 5308 | + foreach ($headersNew as &$_headerObject) { |
|
| 5309 | 5309 | $retValue = $_headerObject->getHeaderText(); |
| 5310 | 5310 | if ($_partID != '') |
| 5311 | 5311 | { |
| 5312 | 5312 | $mailStructureObject = $_headerObject->getStructure(); |
| 5313 | 5313 | foreach ($mailStructureObject->contentTypeMap() as $mime_id => $mime_type) |
| 5314 | 5314 | { |
| 5315 | - if ($mime_id==$_partID) |
|
| 5315 | + if ($mime_id == $_partID) |
|
| 5316 | 5316 | { |
| 5317 | 5317 | $retValue = $_headerObject->getHeaderText($mime_id); |
| 5318 | 5318 | } |
@@ -5320,8 +5320,8 @@ discard block |
||
| 5320 | 5320 | } |
| 5321 | 5321 | } |
| 5322 | 5322 | } |
| 5323 | - $rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID)?'NIL':$_partID)]=$retValue; |
|
| 5324 | - Cache::setCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']),$rawHeaders,60*60*1); |
|
| 5323 | + $rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)] = $retValue; |
|
| 5324 | + Cache::setCache(Cache::INSTANCE, 'email', 'rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']), $rawHeaders, 60 * 60 * 1); |
|
| 5325 | 5325 | return $retValue; |
| 5326 | 5326 | } |
| 5327 | 5327 | |
@@ -5334,25 +5334,25 @@ discard block |
||
| 5334 | 5334 | { |
| 5335 | 5335 | $style = ''; |
| 5336 | 5336 | if (empty($_bodyParts)) return ""; |
| 5337 | - foreach((array)$_bodyParts as $singleBodyPart) { |
|
| 5337 | + foreach ((array)$_bodyParts as $singleBodyPart) { |
|
| 5338 | 5338 | if (!isset($singleBodyPart['body'])) { |
| 5339 | 5339 | $singleBodyPart['body'] = self::getStyles($singleBodyPart); |
| 5340 | 5340 | $style .= $singleBodyPart['body']; |
| 5341 | 5341 | continue; |
| 5342 | 5342 | } |
| 5343 | 5343 | |
| 5344 | - if ($singleBodyPart['charSet']===false) $singleBodyPart['charSet'] = Translation::detect_encoding($singleBodyPart['body']); |
|
| 5344 | + if ($singleBodyPart['charSet'] === false) $singleBodyPart['charSet'] = Translation::detect_encoding($singleBodyPart['body']); |
|
| 5345 | 5345 | $singleBodyPart['body'] = Translation::convert( |
| 5346 | 5346 | $singleBodyPart['body'], |
| 5347 | 5347 | strtolower($singleBodyPart['charSet']) |
| 5348 | 5348 | ); |
| 5349 | 5349 | $ct = 0; |
| 5350 | - $newStyle=array(); |
|
| 5351 | - if (stripos($singleBodyPart['body'],'<style')!==false) $ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $singleBodyPart['body'], $newStyle); |
|
| 5352 | - if ($ct>0) |
|
| 5350 | + $newStyle = array(); |
|
| 5351 | + if (stripos($singleBodyPart['body'], '<style') !== false) $ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $singleBodyPart['body'], $newStyle); |
|
| 5352 | + if ($ct > 0) |
|
| 5353 | 5353 | { |
| 5354 | 5354 | //error_log(__METHOD__.' ('.__LINE__.') '.'#'.$ct.'#'.array2string($newStyle)); |
| 5355 | - $style2buffer = implode('',$newStyle[0]); |
|
| 5355 | + $style2buffer = implode('', $newStyle[0]); |
|
| 5356 | 5356 | } |
| 5357 | 5357 | if ($style2buffer && strtoupper(self::$displayCharset) == 'UTF-8') |
| 5358 | 5358 | { |
@@ -5360,7 +5360,7 @@ discard block |
||
| 5360 | 5360 | $test = json_encode($style2buffer); |
| 5361 | 5361 | //error_log(__METHOD__.' ('.__LINE__.') '.'#'.$test.'# ->'.strlen($style2buffer).' Error:'.json_last_error()); |
| 5362 | 5362 | //if (json_last_error() != JSON_ERROR_NONE && strlen($style2buffer)>0) |
| 5363 | - if ($test=="null" && strlen($style2buffer)>0) |
|
| 5363 | + if ($test == "null" && strlen($style2buffer) > 0) |
|
| 5364 | 5364 | { |
| 5365 | 5365 | // this should not be needed, unless something fails with charset detection/ wrong charset passed |
| 5366 | 5366 | error_log(__METHOD__.' ('.__LINE__.') '.' Found Invalid sequence for utf-8 in CSS:'.$style2buffer.' Charset Reported:'.$singleBodyPart['charSet'].' Carset Detected:'.Translation::detect_encoding($style2buffer)); |
@@ -5371,19 +5371,19 @@ discard block |
||
| 5371 | 5371 | } |
| 5372 | 5372 | // clean out comments and stuff |
| 5373 | 5373 | $search = array( |
| 5374 | - '@url\(http:\/\/[^\)].*?\)@si', // url calls e.g. in style definitions |
|
| 5374 | + '@url\(http:\/\/[^\)].*?\)@si', // url calls e.g. in style definitions |
|
| 5375 | 5375 | // '@<!--[\s\S]*?[ \t\n\r]*-->@', // Strip multi-line comments including CDATA |
| 5376 | 5376 | // '@<!--[\s\S]*?[ \t\n\r]*--@', // Strip broken multi-line comments including CDATA |
| 5377 | 5377 | ); |
| 5378 | - $style = preg_replace($search,"",$style); |
|
| 5378 | + $style = preg_replace($search, "", $style); |
|
| 5379 | 5379 | |
| 5380 | 5380 | // CSS Security |
| 5381 | 5381 | // http://code.google.com/p/browsersec/wiki/Part1#Cascading_stylesheets |
| 5382 | - $css = preg_replace('/(javascript|expression|-moz-binding)/i','',$style); |
|
| 5383 | - if (stripos($css,'script')!==false) Mail\Html::replaceTagsCompletley($css,'script'); // Strip out script that may be included |
|
| 5382 | + $css = preg_replace('/(javascript|expression|-moz-binding)/i', '', $style); |
|
| 5383 | + if (stripos($css, 'script') !== false) Mail\Html::replaceTagsCompletley($css, 'script'); // Strip out script that may be included |
|
| 5384 | 5384 | // 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 |
| 5385 | 5385 | // as the comments as <!-- styledefinition --> in stylesheet are outdated, and ck-editor does not understand it, we remove it |
| 5386 | - $css = str_replace(array(':','<!--','-->'),array(': ','',''),$css); |
|
| 5386 | + $css = str_replace(array(':', '<!--', '-->'), array(': ', '', ''), $css); |
|
| 5387 | 5387 | //error_log(__METHOD__.' ('.__LINE__.') '.$css); |
| 5388 | 5388 | // TODO: we may have to strip urls and maybe comments and ifs |
| 5389 | 5389 | return $css; |
@@ -5397,16 +5397,16 @@ discard block |
||
| 5397 | 5397 | * @param string $_folder folder to work on |
| 5398 | 5398 | * @return string the message body |
| 5399 | 5399 | */ |
| 5400 | - function getMessageRawBody($_uid, $_partID = '', $_folder='') |
|
| 5400 | + function getMessageRawBody($_uid, $_partID = '', $_folder = '') |
|
| 5401 | 5401 | { |
| 5402 | 5402 | //TODO: caching einbauen static! |
| 5403 | 5403 | static $rawBody; |
| 5404 | 5404 | if (is_null($rawBody)) $rawBody = array(); |
| 5405 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5406 | - if (isset($rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID)?'NIL':$_partID)])) |
|
| 5405 | + if (empty($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5406 | + if (isset($rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)])) |
|
| 5407 | 5407 | { |
| 5408 | 5408 | //error_log(__METHOD__.' ('.__LINE__.') '." Using Cache for raw Body $_uid, $_partID in Folder $_folder"); |
| 5409 | - return $rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID)?'NIL':$_partID)]; |
|
| 5409 | + return $rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)]; |
|
| 5410 | 5410 | } |
| 5411 | 5411 | |
| 5412 | 5412 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
@@ -5419,13 +5419,13 @@ discard block |
||
| 5419 | 5419 | if ($_partID != '') |
| 5420 | 5420 | { |
| 5421 | 5421 | $fquery->structure(); |
| 5422 | - $fquery->bodyPart($_partID,array('peek'=>true)); |
|
| 5422 | + $fquery->bodyPart($_partID, array('peek'=>true)); |
|
| 5423 | 5423 | } |
| 5424 | 5424 | $headersNew = $this->icServer->fetch($_folder, $fquery, array( |
| 5425 | 5425 | 'ids' => $uidsToFetch, |
| 5426 | 5426 | )); |
| 5427 | 5427 | if (is_object($headersNew)) { |
| 5428 | - foreach($headersNew as &$_headerObject) { |
|
| 5428 | + foreach ($headersNew as &$_headerObject) { |
|
| 5429 | 5429 | $body = $_headerObject->getFullMsg(); |
| 5430 | 5430 | if ($_partID != '') |
| 5431 | 5431 | { |
@@ -5433,7 +5433,7 @@ discard block |
||
| 5433 | 5433 | //_debug_array($mailStructureObject->contentTypeMap()); |
| 5434 | 5434 | foreach ($mailStructureObject->contentTypeMap() as $mime_id => $mime_type) |
| 5435 | 5435 | { |
| 5436 | - if ($mime_id==$_partID) |
|
| 5436 | + if ($mime_id == $_partID) |
|
| 5437 | 5437 | { |
| 5438 | 5438 | $body = $_headerObject->getBodyPart($mime_id); |
| 5439 | 5439 | } |
@@ -5442,7 +5442,7 @@ discard block |
||
| 5442 | 5442 | } |
| 5443 | 5443 | } |
| 5444 | 5444 | //error_log(__METHOD__.' ('.__LINE__.') '."[$this->icServer->ImapServerId][$_folder][$_uid][".(empty($_partID)?'NIL':$_partID)."]"); |
| 5445 | - $rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID)?'NIL':$_partID)] = $body; |
|
| 5445 | + $rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID) ? 'NIL' : $_partID)] = $body; |
|
| 5446 | 5446 | return $body; |
| 5447 | 5447 | } |
| 5448 | 5448 | |
@@ -5456,13 +5456,13 @@ discard block |
||
| 5456 | 5456 | * @param Horde_Imap_Client_Fetch_Query $fquery=null default query just structure |
| 5457 | 5457 | * @return Horde_Mime_Part |
| 5458 | 5458 | */ |
| 5459 | - function getStructure($_uid, $_partID=null, $_folder=null, $_preserveSeen=false) |
|
| 5459 | + function getStructure($_uid, $_partID = null, $_folder = null, $_preserveSeen = false) |
|
| 5460 | 5460 | { |
| 5461 | - if (self::$debug) error_log( __METHOD__.' ('.__LINE__.') '.":$_uid, $_partID"); |
|
| 5461 | + if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.":$_uid, $_partID"); |
|
| 5462 | 5462 | |
| 5463 | 5463 | if (empty($_folder)) |
| 5464 | 5464 | { |
| 5465 | - $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5465 | + $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5466 | 5466 | } |
| 5467 | 5467 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5468 | 5468 | if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
@@ -5480,7 +5480,7 @@ discard block |
||
| 5480 | 5480 | 'ids' => $uidsToFetch, |
| 5481 | 5481 | ))->first(); |
| 5482 | 5482 | |
| 5483 | - return is_object($mail)?$mail->getStructure():null; |
|
| 5483 | + return is_object($mail) ? $mail->getStructure() : null; |
|
| 5484 | 5484 | } |
| 5485 | 5485 | catch (\Exception $e) |
| 5486 | 5486 | { |
@@ -5503,14 +5503,14 @@ discard block |
||
| 5503 | 5503 | * @param string $_folder folder to work on |
| 5504 | 5504 | * @return array an array of information about the attachment: array of array(name, size, mimeType, partID, encoding) |
| 5505 | 5505 | */ |
| 5506 | - function getMessageAttachments($_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folder='') |
|
| 5506 | + function getMessageAttachments($_uid, $_partID = null, Horde_Mime_Part $_structure = null, $fetchEmbeddedImages = true, $fetchTextCalendar = false, $resolveTNEF = true, $_folder = '') |
|
| 5507 | 5507 | { |
| 5508 | - if (self::$debug) error_log( __METHOD__.":$_uid, $_partID"); |
|
| 5509 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5508 | + if (self::$debug) error_log(__METHOD__.":$_uid, $_partID"); |
|
| 5509 | + if (empty($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5510 | 5510 | $attachments = array(); |
| 5511 | 5511 | if (!isset($_structure)) |
| 5512 | 5512 | { |
| 5513 | - $_structure = $this->getStructure($_uid, $_partID,$_folder,true); |
|
| 5513 | + $_structure = $this->getStructure($_uid, $_partID, $_folder, true); |
|
| 5514 | 5514 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.print_r($_structure->contentTypeMap(),true)); |
| 5515 | 5515 | } |
| 5516 | 5516 | if (!$_structure || !$_structure->contentTypeMap()) return array(); |
@@ -5518,7 +5518,7 @@ discard block |
||
| 5518 | 5518 | $skipParts = array(); |
| 5519 | 5519 | $tnefParts = array(); |
| 5520 | 5520 | $skip = 0; |
| 5521 | - foreach($_structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 5521 | + foreach ($_structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 5522 | 5522 | { |
| 5523 | 5523 | // skip multipart/encrypted incl. its two sub-parts, as we show 2. sub-part as body to be decrypted client-side |
| 5524 | 5524 | if ($mime_type == 'multipart/encrypted') |
@@ -5526,7 +5526,7 @@ discard block |
||
| 5526 | 5526 | $skip = 2; |
| 5527 | 5527 | continue; |
| 5528 | 5528 | } |
| 5529 | - elseif($skip) |
|
| 5529 | + elseif ($skip) |
|
| 5530 | 5530 | { |
| 5531 | 5531 | $skip--; |
| 5532 | 5532 | continue; |
@@ -5540,10 +5540,10 @@ discard block |
||
| 5540 | 5540 | $partPrimaryType = $part->getPrimaryType(); |
| 5541 | 5541 | // we only want to retrieve the attachments of the current mail, not those of possible |
| 5542 | 5542 | // attached mails |
| 5543 | - if ($mime_type=='message/rfc822' && $_partID!=$mime_id) |
|
| 5543 | + if ($mime_type == 'message/rfc822' && $_partID != $mime_id) |
|
| 5544 | 5544 | { |
| 5545 | 5545 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.':'.array2string($part->contentTypeMap())); |
| 5546 | - foreach($part->contentTypeMap() as $sub_id => $sub_type) {if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type;} |
|
| 5546 | + foreach ($part->contentTypeMap() as $sub_id => $sub_type) {if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type; } |
|
| 5547 | 5547 | } |
| 5548 | 5548 | if (empty($partDisposition) && $partPrimaryType != 'multipart' && $partPrimaryType != 'text') |
| 5549 | 5549 | { |
@@ -5551,27 +5551,27 @@ discard block |
||
| 5551 | 5551 | // attachment with no link to show the attachment inline. |
| 5552 | 5552 | // Considering this: we "list" everything that matches the above criteria |
| 5553 | 5553 | // as attachment in order to not loose/miss information on our data |
| 5554 | - $partDisposition='attachment'; |
|
| 5554 | + $partDisposition = 'attachment'; |
|
| 5555 | 5555 | } |
| 5556 | 5556 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.' Part:'.$_partID.'->'.$mime_id.':'.array2string($skipParts)); |
| 5557 | - if (array_key_exists($mime_id,$skipParts)) continue; |
|
| 5557 | + if (array_key_exists($mime_id, $skipParts)) continue; |
|
| 5558 | 5558 | |
| 5559 | 5559 | if ($partDisposition == 'attachment' || |
| 5560 | - (($partDisposition == 'inline' || empty($partDisposition)) && $partPrimaryType == 'image' && $part->getContentId()=='') || |
|
| 5560 | + (($partDisposition == 'inline' || empty($partDisposition)) && $partPrimaryType == 'image' && $part->getContentId() == '') || |
|
| 5561 | 5561 | (($partDisposition == 'inline' || empty($partDisposition)) && $partPrimaryType != 'image' && $partPrimaryType != 'text' && $partPrimaryType != 'multipart') || |
| 5562 | - ($mime_type=='image/tiff') || //always fetch. even if $fetchEmbeddedImages is false. as we cannot display tiffs |
|
| 5562 | + ($mime_type == 'image/tiff') || //always fetch. even if $fetchEmbeddedImages is false. as we cannot display tiffs |
|
| 5563 | 5563 | ($fetchEmbeddedImages && ($partDisposition == 'inline' || empty($partDisposition)) && $partPrimaryType == 'image') || |
| 5564 | 5564 | ($fetchTextCalendar && $partPrimaryType == 'text' && $part->getSubType() == 'calendar')) |
| 5565 | 5565 | { |
| 5566 | 5566 | // if type is message/rfc822 and _partID is given, and MimeID equals partID |
| 5567 | 5567 | // we attempt to fetch "ourselves" |
| 5568 | - if ($_partID==$part->getMimeId() && $part->getPrimaryType()=='message') continue; |
|
| 5568 | + if ($_partID == $part->getMimeId() && $part->getPrimaryType() == 'message') continue; |
|
| 5569 | 5569 | $attachment = $part->getAllDispositionParameters(); |
| 5570 | 5570 | $attachment['disposition'] = $part->getDisposition(); |
| 5571 | 5571 | $attachment['mimeType'] = $mime_type; |
| 5572 | 5572 | $attachment['uid'] = $_uid; |
| 5573 | 5573 | $attachment['partID'] = $mime_id; |
| 5574 | - if (!isset($attachment['name'])||empty($attachment['name'])) $attachment['name'] = $part->getName(); |
|
| 5574 | + if (!isset($attachment['name']) || empty($attachment['name'])) $attachment['name'] = $part->getName(); |
|
| 5575 | 5575 | if ($fetchTextCalendar) |
| 5576 | 5576 | { |
| 5577 | 5577 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($part->getAllContentTypeParameters())); |
@@ -5581,11 +5581,11 @@ discard block |
||
| 5581 | 5581 | } |
| 5582 | 5582 | $attachment['size'] = $part->getBytes(); |
| 5583 | 5583 | if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
| 5584 | - 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); |
|
| 5584 | + 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); |
|
| 5585 | 5585 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.' Part:'.$_partID.'->'.$mime_id.':'.array2string($attachment)); |
| 5586 | 5586 | //typical winmail.dat attachment is |
| 5587 | 5587 | //Array([size] => 1462762[filename] => winmail.dat[mimeType] => application/ms-tnef[uid] => 100[partID] => 2[name] => winmail.dat) |
| 5588 | - if ($resolveTNEF && ($attachment['mimeType']=='application/ms-tnef' || !strcasecmp($attachment['name'],'winmail.dat'))) |
|
| 5588 | + if ($resolveTNEF && ($attachment['mimeType'] == 'application/ms-tnef' || !strcasecmp($attachment['name'], 'winmail.dat'))) |
|
| 5589 | 5589 | { |
| 5590 | 5590 | $tnefParts[] = $attachment; |
| 5591 | 5591 | } |
@@ -5600,31 +5600,31 @@ discard block |
||
| 5600 | 5600 | //error_log(__METHOD__.__LINE__.array2string($tnefParts)); |
| 5601 | 5601 | foreach ($tnefParts as $k => $tnp) |
| 5602 | 5602 | { |
| 5603 | - $tnefResolved=false; |
|
| 5604 | - $tnef_data = $this->getAttachment($tnp['uid'],$tnp['partID'],$k,false); |
|
| 5603 | + $tnefResolved = false; |
|
| 5604 | + $tnef_data = $this->getAttachment($tnp['uid'], $tnp['partID'], $k, false); |
|
| 5605 | 5605 | $myTnef = $this->tnef_decoder($tnef_data['attachment']); |
| 5606 | 5606 | //error_log(__METHOD__.__LINE__.array2string($myTnef->getParts())); |
| 5607 | 5607 | // Note: MimeId starts with 0, almost always, we cannot use that as winmail_id |
| 5608 | 5608 | // we need to build Something that meets the needs |
| 5609 | 5609 | if ($myTnef) |
| 5610 | 5610 | { |
| 5611 | - foreach($myTnef->getParts() as $mime_id => $part) |
|
| 5611 | + foreach ($myTnef->getParts() as $mime_id => $part) |
|
| 5612 | 5612 | { |
| 5613 | - $tnefResolved=true; |
|
| 5613 | + $tnefResolved = true; |
|
| 5614 | 5614 | $attachment = $part->getAllDispositionParameters(); |
| 5615 | 5615 | $attachment['disposition'] = $part->getDisposition(); |
| 5616 | 5616 | $attachment['mimeType'] = $part->getType(); |
| 5617 | 5617 | $attachment['uid'] = $tnp['uid']; |
| 5618 | 5618 | $attachment['partID'] = $tnp['partID']; |
| 5619 | 5619 | $attachment['is_winmail'] = $tnp['uid'].'@'.$tnp['partID'].'@'.$mime_id; |
| 5620 | - if (!isset($attachment['name'])||empty($attachment['name'])) $attachment['name'] = $part->getName(); |
|
| 5620 | + if (!isset($attachment['name']) || empty($attachment['name'])) $attachment['name'] = $part->getName(); |
|
| 5621 | 5621 | $attachment['size'] = $part->getBytes(); |
| 5622 | 5622 | if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
| 5623 | - 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']); |
|
| 5623 | + 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']); |
|
| 5624 | 5624 | $attachments[] = $attachment; |
| 5625 | 5625 | } |
| 5626 | 5626 | } |
| 5627 | - if ($tnefResolved===false) $attachments[]=$tnp; |
|
| 5627 | + if ($tnefResolved === false) $attachments[] = $tnp; |
|
| 5628 | 5628 | } |
| 5629 | 5629 | } |
| 5630 | 5630 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
@@ -5639,9 +5639,9 @@ discard block |
||
| 5639 | 5639 | * @return boolean|Horde_Mime_part Multipart/Mixed part decoded attachments | |
| 5640 | 5640 | * return false if there's no attachments or failure |
| 5641 | 5641 | */ |
| 5642 | - public function tnef_decoder( $data ) |
|
| 5642 | + public function tnef_decoder($data) |
|
| 5643 | 5643 | { |
| 5644 | - foreach(array('Horde_Compress', 'Horde_Icalendar', 'Horde_Mapi') as $class) |
|
| 5644 | + foreach (array('Horde_Compress', 'Horde_Icalendar', 'Horde_Mapi') as $class) |
|
| 5645 | 5645 | { |
| 5646 | 5646 | if (!class_exists($class)) |
| 5647 | 5647 | { |
@@ -5673,7 +5673,7 @@ discard block |
||
| 5673 | 5673 | $tmp_part->setContents($data['stream']); |
| 5674 | 5674 | $tmp_part->setDescription($data['name']); |
| 5675 | 5675 | |
| 5676 | - $type = $data['type'] . '/' . $data['subtype']; |
|
| 5676 | + $type = $data['type'].'/'.$data['subtype']; |
|
| 5677 | 5677 | if (in_array($type, array('application/octet-stream', 'application/base64'))) |
| 5678 | 5678 | { |
| 5679 | 5679 | $type = Horde_Mime_Magic::filenameToMIME($data['name']); |
@@ -5716,24 +5716,24 @@ discard block |
||
| 5716 | 5716 | * |
| 5717 | 5717 | * @return array returns an array of all resolved embeded attachments from winmail.dat |
| 5718 | 5718 | */ |
| 5719 | - function getTnefAttachments ($_uid, $_partID, $_stream=false) |
|
| 5719 | + function getTnefAttachments($_uid, $_partID, $_stream = false) |
|
| 5720 | 5720 | { |
| 5721 | - $tnef_data = $this->getAttachment($_uid, $_partID,0,false); |
|
| 5721 | + $tnef_data = $this->getAttachment($_uid, $_partID, 0, false); |
|
| 5722 | 5722 | $tnef_parts = $this->tnef_decoder($tnef_data['attachment']); |
| 5723 | 5723 | $attachments = array(); |
| 5724 | 5724 | if ($tnef_parts) |
| 5725 | 5725 | { |
| 5726 | - foreach($tnef_parts->getParts() as $mime_id => $part) |
|
| 5726 | + foreach ($tnef_parts->getParts() as $mime_id => $part) |
|
| 5727 | 5727 | { |
| 5728 | 5728 | |
| 5729 | 5729 | $attachment = $part->getAllDispositionParameters(); |
| 5730 | 5730 | $attachment['mimeType'] = $part->getType(); |
| 5731 | - if (!isset($attachment['filename'])||empty($attachment['filename'])) $attachment['filename'] = $part->getName(); |
|
| 5731 | + if (!isset($attachment['filename']) || empty($attachment['filename'])) $attachment['filename'] = $part->getName(); |
|
| 5732 | 5732 | if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
| 5733 | 5733 | if (empty($attachment['filename'])) |
| 5734 | 5734 | { |
| 5735 | - $attachment['filename'] = (isset($attachment['cid'])&&!empty($attachment['cid'])? |
|
| 5736 | - $attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']); |
|
| 5735 | + $attachment['filename'] = (isset($attachment['cid']) && !empty($attachment['cid']) ? |
|
| 5736 | + $attachment['cid'] : lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']); |
|
| 5737 | 5737 | } |
| 5738 | 5738 | |
| 5739 | 5739 | $attachment['attachment'] = $part->getContents(array('stream'=>$_stream)); |
@@ -5757,10 +5757,10 @@ discard block |
||
| 5757 | 5757 | * |
| 5758 | 5758 | * @return array |
| 5759 | 5759 | */ |
| 5760 | - function getAttachment($_uid, $_partID, $_winmail_nr=0, $_returnPart=true, $_stream=false, $_folder=null) |
|
| 5760 | + function getAttachment($_uid, $_partID, $_winmail_nr = 0, $_returnPart = true, $_stream = false, $_folder = null) |
|
| 5761 | 5761 | { |
| 5762 | 5762 | //error_log(__METHOD__.__LINE__."Uid:$_uid, PartId:$_partID, WinMailNr:$_winmail_nr, ReturnPart:$_returnPart, Stream:$_stream, Folder:$_folder".function_backtrace()); |
| 5763 | - if (!isset($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5763 | + if (!isset($_folder)) $_folder = ($this->sessionData['mailbox'] ? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5764 | 5764 | |
| 5765 | 5765 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5766 | 5766 | if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
@@ -5773,36 +5773,36 @@ discard block |
||
| 5773 | 5773 | 'ids' => $uidsToFetch, |
| 5774 | 5774 | )); |
| 5775 | 5775 | if (is_object($headersNew)) { |
| 5776 | - foreach($headersNew as $id=>$_headerObject) { |
|
| 5776 | + foreach ($headersNew as $id=>$_headerObject) { |
|
| 5777 | 5777 | $body = $_headerObject->getFullMsg(); |
| 5778 | 5778 | if ($_partID != '') |
| 5779 | 5779 | { |
| 5780 | 5780 | $mailStructureObject = $_headerObject->getStructure(); |
| 5781 | 5781 | $mailStructureObject->contentTypeMap(); |
| 5782 | 5782 | $part = $mailStructureObject->getPart($_partID); |
| 5783 | - $partDisposition = ($part?$part->getDisposition():'failed'); |
|
| 5784 | - if ($partDisposition=='failed') |
|
| 5783 | + $partDisposition = ($part ? $part->getDisposition() : 'failed'); |
|
| 5784 | + if ($partDisposition == 'failed') |
|
| 5785 | 5785 | { |
| 5786 | 5786 | error_log(__METHOD__.'('.__LINE__.'):'.array2string($_uid).','.$_partID.' ID:'.$id.' HObject:'.array2string($_headerObject).' StructureObject:'.array2string($mailStructureObject->contentTypeMap()).'->'.function_backtrace()); |
| 5787 | 5787 | } |
| 5788 | 5788 | // if $partDisposition is empty, we assume attachment, and hope that the function |
| 5789 | 5789 | // itself is only triggered to fetch attachments |
| 5790 | - if (empty($partDisposition)) $partDisposition='attachment'; |
|
| 5791 | - if ($part && ($partDisposition=='attachment' || $partDisposition=='inline' || ($part->getPrimaryType() == 'text' && $part->getSubType() == 'calendar'))) |
|
| 5790 | + if (empty($partDisposition)) $partDisposition = 'attachment'; |
|
| 5791 | + if ($part && ($partDisposition == 'attachment' || $partDisposition == 'inline' || ($part->getPrimaryType() == 'text' && $part->getSubType() == 'calendar'))) |
|
| 5792 | 5792 | { |
| 5793 | 5793 | //$headerObject=$part->getAllDispositionParameters();//not used anywhere around here |
| 5794 | 5794 | $structure_mime = $part->getType(); |
| 5795 | 5795 | $filename = $part->getName(); |
| 5796 | 5796 | $charset = $part->getContentTypeParameter('charset'); |
| 5797 | 5797 | //$structure_bytes = $part->getBytes(); $structure_partID=$part->getMimeId(); error_log(__METHOD__.__LINE__." fetchPartContents(".array2string($_uid).", $structure_partID, $_stream, $_preserveSeen,$structure_mime)" ); |
| 5798 | - $this->fetchPartContents($_uid, $part, $_stream, $_preserveSeen=true,$structure_mime); |
|
| 5798 | + $this->fetchPartContents($_uid, $part, $_stream, $_preserveSeen = true, $structure_mime); |
|
| 5799 | 5799 | if ($_returnPart) return $part; |
| 5800 | 5800 | } |
| 5801 | 5801 | } |
| 5802 | 5802 | } |
| 5803 | 5803 | } |
| 5804 | 5804 | $ext = MimeMagic::mime2ext($structure_mime); |
| 5805 | - if ($ext && stripos($filename,'.')===false && stripos($filename,$ext)===false) $filename = trim($filename).'.'.$ext; |
|
| 5805 | + if ($ext && stripos($filename, '.') === false && stripos($filename, $ext) === false) $filename = trim($filename).'.'.$ext; |
|
| 5806 | 5806 | if (!$part) |
| 5807 | 5807 | { |
| 5808 | 5808 | throw new Exception\WrongParameter("Error: Could not fetch attachment for Uid=".array2string($_uid).", PartId=$_partID, WinMailNr=$_winmail_nr, folder=$_folder"); |
@@ -5820,20 +5820,20 @@ discard block |
||
| 5820 | 5820 | // try guessing the mimetype, if we get the application/octet-stream |
| 5821 | 5821 | if (strtolower($attachmentData['type']) == 'application/octet-stream') $attachmentData['type'] = MimeMagic::filename2mime($attachmentData['filename']); |
| 5822 | 5822 | # if the attachment holds a winmail number and is a winmail.dat then we have to handle that. |
| 5823 | - if ( $filename == 'winmail.dat' && $_winmail_nr) |
|
| 5823 | + if ($filename == 'winmail.dat' && $_winmail_nr) |
|
| 5824 | 5824 | { |
| 5825 | 5825 | //by now _uid is of type array |
| 5826 | - $tnefResolved=false; |
|
| 5827 | - $wantedPart=$_uid[0].'@'.$_partID; |
|
| 5826 | + $tnefResolved = false; |
|
| 5827 | + $wantedPart = $_uid[0].'@'.$_partID; |
|
| 5828 | 5828 | $myTnef = $this->tnef_decoder($attachmentData['attachment']); |
| 5829 | 5829 | //error_log(__METHOD__.__LINE__.array2string($myTnef->getParts())); |
| 5830 | 5830 | // Note: MimeId starts with 0, almost always, we cannot use that as winmail_id |
| 5831 | 5831 | // we need to build Something that meets the needs |
| 5832 | 5832 | if ($myTnef) |
| 5833 | 5833 | { |
| 5834 | - foreach($myTnef->getParts() as $mime_id => $part) |
|
| 5834 | + foreach ($myTnef->getParts() as $mime_id => $part) |
|
| 5835 | 5835 | { |
| 5836 | - $tnefResolved=true; |
|
| 5836 | + $tnefResolved = true; |
|
| 5837 | 5837 | $attachment = $part->getAllDispositionParameters(); |
| 5838 | 5838 | $attachment['mimeType'] = $part->getType(); |
| 5839 | 5839 | //error_log(__METHOD__.__LINE__.'#'.$mime_id.'#'.$filename.'#'.array2string($attachment)); |
@@ -5841,9 +5841,9 @@ discard block |
||
| 5841 | 5841 | if ($_winmail_nr == $wantedPart.'@'.$mime_id) |
| 5842 | 5842 | { |
| 5843 | 5843 | //error_log(__METHOD__.__LINE__.'#'.$structure_mime.'#'.$filename.'#'.array2string($attachment)); |
| 5844 | - if (!isset($attachment['filename'])||empty($attachment['filename'])) $attachment['filename'] = $part->getName(); |
|
| 5844 | + if (!isset($attachment['filename']) || empty($attachment['filename'])) $attachment['filename'] = $part->getName(); |
|
| 5845 | 5845 | if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
| 5846 | - 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']); |
|
| 5846 | + 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']); |
|
| 5847 | 5847 | $wmattach = $attachment; |
| 5848 | 5848 | $wmattach['attachment'] = $part->getContents(array('stream'=>$_stream)); |
| 5849 | 5849 | |
@@ -5853,7 +5853,7 @@ discard block |
||
| 5853 | 5853 | if ($tnefResolved) |
| 5854 | 5854 | { |
| 5855 | 5855 | $ext = MimeMagic::mime2ext($wmattach['mimeType']); |
| 5856 | - if ($ext && stripos($wmattach['filename'],'.')===false && stripos($wmattach['filename'],$ext)===false) $wmattach['filename'] = trim($wmattach['filename']).'.'.$ext; |
|
| 5856 | + if ($ext && stripos($wmattach['filename'], '.') === false && stripos($wmattach['filename'], $ext) === false) $wmattach['filename'] = trim($wmattach['filename']).'.'.$ext; |
|
| 5857 | 5857 | $attachmentData = array( |
| 5858 | 5858 | 'type' => $wmattach['mimeType'], |
| 5859 | 5859 | 'filename' => $wmattach['filename'], |
@@ -5877,21 +5877,21 @@ discard block |
||
| 5877 | 5877 | * true: |
| 5878 | 5878 | * @return Horde_Mime_Part |
| 5879 | 5879 | */ |
| 5880 | - function getAttachmentByCID($_uid, $_cid, $_part, $_stream=null) |
|
| 5880 | + function getAttachmentByCID($_uid, $_cid, $_part, $_stream = null) |
|
| 5881 | 5881 | { |
| 5882 | 5882 | // some static variables to avoid fetching the same mail multiple times |
| 5883 | - static $uid=null, $part=null, $structure=null; |
|
| 5883 | + static $uid = null, $part = null, $structure = null; |
|
| 5884 | 5884 | //error_log(__METHOD__.' ('.__LINE__.') '.":$_uid, $_cid, $_part"); |
| 5885 | 5885 | |
| 5886 | - if(empty($_cid)) return false; |
|
| 5886 | + if (empty($_cid)) return false; |
|
| 5887 | 5887 | |
| 5888 | 5888 | if ($_uid != $uid || $_part != $part) |
| 5889 | 5889 | { |
| 5890 | - $structure = $this->getStructure($uid=$_uid, $part=$_part); |
|
| 5890 | + $structure = $this->getStructure($uid = $_uid, $part = $_part); |
|
| 5891 | 5891 | } |
| 5892 | 5892 | /** @var Horde_Mime_Part */ |
| 5893 | 5893 | $attachment = null; |
| 5894 | - foreach($structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 5894 | + foreach ($structure->contentTypeMap() as $mime_id => $mime_type) |
|
| 5895 | 5895 | { |
| 5896 | 5896 | $part = $structure->getPart($mime_id); |
| 5897 | 5897 | |
@@ -5943,16 +5943,16 @@ discard block |
||
| 5943 | 5943 | * @param string $_mimetype to decide wether to try to fetch part as binary or not |
| 5944 | 5944 | * @return Horde_Mime_Part |
| 5945 | 5945 | */ |
| 5946 | - public function fetchPartContents($_uid, Horde_Mime_Part $part=null, $_stream=false, $_preserveSeen=false, $_mimetype=null) |
|
| 5946 | + public function fetchPartContents($_uid, Horde_Mime_Part $part = null, $_stream = false, $_preserveSeen = false, $_mimetype = null) |
|
| 5947 | 5947 | { |
| 5948 | - if (is_null($part)) return null;//new Horde_Mime_Part; |
|
| 5948 | + if (is_null($part)) return null; //new Horde_Mime_Part; |
|
| 5949 | 5949 | $encoding = null; |
| 5950 | 5950 | $fetchAsBinary = true; |
| 5951 | - if ($_mimetype && strtolower($_mimetype)=='message/rfc822') $fetchAsBinary = false; |
|
| 5951 | + if ($_mimetype && strtolower($_mimetype) == 'message/rfc822') $fetchAsBinary = false; |
|
| 5952 | 5952 | // we need to set content on structure to decode transfer encoding |
| 5953 | 5953 | $part->setContents( |
| 5954 | 5954 | $this->getBodyPart($_uid, $part->getMimeId(), null, $_preserveSeen, $_stream, $encoding, $fetchAsBinary), |
| 5955 | - array('encoding' => (!$fetchAsBinary&&!$encoding?'8bit':$encoding))); |
|
| 5955 | + array('encoding' => (!$fetchAsBinary && !$encoding ? '8bit' : $encoding))); |
|
| 5956 | 5956 | |
| 5957 | 5957 | return $part; |
| 5958 | 5958 | } |
@@ -5970,17 +5970,17 @@ discard block |
||
| 5970 | 5970 | * @return the id of the message appended or exception |
| 5971 | 5971 | * @throws Exception\WrongUserinput |
| 5972 | 5972 | */ |
| 5973 | - function appendMessage($_folderName, $_header, $_body, $_flags='\\Recent') |
|
| 5973 | + function appendMessage($_folderName, $_header, $_body, $_flags = '\\Recent') |
|
| 5974 | 5974 | { |
| 5975 | 5975 | if (!is_resource($_header)) |
| 5976 | 5976 | { |
| 5977 | - if (stripos($_header,'message-id:')===false) |
|
| 5977 | + if (stripos($_header, 'message-id:') === false) |
|
| 5978 | 5978 | { |
| 5979 | 5979 | $_header = 'Message-ID: <'.self::getRandomString().'@localhost>'."\n".$_header; |
| 5980 | 5980 | } |
| 5981 | 5981 | //error_log(__METHOD__.' ('.__LINE__.') '."$_folderName, $_header, $_body, $_flags"); |
| 5982 | - $_header = ltrim(str_replace("\n","\r\n",$_header)); |
|
| 5983 | - $_header .= str_replace("\n","\r\n",$_body); |
|
| 5982 | + $_header = ltrim(str_replace("\n", "\r\n", $_header)); |
|
| 5983 | + $_header .= str_replace("\n", "\r\n", $_body); |
|
| 5984 | 5984 | } |
| 5985 | 5985 | // the recent flag is the default enforced here ; as we assume the _flags is always set, |
| 5986 | 5986 | // we default it to hordes default (Recent) (, other wise we should not pass the parameter |
@@ -5998,7 +5998,7 @@ discard block |
||
| 5998 | 5998 | // searched for the message-id then returning the uid found |
| 5999 | 5999 | //$dataNflags[] = array('data'=>array(array('t'=>'text','v'=>"$header"."$body")), 'flags'=>array($_flags)); |
| 6000 | 6000 | $dataNflags[] = array('data' => $_header, 'flags'=>array($_flags)); |
| 6001 | - $messageid = $this->icServer->append($_folderName,$dataNflags); |
|
| 6001 | + $messageid = $this->icServer->append($_folderName, $dataNflags); |
|
| 6002 | 6002 | } |
| 6003 | 6003 | catch (\Exception $e) |
| 6004 | 6004 | { |
@@ -6010,7 +6010,7 @@ discard block |
||
| 6010 | 6010 | //$messageid = true; // for debug reasons only |
| 6011 | 6011 | if ($messageid === true || empty($messageid)) // try to figure out the message uid |
| 6012 | 6012 | { |
| 6013 | - $list = $this->getHeaders($_folderName, $_startMessage=1, 1, 'INTERNALDATE', true, array(),null, false); |
|
| 6013 | + $list = $this->getHeaders($_folderName, $_startMessage = 1, 1, 'INTERNALDATE', true, array(), null, false); |
|
| 6014 | 6014 | if ($list) |
| 6015 | 6015 | { |
| 6016 | 6016 | if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' MessageUid:'.$messageid.' but found:'.array2string($list)); |
@@ -6050,27 +6050,27 @@ discard block |
||
| 6050 | 6050 | * 'attachments'=>$attachments, |
| 6051 | 6051 | * 'headers'=>$headers,; boolean false on failure |
| 6052 | 6052 | */ |
| 6053 | - static function get_mailcontent(&$mailClass,$uid,$partid='',$mailbox='', $preserveHTML = false, $addHeaderSection=true, $includeAttachments=true) |
|
| 6053 | + static function get_mailcontent(&$mailClass, $uid, $partid = '', $mailbox = '', $preserveHTML = false, $addHeaderSection = true, $includeAttachments = true) |
|
| 6054 | 6054 | { |
| 6055 | 6055 | //echo __METHOD__." called for $uid,$partid <br>"; |
| 6056 | - $headers = $mailClass->getMessageHeader($uid,$partid,true,false,$mailbox); |
|
| 6056 | + $headers = $mailClass->getMessageHeader($uid, $partid, true, false, $mailbox); |
|
| 6057 | 6057 | if (empty($headers)) return false; |
| 6058 | 6058 | // dont force retrieval of the textpart, let mailClass preferences decide |
| 6059 | - $bodyParts = $mailClass->getMessageBody($uid,($preserveHTML?'always_display':'only_if_no_text'),$partid,null,false,$mailbox); |
|
| 6059 | + $bodyParts = $mailClass->getMessageBody($uid, ($preserveHTML ? 'always_display' : 'only_if_no_text'), $partid, null, false, $mailbox); |
|
| 6060 | 6060 | // if we do not want HTML but there is no TextRepresentation with the message itself, try converting |
| 6061 | - if ( !$preserveHTML && $bodyParts[0]['mimeType']=='text/html') |
|
| 6061 | + if (!$preserveHTML && $bodyParts[0]['mimeType'] == 'text/html') |
|
| 6062 | 6062 | { |
| 6063 | - foreach($bodyParts as $i => $part) |
|
| 6063 | + foreach ($bodyParts as $i => $part) |
|
| 6064 | 6064 | { |
| 6065 | - if ($bodyParts[$i]['mimeType']=='text/html') |
|
| 6065 | + if ($bodyParts[$i]['mimeType'] == 'text/html') |
|
| 6066 | 6066 | { |
| 6067 | - $bodyParts[$i]['body'] = Mail\Html::convertHTMLToText($bodyParts[$i]['body'],$bodyParts[$i]['charSet'],true,$stripalltags=true); |
|
| 6068 | - $bodyParts[$i]['mimeType']='text/plain'; |
|
| 6067 | + $bodyParts[$i]['body'] = Mail\Html::convertHTMLToText($bodyParts[$i]['body'], $bodyParts[$i]['charSet'], true, $stripalltags = true); |
|
| 6068 | + $bodyParts[$i]['mimeType'] = 'text/plain'; |
|
| 6069 | 6069 | } |
| 6070 | 6070 | } |
| 6071 | 6071 | } |
| 6072 | 6072 | //error_log(array2string($bodyParts)); |
| 6073 | - $attachments = $includeAttachments?$mailClass->getMessageAttachments($uid,$partid,null,true,false,true,$mailbox):array(); |
|
| 6073 | + $attachments = $includeAttachments ? $mailClass->getMessageAttachments($uid, $partid, null, true, false, true, $mailbox) : array(); |
|
| 6074 | 6074 | |
| 6075 | 6075 | if ($mailClass->isSentFolder($mailbox)) $mailaddress = $headers['TO']; |
| 6076 | 6076 | elseif (isset($headers['FROM'])) $mailaddress = $headers['FROM']; |
@@ -6081,7 +6081,7 @@ discard block |
||
| 6081 | 6081 | |
| 6082 | 6082 | $message = self::getdisplayableBody($mailClass, $bodyParts, $preserveHTML); |
| 6083 | 6083 | if ($preserveHTML && $mailClass->activeMimeType == 'text/plain') $message = '<pre>'.$message.'</pre>'; |
| 6084 | - $headdata = ($addHeaderSection ? self::createHeaderInfoSection($headers, '',$preserveHTML) : ''); |
|
| 6084 | + $headdata = ($addHeaderSection ? self::createHeaderInfoSection($headers, '', $preserveHTML) : ''); |
|
| 6085 | 6085 | $message = $headdata.$message; |
| 6086 | 6086 | //echo __METHOD__.'<br>'; |
| 6087 | 6087 | //_debug_array($attachments); |
@@ -6097,25 +6097,25 @@ discard block |
||
| 6097 | 6097 | //_debug_array($mailClass->getMessageHeader($uid, $attachment['partID'])); |
| 6098 | 6098 | //_debug_array($mailClass->getMessageBody($uid,'', $attachment['partID'])); |
| 6099 | 6099 | //_debug_array($mailClass->getMessageAttachments($uid, $attachment['partID'])); |
| 6100 | - $mailcontent = self::get_mailcontent($mailClass,$uid,$attachment['partID'],$mailbox); |
|
| 6101 | - $headdata =''; |
|
| 6100 | + $mailcontent = self::get_mailcontent($mailClass, $uid, $attachment['partID'], $mailbox); |
|
| 6101 | + $headdata = ''; |
|
| 6102 | 6102 | if ($mailcontent['headers']) |
| 6103 | 6103 | { |
| 6104 | - $headdata = self::createHeaderInfoSection($mailcontent['headers'],'',$preserveHTML); |
|
| 6104 | + $headdata = self::createHeaderInfoSection($mailcontent['headers'], '', $preserveHTML); |
|
| 6105 | 6105 | } |
| 6106 | 6106 | if ($mailcontent['message']) |
| 6107 | 6107 | { |
| 6108 | - $tempname =tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_"); |
|
| 6108 | + $tempname = tempnam($GLOBALS['egw_info']['server']['temp_dir'], $GLOBALS['egw_info']['flags']['currentapp']."_"); |
|
| 6109 | 6109 | $attachedMessages[] = array( |
| 6110 | 6110 | 'type' => 'TEXT/PLAIN', |
| 6111 | 6111 | 'name' => $mailcontent['subject'].'.txt', |
| 6112 | 6112 | 'tmp_name' => $tempname, |
| 6113 | 6113 | ); |
| 6114 | - $tmpfile = fopen($tempname,'w'); |
|
| 6115 | - fwrite($tmpfile,$headdata.$mailcontent['message']); |
|
| 6114 | + $tmpfile = fopen($tempname, 'w'); |
|
| 6115 | + fwrite($tmpfile, $headdata.$mailcontent['message']); |
|
| 6116 | 6116 | fclose($tmpfile); |
| 6117 | 6117 | } |
| 6118 | - foreach($mailcontent['attachments'] as &$tmpval) |
|
| 6118 | + foreach ($mailcontent['attachments'] as &$tmpval) |
|
| 6119 | 6119 | { |
| 6120 | 6120 | $attachedMessages[] = $tmpval; |
| 6121 | 6121 | } |
@@ -6123,36 +6123,36 @@ discard block |
||
| 6123 | 6123 | } |
| 6124 | 6124 | else |
| 6125 | 6125 | { |
| 6126 | - $attachments[$num] = array_merge($attachments[$num],$mailClass->getAttachment($uid, $attachment['partID'],0,false,false)); |
|
| 6126 | + $attachments[$num] = array_merge($attachments[$num], $mailClass->getAttachment($uid, $attachment['partID'], 0, false, false)); |
|
| 6127 | 6127 | |
| 6128 | - if (empty($attachments[$num]['attachment'])&&$attachments[$num]['cid']) |
|
| 6128 | + if (empty($attachments[$num]['attachment']) && $attachments[$num]['cid']) |
|
| 6129 | 6129 | { |
| 6130 | - $c = $mailClass->getAttachmentByCID($uid, $attachment['cid'], $attachment['partID'],true); |
|
| 6130 | + $c = $mailClass->getAttachmentByCID($uid, $attachment['cid'], $attachment['partID'], true); |
|
| 6131 | 6131 | $attachments[$num]['attachment'] = $c->getContents(); |
| 6132 | 6132 | } |
| 6133 | 6133 | // no attempt to convert, if we dont know about the charset |
| 6134 | - if (isset($attachments[$num]['charset'])&&!empty($attachments[$num]['charset'])) { |
|
| 6134 | + if (isset($attachments[$num]['charset']) && !empty($attachments[$num]['charset'])) { |
|
| 6135 | 6135 | // we do not try guessing the charset, if it is not set |
| 6136 | 6136 | //if ($attachments[$num]['charset']===false) $attachments[$num]['charset'] = Translation::detect_encoding($attachments[$num]['attachment']); |
| 6137 | - Translation::convert($attachments[$num]['attachment'],$attachments[$num]['charset']); |
|
| 6137 | + Translation::convert($attachments[$num]['attachment'], $attachments[$num]['charset']); |
|
| 6138 | 6138 | } |
| 6139 | - if(in_array($attachments[$num]['name'], $file_list)) |
|
| 6139 | + if (in_array($attachments[$num]['name'], $file_list)) |
|
| 6140 | 6140 | { |
| 6141 | 6141 | $dupe_count[$attachments[$num]['name']]++; |
| 6142 | - $attachments[$num]['name'] = pathinfo($attachments[$num]['name'], PATHINFO_FILENAME) . |
|
| 6143 | - ' ('.($dupe_count[$attachments[$num]['name']] + 1).')' . '.' . |
|
| 6142 | + $attachments[$num]['name'] = pathinfo($attachments[$num]['name'], PATHINFO_FILENAME). |
|
| 6143 | + ' ('.($dupe_count[$attachments[$num]['name']] + 1).')'.'.'. |
|
| 6144 | 6144 | pathinfo($attachments[$num]['name'], PATHINFO_EXTENSION); |
| 6145 | 6145 | } |
| 6146 | 6146 | $attachments[$num]['type'] = $attachments[$num]['mimeType']; |
| 6147 | - $attachments[$num]['tmp_name'] = tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_"); |
|
| 6148 | - $tmpfile = fopen($attachments[$num]['tmp_name'],'w'); |
|
| 6149 | - fwrite($tmpfile,$attachments[$num]['attachment']); |
|
| 6147 | + $attachments[$num]['tmp_name'] = tempnam($GLOBALS['egw_info']['server']['temp_dir'], $GLOBALS['egw_info']['flags']['currentapp']."_"); |
|
| 6148 | + $tmpfile = fopen($attachments[$num]['tmp_name'], 'w'); |
|
| 6149 | + fwrite($tmpfile, $attachments[$num]['attachment']); |
|
| 6150 | 6150 | fclose($tmpfile); |
| 6151 | 6151 | $file_list[] = $attachments[$num]['name']; |
| 6152 | 6152 | unset($attachments[$num]['attachment']); |
| 6153 | 6153 | } |
| 6154 | 6154 | } |
| 6155 | - if (is_array($attachedMessages)) $attachments = array_merge($attachments,$attachedMessages); |
|
| 6155 | + if (is_array($attachedMessages)) $attachments = array_merge($attachments, $attachedMessages); |
|
| 6156 | 6156 | } |
| 6157 | 6157 | return array( |
| 6158 | 6158 | 'mailaddress'=>$mailaddress, |
@@ -6174,10 +6174,10 @@ discard block |
||
| 6174 | 6174 | { |
| 6175 | 6175 | $c = 0; |
| 6176 | 6176 | // use the standardIdentity |
| 6177 | - foreach($_identities as $key => $acc) { |
|
| 6178 | - if ($c==0) $identity = $acc; |
|
| 6177 | + foreach ($_identities as $key => $acc) { |
|
| 6178 | + if ($c == 0) $identity = $acc; |
|
| 6179 | 6179 | //error_log(__METHOD__.__LINE__." $key == $_profile_id "); |
| 6180 | - if ($key==$_profile_id) $identity = $acc; |
|
| 6180 | + if ($key == $_profile_id) $identity = $acc; |
|
| 6181 | 6181 | $c++; |
| 6182 | 6182 | } |
| 6183 | 6183 | return $identity; |
@@ -6189,29 +6189,29 @@ discard block |
||
| 6189 | 6189 | * @param bool createHTML do it with HTML breaks |
| 6190 | 6190 | * @return string a preformatted string with the information of the header worked into it |
| 6191 | 6191 | */ |
| 6192 | - static function createHeaderInfoSection($header,$headline='', $createHTML = false) |
|
| 6192 | + static function createHeaderInfoSection($header, $headline = '', $createHTML = false) |
|
| 6193 | 6193 | { |
| 6194 | 6194 | $headdata = null; |
| 6195 | 6195 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($header).function_backtrace()); |
| 6196 | - if ($header['SUBJECT']) $headdata = lang('subject').': '.$header['SUBJECT'].($createHTML?"<br />":"\n"); |
|
| 6197 | - if ($header['FROM']) $headdata .= lang('from').': '.self::convertAddressArrayToString($header['FROM'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6198 | - if ($header['SENDER']) $headdata .= lang('sender').': '.self::convertAddressArrayToString($header['SENDER'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6199 | - if ($header['TO']) $headdata .= lang('to').': '.self::convertAddressArrayToString($header['TO'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6200 | - if ($header['CC']) $headdata .= lang('cc').': '.self::convertAddressArrayToString($header['CC'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6201 | - if ($header['BCC']) $headdata .= lang('bcc').': '.self::convertAddressArrayToString($header['BCC'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6202 | - if ($header['DATE']) $headdata .= lang('date').': '.$header['DATE'].($createHTML?"<br />":"\n"); |
|
| 6203 | - if ($header['PRIORITY'] && $header['PRIORITY'] != 'normal') $headdata .= lang('priority').': '.$header['PRIORITY'].($createHTML?"<br />":"\n"); |
|
| 6204 | - if ($header['IMPORTANCE'] && $header['IMPORTANCE'] !='normal') $headdata .= lang('importance').': '.$header['IMPORTANCE'].($createHTML?"<br />":"\n"); |
|
| 6196 | + if ($header['SUBJECT']) $headdata = lang('subject').': '.$header['SUBJECT'].($createHTML ? "<br />" : "\n"); |
|
| 6197 | + if ($header['FROM']) $headdata .= lang('from').': '.self::convertAddressArrayToString($header['FROM'], $createHTML).($createHTML ? "<br />" : "\n"); |
|
| 6198 | + if ($header['SENDER']) $headdata .= lang('sender').': '.self::convertAddressArrayToString($header['SENDER'], $createHTML).($createHTML ? "<br />" : "\n"); |
|
| 6199 | + if ($header['TO']) $headdata .= lang('to').': '.self::convertAddressArrayToString($header['TO'], $createHTML).($createHTML ? "<br />" : "\n"); |
|
| 6200 | + if ($header['CC']) $headdata .= lang('cc').': '.self::convertAddressArrayToString($header['CC'], $createHTML).($createHTML ? "<br />" : "\n"); |
|
| 6201 | + if ($header['BCC']) $headdata .= lang('bcc').': '.self::convertAddressArrayToString($header['BCC'], $createHTML).($createHTML ? "<br />" : "\n"); |
|
| 6202 | + if ($header['DATE']) $headdata .= lang('date').': '.$header['DATE'].($createHTML ? "<br />" : "\n"); |
|
| 6203 | + if ($header['PRIORITY'] && $header['PRIORITY'] != 'normal') $headdata .= lang('priority').': '.$header['PRIORITY'].($createHTML ? "<br />" : "\n"); |
|
| 6204 | + if ($header['IMPORTANCE'] && $header['IMPORTANCE'] != 'normal') $headdata .= lang('importance').': '.$header['IMPORTANCE'].($createHTML ? "<br />" : "\n"); |
|
| 6205 | 6205 | //if ($mailcontent['headers']['ORGANIZATION']) $headdata .= lang('organization').': '.$mailcontent['headers']['ORGANIZATION']."\ |
| 6206 | 6206 | if (!empty($headdata)) |
| 6207 | 6207 | { |
| 6208 | - if (!empty($headline) && $headline != 'SUPPRESS') $headdata = "---------------------------- $headline ----------------------------".($createHTML?"<br />":"\n").$headdata; |
|
| 6209 | - if (empty($headline)) $headdata = ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):'').$headdata; |
|
| 6210 | - $headdata .= ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):''); |
|
| 6208 | + if (!empty($headline) && $headline != 'SUPPRESS') $headdata = "---------------------------- $headline ----------------------------".($createHTML ? "<br />" : "\n").$headdata; |
|
| 6209 | + if (empty($headline)) $headdata = ($headline != 'SUPPRESS' ? "--------------------------------------------------------".($createHTML ? "<br />" : "\n") : '').$headdata; |
|
| 6210 | + $headdata .= ($headline != 'SUPPRESS' ? "--------------------------------------------------------".($createHTML ? "<br />" : "\n") : ''); |
|
| 6211 | 6211 | } |
| 6212 | 6212 | else |
| 6213 | 6213 | { |
| 6214 | - $headdata = ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):''); |
|
| 6214 | + $headdata = ($headline != 'SUPPRESS' ? "--------------------------------------------------------".($createHTML ? "<br />" : "\n") : ''); |
|
| 6215 | 6215 | } |
| 6216 | 6216 | return $headdata; |
| 6217 | 6217 | } |
@@ -6224,8 +6224,8 @@ discard block |
||
| 6224 | 6224 | */ |
| 6225 | 6225 | static function adaptSubjectForImport($subject) |
| 6226 | 6226 | { |
| 6227 | - $subject = str_replace('$$','__',($subject?$subject:lang('(no subject)'))); |
|
| 6228 | - $subject = str_ireplace(array('[FWD]','[',']','{','}','<','>'),array('Fwd:',' ',' ',' ',' ',' ',' '),trim($subject)); |
|
| 6227 | + $subject = str_replace('$$', '__', ($subject ? $subject : lang('(no subject)'))); |
|
| 6228 | + $subject = str_ireplace(array('[FWD]', '[', ']', '{', '}', '<', '>'), array('Fwd:', ' ', ' ', ' ', ' ', ' ', ' '), trim($subject)); |
|
| 6229 | 6229 | return $subject; |
| 6230 | 6230 | } |
| 6231 | 6231 | |
@@ -6237,15 +6237,15 @@ discard block |
||
| 6237 | 6237 | static function convertAddressArrayToString($rfcAddressArray) |
| 6238 | 6238 | { |
| 6239 | 6239 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($rfcAddressArray)); |
| 6240 | - $returnAddr =''; |
|
| 6240 | + $returnAddr = ''; |
|
| 6241 | 6241 | if (is_array($rfcAddressArray)) |
| 6242 | 6242 | { |
| 6243 | - foreach((array)$rfcAddressArray as $addressData) { |
|
| 6243 | + foreach ((array)$rfcAddressArray as $addressData) { |
|
| 6244 | 6244 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($addressData)); |
| 6245 | - if($addressData['MAILBOX_NAME'] == 'NIL') { |
|
| 6245 | + if ($addressData['MAILBOX_NAME'] == 'NIL') { |
|
| 6246 | 6246 | continue; |
| 6247 | 6247 | } |
| 6248 | - if(strtolower($addressData['MAILBOX_NAME']) == 'undisclosed-recipients') { |
|
| 6248 | + if (strtolower($addressData['MAILBOX_NAME']) == 'undisclosed-recipients') { |
|
| 6249 | 6249 | continue; |
| 6250 | 6250 | } |
| 6251 | 6251 | if ($addressData['RFC822_EMAIL']) |
@@ -6254,7 +6254,7 @@ discard block |
||
| 6254 | 6254 | } |
| 6255 | 6255 | else |
| 6256 | 6256 | { |
| 6257 | - $emailaddress = ($addressData['PERSONAL_NAME']?$addressData['PERSONAL_NAME'].' <'.$addressData['EMAIL'].'>':$addressData['EMAIL']); |
|
| 6257 | + $emailaddress = ($addressData['PERSONAL_NAME'] ? $addressData['PERSONAL_NAME'].' <'.$addressData['EMAIL'].'>' : $addressData['EMAIL']); |
|
| 6258 | 6258 | $addressObjectA = self::parseAddressList($emailaddress); |
| 6259 | 6259 | } |
| 6260 | 6260 | $addressObject = $addressObjectA[0]; |
@@ -6263,10 +6263,10 @@ discard block |
||
| 6263 | 6263 | //$mb =(string)$addressObject->mailbox; |
| 6264 | 6264 | //$h = (string)$addressObject->host; |
| 6265 | 6265 | //$p = (string)$addressObject->personal; |
| 6266 | - $returnAddr .= (strlen($returnAddr)>0?',':''); |
|
| 6266 | + $returnAddr .= (strlen($returnAddr) > 0 ? ',' : ''); |
|
| 6267 | 6267 | //error_log(__METHOD__.' ('.__LINE__.') '.$p.' <'.$mb.'@'.$h.'>'); |
| 6268 | 6268 | $buff = imap_rfc822_write_address($addressObject->mailbox, Horde_Idna::decode($addressObject->host), $addressObject->personal); |
| 6269 | - $buff = str_replace(array('<','>','"\'','\'"'),array('[',']','"','"'),$buff); |
|
| 6269 | + $buff = str_replace(array('<', '>', '"\'', '\'"'), array('[', ']', '"', '"'), $buff); |
|
| 6270 | 6270 | //error_log(__METHOD__.' ('.__LINE__.') '.' Address: '.$returnAddr); |
| 6271 | 6271 | $returnAddr .= $buff; |
| 6272 | 6272 | } |
@@ -6274,8 +6274,8 @@ discard block |
||
| 6274 | 6274 | else |
| 6275 | 6275 | { |
| 6276 | 6276 | // do not mess with strings, return them untouched /* ToDo: validate string as Address */ |
| 6277 | - $rfcAddressArray = self::decode_header($rfcAddressArray,true); |
|
| 6278 | - $rfcAddressArray = str_replace(array('<','>','"\'','\'"'),array('[',']','"','"'),$rfcAddressArray); |
|
| 6277 | + $rfcAddressArray = self::decode_header($rfcAddressArray, true); |
|
| 6278 | + $rfcAddressArray = str_replace(array('<', '>', '"\'', '\'"'), array('[', ']', '"', '"'), $rfcAddressArray); |
|
| 6279 | 6279 | if (is_string($rfcAddressArray)) return $rfcAddressArray; |
| 6280 | 6280 | } |
| 6281 | 6281 | return $returnAddr; |
@@ -6289,12 +6289,12 @@ discard block |
||
| 6289 | 6289 | * @param string &$err error-message on error |
| 6290 | 6290 | * @return string/boolean merged content or false on error |
| 6291 | 6291 | */ |
| 6292 | - static function merge($content,$ids,$mimetype='') |
|
| 6292 | + static function merge($content, $ids, $mimetype = '') |
|
| 6293 | 6293 | { |
| 6294 | 6294 | $mergeobj = new Contacts\Merge(); |
| 6295 | 6295 | |
| 6296 | - if (empty($mimetype)) $mimetype = (strlen(strip_tags($content)) == strlen($content) ?'text/plain':'text/html'); |
|
| 6297 | - $rv = $mergeobj->merge_string($content,$ids,$err='',$mimetype, array(), self::$displayCharset); |
|
| 6296 | + if (empty($mimetype)) $mimetype = (strlen(strip_tags($content)) == strlen($content) ? 'text/plain' : 'text/html'); |
|
| 6297 | + $rv = $mergeobj->merge_string($content, $ids, $err = '', $mimetype, array(), self::$displayCharset); |
|
| 6298 | 6298 | if (empty($rv) && !empty($content) && !empty($err)) $rv = $content; |
| 6299 | 6299 | if (!empty($err) && !empty($content) && !empty($ids)) error_log(__METHOD__.' ('.__LINE__.') '.' Merge failed for Ids:'.array2string($ids).' ContentType:'.$mimetype.' Content:'.$content.' Reason:'.array2string($err)); |
| 6300 | 6300 | return $rv; |
@@ -6336,12 +6336,12 @@ discard block |
||
| 6336 | 6336 | else |
| 6337 | 6337 | settype($bytes, 'integer'); |
| 6338 | 6338 | |
| 6339 | - return $bytes . ' ' . $type ; |
|
| 6339 | + return $bytes.' '.$type; |
|
| 6340 | 6340 | } |
| 6341 | 6341 | |
| 6342 | 6342 | static function detect_qp(&$sting) { |
| 6343 | 6343 | $needle = '/(=[0-9][A-F])|(=[A-F][0-9])|(=[A-F][A-F])|(=[0-9][0-9])/'; |
| 6344 | - return preg_match("$needle",$string); |
|
| 6344 | + return preg_match("$needle", $string); |
|
| 6345 | 6345 | } |
| 6346 | 6346 | |
| 6347 | 6347 | /** |
@@ -6354,11 +6354,11 @@ discard block |
||
| 6354 | 6354 | * @param string $_methodNline - Information where the log was taken |
| 6355 | 6355 | * @return void |
| 6356 | 6356 | */ |
| 6357 | - static function logRunTimes($_starttime,$_endtime=null,$_message='',$_methodNline='') |
|
| 6357 | + static function logRunTimes($_starttime, $_endtime = null, $_message = '', $_methodNline = '') |
|
| 6358 | 6358 | { |
| 6359 | 6359 | if (is_null($_endtime)) $_endtime = microtime(true); |
| 6360 | 6360 | $usagetime = microtime(true) - $_starttime; |
| 6361 | - if (self::$debugTimes) error_log($_methodNline.' took:'.number_format($usagetime,5).'(s) '.($_message?'Details:'.$_message:'')); |
|
| 6361 | + if (self::$debugTimes) error_log($_methodNline.' took:'.number_format($usagetime, 5).'(s) '.($_message ? 'Details:'.$_message : '')); |
|
| 6362 | 6362 | } |
| 6363 | 6363 | |
| 6364 | 6364 | /** |
@@ -6371,9 +6371,9 @@ discard block |
||
| 6371 | 6371 | * |
| 6372 | 6372 | * @throws Exception\WrongUserinput |
| 6373 | 6373 | */ |
| 6374 | - static function checkFileBasics(&$_formData, $IDtoAddToFileName='', $reqMimeType='message/rfc822') |
|
| 6374 | + static function checkFileBasics(&$_formData, $IDtoAddToFileName = '', $reqMimeType = 'message/rfc822') |
|
| 6375 | 6375 | { |
| 6376 | - if (parse_url($_formData['file'],PHP_URL_SCHEME) == 'egw-data') return $_formData['file']; |
|
| 6376 | + if (parse_url($_formData['file'], PHP_URL_SCHEME) == 'egw-data') return $_formData['file']; |
|
| 6377 | 6377 | |
| 6378 | 6378 | //error_log(__METHOD__.__FILE__.array2string($_formData).' Id:'.$IDtoAddToFileName.' ReqMimeType:'.$reqMimeType); |
| 6379 | 6379 | $importfailed = $tmpFileName = false; |
@@ -6383,7 +6383,7 @@ discard block |
||
| 6383 | 6383 | $importfailed = true; |
| 6384 | 6384 | $alert_msg .= lang("Empty file %1 ignored.", $_formData['name']); |
| 6385 | 6385 | } |
| 6386 | - elseif (parse_url($_formData['file'],PHP_URL_SCHEME) == 'vfs' || is_uploaded_file($_formData['file']) || |
|
| 6386 | + elseif (parse_url($_formData['file'], PHP_URL_SCHEME) == 'vfs' || is_uploaded_file($_formData['file']) || |
|
| 6387 | 6387 | realpath(dirname($_formData['file'])) == realpath($GLOBALS['egw_info']['server']['temp_dir'])) |
| 6388 | 6388 | { |
| 6389 | 6389 | // ensure existance of eGW temp dir |
@@ -6391,7 +6391,7 @@ discard block |
||
| 6391 | 6391 | // and different from any other temp file location set in php.ini |
| 6392 | 6392 | if (!file_exists($GLOBALS['egw_info']['server']['temp_dir'])) |
| 6393 | 6393 | { |
| 6394 | - @mkdir($GLOBALS['egw_info']['server']['temp_dir'],0700); |
|
| 6394 | + @mkdir($GLOBALS['egw_info']['server']['temp_dir'], 0700); |
|
| 6395 | 6395 | } |
| 6396 | 6396 | |
| 6397 | 6397 | // if we were NOT able to create this temp directory, then make an ERROR report |
@@ -6418,14 +6418,14 @@ discard block |
||
| 6418 | 6418 | // maybe its application/octet-stream -> this may mean that we could not determine the type |
| 6419 | 6419 | // so we check for the suffix too |
| 6420 | 6420 | // trust vfs mime-types, trust the mimetype if it contains a method |
| 6421 | - if ((substr($_formData['file'],0,6) !== 'vfs://' || $_formData['type'] == 'application/octet-stream') && stripos($_formData['type'],'method=')===false) |
|
| 6421 | + if ((substr($_formData['file'], 0, 6) !== 'vfs://' || $_formData['type'] == 'application/octet-stream') && stripos($_formData['type'], 'method=') === false) |
|
| 6422 | 6422 | { |
| 6423 | - $buff = explode('.',$_formData['name']); |
|
| 6423 | + $buff = explode('.', $_formData['name']); |
|
| 6424 | 6424 | $suffix = ''; |
| 6425 | 6425 | if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
| 6426 | 6426 | if (!empty($suffix)) $sfxMimeType = MimeMagic::ext2mime($suffix); |
| 6427 | 6427 | if (!empty($suffix) && !empty($sfxMimeType) && |
| 6428 | - (strlen(trim($_formData['type']))==0 || (strtolower(trim($_formData['type'])) != $sfxMimeType))) |
|
| 6428 | + (strlen(trim($_formData['type'])) == 0 || (strtolower(trim($_formData['type'])) != $sfxMimeType))) |
|
| 6429 | 6429 | { |
| 6430 | 6430 | error_log(__METHOD__.' ('.__LINE__.') '.' Data:'.array2string($_formData)); |
| 6431 | 6431 | error_log(__METHOD__.' ('.__LINE__.') '.' Form reported Mimetype:'.$_formData['type'].' but seems to be:'.$sfxMimeType); |
@@ -6440,13 +6440,13 @@ discard block |
||
| 6440 | 6440 | if ($reqMimeType) |
| 6441 | 6441 | { |
| 6442 | 6442 | // so if PHP did not pass any file_type info, then substitute the rfc default value |
| 6443 | - if (substr(strtolower(trim($_formData['type'])),0,strlen($mime_type_default)) != $mime_type_default) |
|
| 6443 | + if (substr(strtolower(trim($_formData['type'])), 0, strlen($mime_type_default)) != $mime_type_default) |
|
| 6444 | 6444 | { |
| 6445 | 6445 | if (!(strtolower(trim($_formData['type'])) == "application/octet-stream" && $sfxMimeType == $reqMimeType)) |
| 6446 | 6446 | { |
| 6447 | 6447 | //error_log("Message rejected, no message/rfc. Is:".$_formData['type']); |
| 6448 | 6448 | $importfailed = true; |
| 6449 | - $alert_msg .= lang("File rejected, no %2. Is:%1",$_formData['type'],$reqMimeType); |
|
| 6449 | + $alert_msg .= lang("File rejected, no %2. Is:%1", $_formData['type'], $reqMimeType); |
|
| 6450 | 6450 | } |
| 6451 | 6451 | if ((strtolower(trim($_formData['type'])) != $reqMimeType && $sfxMimeType == $reqMimeType)) |
| 6452 | 6452 | { |
@@ -6455,17 +6455,17 @@ discard block |
||
| 6455 | 6455 | } |
| 6456 | 6456 | } |
| 6457 | 6457 | // as FreeBSD seems to have problems with the generated temp names we append some more random stuff |
| 6458 | - $randomString = chr(rand(65,90)).chr(rand(48,57)).chr(rand(65,90)).chr(rand(48,57)).chr(rand(65,90)); |
|
| 6458 | + $randomString = chr(rand(65, 90)).chr(rand(48, 57)).chr(rand(65, 90)).chr(rand(48, 57)).chr(rand(65, 90)); |
|
| 6459 | 6459 | $tmpFileName = $GLOBALS['egw_info']['user']['account_id']. |
| 6460 | 6460 | trim($IDtoAddToFileName).basename($_formData['file']).'_'.$randomString; |
| 6461 | 6461 | |
| 6462 | - if (parse_url($_formData['file'],PHP_URL_SCHEME) == 'vfs') |
|
| 6462 | + if (parse_url($_formData['file'], PHP_URL_SCHEME) == 'vfs') |
|
| 6463 | 6463 | { |
| 6464 | - $tmpFileName = $_formData['file']; // no need to store it somewhere |
|
| 6464 | + $tmpFileName = $_formData['file']; // no need to store it somewhere |
|
| 6465 | 6465 | } |
| 6466 | 6466 | elseif (is_uploaded_file($_formData['file'])) |
| 6467 | 6467 | { |
| 6468 | - move_uploaded_file($_formData['file'], $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmpFileName); // requirement for safe_mode! |
|
| 6468 | + move_uploaded_file($_formData['file'], $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmpFileName); // requirement for safe_mode! |
|
| 6469 | 6469 | } |
| 6470 | 6470 | else |
| 6471 | 6471 | { |
@@ -6474,7 +6474,7 @@ discard block |
||
| 6474 | 6474 | } else { |
| 6475 | 6475 | //error_log("Import of message ".$_formData['file']." failes to meet basic restrictions"); |
| 6476 | 6476 | $importfailed = true; |
| 6477 | - $alert_msg .= lang("Processing of file %1 failed. Failed to meet basic restrictions.",$_formData['name']); |
|
| 6477 | + $alert_msg .= lang("Processing of file %1 failed. Failed to meet basic restrictions.", $_formData['name']); |
|
| 6478 | 6478 | } |
| 6479 | 6479 | if ($importfailed == true) |
| 6480 | 6480 | { |
@@ -6482,7 +6482,7 @@ discard block |
||
| 6482 | 6482 | } |
| 6483 | 6483 | else |
| 6484 | 6484 | { |
| 6485 | - if (parse_url($tmpFileName,PHP_URL_SCHEME) == 'vfs') |
|
| 6485 | + if (parse_url($tmpFileName, PHP_URL_SCHEME) == 'vfs') |
|
| 6486 | 6486 | { |
| 6487 | 6487 | Vfs::load_wrapper('vfs'); |
| 6488 | 6488 | } |
@@ -6507,7 +6507,7 @@ discard block |
||
| 6507 | 6507 | $images = null; |
| 6508 | 6508 | if (preg_match_all("/(src|background)=\"(.*)\"/Ui", $_html2parse, $images) && isset($images[2])) |
| 6509 | 6509 | { |
| 6510 | - foreach($images[2] as $i => $url) |
|
| 6510 | + foreach ($images[2] as $i => $url) |
|
| 6511 | 6511 | { |
| 6512 | 6512 | //$isData = false; |
| 6513 | 6513 | $basedir = $data = ''; |
@@ -6519,20 +6519,20 @@ discard block |
||
| 6519 | 6519 | $filename = basename($url); |
| 6520 | 6520 | if (($directory = dirname($url)) == '.') $directory = ''; |
| 6521 | 6521 | $ext = pathinfo($filename, PATHINFO_EXTENSION); |
| 6522 | - $mimeType = MimeMagic::ext2mime($ext); |
|
| 6523 | - if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; } |
|
| 6522 | + $mimeType = MimeMagic::ext2mime($ext); |
|
| 6523 | + if (strlen($directory) > 1 && substr($directory, -1) != '/') { $directory .= '/'; } |
|
| 6524 | 6524 | $myUrl = $directory.$filename; |
| 6525 | - if ($myUrl[0]=='/') // local path -> we only allow path's that are available via http/https (or vfs) |
|
| 6525 | + if ($myUrl[0] == '/') // local path -> we only allow path's that are available via http/https (or vfs) |
|
| 6526 | 6526 | { |
| 6527 | - $basedir = ($_SERVER['HTTPS']?'https://':'http://'.$_SERVER['HTTP_HOST']); |
|
| 6527 | + $basedir = ($_SERVER['HTTPS'] ? 'https://' : 'http://'.$_SERVER['HTTP_HOST']); |
|
| 6528 | 6528 | } |
| 6529 | 6529 | // use vfs instead of url containing webdav.php |
| 6530 | 6530 | // ToDo: we should test if the webdav url is of our own scope, as we cannot handle foreign |
| 6531 | 6531 | // webdav.php urls as vfs |
| 6532 | - if (strpos($myUrl,'/webdav.php') !== false) // we have a webdav link, so we build a vfs/sqlfs link of it. |
|
| 6532 | + if (strpos($myUrl, '/webdav.php') !== false) // we have a webdav link, so we build a vfs/sqlfs link of it. |
|
| 6533 | 6533 | { |
| 6534 | 6534 | Vfs::load_wrapper('vfs'); |
| 6535 | - list(,$myUrl) = explode('/webdav.php',$myUrl,2); |
|
| 6535 | + list(,$myUrl) = explode('/webdav.php', $myUrl, 2); |
|
| 6536 | 6536 | $basedir = 'vfs://default'; |
| 6537 | 6537 | $needTempFile = false; |
| 6538 | 6538 | } |
@@ -6545,11 +6545,11 @@ discard block |
||
| 6545 | 6545 | // Strips the url and store it into a temp for further procss |
| 6546 | 6546 | $tmp_url = html_entity_decode($myUrl); |
| 6547 | 6547 | |
| 6548 | - parse_str(parse_url($tmp_url, PHP_URL_QUERY),$URI_params); |
|
| 6548 | + parse_str(parse_url($tmp_url, PHP_URL_QUERY), $URI_params); |
|
| 6549 | 6549 | if ($URI_params['mailbox'] && $URI_params['uid'] && $URI_params['cid']) |
| 6550 | 6550 | { |
| 6551 | 6551 | $mail_bo->reopen(base64_decode($URI_params['mailbox'])); |
| 6552 | - $attachment = $mail_bo->getAttachmentByCID($URI_params['uid'], base64_decode($URI_params['cid']),base64_decode($URI_params['partID']),true); |
|
| 6552 | + $attachment = $mail_bo->getAttachmentByCID($URI_params['uid'], base64_decode($URI_params['cid']), base64_decode($URI_params['partID']), true); |
|
| 6553 | 6553 | $mail_bo->closeConnection(); |
| 6554 | 6554 | if ($attachment) |
| 6555 | 6555 | { |
@@ -6560,32 +6560,32 @@ discard block |
||
| 6560 | 6560 | } |
| 6561 | 6561 | } |
| 6562 | 6562 | |
| 6563 | - if ( strlen($basedir) > 1 && substr($basedir,-1) != '/' && $myUrl[0]!='/') { $basedir .= '/'; } |
|
| 6564 | - if ($needTempFile && !$attachment && substr($myUrl,0,4) !== "http") $data = file_get_contents($basedir.urldecode($myUrl)); |
|
| 6563 | + if (strlen($basedir) > 1 && substr($basedir, -1) != '/' && $myUrl[0] != '/') { $basedir .= '/'; } |
|
| 6564 | + if ($needTempFile && !$attachment && substr($myUrl, 0, 4) !== "http") $data = file_get_contents($basedir.urldecode($myUrl)); |
|
| 6565 | 6565 | } |
| 6566 | - if (substr($url,0,strlen('data:'))=='data:') |
|
| 6566 | + if (substr($url, 0, strlen('data:')) == 'data:') |
|
| 6567 | 6567 | { |
| 6568 | 6568 | //error_log(__METHOD__.' ('.__LINE__.') '.' -> '.$i.': '.array2string($images[$i])); |
| 6569 | 6569 | // we only support base64 encoded data |
| 6570 | - $tmp = substr($url,strlen('data:')); |
|
| 6571 | - list($mimeType,$data_base64) = explode(';base64,',$tmp); |
|
| 6570 | + $tmp = substr($url, strlen('data:')); |
|
| 6571 | + list($mimeType, $data_base64) = explode(';base64,', $tmp); |
|
| 6572 | 6572 | $data = base64_decode($data_base64); |
| 6573 | 6573 | // FF currently does NOT add any mime-type |
| 6574 | 6574 | if (strtolower(substr($mimeType, 0, 6)) != 'image/') |
| 6575 | 6575 | { |
| 6576 | 6576 | $mimeType = MimeMagic::analyze_data($data); |
| 6577 | 6577 | } |
| 6578 | - list($what,$exactly) = explode('/',$mimeType); |
|
| 6578 | + list($what, $exactly) = explode('/', $mimeType); |
|
| 6579 | 6579 | $needTempFile = true; |
| 6580 | - $filename = ($what?$what:'data').$imageC++.'.'.$exactly; |
|
| 6580 | + $filename = ($what ? $what : 'data').$imageC++.'.'.$exactly; |
|
| 6581 | 6581 | } |
| 6582 | 6582 | if ($data || $needTempFile === false) |
| 6583 | 6583 | { |
| 6584 | 6584 | if ($needTempFile) |
| 6585 | 6585 | { |
| 6586 | - $attachment_file =tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_"); |
|
| 6587 | - $tmpfile = fopen($attachment_file,'w'); |
|
| 6588 | - fwrite($tmpfile,$data); |
|
| 6586 | + $attachment_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'], $GLOBALS['egw_info']['flags']['currentapp']."_"); |
|
| 6587 | + $tmpfile = fopen($attachment_file, 'w'); |
|
| 6588 | + fwrite($tmpfile, $data); |
|
| 6589 | 6589 | fclose($tmpfile); |
| 6590 | 6590 | } |
| 6591 | 6591 | else |
@@ -6596,7 +6596,7 @@ discard block |
||
| 6596 | 6596 | // (or similar) in all cases (when cut&paste). This may lead to more attached files, in case |
| 6597 | 6597 | // we use the same image multiple times, but, if we do this, we should try to detect that |
| 6598 | 6598 | // on upload. filename itself is not sufficient to determine the sameness of images |
| 6599 | - $cid = 'cid:' . md5($attachment_file); |
|
| 6599 | + $cid = 'cid:'.md5($attachment_file); |
|
| 6600 | 6600 | if ($_mailObject->AddEmbeddedImage($attachment_file, substr($cid, 4), urldecode($filename), $mimeType) !== null) |
| 6601 | 6601 | { |
| 6602 | 6602 | //$_html2parse = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $_html2parse); |
@@ -6618,10 +6618,10 @@ discard block |
||
| 6618 | 6618 | * @param string& $importID ID for the imported message, used by attachments to identify them unambiguously |
| 6619 | 6619 | * @return mixed array of messages with success and failed messages or exception |
| 6620 | 6620 | */ |
| 6621 | - function importMessageToMergeAndSend(Storage\Merge $bo_merge, $document, $SendAndMergeTocontacts, &$_folder, &$importID='') |
|
| 6621 | + function importMessageToMergeAndSend(Storage\Merge $bo_merge, $document, $SendAndMergeTocontacts, &$_folder, &$importID = '') |
|
| 6622 | 6622 | { |
| 6623 | 6623 | $importfailed = false; |
| 6624 | - $processStats = array('success'=>array(),'failed'=>array()); |
|
| 6624 | + $processStats = array('success'=>array(), 'failed'=>array()); |
|
| 6625 | 6625 | if (empty($SendAndMergeTocontacts)) |
| 6626 | 6626 | { |
| 6627 | 6627 | $importfailed = true; |
@@ -6662,7 +6662,7 @@ discard block |
||
| 6662 | 6662 | $_folder = $this->getSentFolder(); |
| 6663 | 6663 | } |
| 6664 | 6664 | $delimiter = $this->getHierarchyDelimiter(); |
| 6665 | - if($_folder=='INBOX'.$delimiter) $_folder='INBOX'; |
|
| 6665 | + if ($_folder == 'INBOX'.$delimiter) $_folder = 'INBOX'; |
|
| 6666 | 6666 | if ($importfailed === false) |
| 6667 | 6667 | { |
| 6668 | 6668 | $Subject = $mailObject->getHeader('Subject'); |
@@ -6680,9 +6680,9 @@ discard block |
||
| 6680 | 6680 | { |
| 6681 | 6681 | $mailObject->clearReplyTos(); |
| 6682 | 6682 | $activeMailProfiles = $this->mail->getAccountIdentities($this->profileID); |
| 6683 | - $activeMailProfile = self::getStandardIdentityForProfile($activeMailProfiles,$this->profileID); |
|
| 6683 | + $activeMailProfile = self::getStandardIdentityForProfile($activeMailProfiles, $this->profileID); |
|
| 6684 | 6684 | |
| 6685 | - $mailObject->addReplyTo(Horde_Idna::encode($activeMailProfile['ident_email']),Mail::generateIdentityString($activeMailProfile,false)); |
|
| 6685 | + $mailObject->addReplyTo(Horde_Idna::encode($activeMailProfile['ident_email']), Mail::generateIdentityString($activeMailProfile, false)); |
|
| 6686 | 6686 | } |
| 6687 | 6687 | foreach ($SendAndMergeTocontacts as $k => $val) |
| 6688 | 6688 | { |
@@ -6696,12 +6696,12 @@ discard block |
||
| 6696 | 6696 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mailObject)); |
| 6697 | 6697 | |
| 6698 | 6698 | // Parse destinations for placeholders |
| 6699 | - foreach(Mailer::$type2header as $type => $h) |
|
| 6699 | + foreach (Mailer::$type2header as $type => $h) |
|
| 6700 | 6700 | { |
| 6701 | 6701 | //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)); |
| 6702 | - $merged = $bo_merge->merge_string($mailObject->getHeader(Mailer::$type2header[$type]),$val,$e,'text/plain',array(),self::$displayCharset); |
|
| 6703 | - $mailObject->addAddress($merged,'',$type); |
|
| 6704 | - if($type == 'to') |
|
| 6702 | + $merged = $bo_merge->merge_string($mailObject->getHeader(Mailer::$type2header[$type]), $val, $e, 'text/plain', array(), self::$displayCharset); |
|
| 6703 | + $mailObject->addAddress($merged, '', $type); |
|
| 6704 | + if ($type == 'to') |
|
| 6705 | 6705 | { |
| 6706 | 6706 | $email = $merged; |
| 6707 | 6707 | } |
@@ -6714,26 +6714,26 @@ discard block |
||
| 6714 | 6714 | //error_log(__METHOD__.' ('.__LINE__.') '.' ID:'.$val.' Data:'.array2string($contact)); |
| 6715 | 6715 | $email = ($contact['email'] ? $contact['email'] : $contact['email_home']); |
| 6716 | 6716 | $nfn = ($contact['n_fn'] ? $contact['n_fn'] : $contact['n_given'].' '.$contact['n_family']); |
| 6717 | - if($email) |
|
| 6717 | + if ($email) |
|
| 6718 | 6718 | { |
| 6719 | 6719 | $mailObject->addAddress(Horde_Idna::encode($email), $nfn); |
| 6720 | 6720 | } |
| 6721 | 6721 | } |
| 6722 | 6722 | |
| 6723 | 6723 | $activeMailProfiles = $this->getAccountIdentities($this->profileID); |
| 6724 | - $activeMailProfile = self::getStandardIdentityForProfile($activeMailProfiles,$this->profileID); |
|
| 6724 | + $activeMailProfile = self::getStandardIdentityForProfile($activeMailProfiles, $this->profileID); |
|
| 6725 | 6725 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($activeMailProfile)); |
| 6726 | 6726 | $mailObject->setFrom($activeMailProfile['ident_email'], |
| 6727 | - self::generateIdentityString($activeMailProfile,false)); |
|
| 6727 | + self::generateIdentityString($activeMailProfile, false)); |
|
| 6728 | 6728 | |
| 6729 | 6729 | $mailObject->removeHeader('Message-ID'); |
| 6730 | 6730 | $mailObject->removeHeader('Date'); |
| 6731 | 6731 | $mailObject->clearCustomHeaders(); |
| 6732 | 6732 | $mailObject->addHeader('Subject', $bo_merge->merge_string($Subject, $val, $e, 'text/plain', array(), self::$displayCharset)); |
| 6733 | 6733 | //error_log(__METHOD__.' ('.__LINE__.') '.' ContentType:'.$mailObject->BodyContentType); |
| 6734 | - 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)); |
|
| 6734 | + 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)); |
|
| 6735 | 6735 | //error_log(__METHOD__.' ('.__LINE__.') '.' Result:'.$mailObject->Body.' error:'.array2string($e)); |
| 6736 | - 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)); |
|
| 6736 | + 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)); |
|
| 6737 | 6737 | |
| 6738 | 6738 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mailObject)); |
| 6739 | 6739 | // set a higher timeout for big messages |
@@ -6742,7 +6742,7 @@ discard block |
||
| 6742 | 6742 | try { |
| 6743 | 6743 | $mailObject->send(); |
| 6744 | 6744 | } |
| 6745 | - catch(Exception $e) { |
|
| 6745 | + catch (Exception $e) { |
|
| 6746 | 6746 | $sendOK = false; |
| 6747 | 6747 | $errorInfo = $e->getMessage(); |
| 6748 | 6748 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($errorInfo)); |
@@ -6756,41 +6756,41 @@ discard block |
||
| 6756 | 6756 | $mailObject->clearCustomHeaders(); |
| 6757 | 6757 | |
| 6758 | 6758 | // Parse destinations for placeholders |
| 6759 | - foreach(Mailer::$type2header as $type => $h) |
|
| 6759 | + foreach (Mailer::$type2header as $type => $h) |
|
| 6760 | 6760 | { |
| 6761 | - $merged = $bo_merge->merge_string($mailObject->getHeader(Mailer::$type2header[$type]),$val,$e,'text/plain',array(),self::$displayCharset); |
|
| 6761 | + $merged = $bo_merge->merge_string($mailObject->getHeader(Mailer::$type2header[$type]), $val, $e, 'text/plain', array(), self::$displayCharset); |
|
| 6762 | 6762 | //error_log($type . ': ' . $mailObject->getHeader(Mailer::$type2header[$type]) . ' -> ' .$merged); |
| 6763 | - $mailObject->addAddress(trim($merged,'"'),'',$type); |
|
| 6763 | + $mailObject->addAddress(trim($merged, '"'), '', $type); |
|
| 6764 | 6764 | } |
| 6765 | 6765 | |
| 6766 | 6766 | // No addresses from placeholders? Treat it as just a contact ID |
| 6767 | - if (count($mailObject->getAddresses('to',true)) == 0 && |
|
| 6767 | + if (count($mailObject->getAddresses('to', true)) == 0 && |
|
| 6768 | 6768 | is_numeric($val) || $GLOBALS['egw']->accounts->name2id($val)) // do the merge |
| 6769 | 6769 | { |
| 6770 | 6770 | $contact = $bo_merge->contacts->read($val); |
| 6771 | 6771 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($contact)); |
| 6772 | 6772 | $email = ($contact['email'] ? $contact['email'] : $contact['email_home']); |
| 6773 | 6773 | $nfn = ($contact['n_fn'] ? $contact['n_fn'] : $contact['n_given'].' '.$contact['n_family']); |
| 6774 | - if($email) |
|
| 6774 | + if ($email) |
|
| 6775 | 6775 | { |
| 6776 | 6776 | $mailObject->addAddress(Horde_Idna::encode($email), $nfn); |
| 6777 | 6777 | } |
| 6778 | 6778 | } |
| 6779 | 6779 | $mailObject->addHeader('Subject', $bo_merge->merge_string($Subject, $val, $e, 'text/plain', array(), self::$displayCharset)); |
| 6780 | 6780 | //error_log(__METHOD__.' ('.__LINE__.') '.' ContentType:'.$mailObject->BodyContentType); |
| 6781 | - 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)); |
|
| 6781 | + 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)); |
|
| 6782 | 6782 | //error_log(__METHOD__.' ('.__LINE__.') '.' Result:'.$mailObject->Body.' error:'.array2string($e)); |
| 6783 | - 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)); |
|
| 6783 | + 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)); |
|
| 6784 | 6784 | $_folder = $this->getDraftFolder(); |
| 6785 | 6785 | } |
| 6786 | 6786 | if ($sendOK || $openAsDraft) |
| 6787 | 6787 | { |
| 6788 | - if ($this->folderExists($_folder,true)) |
|
| 6788 | + if ($this->folderExists($_folder, true)) |
|
| 6789 | 6789 | { |
| 6790 | - if($this->isSentFolder($_folder)) |
|
| 6790 | + if ($this->isSentFolder($_folder)) |
|
| 6791 | 6791 | { |
| 6792 | 6792 | $flags = '\\Seen'; |
| 6793 | - } elseif($this->isDraftFolder($_folder)) { |
|
| 6793 | + } elseif ($this->isDraftFolder($_folder)) { |
|
| 6794 | 6794 | $flags = '\\Draft'; |
| 6795 | 6795 | } else { |
| 6796 | 6796 | $flags = ''; |
@@ -6798,7 +6798,7 @@ discard block |
||
| 6798 | 6798 | $savefailed = false; |
| 6799 | 6799 | try |
| 6800 | 6800 | { |
| 6801 | - $messageUid =$this->appendMessage($_folder, |
|
| 6801 | + $messageUid = $this->appendMessage($_folder, |
|
| 6802 | 6802 | $mailObject->getRaw(), |
| 6803 | 6803 | null, |
| 6804 | 6804 | $flags); |
@@ -6806,10 +6806,10 @@ discard block |
||
| 6806 | 6806 | catch (\Exception\WrongUserinput $e) |
| 6807 | 6807 | { |
| 6808 | 6808 | $savefailed = true; |
| 6809 | - $alert_msg .= lang("Save of message %1 failed. Could not save message to folder %2 due to: %3",$Subject,$_folder,$e->getMessage()); |
|
| 6809 | + $alert_msg .= lang("Save of message %1 failed. Could not save message to folder %2 due to: %3", $Subject, $_folder, $e->getMessage()); |
|
| 6810 | 6810 | } |
| 6811 | 6811 | // no send, save successful, and message_uid present |
| 6812 | - if ($savefailed===false && $messageUid && is_null($sendOK)) |
|
| 6812 | + if ($savefailed === false && $messageUid && is_null($sendOK)) |
|
| 6813 | 6813 | { |
| 6814 | 6814 | $importID = $messageUid; |
| 6815 | 6815 | $openComposeWindow = true; |
@@ -6818,20 +6818,20 @@ discard block |
||
| 6818 | 6818 | else |
| 6819 | 6819 | { |
| 6820 | 6820 | $savefailed = true; |
| 6821 | - $alert_msg .= lang("Saving of message %1 failed. Destination Folder %2 does not exist.",$Subject,$_folder); |
|
| 6821 | + $alert_msg .= lang("Saving of message %1 failed. Destination Folder %2 does not exist.", $Subject, $_folder); |
|
| 6822 | 6822 | } |
| 6823 | 6823 | if ($sendOK) |
| 6824 | 6824 | { |
| 6825 | - $processStats['success'][$val] = 'Send succeeded to '.$nfn.'<'.$email.'>'.($savefailed?' but failed to store to Folder:'.$_folder:''); |
|
| 6825 | + $processStats['success'][$val] = 'Send succeeded to '.$nfn.'<'.$email.'>'.($savefailed ? ' but failed to store to Folder:'.$_folder : ''); |
|
| 6826 | 6826 | } |
| 6827 | 6827 | else |
| 6828 | 6828 | { |
| 6829 | - if (!$openComposeWindow) $processStats['failed'][$val] = $errorInfo?$errorInfo:'Send failed to '.$nfn.'<'.$email.'> See error_log for details'; |
|
| 6829 | + if (!$openComposeWindow) $processStats['failed'][$val] = $errorInfo ? $errorInfo : 'Send failed to '.$nfn.'<'.$email.'> See error_log for details'; |
|
| 6830 | 6830 | } |
| 6831 | 6831 | } |
| 6832 | - if (!is_null($sendOK) && $sendOK===false && is_null($openComposeWindow)) |
|
| 6832 | + if (!is_null($sendOK) && $sendOK === false && is_null($openComposeWindow)) |
|
| 6833 | 6833 | { |
| 6834 | - $processStats['failed'][$val] = $errorInfo?$errorInfo:'Send failed to '.$nfn.'<'.$email.'> See error_log for details'; |
|
| 6834 | + $processStats['failed'][$val] = $errorInfo ? $errorInfo : 'Send failed to '.$nfn.'<'.$email.'> See error_log for details'; |
|
| 6835 | 6835 | } |
| 6836 | 6836 | } |
| 6837 | 6837 | } |
@@ -6901,19 +6901,18 @@ discard block |
||
| 6901 | 6901 | //error_log(__METHOD__.__LINE__.':'.array2string($structure)); |
| 6902 | 6902 | |
| 6903 | 6903 | // unfortunately parseMessage does NOT return parsed headers (we assume header is shorter then 8k) |
| 6904 | - $start = is_string($message) ? substr($message, 0, 8192) : |
|
| 6905 | - (fseek($message, 0, SEEK_SET) == -1 ? '' : fread($message, 8192)); |
|
| 6904 | + $start = is_string($message) ? substr($message, 0, 8192) : (fseek($message, 0, SEEK_SET) == -1 ? '' : fread($message, 8192)); |
|
| 6906 | 6905 | |
| 6907 | 6906 | $length = strpos($start, Horde_Mime_Part::RFC_EOL.Horde_Mime_Part::RFC_EOL); |
| 6908 | - if ($length===false) $length = strlen($start); |
|
| 6909 | - $headers = Horde_Mime_Headers::parseHeaders(substr($start, 0,$length)); |
|
| 6907 | + if ($length === false) $length = strlen($start); |
|
| 6908 | + $headers = Horde_Mime_Headers::parseHeaders(substr($start, 0, $length)); |
|
| 6910 | 6909 | |
| 6911 | - foreach($headers->toArray(array('nowrap' => true)) as $header => $value) |
|
| 6910 | + foreach ($headers->toArray(array('nowrap' => true)) as $header => $value) |
|
| 6912 | 6911 | { |
| 6913 | - foreach((array)$value as $n => $val) |
|
| 6912 | + foreach ((array)$value as $n => $val) |
|
| 6914 | 6913 | { |
| 6915 | 6914 | $overwrite = !$n; |
| 6916 | - switch($header) |
|
| 6915 | + switch ($header) |
|
| 6917 | 6916 | { |
| 6918 | 6917 | case 'Content-Transfer-Encoding': |
| 6919 | 6918 | //as we parse the message and this sets the part with a Content-Transfer-Encoding, we |
@@ -6934,7 +6933,7 @@ discard block |
||
| 6934 | 6933 | } |
| 6935 | 6934 | else |
| 6936 | 6935 | { |
| 6937 | - if (($type = gettype($message)) == 'object') $type = get_class ($message); |
|
| 6936 | + if (($type = gettype($message)) == 'object') $type = get_class($message); |
|
| 6938 | 6937 | throw new Exception\WrongParameter('Wrong parameter type for message: '.$type); |
| 6939 | 6938 | } |
| 6940 | 6939 | } |
@@ -6948,50 +6947,50 @@ discard block |
||
| 6948 | 6947 | * @param string $default_domain |
| 6949 | 6948 | * @return Horde_Mail_Rfc822_List iteratable Horde_Mail_Rfc822_Address objects with attributes mailbox, host, personal and valid |
| 6950 | 6949 | */ |
| 6951 | - public static function parseAddressList($addresses, $default_domain=null) |
|
| 6950 | + public static function parseAddressList($addresses, $default_domain = null) |
|
| 6952 | 6951 | { |
| 6953 | 6952 | $rfc822 = new Horde_Mail_Rfc822(); |
| 6954 | 6953 | $ret = $rfc822->parseAddressList($addresses, $default_domain ? array('default_domain' => $default_domain) : array()); |
| 6955 | 6954 | //error_log(__METHOD__.__LINE__.'#'.array2string($addresses).'#'.array2string($ret).'#'.$ret->count().'#'.$ret->count.function_backtrace()); |
| 6956 | - if ((empty($ret) || $ret->count()==0)&& is_string($addresses) && strlen($addresses)>0) |
|
| 6955 | + if ((empty($ret) || $ret->count() == 0) && is_string($addresses) && strlen($addresses) > 0) |
|
| 6957 | 6956 | { |
| 6958 | 6957 | $matches = array(); |
| 6959 | - preg_match_all("/[\w\.,-.,_.,0-9.]+@[\w\.,-.,_.,0-9.]+/",$addresses,$matches); |
|
| 6958 | + preg_match_all("/[\w\.,-.,_.,0-9.]+@[\w\.,-.,_.,0-9.]+/", $addresses, $matches); |
|
| 6960 | 6959 | //error_log(__METHOD__.__LINE__.array2string($matches)); |
| 6961 | - foreach ($matches[0] as &$match) {$match = trim($match,', ');} |
|
| 6962 | - $addresses = implode(',',$matches[0]); |
|
| 6960 | + foreach ($matches[0] as &$match) {$match = trim($match, ', '); } |
|
| 6961 | + $addresses = implode(',', $matches[0]); |
|
| 6963 | 6962 | //error_log(__METHOD__.__LINE__.array2string($addresses)); |
| 6964 | 6963 | $ret = $rfc822->parseAddressList($addresses, $default_domain ? array('default_domain' => $default_domain) : array()); |
| 6965 | 6964 | //error_log(__METHOD__.__LINE__.'#'.array2string($addresses).'#'.array2string($ret).'#'.$ret->count().'#'.$ret->count); |
| 6966 | 6965 | } |
| 6967 | - $previousFailed=false; |
|
| 6966 | + $previousFailed = false; |
|
| 6968 | 6967 | $ret2 = new Horde_Mail_Rfc822_List(); |
| 6969 | 6968 | // handle known problems on emailaddresses |
| 6970 | - foreach($ret as $i => $adr) |
|
| 6969 | + foreach ($ret as $i => $adr) |
|
| 6971 | 6970 | { |
| 6972 | 6971 | //mailaddresses enclosed in single quotes like '[email protected]' show up as 'me as mailbox and you.com' as host |
| 6973 | - if ($adr->mailbox && stripos($adr->mailbox,"'")== 0 && |
|
| 6974 | - $adr->host && stripos($adr->host,"'")== (strlen($adr->host) -1)) |
|
| 6972 | + if ($adr->mailbox && stripos($adr->mailbox, "'") == 0 && |
|
| 6973 | + $adr->host && stripos($adr->host, "'") == (strlen($adr->host) - 1)) |
|
| 6975 | 6974 | { |
| 6976 | - $adr->mailbox = str_replace("'","",$adr->mailbox); |
|
| 6977 | - $adr->host = str_replace("'","",$adr->host); |
|
| 6975 | + $adr->mailbox = str_replace("'", "", $adr->mailbox); |
|
| 6976 | + $adr->host = str_replace("'", "", $adr->host); |
|
| 6978 | 6977 | } |
| 6979 | 6978 | // no mailbox or host part as 'Xr\xc3\xa4hlyz, User <[email protected]>' is parsed as 2 addresses separated by ',' |
| 6980 | 6979 | //#'Xr\xc3\xa4hlyz, User <[email protected]>' |
| 6981 | 6980 | //#Horde_Mail_Rfc822_List Object([_data:protected] => Array( |
| 6982 | 6981 | //[0] => Horde_Mail_Rfc822_Address Object([comment] => Array()[mailbox] => Xr\xc3\xa4hlyz[_host:protected] => [_personal:protected] => ) |
| 6983 | 6982 | //[1] => Horde_Mail_Rfc822_Address Object([comment] => Array()[mailbox] => mailboxpart1.mailboxpart2[_host:protected] => youthost.com[_personal:protected] => User))[_filter:protected] => Array()[_ptr:protected] => )#2#, |
| 6984 | - if (strlen($adr->mailbox)==0||strlen($adr->host)==0) |
|
| 6983 | + if (strlen($adr->mailbox) == 0 || strlen($adr->host) == 0) |
|
| 6985 | 6984 | { |
| 6986 | - $remember = ($adr->mailbox?$adr->mailbox:($adr->host?$adr->host:'')); |
|
| 6987 | - $previousFailed=true; |
|
| 6985 | + $remember = ($adr->mailbox ? $adr->mailbox : ($adr->host ? $adr->host : '')); |
|
| 6986 | + $previousFailed = true; |
|
| 6988 | 6987 | //error_log(__METHOD__.__LINE__."('$addresses', $default_domain) parsed $i: mailbox=$adr->mailbox, host=$adr->host, personal=$adr->personal"); |
| 6989 | 6988 | } |
| 6990 | 6989 | else |
| 6991 | 6990 | { |
| 6992 | - if ($previousFailed && $remember) $adr->personal = $remember. ' ' . $adr->personal; |
|
| 6991 | + if ($previousFailed && $remember) $adr->personal = $remember.' '.$adr->personal; |
|
| 6993 | 6992 | $remember = ''; |
| 6994 | - $previousFailed=false; |
|
| 6993 | + $previousFailed = false; |
|
| 6995 | 6994 | //error_log(__METHOD__.__LINE__."('$addresses', $default_domain) parsed $i: mailbox=$adr->mailbox, host=$adr->host, personal=$adr->personal"); |
| 6996 | 6995 | $ret2->add($adr); |
| 6997 | 6996 | } |
@@ -7007,7 +7006,7 @@ discard block |
||
| 7007 | 7006 | * @param string $_folder |
| 7008 | 7007 | * @return boolean |
| 7009 | 7008 | */ |
| 7010 | - function sendMDN($uid,$_folder) |
|
| 7009 | + function sendMDN($uid, $_folder) |
|
| 7011 | 7010 | { |
| 7012 | 7011 | $acc = Mail\Account::read($this->profileID); |
| 7013 | 7012 | $identity = Mail\Account::read_identity($acc['ident_id'], true, null, $acc); |
@@ -7037,7 +7036,7 @@ discard block |
||
| 7037 | 7036 | */ |
| 7038 | 7037 | function addAccount($_hookValues) |
| 7039 | 7038 | { |
| 7040 | - error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!' . ' hookValue = '. $_hookValues); |
|
| 7039 | + error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!'.' hookValue = '.$_hookValues); |
|
| 7041 | 7040 | |
| 7042 | 7041 | } |
| 7043 | 7042 | |
@@ -7051,7 +7050,7 @@ discard block |
||
| 7051 | 7050 | */ |
| 7052 | 7051 | function deleteAccount($_hookValues) |
| 7053 | 7052 | { |
| 7054 | - error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!' . ' hookValue = '. $_hookValues); |
|
| 7053 | + error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!'.' hookValue = '.$_hookValues); |
|
| 7055 | 7054 | |
| 7056 | 7055 | } |
| 7057 | 7056 | |
@@ -7065,7 +7064,7 @@ discard block |
||
| 7065 | 7064 | */ |
| 7066 | 7065 | function updateAccount($_hookValues) |
| 7067 | 7066 | { |
| 7068 | - error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!' . ' hookValue = '. $_hookValues); |
|
| 7067 | + error_log(__METHOD__.' ('.__LINE__.') '.' NOT DONE YET!'.' hookValue = '.$_hookValues); |
|
| 7069 | 7068 | |
| 7070 | 7069 | } |
| 7071 | 7070 | } |
@@ -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 | if (isset(self::$profileDefunct[$_profileID]) && self::$profileDefunct[$_profileID]===true) |
@@ -229,9 +232,15 @@ discard block |
||
| 229 | 232 | { |
| 230 | 233 | $profileID = Mail\Account::get_default_acc_id(); |
| 231 | 234 | } |
| 232 | - if ($profileID!=$_profileID) $_restoreSession==false; |
|
| 235 | + if ($profileID!=$_profileID) |
|
| 236 | + { |
|
| 237 | + $_restoreSession==false; |
|
| 238 | + } |
|
| 233 | 239 | $_profileID=$profileID; |
| 234 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' called with profileID==0 using '.$profileID.' instead->'.function_backtrace()); |
|
| 240 | + if (self::$debug) |
|
| 241 | + { |
|
| 242 | + error_log(__METHOD__.' ('.__LINE__.') '.' called with profileID==0 using '.$profileID.' instead->'.function_backtrace()); |
|
| 243 | + } |
|
| 235 | 244 | } |
| 236 | 245 | // no validation or restoreSession for old ImapServer Object, just fetch it and return it |
| 237 | 246 | if ($_oldImapServerObject===true) |
@@ -270,7 +279,8 @@ discard block |
||
| 270 | 279 | // TODO: merge mailprefs into userprefs, for easy treatment |
| 271 | 280 | self::$instances[$_profileID]->mailPreferences = $GLOBALS['egw_info']['user']['preferences']['mail']; |
| 272 | 281 | self::$instances[$_profileID]->htmlOptions = self::$instances[$_profileID]->mailPreferences['htmlOptions']; |
| 273 | - } catch (\Exception $e) |
|
| 282 | + } |
|
| 283 | + catch (\Exception $e) |
|
| 274 | 284 | { |
| 275 | 285 | $newprofileID = Mail\Account::get_default_acc_id(); |
| 276 | 286 | // try loading the default profile for the user |
@@ -288,9 +298,15 @@ discard block |
||
| 288 | 298 | self::storeActiveProfileIDToPref(self::$instances[$_profileID]->icServer, $_profileID, $_validate ); |
| 289 | 299 | } |
| 290 | 300 | self::$instances[$_profileID]->profileID = $_profileID; |
| 291 | - if (!isset(self::$instances[$_profileID]->idna2)) self::$instances[$_profileID]->idna2 = new Horde_Idna; |
|
| 301 | + if (!isset(self::$instances[$_profileID]->idna2)) |
|
| 302 | + { |
|
| 303 | + self::$instances[$_profileID]->idna2 = new Horde_Idna; |
|
| 304 | + } |
|
| 292 | 305 | //if ($_profileID==0); error_log(__METHOD__.' ('.__LINE__.') '.' RestoreSession:'.$_restoreSession.' ProfileId:'.$_profileID); |
| 293 | - if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail'); |
|
| 306 | + if (is_null(self::$mailConfig)) |
|
| 307 | + { |
|
| 308 | + self::$mailConfig = Config::read('mail'); |
|
| 309 | + } |
|
| 294 | 310 | return self::$instances[$_profileID]; |
| 295 | 311 | } |
| 296 | 312 | |
@@ -315,14 +331,20 @@ discard block |
||
| 315 | 331 | } |
| 316 | 332 | catch (\Exception $e) |
| 317 | 333 | { |
| 318 | - if ($_profileID != Mail\Account::get_default_acc_id()) $_profileID = Mail\Account::get_default_acc_id(); |
|
| 334 | + if ($_profileID != Mail\Account::get_default_acc_id()) |
|
| 335 | + { |
|
| 336 | + $_profileID = Mail\Account::get_default_acc_id(); |
|
| 337 | + } |
|
| 319 | 338 | error_log(__METHOD__.__LINE__.' '.$e->getMessage()); |
| 320 | 339 | return false; |
| 321 | 340 | } |
| 322 | 341 | } |
| 323 | 342 | if ($oldProfileID != $_profileID) |
| 324 | 343 | { |
| 325 | - if ($oldProfileID && $_profileID==0) $_profileID = $oldProfileID; |
|
| 344 | + if ($oldProfileID && $_profileID==0) |
|
| 345 | + { |
|
| 346 | + $_profileID = $oldProfileID; |
|
| 347 | + } |
|
| 326 | 348 | $GLOBALS['egw']->preferences->add('mail','ActiveProfileID',$_profileID,'user'); |
| 327 | 349 | // save prefs |
| 328 | 350 | $GLOBALS['egw']->preferences->save_repository(true); |
@@ -352,11 +374,17 @@ discard block |
||
| 352 | 374 | { |
| 353 | 375 | return $_acc_id; |
| 354 | 376 | } |
| 355 | - if (self::$debug) error_log(__METHOD__."($_acc_id) account NOT valid, no imap-host!"); |
|
| 377 | + if (self::$debug) |
|
| 378 | + { |
|
| 379 | + error_log(__METHOD__."($_acc_id) account NOT valid, no imap-host!"); |
|
| 380 | + } |
|
| 356 | 381 | } |
| 357 | 382 | catch (\Exception $e) { |
| 358 | 383 | unset($e); |
| 359 | - if (self::$debug) error_log(__METHOD__."($_acc_id) account NOT found!"); |
|
| 384 | + if (self::$debug) |
|
| 385 | + { |
|
| 386 | + error_log(__METHOD__."($_acc_id) account NOT found!"); |
|
| 387 | + } |
|
| 360 | 388 | } |
| 361 | 389 | } |
| 362 | 390 | // no account specified or specified account not found or not valid |
@@ -365,11 +393,17 @@ discard block |
||
| 365 | 393 | { |
| 366 | 394 | if (!empty($imap_host) && ($account = Mail\Account::read($acc_id)) && $account->is_imap()) |
| 367 | 395 | { |
| 368 | - if (self::$debug && $_acc_id) error_log(__METHOD__."($_acc_id) using $acc_id instead"); |
|
| 396 | + if (self::$debug && $_acc_id) |
|
| 397 | + { |
|
| 398 | + error_log(__METHOD__."($_acc_id) using $acc_id instead"); |
|
| 399 | + } |
|
| 369 | 400 | return $acc_id; |
| 370 | 401 | } |
| 371 | 402 | } |
| 372 | - if (self::$debug) error_log(__METHOD__."($_acc_id) NO valid account found!"); |
|
| 403 | + if (self::$debug) |
|
| 404 | + { |
|
| 405 | + error_log(__METHOD__."($_acc_id) NO valid account found!"); |
|
| 406 | + } |
|
| 373 | 407 | return 0; |
| 374 | 408 | } |
| 375 | 409 | |
@@ -385,10 +419,19 @@ discard block |
||
| 385 | 419 | */ |
| 386 | 420 | private function __construct($_displayCharset='utf-8',$_restoreSession=true, $_profileID=0, $_oldImapServerObject=false, $_reuseCache=null) |
| 387 | 421 | { |
| 388 | - if (is_null($_reuseCache)) $_reuseCache = $_restoreSession; |
|
| 389 | - if (!empty($_displayCharset)) self::$displayCharset = $_displayCharset; |
|
| 422 | + if (is_null($_reuseCache)) |
|
| 423 | + { |
|
| 424 | + $_reuseCache = $_restoreSession; |
|
| 425 | + } |
|
| 426 | + if (!empty($_displayCharset)) |
|
| 427 | + { |
|
| 428 | + self::$displayCharset = $_displayCharset; |
|
| 429 | + } |
|
| 390 | 430 | // not nummeric, we assume we only want an empty class object |
| 391 | - if (!is_numeric($_profileID)) return true; |
|
| 431 | + if (!is_numeric($_profileID)) |
|
| 432 | + { |
|
| 433 | + return true; |
|
| 434 | + } |
|
| 392 | 435 | if ($_restoreSession) |
| 393 | 436 | { |
| 394 | 437 | //error_log(__METHOD__." Session restore ".function_backtrace()); |
@@ -403,7 +446,10 @@ discard block |
||
| 403 | 446 | $firstMessage = $this->sessionData['previewMessage']; |
| 404 | 447 | $this->sessionData = array(); |
| 405 | 448 | } |
| 406 | - if (!$_reuseCache) $this->forcePrefReload($_profileID,!$_reuseCache); |
|
| 449 | + if (!$_reuseCache) |
|
| 450 | + { |
|
| 451 | + $this->forcePrefReload($_profileID,!$_reuseCache); |
|
| 452 | + } |
|
| 407 | 453 | try |
| 408 | 454 | { |
| 409 | 455 | $this->profileID = self::validateProfileID($_profileID); |
@@ -427,7 +473,10 @@ discard block |
||
| 427 | 473 | $_profileID = $this->profileID = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $this->icServer->ImapServerId; |
| 428 | 474 | } |
| 429 | 475 | |
| 430 | - if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail'); |
|
| 476 | + if (is_null(self::$mailConfig)) |
|
| 477 | + { |
|
| 478 | + self::$mailConfig = Config::read('mail'); |
|
| 479 | + } |
|
| 431 | 480 | } |
| 432 | 481 | |
| 433 | 482 | /** |
@@ -456,7 +505,10 @@ discard block |
||
| 456 | 505 | // unset the mail_preferences session object, to force the reload/rebuild |
| 457 | 506 | Cache::setSession('mail','mail_preferences',serialize(array())); |
| 458 | 507 | Cache::setSession('emailadmin','session_data',serialize(array())); |
| 459 | - if ($_resetFolderObjects) self::resetFolderObjectCache($_profile_id); |
|
| 508 | + if ($_resetFolderObjects) |
|
| 509 | + { |
|
| 510 | + self::resetFolderObjectCache($_profile_id); |
|
| 511 | + } |
|
| 460 | 512 | } |
| 461 | 513 | |
| 462 | 514 | /** |
@@ -466,7 +518,10 @@ discard block |
||
| 466 | 518 | { |
| 467 | 519 | $this->sessionData = array();//Cache::getCache(Cache::SESSION,'mail','session_data',$callback=null,$callback_params=array(),$expiration=60*60*1); |
| 468 | 520 | self::$activeFolderCache = Cache::getCache(Cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*10); |
| 469 | - if (!empty(self::$activeFolderCache[$this->profileID])) $this->sessionData['mailbox'] = self::$activeFolderCache[$this->profileID]; |
|
| 521 | + if (!empty(self::$activeFolderCache[$this->profileID])) |
|
| 522 | + { |
|
| 523 | + $this->sessionData['mailbox'] = self::$activeFolderCache[$this->profileID]; |
|
| 524 | + } |
|
| 470 | 525 | } |
| 471 | 526 | |
| 472 | 527 | /** |
@@ -475,7 +530,10 @@ discard block |
||
| 475 | 530 | function saveSessionData() |
| 476 | 531 | { |
| 477 | 532 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string(array_keys($this->sessionData))); |
| 478 | - if (!empty($this->sessionData['mailbox'])) self::$activeFolderCache[$this->profileID]=$this->sessionData['mailbox']; |
|
| 533 | + if (!empty($this->sessionData['mailbox'])) |
|
| 534 | + { |
|
| 535 | + self::$activeFolderCache[$this->profileID]=$this->sessionData['mailbox']; |
|
| 536 | + } |
|
| 479 | 537 | if (isset(self::$activeFolderCache) && is_array(self::$activeFolderCache)) |
| 480 | 538 | { |
| 481 | 539 | Cache::setCache(Cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),self::$activeFolderCache, 60*60*10); |
@@ -496,8 +554,14 @@ discard block |
||
| 496 | 554 | */ |
| 497 | 555 | static function unsetCachedObjects($_profileID=null) |
| 498 | 556 | { |
| 499 | - if (is_null($_profileID)) $_profileID = Mail\Account::get_default_acc_id(); |
|
| 500 | - if (is_array($_profileID) && $_profileID['account_id']) $account_id = $_profileID['account_id']; |
|
| 557 | + if (is_null($_profileID)) |
|
| 558 | + { |
|
| 559 | + $_profileID = Mail\Account::get_default_acc_id(); |
|
| 560 | + } |
|
| 561 | + if (is_array($_profileID) && $_profileID['account_id']) |
|
| 562 | + { |
|
| 563 | + $account_id = $_profileID['account_id']; |
|
| 564 | + } |
|
| 501 | 565 | //error_log(__METHOD__.__LINE__.' called with ProfileID:'.array2string($_profileID).' from '.function_backtrace()); |
| 502 | 566 | if (!is_array($_profileID) && (is_numeric($_profileID) || !(stripos($_profileID,'tracker_')===false))) |
| 503 | 567 | { |
@@ -530,7 +594,10 @@ discard block |
||
| 530 | 594 | Cache::setCache(Cache::INSTANCE,'email','vacationNotice'.trim($account_id),$vacationCached, $expiration=60*60*24*1); |
| 531 | 595 | } |
| 532 | 596 | |
| 533 | - if (isset(self::$instances[$_profileID])) unset(self::$instances[$_profileID]); |
|
| 597 | + if (isset(self::$instances[$_profileID])) |
|
| 598 | + { |
|
| 599 | + unset(self::$instances[$_profileID]); |
|
| 600 | + } |
|
| 534 | 601 | } |
| 535 | 602 | if (is_array($_profileID) && $_profileID['location'] == 'clear_cache') |
| 536 | 603 | { |
@@ -559,7 +626,10 @@ discard block |
||
| 559 | 626 | static function resetConnectionErrorCache($_ImapServerId=null,$account_id=null) |
| 560 | 627 | { |
| 561 | 628 | //error_log(__METHOD__.' ('.__LINE__.') '.' for Profile:'.array2string($_ImapServerId) .' for user:'.trim($account_id)); |
| 562 | - if (is_null($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id']; |
|
| 629 | + if (is_null($account_id)) |
|
| 630 | + { |
|
| 631 | + $account_id = $GLOBALS['egw_info']['user']['account_id']; |
|
| 632 | + } |
|
| 563 | 633 | if (is_array($_ImapServerId)) |
| 564 | 634 | { |
| 565 | 635 | // called via hook |
@@ -598,7 +668,10 @@ discard block |
||
| 598 | 668 | static function resetFolderObjectCache($_ImapServerId=null,$account_id=null) |
| 599 | 669 | { |
| 600 | 670 | //error_log(__METHOD__.' ('.__LINE__.') '.' called for Profile:'.array2string($_ImapServerId).'->'.function_backtrace()); |
| 601 | - if (is_null($account_id)) $account_id = $GLOBALS['egw_info']['user']['account_id']; |
|
| 671 | + if (is_null($account_id)) |
|
| 672 | + { |
|
| 673 | + $account_id = $GLOBALS['egw_info']['user']['account_id']; |
|
| 674 | + } |
|
| 602 | 675 | // on [location] => verify_settings we coud either use [prefs] => Array([ActiveProfileID] => 9, .. as $_ImapServerId |
| 603 | 676 | // or treat it as not given. we try that path |
| 604 | 677 | if (is_null($_ImapServerId)||is_array($_ImapServerId)) |
@@ -672,10 +745,14 @@ discard block |
||
| 672 | 745 | |
| 673 | 746 | $userEMailAdresses = array($acc['ident_email']=>$acc['ident_realname']); |
| 674 | 747 | |
| 675 | - foreach($identities as $ik => $ident) { |
|
| 748 | + foreach($identities as $ik => $ident) |
|
| 749 | + { |
|
| 676 | 750 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident)); |
| 677 | 751 | $identity = Mail\Account::read_identity($ik); |
| 678 | - if (!empty($identity['ident_email']) && !isset($userEMailAdresses[$identity['ident_email']])) $userEMailAdresses[$identity['ident_email']] = $identity['ident_realname']; |
|
| 752 | + if (!empty($identity['ident_email']) && !isset($userEMailAdresses[$identity['ident_email']])) |
|
| 753 | + { |
|
| 754 | + $userEMailAdresses[$identity['ident_email']] = $identity['ident_realname']; |
|
| 755 | + } |
|
| 679 | 756 | } |
| 680 | 757 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($userEMailAdresses)); |
| 681 | 758 | return $userEMailAdresses; |
@@ -693,13 +770,20 @@ discard block |
||
| 693 | 770 | foreach(Mail\Account::search($only_current_user=($_accountToSearch?$_accountToSearch:true), $just_name=true) as $acc_id => $identity_name) |
| 694 | 771 | { |
| 695 | 772 | $acc = Mail\Account::read($acc_id,($_accountToSearch?$_accountToSearch:null)); |
| 696 | - 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']); |
|
| 773 | + if (!$resolve_placeholders) |
|
| 774 | + { |
|
| 775 | + $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']); |
|
| 776 | + } |
|
| 697 | 777 | |
| 698 | - foreach(Mail\Account::identities($acc) as $ik => $ident) { |
|
| 778 | + foreach(Mail\Account::identities($acc) as $ik => $ident) |
|
| 779 | + { |
|
| 699 | 780 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident)); |
| 700 | 781 | $identity = Mail\Account::read_identity($ik,$resolve_placeholders); |
| 701 | 782 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($identity)); |
| 702 | - 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']); |
|
| 783 | + if (!isset($userEMailAdresses[$identity['ident_id']])) |
|
| 784 | + { |
|
| 785 | + $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']); |
|
| 786 | + } |
|
| 703 | 787 | } |
| 704 | 788 | } |
| 705 | 789 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($userEMailAdresses)); |
@@ -719,12 +803,16 @@ discard block |
||
| 719 | 803 | $account = Mail\Account::read($account); |
| 720 | 804 | } |
| 721 | 805 | $userEMailAdresses = array(); |
| 722 | - foreach(Mail\Account::identities($account, true, 'params') as $ik => $ident) { |
|
| 806 | + foreach(Mail\Account::identities($account, true, 'params') as $ik => $ident) |
|
| 807 | + { |
|
| 723 | 808 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident)); |
| 724 | 809 | $identity = Mail\Account::read_identity($ik,true,null,$account); |
| 725 | 810 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($identity)); |
| 726 | 811 | // standardIdentity has ident_id==acc_id (as it is done within account->identities) |
| 727 | - if (empty($identity['ident_id'])) $identity['ident_id'] = $identity['acc_id']; |
|
| 812 | + if (empty($identity['ident_id'])) |
|
| 813 | + { |
|
| 814 | + $identity['ident_id'] = $identity['acc_id']; |
|
| 815 | + } |
|
| 728 | 816 | if (!isset($userEMailAdresses[$identity['ident_id']])) |
| 729 | 817 | { |
| 730 | 818 | $userEMailAdresses[$identity['ident_id']] = array('acc_id'=>$identity['acc_id'], |
@@ -767,15 +855,25 @@ discard block |
||
| 767 | 855 | // account select box |
| 768 | 856 | $selectedID = $this->profileID; |
| 769 | 857 | $allAccountData = Mail\Account::search($only_current_user=true, false, null); |
| 770 | - if ($allAccountData) { |
|
| 858 | + if ($allAccountData) |
|
| 859 | + { |
|
| 771 | 860 | $rememberFirst=$selectedFound=null; |
| 772 | 861 | foreach ($allAccountData as $tmpkey => $icServers) |
| 773 | 862 | { |
| 774 | - if (is_null($rememberFirst)) $rememberFirst = $tmpkey; |
|
| 775 | - if ($tmpkey == $selectedID) $selectedFound=true; |
|
| 863 | + if (is_null($rememberFirst)) |
|
| 864 | + { |
|
| 865 | + $rememberFirst = $tmpkey; |
|
| 866 | + } |
|
| 867 | + if ($tmpkey == $selectedID) |
|
| 868 | + { |
|
| 869 | + $selectedFound=true; |
|
| 870 | + } |
|
| 776 | 871 | //error_log(__METHOD__.' ('.__LINE__.') '.' Key:'.$tmpkey.'->'.array2string($icServers->acc_imap_host)); |
| 777 | 872 | $host = $icServers->acc_imap_host; |
| 778 | - if (empty($host)) continue; |
|
| 873 | + if (empty($host)) |
|
| 874 | + { |
|
| 875 | + continue; |
|
| 876 | + } |
|
| 779 | 877 | $identities[$icServers->acc_id] = $icServers['ident_realname'].' '.$icServers['ident_org'].' <'.$icServers['ident_email'].'>'; |
| 780 | 878 | //error_log(__METHOD__.' ('.__LINE__.') '.' Key:'.$tmpkey.'->'.array2string($identities[$icServers->acc_id])); |
| 781 | 879 | } |
@@ -835,7 +933,10 @@ discard block |
||
| 835 | 933 | */ |
| 836 | 934 | function reopen($_foldername) |
| 837 | 935 | { |
| 838 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 936 | + if (self::$debugTimes) |
|
| 937 | + { |
|
| 938 | + $starttime = microtime (true); |
|
| 939 | + } |
|
| 839 | 940 | |
| 840 | 941 | //error_log(__METHOD__.' ('.__LINE__.') '."('$_foldername') ".function_backtrace()); |
| 841 | 942 | // TODO: trying to reduce traffic to the IMAP Server here, introduces problems with fetching the bodies of |
@@ -845,12 +946,16 @@ discard block |
||
| 845 | 946 | //{ |
| 846 | 947 | //error_log( __METHOD__.' ('.__LINE__.') '." $_foldername ".function_backtrace()); |
| 847 | 948 | //error_log(__METHOD__.' ('.__LINE__.') '.' Connected with icServer for Profile:'.$this->profileID.'?'.print_r($this->icServer->_connected,true)); |
| 848 | - if ($this->folderIsSelectable($_foldername)) { |
|
| 949 | + if ($this->folderIsSelectable($_foldername)) |
|
| 950 | + { |
|
| 849 | 951 | $this->icServer->openMailbox($_foldername); |
| 850 | 952 | } |
| 851 | 953 | $folderOpened = $_foldername; |
| 852 | 954 | //} |
| 853 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'Folder:'.$_foldername,__METHOD__.' ('.__LINE__.') '); |
|
| 955 | + if (self::$debugTimes) |
|
| 956 | + { |
|
| 957 | + self::logRunTimes($starttime,null,'Folder:'.$_foldername,__METHOD__.' ('.__LINE__.') '); |
|
| 958 | + } |
|
| 854 | 959 | } |
| 855 | 960 | |
| 856 | 961 | |
@@ -865,13 +970,22 @@ discard block |
||
| 865 | 970 | { |
| 866 | 971 | //error_log( "-------------------------->open connection ".function_backtrace()); |
| 867 | 972 | //error_log(__METHOD__.' ('.__LINE__.') '.' ->'.array2string($this->icServer)); |
| 868 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 973 | + if (self::$debugTimes) |
|
| 974 | + { |
|
| 975 | + $starttime = microtime (true); |
|
| 976 | + } |
|
| 869 | 977 | $mailbox=null; |
| 870 | 978 | try |
| 871 | 979 | { |
| 872 | - if(isset($this->sessionData['mailbox'])&&$this->folderExists($this->sessionData['mailbox'])) $mailbox = $this->sessionData['mailbox']; |
|
| 873 | - if (empty($mailbox)) $mailbox = $this->icServer->getCurrentMailbox(); |
|
| 874 | -/* |
|
| 980 | + if(isset($this->sessionData['mailbox'])&&$this->folderExists($this->sessionData['mailbox'])) |
|
| 981 | + { |
|
| 982 | + $mailbox = $this->sessionData['mailbox']; |
|
| 983 | + } |
|
| 984 | + if (empty($mailbox)) |
|
| 985 | + { |
|
| 986 | + $mailbox = $this->icServer->getCurrentMailbox(); |
|
| 987 | + } |
|
| 988 | + /* |
|
| 875 | 989 | if (isset(Mail\Imap::$supports_keywords[$_icServerID])) |
| 876 | 990 | { |
| 877 | 991 | $this->icServer->openMailbox($mailbox); |
@@ -896,7 +1010,10 @@ discard block |
||
| 896 | 1010 | error_log(__METHOD__.' ('.__LINE__.') '."->open connection for Server with profileID:".$_icServerID." trying to examine ($mailbox) failed!".$e->getMessage()); |
| 897 | 1011 | throw new Exception(__METHOD__." failed to ".__METHOD__." on Profile to $_icServerID while trying to examine $mailbox:".$e->getMessage()); |
| 898 | 1012 | } |
| 899 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'ProfileID:'.$_icServerID,__METHOD__.' ('.__LINE__.') '); |
|
| 1013 | + if (self::$debugTimes) |
|
| 1014 | + { |
|
| 1015 | + self::logRunTimes($starttime,null,'ProfileID:'.$_icServerID,__METHOD__.' ('.__LINE__.') '); |
|
| 1016 | + } |
|
| 900 | 1017 | } |
| 901 | 1018 | |
| 902 | 1019 | /** |
@@ -908,7 +1025,10 @@ discard block |
||
| 908 | 1025 | function getQuotaRoot() |
| 909 | 1026 | { |
| 910 | 1027 | static $quota; |
| 911 | - if (isset($quota)) return $quota; |
|
| 1028 | + if (isset($quota)) |
|
| 1029 | + { |
|
| 1030 | + return $quota; |
|
| 1031 | + } |
|
| 912 | 1032 | if (isset(self::$profileDefunct[$this->profileID]) && self::$profileDefunct[$this->profileID]===true) |
| 913 | 1033 | { |
| 914 | 1034 | // something is wrong. Do not proceed. either no folder or profile is marked as defunct for this request |
@@ -917,7 +1037,8 @@ discard block |
||
| 917 | 1037 | try |
| 918 | 1038 | { |
| 919 | 1039 | $this->icServer->getCurrentMailbox(); |
| 920 | - if(!$this->icServer->hasCapability('QUOTA')) { |
|
| 1040 | + if(!$this->icServer->hasCapability('QUOTA')) |
|
| 1041 | + { |
|
| 921 | 1042 | $quota = false; |
| 922 | 1043 | return false; |
| 923 | 1044 | } |
@@ -934,12 +1055,15 @@ discard block |
||
| 934 | 1055 | } |
| 935 | 1056 | } |
| 936 | 1057 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($quota)); |
| 937 | - if(is_array($quota)) { |
|
| 1058 | + if(is_array($quota)) |
|
| 1059 | + { |
|
| 938 | 1060 | $quota = array( |
| 939 | 1061 | 'usage' => $quota['USED'], |
| 940 | 1062 | 'limit' => $quota['QMAX'], |
| 941 | 1063 | ); |
| 942 | - } else { |
|
| 1064 | + } |
|
| 1065 | + else |
|
| 1066 | + { |
|
| 943 | 1067 | $quota = false; |
| 944 | 1068 | } |
| 945 | 1069 | return $quota; |
@@ -955,7 +1079,11 @@ discard block |
||
| 955 | 1079 | static function getTimeOut($_use='IMAP') |
| 956 | 1080 | { |
| 957 | 1081 | $timeout = $GLOBALS['egw_info']['user']['preferences']['mail']['connectionTimeout']; |
| 958 | - if (empty($timeout)) $timeout = ($_use=='SIEVE'?10:20); // this is the default value |
|
| 1082 | + if (empty($timeout)) |
|
| 1083 | + { |
|
| 1084 | + $timeout = ($_use=='SIEVE'?10:20); |
|
| 1085 | + } |
|
| 1086 | + // this is the default value |
|
| 959 | 1087 | return $timeout; |
| 960 | 1088 | } |
| 961 | 1089 | |
@@ -973,9 +1101,13 @@ discard block |
||
| 973 | 1101 | $foldersNameSpace = array(); |
| 974 | 1102 | $delimiter = $this->getHierarchyDelimiter(); |
| 975 | 1103 | // TODO: cache by $this->icServer->ImapServerId |
| 976 | - if (is_null($nameSpace)) $nameSpace = $this->icServer->getNameSpaceArray(); |
|
| 1104 | + if (is_null($nameSpace)) |
|
| 1105 | + { |
|
| 1106 | + $nameSpace = $this->icServer->getNameSpaceArray(); |
|
| 1107 | + } |
|
| 977 | 1108 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($nameSpace)); |
| 978 | - if (is_array($nameSpace)) { |
|
| 1109 | + if (is_array($nameSpace)) |
|
| 1110 | + { |
|
| 979 | 1111 | foreach($nameSpace as $type => $singleNameSpaceArray) |
| 980 | 1112 | { |
| 981 | 1113 | foreach ($singleNameSpaceArray as $singleNameSpace) |
@@ -992,7 +1124,9 @@ discard block |
||
| 992 | 1124 | $_foldersNameSpace['prefix_present'] = 'forced'; |
| 993 | 1125 | // uw-imap server with mailbox prefix or dovecot maybe |
| 994 | 1126 | $_foldersNameSpace['prefix'] = 'mail'; |
| 995 | - } else { |
|
| 1127 | + } |
|
| 1128 | + else |
|
| 1129 | + { |
|
| 996 | 1130 | $_foldersNameSpace['prefix_present'] = !empty($singleNameSpace['name']); |
| 997 | 1131 | $_foldersNameSpace['prefix'] = $singleNameSpace['name']; |
| 998 | 1132 | } |
@@ -1019,7 +1153,10 @@ discard block |
||
| 1019 | 1153 | foreach($nameSpace as &$singleNameSpace) |
| 1020 | 1154 | { |
| 1021 | 1155 | //if (substr($singleNameSpace['prefix'],0,strlen($folderName))==$folderName) return $singleNameSpace['prefix']; |
| 1022 | - if (substr($folderName,0,strlen($singleNameSpace['prefix']))==$singleNameSpace['prefix']) return $singleNameSpace['prefix']; |
|
| 1156 | + if (substr($folderName,0,strlen($singleNameSpace['prefix']))==$singleNameSpace['prefix']) |
|
| 1157 | + { |
|
| 1158 | + return $singleNameSpace['prefix']; |
|
| 1159 | + } |
|
| 1023 | 1160 | } |
| 1024 | 1161 | return ""; |
| 1025 | 1162 | } |
@@ -1033,8 +1170,14 @@ discard block |
||
| 1033 | 1170 | function getHierarchyDelimiter($_useCache=true) |
| 1034 | 1171 | { |
| 1035 | 1172 | static $HierarchyDelimiter = null; |
| 1036 | - if (is_null($HierarchyDelimiter)) $HierarchyDelimiter = Cache::getCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5); |
|
| 1037 | - if ($_useCache===false) unset($HierarchyDelimiter[$this->icServer->ImapServerId]); |
|
| 1173 | + if (is_null($HierarchyDelimiter)) |
|
| 1174 | + { |
|
| 1175 | + $HierarchyDelimiter = Cache::getCache(Cache::INSTANCE,'email','HierarchyDelimiter'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5); |
|
| 1176 | + } |
|
| 1177 | + if ($_useCache===false) |
|
| 1178 | + { |
|
| 1179 | + unset($HierarchyDelimiter[$this->icServer->ImapServerId]); |
|
| 1180 | + } |
|
| 1038 | 1181 | if (isset($HierarchyDelimiter[$this->icServer->ImapServerId])&&!empty($HierarchyDelimiter[$this->icServer->ImapServerId])) |
| 1039 | 1182 | { |
| 1040 | 1183 | return $HierarchyDelimiter[$this->icServer->ImapServerId]; |
@@ -1047,7 +1190,10 @@ discard block |
||
| 1047 | 1190 | } |
| 1048 | 1191 | catch(\Exception $e) |
| 1049 | 1192 | { |
| 1050 | - if ($e->getCode()==102) self::$profileDefunct[$this->profileID]=true; |
|
| 1193 | + if ($e->getCode()==102) |
|
| 1194 | + { |
|
| 1195 | + self::$profileDefunct[$this->profileID]=true; |
|
| 1196 | + } |
|
| 1051 | 1197 | unset($e); |
| 1052 | 1198 | $HierarchyDelimiter[$this->icServer->ImapServerId] = '/'; |
| 1053 | 1199 | } |
@@ -1064,14 +1210,19 @@ discard block |
||
| 1064 | 1210 | { |
| 1065 | 1211 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$this->icServer->ImapServerId.' Connected:'.$this->icServer->_connected); |
| 1066 | 1212 | static $_specialUseFolders = null; |
| 1067 | - 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); |
|
| 1213 | + if (is_null($_specialUseFolders)||empty($_specialUseFolders)) |
|
| 1214 | + { |
|
| 1215 | + $_specialUseFolders = Cache::getCache(Cache::INSTANCE,'email','specialUseFolders'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*24*5); |
|
| 1216 | + } |
|
| 1068 | 1217 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_trash)); |
| 1069 | 1218 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_sent)); |
| 1070 | 1219 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_draft)); |
| 1071 | 1220 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($this->icServer->acc_folder_template)); |
| 1072 | 1221 | self::$specialUseFolders = $_specialUseFolders[$this->icServer->ImapServerId]; |
| 1073 | 1222 | if (isset($_specialUseFolders[$this->icServer->ImapServerId]) && !empty($_specialUseFolders[$this->icServer->ImapServerId])) |
| 1074 | - return $_specialUseFolders[$this->icServer->ImapServerId]; |
|
| 1223 | + { |
|
| 1224 | + return $_specialUseFolders[$this->icServer->ImapServerId]; |
|
| 1225 | + } |
|
| 1075 | 1226 | $_specialUseFolders[$this->icServer->ImapServerId]=array(); |
| 1076 | 1227 | //if (!empty($this->icServer->acc_folder_trash) && !isset($_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash])) |
| 1077 | 1228 | $_specialUseFolders[$this->icServer->ImapServerId][$this->icServer->acc_folder_trash]='Trash'; |
@@ -1099,7 +1250,8 @@ discard block |
||
| 1099 | 1250 | function folderIsSelectable($folderToSelect) |
| 1100 | 1251 | { |
| 1101 | 1252 | $retval = true; |
| 1102 | - if($folderToSelect && ($folderStatus = $this->getFolderStatus($folderToSelect,false,true))) { |
|
| 1253 | + if($folderToSelect && ($folderStatus = $this->getFolderStatus($folderToSelect,false,true))) |
|
| 1254 | + { |
|
| 1103 | 1255 | if (!empty($folderStatus['attributes']) && stripos(array2string($folderStatus['attributes']),'noselect')!==false) |
| 1104 | 1256 | { |
| 1105 | 1257 | $retval = false; |
@@ -1152,7 +1304,10 @@ discard block |
||
| 1152 | 1304 | */ |
| 1153 | 1305 | function getFolderStatus($_folderName,$ignoreStatusCache=false,$basicInfoOnly=false,$fetchSubscribedInfo=true) |
| 1154 | 1306 | { |
| 1155 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '." called with:$_folderName,$ignoreStatusCache,$basicInfoOnly"); |
|
| 1307 | + if (self::$debug) |
|
| 1308 | + { |
|
| 1309 | + error_log(__METHOD__.' ('.__LINE__.') '." called with:$_folderName,$ignoreStatusCache,$basicInfoOnly"); |
|
| 1310 | + } |
|
| 1156 | 1311 | if (!is_string($_folderName) || empty($_folderName)||(isset(self::$profileDefunct[$this->profileID]) && self::$profileDefunct[$this->profileID]===true)) |
| 1157 | 1312 | { |
| 1158 | 1313 | // something is wrong. Do not proceed. either no folder or profile is marked as defunct for this request |
@@ -1164,7 +1319,10 @@ discard block |
||
| 1164 | 1319 | { |
| 1165 | 1320 | $folderInfoCache = $folderBasicInfo[$this->profileID]; |
| 1166 | 1321 | } |
| 1167 | - if (isset($folderInfoCache[$_folderName]) && $ignoreStatusCache==false && $basicInfoOnly) return $folderInfoCache[$_folderName]; |
|
| 1322 | + if (isset($folderInfoCache[$_folderName]) && $ignoreStatusCache==false && $basicInfoOnly) |
|
| 1323 | + { |
|
| 1324 | + return $folderInfoCache[$_folderName]; |
|
| 1325 | + } |
|
| 1168 | 1326 | $retValue = array(); |
| 1169 | 1327 | $retValue['subscribed'] = false; |
| 1170 | 1328 | /* |
@@ -1192,7 +1350,10 @@ discard block |
||
| 1192 | 1350 | if (is_array($ret)) |
| 1193 | 1351 | { |
| 1194 | 1352 | $retkeys = array_keys($ret); |
| 1195 | - if ($retkeys[0]==$_folderName) $folderInfoCache[$_folderName] = $ret[$retkeys[0]]; |
|
| 1353 | + if ($retkeys[0]==$_folderName) |
|
| 1354 | + { |
|
| 1355 | + $folderInfoCache[$_folderName] = $ret[$retkeys[0]]; |
|
| 1356 | + } |
|
| 1196 | 1357 | } |
| 1197 | 1358 | else |
| 1198 | 1359 | { |
@@ -1201,7 +1362,8 @@ discard block |
||
| 1201 | 1362 | } |
| 1202 | 1363 | $folderInfo = $folderInfoCache[$_folderName]; |
| 1203 | 1364 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($folderInfo).'->'.function_backtrace()); |
| 1204 | - if($ignoreStatusCache||!$folderInfo|| !is_array($folderInfo)) { |
|
| 1365 | + if($ignoreStatusCache||!$folderInfo|| !is_array($folderInfo)) |
|
| 1366 | + { |
|
| 1205 | 1367 | try |
| 1206 | 1368 | { |
| 1207 | 1369 | $folderInfo = $this->_getStatus($_folderName,$ignoreStatusCache); |
@@ -1235,7 +1397,8 @@ discard block |
||
| 1235 | 1397 | $retValue['shortName'] = array_pop($shortNameParts); |
| 1236 | 1398 | $retValue['displayName'] = $_folderName; |
| 1237 | 1399 | $retValue['shortDisplayName'] = $retValue['shortName']; |
| 1238 | - if(strtoupper($retValue['shortName']) == 'INBOX') { |
|
| 1400 | + if(strtoupper($retValue['shortName']) == 'INBOX') |
|
| 1401 | + { |
|
| 1239 | 1402 | $retValue['displayName'] = lang('INBOX'); |
| 1240 | 1403 | $retValue['shortDisplayName'] = lang('INBOX'); |
| 1241 | 1404 | } |
@@ -1244,7 +1407,10 @@ discard block |
||
| 1244 | 1407 | { |
| 1245 | 1408 | $retValue['displayName'] = $retValue['shortDisplayName'] = lang($retValue['shortName']); |
| 1246 | 1409 | } |
| 1247 | - if ($folderInfo) $folderBasicInfo[$this->profileID][$_folderName]=$retValue; |
|
| 1410 | + if ($folderInfo) |
|
| 1411 | + { |
|
| 1412 | + $folderBasicInfo[$this->profileID][$_folderName]=$retValue; |
|
| 1413 | + } |
|
| 1248 | 1414 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$_folderName.array2string($retValue['attributes'])); |
| 1249 | 1415 | if ($basicInfoOnly || (isset($retValue['attributes']) && stripos(array2string($retValue['attributes']),'noselect')!==false)) |
| 1250 | 1416 | { |
@@ -1256,24 +1422,34 @@ discard block |
||
| 1256 | 1422 | static $subscribedFolders = null; |
| 1257 | 1423 | static $nameSpace = null; |
| 1258 | 1424 | static $prefix = null; |
| 1259 | - if (is_null($nameSpace) || empty($nameSpace[$this->profileID])) $nameSpace[$this->profileID] = $this->_getNameSpaces(); |
|
| 1425 | + if (is_null($nameSpace) || empty($nameSpace[$this->profileID])) |
|
| 1426 | + { |
|
| 1427 | + $nameSpace[$this->profileID] = $this->_getNameSpaces(); |
|
| 1428 | + } |
|
| 1260 | 1429 | if (!empty($nameSpace[$this->profileID])) |
| 1261 | 1430 | { |
| 1262 | 1431 | $nsNoPersonal=array(); |
| 1263 | 1432 | foreach($nameSpace[$this->profileID] as &$ns) |
| 1264 | 1433 | { |
| 1265 | - if ($ns['type']!='personal') $nsNoPersonal[]=$ns; |
|
| 1434 | + if ($ns['type']!='personal') |
|
| 1435 | + { |
|
| 1436 | + $nsNoPersonal[]=$ns; |
|
| 1437 | + } |
|
| 1266 | 1438 | } |
| 1267 | 1439 | $nameSpace[$this->profileID]=$nsNoPersonal; |
| 1268 | 1440 | } |
| 1269 | - if (is_null($prefix) || empty($prefix[$this->profileID]) || empty($prefix[$this->profileID][$_folderName])) $prefix[$this->profileID][$_folderName] = $this->getFolderPrefixFromNamespace($nameSpace[$this->profileID], $_folderName); |
|
| 1441 | + if (is_null($prefix) || empty($prefix[$this->profileID]) || empty($prefix[$this->profileID][$_folderName])) |
|
| 1442 | + { |
|
| 1443 | + $prefix[$this->profileID][$_folderName] = $this->getFolderPrefixFromNamespace($nameSpace[$this->profileID], $_folderName); |
|
| 1444 | + } |
|
| 1270 | 1445 | |
| 1271 | 1446 | if ($fetchSubscribedInfo && is_null($subscribedFolders) || empty($subscribedFolders[$this->profileID])) |
| 1272 | 1447 | { |
| 1273 | 1448 | $subscribedFolders[$this->profileID] = $this->icServer->listSubscribedMailboxes(); |
| 1274 | 1449 | } |
| 1275 | 1450 | |
| 1276 | - if($fetchSubscribedInfo && is_array($subscribedFolders[$this->profileID]) && in_array($_folderName,$subscribedFolders[$this->profileID])) { |
|
| 1451 | + if($fetchSubscribedInfo && is_array($subscribedFolders[$this->profileID]) && in_array($_folderName,$subscribedFolders[$this->profileID])) |
|
| 1452 | + { |
|
| 1277 | 1453 | $retValue['subscribed'] = true; |
| 1278 | 1454 | } |
| 1279 | 1455 | |
@@ -1292,8 +1468,7 @@ discard block |
||
| 1292 | 1468 | (isset($this->mailPreferences['trustServersUnseenInfo']) && |
| 1293 | 1469 | $this->mailPreferences['trustServersUnseenInfo']==2 && |
| 1294 | 1470 | $prefix[$this->profileID][$_folderName] != '' && stripos($_folderName,$prefix[$this->profileID][$_folderName]) !== false) |
| 1295 | - ) |
|
| 1296 | - { |
|
| 1471 | + ) { |
|
| 1297 | 1472 | //error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($prefix,true).' TS:'.$this->mailPreferences['trustServersUnseenInfo']); |
| 1298 | 1473 | // we filter for the combined status of unseen and undeleted, as this is what we show in list |
| 1299 | 1474 | try |
@@ -1303,13 +1478,19 @@ discard block |
||
| 1303 | 1478 | } |
| 1304 | 1479 | catch (\Exception $ee) |
| 1305 | 1480 | { |
| 1306 | - if (self::$debug) error_log(__METHOD__." could not fetch/calculate unseen counter for $_folderName Reason:'".$ee->getMessage()."' but requested."); |
|
| 1481 | + if (self::$debug) |
|
| 1482 | + { |
|
| 1483 | + error_log(__METHOD__." could not fetch/calculate unseen counter for $_folderName Reason:'".$ee->getMessage()."' but requested."); |
|
| 1484 | + } |
|
| 1307 | 1485 | } |
| 1308 | 1486 | } |
| 1309 | 1487 | } |
| 1310 | 1488 | catch (\Exception $e) |
| 1311 | 1489 | { |
| 1312 | - if (self::$debug) error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($e->getMessage(),true)); |
|
| 1490 | + if (self::$debug) |
|
| 1491 | + { |
|
| 1492 | + error_log(__METHOD__." returned folderStatus for Folder $_folderName:".print_r($e->getMessage(),true)); |
|
| 1493 | + } |
|
| 1313 | 1494 | } |
| 1314 | 1495 | |
| 1315 | 1496 | return $retValue; |
@@ -1334,8 +1515,14 @@ discard block |
||
| 1334 | 1515 | function getHeaders($_folderName, $_startMessage, $_numberOfMessages, $_sort, $_reverse, $_filter, $_thisUIDOnly=null, $_cacheResult=true, $_fetchPreviews=false) |
| 1335 | 1516 | { |
| 1336 | 1517 | //self::$debug=true; |
| 1337 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.function_backtrace()); |
|
| 1338 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$_folderName,$_startMessage, $_numberOfMessages, $_sort, $_reverse, ".array2string($_filter).", $_thisUIDOnly"); |
|
| 1518 | + if (self::$debug) |
|
| 1519 | + { |
|
| 1520 | + error_log(__METHOD__.' ('.__LINE__.') '.function_backtrace()); |
|
| 1521 | + } |
|
| 1522 | + if (self::$debug) |
|
| 1523 | + { |
|
| 1524 | + error_log(__METHOD__.' ('.__LINE__.') '."$_folderName,$_startMessage, $_numberOfMessages, $_sort, $_reverse, ".array2string($_filter).", $_thisUIDOnly"); |
|
| 1525 | + } |
|
| 1339 | 1526 | $reverse = (bool)$_reverse; |
| 1340 | 1527 | // get the list of messages to fetch |
| 1341 | 1528 | $this->reopen($_folderName); |
@@ -1356,21 +1543,34 @@ discard block |
||
| 1356 | 1543 | //$_filter['range'] ="$start:$end"; |
| 1357 | 1544 | //$_filter['range'] ="$_startMessage:*"; |
| 1358 | 1545 | } |
| 1359 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$_folderName, $_sort, $reverse, ".array2string($_filter).", $rByUid"); |
|
| 1360 | - if (self::$debug||self::$debugTimes) $starttime = microtime (true); |
|
| 1546 | + if (self::$debug) |
|
| 1547 | + { |
|
| 1548 | + error_log(__METHOD__.' ('.__LINE__.') '."$_folderName, $_sort, $reverse, ".array2string($_filter).", $rByUid"); |
|
| 1549 | + } |
|
| 1550 | + if (self::$debug||self::$debugTimes) |
|
| 1551 | + { |
|
| 1552 | + $starttime = microtime (true); |
|
| 1553 | + } |
|
| 1361 | 1554 | //see this example below for a 12 week datefilter (since) |
| 1362 | 1555 | //$_filter = array('status'=>array('UNDELETED'),'type'=>"SINCE",'string'=> date("d-M-Y", $starttime-(3600*24*7*12))); |
| 1363 | 1556 | $_sortResult = $this->getSortedList($_folderName, $_sort, $reverse, $_filter, $rByUid, $_cacheResult); |
| 1364 | 1557 | $sortResult = $_sortResult['match']->ids; |
| 1365 | 1558 | //$modseq = $_sortResult['modseq']; |
| 1366 | 1559 | //error_log(__METHOD__.' ('.__LINE__.') '.'Modsequence:'.$modseq); |
| 1367 | - if (self::$debug||self::$debugTimes) self::logRunTimes($starttime,null,' call getSortedList for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_thisUIDOnly),__METHOD__.' ('.__LINE__.') '); |
|
| 1560 | + if (self::$debug||self::$debugTimes) |
|
| 1561 | + { |
|
| 1562 | + self::logRunTimes($starttime,null,' call getSortedList for Folder:'.$_folderName.' Filter:'.array2string($_filter).' Ids:'.array2string($_thisUIDOnly),__METHOD__.' ('.__LINE__.') '); |
|
| 1563 | + } |
|
| 1368 | 1564 | |
| 1369 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult)); |
|
| 1565 | + if (self::$debug) |
|
| 1566 | + { |
|
| 1567 | + error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult)); |
|
| 1568 | + } |
|
| 1370 | 1569 | #$this->icServer->setDebug(false); |
| 1371 | 1570 | #print "</pre>"; |
| 1372 | 1571 | // nothing found |
| 1373 | - if(!is_array($sortResult) || empty($sortResult)) { |
|
| 1572 | + if(!is_array($sortResult) || empty($sortResult)) |
|
| 1573 | + { |
|
| 1374 | 1574 | $retValue = array(); |
| 1375 | 1575 | $retValue['info']['total'] = 0; |
| 1376 | 1576 | $retValue['info']['first'] = 0; |
@@ -1382,7 +1582,8 @@ discard block |
||
| 1382 | 1582 | #_debug_array($sortResult); |
| 1383 | 1583 | #_debug_array(array_slice($sortResult, -5, -2)); |
| 1384 | 1584 | //error_log("REVERSE: $reverse"); |
| 1385 | - if($reverse === true) { |
|
| 1585 | + if($reverse === true) |
|
| 1586 | + { |
|
| 1386 | 1587 | if ($_startMessage<=$total) |
| 1387 | 1588 | { |
| 1388 | 1589 | $startMessage = $_startMessage-1; |
@@ -1394,7 +1595,10 @@ discard block |
||
| 1394 | 1595 | { |
| 1395 | 1596 | $numberOfMessages = $total%$_numberOfMessages; |
| 1396 | 1597 | //$numberOfMessages = abs($_startMessage-$total-1); |
| 1397 | - if ($numberOfMessages>0 && $numberOfMessages<=$_numberOfMessages) $_numberOfMessages = $numberOfMessages; |
|
| 1598 | + if ($numberOfMessages>0 && $numberOfMessages<=$_numberOfMessages) |
|
| 1599 | + { |
|
| 1600 | + $_numberOfMessages = $numberOfMessages; |
|
| 1601 | + } |
|
| 1398 | 1602 | //error_log(__METHOD__.' ('.__LINE__.') '.' Start:'.$_startMessage.' NumberOfMessages:'.$_numberOfMessages.' Total:'.$total); |
| 1399 | 1603 | } |
| 1400 | 1604 | $startMessage=($total-$_numberOfMessages)-1; |
@@ -1408,19 +1612,36 @@ discard block |
||
| 1408 | 1612 | //$retValue['info']['first'] = $startMessage; |
| 1409 | 1613 | //$retValue['info']['last'] = $total; |
| 1410 | 1614 | } |
| 1411 | - if($startMessage > 0) { |
|
| 1412 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+$startMessage)).', '.-$startMessage.' Number of Messages:'.count($sortResult)); |
|
| 1615 | + if($startMessage > 0) |
|
| 1616 | + { |
|
| 1617 | + if (self::$debug) |
|
| 1618 | + { |
|
| 1619 | + error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+$startMessage)).', '.-$startMessage.' Number of Messages:'.count($sortResult)); |
|
| 1620 | + } |
|
| 1413 | 1621 | $sortResult = array_slice($sortResult, -($_numberOfMessages+$startMessage), -$startMessage); |
| 1414 | - } else { |
|
| 1415 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+($_startMessage-1))).', AllTheRest, Number of Messages:'.count($sortResult)); |
|
| 1622 | + } |
|
| 1623 | + else |
|
| 1624 | + { |
|
| 1625 | + if (self::$debug) |
|
| 1626 | + { |
|
| 1627 | + error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.(-($_numberOfMessages+($_startMessage-1))).', AllTheRest, Number of Messages:'.count($sortResult)); |
|
| 1628 | + } |
|
| 1416 | 1629 | $sortResult = array_slice($sortResult, -($_numberOfMessages+($_startMessage-1))); |
| 1417 | 1630 | } |
| 1418 | 1631 | $sortResult = array_reverse($sortResult); |
| 1419 | - } else { |
|
| 1420 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.($_startMessage-1).', '.$_numberOfMessages.' Number of Messages:'.count($sortResult)); |
|
| 1632 | + } |
|
| 1633 | + else |
|
| 1634 | + { |
|
| 1635 | + if (self::$debug) |
|
| 1636 | + { |
|
| 1637 | + error_log(__METHOD__.' ('.__LINE__.') '.' StartMessage:'.($_startMessage-1).', '.$_numberOfMessages.' Number of Messages:'.count($sortResult)); |
|
| 1638 | + } |
|
| 1421 | 1639 | $sortResult = array_slice($sortResult, $_startMessage-1, $_numberOfMessages); |
| 1422 | 1640 | } |
| 1423 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult)); |
|
| 1641 | + if (self::$debug) |
|
| 1642 | + { |
|
| 1643 | + error_log(__METHOD__.' ('.__LINE__.') '.array2string($sortResult)); |
|
| 1644 | + } |
|
| 1424 | 1645 | } |
| 1425 | 1646 | else |
| 1426 | 1647 | { |
@@ -1429,7 +1650,10 @@ discard block |
||
| 1429 | 1650 | |
| 1430 | 1651 | |
| 1431 | 1652 | // fetch the data for the selected messages |
| 1432 | - if (self::$debug||self::$debugTimes) $starttime = microtime(true); |
|
| 1653 | + if (self::$debug||self::$debugTimes) |
|
| 1654 | + { |
|
| 1655 | + $starttime = microtime(true); |
|
| 1656 | + } |
|
| 1433 | 1657 | try |
| 1434 | 1658 | { |
| 1435 | 1659 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
@@ -1453,7 +1677,10 @@ discard block |
||
| 1453 | 1677 | $fquery->flags(); |
| 1454 | 1678 | $fquery->imapDate();// needed to ensure getImapDate fetches the internaldate, not the current time |
| 1455 | 1679 | // if $_fetchPreviews is activated fetch part of the messages too |
| 1456 | - if ($_fetchPreviews) $fquery->fullText(array('peek'=>true,'length'=>((int)$_fetchPreviews<5000?5000:$_fetchPreviews),'start'=>0)); |
|
| 1680 | + if ($_fetchPreviews) |
|
| 1681 | + { |
|
| 1682 | + $fquery->fullText(array('peek'=>true,'length'=>((int)$_fetchPreviews<5000?5000:$_fetchPreviews),'start'=>0)); |
|
| 1683 | + } |
|
| 1457 | 1684 | $headersNew = $this->icServer->fetch($_folderName, $fquery, array( |
| 1458 | 1685 | 'ids' => $uidsToFetch, |
| 1459 | 1686 | )); |
@@ -1476,14 +1703,20 @@ discard block |
||
| 1476 | 1703 | |
| 1477 | 1704 | $cnt = 0; |
| 1478 | 1705 | |
| 1479 | - foreach((array)$sortResult as $uid) { |
|
| 1706 | + foreach((array)$sortResult as $uid) |
|
| 1707 | + { |
|
| 1480 | 1708 | $sortOrder[$uid] = $cnt++; |
| 1481 | 1709 | } |
| 1482 | 1710 | |
| 1483 | 1711 | $count = 0; |
| 1484 | - if (is_object($headersNew)) { |
|
| 1485 | - if (self::$debug||self::$debugTimes) $starttime = microtime(true); |
|
| 1486 | - foreach($headersNew->ids() as $id) { |
|
| 1712 | + if (is_object($headersNew)) |
|
| 1713 | + { |
|
| 1714 | + if (self::$debug||self::$debugTimes) |
|
| 1715 | + { |
|
| 1716 | + $starttime = microtime(true); |
|
| 1717 | + } |
|
| 1718 | + foreach($headersNew->ids() as $id) |
|
| 1719 | + { |
|
| 1487 | 1720 | $_headerObject = $headersNew->get($id); |
| 1488 | 1721 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_headerObject)); |
| 1489 | 1722 | $headerObject = array(); |
@@ -1496,7 +1729,10 @@ discard block |
||
| 1496 | 1729 | // Get already cached headers, 'fetchHeaders' is a label matchimg above |
| 1497 | 1730 | $headerForPrio = $_headerObject->getHeaders('fetchHeaders',Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(); |
| 1498 | 1731 | // Try to fetch header with key='' as some servers might have no fetchHeaders index. e.g. yandex.com |
| 1499 | - if (empty($headerForPrio)) $headerForPrio = $_headerObject->getHeaders('',Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(); |
|
| 1732 | + if (empty($headerForPrio)) |
|
| 1733 | + { |
|
| 1734 | + $headerForPrio = $_headerObject->getHeaders('',Horde_Imap_Client_Data_Fetch::HEADER_PARSE)->toArray(); |
|
| 1735 | + } |
|
| 1500 | 1736 | //fetch the fullMsg part if all conditions match to be available in case $_headerObject->getHeaders returns |
| 1501 | 1737 | //nothing worthwhile (as it does for googlemail accounts, when preview is switched on |
| 1502 | 1738 | if ($_fetchPreviews) |
@@ -1507,12 +1743,16 @@ discard block |
||
| 1507 | 1743 | if (empty($headerForPrio)||(is_array($headerForPrio)&&count($headerForPrio)===1&&$headerForPrio[''])) |
| 1508 | 1744 | { |
| 1509 | 1745 | $length = strpos($bodyPreview, Horde_Mime_Part::RFC_EOL.Horde_Mime_Part::RFC_EOL); |
| 1510 | - if ($length===false) $length = strlen($bodyPreview); |
|
| 1746 | + if ($length===false) |
|
| 1747 | + { |
|
| 1748 | + $length = strlen($bodyPreview); |
|
| 1749 | + } |
|
| 1511 | 1750 | $headerForPrio = Horde_Mime_Headers::parseHeaders(substr($bodyPreview, 0,$length))->toArray(); |
| 1512 | 1751 | } |
| 1513 | 1752 | } |
| 1514 | 1753 | $headerForPrio = array_change_key_case($headerForPrio, CASE_UPPER); |
| 1515 | - if (self::$debug) { |
|
| 1754 | + if (self::$debug) |
|
| 1755 | + { |
|
| 1516 | 1756 | 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')); |
| 1517 | 1757 | error_log(__METHOD__.' ('.__LINE__.') '.array2string($headerForPrio)); |
| 1518 | 1758 | } |
@@ -1522,11 +1762,16 @@ discard block |
||
| 1522 | 1762 | $total--; |
| 1523 | 1763 | continue; |
| 1524 | 1764 | } |
| 1525 | - if ( isset($headerForPrio['DISPOSITION-NOTIFICATION-TO']) ) { |
|
| 1765 | + if ( isset($headerForPrio['DISPOSITION-NOTIFICATION-TO']) ) |
|
| 1766 | + { |
|
| 1526 | 1767 | $headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['DISPOSITION-NOTIFICATION-TO'])); |
| 1527 | - } else if ( isset($headerForPrio['RETURN-RECEIPT-TO']) ) { |
|
| 1768 | + } |
|
| 1769 | + else if ( isset($headerForPrio['RETURN-RECEIPT-TO']) ) |
|
| 1770 | + { |
|
| 1528 | 1771 | $headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['RETURN-RECEIPT-TO'])); |
| 1529 | - } else if ( isset($headerForPrio['X-CONFIRM-READING-TO']) ) { |
|
| 1772 | + } |
|
| 1773 | + else if ( isset($headerForPrio['X-CONFIRM-READING-TO']) ) |
|
| 1774 | + { |
|
| 1530 | 1775 | $headerObject['DISPOSITION-NOTIFICATION-TO'] = self::decode_header(trim($headerForPrio['X-CONFIRM-READING-TO'])); |
| 1531 | 1776 | } /*else $sent_not = "";*/ |
| 1532 | 1777 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($headerObject)); |
@@ -1557,7 +1802,11 @@ discard block |
||
| 1557 | 1802 | $rfcAddr = self::parseAddressList($ad); // does some fixing of known problems too |
| 1558 | 1803 | foreach ($rfcAddr as $_rfcAddr) |
| 1559 | 1804 | { |
| 1560 | - if (!$_rfcAddr->valid) continue; // skip. not a valid address |
|
| 1805 | + if (!$_rfcAddr->valid) |
|
| 1806 | + { |
|
| 1807 | + continue; |
|
| 1808 | + } |
|
| 1809 | + // skip. not a valid address |
|
| 1561 | 1810 | $address[] = imap_rfc822_write_address($_rfcAddr->mailbox,$_rfcAddr->host,$_rfcAddr->personal); |
| 1562 | 1811 | } |
| 1563 | 1812 | } |
@@ -1573,7 +1822,10 @@ discard block |
||
| 1573 | 1822 | { |
| 1574 | 1823 | // $bodyPreview is populated at the beginning of the loop, as it may be |
| 1575 | 1824 | // needed to parse the Headers of the Message |
| 1576 | - if (empty($bodyPreview)) $bodyPreview = $_headerObject->getFullMsg(); |
|
| 1825 | + if (empty($bodyPreview)) |
|
| 1826 | + { |
|
| 1827 | + $bodyPreview = $_headerObject->getFullMsg(); |
|
| 1828 | + } |
|
| 1577 | 1829 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($bodyPreview)); |
| 1578 | 1830 | $base = Horde_Mime_Part::parseMessage($bodyPreview); |
| 1579 | 1831 | foreach($base->partIterator() as $part) |
@@ -1586,7 +1838,8 @@ discard block |
||
| 1586 | 1838 | 'encode' => Horde_Mime_Part::ENCODE_BINARY, // otherwise we cant recode charset |
| 1587 | 1839 | )), $charset, 'utf-8'); |
| 1588 | 1840 | $headerObject['BODYPREVIEW']=trim(str_replace(array("\r\n","\r","\n"),' ',mb_substr(Translation::convert_jsonsafe($buffer),0,((int)$_fetchPreviews<300?300:$_fetchPreviews)))); |
| 1589 | - } elseif (empty($headerObject['BODYPREVIEW'])&&$part->getPrimaryType()== 'multipart') |
|
| 1841 | + } |
|
| 1842 | + elseif (empty($headerObject['BODYPREVIEW'])&&$part->getPrimaryType()== 'multipart') |
|
| 1590 | 1843 | { |
| 1591 | 1844 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($part)); |
| 1592 | 1845 | } |
@@ -1602,7 +1855,10 @@ discard block |
||
| 1602 | 1855 | $messageMimeType=''; |
| 1603 | 1856 | foreach ($mailStructureObject->contentTypeMap() as $mime_id => $mime_type) |
| 1604 | 1857 | { |
| 1605 | - if ($mime_id==0 || $messageMimeType==='') $messageMimeType = $mime_type; |
|
| 1858 | + if ($mime_id==0 || $messageMimeType==='') |
|
| 1859 | + { |
|
| 1860 | + $messageMimeType = $mime_type; |
|
| 1861 | + } |
|
| 1606 | 1862 | $part = $mailStructureObject->getPart($mime_id); |
| 1607 | 1863 | $partdisposition = $part->getDisposition(); |
| 1608 | 1864 | $partPrimaryType = $part->getPrimaryType(); |
@@ -1612,7 +1868,8 @@ discard block |
||
| 1612 | 1868 | // bodypreview could be found (multipart/....) |
| 1613 | 1869 | if ($_fetchPreviews && empty($headerObject['BODYPREVIEW'])&&($partPrimaryType == 'text') && |
| 1614 | 1870 | ((intval($mime_id) === 1) || !$mime_id) && |
| 1615 | - ($partdisposition !== 'attachment')) { |
|
| 1871 | + ($partdisposition !== 'attachment')) |
|
| 1872 | + { |
|
| 1616 | 1873 | $_structure=$part; |
| 1617 | 1874 | $this->fetchPartContents($uid, $_structure, false,true); |
| 1618 | 1875 | $headerObject['BODYPREVIEW']=trim(str_replace(array("\r\n","\r","\n"),' ',mb_substr(Mail\Html::convertHTMLToText($_structure->getContents()),0,((int)$_fetchPreviews<300?300:$_fetchPreviews)))); |
@@ -1634,10 +1891,19 @@ discard block |
||
| 1634 | 1891 | if ($mime_type=='message/rfc822') |
| 1635 | 1892 | { |
| 1636 | 1893 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.':'.array2string($part->contentTypeMap())); |
| 1637 | - foreach($part->contentTypeMap() as $sub_id => $sub_type) { if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type;} |
|
| 1894 | + foreach($part->contentTypeMap() as $sub_id => $sub_type) |
|
| 1895 | + { |
|
| 1896 | +if ($sub_id != $mime_id) |
|
| 1897 | + { |
|
| 1898 | + $skipParts[$sub_id] = $sub_type; |
|
| 1899 | + } |
|
| 1900 | + } |
|
| 1638 | 1901 | } |
| 1639 | 1902 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.' Disp:'.$partdisposition.' Type:'.$partPrimaryType.' Skip:'.array2string($skipParts)); |
| 1640 | - if (array_key_exists($mime_id,$skipParts)) continue; |
|
| 1903 | + if (array_key_exists($mime_id,$skipParts)) |
|
| 1904 | + { |
|
| 1905 | + continue; |
|
| 1906 | + } |
|
| 1641 | 1907 | if ($partdisposition=='attachment' || |
| 1642 | 1908 | ($partdisposition=='inline'&&$partPrimaryType == 'image'&&$mime_type=='image/tiff') || // as we are not able to display tiffs |
| 1643 | 1909 | ($partdisposition=='inline'&&$partPrimaryType == 'image'&&empty($cid)) || |
@@ -1648,7 +1914,10 @@ discard block |
||
| 1648 | 1914 | $headerObject['ATTACHMENTS'][$mime_id]['uid']=$uid; |
| 1649 | 1915 | $headerObject['ATTACHMENTS'][$mime_id]['cid'] = $cid; |
| 1650 | 1916 | $headerObject['ATTACHMENTS'][$mime_id]['partID']=$mime_id; |
| 1651 | - if (!isset($headerObject['ATTACHMENTS'][$mime_id]['name']))$headerObject['ATTACHMENTS'][$mime_id]['name']=$part->getName(); |
|
| 1917 | + if (!isset($headerObject['ATTACHMENTS'][$mime_id]['name'])) |
|
| 1918 | + { |
|
| 1919 | + $headerObject['ATTACHMENTS'][$mime_id]['name']=$part->getName(); |
|
| 1920 | + } |
|
| 1652 | 1921 | if (!strcasecmp($headerObject['ATTACHMENTS'][$mime_id]['name'],'winmail.dat') || |
| 1653 | 1922 | $headerObject['ATTACHMENTS'][$mime_id]['mimeType']=='application/ms-tnef') |
| 1654 | 1923 | { |
@@ -1662,18 +1931,27 @@ discard block |
||
| 1662 | 1931 | //error_log(__METHOD__.' ('.__LINE__.') '.' FindBody (plain):'.array2string($mailStructureObject->findBody('plain'))); |
| 1663 | 1932 | //error_log(__METHOD__.' ('.__LINE__.') '.' FindBody (html):'.array2string($mailStructureObject->findBody('html'))); |
| 1664 | 1933 | //if($count == 0) error_log(__METHOD__.array2string($headerObject)); |
| 1665 | - if (empty($headerObject['UID'])) continue; |
|
| 1934 | + if (empty($headerObject['UID'])) |
|
| 1935 | + { |
|
| 1936 | + continue; |
|
| 1937 | + } |
|
| 1666 | 1938 | //$uid = ($rByUid ? $headerObject['UID'] : $headerObject['MSG_NUM']); |
| 1667 | 1939 | // make dates like "Mon, 23 Apr 2007 10:11:06 UT" working with strtotime |
| 1668 | - if(substr($headerObject['DATE'],-2) === 'UT') { |
|
| 1940 | + if(substr($headerObject['DATE'],-2) === 'UT') |
|
| 1941 | + { |
|
| 1669 | 1942 | $headerObject['DATE'] .= 'C'; |
| 1670 | 1943 | } |
| 1671 | - if(substr($headerObject['INTERNALDATE'],-2) === 'UT') { |
|
| 1944 | + if(substr($headerObject['INTERNALDATE'],-2) === 'UT') |
|
| 1945 | + { |
|
| 1672 | 1946 | $headerObject['INTERNALDATE'] .= 'C'; |
| 1673 | 1947 | } |
| 1674 | 1948 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$headerObject['SUBJECT'].'->'.$headerObject['DATE'].'<->'.$headerObject['INTERNALDATE'] .'#'); |
| 1675 | 1949 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$this->decode_subject($headerObject['SUBJECT']).'->'.$headerObject['DATE']); |
| 1676 | - if (isset($headerObject['ATTACHMENTS']) && count($headerObject['ATTACHMENTS'])) foreach ($headerObject['ATTACHMENTS'] as &$a) { $retValue['header'][$sortOrder[$uid]]['attachments'][]=$a;} |
|
| 1950 | + if (isset($headerObject['ATTACHMENTS']) && count($headerObject['ATTACHMENTS'])) |
|
| 1951 | + { |
|
| 1952 | + foreach ($headerObject['ATTACHMENTS'] as &$a) { $retValue['header'][$sortOrder[$uid]]['attachments'][]=$a; |
|
| 1953 | + } |
|
| 1954 | + } |
|
| 1677 | 1955 | $retValue['header'][$sortOrder[$uid]]['subject'] = $this->decode_subject($headerObject['SUBJECT']); |
| 1678 | 1956 | $retValue['header'][$sortOrder[$uid]]['size'] = $headerObject['SIZE']; |
| 1679 | 1957 | $retValue['header'][$sortOrder[$uid]]['date'] = self::_strtotime(($headerObject['DATE']&&!($headerObject['DATE']=='NIL')?$headerObject['DATE']:$headerObject['INTERNALDATE']),'ts',true); |
@@ -1684,22 +1962,31 @@ discard block |
||
| 1684 | 1962 | $retValue['header'][$sortOrder[$uid]]['bodypreview'] = $headerObject['BODYPREVIEW']; |
| 1685 | 1963 | $retValue['header'][$sortOrder[$uid]]['priority'] = ($headerObject['PRIORITY']?$headerObject['PRIORITY']:3); |
| 1686 | 1964 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.array2string($retValue['header'][$sortOrder[$uid]])); |
| 1687 | - if (isset($headerObject['DISPOSITION-NOTIFICATION-TO'])) $retValue['header'][$sortOrder[$uid]]['disposition-notification-to'] = $headerObject['DISPOSITION-NOTIFICATION-TO']; |
|
| 1688 | - if (is_array($headerObject['FLAGS'])) { |
|
| 1965 | + if (isset($headerObject['DISPOSITION-NOTIFICATION-TO'])) |
|
| 1966 | + { |
|
| 1967 | + $retValue['header'][$sortOrder[$uid]]['disposition-notification-to'] = $headerObject['DISPOSITION-NOTIFICATION-TO']; |
|
| 1968 | + } |
|
| 1969 | + if (is_array($headerObject['FLAGS'])) |
|
| 1970 | + { |
|
| 1689 | 1971 | $retValue['header'][$sortOrder[$uid]] = array_merge($retValue['header'][$sortOrder[$uid]],self::prepareFlagsArray($headerObject)); |
| 1690 | 1972 | } |
| 1691 | 1973 | //error_log(__METHOD__.' ('.__LINE__.') '.$headerObject['SUBJECT'].'->'.array2string($_headerObject->getEnvelope()->__get('from'))); |
| 1692 | - if(is_array($headerObject['FROM']) && $headerObject['FROM'][0]) { |
|
| 1974 | + if(is_array($headerObject['FROM']) && $headerObject['FROM'][0]) |
|
| 1975 | + { |
|
| 1693 | 1976 | $retValue['header'][$sortOrder[$uid]]['sender_address'] = self::decode_header($headerObject['FROM'][0],true); |
| 1694 | 1977 | } |
| 1695 | - if(is_array($headerObject['TO']) && $headerObject['TO'][0]) { |
|
| 1978 | + if(is_array($headerObject['TO']) && $headerObject['TO'][0]) |
|
| 1979 | + { |
|
| 1696 | 1980 | $retValue['header'][$sortOrder[$uid]]['to_address'] = self::decode_header($headerObject['TO'][0],true); |
| 1697 | 1981 | if (count($headerObject['TO'])>1) |
| 1698 | 1982 | { |
| 1699 | 1983 | $ki=0; |
| 1700 | 1984 | foreach($headerObject['TO'] as $k => $add) |
| 1701 | 1985 | { |
| 1702 | - if ($k==0) continue; |
|
| 1986 | + if ($k==0) |
|
| 1987 | + { |
|
| 1988 | + continue; |
|
| 1989 | + } |
|
| 1703 | 1990 | //error_log(__METHOD__.' ('.__LINE__.') '."-> $k:".array2string($add)); |
| 1704 | 1991 | $retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki] = self::decode_header($add,true); |
| 1705 | 1992 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($retValue['header'][$sortOrder[$uid]]['additional_to_addresses'][$ki])); |
@@ -1707,7 +1994,8 @@ discard block |
||
| 1707 | 1994 | } |
| 1708 | 1995 | } |
| 1709 | 1996 | } |
| 1710 | - if(is_array($headerObject['CC']) && count($headerObject['CC'])>0) { |
|
| 1997 | + if(is_array($headerObject['CC']) && count($headerObject['CC'])>0) |
|
| 1998 | + { |
|
| 1711 | 1999 | $ki=0; |
| 1712 | 2000 | foreach($headerObject['CC'] as $k => $add) |
| 1713 | 2001 | { |
@@ -1721,27 +2009,41 @@ discard block |
||
| 1721 | 2009 | |
| 1722 | 2010 | $count++; |
| 1723 | 2011 | } |
| 1724 | - if (self::$debug||self::$debugTimes) self::logRunTimes($starttime,null,' fetching Headers and stuff for Folder:'.$_folderName,__METHOD__.' ('.__LINE__.') '); |
|
| 2012 | + if (self::$debug||self::$debugTimes) |
|
| 2013 | + { |
|
| 2014 | + self::logRunTimes($starttime,null,' fetching Headers and stuff for Folder:'.$_folderName,__METHOD__.' ('.__LINE__.') '); |
|
| 2015 | + } |
|
| 1725 | 2016 | //self::$debug=false; |
| 1726 | 2017 | // sort the messages to the requested displayorder |
| 1727 | - if(is_array($retValue['header'])) { |
|
| 2018 | + if(is_array($retValue['header'])) |
|
| 2019 | + { |
|
| 1728 | 2020 | $countMessages = $total; |
| 1729 | - if (isset($_filter['range'])) $countMessages = self::$folderStatusCache[$this->profileID][$_folderName]['messages']; |
|
| 2021 | + if (isset($_filter['range'])) |
|
| 2022 | + { |
|
| 2023 | + $countMessages = self::$folderStatusCache[$this->profileID][$_folderName]['messages']; |
|
| 2024 | + } |
|
| 1730 | 2025 | ksort($retValue['header']); |
| 1731 | 2026 | $retValue['info']['total'] = $total; |
| 1732 | 2027 | //if ($_startMessage>$total) $_startMessage = $total-($count-1); |
| 1733 | 2028 | $retValue['info']['first'] = $_startMessage; |
| 1734 | 2029 | $retValue['info']['last'] = $_startMessage + $count - 1 ; |
| 1735 | 2030 | return $retValue; |
| 1736 | - } else { |
|
| 2031 | + } |
|
| 2032 | + else |
|
| 2033 | + { |
|
| 1737 | 2034 | $retValue = array(); |
| 1738 | 2035 | $retValue['info']['total'] = 0; |
| 1739 | 2036 | $retValue['info']['first'] = 0; |
| 1740 | 2037 | $retValue['info']['last'] = 0; |
| 1741 | 2038 | return $retValue; |
| 1742 | 2039 | } |
| 1743 | - } else { |
|
| 1744 | - if ($headersNew == null && empty($_thisUIDOnly)) error_log(__METHOD__." -> retrieval of Message Details to Query $queryString failed: ".print_r($headersNew,TRUE)); |
|
| 2040 | + } |
|
| 2041 | + else |
|
| 2042 | + { |
|
| 2043 | + if ($headersNew == null && empty($_thisUIDOnly)) |
|
| 2044 | + { |
|
| 2045 | + error_log(__METHOD__." -> retrieval of Message Details to Query $queryString failed: ".print_r($headersNew,TRUE)); |
|
| 2046 | + } |
|
| 1745 | 2047 | $retValue = array(); |
| 1746 | 2048 | $retValue['info']['total'] = 0; |
| 1747 | 2049 | $retValue['info']['first'] = 0; |
@@ -1758,7 +2060,10 @@ discard block |
||
| 1758 | 2060 | */ |
| 1759 | 2061 | static function prepareFlagsArray($headerObject) |
| 1760 | 2062 | { |
| 1761 | - if (is_array($headerObject['FLAGS'])) $headerFlags = array_map('strtolower',$headerObject['FLAGS']); |
|
| 2063 | + if (is_array($headerObject['FLAGS'])) |
|
| 2064 | + { |
|
| 2065 | + $headerFlags = array_map('strtolower',$headerObject['FLAGS']); |
|
| 2066 | + } |
|
| 1762 | 2067 | $retValue = array(); |
| 1763 | 2068 | $retValue['recent'] = in_array('\\recent', $headerFlags); |
| 1764 | 2069 | $retValue['flagged'] = in_array('\\flagged', $headerFlags); |
@@ -1809,24 +2114,43 @@ discard block |
||
| 1809 | 2114 | //error_log(__METHOD__.' ('.__LINE__.') '.' Filter:'.array2string($_filter)); |
| 1810 | 2115 | $try2useCache = true; |
| 1811 | 2116 | static $eMailListContainsDeletedMessages = null; |
| 1812 | - if (is_null($eMailListContainsDeletedMessages)) $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 2117 | + if (is_null($eMailListContainsDeletedMessages)) |
|
| 2118 | + { |
|
| 2119 | + $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 2120 | + } |
|
| 1813 | 2121 | // this indicates, that there is no Filter set, and the returned set/subset should not contain DELETED Messages, nor filtered for UNDELETED |
| 1814 | 2122 | if ($setSession==true && ((strpos(array2string($_filter), 'UNDELETED') === false && strpos(array2string($_filter), 'DELETED') === false))) |
| 1815 | 2123 | { |
| 1816 | - if (self::$debugTimes) $starttime = microtime(true); |
|
| 1817 | - 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); |
|
| 1818 | - $deletedMessages = $this->getSortedList($_folderName, 0, $three=1, array('status'=>array('DELETED')),$five=true,false); |
|
| 1819 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') Found DeletedMessages:'.array2string($eMailListContainsDeletedMessages)); |
|
| 1820 | - $eMailListContainsDeletedMessages[$this->profileID][$_folderName] =$deletedMessages['count']; |
|
| 1821 | - Cache::setCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),$eMailListContainsDeletedMessages, 60*60*1); |
|
| 1822 | - 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']); |
|
| 2124 | + if (self::$debugTimes) |
|
| 2125 | + { |
|
| 2126 | + $starttime = microtime(true); |
|
| 2127 | + } |
|
| 2128 | + if (is_null($eMailListContainsDeletedMessages) || empty($eMailListContainsDeletedMessages[$this->profileID]) || empty($eMailListContainsDeletedMessages[$this->profileID][$_folderName])) |
|
| 2129 | + { |
|
| 2130 | + $eMailListContainsDeletedMessages = Cache::getCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 2131 | + } |
|
| 2132 | + $deletedMessages = $this->getSortedList($_folderName, 0, $three=1, array('status'=>array('DELETED')),$five=true,false); |
|
| 2133 | + if (self::$debug) |
|
| 2134 | + { |
|
| 2135 | + error_log(__METHOD__.' ('.__LINE__.') Found DeletedMessages:'.array2string($eMailListContainsDeletedMessages)); |
|
| 2136 | + } |
|
| 2137 | + $eMailListContainsDeletedMessages[$this->profileID][$_folderName] =$deletedMessages['count']; |
|
| 2138 | + Cache::setCache(Cache::INSTANCE,'email','eMailListContainsDeletedMessages'.trim($GLOBALS['egw_info']['user']['account_id']),$eMailListContainsDeletedMessages, 60*60*1); |
|
| 2139 | + if (self::$debugTimes) |
|
| 2140 | + { |
|
| 2141 | + self::logRunTimes($starttime,null,'setting eMailListContainsDeletedMessages for Profile:'.$this->profileID.' Folder:'.$_folderName.' to '.$eMailListContainsDeletedMessages[$this->profileID][$_folderName],__METHOD__.' ('.__LINE__.') '); |
|
| 2142 | + } |
|
| 2143 | + //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']); |
|
| 1823 | 2144 | } |
| 1824 | 2145 | $try2useCache = false; |
| 1825 | 2146 | //self::$supportsORinQuery[$this->profileID]=true; |
| 1826 | 2147 | if (is_null(self::$supportsORinQuery) || !isset(self::$supportsORinQuery[$this->profileID])) |
| 1827 | 2148 | { |
| 1828 | 2149 | self::$supportsORinQuery = Cache::getCache(Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*10); |
| 1829 | - if (!isset(self::$supportsORinQuery[$this->profileID])) self::$supportsORinQuery[$this->profileID]=true; |
|
| 2150 | + if (!isset(self::$supportsORinQuery[$this->profileID])) |
|
| 2151 | + { |
|
| 2152 | + self::$supportsORinQuery[$this->profileID]=true; |
|
| 2153 | + } |
|
| 1830 | 2154 | } |
| 1831 | 2155 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_filter).' SupportsOrInQuery:'.self::$supportsORinQuery[$this->profileID]); |
| 1832 | 2156 | $filter = $this->createIMAPFilter($_folderName, $_filter,self::$supportsORinQuery[$this->profileID]); |
@@ -1837,15 +2161,26 @@ discard block |
||
| 1837 | 2161 | } |
| 1838 | 2162 | //_debug_array($filter); |
| 1839 | 2163 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($filter).'#'.array2string($this->icServer->capability())); |
| 1840 | - if($this->icServer->hasCapability('SORT')) { |
|
| 2164 | + if($this->icServer->hasCapability('SORT')) |
|
| 2165 | + { |
|
| 1841 | 2166 | // when using an orQuery and we sort by date. sort seems to fail on certain servers => ZIMBRA with Horde_Imap_Client |
| 1842 | 2167 | // thus we translate the search request from date to Horde_Imap_Client::SORT_SEQUENCE (which should be the same, if |
| 1843 | 2168 | // there is no messing with the dates) |
| 1844 | 2169 | //if (self::$supportsORinQuery[$this->profileID]&&$_sort=='date'&&$_filter['type']=='quick'&&!empty($_filter['string']))$_sort='INTERNALDATE'; |
| 1845 | - if (self::$debug) error_log(__METHOD__." Mailserver has SORT Capability, SortBy: ".array2string($_sort)." Reverse: $_reverse"); |
|
| 2170 | + if (self::$debug) |
|
| 2171 | + { |
|
| 2172 | + error_log(__METHOD__." Mailserver has SORT Capability, SortBy: ".array2string($_sort)." Reverse: $_reverse"); |
|
| 2173 | + } |
|
| 1846 | 2174 | $sortOrder = $this->_getSortString($_sort, $_reverse); |
| 1847 | - if ($_reverse && in_array(Horde_Imap_Client::SORT_REVERSE,$sortOrder)) $_reverse=false; // as we reversed the result already |
|
| 1848 | - if (self::$debug) error_log(__METHOD__." Mailserver runs SORT: SortBy:".array2string($_sort)."->".array2string($sortOrder)." Filter: ".array2string($filter)); |
|
| 2175 | + if ($_reverse && in_array(Horde_Imap_Client::SORT_REVERSE,$sortOrder)) |
|
| 2176 | + { |
|
| 2177 | + $_reverse=false; |
|
| 2178 | + } |
|
| 2179 | + // as we reversed the result already |
|
| 2180 | + if (self::$debug) |
|
| 2181 | + { |
|
| 2182 | + error_log(__METHOD__." Mailserver runs SORT: SortBy:".array2string($_sort)."->".array2string($sortOrder)." Filter: ".array2string($filter)); |
|
| 2183 | + } |
|
| 1849 | 2184 | try |
| 1850 | 2185 | { |
| 1851 | 2186 | $sortResult = $this->icServer->search($_folderName, $filter, array( |
@@ -1857,7 +2192,10 @@ discard block |
||
| 1857 | 2192 | //error_log(__METHOD__.'('.__LINE__.'):'.$e->getMessage()); |
| 1858 | 2193 | $resultByUid = false; |
| 1859 | 2194 | $sortOrder = array(Horde_Imap_Client::SORT_SEQUENCE); |
| 1860 | - if ($_reverse) array_unshift($sortOrder,Horde_Imap_Client::SORT_REVERSE); |
|
| 2195 | + if ($_reverse) |
|
| 2196 | + { |
|
| 2197 | + array_unshift($sortOrder,Horde_Imap_Client::SORT_REVERSE); |
|
| 2198 | + } |
|
| 1861 | 2199 | try |
| 1862 | 2200 | { |
| 1863 | 2201 | $sortResult = $this->icServer->search($_folderName, $filter, array( |
@@ -1869,9 +2207,17 @@ discard block |
||
| 1869 | 2207 | $sortResult = self::$folderStatusCache[$this->profileID][$_folderName]['sortResult']; |
| 1870 | 2208 | } |
| 1871 | 2209 | } |
| 1872 | - if (self::$debug) error_log(__METHOD__.print_r($sortResult,true)); |
|
| 1873 | - } else { |
|
| 1874 | - if (self::$debug) error_log(__METHOD__." Mailserver has NO SORT Capability"); |
|
| 2210 | + if (self::$debug) |
|
| 2211 | + { |
|
| 2212 | + error_log(__METHOD__.print_r($sortResult,true)); |
|
| 2213 | + } |
|
| 2214 | + } |
|
| 2215 | + else |
|
| 2216 | + { |
|
| 2217 | + if (self::$debug) |
|
| 2218 | + { |
|
| 2219 | + error_log(__METHOD__." Mailserver has NO SORT Capability"); |
|
| 2220 | + } |
|
| 1875 | 2221 | //$sortOrder = array(Horde_Imap_Client::SORT_SEQUENCE); |
| 1876 | 2222 | //if ($_reverse) array_unshift($sortOrder,Horde_Imap_Client::SORT_REVERSE); |
| 1877 | 2223 | try |
@@ -1885,7 +2231,10 @@ discard block |
||
| 1885 | 2231 | // possible error OR Query. But Horde gives no detailed Info :-( |
| 1886 | 2232 | self::$supportsORinQuery[$this->profileID]=false; |
| 1887 | 2233 | Cache::setCache(Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']),self::$supportsORinQuery,60*60*10); |
| 1888 | - if (self::$debug) error_log(__METHOD__.__LINE__." Mailserver seems to have NO OR Capability for Search:".$sortResult->message); |
|
| 2234 | + if (self::$debug) |
|
| 2235 | + { |
|
| 2236 | + error_log(__METHOD__.__LINE__." Mailserver seems to have NO OR Capability for Search:".$sortResult->message); |
|
| 2237 | + } |
|
| 1889 | 2238 | $filter = $this->createIMAPFilter($_folderName, $_filter, self::$supportsORinQuery[$this->profileID]); |
| 1890 | 2239 | try |
| 1891 | 2240 | { |
@@ -1896,11 +2245,15 @@ discard block |
||
| 1896 | 2245 | { |
| 1897 | 2246 | } |
| 1898 | 2247 | } |
| 1899 | - if(is_array($sortResult['match'])) { |
|
| 2248 | + if(is_array($sortResult['match'])) |
|
| 2249 | + { |
|
| 1900 | 2250 | // not sure that this is going so succeed as $sortResult['match'] is a hordeObject |
| 1901 | 2251 | sort($sortResult['match'], SORT_NUMERIC); |
| 1902 | 2252 | } |
| 1903 | - if (self::$debug) error_log(__METHOD__." using Filter:".print_r($filter,true)." ->".print_r($sortResult,true)); |
|
| 2253 | + if (self::$debug) |
|
| 2254 | + { |
|
| 2255 | + error_log(__METHOD__." using Filter:".print_r($filter,true)." ->".print_r($sortResult,true)); |
|
| 2256 | + } |
|
| 1904 | 2257 | } |
| 1905 | 2258 | if ($setSession) |
| 1906 | 2259 | { |
@@ -1929,7 +2282,8 @@ discard block |
||
| 1929 | 2282 | $_reverse=false; |
| 1930 | 2283 | if (is_numeric($_sort)) |
| 1931 | 2284 | { |
| 1932 | - switch($_sort) { |
|
| 2285 | + switch($_sort) |
|
| 2286 | + { |
|
| 1933 | 2287 | case 2: |
| 1934 | 2288 | $retValue = array(Horde_Imap_Client::SORT_FROM); |
| 1935 | 2289 | break; |
@@ -1951,7 +2305,8 @@ discard block |
||
| 1951 | 2305 | } |
| 1952 | 2306 | else |
| 1953 | 2307 | { |
| 1954 | - switch(strtoupper($_sort)) { |
|
| 2308 | + switch(strtoupper($_sort)) |
|
| 2309 | + { |
|
| 1955 | 2310 | case 'FROMADDRESS': |
| 1956 | 2311 | $retValue = array(Horde_Imap_Client::SORT_FROM); |
| 1957 | 2312 | break; |
@@ -1977,7 +2332,10 @@ discard block |
||
| 1977 | 2332 | break; |
| 1978 | 2333 | } |
| 1979 | 2334 | } |
| 1980 | - if ($_reverse) array_unshift($retValue,Horde_Imap_Client::SORT_REVERSE); |
|
| 2335 | + if ($_reverse) |
|
| 2336 | + { |
|
| 2337 | + array_unshift($retValue,Horde_Imap_Client::SORT_REVERSE); |
|
| 2338 | + } |
|
| 1981 | 2339 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.($_reverse?'REVERSE ':'').$_sort.'->'.$retValue); |
| 1982 | 2340 | return $retValue; |
| 1983 | 2341 | } |
@@ -1996,7 +2354,10 @@ discard block |
||
| 1996 | 2354 | $imapFilter->charset('UTF-8'); |
| 1997 | 2355 | |
| 1998 | 2356 | //_debug_array($_criterias); |
| 1999 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' Criterias:'.(!is_array($_criterias)?" none -> returning":array2string($_criterias))); |
|
| 2357 | + if (self::$debug) |
|
| 2358 | + { |
|
| 2359 | + error_log(__METHOD__.' ('.__LINE__.') '.' Criterias:'.(!is_array($_criterias)?" none -> returning":array2string($_criterias))); |
|
| 2360 | + } |
|
| 2000 | 2361 | if((!is_array($_criterias) || $_criterias['status']=='any') && |
| 2001 | 2362 | (!isset($_criterias['string']) || empty($_criterias['string'])) && |
| 2002 | 2363 | (!isset($_criterias['range'])|| empty($_criterias['range']) || |
@@ -2011,11 +2372,13 @@ discard block |
||
| 2011 | 2372 | // statusQuery MUST be placed first, as search for subject/mailbody and such is |
| 2012 | 2373 | // depending on charset. flagSearch is not BUT messes the charset if called afterwards |
| 2013 | 2374 | $statusQueryValid = false; |
| 2014 | - foreach((array)$_criterias['status'] as $k => $criteria) { |
|
| 2375 | + foreach((array)$_criterias['status'] as $k => $criteria) |
|
| 2376 | + { |
|
| 2015 | 2377 | $imapStatusFilter = new Horde_Imap_Client_Search_Query(); |
| 2016 | 2378 | $imapStatusFilter->charset('UTF-8'); |
| 2017 | 2379 | $criteria = strtoupper($criteria); |
| 2018 | - switch ($criteria) { |
|
| 2380 | + switch ($criteria) |
|
| 2381 | + { |
|
| 2019 | 2382 | case 'ANSWERED': |
| 2020 | 2383 | case 'DELETED': |
| 2021 | 2384 | case 'FLAGGED': |
@@ -2098,9 +2461,11 @@ discard block |
||
| 2098 | 2461 | $imapSearchFilter = new Horde_Imap_Client_Search_Query(); |
| 2099 | 2462 | $imapSearchFilter->charset('UTF-8'); |
| 2100 | 2463 | |
| 2101 | - if(!empty($_criterias['string'])) { |
|
| 2464 | + if(!empty($_criterias['string'])) |
|
| 2465 | + { |
|
| 2102 | 2466 | $criteria = strtoupper($_criterias['type']); |
| 2103 | - switch ($criteria) { |
|
| 2467 | + switch ($criteria) |
|
| 2468 | + { |
|
| 2104 | 2469 | case 'BYDATE': |
| 2105 | 2470 | case 'QUICK': |
| 2106 | 2471 | case 'QUICKWITHCC': |
@@ -2108,9 +2473,12 @@ discard block |
||
| 2108 | 2473 | //$imapSearchFilter->charset('UTF-8'); |
| 2109 | 2474 | $imapFilter2 = new Horde_Imap_Client_Search_Query(); |
| 2110 | 2475 | $imapFilter2->charset('UTF-8'); |
| 2111 | - if($this->isSentFolder($_folder)) { |
|
| 2476 | + if($this->isSentFolder($_folder)) |
|
| 2477 | + { |
|
| 2112 | 2478 | $imapFilter2->headerText('TO', $_criterias['string'], $not=false); |
| 2113 | - } else { |
|
| 2479 | + } |
|
| 2480 | + else |
|
| 2481 | + { |
|
| 2114 | 2482 | $imapFilter2->headerText('FROM', $_criterias['string'], $not=false); |
| 2115 | 2483 | } |
| 2116 | 2484 | if ($_supportsOrInQuery) |
@@ -2141,7 +2509,10 @@ discard block |
||
| 2141 | 2509 | 'GB'=>1024*1000*1000,'G'=>1024*1000*1000, |
| 2142 | 2510 | 'TB'=>1024*1000*1000*1000,'T'=>1024*1000*1000*1000); |
| 2143 | 2511 | $numberinBytes=(float)$_criterias['string']; |
| 2144 | - if (isset($multipleBy[$unit])) $numberinBytes=(float)$_criterias['string']*$multipleBy[$unit]; |
|
| 2512 | + if (isset($multipleBy[$unit])) |
|
| 2513 | + { |
|
| 2514 | + $numberinBytes=(float)$_criterias['string']*$multipleBy[$unit]; |
|
| 2515 | + } |
|
| 2145 | 2516 | //error_log(__METHOD__.__LINE__.'#'.$_criterias['string'].'->'.(float)$_criterias['string'].'#'.$unit.' ='.$numberinBytes); |
| 2146 | 2517 | $_criterias['string']=$numberinBytes; |
| 2147 | 2518 | } |
@@ -2178,8 +2549,14 @@ discard block |
||
| 2178 | 2549 | break; |
| 2179 | 2550 | } |
| 2180 | 2551 | } |
| 2181 | - if ($statusQueryValid && !$queryValid) $queryValid=true; |
|
| 2182 | - if ($queryValid) $imapFilter->andSearch($imapSearchFilter); |
|
| 2552 | + if ($statusQueryValid && !$queryValid) |
|
| 2553 | + { |
|
| 2554 | + $queryValid=true; |
|
| 2555 | + } |
|
| 2556 | + if ($queryValid) |
|
| 2557 | + { |
|
| 2558 | + $imapFilter->andSearch($imapSearchFilter); |
|
| 2559 | + } |
|
| 2183 | 2560 | |
| 2184 | 2561 | if (isset($_criterias['range']) && !empty($_criterias['range'])) |
| 2185 | 2562 | { |
@@ -2194,7 +2571,8 @@ discard block |
||
| 2194 | 2571 | unset($_criterias['before']); |
| 2195 | 2572 | $criteria=$_criterias['range']='ON'; |
| 2196 | 2573 | } |
| 2197 | - switch ($criteria) { |
|
| 2574 | + switch ($criteria) |
|
| 2575 | + { |
|
| 2198 | 2576 | case 'BETWEEN': |
| 2199 | 2577 | //try to be smart about missing |
| 2200 | 2578 | //enddate |
@@ -2230,8 +2608,14 @@ discard block |
||
| 2230 | 2608 | $rangeValid = true; |
| 2231 | 2609 | break; |
| 2232 | 2610 | } |
| 2233 | - if ($rangeValid && !$queryValid) $queryValid=true; |
|
| 2234 | - if ($rangeValid) $imapFilter->andSearch($imapRangeFilter); |
|
| 2611 | + if ($rangeValid && !$queryValid) |
|
| 2612 | + { |
|
| 2613 | + $queryValid=true; |
|
| 2614 | + } |
|
| 2615 | + if ($rangeValid) |
|
| 2616 | + { |
|
| 2617 | + $imapFilter->andSearch($imapRangeFilter); |
|
| 2618 | + } |
|
| 2235 | 2619 | } |
| 2236 | 2620 | if (self::$debug) |
| 2237 | 2621 | { |
@@ -2239,10 +2623,13 @@ discard block |
||
| 2239 | 2623 | $query_str = $imapFilter->build(); |
| 2240 | 2624 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$query_str['query'].' created by Criterias:'.(!is_array($_criterias)?" none -> returning":array2string($_criterias))); |
| 2241 | 2625 | } |
| 2242 | - if($queryValid==false) { |
|
| 2626 | + if($queryValid==false) |
|
| 2627 | + { |
|
| 2243 | 2628 | $imapFilter->flag('DELETED', $set=false); |
| 2244 | 2629 | return $imapFilter; |
| 2245 | - } else { |
|
| 2630 | + } |
|
| 2631 | + else |
|
| 2632 | + { |
|
| 2246 | 2633 | return $imapFilter; |
| 2247 | 2634 | } |
| 2248 | 2635 | } |
@@ -2299,7 +2686,10 @@ discard block |
||
| 2299 | 2686 | } |
| 2300 | 2687 | $stringA[] = imap_rfc822_write_address($_rfcAddr->mailbox,Horde_Idna::decode($_rfcAddr->host),$_rfcAddr->personal); |
| 2301 | 2688 | } |
| 2302 | - if (!empty($stringA)) $_string = implode(',',$stringA); |
|
| 2689 | + if (!empty($stringA)) |
|
| 2690 | + { |
|
| 2691 | + $_string = implode(',',$stringA); |
|
| 2692 | + } |
|
| 2303 | 2693 | } |
| 2304 | 2694 | if ($_tryIDNConversion==='FORCE') |
| 2305 | 2695 | { |
@@ -2324,7 +2714,10 @@ discard block |
||
| 2324 | 2714 | { |
| 2325 | 2715 | return 'No Subject'; |
| 2326 | 2716 | } |
| 2327 | - if ($decode) $_string = self::decode_header($_string); |
|
| 2717 | + if ($decode) |
|
| 2718 | + { |
|
| 2719 | + $_string = self::decode_header($_string); |
|
| 2720 | + } |
|
| 2328 | 2721 | // make sure its utf-8 |
| 2329 | 2722 | $test = @json_encode($_string); |
| 2330 | 2723 | if (($test=="null" || $test === false || is_null($test)) && strlen($_string)>0) |
@@ -2362,7 +2755,8 @@ discard block |
||
| 2362 | 2755 | * @param string _parent the parent foldername |
| 2363 | 2756 | * @return ISO-8859-1 / UTF7-IMAP encoded string |
| 2364 | 2757 | */ |
| 2365 | - function _encodeFolderName($_folderName) { |
|
| 2758 | + function _encodeFolderName($_folderName) |
|
| 2759 | + { |
|
| 2366 | 2760 | return Translation::convert($_folderName, self::$displayCharset, 'ISO-8859-1'); |
| 2367 | 2761 | #return Translation::convert($_folderName, self::$displayCharset, 'UTF7-IMAP'); |
| 2368 | 2762 | } |
@@ -2378,21 +2772,36 @@ discard block |
||
| 2378 | 2772 | */ |
| 2379 | 2773 | function createFolder($_parent, $_folderName, &$_error) |
| 2380 | 2774 | { |
| 2381 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."->"."$_parent, $_folderName called from:".function_backtrace()); |
|
| 2775 | + if (self::$debug) |
|
| 2776 | + { |
|
| 2777 | + error_log(__METHOD__.' ('.__LINE__.') '."->"."$_parent, $_folderName called from:".function_backtrace()); |
|
| 2778 | + } |
|
| 2382 | 2779 | $parent = $_parent;//$this->_encodeFolderName($_parent); |
| 2383 | 2780 | $folderName = $_folderName;//$this->_encodeFolderName($_folderName); |
| 2384 | 2781 | |
| 2385 | - if(empty($parent)) { |
|
| 2782 | + if(empty($parent)) |
|
| 2783 | + { |
|
| 2386 | 2784 | $newFolderName = $folderName; |
| 2387 | - } else { |
|
| 2785 | + } |
|
| 2786 | + else |
|
| 2787 | + { |
|
| 2388 | 2788 | $HierarchyDelimiter = $this->getHierarchyDelimiter(); |
| 2389 | 2789 | $newFolderName = $parent . $HierarchyDelimiter . $folderName; |
| 2390 | 2790 | } |
| 2391 | - if (empty($newFolderName)) return false; |
|
| 2392 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.'->'.$newFolderName); |
|
| 2791 | + if (empty($newFolderName)) |
|
| 2792 | + { |
|
| 2793 | + return false; |
|
| 2794 | + } |
|
| 2795 | + if (self::$debug) |
|
| 2796 | + { |
|
| 2797 | + error_log(__METHOD__.' ('.__LINE__.') '.'->'.$newFolderName); |
|
| 2798 | + } |
|
| 2393 | 2799 | if ($this->folderExists($newFolderName,true)) |
| 2394 | 2800 | { |
| 2395 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '." Folder $newFolderName already exists."); |
|
| 2801 | + if (self::$debug) |
|
| 2802 | + { |
|
| 2803 | + error_log(__METHOD__.' ('.__LINE__.') '." Folder $newFolderName already exists."); |
|
| 2804 | + } |
|
| 2396 | 2805 | return $newFolderName; |
| 2397 | 2806 | } |
| 2398 | 2807 | try |
@@ -2440,13 +2849,19 @@ discard block |
||
| 2440 | 2849 | $parent = $_parent;//$this->_encodeFolderName($_parent); |
| 2441 | 2850 | $folderName = $_folderName;//$this->_encodeFolderName($_folderName); |
| 2442 | 2851 | |
| 2443 | - if(empty($parent)) { |
|
| 2852 | + if(empty($parent)) |
|
| 2853 | + { |
|
| 2444 | 2854 | $newFolderName = $folderName; |
| 2445 | - } else { |
|
| 2855 | + } |
|
| 2856 | + else |
|
| 2857 | + { |
|
| 2446 | 2858 | $HierarchyDelimiter = $this->getHierarchyDelimiter(); |
| 2447 | 2859 | $newFolderName = $parent . $HierarchyDelimiter . $folderName; |
| 2448 | 2860 | } |
| 2449 | - if (self::$debug) error_log("create folder: $newFolderName"); |
|
| 2861 | + if (self::$debug) |
|
| 2862 | + { |
|
| 2863 | + error_log("create folder: $newFolderName"); |
|
| 2864 | + } |
|
| 2450 | 2865 | try |
| 2451 | 2866 | { |
| 2452 | 2867 | $this->icServer->renameMailbox($oldFolderName, $newFolderName); |
@@ -2520,8 +2935,14 @@ discard block |
||
| 2520 | 2935 | */ |
| 2521 | 2936 | function getFolderObjects($_subscribedOnly=false, $_getCounters=false, $_alwaysGetDefaultFolders=false,$_useCacheIfPossible=true) |
| 2522 | 2937 | { |
| 2523 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' ServerID:'.$this->icServer->ImapServerId.", subscribedOnly:$_subscribedOnly, getCounters:$_getCounters, alwaysGetDefaultFolders:$_alwaysGetDefaultFolders, _useCacheIfPossible:$_useCacheIfPossible"); |
|
| 2524 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 2938 | + if (self::$debug) |
|
| 2939 | + { |
|
| 2940 | + error_log(__METHOD__.' ('.__LINE__.') '.' ServerID:'.$this->icServer->ImapServerId.", subscribedOnly:$_subscribedOnly, getCounters:$_getCounters, alwaysGetDefaultFolders:$_alwaysGetDefaultFolders, _useCacheIfPossible:$_useCacheIfPossible"); |
|
| 2941 | + } |
|
| 2942 | + if (self::$debugTimes) |
|
| 2943 | + { |
|
| 2944 | + $starttime = microtime (true); |
|
| 2945 | + } |
|
| 2525 | 2946 | static $folders2return; |
| 2526 | 2947 | //$_subscribedOnly=false; |
| 2527 | 2948 | // always use static on single request if info is available; |
@@ -2529,23 +2950,35 @@ discard block |
||
| 2529 | 2950 | // set $_useCacheIfPossible to false ! |
| 2530 | 2951 | if ($_useCacheIfPossible && isset($folders2return[$this->icServer->ImapServerId]) && !empty($folders2return[$this->icServer->ImapServerId])) |
| 2531 | 2952 | { |
| 2532 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'using static',__METHOD__.' ('.__LINE__.') '); |
|
| 2953 | + if (self::$debugTimes) |
|
| 2954 | + { |
|
| 2955 | + self::logRunTimes($starttime,null,'using static',__METHOD__.' ('.__LINE__.') '); |
|
| 2956 | + } |
|
| 2533 | 2957 | return $folders2return[$this->icServer->ImapServerId]; |
| 2534 | 2958 | } |
| 2535 | 2959 | |
| 2536 | 2960 | if ($_subscribedOnly && $_getCounters===false) |
| 2537 | 2961 | { |
| 2538 | - if (is_null($folders2return)) $folders2return = Cache::getCache(Cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 2962 | + if (is_null($folders2return)) |
|
| 2963 | + { |
|
| 2964 | + $folders2return = Cache::getCache(Cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 2965 | + } |
|
| 2539 | 2966 | if ($_useCacheIfPossible && isset($folders2return[$this->icServer->ImapServerId]) && !empty($folders2return[$this->icServer->ImapServerId])) |
| 2540 | 2967 | { |
| 2541 | 2968 | //error_log(__METHOD__.' ('.__LINE__.') '.' using Cached folderObjects'.array2string($folders2return[$this->icServer->ImapServerId])); |
| 2542 | - if (self::$debugTimes) self::logRunTimes($starttime,null,'from Cache',__METHOD__.' ('.__LINE__.') '); |
|
| 2969 | + if (self::$debugTimes) |
|
| 2970 | + { |
|
| 2971 | + self::logRunTimes($starttime,null,'from Cache',__METHOD__.' ('.__LINE__.') '); |
|
| 2972 | + } |
|
| 2543 | 2973 | return $folders2return[$this->icServer->ImapServerId]; |
| 2544 | 2974 | } |
| 2545 | 2975 | } |
| 2546 | 2976 | // use $folderBasicInfo for holding attributes and other basic folderinfo $folderBasicInfo[$this->icServer->ImapServerId] |
| 2547 | 2977 | static $folderBasicInfo; |
| 2548 | - 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); |
|
| 2978 | + if (is_null($folderBasicInfo)||!isset($folderBasicInfo[$this->icServer->ImapServerId])) |
|
| 2979 | + { |
|
| 2980 | + $folderBasicInfo = Cache::getCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 2981 | + } |
|
| 2549 | 2982 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string(array_keys($folderBasicInfo[$this->icServer->ImapServerId]))); |
| 2550 | 2983 | |
| 2551 | 2984 | $delimiter = $this->getHierarchyDelimiter(); |
@@ -2558,7 +2991,8 @@ discard block |
||
| 2558 | 2991 | $inboxData->shortFolderName = 'INBOX'; |
| 2559 | 2992 | $inboxData->shortDisplayName = lang('INBOX'); |
| 2560 | 2993 | $inboxData->subscribed = true; |
| 2561 | - if($_getCounters == true) { |
|
| 2994 | + if($_getCounters == true) |
|
| 2995 | + { |
|
| 2562 | 2996 | $inboxData->counter = $this->getMailBoxCounters('INBOX'); |
| 2563 | 2997 | } |
| 2564 | 2998 | // force unsubscribed by preference showAllFoldersInFolderPane |
@@ -2577,12 +3011,14 @@ discard block |
||
| 2577 | 3011 | //error_log(__METHOD__.__LINE__.array2string($nameSpace)); |
| 2578 | 3012 | if (is_array($nameSpace)) |
| 2579 | 3013 | { |
| 2580 | - foreach($nameSpace as $k => $singleNameSpace) { |
|
| 3014 | + foreach($nameSpace as $k => $singleNameSpace) |
|
| 3015 | + { |
|
| 2581 | 3016 | $type = $singleNameSpace['type']; |
| 2582 | 3017 | // the following line (assumption that for the same namespace the delimiter should be equal) may be wrong |
| 2583 | 3018 | $foldersNameSpace[$type]['delimiter'] = $singleNameSpace['delimiter']; |
| 2584 | 3019 | |
| 2585 | - if(is_array($singleNameSpace)&&$fetchedAllInOneGo==false) { |
|
| 3020 | + if(is_array($singleNameSpace)&&$fetchedAllInOneGo==false) |
|
| 3021 | + { |
|
| 2586 | 3022 | // fetch and sort the subscribed folders |
| 2587 | 3023 | // we alway fetch the subscribed, as this provides the only way to tell |
| 2588 | 3024 | // if a folder is subscribed or not |
@@ -2633,8 +3069,12 @@ discard block |
||
| 2633 | 3069 | } |
| 2634 | 3070 | } |
| 2635 | 3071 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$type.'->'.array2string($foldersNameSpace[$type]['subscribed'])); |
| 2636 | - if (!is_array($foldersNameSpace[$type]['all'])) $foldersNameSpace[$type]['all'] = array(); |
|
| 2637 | - if ($_subscribedOnly == true && !empty($foldersNameSpace[$type]['subscribed'])) { |
|
| 3072 | + if (!is_array($foldersNameSpace[$type]['all'])) |
|
| 3073 | + { |
|
| 3074 | + $foldersNameSpace[$type]['all'] = array(); |
|
| 3075 | + } |
|
| 3076 | + if ($_subscribedOnly == true && !empty($foldersNameSpace[$type]['subscribed'])) |
|
| 3077 | + { |
|
| 2638 | 3078 | continue; |
| 2639 | 3079 | } |
| 2640 | 3080 | |
@@ -2664,7 +3104,8 @@ discard block |
||
| 2664 | 3104 | } |
| 2665 | 3105 | |
| 2666 | 3106 | //error_log(__METHOD__.' ('.__LINE__.') '.' '.$type.'->'.array2string($allMailboxesExt)); |
| 2667 | - foreach ($allMailboxesExt as $mbx) { |
|
| 3107 | + foreach ($allMailboxesExt as $mbx) |
|
| 3108 | + { |
|
| 2668 | 3109 | if (!isset($folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']])) |
| 2669 | 3110 | { |
| 2670 | 3111 | $folderBasicInfo[$this->icServer->ImapServerId][$mbx['MAILBOX']]=array( |
@@ -2687,20 +3128,33 @@ discard block |
||
| 2687 | 3128 | if (isset($allMailBoxesExtSorted[$mbx['MAILBOX']])|| |
| 2688 | 3129 | isset($allMailBoxesExtSorted[$mbx['MAILBOX'].$foldersNameSpace[$type]['delimiter']])|| |
| 2689 | 3130 | (substr($mbx['MAILBOX'],-1)==$foldersNameSpace[$type]['delimiter'] && isset($allMailBoxesExtSorted[substr($mbx['MAILBOX'],0,-1)])) |
| 2690 | - ) continue; |
|
| 3131 | + ) |
|
| 3132 | + { |
|
| 3133 | + continue; |
|
| 3134 | + } |
|
| 2691 | 3135 | |
| 2692 | 3136 | //echo '#'.$mbx['MAILBOX'].':'.array2string($mbx)."#<br>"; |
| 2693 | 3137 | $allMailBoxesExtSorted[$mbx['MAILBOX']] = $mbx; |
| 2694 | 3138 | } |
| 2695 | - if (is_array($allMailBoxesExtSorted)) ksort($allMailBoxesExtSorted); |
|
| 3139 | + if (is_array($allMailBoxesExtSorted)) |
|
| 3140 | + { |
|
| 3141 | + ksort($allMailBoxesExtSorted); |
|
| 3142 | + } |
|
| 2696 | 3143 | //_debug_array(array_keys($allMailBoxesExtSorted)); |
| 2697 | 3144 | $allMailboxes = array(); |
| 2698 | - foreach ((array)$allMailBoxesExtSorted as $mbx) { |
|
| 2699 | - if (!in_array($mbx['MAILBOX'],$allMailboxes)) $allMailboxes[] = $mbx['MAILBOX']; |
|
| 3145 | + foreach ((array)$allMailBoxesExtSorted as $mbx) |
|
| 3146 | + { |
|
| 3147 | + if (!in_array($mbx['MAILBOX'],$allMailboxes)) |
|
| 3148 | + { |
|
| 3149 | + $allMailboxes[] = $mbx['MAILBOX']; |
|
| 3150 | + } |
|
| 2700 | 3151 | //echo "Result:";_debug_array($allMailboxes); |
| 2701 | 3152 | } |
| 2702 | 3153 | $foldersNameSpace[$type]['all'] = $allMailboxes; |
| 2703 | - if (is_array($foldersNameSpace[$type]['all'])) sort($foldersNameSpace[$type]['all']); |
|
| 3154 | + if (is_array($foldersNameSpace[$type]['all'])) |
|
| 3155 | + { |
|
| 3156 | + sort($foldersNameSpace[$type]['all']); |
|
| 3157 | + } |
|
| 2704 | 3158 | } |
| 2705 | 3159 | } |
| 2706 | 3160 | } |
@@ -2709,24 +3163,50 @@ discard block |
||
| 2709 | 3163 | //echo "<br>FolderNameSpace To Process:";_debug_array($foldersNameSpace); |
| 2710 | 3164 | $autoFolderObjects = $folders = array(); |
| 2711 | 3165 | $autofolder_exists = array(); |
| 2712 | - foreach( array('personal', 'others', 'shared') as $type) { |
|
| 2713 | - if(isset($foldersNameSpace[$type])) { |
|
| 2714 | - if($_subscribedOnly) { |
|
| 2715 | - if( !empty($foldersNameSpace[$type]['subscribed']) ) $listOfFolders = $foldersNameSpace[$type]['subscribed']; |
|
| 2716 | - } else { |
|
| 2717 | - if( !empty($foldersNameSpace[$type]['all'])) $listOfFolders = $foldersNameSpace[$type]['all']; |
|
| 2718 | - } |
|
| 2719 | - foreach((array)$listOfFolders as $folderName) { |
|
| 3166 | + foreach( array('personal', 'others', 'shared') as $type) |
|
| 3167 | + { |
|
| 3168 | + if(isset($foldersNameSpace[$type])) |
|
| 3169 | + { |
|
| 3170 | + if($_subscribedOnly) |
|
| 3171 | + { |
|
| 3172 | + if( !empty($foldersNameSpace[$type]['subscribed']) ) |
|
| 3173 | + { |
|
| 3174 | + $listOfFolders = $foldersNameSpace[$type]['subscribed']; |
|
| 3175 | + } |
|
| 3176 | + } |
|
| 3177 | + else |
|
| 3178 | + { |
|
| 3179 | + if( !empty($foldersNameSpace[$type]['all'])) |
|
| 3180 | + { |
|
| 3181 | + $listOfFolders = $foldersNameSpace[$type]['all']; |
|
| 3182 | + } |
|
| 3183 | + } |
|
| 3184 | + foreach((array)$listOfFolders as $folderName) |
|
| 3185 | + { |
|
| 2720 | 3186 | //echo "<br>FolderToCheck:$folderName<br>"; |
| 2721 | 3187 | //error_log(__METHOD__.__LINE__.'#Delimiter:'.$delimiter.':#'.$folderName); |
| 2722 | - if ($_subscribedOnly && empty($foldersNameSpace[$type]['all'])) continue;//when subscribedonly, we fetch all folders in one go. |
|
| 2723 | - if($_subscribedOnly && !(in_array($folderName, $foldersNameSpace[$type]['all'])||in_array($folderName.$foldersNameSpace[$type]['delimiter'], $foldersNameSpace[$type]['all']))) { |
|
| 3188 | + if ($_subscribedOnly && empty($foldersNameSpace[$type]['all'])) |
|
| 3189 | + { |
|
| 3190 | + continue; |
|
| 3191 | + } |
|
| 3192 | + //when subscribedonly, we fetch all folders in one go. |
|
| 3193 | + if($_subscribedOnly && !(in_array($folderName, $foldersNameSpace[$type]['all'])||in_array($folderName.$foldersNameSpace[$type]['delimiter'], $foldersNameSpace[$type]['all']))) |
|
| 3194 | + { |
|
| 2724 | 3195 | #echo "$folderName failed to be here <br>"; |
| 2725 | 3196 | continue; |
| 2726 | 3197 | } |
| 2727 | - if (isset($folders[$folderName])) continue; |
|
| 2728 | - if (isset($autoFolderObjects[$folderName])) continue; |
|
| 2729 | - if (empty($delimiter)||$delimiter != $foldersNameSpace[$type]['delimiter']) $delimiter = $foldersNameSpace[$type]['delimiter']; |
|
| 3198 | + if (isset($folders[$folderName])) |
|
| 3199 | + { |
|
| 3200 | + continue; |
|
| 3201 | + } |
|
| 3202 | + if (isset($autoFolderObjects[$folderName])) |
|
| 3203 | + { |
|
| 3204 | + continue; |
|
| 3205 | + } |
|
| 3206 | + if (empty($delimiter)||$delimiter != $foldersNameSpace[$type]['delimiter']) |
|
| 3207 | + { |
|
| 3208 | + $delimiter = $foldersNameSpace[$type]['delimiter']; |
|
| 3209 | + } |
|
| 2730 | 3210 | $folderParts = explode($delimiter, $folderName); |
| 2731 | 3211 | $shortName = array_pop($folderParts); |
| 2732 | 3212 | |
@@ -2734,17 +3214,20 @@ discard block |
||
| 2734 | 3214 | $folderObject->delimiter = $delimiter; |
| 2735 | 3215 | $folderObject->folderName = $folderName; |
| 2736 | 3216 | $folderObject->shortFolderName = $shortName; |
| 2737 | - if(!$_subscribedOnly) { |
|
| 3217 | + if(!$_subscribedOnly) |
|
| 3218 | + { |
|
| 2738 | 3219 | #echo $folderName."->".$type."<br>"; |
| 2739 | 3220 | #_debug_array($foldersNameSpace[$type]['subscribed']); |
| 2740 | 3221 | $folderObject->subscribed = in_array($folderName, (array)$foldersNameSpace[$type]['subscribed']); |
| 2741 | 3222 | } |
| 2742 | 3223 | |
| 2743 | - if($_getCounters == true) { |
|
| 3224 | + if($_getCounters == true) |
|
| 3225 | + { |
|
| 2744 | 3226 | //error_log(__METHOD__.' ('.__LINE__.') '.' getCounter forFolder:'.$folderName); |
| 2745 | 3227 | $folderObject->counter = $this->getMailBoxCounters($folderName); |
| 2746 | 3228 | } |
| 2747 | - if(strtoupper($folderName) == 'INBOX') { |
|
| 3229 | + if(strtoupper($folderName) == 'INBOX') |
|
| 3230 | + { |
|
| 2748 | 3231 | $folderName = 'INBOX'; |
| 2749 | 3232 | $folderObject->folderName = 'INBOX'; |
| 2750 | 3233 | $folderObject->shortFolderName = 'INBOX'; |
@@ -2752,24 +3235,34 @@ discard block |
||
| 2752 | 3235 | $folderObject->shortDisplayName = lang('INBOX'); |
| 2753 | 3236 | $folderObject->subscribed = true; |
| 2754 | 3237 | // translate the automatic Folders (Sent, Drafts, ...) like the INBOX |
| 2755 | - } elseif (in_array($shortName,self::$autoFolders)) { |
|
| 3238 | + } |
|
| 3239 | + elseif (in_array($shortName,self::$autoFolders)) |
|
| 3240 | + { |
|
| 2756 | 3241 | $tmpfolderparts = explode($delimiter,$folderObject->folderName); |
| 2757 | 3242 | array_pop($tmpfolderparts); |
| 2758 | 3243 | $folderObject->displayName = implode($delimiter,$tmpfolderparts).$delimiter.lang($shortName); |
| 2759 | 3244 | $folderObject->shortDisplayName = lang($shortName); |
| 2760 | 3245 | unset($tmpfolderparts); |
| 2761 | - } else { |
|
| 3246 | + } |
|
| 3247 | + else |
|
| 3248 | + { |
|
| 2762 | 3249 | $folderObject->displayName = $folderObject->folderName; |
| 2763 | 3250 | $folderObject->shortDisplayName = $shortName; |
| 2764 | 3251 | } |
| 2765 | 3252 | //$folderName = $folderName; |
| 2766 | - if (in_array($shortName,self::$autoFolders)&&self::searchValueInFolderObjects($shortName,$autoFolderObjects)===false) { |
|
| 3253 | + if (in_array($shortName,self::$autoFolders)&&self::searchValueInFolderObjects($shortName,$autoFolderObjects)===false) |
|
| 3254 | + { |
|
| 2767 | 3255 | $autoFolderObjects[$folderName] = $folderObject; |
| 2768 | - } else { |
|
| 3256 | + } |
|
| 3257 | + else |
|
| 3258 | + { |
|
| 2769 | 3259 | $folders[$folderName] = $folderObject; |
| 2770 | 3260 | } |
| 2771 | 3261 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$folderObject->folderName); |
| 2772 | - if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders (); |
|
| 3262 | + if (!isset(self::$specialUseFolders)) |
|
| 3263 | + { |
|
| 3264 | + $this->getSpecialUseFolders (); |
|
| 3265 | + } |
|
| 2773 | 3266 | if (isset(self::$specialUseFolders[$folderName])) |
| 2774 | 3267 | { |
| 2775 | 3268 | $autofolder_exists[$folderName] = self::$specialUseFolders[$folderName]; |
@@ -2777,7 +3270,8 @@ discard block |
||
| 2777 | 3270 | } |
| 2778 | 3271 | } |
| 2779 | 3272 | } |
| 2780 | - if (is_array($autoFolderObjects) && !empty($autoFolderObjects)) { |
|
| 3273 | + if (is_array($autoFolderObjects) && !empty($autoFolderObjects)) |
|
| 3274 | + { |
|
| 2781 | 3275 | uasort($autoFolderObjects,array($this,"sortByAutoFolderPos")); |
| 2782 | 3276 | } |
| 2783 | 3277 | // check if some standard folders are missing and need to be created |
@@ -2786,7 +3280,10 @@ discard block |
||
| 2786 | 3280 | // if new folders have been created, re-read folders ignoring the cache |
| 2787 | 3281 | return $this->getFolderObjects($_subscribedOnly, $_getCounters, $_alwaysGetDefaultFolders, false); // false = do NOT use cache |
| 2788 | 3282 | } |
| 2789 | - if (is_array($folders)) uasort($folders,array($this,"sortByDisplayName")); |
|
| 3283 | + if (is_array($folders)) |
|
| 3284 | + { |
|
| 3285 | + uasort($folders,array($this,"sortByDisplayName")); |
|
| 3286 | + } |
|
| 2790 | 3287 | //$folders2return = array_merge($autoFolderObjects,$folders); |
| 2791 | 3288 | //_debug_array($folders2return); #exit; |
| 2792 | 3289 | $folders2return[$this->icServer->ImapServerId] = array_merge((array)$inboxFolderObject,(array)$autoFolderObjects,(array)$folders); |
@@ -2798,7 +3295,10 @@ discard block |
||
| 2798 | 3295 | Cache::setCache(Cache::INSTANCE,'email','folderObjects'.trim($GLOBALS['egw_info']['user']['account_id']),$folders2return,$expiration=60*60*1); |
| 2799 | 3296 | } |
| 2800 | 3297 | Cache::setCache(Cache::INSTANCE,'email','folderBasicInfo'.trim($GLOBALS['egw_info']['user']['account_id']),$folderBasicInfo,$expiration=60*60*1); |
| 2801 | - if (self::$debugTimes) self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') '); |
|
| 3298 | + if (self::$debugTimes) |
|
| 3299 | + { |
|
| 3300 | + self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') '); |
|
| 3301 | + } |
|
| 2802 | 3302 | return $folders2return[$this->icServer->ImapServerId]; |
| 2803 | 3303 | } |
| 2804 | 3304 | |
@@ -2826,31 +3326,44 @@ discard block |
||
| 2826 | 3326 | |
| 2827 | 3327 | $folders = $nameSpace = array(); |
| 2828 | 3328 | $nameSpaceTmp = $this->_getNameSpaces(); |
| 2829 | - foreach($nameSpaceTmp as $k => $singleNameSpace) { |
|
| 3329 | + foreach($nameSpaceTmp as $k => $singleNameSpace) |
|
| 3330 | + { |
|
| 2830 | 3331 | $nameSpace[$singleNameSpace['type']]=$singleNameSpace; |
| 2831 | 3332 | } |
| 2832 | 3333 | unset($nameSpaceTmp); |
| 2833 | 3334 | |
| 2834 | 3335 | //error_log(__METHOD__.__LINE__.array2string($nameSpace)); |
| 2835 | 3336 | // Get special use folders |
| 2836 | - if (!isset(self::$specialUseFolders)) $this->getSpecialUseFolders (); // Set self::$specialUseFolders |
|
| 3337 | + if (!isset(self::$specialUseFolders)) |
|
| 3338 | + { |
|
| 3339 | + $this->getSpecialUseFolders (); |
|
| 3340 | + } |
|
| 3341 | + // Set self::$specialUseFolders |
|
| 2837 | 3342 | // topLevelQueries generally ignore the $_search param. Except for Config::examineNamespace |
| 2838 | - if ($_onlyTopLevel) // top level leaves |
|
| 3343 | + if ($_onlyTopLevel) |
|
| 3344 | + { |
|
| 3345 | + // top level leaves |
|
| 2839 | 3346 | { |
| 2840 | 3347 | // Get top mailboxes of icServer |
| 2841 | 3348 | $topFolders = $this->icServer->getMailboxes("", 2, true); |
| 3349 | + } |
|
| 2842 | 3350 | // Trigger examination of namespace to retrieve |
| 2843 | 3351 | // folders located in other and shared; needed only for some servers |
| 2844 | - if (is_null(self::$mailConfig)) self::$mailConfig = Config::read('mail'); |
|
| 3352 | + if (is_null(self::$mailConfig)) |
|
| 3353 | + { |
|
| 3354 | + self::$mailConfig = Config::read('mail'); |
|
| 3355 | + } |
|
| 2845 | 3356 | if (self::$mailConfig['examineNamespace']) |
| 2846 | 3357 | { |
| 2847 | 3358 | $prefixes=array(); |
| 2848 | 3359 | if (is_array($nameSpace)) |
| 2849 | 3360 | { |
| 2850 | - foreach($nameSpace as $k => $singleNameSpace) { |
|
| 3361 | + foreach($nameSpace as $k => $singleNameSpace) |
|
| 3362 | + { |
|
| 2851 | 3363 | $type = $singleNameSpace['type']; |
| 2852 | 3364 | |
| 2853 | - if(is_array($singleNameSpace) && $singleNameSpace['prefix']){ |
|
| 3365 | + if(is_array($singleNameSpace) && $singleNameSpace['prefix']) |
|
| 3366 | + { |
|
| 2854 | 3367 | $prefixes[$type] = $singleNameSpace['prefix']; |
| 2855 | 3368 | //regard extra care for nameSpacequeries when configured AND respect $_search |
| 2856 | 3369 | $result = $this->icServer->getMailboxes($singleNameSpace['prefix'], $_search==0?0:2, true); |
@@ -2926,7 +3439,10 @@ discard block |
||
| 2926 | 3439 | $nFolders [$path] = $folder; |
| 2927 | 3440 | } |
| 2928 | 3441 | } |
| 2929 | - if (is_array($aFolders)) uasort ($aFolders, array($this,'sortByAutofolder')); |
|
| 3442 | + if (is_array($aFolders)) |
|
| 3443 | + { |
|
| 3444 | + uasort ($aFolders, array($this,'sortByAutofolder')); |
|
| 3445 | + } |
|
| 2930 | 3446 | //ksort($aFolders); |
| 2931 | 3447 | |
| 2932 | 3448 | // Sort none auto folders base on mailbox name |
@@ -2936,12 +3452,17 @@ discard block |
||
| 2936 | 3452 | } |
| 2937 | 3453 | else |
| 2938 | 3454 | { |
| 2939 | - if (is_array($subFolders)) ksort($subFolders); |
|
| 3455 | + if (is_array($subFolders)) |
|
| 3456 | + { |
|
| 3457 | + ksort($subFolders); |
|
| 3458 | + } |
|
| 2940 | 3459 | } |
| 2941 | 3460 | $folders = array_merge($folders,(array)$mainFolder, (array)$subFolders); |
| 2942 | 3461 | } |
| 2943 | 3462 | } |
| 2944 | - elseif ($_nodePath) // single node |
|
| 3463 | + elseif ($_nodePath) |
|
| 3464 | + { |
|
| 3465 | + // single node |
|
| 2945 | 3466 | { |
| 2946 | 3467 | switch ($_search) |
| 2947 | 3468 | { |
@@ -2949,6 +3470,7 @@ discard block |
||
| 2949 | 3470 | case 0: |
| 2950 | 3471 | case 2: |
| 2951 | 3472 | $path = $_nodePath.''.$delimiter; |
| 3473 | + } |
|
| 2952 | 3474 | break; |
| 2953 | 3475 | // Node itself |
| 2954 | 3476 | // shouldn't contain next level delimiter |
@@ -2967,11 +3489,14 @@ discard block |
||
| 2967 | 3489 | |
| 2968 | 3490 | uasort($folders,array($this,'sortByMailbox'));//ksort($folders); |
| 2969 | 3491 | } |
| 2970 | - elseif(!$_nodePath) // all |
|
| 3492 | + elseif(!$_nodePath) |
|
| 3493 | + { |
|
| 3494 | + // all |
|
| 2971 | 3495 | { |
| 2972 | 3496 | if ($_subscribedOnly) |
| 2973 | 3497 | { |
| 2974 | 3498 | $folders = $this->icServer->listSubscribedMailboxes('', 0, true); |
| 3499 | + } |
|
| 2975 | 3500 | } |
| 2976 | 3501 | else |
| 2977 | 3502 | { |
@@ -2983,7 +3508,10 @@ discard block |
||
| 2983 | 3508 | { |
| 2984 | 3509 | // SORTING FOLDERS |
| 2985 | 3510 | //self::$debugTimes=true; |
| 2986 | - if (self::$debugTimes) $starttime = microtime (true); |
|
| 3511 | + if (self::$debugTimes) |
|
| 3512 | + { |
|
| 3513 | + $starttime = microtime (true); |
|
| 3514 | + } |
|
| 2987 | 3515 | // Merge of all auto folders and specialusefolders |
| 2988 | 3516 | $autoFoldersTmp = array_unique((array_merge(self::$autoFolders, array_values(self::$specialUseFolders)))); |
| 2989 | 3517 | uasort($folders,array($this,'sortByMailbox'));//ksort($folders); |
@@ -2993,73 +3521,103 @@ discard block |
||
| 2993 | 3521 | $isGoogleMail=false; |
| 2994 | 3522 | foreach($autoFoldersTmp as $afk=>$aF) |
| 2995 | 3523 | { |
| 2996 | - if (!isset($mySpecialUseFolders[$aF]) && $aF) $mySpecialUseFolders[$aF]=$this->getFolderByType($aF,false); |
|
| 3524 | + if (!isset($mySpecialUseFolders[$aF]) && $aF) |
|
| 3525 | + { |
|
| 3526 | + $mySpecialUseFolders[$aF]=$this->getFolderByType($aF,false); |
|
| 3527 | + } |
|
| 2997 | 3528 | //error_log($afk.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 2998 | 3529 | } |
| 2999 | 3530 | //error_log(array2string($mySpecialUseFolders)); |
| 3000 | - foreach ($tmpFolders as $k => $f) { |
|
| 3531 | + foreach ($tmpFolders as $k => $f) |
|
| 3532 | + { |
|
| 3001 | 3533 | $sorted=false; |
| 3002 | - if (strtoupper(substr($k,0,5))=='INBOX') { |
|
| 3003 | - if (strtoupper($k)=='INBOX') { |
|
| 3534 | + if (strtoupper(substr($k,0,5))=='INBOX') |
|
| 3535 | + { |
|
| 3536 | + if (strtoupper($k)=='INBOX') |
|
| 3537 | + { |
|
| 3004 | 3538 | //error_log(__METHOD__.__LINE__.':'.strtoupper(substr($k,0,5)).':'.$k); |
| 3005 | 3539 | $inboxFolderObject[$k]=$f; |
| 3006 | 3540 | unset($folders[$k]); |
| 3007 | 3541 | $sorted=true; |
| 3008 | - } else { |
|
| 3542 | + } |
|
| 3543 | + else |
|
| 3544 | + { |
|
| 3009 | 3545 | $isAutoFolder=false; |
| 3010 | 3546 | foreach($autoFoldersTmp as $afk=>$aF) |
| 3011 | 3547 | { |
| 3012 | 3548 | //error_log(__METHOD__.__LINE__.$k.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 3013 | 3549 | if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
| 3014 | 3550 | ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter || //k may be child of an autofolder |
| 3015 | - stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder |
|
| 3551 | + stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) |
|
| 3552 | + { |
|
| 3553 | + // k is parent of an autofolder |
|
| 3016 | 3554 | { |
| 3017 | 3555 | //error_log(__METHOD__.__LINE__.$k.'->'.$mySpecialUseFolders[$aF]); |
| 3018 | 3556 | $isAutoFolder=true; |
| 3557 | + } |
|
| 3019 | 3558 | $autoFolderObjects[$k]=$f; |
| 3020 | 3559 | break; |
| 3021 | 3560 | } |
| 3022 | 3561 | } |
| 3023 | - if ($isAutoFolder==false) $inboxSubFolderObjects[$k]=$f; |
|
| 3562 | + if ($isAutoFolder==false) |
|
| 3563 | + { |
|
| 3564 | + $inboxSubFolderObjects[$k]=$f; |
|
| 3565 | + } |
|
| 3024 | 3566 | unset($folders[$k]); |
| 3025 | 3567 | $sorted=true; |
| 3026 | 3568 | } |
| 3027 | - } elseif (strtoupper(substr($k,0,13))=='[GOOGLE MAIL]') { |
|
| 3569 | + } |
|
| 3570 | + elseif (strtoupper(substr($k,0,13))=='[GOOGLE MAIL]') |
|
| 3571 | + { |
|
| 3028 | 3572 | $isGoogleMail=true; |
| 3029 | - if (strtoupper($k)=='[GOOGLE MAIL]') { |
|
| 3573 | + if (strtoupper($k)=='[GOOGLE MAIL]') |
|
| 3574 | + { |
|
| 3030 | 3575 | $googleMailFolderObject[$k]=$f; |
| 3031 | 3576 | unset($folders[$k]); |
| 3032 | 3577 | $sorted=true; |
| 3033 | - } else { |
|
| 3578 | + } |
|
| 3579 | + else |
|
| 3580 | + { |
|
| 3034 | 3581 | $isAutoFolder=false; |
| 3035 | 3582 | foreach($autoFoldersTmp as $afk=>$aF) |
| 3036 | 3583 | { |
| 3037 | 3584 | //error_log($k.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 3038 | 3585 | if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
| 3039 | 3586 | ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter|| //k may be child of an autofolder |
| 3040 | - stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder |
|
| 3587 | + stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) |
|
| 3588 | + { |
|
| 3589 | + // k is parent of an autofolder |
|
| 3041 | 3590 | { |
| 3042 | 3591 | //error_log($k.'->'.$mySpecialUseFolders[$aF]); |
| 3043 | 3592 | $isAutoFolder=true; |
| 3593 | + } |
|
| 3044 | 3594 | $googleAutoFolderObjects[$k]=$f; |
| 3045 | 3595 | break; |
| 3046 | 3596 | } |
| 3047 | 3597 | } |
| 3048 | - if ($isAutoFolder==false) $googleSubFolderObjects[$k]=$f; |
|
| 3598 | + if ($isAutoFolder==false) |
|
| 3599 | + { |
|
| 3600 | + $googleSubFolderObjects[$k]=$f; |
|
| 3601 | + } |
|
| 3049 | 3602 | unset($folders[$k]); |
| 3050 | 3603 | $sorted=true; |
| 3051 | 3604 | } |
| 3052 | - } else { |
|
| 3605 | + } |
|
| 3606 | + else |
|
| 3607 | + { |
|
| 3053 | 3608 | $isAutoFolder=false; |
| 3054 | 3609 | foreach($autoFoldersTmp as $afk=>$aF) |
| 3055 | 3610 | { |
| 3056 | 3611 | //error_log($k.':'.$aF.'->'.$mySpecialUseFolders[$aF]); |
| 3057 | 3612 | if($aF && strlen($mySpecialUseFolders[$aF])&&/*strlen($k)>=strlen($mySpecialUseFolders[$aF])&&*/ |
| 3058 | 3613 | ($mySpecialUseFolders[$aF]==$k || substr($k,0,strlen($mySpecialUseFolders[$aF].$delimiter))==$mySpecialUseFolders[$aF].$delimiter|| //k may be child of an autofolder |
| 3059 | - stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) // k is parent of an autofolder |
|
| 3614 | + stristr($mySpecialUseFolders[$aF],$k.$delimiter)!==false)) |
|
| 3615 | + { |
|
| 3616 | + // k is parent of an autofolder |
|
| 3060 | 3617 | { |
| 3061 | 3618 | //error_log($k.'->'.$mySpecialUseFolders[$aF]); |
| 3062 | 3619 | $isAutoFolder=true; |
| 3620 | + } |
|
| 3063 | 3621 | $autoFolderObjects[$k]=$f; |
| 3064 | 3622 | unset($folders[$k]); |
| 3065 | 3623 | $sorted=true; |
@@ -3075,7 +3633,8 @@ discard block |
||
| 3075 | 3633 | if ($nameSpace[$type]['prefix_present']&&$nameSpace[$type]['prefix']) |
| 3076 | 3634 | { |
| 3077 | 3635 | if (substr($k,0,strlen($nameSpace[$type]['prefix']))==$nameSpace[$type]['prefix']|| |
| 3078 | - substr($k,0,strlen($nameSpace[$type]['prefix'])-strlen($nameSpace[$type]['delimiter']))==substr($nameSpace[$type]['prefix'],0,strlen($nameSpace[$type]['delimiter'])*-1)) { |
|
| 3636 | + substr($k,0,strlen($nameSpace[$type]['prefix'])-strlen($nameSpace[$type]['delimiter']))==substr($nameSpace[$type]['prefix'],0,strlen($nameSpace[$type]['delimiter'])*-1)) |
|
| 3637 | + { |
|
| 3079 | 3638 | //error_log(__METHOD__.__LINE__.':'.substr($k,0,strlen($nameSpace[$type]['prefix'])).':'.$k); |
| 3080 | 3639 | $typeFolderObject[$type][$k]=$f; |
| 3081 | 3640 | unset($folders[$k]); |
@@ -3102,9 +3661,12 @@ discard block |
||
| 3102 | 3661 | } |
| 3103 | 3662 | } |
| 3104 | 3663 | //error_log(__METHOD__.__LINE__.array2string($autoFolderObjects)); |
| 3105 | - if (!$isGoogleMail) { |
|
| 3664 | + if (!$isGoogleMail) |
|
| 3665 | + { |
|
| 3106 | 3666 | $folders = array_merge($inboxFolderObject,$autoFolderObjects,(array)$inboxSubFolderObjects,(array)$folders,(array)$typeFolderObject['others'],(array)$typeFolderObject['shared']); |
| 3107 | - } else { |
|
| 3667 | + } |
|
| 3668 | + else |
|
| 3669 | + { |
|
| 3108 | 3670 | // avoid calling sortByAutoFolder as it is not regarding subfolders |
| 3109 | 3671 | $gAutoFolderObjectsTmp = $googleAutoFolderObjects; |
| 3110 | 3672 | unset($googleAutoFolderObjects); |
@@ -3121,7 +3683,10 @@ discard block |
||
| 3121 | 3683 | } |
| 3122 | 3684 | $folders = array_merge($inboxFolderObject,$autoFolderObjects,(array)$folders,(array)$googleMailFolderObject,$googleAutoFolderObjects,$googleSubFolderObjects,(array)$typeFolderObject['others'],(array)$typeFolderObject['shared']); |
| 3123 | 3685 | } |
| 3124 | - if (self::$debugTimes) self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') Sorting:'); |
|
| 3686 | + if (self::$debugTimes) |
|
| 3687 | + { |
|
| 3688 | + self::logRunTimes($starttime,null,function_backtrace(),__METHOD__.' ('.__LINE__.') Sorting:'); |
|
| 3689 | + } |
|
| 3125 | 3690 | //self::$debugTimes=false; |
| 3126 | 3691 | } |
| 3127 | 3692 | // Get counter information and add them to each fetched folders array |
@@ -3171,7 +3736,13 @@ discard block |
||
| 3171 | 3736 | $rv = false; |
| 3172 | 3737 | foreach ($haystack as $k => $v) |
| 3173 | 3738 | { |
| 3174 | - foreach($v as &$sv) {if (trim($sv)==trim($needle)) return $k;} |
|
| 3739 | + foreach($v as &$sv) |
|
| 3740 | + { |
|
| 3741 | +if (trim($sv)==trim($needle)) |
|
| 3742 | + { |
|
| 3743 | + return $k; |
|
| 3744 | + } |
|
| 3745 | + } |
|
| 3175 | 3746 | } |
| 3176 | 3747 | return $rv; |
| 3177 | 3748 | } |
@@ -3198,7 +3769,10 @@ discard block |
||
| 3198 | 3769 | */ |
| 3199 | 3770 | static function pathToFolderData ($_path, $_hDelimiter) |
| 3200 | 3771 | { |
| 3201 | - if (!strpos($_path, self::DELIMITER)) $_path = self::DELIMITER.$_path; |
|
| 3772 | + if (!strpos($_path, self::DELIMITER)) |
|
| 3773 | + { |
|
| 3774 | + $_path = self::DELIMITER.$_path; |
|
| 3775 | + } |
|
| 3202 | 3776 | list(,$path) = explode(self::DELIMITER, $_path); |
| 3203 | 3777 | $path_chain = $parts = explode($_hDelimiter, $path); |
| 3204 | 3778 | $name = array_pop($parts); |
@@ -3227,7 +3801,10 @@ discard block |
||
| 3227 | 3801 | $b = self::pathToFolderData($_b['MAILBOX'], $_b['delimiter']); |
| 3228 | 3802 | $pos1 = array_search(trim($a['name']),self::$autoFolders); |
| 3229 | 3803 | $pos2 = array_search(trim($b['name']),self::$autoFolders); |
| 3230 | - if ($pos1 == $pos2) return 0; |
|
| 3804 | + if ($pos1 == $pos2) |
|
| 3805 | + { |
|
| 3806 | + return 0; |
|
| 3807 | + } |
|
| 3231 | 3808 | return ($pos1 < $pos2) ? -1 : 1; |
| 3232 | 3809 | } |
| 3233 | 3810 | |
@@ -3258,7 +3835,10 @@ discard block |
||
| 3258 | 3835 | // 0, 1 und -1 |
| 3259 | 3836 | $pos1 = array_search(trim($a->shortFolderName),self::$autoFolders); |
| 3260 | 3837 | $pos2 = array_search(trim($b->shortFolderName),self::$autoFolders); |
| 3261 | - if ($pos1 == $pos2) return 0; |
|
| 3838 | + if ($pos1 == $pos2) |
|
| 3839 | + { |
|
| 3840 | + return 0; |
|
| 3841 | + } |
|
| 3262 | 3842 | return ($pos1 < $pos2) ? -1 : 1; |
| 3263 | 3843 | } |
| 3264 | 3844 | |
@@ -3279,11 +3859,18 @@ discard block |
||
| 3279 | 3859 | } |
| 3280 | 3860 | catch (\Exception $e) |
| 3281 | 3861 | { |
| 3282 | - if (self::$debug) error_log(__METHOD__." returned FolderStatus for Folder $folderName:".$e->getMessage()); |
|
| 3862 | + if (self::$debug) |
|
| 3863 | + { |
|
| 3864 | + error_log(__METHOD__." returned FolderStatus for Folder $folderName:".$e->getMessage()); |
|
| 3865 | + } |
|
| 3283 | 3866 | return false; |
| 3284 | 3867 | } |
| 3285 | - if(is_array($folderStatus)) { |
|
| 3286 | - if ($_returnObject===false) return $folderStatus; |
|
| 3868 | + if(is_array($folderStatus)) |
|
| 3869 | + { |
|
| 3870 | + if ($_returnObject===false) |
|
| 3871 | + { |
|
| 3872 | + return $folderStatus; |
|
| 3873 | + } |
|
| 3287 | 3874 | $status = new \stdClass; |
| 3288 | 3875 | $status->messages = $folderStatus['MESSAGES']; |
| 3289 | 3876 | $status->unseen = $folderStatus['UNSEEN']; |
@@ -3310,7 +3897,8 @@ discard block |
||
| 3310 | 3897 | { |
| 3311 | 3898 | #echo __METHOD__." retrieve SubFolders for $_mailbox$delimiter <br>"; |
| 3312 | 3899 | $maxreclevel=25; |
| 3313 | - if ($reclevel > $maxreclevel) { |
|
| 3900 | + if ($reclevel > $maxreclevel) |
|
| 3901 | + { |
|
| 3314 | 3902 | error_log( __METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter "); |
| 3315 | 3903 | return array(); |
| 3316 | 3904 | } |
@@ -3324,7 +3912,8 @@ discard block |
||
| 3324 | 3912 | //error_log(__METHOD__.' ('.__LINE__.') '.' Delimiter:'.array2string($delimiter)); |
| 3325 | 3913 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mbx)); |
| 3326 | 3914 | // Example: Array([INBOX/GaGa] => Array([MAILBOX] => INBOX/GaGa[ATTRIBUTES] => Array([0] => \\unmarked)[delimiter] => /)) |
| 3327 | - 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"]))) { |
|
| 3915 | + 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"]))) |
|
| 3916 | + { |
|
| 3328 | 3917 | // if there are children fetch them |
| 3329 | 3918 | //echo $mbx[$mbxkeys[0]]['MAILBOX']."<br>"; |
| 3330 | 3919 | |
@@ -3332,7 +3921,8 @@ discard block |
||
| 3332 | 3921 | //$buff = $this->icServer->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'],2,false); |
| 3333 | 3922 | //_debug_array($buff); |
| 3334 | 3923 | $allMailboxes = array(); |
| 3335 | - foreach ($buff as $mbxname) { |
|
| 3924 | + foreach ($buff as $mbxname) |
|
| 3925 | + { |
|
| 3336 | 3926 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mbxname)); |
| 3337 | 3927 | $mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$mbxname['MAILBOX']); |
| 3338 | 3928 | #echo "About to recur in level $reclevel:".$mbxname."<br>"; |
@@ -3341,9 +3931,14 @@ discard block |
||
| 3341 | 3931 | $allMailboxes = array_merge($allMailboxes, self::getMailBoxesRecursive($mbxname, $delimiter, $prefix, $reclevel)); |
| 3342 | 3932 | } |
| 3343 | 3933 | } |
| 3344 | - 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']; |
|
| 3934 | + if (!(in_array('\NoSelect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) |
|
| 3935 | + { |
|
| 3936 | + $allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX']; |
|
| 3937 | + } |
|
| 3345 | 3938 | return $allMailboxes; |
| 3346 | - } else { |
|
| 3939 | + } |
|
| 3940 | + else |
|
| 3941 | + { |
|
| 3347 | 3942 | return array($_mailbox); |
| 3348 | 3943 | } |
| 3349 | 3944 | } |
@@ -3367,14 +3962,21 @@ discard block |
||
| 3367 | 3962 | 'Outbox' => array('profileKey'=>'acc_folder_outbox','autoFolderName'=>'Outbox'), |
| 3368 | 3963 | 'Archive' => array('profileKey'=>'acc_folder_archive','autoFolderName'=>'Archive'), |
| 3369 | 3964 | ); |
| 3370 | - if ($_type == 'Templates') $_type = 'Template'; // for some reason self::$autofolders uses 'Templates'! |
|
| 3965 | + if ($_type == 'Templates') |
|
| 3966 | + { |
|
| 3967 | + $_type = 'Template'; |
|
| 3968 | + } |
|
| 3969 | + // for some reason self::$autofolders uses 'Templates'! |
|
| 3371 | 3970 | $created = false; |
| 3372 | 3971 | if (!isset($types[$_type])) |
| 3373 | 3972 | { |
| 3374 | 3973 | error_log(__METHOD__.' ('.__LINE__.') '.' '.$_type.' not supported for '.__METHOD__); |
| 3375 | 3974 | return false; |
| 3376 | 3975 | } |
| 3377 | - if (is_null(self::$specialUseFolders) || empty(self::$specialUseFolders)) self::$specialUseFolders = $this->getSpecialUseFolders(); |
|
| 3976 | + if (is_null(self::$specialUseFolders) || empty(self::$specialUseFolders)) |
|
| 3977 | + { |
|
| 3978 | + self::$specialUseFolders = $this->getSpecialUseFolders(); |
|
| 3979 | + } |
|
| 3378 | 3980 | |
| 3379 | 3981 | //highest precedence |
| 3380 | 3982 | try |
@@ -3384,25 +3986,39 @@ discard block |
||
| 3384 | 3986 | catch (\Exception $e) |
| 3385 | 3987 | { |
| 3386 | 3988 | // we know that outbox is not supported, but we use this here, as we autocreate expected SpecialUseFolders in this function |
| 3387 | - if ($_type != 'Outbox') error_log(__METHOD__.' ('.__LINE__.') '.' Failed to retrieve Folder'.$_folderName." for ".array2string($types[$_type]).":".$e->getMessage()); |
|
| 3989 | + if ($_type != 'Outbox') |
|
| 3990 | + { |
|
| 3991 | + error_log(__METHOD__.' ('.__LINE__.') '.' Failed to retrieve Folder'.$_folderName." for ".array2string($types[$_type]).":".$e->getMessage()); |
|
| 3992 | + } |
|
| 3388 | 3993 | $_folderName = false; |
| 3389 | 3994 | } |
| 3390 | 3995 | // do not try to autocreate configured Archive-Folder. Return false if configured folder does not exist |
| 3391 | - if ($_type == 'Archive') { |
|
| 3392 | - if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true)) { |
|
| 3996 | + if ($_type == 'Archive') |
|
| 3997 | + { |
|
| 3998 | + if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true)) |
|
| 3999 | + { |
|
| 3393 | 4000 | return false; |
| 3394 | - } else { |
|
| 4001 | + } |
|
| 4002 | + else |
|
| 4003 | + { |
|
| 3395 | 4004 | return $_folderName; |
| 3396 | 4005 | } |
| 3397 | 4006 | |
| 3398 | 4007 | } |
| 3399 | 4008 | // does the folder exist??? (is configured/preset, but non-existent) |
| 3400 | - if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true)) { |
|
| 4009 | + if ($_folderName && $_checkexistance && strtolower($_folderName) !='none' && !$this->folderExists($_folderName,true)) |
|
| 4010 | + { |
|
| 3401 | 4011 | try |
| 3402 | 4012 | { |
| 3403 | 4013 | $error = null; |
| 3404 | - if (($_folderName = $this->createFolder('', $_folderName, $error))) $created = true; |
|
| 3405 | - if ($error) error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error); |
|
| 4014 | + if (($_folderName = $this->createFolder('', $_folderName, $error))) |
|
| 4015 | + { |
|
| 4016 | + $created = true; |
|
| 4017 | + } |
|
| 4018 | + if ($error) |
|
| 4019 | + { |
|
| 4020 | + error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error); |
|
| 4021 | + } |
|
| 3406 | 4022 | } |
| 3407 | 4023 | catch(Exception $e) |
| 3408 | 4024 | { |
@@ -3411,9 +4027,16 @@ discard block |
||
| 3411 | 4027 | } |
| 3412 | 4028 | } |
| 3413 | 4029 | // not sure yet if false is the correct behavior on none |
| 3414 | - if ($_folderName =='none') return 'none' ; //false; |
|
| 4030 | + if ($_folderName =='none') |
|
| 4031 | + { |
|
| 4032 | + return 'none' ; |
|
| 4033 | + } |
|
| 4034 | + //false; |
|
| 3415 | 4035 | //no (valid) folder found yet; try specialUseFolders |
| 3416 | - if (empty($_folderName) && is_array(self::$specialUseFolders) && ($f = array_search($_type,self::$specialUseFolders))) $_folderName = $f; |
|
| 4036 | + if (empty($_folderName) && is_array(self::$specialUseFolders) && ($f = array_search($_type,self::$specialUseFolders))) |
|
| 4037 | + { |
|
| 4038 | + $_folderName = $f; |
|
| 4039 | + } |
|
| 3417 | 4040 | //no specialUseFolder; try some Defaults |
| 3418 | 4041 | if (empty($_folderName) && isset($types[$_type])) |
| 3419 | 4042 | { |
@@ -3439,7 +4062,10 @@ discard block |
||
| 3439 | 4062 | $error = null; |
| 3440 | 4063 | $this->createFolder('', $prefix.$types[$_type]['autoFolderName'],$error); |
| 3441 | 4064 | $_folderName = $prefix.$types[$_type]['autoFolderName']; |
| 3442 | - if ($error) error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error); |
|
| 4065 | + if ($error) |
|
| 4066 | + { |
|
| 4067 | + error_log(__METHOD__.' ('.__LINE__.') '.' Failed to create Folder '.$_folderName." for $_type:".$error); |
|
| 4068 | + } |
|
| 3443 | 4069 | } |
| 3444 | 4070 | catch(Exception $e) |
| 3445 | 4071 | { |
@@ -3541,17 +4167,22 @@ discard block |
||
| 3541 | 4167 | function isSentFolder($_folderName, $_checkexistance=TRUE) |
| 3542 | 4168 | { |
| 3543 | 4169 | $sentFolder = $this->getSentFolder($_checkexistance); |
| 3544 | - if(empty($sentFolder)) { |
|
| 4170 | + if(empty($sentFolder)) |
|
| 4171 | + { |
|
| 3545 | 4172 | return false; |
| 3546 | 4173 | } |
| 3547 | 4174 | // does the folder exist??? |
| 3548 | - if ($_checkexistance && !$this->folderExists($_folderName)) { |
|
| 4175 | + if ($_checkexistance && !$this->folderExists($_folderName)) |
|
| 4176 | + { |
|
| 3549 | 4177 | return false; |
| 3550 | 4178 | } |
| 3551 | 4179 | |
| 3552 | - if(false !== stripos($_folderName, $sentFolder)) { |
|
| 4180 | + if(false !== stripos($_folderName, $sentFolder)) |
|
| 4181 | + { |
|
| 3553 | 4182 | return true; |
| 3554 | - } else { |
|
| 4183 | + } |
|
| 4184 | + else |
|
| 4185 | + { |
|
| 3555 | 4186 | return false; |
| 3556 | 4187 | } |
| 3557 | 4188 | } |
@@ -3564,15 +4195,20 @@ discard block |
||
| 3564 | 4195 | */ |
| 3565 | 4196 | function isOutbox($_folderName, $_checkexistance=TRUE) |
| 3566 | 4197 | { |
| 3567 | - if (stripos($_folderName, 'Outbox')===false) { |
|
| 4198 | + if (stripos($_folderName, 'Outbox')===false) |
|
| 4199 | + { |
|
| 3568 | 4200 | return false; |
| 3569 | 4201 | } |
| 3570 | 4202 | // does the folder exist??? |
| 3571 | - if ($_checkexistance && $GLOBALS['egw_info']['user']['apps']['activesync'] && !$this->folderExists($_folderName)) { |
|
| 4203 | + if ($_checkexistance && $GLOBALS['egw_info']['user']['apps']['activesync'] && !$this->folderExists($_folderName)) |
|
| 4204 | + { |
|
| 3572 | 4205 | $outboxFolder = $this->getOutboxFolder($_checkexistance); |
| 3573 | - if(false !== stripos($_folderName, $outboxFolder)) { |
|
| 4206 | + if(false !== stripos($_folderName, $outboxFolder)) |
|
| 4207 | + { |
|
| 3574 | 4208 | return true; |
| 3575 | - } else { |
|
| 4209 | + } |
|
| 4210 | + else |
|
| 4211 | + { |
|
| 3576 | 4212 | return false; |
| 3577 | 4213 | } |
| 3578 | 4214 | } |
@@ -3588,17 +4224,25 @@ discard block |
||
| 3588 | 4224 | function isDraftFolder($_folderName, $_checkexistance=TRUE) |
| 3589 | 4225 | { |
| 3590 | 4226 | $draftFolder = $this->getDraftFolder($_checkexistance); |
| 3591 | - if(empty($draftFolder)) { |
|
| 4227 | + if(empty($draftFolder)) |
|
| 4228 | + { |
|
| 3592 | 4229 | return false; |
| 3593 | 4230 | } |
| 3594 | 4231 | // does the folder exist??? |
| 3595 | - if ($_checkexistance && !$this->folderExists($_folderName)) { |
|
| 4232 | + if ($_checkexistance && !$this->folderExists($_folderName)) |
|
| 4233 | + { |
|
| 3596 | 4234 | return false; |
| 3597 | 4235 | } |
| 3598 | - if (is_a($_folderName,"Horde_Imap_Client_Mailbox")) $_folderName = $_folderName->utf8; |
|
| 3599 | - if(false !== stripos($_folderName, $draftFolder)) { |
|
| 4236 | + if (is_a($_folderName,"Horde_Imap_Client_Mailbox")) |
|
| 4237 | + { |
|
| 4238 | + $_folderName = $_folderName->utf8; |
|
| 4239 | + } |
|
| 4240 | + if(false !== stripos($_folderName, $draftFolder)) |
|
| 4241 | + { |
|
| 3600 | 4242 | return true; |
| 3601 | - } else { |
|
| 4243 | + } |
|
| 4244 | + else |
|
| 4245 | + { |
|
| 3602 | 4246 | return false; |
| 3603 | 4247 | } |
| 3604 | 4248 | } |
@@ -3612,17 +4256,22 @@ discard block |
||
| 3612 | 4256 | function isTrashFolder($_folderName, $_checkexistance=TRUE) |
| 3613 | 4257 | { |
| 3614 | 4258 | $trashFolder = $this->getTrashFolder($_checkexistance); |
| 3615 | - if(empty($trashFolder)) { |
|
| 4259 | + if(empty($trashFolder)) |
|
| 4260 | + { |
|
| 3616 | 4261 | return false; |
| 3617 | 4262 | } |
| 3618 | 4263 | // does the folder exist??? |
| 3619 | - if ($_checkexistance && !$this->folderExists($_folderName)) { |
|
| 4264 | + if ($_checkexistance && !$this->folderExists($_folderName)) |
|
| 4265 | + { |
|
| 3620 | 4266 | return false; |
| 3621 | 4267 | } |
| 3622 | 4268 | |
| 3623 | - if(false !== stripos($_folderName, $trashFolder)) { |
|
| 4269 | + if(false !== stripos($_folderName, $trashFolder)) |
|
| 4270 | + { |
|
| 3624 | 4271 | return true; |
| 3625 | - } else { |
|
| 4272 | + } |
|
| 4273 | + else |
|
| 4274 | + { |
|
| 3626 | 4275 | return false; |
| 3627 | 4276 | } |
| 3628 | 4277 | } |
@@ -3636,17 +4285,22 @@ discard block |
||
| 3636 | 4285 | function isTemplateFolder($_folderName, $_checkexistance=TRUE) |
| 3637 | 4286 | { |
| 3638 | 4287 | $templateFolder = $this->getTemplateFolder($_checkexistance); |
| 3639 | - if(empty($templateFolder)) { |
|
| 4288 | + if(empty($templateFolder)) |
|
| 4289 | + { |
|
| 3640 | 4290 | return false; |
| 3641 | 4291 | } |
| 3642 | 4292 | // does the folder exist??? |
| 3643 | - if ($_checkexistance && !$this->folderExists($_folderName)) { |
|
| 4293 | + if ($_checkexistance && !$this->folderExists($_folderName)) |
|
| 4294 | + { |
|
| 3644 | 4295 | return false; |
| 3645 | 4296 | } |
| 3646 | 4297 | |
| 3647 | - if(false !== stripos($_folderName, $templateFolder)) { |
|
| 4298 | + if(false !== stripos($_folderName, $templateFolder)) |
|
| 4299 | + { |
|
| 3648 | 4300 | return true; |
| 3649 | - } else { |
|
| 4301 | + } |
|
| 4302 | + else |
|
| 4303 | + { |
|
| 3650 | 4304 | return false; |
| 3651 | 4305 | } |
| 3652 | 4306 | } |
@@ -3664,15 +4318,27 @@ discard block |
||
| 3664 | 4318 | if (empty($_folder)) |
| 3665 | 4319 | { |
| 3666 | 4320 | // this error is more or less without significance, unless we force the check |
| 3667 | - if ($_forceCheck===true) error_log(__METHOD__.' ('.__LINE__.') '.' Called with empty Folder:'.$_folder.function_backtrace()); |
|
| 4321 | + if ($_forceCheck===true) |
|
| 4322 | + { |
|
| 4323 | + error_log(__METHOD__.' ('.__LINE__.') '.' Called with empty Folder:'.$_folder.function_backtrace()); |
|
| 4324 | + } |
|
| 3668 | 4325 | return false; |
| 3669 | 4326 | } |
| 3670 | 4327 | // when check is not enforced , we assume a folder represented as Horde_Imap_Client_Mailbox as existing folder |
| 3671 | - if (is_a($_folder,"Horde_Imap_Client_Mailbox")&&$_forceCheck===false) return true; |
|
| 3672 | - if (is_a($_folder,"Horde_Imap_Client_Mailbox")) $_folder = $_folder->utf8; |
|
| 4328 | + if (is_a($_folder,"Horde_Imap_Client_Mailbox")&&$_forceCheck===false) |
|
| 4329 | + { |
|
| 4330 | + return true; |
|
| 4331 | + } |
|
| 4332 | + if (is_a($_folder,"Horde_Imap_Client_Mailbox")) |
|
| 4333 | + { |
|
| 4334 | + $_folder = $_folder->utf8; |
|
| 4335 | + } |
|
| 3673 | 4336 | // reduce traffic within the Instance per User; Expire every 5 hours |
| 3674 | 4337 | //error_log(__METHOD__.' ('.__LINE__.') '.' Called with Folder:'.$_folder.function_backtrace()); |
| 3675 | - if (is_null($folderInfo)) $folderInfo = Cache::getCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*5); |
|
| 4338 | + if (is_null($folderInfo)) |
|
| 4339 | + { |
|
| 4340 | + $folderInfo = Cache::getCache(Cache::INSTANCE,'email','icServerFolderExistsInfo'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*5); |
|
| 4341 | + } |
|
| 3676 | 4342 | //error_log(__METHOD__.' ('.__LINE__.') '.'Cached Info on Folder:'.$_folder.' for Profile:'.$this->profileID.($forceCheck?'(forcedCheck)':'').':'.array2string($folderInfo)); |
| 3677 | 4343 | if (!empty($folderInfo) && isset($folderInfo[$this->profileID]) && isset($folderInfo[$this->profileID][$_folder]) && $forceCheck===false) |
| 3678 | 4344 | { |
@@ -3690,7 +4356,8 @@ discard block |
||
| 3690 | 4356 | |
| 3691 | 4357 | // does the folder exist??? |
| 3692 | 4358 | //error_log(__METHOD__."->Connected?".$this->icServer->_connected.", ".$_folder.", ".($forceCheck?' forceCheck activated':'dont check on server')); |
| 3693 | - if ( $forceCheck || empty($folderInfo) || !isset($folderInfo[$this->profileID]) || !isset($folderInfo[$this->profileID][$_folder])) { |
|
| 4359 | + if ( $forceCheck || empty($folderInfo) || !isset($folderInfo[$this->profileID]) || !isset($folderInfo[$this->profileID][$_folder])) |
|
| 4360 | + { |
|
| 3694 | 4361 | //error_log(__METHOD__."->NotConnected and forceCheck with profile:".$this->profileID); |
| 3695 | 4362 | //return false; |
| 3696 | 4363 | //try to connect |
@@ -3731,9 +4398,12 @@ discard block |
||
| 3731 | 4398 | |
| 3732 | 4399 | $this->icServer->openMailbox($folderName); |
| 3733 | 4400 | |
| 3734 | - if(strtolower($folderName) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") { |
|
| 4401 | + if(strtolower($folderName) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") |
|
| 4402 | + { |
|
| 3735 | 4403 | $this->deleteMessages('all',$folderName,'remove_immediately'); |
| 3736 | - } else { |
|
| 4404 | + } |
|
| 4405 | + else |
|
| 4406 | + { |
|
| 3737 | 4407 | $this->icServer->expunge($folderName); |
| 3738 | 4408 | } |
| 3739 | 4409 | } |
@@ -3752,10 +4422,16 @@ discard block |
||
| 3752 | 4422 | { |
| 3753 | 4423 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.array2string($_folder).', '.$_forceDeleteMethod); |
| 3754 | 4424 | $oldMailbox = ''; |
| 3755 | - if (is_null($_folder) || empty($_folder)) $_folder = $this->sessionData['mailbox']; |
|
| 4425 | + if (is_null($_folder) || empty($_folder)) |
|
| 4426 | + { |
|
| 4427 | + $_folder = $this->sessionData['mailbox']; |
|
| 4428 | + } |
|
| 3756 | 4429 | if (empty($_messageUID)) |
| 3757 | 4430 | { |
| 3758 | - if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID)); |
|
| 4431 | + if (self::$debug) |
|
| 4432 | + { |
|
| 4433 | + error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID)); |
|
| 4434 | + } |
|
| 3759 | 4435 | return false; |
| 3760 | 4436 | } |
| 3761 | 4437 | elseif ($_messageUID==='all') |
@@ -3765,32 +4441,48 @@ discard block |
||
| 3765 | 4441 | else |
| 3766 | 4442 | { |
| 3767 | 4443 | $uidsToDelete = new Horde_Imap_Client_Ids(); |
| 3768 | - if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID; |
|
| 4444 | + if (!(is_object($_messageUID) || is_array($_messageUID))) |
|
| 4445 | + { |
|
| 4446 | + $_messageUID = (array)$_messageUID; |
|
| 4447 | + } |
|
| 3769 | 4448 | $uidsToDelete->add($_messageUID); |
| 3770 | 4449 | } |
| 3771 | 4450 | $deleteOptions = $_forceDeleteMethod; // use forceDeleteMethod if not "no", or unknown method |
| 3772 | - 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"); |
|
| 4451 | + if ($_forceDeleteMethod === 'no' || !in_array($_forceDeleteMethod,array('move_to_trash',"mark_as_deleted","remove_immediately"))) |
|
| 4452 | + { |
|
| 4453 | + $deleteOptions = ($this->mailPreferences['deleteOptions']?$this->mailPreferences['deleteOptions']:"mark_as_deleted"); |
|
| 4454 | + } |
|
| 3773 | 4455 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.$_folder.'/'.$this->sessionData['mailbox'].' Option:'.$deleteOptions); |
| 3774 | 4456 | $trashFolder = $this->getTrashFolder(); |
| 3775 | 4457 | $draftFolder = $this->getDraftFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['draftFolder']; |
| 3776 | 4458 | $templateFolder = $this->getTemplateFolder(); //$GLOBALS['egw_info']['user']['preferences']['mail']['templateFolder']; |
| 3777 | 4459 | if((strtolower($_folder) == strtolower($trashFolder) && $deleteOptions == "move_to_trash") || |
| 3778 | - (strtolower($_folder) == strtolower($draftFolder))) { |
|
| 4460 | + (strtolower($_folder) == strtolower($draftFolder))) |
|
| 4461 | + { |
|
| 3779 | 4462 | $deleteOptions = "remove_immediately"; |
| 3780 | 4463 | } |
| 3781 | - if($this->icServer->getCurrentMailbox() != $_folder) { |
|
| 4464 | + if($this->icServer->getCurrentMailbox() != $_folder) |
|
| 4465 | + { |
|
| 3782 | 4466 | $oldMailbox = $this->icServer->getCurrentMailbox(); |
| 3783 | 4467 | $this->icServer->openMailbox($_folder); |
| 3784 | 4468 | } |
| 3785 | 4469 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.array2string($_messageUID).','.$_folder.'/'.$this->sessionData['mailbox'].' Option:'.$deleteOptions); |
| 3786 | 4470 | $updateCache = false; |
| 3787 | - switch($deleteOptions) { |
|
| 4471 | + switch($deleteOptions) |
|
| 4472 | + { |
|
| 3788 | 4473 | case "move_to_trash": |
| 3789 | 4474 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 3790 | 4475 | $updateCache = true; |
| 3791 | - if(!empty($trashFolder)) { |
|
| 3792 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.implode(' : ', $_messageUID)); |
|
| 3793 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '."$trashFolder <= $_folder / ". $this->sessionData['mailbox']); |
|
| 4476 | + if(!empty($trashFolder)) |
|
| 4477 | + { |
|
| 4478 | + if (self::$debug) |
|
| 4479 | + { |
|
| 4480 | + error_log(__METHOD__.' ('.__LINE__.') '.implode(' : ', $_messageUID)); |
|
| 4481 | + } |
|
| 4482 | + if (self::$debug) |
|
| 4483 | + { |
|
| 4484 | + error_log(__METHOD__.' ('.__LINE__.') '."$trashFolder <= $_folder / ". $this->sessionData['mailbox']); |
|
| 4485 | + } |
|
| 3794 | 4486 | // copy messages |
| 3795 | 4487 | try |
| 3796 | 4488 | { |
@@ -3806,7 +4498,10 @@ discard block |
||
| 3806 | 4498 | case "mark_as_deleted": |
| 3807 | 4499 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 3808 | 4500 | // mark messages as deleted |
| 3809 | - if (is_null($_messageUID)) $_messageUID='all'; |
|
| 4501 | + if (is_null($_messageUID)) |
|
| 4502 | + { |
|
| 4503 | + $_messageUID='all'; |
|
| 4504 | + } |
|
| 3810 | 4505 | foreach((array)$_messageUID as $key =>$uid) |
| 3811 | 4506 | { |
| 3812 | 4507 | //flag messages, that are flagged for deletion as seen too |
@@ -3814,7 +4509,10 @@ discard block |
||
| 3814 | 4509 | $flags = $this->getFlags($uid); |
| 3815 | 4510 | $this->flagMessages('delete', $uid, $_folder); |
| 3816 | 4511 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($flags)); |
| 3817 | - if (strpos( array2string($flags),'Deleted')!==false) $undelete[] = $uid; |
|
| 4512 | + if (strpos( array2string($flags),'Deleted')!==false) |
|
| 4513 | + { |
|
| 4514 | + $undelete[] = $uid; |
|
| 4515 | + } |
|
| 3818 | 4516 | unset($flags); |
| 3819 | 4517 | } |
| 3820 | 4518 | foreach((array)$undelete as $key =>$uid) |
@@ -3826,7 +4524,10 @@ discard block |
||
| 3826 | 4524 | case "remove_immediately": |
| 3827 | 4525 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 3828 | 4526 | $updateCache = true; |
| 3829 | - if (is_null($_messageUID)) $_messageUID='all'; |
|
| 4527 | + if (is_null($_messageUID)) |
|
| 4528 | + { |
|
| 4529 | + $_messageUID='all'; |
|
| 4530 | + } |
|
| 3830 | 4531 | if (is_object($_messageUID)) |
| 3831 | 4532 | { |
| 3832 | 4533 | $this->flagMessages('delete', $_messageUID, $_folder); |
@@ -3843,7 +4544,8 @@ discard block |
||
| 3843 | 4544 | $this->icServer->expunge($_folder); |
| 3844 | 4545 | break; |
| 3845 | 4546 | } |
| 3846 | - if($oldMailbox != '') { |
|
| 4547 | + if($oldMailbox != '') |
|
| 4548 | + { |
|
| 3847 | 4549 | $this->icServer->openMailbox($oldMailbox); |
| 3848 | 4550 | } |
| 3849 | 4551 | |
@@ -3857,11 +4559,15 @@ discard block |
||
| 3857 | 4559 | * |
| 3858 | 4560 | * @return null/array flags |
| 3859 | 4561 | */ |
| 3860 | - function getFlags ($_messageUID) { |
|
| 4562 | + function getFlags ($_messageUID) |
|
| 4563 | + { |
|
| 3861 | 4564 | try |
| 3862 | 4565 | { |
| 3863 | 4566 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 3864 | - if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID; |
|
| 4567 | + if (!(is_object($_messageUID) || is_array($_messageUID))) |
|
| 4568 | + { |
|
| 4569 | + $_messageUID = (array)$_messageUID; |
|
| 4570 | + } |
|
| 3865 | 4571 | $uidsToFetch->add($_messageUID); |
| 3866 | 4572 | $_folderName = $this->icServer->getCurrentMailbox(); |
| 3867 | 4573 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
@@ -3869,8 +4575,10 @@ discard block |
||
| 3869 | 4575 | $headersNew = $this->icServer->fetch($_folderName, $fquery, array( |
| 3870 | 4576 | 'ids' => $uidsToFetch, |
| 3871 | 4577 | )); |
| 3872 | - if (is_object($headersNew)) { |
|
| 3873 | - foreach($headersNew->ids() as $id) { |
|
| 4578 | + if (is_object($headersNew)) |
|
| 4579 | + { |
|
| 4580 | + foreach($headersNew->ids() as $id) |
|
| 4581 | + { |
|
| 3874 | 4582 | $_headerObject = $headersNew->get($id); |
| 3875 | 4583 | $flags = $_headerObject->getFlags(); |
| 3876 | 4584 | } |
@@ -3895,10 +4603,16 @@ discard block |
||
| 3895 | 4603 | */ |
| 3896 | 4604 | function getNotifyFlags ($_messageUID, $flags=null) |
| 3897 | 4605 | { |
| 3898 | - if (self::$debug) error_log(__METHOD__.$_messageUID.' Flags:'.array2string($flags)); |
|
| 4606 | + if (self::$debug) |
|
| 4607 | + { |
|
| 4608 | + error_log(__METHOD__.$_messageUID.' Flags:'.array2string($flags)); |
|
| 4609 | + } |
|
| 3899 | 4610 | try |
| 3900 | 4611 | { |
| 3901 | - if($flags===null) $flags = $this->getFlags($_messageUID); |
|
| 4612 | + if($flags===null) |
|
| 4613 | + { |
|
| 4614 | + $flags = $this->getFlags($_messageUID); |
|
| 4615 | + } |
|
| 3902 | 4616 | } |
| 3903 | 4617 | catch (\Exception $e) |
| 3904 | 4618 | { |
@@ -3906,10 +4620,14 @@ discard block |
||
| 3906 | 4620 | } |
| 3907 | 4621 | |
| 3908 | 4622 | if ( stripos( array2string($flags),'MDNSent')!==false) |
| 3909 | - return true; |
|
| 4623 | + { |
|
| 4624 | + return true; |
|
| 4625 | + } |
|
| 3910 | 4626 | |
| 3911 | 4627 | if ( stripos( array2string($flags),'MDNnotSent')!==false) |
| 3912 | - return false; |
|
| 4628 | + { |
|
| 4629 | + return false; |
|
| 4630 | + } |
|
| 3913 | 4631 | |
| 3914 | 4632 | return null; |
| 3915 | 4633 | } |
@@ -3930,7 +4648,10 @@ discard block |
||
| 3930 | 4648 | //error_log(__METHOD__.' ('.__LINE__.') '.'->' .$_flag." ".array2string($_messageUID).",$_folder /".$this->sessionData['mailbox']); |
| 3931 | 4649 | if (empty($_messageUID)) |
| 3932 | 4650 | { |
| 3933 | - if (self::$debug) error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID)); |
|
| 4651 | + if (self::$debug) |
|
| 4652 | + { |
|
| 4653 | + error_log(__METHOD__." no messages Message(s): ".implode(',',$_messageUID)); |
|
| 4654 | + } |
|
| 3934 | 4655 | return false; |
| 3935 | 4656 | } |
| 3936 | 4657 | $this->icServer->openMailbox(($_folder?$_folder:$this->sessionData['mailbox'])); |
@@ -3938,7 +4659,10 @@ discard block |
||
| 3938 | 4659 | if (is_array($_messageUID)&& count($_messageUID)>50) |
| 3939 | 4660 | { |
| 3940 | 4661 | $count = $this->getMailBoxCounters($folder,true); |
| 3941 | - if ($count->messages == count($_messageUID)) $_messageUID='all'; |
|
| 4662 | + if ($count->messages == count($_messageUID)) |
|
| 4663 | + { |
|
| 4664 | + $_messageUID='all'; |
|
| 4665 | + } |
|
| 3942 | 4666 | } |
| 3943 | 4667 | |
| 3944 | 4668 | if ($_messageUID==='all') |
@@ -3947,7 +4671,10 @@ discard block |
||
| 3947 | 4671 | } |
| 3948 | 4672 | else |
| 3949 | 4673 | { |
| 3950 | - if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID; |
|
| 4674 | + if (!(is_object($_messageUID) || is_array($_messageUID))) |
|
| 4675 | + { |
|
| 4676 | + $_messageUID = (array)$_messageUID; |
|
| 4677 | + } |
|
| 3951 | 4678 | $messageUIDs = array_chunk($_messageUID,50,true); |
| 3952 | 4679 | } |
| 3953 | 4680 | try |
@@ -3963,7 +4690,8 @@ discard block |
||
| 3963 | 4690 | $uidsToModify = new Horde_Imap_Client_Ids(); |
| 3964 | 4691 | $uidsToModify->add($uids); |
| 3965 | 4692 | } |
| 3966 | - switch($_flag) { |
|
| 4693 | + switch($_flag) |
|
| 4694 | + { |
|
| 3967 | 4695 | case "delete": |
| 3968 | 4696 | $ret = $this->icServer->store($folder, array('add'=>array('\\Deleted'), 'ids'=> $uidsToModify)); |
| 3969 | 4697 | break; |
@@ -4049,7 +4777,10 @@ discard block |
||
| 4049 | 4777 | { |
| 4050 | 4778 | error_log(__METHOD__.__LINE__.' Error, could not flag messages in folder '.$folder.' Reason:'.$e->getMessage()); |
| 4051 | 4779 | } |
| 4052 | - if ($folder instanceof Horde_Imap_Client_Mailbox) $_folder = $folder->utf8; |
|
| 4780 | + if ($folder instanceof Horde_Imap_Client_Mailbox) |
|
| 4781 | + { |
|
| 4782 | + $_folder = $folder->utf8; |
|
| 4783 | + } |
|
| 4053 | 4784 | //error_log(__METHOD__.__LINE__.'#'.$this->icServer->ImapServerId.'#'.array2string($_folder).'#'); |
| 4054 | 4785 | self::$folderStatusCache[$this->icServer->ImapServerId][(!empty($_folder)?$_folder: $this->sessionData['mailbox'])]['uidValidity'] = 0; |
| 4055 | 4786 | |
@@ -4078,7 +4809,10 @@ discard block |
||
| 4078 | 4809 | //$deleteOptions = $GLOBALS['egw_info']["user"]["preferences"]["mail"]["deleteOptions"]; |
| 4079 | 4810 | if (empty($_messageUID)) |
| 4080 | 4811 | { |
| 4081 | - if (self::$debug) error_log(__METHOD__." no Message(s): ".implode(',',$_messageUID)); |
|
| 4812 | + if (self::$debug) |
|
| 4813 | + { |
|
| 4814 | + error_log(__METHOD__." no Message(s): ".implode(',',$_messageUID)); |
|
| 4815 | + } |
|
| 4082 | 4816 | return false; |
| 4083 | 4817 | } |
| 4084 | 4818 | elseif ($_messageUID==='all') |
@@ -4090,7 +4824,10 @@ discard block |
||
| 4090 | 4824 | { |
| 4091 | 4825 | //error_log(__METHOD__." Message(s): ".implode(',',$_messageUID)); |
| 4092 | 4826 | $uidsToMove = new Horde_Imap_Client_Ids(); |
| 4093 | - if (!(is_object($_messageUID) || is_array($_messageUID))) $_messageUID = (array)$_messageUID; |
|
| 4827 | + if (!(is_object($_messageUID) || is_array($_messageUID))) |
|
| 4828 | + { |
|
| 4829 | + $_messageUID = (array)$_messageUID; |
|
| 4830 | + } |
|
| 4094 | 4831 | $uidsToMove->add($_messageUID); |
| 4095 | 4832 | } |
| 4096 | 4833 | $sourceFolder = (!empty($currentFolder)?$currentFolder: $this->sessionData['mailbox']); |
@@ -4112,12 +4849,14 @@ discard block |
||
| 4112 | 4849 | |
| 4113 | 4850 | //error_log(__METHOD__.' ('.__LINE__.') '.' Sourceserver:'.$source->ImapServerId.' mailheaders:'.array2string($headersNew)); |
| 4114 | 4851 | |
| 4115 | - if (is_object($headersNew)) { |
|
| 4852 | + if (is_object($headersNew)) |
|
| 4853 | + { |
|
| 4116 | 4854 | $c=0; |
| 4117 | 4855 | $retUid = new Horde_Imap_Client_Ids(); |
| 4118 | 4856 | // we copy chunks of 5 to avoid too much memory and/or server stress |
| 4119 | 4857 | // some servers seem not to allow/support the appendig of multiple messages. so we are down to one |
| 4120 | - foreach($headersNew as &$_headerObject) { |
|
| 4858 | + foreach($headersNew as &$_headerObject) |
|
| 4859 | + { |
|
| 4121 | 4860 | $c++; |
| 4122 | 4861 | $flags = $_headerObject->getFlags(); //unseen status seems to be lost when retrieving the full message |
| 4123 | 4862 | $date = $_headerObject->getImapDate(); |
@@ -4201,7 +4940,11 @@ discard block |
||
| 4201 | 4940 | { |
| 4202 | 4941 | try { |
| 4203 | 4942 | $date = new DateTime($_date); // parse date & time including timezone (throws exception, if not parsable) |
| 4204 | - if ($convert2usertime) $date->setUser(); // convert to user-time |
|
| 4943 | + if ($convert2usertime) |
|
| 4944 | + { |
|
| 4945 | + $date->setUser(); |
|
| 4946 | + } |
|
| 4947 | + // convert to user-time |
|
| 4205 | 4948 | $date2return = $date->format($format); |
| 4206 | 4949 | } |
| 4207 | 4950 | catch(\Exception $e) |
@@ -4233,9 +4976,15 @@ discard block |
||
| 4233 | 4976 | static function htmlentities($_string, $_charset=false) |
| 4234 | 4977 | { |
| 4235 | 4978 | //setting the charset (if not given) |
| 4236 | - if ($_charset===false) $_charset = self::$displayCharset; |
|
| 4979 | + if ($_charset===false) |
|
| 4980 | + { |
|
| 4981 | + $_charset = self::$displayCharset; |
|
| 4982 | + } |
|
| 4237 | 4983 | $string = @htmlentities($_string, ENT_QUOTES, $_charset, false); |
| 4238 | - if (empty($string) && !empty($_string)) $string = @htmlentities(Translation::convert($_string,Translation::detect_encoding($_string),$_charset),ENT_QUOTES | ENT_IGNORE,$_charset, false); |
|
| 4984 | + if (empty($string) && !empty($_string)) |
|
| 4985 | + { |
|
| 4986 | + $string = @htmlentities(Translation::convert($_string,Translation::detect_encoding($_string),$_charset),ENT_QUOTES | ENT_IGNORE,$_charset, false); |
|
| 4987 | + } |
|
| 4239 | 4988 | return $string; |
| 4240 | 4989 | } |
| 4241 | 4990 | |
@@ -4255,18 +5004,41 @@ discard block |
||
| 4255 | 5004 | $_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>'), |
| 4256 | 5005 | array('&', '<BR>', '<BR>', '<BR>', '</font></td>','<td>', '', '', '', ''),$_html); |
| 4257 | 5006 | //$_html = str_replace(array('&amp;'),array('&'),$_html); |
| 4258 | - if (stripos($_html,'style')!==false) Mail\Html::replaceTagsCompletley($_html,'style'); // clean out empty or pagewide style definitions / left over tags |
|
| 4259 | - if (stripos($_html,'head')!==false) Mail\Html::replaceTagsCompletley($_html,'head'); // Strip out stuff in head |
|
| 5007 | + if (stripos($_html,'style')!==false) |
|
| 5008 | + { |
|
| 5009 | + Mail\Html::replaceTagsCompletley($_html,'style'); |
|
| 5010 | + } |
|
| 5011 | + // clean out empty or pagewide style definitions / left over tags |
|
| 5012 | + if (stripos($_html,'head')!==false) |
|
| 5013 | + { |
|
| 5014 | + Mail\Html::replaceTagsCompletley($_html,'head'); |
|
| 5015 | + } |
|
| 5016 | + // Strip out stuff in head |
|
| 4260 | 5017 | //if (stripos($_html,'![if')!==false && stripos($_html,'<![endif]>')!==false) Mail\Html::replaceTagsCompletley($_html,'!\[if','<!\[endif\]>',false); // Strip out stuff in ifs |
| 4261 | 5018 | //if (stripos($_html,'!--[if')!==false && stripos($_html,'<![endif]-->')!==false) Mail\Html::replaceTagsCompletley($_html,'!--\[if','<!\[endif\]-->',false); // Strip out stuff in ifs |
| 4262 | 5019 | //error_log(__METHOD__.' ('.__LINE__.') '.$_html); |
| 4263 | 5020 | |
| 4264 | - if (get_magic_quotes_gpc() === 1) $_html = stripslashes($_html); |
|
| 5021 | + if (get_magic_quotes_gpc() === 1) |
|
| 5022 | + { |
|
| 5023 | + $_html = stripslashes($_html); |
|
| 5024 | + } |
|
| 4265 | 5025 | // Strip out doctype in head, as htmlLawed cannot handle it TODO: Consider extracting it and adding it afterwards |
| 4266 | - if (stripos($_html,'!doctype')!==false) Mail\Html::replaceTagsCompletley($_html,'!doctype'); |
|
| 4267 | - if (stripos($_html,'?xml:namespace')!==false) Mail\Html::replaceTagsCompletley($_html,'\?xml:namespace','/>',false); |
|
| 4268 | - if (stripos($_html,'?xml version')!==false) Mail\Html::replaceTagsCompletley($_html,'\?xml version','\?>',false); |
|
| 4269 | - if (strpos($_html,'!CURSOR')!==false) Mail\Html::replaceTagsCompletley($_html,'!CURSOR'); |
|
| 5026 | + if (stripos($_html,'!doctype')!==false) |
|
| 5027 | + { |
|
| 5028 | + Mail\Html::replaceTagsCompletley($_html,'!doctype'); |
|
| 5029 | + } |
|
| 5030 | + if (stripos($_html,'?xml:namespace')!==false) |
|
| 5031 | + { |
|
| 5032 | + Mail\Html::replaceTagsCompletley($_html,'\?xml:namespace','/>',false); |
|
| 5033 | + } |
|
| 5034 | + if (stripos($_html,'?xml version')!==false) |
|
| 5035 | + { |
|
| 5036 | + Mail\Html::replaceTagsCompletley($_html,'\?xml version','\?>',false); |
|
| 5037 | + } |
|
| 5038 | + if (strpos($_html,'!CURSOR')!==false) |
|
| 5039 | + { |
|
| 5040 | + Mail\Html::replaceTagsCompletley($_html,'!CURSOR'); |
|
| 5041 | + } |
|
| 4270 | 5042 | // htmLawed filter only the 'body' |
| 4271 | 5043 | //preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $_html, $matches); |
| 4272 | 5044 | //if ($matches[2]) |
@@ -4305,8 +5077,10 @@ discard block |
||
| 4305 | 5077 | //$charSet = 'iso-8859-1';//self::$displayCharset; //'iso-8859-1'; // self::displayCharset seems to be asmarter fallback than iso-8859-1 |
| 4306 | 5078 | $CharsetFound=false; |
| 4307 | 5079 | //echo "#".$_mimePartObject->encoding.'#<br>'; |
| 4308 | - if(is_array($_mimePartObject->parameters)) { |
|
| 4309 | - if(isset($_mimePartObject->parameters['CHARSET'])) { |
|
| 5080 | + if(is_array($_mimePartObject->parameters)) |
|
| 5081 | + { |
|
| 5082 | + if(isset($_mimePartObject->parameters['CHARSET'])) |
|
| 5083 | + { |
|
| 4310 | 5084 | $charSet = $_mimePartObject->parameters['CHARSET']; |
| 4311 | 5085 | $CharsetFound=true; |
| 4312 | 5086 | } |
@@ -4327,7 +5101,10 @@ discard block |
||
| 4327 | 5101 | function decodeMimePart($_mimeMessage, $_encoding, $_charset = '') |
| 4328 | 5102 | { |
| 4329 | 5103 | // decode the part |
| 4330 | - if (self::$debug) error_log(__METHOD__."() with $_encoding and $_charset:".print_r($_mimeMessage,true)); |
|
| 5104 | + if (self::$debug) |
|
| 5105 | + { |
|
| 5106 | + error_log(__METHOD__."() with $_encoding and $_charset:".print_r($_mimeMessage,true)); |
|
| 5107 | + } |
|
| 4331 | 5108 | switch (strtoupper($_encoding)) |
| 4332 | 5109 | { |
| 4333 | 5110 | case 'BASE64': |
@@ -4367,13 +5144,19 @@ discard block |
||
| 4367 | 5144 | // sometimes there are 3 parts, when there is an ics/ical attached/included-> we want to show that |
| 4368 | 5145 | // as attachment AND as abstracted ical information (we use our notification style here). |
| 4369 | 5146 | $partText = $partCalendar = $partHTML = null; |
| 4370 | - if (self::$debug) _debug_array(array("METHOD"=>__METHOD__,"LINE"=>__LINE__,"STRUCTURE"=>$_structure)); |
|
| 5147 | + if (self::$debug) |
|
| 5148 | + { |
|
| 5149 | + _debug_array(array("METHOD"=>__METHOD__,"LINE"=>__LINE__,"STRUCTURE"=>$_structure)); |
|
| 5150 | + } |
|
| 4371 | 5151 | //error_log(__METHOD__.' ('.__LINE__.') '); |
| 4372 | 5152 | $ignore_first_part = true; |
| 4373 | 5153 | foreach($_structure->contentTypeMap() as $mime_id => $mime_type) |
| 4374 | 5154 | { |
| 4375 | 5155 | //error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") $mime_id: $mime_type"." ignoreFirstPart:".$ignore_first_part); |
| 4376 | - if (self::$debug) echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>"; |
|
| 5156 | + if (self::$debug) |
|
| 5157 | + { |
|
| 5158 | + echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>"; |
|
| 5159 | + } |
|
| 4377 | 5160 | |
| 4378 | 5161 | if ($ignore_first_part) |
| 4379 | 5162 | { |
@@ -4389,11 +5172,17 @@ discard block |
||
| 4389 | 5172 | switch($mimePart->getSubType()) |
| 4390 | 5173 | { |
| 4391 | 5174 | case 'plain': |
| 4392 | - if ($mimePart->getBytes() > 0) $partText = $mimePart; |
|
| 5175 | + if ($mimePart->getBytes() > 0) |
|
| 5176 | + { |
|
| 5177 | + $partText = $mimePart; |
|
| 5178 | + } |
|
| 4393 | 5179 | break; |
| 4394 | 5180 | |
| 4395 | 5181 | case 'html': |
| 4396 | - if ($mimePart->getBytes() > 0) $partHTML = $mimePart; |
|
| 5182 | + if ($mimePart->getBytes() > 0) |
|
| 5183 | + { |
|
| 5184 | + $partHTML = $mimePart; |
|
| 5185 | + } |
|
| 4397 | 5186 | break; |
| 4398 | 5187 | } |
| 4399 | 5188 | break; |
@@ -4406,7 +5195,10 @@ discard block |
||
| 4406 | 5195 | if (count($mimePart->getParts()) > 1) |
| 4407 | 5196 | { |
| 4408 | 5197 | // in a multipart alternative we treat the multipart/related as html part |
| 4409 | - if (self::$debug) error_log(__METHOD__." process MULTIPART/".$mimePart->getSubType()." with array as subparts"); |
|
| 5198 | + if (self::$debug) |
|
| 5199 | + { |
|
| 5200 | + error_log(__METHOD__." process MULTIPART/".$mimePart->getSubType()." with array as subparts"); |
|
| 5201 | + } |
|
| 4410 | 5202 | $partHTML = $mimePart; |
| 4411 | 5203 | break 3; // GET OUT OF LOOP, will be processed according to type |
| 4412 | 5204 | } |
@@ -4487,9 +5279,15 @@ discard block |
||
| 4487 | 5279 | */ |
| 4488 | 5280 | function getMultipartMixed($_uid, Horde_Mime_Part $_structure, $_htmlMode, $_preserveSeen = false, &$skipParts=array()) |
| 4489 | 5281 | { |
| 4490 | - if (self::$debug) echo __METHOD__."$_uid, $_htmlMode<br>"; |
|
| 5282 | + if (self::$debug) |
|
| 5283 | + { |
|
| 5284 | + echo __METHOD__."$_uid, $_htmlMode<br>"; |
|
| 5285 | + } |
|
| 4491 | 5286 | $bodyPart = array(); |
| 4492 | - if (self::$debug) _debug_array($_structure); |
|
| 5287 | + if (self::$debug) |
|
| 5288 | + { |
|
| 5289 | + _debug_array($_structure); |
|
| 5290 | + } |
|
| 4493 | 5291 | |
| 4494 | 5292 | $ignore_first_part = true; |
| 4495 | 5293 | //$skipParts = array(); |
@@ -4497,7 +5295,10 @@ discard block |
||
| 4497 | 5295 | foreach($_structure->contentTypeMap() as $mime_id => $mime_type) |
| 4498 | 5296 | { |
| 4499 | 5297 | //error_log(__METHOD__."($_uid, ".$_structure->getMimeId().") $mime_id: $mime_type"); |
| 4500 | - if (self::$debug) echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>"; |
|
| 5298 | + if (self::$debug) |
|
| 5299 | + { |
|
| 5300 | + echo __METHOD__."($_uid, partID=".$_structure->getMimeId().") $mime_id: $mime_type<br>"; |
|
| 5301 | + } |
|
| 4501 | 5302 | if ($ignore_first_part) |
| 4502 | 5303 | { |
| 4503 | 5304 | $ignore_first_part = false; |
@@ -4515,7 +5316,10 @@ discard block |
||
| 4515 | 5316 | switch($part->getPrimaryType()) |
| 4516 | 5317 | { |
| 4517 | 5318 | case 'multipart': |
| 4518 | - if ($part->getDisposition() == 'attachment') continue; |
|
| 5319 | + if ($part->getDisposition() == 'attachment') |
|
| 5320 | + { |
|
| 5321 | + continue; |
|
| 5322 | + } |
|
| 4519 | 5323 | switch($part->getSubType()) |
| 4520 | 5324 | { |
| 4521 | 5325 | case 'alternative': |
@@ -4580,7 +5384,9 @@ discard block |
||
| 4580 | 5384 | if($part->getSubType() == 'rfc822' || $part->getDisposition() == 'attachment') |
| 4581 | 5385 | { |
| 4582 | 5386 | $skipParts[$mime_id.'.0'] = $mime_type; |
| 4583 | - foreach($part->contentTypeMap() as $sub_id => $sub_type){ $skipParts[$sub_id] = $sub_type;} |
|
| 5387 | + foreach($part->contentTypeMap() as $sub_id => $sub_type) |
|
| 5388 | + { |
|
| 5389 | +$skipParts[$sub_id] = $sub_type;} |
|
| 4584 | 5390 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$_uid.' Part:'.$mime_id.':'.array2string($skipParts)); |
| 4585 | 5391 | //break 2; |
| 4586 | 5392 | } |
@@ -4623,7 +5429,10 @@ discard block |
||
| 4623 | 5429 | */ |
| 4624 | 5430 | function getBodyPart($_uid, $_partID=null, $_folder=null, $_preserveSeen=false, $_stream=false, &$_encoding=null, $_tryDecodingServerside=true) |
| 4625 | 5431 | { |
| 4626 | - if (self::$debug) error_log( __METHOD__.__LINE__."(".array2string($_uid).", $_partID, $_folder, $_preserveSeen, $_stream, $_encoding, $_tryDecodingServerside)"); |
|
| 5432 | + if (self::$debug) |
|
| 5433 | + { |
|
| 5434 | + error_log( __METHOD__.__LINE__."(".array2string($_uid).", $_partID, $_folder, $_preserveSeen, $_stream, $_encoding, $_tryDecodingServerside)"); |
|
| 5435 | + } |
|
| 4627 | 5436 | |
| 4628 | 5437 | if (empty($_folder)) |
| 4629 | 5438 | { |
@@ -4632,7 +5441,10 @@ discard block |
||
| 4632 | 5441 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($_folder).'/'.$this->icServer->getCurrentMailbox().'/'. $this->sessionData['mailbox']); |
| 4633 | 5442 | // querying contents of body part |
| 4634 | 5443 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 4635 | - if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
|
| 5444 | + if (!(is_object($_uid) || is_array($_uid))) |
|
| 5445 | + { |
|
| 5446 | + $_uid = (array)$_uid; |
|
| 5447 | + } |
|
| 4636 | 5448 | $uidsToFetch->add($_uid); |
| 4637 | 5449 | |
| 4638 | 5450 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
@@ -4640,9 +5452,12 @@ discard block |
||
| 4640 | 5452 | 'peek' => $_preserveSeen, |
| 4641 | 5453 | 'decode' => true, // try decode on server, does NOT neccessary work |
| 4642 | 5454 | ); |
| 4643 | - if ($_tryDecodingServerside===false)// || ($_tryDecodingServerside&&$this->isDraftFolder($_folder))) |
|
| 5455 | + if ($_tryDecodingServerside===false) |
|
| 5456 | + { |
|
| 5457 | + // || ($_tryDecodingServerside&&$this->isDraftFolder($_folder))) |
|
| 4644 | 5458 | { |
| 4645 | 5459 | $_tryDecodingServerside=false; |
| 5460 | + } |
|
| 4646 | 5461 | $fetchParams = array( |
| 4647 | 5462 | 'peek' => $_preserveSeen, |
| 4648 | 5463 | ); |
@@ -4684,7 +5499,10 @@ discard block |
||
| 4684 | 5499 | { |
| 4685 | 5500 | //error_log(__METHOD__.' ('.__LINE__.') '.'->'.$_uid.':'.array2string($_structure).' '.function_backtrace()); |
| 4686 | 5501 | $bodyPart = array(); |
| 4687 | - if (self::$debug) _debug_array(array($_structure,function_backtrace())); |
|
| 5502 | + if (self::$debug) |
|
| 5503 | + { |
|
| 5504 | + _debug_array(array($_structure,function_backtrace())); |
|
| 5505 | + } |
|
| 4688 | 5506 | |
| 4689 | 5507 | if($_structure->getSubType() == 'html' && !in_array($_htmlMode, array('html_only', 'always_display', 'only_if_no_text'))) |
| 4690 | 5508 | { |
@@ -4734,8 +5552,12 @@ discard block |
||
| 4734 | 5552 | */ |
| 4735 | 5553 | function getMessageBody($_uid, $_htmlOptions='', $_partID=null, Horde_Mime_Part $_structure=null, $_preserveSeen = false, $_folder = '') |
| 4736 | 5554 | { |
| 4737 | - if (self::$debug) echo __METHOD__."$_uid, $_htmlOptions, $_partID<br>"; |
|
| 4738 | - if($_htmlOptions != '') { |
|
| 5555 | + if (self::$debug) |
|
| 5556 | + { |
|
| 5557 | + echo __METHOD__."$_uid, $_htmlOptions, $_partID<br>"; |
|
| 5558 | + } |
|
| 5559 | + if($_htmlOptions != '') |
|
| 5560 | + { |
|
| 4739 | 5561 | $this->htmlOptions = $_htmlOptions; |
| 4740 | 5562 | } |
| 4741 | 5563 | if (empty($_folder)) |
@@ -4824,7 +5646,9 @@ discard block |
||
| 4824 | 5646 | default: |
| 4825 | 5647 | $bodyPart = array($this->getTextPart($_uid, $_structure, $this->htmlOptions, $_preserveSeen)); |
| 4826 | 5648 | } |
| 4827 | - } else { |
|
| 5649 | + } |
|
| 5650 | + else |
|
| 5651 | + { |
|
| 4828 | 5652 | // what if the structure->disposition is attachment ,... |
| 4829 | 5653 | } |
| 4830 | 5654 | return self::normalizeBodyParts($bodyPart); |
@@ -4835,13 +5659,18 @@ discard block |
||
| 4835 | 5659 | { |
| 4836 | 5660 | case 'rfc822': |
| 4837 | 5661 | $newStructure = $_structure->getParts(); |
| 4838 | - if (self::$debug) {echo __METHOD__." Message -> RFC -> NewStructure:"; _debug_array($newStructure[0]);} |
|
| 5662 | + if (self::$debug) |
|
| 5663 | + { |
|
| 5664 | +echo __METHOD__." Message -> RFC -> NewStructure:"; _debug_array($newStructure[0]);} |
|
| 4839 | 5665 | return self::normalizeBodyParts($this->getMessageBody($_uid, $_htmlOptions, $newStructure[0]->getMimeId(), $newStructure[0], $_preserveSeen, $_folder)); |
| 4840 | 5666 | } |
| 4841 | 5667 | break; |
| 4842 | 5668 | |
| 4843 | 5669 | default: |
| 4844 | - if (self::$debug) _debug_array($_structure); |
|
| 5670 | + if (self::$debug) |
|
| 5671 | + { |
|
| 5672 | + _debug_array($_structure); |
|
| 5673 | + } |
|
| 4845 | 5674 | return array( |
| 4846 | 5675 | array( |
| 4847 | 5676 | 'body' => lang('The mimeparser can not parse this message.').$_structure->getType(), |
@@ -4865,9 +5694,12 @@ discard block |
||
| 4865 | 5694 | { |
| 4866 | 5695 | foreach($_bodyParts as $singleBodyPart) |
| 4867 | 5696 | { |
| 4868 | - if (!isset($singleBodyPart['body'])) { |
|
| 5697 | + if (!isset($singleBodyPart['body'])) |
|
| 5698 | + { |
|
| 4869 | 5699 | $buff = self::normalizeBodyParts($singleBodyPart); |
| 4870 | - foreach ((array)$buff as $val) { $body2return[] = $val;} |
|
| 5700 | + foreach ((array)$buff as $val) |
|
| 5701 | + { |
|
| 5702 | +$body2return[] = $val;} |
|
| 4871 | 5703 | continue; |
| 4872 | 5704 | } |
| 4873 | 5705 | $body2return[] = $singleBodyPart; |
@@ -4893,13 +5725,20 @@ discard block |
||
| 4893 | 5725 | $message=''; |
| 4894 | 5726 | for($i=0; $i<count($bodyParts); $i++) |
| 4895 | 5727 | { |
| 4896 | - if (!isset($bodyParts[$i]['body'])) { |
|
| 5728 | + if (!isset($bodyParts[$i]['body'])) |
|
| 5729 | + { |
|
| 4897 | 5730 | $bodyParts[$i]['body'] = self::getdisplayableBody($mailClass, $bodyParts[$i], $preserveHTML, $useTidy); |
| 4898 | 5731 | $message .= empty($bodyParts[$i]['body'])?'':$bodyParts[$i]['body']; |
| 4899 | 5732 | continue; |
| 4900 | 5733 | } |
| 4901 | - if (isset($bodyParts[$i]['error'])) continue; |
|
| 4902 | - if (empty($bodyParts[$i]['body'])) continue; |
|
| 5734 | + if (isset($bodyParts[$i]['error'])) |
|
| 5735 | + { |
|
| 5736 | + continue; |
|
| 5737 | + } |
|
| 5738 | + if (empty($bodyParts[$i]['body'])) |
|
| 5739 | + { |
|
| 5740 | + continue; |
|
| 5741 | + } |
|
| 4903 | 5742 | // some characterreplacements, as they fail to translate |
| 4904 | 5743 | $sar = array( |
| 4905 | 5744 | '@(\x84|\x93|\x94)@', |
@@ -4926,13 +5765,17 @@ discard block |
||
| 4926 | 5765 | $bodyParts[$i]['body'] = preg_replace($sar,$rar,$bodyParts[$i]['body']); |
| 4927 | 5766 | } |
| 4928 | 5767 | |
| 4929 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Translation::detect_encoding($bodyParts[$i]['body']); |
|
| 5768 | + if ($bodyParts[$i]['charSet']===false) |
|
| 5769 | + { |
|
| 5770 | + $bodyParts[$i]['charSet'] = Translation::detect_encoding($bodyParts[$i]['body']); |
|
| 5771 | + } |
|
| 4930 | 5772 | // add line breaks to $bodyParts |
| 4931 | 5773 | //error_log(__METHOD__.' ('.__LINE__.') '.' Charset:'.$bodyParts[$i]['charSet'].'->'.$bodyParts[$i]['body']); |
| 4932 | 5774 | $newBody = Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
| 4933 | 5775 | //error_log(__METHOD__.' ('.__LINE__.') '.' MimeType:'.$bodyParts[$i]['mimeType'].'->'.$newBody); |
| 4934 | 5776 | $mailClass->activeMimeType = 'text/plain'; |
| 4935 | - if ($bodyParts[$i]['mimeType'] == 'text/html') { |
|
| 5777 | + if ($bodyParts[$i]['mimeType'] == 'text/html') |
|
| 5778 | + { |
|
| 4936 | 5779 | $mailClass->activeMimeType = $bodyParts[$i]['mimeType']; |
| 4937 | 5780 | if (!$preserveHTML) |
| 4938 | 5781 | { |
@@ -4978,15 +5821,28 @@ discard block |
||
| 4978 | 5821 | // as we switched off HTMLaweds tidy functionality |
| 4979 | 5822 | $newBody = str_replace(array('&amp;','<DIV><BR></DIV>',"<DIV> </DIV>",'<div> </div>'),array('&','<BR>','<BR>','<BR>'),$newBody); |
| 4980 | 5823 | $newBody = $htmLawed->run($newBody,self::$htmLawed_config); |
| 4981 | - if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3]; |
|
| 5824 | + if ($hasOther && $preserveHTML) |
|
| 5825 | + { |
|
| 5826 | + $newBody = $matches[1]. $newBody. $matches[3]; |
|
| 5827 | + } |
|
| 4982 | 5828 | $alreadyHtmlLawed=true; |
| 4983 | 5829 | } |
| 4984 | 5830 | //error_log(__METHOD__.' ('.__LINE__.') '.' after purify:'.$newBody); |
| 4985 | - if ($preserveHTML==false) $newBody = Mail\Html::convertHTMLToText($newBody,self::$displayCharset,true,true); |
|
| 5831 | + if ($preserveHTML==false) |
|
| 5832 | + { |
|
| 5833 | + $newBody = Mail\Html::convertHTMLToText($newBody,self::$displayCharset,true,true); |
|
| 5834 | + } |
|
| 4986 | 5835 | //error_log(__METHOD__.' ('.__LINE__.') '.' after convertHTMLToText:'.$newBody); |
| 4987 | - if ($preserveHTML==false) $newBody = nl2br($newBody); // we need this, as htmLawed removes \r\n |
|
| 5836 | + if ($preserveHTML==false) |
|
| 5837 | + { |
|
| 5838 | + $newBody = nl2br($newBody); |
|
| 5839 | + } |
|
| 5840 | + // we need this, as htmLawed removes \r\n |
|
| 4988 | 5841 | /*if (!$alreadyHtmlLawed) */ $mailClass->getCleanHTML($newBody); // remove stuff we regard as unwanted |
| 4989 | - if ($preserveHTML==false) $newBody = str_replace("<br />","\r\n",$newBody); |
|
| 5842 | + if ($preserveHTML==false) |
|
| 5843 | + { |
|
| 5844 | + $newBody = str_replace("<br />","\r\n",$newBody); |
|
| 5845 | + } |
|
| 4990 | 5846 | //error_log(__METHOD__.' ('.__LINE__.') '.' after getClean:'.$newBody); |
| 4991 | 5847 | } |
| 4992 | 5848 | $message .= $newBody; |
@@ -5023,12 +5879,12 @@ discard block |
||
| 5023 | 5879 | substr($line,0,strlen($dontbreaklinesstartingwith)) != $dontbreaklinesstartingwith |
| 5024 | 5880 | ) |
| 5025 | 5881 | ) |
| 5026 | - ) |
|
| 5027 | - { |
|
| 5882 | + ) { |
|
| 5028 | 5883 | $s=explode(" ", $line); |
| 5029 | 5884 | $line = ""; |
| 5030 | 5885 | $linecnt = 0; |
| 5031 | - foreach ($s as &$v) { |
|
| 5886 | + foreach ($s as &$v) |
|
| 5887 | + { |
|
| 5032 | 5888 | $cnt = strlen($v); |
| 5033 | 5889 | // only break long words within the wordboundaries, |
| 5034 | 5890 | // but it may destroy links, so we check for href and dont do it if we find one |
@@ -5038,14 +5894,20 @@ discard block |
||
| 5038 | 5894 | $v=wordwrap($v, $allowedLength, $cut, true); |
| 5039 | 5895 | } |
| 5040 | 5896 | // the rest should be broken at the start of the new word that exceeds the limit |
| 5041 | - if ($linecnt+$cnt > $allowedLength) { |
|
| 5897 | + if ($linecnt+$cnt > $allowedLength) |
|
| 5898 | + { |
|
| 5042 | 5899 | $v=$cut.$v; |
| 5043 | 5900 | #$linecnt = 0; |
| 5044 | 5901 | $linecnt =strlen($v)-strlen($cut); |
| 5045 | - } else { |
|
| 5902 | + } |
|
| 5903 | + else |
|
| 5904 | + { |
|
| 5046 | 5905 | $linecnt += $cnt; |
| 5047 | 5906 | } |
| 5048 | - if (strlen($v)) $line .= (strlen($line) ? " " : "").$v; |
|
| 5907 | + if (strlen($v)) |
|
| 5908 | + { |
|
| 5909 | + $line .= (strlen($line) ? " " : "").$v; |
|
| 5910 | + } |
|
| 5049 | 5911 | } |
| 5050 | 5912 | } |
| 5051 | 5913 | $newStr .= $line . "\n"; |
@@ -5066,11 +5928,18 @@ discard block |
||
| 5066 | 5928 | function getMessageEnvelope($_uid, $_partID = '',$decode=false, $_folder='', $_useHeaderInsteadOfEnvelope=false) |
| 5067 | 5929 | { |
| 5068 | 5930 | //error_log(__METHOD__.' ('.__LINE__.') '.":$_uid,$_partID,$decode,$_folder".function_backtrace()); |
| 5069 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5931 | + if (empty($_folder)) |
|
| 5932 | + { |
|
| 5933 | + $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 5934 | + } |
|
| 5070 | 5935 | //error_log(__METHOD__.' ('.__LINE__.') '.":$_uid,$_partID,$decode,$_folder"); |
| 5071 | - if((empty($_partID)||$_partID=='null')&&$_useHeaderInsteadOfEnvelope===false) { |
|
| 5936 | + if((empty($_partID)||$_partID=='null')&&$_useHeaderInsteadOfEnvelope===false) |
|
| 5937 | + { |
|
| 5072 | 5938 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5073 | - if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
|
| 5939 | + if (!(is_object($_uid) || is_array($_uid))) |
|
| 5940 | + { |
|
| 5941 | + $_uid = (array)$_uid; |
|
| 5942 | + } |
|
| 5074 | 5943 | $uidsToFetch->add($_uid); |
| 5075 | 5944 | |
| 5076 | 5945 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
@@ -5080,8 +5949,10 @@ discard block |
||
| 5080 | 5949 | $headersNew = $this->icServer->fetch($_folder, $fquery, array( |
| 5081 | 5950 | 'ids' => $uidsToFetch, |
| 5082 | 5951 | )); |
| 5083 | - if (is_object($headersNew)) { |
|
| 5084 | - foreach($headersNew as &$_headerObject) { |
|
| 5952 | + if (is_object($headersNew)) |
|
| 5953 | + { |
|
| 5954 | + foreach($headersNew as &$_headerObject) |
|
| 5955 | + { |
|
| 5085 | 5956 | $env = $_headerObject->getEnvelope(); |
| 5086 | 5957 | //_debug_array($envFields->singleFields()); |
| 5087 | 5958 | $singleFields = $envFields->singleFields(); |
@@ -5098,7 +5969,10 @@ discard block |
||
| 5098 | 5969 | //error_log(__METHOD__.' ('.__LINE__.') '.$v.'->'.array2string($env->$v->addresses)); |
| 5099 | 5970 | $envelope[$v]=$env->$v->addresses; |
| 5100 | 5971 | $address = array(); |
| 5101 | - if (!is_array($envelope[$v])) break; |
|
| 5972 | + if (!is_array($envelope[$v])) |
|
| 5973 | + { |
|
| 5974 | + break; |
|
| 5975 | + } |
|
| 5102 | 5976 | foreach ($envelope[$v] as $k => $ad) |
| 5103 | 5977 | { |
| 5104 | 5978 | if (stripos($ad,'@')===false) |
@@ -5135,7 +6009,9 @@ discard block |
||
| 5135 | 6009 | } |
| 5136 | 6010 | } |
| 5137 | 6011 | return $envelope; |
| 5138 | - } else { |
|
| 6012 | + } |
|
| 6013 | + else |
|
| 6014 | + { |
|
| 5139 | 6015 | |
| 5140 | 6016 | $headers = $this->getMessageHeader($_uid, $_partID, true,true,$_folder); |
| 5141 | 6017 | |
@@ -5146,19 +6022,43 @@ discard block |
||
| 5146 | 6022 | 'SUBJECT' => ($decode ? self::decode_header($headers['SUBJECT']):$headers['SUBJECT']), |
| 5147 | 6023 | 'MESSAGE_ID' => $headers['MESSAGE-ID'] |
| 5148 | 6024 | ); |
| 5149 | - if (isset($headers['IN-REPLY-TO'])) $newData['IN-REPLY-TO'] = $headers['IN-REPLY-TO']; |
|
| 5150 | - if (isset($headers['REFERENCES'])) $newData['REFERENCES'] = $headers['REFERENCES']; |
|
| 5151 | - if (isset($headers['THREAD-TOPIC'])) $newData['THREAD-TOPIC'] = $headers['THREAD-TOPIC']; |
|
| 5152 | - if (isset($headers['THREAD-INDEX'])) $newData['THREAD-INDEX'] = $headers['THREAD-INDEX']; |
|
| 5153 | - if (isset($headers['LIST-ID'])) $newData['LIST-ID'] = $headers['LIST-ID']; |
|
| 5154 | - if (isset($headers['SIZE'])) $newData['SIZE'] = $headers['SIZE']; |
|
| 6025 | + if (isset($headers['IN-REPLY-TO'])) |
|
| 6026 | + { |
|
| 6027 | + $newData['IN-REPLY-TO'] = $headers['IN-REPLY-TO']; |
|
| 6028 | + } |
|
| 6029 | + if (isset($headers['REFERENCES'])) |
|
| 6030 | + { |
|
| 6031 | + $newData['REFERENCES'] = $headers['REFERENCES']; |
|
| 6032 | + } |
|
| 6033 | + if (isset($headers['THREAD-TOPIC'])) |
|
| 6034 | + { |
|
| 6035 | + $newData['THREAD-TOPIC'] = $headers['THREAD-TOPIC']; |
|
| 6036 | + } |
|
| 6037 | + if (isset($headers['THREAD-INDEX'])) |
|
| 6038 | + { |
|
| 6039 | + $newData['THREAD-INDEX'] = $headers['THREAD-INDEX']; |
|
| 6040 | + } |
|
| 6041 | + if (isset($headers['LIST-ID'])) |
|
| 6042 | + { |
|
| 6043 | + $newData['LIST-ID'] = $headers['LIST-ID']; |
|
| 6044 | + } |
|
| 6045 | + if (isset($headers['SIZE'])) |
|
| 6046 | + { |
|
| 6047 | + $newData['SIZE'] = $headers['SIZE']; |
|
| 6048 | + } |
|
| 5155 | 6049 | //_debug_array($newData); |
| 5156 | 6050 | $recepientList = array('FROM', 'TO', 'CC', 'BCC', 'SENDER', 'REPLY-TO'); |
| 5157 | - foreach($recepientList as $recepientType) { |
|
| 5158 | - if(isset($headers[$recepientType])) { |
|
| 5159 | - if ($decode) $headers[$recepientType] = self::decode_header($headers[$recepientType],true); |
|
| 6051 | + foreach($recepientList as $recepientType) |
|
| 6052 | + { |
|
| 6053 | + if(isset($headers[$recepientType])) |
|
| 6054 | + { |
|
| 6055 | + if ($decode) |
|
| 6056 | + { |
|
| 6057 | + $headers[$recepientType] = self::decode_header($headers[$recepientType],true); |
|
| 6058 | + } |
|
| 5160 | 6059 | //error_log(__METHOD__.__LINE__." ".$recepientType."->".array2string($headers[$recepientType])); |
| 5161 | - foreach(self::parseAddressList($headers[$recepientType]) as $singleAddress) { |
|
| 6060 | + foreach(self::parseAddressList($headers[$recepientType]) as $singleAddress) |
|
| 6061 | + { |
|
| 5162 | 6062 | $addressData = array( |
| 5163 | 6063 | 'PERSONAL_NAME' => $singleAddress->personal ? $singleAddress->personal : 'NIL', |
| 5164 | 6064 | 'AT_DOMAIN_LIST' => $singleAddress->adl ? $singleAddress->adl : 'NIL', |
@@ -5166,17 +6066,25 @@ discard block |
||
| 5166 | 6066 | 'HOST_NAME' => $singleAddress->host ? $singleAddress->host : 'NIL', |
| 5167 | 6067 | 'EMAIL' => $singleAddress->host ? $singleAddress->mailbox.'@'.$singleAddress->host : $singleAddress->mailbox, |
| 5168 | 6068 | ); |
| 5169 | - if($addressData['PERSONAL_NAME'] != 'NIL') { |
|
| 6069 | + if($addressData['PERSONAL_NAME'] != 'NIL') |
|
| 6070 | + { |
|
| 5170 | 6071 | $addressData['RFC822_EMAIL'] = imap_rfc822_write_address($singleAddress->mailbox, $singleAddress->host, $singleAddress->personal); |
| 5171 | - } else { |
|
| 6072 | + } |
|
| 6073 | + else |
|
| 6074 | + { |
|
| 5172 | 6075 | $addressData['RFC822_EMAIL'] = 'NIL'; |
| 5173 | 6076 | } |
| 5174 | 6077 | $newData[$recepientType][] = ($addressData['RFC822_EMAIL']!='NIL'?$addressData['RFC822_EMAIL']:$addressData['EMAIL']);//$addressData; |
| 5175 | 6078 | } |
| 5176 | - } else { |
|
| 5177 | - if($recepientType == 'SENDER' || $recepientType == 'REPLY-TO') { |
|
| 6079 | + } |
|
| 6080 | + else |
|
| 6081 | + { |
|
| 6082 | + if($recepientType == 'SENDER' || $recepientType == 'REPLY-TO') |
|
| 6083 | + { |
|
| 5178 | 6084 | $newData[$recepientType] = $newData['FROM']; |
| 5179 | - } else { |
|
| 6085 | + } |
|
| 6086 | + else |
|
| 6087 | + { |
|
| 5180 | 6088 | $newData[$recepientType] = array(); |
| 5181 | 6089 | } |
| 5182 | 6090 | } |
@@ -5199,9 +6107,15 @@ discard block |
||
| 5199 | 6107 | function getMessageHeader($_uid, $_partID = '',$decode=false, $preserveUnSeen=false, $_folder='') |
| 5200 | 6108 | { |
| 5201 | 6109 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.$_uid.', '.$_partID.', '.$decode.', '.$preserveUnSeen.', '.$_folder); |
| 5202 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6110 | + if (empty($_folder)) |
|
| 6111 | + { |
|
| 6112 | + $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6113 | + } |
|
| 5203 | 6114 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5204 | - if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
|
| 6115 | + if (!(is_object($_uid) || is_array($_uid))) |
|
| 6116 | + { |
|
| 6117 | + $_uid = (array)$_uid; |
|
| 6118 | + } |
|
| 5205 | 6119 | $uidsToFetch->add($_uid); |
| 5206 | 6120 | |
| 5207 | 6121 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
@@ -5219,7 +6133,8 @@ discard block |
||
| 5219 | 6133 | $headersNew = $this->icServer->fetch($_folder, $fquery, array( |
| 5220 | 6134 | 'ids' => $uidsToFetch, |
| 5221 | 6135 | )); |
| 5222 | - if (is_object($headersNew)) { |
|
| 6136 | + if (is_object($headersNew)) |
|
| 6137 | + { |
|
| 5223 | 6138 | foreach($headersNew as $_fetchObject) |
| 5224 | 6139 | { |
| 5225 | 6140 | $headers = $_fetchObject->getHeaderText(0,Horde_Imap_Client_Data_Fetch::HEADER_PARSE); |
@@ -5241,11 +6156,17 @@ discard block |
||
| 5241 | 6156 | } |
| 5242 | 6157 | if ($decode === 'object') |
| 5243 | 6158 | { |
| 5244 | - if (is_object($headers)) $headers->setUserAgent('EGroupware API '.$GLOBALS['egw_info']['server']['versions']['phpgwapi']); |
|
| 6159 | + if (is_object($headers)) |
|
| 6160 | + { |
|
| 6161 | + $headers->setUserAgent('EGroupware API '.$GLOBALS['egw_info']['server']['versions']['phpgwapi']); |
|
| 6162 | + } |
|
| 5245 | 6163 | return $headers; |
| 5246 | 6164 | } |
| 5247 | 6165 | $retValue = is_object($headers) ? $headers->toArray():array(); |
| 5248 | - if ($size) $retValue['size'] = $size; |
|
| 6166 | + if ($size) |
|
| 6167 | + { |
|
| 6168 | + $retValue['size'] = $size; |
|
| 6169 | + } |
|
| 5249 | 6170 | } |
| 5250 | 6171 | $retValue = array_change_key_case($retValue,CASE_UPPER); |
| 5251 | 6172 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($retValue)); |
@@ -5277,10 +6198,16 @@ discard block |
||
| 5277 | 6198 | function getMessageRawHeader($_uid, $_partID = '', $_folder = '') |
| 5278 | 6199 | { |
| 5279 | 6200 | static $rawHeaders; |
| 5280 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6201 | + if (empty($_folder)) |
|
| 6202 | + { |
|
| 6203 | + $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6204 | + } |
|
| 5281 | 6205 | //error_log(__METHOD__.' ('.__LINE__.') '." Try Using Cache for raw Header $_uid, $_partID in Folder $_folder"); |
| 5282 | 6206 | |
| 5283 | - 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); |
|
| 6207 | + if (is_null($rawHeaders)||!is_array($rawHeaders)) |
|
| 6208 | + { |
|
| 6209 | + $rawHeaders = Cache::getCache(Cache::INSTANCE,'email','rawHeadersCache'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),60*60*1); |
|
| 6210 | + } |
|
| 5284 | 6211 | if (isset($rawHeaders[$this->icServer->ImapServerId][(string)$_folder][$_uid][(empty($_partID)?'NIL':$_partID)])) |
| 5285 | 6212 | { |
| 5286 | 6213 | //error_log(__METHOD__.' ('.__LINE__.') '." Using Cache for raw Header $_uid, $_partID in Folder $_folder"); |
@@ -5288,7 +6215,10 @@ discard block |
||
| 5288 | 6215 | } |
| 5289 | 6216 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5290 | 6217 | $uid = $_uid; |
| 5291 | - if (!(is_object($_uid) || is_array($_uid))) $uid = (array)$_uid; |
|
| 6218 | + if (!(is_object($_uid) || is_array($_uid))) |
|
| 6219 | + { |
|
| 6220 | + $uid = (array)$_uid; |
|
| 6221 | + } |
|
| 5292 | 6222 | $uidsToFetch->add($uid); |
| 5293 | 6223 | |
| 5294 | 6224 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
@@ -5304,8 +6234,10 @@ discard block |
||
| 5304 | 6234 | $headersNew = $this->icServer->fetch($_folder, $fquery, array( |
| 5305 | 6235 | 'ids' => $uidsToFetch, |
| 5306 | 6236 | )); |
| 5307 | - if (is_object($headersNew)) { |
|
| 5308 | - foreach($headersNew as &$_headerObject) { |
|
| 6237 | + if (is_object($headersNew)) |
|
| 6238 | + { |
|
| 6239 | + foreach($headersNew as &$_headerObject) |
|
| 6240 | + { |
|
| 5309 | 6241 | $retValue = $_headerObject->getHeaderText(); |
| 5310 | 6242 | if ($_partID != '') |
| 5311 | 6243 | { |
@@ -5333,22 +6265,33 @@ discard block |
||
| 5333 | 6265 | static function &getStyles($_bodyParts) |
| 5334 | 6266 | { |
| 5335 | 6267 | $style = ''; |
| 5336 | - if (empty($_bodyParts)) return ""; |
|
| 5337 | - foreach((array)$_bodyParts as $singleBodyPart) { |
|
| 5338 | - if (!isset($singleBodyPart['body'])) { |
|
| 6268 | + if (empty($_bodyParts)) |
|
| 6269 | + { |
|
| 6270 | + return ""; |
|
| 6271 | + } |
|
| 6272 | + foreach((array)$_bodyParts as $singleBodyPart) |
|
| 6273 | + { |
|
| 6274 | + if (!isset($singleBodyPart['body'])) |
|
| 6275 | + { |
|
| 5339 | 6276 | $singleBodyPart['body'] = self::getStyles($singleBodyPart); |
| 5340 | 6277 | $style .= $singleBodyPart['body']; |
| 5341 | 6278 | continue; |
| 5342 | 6279 | } |
| 5343 | 6280 | |
| 5344 | - if ($singleBodyPart['charSet']===false) $singleBodyPart['charSet'] = Translation::detect_encoding($singleBodyPart['body']); |
|
| 6281 | + if ($singleBodyPart['charSet']===false) |
|
| 6282 | + { |
|
| 6283 | + $singleBodyPart['charSet'] = Translation::detect_encoding($singleBodyPart['body']); |
|
| 6284 | + } |
|
| 5345 | 6285 | $singleBodyPart['body'] = Translation::convert( |
| 5346 | 6286 | $singleBodyPart['body'], |
| 5347 | 6287 | strtolower($singleBodyPart['charSet']) |
| 5348 | 6288 | ); |
| 5349 | 6289 | $ct = 0; |
| 5350 | 6290 | $newStyle=array(); |
| 5351 | - if (stripos($singleBodyPart['body'],'<style')!==false) $ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $singleBodyPart['body'], $newStyle); |
|
| 6291 | + if (stripos($singleBodyPart['body'],'<style')!==false) |
|
| 6292 | + { |
|
| 6293 | + $ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $singleBodyPart['body'], $newStyle); |
|
| 6294 | + } |
|
| 5352 | 6295 | if ($ct>0) |
| 5353 | 6296 | { |
| 5354 | 6297 | //error_log(__METHOD__.' ('.__LINE__.') '.'#'.$ct.'#'.array2string($newStyle)); |
@@ -5380,7 +6323,11 @@ discard block |
||
| 5380 | 6323 | // CSS Security |
| 5381 | 6324 | // http://code.google.com/p/browsersec/wiki/Part1#Cascading_stylesheets |
| 5382 | 6325 | $css = preg_replace('/(javascript|expression|-moz-binding)/i','',$style); |
| 5383 | - if (stripos($css,'script')!==false) Mail\Html::replaceTagsCompletley($css,'script'); // Strip out script that may be included |
|
| 6326 | + if (stripos($css,'script')!==false) |
|
| 6327 | + { |
|
| 6328 | + Mail\Html::replaceTagsCompletley($css,'script'); |
|
| 6329 | + } |
|
| 6330 | + // Strip out script that may be included |
|
| 5384 | 6331 | // 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 |
| 5385 | 6332 | // as the comments as <!-- styledefinition --> in stylesheet are outdated, and ck-editor does not understand it, we remove it |
| 5386 | 6333 | $css = str_replace(array(':','<!--','-->'),array(': ','',''),$css); |
@@ -5401,8 +6348,14 @@ discard block |
||
| 5401 | 6348 | { |
| 5402 | 6349 | //TODO: caching einbauen static! |
| 5403 | 6350 | static $rawBody; |
| 5404 | - if (is_null($rawBody)) $rawBody = array(); |
|
| 5405 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6351 | + if (is_null($rawBody)) |
|
| 6352 | + { |
|
| 6353 | + $rawBody = array(); |
|
| 6354 | + } |
|
| 6355 | + if (empty($_folder)) |
|
| 6356 | + { |
|
| 6357 | + $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6358 | + } |
|
| 5406 | 6359 | if (isset($rawBody[$this->icServer->ImapServerId][$_folder][$_uid][(empty($_partID)?'NIL':$_partID)])) |
| 5407 | 6360 | { |
| 5408 | 6361 | //error_log(__METHOD__.' ('.__LINE__.') '." Using Cache for raw Body $_uid, $_partID in Folder $_folder"); |
@@ -5411,7 +6364,10 @@ discard block |
||
| 5411 | 6364 | |
| 5412 | 6365 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5413 | 6366 | $uid = $_uid; |
| 5414 | - if (!(is_object($_uid) || is_array($_uid))) $uid = (array)$_uid; |
|
| 6367 | + if (!(is_object($_uid) || is_array($_uid))) |
|
| 6368 | + { |
|
| 6369 | + $uid = (array)$_uid; |
|
| 6370 | + } |
|
| 5415 | 6371 | $uidsToFetch->add($uid); |
| 5416 | 6372 | |
| 5417 | 6373 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
@@ -5424,8 +6380,10 @@ discard block |
||
| 5424 | 6380 | $headersNew = $this->icServer->fetch($_folder, $fquery, array( |
| 5425 | 6381 | 'ids' => $uidsToFetch, |
| 5426 | 6382 | )); |
| 5427 | - if (is_object($headersNew)) { |
|
| 5428 | - foreach($headersNew as &$_headerObject) { |
|
| 6383 | + if (is_object($headersNew)) |
|
| 6384 | + { |
|
| 6385 | + foreach($headersNew as &$_headerObject) |
|
| 6386 | + { |
|
| 5429 | 6387 | $body = $_headerObject->getFullMsg(); |
| 5430 | 6388 | if ($_partID != '') |
| 5431 | 6389 | { |
@@ -5458,14 +6416,20 @@ discard block |
||
| 5458 | 6416 | */ |
| 5459 | 6417 | function getStructure($_uid, $_partID=null, $_folder=null, $_preserveSeen=false) |
| 5460 | 6418 | { |
| 5461 | - if (self::$debug) error_log( __METHOD__.' ('.__LINE__.') '.":$_uid, $_partID"); |
|
| 6419 | + if (self::$debug) |
|
| 6420 | + { |
|
| 6421 | + error_log( __METHOD__.' ('.__LINE__.') '.":$_uid, $_partID"); |
|
| 6422 | + } |
|
| 5462 | 6423 | |
| 5463 | 6424 | if (empty($_folder)) |
| 5464 | 6425 | { |
| 5465 | 6426 | $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
| 5466 | 6427 | } |
| 5467 | 6428 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5468 | - if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
|
| 6429 | + if (!(is_object($_uid) || is_array($_uid))) |
|
| 6430 | + { |
|
| 6431 | + $_uid = (array)$_uid; |
|
| 6432 | + } |
|
| 5469 | 6433 | $uidsToFetch->add($_uid); |
| 5470 | 6434 | try |
| 5471 | 6435 | { |
@@ -5474,7 +6438,10 @@ discard block |
||
| 5474 | 6438 | // $fquery->envelope(); |
| 5475 | 6439 | // $fquery->size(); |
| 5476 | 6440 | $_fquery->structure(); |
| 5477 | - if ($_partID) $_fquery->bodyPart($_partID, array('peek' => $_preserveSeen)); |
|
| 6441 | + if ($_partID) |
|
| 6442 | + { |
|
| 6443 | + $_fquery->bodyPart($_partID, array('peek' => $_preserveSeen)); |
|
| 6444 | + } |
|
| 5478 | 6445 | |
| 5479 | 6446 | $mail = $this->icServer->fetch($_folder, $_fquery, array( |
| 5480 | 6447 | 'ids' => $uidsToFetch, |
@@ -5505,16 +6472,28 @@ discard block |
||
| 5505 | 6472 | */ |
| 5506 | 6473 | function getMessageAttachments($_uid, $_partID=null, Horde_Mime_Part $_structure=null, $fetchEmbeddedImages=true, $fetchTextCalendar=false, $resolveTNEF=true, $_folder='') |
| 5507 | 6474 | { |
| 5508 | - if (self::$debug) error_log( __METHOD__.":$_uid, $_partID"); |
|
| 5509 | - if (empty($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6475 | + if (self::$debug) |
|
| 6476 | + { |
|
| 6477 | + error_log( __METHOD__.":$_uid, $_partID"); |
|
| 6478 | + } |
|
| 6479 | + if (empty($_folder)) |
|
| 6480 | + { |
|
| 6481 | + $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6482 | + } |
|
| 5510 | 6483 | $attachments = array(); |
| 5511 | 6484 | if (!isset($_structure)) |
| 5512 | 6485 | { |
| 5513 | 6486 | $_structure = $this->getStructure($_uid, $_partID,$_folder,true); |
| 5514 | 6487 | //error_log(__METHOD__.' ('.__LINE__.') '.':'.print_r($_structure->contentTypeMap(),true)); |
| 5515 | 6488 | } |
| 5516 | - if (!$_structure || !$_structure->contentTypeMap()) return array(); |
|
| 5517 | - if (!empty($_partID)) $_structure = $_structure->getPart($_partID); |
|
| 6489 | + if (!$_structure || !$_structure->contentTypeMap()) |
|
| 6490 | + { |
|
| 6491 | + return array(); |
|
| 6492 | + } |
|
| 6493 | + if (!empty($_partID)) |
|
| 6494 | + { |
|
| 6495 | + $_structure = $_structure->getPart($_partID); |
|
| 6496 | + } |
|
| 5518 | 6497 | $skipParts = array(); |
| 5519 | 6498 | $tnefParts = array(); |
| 5520 | 6499 | $skip = 0; |
@@ -5543,7 +6522,13 @@ discard block |
||
| 5543 | 6522 | if ($mime_type=='message/rfc822' && $_partID!=$mime_id) |
| 5544 | 6523 | { |
| 5545 | 6524 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.'->'.$mime_id.':'.array2string($part->contentTypeMap())); |
| 5546 | - foreach($part->contentTypeMap() as $sub_id => $sub_type) {if ($sub_id != $mime_id) $skipParts[$sub_id] = $sub_type;} |
|
| 6525 | + foreach($part->contentTypeMap() as $sub_id => $sub_type) |
|
| 6526 | + { |
|
| 6527 | +if ($sub_id != $mime_id) |
|
| 6528 | + { |
|
| 6529 | + $skipParts[$sub_id] = $sub_type; |
|
| 6530 | + } |
|
| 6531 | + } |
|
| 5547 | 6532 | } |
| 5548 | 6533 | if (empty($partDisposition) && $partPrimaryType != 'multipart' && $partPrimaryType != 'text') |
| 5549 | 6534 | { |
@@ -5554,7 +6539,10 @@ discard block |
||
| 5554 | 6539 | $partDisposition='attachment'; |
| 5555 | 6540 | } |
| 5556 | 6541 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.' Part:'.$_partID.'->'.$mime_id.':'.array2string($skipParts)); |
| 5557 | - if (array_key_exists($mime_id,$skipParts)) continue; |
|
| 6542 | + if (array_key_exists($mime_id,$skipParts)) |
|
| 6543 | + { |
|
| 6544 | + continue; |
|
| 6545 | + } |
|
| 5558 | 6546 | |
| 5559 | 6547 | if ($partDisposition == 'attachment' || |
| 5560 | 6548 | (($partDisposition == 'inline' || empty($partDisposition)) && $partPrimaryType == 'image' && $part->getContentId()=='') || |
@@ -5565,23 +6553,41 @@ discard block |
||
| 5565 | 6553 | { |
| 5566 | 6554 | // if type is message/rfc822 and _partID is given, and MimeID equals partID |
| 5567 | 6555 | // we attempt to fetch "ourselves" |
| 5568 | - if ($_partID==$part->getMimeId() && $part->getPrimaryType()=='message') continue; |
|
| 6556 | + if ($_partID==$part->getMimeId() && $part->getPrimaryType()=='message') |
|
| 6557 | + { |
|
| 6558 | + continue; |
|
| 6559 | + } |
|
| 5569 | 6560 | $attachment = $part->getAllDispositionParameters(); |
| 5570 | 6561 | $attachment['disposition'] = $part->getDisposition(); |
| 5571 | 6562 | $attachment['mimeType'] = $mime_type; |
| 5572 | 6563 | $attachment['uid'] = $_uid; |
| 5573 | 6564 | $attachment['partID'] = $mime_id; |
| 5574 | - if (!isset($attachment['name'])||empty($attachment['name'])) $attachment['name'] = $part->getName(); |
|
| 6565 | + if (!isset($attachment['name'])||empty($attachment['name'])) |
|
| 6566 | + { |
|
| 6567 | + $attachment['name'] = $part->getName(); |
|
| 6568 | + } |
|
| 5575 | 6569 | if ($fetchTextCalendar) |
| 5576 | 6570 | { |
| 5577 | 6571 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($part->getAllContentTypeParameters())); |
| 5578 | 6572 | $method = $part->getContentTypeParameter('method'); |
| 5579 | - if ($method) $attachment['method'] = $method; |
|
| 5580 | - if (!isset($attachment['name'])) $attachment['name'] = 'event.ics'; |
|
| 6573 | + if ($method) |
|
| 6574 | + { |
|
| 6575 | + $attachment['method'] = $method; |
|
| 6576 | + } |
|
| 6577 | + if (!isset($attachment['name'])) |
|
| 6578 | + { |
|
| 6579 | + $attachment['name'] = 'event.ics'; |
|
| 6580 | + } |
|
| 5581 | 6581 | } |
| 5582 | 6582 | $attachment['size'] = $part->getBytes(); |
| 5583 | - if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
|
| 5584 | - 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); |
|
| 6583 | + if (($cid = $part->getContentId())) |
|
| 6584 | + { |
|
| 6585 | + $attachment['cid'] = $cid; |
|
| 6586 | + } |
|
| 6587 | + if (empty($attachment['name'])) |
|
| 6588 | + { |
|
| 6589 | + $attachment['name'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($mime_type); |
|
| 6590 | + } |
|
| 5585 | 6591 | //error_log(__METHOD__.' ('.__LINE__.') '.' Uid:'.$uid.' Part:'.$_partID.'->'.$mime_id.':'.array2string($attachment)); |
| 5586 | 6592 | //typical winmail.dat attachment is |
| 5587 | 6593 | //Array([size] => 1462762[filename] => winmail.dat[mimeType] => application/ms-tnef[uid] => 100[partID] => 2[name] => winmail.dat) |
@@ -5617,14 +6623,26 @@ discard block |
||
| 5617 | 6623 | $attachment['uid'] = $tnp['uid']; |
| 5618 | 6624 | $attachment['partID'] = $tnp['partID']; |
| 5619 | 6625 | $attachment['is_winmail'] = $tnp['uid'].'@'.$tnp['partID'].'@'.$mime_id; |
| 5620 | - if (!isset($attachment['name'])||empty($attachment['name'])) $attachment['name'] = $part->getName(); |
|
| 6626 | + if (!isset($attachment['name'])||empty($attachment['name'])) |
|
| 6627 | + { |
|
| 6628 | + $attachment['name'] = $part->getName(); |
|
| 6629 | + } |
|
| 5621 | 6630 | $attachment['size'] = $part->getBytes(); |
| 5622 | - if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
|
| 5623 | - 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']); |
|
| 6631 | + if (($cid = $part->getContentId())) |
|
| 6632 | + { |
|
| 6633 | + $attachment['cid'] = $cid; |
|
| 6634 | + } |
|
| 6635 | + if (empty($attachment['name'])) |
|
| 6636 | + { |
|
| 6637 | + $attachment['name'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']); |
|
| 6638 | + } |
|
| 5624 | 6639 | $attachments[] = $attachment; |
| 5625 | 6640 | } |
| 5626 | 6641 | } |
| 5627 | - if ($tnefResolved===false) $attachments[]=$tnp; |
|
| 6642 | + if ($tnefResolved===false) |
|
| 6643 | + { |
|
| 6644 | + $attachments[]=$tnp; |
|
| 6645 | + } |
|
| 5628 | 6646 | } |
| 5629 | 6647 | } |
| 5630 | 6648 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
@@ -5728,8 +6746,14 @@ discard block |
||
| 5728 | 6746 | |
| 5729 | 6747 | $attachment = $part->getAllDispositionParameters(); |
| 5730 | 6748 | $attachment['mimeType'] = $part->getType(); |
| 5731 | - if (!isset($attachment['filename'])||empty($attachment['filename'])) $attachment['filename'] = $part->getName(); |
|
| 5732 | - if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
|
| 6749 | + if (!isset($attachment['filename'])||empty($attachment['filename'])) |
|
| 6750 | + { |
|
| 6751 | + $attachment['filename'] = $part->getName(); |
|
| 6752 | + } |
|
| 6753 | + if (($cid = $part->getContentId())) |
|
| 6754 | + { |
|
| 6755 | + $attachment['cid'] = $cid; |
|
| 6756 | + } |
|
| 5733 | 6757 | if (empty($attachment['filename'])) |
| 5734 | 6758 | { |
| 5735 | 6759 | $attachment['filename'] = (isset($attachment['cid'])&&!empty($attachment['cid'])? |
@@ -5741,7 +6765,10 @@ discard block |
||
| 5741 | 6765 | $attachments[$_uid.'@'.$_partID.'@'.$mime_id] = $attachment; |
| 5742 | 6766 | } |
| 5743 | 6767 | } |
| 5744 | - if (!is_array($attachments)) return false; |
|
| 6768 | + if (!is_array($attachments)) |
|
| 6769 | + { |
|
| 6770 | + return false; |
|
| 6771 | + } |
|
| 5745 | 6772 | return $attachments; |
| 5746 | 6773 | } |
| 5747 | 6774 | |
@@ -5760,10 +6787,16 @@ discard block |
||
| 5760 | 6787 | function getAttachment($_uid, $_partID, $_winmail_nr=0, $_returnPart=true, $_stream=false, $_folder=null) |
| 5761 | 6788 | { |
| 5762 | 6789 | //error_log(__METHOD__.__LINE__."Uid:$_uid, PartId:$_partID, WinMailNr:$_winmail_nr, ReturnPart:$_returnPart, Stream:$_stream, Folder:$_folder".function_backtrace()); |
| 5763 | - if (!isset($_folder)) $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6790 | + if (!isset($_folder)) |
|
| 6791 | + { |
|
| 6792 | + $_folder = ($this->sessionData['mailbox']? $this->sessionData['mailbox'] : $this->icServer->getCurrentMailbox()); |
|
| 6793 | + } |
|
| 5764 | 6794 | |
| 5765 | 6795 | $uidsToFetch = new Horde_Imap_Client_Ids(); |
| 5766 | - if (!(is_object($_uid) || is_array($_uid))) $_uid = (array)$_uid; |
|
| 6796 | + if (!(is_object($_uid) || is_array($_uid))) |
|
| 6797 | + { |
|
| 6798 | + $_uid = (array)$_uid; |
|
| 6799 | + } |
|
| 5767 | 6800 | $uidsToFetch->add($_uid); |
| 5768 | 6801 | |
| 5769 | 6802 | $fquery = new Horde_Imap_Client_Fetch_Query(); |
@@ -5772,8 +6805,10 @@ discard block |
||
| 5772 | 6805 | $headersNew = $this->icServer->fetch($_folder, $fquery, array( |
| 5773 | 6806 | 'ids' => $uidsToFetch, |
| 5774 | 6807 | )); |
| 5775 | - if (is_object($headersNew)) { |
|
| 5776 | - foreach($headersNew as $id=>$_headerObject) { |
|
| 6808 | + if (is_object($headersNew)) |
|
| 6809 | + { |
|
| 6810 | + foreach($headersNew as $id=>$_headerObject) |
|
| 6811 | + { |
|
| 5777 | 6812 | $body = $_headerObject->getFullMsg(); |
| 5778 | 6813 | if ($_partID != '') |
| 5779 | 6814 | { |
@@ -5787,7 +6822,10 @@ discard block |
||
| 5787 | 6822 | } |
| 5788 | 6823 | // if $partDisposition is empty, we assume attachment, and hope that the function |
| 5789 | 6824 | // itself is only triggered to fetch attachments |
| 5790 | - if (empty($partDisposition)) $partDisposition='attachment'; |
|
| 6825 | + if (empty($partDisposition)) |
|
| 6826 | + { |
|
| 6827 | + $partDisposition='attachment'; |
|
| 6828 | + } |
|
| 5791 | 6829 | if ($part && ($partDisposition=='attachment' || $partDisposition=='inline' || ($part->getPrimaryType() == 'text' && $part->getSubType() == 'calendar'))) |
| 5792 | 6830 | { |
| 5793 | 6831 | //$headerObject=$part->getAllDispositionParameters();//not used anywhere around here |
@@ -5796,13 +6834,19 @@ discard block |
||
| 5796 | 6834 | $charset = $part->getContentTypeParameter('charset'); |
| 5797 | 6835 | //$structure_bytes = $part->getBytes(); $structure_partID=$part->getMimeId(); error_log(__METHOD__.__LINE__." fetchPartContents(".array2string($_uid).", $structure_partID, $_stream, $_preserveSeen,$structure_mime)" ); |
| 5798 | 6836 | $this->fetchPartContents($_uid, $part, $_stream, $_preserveSeen=true,$structure_mime); |
| 5799 | - if ($_returnPart) return $part; |
|
| 6837 | + if ($_returnPart) |
|
| 6838 | + { |
|
| 6839 | + return $part; |
|
| 6840 | + } |
|
| 5800 | 6841 | } |
| 5801 | 6842 | } |
| 5802 | 6843 | } |
| 5803 | 6844 | } |
| 5804 | 6845 | $ext = MimeMagic::mime2ext($structure_mime); |
| 5805 | - if ($ext && stripos($filename,'.')===false && stripos($filename,$ext)===false) $filename = trim($filename).'.'.$ext; |
|
| 6846 | + if ($ext && stripos($filename,'.')===false && stripos($filename,$ext)===false) |
|
| 6847 | + { |
|
| 6848 | + $filename = trim($filename).'.'.$ext; |
|
| 6849 | + } |
|
| 5806 | 6850 | if (!$part) |
| 5807 | 6851 | { |
| 5808 | 6852 | throw new Exception\WrongParameter("Error: Could not fetch attachment for Uid=".array2string($_uid).", PartId=$_partID, WinMailNr=$_winmail_nr, folder=$_folder"); |
@@ -5818,7 +6862,10 @@ discard block |
||
| 5818 | 6862 | ); |
| 5819 | 6863 | |
| 5820 | 6864 | // try guessing the mimetype, if we get the application/octet-stream |
| 5821 | - if (strtolower($attachmentData['type']) == 'application/octet-stream') $attachmentData['type'] = MimeMagic::filename2mime($attachmentData['filename']); |
|
| 6865 | + if (strtolower($attachmentData['type']) == 'application/octet-stream') |
|
| 6866 | + { |
|
| 6867 | + $attachmentData['type'] = MimeMagic::filename2mime($attachmentData['filename']); |
|
| 6868 | + } |
|
| 5822 | 6869 | # if the attachment holds a winmail number and is a winmail.dat then we have to handle that. |
| 5823 | 6870 | if ( $filename == 'winmail.dat' && $_winmail_nr) |
| 5824 | 6871 | { |
@@ -5841,9 +6888,18 @@ discard block |
||
| 5841 | 6888 | if ($_winmail_nr == $wantedPart.'@'.$mime_id) |
| 5842 | 6889 | { |
| 5843 | 6890 | //error_log(__METHOD__.__LINE__.'#'.$structure_mime.'#'.$filename.'#'.array2string($attachment)); |
| 5844 | - if (!isset($attachment['filename'])||empty($attachment['filename'])) $attachment['filename'] = $part->getName(); |
|
| 5845 | - if (($cid = $part->getContentId())) $attachment['cid'] = $cid; |
|
| 5846 | - 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']); |
|
| 6891 | + if (!isset($attachment['filename'])||empty($attachment['filename'])) |
|
| 6892 | + { |
|
| 6893 | + $attachment['filename'] = $part->getName(); |
|
| 6894 | + } |
|
| 6895 | + if (($cid = $part->getContentId())) |
|
| 6896 | + { |
|
| 6897 | + $attachment['cid'] = $cid; |
|
| 6898 | + } |
|
| 6899 | + if (empty($attachment['filename'])) |
|
| 6900 | + { |
|
| 6901 | + $attachment['filename'] = (isset($attachment['cid'])&&!empty($attachment['cid'])?$attachment['cid']:lang("unknown").'_Uid'.$_uid.'_Part'.$mime_id).'.'.MimeMagic::mime2ext($attachment['mimeType']); |
|
| 6902 | + } |
|
| 5847 | 6903 | $wmattach = $attachment; |
| 5848 | 6904 | $wmattach['attachment'] = $part->getContents(array('stream'=>$_stream)); |
| 5849 | 6905 | |
@@ -5853,7 +6909,10 @@ discard block |
||
| 5853 | 6909 | if ($tnefResolved) |
| 5854 | 6910 | { |
| 5855 | 6911 | $ext = MimeMagic::mime2ext($wmattach['mimeType']); |
| 5856 | - if ($ext && stripos($wmattach['filename'],'.')===false && stripos($wmattach['filename'],$ext)===false) $wmattach['filename'] = trim($wmattach['filename']).'.'.$ext; |
|
| 6912 | + if ($ext && stripos($wmattach['filename'],'.')===false && stripos($wmattach['filename'],$ext)===false) |
|
| 6913 | + { |
|
| 6914 | + $wmattach['filename'] = trim($wmattach['filename']).'.'.$ext; |
|
| 6915 | + } |
|
| 5857 | 6916 | $attachmentData = array( |
| 5858 | 6917 | 'type' => $wmattach['mimeType'], |
| 5859 | 6918 | 'filename' => $wmattach['filename'], |
@@ -5883,7 +6942,10 @@ discard block |
||
| 5883 | 6942 | static $uid=null, $part=null, $structure=null; |
| 5884 | 6943 | //error_log(__METHOD__.' ('.__LINE__.') '.":$_uid, $_cid, $_part"); |
| 5885 | 6944 | |
| 5886 | - if(empty($_cid)) return false; |
|
| 6945 | + if(empty($_cid)) |
|
| 6946 | + { |
|
| 6947 | + return false; |
|
| 6948 | + } |
|
| 5887 | 6949 | |
| 5888 | 6950 | if ($_uid != $uid || $_part != $part) |
| 5889 | 6951 | { |
@@ -5908,13 +6970,19 @@ discard block |
||
| 5908 | 6970 | $attachment = $part; |
| 5909 | 6971 | } |
| 5910 | 6972 | // everything else we only consider after we checked all |
| 5911 | - if (!isset($attachment)) $attachment = $part; |
|
| 6973 | + if (!isset($attachment)) |
|
| 6974 | + { |
|
| 6975 | + $attachment = $part; |
|
| 6976 | + } |
|
| 5912 | 6977 | // do we want content fetched, can be done later, if not needed |
| 5913 | 6978 | if (isset($_stream)) |
| 5914 | 6979 | { |
| 5915 | 6980 | $this->fetchPartContents($_uid, $attachment, $_stream); |
| 5916 | 6981 | } |
| 5917 | - if (isset($attachment)) break; |
|
| 6982 | + if (isset($attachment)) |
|
| 6983 | + { |
|
| 6984 | + break; |
|
| 6985 | + } |
|
| 5918 | 6986 | } |
| 5919 | 6987 | } |
| 5920 | 6988 | // set name as filename, if not set |
@@ -5945,10 +7013,17 @@ discard block |
||
| 5945 | 7013 | */ |
| 5946 | 7014 | public function fetchPartContents($_uid, Horde_Mime_Part $part=null, $_stream=false, $_preserveSeen=false, $_mimetype=null) |
| 5947 | 7015 | { |
| 5948 | - if (is_null($part)) return null;//new Horde_Mime_Part; |
|
| 7016 | + if (is_null($part)) |
|
| 7017 | + { |
|
| 7018 | + return null; |
|
| 7019 | + } |
|
| 7020 | + //new Horde_Mime_Part; |
|
| 5949 | 7021 | $encoding = null; |
| 5950 | 7022 | $fetchAsBinary = true; |
| 5951 | - if ($_mimetype && strtolower($_mimetype)=='message/rfc822') $fetchAsBinary = false; |
|
| 7023 | + if ($_mimetype && strtolower($_mimetype)=='message/rfc822') |
|
| 7024 | + { |
|
| 7025 | + $fetchAsBinary = false; |
|
| 7026 | + } |
|
| 5952 | 7027 | // we need to set content on structure to decode transfer encoding |
| 5953 | 7028 | $part->setContents( |
| 5954 | 7029 | $this->getBodyPart($_uid, $part->getMimeId(), null, $_preserveSeen, $_stream, $encoding, $fetchAsBinary), |
@@ -5985,7 +7060,10 @@ discard block |
||
| 5985 | 7060 | // the recent flag is the default enforced here ; as we assume the _flags is always set, |
| 5986 | 7061 | // we default it to hordes default (Recent) (, other wise we should not pass the parameter |
| 5987 | 7062 | // for flags at all) |
| 5988 | - if (empty($_flags)) $_flags = '\\Recent'; |
|
| 7063 | + if (empty($_flags)) |
|
| 7064 | + { |
|
| 7065 | + $_flags = '\\Recent'; |
|
| 7066 | + } |
|
| 5989 | 7067 | //if (!is_array($_flags) && stripos($_flags,',')!==false) $_flags=explode(',',$_flags); |
| 5990 | 7068 | //if (!is_array($_flags)) $_flags = (array) $_flags; |
| 5991 | 7069 | try |
@@ -6002,18 +7080,27 @@ discard block |
||
| 6002 | 7080 | } |
| 6003 | 7081 | catch (\Exception $e) |
| 6004 | 7082 | { |
| 6005 | - if (self::$debug) error_log("Could not append Message: ".$e->getMessage()); |
|
| 7083 | + if (self::$debug) |
|
| 7084 | + { |
|
| 7085 | + error_log("Could not append Message: ".$e->getMessage()); |
|
| 7086 | + } |
|
| 6006 | 7087 | throw new Exception\WrongUserinput(lang("Could not append Message:").' '.$e->getMessage().': '.$e->details); |
| 6007 | 7088 | //return false; |
| 6008 | 7089 | } |
| 6009 | 7090 | //error_log(__METHOD__.' ('.__LINE__.') '.' appended UID:'.$messageid); |
| 6010 | 7091 | //$messageid = true; // for debug reasons only |
| 6011 | - if ($messageid === true || empty($messageid)) // try to figure out the message uid |
|
| 7092 | + if ($messageid === true || empty($messageid)) |
|
| 7093 | + { |
|
| 7094 | + // try to figure out the message uid |
|
| 6012 | 7095 | { |
| 6013 | 7096 | $list = $this->getHeaders($_folderName, $_startMessage=1, 1, 'INTERNALDATE', true, array(),null, false); |
| 7097 | + } |
|
| 6014 | 7098 | if ($list) |
| 6015 | 7099 | { |
| 6016 | - if (self::$debug) error_log(__METHOD__.' ('.__LINE__.') '.' MessageUid:'.$messageid.' but found:'.array2string($list)); |
|
| 7100 | + if (self::$debug) |
|
| 7101 | + { |
|
| 7102 | + error_log(__METHOD__.' ('.__LINE__.') '.' MessageUid:'.$messageid.' but found:'.array2string($list)); |
|
| 7103 | + } |
|
| 6017 | 7104 | $messageid = $list['header'][0]['uid']; |
| 6018 | 7105 | } |
| 6019 | 7106 | } |
@@ -6054,7 +7141,10 @@ discard block |
||
| 6054 | 7141 | { |
| 6055 | 7142 | //echo __METHOD__." called for $uid,$partid <br>"; |
| 6056 | 7143 | $headers = $mailClass->getMessageHeader($uid,$partid,true,false,$mailbox); |
| 6057 | - if (empty($headers)) return false; |
|
| 7144 | + if (empty($headers)) |
|
| 7145 | + { |
|
| 7146 | + return false; |
|
| 7147 | + } |
|
| 6058 | 7148 | // dont force retrieval of the textpart, let mailClass preferences decide |
| 6059 | 7149 | $bodyParts = $mailClass->getMessageBody($uid,($preserveHTML?'always_display':'only_if_no_text'),$partid,null,false,$mailbox); |
| 6060 | 7150 | // if we do not want HTML but there is no TextRepresentation with the message itself, try converting |
@@ -6072,15 +7162,30 @@ discard block |
||
| 6072 | 7162 | //error_log(array2string($bodyParts)); |
| 6073 | 7163 | $attachments = $includeAttachments?$mailClass->getMessageAttachments($uid,$partid,null,true,false,true,$mailbox):array(); |
| 6074 | 7164 | |
| 6075 | - if ($mailClass->isSentFolder($mailbox)) $mailaddress = $headers['TO']; |
|
| 6076 | - elseif (isset($headers['FROM'])) $mailaddress = $headers['FROM']; |
|
| 6077 | - elseif (isset($headers['SENDER'])) $mailaddress = $headers['SENDER']; |
|
| 6078 | - if (isset($headers['CC'])) $mailaddress .= ','.$headers['CC']; |
|
| 7165 | + if ($mailClass->isSentFolder($mailbox)) |
|
| 7166 | + { |
|
| 7167 | + $mailaddress = $headers['TO']; |
|
| 7168 | + } |
|
| 7169 | + elseif (isset($headers['FROM'])) |
|
| 7170 | + { |
|
| 7171 | + $mailaddress = $headers['FROM']; |
|
| 7172 | + } |
|
| 7173 | + elseif (isset($headers['SENDER'])) |
|
| 7174 | + { |
|
| 7175 | + $mailaddress = $headers['SENDER']; |
|
| 7176 | + } |
|
| 7177 | + if (isset($headers['CC'])) |
|
| 7178 | + { |
|
| 7179 | + $mailaddress .= ','.$headers['CC']; |
|
| 7180 | + } |
|
| 6079 | 7181 | //_debug_array(array($headers,$mailaddress)); |
| 6080 | 7182 | $subject = $headers['SUBJECT']; |
| 6081 | 7183 | |
| 6082 | 7184 | $message = self::getdisplayableBody($mailClass, $bodyParts, $preserveHTML); |
| 6083 | - if ($preserveHTML && $mailClass->activeMimeType == 'text/plain') $message = '<pre>'.$message.'</pre>'; |
|
| 7185 | + if ($preserveHTML && $mailClass->activeMimeType == 'text/plain') |
|
| 7186 | + { |
|
| 7187 | + $message = '<pre>'.$message.'</pre>'; |
|
| 7188 | + } |
|
| 6084 | 7189 | $headdata = ($addHeaderSection ? self::createHeaderInfoSection($headers, '',$preserveHTML) : ''); |
| 6085 | 7190 | $message = $headdata.$message; |
| 6086 | 7191 | //echo __METHOD__.'<br>'; |
@@ -6131,7 +7236,8 @@ discard block |
||
| 6131 | 7236 | $attachments[$num]['attachment'] = $c->getContents(); |
| 6132 | 7237 | } |
| 6133 | 7238 | // no attempt to convert, if we dont know about the charset |
| 6134 | - if (isset($attachments[$num]['charset'])&&!empty($attachments[$num]['charset'])) { |
|
| 7239 | + if (isset($attachments[$num]['charset'])&&!empty($attachments[$num]['charset'])) |
|
| 7240 | + { |
|
| 6135 | 7241 | // we do not try guessing the charset, if it is not set |
| 6136 | 7242 | //if ($attachments[$num]['charset']===false) $attachments[$num]['charset'] = Translation::detect_encoding($attachments[$num]['attachment']); |
| 6137 | 7243 | Translation::convert($attachments[$num]['attachment'],$attachments[$num]['charset']); |
@@ -6152,7 +7258,10 @@ discard block |
||
| 6152 | 7258 | unset($attachments[$num]['attachment']); |
| 6153 | 7259 | } |
| 6154 | 7260 | } |
| 6155 | - if (is_array($attachedMessages)) $attachments = array_merge($attachments,$attachedMessages); |
|
| 7261 | + if (is_array($attachedMessages)) |
|
| 7262 | + { |
|
| 7263 | + $attachments = array_merge($attachments,$attachedMessages); |
|
| 7264 | + } |
|
| 6156 | 7265 | } |
| 6157 | 7266 | return array( |
| 6158 | 7267 | 'mailaddress'=>$mailaddress, |
@@ -6174,10 +7283,17 @@ discard block |
||
| 6174 | 7283 | { |
| 6175 | 7284 | $c = 0; |
| 6176 | 7285 | // use the standardIdentity |
| 6177 | - foreach($_identities as $key => $acc) { |
|
| 6178 | - if ($c==0) $identity = $acc; |
|
| 7286 | + foreach($_identities as $key => $acc) |
|
| 7287 | + { |
|
| 7288 | + if ($c==0) |
|
| 7289 | + { |
|
| 7290 | + $identity = $acc; |
|
| 7291 | + } |
|
| 6179 | 7292 | //error_log(__METHOD__.__LINE__." $key == $_profile_id "); |
| 6180 | - if ($key==$_profile_id) $identity = $acc; |
|
| 7293 | + if ($key==$_profile_id) |
|
| 7294 | + { |
|
| 7295 | + $identity = $acc; |
|
| 7296 | + } |
|
| 6181 | 7297 | $c++; |
| 6182 | 7298 | } |
| 6183 | 7299 | return $identity; |
@@ -6193,20 +7309,53 @@ discard block |
||
| 6193 | 7309 | { |
| 6194 | 7310 | $headdata = null; |
| 6195 | 7311 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($header).function_backtrace()); |
| 6196 | - if ($header['SUBJECT']) $headdata = lang('subject').': '.$header['SUBJECT'].($createHTML?"<br />":"\n"); |
|
| 6197 | - if ($header['FROM']) $headdata .= lang('from').': '.self::convertAddressArrayToString($header['FROM'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6198 | - if ($header['SENDER']) $headdata .= lang('sender').': '.self::convertAddressArrayToString($header['SENDER'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6199 | - if ($header['TO']) $headdata .= lang('to').': '.self::convertAddressArrayToString($header['TO'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6200 | - if ($header['CC']) $headdata .= lang('cc').': '.self::convertAddressArrayToString($header['CC'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6201 | - if ($header['BCC']) $headdata .= lang('bcc').': '.self::convertAddressArrayToString($header['BCC'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 6202 | - if ($header['DATE']) $headdata .= lang('date').': '.$header['DATE'].($createHTML?"<br />":"\n"); |
|
| 6203 | - if ($header['PRIORITY'] && $header['PRIORITY'] != 'normal') $headdata .= lang('priority').': '.$header['PRIORITY'].($createHTML?"<br />":"\n"); |
|
| 6204 | - if ($header['IMPORTANCE'] && $header['IMPORTANCE'] !='normal') $headdata .= lang('importance').': '.$header['IMPORTANCE'].($createHTML?"<br />":"\n"); |
|
| 7312 | + if ($header['SUBJECT']) |
|
| 7313 | + { |
|
| 7314 | + $headdata = lang('subject').': '.$header['SUBJECT'].($createHTML?"<br />":"\n"); |
|
| 7315 | + } |
|
| 7316 | + if ($header['FROM']) |
|
| 7317 | + { |
|
| 7318 | + $headdata .= lang('from').': '.self::convertAddressArrayToString($header['FROM'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 7319 | + } |
|
| 7320 | + if ($header['SENDER']) |
|
| 7321 | + { |
|
| 7322 | + $headdata .= lang('sender').': '.self::convertAddressArrayToString($header['SENDER'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 7323 | + } |
|
| 7324 | + if ($header['TO']) |
|
| 7325 | + { |
|
| 7326 | + $headdata .= lang('to').': '.self::convertAddressArrayToString($header['TO'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 7327 | + } |
|
| 7328 | + if ($header['CC']) |
|
| 7329 | + { |
|
| 7330 | + $headdata .= lang('cc').': '.self::convertAddressArrayToString($header['CC'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 7331 | + } |
|
| 7332 | + if ($header['BCC']) |
|
| 7333 | + { |
|
| 7334 | + $headdata .= lang('bcc').': '.self::convertAddressArrayToString($header['BCC'], $createHTML).($createHTML?"<br />":"\n"); |
|
| 7335 | + } |
|
| 7336 | + if ($header['DATE']) |
|
| 7337 | + { |
|
| 7338 | + $headdata .= lang('date').': '.$header['DATE'].($createHTML?"<br />":"\n"); |
|
| 7339 | + } |
|
| 7340 | + if ($header['PRIORITY'] && $header['PRIORITY'] != 'normal') |
|
| 7341 | + { |
|
| 7342 | + $headdata .= lang('priority').': '.$header['PRIORITY'].($createHTML?"<br />":"\n"); |
|
| 7343 | + } |
|
| 7344 | + if ($header['IMPORTANCE'] && $header['IMPORTANCE'] !='normal') |
|
| 7345 | + { |
|
| 7346 | + $headdata .= lang('importance').': '.$header['IMPORTANCE'].($createHTML?"<br />":"\n"); |
|
| 7347 | + } |
|
| 6205 | 7348 | //if ($mailcontent['headers']['ORGANIZATION']) $headdata .= lang('organization').': '.$mailcontent['headers']['ORGANIZATION']."\ |
| 6206 | 7349 | if (!empty($headdata)) |
| 6207 | 7350 | { |
| 6208 | - if (!empty($headline) && $headline != 'SUPPRESS') $headdata = "---------------------------- $headline ----------------------------".($createHTML?"<br />":"\n").$headdata; |
|
| 6209 | - if (empty($headline)) $headdata = ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):'').$headdata; |
|
| 7351 | + if (!empty($headline) && $headline != 'SUPPRESS') |
|
| 7352 | + { |
|
| 7353 | + $headdata = "---------------------------- $headline ----------------------------".($createHTML?"<br />":"\n").$headdata; |
|
| 7354 | + } |
|
| 7355 | + if (empty($headline)) |
|
| 7356 | + { |
|
| 7357 | + $headdata = ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):'').$headdata; |
|
| 7358 | + } |
|
| 6210 | 7359 | $headdata .= ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):''); |
| 6211 | 7360 | } |
| 6212 | 7361 | else |
@@ -6240,12 +7389,15 @@ discard block |
||
| 6240 | 7389 | $returnAddr =''; |
| 6241 | 7390 | if (is_array($rfcAddressArray)) |
| 6242 | 7391 | { |
| 6243 | - foreach((array)$rfcAddressArray as $addressData) { |
|
| 7392 | + foreach((array)$rfcAddressArray as $addressData) |
|
| 7393 | + { |
|
| 6244 | 7394 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($addressData)); |
| 6245 | - if($addressData['MAILBOX_NAME'] == 'NIL') { |
|
| 7395 | + if($addressData['MAILBOX_NAME'] == 'NIL') |
|
| 7396 | + { |
|
| 6246 | 7397 | continue; |
| 6247 | 7398 | } |
| 6248 | - if(strtolower($addressData['MAILBOX_NAME']) == 'undisclosed-recipients') { |
|
| 7399 | + if(strtolower($addressData['MAILBOX_NAME']) == 'undisclosed-recipients') |
|
| 7400 | + { |
|
| 6249 | 7401 | continue; |
| 6250 | 7402 | } |
| 6251 | 7403 | if ($addressData['RFC822_EMAIL']) |
@@ -6259,7 +7411,10 @@ discard block |
||
| 6259 | 7411 | } |
| 6260 | 7412 | $addressObject = $addressObjectA[0]; |
| 6261 | 7413 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($addressObject)); |
| 6262 | - if (!$addressObject->valid) continue; |
|
| 7414 | + if (!$addressObject->valid) |
|
| 7415 | + { |
|
| 7416 | + continue; |
|
| 7417 | + } |
|
| 6263 | 7418 | //$mb =(string)$addressObject->mailbox; |
| 6264 | 7419 | //$h = (string)$addressObject->host; |
| 6265 | 7420 | //$p = (string)$addressObject->personal; |
@@ -6276,7 +7431,10 @@ discard block |
||
| 6276 | 7431 | // do not mess with strings, return them untouched /* ToDo: validate string as Address */ |
| 6277 | 7432 | $rfcAddressArray = self::decode_header($rfcAddressArray,true); |
| 6278 | 7433 | $rfcAddressArray = str_replace(array('<','>','"\'','\'"'),array('[',']','"','"'),$rfcAddressArray); |
| 6279 | - if (is_string($rfcAddressArray)) return $rfcAddressArray; |
|
| 7434 | + if (is_string($rfcAddressArray)) |
|
| 7435 | + { |
|
| 7436 | + return $rfcAddressArray; |
|
| 7437 | + } |
|
| 6280 | 7438 | } |
| 6281 | 7439 | return $returnAddr; |
| 6282 | 7440 | } |
@@ -6293,10 +7451,19 @@ discard block |
||
| 6293 | 7451 | { |
| 6294 | 7452 | $mergeobj = new Contacts\Merge(); |
| 6295 | 7453 | |
| 6296 | - if (empty($mimetype)) $mimetype = (strlen(strip_tags($content)) == strlen($content) ?'text/plain':'text/html'); |
|
| 7454 | + if (empty($mimetype)) |
|
| 7455 | + { |
|
| 7456 | + $mimetype = (strlen(strip_tags($content)) == strlen($content) ?'text/plain':'text/html'); |
|
| 7457 | + } |
|
| 6297 | 7458 | $rv = $mergeobj->merge_string($content,$ids,$err='',$mimetype, array(), self::$displayCharset); |
| 6298 | - if (empty($rv) && !empty($content) && !empty($err)) $rv = $content; |
|
| 6299 | - if (!empty($err) && !empty($content) && !empty($ids)) error_log(__METHOD__.' ('.__LINE__.') '.' Merge failed for Ids:'.array2string($ids).' ContentType:'.$mimetype.' Content:'.$content.' Reason:'.array2string($err)); |
|
| 7459 | + if (empty($rv) && !empty($content) && !empty($err)) |
|
| 7460 | + { |
|
| 7461 | + $rv = $content; |
|
| 7462 | + } |
|
| 7463 | + if (!empty($err) && !empty($content) && !empty($ids)) |
|
| 7464 | + { |
|
| 7465 | + error_log(__METHOD__.' ('.__LINE__.') '.' Merge failed for Ids:'.array2string($ids).' ContentType:'.$mimetype.' Content:'.$content.' Reason:'.array2string($err)); |
|
| 7466 | + } |
|
| 6300 | 7467 | return $rv; |
| 6301 | 7468 | } |
| 6302 | 7469 | |
@@ -6333,13 +7500,15 @@ discard block |
||
| 6333 | 7500 | settype($bytes, 'integer'); |
| 6334 | 7501 | $bytes /= 10; |
| 6335 | 7502 | } |
| 6336 | - else |
|
| 6337 | - settype($bytes, 'integer'); |
|
| 7503 | + else { |
|
| 7504 | + settype($bytes, 'integer'); |
|
| 7505 | + } |
|
| 6338 | 7506 | |
| 6339 | 7507 | return $bytes . ' ' . $type ; |
| 6340 | 7508 | } |
| 6341 | 7509 | |
| 6342 | - static function detect_qp(&$sting) { |
|
| 7510 | + static function detect_qp(&$sting) |
|
| 7511 | + { |
|
| 6343 | 7512 | $needle = '/(=[0-9][A-F])|(=[A-F][0-9])|(=[A-F][A-F])|(=[0-9][0-9])/'; |
| 6344 | 7513 | return preg_match("$needle",$string); |
| 6345 | 7514 | } |
@@ -6356,9 +7525,15 @@ discard block |
||
| 6356 | 7525 | */ |
| 6357 | 7526 | static function logRunTimes($_starttime,$_endtime=null,$_message='',$_methodNline='') |
| 6358 | 7527 | { |
| 6359 | - if (is_null($_endtime)) $_endtime = microtime(true); |
|
| 7528 | + if (is_null($_endtime)) |
|
| 7529 | + { |
|
| 7530 | + $_endtime = microtime(true); |
|
| 7531 | + } |
|
| 6360 | 7532 | $usagetime = microtime(true) - $_starttime; |
| 6361 | - if (self::$debugTimes) error_log($_methodNline.' took:'.number_format($usagetime,5).'(s) '.($_message?'Details:'.$_message:'')); |
|
| 7533 | + if (self::$debugTimes) |
|
| 7534 | + { |
|
| 7535 | + error_log($_methodNline.' took:'.number_format($usagetime,5).'(s) '.($_message?'Details:'.$_message:'')); |
|
| 7536 | + } |
|
| 6362 | 7537 | } |
| 6363 | 7538 | |
| 6364 | 7539 | /** |
@@ -6373,7 +7548,10 @@ discard block |
||
| 6373 | 7548 | */ |
| 6374 | 7549 | static function checkFileBasics(&$_formData, $IDtoAddToFileName='', $reqMimeType='message/rfc822') |
| 6375 | 7550 | { |
| 6376 | - if (parse_url($_formData['file'],PHP_URL_SCHEME) == 'egw-data') return $_formData['file']; |
|
| 7551 | + if (parse_url($_formData['file'],PHP_URL_SCHEME) == 'egw-data') |
|
| 7552 | + { |
|
| 7553 | + return $_formData['file']; |
|
| 7554 | + } |
|
| 6377 | 7555 | |
| 6378 | 7556 | //error_log(__METHOD__.__FILE__.array2string($_formData).' Id:'.$IDtoAddToFileName.' ReqMimeType:'.$reqMimeType); |
| 6379 | 7557 | $importfailed = $tmpFileName = false; |
@@ -6422,8 +7600,15 @@ discard block |
||
| 6422 | 7600 | { |
| 6423 | 7601 | $buff = explode('.',$_formData['name']); |
| 6424 | 7602 | $suffix = ''; |
| 6425 | - if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
|
| 6426 | - if (!empty($suffix)) $sfxMimeType = MimeMagic::ext2mime($suffix); |
|
| 7603 | + if (is_array($buff)) |
|
| 7604 | + { |
|
| 7605 | + $suffix = array_pop($buff); |
|
| 7606 | + } |
|
| 7607 | + // take the last extension to check with ext2mime |
|
| 7608 | + if (!empty($suffix)) |
|
| 7609 | + { |
|
| 7610 | + $sfxMimeType = MimeMagic::ext2mime($suffix); |
|
| 7611 | + } |
|
| 6427 | 7612 | if (!empty($suffix) && !empty($sfxMimeType) && |
| 6428 | 7613 | (strlen(trim($_formData['type']))==0 || (strtolower(trim($_formData['type'])) != $sfxMimeType))) |
| 6429 | 7614 | { |
@@ -6471,7 +7656,9 @@ discard block |
||
| 6471 | 7656 | { |
| 6472 | 7657 | rename($_formData['file'], $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmpFileName); |
| 6473 | 7658 | } |
| 6474 | - } else { |
|
| 7659 | + } |
|
| 7660 | + else |
|
| 7661 | + { |
|
| 6475 | 7662 | //error_log("Import of message ".$_formData['file']." failes to meet basic restrictions"); |
| 6476 | 7663 | $importfailed = true; |
| 6477 | 7664 | $alert_msg .= lang("Processing of file %1 failed. Failed to meet basic restrictions.",$_formData['name']); |
@@ -6517,21 +7704,32 @@ discard block |
||
| 6517 | 7704 | if (substr($url, 0, 5) !== 'data:') |
| 6518 | 7705 | { |
| 6519 | 7706 | $filename = basename($url); |
| 6520 | - if (($directory = dirname($url)) == '.') $directory = ''; |
|
| 7707 | + if (($directory = dirname($url)) == '.') |
|
| 7708 | + { |
|
| 7709 | + $directory = ''; |
|
| 7710 | + } |
|
| 6521 | 7711 | $ext = pathinfo($filename, PATHINFO_EXTENSION); |
| 6522 | 7712 | $mimeType = MimeMagic::ext2mime($ext); |
| 6523 | - if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; } |
|
| 7713 | + if ( strlen($directory) > 1 && substr($directory,-1) != '/') |
|
| 7714 | + { |
|
| 7715 | +$directory .= '/'; } |
|
| 6524 | 7716 | $myUrl = $directory.$filename; |
| 6525 | - if ($myUrl[0]=='/') // local path -> we only allow path's that are available via http/https (or vfs) |
|
| 7717 | + if ($myUrl[0]=='/') |
|
| 7718 | + { |
|
| 7719 | + // local path -> we only allow path's that are available via http/https (or vfs) |
|
| 6526 | 7720 | { |
| 6527 | 7721 | $basedir = ($_SERVER['HTTPS']?'https://':'http://'.$_SERVER['HTTP_HOST']); |
| 6528 | 7722 | } |
| 7723 | + } |
|
| 6529 | 7724 | // use vfs instead of url containing webdav.php |
| 6530 | 7725 | // ToDo: we should test if the webdav url is of our own scope, as we cannot handle foreign |
| 6531 | 7726 | // webdav.php urls as vfs |
| 6532 | - if (strpos($myUrl,'/webdav.php') !== false) // we have a webdav link, so we build a vfs/sqlfs link of it. |
|
| 7727 | + if (strpos($myUrl,'/webdav.php') !== false) |
|
| 7728 | + { |
|
| 7729 | + // we have a webdav link, so we build a vfs/sqlfs link of it. |
|
| 6533 | 7730 | { |
| 6534 | 7731 | Vfs::load_wrapper('vfs'); |
| 7732 | + } |
|
| 6535 | 7733 | list(,$myUrl) = explode('/webdav.php',$myUrl,2); |
| 6536 | 7734 | $basedir = 'vfs://default'; |
| 6537 | 7735 | $needTempFile = false; |
@@ -6560,8 +7758,13 @@ discard block |
||
| 6560 | 7758 | } |
| 6561 | 7759 | } |
| 6562 | 7760 | |
| 6563 | - if ( strlen($basedir) > 1 && substr($basedir,-1) != '/' && $myUrl[0]!='/') { $basedir .= '/'; } |
|
| 6564 | - if ($needTempFile && !$attachment && substr($myUrl,0,4) !== "http") $data = file_get_contents($basedir.urldecode($myUrl)); |
|
| 7761 | + if ( strlen($basedir) > 1 && substr($basedir,-1) != '/' && $myUrl[0]!='/') |
|
| 7762 | + { |
|
| 7763 | +$basedir .= '/'; } |
|
| 7764 | + if ($needTempFile && !$attachment && substr($myUrl,0,4) !== "http") |
|
| 7765 | + { |
|
| 7766 | + $data = file_get_contents($basedir.urldecode($myUrl)); |
|
| 7767 | + } |
|
| 6565 | 7768 | } |
| 6566 | 7769 | if (substr($url,0,strlen('data:'))=='data:') |
| 6567 | 7770 | { |
@@ -6662,7 +7865,10 @@ discard block |
||
| 6662 | 7865 | $_folder = $this->getSentFolder(); |
| 6663 | 7866 | } |
| 6664 | 7867 | $delimiter = $this->getHierarchyDelimiter(); |
| 6665 | - if($_folder=='INBOX'.$delimiter) $_folder='INBOX'; |
|
| 7868 | + if($_folder=='INBOX'.$delimiter) |
|
| 7869 | + { |
|
| 7870 | + $_folder='INBOX'; |
|
| 7871 | + } |
|
| 6666 | 7872 | if ($importfailed === false) |
| 6667 | 7873 | { |
| 6668 | 7874 | $Subject = $mailObject->getHeader('Subject'); |
@@ -6691,7 +7897,9 @@ discard block |
||
| 6691 | 7897 | //error_log(__METHOD__.' ('.__LINE__.') '.' Id To Merge:'.$val); |
| 6692 | 7898 | if (/*$GLOBALS['egw_info']['flags']['currentapp'] == 'addressbook' &&*/ |
| 6693 | 7899 | count($SendAndMergeTocontacts) > 1 && $val && |
| 6694 | - (is_numeric($val) || $GLOBALS['egw']->accounts->name2id($val))) // do the merge |
|
| 7900 | + (is_numeric($val) || $GLOBALS['egw']->accounts->name2id($val))) |
|
| 7901 | + { |
|
| 7902 | + // do the merge |
|
| 6695 | 7903 | { |
| 6696 | 7904 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mailObject)); |
| 6697 | 7905 | |
@@ -6700,6 +7908,7 @@ discard block |
||
| 6700 | 7908 | { |
| 6701 | 7909 | //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)); |
| 6702 | 7910 | $merged = $bo_merge->merge_string($mailObject->getHeader(Mailer::$type2header[$type]),$val,$e,'text/plain',array(),self::$displayCharset); |
| 7911 | + } |
|
| 6703 | 7912 | $mailObject->addAddress($merged,'',$type); |
| 6704 | 7913 | if($type == 'to') |
| 6705 | 7914 | { |
@@ -6731,9 +7940,15 @@ discard block |
||
| 6731 | 7940 | $mailObject->clearCustomHeaders(); |
| 6732 | 7941 | $mailObject->addHeader('Subject', $bo_merge->merge_string($Subject, $val, $e, 'text/plain', array(), self::$displayCharset)); |
| 6733 | 7942 | //error_log(__METHOD__.' ('.__LINE__.') '.' ContentType:'.$mailObject->BodyContentType); |
| 6734 | - 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)); |
|
| 7943 | + if($text_body) |
|
| 7944 | + { |
|
| 7945 | + $text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 7946 | + } |
|
| 6735 | 7947 | //error_log(__METHOD__.' ('.__LINE__.') '.' Result:'.$mailObject->Body.' error:'.array2string($e)); |
| 6736 | - 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)); |
|
| 7948 | + if($html_body) |
|
| 7949 | + { |
|
| 7950 | + $html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 7951 | + } |
|
| 6737 | 7952 | |
| 6738 | 7953 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($mailObject)); |
| 6739 | 7954 | // set a higher timeout for big messages |
@@ -6748,9 +7963,12 @@ discard block |
||
| 6748 | 7963 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($errorInfo)); |
| 6749 | 7964 | } |
| 6750 | 7965 | } |
| 6751 | - elseif (!$k) // 1. entry, further entries will fail for apps other then addressbook |
|
| 7966 | + elseif (!$k) |
|
| 7967 | + { |
|
| 7968 | + // 1. entry, further entries will fail for apps other then addressbook |
|
| 6752 | 7969 | { |
| 6753 | 7970 | $openAsDraft = true; |
| 7971 | + } |
|
| 6754 | 7972 | $mailObject->removeHeader('Message-ID'); |
| 6755 | 7973 | $mailObject->removeHeader('Date'); |
| 6756 | 7974 | $mailObject->clearCustomHeaders(); |
@@ -6765,9 +7983,12 @@ discard block |
||
| 6765 | 7983 | |
| 6766 | 7984 | // No addresses from placeholders? Treat it as just a contact ID |
| 6767 | 7985 | if (count($mailObject->getAddresses('to',true)) == 0 && |
| 6768 | - is_numeric($val) || $GLOBALS['egw']->accounts->name2id($val)) // do the merge |
|
| 7986 | + is_numeric($val) || $GLOBALS['egw']->accounts->name2id($val)) |
|
| 7987 | + { |
|
| 7988 | + // do the merge |
|
| 6769 | 7989 | { |
| 6770 | 7990 | $contact = $bo_merge->contacts->read($val); |
| 7991 | + } |
|
| 6771 | 7992 | //error_log(__METHOD__.' ('.__LINE__.') '.array2string($contact)); |
| 6772 | 7993 | $email = ($contact['email'] ? $contact['email'] : $contact['email_home']); |
| 6773 | 7994 | $nfn = ($contact['n_fn'] ? $contact['n_fn'] : $contact['n_given'].' '.$contact['n_family']); |
@@ -6778,9 +7999,15 @@ discard block |
||
| 6778 | 7999 | } |
| 6779 | 8000 | $mailObject->addHeader('Subject', $bo_merge->merge_string($Subject, $val, $e, 'text/plain', array(), self::$displayCharset)); |
| 6780 | 8001 | //error_log(__METHOD__.' ('.__LINE__.') '.' ContentType:'.$mailObject->BodyContentType); |
| 6781 | - 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)); |
|
| 8002 | + if (!empty($Body)) |
|
| 8003 | + { |
|
| 8004 | + $text_body->setContents($bo_merge->merge_string($Body, $val, $e, 'text/plain', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 8005 | + } |
|
| 6782 | 8006 | //error_log(__METHOD__.' ('.__LINE__.') '.' Result:'.$mailObject->Body.' error:'.array2string($e)); |
| 6783 | - 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)); |
|
| 8007 | + if (!empty($AltBody)) |
|
| 8008 | + { |
|
| 8009 | + $html_body->setContents($bo_merge->merge_string($AltBody, $val, $e, 'text/html', array(), self::$displayCharset),array('encoding'=>Horde_Mime_Part::DEFAULT_ENCODING)); |
|
| 8010 | + } |
|
| 6784 | 8011 | $_folder = $this->getDraftFolder(); |
| 6785 | 8012 | } |
| 6786 | 8013 | if ($sendOK || $openAsDraft) |
@@ -6788,11 +8015,15 @@ discard block |
||
| 6788 | 8015 | if ($this->folderExists($_folder,true)) |
| 6789 | 8016 | { |
| 6790 | 8017 | if($this->isSentFolder($_folder)) |
| 6791 | - { |
|
| 8018 | + { |
|
| 6792 | 8019 | $flags = '\\Seen'; |
| 6793 | - } elseif($this->isDraftFolder($_folder)) { |
|
| 8020 | + } |
|
| 8021 | + elseif($this->isDraftFolder($_folder)) |
|
| 8022 | + { |
|
| 6794 | 8023 | $flags = '\\Draft'; |
| 6795 | - } else { |
|
| 8024 | + } |
|
| 8025 | + else |
|
| 8026 | + { |
|
| 6796 | 8027 | $flags = ''; |
| 6797 | 8028 | } |
| 6798 | 8029 | $savefailed = false; |
@@ -6826,7 +8057,10 @@ discard block |
||
| 6826 | 8057 | } |
| 6827 | 8058 | else |
| 6828 | 8059 | { |
| 6829 | - if (!$openComposeWindow) $processStats['failed'][$val] = $errorInfo?$errorInfo:'Send failed to '.$nfn.'<'.$email.'> See error_log for details'; |
|
| 8060 | + if (!$openComposeWindow) |
|
| 8061 | + { |
|
| 8062 | + $processStats['failed'][$val] = $errorInfo?$errorInfo:'Send failed to '.$nfn.'<'.$email.'> See error_log for details'; |
|
| 8063 | + } |
|
| 6830 | 8064 | } |
| 6831 | 8065 | } |
| 6832 | 8066 | if (!is_null($sendOK) && $sendOK===false && is_null($openComposeWindow)) |
@@ -6874,7 +8108,10 @@ discard block |
||
| 6874 | 8108 | $tmpFileName = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($tmpFileName); |
| 6875 | 8109 | break; |
| 6876 | 8110 | } |
| 6877 | - if (!isset($message)) $message = fopen($tmpFileName, 'r'); |
|
| 8111 | + if (!isset($message)) |
|
| 8112 | + { |
|
| 8113 | + $message = fopen($tmpFileName, 'r'); |
|
| 8114 | + } |
|
| 6878 | 8115 | |
| 6879 | 8116 | if (!$message) |
| 6880 | 8117 | { |
@@ -6905,7 +8142,10 @@ discard block |
||
| 6905 | 8142 | (fseek($message, 0, SEEK_SET) == -1 ? '' : fread($message, 8192)); |
| 6906 | 8143 | |
| 6907 | 8144 | $length = strpos($start, Horde_Mime_Part::RFC_EOL.Horde_Mime_Part::RFC_EOL); |
| 6908 | - if ($length===false) $length = strlen($start); |
|
| 8145 | + if ($length===false) |
|
| 8146 | + { |
|
| 8147 | + $length = strlen($start); |
|
| 8148 | + } |
|
| 6909 | 8149 | $headers = Horde_Mime_Headers::parseHeaders(substr($start, 0,$length)); |
| 6910 | 8150 | |
| 6911 | 8151 | foreach($headers->toArray(array('nowrap' => true)) as $header => $value) |
@@ -6934,7 +8174,10 @@ discard block |
||
| 6934 | 8174 | } |
| 6935 | 8175 | else |
| 6936 | 8176 | { |
| 6937 | - if (($type = gettype($message)) == 'object') $type = get_class ($message); |
|
| 8177 | + if (($type = gettype($message)) == 'object') |
|
| 8178 | + { |
|
| 8179 | + $type = get_class ($message); |
|
| 8180 | + } |
|
| 6938 | 8181 | throw new Exception\WrongParameter('Wrong parameter type for message: '.$type); |
| 6939 | 8182 | } |
| 6940 | 8183 | } |
@@ -6958,7 +8201,9 @@ discard block |
||
| 6958 | 8201 | $matches = array(); |
| 6959 | 8202 | preg_match_all("/[\w\.,-.,_.,0-9.]+@[\w\.,-.,_.,0-9.]+/",$addresses,$matches); |
| 6960 | 8203 | //error_log(__METHOD__.__LINE__.array2string($matches)); |
| 6961 | - foreach ($matches[0] as &$match) {$match = trim($match,', ');} |
|
| 8204 | + foreach ($matches[0] as &$match) |
|
| 8205 | + { |
|
| 8206 | +$match = trim($match,', ');} |
|
| 6962 | 8207 | $addresses = implode(',',$matches[0]); |
| 6963 | 8208 | //error_log(__METHOD__.__LINE__.array2string($addresses)); |
| 6964 | 8209 | $ret = $rfc822->parseAddressList($addresses, $default_domain ? array('default_domain' => $default_domain) : array()); |
@@ -6989,7 +8234,10 @@ discard block |
||
| 6989 | 8234 | } |
| 6990 | 8235 | else |
| 6991 | 8236 | { |
| 6992 | - if ($previousFailed && $remember) $adr->personal = $remember. ' ' . $adr->personal; |
|
| 8237 | + if ($previousFailed && $remember) |
|
| 8238 | + { |
|
| 8239 | + $adr->personal = $remember. ' ' . $adr->personal; |
|
| 8240 | + } |
|
| 6993 | 8241 | $remember = ''; |
| 6994 | 8242 | $previousFailed=false; |
| 6995 | 8243 | //error_log(__METHOD__.__LINE__."('$addresses', $default_domain) parsed $i: mailbox=$adr->mailbox, host=$adr->host, personal=$adr->personal"); |
@@ -7011,7 +8259,10 @@ discard block |
||
| 7011 | 8259 | { |
| 7012 | 8260 | $acc = Mail\Account::read($this->profileID); |
| 7013 | 8261 | $identity = Mail\Account::read_identity($acc['ident_id'], true, null, $acc); |
| 7014 | - if (self::$debug) error_log(__METHOD__.__LINE__.array2string($identity)); |
|
| 8262 | + if (self::$debug) |
|
| 8263 | + { |
|
| 8264 | + error_log(__METHOD__.__LINE__.array2string($identity)); |
|
| 8265 | + } |
|
| 7015 | 8266 | $headers = $this->getMessageHeader($uid, '', 'object', true, $_folder); |
| 7016 | 8267 | |
| 7017 | 8268 | $mdn = new Horde_Mime_Mdn($headers); |