Example #1
0
 public function pub_getAccountFolders($o)
 {
     $this->setAccount($o['account']);
     $res = array('text' => $o['account'], 'uiProvider' => 'col', 'expanded' => true, 'allowDrop' => true, 'allowChildren' => true, 'folderType' => 'account');
     $this->imapProxy->open();
     if (!$this->imapProxy->isConnected()) {
         return $res;
     }
     $list = $this->imapProxy->getmailboxes("*");
     if (is_array($list)) {
         foreach ($list as $val) {
             $name = utf8_encode(imap_utf7_decode(str_replace($this->imapProxy->getAccountVar('cnx'), '', $val->name)));
             if (trim($name) != '') {
                 $tmpArr = explode($val->delimiter, $name);
                 $tmp =& $res;
                 foreach ($tmpArr as $k => $v) {
                     $id = implode($val->delimiter, array_slice($tmpArr, 0, $k + 1));
                     if (!array_key_exists('children', $tmp)) {
                         $tmp['children'] = array();
                     }
                     $subId = $id;
                     if (!array_key_exists($subId, $tmp['children'])) {
                         //db($subId);
                         //db($this->imapProxy->getacl($subId));
                         $tmp['children'][$subId] = array('text' => $v, 'id' => base64_encode($id), 'fid' => $id, 'uiProvider' => 'col', 'cls' => ' x-tree-node-collapsed x-tree-node-icon ', 'nb' => 0, 'allowDrop' => true, 'stat' => $this->imapProxy->status($subId), 'folderType' => 'folder');
                         QDImap::personalizeFolderIcon($tmp['children'][$subId], strtolower($v));
                     }
                     $tmp =& $tmp['children'][$subId];
                 }
             }
         }
         uasort($res['children'], array('QDImap', 'sortNaturalMailFolders'));
     } else {
         echo "imap_getmailboxes failed : " . imap_last_error() . "\n";
     }
     $this->flatAssocChildren($res);
     return array($res);
 }