Example #1
0
 public static function getInstance()
 {
     if (self::$instance === null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 protected function buildFrom() {
     $this->_selectBuilder->from->add(Pap_Db_Table_Users::getName(), 'u');
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_Users::getName(),
         'gu', 'u.accountuserid=gu.accountuserid');
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(),
         'au', 'au.authid=gu.authid');
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_Accounts::getName(),
         'a', 'a.accountid=gu.accountid');
     $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_Roles::getName(),
         'r', 'r.roleid=gu.roleid');
 }
Example #3
0
 public function loadByRoleType($roleType, $application)
 {
     $query = new Gpf_SqlBuilder_SelectBuilder();
     $query->select->addAll(Gpf_Db_Table_Users::getInstance(), 'u');
     $query->from->add(Gpf_Db_Table_Users::getName(), "u");
     $query->from->addInnerJoin(Gpf_Db_Table_Roles::getName(), "r", "r.roleid = u.roleid");
     $query->from->addInnerJoin(Gpf_Db_Table_Accounts::getName(), "a", "u.accountid = a.accountid");
     $query->where->add('u.authid', '=', $this->getAuthId());
     $query->where->add('u.accountid', '=', $this->getAccountId());
     $query->where->add('a.application', '=', $application);
     $query->where->add('r.roletype', '=', $roleType);
     $record = $query->getOneRow();
     $this->fillFromRecord($record);
 }
    /**
     * Get recordset of merchants recipients
     * 
     * @param $from
     * @return Gpf_Data_RecordSet
     */
    private function getMerchantsRecipients($from) {
        $select = new Gpf_SqlBuilder_SelectBuilder();
        $select->select->addAll(Gpf_Db_Table_AuthUsers::getInstance(), 'au');
        $select->select->addAll(Gpf_Db_Table_Accounts::getInstance(), 'a');
        $select->select->addAll(Gpf_Db_Table_Users::getInstance(), 'gu');
        $select->select->addAll(Pap_Db_Table_Users::getInstance(), 'u');
        $select->from->add(Pap_Db_Table_Users::getName(), 'u');
        $select->from->addInnerJoin(Gpf_Db_Table_Users::getName(), 'gu', 'u.'.Pap_Db_Table_Users::ACCOUNTUSERID.'=gu.'.Gpf_Db_Table_Users::ID.
        ' AND u.'.Pap_Db_Table_Users::DELETED . ' = \'' . Gpf::NO . '\''.
        ' AND u.' .Pap_Db_Table_Users::TYPE . ' = \'' . Pap_Application::ROLETYPE_MERCHANT . '\'');
        $select->from->addInnerJoin(Gpf_Db_Table_AuthUsers::getName(), 'au', 'au.'.Gpf_Db_Table_AuthUsers::ID.'=gu.'.Gpf_Db_Table_Users::AUTHID);
        $select->from->addInnerJoin(Gpf_Db_Table_Accounts::getName(), 'a', 'a.'.Gpf_Db_Table_Accounts::ID.'=gu.'.Gpf_Db_Table_Users::ACCOUNTID);
        $select->limit->set($from, Pap_Mail_MassMailAffiliatesGrid::MAX_ROWS_PER_SQL);

        return $select->getAllRows();
    }
Example #5
0
 function init()
 {
     $this->setTable(Gpf_Db_Table_Accounts::getInstance());
     parent::init();
 }
Example #6
0
 /**
  *
  * @param $username
  * @param $password
  * @param $accountId
  * @param $rememberMe
  * @return Gpf_Rpc_Form
  */
 public function authenticateNoRpc($username = '', $password = '', $accountId = '', $rememberMe = Gpf::NO, $language = '', $roleType = '', $authToken = '')
 {
     if ($language == '') {
         $language = Gpf_Lang_Dictionary::getDefaultLanguage();
     }
     $loginForm = $this->createResponseForm();
     $loginForm->setField(self::USERNAME, $username);
     $loginForm->setField(self::PASSWORD, $password);
     $loginForm->setField(self::ACCOUNTID, $accountId);
     $loginForm->setField(self::REMEMBER_ME, $rememberMe);
     $loginForm->setField(self::LANGUAGE, $language);
     try {
         $authInfo = Gpf_Auth_Info::create($loginForm->getFieldValue(self::USERNAME), $loginForm->getFieldValue(self::PASSWORD), $accountId, $roleType, $authToken);
         if ($authInfo->hasAccount()) {
             return $this->authenticateUser($loginForm, $authInfo);
         }
         $accounts = Gpf_Db_Table_Accounts::getAccounts($authInfo);
         if ($accounts->getSize() == 0) {
             Gpf_Log::info($this->_sys("Wrong username/password (Username: %s)", $username));
             $loginForm->setErrorMessage($this->_("Wrong username/password"));
         } else {
             if ($accounts->getSize() == 1) {
                 $authInfo->setAccount($accounts->getRecord(0)->get('accountid'));
                 return $this->authenticateUser($loginForm, $authInfo);
             } else {
                 if ($accounts->getSize() > 1) {
                     $loginForm->setField(self::ACCOUNTID, "select_account", $accounts->toObject());
                     $loginForm->setInfoMessage($this->_("Select account"));
                 }
             }
         }
     } catch (Gpf_Auth_Exception $e) {
         $loginForm->setErrorMessage($e->getMessage());
     } catch (Gpf_DbEngine_NoRowException $e) {
         Gpf_Log::info($this->_sys("Wrong username/password (Username: %s)", $username));
         $loginForm->setErrorMessage($this->_("Wrong username/password"));
     } catch (Exception $e) {
         if (strlen($username)) {
             Gpf_Log::info($this->_sys("Authentication failed for user %s", $username));
         }
         $loginForm->setErrorMessage($this->_("Authentication failed"));
     }
     return $loginForm;
 }