@@ -1541,7 +1541,7 @@ discard block |
||
| 1541 | 1541 | * function splitRowID - split the rowID into its parts |
| 1542 | 1542 | * |
| 1543 | 1543 | * @param string $_rowID string - a colon separated string in the form accountID:profileID:folder:message_uid |
| 1544 | - * @return array populated named result array (accountID,profileID,folder,msgUID) |
|
| 1544 | + * @return string populated named result array (accountID,profileID,folder,msgUID) |
|
| 1545 | 1545 | */ |
| 1546 | 1546 | static function splitRowID($_rowID) |
| 1547 | 1547 | { |
@@ -1623,9 +1623,9 @@ discard block |
||
| 1623 | 1623 | * function header2gridelements - to populate the grid elements with the collected Data |
| 1624 | 1624 | * |
| 1625 | 1625 | * @param array $_headers headerdata to process |
| 1626 | - * @param array $cols cols to populate |
|
| 1626 | + * @param string[] $cols cols to populate |
|
| 1627 | 1627 | * @param array $_folderName to ensure the uniqueness of the uid over all folders |
| 1628 | - * @param array $_folderType used to determine if we need to populate from/to |
|
| 1628 | + * @param integer $_folderType used to determine if we need to populate from/to |
|
| 1629 | 1629 | * @return array populated result array |
| 1630 | 1630 | */ |
| 1631 | 1631 | public function header2gridelements($_headers, $cols, $_folderName, $_folderType=0) |
@@ -2863,6 +2863,9 @@ discard block |
||
| 2863 | 2863 | return $GLOBALS['egw']->framework->header(); |
| 2864 | 2864 | } |
| 2865 | 2865 | |
| 2866 | + /** |
|
| 2867 | + * @param string $body |
|
| 2868 | + */ |
|
| 2866 | 2869 | function showBody(&$body, $print=true,$fullPageTags=true) |
| 2867 | 2870 | { |
| 2868 | 2871 | $BeginBody = '<div class="mailDisplayBody"> |
@@ -3099,9 +3102,9 @@ discard block |
||
| 3099 | 3102 | * Replace CID with proper type of content understandable by browser |
| 3100 | 3103 | * |
| 3101 | 3104 | * @param type $_body content of message |
| 3102 | - * @param type $_mailbox mail box |
|
| 3103 | - * @param type $_uid uid |
|
| 3104 | - * @param type $_partID part id |
|
| 3105 | + * @param string $_mailbox mail box |
|
| 3106 | + * @param string $_uid uid |
|
| 3107 | + * @param string $_partID part id |
|
| 3105 | 3108 | * @param type $_type = 'src' type of inline image that needs to be resolved and replaced |
| 3106 | 3109 | * - types: {plain|src|url|background} |
| 3107 | 3110 | * @return string returns body content including all CID replacements |
@@ -3283,7 +3286,7 @@ discard block |
||
| 3283 | 3286 | * @param string $_folder (passed by reference) will set the folder used. must be set with a folder, but will hold modifications if |
| 3284 | 3287 | * folder is modified |
| 3285 | 3288 | * @param string $importID ID for the imported message, used by attachments to identify them unambiguously |
| 3286 | - * @return mixed $messageUID or exception |
|
| 3289 | + * @return string $messageUID or exception |
|
| 3287 | 3290 | */ |
| 3288 | 3291 | function importMessageToFolder($_formData,&$_folder,$importID='') |
| 3289 | 3292 | { |
@@ -3444,7 +3447,7 @@ discard block |
||
| 3444 | 3447 | * |
| 3445 | 3448 | * @param string _messageID UID |
| 3446 | 3449 | * |
| 3447 | - * @return xajax response |
|
| 3450 | + * @return string|null response |
|
| 3448 | 3451 | */ |
| 3449 | 3452 | function loadEmailBody($_messageID=null,$_partID=null,$_htmloptions=null) |
| 3450 | 3453 | { |
@@ -3995,7 +3998,7 @@ discard block |
||
| 3995 | 3998 | * ajax_deleteFolder - its called via json, so the function must start with ajax (or the class-name must contain ajax) |
| 3996 | 3999 | * @param string $_folderName folder to delete |
| 3997 | 4000 | * @param boolean $_return = false wheter return the success value (true) or send response to client (false) |
| 3998 | - * @return nothing |
|
| 4001 | + * @return null|boolean |
|
| 3999 | 4002 | */ |
| 4000 | 4003 | function ajax_deleteFolder($_folderName, $_return = false) |
| 4001 | 4004 | { |
@@ -3117,7 +3117,7 @@ discard block |
||
| 3117 | 3117 | * @param string $_partID |
| 3118 | 3118 | * @param string $_type |
| 3119 | 3119 | * @return string|boolean returns the replace |
| 3120 | - */ |
|
| 3120 | + */ |
|
| 3121 | 3121 | $replace_callback = function ($matches) use ($_mailbox,$_uid, $_partID, $_type) |
| 3122 | 3122 | { |
| 3123 | 3123 | if (!$_type) return false; |
@@ -3249,10 +3249,10 @@ discard block |
||
| 3249 | 3249 | try |
| 3250 | 3250 | { |
| 3251 | 3251 | $messageUid = $this->importMessageToFolder($file,$destination,$importID); |
| 3252 | - $linkData = array |
|
| 3253 | - ( |
|
| 3252 | + $linkData = array |
|
| 3253 | + ( |
|
| 3254 | 3254 | 'id' => $this->createRowID($destination, $messageUid, true), |
| 3255 | - ); |
|
| 3255 | + ); |
|
| 3256 | 3256 | } |
| 3257 | 3257 | catch (Api\Exception\WrongUserinput $e) |
| 3258 | 3258 | { |
@@ -3418,7 +3418,7 @@ discard block |
||
| 3418 | 3418 | $messageUid = $this->importMessageToFolder($formData,$draftFolder,$importID); |
| 3419 | 3419 | $linkData = array |
| 3420 | 3420 | ( |
| 3421 | - 'menuaction' => ($mode=='display'?'mail.mail_ui.displayMessage':'mail.mail_compose.composeFromDraft'), |
|
| 3421 | + 'menuaction' => ($mode=='display'?'mail.mail_ui.displayMessage':'mail.mail_compose.composeFromDraft'), |
|
| 3422 | 3422 | 'id' => $this->createRowID($draftFolder,$messageUid,true), |
| 3423 | 3423 | 'deleteDraftOnClose' => 1, |
| 3424 | 3424 | ); |
@@ -1811,7 +1811,7 @@ |
||
| 1811 | 1811 | |
| 1812 | 1812 | $data["class"] = implode(' ', $css_styles); |
| 1813 | 1813 | //translate style-classes back to flags |
| 1814 | - $data['flags'] = Array(); |
|
| 1814 | + $data['flags'] = array(); |
|
| 1815 | 1815 | if ($header['seen']) $data["flags"]['read'] = 'read'; |
| 1816 | 1816 | foreach ($css_styles as &$flag) { |
| 1817 | 1817 | if ($flag!='mail') |
@@ -31,8 +31,7 @@ discard block |
||
| 31 | 31 | * |
| 32 | 32 | * @var array |
| 33 | 33 | */ |
| 34 | - var $public_functions = array |
|
| 35 | - ( |
|
| 34 | + var $public_functions = array( |
|
| 36 | 35 | 'index' => True, |
| 37 | 36 | 'displayHeader' => True, |
| 38 | 37 | 'displayMessage' => True, |
@@ -83,12 +82,12 @@ discard block |
||
| 83 | 82 | * @var array |
| 84 | 83 | */ |
| 85 | 84 | var $searchTypes = array( |
| 86 | - 'quick' => 'quicksearch', // lang('quicksearch') |
|
| 87 | - 'subject' => 'subject', // lang('subject') |
|
| 88 | - 'body' => 'message body', // lang('message body') |
|
| 89 | - 'from' => 'from', // lang('from') |
|
| 90 | - 'to' => 'to', // lang('to') |
|
| 91 | - 'cc' => 'cc', // lang('cc') |
|
| 85 | + 'quick' => 'quicksearch', // lang('quicksearch') |
|
| 86 | + 'subject' => 'subject', // lang('subject') |
|
| 87 | + 'body' => 'message body', // lang('message body') |
|
| 88 | + 'from' => 'from', // lang('from') |
|
| 89 | + 'to' => 'to', // lang('to') |
|
| 90 | + 'cc' => 'cc', // lang('cc') |
|
| 92 | 91 | 'text' => 'whole message' // lang('whole message') |
| 93 | 92 | ); |
| 94 | 93 | |
@@ -98,12 +97,12 @@ discard block |
||
| 98 | 97 | * @var array |
| 99 | 98 | */ |
| 100 | 99 | var $statusTypes = array( |
| 101 | - 'any' => 'any status',// lang('any status') |
|
| 102 | - 'flagged' => 'flagged', // lang('flagged') |
|
| 103 | - 'unseen' => 'unread', // lang('unread') |
|
| 104 | - 'answered' => 'replied', // lang('replied') |
|
| 105 | - 'seen' => 'read', // lang('read') |
|
| 106 | - 'deleted' => 'deleted', // lang('deleted') |
|
| 100 | + 'any' => 'any status', // lang('any status') |
|
| 101 | + 'flagged' => 'flagged', // lang('flagged') |
|
| 102 | + 'unseen' => 'unread', // lang('unread') |
|
| 103 | + 'answered' => 'replied', // lang('replied') |
|
| 104 | + 'seen' => 'read', // lang('read') |
|
| 105 | + 'deleted' => 'deleted', // lang('deleted') |
|
| 107 | 106 | ); |
| 108 | 107 | |
| 109 | 108 | /** |
@@ -111,12 +110,12 @@ discard block |
||
| 111 | 110 | * |
| 112 | 111 | * @param boolean $run_constructor =true false: no not run constructor and therefore do NOT connect to imap server |
| 113 | 112 | */ |
| 114 | - function __construct($run_constructor=true) |
|
| 113 | + function __construct($run_constructor = true) |
|
| 115 | 114 | { |
| 116 | 115 | $this->mail_tree = new mail_tree($this); |
| 117 | 116 | if (!$run_constructor) return; |
| 118 | 117 | |
| 119 | - if (mail_bo::$debugTimes) $starttime = microtime (true); |
|
| 118 | + if (mail_bo::$debugTimes) $starttime = microtime(true); |
|
| 120 | 119 | // no autohide of the sidebox, as we use it for folderlist now. |
| 121 | 120 | unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']); |
| 122 | 121 | |
@@ -132,13 +131,13 @@ discard block |
||
| 132 | 131 | } |
| 133 | 132 | |
| 134 | 133 | try { |
| 135 | - $this->mail_bo = mail_bo::getInstance(true,self::$icServerID, true, false, true); |
|
| 134 | + $this->mail_bo = mail_bo::getInstance(true, self::$icServerID, true, false, true); |
|
| 136 | 135 | if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace()); |
| 137 | 136 | //error_log(__METHOD__.__LINE__.array2string($this->mail_bo->icServer)); |
| 138 | 137 | |
| 139 | 138 | // RegEx to minimize extra openConnection |
| 140 | 139 | $needle = '/^(?!mail)/'; |
| 141 | - if (!preg_match($needle,$_GET['menuaction']) && !egw_json_request::isJSONRequest()) |
|
| 140 | + if (!preg_match($needle, $_GET['menuaction']) && !egw_json_request::isJSONRequest()) |
|
| 142 | 141 | { |
| 143 | 142 | //error_log(__METHOD__.__LINE__.' Fetched IC Server openConnection:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace()); |
| 144 | 143 | //openConnection gathers SpecialUseFolderInformation and Delimiter Info |
@@ -148,9 +147,9 @@ discard block |
||
| 148 | 147 | catch (Exception $e) |
| 149 | 148 | { |
| 150 | 149 | // redirect to mail wizard to handle it (redirect works for ajax too) |
| 151 | - self::callWizard($e->getMessage(),true,'error'); |
|
| 150 | + self::callWizard($e->getMessage(), true, 'error'); |
|
| 152 | 151 | } |
| 153 | - if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 152 | + if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime, null, '', __METHOD__.__LINE__); |
|
| 154 | 153 | } |
| 155 | 154 | |
| 156 | 155 | /** |
@@ -160,10 +159,10 @@ discard block |
||
| 160 | 159 | * @param boolean $exit If true, will call common::egw_exit() after opening the wizardpopup |
| 161 | 160 | * @param string $msg_type = 'success' message type |
| 162 | 161 | */ |
| 163 | - static function callWizard($message, $exit=true, $msg_type='success') |
|
| 162 | + static function callWizard($message, $exit = true, $msg_type = 'success') |
|
| 164 | 163 | { |
| 165 | 164 | //error_log(__METHOD__."('$message', $exit) ".function_backtrace()); |
| 166 | - $linkData=(self::$icServerID ? array( |
|
| 165 | + $linkData = (self::$icServerID ? array( |
|
| 167 | 166 | 'menuaction' => 'mail.mail_wizard.edit', |
| 168 | 167 | 'acc_id' => self::$icServerID, |
| 169 | 168 | ) : array( |
@@ -177,11 +176,11 @@ discard block |
||
| 177 | 176 | { |
| 178 | 177 | $response = egw_json_response::get(); |
| 179 | 178 | $windowName = "editMailAccount".self::$icServerID; |
| 180 | - $response->call("egw.open_link", egw::link('/index.php', $linkData), $windowName, "600x480",null,true); |
|
| 179 | + $response->call("egw.open_link", egw::link('/index.php', $linkData), $windowName, "600x480", null, true); |
|
| 181 | 180 | egw_framework::message($message, 'error'); |
| 182 | 181 | if ($_GET['menuaction'] == 'mail.mail_ui.index') |
| 183 | 182 | { |
| 184 | - $response->call('framework.setSidebox','mail',array(),'md5'); |
|
| 183 | + $response->call('framework.setSidebox', 'mail', array(), 'md5'); |
|
| 185 | 184 | } |
| 186 | 185 | if ($exit) |
| 187 | 186 | { |
@@ -190,8 +189,8 @@ discard block |
||
| 190 | 189 | } |
| 191 | 190 | else // regular GET request eg. in idots template |
| 192 | 191 | { |
| 193 | - egw_framework::popup(egw_framework::link('/index.php',$linkData)); |
|
| 194 | - $GLOBALS['egw']->framework->render($message,'',true); |
|
| 192 | + egw_framework::popup(egw_framework::link('/index.php', $linkData)); |
|
| 193 | + $GLOBALS['egw']->framework->render($message, '', true); |
|
| 195 | 194 | if ($exit) |
| 196 | 195 | { |
| 197 | 196 | common::egw_exit(); |
@@ -207,9 +206,9 @@ discard block |
||
| 207 | 206 | * |
| 208 | 207 | * @throws egw_exception |
| 209 | 208 | */ |
| 210 | - function changeProfile($_icServerID,$unsetCache=false) |
|
| 209 | + function changeProfile($_icServerID, $unsetCache = false) |
|
| 211 | 210 | { |
| 212 | - if (mail_bo::$debugTimes) $starttime = microtime (true); |
|
| 211 | + if (mail_bo::$debugTimes) $starttime = microtime(true); |
|
| 213 | 212 | if (self::$icServerID != $_icServerID) |
| 214 | 213 | { |
| 215 | 214 | self::$icServerID = $_icServerID; |
@@ -217,35 +216,35 @@ discard block |
||
| 217 | 216 | if (mail_bo::$debug) error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID); |
| 218 | 217 | |
| 219 | 218 | if ($unsetCache) emailadmin_imapbase::unsetCachedObjects(self::$icServerID); |
| 220 | - $this->mail_bo = mail_bo::getInstance(false,self::$icServerID,true, false, true); |
|
| 219 | + $this->mail_bo = mail_bo::getInstance(false, self::$icServerID, true, false, true); |
|
| 221 | 220 | if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace()); |
| 222 | 221 | // no icServer Object: something failed big time |
| 223 | - if (!isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId<>$_icServerID) |
|
| 222 | + if (!isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId <> $_icServerID) |
|
| 224 | 223 | { |
| 225 | 224 | self::$icServerID = $_icServerID; |
| 226 | 225 | throw new egw_exception('Profile change failed!'); |
| 227 | 226 | } |
| 228 | 227 | |
| 229 | 228 | // save session varchar |
| 230 | - $oldicServerID =& egw_cache::getSession('mail','activeProfileID'); |
|
| 229 | + $oldicServerID = & egw_cache::getSession('mail', 'activeProfileID'); |
|
| 231 | 230 | if ($oldicServerID <> self::$icServerID) $this->mail_bo->openConnection(self::$icServerID); |
| 232 | 231 | $oldicServerID = self::$icServerID; |
| 233 | - if (!emailadmin_imapbase::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true )) |
|
| 232 | + if (!emailadmin_imapbase::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true)) |
|
| 234 | 233 | { |
| 235 | 234 | throw new egw_exception(__METHOD__." failed to change Profile to $_icServerID"); |
| 236 | 235 | } |
| 237 | 236 | |
| 238 | - if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 237 | + if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime, null, '', __METHOD__.__LINE__); |
|
| 239 | 238 | } |
| 240 | 239 | |
| 241 | 240 | /** |
| 242 | 241 | * Ajax function to request next branch of a tree branch |
| 243 | 242 | */ |
| 244 | - static function ajax_tree_autoloading ($_id = null) |
|
| 243 | + static function ajax_tree_autoloading($_id = null) |
|
| 245 | 244 | { |
| 246 | 245 | $mail_ui = new mail_ui(); |
| 247 | - $_id = $_id? $_id:$_GET['id']; |
|
| 248 | - etemplate_widget_tree::send_quote_json($mail_ui->mail_tree->getTree($_id,'',1,false)); |
|
| 246 | + $_id = $_id ? $_id : $_GET['id']; |
|
| 247 | + etemplate_widget_tree::send_quote_json($mail_ui->mail_tree->getTree($_id, '', 1, false)); |
|
| 249 | 248 | } |
| 250 | 249 | |
| 251 | 250 | /** |
@@ -254,11 +253,11 @@ discard block |
||
| 254 | 253 | * @param array $content |
| 255 | 254 | * @param type $msg |
| 256 | 255 | */ |
| 257 | - function subscription(array $content=null ,$msg=null) |
|
| 256 | + function subscription(array $content = null, $msg = null) |
|
| 258 | 257 | { |
| 259 | 258 | $stmpl = new etemplate_new('mail.subscribe'); |
| 260 | 259 | |
| 261 | - if(is_array($content)) |
|
| 260 | + if (is_array($content)) |
|
| 262 | 261 | { |
| 263 | 262 | $profileId = $content['profileId']; |
| 264 | 263 | } |
@@ -268,14 +267,14 @@ discard block |
||
| 268 | 267 | } |
| 269 | 268 | // Initial tree's options, the rest would be loaded dynamicaly by autoloading, |
| 270 | 269 | // triggered from client-side. Also, we keep this here as |
| 271 | - $sel_options['foldertree'] = $this->mail_tree->getTree(null,$profileId,1,true,false,true); |
|
| 270 | + $sel_options['foldertree'] = $this->mail_tree->getTree(null, $profileId, 1, true, false, true); |
|
| 272 | 271 | |
| 273 | 272 | //Get all subscribed folders |
| 274 | 273 | // as getting all subscribed folders is very fast operation |
| 275 | 274 | // we can use it to get a comparison base for folders which |
| 276 | 275 | // got subscribed or unsubscribed by the user |
| 277 | 276 | try { |
| 278 | - $subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('',0,true); |
|
| 277 | + $subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('', 0, true); |
|
| 279 | 278 | } catch (Exception $ex) { |
| 280 | 279 | egw_framework::message($ex->getMessage()); |
| 281 | 280 | } |
@@ -286,7 +285,7 @@ discard block |
||
| 286 | 285 | |
| 287 | 286 | foreach ($subscribed as $folder) |
| 288 | 287 | { |
| 289 | - $folderName = $profileId . self::$delimiter . $folder['MAILBOX']; |
|
| 288 | + $folderName = $profileId.self::$delimiter.$folder['MAILBOX']; |
|
| 290 | 289 | array_push($content['foldertree'], $folderName); |
| 291 | 290 | } |
| 292 | 291 | } |
@@ -300,9 +299,9 @@ discard block |
||
| 300 | 299 | { |
| 301 | 300 | // do not let user (un)subscribe namespace roots eg. "other", "user" or "INBOX", same for tree-root/account itself |
| 302 | 301 | $namespace_roots = array($profileId); |
| 303 | - foreach($this->mail_bo->_getNameSpaces() as $namespace) |
|
| 302 | + foreach ($this->mail_bo->_getNameSpaces() as $namespace) |
|
| 304 | 303 | { |
| 305 | - $namespace_roots[] = $profileId . self::$delimiter . str_replace($namespace['delimiter'], '', $namespace['prefix']); |
|
| 304 | + $namespace_roots[] = $profileId.self::$delimiter.str_replace($namespace['delimiter'], '', $namespace['prefix']); |
|
| 306 | 305 | } |
| 307 | 306 | $to_unsubscribe = $to_subscribe = array(); |
| 308 | 307 | foreach ($content['foldertree'] as $path => $value) |
@@ -310,7 +309,7 @@ discard block |
||
| 310 | 309 | list(,$node) = explode($profileId.self::$delimiter, $path); |
| 311 | 310 | if ($node) |
| 312 | 311 | { |
| 313 | - if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe []= $node; |
|
| 312 | + if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe [] = $node; |
|
| 314 | 313 | if (is_array($subscribed) && !$subscribed[$node] && $value['value']) $to_subscribe [] = $node; |
| 315 | 314 | if ($value['value']) $cont[] = $path; |
| 316 | 315 | } |
@@ -320,7 +319,7 @@ discard block |
||
| 320 | 319 | // set foldertree options to basic node in order to avoid initial autoloading |
| 321 | 320 | // from client side, as no options would trigger that. |
| 322 | 321 | $sel_options['foldertree'] = array('id' => '0', 'item'=> array()); |
| 323 | - foreach(array_merge($to_subscribe, $to_unsubscribe) as $mailbox) |
|
| 322 | + foreach (array_merge($to_subscribe, $to_unsubscribe) as $mailbox) |
|
| 324 | 323 | { |
| 325 | 324 | if (in_array($profileId.self::$delimiter.$mailbox, $namespace_roots, true)) |
| 326 | 325 | { |
@@ -356,18 +355,18 @@ discard block |
||
| 356 | 355 | } |
| 357 | 356 | } |
| 358 | 357 | // update foldertree in main window |
| 359 | - $parentFolder='INBOX'; |
|
| 358 | + $parentFolder = 'INBOX'; |
|
| 360 | 359 | $refreshData = array( |
| 361 | 360 | $profileId => lang($parentFolder), |
| 362 | 361 | ); |
| 363 | 362 | $response = egw_json_response::get(); |
| 364 | - foreach($refreshData as $folder => &$name) |
|
| 363 | + foreach ($refreshData as $folder => &$name) |
|
| 365 | 364 | { |
| 366 | - $name = $this->mail_tree->getTree($folder, $profileId,1,true,true,true); |
|
| 365 | + $name = $this->mail_tree->getTree($folder, $profileId, 1, true, true, true); |
|
| 367 | 366 | } |
| 368 | 367 | // give success/error message to opener and popup itself |
| 369 | 368 | //$response->call('opener.app.mail.subscription_refresh',$refreshData); |
| 370 | - $response->call('opener.app.mail.mail_reloadNode',$refreshData); |
|
| 369 | + $response->call('opener.app.mail.mail_reloadNode', $refreshData); |
|
| 371 | 370 | |
| 372 | 371 | egw_framework::refresh_opener($msg, 'mail', null, null, null, null, null, $msg_type); |
| 373 | 372 | if ($button == 'apply') |
@@ -387,7 +386,7 @@ discard block |
||
| 387 | 386 | |
| 388 | 387 | $readonlys = array(); |
| 389 | 388 | |
| 390 | - $stmpl->exec('mail.mail_ui.subscription', $content,$sel_options,$readonlys,$preserv,2); |
|
| 389 | + $stmpl->exec('mail.mail_ui.subscription', $content, $sel_options, $readonlys, $preserv, 2); |
|
| 391 | 390 | } |
| 392 | 391 | |
| 393 | 392 | /** |
@@ -396,11 +395,11 @@ discard block |
||
| 396 | 395 | * @param array $content |
| 397 | 396 | * @param string $msg |
| 398 | 397 | */ |
| 399 | - function index(array $content=null,$msg=null) |
|
| 398 | + function index(array $content = null, $msg = null) |
|
| 400 | 399 | { |
| 401 | - try { |
|
| 400 | + try { |
|
| 402 | 401 | //error_log(__METHOD__.__LINE__.function_backtrace()); |
| 403 | - if (mail_bo::$debugTimes) $starttime = microtime (true); |
|
| 402 | + if (mail_bo::$debugTimes) $starttime = microtime(true); |
|
| 404 | 403 | $this->mail_bo->restoreSessionData(); |
| 405 | 404 | $sessionFolder = $this->mail_bo->sessionData['mailbox']; |
| 406 | 405 | if ($this->mail_bo->folderExists($sessionFolder)) |
@@ -415,20 +414,20 @@ discard block |
||
| 415 | 414 | if (!is_array($content)) |
| 416 | 415 | { |
| 417 | 416 | $content = array( |
| 418 | - self::$nm_index => egw_session::appsession('index','mail'), |
|
| 417 | + self::$nm_index => egw_session::appsession('index', 'mail'), |
|
| 419 | 418 | ); |
| 420 | 419 | if (!is_array($content[self::$nm_index])) |
| 421 | 420 | { |
| 422 | 421 | $content[self::$nm_index] = array( |
| 423 | - 'filter' => 'any', // filter is used to choose the mailbox |
|
| 424 | - 'no_filter2' => false, // I disable the 2. filter (params are the same as for filter) |
|
| 425 | - 'no_cat' => true, // I disable the cat-selectbox |
|
| 422 | + 'filter' => 'any', // filter is used to choose the mailbox |
|
| 423 | + 'no_filter2' => false, // I disable the 2. filter (params are the same as for filter) |
|
| 424 | + 'no_cat' => true, // I disable the cat-selectbox |
|
| 426 | 425 | //'cat_is_select' => 'no_lang', // true or no_lang |
| 427 | - 'lettersearch' => false, // I show a lettersearch |
|
| 428 | - 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
| 429 | - 'start' => 0, // IO position in list |
|
| 430 | - 'order' => 'date', // IO name of the column to sort after (optional for the sortheaders) |
|
| 431 | - 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 426 | + 'lettersearch' => false, // I show a lettersearch |
|
| 427 | + 'searchletter' => false, // I0 active letter of the lettersearch or false for [all] |
|
| 428 | + 'start' => 0, // IO position in list |
|
| 429 | + 'order' => 'date', // IO name of the column to sort after (optional for the sortheaders) |
|
| 430 | + 'sort' => 'DESC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 432 | 431 | //'default_cols' => 'status,attachments,subject,'.($toSchema?'toaddress':'fromaddress').',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 |
| 433 | 432 | //'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 |
| 434 | 433 | //'csv_fields' => false, // I false=disable csv export, true or unset=enable it with auto-detected fieldnames, |
@@ -441,8 +440,8 @@ discard block |
||
| 441 | 440 | } |
| 442 | 441 | |
| 443 | 442 | $content[self::$nm_index]['get_rows'] = 'mail_ui::get_rows'; |
| 444 | - $content[self::$nm_index]['num_rows'] = 0; // Do not send any rows with initial request |
|
| 445 | - $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 |
|
| 443 | + $content[self::$nm_index]['num_rows'] = 0; // Do not send any rows with initial request |
|
| 444 | + $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 |
|
| 446 | 445 | $content[self::$nm_index]['csv_fields'] = false; |
| 447 | 446 | if ($msg) |
| 448 | 447 | { |
@@ -454,11 +453,11 @@ discard block |
||
| 454 | 453 | unset($content['msg']); |
| 455 | 454 | } |
| 456 | 455 | // call getQuotaRoot asynchronously in getRows by initiating a client Server roundtrip |
| 457 | - $quota = false;//$this->mail_bo->getQuotaRoot(); |
|
| 458 | - if($quota !== false && $quota['limit'] != 'NOT SET') { |
|
| 456 | + $quota = false; //$this->mail_bo->getQuotaRoot(); |
|
| 457 | + if ($quota !== false && $quota['limit'] != 'NOT SET') { |
|
| 459 | 458 | $quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']); |
| 460 | 459 | $content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text']; |
| 461 | - $content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent']; |
|
| 460 | + $content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent']; |
|
| 462 | 461 | $content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class']; |
| 463 | 462 | $content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = ""; |
| 464 | 463 | } else { |
@@ -467,43 +466,43 @@ discard block |
||
| 467 | 466 | $content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone"; |
| 468 | 467 | } |
| 469 | 468 | // call gatherVacation asynchronously in getRows by initiating a client Server roundtrip |
| 470 | - $vacation = false;//$this->gatherVacation(); |
|
| 469 | + $vacation = false; //$this->gatherVacation(); |
|
| 471 | 470 | //error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation)); |
| 472 | - if($vacation) { |
|
| 473 | - if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date' && $vacation['end_date'] > time())) |
|
| 471 | + if ($vacation) { |
|
| 472 | + if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status'] == 'by_date' && $vacation['end_date'] > time())) |
|
| 474 | 473 | { |
| 475 | 474 | $dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']/*.' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat']!='24'?'h:i a':'H:i')*/; |
| 476 | 475 | $content[self::$nm_index]['vacationnotice'] = $sel_options[self::$nm_index]['vacationnotice'] = lang('Vacation notice is active'); |
| 477 | - $content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = ($vacation['status']=='by_date'? common::show_date($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.common::show_date($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):''); |
|
| 476 | + $content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = ($vacation['status'] == 'by_date' ? common::show_date($vacation['start_date'], $dtfrmt, true).($vacation['end_date'] > $vacation['start_date'] ? '->'.common::show_date($vacation['end_date'] + 24 * 3600 - 1, $dtfrmt, true) : '') : ''); |
|
| 478 | 477 | } |
| 479 | 478 | } |
| 480 | - if ($vacation==false) |
|
| 479 | + if ($vacation == false) |
|
| 481 | 480 | { |
| 482 | 481 | $content[self::$nm_index]['vacationnotice'] = $sel_options[self::$nm_index]['vacationnotice'] = ''; |
| 483 | 482 | $content[self::$nm_index]['vacationrange'] = $sel_options[self::$nm_index]['vacationrange'] = ''; |
| 484 | 483 | } |
| 485 | 484 | //$zstarttime = microtime (true); |
| 486 | - $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']); |
|
| 485 | + $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']); |
|
| 487 | 486 | //$zendtime = microtime(true) - $zstarttime; |
| 488 | 487 | //error_log(__METHOD__.__LINE__. " time used: ".$zendtime); |
| 489 | - $content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.(!empty($this->mail_bo->sessionData['mailbox'])?$this->mail_bo->sessionData['mailbox']:'INBOX'); |
|
| 488 | + $content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.(!empty($this->mail_bo->sessionData['mailbox']) ? $this->mail_bo->sessionData['mailbox'] : 'INBOX'); |
|
| 490 | 489 | // since we are connected,(and selected the folder) we check for capabilities SUPPORTS_KEYWORDS to eventually add the keyword filters |
| 491 | - if ( $this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS')) |
|
| 490 | + if ($this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS')) |
|
| 492 | 491 | { |
| 493 | - $this->statusTypes = array_merge($this->statusTypes,array( |
|
| 494 | - 'keyword1' => 'important',//lang('important'), |
|
| 495 | - 'keyword2' => 'job', //lang('job'), |
|
| 496 | - 'keyword3' => 'personal',//lang('personal'), |
|
| 497 | - 'keyword4' => 'to do', //lang('to do'), |
|
| 498 | - 'keyword5' => 'later', //lang('later'), |
|
| 492 | + $this->statusTypes = array_merge($this->statusTypes, array( |
|
| 493 | + 'keyword1' => 'important', //lang('important'), |
|
| 494 | + 'keyword2' => 'job', //lang('job'), |
|
| 495 | + 'keyword3' => 'personal', //lang('personal'), |
|
| 496 | + 'keyword4' => 'to do', //lang('to do'), |
|
| 497 | + 'keyword5' => 'later', //lang('later'), |
|
| 499 | 498 | )); |
| 500 | 499 | } |
| 501 | 500 | else |
| 502 | 501 | { |
| 503 | - $keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5'); |
|
| 504 | - foreach($keywords as &$k) |
|
| 502 | + $keywords = array('keyword1', 'keyword2', 'keyword3', 'keyword4', 'keyword5'); |
|
| 503 | + foreach ($keywords as &$k) |
|
| 505 | 504 | { |
| 506 | - if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]); |
|
| 505 | + if (array_key_exists($k, $this->statusTypes)) unset($this->statusTypes[$k]); |
|
| 507 | 506 | } |
| 508 | 507 | } |
| 509 | 508 | |
@@ -514,17 +513,17 @@ discard block |
||
| 514 | 513 | |
| 515 | 514 | if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) |
| 516 | 515 | { |
| 517 | - emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
|
| 518 | - if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 516 | + emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 517 | + if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID] = true; |
|
| 519 | 518 | } |
| 520 | 519 | if (!emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]) unset($this->searchTypes['quick']); |
| 521 | 520 | $sel_options['filter2'] = $this->searchTypes; |
| 522 | 521 | $sel_options['filter'] = $this->statusTypes; |
| 523 | 522 | |
| 524 | - $etpl = new etemplate_new(html::$ua_mobile?'mail.mobile_index':'mail.index'); |
|
| 523 | + $etpl = new etemplate_new(html::$ua_mobile ? 'mail.mobile_index' : 'mail.index'); |
|
| 525 | 524 | // Start at 2 so auto-added copy+paste actions show up as second group |
| 526 | 525 | // Needed because there's no 'select all' action to push things down |
| 527 | - $group=2; |
|
| 526 | + $group = 2; |
|
| 528 | 527 | // Set tree actions |
| 529 | 528 | $tree_actions = array( |
| 530 | 529 | 'drop_move_mail' => array( |
@@ -602,13 +601,13 @@ discard block |
||
| 602 | 601 | 'sieve' => array( |
| 603 | 602 | 'caption' => 'Mail filter', |
| 604 | 603 | 'onExecute' => 'javaScript:app.mail.edit_sieve', |
| 605 | - 'group' => ++$group, // new group for filter |
|
| 604 | + 'group' => ++$group, // new group for filter |
|
| 606 | 605 | 'enabled' => 'javaScript:app.mail.sieve_enabled', |
| 607 | - 'icon' => 'etemplate/fav_filter', // funnel |
|
| 606 | + 'icon' => 'etemplate/fav_filter', // funnel |
|
| 608 | 607 | ), |
| 609 | 608 | 'vacation' => array( |
| 610 | 609 | 'caption' => 'Vacation notice', |
| 611 | - 'icon' => 'mail/navbar', // mail as in admin |
|
| 610 | + 'icon' => 'mail/navbar', // mail as in admin |
|
| 612 | 611 | 'onExecute' => 'javaScript:app.mail.edit_vacation', |
| 613 | 612 | 'group' => $group, |
| 614 | 613 | 'enabled' => 'javaScript:app.mail.sieve_enabled', |
@@ -617,7 +616,7 @@ discard block |
||
| 617 | 616 | 'caption' => 'Edit account ...', |
| 618 | 617 | 'icon' => 'configure', |
| 619 | 618 | 'onExecute' => 'javaScript:app.mail.edit_account', |
| 620 | - 'group' => ++$group, // new groups for account & acl |
|
| 619 | + 'group' => ++$group, // new groups for account & acl |
|
| 621 | 620 | ), |
| 622 | 621 | 'edit_acl' => array( |
| 623 | 622 | 'caption' => 'Edit folder ACL ...', |
@@ -652,8 +651,8 @@ discard block |
||
| 652 | 651 | unset($tree_actions['subscribe']); |
| 653 | 652 | unset($tree_actions['unsubscribe']); |
| 654 | 653 | } |
| 655 | - ++$group; // put delete in own group |
|
| 656 | - switch($GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions']) |
|
| 654 | + ++$group; // put delete in own group |
|
| 655 | + switch ($GLOBALS['egw_info']['user']['preferences']['mail']['deleteOptions']) |
|
| 657 | 656 | { |
| 658 | 657 | case 'move_to_trash': |
| 659 | 658 | $tree_actions['empty_trash'] = array( |
@@ -672,7 +671,7 @@ discard block |
||
| 672 | 671 | ); |
| 673 | 672 | break; |
| 674 | 673 | } |
| 675 | - ++$group; // put empty spam immediately in own group |
|
| 674 | + ++$group; // put empty spam immediately in own group |
|
| 676 | 675 | $junkFolder = $this->mail_bo->getJunkFolder(); |
| 677 | 676 | //error_log(__METHOD__.__LINE__.$junkFolder); |
| 678 | 677 | if ($junkFolder && !empty($junkFolder)) |
@@ -709,23 +708,23 @@ discard block |
||
| 709 | 708 | // to existing folders, it should only affect add/rename/move/delete |
| 710 | 709 | } |
| 711 | 710 | |
| 712 | - $etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $tree_actions); |
|
| 711 | + $etpl->setElementAttribute(self::$nm_index.'[foldertree]', 'actions', $tree_actions); |
|
| 713 | 712 | |
| 714 | 713 | // sending preview toolbar actions |
| 715 | 714 | if ($content['mailSplitter']) $etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions()); |
| 716 | 715 | |
| 717 | - if (empty($content[self::$nm_index]['filter2']) || empty($content[self::$nm_index]['search'])) $content[self::$nm_index]['filter2']=(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject'); |
|
| 716 | + if (empty($content[self::$nm_index]['filter2']) || empty($content[self::$nm_index]['search'])) $content[self::$nm_index]['filter2'] = (emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID] ? 'quick' : 'subject'); |
|
| 718 | 717 | $readonlys = $preserv = array(); |
| 719 | - if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 718 | + if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime, null, '', __METHOD__.__LINE__); |
|
| 720 | 719 | } |
| 721 | 720 | catch (Exception $e) |
| 722 | 721 | { |
| 723 | - self::callWizard($e->getMessage(),true, 'error'); |
|
| 722 | + self::callWizard($e->getMessage(), true, 'error'); |
|
| 724 | 723 | } |
| 725 | 724 | // Check preview pane is enabled, then show spliter |
| 726 | 725 | if ($this->mail_bo->mailPreferences['previewPane']) $etpl->setElementAttribute('mail.index.spliter', 'template', 'mail.index.nospliter'); |
| 727 | 726 | |
| 728 | - return $etpl->exec('mail.mail_ui.index',$content,$sel_options,$readonlys,$preserv); |
|
| 727 | + return $etpl->exec('mail.mail_ui.index', $content, $sel_options, $readonlys, $preserv); |
|
| 729 | 728 | } |
| 730 | 729 | |
| 731 | 730 | /** |
@@ -735,19 +734,19 @@ discard block |
||
| 735 | 734 | * @param {string} $_folderName name of mailbox needs to be subcribe or unsubscribed |
| 736 | 735 | * @param {boolean} $_status set true for subscribe and false to unsubscribe |
| 737 | 736 | */ |
| 738 | - public function ajax_foldersubscription($_acc_id,$_folderName, $_status) |
|
| 737 | + public function ajax_foldersubscription($_acc_id, $_folderName, $_status) |
|
| 739 | 738 | { |
| 740 | 739 | //Change the mail_bo object to related profileId |
| 741 | 740 | $this->changeProfile($_acc_id); |
| 742 | 741 | |
| 743 | - if($this->mail_bo->icServer->subscribeMailbox($_folderName, $_status)) |
|
| 742 | + if ($this->mail_bo->icServer->subscribeMailbox($_folderName, $_status)) |
|
| 744 | 743 | { |
| 745 | 744 | $this->mail_bo->resetFolderObjectCache($_acc_id); |
| 746 | - $this->ajax_reloadNode($_acc_id,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 745 | + $this->ajax_reloadNode($_acc_id, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 747 | 746 | } |
| 748 | 747 | else |
| 749 | 748 | { |
| 750 | - error_log(__METHOD__.__LINE__."()". lang('Folder %1 %2 failed!',$_folderName,$_status?'subscribed':'unsubscribed')); |
|
| 749 | + error_log(__METHOD__.__LINE__."()".lang('Folder %1 %2 failed!', $_folderName, $_status ? 'subscribed' : 'unsubscribed')); |
|
| 751 | 750 | } |
| 752 | 751 | } |
| 753 | 752 | |
@@ -759,25 +758,25 @@ discard block |
||
| 759 | 758 | * @param string $_nodeID if of node whos children are requested |
| 760 | 759 | * @param boolean $_subscribedOnly flag to tell wether to fetch all or only subscribed (default) |
| 761 | 760 | */ |
| 762 | - public function ajax_foldertree($_nodeID = null,$_subscribedOnly=null) |
|
| 761 | + public function ajax_foldertree($_nodeID = null, $_subscribedOnly = null) |
|
| 763 | 762 | { |
| 764 | 763 | $nodeID = $_GET['id']; |
| 765 | 764 | if (!is_null($_nodeID)) $nodeID = $_nodeID; |
| 766 | - $subscribedOnly = (bool)(!is_null($_subscribedOnly)?$_subscribedOnly:!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 765 | + $subscribedOnly = (bool)(!is_null($_subscribedOnly) ? $_subscribedOnly : !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 767 | 766 | $fetchCounters = !is_null($_nodeID); |
| 768 | - list($_profileID,$_folderName) = explode(self::$delimiter,$nodeID,2); |
|
| 767 | + list($_profileID, $_folderName) = explode(self::$delimiter, $nodeID, 2); |
|
| 769 | 768 | |
| 770 | 769 | if (!empty($_folderName)) $fetchCounters = true; |
| 771 | 770 | |
| 772 | 771 | // Check if it is called for refresh root |
| 773 | 772 | // then we need to reinitialized the index tree |
| 774 | - if(!$nodeID && !$_profileID) |
|
| 773 | + if (!$nodeID && !$_profileID) |
|
| 775 | 774 | { |
| 776 | - $data = $this->mail_tree->getInitialIndexTree(null,null,null,null,true,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 775 | + $data = $this->mail_tree->getInitialIndexTree(null, null, null, null, true, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 777 | 776 | } |
| 778 | 777 | else |
| 779 | 778 | { |
| 780 | - $data = $this->mail_tree->getTree($nodeID,$_profileID,0, false,$subscribedOnly,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 779 | + $data = $this->mail_tree->getTree($nodeID, $_profileID, 0, false, $subscribedOnly, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
|
| 781 | 780 | } |
| 782 | 781 | if (!is_null($_nodeID)) return $data; |
| 783 | 782 | etemplate_widget_tree::send_quote_json($data); |
@@ -793,17 +792,17 @@ discard block |
||
| 793 | 792 | */ |
| 794 | 793 | static function findNode($_out, $_nodeID, $childElements = false) |
| 795 | 794 | { |
| 796 | - foreach($_out['item'] as $node) |
|
| 795 | + foreach ($_out['item'] as $node) |
|
| 797 | 796 | { |
| 798 | - if (strcmp($node['id'],$_nodeID)===0) |
|
| 797 | + if (strcmp($node['id'], $_nodeID) === 0) |
|
| 799 | 798 | { |
| 800 | 799 | //error_log(__METHOD__.__LINE__.':'.$_nodeID.'->'.$node['id']); |
| 801 | - return ($childElements?$node['item']:$node); |
|
| 800 | + return ($childElements ? $node['item'] : $node); |
|
| 802 | 801 | } |
| 803 | - elseif (is_array($node['item']) && strncmp($node['id'],$_nodeID,strlen($node['id']))===0 && strlen($_nodeID)>strlen($node['id'])) |
|
| 802 | + elseif (is_array($node['item']) && strncmp($node['id'], $_nodeID, strlen($node['id'])) === 0 && strlen($_nodeID) > strlen($node['id'])) |
|
| 804 | 803 | { |
| 805 | 804 | //error_log(__METHOD__.__LINE__.' descend into '.$node['id']); |
| 806 | - return self::findNode($node,$_nodeID,$childElements); |
|
| 805 | + return self::findNode($node, $_nodeID, $childElements); |
|
| 807 | 806 | } |
| 808 | 807 | } |
| 809 | 808 | } |
@@ -817,7 +816,7 @@ discard block |
||
| 817 | 816 | */ |
| 818 | 817 | private function get_actions() |
| 819 | 818 | { |
| 820 | - static $accArray=array(); // buffer identity names on single request |
|
| 819 | + static $accArray = array(); // buffer identity names on single request |
|
| 821 | 820 | // duplicated from mail_hooks |
| 822 | 821 | static $deleteOptions = array( |
| 823 | 822 | 'move_to_trash' => 'move to trash', |
@@ -827,12 +826,12 @@ discard block |
||
| 827 | 826 | // todo: real hierarchical folder list |
| 828 | 827 | $lastFolderUsedForMove = null; |
| 829 | 828 | $moveactions = array(); |
| 830 | - $lastFoldersUsedForMoveCont = egw_cache::getCache(egw_cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1); |
|
| 829 | + $lastFoldersUsedForMoveCont = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 1); |
|
| 831 | 830 | //error_log(__METHOD__.__LINE__." StoredFolders->".array2string($lastFoldersUsedForMoveCont)); |
| 832 | 831 | //error_log(__METHOD__.__LINE__.' ProfileId:'.$this->mail_bo->profileID." StoredFolders->(".count($lastFoldersUsedForMoveCont[$this->mail_bo->profileID]).") ".array2string($lastFoldersUsedForMoveCont[$this->mail_bo->profileID])); |
| 833 | 832 | if (is_null($accArray)) |
| 834 | 833 | { |
| 835 | - foreach(emailadmin_account::search($only_current_user=true, false) as $acc_id => $accountObj) |
|
| 834 | + foreach (emailadmin_account::search($only_current_user = true, false) as $acc_id => $accountObj) |
|
| 836 | 835 | { |
| 837 | 836 | //error_log(__METHOD__.__LINE__.array2string($accountObj)); |
| 838 | 837 | if (!$accountObj->is_imap()) |
@@ -840,22 +839,22 @@ discard block |
||
| 840 | 839 | // not to be used for IMAP Foldertree, as there is no Imap host |
| 841 | 840 | continue; |
| 842 | 841 | } |
| 843 | - $identity_name = emailadmin_account::identity_name($accountObj,true,$GLOBALS['egw_info']['user']['acount_id']); |
|
| 844 | - $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 |
|
| 842 | + $identity_name = emailadmin_account::identity_name($accountObj, true, $GLOBALS['egw_info']['user']['acount_id']); |
|
| 843 | + $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 |
|
| 845 | 844 | } |
| 846 | 845 | } |
| 847 | - if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont=array(); |
|
| 846 | + if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont = array(); |
|
| 848 | 847 | foreach ($lastFoldersUsedForMoveCont as $pid => $info) |
| 849 | 848 | { |
| 850 | - if ($this->mail_bo->profileID==$pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID])) |
|
| 849 | + if ($this->mail_bo->profileID == $pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID])) |
|
| 851 | 850 | { |
| 852 | 851 | $_folder = $this->mail_bo->icServer->getCurrentMailbox(); |
| 853 | 852 | //error_log(__METHOD__.__LINE__.' '.$_folder."<->".$lastFoldersUsedForMoveCont[$this->mail_bo->profileID].function_backtrace()); |
| 854 | - $counter =1; |
|
| 853 | + $counter = 1; |
|
| 855 | 854 | foreach ($lastFoldersUsedForMoveCont[$this->mail_bo->profileID] as $i => $lastFolderUsedForMoveCont) |
| 856 | 855 | { |
| 857 | 856 | $moveaction = 'move_'; |
| 858 | - if ($_folder!=$i) |
|
| 857 | + if ($_folder != $i) |
|
| 859 | 858 | { |
| 860 | 859 | $moveaction .= $lastFolderUsedForMoveCont; |
| 861 | 860 | |
@@ -865,7 +864,7 @@ discard block |
||
| 865 | 864 | $fS['profileName'] = $accArray[$this->mail_bo->profileID]; |
| 866 | 865 | $fS['shortDisplayName'] = $i; |
| 867 | 866 | $moveactions[$moveaction] = $fS; |
| 868 | - $counter ++; |
|
| 867 | + $counter++; |
|
| 869 | 868 | } |
| 870 | 869 | else |
| 871 | 870 | { |
@@ -875,9 +874,9 @@ discard block |
||
| 875 | 874 | } |
| 876 | 875 | } |
| 877 | 876 | } |
| 878 | - elseif ($this->mail_bo->profileID!=$pid && isset($lastFoldersUsedForMoveCont[$pid]) && !empty($lastFoldersUsedForMoveCont[$pid])) |
|
| 877 | + elseif ($this->mail_bo->profileID != $pid && isset($lastFoldersUsedForMoveCont[$pid]) && !empty($lastFoldersUsedForMoveCont[$pid])) |
|
| 879 | 878 | { |
| 880 | - $counter =1; |
|
| 879 | + $counter = 1; |
|
| 881 | 880 | foreach ($lastFoldersUsedForMoveCont[$pid] as $i => $lastFolderUsedForMoveCont) |
| 882 | 881 | { |
| 883 | 882 | //error_log(__METHOD__.__LINE__."$i => $lastFolderUsedForMoveCont"); |
@@ -889,14 +888,14 @@ discard block |
||
| 889 | 888 | $fS['profileName'] = $accArray[$pid]; |
| 890 | 889 | $fS['shortDisplayName'] = $i; |
| 891 | 890 | $moveactions[$moveaction] = $fS; |
| 892 | - $counter ++; |
|
| 891 | + $counter++; |
|
| 893 | 892 | } |
| 894 | 893 | } |
| 895 | 894 | } |
| 896 | 895 | } |
| 897 | - egw_cache::setCache(egw_cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFoldersUsedForMoveCont, $expiration=60*60*1); |
|
| 896 | + egw_cache::setCache(egw_cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), $lastFoldersUsedForMoveCont, $expiration = 60 * 60 * 1); |
|
| 898 | 897 | $group = 0; |
| 899 | - $actions = array( |
|
| 898 | + $actions = array( |
|
| 900 | 899 | 'open' => array( |
| 901 | 900 | 'caption' => lang('Open'), |
| 902 | 901 | 'icon' => 'view', |
@@ -952,20 +951,20 @@ discard block |
||
| 952 | 951 | 'allowOnMultiple' => false, |
| 953 | 952 | ) |
| 954 | 953 | ); |
| 955 | - $macounter=0; |
|
| 954 | + $macounter = 0; |
|
| 956 | 955 | if (!empty($moveactions)) |
| 957 | 956 | { |
| 958 | 957 | //error_log(__METHOD__.__LINE__.array2string($moveactions)); |
| 959 | - $children=array(); |
|
| 960 | - $pID=0; |
|
| 958 | + $children = array(); |
|
| 959 | + $pID = 0; |
|
| 961 | 960 | foreach ($moveactions as $moveaction => $lastFolderUsedForMove) |
| 962 | 961 | { |
| 963 | - $group = ($pID != $lastFolderUsedForMove['profileID'] && $macounter>0? $group+1 : $group); |
|
| 962 | + $group = ($pID != $lastFolderUsedForMove['profileID'] && $macounter > 0 ? $group + 1 : $group); |
|
| 964 | 963 | //error_log(__METHOD__.__LINE__."#$pID != ".$lastFolderUsedForMove['profileID']."#".$macounter.'#'.$groupCounter.'#'); |
| 965 | 964 | $children = array_merge($children, |
| 966 | 965 | array( |
| 967 | 966 | $moveaction => array( |
| 968 | - 'caption' => (!empty($lastFolderUsedForMove['profileName'])?$lastFolderUsedForMove['profileName']:'('.$lastFolderUsedForMove['profileID'].')').': '.(isset($lastFolderUsedForMove['shortDisplayName'])?$lastFolderUsedForMove['shortDisplayName']:''), |
|
| 967 | + 'caption' => (!empty($lastFolderUsedForMove['profileName']) ? $lastFolderUsedForMove['profileName'] : '('.$lastFolderUsedForMove['profileID'].')').': '.(isset($lastFolderUsedForMove['shortDisplayName']) ? $lastFolderUsedForMove['shortDisplayName'] : ''), |
|
| 969 | 968 | 'icon' => 'move', |
| 970 | 969 | 'group' => $group, |
| 971 | 970 | 'onExecute' => 'javaScript:app.mail.mail_move2folder', |
@@ -976,7 +975,7 @@ discard block |
||
| 976 | 975 | $pID = $lastFolderUsedForMove['profileID']; |
| 977 | 976 | $macounter++; |
| 978 | 977 | } |
| 979 | - $actions = array_merge($actions,array('moveto' => |
|
| 978 | + $actions = array_merge($actions, array('moveto' => |
|
| 980 | 979 | array( |
| 981 | 980 | 'caption' => lang('Move selected to'), |
| 982 | 981 | 'icon' => 'move', |
@@ -1007,7 +1006,7 @@ discard block |
||
| 1007 | 1006 | 'icon' => 'tracker/navbar', |
| 1008 | 1007 | 'onExecute' => 'javaScript:app.mail.mail_integrate', |
| 1009 | 1008 | 'popup' => egw_link::get_registry('tracker', 'add_popup'), |
| 1010 | - 'mail_import' => $GLOBALS['egw']->hooks->single(array('location' => 'mail_import'),'tracker'), |
|
| 1009 | + 'mail_import' => $GLOBALS['egw']->hooks->single(array('location' => 'mail_import'), 'tracker'), |
|
| 1011 | 1010 | 'allowOnMultiple' => false, |
| 1012 | 1011 | ), |
| 1013 | 1012 | 'calendar' => array( |
@@ -1223,22 +1222,22 @@ discard block |
||
| 1223 | 1222 | * @param array &$rows |
| 1224 | 1223 | * @param array &$readonlys |
| 1225 | 1224 | */ |
| 1226 | - public static function get_rows(&$query,&$rows,&$readonlys) |
|
| 1225 | + public static function get_rows(&$query, &$rows, &$readonlys) |
|
| 1227 | 1226 | { |
| 1228 | 1227 | // handle possible profile change in get_rows |
| 1229 | 1228 | if (!empty($query['selectedFolder'])) |
| 1230 | 1229 | { |
| 1231 | - list($_profileID,$folderName) = explode(self::$delimiter, $query['selectedFolder'], 2); |
|
| 1230 | + list($_profileID, $folderName) = explode(self::$delimiter, $query['selectedFolder'], 2); |
|
| 1232 | 1231 | if (is_numeric(($_profileID)) && $_profileID != $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']) |
| 1233 | 1232 | { |
| 1234 | 1233 | try { |
| 1235 | - $mail_ui = new mail_ui(false); // do NOT run constructor, as we change profile anyway |
|
| 1234 | + $mail_ui = new mail_ui(false); // do NOT run constructor, as we change profile anyway |
|
| 1236 | 1235 | $mail_ui->changeProfile($_profileID); |
| 1237 | 1236 | $query['actions'] = $mail_ui->get_actions(); |
| 1238 | 1237 | } |
| 1239 | - catch(Exception $e) |
|
| 1238 | + catch (Exception $e) |
|
| 1240 | 1239 | { |
| 1241 | - $rows=array(); |
|
| 1240 | + $rows = array(); |
|
| 1242 | 1241 | return 0; |
| 1243 | 1242 | } |
| 1244 | 1243 | if (empty($folderName)) $query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX'; |
@@ -1246,7 +1245,7 @@ discard block |
||
| 1246 | 1245 | } |
| 1247 | 1246 | if (!isset($mail_ui)) |
| 1248 | 1247 | { |
| 1249 | - $mail_ui = new mail_ui(true); // run constructor for current profile |
|
| 1248 | + $mail_ui = new mail_ui(true); // run constructor for current profile |
|
| 1250 | 1249 | if (empty($query['selectedFolder'])) $query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX'; |
| 1251 | 1250 | } |
| 1252 | 1251 | |
@@ -1256,51 +1255,51 @@ discard block |
||
| 1256 | 1255 | //$query['search'] is the phrase in the searchbox |
| 1257 | 1256 | |
| 1258 | 1257 | $mail_ui->mail_bo->restoreSessionData(); |
| 1259 | - if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder']; |
|
| 1258 | + if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox'] = $query['selectedFolder']; |
|
| 1260 | 1259 | $mail_ui->mail_bo->saveSessionData(); |
| 1261 | 1260 | |
| 1262 | 1261 | $sRToFetch = null; |
| 1263 | - list($_profileID,$_folderName) = explode(self::$delimiter,$query['selectedFolder'],2); |
|
| 1264 | - if (strpos($_folderName,self::$delimiter)!==false) |
|
| 1262 | + list($_profileID, $_folderName) = explode(self::$delimiter, $query['selectedFolder'], 2); |
|
| 1263 | + if (strpos($_folderName, self::$delimiter) !== false) |
|
| 1265 | 1264 | { |
| 1266 | - list($app,$_profileID,$_folderName) = explode(self::$delimiter,$_folderName,3); |
|
| 1265 | + list($app, $_profileID, $_folderName) = explode(self::$delimiter, $_folderName, 3); |
|
| 1267 | 1266 | unset($app); |
| 1268 | 1267 | } |
| 1269 | 1268 | //save selected Folder to sessionData (mailbox)->currentFolder |
| 1270 | - if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$_folderName; |
|
| 1271 | - $toSchema = false;//decides to select list schema with column to selected (if false fromaddress is default) |
|
| 1269 | + if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox'] = $_folderName; |
|
| 1270 | + $toSchema = false; //decides to select list schema with column to selected (if false fromaddress is default) |
|
| 1272 | 1271 | if ($mail_ui->mail_bo->folderExists($_folderName)) |
| 1273 | 1272 | { |
| 1274 | - $toSchema = $mail_ui->mail_bo->isDraftFolder($_folderName,false)||$mail_ui->mail_bo->isSentFolder($_folderName,false)||$mail_ui->mail_bo->isTemplateFolder($_folderName,false); |
|
| 1273 | + $toSchema = $mail_ui->mail_bo->isDraftFolder($_folderName, false) || $mail_ui->mail_bo->isSentFolder($_folderName, false) || $mail_ui->mail_bo->isTemplateFolder($_folderName, false); |
|
| 1275 | 1274 | } |
| 1276 | 1275 | else |
| 1277 | 1276 | { |
| 1278 | 1277 | // take the extra time on failure |
| 1279 | - if (!$mail_ui->mail_bo->folderExists($_folderName,true)) |
|
| 1278 | + if (!$mail_ui->mail_bo->folderExists($_folderName, true)) |
|
| 1280 | 1279 | { |
| 1281 | 1280 | //error_log(__METHOD__.__LINE__.' Test on Folder:'.$_folderName.' failed; Using INBOX instead'); |
| 1282 | - $query['selectedFolder']=$mail_ui->mail_bo->sessionData['mailbox']=$_folderName='INBOX'; |
|
| 1281 | + $query['selectedFolder'] = $mail_ui->mail_bo->sessionData['mailbox'] = $_folderName = 'INBOX'; |
|
| 1283 | 1282 | } |
| 1284 | 1283 | } |
| 1285 | 1284 | $mail_ui->mail_bo->saveSessionData(); |
| 1286 | 1285 | $rowsFetched['messages'] = null; |
| 1287 | - $offset = $query['start']+1; // we always start with 1 |
|
| 1286 | + $offset = $query['start'] + 1; // we always start with 1 |
|
| 1288 | 1287 | $maxMessages = $query['num_rows']; |
| 1289 | 1288 | //error_log(__METHOD__.__LINE__.$query['order']); |
| 1290 | - $sort = ($query['order']=='address'?($toSchema?'toaddress':'fromaddress'):$query['order']); |
|
| 1289 | + $sort = ($query['order'] == 'address' ? ($toSchema ? 'toaddress' : 'fromaddress') : $query['order']); |
|
| 1291 | 1290 | if (!empty($query['search'])) |
| 1292 | 1291 | { |
| 1293 | 1292 | if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$mail_ui->mail_bo->profileID])) |
| 1294 | 1293 | { |
| 1295 | - emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
|
| 1294 | + emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 1296 | 1295 | if (!isset(emailadmin_imapbase::$supportsORinQuery[$mail_ui->mail_bo->profileID])) |
| 1297 | 1296 | { |
| 1298 | - emailadmin_imapbase::$supportsORinQuery[$mail_ui->mail_bo->profileID]=true; |
|
| 1297 | + emailadmin_imapbase::$supportsORinQuery[$mail_ui->mail_bo->profileID] = true; |
|
| 1299 | 1298 | } |
| 1300 | 1299 | } |
| 1301 | 1300 | $filter = array( |
| 1302 | - 'filterName' => (emailadmin_imapbase::$supportsORinQuery[$mail_ui->mail_bo->profileID]?lang('quicksearch'):lang('subject')), |
|
| 1303 | - 'type' => ($query['filter2']?$query['filter2']:(emailadmin_imapbase::$supportsORinQuery[$mail_ui->mail_bo->profileID]?'quick':'subject')), |
|
| 1301 | + 'filterName' => (emailadmin_imapbase::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? lang('quicksearch') : lang('subject')), |
|
| 1302 | + 'type' => ($query['filter2'] ? $query['filter2'] : (emailadmin_imapbase::$supportsORinQuery[$mail_ui->mail_bo->profileID] ? 'quick' : 'subject')), |
|
| 1304 | 1303 | 'string' => $query['search'], |
| 1305 | 1304 | 'status' => 'any'); |
| 1306 | 1305 | } |
@@ -1312,7 +1311,7 @@ discard block |
||
| 1312 | 1311 | { |
| 1313 | 1312 | $filter['status'] = $query['filter']; |
| 1314 | 1313 | } |
| 1315 | - $reverse = ($query['sort']=='ASC'?false:true); |
|
| 1314 | + $reverse = ($query['sort'] == 'ASC' ? false : true); |
|
| 1316 | 1315 | //error_log(__METHOD__.__LINE__.' maxMessages:'.$maxMessages.' Offset:'.$offset.' Filter:'.array2string($mail_ui->sessionData['messageFilter'])); |
| 1317 | 1316 | try |
| 1318 | 1317 | { |
@@ -1323,18 +1322,18 @@ discard block |
||
| 1323 | 1322 | $sort, |
| 1324 | 1323 | $reverse, |
| 1325 | 1324 | $filter, |
| 1326 | - $rByUid=true |
|
| 1325 | + $rByUid = true |
|
| 1327 | 1326 | ); |
| 1328 | 1327 | $rowsFetched['messages'] = $_sR['count']; |
| 1329 | 1328 | $sR = $_sR['match']->ids; |
| 1330 | 1329 | // if $sR is false, something failed fundamentally |
| 1331 | - if($reverse === true) $sR = ($sR===false?array():array_reverse((array)$sR)); |
|
| 1332 | - $sR = array_slice((array)$sR,($offset==0?0:$offset-1),$maxMessages); // we need only $maxMessages of uids |
|
| 1333 | - $sRToFetch = $sR;//array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids |
|
| 1330 | + if ($reverse === true) $sR = ($sR === false ? array() : array_reverse((array)$sR)); |
|
| 1331 | + $sR = array_slice((array)$sR, ($offset == 0 ? 0 : $offset - 1), $maxMessages); // we need only $maxMessages of uids |
|
| 1332 | + $sRToFetch = $sR; //array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids |
|
| 1334 | 1333 | //error_log(__METHOD__.__LINE__.' Rows fetched (UID only):'.count($sR).' Data:'.array2string($sR)); |
| 1335 | 1334 | $maxMessages = 75; |
| 1336 | 1335 | $sortResultwH['header'] = array(); |
| 1337 | - if (count($sRToFetch)>0) |
|
| 1336 | + if (count($sRToFetch) > 0) |
|
| 1338 | 1337 | { |
| 1339 | 1338 | //error_log(__METHOD__.__LINE__.' Headers to fetch with UIDs:'.count($sRToFetch).' Data:'.array2string($sRToFetch)); |
| 1340 | 1339 | $sortResult = array(); |
@@ -1372,23 +1371,23 @@ discard block |
||
| 1372 | 1371 | } |
| 1373 | 1372 | catch (Exception $e) |
| 1374 | 1373 | { |
| 1375 | - $sortResultwH=array(); |
|
| 1376 | - $sR=array(); |
|
| 1374 | + $sortResultwH = array(); |
|
| 1375 | + $sR = array(); |
|
| 1377 | 1376 | self::callWizard($e->getMessage(), false, 'error'); |
| 1378 | 1377 | } |
| 1379 | 1378 | $response = egw_json_response::get(); |
| 1380 | 1379 | // unlock immediately after fetching the rows |
| 1381 | - if (stripos($_GET['menuaction'],'ajax_get_rows')!==false) |
|
| 1380 | + if (stripos($_GET['menuaction'], 'ajax_get_rows') !== false) |
|
| 1382 | 1381 | { |
| 1383 | 1382 | //error_log(__METHOD__.__LINE__.' unlock tree ->'.$_GET['menuaction']); |
| 1384 | 1383 | $response->call('app.mail.unlock_tree'); |
| 1385 | 1384 | } |
| 1386 | 1385 | |
| 1387 | - if (is_array($sR) && count($sR)>0) |
|
| 1386 | + if (is_array($sR) && count($sR) > 0) |
|
| 1388 | 1387 | { |
| 1389 | 1388 | foreach ((array)$sR as $key => $v) |
| 1390 | 1389 | { |
| 1391 | - if (array_key_exists($key,(array)$sortResultwH['header'])==true) |
|
| 1390 | + if (array_key_exists($key, (array)$sortResultwH['header']) == true) |
|
| 1392 | 1391 | { |
| 1393 | 1392 | $sortResult['header'][] = $sortResultwH['header'][$key]; |
| 1394 | 1393 | } |
@@ -1406,12 +1405,12 @@ discard block |
||
| 1406 | 1405 | if (empty($rowsFetched['messages'])) $rowsFetched['messages'] = $rowsFetched['rowsFetched']; |
| 1407 | 1406 | |
| 1408 | 1407 | //error_log(__METHOD__.__LINE__.' Rows fetched:'.$rowsFetched.' Data:'.array2string($sortResult)); |
| 1409 | - $cols = array('row_id','uid','status','attachments','subject','address','toaddress','fromaddress','ccaddress','additionaltoaddress','date','size','modified','bodypreview'); |
|
| 1410 | - if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE') unset($cols[0]); |
|
| 1411 | - $rows = $mail_ui->header2gridelements($sortResult['header'],$cols, $_folderName, $folderType=$toSchema); |
|
| 1408 | + $cols = array('row_id', 'uid', 'status', 'attachments', 'subject', 'address', 'toaddress', 'fromaddress', 'ccaddress', 'additionaltoaddress', 'date', 'size', 'modified', 'bodypreview'); |
|
| 1409 | + if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode'] == 'EGW_SELECTMODE_TOGGLE') unset($cols[0]); |
|
| 1410 | + $rows = $mail_ui->header2gridelements($sortResult['header'], $cols, $_folderName, $folderType = $toSchema); |
|
| 1412 | 1411 | //error_log(__METHOD__.__LINE__.array2string($rows)); |
| 1413 | 1412 | |
| 1414 | - if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__); |
|
| 1413 | + if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime, null, 'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'], __METHOD__.__LINE__); |
|
| 1415 | 1414 | return $rowsFetched['messages']; |
| 1416 | 1415 | } |
| 1417 | 1416 | |
@@ -1423,7 +1422,7 @@ discard block |
||
| 1423 | 1422 | * @param boolean $_prependApp to indicate that the app 'mail' is to be used for creating the rowID |
| 1424 | 1423 | * @return string - a colon separated string in the form [app:]accountID:profileID:folder:message_uid |
| 1425 | 1424 | */ |
| 1426 | - function createRowID($_folderName, $message_uid, $_prependApp=false) |
|
| 1425 | + function createRowID($_folderName, $message_uid, $_prependApp = false) |
|
| 1427 | 1426 | { |
| 1428 | 1427 | return self::generateRowID($this->mail_bo->profileID, $_folderName, $message_uid, $_prependApp); |
| 1429 | 1428 | } |
@@ -1437,9 +1436,9 @@ discard block |
||
| 1437 | 1436 | * @param boolean $_prependApp to indicate that the app 'mail' is to be used for creating the rowID |
| 1438 | 1437 | * @return string - a colon separated string in the form [app:]accountID:profileID:folder:message_uid |
| 1439 | 1438 | */ |
| 1440 | - static function generateRowID($_profileID, $_folderName, $message_uid, $_prependApp=false) |
|
| 1439 | + static function generateRowID($_profileID, $_folderName, $message_uid, $_prependApp = false) |
|
| 1441 | 1440 | { |
| 1442 | - return ($_prependApp?'mail'.self::$delimiter:'').trim($GLOBALS['egw_info']['user']['account_id']).self::$delimiter.$_profileID.self::$delimiter.base64_encode($_folderName).self::$delimiter.$message_uid; |
|
| 1441 | + return ($_prependApp ? 'mail'.self::$delimiter : '').trim($GLOBALS['egw_info']['user']['account_id']).self::$delimiter.$_profileID.self::$delimiter.base64_encode($_folderName).self::$delimiter.$message_uid; |
|
| 1443 | 1442 | } |
| 1444 | 1443 | |
| 1445 | 1444 | /** |
@@ -1450,13 +1449,13 @@ discard block |
||
| 1450 | 1449 | */ |
| 1451 | 1450 | static function splitRowID($_rowID) |
| 1452 | 1451 | { |
| 1453 | - $res = explode(self::$delimiter,$_rowID); |
|
| 1452 | + $res = explode(self::$delimiter, $_rowID); |
|
| 1454 | 1453 | // as a rowID is perceeded by app::, should be mail! |
| 1455 | 1454 | //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)); |
| 1456 | - if (count($res)==4 && is_numeric($res[0]) ) |
|
| 1455 | + if (count($res) == 4 && is_numeric($res[0])) |
|
| 1457 | 1456 | { |
| 1458 | 1457 | // we have an own created rowID; prepend app=mail |
| 1459 | - array_unshift($res,'mail'); |
|
| 1458 | + array_unshift($res, 'mail'); |
|
| 1460 | 1459 | } |
| 1461 | 1460 | return array('app'=>$res[0], 'accountID'=>$res[1], 'profileID'=>$res[2], 'folder'=>base64_decode($res[3]), 'msgUID'=>$res[4]); |
| 1462 | 1461 | } |
@@ -1470,56 +1469,56 @@ discard block |
||
| 1470 | 1469 | { |
| 1471 | 1470 | $actions = $this->get_actions(); |
| 1472 | 1471 | $arrActions = array('composeasnew', 'reply', 'reply_all', 'forward', 'flagged', 'delete', 'print', |
| 1473 | - 'infolog', 'tracker', 'calendar', 'save', 'view', 'read', 'label1', 'label2', 'label3', 'label4', 'label5'); |
|
| 1474 | - foreach( $arrActions as &$act) |
|
| 1472 | + 'infolog', 'tracker', 'calendar', 'save', 'view', 'read', 'label1', 'label2', 'label3', 'label4', 'label5'); |
|
| 1473 | + foreach ($arrActions as &$act) |
|
| 1475 | 1474 | { |
| 1476 | 1475 | //error_log(__METHOD__.__LINE__.' '.$act.'->'.array2string($actions[$act])); |
| 1477 | 1476 | switch ($act) |
| 1478 | 1477 | { |
| 1479 | 1478 | case 'forward': |
| 1480 | - $actionsenabled[$act]=$actions[$act]; |
|
| 1479 | + $actionsenabled[$act] = $actions[$act]; |
|
| 1481 | 1480 | break; |
| 1482 | 1481 | case 'save': |
| 1483 | - $actionsenabled[$act]=$actions[$act]; |
|
| 1482 | + $actionsenabled[$act] = $actions[$act]; |
|
| 1484 | 1483 | |
| 1485 | 1484 | break; |
| 1486 | 1485 | case 'view': |
| 1487 | - $actionsenabled[$act]=$actions[$act]; |
|
| 1486 | + $actionsenabled[$act] = $actions[$act]; |
|
| 1488 | 1487 | break; |
| 1489 | 1488 | case 'flagged': |
| 1490 | - $actionsenabled[$act]= $actions['mark']['children'][$act]; |
|
| 1489 | + $actionsenabled[$act] = $actions['mark']['children'][$act]; |
|
| 1491 | 1490 | break; |
| 1492 | 1491 | case 'read': |
| 1493 | - $actionsenabled[$act]= $actions['mark']['children'][$act]; |
|
| 1492 | + $actionsenabled[$act] = $actions['mark']['children'][$act]; |
|
| 1494 | 1493 | break; |
| 1495 | 1494 | case 'label1': |
| 1496 | 1495 | $actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('important'); |
| 1497 | - $actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1496 | + $actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1498 | 1497 | break; |
| 1499 | 1498 | case 'label2': |
| 1500 | 1499 | $actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('job'); |
| 1501 | - $actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1500 | + $actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1502 | 1501 | break; |
| 1503 | 1502 | case 'label3': |
| 1504 | 1503 | $actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('personal'); |
| 1505 | - $actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1504 | + $actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1506 | 1505 | break; |
| 1507 | 1506 | case 'label4': |
| 1508 | 1507 | $actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('to do'); |
| 1509 | - $actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1508 | + $actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1510 | 1509 | break; |
| 1511 | 1510 | case 'label5': |
| 1512 | 1511 | $actions['mark']['children']['setLabel']['children'][$act]['caption'] = lang('later'); |
| 1513 | - $actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1512 | + $actionsenabled[$act] = $actions['mark']['children']['setLabel']['children'][$act]; |
|
| 1514 | 1513 | break; |
| 1515 | 1514 | default: |
| 1516 | - if (isset($actions[$act])) $actionsenabled[$act]=$actions[$act]; |
|
| 1515 | + if (isset($actions[$act])) $actionsenabled[$act] = $actions[$act]; |
|
| 1517 | 1516 | } |
| 1518 | 1517 | } |
| 1519 | 1518 | unset($actionsenabled['drag_mail']); |
| 1520 | 1519 | //error_log(array2string($actionsenabled['view'])); |
| 1521 | - unset($actionsenabled['view']['children']['openastext']);//not supported in preview |
|
| 1522 | - unset($actionsenabled['view']['children']['openashtml']);//not supported in preview |
|
| 1520 | + unset($actionsenabled['view']['children']['openastext']); //not supported in preview |
|
| 1521 | + unset($actionsenabled['view']['children']['openashtml']); //not supported in preview |
|
| 1523 | 1522 | |
| 1524 | 1523 | return $actionsenabled; |
| 1525 | 1524 | } |
@@ -1533,45 +1532,45 @@ discard block |
||
| 1533 | 1532 | * @param array $_folderType used to determine if we need to populate from/to |
| 1534 | 1533 | * @return array populated result array |
| 1535 | 1534 | */ |
| 1536 | - public function header2gridelements($_headers, $cols, $_folderName, $_folderType=0) |
|
| 1535 | + public function header2gridelements($_headers, $cols, $_folderName, $_folderType = 0) |
|
| 1537 | 1536 | { |
| 1538 | 1537 | if (mail_bo::$debugTimes) $starttime = microtime(true); |
| 1539 | 1538 | $rv = array(); |
| 1540 | - $i=0; |
|
| 1541 | - foreach((array)$_headers as $header) |
|
| 1539 | + $i = 0; |
|
| 1540 | + foreach ((array)$_headers as $header) |
|
| 1542 | 1541 | { |
| 1543 | 1542 | $i++; |
| 1544 | 1543 | $data = array(); |
| 1545 | 1544 | //error_log(__METHOD__.array2string($header)); |
| 1546 | 1545 | $message_uid = $header['uid']; |
| 1547 | 1546 | $data['uid'] = $message_uid; |
| 1548 | - $data['row_id']=$this->createRowID($_folderName,$message_uid); |
|
| 1547 | + $data['row_id'] = $this->createRowID($_folderName, $message_uid); |
|
| 1549 | 1548 | |
| 1550 | 1549 | $flags = ""; |
| 1551 | - if(!empty($header['recent'])) $flags .= "R"; |
|
| 1552 | - if(!empty($header['flagged'])) $flags .= "F"; |
|
| 1553 | - if(!empty($header['answered'])) $flags .= "A"; |
|
| 1554 | - if(!empty($header['forwarded'])) $flags .= "W"; |
|
| 1555 | - if(!empty($header['deleted'])) $flags .= "D"; |
|
| 1556 | - if(!empty($header['seen'])) $flags .= "S"; |
|
| 1557 | - if(!empty($header['label1'])) $flags .= "1"; |
|
| 1558 | - if(!empty($header['label2'])) $flags .= "2"; |
|
| 1559 | - if(!empty($header['label3'])) $flags .= "3"; |
|
| 1560 | - if(!empty($header['label4'])) $flags .= "4"; |
|
| 1561 | - if(!empty($header['label5'])) $flags .= "5"; |
|
| 1550 | + if (!empty($header['recent'])) $flags .= "R"; |
|
| 1551 | + if (!empty($header['flagged'])) $flags .= "F"; |
|
| 1552 | + if (!empty($header['answered'])) $flags .= "A"; |
|
| 1553 | + if (!empty($header['forwarded'])) $flags .= "W"; |
|
| 1554 | + if (!empty($header['deleted'])) $flags .= "D"; |
|
| 1555 | + if (!empty($header['seen'])) $flags .= "S"; |
|
| 1556 | + if (!empty($header['label1'])) $flags .= "1"; |
|
| 1557 | + if (!empty($header['label2'])) $flags .= "2"; |
|
| 1558 | + if (!empty($header['label3'])) $flags .= "3"; |
|
| 1559 | + if (!empty($header['label4'])) $flags .= "4"; |
|
| 1560 | + if (!empty($header['label5'])) $flags .= "5"; |
|
| 1562 | 1561 | |
| 1563 | 1562 | $data["status"] = "<span class=\"status_img\"></span>"; |
| 1564 | 1563 | //error_log(__METHOD__.array2string($header).' Flags:'.$flags); |
| 1565 | 1564 | |
| 1566 | 1565 | // the css for this row |
| 1567 | - $is_recent=false; |
|
| 1566 | + $is_recent = false; |
|
| 1568 | 1567 | $css_styles = array("mail"); |
| 1569 | 1568 | if ($header['deleted']) { |
| 1570 | 1569 | $css_styles[] = 'deleted'; |
| 1571 | 1570 | } |
| 1572 | 1571 | if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded'])) { |
| 1573 | 1572 | $css_styles[] = 'recent'; |
| 1574 | - $is_recent=true; |
|
| 1573 | + $is_recent = true; |
|
| 1575 | 1574 | } |
| 1576 | 1575 | if ($header['priority'] < 3) { |
| 1577 | 1576 | $css_styles[] = 'prio_high'; |
@@ -1609,19 +1608,19 @@ discard block |
||
| 1609 | 1608 | if (in_array("subject", $cols)) |
| 1610 | 1609 | { |
| 1611 | 1610 | // filter out undisplayable characters |
| 1612 | - $search = array('[\016]','[\017]', |
|
| 1613 | - '[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]', |
|
| 1614 | - '[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]'); |
|
| 1611 | + $search = array('[\016]', '[\017]', |
|
| 1612 | + '[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]', |
|
| 1613 | + '[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]'); |
|
| 1615 | 1614 | $replace = ''; |
| 1616 | 1615 | |
| 1617 | - $header['subject'] = preg_replace($search,$replace,$header['subject']); |
|
| 1616 | + $header['subject'] = preg_replace($search, $replace, $header['subject']); |
|
| 1618 | 1617 | // curly brackets get messed up by the template! |
| 1619 | 1618 | |
| 1620 | 1619 | if (!empty($header['subject'])) { |
| 1621 | 1620 | // make the subject shorter if it is to long |
| 1622 | 1621 | $subject = $header['subject']; |
| 1623 | 1622 | } else { |
| 1624 | - $subject = '('. lang('no subject') .')'; |
|
| 1623 | + $subject = '('.lang('no subject').')'; |
|
| 1625 | 1624 | } |
| 1626 | 1625 | |
| 1627 | 1626 | $data["subject"] = $subject; // the mailsubject |
@@ -1631,53 +1630,53 @@ discard block |
||
| 1631 | 1630 | //error_log(__METHOD__.__LINE__.array2string($header)); |
| 1632 | 1631 | if (in_array("attachments", $cols)) |
| 1633 | 1632 | { |
| 1634 | - if($header['mimetype'] == 'multipart/mixed' || |
|
| 1633 | + if ($header['mimetype'] == 'multipart/mixed' || |
|
| 1635 | 1634 | $header['mimetype'] == 'multipart/signed' || |
| 1636 | 1635 | $header['mimetype'] == 'multipart/related' || |
| 1637 | 1636 | $header['mimetype'] == 'multipart/report' || |
| 1638 | 1637 | $header['mimetype'] == 'text/calendar' || |
| 1639 | 1638 | $header['mimetype'] == 'text/html' || |
| 1640 | - substr($header['mimetype'],0,11) == 'application' || |
|
| 1641 | - substr($header['mimetype'],0,5) == 'audio' || |
|
| 1642 | - substr($header['mimetype'],0,5) == 'video' || |
|
| 1639 | + substr($header['mimetype'], 0, 11) == 'application' || |
|
| 1640 | + substr($header['mimetype'], 0, 5) == 'audio' || |
|
| 1641 | + substr($header['mimetype'], 0, 5) == 'video' || |
|
| 1643 | 1642 | $header['mimetype'] == 'multipart/alternative') |
| 1644 | 1643 | { |
| 1645 | - $image = html::image('mail','attach'); |
|
| 1644 | + $image = html::image('mail', 'attach'); |
|
| 1646 | 1645 | $imageHTMLBlock = ''; |
| 1647 | - $datarowid = $this->createRowID($_folderName,$message_uid,true); |
|
| 1646 | + $datarowid = $this->createRowID($_folderName, $message_uid, true); |
|
| 1648 | 1647 | $attachments = $header['attachments']; |
| 1649 | - if (count($attachments)<1) |
|
| 1648 | + if (count($attachments) < 1) |
|
| 1650 | 1649 | { |
| 1651 | 1650 | $image = ' '; |
| 1652 | 1651 | } |
| 1653 | - if (count($attachments)==1) |
|
| 1652 | + if (count($attachments) == 1) |
|
| 1654 | 1653 | { |
| 1655 | - $imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'],$_folderName); |
|
| 1656 | - $image = html::image('mail','attach',$attachments[0]['name'].(!empty($attachments[0]['mimeType'])?' ('.$attachments[0]['mimeType'].')':'')); |
|
| 1654 | + $imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'], $_folderName); |
|
| 1655 | + $image = html::image('mail', 'attach', $attachments[0]['name'].(!empty($attachments[0]['mimeType']) ? ' ('.$attachments[0]['mimeType'].')' : '')); |
|
| 1657 | 1656 | } |
| 1658 | - if (count($attachments)>1) |
|
| 1657 | + if (count($attachments) > 1) |
|
| 1659 | 1658 | { |
| 1660 | - $imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'],$_folderName); |
|
| 1661 | - $image = html::image('mail','attach',lang('%1 attachments',count($attachments))); |
|
| 1659 | + $imageHTMLBlock = self::createAttachmentBlock($attachments, $datarowid, $header['uid'], $_folderName); |
|
| 1660 | + $image = html::image('mail', 'attach', lang('%1 attachments', count($attachments))); |
|
| 1662 | 1661 | } |
| 1663 | 1662 | |
| 1664 | 1663 | $attachmentFlag = $image; |
| 1665 | 1664 | } else { |
| 1666 | - $attachmentFlag =' '; |
|
| 1665 | + $attachmentFlag = ' '; |
|
| 1667 | 1666 | } |
| 1668 | 1667 | // show priority flag |
| 1669 | 1668 | if ($header['priority'] < 3) { |
| 1670 | - $image = html::image('mail','prio_high'); |
|
| 1669 | + $image = html::image('mail', 'prio_high'); |
|
| 1671 | 1670 | } elseif ($header['priority'] > 3) { |
| 1672 | - $image = html::image('mail','prio_low'); |
|
| 1671 | + $image = html::image('mail', 'prio_low'); |
|
| 1673 | 1672 | } else { |
| 1674 | 1673 | $image = ''; |
| 1675 | 1674 | } |
| 1676 | 1675 | // show a flag for flagged messages |
| 1677 | - $imageflagged =''; |
|
| 1676 | + $imageflagged = ''; |
|
| 1678 | 1677 | if ($header['flagged']) |
| 1679 | 1678 | { |
| 1680 | - $imageflagged = html::image('mail','unread_flagged_small'); |
|
| 1679 | + $imageflagged = html::image('mail', 'unread_flagged_small'); |
|
| 1681 | 1680 | } |
| 1682 | 1681 | $data["attachments"] = $image.$attachmentFlag.$imageflagged; // icon for attachments available |
| 1683 | 1682 | } |
@@ -1686,7 +1685,7 @@ discard block |
||
| 1686 | 1685 | if (in_array("toaddress", $cols)) |
| 1687 | 1686 | { |
| 1688 | 1687 | // sent or drafts or template folder means foldertype > 0, use to address instead of from |
| 1689 | - $data["toaddress"] = $header['to_address'];//mail_bo::htmlentities($header['to_address'],$this->charset); |
|
| 1688 | + $data["toaddress"] = $header['to_address']; //mail_bo::htmlentities($header['to_address'],$this->charset); |
|
| 1690 | 1689 | } |
| 1691 | 1690 | |
| 1692 | 1691 | if (in_array("additionaltoaddress", $cols)) |
@@ -1719,29 +1718,29 @@ discard block |
||
| 1719 | 1718 | $data['flags'] = Array(); |
| 1720 | 1719 | if ($header['seen']) $data["flags"]['read'] = 'read'; |
| 1721 | 1720 | foreach ($css_styles as &$flag) { |
| 1722 | - if ($flag!='mail') |
|
| 1721 | + if ($flag != 'mail') |
|
| 1723 | 1722 | { |
| 1724 | - if ($flag=='labelone') {$data["flags"]['label1'] = 'label1';} |
|
| 1725 | - elseif ($flag=='labeltwo') {$data["flags"]['label2'] = 'label2';} |
|
| 1726 | - elseif ($flag=='labelthree') {$data["flags"]['label3'] = 'label3';} |
|
| 1727 | - elseif ($flag=='labelfour') {$data["flags"]['label4'] = 'label4';} |
|
| 1728 | - elseif ($flag=='labelfive') {$data["flags"]['label5'] = 'label5';} |
|
| 1729 | - elseif ($flag=='unseen') {unset($data["flags"]['read']);} |
|
| 1723 | + if ($flag == 'labelone') {$data["flags"]['label1'] = 'label1'; } |
|
| 1724 | + elseif ($flag == 'labeltwo') {$data["flags"]['label2'] = 'label2'; } |
|
| 1725 | + elseif ($flag == 'labelthree') {$data["flags"]['label3'] = 'label3'; } |
|
| 1726 | + elseif ($flag == 'labelfour') {$data["flags"]['label4'] = 'label4'; } |
|
| 1727 | + elseif ($flag == 'labelfive') {$data["flags"]['label5'] = 'label5'; } |
|
| 1728 | + elseif ($flag == 'unseen') {unset($data["flags"]['read']); } |
|
| 1730 | 1729 | else $data["flags"][$flag] = $flag; |
| 1731 | 1730 | } |
| 1732 | 1731 | } |
| 1733 | 1732 | if ($header['disposition-notification-to']) $data['dispositionnotificationto'] = $header['disposition-notification-to']; |
| 1734 | - if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']); |
|
| 1733 | + if (($header['mdnsent'] || $header['mdnnotsent']|$header['seen']) && isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']); |
|
| 1735 | 1734 | $data['attachmentsBlock'] = $imageHTMLBlock; |
| 1736 | - $data['address'] = ($_folderType?$data["toaddress"]:$data["fromaddress"]); |
|
| 1737 | - if (in_array("bodypreview", $cols)&&$header['bodypreview']) |
|
| 1735 | + $data['address'] = ($_folderType ? $data["toaddress"] : $data["fromaddress"]); |
|
| 1736 | + if (in_array("bodypreview", $cols) && $header['bodypreview']) |
|
| 1738 | 1737 | { |
| 1739 | 1738 | $data["bodypreview"] = $header['bodypreview']; |
| 1740 | 1739 | } |
| 1741 | 1740 | $rv[] = $data; |
| 1742 | 1741 | //error_log(__METHOD__.__LINE__.array2string($data)); |
| 1743 | 1742 | } |
| 1744 | - if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__); |
|
| 1743 | + if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime, null, 'Folder:'.$_folderName, __METHOD__.__LINE__); |
|
| 1745 | 1744 | |
| 1746 | 1745 | // ToDo: call this ONLY if labels change |
| 1747 | 1746 | etemplate_widget::setElementAttribute('toolbar', 'actions', $this->get_toolbar_actions()); |
@@ -1756,8 +1755,8 @@ discard block |
||
| 1756 | 1755 | */ |
| 1757 | 1756 | function displayHeader() |
| 1758 | 1757 | { |
| 1759 | - if(isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 1760 | - if(isset($_GET['part'])) $partID = $_GET['part']; |
|
| 1758 | + if (isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 1759 | + if (isset($_GET['part'])) $partID = $_GET['part']; |
|
| 1761 | 1760 | |
| 1762 | 1761 | $hA = self::splitRowID($rowID); |
| 1763 | 1762 | $uid = $hA['msgUID']; |
@@ -1771,17 +1770,17 @@ discard block |
||
| 1771 | 1770 | } |
| 1772 | 1771 | |
| 1773 | 1772 | $this->mail_bo->reopen($mailbox); |
| 1774 | - $rawheaders = $this->mail_bo->getMessageRawHeader($uid, $partID); |
|
| 1773 | + $rawheaders = $this->mail_bo->getMessageRawHeader($uid, $partID); |
|
| 1775 | 1774 | |
| 1776 | 1775 | // add line breaks to $rawheaders |
| 1777 | - $newRawHeaders = explode("\n",$rawheaders); |
|
| 1776 | + $newRawHeaders = explode("\n", $rawheaders); |
|
| 1778 | 1777 | reset($newRawHeaders); |
| 1779 | 1778 | |
| 1780 | 1779 | // reset $rawheaders |
| 1781 | - $rawheaders = ""; |
|
| 1780 | + $rawheaders = ""; |
|
| 1782 | 1781 | // create it new, with good line breaks |
| 1783 | 1782 | reset($newRawHeaders); |
| 1784 | - while(list($key,$value) = @each($newRawHeaders)) { |
|
| 1783 | + while (list($key, $value) = @each($newRawHeaders)) { |
|
| 1785 | 1784 | $rawheaders .= wordwrap($value, 90, "\n "); |
| 1786 | 1785 | } |
| 1787 | 1786 | |
@@ -1793,7 +1792,7 @@ discard block |
||
| 1793 | 1792 | } |
| 1794 | 1793 | |
| 1795 | 1794 | header('Content-type: text/html; charset=iso-8859-1'); |
| 1796 | - print '<pre>'. htmlspecialchars($rawheaders, ENT_NOQUOTES, 'iso-8859-1') .'</pre>'; |
|
| 1795 | + print '<pre>'.htmlspecialchars($rawheaders, ENT_NOQUOTES, 'iso-8859-1').'</pre>'; |
|
| 1797 | 1796 | |
| 1798 | 1797 | } |
| 1799 | 1798 | |
@@ -1806,10 +1805,10 @@ discard block |
||
| 1806 | 1805 | { |
| 1807 | 1806 | if (is_null($_requesteddata)) $_requesteddata = $_GET; |
| 1808 | 1807 | |
| 1809 | - $preventRedirect=false; |
|
| 1810 | - if(isset($_requesteddata['id'])) $rowID = $_requesteddata['id']; |
|
| 1811 | - if(isset($_requesteddata['part'])) $partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null; |
|
| 1812 | - if(isset($_requesteddata['mode'])) $preventRedirect = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false); |
|
| 1808 | + $preventRedirect = false; |
|
| 1809 | + if (isset($_requesteddata['id'])) $rowID = $_requesteddata['id']; |
|
| 1810 | + if (isset($_requesteddata['part'])) $partID = $_requesteddata['part'] != 'null' ? $_requesteddata['part'] : null; |
|
| 1811 | + if (isset($_requesteddata['mode'])) $preventRedirect = (($_requesteddata['mode'] == 'display' || $_requesteddata['mode'] == 'print') ? true : false); |
|
| 1813 | 1812 | |
| 1814 | 1813 | $hA = self::splitRowID($rowID); |
| 1815 | 1814 | $uid = $hA['msgUID']; |
@@ -1833,78 +1832,78 @@ discard block |
||
| 1833 | 1832 | } |
| 1834 | 1833 | if (!$preventRedirect && ($this->mail_bo->isDraftFolder($mailbox) || $this->mail_bo->isTemplateFolder($mailbox))) |
| 1835 | 1834 | { |
| 1836 | - egw::redirect_link('/index.php',array('menuaction'=>'mail.mail_compose.compose','id'=>$rowID,'from'=>'composefromdraft')); |
|
| 1835 | + egw::redirect_link('/index.php', array('menuaction'=>'mail.mail_compose.compose', 'id'=>$rowID, 'from'=>'composefromdraft')); |
|
| 1837 | 1836 | } |
| 1838 | 1837 | $this->mail_bo->reopen($mailbox); |
| 1839 | 1838 | // retrieve the flags of the message, before touching it. |
| 1840 | 1839 | try |
| 1841 | 1840 | { |
| 1842 | - $headers = $this->mail_bo->getMessageHeader($uid, $partID,true,true,$mailbox); |
|
| 1841 | + $headers = $this->mail_bo->getMessageHeader($uid, $partID, true, true, $mailbox); |
|
| 1843 | 1842 | } |
| 1844 | 1843 | catch (egw_exception $e) |
| 1845 | 1844 | { |
| 1846 | 1845 | $error_msg[] = lang("ERROR: Message could not be displayed."); |
| 1847 | - $error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3",$mailbox,$uid,$partID); |
|
| 1846 | + $error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3", $mailbox, $uid, $partID); |
|
| 1848 | 1847 | egw_framework::message($e->getMessage(), 'error'); |
| 1849 | 1848 | } |
| 1850 | 1849 | if (!empty($uid)) $this->mail_bo->getFlags($uid); |
| 1851 | - $envelope = $this->mail_bo->getMessageEnvelope($uid, $partID,true,$mailbox); |
|
| 1850 | + $envelope = $this->mail_bo->getMessageEnvelope($uid, $partID, true, $mailbox); |
|
| 1852 | 1851 | //error_log(__METHOD__.__LINE__.array2string($envelope)); |
| 1853 | - $this->mail_bo->getMessageRawHeader($uid, $partID,$mailbox); |
|
| 1852 | + $this->mail_bo->getMessageRawHeader($uid, $partID, $mailbox); |
|
| 1854 | 1853 | $fetchEmbeddedImages = false; |
| 1855 | 1854 | // if we are in HTML so its likely that we should show the embedded images; as a result |
| 1856 | 1855 | // we do NOT want to see those, that are embedded in the list of attachments |
| 1857 | - if ($htmlOptions !='always_display') $fetchEmbeddedImages = true; |
|
| 1858 | - $attachments = $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages,true,true,$mailbox); |
|
| 1856 | + if ($htmlOptions != 'always_display') $fetchEmbeddedImages = true; |
|
| 1857 | + $attachments = $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages, true, true, $mailbox); |
|
| 1859 | 1858 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
| 1860 | 1859 | $attachmentHTMLBlock = self::createAttachmentBlock($attachments, $rowID, $uid, $mailbox); |
| 1861 | 1860 | //error_log(__METHOD__.__LINE__.array2string($attachmentHTMLBlock)); |
| 1862 | - $nonDisplayAbleCharacters = array('[\016]','[\017]', |
|
| 1863 | - '[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]', |
|
| 1864 | - '[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]'); |
|
| 1861 | + $nonDisplayAbleCharacters = array('[\016]', '[\017]', |
|
| 1862 | + '[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]', |
|
| 1863 | + '[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]'); |
|
| 1865 | 1864 | |
| 1866 | 1865 | //error_log(__METHOD__.__LINE__.$mailBody); |
| 1867 | 1866 | $this->mail_bo->closeConnection(); |
| 1868 | 1867 | //$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed |
| 1869 | 1868 | $etpl = new etemplate_new('mail.display'); |
| 1870 | - $subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters,'',$envelope['SUBJECT']),false); |
|
| 1869 | + $subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters, '', $envelope['SUBJECT']), false); |
|
| 1871 | 1870 | |
| 1872 | 1871 | // Set up data for taglist widget(s) |
| 1873 | - if ($envelope['FROM']==$envelope['SENDER']) unset($envelope['SENDER']); |
|
| 1874 | - foreach(array('SENDER','FROM','TO','CC','BCC') as $field) |
|
| 1872 | + if ($envelope['FROM'] == $envelope['SENDER']) unset($envelope['SENDER']); |
|
| 1873 | + foreach (array('SENDER', 'FROM', 'TO', 'CC', 'BCC') as $field) |
|
| 1875 | 1874 | { |
| 1876 | 1875 | if (!isset($envelope[$field])) continue; |
| 1877 | - foreach($envelope[$field] as $field_data) |
|
| 1876 | + foreach ($envelope[$field] as $field_data) |
|
| 1878 | 1877 | { |
| 1879 | 1878 | //error_log(__METHOD__.__LINE__.array2string($field_data)); |
| 1880 | 1879 | $content[$field][] = $field_data; |
| 1881 | 1880 | $sel_options[$field][] = array( |
| 1882 | 1881 | // taglist requires these - not optional |
| 1883 | 1882 | 'id' => $field_data, |
| 1884 | - 'label' => str_replace('"',"'",$field_data), |
|
| 1883 | + 'label' => str_replace('"', "'", $field_data), |
|
| 1885 | 1884 | ); |
| 1886 | 1885 | } |
| 1887 | 1886 | } |
| 1888 | 1887 | $actionsenabled = $this->getDisplayToolbarActions(); |
| 1889 | 1888 | $content['displayToolbaractions'] = json_encode($actionsenabled); |
| 1890 | 1889 | if (empty($subject)) $subject = lang('no subject'); |
| 1891 | - $content['msg'] = (is_array($error_msg)?implode("<br>",$error_msg):$error_msg); |
|
| 1890 | + $content['msg'] = (is_array($error_msg) ? implode("<br>", $error_msg) : $error_msg); |
|
| 1892 | 1891 | // Send mail ID so we can use it for actions |
| 1893 | 1892 | $content['mail_id'] = $rowID; |
| 1894 | 1893 | if (!is_array($headers) || !isset($headers['DATE'])) |
| 1895 | 1894 | { |
| 1896 | - $headers['DATE'] = (is_array($envelope)&&$envelope['DATE']?$envelope['DATE']:''); |
|
| 1895 | + $headers['DATE'] = (is_array($envelope) && $envelope['DATE'] ? $envelope['DATE'] : ''); |
|
| 1897 | 1896 | } |
| 1898 | - $content['mail_displaydate'] = mail_bo::_strtotime($headers['DATE'],'ts',true); |
|
| 1897 | + $content['mail_displaydate'] = mail_bo::_strtotime($headers['DATE'], 'ts', true); |
|
| 1899 | 1898 | $content['mail_displaysubject'] = $subject; |
| 1900 | - $linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody","_messageID"=>$rowID); |
|
| 1901 | - if (!empty($partID)) $linkData['_partID']=$partID; |
|
| 1902 | - if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions']=$htmlOptions; |
|
| 1903 | - $content['mailDisplayBodySrc'] = egw::link('/index.php',$linkData); |
|
| 1899 | + $linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody", "_messageID"=>$rowID); |
|
| 1900 | + if (!empty($partID)) $linkData['_partID'] = $partID; |
|
| 1901 | + if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions'] = $htmlOptions; |
|
| 1902 | + $content['mailDisplayBodySrc'] = egw::link('/index.php', $linkData); |
|
| 1904 | 1903 | $content['mail_displayattachments'] = $attachmentHTMLBlock; |
| 1905 | - $content['mail_id']=$rowID; |
|
| 1906 | - $content['mailDisplayContainerClass']=(count($attachments)?"mailDisplayContainer mailDisplayContainerFixedHeight":"mailDisplayContainer mailDisplayContainerFullHeight"); |
|
| 1907 | - $content['mailDisplayAttachmentsClass']=(count($attachments)?"mailDisplayAttachments":"mail_DisplayNone"); |
|
| 1904 | + $content['mail_id'] = $rowID; |
|
| 1905 | + $content['mailDisplayContainerClass'] = (count($attachments) ? "mailDisplayContainer mailDisplayContainerFixedHeight" : "mailDisplayContainer mailDisplayContainerFullHeight"); |
|
| 1906 | + $content['mailDisplayAttachmentsClass'] = (count($attachments) ? "mailDisplayAttachments" : "mail_DisplayNone"); |
|
| 1908 | 1907 | |
| 1909 | 1908 | // DRAG attachments actions |
| 1910 | 1909 | $etpl->setElementAttribute('mail_displayattachments', 'actions', array( |
@@ -1921,22 +1920,22 @@ discard block |
||
| 1921 | 1920 | $this->changeProfile($rememberServerID); |
| 1922 | 1921 | } |
| 1923 | 1922 | |
| 1924 | - $etpl->exec('mail.mail_ui.displayMessage',$content,$sel_options,$readonlys,$preserv,2); |
|
| 1923 | + $etpl->exec('mail.mail_ui.displayMessage', $content, $sel_options, $readonlys, $preserv, 2); |
|
| 1925 | 1924 | } |
| 1926 | 1925 | |
| 1927 | 1926 | /** |
| 1928 | 1927 | * Build actions for display toolbar |
| 1929 | 1928 | */ |
| 1930 | - function getDisplayToolbarActions () |
|
| 1929 | + function getDisplayToolbarActions() |
|
| 1931 | 1930 | { |
| 1932 | 1931 | $actions = $this->get_toolbar_actions(); |
| 1933 | - $actions['mark']['children']['flagged']=array( |
|
| 1932 | + $actions['mark']['children']['flagged'] = array( |
|
| 1934 | 1933 | 'group' => $actions['mark']['children']['flagged']['group'], |
| 1935 | 1934 | 'caption' => 'Flagged', |
| 1936 | 1935 | 'icon' => 'unread_flagged_small', |
| 1937 | 1936 | 'onExecute' => 'javaScript:app.mail.mail_flag', |
| 1938 | 1937 | ); |
| 1939 | - $actions['mark']['children']['unflagged']=array( |
|
| 1938 | + $actions['mark']['children']['unflagged'] = array( |
|
| 1940 | 1939 | 'group' => $actions['mark']['children']['flagged']['group'], |
| 1941 | 1940 | 'caption' => 'Unflagged', |
| 1942 | 1941 | 'icon' => 'read_flagged_small', |
@@ -1946,9 +1945,9 @@ discard block |
||
| 1946 | 1945 | $actions['forward']['toolbarDefault'] = true; |
| 1947 | 1946 | $compose = $actions['composeasnew']; |
| 1948 | 1947 | unset($actions['composeasnew']); |
| 1949 | - $actions = array_reverse($actions,true); |
|
| 1950 | - $actions['composeasnew']= $compose; |
|
| 1951 | - $actions = array_reverse($actions,true); |
|
| 1948 | + $actions = array_reverse($actions, true); |
|
| 1949 | + $actions['composeasnew'] = $compose; |
|
| 1950 | + $actions = array_reverse($actions, true); |
|
| 1952 | 1951 | return $actions; |
| 1953 | 1952 | } |
| 1954 | 1953 | |
@@ -1963,23 +1962,23 @@ discard block |
||
| 1963 | 1962 | * @param boolean $_returnFullHTML flag wether to return HTML or data array |
| 1964 | 1963 | * @return mixed array/string data array or html or empty string |
| 1965 | 1964 | */ |
| 1966 | - static function createAttachmentBlock($attachments, $rowID, $uid, $mailbox,$_returnFullHTML=false) |
|
| 1965 | + static function createAttachmentBlock($attachments, $rowID, $uid, $mailbox, $_returnFullHTML = false) |
|
| 1967 | 1966 | { |
| 1968 | - $attachmentHTMLBlock=''; |
|
| 1967 | + $attachmentHTMLBlock = ''; |
|
| 1969 | 1968 | $attachmentHTML = array(); |
| 1970 | 1969 | if (is_array($attachments) && count($attachments) > 0) { |
| 1971 | - $url_img_vfs = html::image('filemanager','navbar', lang('Filemanager'), ' height="16"'); |
|
| 1972 | - $url_img_vfs_save_all = html::image('mail','save_all', lang('Save all')); |
|
| 1970 | + $url_img_vfs = html::image('filemanager', 'navbar', lang('Filemanager'), ' height="16"'); |
|
| 1971 | + $url_img_vfs_save_all = html::image('mail', 'save_all', lang('Save all')); |
|
| 1973 | 1972 | |
| 1974 | 1973 | foreach ($attachments as $key => $value) |
| 1975 | 1974 | { |
| 1976 | - $attachmentHTML[$key]['filename']= ($value['name'] ? ( $value['filename'] ? $value['filename'] : $value['name'] ) : lang('(no subject)')); |
|
| 1977 | - $attachmentHTML[$key]['filename'] = translation::convert_jsonsafe($attachmentHTML[$key]['filename'],'utf-8'); |
|
| 1975 | + $attachmentHTML[$key]['filename'] = ($value['name'] ? ($value['filename'] ? $value['filename'] : $value['name']) : lang('(no subject)')); |
|
| 1976 | + $attachmentHTML[$key]['filename'] = translation::convert_jsonsafe($attachmentHTML[$key]['filename'], 'utf-8'); |
|
| 1978 | 1977 | //error_log(array2string($value)); |
| 1979 | 1978 | //error_log(strtoupper($value['mimeType']) .'<->'. mime_magic::filename2mime($attachmentHTML[$key]['filename'])); |
| 1980 | - if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) $value['mimeType'] = mime_magic::filename2mime($attachmentHTML[$key]['filename']); |
|
| 1981 | - $attachmentHTML[$key]['type']=$value['mimeType']; |
|
| 1982 | - $attachmentHTML[$key]['mimetype']=mime_magic::mime2label($value['mimeType']); |
|
| 1979 | + if (strtoupper($value['mimeType'] == 'APPLICATION/OCTET-STREAM')) $value['mimeType'] = mime_magic::filename2mime($attachmentHTML[$key]['filename']); |
|
| 1980 | + $attachmentHTML[$key]['type'] = $value['mimeType']; |
|
| 1981 | + $attachmentHTML[$key]['mimetype'] = mime_magic::mime2label($value['mimeType']); |
|
| 1983 | 1982 | $hA = self::splitRowID($rowID); |
| 1984 | 1983 | $uid = $hA['msgUID']; |
| 1985 | 1984 | $mailbox = $hA['folder']; |
@@ -1988,26 +1987,25 @@ discard block |
||
| 1988 | 1987 | $attachmentHTML[$key]['mime_data'] = egw_link::set_data($value['mimeType'], 'emailadmin_imapbase::getAttachmentAccount', array( |
| 1989 | 1988 | $acc_id, $mailbox, $uid, $value['partID'], $value['is_winmail'], true |
| 1990 | 1989 | )); |
| 1991 | - $attachmentHTML[$key]['size']=egw_vfs::hsize($value['size']); |
|
| 1992 | - $attachmentHTML[$key]['attachment_number']=$key; |
|
| 1993 | - $attachmentHTML[$key]['partID']=$value['partID']; |
|
| 1990 | + $attachmentHTML[$key]['size'] = egw_vfs::hsize($value['size']); |
|
| 1991 | + $attachmentHTML[$key]['attachment_number'] = $key; |
|
| 1992 | + $attachmentHTML[$key]['partID'] = $value['partID']; |
|
| 1994 | 1993 | $attachmentHTML[$key]['mail_id'] = $rowID; |
| 1995 | - $attachmentHTML[$key]['winmailFlag']=$value['is_winmail']; |
|
| 1994 | + $attachmentHTML[$key]['winmailFlag'] = $value['is_winmail']; |
|
| 1996 | 1995 | $attachmentHTML[$key]['classSaveAllPossiblyDisabled'] = "mail_DisplayNone"; |
| 1997 | 1996 | |
| 1998 | - switch(strtoupper($value['mimeType'])) |
|
| 1997 | + switch (strtoupper($value['mimeType'])) |
|
| 1999 | 1998 | { |
| 2000 | 1999 | case 'MESSAGE/RFC822': |
| 2001 | - $linkData = array |
|
| 2002 | - ( |
|
| 2000 | + $linkData = array( |
|
| 2003 | 2001 | 'menuaction' => 'mail.mail_ui.displayMessage', |
| 2004 | 2002 | 'mode' => 'display', //message/rfc822 attachments should be opened in display mode |
| 2005 | 2003 | 'id' => $rowID, |
| 2006 | 2004 | 'part' => $value['partID'], |
| 2007 | 2005 | 'is_winmail' => $value['is_winmail'] |
| 2008 | 2006 | ); |
| 2009 | - $windowName = 'displayMessage_'. $rowID.'_'.$value['partID']; |
|
| 2010 | - $linkView = "egw_openWindowCentered('".egw::link('/index.php',$linkData)."','$windowName',700,egw_getWindowOuterHeight());"; |
|
| 2007 | + $windowName = 'displayMessage_'.$rowID.'_'.$value['partID']; |
|
| 2008 | + $linkView = "egw_openWindowCentered('".egw::link('/index.php', $linkData)."','$windowName',700,egw_getWindowOuterHeight());"; |
|
| 2011 | 2009 | break; |
| 2012 | 2010 | case 'IMAGE/JPEG': |
| 2013 | 2011 | case 'IMAGE/PNG': |
@@ -2018,7 +2016,7 @@ discard block |
||
| 2018 | 2016 | case 'TEXT/HTML': |
| 2019 | 2017 | case 'TEXT/DIRECTORY': |
| 2020 | 2018 | $sfxMimeType = $value['mimeType']; |
| 2021 | - $buff = explode('.',$value['name']); |
|
| 2019 | + $buff = explode('.', $value['name']); |
|
| 2022 | 2020 | $suffix = ''; |
| 2023 | 2021 | if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
| 2024 | 2022 | if (!empty($suffix)) $sfxMimeType = mime_magic::ext2mime($suffix); |
@@ -2031,49 +2029,47 @@ discard block |
||
| 2031 | 2029 | case 'TEXT/VCARD': |
| 2032 | 2030 | case 'TEXT/CALENDAR': |
| 2033 | 2031 | case 'TEXT/X-VCALENDAR': |
| 2034 | - $linkData = array |
|
| 2035 | - ( |
|
| 2032 | + $linkData = array( |
|
| 2036 | 2033 | 'menuaction' => 'mail.mail_ui.getAttachment', |
| 2037 | 2034 | 'id' => $rowID, |
| 2038 | 2035 | 'part' => $value['partID'], |
| 2039 | 2036 | 'is_winmail' => $value['is_winmail'], |
| 2040 | 2037 | 'mailbox' => base64_encode($mailbox), |
| 2041 | 2038 | ); |
| 2042 | - $windowName = 'displayAttachment_'. $uid; |
|
| 2039 | + $windowName = 'displayAttachment_'.$uid; |
|
| 2043 | 2040 | $reg = '800x600'; |
| 2044 | 2041 | // handle calendar/vcard |
| 2045 | - if (strtoupper($value['mimeType'])=='TEXT/CALENDAR') |
|
| 2042 | + if (strtoupper($value['mimeType']) == 'TEXT/CALENDAR') |
|
| 2046 | 2043 | { |
| 2047 | - $windowName = 'displayEvent_'. $rowID; |
|
| 2048 | - $reg2 = egw_link::get_registry('calendar','view_popup'); |
|
| 2049 | - $attachmentHTML[$key]['popup']=(!empty($reg2) ? $reg2 : $reg); |
|
| 2044 | + $windowName = 'displayEvent_'.$rowID; |
|
| 2045 | + $reg2 = egw_link::get_registry('calendar', 'view_popup'); |
|
| 2046 | + $attachmentHTML[$key]['popup'] = (!empty($reg2) ? $reg2 : $reg); |
|
| 2050 | 2047 | } |
| 2051 | - if (strtoupper($value['mimeType'])=='TEXT/X-VCARD' || strtoupper($value['mimeType'])=='TEXT/VCARD') |
|
| 2048 | + if (strtoupper($value['mimeType']) == 'TEXT/X-VCARD' || strtoupper($value['mimeType']) == 'TEXT/VCARD') |
|
| 2052 | 2049 | { |
| 2053 | - $windowName = 'displayContact_'. $rowID; |
|
| 2054 | - $reg2 = egw_link::get_registry('addressbook','add_popup'); |
|
| 2055 | - $attachmentHTML[$key]['popup']=(!empty($reg2) ? $reg2 : $reg); |
|
| 2050 | + $windowName = 'displayContact_'.$rowID; |
|
| 2051 | + $reg2 = egw_link::get_registry('addressbook', 'add_popup'); |
|
| 2052 | + $attachmentHTML[$key]['popup'] = (!empty($reg2) ? $reg2 : $reg); |
|
| 2056 | 2053 | } |
| 2057 | 2054 | // apply to action |
| 2058 | - list($width,$height) = explode('x',(!empty($reg2) ? $reg2 : $reg)); |
|
| 2059 | - $linkView = "egw_openWindowCentered('".egw::link('/index.php',$linkData)."','$windowName',$width,$height);"; |
|
| 2055 | + list($width, $height) = explode('x', (!empty($reg2) ? $reg2 : $reg)); |
|
| 2056 | + $linkView = "egw_openWindowCentered('".egw::link('/index.php', $linkData)."','$windowName',$width,$height);"; |
|
| 2060 | 2057 | break; |
| 2061 | 2058 | default: |
| 2062 | - $linkData = array |
|
| 2063 | - ( |
|
| 2059 | + $linkData = array( |
|
| 2064 | 2060 | 'menuaction' => 'mail.mail_ui.getAttachment', |
| 2065 | 2061 | 'id' => $rowID, |
| 2066 | 2062 | 'part' => $value['partID'], |
| 2067 | 2063 | 'is_winmail' => $value['is_winmail'], |
| 2068 | 2064 | 'mailbox' => base64_encode($mailbox), |
| 2069 | 2065 | ); |
| 2070 | - $linkView = "window.location.href = '".egw::link('/index.php',$linkData)."';"; |
|
| 2066 | + $linkView = "window.location.href = '".egw::link('/index.php', $linkData)."';"; |
|
| 2071 | 2067 | break; |
| 2072 | 2068 | } |
| 2073 | 2069 | // we either use mime_data for server-side supported mime-types or mime_url for client-side or download |
| 2074 | 2070 | if (empty($attachmentHTML[$key]['mime_data'])) |
| 2075 | 2071 | { |
| 2076 | - $attachmentHTML[$key]['mime_url'] = egw::link('/index.php',$linkData); |
|
| 2072 | + $attachmentHTML[$key]['mime_url'] = egw::link('/index.php', $linkData); |
|
| 2077 | 2073 | unset($attachmentHTML[$key]['mime_data']); |
| 2078 | 2074 | } |
| 2079 | 2075 | $attachmentHTML[$key]['windowName'] = $windowName; |
@@ -2083,8 +2079,7 @@ discard block |
||
| 2083 | 2079 | ($value['name'] ? $value['name'] : lang('(no subject)')). |
| 2084 | 2080 | '</b></a>'; |
| 2085 | 2081 | |
| 2086 | - $linkData = array |
|
| 2087 | - ( |
|
| 2082 | + $linkData = array( |
|
| 2088 | 2083 | 'menuaction' => 'mail.mail_ui.getAttachment', |
| 2089 | 2084 | 'mode' => 'save', |
| 2090 | 2085 | 'id' => $rowID, |
@@ -2092,11 +2087,11 @@ discard block |
||
| 2092 | 2087 | 'is_winmail' => $value['is_winmail'], |
| 2093 | 2088 | 'mailbox' => base64_encode($mailbox), |
| 2094 | 2089 | ); |
| 2095 | - $attachmentHTML[$key]['link_save'] ="<a href='".egw::link('/index.php',$linkData)."' title='".$attachmentHTML[$key]['filename']."'>".html::image('mail','fileexport')."</a>"; |
|
| 2090 | + $attachmentHTML[$key]['link_save'] = "<a href='".egw::link('/index.php', $linkData)."' title='".$attachmentHTML[$key]['filename']."'>".html::image('mail', 'fileexport')."</a>"; |
|
| 2096 | 2091 | |
| 2097 | 2092 | if ($GLOBALS['egw_info']['user']['apps']['filemanager']) |
| 2098 | 2093 | { |
| 2099 | - $link_vfs_save = egw::link('/index.php',array( |
|
| 2094 | + $link_vfs_save = egw::link('/index.php', array( |
|
| 2100 | 2095 | 'menuaction' => 'filemanager.filemanager_select.select', |
| 2101 | 2096 | 'mode' => 'saveas', |
| 2102 | 2097 | 'name' => $value['name'], |
@@ -2115,19 +2110,19 @@ discard block |
||
| 2115 | 2110 | //$rowID |
| 2116 | 2111 | $ids["id[$ikey]"] = $rowID.'::'.$value['partID'].'::'.$value['is_winmail'].'::'.$value['name']; |
| 2117 | 2112 | } |
| 2118 | - $link_vfs_save = egw::link('/index.php',array( |
|
| 2113 | + $link_vfs_save = egw::link('/index.php', array( |
|
| 2119 | 2114 | 'menuaction' => 'filemanager.filemanager_select.select', |
| 2120 | 2115 | 'mode' => 'select-dir', |
| 2121 | 2116 | 'method' => 'mail.mail_ui.vfsSaveAttachment', |
| 2122 | 2117 | 'label' => lang('Save all'), |
| 2123 | - )+$ids); |
|
| 2118 | + ) + $ids); |
|
| 2124 | 2119 | $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>"; |
| 2125 | 2120 | } |
| 2126 | 2121 | $attachmentHTML[$key]['link_save'] .= $vfs_save; |
| 2127 | 2122 | //error_log(__METHOD__.__LINE__.$attachmentHTML[$key]['link_save']); |
| 2128 | 2123 | } |
| 2129 | 2124 | } |
| 2130 | - $attachmentHTMLBlock="<table width='100%'>"; |
|
| 2125 | + $attachmentHTMLBlock = "<table width='100%'>"; |
|
| 2131 | 2126 | foreach ((array)$attachmentHTML as $row) |
| 2132 | 2127 | { |
| 2133 | 2128 | $attachmentHTMLBlock .= "<tr><td><div class='useEllipsis'>".$row['link_view'].'</div></td>'; |
@@ -2146,7 +2141,7 @@ discard block |
||
| 2146 | 2141 | unset($attachmentHTML[$ikey]['link_save']); |
| 2147 | 2142 | } |
| 2148 | 2143 | } |
| 2149 | - return ($_returnFullHTML?$attachmentHTMLBlock:$attachmentHTML); |
|
| 2144 | + return ($_returnFullHTML ? $attachmentHTMLBlock : $attachmentHTML); |
|
| 2150 | 2145 | } |
| 2151 | 2146 | |
| 2152 | 2147 | /** |
@@ -2157,7 +2152,7 @@ discard block |
||
| 2157 | 2152 | */ |
| 2158 | 2153 | function gatherVacation($cachedVacations = array()) |
| 2159 | 2154 | { |
| 2160 | - $isVacationEnabled = $this->mail_bo->icServer->acc_sieve_enabled && ($this->mail_bo->icServer->acc_sieve_host||$this->mail_bo->icServer->acc_imap_host); |
|
| 2155 | + $isVacationEnabled = $this->mail_bo->icServer->acc_sieve_enabled && ($this->mail_bo->icServer->acc_sieve_host || $this->mail_bo->icServer->acc_imap_host); |
|
| 2161 | 2156 | //error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation)); |
| 2162 | 2157 | |
| 2163 | 2158 | if ($isVacationEnabled) |
@@ -2170,7 +2165,7 @@ discard block |
||
| 2170 | 2165 | |
| 2171 | 2166 | $cachedVacations = array($sieveServer->acc_id => $vacation) + (array)$cachedVacations; |
| 2172 | 2167 | // Set vacation to the instance cache for particular account with expiration of one day |
| 2173 | - egw_cache::setCache(egw_cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations, 60*60*24); |
|
| 2168 | + egw_cache::setCache(egw_cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations, 60 * 60 * 24); |
|
| 2174 | 2169 | } |
| 2175 | 2170 | catch (PEAR_Exception $ex) |
| 2176 | 2171 | { |
@@ -2191,36 +2186,36 @@ discard block |
||
| 2191 | 2186 | function quotaDisplay($_usage, $_limit) |
| 2192 | 2187 | { |
| 2193 | 2188 | |
| 2194 | - if($_limit == 0) { |
|
| 2195 | - $quotaPercent=100; |
|
| 2189 | + if ($_limit == 0) { |
|
| 2190 | + $quotaPercent = 100; |
|
| 2196 | 2191 | } else { |
| 2197 | - $quotaPercent=round(($_usage*100)/$_limit); |
|
| 2192 | + $quotaPercent = round(($_usage * 100) / $_limit); |
|
| 2198 | 2193 | } |
| 2199 | 2194 | |
| 2200 | - $quotaLimit=mail_bo::show_readable_size($_limit*1024); |
|
| 2201 | - $quotaUsage=mail_bo::show_readable_size($_usage*1024); |
|
| 2195 | + $quotaLimit = mail_bo::show_readable_size($_limit * 1024); |
|
| 2196 | + $quotaUsage = mail_bo::show_readable_size($_usage * 1024); |
|
| 2202 | 2197 | |
| 2203 | 2198 | |
| 2204 | - if($quotaPercent > 90 && $_limit>0) { |
|
| 2205 | - $quotaBG='mail-index_QuotaRed'; |
|
| 2206 | - } elseif($quotaPercent > 80 && $_limit>0) { |
|
| 2207 | - $quotaBG='mail-index_QuotaYellow'; |
|
| 2199 | + if ($quotaPercent > 90 && $_limit > 0) { |
|
| 2200 | + $quotaBG = 'mail-index_QuotaRed'; |
|
| 2201 | + } elseif ($quotaPercent > 80 && $_limit > 0) { |
|
| 2202 | + $quotaBG = 'mail-index_QuotaYellow'; |
|
| 2208 | 2203 | } else { |
| 2209 | - $quotaBG='mail-index_QuotaGreen'; |
|
| 2204 | + $quotaBG = 'mail-index_QuotaGreen'; |
|
| 2210 | 2205 | } |
| 2211 | 2206 | |
| 2212 | - if($_limit > 0) { |
|
| 2213 | - $quotaText = $quotaUsage .'/'.$quotaLimit; |
|
| 2207 | + if ($_limit > 0) { |
|
| 2208 | + $quotaText = $quotaUsage.'/'.$quotaLimit; |
|
| 2214 | 2209 | } else { |
| 2215 | 2210 | $quotaText = $quotaUsage; |
| 2216 | 2211 | } |
| 2217 | 2212 | |
| 2218 | - if($quotaPercent > 50) { |
|
| 2213 | + if ($quotaPercent > 50) { |
|
| 2219 | 2214 | } else { |
| 2220 | 2215 | } |
| 2221 | 2216 | $quota['class'] = $quotaBG; |
| 2222 | - $quota['text'] = lang('Quota: %1',$quotaText); |
|
| 2223 | - $quota['percent'] = (string)round(($_usage*100)/$_limit); |
|
| 2217 | + $quota['text'] = lang('Quota: %1', $quotaText); |
|
| 2218 | + $quota['percent'] = (string)round(($_usage * 100) / $_limit); |
|
| 2224 | 2219 | return $quota; |
| 2225 | 2220 | } |
| 2226 | 2221 | |
@@ -2234,12 +2229,12 @@ discard block |
||
| 2234 | 2229 | $uid = $_GET['uid']; |
| 2235 | 2230 | $cid = base64_decode($_GET['cid']); |
| 2236 | 2231 | $partID = urldecode($_GET['partID']); |
| 2237 | - if (!empty($_GET['mailbox'])) $mailbox = base64_decode($_GET['mailbox']); |
|
| 2232 | + if (!empty($_GET['mailbox'])) $mailbox = base64_decode($_GET['mailbox']); |
|
| 2238 | 2233 | |
| 2239 | 2234 | //error_log(__METHOD__.__LINE__.":$uid, $cid, $partID"); |
| 2240 | 2235 | $this->mail_bo->reopen($mailbox); |
| 2241 | 2236 | |
| 2242 | - $attachment = $this->mail_bo->getAttachmentByCID($uid, $cid, $partID, true); // true get contents as stream |
|
| 2237 | + $attachment = $this->mail_bo->getAttachmentByCID($uid, $cid, $partID, true); // true get contents as stream |
|
| 2243 | 2238 | |
| 2244 | 2239 | $this->mail_bo->closeConnection(); |
| 2245 | 2240 | |
@@ -2247,8 +2242,8 @@ discard block |
||
| 2247 | 2242 | |
| 2248 | 2243 | if ($attachment) |
| 2249 | 2244 | { |
| 2250 | - header("Content-Type: ". $attachment->getType()); |
|
| 2251 | - header('Content-Disposition: inline; filename="'. $attachment->getDispositionParameter('filename') .'"'); |
|
| 2245 | + header("Content-Type: ".$attachment->getType()); |
|
| 2246 | + header('Content-Disposition: inline; filename="'.$attachment->getDispositionParameter('filename').'"'); |
|
| 2252 | 2247 | //header("Expires: 0"); |
| 2253 | 2248 | // the next headers are for IE and SSL |
| 2254 | 2249 | //header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
@@ -2266,7 +2261,7 @@ discard block |
||
| 2266 | 2261 | |
| 2267 | 2262 | function getAttachment() |
| 2268 | 2263 | { |
| 2269 | - if(isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 2264 | + if (isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 2270 | 2265 | |
| 2271 | 2266 | $hA = self::splitRowID($rowID); |
| 2272 | 2267 | $uid = $hA['msgUID']; |
@@ -2278,11 +2273,11 @@ discard block |
||
| 2278 | 2273 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
| 2279 | 2274 | $this->changeProfile($icServerID); |
| 2280 | 2275 | } |
| 2281 | - $part = $_GET['part']; |
|
| 2276 | + $part = $_GET['part']; |
|
| 2282 | 2277 | $is_winmail = $_GET['is_winmail'] ? $_GET['is_winmail'] : 0; |
| 2283 | 2278 | |
| 2284 | 2279 | $this->mail_bo->reopen($mailbox); |
| 2285 | - $attachment = $this->mail_bo->getAttachment($uid,$part,$is_winmail,false); |
|
| 2280 | + $attachment = $this->mail_bo->getAttachment($uid, $part, $is_winmail, false); |
|
| 2286 | 2281 | $this->mail_bo->closeConnection(); |
| 2287 | 2282 | if ($rememberServerID != $this->mail_bo->profileID) |
| 2288 | 2283 | { |
@@ -2297,7 +2292,7 @@ discard block |
||
| 2297 | 2292 | if (strtoupper($attachment['type']) == 'TEXT/DIRECTORY' || empty($attachment['type'])) |
| 2298 | 2293 | { |
| 2299 | 2294 | $sfxMimeType = $attachment['type']; |
| 2300 | - $buff = explode('.',$attachment['filename']); |
|
| 2295 | + $buff = explode('.', $attachment['filename']); |
|
| 2301 | 2296 | $suffix = ''; |
| 2302 | 2297 | if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
| 2303 | 2298 | if (!empty($suffix)) $sfxMimeType = mime_magic::ext2mime($suffix); |
@@ -2309,10 +2304,10 @@ discard block |
||
| 2309 | 2304 | { |
| 2310 | 2305 | //error_log(__METHOD__."about to call calendar_ical"); |
| 2311 | 2306 | $calendar_ical = new calendar_ical(); |
| 2312 | - $eventid = $calendar_ical->search($attachment['attachment'],-1); |
|
| 2307 | + $eventid = $calendar_ical->search($attachment['attachment'], -1); |
|
| 2313 | 2308 | //error_log(__METHOD__.array2string($eventid)); |
| 2314 | 2309 | if (!$eventid) $eventid = -1; |
| 2315 | - $event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true,0,'',null,$attachment['charset']); |
|
| 2310 | + $event = $calendar_ical->importVCal($attachment['attachment'], (is_array($eventid) ? $eventid[0] : $eventid), null, true, 0, '', null, $attachment['charset']); |
|
| 2316 | 2311 | //error_log(__METHOD__.$event); |
| 2317 | 2312 | if ((int)$event > 0) |
| 2318 | 2313 | { |
@@ -2320,7 +2315,7 @@ discard block |
||
| 2320 | 2315 | 'menuaction' => 'calendar.calendar_uiforms.edit', |
| 2321 | 2316 | 'cal_id' => $event, |
| 2322 | 2317 | ); |
| 2323 | - egw::redirect_link('../index.php',$vars); |
|
| 2318 | + egw::redirect_link('../index.php', $vars); |
|
| 2324 | 2319 | } |
| 2325 | 2320 | //Import failed, download content anyway |
| 2326 | 2321 | } |
@@ -2335,13 +2330,13 @@ discard block |
||
| 2335 | 2330 | { |
| 2336 | 2331 | $vcard['uid'] = trim($vcard['uid']); |
| 2337 | 2332 | //error_log(__METHOD__.__LINE__.print_r($vcard,true)); |
| 2338 | - $contact = $addressbook_vcal->find_contact($vcard,false); |
|
| 2333 | + $contact = $addressbook_vcal->find_contact($vcard, false); |
|
| 2339 | 2334 | } |
| 2340 | 2335 | if (!$contact) $contact = null; |
| 2341 | 2336 | // 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)) |
| 2342 | - if ($contact || count($vcard)>2) |
|
| 2337 | + if ($contact || count($vcard) > 2) |
|
| 2343 | 2338 | { |
| 2344 | - $contact = $addressbook_vcal->addVCard($attachment['attachment'],(is_array($contact)?array_shift($contact):$contact),true,$attachment['charset']); |
|
| 2339 | + $contact = $addressbook_vcal->addVCard($attachment['attachment'], (is_array($contact) ? array_shift($contact) : $contact), true, $attachment['charset']); |
|
| 2345 | 2340 | } |
| 2346 | 2341 | if ((int)$contact > 0) |
| 2347 | 2342 | { |
@@ -2349,14 +2344,14 @@ discard block |
||
| 2349 | 2344 | 'menuaction' => 'addressbook.addressbook_ui.edit', |
| 2350 | 2345 | 'contact_id' => $contact, |
| 2351 | 2346 | ); |
| 2352 | - egw::redirect_link('../index.php',$vars); |
|
| 2347 | + egw::redirect_link('../index.php', $vars); |
|
| 2353 | 2348 | } |
| 2354 | 2349 | //Import failed, download content anyway |
| 2355 | 2350 | } |
| 2356 | 2351 | } |
| 2357 | 2352 | //error_log(__METHOD__.__LINE__.'->'.array2string($attachment)); |
| 2358 | - $filename = ($attachment['name']?$attachment['name']:($attachment['filename']?$attachment['filename']:$mailbox.'_uid'.$uid.'_part'.$part)); |
|
| 2359 | - html::safe_content_header($attachment['attachment'], $filename, $attachment['type'], $size=0, True, $_GET['mode'] == "save"); |
|
| 2353 | + $filename = ($attachment['name'] ? $attachment['name'] : ($attachment['filename'] ? $attachment['filename'] : $mailbox.'_uid'.$uid.'_part'.$part)); |
|
| 2354 | + html::safe_content_header($attachment['attachment'], $filename, $attachment['type'], $size = 0, True, $_GET['mode'] == "save"); |
|
| 2360 | 2355 | echo $attachment['attachment']; |
| 2361 | 2356 | |
| 2362 | 2357 | common::egw_exit(); |
@@ -2371,9 +2366,9 @@ discard block |
||
| 2371 | 2366 | function saveMessage() |
| 2372 | 2367 | { |
| 2373 | 2368 | $display = false; |
| 2374 | - if(isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 2375 | - if(isset($_GET['part'])) $partID = $_GET['part']; |
|
| 2376 | - if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager')) $display = $_GET['location']; |
|
| 2369 | + if (isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 2370 | + if (isset($_GET['part'])) $partID = $_GET['part']; |
|
| 2371 | + if (isset($_GET['location']) && ($_GET['location'] == 'display' || $_GET['location'] == 'filemanager')) $display = $_GET['location']; |
|
| 2377 | 2372 | |
| 2378 | 2373 | $hA = self::splitRowID($rowID); |
| 2379 | 2374 | $uid = $hA['msgUID']; |
@@ -2389,7 +2384,7 @@ discard block |
||
| 2389 | 2384 | $this->mail_bo->reopen($mailbox); |
| 2390 | 2385 | |
| 2391 | 2386 | $message = $this->mail_bo->getMessageRawBody($uid, $partID, $mailbox); |
| 2392 | - $headers = $this->mail_bo->getMessageHeader($uid, $partID, true,false, $mailbox); |
|
| 2387 | + $headers = $this->mail_bo->getMessageHeader($uid, $partID, true, false, $mailbox); |
|
| 2393 | 2388 | |
| 2394 | 2389 | $this->mail_bo->closeConnection(); |
| 2395 | 2390 | if ($rememberServerID != $this->mail_bo->profileID) |
@@ -2401,14 +2396,14 @@ discard block |
||
| 2401 | 2396 | $GLOBALS['egw']->session->commit_session(); |
| 2402 | 2397 | if (!$display) |
| 2403 | 2398 | { |
| 2404 | - $subject = str_replace('$$','__',mail_bo::decode_header($headers['SUBJECT'])); |
|
| 2405 | - html::safe_content_header($message, $subject.".eml", $mime='message/rfc822', $size=0, true, true); |
|
| 2399 | + $subject = str_replace('$$', '__', mail_bo::decode_header($headers['SUBJECT'])); |
|
| 2400 | + html::safe_content_header($message, $subject.".eml", $mime = 'message/rfc822', $size = 0, true, true); |
|
| 2406 | 2401 | echo $message; |
| 2407 | 2402 | } |
| 2408 | 2403 | else |
| 2409 | 2404 | { |
| 2410 | - html::safe_content_header($message, $subject.".eml", $mime='text/html', $size=0, true, false); |
|
| 2411 | - print '<pre>'. htmlspecialchars($message, ENT_NOQUOTES|ENT_SUBSTITUTE, 'utf-8') .'</pre>'; |
|
| 2405 | + html::safe_content_header($message, $subject.".eml", $mime = 'text/html', $size = 0, true, false); |
|
| 2406 | + print '<pre>'.htmlspecialchars($message, ENT_NOQUOTES|ENT_SUBSTITUTE, 'utf-8').'</pre>'; |
|
| 2412 | 2407 | } |
| 2413 | 2408 | } |
| 2414 | 2409 | |
@@ -2420,18 +2415,18 @@ discard block |
||
| 2420 | 2415 | * @param boolean $close Return javascript to close the window |
| 2421 | 2416 | * @return string|boolean javascript eg. to close the selector window if $close is true, or success/fail if $close is false |
| 2422 | 2417 | */ |
| 2423 | - function vfsSaveMessage($ids,$path, $close = true) |
|
| 2418 | + function vfsSaveMessage($ids, $path, $close = true) |
|
| 2424 | 2419 | { |
| 2425 | 2420 | //error_log(__METHOD__.' IDs:'.array2string($ids).' SaveToPath:'.$path); |
| 2426 | 2421 | |
| 2427 | 2422 | if (is_array($ids) && !egw_vfs::is_writable($path) || !is_array($ids) && !egw_vfs::is_writable(dirname($path))) |
| 2428 | 2423 | { |
| 2429 | - return 'alert("'.addslashes(lang('%1 is NOT writable by you!',$path)).'"); egw(window).close();'; |
|
| 2424 | + return 'alert("'.addslashes(lang('%1 is NOT writable by you!', $path)).'"); egw(window).close();'; |
|
| 2430 | 2425 | } |
| 2431 | 2426 | translation::add_app('mail'); |
| 2432 | 2427 | |
| 2433 | 2428 | $rememberServerID = $this->mail_bo->profileID; |
| 2434 | - foreach((array)$ids as $id) |
|
| 2429 | + foreach ((array)$ids as $id) |
|
| 2435 | 2430 | { |
| 2436 | 2431 | $hA = self::splitRowID($id); |
| 2437 | 2432 | $uid = $hA['msgUID']; |
@@ -2442,20 +2437,20 @@ discard block |
||
| 2442 | 2437 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
| 2443 | 2438 | $this->changeProfile($icServerID); |
| 2444 | 2439 | } |
| 2445 | - $message = $this->mail_bo->getMessageRawBody($uid, $partID='', $mailbox); |
|
| 2446 | - $err=null; |
|
| 2447 | - if(egw_vfs::is_dir($path)) |
|
| 2440 | + $message = $this->mail_bo->getMessageRawBody($uid, $partID = '', $mailbox); |
|
| 2441 | + $err = null; |
|
| 2442 | + if (egw_vfs::is_dir($path)) |
|
| 2448 | 2443 | { |
| 2449 | - $headers = $this->mail_bo->getMessageHeader($uid,$partID,true,false,$mailbox); |
|
| 2450 | - $file = $path . '/'.preg_replace('/[\f\n\t\v\\:*#?<>\|]/',"_",$headers['SUBJECT']).'.eml'; |
|
| 2444 | + $headers = $this->mail_bo->getMessageHeader($uid, $partID, true, false, $mailbox); |
|
| 2445 | + $file = $path.'/'.preg_replace('/[\f\n\t\v\\:*#?<>\|]/', "_", $headers['SUBJECT']).'.eml'; |
|
| 2451 | 2446 | } |
| 2452 | 2447 | else |
| 2453 | 2448 | { |
| 2454 | 2449 | $file = $path; |
| 2455 | 2450 | } |
| 2456 | - if (!($fp = egw_vfs::fopen($file,'wb')) || !fwrite($fp,$message)) |
|
| 2451 | + if (!($fp = egw_vfs::fopen($file, 'wb')) || !fwrite($fp, $message)) |
|
| 2457 | 2452 | { |
| 2458 | - $err .= lang('Error saving %1!',$file); |
|
| 2453 | + $err .= lang('Error saving %1!', $file); |
|
| 2459 | 2454 | $succeeded = false; |
| 2460 | 2455 | } |
| 2461 | 2456 | else |
@@ -2465,10 +2460,10 @@ discard block |
||
| 2465 | 2460 | if ($fp) fclose($fp); |
| 2466 | 2461 | if ($succeeded) |
| 2467 | 2462 | { |
| 2468 | - unset($headers['SUBJECT']);//already in filename |
|
| 2463 | + unset($headers['SUBJECT']); //already in filename |
|
| 2469 | 2464 | $infoSection = mail_bo::createHeaderInfoSection($headers, 'SUPPRESS', false); |
| 2470 | - $props = array(array('name' => 'comment','val' => $infoSection)); |
|
| 2471 | - egw_vfs::proppatch($file,$props); |
|
| 2465 | + $props = array(array('name' => 'comment', 'val' => $infoSection)); |
|
| 2466 | + egw_vfs::proppatch($file, $props); |
|
| 2472 | 2467 | } |
| 2473 | 2468 | } |
| 2474 | 2469 | if ($rememberServerID != $this->mail_bo->profileID) |
@@ -2477,9 +2472,9 @@ discard block |
||
| 2477 | 2472 | $this->changeProfile($rememberServerID); |
| 2478 | 2473 | } |
| 2479 | 2474 | |
| 2480 | - if($close) |
|
| 2475 | + if ($close) |
|
| 2481 | 2476 | { |
| 2482 | - egw_framework::window_close(($err?$err:null)); |
|
| 2477 | + egw_framework::window_close(($err ? $err : null)); |
|
| 2483 | 2478 | } |
| 2484 | 2479 | else |
| 2485 | 2480 | { |
@@ -2494,15 +2489,15 @@ discard block |
||
| 2494 | 2489 | * @param string $path path in vfs (no egw_vfs::PREFIX!), only directory for multiple id's ($ids is an array) |
| 2495 | 2490 | * @return string javascript eg. to close the selector window |
| 2496 | 2491 | */ |
| 2497 | - function vfsSaveAttachment($ids,$path) |
|
| 2492 | + function vfsSaveAttachment($ids, $path) |
|
| 2498 | 2493 | { |
| 2499 | 2494 | //error_log(__METHOD__.__LINE__.'("'.array2string($ids).'","'.$path."\")');"); |
| 2500 | 2495 | |
| 2501 | 2496 | if (is_array($ids) && !egw_vfs::is_writable($path) || !is_array($ids) && !egw_vfs::is_writable(dirname($path))) |
| 2502 | 2497 | { |
| 2503 | - return 'alert("'.addslashes(lang('%1 is NOT writable by you!',$path)).'"); egw(window).close();'; |
|
| 2498 | + return 'alert("'.addslashes(lang('%1 is NOT writable by you!', $path)).'"); egw(window).close();'; |
|
| 2504 | 2499 | } |
| 2505 | - $err=null; |
|
| 2500 | + $err = null; |
|
| 2506 | 2501 | $dupe_count = array(); |
| 2507 | 2502 | $rememberServerID = $this->mail_bo->profileID; |
| 2508 | 2503 | |
@@ -2512,12 +2507,12 @@ discard block |
||
| 2512 | 2507 | * |
| 2513 | 2508 | * @return array an array of parameters |
| 2514 | 2509 | */ |
| 2515 | - $getParams = function ($id) { |
|
| 2516 | - list($app,$user,$serverID,$mailbox,$uid,$part,$is_winmail,$name) = explode('::',$id,8); |
|
| 2517 | - $lId = implode('::',array($app,$user,$serverID,$mailbox,$uid)); |
|
| 2510 | + $getParams = function($id) { |
|
| 2511 | + list($app, $user, $serverID, $mailbox, $uid, $part, $is_winmail, $name) = explode('::', $id, 8); |
|
| 2512 | + $lId = implode('::', array($app, $user, $serverID, $mailbox, $uid)); |
|
| 2518 | 2513 | $hA = mail_ui::splitRowID($lId); |
| 2519 | 2514 | return array( |
| 2520 | - 'is_winmail' => $is_winmail == "null" || !$is_winmail?false:$is_winmail, |
|
| 2515 | + 'is_winmail' => $is_winmail == "null" || !$is_winmail ? false : $is_winmail, |
|
| 2521 | 2516 | 'user' => $user, |
| 2522 | 2517 | 'name' => $name, |
| 2523 | 2518 | 'part' => $part, |
@@ -2529,8 +2524,8 @@ discard block |
||
| 2529 | 2524 | |
| 2530 | 2525 | //Examine the first attachment to see if attachment |
| 2531 | 2526 | //is winmail.dat embedded attachments. |
| 2532 | - $isMultipleDownload=is_array($ids); |
|
| 2533 | - $p = $getParams((is_array($ids)?$ids[0]:$ids)); |
|
| 2527 | + $isMultipleDownload = is_array($ids); |
|
| 2528 | + $p = $getParams((is_array($ids) ? $ids[0] : $ids)); |
|
| 2534 | 2529 | if ($p['is_winmail']) |
| 2535 | 2530 | { |
| 2536 | 2531 | if ($p['icServer'] && $p['icServer'] != $this->mail_bo->profileID) |
@@ -2541,14 +2536,14 @@ discard block |
||
| 2541 | 2536 | // Retrive all embedded attachments at once |
| 2542 | 2537 | // avoids to fetch heavy winmail.dat content |
| 2543 | 2538 | // for each file. |
| 2544 | - $attachments = $this->mail_bo->getTnefAttachments($p['uid'],$p['part']); |
|
| 2539 | + $attachments = $this->mail_bo->getTnefAttachments($p['uid'], $p['part']); |
|
| 2545 | 2540 | } |
| 2546 | 2541 | |
| 2547 | - foreach((array)$ids as $id) |
|
| 2542 | + foreach ((array)$ids as $id) |
|
| 2548 | 2543 | { |
| 2549 | 2544 | $params = $getParams($id); |
| 2550 | 2545 | // when downloading a single file, name is not set |
| 2551 | - if (!$params['name']&&isset($_GET['name'])&&!$isMultipleDownload) $params['name'] = $_GET['name']; |
|
| 2546 | + if (!$params['name'] && isset($_GET['name']) && !$isMultipleDownload) $params['name'] = $_GET['name']; |
|
| 2552 | 2547 | if ($params['icServer'] && $params['icServer'] != $this->mail_bo->profileID) |
| 2553 | 2548 | { |
| 2554 | 2549 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
@@ -2566,25 +2561,25 @@ discard block |
||
| 2566 | 2561 | } |
| 2567 | 2562 | else |
| 2568 | 2563 | { |
| 2569 | - $attachment = $this->mail_bo->getAttachment($params['uid'],$params['part'],$params['is_winmail'],false); |
|
| 2564 | + $attachment = $this->mail_bo->getAttachment($params['uid'], $params['part'], $params['is_winmail'], false); |
|
| 2570 | 2565 | } |
| 2571 | 2566 | |
| 2572 | 2567 | $file = $params['name']; |
| 2573 | 2568 | // when $isMultipleDownload the path holds no filename |
| 2574 | - while(egw_vfs::file_exists($path.($file && $isMultipleDownload ? '/'.$file : ''))) |
|
| 2569 | + while (egw_vfs::file_exists($path.($file && $isMultipleDownload ? '/'.$file : ''))) |
|
| 2575 | 2570 | { |
| 2576 | 2571 | $dupe_count[$params['name']]++; |
| 2577 | - $file = pathinfo($params['name'], PATHINFO_FILENAME) . |
|
| 2578 | - ' ('.($dupe_count[$params['name']] + 1).')' . '.' . |
|
| 2572 | + $file = pathinfo($params['name'], PATHINFO_FILENAME). |
|
| 2573 | + ' ('.($dupe_count[$params['name']] + 1).')'.'.'. |
|
| 2579 | 2574 | pathinfo($params['name'], PATHINFO_EXTENSION); |
| 2580 | 2575 | } |
| 2581 | 2576 | $params['name'] = $file; |
| 2582 | 2577 | //error_log(__METHOD__.__LINE__.array2string($attachment)); |
| 2583 | 2578 | // when $isMultipleDownload the path holds no filename |
| 2584 | - if (!($fp = egw_vfs::fopen($file=$path.($params['name'] && $isMultipleDownload ? '/'.$params['name'] : ''),'wb')) || |
|
| 2585 | - !fwrite($fp,$attachment['attachment'])) |
|
| 2579 | + if (!($fp = egw_vfs::fopen($file = $path.($params['name'] && $isMultipleDownload ? '/'.$params['name'] : ''), 'wb')) || |
|
| 2580 | + !fwrite($fp, $attachment['attachment'])) |
|
| 2586 | 2581 | { |
| 2587 | - $err .= lang('Error saving %1!',$file); |
|
| 2582 | + $err .= lang('Error saving %1!', $file); |
|
| 2588 | 2583 | } |
| 2589 | 2584 | if ($fp) |
| 2590 | 2585 | { |
@@ -2597,21 +2592,21 @@ discard block |
||
| 2597 | 2592 | //error_log(__METHOD__.__LINE__.' change Profile back to where we came from ->'.$rememberServerID); |
| 2598 | 2593 | $this->changeProfile($rememberServerID); |
| 2599 | 2594 | } |
| 2600 | - egw_framework::window_close(($err?$err:null)); |
|
| 2595 | + egw_framework::window_close(($err ? $err : null)); |
|
| 2601 | 2596 | } |
| 2602 | 2597 | |
| 2603 | 2598 | /** |
| 2604 | 2599 | * Zip all attachments and send to user |
| 2605 | 2600 | * @param string $message_id = null |
| 2606 | 2601 | */ |
| 2607 | - function download_zip($message_id=null) |
|
| 2602 | + function download_zip($message_id = null) |
|
| 2608 | 2603 | { |
| 2609 | 2604 | //error_log(__METHOD__.__LINE__.array2string($_GET)); |
| 2610 | 2605 | // First, get all attachment IDs |
| 2611 | - if(isset($_GET['id'])) $message_id = $_GET['id']; |
|
| 2606 | + if (isset($_GET['id'])) $message_id = $_GET['id']; |
|
| 2612 | 2607 | //error_log(__METHOD__.__LINE__.$message_id); |
| 2613 | 2608 | $rememberServerID = $this->mail_bo->profileID; |
| 2614 | - if(!is_numeric($message_id)) |
|
| 2609 | + if (!is_numeric($message_id)) |
|
| 2615 | 2610 | { |
| 2616 | 2611 | $hA = self::splitRowID($message_id); |
| 2617 | 2612 | $message_id = $hA['msgUID']; |
@@ -2629,29 +2624,29 @@ discard block |
||
| 2629 | 2624 | } |
| 2630 | 2625 | // always fetch all, even inline (images) |
| 2631 | 2626 | $fetchEmbeddedImages = true; |
| 2632 | - $attachments = $this->mail_bo->getMessageAttachments($message_id,null, null, $fetchEmbeddedImages, true,true,$mailbox); |
|
| 2627 | + $attachments = $this->mail_bo->getMessageAttachments($message_id, null, null, $fetchEmbeddedImages, true, true, $mailbox); |
|
| 2633 | 2628 | // put them in VFS so they can be zipped |
| 2634 | - $header = $this->mail_bo->getMessageHeader($message_id,'',true,false,$mailbox); |
|
| 2629 | + $header = $this->mail_bo->getMessageHeader($message_id, '', true, false, $mailbox); |
|
| 2635 | 2630 | //get_home_dir may fetch the users startfolder if set; if not writeable, action will fail. TODO: use temp_dir |
| 2636 | 2631 | $homedir = '/home/'.$GLOBALS['egw_info']['user']['account_lid']; |
| 2637 | - $temp_path = $homedir/*egw_vfs::get_home_dir()*/ . "/.mail_$message_id"; |
|
| 2638 | - if(egw_vfs::is_dir($temp_path)) egw_vfs::remove ($temp_path); |
|
| 2632 | + $temp_path = $homedir/*egw_vfs::get_home_dir()*/."/.mail_$message_id"; |
|
| 2633 | + if (egw_vfs::is_dir($temp_path)) egw_vfs::remove($temp_path); |
|
| 2639 | 2634 | |
| 2640 | 2635 | // Add subject to path, so it gets used as the file name |
| 2641 | - $path = $temp_path . '/' . ($header['SUBJECT'] ? egw_vfs::encodePathComponent($header['SUBJECT']) : lang('mail')) .'/'; |
|
| 2642 | - if(!egw_vfs::mkdir($path, 0700, true)) |
|
| 2636 | + $path = $temp_path.'/'.($header['SUBJECT'] ? egw_vfs::encodePathComponent($header['SUBJECT']) : lang('mail')).'/'; |
|
| 2637 | + if (!egw_vfs::mkdir($path, 0700, true)) |
|
| 2643 | 2638 | { |
| 2644 | - egw_framework::message("Unable to open temp directory $path",'error'); |
|
| 2639 | + egw_framework::message("Unable to open temp directory $path", 'error'); |
|
| 2645 | 2640 | return; |
| 2646 | 2641 | } |
| 2647 | 2642 | |
| 2648 | 2643 | $file_list = array(); |
| 2649 | 2644 | $this->mail_bo->reopen($mailbox); |
| 2650 | - if ($attachments[0]['is_winmail'] && $attachments[0]['is_winmail']!='null') |
|
| 2645 | + if ($attachments[0]['is_winmail'] && $attachments[0]['is_winmail'] != 'null') |
|
| 2651 | 2646 | { |
| 2652 | - $tnefAttachments = $this->mail_bo->getTnefAttachments($message_id, $attachments[0]['partID'],true); |
|
| 2647 | + $tnefAttachments = $this->mail_bo->getTnefAttachments($message_id, $attachments[0]['partID'], true); |
|
| 2653 | 2648 | } |
| 2654 | - foreach($attachments as $file) |
|
| 2649 | + foreach ($attachments as $file) |
|
| 2655 | 2650 | { |
| 2656 | 2651 | if ($file['is_winmail']) |
| 2657 | 2652 | { |
@@ -2664,15 +2659,15 @@ discard block |
||
| 2664 | 2659 | } |
| 2665 | 2660 | else |
| 2666 | 2661 | { |
| 2667 | - $attachment = $this->mail_bo->getAttachment($message_id,$file['partID'],$file['is_winmail'],false,true); |
|
| 2662 | + $attachment = $this->mail_bo->getAttachment($message_id, $file['partID'], $file['is_winmail'], false, true); |
|
| 2668 | 2663 | } |
| 2669 | - $success=true; |
|
| 2664 | + $success = true; |
|
| 2670 | 2665 | if (empty($file['filename'])) $file['filename'] = $file['name']; |
| 2671 | - if (!($fp = egw_vfs::fopen($path.$file['filename'],'wb')) || |
|
| 2666 | + if (!($fp = egw_vfs::fopen($path.$file['filename'], 'wb')) || |
|
| 2672 | 2667 | !(!fseek($attachment['attachment'], 0, SEEK_SET) && stream_copy_to_stream($attachment['attachment'], $fp))) |
| 2673 | 2668 | { |
| 2674 | - $success=false; |
|
| 2675 | - egw_framework::message("Unable to zip {$file['filename']}",'error'); |
|
| 2669 | + $success = false; |
|
| 2670 | + egw_framework::message("Unable to zip {$file['filename']}", 'error'); |
|
| 2676 | 2671 | } |
| 2677 | 2672 | if ($success) $file_list[] = $path.$file['filename']; |
| 2678 | 2673 | if ($fp) fclose($fp); |
@@ -2693,7 +2688,7 @@ discard block |
||
| 2693 | 2688 | common::egw_exit(); |
| 2694 | 2689 | } |
| 2695 | 2690 | |
| 2696 | - function get_load_email_data($uid, $partID, $mailbox,$htmlOptions=null) |
|
| 2691 | + function get_load_email_data($uid, $partID, $mailbox, $htmlOptions = null) |
|
| 2697 | 2692 | { |
| 2698 | 2693 | // seems to be needed, as if we open a mail from notification popup that is |
| 2699 | 2694 | // located in a different folder, we experience: could not parse message |
@@ -2705,19 +2700,19 @@ discard block |
||
| 2705 | 2700 | if (empty($htmlOptions)) $htmlOptions = $this->mail_bo->htmlOptions; |
| 2706 | 2701 | // fetching structure now, to supply it to getMessageBody and getMessageAttachment, so it does not get fetched twice |
| 2707 | 2702 | $structure = $this->mail_bo->getStructure($uid, $partID, $mailbox, false); |
| 2708 | - $bodyParts = $this->mail_bo->getMessageBody($uid, ($htmlOptions?$htmlOptions:''), $partID, $structure, false, $mailbox); |
|
| 2703 | + $bodyParts = $this->mail_bo->getMessageBody($uid, ($htmlOptions ? $htmlOptions : ''), $partID, $structure, false, $mailbox); |
|
| 2709 | 2704 | |
| 2710 | 2705 | //error_log(__METHOD__.__LINE__.array2string($bodyParts)); |
| 2711 | 2706 | // attachments here are only fetched to determine if there is a meeting request |
| 2712 | 2707 | // and if. use the appropriate action. so we do not need embedded images |
| 2713 | 2708 | $fetchEmbeddedImages = false; |
| 2714 | - $attachments = (array)$this->mail_bo->getMessageAttachments($uid, $partID, $structure, $fetchEmbeddedImages, true,true,$mailbox); |
|
| 2709 | + $attachments = (array)$this->mail_bo->getMessageAttachments($uid, $partID, $structure, $fetchEmbeddedImages, true, true, $mailbox); |
|
| 2715 | 2710 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
| 2716 | 2711 | foreach ($attachments as &$attach) |
| 2717 | 2712 | { |
| 2718 | 2713 | if (strtolower($attach['mimeType']) == 'text/calendar' && |
| 2719 | 2714 | isset($GLOBALS['egw_info']['user']['apps']['calendar']) && |
| 2720 | - ($attachment = $this->mail_bo->getAttachment($uid, $attach['partID'],$attach['is_winmail'],(strtolower($attach['mimeType']) == 'text/calendar'?false:true)))) |
|
| 2715 | + ($attachment = $this->mail_bo->getAttachment($uid, $attach['partID'], $attach['is_winmail'], (strtolower($attach['mimeType']) == 'text/calendar' ? false : true)))) |
|
| 2721 | 2716 | { |
| 2722 | 2717 | //error_log(__METHOD__.__LINE__.array2string($attachment)); |
| 2723 | 2718 | egw_cache::setSession('calendar', 'ical', array( |
@@ -2728,28 +2723,28 @@ discard block |
||
| 2728 | 2723 | )); |
| 2729 | 2724 | $this->mail_bo->htmlOptions = $bufferHtmlOptions; |
| 2730 | 2725 | translation::add_app('calendar'); |
| 2731 | - return ExecMethod( 'calendar.calendar_uiforms.meeting', |
|
| 2732 | - array('event'=>null,'msg'=>'','useSession'=>true) |
|
| 2726 | + return ExecMethod('calendar.calendar_uiforms.meeting', |
|
| 2727 | + array('event'=>null, 'msg'=>'', 'useSession'=>true) |
|
| 2733 | 2728 | ); |
| 2734 | 2729 | } |
| 2735 | 2730 | } |
| 2736 | 2731 | // Compose the content of the frame |
| 2737 | 2732 | $frameHtml = |
| 2738 | 2733 | $this->get_email_header($this->mail_bo->getStyles($bodyParts)). |
| 2739 | - $this->showBody($this->getdisplayableBody($bodyParts,true,false), false); |
|
| 2734 | + $this->showBody($this->getdisplayableBody($bodyParts, true, false), false); |
|
| 2740 | 2735 | //IE10 eats away linebreaks preceeded by a whitespace in PRE sections |
| 2741 | - $frameHtml = str_replace(" \r\n","\r\n",$frameHtml); |
|
| 2736 | + $frameHtml = str_replace(" \r\n", "\r\n", $frameHtml); |
|
| 2742 | 2737 | $this->mail_bo->htmlOptions = $bufferHtmlOptions; |
| 2743 | 2738 | |
| 2744 | 2739 | return $frameHtml; |
| 2745 | 2740 | } |
| 2746 | 2741 | |
| 2747 | - static function get_email_header($additionalStyle='') |
|
| 2742 | + static function get_email_header($additionalStyle = '') |
|
| 2748 | 2743 | { |
| 2749 | 2744 | // egw_info[flags][css] already include <style> tags |
| 2750 | 2745 | $GLOBALS['egw_info']['flags']['css'] = preg_replace('|</?style[^>]*>|i', '', $additionalStyle); |
| 2751 | - $GLOBALS['egw_info']['flags']['nofooter']=true; |
|
| 2752 | - $GLOBALS['egw_info']['flags']['nonavbar']=true; |
|
| 2746 | + $GLOBALS['egw_info']['flags']['nofooter'] = true; |
|
| 2747 | + $GLOBALS['egw_info']['flags']['nonavbar'] = true; |
|
| 2753 | 2748 | // do NOT include any default CSS |
| 2754 | 2749 | egw_framework::includeCSS('mail', 'preview', true, true); |
| 2755 | 2750 | |
@@ -2760,35 +2755,35 @@ discard block |
||
| 2760 | 2755 | return $GLOBALS['egw']->framework->header(); |
| 2761 | 2756 | } |
| 2762 | 2757 | |
| 2763 | - function showBody(&$body, $print=true,$fullPageTags=true) |
|
| 2758 | + function showBody(&$body, $print = true, $fullPageTags = true) |
|
| 2764 | 2759 | { |
| 2765 | 2760 | $BeginBody = '<div class="mailDisplayBody"> |
| 2766 | 2761 | <table width="100%" style="table-layout:fixed"><tr><td class="td_display">'; |
| 2767 | 2762 | |
| 2768 | 2763 | $EndBody = '</td></tr></table></div>'; |
| 2769 | 2764 | if ($fullPageTags) $EndBody .= "</body></html>"; |
| 2770 | - if ($print) { |
|
| 2771 | - print $BeginBody. $body .$EndBody; |
|
| 2765 | + if ($print) { |
|
| 2766 | + print $BeginBody.$body.$EndBody; |
|
| 2772 | 2767 | } else { |
| 2773 | - return $BeginBody. $body .$EndBody; |
|
| 2768 | + return $BeginBody.$body.$EndBody; |
|
| 2774 | 2769 | } |
| 2775 | 2770 | } |
| 2776 | 2771 | |
| 2777 | - function &getdisplayableBody($_bodyParts,$modifyURI=true,$useTidy = true) |
|
| 2772 | + function &getdisplayableBody($_bodyParts, $modifyURI = true, $useTidy = true) |
|
| 2778 | 2773 | { |
| 2779 | - $bodyParts = $_bodyParts; |
|
| 2774 | + $bodyParts = $_bodyParts; |
|
| 2780 | 2775 | |
| 2781 | - $nonDisplayAbleCharacters = array('[\016]','[\017]', |
|
| 2782 | - '[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]', |
|
| 2783 | - '[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]'); |
|
| 2776 | + $nonDisplayAbleCharacters = array('[\016]', '[\017]', |
|
| 2777 | + '[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]', |
|
| 2778 | + '[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]'); |
|
| 2784 | 2779 | |
| 2785 | 2780 | $body = ''; |
| 2786 | 2781 | |
| 2787 | 2782 | //error_log(__METHOD__.array2string($bodyParts)); //exit; |
| 2788 | 2783 | if (empty($bodyParts)) return ""; |
| 2789 | - foreach((array)$bodyParts as $singleBodyPart) { |
|
| 2784 | + foreach ((array)$bodyParts as $singleBodyPart) { |
|
| 2790 | 2785 | if (!isset($singleBodyPart['body'])) { |
| 2791 | - $singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart,$modifyURI,$useTidy); |
|
| 2786 | + $singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart, $modifyURI, $useTidy); |
|
| 2792 | 2787 | $body .= $singleBodyPart['body']; |
| 2793 | 2788 | continue; |
| 2794 | 2789 | } |
@@ -2798,7 +2793,7 @@ discard block |
||
| 2798 | 2793 | $body .= ''; |
| 2799 | 2794 | continue; |
| 2800 | 2795 | } |
| 2801 | - if(!empty($body)) { |
|
| 2796 | + if (!empty($body)) { |
|
| 2802 | 2797 | $body .= '<hr style="border:dotted 1px silver;">'; |
| 2803 | 2798 | } |
| 2804 | 2799 | //error_log($singleBodyPart['body']); |
@@ -2823,22 +2818,22 @@ discard block |
||
| 2823 | 2818 | '(R)', |
| 2824 | 2819 | ); |
| 2825 | 2820 | |
| 2826 | - if(($singleBodyPart['mimeType'] == 'text/html' || $singleBodyPart['mimeType'] == 'text/plain') && |
|
| 2821 | + if (($singleBodyPart['mimeType'] == 'text/html' || $singleBodyPart['mimeType'] == 'text/plain') && |
|
| 2827 | 2822 | strtoupper($singleBodyPart['charSet']) != 'UTF-8') |
| 2828 | 2823 | { |
| 2829 | - $singleBodyPart['body'] = preg_replace($sar,$rar,$singleBodyPart['body']); |
|
| 2824 | + $singleBodyPart['body'] = preg_replace($sar, $rar, $singleBodyPart['body']); |
|
| 2830 | 2825 | } |
| 2831 | 2826 | //error_log(__METHOD__.__LINE__.'reports:'.$singleBodyPart['charSet']); |
| 2832 | - $singleBodyPart['body'] = translation::convert_jsonsafe($singleBodyPart['body'],$singleBodyPart['charSet']); |
|
| 2827 | + $singleBodyPart['body'] = translation::convert_jsonsafe($singleBodyPart['body'], $singleBodyPart['charSet']); |
|
| 2833 | 2828 | //error_log(__METHOD__.__LINE__.array2string($singleBodyPart)); |
| 2834 | - if($singleBodyPart['mimeType'] == 'text/plain') |
|
| 2829 | + if ($singleBodyPart['mimeType'] == 'text/plain') |
|
| 2835 | 2830 | { |
| 2836 | - $newBody = @htmlentities($singleBodyPart['body'],ENT_QUOTES, strtoupper(mail_bo::$displayCharset)); |
|
| 2831 | + $newBody = @htmlentities($singleBodyPart['body'], ENT_QUOTES, strtoupper(mail_bo::$displayCharset)); |
|
| 2837 | 2832 | //error_log(__METHOD__.__LINE__.'..'.$newBody); |
| 2838 | 2833 | // if empty and charset is utf8 try sanitizing the string in question |
| 2839 | - if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(mail_bo::$displayCharset)); |
|
| 2834 | + if (empty($newBody) && strtolower($singleBodyPart['charSet']) == 'utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']), ENT_QUOTES, strtoupper(mail_bo::$displayCharset)); |
|
| 2840 | 2835 | // if the conversion to htmlentities fails somehow, try without specifying the charset, which defaults to iso- |
| 2841 | - if (empty($newBody)) $newBody = htmlentities($singleBodyPart['body'],ENT_QUOTES); |
|
| 2836 | + if (empty($newBody)) $newBody = htmlentities($singleBodyPart['body'], ENT_QUOTES); |
|
| 2842 | 2837 | |
| 2843 | 2838 | // search http[s] links and make them as links available again |
| 2844 | 2839 | // to understand what's going on here, have a look at |
@@ -2866,20 +2861,20 @@ discard block |
||
| 2866 | 2861 | // since we do not display the message as HTML anymore we may want to insert good linebreaking (for visibility). |
| 2867 | 2862 | //error_log(__METHOD__.__LINE__.'..'.$newBody); |
| 2868 | 2863 | // dont break lines that start with > (> as the text was processed with htmlentities before) |
| 2869 | - $newBody = "<pre>".mail_bo::wordwrap($newBody,90,"\n",'>')."</pre>"; |
|
| 2864 | + $newBody = "<pre>".mail_bo::wordwrap($newBody, 90, "\n", '>')."</pre>"; |
|
| 2870 | 2865 | } |
| 2871 | 2866 | else |
| 2872 | 2867 | { |
| 2873 | - $alreadyHtmlLawed=false; |
|
| 2874 | - $newBody = $singleBodyPart['body']; |
|
| 2868 | + $alreadyHtmlLawed = false; |
|
| 2869 | + $newBody = $singleBodyPart['body']; |
|
| 2875 | 2870 | //TODO:$newBody = $this->highlightQuotes($newBody); |
| 2876 | 2871 | #error_log(print_r($newBody,true)); |
| 2877 | 2872 | if ($useTidy && extension_loaded('tidy')) |
| 2878 | 2873 | { |
| 2879 | 2874 | $tidy = new tidy(); |
| 2880 | - $cleaned = $tidy->repairString($newBody, mail_bo::$tidy_config,'utf8'); |
|
| 2875 | + $cleaned = $tidy->repairString($newBody, mail_bo::$tidy_config, 'utf8'); |
|
| 2881 | 2876 | // Found errors. Strip it all so there's some output |
| 2882 | - if($tidy->getStatus() == 2) |
|
| 2877 | + if ($tidy->getStatus() == 2) |
|
| 2883 | 2878 | { |
| 2884 | 2879 | error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$tidy->errorBuffer); |
| 2885 | 2880 | } |
@@ -2890,7 +2885,7 @@ discard block |
||
| 2890 | 2885 | if (!$preserveHTML) |
| 2891 | 2886 | { |
| 2892 | 2887 | // filter only the 'body', as we only want that part, if we throw away the html |
| 2893 | - preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array()); |
|
| 2888 | + preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array()); |
|
| 2894 | 2889 | if ($matches[2]) |
| 2895 | 2890 | { |
| 2896 | 2891 | $hasOther = true; |
@@ -2901,7 +2896,7 @@ discard block |
||
| 2901 | 2896 | else |
| 2902 | 2897 | { |
| 2903 | 2898 | // htmLawed filter only the 'body' |
| 2904 | - preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches=array()); |
|
| 2899 | + preg_match('`(<htm.+?<body[^>]*>)(.+?)(</body>.*?</html>)`ims', $newBody, $matches = array()); |
|
| 2905 | 2900 | if ($matches[2]) |
| 2906 | 2901 | { |
| 2907 | 2902 | $hasOther = true; |
@@ -2910,10 +2905,10 @@ discard block |
||
| 2910 | 2905 | $htmLawed = new egw_htmLawed(); |
| 2911 | 2906 | // the next line should not be needed, but produces better results on HTML 2 Text conversion, |
| 2912 | 2907 | // as we switched off HTMLaweds tidy functionality |
| 2913 | - $newBody = str_replace(array('&amp;','<DIV><BR></DIV>',"<DIV> </DIV>",'<div> </div>'),array('&','<BR>','<BR>','<BR>'),$newBody); |
|
| 2914 | - $newBody = $htmLawed->egw_htmLawed($newBody,mail_bo::$htmLawed_config); |
|
| 2915 | - if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3]; |
|
| 2916 | - $alreadyHtmlLawed=true; |
|
| 2908 | + $newBody = str_replace(array('&amp;', '<DIV><BR></DIV>', "<DIV> </DIV>", '<div> </div>'), array('&', '<BR>', '<BR>', '<BR>'), $newBody); |
|
| 2909 | + $newBody = $htmLawed->egw_htmLawed($newBody, mail_bo::$htmLawed_config); |
|
| 2910 | + if ($hasOther && $preserveHTML) $newBody = $matches[1].$newBody.$matches[3]; |
|
| 2911 | + $alreadyHtmlLawed = true; |
|
| 2917 | 2912 | } |
| 2918 | 2913 | // do the cleanup, set for the use of purifier |
| 2919 | 2914 | //$newBodyBuff = $newBody; |
@@ -2935,8 +2930,8 @@ discard block |
||
| 2935 | 2930 | } |
| 2936 | 2931 | */ |
| 2937 | 2932 | // removes stuff between http and ?http |
| 2938 | - $Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))'; // only http:// gets removed, other protocolls are shown |
|
| 2939 | - $newBody = preg_replace('~'.$Protocol.'[^>]*\?'.$Protocol.'~sim','$1',$newBody); // removes stuff between http:// and ?http:// |
|
| 2933 | + $Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))'; // only http:// gets removed, other protocolls are shown |
|
| 2934 | + $newBody = preg_replace('~'.$Protocol.'[^>]*\?'.$Protocol.'~sim', '$1', $newBody); // removes stuff between http:// and ?http:// |
|
| 2940 | 2935 | // TRANSFORM MAILTO LINKS TO EMAILADDRESS ONLY, WILL BE SUBSTITUTED BY parseEmail TO CLICKABLE LINK |
| 2941 | 2936 | $newBody = preg_replace('/(?<!"|href=|href\s=\s|href=\s|href\s=)'.'mailto:([a-z0-9._-]+)@([a-z0-9_-]+)\.([a-z0-9._-]+)/i', |
| 2942 | 2937 | "\\1@\\2.\\3", |
@@ -2949,7 +2944,7 @@ discard block |
||
| 2949 | 2944 | // create links for inline images |
| 2950 | 2945 | if ($modifyURI) |
| 2951 | 2946 | { |
| 2952 | - $newBody = self::resolve_inline_images ($newBody, $this->mailbox, $this->uid, $this->partID); |
|
| 2947 | + $newBody = self::resolve_inline_images($newBody, $this->mailbox, $this->uid, $this->partID); |
|
| 2953 | 2948 | } |
| 2954 | 2949 | // email addresses / mailto links get now activated on client-side |
| 2955 | 2950 | } |
@@ -2961,7 +2956,7 @@ discard block |
||
| 2961 | 2956 | $body = preg_replace("/(\\\\\\\\)([\w,\\\\,-]+)/i", |
| 2962 | 2957 | "<a href=\"file:$1$2\" target=\"_blank\"><font color=\"blue\">$1$2</font></a>", $body); |
| 2963 | 2958 | |
| 2964 | - $body = preg_replace($nonDisplayAbleCharacters,'',$body); |
|
| 2959 | + $body = preg_replace($nonDisplayAbleCharacters, '', $body); |
|
| 2965 | 2960 | |
| 2966 | 2961 | return $body; |
| 2967 | 2962 | } |
@@ -2976,7 +2971,7 @@ discard block |
||
| 2976 | 2971 | * @param string $_messageType = 'html', message type is either html or plain |
| 2977 | 2972 | * @return string message body including all CID images replaced |
| 2978 | 2973 | */ |
| 2979 | - public static function resolve_inline_images ($_body,$_mailbox, $_uid, $_partID, $_messageType = 'html') |
|
| 2974 | + public static function resolve_inline_images($_body, $_mailbox, $_uid, $_partID, $_messageType = 'html') |
|
| 2980 | 2975 | { |
| 2981 | 2976 | if ($_messageType === 'plain') |
| 2982 | 2977 | { |
@@ -2984,7 +2979,7 @@ discard block |
||
| 2984 | 2979 | } |
| 2985 | 2980 | else |
| 2986 | 2981 | { |
| 2987 | - foreach(array('src','url','background') as $type) |
|
| 2982 | + foreach (array('src', 'url', 'background') as $type) |
|
| 2988 | 2983 | { |
| 2989 | 2984 | $_body = self::resolve_inline_image_byType($_body, $_mailbox, $_uid, $_partID, $type); |
| 2990 | 2985 | } |
@@ -3003,7 +2998,7 @@ discard block |
||
| 3003 | 2998 | * - types: {plain|src|url|background} |
| 3004 | 2999 | * @return string returns body content including all CID replacements |
| 3005 | 3000 | */ |
| 3006 | - public static function resolve_inline_image_byType ($_body,$_mailbox, $_uid, $_partID, $_type ='src') |
|
| 3001 | + public static function resolve_inline_image_byType($_body, $_mailbox, $_uid, $_partID, $_type = 'src') |
|
| 3007 | 3002 | { |
| 3008 | 3003 | /** |
| 3009 | 3004 | * Callback for preg_replace_callback function |
@@ -3015,7 +3010,7 @@ discard block |
||
| 3015 | 3010 | * @param string $_type |
| 3016 | 3011 | * @return string|boolean returns the replace |
| 3017 | 3012 | */ |
| 3018 | - $replace_callback = function ($matches) use ($_mailbox,$_uid, $_partID, $_type) |
|
| 3013 | + $replace_callback = function($matches) use ($_mailbox, $_uid, $_partID, $_type) |
|
| 3019 | 3014 | { |
| 3020 | 3015 | if (!$_type) return false; |
| 3021 | 3016 | $CID = ''; |
@@ -3037,11 +3032,11 @@ discard block |
||
| 3037 | 3032 | break; |
| 3038 | 3033 | } |
| 3039 | 3034 | |
| 3040 | - static $cache = array(); // some caching, if mails containing the same image multiple times |
|
| 3035 | + static $cache = array(); // some caching, if mails containing the same image multiple times |
|
| 3041 | 3036 | |
| 3042 | 3037 | if (is_array($matches) && $CID) |
| 3043 | 3038 | { |
| 3044 | - $linkData = array ( |
|
| 3039 | + $linkData = array( |
|
| 3045 | 3040 | 'menuaction' => 'mail.mail_ui.displayImage', |
| 3046 | 3041 | 'uid' => $_uid, |
| 3047 | 3042 | 'mailbox' => base64_encode($_mailbox), |
@@ -3054,7 +3049,7 @@ discard block |
||
| 3054 | 3049 | { |
| 3055 | 3050 | if (!isset($cache[$imageURL])) |
| 3056 | 3051 | { |
| 3057 | - if ($_type !="background") |
|
| 3052 | + if ($_type != "background") |
|
| 3058 | 3053 | { |
| 3059 | 3054 | $bo = emailadmin_imapbase::getInstance(false, mail_ui::$icServerID); |
| 3060 | 3055 | $attachment = $bo->getAttachmentByCID($_uid, $CID, $_partID); |
@@ -3095,16 +3090,16 @@ discard block |
||
| 3095 | 3090 | }; |
| 3096 | 3091 | |
| 3097 | 3092 | // return new body content base on chosen type |
| 3098 | - switch($_type) |
|
| 3093 | + switch ($_type) |
|
| 3099 | 3094 | { |
| 3100 | 3095 | case"plain": |
| 3101 | - return preg_replace_callback("/\[cid:(.*)\]/iU",$replace_callback,$_body); |
|
| 3096 | + return preg_replace_callback("/\[cid:(.*)\]/iU", $replace_callback, $_body); |
|
| 3102 | 3097 | case "src": |
| 3103 | - return preg_replace_callback("/src=(\"|\')cid:(.*)(\"|\')/iU",$replace_callback,$_body); |
|
| 3098 | + return preg_replace_callback("/src=(\"|\')cid:(.*)(\"|\')/iU", $replace_callback, $_body); |
|
| 3104 | 3099 | case "url": |
| 3105 | - return preg_replace_callback("/url\(cid:(.*)\);/iU",$replace_callback,$_body); |
|
| 3100 | + return preg_replace_callback("/url\(cid:(.*)\);/iU", $replace_callback, $_body); |
|
| 3106 | 3101 | case "background": |
| 3107 | - return preg_replace_callback("/background=(\"|\')cid:(.*)(\"|\')/iU",$replace_callback,$_body); |
|
| 3102 | + return preg_replace_callback("/background=(\"|\')cid:(.*)(\"|\')/iU", $replace_callback, $_body); |
|
| 3108 | 3103 | } |
| 3109 | 3104 | } |
| 3110 | 3105 | |
@@ -3112,7 +3107,7 @@ discard block |
||
| 3112 | 3107 | * importMessage |
| 3113 | 3108 | * @param array $content = null an array of content |
| 3114 | 3109 | */ |
| 3115 | - function importMessage($content=null) |
|
| 3110 | + function importMessage($content = null) |
|
| 3116 | 3111 | { |
| 3117 | 3112 | //error_log(__METHOD__.__LINE__.$this->mail_bo->getDraftFolder()); |
| 3118 | 3113 | |
@@ -3134,7 +3129,7 @@ discard block |
||
| 3134 | 3129 | } |
| 3135 | 3130 | $destination = $content['FOLDER'][0]; |
| 3136 | 3131 | |
| 3137 | - if (stripos($destination,self::$delimiter)!==false) list($icServerID,$destination) = explode(self::$delimiter,$destination,2); |
|
| 3132 | + if (stripos($destination, self::$delimiter) !== false) list($icServerID, $destination) = explode(self::$delimiter, $destination, 2); |
|
| 3138 | 3133 | if ($icServerID && $icServerID != $this->mail_bo->profileID) |
| 3139 | 3134 | { |
| 3140 | 3135 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
@@ -3145,32 +3140,31 @@ discard block |
||
| 3145 | 3140 | $importFailed = false; |
| 3146 | 3141 | try |
| 3147 | 3142 | { |
| 3148 | - $messageUid = $this->importMessageToFolder($file,$destination,$importID); |
|
| 3149 | - $linkData = array |
|
| 3150 | - ( |
|
| 3143 | + $messageUid = $this->importMessageToFolder($file, $destination, $importID); |
|
| 3144 | + $linkData = array( |
|
| 3151 | 3145 | 'id' => $this->createRowID($destination, $messageUid, true), |
| 3152 | 3146 | ); |
| 3153 | 3147 | } |
| 3154 | 3148 | catch (egw_exception_wrong_userinput $e) |
| 3155 | 3149 | { |
| 3156 | - $importFailed=true; |
|
| 3157 | - $content['msg'] = $e->getMessage(); |
|
| 3150 | + $importFailed = true; |
|
| 3151 | + $content['msg'] = $e->getMessage(); |
|
| 3158 | 3152 | } |
| 3159 | 3153 | if (!$importFailed) |
| 3160 | 3154 | { |
| 3161 | 3155 | list($width, $height) = explode('x', egw_link::get_registry('mail', 'add_popup')); |
| 3162 | 3156 | if ($width > 0 && $height > 0) egw_json_response::get()->call('resizeTo', $width, $height); |
| 3163 | - ExecMethod2('mail.mail_ui.displayMessage',$linkData); |
|
| 3157 | + ExecMethod2('mail.mail_ui.displayMessage', $linkData); |
|
| 3164 | 3158 | return; |
| 3165 | 3159 | } |
| 3166 | 3160 | } |
| 3167 | 3161 | if (!is_array($content)) $content = array(); |
| 3168 | - if (empty($content['FOLDER'])) $content['FOLDER']=(array)$this->mail_bo->getDraftFolder(); |
|
| 3169 | - if (!empty($content['FOLDER'])) $sel_options['FOLDER']=mail_compose::ajax_searchFolder(0,true); |
|
| 3162 | + if (empty($content['FOLDER'])) $content['FOLDER'] = (array)$this->mail_bo->getDraftFolder(); |
|
| 3163 | + if (!empty($content['FOLDER'])) $sel_options['FOLDER'] = mail_compose::ajax_searchFolder(0, true); |
|
| 3170 | 3164 | |
| 3171 | 3165 | $etpl = new etemplate_new('mail.importMessage'); |
| 3172 | - $etpl->setElementAttribute('uploadForImport','onFinish','app.mail.uploadForImport'); |
|
| 3173 | - $etpl->exec('mail.mail_ui.importMessage',$content,$sel_options,array(),array(),2); |
|
| 3166 | + $etpl->setElementAttribute('uploadForImport', 'onFinish', 'app.mail.uploadForImport'); |
|
| 3167 | + $etpl->exec('mail.mail_ui.importMessage', $content, $sel_options, array(), array(), 2); |
|
| 3174 | 3168 | } |
| 3175 | 3169 | |
| 3176 | 3170 | /** |
@@ -3182,7 +3176,7 @@ discard block |
||
| 3182 | 3176 | * @param string $importID ID for the imported message, used by attachments to identify them unambiguously |
| 3183 | 3177 | * @return mixed $messageUID or exception |
| 3184 | 3178 | */ |
| 3185 | - function importMessageToFolder($_formData,&$_folder,$importID='') |
|
| 3179 | + function importMessageToFolder($_formData, &$_folder, $importID = '') |
|
| 3186 | 3180 | { |
| 3187 | 3181 | $importfailed = false; |
| 3188 | 3182 | //error_log(__METHOD__.__LINE__.array2string($_formData)); |
@@ -3190,7 +3184,7 @@ discard block |
||
| 3190 | 3184 | // check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.) |
| 3191 | 3185 | try |
| 3192 | 3186 | { |
| 3193 | - $tmpFileName = mail_bo::checkFileBasics($_formData,$importID); |
|
| 3187 | + $tmpFileName = mail_bo::checkFileBasics($_formData, $importID); |
|
| 3194 | 3188 | } |
| 3195 | 3189 | catch (egw_exception_wrong_userinput $e) |
| 3196 | 3190 | { |
@@ -3214,29 +3208,29 @@ discard block |
||
| 3214 | 3208 | if (empty($_folder)) |
| 3215 | 3209 | { |
| 3216 | 3210 | $importfailed = true; |
| 3217 | - $alert_msg .= lang("Import of message %1 failed. Destination Folder not set.",$_formData['name']); |
|
| 3211 | + $alert_msg .= lang("Import of message %1 failed. Destination Folder not set.", $_formData['name']); |
|
| 3218 | 3212 | } |
| 3219 | 3213 | $delimiter = $this->mail_bo->getHierarchyDelimiter(); |
| 3220 | - if($_folder=='INBOX'.$delimiter) $_folder='INBOX'; |
|
| 3214 | + if ($_folder == 'INBOX'.$delimiter) $_folder = 'INBOX'; |
|
| 3221 | 3215 | if ($importfailed === false) |
| 3222 | 3216 | { |
| 3223 | - if ($this->mail_bo->folderExists($_folder,true)) { |
|
| 3217 | + if ($this->mail_bo->folderExists($_folder, true)) { |
|
| 3224 | 3218 | try |
| 3225 | 3219 | { |
| 3226 | 3220 | $messageUid = $this->mail_bo->appendMessage($_folder, |
| 3227 | 3221 | $mailObject->getRaw(), |
| 3228 | - null,'\\Seen'); |
|
| 3222 | + null, '\\Seen'); |
|
| 3229 | 3223 | } |
| 3230 | 3224 | catch (egw_exception_wrong_userinput $e) |
| 3231 | 3225 | { |
| 3232 | 3226 | $importfailed = true; |
| 3233 | - $alert_msg .= lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$_formData['name'],$_folder,$e->getMessage()); |
|
| 3227 | + $alert_msg .= lang("Import of message %1 failed. Could not save message to folder %2 due to: %3", $_formData['name'], $_folder, $e->getMessage()); |
|
| 3234 | 3228 | } |
| 3235 | 3229 | } |
| 3236 | 3230 | else |
| 3237 | 3231 | { |
| 3238 | 3232 | $importfailed = true; |
| 3239 | - $alert_msg .= lang("Import of message %1 failed. Destination Folder %2 does not exist.",$_formData['name'],$_folder); |
|
| 3233 | + $alert_msg .= lang("Import of message %1 failed. Destination Folder %2 does not exist.", $_formData['name'], $_folder); |
|
| 3240 | 3234 | } |
| 3241 | 3235 | } |
| 3242 | 3236 | } |
@@ -3262,9 +3256,9 @@ discard block |
||
| 3262 | 3256 | * $formData['size'] = 2136; |
| 3263 | 3257 | * @return void |
| 3264 | 3258 | */ |
| 3265 | - function importMessageFromVFS2DraftAndEdit($formData='') |
|
| 3259 | + function importMessageFromVFS2DraftAndEdit($formData = '') |
|
| 3266 | 3260 | { |
| 3267 | - $this->importMessageFromVFS2DraftAndDisplay($formData,'edit'); |
|
| 3261 | + $this->importMessageFromVFS2DraftAndDisplay($formData, 'edit'); |
|
| 3268 | 3262 | } |
| 3269 | 3263 | |
| 3270 | 3264 | /** |
@@ -3279,7 +3273,7 @@ discard block |
||
| 3279 | 3273 | * @param string $mode mode to open ImportedMessage display and edit are supported |
| 3280 | 3274 | * @return void |
| 3281 | 3275 | */ |
| 3282 | - function importMessageFromVFS2DraftAndDisplay($formData='',$mode='display') |
|
| 3276 | + function importMessageFromVFS2DraftAndDisplay($formData = '', $mode = 'display') |
|
| 3283 | 3277 | { |
| 3284 | 3278 | if (empty($formData)) if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData']; |
| 3285 | 3279 | //error_log(__METHOD__.__LINE__.':'.array2string($formData).' Mode:'.$mode.'->'.function_backtrace()); |
@@ -3292,43 +3286,42 @@ discard block |
||
| 3292 | 3286 | $formData['file'] = 'egw-data://'.$formData['data']; |
| 3293 | 3287 | } |
| 3294 | 3288 | // name should be set to meet the requirements of checkFileBasics |
| 3295 | - if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['name'])) |
|
| 3289 | + if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && empty($formData['name'])) |
|
| 3296 | 3290 | { |
| 3297 | - $buff = explode('/',$formData['file']); |
|
| 3291 | + $buff = explode('/', $formData['file']); |
|
| 3298 | 3292 | if (is_array($buff)) $formData['name'] = array_pop($buff); // take the last part as name |
| 3299 | 3293 | } |
| 3300 | 3294 | // type should be set to meet the requirements of checkFileBasics |
| 3301 | - if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['type'])) |
|
| 3295 | + if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && empty($formData['type'])) |
|
| 3302 | 3296 | { |
| 3303 | - $buff = explode('.',$formData['file']); |
|
| 3297 | + $buff = explode('.', $formData['file']); |
|
| 3304 | 3298 | $suffix = ''; |
| 3305 | 3299 | if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
| 3306 | 3300 | if (!empty($suffix)) $formData['type'] = mime_magic::ext2mime($suffix); |
| 3307 | 3301 | } |
| 3308 | 3302 | // size should be set to meet the requirements of checkFileBasics |
| 3309 | - if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && !isset($formData['size'])) |
|
| 3303 | + if (parse_url($formData['file'], PHP_URL_SCHEME) == 'vfs' && !isset($formData['size'])) |
|
| 3310 | 3304 | { |
| 3311 | 3305 | $formData['size'] = strlen($formData['file']); // set some size, to meet requirements of checkFileBasics |
| 3312 | 3306 | } |
| 3313 | 3307 | try |
| 3314 | 3308 | { |
| 3315 | - $messageUid = $this->importMessageToFolder($formData,$draftFolder,$importID); |
|
| 3316 | - $linkData = array |
|
| 3317 | - ( |
|
| 3318 | - 'menuaction' => ($mode=='display'?'mail.mail_ui.displayMessage':'mail.mail_compose.composeFromDraft'), |
|
| 3319 | - 'id' => $this->createRowID($draftFolder,$messageUid,true), |
|
| 3309 | + $messageUid = $this->importMessageToFolder($formData, $draftFolder, $importID); |
|
| 3310 | + $linkData = array( |
|
| 3311 | + 'menuaction' => ($mode == 'display' ? 'mail.mail_ui.displayMessage' : 'mail.mail_compose.composeFromDraft'), |
|
| 3312 | + 'id' => $this->createRowID($draftFolder, $messageUid, true), |
|
| 3320 | 3313 | 'deleteDraftOnClose' => 1, |
| 3321 | 3314 | ); |
| 3322 | - if ($mode!='display') |
|
| 3315 | + if ($mode != 'display') |
|
| 3323 | 3316 | { |
| 3324 | 3317 | unset($linkData['deleteDraftOnClose']); |
| 3325 | - $linkData['method'] ='importMessageToMergeAndSend'; |
|
| 3318 | + $linkData['method'] = 'importMessageToMergeAndSend'; |
|
| 3326 | 3319 | } |
| 3327 | 3320 | else |
| 3328 | 3321 | { |
| 3329 | - $linkData['mode']=$mode; |
|
| 3322 | + $linkData['mode'] = $mode; |
|
| 3330 | 3323 | } |
| 3331 | - egw::redirect_link('/index.php',$linkData); |
|
| 3324 | + egw::redirect_link('/index.php', $linkData); |
|
| 3332 | 3325 | } |
| 3333 | 3326 | catch (egw_exception_wrong_userinput $e) |
| 3334 | 3327 | { |
@@ -3343,13 +3336,13 @@ discard block |
||
| 3343 | 3336 | * |
| 3344 | 3337 | * @return xajax response |
| 3345 | 3338 | */ |
| 3346 | - function loadEmailBody($_messageID=null,$_partID=null,$_htmloptions=null) |
|
| 3339 | + function loadEmailBody($_messageID = null, $_partID = null, $_htmloptions = null) |
|
| 3347 | 3340 | { |
| 3348 | 3341 | //error_log(__METHOD__.__LINE__.array2string($_GET)); |
| 3349 | 3342 | if (!$_messageID && !empty($_GET['_messageID'])) $_messageID = $_GET['_messageID']; |
| 3350 | 3343 | if (!$_partID && !empty($_GET['_partID'])) $_partID = $_GET['_partID']; |
| 3351 | 3344 | if (!$_htmloptions && !empty($_GET['_htmloptions'])) $_htmloptions = $_GET['_htmloptions']; |
| 3352 | - if(mail_bo::$debug) error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions"); |
|
| 3345 | + if (mail_bo::$debug) error_log(__METHOD__."->".print_r($_messageID, true).",$_partID,$_htmloptions"); |
|
| 3353 | 3346 | if (empty($_messageID)) return ""; |
| 3354 | 3347 | $uidA = self::splitRowID($_messageID); |
| 3355 | 3348 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
@@ -3363,7 +3356,7 @@ discard block |
||
| 3363 | 3356 | $this->changeProfile($icServerID); |
| 3364 | 3357 | } |
| 3365 | 3358 | |
| 3366 | - $bodyResponse = $this->get_load_email_data($messageID,$_partID,$folder,$_htmloptions); |
|
| 3359 | + $bodyResponse = $this->get_load_email_data($messageID, $_partID, $folder, $_htmloptions); |
|
| 3367 | 3360 | egw_session::cache_control(true); |
| 3368 | 3361 | //error_log(array2string($bodyResponse)); |
| 3369 | 3362 | echo $bodyResponse; |
@@ -3386,20 +3379,20 @@ discard block |
||
| 3386 | 3379 | $oA = array(); |
| 3387 | 3380 | foreach ($_folder as $_folderName) |
| 3388 | 3381 | { |
| 3389 | - list($profileID,$folderName) = explode(self::$delimiter,$_folderName,2); |
|
| 3382 | + list($profileID, $folderName) = explode(self::$delimiter, $_folderName, 2); |
|
| 3390 | 3383 | if (is_numeric($profileID)) |
| 3391 | 3384 | { |
| 3392 | 3385 | if ($profileID != $this->mail_bo->profileID) continue; // only current connection |
| 3393 | 3386 | if ($folderName) |
| 3394 | 3387 | { |
| 3395 | - $fS = $this->mail_bo->getFolderStatus($folderName,false,false,false); |
|
| 3396 | - if (in_array($fS['shortDisplayName'],mail_bo::$autoFolders)) $fS['shortDisplayName']=lang($fS['shortDisplayName']); |
|
| 3388 | + $fS = $this->mail_bo->getFolderStatus($folderName, false, false, false); |
|
| 3389 | + if (in_array($fS['shortDisplayName'], mail_bo::$autoFolders)) $fS['shortDisplayName'] = lang($fS['shortDisplayName']); |
|
| 3397 | 3390 | //error_log(__METHOD__.__LINE__.array2string($fS)); |
| 3398 | 3391 | if ($fS['unseen']) |
| 3399 | 3392 | { |
| 3400 | 3393 | $oA[$_folderName] = $fS['shortDisplayName'].' ('.$fS['unseen'].')'; |
| 3401 | 3394 | } |
| 3402 | - if ($fS['unseen']==0 && $fS['shortDisplayName']) |
|
| 3395 | + if ($fS['unseen'] == 0 && $fS['shortDisplayName']) |
|
| 3403 | 3396 | { |
| 3404 | 3397 | $oA[$_folderName] = $fS['shortDisplayName']; |
| 3405 | 3398 | } |
@@ -3410,7 +3403,7 @@ discard block |
||
| 3410 | 3403 | if ($oA) |
| 3411 | 3404 | { |
| 3412 | 3405 | $response = egw_json_response::get(); |
| 3413 | - $response->call('app.mail.mail_setFolderStatus',$oA); |
|
| 3406 | + $response->call('app.mail.mail_setFolderStatus', $oA); |
|
| 3414 | 3407 | } |
| 3415 | 3408 | } |
| 3416 | 3409 | } |
@@ -3424,14 +3417,14 @@ discard block |
||
| 3424 | 3417 | function ajax_addFolder($_parentFolderName, $_newName) |
| 3425 | 3418 | { |
| 3426 | 3419 | //error_log(__METHOD__.__LINE__.' ParentFolderName:'.array2string($_parentFolderName).' NewName/Folder:'.array2string($_newName)); |
| 3427 | - $errorMessage=''; |
|
| 3420 | + $errorMessage = ''; |
|
| 3428 | 3421 | if ($_parentFolderName) |
| 3429 | 3422 | { |
| 3430 | 3423 | $created = false; |
| 3431 | 3424 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_parentFolderName); |
| 3432 | 3425 | //the conversion is handeled by horde, frontend interaction is all utf-8 |
| 3433 | 3426 | $_newName = $this->mail_bo->decodeEntityFolderName($_newName); |
| 3434 | - list($profileID,$parentFolderName) = explode(self::$delimiter,$decodedFolderName,2); |
|
| 3427 | + list($profileID, $parentFolderName) = explode(self::$delimiter, $decodedFolderName, 2); |
|
| 3435 | 3428 | if (is_numeric($profileID)) |
| 3436 | 3429 | { |
| 3437 | 3430 | if ($profileID != $this->mail_bo->profileID) return; // only current connection |
@@ -3471,10 +3464,10 @@ discard block |
||
| 3471 | 3464 | |
| 3472 | 3465 | if (empty($del)) $del = $this->mail_bo->getHierarchyDelimiter(false); |
| 3473 | 3466 | */ |
| 3474 | - $nA = explode($del,$_newName); |
|
| 3467 | + $nA = explode($del, $_newName); |
|
| 3475 | 3468 | |
| 3476 | 3469 | //error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName"); |
| 3477 | - if (!!empty($parentFolderName)) $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName,false); |
|
| 3470 | + if (!!empty($parentFolderName)) $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName, false); |
|
| 3478 | 3471 | //error_log(__METHOD__.__LINE__.array2string($oldFolderInfo)); |
| 3479 | 3472 | |
| 3480 | 3473 | $this->mail_bo->reopen('INBOX'); |
@@ -3482,11 +3475,11 @@ discard block |
||
| 3482 | 3475 | // if newName has delimiter ($del) in it, we need to create the subtree |
| 3483 | 3476 | if (!empty($nA)) |
| 3484 | 3477 | { |
| 3485 | - $c=0; |
|
| 3486 | - foreach($nA as $sTName) |
|
| 3478 | + $c = 0; |
|
| 3479 | + foreach ($nA as $sTName) |
|
| 3487 | 3480 | { |
| 3488 | - $error=null; |
|
| 3489 | - if(($parentFolderName = $this->mail_bo->createFolder($parentFolderName, $sTName, $error))) |
|
| 3481 | + $error = null; |
|
| 3482 | + if (($parentFolderName = $this->mail_bo->createFolder($parentFolderName, $sTName, $error))) |
|
| 3490 | 3483 | { |
| 3491 | 3484 | $c++; |
| 3492 | 3485 | } |
@@ -3495,16 +3488,16 @@ discard block |
||
| 3495 | 3488 | $errorMessage .= $error; |
| 3496 | 3489 | } |
| 3497 | 3490 | } |
| 3498 | - if ($c==count($nA)) $created=true; |
|
| 3491 | + if ($c == count($nA)) $created = true; |
|
| 3499 | 3492 | } |
| 3500 | 3493 | if (!empty($parentName)) $this->mail_bo->reopen($parentName); |
| 3501 | 3494 | } |
| 3502 | 3495 | //error_log(__METHOD__.__LINE__.array2string($oA)); |
| 3503 | - if ($created===true) |
|
| 3496 | + if ($created === true) |
|
| 3504 | 3497 | { |
| 3505 | 3498 | $this->mail_bo->resetFolderObjectCache($profileID); |
| 3506 | 3499 | $response = egw_json_response::get(); |
| 3507 | - if ( $oldFolderInfo['shortDisplayName']) |
|
| 3500 | + if ($oldFolderInfo['shortDisplayName']) |
|
| 3508 | 3501 | { |
| 3509 | 3502 | $nodeInfo = array($_parentFolderName=>$oldFolderInfo['shortDisplayName']); |
| 3510 | 3503 | } |
@@ -3512,14 +3505,14 @@ discard block |
||
| 3512 | 3505 | { |
| 3513 | 3506 | $nodeInfo = array($profileID=>lang('INBOX')); |
| 3514 | 3507 | } |
| 3515 | - $response->call('app.mail.mail_reloadNode',$nodeInfo); |
|
| 3508 | + $response->call('app.mail.mail_reloadNode', $nodeInfo); |
|
| 3516 | 3509 | } |
| 3517 | 3510 | else |
| 3518 | 3511 | { |
| 3519 | 3512 | if ($errorMessage) |
| 3520 | 3513 | { |
| 3521 | 3514 | $response = egw_json_response::get(); |
| 3522 | - $response->call('egw.message',$errorMessage); |
|
| 3515 | + $response->call('egw.message', $errorMessage); |
|
| 3523 | 3516 | } |
| 3524 | 3517 | } |
| 3525 | 3518 | } |
@@ -3541,22 +3534,22 @@ discard block |
||
| 3541 | 3534 | $_newName = $this->mail_bo->decodeEntityFolderName($_newName); |
| 3542 | 3535 | $del = $this->mail_bo->getHierarchyDelimiter(false); |
| 3543 | 3536 | $oA = array(); |
| 3544 | - list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
|
| 3537 | + list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2); |
|
| 3545 | 3538 | $hasChildren = false; |
| 3546 | 3539 | if (is_numeric($profileID)) |
| 3547 | 3540 | { |
| 3548 | 3541 | if ($profileID != $this->mail_bo->profileID) return; // only current connection |
| 3549 | - $pA = explode($del,$folderName); |
|
| 3542 | + $pA = explode($del, $folderName); |
|
| 3550 | 3543 | array_pop($pA); |
| 3551 | - $parentFolder = implode($del,$pA); |
|
| 3552 | - if (strtoupper($folderName)!= 'INBOX') |
|
| 3544 | + $parentFolder = implode($del, $pA); |
|
| 3545 | + if (strtoupper($folderName) != 'INBOX') |
|
| 3553 | 3546 | { |
| 3554 | 3547 | //error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName"); |
| 3555 | - $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false); |
|
| 3548 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false); |
|
| 3556 | 3549 | //error_log(__METHOD__.__LINE__.array2string($oldFolderInfo)); |
| 3557 | - if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false) |
|
| 3550 | + if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false) |
|
| 3558 | 3551 | { |
| 3559 | - $hasChildren=true; // translates to: hasChildren -> dynamicLoading |
|
| 3552 | + $hasChildren = true; // translates to: hasChildren -> dynamicLoading |
|
| 3560 | 3553 | $delimiter = $this->mail_bo->getHierarchyDelimiter(); |
| 3561 | 3554 | $nameSpace = $this->mail_bo->_getNameSpaces(); |
| 3562 | 3555 | $prefix = $this->mail_bo->getFolderPrefixFromNamespace($nameSpace, $folderName); |
@@ -3573,7 +3566,7 @@ discard block |
||
| 3573 | 3566 | else |
| 3574 | 3567 | { |
| 3575 | 3568 | $rv = $this->mail_bo->icServer->subscribeMailbox($folder, false); |
| 3576 | - $fragments[$profileID.self::$delimiter.$folder] = substr($folder,strlen($folderName)); |
|
| 3569 | + $fragments[$profileID.self::$delimiter.$folder] = substr($folder, strlen($folderName)); |
|
| 3577 | 3570 | } |
| 3578 | 3571 | } |
| 3579 | 3572 | //error_log(__METHOD__.__LINE__.' Fetched Subfolders->'.array2string($fragments)); |
@@ -3583,7 +3576,7 @@ discard block |
||
| 3583 | 3576 | $success = false; |
| 3584 | 3577 | try |
| 3585 | 3578 | { |
| 3586 | - if(($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName))) |
|
| 3579 | + if (($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName))) |
|
| 3587 | 3580 | { |
| 3588 | 3581 | $this->mail_bo->resetFolderObjectCache($profileID); |
| 3589 | 3582 | //enforce the subscription to the newly named server, as it seems to fail for names with umlauts |
@@ -3594,11 +3587,11 @@ discard block |
||
| 3594 | 3587 | } |
| 3595 | 3588 | catch (Exception $e) |
| 3596 | 3589 | { |
| 3597 | - $newFolderName=$folderName; |
|
| 3590 | + $newFolderName = $folderName; |
|
| 3598 | 3591 | $msg = $e->getMessage(); |
| 3599 | 3592 | } |
| 3600 | 3593 | $this->mail_bo->reopen($newFolderName); |
| 3601 | - $fS = $this->mail_bo->getFolderStatus($newFolderName,false); |
|
| 3594 | + $fS = $this->mail_bo->getFolderStatus($newFolderName, false); |
|
| 3602 | 3595 | //error_log(__METHOD__.__LINE__.array2string($fS)); |
| 3603 | 3596 | if ($hasChildren) |
| 3604 | 3597 | { |
@@ -3629,12 +3622,12 @@ discard block |
||
| 3629 | 3622 | { |
| 3630 | 3623 | $oA[$_folderName]['desc'] = $fS['shortDisplayName']; |
| 3631 | 3624 | } |
| 3632 | - foreach($fragments as $oldFolderName => $fragment) |
|
| 3625 | + foreach ($fragments as $oldFolderName => $fragment) |
|
| 3633 | 3626 | { |
| 3634 | 3627 | //error_log(__METHOD__.__LINE__.':'.$oldFolderName.'->'.$profileID.self::$delimiter.$newFolderName.$fragment); |
| 3635 | 3628 | $oA[$oldFolderName]['id'] = $profileID.self::$delimiter.$newFolderName.$fragment; |
| 3636 | 3629 | $oA[$oldFolderName]['olddesc'] = '#skip-user-interaction-message#'; |
| 3637 | - $fS = $this->mail_bo->getFolderStatus($newFolderName.$fragment,false); |
|
| 3630 | + $fS = $this->mail_bo->getFolderStatus($newFolderName.$fragment, false); |
|
| 3638 | 3631 | if ($fS['unseen']) |
| 3639 | 3632 | { |
| 3640 | 3633 | $oA[$oldFolderName]['desc'] = $fS['shortDisplayName'].' ('.$fS['unseen'].')'; |
@@ -3647,20 +3640,20 @@ discard block |
||
| 3647 | 3640 | } |
| 3648 | 3641 | } |
| 3649 | 3642 | } |
| 3650 | - if ($folderName==$this->mail_bo->sessionData['mailbox']) |
|
| 3643 | + if ($folderName == $this->mail_bo->sessionData['mailbox']) |
|
| 3651 | 3644 | { |
| 3652 | - $this->mail_bo->sessionData['mailbox']=$newFolderName; |
|
| 3645 | + $this->mail_bo->sessionData['mailbox'] = $newFolderName; |
|
| 3653 | 3646 | $this->mail_bo->saveSessionData(); |
| 3654 | 3647 | } |
| 3655 | 3648 | //error_log(__METHOD__.__LINE__.array2string($oA)); |
| 3656 | 3649 | $response = egw_json_response::get(); |
| 3657 | 3650 | if ($oA && $success) |
| 3658 | 3651 | { |
| 3659 | - $response->call('app.mail.mail_setLeaf',$oA); |
|
| 3652 | + $response->call('app.mail.mail_setLeaf', $oA); |
|
| 3660 | 3653 | } |
| 3661 | 3654 | else |
| 3662 | 3655 | { |
| 3663 | - $response->call('egw.refresh',lang('failed to rename %1 ! Reason: %2',$oldFolderName,$msg),'mail'); |
|
| 3656 | + $response->call('egw.refresh', lang('failed to rename %1 ! Reason: %2', $oldFolderName, $msg), 'mail'); |
|
| 3664 | 3657 | } |
| 3665 | 3658 | } |
| 3666 | 3659 | } |
@@ -3672,7 +3665,7 @@ discard block |
||
| 3672 | 3665 | * @param boolean $_subscribedOnly = true |
| 3673 | 3666 | * @return void |
| 3674 | 3667 | */ |
| 3675 | - function ajax_reloadNode($_folderName,$_subscribedOnly=true) |
|
| 3668 | + function ajax_reloadNode($_folderName, $_subscribedOnly = true) |
|
| 3676 | 3669 | { |
| 3677 | 3670 | translation::add_app('mail'); |
| 3678 | 3671 | $oldPrefForSubscribedOnly = !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']; |
@@ -3683,20 +3676,20 @@ discard block |
||
| 3683 | 3676 | |
| 3684 | 3677 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 3685 | 3678 | $this->mail_bo->getHierarchyDelimiter(false); |
| 3686 | - list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
|
| 3679 | + list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2); |
|
| 3687 | 3680 | // if pref and required mode dont match -> reset the folderObject cache to ensure |
| 3688 | 3681 | // that we get what we request |
| 3689 | 3682 | if ($_subscribedOnly != $oldPrefForSubscribedOnly) $this->mail_bo->resetFolderObjectCache($profileID); |
| 3690 | 3683 | if ($profileID != $this->mail_bo->profileID) return; // only current connection |
| 3691 | 3684 | if (!empty($folderName)) |
| 3692 | 3685 | { |
| 3693 | - $parentFolder=(!empty($folderName)?$folderName:'INBOX'); |
|
| 3694 | - $folderInfo = $this->mail_bo->getFolderStatus($parentFolder,false,false,false); |
|
| 3686 | + $parentFolder = (!empty($folderName) ? $folderName : 'INBOX'); |
|
| 3687 | + $folderInfo = $this->mail_bo->getFolderStatus($parentFolder, false, false, false); |
|
| 3695 | 3688 | if ($folderInfo['unseen']) |
| 3696 | 3689 | { |
| 3697 | 3690 | $folderInfo['shortDisplayName'] = $folderInfo['shortDisplayName'].' ('.$folderInfo['unseen'].')'; |
| 3698 | 3691 | } |
| 3699 | - if ($folderInfo['unseen']==0 && $folderInfo['shortDisplayName']) |
|
| 3692 | + if ($folderInfo['unseen'] == 0 && $folderInfo['shortDisplayName']) |
|
| 3700 | 3693 | { |
| 3701 | 3694 | $folderInfo['shortDisplayName'] = $folderInfo['shortDisplayName']; |
| 3702 | 3695 | } |
@@ -3712,11 +3705,11 @@ discard block |
||
| 3712 | 3705 | } |
| 3713 | 3706 | // Send full info back in the response |
| 3714 | 3707 | $response = egw_json_response::get(); |
| 3715 | - foreach($refreshData as $folder => &$name) |
|
| 3708 | + foreach ($refreshData as $folder => &$name) |
|
| 3716 | 3709 | { |
| 3717 | - $name = $this->mail_tree->getTree($folder,$profileID,1,false, $_subscribedOnly,true); |
|
| 3710 | + $name = $this->mail_tree->getTree($folder, $profileID, 1, false, $_subscribedOnly, true); |
|
| 3718 | 3711 | } |
| 3719 | - $response->call('app.mail.mail_reloadNode',$refreshData); |
|
| 3712 | + $response->call('app.mail.mail_reloadNode', $refreshData); |
|
| 3720 | 3713 | |
| 3721 | 3714 | } |
| 3722 | 3715 | |
@@ -3732,7 +3725,7 @@ discard block |
||
| 3732 | 3725 | * @param type $_rowid row id from nm |
| 3733 | 3726 | * |
| 3734 | 3727 | */ |
| 3735 | - function ajax_resolveWinmail ($_rowid) |
|
| 3728 | + function ajax_resolveWinmail($_rowid) |
|
| 3736 | 3729 | { |
| 3737 | 3730 | $response = egw_json_response::get(); |
| 3738 | 3731 | |
@@ -3740,7 +3733,7 @@ discard block |
||
| 3740 | 3733 | $uid = $idParts['msgUID']; |
| 3741 | 3734 | $mbox = $idParts['folder']; |
| 3742 | 3735 | |
| 3743 | - $attachments = $this->mail_bo->getMessageAttachments($uid, null, null, false,true,true,$mbox); |
|
| 3736 | + $attachments = $this->mail_bo->getMessageAttachments($uid, null, null, false, true, true, $mbox); |
|
| 3744 | 3737 | if (is_array($attachments)) |
| 3745 | 3738 | { |
| 3746 | 3739 | $attachments = $this->createAttachmentBlock($attachments, $_rowid, $uid, $mbox, false); |
@@ -3768,30 +3761,30 @@ discard block |
||
| 3768 | 3761 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 3769 | 3762 | $_newLocation = $this->mail_bo->decodeEntityFolderName($_target); |
| 3770 | 3763 | $del = $this->mail_bo->getHierarchyDelimiter(false); |
| 3771 | - list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
|
| 3772 | - list($newProfileID,$_newLocation) = explode(self::$delimiter,$_newLocation,2); |
|
| 3764 | + list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2); |
|
| 3765 | + list($newProfileID, $_newLocation) = explode(self::$delimiter, $_newLocation, 2); |
|
| 3773 | 3766 | $hasChildren = false; |
| 3774 | 3767 | if (is_numeric($profileID)) |
| 3775 | 3768 | { |
| 3776 | 3769 | if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID) return; // only current connection |
| 3777 | - $pA = explode($del,$folderName); |
|
| 3770 | + $pA = explode($del, $folderName); |
|
| 3778 | 3771 | $namePart = array_pop($pA); |
| 3779 | 3772 | $_newName = $namePart; |
| 3780 | - $oldParentFolder = implode($del,$pA); |
|
| 3773 | + $oldParentFolder = implode($del, $pA); |
|
| 3781 | 3774 | $parentFolder = $_newLocation; |
| 3782 | 3775 | |
| 3783 | - if (strtoupper($folderName)!= 'INBOX' && |
|
| 3776 | + if (strtoupper($folderName) != 'INBOX' && |
|
| 3784 | 3777 | (($oldParentFolder === $parentFolder) || //$oldParentFolder == $parentFolder means move on same level |
| 3785 | 3778 | (($oldParentFolder != $parentFolder && |
| 3786 | - strlen($parentFolder)>0 && strlen($folderName)>0 && |
|
| 3787 | - strpos($parentFolder,$folderName)===false)))) // indicates that we move the older up the tree within its own branch |
|
| 3779 | + strlen($parentFolder) > 0 && strlen($folderName) > 0 && |
|
| 3780 | + strpos($parentFolder, $folderName) === false)))) // indicates that we move the older up the tree within its own branch |
|
| 3788 | 3781 | { |
| 3789 | 3782 | //error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName"); |
| 3790 | - $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false); |
|
| 3783 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false, false, false); |
|
| 3791 | 3784 | //error_log(__METHOD__.__LINE__.array2string($oldFolderInfo)); |
| 3792 | - if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false) |
|
| 3785 | + if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false) |
|
| 3793 | 3786 | { |
| 3794 | - $hasChildren=true; // translates to: hasChildren -> dynamicLoading |
|
| 3787 | + $hasChildren = true; // translates to: hasChildren -> dynamicLoading |
|
| 3795 | 3788 | $delimiter = $this->mail_bo->getHierarchyDelimiter(); |
| 3796 | 3789 | $nameSpace = $this->mail_bo->_getNameSpaces(); |
| 3797 | 3790 | $prefix = $this->mail_bo->getFolderPrefixFromNamespace($nameSpace, $folderName); |
@@ -3816,7 +3809,7 @@ discard block |
||
| 3816 | 3809 | $success = false; |
| 3817 | 3810 | try |
| 3818 | 3811 | { |
| 3819 | - if(($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName))) |
|
| 3812 | + if (($newFolderName = $this->mail_bo->renameFolder($folderName, $parentFolder, $_newName))) |
|
| 3820 | 3813 | { |
| 3821 | 3814 | $this->mail_bo->resetFolderObjectCache($profileID); |
| 3822 | 3815 | //enforce the subscription to the newly named server, as it seems to fail for names with umlauts |
@@ -3828,11 +3821,11 @@ discard block |
||
| 3828 | 3821 | } |
| 3829 | 3822 | catch (Exception $e) |
| 3830 | 3823 | { |
| 3831 | - $newFolderName=$folderName; |
|
| 3824 | + $newFolderName = $folderName; |
|
| 3832 | 3825 | $msg = $e->getMessage(); |
| 3833 | 3826 | } |
| 3834 | 3827 | $this->mail_bo->reopen($parentFolder); |
| 3835 | - $this->mail_bo->getFolderStatus($parentFolder,false,false,false); |
|
| 3828 | + $this->mail_bo->getFolderStatus($parentFolder, false, false, false); |
|
| 3836 | 3829 | //error_log(__METHOD__.__LINE__.array2string($fS)); |
| 3837 | 3830 | if ($hasChildren) |
| 3838 | 3831 | { |
@@ -3853,9 +3846,9 @@ discard block |
||
| 3853 | 3846 | } |
| 3854 | 3847 | } |
| 3855 | 3848 | } |
| 3856 | - if ($folderName==$this->mail_bo->sessionData['mailbox']) |
|
| 3849 | + if ($folderName == $this->mail_bo->sessionData['mailbox']) |
|
| 3857 | 3850 | { |
| 3858 | - $this->mail_bo->sessionData['mailbox']=$newFolderName; |
|
| 3851 | + $this->mail_bo->sessionData['mailbox'] = $newFolderName; |
|
| 3859 | 3852 | $this->mail_bo->saveSessionData(); |
| 3860 | 3853 | } |
| 3861 | 3854 | //error_log(__METHOD__.__LINE__.array2string($oA)); |
@@ -3864,26 +3857,26 @@ discard block |
||
| 3864 | 3857 | { |
| 3865 | 3858 | translation::add_app('mail'); |
| 3866 | 3859 | |
| 3867 | - $oldFolderInfo = $this->mail_bo->getFolderStatus($oldParentFolder,false,false,false); |
|
| 3868 | - $folderInfo = $this->mail_bo->getFolderStatus($parentFolder,false,false,false); |
|
| 3860 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($oldParentFolder, false, false, false); |
|
| 3861 | + $folderInfo = $this->mail_bo->getFolderStatus($parentFolder, false, false, false); |
|
| 3869 | 3862 | $refreshData = array( |
| 3870 | 3863 | $profileID.self::$delimiter.$oldParentFolder=>$oldFolderInfo['shortDisplayName'], |
| 3871 | 3864 | $profileID.self::$delimiter.$parentFolder=>$folderInfo['shortDisplayName']); |
| 3872 | 3865 | // if we move the folder within the same parent-branch of the tree, there is no need no refresh the upper part |
| 3873 | - if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]); |
|
| 3874 | - if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]); |
|
| 3866 | + if (strlen($parentFolder) > strlen($oldParentFolder) && strpos($parentFolder, $oldParentFolder) !== false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]); |
|
| 3867 | + if (count($refreshData) > 1 && strlen($oldParentFolder) > strlen($parentFolder) && strpos($oldParentFolder, $parentFolder) !== false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]); |
|
| 3875 | 3868 | |
| 3876 | 3869 | // Send full info back in the response |
| 3877 | - foreach($refreshData as $folder => &$name) |
|
| 3870 | + foreach ($refreshData as $folder => &$name) |
|
| 3878 | 3871 | { |
| 3879 | - $name = $this->mail_tree->getTree($folder,$profileID,1,false,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'],true); |
|
| 3872 | + $name = $this->mail_tree->getTree($folder, $profileID, 1, false, !$this->mail_bo->mailPreferences['showAllFoldersInFolderPane'], true); |
|
| 3880 | 3873 | } |
| 3881 | - $response->call('app.mail.mail_reloadNode',$refreshData); |
|
| 3874 | + $response->call('app.mail.mail_reloadNode', $refreshData); |
|
| 3882 | 3875 | |
| 3883 | 3876 | } |
| 3884 | 3877 | else |
| 3885 | 3878 | { |
| 3886 | - $response->call('egw.refresh',lang('failed to move %1 ! Reason: %2',$folderName,$msg),'mail'); |
|
| 3879 | + $response->call('egw.refresh', lang('failed to move %1 ! Reason: %2', $folderName, $msg), 'mail'); |
|
| 3887 | 3880 | } |
| 3888 | 3881 | } |
| 3889 | 3882 | } |
@@ -3903,23 +3896,23 @@ discard block |
||
| 3903 | 3896 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 3904 | 3897 | $del = $this->mail_bo->getHierarchyDelimiter(false); |
| 3905 | 3898 | $oA = array(); |
| 3906 | - list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
|
| 3899 | + list($profileID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2); |
|
| 3907 | 3900 | $hasChildren = false; |
| 3908 | 3901 | if (is_numeric($profileID)) |
| 3909 | 3902 | { |
| 3910 | 3903 | if ($profileID != $this->mail_bo->profileID) return; // only current connection |
| 3911 | - $pA = explode($del,$folderName); |
|
| 3904 | + $pA = explode($del, $folderName); |
|
| 3912 | 3905 | array_pop($pA); |
| 3913 | - if (strtoupper($folderName)!= 'INBOX') |
|
| 3906 | + if (strtoupper($folderName) != 'INBOX') |
|
| 3914 | 3907 | { |
| 3915 | 3908 | //error_log(__METHOD__.__LINE__."$folderName, implode($del,$pA), $_newName"); |
| 3916 | 3909 | $oA = array(); |
| 3917 | 3910 | $subFolders = array(); |
| 3918 | - $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false); |
|
| 3911 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName, false, false, false); |
|
| 3919 | 3912 | //error_log(__METHOD__.__LINE__.array2string($oldFolderInfo)); |
| 3920 | - if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false) |
|
| 3913 | + if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']), '\hasnochildren') === false) |
|
| 3921 | 3914 | { |
| 3922 | - $hasChildren=true; // translates to: hasChildren -> dynamicLoading |
|
| 3915 | + $hasChildren = true; // translates to: hasChildren -> dynamicLoading |
|
| 3923 | 3916 | $ftD = array(); |
| 3924 | 3917 | $delimiter = $this->mail_bo->getHierarchyDelimiter(); |
| 3925 | 3918 | $nameSpace = $this->mail_bo->_getNameSpaces(); |
@@ -3929,24 +3922,24 @@ discard block |
||
| 3929 | 3922 | //error_log(__METHOD__.__LINE__.'->'."$folderName, $delimiter, $prefix"); |
| 3930 | 3923 | foreach ($subFolders as $k => $f) |
| 3931 | 3924 | { |
| 3932 | - $ftD[substr_count($f,$delimiter)][]=$f; |
|
| 3925 | + $ftD[substr_count($f, $delimiter)][] = $f; |
|
| 3933 | 3926 | } |
| 3934 | - krsort($ftD,SORT_NUMERIC);//sort per level |
|
| 3927 | + krsort($ftD, SORT_NUMERIC); //sort per level |
|
| 3935 | 3928 | //we iterate per level of depth of the subtree, deepest nesting is to be deleted first, and then up the tree |
| 3936 | - foreach($ftD as $k => $lc)//collection per level |
|
| 3929 | + foreach ($ftD as $k => $lc)//collection per level |
|
| 3937 | 3930 | { |
| 3938 | - foreach($lc as $i => $f)//folders contained in that level |
|
| 3931 | + foreach ($lc as $i => $f)//folders contained in that level |
|
| 3939 | 3932 | { |
| 3940 | 3933 | try |
| 3941 | 3934 | { |
| 3942 | 3935 | //error_log(__METHOD__.__LINE__.array2string($f).'<->'.$folderName); |
| 3943 | 3936 | $this->mail_bo->deleteFolder($f); |
| 3944 | 3937 | $success = true; |
| 3945 | - if ($f==$folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName']; |
|
| 3938 | + if ($f == $folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName']; |
|
| 3946 | 3939 | } |
| 3947 | 3940 | catch (Exception $e) |
| 3948 | 3941 | { |
| 3949 | - $msg .= ($msg?' ':'').lang("Failed to delete %1. Server responded:",$f).$e->getMessage(); |
|
| 3942 | + $msg .= ($msg ? ' ' : '').lang("Failed to delete %1. Server responded:", $f).$e->getMessage(); |
|
| 3950 | 3943 | $success = false; |
| 3951 | 3944 | } |
| 3952 | 3945 | } |
@@ -3977,11 +3970,11 @@ discard block |
||
| 3977 | 3970 | if ($success) |
| 3978 | 3971 | { |
| 3979 | 3972 | //error_log(__METHOD__.__LINE__.array2string($oA)); |
| 3980 | - $response->call('app.mail.mail_removeLeaf',$oA); |
|
| 3973 | + $response->call('app.mail.mail_removeLeaf', $oA); |
|
| 3981 | 3974 | } |
| 3982 | 3975 | else |
| 3983 | 3976 | { |
| 3984 | - $response->call('egw.refresh',lang('failed to delete %1 ! Reason: %2',$oldFolderInfo['shortDisplayName'],$msg),'mail'); |
|
| 3977 | + $response->call('egw.refresh', lang('failed to delete %1 ! Reason: %2', $oldFolderInfo['shortDisplayName'], $msg), 'mail'); |
|
| 3985 | 3978 | } |
| 3986 | 3979 | } |
| 3987 | 3980 | } |
@@ -3995,7 +3988,7 @@ discard block |
||
| 3995 | 3988 | * @param bool $getFolders The client needs the folders for the profile |
| 3996 | 3989 | * @return nothing |
| 3997 | 3990 | */ |
| 3998 | - public static function ajax_changeProfile($icServerID, $getFolders = true, $exec_id=null) |
|
| 3991 | + public static function ajax_changeProfile($icServerID, $getFolders = true, $exec_id = null) |
|
| 3999 | 3992 | { |
| 4000 | 3993 | $response = egw_json_response::get(); |
| 4001 | 3994 | |
@@ -4003,7 +3996,7 @@ discard block |
||
| 4003 | 3996 | |
| 4004 | 3997 | if ($icServerID && $icServerID != $previous_id) |
| 4005 | 3998 | { |
| 4006 | - $mail_ui = new mail_ui(false); // do NOT run constructor, as we call changeProfile anyway |
|
| 3999 | + $mail_ui = new mail_ui(false); // do NOT run constructor, as we call changeProfile anyway |
|
| 4007 | 4000 | try |
| 4008 | 4001 | { |
| 4009 | 4002 | $mail_ui->changeProfile($icServerID); |
@@ -4019,23 +4012,23 @@ discard block |
||
| 4019 | 4012 | } |
| 4020 | 4013 | } |
| 4021 | 4014 | catch (Exception $e) { |
| 4022 | - self::callWizard($e->getMessage(),true, 'error'); |
|
| 4015 | + self::callWizard($e->getMessage(), true, 'error'); |
|
| 4023 | 4016 | } |
| 4024 | 4017 | } |
| 4025 | 4018 | else |
| 4026 | 4019 | { |
| 4027 | - $mail_ui = new mail_ui(true); // run constructor |
|
| 4020 | + $mail_ui = new mail_ui(true); // run constructor |
|
| 4028 | 4021 | } |
| 4029 | 4022 | |
| 4030 | 4023 | // Send full info back in the response |
| 4031 | - if($getFolders) |
|
| 4024 | + if ($getFolders) |
|
| 4032 | 4025 | { |
| 4033 | 4026 | translation::add_app('mail'); |
| 4034 | 4027 | |
| 4035 | 4028 | $refreshData = array( |
| 4036 | - $icServerID => $mail_ui->mail_tree->getTree(null,$icServerID,1,false,!$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane'],!$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane']) |
|
| 4029 | + $icServerID => $mail_ui->mail_tree->getTree(null, $icServerID, 1, false, !$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane'], !$mail_ui->mail_bo->mailPreferences['showAllFoldersInFolderPane']) |
|
| 4037 | 4030 | ); |
| 4038 | - $response->call('app.mail.mail_reloadNode',$refreshData); |
|
| 4031 | + $response->call('app.mail.mail_reloadNode', $refreshData); |
|
| 4039 | 4032 | } |
| 4040 | 4033 | } |
| 4041 | 4034 | |
@@ -4046,7 +4039,7 @@ discard block |
||
| 4046 | 4039 | * if other than active profile; nothing is done! |
| 4047 | 4040 | * @return nothing |
| 4048 | 4041 | */ |
| 4049 | - public static function ajax_refreshVacationNotice($icServerID=null) |
|
| 4042 | + public static function ajax_refreshVacationNotice($icServerID = null) |
|
| 4050 | 4043 | { |
| 4051 | 4044 | //Get vacation from cache if it's available |
| 4052 | 4045 | $cachedVacations = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid']); |
@@ -4063,22 +4056,22 @@ discard block |
||
| 4063 | 4056 | $vacation = $mail->gatherVacation($cachedVacations); |
| 4064 | 4057 | } |
| 4065 | 4058 | |
| 4066 | - if($vacation) { |
|
| 4067 | - if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date')) |
|
| 4059 | + if ($vacation) { |
|
| 4060 | + if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status'] == 'by_date')) |
|
| 4068 | 4061 | { |
| 4069 | 4062 | $dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']; |
| 4070 | 4063 | $refreshData['vacationnotice'] = lang('Vacation notice is active'); |
| 4071 | - $refreshData['vacationrange'] = ($vacation['status']=='by_date'? common::show_date($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.common::show_date($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):''); |
|
| 4072 | - if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time())$refreshData = ''; |
|
| 4064 | + $refreshData['vacationrange'] = ($vacation['status'] == 'by_date' ? common::show_date($vacation['start_date'], $dtfrmt, true).($vacation['end_date'] > $vacation['start_date'] ? '->'.common::show_date($vacation['end_date'] + 24 * 3600 - 1, $dtfrmt, true) : '') : ''); |
|
| 4065 | + if ($vacation['status'] == 'by_date' && $vacation['end_date'] + 24 * 3600 < time())$refreshData = ''; |
|
| 4073 | 4066 | } |
| 4074 | 4067 | } |
| 4075 | - if ($vacation==false) |
|
| 4068 | + if ($vacation == false) |
|
| 4076 | 4069 | { |
| 4077 | - $refreshData['vacationnotice'] = ''; |
|
| 4078 | - $refreshData['vacationrange'] = ''; |
|
| 4070 | + $refreshData['vacationnotice'] = ''; |
|
| 4071 | + $refreshData['vacationrange'] = ''; |
|
| 4079 | 4072 | } |
| 4080 | 4073 | $response = egw_json_response::get(); |
| 4081 | - $response->call('app.mail.mail_refreshVacationNotice',$refreshData); |
|
| 4074 | + $response->call('app.mail.mail_refreshVacationNotice', $refreshData); |
|
| 4082 | 4075 | } |
| 4083 | 4076 | |
| 4084 | 4077 | /** |
@@ -4088,41 +4081,41 @@ discard block |
||
| 4088 | 4081 | * if other than active profile; nothing is done! |
| 4089 | 4082 | * @return nothing |
| 4090 | 4083 | */ |
| 4091 | - function ajax_refreshFilters($icServerID=null) |
|
| 4084 | + function ajax_refreshFilters($icServerID = null) |
|
| 4092 | 4085 | { |
| 4093 | 4086 | //error_log(__METHOD__.__LINE__.array2string($icServerId)); |
| 4094 | 4087 | if (empty($icServerID)) $icServerID = $this->mail_bo->profileID; |
| 4095 | 4088 | if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) |
| 4096 | 4089 | { |
| 4097 | - emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
|
| 4098 | - if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 4090 | + emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 4091 | + if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID] = true; |
|
| 4099 | 4092 | } |
| 4100 | 4093 | if (!emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]) |
| 4101 | 4094 | { |
| 4102 | 4095 | unset($this->searchTypes['quick']); |
| 4103 | 4096 | } |
| 4104 | - if ( $this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS')) |
|
| 4097 | + if ($this->mail_bo->icServer->hasCapability('SUPPORTS_KEYWORDS')) |
|
| 4105 | 4098 | { |
| 4106 | - $this->statusTypes = array_merge($this->statusTypes,array( |
|
| 4107 | - 'keyword1' => 'important',//lang('important'), |
|
| 4108 | - 'keyword2' => 'job', //lang('job'), |
|
| 4109 | - 'keyword3' => 'personal',//lang('personal'), |
|
| 4110 | - 'keyword4' => 'to do', //lang('to do'), |
|
| 4111 | - 'keyword5' => 'later', //lang('later'), |
|
| 4099 | + $this->statusTypes = array_merge($this->statusTypes, array( |
|
| 4100 | + 'keyword1' => 'important', //lang('important'), |
|
| 4101 | + 'keyword2' => 'job', //lang('job'), |
|
| 4102 | + 'keyword3' => 'personal', //lang('personal'), |
|
| 4103 | + 'keyword4' => 'to do', //lang('to do'), |
|
| 4104 | + 'keyword5' => 'later', //lang('later'), |
|
| 4112 | 4105 | )); |
| 4113 | 4106 | } |
| 4114 | 4107 | else |
| 4115 | 4108 | { |
| 4116 | - $keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5'); |
|
| 4117 | - foreach($keywords as &$k) |
|
| 4109 | + $keywords = array('keyword1', 'keyword2', 'keyword3', 'keyword4', 'keyword5'); |
|
| 4110 | + foreach ($keywords as &$k) |
|
| 4118 | 4111 | { |
| 4119 | - if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]); |
|
| 4112 | + if (array_key_exists($k, $this->statusTypes)) unset($this->statusTypes[$k]); |
|
| 4120 | 4113 | } |
| 4121 | 4114 | } |
| 4122 | 4115 | |
| 4123 | 4116 | $response = egw_json_response::get(); |
| 4124 | - $response->call('app.mail.mail_refreshFilter2Options',$this->searchTypes); |
|
| 4125 | - $response->call('app.mail.mail_refreshFilterOptions',$this->statusTypes); |
|
| 4117 | + $response->call('app.mail.mail_refreshFilter2Options', $this->searchTypes); |
|
| 4118 | + $response->call('app.mail.mail_refreshFilterOptions', $this->statusTypes); |
|
| 4126 | 4119 | |
| 4127 | 4120 | } |
| 4128 | 4121 | |
@@ -4131,7 +4124,7 @@ discard block |
||
| 4131 | 4124 | * |
| 4132 | 4125 | * @return nothing |
| 4133 | 4126 | */ |
| 4134 | - function ajax_refreshQuotaDisplay($icServerID=null) |
|
| 4127 | + function ajax_refreshQuotaDisplay($icServerID = null) |
|
| 4135 | 4128 | { |
| 4136 | 4129 | //error_log(__METHOD__.__LINE__.array2string($icServerID)); |
| 4137 | 4130 | translation::add_app('mail'); |
@@ -4150,10 +4143,10 @@ discard block |
||
| 4150 | 4143 | error_log(__METHOD__.__LINE__." ".$e->getMessage()); |
| 4151 | 4144 | } |
| 4152 | 4145 | |
| 4153 | - if($quota !== false && $quota['limit'] != 'NOT SET') { |
|
| 4146 | + if ($quota !== false && $quota['limit'] != 'NOT SET') { |
|
| 4154 | 4147 | $quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']); |
| 4155 | 4148 | $content['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text']; |
| 4156 | - $content['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent']; |
|
| 4149 | + $content['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent']; |
|
| 4157 | 4150 | $content['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class']; |
| 4158 | 4151 | $content['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = ""; |
| 4159 | 4152 | } else { |
@@ -4167,7 +4160,7 @@ discard block |
||
| 4167 | 4160 | $this->changeProfile($rememberServerID); |
| 4168 | 4161 | } |
| 4169 | 4162 | $response = egw_json_response::get(); |
| 4170 | - $response->call('app.mail.mail_setQuotaDisplay',array('data'=>$content)); |
|
| 4163 | + $response->call('app.mail.mail_setQuotaDisplay', array('data'=>$content)); |
|
| 4171 | 4164 | } |
| 4172 | 4165 | |
| 4173 | 4166 | /** |
@@ -4189,34 +4182,34 @@ discard block |
||
| 4189 | 4182 | $this->changeProfile($icServerID); |
| 4190 | 4183 | } |
| 4191 | 4184 | $junkFolder = $this->mail_bo->getJunkFolder(); |
| 4192 | - if(!empty($junkFolder)) { |
|
| 4185 | + if (!empty($junkFolder)) { |
|
| 4193 | 4186 | if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder) |
| 4194 | 4187 | { |
| 4195 | 4188 | // Lock the tree if the active folder is junk folder |
| 4196 | 4189 | $response->call('app.mail.lock_tree'); |
| 4197 | 4190 | } |
| 4198 | - $this->mail_bo->deleteMessages('all',$junkFolder,'remove_immediately'); |
|
| 4191 | + $this->mail_bo->deleteMessages('all', $junkFolder, 'remove_immediately'); |
|
| 4199 | 4192 | |
| 4200 | 4193 | $heirarchyDelimeter = $this->mail_bo->getHierarchyDelimiter(true); |
| 4201 | - $fShortName = array_pop(explode($heirarchyDelimeter, $junkFolder)); |
|
| 4194 | + $fShortName = array_pop(explode($heirarchyDelimeter, $junkFolder)); |
|
| 4202 | 4195 | $fStatus = array( |
| 4203 | 4196 | $icServerID.self::$delimiter.$junkFolder => lang($fShortName) |
| 4204 | 4197 | ); |
| 4205 | 4198 | //Call to reset folder status counter, after junkFolder triggered not from Junk folder |
| 4206 | 4199 | //-as we don't have junk folder specific information available on client-side we need to deal with it on server |
| 4207 | - $response->call('app.mail.mail_setFolderStatus',$fStatus); |
|
| 4200 | + $response->call('app.mail.mail_setFolderStatus', $fStatus); |
|
| 4208 | 4201 | } |
| 4209 | 4202 | if ($rememberServerID != $this->mail_bo->profileID) |
| 4210 | 4203 | { |
| 4211 | - $oldFolderInfo = $this->mail_bo->getFolderStatus($junkFolder,false,false,false); |
|
| 4212 | - $response->call('egw.message',lang('empty junk')); |
|
| 4213 | - $response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$junkFolder=>$oldFolderInfo['shortDisplayName'])); |
|
| 4204 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($junkFolder, false, false, false); |
|
| 4205 | + $response->call('egw.message', lang('empty junk')); |
|
| 4206 | + $response->call('app.mail.mail_reloadNode', array($icServerID.self::$delimiter.$junkFolder=>$oldFolderInfo['shortDisplayName'])); |
|
| 4214 | 4207 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID); |
| 4215 | 4208 | $this->changeProfile($rememberServerID); |
| 4216 | 4209 | } |
| 4217 | 4210 | else if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder) |
| 4218 | 4211 | { |
| 4219 | - $response->call('egw.refresh',lang('empty junk'),'mail'); |
|
| 4212 | + $response->call('egw.refresh', lang('empty junk'), 'mail'); |
|
| 4220 | 4213 | } |
| 4221 | 4214 | } |
| 4222 | 4215 | |
@@ -4239,7 +4232,7 @@ discard block |
||
| 4239 | 4232 | $this->changeProfile($icServerID); |
| 4240 | 4233 | } |
| 4241 | 4234 | $trashFolder = $this->mail_bo->getTrashFolder(); |
| 4242 | - if(!empty($trashFolder)) { |
|
| 4235 | + if (!empty($trashFolder)) { |
|
| 4243 | 4236 | if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder) |
| 4244 | 4237 | { |
| 4245 | 4238 | // Lock the tree if the active folder is Trash folder |
@@ -4248,25 +4241,25 @@ discard block |
||
| 4248 | 4241 | $this->mail_bo->compressFolder($trashFolder); |
| 4249 | 4242 | |
| 4250 | 4243 | $heirarchyDelimeter = $this->mail_bo->getHierarchyDelimiter(true); |
| 4251 | - $fShortName = array_pop(explode($heirarchyDelimeter, $trashFolder)); |
|
| 4244 | + $fShortName = array_pop(explode($heirarchyDelimeter, $trashFolder)); |
|
| 4252 | 4245 | $fStatus = array( |
| 4253 | 4246 | $icServerID.self::$delimiter.$trashFolder => lang($fShortName) |
| 4254 | 4247 | ); |
| 4255 | 4248 | //Call to reset folder status counter, after emptyTrash triggered not from Trash folder |
| 4256 | 4249 | //-as we don't have trash folder specific information available on client-side we need to deal with it on server |
| 4257 | - $response->call('app.mail.mail_setFolderStatus',$fStatus); |
|
| 4250 | + $response->call('app.mail.mail_setFolderStatus', $fStatus); |
|
| 4258 | 4251 | } |
| 4259 | 4252 | if ($rememberServerID != $this->mail_bo->profileID) |
| 4260 | 4253 | { |
| 4261 | - $oldFolderInfo = $this->mail_bo->getFolderStatus($trashFolder,false,false,false); |
|
| 4262 | - $response->call('egw.message',lang('empty trash')); |
|
| 4263 | - $response->call('app.mail.mail_reloadNode',array($icServerID.self::$delimiter.$trashFolder=>$oldFolderInfo['shortDisplayName'])); |
|
| 4254 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($trashFolder, false, false, false); |
|
| 4255 | + $response->call('egw.message', lang('empty trash')); |
|
| 4256 | + $response->call('app.mail.mail_reloadNode', array($icServerID.self::$delimiter.$trashFolder=>$oldFolderInfo['shortDisplayName'])); |
|
| 4264 | 4257 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$rememberServerID); |
| 4265 | 4258 | $this->changeProfile($rememberServerID); |
| 4266 | 4259 | } |
| 4267 | 4260 | else if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder) |
| 4268 | 4261 | { |
| 4269 | - $response->call('egw.refresh',lang('empty trash'),'mail'); |
|
| 4262 | + $response->call('egw.refresh', lang('empty trash'), 'mail'); |
|
| 4270 | 4263 | } |
| 4271 | 4264 | } |
| 4272 | 4265 | |
@@ -4283,7 +4276,7 @@ discard block |
||
| 4283 | 4276 | |
| 4284 | 4277 | $this->mail_bo->restoreSessionData(); |
| 4285 | 4278 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 4286 | - list($icServerID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
|
| 4279 | + list($icServerID, $folderName) = explode(self::$delimiter, $decodedFolderName, 2); |
|
| 4287 | 4280 | |
| 4288 | 4281 | if (empty($folderName)) $folderName = $this->mail_bo->sessionData['mailbox']; |
| 4289 | 4282 | if ($this->mail_bo->folderExists($folderName)) |
@@ -4294,7 +4287,7 @@ discard block |
||
| 4294 | 4287 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
| 4295 | 4288 | $this->changeProfile($icServerID); |
| 4296 | 4289 | } |
| 4297 | - if(!empty($_folderName)) { |
|
| 4290 | + if (!empty($_folderName)) { |
|
| 4298 | 4291 | $this->mail_bo->compressFolder($folderName); |
| 4299 | 4292 | } |
| 4300 | 4293 | if ($rememberServerID != $this->mail_bo->profileID) |
@@ -4303,7 +4296,7 @@ discard block |
||
| 4303 | 4296 | $this->changeProfile($rememberServerID); |
| 4304 | 4297 | } |
| 4305 | 4298 | $response = egw_json_response::get(); |
| 4306 | - $response->call('egw.refresh',lang('compress folder').': '.$folderName,'mail'); |
|
| 4299 | + $response->call('egw.refresh', lang('compress folder').': '.$folderName, 'mail'); |
|
| 4307 | 4300 | } |
| 4308 | 4301 | } |
| 4309 | 4302 | |
@@ -4316,10 +4309,10 @@ discard block |
||
| 4316 | 4309 | */ |
| 4317 | 4310 | function ajax_sendMDN($_messageList) |
| 4318 | 4311 | { |
| 4319 | - if(mail_bo::$debug) error_log(__METHOD__."->".array2string($_messageList)); |
|
| 4312 | + if (mail_bo::$debug) error_log(__METHOD__."->".array2string($_messageList)); |
|
| 4320 | 4313 | $uidA = self::splitRowID($_messageList['msg'][0]); |
| 4321 | 4314 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
| 4322 | - $this->mail_bo->sendMDN($uidA['msgUID'],$folder); |
|
| 4315 | + $this->mail_bo->sendMDN($uidA['msgUID'], $folder); |
|
| 4323 | 4316 | } |
| 4324 | 4317 | |
| 4325 | 4318 | /** |
@@ -4331,14 +4324,14 @@ discard block |
||
| 4331 | 4324 | * |
| 4332 | 4325 | * @return xajax response |
| 4333 | 4326 | */ |
| 4334 | - function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse=true) |
|
| 4327 | + function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse = true) |
|
| 4335 | 4328 | { |
| 4336 | - if(mail_bo::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList)); |
|
| 4329 | + if (mail_bo::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList)); |
|
| 4337 | 4330 | translation::add_app('mail'); |
| 4338 | - $alreadyFlagged=false; |
|
| 4339 | - $flag2check=''; |
|
| 4331 | + $alreadyFlagged = false; |
|
| 4332 | + $flag2check = ''; |
|
| 4340 | 4333 | $filter2toggle = $query = array(); |
| 4341 | - if ($_messageList=='all' || !empty($_messageList['msg'])) |
|
| 4334 | + if ($_messageList == 'all' || !empty($_messageList['msg'])) |
|
| 4342 | 4335 | { |
| 4343 | 4336 | if (isset($_messageList['all']) && $_messageList['all']) |
| 4344 | 4337 | { |
@@ -4353,10 +4346,10 @@ discard block |
||
| 4353 | 4346 | //([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any |
| 4354 | 4347 | if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) |
| 4355 | 4348 | { |
| 4356 | - emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
|
| 4357 | - if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 4349 | + emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 4350 | + if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID] = true; |
|
| 4358 | 4351 | } |
| 4359 | - $filter = $filter2toggle = array('filterName' => (emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?lang('quicksearch'):lang('subject')),'type' => ($query['filter2']?$query['filter2']:(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject')),'string' => $query['search'],'status' => 'any'); |
|
| 4352 | + $filter = $filter2toggle = array('filterName' => (emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID] ? lang('quicksearch') : lang('subject')), 'type' => ($query['filter2'] ? $query['filter2'] : (emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID] ? 'quick' : 'subject')), 'string' => $query['search'], 'status' => 'any'); |
|
| 4360 | 4353 | } |
| 4361 | 4354 | else |
| 4362 | 4355 | { |
@@ -4365,70 +4358,70 @@ discard block |
||
| 4365 | 4358 | // flags read,flagged,label1,label2,label3,label4,label5 can be toggled: handle this when all mails in a folder |
| 4366 | 4359 | // should be affected serverside. here. |
| 4367 | 4360 | $messageList = $messageListForToggle = array(); |
| 4368 | - $flag2check = ($_flag=='read'?'seen':$_flag); |
|
| 4369 | - if (in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) && |
|
| 4370 | - !($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false)) |
|
| 4361 | + $flag2check = ($_flag == 'read' ? 'seen' : $_flag); |
|
| 4362 | + if (in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) && |
|
| 4363 | + !($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false)) |
|
| 4371 | 4364 | { |
| 4372 | 4365 | $filter2toggle['status'] = array('un'.$_flag); |
| 4373 | - if ($query['filter'] && $query['filter']!='any') |
|
| 4366 | + if ($query['filter'] && $query['filter'] != 'any') |
|
| 4374 | 4367 | { |
| 4375 | 4368 | $filter2toggle['status'][] = $query['filter']; |
| 4376 | 4369 | } |
| 4377 | 4370 | $_sRt = $this->mail_bo->getSortedList( |
| 4378 | 4371 | $folder, |
| 4379 | - $sort=0, |
|
| 4380 | - $reverse=1, |
|
| 4372 | + $sort = 0, |
|
| 4373 | + $reverse = 1, |
|
| 4381 | 4374 | $filter2toggle, |
| 4382 | - $rByUid=true, |
|
| 4375 | + $rByUid = true, |
|
| 4383 | 4376 | false |
| 4384 | 4377 | ); |
| 4385 | 4378 | $messageListForToggle = $_sRt['match']->ids; |
| 4386 | 4379 | $filter['status'] = array($_flag); |
| 4387 | - if ($query['filter'] && $query['filter'] !='any') |
|
| 4380 | + if ($query['filter'] && $query['filter'] != 'any') |
|
| 4388 | 4381 | { |
| 4389 | 4382 | $filter['status'][] = $query['filter']; |
| 4390 | 4383 | } |
| 4391 | 4384 | $_sR = $this->mail_bo->getSortedList( |
| 4392 | 4385 | $folder, |
| 4393 | - $sort=0, |
|
| 4394 | - $reverse=1, |
|
| 4386 | + $sort = 0, |
|
| 4387 | + $reverse = 1, |
|
| 4395 | 4388 | $filter, |
| 4396 | - $rByUid=true, |
|
| 4389 | + $rByUid = true, |
|
| 4397 | 4390 | false |
| 4398 | 4391 | ); |
| 4399 | 4392 | $messageList = $_sR['match']->ids; |
| 4400 | - if (count($messageListForToggle)>0) |
|
| 4393 | + if (count($messageListForToggle) > 0) |
|
| 4401 | 4394 | { |
| 4402 | 4395 | $flag2set = (strtolower($_flag)); |
| 4403 | - if(mail_bo::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle)); |
|
| 4404 | - $this->mail_bo->flagMessages($flag2set, $messageListForToggle,$folder); |
|
| 4396 | + if (mail_bo::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle)); |
|
| 4397 | + $this->mail_bo->flagMessages($flag2set, $messageListForToggle, $folder); |
|
| 4405 | 4398 | } |
| 4406 | - if (count($messageList)>0) |
|
| 4399 | + if (count($messageList) > 0) |
|
| 4407 | 4400 | { |
| 4408 | 4401 | $flag2set = 'un'.$_flag; |
| 4409 | - if(mail_bo::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList)); |
|
| 4410 | - $this->mail_bo->flagMessages($flag2set, $messageList,$folder); |
|
| 4402 | + if (mail_bo::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList)); |
|
| 4403 | + $this->mail_bo->flagMessages($flag2set, $messageList, $folder); |
|
| 4411 | 4404 | } |
| 4412 | - $alreadyFlagged=true; |
|
| 4405 | + $alreadyFlagged = true; |
|
| 4413 | 4406 | } |
| 4414 | 4407 | elseif (!empty($filter) && |
| 4415 | - (!in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) || |
|
| 4416 | - (in_array($_flag,array('read','flagged','label1','label2','label3','label4','label5')) && |
|
| 4417 | - ($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false)))) |
|
| 4408 | + (!in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) || |
|
| 4409 | + (in_array($_flag, array('read', 'flagged', 'label1', 'label2', 'label3', 'label4', 'label5')) && |
|
| 4410 | + ($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false)))) |
|
| 4418 | 4411 | { |
| 4419 | - if ($query['filter'] && $query['filter'] !='any') |
|
| 4412 | + if ($query['filter'] && $query['filter'] != 'any') |
|
| 4420 | 4413 | { |
| 4421 | 4414 | $filter['status'] = $query['filter']; |
| 4422 | 4415 | // since we toggle and we toggle by the filtered flag we must must change _flag |
| 4423 | - $_flag = ($query['filter']=='unseen' && $_flag=='read' ? 'read' : ($query['filter']=='seen'&& $_flag=='read'?'unread':($_flag==$query['filter']?'un'.$_flag:$_flag))); |
|
| 4416 | + $_flag = ($query['filter'] == 'unseen' && $_flag == 'read' ? 'read' : ($query['filter'] == 'seen' && $_flag == 'read' ? 'unread' : ($_flag == $query['filter'] ? 'un'.$_flag : $_flag))); |
|
| 4424 | 4417 | } |
| 4425 | - if(mail_bo::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter)); |
|
| 4418 | + if (mail_bo::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter)); |
|
| 4426 | 4419 | $_sR = $this->mail_bo->getSortedList( |
| 4427 | 4420 | $folder, |
| 4428 | - $sort=0, |
|
| 4429 | - $reverse=1, |
|
| 4421 | + $sort = 0, |
|
| 4422 | + $reverse = 1, |
|
| 4430 | 4423 | $filter, |
| 4431 | - $rByUid=true, |
|
| 4424 | + $rByUid = true, |
|
| 4432 | 4425 | false |
| 4433 | 4426 | ); |
| 4434 | 4427 | $messageList = $_sR['match']->ids; |
@@ -4437,8 +4430,8 @@ discard block |
||
| 4437 | 4430 | } |
| 4438 | 4431 | else |
| 4439 | 4432 | { |
| 4440 | - if(mail_bo::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter)); |
|
| 4441 | - $alreadyFlagged=true; |
|
| 4433 | + if (mail_bo::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter)); |
|
| 4434 | + $alreadyFlagged = true; |
|
| 4442 | 4435 | $uidA = self::splitRowID($_messageList['msg'][0]); |
| 4443 | 4436 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
| 4444 | 4437 | $this->mail_bo->flagMessages($_flag, 'all', $folder); |
@@ -4452,41 +4445,41 @@ discard block |
||
| 4452 | 4445 | } |
| 4453 | 4446 | if (!$alreadyFlagged) |
| 4454 | 4447 | { |
| 4455 | - foreach($_messageList['msg'] as $rowID) |
|
| 4448 | + foreach ($_messageList['msg'] as $rowID) |
|
| 4456 | 4449 | { |
| 4457 | 4450 | $hA = self::splitRowID($rowID); |
| 4458 | 4451 | $messageList[] = $hA['msgUID']; |
| 4459 | 4452 | } |
| 4460 | - if(mail_bo::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList))); |
|
| 4461 | - $this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList),$folder); |
|
| 4453 | + if (mail_bo::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all' : $messageList))); |
|
| 4454 | + $this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all' : $messageList), $folder); |
|
| 4462 | 4455 | } |
| 4463 | 4456 | } |
| 4464 | 4457 | else |
| 4465 | 4458 | { |
| 4466 | - if(mail_bo::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 4459 | + if (mail_bo::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 4467 | 4460 | } |
| 4468 | 4461 | |
| 4469 | 4462 | if ($_sendJsonResponse) |
| 4470 | 4463 | { |
| 4471 | - $flag=array( |
|
| 4472 | - 'label1' => 'important',//lang('important'), |
|
| 4473 | - 'label2' => 'job', //lang('job'), |
|
| 4474 | - 'label3' => 'personal',//lang('personal'), |
|
| 4475 | - 'label4' => 'to do', //lang('to do'), |
|
| 4476 | - 'label5' => 'later', //lang('later'), |
|
| 4464 | + $flag = array( |
|
| 4465 | + 'label1' => 'important', //lang('important'), |
|
| 4466 | + 'label2' => 'job', //lang('job'), |
|
| 4467 | + 'label3' => 'personal', //lang('personal'), |
|
| 4468 | + 'label4' => 'to do', //lang('to do'), |
|
| 4469 | + 'label5' => 'later', //lang('later'), |
|
| 4477 | 4470 | ); |
| 4478 | 4471 | $response = egw_json_response::get(); |
| 4479 | 4472 | if (isset($_messageList['msg']) && $_messageList['popup']) |
| 4480 | 4473 | { |
| 4481 | - $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'); |
|
| 4474 | + $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'); |
|
| 4482 | 4475 | } |
| 4483 | - else if ((isset($_messageList['all']) && $_messageList['all']) || ($query['filter'] && ($flag2check==$query['filter'] || stripos($query['filter'],$flag2check)!==false))) |
|
| 4476 | + else if ((isset($_messageList['all']) && $_messageList['all']) || ($query['filter'] && ($flag2check == $query['filter'] || stripos($query['filter'], $flag2check) !== false))) |
|
| 4484 | 4477 | { |
| 4485 | - $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'); |
|
| 4478 | + $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'); |
|
| 4486 | 4479 | } |
| 4487 | 4480 | else |
| 4488 | 4481 | { |
| 4489 | - $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)); |
|
| 4482 | + $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)); |
|
| 4490 | 4483 | } |
| 4491 | 4484 | } |
| 4492 | 4485 | } |
@@ -4498,12 +4491,12 @@ discard block |
||
| 4498 | 4491 | * @param string _forceDeleteMethod - method of deletion to be enforced |
| 4499 | 4492 | * @return xajax response |
| 4500 | 4493 | */ |
| 4501 | - function ajax_deleteMessages($_messageList,$_forceDeleteMethod=null) |
|
| 4494 | + function ajax_deleteMessages($_messageList, $_forceDeleteMethod = null) |
|
| 4502 | 4495 | { |
| 4503 | - if(mail_bo::$debug) error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod); |
|
| 4496 | + if (mail_bo::$debug) error_log(__METHOD__."->".print_r($_messageList, true).' Method:'.$_forceDeleteMethod); |
|
| 4504 | 4497 | $error = null; |
| 4505 | - $filtered = false; |
|
| 4506 | - if ($_messageList=='all' || !empty($_messageList['msg'])) |
|
| 4498 | + $filtered = false; |
|
| 4499 | + if ($_messageList == 'all' || !empty($_messageList['msg'])) |
|
| 4507 | 4500 | { |
| 4508 | 4501 | if (isset($_messageList['all']) && $_messageList['all']) |
| 4509 | 4502 | { |
@@ -4518,11 +4511,11 @@ discard block |
||
| 4518 | 4511 | //([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any |
| 4519 | 4512 | if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) |
| 4520 | 4513 | { |
| 4521 | - emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
|
| 4522 | - if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 4514 | + emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 4515 | + if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID] = true; |
|
| 4523 | 4516 | } |
| 4524 | - $filtered = true; |
|
| 4525 | - $filter = array('filterName' => (emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?lang('quicksearch'):lang('subject')),'type' => ($query['filter2']?$query['filter2']:(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject')),'string' => $query['search'],'status' => (!empty($query['filter'])?$query['filter']:'any')); |
|
| 4517 | + $filtered = true; |
|
| 4518 | + $filter = array('filterName' => (emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID] ? lang('quicksearch') : lang('subject')), 'type' => ($query['filter2'] ? $query['filter2'] : (emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID] ? 'quick' : 'subject')), 'string' => $query['search'], 'status' => (!empty($query['filter']) ? $query['filter'] : 'any')); |
|
| 4526 | 4519 | } |
| 4527 | 4520 | else |
| 4528 | 4521 | { |
@@ -4534,7 +4527,7 @@ discard block |
||
| 4534 | 4527 | $rByUid = true; |
| 4535 | 4528 | $_sR = $this->mail_bo->getSortedList( |
| 4536 | 4529 | $folder, |
| 4537 | - $sort=0, |
|
| 4530 | + $sort = 0, |
|
| 4538 | 4531 | $reverse, |
| 4539 | 4532 | $filter, |
| 4540 | 4533 | $rByUid, |
@@ -4544,23 +4537,23 @@ discard block |
||
| 4544 | 4537 | } |
| 4545 | 4538 | else |
| 4546 | 4539 | { |
| 4547 | - $messageList='all'; |
|
| 4540 | + $messageList = 'all'; |
|
| 4548 | 4541 | } |
| 4549 | 4542 | try |
| 4550 | 4543 | { |
| 4551 | 4544 | //error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod); |
| 4552 | - $this->mail_bo->deleteMessages(($messageList=='all' ? 'all':$messageList),$folder,(empty($_forceDeleteMethod)?'no':$_forceDeleteMethod)); |
|
| 4545 | + $this->mail_bo->deleteMessages(($messageList == 'all' ? 'all' : $messageList), $folder, (empty($_forceDeleteMethod) ? 'no' : $_forceDeleteMethod)); |
|
| 4553 | 4546 | } |
| 4554 | 4547 | catch (egw_exception $e) |
| 4555 | 4548 | { |
| 4556 | - $error = str_replace('"',"'",$e->getMessage()); |
|
| 4549 | + $error = str_replace('"', "'", $e->getMessage()); |
|
| 4557 | 4550 | } |
| 4558 | 4551 | } |
| 4559 | 4552 | else |
| 4560 | 4553 | { |
| 4561 | 4554 | $uidA = self::splitRowID($_messageList['msg'][0]); |
| 4562 | 4555 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
| 4563 | - foreach($_messageList['msg'] as $rowID) |
|
| 4556 | + foreach ($_messageList['msg'] as $rowID) |
|
| 4564 | 4557 | { |
| 4565 | 4558 | $hA = self::splitRowID($rowID); |
| 4566 | 4559 | $messageList[] = $hA['msgUID']; |
@@ -4568,27 +4561,27 @@ discard block |
||
| 4568 | 4561 | try |
| 4569 | 4562 | { |
| 4570 | 4563 | //error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod); |
| 4571 | - $this->mail_bo->deleteMessages($messageList,$folder,(empty($_forceDeleteMethod)?'no':$_forceDeleteMethod)); |
|
| 4564 | + $this->mail_bo->deleteMessages($messageList, $folder, (empty($_forceDeleteMethod) ? 'no' : $_forceDeleteMethod)); |
|
| 4572 | 4565 | } |
| 4573 | 4566 | catch (egw_exception $e) |
| 4574 | 4567 | { |
| 4575 | - $error = str_replace('"',"'",$e->getMessage()); |
|
| 4568 | + $error = str_replace('"', "'", $e->getMessage()); |
|
| 4576 | 4569 | } |
| 4577 | 4570 | } |
| 4578 | 4571 | $response = egw_json_response::get(); |
| 4579 | 4572 | if (empty($error)) |
| 4580 | 4573 | { |
| 4581 | - $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'])); |
|
| 4574 | + $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'])); |
|
| 4582 | 4575 | } |
| 4583 | 4576 | else |
| 4584 | 4577 | { |
| 4585 | - $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)); |
|
| 4586 | - $response->call('app.mail.mail_retryForcedDelete',array('response'=>$error,'messageList'=>$_messageList)); |
|
| 4578 | + $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)); |
|
| 4579 | + $response->call('app.mail.mail_retryForcedDelete', array('response'=>$error, 'messageList'=>$_messageList)); |
|
| 4587 | 4580 | } |
| 4588 | 4581 | } |
| 4589 | 4582 | else |
| 4590 | 4583 | { |
| 4591 | - if(mail_bo::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 4584 | + if (mail_bo::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 4592 | 4585 | } |
| 4593 | 4586 | } |
| 4594 | 4587 | |
@@ -4601,35 +4594,35 @@ discard block |
||
| 4601 | 4594 | * |
| 4602 | 4595 | * @return xajax response |
| 4603 | 4596 | */ |
| 4604 | - function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove='copy') |
|
| 4597 | + function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove = 'copy') |
|
| 4605 | 4598 | { |
| 4606 | - if(mail_bo::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove); |
|
| 4599 | + if (mail_bo::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList, true).' Method:'.$_copyOrMove); |
|
| 4607 | 4600 | translation::add_app('mail'); |
| 4608 | 4601 | $_folderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 4609 | 4602 | // only copy or move are supported as method |
| 4610 | - if (!($_copyOrMove=='copy' || $_copyOrMove=='move')) $_copyOrMove='copy'; |
|
| 4611 | - list($targetProfileID,$targetFolder) = explode(self::$delimiter,$_folderName,2); |
|
| 4612 | - $lastFoldersUsedForMoveCont = egw_cache::getCache(egw_cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1); |
|
| 4603 | + if (!($_copyOrMove == 'copy' || $_copyOrMove == 'move')) $_copyOrMove = 'copy'; |
|
| 4604 | + list($targetProfileID, $targetFolder) = explode(self::$delimiter, $_folderName, 2); |
|
| 4605 | + $lastFoldersUsedForMoveCont = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 1); |
|
| 4613 | 4606 | $changeFolderActions = false; |
| 4614 | 4607 | if (!isset($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder])) |
| 4615 | 4608 | { |
| 4616 | - if ($lastFoldersUsedForMoveCont[$targetProfileID] && count($lastFoldersUsedForMoveCont[$targetProfileID])>3) |
|
| 4609 | + if ($lastFoldersUsedForMoveCont[$targetProfileID] && count($lastFoldersUsedForMoveCont[$targetProfileID]) > 3) |
|
| 4617 | 4610 | { |
| 4618 | 4611 | $keys = array_keys($lastFoldersUsedForMoveCont[$targetProfileID]); |
| 4619 | - foreach( $keys as &$f) |
|
| 4612 | + foreach ($keys as &$f) |
|
| 4620 | 4613 | { |
| 4621 | - if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]); |
|
| 4614 | + if (count($lastFoldersUsedForMoveCont[$targetProfileID]) > 9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]); |
|
| 4622 | 4615 | else break; |
| 4623 | 4616 | } |
| 4624 | 4617 | //error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID])); |
| 4625 | 4618 | } |
| 4626 | - $lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]=$_folderName; |
|
| 4619 | + $lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder] = $_folderName; |
|
| 4627 | 4620 | $changeFolderActions = true; |
| 4628 | 4621 | } |
| 4629 | 4622 | $filtered = false; |
| 4630 | - if ($_messageList=='all' || !empty($_messageList['msg'])) |
|
| 4623 | + if ($_messageList == 'all' || !empty($_messageList['msg'])) |
|
| 4631 | 4624 | { |
| 4632 | - $error=false; |
|
| 4625 | + $error = false; |
|
| 4633 | 4626 | if (isset($_messageList['all']) && $_messageList['all']) |
| 4634 | 4627 | { |
| 4635 | 4628 | // we have both messageIds AND allFlag folder information |
@@ -4644,11 +4637,11 @@ discard block |
||
| 4644 | 4637 | //([filterName] => Schnellsuche[type] => quick[string] => ebay[status] => any |
| 4645 | 4638 | if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) |
| 4646 | 4639 | { |
| 4647 | - emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
|
| 4648 | - if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 4640 | + emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60 * 60 * 10); |
|
| 4641 | + if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID] = true; |
|
| 4649 | 4642 | } |
| 4650 | 4643 | $filtered = true; |
| 4651 | - $filter = array('filterName' => (emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?lang('quicksearch'):lang('subject')),'type' => ($query['filter2']?$query['filter2']:(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject')),'string' => $query['search'],'status' => (!empty($query['filter'])?$query['filter']:'any')); |
|
| 4644 | + $filter = array('filterName' => (emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID] ? lang('quicksearch') : lang('subject')), 'type' => ($query['filter2'] ? $query['filter2'] : (emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID] ? 'quick' : 'subject')), 'string' => $query['search'], 'status' => (!empty($query['filter']) ? $query['filter'] : 'any')); |
|
| 4652 | 4645 | } |
| 4653 | 4646 | else |
| 4654 | 4647 | { |
@@ -4659,70 +4652,70 @@ discard block |
||
| 4659 | 4652 | $rByUid = true; |
| 4660 | 4653 | $_sR = $this->mail_bo->getSortedList( |
| 4661 | 4654 | $folder, |
| 4662 | - $sort=0, |
|
| 4655 | + $sort = 0, |
|
| 4663 | 4656 | $reverse, |
| 4664 | 4657 | $filter, |
| 4665 | - $rByUid=true, |
|
| 4658 | + $rByUid = true, |
|
| 4666 | 4659 | false |
| 4667 | 4660 | ); |
| 4668 | 4661 | $messageList = $_sR['match']->ids; |
| 4669 | - foreach($messageList as $uID) |
|
| 4662 | + foreach ($messageList as $uID) |
|
| 4670 | 4663 | { |
| 4671 | 4664 | //error_log(__METHOD__.__LINE__.$uID); |
| 4672 | - if ($_copyOrMove=='move') |
|
| 4665 | + if ($_copyOrMove == 'move') |
|
| 4673 | 4666 | { |
| 4674 | - $messageListForRefresh[] = self::generateRowID($sourceProfileID, $_folderName, $uID, $_prependApp=false); |
|
| 4667 | + $messageListForRefresh[] = self::generateRowID($sourceProfileID, $_folderName, $uID, $_prependApp = false); |
|
| 4675 | 4668 | } |
| 4676 | 4669 | } |
| 4677 | 4670 | } |
| 4678 | 4671 | else |
| 4679 | 4672 | { |
| 4680 | - $messageList='all'; |
|
| 4673 | + $messageList = 'all'; |
|
| 4681 | 4674 | } |
| 4682 | 4675 | try |
| 4683 | 4676 | { |
| 4684 | 4677 | //error_log(__METHOD__.__LINE__."->".print_r($messageList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod.' '.$targetProfileID.'/'.$sourceProfileID); |
| 4685 | - $this->mail_bo->moveMessages($targetFolder,$messageList,($_copyOrMove=='copy'?false:true),$folder,false,$sourceProfileID,($targetProfileID!=$sourceProfileID?$targetProfileID:null)); |
|
| 4678 | + $this->mail_bo->moveMessages($targetFolder, $messageList, ($_copyOrMove == 'copy' ? false : true), $folder, false, $sourceProfileID, ($targetProfileID != $sourceProfileID ? $targetProfileID : null)); |
|
| 4686 | 4679 | } |
| 4687 | 4680 | catch (egw_exception $e) |
| 4688 | 4681 | { |
| 4689 | - $error = str_replace('"',"'",$e->getMessage()); |
|
| 4682 | + $error = str_replace('"', "'", $e->getMessage()); |
|
| 4690 | 4683 | } |
| 4691 | 4684 | } |
| 4692 | 4685 | else |
| 4693 | 4686 | { |
| 4694 | 4687 | $messageList = array(); |
| 4695 | - while(count($_messageList['msg']) > 0) |
|
| 4688 | + while (count($_messageList['msg']) > 0) |
|
| 4696 | 4689 | { |
| 4697 | 4690 | $uidA = self::splitRowID($_messageList['msg'][0]); |
| 4698 | 4691 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
| 4699 | 4692 | $sourceProfileID = $uidA['profileID']; |
| 4700 | 4693 | $moveList = array(); |
| 4701 | - foreach($_messageList['msg'] as $rowID) |
|
| 4694 | + foreach ($_messageList['msg'] as $rowID) |
|
| 4702 | 4695 | { |
| 4703 | 4696 | $hA = self::splitRowID($rowID); |
| 4704 | 4697 | |
| 4705 | 4698 | // If folder changes, stop and move what we've got |
| 4706 | - if($hA['folder'] != $folder) break; |
|
| 4699 | + if ($hA['folder'] != $folder) break; |
|
| 4707 | 4700 | |
| 4708 | 4701 | array_shift($_messageList['msg']); |
| 4709 | 4702 | $messageList[] = $hA['msgUID']; |
| 4710 | 4703 | $moveList[] = $hA['msgUID']; |
| 4711 | - if ($_copyOrMove=='move') |
|
| 4704 | + if ($_copyOrMove == 'move') |
|
| 4712 | 4705 | { |
| 4713 | - $helpvar = explode(self::$delimiter,$rowID); |
|
| 4706 | + $helpvar = explode(self::$delimiter, $rowID); |
|
| 4714 | 4707 | array_shift($helpvar); |
| 4715 | - $messageListForRefresh[]= implode(self::$delimiter,$helpvar); |
|
| 4708 | + $messageListForRefresh[] = implode(self::$delimiter, $helpvar); |
|
| 4716 | 4709 | } |
| 4717 | 4710 | } |
| 4718 | 4711 | try |
| 4719 | 4712 | { |
| 4720 | 4713 | //error_log(__METHOD__.__LINE__."->".print_r($moveList,true).' folder:'.$folder.' Method:'.$_forceDeleteMethod.' '.$targetProfileID.'/'.$sourceProfileID); |
| 4721 | - $this->mail_bo->moveMessages($targetFolder,$moveList,($_copyOrMove=='copy'?false:true),$folder,false,$sourceProfileID,($targetProfileID!=$sourceProfileID?$targetProfileID:null)); |
|
| 4714 | + $this->mail_bo->moveMessages($targetFolder, $moveList, ($_copyOrMove == 'copy' ? false : true), $folder, false, $sourceProfileID, ($targetProfileID != $sourceProfileID ? $targetProfileID : null)); |
|
| 4722 | 4715 | } |
| 4723 | 4716 | catch (egw_exception $e) |
| 4724 | 4717 | { |
| 4725 | - $error = str_replace('"',"'",$e->getMessage()); |
|
| 4718 | + $error = str_replace('"', "'", $e->getMessage()); |
|
| 4726 | 4719 | } |
| 4727 | 4720 | } |
| 4728 | 4721 | } |
@@ -4735,30 +4728,30 @@ discard block |
||
| 4735 | 4728 | unset($lastFoldersUsedForMoveCont[$targetProfileID][$targetFolder]); |
| 4736 | 4729 | $changeFolderActions = true; |
| 4737 | 4730 | } |
| 4738 | - $response->call('egw.message',$error,"error"); |
|
| 4731 | + $response->call('egw.message', $error, "error"); |
|
| 4739 | 4732 | } |
| 4740 | 4733 | else |
| 4741 | 4734 | { |
| 4742 | - if ($_copyOrMove=='copy') |
|
| 4735 | + if ($_copyOrMove == 'copy') |
|
| 4743 | 4736 | { |
| 4744 | - $response->call('egw.message',lang('copied %1 message(s) from %2 to %3',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($messageList)),$folder,$targetFolder)); |
|
| 4737 | + $response->call('egw.message', lang('copied %1 message(s) from %2 to %3', ($messageList == 'all' || $_messageList['all'] ? ($filtered ? lang('all filtered') : lang('all')) : count($messageList)), $folder, $targetFolder)); |
|
| 4745 | 4738 | } |
| 4746 | 4739 | else |
| 4747 | 4740 | { |
| 4748 | - $response->call('egw.refresh',lang('moved %1 message(s) from %2 to %3',($messageList=='all'||$_messageList['all']?($filtered?lang('all filtered'):lang('all')):count($messageList)),$folder,$targetFolder),'mail',$messageListForRefresh,'delete'); |
|
| 4741 | + $response->call('egw.refresh', lang('moved %1 message(s) from %2 to %3', ($messageList == 'all' || $_messageList['all'] ? ($filtered ? lang('all filtered') : lang('all')) : count($messageList)), $folder, $targetFolder), 'mail', $messageListForRefresh, 'delete'); |
|
| 4749 | 4742 | } |
| 4750 | 4743 | } |
| 4751 | 4744 | if ($changeFolderActions == true) |
| 4752 | 4745 | { |
| 4753 | - egw_cache::setCache(egw_cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),$lastFoldersUsedForMoveCont, $expiration=60*60*1); |
|
| 4746 | + egw_cache::setCache(egw_cache::INSTANCE, 'email', 'lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']), $lastFoldersUsedForMoveCont, $expiration = 60 * 60 * 1); |
|
| 4754 | 4747 | $actionsnew = self::get_actions(); |
| 4755 | 4748 | $actionsnew = etemplate_widget_nextmatch::egw_actions($actionsnew); |
| 4756 | - $response->call('app.mail.mail_rebuildActionsOnList',$actionsnew); |
|
| 4749 | + $response->call('app.mail.mail_rebuildActionsOnList', $actionsnew); |
|
| 4757 | 4750 | } |
| 4758 | 4751 | } |
| 4759 | 4752 | else |
| 4760 | 4753 | { |
| 4761 | - if(mail_bo::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 4754 | + if (mail_bo::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 4762 | 4755 | } |
| 4763 | 4756 | } |
| 4764 | 4757 | |
@@ -4768,11 +4761,11 @@ discard block |
||
| 4768 | 4761 | * |
| 4769 | 4762 | * @param type $_id |
| 4770 | 4763 | */ |
| 4771 | - function ajax_folderMgmtTree_autoloading ($_id = null) |
|
| 4764 | + function ajax_folderMgmtTree_autoloading($_id = null) |
|
| 4772 | 4765 | { |
| 4773 | 4766 | $mail_ui = new mail_ui(); |
| 4774 | - $_id = $_id? $_id:$_GET['id']; |
|
| 4775 | - etemplate_widget_tree::send_quote_json($mail_ui->mail_tree->getTree($_id,'',1,true,false,false,false)); |
|
| 4767 | + $_id = $_id ? $_id : $_GET['id']; |
|
| 4768 | + etemplate_widget_tree::send_quote_json($mail_ui->mail_tree->getTree($_id, '', 1, true, false, false, false)); |
|
| 4776 | 4769 | } |
| 4777 | 4770 | |
| 4778 | 4771 | /** |
@@ -4780,15 +4773,15 @@ discard block |
||
| 4780 | 4773 | * |
| 4781 | 4774 | * @param array $content content of dialog |
| 4782 | 4775 | */ |
| 4783 | - function folderManagement (array $content = null) |
|
| 4776 | + function folderManagement(array $content = null) |
|
| 4784 | 4777 | { |
| 4785 | 4778 | $dtmpl = new etemplate_new('mail.folder_management'); |
| 4786 | - $profileID = $_GET['acc_id']? $_GET['acc_id']: $content['acc_id']; |
|
| 4787 | - $sel_options['tree'] = $this->mail_tree->getTree(null,$profileID, 1, true, false, false); |
|
| 4779 | + $profileID = $_GET['acc_id'] ? $_GET['acc_id'] : $content['acc_id']; |
|
| 4780 | + $sel_options['tree'] = $this->mail_tree->getTree(null, $profileID, 1, true, false, false); |
|
| 4788 | 4781 | |
| 4789 | 4782 | if (!is_array($content)) |
| 4790 | 4783 | { |
| 4791 | - $content = array ('acc_id' => $profileID); |
|
| 4784 | + $content = array('acc_id' => $profileID); |
|
| 4792 | 4785 | } |
| 4793 | 4786 | |
| 4794 | 4787 | $readonlys = array(); |
@@ -4796,7 +4789,7 @@ discard block |
||
| 4796 | 4789 | $preserv = array( |
| 4797 | 4790 | 'acc_id' => $content['acc_id'] // preserve acc id to be used in client-side |
| 4798 | 4791 | ); |
| 4799 | - $dtmpl->exec('mail.mail_ui.folderManagement', $content,$sel_options,$readonlys,$preserv,2); |
|
| 4792 | + $dtmpl->exec('mail.mail_ui.folderManagement', $content, $sel_options, $readonlys, $preserv, 2); |
|
| 4800 | 4793 | } |
| 4801 | 4794 | |
| 4802 | 4795 | /** |
@@ -4806,11 +4799,11 @@ discard block |
||
| 4806 | 4799 | * |
| 4807 | 4800 | * @param type $_folderName |
| 4808 | 4801 | */ |
| 4809 | - function ajax_folderMgmt_delete ($_folderName) |
|
| 4802 | + function ajax_folderMgmt_delete($_folderName) |
|
| 4810 | 4803 | { |
| 4811 | 4804 | if ($_folderName) |
| 4812 | 4805 | { |
| 4813 | - $success = $this->ajax_deleteFolder($_folderName,true); |
|
| 4806 | + $success = $this->ajax_deleteFolder($_folderName, true); |
|
| 4814 | 4807 | $response = egw_json_response::get(); |
| 4815 | 4808 | list(,$folderName) = explode(self::$delimiter, $_folderName); |
| 4816 | 4809 | if ($success) |
@@ -4819,7 +4812,7 @@ discard block |
||
| 4819 | 4812 | } |
| 4820 | 4813 | else |
| 4821 | 4814 | { |
| 4822 | - $res = lang("Failed to delete %1",$folderName); |
|
| 4815 | + $res = lang("Failed to delete %1", $folderName); |
|
| 4823 | 4816 | } |
| 4824 | 4817 | $response->data($res); |
| 4825 | 4818 | } |
@@ -114,9 +114,15 @@ discard block |
||
| 114 | 114 | function __construct($run_constructor=true) |
| 115 | 115 | { |
| 116 | 116 | $this->mail_tree = new mail_tree($this); |
| 117 | - if (!$run_constructor) return; |
|
| 117 | + if (!$run_constructor) |
|
| 118 | + { |
|
| 119 | + return; |
|
| 120 | + } |
|
| 118 | 121 | |
| 119 | - if (mail_bo::$debugTimes) $starttime = microtime (true); |
|
| 122 | + if (mail_bo::$debugTimes) |
|
| 123 | + { |
|
| 124 | + $starttime = microtime (true); |
|
| 125 | + } |
|
| 120 | 126 | // no autohide of the sidebox, as we use it for folderlist now. |
| 121 | 127 | unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']); |
| 122 | 128 | |
@@ -127,13 +133,19 @@ discard block |
||
| 127 | 133 | if ($_GET["resetConnection"]) |
| 128 | 134 | { |
| 129 | 135 | unset($_GET["resetConnection"]); |
| 130 | - if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' Connection Reset triggered: for Profile with ID:'.self::$icServerID); |
|
| 136 | + if (mail_bo::$debug) |
|
| 137 | + { |
|
| 138 | + error_log(__METHOD__.__LINE__.' Connection Reset triggered: for Profile with ID:'.self::$icServerID); |
|
| 139 | + } |
|
| 131 | 140 | emailadmin_imapbase::unsetCachedObjects(self::$icServerID); |
| 132 | 141 | } |
| 133 | 142 | |
| 134 | 143 | try { |
| 135 | 144 | $this->mail_bo = mail_bo::getInstance(true,self::$icServerID, true, false, true); |
| 136 | - if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace()); |
|
| 145 | + if (mail_bo::$debug) |
|
| 146 | + { |
|
| 147 | + error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace()); |
|
| 148 | + } |
|
| 137 | 149 | //error_log(__METHOD__.__LINE__.array2string($this->mail_bo->icServer)); |
| 138 | 150 | |
| 139 | 151 | // RegEx to minimize extra openConnection |
@@ -150,7 +162,10 @@ discard block |
||
| 150 | 162 | // redirect to mail wizard to handle it (redirect works for ajax too) |
| 151 | 163 | self::callWizard($e->getMessage(),true,'error'); |
| 152 | 164 | } |
| 153 | - if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 165 | + if (mail_bo::$debugTimes) |
|
| 166 | + { |
|
| 167 | + mail_bo::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 168 | + } |
|
| 154 | 169 | } |
| 155 | 170 | |
| 156 | 171 | /** |
@@ -209,16 +224,28 @@ discard block |
||
| 209 | 224 | */ |
| 210 | 225 | function changeProfile($_icServerID,$unsetCache=false) |
| 211 | 226 | { |
| 212 | - if (mail_bo::$debugTimes) $starttime = microtime (true); |
|
| 227 | + if (mail_bo::$debugTimes) |
|
| 228 | + { |
|
| 229 | + $starttime = microtime (true); |
|
| 230 | + } |
|
| 213 | 231 | if (self::$icServerID != $_icServerID) |
| 214 | 232 | { |
| 215 | 233 | self::$icServerID = $_icServerID; |
| 216 | 234 | } |
| 217 | - if (mail_bo::$debug) error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID); |
|
| 235 | + if (mail_bo::$debug) |
|
| 236 | + { |
|
| 237 | + error_log(__METHOD__.__LINE__.'->'.self::$icServerID.'<->'.$_icServerID); |
|
| 238 | + } |
|
| 218 | 239 | |
| 219 | - if ($unsetCache) emailadmin_imapbase::unsetCachedObjects(self::$icServerID); |
|
| 240 | + if ($unsetCache) |
|
| 241 | + { |
|
| 242 | + emailadmin_imapbase::unsetCachedObjects(self::$icServerID); |
|
| 243 | + } |
|
| 220 | 244 | $this->mail_bo = mail_bo::getInstance(false,self::$icServerID,true, false, true); |
| 221 | - if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace()); |
|
| 245 | + if (mail_bo::$debug) |
|
| 246 | + { |
|
| 247 | + error_log(__METHOD__.__LINE__.' Fetched IC Server:'.self::$icServerID.'/'.$this->mail_bo->profileID.':'.function_backtrace()); |
|
| 248 | + } |
|
| 222 | 249 | // no icServer Object: something failed big time |
| 223 | 250 | if (!isset($this->mail_bo->icServer) || $this->mail_bo->icServer->ImapServerId<>$_icServerID) |
| 224 | 251 | { |
@@ -228,14 +255,20 @@ discard block |
||
| 228 | 255 | |
| 229 | 256 | // save session varchar |
| 230 | 257 | $oldicServerID =& egw_cache::getSession('mail','activeProfileID'); |
| 231 | - if ($oldicServerID <> self::$icServerID) $this->mail_bo->openConnection(self::$icServerID); |
|
| 258 | + if ($oldicServerID <> self::$icServerID) |
|
| 259 | + { |
|
| 260 | + $this->mail_bo->openConnection(self::$icServerID); |
|
| 261 | + } |
|
| 232 | 262 | $oldicServerID = self::$icServerID; |
| 233 | 263 | if (!emailadmin_imapbase::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true )) |
| 234 | 264 | { |
| 235 | 265 | throw new egw_exception(__METHOD__." failed to change Profile to $_icServerID"); |
| 236 | 266 | } |
| 237 | 267 | |
| 238 | - if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 268 | + if (mail_bo::$debugTimes) |
|
| 269 | + { |
|
| 270 | + mail_bo::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 271 | + } |
|
| 239 | 272 | } |
| 240 | 273 | |
| 241 | 274 | /** |
@@ -276,7 +309,8 @@ discard block |
||
| 276 | 309 | // got subscribed or unsubscribed by the user |
| 277 | 310 | try { |
| 278 | 311 | $subscribed = $this->mail_bo->icServer->listSubscribedMailboxes('',0,true); |
| 279 | - } catch (Exception $ex) { |
|
| 312 | + } |
|
| 313 | + catch (Exception $ex) { |
|
| 280 | 314 | egw_framework::message($ex->getMessage()); |
| 281 | 315 | } |
| 282 | 316 | |
@@ -310,9 +344,18 @@ discard block |
||
| 310 | 344 | list(,$node) = explode($profileId.self::$delimiter, $path); |
| 311 | 345 | if ($node) |
| 312 | 346 | { |
| 313 | - if (is_array($subscribed) && $subscribed[$node] && !$value['value']) $to_unsubscribe []= $node; |
|
| 314 | - if (is_array($subscribed) && !$subscribed[$node] && $value['value']) $to_subscribe [] = $node; |
|
| 315 | - if ($value['value']) $cont[] = $path; |
|
| 347 | + if (is_array($subscribed) && $subscribed[$node] && !$value['value']) |
|
| 348 | + { |
|
| 349 | + $to_unsubscribe []= $node; |
|
| 350 | + } |
|
| 351 | + if (is_array($subscribed) && !$subscribed[$node] && $value['value']) |
|
| 352 | + { |
|
| 353 | + $to_subscribe [] = $node; |
|
| 354 | + } |
|
| 355 | + if ($value['value']) |
|
| 356 | + { |
|
| 357 | + $cont[] = $path; |
|
| 358 | + } |
|
| 316 | 359 | } |
| 317 | 360 | |
| 318 | 361 | } |
@@ -400,7 +443,10 @@ discard block |
||
| 400 | 443 | { |
| 401 | 444 | try { |
| 402 | 445 | //error_log(__METHOD__.__LINE__.function_backtrace()); |
| 403 | - if (mail_bo::$debugTimes) $starttime = microtime (true); |
|
| 446 | + if (mail_bo::$debugTimes) |
|
| 447 | + { |
|
| 448 | + $starttime = microtime (true); |
|
| 449 | + } |
|
| 404 | 450 | $this->mail_bo->restoreSessionData(); |
| 405 | 451 | $sessionFolder = $this->mail_bo->sessionData['mailbox']; |
| 406 | 452 | if ($this->mail_bo->folderExists($sessionFolder)) |
@@ -455,13 +501,16 @@ discard block |
||
| 455 | 501 | } |
| 456 | 502 | // call getQuotaRoot asynchronously in getRows by initiating a client Server roundtrip |
| 457 | 503 | $quota = false;//$this->mail_bo->getQuotaRoot(); |
| 458 | - if($quota !== false && $quota['limit'] != 'NOT SET') { |
|
| 504 | + if($quota !== false && $quota['limit'] != 'NOT SET') |
|
| 505 | + { |
|
| 459 | 506 | $quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']); |
| 460 | 507 | $content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text']; |
| 461 | 508 | $content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent']; |
| 462 | 509 | $content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class']; |
| 463 | 510 | $content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = ""; |
| 464 | - } else { |
|
| 511 | + } |
|
| 512 | + else |
|
| 513 | + { |
|
| 465 | 514 | $content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = lang("Quota not provided by server"); |
| 466 | 515 | $content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = "mail_DisplayNone"; |
| 467 | 516 | $content[self::$nm_index]['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone"; |
@@ -469,7 +518,8 @@ discard block |
||
| 469 | 518 | // call gatherVacation asynchronously in getRows by initiating a client Server roundtrip |
| 470 | 519 | $vacation = false;//$this->gatherVacation(); |
| 471 | 520 | //error_log(__METHOD__.__LINE__.' Server:'.self::$icServerID.' Sieve Enabled:'.array2string($vacation)); |
| 472 | - if($vacation) { |
|
| 521 | + if($vacation) |
|
| 522 | + { |
|
| 473 | 523 | if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date' && $vacation['end_date'] > time())) |
| 474 | 524 | { |
| 475 | 525 | $dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']/*.' '.($GLOBALS['egw_info']['user']['preferences']['common']['timeformat']!='24'?'h:i a':'H:i')*/; |
@@ -503,21 +553,36 @@ discard block |
||
| 503 | 553 | $keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5'); |
| 504 | 554 | foreach($keywords as &$k) |
| 505 | 555 | { |
| 506 | - if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]); |
|
| 556 | + if (array_key_exists($k,$this->statusTypes)) |
|
| 557 | + { |
|
| 558 | + unset($this->statusTypes[$k]); |
|
| 559 | + } |
|
| 507 | 560 | } |
| 508 | 561 | } |
| 509 | 562 | |
| 510 | - if (!isset($content[self::$nm_index]['foldertree'])) $content[self::$nm_index]['foldertree'] = $this->mail_bo->profileID.self::$delimiter.'INBOX'; |
|
| 511 | - if (!isset($content[self::$nm_index]['selectedFolder'])) $content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.'INBOX'; |
|
| 563 | + if (!isset($content[self::$nm_index]['foldertree'])) |
|
| 564 | + { |
|
| 565 | + $content[self::$nm_index]['foldertree'] = $this->mail_bo->profileID.self::$delimiter.'INBOX'; |
|
| 566 | + } |
|
| 567 | + if (!isset($content[self::$nm_index]['selectedFolder'])) |
|
| 568 | + { |
|
| 569 | + $content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.'INBOX'; |
|
| 570 | + } |
|
| 512 | 571 | |
| 513 | 572 | $content[self::$nm_index]['foldertree'] = $content[self::$nm_index]['selectedFolder']; |
| 514 | 573 | |
| 515 | 574 | if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) |
| 516 | 575 | { |
| 517 | 576 | emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE, 'email', 'supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
| 518 | - if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 577 | + if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) |
|
| 578 | + { |
|
| 579 | + emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 580 | + } |
|
| 581 | + } |
|
| 582 | + if (!emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]) |
|
| 583 | + { |
|
| 584 | + unset($this->searchTypes['quick']); |
|
| 519 | 585 | } |
| 520 | - if (!emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]) unset($this->searchTypes['quick']); |
|
| 521 | 586 | $sel_options['filter2'] = $this->searchTypes; |
| 522 | 587 | $sel_options['filter'] = $this->statusTypes; |
| 523 | 588 | |
@@ -712,18 +777,30 @@ discard block |
||
| 712 | 777 | $etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', $tree_actions); |
| 713 | 778 | |
| 714 | 779 | // sending preview toolbar actions |
| 715 | - if ($content['mailSplitter']) $etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions()); |
|
| 780 | + if ($content['mailSplitter']) |
|
| 781 | + { |
|
| 782 | + $etpl->setElementAttribute('mailPreview[toolbar]', 'actions', $this->get_toolbar_actions()); |
|
| 783 | + } |
|
| 716 | 784 | |
| 717 | - if (empty($content[self::$nm_index]['filter2']) || empty($content[self::$nm_index]['search'])) $content[self::$nm_index]['filter2']=(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject'); |
|
| 785 | + if (empty($content[self::$nm_index]['filter2']) || empty($content[self::$nm_index]['search'])) |
|
| 786 | + { |
|
| 787 | + $content[self::$nm_index]['filter2']=(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject'); |
|
| 788 | + } |
|
| 718 | 789 | $readonlys = $preserv = array(); |
| 719 | - if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 790 | + if (mail_bo::$debugTimes) |
|
| 791 | + { |
|
| 792 | + mail_bo::logRunTimes($starttime,null,'',__METHOD__.__LINE__); |
|
| 793 | + } |
|
| 720 | 794 | } |
| 721 | 795 | catch (Exception $e) |
| 722 | 796 | { |
| 723 | 797 | self::callWizard($e->getMessage(),true, 'error'); |
| 724 | 798 | } |
| 725 | 799 | // Check preview pane is enabled, then show spliter |
| 726 | - if ($this->mail_bo->mailPreferences['previewPane']) $etpl->setElementAttribute('mail.index.spliter', 'template', 'mail.index.nospliter'); |
|
| 800 | + if ($this->mail_bo->mailPreferences['previewPane']) |
|
| 801 | + { |
|
| 802 | + $etpl->setElementAttribute('mail.index.spliter', 'template', 'mail.index.nospliter'); |
|
| 803 | + } |
|
| 727 | 804 | |
| 728 | 805 | return $etpl->exec('mail.mail_ui.index',$content,$sel_options,$readonlys,$preserv); |
| 729 | 806 | } |
@@ -762,12 +839,18 @@ discard block |
||
| 762 | 839 | public function ajax_foldertree($_nodeID = null,$_subscribedOnly=null) |
| 763 | 840 | { |
| 764 | 841 | $nodeID = $_GET['id']; |
| 765 | - if (!is_null($_nodeID)) $nodeID = $_nodeID; |
|
| 842 | + if (!is_null($_nodeID)) |
|
| 843 | + { |
|
| 844 | + $nodeID = $_nodeID; |
|
| 845 | + } |
|
| 766 | 846 | $subscribedOnly = (bool)(!is_null($_subscribedOnly)?$_subscribedOnly:!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
| 767 | 847 | $fetchCounters = !is_null($_nodeID); |
| 768 | 848 | list($_profileID,$_folderName) = explode(self::$delimiter,$nodeID,2); |
| 769 | 849 | |
| 770 | - if (!empty($_folderName)) $fetchCounters = true; |
|
| 850 | + if (!empty($_folderName)) |
|
| 851 | + { |
|
| 852 | + $fetchCounters = true; |
|
| 853 | + } |
|
| 771 | 854 | |
| 772 | 855 | // Check if it is called for refresh root |
| 773 | 856 | // then we need to reinitialized the index tree |
@@ -779,7 +862,10 @@ discard block |
||
| 779 | 862 | { |
| 780 | 863 | $data = $this->mail_tree->getTree($nodeID,$_profileID,0, false,$subscribedOnly,!$this->mail_bo->mailPreferences['showAllFoldersInFolderPane']); |
| 781 | 864 | } |
| 782 | - if (!is_null($_nodeID)) return $data; |
|
| 865 | + if (!is_null($_nodeID)) |
|
| 866 | + { |
|
| 867 | + return $data; |
|
| 868 | + } |
|
| 783 | 869 | etemplate_widget_tree::send_quote_json($data); |
| 784 | 870 | } |
| 785 | 871 | |
@@ -844,7 +930,10 @@ discard block |
||
| 844 | 930 | $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 |
| 845 | 931 | } |
| 846 | 932 | } |
| 847 | - if (!is_array($lastFoldersUsedForMoveCont)) $lastFoldersUsedForMoveCont=array(); |
|
| 933 | + if (!is_array($lastFoldersUsedForMoveCont)) |
|
| 934 | + { |
|
| 935 | + $lastFoldersUsedForMoveCont=array(); |
|
| 936 | + } |
|
| 848 | 937 | foreach ($lastFoldersUsedForMoveCont as $pid => $info) |
| 849 | 938 | { |
| 850 | 939 | if ($this->mail_bo->profileID==$pid && isset($lastFoldersUsedForMoveCont[$this->mail_bo->profileID])) |
@@ -859,9 +948,12 @@ discard block |
||
| 859 | 948 | { |
| 860 | 949 | $moveaction .= $lastFolderUsedForMoveCont; |
| 861 | 950 | |
| 862 | - if ($this->mail_bo->folderExists($i)) // only 10 entries per mailaccount.Control this on setting the buffered folders |
|
| 951 | + if ($this->mail_bo->folderExists($i)) |
|
| 952 | + { |
|
| 953 | + // only 10 entries per mailaccount.Control this on setting the buffered folders |
|
| 863 | 954 | { |
| 864 | 955 | $fS['profileID'] = $this->mail_bo->profileID; |
| 956 | + } |
|
| 865 | 957 | $fS['profileName'] = $accArray[$this->mail_bo->profileID]; |
| 866 | 958 | $fS['shortDisplayName'] = $i; |
| 867 | 959 | $moveactions[$moveaction] = $fS; |
@@ -881,9 +973,12 @@ discard block |
||
| 881 | 973 | foreach ($lastFoldersUsedForMoveCont[$pid] as $i => $lastFolderUsedForMoveCont) |
| 882 | 974 | { |
| 883 | 975 | //error_log(__METHOD__.__LINE__."$i => $lastFolderUsedForMoveCont"); |
| 884 | - if (!empty($lastFolderUsedForMoveCont)) // only 10 entries per mailaccount.Control this on setting the buffered folders |
|
| 976 | + if (!empty($lastFolderUsedForMoveCont)) |
|
| 977 | + { |
|
| 978 | + // only 10 entries per mailaccount.Control this on setting the buffered folders |
|
| 885 | 979 | { |
| 886 | 980 | $moveaction = 'move_'; |
| 981 | + } |
|
| 887 | 982 | $fS = array(); |
| 888 | 983 | $fS['profileID'] = $pid; |
| 889 | 984 | $fS['profileName'] = $accArray[$pid]; |
@@ -1241,22 +1336,34 @@ discard block |
||
| 1241 | 1336 | $rows=array(); |
| 1242 | 1337 | return 0; |
| 1243 | 1338 | } |
| 1244 | - if (empty($folderName)) $query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX'; |
|
| 1339 | + if (empty($folderName)) |
|
| 1340 | + { |
|
| 1341 | + $query['selectedFolder'] = $_profileID.self::$delimiter.'INBOX'; |
|
| 1342 | + } |
|
| 1245 | 1343 | } |
| 1246 | 1344 | } |
| 1247 | 1345 | if (!isset($mail_ui)) |
| 1248 | 1346 | { |
| 1249 | 1347 | $mail_ui = new mail_ui(true); // run constructor for current profile |
| 1250 | - if (empty($query['selectedFolder'])) $query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX'; |
|
| 1348 | + if (empty($query['selectedFolder'])) |
|
| 1349 | + { |
|
| 1350 | + $query['selectedFolder'] = $mail_ui->mail_bo->profileID.self::$delimiter.'INBOX'; |
|
| 1351 | + } |
|
| 1251 | 1352 | } |
| 1252 | 1353 | |
| 1253 | 1354 | //error_log(__METHOD__.__LINE__.' SelectedFolder:'.$query['selectedFolder'].' Start:'.$query['start'].' NumRows:'.$query['num_rows'].array2string($query['order']).'->'.array2string($query['sort'])); |
| 1254 | 1355 | //mail_bo::$debugTimes=true; |
| 1255 | - if (mail_bo::$debugTimes) $starttime = microtime(true); |
|
| 1356 | + if (mail_bo::$debugTimes) |
|
| 1357 | + { |
|
| 1358 | + $starttime = microtime(true); |
|
| 1359 | + } |
|
| 1256 | 1360 | //$query['search'] is the phrase in the searchbox |
| 1257 | 1361 | |
| 1258 | 1362 | $mail_ui->mail_bo->restoreSessionData(); |
| 1259 | - if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder']; |
|
| 1363 | + if (isset($query['selectedFolder'])) |
|
| 1364 | + { |
|
| 1365 | + $mail_ui->mail_bo->sessionData['mailbox']=$query['selectedFolder']; |
|
| 1366 | + } |
|
| 1260 | 1367 | $mail_ui->mail_bo->saveSessionData(); |
| 1261 | 1368 | |
| 1262 | 1369 | $sRToFetch = null; |
@@ -1267,7 +1374,10 @@ discard block |
||
| 1267 | 1374 | unset($app); |
| 1268 | 1375 | } |
| 1269 | 1376 | //save selected Folder to sessionData (mailbox)->currentFolder |
| 1270 | - if (isset($query['selectedFolder'])) $mail_ui->mail_bo->sessionData['mailbox']=$_folderName; |
|
| 1377 | + if (isset($query['selectedFolder'])) |
|
| 1378 | + { |
|
| 1379 | + $mail_ui->mail_bo->sessionData['mailbox']=$_folderName; |
|
| 1380 | + } |
|
| 1271 | 1381 | $toSchema = false;//decides to select list schema with column to selected (if false fromaddress is default) |
| 1272 | 1382 | if ($mail_ui->mail_bo->folderExists($_folderName)) |
| 1273 | 1383 | { |
@@ -1328,7 +1438,10 @@ discard block |
||
| 1328 | 1438 | $rowsFetched['messages'] = $_sR['count']; |
| 1329 | 1439 | $sR = $_sR['match']->ids; |
| 1330 | 1440 | // if $sR is false, something failed fundamentally |
| 1331 | - if($reverse === true) $sR = ($sR===false?array():array_reverse((array)$sR)); |
|
| 1441 | + if($reverse === true) |
|
| 1442 | + { |
|
| 1443 | + $sR = ($sR===false?array():array_reverse((array)$sR)); |
|
| 1444 | + } |
|
| 1332 | 1445 | $sR = array_slice((array)$sR,($offset==0?0:$offset-1),$maxMessages); // we need only $maxMessages of uids |
| 1333 | 1446 | $sRToFetch = $sR;//array_slice($sR,0,50); // we fetch only the headers of a subset of the fetched uids |
| 1334 | 1447 | //error_log(__METHOD__.__LINE__.' Rows fetched (UID only):'.count($sR).' Data:'.array2string($sR)); |
@@ -1394,7 +1507,10 @@ discard block |
||
| 1394 | 1507 | } |
| 1395 | 1508 | else |
| 1396 | 1509 | { |
| 1397 | - if (!empty($v)) $sortResult['header'][] = array('uid'=>$v); |
|
| 1510 | + if (!empty($v)) |
|
| 1511 | + { |
|
| 1512 | + $sortResult['header'][] = array('uid'=>$v); |
|
| 1513 | + } |
|
| 1398 | 1514 | } |
| 1399 | 1515 | } |
| 1400 | 1516 | } |
@@ -1403,15 +1519,24 @@ discard block |
||
| 1403 | 1519 | $sortResult = $sortResultwH; |
| 1404 | 1520 | } |
| 1405 | 1521 | $rowsFetched['rowsFetched'] = count($sortResult['header']); |
| 1406 | - if (empty($rowsFetched['messages'])) $rowsFetched['messages'] = $rowsFetched['rowsFetched']; |
|
| 1522 | + if (empty($rowsFetched['messages'])) |
|
| 1523 | + { |
|
| 1524 | + $rowsFetched['messages'] = $rowsFetched['rowsFetched']; |
|
| 1525 | + } |
|
| 1407 | 1526 | |
| 1408 | 1527 | //error_log(__METHOD__.__LINE__.' Rows fetched:'.$rowsFetched.' Data:'.array2string($sortResult)); |
| 1409 | 1528 | $cols = array('row_id','uid','status','attachments','subject','address','toaddress','fromaddress','ccaddress','additionaltoaddress','date','size','modified','bodypreview'); |
| 1410 | - if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE') unset($cols[0]); |
|
| 1529 | + if ($GLOBALS['egw_info']['user']['preferences']['common']['select_mode']=='EGW_SELECTMODE_TOGGLE') |
|
| 1530 | + { |
|
| 1531 | + unset($cols[0]); |
|
| 1532 | + } |
|
| 1411 | 1533 | $rows = $mail_ui->header2gridelements($sortResult['header'],$cols, $_folderName, $folderType=$toSchema); |
| 1412 | 1534 | //error_log(__METHOD__.__LINE__.array2string($rows)); |
| 1413 | 1535 | |
| 1414 | - if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__); |
|
| 1536 | + if (mail_bo::$debugTimes) |
|
| 1537 | + { |
|
| 1538 | + mail_bo::logRunTimes($starttime,null,'Folder:'.$_folderName.' Start:'.$query['start'].' NumRows:'.$query['num_rows'],__METHOD__.__LINE__); |
|
| 1539 | + } |
|
| 1415 | 1540 | return $rowsFetched['messages']; |
| 1416 | 1541 | } |
| 1417 | 1542 | |
@@ -1513,7 +1638,10 @@ discard block |
||
| 1513 | 1638 | $actionsenabled[$act]= $actions['mark']['children']['setLabel']['children'][$act]; |
| 1514 | 1639 | break; |
| 1515 | 1640 | default: |
| 1516 | - if (isset($actions[$act])) $actionsenabled[$act]=$actions[$act]; |
|
| 1641 | + if (isset($actions[$act])) |
|
| 1642 | + { |
|
| 1643 | + $actionsenabled[$act]=$actions[$act]; |
|
| 1644 | + } |
|
| 1517 | 1645 | } |
| 1518 | 1646 | } |
| 1519 | 1647 | unset($actionsenabled['drag_mail']); |
@@ -1535,7 +1663,10 @@ discard block |
||
| 1535 | 1663 | */ |
| 1536 | 1664 | public function header2gridelements($_headers, $cols, $_folderName, $_folderType=0) |
| 1537 | 1665 | { |
| 1538 | - if (mail_bo::$debugTimes) $starttime = microtime(true); |
|
| 1666 | + if (mail_bo::$debugTimes) |
|
| 1667 | + { |
|
| 1668 | + $starttime = microtime(true); |
|
| 1669 | + } |
|
| 1539 | 1670 | $rv = array(); |
| 1540 | 1671 | $i=0; |
| 1541 | 1672 | foreach((array)$_headers as $header) |
@@ -1548,17 +1679,50 @@ discard block |
||
| 1548 | 1679 | $data['row_id']=$this->createRowID($_folderName,$message_uid); |
| 1549 | 1680 | |
| 1550 | 1681 | $flags = ""; |
| 1551 | - if(!empty($header['recent'])) $flags .= "R"; |
|
| 1552 | - if(!empty($header['flagged'])) $flags .= "F"; |
|
| 1553 | - if(!empty($header['answered'])) $flags .= "A"; |
|
| 1554 | - if(!empty($header['forwarded'])) $flags .= "W"; |
|
| 1555 | - if(!empty($header['deleted'])) $flags .= "D"; |
|
| 1556 | - if(!empty($header['seen'])) $flags .= "S"; |
|
| 1557 | - if(!empty($header['label1'])) $flags .= "1"; |
|
| 1558 | - if(!empty($header['label2'])) $flags .= "2"; |
|
| 1559 | - if(!empty($header['label3'])) $flags .= "3"; |
|
| 1560 | - if(!empty($header['label4'])) $flags .= "4"; |
|
| 1561 | - if(!empty($header['label5'])) $flags .= "5"; |
|
| 1682 | + if(!empty($header['recent'])) |
|
| 1683 | + { |
|
| 1684 | + $flags .= "R"; |
|
| 1685 | + } |
|
| 1686 | + if(!empty($header['flagged'])) |
|
| 1687 | + { |
|
| 1688 | + $flags .= "F"; |
|
| 1689 | + } |
|
| 1690 | + if(!empty($header['answered'])) |
|
| 1691 | + { |
|
| 1692 | + $flags .= "A"; |
|
| 1693 | + } |
|
| 1694 | + if(!empty($header['forwarded'])) |
|
| 1695 | + { |
|
| 1696 | + $flags .= "W"; |
|
| 1697 | + } |
|
| 1698 | + if(!empty($header['deleted'])) |
|
| 1699 | + { |
|
| 1700 | + $flags .= "D"; |
|
| 1701 | + } |
|
| 1702 | + if(!empty($header['seen'])) |
|
| 1703 | + { |
|
| 1704 | + $flags .= "S"; |
|
| 1705 | + } |
|
| 1706 | + if(!empty($header['label1'])) |
|
| 1707 | + { |
|
| 1708 | + $flags .= "1"; |
|
| 1709 | + } |
|
| 1710 | + if(!empty($header['label2'])) |
|
| 1711 | + { |
|
| 1712 | + $flags .= "2"; |
|
| 1713 | + } |
|
| 1714 | + if(!empty($header['label3'])) |
|
| 1715 | + { |
|
| 1716 | + $flags .= "3"; |
|
| 1717 | + } |
|
| 1718 | + if(!empty($header['label4'])) |
|
| 1719 | + { |
|
| 1720 | + $flags .= "4"; |
|
| 1721 | + } |
|
| 1722 | + if(!empty($header['label5'])) |
|
| 1723 | + { |
|
| 1724 | + $flags .= "5"; |
|
| 1725 | + } |
|
| 1562 | 1726 | |
| 1563 | 1727 | $data["status"] = "<span class=\"status_img\"></span>"; |
| 1564 | 1728 | //error_log(__METHOD__.array2string($header).' Flags:'.$flags); |
@@ -1566,41 +1730,53 @@ discard block |
||
| 1566 | 1730 | // the css for this row |
| 1567 | 1731 | $is_recent=false; |
| 1568 | 1732 | $css_styles = array("mail"); |
| 1569 | - if ($header['deleted']) { |
|
| 1733 | + if ($header['deleted']) |
|
| 1734 | + { |
|
| 1570 | 1735 | $css_styles[] = 'deleted'; |
| 1571 | 1736 | } |
| 1572 | - if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded'])) { |
|
| 1737 | + if ($header['recent'] && !($header['deleted'] || $header['seen'] || $header['answered'] || $header['forwarded'])) |
|
| 1738 | + { |
|
| 1573 | 1739 | $css_styles[] = 'recent'; |
| 1574 | 1740 | $is_recent=true; |
| 1575 | 1741 | } |
| 1576 | - if ($header['priority'] < 3) { |
|
| 1742 | + if ($header['priority'] < 3) |
|
| 1743 | + { |
|
| 1577 | 1744 | $css_styles[] = 'prio_high'; |
| 1578 | 1745 | } |
| 1579 | - if ($header['flagged']) { |
|
| 1746 | + if ($header['flagged']) |
|
| 1747 | + { |
|
| 1580 | 1748 | $css_styles[] = 'flagged'; |
| 1581 | 1749 | } |
| 1582 | - if (!$header['seen']) { |
|
| 1750 | + if (!$header['seen']) |
|
| 1751 | + { |
|
| 1583 | 1752 | $css_styles[] = 'unseen'; // different status image for recent // solved via css !important |
| 1584 | 1753 | } |
| 1585 | - if ($header['answered']) { |
|
| 1754 | + if ($header['answered']) |
|
| 1755 | + { |
|
| 1586 | 1756 | $css_styles[] = 'replied'; |
| 1587 | 1757 | } |
| 1588 | - if ($header['forwarded']) { |
|
| 1758 | + if ($header['forwarded']) |
|
| 1759 | + { |
|
| 1589 | 1760 | $css_styles[] = 'forwarded'; |
| 1590 | 1761 | } |
| 1591 | - if ($header['label1']) { |
|
| 1762 | + if ($header['label1']) |
|
| 1763 | + { |
|
| 1592 | 1764 | $css_styles[] = 'labelone'; |
| 1593 | 1765 | } |
| 1594 | - if ($header['label2']) { |
|
| 1766 | + if ($header['label2']) |
|
| 1767 | + { |
|
| 1595 | 1768 | $css_styles[] = 'labeltwo'; |
| 1596 | 1769 | } |
| 1597 | - if ($header['label3']) { |
|
| 1770 | + if ($header['label3']) |
|
| 1771 | + { |
|
| 1598 | 1772 | $css_styles[] = 'labelthree'; |
| 1599 | 1773 | } |
| 1600 | - if ($header['label4']) { |
|
| 1774 | + if ($header['label4']) |
|
| 1775 | + { |
|
| 1601 | 1776 | $css_styles[] = 'labelfour'; |
| 1602 | 1777 | } |
| 1603 | - if ($header['label5']) { |
|
| 1778 | + if ($header['label5']) |
|
| 1779 | + { |
|
| 1604 | 1780 | $css_styles[] = 'labelfive'; |
| 1605 | 1781 | } |
| 1606 | 1782 | |
@@ -1617,10 +1793,13 @@ discard block |
||
| 1617 | 1793 | $header['subject'] = preg_replace($search,$replace,$header['subject']); |
| 1618 | 1794 | // curly brackets get messed up by the template! |
| 1619 | 1795 | |
| 1620 | - if (!empty($header['subject'])) { |
|
| 1796 | + if (!empty($header['subject'])) |
|
| 1797 | + { |
|
| 1621 | 1798 | // make the subject shorter if it is to long |
| 1622 | 1799 | $subject = $header['subject']; |
| 1623 | - } else { |
|
| 1800 | + } |
|
| 1801 | + else |
|
| 1802 | + { |
|
| 1624 | 1803 | $subject = '('. lang('no subject') .')'; |
| 1625 | 1804 | } |
| 1626 | 1805 | |
@@ -1662,15 +1841,22 @@ discard block |
||
| 1662 | 1841 | } |
| 1663 | 1842 | |
| 1664 | 1843 | $attachmentFlag = $image; |
| 1665 | - } else { |
|
| 1844 | + } |
|
| 1845 | + else |
|
| 1846 | + { |
|
| 1666 | 1847 | $attachmentFlag =' '; |
| 1667 | 1848 | } |
| 1668 | 1849 | // show priority flag |
| 1669 | - if ($header['priority'] < 3) { |
|
| 1850 | + if ($header['priority'] < 3) |
|
| 1851 | + { |
|
| 1670 | 1852 | $image = html::image('mail','prio_high'); |
| 1671 | - } elseif ($header['priority'] > 3) { |
|
| 1853 | + } |
|
| 1854 | + elseif ($header['priority'] > 3) |
|
| 1855 | + { |
|
| 1672 | 1856 | $image = html::image('mail','prio_low'); |
| 1673 | - } else { |
|
| 1857 | + } |
|
| 1858 | + else |
|
| 1859 | + { |
|
| 1674 | 1860 | $image = ''; |
| 1675 | 1861 | } |
| 1676 | 1862 | // show a flag for flagged messages |
@@ -1712,26 +1898,53 @@ discard block |
||
| 1712 | 1898 | } |
| 1713 | 1899 | |
| 1714 | 1900 | if (in_array("size", $cols)) |
| 1715 | - $data["size"] = $header['size']; /// size |
|
| 1901 | + { |
|
| 1902 | + $data["size"] = $header['size']; |
|
| 1903 | + } |
|
| 1904 | + /// size |
|
| 1716 | 1905 | |
| 1717 | 1906 | $data["class"] = implode(' ', $css_styles); |
| 1718 | 1907 | //translate style-classes back to flags |
| 1719 | 1908 | $data['flags'] = Array(); |
| 1720 | - if ($header['seen']) $data["flags"]['read'] = 'read'; |
|
| 1721 | - foreach ($css_styles as &$flag) { |
|
| 1909 | + if ($header['seen']) |
|
| 1910 | + { |
|
| 1911 | + $data["flags"]['read'] = 'read'; |
|
| 1912 | + } |
|
| 1913 | + foreach ($css_styles as &$flag) |
|
| 1914 | + { |
|
| 1722 | 1915 | if ($flag!='mail') |
| 1723 | 1916 | { |
| 1724 | - if ($flag=='labelone') {$data["flags"]['label1'] = 'label1';} |
|
| 1725 | - elseif ($flag=='labeltwo') {$data["flags"]['label2'] = 'label2';} |
|
| 1726 | - elseif ($flag=='labelthree') {$data["flags"]['label3'] = 'label3';} |
|
| 1727 | - elseif ($flag=='labelfour') {$data["flags"]['label4'] = 'label4';} |
|
| 1728 | - elseif ($flag=='labelfive') {$data["flags"]['label5'] = 'label5';} |
|
| 1729 | - elseif ($flag=='unseen') {unset($data["flags"]['read']);} |
|
| 1730 | - else $data["flags"][$flag] = $flag; |
|
| 1917 | + if ($flag=='labelone') |
|
| 1918 | + { |
|
| 1919 | +$data["flags"]['label1'] = 'label1';} |
|
| 1920 | + elseif ($flag=='labeltwo') |
|
| 1921 | + { |
|
| 1922 | +$data["flags"]['label2'] = 'label2';} |
|
| 1923 | + elseif ($flag=='labelthree') |
|
| 1924 | + { |
|
| 1925 | +$data["flags"]['label3'] = 'label3';} |
|
| 1926 | + elseif ($flag=='labelfour') |
|
| 1927 | + { |
|
| 1928 | +$data["flags"]['label4'] = 'label4';} |
|
| 1929 | + elseif ($flag=='labelfive') |
|
| 1930 | + { |
|
| 1931 | +$data["flags"]['label5'] = 'label5';} |
|
| 1932 | + elseif ($flag=='unseen') |
|
| 1933 | + { |
|
| 1934 | +unset($data["flags"]['read']);} |
|
| 1935 | + else { |
|
| 1936 | + $data["flags"][$flag] = $flag; |
|
| 1937 | + } |
|
| 1731 | 1938 | } |
| 1732 | 1939 | } |
| 1733 | - if ($header['disposition-notification-to']) $data['dispositionnotificationto'] = $header['disposition-notification-to']; |
|
| 1734 | - if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto'])) unset($data['dispositionnotificationto']); |
|
| 1940 | + if ($header['disposition-notification-to']) |
|
| 1941 | + { |
|
| 1942 | + $data['dispositionnotificationto'] = $header['disposition-notification-to']; |
|
| 1943 | + } |
|
| 1944 | + if (($header['mdnsent']||$header['mdnnotsent']|$header['seen'])&&isset($data['dispositionnotificationto'])) |
|
| 1945 | + { |
|
| 1946 | + unset($data['dispositionnotificationto']); |
|
| 1947 | + } |
|
| 1735 | 1948 | $data['attachmentsBlock'] = $imageHTMLBlock; |
| 1736 | 1949 | $data['address'] = ($_folderType?$data["toaddress"]:$data["fromaddress"]); |
| 1737 | 1950 | if (in_array("bodypreview", $cols)&&$header['bodypreview']) |
@@ -1741,7 +1954,10 @@ discard block |
||
| 1741 | 1954 | $rv[] = $data; |
| 1742 | 1955 | //error_log(__METHOD__.__LINE__.array2string($data)); |
| 1743 | 1956 | } |
| 1744 | - if (mail_bo::$debugTimes) mail_bo::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__); |
|
| 1957 | + if (mail_bo::$debugTimes) |
|
| 1958 | + { |
|
| 1959 | + mail_bo::logRunTimes($starttime,null,'Folder:'.$_folderName,__METHOD__.__LINE__); |
|
| 1960 | + } |
|
| 1745 | 1961 | |
| 1746 | 1962 | // ToDo: call this ONLY if labels change |
| 1747 | 1963 | etemplate_widget::setElementAttribute('toolbar', 'actions', $this->get_toolbar_actions()); |
@@ -1756,8 +1972,14 @@ discard block |
||
| 1756 | 1972 | */ |
| 1757 | 1973 | function displayHeader() |
| 1758 | 1974 | { |
| 1759 | - if(isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 1760 | - if(isset($_GET['part'])) $partID = $_GET['part']; |
|
| 1975 | + if(isset($_GET['id'])) |
|
| 1976 | + { |
|
| 1977 | + $rowID = $_GET['id']; |
|
| 1978 | + } |
|
| 1979 | + if(isset($_GET['part'])) |
|
| 1980 | + { |
|
| 1981 | + $partID = $_GET['part']; |
|
| 1982 | + } |
|
| 1761 | 1983 | |
| 1762 | 1984 | $hA = self::splitRowID($rowID); |
| 1763 | 1985 | $uid = $hA['msgUID']; |
@@ -1781,7 +2003,8 @@ discard block |
||
| 1781 | 2003 | $rawheaders = ""; |
| 1782 | 2004 | // create it new, with good line breaks |
| 1783 | 2005 | reset($newRawHeaders); |
| 1784 | - while(list($key,$value) = @each($newRawHeaders)) { |
|
| 2006 | + while(list($key,$value) = @each($newRawHeaders)) |
|
| 2007 | + { |
|
| 1785 | 2008 | $rawheaders .= wordwrap($value, 90, "\n "); |
| 1786 | 2009 | } |
| 1787 | 2010 | |
@@ -1804,12 +2027,24 @@ discard block |
||
| 1804 | 2027 | */ |
| 1805 | 2028 | function displayMessage($_requesteddata = null) |
| 1806 | 2029 | { |
| 1807 | - if (is_null($_requesteddata)) $_requesteddata = $_GET; |
|
| 2030 | + if (is_null($_requesteddata)) |
|
| 2031 | + { |
|
| 2032 | + $_requesteddata = $_GET; |
|
| 2033 | + } |
|
| 1808 | 2034 | |
| 1809 | 2035 | $preventRedirect=false; |
| 1810 | - if(isset($_requesteddata['id'])) $rowID = $_requesteddata['id']; |
|
| 1811 | - if(isset($_requesteddata['part'])) $partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null; |
|
| 1812 | - if(isset($_requesteddata['mode'])) $preventRedirect = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false); |
|
| 2036 | + if(isset($_requesteddata['id'])) |
|
| 2037 | + { |
|
| 2038 | + $rowID = $_requesteddata['id']; |
|
| 2039 | + } |
|
| 2040 | + if(isset($_requesteddata['part'])) |
|
| 2041 | + { |
|
| 2042 | + $partID = $_requesteddata['part']!='null'?$_requesteddata['part']:null; |
|
| 2043 | + } |
|
| 2044 | + if(isset($_requesteddata['mode'])) |
|
| 2045 | + { |
|
| 2046 | + $preventRedirect = (($_requesteddata['mode']=='display' || $_requesteddata['mode'] == 'print')?true:false); |
|
| 2047 | + } |
|
| 1813 | 2048 | |
| 1814 | 2049 | $hA = self::splitRowID($rowID); |
| 1815 | 2050 | $uid = $hA['msgUID']; |
@@ -1822,8 +2057,14 @@ discard block |
||
| 1822 | 2057 | $this->changeProfile($icServerID); |
| 1823 | 2058 | } |
| 1824 | 2059 | $htmlOptions = $this->mail_bo->htmlOptions; |
| 1825 | - if (!empty($_requesteddata['tryastext'])) $htmlOptions = "only_if_no_text"; |
|
| 1826 | - if (!empty($_requesteddata['tryashtml'])) $htmlOptions = "always_display"; |
|
| 2060 | + if (!empty($_requesteddata['tryastext'])) |
|
| 2061 | + { |
|
| 2062 | + $htmlOptions = "only_if_no_text"; |
|
| 2063 | + } |
|
| 2064 | + if (!empty($_requesteddata['tryashtml'])) |
|
| 2065 | + { |
|
| 2066 | + $htmlOptions = "always_display"; |
|
| 2067 | + } |
|
| 1827 | 2068 | |
| 1828 | 2069 | //error_log(__METHOD__.__LINE__.array2string($hA)); |
| 1829 | 2070 | if (($this->mail_bo->isDraftFolder($mailbox)) && $_requesteddata['mode'] == 'print') |
@@ -1847,14 +2088,20 @@ discard block |
||
| 1847 | 2088 | $error_msg[] = lang("In Mailbox: %1, with ID: %2, and PartID: %3",$mailbox,$uid,$partID); |
| 1848 | 2089 | egw_framework::message($e->getMessage(), 'error'); |
| 1849 | 2090 | } |
| 1850 | - if (!empty($uid)) $this->mail_bo->getFlags($uid); |
|
| 2091 | + if (!empty($uid)) |
|
| 2092 | + { |
|
| 2093 | + $this->mail_bo->getFlags($uid); |
|
| 2094 | + } |
|
| 1851 | 2095 | $envelope = $this->mail_bo->getMessageEnvelope($uid, $partID,true,$mailbox); |
| 1852 | 2096 | //error_log(__METHOD__.__LINE__.array2string($envelope)); |
| 1853 | 2097 | $this->mail_bo->getMessageRawHeader($uid, $partID,$mailbox); |
| 1854 | 2098 | $fetchEmbeddedImages = false; |
| 1855 | 2099 | // if we are in HTML so its likely that we should show the embedded images; as a result |
| 1856 | 2100 | // we do NOT want to see those, that are embedded in the list of attachments |
| 1857 | - if ($htmlOptions !='always_display') $fetchEmbeddedImages = true; |
|
| 2101 | + if ($htmlOptions !='always_display') |
|
| 2102 | + { |
|
| 2103 | + $fetchEmbeddedImages = true; |
|
| 2104 | + } |
|
| 1858 | 2105 | $attachments = $this->mail_bo->getMessageAttachments($uid, $partID, null, $fetchEmbeddedImages,true,true,$mailbox); |
| 1859 | 2106 | //error_log(__METHOD__.__LINE__.array2string($attachments)); |
| 1860 | 2107 | $attachmentHTMLBlock = self::createAttachmentBlock($attachments, $rowID, $uid, $mailbox); |
@@ -1870,10 +2117,16 @@ discard block |
||
| 1870 | 2117 | $subject = $this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters,'',$envelope['SUBJECT']),false); |
| 1871 | 2118 | |
| 1872 | 2119 | // Set up data for taglist widget(s) |
| 1873 | - if ($envelope['FROM']==$envelope['SENDER']) unset($envelope['SENDER']); |
|
| 2120 | + if ($envelope['FROM']==$envelope['SENDER']) |
|
| 2121 | + { |
|
| 2122 | + unset($envelope['SENDER']); |
|
| 2123 | + } |
|
| 1874 | 2124 | foreach(array('SENDER','FROM','TO','CC','BCC') as $field) |
| 1875 | 2125 | { |
| 1876 | - if (!isset($envelope[$field])) continue; |
|
| 2126 | + if (!isset($envelope[$field])) |
|
| 2127 | + { |
|
| 2128 | + continue; |
|
| 2129 | + } |
|
| 1877 | 2130 | foreach($envelope[$field] as $field_data) |
| 1878 | 2131 | { |
| 1879 | 2132 | //error_log(__METHOD__.__LINE__.array2string($field_data)); |
@@ -1887,7 +2140,10 @@ discard block |
||
| 1887 | 2140 | } |
| 1888 | 2141 | $actionsenabled = $this->getDisplayToolbarActions(); |
| 1889 | 2142 | $content['displayToolbaractions'] = json_encode($actionsenabled); |
| 1890 | - if (empty($subject)) $subject = lang('no subject'); |
|
| 2143 | + if (empty($subject)) |
|
| 2144 | + { |
|
| 2145 | + $subject = lang('no subject'); |
|
| 2146 | + } |
|
| 1891 | 2147 | $content['msg'] = (is_array($error_msg)?implode("<br>",$error_msg):$error_msg); |
| 1892 | 2148 | // Send mail ID so we can use it for actions |
| 1893 | 2149 | $content['mail_id'] = $rowID; |
@@ -1898,8 +2154,14 @@ discard block |
||
| 1898 | 2154 | $content['mail_displaydate'] = mail_bo::_strtotime($headers['DATE'],'ts',true); |
| 1899 | 2155 | $content['mail_displaysubject'] = $subject; |
| 1900 | 2156 | $linkData = array('menuaction'=>"mail.mail_ui.loadEmailBody","_messageID"=>$rowID); |
| 1901 | - if (!empty($partID)) $linkData['_partID']=$partID; |
|
| 1902 | - if ($htmlOptions != $this->mail_bo->htmlOptions) $linkData['_htmloptions']=$htmlOptions; |
|
| 2157 | + if (!empty($partID)) |
|
| 2158 | + { |
|
| 2159 | + $linkData['_partID']=$partID; |
|
| 2160 | + } |
|
| 2161 | + if ($htmlOptions != $this->mail_bo->htmlOptions) |
|
| 2162 | + { |
|
| 2163 | + $linkData['_htmloptions']=$htmlOptions; |
|
| 2164 | + } |
|
| 1903 | 2165 | $content['mailDisplayBodySrc'] = egw::link('/index.php',$linkData); |
| 1904 | 2166 | $content['mail_displayattachments'] = $attachmentHTMLBlock; |
| 1905 | 2167 | $content['mail_id']=$rowID; |
@@ -1967,7 +2229,8 @@ discard block |
||
| 1967 | 2229 | { |
| 1968 | 2230 | $attachmentHTMLBlock=''; |
| 1969 | 2231 | $attachmentHTML = array(); |
| 1970 | - if (is_array($attachments) && count($attachments) > 0) { |
|
| 2232 | + if (is_array($attachments) && count($attachments) > 0) |
|
| 2233 | + { |
|
| 1971 | 2234 | $url_img_vfs = html::image('filemanager','navbar', lang('Filemanager'), ' height="16"'); |
| 1972 | 2235 | $url_img_vfs_save_all = html::image('mail','save_all', lang('Save all')); |
| 1973 | 2236 | |
@@ -1977,7 +2240,10 @@ discard block |
||
| 1977 | 2240 | $attachmentHTML[$key]['filename'] = translation::convert_jsonsafe($attachmentHTML[$key]['filename'],'utf-8'); |
| 1978 | 2241 | //error_log(array2string($value)); |
| 1979 | 2242 | //error_log(strtoupper($value['mimeType']) .'<->'. mime_magic::filename2mime($attachmentHTML[$key]['filename'])); |
| 1980 | - if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) $value['mimeType'] = mime_magic::filename2mime($attachmentHTML[$key]['filename']); |
|
| 2243 | + if (strtoupper($value['mimeType']=='APPLICATION/OCTET-STREAM')) |
|
| 2244 | + { |
|
| 2245 | + $value['mimeType'] = mime_magic::filename2mime($attachmentHTML[$key]['filename']); |
|
| 2246 | + } |
|
| 1981 | 2247 | $attachmentHTML[$key]['type']=$value['mimeType']; |
| 1982 | 2248 | $attachmentHTML[$key]['mimetype']=mime_magic::mime2label($value['mimeType']); |
| 1983 | 2249 | $hA = self::splitRowID($rowID); |
@@ -2020,8 +2286,15 @@ discard block |
||
| 2020 | 2286 | $sfxMimeType = $value['mimeType']; |
| 2021 | 2287 | $buff = explode('.',$value['name']); |
| 2022 | 2288 | $suffix = ''; |
| 2023 | - if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
|
| 2024 | - if (!empty($suffix)) $sfxMimeType = mime_magic::ext2mime($suffix); |
|
| 2289 | + if (is_array($buff)) |
|
| 2290 | + { |
|
| 2291 | + $suffix = array_pop($buff); |
|
| 2292 | + } |
|
| 2293 | + // take the last extension to check with ext2mime |
|
| 2294 | + if (!empty($suffix)) |
|
| 2295 | + { |
|
| 2296 | + $sfxMimeType = mime_magic::ext2mime($suffix); |
|
| 2297 | + } |
|
| 2025 | 2298 | if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') |
| 2026 | 2299 | { |
| 2027 | 2300 | $attachments[$key]['mimeType'] = $sfxMimeType; |
@@ -2191,9 +2464,12 @@ discard block |
||
| 2191 | 2464 | function quotaDisplay($_usage, $_limit) |
| 2192 | 2465 | { |
| 2193 | 2466 | |
| 2194 | - if($_limit == 0) { |
|
| 2467 | + if($_limit == 0) |
|
| 2468 | + { |
|
| 2195 | 2469 | $quotaPercent=100; |
| 2196 | - } else { |
|
| 2470 | + } |
|
| 2471 | + else |
|
| 2472 | + { |
|
| 2197 | 2473 | $quotaPercent=round(($_usage*100)/$_limit); |
| 2198 | 2474 | } |
| 2199 | 2475 | |
@@ -2201,22 +2477,33 @@ discard block |
||
| 2201 | 2477 | $quotaUsage=mail_bo::show_readable_size($_usage*1024); |
| 2202 | 2478 | |
| 2203 | 2479 | |
| 2204 | - if($quotaPercent > 90 && $_limit>0) { |
|
| 2480 | + if($quotaPercent > 90 && $_limit>0) |
|
| 2481 | + { |
|
| 2205 | 2482 | $quotaBG='mail-index_QuotaRed'; |
| 2206 | - } elseif($quotaPercent > 80 && $_limit>0) { |
|
| 2483 | + } |
|
| 2484 | + elseif($quotaPercent > 80 && $_limit>0) |
|
| 2485 | + { |
|
| 2207 | 2486 | $quotaBG='mail-index_QuotaYellow'; |
| 2208 | - } else { |
|
| 2487 | + } |
|
| 2488 | + else |
|
| 2489 | + { |
|
| 2209 | 2490 | $quotaBG='mail-index_QuotaGreen'; |
| 2210 | 2491 | } |
| 2211 | 2492 | |
| 2212 | - if($_limit > 0) { |
|
| 2493 | + if($_limit > 0) |
|
| 2494 | + { |
|
| 2213 | 2495 | $quotaText = $quotaUsage .'/'.$quotaLimit; |
| 2214 | - } else { |
|
| 2496 | + } |
|
| 2497 | + else |
|
| 2498 | + { |
|
| 2215 | 2499 | $quotaText = $quotaUsage; |
| 2216 | 2500 | } |
| 2217 | 2501 | |
| 2218 | - if($quotaPercent > 50) { |
|
| 2219 | - } else { |
|
| 2502 | + if($quotaPercent > 50) |
|
| 2503 | + { |
|
| 2504 | + } |
|
| 2505 | + else |
|
| 2506 | + { |
|
| 2220 | 2507 | } |
| 2221 | 2508 | $quota['class'] = $quotaBG; |
| 2222 | 2509 | $quota['text'] = lang('Quota: %1',$quotaText); |
@@ -2234,7 +2521,10 @@ discard block |
||
| 2234 | 2521 | $uid = $_GET['uid']; |
| 2235 | 2522 | $cid = base64_decode($_GET['cid']); |
| 2236 | 2523 | $partID = urldecode($_GET['partID']); |
| 2237 | - if (!empty($_GET['mailbox'])) $mailbox = base64_decode($_GET['mailbox']); |
|
| 2524 | + if (!empty($_GET['mailbox'])) |
|
| 2525 | + { |
|
| 2526 | + $mailbox = base64_decode($_GET['mailbox']); |
|
| 2527 | + } |
|
| 2238 | 2528 | |
| 2239 | 2529 | //error_log(__METHOD__.__LINE__.":$uid, $cid, $partID"); |
| 2240 | 2530 | $this->mail_bo->reopen($mailbox); |
@@ -2266,7 +2556,10 @@ discard block |
||
| 2266 | 2556 | |
| 2267 | 2557 | function getAttachment() |
| 2268 | 2558 | { |
| 2269 | - if(isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 2559 | + if(isset($_GET['id'])) |
|
| 2560 | + { |
|
| 2561 | + $rowID = $_GET['id']; |
|
| 2562 | + } |
|
| 2270 | 2563 | |
| 2271 | 2564 | $hA = self::splitRowID($rowID); |
| 2272 | 2565 | $uid = $hA['msgUID']; |
@@ -2299,10 +2592,20 @@ discard block |
||
| 2299 | 2592 | $sfxMimeType = $attachment['type']; |
| 2300 | 2593 | $buff = explode('.',$attachment['filename']); |
| 2301 | 2594 | $suffix = ''; |
| 2302 | - if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
|
| 2303 | - if (!empty($suffix)) $sfxMimeType = mime_magic::ext2mime($suffix); |
|
| 2595 | + if (is_array($buff)) |
|
| 2596 | + { |
|
| 2597 | + $suffix = array_pop($buff); |
|
| 2598 | + } |
|
| 2599 | + // take the last extension to check with ext2mime |
|
| 2600 | + if (!empty($suffix)) |
|
| 2601 | + { |
|
| 2602 | + $sfxMimeType = mime_magic::ext2mime($suffix); |
|
| 2603 | + } |
|
| 2304 | 2604 | $attachment['type'] = $sfxMimeType; |
| 2305 | - if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') $attachment['type'] = strtoupper($sfxMimeType); |
|
| 2605 | + if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') |
|
| 2606 | + { |
|
| 2607 | + $attachment['type'] = strtoupper($sfxMimeType); |
|
| 2608 | + } |
|
| 2306 | 2609 | } |
| 2307 | 2610 | //error_log(__METHOD__.print_r($attachment,true)); |
| 2308 | 2611 | if (strtoupper($attachment['type']) == 'TEXT/CALENDAR' || strtoupper($attachment['type']) == 'TEXT/X-VCALENDAR') |
@@ -2311,7 +2614,10 @@ discard block |
||
| 2311 | 2614 | $calendar_ical = new calendar_ical(); |
| 2312 | 2615 | $eventid = $calendar_ical->search($attachment['attachment'],-1); |
| 2313 | 2616 | //error_log(__METHOD__.array2string($eventid)); |
| 2314 | - if (!$eventid) $eventid = -1; |
|
| 2617 | + if (!$eventid) |
|
| 2618 | + { |
|
| 2619 | + $eventid = -1; |
|
| 2620 | + } |
|
| 2315 | 2621 | $event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true,0,'',null,$attachment['charset']); |
| 2316 | 2622 | //error_log(__METHOD__.$event); |
| 2317 | 2623 | if ((int)$event > 0) |
@@ -2337,7 +2643,10 @@ discard block |
||
| 2337 | 2643 | //error_log(__METHOD__.__LINE__.print_r($vcard,true)); |
| 2338 | 2644 | $contact = $addressbook_vcal->find_contact($vcard,false); |
| 2339 | 2645 | } |
| 2340 | - if (!$contact) $contact = null; |
|
| 2646 | + if (!$contact) |
|
| 2647 | + { |
|
| 2648 | + $contact = null; |
|
| 2649 | + } |
|
| 2341 | 2650 | // 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)) |
| 2342 | 2651 | if ($contact || count($vcard)>2) |
| 2343 | 2652 | { |
@@ -2371,9 +2680,18 @@ discard block |
||
| 2371 | 2680 | function saveMessage() |
| 2372 | 2681 | { |
| 2373 | 2682 | $display = false; |
| 2374 | - if(isset($_GET['id'])) $rowID = $_GET['id']; |
|
| 2375 | - if(isset($_GET['part'])) $partID = $_GET['part']; |
|
| 2376 | - if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager')) $display = $_GET['location']; |
|
| 2683 | + if(isset($_GET['id'])) |
|
| 2684 | + { |
|
| 2685 | + $rowID = $_GET['id']; |
|
| 2686 | + } |
|
| 2687 | + if(isset($_GET['part'])) |
|
| 2688 | + { |
|
| 2689 | + $partID = $_GET['part']; |
|
| 2690 | + } |
|
| 2691 | + if (isset($_GET['location'])&& ($_GET['location']=='display'||$_GET['location']=='filemanager')) |
|
| 2692 | + { |
|
| 2693 | + $display = $_GET['location']; |
|
| 2694 | + } |
|
| 2377 | 2695 | |
| 2378 | 2696 | $hA = self::splitRowID($rowID); |
| 2379 | 2697 | $uid = $hA['msgUID']; |
@@ -2462,7 +2780,10 @@ discard block |
||
| 2462 | 2780 | { |
| 2463 | 2781 | $succeeded = true; |
| 2464 | 2782 | } |
| 2465 | - if ($fp) fclose($fp); |
|
| 2783 | + if ($fp) |
|
| 2784 | + { |
|
| 2785 | + fclose($fp); |
|
| 2786 | + } |
|
| 2466 | 2787 | if ($succeeded) |
| 2467 | 2788 | { |
| 2468 | 2789 | unset($headers['SUBJECT']);//already in filename |
@@ -2512,7 +2833,8 @@ discard block |
||
| 2512 | 2833 | * |
| 2513 | 2834 | * @return array an array of parameters |
| 2514 | 2835 | */ |
| 2515 | - $getParams = function ($id) { |
|
| 2836 | + $getParams = function ($id) |
|
| 2837 | + { |
|
| 2516 | 2838 | list($app,$user,$serverID,$mailbox,$uid,$part,$is_winmail,$name) = explode('::',$id,8); |
| 2517 | 2839 | $lId = implode('::',array($app,$user,$serverID,$mailbox,$uid)); |
| 2518 | 2840 | $hA = mail_ui::splitRowID($lId); |
@@ -2548,7 +2870,10 @@ discard block |
||
| 2548 | 2870 | { |
| 2549 | 2871 | $params = $getParams($id); |
| 2550 | 2872 | // when downloading a single file, name is not set |
| 2551 | - if (!$params['name']&&isset($_GET['name'])&&!$isMultipleDownload) $params['name'] = $_GET['name']; |
|
| 2873 | + if (!$params['name']&&isset($_GET['name'])&&!$isMultipleDownload) |
|
| 2874 | + { |
|
| 2875 | + $params['name'] = $_GET['name']; |
|
| 2876 | + } |
|
| 2552 | 2877 | if ($params['icServer'] && $params['icServer'] != $this->mail_bo->profileID) |
| 2553 | 2878 | { |
| 2554 | 2879 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
@@ -2561,7 +2886,10 @@ discard block |
||
| 2561 | 2886 | // Try to find the right content for file id |
| 2562 | 2887 | foreach ($attachments as $key => $val) |
| 2563 | 2888 | { |
| 2564 | - if ($key == $params['is_winmail']) $attachment = $val; |
|
| 2889 | + if ($key == $params['is_winmail']) |
|
| 2890 | + { |
|
| 2891 | + $attachment = $val; |
|
| 2892 | + } |
|
| 2565 | 2893 | } |
| 2566 | 2894 | } |
| 2567 | 2895 | else |
@@ -2608,7 +2936,10 @@ discard block |
||
| 2608 | 2936 | { |
| 2609 | 2937 | //error_log(__METHOD__.__LINE__.array2string($_GET)); |
| 2610 | 2938 | // First, get all attachment IDs |
| 2611 | - if(isset($_GET['id'])) $message_id = $_GET['id']; |
|
| 2939 | + if(isset($_GET['id'])) |
|
| 2940 | + { |
|
| 2941 | + $message_id = $_GET['id']; |
|
| 2942 | + } |
|
| 2612 | 2943 | //error_log(__METHOD__.__LINE__.$message_id); |
| 2613 | 2944 | $rememberServerID = $this->mail_bo->profileID; |
| 2614 | 2945 | if(!is_numeric($message_id)) |
@@ -2635,7 +2966,10 @@ discard block |
||
| 2635 | 2966 | //get_home_dir may fetch the users startfolder if set; if not writeable, action will fail. TODO: use temp_dir |
| 2636 | 2967 | $homedir = '/home/'.$GLOBALS['egw_info']['user']['account_lid']; |
| 2637 | 2968 | $temp_path = $homedir/*egw_vfs::get_home_dir()*/ . "/.mail_$message_id"; |
| 2638 | - if(egw_vfs::is_dir($temp_path)) egw_vfs::remove ($temp_path); |
|
| 2969 | + if(egw_vfs::is_dir($temp_path)) |
|
| 2970 | + { |
|
| 2971 | + egw_vfs::remove ($temp_path); |
|
| 2972 | + } |
|
| 2639 | 2973 | |
| 2640 | 2974 | // Add subject to path, so it gets used as the file name |
| 2641 | 2975 | $path = $temp_path . '/' . ($header['SUBJECT'] ? egw_vfs::encodePathComponent($header['SUBJECT']) : lang('mail')) .'/'; |
@@ -2659,7 +2993,10 @@ discard block |
||
| 2659 | 2993 | foreach ($tnefAttachments as $key => $val) |
| 2660 | 2994 | { |
| 2661 | 2995 | error_log(__METHOD__.' winmail = '.$key); |
| 2662 | - if ($key == $file['is_winmail']) $attachment = $val; |
|
| 2996 | + if ($key == $file['is_winmail']) |
|
| 2997 | + { |
|
| 2998 | + $attachment = $val; |
|
| 2999 | + } |
|
| 2663 | 3000 | } |
| 2664 | 3001 | } |
| 2665 | 3002 | else |
@@ -2667,15 +3004,24 @@ discard block |
||
| 2667 | 3004 | $attachment = $this->mail_bo->getAttachment($message_id,$file['partID'],$file['is_winmail'],false,true); |
| 2668 | 3005 | } |
| 2669 | 3006 | $success=true; |
| 2670 | - if (empty($file['filename'])) $file['filename'] = $file['name']; |
|
| 3007 | + if (empty($file['filename'])) |
|
| 3008 | + { |
|
| 3009 | + $file['filename'] = $file['name']; |
|
| 3010 | + } |
|
| 2671 | 3011 | if (!($fp = egw_vfs::fopen($path.$file['filename'],'wb')) || |
| 2672 | 3012 | !(!fseek($attachment['attachment'], 0, SEEK_SET) && stream_copy_to_stream($attachment['attachment'], $fp))) |
| 2673 | 3013 | { |
| 2674 | 3014 | $success=false; |
| 2675 | 3015 | egw_framework::message("Unable to zip {$file['filename']}",'error'); |
| 2676 | 3016 | } |
| 2677 | - if ($success) $file_list[] = $path.$file['filename']; |
|
| 2678 | - if ($fp) fclose($fp); |
|
| 3017 | + if ($success) |
|
| 3018 | + { |
|
| 3019 | + $file_list[] = $path.$file['filename']; |
|
| 3020 | + } |
|
| 3021 | + if ($fp) |
|
| 3022 | + { |
|
| 3023 | + fclose($fp); |
|
| 3024 | + } |
|
| 2679 | 3025 | } |
| 2680 | 3026 | $this->mail_bo->closeConnection(); |
| 2681 | 3027 | if ($rememberServerID != $this->mail_bo->profileID) |
@@ -2702,7 +3048,10 @@ discard block |
||
| 2702 | 3048 | $this->uid = $uid; |
| 2703 | 3049 | $this->partID = $partID; |
| 2704 | 3050 | $bufferHtmlOptions = $this->mail_bo->htmlOptions; |
| 2705 | - if (empty($htmlOptions)) $htmlOptions = $this->mail_bo->htmlOptions; |
|
| 3051 | + if (empty($htmlOptions)) |
|
| 3052 | + { |
|
| 3053 | + $htmlOptions = $this->mail_bo->htmlOptions; |
|
| 3054 | + } |
|
| 2706 | 3055 | // fetching structure now, to supply it to getMessageBody and getMessageAttachment, so it does not get fetched twice |
| 2707 | 3056 | $structure = $this->mail_bo->getStructure($uid, $partID, $mailbox, false); |
| 2708 | 3057 | $bodyParts = $this->mail_bo->getMessageBody($uid, ($htmlOptions?$htmlOptions:''), $partID, $structure, false, $mailbox); |
@@ -2766,10 +3115,16 @@ discard block |
||
| 2766 | 3115 | <table width="100%" style="table-layout:fixed"><tr><td class="td_display">'; |
| 2767 | 3116 | |
| 2768 | 3117 | $EndBody = '</td></tr></table></div>'; |
| 2769 | - if ($fullPageTags) $EndBody .= "</body></html>"; |
|
| 2770 | - if ($print) { |
|
| 3118 | + if ($fullPageTags) |
|
| 3119 | + { |
|
| 3120 | + $EndBody .= "</body></html>"; |
|
| 3121 | + } |
|
| 3122 | + if ($print) |
|
| 3123 | + { |
|
| 2771 | 3124 | print $BeginBody. $body .$EndBody; |
| 2772 | - } else { |
|
| 3125 | + } |
|
| 3126 | + else |
|
| 3127 | + { |
|
| 2773 | 3128 | return $BeginBody. $body .$EndBody; |
| 2774 | 3129 | } |
| 2775 | 3130 | } |
@@ -2785,9 +3140,14 @@ discard block |
||
| 2785 | 3140 | $body = ''; |
| 2786 | 3141 | |
| 2787 | 3142 | //error_log(__METHOD__.array2string($bodyParts)); //exit; |
| 2788 | - if (empty($bodyParts)) return ""; |
|
| 2789 | - foreach((array)$bodyParts as $singleBodyPart) { |
|
| 2790 | - if (!isset($singleBodyPart['body'])) { |
|
| 3143 | + if (empty($bodyParts)) |
|
| 3144 | + { |
|
| 3145 | + return ""; |
|
| 3146 | + } |
|
| 3147 | + foreach((array)$bodyParts as $singleBodyPart) |
|
| 3148 | + { |
|
| 3149 | + if (!isset($singleBodyPart['body'])) |
|
| 3150 | + { |
|
| 2791 | 3151 | $singleBodyPart['body'] = $this->getdisplayableBody($singleBodyPart,$modifyURI,$useTidy); |
| 2792 | 3152 | $body .= $singleBodyPart['body']; |
| 2793 | 3153 | continue; |
@@ -2798,7 +3158,8 @@ discard block |
||
| 2798 | 3158 | $body .= ''; |
| 2799 | 3159 | continue; |
| 2800 | 3160 | } |
| 2801 | - if(!empty($body)) { |
|
| 3161 | + if(!empty($body)) |
|
| 3162 | + { |
|
| 2802 | 3163 | $body .= '<hr style="border:dotted 1px silver;">'; |
| 2803 | 3164 | } |
| 2804 | 3165 | //error_log($singleBodyPart['body']); |
@@ -2836,16 +3197,25 @@ discard block |
||
| 2836 | 3197 | $newBody = @htmlentities($singleBodyPart['body'],ENT_QUOTES, strtoupper(mail_bo::$displayCharset)); |
| 2837 | 3198 | //error_log(__METHOD__.__LINE__.'..'.$newBody); |
| 2838 | 3199 | // if empty and charset is utf8 try sanitizing the string in question |
| 2839 | - if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8') $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(mail_bo::$displayCharset)); |
|
| 3200 | + if (empty($newBody) && strtolower($singleBodyPart['charSet'])=='utf-8') |
|
| 3201 | + { |
|
| 3202 | + $newBody = @htmlentities(iconv('utf-8', 'utf-8', $singleBodyPart['body']),ENT_QUOTES, strtoupper(mail_bo::$displayCharset)); |
|
| 3203 | + } |
|
| 2840 | 3204 | // if the conversion to htmlentities fails somehow, try without specifying the charset, which defaults to iso- |
| 2841 | - if (empty($newBody)) $newBody = htmlentities($singleBodyPart['body'],ENT_QUOTES); |
|
| 3205 | + if (empty($newBody)) |
|
| 3206 | + { |
|
| 3207 | + $newBody = htmlentities($singleBodyPart['body'],ENT_QUOTES); |
|
| 3208 | + } |
|
| 2842 | 3209 | |
| 2843 | 3210 | // search http[s] links and make them as links available again |
| 2844 | 3211 | // to understand what's going on here, have a look at |
| 2845 | 3212 | // http://www.php.net/manual/en/function.preg-replace.php |
| 2846 | 3213 | |
| 2847 | 3214 | // create links for websites |
| 2848 | - if ($modifyURI) $newBody = html::activate_links($newBody); |
|
| 3215 | + if ($modifyURI) |
|
| 3216 | + { |
|
| 3217 | + $newBody = html::activate_links($newBody); |
|
| 3218 | + } |
|
| 2849 | 3219 | //error_log(__METHOD__.__LINE__.'..'.$newBody); |
| 2850 | 3220 | // redirect links for websites if you use no cookies |
| 2851 | 3221 | #if (!($GLOBALS['egw_info']['server']['usecookies'])) |
@@ -2912,7 +3282,10 @@ discard block |
||
| 2912 | 3282 | // as we switched off HTMLaweds tidy functionality |
| 2913 | 3283 | $newBody = str_replace(array('&amp;','<DIV><BR></DIV>',"<DIV> </DIV>",'<div> </div>'),array('&','<BR>','<BR>','<BR>'),$newBody); |
| 2914 | 3284 | $newBody = $htmLawed->egw_htmLawed($newBody,mail_bo::$htmLawed_config); |
| 2915 | - if ($hasOther && $preserveHTML) $newBody = $matches[1]. $newBody. $matches[3]; |
|
| 3285 | + if ($hasOther && $preserveHTML) |
|
| 3286 | + { |
|
| 3287 | + $newBody = $matches[1]. $newBody. $matches[3]; |
|
| 3288 | + } |
|
| 2916 | 3289 | $alreadyHtmlLawed=true; |
| 2917 | 3290 | } |
| 2918 | 3291 | // do the cleanup, set for the use of purifier |
@@ -3017,7 +3390,10 @@ discard block |
||
| 3017 | 3390 | */ |
| 3018 | 3391 | $replace_callback = function ($matches) use ($_mailbox,$_uid, $_partID, $_type) |
| 3019 | 3392 | { |
| 3020 | - if (!$_type) return false; |
|
| 3393 | + if (!$_type) |
|
| 3394 | + { |
|
| 3395 | + return false; |
|
| 3396 | + } |
|
| 3021 | 3397 | $CID = ''; |
| 3022 | 3398 | // Build up matches according to selected type |
| 3023 | 3399 | switch ($_type) |
@@ -3060,9 +3436,12 @@ discard block |
||
| 3060 | 3436 | $attachment = $bo->getAttachmentByCID($_uid, $CID, $_partID); |
| 3061 | 3437 | |
| 3062 | 3438 | // only use data uri for "smaller" images, as otherwise the first display of the mail takes to long |
| 3063 | - if (($attachment instanceof Horde_Mime_Part) && $attachment->getBytes() < 8192) // msie=8 allows max 32k data uris |
|
| 3439 | + if (($attachment instanceof Horde_Mime_Part) && $attachment->getBytes() < 8192) |
|
| 3440 | + { |
|
| 3441 | + // msie=8 allows max 32k data uris |
|
| 3064 | 3442 | { |
| 3065 | 3443 | $bo->fetchPartContents($_uid, $attachment); |
| 3444 | + } |
|
| 3066 | 3445 | $cache[$imageURL] = 'data:'.$attachment->getType().';base64,'.base64_encode($attachment->getContents()); |
| 3067 | 3446 | } |
| 3068 | 3447 | else |
@@ -3134,7 +3513,10 @@ discard block |
||
| 3134 | 3513 | } |
| 3135 | 3514 | $destination = $content['FOLDER'][0]; |
| 3136 | 3515 | |
| 3137 | - if (stripos($destination,self::$delimiter)!==false) list($icServerID,$destination) = explode(self::$delimiter,$destination,2); |
|
| 3516 | + if (stripos($destination,self::$delimiter)!==false) |
|
| 3517 | + { |
|
| 3518 | + list($icServerID,$destination) = explode(self::$delimiter,$destination,2); |
|
| 3519 | + } |
|
| 3138 | 3520 | if ($icServerID && $icServerID != $this->mail_bo->profileID) |
| 3139 | 3521 | { |
| 3140 | 3522 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
@@ -3159,14 +3541,26 @@ discard block |
||
| 3159 | 3541 | if (!$importFailed) |
| 3160 | 3542 | { |
| 3161 | 3543 | list($width, $height) = explode('x', egw_link::get_registry('mail', 'add_popup')); |
| 3162 | - if ($width > 0 && $height > 0) egw_json_response::get()->call('resizeTo', $width, $height); |
|
| 3544 | + if ($width > 0 && $height > 0) |
|
| 3545 | + { |
|
| 3546 | + egw_json_response::get()->call('resizeTo', $width, $height); |
|
| 3547 | + } |
|
| 3163 | 3548 | ExecMethod2('mail.mail_ui.displayMessage',$linkData); |
| 3164 | 3549 | return; |
| 3165 | 3550 | } |
| 3166 | 3551 | } |
| 3167 | - if (!is_array($content)) $content = array(); |
|
| 3168 | - if (empty($content['FOLDER'])) $content['FOLDER']=(array)$this->mail_bo->getDraftFolder(); |
|
| 3169 | - if (!empty($content['FOLDER'])) $sel_options['FOLDER']=mail_compose::ajax_searchFolder(0,true); |
|
| 3552 | + if (!is_array($content)) |
|
| 3553 | + { |
|
| 3554 | + $content = array(); |
|
| 3555 | + } |
|
| 3556 | + if (empty($content['FOLDER'])) |
|
| 3557 | + { |
|
| 3558 | + $content['FOLDER']=(array)$this->mail_bo->getDraftFolder(); |
|
| 3559 | + } |
|
| 3560 | + if (!empty($content['FOLDER'])) |
|
| 3561 | + { |
|
| 3562 | + $sel_options['FOLDER']=mail_compose::ajax_searchFolder(0,true); |
|
| 3563 | + } |
|
| 3170 | 3564 | |
| 3171 | 3565 | $etpl = new etemplate_new('mail.importMessage'); |
| 3172 | 3566 | $etpl->setElementAttribute('uploadForImport','onFinish','app.mail.uploadForImport'); |
@@ -3186,7 +3580,10 @@ discard block |
||
| 3186 | 3580 | { |
| 3187 | 3581 | $importfailed = false; |
| 3188 | 3582 | //error_log(__METHOD__.__LINE__.array2string($_formData)); |
| 3189 | - if (empty($_formData['file'])) $_formData['file'] = $_formData['tmp_name']; |
|
| 3583 | + if (empty($_formData['file'])) |
|
| 3584 | + { |
|
| 3585 | + $_formData['file'] = $_formData['tmp_name']; |
|
| 3586 | + } |
|
| 3190 | 3587 | // check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.) |
| 3191 | 3588 | try |
| 3192 | 3589 | { |
@@ -3217,10 +3614,14 @@ discard block |
||
| 3217 | 3614 | $alert_msg .= lang("Import of message %1 failed. Destination Folder not set.",$_formData['name']); |
| 3218 | 3615 | } |
| 3219 | 3616 | $delimiter = $this->mail_bo->getHierarchyDelimiter(); |
| 3220 | - if($_folder=='INBOX'.$delimiter) $_folder='INBOX'; |
|
| 3617 | + if($_folder=='INBOX'.$delimiter) |
|
| 3618 | + { |
|
| 3619 | + $_folder='INBOX'; |
|
| 3620 | + } |
|
| 3221 | 3621 | if ($importfailed === false) |
| 3222 | 3622 | { |
| 3223 | - if ($this->mail_bo->folderExists($_folder,true)) { |
|
| 3623 | + if ($this->mail_bo->folderExists($_folder,true)) |
|
| 3624 | + { |
|
| 3224 | 3625 | try |
| 3225 | 3626 | { |
| 3226 | 3627 | $messageUid = $this->mail_bo->appendMessage($_folder, |
@@ -3281,7 +3682,10 @@ discard block |
||
| 3281 | 3682 | */ |
| 3282 | 3683 | function importMessageFromVFS2DraftAndDisplay($formData='',$mode='display') |
| 3283 | 3684 | { |
| 3284 | - if (empty($formData)) if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData']; |
|
| 3685 | + if (empty($formData)) |
|
| 3686 | + { |
|
| 3687 | + if (isset($_REQUEST['formData'])) $formData = $_REQUEST['formData']; |
|
| 3688 | + } |
|
| 3285 | 3689 | //error_log(__METHOD__.__LINE__.':'.array2string($formData).' Mode:'.$mode.'->'.function_backtrace()); |
| 3286 | 3690 | $draftFolder = $this->mail_bo->getDraftFolder(false); |
| 3287 | 3691 | $importID = mail_bo::getRandomString(); |
@@ -3295,15 +3699,26 @@ discard block |
||
| 3295 | 3699 | if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['name'])) |
| 3296 | 3700 | { |
| 3297 | 3701 | $buff = explode('/',$formData['file']); |
| 3298 | - if (is_array($buff)) $formData['name'] = array_pop($buff); // take the last part as name |
|
| 3702 | + if (is_array($buff)) |
|
| 3703 | + { |
|
| 3704 | + $formData['name'] = array_pop($buff); |
|
| 3705 | + } |
|
| 3706 | + // take the last part as name |
|
| 3299 | 3707 | } |
| 3300 | 3708 | // type should be set to meet the requirements of checkFileBasics |
| 3301 | 3709 | if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && empty($formData['type'])) |
| 3302 | 3710 | { |
| 3303 | 3711 | $buff = explode('.',$formData['file']); |
| 3304 | 3712 | $suffix = ''; |
| 3305 | - if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
|
| 3306 | - if (!empty($suffix)) $formData['type'] = mime_magic::ext2mime($suffix); |
|
| 3713 | + if (is_array($buff)) |
|
| 3714 | + { |
|
| 3715 | + $suffix = array_pop($buff); |
|
| 3716 | + } |
|
| 3717 | + // take the last extension to check with ext2mime |
|
| 3718 | + if (!empty($suffix)) |
|
| 3719 | + { |
|
| 3720 | + $formData['type'] = mime_magic::ext2mime($suffix); |
|
| 3721 | + } |
|
| 3307 | 3722 | } |
| 3308 | 3723 | // size should be set to meet the requirements of checkFileBasics |
| 3309 | 3724 | if (parse_url($formData['file'],PHP_URL_SCHEME) == 'vfs' && !isset($formData['size'])) |
@@ -3346,17 +3761,35 @@ discard block |
||
| 3346 | 3761 | function loadEmailBody($_messageID=null,$_partID=null,$_htmloptions=null) |
| 3347 | 3762 | { |
| 3348 | 3763 | //error_log(__METHOD__.__LINE__.array2string($_GET)); |
| 3349 | - if (!$_messageID && !empty($_GET['_messageID'])) $_messageID = $_GET['_messageID']; |
|
| 3350 | - if (!$_partID && !empty($_GET['_partID'])) $_partID = $_GET['_partID']; |
|
| 3351 | - if (!$_htmloptions && !empty($_GET['_htmloptions'])) $_htmloptions = $_GET['_htmloptions']; |
|
| 3352 | - if(mail_bo::$debug) error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions"); |
|
| 3353 | - if (empty($_messageID)) return ""; |
|
| 3764 | + if (!$_messageID && !empty($_GET['_messageID'])) |
|
| 3765 | + { |
|
| 3766 | + $_messageID = $_GET['_messageID']; |
|
| 3767 | + } |
|
| 3768 | + if (!$_partID && !empty($_GET['_partID'])) |
|
| 3769 | + { |
|
| 3770 | + $_partID = $_GET['_partID']; |
|
| 3771 | + } |
|
| 3772 | + if (!$_htmloptions && !empty($_GET['_htmloptions'])) |
|
| 3773 | + { |
|
| 3774 | + $_htmloptions = $_GET['_htmloptions']; |
|
| 3775 | + } |
|
| 3776 | + if(mail_bo::$debug) |
|
| 3777 | + { |
|
| 3778 | + error_log(__METHOD__."->".print_r($_messageID,true).",$_partID,$_htmloptions"); |
|
| 3779 | + } |
|
| 3780 | + if (empty($_messageID)) |
|
| 3781 | + { |
|
| 3782 | + return ""; |
|
| 3783 | + } |
|
| 3354 | 3784 | $uidA = self::splitRowID($_messageID); |
| 3355 | 3785 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
| 3356 | 3786 | $messageID = $uidA['msgUID']; |
| 3357 | 3787 | $icServerID = $uidA['profileID']; |
| 3358 | 3788 | //something went wrong. there is a $_messageID but no $messageID: means $_messageID is crippeled |
| 3359 | - if (empty($messageID)) return ""; |
|
| 3789 | + if (empty($messageID)) |
|
| 3790 | + { |
|
| 3791 | + return ""; |
|
| 3792 | + } |
|
| 3360 | 3793 | if ($icServerID && $icServerID != $this->mail_bo->profileID) |
| 3361 | 3794 | { |
| 3362 | 3795 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
@@ -3389,11 +3822,18 @@ discard block |
||
| 3389 | 3822 | list($profileID,$folderName) = explode(self::$delimiter,$_folderName,2); |
| 3390 | 3823 | if (is_numeric($profileID)) |
| 3391 | 3824 | { |
| 3392 | - if ($profileID != $this->mail_bo->profileID) continue; // only current connection |
|
| 3825 | + if ($profileID != $this->mail_bo->profileID) |
|
| 3826 | + { |
|
| 3827 | + continue; |
|
| 3828 | + } |
|
| 3829 | + // only current connection |
|
| 3393 | 3830 | if ($folderName) |
| 3394 | 3831 | { |
| 3395 | 3832 | $fS = $this->mail_bo->getFolderStatus($folderName,false,false,false); |
| 3396 | - if (in_array($fS['shortDisplayName'],mail_bo::$autoFolders)) $fS['shortDisplayName']=lang($fS['shortDisplayName']); |
|
| 3833 | + if (in_array($fS['shortDisplayName'],mail_bo::$autoFolders)) |
|
| 3834 | + { |
|
| 3835 | + $fS['shortDisplayName']=lang($fS['shortDisplayName']); |
|
| 3836 | + } |
|
| 3397 | 3837 | //error_log(__METHOD__.__LINE__.array2string($fS)); |
| 3398 | 3838 | if ($fS['unseen']) |
| 3399 | 3839 | { |
@@ -3434,7 +3874,11 @@ discard block |
||
| 3434 | 3874 | list($profileID,$parentFolderName) = explode(self::$delimiter,$decodedFolderName,2); |
| 3435 | 3875 | if (is_numeric($profileID)) |
| 3436 | 3876 | { |
| 3437 | - if ($profileID != $this->mail_bo->profileID) return; // only current connection |
|
| 3877 | + if ($profileID != $this->mail_bo->profileID) |
|
| 3878 | + { |
|
| 3879 | + return; |
|
| 3880 | + } |
|
| 3881 | + // only current connection |
|
| 3438 | 3882 | $del = $this->mail_bo->getHierarchyDelimiter(false); |
| 3439 | 3883 | //$del = $prefix = ''; |
| 3440 | 3884 | //$nameSpace = $this->mail_bo->_getNameSpaces(); |
@@ -3474,7 +3918,10 @@ discard block |
||
| 3474 | 3918 | $nA = explode($del,$_newName); |
| 3475 | 3919 | |
| 3476 | 3920 | //error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName"); |
| 3477 | - if (!!empty($parentFolderName)) $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName,false); |
|
| 3921 | + if (!!empty($parentFolderName)) |
|
| 3922 | + { |
|
| 3923 | + $oldFolderInfo = $this->mail_bo->getFolderStatus($parentFolderName,false); |
|
| 3924 | + } |
|
| 3478 | 3925 | //error_log(__METHOD__.__LINE__.array2string($oldFolderInfo)); |
| 3479 | 3926 | |
| 3480 | 3927 | $this->mail_bo->reopen('INBOX'); |
@@ -3495,9 +3942,15 @@ discard block |
||
| 3495 | 3942 | $errorMessage .= $error; |
| 3496 | 3943 | } |
| 3497 | 3944 | } |
| 3498 | - if ($c==count($nA)) $created=true; |
|
| 3945 | + if ($c==count($nA)) |
|
| 3946 | + { |
|
| 3947 | + $created=true; |
|
| 3948 | + } |
|
| 3949 | + } |
|
| 3950 | + if (!empty($parentName)) |
|
| 3951 | + { |
|
| 3952 | + $this->mail_bo->reopen($parentName); |
|
| 3499 | 3953 | } |
| 3500 | - if (!empty($parentName)) $this->mail_bo->reopen($parentName); |
|
| 3501 | 3954 | } |
| 3502 | 3955 | //error_log(__METHOD__.__LINE__.array2string($oA)); |
| 3503 | 3956 | if ($created===true) |
@@ -3533,7 +3986,10 @@ discard block |
||
| 3533 | 3986 | */ |
| 3534 | 3987 | function ajax_renameFolder($_folderName, $_newName) |
| 3535 | 3988 | { |
| 3536 | - if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' OldFolderName:'.array2string($_folderName).' NewName:'.array2string($_newName)); |
|
| 3989 | + if (mail_bo::$debug) |
|
| 3990 | + { |
|
| 3991 | + error_log(__METHOD__.__LINE__.' OldFolderName:'.array2string($_folderName).' NewName:'.array2string($_newName)); |
|
| 3992 | + } |
|
| 3537 | 3993 | if ($_folderName) |
| 3538 | 3994 | { |
| 3539 | 3995 | translation::add_app('mail'); |
@@ -3545,7 +4001,11 @@ discard block |
||
| 3545 | 4001 | $hasChildren = false; |
| 3546 | 4002 | if (is_numeric($profileID)) |
| 3547 | 4003 | { |
| 3548 | - if ($profileID != $this->mail_bo->profileID) return; // only current connection |
|
| 4004 | + if ($profileID != $this->mail_bo->profileID) |
|
| 4005 | + { |
|
| 4006 | + return; |
|
| 4007 | + } |
|
| 4008 | + // only current connection |
|
| 3549 | 4009 | $pA = explode($del,$folderName); |
| 3550 | 4010 | array_pop($pA); |
| 3551 | 4011 | $parentFolder = implode($del,$pA); |
@@ -3686,8 +4146,15 @@ discard block |
||
| 3686 | 4146 | list($profileID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
| 3687 | 4147 | // if pref and required mode dont match -> reset the folderObject cache to ensure |
| 3688 | 4148 | // that we get what we request |
| 3689 | - if ($_subscribedOnly != $oldPrefForSubscribedOnly) $this->mail_bo->resetFolderObjectCache($profileID); |
|
| 3690 | - if ($profileID != $this->mail_bo->profileID) return; // only current connection |
|
| 4149 | + if ($_subscribedOnly != $oldPrefForSubscribedOnly) |
|
| 4150 | + { |
|
| 4151 | + $this->mail_bo->resetFolderObjectCache($profileID); |
|
| 4152 | + } |
|
| 4153 | + if ($profileID != $this->mail_bo->profileID) |
|
| 4154 | + { |
|
| 4155 | + return; |
|
| 4156 | + } |
|
| 4157 | + // only current connection |
|
| 3691 | 4158 | if (!empty($folderName)) |
| 3692 | 4159 | { |
| 3693 | 4160 | $parentFolder=(!empty($folderName)?$folderName:'INBOX'); |
@@ -3762,7 +4229,10 @@ discard block |
||
| 3762 | 4229 | */ |
| 3763 | 4230 | function ajax_MoveFolder($_folderName, $_target) |
| 3764 | 4231 | { |
| 3765 | - if (mail_bo::$debug) error_log(__METHOD__.__LINE__."Move Folder: $_folderName to Target: $_target"); |
|
| 4232 | + if (mail_bo::$debug) |
|
| 4233 | + { |
|
| 4234 | + error_log(__METHOD__.__LINE__."Move Folder: $_folderName to Target: $_target"); |
|
| 4235 | + } |
|
| 3766 | 4236 | if ($_folderName) |
| 3767 | 4237 | { |
| 3768 | 4238 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
@@ -3773,7 +4243,11 @@ discard block |
||
| 3773 | 4243 | $hasChildren = false; |
| 3774 | 4244 | if (is_numeric($profileID)) |
| 3775 | 4245 | { |
| 3776 | - if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID) return; // only current connection |
|
| 4246 | + if ($profileID != $this->mail_bo->profileID || $profileID != $newProfileID) |
|
| 4247 | + { |
|
| 4248 | + return; |
|
| 4249 | + } |
|
| 4250 | + // only current connection |
|
| 3777 | 4251 | $pA = explode($del,$folderName); |
| 3778 | 4252 | $namePart = array_pop($pA); |
| 3779 | 4253 | $_newName = $namePart; |
@@ -3784,10 +4258,13 @@ discard block |
||
| 3784 | 4258 | (($oldParentFolder === $parentFolder) || //$oldParentFolder == $parentFolder means move on same level |
| 3785 | 4259 | (($oldParentFolder != $parentFolder && |
| 3786 | 4260 | strlen($parentFolder)>0 && strlen($folderName)>0 && |
| 3787 | - strpos($parentFolder,$folderName)===false)))) // indicates that we move the older up the tree within its own branch |
|
| 4261 | + strpos($parentFolder,$folderName)===false)))) |
|
| 4262 | + { |
|
| 4263 | + // indicates that we move the older up the tree within its own branch |
|
| 3788 | 4264 | { |
| 3789 | 4265 | //error_log(__METHOD__.__LINE__."$folderName, $parentFolder, $_newName"); |
| 3790 | 4266 | $oldFolderInfo = $this->mail_bo->getFolderStatus($folderName,false,false,false); |
| 4267 | + } |
|
| 3791 | 4268 | //error_log(__METHOD__.__LINE__.array2string($oldFolderInfo)); |
| 3792 | 4269 | if (!empty($oldFolderInfo['attributes']) && stripos(array2string($oldFolderInfo['attributes']),'\hasnochildren')=== false) |
| 3793 | 4270 | { |
@@ -3870,8 +4347,14 @@ discard block |
||
| 3870 | 4347 | $profileID.self::$delimiter.$oldParentFolder=>$oldFolderInfo['shortDisplayName'], |
| 3871 | 4348 | $profileID.self::$delimiter.$parentFolder=>$folderInfo['shortDisplayName']); |
| 3872 | 4349 | // if we move the folder within the same parent-branch of the tree, there is no need no refresh the upper part |
| 3873 | - if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$parentFolder]); |
|
| 3874 | - if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false) unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]); |
|
| 4350 | + if (strlen($parentFolder)>strlen($oldParentFolder) && strpos($parentFolder,$oldParentFolder)!==false) |
|
| 4351 | + { |
|
| 4352 | + unset($refreshData[$profileID.self::$delimiter.$parentFolder]); |
|
| 4353 | + } |
|
| 4354 | + if (count($refreshData)>1 && strlen($oldParentFolder)>strlen($parentFolder) && strpos($oldParentFolder,$parentFolder)!==false) |
|
| 4355 | + { |
|
| 4356 | + unset($refreshData[$profileID.self::$delimiter.$oldParentFolder]); |
|
| 4357 | + } |
|
| 3875 | 4358 | |
| 3876 | 4359 | // Send full info back in the response |
| 3877 | 4360 | foreach($refreshData as $folder => &$name) |
@@ -3907,7 +4390,11 @@ discard block |
||
| 3907 | 4390 | $hasChildren = false; |
| 3908 | 4391 | if (is_numeric($profileID)) |
| 3909 | 4392 | { |
| 3910 | - if ($profileID != $this->mail_bo->profileID) return; // only current connection |
|
| 4393 | + if ($profileID != $this->mail_bo->profileID) |
|
| 4394 | + { |
|
| 4395 | + return; |
|
| 4396 | + } |
|
| 4397 | + // only current connection |
|
| 3911 | 4398 | $pA = explode($del,$folderName); |
| 3912 | 4399 | array_pop($pA); |
| 3913 | 4400 | if (strtoupper($folderName)!= 'INBOX') |
@@ -3933,7 +4420,9 @@ discard block |
||
| 3933 | 4420 | } |
| 3934 | 4421 | krsort($ftD,SORT_NUMERIC);//sort per level |
| 3935 | 4422 | //we iterate per level of depth of the subtree, deepest nesting is to be deleted first, and then up the tree |
| 3936 | - foreach($ftD as $k => $lc)//collection per level |
|
| 4423 | + foreach($ftD as $k => $lc) |
|
| 4424 | + { |
|
| 4425 | + //collection per level |
|
| 3937 | 4426 | { |
| 3938 | 4427 | foreach($lc as $i => $f)//folders contained in that level |
| 3939 | 4428 | { |
@@ -3941,8 +4430,12 @@ discard block |
||
| 3941 | 4430 | { |
| 3942 | 4431 | //error_log(__METHOD__.__LINE__.array2string($f).'<->'.$folderName); |
| 3943 | 4432 | $this->mail_bo->deleteFolder($f); |
| 4433 | + } |
|
| 3944 | 4434 | $success = true; |
| 3945 | - if ($f==$folderName) $oA[$_folderName] = $oldFolderInfo['shortDisplayName']; |
|
| 4435 | + if ($f==$folderName) |
|
| 4436 | + { |
|
| 4437 | + $oA[$_folderName] = $oldFolderInfo['shortDisplayName']; |
|
| 4438 | + } |
|
| 3946 | 4439 | } |
| 3947 | 4440 | catch (Exception $e) |
| 3948 | 4441 | { |
@@ -3972,7 +4465,10 @@ discard block |
||
| 3972 | 4465 | $msg = lang("refused to delete folder INBOX"); |
| 3973 | 4466 | } |
| 3974 | 4467 | } |
| 3975 | - if ($_return) return $success; |
|
| 4468 | + if ($_return) |
|
| 4469 | + { |
|
| 4470 | + return $success; |
|
| 4471 | + } |
|
| 3976 | 4472 | $response = egw_json_response::get(); |
| 3977 | 4473 | if ($success) |
| 3978 | 4474 | { |
@@ -4057,19 +4553,29 @@ discard block |
||
| 4057 | 4553 | // Create mail app object |
| 4058 | 4554 | $mail = new mail_ui(); |
| 4059 | 4555 | |
| 4060 | - if (empty($icServerID)) $icServerID = $mail->mail_bo->profileID; |
|
| 4061 | - if ($icServerID != $mail->mail_bo->profileID) return; |
|
| 4556 | + if (empty($icServerID)) |
|
| 4557 | + { |
|
| 4558 | + $icServerID = $mail->mail_bo->profileID; |
|
| 4559 | + } |
|
| 4560 | + if ($icServerID != $mail->mail_bo->profileID) |
|
| 4561 | + { |
|
| 4562 | + return; |
|
| 4563 | + } |
|
| 4062 | 4564 | |
| 4063 | 4565 | $vacation = $mail->gatherVacation($cachedVacations); |
| 4064 | 4566 | } |
| 4065 | 4567 | |
| 4066 | - if($vacation) { |
|
| 4568 | + if($vacation) |
|
| 4569 | + { |
|
| 4067 | 4570 | if (is_array($vacation) && ($vacation['status'] == 'on' || $vacation['status']=='by_date')) |
| 4068 | 4571 | { |
| 4069 | 4572 | $dtfrmt = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat']; |
| 4070 | 4573 | $refreshData['vacationnotice'] = lang('Vacation notice is active'); |
| 4071 | 4574 | $refreshData['vacationrange'] = ($vacation['status']=='by_date'? common::show_date($vacation['start_date'],$dtfrmt,true).($vacation['end_date']>$vacation['start_date']?'->'.common::show_date($vacation['end_date']+ 24*3600-1,$dtfrmt,true):''):''); |
| 4072 | - if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time())$refreshData = ''; |
|
| 4575 | + if ($vacation['status'] == 'by_date' && $vacation['end_date']+ 24*3600 < time()) |
|
| 4576 | + { |
|
| 4577 | + $refreshData = ''; |
|
| 4578 | + } |
|
| 4073 | 4579 | } |
| 4074 | 4580 | } |
| 4075 | 4581 | if ($vacation==false) |
@@ -4091,11 +4597,17 @@ discard block |
||
| 4091 | 4597 | function ajax_refreshFilters($icServerID=null) |
| 4092 | 4598 | { |
| 4093 | 4599 | //error_log(__METHOD__.__LINE__.array2string($icServerId)); |
| 4094 | - if (empty($icServerID)) $icServerID = $this->mail_bo->profileID; |
|
| 4600 | + if (empty($icServerID)) |
|
| 4601 | + { |
|
| 4602 | + $icServerID = $this->mail_bo->profileID; |
|
| 4603 | + } |
|
| 4095 | 4604 | if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) |
| 4096 | 4605 | { |
| 4097 | 4606 | emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
| 4098 | - if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 4607 | + if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) |
|
| 4608 | + { |
|
| 4609 | + emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 4610 | + } |
|
| 4099 | 4611 | } |
| 4100 | 4612 | if (!emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]) |
| 4101 | 4613 | { |
@@ -4116,7 +4628,10 @@ discard block |
||
| 4116 | 4628 | $keywords = array('keyword1','keyword2','keyword3','keyword4','keyword5'); |
| 4117 | 4629 | foreach($keywords as &$k) |
| 4118 | 4630 | { |
| 4119 | - if (array_key_exists($k,$this->statusTypes)) unset($this->statusTypes[$k]); |
|
| 4631 | + if (array_key_exists($k,$this->statusTypes)) |
|
| 4632 | + { |
|
| 4633 | + unset($this->statusTypes[$k]); |
|
| 4634 | + } |
|
| 4120 | 4635 | } |
| 4121 | 4636 | } |
| 4122 | 4637 | |
@@ -4135,7 +4650,10 @@ discard block |
||
| 4135 | 4650 | { |
| 4136 | 4651 | //error_log(__METHOD__.__LINE__.array2string($icServerID)); |
| 4137 | 4652 | translation::add_app('mail'); |
| 4138 | - if (is_null($icServerID)) $icServerID = $this->mail_bo->profileID; |
|
| 4653 | + if (is_null($icServerID)) |
|
| 4654 | + { |
|
| 4655 | + $icServerID = $this->mail_bo->profileID; |
|
| 4656 | + } |
|
| 4139 | 4657 | $rememberServerID = $this->mail_bo->profileID; |
| 4140 | 4658 | if ($icServerID && $icServerID != $this->mail_bo->profileID) |
| 4141 | 4659 | { |
@@ -4145,18 +4663,22 @@ discard block |
||
| 4145 | 4663 | try |
| 4146 | 4664 | { |
| 4147 | 4665 | $quota = $this->mail_bo->getQuotaRoot(); |
| 4148 | - } catch (Exception $e) { |
|
| 4666 | + } |
|
| 4667 | + catch (Exception $e) { |
|
| 4149 | 4668 | $quota['limit'] = 'NOT SET'; |
| 4150 | 4669 | error_log(__METHOD__.__LINE__." ".$e->getMessage()); |
| 4151 | 4670 | } |
| 4152 | 4671 | |
| 4153 | - if($quota !== false && $quota['limit'] != 'NOT SET') { |
|
| 4672 | + if($quota !== false && $quota['limit'] != 'NOT SET') |
|
| 4673 | + { |
|
| 4154 | 4674 | $quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']); |
| 4155 | 4675 | $content['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text']; |
| 4156 | 4676 | $content['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent']; |
| 4157 | 4677 | $content['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class']; |
| 4158 | 4678 | $content['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = ""; |
| 4159 | - } else { |
|
| 4679 | + } |
|
| 4680 | + else |
|
| 4681 | + { |
|
| 4160 | 4682 | $content['quota'] = $sel_options[self::$nm_index]['quota'] = lang("Quota not provided by server"); |
| 4161 | 4683 | $content['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = "mail_DisplayNone"; |
| 4162 | 4684 | $content['quotanotsupported'] = $sel_options[self::$nm_index]['quotanotsupported'] = "mail_DisplayNone"; |
@@ -4189,7 +4711,8 @@ discard block |
||
| 4189 | 4711 | $this->changeProfile($icServerID); |
| 4190 | 4712 | } |
| 4191 | 4713 | $junkFolder = $this->mail_bo->getJunkFolder(); |
| 4192 | - if(!empty($junkFolder)) { |
|
| 4714 | + if(!empty($junkFolder)) |
|
| 4715 | + { |
|
| 4193 | 4716 | if ($selectedFolder == $icServerID.self::$delimiter.$junkFolder) |
| 4194 | 4717 | { |
| 4195 | 4718 | // Lock the tree if the active folder is junk folder |
@@ -4239,7 +4762,8 @@ discard block |
||
| 4239 | 4762 | $this->changeProfile($icServerID); |
| 4240 | 4763 | } |
| 4241 | 4764 | $trashFolder = $this->mail_bo->getTrashFolder(); |
| 4242 | - if(!empty($trashFolder)) { |
|
| 4765 | + if(!empty($trashFolder)) |
|
| 4766 | + { |
|
| 4243 | 4767 | if ($selectedFolder == $icServerID.self::$delimiter.$trashFolder) |
| 4244 | 4768 | { |
| 4245 | 4769 | // Lock the tree if the active folder is Trash folder |
@@ -4285,7 +4809,10 @@ discard block |
||
| 4285 | 4809 | $decodedFolderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 4286 | 4810 | list($icServerID,$folderName) = explode(self::$delimiter,$decodedFolderName,2); |
| 4287 | 4811 | |
| 4288 | - if (empty($folderName)) $folderName = $this->mail_bo->sessionData['mailbox']; |
|
| 4812 | + if (empty($folderName)) |
|
| 4813 | + { |
|
| 4814 | + $folderName = $this->mail_bo->sessionData['mailbox']; |
|
| 4815 | + } |
|
| 4289 | 4816 | if ($this->mail_bo->folderExists($folderName)) |
| 4290 | 4817 | { |
| 4291 | 4818 | $rememberServerID = $this->mail_bo->profileID; |
@@ -4294,7 +4821,8 @@ discard block |
||
| 4294 | 4821 | //error_log(__METHOD__.__LINE__.' change Profile to ->'.$icServerID); |
| 4295 | 4822 | $this->changeProfile($icServerID); |
| 4296 | 4823 | } |
| 4297 | - if(!empty($_folderName)) { |
|
| 4824 | + if(!empty($_folderName)) |
|
| 4825 | + { |
|
| 4298 | 4826 | $this->mail_bo->compressFolder($folderName); |
| 4299 | 4827 | } |
| 4300 | 4828 | if ($rememberServerID != $this->mail_bo->profileID) |
@@ -4316,7 +4844,10 @@ discard block |
||
| 4316 | 4844 | */ |
| 4317 | 4845 | function ajax_sendMDN($_messageList) |
| 4318 | 4846 | { |
| 4319 | - if(mail_bo::$debug) error_log(__METHOD__."->".array2string($_messageList)); |
|
| 4847 | + if(mail_bo::$debug) |
|
| 4848 | + { |
|
| 4849 | + error_log(__METHOD__."->".array2string($_messageList)); |
|
| 4850 | + } |
|
| 4320 | 4851 | $uidA = self::splitRowID($_messageList['msg'][0]); |
| 4321 | 4852 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
| 4322 | 4853 | $this->mail_bo->sendMDN($uidA['msgUID'],$folder); |
@@ -4333,7 +4864,10 @@ discard block |
||
| 4333 | 4864 | */ |
| 4334 | 4865 | function ajax_flagMessages($_flag, $_messageList, $_sendJsonResponse=true) |
| 4335 | 4866 | { |
| 4336 | - if(mail_bo::$debug) error_log(__METHOD__."->".$_flag.':'.array2string($_messageList)); |
|
| 4867 | + if(mail_bo::$debug) |
|
| 4868 | + { |
|
| 4869 | + error_log(__METHOD__."->".$_flag.':'.array2string($_messageList)); |
|
| 4870 | + } |
|
| 4337 | 4871 | translation::add_app('mail'); |
| 4338 | 4872 | $alreadyFlagged=false; |
| 4339 | 4873 | $flag2check=''; |
@@ -4354,7 +4888,10 @@ discard block |
||
| 4354 | 4888 | if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) |
| 4355 | 4889 | { |
| 4356 | 4890 | emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
| 4357 | - if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 4891 | + if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) |
|
| 4892 | + { |
|
| 4893 | + emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 4894 | + } |
|
| 4358 | 4895 | } |
| 4359 | 4896 | $filter = $filter2toggle = array('filterName' => (emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?lang('quicksearch'):lang('subject')),'type' => ($query['filter2']?$query['filter2']:(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject')),'string' => $query['search'],'status' => 'any'); |
| 4360 | 4897 | } |
@@ -4400,13 +4937,19 @@ discard block |
||
| 4400 | 4937 | if (count($messageListForToggle)>0) |
| 4401 | 4938 | { |
| 4402 | 4939 | $flag2set = (strtolower($_flag)); |
| 4403 | - if(mail_bo::$debug) error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle)); |
|
| 4940 | + if(mail_bo::$debug) |
|
| 4941 | + { |
|
| 4942 | + error_log(__METHOD__.__LINE__." toggle un$_flag -> $flag2set ".array2string($filter2toggle).array2string($messageListForToggle)); |
|
| 4943 | + } |
|
| 4404 | 4944 | $this->mail_bo->flagMessages($flag2set, $messageListForToggle,$folder); |
| 4405 | 4945 | } |
| 4406 | 4946 | if (count($messageList)>0) |
| 4407 | 4947 | { |
| 4408 | 4948 | $flag2set = 'un'.$_flag; |
| 4409 | - if(mail_bo::$debug) error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList)); |
|
| 4949 | + if(mail_bo::$debug) |
|
| 4950 | + { |
|
| 4951 | + error_log(__METHOD__.__LINE__." $_flag -> $flag2set ".array2string($filter).array2string($messageList)); |
|
| 4952 | + } |
|
| 4410 | 4953 | $this->mail_bo->flagMessages($flag2set, $messageList,$folder); |
| 4411 | 4954 | } |
| 4412 | 4955 | $alreadyFlagged=true; |
@@ -4422,7 +4965,10 @@ discard block |
||
| 4422 | 4965 | // since we toggle and we toggle by the filtered flag we must must change _flag |
| 4423 | 4966 | $_flag = ($query['filter']=='unseen' && $_flag=='read' ? 'read' : ($query['filter']=='seen'&& $_flag=='read'?'unread':($_flag==$query['filter']?'un'.$_flag:$_flag))); |
| 4424 | 4967 | } |
| 4425 | - if(mail_bo::$debug) error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter)); |
|
| 4968 | + if(mail_bo::$debug) |
|
| 4969 | + { |
|
| 4970 | + error_log(__METHOD__.__LINE__." flag all with $_flag on filter used:".array2string($filter)); |
|
| 4971 | + } |
|
| 4426 | 4972 | $_sR = $this->mail_bo->getSortedList( |
| 4427 | 4973 | $folder, |
| 4428 | 4974 | $sort=0, |
@@ -4437,7 +4983,10 @@ discard block |
||
| 4437 | 4983 | } |
| 4438 | 4984 | else |
| 4439 | 4985 | { |
| 4440 | - if(mail_bo::$debug) error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter)); |
|
| 4986 | + if(mail_bo::$debug) |
|
| 4987 | + { |
|
| 4988 | + error_log(__METHOD__.__LINE__." $_flag all ".array2string($filter)); |
|
| 4989 | + } |
|
| 4441 | 4990 | $alreadyFlagged=true; |
| 4442 | 4991 | $uidA = self::splitRowID($_messageList['msg'][0]); |
| 4443 | 4992 | $folder = $uidA['folder']; // all messages in one set are supposed to be within the same folder |
@@ -4457,13 +5006,19 @@ discard block |
||
| 4457 | 5006 | $hA = self::splitRowID($rowID); |
| 4458 | 5007 | $messageList[] = $hA['msgUID']; |
| 4459 | 5008 | } |
| 4460 | - if(mail_bo::$debug) error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList))); |
|
| 5009 | + if(mail_bo::$debug) |
|
| 5010 | + { |
|
| 5011 | + error_log(__METHOD__.__LINE__." $_flag in $folder:".array2string(((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList))); |
|
| 5012 | + } |
|
| 4461 | 5013 | $this->mail_bo->flagMessages($_flag, ((isset($_messageList['all']) && $_messageList['all']) ? 'all':$messageList),$folder); |
| 4462 | 5014 | } |
| 4463 | 5015 | } |
| 4464 | 5016 | else |
| 4465 | 5017 | { |
| 4466 | - if(mail_bo::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 5018 | + if(mail_bo::$debug) |
|
| 5019 | + { |
|
| 5020 | + error_log(__METHOD__."-> No messages selected."); |
|
| 5021 | + } |
|
| 4467 | 5022 | } |
| 4468 | 5023 | |
| 4469 | 5024 | if ($_sendJsonResponse) |
@@ -4500,7 +5055,10 @@ discard block |
||
| 4500 | 5055 | */ |
| 4501 | 5056 | function ajax_deleteMessages($_messageList,$_forceDeleteMethod=null) |
| 4502 | 5057 | { |
| 4503 | - if(mail_bo::$debug) error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod); |
|
| 5058 | + if(mail_bo::$debug) |
|
| 5059 | + { |
|
| 5060 | + error_log(__METHOD__."->".print_r($_messageList,true).' Method:'.$_forceDeleteMethod); |
|
| 5061 | + } |
|
| 4504 | 5062 | $error = null; |
| 4505 | 5063 | $filtered = false; |
| 4506 | 5064 | if ($_messageList=='all' || !empty($_messageList['msg'])) |
@@ -4519,7 +5077,10 @@ discard block |
||
| 4519 | 5077 | if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) |
| 4520 | 5078 | { |
| 4521 | 5079 | emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
| 4522 | - if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 5080 | + if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) |
|
| 5081 | + { |
|
| 5082 | + emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 5083 | + } |
|
| 4523 | 5084 | } |
| 4524 | 5085 | $filtered = true; |
| 4525 | 5086 | $filter = array('filterName' => (emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?lang('quicksearch'):lang('subject')),'type' => ($query['filter2']?$query['filter2']:(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject')),'string' => $query['search'],'status' => (!empty($query['filter'])?$query['filter']:'any')); |
@@ -4588,7 +5149,10 @@ discard block |
||
| 4588 | 5149 | } |
| 4589 | 5150 | else |
| 4590 | 5151 | { |
| 4591 | - if(mail_bo::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 5152 | + if(mail_bo::$debug) |
|
| 5153 | + { |
|
| 5154 | + error_log(__METHOD__."-> No messages selected."); |
|
| 5155 | + } |
|
| 4592 | 5156 | } |
| 4593 | 5157 | } |
| 4594 | 5158 | |
@@ -4603,11 +5167,17 @@ discard block |
||
| 4603 | 5167 | */ |
| 4604 | 5168 | function ajax_copyMessages($_folderName, $_messageList, $_copyOrMove='copy') |
| 4605 | 5169 | { |
| 4606 | - if(mail_bo::$debug) error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove); |
|
| 5170 | + if(mail_bo::$debug) |
|
| 5171 | + { |
|
| 5172 | + error_log(__METHOD__."->".$_folderName.':'.print_r($_messageList,true).' Method:'.$_copyOrMove); |
|
| 5173 | + } |
|
| 4607 | 5174 | translation::add_app('mail'); |
| 4608 | 5175 | $_folderName = $this->mail_bo->decodeEntityFolderName($_folderName); |
| 4609 | 5176 | // only copy or move are supported as method |
| 4610 | - if (!($_copyOrMove=='copy' || $_copyOrMove=='move')) $_copyOrMove='copy'; |
|
| 5177 | + if (!($_copyOrMove=='copy' || $_copyOrMove=='move')) |
|
| 5178 | + { |
|
| 5179 | + $_copyOrMove='copy'; |
|
| 5180 | + } |
|
| 4611 | 5181 | list($targetProfileID,$targetFolder) = explode(self::$delimiter,$_folderName,2); |
| 4612 | 5182 | $lastFoldersUsedForMoveCont = egw_cache::getCache(egw_cache::INSTANCE,'email','lastFolderUsedForMove'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*1); |
| 4613 | 5183 | $changeFolderActions = false; |
@@ -4618,8 +5188,13 @@ discard block |
||
| 4618 | 5188 | $keys = array_keys($lastFoldersUsedForMoveCont[$targetProfileID]); |
| 4619 | 5189 | foreach( $keys as &$f) |
| 4620 | 5190 | { |
| 4621 | - if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9) unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]); |
|
| 4622 | - else break; |
|
| 5191 | + if (count($lastFoldersUsedForMoveCont[$targetProfileID])>9) |
|
| 5192 | + { |
|
| 5193 | + unset($lastFoldersUsedForMoveCont[$targetProfileID][$f]); |
|
| 5194 | + } |
|
| 5195 | + else { |
|
| 5196 | + break; |
|
| 5197 | + } |
|
| 4623 | 5198 | } |
| 4624 | 5199 | //error_log(__METHOD__.__LINE__.array2string($lastFoldersUsedForMoveCont[$targetProfileID])); |
| 4625 | 5200 | } |
@@ -4645,7 +5220,10 @@ discard block |
||
| 4645 | 5220 | if (is_null(emailadmin_imapbase::$supportsORinQuery) || !isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) |
| 4646 | 5221 | { |
| 4647 | 5222 | emailadmin_imapbase::$supportsORinQuery = egw_cache::getCache(egw_cache::INSTANCE,'email','supportsORinQuery'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), 60*60*10); |
| 4648 | - if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 5223 | + if (!isset(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID])) |
|
| 5224 | + { |
|
| 5225 | + emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]=true; |
|
| 5226 | + } |
|
| 4649 | 5227 | } |
| 4650 | 5228 | $filtered = true; |
| 4651 | 5229 | $filter = array('filterName' => (emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?lang('quicksearch'):lang('subject')),'type' => ($query['filter2']?$query['filter2']:(emailadmin_imapbase::$supportsORinQuery[$this->mail_bo->profileID]?'quick':'subject')),'string' => $query['search'],'status' => (!empty($query['filter'])?$query['filter']:'any')); |
@@ -4703,7 +5281,10 @@ discard block |
||
| 4703 | 5281 | $hA = self::splitRowID($rowID); |
| 4704 | 5282 | |
| 4705 | 5283 | // If folder changes, stop and move what we've got |
| 4706 | - if($hA['folder'] != $folder) break; |
|
| 5284 | + if($hA['folder'] != $folder) |
|
| 5285 | + { |
|
| 5286 | + break; |
|
| 5287 | + } |
|
| 4707 | 5288 | |
| 4708 | 5289 | array_shift($_messageList['msg']); |
| 4709 | 5290 | $messageList[] = $hA['msgUID']; |
@@ -4758,7 +5339,10 @@ discard block |
||
| 4758 | 5339 | } |
| 4759 | 5340 | else |
| 4760 | 5341 | { |
| 4761 | - if(mail_bo::$debug) error_log(__METHOD__."-> No messages selected."); |
|
| 5342 | + if(mail_bo::$debug) |
|
| 5343 | + { |
|
| 5344 | + error_log(__METHOD__."-> No messages selected."); |
|
| 5345 | + } |
|
| 4762 | 5346 | } |
| 4763 | 5347 | } |
| 4764 | 5348 | |
@@ -131,7 +131,7 @@ |
||
| 131 | 131 | * @param array $_links |
| 132 | 132 | * @param boolean $_render_html |
| 133 | 133 | * @param boolean $_render_external |
| 134 | - * @return plain or html rendered link(s) as complete string |
|
| 134 | + * @return false|string or html rendered link(s) as complete string |
|
| 135 | 135 | */ |
| 136 | 136 | private function render_links($_links = false, $_render_html = false, $_render_external = true) { |
| 137 | 137 | if(!is_array($_links) || count($_links) == 0) { return false; } |
@@ -15,7 +15,8 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * User notification via email. |
| 17 | 17 | */ |
| 18 | -class notifications_email implements notifications_iface { |
|
| 18 | +class notifications_email implements notifications_iface |
|
| 19 | +{ |
|
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Appname |
@@ -65,9 +66,14 @@ discard block |
||
| 65 | 66 | * @param object $_config |
| 66 | 67 | * @param object $_preferences |
| 67 | 68 | */ |
| 68 | - public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) { |
|
| 69 | - if(!is_object($_sender)) { throw new Exception("no sender given."); } |
|
| 70 | - if(!is_object($_recipient)) { throw new Exception("no recipient given."); } |
|
| 69 | + public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) |
|
| 70 | + { |
|
| 71 | + if(!is_object($_sender)) |
|
| 72 | + { |
|
| 73 | +throw new Exception("no sender given."); } |
|
| 74 | + if(!is_object($_recipient)) |
|
| 75 | + { |
|
| 76 | +throw new Exception("no recipient given."); } |
|
| 71 | 77 | $this->sender = $_sender; |
| 72 | 78 | $this->recipient = $_recipient; |
| 73 | 79 | $this->config = $_config; |
@@ -133,23 +139,34 @@ discard block |
||
| 133 | 139 | * @param boolean $_render_external |
| 134 | 140 | * @return plain or html rendered link(s) as complete string |
| 135 | 141 | */ |
| 136 | - private function render_links($_links = false, $_render_html = false, $_render_external = true) { |
|
| 137 | - if(!is_array($_links) || count($_links) == 0) { return false; } |
|
| 142 | + private function render_links($_links = false, $_render_html = false, $_render_external = true) |
|
| 143 | + { |
|
| 144 | + if(!is_array($_links) || count($_links) == 0) |
|
| 145 | + { |
|
| 146 | +return false; } |
|
| 138 | 147 | |
| 139 | 148 | // provide defaults if given arguments are null |
| 140 | 149 | // php distinguishes between missing and present(null) arguments |
| 141 | - if(is_null($_render_html)) { $_render_html = false; } |
|
| 142 | - if(is_null($_render_external)) { $_render_external = true; } |
|
| 150 | + if(is_null($_render_html)) |
|
| 151 | + { |
|
| 152 | +$_render_html = false; } |
|
| 153 | + if(is_null($_render_external)) |
|
| 154 | + { |
|
| 155 | +$_render_external = true; } |
|
| 143 | 156 | $newline = $_render_html ? "<br />" : "\n"; |
| 144 | 157 | $hruler = $_render_html ? Api\Html::hr() : ''; |
| 145 | 158 | |
| 146 | 159 | $rendered_links = array(); |
| 147 | - foreach($_links as $link) { |
|
| 148 | - if($_render_external || ! $link->popup) { $link->view['no_popup'] = 1; } |
|
| 160 | + foreach($_links as $link) |
|
| 161 | + { |
|
| 162 | + if($_render_external || ! $link->popup) |
|
| 163 | + { |
|
| 164 | +$link->view['no_popup'] = 1; } |
|
| 149 | 165 | // do not expose sensitive data |
| 150 | 166 | $url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',Api\Html::link('/index.php', $link->view)); |
| 151 | 167 | // complete missing protocol and domain part if needed |
| 152 | - if ($url{0} == '/' && $_render_external) { |
|
| 168 | + if ($url{0} == '/' && $_render_external) |
|
| 169 | + { |
|
| 153 | 170 | $url = ($_SERVER['HTTPS'] || $GLOBALS['egw_info']['server']['enforce_ssl'] ? 'https://' : 'http://'). |
| 154 | 171 | ($GLOBALS['egw_info']['server']['hostname'] ? $GLOBALS['egw_info']['server']['hostname'] : $_SERVER['HTTP_HOST']).$url; |
| 155 | 172 | } |
@@ -64,13 +64,13 @@ discard block |
||
| 64 | 64 | * @param object $_preferences |
| 65 | 65 | */ |
| 66 | 66 | public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) { |
| 67 | - if(!is_object($_sender)) { throw new Exception("no sender given."); } |
|
| 68 | - if(!is_object($_recipient)) { throw new Exception("no recipient given."); } |
|
| 67 | + if (!is_object($_sender)) { throw new Exception("no sender given."); } |
|
| 68 | + if (!is_object($_recipient)) { throw new Exception("no recipient given."); } |
|
| 69 | 69 | $this->sender = $_sender; |
| 70 | 70 | $this->recipient = $_recipient; |
| 71 | 71 | $this->config = $_config; |
| 72 | 72 | $this->preferences = $_preferences; |
| 73 | - if(is_object($this->mail)) |
|
| 73 | + if (is_object($this->mail)) |
|
| 74 | 74 | { |
| 75 | 75 | unset($this->mail); |
| 76 | 76 | } |
@@ -102,18 +102,18 @@ discard block |
||
| 102 | 102 | $this->mail->setFrom($this->sender->account_email, $this->sender->account_fullname); |
| 103 | 103 | |
| 104 | 104 | $this->mail->addHeader('Subject', trim($_subject)); // trim the subject to avoid strange wrong encoding problem |
| 105 | - $this->mail->setHtmlBody($body_html, null, false); // no automatic alternativ |
|
| 105 | + $this->mail->setHtmlBody($body_html, null, false); // no automatic alternativ |
|
| 106 | 106 | $this->mail->setBody($body_plain); |
| 107 | 107 | |
| 108 | - if(is_array($_attachments) && count($_attachments) > 0) |
|
| 108 | + if (is_array($_attachments) && count($_attachments) > 0) |
|
| 109 | 109 | { |
| 110 | - foreach($_attachments as $attachment) |
|
| 110 | + foreach ($_attachments as $attachment) |
|
| 111 | 111 | { |
| 112 | 112 | if ($attachment->string) |
| 113 | 113 | { |
| 114 | 114 | $this->mail->AddStringAttachment($attachment->string, $attachment->filename, $attachment->encoding, $attachment->type); |
| 115 | 115 | } |
| 116 | - elseif($attachment->path) |
|
| 116 | + elseif ($attachment->path) |
|
| 117 | 117 | { |
| 118 | 118 | $this->mail->AddAttachment($attachment->path, $attachment->filename, $attachment->encoding, $attachment->type); |
| 119 | 119 | } |
@@ -132,20 +132,20 @@ discard block |
||
| 132 | 132 | * @return plain or html rendered link(s) as complete string |
| 133 | 133 | */ |
| 134 | 134 | private function render_links($_links = false, $_render_html = false, $_render_external = true) { |
| 135 | - if(!is_array($_links) || count($_links) == 0) { return false; } |
|
| 135 | + if (!is_array($_links) || count($_links) == 0) { return false; } |
|
| 136 | 136 | |
| 137 | 137 | // provide defaults if given arguments are null |
| 138 | 138 | // php distinguishes between missing and present(null) arguments |
| 139 | - if(is_null($_render_html)) { $_render_html = false; } |
|
| 140 | - if(is_null($_render_external)) { $_render_external = true; } |
|
| 139 | + if (is_null($_render_html)) { $_render_html = false; } |
|
| 140 | + if (is_null($_render_external)) { $_render_external = true; } |
|
| 141 | 141 | $newline = $_render_html ? "<br />" : "\n"; |
| 142 | 142 | $hruler = $_render_html ? html::hr() : ''; |
| 143 | 143 | |
| 144 | 144 | $rendered_links = array(); |
| 145 | - foreach($_links as $link) { |
|
| 146 | - if($_render_external || ! $link->popup) { $link->view['no_popup'] = 1; } |
|
| 145 | + foreach ($_links as $link) { |
|
| 146 | + if ($_render_external || !$link->popup) { $link->view['no_popup'] = 1; } |
|
| 147 | 147 | // do not expose sensitive data |
| 148 | - $url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/','',html::link('/index.php', $link->view)); |
|
| 148 | + $url = preg_replace('/(sessionid|kp3|domain)=[^&]+&?/', '', html::link('/index.php', $link->view)); |
|
| 149 | 149 | // complete missing protocol and domain part if needed |
| 150 | 150 | if ($url{0} == '/' && $_render_external) { |
| 151 | 151 | $url = ($_SERVER['HTTPS'] || $GLOBALS['egw_info']['server']['enforce_ssl'] ? 'https://' : 'http://'). |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | $rendered_links[] = $_render_html ? $a_href : $url; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - return $hruler.$newline.lang('Linked entries:').$newline.implode($newline,$rendered_links); |
|
| 158 | + return $hruler.$newline.lang('Linked entries:').$newline.implode($newline, $rendered_links); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | } |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * checks for a valid IPv4-address without CIDR notation |
| 156 | 156 | * |
| 157 | 157 | * @param string $_ip |
| 158 | - * @return true or false |
|
| 158 | + * @return integer or false |
|
| 159 | 159 | */ |
| 160 | 160 | private function valid_ip($_ip) { |
| 161 | 161 | return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$_ip); |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | * renders additional info from subject |
| 166 | 166 | * |
| 167 | 167 | * @param string $_subject |
| 168 | - * @return plain rendered info as complete string |
|
| 168 | + * @return string|false rendered info as complete string |
|
| 169 | 169 | */ |
| 170 | 170 | private function render_infos($_subject = false) { |
| 171 | 171 | $newline = "\n"; |
@@ -79,12 +79,12 @@ discard block |
||
| 79 | 79 | * @param object $_preferences |
| 80 | 80 | */ |
| 81 | 81 | public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) { |
| 82 | - if(!is_object($_sender)) { throw new Exception("no sender given."); } |
|
| 83 | - if(!is_object($_recipient)) { throw new Exception("no recipient given."); } |
|
| 84 | - if(!$this->netbios_command) { |
|
| 85 | - throw new Exception( 'Winpopup plugin not configured yet. Skipped sending notification message. '. |
|
| 82 | + if (!is_object($_sender)) { throw new Exception("no sender given."); } |
|
| 83 | + if (!is_object($_recipient)) { throw new Exception("no recipient given."); } |
|
| 84 | + if (!$this->netbios_command) { |
|
| 85 | + throw new Exception('Winpopup plugin not configured yet. Skipped sending notification message. '. |
|
| 86 | 86 | 'Please check var "netbios_command" in winpopup backend '. |
| 87 | - '('.EGW_INCLUDE_ROOT. SEP. self::_appname. SEP. 'inc'. SEP. 'class.notifications_winpopup.inc.php).'); |
|
| 87 | + '('.EGW_INCLUDE_ROOT.SEP.self::_appname.SEP.'inc'.SEP.'class.notifications_winpopup.inc.php).'); |
|
| 88 | 88 | } |
| 89 | 89 | $this->sender = $_sender; |
| 90 | 90 | $this->recipient = $_recipient; |
@@ -103,15 +103,15 @@ discard block |
||
| 103 | 103 | public function send(array $_messages, $_subject = false, $_links = false, $_attachments = false) { |
| 104 | 104 | $user_sessions = array(); |
| 105 | 105 | foreach (egw_session::session_list(0, 'asc', 'session_dla', true) as $session) { |
| 106 | - if ($session['session_lid'] == $this->recipient->account_lid. '@'. $GLOBALS['egw_info']['user']['domain']) { |
|
| 107 | - if($this->valid_ip($session['session_ip'])) { |
|
| 106 | + if ($session['session_lid'] == $this->recipient->account_lid.'@'.$GLOBALS['egw_info']['user']['domain']) { |
|
| 107 | + if ($this->valid_ip($session['session_ip'])) { |
|
| 108 | 108 | $user_sessions[] = $session['session_ip']; |
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | - if ( empty($user_sessions) ) throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup"); |
|
| 112 | + if (empty($user_sessions)) throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup"); |
|
| 113 | 113 | |
| 114 | - $this->send_winpopup( $this->render_infos($_subject).$_messages['plain'], $user_sessions ); |
|
| 114 | + $this->send_winpopup($this->render_infos($_subject).$_messages['plain'], $user_sessions); |
|
| 115 | 115 | return true; |
| 116 | 116 | } |
| 117 | 117 | |
@@ -121,15 +121,15 @@ discard block |
||
| 121 | 121 | * @param string $_message |
| 122 | 122 | * @param array $_user_sessions |
| 123 | 123 | */ |
| 124 | - private function send_winpopup( $_message, array $_user_sessions ) { |
|
| 125 | - foreach($_user_sessions as $user_session) { |
|
| 126 | - $ip_octets=explode(".",$user_session); |
|
| 124 | + private function send_winpopup($_message, array $_user_sessions) { |
|
| 125 | + foreach ($_user_sessions as $user_session) { |
|
| 126 | + $ip_octets = explode(".", $user_session); |
|
| 127 | 127 | // format the ip_octets to 3 digits each |
| 128 | - foreach($ip_octets as $id=>$ip_octet) { |
|
| 129 | - if(strlen($ip_octet)==1) { $ip_octets[$id] = '00'.$ip_octet; } |
|
| 130 | - if(strlen($ip_octet)==2) { $ip_octets[$id] = '0'.$ip_octet; } |
|
| 128 | + foreach ($ip_octets as $id=>$ip_octet) { |
|
| 129 | + if (strlen($ip_octet) == 1) { $ip_octets[$id] = '00'.$ip_octet; } |
|
| 130 | + if (strlen($ip_octet) == 2) { $ip_octets[$id] = '0'.$ip_octet; } |
|
| 131 | 131 | } |
| 132 | - $placeholders = array( '/\[MESSAGE\]/' => escapeshellarg($_message), // prevent code injection |
|
| 132 | + $placeholders = array('/\[MESSAGE\]/' => escapeshellarg($_message), // prevent code injection |
|
| 133 | 133 | '/\[1\]/' => $ip_octets[0], |
| 134 | 134 | '/\[2\]/' => $ip_octets[1], |
| 135 | 135 | '/\[3\]/' => $ip_octets[2], |
@@ -138,8 +138,8 @@ discard block |
||
| 138 | 138 | '/\[SENDER\]/' => $this->sender->account_fullname ? escapeshellarg($this->sender->account_fullname) : escapeshellarg($this->sender->account_email), |
| 139 | 139 | ); |
| 140 | 140 | $command = preg_replace(array_keys($placeholders), $placeholders, $this->netbios_command); |
| 141 | - exec($command,$output,$returncode); |
|
| 142 | - if($returncode != 0) { |
|
| 141 | + exec($command, $output, $returncode); |
|
| 142 | + if ($returncode != 0) { |
|
| 143 | 143 | throw new Exception("Failed sending notification message via winpopup. Error while executing the specified command."); |
| 144 | 144 | } |
| 145 | 145 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * @return true or false |
| 153 | 153 | */ |
| 154 | 154 | private function valid_ip($_ip) { |
| 155 | - return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$_ip); |
|
| 155 | + return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$', $_ip); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | private function render_infos($_subject = false) { |
| 165 | 165 | $newline = "\n"; |
| 166 | - if(!empty($_subject)) { return $_subject.$newline; } |
|
| 166 | + if (!empty($_subject)) { return $_subject.$newline; } |
|
| 167 | 167 | return false; |
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | \ No newline at end of file |
@@ -13,7 +13,8 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * User notification via winpopup. |
| 15 | 15 | */ |
| 16 | -class notifications_winpopup implements notifications_iface { |
|
| 16 | +class notifications_winpopup implements notifications_iface |
|
| 17 | +{ |
|
| 17 | 18 | |
| 18 | 19 | /** |
| 19 | 20 | * Appname |
@@ -78,10 +79,16 @@ discard block |
||
| 78 | 79 | * @param object $_config |
| 79 | 80 | * @param object $_preferences |
| 80 | 81 | */ |
| 81 | - public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) { |
|
| 82 | - if(!is_object($_sender)) { throw new Exception("no sender given."); } |
|
| 83 | - if(!is_object($_recipient)) { throw new Exception("no recipient given."); } |
|
| 84 | - if(!$this->netbios_command) { |
|
| 82 | + public function __construct($_sender, $_recipient, $_config = null, $_preferences = null) |
|
| 83 | + { |
|
| 84 | + if(!is_object($_sender)) |
|
| 85 | + { |
|
| 86 | +throw new Exception("no sender given."); } |
|
| 87 | + if(!is_object($_recipient)) |
|
| 88 | + { |
|
| 89 | +throw new Exception("no recipient given."); } |
|
| 90 | + if(!$this->netbios_command) |
|
| 91 | + { |
|
| 85 | 92 | throw new Exception( 'Winpopup plugin not configured yet. Skipped sending notification message. '. |
| 86 | 93 | 'Please check var "netbios_command" in winpopup backend '. |
| 87 | 94 | '('.EGW_INCLUDE_ROOT. SEP. self::_appname. SEP. 'inc'. SEP. 'class.notifications_winpopup.inc.php).'); |
@@ -100,16 +107,23 @@ discard block |
||
| 100 | 107 | * @param array $_links |
| 101 | 108 | * @param array $_attachments |
| 102 | 109 | */ |
| 103 | - public function send(array $_messages, $_subject = false, $_links = false, $_attachments = false) { |
|
| 110 | + public function send(array $_messages, $_subject = false, $_links = false, $_attachments = false) |
|
| 111 | + { |
|
| 104 | 112 | $user_sessions = array(); |
| 105 | - foreach (egw_session::session_list(0, 'asc', 'session_dla', true) as $session) { |
|
| 106 | - if ($session['session_lid'] == $this->recipient->account_lid. '@'. $GLOBALS['egw_info']['user']['domain']) { |
|
| 107 | - if($this->valid_ip($session['session_ip'])) { |
|
| 113 | + foreach (egw_session::session_list(0, 'asc', 'session_dla', true) as $session) |
|
| 114 | + { |
|
| 115 | + if ($session['session_lid'] == $this->recipient->account_lid. '@'. $GLOBALS['egw_info']['user']['domain']) |
|
| 116 | + { |
|
| 117 | + if($this->valid_ip($session['session_ip'])) |
|
| 118 | + { |
|
| 108 | 119 | $user_sessions[] = $session['session_ip']; |
| 109 | 120 | } |
| 110 | 121 | } |
| 111 | 122 | } |
| 112 | - if ( empty($user_sessions) ) throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup"); |
|
| 123 | + if ( empty($user_sessions) ) |
|
| 124 | + { |
|
| 125 | + throw new Exception("User #{$this->recipient->account_id} isn't online. Can't send notification via winpopup"); |
|
| 126 | + } |
|
| 113 | 127 | |
| 114 | 128 | $this->send_winpopup( $this->render_infos($_subject).$_messages['plain'], $user_sessions ); |
| 115 | 129 | return true; |
@@ -121,13 +135,20 @@ discard block |
||
| 121 | 135 | * @param string $_message |
| 122 | 136 | * @param array $_user_sessions |
| 123 | 137 | */ |
| 124 | - private function send_winpopup( $_message, array $_user_sessions ) { |
|
| 125 | - foreach($_user_sessions as $user_session) { |
|
| 138 | + private function send_winpopup( $_message, array $_user_sessions ) |
|
| 139 | + { |
|
| 140 | + foreach($_user_sessions as $user_session) |
|
| 141 | + { |
|
| 126 | 142 | $ip_octets=explode(".",$user_session); |
| 127 | 143 | // format the ip_octets to 3 digits each |
| 128 | - foreach($ip_octets as $id=>$ip_octet) { |
|
| 129 | - if(strlen($ip_octet)==1) { $ip_octets[$id] = '00'.$ip_octet; } |
|
| 130 | - if(strlen($ip_octet)==2) { $ip_octets[$id] = '0'.$ip_octet; } |
|
| 144 | + foreach($ip_octets as $id=>$ip_octet) |
|
| 145 | + { |
|
| 146 | + if(strlen($ip_octet)==1) |
|
| 147 | + { |
|
| 148 | +$ip_octets[$id] = '00'.$ip_octet; } |
|
| 149 | + if(strlen($ip_octet)==2) |
|
| 150 | + { |
|
| 151 | +$ip_octets[$id] = '0'.$ip_octet; } |
|
| 131 | 152 | } |
| 132 | 153 | $placeholders = array( '/\[MESSAGE\]/' => escapeshellarg($_message), // prevent code injection |
| 133 | 154 | '/\[1\]/' => $ip_octets[0], |
@@ -139,7 +160,8 @@ discard block |
||
| 139 | 160 | ); |
| 140 | 161 | $command = preg_replace(array_keys($placeholders), $placeholders, $this->netbios_command); |
| 141 | 162 | exec($command,$output,$returncode); |
| 142 | - if($returncode != 0) { |
|
| 163 | + if($returncode != 0) |
|
| 164 | + { |
|
| 143 | 165 | throw new Exception("Failed sending notification message via winpopup. Error while executing the specified command."); |
| 144 | 166 | } |
| 145 | 167 | } |
@@ -151,7 +173,8 @@ discard block |
||
| 151 | 173 | * @param string $_ip |
| 152 | 174 | * @return true or false |
| 153 | 175 | */ |
| 154 | - private function valid_ip($_ip) { |
|
| 176 | + private function valid_ip($_ip) |
|
| 177 | + { |
|
| 155 | 178 | return eregi('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$_ip); |
| 156 | 179 | } |
| 157 | 180 | |
@@ -161,9 +184,12 @@ discard block |
||
| 161 | 184 | * @param string $_subject |
| 162 | 185 | * @return plain rendered info as complete string |
| 163 | 186 | */ |
| 164 | - private function render_infos($_subject = false) { |
|
| 187 | + private function render_infos($_subject = false) |
|
| 188 | + { |
|
| 165 | 189 | $newline = "\n"; |
| 166 | - if(!empty($_subject)) { return $_subject.$newline; } |
|
| 190 | + if(!empty($_subject)) |
|
| 191 | + { |
|
| 192 | +return $_subject.$newline; } |
|
| 167 | 193 | return false; |
| 168 | 194 | } |
| 169 | 195 | } |
| 170 | 196 | \ No newline at end of file |
@@ -24,6 +24,10 @@ |
||
| 24 | 24 | |
| 25 | 25 | if(!function_exists('html_entity_decode')) |
| 26 | 26 | { |
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * @param integer $quote_style |
|
| 30 | + */ |
|
| 27 | 31 | function html_entity_decode($given_html, $quote_style = ENT_QUOTES) |
| 28 | 32 | { |
| 29 | 33 | $trans_table = array_flip(get_html_translation_table( HTML_SPECIALCHARS, $quote_style)); |
@@ -22,11 +22,11 @@ discard block |
||
| 22 | 22 | "<a href=\"$webserverURL/redirect.php?go=".htmlentities(urlencode('http://www.egroupware.org')).'">' |
| 23 | 23 | */ |
| 24 | 24 | |
| 25 | - if(!function_exists('html_entity_decode')) |
|
| 25 | + if (!function_exists('html_entity_decode')) |
|
| 26 | 26 | { |
| 27 | 27 | function html_entity_decode($given_html, $quote_style = ENT_QUOTES) |
| 28 | 28 | { |
| 29 | - $trans_table = array_flip(get_html_translation_table( HTML_SPECIALCHARS, $quote_style)); |
|
| 29 | + $trans_table = array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style)); |
|
| 30 | 30 | $trans_table['''] = "'"; |
| 31 | 31 | return(strtr($given_html, $trans_table)); |
| 32 | 32 | } |
@@ -45,17 +45,17 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | /* Only allow redirects from inside this eGroupware installation. */ |
| 47 | 47 | $valid_referer = array(); |
| 48 | - $path = preg_replace('/\/[^\/]*$/','',$_SERVER['PHP_SELF']) . '/'; |
|
| 48 | + $path = preg_replace('/\/[^\/]*$/', '', $_SERVER['PHP_SELF']).'/'; |
|
| 49 | 49 | array_push($valid_referer, $path); |
| 50 | - array_push($valid_referer, ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['SERVER_ADDR'] . $path); |
|
| 51 | - array_push($valid_referer, ($_SERVER['HTTPS'] ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . $path); |
|
| 50 | + array_push($valid_referer, ($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['SERVER_ADDR'].$path); |
|
| 51 | + array_push($valid_referer, ($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['SERVER_NAME'].$path); |
|
| 52 | 52 | |
| 53 | 53 | $referrer = trim($_SERVER['HTTP_REFERER']); |
| 54 | 54 | if ((!isset($_SERVER['HTTP_REFERER'])) || (empty($referrer))) |
| 55 | 55 | { |
| 56 | 56 | echo "Only usable from within eGroupware.\n"; |
| 57 | 57 | } |
| 58 | - else if($_GET['go']) |
|
| 58 | + else if ($_GET['go']) |
|
| 59 | 59 | { |
| 60 | 60 | $allow = false; |
| 61 | 61 | foreach ($valid_referer as $urlRoot) |
@@ -69,15 +69,15 @@ discard block |
||
| 69 | 69 | } |
| 70 | 70 | if ($allow) |
| 71 | 71 | { |
| 72 | - $url= html_entity_decode(urldecode($_GET['go'])); |
|
| 72 | + $url = html_entity_decode(urldecode($_GET['go'])); |
|
| 73 | 73 | unset($_GET['go']); |
| 74 | 74 | /* Only add "&" if there is something to append. */ |
| 75 | 75 | if (!empty($_GET)) |
| 76 | 76 | { |
| 77 | - $url=$url."&".http_build_query($_GET); |
|
| 77 | + $url = $url."&".http_build_query($_GET); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - Header('Location: ' . html_entity_decode(urldecode($url))); |
|
| 80 | + Header('Location: '.html_entity_decode(urldecode($url))); |
|
| 81 | 81 | exit; |
| 82 | 82 | } |
| 83 | 83 | else |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | /** |
| 30 | 30 | * Exports records as defined in $_definition |
| 31 | 31 | * |
| 32 | - * @param egw_record $_definition |
|
| 32 | + * @param importexport_definition $_definition |
|
| 33 | 33 | */ |
| 34 | 34 | public function export( $_stream, importexport_definition $_definition) { |
| 35 | 35 | $options = $_definition->plugin_options; |
@@ -170,9 +170,9 @@ |
||
| 170 | 170 | * Get selectbox values |
| 171 | 171 | */ |
| 172 | 172 | protected function get_selects() |
| 173 | - { |
|
| 173 | + { |
|
| 174 | 174 | $this->selects = array(); |
| 175 | - } |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | 177 | /** |
| 178 | 178 | * Customize automatically generated filter fields |
@@ -247,7 +247,7 @@ |
||
| 247 | 247 | $this->selects['info_status'] = $this->bo->get_status(); |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - public function get_filter_fields(Array &$filters) |
|
| 250 | + public function get_filter_fields(array &$filters) |
|
| 251 | 251 | { |
| 252 | 252 | foreach($filters as $field_name => &$settings) |
| 253 | 253 | { |
@@ -28,54 +28,54 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @param egw_record $_definition |
| 30 | 30 | */ |
| 31 | - public function export( $_stream, importexport_definition $_definition) { |
|
| 31 | + public function export($_stream, importexport_definition $_definition) { |
|
| 32 | 32 | $options = $_definition->plugin_options; |
| 33 | 33 | |
| 34 | 34 | $selection = array(); |
| 35 | 35 | if ($options['selection'] == 'search') { |
| 36 | 36 | // ui selection with checkbox 'selected' |
| 37 | 37 | $query = egw_cache::getSession('resources', 'get_rows'); |
| 38 | - $query['num_rows'] = -1; // all |
|
| 38 | + $query['num_rows'] = -1; // all |
|
| 39 | 39 | unset($query['store_state']); |
| 40 | - $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
| 41 | - $this->bo->get_rows($query,$selection,$readonlys); |
|
| 40 | + $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
|
| 41 | + $this->bo->get_rows($query, $selection, $readonlys); |
|
| 42 | 42 | } |
| 43 | - elseif ( $options['selection'] == 'all' || $options['selection'] == 'filter') { |
|
| 43 | + elseif ($options['selection'] == 'all' || $options['selection'] == 'filter') { |
|
| 44 | 44 | $query = array( |
| 45 | 45 | 'num_rows' => -1, |
| 46 | - 'filter2' => -3, // Accessories & resources |
|
| 47 | - 'csv_export' => true, // so get_rows method _can_ produce different content or not store state in the session |
|
| 48 | - ); // all |
|
| 46 | + 'filter2' => -3, // Accessories & resources |
|
| 47 | + 'csv_export' => true, // so get_rows method _can_ produce different content or not store state in the session |
|
| 48 | + ); // all |
|
| 49 | 49 | |
| 50 | - if($options['selection'] == 'filter') |
|
| 50 | + if ($options['selection'] == 'filter') |
|
| 51 | 51 | { |
| 52 | 52 | $filter = $_definition->filter; |
| 53 | 53 | // Handle ranges |
| 54 | - foreach($filter as $field => $value) |
|
| 54 | + foreach ($filter as $field => $value) |
|
| 55 | 55 | { |
| 56 | - if($field == 'cat_id') |
|
| 56 | + if ($field == 'cat_id') |
|
| 57 | 57 | { |
| 58 | 58 | $query['filter'] = $value; |
| 59 | 59 | continue; |
| 60 | 60 | } |
| 61 | - if($field == 'filter2') |
|
| 61 | + if ($field == 'filter2') |
|
| 62 | 62 | { |
| 63 | 63 | $query['filter2'] = $value; |
| 64 | 64 | continue; |
| 65 | 65 | } |
| 66 | 66 | $query['col_filter'][$field] = $value; |
| 67 | - if(!is_array($value) || (!$value['from'] && !$value['to'])) continue; |
|
| 67 | + if (!is_array($value) || (!$value['from'] && !$value['to'])) continue; |
|
| 68 | 68 | |
| 69 | 69 | // Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10) |
| 70 | - if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from']; |
|
| 71 | - if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to']; |
|
| 70 | + if ($value['from']) $query['col_filter'][] = "$field >= ".(int)$value['from']; |
|
| 71 | + if ($value['to']) $query['col_filter'][] = "$field <= ".(int)$value['to']; |
|
| 72 | 72 | unset($query['col_filter'][$field]); |
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - $this->bo->get_rows($query,$selection,$readonlys); |
|
| 76 | + $this->bo->get_rows($query, $selection, $readonlys); |
|
| 77 | 77 | } else { |
| 78 | - $selection = explode(',',$options['selection']); |
|
| 78 | + $selection = explode(',', $options['selection']); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | $export_object = new importexport_export_csv($_stream, (array)$options); |
@@ -83,28 +83,28 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | // Check if we need to load the custom fields |
| 85 | 85 | $need_custom = false; |
| 86 | - foreach(config::get_customfields('resources') as $field => $settings) { |
|
| 87 | - if($options['mapping']['#'.$field]) { |
|
| 86 | + foreach (config::get_customfields('resources') as $field => $settings) { |
|
| 87 | + if ($options['mapping']['#'.$field]) { |
|
| 88 | 88 | $need_custom = true; |
| 89 | 89 | break; |
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | foreach ($selection as $record) { |
| 94 | - if(!is_array($record) || !$record['res_id']) continue; |
|
| 94 | + if (!is_array($record) || !$record['res_id']) continue; |
|
| 95 | 95 | |
| 96 | - if($need_custom) { |
|
| 96 | + if ($need_custom) { |
|
| 97 | 97 | $record = $this->bo->read($record['res_id']); |
| 98 | 98 | } |
| 99 | 99 | $resource = new resources_egw_record(); |
| 100 | 100 | $resource->set_record($record); |
| 101 | 101 | $resource->long_description = strip_tags($resource->long_description); |
| 102 | - if($options['convert']) { |
|
| 102 | + if ($options['convert']) { |
|
| 103 | 103 | importexport_export_csv::convert($resource, resources_egw_record::$types, 'resources', $this->selects); |
| 104 | 104 | } else { |
| 105 | 105 | // Implode arrays, so they don't say 'Array' |
| 106 | - foreach($resource->get_record_array() as $key => $value) { |
|
| 107 | - if(is_array($value)) $resource->$key = implode(',', $value); |
|
| 106 | + foreach ($resource->get_record_array() as $key => $value) { |
|
| 107 | + if (is_array($value)) $resource->$key = implode(',', $value); |
|
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | // In resources, not all categories are used |
| 180 | 180 | $filters['cat_id']['type'] = 'select'; |
| 181 | 181 | $filters['cat_id']['name'] = 'filter'; |
| 182 | - $filters['cat_id']['values']= (array)$this->bo->acl->get_cats(EGW_ACL_READ); |
|
| 182 | + $filters['cat_id']['values'] = (array)$this->bo->acl->get_cats(EGW_ACL_READ); |
|
| 183 | 183 | |
| 184 | 184 | // Add in resources / accessories |
| 185 | 185 | $filters['filter2'] = array( |
@@ -189,9 +189,9 @@ discard block |
||
| 189 | 189 | 'rows' => 5, |
| 190 | 190 | 'values' => resources_bo::$filter_options |
| 191 | 191 | ); |
| 192 | - foreach($filters as $field_name => &$settings) |
|
| 192 | + foreach ($filters as $field_name => &$settings) |
|
| 193 | 193 | { |
| 194 | - if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
| 194 | + if ($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | 197 | |
@@ -14,7 +14,8 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * export resources to CSV |
| 16 | 16 | */ |
| 17 | -class resources_export_csv implements importexport_iface_export_plugin { |
|
| 17 | +class resources_export_csv implements importexport_iface_export_plugin |
|
| 18 | +{ |
|
| 18 | 19 | |
| 19 | 20 | public function __construct() |
| 20 | 21 | { |
@@ -28,11 +29,13 @@ discard block |
||
| 28 | 29 | * |
| 29 | 30 | * @param egw_record $_definition |
| 30 | 31 | */ |
| 31 | - public function export( $_stream, importexport_definition $_definition) { |
|
| 32 | + public function export( $_stream, importexport_definition $_definition) |
|
| 33 | + { |
|
| 32 | 34 | $options = $_definition->plugin_options; |
| 33 | 35 | |
| 34 | 36 | $selection = array(); |
| 35 | - if ($options['selection'] == 'search') { |
|
| 37 | + if ($options['selection'] == 'search') |
|
| 38 | + { |
|
| 36 | 39 | // ui selection with checkbox 'selected' |
| 37 | 40 | $query = egw_cache::getSession('resources', 'get_rows'); |
| 38 | 41 | $query['num_rows'] = -1; // all |
@@ -40,7 +43,8 @@ discard block |
||
| 40 | 43 | $query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session |
| 41 | 44 | $this->bo->get_rows($query,$selection,$readonlys); |
| 42 | 45 | } |
| 43 | - elseif ( $options['selection'] == 'all' || $options['selection'] == 'filter') { |
|
| 46 | + elseif ( $options['selection'] == 'all' || $options['selection'] == 'filter') |
|
| 47 | + { |
|
| 44 | 48 | $query = array( |
| 45 | 49 | 'num_rows' => -1, |
| 46 | 50 | 'filter2' => -3, // Accessories & resources |
@@ -64,17 +68,28 @@ discard block |
||
| 64 | 68 | continue; |
| 65 | 69 | } |
| 66 | 70 | $query['col_filter'][$field] = $value; |
| 67 | - if(!is_array($value) || (!$value['from'] && !$value['to'])) continue; |
|
| 71 | + if(!is_array($value) || (!$value['from'] && !$value['to'])) |
|
| 72 | + { |
|
| 73 | + continue; |
|
| 74 | + } |
|
| 68 | 75 | |
| 69 | 76 | // Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10) |
| 70 | - if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from']; |
|
| 71 | - if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to']; |
|
| 77 | + if($value['from']) |
|
| 78 | + { |
|
| 79 | + $query['col_filter'][] = "$field >= " . (int)$value['from']; |
|
| 80 | + } |
|
| 81 | + if($value['to']) |
|
| 82 | + { |
|
| 83 | + $query['col_filter'][] = "$field <= " . (int)$value['to']; |
|
| 84 | + } |
|
| 72 | 85 | unset($query['col_filter'][$field]); |
| 73 | 86 | } |
| 74 | 87 | } |
| 75 | 88 | |
| 76 | 89 | $this->bo->get_rows($query,$selection,$readonlys); |
| 77 | - } else { |
|
| 90 | + } |
|
| 91 | + else |
|
| 92 | + { |
|
| 78 | 93 | $selection = explode(',',$options['selection']); |
| 79 | 94 | } |
| 80 | 95 | |
@@ -83,28 +98,42 @@ discard block |
||
| 83 | 98 | |
| 84 | 99 | // Check if we need to load the custom fields |
| 85 | 100 | $need_custom = false; |
| 86 | - foreach(config::get_customfields('resources') as $field => $settings) { |
|
| 87 | - if($options['mapping']['#'.$field]) { |
|
| 101 | + foreach(config::get_customfields('resources') as $field => $settings) |
|
| 102 | + { |
|
| 103 | + if($options['mapping']['#'.$field]) |
|
| 104 | + { |
|
| 88 | 105 | $need_custom = true; |
| 89 | 106 | break; |
| 90 | 107 | } |
| 91 | 108 | } |
| 92 | 109 | |
| 93 | - foreach ($selection as $record) { |
|
| 94 | - if(!is_array($record) || !$record['res_id']) continue; |
|
| 110 | + foreach ($selection as $record) |
|
| 111 | + { |
|
| 112 | + if(!is_array($record) || !$record['res_id']) |
|
| 113 | + { |
|
| 114 | + continue; |
|
| 115 | + } |
|
| 95 | 116 | |
| 96 | - if($need_custom) { |
|
| 117 | + if($need_custom) |
|
| 118 | + { |
|
| 97 | 119 | $record = $this->bo->read($record['res_id']); |
| 98 | 120 | } |
| 99 | 121 | $resource = new resources_egw_record(); |
| 100 | 122 | $resource->set_record($record); |
| 101 | 123 | $resource->long_description = strip_tags($resource->long_description); |
| 102 | - if($options['convert']) { |
|
| 124 | + if($options['convert']) |
|
| 125 | + { |
|
| 103 | 126 | importexport_export_csv::convert($resource, resources_egw_record::$types, 'resources', $this->selects); |
| 104 | - } else { |
|
| 127 | + } |
|
| 128 | + else |
|
| 129 | + { |
|
| 105 | 130 | // Implode arrays, so they don't say 'Array' |
| 106 | - foreach($resource->get_record_array() as $key => $value) { |
|
| 107 | - if(is_array($value)) $resource->$key = implode(',', $value); |
|
| 131 | + foreach($resource->get_record_array() as $key => $value) |
|
| 132 | + { |
|
| 133 | + if(is_array($value)) |
|
| 134 | + { |
|
| 135 | + $resource->$key = implode(',', $value); |
|
| 136 | + } |
|
| 108 | 137 | } |
| 109 | 138 | } |
| 110 | 139 | |
@@ -119,7 +148,8 @@ discard block |
||
| 119 | 148 | * |
| 120 | 149 | * @return string name |
| 121 | 150 | */ |
| 122 | - public static function get_name() { |
|
| 151 | + public static function get_name() |
|
| 152 | + { |
|
| 123 | 153 | return lang('Resources CSV export'); |
| 124 | 154 | } |
| 125 | 155 | |
@@ -128,7 +158,8 @@ discard block |
||
| 128 | 158 | * |
| 129 | 159 | * @return string descriprion |
| 130 | 160 | */ |
| 131 | - public static function get_description() { |
|
| 161 | + public static function get_description() |
|
| 162 | + { |
|
| 132 | 163 | return lang("Exports a list of resources to a CSV File."); |
| 133 | 164 | } |
| 134 | 165 | |
@@ -137,11 +168,13 @@ discard block |
||
| 137 | 168 | * |
| 138 | 169 | * @return string suffix |
| 139 | 170 | */ |
| 140 | - public static function get_filesuffix() { |
|
| 171 | + public static function get_filesuffix() |
|
| 172 | + { |
|
| 141 | 173 | return 'csv'; |
| 142 | 174 | } |
| 143 | 175 | |
| 144 | - public static function get_mimetype() { |
|
| 176 | + public static function get_mimetype() |
|
| 177 | + { |
|
| 145 | 178 | return 'text/csv'; |
| 146 | 179 | } |
| 147 | 180 | |
@@ -150,14 +183,16 @@ discard block |
||
| 150 | 183 | * this way the plugin has all opportunities for options tab |
| 151 | 184 | * |
| 152 | 185 | */ |
| 153 | - public function get_options_etpl() { |
|
| 186 | + public function get_options_etpl() |
|
| 187 | + { |
|
| 154 | 188 | } |
| 155 | 189 | |
| 156 | 190 | /** |
| 157 | 191 | * returns selectors information |
| 158 | 192 | * |
| 159 | 193 | */ |
| 160 | - public function get_selectors_etpl() { |
|
| 194 | + public function get_selectors_etpl() |
|
| 195 | + { |
|
| 161 | 196 | return array( |
| 162 | 197 | 'name' => 'importexport.export_csv_selectors', |
| 163 | 198 | ); |
@@ -167,7 +202,7 @@ discard block |
||
| 167 | 202 | * Get selectbox values |
| 168 | 203 | */ |
| 169 | 204 | protected function get_selects() |
| 170 | - { |
|
| 205 | + { |
|
| 171 | 206 | $this->selects = array(); |
| 172 | 207 | } |
| 173 | 208 | |
@@ -191,7 +226,10 @@ discard block |
||
| 191 | 226 | ); |
| 192 | 227 | foreach($filters as $field_name => &$settings) |
| 193 | 228 | { |
| 194 | - if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name]; |
|
| 229 | + if($this->selects[$field_name]) |
|
| 230 | + { |
|
| 231 | + $settings['values'] = $this->selects[$field_name]; |
|
| 232 | + } |
|
| 195 | 233 | } |
| 196 | 234 | } |
| 197 | 235 | |
@@ -28,9 +28,7 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * imports entries according to given definition object. |
| 31 | - * @param resource $_stream |
|
| 32 | - * @param string $_charset |
|
| 33 | - * @param definition $_definition |
|
| 31 | + * @param importexport_definition $_definition |
|
| 34 | 32 | */ |
| 35 | 33 | public function init(importexport_definition $_definition ) { |
| 36 | 34 | |
@@ -52,7 +50,7 @@ discard block |
||
| 52 | 50 | * |
| 53 | 51 | * Updates the count of actions taken |
| 54 | 52 | * |
| 55 | - * @return boolean success |
|
| 53 | + * @return null|boolean success |
|
| 56 | 54 | */ |
| 57 | 55 | protected function import_record(importexport_iface_egw_record &$record, &$import_csv) |
| 58 | 56 | { |
@@ -45,15 +45,15 @@ discard block |
||
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | - * Import a single record |
|
| 49 | - * |
|
| 50 | - * You don't need to worry about mappings or translations, they've been done already. |
|
| 51 | - * You do need to handle the conditions and the actions taken. |
|
| 52 | - * |
|
| 53 | - * Updates the count of actions taken |
|
| 54 | - * |
|
| 55 | - * @return boolean success |
|
| 56 | - */ |
|
| 48 | + * Import a single record |
|
| 49 | + * |
|
| 50 | + * You don't need to worry about mappings or translations, they've been done already. |
|
| 51 | + * You do need to handle the conditions and the actions taken. |
|
| 52 | + * |
|
| 53 | + * Updates the count of actions taken |
|
| 54 | + * |
|
| 55 | + * @return boolean success |
|
| 56 | + */ |
|
| 57 | 57 | protected function import_record(importexport_iface_egw_record &$record, &$import_csv) |
| 58 | 58 | { |
| 59 | 59 | // Check for an un-matched accessory of, try again on just name |
@@ -250,14 +250,14 @@ discard block |
||
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
| 253 | - * Returns warnings that were encountered during importing |
|
| 254 | - * Maximum of one warning message per record, but you can append if you need to |
|
| 255 | - * |
|
| 256 | - * @return Array ( |
|
| 257 | - * record_# => warning message |
|
| 258 | - * ) |
|
| 259 | - */ |
|
| 260 | - public function get_warnings() { |
|
| 253 | + * Returns warnings that were encountered during importing |
|
| 254 | + * Maximum of one warning message per record, but you can append if you need to |
|
| 255 | + * |
|
| 256 | + * @return Array ( |
|
| 257 | + * record_# => warning message |
|
| 258 | + * ) |
|
| 259 | + */ |
|
| 260 | + public function get_warnings() { |
|
| 261 | 261 | return $this->warnings; |
| 262 | 262 | } |
| 263 | 263 | } |
@@ -16,7 +16,8 @@ discard block |
||
| 16 | 16 | /** |
| 17 | 17 | * class to import resources from CSV |
| 18 | 18 | */ |
| 19 | -class resources_import_csv extends importexport_basic_import_csv { |
|
| 19 | +class resources_import_csv extends importexport_basic_import_csv |
|
| 20 | +{ |
|
| 20 | 21 | |
| 21 | 22 | |
| 22 | 23 | /** |
@@ -32,7 +33,8 @@ discard block |
||
| 32 | 33 | * @param string $_charset |
| 33 | 34 | * @param definition $_definition |
| 34 | 35 | */ |
| 35 | - public function init(importexport_definition $_definition ) { |
|
| 36 | + public function init(importexport_definition $_definition ) |
|
| 37 | + { |
|
| 36 | 38 | |
| 37 | 39 | // fetch the resource bo |
| 38 | 40 | $this->bo = new resources_bo(); |
@@ -92,7 +94,8 @@ discard block |
||
| 92 | 94 | // Check for a new category, it needs permissions set |
| 93 | 95 | $category = $GLOBALS['egw']->categories->read($record->cat_id); |
| 94 | 96 | |
| 95 | - if($category['last_mod'] >= $this->start_time) { |
|
| 97 | + if($category['last_mod'] >= $this->start_time) |
|
| 98 | + { |
|
| 96 | 99 | // New category. Give read & write permissions to the current user's default group |
| 97 | 100 | $this->acl_bo->set_rights($record['cat_id'], |
| 98 | 101 | array($GLOBALS['egw_info']['user']['account_primary_group']), |
@@ -104,35 +107,53 @@ discard block |
||
| 104 | 107 | // Refresh ACL |
| 105 | 108 | //$GLOBALS['egw']->acl->read_repository(); |
| 106 | 109 | } |
| 107 | - if(!$record->accessory_of) $record->accessory_of = -1; |
|
| 110 | + if(!$record->accessory_of) |
|
| 111 | + { |
|
| 112 | + $record->accessory_of = -1; |
|
| 113 | + } |
|
| 108 | 114 | //error_log(__METHOD__.__LINE__.array2string($_definition->plugin_options['conditions'])); |
| 109 | - if ($this->definition->plugin_options['conditions']) { |
|
| 115 | + if ($this->definition->plugin_options['conditions']) |
|
| 116 | + { |
|
| 110 | 117 | |
| 111 | - foreach ( $this->definition->plugin_options['conditions'] as $condition ) { |
|
| 118 | + foreach ( $this->definition->plugin_options['conditions'] as $condition ) |
|
| 119 | + { |
|
| 112 | 120 | $results = array(); |
| 113 | - switch ( $condition['type'] ) { |
|
| 121 | + switch ( $condition['type'] ) |
|
| 122 | + { |
|
| 114 | 123 | // exists |
| 115 | 124 | case 'exists' : |
| 116 | - if($record->$condition['string']) { |
|
| 125 | + if($record->$condition['string']) |
|
| 126 | + { |
|
| 117 | 127 | $results = $this->bo->so->search( |
| 118 | 128 | array( $condition['string'] => $record->$condition['string']), |
| 119 | 129 | False |
| 120 | 130 | ); |
| 121 | 131 | } |
| 122 | 132 | |
| 123 | - if ( is_array( $results ) && count( array_keys( $results )) >= 1) { |
|
| 133 | + if ( is_array( $results ) && count( array_keys( $results )) >= 1) |
|
| 134 | + { |
|
| 124 | 135 | // apply action to all contacts matching this exists condition |
| 125 | 136 | $action = $condition['true']; |
| 126 | - foreach ( (array)$results as $resource ) { |
|
| 137 | + foreach ( (array)$results as $resource ) |
|
| 138 | + { |
|
| 127 | 139 | $record->res_id = $resource['res_id']; |
| 128 | - if ( $_definition->plugin_options['update_cats'] == 'add' ) { |
|
| 129 | - if ( !is_array( $resource['cat_id'] ) ) $resource['cat_id'] = explode( ',', $resource['cat_id'] ); |
|
| 130 | - if ( !is_array( $record->cat_id ) ) $record->cat_id = explode( ',', $record->cat_id ); |
|
| 140 | + if ( $_definition->plugin_options['update_cats'] == 'add' ) |
|
| 141 | + { |
|
| 142 | + if ( !is_array( $resource['cat_id'] ) ) |
|
| 143 | + { |
|
| 144 | + $resource['cat_id'] = explode( ',', $resource['cat_id'] ); |
|
| 145 | + } |
|
| 146 | + if ( !is_array( $record->cat_id ) ) |
|
| 147 | + { |
|
| 148 | + $record->cat_id = explode( ',', $record->cat_id ); |
|
| 149 | + } |
|
| 131 | 150 | $record->cat_id = implode( ',', array_unique( array_merge( $record->cat_id, $resource['cat_id'] ) ) ); |
| 132 | 151 | } |
| 133 | 152 | $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
| 134 | 153 | } |
| 135 | - } else { |
|
| 154 | + } |
|
| 155 | + else |
|
| 156 | + { |
|
| 136 | 157 | $action = $condition['false']; |
| 137 | 158 | $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
| 138 | 159 | } |
@@ -143,9 +164,14 @@ discard block |
||
| 143 | 164 | die('condition / action not supported!!!'); |
| 144 | 165 | break; |
| 145 | 166 | } |
| 146 | - if ($action['last']) break; |
|
| 167 | + if ($action['last']) |
|
| 168 | + { |
|
| 169 | + break; |
|
| 170 | + } |
|
| 147 | 171 | } |
| 148 | - } else { |
|
| 172 | + } |
|
| 173 | + else |
|
| 174 | + { |
|
| 149 | 175 | // unconditional insert |
| 150 | 176 | $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
| 151 | 177 | } |
@@ -159,9 +185,11 @@ discard block |
||
| 159 | 185 | * @param importexport_iface_egw_record $record Entry record |
| 160 | 186 | * @return bool success or not |
| 161 | 187 | */ |
| 162 | - protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) { |
|
| 188 | + protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) |
|
| 189 | + { |
|
| 163 | 190 | $_data = $record->get_record_array(); |
| 164 | - switch ($_action) { |
|
| 191 | + switch ($_action) |
|
| 192 | + { |
|
| 165 | 193 | case 'none' : |
| 166 | 194 | return true; |
| 167 | 195 | case 'update' : |
@@ -173,20 +201,27 @@ discard block |
||
| 173 | 201 | |
| 174 | 202 | // Fall through |
| 175 | 203 | case 'insert' : |
| 176 | - if($_action == 'insert') { |
|
| 204 | + if($_action == 'insert') |
|
| 205 | + { |
|
| 177 | 206 | // Backend doesn't like inserting with ID specified, it can overwrite |
| 178 | 207 | unset($_data['res_id']); |
| 179 | 208 | } |
| 180 | - if ( $this->dry_run ) { |
|
| 209 | + if ( $this->dry_run ) |
|
| 210 | + { |
|
| 181 | 211 | //print_r($_data); |
| 182 | 212 | $this->results[$_action]++; |
| 183 | 213 | return true; |
| 184 | - } else { |
|
| 214 | + } |
|
| 215 | + else |
|
| 216 | + { |
|
| 185 | 217 | $result = $this->bo->save( $_data ); |
| 186 | - if($result && !is_numeric($result)) { |
|
| 218 | + if($result && !is_numeric($result)) |
|
| 219 | + { |
|
| 187 | 220 | $this->errors[$record_num] = $result; |
| 188 | 221 | return false; |
| 189 | - } else { |
|
| 222 | + } |
|
| 223 | + else |
|
| 224 | + { |
|
| 190 | 225 | $this->results[$_action]++; |
| 191 | 226 | return true; |
| 192 | 227 | } |
@@ -202,7 +237,8 @@ discard block |
||
| 202 | 237 | * |
| 203 | 238 | * @return string name |
| 204 | 239 | */ |
| 205 | - public static function get_name() { |
|
| 240 | + public static function get_name() |
|
| 241 | + { |
|
| 206 | 242 | return lang('Resources CSV import'); |
| 207 | 243 | } |
| 208 | 244 | |
@@ -211,7 +247,8 @@ discard block |
||
| 211 | 247 | * |
| 212 | 248 | * @return string descriprion |
| 213 | 249 | */ |
| 214 | - public static function get_description() { |
|
| 250 | + public static function get_description() |
|
| 251 | + { |
|
| 215 | 252 | return lang("Imports a list of resources from a CSV file."); |
| 216 | 253 | } |
| 217 | 254 | |
@@ -220,7 +257,8 @@ discard block |
||
| 220 | 257 | * |
| 221 | 258 | * @return string suffix (comma seperated) |
| 222 | 259 | */ |
| 223 | - public static function get_filesuffix() { |
|
| 260 | + public static function get_filesuffix() |
|
| 261 | + { |
|
| 224 | 262 | return 'csv'; |
| 225 | 263 | } |
| 226 | 264 | |
@@ -236,7 +274,8 @@ discard block |
||
| 236 | 274 | * preserv => array, |
| 237 | 275 | * ) |
| 238 | 276 | */ |
| 239 | - public function get_options_etpl() { |
|
| 277 | + public function get_options_etpl() |
|
| 278 | + { |
|
| 240 | 279 | // lets do it! |
| 241 | 280 | } |
| 242 | 281 | |
@@ -245,7 +284,8 @@ discard block |
||
| 245 | 284 | * |
| 246 | 285 | * @return string etemplate name |
| 247 | 286 | */ |
| 248 | - public function get_selectors_etpl() { |
|
| 287 | + public function get_selectors_etpl() |
|
| 288 | + { |
|
| 249 | 289 | // lets do it! |
| 250 | 290 | } |
| 251 | 291 | |
@@ -257,7 +297,8 @@ discard block |
||
| 257 | 297 | * record_# => warning message |
| 258 | 298 | * ) |
| 259 | 299 | */ |
| 260 | - public function get_warnings() { |
|
| 300 | + public function get_warnings() |
|
| 301 | + { |
|
| 261 | 302 | return $this->warnings; |
| 262 | 303 | } |
| 263 | 304 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * class to import resources from CSV |
| 17 | 17 | */ |
| 18 | -class resources_import_csv extends importexport_basic_import_csv { |
|
| 18 | +class resources_import_csv extends importexport_basic_import_csv { |
|
| 19 | 19 | |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @var array |
| 25 | 25 | */ |
| 26 | - protected static $conditions = array( 'exists' ); |
|
| 26 | + protected static $conditions = array('exists'); |
|
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * imports entries according to given definition object. |
@@ -31,13 +31,13 @@ discard block |
||
| 31 | 31 | * @param string $_charset |
| 32 | 32 | * @param definition $_definition |
| 33 | 33 | */ |
| 34 | - public function init(importexport_definition $_definition ) { |
|
| 34 | + public function init(importexport_definition $_definition) { |
|
| 35 | 35 | |
| 36 | 36 | // fetch the resource bo |
| 37 | 37 | $this->bo = new resources_bo(); |
| 38 | 38 | |
| 39 | 39 | // For adding ACLs |
| 40 | - $this->acl_bo = CreateObject('resources.bo_acl',True); |
|
| 40 | + $this->acl_bo = CreateObject('resources.bo_acl', True); |
|
| 41 | 41 | |
| 42 | 42 | // For checking categories |
| 43 | 43 | $this->start_time = time(); |
@@ -53,33 +53,33 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @return boolean success |
| 55 | 55 | */ |
| 56 | - protected function import_record(importexport_iface_egw_record &$record, &$import_csv) |
|
| 56 | + protected function import_record(importexport_iface_egw_record&$record, &$import_csv) |
|
| 57 | 57 | { |
| 58 | 58 | // Check for an un-matched accessory of, try again on just name |
| 59 | - if(!is_numeric($record->accessory_of)) |
|
| 59 | + if (!is_numeric($record->accessory_of)) |
|
| 60 | 60 | { |
| 61 | 61 | $accessory_of = $record->accessory_of; |
| 62 | 62 | |
| 63 | 63 | // Look for exact match in just name |
| 64 | - $results = $this->bo->so->search(array('name' => $record->accessory_of),array('res_id','name')); |
|
| 65 | - if(count($results) >= 1) |
|
| 64 | + $results = $this->bo->so->search(array('name' => $record->accessory_of), array('res_id', 'name')); |
|
| 65 | + if (count($results) >= 1) |
|
| 66 | 66 | { |
| 67 | 67 | // More than 1 result? Bad names. Pick one. |
| 68 | - foreach($results as $result) |
|
| 68 | + foreach ($results as $result) |
|
| 69 | 69 | { |
| 70 | - if($result['name'] == $record->accessory_of) |
|
| 70 | + if ($result['name'] == $record->accessory_of) |
|
| 71 | 71 | { |
| 72 | 72 | $record->accessory_of = $result['res_id']; |
| 73 | 73 | break; |
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | - if(is_numeric($record->accessory_of)) |
|
| 76 | + if (is_numeric($record->accessory_of)) |
|
| 77 | 77 | { |
| 78 | 78 | // Import/Export conversion gave a warning, so cancel it |
| 79 | - $pattern = lang('Unable to link to %1 "%2"',lang('resources'),$accessory_of) . ' - ('.lang('too many matches') . '|'.lang('no matches') . ')'; |
|
| 79 | + $pattern = lang('Unable to link to %1 "%2"', lang('resources'), $accessory_of).' - ('.lang('too many matches').'|'.lang('no matches').')'; |
|
| 80 | 80 | $this->warnings[$import_csv->get_current_position()] = preg_replace($pattern, '', $this->warnings[$import_csv->get_current_position()], 1); |
| 81 | 81 | // If that was the only warning, clear it for this row |
| 82 | - if(trim($this->warnings[$import_csv->get_current_position()]) == '') |
|
| 82 | + if (trim($this->warnings[$import_csv->get_current_position()]) == '') |
|
| 83 | 83 | { |
| 84 | 84 | unset($this->warnings[$import_csv->get_current_position()]); |
| 85 | 85 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | // Check for a new category, it needs permissions set |
| 92 | 92 | $category = $GLOBALS['egw']->categories->read($record->cat_id); |
| 93 | 93 | |
| 94 | - if($category['last_mod'] >= $this->start_time) { |
|
| 94 | + if ($category['last_mod'] >= $this->start_time) { |
|
| 95 | 95 | // New category. Give read & write permissions to the current user's default group |
| 96 | 96 | $this->acl_bo->set_rights($record['cat_id'], |
| 97 | 97 | array($GLOBALS['egw_info']['user']['account_primary_group']), |
@@ -103,37 +103,37 @@ discard block |
||
| 103 | 103 | // Refresh ACL |
| 104 | 104 | //$GLOBALS['egw']->acl->read_repository(); |
| 105 | 105 | } |
| 106 | - if(!$record->accessory_of) $record->accessory_of = -1; |
|
| 106 | + if (!$record->accessory_of) $record->accessory_of = -1; |
|
| 107 | 107 | //error_log(__METHOD__.__LINE__.array2string($_definition->plugin_options['conditions'])); |
| 108 | 108 | if ($this->definition->plugin_options['conditions']) { |
| 109 | 109 | |
| 110 | - foreach ( $this->definition->plugin_options['conditions'] as $condition ) { |
|
| 110 | + foreach ($this->definition->plugin_options['conditions'] as $condition) { |
|
| 111 | 111 | $results = array(); |
| 112 | - switch ( $condition['type'] ) { |
|
| 112 | + switch ($condition['type']) { |
|
| 113 | 113 | // exists |
| 114 | 114 | case 'exists' : |
| 115 | - if($record->$condition['string']) { |
|
| 115 | + if ($record->$condition['string']) { |
|
| 116 | 116 | $results = $this->bo->so->search( |
| 117 | - array( $condition['string'] => $record->$condition['string']), |
|
| 117 | + array($condition['string'] => $record->$condition['string']), |
|
| 118 | 118 | False |
| 119 | 119 | ); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - if ( is_array( $results ) && count( array_keys( $results )) >= 1) { |
|
| 122 | + if (is_array($results) && count(array_keys($results)) >= 1) { |
|
| 123 | 123 | // apply action to all contacts matching this exists condition |
| 124 | 124 | $action = $condition['true']; |
| 125 | - foreach ( (array)$results as $resource ) { |
|
| 125 | + foreach ((array)$results as $resource) { |
|
| 126 | 126 | $record->res_id = $resource['res_id']; |
| 127 | - if ( $_definition->plugin_options['update_cats'] == 'add' ) { |
|
| 128 | - if ( !is_array( $resource['cat_id'] ) ) $resource['cat_id'] = explode( ',', $resource['cat_id'] ); |
|
| 129 | - if ( !is_array( $record->cat_id ) ) $record->cat_id = explode( ',', $record->cat_id ); |
|
| 130 | - $record->cat_id = implode( ',', array_unique( array_merge( $record->cat_id, $resource['cat_id'] ) ) ); |
|
| 127 | + if ($_definition->plugin_options['update_cats'] == 'add') { |
|
| 128 | + if (!is_array($resource['cat_id'])) $resource['cat_id'] = explode(',', $resource['cat_id']); |
|
| 129 | + if (!is_array($record->cat_id)) $record->cat_id = explode(',', $record->cat_id); |
|
| 130 | + $record->cat_id = implode(',', array_unique(array_merge($record->cat_id, $resource['cat_id']))); |
|
| 131 | 131 | } |
| 132 | - $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); |
|
| 132 | + $success = $this->action($action['action'], $record, $import_csv->get_current_position()); |
|
| 133 | 133 | } |
| 134 | 134 | } else { |
| 135 | 135 | $action = $condition['false']; |
| 136 | - $success = ($this->action( $action['action'], $record, $import_csv->get_current_position() )); |
|
| 136 | + $success = ($this->action($action['action'], $record, $import_csv->get_current_position())); |
|
| 137 | 137 | } |
| 138 | 138 | break; |
| 139 | 139 | |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | } |
| 147 | 147 | } else { |
| 148 | 148 | // unconditional insert |
| 149 | - $success = $this->action( 'insert', $record, $import_csv->get_current_position() ); |
|
| 149 | + $success = $this->action('insert', $record, $import_csv->get_current_position()); |
|
| 150 | 150 | } |
| 151 | 151 | return $success; |
| 152 | 152 | } |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @param importexport_iface_egw_record $record Entry record |
| 159 | 159 | * @return bool success or not |
| 160 | 160 | */ |
| 161 | - protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) { |
|
| 161 | + protected function action($_action, importexport_iface_egw_record&$record, $record_num = 0) { |
|
| 162 | 162 | $_data = $record->get_record_array(); |
| 163 | 163 | switch ($_action) { |
| 164 | 164 | case 'none' : |
@@ -172,17 +172,17 @@ discard block |
||
| 172 | 172 | |
| 173 | 173 | // Fall through |
| 174 | 174 | case 'insert' : |
| 175 | - if($_action == 'insert') { |
|
| 175 | + if ($_action == 'insert') { |
|
| 176 | 176 | // Backend doesn't like inserting with ID specified, it can overwrite |
| 177 | 177 | unset($_data['res_id']); |
| 178 | 178 | } |
| 179 | - if ( $this->dry_run ) { |
|
| 179 | + if ($this->dry_run) { |
|
| 180 | 180 | //print_r($_data); |
| 181 | 181 | $this->results[$_action]++; |
| 182 | 182 | return true; |
| 183 | 183 | } else { |
| 184 | - $result = $this->bo->save( $_data ); |
|
| 185 | - if($result && !is_numeric($result)) { |
|
| 184 | + $result = $this->bo->save($_data); |
|
| 185 | + if ($result && !is_numeric($result)) { |
|
| 186 | 186 | $this->errors[$record_num] = $result; |
| 187 | 187 | return false; |
| 188 | 188 | } else { |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | * |
| 34 | 34 | * @param string $key key of value to get |
| 35 | 35 | * @param int $res_id resource id |
| 36 | - * @return mixed value of key and resource, false if key or id not found. |
|
| 36 | + * @return integer value of key and resource, false if key or id not found. |
|
| 37 | 37 | */ |
| 38 | 38 | function get_value($key,$res_id) |
| 39 | 39 | { |
@@ -22,10 +22,10 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | function __construct() |
| 24 | 24 | { |
| 25 | - parent::__construct('resources','egw_resources', 'egw_resources_extra', '', |
|
| 26 | - 'extra_name', 'extra_value', 'extra_id' ); |
|
| 25 | + parent::__construct('resources', 'egw_resources', 'egw_resources_extra', '', |
|
| 26 | + 'extra_name', 'extra_value', 'extra_id'); |
|
| 27 | 27 | |
| 28 | - $this->columns_to_search = array('name','short_description','inventory_number','long_description','location'); |
|
| 28 | + $this->columns_to_search = array('name', 'short_description', 'inventory_number', 'long_description', 'location'); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -35,10 +35,9 @@ discard block |
||
| 35 | 35 | * @param int $res_id resource id |
| 36 | 36 | * @return mixed value of key and resource, false if key or id not found. |
| 37 | 37 | */ |
| 38 | - function get_value($key,$res_id) |
|
| 38 | + function get_value($key, $res_id) |
|
| 39 | 39 | { |
| 40 | - return $res_id == $this->data['res_id'] ? $this->data[$key] : |
|
| 41 | - $this->db->select($this->table_name,$key,array('res_id' => $res_id),__LINE__,__FILE__)->fetchColumn(); |
|
| 40 | + return $res_id == $this->data['res_id'] ? $this->data[$key] : $this->db->select($this->table_name, $key, array('res_id' => $res_id), __LINE__, __FILE__)->fetchColumn(); |
|
| 42 | 41 | } |
| 43 | 42 | |
| 44 | 43 | /** |
@@ -90,7 +89,7 @@ discard block |
||
| 90 | 89 | function save($resource) |
| 91 | 90 | { |
| 92 | 91 | $this->data = $resource; |
| 93 | - if(parent::save() != 0) return false; |
|
| 92 | + if (parent::save() != 0) return false; |
|
| 94 | 93 | $res_id = $this->data['res_id']; |
| 95 | 94 | |
| 96 | 95 | return $res_id; |
@@ -51,7 +51,10 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | function read($res_id) |
| 53 | 53 | { |
| 54 | - if (is_array($res_id) && count($res_id) == 1 && isset($res_id['res_id'])) $res_id = $res_id['res_id']; |
|
| 54 | + if (is_array($res_id) && count($res_id) == 1 && isset($res_id['res_id'])) |
|
| 55 | + { |
|
| 56 | + $res_id = $res_id['res_id']; |
|
| 57 | + } |
|
| 55 | 58 | |
| 56 | 59 | /*if (!is_array($res_id) && $res_id == $this->data['res_id']) |
| 57 | 60 | { |
@@ -90,7 +93,10 @@ discard block |
||
| 90 | 93 | function save($resource) |
| 91 | 94 | { |
| 92 | 95 | $this->data = $resource; |
| 93 | - if(parent::save() != 0) return false; |
|
| 96 | + if(parent::save() != 0) |
|
| 97 | + { |
|
| 98 | + return false; |
|
| 99 | + } |
|
| 94 | 100 | $res_id = $this->data['res_id']; |
| 95 | 101 | |
| 96 | 102 | return $res_id; |
@@ -936,9 +936,6 @@ |
||
| 936 | 936 | * |
| 937 | 937 | * Uses $this->ldap_host, $this->ldap_admin and $this->ldap_admin_pw to connect. |
| 938 | 938 | * |
| 939 | - * @param string $this->object_class ='qmailUser' |
|
| 940 | - * @param string $this->mbox_attr ='mailmessagestore' lowercase!!! |
|
| 941 | - * @param string $this->mail_login_type ='email' 'email', 'vmailmgr', 'standard' or 'uidNumber' |
|
| 942 | 939 | * @return string with success message N entries modified |
| 943 | 940 | * @throws Api\Exception if dn not found, not listable or delete fails |
| 944 | 941 | */ |
@@ -82,9 +82,9 @@ discard block |
||
| 82 | 82 | * @param string $ldap_encryption_type ='des' |
| 83 | 83 | * @param boolean $truncate_egw_accounts =false truncate accounts table before migration to SQL |
| 84 | 84 | */ |
| 85 | - function __construct($domain,$ldap_host=null,$ldap_suffix=null,$ldap_admin=null,$ldap_admin_pw=null, |
|
| 86 | - $ldap_base=null,$ldap_root_dn=null,$ldap_root_pw=null,$ldap_context=null,$ldap_search_filter=null, |
|
| 87 | - $ldap_group_context=null,$sub_command='create_ldap',$ldap_encryption_type='des',$truncate_egw_accounts=false) |
|
| 85 | + function __construct($domain, $ldap_host = null, $ldap_suffix = null, $ldap_admin = null, $ldap_admin_pw = null, |
|
| 86 | + $ldap_base = null, $ldap_root_dn = null, $ldap_root_pw = null, $ldap_context = null, $ldap_search_filter = null, |
|
| 87 | + $ldap_group_context = null, $sub_command = 'create_ldap', $ldap_encryption_type = 'des', $truncate_egw_accounts = false) |
|
| 88 | 88 | { |
| 89 | 89 | if (!is_array($domain)) |
| 90 | 90 | { |
@@ -117,23 +117,23 @@ discard block |
||
| 117 | 117 | * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); |
| 118 | 118 | * @throws Exception('header.inc.php not found!'); |
| 119 | 119 | */ |
| 120 | - protected function exec($check_only=false) |
|
| 120 | + protected function exec($check_only = false) |
|
| 121 | 121 | { |
| 122 | - if (!empty($this->domain) && !preg_match('/^([a-z0-9_-]+\.)*[a-z0-9]+/i',$this->domain)) |
|
| 122 | + if (!empty($this->domain) && !preg_match('/^([a-z0-9_-]+\.)*[a-z0-9]+/i', $this->domain)) |
|
| 123 | 123 | { |
| 124 | - throw new egw_exception_wrong_userinput(lang("'%1' is no valid domain name!",$this->domain)); |
|
| 124 | + throw new egw_exception_wrong_userinput(lang("'%1' is no valid domain name!", $this->domain)); |
|
| 125 | 125 | } |
| 126 | 126 | if ($this->remote_id && $check_only && !in_array($this->sub_command, array('set_mailbox', 'sid2uidnumber', 'copy2ad'))) |
| 127 | 127 | { |
| 128 | - return true; // further checks can only done locally |
|
| 128 | + return true; // further checks can only done locally |
|
| 129 | 129 | } |
| 130 | 130 | $this->_merge_defaults(); |
| 131 | 131 | //_debug_array($this->as_array()); |
| 132 | 132 | |
| 133 | - switch($this->sub_command) |
|
| 133 | + switch ($this->sub_command) |
|
| 134 | 134 | { |
| 135 | 135 | case 'test_ldap_root': |
| 136 | - $msg = $this->connect($this->ldap_admin,$this->ldap_admin_pw); |
|
| 136 | + $msg = $this->connect($this->ldap_admin, $this->ldap_admin_pw); |
|
| 137 | 137 | break; |
| 138 | 138 | case 'test_ldap': |
| 139 | 139 | $msg = $this->connect(); |
@@ -178,28 +178,28 @@ discard block |
||
| 178 | 178 | * |
| 179 | 179 | * @param boolean $check_only =false true: only connect and output necessary commands |
| 180 | 180 | */ |
| 181 | - private function sid2uidnumber($check_only=false) |
|
| 181 | + private function sid2uidnumber($check_only = false) |
|
| 182 | 182 | { |
| 183 | 183 | $msg = array(); |
| 184 | 184 | $this->connect(); |
| 185 | 185 | |
| 186 | 186 | // check if base does exist |
| 187 | - if (!@ldap_read($this->test_ldap->ds,$this->ldap_base,'objectClass=*')) |
|
| 187 | + if (!@ldap_read($this->test_ldap->ds, $this->ldap_base, 'objectClass=*')) |
|
| 188 | 188 | { |
| 189 | - throw new egw_exception_wrong_userinput(lang('Base dn "%1" NOT found!',$this->ldap_base)); |
|
| 189 | + throw new egw_exception_wrong_userinput(lang('Base dn "%1" NOT found!', $this->ldap_base)); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - if (!($sr = ldap_search($this->test_ldap->ds,$this->ldap_base, |
|
| 193 | - $search='(&(|(objectClass=posixAccount)(objectClass=posixGroup))('.self::sambaSID.'=*)(!(uid=*$)))', |
|
| 194 | - array('uidNumber','gidNumber','uid','cn', 'objectClass',self::sambaSID))) || |
|
| 192 | + if (!($sr = ldap_search($this->test_ldap->ds, $this->ldap_base, |
|
| 193 | + $search = '(&(|(objectClass=posixAccount)(objectClass=posixGroup))('.self::sambaSID.'=*)(!(uid=*$)))', |
|
| 194 | + array('uidNumber', 'gidNumber', 'uid', 'cn', 'objectClass', self::sambaSID))) || |
|
| 195 | 195 | !($entries = ldap_get_entries($this->test_ldap->ds, $sr))) |
| 196 | 196 | { |
| 197 | - throw new egw_exception(lang('Error searching "dn=%1" for "%2"!',$this->ldap_base, $search)); |
|
| 197 | + throw new egw_exception(lang('Error searching "dn=%1" for "%2"!', $this->ldap_base, $search)); |
|
| 198 | 198 | } |
| 199 | 199 | $change = $accounts = array(); |
| 200 | 200 | $cmd_change_account_id = 'admin/admin-cli.php --change-account-id <admin>@<domain>,<adminpw>'; |
| 201 | 201 | $change_account_id = ''; |
| 202 | - foreach($entries as $key => $entry) |
|
| 202 | + foreach ($entries as $key => $entry) |
|
| 203 | 203 | { |
| 204 | 204 | if ($key === 'count') continue; |
| 205 | 205 | |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | // now change them in LDAP |
| 236 | 236 | $changed = 0; |
| 237 | - foreach($accounts as $dn => $account) |
|
| 237 | + foreach ($accounts as $dn => $account) |
|
| 238 | 238 | { |
| 239 | 239 | $modify = array(); |
| 240 | 240 | if (!empty($account['uidnumber']) && isset($change[$account['uidnumber']])) |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | if (!$check_only && $modify && !ldap_modify($this->test_ldap->ds, $dn, $modify)) |
| 249 | 249 | { |
| 250 | 250 | throw new egw_exception("Failed to modify ldap: !ldap_modify({$this->test_ldap->ds}, '$dn', ".array2string($modify).") ".ldap_error($this->test_ldap->ds). |
| 251 | - "\n- ".implode("\n- ", $msg)); // EGroupware change already run successful |
|
| 251 | + "\n- ".implode("\n- ", $msg)); // EGroupware change already run successful |
|
| 252 | 252 | } |
| 253 | 253 | if ($modify) ++$changed; |
| 254 | 254 | } |
@@ -263,13 +263,13 @@ discard block |
||
| 263 | 263 | * |
| 264 | 264 | * @param boolean $check_only =false true: only connect and output necessary commands |
| 265 | 265 | */ |
| 266 | - private function copy2ad($check_only=false) |
|
| 266 | + private function copy2ad($check_only = false) |
|
| 267 | 267 | { |
| 268 | 268 | $msg = array(); |
| 269 | 269 | $attrs = $rename = array(); |
| 270 | - foreach(explode(',', $this->attributes) as $attr) |
|
| 270 | + foreach (explode(',', $this->attributes) as $attr) |
|
| 271 | 271 | { |
| 272 | - if ($attr[0] == '@' || // copy whole objectclass without renaming, eg. @inetOrgPerson |
|
| 272 | + if ($attr[0] == '@' || // copy whole objectclass without renaming, eg. @inetOrgPerson |
|
| 273 | 273 | strpos($attr, '=') === false) |
| 274 | 274 | { |
| 275 | 275 | $attrs[] = $attr; |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | $ignore_attr = array_flip(array('dn', 'objectclass', 'cn', 'userpassword')); |
| 285 | 285 | if (!in_array('uid', $attrs)) |
| 286 | 286 | { |
| 287 | - $attrs[] = 'uid'; // need to match account |
|
| 287 | + $attrs[] = 'uid'; // need to match account |
|
| 288 | 288 | $ignore_attr['uid'] = true; |
| 289 | 289 | } |
| 290 | 290 | // connect to destination ads |
@@ -293,9 +293,8 @@ discard block |
||
| 293 | 293 | $this->ads_context = 'CN=Users,DC='.implode(',DC=', explode('.', $this->ads_domain)); |
| 294 | 294 | } |
| 295 | 295 | if (empty($this->ads_admin_user)) $this->ads_admin_user = 'Administrator'; |
| 296 | - $admin_dn = strpos($this->ads_admin_user, '=') !== false ? $this->ads_admin_user : |
|
| 297 | - 'CN='.$this->ads_admin_user.','.$this->ads_context; |
|
| 298 | - switch($this->ads_connection) |
|
| 296 | + $admin_dn = strpos($this->ads_admin_user, '=') !== false ? $this->ads_admin_user : 'CN='.$this->ads_admin_user.','.$this->ads_context; |
|
| 297 | + switch ($this->ads_connection) |
|
| 299 | 298 | { |
| 300 | 299 | case 'ssl': |
| 301 | 300 | $url = 'ldaps://'.$this->ads_host.'/'; |
@@ -313,28 +312,27 @@ discard block |
||
| 313 | 312 | // check if ads base does exist |
| 314 | 313 | if (!@ldap_read($ads->ds, $this->ads_context, 'objectClass=*')) |
| 315 | 314 | { |
| 316 | - throw new egw_exception_wrong_userinput(lang('Ads dn "%1" NOT found!',$this->ads_context)); |
|
| 315 | + throw new egw_exception_wrong_userinput(lang('Ads dn "%1" NOT found!', $this->ads_context)); |
|
| 317 | 316 | } |
| 318 | 317 | |
| 319 | 318 | // connect to source ldap |
| 320 | 319 | $this->connect(); |
| 321 | 320 | |
| 322 | 321 | // check if ldap base does exist |
| 323 | - if (!@ldap_read($this->test_ldap->ds,$this->ldap_base,'objectClass=*')) |
|
| 322 | + if (!@ldap_read($this->test_ldap->ds, $this->ldap_base, 'objectClass=*')) |
|
| 324 | 323 | { |
| 325 | - throw new egw_exception_wrong_userinput(lang('Base dn "%1" NOT found!',$this->ldap_base)); |
|
| 324 | + throw new egw_exception_wrong_userinput(lang('Base dn "%1" NOT found!', $this->ldap_base)); |
|
| 326 | 325 | } |
| 327 | 326 | |
| 328 | - if (!($sr = ldap_search($this->test_ldap->ds,$this->ldap_base, |
|
| 329 | - $search = $this->no_sid_check ? '(objectClass=posixAccount)' : |
|
| 330 | - '(&(objectClass=posixAccount)('.self::sambaSID.'=*)(!(uid=*$)))', $attrs)) || |
|
| 327 | + if (!($sr = ldap_search($this->test_ldap->ds, $this->ldap_base, |
|
| 328 | + $search = $this->no_sid_check ? '(objectClass=posixAccount)' : '(&(objectClass=posixAccount)('.self::sambaSID.'=*)(!(uid=*$)))', $attrs)) || |
|
| 331 | 329 | !($entries = ldap_get_entries($this->test_ldap->ds, $sr))) |
| 332 | 330 | { |
| 333 | - throw new egw_exception(lang('Error searching "dn=%1" for "%2"!',$this->ldap_base, $search)); |
|
| 331 | + throw new egw_exception(lang('Error searching "dn=%1" for "%2"!', $this->ldap_base, $search)); |
|
| 334 | 332 | } |
| 335 | 333 | $changed = 0; |
| 336 | 334 | $utc_diff = null; |
| 337 | - foreach($entries as $key => $entry) |
|
| 335 | + foreach ($entries as $key => $entry) |
|
| 338 | 336 | { |
| 339 | 337 | if ($key === 'count') continue; |
| 340 | 338 | |
@@ -343,7 +341,7 @@ discard block |
||
| 343 | 341 | $entry = array_diff_key($entry_arr, $ignore_attr); |
| 344 | 342 | |
| 345 | 343 | if (!($sr = ldap_search($ads->ds, $this->ads_context, |
| 346 | - $search='(&(objectClass=user)(sAMAccountName='.ldap::quote($uid).'))', array('dn'))) || |
|
| 344 | + $search = '(&(objectClass=user)(sAMAccountName='.ldap::quote($uid).'))', array('dn'))) || |
|
| 347 | 345 | !($dest = ldap_get_entries($ads->ds, $sr))) |
| 348 | 346 | { |
| 349 | 347 | $msg[] = lang('User "%1" not found!', $uid); |
@@ -363,11 +361,11 @@ discard block |
||
| 363 | 361 | { |
| 364 | 362 | if (is_null($utc_diff)) $utc_diff = date('Z'); |
| 365 | 363 | $entry['shadowexpire'] = accounts_ads::convertUnixTimeToWindowsTime( |
| 366 | - $entry['shadowexpire']*24*3600+$utc_diff); // ldap time to unixTime |
|
| 364 | + $entry['shadowexpire'] * 24 * 3600 + $utc_diff); // ldap time to unixTime |
|
| 367 | 365 | } |
| 368 | 366 | } |
| 369 | 367 | $update = array(); |
| 370 | - foreach($entry as $attr => $value) |
|
| 368 | + foreach ($entry as $attr => $value) |
|
| 371 | 369 | { |
| 372 | 370 | if ($value || $attr === '') |
| 373 | 371 | { |
@@ -377,14 +375,14 @@ discard block |
||
| 377 | 375 | { |
| 378 | 376 | list($prefix, $to) = explode('}', substr($to, 1)); |
| 379 | 377 | } |
| 380 | - foreach((array)$value as $val) |
|
| 378 | + foreach ((array)$value as $val) |
|
| 381 | 379 | { |
| 382 | 380 | if (isset($update[$to])) |
| 383 | 381 | { |
| 384 | 382 | if (!is_array($update[$to])) $update[$to] = array($update[$to]); |
| 385 | 383 | // we need to check (caseinsensitive) if value already exists in set |
| 386 | 384 | // as AD chokes on doublicate values "Type or value exists" |
| 387 | - foreach($update[$to] as $v) |
|
| 385 | + foreach ($update[$to] as $v) |
|
| 388 | 386 | { |
| 389 | 387 | if (!strcasecmp($v, $prefix.$val)) continue 2; |
| 390 | 388 | } |
@@ -416,7 +414,7 @@ discard block |
||
| 416 | 414 | if ($check_only) return lang("%1 accounts to copy found.", count($entries)); |
| 417 | 415 | |
| 418 | 416 | return "Copied data of $changed accounts from LDAP to AD ". |
| 419 | - (count($msg) > $changed ? ' ('.(count($msg)-$changed).' errors!)' : ''); |
|
| 417 | + (count($msg) > $changed ? ' ('.(count($msg) - $changed).' errors!)' : ''); |
|
| 420 | 418 | } |
| 421 | 419 | |
| 422 | 420 | /** |
@@ -459,9 +457,9 @@ discard block |
||
| 459 | 457 | $accounts_created = $groups_created = $errors = $egw_info_set = 0; |
| 460 | 458 | $emailadmin_src = $ldap_class = null; |
| 461 | 459 | $target = strtoupper($to); |
| 462 | - foreach($accounts as $account_id => $account) |
|
| 460 | + foreach ($accounts as $account_id => $account) |
|
| 463 | 461 | { |
| 464 | - if (isset($this->only) && !in_array($account_id,$this->only)) |
|
| 462 | + if (isset($this->only) && !in_array($account_id, $this->only)) |
|
| 465 | 463 | { |
| 466 | 464 | continue; |
| 467 | 465 | } |
@@ -481,12 +479,12 @@ discard block |
||
| 481 | 479 | { |
| 482 | 480 | if (!($sql_account = $accounts_obj->read($account_id))) |
| 483 | 481 | { |
| 484 | - $msg[] = lang('%1 does NOT exist in %2.',$what,$target); |
|
| 482 | + $msg[] = lang('%1 does NOT exist in %2.', $what, $target); |
|
| 485 | 483 | $errors++; |
| 486 | 484 | } |
| 487 | - elseif(empty($account['account_pwd'])) |
|
| 485 | + elseif (empty($account['account_pwd'])) |
|
| 488 | 486 | { |
| 489 | - $msg[] = lang('%1 does NOT have a password (userPassword attribute) or we are not allowed to read it!',$what); |
|
| 487 | + $msg[] = lang('%1 does NOT have a password (userPassword attribute) or we are not allowed to read it!', $what); |
|
| 490 | 488 | $errors++; |
| 491 | 489 | } |
| 492 | 490 | else |
@@ -495,12 +493,12 @@ discard block |
||
| 495 | 493 | |
| 496 | 494 | if (!$accounts_obj->save($sql_account)) |
| 497 | 495 | { |
| 498 | - $msg[] = lang('Update of %1 in %2 failed !!!',$what,$target); |
|
| 496 | + $msg[] = lang('Update of %1 in %2 failed !!!', $what, $target); |
|
| 499 | 497 | $errors++; |
| 500 | 498 | } |
| 501 | 499 | else |
| 502 | 500 | { |
| 503 | - $msg[] = lang('%1 password set in %2.',$what,$target); |
|
| 501 | + $msg[] = lang('%1 password set in %2.', $what, $target); |
|
| 504 | 502 | $accounts_created++; |
| 505 | 503 | } |
| 506 | 504 | } |
@@ -511,7 +509,7 @@ discard block |
||
| 511 | 509 | { |
| 512 | 510 | if ($accounts_obj->exists($account_id)) |
| 513 | 511 | { |
| 514 | - $msg[] = lang('%1 already exists in %2.',$what,$target); |
|
| 512 | + $msg[] = lang('%1 already exists in %2.', $what, $target); |
|
| 515 | 513 | $errors++; |
| 516 | 514 | continue; |
| 517 | 515 | } |
@@ -519,7 +517,7 @@ discard block |
||
| 519 | 517 | { |
| 520 | 518 | if ($GLOBALS['egw_info']['server']['ldap_extra_attributes']) |
| 521 | 519 | { |
| 522 | - $account['homedirectory'] = $GLOBALS['egw_info']['server']['ldap_account_home'] . '/' . $account['account_lid']; |
|
| 520 | + $account['homedirectory'] = $GLOBALS['egw_info']['server']['ldap_account_home'].'/'.$account['account_lid']; |
|
| 523 | 521 | $account['loginshell'] = $GLOBALS['egw_info']['server']['ldap_account_shell']; |
| 524 | 522 | } |
| 525 | 523 | $account['account_passwd'] = self::hash_sql2ldap($account['account_pwd']); |
@@ -532,12 +530,12 @@ discard block |
||
| 532 | 530 | |
| 533 | 531 | if (!$accounts_obj->save($account)) |
| 534 | 532 | { |
| 535 | - $msg[] = lang('Creation of %1 in %2 failed !!!',$what,$target); |
|
| 533 | + $msg[] = lang('Creation of %1 in %2 failed !!!', $what, $target); |
|
| 536 | 534 | $errors++; |
| 537 | 535 | continue; |
| 538 | 536 | } |
| 539 | - $accounts_obj->set_memberships($account['memberships'],$account_id); |
|
| 540 | - $msg[] = lang('%1 created in %2.',$what,$target); |
|
| 537 | + $accounts_obj->set_memberships($account['memberships'], $account_id); |
|
| 538 | + $msg[] = lang('%1 created in %2.', $what, $target); |
|
| 541 | 539 | $accounts_created++; |
| 542 | 540 | |
| 543 | 541 | // check if we need to migrate mail-account |
@@ -546,7 +544,7 @@ discard block |
||
| 546 | 544 | $ldap_class = false; |
| 547 | 545 | $ldap = new ldap(); |
| 548 | 546 | $ldap->ldapConnect(); |
| 549 | - foreach(array( // todo: have these enumerated by emailadmin ... |
|
| 547 | + foreach (array( // todo: have these enumerated by emailadmin ... |
|
| 550 | 548 | 'qmailUser' => 'postfixldap', |
| 551 | 549 | 'dbMailUser' => 'postfixdbmailuser', |
| 552 | 550 | // nothing to migrate for inetOrgPerson ... |
@@ -594,7 +592,7 @@ discard block |
||
| 594 | 592 | // setting up egw_info array with new ldap information, so hook can use ldap::ldapConnect() |
| 595 | 593 | if (!$egw_info_set++) |
| 596 | 594 | { |
| 597 | - foreach(array('ldap_host','ldap_root_dn','ldap_root_pw','ldap_context','ldap_group_context','ldap_search_filter','ldap_encryptin_type','mail_suffix','mail_login_type') as $name) |
|
| 595 | + foreach (array('ldap_host', 'ldap_root_dn', 'ldap_root_pw', 'ldap_context', 'ldap_group_context', 'ldap_search_filter', 'ldap_encryptin_type', 'mail_suffix', 'mail_login_type') as $name) |
|
| 598 | 596 | { |
| 599 | 597 | if (!empty($this->$name)) $GLOBALS['egw_info']['server'][$name] = $this->$name; |
| 600 | 598 | } |
@@ -606,14 +604,14 @@ discard block |
||
| 606 | 604 | // running all addAccount hooks (currently NOT working, as not all work in setup) |
| 607 | 605 | if ($this->add_account_hook === true) |
| 608 | 606 | { |
| 609 | - $GLOBALS['egw']->hooks->process($account,array(),true); |
|
| 607 | + $GLOBALS['egw']->hooks->process($account, array(), true); |
|
| 610 | 608 | } |
| 611 | - elseif(is_callable($this->add_account_hook)) |
|
| 609 | + elseif (is_callable($this->add_account_hook)) |
|
| 612 | 610 | { |
| 613 | - call_user_func($this->add_account_hook,$account); |
|
| 611 | + call_user_func($this->add_account_hook, $account); |
|
| 614 | 612 | } |
| 615 | 613 | } |
| 616 | - catch(Exception $e) |
|
| 614 | + catch (Exception $e) |
|
| 617 | 615 | { |
| 618 | 616 | $msg[] = $e->getMessage(); |
| 619 | 617 | $errors++; |
@@ -627,38 +625,38 @@ discard block |
||
| 627 | 625 | { |
| 628 | 626 | if (!$accounts_obj->save($account)) |
| 629 | 627 | { |
| 630 | - $msg[] = lang('Creation of %1 in %2 failed !!!',$what,$target); |
|
| 628 | + $msg[] = lang('Creation of %1 in %2 failed !!!', $what, $target); |
|
| 631 | 629 | ++$errors; |
| 632 | 630 | continue; |
| 633 | 631 | } |
| 634 | - $msg[] = lang('%1 created in %2.',$what,$target); |
|
| 632 | + $msg[] = lang('%1 created in %2.', $what, $target); |
|
| 635 | 633 | $groups_created++; |
| 636 | 634 | } |
| 637 | 635 | else |
| 638 | 636 | { |
| 639 | - $msg[] = lang('%1 already exists in %2.',$what,$target); |
|
| 637 | + $msg[] = lang('%1 already exists in %2.', $what, $target); |
|
| 640 | 638 | $errors++; |
| 641 | 639 | |
| 642 | 640 | if ($accounts_obj->id2name($account_id) != $account['account_lid']) |
| 643 | 641 | { |
| 644 | - $msg[] = lang("==> different group '%1' under that gidNumber %2, NOT setting memberships!",$account['account_lid'],$account_id); |
|
| 642 | + $msg[] = lang("==> different group '%1' under that gidNumber %2, NOT setting memberships!", $account['account_lid'], $account_id); |
|
| 645 | 643 | ++$errors; |
| 646 | - continue; // different group under that gidnumber! |
|
| 644 | + continue; // different group under that gidnumber! |
|
| 647 | 645 | } |
| 648 | 646 | } |
| 649 | 647 | // now saving / updating the memberships |
| 650 | - $accounts_obj->set_members($account['members'],$account_id); |
|
| 648 | + $accounts_obj->set_members($account['members'], $account_id); |
|
| 651 | 649 | } |
| 652 | 650 | } |
| 653 | 651 | if ($passwords2sql) |
| 654 | 652 | { |
| 655 | - return lang('%1 passwords updated, %3 errors',$accounts_created,$groups_created,$errors). |
|
| 656 | - ($errors || $this->verbose ? "\n- ".implode("\n- ",$msg) : ''); |
|
| 653 | + return lang('%1 passwords updated, %3 errors', $accounts_created, $groups_created, $errors). |
|
| 654 | + ($errors || $this->verbose ? "\n- ".implode("\n- ", $msg) : ''); |
|
| 657 | 655 | } |
| 658 | 656 | // migrate addressbook data |
| 659 | - $GLOBALS['egw_info']['user']['apps']['admin'] = true; // otherwise migration will not run in setup! |
|
| 657 | + $GLOBALS['egw_info']['user']['apps']['admin'] = true; // otherwise migration will not run in setup! |
|
| 660 | 658 | $addressbook = new addressbook_so(); |
| 661 | - foreach($this->as_array() as $name => $value) |
|
| 659 | + foreach ($this->as_array() as $name => $value) |
|
| 662 | 660 | { |
| 663 | 661 | if (substr($name, 5) == 'ldap_') |
| 664 | 662 | { |
@@ -671,8 +669,8 @@ discard block |
||
| 671 | 669 | |
| 672 | 670 | $this->restore_db(); |
| 673 | 671 | |
| 674 | - return lang('%1 users and %2 groups created, %3 errors',$accounts_created,$groups_created,$errors). |
|
| 675 | - ($errors || $this->verbose ? "\n- ".implode("\n- ",$msgs) : ''); |
|
| 672 | + return lang('%1 users and %2 groups created, %3 errors', $accounts_created, $groups_created, $errors). |
|
| 673 | + ($errors || $this->verbose ? "\n- ".implode("\n- ", $msgs) : ''); |
|
| 676 | 674 | } |
| 677 | 675 | |
| 678 | 676 | /** |
@@ -686,22 +684,22 @@ discard block |
||
| 686 | 684 | if (!($type = $GLOBALS['egw_info']['server']['sql_encryption_type'])) $type = 'md5'; |
| 687 | 685 | |
| 688 | 686 | $matches = null; |
| 689 | - if (preg_match('/^\\{(.*)\\}(.*)$/',$hash,$matches)) |
|
| 687 | + if (preg_match('/^\\{(.*)\\}(.*)$/', $hash, $matches)) |
|
| 690 | 688 | { |
| 691 | - list(,$type,$hash) = $matches; |
|
| 689 | + list(,$type, $hash) = $matches; |
|
| 692 | 690 | } |
| 693 | - elseif (preg_match('/^[0-9a-f]{32}$/',$hash)) |
|
| 691 | + elseif (preg_match('/^[0-9a-f]{32}$/', $hash)) |
|
| 694 | 692 | { |
| 695 | 693 | $type = 'md5'; |
| 696 | 694 | } |
| 697 | - switch(strtolower($type)) |
|
| 695 | + switch (strtolower($type)) |
|
| 698 | 696 | { |
| 699 | 697 | case 'plain': |
| 700 | 698 | // ldap stores plaintext passwords without {plain} prefix |
| 701 | 699 | break; |
| 702 | 700 | |
| 703 | 701 | case 'md5': |
| 704 | - $hash = base64_encode(pack("H*",$hash)); |
|
| 702 | + $hash = base64_encode(pack("H*", $hash)); |
|
| 705 | 703 | // fall through |
| 706 | 704 | default: |
| 707 | 705 | $hash = '{'.strtoupper($type).'}'.$hash; |
@@ -731,14 +729,14 @@ discard block |
||
| 731 | 729 | * @param string $type ='both' |
| 732 | 730 | * @return array |
| 733 | 731 | */ |
| 734 | - public function accounts($from='ldap', $type='both') |
|
| 732 | + public function accounts($from = 'ldap', $type = 'both') |
|
| 735 | 733 | { |
| 736 | 734 | $accounts_obj = $this->accounts_obj($from); |
| 737 | 735 | //error_log(__METHOD__."(from_ldap=".array2string($from_ldap).') get_class(accounts_obj->backend)='.get_class($accounts_obj->backend)); |
| 738 | 736 | |
| 739 | 737 | $accounts = $accounts_obj->search(array('type' => $type, 'objectclass' => true, 'active' => false)); |
| 740 | 738 | |
| 741 | - foreach($accounts as $account_id => &$account) |
|
| 739 | + foreach ($accounts as $account_id => &$account) |
|
| 742 | 740 | { |
| 743 | 741 | if ($account_id != $account['account_id']) // not all backends have as key the account_id |
| 744 | 742 | { |
@@ -749,11 +747,11 @@ discard block |
||
| 749 | 747 | |
| 750 | 748 | if ($account['account_type'] == 'g') |
| 751 | 749 | { |
| 752 | - $account['members'] = $accounts_obj->members($account_id,true); |
|
| 750 | + $account['members'] = $accounts_obj->members($account_id, true); |
|
| 753 | 751 | } |
| 754 | 752 | else |
| 755 | 753 | { |
| 756 | - $account['memberships'] = $accounts_obj->memberships($account_id,true); |
|
| 754 | + $account['memberships'] = $accounts_obj->memberships($account_id, true); |
|
| 757 | 755 | } |
| 758 | 756 | } |
| 759 | 757 | accounts::cache_invalidate(); |
@@ -769,13 +767,13 @@ discard block |
||
| 769 | 767 | */ |
| 770 | 768 | private function accounts_obj($type) |
| 771 | 769 | { |
| 772 | - static $enviroment_setup=null; |
|
| 770 | + static $enviroment_setup = null; |
|
| 773 | 771 | if (!$enviroment_setup) |
| 774 | 772 | { |
| 775 | 773 | parent::_setup_enviroment($this->domain); |
| 776 | 774 | $enviroment_setup = true; |
| 777 | 775 | } |
| 778 | - if ($type != 'sql') $this->connect(); // throws exception, if it can NOT connect |
|
| 776 | + if ($type != 'sql') $this->connect(); // throws exception, if it can NOT connect |
|
| 779 | 777 | |
| 780 | 778 | // otherwise search does NOT work, as accounts_sql uses addressbook_bo for it |
| 781 | 779 | $GLOBALS['egw_info']['server']['account_repository'] = $type; |
@@ -784,8 +782,8 @@ discard block |
||
| 784 | 782 | array( |
| 785 | 783 | 'account_repository' => $GLOBALS['egw_info']['server']['account_repository'], |
| 786 | 784 | ) + $this->as_array()) || |
| 787 | - !is_a(self::$egw_setup->accounts,'accounts') || |
|
| 788 | - !is_a(self::$egw_setup->accounts->backend,'accounts_'.$type)) |
|
| 785 | + !is_a(self::$egw_setup->accounts, 'accounts') || |
|
| 786 | + !is_a(self::$egw_setup->accounts->backend, 'accounts_'.$type)) |
|
| 789 | 787 | { |
| 790 | 788 | throw new Exception(lang("Can NOT instancate accounts object for %1", strtoupper($type))); |
| 791 | 789 | } |
@@ -800,7 +798,7 @@ discard block |
||
| 800 | 798 | * @param string $host =null default $this->ldap_host, hostname, ip or ldap-url |
| 801 | 799 | * @throws egw_exception_wrong_userinput Can not connect to ldap ... |
| 802 | 800 | */ |
| 803 | - private function connect($dn=null,$pw=null,$host=null) |
|
| 801 | + private function connect($dn = null, $pw = null, $host = null) |
|
| 804 | 802 | { |
| 805 | 803 | if (is_null($dn)) $dn = $this->ldap_root_dn; |
| 806 | 804 | if (is_null($pw)) $pw = $this->ldap_root_pw; |
@@ -813,18 +811,18 @@ discard block |
||
| 813 | 811 | $this->test_ldap = new ldap(); |
| 814 | 812 | |
| 815 | 813 | $error_rep = error_reporting(); |
| 816 | - error_reporting($error_rep & ~E_WARNING); // switch warnings of, in case they are on |
|
| 814 | + error_reporting($error_rep&~E_WARNING); // switch warnings of, in case they are on |
|
| 817 | 815 | ob_start(); |
| 818 | - $ds = $this->test_ldap->ldapConnect($host,$dn,$pw); |
|
| 816 | + $ds = $this->test_ldap->ldapConnect($host, $dn, $pw); |
|
| 819 | 817 | ob_end_clean(); |
| 820 | 818 | error_reporting($error_rep); |
| 821 | 819 | |
| 822 | 820 | if (!$ds) |
| 823 | 821 | { |
| 824 | 822 | throw new egw_exception_wrong_userinput(lang('Can not connect to LDAP server on host %1 using DN %2!', |
| 825 | - $host,$dn).($this->test_ldap->ds ? ' ('.ldap_error($this->test_ldap->ds).')' : '')); |
|
| 823 | + $host, $dn).($this->test_ldap->ds ? ' ('.ldap_error($this->test_ldap->ds).')' : '')); |
|
| 826 | 824 | } |
| 827 | - return lang('Successful connected to LDAP server on %1 using DN %2.',$this->ldap_host,$dn); |
|
| 825 | + return lang('Successful connected to LDAP server on %1 using DN %2.', $this->ldap_host, $dn); |
|
| 828 | 826 | } |
| 829 | 827 | |
| 830 | 828 | /** |
@@ -837,16 +835,16 @@ discard block |
||
| 837 | 835 | { |
| 838 | 836 | $this->connect(); |
| 839 | 837 | |
| 840 | - $sr = ldap_list($this->test_ldap->ds,$this->ldap_context,'ObjectClass=posixAccount',array('dn','shadowExpire')); |
|
| 838 | + $sr = ldap_list($this->test_ldap->ds, $this->ldap_context, 'ObjectClass=posixAccount', array('dn', 'shadowExpire')); |
|
| 841 | 839 | if (!($entries = ldap_get_entries($this->test_ldap->ds, $sr))) |
| 842 | 840 | { |
| 843 | - throw new egw_exception('Error listing "dn=%1"!',$this->ldap_context); |
|
| 841 | + throw new egw_exception('Error listing "dn=%1"!', $this->ldap_context); |
|
| 844 | 842 | } |
| 845 | 843 | $num = 0; |
| 846 | - foreach($entries as $n => $entry) |
|
| 844 | + foreach ($entries as $n => $entry) |
|
| 847 | 845 | { |
| 848 | 846 | if ($n === 'count') continue; |
| 849 | - if (isset($entry['shadowexpire']) && $entry['shadowexpire'][0]*24*3600 < time()) continue; |
|
| 847 | + if (isset($entry['shadowexpire']) && $entry['shadowexpire'][0] * 24 * 3600 < time()) continue; |
|
| 850 | 848 | ++$num; |
| 851 | 849 | } |
| 852 | 850 | return $num; |
@@ -860,23 +858,23 @@ discard block |
||
| 860 | 858 | */ |
| 861 | 859 | private function create() |
| 862 | 860 | { |
| 863 | - $this->connect($this->ldap_admin,$this->ldap_admin_pw); |
|
| 861 | + $this->connect($this->ldap_admin, $this->ldap_admin_pw); |
|
| 864 | 862 | |
| 865 | - foreach(array( |
|
| 863 | + foreach (array( |
|
| 866 | 864 | $this->ldap_base => array(), |
| 867 | 865 | $this->ldap_context => array(), |
| 868 | 866 | $this->ldap_group_context => array(), |
| 869 | - $this->ldap_root_dn => array('userPassword' => auth::encrypt_ldap($this->ldap_root_pw,'ssha')), |
|
| 867 | + $this->ldap_root_dn => array('userPassword' => auth::encrypt_ldap($this->ldap_root_pw, 'ssha')), |
|
| 870 | 868 | ) as $dn => $extra) |
| 871 | 869 | { |
| 872 | - if (!$this->_create_node($dn,$extra,$this->check_only) && $dn == $this->ldap_root_dn) |
|
| 870 | + if (!$this->_create_node($dn, $extra, $this->check_only) && $dn == $this->ldap_root_dn) |
|
| 873 | 871 | { |
| 874 | 872 | // ldap_root already existed, lets check the pw is correct |
| 875 | 873 | $this->connect(); |
| 876 | 874 | } |
| 877 | 875 | } |
| 878 | 876 | return lang('Successful connected to LDAP server on %1 and created/checked required structur %2.', |
| 879 | - $this->ldap_host,$this->ldap_base); |
|
| 877 | + $this->ldap_host, $this->ldap_base); |
|
| 880 | 878 | } |
| 881 | 879 | |
| 882 | 880 | /** |
@@ -887,25 +885,25 @@ discard block |
||
| 887 | 885 | */ |
| 888 | 886 | private function delete_base() |
| 889 | 887 | { |
| 890 | - $this->connect($this->ldap_admin,$this->ldap_admin_pw); |
|
| 888 | + $this->connect($this->ldap_admin, $this->ldap_admin_pw); |
|
| 891 | 889 | |
| 892 | 890 | // if base not set, use context minus one hierarchy, eg. ou=accounts,(o=domain,dc=local) |
| 893 | 891 | if (empty($this->ldap_base) && $this->ldap_context) |
| 894 | 892 | { |
| 895 | - list(,$this->ldap_base) = explode(',',$this->ldap_context,2); |
|
| 893 | + list(,$this->ldap_base) = explode(',', $this->ldap_context, 2); |
|
| 896 | 894 | } |
| 897 | 895 | // some precausion to not delete whole ldap tree! |
| 898 | - if (count(explode(',',$this->ldap_base)) < 2) |
|
| 896 | + if (count(explode(',', $this->ldap_base)) < 2) |
|
| 899 | 897 | { |
| 900 | - throw new egw_exception_assertion_failed(lang('Refusing to delete dn "%1"!',$this->ldap_base)); |
|
| 898 | + throw new egw_exception_assertion_failed(lang('Refusing to delete dn "%1"!', $this->ldap_base)); |
|
| 901 | 899 | } |
| 902 | 900 | // check if base does exist |
| 903 | - if (!@ldap_read($this->test_ldap->ds,$this->ldap_base,'objectClass=*')) |
|
| 901 | + if (!@ldap_read($this->test_ldap->ds, $this->ldap_base, 'objectClass=*')) |
|
| 904 | 902 | { |
| 905 | - throw new egw_exception_wrong_userinput(lang('Base dn "%1" NOT found!',$this->ldap_base)); |
|
| 903 | + throw new egw_exception_wrong_userinput(lang('Base dn "%1" NOT found!', $this->ldap_base)); |
|
| 906 | 904 | } |
| 907 | 905 | return lang('LDAP dn="%1" with %2 entries deleted.', |
| 908 | - $this->ldap_base,$this->rdelete($this->ldap_base)); |
|
| 906 | + $this->ldap_base, $this->rdelete($this->ldap_base)); |
|
| 909 | 907 | } |
| 910 | 908 | |
| 911 | 909 | /** |
@@ -917,20 +915,20 @@ discard block |
||
| 917 | 915 | */ |
| 918 | 916 | private function rdelete($dn) |
| 919 | 917 | { |
| 920 | - if (!($sr = ldap_list($this->test_ldap->ds,$dn,'ObjectClass=*',array(''))) || |
|
| 918 | + if (!($sr = ldap_list($this->test_ldap->ds, $dn, 'ObjectClass=*', array(''))) || |
|
| 921 | 919 | !($entries = ldap_get_entries($this->test_ldap->ds, $sr))) |
| 922 | 920 | { |
| 923 | - throw new egw_exception(lang('Error listing "dn=%1"!',$dn)); |
|
| 921 | + throw new egw_exception(lang('Error listing "dn=%1"!', $dn)); |
|
| 924 | 922 | } |
| 925 | 923 | $deleted = 0; |
| 926 | - foreach($entries as $n => $entry) |
|
| 924 | + foreach ($entries as $n => $entry) |
|
| 927 | 925 | { |
| 928 | 926 | if ($n === 'count') continue; |
| 929 | 927 | $deleted += $this->rdelete($entry['dn']); |
| 930 | 928 | } |
| 931 | - if (!ldap_delete($this->test_ldap->ds,$dn)) |
|
| 929 | + if (!ldap_delete($this->test_ldap->ds, $dn)) |
|
| 932 | 930 | { |
| 933 | - throw new egw_exception(lang('Error deleting "dn=%1"!',$dn)); |
|
| 931 | + throw new egw_exception(lang('Error deleting "dn=%1"!', $dn)); |
|
| 934 | 932 | } |
| 935 | 933 | return ++$deleted; |
| 936 | 934 | } |
@@ -946,32 +944,32 @@ discard block |
||
| 946 | 944 | * @return string with success message N entries modified |
| 947 | 945 | * @throws egw_exception if dn not found, not listable or delete fails |
| 948 | 946 | */ |
| 949 | - private function set_mailbox($check_only=false) |
|
| 947 | + private function set_mailbox($check_only = false) |
|
| 950 | 948 | { |
| 951 | - $this->connect($this->ldap_admin,$this->ldap_admin_pw); |
|
| 949 | + $this->connect($this->ldap_admin, $this->ldap_admin_pw); |
|
| 952 | 950 | |
| 953 | 951 | // if base not set, use context minus one hierarchy, eg. ou=accounts,(o=domain,dc=local) |
| 954 | 952 | if (empty($this->ldap_base) && $this->ldap_context) |
| 955 | 953 | { |
| 956 | - list(,$this->ldap_base) = explode(',',$this->ldap_context,2); |
|
| 954 | + list(,$this->ldap_base) = explode(',', $this->ldap_context, 2); |
|
| 957 | 955 | } |
| 958 | 956 | // check if base does exist |
| 959 | - if (!@ldap_read($this->test_ldap->ds,$this->ldap_base,'objectClass=*')) |
|
| 957 | + if (!@ldap_read($this->test_ldap->ds, $this->ldap_base, 'objectClass=*')) |
|
| 960 | 958 | { |
| 961 | - throw new egw_exception_wrong_userinput(lang('Base dn "%1" NOT found!',$this->ldap_base)); |
|
| 959 | + throw new egw_exception_wrong_userinput(lang('Base dn "%1" NOT found!', $this->ldap_base)); |
|
| 962 | 960 | } |
| 963 | 961 | $object_class = $this->object_class ? $this->object_class : 'qmailUser'; |
| 964 | 962 | $mbox_attr = $this->mbox_attr ? $this->mbox_attr : 'mailmessagestore'; |
| 965 | 963 | $mail_login_type = $this->mail_login_type ? $this->mail_login_type : 'email'; |
| 966 | 964 | |
| 967 | - if (!($sr = ldap_search($this->test_ldap->ds,$this->ldap_base, |
|
| 968 | - 'objectClass='.$object_class,array('mail','uidNumber','uid',$mbox_attr))) || |
|
| 965 | + if (!($sr = ldap_search($this->test_ldap->ds, $this->ldap_base, |
|
| 966 | + 'objectClass='.$object_class, array('mail', 'uidNumber', 'uid', $mbox_attr))) || |
|
| 969 | 967 | !($entries = ldap_get_entries($this->test_ldap->ds, $sr))) |
| 970 | 968 | { |
| 971 | - throw new egw_exception(lang('Error listing "dn=%1"!',$this->ldap_base)); |
|
| 969 | + throw new egw_exception(lang('Error listing "dn=%1"!', $this->ldap_base)); |
|
| 972 | 970 | } |
| 973 | 971 | $modified = 0; |
| 974 | - foreach($entries as $n => $entry) |
|
| 972 | + foreach ($entries as $n => $entry) |
|
| 975 | 973 | { |
| 976 | 974 | if ($n === 'count') continue; |
| 977 | 975 | |
@@ -979,21 +977,20 @@ discard block |
||
| 979 | 977 | 'account_id' => $entry['uidnumber'][0], |
| 980 | 978 | 'account_lid' => $entry['uid'][0], |
| 981 | 979 | 'account_email' => $entry['mail'][0], |
| 982 | - ),$this->domain,$mail_login_type); |
|
| 980 | + ), $this->domain, $mail_login_type); |
|
| 983 | 981 | |
| 984 | - if ($mbox === $entry[$mbox_attr][0]) continue; // nothing to change |
|
| 982 | + if ($mbox === $entry[$mbox_attr][0]) continue; // nothing to change |
|
| 985 | 983 | |
| 986 | - if (!$check_only && !ldap_modify($this->test_ldap->ds,$entry['dn'],array( |
|
| 984 | + if (!$check_only && !ldap_modify($this->test_ldap->ds, $entry['dn'], array( |
|
| 987 | 985 | $mbox_attr => $mbox, |
| 988 | 986 | ))) |
| 989 | 987 | { |
| 990 | - throw new egw_exception(lang("Error modifying dn=%1: %2='%3'!",$entry['dn'],$mbox_attr,$mbox)); |
|
| 988 | + throw new egw_exception(lang("Error modifying dn=%1: %2='%3'!", $entry['dn'], $mbox_attr, $mbox)); |
|
| 991 | 989 | } |
| 992 | 990 | ++$modified; |
| 993 | 991 | if ($check_only) echo "$modified: $entry[dn]: $mbox_attr={$entry[$mbox_attr][0]} --> $mbox\n"; |
| 994 | 992 | } |
| 995 | - return $check_only ? lang('%1 entries would have been modified.',$modified) : |
|
| 996 | - lang('%1 entries modified.',$modified); |
|
| 993 | + return $check_only ? lang('%1 entries would have been modified.', $modified) : lang('%1 entries modified.', $modified); |
|
| 997 | 994 | } |
| 998 | 995 | |
| 999 | 996 | /** |
@@ -1004,9 +1001,9 @@ discard block |
||
| 1004 | 1001 | static $requiredObjectclasses = array( |
| 1005 | 1002 | 'o' => 'organization', |
| 1006 | 1003 | 'ou' => 'organizationalUnit', |
| 1007 | - 'cn' => array('organizationalRole','simpleSecurityObject'), |
|
| 1008 | - 'uid' => array('uidObject','organizationalRole','simpleSecurityObject'), |
|
| 1009 | - 'dc' => array('organization','dcObject'), |
|
| 1004 | + 'cn' => array('organizationalRole', 'simpleSecurityObject'), |
|
| 1005 | + 'uid' => array('uidObject', 'organizationalRole', 'simpleSecurityObject'), |
|
| 1006 | + 'dc' => array('organization', 'dcObject'), |
|
| 1010 | 1007 | ); |
| 1011 | 1008 | |
| 1012 | 1009 | /** |
@@ -1017,37 +1014,37 @@ discard block |
||
| 1017 | 1014 | * @return boolean true if the node was create, false if it was already there |
| 1018 | 1015 | * @throws egw_exception_wrong_userinput |
| 1019 | 1016 | */ |
| 1020 | - private function _create_node($dn,$extra=array()) |
|
| 1017 | + private function _create_node($dn, $extra = array()) |
|
| 1021 | 1018 | { |
| 1022 | 1019 | // check if the node already exists and return if it does |
| 1023 | - if (@ldap_read($this->test_ldap->ds,$dn,'objectClass=*')) |
|
| 1020 | + if (@ldap_read($this->test_ldap->ds, $dn, 'objectClass=*')) |
|
| 1024 | 1021 | { |
| 1025 | 1022 | return false; |
| 1026 | 1023 | } |
| 1027 | - list($node,$base) = explode(',',$dn,2); |
|
| 1024 | + list($node, $base) = explode(',', $dn, 2); |
|
| 1028 | 1025 | |
| 1029 | - if (!@ldap_read($this->test_ldap->ds,$base,'objectClass=*')) |
|
| 1026 | + if (!@ldap_read($this->test_ldap->ds, $base, 'objectClass=*')) |
|
| 1030 | 1027 | { |
| 1031 | - $this->_create_node($base); // create the base if it's not already there |
|
| 1028 | + $this->_create_node($base); // create the base if it's not already there |
|
| 1032 | 1029 | } |
| 1033 | 1030 | // now we need to create the node itself |
| 1034 | - list($name,$value) = explode('=',$node); |
|
| 1031 | + list($name, $value) = explode('=', $node); |
|
| 1035 | 1032 | |
| 1036 | 1033 | if (!isset(self::$requiredObjectclasses[$name])) |
| 1037 | 1034 | { |
| 1038 | - throw new egw_exception_wrong_userinput(lang('Can not create DN %1!',$dn).' '. |
|
| 1039 | - lang('Supported node types:').implode(', ',array_keys(self::$requiredObjectclasses))); |
|
| 1035 | + throw new egw_exception_wrong_userinput(lang('Can not create DN %1!', $dn).' '. |
|
| 1036 | + lang('Supported node types:').implode(', ', array_keys(self::$requiredObjectclasses))); |
|
| 1040 | 1037 | } |
| 1041 | - if ($name == 'dc') $extra['o'] = $value; // required by organisation |
|
| 1042 | - if ($name == 'uid') $extra['cn'] = $value; // required by organizationalRole |
|
| 1038 | + if ($name == 'dc') $extra['o'] = $value; // required by organisation |
|
| 1039 | + if ($name == 'uid') $extra['cn'] = $value; // required by organizationalRole |
|
| 1043 | 1040 | |
| 1044 | - if (!@ldap_add($this->test_ldap->ds,$dn,$attr = array( |
|
| 1041 | + if (!@ldap_add($this->test_ldap->ds, $dn, $attr = array( |
|
| 1045 | 1042 | $name => $value, |
| 1046 | 1043 | 'objectClass' => self::$requiredObjectclasses[$name], |
| 1047 | - )+$extra)) |
|
| 1044 | + ) + $extra)) |
|
| 1048 | 1045 | { |
| 1049 | - throw new egw_exception_wrong_userinput(lang('Can not create DN %1!',$dn). |
|
| 1050 | - ' ('.ldap_error($this->test_ldap->ds).', attributes='.print_r($attr,true).')'); |
|
| 1046 | + throw new egw_exception_wrong_userinput(lang('Can not create DN %1!', $dn). |
|
| 1047 | + ' ('.ldap_error($this->test_ldap->ds).', attributes='.print_r($attr, true).')'); |
|
| 1051 | 1048 | } |
| 1052 | 1049 | return true; |
| 1053 | 1050 | } |
@@ -1078,30 +1075,30 @@ discard block |
||
| 1078 | 1075 | */ |
| 1079 | 1076 | private function _merge_defaults() |
| 1080 | 1077 | { |
| 1081 | - foreach(self::defaults() as $name => $default) |
|
| 1078 | + foreach (self::defaults() as $name => $default) |
|
| 1082 | 1079 | { |
| 1083 | - if ($this->sub_command == 'delete_ldap' && in_array($name,array('ldap_base','ldap_context'))) |
|
| 1080 | + if ($this->sub_command == 'delete_ldap' && in_array($name, array('ldap_base', 'ldap_context'))) |
|
| 1084 | 1081 | { |
| 1085 | - continue; // no default on what to delete! |
|
| 1082 | + continue; // no default on what to delete! |
|
| 1086 | 1083 | } |
| 1087 | 1084 | if (!$this->$name) |
| 1088 | 1085 | { |
| 1089 | 1086 | //echo "<p>setting $name='{$this->$name}' to it's default='$default'</p>\n"; |
| 1090 | 1087 | $this->set_defaults[$name] = $this->$name = $default; |
| 1091 | 1088 | } |
| 1092 | - if (strpos($this->$name,'$') !== false) |
|
| 1089 | + if (strpos($this->$name, '$') !== false) |
|
| 1093 | 1090 | { |
| 1094 | 1091 | $this->set_defaults[$name] = $this->$name = str_replace(array( |
| 1095 | 1092 | '$domain', |
| 1096 | 1093 | '$suffix', |
| 1097 | 1094 | '$base', |
| 1098 | 1095 | '$admin_pw', |
| 1099 | - ),array( |
|
| 1096 | + ), array( |
|
| 1100 | 1097 | $this->domain, |
| 1101 | 1098 | $this->ldap_suffix, |
| 1102 | 1099 | $this->ldap_base, |
| 1103 | 1100 | $this->ldap_admin_pw, |
| 1104 | - ),$this->$name); |
|
| 1101 | + ), $this->$name); |
|
| 1105 | 1102 | } |
| 1106 | 1103 | } |
| 1107 | 1104 | } |
@@ -201,7 +201,10 @@ discard block |
||
| 201 | 201 | $change_account_id = ''; |
| 202 | 202 | foreach($entries as $key => $entry) |
| 203 | 203 | { |
| 204 | - if ($key === 'count') continue; |
|
| 204 | + if ($key === 'count') |
|
| 205 | + { |
|
| 206 | + continue; |
|
| 207 | + } |
|
| 205 | 208 | |
| 206 | 209 | $entry = ldap::result2array($entry); |
| 207 | 210 | $accounts[$entry['dn']] = $entry; |
@@ -228,7 +231,10 @@ discard block |
||
| 228 | 231 | //print_r($change); die('Stop'); |
| 229 | 232 | |
| 230 | 233 | // change account-ids inside EGroupware |
| 231 | - if ($check_only) $msg[] = "You need to run now:\n$cmd_change_account_id $change_account_id"; |
|
| 234 | + if ($check_only) |
|
| 235 | + { |
|
| 236 | + $msg[] = "You need to run now:\n$cmd_change_account_id $change_account_id"; |
|
| 237 | + } |
|
| 232 | 238 | //$cmd = new admin_cmd_change_account_id($change); |
| 233 | 239 | //$msg[] = $cmd->run($time=null, $set_modifier=false, $skip_checks=false, $check_only); |
| 234 | 240 | |
@@ -250,7 +256,10 @@ discard block |
||
| 250 | 256 | throw new egw_exception("Failed to modify ldap: !ldap_modify({$this->test_ldap->ds}, '$dn', ".array2string($modify).") ".ldap_error($this->test_ldap->ds). |
| 251 | 257 | "\n- ".implode("\n- ", $msg)); // EGroupware change already run successful |
| 252 | 258 | } |
| 253 | - if ($modify) ++$changed; |
|
| 259 | + if ($modify) |
|
| 260 | + { |
|
| 261 | + ++$changed; |
|
| 262 | + } |
|
| 254 | 263 | } |
| 255 | 264 | $msg[] = "You need to run now on your samba share(s):\nsetup/doc/chown.php -R $change_account_id <share>"; |
| 256 | 265 | |
@@ -277,7 +286,10 @@ discard block |
||
| 277 | 286 | else |
| 278 | 287 | { |
| 279 | 288 | list($to, $from) = explode('=', $attr); |
| 280 | - if ($from) $attrs[] = $from; |
|
| 289 | + if ($from) |
|
| 290 | + { |
|
| 291 | + $attrs[] = $from; |
|
| 292 | + } |
|
| 281 | 293 | $rename[strtolower($from)] = $to; |
| 282 | 294 | } |
| 283 | 295 | } |
@@ -292,7 +304,10 @@ discard block |
||
| 292 | 304 | { |
| 293 | 305 | $this->ads_context = 'CN=Users,DC='.implode(',DC=', explode('.', $this->ads_domain)); |
| 294 | 306 | } |
| 295 | - if (empty($this->ads_admin_user)) $this->ads_admin_user = 'Administrator'; |
|
| 307 | + if (empty($this->ads_admin_user)) |
|
| 308 | + { |
|
| 309 | + $this->ads_admin_user = 'Administrator'; |
|
| 310 | + } |
|
| 296 | 311 | $admin_dn = strpos($this->ads_admin_user, '=') !== false ? $this->ads_admin_user : |
| 297 | 312 | 'CN='.$this->ads_admin_user.','.$this->ads_context; |
| 298 | 313 | switch($this->ads_connection) |
@@ -336,7 +351,10 @@ discard block |
||
| 336 | 351 | $utc_diff = null; |
| 337 | 352 | foreach($entries as $key => $entry) |
| 338 | 353 | { |
| 339 | - if ($key === 'count') continue; |
|
| 354 | + if ($key === 'count') |
|
| 355 | + { |
|
| 356 | + continue; |
|
| 357 | + } |
|
| 340 | 358 | |
| 341 | 359 | $entry_arr = ldap::result2array($entry); |
| 342 | 360 | $uid = $entry_arr['uid']; |
@@ -350,7 +368,10 @@ discard block |
||
| 350 | 368 | continue; |
| 351 | 369 | } |
| 352 | 370 | $dn = $dest[0]['dn']; |
| 353 | - if (isset($rename[''])) $entry[''] = ''; |
|
| 371 | + if (isset($rename[''])) |
|
| 372 | + { |
|
| 373 | + $entry[''] = ''; |
|
| 374 | + } |
|
| 354 | 375 | // special handling for copying shadowExpires to accountExpires |
| 355 | 376 | if (strtolower($rename['shadowexpire']) === 'accountexpires') |
| 356 | 377 | { |
@@ -361,7 +382,10 @@ discard block |
||
| 361 | 382 | } |
| 362 | 383 | else |
| 363 | 384 | { |
| 364 | - if (is_null($utc_diff)) $utc_diff = date('Z'); |
|
| 385 | + if (is_null($utc_diff)) |
|
| 386 | + { |
|
| 387 | + $utc_diff = date('Z'); |
|
| 388 | + } |
|
| 365 | 389 | $entry['shadowexpire'] = accounts_ads::convertUnixTimeToWindowsTime( |
| 366 | 390 | $entry['shadowexpire']*24*3600+$utc_diff); // ldap time to unixTime |
| 367 | 391 | } |
@@ -373,20 +397,29 @@ discard block |
||
| 373 | 397 | { |
| 374 | 398 | $to = isset($rename[$attr]) ? $rename[$attr] : $attr; |
| 375 | 399 | $prefix = null; |
| 376 | - if ($to[0] == '{') // eg. {smtp:}proxyAddresses=forwardTo |
|
| 400 | + if ($to[0] == '{') |
|
| 401 | + { |
|
| 402 | + // eg. {smtp:}proxyAddresses=forwardTo |
|
| 377 | 403 | { |
| 378 | 404 | list($prefix, $to) = explode('}', substr($to, 1)); |
| 379 | 405 | } |
| 406 | + } |
|
| 380 | 407 | foreach((array)$value as $val) |
| 381 | 408 | { |
| 382 | 409 | if (isset($update[$to])) |
| 383 | 410 | { |
| 384 | - if (!is_array($update[$to])) $update[$to] = array($update[$to]); |
|
| 411 | + if (!is_array($update[$to])) |
|
| 412 | + { |
|
| 413 | + $update[$to] = array($update[$to]); |
|
| 414 | + } |
|
| 385 | 415 | // we need to check (caseinsensitive) if value already exists in set |
| 386 | 416 | // as AD chokes on doublicate values "Type or value exists" |
| 387 | 417 | foreach($update[$to] as $v) |
| 388 | 418 | { |
| 389 | - if (!strcasecmp($v, $prefix.$val)) continue 2; |
|
| 419 | + if (!strcasecmp($v, $prefix.$val)) |
|
| 420 | + { |
|
| 421 | + continue 2; |
|
| 422 | + } |
|
| 390 | 423 | } |
| 391 | 424 | $update[$to][] = $prefix.$val; |
| 392 | 425 | } |
@@ -413,7 +446,10 @@ discard block |
||
| 413 | 446 | $changed++; |
| 414 | 447 | } |
| 415 | 448 | } |
| 416 | - if ($check_only) return lang("%1 accounts to copy found.", count($entries)); |
|
| 449 | + if ($check_only) |
|
| 450 | + { |
|
| 451 | + return lang("%1 accounts to copy found.", count($entries)); |
|
| 452 | + } |
|
| 417 | 453 | |
| 418 | 454 | return "Copied data of $changed accounts from LDAP to AD ". |
| 419 | 455 | (count($msg) > $changed ? ' ('.(count($msg)-$changed).' errors!)' : ''); |
@@ -429,7 +465,10 @@ discard block |
||
| 429 | 465 | private function migrate($mode) |
| 430 | 466 | { |
| 431 | 467 | // support old boolean mode |
| 432 | - if (is_bool($mode)) $mode = $mode ? 'migrate_to_ldap' : 'migrate_to_sql'; |
|
| 468 | + if (is_bool($mode)) |
|
| 469 | + { |
|
| 470 | + $mode = $mode ? 'migrate_to_ldap' : 'migrate_to_sql'; |
|
| 471 | + } |
|
| 433 | 472 | |
| 434 | 473 | $passwords2sql = $mode === "passwords_to_sql"; |
| 435 | 474 | list(,$to) = explode('_to_', $mode); |
@@ -596,7 +635,10 @@ discard block |
||
| 596 | 635 | { |
| 597 | 636 | foreach(array('ldap_host','ldap_root_dn','ldap_root_pw','ldap_context','ldap_group_context','ldap_search_filter','ldap_encryptin_type','mail_suffix','mail_login_type') as $name) |
| 598 | 637 | { |
| 599 | - if (!empty($this->$name)) $GLOBALS['egw_info']['server'][$name] = $this->$name; |
|
| 638 | + if (!empty($this->$name)) |
|
| 639 | + { |
|
| 640 | + $GLOBALS['egw_info']['server'][$name] = $this->$name; |
|
| 641 | + } |
|
| 600 | 642 | } |
| 601 | 643 | //error_log(__METHOD__."() setup up egw_info[server]: ldap_host='{$GLOBALS['egw_info']['server']['ldap_host']}', ldap_root_dn='{$GLOBALS['egw_info']['server']['ldap_root_dn']}', ldap_root_pw='{$GLOBALS['egw_info']['server']['ldap_root_pw']}', ldap_context='{$GLOBALS['egw_info']['server']['ldap_context']}', mail_suffix='{$GLOBALS['egw_info']['server']['mail_suffix']}', mail_logig_type='{$GLOBALS['egw_info']['server']['mail_login-type']}'"); |
| 602 | 644 | } |
@@ -683,7 +725,10 @@ discard block |
||
| 683 | 725 | */ |
| 684 | 726 | public static function hash_sql2ldap($hash) |
| 685 | 727 | { |
| 686 | - if (!($type = $GLOBALS['egw_info']['server']['sql_encryption_type'])) $type = 'md5'; |
|
| 728 | + if (!($type = $GLOBALS['egw_info']['server']['sql_encryption_type'])) |
|
| 729 | + { |
|
| 730 | + $type = 'md5'; |
|
| 731 | + } |
|
| 687 | 732 | |
| 688 | 733 | $matches = null; |
| 689 | 734 | if (preg_match('/^\\{(.*)\\}(.*)$/',$hash,$matches)) |
@@ -717,10 +762,13 @@ discard block |
||
| 717 | 762 | */ |
| 718 | 763 | public static function hash_ldap2sql($hash) |
| 719 | 764 | { |
| 720 | - if ($hash[0] != '{') // plain has to be explicitly specified for sql, in ldap it's the default |
|
| 765 | + if ($hash[0] != '{') |
|
| 766 | + { |
|
| 767 | + // plain has to be explicitly specified for sql, in ldap it's the default |
|
| 721 | 768 | { |
| 722 | 769 | $hash = '{PLAIN}'.$hash; |
| 723 | 770 | } |
| 771 | + } |
|
| 724 | 772 | return $hash; |
| 725 | 773 | } |
| 726 | 774 | |
@@ -740,9 +788,12 @@ discard block |
||
| 740 | 788 | |
| 741 | 789 | foreach($accounts as $account_id => &$account) |
| 742 | 790 | { |
| 743 | - if ($account_id != $account['account_id']) // not all backends have as key the account_id |
|
| 791 | + if ($account_id != $account['account_id']) |
|
| 792 | + { |
|
| 793 | + // not all backends have as key the account_id |
|
| 744 | 794 | { |
| 745 | 795 | unset($account); |
| 796 | + } |
|
| 746 | 797 | $account_id = $account['account_id']; |
| 747 | 798 | } |
| 748 | 799 | $account += $accounts_obj->read($account_id); |
@@ -775,7 +826,11 @@ discard block |
||
| 775 | 826 | parent::_setup_enviroment($this->domain); |
| 776 | 827 | $enviroment_setup = true; |
| 777 | 828 | } |
| 778 | - if ($type != 'sql') $this->connect(); // throws exception, if it can NOT connect |
|
| 829 | + if ($type != 'sql') |
|
| 830 | + { |
|
| 831 | + $this->connect(); |
|
| 832 | + } |
|
| 833 | + // throws exception, if it can NOT connect |
|
| 779 | 834 | |
| 780 | 835 | // otherwise search does NOT work, as accounts_sql uses addressbook_bo for it |
| 781 | 836 | $GLOBALS['egw_info']['server']['account_repository'] = $type; |
@@ -802,14 +857,26 @@ discard block |
||
| 802 | 857 | */ |
| 803 | 858 | private function connect($dn=null,$pw=null,$host=null) |
| 804 | 859 | { |
| 805 | - if (is_null($dn)) $dn = $this->ldap_root_dn; |
|
| 806 | - if (is_null($pw)) $pw = $this->ldap_root_pw; |
|
| 807 | - if (is_null($host)) $host = $this->ldap_host; |
|
| 860 | + if (is_null($dn)) |
|
| 861 | + { |
|
| 862 | + $dn = $this->ldap_root_dn; |
|
| 863 | + } |
|
| 864 | + if (is_null($pw)) |
|
| 865 | + { |
|
| 866 | + $pw = $this->ldap_root_pw; |
|
| 867 | + } |
|
| 868 | + if (is_null($host)) |
|
| 869 | + { |
|
| 870 | + $host = $this->ldap_host; |
|
| 871 | + } |
|
| 808 | 872 | |
| 809 | - if (!$pw) // ldap::ldapConnect use the current eGW's pw otherwise |
|
| 873 | + if (!$pw) |
|
| 874 | + { |
|
| 875 | + // ldap::ldapConnect use the current eGW's pw otherwise |
|
| 810 | 876 | { |
| 811 | 877 | throw new egw_exception_wrong_userinput(lang('You need to specify a password!')); |
| 812 | 878 | } |
| 879 | + } |
|
| 813 | 880 | $this->test_ldap = new ldap(); |
| 814 | 881 | |
| 815 | 882 | $error_rep = error_reporting(); |
@@ -845,8 +912,14 @@ discard block |
||
| 845 | 912 | $num = 0; |
| 846 | 913 | foreach($entries as $n => $entry) |
| 847 | 914 | { |
| 848 | - if ($n === 'count') continue; |
|
| 849 | - if (isset($entry['shadowexpire']) && $entry['shadowexpire'][0]*24*3600 < time()) continue; |
|
| 915 | + if ($n === 'count') |
|
| 916 | + { |
|
| 917 | + continue; |
|
| 918 | + } |
|
| 919 | + if (isset($entry['shadowexpire']) && $entry['shadowexpire'][0]*24*3600 < time()) |
|
| 920 | + { |
|
| 921 | + continue; |
|
| 922 | + } |
|
| 850 | 923 | ++$num; |
| 851 | 924 | } |
| 852 | 925 | return $num; |
@@ -925,7 +998,10 @@ discard block |
||
| 925 | 998 | $deleted = 0; |
| 926 | 999 | foreach($entries as $n => $entry) |
| 927 | 1000 | { |
| 928 | - if ($n === 'count') continue; |
|
| 1001 | + if ($n === 'count') |
|
| 1002 | + { |
|
| 1003 | + continue; |
|
| 1004 | + } |
|
| 929 | 1005 | $deleted += $this->rdelete($entry['dn']); |
| 930 | 1006 | } |
| 931 | 1007 | if (!ldap_delete($this->test_ldap->ds,$dn)) |
@@ -973,7 +1049,10 @@ discard block |
||
| 973 | 1049 | $modified = 0; |
| 974 | 1050 | foreach($entries as $n => $entry) |
| 975 | 1051 | { |
| 976 | - if ($n === 'count') continue; |
|
| 1052 | + if ($n === 'count') |
|
| 1053 | + { |
|
| 1054 | + continue; |
|
| 1055 | + } |
|
| 977 | 1056 | |
| 978 | 1057 | $mbox = emailadmin_smtp_ldap::mailbox_addr(array( |
| 979 | 1058 | 'account_id' => $entry['uidnumber'][0], |
@@ -981,7 +1060,11 @@ discard block |
||
| 981 | 1060 | 'account_email' => $entry['mail'][0], |
| 982 | 1061 | ),$this->domain,$mail_login_type); |
| 983 | 1062 | |
| 984 | - if ($mbox === $entry[$mbox_attr][0]) continue; // nothing to change |
|
| 1063 | + if ($mbox === $entry[$mbox_attr][0]) |
|
| 1064 | + { |
|
| 1065 | + continue; |
|
| 1066 | + } |
|
| 1067 | + // nothing to change |
|
| 985 | 1068 | |
| 986 | 1069 | if (!$check_only && !ldap_modify($this->test_ldap->ds,$entry['dn'],array( |
| 987 | 1070 | $mbox_attr => $mbox, |
@@ -990,7 +1073,10 @@ discard block |
||
| 990 | 1073 | throw new egw_exception(lang("Error modifying dn=%1: %2='%3'!",$entry['dn'],$mbox_attr,$mbox)); |
| 991 | 1074 | } |
| 992 | 1075 | ++$modified; |
| 993 | - if ($check_only) echo "$modified: $entry[dn]: $mbox_attr={$entry[$mbox_attr][0]} --> $mbox\n"; |
|
| 1076 | + if ($check_only) |
|
| 1077 | + { |
|
| 1078 | + echo "$modified: $entry[dn]: $mbox_attr={$entry[$mbox_attr][0]} --> $mbox\n"; |
|
| 1079 | + } |
|
| 994 | 1080 | } |
| 995 | 1081 | return $check_only ? lang('%1 entries would have been modified.',$modified) : |
| 996 | 1082 | lang('%1 entries modified.',$modified); |
@@ -1038,8 +1124,16 @@ discard block |
||
| 1038 | 1124 | throw new egw_exception_wrong_userinput(lang('Can not create DN %1!',$dn).' '. |
| 1039 | 1125 | lang('Supported node types:').implode(', ',array_keys(self::$requiredObjectclasses))); |
| 1040 | 1126 | } |
| 1041 | - if ($name == 'dc') $extra['o'] = $value; // required by organisation |
|
| 1042 | - if ($name == 'uid') $extra['cn'] = $value; // required by organizationalRole |
|
| 1127 | + if ($name == 'dc') |
|
| 1128 | + { |
|
| 1129 | + $extra['o'] = $value; |
|
| 1130 | + } |
|
| 1131 | + // required by organisation |
|
| 1132 | + if ($name == 'uid') |
|
| 1133 | + { |
|
| 1134 | + $extra['cn'] = $value; |
|
| 1135 | + } |
|
| 1136 | + // required by organizationalRole |
|
| 1043 | 1137 | |
| 1044 | 1138 | if (!@ldap_add($this->test_ldap->ds,$dn,$attr = array( |
| 1045 | 1139 | $name => $value, |
@@ -252,7 +252,7 @@ |
||
| 252 | 252 | /** |
| 253 | 253 | * Check if header exists and is up to date |
| 254 | 254 | * |
| 255 | - * @return int 1=no header.inc.php, 2=no header admin pw, 3=no instances, 4=need upgrade, 10=ok |
|
| 255 | + * @return string 1=no header.inc.php, 2=no header admin pw, 3=no instances, 4=need upgrade, 10=ok |
|
| 256 | 256 | */ |
| 257 | 257 | function check_header() |
| 258 | 258 | { |
@@ -65,7 +65,9 @@ discard block |
||
| 65 | 65 | foreach($GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->applications_table,'*',false,__LINE__,__FILE__) as $row) |
| 66 | 66 | { |
| 67 | 67 | $app = $row['app_name']; |
| 68 | - if (!isset($setup_info[$app])) // app source no longer there |
|
| 68 | + if (!isset($setup_info[$app])) |
|
| 69 | + { |
|
| 70 | + // app source no longer there |
|
| 69 | 71 | { |
| 70 | 72 | $setup_info[$app] = array( |
| 71 | 73 | 'name' => $app, |
@@ -73,6 +75,7 @@ discard block |
||
| 73 | 75 | 'version' => 'deleted', |
| 74 | 76 | ); |
| 75 | 77 | } |
| 78 | + } |
|
| 76 | 79 | $setup_info[$app]['currentver'] = $row['app_version']; |
| 77 | 80 | $setup_info[$app]['enabled'] = $row['app_enabled']; |
| 78 | 81 | } |
@@ -212,7 +215,9 @@ discard block |
||
| 212 | 215 | if ($setup_info['depends'][$depkey]['status'] == False) |
| 213 | 216 | { |
| 214 | 217 | /* Only set this if it has not already failed to upgrade - Milosch */ |
| 215 | - if($setup_info[$key]['status'] != 'F')//&& $setup_info[$key]['status'] != 'C') |
|
| 218 | + if($setup_info[$key]['status'] != 'F') |
|
| 219 | + { |
|
| 220 | + //&& $setup_info[$key]['status'] != 'C') |
|
| 216 | 221 | { |
| 217 | 222 | /* Added check for status U - uninstalled apps carry this flag (upgrade from nothing == install). |
| 218 | 223 | * This should fix apps showing post-install dep failure when they are not yet installed. |
@@ -220,6 +225,7 @@ discard block |
||
| 220 | 225 | if($setup_info[$key]['status'] == 'C' || $setup_info[$key]['status'] == 'U') |
| 221 | 226 | { |
| 222 | 227 | $setup_info[$key]['status'] = 'D'; |
| 228 | + } |
|
| 223 | 229 | } |
| 224 | 230 | else |
| 225 | 231 | { |
@@ -292,7 +298,10 @@ discard block |
||
| 292 | 298 | */ |
| 293 | 299 | function check_db($setup_info=null) |
| 294 | 300 | { |
| 295 | - if (!$setup_info) $setup_info = $GLOBALS['setup_info']; |
|
| 301 | + if (!$setup_info) |
|
| 302 | + { |
|
| 303 | + $setup_info = $GLOBALS['setup_info']; |
|
| 304 | + } |
|
| 296 | 305 | |
| 297 | 306 | try { // catch DB errors |
| 298 | 307 | if (!$GLOBALS['egw_setup']->db->Link_ID) |
@@ -482,11 +491,14 @@ discard block |
||
| 482 | 491 | { |
| 483 | 492 | echo '<br>check_app_tables(): Checking: ' . $appname . ',table: ' . $val; |
| 484 | 493 | } |
| 485 | - if(!in_array($val,$tables) && !in_array(strtolower($val),$tables)) // names in tables might be lowercase |
|
| 494 | + if(!in_array($val,$tables) && !in_array(strtolower($val),$tables)) |
|
| 495 | + { |
|
| 496 | + // names in tables might be lowercase |
|
| 486 | 497 | { |
| 487 | 498 | if($GLOBALS['DEBUG']) |
| 488 | 499 | { |
| 489 | 500 | echo '<br>check_app_tables(): ' . $val . ' missing!'; |
| 501 | + } |
|
| 490 | 502 | } |
| 491 | 503 | if(!$any) |
| 492 | 504 | { |
@@ -543,9 +555,12 @@ discard block |
||
| 543 | 555 | $msg = lang('does not exist'); |
| 544 | 556 | return false; |
| 545 | 557 | } |
| 546 | - if (!@is_writeable($dir) && $_SERVER['HTTP_HOST']) // only do the check if we run by the webserver |
|
| 558 | + if (!@is_writeable($dir) && $_SERVER['HTTP_HOST']) |
|
| 559 | + { |
|
| 560 | + // only do the check if we run by the webserver |
|
| 547 | 561 | { |
| 548 | 562 | $msg = lang('is not writeable by the webserver'); |
| 563 | + } |
|
| 549 | 564 | return false; |
| 550 | 565 | } |
| 551 | 566 | if ($check_in_docroot) |
@@ -464,7 +464,7 @@ |
||
| 464 | 464 | { |
| 465 | 465 | /* Make a copy, else we send some callers into an infinite loop */ |
| 466 | 466 | $copy = $setup_info; |
| 467 | - $tables = Array(); |
|
| 467 | + $tables = array(); |
|
| 468 | 468 | try { |
| 469 | 469 | $table_names = $GLOBALS['egw_setup']->db->table_names(); |
| 470 | 470 | foreach($table_names as $key => $val) |
@@ -25,12 +25,12 @@ discard block |
||
| 25 | 25 | { |
| 26 | 26 | $setup_info = array(); |
| 27 | 27 | $d = dir(EGW_SERVER_ROOT); |
| 28 | - while($entry=$d->read()) |
|
| 28 | + while ($entry = $d->read()) |
|
| 29 | 29 | { |
| 30 | - if($entry != ".." && $entry != 'setup' && is_dir(EGW_SERVER_ROOT . '/' . $entry)) |
|
| 30 | + if ($entry != ".." && $entry != 'setup' && is_dir(EGW_SERVER_ROOT.'/'.$entry)) |
|
| 31 | 31 | { |
| 32 | - $f = EGW_SERVER_ROOT . '/' . $entry . '/setup/setup.inc.php'; |
|
| 33 | - if (@file_exists ($f)) |
|
| 32 | + $f = EGW_SERVER_ROOT.'/'.$entry.'/setup/setup.inc.php'; |
|
| 33 | + if (@file_exists($f)) |
|
| 34 | 34 | { |
| 35 | 35 | include($f); |
| 36 | 36 | $setup_info[$entry]['filename'] = $f; |
@@ -50,18 +50,18 @@ discard block |
||
| 50 | 50 | * @param array $setup_info |
| 51 | 51 | * @return array $setup_info |
| 52 | 52 | */ |
| 53 | - function get_db_versions($setup_info=null) |
|
| 53 | + function get_db_versions($setup_info = null) |
|
| 54 | 54 | { |
| 55 | 55 | try { // catch DB errors |
| 56 | 56 | $GLOBALS['egw_setup']->set_table_names(); |
| 57 | 57 | |
| 58 | - if($GLOBALS['egw_setup']->table_exist(array($GLOBALS['egw_setup']->applications_table),true)) |
|
| 58 | + if ($GLOBALS['egw_setup']->table_exist(array($GLOBALS['egw_setup']->applications_table), true)) |
|
| 59 | 59 | { |
| 60 | 60 | /* one of these tables exists. checking for post/pre beta version */ |
| 61 | - if($GLOBALS['egw_setup']->applications_table != 'applications') |
|
| 61 | + if ($GLOBALS['egw_setup']->applications_table != 'applications') |
|
| 62 | 62 | { |
| 63 | - $GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->applications_table,'*',false,__LINE__,__FILE__); |
|
| 64 | - while(@$GLOBALS['egw_setup']->db->next_record()) |
|
| 63 | + $GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->applications_table, '*', false, __LINE__, __FILE__); |
|
| 64 | + while (@$GLOBALS['egw_setup']->db->next_record()) |
|
| 65 | 65 | { |
| 66 | 66 | $app = $GLOBALS['egw_setup']->db->f('app_name'); |
| 67 | 67 | if (!isset($setup_info[$app])) // app source no longer there |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | /* This is to catch old setup installs that did not have phpgwapi listed as an app */ |
| 79 | 79 | $tmp = @$setup_info['phpgwapi']['version']; /* save the file version */ |
| 80 | - if(!@$setup_info['phpgwapi']['currentver']) |
|
| 80 | + if (!@$setup_info['phpgwapi']['currentver']) |
|
| 81 | 81 | { |
| 82 | 82 | $setup_info['phpgwapi']['currentver'] = $setup_info['admin']['currentver']; |
| 83 | 83 | $setup_info['phpgwapi']['version'] = $setup_info['admin']['currentver']; |
@@ -97,9 +97,9 @@ discard block |
||
| 97 | 97 | else |
| 98 | 98 | { |
| 99 | 99 | $GLOBALS['egw_setup']->db->query('select * from applications'); |
| 100 | - while(@$GLOBALS['egw_setup']->db->next_record()) |
|
| 100 | + while (@$GLOBALS['egw_setup']->db->next_record()) |
|
| 101 | 101 | { |
| 102 | - if($GLOBALS['egw_setup']->db->f('app_name') == 'admin') |
|
| 102 | + if ($GLOBALS['egw_setup']->db->f('app_name') == 'admin') |
|
| 103 | 103 | { |
| 104 | 104 | $setup_info['phpgwapi']['currentver'] = $GLOBALS['egw_setup']->db->f('app_version'); |
| 105 | 105 | } |
@@ -127,25 +127,25 @@ discard block |
||
| 127 | 127 | * V Version mismatch at end of upgrade (Not used, proposed only) |
| 128 | 128 | * M Missing files at start of upgrade (Not used, proposed only) |
| 129 | 129 | */ |
| 130 | - function compare_versions($setup_info,$try_downgrade=false) |
|
| 130 | + function compare_versions($setup_info, $try_downgrade = false) |
|
| 131 | 131 | { |
| 132 | - foreach($setup_info as $key => $value) |
|
| 132 | + foreach ($setup_info as $key => $value) |
|
| 133 | 133 | { |
| 134 | 134 | //echo '<br>'.$value['name'].'STATUS: '.$value['status']; |
| 135 | 135 | /* Only set this if it has not already failed to upgrade - Milosch */ |
| 136 | - if(!( (@$value['status'] == 'F') || (@$value['status'] == 'C') )) |
|
| 136 | + if (!((@$value['status'] == 'F') || (@$value['status'] == 'C'))) |
|
| 137 | 137 | { |
| 138 | 138 | //if ($setup_info[$key]['currentver'] > $setup_info[$key]['version']) |
| 139 | - if(!$try_downgrade && $GLOBALS['egw_setup']->amorethanb($value['currentver'],@$value['version']) || |
|
| 139 | + if (!$try_downgrade && $GLOBALS['egw_setup']->amorethanb($value['currentver'], @$value['version']) || |
|
| 140 | 140 | $value['version'] == 'deleted') |
| 141 | 141 | { |
| 142 | 142 | $setup_info[$key]['status'] = 'V'; |
| 143 | 143 | } |
| 144 | - elseif(@$value['currentver'] == @$value['version']) |
|
| 144 | + elseif (@$value['currentver'] == @$value['version']) |
|
| 145 | 145 | { |
| 146 | 146 | $setup_info[$key]['status'] = 'C'; |
| 147 | 147 | } |
| 148 | - elseif($GLOBALS['egw_setup']->alessthanb(@$value['currentver'],@$value['version'])) |
|
| 148 | + elseif ($GLOBALS['egw_setup']->alessthanb(@$value['currentver'], @$value['version'])) |
|
| 149 | 149 | { |
| 150 | 150 | $setup_info[$key]['status'] = 'U'; |
| 151 | 151 | } |
@@ -162,35 +162,35 @@ discard block |
||
| 162 | 162 | function check_depends($setup_info) |
| 163 | 163 | { |
| 164 | 164 | /* Run the list of apps */ |
| 165 | - foreach($setup_info as $key => $value) |
|
| 165 | + foreach ($setup_info as $key => $value) |
|
| 166 | 166 | { |
| 167 | 167 | /* Does this app have any depends */ |
| 168 | - if(isset($value['depends'])) |
|
| 168 | + if (isset($value['depends'])) |
|
| 169 | 169 | { |
| 170 | 170 | /* If so find out which apps it depends on */ |
| 171 | - foreach($value['depends'] as $depkey => $depvalue) |
|
| 171 | + foreach ($value['depends'] as $depkey => $depvalue) |
|
| 172 | 172 | { |
| 173 | 173 | /* I set this to False until we find a compatible version of this app */ |
| 174 | 174 | $setup_info['depends'][$depkey]['status'] = False; |
| 175 | 175 | /* Now we loop thru the versions looking for a compatible version */ |
| 176 | 176 | |
| 177 | - foreach($depvalue['versions'] as $depsvalue) |
|
| 177 | + foreach ($depvalue['versions'] as $depsvalue) |
|
| 178 | 178 | { |
| 179 | 179 | $currentver = $setup_info[$depvalue['appname']]['currentver']; |
| 180 | - if ($depvalue['appname'] == 'phpgwapi' && substr($currentver,0,6) == '0.9.99') |
|
| 180 | + if ($depvalue['appname'] == 'phpgwapi' && substr($currentver, 0, 6) == '0.9.99') |
|
| 181 | 181 | { |
| 182 | 182 | $currentver = '0.9.14.508'; |
| 183 | 183 | } |
| 184 | 184 | $major = $GLOBALS['egw_setup']->get_major($currentver); |
| 185 | - if ($major >= $depsvalue || $major == $depsvalue && substr($major,0,strlen($depsvalue)+1) == $depsvalue.'.') |
|
| 185 | + if ($major >= $depsvalue || $major == $depsvalue && substr($major, 0, strlen($depsvalue) + 1) == $depsvalue.'.') |
|
| 186 | 186 | { |
| 187 | 187 | $setup_info['depends'][$depkey]['status'] = True; |
| 188 | 188 | } |
| 189 | 189 | else // check if majors are equal and minors greater or equal |
| 190 | 190 | { |
| 191 | 191 | $major_depsvalue = $GLOBALS['egw_setup']->get_major($depsvalue); |
| 192 | - $tmp = explode('.',$depsvalue); $minor_depsvalue = array_pop($tmp); |
|
| 193 | - $tmp2 = explode('.',$currentver); $minor = array_pop($tmp2); |
|
| 192 | + $tmp = explode('.', $depsvalue); $minor_depsvalue = array_pop($tmp); |
|
| 193 | + $tmp2 = explode('.', $currentver); $minor = array_pop($tmp2); |
|
| 194 | 194 | if ($major == $major_depsvalue && $minor <= $minor_depsvalue) |
| 195 | 195 | { |
| 196 | 196 | $setup_info['depends'][$depkey]['status'] = True; |
@@ -203,17 +203,17 @@ discard block |
||
| 203 | 203 | Finally, we loop through the dependencies again to look for apps that still have a failure status |
| 204 | 204 | If we find one, we set the apps overall status as a dependency failure. |
| 205 | 205 | */ |
| 206 | - foreach($value['depends'] as $depkey => $depvalue) |
|
| 206 | + foreach ($value['depends'] as $depkey => $depvalue) |
|
| 207 | 207 | { |
| 208 | 208 | if ($setup_info['depends'][$depkey]['status'] == False) |
| 209 | 209 | { |
| 210 | 210 | /* Only set this if it has not already failed to upgrade - Milosch */ |
| 211 | - if($setup_info[$key]['status'] != 'F')//&& $setup_info[$key]['status'] != 'C') |
|
| 211 | + if ($setup_info[$key]['status'] != 'F')//&& $setup_info[$key]['status'] != 'C') |
|
| 212 | 212 | { |
| 213 | 213 | /* Added check for status U - uninstalled apps carry this flag (upgrade from nothing == install). |
| 214 | 214 | * This should fix apps showing post-install dep failure when they are not yet installed. |
| 215 | 215 | */ |
| 216 | - if($setup_info[$key]['status'] == 'C' || $setup_info[$key]['status'] == 'U') |
|
| 216 | + if ($setup_info[$key]['status'] == 'C' || $setup_info[$key]['status'] == 'U') |
|
| 217 | 217 | { |
| 218 | 218 | $setup_info[$key]['status'] = 'D'; |
| 219 | 219 | } |
@@ -235,9 +235,9 @@ discard block |
||
| 235 | 235 | */ |
| 236 | 236 | function upgrade_exclude($setup_info) |
| 237 | 237 | { |
| 238 | - foreach($setup_info as $key => $value) |
|
| 238 | + foreach ($setup_info as $key => $value) |
|
| 239 | 239 | { |
| 240 | - if(isset($value['no_mass_update'])) |
|
| 240 | + if (isset($value['no_mass_update'])) |
|
| 241 | 241 | { |
| 242 | 242 | unset($setup_info[$key]); |
| 243 | 243 | } |
@@ -252,24 +252,24 @@ discard block |
||
| 252 | 252 | */ |
| 253 | 253 | function check_header() |
| 254 | 254 | { |
| 255 | - if(!file_exists(EGW_SERVER_ROOT.'/header.inc.php') || filesize(EGW_SERVER_ROOT.'/header.inc.php') < 200) |
|
| 255 | + if (!file_exists(EGW_SERVER_ROOT.'/header.inc.php') || filesize(EGW_SERVER_ROOT.'/header.inc.php') < 200) |
|
| 256 | 256 | { |
| 257 | 257 | $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One'; |
| 258 | 258 | return '1'; |
| 259 | 259 | } |
| 260 | 260 | else |
| 261 | 261 | { |
| 262 | - if(!@isset($GLOBALS['egw_info']['server']['header_admin_password'])) |
|
| 262 | + if (!@isset($GLOBALS['egw_info']['server']['header_admin_password'])) |
|
| 263 | 263 | { |
| 264 | 264 | $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One (No header admin password set)'; |
| 265 | 265 | return '2'; |
| 266 | 266 | } |
| 267 | - elseif(!@isset($GLOBALS['egw_domain'])) |
|
| 267 | + elseif (!@isset($GLOBALS['egw_domain'])) |
|
| 268 | 268 | { |
| 269 | 269 | $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One (Add domains to your header.inc.php)'; |
| 270 | 270 | return '3'; |
| 271 | 271 | } |
| 272 | - elseif(@$GLOBALS['egw_info']['server']['versions']['header'] != @$GLOBALS['egw_info']['server']['versions']['current_header']) |
|
| 272 | + elseif (@$GLOBALS['egw_info']['server']['versions']['header'] != @$GLOBALS['egw_info']['server']['versions']['current_header']) |
|
| 273 | 273 | { |
| 274 | 274 | $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage One (Upgrade your header.inc.php)'; |
| 275 | 275 | return '4'; |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | * @param array $setup_info =null default use $GLOBALS['setup_info'] |
| 287 | 287 | * @return int 1=no database, 3=empty, 4=need upgrade, 10=complete |
| 288 | 288 | */ |
| 289 | - function check_db($setup_info=null) |
|
| 289 | + function check_db($setup_info = null) |
|
| 290 | 290 | { |
| 291 | 291 | if (!$setup_info) $setup_info = $GLOBALS['setup_info']; |
| 292 | 292 | |
@@ -294,14 +294,14 @@ discard block |
||
| 294 | 294 | if (!$GLOBALS['egw_setup']->db->Link_ID) |
| 295 | 295 | { |
| 296 | 296 | $old = error_reporting(); |
| 297 | - error_reporting($old & ~E_WARNING); // no warnings |
|
| 297 | + error_reporting($old&~E_WARNING); // no warnings |
|
| 298 | 298 | $GLOBALS['egw_setup']->db->connect(); |
| 299 | 299 | error_reporting($old); |
| 300 | 300 | |
| 301 | 301 | $GLOBALS['egw_setup']->set_table_names(); |
| 302 | 302 | } |
| 303 | 303 | } |
| 304 | - catch(egw_exception_db $e) { |
|
| 304 | + catch (egw_exception_db $e) { |
|
| 305 | 305 | // ignore error |
| 306 | 306 | } |
| 307 | 307 | |
@@ -310,14 +310,14 @@ discard block |
||
| 310 | 310 | $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 1 (Create Database)'; |
| 311 | 311 | return 1; |
| 312 | 312 | } |
| 313 | - if(!isset($setup_info['phpgwapi']['currentver'])) |
|
| 313 | + if (!isset($setup_info['phpgwapi']['currentver'])) |
|
| 314 | 314 | { |
| 315 | 315 | $setup_info = $this->get_db_versions($setup_info); |
| 316 | 316 | } |
| 317 | 317 | //_debug_array($setup_info); |
| 318 | 318 | if (isset($setup_info['phpgwapi']['currentver'])) |
| 319 | 319 | { |
| 320 | - if(@$setup_info['phpgwapi']['currentver'] == @$setup_info['phpgwapi']['version']) |
|
| 320 | + if (@$setup_info['phpgwapi']['currentver'] == @$setup_info['phpgwapi']['version']) |
|
| 321 | 321 | { |
| 322 | 322 | $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 1 (Tables Complete)'; |
| 323 | 323 | return 10; |
@@ -351,14 +351,14 @@ discard block |
||
| 351 | 351 | */ |
| 352 | 352 | function check_config() |
| 353 | 353 | { |
| 354 | - if(@$GLOBALS['egw_info']['setup']['stage']['db'] != 10) |
|
| 354 | + if (@$GLOBALS['egw_info']['setup']['stage']['db'] != 10) |
|
| 355 | 355 | { |
| 356 | 356 | return ''; |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | try { // catch db errors |
| 360 | - $GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table,'config_name,config_value',array('config_app' => 'phpgwapi'),__LINE__,__FILE__); |
|
| 361 | - while($GLOBALS['egw_setup']->db->next_record()) |
|
| 360 | + $GLOBALS['egw_setup']->db->select($GLOBALS['egw_setup']->config_table, 'config_name,config_value', array('config_app' => 'phpgwapi'), __LINE__, __FILE__); |
|
| 361 | + while ($GLOBALS['egw_setup']->db->next_record()) |
|
| 362 | 362 | { |
| 363 | 363 | $config[$GLOBALS['egw_setup']->db->f(0)] = $GLOBALS['egw_setup']->db->f(1); |
| 364 | 364 | } |
@@ -368,21 +368,21 @@ discard block |
||
| 368 | 368 | // ignore db errors |
| 369 | 369 | } |
| 370 | 370 | $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 2 (Needs Configuration)'; |
| 371 | - if(!count($config)) |
|
| 371 | + if (!count($config)) |
|
| 372 | 372 | { |
| 373 | 373 | return 1; |
| 374 | 374 | } |
| 375 | - $config_errors =& $GLOBALS['egw_info']['setup']['config_errors']; |
|
| 375 | + $config_errors = & $GLOBALS['egw_info']['setup']['config_errors']; |
|
| 376 | 376 | $GLOBALS['egw_info']['setup']['config_errors'] = array(); |
| 377 | 377 | $error_msg = null; |
| 378 | - if (!$this->check_dir($config['temp_dir'],$error_msg)) |
|
| 378 | + if (!$this->check_dir($config['temp_dir'], $error_msg)) |
|
| 379 | 379 | { |
| 380 | - $config_errors[] = lang("Your temporary directory '%1' %2",$config['temp_dir'],$error_msg); |
|
| 380 | + $config_errors[] = lang("Your temporary directory '%1' %2", $config['temp_dir'], $error_msg); |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | - if (!$this->check_dir($config['files_dir'],$error_msg,true)) |
|
| 383 | + if (!$this->check_dir($config['files_dir'], $error_msg, true)) |
|
| 384 | 384 | { |
| 385 | - $config_errors[] = lang("Your files directory '%1' %2",$config['files_dir'],$error_msg); |
|
| 385 | + $config_errors[] = lang("Your files directory '%1' %2", $config['files_dir'], $error_msg); |
|
| 386 | 386 | } |
| 387 | 387 | // set and create the default backup_dir |
| 388 | 388 | if (@is_writeable($config['files_dir']) && empty($config['backup_dir'])) |
@@ -390,35 +390,35 @@ discard block |
||
| 390 | 390 | $config['backup_dir'] = $config['files_dir'].'/db_backup'; |
| 391 | 391 | if (!is_dir($config['backup_dir']) && mkdir($config['backup_dir'])) |
| 392 | 392 | { |
| 393 | - $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array( |
|
| 393 | + $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table, array( |
|
| 394 | 394 | 'config_value' => $config['backup_dir'], |
| 395 | - ),array( |
|
| 395 | + ), array( |
|
| 396 | 396 | 'config_app' => 'phpgwapi', |
| 397 | 397 | 'config_name' => 'backup_dir', |
| 398 | - ),__LINE__,__FILE__); |
|
| 398 | + ), __LINE__, __FILE__); |
|
| 399 | 399 | } |
| 400 | 400 | } |
| 401 | 401 | if (isset($config['backup_mincount'])) |
| 402 | 402 | { |
| 403 | - $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array( |
|
| 403 | + $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table, array( |
|
| 404 | 404 | 'config_value' => $config['backup_mincount'], |
| 405 | - ),array( |
|
| 405 | + ), array( |
|
| 406 | 406 | 'config_app' => 'phpgwapi', |
| 407 | 407 | 'config_name' => 'backup_mincount', |
| 408 | - ),__LINE__,__FILE__); |
|
| 408 | + ), __LINE__, __FILE__); |
|
| 409 | 409 | } |
| 410 | 410 | if (isset($config['backup_files'])) |
| 411 | 411 | { |
| 412 | - $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array( |
|
| 412 | + $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table, array( |
|
| 413 | 413 | 'config_value' => (int)$config['backup_files'], |
| 414 | - ),array( |
|
| 414 | + ), array( |
|
| 415 | 415 | 'config_app' => 'phpgwapi', |
| 416 | 416 | 'config_name' => 'backup_files', |
| 417 | - ),__LINE__,__FILE__); |
|
| 417 | + ), __LINE__, __FILE__); |
|
| 418 | 418 | } |
| 419 | - if (!$this->check_dir($config['backup_dir'],$error_msg,true)) |
|
| 419 | + if (!$this->check_dir($config['backup_dir'], $error_msg, true)) |
|
| 420 | 420 | { |
| 421 | - $config_errors[] = lang("Your backup directory '%1' %2",$config['backup_dir'],$error_msg); |
|
| 421 | + $config_errors[] = lang("Your backup directory '%1' %2", $config['backup_dir'], $error_msg); |
|
| 422 | 422 | } |
| 423 | 423 | if ($config_errors) |
| 424 | 424 | { |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | |
| 431 | 431 | function check_lang($check = True) |
| 432 | 432 | { |
| 433 | - if($check && $GLOBALS['egw_info']['setup']['stage']['db'] != 10) |
|
| 433 | + if ($check && $GLOBALS['egw_info']['setup']['stage']['db'] != 10) |
|
| 434 | 434 | { |
| 435 | 435 | return ''; |
| 436 | 436 | } |
@@ -439,21 +439,21 @@ discard block |
||
| 439 | 439 | $GLOBALS['setup_info'] = $GLOBALS['egw_setup']->detection->get_db_versions($GLOBALS['setup_info']); |
| 440 | 440 | } |
| 441 | 441 | try { |
| 442 | - $GLOBALS['egw_setup']->db->query($q = "SELECT DISTINCT lang FROM {$GLOBALS['egw_setup']->lang_table}",__LINE__,__FILE__); |
|
| 442 | + $GLOBALS['egw_setup']->db->query($q = "SELECT DISTINCT lang FROM {$GLOBALS['egw_setup']->lang_table}", __LINE__, __FILE__); |
|
| 443 | 443 | } |
| 444 | 444 | catch (egw_exception_db $e) { |
| 445 | 445 | // ignore db error |
| 446 | 446 | } |
| 447 | - if($e || $GLOBALS['egw_setup']->db->num_rows() == 0) |
|
| 447 | + if ($e || $GLOBALS['egw_setup']->db->num_rows() == 0) |
|
| 448 | 448 | { |
| 449 | 449 | $GLOBALS['egw_info']['setup']['header_msg'] = 'Stage 3 (No languages installed)'; |
| 450 | 450 | return 1; |
| 451 | 451 | } |
| 452 | - while(@$GLOBALS['egw_setup']->db->next_record()) |
|
| 452 | + while (@$GLOBALS['egw_setup']->db->next_record()) |
|
| 453 | 453 | { |
| 454 | 454 | $GLOBALS['egw_info']['setup']['installed_langs'][$GLOBALS['egw_setup']->db->f('lang')] = $GLOBALS['egw_setup']->db->f('lang'); |
| 455 | 455 | } |
| 456 | - foreach($GLOBALS['egw_info']['setup']['installed_langs'] as $value) |
|
| 456 | + foreach ($GLOBALS['egw_info']['setup']['installed_langs'] as $value) |
|
| 457 | 457 | { |
| 458 | 458 | $sql = "SELECT lang_name FROM {$GLOBALS['egw_setup']->languages_table} WHERE lang_id = '".$value."'"; |
| 459 | 459 | $GLOBALS['egw_setup']->db->query($sql); |
@@ -471,19 +471,19 @@ discard block |
||
| 471 | 471 | * @param $appname |
| 472 | 472 | * @param $any optional, set to True to see if any of the apps tables are installed |
| 473 | 473 | */ |
| 474 | - function check_app_tables($appname,$any=False) |
|
| 474 | + function check_app_tables($appname, $any = False) |
|
| 475 | 475 | { |
| 476 | 476 | $none = 0; |
| 477 | 477 | $setup_info = $GLOBALS['setup_info']; |
| 478 | 478 | |
| 479 | - if(@$setup_info[$appname]['tables']) |
|
| 479 | + if (@$setup_info[$appname]['tables']) |
|
| 480 | 480 | { |
| 481 | 481 | /* Make a copy, else we send some callers into an infinite loop */ |
| 482 | 482 | $copy = $setup_info; |
| 483 | 483 | $tables = Array(); |
| 484 | 484 | try { |
| 485 | 485 | $table_names = $GLOBALS['egw_setup']->db->table_names(); |
| 486 | - foreach($table_names as $key => $val) |
|
| 486 | + foreach ($table_names as $key => $val) |
|
| 487 | 487 | { |
| 488 | 488 | $tables[] = $val['table_name']; |
| 489 | 489 | } |
@@ -492,19 +492,19 @@ discard block |
||
| 492 | 492 | unset($e); |
| 493 | 493 | // ignore db error |
| 494 | 494 | } |
| 495 | - foreach($copy[$appname]['tables'] as $key => $val) |
|
| 495 | + foreach ($copy[$appname]['tables'] as $key => $val) |
|
| 496 | 496 | { |
| 497 | - if($GLOBALS['DEBUG']) |
|
| 497 | + if ($GLOBALS['DEBUG']) |
|
| 498 | 498 | { |
| 499 | - echo '<br>check_app_tables(): Checking: ' . $appname . ',table: ' . $val; |
|
| 499 | + echo '<br>check_app_tables(): Checking: '.$appname.',table: '.$val; |
|
| 500 | 500 | } |
| 501 | - if(!in_array($val,$tables) && !in_array(strtolower($val),$tables)) // names in tables might be lowercase |
|
| 501 | + if (!in_array($val, $tables) && !in_array(strtolower($val), $tables)) // names in tables might be lowercase |
|
| 502 | 502 | { |
| 503 | - if($GLOBALS['DEBUG']) |
|
| 503 | + if ($GLOBALS['DEBUG']) |
|
| 504 | 504 | { |
| 505 | - echo '<br>check_app_tables(): ' . $val . ' missing!'; |
|
| 505 | + echo '<br>check_app_tables(): '.$val.' missing!'; |
|
| 506 | 506 | } |
| 507 | - if(!$any) |
|
| 507 | + if (!$any) |
|
| 508 | 508 | { |
| 509 | 509 | return False; |
| 510 | 510 | } |
@@ -515,9 +515,9 @@ discard block |
||
| 515 | 515 | } |
| 516 | 516 | else |
| 517 | 517 | { |
| 518 | - if($any) |
|
| 518 | + if ($any) |
|
| 519 | 519 | { |
| 520 | - if($GLOBALS['DEBUG']) |
|
| 520 | + if ($GLOBALS['DEBUG']) |
|
| 521 | 521 | { |
| 522 | 522 | echo '<br>check_app_tables(): Some tables installed'; |
| 523 | 523 | } |
@@ -526,9 +526,9 @@ discard block |
||
| 526 | 526 | } |
| 527 | 527 | } |
| 528 | 528 | } |
| 529 | - if($none && $any) |
|
| 529 | + if ($none && $any) |
|
| 530 | 530 | { |
| 531 | - if($GLOBALS['DEBUG']) |
|
| 531 | + if ($GLOBALS['DEBUG']) |
|
| 532 | 532 | { |
| 533 | 533 | echo '<br>check_app_tables(): No tables installed'; |
| 534 | 534 | } |
@@ -536,7 +536,7 @@ discard block |
||
| 536 | 536 | } |
| 537 | 537 | else |
| 538 | 538 | { |
| 539 | - if($GLOBALS['DEBUG']) |
|
| 539 | + if ($GLOBALS['DEBUG']) |
|
| 540 | 540 | { |
| 541 | 541 | echo '<br>check_app_tables(): All tables installed'; |
| 542 | 542 | } |
@@ -552,9 +552,9 @@ discard block |
||
| 552 | 552 | * @param boolean $check_in_docroot =false run an optional in docroot check |
| 553 | 553 | * @return boolean |
| 554 | 554 | */ |
| 555 | - static function check_dir($dir,&$msg,$check_in_docroot=false) |
|
| 555 | + static function check_dir($dir, &$msg, $check_in_docroot = false) |
|
| 556 | 556 | { |
| 557 | - if (!@is_dir($dir) && !@mkdir($dir,0700,true)) |
|
| 557 | + if (!@is_dir($dir) && !@mkdir($dir, 0700, true)) |
|
| 558 | 558 | { |
| 559 | 559 | $msg = lang('does not exist'); |
| 560 | 560 | return false; |
@@ -566,16 +566,16 @@ discard block |
||
| 566 | 566 | } |
| 567 | 567 | if ($check_in_docroot) |
| 568 | 568 | { |
| 569 | - $docroots = array(realpath(EGW_SERVER_ROOT),realpath($_SERVER['DOCUMENT_ROOT'])); |
|
| 569 | + $docroots = array(realpath(EGW_SERVER_ROOT), realpath($_SERVER['DOCUMENT_ROOT'])); |
|
| 570 | 570 | $dir = realpath($dir); |
| 571 | 571 | |
| 572 | 572 | foreach ($docroots as $docroot) |
| 573 | 573 | { |
| 574 | 574 | $len = strlen($docroot); |
| 575 | 575 | |
| 576 | - if ($docroot == substr($dir,0,$len) && $len>0) |
|
| 576 | + if ($docroot == substr($dir, 0, $len) && $len > 0) |
|
| 577 | 577 | { |
| 578 | - $rest = substr($dir,$len); |
|
| 578 | + $rest = substr($dir, $len); |
|
| 579 | 579 | |
| 580 | 580 | if (!strlen($rest) || $rest[0] == DIRECTORY_SEPARATOR) |
| 581 | 581 | { |