@@ -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 |
@@ -164,12 +163,12 @@ discard block |
||
| 164 | 163 | if (Api\Json\Request::isJSONRequest() && $_GET['menuaction'] != 'mail.mail_ui.index') |
| 165 | 164 | { |
| 166 | 165 | $response = Api\Json\Response::get(); |
| 167 | - $response->call('egw.message',$e->getMessage(),'error'); |
|
| 166 | + $response->call('egw.message', $e->getMessage(), 'error'); |
|
| 168 | 167 | } |
| 169 | 168 | // redirect to mail wizard to handle it (redirect works for ajax too), unless index is called. we want the sidebox |
| 170 | - if ($_GET['menuaction'] != 'mail.mail_ui.index') self::callWizard($e->getMessage(),true,'error',false); |
|
| 169 | + if ($_GET['menuaction'] != 'mail.mail_ui.index') self::callWizard($e->getMessage(), true, 'error', false); |
|
| 171 | 170 | } |
| 172 | - if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 171 | + if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, '', __METHOD__.__LINE__); |
|
| 173 | 172 | } |
| 174 | 173 | |
| 175 | 174 | /** |
@@ -179,10 +178,10 @@ discard block |
||
| 179 | 178 | * @param boolean $exit If true, will call exit() after opening the wizardpopup |
| 180 | 179 | * @param string $msg_type = 'success' message type |
| 181 | 180 | */ |
| 182 | - static function callWizard($message, $exit=true, $msg_type='success',$reset_sidebox_on_index=true) |
|
| 181 | + static function callWizard($message, $exit = true, $msg_type = 'success', $reset_sidebox_on_index = true) |
|
| 183 | 182 | { |
| 184 | 183 | //error_log(__METHOD__."('$message', $exit) ".function_backtrace()); |
| 185 | - $linkData=(self::$icServerID ? array( |
|
| 184 | + $linkData = (self::$icServerID ? array( |
|
| 186 | 185 | 'menuaction' => 'mail.mail_wizard.edit', |
| 187 | 186 | 'acc_id' => self::$icServerID, |
| 188 | 187 | ) : array( |
@@ -196,11 +195,11 @@ discard block |
||
| 196 | 195 | { |
| 197 | 196 | $response = Api\Json\Response::get(); |
| 198 | 197 | $windowName = "editMailAccount".self::$icServerID; |
| 199 | - $response->call("egw.open_link", Egw::link('/index.php', $linkData), $windowName, "600x480",null,true); |
|
| 198 | + $response->call("egw.open_link", Egw::link('/index.php', $linkData), $windowName, "600x480", null, true); |
|
| 200 | 199 | Framework::message($message, 'error'); |
| 201 | 200 | if ($_GET['menuaction'] == 'mail.mail_ui.index' && $reset_sidebox_on_index) |
| 202 | 201 | { |
| 203 | - $response->call('framework.setSidebox','mail',array(),'md5'); |
|
| 202 | + $response->call('framework.setSidebox', 'mail', array(), 'md5'); |
|
| 204 | 203 | } |
| 205 | 204 | if ($exit) |
| 206 | 205 | { |
@@ -210,8 +209,8 @@ discard block |
||
| 210 | 209 | else // regular GET request eg. in idots template |
| 211 | 210 | { |
| 212 | 211 | $windowName = "editMailAccount".self::$icServerID; |
| 213 | - Framework::popup(Framework::link('/index.php',$linkData),$windowName); |
|
| 214 | - $GLOBALS['egw']->framework->render($message,'',true); |
|
| 212 | + Framework::popup(Framework::link('/index.php', $linkData), $windowName); |
|
| 213 | + $GLOBALS['egw']->framework->render($message, '', true); |
|
| 215 | 214 | if ($exit) |
| 216 | 215 | { |
| 217 | 216 | exit(); |
@@ -227,9 +226,9 @@ discard block |
||
| 227 | 226 | * |
| 228 | 227 | * @throws Api\Exception |
| 229 | 228 | */ |
| 230 | - function changeProfile($_icServerID,$unsetCache=false) |
|
| 229 | + function changeProfile($_icServerID, $unsetCache = false) |
|
| 231 | 230 | { |
| 232 | - if (Mail::$debugTimes) $starttime = microtime (true); |
|
| 231 | + if (Mail::$debugTimes) $starttime = microtime(true); |
|
| 233 | 232 | if (self::$icServerID != $_icServerID) |
| 234 | 233 | { |
| 235 | 234 | self::$icServerID = $_icServerID; |
@@ -237,35 +236,35 @@ discard block |
||
| 237 | 236 | if (Mail::$debug) error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID); |
| 238 | 237 | |
| 239 | 238 | if ($unsetCache) Mail::unsetCachedObjects(self::$icServerID); |
| 240 | - $this->mail_bo = Mail::getInstance(false,self::$icServerID,true, false, true); |
|
| 239 | + $this->mail_bo = Mail::getInstance(false, self::$icServerID, true, false, true); |
|
| 241 | 240 | if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace()); |
| 242 | 241 | // no icServer Object: something failed big time |
| 243 | - if (!isset($this->mail_bo) || !isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId<>$_icServerID) |
|
| 242 | + if (!isset($this->mail_bo) || !isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId <> $_icServerID) |
|
| 244 | 243 | { |
| 245 | 244 | self::$icServerID = $_icServerID; |
| 246 | 245 | throw new Api\Exception('Profile change failed!'); |
| 247 | 246 | } |
| 248 | 247 | |
| 249 | 248 | // save session varchar |
| 250 | - $oldicServerID =& Api\Cache::getSession('mail','activeProfileID'); |
|
| 249 | + $oldicServerID = & Api\Cache::getSession('mail', 'activeProfileID'); |
|
| 251 | 250 | if ($oldicServerID <> self::$icServerID) $this->mail_bo->openConnection(self::$icServerID); |
| 252 | 251 | if (true) $oldicServerID = self::$icServerID; |
| 253 | - if (!Mail::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true )) |
|
| 252 | + if (!Mail::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true)) |
|
| 254 | 253 | { |
| 255 | 254 | throw new Api\Exception(__METHOD__." failed to change Profile to $_icServerID"); |
| 256 | 255 | } |
| 257 | 256 | |
| 258 | - if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 257 | + if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, '', __METHOD__.__LINE__); |
|
| 259 | 258 | } |
| 260 | 259 | |
| 261 | 260 | /** |
| 262 | 261 | * Ajax function to request next branch of a tree branch |
| 263 | 262 | */ |
| 264 | - static function ajax_tree_autoloading ($_id = null) |
|
| 263 | + static function ajax_tree_autoloading($_id = null) |
|
| 265 | 264 | { |
| 266 | 265 | $mail_ui = new mail_ui(); |
| 267 | 266 | $id = $_id ? $_id : $_GET['id']; |
| 268 | - Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id,'',1,false)); |
|
| 267 | + Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id, '', 1, false)); |
|
| 269 | 268 | } |
| 270 | 269 | |
| 271 | 270 | /** |
@@ -274,11 +273,11 @@ discard block |
||
| 274 | 273 | * @param array $content |
| 275 | 274 | * @param type $msg |
| 276 | 275 | */ |
| 277 | - function subscription(array $content=null ,$msg=null) |
|
| 276 | + function subscription(array $content = null, $msg = null) |
|
| 278 | 277 | { |
| 279 | 278 | $stmpl = new Etemplate('mail.subscribe'); |
| 280 | 279 | |
| 281 | - if(is_array($content)) |
|
| 280 | + if (is_array($content)) |
|
| 282 | 281 | { |
| 283 | 282 | $profileId = $content['profileId']; |
| 284 | 283 | } |
@@ -288,14 +287,14 @@ discard block |
||
| 288 | 287 | } |
| 289 | 288 | // Initial tree's options, the rest would be loaded dynamicaly by autoloading, |
| 290 | 289 | // triggered from client-side. Also, we keep this here as |
| 291 | - $sel_options['foldertree'] = $this->mail_tree->getTree(null,$profileId,1,true,false,true); |
|
| 290 | + $sel_options['foldertree'] = $this->mail_tree->getTree(null, $profileId, 1, true, false, true); |
|
| 292 | 291 | |
| 293 | 292 | //Get all subscribed folders |
| 294 | 293 | // as getting all subscribed folders is very fast operation |
| 295 | 294 | // we can use it to get a comparison base for folders which |
| 296 | 295 | // got subscribed or unsubscribed by the user |
| 297 | 296 | try { |
| 298 | - $subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('',0,true); |
|
| 297 | + $subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('', 0, true); |
|
| 299 | 298 | } catch (Exception $ex) { |
| 300 | 299 | Framework::message($ex->getMessage()); |
| 301 | 300 | } |
@@ -306,7 +305,7 @@ discard block |
||
| 306 | 305 | |
| 307 | 306 | foreach ($subscribed as $folder) |
| 308 | 307 | { |
| 309 | - $folderName = $profileId . self::$delimiter . $folder['MAILBOX']; |
|
| 308 | + $folderName = $profileId.self::$delimiter.$folder['MAILBOX']; |
|
| 310 | 309 | array_push($content['foldertree'], $folderName); |
| 311 | 310 | } |
| 312 | 311 | } |
@@ -320,9 +319,9 @@ discard block |
||
| 320 | 319 | { |
| 321 | 320 | // do not let user (un)subscribe namespace roots eg. "other", "user" or "INBOX", same for tree-root/account itself |
| 322 | 321 | $namespace_roots = array($profileId); |
| 323 | - foreach($this->mail_bo->_getNameSpaces() as $namespace) |
|
| 322 | + foreach ($this->mail_bo->_getNameSpaces() as $namespace) |
|
| 324 | 323 | { |
| 325 | - $namespace_roots[] = $profileId . self::$delimiter . str_replace($namespace['delimiter'], '', $namespace['prefix']); |
|
| 324 | + $namespace_roots[] = $profileId.self::$delimiter.str_replace($namespace['delimiter'], '', $namespace['prefix']); |
|
| 326 | 325 | } |
| 327 | 326 | $to_unsubscribe = $to_subscribe = array(); |
| 328 | 327 | foreach ($content['foldertree'] as $path => $value) |
@@ -330,7 +329,7 @@ discard block |
||
| 330 | 329 | list(,$node) = explode($profileId.self::$delimiter, $path); |
| 331 | 330 | if ($node) |
| 332 | 331 | { |
| 333 | - if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe []= $node; |
|
| 332 | + if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe [] = $node; |
|
| 334 | 333 | if (is_array($subscribed) && !$subscribed[$node] && $value['value']) $to_subscribe [] = $node; |
| 335 | 334 | if ($value['value']) $cont[] = $path; |
| 336 | 335 | } |
@@ -340,7 +339,7 @@ discard block |
||
| 340 | 339 | // set foldertree options to basic node in order to avoid initial autoloading |
| 341 | 340 | // from client side, as no options would trigger that. |
| 342 | 341 | $sel_options['foldertree'] = array('id' => '0', 'item'=> array()); |
| 343 | - foreach(array_merge($to_subscribe, $to_unsubscribe) as $mailbox) |
|
| 342 | + foreach (array_merge($to_subscribe, $to_unsubscribe) as $mailbox) |
|
| 344 | 343 | { |
| 345 | 344 | if (in_array($profileId.self::$delimiter.$mailbox, $namespace_roots, true)) |
| 346 | 345 | { |
@@ -376,18 +375,18 @@ discard block |
||
| 376 | 375 | } |
| 377 | 376 | } |
| 378 | 377 | // update foldertree in main window |
| 379 | - $parentFolder='INBOX'; |
|
| 378 | + $parentFolder = 'INBOX'; |
|
| 380 | 379 | $refreshData = array( |
| 381 | 380 | $profileId => lang($parentFolder), |
| 382 | 381 | ); |
| 383 | 382 | $response = Api\Json\Response::get(); |
| 384 | - foreach($refreshData as $folder => &$name) |
|
| 383 | + foreach ($refreshData as $folder => &$name) |
|
| 385 | 384 | { |
| 386 | - $name = $this->mail_tree->getTree($folder, $profileId,1,true,true,true); |
|
| 385 | + $name = $this->mail_tree->getTree($folder, $profileId, 1, true, true, true); |
|
| 387 | 386 | } |
| 388 | 387 | // give success/error message to opener and popup itself |
| 389 | 388 | //$response->call('opener.app.mail.subscription_refresh',$refreshData); |
| 390 | - $response->call('opener.app.mail.mail_reloadNode',$refreshData); |
|
| 389 | + $response->call('opener.app.mail.mail_reloadNode', $refreshData); |
|
| 391 | 390 | |
| 392 | 391 | Framework::refresh_opener($msg, 'mail', null, null, null, null, null, $msg_type); |
| 393 | 392 | if ($button == 'apply') |
@@ -407,7 +406,7 @@ discard block |
||
| 407 | 406 | |
| 408 | 407 | $readonlys = array(); |
| 409 | 408 | |
| 410 | - $stmpl->exec('mail.mail_ui.subscription', $content,$sel_options,$readonlys,$preserv,2); |
|
| 409 | + $stmpl->exec('mail.mail_ui.subscription', $content, $sel_options, $readonlys, $preserv, 2); |
|
| 411 | 410 | } |
| 412 | 411 | |
| 413 | 412 | /** |
@@ -416,13 +415,13 @@ discard block |
||
| 416 | 415 | * @param array $content |
| 417 | 416 | * @param string $msg |
| 418 | 417 | */ |
| 419 | - function index(array $content=null,$msg=null) |
|
| 418 | + function index(array $content = null, $msg = null) |
|
| 420 | 419 | { |
| 421 | 420 | //error_log(__METHOD__.__LINE__.array2string($content)); |
| 422 | - try { |
|
| 421 | + try { |
|
| 423 | 422 | if (!isset($this->mail_bo)) throw new Api\Exception\WrongUserinput(lang('Initialization of mail failed. Please use the Wizard to cope with the problem.')); |
| 424 | 423 | //error_log(__METHOD__.__LINE__.function_backtrace()); |
| 425 | - if (Mail::$debugTimes) $starttime = microtime (true); |
|
| 424 | + if (Mail::$debugTimes) $starttime = microtime(true); |
|
| 426 | 425 | $this->mail_bo->restoreSessionData(); |
| 427 | 426 | $sessionFolder = $this->mail_bo->sessionData['mailbox']; |
| 428 | 427 | if ($this->mail_bo->folderExists($sessionFolder)) |
@@ -443,26 +442,26 @@ discard block |
||
| 443 | 442 | { |
| 444 | 443 | // These only set on first load |
| 445 | 444 | $content[self::$nm_index] = array( |
| 446 | - 'filter' => 'any', // filter is used to choose the mailbox |
|
| 447 | - 'lettersearch' => false, // I show a lettersearch |
|
| 448 | - 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
| 449 | - 'start' => 0, // IO position in list |
|
| 450 | - 'order' => 'date', // IO name of the column to sort after (optional for the sortheaders) |
|
| 451 | - 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 445 | + 'filter' => 'any', // filter is used to choose the mailbox |
|
| 446 | + 'lettersearch' => false, // I show a lettersearch |
|
| 447 | + 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
| 448 | + 'start' => 0, // IO position in list |
|
| 449 | + 'order' => 'date', // IO name of the column to sort after (optional for the sortheaders) |
|
| 450 | + 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 452 | 451 | ); |
| 453 | 452 | } |
| 454 | 453 | if (Api\Header\UserAgent::mobile()) $content[self::$nm_index]['header_row'] = 'mail.index.header_right'; |
| 455 | 454 | } |
| 456 | 455 | |
| 457 | 456 | // These must always be set, even if $content is an array |
| 458 | - $content[self::$nm_index]['cat_is_select'] = true; // Category select is just a normal selectbox |
|
| 459 | - $content[self::$nm_index]['no_filter2'] = false; // Disable second filter |
|
| 457 | + $content[self::$nm_index]['cat_is_select'] = true; // Category select is just a normal selectbox |
|
| 458 | + $content[self::$nm_index]['no_filter2'] = false; // Disable second filter |
|
| 460 | 459 | $content[self::$nm_index]['actions'] = self::get_actions(); |
| 461 | - $content[self::$nm_index]['row_id'] = 'row_id'; // is a concatenation of trim($GLOBALS['egw_info']['user']['account_id']):profileID:base64_encode(FOLDERNAME):uid |
|
| 460 | + $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 | 461 | $content[self::$nm_index]['placeholder_actions'] = array('composeasnew'); |
| 463 | 462 | $content[self::$nm_index]['get_rows'] = 'mail_ui::get_rows'; |
| 464 | - $content[self::$nm_index]['num_rows'] = 0; // Do not send any rows with initial request |
|
| 465 | - $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 |
|
| 463 | + $content[self::$nm_index]['num_rows'] = 0; // Do not send any rows with initial request |
|
| 464 | + $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 |
|
| 466 | 465 | $content[self::$nm_index]['csv_fields'] = false; |
| 467 | 466 | if ($msg) |
| 468 | 467 | { |
@@ -474,11 +473,11 @@ discard block |
||
| 474 | 473 | unset($content['msg']); |
| 475 | 474 | } |
| 476 | 475 | // call getQuotaRoot asynchronously in getRows by initiating a client Server roundtrip |
| 477 | - $quota = false;//$this->mail_bo->getQuotaRoot(); |
|
| 478 | - if($quota !== false && $quota['limit'] != 'NOT SET') { |
|
| 476 | + $quota = false; //$this->mail_bo->getQuotaRoot(); |
|
| 477 | + if ($quota !== false && $quota['limit'] != 'NOT SET') { |
|
| 479 | 478 | $quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']); |
| 480 | 479 | $content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text']; |
| 481 | - $content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent']; |
|
| 480 | + $content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent']; |
|
| 482 | 481 | $content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class']; |
| 483 | 482 | $content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = ""; |
| 484 | 483 | } else { |
@@ -487,43 +486,43 @@ discard block |
||
| 487 | 486 | $content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone"; |
| 488 | 487 | } |
| 489 | 488 | // call gatherVacation asynchronously in getRows by initiating a client Server roundtrip |
| 490 | - $vacation = false;//$this->gatherVacation(); |
|
| 489 | + $vacation = false; //$this->gatherVacation(); |
|
| 491 | 490 | //error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation)); |
| 492 | - if($vacation) { |
|
| 493 | - if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date' && $vacation['end_date'] > time())) |
|
| 491 | + if ($vacation) { |
|
| 492 | + if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status'] == 'by_date' && $vacation['end_date'] > time())) |
|
| 494 | 493 | { |
| 495 | 494 | $dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']/*.' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat']!='24'?'h:i a':'H:i')*/; |
| 496 | 495 | $content[self::$nm_index]['vacationnotice'] = $sel_options[self::$nm_index]['vacationnotice'] = lang('Vacation notice is active'); |
| 497 | - $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):''):''); |
|
| 496 | + $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 | 497 | } |
| 499 | 498 | } |
| 500 | - if ($vacation==false) |
|
| 499 | + if ($vacation == false) |
|
| 501 | 500 | { |
| 502 | 501 | $content[self::$nm_index]['vacationnotice'] = $sel_options[self::$nm_index]['vacationnotice'] = ''; |
| 503 | 502 | $content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = ''; |
| 504 | 503 | } |
| 505 | 504 | //$zstarttime = microtime (true); |
| 506 | - $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']); |
|
| 505 | + $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 | 506 | //$zendtime = microtime(true) - $zstarttime; |
| 508 | 507 | //error_log(__METHOD__.__LINE__. " time used: ".$zendtime); |
| 509 | - $content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.(!empty($this->mail_bo->sessionData['mailbox'])?$this->mail_bo->sessionData['mailbox']:'INBOX'); |
|
| 508 | + $content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.(!empty($this->mail_bo->sessionData['mailbox']) ? $this->mail_bo->sessionData['mailbox'] : 'INBOX'); |
|
| 510 | 509 | // since we are connected,(and selected the folder) we check for capabilities SUPPORTS_KEYWORDS to eventually add the keyword filters |
| 511 | - if ( $this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS')) |
|
| 510 | + if ($this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS')) |
|
| 512 | 511 | { |
| 513 | - $this->statusTypes = array_merge($this->statusTypes,array( |
|
| 514 | - 'keyword1' => 'important',//lang('important'), |
|
| 515 | - 'keyword2' => 'job', //lang('job'), |
|
| 516 | - 'keyword3' => 'personal',//lang('personal'), |
|
| 517 | - 'keyword4' => 'to do', //lang('to do'), |
|
| 518 | - 'keyword5' => 'later', //lang('later'), |
|
| 512 | + $this->statusTypes = array_merge($this->statusTypes, array( |
|
| 513 | + 'keyword1' => 'important', //lang('important'), |
|
| 514 | + 'keyword2' => 'job', //lang('job'), |
|
| 515 | + 'keyword3' => 'personal', //lang('personal'), |
|
| 516 | + 'keyword4' => 'to do', //lang('to do'), |
|
| 517 | + 'keyword5' => 'later', //lang('later'), |
|
| 519 | 518 | )); |
| 520 | 519 | } |
| 521 | 520 | else |
| 522 | 521 | { |
| 523 | - $keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5'); |
|
| 524 | - foreach($keywords as &$k) |
|
| 522 | + $keywords = array('keyword1', 'keyword2', 'keyword3', 'keyword4', 'keyword5'); |
|
| 523 | + foreach ($keywords as &$k) |
|
| 525 | 524 | { |
| 526 | - if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]); |
|
| 525 | + if (array_key_exists($k, $this->statusTypes)) unset($this->statusTypes[$k]); |
|
| 527 | 526 | } |
| 528 | 527 | } |
| 529 | 528 | |
@@ -534,8 +533,8 @@ discard block |
||
| 534 | 533 | |
| 535 | 534 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
| 536 | 535 | { |
| 537 | - Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
|
| 538 | - if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 536 | + Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 537 | + if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true; |
|
| 539 | 538 | } |
| 540 | 539 | if (!Mail::$supportsORinQuery[$this->mail_bo->profileID]) |
| 541 | 540 | { |
@@ -547,14 +546,14 @@ discard block |
||
| 547 | 546 | //error_log(__METHOD__.__LINE__.array2string($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType'])); |
| 548 | 547 | $content[self::$nm_index]['cat_id'] = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']; |
| 549 | 548 | $sel_options['filter'] = $this->statusTypes; |
| 550 | - $sel_options['filter2'] = array(''=>lang('No Sneak Preview in list'),1=>lang('Sneak Preview in list')); |
|
| 549 | + $sel_options['filter2'] = array(''=>lang('No Sneak Preview in list'), 1=>lang('Sneak Preview in list')); |
|
| 551 | 550 | $content[self::$nm_index]['filter2'] = $GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']; |
| 552 | 551 | |
| 553 | 552 | $etpl = new Etemplate('mail.index'); |
| 554 | 553 | //apply infolog_filter_change javascript method (hide/show of date filter form) over onchange filter |
| 555 | 554 | $content[self::$nm_index]['cat_id_onchange'] = "app.mail.mail_searchtype_change()"; |
| 556 | 555 | // set the actions on tree |
| 557 | - $etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $this->get_tree_actions()); |
|
| 556 | + $etpl->setElementAttribute(self::$nm_index.'[foldertree]', 'actions', $this->get_tree_actions()); |
|
| 558 | 557 | |
| 559 | 558 | // sending preview toolbar actions |
| 560 | 559 | if ($content['mailSplitter']) $etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions()); |
@@ -565,28 +564,28 @@ discard block |
||
| 565 | 564 | //we use the category "filter" option as specifier where we want to search (quick, subject, from, to, etc. ....) |
| 566 | 565 | if (empty($content[self::$nm_index]['cat_id']) || empty($content[self::$nm_index]['search'])) |
| 567 | 566 | { |
| 568 | - $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')); |
|
| 567 | + $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')); |
|
| 569 | 568 | } |
| 570 | 569 | $readonlys = $preserv = array(); |
| 571 | - if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 570 | + if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, '', __METHOD__.__LINE__); |
|
| 572 | 571 | } |
| 573 | 572 | catch (Exception $e) |
| 574 | 573 | { |
| 575 | 574 | // do not exit here. mail-tree should be build. if we exit here, we never get there. |
| 576 | - error_log(__METHOD__.__LINE__.$e->getMessage().($e->details?', '.$e->details:'').' Menuaction:'.$_GET['menuaction'].'.'.function_backtrace()); |
|
| 575 | + error_log(__METHOD__.__LINE__.$e->getMessage().($e->details ? ', '.$e->details : '').' Menuaction:'.$_GET['menuaction'].'.'.function_backtrace()); |
|
| 577 | 576 | if (isset($this->mail_bo)) |
| 578 | 577 | { |
| 579 | 578 | if (empty($etpl)) |
| 580 | 579 | { |
| 581 | - $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']); |
|
| 580 | + $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']); |
|
| 582 | 581 | $etpl = new Etemplate('mail.index'); |
| 583 | 582 | } |
| 584 | - $etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $this->get_tree_actions(false)); |
|
| 583 | + $etpl->setElementAttribute(self::$nm_index.'[foldertree]', 'actions', $this->get_tree_actions(false)); |
|
| 585 | 584 | } |
| 586 | 585 | $readonlys = $preserv = array(); |
| 587 | - if (empty($content)) $content=array(); |
|
| 586 | + if (empty($content)) $content = array(); |
|
| 588 | 587 | |
| 589 | - self::callWizard($e->getMessage().($e->details?', '.$e->details:''),(isset($this->mail_bo)?false:true), 'error',false); |
|
| 588 | + self::callWizard($e->getMessage().($e->details ? ', '.$e->details : ''), (isset($this->mail_bo) ? false : true), 'error', false); |
|
| 590 | 589 | //return false; |
| 591 | 590 | } |
| 592 | 591 | // Check preview pane is enabled, then show splitter - preference used to be '1', now 'hide' |
@@ -595,7 +594,7 @@ discard block |
||
| 595 | 594 | $etpl->setElementAttribute('splitter', 'template', 'mail.index.nosplitter'); |
| 596 | 595 | } |
| 597 | 596 | |
| 598 | - return $etpl->exec('mail.mail_ui.index',$content,$sel_options,$readonlys,$preserv); |
|
| 597 | + return $etpl->exec('mail.mail_ui.index', $content, $sel_options, $readonlys, $preserv); |
|
| 599 | 598 | } |
| 600 | 599 | |
| 601 | 600 | /** |
@@ -605,11 +604,11 @@ discard block |
||
| 605 | 604 | * @param {boolean} $imap_actions set to false if you want to avoid to talk to the imap-server |
| 606 | 605 | * @return array |
| 607 | 606 | */ |
| 608 | - function get_tree_actions($imap_actions=true) |
|
| 607 | + function get_tree_actions($imap_actions = true) |
|
| 609 | 608 | { |
| 610 | 609 | // Start at 2 so auto-added copy+paste actions show up as second group |
| 611 | 610 | // Needed because there's no 'select all' action to push things down |
| 612 | - $group=1; |
|
| 611 | + $group = 1; |
|
| 613 | 612 | // Set tree actions |
| 614 | 613 | $tree_actions = array( |
| 615 | 614 | 'drop_move_mail' => array( |
@@ -691,12 +690,12 @@ discard block |
||
| 691 | 690 | 'onExecute' => 'javaScript:app.mail.edit_sieve', |
| 692 | 691 | |
| 693 | 692 | 'enabled' => 'javaScript:app.mail.sieve_enabled', |
| 694 | - 'icon' => 'mail/filter', // funnel |
|
| 693 | + 'icon' => 'mail/filter', // funnel |
|
| 695 | 694 | 'hideOnMobile' => true |
| 696 | 695 | ), |
| 697 | 696 | 'vacation' => array( |
| 698 | 697 | 'caption' => 'Vacation notice', |
| 699 | - 'icon' => 'mail/navbar', // mail as in admin |
|
| 698 | + 'icon' => 'mail/navbar', // mail as in admin |
|
| 700 | 699 | 'onExecute' => 'javaScript:app.mail.edit_vacation', |
| 701 | 700 | 'enabled' => 'javaScript:app.mail.sieve_enabled', |
| 702 | 701 | ), |
@@ -737,8 +736,8 @@ discard block |
||
| 737 | 736 | unset($tree_actions['subscribe']); |
| 738 | 737 | unset($tree_actions['unsubscribe']); |
| 739 | 738 | } |
| 740 | - ++$group; // put delete in own group |
|
| 741 | - switch($GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions']) |
|
| 739 | + ++$group; // put delete in own group |
|
| 740 | + switch ($GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions']) |
|
| 742 | 741 | { |
| 743 | 742 | case 'move_to_trash': |
| 744 | 743 | $tree_actions['empty_trash'] = array( |
@@ -757,7 +756,7 @@ discard block |
||
| 757 | 756 | ); |
| 758 | 757 | break; |
| 759 | 758 | } |
| 760 | - $junkFolder = ($imap_actions?$this->mail_bo->getJunkFolder():null); |
|
| 759 | + $junkFolder = ($imap_actions ? $this->mail_bo->getJunkFolder() : null); |
|
| 761 | 760 | |
| 762 | 761 | //error_log(__METHOD__.__LINE__.$junkFolder); |
| 763 | 762 | if ($junkFolder && !empty($junkFolder)) |
@@ -770,8 +769,8 @@ discard block |
||
| 770 | 769 | 'group' => $group, |
| 771 | 770 | ); |
| 772 | 771 | } |
| 773 | - $tree_actions['sieve']['group'] = $tree_actions['vacation']['group'] = ++$group; // new group for filter |
|
| 774 | - $tree_actions['edit_account']['group'] = $tree_actions['edit_acl']['group'] = ++$group; |
|
| 772 | + $tree_actions['sieve']['group'] = $tree_actions['vacation']['group'] = ++$group; // new group for filter |
|
| 773 | + $tree_actions['edit_account']['group'] = $tree_actions['edit_acl']['group'] = ++$group; |
|
| 775 | 774 | |
| 776 | 775 | |
| 777 | 776 | // enforce global (group-specific) ACL |
@@ -806,17 +805,17 @@ discard block |
||
| 806 | 805 | * @param {string} $_folderName name of mailbox needs to be subcribe or unsubscribed |
| 807 | 806 | * @param {boolean} $_status set true for subscribe and false to unsubscribe |
| 808 | 807 | */ |
| 809 | - public function ajax_foldersubscription($_acc_id,$_folderName, $_status) |
|
| 808 | + public function ajax_foldersubscription($_acc_id, $_folderName, $_status) |
|
| 810 | 809 | { |
| 811 | 810 | //Change the Mail object to related profileId |
| 812 | 811 | $this->changeProfile($_acc_id); |
| 813 | - try{ |
|
| 812 | + try { |
|
| 814 | 813 | $this->mail_bo->icServer->subscribeMailbox($_folderName, $_status); |
| 815 | 814 | $this->mail_bo->resetFolderObjectCache($_acc_id); |
| 816 | - $this->ajax_reloadNode($_acc_id,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 815 | + $this->ajax_reloadNode($_acc_id, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 817 | 816 | } catch (Horde_Imap_Client_Exception $ex) { |
| 818 | - error_log(__METHOD__.__LINE__."()". lang('Folder %1 %2 failed because of %3!',$_folderName,$_status?'subscribed':'unsubscribed', $ex)); |
|
| 819 | - Framework::message(lang('Folder %1 %2 failed!',$_folderName,$_status)); |
|
| 817 | + error_log(__METHOD__.__LINE__."()".lang('Folder %1 %2 failed because of %3!', $_folderName, $_status ? 'subscribed' : 'unsubscribed', $ex)); |
|
| 818 | + Framework::message(lang('Folder %1 %2 failed!', $_folderName, $_status)); |
|
| 820 | 819 | } |
| 821 | 820 | } |
| 822 | 821 | |
@@ -828,25 +827,25 @@ discard block |
||
| 828 | 827 | * @param string $_nodeID if of node whose children are requested |
| 829 | 828 | * @param boolean $_subscribedOnly flag to tell whether to fetch all or only subscribed (default) |
| 830 | 829 | */ |
| 831 | - public function ajax_foldertree($_nodeID = null,$_subscribedOnly=null) |
|
| 830 | + public function ajax_foldertree($_nodeID = null, $_subscribedOnly = null) |
|
| 832 | 831 | { |
| 833 | 832 | $nodeID = $_GET['id']; |
| 834 | 833 | if (!is_null($_nodeID)) $nodeID = $_nodeID; |
| 835 | - $subscribedOnly = (bool)(!is_null($_subscribedOnly)?$_subscribedOnly:!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 834 | + $subscribedOnly = (bool)(!is_null($_subscribedOnly) ? $_subscribedOnly : !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 836 | 835 | $fetchCounters = !is_null($_nodeID); |
| 837 | - list($_profileID,$_folderName) = explode(self::$delimiter,$nodeID,2); |
|
| 836 | + list($_profileID, $_folderName) = explode(self::$delimiter, $nodeID, 2); |
|
| 838 | 837 | |
| 839 | 838 | if (!empty($_folderName)) $fetchCounters = true; |
| 840 | 839 | |
| 841 | 840 | // Check if it is called for refresh root |
| 842 | 841 | // then we need to reinitialized the index tree |
| 843 | - if(!$nodeID && !$_profileID) |
|
| 842 | + if (!$nodeID && !$_profileID) |
|
| 844 | 843 | { |
| 845 | - $data = $this->mail_tree->getInitialIndexTree(null,null,null,null,true,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 844 | + $data = $this->mail_tree->getInitialIndexTree(null, null, null, null, true, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 846 | 845 | } |
| 847 | 846 | else |
| 848 | 847 | { |
| 849 | - $data = $this->mail_tree->getTree($nodeID,$_profileID,0, false,$subscribedOnly,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 848 | + $data = $this->mail_tree->getTree($nodeID, $_profileID, 0, false, $subscribedOnly, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 850 | 849 | } |
| 851 | 850 | if (!is_null($_nodeID)) return $data; |
| 852 | 851 | Etemplate\Widget\Tree::send_quote_json($data); |
@@ -862,17 +861,17 @@ discard block |
||
| 862 | 861 | */ |
| 863 | 862 | static function findNode($_out, $_nodeID, $childElements = false) |
| 864 | 863 | { |
| 865 | - foreach($_out['item'] as $node) |
|
| 864 | + foreach ($_out['item'] as $node) |
|
| 866 | 865 | { |
| 867 | - if (strcmp($node['id'],$_nodeID)===0) |
|
| 866 | + if (strcmp($node['id'], $_nodeID) === 0) |
|
| 868 | 867 | { |
| 869 | 868 | //error_log(__METHOD__.__LINE__.':'.$_nodeID.'->'.$node['id']); |
| 870 | - return ($childElements?$node['item']:$node); |
|
| 869 | + return ($childElements ? $node['item'] : $node); |
|
| 871 | 870 | } |
| 872 | - elseif (is_array($node['item']) && strncmp($node['id'],$_nodeID,strlen($node['id']))===0 && strlen($_nodeID)>strlen($node['id'])) |
|
| 871 | + elseif (is_array($node['item']) && strncmp($node['id'], $_nodeID, strlen($node['id'])) === 0 && strlen($_nodeID) > strlen($node['id'])) |
|
| 873 | 872 | { |
| 874 | 873 | //error_log(__METHOD__.__LINE__.' descend into '.$node['id']); |
| 875 | - return self::findNode($node,$_nodeID,$childElements); |
|
| 874 | + return self::findNode($node, $_nodeID, $childElements); |
|
| 876 | 875 | } |
| 877 | 876 | } |
| 878 | 877 | } |
@@ -958,11 +957,11 @@ discard block |
||
| 958 | 957 | |
| 959 | 958 | if ($refresh) |
| 960 | 959 | { |
| 961 | - $response->data([implode('\n',$msg),$messages]); |
|
| 960 | + $response->data([implode('\n', $msg), $messages]); |
|
| 962 | 961 | } |
| 963 | 962 | else |
| 964 | 963 | { |
| 965 | - $response->apply('egw.message',[implode('\n',$msg)]); |
|
| 964 | + $response->apply('egw.message', [implode('\n', $msg)]); |
|
| 966 | 965 | } |
| 967 | 966 | } |
| 968 | 967 | |
@@ -971,22 +970,22 @@ discard block |
||
| 971 | 970 | * |
| 972 | 971 | * @return array actions |
| 973 | 972 | */ |
| 974 | - public function getSpamActions () |
|
| 973 | + public function getSpamActions() |
|
| 975 | 974 | { |
| 976 | - $actions = array ( |
|
| 977 | - 'spamfilter' => array ( |
|
| 975 | + $actions = array( |
|
| 976 | + 'spamfilter' => array( |
|
| 978 | 977 | 'caption' => 'Spam', |
| 979 | 978 | 'icon' => 'dhtmlxtree/MailFolderJunk', |
| 980 | 979 | 'allowOnMultiple' => true, |
| 981 | - 'children' => array ( |
|
| 982 | - 'spam' => array ( |
|
| 980 | + 'children' => array( |
|
| 981 | + 'spam' => array( |
|
| 983 | 982 | 'caption' => 'Report as Spam', |
| 984 | 983 | 'icon' => 'dhtmlxtree/MailFolderJunk', |
| 985 | 984 | 'onExecute' => 'javaScript:app.mail.spam_actions', |
| 986 | 985 | 'hint' => 'Report this email content as Spam - spam solutions like spamTitan will learn', |
| 987 | 986 | 'allowOnMultiple' => true |
| 988 | 987 | ), |
| 989 | - 'ham' => array ( |
|
| 988 | + 'ham' => array( |
|
| 990 | 989 | 'caption' => 'Report as Ham', |
| 991 | 990 | 'icon' => 'dhtmlxtree/MailFolderHam', |
| 992 | 991 | 'onExecute' => 'javaScript:app.mail.spam_actions', |
@@ -1013,7 +1012,7 @@ discard block |
||
| 1013 | 1012 | */ |
| 1014 | 1013 | private function get_actions() |
| 1015 | 1014 | { |
| 1016 | - static $accArray=array(); // buffer identity names on single request |
|
| 1015 | + static $accArray = array(); // buffer identity names on single request |
|
| 1017 | 1016 | // duplicated from mail_hooks |
| 1018 | 1017 | static $deleteOptions = array( |
| 1019 | 1018 | 'move_to_trash' => 'move to trash', |
@@ -1024,12 +1023,12 @@ discard block |
||
| 1024 | 1023 | $lastFolderUsedForMove = null; |
| 1025 | 1024 | $moveactions = array(); |
| 1026 | 1025 | $archiveFolder = $this->mail_bo->getArchiveFolder(); |
| 1027 | - $lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1); |
|
| 1026 | + $lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 1); |
|
| 1028 | 1027 | //error_log(__METHOD__.__LINE__." StoredFolders->".array2string($lastFoldersUsedForMoveCont)); |
| 1029 | 1028 | //error_log(__METHOD__.__LINE__.' ProfileId:'.$this->mail_bo->profileID." StoredFolders->(".count($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]).") ".array2string($lastFoldersUsedForMoveCont[$this->mail_bo->profileID])); |
| 1030 | 1029 | if (is_null($accArray)) |
| 1031 | 1030 | { |
| 1032 | - foreach(Mail\Account::search($only_current_user=true, false) as $acc_id => $accountObj) |
|
| 1031 | + foreach (Mail\Account::search($only_current_user = true, false) as $acc_id => $accountObj) |
|
| 1033 | 1032 | { |
| 1034 | 1033 | //error_log(__METHOD__.__LINE__.array2string($accountObj)); |
| 1035 | 1034 | if (!$accountObj->is_imap()) |
@@ -1037,22 +1036,22 @@ discard block |
||
| 1037 | 1036 | // not to be used for IMAP Foldertree, as there is no Imap host |
| 1038 | 1037 | continue; |
| 1039 | 1038 | } |
| 1040 | - $identity_name = Mail\Account::identity_name($accountObj,true,$GLOBALS['egw_info']['user']['acount_id']); |
|
| 1041 | - $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 |
|
| 1039 | + $identity_name = Mail\Account::identity_name($accountObj, true, $GLOBALS['egw_info']['user']['acount_id']); |
|
| 1040 | + $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 |
|
| 1042 | 1041 | } |
| 1043 | 1042 | } |
| 1044 | - if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont=array(); |
|
| 1043 | + if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont = array(); |
|
| 1045 | 1044 | foreach (array_keys($lastFoldersUsedForMoveCont) as $pid) |
| 1046 | 1045 | { |
| 1047 | - if ($this->mail_bo->profileID==$pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID])) |
|
| 1046 | + if ($this->mail_bo->profileID == $pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID])) |
|
| 1048 | 1047 | { |
| 1049 | 1048 | $_folder = $this->mail_bo->icServer->getCurrentMailbox(); |
| 1050 | 1049 | //error_log(__METHOD__.__LINE__.' '.$_folder."<->".$lastFoldersUsedForMoveCont[$this->mail_bo->profileID].function_backtrace()); |
| 1051 | - $counter =1; |
|
| 1050 | + $counter = 1; |
|
| 1052 | 1051 | foreach ($lastFoldersUsedForMoveCont[$this->mail_bo->profileID] as $i => $lastFolderUsedForMoveCont) |
| 1053 | 1052 | { |
| 1054 | 1053 | $moveaction = 'move_'; |
| 1055 | - if ($_folder!=$i) |
|
| 1054 | + if ($_folder != $i) |
|
| 1056 | 1055 | { |
| 1057 | 1056 | $moveaction .= $lastFolderUsedForMoveCont; |
| 1058 | 1057 | //error_log(__METHOD__.__LINE__.'#'.$moveaction); |
@@ -1063,7 +1062,7 @@ discard block |
||
| 1063 | 1062 | $fS['profileName'] = $accArray[$this->mail_bo->profileID]; |
| 1064 | 1063 | $fS['shortDisplayName'] = $i; |
| 1065 | 1064 | $moveactions[$moveaction] = $fS; |
| 1066 | - $counter ++; |
|
| 1065 | + $counter++; |
|
| 1067 | 1066 | } |
| 1068 | 1067 | else |
| 1069 | 1068 | { |
@@ -1073,9 +1072,9 @@ discard block |
||
| 1073 | 1072 | } |
| 1074 | 1073 | } |
| 1075 | 1074 | } |
| 1076 | - elseif ($this->mail_bo->profileID!=$pid && isset($lastFoldersUsedForMoveCont[$pid]) && !empty($lastFoldersUsedForMoveCont[$pid])) |
|
| 1075 | + elseif ($this->mail_bo->profileID != $pid && isset($lastFoldersUsedForMoveCont[$pid]) && !empty($lastFoldersUsedForMoveCont[$pid])) |
|
| 1077 | 1076 | { |
| 1078 | - $counter =1; |
|
| 1077 | + $counter = 1; |
|
| 1079 | 1078 | foreach ($lastFoldersUsedForMoveCont[$pid] as $i => $lastFolderUsedForMoveCont) |
| 1080 | 1079 | { |
| 1081 | 1080 | //error_log(__METHOD__.__LINE__."$i => $lastFolderUsedForMoveCont"); |
@@ -1088,19 +1087,19 @@ discard block |
||
| 1088 | 1087 | $fS['profileName'] = $accArray[$pid]; |
| 1089 | 1088 | $fS['shortDisplayName'] = $i; |
| 1090 | 1089 | $moveactions[$moveaction] = $fS; |
| 1091 | - $counter ++; |
|
| 1090 | + $counter++; |
|
| 1092 | 1091 | } |
| 1093 | 1092 | } |
| 1094 | 1093 | } |
| 1095 | 1094 | } |
| 1096 | - Api\Cache::setCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFoldersUsedForMoveCont, $expiration=60*60*1); |
|
| 1095 | + Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), $lastFoldersUsedForMoveCont, $expiration = 60 * 60 * 1); |
|
| 1097 | 1096 | $group = 0; |
| 1098 | - $actions = array( |
|
| 1097 | + $actions = array( |
|
| 1099 | 1098 | 'open' => array( |
| 1100 | 1099 | 'caption' => lang('Open'), |
| 1101 | 1100 | 'icon' => 'view', |
| 1102 | 1101 | 'group' => ++$group, |
| 1103 | - 'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.mail.mobileView':'javaScript:app.mail.mail_open', |
|
| 1102 | + 'onExecute' => Api\Header\UserAgent::mobile() ? 'javaScript:app.mail.mobileView' : 'javaScript:app.mail.mail_open', |
|
| 1104 | 1103 | 'allowOnMultiple' => false, |
| 1105 | 1104 | 'default' => true, |
| 1106 | 1105 | 'mobileViewTemplate' => 'view?'.filemtime(Api\Etemplate\Widget\Template::rel2path('/mail/templates/mobile/view.xet')) |
@@ -1153,20 +1152,20 @@ discard block |
||
| 1153 | 1152 | 'allowOnMultiple' => false, |
| 1154 | 1153 | ) |
| 1155 | 1154 | ); |
| 1156 | - $macounter=0; |
|
| 1155 | + $macounter = 0; |
|
| 1157 | 1156 | if (!empty($moveactions)) |
| 1158 | 1157 | { |
| 1159 | 1158 | //error_log(__METHOD__.__LINE__.array2string($moveactions)); |
| 1160 | - $children=array(); |
|
| 1161 | - $pID=0; |
|
| 1159 | + $children = array(); |
|
| 1160 | + $pID = 0; |
|
| 1162 | 1161 | foreach ($moveactions as $moveaction => $lastFolderUsedForMove) |
| 1163 | 1162 | { |
| 1164 | - $group = ($pID != $lastFolderUsedForMove['profileID'] && $macounter>0? $group+1 : $group); |
|
| 1163 | + $group = ($pID != $lastFolderUsedForMove['profileID'] && $macounter > 0 ? $group + 1 : $group); |
|
| 1165 | 1164 | //error_log(__METHOD__.__LINE__."#$pID != ".$lastFolderUsedForMove['profileID']."#".$macounter.'#'.$groupCounter.'#'); |
| 1166 | 1165 | $children = array_merge($children, |
| 1167 | 1166 | array( |
| 1168 | 1167 | $moveaction => array( |
| 1169 | - 'caption' => (!empty($lastFolderUsedForMove['profileName'])?$lastFolderUsedForMove['profileName']:'('.$lastFolderUsedForMove['profileID'].')').': '.(isset($lastFolderUsedForMove['shortDisplayName'])?$lastFolderUsedForMove['shortDisplayName']:''), |
|
| 1168 | + 'caption' => (!empty($lastFolderUsedForMove['profileName']) ? $lastFolderUsedForMove['profileName'] : '('.$lastFolderUsedForMove['profileID'].')').': '.(isset($lastFolderUsedForMove['shortDisplayName']) ? $lastFolderUsedForMove['shortDisplayName'] : ''), |
|
| 1170 | 1169 | 'icon' => 'move', |
| 1171 | 1170 | 'group' => $group, |
| 1172 | 1171 | 'onExecute' => 'javaScript:app.mail.mail_move2folder', |
@@ -1177,7 +1176,7 @@ discard block |
||
| 1177 | 1176 | $pID = $lastFolderUsedForMove['profileID']; |
| 1178 | 1177 | $macounter++; |
| 1179 | 1178 | } |
| 1180 | - $actions['moveto'] = array( |
|
| 1179 | + $actions['moveto'] = array( |
|
| 1181 | 1180 | 'caption' => lang('Move selected to'), |
| 1182 | 1181 | 'icon' => 'move', |
| 1183 | 1182 | 'group' => $group, |
@@ -1225,7 +1224,7 @@ discard block |
||
| 1225 | 1224 | 'icon' => 'tracker/navbar', |
| 1226 | 1225 | 'onExecute' => 'javaScript:app.mail.mail_integrate', |
| 1227 | 1226 | 'popup' => Link::get_registry('tracker', 'add_popup'), |
| 1228 | - 'mail_import' => Api\Hooks::single(array('location' => 'mail_import'),'tracker'), |
|
| 1227 | + 'mail_import' => Api\Hooks::single(array('location' => 'mail_import'), 'tracker'), |
|
| 1229 | 1228 | 'allowOnMultiple' => false, |
| 1230 | 1229 | ), |
| 1231 | 1230 | 'calendar' => array( |
@@ -1449,25 +1448,25 @@ discard block |
||
| 1449 | 1448 | * @param array &$rows |
| 1450 | 1449 | * @param array &$readonlys |
| 1451 | 1450 | */ |
| 1452 | - public static function get_rows(&$query,&$rows,&$readonlys) |
|
| 1451 | + public static function get_rows(&$query, &$rows, &$readonlys) |
|
| 1453 | 1452 | { |
| 1454 | - unset($readonlys); // not used, but required by function signature |
|
| 1453 | + unset($readonlys); // not used, but required by function signature |
|
| 1455 | 1454 | |
| 1456 | 1455 | // handle possible profile change in get_rows |
| 1457 | 1456 | if (!empty($query['selectedFolder'])) |
| 1458 | 1457 | { |
| 1459 | - list($_profileID,$folderName) = explode(self::$delimiter, $query['selectedFolder'], 2); |
|
| 1458 | + list($_profileID, $folderName) = explode(self::$delimiter, $query['selectedFolder'], 2); |
|
| 1460 | 1459 | if (is_numeric(($_profileID)) && $_profileID != $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']) |
| 1461 | 1460 | { |
| 1462 | 1461 | try { |
| 1463 | - $mail_ui = new mail_ui(false); // do NOT run constructor, as we change profile anyway |
|
| 1462 | + $mail_ui = new mail_ui(false); // do NOT run constructor, as we change profile anyway |
|
| 1464 | 1463 | $mail_ui->changeProfile($_profileID); |
| 1465 | 1464 | $query['actions'] = $mail_ui->get_actions(); |
| 1466 | 1465 | } |
| 1467 | - catch(Exception $e) |
|
| 1466 | + catch (Exception $e) |
|
| 1468 | 1467 | { |
| 1469 | 1468 | unset($e); |
| 1470 | - $rows=array(); |
|
| 1469 | + $rows = array(); |
|
| 1471 | 1470 | return 0; |
| 1472 | 1471 | } |
| 1473 | 1472 | if (empty($folderName)) $query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX'; |
@@ -1477,12 +1476,12 @@ discard block |
||
| 1477 | 1476 | { |
| 1478 | 1477 | try |
| 1479 | 1478 | { |
| 1480 | - $mail_ui = new mail_ui(true); // run constructor for current profile |
|
| 1479 | + $mail_ui = new mail_ui(true); // run constructor for current profile |
|
| 1481 | 1480 | } |
| 1482 | - catch(Exception $e) |
|
| 1481 | + catch (Exception $e) |
|
| 1483 | 1482 | { |
| 1484 | 1483 | unset($e); |
| 1485 | - $rows=array(); |
|
| 1484 | + $rows = array(); |
|
| 1486 | 1485 | return 0; |
| 1487 | 1486 | } |
| 1488 | 1487 | if (empty($query['selectedFolder'])) $query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX'; |
@@ -1493,66 +1492,66 @@ discard block |
||
| 1493 | 1492 | //$query['search'] is the phrase in the searchbox |
| 1494 | 1493 | |
| 1495 | 1494 | $mail_ui->mail_bo->restoreSessionData(); |
| 1496 | - if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder']; |
|
| 1495 | + if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox'] = $query['selectedFolder']; |
|
| 1497 | 1496 | |
| 1498 | 1497 | $sRToFetch = null; |
| 1499 | - list($_profileID,$_folderName) = explode(self::$delimiter,$query['selectedFolder'],2); |
|
| 1500 | - if (strpos($_folderName,self::$delimiter)!==false) |
|
| 1498 | + list($_profileID, $_folderName) = explode(self::$delimiter, $query['selectedFolder'], 2); |
|
| 1499 | + if (strpos($_folderName, self::$delimiter) !== false) |
|
| 1501 | 1500 | { |
| 1502 | - list($app,$_profileID,$_folderName) = explode(self::$delimiter,$_folderName,3); |
|
| 1501 | + list($app, $_profileID, $_folderName) = explode(self::$delimiter, $_folderName, 3); |
|
| 1503 | 1502 | unset($app); |
| 1504 | 1503 | } |
| 1505 | 1504 | //save selected Folder to sessionData (mailbox)->currentFolder |
| 1506 | - if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$_folderName; |
|
| 1507 | - $toSchema = false;//decides to select list schema with column to selected (if false fromaddress is default) |
|
| 1505 | + if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox'] = $_folderName; |
|
| 1506 | + $toSchema = false; //decides to select list schema with column to selected (if false fromaddress is default) |
|
| 1508 | 1507 | if ($mail_ui->mail_bo->folderExists($_folderName)) |
| 1509 | 1508 | { |
| 1510 | - $toSchema = $mail_ui->mail_bo->isDraftFolder($_folderName,false)||$mail_ui->mail_bo->isSentFolder($_folderName,false)||$mail_ui->mail_bo->isTemplateFolder($_folderName,false); |
|
| 1509 | + $toSchema = $mail_ui->mail_bo->isDraftFolder($_folderName, false) || $mail_ui->mail_bo->isSentFolder($_folderName, false) || $mail_ui->mail_bo->isTemplateFolder($_folderName, false); |
|
| 1511 | 1510 | } |
| 1512 | 1511 | else |
| 1513 | 1512 | { |
| 1514 | 1513 | // take the extra time on failure |
| 1515 | - if (!$mail_ui->mail_bo->folderExists($_folderName,true)) |
|
| 1514 | + if (!$mail_ui->mail_bo->folderExists($_folderName, true)) |
|
| 1516 | 1515 | { |
| 1517 | 1516 | //error_log(__METHOD__.__LINE__.' Test on Folder:'.$_folderName.' failed; Using INBOX instead'); |
| 1518 | - $query['selectedFolder']=$mail_ui->mail_bo->sessionData['mailbox']=$_folderName='INBOX'; |
|
| 1517 | + $query['selectedFolder'] = $mail_ui->mail_bo->sessionData['mailbox'] = $_folderName = 'INBOX'; |
|
| 1519 | 1518 | } |
| 1520 | 1519 | } |
| 1521 | 1520 | $rowsFetched['messages'] = null; |
| 1522 | - $offset = $query['start']+1; // we always start with 1 |
|
| 1521 | + $offset = $query['start'] + 1; // we always start with 1 |
|
| 1523 | 1522 | $maxMessages = $query['num_rows']; |
| 1524 | 1523 | //error_log(__METHOD__.__LINE__.array2string($query)); |
| 1525 | - $sort = ($query['order']=='address'?($toSchema?'toaddress':'fromaddress'):$query['order']); |
|
| 1526 | - if (!empty($query['search'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate'])))) |
|
| 1524 | + $sort = ($query['order'] == 'address' ? ($toSchema ? 'toaddress' : 'fromaddress') : $query['order']); |
|
| 1525 | + if (!empty($query['search']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate'])))) |
|
| 1527 | 1526 | { |
| 1528 | 1527 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID])) |
| 1529 | 1528 | { |
| 1530 | - Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
|
| 1529 | + Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 1531 | 1530 | if (!isset(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID])) |
| 1532 | 1531 | { |
| 1533 | - Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]=true; |
|
| 1532 | + Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] = true; |
|
| 1534 | 1533 | } |
| 1535 | 1534 | } |
| 1536 | 1535 | //error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']); |
| 1537 | 1536 | $cutoffdate = $cutoffdate2 = null; |
| 1538 | - if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate |
|
| 1539 | - if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate |
|
| 1537 | + if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate |
|
| 1538 | + if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate |
|
| 1540 | 1539 | //error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate); |
| 1541 | 1540 | $filter = array( |
| 1542 | - 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')), |
|
| 1543 | - 'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')), |
|
| 1541 | + 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')), |
|
| 1542 | + 'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')), |
|
| 1544 | 1543 | 'string' => $query['search'], |
| 1545 | 1544 | 'status' => 'any', |
| 1546 | 1545 | //'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2) |
| 1547 | 1546 | ); |
| 1548 | - if ($query['enddate']||$query['startdate']) { |
|
| 1547 | + if ($query['enddate'] || $query['startdate']) { |
|
| 1549 | 1548 | $filter['range'] = "BETWEEN"; |
| 1550 | 1549 | if ($cutoffdate) { |
| 1551 | - $filter[(empty($cutoffdate2)?'date':'since')] = date("d-M-Y", $cutoffdate); |
|
| 1550 | + $filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate); |
|
| 1552 | 1551 | if (empty($cutoffdate2)) $filter['range'] = "SINCE"; |
| 1553 | 1552 | } |
| 1554 | 1553 | if ($cutoffdate2) { |
| 1555 | - $filter[(empty($cutoffdate)?'date':'before')] = date("d-M-Y", $cutoffdate2); |
|
| 1554 | + $filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2); |
|
| 1556 | 1555 | if (empty($cutoffdate)) $filter['range'] = "BEFORE"; |
| 1557 | 1556 | } |
| 1558 | 1557 | } |
@@ -1565,17 +1564,17 @@ discard block |
||
| 1565 | 1564 | { |
| 1566 | 1565 | $filter['status'] = $query['filter']; |
| 1567 | 1566 | } |
| 1568 | - $reverse = ($query['sort']=='ASC'?false:true); |
|
| 1567 | + $reverse = ($query['sort'] == 'ASC' ? false : true); |
|
| 1569 | 1568 | $prefchanged = false; |
| 1570 | - if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']) || ($query['cat_id'] !=$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType'])) |
|
| 1569 | + if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType']) || ($query['cat_id'] != $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveSearchType'])) |
|
| 1571 | 1570 | { |
| 1572 | 1571 | //error_log(__METHOD__.__LINE__.' Changing userPref ActivesearchType:'.$query['cat_id']); |
| 1573 | - $GLOBALS['egw']->preferences->add('mail','ActiveSearchType',$query['cat_id'],'user'); |
|
| 1572 | + $GLOBALS['egw']->preferences->add('mail', 'ActiveSearchType', $query['cat_id'], 'user'); |
|
| 1574 | 1573 | $prefchanged = true; |
| 1575 | 1574 | } |
| 1576 | - if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']) || ($query['filter2'] !=$GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails'])) |
|
| 1575 | + if (!isset($GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails']) || ($query['filter2'] != $GLOBALS['egw_info']['user']['preferences']['mail']['ShowDetails'])) |
|
| 1577 | 1576 | { |
| 1578 | - $GLOBALS['egw']->preferences->add('mail','ShowDetails',$query['filter2'],'user'); |
|
| 1577 | + $GLOBALS['egw']->preferences->add('mail', 'ShowDetails', $query['filter2'], 'user'); |
|
| 1579 | 1578 | $prefchanged = true; |
| 1580 | 1579 | } |
| 1581 | 1580 | if ($prefchanged) |
@@ -1606,13 +1605,13 @@ discard block |
||
| 1606 | 1605 | $rowsFetched['messages'] = $_sR['count']; |
| 1607 | 1606 | $ids = $_sR['match']->ids; |
| 1608 | 1607 | // if $sR is false, something failed fundamentally |
| 1609 | - if($reverse === true) $ids = ($ids===false?array():array_reverse((array)$ids)); |
|
| 1610 | - $sR = array_slice((array)$ids,($offset==0?0:$offset-1),$maxMessages); // we need only $maxMessages of uids |
|
| 1611 | - $sRToFetch = $sR;//array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids |
|
| 1608 | + if ($reverse === true) $ids = ($ids === false ? array() : array_reverse((array)$ids)); |
|
| 1609 | + $sR = array_slice((array)$ids, ($offset == 0 ? 0 : $offset - 1), $maxMessages); // we need only $maxMessages of uids |
|
| 1610 | + $sRToFetch = $sR; //array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids |
|
| 1612 | 1611 | //error_log(__METHOD__.__LINE__.' Rows fetched (UID only):'.count($sR).' Data:'.array2string($sR)); |
| 1613 | 1612 | $maxMessages = 75; |
| 1614 | 1613 | $sortResultwH['header'] = array(); |
| 1615 | - if (count($sRToFetch)>0) |
|
| 1614 | + if (count($sRToFetch) > 0) |
|
| 1616 | 1615 | { |
| 1617 | 1616 | //error_log(__METHOD__.__LINE__.' Headers to fetch with UIDs:'.count($sRToFetch).' Data:'.array2string($sRToFetch)); |
| 1618 | 1617 | $sortResult = array(); |
@@ -1626,7 +1625,7 @@ discard block |
||
| 1626 | 1625 | $filter, |
| 1627 | 1626 | $sRToFetch, |
| 1628 | 1627 | true, //cacheResult |
| 1629 | - ($query['filter2']?true:false) // fetchPreview |
|
| 1628 | + ($query['filter2'] ? true : false) // fetchPreview |
|
| 1630 | 1629 | ); |
| 1631 | 1630 | } |
| 1632 | 1631 | } |
@@ -1643,30 +1642,30 @@ discard block |
||
| 1643 | 1642 | $filter, |
| 1644 | 1643 | null, // this uids only |
| 1645 | 1644 | true, // cacheResult |
| 1646 | - ($query['filter2']?true:false) // fetchPreview |
|
| 1645 | + ($query['filter2'] ? true : false) // fetchPreview |
|
| 1647 | 1646 | ); |
| 1648 | 1647 | $rowsFetched['messages'] = $sortResultwH['info']['total']; |
| 1649 | 1648 | } |
| 1650 | 1649 | } |
| 1651 | 1650 | catch (Exception $e) |
| 1652 | 1651 | { |
| 1653 | - $sortResultwH=array(); |
|
| 1654 | - $sR=array(); |
|
| 1652 | + $sortResultwH = array(); |
|
| 1653 | + $sR = array(); |
|
| 1655 | 1654 | self::callWizard($e->getMessage(), false, 'error'); |
| 1656 | 1655 | } |
| 1657 | 1656 | $response = Api\Json\Response::get(); |
| 1658 | 1657 | // unlock immediately after fetching the rows |
| 1659 | - if (stripos($_GET['menuaction'],'ajax_get_rows')!==false) |
|
| 1658 | + if (stripos($_GET['menuaction'], 'ajax_get_rows') !== false) |
|
| 1660 | 1659 | { |
| 1661 | 1660 | //error_log(__METHOD__.__LINE__.' unlock tree ->'.$_GET['menuaction']); |
| 1662 | 1661 | $response->call('app.mail.unlock_tree'); |
| 1663 | 1662 | } |
| 1664 | 1663 | |
| 1665 | - if (is_array($sR) && count($sR)>0) |
|
| 1664 | + if (is_array($sR) && count($sR) > 0) |
|
| 1666 | 1665 | { |
| 1667 | 1666 | foreach ((array)$sR as $key => $v) |
| 1668 | 1667 | { |
| 1669 | - if (array_key_exists($key,(array)$sortResultwH['header'])==true) |
|
| 1668 | + if (array_key_exists($key, (array)$sortResultwH['header']) == true) |
|
| 1670 | 1669 | { |
| 1671 | 1670 | $sortResult['header'][] = $sortResultwH['header'][$key]; |
| 1672 | 1671 | } |
@@ -1684,16 +1683,16 @@ discard block |
||
| 1684 | 1683 | if (empty($rowsFetched['messages'])) $rowsFetched['messages'] = $rowsFetched['rowsFetched']; |
| 1685 | 1684 | |
| 1686 | 1685 | //error_log(__METHOD__.__LINE__.' Rows fetched:'.$rowsFetched.' Data:'.array2string($sortResult)); |
| 1687 | - $cols = array('row_id','uid','status','attachments','subject','address','toaddress','fromaddress','ccaddress','additionaltoaddress','date','size','modified','bodypreview'); |
|
| 1688 | - if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE') unset($cols[0]); |
|
| 1689 | - $rows = $mail_ui->header2gridelements($sortResult['header'],$cols, $_folderName, $folderType=$toSchema); |
|
| 1686 | + $cols = array('row_id', 'uid', 'status', 'attachments', 'subject', 'address', 'toaddress', 'fromaddress', 'ccaddress', 'additionaltoaddress', 'date', 'size', 'modified', 'bodypreview'); |
|
| 1687 | + if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode'] == 'EGW_SELECTMODE_TOGGLE') unset($cols[0]); |
|
| 1688 | + $rows = $mail_ui->header2gridelements($sortResult['header'], $cols, $_folderName, $folderType = $toSchema); |
|
| 1690 | 1689 | |
| 1691 | 1690 | // Save the session (since we are committing session) at the end |
| 1692 | 1691 | // to make sure all necessary data are stored in session. |
| 1693 | 1692 | // e.g.: Link:: get_data which is used to read attachments data. |
| 1694 | 1693 | $mail_ui->mail_bo->saveSessionData(); |
| 1695 | 1694 | |
| 1696 | - if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__); |
|
| 1695 | + if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, 'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'], __METHOD__.__LINE__); |
|
| 1697 | 1696 | return $rowsFetched['messages']; |
| 1698 | 1697 | } |
| 1699 | 1698 | |
@@ -1705,7 +1704,7 @@ discard block |
||
| 1705 | 1704 | * @param boolean $_prependApp to indicate that the app 'mail' is to be used for creating the rowID |
| 1706 | 1705 | * @return string - a colon separated string in the form [app:]accountID:profileID:folder:message_uid |
| 1707 | 1706 | */ |
| 1708 | - function createRowID($_folderName, $message_uid, $_prependApp=false) |
|
| 1707 | + function createRowID($_folderName, $message_uid, $_prependApp = false) |
|
| 1709 | 1708 | { |
| 1710 | 1709 | return self::generateRowID($this->mail_bo->profileID, $_folderName, $message_uid, $_prependApp); |
| 1711 | 1710 | } |
@@ -1719,9 +1718,9 @@ discard block |
||
| 1719 | 1718 | * @param boolean $_prependApp to indicate that the app 'mail' is to be used for creating the rowID |
| 1720 | 1719 | * @return string - a colon separated string in the form [app:]accountID:profileID:folder:message_uid |
| 1721 | 1720 | */ |
| 1722 | - static function generateRowID($_profileID, $_folderName, $message_uid, $_prependApp=false) |
|
| 1721 | + static function generateRowID($_profileID, $_folderName, $message_uid, $_prependApp = false) |
|
| 1723 | 1722 | { |
| 1724 | - return ($_prependApp?'mail'.self::$delimiter:'').trim($GLOBALS['egw_info']['user']['account_id']).self::$delimiter.$_profileID.self::$delimiter.base64_encode($_folderName).self::$delimiter.$message_uid; |
|
| 1723 | + return ($_prependApp ? 'mail'.self::$delimiter : '').trim($GLOBALS['egw_info']['user']['account_id']).self::$delimiter.$_profileID.self::$delimiter.base64_encode($_folderName).self::$delimiter.$message_uid; |
|
| 1725 | 1724 | } |
| 1726 | 1725 | |
| 1727 | 1726 | /** |
@@ -1732,13 +1731,13 @@ discard block |
||
| 1732 | 1731 | */ |
| 1733 | 1732 | static function splitRowID($_rowID) |
| 1734 | 1733 | { |
| 1735 | - $res = explode(self::$delimiter,$_rowID); |
|
| 1734 | + $res = explode(self::$delimiter, $_rowID); |
|
| 1736 | 1735 | // as a rowID is perceeded by app::, should be mail! |
| 1737 | 1736 | //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)); |
| 1738 | - if (count($res)==4 && is_numeric($res[0]) ) |
|
| 1737 | + if (count($res) == 4 && is_numeric($res[0])) |
|
| 1739 | 1738 | { |
| 1740 | 1739 | // we have an own created rowID; prepend app=mail |
| 1741 | - array_unshift($res,'mail'); |
|
| 1740 | + array_unshift($res, 'mail'); |
|
| 1742 | 1741 | } |
| 1743 | 1742 | return array('app'=>$res[0], 'accountID'=>$res[1], 'profileID'=>$res[2], 'folder'=>base64_decode($res[3]), 'msgUID'=>$res[4]); |
| 1744 | 1743 | } |
@@ -1752,60 +1751,60 @@ discard block |
||
| 1752 | 1751 | { |
| 1753 | 1752 | $actions = $this->get_actions(); |
| 1754 | 1753 | $arrActions = array('composeasnew', 'reply', 'reply_all', 'forward', 'flagged', 'delete', 'print', |
| 1755 | - 'infolog', 'tracker', 'calendar', 'save', 'view', 'read', 'label1', 'label2', 'label3', 'label4', 'label5','spam', 'ham'); |
|
| 1756 | - foreach( $arrActions as &$act) |
|
| 1754 | + 'infolog', 'tracker', 'calendar', 'save', 'view', 'read', 'label1', 'label2', 'label3', 'label4', 'label5', 'spam', 'ham'); |
|
| 1755 | + foreach ($arrActions as &$act) |
|
| 1757 | 1756 | { |
| 1758 | 1757 | //error_log(__METHOD__.__LINE__.' '.$act.'->'.array2string($actions[$act])); |
| 1759 | 1758 | switch ($act) |
| 1760 | 1759 | { |
| 1761 | 1760 | case 'forward': |
| 1762 | - $actionsenabled[$act]=$actions[$act]; |
|
| 1761 | + $actionsenabled[$act] = $actions[$act]; |
|
| 1763 | 1762 | break; |
| 1764 | 1763 | case 'save': |
| 1765 | - $actionsenabled[$act]=$actions[$act]; |
|
| 1764 | + $actionsenabled[$act] = $actions[$act]; |
|
| 1766 | 1765 | |
| 1767 | 1766 | break; |
| 1768 | 1767 | case 'view': |
| 1769 | - $actionsenabled[$act]=$actions[$act]; |
|
| 1768 | + $actionsenabled[$act] = $actions[$act]; |
|
| 1770 | 1769 | break; |
| 1771 | 1770 | case 'flagged': |
| 1772 | - $actionsenabled[$act]= $actions['mark']['children'][$act]; |
|
| 1771 | + $actionsenabled[$act] = $actions['mark']['children'][$act]; |
|
| 1773 | 1772 | break; |
| 1774 | 1773 | case 'read': |
| 1775 | - $actionsenabled[$act]= $actions['mark']['children'][$act]; |
|
| 1774 | + $actionsenabled[$act] = $actions['mark']['children'][$act]; |
|
| 1776 | 1775 | break; |
| 1777 | 1776 | case 'label1': |
| 1778 | 1777 | $actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('important'); |
| 1779 | - $actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1778 | + $actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1780 | 1779 | break; |
| 1781 | 1780 | case 'label2': |
| 1782 | 1781 | $actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('job'); |
| 1783 | - $actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1782 | + $actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1784 | 1783 | break; |
| 1785 | 1784 | case 'label3': |
| 1786 | 1785 | $actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('personal'); |
| 1787 | - $actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1786 | + $actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1788 | 1787 | break; |
| 1789 | 1788 | case 'label4': |
| 1790 | 1789 | $actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('to do'); |
| 1791 | - $actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1790 | + $actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1792 | 1791 | break; |
| 1793 | 1792 | case 'label5': |
| 1794 | 1793 | $actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('later'); |
| 1795 | - $actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1794 | + $actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1796 | 1795 | break; |
| 1797 | 1796 | case 'ham': |
| 1798 | 1797 | case 'spam': |
| 1799 | - $actionsenabled[$act]= $actions['spamfilter']['children'][$act]; |
|
| 1798 | + $actionsenabled[$act] = $actions['spamfilter']['children'][$act]; |
|
| 1800 | 1799 | break; |
| 1801 | 1800 | default: |
| 1802 | - if (isset($actions[$act])) $actionsenabled[$act]=$actions[$act]; |
|
| 1801 | + if (isset($actions[$act])) $actionsenabled[$act] = $actions[$act]; |
|
| 1803 | 1802 | } |
| 1804 | 1803 | } |
| 1805 | 1804 | unset($actionsenabled['drag_mail']); |
| 1806 | 1805 | //error_log(array2string($actionsenabled['view'])); |
| 1807 | - unset($actionsenabled['view']['children']['openastext']);//not supported in preview |
|
| 1808 | - unset($actionsenabled['view']['children']['openashtml']);//not supported in preview |
|
| 1806 | + unset($actionsenabled['view']['children']['openastext']); //not supported in preview |
|
| 1807 | + unset($actionsenabled['view']['children']['openashtml']); //not supported in preview |
|
| 1809 | 1808 | |
| 1810 | 1809 | return $actionsenabled; |
| 1811 | 1810 | } |
@@ -1819,45 +1818,45 @@ discard block |
||
| 1819 | 1818 | * @param array $_folderType used to determine if we need to populate from/to |
| 1820 | 1819 | * @return array populated result array |
| 1821 | 1820 | */ |
| 1822 | - public function header2gridelements($_headers, $cols, $_folderName, $_folderType=0) |
|
| 1821 | + public function header2gridelements($_headers, $cols, $_folderName, $_folderType = 0) |
|
| 1823 | 1822 | { |
| 1824 | 1823 | if (Mail::$debugTimes) $starttime = microtime(true); |
| 1825 | 1824 | $rv = array(); |
| 1826 | - $i=0; |
|
| 1827 | - foreach((array)$_headers as $header) |
|
| 1825 | + $i = 0; |
|
| 1826 | + foreach ((array)$_headers as $header) |
|
| 1828 | 1827 | { |
| 1829 | 1828 | $i++; |
| 1830 | 1829 | $data = array(); |
| 1831 | 1830 | //error_log(__METHOD__.array2string($header)); |
| 1832 | 1831 | $message_uid = $header['uid']; |
| 1833 | 1832 | $data['uid'] = $message_uid; |
| 1834 | - $data['row_id']=$this->createRowID($_folderName,$message_uid); |
|
| 1833 | + $data['row_id'] = $this->createRowID($_folderName, $message_uid); |
|
| 1835 | 1834 | |
| 1836 | 1835 | $flags = ""; |
| 1837 | - if(!empty($header['recent'])) $flags .= "R"; |
|
| 1838 | - if(!empty($header['flagged'])) $flags .= "F"; |
|
| 1839 | - if(!empty($header['answered'])) $flags .= "A"; |
|
| 1840 | - if(!empty($header['forwarded'])) $flags .= "W"; |
|
| 1841 | - if(!empty($header['deleted'])) $flags .= "D"; |
|
| 1842 | - if(!empty($header['seen'])) $flags .= "S"; |
|
| 1843 | - if(!empty($header['label1'])) $flags .= "1"; |
|
| 1844 | - if(!empty($header['label2'])) $flags .= "2"; |
|
| 1845 | - if(!empty($header['label3'])) $flags .= "3"; |
|
| 1846 | - if(!empty($header['label4'])) $flags .= "4"; |
|
| 1847 | - if(!empty($header['label5'])) $flags .= "5"; |
|
| 1836 | + if (!empty($header['recent'])) $flags .= "R"; |
|
| 1837 | + if (!empty($header['flagged'])) $flags .= "F"; |
|
| 1838 | + if (!empty($header['answered'])) $flags .= "A"; |
|
| 1839 | + if (!empty($header['forwarded'])) $flags .= "W"; |
|
| 1840 | + if (!empty($header['deleted'])) $flags .= "D"; |
|
| 1841 | + if (!empty($header['seen'])) $flags .= "S"; |
|
| 1842 | + if (!empty($header['label1'])) $flags .= "1"; |
|
| 1843 | + if (!empty($header['label2'])) $flags .= "2"; |
|
| 1844 | + if (!empty($header['label3'])) $flags .= "3"; |
|
| 1845 | + if (!empty($header['label4'])) $flags .= "4"; |
|
| 1846 | + if (!empty($header['label5'])) $flags .= "5"; |
|
| 1848 | 1847 | |
| 1849 | 1848 | $data["status"] = "<span class=\"status_img\"></span>"; |
| 1850 | 1849 | //error_log(__METHOD__.array2string($header).' Flags:'.$flags); |
| 1851 | 1850 | |
| 1852 | 1851 | // the css for this row |
| 1853 | - $is_recent=false; |
|
| 1852 | + $is_recent = false; |
|
| 1854 | 1853 | $css_styles = array("mail"); |
| 1855 | 1854 | if ($header['deleted']) { |
| 1856 | 1855 | $css_styles[] = 'deleted'; |
| 1857 | 1856 | } |
| 1858 | 1857 | if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded'])) { |
| 1859 | 1858 | $css_styles[] = 'recent'; |
| 1860 | - $is_recent=true; |
|
| 1859 | + $is_recent = true; |
|
| 1861 | 1860 | } |
| 1862 | 1861 | if ($header['priority'] < 3) { |
| 1863 | 1862 | $css_styles[] = 'prio_high'; |
@@ -1895,19 +1894,19 @@ discard block |
||
| 1895 | 1894 | if (in_array("subject", $cols)) |
| 1896 | 1895 | { |
| 1897 | 1896 | // filter out undisplayable characters |
| 1898 | - $search = array('[\016]','[\017]', |
|
| 1899 | - '[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]', |
|
| 1900 | - '[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]'); |
|
| 1897 | + $search = array('[\016]', '[\017]', |
|
| 1898 | + '[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]', |
|
| 1899 | + '[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]'); |
|
| 1901 | 1900 | $replace = ''; |
| 1902 | 1901 | |
| 1903 | - $header['subject'] = preg_replace($search,$replace,$header['subject']); |
|
| 1902 | + $header['subject'] = preg_replace($search, $replace, $header['subject']); |
|
| 1904 | 1903 | // curly brackets get messed up by the template! |
| 1905 | 1904 | |
| 1906 | 1905 | if (!empty($header['subject'])) { |
| 1907 | 1906 | // make the subject shorter if it is to long |
| 1908 | 1907 | $subject = $header['subject']; |
| 1909 | 1908 | } else { |
| 1910 | - $subject = '('. lang('no subject') .')'; |
|
| 1909 | + $subject = '('.lang('no subject').')'; |
|
| 1911 | 1910 | } |
| 1912 | 1911 | |
| 1913 | 1912 | $data["subject"] = $subject; // the mailsubject |
@@ -1917,53 +1916,53 @@ discard block |
||
| 1917 | 1916 | //error_log(__METHOD__.__LINE__.array2string($header)); |
| 1918 | 1917 | if (in_array("attachments", $cols)) |
| 1919 | 1918 | { |
| 1920 | - if($header['mimetype'] == 'multipart/mixed' || |
|
| 1919 | + if ($header['mimetype'] == 'multipart/mixed' || |
|
| 1921 | 1920 | $header['mimetype'] == 'multipart/signed' || |
| 1922 | 1921 | $header['mimetype'] == 'multipart/related' || |
| 1923 | 1922 | $header['mimetype'] == 'multipart/report' || |
| 1924 | 1923 | $header['mimetype'] == 'text/calendar' || |
| 1925 | 1924 | $header['mimetype'] == 'text/html' || |
| 1926 | - substr($header['mimetype'],0,11) == 'application' || |
|
| 1927 | - substr($header['mimetype'],0,5) == 'audio' || |
|
| 1928 | - substr($header['mimetype'],0,5) == 'video' || |
|
| 1925 | + substr($header['mimetype'], 0, 11) == 'application' || |
|
| 1926 | + substr($header['mimetype'], 0, 5) == 'audio' || |
|
| 1927 | + substr($header['mimetype'], 0, 5) == 'video' || |
|
| 1929 | 1928 | $header['mimetype'] == 'multipart/alternative') |
| 1930 | 1929 | { |
| 1931 | - $image = Api\Html::image('mail','attach'); |
|
| 1930 | + $image = Api\Html::image('mail', 'attach'); |
|
| 1932 | 1931 | $imageHTMLBlock = ''; |
| 1933 | - $datarowid = $this->createRowID($_folderName,$message_uid,true); |
|
| 1932 | + $datarowid = $this->createRowID($_folderName, $message_uid, true); |
|
| 1934 | 1933 | $attachments = $header['attachments']; |
| 1935 | - if (count($attachments)<1) |
|
| 1934 | + if (count($attachments) < 1) |
|
| 1936 | 1935 | { |
| 1937 | 1936 | $image = ' '; |
| 1938 | 1937 | } |
| 1939 | - if (count($attachments)==1) |
|
| 1938 | + if (count($attachments) == 1) |
|
| 1940 | 1939 | { |
| 1941 | - $imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'],$_folderName); |
|
| 1942 | - $image = Api\Html::image('mail','attach',$attachments[0]['name'].(!empty($attachments[0]['mimeType'])?' ('.$attachments[0]['mimeType'].')':'')); |
|
| 1940 | + $imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'], $_folderName); |
|
| 1941 | + $image = Api\Html::image('mail', 'attach', $attachments[0]['name'].(!empty($attachments[0]['mimeType']) ? ' ('.$attachments[0]['mimeType'].')' : '')); |
|
| 1943 | 1942 | } |
| 1944 | - if (count($attachments)>1) |
|
| 1943 | + if (count($attachments) > 1) |
|
| 1945 | 1944 | { |
| 1946 | - $imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'],$_folderName); |
|
| 1947 | - $image = Api\Html::image('mail','attach',lang('%1 attachments',count($attachments))); |
|
| 1945 | + $imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'], $_folderName); |
|
| 1946 | + $image = Api\Html::image('mail', 'attach', lang('%1 attachments', count($attachments))); |
|
| 1948 | 1947 | } |
| 1949 | 1948 | |
| 1950 | 1949 | $attachmentFlag = $image; |
| 1951 | 1950 | } else { |
| 1952 | - $attachmentFlag =' '; |
|
| 1951 | + $attachmentFlag = ' '; |
|
| 1953 | 1952 | } |
| 1954 | 1953 | // show priority flag |
| 1955 | 1954 | if ($header['priority'] < 3) { |
| 1956 | - $image = Api\Html::image('mail','prio_high'); |
|
| 1955 | + $image = Api\Html::image('mail', 'prio_high'); |
|
| 1957 | 1956 | } elseif ($header['priority'] > 3) { |
| 1958 | - $image = Api\Html::image('mail','prio_low'); |
|
| 1957 | + $image = Api\Html::image('mail', 'prio_low'); |
|
| 1959 | 1958 | } else { |
| 1960 | 1959 | $image = ''; |
| 1961 | 1960 | } |
| 1962 | 1961 | // show a flag for flagged messages |
| 1963 | - $imageflagged =''; |
|
| 1962 | + $imageflagged = ''; |
|
| 1964 | 1963 | if ($header['flagged']) |
| 1965 | 1964 | { |
| 1966 | - $imageflagged = Api\Html::image('mail','unread_flagged_small'); |
|
| 1965 | + $imageflagged = Api\Html::image('mail', 'unread_flagged_small'); |
|
| 1967 | 1966 | } |
| 1968 | 1967 | $data["attachments"] = $image.$attachmentFlag.$imageflagged; // icon for attachments available |
| 1969 | 1968 | } |
@@ -1972,7 +1971,7 @@ discard block |
||
| 1972 | 1971 | if (in_array("toaddress", $cols)) |
| 1973 | 1972 | { |
| 1974 | 1973 | // sent or drafts or template folder means foldertype > 0, use to address instead of from |
| 1975 | - $data["toaddress"] = $header['to_address'];//Mail::htmlentities($header['to_address'],$this->charset); |
|
| 1974 | + $data["toaddress"] = $header['to_address']; //Mail::htmlentities($header['to_address'],$this->charset); |
|
| 1976 | 1975 | } |
| 1977 | 1976 | |
| 1978 | 1977 | if (in_array("additionaltoaddress", $cols)) |
@@ -2005,29 +2004,29 @@ discard block |
||
| 2005 | 2004 | $data['flags'] = Array(); |
| 2006 | 2005 | if ($header['seen']) $data["flags"]['read'] = 'read'; |
| 2007 | 2006 | foreach ($css_styles as &$flag) { |
| 2008 | - if ($flag!='mail') |
|
| 2007 | + if ($flag != 'mail') |
|
| 2009 | 2008 | { |
| 2010 | - if ($flag=='labelone') {$data["flags"]['label1'] = 'label1';} |
|
| 2011 | - elseif ($flag=='labeltwo') {$data["flags"]['label2'] = 'label2';} |
|
| 2012 | - elseif ($flag=='labelthree') {$data["flags"]['label3'] = 'label3';} |
|
| 2013 | - elseif ($flag=='labelfour') {$data["flags"]['label4'] = 'label4';} |
|
| 2014 | - elseif ($flag=='labelfive') {$data["flags"]['label5'] = 'label5';} |
|
| 2015 | - elseif ($flag=='unseen') {unset($data["flags"]['read']);} |
|
| 2009 | + if ($flag == 'labelone') {$data["flags"]['label1'] = 'label1'; } |
|
| 2010 | + elseif ($flag == 'labeltwo') {$data["flags"]['label2'] = 'label2'; } |
|
| 2011 | + elseif ($flag == 'labelthree') {$data["flags"]['label3'] = 'label3'; } |
|
| 2012 | + elseif ($flag == 'labelfour') {$data["flags"]['label4'] = 'label4'; } |
|
| 2013 | + elseif ($flag == 'labelfive') {$data["flags"]['label5'] = 'label5'; } |
|
| 2014 | + elseif ($flag == 'unseen') {unset($data["flags"]['read']); } |
|
| 2016 | 2015 | else $data["flags"][$flag] = $flag; |
| 2017 | 2016 | } |
| 2018 | 2017 | } |
| 2019 | 2018 | if ($header['disposition-notification-to']) $data['dispositionnotificationto'] = $header['disposition-notification-to']; |
| 2020 | - if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']); |
|
| 2019 | + if (($header['mdnsent'] || $header['mdnnotsent']|$header['seen']) && isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']); |
|
| 2021 | 2020 | $data['attachmentsBlock'] = $imageHTMLBlock; |
| 2022 | - $data['address'] = ($_folderType?$data["toaddress"]:$data["fromaddress"]); |
|
| 2023 | - if (in_array("bodypreview", $cols)&&$header['bodypreview']) |
|
| 2021 | + $data['address'] = ($_folderType ? $data["toaddress"] : $data["fromaddress"]); |
|
| 2022 | + if (in_array("bodypreview", $cols) && $header['bodypreview']) |
|
| 2024 | 2023 | { |
| 2025 | 2024 | $data["bodypreview"] = $header['bodypreview']; |
| 2026 | 2025 | } |
| 2027 | 2026 | $rv[] = $data; |
| 2028 | 2027 | //error_log(__METHOD__.__LINE__.array2string($data)); |
| 2029 | 2028 | } |
| 2030 | - if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__); |
|
| 2029 | + if (Mail::$debugTimes) Mail::logRunTimes($starttime, null, 'Folder:'.$_folderName, __METHOD__.__LINE__); |
|
| 2031 | 2030 | |
| 2032 | 2031 | // ToDo: call this ONLY if labels change |
| 2033 | 2032 | Etemplate\Widget::setElementAttribute('toolbar', 'actions', $this->get_toolbar_actions()); |
@@ -2042,8 +2041,8 @@ discard block |
||
| 2042 | 2041 | */ |
| 2043 | 2042 | function displayHeader() |
| 2044 | 2043 | { |
| 2045 | - if(isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 2046 | - if(isset($_GET['part'])) $partID = $_GET['part']; |
|
| 2044 | + if (isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 2045 | + if (isset($_GET['part'])) $partID = $_GET['part']; |
|
| 2047 | 2046 | |
| 2048 | 2047 | $hA = self::splitRowID($rowID); |
| 2049 | 2048 | $uid = $hA['msgUID']; |
@@ -2057,17 +2056,17 @@ discard block |
||
| 2057 | 2056 | } |
| 2058 | 2057 | |
| 2059 | 2058 | $this->mail_bo->reopen($mailbox); |
| 2060 | - $headers_in = $this->mail_bo->getMessageRawHeader($uid, $partID); |
|
| 2059 | + $headers_in = $this->mail_bo->getMessageRawHeader($uid, $partID); |
|
| 2061 | 2060 | |
| 2062 | 2061 | // add line breaks to $rawheaders |
| 2063 | - $newRawHeaders = explode("\n",$headers_in); |
|
| 2062 | + $newRawHeaders = explode("\n", $headers_in); |
|
| 2064 | 2063 | reset($newRawHeaders); |
| 2065 | 2064 | |
| 2066 | 2065 | // reset $rawheaders |
| 2067 | - $rawheaders = ""; |
|
| 2066 | + $rawheaders = ""; |
|
| 2068 | 2067 | // create it new, with good line breaks |
| 2069 | 2068 | reset($newRawHeaders); |
| 2070 | - while(list($key,$value) = @each($newRawHeaders)) { |
|
| 2069 | + while (list($key, $value) = @each($newRawHeaders)) { |
|
| 2071 | 2070 | $rawheaders .= wordwrap($value, 90, "\n "); |
| 2072 | 2071 | } |
| 2073 | 2072 | |
@@ -2079,7 +2078,7 @@ discard block |
||
| 2079 | 2078 | } |
| 2080 | 2079 | |
| 2081 | 2080 | header('Content-type: text/html; charset=iso-8859-1'); |
| 2082 | - print '<pre>'. htmlspecialchars($rawheaders, ENT_NOQUOTES, 'iso-8859-1') .'</pre>'; |
|
| 2081 | + print '<pre>'.htmlspecialchars($rawheaders, ENT_NOQUOTES, 'iso-8859-1').'</pre>'; |
|
| 2083 | 2082 | |
| 2084 | 2083 | } |
| 2085 | 2084 | |
@@ -2092,10 +2091,10 @@ discard block |
||
| 2092 | 2091 | { |
| 2093 | 2092 | if (is_null($_requesteddata)) $_requesteddata = $_GET; |
| 2094 | 2093 | |
| 2095 | - $preventRedirect=false; |
|
| 2096 | - if(isset($_requesteddata['id'])) $rowID = $_requesteddata['id']; |
|
| 2097 | - if(isset($_requesteddata['part'])) $partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null; |
|
| 2098 | - if(isset($_requesteddata['mode'])) $preventRedirect = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false); |
|
| 2094 | + $preventRedirect = false; |
|
| 2095 | + if (isset($_requesteddata['id'])) $rowID = $_requesteddata['id']; |
|
| 2096 | + if (isset($_requesteddata['part'])) $partID = $_requesteddata['part'] != 'null' ? $_requesteddata['part'] : null; |
|
| 2097 | + if (isset($_requesteddata['mode'])) $preventRedirect = (($_requesteddata['mode'] == 'display' || $_requesteddata['mode'] == 'print') ? true : false); |
|
| 2099 | 2098 | |
| 2100 | 2099 | $hA = self::splitRowID($rowID); |
| 2101 | 2100 | $uid = $hA['msgUID']; |
@@ -2119,79 +2118,79 @@ discard block |
||
| 2119 | 2118 | } |
| 2120 | 2119 | if (!$preventRedirect && ($this->mail_bo->isDraftFolder($mailbox) || $this->mail_bo->isTemplateFolder($mailbox))) |
| 2121 | 2120 | { |
| 2122 | - Egw::redirect_link('/index.php',array('menuaction'=>'mail.mail_compose.compose','id'=>$rowID,'from'=>'composefromdraft')); |
|
| 2121 | + Egw::redirect_link('/index.php', array('menuaction'=>'mail.mail_compose.compose', 'id'=>$rowID, 'from'=>'composefromdraft')); |
|
| 2123 | 2122 | } |
| 2124 | 2123 | $this->mail_bo->reopen($mailbox); |
| 2125 | 2124 | // retrieve the flags of the message, before touching it. |
| 2126 | 2125 | try |
| 2127 | 2126 | { |
| 2128 | - $headers = $this->mail_bo->getMessageHeader($uid, $partID,true,true,$mailbox); |
|
| 2127 | + $headers = $this->mail_bo->getMessageHeader($uid, $partID, true, true, $mailbox); |
|
| 2129 | 2128 | } |
| 2130 | 2129 | catch (Api\Exception $e) |
| 2131 | 2130 | { |
| 2132 | 2131 | $error_msg[] = lang("ERROR: Message could not be displayed."); |
| 2133 | - $error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3",$mailbox,$uid,$partID); |
|
| 2132 | + $error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3", $mailbox, $uid, $partID); |
|
| 2134 | 2133 | Framework::message($e->getMessage(), 'error'); |
| 2135 | 2134 | } |
| 2136 | 2135 | if (!empty($uid)) $this->mail_bo->getFlags($uid); |
| 2137 | - $envelope = $this->mail_bo->getMessageEnvelope($uid, $partID,true,$mailbox); |
|
| 2136 | + $envelope = $this->mail_bo->getMessageEnvelope($uid, $partID, true, $mailbox); |
|
| 2138 | 2137 | //error_log(__METHOD__.__LINE__.array2string($envelope)); |
| 2139 | - $this->mail_bo->getMessageRawHeader($uid, $partID,$mailbox); |
|
| 2138 | + $this->mail_bo->getMessageRawHeader($uid, $partID, $mailbox); |
|
| 2140 | 2139 | $fetchEmbeddedImages = false; |
| 2141 | 2140 | // if we are in HTML so its likely that we should show the embedded images; as a result |
| 2142 | 2141 | // we do NOT want to see those, that are embedded in the list of attachments |
| 2143 | - if ($htmlOptions !='always_display') $fetchEmbeddedImages = true; |
|
| 2144 | - $attachments = $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages,true,true,$mailbox); |
|
| 2142 | + if ($htmlOptions != 'always_display') $fetchEmbeddedImages = true; |
|
| 2143 | + $attachments = $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages, true, true, $mailbox); |
|
| 2145 | 2144 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
| 2146 | 2145 | $attachmentHTMLBlock = self::createAttachmentBlock($attachments, $rowID, $uid, $mailbox); |
| 2147 | 2146 | |
| 2148 | - $nonDisplayAbleCharacters = array('[\016]','[\017]', |
|
| 2149 | - '[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]', |
|
| 2150 | - '[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]'); |
|
| 2147 | + $nonDisplayAbleCharacters = array('[\016]', '[\017]', |
|
| 2148 | + '[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]', |
|
| 2149 | + '[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]'); |
|
| 2151 | 2150 | |
| 2152 | 2151 | //error_log(__METHOD__.__LINE__.$mailBody); |
| 2153 | 2152 | $this->mail_bo->closeConnection(); |
| 2154 | 2153 | //$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed |
| 2155 | 2154 | $etpl = new Etemplate('mail.display'); |
| 2156 | - $subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters,'',$envelope['SUBJECT']),false); |
|
| 2155 | + $subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters, '', $envelope['SUBJECT']), false); |
|
| 2157 | 2156 | |
| 2158 | 2157 | // Set up data for taglist widget(s) |
| 2159 | - if ($envelope['FROM']==$envelope['SENDER']) unset($envelope['SENDER']); |
|
| 2158 | + if ($envelope['FROM'] == $envelope['SENDER']) unset($envelope['SENDER']); |
|
| 2160 | 2159 | $sel_options = array(); |
| 2161 | - foreach(array('SENDER','FROM','TO','CC','BCC') as $field) |
|
| 2160 | + foreach (array('SENDER', 'FROM', 'TO', 'CC', 'BCC') as $field) |
|
| 2162 | 2161 | { |
| 2163 | 2162 | if (!isset($envelope[$field])) continue; |
| 2164 | - foreach($envelope[$field] as $field_data) |
|
| 2163 | + foreach ($envelope[$field] as $field_data) |
|
| 2165 | 2164 | { |
| 2166 | 2165 | //error_log(__METHOD__.__LINE__.array2string($field_data)); |
| 2167 | 2166 | $content[$field][] = $field_data; |
| 2168 | 2167 | $sel_options[$field][] = array( |
| 2169 | 2168 | // taglist requires these - not optional |
| 2170 | 2169 | 'id' => $field_data, |
| 2171 | - 'label' => str_replace('"',"'",$field_data), |
|
| 2170 | + 'label' => str_replace('"', "'", $field_data), |
|
| 2172 | 2171 | ); |
| 2173 | 2172 | } |
| 2174 | 2173 | } |
| 2175 | 2174 | $actionsenabled = $this->getDisplayToolbarActions(); |
| 2176 | 2175 | $content['displayToolbaractions'] = json_encode($actionsenabled); |
| 2177 | 2176 | if (empty($subject)) $subject = lang('no subject'); |
| 2178 | - $content['msg'] = (is_array($error_msg)?implode("<br>",$error_msg):$error_msg); |
|
| 2177 | + $content['msg'] = (is_array($error_msg) ? implode("<br>", $error_msg) : $error_msg); |
|
| 2179 | 2178 | // Send mail ID so we can use it for actions |
| 2180 | 2179 | $content['mail_id'] = $rowID; |
| 2181 | 2180 | if (!is_array($headers) || !isset($headers['DATE'])) |
| 2182 | 2181 | { |
| 2183 | - $headers['DATE'] = (is_array($envelope)&&$envelope['DATE']?$envelope['DATE']:''); |
|
| 2182 | + $headers['DATE'] = (is_array($envelope) && $envelope['DATE'] ? $envelope['DATE'] : ''); |
|
| 2184 | 2183 | } |
| 2185 | - $content['mail_displaydate'] = Mail::_strtotime($headers['DATE'],'ts',true); |
|
| 2184 | + $content['mail_displaydate'] = Mail::_strtotime($headers['DATE'], 'ts', true); |
|
| 2186 | 2185 | $content['mail_displaysubject'] = $subject; |
| 2187 | - $linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody","_messageID"=>$rowID); |
|
| 2188 | - if (!empty($partID)) $linkData['_partID']=$partID; |
|
| 2189 | - if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions']=$htmlOptions; |
|
| 2190 | - $content['mailDisplayBodySrc'] = Egw::link('/index.php',$linkData); |
|
| 2186 | + $linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody", "_messageID"=>$rowID); |
|
| 2187 | + if (!empty($partID)) $linkData['_partID'] = $partID; |
|
| 2188 | + if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions'] = $htmlOptions; |
|
| 2189 | + $content['mailDisplayBodySrc'] = Egw::link('/index.php', $linkData); |
|
| 2191 | 2190 | $content['mail_displayattachments'] = $attachmentHTMLBlock; |
| 2192 | - $content['mail_id']=$rowID; |
|
| 2193 | - $content['mailDisplayContainerClass']=(count($attachments)?"mailDisplayContainer mailDisplayContainerFixedHeight":"mailDisplayContainer mailDisplayContainerFullHeight"); |
|
| 2194 | - $content['mailDisplayAttachmentsClass']=(count($attachments)?"mailDisplayAttachments":"mail_DisplayNone"); |
|
| 2191 | + $content['mail_id'] = $rowID; |
|
| 2192 | + $content['mailDisplayContainerClass'] = (count($attachments) ? "mailDisplayContainer mailDisplayContainerFixedHeight" : "mailDisplayContainer mailDisplayContainerFullHeight"); |
|
| 2193 | + $content['mailDisplayAttachmentsClass'] = (count($attachments) ? "mailDisplayAttachments" : "mail_DisplayNone"); |
|
| 2195 | 2194 | |
| 2196 | 2195 | // DRAG attachments actions |
| 2197 | 2196 | $etpl->setElementAttribute('mail_displayattachments', 'actions', array( |
@@ -2208,22 +2207,22 @@ discard block |
||
| 2208 | 2207 | $this->changeProfile($rememberServerID); |
| 2209 | 2208 | } |
| 2210 | 2209 | |
| 2211 | - $etpl->exec('mail.mail_ui.displayMessage',$content,$sel_options,$readonlys,$preserv,2); |
|
| 2210 | + $etpl->exec('mail.mail_ui.displayMessage', $content, $sel_options, $readonlys, $preserv, 2); |
|
| 2212 | 2211 | } |
| 2213 | 2212 | |
| 2214 | 2213 | /** |
| 2215 | 2214 | * Build actions for display toolbar |
| 2216 | 2215 | */ |
| 2217 | - function getDisplayToolbarActions () |
|
| 2216 | + function getDisplayToolbarActions() |
|
| 2218 | 2217 | { |
| 2219 | 2218 | $actions = $this->get_toolbar_actions(); |
| 2220 | - $actions['mark']['children']['flagged']=array( |
|
| 2219 | + $actions['mark']['children']['flagged'] = array( |
|
| 2221 | 2220 | 'group' => $actions['mark']['children']['flagged']['group'], |
| 2222 | 2221 | 'caption' => 'Flagged', |
| 2223 | 2222 | 'icon' => 'unread_flagged_small', |
| 2224 | 2223 | 'onExecute' => 'javaScript:app.mail.mail_flag', |
| 2225 | 2224 | ); |
| 2226 | - $actions['mark']['children']['unflagged']=array( |
|
| 2225 | + $actions['mark']['children']['unflagged'] = array( |
|
| 2227 | 2226 | 'group' => $actions['mark']['children']['flagged']['group'], |
| 2228 | 2227 | 'caption' => 'Unflagged', |
| 2229 | 2228 | 'icon' => 'read_flagged_small', |
@@ -2235,9 +2234,9 @@ discard block |
||
| 2235 | 2234 | $compose = $actions['composeasnew']; |
| 2236 | 2235 | unset($actions['composeasnew']); |
| 2237 | 2236 | |
| 2238 | - $actions2 = array_reverse($actions,true); |
|
| 2239 | - $actions2['composeasnew']= $compose; |
|
| 2240 | - return array_reverse($actions2,true); |
|
| 2237 | + $actions2 = array_reverse($actions, true); |
|
| 2238 | + $actions2['composeasnew'] = $compose; |
|
| 2239 | + return array_reverse($actions2, true); |
|
| 2241 | 2240 | } |
| 2242 | 2241 | |
| 2243 | 2242 | /** |
@@ -2250,9 +2249,9 @@ discard block |
||
| 2250 | 2249 | * @param boolean $_returnFullHTML flag wether to return HTML or data array |
| 2251 | 2250 | * @return array|string data array or html or empty string |
| 2252 | 2251 | */ |
| 2253 | - static function createAttachmentBlock($attachments, $rowID, $uid, $mailbox,$_returnFullHTML=false) |
|
| 2252 | + static function createAttachmentBlock($attachments, $rowID, $uid, $mailbox, $_returnFullHTML = false) |
|
| 2254 | 2253 | { |
| 2255 | - $attachmentHTMLBlock=''; |
|
| 2254 | + $attachmentHTMLBlock = ''; |
|
| 2256 | 2255 | $attachmentHTML = array(); |
| 2257 | 2256 | |
| 2258 | 2257 | // skip message/delivery-status and set a title for original eml file |
@@ -2267,17 +2266,17 @@ discard block |
||
| 2267 | 2266 | } |
| 2268 | 2267 | |
| 2269 | 2268 | if (is_array($attachments) && count($attachments) > 0) { |
| 2270 | - $url_img_vfs = Api\Html::image('filemanager','navbar', lang('Filemanager'), ' height="16"'); |
|
| 2271 | - $url_img_vfs_save_all = Api\Html::image('mail','save_all', lang('Save all')); |
|
| 2269 | + $url_img_vfs = Api\Html::image('filemanager', 'navbar', lang('Filemanager'), ' height="16"'); |
|
| 2270 | + $url_img_vfs_save_all = Api\Html::image('mail', 'save_all', lang('Save all')); |
|
| 2272 | 2271 | |
| 2273 | 2272 | foreach ($attachments as $key => $value) |
| 2274 | 2273 | { |
| 2275 | - $attachmentHTML[$key]['filename']= ($value['name'] ? ( $value['filename'] ? $value['filename'] : $value['name'] ) : lang('(no subject)')); |
|
| 2276 | - $attachmentHTML[$key]['filename'] = Api\Translation::convert_jsonsafe($attachmentHTML[$key]['filename'],'utf-8'); |
|
| 2274 | + $attachmentHTML[$key]['filename'] = ($value['name'] ? ($value['filename'] ? $value['filename'] : $value['name']) : lang('(no subject)')); |
|
| 2275 | + $attachmentHTML[$key]['filename'] = Api\Translation::convert_jsonsafe($attachmentHTML[$key]['filename'], 'utf-8'); |
|
| 2277 | 2276 | //error_log(array2string($value)); |
| 2278 | 2277 | //error_log(strtoupper($value['mimeType']) .'<->'. Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename'])); |
| 2279 | - if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) $value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']); |
|
| 2280 | - $attachmentHTML[$key]['type']=$value['mimeType']; |
|
| 2278 | + if (strtoupper($value['mimeType'] == 'APPLICATION/OCTET-STREAM')) $value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']); |
|
| 2279 | + $attachmentHTML[$key]['type'] = $value['mimeType']; |
|
| 2281 | 2280 | $attachmentHTML[$key]['mimetype'] = Api\MimeMagic::mime2label($value['mimeType']); |
| 2282 | 2281 | $hA = self::splitRowID($rowID); |
| 2283 | 2282 | $uid = $hA['msgUID']; |
@@ -2287,28 +2286,27 @@ discard block |
||
| 2287 | 2286 | $attachmentHTML[$key]['mime_data'] = Link::set_data($value['mimeType'], 'EGroupware\\Api\\Mail::getAttachmentAccount', array( |
| 2288 | 2287 | $acc_id, $mailbox, $uid, $value['partID'], $value['is_winmail'], true |
| 2289 | 2288 | )); |
| 2290 | - $attachmentHTML[$key]['size']=Vfs::hsize($value['size']); |
|
| 2291 | - $attachmentHTML[$key]['attachment_number']=$key; |
|
| 2292 | - $attachmentHTML[$key]['partID']=$value['partID']; |
|
| 2289 | + $attachmentHTML[$key]['size'] = Vfs::hsize($value['size']); |
|
| 2290 | + $attachmentHTML[$key]['attachment_number'] = $key; |
|
| 2291 | + $attachmentHTML[$key]['partID'] = $value['partID']; |
|
| 2293 | 2292 | $attachmentHTML[$key]['mail_id'] = $rowID; |
| 2294 | - $attachmentHTML[$key]['winmailFlag']=$value['is_winmail']; |
|
| 2293 | + $attachmentHTML[$key]['winmailFlag'] = $value['is_winmail']; |
|
| 2295 | 2294 | $attachmentHTML[$key]['classSaveAllPossiblyDisabled'] = "mail_DisplayNone"; |
| 2296 | 2295 | // reset mode array as it should be considered differently for |
| 2297 | 2296 | // each attachment |
| 2298 | 2297 | $mode = array(); |
| 2299 | - switch(strtoupper($value['mimeType'])) |
|
| 2298 | + switch (strtoupper($value['mimeType'])) |
|
| 2300 | 2299 | { |
| 2301 | 2300 | case 'MESSAGE/RFC822': |
| 2302 | - $linkData = array |
|
| 2303 | - ( |
|
| 2301 | + $linkData = array( |
|
| 2304 | 2302 | 'menuaction' => 'mail.mail_ui.displayMessage', |
| 2305 | 2303 | 'mode' => 'display', //message/rfc822 attachments should be opened in display mode |
| 2306 | 2304 | 'id' => $rowID, |
| 2307 | 2305 | 'part' => $value['partID'], |
| 2308 | 2306 | 'is_winmail' => $value['is_winmail'] |
| 2309 | 2307 | ); |
| 2310 | - $windowName = 'displayMessage_'. $rowID.'_'.$value['partID']; |
|
| 2311 | - $linkView = "egw_openWindowCentered('".Egw::link('/index.php',$linkData)."','$windowName',700,egw_getWindowOuterHeight());"; |
|
| 2308 | + $windowName = 'displayMessage_'.$rowID.'_'.$value['partID']; |
|
| 2309 | + $linkView = "egw_openWindowCentered('".Egw::link('/index.php', $linkData)."','$windowName',700,egw_getWindowOuterHeight());"; |
|
| 2312 | 2310 | break; |
| 2313 | 2311 | case 'IMAGE/JPEG': |
| 2314 | 2312 | case 'IMAGE/PNG': |
@@ -2324,7 +2322,7 @@ discard block |
||
| 2324 | 2322 | case 'TEXT/HTML': |
| 2325 | 2323 | case 'TEXT/DIRECTORY': |
| 2326 | 2324 | $sfxMimeType = $value['mimeType']; |
| 2327 | - $buff = explode('.',$value['name']); |
|
| 2325 | + $buff = explode('.', $value['name']); |
|
| 2328 | 2326 | $suffix = ''; |
| 2329 | 2327 | if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
| 2330 | 2328 | if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix); |
@@ -2337,49 +2335,47 @@ discard block |
||
| 2337 | 2335 | case 'TEXT/VCARD': |
| 2338 | 2336 | case 'TEXT/CALENDAR': |
| 2339 | 2337 | case 'TEXT/X-VCALENDAR': |
| 2340 | - $linkData = array_merge(array |
|
| 2341 | - ( |
|
| 2338 | + $linkData = array_merge(array( |
|
| 2342 | 2339 | 'menuaction' => 'mail.mail_ui.getAttachment', |
| 2343 | 2340 | 'id' => $rowID, |
| 2344 | 2341 | 'part' => $value['partID'], |
| 2345 | 2342 | 'is_winmail' => $value['is_winmail'], |
| 2346 | 2343 | 'mailbox' => base64_encode($mailbox), |
| 2347 | - ) , $mode); |
|
| 2348 | - $windowName = 'displayAttachment_'. $uid; |
|
| 2344 | + ), $mode); |
|
| 2345 | + $windowName = 'displayAttachment_'.$uid; |
|
| 2349 | 2346 | $reg = '800x600'; |
| 2350 | 2347 | // handle calendar/vcard |
| 2351 | - if (strtoupper($value['mimeType'])=='TEXT/CALENDAR') |
|
| 2348 | + if (strtoupper($value['mimeType']) == 'TEXT/CALENDAR') |
|
| 2352 | 2349 | { |
| 2353 | - $windowName = 'displayEvent_'. $rowID; |
|
| 2354 | - $reg2 = Link::get_registry('calendar','view_popup'); |
|
| 2355 | - $attachmentHTML[$key]['popup']=(!empty($reg2) ? $reg2 : $reg); |
|
| 2350 | + $windowName = 'displayEvent_'.$rowID; |
|
| 2351 | + $reg2 = Link::get_registry('calendar', 'view_popup'); |
|
| 2352 | + $attachmentHTML[$key]['popup'] = (!empty($reg2) ? $reg2 : $reg); |
|
| 2356 | 2353 | } |
| 2357 | - if (strtoupper($value['mimeType'])=='TEXT/X-VCARD' || strtoupper($value['mimeType'])=='TEXT/VCARD') |
|
| 2354 | + if (strtoupper($value['mimeType']) == 'TEXT/X-VCARD' || strtoupper($value['mimeType']) == 'TEXT/VCARD') |
|
| 2358 | 2355 | { |
| 2359 | - $windowName = 'displayContact_'. $rowID; |
|
| 2360 | - $reg2 = Link::get_registry('addressbook','add_popup'); |
|
| 2361 | - $attachmentHTML[$key]['popup']=(!empty($reg2) ? $reg2 : $reg); |
|
| 2356 | + $windowName = 'displayContact_'.$rowID; |
|
| 2357 | + $reg2 = Link::get_registry('addressbook', 'add_popup'); |
|
| 2358 | + $attachmentHTML[$key]['popup'] = (!empty($reg2) ? $reg2 : $reg); |
|
| 2362 | 2359 | } |
| 2363 | 2360 | // apply to action |
| 2364 | - list($width,$height) = explode('x',(!empty($reg2) ? $reg2 : $reg)); |
|
| 2365 | - $linkView = "egw_openWindowCentered('".Egw::link('/index.php',$linkData)."','$windowName',$width,$height);"; |
|
| 2361 | + list($width, $height) = explode('x', (!empty($reg2) ? $reg2 : $reg)); |
|
| 2362 | + $linkView = "egw_openWindowCentered('".Egw::link('/index.php', $linkData)."','$windowName',$width,$height);"; |
|
| 2366 | 2363 | break; |
| 2367 | 2364 | default: |
| 2368 | - $linkData = array |
|
| 2369 | - ( |
|
| 2365 | + $linkData = array( |
|
| 2370 | 2366 | 'menuaction' => 'mail.mail_ui.getAttachment', |
| 2371 | 2367 | 'id' => $rowID, |
| 2372 | 2368 | 'part' => $value['partID'], |
| 2373 | 2369 | 'is_winmail' => $value['is_winmail'], |
| 2374 | 2370 | 'mailbox' => base64_encode($mailbox), |
| 2375 | 2371 | ); |
| 2376 | - $linkView = "window.location.href = '".Egw::link('/index.php',$linkData)."';"; |
|
| 2372 | + $linkView = "window.location.href = '".Egw::link('/index.php', $linkData)."';"; |
|
| 2377 | 2373 | break; |
| 2378 | 2374 | } |
| 2379 | 2375 | // we either use mime_data for server-side supported mime-types or mime_url for client-side or download |
| 2380 | 2376 | if (empty($attachmentHTML[$key]['mime_data'])) |
| 2381 | 2377 | { |
| 2382 | - $attachmentHTML[$key]['mime_url'] = Egw::link('/index.php',$linkData); |
|
| 2378 | + $attachmentHTML[$key]['mime_url'] = Egw::link('/index.php', $linkData); |
|
| 2383 | 2379 | unset($attachmentHTML[$key]['mime_data']); |
| 2384 | 2380 | } |
| 2385 | 2381 | $attachmentHTML[$key]['windowName'] = $windowName; |
@@ -2389,8 +2385,7 @@ discard block |
||
| 2389 | 2385 | ($value['name'] ? $value['name'] : lang('(no subject)')). |
| 2390 | 2386 | '</b></a>'; |
| 2391 | 2387 | |
| 2392 | - $linkData = array |
|
| 2393 | - ( |
|
| 2388 | + $linkData = array( |
|
| 2394 | 2389 | 'menuaction' => 'mail.mail_ui.getAttachment', |
| 2395 | 2390 | 'mode' => 'save', |
| 2396 | 2391 | 'id' => $rowID, |
@@ -2398,11 +2393,11 @@ discard block |
||
| 2398 | 2393 | 'is_winmail' => $value['is_winmail'], |
| 2399 | 2394 | 'mailbox' => base64_encode($mailbox), |
| 2400 | 2395 | ); |
| 2401 | - $attachmentHTML[$key]['link_save'] ="<a href='".Egw::link('/index.php',$linkData)."' title='".$attachmentHTML[$key]['filename']."'>".Api\Html::image('mail','fileexport')."</a>"; |
|
| 2396 | + $attachmentHTML[$key]['link_save'] = "<a href='".Egw::link('/index.php', $linkData)."' title='".$attachmentHTML[$key]['filename']."'>".Api\Html::image('mail', 'fileexport')."</a>"; |
|
| 2402 | 2397 | |
| 2403 | 2398 | if ($GLOBALS['egw_info']['user']['apps']['filemanager']) |
| 2404 | 2399 | { |
| 2405 | - $link_vfs_save = Egw::link('/index.php',array( |
|
| 2400 | + $link_vfs_save = Egw::link('/index.php', array( |
|
| 2406 | 2401 | 'menuaction' => 'filemanager.filemanager_select.select', |
| 2407 | 2402 | 'mode' => 'saveas', |
| 2408 | 2403 | 'name' => $value['name'], |
@@ -2421,19 +2416,19 @@ discard block |
||
| 2421 | 2416 | //$rowID |
| 2422 | 2417 | $ids["id[$ikey]"] = $rowID.'::'.$value['partID'].'::'.$value['is_winmail'].'::'.$value['name']; |
| 2423 | 2418 | } |
| 2424 | - $link_vfs_save = Egw::link('/index.php',array( |
|
| 2419 | + $link_vfs_save = Egw::link('/index.php', array( |
|
| 2425 | 2420 | 'menuaction' => 'filemanager.filemanager_select.select', |
| 2426 | 2421 | 'mode' => 'select-dir', |
| 2427 | 2422 | 'method' => 'mail.mail_ui.vfsSaveAttachment', |
| 2428 | 2423 | 'label' => lang('Save all'), |
| 2429 | - )+$ids); |
|
| 2424 | + ) + $ids); |
|
| 2430 | 2425 | $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>"; |
| 2431 | 2426 | } |
| 2432 | 2427 | $attachmentHTML[$key]['link_save'] .= $vfs_save; |
| 2433 | 2428 | //error_log(__METHOD__.__LINE__.$attachmentHTML[$key]['link_save']); |
| 2434 | 2429 | } |
| 2435 | 2430 | } |
| 2436 | - $attachmentHTMLBlock="<table width='100%'>"; |
|
| 2431 | + $attachmentHTMLBlock = "<table width='100%'>"; |
|
| 2437 | 2432 | foreach ((array)$attachmentHTML as $row) |
| 2438 | 2433 | { |
| 2439 | 2434 | $attachmentHTMLBlock .= "<tr><td><div class='useEllipsis'>".$row['link_view'].'</div></td>'; |
@@ -2451,7 +2446,7 @@ discard block |
||
| 2451 | 2446 | unset($attachmentHTML[$ikey]['link_save']); |
| 2452 | 2447 | } |
| 2453 | 2448 | } |
| 2454 | - return ($_returnFullHTML?$attachmentHTMLBlock:$attachmentHTML); |
|
| 2449 | + return ($_returnFullHTML ? $attachmentHTMLBlock : $attachmentHTML); |
|
| 2455 | 2450 | } |
| 2456 | 2451 | |
| 2457 | 2452 | /** |
@@ -2462,7 +2457,7 @@ discard block |
||
| 2462 | 2457 | */ |
| 2463 | 2458 | function gatherVacation($cachedVacations = array()) |
| 2464 | 2459 | { |
| 2465 | - $isVacationEnabled = $this->mail_bo->icServer->acc_sieve_enabled && ($this->mail_bo->icServer->acc_sieve_host||$this->mail_bo->icServer->acc_imap_host); |
|
| 2460 | + $isVacationEnabled = $this->mail_bo->icServer->acc_sieve_enabled && ($this->mail_bo->icServer->acc_sieve_host || $this->mail_bo->icServer->acc_imap_host); |
|
| 2466 | 2461 | //error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation)); |
| 2467 | 2462 | |
| 2468 | 2463 | if ($isVacationEnabled) |
@@ -2475,7 +2470,7 @@ discard block |
||
| 2475 | 2470 | |
| 2476 | 2471 | $cachedVacations = array($sieveServer->acc_id => $vacation) + (array)$cachedVacations; |
| 2477 | 2472 | // Set vacation to the instance cache for particular account with expiration of one day |
| 2478 | - Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations, 60*60*24); |
|
| 2473 | + Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations, 60 * 60 * 24); |
|
| 2479 | 2474 | } |
| 2480 | 2475 | catch (PEAR_Exception $ex) |
| 2481 | 2476 | { |
@@ -2501,35 +2496,35 @@ discard block |
||
| 2501 | 2496 | */ |
| 2502 | 2497 | function quotaDisplay($_usage, $_limit) |
| 2503 | 2498 | { |
| 2504 | - $percent = $_limit == 0 ? 100 : round(($_usage*100)/$_limit); |
|
| 2505 | - $limit = Mail::show_readable_size($_limit*1024); |
|
| 2506 | - $usage = Mail::show_readable_size($_usage*1024); |
|
| 2499 | + $percent = $_limit == 0 ? 100 : round(($_usage * 100) / $_limit); |
|
| 2500 | + $limit = Mail::show_readable_size($_limit * 1024); |
|
| 2501 | + $usage = Mail::show_readable_size($_usage * 1024); |
|
| 2507 | 2502 | |
| 2508 | 2503 | if ($_limit > 0) |
| 2509 | 2504 | { |
| 2510 | - $text = $usage .'/'.$limit; |
|
| 2505 | + $text = $usage.'/'.$limit; |
|
| 2511 | 2506 | switch ($percent) |
| 2512 | 2507 | { |
| 2513 | 2508 | case ($percent > 90): |
| 2514 | - $class ='mail-index_QuotaRed'; |
|
| 2509 | + $class = 'mail-index_QuotaRed'; |
|
| 2515 | 2510 | break; |
| 2516 | 2511 | case ($percent > 80): |
| 2517 | - $class ='mail-index_QuotaYellow'; |
|
| 2512 | + $class = 'mail-index_QuotaYellow'; |
|
| 2518 | 2513 | break; |
| 2519 | 2514 | default: |
| 2520 | - $class ='mail-index_QuotaGreen'; |
|
| 2515 | + $class = 'mail-index_QuotaGreen'; |
|
| 2521 | 2516 | } |
| 2522 | 2517 | } |
| 2523 | 2518 | else |
| 2524 | 2519 | { |
| 2525 | 2520 | $text = $usage; |
| 2526 | - $class ='mail-index_QuotaGreen'; |
|
| 2521 | + $class = 'mail-index_QuotaGreen'; |
|
| 2527 | 2522 | } |
| 2528 | - return array ( |
|
| 2523 | + return array( |
|
| 2529 | 2524 | 'class' => $class, |
| 2530 | - 'text' => lang('Quota: %1',$text), |
|
| 2525 | + 'text' => lang('Quota: %1', $text), |
|
| 2531 | 2526 | 'percent' => $percent, |
| 2532 | - 'freespace' => $_limit*1024 - $_usage*1024 |
|
| 2527 | + 'freespace' => $_limit * 1024 - $_usage * 1024 |
|
| 2533 | 2528 | ); |
| 2534 | 2529 | } |
| 2535 | 2530 | |
@@ -2543,12 +2538,12 @@ discard block |
||
| 2543 | 2538 | $uid = $_GET['uid']; |
| 2544 | 2539 | $cid = base64_decode($_GET['cid']); |
| 2545 | 2540 | $partID = urldecode($_GET['partID']); |
| 2546 | - if (!empty($_GET['mailbox'])) $mailbox = base64_decode($_GET['mailbox']); |
|
| 2541 | + if (!empty($_GET['mailbox'])) $mailbox = base64_decode($_GET['mailbox']); |
|
| 2547 | 2542 | |
| 2548 | 2543 | //error_log(__METHOD__.__LINE__.":$uid, $cid, $partID"); |
| 2549 | 2544 | $this->mail_bo->reopen($mailbox); |
| 2550 | 2545 | |
| 2551 | - $attachment = $this->mail_bo->getAttachmentByCID($uid, $cid, $partID, true); // true get contents as stream |
|
| 2546 | + $attachment = $this->mail_bo->getAttachmentByCID($uid, $cid, $partID, true); // true get contents as stream |
|
| 2552 | 2547 | |
| 2553 | 2548 | $this->mail_bo->closeConnection(); |
| 2554 | 2549 | |
@@ -2556,8 +2551,8 @@ discard block |
||
| 2556 | 2551 | |
| 2557 | 2552 | if ($attachment) |
| 2558 | 2553 | { |
| 2559 | - header("Content-Type: ". $attachment->getType()); |
|
| 2560 | - header('Content-Disposition: inline; filename="'. $attachment->getDispositionParameter('filename') .'"'); |
|
| 2554 | + header("Content-Type: ".$attachment->getType()); |
|
| 2555 | + header('Content-Disposition: inline; filename="'.$attachment->getDispositionParameter('filename').'"'); |
|
| 2561 | 2556 | //header("Expires: 0"); |
| 2562 | 2557 | // the next headers are for IE and SSL |
| 2563 | 2558 | //header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
@@ -2575,7 +2570,7 @@ discard block |
||
| 2575 | 2570 | |
| 2576 | 2571 | function getAttachment() |
| 2577 | 2572 | { |
| 2578 | - if(isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 2573 | + if (isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 2579 | 2574 | |
| 2580 | 2575 | $hA = self::splitRowID($rowID); |
| 2581 | 2576 | $uid = $hA['msgUID']; |
@@ -2587,11 +2582,11 @@ discard block |
||
| 2587 | 2582 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
| 2588 | 2583 | $this->changeProfile($icServerID); |
| 2589 | 2584 | } |
| 2590 | - $part = $_GET['part']; |
|
| 2585 | + $part = $_GET['part']; |
|
| 2591 | 2586 | $is_winmail = $_GET['is_winmail'] ? $_GET['is_winmail'] : 0; |
| 2592 | 2587 | |
| 2593 | 2588 | $this->mail_bo->reopen($mailbox); |
| 2594 | - $attachment = $this->mail_bo->getAttachment($uid,$part,$is_winmail,false); |
|
| 2589 | + $attachment = $this->mail_bo->getAttachment($uid, $part, $is_winmail, false); |
|
| 2595 | 2590 | $this->mail_bo->closeConnection(); |
| 2596 | 2591 | if ($rememberServerID != $this->mail_bo->profileID) |
| 2597 | 2592 | { |
@@ -2606,7 +2601,7 @@ discard block |
||
| 2606 | 2601 | if (strtoupper($attachment['type']) == 'TEXT/DIRECTORY' || empty($attachment['type'])) |
| 2607 | 2602 | { |
| 2608 | 2603 | $sfxMimeType = $attachment['type']; |
| 2609 | - $buff = explode('.',$attachment['filename']); |
|
| 2604 | + $buff = explode('.', $attachment['filename']); |
|
| 2610 | 2605 | $suffix = ''; |
| 2611 | 2606 | if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
| 2612 | 2607 | if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix); |
@@ -2618,10 +2613,10 @@ discard block |
||
| 2618 | 2613 | { |
| 2619 | 2614 | //error_log(__METHOD__."about to call calendar_ical"); |
| 2620 | 2615 | $calendar_ical = new calendar_ical(); |
| 2621 | - $eventid = $calendar_ical->search($attachment['attachment'],-1); |
|
| 2616 | + $eventid = $calendar_ical->search($attachment['attachment'], -1); |
|
| 2622 | 2617 | //error_log(__METHOD__.array2string($eventid)); |
| 2623 | 2618 | if (!$eventid) $eventid = -1; |
| 2624 | - $event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true,0,'',null,$attachment['charset']); |
|
| 2619 | + $event = $calendar_ical->importVCal($attachment['attachment'], (is_array($eventid) ? $eventid[0] : $eventid), null, true, 0, '', null, $attachment['charset']); |
|
| 2625 | 2620 | //error_log(__METHOD__.$event); |
| 2626 | 2621 | if ((int)$event > 0) |
| 2627 | 2622 | { |
@@ -2629,7 +2624,7 @@ discard block |
||
| 2629 | 2624 | 'menuaction' => 'calendar.calendar_uiforms.edit', |
| 2630 | 2625 | 'cal_id' => $event, |
| 2631 | 2626 | ); |
| 2632 | - Egw::redirect_link('../index.php',$vars); |
|
| 2627 | + Egw::redirect_link('../index.php', $vars); |
|
| 2633 | 2628 | } |
| 2634 | 2629 | //Import failed, download content anyway |
| 2635 | 2630 | } |
@@ -2644,13 +2639,13 @@ discard block |
||
| 2644 | 2639 | { |
| 2645 | 2640 | $vcard['uid'] = trim($vcard['uid']); |
| 2646 | 2641 | //error_log(__METHOD__.__LINE__.print_r($vcard,true)); |
| 2647 | - $contact = $addressbook_vcal->find_contact($vcard,false); |
|
| 2642 | + $contact = $addressbook_vcal->find_contact($vcard, false); |
|
| 2648 | 2643 | } |
| 2649 | 2644 | if (!$contact) $contact = null; |
| 2650 | 2645 | // 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)) |
| 2651 | - if ($contact || count($vcard)>2) |
|
| 2646 | + if ($contact || count($vcard) > 2) |
|
| 2652 | 2647 | { |
| 2653 | - $contact = $addressbook_vcal->addVCard($attachment['attachment'],(is_array($contact)?array_shift($contact):$contact),true,$attachment['charset']); |
|
| 2648 | + $contact = $addressbook_vcal->addVCard($attachment['attachment'], (is_array($contact) ? array_shift($contact) : $contact), true, $attachment['charset']); |
|
| 2654 | 2649 | } |
| 2655 | 2650 | if ((int)$contact > 0) |
| 2656 | 2651 | { |
@@ -2658,14 +2653,14 @@ discard block |
||
| 2658 | 2653 | 'menuaction' => 'addressbook.addressbook_ui.edit', |
| 2659 | 2654 | 'contact_id' => $contact, |
| 2660 | 2655 | ); |
| 2661 | - Egw::redirect_link('../index.php',$vars); |
|
| 2656 | + Egw::redirect_link('../index.php', $vars); |
|
| 2662 | 2657 | } |
| 2663 | 2658 | //Import failed, download content anyway |
| 2664 | 2659 | } |
| 2665 | 2660 | } |
| 2666 | 2661 | //error_log(__METHOD__.__LINE__.'->'.array2string($attachment)); |
| 2667 | - $filename = ($attachment['name']?$attachment['name']:($attachment['filename']?$attachment['filename']:$mailbox.'_uid'.$uid.'_part'.$part)); |
|
| 2668 | - Api\Header\Content::safe($attachment['attachment'], $filename, $attachment['type'], $size=0, True, $_GET['mode'] == "save"); |
|
| 2662 | + $filename = ($attachment['name'] ? $attachment['name'] : ($attachment['filename'] ? $attachment['filename'] : $mailbox.'_uid'.$uid.'_part'.$part)); |
|
| 2663 | + Api\Header\Content::safe($attachment['attachment'], $filename, $attachment['type'], $size = 0, True, $_GET['mode'] == "save"); |
|
| 2669 | 2664 | echo $attachment['attachment']; |
| 2670 | 2665 | |
| 2671 | 2666 | exit(); |
@@ -2680,9 +2675,9 @@ discard block |
||
| 2680 | 2675 | function saveMessage() |
| 2681 | 2676 | { |
| 2682 | 2677 | $display = false; |
| 2683 | - if(isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 2684 | - if(isset($_GET['part'])) $partID = $_GET['part']; |
|
| 2685 | - if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager')) $display = $_GET['location']; |
|
| 2678 | + if (isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 2679 | + if (isset($_GET['part'])) $partID = $_GET['part']; |
|
| 2680 | + if (isset($_GET['location']) && ($_GET['location'] == 'display' || $_GET['location'] == 'filemanager')) $display = $_GET['location']; |
|
| 2686 | 2681 | |
| 2687 | 2682 | $hA = self::splitRowID($rowID); |
| 2688 | 2683 | $uid = $hA['msgUID']; |
@@ -2710,14 +2705,14 @@ discard block |
||
| 2710 | 2705 | if (!$display) |
| 2711 | 2706 | { |
| 2712 | 2707 | $headers = Horde_Mime_Headers::parseHeaders($message); |
| 2713 | - $subject = str_replace('$$','__',Mail::decode_header($headers['SUBJECT'])); |
|
| 2714 | - Api\Header\Content::safe($message, $subject.".eml", $mime='message/rfc822', $size=0, true, true); |
|
| 2708 | + $subject = str_replace('$$', '__', Mail::decode_header($headers['SUBJECT'])); |
|
| 2709 | + Api\Header\Content::safe($message, $subject.".eml", $mime = 'message/rfc822', $size = 0, true, true); |
|
| 2715 | 2710 | echo $message; |
| 2716 | 2711 | } |
| 2717 | 2712 | else |
| 2718 | 2713 | { |
| 2719 | - Api\Header\Content::safe($message, $subject.".eml", $mime='text/html', $size=0, true, false); |
|
| 2720 | - print '<pre>'. htmlspecialchars($message, ENT_NOQUOTES|ENT_SUBSTITUTE, 'utf-8') .'</pre>'; |
|
| 2714 | + Api\Header\Content::safe($message, $subject.".eml", $mime = 'text/html', $size = 0, true, false); |
|
| 2715 | + print '<pre>'.htmlspecialchars($message, ENT_NOQUOTES|ENT_SUBSTITUTE, 'utf-8').'</pre>'; |
|
| 2721 | 2716 | } |
| 2722 | 2717 | } |
| 2723 | 2718 | |
@@ -2729,18 +2724,18 @@ discard block |
||
| 2729 | 2724 | * @param boolean $close Return javascript to close the window |
| 2730 | 2725 | * @return string|boolean javascript eg. to close the selector window if $close is true, or success/fail if $close is false |
| 2731 | 2726 | */ |
| 2732 | - function vfsSaveMessage($ids,$path, $close = true) |
|
| 2727 | + function vfsSaveMessage($ids, $path, $close = true) |
|
| 2733 | 2728 | { |
| 2734 | 2729 | //error_log(__METHOD__.' IDs:'.array2string($ids).' SaveToPath:'.$path); |
| 2735 | 2730 | |
| 2736 | 2731 | if (is_array($ids) && !Vfs::is_writable($path) || !is_array($ids) && !Vfs::is_writable(dirname($path))) |
| 2737 | 2732 | { |
| 2738 | - return 'alert("'.addslashes(lang('%1 is NOT writable by you!',$path)).'"); Egw(window).close();'; |
|
| 2733 | + return 'alert("'.addslashes(lang('%1 is NOT writable by you!', $path)).'"); Egw(window).close();'; |
|
| 2739 | 2734 | } |
| 2740 | 2735 | Api\Translation::add_app('mail'); |
| 2741 | 2736 | |
| 2742 | 2737 | $rememberServerID = $this->mail_bo->profileID; |
| 2743 | - foreach((array)$ids as $id) |
|
| 2738 | + foreach ((array)$ids as $id) |
|
| 2744 | 2739 | { |
| 2745 | 2740 | $hA = self::splitRowID($id); |
| 2746 | 2741 | $uid = $hA['msgUID']; |
@@ -2751,20 +2746,20 @@ discard block |
||
| 2751 | 2746 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
| 2752 | 2747 | $this->changeProfile($icServerID); |
| 2753 | 2748 | } |
| 2754 | - $message = $this->mail_bo->getMessageRawBody($uid, $partID='', $mailbox); |
|
| 2755 | - $err=null; |
|
| 2756 | - if(Vfs::is_dir($path)) |
|
| 2749 | + $message = $this->mail_bo->getMessageRawBody($uid, $partID = '', $mailbox); |
|
| 2750 | + $err = null; |
|
| 2751 | + if (Vfs::is_dir($path)) |
|
| 2757 | 2752 | { |
| 2758 | - $headers = $this->mail_bo->getMessageHeader($uid,$partID,true,false,$mailbox); |
|
| 2759 | - $file = $path . '/'.preg_replace('/[\f\n\t\v\\:*#?<>\|]/',"_",$headers['SUBJECT']).'.eml'; |
|
| 2753 | + $headers = $this->mail_bo->getMessageHeader($uid, $partID, true, false, $mailbox); |
|
| 2754 | + $file = $path.'/'.preg_replace('/[\f\n\t\v\\:*#?<>\|]/', "_", $headers['SUBJECT']).'.eml'; |
|
| 2760 | 2755 | } |
| 2761 | 2756 | else |
| 2762 | 2757 | { |
| 2763 | 2758 | $file = $path; |
| 2764 | 2759 | } |
| 2765 | - if (!($fp = Vfs::fopen($file,'wb')) || !fwrite($fp,$message)) |
|
| 2760 | + if (!($fp = Vfs::fopen($file, 'wb')) || !fwrite($fp, $message)) |
|
| 2766 | 2761 | { |
| 2767 | - $err .= lang('Error saving %1!',$file); |
|
| 2762 | + $err .= lang('Error saving %1!', $file); |
|
| 2768 | 2763 | $succeeded = false; |
| 2769 | 2764 | } |
| 2770 | 2765 | else |
@@ -2774,10 +2769,10 @@ discard block |
||
| 2774 | 2769 | if ($fp) fclose($fp); |
| 2775 | 2770 | if ($succeeded) |
| 2776 | 2771 | { |
| 2777 | - unset($headers['SUBJECT']);//already in filename |
|
| 2772 | + unset($headers['SUBJECT']); //already in filename |
|
| 2778 | 2773 | $infoSection = Mail::createHeaderInfoSection($headers, 'SUPPRESS', false); |
| 2779 | - $props = array(array('name' => 'comment','val' => $infoSection)); |
|
| 2780 | - Vfs::proppatch($file,$props); |
|
| 2774 | + $props = array(array('name' => 'comment', 'val' => $infoSection)); |
|
| 2775 | + Vfs::proppatch($file, $props); |
|
| 2781 | 2776 | } |
| 2782 | 2777 | } |
| 2783 | 2778 | if ($rememberServerID != $this->mail_bo->profileID) |
@@ -2786,9 +2781,9 @@ discard block |
||
| 2786 | 2781 | $this->changeProfile($rememberServerID); |
| 2787 | 2782 | } |
| 2788 | 2783 | |
| 2789 | - if($close) |
|
| 2784 | + if ($close) |
|
| 2790 | 2785 | { |
| 2791 | - Framework::window_close(($err?$err:null)); |
|
| 2786 | + Framework::window_close(($err ? $err : null)); |
|
| 2792 | 2787 | } |
| 2793 | 2788 | else |
| 2794 | 2789 | { |
@@ -2803,15 +2798,15 @@ discard block |
||
| 2803 | 2798 | * @param string $path path in vfs (no Vfs::PREFIX!), only directory for multiple id's ($ids is an array) |
| 2804 | 2799 | * @return string javascript eg. to close the selector window |
| 2805 | 2800 | */ |
| 2806 | - function vfsSaveAttachment($ids,$path) |
|
| 2801 | + function vfsSaveAttachment($ids, $path) |
|
| 2807 | 2802 | { |
| 2808 | 2803 | //error_log(__METHOD__.__LINE__.'("'.array2string($ids).'","'.$path."\")');"); |
| 2809 | 2804 | |
| 2810 | 2805 | if (is_array($ids) && !Vfs::is_writable($path) || !is_array($ids) && !Vfs::is_writable(dirname($path))) |
| 2811 | 2806 | { |
| 2812 | - return 'alert("'.addslashes(lang('%1 is NOT writable by you!',$path)).'"); Egw(window).close();'; |
|
| 2807 | + return 'alert("'.addslashes(lang('%1 is NOT writable by you!', $path)).'"); Egw(window).close();'; |
|
| 2813 | 2808 | } |
| 2814 | - $err=null; |
|
| 2809 | + $err = null; |
|
| 2815 | 2810 | $dupe_count = array(); |
| 2816 | 2811 | $rememberServerID = $this->mail_bo->profileID; |
| 2817 | 2812 | |
@@ -2821,12 +2816,12 @@ discard block |
||
| 2821 | 2816 | * |
| 2822 | 2817 | * @return array an array of parameters |
| 2823 | 2818 | */ |
| 2824 | - $getParams = function ($id) { |
|
| 2825 | - list($app,$user,$serverID,$mailbox,$uid,$part,$is_winmail,$name) = explode('::',$id,8); |
|
| 2826 | - $lId = implode('::',array($app,$user,$serverID,$mailbox,$uid)); |
|
| 2819 | + $getParams = function($id) { |
|
| 2820 | + list($app, $user, $serverID, $mailbox, $uid, $part, $is_winmail, $name) = explode('::', $id, 8); |
|
| 2821 | + $lId = implode('::', array($app, $user, $serverID, $mailbox, $uid)); |
|
| 2827 | 2822 | $hA = mail_ui::splitRowID($lId); |
| 2828 | 2823 | return array( |
| 2829 | - 'is_winmail' => $is_winmail == "null" || !$is_winmail?false:$is_winmail, |
|
| 2824 | + 'is_winmail' => $is_winmail == "null" || !$is_winmail ? false : $is_winmail, |
|
| 2830 | 2825 | 'user' => $user, |
| 2831 | 2826 | 'name' => $name, |
| 2832 | 2827 | 'part' => $part, |
@@ -2838,8 +2833,8 @@ discard block |
||
| 2838 | 2833 | |
| 2839 | 2834 | //Examine the first attachment to see if attachment |
| 2840 | 2835 | //is winmail.dat embedded attachments. |
| 2841 | - $isMultipleDownload=is_array($ids); |
|
| 2842 | - $p = $getParams((is_array($ids)?$ids[0]:$ids)); |
|
| 2836 | + $isMultipleDownload = is_array($ids); |
|
| 2837 | + $p = $getParams((is_array($ids) ? $ids[0] : $ids)); |
|
| 2843 | 2838 | if ($p['is_winmail']) |
| 2844 | 2839 | { |
| 2845 | 2840 | if ($p['icServer'] && $p['icServer'] != $this->mail_bo->profileID) |
@@ -2850,14 +2845,14 @@ discard block |
||
| 2850 | 2845 | // retrieve all embedded attachments at once |
| 2851 | 2846 | // avoids to fetch heavy winmail.dat content |
| 2852 | 2847 | // for each file. |
| 2853 | - $attachments = $this->mail_bo->getTnefAttachments($p['uid'],$p['part']); |
|
| 2848 | + $attachments = $this->mail_bo->getTnefAttachments($p['uid'], $p['part']); |
|
| 2854 | 2849 | } |
| 2855 | 2850 | |
| 2856 | - foreach((array)$ids as $id) |
|
| 2851 | + foreach ((array)$ids as $id) |
|
| 2857 | 2852 | { |
| 2858 | 2853 | $params = $getParams($id); |
| 2859 | 2854 | // when downloading a single file, name is not set |
| 2860 | - if (!$params['name']&&isset($_GET['name'])&&!$isMultipleDownload) $params['name'] = $_GET['name']; |
|
| 2855 | + if (!$params['name'] && isset($_GET['name']) && !$isMultipleDownload) $params['name'] = $_GET['name']; |
|
| 2861 | 2856 | if ($params['icServer'] && $params['icServer'] != $this->mail_bo->profileID) |
| 2862 | 2857 | { |
| 2863 | 2858 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
@@ -2875,25 +2870,25 @@ discard block |
||
| 2875 | 2870 | } |
| 2876 | 2871 | else |
| 2877 | 2872 | { |
| 2878 | - $attachment = $this->mail_bo->getAttachment($params['uid'],$params['part'],$params['is_winmail'],false); |
|
| 2873 | + $attachment = $this->mail_bo->getAttachment($params['uid'], $params['part'], $params['is_winmail'], false); |
|
| 2879 | 2874 | } |
| 2880 | 2875 | |
| 2881 | 2876 | $file = $params['name']; |
| 2882 | 2877 | // when $isMultipleDownload the path holds no filename |
| 2883 | - while(Vfs::file_exists($path.($file && $isMultipleDownload ? '/'.$file : ''))) |
|
| 2878 | + while (Vfs::file_exists($path.($file && $isMultipleDownload ? '/'.$file : ''))) |
|
| 2884 | 2879 | { |
| 2885 | 2880 | $dupe_count[$params['name']]++; |
| 2886 | - $file = pathinfo($params['name'], PATHINFO_FILENAME) . |
|
| 2887 | - ' ('.($dupe_count[$params['name']] + 1).')' . '.' . |
|
| 2881 | + $file = pathinfo($params['name'], PATHINFO_FILENAME). |
|
| 2882 | + ' ('.($dupe_count[$params['name']] + 1).')'.'.'. |
|
| 2888 | 2883 | pathinfo($params['name'], PATHINFO_EXTENSION); |
| 2889 | 2884 | } |
| 2890 | 2885 | $params['name'] = $file; |
| 2891 | 2886 | //error_log(__METHOD__.__LINE__.array2string($attachment)); |
| 2892 | 2887 | // when $isMultipleDownload the path holds no filename |
| 2893 | - if (!($fp = Vfs::fopen($file=$path.($params['name'] && $isMultipleDownload ? '/'.$params['name'] : ''),'wb')) || |
|
| 2894 | - !fwrite($fp,$attachment['attachment'])) |
|
| 2888 | + if (!($fp = Vfs::fopen($file = $path.($params['name'] && $isMultipleDownload ? '/'.$params['name'] : ''), 'wb')) || |
|
| 2889 | + !fwrite($fp, $attachment['attachment'])) |
|
| 2895 | 2890 | { |
| 2896 | - $err .= lang('Error saving %1!',$file); |
|
| 2891 | + $err .= lang('Error saving %1!', $file); |
|
| 2897 | 2892 | } |
| 2898 | 2893 | if ($fp) |
| 2899 | 2894 | { |
@@ -2906,21 +2901,21 @@ discard block |
||
| 2906 | 2901 | //error_log(__METHOD__.__LINE__.' change Profile back to where we came from ->'.$rememberServerID); |
| 2907 | 2902 | $this->changeProfile($rememberServerID); |
| 2908 | 2903 | } |
| 2909 | - Framework::window_close(($err?$err:null)); |
|
| 2904 | + Framework::window_close(($err ? $err : null)); |
|
| 2910 | 2905 | } |
| 2911 | 2906 | |
| 2912 | 2907 | /** |
| 2913 | 2908 | * Zip all attachments and send to user |
| 2914 | 2909 | * @param string $message_id = null |
| 2915 | 2910 | */ |
| 2916 | - function download_zip($message_id=null) |
|
| 2911 | + function download_zip($message_id = null) |
|
| 2917 | 2912 | { |
| 2918 | 2913 | //error_log(__METHOD__.__LINE__.array2string($_GET)); |
| 2919 | 2914 | // First, get all attachment IDs |
| 2920 | - if(isset($_GET['id'])) $message_id = $_GET['id']; |
|
| 2915 | + if (isset($_GET['id'])) $message_id = $_GET['id']; |
|
| 2921 | 2916 | //error_log(__METHOD__.__LINE__.$message_id); |
| 2922 | 2917 | $rememberServerID = $this->mail_bo->profileID; |
| 2923 | - if(!is_numeric($message_id)) |
|
| 2918 | + if (!is_numeric($message_id)) |
|
| 2924 | 2919 | { |
| 2925 | 2920 | $hA = self::splitRowID($message_id); |
| 2926 | 2921 | $message_id = $hA['msgUID']; |
@@ -2938,18 +2933,18 @@ discard block |
||
| 2938 | 2933 | } |
| 2939 | 2934 | // always fetch all, even inline (images) |
| 2940 | 2935 | $fetchEmbeddedImages = true; |
| 2941 | - $attachments = $this->mail_bo->getMessageAttachments($message_id,null, null, $fetchEmbeddedImages, true,true,$mailbox); |
|
| 2936 | + $attachments = $this->mail_bo->getMessageAttachments($message_id, null, null, $fetchEmbeddedImages, true, true, $mailbox); |
|
| 2942 | 2937 | // put them in VFS so they can be zipped |
| 2943 | - $header = $this->mail_bo->getMessageHeader($message_id,'',true,false,$mailbox); |
|
| 2938 | + $header = $this->mail_bo->getMessageHeader($message_id, '', true, false, $mailbox); |
|
| 2944 | 2939 | //get_home_dir may fetch the users startfolder if set; if not writeable, action will fail. TODO: use temp_dir |
| 2945 | 2940 | $homedir = '/home/'.$GLOBALS['egw_info']['user']['account_lid']; |
| 2946 | - $temp_path = $homedir/*Vfs::get_home_dir()*/ . "/.mail_$message_id"; |
|
| 2947 | - if(Vfs::is_dir($temp_path)) Vfs::remove ($temp_path); |
|
| 2941 | + $temp_path = $homedir/*Vfs::get_home_dir()*/."/.mail_$message_id"; |
|
| 2942 | + if (Vfs::is_dir($temp_path)) Vfs::remove($temp_path); |
|
| 2948 | 2943 | |
| 2949 | 2944 | // Add subject to path, so it gets used as the file name, replacing ':' |
| 2950 | 2945 | // as it seems to cause an error |
| 2951 | - $path = $temp_path . '/' . ($header['SUBJECT'] ? Vfs::encodePathComponent(str_replace(':','-', $header['SUBJECT'])) : lang('mail')) .'/'; |
|
| 2952 | - if(!Vfs::mkdir($path, 0700, true)) |
|
| 2946 | + $path = $temp_path.'/'.($header['SUBJECT'] ? Vfs::encodePathComponent(str_replace(':', '-', $header['SUBJECT'])) : lang('mail')).'/'; |
|
| 2947 | + if (!Vfs::mkdir($path, 0700, true)) |
|
| 2953 | 2948 | { |
| 2954 | 2949 | echo "Unable to open temp directory $path"; |
| 2955 | 2950 | return; |
@@ -2958,11 +2953,11 @@ discard block |
||
| 2958 | 2953 | $file_list = array(); |
| 2959 | 2954 | $dupe_count = array(); |
| 2960 | 2955 | $this->mail_bo->reopen($mailbox); |
| 2961 | - if ($attachments[0]['is_winmail'] && $attachments[0]['is_winmail']!='null') |
|
| 2956 | + if ($attachments[0]['is_winmail'] && $attachments[0]['is_winmail'] != 'null') |
|
| 2962 | 2957 | { |
| 2963 | - $tnefAttachments = $this->mail_bo->getTnefAttachments($message_id, $attachments[0]['partID'],true); |
|
| 2958 | + $tnefAttachments = $this->mail_bo->getTnefAttachments($message_id, $attachments[0]['partID'], true); |
|
| 2964 | 2959 | } |
| 2965 | - foreach($attachments as $file) |
|
| 2960 | + foreach ($attachments as $file) |
|
| 2966 | 2961 | { |
| 2967 | 2962 | if ($file['is_winmail']) |
| 2968 | 2963 | { |
@@ -2975,25 +2970,25 @@ discard block |
||
| 2975 | 2970 | } |
| 2976 | 2971 | else |
| 2977 | 2972 | { |
| 2978 | - $attachment = $this->mail_bo->getAttachment($message_id,$file['partID'],$file['is_winmail'],false,true); |
|
| 2973 | + $attachment = $this->mail_bo->getAttachment($message_id, $file['partID'], $file['is_winmail'], false, true); |
|
| 2979 | 2974 | } |
| 2980 | - $success=true; |
|
| 2975 | + $success = true; |
|
| 2981 | 2976 | if (empty($file['filename'])) $file['filename'] = $file['name']; |
| 2982 | - if(in_array($path.$file['filename'], $file_list)) |
|
| 2977 | + if (in_array($path.$file['filename'], $file_list)) |
|
| 2983 | 2978 | { |
| 2984 | 2979 | $dupe_count[$path.$file['filename']]++; |
| 2985 | - $file['filename'] = pathinfo($file['filename'], PATHINFO_FILENAME) . |
|
| 2986 | - ' ('.($dupe_count[$path.$file['filename']] + 1).')' . '.' . |
|
| 2980 | + $file['filename'] = pathinfo($file['filename'], PATHINFO_FILENAME). |
|
| 2981 | + ' ('.($dupe_count[$path.$file['filename']] + 1).')'.'.'. |
|
| 2987 | 2982 | pathinfo($file['filename'], PATHINFO_EXTENSION); |
| 2988 | 2983 | } |
| 2989 | 2984 | // Strip special characters to make sure the files are visible for all OS (windows has issues) |
| 2990 | 2985 | $target_name = iconv($file['charset'] ? $file['charset'] : $GLOBALS['egw_info']['server']['system_charset'], 'ASCII//IGNORE', $file['filename']); |
| 2991 | 2986 | |
| 2992 | - if (!($fp = Vfs::fopen($path.$target_name,'wb')) || |
|
| 2987 | + if (!($fp = Vfs::fopen($path.$target_name, 'wb')) || |
|
| 2993 | 2988 | !(!fseek($attachment['attachment'], 0, SEEK_SET) && stream_copy_to_stream($attachment['attachment'], $fp))) |
| 2994 | 2989 | { |
| 2995 | - $success=false; |
|
| 2996 | - Framework::message("Unable to zip {$target_name}",'error'); |
|
| 2990 | + $success = false; |
|
| 2991 | + Framework::message("Unable to zip {$target_name}", 'error'); |
|
| 2997 | 2992 | } |
| 2998 | 2993 | if ($success) $file_list[] = $path.$target_name; |
| 2999 | 2994 | if ($fp) fclose($fp); |
@@ -3014,7 +3009,7 @@ discard block |
||
| 3014 | 3009 | exit(); |
| 3015 | 3010 | } |
| 3016 | 3011 | |
| 3017 | - function get_load_email_data($uid, $partID, $mailbox,$htmlOptions=null) |
|
| 3012 | + function get_load_email_data($uid, $partID, $mailbox, $htmlOptions = null) |
|
| 3018 | 3013 | { |
| 3019 | 3014 | // seems to be needed, as if we open a mail from notification popup that is |
| 3020 | 3015 | // located in a different folder, we experience: could not parse message |
@@ -3027,7 +3022,7 @@ discard block |
||
| 3027 | 3022 | // fetching structure now, to supply it to getMessageBody and getMessageAttachment, so it does not get fetched twice |
| 3028 | 3023 | $structure = $this->mail_bo->getStructure($uid, $partID, $mailbox, false); |
| 3029 | 3024 | $calendar_part = null; |
| 3030 | - $bodyParts = $this->mail_bo->getMessageBody($uid, ($htmlOptions?$htmlOptions:''), $partID, $structure, false, $mailbox, $calendar_part); |
|
| 3025 | + $bodyParts = $this->mail_bo->getMessageBody($uid, ($htmlOptions ? $htmlOptions : ''), $partID, $structure, false, $mailbox, $calendar_part); |
|
| 3031 | 3026 | |
| 3032 | 3027 | // for meeting requests (multipart alternative with text/calendar part) let calendar render it |
| 3033 | 3028 | if ($calendar_part && isset($GLOBALS['egw_info']['user']['apps']['calendar'])) |
@@ -3042,26 +3037,26 @@ discard block |
||
| 3042 | 3037 | $this->mail_bo->htmlOptions = $bufferHtmlOptions; |
| 3043 | 3038 | Api\Translation::add_app('calendar'); |
| 3044 | 3039 | return ExecMethod('calendar.calendar_uiforms.meeting', |
| 3045 | - array('event'=>null,'msg'=>'','useSession'=>true) |
|
| 3040 | + array('event'=>null, 'msg'=>'', 'useSession'=>true) |
|
| 3046 | 3041 | ); |
| 3047 | 3042 | } |
| 3048 | 3043 | // Compose the content of the frame |
| 3049 | 3044 | $frameHtml = |
| 3050 | 3045 | $this->get_email_header($this->mail_bo->getStyles($bodyParts)). |
| 3051 | - $this->showBody($this->getdisplayableBody($bodyParts,true,false), false); |
|
| 3046 | + $this->showBody($this->getdisplayableBody($bodyParts, true, false), false); |
|
| 3052 | 3047 | //IE10 eats away linebreaks preceeded by a whitespace in PRE sections |
| 3053 | - $frameHtml = str_replace(" \r\n","\r\n",$frameHtml); |
|
| 3048 | + $frameHtml = str_replace(" \r\n", "\r\n", $frameHtml); |
|
| 3054 | 3049 | $this->mail_bo->htmlOptions = $bufferHtmlOptions; |
| 3055 | 3050 | |
| 3056 | 3051 | return $frameHtml; |
| 3057 | 3052 | } |
| 3058 | 3053 | |
| 3059 | - static function get_email_header($additionalStyle='') |
|
| 3054 | + static function get_email_header($additionalStyle = '') |
|
| 3060 | 3055 | { |
| 3061 | 3056 | // egw_info[flags][css] already include <style> tags |
| 3062 | 3057 | $GLOBALS['egw_info']['flags']['css'] = preg_replace('|</?style[^>]*>|i', '', $additionalStyle); |
| 3063 | - $GLOBALS['egw_info']['flags']['nofooter']=true; |
|
| 3064 | - $GLOBALS['egw_info']['flags']['nonavbar']=true; |
|
| 3058 | + $GLOBALS['egw_info']['flags']['nofooter'] = true; |
|
| 3059 | + $GLOBALS['egw_info']['flags']['nonavbar'] = true; |
|
| 3065 | 3060 | // do NOT include any default CSS |
| 3066 | 3061 | Framework::includeCSS('mail', 'preview', true, true); |
| 3067 | 3062 | |
@@ -3072,35 +3067,35 @@ discard block |
||
| 3072 | 3067 | return $GLOBALS['egw']->framework->header(); |
| 3073 | 3068 | } |
| 3074 | 3069 | |
| 3075 | - function showBody(&$body, $print=true,$fullPageTags=true) |
|
| 3070 | + function showBody(&$body, $print = true, $fullPageTags = true) |
|
| 3076 | 3071 | { |
| 3077 | 3072 | $BeginBody = '<div class="mailDisplayBody"> |
| 3078 | 3073 | <table width="100%" style="table-layout:fixed"><tr><td class="td_display">'; |
| 3079 | 3074 | |
| 3080 | 3075 | $EndBody = '</td></tr></table></div>'; |
| 3081 | 3076 | if ($fullPageTags) $EndBody .= "</body></html>"; |
| 3082 | - if ($print) { |
|
| 3083 | - print $BeginBody. $body .$EndBody; |
|
| 3077 | + if ($print) { |
|
| 3078 | + print $BeginBody.$body.$EndBody; |
|
| 3084 | 3079 | } else { |
| 3085 | - return $BeginBody. $body .$EndBody; |
|
| 3080 | + return $BeginBody.$body.$EndBody; |
|
| 3086 | 3081 | } |
| 3087 | 3082 | } |
| 3088 | 3083 | |
| 3089 | - function &getdisplayableBody($_bodyParts,$modifyURI=true,$useTidy = true) |
|
| 3084 | + function &getdisplayableBody($_bodyParts, $modifyURI = true, $useTidy = true) |
|
| 3090 | 3085 | { |
| 3091 | - $bodyParts = $_bodyParts; |
|
| 3086 | + $bodyParts = $_bodyParts; |
|
| 3092 | 3087 | |
| 3093 | - $nonDisplayAbleCharacters = array('[\016]','[\017]', |
|
| 3094 | - '[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]', |
|
| 3095 | - '[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]'); |
|
| 3088 | + $nonDisplayAbleCharacters = array('[\016]', '[\017]', |
|
| 3089 | + '[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]', |
|
| 3090 | + '[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]'); |
|
| 3096 | 3091 | |
| 3097 | 3092 | $body = ''; |
| 3098 | 3093 | |
| 3099 | 3094 | //error_log(__METHOD__.array2string($bodyParts)); //exit; |
| 3100 | 3095 | if (empty($bodyParts)) return ""; |
| 3101 | - foreach((array)$bodyParts as $singleBodyPart) { |
|
| 3096 | + foreach ((array)$bodyParts as $singleBodyPart) { |
|
| 3102 | 3097 | if (!isset($singleBodyPart['body'])) { |
| 3103 | - $singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart,$modifyURI,$useTidy); |
|
| 3098 | + $singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart, $modifyURI, $useTidy); |
|
| 3104 | 3099 | $body .= $singleBodyPart['body']; |
| 3105 | 3100 | continue; |
| 3106 | 3101 | } |
@@ -3110,7 +3105,7 @@ discard block |
||
| 3110 | 3105 | $body .= ''; |
| 3111 | 3106 | continue; |
| 3112 | 3107 | } |
| 3113 | - if(!empty($body)) { |
|
| 3108 | + if (!empty($body)) { |
|
| 3114 | 3109 | $body .= '<hr style="border:dotted 1px silver;">'; |
| 3115 | 3110 | } |
| 3116 | 3111 | //error_log($singleBodyPart['body']); |
@@ -3135,28 +3130,28 @@ discard block |
||
| 3135 | 3130 | '(R)', |
| 3136 | 3131 | ); |
| 3137 | 3132 | |
| 3138 | - if(($singleBodyPart['mimeType'] == 'text/html' || $singleBodyPart['mimeType'] == 'text/plain') && |
|
| 3133 | + if (($singleBodyPart['mimeType'] == 'text/html' || $singleBodyPart['mimeType'] == 'text/plain') && |
|
| 3139 | 3134 | strtoupper($singleBodyPart['charSet']) != 'UTF-8') |
| 3140 | 3135 | { |
| 3141 | - $singleBodyPart['body'] = preg_replace($sar,$rar,$singleBodyPart['body']); |
|
| 3136 | + $singleBodyPart['body'] = preg_replace($sar, $rar, $singleBodyPart['body']); |
|
| 3142 | 3137 | } |
| 3143 | 3138 | //error_log(__METHOD__.__LINE__.'reports:'.$singleBodyPart['charSet']); |
| 3144 | - if ($singleBodyPart['charSet']=='us-ascii') |
|
| 3139 | + if ($singleBodyPart['charSet'] == 'us-ascii') |
|
| 3145 | 3140 | { |
| 3146 | - $orgCharSet=$singleBodyPart['charSet']; |
|
| 3141 | + $orgCharSet = $singleBodyPart['charSet']; |
|
| 3147 | 3142 | $singleBodyPart['charSet'] = Api\Translation::detect_encoding($singleBodyPart['body']); |
| 3148 | 3143 | error_log(__METHOD__.__LINE__.'reports:'.$orgCharSet.' but seems to be:'.$singleBodyPart['charSet']); |
| 3149 | 3144 | } |
| 3150 | - $singleBodyPart['body'] = Api\Translation::convert_jsonsafe($singleBodyPart['body'],$singleBodyPart['charSet']); |
|
| 3145 | + $singleBodyPart['body'] = Api\Translation::convert_jsonsafe($singleBodyPart['body'], $singleBodyPart['charSet']); |
|
| 3151 | 3146 | //error_log(__METHOD__.__LINE__.array2string($singleBodyPart)); |
| 3152 | - if($singleBodyPart['mimeType'] == 'text/plain') |
|
| 3147 | + if ($singleBodyPart['mimeType'] == 'text/plain') |
|
| 3153 | 3148 | { |
| 3154 | - $newBody = @htmlentities($singleBodyPart['body'],ENT_QUOTES, strtoupper(Mail::$displayCharset)); |
|
| 3149 | + $newBody = @htmlentities($singleBodyPart['body'], ENT_QUOTES, strtoupper(Mail::$displayCharset)); |
|
| 3155 | 3150 | //error_log(__METHOD__.__LINE__.'..'.$newBody); |
| 3156 | 3151 | // if empty and charset is utf8 try sanitizing the string in question |
| 3157 | - if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(Mail::$displayCharset)); |
|
| 3152 | + if (empty($newBody) && strtolower($singleBodyPart['charSet']) == 'utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']), ENT_QUOTES, strtoupper(Mail::$displayCharset)); |
|
| 3158 | 3153 | // if the conversion to htmlentities fails somehow, try without specifying the charset, which defaults to iso- |
| 3159 | - if (empty($newBody)) $newBody = htmlentities($singleBodyPart['body'],ENT_QUOTES); |
|
| 3154 | + if (empty($newBody)) $newBody = htmlentities($singleBodyPart['body'], ENT_QUOTES); |
|
| 3160 | 3155 | |
| 3161 | 3156 | // search http[s] links and make them as links available again |
| 3162 | 3157 | // to understand what's going on here, have a look at |
@@ -3184,20 +3179,20 @@ discard block |
||
| 3184 | 3179 | // since we do not display the message as HTML anymore we may want to insert good linebreaking (for visibility). |
| 3185 | 3180 | //error_log(__METHOD__.__LINE__.'..'.$newBody); |
| 3186 | 3181 | // dont break lines that start with > (> as the text was processed with htmlentities before) |
| 3187 | - $newBody = "<pre>".Mail::wordwrap($newBody,90,"\n",'>')."</pre>"; |
|
| 3182 | + $newBody = "<pre>".Mail::wordwrap($newBody, 90, "\n", '>')."</pre>"; |
|
| 3188 | 3183 | } |
| 3189 | 3184 | else |
| 3190 | 3185 | { |
| 3191 | - $alreadyHtmlLawed=false; |
|
| 3192 | - $newBody = $singleBodyPart['body']; |
|
| 3186 | + $alreadyHtmlLawed = false; |
|
| 3187 | + $newBody = $singleBodyPart['body']; |
|
| 3193 | 3188 | //TODO:$newBody = $this->highlightQuotes($newBody); |
| 3194 | 3189 | #error_log(print_r($newBody,true)); |
| 3195 | 3190 | if ($useTidy && extension_loaded('tidy')) |
| 3196 | 3191 | { |
| 3197 | 3192 | $tidy = new tidy(); |
| 3198 | - $cleaned = $tidy->repairString($newBody, Mail::$tidy_config,'utf8'); |
|
| 3193 | + $cleaned = $tidy->repairString($newBody, Mail::$tidy_config, 'utf8'); |
|
| 3199 | 3194 | // Found errors. Strip it all so there's some output |
| 3200 | - if($tidy->getStatus() == 2) |
|
| 3195 | + if ($tidy->getStatus() == 2) |
|
| 3201 | 3196 | { |
| 3202 | 3197 | error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$tidy->errorBuffer); |
| 3203 | 3198 | } |
@@ -3208,7 +3203,7 @@ discard block |
||
| 3208 | 3203 | if (!$preserveHTML) // ToDo KL: $preserveHTML is NOT initialised, so always if is dead code |
| 3209 | 3204 | { |
| 3210 | 3205 | // filter only the 'body', as we only want that part, if we throw away the Api\Html |
| 3211 | - preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array()); |
|
| 3206 | + preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array()); |
|
| 3212 | 3207 | if ($matches[2]) |
| 3213 | 3208 | { |
| 3214 | 3209 | $hasOther = true; |
@@ -3219,7 +3214,7 @@ discard block |
||
| 3219 | 3214 | else |
| 3220 | 3215 | { |
| 3221 | 3216 | // htmLawed filter only the 'body' |
| 3222 | - preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array()); |
|
| 3217 | + preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array()); |
|
| 3223 | 3218 | if ($matches[2]) |
| 3224 | 3219 | { |
| 3225 | 3220 | $hasOther = true; |
@@ -3228,10 +3223,10 @@ discard block |
||
| 3228 | 3223 | $htmLawed = new Api\Html\HtmLawed(); |
| 3229 | 3224 | // the next line should not be needed, but produces better results on HTML 2 Text conversion, |
| 3230 | 3225 | // as we switched off HTMLaweds tidy functionality |
| 3231 | - $newBody = str_replace(array('&amp;','<DIV><BR></DIV>',"<DIV> </DIV>",'<div> </div>'),array('&','<BR>','<BR>','<BR>'),$newBody); |
|
| 3232 | - $newBody = $htmLawed->run($newBody,Mail::$htmLawed_config); |
|
| 3233 | - if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3]; |
|
| 3234 | - $alreadyHtmlLawed=true; |
|
| 3226 | + $newBody = str_replace(array('&amp;', '<DIV><BR></DIV>', "<DIV> </DIV>", '<div> </div>'), array('&', '<BR>', '<BR>', '<BR>'), $newBody); |
|
| 3227 | + $newBody = $htmLawed->run($newBody, Mail::$htmLawed_config); |
|
| 3228 | + if ($hasOther && $preserveHTML) $newBody = $matches[1].$newBody.$matches[3]; |
|
| 3229 | + $alreadyHtmlLawed = true; |
|
| 3235 | 3230 | } |
| 3236 | 3231 | // do the cleanup, set for the use of purifier |
| 3237 | 3232 | //$newBodyBuff = $newBody; |
@@ -3253,8 +3248,8 @@ discard block |
||
| 3253 | 3248 | } |
| 3254 | 3249 | */ |
| 3255 | 3250 | // removes stuff between http and ?http |
| 3256 | - $Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))'; // only http:// gets removed, other protocolls are shown |
|
| 3257 | - $newBody = preg_replace('~'.$Protocol.'[^>]*\?'.$Protocol.'~sim','$1',$newBody); // removes stuff between http:// and ?http:// |
|
| 3251 | + $Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))'; // only http:// gets removed, other protocolls are shown |
|
| 3252 | + $newBody = preg_replace('~'.$Protocol.'[^>]*\?'.$Protocol.'~sim', '$1', $newBody); // removes stuff between http:// and ?http:// |
|
| 3258 | 3253 | // TRANSFORM MAILTO LINKS TO EMAILADDRESS ONLY, WILL BE SUBSTITUTED BY parseEmail TO CLICKABLE LINK |
| 3259 | 3254 | $newBody = preg_replace('/(?<!"|href=|href\s=\s|href=\s|href\s=)'.'mailto:([a-z0-9._-]+)@([a-z0-9_-]+)\.([a-z0-9._-]+)/i', |
| 3260 | 3255 | "\\1@\\2.\\3", |
@@ -3267,7 +3262,7 @@ discard block |
||
| 3267 | 3262 | // create links for inline images |
| 3268 | 3263 | if ($modifyURI) |
| 3269 | 3264 | { |
| 3270 | - $newBody = self::resolve_inline_images ($newBody, $this->mailbox, $this->uid, $this->partID); |
|
| 3265 | + $newBody = self::resolve_inline_images($newBody, $this->mailbox, $this->uid, $this->partID); |
|
| 3271 | 3266 | } |
| 3272 | 3267 | // email addresses / mailto links get now activated on client-side |
| 3273 | 3268 | } |
@@ -3279,7 +3274,7 @@ discard block |
||
| 3279 | 3274 | $body = preg_replace("/(\\\\\\\\)([\w,\\\\,-]+)/i", |
| 3280 | 3275 | "<a href=\"file:$1$2\" target=\"_blank\"><font color=\"blue\">$1$2</font></a>", $body); |
| 3281 | 3276 | |
| 3282 | - $body = preg_replace($nonDisplayAbleCharacters,'',$body); |
|
| 3277 | + $body = preg_replace($nonDisplayAbleCharacters, '', $body); |
|
| 3283 | 3278 | |
| 3284 | 3279 | return $body; |
| 3285 | 3280 | } |
@@ -3294,7 +3289,7 @@ discard block |
||
| 3294 | 3289 | * @param string $_messageType = 'html', message type is either html or plain |
| 3295 | 3290 | * @return string message body including all CID images replaced |
| 3296 | 3291 | */ |
| 3297 | - public static function resolve_inline_images ($_body,$_mailbox, $_uid, $_partID, $_messageType = 'html') |
|
| 3292 | + public static function resolve_inline_images($_body, $_mailbox, $_uid, $_partID, $_messageType = 'html') |
|
| 3298 | 3293 | { |
| 3299 | 3294 | if ($_messageType === 'plain') |
| 3300 | 3295 | { |
@@ -3302,7 +3297,7 @@ discard block |
||
| 3302 | 3297 | } |
| 3303 | 3298 | else |
| 3304 | 3299 | { |
| 3305 | - foreach(array('src','url','background') as $type) |
|
| 3300 | + foreach (array('src', 'url', 'background') as $type) |
|
| 3306 | 3301 | { |
| 3307 | 3302 | $_body = self::resolve_inline_image_byType($_body, $_mailbox, $_uid, $_partID, $type); |
| 3308 | 3303 | } |
@@ -3321,7 +3316,7 @@ discard block |
||
| 3321 | 3316 | * - types: {plain|src|url|background} |
| 3322 | 3317 | * @return string returns body content including all CID replacements |
| 3323 | 3318 | */ |
| 3324 | - public static function resolve_inline_image_byType ($_body,$_mailbox, $_uid, $_partID, $_type ='src') |
|
| 3319 | + public static function resolve_inline_image_byType($_body, $_mailbox, $_uid, $_partID, $_type = 'src') |
|
| 3325 | 3320 | { |
| 3326 | 3321 | /** |
| 3327 | 3322 | * Callback for preg_replace_callback function |
@@ -3333,7 +3328,7 @@ discard block |
||
| 3333 | 3328 | * @param string $_type |
| 3334 | 3329 | * @return string|boolean returns the replace |
| 3335 | 3330 | */ |
| 3336 | - $replace_callback = function ($matches) use ($_mailbox,$_uid, $_partID, $_type) |
|
| 3331 | + $replace_callback = function($matches) use ($_mailbox, $_uid, $_partID, $_type) |
|
| 3337 | 3332 | { |
| 3338 | 3333 | if (!$_type) return false; |
| 3339 | 3334 | $CID = ''; |
@@ -3355,11 +3350,11 @@ discard block |
||
| 3355 | 3350 | break; |
| 3356 | 3351 | } |
| 3357 | 3352 | |
| 3358 | - static $cache = array(); // some caching, if mails containing the same image multiple times |
|
| 3353 | + static $cache = array(); // some caching, if mails containing the same image multiple times |
|
| 3359 | 3354 | |
| 3360 | 3355 | if (is_array($matches) && $CID) |
| 3361 | 3356 | { |
| 3362 | - $linkData = array ( |
|
| 3357 | + $linkData = array( |
|
| 3363 | 3358 | 'menuaction' => 'mail.mail_ui.displayImage', |
| 3364 | 3359 | 'uid' => $_uid, |
| 3365 | 3360 | 'mailbox' => base64_encode($_mailbox), |
@@ -3372,7 +3367,7 @@ discard block |
||
| 3372 | 3367 | { |
| 3373 | 3368 | if (!isset($cache[$imageURL])) |
| 3374 | 3369 | { |
| 3375 | - if ($_type !="background") |
|
| 3370 | + if ($_type != "background") |
|
| 3376 | 3371 | { |
| 3377 | 3372 | $bo = Mail::getInstance(false, mail_ui::$icServerID); |
| 3378 | 3373 | $attachment = $bo->getAttachmentByCID($_uid, $CID, $_partID); |
@@ -3413,16 +3408,16 @@ discard block |
||
| 3413 | 3408 | }; |
| 3414 | 3409 | |
| 3415 | 3410 | // return new body content base on chosen type |
| 3416 | - switch($_type) |
|
| 3411 | + switch ($_type) |
|
| 3417 | 3412 | { |
| 3418 | 3413 | case"plain": |
| 3419 | - return preg_replace_callback("/\[cid:(.*)\]/iU",$replace_callback,$_body); |
|
| 3414 | + return preg_replace_callback("/\[cid:(.*)\]/iU", $replace_callback, $_body); |
|
| 3420 | 3415 | case "src": |
| 3421 | - return preg_replace_callback("/src=(\"|\')cid:(.*)(\"|\')/iU",$replace_callback,$_body); |
|
| 3416 | + return preg_replace_callback("/src=(\"|\')cid:(.*)(\"|\')/iU", $replace_callback, $_body); |
|
| 3422 | 3417 | case "url": |
| 3423 | - return preg_replace_callback("/url\(cid:(.*)\);/iU",$replace_callback,$_body); |
|
| 3418 | + return preg_replace_callback("/url\(cid:(.*)\);/iU", $replace_callback, $_body); |
|
| 3424 | 3419 | case "background": |
| 3425 | - return preg_replace_callback("/background=(\"|\')cid:(.*)(\"|\')/iU",$replace_callback,$_body); |
|
| 3420 | + return preg_replace_callback("/background=(\"|\')cid:(.*)(\"|\')/iU", $replace_callback, $_body); |
|
| 3426 | 3421 | } |
| 3427 | 3422 | } |
| 3428 | 3423 | |
@@ -3430,7 +3425,7 @@ discard block |
||
| 3430 | 3425 | * importMessage |
| 3431 | 3426 | * @param array $content = null an array of content |
| 3432 | 3427 | */ |
| 3433 | - function importMessage($content=null) |
|
| 3428 | + function importMessage($content = null) |
|
| 3434 | 3429 | { |
| 3435 | 3430 | //error_log(__METHOD__.__LINE__.$this->mail_bo->getDraftFolder()); |
| 3436 | 3431 | |
@@ -3452,7 +3447,7 @@ discard block |
||
| 3452 | 3447 | } |
| 3453 | 3448 | $destination = $content['FOLDER'][0]; |
| 3454 | 3449 | |
| 3455 | - if (stripos($destination,self::$delimiter)!==false) list($icServerID,$destination) = explode(self::$delimiter,$destination,2); |
|
| 3450 | + if (stripos($destination, self::$delimiter) !== false) list($icServerID, $destination) = explode(self::$delimiter, $destination, 2); |
|
| 3456 | 3451 | if ($icServerID && $icServerID != $this->mail_bo->profileID) |
| 3457 | 3452 | { |
| 3458 | 3453 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
@@ -3463,36 +3458,35 @@ discard block |
||
| 3463 | 3458 | $importFailed = false; |
| 3464 | 3459 | try |
| 3465 | 3460 | { |
| 3466 | - $messageUid = $this->importMessageToFolder($file,$destination,$importID); |
|
| 3467 | - $linkData = array |
|
| 3468 | - ( |
|
| 3461 | + $messageUid = $this->importMessageToFolder($file, $destination, $importID); |
|
| 3462 | + $linkData = array( |
|
| 3469 | 3463 | 'id' => $this->createRowID($destination, $messageUid, true), |
| 3470 | 3464 | ); |
| 3471 | 3465 | } |
| 3472 | 3466 | catch (Api\Exception\WrongUserinput $e) |
| 3473 | 3467 | { |
| 3474 | - $importFailed=true; |
|
| 3475 | - $content['msg'] = $e->getMessage(); |
|
| 3468 | + $importFailed = true; |
|
| 3469 | + $content['msg'] = $e->getMessage(); |
|
| 3476 | 3470 | } |
| 3477 | 3471 | if (!$importFailed) |
| 3478 | 3472 | { |
| 3479 | 3473 | list($width, $height) = explode('x', Link::get_registry('mail', 'add_popup')); |
| 3480 | 3474 | if ($width > 0 && $height > 0) Api\Json\Response::get()->call('resizeTo', $width, $height); |
| 3481 | - ExecMethod2('mail.mail_ui.displayMessage',$linkData); |
|
| 3475 | + ExecMethod2('mail.mail_ui.displayMessage', $linkData); |
|
| 3482 | 3476 | return; |
| 3483 | 3477 | } |
| 3484 | 3478 | } |
| 3485 | 3479 | if (!is_array($content)) $content = array(); |
| 3486 | - if (empty($content['FOLDER'])) $content['FOLDER']=(array)$this->mail_bo->getDraftFolder(); |
|
| 3480 | + if (empty($content['FOLDER'])) $content['FOLDER'] = (array)$this->mail_bo->getDraftFolder(); |
|
| 3487 | 3481 | if (!empty($content['FOLDER'])) |
| 3488 | 3482 | { |
| 3489 | 3483 | $compose = new mail_compose(); |
| 3490 | - $sel_options['FOLDER'] = $compose->ajax_searchFolder(0,true); |
|
| 3484 | + $sel_options['FOLDER'] = $compose->ajax_searchFolder(0, true); |
|
| 3491 | 3485 | } |
| 3492 | 3486 | |
| 3493 | 3487 | $etpl = new Etemplate('mail.importMessage'); |
| 3494 | - $etpl->setElementAttribute('uploadForImport','onFinish','app.mail.uploadForImport'); |
|
| 3495 | - $etpl->exec('mail.mail_ui.importMessage',$content,$sel_options,array(),array(),2); |
|
| 3488 | + $etpl->setElementAttribute('uploadForImport', 'onFinish', 'app.mail.uploadForImport'); |
|
| 3489 | + $etpl->exec('mail.mail_ui.importMessage', $content, $sel_options, array(), array(), 2); |
|
| 3496 | 3490 | } |
| 3497 | 3491 | |
| 3498 | 3492 | /** |
@@ -3504,7 +3498,7 @@ discard block |
||
| 3504 | 3498 | * @param string $importID ID for the imported message, used by attachments to identify them unambiguously |
| 3505 | 3499 | * @return mixed $messageUID or exception |
| 3506 | 3500 | */ |
| 3507 | - function importMessageToFolder($_formData,&$_folder,$importID='') |
|
| 3501 | + function importMessageToFolder($_formData, &$_folder, $importID = '') |
|
| 3508 | 3502 | { |
| 3509 | 3503 | $importfailed = false; |
| 3510 | 3504 | //error_log(__METHOD__.__LINE__.array2string($_formData)); |
@@ -3512,7 +3506,7 @@ discard block |
||
| 3512 | 3506 | // check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.) |
| 3513 | 3507 | try |
| 3514 | 3508 | { |
| 3515 | - $tmpFileName = Mail::checkFileBasics($_formData,$importID); |
|
| 3509 | + $tmpFileName = Mail::checkFileBasics($_formData, $importID); |
|
| 3516 | 3510 | } |
| 3517 | 3511 | catch (Api\Exception\WrongUserinput $e) |
| 3518 | 3512 | { |
@@ -3536,29 +3530,29 @@ discard block |
||
| 3536 | 3530 | if (empty($_folder)) |
| 3537 | 3531 | { |
| 3538 | 3532 | $importfailed = true; |
| 3539 | - $alert_msg .= lang("Import of message %1 failed. Destination Folder not set.",$_formData['name']); |
|
| 3533 | + $alert_msg .= lang("Import of message %1 failed. Destination Folder not set.", $_formData['name']); |
|
| 3540 | 3534 | } |
| 3541 | 3535 | $delimiter = $this->mail_bo->getHierarchyDelimiter(); |
| 3542 | - if($_folder=='INBOX'.$delimiter) $_folder='INBOX'; |
|
| 3536 | + if ($_folder == 'INBOX'.$delimiter) $_folder = 'INBOX'; |
|
| 3543 | 3537 | if ($importfailed === false) |
| 3544 | 3538 | { |
| 3545 | - if ($this->mail_bo->folderExists($_folder,true)) { |
|
| 3539 | + if ($this->mail_bo->folderExists($_folder, true)) { |
|
| 3546 | 3540 | try |
| 3547 | 3541 | { |
| 3548 | 3542 | $messageUid = $this->mail_bo->appendMessage($_folder, |
| 3549 | 3543 | $mailObject->getRaw(), |
| 3550 | - null,'\\Seen'); |
|
| 3544 | + null, '\\Seen'); |
|
| 3551 | 3545 | } |
| 3552 | 3546 | catch (Api\Exception\WrongUserinput $e) |
| 3553 | 3547 | { |
| 3554 | 3548 | $importfailed = true; |
| 3555 | - $alert_msg .= lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$_formData['name'],$_folder,$e->getMessage()); |
|
| 3549 | + $alert_msg .= lang("Import of message %1 failed. Could not save message to folder %2 due to: %3", $_formData['name'], $_folder, $e->getMessage()); |
|
| 3556 | 3550 | } |
| 3557 | 3551 | } |
| 3558 | 3552 | else |
| 3559 | 3553 | { |
| 3560 | 3554 | $importfailed = true; |
| 3561 | - $alert_msg .= lang("Import of message %1 failed. Destination Folder %2 does not exist.",$_formData['name'],$_folder); |
|
| 3555 | + $alert_msg .= lang("Import of message %1 failed. Destination Folder %2 does not exist.", $_formData['name'], $_folder); |
|
| 3562 | 3556 | } |
| 3563 | 3557 | } |
| 3564 | 3558 | } |
@@ -3584,9 +3578,9 @@ discard block |
||
| 3584 | 3578 | * $formData['size'] = 2136; |
| 3585 | 3579 | * @return void |
| 3586 | 3580 | */ |
| 3587 | - function importMessageFromVFS2DraftAndEdit($formData='') |
|
| 3581 | + function importMessageFromVFS2DraftAndEdit($formData = '') |
|
| 3588 | 3582 | { |
| 3589 | - $this->importMessageFromVFS2DraftAndDisplay($formData,'edit'); |
|
| 3583 | + $this->importMessageFromVFS2DraftAndDisplay($formData, 'edit'); |
|
| 3590 | 3584 | } |
| 3591 | 3585 | |
| 3592 | 3586 | /** |
@@ -3601,7 +3595,7 @@ discard block |
||
| 3601 | 3595 | * @param string $mode mode to open ImportedMessage display and edit are supported |
| 3602 | 3596 | * @return void |
| 3603 | 3597 | */ |
| 3604 | - function importMessageFromVFS2DraftAndDisplay($formData='',$mode='display') |
|
| 3598 | + function importMessageFromVFS2DraftAndDisplay($formData = '', $mode = 'display') |
|
| 3605 | 3599 | { |
| 3606 | 3600 | if (empty($formData)) if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData']; |
| 3607 | 3601 | //error_log(__METHOD__.__LINE__.':'.array2string($formData).' Mode:'.$mode.'->'.function_backtrace()); |
@@ -3614,43 +3608,42 @@ discard block |
||
| 3614 | 3608 | $formData['file'] = 'egw-data://'.$formData['data']; |
| 3615 | 3609 | } |
| 3616 | 3610 | // name should be set to meet the requirements of checkFileBasics |
| 3617 | - if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['name'])) |
|
| 3611 | + if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && empty($formData['name'])) |
|
| 3618 | 3612 | { |
| 3619 | - $buff = explode('/',$formData['file']); |
|
| 3613 | + $buff = explode('/', $formData['file']); |
|
| 3620 | 3614 | if (is_array($buff)) $formData['name'] = array_pop($buff); // take the last part as name |
| 3621 | 3615 | } |
| 3622 | 3616 | // type should be set to meet the requirements of checkFileBasics |
| 3623 | - if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['type'])) |
|
| 3617 | + if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && empty($formData['type'])) |
|
| 3624 | 3618 | { |
| 3625 | - $buff = explode('.',$formData['file']); |
|
| 3619 | + $buff = explode('.', $formData['file']); |
|
| 3626 | 3620 | $suffix = ''; |
| 3627 | 3621 | if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
| 3628 | 3622 | if (!empty($suffix)) $formData['type'] = Api\MimeMagic::ext2mime($suffix); |
| 3629 | 3623 | } |
| 3630 | 3624 | // size should be set to meet the requirements of checkFileBasics |
| 3631 | - if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && !isset($formData['size'])) |
|
| 3625 | + if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && !isset($formData['size'])) |
|
| 3632 | 3626 | { |
| 3633 | 3627 | $formData['size'] = strlen($formData['file']); // set some size, to meet requirements of checkFileBasics |
| 3634 | 3628 | } |
| 3635 | 3629 | try |
| 3636 | 3630 | { |
| 3637 | - $messageUid = $this->importMessageToFolder($formData,$draftFolder,$importID); |
|
| 3638 | - $linkData = array |
|
| 3639 | - ( |
|
| 3640 | - 'menuaction' => ($mode=='display'?'mail.mail_ui.displayMessage':'mail.mail_compose.composeFromDraft'), |
|
| 3641 | - 'id' => $this->createRowID($draftFolder,$messageUid,true), |
|
| 3631 | + $messageUid = $this->importMessageToFolder($formData, $draftFolder, $importID); |
|
| 3632 | + $linkData = array( |
|
| 3633 | + 'menuaction' => ($mode == 'display' ? 'mail.mail_ui.displayMessage' : 'mail.mail_compose.composeFromDraft'), |
|
| 3634 | + 'id' => $this->createRowID($draftFolder, $messageUid, true), |
|
| 3642 | 3635 | 'deleteDraftOnClose' => 1, |
| 3643 | 3636 | ); |
| 3644 | - if ($mode!='display') |
|
| 3637 | + if ($mode != 'display') |
|
| 3645 | 3638 | { |
| 3646 | 3639 | unset($linkData['deleteDraftOnClose']); |
| 3647 | - $linkData['method'] ='importMessageToMergeAndSend'; |
|
| 3640 | + $linkData['method'] = 'importMessageToMergeAndSend'; |
|
| 3648 | 3641 | } |
| 3649 | 3642 | else |
| 3650 | 3643 | { |
| 3651 | - $linkData['mode']=$mode; |
|
| 3644 | + $linkData['mode'] = $mode; |
|
| 3652 | 3645 | } |
| 3653 | - Egw::redirect_link('/index.php',$linkData); |
|
| 3646 | + Egw::redirect_link('/index.php', $linkData); |
|
| 3654 | 3647 | } |
| 3655 | 3648 | catch (Api\Exception\WrongUserinput $e) |
| 3656 | 3649 | { |
@@ -3665,13 +3658,13 @@ discard block |
||
| 3665 | 3658 | * |
| 3666 | 3659 | * @return xajax response |
| 3667 | 3660 | */ |
| 3668 | - function loadEmailBody($_messageID=null,$_partID=null,$_htmloptions=null) |
|
| 3661 | + function loadEmailBody($_messageID = null, $_partID = null, $_htmloptions = null) |
|
| 3669 | 3662 | { |
| 3670 | 3663 | //error_log(__METHOD__.__LINE__.array2string($_GET)); |
| 3671 | 3664 | if (!$_messageID && !empty($_GET['_messageID'])) $_messageID = $_GET['_messageID']; |
| 3672 | 3665 | if (!$_partID && !empty($_GET['_partID'])) $_partID = $_GET['_partID']; |
| 3673 | 3666 | if (!$_htmloptions && !empty($_GET['_htmloptions'])) $_htmloptions = $_GET['_htmloptions']; |
| 3674 | - if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions"); |
|
| 3667 | + if (Mail::$debug) error_log(__METHOD__."->".print_r($_messageID, true).",$_partID,$_htmloptions"); |
|
| 3675 | 3668 | if (empty($_messageID)) return ""; |
| 3676 | 3669 | $uidA = self::splitRowID($_messageID); |
| 3677 | 3670 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
@@ -3685,7 +3678,7 @@ discard block |
||
| 3685 | 3678 | $this->changeProfile($icServerID); |
| 3686 | 3679 | } |
| 3687 | 3680 | |
| 3688 | - $bodyResponse = $this->get_load_email_data($messageID,$_partID,$folder,$_htmloptions); |
|
| 3681 | + $bodyResponse = $this->get_load_email_data($messageID, $_partID, $folder, $_htmloptions); |
|
| 3689 | 3682 | Api\Session::cache_control(true); |
| 3690 | 3683 | //error_log(array2string($bodyResponse)); |
| 3691 | 3684 | echo $bodyResponse; |
@@ -3708,7 +3701,7 @@ discard block |
||
| 3708 | 3701 | $oA = array(); |
| 3709 | 3702 | foreach ($_folder as $_folderName) |
| 3710 | 3703 | { |
| 3711 | - list($profileID,$folderName) = explode(self::$delimiter,$_folderName,2); |
|
| 3704 | + list($profileID, $folderName) = explode(self::$delimiter, $_folderName, 2); |
|
| 3712 | 3705 | if (is_numeric($profileID)) |
| 3713 | 3706 | { |
| 3714 | 3707 | if ($profileID != $this->mail_bo->profileID) continue; // only current connection |
@@ -3716,20 +3709,20 @@ discard block |
||
| 3716 | 3709 | { |
| 3717 | 3710 | try |
| 3718 | 3711 | { |
| 3719 | - $fS = $this->mail_bo->getFolderStatus($folderName,false,false,false); |
|
| 3712 | + $fS = $this->mail_bo->getFolderStatus($folderName, false, false, false); |
|
| 3720 | 3713 | } |
| 3721 | 3714 | catch (Exception $e) |
| 3722 | 3715 | { |
| 3723 | - if (Mail::$debug) error_log(__METHOD__,' ()'.$e->getMessage ()); |
|
| 3716 | + if (Mail::$debug) error_log(__METHOD__, ' ()'.$e->getMessage()); |
|
| 3724 | 3717 | continue; |
| 3725 | 3718 | } |
| 3726 | - if (in_array($fS['shortDisplayName'],Mail::$autoFolders)) $fS['shortDisplayName']=lang($fS['shortDisplayName']); |
|
| 3719 | + if (in_array($fS['shortDisplayName'], Mail::$autoFolders)) $fS['shortDisplayName'] = lang($fS['shortDisplayName']); |
|
| 3727 | 3720 | //error_log(__METHOD__.__LINE__.array2string($fS)); |
| 3728 | 3721 | if ($fS['unseen']) |
| 3729 | 3722 | { |
| 3730 | 3723 | $oA[$_folderName] = $fS['shortDisplayName'].' ('.$fS['unseen'].')'; |
| 3731 | 3724 | } |
| 3732 | - if ($fS['unseen']==0 && $fS['shortDisplayName']) |
|
| 3725 | + if ($fS['unseen'] == 0 && $fS['shortDisplayName']) |
|
| 3733 | 3726 | { |
| 3734 | 3727 | $oA[$_folderName] = $fS['shortDisplayName']; |
| 3735 | 3728 | } |
@@ -3740,7 +3733,7 @@ discard block |
||
| 3740 | 3733 | if ($oA) |
| 3741 | 3734 | { |
| 3742 | 3735 | $response = Api\Json\Response::get(); |
| 3743 | - $response->call('app.mail.mail_setFolderStatus',$oA); |
|
| 3736 | + $response->call('app.mail.mail_setFolderStatus', $oA); |
|
| 3744 | 3737 | } |
| 3745 | 3738 | } |
| 3746 | 3739 | } |
@@ -3754,14 +3747,14 @@ discard block |
||
| 3754 | 3747 | function ajax_addFolder($_parentFolderName, $_newName) |
| 3755 | 3748 | { |
| 3756 | 3749 | //error_log(__METHOD__.__LINE__.' ParentFolderName:'.array2string($_parentFolderName).' NewName/Folder:'.array2string($_newName)); |
| 3757 | - $errorMessage=''; |
|
| 3750 | + $errorMessage = ''; |
|
| 3758 | 3751 | if ($_parentFolderName) |
| 3759 | 3752 | { |
| 3760 | 3753 | $created = false; |
| 3761 | 3754 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_parentFolderName); |
| 3762 | 3755 | //the conversion is handeled by horde, frontend interaction is all utf-8 |
| 3763 | 3756 | $_newName = $this->mail_bo->decodeEntityFolderName($_newName); |
| 3764 | - list($profileID,$parentFolderName) = explode(self::$delimiter,$decodedFolderName,2); |
|
| 3757 | + list($profileID, $parentFolderName) = explode(self::$delimiter, $decodedFolderName, 2); |
|
| 3765 | 3758 | if (is_numeric($profileID)) |
| 3766 | 3759 | { |
| 3767 | 3760 | if ($profileID != $this->mail_bo->profileID) return; // only current connection |
@@ -3801,10 +3794,10 @@ discard block |
||
| 3801 | 3794 | |
| 3802 | 3795 | if (empty($del)) $del = $this->mail_bo->getHierarchyDelimiter(false); |
| 3803 | 3796 | */ |
| 3804 | - $nA = explode($del,$_newName); |
|
| 3797 | + $nA = explode($del, $_newName); |
|
| 3805 | 3798 | |
| 3806 | 3799 | //error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName"); |
| 3807 | - if (!!empty($parentFolderName)) $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName,false); |
|
| 3800 | + if (!!empty($parentFolderName)) $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName, false); |
|
| 3808 | 3801 | //error_log(__METHOD__.__LINE__.array2string($oldFolderInfo)); |
| 3809 | 3802 | |
| 3810 | 3803 | $this->mail_bo->reopen('INBOX'); |
@@ -3812,11 +3805,11 @@ discard block |
||
| 3812 | 3805 | // if newName has delimiter ($del) in it, we need to create the subtree |
| 3813 | 3806 | if (!empty($nA)) |
| 3814 | 3807 | { |
| 3815 | - $c=0; |
|
| 3816 | - foreach($nA as $sTName) |
|
| 3808 | + $c = 0; |
|
| 3809 | + foreach ($nA as $sTName) |
|
| 3817 | 3810 | { |
| 3818 | - $error=null; |
|
| 3819 | - if(($parentFolderName = $this->mail_bo->createFolder($parentFolderName, $sTName, $error))) |
|
| 3811 | + $error = null; |
|
| 3812 | + if (($parentFolderName = $this->mail_bo->createFolder($parentFolderName, $sTName, $error))) |
|
| 3820 | 3813 | { |
| 3821 | 3814 | $c++; |
| 3822 | 3815 | } |
@@ -3825,16 +3818,16 @@ discard block |
||
| 3825 | 3818 | $errorMessage .= $error; |
| 3826 | 3819 | } |
| 3827 | 3820 | } |
| 3828 | - if ($c==count($nA)) $created=true; |
|
| 3821 | + if ($c == count($nA)) $created = true; |
|
| 3829 | 3822 | } |
| 3830 | 3823 | if (!empty($parentName)) $this->mail_bo->reopen($parentName); |
| 3831 | 3824 | } |
| 3832 | 3825 | //error_log(__METHOD__.__LINE__.array2string($oA)); |
| 3833 | - if ($created===true) |
|
| 3826 | + if ($created === true) |
|
| 3834 | 3827 | { |
| 3835 | 3828 | $this->mail_bo->resetFolderObjectCache($profileID); |
| 3836 | 3829 | $response = Api\Json\Response::get(); |
| 3837 | - if ( $oldFolderInfo['shortDisplayName']) |
|
| 3830 | + if ($oldFolderInfo['shortDisplayName']) |
|
| 3838 | 3831 | { |
| 3839 | 3832 | $nodeInfo = array($_parentFolderName=>$oldFolderInfo['shortDisplayName']); |
| 3840 | 3833 | } |
@@ -3842,14 +3835,14 @@ discard block |
||
| 3842 | 3835 | { |
| 3843 | 3836 | $nodeInfo = array($profileID=>lang('INBOX')); |
| 3844 | 3837 | } |
| 3845 | - $response->call('app.mail.mail_reloadNode',$nodeInfo); |
|
| 3838 | + $response->call('app.mail.mail_reloadNode', $nodeInfo); |
|
| 3846 | 3839 | } |
| 3847 | 3840 | else |
| 3848 | 3841 | { |
| 3849 | 3842 | if ($errorMessage) |
| 3850 | 3843 | { |
| 3851 | 3844 | $response = Api\Json\Response::get(); |
| 3852 | - $response->call('egw.message',$errorMessage); |
|
| 3845 | + $response->call('egw.message', $errorMessage); |
|
| 3853 | 3846 | } |
| 3854 | 3847 | } |
| 3855 | 3848 | } |
@@ -3871,22 +3864,22 @@ discard block |
||
| 3871 | 3864 | $_newName = $this->mail_bo->decodeEntityFolderName($_newName); |
| 3872 | 3865 | $del = $this->mail_bo->getHierarchyDelimiter(false); |
| 3873 | 3866 | $oA = array(); |
| 3874 | - list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
|
| 3867 | + list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2); |
|
| 3875 | 3868 | $hasChildren = false; |
| 3876 | 3869 | if (is_numeric($profileID)) |
| 3877 | 3870 | { |
| 3878 | - if ($profileID != $this->mail_bo->profileID) $this->changeProfile ($profileID); |
|
| 3879 | - $pA = explode($del,$folderName); |
|
| 3871 | + if ($profileID != $this->mail_bo->profileID) $this->changeProfile($profileID); |
|
| 3872 | + $pA = explode($del, $folderName); |
|
| 3880 | 3873 | array_pop($pA); |
| 3881 | - $parentFolder = implode($del,$pA); |
|
| 3882 | - if (strtoupper($folderName)!= 'INBOX') |
|
| 3874 | + $parentFolder = implode($del, $pA); |
|
| 3875 | + if (strtoupper($folderName) != 'INBOX') |
|
| 3883 | 3876 | { |
| 3884 | 3877 | //error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName"); |
| 3885 | - $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false); |
|
| 3878 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false); |
|
| 3886 | 3879 | //error_log(__METHOD__.__LINE__.array2string($oldFolderInfo)); |
| 3887 | - if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false) |
|
| 3880 | + if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false) |
|
| 3888 | 3881 | { |
| 3889 | - $hasChildren=true; // translates to: hasChildren -> dynamicLoading |
|
| 3882 | + $hasChildren = true; // translates to: hasChildren -> dynamicLoading |
|
| 3890 | 3883 | $delimiter = $this->mail_bo->getHierarchyDelimiter(); |
| 3891 | 3884 | $nameSpace = $this->mail_bo->_getNameSpaces(); |
| 3892 | 3885 | $prefix = $this->mail_bo->getFolderPrefixFromNamespace($nameSpace, $folderName); |
@@ -3903,7 +3896,7 @@ discard block |
||
| 3903 | 3896 | else |
| 3904 | 3897 | { |
| 3905 | 3898 | $rv = $this->mail_bo->icServer->subscribeMailbox($folder, false); |
| 3906 | - $fragments[$profileID.self::$delimiter.$folder] = substr($folder,strlen($folderName)); |
|
| 3899 | + $fragments[$profileID.self::$delimiter.$folder] = substr($folder, strlen($folderName)); |
|
| 3907 | 3900 | } |
| 3908 | 3901 | } |
| 3909 | 3902 | //error_log(__METHOD__.__LINE__.' Fetched Subfolders->'.array2string($fragments)); |
@@ -3913,7 +3906,7 @@ discard block |
||
| 3913 | 3906 | $success = false; |
| 3914 | 3907 | try |
| 3915 | 3908 | { |
| 3916 | - if(($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName))) |
|
| 3909 | + if (($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName))) |
|
| 3917 | 3910 | { |
| 3918 | 3911 | $this->mail_bo->resetFolderObjectCache($profileID); |
| 3919 | 3912 | //enforce the subscription to the newly named server, as it seems to fail for names with umlauts |
@@ -3924,11 +3917,11 @@ discard block |
||
| 3924 | 3917 | } |
| 3925 | 3918 | catch (Exception $e) |
| 3926 | 3919 | { |
| 3927 | - $newFolderName=$folderName; |
|
| 3920 | + $newFolderName = $folderName; |
|
| 3928 | 3921 | $msg = $e->getMessage(); |
| 3929 | 3922 | } |
| 3930 | 3923 | $this->mail_bo->reopen($newFolderName); |
| 3931 | - $fS = $this->mail_bo->getFolderStatus($newFolderName,false); |
|
| 3924 | + $fS = $this->mail_bo->getFolderStatus($newFolderName, false); |
|
| 3932 | 3925 | //error_log(__METHOD__.__LINE__.array2string($fS)); |
| 3933 | 3926 | if ($hasChildren) |
| 3934 | 3927 | { |
@@ -3959,12 +3952,12 @@ discard block |
||
| 3959 | 3952 | { |
| 3960 | 3953 | $oA[$_folderName]['desc'] = $fS['shortDisplayName']; |
| 3961 | 3954 | } |
| 3962 | - foreach($fragments as $oldFolderName => $fragment) |
|
| 3955 | + foreach ($fragments as $oldFolderName => $fragment) |
|
| 3963 | 3956 | { |
| 3964 | 3957 | //error_log(__METHOD__.__LINE__.':'.$oldFolderName.'->'.$profileID.self::$delimiter.$newFolderName.$fragment); |
| 3965 | 3958 | $oA[$oldFolderName]['id'] = $profileID.self::$delimiter.$newFolderName.$fragment; |
| 3966 | 3959 | $oA[$oldFolderName]['olddesc'] = '#skip-user-interaction-message#'; |
| 3967 | - $fS = $this->mail_bo->getFolderStatus($newFolderName.$fragment,false); |
|
| 3960 | + $fS = $this->mail_bo->getFolderStatus($newFolderName.$fragment, false); |
|
| 3968 | 3961 | if ($fS['unseen']) |
| 3969 | 3962 | { |
| 3970 | 3963 | $oA[$oldFolderName]['desc'] = $fS['shortDisplayName'].' ('.$fS['unseen'].')'; |
@@ -3977,20 +3970,20 @@ discard block |
||
| 3977 | 3970 | } |
| 3978 | 3971 | } |
| 3979 | 3972 | } |
| 3980 | - if ($folderName==$this->mail_bo->sessionData['mailbox']) |
|
| 3973 | + if ($folderName == $this->mail_bo->sessionData['mailbox']) |
|
| 3981 | 3974 | { |
| 3982 | - $this->mail_bo->sessionData['mailbox']=$newFolderName; |
|
| 3975 | + $this->mail_bo->sessionData['mailbox'] = $newFolderName; |
|
| 3983 | 3976 | $this->mail_bo->saveSessionData(); |
| 3984 | 3977 | } |
| 3985 | 3978 | //error_log(__METHOD__.__LINE__.array2string($oA)); |
| 3986 | 3979 | $response = Api\Json\Response::get(); |
| 3987 | 3980 | if ($oA && $success) |
| 3988 | 3981 | { |
| 3989 | - $response->call('app.mail.mail_setLeaf',$oA); |
|
| 3982 | + $response->call('app.mail.mail_setLeaf', $oA); |
|
| 3990 | 3983 | } |
| 3991 | 3984 | else |
| 3992 | 3985 | { |
| 3993 | - $response->call('egw.refresh',lang('failed to rename %1 ! Reason: %2',$oldFolderName,$msg),'mail'); |
|
| 3986 | + $response->call('egw.refresh', lang('failed to rename %1 ! Reason: %2', $oldFolderName, $msg), 'mail'); |
|
| 3994 | 3987 | } |
| 3995 | 3988 | } |
| 3996 | 3989 | } |
@@ -4002,12 +3995,12 @@ discard block |
||
| 4002 | 3995 | * @param boolean $_subscribedOnly = true |
| 4003 | 3996 | * @return void |
| 4004 | 3997 | */ |
| 4005 | - function ajax_reloadNode($_folderName,$_subscribedOnly=true) |
|
| 3998 | + function ajax_reloadNode($_folderName, $_subscribedOnly = true) |
|
| 4006 | 3999 | { |
| 4007 | 4000 | Api\Translation::add_app('mail'); |
| 4008 | 4001 | $oldPrefForSubscribedOnly = !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']; |
| 4009 | 4002 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 4010 | - list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
|
| 4003 | + list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2); |
|
| 4011 | 4004 | if ($profileID != $this->mail_bo->profileID) $this->changeProfile($profileID); |
| 4012 | 4005 | |
| 4013 | 4006 | // if pref and required mode dont match -> reset the folderObject cache to ensure |
@@ -4016,13 +4009,13 @@ discard block |
||
| 4016 | 4009 | |
| 4017 | 4010 | if (!empty($folderName)) |
| 4018 | 4011 | { |
| 4019 | - $parentFolder=(!empty($folderName)?$folderName:'INBOX'); |
|
| 4020 | - $folderInfo = $this->mail_bo->getFolderStatus($parentFolder,false,false,false); |
|
| 4012 | + $parentFolder = (!empty($folderName) ? $folderName : 'INBOX'); |
|
| 4013 | + $folderInfo = $this->mail_bo->getFolderStatus($parentFolder, false, false, false); |
|
| 4021 | 4014 | if ($folderInfo['unseen']) |
| 4022 | 4015 | { |
| 4023 | 4016 | $folderInfo['shortDisplayName'] = $folderInfo['shortDisplayName'].' ('.$folderInfo['unseen'].')'; |
| 4024 | 4017 | } |
| 4025 | - if ($folderInfo['unseen']==0 && $folderInfo['shortDisplayName']) |
|
| 4018 | + if ($folderInfo['unseen'] == 0 && $folderInfo['shortDisplayName']) |
|
| 4026 | 4019 | { |
| 4027 | 4020 | $folderInfo['shortDisplayName'] = $folderInfo['shortDisplayName']; |
| 4028 | 4021 | } |
@@ -4038,11 +4031,11 @@ discard block |
||
| 4038 | 4031 | } |
| 4039 | 4032 | // Send full info back in the response |
| 4040 | 4033 | $response = Api\Json\Response::get(); |
| 4041 | - foreach($refreshData as $folder => &$name) |
|
| 4034 | + foreach ($refreshData as $folder => &$name) |
|
| 4042 | 4035 | { |
| 4043 | - $name = $this->mail_tree->getTree($folder,$profileID,1,false, $_subscribedOnly,true); |
|
| 4036 | + $name = $this->mail_tree->getTree($folder, $profileID, 1, false, $_subscribedOnly, true); |
|
| 4044 | 4037 | } |
| 4045 | - $response->call('app.mail.mail_reloadNode',$refreshData); |
|
| 4038 | + $response->call('app.mail.mail_reloadNode', $refreshData); |
|
| 4046 | 4039 | |
| 4047 | 4040 | } |
| 4048 | 4041 | |
@@ -4058,7 +4051,7 @@ discard block |
||
| 4058 | 4051 | * @param type $_rowid row id from nm |
| 4059 | 4052 | * |
| 4060 | 4053 | */ |
| 4061 | - function ajax_resolveWinmail ($_rowid) |
|
| 4054 | + function ajax_resolveWinmail($_rowid) |
|
| 4062 | 4055 | { |
| 4063 | 4056 | $response = Api\Json\Response::get(); |
| 4064 | 4057 | |
@@ -4066,7 +4059,7 @@ discard block |
||
| 4066 | 4059 | $uid = $idParts['msgUID']; |
| 4067 | 4060 | $mbox = $idParts['folder']; |
| 4068 | 4061 | |
| 4069 | - $attachments = $this->mail_bo->getMessageAttachments($uid, null, null, false,true,true,$mbox); |
|
| 4062 | + $attachments = $this->mail_bo->getMessageAttachments($uid, null, null, false, true, true, $mbox); |
|
| 4070 | 4063 | if (is_array($attachments)) |
| 4071 | 4064 | { |
| 4072 | 4065 | $attachments = $this->createAttachmentBlock($attachments, $_rowid, $uid, $mbox, false); |
@@ -4093,31 +4086,31 @@ discard block |
||
| 4093 | 4086 | { |
| 4094 | 4087 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 4095 | 4088 | $_newLocation2 = $this->mail_bo->decodeEntityFolderName($_target); |
| 4096 | - list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
|
| 4097 | - list($newProfileID,$_newLocation) = explode(self::$delimiter,$_newLocation2,2); |
|
| 4089 | + list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2); |
|
| 4090 | + list($newProfileID, $_newLocation) = explode(self::$delimiter, $_newLocation2, 2); |
|
| 4098 | 4091 | if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID) $this->changeProfile($profileID); |
| 4099 | 4092 | $del = $this->mail_bo->getHierarchyDelimiter(false); |
| 4100 | 4093 | $hasChildren = false; |
| 4101 | 4094 | if (is_numeric($profileID)) |
| 4102 | 4095 | { |
| 4103 | - $pA = explode($del,$folderName); |
|
| 4096 | + $pA = explode($del, $folderName); |
|
| 4104 | 4097 | $namePart = array_pop($pA); |
| 4105 | 4098 | $_newName = $namePart; |
| 4106 | - $oldParentFolder = implode($del,$pA); |
|
| 4099 | + $oldParentFolder = implode($del, $pA); |
|
| 4107 | 4100 | $parentFolder = $_newLocation; |
| 4108 | 4101 | |
| 4109 | - if (strtoupper($folderName)!= 'INBOX' && |
|
| 4102 | + if (strtoupper($folderName) != 'INBOX' && |
|
| 4110 | 4103 | (($oldParentFolder === $parentFolder) || //$oldParentFolder == $parentFolder means move on same level |
| 4111 | 4104 | (($oldParentFolder != $parentFolder && |
| 4112 | - strlen($parentFolder)>0 && strlen($folderName)>0 && |
|
| 4113 | - strpos($parentFolder,$folderName)===false)))) // indicates that we move the older up the tree within its own branch |
|
| 4105 | + strlen($parentFolder) > 0 && strlen($folderName) > 0 && |
|
| 4106 | + strpos($parentFolder, $folderName) === false)))) // indicates that we move the older up the tree within its own branch |
|
| 4114 | 4107 | { |
| 4115 | 4108 | //error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName"); |
| 4116 | - $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false); |
|
| 4109 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false, false, false); |
|
| 4117 | 4110 | //error_log(__METHOD__.__LINE__.array2string($oldFolderInfo)); |
| 4118 | - if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false) |
|
| 4111 | + if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false) |
|
| 4119 | 4112 | { |
| 4120 | - $hasChildren=true; // translates to: hasChildren -> dynamicLoading |
|
| 4113 | + $hasChildren = true; // translates to: hasChildren -> dynamicLoading |
|
| 4121 | 4114 | $delimiter = $this->mail_bo->getHierarchyDelimiter(); |
| 4122 | 4115 | $nameSpace = $this->mail_bo->_getNameSpaces(); |
| 4123 | 4116 | $prefix = $this->mail_bo->getFolderPrefixFromNamespace($nameSpace, $folderName); |
@@ -4142,7 +4135,7 @@ discard block |
||
| 4142 | 4135 | $success = false; |
| 4143 | 4136 | try |
| 4144 | 4137 | { |
| 4145 | - if(($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName))) |
|
| 4138 | + if (($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName))) |
|
| 4146 | 4139 | { |
| 4147 | 4140 | $this->mail_bo->resetFolderObjectCache($profileID); |
| 4148 | 4141 | //enforce the subscription to the newly named server, as it seems to fail for names with umlauts |
@@ -4154,11 +4147,11 @@ discard block |
||
| 4154 | 4147 | } |
| 4155 | 4148 | catch (Exception $e) |
| 4156 | 4149 | { |
| 4157 | - $newFolderName=$folderName; |
|
| 4150 | + $newFolderName = $folderName; |
|
| 4158 | 4151 | $msg = $e->getMessage(); |
| 4159 | 4152 | } |
| 4160 | 4153 | $this->mail_bo->reopen($parentFolder); |
| 4161 | - $this->mail_bo->getFolderStatus($parentFolder,false,false,false); |
|
| 4154 | + $this->mail_bo->getFolderStatus($parentFolder, false, false, false); |
|
| 4162 | 4155 | //error_log(__METHOD__.__LINE__.array2string($fS)); |
| 4163 | 4156 | if ($hasChildren) |
| 4164 | 4157 | { |
@@ -4179,9 +4172,9 @@ discard block |
||
| 4179 | 4172 | } |
| 4180 | 4173 | } |
| 4181 | 4174 | } |
| 4182 | - if ($folderName==$this->mail_bo->sessionData['mailbox']) |
|
| 4175 | + if ($folderName == $this->mail_bo->sessionData['mailbox']) |
|
| 4183 | 4176 | { |
| 4184 | - $this->mail_bo->sessionData['mailbox']=$newFolderName; |
|
| 4177 | + $this->mail_bo->sessionData['mailbox'] = $newFolderName; |
|
| 4185 | 4178 | $this->mail_bo->saveSessionData(); |
| 4186 | 4179 | } |
| 4187 | 4180 | //error_log(__METHOD__.__LINE__.array2string($oA)); |
@@ -4190,26 +4183,26 @@ discard block |
||
| 4190 | 4183 | { |
| 4191 | 4184 | Api\Translation::add_app('mail'); |
| 4192 | 4185 | |
| 4193 | - $oldFolderInfo = $this->mail_bo->getFolderStatus($oldParentFolder,false,false,false); |
|
| 4194 | - $folderInfo = $this->mail_bo->getFolderStatus($parentFolder,false,false,false); |
|
| 4186 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($oldParentFolder, false, false, false); |
|
| 4187 | + $folderInfo = $this->mail_bo->getFolderStatus($parentFolder, false, false, false); |
|
| 4195 | 4188 | $refreshData = array( |
| 4196 | 4189 | $profileID.self::$delimiter.$oldParentFolder=>$oldFolderInfo['shortDisplayName'], |
| 4197 | 4190 | $profileID.self::$delimiter.$parentFolder=>$folderInfo['shortDisplayName']); |
| 4198 | 4191 | // if we move the folder within the same parent-branch of the tree, there is no need no refresh the upper part |
| 4199 | - if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]); |
|
| 4200 | - if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]); |
|
| 4192 | + if (strlen($parentFolder) > strlen($oldParentFolder) && strpos($parentFolder, $oldParentFolder) !== false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]); |
|
| 4193 | + if (count($refreshData) > 1 && strlen($oldParentFolder) > strlen($parentFolder) && strpos($oldParentFolder, $parentFolder) !== false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]); |
|
| 4201 | 4194 | |
| 4202 | 4195 | // Send full info back in the response |
| 4203 | - foreach($refreshData as $folder => &$name) |
|
| 4196 | + foreach ($refreshData as $folder => &$name) |
|
| 4204 | 4197 | { |
| 4205 | - $name = $this->mail_tree->getTree($folder,$profileID,1,false,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'],true); |
|
| 4198 | + $name = $this->mail_tree->getTree($folder, $profileID, 1, false, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'], true); |
|
| 4206 | 4199 | } |
| 4207 | - $response->call('app.mail.mail_reloadNode',$refreshData); |
|
| 4200 | + $response->call('app.mail.mail_reloadNode', $refreshData); |
|
| 4208 | 4201 | |
| 4209 | 4202 | } |
| 4210 | 4203 | else |
| 4211 | 4204 | { |
| 4212 | - $response->call('egw.refresh',lang('failed to move %1 ! Reason: %2',$folderName,$msg),'mail'); |
|
| 4205 | + $response->call('egw.refresh', lang('failed to move %1 ! Reason: %2', $folderName, $msg), 'mail'); |
|
| 4213 | 4206 | } |
| 4214 | 4207 | } |
| 4215 | 4208 | } |
@@ -4228,24 +4221,24 @@ discard block |
||
| 4228 | 4221 | { |
| 4229 | 4222 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 4230 | 4223 | $oA = array(); |
| 4231 | - list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
|
| 4232 | - if (is_numeric($profileID) && $profileID != $this->mail_bo->profileID) $this->changeProfile ($profileID); |
|
| 4224 | + list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2); |
|
| 4225 | + if (is_numeric($profileID) && $profileID != $this->mail_bo->profileID) $this->changeProfile($profileID); |
|
| 4233 | 4226 | $del = $this->mail_bo->getHierarchyDelimiter(false); |
| 4234 | 4227 | $hasChildren = false; |
| 4235 | 4228 | if (is_numeric($profileID)) |
| 4236 | 4229 | { |
| 4237 | - $pA = explode($del,$folderName); |
|
| 4230 | + $pA = explode($del, $folderName); |
|
| 4238 | 4231 | array_pop($pA); |
| 4239 | - if (strtoupper($folderName)!= 'INBOX') |
|
| 4232 | + if (strtoupper($folderName) != 'INBOX') |
|
| 4240 | 4233 | { |
| 4241 | 4234 | //error_log(__METHOD__.__LINE__."$folderName, implode($del,$pA), $_newName"); |
| 4242 | 4235 | $oA = array(); |
| 4243 | 4236 | $subFolders = array(); |
| 4244 | - $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false); |
|
| 4237 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false, false, false); |
|
| 4245 | 4238 | //error_log(__METHOD__.__LINE__.array2string($oldFolderInfo)); |
| 4246 | - if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false) |
|
| 4239 | + if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false) |
|
| 4247 | 4240 | { |
| 4248 | - $hasChildren=true; // translates to: hasChildren -> dynamicLoading |
|
| 4241 | + $hasChildren = true; // translates to: hasChildren -> dynamicLoading |
|
| 4249 | 4242 | $ftD = array(); |
| 4250 | 4243 | $delimiter = $this->mail_bo->getHierarchyDelimiter(); |
| 4251 | 4244 | $nameSpace = $this->mail_bo->_getNameSpaces(); |
@@ -4255,24 +4248,24 @@ discard block |
||
| 4255 | 4248 | //error_log(__METHOD__.__LINE__.'->'."$folderName, $delimiter, $prefix"); |
| 4256 | 4249 | foreach ($subFolders as $k => $f) |
| 4257 | 4250 | { |
| 4258 | - $ftD[substr_count($f,$delimiter)][]=$f; |
|
| 4251 | + $ftD[substr_count($f, $delimiter)][] = $f; |
|
| 4259 | 4252 | } |
| 4260 | - krsort($ftD,SORT_NUMERIC);//sort per level |
|
| 4253 | + krsort($ftD, SORT_NUMERIC); //sort per level |
|
| 4261 | 4254 | //we iterate per level of depth of the subtree, deepest nesting is to be deleted first, and then up the tree |
| 4262 | - foreach($ftD as $k => $lc)//collection per level |
|
| 4255 | + foreach ($ftD as $k => $lc)//collection per level |
|
| 4263 | 4256 | { |
| 4264 | - foreach($lc as $f)//folders contained in that level |
|
| 4257 | + foreach ($lc as $f)//folders contained in that level |
|
| 4265 | 4258 | { |
| 4266 | 4259 | try |
| 4267 | 4260 | { |
| 4268 | 4261 | //error_log(__METHOD__.__LINE__.array2string($f).'<->'.$folderName); |
| 4269 | 4262 | $this->mail_bo->deleteFolder($f); |
| 4270 | 4263 | $success = true; |
| 4271 | - if ($f==$folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName']; |
|
| 4264 | + if ($f == $folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName']; |
|
| 4272 | 4265 | } |
| 4273 | 4266 | catch (Exception $e) |
| 4274 | 4267 | { |
| 4275 | - $msg .= ($msg?' ':'').lang("Failed to delete %1. Server responded:",$f).$e->getMessage(); |
|
| 4268 | + $msg .= ($msg ? ' ' : '').lang("Failed to delete %1. Server responded:", $f).$e->getMessage(); |
|
| 4276 | 4269 | $success = false; |
| 4277 | 4270 | } |
| 4278 | 4271 | } |
@@ -4303,11 +4296,11 @@ discard block |
||
| 4303 | 4296 | if ($success) |
| 4304 | 4297 | { |
| 4305 | 4298 | //error_log(__METHOD__.__LINE__.array2string($oA)); |
| 4306 | - $response->call('app.mail.mail_removeLeaf',$oA); |
|
| 4299 | + $response->call('app.mail.mail_removeLeaf', $oA); |
|
| 4307 | 4300 | } |
| 4308 | 4301 | else |
| 4309 | 4302 | { |
| 4310 | - $response->call('egw.refresh',lang('failed to delete %1 ! Reason: %2',$oldFolderInfo['shortDisplayName'],$msg),'mail'); |
|
| 4303 | + $response->call('egw.refresh', lang('failed to delete %1 ! Reason: %2', $oldFolderInfo['shortDisplayName'], $msg), 'mail'); |
|
| 4311 | 4304 | } |
| 4312 | 4305 | } |
| 4313 | 4306 | } |
@@ -4321,7 +4314,7 @@ discard block |
||
| 4321 | 4314 | * @param bool $getFolders The client needs the folders for the profile |
| 4322 | 4315 | * @return nothing |
| 4323 | 4316 | */ |
| 4324 | - public static function ajax_changeProfile($icServerID, $getFolders = true, $exec_id=null) |
|
| 4317 | + public static function ajax_changeProfile($icServerID, $getFolders = true, $exec_id = null) |
|
| 4325 | 4318 | { |
| 4326 | 4319 | $response = Api\Json\Response::get(); |
| 4327 | 4320 | |
@@ -4329,7 +4322,7 @@ discard block |
||
| 4329 | 4322 | |
| 4330 | 4323 | if ($icServerID && $icServerID != $previous_id) |
| 4331 | 4324 | { |
| 4332 | - $mail_ui = new mail_ui(false); // do NOT run constructor, as we call changeProfile anyway |
|
| 4325 | + $mail_ui = new mail_ui(false); // do NOT run constructor, as we call changeProfile anyway |
|
| 4333 | 4326 | try |
| 4334 | 4327 | { |
| 4335 | 4328 | $mail_ui->changeProfile($icServerID); |
@@ -4345,12 +4338,12 @@ discard block |
||
| 4345 | 4338 | } |
| 4346 | 4339 | } |
| 4347 | 4340 | catch (Exception $e) { |
| 4348 | - self::callWizard($e->getMessage(),true, 'error'); |
|
| 4341 | + self::callWizard($e->getMessage(), true, 'error'); |
|
| 4349 | 4342 | } |
| 4350 | 4343 | } |
| 4351 | 4344 | else |
| 4352 | 4345 | { |
| 4353 | - $mail_ui = new mail_ui(true); // run constructor |
|
| 4346 | + $mail_ui = new mail_ui(true); // run constructor |
|
| 4354 | 4347 | } |
| 4355 | 4348 | } |
| 4356 | 4349 | |
@@ -4361,7 +4354,7 @@ discard block |
||
| 4361 | 4354 | * if other than active profile; nothing is done! |
| 4362 | 4355 | * @return nothing |
| 4363 | 4356 | */ |
| 4364 | - public static function ajax_refreshVacationNotice($icServerID=null) |
|
| 4357 | + public static function ajax_refreshVacationNotice($icServerID = null) |
|
| 4365 | 4358 | { |
| 4366 | 4359 | //Get vacation from cache if it's available |
| 4367 | 4360 | $cachedVacations = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid']); |
@@ -4379,28 +4372,28 @@ discard block |
||
| 4379 | 4372 | |
| 4380 | 4373 | $vacation = $mail->gatherVacation($cachedVacations); |
| 4381 | 4374 | } catch (Exception $e) { |
| 4382 | - $vacation=false; |
|
| 4375 | + $vacation = false; |
|
| 4383 | 4376 | error_log(__METHOD__.__LINE__." ".$e->getMessage()); |
| 4384 | 4377 | unset($e); |
| 4385 | 4378 | } |
| 4386 | 4379 | } |
| 4387 | 4380 | |
| 4388 | - if($vacation) { |
|
| 4389 | - if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date')) |
|
| 4381 | + if ($vacation) { |
|
| 4382 | + if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status'] == 'by_date')) |
|
| 4390 | 4383 | { |
| 4391 | 4384 | $dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']; |
| 4392 | 4385 | $refreshData['vacationnotice'] = lang('Vacation notice is active'); |
| 4393 | - $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):''):''); |
|
| 4394 | - if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time())$refreshData = ''; |
|
| 4386 | + $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) : '') : ''); |
|
| 4387 | + if ($vacation['status'] == 'by_date' && $vacation['end_date'] + 24 * 3600 < time())$refreshData = ''; |
|
| 4395 | 4388 | } |
| 4396 | 4389 | } |
| 4397 | - if ($vacation==false) |
|
| 4390 | + if ($vacation == false) |
|
| 4398 | 4391 | { |
| 4399 | - $refreshData['vacationnotice'] = ''; |
|
| 4400 | - $refreshData['vacationrange'] = ''; |
|
| 4392 | + $refreshData['vacationnotice'] = ''; |
|
| 4393 | + $refreshData['vacationrange'] = ''; |
|
| 4401 | 4394 | } |
| 4402 | 4395 | $response = Api\Json\Response::get(); |
| 4403 | - $response->call('app.mail.mail_refreshVacationNotice',$refreshData); |
|
| 4396 | + $response->call('app.mail.mail_refreshVacationNotice', $refreshData); |
|
| 4404 | 4397 | } |
| 4405 | 4398 | |
| 4406 | 4399 | /** |
@@ -4410,43 +4403,43 @@ discard block |
||
| 4410 | 4403 | * if other than active profile; nothing is done! |
| 4411 | 4404 | * @return nothing |
| 4412 | 4405 | */ |
| 4413 | - function ajax_refreshFilters($icServerID=null) |
|
| 4406 | + function ajax_refreshFilters($icServerID = null) |
|
| 4414 | 4407 | { |
| 4415 | 4408 | //error_log(__METHOD__.__LINE__.array2string($icServerId)); |
| 4416 | 4409 | if (empty($icServerID)) $icServerID = $this->mail_bo->profileID; |
| 4417 | 4410 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
| 4418 | 4411 | { |
| 4419 | - Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
|
| 4420 | - if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 4412 | + Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 4413 | + if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true; |
|
| 4421 | 4414 | } |
| 4422 | 4415 | if (!Mail::$supportsORinQuery[$this->mail_bo->profileID]) |
| 4423 | 4416 | { |
| 4424 | 4417 | unset($this->searchTypes['quick']); |
| 4425 | 4418 | unset($this->searchTypes['quickwithcc']); |
| 4426 | 4419 | } |
| 4427 | - if ( $this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS')) |
|
| 4420 | + if ($this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS')) |
|
| 4428 | 4421 | { |
| 4429 | - $this->statusTypes = array_merge($this->statusTypes,array( |
|
| 4430 | - 'keyword1' => 'important',//lang('important'), |
|
| 4431 | - 'keyword2' => 'job', //lang('job'), |
|
| 4432 | - 'keyword3' => 'personal',//lang('personal'), |
|
| 4433 | - 'keyword4' => 'to do', //lang('to do'), |
|
| 4434 | - 'keyword5' => 'later', //lang('later'), |
|
| 4422 | + $this->statusTypes = array_merge($this->statusTypes, array( |
|
| 4423 | + 'keyword1' => 'important', //lang('important'), |
|
| 4424 | + 'keyword2' => 'job', //lang('job'), |
|
| 4425 | + 'keyword3' => 'personal', //lang('personal'), |
|
| 4426 | + 'keyword4' => 'to do', //lang('to do'), |
|
| 4427 | + 'keyword5' => 'later', //lang('later'), |
|
| 4435 | 4428 | )); |
| 4436 | 4429 | } |
| 4437 | 4430 | else |
| 4438 | 4431 | { |
| 4439 | - $keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5'); |
|
| 4440 | - foreach($keywords as &$k) |
|
| 4432 | + $keywords = array('keyword1', 'keyword2', 'keyword3', 'keyword4', 'keyword5'); |
|
| 4433 | + foreach ($keywords as &$k) |
|
| 4441 | 4434 | { |
| 4442 | - if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]); |
|
| 4435 | + if (array_key_exists($k, $this->statusTypes)) unset($this->statusTypes[$k]); |
|
| 4443 | 4436 | } |
| 4444 | 4437 | } |
| 4445 | 4438 | |
| 4446 | 4439 | $response = Api\Json\Response::get(); |
| 4447 | - $response->call('app.mail.mail_refreshCatIdOptions',$this->searchTypes); |
|
| 4448 | - $response->call('app.mail.mail_refreshFilterOptions',$this->statusTypes); |
|
| 4449 | - $response->call('app.mail.mail_refreshFilter2Options',array(''=>lang('No Sneak Preview in list'),1=>lang('Sneak Preview in list'))); |
|
| 4440 | + $response->call('app.mail.mail_refreshCatIdOptions', $this->searchTypes); |
|
| 4441 | + $response->call('app.mail.mail_refreshFilterOptions', $this->statusTypes); |
|
| 4442 | + $response->call('app.mail.mail_refreshFilter2Options', array(''=>lang('No Sneak Preview in list'), 1=>lang('Sneak Preview in list'))); |
|
| 4450 | 4443 | |
| 4451 | 4444 | } |
| 4452 | 4445 | |
@@ -4458,7 +4451,7 @@ discard block |
||
| 4458 | 4451 | * @param string $icServerID = null |
| 4459 | 4452 | * |
| 4460 | 4453 | */ |
| 4461 | - function ajax_refreshQuotaDisplay($icServerID=null) |
|
| 4454 | + function ajax_refreshQuotaDisplay($icServerID = null) |
|
| 4462 | 4455 | { |
| 4463 | 4456 | Api\Translation::add_app('mail'); |
| 4464 | 4457 | if (is_null($icServerID)) $icServerID = $this->mail_bo->profileID; |
@@ -4476,10 +4469,10 @@ discard block |
||
| 4476 | 4469 | unset($e); |
| 4477 | 4470 | } |
| 4478 | 4471 | |
| 4479 | - if($quota !== false && $quota['limit'] != 'NOT SET') { |
|
| 4472 | + if ($quota !== false && $quota['limit'] != 'NOT SET') { |
|
| 4480 | 4473 | $quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']); |
| 4481 | - $quotaMin = $quotainfo['freespace']/pow(1024, 2); |
|
| 4482 | - $content = array ( |
|
| 4474 | + $quotaMin = $quotainfo['freespace'] / pow(1024, 2); |
|
| 4475 | + $content = array( |
|
| 4483 | 4476 | 'quota' => $quotainfo['text'], |
| 4484 | 4477 | 'quotainpercent' => (string)$quotainfo['percent'], |
| 4485 | 4478 | 'quotaclass' => $quotainfo['class'], |
@@ -4490,7 +4483,7 @@ discard block |
||
| 4490 | 4483 | } |
| 4491 | 4484 | else |
| 4492 | 4485 | { |
| 4493 | - $content = array ( |
|
| 4486 | + $content = array( |
|
| 4494 | 4487 | 'quota' => lang("Quota not provided by server"), |
| 4495 | 4488 | 'quotaclass' => "mail_DisplayNone", |
| 4496 | 4489 | 'quotanotsupported' => "mail_DisplayNone" |
@@ -4506,7 +4499,7 @@ discard block |
||
| 4506 | 4499 | } |
| 4507 | 4500 | } |
| 4508 | 4501 | $response = Api\Json\Response::get(); |
| 4509 | - $response->call('app.mail.mail_setQuotaDisplay',array('data'=>$content)); |
|
| 4502 | + $response->call('app.mail.mail_setQuotaDisplay', array('data'=>$content)); |
|
| 4510 | 4503 | } |
| 4511 | 4504 | |
| 4512 | 4505 | /** |
@@ -4528,34 +4521,34 @@ discard block |
||
| 4528 | 4521 | $this->changeProfile($icServerID); |
| 4529 | 4522 | } |
| 4530 | 4523 | $junkFolder = $this->mail_bo->getJunkFolder(); |
| 4531 | - if(!empty($junkFolder)) { |
|
| 4524 | + if (!empty($junkFolder)) { |
|
| 4532 | 4525 | if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder) |
| 4533 | 4526 | { |
| 4534 | 4527 | // Lock the tree if the active folder is junk folder |
| 4535 | 4528 | $response->call('app.mail.lock_tree'); |
| 4536 | 4529 | } |
| 4537 | - $this->mail_bo->deleteMessages('all',$junkFolder,'remove_immediately'); |
|
| 4530 | + $this->mail_bo->deleteMessages('all', $junkFolder, 'remove_immediately'); |
|
| 4538 | 4531 | |
| 4539 | 4532 | $heirarchyDelimeter = $this->mail_bo->getHierarchyDelimiter(true); |
| 4540 | - $fShortName = array_pop(explode($heirarchyDelimeter, $junkFolder)); |
|
| 4533 | + $fShortName = array_pop(explode($heirarchyDelimeter, $junkFolder)); |
|
| 4541 | 4534 | $fStatus = array( |
| 4542 | 4535 | $icServerID.self::$delimiter.$junkFolder => lang($fShortName) |
| 4543 | 4536 | ); |
| 4544 | 4537 | //Call to reset folder status counter, after junkFolder triggered not from Junk folder |
| 4545 | 4538 | //-as we don't have junk folder specific information available on client-side we need to deal with it on server |
| 4546 | - $response->call('app.mail.mail_setFolderStatus',$fStatus); |
|
| 4539 | + $response->call('app.mail.mail_setFolderStatus', $fStatus); |
|
| 4547 | 4540 | } |
| 4548 | 4541 | if ($rememberServerID != $this->mail_bo->profileID) |
| 4549 | 4542 | { |
| 4550 | - $oldFolderInfo = $this->mail_bo->getFolderStatus($junkFolder,false,false,false); |
|
| 4551 | - $response->call('egw.message',lang('empty junk')); |
|
| 4552 | - $response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$junkFolder=>$oldFolderInfo['shortDisplayName'])); |
|
| 4543 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($junkFolder, false, false, false); |
|
| 4544 | + $response->call('egw.message', lang('empty junk')); |
|
| 4545 | + $response->call('app.mail.mail_reloadNode', array($icServerID.self::$delimiter.$junkFolder=>$oldFolderInfo['shortDisplayName'])); |
|
| 4553 | 4546 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID); |
| 4554 | 4547 | $this->changeProfile($rememberServerID); |
| 4555 | 4548 | } |
| 4556 | 4549 | else if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder) |
| 4557 | 4550 | { |
| 4558 | - $response->call('egw.refresh',lang('empty junk'),'mail'); |
|
| 4551 | + $response->call('egw.refresh', lang('empty junk'), 'mail'); |
|
| 4559 | 4552 | } |
| 4560 | 4553 | } |
| 4561 | 4554 | |
@@ -4578,7 +4571,7 @@ discard block |
||
| 4578 | 4571 | $this->changeProfile($icServerID); |
| 4579 | 4572 | } |
| 4580 | 4573 | $trashFolder = $this->mail_bo->getTrashFolder(); |
| 4581 | - if(!empty($trashFolder)) { |
|
| 4574 | + if (!empty($trashFolder)) { |
|
| 4582 | 4575 | if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder) |
| 4583 | 4576 | { |
| 4584 | 4577 | // Lock the tree if the active folder is Trash folder |
@@ -4587,25 +4580,25 @@ discard block |
||
| 4587 | 4580 | $this->mail_bo->compressFolder($trashFolder); |
| 4588 | 4581 | |
| 4589 | 4582 | $heirarchyDelimeter = $this->mail_bo->getHierarchyDelimiter(true); |
| 4590 | - $fShortName = array_pop(explode($heirarchyDelimeter, $trashFolder)); |
|
| 4583 | + $fShortName = array_pop(explode($heirarchyDelimeter, $trashFolder)); |
|
| 4591 | 4584 | $fStatus = array( |
| 4592 | 4585 | $icServerID.self::$delimiter.$trashFolder => lang($fShortName) |
| 4593 | 4586 | ); |
| 4594 | 4587 | //Call to reset folder status counter, after emptyTrash triggered not from Trash folder |
| 4595 | 4588 | //-as we don't have trash folder specific information available on client-side we need to deal with it on server |
| 4596 | - $response->call('app.mail.mail_setFolderStatus',$fStatus); |
|
| 4589 | + $response->call('app.mail.mail_setFolderStatus', $fStatus); |
|
| 4597 | 4590 | } |
| 4598 | 4591 | if ($rememberServerID != $this->mail_bo->profileID) |
| 4599 | 4592 | { |
| 4600 | - $oldFolderInfo = $this->mail_bo->getFolderStatus($trashFolder,false,false,false); |
|
| 4601 | - $response->call('egw.message',lang('empty trash')); |
|
| 4602 | - $response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$trashFolder=>$oldFolderInfo['shortDisplayName'])); |
|
| 4593 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($trashFolder, false, false, false); |
|
| 4594 | + $response->call('egw.message', lang('empty trash')); |
|
| 4595 | + $response->call('app.mail.mail_reloadNode', array($icServerID.self::$delimiter.$trashFolder=>$oldFolderInfo['shortDisplayName'])); |
|
| 4603 | 4596 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID); |
| 4604 | 4597 | $this->changeProfile($rememberServerID); |
| 4605 | 4598 | } |
| 4606 | 4599 | else if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder) |
| 4607 | 4600 | { |
| 4608 | - $response->call('egw.refresh',lang('empty trash'),'mail'); |
|
| 4601 | + $response->call('egw.refresh', lang('empty trash'), 'mail'); |
|
| 4609 | 4602 | } |
| 4610 | 4603 | } |
| 4611 | 4604 | |
@@ -4622,7 +4615,7 @@ discard block |
||
| 4622 | 4615 | |
| 4623 | 4616 | $this->mail_bo->restoreSessionData(); |
| 4624 | 4617 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 4625 | - list($icServerID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
|
| 4618 | + list($icServerID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2); |
|
| 4626 | 4619 | |
| 4627 | 4620 | if (empty($folderName)) $folderName = $this->mail_bo->sessionData['mailbox']; |
| 4628 | 4621 | if ($this->mail_bo->folderExists($folderName)) |
@@ -4633,7 +4626,7 @@ discard block |
||
| 4633 | 4626 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
| 4634 | 4627 | $this->changeProfile($icServerID); |
| 4635 | 4628 | } |
| 4636 | - if(!empty($_folderName)) { |
|
| 4629 | + if (!empty($_folderName)) { |
|
| 4637 | 4630 | $this->mail_bo->compressFolder($folderName); |
| 4638 | 4631 | } |
| 4639 | 4632 | if ($rememberServerID != $this->mail_bo->profileID) |
@@ -4642,7 +4635,7 @@ discard block |
||
| 4642 | 4635 | $this->changeProfile($rememberServerID); |
| 4643 | 4636 | } |
| 4644 | 4637 | $response = Api\Json\Response::get(); |
| 4645 | - $response->call('egw.refresh',lang('compress folder').': '.$folderName,'mail'); |
|
| 4638 | + $response->call('egw.refresh', lang('compress folder').': '.$folderName, 'mail'); |
|
| 4646 | 4639 | } |
| 4647 | 4640 | } |
| 4648 | 4641 | |
@@ -4655,10 +4648,10 @@ discard block |
||
| 4655 | 4648 | */ |
| 4656 | 4649 | function ajax_sendMDN($_messageList) |
| 4657 | 4650 | { |
| 4658 | - if(Mail::$debug) error_log(__METHOD__."->".array2string($_messageList)); |
|
| 4651 | + if (Mail::$debug) error_log(__METHOD__."->".array2string($_messageList)); |
|
| 4659 | 4652 | $uidA = self::splitRowID($_messageList['msg'][0]); |
| 4660 | 4653 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
| 4661 | - $this->mail_bo->sendMDN($uidA['msgUID'],$folder); |
|
| 4654 | + $this->mail_bo->sendMDN($uidA['msgUID'], $folder); |
|
| 4662 | 4655 | } |
| 4663 | 4656 | |
| 4664 | 4657 | /** |
@@ -4670,14 +4663,14 @@ discard block |
||
| 4670 | 4663 | * |
| 4671 | 4664 | * @return xajax response |
| 4672 | 4665 | */ |
| 4673 | - function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse=true) |
|
| 4666 | + function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse = true) |
|
| 4674 | 4667 | { |
| 4675 | - if(Mail::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList)); |
|
| 4668 | + if (Mail::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList)); |
|
| 4676 | 4669 | Api\Translation::add_app('mail'); |
| 4677 | - $alreadyFlagged=false; |
|
| 4678 | - $flag2check=''; |
|
| 4670 | + $alreadyFlagged = false; |
|
| 4671 | + $flag2check = ''; |
|
| 4679 | 4672 | $filter2toggle = $query = array(); |
| 4680 | - if ($_messageList=='all' || !empty($_messageList['msg'])) |
|
| 4673 | + if ($_messageList == 'all' || !empty($_messageList['msg'])) |
|
| 4681 | 4674 | { |
| 4682 | 4675 | if (isset($_messageList['all']) && $_messageList['all']) |
| 4683 | 4676 | { |
@@ -4687,34 +4680,34 @@ discard block |
||
| 4687 | 4680 | if (isset($_messageList['activeFilters']) && $_messageList['activeFilters']) |
| 4688 | 4681 | { |
| 4689 | 4682 | $query = $_messageList['activeFilters']; |
| 4690 | - if (!empty($query['search']) || !empty($query['filter'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate'])))) |
|
| 4683 | + if (!empty($query['search']) || !empty($query['filter']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate'])))) |
|
| 4691 | 4684 | { |
| 4692 | 4685 | //([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any |
| 4693 | 4686 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
| 4694 | 4687 | { |
| 4695 | - Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
|
| 4696 | - if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 4688 | + Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 4689 | + if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true; |
|
| 4697 | 4690 | } |
| 4698 | 4691 | //error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']); |
| 4699 | 4692 | $cutoffdate = $cutoffdate2 = null; |
| 4700 | - if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate |
|
| 4701 | - if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate |
|
| 4693 | + if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate |
|
| 4694 | + if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate |
|
| 4702 | 4695 | //error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate); |
| 4703 | 4696 | $filter = array( |
| 4704 | - 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')), |
|
| 4705 | - 'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')), |
|
| 4697 | + 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')), |
|
| 4698 | + 'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')), |
|
| 4706 | 4699 | 'string' => $query['search'], |
| 4707 | - 'status' => 'any',//this is a status change. status will be manipulated later on |
|
| 4700 | + 'status' => 'any', //this is a status change. status will be manipulated later on |
|
| 4708 | 4701 | //'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2) |
| 4709 | 4702 | ); |
| 4710 | - if ($query['enddate']||$query['startdate']) { |
|
| 4703 | + if ($query['enddate'] || $query['startdate']) { |
|
| 4711 | 4704 | $filter['range'] = "BETWEEN"; |
| 4712 | 4705 | if ($cutoffdate) { |
| 4713 | - $filter[(empty($cutoffdate2)?'date':'since')] = date("d-M-Y", $cutoffdate); |
|
| 4706 | + $filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate); |
|
| 4714 | 4707 | if (empty($cutoffdate2)) $filter['range'] = "SINCE"; |
| 4715 | 4708 | } |
| 4716 | 4709 | if ($cutoffdate2) { |
| 4717 | - $filter[(empty($cutoffdate)?'date':'before')] = date("d-M-Y", $cutoffdate2); |
|
| 4710 | + $filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2); |
|
| 4718 | 4711 | if (empty($cutoffdate)) $filter['range'] = "BEFORE"; |
| 4719 | 4712 | } |
| 4720 | 4713 | } |
@@ -4727,12 +4720,12 @@ discard block |
||
| 4727 | 4720 | // flags read,flagged,label1,label2,label3,label4,label5 can be toggled: handle this when all mails in a folder |
| 4728 | 4721 | // should be affected serverside. here. |
| 4729 | 4722 | $messageList = $messageListForToggle = array(); |
| 4730 | - $flag2check = ($_flag=='read'?'seen':$_flag); |
|
| 4731 | - if (in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) && |
|
| 4732 | - !($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false)) |
|
| 4723 | + $flag2check = ($_flag == 'read' ? 'seen' : $_flag); |
|
| 4724 | + if (in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) && |
|
| 4725 | + !($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false)) |
|
| 4733 | 4726 | { |
| 4734 | 4727 | $filter2toggle['status'] = array('un'.$_flag); |
| 4735 | - if ($query['filter'] && $query['filter']!='any') |
|
| 4728 | + if ($query['filter'] && $query['filter'] != 'any') |
|
| 4736 | 4729 | { |
| 4737 | 4730 | $filter2toggle['status'][] = $query['filter']; |
| 4738 | 4731 | } |
@@ -4740,7 +4733,7 @@ discard block |
||
| 4740 | 4733 | $reverse = 1; |
| 4741 | 4734 | $_sRt = $this->mail_bo->getSortedList( |
| 4742 | 4735 | $folder, |
| 4743 | - $sort=0, |
|
| 4736 | + $sort = 0, |
|
| 4744 | 4737 | $reverse, |
| 4745 | 4738 | $filter2toggle, |
| 4746 | 4739 | $rByUid, |
@@ -4748,52 +4741,52 @@ discard block |
||
| 4748 | 4741 | ); |
| 4749 | 4742 | $messageListForToggle = $_sRt['match']->ids; |
| 4750 | 4743 | $filter['status'] = array($_flag); |
| 4751 | - if ($query['filter'] && $query['filter'] !='any') |
|
| 4744 | + if ($query['filter'] && $query['filter'] != 'any') |
|
| 4752 | 4745 | { |
| 4753 | 4746 | $filter['status'][] = $query['filter']; |
| 4754 | 4747 | } |
| 4755 | - $rByUid=true; |
|
| 4748 | + $rByUid = true; |
|
| 4756 | 4749 | $reverse = 1; |
| 4757 | 4750 | $_sR = $this->mail_bo->getSortedList( |
| 4758 | 4751 | $folder, |
| 4759 | - $sort=0, |
|
| 4752 | + $sort = 0, |
|
| 4760 | 4753 | $reverse, |
| 4761 | 4754 | $filter, |
| 4762 | 4755 | $rByUid, |
| 4763 | 4756 | false |
| 4764 | 4757 | ); |
| 4765 | 4758 | $messageList = $_sR['match']->ids; |
| 4766 | - if (count($messageListForToggle)>0) |
|
| 4759 | + if (count($messageListForToggle) > 0) |
|
| 4767 | 4760 | { |
| 4768 | 4761 | $flag2set = (strtolower($_flag)); |
| 4769 | - if(Mail::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle)); |
|
| 4770 | - $this->mail_bo->flagMessages($flag2set, $messageListForToggle,$folder); |
|
| 4762 | + if (Mail::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle)); |
|
| 4763 | + $this->mail_bo->flagMessages($flag2set, $messageListForToggle, $folder); |
|
| 4771 | 4764 | } |
| 4772 | - if (count($messageList)>0) |
|
| 4765 | + if (count($messageList) > 0) |
|
| 4773 | 4766 | { |
| 4774 | 4767 | $flag2set = 'un'.$_flag; |
| 4775 | - if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList)); |
|
| 4776 | - $this->mail_bo->flagMessages($flag2set, $messageList,$folder); |
|
| 4768 | + if (Mail::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList)); |
|
| 4769 | + $this->mail_bo->flagMessages($flag2set, $messageList, $folder); |
|
| 4777 | 4770 | } |
| 4778 | - $alreadyFlagged=true; |
|
| 4771 | + $alreadyFlagged = true; |
|
| 4779 | 4772 | } |
| 4780 | 4773 | elseif (!empty($filter) && |
| 4781 | - (!in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) || |
|
| 4782 | - (in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) && |
|
| 4783 | - ($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false)))) |
|
| 4774 | + (!in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) || |
|
| 4775 | + (in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) && |
|
| 4776 | + ($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false)))) |
|
| 4784 | 4777 | { |
| 4785 | - if ($query['filter'] && $query['filter'] !='any') |
|
| 4778 | + if ($query['filter'] && $query['filter'] != 'any') |
|
| 4786 | 4779 | { |
| 4787 | 4780 | $filter['status'] = $query['filter']; |
| 4788 | 4781 | // since we toggle and we toggle by the filtered flag we must must change _flag |
| 4789 | - $_flag = ($query['filter']=='unseen' && $_flag=='read' ? 'read' : ($query['filter']=='seen'&& $_flag=='read'?'unread':($_flag==$query['filter']?'un'.$_flag:$_flag))); |
|
| 4782 | + $_flag = ($query['filter'] == 'unseen' && $_flag == 'read' ? 'read' : ($query['filter'] == 'seen' && $_flag == 'read' ? 'unread' : ($_flag == $query['filter'] ? 'un'.$_flag : $_flag))); |
|
| 4790 | 4783 | } |
| 4791 | - if(Mail::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter)); |
|
| 4784 | + if (Mail::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter)); |
|
| 4792 | 4785 | $rByUid = true; |
| 4793 | 4786 | $reverse = 1; |
| 4794 | 4787 | $_sR = $this->mail_bo->getSortedList( |
| 4795 | 4788 | $folder, |
| 4796 | - $sort=0, |
|
| 4789 | + $sort = 0, |
|
| 4797 | 4790 | $reverse, |
| 4798 | 4791 | $filter, |
| 4799 | 4792 | $rByUid, |
@@ -4805,8 +4798,8 @@ discard block |
||
| 4805 | 4798 | } |
| 4806 | 4799 | else |
| 4807 | 4800 | { |
| 4808 | - if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter)); |
|
| 4809 | - $alreadyFlagged=true; |
|
| 4801 | + if (Mail::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter)); |
|
| 4802 | + $alreadyFlagged = true; |
|
| 4810 | 4803 | $uidA = self::splitRowID($_messageList['msg'][0]); |
| 4811 | 4804 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
| 4812 | 4805 | $this->mail_bo->flagMessages($_flag, 'all', $folder); |
@@ -4820,41 +4813,41 @@ discard block |
||
| 4820 | 4813 | } |
| 4821 | 4814 | if (!$alreadyFlagged) |
| 4822 | 4815 | { |
| 4823 | - foreach($_messageList['msg'] as $rowID) |
|
| 4816 | + foreach ($_messageList['msg'] as $rowID) |
|
| 4824 | 4817 | { |
| 4825 | 4818 | $hA = self::splitRowID($rowID); |
| 4826 | 4819 | $messageList[] = $hA['msgUID']; |
| 4827 | 4820 | } |
| 4828 | - if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList))); |
|
| 4829 | - $this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList),$folder); |
|
| 4821 | + if (Mail::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all' : $messageList))); |
|
| 4822 | + $this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all' : $messageList), $folder); |
|
| 4830 | 4823 | } |
| 4831 | 4824 | } |
| 4832 | 4825 | else |
| 4833 | 4826 | { |
| 4834 | - if(Mail::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 4827 | + if (Mail::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 4835 | 4828 | } |
| 4836 | 4829 | |
| 4837 | 4830 | if ($_sendJsonResponse) |
| 4838 | 4831 | { |
| 4839 | - $flag=array( |
|
| 4840 | - 'label1' => 'important',//lang('important'), |
|
| 4841 | - 'label2' => 'job', //lang('job'), |
|
| 4842 | - 'label3' => 'personal',//lang('personal'), |
|
| 4843 | - 'label4' => 'to do', //lang('to do'), |
|
| 4844 | - 'label5' => 'later', //lang('later'), |
|
| 4832 | + $flag = array( |
|
| 4833 | + 'label1' => 'important', //lang('important'), |
|
| 4834 | + 'label2' => 'job', //lang('job'), |
|
| 4835 | + 'label3' => 'personal', //lang('personal'), |
|
| 4836 | + 'label4' => 'to do', //lang('to do'), |
|
| 4837 | + 'label5' => 'later', //lang('later'), |
|
| 4845 | 4838 | ); |
| 4846 | 4839 | $response = Api\Json\Response::get(); |
| 4847 | 4840 | if (isset($_messageList['msg']) && $_messageList['popup']) |
| 4848 | 4841 | { |
| 4849 | - $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'); |
|
| 4842 | + $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'); |
|
| 4850 | 4843 | } |
| 4851 | - else if ((isset($_messageList['all']) && $_messageList['all']) || ($query['filter'] && ($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false))) |
|
| 4844 | + else if ((isset($_messageList['all']) && $_messageList['all']) || ($query['filter'] && ($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false))) |
|
| 4852 | 4845 | { |
| 4853 | - $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'); |
|
| 4846 | + $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'); |
|
| 4854 | 4847 | } |
| 4855 | 4848 | else |
| 4856 | 4849 | { |
| 4857 | - $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)); |
|
| 4850 | + $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)); |
|
| 4858 | 4851 | } |
| 4859 | 4852 | } |
| 4860 | 4853 | } |
@@ -4866,12 +4859,12 @@ discard block |
||
| 4866 | 4859 | * @param string _forceDeleteMethod - method of deletion to be enforced |
| 4867 | 4860 | * @return xajax response |
| 4868 | 4861 | */ |
| 4869 | - function ajax_deleteMessages($_messageList,$_forceDeleteMethod=null) |
|
| 4862 | + function ajax_deleteMessages($_messageList, $_forceDeleteMethod = null) |
|
| 4870 | 4863 | { |
| 4871 | - if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod); |
|
| 4864 | + if (Mail::$debug) error_log(__METHOD__."->".print_r($_messageList, true).' Method:'.$_forceDeleteMethod); |
|
| 4872 | 4865 | $error = null; |
| 4873 | - $filtered = false; |
|
| 4874 | - if ($_messageList=='all' || !empty($_messageList['msg'])) |
|
| 4866 | + $filtered = false; |
|
| 4867 | + if ($_messageList == 'all' || !empty($_messageList['msg'])) |
|
| 4875 | 4868 | { |
| 4876 | 4869 | if (isset($_messageList['all']) && $_messageList['all']) |
| 4877 | 4870 | { |
@@ -4881,34 +4874,34 @@ discard block |
||
| 4881 | 4874 | if (isset($_messageList['activeFilters']) && $_messageList['activeFilters']) |
| 4882 | 4875 | { |
| 4883 | 4876 | $query = $_messageList['activeFilters']; |
| 4884 | - if (!empty($query['search']) || !empty($query['filter'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate'])))) |
|
| 4877 | + if (!empty($query['search']) || !empty($query['filter']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate'])))) |
|
| 4885 | 4878 | { |
| 4886 | 4879 | //([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any |
| 4887 | 4880 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
| 4888 | 4881 | { |
| 4889 | - Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
|
| 4890 | - if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 4882 | + Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 4883 | + if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true; |
|
| 4891 | 4884 | } |
| 4892 | - $filtered = true; |
|
| 4885 | + $filtered = true; |
|
| 4893 | 4886 | $cutoffdate = $cutoffdate2 = null; |
| 4894 | - if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate |
|
| 4895 | - if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate |
|
| 4887 | + if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate |
|
| 4888 | + if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate |
|
| 4896 | 4889 | //error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate); |
| 4897 | 4890 | $filter = array( |
| 4898 | - 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')), |
|
| 4899 | - 'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')), |
|
| 4891 | + 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')), |
|
| 4892 | + 'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')), |
|
| 4900 | 4893 | 'string' => $query['search'], |
| 4901 | - 'status' => (!empty($query['filter'])?$query['filter']:'any'), |
|
| 4894 | + 'status' => (!empty($query['filter']) ? $query['filter'] : 'any'), |
|
| 4902 | 4895 | //'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2) |
| 4903 | 4896 | ); |
| 4904 | - if ($query['enddate']||$query['startdate']) { |
|
| 4897 | + if ($query['enddate'] || $query['startdate']) { |
|
| 4905 | 4898 | $filter['range'] = "BETWEEN"; |
| 4906 | 4899 | if ($cutoffdate) { |
| 4907 | - $filter[(empty($cutoffdate2)?'date':'since')] = date("d-M-Y", $cutoffdate); |
|
| 4900 | + $filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate); |
|
| 4908 | 4901 | if (empty($cutoffdate2)) $filter['range'] = "SINCE"; |
| 4909 | 4902 | } |
| 4910 | 4903 | if ($cutoffdate2) { |
| 4911 | - $filter[(empty($cutoffdate)?'date':'before')] = date("d-M-Y", $cutoffdate2); |
|
| 4904 | + $filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2); |
|
| 4912 | 4905 | if (empty($cutoffdate)) $filter['range'] = "BEFORE"; |
| 4913 | 4906 | } |
| 4914 | 4907 | } |
@@ -4922,7 +4915,7 @@ discard block |
||
| 4922 | 4915 | $rByUid = true; |
| 4923 | 4916 | $_sR = $this->mail_bo->getSortedList( |
| 4924 | 4917 | $folder, |
| 4925 | - $sort=0, |
|
| 4918 | + $sort = 0, |
|
| 4926 | 4919 | $reverse, |
| 4927 | 4920 | $filter, |
| 4928 | 4921 | $rByUid, |
@@ -4932,23 +4925,23 @@ discard block |
||
| 4932 | 4925 | } |
| 4933 | 4926 | else |
| 4934 | 4927 | { |
| 4935 | - $messageList='all'; |
|
| 4928 | + $messageList = 'all'; |
|
| 4936 | 4929 | } |
| 4937 | 4930 | try |
| 4938 | 4931 | { |
| 4939 | 4932 | //error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod); |
| 4940 | - $this->mail_bo->deleteMessages(($messageList=='all' ? 'all':$messageList),$folder,(empty($_forceDeleteMethod)?'no':$_forceDeleteMethod)); |
|
| 4933 | + $this->mail_bo->deleteMessages(($messageList == 'all' ? 'all' : $messageList), $folder, (empty($_forceDeleteMethod) ? 'no' : $_forceDeleteMethod)); |
|
| 4941 | 4934 | } |
| 4942 | 4935 | catch (Api\Exception $e) |
| 4943 | 4936 | { |
| 4944 | - $error = str_replace('"',"'",$e->getMessage()); |
|
| 4937 | + $error = str_replace('"', "'", $e->getMessage()); |
|
| 4945 | 4938 | } |
| 4946 | 4939 | } |
| 4947 | 4940 | else |
| 4948 | 4941 | { |
| 4949 | 4942 | $uidA = self::splitRowID($_messageList['msg'][0]); |
| 4950 | 4943 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
| 4951 | - foreach($_messageList['msg'] as $rowID) |
|
| 4944 | + foreach ($_messageList['msg'] as $rowID) |
|
| 4952 | 4945 | { |
| 4953 | 4946 | $hA = self::splitRowID($rowID); |
| 4954 | 4947 | $messageList[] = $hA['msgUID']; |
@@ -4956,27 +4949,27 @@ discard block |
||
| 4956 | 4949 | try |
| 4957 | 4950 | { |
| 4958 | 4951 | //error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod); |
| 4959 | - $this->mail_bo->deleteMessages($messageList,$folder,(empty($_forceDeleteMethod)?'no':$_forceDeleteMethod)); |
|
| 4952 | + $this->mail_bo->deleteMessages($messageList, $folder, (empty($_forceDeleteMethod) ? 'no' : $_forceDeleteMethod)); |
|
| 4960 | 4953 | } |
| 4961 | 4954 | catch (Api\Exception $e) |
| 4962 | 4955 | { |
| 4963 | - $error = str_replace('"',"'",$e->getMessage()); |
|
| 4956 | + $error = str_replace('"', "'", $e->getMessage()); |
|
| 4964 | 4957 | } |
| 4965 | 4958 | } |
| 4966 | 4959 | $response = Api\Json\Response::get(); |
| 4967 | 4960 | if (empty($error)) |
| 4968 | 4961 | { |
| 4969 | - $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'])); |
|
| 4962 | + $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'])); |
|
| 4970 | 4963 | } |
| 4971 | 4964 | else |
| 4972 | 4965 | { |
| 4973 | - $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)); |
|
| 4974 | - $response->call('app.mail.mail_retryForcedDelete',array('response'=>$error,'messageList'=>$_messageList)); |
|
| 4966 | + $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)); |
|
| 4967 | + $response->call('app.mail.mail_retryForcedDelete', array('response'=>$error, 'messageList'=>$_messageList)); |
|
| 4975 | 4968 | } |
| 4976 | 4969 | } |
| 4977 | 4970 | else |
| 4978 | 4971 | { |
| 4979 | - if(Mail::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 4972 | + if (Mail::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 4980 | 4973 | } |
| 4981 | 4974 | } |
| 4982 | 4975 | |
@@ -4992,48 +4985,48 @@ discard block |
||
| 4992 | 4985 | * |
| 4993 | 4986 | * @return xajax response |
| 4994 | 4987 | */ |
| 4995 | - function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove='copy', $_move2ArchiveMarker='_', $_return = false) |
|
| 4988 | + function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove = 'copy', $_move2ArchiveMarker = '_', $_return = false) |
|
| 4996 | 4989 | { |
| 4997 | - if(Mail::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker); |
|
| 4990 | + if (Mail::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList, true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker); |
|
| 4998 | 4991 | Api\Translation::add_app('mail'); |
| 4999 | 4992 | $folderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 5000 | 4993 | // only copy or move are supported as method |
| 5001 | - if (!($_copyOrMove=='copy' || $_copyOrMove=='move')) $_copyOrMove='copy'; |
|
| 5002 | - list($targetProfileID,$targetFolder) = explode(self::$delimiter,$folderName,2); |
|
| 4994 | + if (!($_copyOrMove == 'copy' || $_copyOrMove == 'move')) $_copyOrMove = 'copy'; |
|
| 4995 | + list($targetProfileID, $targetFolder) = explode(self::$delimiter, $folderName, 2); |
|
| 5003 | 4996 | // check if move2archive was called with the correct archiveFolder |
| 5004 | 4997 | $archiveFolder = $this->mail_bo->getArchiveFolder(); |
| 5005 | - if ($_move2ArchiveMarker=='2' && $targetFolder != $archiveFolder) |
|
| 4998 | + if ($_move2ArchiveMarker == '2' && $targetFolder != $archiveFolder) |
|
| 5006 | 4999 | { |
| 5007 | 5000 | error_log(__METHOD__.__LINE__."#Move to Archive called with:"."$targetProfileID,$targetFolder"); |
| 5008 | 5001 | $targetProfileID = $this->mail_bo->profileID; |
| 5009 | 5002 | $targetFolder = $archiveFolder; |
| 5010 | 5003 | error_log(__METHOD__.__LINE__."#Fixed ArchiveFolder:"."$targetProfileID,$targetFolder"); |
| 5011 | 5004 | } |
| 5012 | - $lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1); |
|
| 5005 | + $lastFoldersUsedForMoveCont = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 1); |
|
| 5013 | 5006 | $changeFolderActions = false; |
| 5014 | 5007 | //error_log(__METHOD__.__LINE__."#"."$targetProfileID,$targetFolder"); |
| 5015 | 5008 | //error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont)); |
| 5016 | 5009 | if (!isset($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder])) |
| 5017 | 5010 | { |
| 5018 | 5011 | //error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder])); |
| 5019 | - if ($lastFoldersUsedForMoveCont[$targetProfileID] && count($lastFoldersUsedForMoveCont[$targetProfileID])>3) |
|
| 5012 | + if ($lastFoldersUsedForMoveCont[$targetProfileID] && count($lastFoldersUsedForMoveCont[$targetProfileID]) > 3) |
|
| 5020 | 5013 | { |
| 5021 | 5014 | $keys = array_keys($lastFoldersUsedForMoveCont[$targetProfileID]); |
| 5022 | - foreach( $keys as &$f) |
|
| 5015 | + foreach ($keys as &$f) |
|
| 5023 | 5016 | { |
| 5024 | - if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]); |
|
| 5017 | + if (count($lastFoldersUsedForMoveCont[$targetProfileID]) > 9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]); |
|
| 5025 | 5018 | else break; |
| 5026 | 5019 | } |
| 5027 | 5020 | //error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID])); |
| 5028 | 5021 | } |
| 5029 | 5022 | //error_log(__METHOD__.__LINE__."#"."$targetProfileID,$targetFolder = $_folderName"); |
| 5030 | - $lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]=$folderName; |
|
| 5023 | + $lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder] = $folderName; |
|
| 5031 | 5024 | $changeFolderActions = true; |
| 5032 | 5025 | } |
| 5033 | 5026 | $filtered = false; |
| 5034 | - if ($_messageList=='all' || !empty($_messageList['msg'])) |
|
| 5027 | + if ($_messageList == 'all' || !empty($_messageList['msg'])) |
|
| 5035 | 5028 | { |
| 5036 | - $error=false; |
|
| 5029 | + $error = false; |
|
| 5037 | 5030 | if (isset($_messageList['all']) && $_messageList['all']) |
| 5038 | 5031 | { |
| 5039 | 5032 | // we have both messageIds AND allFlag folder information |
@@ -5043,34 +5036,34 @@ discard block |
||
| 5043 | 5036 | if (isset($_messageList['activeFilters']) && $_messageList['activeFilters']) |
| 5044 | 5037 | { |
| 5045 | 5038 | $query = $_messageList['activeFilters']; |
| 5046 | - if (!empty($query['search']) || !empty($query['filter'])||($query['cat_id']=='bydate' && (!empty($query['startdate'])||!empty($query['enddate'])))) |
|
| 5039 | + if (!empty($query['search']) || !empty($query['filter']) || ($query['cat_id'] == 'bydate' && (!empty($query['startdate']) || !empty($query['enddate'])))) |
|
| 5047 | 5040 | { |
| 5048 | 5041 | //([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any |
| 5049 | 5042 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
| 5050 | 5043 | { |
| 5051 | - Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
|
| 5052 | - if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 5044 | + Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 5045 | + if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID] = true; |
|
| 5053 | 5046 | } |
| 5054 | 5047 | $filtered = true; |
| 5055 | 5048 | $cutoffdate = $cutoffdate2 = null; |
| 5056 | - if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate |
|
| 5057 | - if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate |
|
| 5049 | + if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'], 'ts'); //SINCE, enddate |
|
| 5050 | + if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'], 'ts'); //BEFORE, startdate |
|
| 5058 | 5051 | //error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate); |
| 5059 | 5052 | $filter = array( |
| 5060 | - 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')), |
|
| 5061 | - 'type' => ($query['cat_id']?$query['cat_id']:(Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')), |
|
| 5053 | + 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')), |
|
| 5054 | + 'type' => ($query['cat_id'] ? $query['cat_id'] : (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')), |
|
| 5062 | 5055 | 'string' => $query['search'], |
| 5063 | - 'status' => (!empty($query['filter'])?$query['filter']:'any'), |
|
| 5056 | + 'status' => (!empty($query['filter']) ? $query['filter'] : 'any'), |
|
| 5064 | 5057 | //'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2) |
| 5065 | 5058 | ); |
| 5066 | - if ($query['enddate']||$query['startdate']) { |
|
| 5059 | + if ($query['enddate'] || $query['startdate']) { |
|
| 5067 | 5060 | $filter['range'] = "BETWEEN"; |
| 5068 | 5061 | if ($cutoffdate) { |
| 5069 | - $filter[(empty($cutoffdate2)?'date':'since')] = date("d-M-Y", $cutoffdate); |
|
| 5062 | + $filter[(empty($cutoffdate2) ? 'date' : 'since')] = date("d-M-Y", $cutoffdate); |
|
| 5070 | 5063 | if (empty($cutoffdate2)) $filter['range'] = "SINCE"; |
| 5071 | 5064 | } |
| 5072 | 5065 | if ($cutoffdate2) { |
| 5073 | - $filter[(empty($cutoffdate)?'date':'before')] = date("d-M-Y", $cutoffdate2); |
|
| 5066 | + $filter[(empty($cutoffdate) ? 'date' : 'before')] = date("d-M-Y", $cutoffdate2); |
|
| 5074 | 5067 | if (empty($cutoffdate)) $filter['range'] = "BEFORE"; |
| 5075 | 5068 | } |
| 5076 | 5069 | } |
@@ -5083,70 +5076,70 @@ discard block |
||
| 5083 | 5076 | $rByUid = true; |
| 5084 | 5077 | $_sR = $this->mail_bo->getSortedList( |
| 5085 | 5078 | $folder, |
| 5086 | - $sort=0, |
|
| 5079 | + $sort = 0, |
|
| 5087 | 5080 | $reverse, |
| 5088 | 5081 | $filter, |
| 5089 | - $rByUid=true, |
|
| 5082 | + $rByUid = true, |
|
| 5090 | 5083 | false |
| 5091 | 5084 | ); |
| 5092 | 5085 | $messageList = $_sR['match']->ids; |
| 5093 | - foreach($messageList as $uID) |
|
| 5086 | + foreach ($messageList as $uID) |
|
| 5094 | 5087 | { |
| 5095 | 5088 | //error_log(__METHOD__.__LINE__.$uID); |
| 5096 | - if ($_copyOrMove=='move') |
|
| 5089 | + if ($_copyOrMove == 'move') |
|
| 5097 | 5090 | { |
| 5098 | - $messageListForRefresh[] = self::generateRowID($sourceProfileID, $folderName, $uID, $_prependApp=false); |
|
| 5091 | + $messageListForRefresh[] = self::generateRowID($sourceProfileID, $folderName, $uID, $_prependApp = false); |
|
| 5099 | 5092 | } |
| 5100 | 5093 | } |
| 5101 | 5094 | } |
| 5102 | 5095 | else |
| 5103 | 5096 | { |
| 5104 | - $messageList='all'; |
|
| 5097 | + $messageList = 'all'; |
|
| 5105 | 5098 | } |
| 5106 | 5099 | try |
| 5107 | 5100 | { |
| 5108 | 5101 | //error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod.' '.$targetProfileID.'/'.$sourceProfileID); |
| 5109 | - $this->mail_bo->moveMessages($targetFolder,$messageList,($_copyOrMove=='copy'?false:true),$folder,false,$sourceProfileID,($targetProfileID!=$sourceProfileID?$targetProfileID:null)); |
|
| 5102 | + $this->mail_bo->moveMessages($targetFolder, $messageList, ($_copyOrMove == 'copy' ? false : true), $folder, false, $sourceProfileID, ($targetProfileID != $sourceProfileID ? $targetProfileID : null)); |
|
| 5110 | 5103 | } |
| 5111 | 5104 | catch (Api\Exception $e) |
| 5112 | 5105 | { |
| 5113 | - $error = str_replace('"',"'",$e->getMessage()); |
|
| 5106 | + $error = str_replace('"', "'", $e->getMessage()); |
|
| 5114 | 5107 | } |
| 5115 | 5108 | } |
| 5116 | 5109 | else |
| 5117 | 5110 | { |
| 5118 | 5111 | $messageList = array(); |
| 5119 | - while(count($_messageList['msg']) > 0) |
|
| 5112 | + while (count($_messageList['msg']) > 0) |
|
| 5120 | 5113 | { |
| 5121 | 5114 | $uidA = self::splitRowID($_messageList['msg'][0]); |
| 5122 | 5115 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
| 5123 | 5116 | $sourceProfileID = $uidA['profileID']; |
| 5124 | 5117 | $moveList = array(); |
| 5125 | - foreach($_messageList['msg'] as $rowID) |
|
| 5118 | + foreach ($_messageList['msg'] as $rowID) |
|
| 5126 | 5119 | { |
| 5127 | 5120 | $hA = self::splitRowID($rowID); |
| 5128 | 5121 | |
| 5129 | 5122 | // If folder changes, stop and move what we've got |
| 5130 | - if($hA['folder'] != $folder) break; |
|
| 5123 | + if ($hA['folder'] != $folder) break; |
|
| 5131 | 5124 | |
| 5132 | 5125 | array_shift($_messageList['msg']); |
| 5133 | 5126 | $messageList[] = $hA['msgUID']; |
| 5134 | 5127 | $moveList[] = $hA['msgUID']; |
| 5135 | - if ($_copyOrMove=='move') |
|
| 5128 | + if ($_copyOrMove == 'move') |
|
| 5136 | 5129 | { |
| 5137 | - $helpvar = explode(self::$delimiter,$rowID); |
|
| 5130 | + $helpvar = explode(self::$delimiter, $rowID); |
|
| 5138 | 5131 | array_shift($helpvar); |
| 5139 | - $messageListForRefresh[]= implode(self::$delimiter,$helpvar); |
|
| 5132 | + $messageListForRefresh[] = implode(self::$delimiter, $helpvar); |
|
| 5140 | 5133 | } |
| 5141 | 5134 | } |
| 5142 | 5135 | try |
| 5143 | 5136 | { |
| 5144 | 5137 | //error_log(__METHOD__.__LINE__."->".print_r($moveList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod.' '.$targetProfileID.'/'.$sourceProfileID); |
| 5145 | - $this->mail_bo->moveMessages($targetFolder,$moveList,($_copyOrMove=='copy'?false:true),$folder,false,$sourceProfileID,($targetProfileID!=$sourceProfileID?$targetProfileID:null)); |
|
| 5138 | + $this->mail_bo->moveMessages($targetFolder, $moveList, ($_copyOrMove == 'copy' ? false : true), $folder, false, $sourceProfileID, ($targetProfileID != $sourceProfileID ? $targetProfileID : null)); |
|
| 5146 | 5139 | } |
| 5147 | 5140 | catch (Api\Exception $e) |
| 5148 | 5141 | { |
| 5149 | - $error = str_replace('"',"'",$e->getMessage()); |
|
| 5142 | + $error = str_replace('"', "'", $e->getMessage()); |
|
| 5150 | 5143 | } |
| 5151 | 5144 | } |
| 5152 | 5145 | } |
@@ -5160,34 +5153,34 @@ discard block |
||
| 5160 | 5153 | $changeFolderActions = true; |
| 5161 | 5154 | } |
| 5162 | 5155 | if ($_return) return $error; |
| 5163 | - $response->call('egw.message',$error,"error"); |
|
| 5156 | + $response->call('egw.message', $error, "error"); |
|
| 5164 | 5157 | } |
| 5165 | 5158 | else |
| 5166 | 5159 | { |
| 5167 | - if ($_copyOrMove=='copy') |
|
| 5160 | + if ($_copyOrMove == 'copy') |
|
| 5168 | 5161 | { |
| 5169 | - $msg = lang('copied %1 message(s) from %2 to %3',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($messageList)),$folder,$targetFolder); |
|
| 5162 | + $msg = lang('copied %1 message(s) from %2 to %3', ($messageList == 'all' || $_messageList['all'] ? ($filtered ? lang('all filtered') : lang('all')) : count($messageList)), $folder, $targetFolder); |
|
| 5170 | 5163 | if ($_return) return $msg; |
| 5171 | - $response->call('egw.message',$msg); |
|
| 5164 | + $response->call('egw.message', $msg); |
|
| 5172 | 5165 | } |
| 5173 | 5166 | else |
| 5174 | 5167 | { |
| 5175 | - $msg = lang('moved %1 message(s) from %2 to %3',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($messageList)),$folder,$targetFolder); |
|
| 5168 | + $msg = lang('moved %1 message(s) from %2 to %3', ($messageList == 'all' || $_messageList['all'] ? ($filtered ? lang('all filtered') : lang('all')) : count($messageList)), $folder, $targetFolder); |
|
| 5176 | 5169 | if ($_return) return $msg; |
| 5177 | - $response->call('egw.refresh',$msg,'mail',$messageListForRefresh,'delete'); |
|
| 5170 | + $response->call('egw.refresh', $msg, 'mail', $messageListForRefresh, 'delete'); |
|
| 5178 | 5171 | } |
| 5179 | 5172 | } |
| 5180 | 5173 | if ($changeFolderActions == true) |
| 5181 | 5174 | { |
| 5182 | 5175 | //error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont)); |
| 5183 | - Api\Cache::setCache(Api\Cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFoldersUsedForMoveCont, $expiration=60*60*1); |
|
| 5176 | + Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), $lastFoldersUsedForMoveCont, $expiration = 60 * 60 * 1); |
|
| 5184 | 5177 | $actionsnew = Etemplate\Widget\Nextmatch::egw_actions(self::get_actions()); |
| 5185 | - $response->call('app.mail.mail_rebuildActionsOnList',$actionsnew); |
|
| 5178 | + $response->call('app.mail.mail_rebuildActionsOnList', $actionsnew); |
|
| 5186 | 5179 | } |
| 5187 | 5180 | } |
| 5188 | 5181 | else |
| 5189 | 5182 | { |
| 5190 | - if(Mail::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 5183 | + if (Mail::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 5191 | 5184 | } |
| 5192 | 5185 | } |
| 5193 | 5186 | |
@@ -5197,11 +5190,11 @@ discard block |
||
| 5197 | 5190 | * |
| 5198 | 5191 | * @param type $_id |
| 5199 | 5192 | */ |
| 5200 | - function ajax_folderMgmtTree_autoloading ($_id = null) |
|
| 5193 | + function ajax_folderMgmtTree_autoloading($_id = null) |
|
| 5201 | 5194 | { |
| 5202 | 5195 | $mail_ui = new mail_ui(); |
| 5203 | - $id = $_id? $_id : $_GET['id']; |
|
| 5204 | - Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id,'',1,true,false,false,false)); |
|
| 5196 | + $id = $_id ? $_id : $_GET['id']; |
|
| 5197 | + Etemplate\Widget\Tree::send_quote_json($mail_ui->mail_tree->getTree($id, '', 1, true, false, false, false)); |
|
| 5205 | 5198 | } |
| 5206 | 5199 | |
| 5207 | 5200 | /** |
@@ -5209,15 +5202,15 @@ discard block |
||
| 5209 | 5202 | * |
| 5210 | 5203 | * @param array $content content of dialog |
| 5211 | 5204 | */ |
| 5212 | - function folderManagement (array $content = null) |
|
| 5205 | + function folderManagement(array $content = null) |
|
| 5213 | 5206 | { |
| 5214 | 5207 | $dtmpl = new Etemplate('mail.folder_management'); |
| 5215 | - $profileID = $_GET['acc_id']? $_GET['acc_id']: $content['acc_id']; |
|
| 5216 | - $sel_options['tree'] = $this->mail_tree->getTree(null,$profileID, 1, true, false, false); |
|
| 5208 | + $profileID = $_GET['acc_id'] ? $_GET['acc_id'] : $content['acc_id']; |
|
| 5209 | + $sel_options['tree'] = $this->mail_tree->getTree(null, $profileID, 1, true, false, false); |
|
| 5217 | 5210 | |
| 5218 | 5211 | if (!is_array($content)) |
| 5219 | 5212 | { |
| 5220 | - $content = array ('acc_id' => $profileID); |
|
| 5213 | + $content = array('acc_id' => $profileID); |
|
| 5221 | 5214 | } |
| 5222 | 5215 | |
| 5223 | 5216 | $readonlys = array(); |
@@ -5225,7 +5218,7 @@ discard block |
||
| 5225 | 5218 | $preserv = array( |
| 5226 | 5219 | 'acc_id' => $content['acc_id'] // preserve acc id to be used in client-side |
| 5227 | 5220 | ); |
| 5228 | - $dtmpl->exec('mail.mail_ui.folderManagement', $content,$sel_options,$readonlys,$preserv,2); |
|
| 5221 | + $dtmpl->exec('mail.mail_ui.folderManagement', $content, $sel_options, $readonlys, $preserv, 2); |
|
| 5229 | 5222 | } |
| 5230 | 5223 | |
| 5231 | 5224 | /** |
@@ -5235,11 +5228,11 @@ discard block |
||
| 5235 | 5228 | * |
| 5236 | 5229 | * @param type $_folderName |
| 5237 | 5230 | */ |
| 5238 | - function ajax_folderMgmt_delete ($_folderName) |
|
| 5231 | + function ajax_folderMgmt_delete($_folderName) |
|
| 5239 | 5232 | { |
| 5240 | 5233 | if ($_folderName) |
| 5241 | 5234 | { |
| 5242 | - $success = $this->ajax_deleteFolder($_folderName,true); |
|
| 5235 | + $success = $this->ajax_deleteFolder($_folderName, true); |
|
| 5243 | 5236 | $response = Api\Json\Response::get(); |
| 5244 | 5237 | list(,$folderName) = explode(self::$delimiter, $_folderName); |
| 5245 | 5238 | if ($success) |
@@ -5248,7 +5241,7 @@ discard block |
||
| 5248 | 5241 | } |
| 5249 | 5242 | else |
| 5250 | 5243 | { |
| 5251 | - $res = lang("Failed to delete %1",$folderName); |
|
| 5244 | + $res = lang("Failed to delete %1", $folderName); |
|
| 5252 | 5245 | } |
| 5253 | 5246 | $response->data($res); |
| 5254 | 5247 | } |
@@ -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 |
@@ -167,9 +179,15 @@ discard block |
||
| 167 | 179 | $response->call('egw.message',$e->getMessage(),'error'); |
| 168 | 180 | } |
| 169 | 181 | // redirect to mail wizard to handle it (redirect works for ajax too), unless index is called. we want the sidebox |
| 170 | - if ($_GET['menuaction'] != 'mail.mail_ui.index') self::callWizard($e->getMessage(),true,'error',false); |
|
| 182 | + if ($_GET['menuaction'] != 'mail.mail_ui.index') |
|
| 183 | + { |
|
| 184 | + self::callWizard($e->getMessage(),true,'error',false); |
|
| 185 | + } |
|
| 186 | + } |
|
| 187 | + if (Mail::$debugTimes) |
|
| 188 | + { |
|
| 189 | + Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 171 | 190 | } |
| 172 | - if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 173 | 191 | } |
| 174 | 192 | |
| 175 | 193 | /** |
@@ -229,16 +247,28 @@ discard block |
||
| 229 | 247 | */ |
| 230 | 248 | function changeProfile($_icServerID,$unsetCache=false) |
| 231 | 249 | { |
| 232 | - if (Mail::$debugTimes) $starttime = microtime (true); |
|
| 250 | + if (Mail::$debugTimes) |
|
| 251 | + { |
|
| 252 | + $starttime = microtime (true); |
|
| 253 | + } |
|
| 233 | 254 | if (self::$icServerID != $_icServerID) |
| 234 | 255 | { |
| 235 | 256 | self::$icServerID = $_icServerID; |
| 236 | 257 | } |
| 237 | - if (Mail::$debug) error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID); |
|
| 258 | + if (Mail::$debug) |
|
| 259 | + { |
|
| 260 | + error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID); |
|
| 261 | + } |
|
| 238 | 262 | |
| 239 | - if ($unsetCache) Mail::unsetCachedObjects(self::$icServerID); |
|
| 263 | + if ($unsetCache) |
|
| 264 | + { |
|
| 265 | + Mail::unsetCachedObjects(self::$icServerID); |
|
| 266 | + } |
|
| 240 | 267 | $this->mail_bo = Mail::getInstance(false,self::$icServerID,true, false, true); |
| 241 | - if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace()); |
|
| 268 | + if (Mail::$debug) |
|
| 269 | + { |
|
| 270 | + error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace()); |
|
| 271 | + } |
|
| 242 | 272 | // no icServer Object: something failed big time |
| 243 | 273 | if (!isset($this->mail_bo) || !isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId<>$_icServerID) |
| 244 | 274 | { |
@@ -248,14 +278,23 @@ discard block |
||
| 248 | 278 | |
| 249 | 279 | // save session varchar |
| 250 | 280 | $oldicServerID =& Api\Cache::getSession('mail','activeProfileID'); |
| 251 | - if ($oldicServerID <> self::$icServerID) $this->mail_bo->openConnection(self::$icServerID); |
|
| 252 | - if (true) $oldicServerID = self::$icServerID; |
|
| 281 | + if ($oldicServerID <> self::$icServerID) |
|
| 282 | + { |
|
| 283 | + $this->mail_bo->openConnection(self::$icServerID); |
|
| 284 | + } |
|
| 285 | + if (true) |
|
| 286 | + { |
|
| 287 | + $oldicServerID = self::$icServerID; |
|
| 288 | + } |
|
| 253 | 289 | if (!Mail::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true )) |
| 254 | 290 | { |
| 255 | 291 | throw new Api\Exception(__METHOD__." failed to change Profile to $_icServerID"); |
| 256 | 292 | } |
| 257 | 293 | |
| 258 | - if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 294 | + if (Mail::$debugTimes) |
|
| 295 | + { |
|
| 296 | + Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 297 | + } |
|
| 259 | 298 | } |
| 260 | 299 | |
| 261 | 300 | /** |
@@ -296,7 +335,8 @@ discard block |
||
| 296 | 335 | // got subscribed or unsubscribed by the user |
| 297 | 336 | try { |
| 298 | 337 | $subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('',0,true); |
| 299 | - } catch (Exception $ex) { |
|
| 338 | + } |
|
| 339 | + catch (Exception $ex) { |
|
| 300 | 340 | Framework::message($ex->getMessage()); |
| 301 | 341 | } |
| 302 | 342 | |
@@ -330,9 +370,18 @@ discard block |
||
| 330 | 370 | list(,$node) = explode($profileId.self::$delimiter, $path); |
| 331 | 371 | if ($node) |
| 332 | 372 | { |
| 333 | - if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe []= $node; |
|
| 334 | - if (is_array($subscribed) && !$subscribed[$node] && $value['value']) $to_subscribe [] = $node; |
|
| 335 | - if ($value['value']) $cont[] = $path; |
|
| 373 | + if (is_array($subscribed) && $subscribed[$node] && !$value['value']) |
|
| 374 | + { |
|
| 375 | + $to_unsubscribe []= $node; |
|
| 376 | + } |
|
| 377 | + if (is_array($subscribed) && !$subscribed[$node] && $value['value']) |
|
| 378 | + { |
|
| 379 | + $to_subscribe [] = $node; |
|
| 380 | + } |
|
| 381 | + if ($value['value']) |
|
| 382 | + { |
|
| 383 | + $cont[] = $path; |
|
| 384 | + } |
|
| 336 | 385 | } |
| 337 | 386 | |
| 338 | 387 | } |
@@ -420,9 +469,15 @@ discard block |
||
| 420 | 469 | { |
| 421 | 470 | //error_log(__METHOD__.__LINE__.array2string($content)); |
| 422 | 471 | try { |
| 423 | - if (!isset($this->mail_bo)) throw new Api\Exception\WrongUserinput(lang('Initialization of mail failed. Please use the Wizard to cope with the problem.')); |
|
| 472 | + if (!isset($this->mail_bo)) |
|
| 473 | + { |
|
| 474 | + throw new Api\Exception\WrongUserinput(lang('Initialization of mail failed. Please use the Wizard to cope with the problem.')); |
|
| 475 | + } |
|
| 424 | 476 | //error_log(__METHOD__.__LINE__.function_backtrace()); |
| 425 | - if (Mail::$debugTimes) $starttime = microtime (true); |
|
| 477 | + if (Mail::$debugTimes) |
|
| 478 | + { |
|
| 479 | + $starttime = microtime (true); |
|
| 480 | + } |
|
| 426 | 481 | $this->mail_bo->restoreSessionData(); |
| 427 | 482 | $sessionFolder = $this->mail_bo->sessionData['mailbox']; |
| 428 | 483 | if ($this->mail_bo->folderExists($sessionFolder)) |
@@ -451,7 +506,10 @@ discard block |
||
| 451 | 506 | 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' |
| 452 | 507 | ); |
| 453 | 508 | } |
| 454 | - if (Api\Header\UserAgent::mobile()) $content[self::$nm_index]['header_row'] = 'mail.index.header_right'; |
|
| 509 | + if (Api\Header\UserAgent::mobile()) |
|
| 510 | + { |
|
| 511 | + $content[self::$nm_index]['header_row'] = 'mail.index.header_right'; |
|
| 512 | + } |
|
| 455 | 513 | } |
| 456 | 514 | |
| 457 | 515 | // These must always be set, even if $content is an array |
@@ -475,13 +533,16 @@ discard block |
||
| 475 | 533 | } |
| 476 | 534 | // call getQuotaRoot asynchronously in getRows by initiating a client Server roundtrip |
| 477 | 535 | $quota = false;//$this->mail_bo->getQuotaRoot(); |
| 478 | - if($quota !== false && $quota['limit'] != 'NOT SET') { |
|
| 536 | + if($quota !== false && $quota['limit'] != 'NOT SET') |
|
| 537 | + { |
|
| 479 | 538 | $quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']); |
| 480 | 539 | $content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text']; |
| 481 | 540 | $content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent']; |
| 482 | 541 | $content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class']; |
| 483 | 542 | $content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = ""; |
| 484 | - } else { |
|
| 543 | + } |
|
| 544 | + else |
|
| 545 | + { |
|
| 485 | 546 | $content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = lang("Quota not provided by server"); |
| 486 | 547 | $content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = "mail_DisplayNone"; |
| 487 | 548 | $content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone"; |
@@ -489,7 +550,8 @@ discard block |
||
| 489 | 550 | // call gatherVacation asynchronously in getRows by initiating a client Server roundtrip |
| 490 | 551 | $vacation = false;//$this->gatherVacation(); |
| 491 | 552 | //error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation)); |
| 492 | - if($vacation) { |
|
| 553 | + if($vacation) |
|
| 554 | + { |
|
| 493 | 555 | if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date' && $vacation['end_date'] > time())) |
| 494 | 556 | { |
| 495 | 557 | $dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']/*.' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat']!='24'?'h:i a':'H:i')*/; |
@@ -523,19 +585,31 @@ discard block |
||
| 523 | 585 | $keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5'); |
| 524 | 586 | foreach($keywords as &$k) |
| 525 | 587 | { |
| 526 | - if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]); |
|
| 588 | + if (array_key_exists($k,$this->statusTypes)) |
|
| 589 | + { |
|
| 590 | + unset($this->statusTypes[$k]); |
|
| 591 | + } |
|
| 527 | 592 | } |
| 528 | 593 | } |
| 529 | 594 | |
| 530 | - if (!isset($content[self::$nm_index]['foldertree'])) $content[self::$nm_index]['foldertree'] = $this->mail_bo->profileID.self::$delimiter.'INBOX'; |
|
| 531 | - if (!isset($content[self::$nm_index]['selectedFolder'])) $content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.'INBOX'; |
|
| 595 | + if (!isset($content[self::$nm_index]['foldertree'])) |
|
| 596 | + { |
|
| 597 | + $content[self::$nm_index]['foldertree'] = $this->mail_bo->profileID.self::$delimiter.'INBOX'; |
|
| 598 | + } |
|
| 599 | + if (!isset($content[self::$nm_index]['selectedFolder'])) |
|
| 600 | + { |
|
| 601 | + $content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.'INBOX'; |
|
| 602 | + } |
|
| 532 | 603 | |
| 533 | 604 | $content[self::$nm_index]['foldertree'] = $content[self::$nm_index]['selectedFolder']; |
| 534 | 605 | |
| 535 | 606 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
| 536 | 607 | { |
| 537 | 608 | Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
| 538 | - if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 609 | + if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
|
| 610 | + { |
|
| 611 | + Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 612 | + } |
|
| 539 | 613 | } |
| 540 | 614 | if (!Mail::$supportsORinQuery[$this->mail_bo->profileID]) |
| 541 | 615 | { |
@@ -557,10 +631,16 @@ discard block |
||
| 557 | 631 | $etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $this->get_tree_actions()); |
| 558 | 632 | |
| 559 | 633 | // sending preview toolbar actions |
| 560 | - if ($content['mailSplitter']) $etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions()); |
|
| 634 | + if ($content['mailSplitter']) |
|
| 635 | + { |
|
| 636 | + $etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions()); |
|
| 637 | + } |
|
| 561 | 638 | |
| 562 | 639 | // We need to send toolbar actions to client-side because view template needs them |
| 563 | - if (Api\Header\UserAgent::mobile()) $sel_options['toolbar'] = $this->get_toolbar_actions(); |
|
| 640 | + if (Api\Header\UserAgent::mobile()) |
|
| 641 | + { |
|
| 642 | + $sel_options['toolbar'] = $this->get_toolbar_actions(); |
|
| 643 | + } |
|
| 564 | 644 | |
| 565 | 645 | //we use the category "filter" option as specifier where we want to search (quick, subject, from, to, etc. ....) |
| 566 | 646 | if (empty($content[self::$nm_index]['cat_id']) || empty($content[self::$nm_index]['search'])) |
@@ -568,7 +648,10 @@ discard block |
||
| 568 | 648 | $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')); |
| 569 | 649 | } |
| 570 | 650 | $readonlys = $preserv = array(); |
| 571 | - if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 651 | + if (Mail::$debugTimes) |
|
| 652 | + { |
|
| 653 | + Mail::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 654 | + } |
|
| 572 | 655 | } |
| 573 | 656 | catch (Exception $e) |
| 574 | 657 | { |
@@ -584,7 +667,10 @@ discard block |
||
| 584 | 667 | $etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $this->get_tree_actions(false)); |
| 585 | 668 | } |
| 586 | 669 | $readonlys = $preserv = array(); |
| 587 | - if (empty($content)) $content=array(); |
|
| 670 | + if (empty($content)) |
|
| 671 | + { |
|
| 672 | + $content=array(); |
|
| 673 | + } |
|
| 588 | 674 | |
| 589 | 675 | self::callWizard($e->getMessage().($e->details?', '.$e->details:''),(isset($this->mail_bo)?false:true), 'error',false); |
| 590 | 676 | //return false; |
@@ -814,7 +900,8 @@ discard block |
||
| 814 | 900 | $this->mail_bo->icServer->subscribeMailbox($_folderName, $_status); |
| 815 | 901 | $this->mail_bo->resetFolderObjectCache($_acc_id); |
| 816 | 902 | $this->ajax_reloadNode($_acc_id,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
| 817 | - } catch (Horde_Imap_Client_Exception $ex) { |
|
| 903 | + } |
|
| 904 | + catch (Horde_Imap_Client_Exception $ex) { |
|
| 818 | 905 | error_log(__METHOD__.__LINE__."()". lang('Folder %1 %2 failed because of %3!',$_folderName,$_status?'subscribed':'unsubscribed', $ex)); |
| 819 | 906 | Framework::message(lang('Folder %1 %2 failed!',$_folderName,$_status)); |
| 820 | 907 | } |
@@ -831,12 +918,18 @@ discard block |
||
| 831 | 918 | public function ajax_foldertree($_nodeID = null,$_subscribedOnly=null) |
| 832 | 919 | { |
| 833 | 920 | $nodeID = $_GET['id']; |
| 834 | - if (!is_null($_nodeID)) $nodeID = $_nodeID; |
|
| 921 | + if (!is_null($_nodeID)) |
|
| 922 | + { |
|
| 923 | + $nodeID = $_nodeID; |
|
| 924 | + } |
|
| 835 | 925 | $subscribedOnly = (bool)(!is_null($_subscribedOnly)?$_subscribedOnly:!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
| 836 | 926 | $fetchCounters = !is_null($_nodeID); |
| 837 | 927 | list($_profileID,$_folderName) = explode(self::$delimiter,$nodeID,2); |
| 838 | 928 | |
| 839 | - if (!empty($_folderName)) $fetchCounters = true; |
|
| 929 | + if (!empty($_folderName)) |
|
| 930 | + { |
|
| 931 | + $fetchCounters = true; |
|
| 932 | + } |
|
| 840 | 933 | |
| 841 | 934 | // Check if it is called for refresh root |
| 842 | 935 | // then we need to reinitialized the index tree |
@@ -848,7 +941,10 @@ discard block |
||
| 848 | 941 | { |
| 849 | 942 | $data = $this->mail_tree->getTree($nodeID,$_profileID,0, false,$subscribedOnly,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
| 850 | 943 | } |
| 851 | - if (!is_null($_nodeID)) return $data; |
|
| 944 | + if (!is_null($_nodeID)) |
|
| 945 | + { |
|
| 946 | + return $data; |
|
| 947 | + } |
|
| 852 | 948 | Etemplate\Widget\Tree::send_quote_json($data); |
| 853 | 949 | } |
| 854 | 950 | |
@@ -1041,7 +1137,10 @@ discard block |
||
| 1041 | 1137 | $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 |
| 1042 | 1138 | } |
| 1043 | 1139 | } |
| 1044 | - if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont=array(); |
|
| 1140 | + if (!is_array($lastFoldersUsedForMoveCont)) |
|
| 1141 | + { |
|
| 1142 | + $lastFoldersUsedForMoveCont=array(); |
|
| 1143 | + } |
|
| 1045 | 1144 | foreach (array_keys($lastFoldersUsedForMoveCont) as $pid) |
| 1046 | 1145 | { |
| 1047 | 1146 | if ($this->mail_bo->profileID==$pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID])) |
@@ -1057,9 +1156,12 @@ discard block |
||
| 1057 | 1156 | $moveaction .= $lastFolderUsedForMoveCont; |
| 1058 | 1157 | //error_log(__METHOD__.__LINE__.'#'.$moveaction); |
| 1059 | 1158 | //error_log(__METHOD__.__LINE__.'#'.$currentArchiveActionKey); |
| 1060 | - if ($this->mail_bo->folderExists($i)) // only 10 entries per mailaccount.Control this on setting the buffered folders |
|
| 1159 | + if ($this->mail_bo->folderExists($i)) |
|
| 1160 | + { |
|
| 1161 | + // only 10 entries per mailaccount.Control this on setting the buffered folders |
|
| 1061 | 1162 | { |
| 1062 | 1163 | $fS['profileID'] = $this->mail_bo->profileID; |
| 1164 | + } |
|
| 1063 | 1165 | $fS['profileName'] = $accArray[$this->mail_bo->profileID]; |
| 1064 | 1166 | $fS['shortDisplayName'] = $i; |
| 1065 | 1167 | $moveactions[$moveaction] = $fS; |
@@ -1079,9 +1181,12 @@ discard block |
||
| 1079 | 1181 | foreach ($lastFoldersUsedForMoveCont[$pid] as $i => $lastFolderUsedForMoveCont) |
| 1080 | 1182 | { |
| 1081 | 1183 | //error_log(__METHOD__.__LINE__."$i => $lastFolderUsedForMoveCont"); |
| 1082 | - if (!empty($lastFolderUsedForMoveCont)) // only 10 entries per mailaccount.Control this on setting the buffered folders |
|
| 1184 | + if (!empty($lastFolderUsedForMoveCont)) |
|
| 1185 | + { |
|
| 1186 | + // only 10 entries per mailaccount.Control this on setting the buffered folders |
|
| 1083 | 1187 | { |
| 1084 | 1188 | $moveaction = 'move_'.$lastFolderUsedForMoveCont; |
| 1189 | + } |
|
| 1085 | 1190 | //error_log(__METHOD__.__LINE__.'#'.$moveaction); |
| 1086 | 1191 | $fS = array(); |
| 1087 | 1192 | $fS['profileID'] = $pid; |
@@ -1184,7 +1289,9 @@ discard block |
||
| 1184 | 1289 | 'children' => $children, |
| 1185 | 1290 | ); |
| 1186 | 1291 | |
| 1187 | - } else { |
|
| 1292 | + } |
|
| 1293 | + else |
|
| 1294 | + { |
|
| 1188 | 1295 | $group++; |
| 1189 | 1296 | } |
| 1190 | 1297 | $spam_actions = $this->getSpamActions(); |
@@ -1470,7 +1577,10 @@ discard block |
||
| 1470 | 1577 | $rows=array(); |
| 1471 | 1578 | return 0; |
| 1472 | 1579 | } |
| 1473 | - if (empty($folderName)) $query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX'; |
|
| 1580 | + if (empty($folderName)) |
|
| 1581 | + { |
|
| 1582 | + $query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX'; |
|
| 1583 | + } |
|
| 1474 | 1584 | } |
| 1475 | 1585 | } |
| 1476 | 1586 | if (!isset($mail_ui)) |
@@ -1485,15 +1595,24 @@ discard block |
||
| 1485 | 1595 | $rows=array(); |
| 1486 | 1596 | return 0; |
| 1487 | 1597 | } |
| 1488 | - if (empty($query['selectedFolder'])) $query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX'; |
|
| 1598 | + if (empty($query['selectedFolder'])) |
|
| 1599 | + { |
|
| 1600 | + $query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX'; |
|
| 1601 | + } |
|
| 1489 | 1602 | } |
| 1490 | 1603 | //error_log(__METHOD__.__LINE__.' SelectedFolder:'.$query['selectedFolder'].' Start:'.$query['start'].' NumRows:'.$query['num_rows'].array2string($query['order']).'->'.array2string($query['sort'])); |
| 1491 | 1604 | //Mail::$debugTimes=true; |
| 1492 | - if (Mail::$debugTimes) $starttime = microtime(true); |
|
| 1605 | + if (Mail::$debugTimes) |
|
| 1606 | + { |
|
| 1607 | + $starttime = microtime(true); |
|
| 1608 | + } |
|
| 1493 | 1609 | //$query['search'] is the phrase in the searchbox |
| 1494 | 1610 | |
| 1495 | 1611 | $mail_ui->mail_bo->restoreSessionData(); |
| 1496 | - if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder']; |
|
| 1612 | + if (isset($query['selectedFolder'])) |
|
| 1613 | + { |
|
| 1614 | + $mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder']; |
|
| 1615 | + } |
|
| 1497 | 1616 | |
| 1498 | 1617 | $sRToFetch = null; |
| 1499 | 1618 | list($_profileID,$_folderName) = explode(self::$delimiter,$query['selectedFolder'],2); |
@@ -1503,7 +1622,10 @@ discard block |
||
| 1503 | 1622 | unset($app); |
| 1504 | 1623 | } |
| 1505 | 1624 | //save selected Folder to sessionData (mailbox)->currentFolder |
| 1506 | - if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$_folderName; |
|
| 1625 | + if (isset($query['selectedFolder'])) |
|
| 1626 | + { |
|
| 1627 | + $mail_ui->mail_bo->sessionData['mailbox']=$_folderName; |
|
| 1628 | + } |
|
| 1507 | 1629 | $toSchema = false;//decides to select list schema with column to selected (if false fromaddress is default) |
| 1508 | 1630 | if ($mail_ui->mail_bo->folderExists($_folderName)) |
| 1509 | 1631 | { |
@@ -1535,8 +1657,16 @@ discard block |
||
| 1535 | 1657 | } |
| 1536 | 1658 | //error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']); |
| 1537 | 1659 | $cutoffdate = $cutoffdate2 = null; |
| 1538 | - if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate |
|
| 1539 | - if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate |
|
| 1660 | + if ($query['startdate']) |
|
| 1661 | + { |
|
| 1662 | + $cutoffdate = Api\DateTime::to($query['startdate'],'ts'); |
|
| 1663 | + } |
|
| 1664 | + //SINCE, enddate |
|
| 1665 | + if ($query['enddate']) |
|
| 1666 | + { |
|
| 1667 | + $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts'); |
|
| 1668 | + } |
|
| 1669 | + //BEFORE, startdate |
|
| 1540 | 1670 | //error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate); |
| 1541 | 1671 | $filter = array( |
| 1542 | 1672 | 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')), |
@@ -1545,15 +1675,24 @@ discard block |
||
| 1545 | 1675 | 'status' => 'any', |
| 1546 | 1676 | //'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2) |
| 1547 | 1677 | ); |
| 1548 | - if ($query['enddate']||$query['startdate']) { |
|
| 1678 | + if ($query['enddate']||$query['startdate']) |
|
| 1679 | + { |
|
| 1549 | 1680 | $filter['range'] = "BETWEEN"; |
| 1550 | - if ($cutoffdate) { |
|
| 1681 | + if ($cutoffdate) |
|
| 1682 | + { |
|
| 1551 | 1683 | $filter[(empty($cutoffdate2)?'date':'since')] = date("d-M-Y", $cutoffdate); |
| 1552 | - if (empty($cutoffdate2)) $filter['range'] = "SINCE"; |
|
| 1684 | + if (empty($cutoffdate2)) |
|
| 1685 | + { |
|
| 1686 | + $filter['range'] = "SINCE"; |
|
| 1687 | + } |
|
| 1553 | 1688 | } |
| 1554 | - if ($cutoffdate2) { |
|
| 1689 | + if ($cutoffdate2) |
|
| 1690 | + { |
|
| 1555 | 1691 | $filter[(empty($cutoffdate)?'date':'before')] = date("d-M-Y", $cutoffdate2); |
| 1556 | - if (empty($cutoffdate)) $filter['range'] = "BEFORE"; |
|
| 1692 | + if (empty($cutoffdate)) |
|
| 1693 | + { |
|
| 1694 | + $filter['range'] = "BEFORE"; |
|
| 1695 | + } |
|
| 1557 | 1696 | } |
| 1558 | 1697 | } |
| 1559 | 1698 | } |
@@ -1606,7 +1745,10 @@ discard block |
||
| 1606 | 1745 | $rowsFetched['messages'] = $_sR['count']; |
| 1607 | 1746 | $ids = $_sR['match']->ids; |
| 1608 | 1747 | // if $sR is false, something failed fundamentally |
| 1609 | - if($reverse === true) $ids = ($ids===false?array():array_reverse((array)$ids)); |
|
| 1748 | + if($reverse === true) |
|
| 1749 | + { |
|
| 1750 | + $ids = ($ids===false?array():array_reverse((array)$ids)); |
|
| 1751 | + } |
|
| 1610 | 1752 | $sR = array_slice((array)$ids,($offset==0?0:$offset-1),$maxMessages); // we need only $maxMessages of uids |
| 1611 | 1753 | $sRToFetch = $sR;//array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids |
| 1612 | 1754 | //error_log(__METHOD__.__LINE__.' Rows fetched (UID only):'.count($sR).' Data:'.array2string($sR)); |
@@ -1672,7 +1814,10 @@ discard block |
||
| 1672 | 1814 | } |
| 1673 | 1815 | else |
| 1674 | 1816 | { |
| 1675 | - if (!empty($v)) $sortResult['header'][] = array('uid'=>$v); |
|
| 1817 | + if (!empty($v)) |
|
| 1818 | + { |
|
| 1819 | + $sortResult['header'][] = array('uid'=>$v); |
|
| 1820 | + } |
|
| 1676 | 1821 | } |
| 1677 | 1822 | } |
| 1678 | 1823 | } |
@@ -1681,11 +1826,17 @@ discard block |
||
| 1681 | 1826 | $sortResult = $sortResultwH; |
| 1682 | 1827 | } |
| 1683 | 1828 | $rowsFetched['rowsFetched'] = count($sortResult['header']); |
| 1684 | - if (empty($rowsFetched['messages'])) $rowsFetched['messages'] = $rowsFetched['rowsFetched']; |
|
| 1829 | + if (empty($rowsFetched['messages'])) |
|
| 1830 | + { |
|
| 1831 | + $rowsFetched['messages'] = $rowsFetched['rowsFetched']; |
|
| 1832 | + } |
|
| 1685 | 1833 | |
| 1686 | 1834 | //error_log(__METHOD__.__LINE__.' Rows fetched:'.$rowsFetched.' Data:'.array2string($sortResult)); |
| 1687 | 1835 | $cols = array('row_id','uid','status','attachments','subject','address','toaddress','fromaddress','ccaddress','additionaltoaddress','date','size','modified','bodypreview'); |
| 1688 | - if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE') unset($cols[0]); |
|
| 1836 | + if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE') |
|
| 1837 | + { |
|
| 1838 | + unset($cols[0]); |
|
| 1839 | + } |
|
| 1689 | 1840 | $rows = $mail_ui->header2gridelements($sortResult['header'],$cols, $_folderName, $folderType=$toSchema); |
| 1690 | 1841 | |
| 1691 | 1842 | // Save the session (since we are committing session) at the end |
@@ -1693,7 +1844,10 @@ discard block |
||
| 1693 | 1844 | // e.g.: Link:: get_data which is used to read attachments data. |
| 1694 | 1845 | $mail_ui->mail_bo->saveSessionData(); |
| 1695 | 1846 | |
| 1696 | - if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__); |
|
| 1847 | + if (Mail::$debugTimes) |
|
| 1848 | + { |
|
| 1849 | + Mail::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__); |
|
| 1850 | + } |
|
| 1697 | 1851 | return $rowsFetched['messages']; |
| 1698 | 1852 | } |
| 1699 | 1853 | |
@@ -1799,7 +1953,10 @@ discard block |
||
| 1799 | 1953 | $actionsenabled[$act]= $actions['spamfilter']['children'][$act]; |
| 1800 | 1954 | break; |
| 1801 | 1955 | default: |
| 1802 | - if (isset($actions[$act])) $actionsenabled[$act]=$actions[$act]; |
|
| 1956 | + if (isset($actions[$act])) |
|
| 1957 | + { |
|
| 1958 | + $actionsenabled[$act]=$actions[$act]; |
|
| 1959 | + } |
|
| 1803 | 1960 | } |
| 1804 | 1961 | } |
| 1805 | 1962 | unset($actionsenabled['drag_mail']); |
@@ -1821,7 +1978,10 @@ discard block |
||
| 1821 | 1978 | */ |
| 1822 | 1979 | public function header2gridelements($_headers, $cols, $_folderName, $_folderType=0) |
| 1823 | 1980 | { |
| 1824 | - if (Mail::$debugTimes) $starttime = microtime(true); |
|
| 1981 | + if (Mail::$debugTimes) |
|
| 1982 | + { |
|
| 1983 | + $starttime = microtime(true); |
|
| 1984 | + } |
|
| 1825 | 1985 | $rv = array(); |
| 1826 | 1986 | $i=0; |
| 1827 | 1987 | foreach((array)$_headers as $header) |
@@ -1834,17 +1994,50 @@ discard block |
||
| 1834 | 1994 | $data['row_id']=$this->createRowID($_folderName,$message_uid); |
| 1835 | 1995 | |
| 1836 | 1996 | $flags = ""; |
| 1837 | - if(!empty($header['recent'])) $flags .= "R"; |
|
| 1838 | - if(!empty($header['flagged'])) $flags .= "F"; |
|
| 1839 | - if(!empty($header['answered'])) $flags .= "A"; |
|
| 1840 | - if(!empty($header['forwarded'])) $flags .= "W"; |
|
| 1841 | - if(!empty($header['deleted'])) $flags .= "D"; |
|
| 1842 | - if(!empty($header['seen'])) $flags .= "S"; |
|
| 1843 | - if(!empty($header['label1'])) $flags .= "1"; |
|
| 1844 | - if(!empty($header['label2'])) $flags .= "2"; |
|
| 1845 | - if(!empty($header['label3'])) $flags .= "3"; |
|
| 1846 | - if(!empty($header['label4'])) $flags .= "4"; |
|
| 1847 | - if(!empty($header['label5'])) $flags .= "5"; |
|
| 1997 | + if(!empty($header['recent'])) |
|
| 1998 | + { |
|
| 1999 | + $flags .= "R"; |
|
| 2000 | + } |
|
| 2001 | + if(!empty($header['flagged'])) |
|
| 2002 | + { |
|
| 2003 | + $flags .= "F"; |
|
| 2004 | + } |
|
| 2005 | + if(!empty($header['answered'])) |
|
| 2006 | + { |
|
| 2007 | + $flags .= "A"; |
|
| 2008 | + } |
|
| 2009 | + if(!empty($header['forwarded'])) |
|
| 2010 | + { |
|
| 2011 | + $flags .= "W"; |
|
| 2012 | + } |
|
| 2013 | + if(!empty($header['deleted'])) |
|
| 2014 | + { |
|
| 2015 | + $flags .= "D"; |
|
| 2016 | + } |
|
| 2017 | + if(!empty($header['seen'])) |
|
| 2018 | + { |
|
| 2019 | + $flags .= "S"; |
|
| 2020 | + } |
|
| 2021 | + if(!empty($header['label1'])) |
|
| 2022 | + { |
|
| 2023 | + $flags .= "1"; |
|
| 2024 | + } |
|
| 2025 | + if(!empty($header['label2'])) |
|
| 2026 | + { |
|
| 2027 | + $flags .= "2"; |
|
| 2028 | + } |
|
| 2029 | + if(!empty($header['label3'])) |
|
| 2030 | + { |
|
| 2031 | + $flags .= "3"; |
|
| 2032 | + } |
|
| 2033 | + if(!empty($header['label4'])) |
|
| 2034 | + { |
|
| 2035 | + $flags .= "4"; |
|
| 2036 | + } |
|
| 2037 | + if(!empty($header['label5'])) |
|
| 2038 | + { |
|
| 2039 | + $flags .= "5"; |
|
| 2040 | + } |
|
| 1848 | 2041 | |
| 1849 | 2042 | $data["status"] = "<span class=\"status_img\"></span>"; |
| 1850 | 2043 | //error_log(__METHOD__.array2string($header).' Flags:'.$flags); |
@@ -1852,41 +2045,53 @@ discard block |
||
| 1852 | 2045 | // the css for this row |
| 1853 | 2046 | $is_recent=false; |
| 1854 | 2047 | $css_styles = array("mail"); |
| 1855 | - if ($header['deleted']) { |
|
| 2048 | + if ($header['deleted']) |
|
| 2049 | + { |
|
| 1856 | 2050 | $css_styles[] = 'deleted'; |
| 1857 | 2051 | } |
| 1858 | - if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded'])) { |
|
| 2052 | + if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded'])) |
|
| 2053 | + { |
|
| 1859 | 2054 | $css_styles[] = 'recent'; |
| 1860 | 2055 | $is_recent=true; |
| 1861 | 2056 | } |
| 1862 | - if ($header['priority'] < 3) { |
|
| 2057 | + if ($header['priority'] < 3) |
|
| 2058 | + { |
|
| 1863 | 2059 | $css_styles[] = 'prio_high'; |
| 1864 | 2060 | } |
| 1865 | - if ($header['flagged']) { |
|
| 2061 | + if ($header['flagged']) |
|
| 2062 | + { |
|
| 1866 | 2063 | $css_styles[] = 'flagged'; |
| 1867 | 2064 | } |
| 1868 | - if (!$header['seen']) { |
|
| 2065 | + if (!$header['seen']) |
|
| 2066 | + { |
|
| 1869 | 2067 | $css_styles[] = 'unseen'; // different status image for recent // solved via css !important |
| 1870 | 2068 | } |
| 1871 | - if ($header['answered']) { |
|
| 2069 | + if ($header['answered']) |
|
| 2070 | + { |
|
| 1872 | 2071 | $css_styles[] = 'replied'; |
| 1873 | 2072 | } |
| 1874 | - if ($header['forwarded']) { |
|
| 2073 | + if ($header['forwarded']) |
|
| 2074 | + { |
|
| 1875 | 2075 | $css_styles[] = 'forwarded'; |
| 1876 | 2076 | } |
| 1877 | - if ($header['label1']) { |
|
| 2077 | + if ($header['label1']) |
|
| 2078 | + { |
|
| 1878 | 2079 | $css_styles[] = 'labelone'; |
| 1879 | 2080 | } |
| 1880 | - if ($header['label2']) { |
|
| 2081 | + if ($header['label2']) |
|
| 2082 | + { |
|
| 1881 | 2083 | $css_styles[] = 'labeltwo'; |
| 1882 | 2084 | } |
| 1883 | - if ($header['label3']) { |
|
| 2085 | + if ($header['label3']) |
|
| 2086 | + { |
|
| 1884 | 2087 | $css_styles[] = 'labelthree'; |
| 1885 | 2088 | } |
| 1886 | - if ($header['label4']) { |
|
| 2089 | + if ($header['label4']) |
|
| 2090 | + { |
|
| 1887 | 2091 | $css_styles[] = 'labelfour'; |
| 1888 | 2092 | } |
| 1889 | - if ($header['label5']) { |
|
| 2093 | + if ($header['label5']) |
|
| 2094 | + { |
|
| 1890 | 2095 | $css_styles[] = 'labelfive'; |
| 1891 | 2096 | } |
| 1892 | 2097 | |
@@ -1903,10 +2108,13 @@ discard block |
||
| 1903 | 2108 | $header['subject'] = preg_replace($search,$replace,$header['subject']); |
| 1904 | 2109 | // curly brackets get messed up by the template! |
| 1905 | 2110 | |
| 1906 | - if (!empty($header['subject'])) { |
|
| 2111 | + if (!empty($header['subject'])) |
|
| 2112 | + { |
|
| 1907 | 2113 | // make the subject shorter if it is to long |
| 1908 | 2114 | $subject = $header['subject']; |
| 1909 | - } else { |
|
| 2115 | + } |
|
| 2116 | + else |
|
| 2117 | + { |
|
| 1910 | 2118 | $subject = '('. lang('no subject') .')'; |
| 1911 | 2119 | } |
| 1912 | 2120 | |
@@ -1948,15 +2156,22 @@ discard block |
||
| 1948 | 2156 | } |
| 1949 | 2157 | |
| 1950 | 2158 | $attachmentFlag = $image; |
| 1951 | - } else { |
|
| 2159 | + } |
|
| 2160 | + else |
|
| 2161 | + { |
|
| 1952 | 2162 | $attachmentFlag =' '; |
| 1953 | 2163 | } |
| 1954 | 2164 | // show priority flag |
| 1955 | - if ($header['priority'] < 3) { |
|
| 2165 | + if ($header['priority'] < 3) |
|
| 2166 | + { |
|
| 1956 | 2167 | $image = Api\Html::image('mail','prio_high'); |
| 1957 | - } elseif ($header['priority'] > 3) { |
|
| 2168 | + } |
|
| 2169 | + elseif ($header['priority'] > 3) |
|
| 2170 | + { |
|
| 1958 | 2171 | $image = Api\Html::image('mail','prio_low'); |
| 1959 | - } else { |
|
| 2172 | + } |
|
| 2173 | + else |
|
| 2174 | + { |
|
| 1960 | 2175 | $image = ''; |
| 1961 | 2176 | } |
| 1962 | 2177 | // show a flag for flagged messages |
@@ -1998,26 +2213,53 @@ discard block |
||
| 1998 | 2213 | } |
| 1999 | 2214 | |
| 2000 | 2215 | if (in_array("size", $cols)) |
| 2001 | - $data["size"] = $header['size']; /// size |
|
| 2216 | + { |
|
| 2217 | + $data["size"] = $header['size']; |
|
| 2218 | + } |
|
| 2219 | + /// size |
|
| 2002 | 2220 | |
| 2003 | 2221 | $data["class"] = implode(' ', $css_styles); |
| 2004 | 2222 | //translate style-classes back to flags |
| 2005 | 2223 | $data['flags'] = Array(); |
| 2006 | - if ($header['seen']) $data["flags"]['read'] = 'read'; |
|
| 2007 | - foreach ($css_styles as &$flag) { |
|
| 2224 | + if ($header['seen']) |
|
| 2225 | + { |
|
| 2226 | + $data["flags"]['read'] = 'read'; |
|
| 2227 | + } |
|
| 2228 | + foreach ($css_styles as &$flag) |
|
| 2229 | + { |
|
| 2008 | 2230 | if ($flag!='mail') |
| 2009 | 2231 | { |
| 2010 | - if ($flag=='labelone') {$data["flags"]['label1'] = 'label1';} |
|
| 2011 | - elseif ($flag=='labeltwo') {$data["flags"]['label2'] = 'label2';} |
|
| 2012 | - elseif ($flag=='labelthree') {$data["flags"]['label3'] = 'label3';} |
|
| 2013 | - elseif ($flag=='labelfour') {$data["flags"]['label4'] = 'label4';} |
|
| 2014 | - elseif ($flag=='labelfive') {$data["flags"]['label5'] = 'label5';} |
|
| 2015 | - elseif ($flag=='unseen') {unset($data["flags"]['read']);} |
|
| 2016 | - else $data["flags"][$flag] = $flag; |
|
| 2232 | + if ($flag=='labelone') |
|
| 2233 | + { |
|
| 2234 | +$data["flags"]['label1'] = 'label1';} |
|
| 2235 | + elseif ($flag=='labeltwo') |
|
| 2236 | + { |
|
| 2237 | +$data["flags"]['label2'] = 'label2';} |
|
| 2238 | + elseif ($flag=='labelthree') |
|
| 2239 | + { |
|
| 2240 | +$data["flags"]['label3'] = 'label3';} |
|
| 2241 | + elseif ($flag=='labelfour') |
|
| 2242 | + { |
|
| 2243 | +$data["flags"]['label4'] = 'label4';} |
|
| 2244 | + elseif ($flag=='labelfive') |
|
| 2245 | + { |
|
| 2246 | +$data["flags"]['label5'] = 'label5';} |
|
| 2247 | + elseif ($flag=='unseen') |
|
| 2248 | + { |
|
| 2249 | +unset($data["flags"]['read']);} |
|
| 2250 | + else { |
|
| 2251 | + $data["flags"][$flag] = $flag; |
|
| 2252 | + } |
|
| 2017 | 2253 | } |
| 2018 | 2254 | } |
| 2019 | - if ($header['disposition-notification-to']) $data['dispositionnotificationto'] = $header['disposition-notification-to']; |
|
| 2020 | - if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']); |
|
| 2255 | + if ($header['disposition-notification-to']) |
|
| 2256 | + { |
|
| 2257 | + $data['dispositionnotificationto'] = $header['disposition-notification-to']; |
|
| 2258 | + } |
|
| 2259 | + if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto'])) |
|
| 2260 | + { |
|
| 2261 | + unset($data['dispositionnotificationto']); |
|
| 2262 | + } |
|
| 2021 | 2263 | $data['attachmentsBlock'] = $imageHTMLBlock; |
| 2022 | 2264 | $data['address'] = ($_folderType?$data["toaddress"]:$data["fromaddress"]); |
| 2023 | 2265 | if (in_array("bodypreview", $cols)&&$header['bodypreview']) |
@@ -2027,7 +2269,10 @@ discard block |
||
| 2027 | 2269 | $rv[] = $data; |
| 2028 | 2270 | //error_log(__METHOD__.__LINE__.array2string($data)); |
| 2029 | 2271 | } |
| 2030 | - if (Mail::$debugTimes) Mail::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__); |
|
| 2272 | + if (Mail::$debugTimes) |
|
| 2273 | + { |
|
| 2274 | + Mail::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__); |
|
| 2275 | + } |
|
| 2031 | 2276 | |
| 2032 | 2277 | // ToDo: call this ONLY if labels change |
| 2033 | 2278 | Etemplate\Widget::setElementAttribute('toolbar', 'actions', $this->get_toolbar_actions()); |
@@ -2042,8 +2287,14 @@ discard block |
||
| 2042 | 2287 | */ |
| 2043 | 2288 | function displayHeader() |
| 2044 | 2289 | { |
| 2045 | - if(isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 2046 | - if(isset($_GET['part'])) $partID = $_GET['part']; |
|
| 2290 | + if(isset($_GET['id'])) |
|
| 2291 | + { |
|
| 2292 | + $rowID = $_GET['id']; |
|
| 2293 | + } |
|
| 2294 | + if(isset($_GET['part'])) |
|
| 2295 | + { |
|
| 2296 | + $partID = $_GET['part']; |
|
| 2297 | + } |
|
| 2047 | 2298 | |
| 2048 | 2299 | $hA = self::splitRowID($rowID); |
| 2049 | 2300 | $uid = $hA['msgUID']; |
@@ -2067,7 +2318,8 @@ discard block |
||
| 2067 | 2318 | $rawheaders = ""; |
| 2068 | 2319 | // create it new, with good line breaks |
| 2069 | 2320 | reset($newRawHeaders); |
| 2070 | - while(list($key,$value) = @each($newRawHeaders)) { |
|
| 2321 | + while(list($key,$value) = @each($newRawHeaders)) |
|
| 2322 | + { |
|
| 2071 | 2323 | $rawheaders .= wordwrap($value, 90, "\n "); |
| 2072 | 2324 | } |
| 2073 | 2325 | |
@@ -2090,12 +2342,24 @@ discard block |
||
| 2090 | 2342 | */ |
| 2091 | 2343 | function displayMessage($_requesteddata = null) |
| 2092 | 2344 | { |
| 2093 | - if (is_null($_requesteddata)) $_requesteddata = $_GET; |
|
| 2345 | + if (is_null($_requesteddata)) |
|
| 2346 | + { |
|
| 2347 | + $_requesteddata = $_GET; |
|
| 2348 | + } |
|
| 2094 | 2349 | |
| 2095 | 2350 | $preventRedirect=false; |
| 2096 | - if(isset($_requesteddata['id'])) $rowID = $_requesteddata['id']; |
|
| 2097 | - if(isset($_requesteddata['part'])) $partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null; |
|
| 2098 | - if(isset($_requesteddata['mode'])) $preventRedirect = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false); |
|
| 2351 | + if(isset($_requesteddata['id'])) |
|
| 2352 | + { |
|
| 2353 | + $rowID = $_requesteddata['id']; |
|
| 2354 | + } |
|
| 2355 | + if(isset($_requesteddata['part'])) |
|
| 2356 | + { |
|
| 2357 | + $partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null; |
|
| 2358 | + } |
|
| 2359 | + if(isset($_requesteddata['mode'])) |
|
| 2360 | + { |
|
| 2361 | + $preventRedirect = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false); |
|
| 2362 | + } |
|
| 2099 | 2363 | |
| 2100 | 2364 | $hA = self::splitRowID($rowID); |
| 2101 | 2365 | $uid = $hA['msgUID']; |
@@ -2108,8 +2372,14 @@ discard block |
||
| 2108 | 2372 | $this->changeProfile($icServerID); |
| 2109 | 2373 | } |
| 2110 | 2374 | $htmlOptions = $this->mail_bo->htmlOptions; |
| 2111 | - if (!empty($_requesteddata['tryastext'])) $htmlOptions = "only_if_no_text"; |
|
| 2112 | - if (!empty($_requesteddata['tryashtml'])) $htmlOptions = "always_display"; |
|
| 2375 | + if (!empty($_requesteddata['tryastext'])) |
|
| 2376 | + { |
|
| 2377 | + $htmlOptions = "only_if_no_text"; |
|
| 2378 | + } |
|
| 2379 | + if (!empty($_requesteddata['tryashtml'])) |
|
| 2380 | + { |
|
| 2381 | + $htmlOptions = "always_display"; |
|
| 2382 | + } |
|
| 2113 | 2383 | |
| 2114 | 2384 | //error_log(__METHOD__.__LINE__.array2string($hA)); |
| 2115 | 2385 | if (($this->mail_bo->isDraftFolder($mailbox)) && $_requesteddata['mode'] == 'print') |
@@ -2133,14 +2403,20 @@ discard block |
||
| 2133 | 2403 | $error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3",$mailbox,$uid,$partID); |
| 2134 | 2404 | Framework::message($e->getMessage(), 'error'); |
| 2135 | 2405 | } |
| 2136 | - if (!empty($uid)) $this->mail_bo->getFlags($uid); |
|
| 2406 | + if (!empty($uid)) |
|
| 2407 | + { |
|
| 2408 | + $this->mail_bo->getFlags($uid); |
|
| 2409 | + } |
|
| 2137 | 2410 | $envelope = $this->mail_bo->getMessageEnvelope($uid, $partID,true,$mailbox); |
| 2138 | 2411 | //error_log(__METHOD__.__LINE__.array2string($envelope)); |
| 2139 | 2412 | $this->mail_bo->getMessageRawHeader($uid, $partID,$mailbox); |
| 2140 | 2413 | $fetchEmbeddedImages = false; |
| 2141 | 2414 | // if we are in HTML so its likely that we should show the embedded images; as a result |
| 2142 | 2415 | // we do NOT want to see those, that are embedded in the list of attachments |
| 2143 | - if ($htmlOptions !='always_display') $fetchEmbeddedImages = true; |
|
| 2416 | + if ($htmlOptions !='always_display') |
|
| 2417 | + { |
|
| 2418 | + $fetchEmbeddedImages = true; |
|
| 2419 | + } |
|
| 2144 | 2420 | $attachments = $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages,true,true,$mailbox); |
| 2145 | 2421 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
| 2146 | 2422 | $attachmentHTMLBlock = self::createAttachmentBlock($attachments, $rowID, $uid, $mailbox); |
@@ -2156,11 +2432,17 @@ discard block |
||
| 2156 | 2432 | $subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters,'',$envelope['SUBJECT']),false); |
| 2157 | 2433 | |
| 2158 | 2434 | // Set up data for taglist widget(s) |
| 2159 | - if ($envelope['FROM']==$envelope['SENDER']) unset($envelope['SENDER']); |
|
| 2435 | + if ($envelope['FROM']==$envelope['SENDER']) |
|
| 2436 | + { |
|
| 2437 | + unset($envelope['SENDER']); |
|
| 2438 | + } |
|
| 2160 | 2439 | $sel_options = array(); |
| 2161 | 2440 | foreach(array('SENDER','FROM','TO','CC','BCC') as $field) |
| 2162 | 2441 | { |
| 2163 | - if (!isset($envelope[$field])) continue; |
|
| 2442 | + if (!isset($envelope[$field])) |
|
| 2443 | + { |
|
| 2444 | + continue; |
|
| 2445 | + } |
|
| 2164 | 2446 | foreach($envelope[$field] as $field_data) |
| 2165 | 2447 | { |
| 2166 | 2448 | //error_log(__METHOD__.__LINE__.array2string($field_data)); |
@@ -2174,7 +2456,10 @@ discard block |
||
| 2174 | 2456 | } |
| 2175 | 2457 | $actionsenabled = $this->getDisplayToolbarActions(); |
| 2176 | 2458 | $content['displayToolbaractions'] = json_encode($actionsenabled); |
| 2177 | - if (empty($subject)) $subject = lang('no subject'); |
|
| 2459 | + if (empty($subject)) |
|
| 2460 | + { |
|
| 2461 | + $subject = lang('no subject'); |
|
| 2462 | + } |
|
| 2178 | 2463 | $content['msg'] = (is_array($error_msg)?implode("<br>",$error_msg):$error_msg); |
| 2179 | 2464 | // Send mail ID so we can use it for actions |
| 2180 | 2465 | $content['mail_id'] = $rowID; |
@@ -2185,8 +2470,14 @@ discard block |
||
| 2185 | 2470 | $content['mail_displaydate'] = Mail::_strtotime($headers['DATE'],'ts',true); |
| 2186 | 2471 | $content['mail_displaysubject'] = $subject; |
| 2187 | 2472 | $linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody","_messageID"=>$rowID); |
| 2188 | - if (!empty($partID)) $linkData['_partID']=$partID; |
|
| 2189 | - if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions']=$htmlOptions; |
|
| 2473 | + if (!empty($partID)) |
|
| 2474 | + { |
|
| 2475 | + $linkData['_partID']=$partID; |
|
| 2476 | + } |
|
| 2477 | + if ($htmlOptions != $this->mail_bo->htmlOptions) |
|
| 2478 | + { |
|
| 2479 | + $linkData['_htmloptions']=$htmlOptions; |
|
| 2480 | + } |
|
| 2190 | 2481 | $content['mailDisplayBodySrc'] = Egw::link('/index.php',$linkData); |
| 2191 | 2482 | $content['mail_displayattachments'] = $attachmentHTMLBlock; |
| 2192 | 2483 | $content['mail_id']=$rowID; |
@@ -2266,7 +2557,8 @@ discard block |
||
| 2266 | 2557 | } |
| 2267 | 2558 | } |
| 2268 | 2559 | |
| 2269 | - if (is_array($attachments) && count($attachments) > 0) { |
|
| 2560 | + if (is_array($attachments) && count($attachments) > 0) |
|
| 2561 | + { |
|
| 2270 | 2562 | $url_img_vfs = Api\Html::image('filemanager','navbar', lang('Filemanager'), ' height="16"'); |
| 2271 | 2563 | $url_img_vfs_save_all = Api\Html::image('mail','save_all', lang('Save all')); |
| 2272 | 2564 | |
@@ -2276,7 +2568,10 @@ discard block |
||
| 2276 | 2568 | $attachmentHTML[$key]['filename'] = Api\Translation::convert_jsonsafe($attachmentHTML[$key]['filename'],'utf-8'); |
| 2277 | 2569 | //error_log(array2string($value)); |
| 2278 | 2570 | //error_log(strtoupper($value['mimeType']) .'<->'. Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename'])); |
| 2279 | - if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) $value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']); |
|
| 2571 | + if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) |
|
| 2572 | + { |
|
| 2573 | + $value['mimeType'] = Api\MimeMagic::filename2mime($attachmentHTML[$key]['filename']); |
|
| 2574 | + } |
|
| 2280 | 2575 | $attachmentHTML[$key]['type']=$value['mimeType']; |
| 2281 | 2576 | $attachmentHTML[$key]['mimetype'] = Api\MimeMagic::mime2label($value['mimeType']); |
| 2282 | 2577 | $hA = self::splitRowID($rowID); |
@@ -2326,8 +2621,15 @@ discard block |
||
| 2326 | 2621 | $sfxMimeType = $value['mimeType']; |
| 2327 | 2622 | $buff = explode('.',$value['name']); |
| 2328 | 2623 | $suffix = ''; |
| 2329 | - if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
|
| 2330 | - if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix); |
|
| 2624 | + if (is_array($buff)) |
|
| 2625 | + { |
|
| 2626 | + $suffix = array_pop($buff); |
|
| 2627 | + } |
|
| 2628 | + // take the last extension to check with ext2mime |
|
| 2629 | + if (!empty($suffix)) |
|
| 2630 | + { |
|
| 2631 | + $sfxMimeType = Api\MimeMagic::ext2mime($suffix); |
|
| 2632 | + } |
|
| 2331 | 2633 | if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') |
| 2332 | 2634 | { |
| 2333 | 2635 | $attachments[$key]['mimeType'] = $sfxMimeType; |
@@ -2543,7 +2845,10 @@ discard block |
||
| 2543 | 2845 | $uid = $_GET['uid']; |
| 2544 | 2846 | $cid = base64_decode($_GET['cid']); |
| 2545 | 2847 | $partID = urldecode($_GET['partID']); |
| 2546 | - if (!empty($_GET['mailbox'])) $mailbox = base64_decode($_GET['mailbox']); |
|
| 2848 | + if (!empty($_GET['mailbox'])) |
|
| 2849 | + { |
|
| 2850 | + $mailbox = base64_decode($_GET['mailbox']); |
|
| 2851 | + } |
|
| 2547 | 2852 | |
| 2548 | 2853 | //error_log(__METHOD__.__LINE__.":$uid, $cid, $partID"); |
| 2549 | 2854 | $this->mail_bo->reopen($mailbox); |
@@ -2575,7 +2880,10 @@ discard block |
||
| 2575 | 2880 | |
| 2576 | 2881 | function getAttachment() |
| 2577 | 2882 | { |
| 2578 | - if(isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 2883 | + if(isset($_GET['id'])) |
|
| 2884 | + { |
|
| 2885 | + $rowID = $_GET['id']; |
|
| 2886 | + } |
|
| 2579 | 2887 | |
| 2580 | 2888 | $hA = self::splitRowID($rowID); |
| 2581 | 2889 | $uid = $hA['msgUID']; |
@@ -2608,10 +2916,20 @@ discard block |
||
| 2608 | 2916 | $sfxMimeType = $attachment['type']; |
| 2609 | 2917 | $buff = explode('.',$attachment['filename']); |
| 2610 | 2918 | $suffix = ''; |
| 2611 | - if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
|
| 2612 | - if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix); |
|
| 2919 | + if (is_array($buff)) |
|
| 2920 | + { |
|
| 2921 | + $suffix = array_pop($buff); |
|
| 2922 | + } |
|
| 2923 | + // take the last extension to check with ext2mime |
|
| 2924 | + if (!empty($suffix)) |
|
| 2925 | + { |
|
| 2926 | + $sfxMimeType = Api\MimeMagic::ext2mime($suffix); |
|
| 2927 | + } |
|
| 2613 | 2928 | $attachment['type'] = $sfxMimeType; |
| 2614 | - if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') $attachment['type'] = strtoupper($sfxMimeType); |
|
| 2929 | + if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') |
|
| 2930 | + { |
|
| 2931 | + $attachment['type'] = strtoupper($sfxMimeType); |
|
| 2932 | + } |
|
| 2615 | 2933 | } |
| 2616 | 2934 | //error_log(__METHOD__.print_r($attachment,true)); |
| 2617 | 2935 | if (strtoupper($attachment['type']) == 'TEXT/CALENDAR' || strtoupper($attachment['type']) == 'TEXT/X-VCALENDAR') |
@@ -2620,7 +2938,10 @@ discard block |
||
| 2620 | 2938 | $calendar_ical = new calendar_ical(); |
| 2621 | 2939 | $eventid = $calendar_ical->search($attachment['attachment'],-1); |
| 2622 | 2940 | //error_log(__METHOD__.array2string($eventid)); |
| 2623 | - if (!$eventid) $eventid = -1; |
|
| 2941 | + if (!$eventid) |
|
| 2942 | + { |
|
| 2943 | + $eventid = -1; |
|
| 2944 | + } |
|
| 2624 | 2945 | $event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true,0,'',null,$attachment['charset']); |
| 2625 | 2946 | //error_log(__METHOD__.$event); |
| 2626 | 2947 | if ((int)$event > 0) |
@@ -2646,7 +2967,10 @@ discard block |
||
| 2646 | 2967 | //error_log(__METHOD__.__LINE__.print_r($vcard,true)); |
| 2647 | 2968 | $contact = $addressbook_vcal->find_contact($vcard,false); |
| 2648 | 2969 | } |
| 2649 | - if (!$contact) $contact = null; |
|
| 2970 | + if (!$contact) |
|
| 2971 | + { |
|
| 2972 | + $contact = null; |
|
| 2973 | + } |
|
| 2650 | 2974 | // 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)) |
| 2651 | 2975 | if ($contact || count($vcard)>2) |
| 2652 | 2976 | { |
@@ -2680,9 +3004,18 @@ discard block |
||
| 2680 | 3004 | function saveMessage() |
| 2681 | 3005 | { |
| 2682 | 3006 | $display = false; |
| 2683 | - if(isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 2684 | - if(isset($_GET['part'])) $partID = $_GET['part']; |
|
| 2685 | - if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager')) $display = $_GET['location']; |
|
| 3007 | + if(isset($_GET['id'])) |
|
| 3008 | + { |
|
| 3009 | + $rowID = $_GET['id']; |
|
| 3010 | + } |
|
| 3011 | + if(isset($_GET['part'])) |
|
| 3012 | + { |
|
| 3013 | + $partID = $_GET['part']; |
|
| 3014 | + } |
|
| 3015 | + if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager')) |
|
| 3016 | + { |
|
| 3017 | + $display = $_GET['location']; |
|
| 3018 | + } |
|
| 2686 | 3019 | |
| 2687 | 3020 | $hA = self::splitRowID($rowID); |
| 2688 | 3021 | $uid = $hA['msgUID']; |
@@ -2771,7 +3104,10 @@ discard block |
||
| 2771 | 3104 | { |
| 2772 | 3105 | $succeeded = true; |
| 2773 | 3106 | } |
| 2774 | - if ($fp) fclose($fp); |
|
| 3107 | + if ($fp) |
|
| 3108 | + { |
|
| 3109 | + fclose($fp); |
|
| 3110 | + } |
|
| 2775 | 3111 | if ($succeeded) |
| 2776 | 3112 | { |
| 2777 | 3113 | unset($headers['SUBJECT']);//already in filename |
@@ -2821,7 +3157,8 @@ discard block |
||
| 2821 | 3157 | * |
| 2822 | 3158 | * @return array an array of parameters |
| 2823 | 3159 | */ |
| 2824 | - $getParams = function ($id) { |
|
| 3160 | + $getParams = function ($id) |
|
| 3161 | + { |
|
| 2825 | 3162 | list($app,$user,$serverID,$mailbox,$uid,$part,$is_winmail,$name) = explode('::',$id,8); |
| 2826 | 3163 | $lId = implode('::',array($app,$user,$serverID,$mailbox,$uid)); |
| 2827 | 3164 | $hA = mail_ui::splitRowID($lId); |
@@ -2857,7 +3194,10 @@ discard block |
||
| 2857 | 3194 | { |
| 2858 | 3195 | $params = $getParams($id); |
| 2859 | 3196 | // when downloading a single file, name is not set |
| 2860 | - if (!$params['name']&&isset($_GET['name'])&&!$isMultipleDownload) $params['name'] = $_GET['name']; |
|
| 3197 | + if (!$params['name']&&isset($_GET['name'])&&!$isMultipleDownload) |
|
| 3198 | + { |
|
| 3199 | + $params['name'] = $_GET['name']; |
|
| 3200 | + } |
|
| 2861 | 3201 | if ($params['icServer'] && $params['icServer'] != $this->mail_bo->profileID) |
| 2862 | 3202 | { |
| 2863 | 3203 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
@@ -2870,7 +3210,10 @@ discard block |
||
| 2870 | 3210 | // Try to find the right content for file id |
| 2871 | 3211 | foreach ($attachments as $key => $val) |
| 2872 | 3212 | { |
| 2873 | - if ($key == $params['is_winmail']) $attachment = $val; |
|
| 3213 | + if ($key == $params['is_winmail']) |
|
| 3214 | + { |
|
| 3215 | + $attachment = $val; |
|
| 3216 | + } |
|
| 2874 | 3217 | } |
| 2875 | 3218 | } |
| 2876 | 3219 | else |
@@ -2917,7 +3260,10 @@ discard block |
||
| 2917 | 3260 | { |
| 2918 | 3261 | //error_log(__METHOD__.__LINE__.array2string($_GET)); |
| 2919 | 3262 | // First, get all attachment IDs |
| 2920 | - if(isset($_GET['id'])) $message_id = $_GET['id']; |
|
| 3263 | + if(isset($_GET['id'])) |
|
| 3264 | + { |
|
| 3265 | + $message_id = $_GET['id']; |
|
| 3266 | + } |
|
| 2921 | 3267 | //error_log(__METHOD__.__LINE__.$message_id); |
| 2922 | 3268 | $rememberServerID = $this->mail_bo->profileID; |
| 2923 | 3269 | if(!is_numeric($message_id)) |
@@ -2944,7 +3290,10 @@ discard block |
||
| 2944 | 3290 | //get_home_dir may fetch the users startfolder if set; if not writeable, action will fail. TODO: use temp_dir |
| 2945 | 3291 | $homedir = '/home/'.$GLOBALS['egw_info']['user']['account_lid']; |
| 2946 | 3292 | $temp_path = $homedir/*Vfs::get_home_dir()*/ . "/.mail_$message_id"; |
| 2947 | - if(Vfs::is_dir($temp_path)) Vfs::remove ($temp_path); |
|
| 3293 | + if(Vfs::is_dir($temp_path)) |
|
| 3294 | + { |
|
| 3295 | + Vfs::remove ($temp_path); |
|
| 3296 | + } |
|
| 2948 | 3297 | |
| 2949 | 3298 | // Add subject to path, so it gets used as the file name, replacing ':' |
| 2950 | 3299 | // as it seems to cause an error |
@@ -2970,7 +3319,10 @@ discard block |
||
| 2970 | 3319 | foreach ($tnefAttachments as $key => $val) |
| 2971 | 3320 | { |
| 2972 | 3321 | error_log(__METHOD__.' winmail = '.$key); |
| 2973 | - if ($key == $file['is_winmail']) $attachment = $val; |
|
| 3322 | + if ($key == $file['is_winmail']) |
|
| 3323 | + { |
|
| 3324 | + $attachment = $val; |
|
| 3325 | + } |
|
| 2974 | 3326 | } |
| 2975 | 3327 | } |
| 2976 | 3328 | else |
@@ -2978,7 +3330,10 @@ discard block |
||
| 2978 | 3330 | $attachment = $this->mail_bo->getAttachment($message_id,$file['partID'],$file['is_winmail'],false,true); |
| 2979 | 3331 | } |
| 2980 | 3332 | $success=true; |
| 2981 | - if (empty($file['filename'])) $file['filename'] = $file['name']; |
|
| 3333 | + if (empty($file['filename'])) |
|
| 3334 | + { |
|
| 3335 | + $file['filename'] = $file['name']; |
|
| 3336 | + } |
|
| 2982 | 3337 | if(in_array($path.$file['filename'], $file_list)) |
| 2983 | 3338 | { |
| 2984 | 3339 | $dupe_count[$path.$file['filename']]++; |
@@ -2995,8 +3350,14 @@ discard block |
||
| 2995 | 3350 | $success=false; |
| 2996 | 3351 | Framework::message("Unable to zip {$target_name}",'error'); |
| 2997 | 3352 | } |
| 2998 | - if ($success) $file_list[] = $path.$target_name; |
|
| 2999 | - if ($fp) fclose($fp); |
|
| 3353 | + if ($success) |
|
| 3354 | + { |
|
| 3355 | + $file_list[] = $path.$target_name; |
|
| 3356 | + } |
|
| 3357 | + if ($fp) |
|
| 3358 | + { |
|
| 3359 | + fclose($fp); |
|
| 3360 | + } |
|
| 3000 | 3361 | } |
| 3001 | 3362 | $this->mail_bo->closeConnection(); |
| 3002 | 3363 | if ($rememberServerID != $this->mail_bo->profileID) |
@@ -3023,7 +3384,10 @@ discard block |
||
| 3023 | 3384 | $this->uid = $uid; |
| 3024 | 3385 | $this->partID = $partID; |
| 3025 | 3386 | $bufferHtmlOptions = $this->mail_bo->htmlOptions; |
| 3026 | - if (empty($htmlOptions)) $htmlOptions = $this->mail_bo->htmlOptions; |
|
| 3387 | + if (empty($htmlOptions)) |
|
| 3388 | + { |
|
| 3389 | + $htmlOptions = $this->mail_bo->htmlOptions; |
|
| 3390 | + } |
|
| 3027 | 3391 | // fetching structure now, to supply it to getMessageBody and getMessageAttachment, so it does not get fetched twice |
| 3028 | 3392 | $structure = $this->mail_bo->getStructure($uid, $partID, $mailbox, false); |
| 3029 | 3393 | $calendar_part = null; |
@@ -3078,10 +3442,16 @@ discard block |
||
| 3078 | 3442 | <table width="100%" style="table-layout:fixed"><tr><td class="td_display">'; |
| 3079 | 3443 | |
| 3080 | 3444 | $EndBody = '</td></tr></table></div>'; |
| 3081 | - if ($fullPageTags) $EndBody .= "</body></html>"; |
|
| 3082 | - if ($print) { |
|
| 3445 | + if ($fullPageTags) |
|
| 3446 | + { |
|
| 3447 | + $EndBody .= "</body></html>"; |
|
| 3448 | + } |
|
| 3449 | + if ($print) |
|
| 3450 | + { |
|
| 3083 | 3451 | print $BeginBody. $body .$EndBody; |
| 3084 | - } else { |
|
| 3452 | + } |
|
| 3453 | + else |
|
| 3454 | + { |
|
| 3085 | 3455 | return $BeginBody. $body .$EndBody; |
| 3086 | 3456 | } |
| 3087 | 3457 | } |
@@ -3097,9 +3467,14 @@ discard block |
||
| 3097 | 3467 | $body = ''; |
| 3098 | 3468 | |
| 3099 | 3469 | //error_log(__METHOD__.array2string($bodyParts)); //exit; |
| 3100 | - if (empty($bodyParts)) return ""; |
|
| 3101 | - foreach((array)$bodyParts as $singleBodyPart) { |
|
| 3102 | - if (!isset($singleBodyPart['body'])) { |
|
| 3470 | + if (empty($bodyParts)) |
|
| 3471 | + { |
|
| 3472 | + return ""; |
|
| 3473 | + } |
|
| 3474 | + foreach((array)$bodyParts as $singleBodyPart) |
|
| 3475 | + { |
|
| 3476 | + if (!isset($singleBodyPart['body'])) |
|
| 3477 | + { |
|
| 3103 | 3478 | $singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart,$modifyURI,$useTidy); |
| 3104 | 3479 | $body .= $singleBodyPart['body']; |
| 3105 | 3480 | continue; |
@@ -3110,7 +3485,8 @@ discard block |
||
| 3110 | 3485 | $body .= ''; |
| 3111 | 3486 | continue; |
| 3112 | 3487 | } |
| 3113 | - if(!empty($body)) { |
|
| 3488 | + if(!empty($body)) |
|
| 3489 | + { |
|
| 3114 | 3490 | $body .= '<hr style="border:dotted 1px silver;">'; |
| 3115 | 3491 | } |
| 3116 | 3492 | //error_log($singleBodyPart['body']); |
@@ -3154,16 +3530,25 @@ discard block |
||
| 3154 | 3530 | $newBody = @htmlentities($singleBodyPart['body'],ENT_QUOTES, strtoupper(Mail::$displayCharset)); |
| 3155 | 3531 | //error_log(__METHOD__.__LINE__.'..'.$newBody); |
| 3156 | 3532 | // if empty and charset is utf8 try sanitizing the string in question |
| 3157 | - if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(Mail::$displayCharset)); |
|
| 3533 | + if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8') |
|
| 3534 | + { |
|
| 3535 | + $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(Mail::$displayCharset)); |
|
| 3536 | + } |
|
| 3158 | 3537 | // if the conversion to htmlentities fails somehow, try without specifying the charset, which defaults to iso- |
| 3159 | - if (empty($newBody)) $newBody = htmlentities($singleBodyPart['body'],ENT_QUOTES); |
|
| 3538 | + if (empty($newBody)) |
|
| 3539 | + { |
|
| 3540 | + $newBody = htmlentities($singleBodyPart['body'],ENT_QUOTES); |
|
| 3541 | + } |
|
| 3160 | 3542 | |
| 3161 | 3543 | // search http[s] links and make them as links available again |
| 3162 | 3544 | // to understand what's going on here, have a look at |
| 3163 | 3545 | // http://www.php.net/manual/en/function.preg-replace.php |
| 3164 | 3546 | |
| 3165 | 3547 | // create links for websites |
| 3166 | - if ($modifyURI) $newBody = Api\Html::activate_links($newBody); |
|
| 3548 | + if ($modifyURI) |
|
| 3549 | + { |
|
| 3550 | + $newBody = Api\Html::activate_links($newBody); |
|
| 3551 | + } |
|
| 3167 | 3552 | //error_log(__METHOD__.__LINE__.'..'.$newBody); |
| 3168 | 3553 | // redirect links for websites if you use no cookies |
| 3169 | 3554 | #if (!($GLOBALS['egw_info']['server']['usecookies'])) |
@@ -3205,10 +3590,13 @@ discard block |
||
| 3205 | 3590 | { |
| 3206 | 3591 | $newBody = $cleaned; |
| 3207 | 3592 | } |
| 3208 | - if (!$preserveHTML) // ToDo KL: $preserveHTML is NOT initialised, so always if is dead code |
|
| 3593 | + if (!$preserveHTML) |
|
| 3594 | + { |
|
| 3595 | + // ToDo KL: $preserveHTML is NOT initialised, so always if is dead code |
|
| 3209 | 3596 | { |
| 3210 | 3597 | // filter only the 'body', as we only want that part, if we throw away the Api\Html |
| 3211 | 3598 | preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array()); |
| 3599 | + } |
|
| 3212 | 3600 | if ($matches[2]) |
| 3213 | 3601 | { |
| 3214 | 3602 | $hasOther = true; |
@@ -3230,7 +3618,10 @@ discard block |
||
| 3230 | 3618 | // as we switched off HTMLaweds tidy functionality |
| 3231 | 3619 | $newBody = str_replace(array('&amp;','<DIV><BR></DIV>',"<DIV> </DIV>",'<div> </div>'),array('&','<BR>','<BR>','<BR>'),$newBody); |
| 3232 | 3620 | $newBody = $htmLawed->run($newBody,Mail::$htmLawed_config); |
| 3233 | - if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3]; |
|
| 3621 | + if ($hasOther && $preserveHTML) |
|
| 3622 | + { |
|
| 3623 | + $newBody = $matches[1]. $newBody. $matches[3]; |
|
| 3624 | + } |
|
| 3234 | 3625 | $alreadyHtmlLawed=true; |
| 3235 | 3626 | } |
| 3236 | 3627 | // do the cleanup, set for the use of purifier |
@@ -3335,7 +3726,10 @@ discard block |
||
| 3335 | 3726 | */ |
| 3336 | 3727 | $replace_callback = function ($matches) use ($_mailbox,$_uid, $_partID, $_type) |
| 3337 | 3728 | { |
| 3338 | - if (!$_type) return false; |
|
| 3729 | + if (!$_type) |
|
| 3730 | + { |
|
| 3731 | + return false; |
|
| 3732 | + } |
|
| 3339 | 3733 | $CID = ''; |
| 3340 | 3734 | // Build up matches according to selected type |
| 3341 | 3735 | switch ($_type) |
@@ -3378,9 +3772,12 @@ discard block |
||
| 3378 | 3772 | $attachment = $bo->getAttachmentByCID($_uid, $CID, $_partID); |
| 3379 | 3773 | |
| 3380 | 3774 | // only use data uri for "smaller" images, as otherwise the first display of the mail takes to long |
| 3381 | - if (($attachment instanceof Horde_Mime_Part) && $attachment->getBytes() < 8192) // msie=8 allows max 32k data uris |
|
| 3775 | + if (($attachment instanceof Horde_Mime_Part) && $attachment->getBytes() < 8192) |
|
| 3776 | + { |
|
| 3777 | + // msie=8 allows max 32k data uris |
|
| 3382 | 3778 | { |
| 3383 | 3779 | $bo->fetchPartContents($_uid, $attachment); |
| 3780 | + } |
|
| 3384 | 3781 | $cache[$imageURL] = 'data:'.$attachment->getType().';base64,'.base64_encode($attachment->getContents()); |
| 3385 | 3782 | } |
| 3386 | 3783 | else |
@@ -3452,7 +3849,10 @@ discard block |
||
| 3452 | 3849 | } |
| 3453 | 3850 | $destination = $content['FOLDER'][0]; |
| 3454 | 3851 | |
| 3455 | - if (stripos($destination,self::$delimiter)!==false) list($icServerID,$destination) = explode(self::$delimiter,$destination,2); |
|
| 3852 | + if (stripos($destination,self::$delimiter)!==false) |
|
| 3853 | + { |
|
| 3854 | + list($icServerID,$destination) = explode(self::$delimiter,$destination,2); |
|
| 3855 | + } |
|
| 3456 | 3856 | if ($icServerID && $icServerID != $this->mail_bo->profileID) |
| 3457 | 3857 | { |
| 3458 | 3858 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
@@ -3477,13 +3877,22 @@ discard block |
||
| 3477 | 3877 | if (!$importFailed) |
| 3478 | 3878 | { |
| 3479 | 3879 | list($width, $height) = explode('x', Link::get_registry('mail', 'add_popup')); |
| 3480 | - if ($width > 0 && $height > 0) Api\Json\Response::get()->call('resizeTo', $width, $height); |
|
| 3880 | + if ($width > 0 && $height > 0) |
|
| 3881 | + { |
|
| 3882 | + Api\Json\Response::get()->call('resizeTo', $width, $height); |
|
| 3883 | + } |
|
| 3481 | 3884 | ExecMethod2('mail.mail_ui.displayMessage',$linkData); |
| 3482 | 3885 | return; |
| 3483 | 3886 | } |
| 3484 | 3887 | } |
| 3485 | - if (!is_array($content)) $content = array(); |
|
| 3486 | - if (empty($content['FOLDER'])) $content['FOLDER']=(array)$this->mail_bo->getDraftFolder(); |
|
| 3888 | + if (!is_array($content)) |
|
| 3889 | + { |
|
| 3890 | + $content = array(); |
|
| 3891 | + } |
|
| 3892 | + if (empty($content['FOLDER'])) |
|
| 3893 | + { |
|
| 3894 | + $content['FOLDER']=(array)$this->mail_bo->getDraftFolder(); |
|
| 3895 | + } |
|
| 3487 | 3896 | if (!empty($content['FOLDER'])) |
| 3488 | 3897 | { |
| 3489 | 3898 | $compose = new mail_compose(); |
@@ -3508,7 +3917,10 @@ discard block |
||
| 3508 | 3917 | { |
| 3509 | 3918 | $importfailed = false; |
| 3510 | 3919 | //error_log(__METHOD__.__LINE__.array2string($_formData)); |
| 3511 | - if (empty($_formData['file'])) $_formData['file'] = $_formData['tmp_name']; |
|
| 3920 | + if (empty($_formData['file'])) |
|
| 3921 | + { |
|
| 3922 | + $_formData['file'] = $_formData['tmp_name']; |
|
| 3923 | + } |
|
| 3512 | 3924 | // check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.) |
| 3513 | 3925 | try |
| 3514 | 3926 | { |
@@ -3539,10 +3951,14 @@ discard block |
||
| 3539 | 3951 | $alert_msg .= lang("Import of message %1 failed. Destination Folder not set.",$_formData['name']); |
| 3540 | 3952 | } |
| 3541 | 3953 | $delimiter = $this->mail_bo->getHierarchyDelimiter(); |
| 3542 | - if($_folder=='INBOX'.$delimiter) $_folder='INBOX'; |
|
| 3954 | + if($_folder=='INBOX'.$delimiter) |
|
| 3955 | + { |
|
| 3956 | + $_folder='INBOX'; |
|
| 3957 | + } |
|
| 3543 | 3958 | if ($importfailed === false) |
| 3544 | 3959 | { |
| 3545 | - if ($this->mail_bo->folderExists($_folder,true)) { |
|
| 3960 | + if ($this->mail_bo->folderExists($_folder,true)) |
|
| 3961 | + { |
|
| 3546 | 3962 | try |
| 3547 | 3963 | { |
| 3548 | 3964 | $messageUid = $this->mail_bo->appendMessage($_folder, |
@@ -3603,7 +4019,10 @@ discard block |
||
| 3603 | 4019 | */ |
| 3604 | 4020 | function importMessageFromVFS2DraftAndDisplay($formData='',$mode='display') |
| 3605 | 4021 | { |
| 3606 | - if (empty($formData)) if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData']; |
|
| 4022 | + if (empty($formData)) |
|
| 4023 | + { |
|
| 4024 | + if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData']; |
|
| 4025 | + } |
|
| 3607 | 4026 | //error_log(__METHOD__.__LINE__.':'.array2string($formData).' Mode:'.$mode.'->'.function_backtrace()); |
| 3608 | 4027 | $draftFolder = $this->mail_bo->getDraftFolder(false); |
| 3609 | 4028 | $importID = Mail::getRandomString(); |
@@ -3617,15 +4036,26 @@ discard block |
||
| 3617 | 4036 | if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['name'])) |
| 3618 | 4037 | { |
| 3619 | 4038 | $buff = explode('/',$formData['file']); |
| 3620 | - if (is_array($buff)) $formData['name'] = array_pop($buff); // take the last part as name |
|
| 4039 | + if (is_array($buff)) |
|
| 4040 | + { |
|
| 4041 | + $formData['name'] = array_pop($buff); |
|
| 4042 | + } |
|
| 4043 | + // take the last part as name |
|
| 3621 | 4044 | } |
| 3622 | 4045 | // type should be set to meet the requirements of checkFileBasics |
| 3623 | 4046 | if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['type'])) |
| 3624 | 4047 | { |
| 3625 | 4048 | $buff = explode('.',$formData['file']); |
| 3626 | 4049 | $suffix = ''; |
| 3627 | - if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
|
| 3628 | - if (!empty($suffix)) $formData['type'] = Api\MimeMagic::ext2mime($suffix); |
|
| 4050 | + if (is_array($buff)) |
|
| 4051 | + { |
|
| 4052 | + $suffix = array_pop($buff); |
|
| 4053 | + } |
|
| 4054 | + // take the last extension to check with ext2mime |
|
| 4055 | + if (!empty($suffix)) |
|
| 4056 | + { |
|
| 4057 | + $formData['type'] = Api\MimeMagic::ext2mime($suffix); |
|
| 4058 | + } |
|
| 3629 | 4059 | } |
| 3630 | 4060 | // size should be set to meet the requirements of checkFileBasics |
| 3631 | 4061 | if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && !isset($formData['size'])) |
@@ -3668,17 +4098,35 @@ discard block |
||
| 3668 | 4098 | function loadEmailBody($_messageID=null,$_partID=null,$_htmloptions=null) |
| 3669 | 4099 | { |
| 3670 | 4100 | //error_log(__METHOD__.__LINE__.array2string($_GET)); |
| 3671 | - if (!$_messageID && !empty($_GET['_messageID'])) $_messageID = $_GET['_messageID']; |
|
| 3672 | - if (!$_partID && !empty($_GET['_partID'])) $_partID = $_GET['_partID']; |
|
| 3673 | - if (!$_htmloptions && !empty($_GET['_htmloptions'])) $_htmloptions = $_GET['_htmloptions']; |
|
| 3674 | - if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions"); |
|
| 3675 | - if (empty($_messageID)) return ""; |
|
| 4101 | + if (!$_messageID && !empty($_GET['_messageID'])) |
|
| 4102 | + { |
|
| 4103 | + $_messageID = $_GET['_messageID']; |
|
| 4104 | + } |
|
| 4105 | + if (!$_partID && !empty($_GET['_partID'])) |
|
| 4106 | + { |
|
| 4107 | + $_partID = $_GET['_partID']; |
|
| 4108 | + } |
|
| 4109 | + if (!$_htmloptions && !empty($_GET['_htmloptions'])) |
|
| 4110 | + { |
|
| 4111 | + $_htmloptions = $_GET['_htmloptions']; |
|
| 4112 | + } |
|
| 4113 | + if(Mail::$debug) |
|
| 4114 | + { |
|
| 4115 | + error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions"); |
|
| 4116 | + } |
|
| 4117 | + if (empty($_messageID)) |
|
| 4118 | + { |
|
| 4119 | + return ""; |
|
| 4120 | + } |
|
| 3676 | 4121 | $uidA = self::splitRowID($_messageID); |
| 3677 | 4122 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
| 3678 | 4123 | $messageID = $uidA['msgUID']; |
| 3679 | 4124 | $icServerID = $uidA['profileID']; |
| 3680 | 4125 | //something went wrong. there is a $_messageID but no $messageID: means $_messageID is crippeled |
| 3681 | - if (empty($messageID)) return ""; |
|
| 4126 | + if (empty($messageID)) |
|
| 4127 | + { |
|
| 4128 | + return ""; |
|
| 4129 | + } |
|
| 3682 | 4130 | if ($icServerID && $icServerID != $this->mail_bo->profileID) |
| 3683 | 4131 | { |
| 3684 | 4132 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
@@ -3711,7 +4159,11 @@ discard block |
||
| 3711 | 4159 | list($profileID,$folderName) = explode(self::$delimiter,$_folderName,2); |
| 3712 | 4160 | if (is_numeric($profileID)) |
| 3713 | 4161 | { |
| 3714 | - if ($profileID != $this->mail_bo->profileID) continue; // only current connection |
|
| 4162 | + if ($profileID != $this->mail_bo->profileID) |
|
| 4163 | + { |
|
| 4164 | + continue; |
|
| 4165 | + } |
|
| 4166 | + // only current connection |
|
| 3715 | 4167 | if ($folderName) |
| 3716 | 4168 | { |
| 3717 | 4169 | try |
@@ -3720,10 +4172,16 @@ discard block |
||
| 3720 | 4172 | } |
| 3721 | 4173 | catch (Exception $e) |
| 3722 | 4174 | { |
| 3723 | - if (Mail::$debug) error_log(__METHOD__,' ()'.$e->getMessage ()); |
|
| 4175 | + if (Mail::$debug) |
|
| 4176 | + { |
|
| 4177 | + error_log(__METHOD__,' ()'.$e->getMessage ()); |
|
| 4178 | + } |
|
| 3724 | 4179 | continue; |
| 3725 | 4180 | } |
| 3726 | - if (in_array($fS['shortDisplayName'],Mail::$autoFolders)) $fS['shortDisplayName']=lang($fS['shortDisplayName']); |
|
| 4181 | + if (in_array($fS['shortDisplayName'],Mail::$autoFolders)) |
|
| 4182 | + { |
|
| 4183 | + $fS['shortDisplayName']=lang($fS['shortDisplayName']); |
|
| 4184 | + } |
|
| 3727 | 4185 | //error_log(__METHOD__.__LINE__.array2string($fS)); |
| 3728 | 4186 | if ($fS['unseen']) |
| 3729 | 4187 | { |
@@ -3764,7 +4222,11 @@ discard block |
||
| 3764 | 4222 | list($profileID,$parentFolderName) = explode(self::$delimiter,$decodedFolderName,2); |
| 3765 | 4223 | if (is_numeric($profileID)) |
| 3766 | 4224 | { |
| 3767 | - if ($profileID != $this->mail_bo->profileID) return; // only current connection |
|
| 4225 | + if ($profileID != $this->mail_bo->profileID) |
|
| 4226 | + { |
|
| 4227 | + return; |
|
| 4228 | + } |
|
| 4229 | + // only current connection |
|
| 3768 | 4230 | $del = $this->mail_bo->getHierarchyDelimiter(false); |
| 3769 | 4231 | //$del = $prefix = ''; |
| 3770 | 4232 | //$nameSpace = $this->mail_bo->_getNameSpaces(); |
@@ -3804,7 +4266,10 @@ discard block |
||
| 3804 | 4266 | $nA = explode($del,$_newName); |
| 3805 | 4267 | |
| 3806 | 4268 | //error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName"); |
| 3807 | - if (!!empty($parentFolderName)) $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName,false); |
|
| 4269 | + if (!!empty($parentFolderName)) |
|
| 4270 | + { |
|
| 4271 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName,false); |
|
| 4272 | + } |
|
| 3808 | 4273 | //error_log(__METHOD__.__LINE__.array2string($oldFolderInfo)); |
| 3809 | 4274 | |
| 3810 | 4275 | $this->mail_bo->reopen('INBOX'); |
@@ -3825,9 +4290,15 @@ discard block |
||
| 3825 | 4290 | $errorMessage .= $error; |
| 3826 | 4291 | } |
| 3827 | 4292 | } |
| 3828 | - if ($c==count($nA)) $created=true; |
|
| 4293 | + if ($c==count($nA)) |
|
| 4294 | + { |
|
| 4295 | + $created=true; |
|
| 4296 | + } |
|
| 4297 | + } |
|
| 4298 | + if (!empty($parentName)) |
|
| 4299 | + { |
|
| 4300 | + $this->mail_bo->reopen($parentName); |
|
| 3829 | 4301 | } |
| 3830 | - if (!empty($parentName)) $this->mail_bo->reopen($parentName); |
|
| 3831 | 4302 | } |
| 3832 | 4303 | //error_log(__METHOD__.__LINE__.array2string($oA)); |
| 3833 | 4304 | if ($created===true) |
@@ -3863,7 +4334,10 @@ discard block |
||
| 3863 | 4334 | */ |
| 3864 | 4335 | function ajax_renameFolder($_folderName, $_newName) |
| 3865 | 4336 | { |
| 3866 | - if (Mail::$debug) error_log(__METHOD__.__LINE__.' OldFolderName:'.array2string($_folderName).' NewName:'.array2string($_newName)); |
|
| 4337 | + if (Mail::$debug) |
|
| 4338 | + { |
|
| 4339 | + error_log(__METHOD__.__LINE__.' OldFolderName:'.array2string($_folderName).' NewName:'.array2string($_newName)); |
|
| 4340 | + } |
|
| 3867 | 4341 | if ($_folderName) |
| 3868 | 4342 | { |
| 3869 | 4343 | Api\Translation::add_app('mail'); |
@@ -3875,7 +4349,10 @@ discard block |
||
| 3875 | 4349 | $hasChildren = false; |
| 3876 | 4350 | if (is_numeric($profileID)) |
| 3877 | 4351 | { |
| 3878 | - if ($profileID != $this->mail_bo->profileID) $this->changeProfile ($profileID); |
|
| 4352 | + if ($profileID != $this->mail_bo->profileID) |
|
| 4353 | + { |
|
| 4354 | + $this->changeProfile ($profileID); |
|
| 4355 | + } |
|
| 3879 | 4356 | $pA = explode($del,$folderName); |
| 3880 | 4357 | array_pop($pA); |
| 3881 | 4358 | $parentFolder = implode($del,$pA); |
@@ -4008,11 +4485,17 @@ discard block |
||
| 4008 | 4485 | $oldPrefForSubscribedOnly = !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']; |
| 4009 | 4486 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 4010 | 4487 | list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
| 4011 | - if ($profileID != $this->mail_bo->profileID) $this->changeProfile($profileID); |
|
| 4488 | + if ($profileID != $this->mail_bo->profileID) |
|
| 4489 | + { |
|
| 4490 | + $this->changeProfile($profileID); |
|
| 4491 | + } |
|
| 4012 | 4492 | |
| 4013 | 4493 | // if pref and required mode dont match -> reset the folderObject cache to ensure |
| 4014 | 4494 | // that we get what we request |
| 4015 | - if ($_subscribedOnly != $oldPrefForSubscribedOnly) $this->mail_bo->resetFolderObjectCache($profileID); |
|
| 4495 | + if ($_subscribedOnly != $oldPrefForSubscribedOnly) |
|
| 4496 | + { |
|
| 4497 | + $this->mail_bo->resetFolderObjectCache($profileID); |
|
| 4498 | + } |
|
| 4016 | 4499 | |
| 4017 | 4500 | if (!empty($folderName)) |
| 4018 | 4501 | { |
@@ -4088,14 +4571,20 @@ discard block |
||
| 4088 | 4571 | */ |
| 4089 | 4572 | function ajax_MoveFolder($_folderName, $_target) |
| 4090 | 4573 | { |
| 4091 | - if (Mail::$debug) error_log(__METHOD__.__LINE__."Move Folder: $_folderName to Target: $_target"); |
|
| 4574 | + if (Mail::$debug) |
|
| 4575 | + { |
|
| 4576 | + error_log(__METHOD__.__LINE__."Move Folder: $_folderName to Target: $_target"); |
|
| 4577 | + } |
|
| 4092 | 4578 | if ($_folderName) |
| 4093 | 4579 | { |
| 4094 | 4580 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 4095 | 4581 | $_newLocation2 = $this->mail_bo->decodeEntityFolderName($_target); |
| 4096 | 4582 | list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
| 4097 | 4583 | list($newProfileID,$_newLocation) = explode(self::$delimiter,$_newLocation2,2); |
| 4098 | - if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID) $this->changeProfile($profileID); |
|
| 4584 | + if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID) |
|
| 4585 | + { |
|
| 4586 | + $this->changeProfile($profileID); |
|
| 4587 | + } |
|
| 4099 | 4588 | $del = $this->mail_bo->getHierarchyDelimiter(false); |
| 4100 | 4589 | $hasChildren = false; |
| 4101 | 4590 | if (is_numeric($profileID)) |
@@ -4110,10 +4599,13 @@ discard block |
||
| 4110 | 4599 | (($oldParentFolder === $parentFolder) || //$oldParentFolder == $parentFolder means move on same level |
| 4111 | 4600 | (($oldParentFolder != $parentFolder && |
| 4112 | 4601 | strlen($parentFolder)>0 && strlen($folderName)>0 && |
| 4113 | - strpos($parentFolder,$folderName)===false)))) // indicates that we move the older up the tree within its own branch |
|
| 4602 | + strpos($parentFolder,$folderName)===false)))) |
|
| 4603 | + { |
|
| 4604 | + // indicates that we move the older up the tree within its own branch |
|
| 4114 | 4605 | { |
| 4115 | 4606 | //error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName"); |
| 4116 | 4607 | $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false); |
| 4608 | + } |
|
| 4117 | 4609 | //error_log(__METHOD__.__LINE__.array2string($oldFolderInfo)); |
| 4118 | 4610 | if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false) |
| 4119 | 4611 | { |
@@ -4196,8 +4688,14 @@ discard block |
||
| 4196 | 4688 | $profileID.self::$delimiter.$oldParentFolder=>$oldFolderInfo['shortDisplayName'], |
| 4197 | 4689 | $profileID.self::$delimiter.$parentFolder=>$folderInfo['shortDisplayName']); |
| 4198 | 4690 | // if we move the folder within the same parent-branch of the tree, there is no need no refresh the upper part |
| 4199 | - if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]); |
|
| 4200 | - if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]); |
|
| 4691 | + if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false) |
|
| 4692 | + { |
|
| 4693 | + unset($refreshData[$profileID.self::$delimiter.$parentFolder]); |
|
| 4694 | + } |
|
| 4695 | + if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false) |
|
| 4696 | + { |
|
| 4697 | + unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]); |
|
| 4698 | + } |
|
| 4201 | 4699 | |
| 4202 | 4700 | // Send full info back in the response |
| 4203 | 4701 | foreach($refreshData as $folder => &$name) |
@@ -4229,7 +4727,10 @@ discard block |
||
| 4229 | 4727 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 4230 | 4728 | $oA = array(); |
| 4231 | 4729 | list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
| 4232 | - if (is_numeric($profileID) && $profileID != $this->mail_bo->profileID) $this->changeProfile ($profileID); |
|
| 4730 | + if (is_numeric($profileID) && $profileID != $this->mail_bo->profileID) |
|
| 4731 | + { |
|
| 4732 | + $this->changeProfile ($profileID); |
|
| 4733 | + } |
|
| 4233 | 4734 | $del = $this->mail_bo->getHierarchyDelimiter(false); |
| 4234 | 4735 | $hasChildren = false; |
| 4235 | 4736 | if (is_numeric($profileID)) |
@@ -4259,7 +4760,9 @@ discard block |
||
| 4259 | 4760 | } |
| 4260 | 4761 | krsort($ftD,SORT_NUMERIC);//sort per level |
| 4261 | 4762 | //we iterate per level of depth of the subtree, deepest nesting is to be deleted first, and then up the tree |
| 4262 | - foreach($ftD as $k => $lc)//collection per level |
|
| 4763 | + foreach($ftD as $k => $lc) |
|
| 4764 | + { |
|
| 4765 | + //collection per level |
|
| 4263 | 4766 | { |
| 4264 | 4767 | foreach($lc as $f)//folders contained in that level |
| 4265 | 4768 | { |
@@ -4267,8 +4770,12 @@ discard block |
||
| 4267 | 4770 | { |
| 4268 | 4771 | //error_log(__METHOD__.__LINE__.array2string($f).'<->'.$folderName); |
| 4269 | 4772 | $this->mail_bo->deleteFolder($f); |
| 4773 | + } |
|
| 4270 | 4774 | $success = true; |
| 4271 | - if ($f==$folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName']; |
|
| 4775 | + if ($f==$folderName) |
|
| 4776 | + { |
|
| 4777 | + $oA[$_folderName] = $oldFolderInfo['shortDisplayName']; |
|
| 4778 | + } |
|
| 4272 | 4779 | } |
| 4273 | 4780 | catch (Exception $e) |
| 4274 | 4781 | { |
@@ -4298,7 +4805,10 @@ discard block |
||
| 4298 | 4805 | $msg = lang("refused to delete folder INBOX"); |
| 4299 | 4806 | } |
| 4300 | 4807 | } |
| 4301 | - if ($_return) return $success; |
|
| 4808 | + if ($_return) |
|
| 4809 | + { |
|
| 4810 | + return $success; |
|
| 4811 | + } |
|
| 4302 | 4812 | $response = Api\Json\Response::get(); |
| 4303 | 4813 | if ($success) |
| 4304 | 4814 | { |
@@ -4374,24 +4884,35 @@ discard block |
||
| 4374 | 4884 | // Create mail app object |
| 4375 | 4885 | $mail = new mail_ui(); |
| 4376 | 4886 | |
| 4377 | - if (empty($icServerID)) $icServerID = $mail->Mail->profileID; |
|
| 4378 | - if ($icServerID != $mail->Mail->profileID) return; |
|
| 4887 | + if (empty($icServerID)) |
|
| 4888 | + { |
|
| 4889 | + $icServerID = $mail->Mail->profileID; |
|
| 4890 | + } |
|
| 4891 | + if ($icServerID != $mail->Mail->profileID) |
|
| 4892 | + { |
|
| 4893 | + return; |
|
| 4894 | + } |
|
| 4379 | 4895 | |
| 4380 | 4896 | $vacation = $mail->gatherVacation($cachedVacations); |
| 4381 | - } catch (Exception $e) { |
|
| 4897 | + } |
|
| 4898 | + catch (Exception $e) { |
|
| 4382 | 4899 | $vacation=false; |
| 4383 | 4900 | error_log(__METHOD__.__LINE__." ".$e->getMessage()); |
| 4384 | 4901 | unset($e); |
| 4385 | 4902 | } |
| 4386 | 4903 | } |
| 4387 | 4904 | |
| 4388 | - if($vacation) { |
|
| 4905 | + if($vacation) |
|
| 4906 | + { |
|
| 4389 | 4907 | if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date')) |
| 4390 | 4908 | { |
| 4391 | 4909 | $dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']; |
| 4392 | 4910 | $refreshData['vacationnotice'] = lang('Vacation notice is active'); |
| 4393 | 4911 | $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):''):''); |
| 4394 | - if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time())$refreshData = ''; |
|
| 4912 | + if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time()) |
|
| 4913 | + { |
|
| 4914 | + $refreshData = ''; |
|
| 4915 | + } |
|
| 4395 | 4916 | } |
| 4396 | 4917 | } |
| 4397 | 4918 | if ($vacation==false) |
@@ -4413,11 +4934,17 @@ discard block |
||
| 4413 | 4934 | function ajax_refreshFilters($icServerID=null) |
| 4414 | 4935 | { |
| 4415 | 4936 | //error_log(__METHOD__.__LINE__.array2string($icServerId)); |
| 4416 | - if (empty($icServerID)) $icServerID = $this->mail_bo->profileID; |
|
| 4937 | + if (empty($icServerID)) |
|
| 4938 | + { |
|
| 4939 | + $icServerID = $this->mail_bo->profileID; |
|
| 4940 | + } |
|
| 4417 | 4941 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
| 4418 | 4942 | { |
| 4419 | 4943 | Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
| 4420 | - if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 4944 | + if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
|
| 4945 | + { |
|
| 4946 | + Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 4947 | + } |
|
| 4421 | 4948 | } |
| 4422 | 4949 | if (!Mail::$supportsORinQuery[$this->mail_bo->profileID]) |
| 4423 | 4950 | { |
@@ -4439,7 +4966,10 @@ discard block |
||
| 4439 | 4966 | $keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5'); |
| 4440 | 4967 | foreach($keywords as &$k) |
| 4441 | 4968 | { |
| 4442 | - if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]); |
|
| 4969 | + if (array_key_exists($k,$this->statusTypes)) |
|
| 4970 | + { |
|
| 4971 | + unset($this->statusTypes[$k]); |
|
| 4972 | + } |
|
| 4443 | 4973 | } |
| 4444 | 4974 | } |
| 4445 | 4975 | |
@@ -4461,7 +4991,10 @@ discard block |
||
| 4461 | 4991 | function ajax_refreshQuotaDisplay($icServerID=null) |
| 4462 | 4992 | { |
| 4463 | 4993 | Api\Translation::add_app('mail'); |
| 4464 | - if (is_null($icServerID)) $icServerID = $this->mail_bo->profileID; |
|
| 4994 | + if (is_null($icServerID)) |
|
| 4995 | + { |
|
| 4996 | + $icServerID = $this->mail_bo->profileID; |
|
| 4997 | + } |
|
| 4465 | 4998 | $rememberServerID = $this->mail_bo->profileID; |
| 4466 | 4999 | try |
| 4467 | 5000 | { |
@@ -4470,13 +5003,15 @@ discard block |
||
| 4470 | 5003 | $this->changeProfile($icServerID); |
| 4471 | 5004 | } |
| 4472 | 5005 | $quota = $this->mail_bo->getQuotaRoot(); |
| 4473 | - } catch (Exception $e) { |
|
| 5006 | + } |
|
| 5007 | + catch (Exception $e) { |
|
| 4474 | 5008 | $quota['limit'] = 'NOT SET'; |
| 4475 | 5009 | error_log(__METHOD__.__LINE__." ".$e->getMessage()); |
| 4476 | 5010 | unset($e); |
| 4477 | 5011 | } |
| 4478 | 5012 | |
| 4479 | - if($quota !== false && $quota['limit'] != 'NOT SET') { |
|
| 5013 | + if($quota !== false && $quota['limit'] != 'NOT SET') |
|
| 5014 | + { |
|
| 4480 | 5015 | $quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']); |
| 4481 | 5016 | $quotaMin = $quotainfo['freespace']/pow(1024, 2); |
| 4482 | 5017 | $content = array ( |
@@ -4501,7 +5036,8 @@ discard block |
||
| 4501 | 5036 | try |
| 4502 | 5037 | { |
| 4503 | 5038 | $this->changeProfile($rememberServerID); |
| 4504 | - } catch (Exception $e) { |
|
| 5039 | + } |
|
| 5040 | + catch (Exception $e) { |
|
| 4505 | 5041 | unset($e); |
| 4506 | 5042 | } |
| 4507 | 5043 | } |
@@ -4528,7 +5064,8 @@ discard block |
||
| 4528 | 5064 | $this->changeProfile($icServerID); |
| 4529 | 5065 | } |
| 4530 | 5066 | $junkFolder = $this->mail_bo->getJunkFolder(); |
| 4531 | - if(!empty($junkFolder)) { |
|
| 5067 | + if(!empty($junkFolder)) |
|
| 5068 | + { |
|
| 4532 | 5069 | if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder) |
| 4533 | 5070 | { |
| 4534 | 5071 | // Lock the tree if the active folder is junk folder |
@@ -4578,7 +5115,8 @@ discard block |
||
| 4578 | 5115 | $this->changeProfile($icServerID); |
| 4579 | 5116 | } |
| 4580 | 5117 | $trashFolder = $this->mail_bo->getTrashFolder(); |
| 4581 | - if(!empty($trashFolder)) { |
|
| 5118 | + if(!empty($trashFolder)) |
|
| 5119 | + { |
|
| 4582 | 5120 | if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder) |
| 4583 | 5121 | { |
| 4584 | 5122 | // Lock the tree if the active folder is Trash folder |
@@ -4624,7 +5162,10 @@ discard block |
||
| 4624 | 5162 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 4625 | 5163 | list($icServerID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
| 4626 | 5164 | |
| 4627 | - if (empty($folderName)) $folderName = $this->mail_bo->sessionData['mailbox']; |
|
| 5165 | + if (empty($folderName)) |
|
| 5166 | + { |
|
| 5167 | + $folderName = $this->mail_bo->sessionData['mailbox']; |
|
| 5168 | + } |
|
| 4628 | 5169 | if ($this->mail_bo->folderExists($folderName)) |
| 4629 | 5170 | { |
| 4630 | 5171 | $rememberServerID = $this->mail_bo->profileID; |
@@ -4633,7 +5174,8 @@ discard block |
||
| 4633 | 5174 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
| 4634 | 5175 | $this->changeProfile($icServerID); |
| 4635 | 5176 | } |
| 4636 | - if(!empty($_folderName)) { |
|
| 5177 | + if(!empty($_folderName)) |
|
| 5178 | + { |
|
| 4637 | 5179 | $this->mail_bo->compressFolder($folderName); |
| 4638 | 5180 | } |
| 4639 | 5181 | if ($rememberServerID != $this->mail_bo->profileID) |
@@ -4655,7 +5197,10 @@ discard block |
||
| 4655 | 5197 | */ |
| 4656 | 5198 | function ajax_sendMDN($_messageList) |
| 4657 | 5199 | { |
| 4658 | - if(Mail::$debug) error_log(__METHOD__."->".array2string($_messageList)); |
|
| 5200 | + if(Mail::$debug) |
|
| 5201 | + { |
|
| 5202 | + error_log(__METHOD__."->".array2string($_messageList)); |
|
| 5203 | + } |
|
| 4659 | 5204 | $uidA = self::splitRowID($_messageList['msg'][0]); |
| 4660 | 5205 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
| 4661 | 5206 | $this->mail_bo->sendMDN($uidA['msgUID'],$folder); |
@@ -4672,7 +5217,10 @@ discard block |
||
| 4672 | 5217 | */ |
| 4673 | 5218 | function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse=true) |
| 4674 | 5219 | { |
| 4675 | - if(Mail::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList)); |
|
| 5220 | + if(Mail::$debug) |
|
| 5221 | + { |
|
| 5222 | + error_log(__METHOD__."->".$_flag.':'.array2string($_messageList)); |
|
| 5223 | + } |
|
| 4676 | 5224 | Api\Translation::add_app('mail'); |
| 4677 | 5225 | $alreadyFlagged=false; |
| 4678 | 5226 | $flag2check=''; |
@@ -4693,12 +5241,23 @@ discard block |
||
| 4693 | 5241 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
| 4694 | 5242 | { |
| 4695 | 5243 | Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
| 4696 | - if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 5244 | + if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
|
| 5245 | + { |
|
| 5246 | + Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 5247 | + } |
|
| 4697 | 5248 | } |
| 4698 | 5249 | //error_log(__METHOD__.__LINE__.' Startdate:'.$query['startdate'].' Enddate'.$query['enddate']); |
| 4699 | 5250 | $cutoffdate = $cutoffdate2 = null; |
| 4700 | - if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate |
|
| 4701 | - if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate |
|
| 5251 | + if ($query['startdate']) |
|
| 5252 | + { |
|
| 5253 | + $cutoffdate = Api\DateTime::to($query['startdate'],'ts'); |
|
| 5254 | + } |
|
| 5255 | + //SINCE, enddate |
|
| 5256 | + if ($query['enddate']) |
|
| 5257 | + { |
|
| 5258 | + $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts'); |
|
| 5259 | + } |
|
| 5260 | + //BEFORE, startdate |
|
| 4702 | 5261 | //error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate); |
| 4703 | 5262 | $filter = array( |
| 4704 | 5263 | 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')), |
@@ -4707,15 +5266,24 @@ discard block |
||
| 4707 | 5266 | 'status' => 'any',//this is a status change. status will be manipulated later on |
| 4708 | 5267 | //'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2) |
| 4709 | 5268 | ); |
| 4710 | - if ($query['enddate']||$query['startdate']) { |
|
| 5269 | + if ($query['enddate']||$query['startdate']) |
|
| 5270 | + { |
|
| 4711 | 5271 | $filter['range'] = "BETWEEN"; |
| 4712 | - if ($cutoffdate) { |
|
| 5272 | + if ($cutoffdate) |
|
| 5273 | + { |
|
| 4713 | 5274 | $filter[(empty($cutoffdate2)?'date':'since')] = date("d-M-Y", $cutoffdate); |
| 4714 | - if (empty($cutoffdate2)) $filter['range'] = "SINCE"; |
|
| 5275 | + if (empty($cutoffdate2)) |
|
| 5276 | + { |
|
| 5277 | + $filter['range'] = "SINCE"; |
|
| 5278 | + } |
|
| 4715 | 5279 | } |
| 4716 | - if ($cutoffdate2) { |
|
| 5280 | + if ($cutoffdate2) |
|
| 5281 | + { |
|
| 4717 | 5282 | $filter[(empty($cutoffdate)?'date':'before')] = date("d-M-Y", $cutoffdate2); |
| 4718 | - if (empty($cutoffdate)) $filter['range'] = "BEFORE"; |
|
| 5283 | + if (empty($cutoffdate)) |
|
| 5284 | + { |
|
| 5285 | + $filter['range'] = "BEFORE"; |
|
| 5286 | + } |
|
| 4719 | 5287 | } |
| 4720 | 5288 | } |
| 4721 | 5289 | $filter2toggle = $filter; |
@@ -4766,13 +5334,19 @@ discard block |
||
| 4766 | 5334 | if (count($messageListForToggle)>0) |
| 4767 | 5335 | { |
| 4768 | 5336 | $flag2set = (strtolower($_flag)); |
| 4769 | - if(Mail::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle)); |
|
| 5337 | + if(Mail::$debug) |
|
| 5338 | + { |
|
| 5339 | + error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle)); |
|
| 5340 | + } |
|
| 4770 | 5341 | $this->mail_bo->flagMessages($flag2set, $messageListForToggle,$folder); |
| 4771 | 5342 | } |
| 4772 | 5343 | if (count($messageList)>0) |
| 4773 | 5344 | { |
| 4774 | 5345 | $flag2set = 'un'.$_flag; |
| 4775 | - if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList)); |
|
| 5346 | + if(Mail::$debug) |
|
| 5347 | + { |
|
| 5348 | + error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList)); |
|
| 5349 | + } |
|
| 4776 | 5350 | $this->mail_bo->flagMessages($flag2set, $messageList,$folder); |
| 4777 | 5351 | } |
| 4778 | 5352 | $alreadyFlagged=true; |
@@ -4788,7 +5362,10 @@ discard block |
||
| 4788 | 5362 | // since we toggle and we toggle by the filtered flag we must must change _flag |
| 4789 | 5363 | $_flag = ($query['filter']=='unseen' && $_flag=='read' ? 'read' : ($query['filter']=='seen'&& $_flag=='read'?'unread':($_flag==$query['filter']?'un'.$_flag:$_flag))); |
| 4790 | 5364 | } |
| 4791 | - if(Mail::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter)); |
|
| 5365 | + if(Mail::$debug) |
|
| 5366 | + { |
|
| 5367 | + error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter)); |
|
| 5368 | + } |
|
| 4792 | 5369 | $rByUid = true; |
| 4793 | 5370 | $reverse = 1; |
| 4794 | 5371 | $_sR = $this->mail_bo->getSortedList( |
@@ -4805,7 +5382,10 @@ discard block |
||
| 4805 | 5382 | } |
| 4806 | 5383 | else |
| 4807 | 5384 | { |
| 4808 | - if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter)); |
|
| 5385 | + if(Mail::$debug) |
|
| 5386 | + { |
|
| 5387 | + error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter)); |
|
| 5388 | + } |
|
| 4809 | 5389 | $alreadyFlagged=true; |
| 4810 | 5390 | $uidA = self::splitRowID($_messageList['msg'][0]); |
| 4811 | 5391 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
@@ -4825,13 +5405,19 @@ discard block |
||
| 4825 | 5405 | $hA = self::splitRowID($rowID); |
| 4826 | 5406 | $messageList[] = $hA['msgUID']; |
| 4827 | 5407 | } |
| 4828 | - if(Mail::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList))); |
|
| 5408 | + if(Mail::$debug) |
|
| 5409 | + { |
|
| 5410 | + error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList))); |
|
| 5411 | + } |
|
| 4829 | 5412 | $this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList),$folder); |
| 4830 | 5413 | } |
| 4831 | 5414 | } |
| 4832 | 5415 | else |
| 4833 | 5416 | { |
| 4834 | - if(Mail::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 5417 | + if(Mail::$debug) |
|
| 5418 | + { |
|
| 5419 | + error_log(__METHOD__."-> No messages selected."); |
|
| 5420 | + } |
|
| 4835 | 5421 | } |
| 4836 | 5422 | |
| 4837 | 5423 | if ($_sendJsonResponse) |
@@ -4868,7 +5454,10 @@ discard block |
||
| 4868 | 5454 | */ |
| 4869 | 5455 | function ajax_deleteMessages($_messageList,$_forceDeleteMethod=null) |
| 4870 | 5456 | { |
| 4871 | - if(Mail::$debug) error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod); |
|
| 5457 | + if(Mail::$debug) |
|
| 5458 | + { |
|
| 5459 | + error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod); |
|
| 5460 | + } |
|
| 4872 | 5461 | $error = null; |
| 4873 | 5462 | $filtered = false; |
| 4874 | 5463 | if ($_messageList=='all' || !empty($_messageList['msg'])) |
@@ -4887,12 +5476,23 @@ discard block |
||
| 4887 | 5476 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
| 4888 | 5477 | { |
| 4889 | 5478 | Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
| 4890 | - if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 5479 | + if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
|
| 5480 | + { |
|
| 5481 | + Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 5482 | + } |
|
| 4891 | 5483 | } |
| 4892 | 5484 | $filtered = true; |
| 4893 | 5485 | $cutoffdate = $cutoffdate2 = null; |
| 4894 | - if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate |
|
| 4895 | - if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate |
|
| 5486 | + if ($query['startdate']) |
|
| 5487 | + { |
|
| 5488 | + $cutoffdate = Api\DateTime::to($query['startdate'],'ts'); |
|
| 5489 | + } |
|
| 5490 | + //SINCE, enddate |
|
| 5491 | + if ($query['enddate']) |
|
| 5492 | + { |
|
| 5493 | + $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts'); |
|
| 5494 | + } |
|
| 5495 | + //BEFORE, startdate |
|
| 4896 | 5496 | //error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate); |
| 4897 | 5497 | $filter = array( |
| 4898 | 5498 | 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')), |
@@ -4901,15 +5501,24 @@ discard block |
||
| 4901 | 5501 | 'status' => (!empty($query['filter'])?$query['filter']:'any'), |
| 4902 | 5502 | //'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2) |
| 4903 | 5503 | ); |
| 4904 | - if ($query['enddate']||$query['startdate']) { |
|
| 5504 | + if ($query['enddate']||$query['startdate']) |
|
| 5505 | + { |
|
| 4905 | 5506 | $filter['range'] = "BETWEEN"; |
| 4906 | - if ($cutoffdate) { |
|
| 5507 | + if ($cutoffdate) |
|
| 5508 | + { |
|
| 4907 | 5509 | $filter[(empty($cutoffdate2)?'date':'since')] = date("d-M-Y", $cutoffdate); |
| 4908 | - if (empty($cutoffdate2)) $filter['range'] = "SINCE"; |
|
| 5510 | + if (empty($cutoffdate2)) |
|
| 5511 | + { |
|
| 5512 | + $filter['range'] = "SINCE"; |
|
| 5513 | + } |
|
| 4909 | 5514 | } |
| 4910 | - if ($cutoffdate2) { |
|
| 5515 | + if ($cutoffdate2) |
|
| 5516 | + { |
|
| 4911 | 5517 | $filter[(empty($cutoffdate)?'date':'before')] = date("d-M-Y", $cutoffdate2); |
| 4912 | - if (empty($cutoffdate)) $filter['range'] = "BEFORE"; |
|
| 5518 | + if (empty($cutoffdate)) |
|
| 5519 | + { |
|
| 5520 | + $filter['range'] = "BEFORE"; |
|
| 5521 | + } |
|
| 4913 | 5522 | } |
| 4914 | 5523 | } |
| 4915 | 5524 | } |
@@ -4976,7 +5585,10 @@ discard block |
||
| 4976 | 5585 | } |
| 4977 | 5586 | else |
| 4978 | 5587 | { |
| 4979 | - if(Mail::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 5588 | + if(Mail::$debug) |
|
| 5589 | + { |
|
| 5590 | + error_log(__METHOD__."-> No messages selected."); |
|
| 5591 | + } |
|
| 4980 | 5592 | } |
| 4981 | 5593 | } |
| 4982 | 5594 | |
@@ -4994,11 +5606,17 @@ discard block |
||
| 4994 | 5606 | */ |
| 4995 | 5607 | function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove='copy', $_move2ArchiveMarker='_', $_return = false) |
| 4996 | 5608 | { |
| 4997 | - if(Mail::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker); |
|
| 5609 | + if(Mail::$debug) |
|
| 5610 | + { |
|
| 5611 | + error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove.' ArchiveMarker:'.$_move2ArchiveMarker); |
|
| 5612 | + } |
|
| 4998 | 5613 | Api\Translation::add_app('mail'); |
| 4999 | 5614 | $folderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 5000 | 5615 | // only copy or move are supported as method |
| 5001 | - if (!($_copyOrMove=='copy' || $_copyOrMove=='move')) $_copyOrMove='copy'; |
|
| 5616 | + if (!($_copyOrMove=='copy' || $_copyOrMove=='move')) |
|
| 5617 | + { |
|
| 5618 | + $_copyOrMove='copy'; |
|
| 5619 | + } |
|
| 5002 | 5620 | list($targetProfileID,$targetFolder) = explode(self::$delimiter,$folderName,2); |
| 5003 | 5621 | // check if move2archive was called with the correct archiveFolder |
| 5004 | 5622 | $archiveFolder = $this->mail_bo->getArchiveFolder(); |
@@ -5021,8 +5639,13 @@ discard block |
||
| 5021 | 5639 | $keys = array_keys($lastFoldersUsedForMoveCont[$targetProfileID]); |
| 5022 | 5640 | foreach( $keys as &$f) |
| 5023 | 5641 | { |
| 5024 | - if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]); |
|
| 5025 | - else break; |
|
| 5642 | + if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9) |
|
| 5643 | + { |
|
| 5644 | + unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]); |
|
| 5645 | + } |
|
| 5646 | + else { |
|
| 5647 | + break; |
|
| 5648 | + } |
|
| 5026 | 5649 | } |
| 5027 | 5650 | //error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID])); |
| 5028 | 5651 | } |
@@ -5049,12 +5672,23 @@ discard block |
||
| 5049 | 5672 | if (is_null(Mail::$supportsORinQuery) || !isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
| 5050 | 5673 | { |
| 5051 | 5674 | Mail::$supportsORinQuery = Api\Cache::getCache(Api\Cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
| 5052 | - if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 5675 | + if (!isset(Mail::$supportsORinQuery[$this->mail_bo->profileID])) |
|
| 5676 | + { |
|
| 5677 | + Mail::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 5678 | + } |
|
| 5053 | 5679 | } |
| 5054 | 5680 | $filtered = true; |
| 5055 | 5681 | $cutoffdate = $cutoffdate2 = null; |
| 5056 | - if ($query['startdate']) $cutoffdate = Api\DateTime::to($query['startdate'],'ts');//SINCE, enddate |
|
| 5057 | - if ($query['enddate']) $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts');//BEFORE, startdate |
|
| 5682 | + if ($query['startdate']) |
|
| 5683 | + { |
|
| 5684 | + $cutoffdate = Api\DateTime::to($query['startdate'],'ts'); |
|
| 5685 | + } |
|
| 5686 | + //SINCE, enddate |
|
| 5687 | + if ($query['enddate']) |
|
| 5688 | + { |
|
| 5689 | + $cutoffdate2 = Api\DateTime::to($query['enddate'],'ts'); |
|
| 5690 | + } |
|
| 5691 | + //BEFORE, startdate |
|
| 5058 | 5692 | //error_log(__METHOD__.__LINE__.' Startdate:'.$cutoffdate2.' Enddate'.$cutoffdate); |
| 5059 | 5693 | $filter = array( |
| 5060 | 5694 | 'filterName' => (Mail::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')), |
@@ -5063,15 +5697,24 @@ discard block |
||
| 5063 | 5697 | 'status' => (!empty($query['filter'])?$query['filter']:'any'), |
| 5064 | 5698 | //'range'=>"BETWEEN",'since'=> date("d-M-Y", $cutoffdate),'before'=> date("d-M-Y", $cutoffdate2) |
| 5065 | 5699 | ); |
| 5066 | - if ($query['enddate']||$query['startdate']) { |
|
| 5700 | + if ($query['enddate']||$query['startdate']) |
|
| 5701 | + { |
|
| 5067 | 5702 | $filter['range'] = "BETWEEN"; |
| 5068 | - if ($cutoffdate) { |
|
| 5703 | + if ($cutoffdate) |
|
| 5704 | + { |
|
| 5069 | 5705 | $filter[(empty($cutoffdate2)?'date':'since')] = date("d-M-Y", $cutoffdate); |
| 5070 | - if (empty($cutoffdate2)) $filter['range'] = "SINCE"; |
|
| 5706 | + if (empty($cutoffdate2)) |
|
| 5707 | + { |
|
| 5708 | + $filter['range'] = "SINCE"; |
|
| 5709 | + } |
|
| 5071 | 5710 | } |
| 5072 | - if ($cutoffdate2) { |
|
| 5711 | + if ($cutoffdate2) |
|
| 5712 | + { |
|
| 5073 | 5713 | $filter[(empty($cutoffdate)?'date':'before')] = date("d-M-Y", $cutoffdate2); |
| 5074 | - if (empty($cutoffdate)) $filter['range'] = "BEFORE"; |
|
| 5714 | + if (empty($cutoffdate)) |
|
| 5715 | + { |
|
| 5716 | + $filter['range'] = "BEFORE"; |
|
| 5717 | + } |
|
| 5075 | 5718 | } |
| 5076 | 5719 | } |
| 5077 | 5720 | } |
@@ -5127,7 +5770,10 @@ discard block |
||
| 5127 | 5770 | $hA = self::splitRowID($rowID); |
| 5128 | 5771 | |
| 5129 | 5772 | // If folder changes, stop and move what we've got |
| 5130 | - if($hA['folder'] != $folder) break; |
|
| 5773 | + if($hA['folder'] != $folder) |
|
| 5774 | + { |
|
| 5775 | + break; |
|
| 5776 | + } |
|
| 5131 | 5777 | |
| 5132 | 5778 | array_shift($_messageList['msg']); |
| 5133 | 5779 | $messageList[] = $hA['msgUID']; |
@@ -5159,7 +5805,10 @@ discard block |
||
| 5159 | 5805 | unset($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]); |
| 5160 | 5806 | $changeFolderActions = true; |
| 5161 | 5807 | } |
| 5162 | - if ($_return) return $error; |
|
| 5808 | + if ($_return) |
|
| 5809 | + { |
|
| 5810 | + return $error; |
|
| 5811 | + } |
|
| 5163 | 5812 | $response->call('egw.message',$error,"error"); |
| 5164 | 5813 | } |
| 5165 | 5814 | else |
@@ -5167,13 +5816,19 @@ discard block |
||
| 5167 | 5816 | if ($_copyOrMove=='copy') |
| 5168 | 5817 | { |
| 5169 | 5818 | $msg = lang('copied %1 message(s) from %2 to %3',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($messageList)),$folder,$targetFolder); |
| 5170 | - if ($_return) return $msg; |
|
| 5819 | + if ($_return) |
|
| 5820 | + { |
|
| 5821 | + return $msg; |
|
| 5822 | + } |
|
| 5171 | 5823 | $response->call('egw.message',$msg); |
| 5172 | 5824 | } |
| 5173 | 5825 | else |
| 5174 | 5826 | { |
| 5175 | 5827 | $msg = lang('moved %1 message(s) from %2 to %3',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($messageList)),$folder,$targetFolder); |
| 5176 | - if ($_return) return $msg; |
|
| 5828 | + if ($_return) |
|
| 5829 | + { |
|
| 5830 | + return $msg; |
|
| 5831 | + } |
|
| 5177 | 5832 | $response->call('egw.refresh',$msg,'mail',$messageListForRefresh,'delete'); |
| 5178 | 5833 | } |
| 5179 | 5834 | } |
@@ -5187,7 +5842,10 @@ discard block |
||
| 5187 | 5842 | } |
| 5188 | 5843 | else |
| 5189 | 5844 | { |
| 5190 | - if(Mail::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 5845 | + if(Mail::$debug) |
|
| 5846 | + { |
|
| 5847 | + error_log(__METHOD__."-> No messages selected."); |
|
| 5848 | + } |
|
| 5191 | 5849 | } |
| 5192 | 5850 | } |
| 5193 | 5851 | |