Beispiel #1
0
 public function getProfilesByAccount($aContentInfo, $iMaxVisible = 2)
 {
     $oProfilesQuery = BxDolProfileQuery::getInstance();
     $aProfiles = $oProfilesQuery->getProfilesByAccount($aContentInfo['id']);
     $iProfiles = count($aProfiles);
     $aTmplVars = array('class_cnt' => '', 'bx_repeat:profiles' => array(), 'bx_if:profiles_more' => array('condition' => $iProfiles > $iMaxVisible, 'content' => array('html_id' => $this->_oConfig->getHtmlIds('profile_more_popup') . $aContentInfo['id'], 'more' => _t('_bx_accnt_txt_more', $iProfiles - $iMaxVisible), 'more_attr' => bx_html_attribute(_t('_bx_accnt_txt_see_more')), 'popup' => '')));
     $aTmplVarsPopup = array('class_cnt' => ' bx-def-padding', 'bx_repeat:profiles' => array(), 'bx_if:profiles_more' => array('condition' => false, 'content' => array()));
     $i = 0;
     foreach ($aProfiles as $iProfileId => $aProfile) {
         $oProfile = BxDolProfile::getInstance($iProfileId);
         if (!$oProfile) {
             continue;
         }
         $sName = $oProfile->getDisplayName();
         $aTmplVarsProfile = array('html_id' => $this->_oConfig->getHtmlIds('profile') . $aProfile['id'], 'id' => $oProfile->id(), 'url' => $oProfile->getUrl(), 'name' => $sName, 'name_attr' => bx_html_attribute($sName));
         if ($i < $iMaxVisible) {
             $aTmplVars['bx_repeat:profiles'][] = $aTmplVarsProfile;
         }
         if ($i >= $iMaxVisible) {
             $aTmplVarsPopup['bx_repeat:profiles'][] = $aTmplVarsProfile;
         }
         ++$i;
     }
     if ($aTmplVarsPopup['bx_repeat:profiles']) {
         $aTmplVars['bx_if:profiles_more']['content']['popup'] = BxTemplFunctions::getInstance()->transBox('', $this->parseHtmlByName('profiles.html', $aTmplVarsPopup));
     }
     return $this->parseHtmlByName('profiles.html', $aTmplVars);
 }
Beispiel #2
0
 function getExpirationLetter($iProfileId, $sLevelName, $iLevelExpireDays)
 {
     $iProfileId = (int) $iProfileId;
     if (!$iProfileId) {
         return false;
     }
     $oProfileQuery = BxDolProfileQuery::getInstance();
     $sProfileEmail = $oProfileQuery->getEmailById($iProfileId);
     $aPlus = array('membership_name' => $sLevelName, 'expire_days' => $iLevelExpireDays);
     $aTemplate = BxDolEmailTemplates::getInstance()->parseTemplate('t_MemExpiration', $aPlus, 0, $iProfileId);
     $iResult = $aTemplate && sendMail($sProfileEmail, $aTemplate['Subject'], $aTemplate['Body'], $iProfileId, $aPlus);
     return !empty($iResult);
 }
 protected function actionProcessDeletedProfiles($sOperation)
 {
     if (!in_array($sOperation, array('install', 'uninstall', 'enable', 'disable'))) {
         return BX_DOL_STUDIO_INSTALLER_FAILED;
     }
     $o = BxDolProfileQuery::getInstance();
     $o->processDeletedProfiles();
     return BX_DOL_STUDIO_INSTALLER_SUCCESS;
 }
Beispiel #4
0
 function getID($vID, $bWithEmail = 1)
 {
     $oPDb = new BxDolProfileQuery();
     if ($bWithEmail) {
         if (eregi("^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,4}\$", $vID)) {
             $aMail = $oPDb->getIdByEmail($vID);
             if ((int) $aMail['ID']) {
                 return (int) $aMail['ID'];
             }
         }
     }
     $iID = (int) $vID;
     if (strcmp("{$vID}", "{$iID}") == 0) {
         return $iID;
     } else {
         $aNick = $oPDb->getIdByNickname($vID);
         if ((int) $aNick['ID']) {
             return (int) $aNick['ID'];
         }
     }
     return false;
 }
Beispiel #5
0
 /**
  * Insert account and content id association. Also if currect profile id is not defined - it updates current profile id in account.
  * @param $iAccountId account id
  * @param $iContentId content id
  * @param $sStatus profile status
  * @param $sType profile content type
  * @return inserted profile's id
  */
 public static function add($iAction, $iAccountId, $iContentId, $sStatus, $sType = 'system')
 {
     $oQuery = BxDolProfileQuery::getInstance();
     if (!($iProfileId = $oQuery->insertProfile($iAccountId, $iContentId, $sStatus, $sType))) {
         return false;
     }
     bx_alert('profile', 'add', $iProfileId, 0, array('module' => $sType, 'content' => $iContentId, 'account' => $iAccountId, 'status' => $sStatus, 'action' => $iAction));
     return $iProfileId;
 }
Beispiel #6
0
 /**
  * Set class fields condition params and paginate array
  */
 function setConditionParams()
 {
     $aWhere = array();
     $aWhere[] = '1';
     $sKeyword = bx_process_input(bx_get('keyword'));
     if ($sKeyword !== false) {
         $this->aCurrent['restriction']['keyword'] = array('value' => $sKeyword, 'field' => '', 'operator' => 'against');
     }
     if (isset($_GET['ownerName'])) {
         $sName = bx_process_input($_GET['ownerName']);
         $iUser = (int) BxDolProfileQuery::getInstance()->getIdByNickname($sName);
         BxDolMenu::getInstance()->setCurrentProfileID($iUser);
     } elseif (isset($_GET['userID'])) {
         $iUser = bx_process_input($_GET['userID'], BX_DATA_INT);
     }
     if (!empty($iUser)) {
         $this->aCurrent['restriction']['owner']['value'] = $iUser;
     }
     $this->setPaginate();
     $iNum = $this->getNum();
     if ($iNum > 0) {
         $this->aCurrent['paginate']['num'] = $iNum;
     } else {
         $this->aCurrent['paginate']['num'] = 0;
     }
 }
 public function serviceAccountProfileSwitcher($iAccountId = false)
 {
     bx_import('BxDolProfileQuery');
     $oProfilesQuery = BxDolProfileQuery::getInstance();
     $aProfiles = $oProfilesQuery->getProfilesByAccount($iAccountId ? $iAccountId : getLoggedId());
     if (!$aProfiles) {
         return false;
     }
     $iLoggedPofileId = bx_get_logged_profile_id();
     $aVars = array('bx_repeat:row' => array());
     foreach ($aProfiles as $aProfile) {
         if ($aProfile['type'] == 'system') {
             // skip system account profile
             continue;
         }
         $aVars['bx_repeat:row'][] = array('class' => $iLoggedPofileId == $aProfile['id'] ? '' : 'bx-def-color-bg-box', 'bx_if:active' => array('condition' => $iLoggedPofileId == $aProfile['id'], 'content' => array('id' => $aProfile['id'])), 'bx_if:inactive' => array('condition' => $iLoggedPofileId != $aProfile['id'], 'content' => array('id' => $aProfile['id'], 'url_switch' => BxDolPermalinks::getInstance()->permalink('page.php?i=account-profile-switcher', array('switch_to_profile' => $aProfile['id'])))), 'unit' => BxDolService::call($aProfile['type'], 'profile_unit', array($aProfile['content_id'])));
     }
     if (!$aVars['bx_repeat:row']) {
         bx_import('BxDolMenu');
         $oMenu = BxDolMenu::getObjectInstance('sys_add_profile');
         return array('content' => $oMenu ? $oMenu->getCode() : MsgBox(_t('_sys_txt_empty')), 'menu' => 'sys_add_profile');
     }
     bx_import('BxDolTemplate');
     $oTemplate = BxDolTemplate::getInstance();
     $oTemplate->addCss('account.css');
     return array('content' => $oTemplate->parseHtmlByName('profile_switch_row.html', $aVars), 'menu' => 'sys_add_profile');
 }
Beispiel #8
0
 /**
  * Delete profile.
  */
 function delete($iAccountId = false)
 {
     $ID = (int) $iAccountId ? (int) $iAccountId : $this->_iAccountID;
     $aAccountInfo = $this->_oQuery->getInfoById($ID);
     if (!$aAccountInfo) {
         return false;
     }
     // create system event before deletion
     $isStopDeletion = false;
     bx_alert('account', 'before_delete', $ID, 0, array('stop_deletion' => &$isStopDeletion));
     if ($isStopDeletion) {
         return false;
     }
     bx_import('BxDolAccountQuery');
     $oAccountQuery = BxDolAccountQuery::getInstance();
     bx_import('BxDolProfile');
     $oProfileQuery = BxDolProfileQuery::getInstance();
     $aProfiles = $oProfileQuery->getProfilesByAccount($ID);
     foreach ($aProfiles as $iProfileId => $aRow) {
         $oProfile = BxDolProfile::getInstance($iProfileId);
         if (!$oProfile) {
             continue;
         }
         $oProfile->delete(false, true);
     }
     // delete profile
     if (!$oAccountQuery->delete($ID)) {
         return false;
     }
     // create system event
     bx_alert('account', 'delete', $ID);
     // unset class instance to prevent creating the instance again
     $this->_iAccountID = 0;
     $sClass = get_class($this) . '_' . $ID;
     unset($GLOBALS['bxDolClasses'][$sClass]);
     return true;
 }
Beispiel #9
0
 /**
  * Set class fields condition params and paginate array
  */
 function setConditionParams()
 {
     // keyword
     $sKeyword = bx_process_input(bx_get('keyword'));
     if ($sKeyword !== false) {
         $this->aCurrent['restriction']['keyword'] = array('value' => $sKeyword, 'field' => '', 'operator' => 'against');
     }
     // owner
     if (isset($_GET['ownerName'])) {
         $sName = bx_process_input($_GET['ownerName']);
         $iUser = (int) BxDolProfileQuery::getInstance()->getIdByNickname($sName);
         BxDolMenu::getInstance()->setCurrentProfileID($iUser);
     } elseif (isset($_GET['userID'])) {
         $iUser = bx_process_input($_GET['userID'], BX_DATA_INT);
     }
     if (!empty($iUser)) {
         $this->aCurrent['restriction']['owner']['value'] = $iUser;
     }
     // meta info
     if ($this->_sMetaType && !empty($this->aCurrent['object_metatags'])) {
         bx_import('BxDolMetatags');
         $o = BxDolMetatags::getObjectInstance($this->aCurrent['object_metatags']);
         if ($o) {
             unset($this->aCurrent['restriction']['keyword']);
             switch ($this->_sMetaType) {
                 case 'location_country':
                     $o->locationsSetSearchCondition($this, $sKeyword);
                     break;
                 case 'location_country_city':
                     $o->locationsSetSearchCondition($this, $sKeyword, bx_process_input(bx_get('state')), bx_process_input(bx_get('city')));
                     break;
                 case 'mention':
                     // TODO:
                     break;
                 case 'keyword':
                     $o->keywordsSetSearchCondition($this, $sKeyword);
                     break;
             }
         }
     }
     $this->setPaginate();
     $iNum = $this->getNum();
     if ($iNum > 0) {
         $this->aCurrent['paginate']['num'] = $iNum;
     } else {
         $this->aCurrent['paginate']['num'] = 0;
     }
 }
Beispiel #10
0
 function getID($vID = false, $bWithEmail = 1)
 {
     if (false === $vID) {
         return $this->_iProfileID;
     }
     $oPDb = new BxDolProfileQuery();
     if ($bWithEmail) {
         if (filter_var($vID, FILTER_VALIDATE_EMAIL)) {
             //eregi("^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,4}$", $vID) ) {
             $aMail = $oPDb->getIdByEmail($vID);
             if ((int) $aMail['ID']) {
                 return (int) $aMail['ID'];
             }
         }
     }
     $iID = (int) $vID;
     if (strcmp("{$vID}", "{$iID}") == 0) {
         return $iID;
     } else {
         $aNick = $oPDb->getIdByNickname($vID);
         if ((int) $aNick['ID']) {
             return (int) $aNick['ID'];
         }
     }
     return false;
 }