/**
  * Check if email is uniq.
  */
 function checkEmailExist($s)
 {
     if (!$this->checkEmail($s)) {
         return false;
     }
     return BxDolAccountQuery::getInstance()->getIdByEmail($s) ? true : _t('_sys_form_forgot_password_email_not_recognized');
 }
Beispiel #2
0
 public function serviceProfilesSearch($sTerm, $iLimit)
 {
     $oDb = BxDolAccountQuery::getInstance();
     $aRet = array();
     $a = $oDb->searchByTerm($sTerm, $iLimit);
     foreach ($a as $r) {
         $aRet[] = array('label' => $this->serviceProfileName($r['content_id']), 'value' => $r['profile_id']);
     }
     return $aRet;
 }
Beispiel #3
0
 /**
  * Check if email is uniq.
  */
 function checkEmailUniq($s)
 {
     if (!$this->checkEmail($s)) {
         return false;
     }
     $oAccount = BxDolAccount::getInstance();
     if ($oAccount) {
         // user is logged in
         $aAccountInfo = $oAccount->getInfo();
         if ($s == $aAccountInfo['email']) {
             // don't check email for uniq, if it wasn't changed
             return true;
         }
         return BxDolAccountQuery::getInstance()->getIdByEmail($s) ? _t('_sys_form_account_input_email_uniq_error_loggedin') : true;
     }
     return BxDolAccountQuery::getInstance()->getIdByEmail($s) ? _t('_sys_form_account_input_email_uniq_error', BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=forgot-password')) : true;
 }
 /**
  * Check if menu items is visible.
  * @param $a menu item array
  * @return boolean
  */
 protected function _isVisible($a)
 {
     if (!parent::_isVisible($a)) {
         return false;
     }
     $aDataEntry = BxDolAccountQuery::getInstance()->getInfoById($this->_iContentId);
     if (empty($aDataEntry) || !is_array($aDataEntry)) {
         return false;
     }
     $sCheckFuncName = '';
     switch ($a['name']) {
         case 'delete':
         case 'delete-with-content':
             $sCheckFuncName = 'checkAllowedDelete';
             break;
     }
     if (!$sCheckFuncName || !method_exists($this->_oModule, $sCheckFuncName)) {
         return true;
     }
     return $this->_oModule->{$sCheckFuncName}($aDataEntry) === CHECK_ACTION_RESULT_ALLOWED;
 }
 /**
  * Get current account profile.
  * @param  string  $iAccountId account id
  * @return current account's profile id
  */
 public function getCurrentProfileByAccount($iAccountId)
 {
     $sSql = $this->prepare("SELECT `profile_id` FROM `sys_accounts` WHERE `id` = ? LIMIT 1", $iAccountId);
     $iProfileId = $this->getOne($sSql);
     if (!$iProfileId) {
         $sSql = $this->prepare("SELECT `id` FROM `sys_profiles` WHERE `account_id` = ? LIMIT 1", $iAccountId);
         $iProfileId = $this->getOne($sSql);
         if (!$iProfileId) {
             return false;
         }
         bx_import('BxDolAccountQuery');
         if (!BxDolAccountQuery::getInstance()->updateCurrentProfile($iAccountId, $iProfileId)) {
             return false;
         }
     }
     return $iProfileId;
 }
 public function __construct()
 {
     parent::__construct();
     $this->_oAccountForms = new BxTemplAccountForms();
     $this->_oAccountQuery = BxDolAccountQuery::getInstance();
 }
Beispiel #7
0
 protected function setLangCookie($sLang)
 {
     $sLang = bx_process_input($sLang);
     if (isLogged()) {
         $iLangId = $this->oDb->getLanguageId($sLang, false);
         if (!$iLangId) {
             $iLangId = 0;
         }
         $iAccountId = getLoggedId();
         bx_import('BxDolAccountQuery');
         $oAccountQuery = BxDolAccountQuery::getInstance();
         $oAccountQuery->updateLanguage($iAccountId, $iLangId);
     }
     setcookie('lang', '', time() - 60 * 60 * 24, '/');
     setcookie('lang', $sLang, time() + 60 * 60 * 24 * 365, '/');
 }
Beispiel #8
0
/**
 * Login user by setting necessary cookies
 * @param $iId account id
 * @return false if id isn't correct or array of user info if user was logged in
 */
function bx_login($iId, $bRememberMe = false)
{
    bx_import('BxDolAccountQuery');
    $oAccountQuery = BxDolAccountQuery::getInstance();
    $sPassword = $oAccountQuery->getPassword($iId);
    if (!$sPassword) {
        return false;
    }
    $aUrl = parse_url(BX_DOL_URL_ROOT);
    $sPath = isset($aUrl['path']) && !empty($aUrl['path']) ? $aUrl['path'] : '/';
    $sHost = '';
    $iCookieTime = $bRememberMe ? time() + 24 * 60 * 60 * 30 : 0;
    setcookie("memberID", $iId, $iCookieTime, $sPath, $sHost);
    $_COOKIE['memberID'] = $iId;
    setcookie("memberPassword", $sPassword, $iCookieTime, $sPath, $sHost, false, true);
    $_COOKIE['memberPassword'] = $sPassword;
    bx_import('BxDolSession');
    BxDolSession::getInstance()->setUserId($iId);
    $oAccountQuery->updateLoggedIn($iId);
    bx_alert('account', 'login', $iId);
    return $oAccountQuery->getInfoById($iId);
}
 protected function _getContentInfo($iId)
 {
     return BxDolAccountQuery::getInstance()->getInfoById($iId);
 }
Beispiel #10
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;
 }