当前位置: 首页>>代码示例>>PHP>>正文


PHP Core::setUser方法代码示例

本文整理汇总了PHP中Core::setUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Core::setUser方法的具体用法?PHP Core::setUser怎么用?PHP Core::setUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Core的用法示例。


在下文中一共展示了Core::setUser方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onAuthorize

 /**
  * (non-PHPdoc)
  * @see TAuthManager::onAuthorize()
  */
 public function onAuthorize($param)
 {
     $application = $this->getApplication();
     //if this is a call back function and its session timed out/invalid, then redirect the page to homepage
     if ($this->getRequest()->contains(TPage::FIELD_CALLBACK_TARGET) && !$application->getAuthorizationRules()->isUserAllowed($application->getUser(), $application->getRequest()->getRequestType(), $application->getRequest()->getUserHostAddress())) {
         // Create a callback adapter which counstructor will set up TCallbackReponseAdapter in the HttpResponse class adapter property
         $callbackAdapter = new TActivePageAdapter(new TPage());
         // Redirect (now the adapter is not null)
         $this->Response->redirect('/');
         // Create a html writer
         $writer = $this->Response->createHtmlWriter();
         // Render the response
         $callbackAdapter->renderCallbackResponse($writer);
         //Flush the output
         $application->flushOutput();
         //exit application do not process the futher part
         exit;
     }
     parent::onAuthorize($param);
     $u = Core::getUser();
     if ($u instanceof UserAccount) {
         $r = Core::getRole();
         Core::setUser($u, $r);
     }
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:29,代码来源:AuthManager.php

示例2: _getResponse

 /**
  * getting the response
  * 
  * @param UDate $time
  * 
  * @return SimpleXMLElement
  */
 protected function _getResponse(UDate $time)
 {
     Core::setUser(UserAccount::get(UserAccount::ID_SYSTEM_ACCOUNT));
     //TODO
     $response = new SimpleXMLElement('<Response />');
     $response->addAttribute('Time', trim($time));
     $response->addAttribute('TimeZone', trim($time->getTimeZone()->getName()));
     return $response;
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:16,代码来源:APIClassAbstract.php

示例3: __construct

 /**
  * constructor
  */
 public function __construct()
 {
     parent::__construct();
     if (!Core::getUser() instanceof UserAccount && get_class($this) !== 'LoginController') {
         if (isset($_REQUEST['user']) && isset($_REQUEST['pass']) && in_array(get_class($this), array('OrderPrintController', 'POPrintController')) && ($userAccount = UserAccount::getUserByUsernameAndPassword(trim($_REQUEST['user']), trim($_REQUEST['pass']), true)) instanceof UserAccount) {
             Core::setUser($userAccount);
         } else {
             $this->getResponse()->Redirect('/login.html');
         }
     }
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:14,代码来源:BPCPageAbstract.php

示例4: _login

 /**
  * login a user
  *
  * @param array $params
  *
  * @throws Exception
  * @return multitype:
  */
 private function _login($params)
 {
     if (!isset($params['username']) || ($username = trim($params['username'])) === '') {
         throw new Exception('username is empty!');
     }
     if (!isset($params['password']) || ($password = trim($params['password'])) === '') {
         throw new Exception('password is empty!');
     }
     $userAccount = UserAccount::getUserByUsernameAndPassword($username, $password, true);
     $role = null;
     if (count($roles = $userAccount->getRoles()) > 0) {
         $role = $roles[0];
     }
     Core::setUser($userAccount, $role);
     return array();
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:24,代码来源:APIUserAccountService.php

示例5: validateUser

 /**
  * validate a user providing $username and $password
  *
  * @param string $username
  * @param string $password
  * @return true, if there is such a userAccount in the database;otherwise, false;
  */
 public function validateUser($username, $password)
 {
     if (!Core::getUser() instanceof UserAccount) {
         $userAccount = UserAccount::getUserByUsernameAndPassword($username, $password);
         if (!$userAccount instanceof UserAccount) {
             return false;
         }
         $role = null;
         if (!Core::getRole() instanceof Role) {
             if (count($roles = $userAccount->getRoles()) > 0) {
                 $role = $roles[0];
             }
         }
         Core::setUser($userAccount, $role);
     }
     return true;
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:24,代码来源:WebUserManager.php

示例6: _setRunningUser

 private static function _setRunningUser($preFix = '', $debug = false)
 {
     self::_log('== Set Running User : ', '', $preFix);
     Core::setUser(UserAccount::get(UserAccount::ID_SYSTEM_ACCOUNT));
     self::_log('UserAccount(ID=' . Core::getUser()->getId() . ')', '', $preFix . self::TAB);
     if (!isset(self::$_api['URL']) || ($apiUrl = trim(self::$_api['URL'])) === '') {
         throw new Exception('No API URL set!');
     }
     if (!isset(self::$_api['token']) || ($token = trim(self::$_api['token'])) === '') {
         self::_log('!! no token yet, need to get token.', '', $preFix . self::TAB);
         $url = $apiUrl . 'UserAccount/login';
         $data = json_encode(array('username' => Core::getUser()->getUserName(), 'password' => Core::getUser()->getPassword()));
         self::_postJson($url, $data, $preFix . self::TAB, $debug);
         if (trim(self::$_api['token']) === '') {
             throw new Exception('Invalid token');
         }
     }
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:18,代码来源:DataFeedImporter.php

示例7: changePersonInfo

 public function changePersonInfo($sender, $param)
 {
     $results = $errors = array();
     try {
         if (!isset($param->CallbackParameter->firstName) || ($firstName = trim($param->CallbackParameter->firstName)) === '') {
             throw new Exception("Invalid firstName!");
         }
         if (!isset($param->CallbackParameter->lastName) || ($lastName = trim($param->CallbackParameter->lastName)) === '') {
             throw new Exception("Invalid lastName!");
         }
         Core::getUser()->getPerson()->setFirstName($firstName)->setLastName($lastName)->save();
         Core::setUser(UserAccount::get(Core::getUser()->getId()), Core::getRole());
         $results['succ'] = true;
     } catch (Exception $ex) {
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:18,代码来源:MeController.php

示例8: run

 /**
  * runner
  * @param string $debug
  */
 public static function run($debug = false)
 {
     try {
         self::$_debug = $debug;
         Dao::beginTransaction();
         Core::setUser(UserAccount::get(UserAccount::ID_SYSTEM_ACCOUNT));
         $start = self::_debug("Start to run " . __CLASS__ . ' =================== ');
         $assetIds = self::_findAllOverdueAssets();
         $assetIds = array_merge($assetIds, self::_findAllZombieAssets());
         self::_deleteAssets($assetIds);
         self::_debug("Finished to run " . __CLASS__ . ' =================== ', self::NEW_LINE, "", $start);
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         self::_debug("***** ERROR: " . $ex->getMessage());
         self::_debug($ex->getTraceAsString());
     }
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:22,代码来源:AssetCleaner.php

示例9: run

 /**
  * The runner
  *
  * @param string $preFix
  * @param string $debug
  */
 public static function run($outputFileDir, $preFix = '', $debug = false)
 {
     $start = self::_log('## START ##############################', __CLASS__ . '::' . __FUNCTION__, $preFix);
     self::$_outputFileDir = trim($outputFileDir);
     self::_log('GEN FILE TO: ' . self::$_outputFileDir, '', $preFix . self::TAB);
     self::$_imageDirName = self::$_imageDirName . '_' . UDate::now()->format('Y_m_d_H_i_s');
     Core::setUser(UserAccount::get(UserAccount::ID_SYSTEM_ACCOUNT));
     $now = UDate::now();
     $settings = self::_getSettings($preFix . self::TAB, $debug);
     $lastUpdatedTime = UDate::zeroDate();
     if (isset($settings['lastUpdatedTime']) && trim($settings['lastUpdatedTime']) !== '') {
         $lastUpdatedTime = new UDate(trim($settings['lastUpdatedTime']));
     }
     self::_log('GOT LAST SYNC TIME: ' . trim($lastUpdatedTime), '', $preFix);
     $products = self::_getData($lastUpdatedTime, $preFix . self::TAB, $debug);
     if (count($products) > 0) {
         $files = self::_genCSV($lastUpdatedTime, array_values($products), $preFix . self::TAB, $debug);
         self::_zipFile($files, $preFix, $debug);
         self::_setSettings('lastUpdatedTime', trim($now), $preFix, $debug);
     } else {
         self::_log('NO changed products found after: "' . trim($lastUpdatedTime) . '".', '', $preFix);
     }
     self::_log('## FINISH ##############################', __CLASS__ . '::' . __FUNCTION__, $preFix, $start);
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:30,代码来源:ProductToMagento.php

示例10: dirname

<?php

require_once dirname(__FILE__) . '/../../bootstrap.php';
Core::setUser(UserAccount::get(UserAccount::ID_SYSTEM_ACCOUNT));
$productIds = Dao::getResultsNative('select distinct id from product where active = 1', array(), PDO::FETCH_ASSOC);
foreach ($productIds as $row) {
    try {
        $output = '';
        $cmd = 'php ' . dirname(__FILE__) . '/pricematch.php ' . $row['id'];
        $output = ExecWaitTimeout($cmd, 10);
        // 	exec($cmd, $output);
        echo print_r($output, true) . "\n";
    } catch (Exception $e) {
        echo $e->getMessage() . "\n";
    }
}
/**
 * Execute a command and kill it if the timeout limit fired to prevent long php execution
 * 
 * @see http://stackoverflow.com/questions/2603912/php-set-timeout-for-script-with-system-call-set-time-limit-not-working
 * 
 * @param string $cmd Command to exec (you should use 2>&1 at the end to pipe all output)
 * @param integer $timeout
 * @return string Returns command output 
 */
function ExecWaitTimeout($cmd, $timeout = 5)
{
    echo $cmd . "\n";
    $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
    $pipes = array();
    $timeout += time();
开发者ID:larryu,项目名称:magento-b2b,代码行数:31,代码来源:pricematchAllRunner.php

示例11: _validateToken

 /**
  * validates the token
  *
  * @param unknown $token
  * @param bool    $showHeader
  *
  * @throws Exception
  * @return APIService
  */
 private function _validateToken($token, $showHeader = false)
 {
     if ($showHeader) {
         header("WWW-Authenticate: Basic realm=\"" . $this->_realm . "\"");
     }
     if (($token = trim($token)) === '') {
         throw new Exception('Invalid access, please login first!', 401);
     }
     $key = $this->_getTokenKey();
     $ciphertext_dec = base64_decode($token);
     $iv_size = $this->_getTokenVISize();
     $iv_dec = substr($ciphertext_dec, 0, $iv_size);
     $ciphertext_dec = substr($ciphertext_dec, $iv_size);
     $plaintext_dec = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $ciphertext_dec, MCRYPT_MODE_CBC, $iv_dec);
     $this->log('decrypted token: "' . $plaintext_dec . '"', __CLASS__ . '::' . __FUNCTION__, '## ');
     $information = explode('|', $plaintext_dec);
     $this->log('got information: "' . preg_replace("/[\n\r]/", " ", print_r($information, true)), __CLASS__ . '::' . __FUNCTION__, self::TAB);
     if (!isset($information[1]) || preg_match('/^\\d{4}-\\d{2}-\\d{2}\\ \\d{2}:\\d{2}:\\d{2}$/', $fromDate = trim($information[1])) !== 1) {
         $this->log('invalid fromDate!', '', self::TAB);
         throw new Exception('Invalid token, please login first!');
     }
     $fromDate = new UDate($fromDate);
     $this->log('Got fromDate: ' . $fromDate, '', self::TAB);
     if (!isset($information[2]) || preg_match('/^\\d{4}-\\d{2}-\\d{2}\\ \\d{2}:\\d{2}:\\d{2}$/', $toDate = trim($information[2])) !== 1) {
         $this->log('invalid toDate!', '', self::TAB);
         throw new Exception('Invalid token, please login first!!');
     }
     $toDate = new UDate($toDate);
     $this->log('Got toDate: ' . $toDate, '', self::TAB);
     $now = UDate::now();
     $this->log('Got NOW: ' . $now, '', self::TAB);
     if ($now->after($toDate) || $now->before($fromDate)) {
         $this->log('Token expired.', '', self::TAB);
         throw new Exception('Token expired.');
     }
     if (!isset($information[0]) || !($userAccount = UserAccount::get(trim($information[0]))) instanceof UserAccount) {
         $this->log('Invalid useraccount.', '', self::TAB);
         throw new Exception('Invalid token, please login first.');
     }
     $role = null;
     if (count($roles = $userAccount->getRoles()) > 0) {
         $role = $roles[0];
     }
     $this->log('Got User: ' . $userAccount->getId(), '', self::TAB);
     Core::setUser($userAccount, $role);
     return $this;
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:56,代码来源:APIService.php

示例12: unserialize

 /**
  * unserialize all the components and store them in Core
  * 
  * @param string $string The serialized core storage string
  */
 public static function unserialize($string)
 {
     self::$_storage = unserialize($string);
     Core::setUser(self::$_storage['user'], self::$_storage['role']);
     return self::$_storage;
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:11,代码来源:Core.php

示例13: getCategory

 /**
  * get category info by magento-b2b productCategory id
  *
  * @param string $systemid
  *
  * @return string
  * @soapmethod
  */
 public function getCategory($systemid)
 {
     $response = $this->_getResponse(UDate::now());
     try {
         $systemid = intval(trim($systemid));
         Core::setUser(UserAccount::get(UserAccount::ID_SYSTEM_ACCOUNT));
         //TODO
         $obj = ProductCategory::get($systemid);
         if (!$obj instanceof ProductCategory) {
             throw new Exception('category with system id "' . $systemid . '" does not exist.');
         }
         $response['status'] = self::RESULT_CODE_SUCC;
         $this->addCData('category', json_encode($obj->getJson()), $response);
     } catch (Exception $e) {
         $response['status'] = self::RESULT_CODE_FAIL;
         $this->addCData('error', $e->getMessage(), $response);
     }
     return trim($response->asXML());
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:27,代码来源:APIProduct.php

示例14: write

 /**
  * Writting the Session Data
  *
  * @param string $sessionId   The sesison ID
  * @param string $sessionData The sesison data
  *
  * @return Session|null
  */
 public static function write($sessionId, $sessionData)
 {
     $user = ($user = Core::getUser()) instanceof UserAccount ? $user : UserAccount::get(UserAccount::ID_SYSTEM_ACCOUNT);
     Core::setUser($user, Core::getRole());
     $session = ($session = self::getSession($sessionId)) instanceof Session ? $session : new Session();
     return $session->setKey($sessionId)->setData($sessionData)->save();
 }
开发者ID:larryu,项目名称:magento-b2b,代码行数:15,代码来源:Session.php


注:本文中的Core::setUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。