@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | static function treeLeafNoConnectionArray($_profileID, $_err, $_path, $_parent) |
| 69 | 69 | { |
| 70 | 70 | $baseNode = array('id' => $_profileID); |
| 71 | - $leaf = array( |
|
| 71 | + $leaf = array( |
|
| 72 | 72 | 'id' => $_profileID.self::$delimiter.'INBOX', |
| 73 | 73 | 'text' => $_err, |
| 74 | 74 | 'tooltip' => $_err, |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | ); |
| 81 | 81 | self::setOutStructure($leaf, $baseNode, self::$delimiter); |
| 82 | 82 | |
| 83 | - return ($baseNode?$baseNode:array( // fallback not connected array |
|
| 83 | + return ($baseNode ? $baseNode : array( // fallback not connected array |
|
| 84 | 84 | 'id'=>0, |
| 85 | 85 | 'item'=> array( |
| 86 | 86 | 'text'=>'INBOX', |
@@ -97,13 +97,13 @@ discard block |
||
| 97 | 97 | * @param string $path a node path |
| 98 | 98 | * @return array returns an array of data extracted from given node path |
| 99 | 99 | */ |
| 100 | - static function pathToFolderData ($_path, $_hDelimiter) |
|
| 100 | + static function pathToFolderData($_path, $_hDelimiter) |
|
| 101 | 101 | { |
| 102 | 102 | if (!strpos($_path, self::$delimiter)) $_path = self::$delimiter.$_path; |
| 103 | 103 | list(,$path) = explode(self::$delimiter, $_path); |
| 104 | 104 | $path_chain = $parts = explode($_hDelimiter, $path); |
| 105 | 105 | $name = array_pop($parts); |
| 106 | - return array ( |
|
| 106 | + return array( |
|
| 107 | 107 | 'name' => $name, |
| 108 | 108 | 'mailbox' => $path, |
| 109 | 109 | 'parent' => implode($_hDelimiter, $parts), |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * @param array $_node array of a node |
| 120 | 120 | * @return int returns 1 if it has children flag set otherwise 0 |
| 121 | 121 | */ |
| 122 | - private static function nodeHasChildren ($_node) |
|
| 122 | + private static function nodeHasChildren($_node) |
|
| 123 | 123 | { |
| 124 | 124 | $hasChildren = 0; |
| 125 | 125 | if (in_array('\haschildren', $_node['ATTRIBUTES']) || |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | * @param type $_node a tree id node |
| 135 | 135 | * @return boolean returns true if the node is account node otherwise false |
| 136 | 136 | */ |
| 137 | - private static function isAccountNode ($_node) |
|
| 137 | + private static function isAccountNode($_node) |
|
| 138 | 138 | { |
| 139 | 139 | list(,$leaf) = explode(self::$delimiter, $_node); |
| 140 | 140 | if ($leaf || $_node == null) return false; |
@@ -172,10 +172,10 @@ discard block |
||
| 172 | 172 | * |
| 173 | 173 | * @return array returns an array of mail tree structure according to provided node |
| 174 | 174 | */ |
| 175 | - function getTree ($_parent = null, $_profileID = '', $_openTopLevel = 1, $_noCheckboxNS = false, $_subscribedOnly= false, $_allInOneGo = false, $_checkSubscribed = true) |
|
| 175 | + function getTree($_parent = null, $_profileID = '', $_openTopLevel = 1, $_noCheckboxNS = false, $_subscribedOnly = false, $_allInOneGo = false, $_checkSubscribed = true) |
|
| 176 | 176 | { |
| 177 | 177 | //Init mail folders |
| 178 | - $tree = array(tree::ID=> $_parent?$_parent:0,tree::CHILDREN => array()); |
|
| 178 | + $tree = array(tree::ID=> $_parent ? $_parent : 0, tree::CHILDREN => array()); |
|
| 179 | 179 | $hDelimiter = $this->ui->mail_bo->getHierarchyDelimiter(); |
| 180 | 180 | |
| 181 | 181 | if ($_parent) list($_profileID) = explode(self::$delimiter, $_parent); |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | { |
| 187 | 187 | $this->ui->changeProfile($_profileID); |
| 188 | 188 | } catch (Exception $ex) { |
| 189 | - return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(),array($_profileID), ''); |
|
| 189 | + return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(), array($_profileID), ''); |
|
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | if ($_parent && !self::isAccountNode($_parent)) // Single node loader |
| 199 | 199 | { |
| 200 | 200 | $nodeInfo = self::pathToFolderData($_parent, $hDelimiter); |
| 201 | - $folders = $this->ui->mail_bo->getFolderArrays($nodeInfo['mailbox'],false,$_allInOneGo?0:2, $_subscribedOnly); |
|
| 201 | + $folders = $this->ui->mail_bo->getFolderArrays($nodeInfo['mailbox'], false, $_allInOneGo ? 0 : 2, $_subscribedOnly); |
|
| 202 | 202 | |
| 203 | 203 | $childrenNode = array(); |
| 204 | 204 | foreach ($folders as &$node) |
@@ -207,14 +207,14 @@ discard block |
||
| 207 | 207 | $nodeData = self::pathToFolderData($nodeId, $node['delimiter']); |
| 208 | 208 | $childrenNode[] = array( |
| 209 | 209 | tree::ID=> $nodeId, |
| 210 | - tree::AUTOLOAD_CHILDREN => $_allInOneGo?false:self::nodeHasChildren($node), |
|
| 210 | + tree::AUTOLOAD_CHILDREN => $_allInOneGo ? false : self::nodeHasChildren($node), |
|
| 211 | 211 | tree::CHILDREN =>array(), |
| 212 | 212 | tree::LABEL => $nodeData['text'], |
| 213 | 213 | tree::TOOLTIP => $nodeData['tooltip'], |
| 214 | 214 | tree::IMAGE_LEAF => self::$leafImages['folderLeaf'], |
| 215 | 215 | tree::IMAGE_FOLDER_OPEN => self::$leafImages['folderOpen'], |
| 216 | 216 | tree::IMAGE_FOLDER_CLOSED => self::$leafImages['folderClose'], |
| 217 | - tree::CHECKED => $_checkSubscribed?$node['SUBSCRIBED']:false, |
|
| 217 | + tree::CHECKED => $_checkSubscribed ? $node['SUBSCRIBED'] : false, |
|
| 218 | 218 | 'parent' => $_parent |
| 219 | 219 | ); |
| 220 | 220 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | //List of folders |
| 237 | - $foldersList = $this->ui->mail_bo->getFolderArrays(null, true, $_allInOneGo?0:2,$_subscribedOnly, true); |
|
| 237 | + $foldersList = $this->ui->mail_bo->getFolderArrays(null, true, $_allInOneGo ? 0 : 2, $_subscribedOnly, true); |
|
| 238 | 238 | |
| 239 | 239 | // User defined folders based on account |
| 240 | 240 | $definedFolders = array( |
@@ -254,14 +254,14 @@ discard block |
||
| 254 | 254 | |
| 255 | 255 | $data = array( |
| 256 | 256 | tree::ID=>$_profileID.self::$delimiter.$folder['MAILBOX'], |
| 257 | - tree::AUTOLOAD_CHILDREN => $_allInOneGo?false:self::nodeHasChildren($folder), |
|
| 257 | + tree::AUTOLOAD_CHILDREN => $_allInOneGo ? false : self::nodeHasChildren($folder), |
|
| 258 | 258 | tree::CHILDREN =>array(), |
| 259 | 259 | tree::LABEL =>lang($folder['MAILBOX']), |
| 260 | - tree::OPEN => self::getNodeLevel($folder['MAILBOX'], $folder['delimiter']) <= $_openTopLevel?1:0, |
|
| 260 | + tree::OPEN => self::getNodeLevel($folder['MAILBOX'], $folder['delimiter']) <= $_openTopLevel ? 1 : 0, |
|
| 261 | 261 | tree::TOOLTIP => lang($folder['MAILBOX']), |
| 262 | - tree::CHECKED => $_checkSubscribed?$folder['SUBSCRIBED']:false, |
|
| 262 | + tree::CHECKED => $_checkSubscribed ? $folder['SUBSCRIBED'] : false, |
|
| 263 | 263 | tree::NOCHECKBOX => 0, |
| 264 | - 'parent' => $parent?$_profileID.self::$delimiter.implode($folder['delimiter'], $parent):$_profileID, |
|
| 264 | + 'parent' => $parent ? $_profileID.self::$delimiter.implode($folder['delimiter'], $parent) : $_profileID, |
|
| 265 | 265 | 'path' => $path, |
| 266 | 266 | 'folderarray' => $folder |
| 267 | 267 | ); |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | catch (Exception $ex) // Catch exceptions |
| 300 | 300 | { |
| 301 | 301 | //mail_ui::callWizard($ex->getMessage(), false, 'error'); |
| 302 | - return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(),array($_profileID), ''); |
|
| 302 | + return self::treeLeafNoConnectionArray($_profileID, $ex->getMessage(), array($_profileID), ''); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | return $tree; |
@@ -316,19 +316,19 @@ discard block |
||
| 316 | 316 | * as clearance for access may be limited to a single branch-node of a tree |
| 317 | 317 | * @return void |
| 318 | 318 | */ |
| 319 | - static function setOutStructure($data, &$out, $del='.', $createMissingParents=true, $nameSpace=array(), $definedFolders= array()) |
|
| 319 | + static function setOutStructure($data, &$out, $del = '.', $createMissingParents = true, $nameSpace = array(), $definedFolders = array()) |
|
| 320 | 320 | { |
| 321 | 321 | //error_log(__METHOD__."(".array2string($data).', '.array2string($out).", '$del')"); |
| 322 | 322 | $components = $data['path']; |
| 323 | - array_pop($components); // remove own name |
|
| 323 | + array_pop($components); // remove own name |
|
| 324 | 324 | |
| 325 | 325 | $insert = &$out; |
| 326 | 326 | $parents = array(); |
| 327 | - foreach($components as $component) |
|
| 327 | + foreach ($components as $component) |
|
| 328 | 328 | { |
| 329 | - if (count($parents)>1) |
|
| 329 | + if (count($parents) > 1) |
|
| 330 | 330 | { |
| 331 | - $helper = array_slice($parents,1,null,true); |
|
| 331 | + $helper = array_slice($parents, 1, null, true); |
|
| 332 | 332 | $parent = $parents[0].self::$delimiter.implode($del, $helper); |
| 333 | 333 | if ($parent) $parent .= $del; |
| 334 | 334 | } |
@@ -351,21 +351,21 @@ discard block |
||
| 351 | 351 | { |
| 352 | 352 | // if (appropriately padded) namespace prefix of (others or shared) is the leading part of parent |
| 353 | 353 | // we want to create the node in question as we meet the above considerations |
| 354 | - if ($nsp['type']!='personal' && $nsp['prefix_present'] && stripos($parent,$data['path'][0].self::$delimiter.$nsp['prefix'])===0) |
|
| 354 | + if ($nsp['type'] != 'personal' && $nsp['prefix_present'] && stripos($parent, $data['path'][0].self::$delimiter.$nsp['prefix']) === 0) |
|
| 355 | 355 | { |
| 356 | 356 | if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' about to create:'.$parent.' in '.$data['path'][0].self::$delimiter.$nsp['prefix']); |
| 357 | - $break=false; |
|
| 357 | + $break = false; |
|
| 358 | 358 | } |
| 359 | 359 | } |
| 360 | 360 | if ($break) break; |
| 361 | 361 | } |
| 362 | 362 | if ($insert['item']) |
| 363 | 363 | { |
| 364 | - foreach($insert['item'] as &$item) |
|
| 364 | + foreach ($insert['item'] as &$item) |
|
| 365 | 365 | { |
| 366 | 366 | if ($item['id'] == $parent.$component) |
| 367 | 367 | { |
| 368 | - $insert =& $item; |
|
| 368 | + $insert = & $item; |
|
| 369 | 369 | break; |
| 370 | 370 | } |
| 371 | 371 | } |
@@ -375,9 +375,9 @@ discard block |
||
| 375 | 375 | if ($createMissingParents) |
| 376 | 376 | { |
| 377 | 377 | unset($item); |
| 378 | - $item = array('id' => $parent.$component, 'text' => $component, 'im0' => "folderNoSelectClosed.gif",'im1' => "folderNoSelectOpen.gif",'im2' => "folderNoSelectClosed.gif",'tooltip' => lang('no access')); |
|
| 379 | - $insert['item'][] =& $item; |
|
| 380 | - $insert =& $item; |
|
| 378 | + $item = array('id' => $parent.$component, 'text' => $component, 'im0' => "folderNoSelectClosed.gif", 'im1' => "folderNoSelectOpen.gif", 'im2' => "folderNoSelectClosed.gif", 'tooltip' => lang('no access')); |
|
| 379 | + $insert['item'][] = & $item; |
|
| 380 | + $insert = & $item; |
|
| 381 | 381 | } |
| 382 | 382 | else |
| 383 | 383 | { |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | $data[tree::IMAGE_FOLDER_OPEN] = |
| 411 | 411 | $data [tree::IMAGE_FOLDER_CLOSED] = "MailFolder".$key.".png"; |
| 412 | 412 | } |
| 413 | - elseif(stripos(array2string($data['folderarray']['attributes']),'\noselect')!== false) |
|
| 413 | + elseif (stripos(array2string($data['folderarray']['attributes']), '\noselect') !== false) |
|
| 414 | 414 | { |
| 415 | 415 | $data[tree::IMAGE_LEAF] = self::$leafImages['folderNoSelectClosed']; |
| 416 | 416 | $data[tree::IMAGE_FOLDER_OPEN] = self::$leafImages['folderNoSelectOpen']; |
@@ -452,20 +452,20 @@ discard block |
||
| 452 | 452 | * |
| 453 | 453 | * @return array an array of baseNodes of accounts |
| 454 | 454 | */ |
| 455 | - static function getAccountsRootNode($_profileID = null, $_noCheckbox = false, $_openTopLevel = 0 ) |
|
| 455 | + static function getAccountsRootNode($_profileID = null, $_noCheckbox = false, $_openTopLevel = 0) |
|
| 456 | 456 | { |
| 457 | 457 | $roots = array(tree::ID => 0, tree::CHILDREN => array()); |
| 458 | 458 | |
| 459 | - foreach(emailadmin_account::search(true, false) as $acc_id => $accObj) |
|
| 459 | + foreach (emailadmin_account::search(true, false) as $acc_id => $accObj) |
|
| 460 | 460 | { |
| 461 | - if (!$accObj->is_imap()|| $_profileID && $acc_id != $_profileID) continue; |
|
| 462 | - $identity = emailadmin_account::identity_name($accObj,true,$GLOBALS['egw_info']['user']['acount_id']); |
|
| 461 | + if (!$accObj->is_imap() || $_profileID && $acc_id != $_profileID) continue; |
|
| 462 | + $identity = emailadmin_account::identity_name($accObj, true, $GLOBALS['egw_info']['user']['acount_id']); |
|
| 463 | 463 | // Open top level folders for active account |
| 464 | - $openActiveAccount = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] == $acc_id?1:0; |
|
| 464 | + $openActiveAccount = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] == $acc_id ? 1 : 0; |
|
| 465 | 465 | |
| 466 | 466 | $baseNode = array( |
| 467 | 467 | tree::ID=> (string)$acc_id, |
| 468 | - tree::LABEL => str_replace(array('<','>'),array('[',']'),$identity), |
|
| 468 | + tree::LABEL => str_replace(array('<', '>'), array('[', ']'), $identity), |
|
| 469 | 469 | tree::TOOLTIP => '('.$acc_id.') '.htmlspecialchars_decode($identity), |
| 470 | 470 | tree::IMAGE_LEAF => self::$leafImages['folderAccount'], |
| 471 | 471 | tree::IMAGE_FOLDER_OPEN => self::$leafImages['folderAccount'], |
@@ -474,15 +474,15 @@ discard block |
||
| 474 | 474 | tree::CHILDREN => array(), // dynamic loading on unfold |
| 475 | 475 | tree::AUTOLOAD_CHILDREN => true, |
| 476 | 476 | 'parent' => '', |
| 477 | - tree::OPEN => $_openTopLevel?$_openTopLevel:$openActiveAccount, |
|
| 477 | + tree::OPEN => $_openTopLevel ? $_openTopLevel : $openActiveAccount, |
|
| 478 | 478 | // mark on account if Sieve is enabled |
| 479 | 479 | 'data' => array( |
| 480 | 480 | 'sieve' => $accObj->imapServer()->acc_sieve_enabled, |
| 481 | - 'spamfolder'=> $accObj->imapServer()->acc_folder_junk?true:false |
|
| 481 | + 'spamfolder'=> $accObj->imapServer()->acc_folder_junk ? true : false |
|
| 482 | 482 | ), |
| 483 | 483 | tree::NOCHECKBOX => $_noCheckbox |
| 484 | 484 | ); |
| 485 | - self::setOutStructure($baseNode, $roots,self::$delimiter); |
|
| 485 | + self::setOutStructure($baseNode, $roots, self::$delimiter); |
|
| 486 | 486 | } |
| 487 | 487 | return $roots; |
| 488 | 488 | } |
@@ -501,15 +501,15 @@ discard block |
||
| 501 | 501 | * @param boolean $_allInOneGo = false, true will get all folders (dependes on subscribedOnly option) of the account in one go |
| 502 | 502 | * @return type an array of tree |
| 503 | 503 | */ |
| 504 | - function getInitialIndexTree ($_parent = null, $_profileID = '', $_openTopLevel = 1, $_subscribedOnly= false, $_allInOneGo = false) |
|
| 504 | + function getInitialIndexTree($_parent = null, $_profileID = '', $_openTopLevel = 1, $_subscribedOnly = false, $_allInOneGo = false) |
|
| 505 | 505 | { |
| 506 | 506 | $tree = $this->getTree($_parent, '', $_openTopLevel, false, $_subscribedOnly, $_allInOneGo); |
| 507 | - $branches = $this->getTree($_profileID, $_profileID,1,false,$_subscribedOnly,$_allInOneGo); |
|
| 507 | + $branches = $this->getTree($_profileID, $_profileID, 1, false, $_subscribedOnly, $_allInOneGo); |
|
| 508 | 508 | foreach ($tree[tree::CHILDREN] as &$account) |
| 509 | 509 | { |
| 510 | 510 | if ($account[tree::ID] == $_profileID) |
| 511 | 511 | { |
| 512 | - $account = array_merge($account , $branches); |
|
| 512 | + $account = array_merge($account, $branches); |
|
| 513 | 513 | } |
| 514 | 514 | } |
| 515 | 515 | return $tree; |