Пример #1
0
 /**
  * Re-used option getter for Show Accounts multiselect pane
  */
 function getShowAccountsOptions(&$ie)
 {
     global $current_user;
     global $app_strings;
     global $mod_strings;
     $ieAccountsFull = $ie->retrieveAllByGroupId($current_user->id);
     $ieAccountsShowOptionsMeta = array();
     $showFolders = unserialize(base64_decode($current_user->getPreference('showFolders', 'Emails')));
     $defaultIEAccount = $ie->getUsersDefaultOutboundServerId($current_user);
     foreach ($ieAccountsFull as $k => $v) {
         $selected = !empty($showFolders) && in_array($v->id, $showFolders) ? true : false;
         $default = $defaultIEAccount == $v->id ? TRUE : FALSE;
         $has_groupfolder = !empty($v->groupfolder_id) ? TRUE : FALSE;
         $type = $v->is_personal ? $mod_strings['LBL_MAILBOX_TYPE_PERSONAL'] : $mod_strings['LBL_MAILBOX_TYPE_GROUP'];
         $ieAccountsShowOptionsMeta[] = array("id" => $v->id, "name" => $v->name, 'is_active' => $selected, 'server_url' => $v->server_url, 'is_group' => !$v->is_personal, 'group_id' => $v->group_id, 'is_default' => $default, 'has_groupfolder' => $has_groupfolder, 'type' => $type);
     }
     //Retrieve the grou folders
     $f = new SugarFolder();
     $groupFolders = $f->getGroupFoldersForSettings($current_user);
     foreach ($groupFolders as $singleGroup) {
         //Retrieve the related IE accounts.
         $relatedIEAccounts = $ie->retrieveByGroupFolderId($singleGroup['id']);
         if (count($relatedIEAccounts) == 0) {
             $server_url = $app_strings['LBL_EMAIL_MULT_GROUP_FOLDER_ACCOUNTS_EMPTY'];
         } else {
             if (count($relatedIEAccounts) == 1) {
                 if ($relatedIEAccounts[0]->status != 'Active' || $relatedIEAccounts[0]->mailbox_type == 'bounce') {
                     continue;
                 }
                 $server_url = $relatedIEAccounts[0]->server_url;
             } else {
                 $server_url = $app_strings['LBL_EMAIL_MULT_GROUP_FOLDER_ACCOUNTS'];
             }
         }
         $type = $mod_strings['LBL_MAILBOX_TYPE_GROUP_FOLDER'];
         $ieAccountsShowOptionsMeta[] = array("id" => $singleGroup['id'], "name" => $singleGroup['origName'], 'is_active' => $singleGroup['selected'], 'server_url' => $server_url, 'is_group' => true, 'group_id' => $singleGroup['id'], 'is_default' => FALSE, 'has_groupfolder' => true, 'type' => $type);
     }
     return $ieAccountsShowOptionsMeta;
 }