Example #1
0
 /**
  * @param int $id
  * @return Account
  */
 function &SelectAccountData($id)
 {
     $null = null;
     if (!$this->_connector->Execute($this->_commandCreator->SelectAccountData($id))) {
         return $null;
     }
     $account = new Account($this->_settings);
     $row = $this->_connector->GetNextRecord();
     if ($row) {
         $account->Id = (int) $row->id_acct;
         $account->IdUser = (int) $row->id_user;
         $account->DefaultAccount = (bool) abs($row->def_acct);
         $account->Deleted = (bool) abs($row->deleted);
         $account->Email = $row->email;
         $account->MailProtocol = (int) $row->mail_protocol;
         $account->MailIncHost = $row->mail_inc_host;
         $account->MailIncLogin = $row->mail_inc_login;
         $account->MailIncPort = (int) $row->mail_inc_port;
         $account->MailOutHost = $row->mail_out_host;
         $account->MailOutLogin = $row->mail_out_login;
         $account->MailOutPort = (int) $row->mail_out_port;
         $account->MailOutAuthentication = (int) $row->mail_out_auth;
         $account->FriendlyName = $row->friendly_nm;
         $account->UseFriendlyName = (bool) abs($row->use_friendly_nm);
         $account->DefaultOrder = (int) $row->def_order;
         $account->GetMailAtLogin = (bool) abs($row->getmail_at_login);
         $account->MailMode = (int) $row->mail_mode;
         $account->MailsOnServerDays = (int) $row->mails_on_server_days;
         $account->SignatureType = (int) $row->signature_type;
         $account->SignatureOptions = (int) $row->signature_opt;
         $account->HideContacts = (bool) abs($row->hide_contacts);
         $account->MailsPerPage = (int) $row->msgs_per_page > 0 ? (int) $row->msgs_per_page : 20;
         $account->Delimiter = $row->delimiter;
         $account->NameSpace = $row->personal_namespace;
         $account->DomainId = (int) $row->id_domain;
         $account->WhiteListing = (bool) abs($row->white_listing);
         $account->XSpam = (bool) abs($row->x_spam);
         $account->LastLogin = (int) $row->last_login;
         $account->LoginsCount = (int) $row->logins_count;
         $account->DefaultSkin = $row->def_skin;
         $account->DefaultLanguage = $row->def_lang;
         $account->DefaultIncCharset = ap_Utils::GetCodePageName((int) $row->def_charset_inc);
         $account->DefaultOutCharset = ap_Utils::GetCodePageName((int) $row->def_charset_out);
         $account->DefaultTimeZone = (int) $row->def_timezone;
         $account->DefaultDateFormat = CDateTime::GetDateFormatFromBd($row->def_date_fmt);
         $account->DefaultTimeFormat = CDateTime::GetTimeFormatFromBd($row->def_date_fmt);
         $account->HideFolders = (bool) abs($row->hide_folders);
         $account->MailboxLimit = GetGoodBigInt($row->mailbox_limit);
         $account->MailboxSize = GetGoodBigInt($row->mailbox_size);
         $account->AllowChangeSettings = (bool) abs($row->allow_change_settings);
         $account->AllowDhtmlEditor = (bool) abs($row->allow_dhtml_editor);
         $account->AllowDirectMode = (bool) abs($row->allow_direct_mode);
         $account->DbCharset = ap_Utils::GetCodePageName((int) $row->db_charset);
         $account->HorizResizer = (int) $row->horiz_resizer;
         $account->VertResizer = (int) $row->vert_resizer;
         $account->Mark = (int) $row->mark;
         $account->Reply = (int) $row->reply;
         $account->ContactsPerPage = (int) $row->contacts_per_page > 0 ? (int) $row->contacts_per_page : 20;
         $account->ViewMode = (int) $row->view_mode;
         $account->MailIncPassword = ap_Utils::DecodePassword($row->mail_inc_pass);
         $account->MailOutPassword = ap_Utils::DecodePassword($row->mail_out_pass);
         $account->IsMailList = (bool) $row->mailing_list;
         $account->ImapQuota = (int) $row->imap_quota;
         $this->_connector->FreeResult();
     } else {
         $account = $null;
     }
     if ($account && !$account->IsMailList) {
         if (!is_object($account) || !$this->_connector->Execute($this->_commandCreator->SelectSignature($account->Id))) {
             return $null;
         }
         $row = $this->_connector->GetNextRecord();
         if ($row) {
             $account->Signature = $row->signature;
             $this->_connector->FreeResult();
         }
         if (!is_object($account) || !$this->_connector->Execute($this->_commandCreator->SelectAccountColumnsData($account->IdUser))) {
             return $null;
         }
         while (($row = $this->_connector->GetNextRecord()) != false) {
             $account->Columns[(int) $row->id_column] = $row->column_value;
         }
         if ($account->DomainId > 0 && $this->_connector->Execute($this->_commandCreator->SelectAccountAliases($account->Id))) {
             while (($row = $this->_connector->GetNextRecord()) != false) {
                 $account->Aliases[] = $row->alias_name;
             }
         }
         if ($account->DomainId > 0 && $this->_connector->Execute($this->_commandCreator->SelectAccountForwards($account->Id))) {
             while (($row = $this->_connector->GetNextRecord()) != false) {
                 $account->Forwards[] = $row->forward_to;
             }
         }
     } else {
         if ($account && $account->IsMailList) {
             if ($this->_connector->Execute($this->_commandCreator->SelectMailListAccountUsers($account->Id))) {
                 while (($row = $this->_connector->GetNextRecord()) != false) {
                     $account->MailingList[] = $row->list_to;
                 }
             }
         }
     }
     return $account;
 }