本文整理汇总了PHP中Gpf_Session::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Gpf_Session::getInstance方法的具体用法?PHP Gpf_Session::getInstance怎么用?PHP Gpf_Session::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gpf_Session
的用法示例。
在下文中一共展示了Gpf_Session::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($filterArray = NULL)
{
$this->initOperators();
if ($filterArray != NULL) {
$this->code = $filterArray[self::FILTER_CODE];
$this->operator = $this->getOperator($filterArray[self::FILTER_OPERATOR]);
$this->value = trim($filterArray[self::FILTER_VALUE]);
$this->timeOffset = Gpf_Session::getInstance()->getTimeOffset();
}
}
示例2: regenerateLanguageCacheFiles
public function regenerateLanguageCacheFiles()
{
//load langage
$dbLang = new Gpf_Db_Language();
$dbLang->setAccountId(Gpf_Session::getInstance()->getAuthUser()->getAccountId());
$dbLang->setCode($this->languageCode);
$dbLang->setId($dbLang->generateId());
$dbLang->load();
$lang = new Gpf_Lang_CsvLanguage();
$lang->loadFromCsvFile(new Gpf_Io_Csv_Reader(Gpf_Lang_CsvLanguage::getAccountCsvFileName($this->languageCode)));
$lang->exportAccountCache();
}
示例3: __construct
/**
* @param $request
* @param $groupId
* @param $validTo
* @return string
*/
public function __construct(Gpf_Rpc_Request $request, Gpf_DateTime $validTo = null)
{
parent::__construct();
$json = new Gpf_Rpc_Json();
if ($validTo === null) {
$validTo = new Gpf_DateTime();
$validTo->addDay(30);
}
$this->setAccountId(Gpf_Session::getInstance()->getAuthUser()->getAccountId());
$this->setGroupId('');
$this->setRequest($json->encode($request->toObject()));
$this->setValidTo($validTo->toDateTime());
$this->insert();
return $this;
}
示例4: createSelectBuilder
/**
* @return Gpf_SqlBuilder_SelectBuilder
*/
protected function createSelectBuilder() {
$selectBuilder = new Gpf_SqlBuilder_SelectBuilder();
$selectBuilder->select->add(Gpf_Db_Table_Roles::ID, self::ID);
$selectBuilder->select->add(Gpf_Db_Table_Roles::NAME, self::VALUE);
$selectBuilder->from->add(Gpf_Db_Table_Roles::getName());
$accountCondition = new Gpf_SqlBuilder_CompoundWhereCondition();
if (Gpf_Session::getAuthUser()->hasPrivilege(Gpf_Privileges::ROLE, Gpf_Privileges::P_READ) ||
Gpf_Session::getAuthUser()->hasPrivilege(Pap_Privileges::ROLE_NAME, Pap_Privileges::P_READ)) {
$accountCondition->add(Gpf_Db_Table_Accounts::ID, '!=', '', 'OR');
} else {
$accountCondition->add(Gpf_Db_Table_Accounts::ID, '=', Gpf_Session::getInstance()->getAuthUser()->getAccountId(), 'OR');
}
$accountCondition->add(Gpf_Db_Table_Accounts::ID, '=', null, 'OR');
$selectBuilder->where->addCondition($accountCondition);
$selectBuilder->where->add(Gpf_Db_Table_Roles::TYPE, '=', Pap_Application::ROLETYPE_MERCHANT);
$selectBuilder->orderBy->add(Gpf_Db_Table_Accounts::ID);
$selectBuilder->orderBy->add(Gpf_Db_Table_Roles::NAME);
return $selectBuilder;
}
示例5: add
/**
* @service role add
* @return Gpf_Rpc_Form
*/
public function add(Gpf_Rpc_Params $params)
{
$form = new Gpf_Rpc_Form($params);
$origRole = new Gpf_Db_Role();
$origRole->setId($form->getFieldValue('roleid'));
$origRole->load();
$newRole = new Gpf_Db_Role();
$newRole->setName($form->getFieldValue('name'));
$newRole->setAccountId(Gpf_Session::getInstance()->getAuthUser()->getAccountId());
$newRole->setRoleType($origRole->getRoleType());
$newRole->insert();
if (strlen($origRole->getAccountId())) {
//it is custom role, copy privileges from db
$select = new Gpf_SqlBuilder_SelectBuilder();
$select->select->addConstant($newRole->getId(), 'roleid');
$select->select->add(Gpf_Db_Table_RolePrivileges::OBJECT, Gpf_Db_Table_RolePrivileges::OBJECT);
$select->select->add(Gpf_Db_Table_RolePrivileges::PRIVILEGE, Gpf_Db_Table_RolePrivileges::PRIVILEGE);
$select->from->add(Gpf_Db_Table_RolePrivileges::getName());
$select->where->add(Gpf_Db_Table_Roles::ID, '=', $origRole->getId());
$insert = new Gpf_SqlBuilder_InsertBuilder();
$insert->setTable(Gpf_Db_Table_RolePrivileges::getInstance());
$insert->fromSelect($select);
$insert->execute();
} else {
//it is default role, copy privileges from php settings
$privileges = Gpf_Application::getInstance()->getRoleDefaultPrivileges($origRole->getId());
foreach ($privileges as $objectName => $privilegeList) {
foreach ($privilegeList as $right) {
$privilege = new Gpf_Db_RolePrivilege();
$privilege->setRoleId($newRole->getId());
$privilege->setObject($objectName);
$privilege->setPrivilege($right);
$privilege->insert();
}
}
}
return $form;
}
示例6: getRolesList
/**
* Get list of roles
*
* @service
* @anonym
* @param Gpf_Rpc_Params $parmas
*/
public function getRolesList(Gpf_Rpc_Params $params)
{
if (!Gpf_Session::getAuthUser()->hasPrivilege(Gpf_Privileges::ROLE, Gpf_Privileges::P_READ) && !Gpf_Session::getAuthUser()->hasPrivilege(Gpf_Privileges::ROLE, Pap_Privileges::P_READ_OWN)) {
throw new Gpf_Rpc_PermissionDeniedException('Gpf_Db_Table_Roles', 'getRolesList');
}
$sql = new Gpf_SqlBuilder_SelectBuilder();
$sql->from->add(Gpf_Db_Table_Roles::getName());
$sql->select->addAll(Gpf_Db_Table_Roles::getInstance());
$accountCondition = new Gpf_SqlBuilder_CompoundWhereCondition();
if (Gpf_Session::getAuthUser()->hasPrivilege(Gpf_Privileges::ROLE, Gpf_Privileges::P_READ)) {
$accountCondition->add(Gpf_Db_Table_Accounts::ID, '!=', '', 'OR');
} else {
$accountCondition->add(Gpf_Db_Table_Accounts::ID, '=', Gpf_Session::getInstance()->getAuthUser()->getAccountId(), 'OR');
}
$accountCondition->add(Gpf_Db_Table_Accounts::ID, '=', null, 'OR');
$sql->where->addCondition($accountCondition);
if ($params->exists('roleTypes') && $params->get('roleTypes') !== '') {
$sql->where->add(Gpf_Db_Table_Roles::TYPE, 'IN', explode(',', $params->get('roleTypes')));
}
$sql->orderBy->add(Gpf_Db_Table_Accounts::ID);
$sql->orderBy->add(Gpf_Db_Table_Roles::NAME);
return $sql->getAllRows();
}
示例7: executeTask
public function executeTask()
{
$quickTaskId = $_GET['quicktask'];
if (!$this->existQuickTask($quickTaskId)) {
$this->output($this->_('Task does not exist!'));
return;
}
$quickTask = $this->getQuickTask($quickTaskId);
if (!$quickTask->isValid()) {
$this->output($this->_('Task is not valid!'));
return;
}
$authUser = Gpf::newObj(Gpf_Application::getInstance()->getAuthClass());
Gpf_Session::getInstance()->save($authUser->createPrivilegedUser());
try {
$method = new Gpf_Tasks_QuickTaskRunner_ServiceMethod($quickTask->getRequest());
$response = $method->execute();
} catch (Gpf_Exception $e) {
$this->output($e->getMessage());
return;
}
$this->output($response->toText());
Gpf_Db_Table_QuickTasks::getInstance()->removeTasksAfterExecute($quickTask);
}
示例8: getPrivateCampaignsSqlBuilder
/**
* Create private campaigns select builder
* @return Gpf_SqlBuilder_SelectBuilder
*/
private function getPrivateCampaignsSqlBuilder() {
$sqlPrivateCampaigns = new Gpf_SqlBuilder_SelectBuilder();
$sqlPrivateCampaigns->select->add('cg.campaignid');
$sqlPrivateCampaigns->from->add(Pap_Db_Table_CommissionGroups::getName(), 'cg');
$sqlPrivateCampaigns->from->addInnerJoin(Pap_Db_Table_UserInCommissionGroup::getName(), 'uicg',
"cg.commissiongroupid = uicg.commissiongroupid AND uicg.userid='" . Gpf_Session::getInstance()->getAuthUser()->getPapUserId() . "'");
$sqlPrivateCampaigns->where->add('uicg.' . Pap_Db_Table_UserInCommissionGroup::STATUS, '=', Pap_Features_PerformanceRewards_Condition::STATUS_APPROVED, 'OR');
$sqlPrivateCampaigns->where->add('uicg.' . Pap_Db_Table_UserInCommissionGroup::STATUS, '=', Pap_Features_PerformanceRewards_Condition::STATUS_FIXED, 'OR');
return $sqlPrivateCampaigns;
}
示例9: create
/**
*
* @param Gpf_Install_Manager $instance
* @return Gpf_Install_Manager
*/
public static function create(Gpf_Install_Manager $instance)
{
Gpf_Session::getInstance()->setVar(Gpf_Paths::INSTALLER, $instance);
return self::$instance = $instance;
}
示例10: clearCache
public function clearCache(){
$this->cacheArray = array();
Gpf_Session::getInstance()->setVar('cacheArray',$this->cacheArray);
}
示例11: getUrl
/**
* Return download url to file
*
* @param string $serverClass Server class name, which will handle download function
* @return string
*/
public function getUrl($serverClass = 'Gpf_File_Download')
{
return Gpf_Paths::getInstance()->getBaseServerUrl() . 'scripts/server.php' . '?C=' . $serverClass . '&M=download&S=' . Gpf_Session::getInstance()->getId() . '&FormRequest=Y&FormResponse=Y&fileid=' . $this->getFileId() . '&attachment=Y';
}
示例12: loadNoRpc
/**
* Load default username and password in login form
*
* @return Gpf_Rpc_Form
*/
public function loadNoRpc()
{
$form = new Gpf_Rpc_Form(new Gpf_Rpc_Params());
$form->setField(self::REMEMBER_ME, Gpf::YES);
if (Gpf_Application::isDemo()) {
$form->setField(self::USERNAME, Gpf_Session::getInstance()->getModule()->getDemoUsername());
$form->setField(self::PASSWORD, Gpf_Session::getInstance()->getModule()->getDemoPassword());
}
$langage = Gpf_Http::getCookie(self::COOKIE_LANGUAGE);
$form->setField(self::LANGUAGE, $langage, $this->setDefaultLanguage(Gpf_Lang_Languages::getInstance()->getActiveLanguagesNoRpc())->toObject());
return $form;
}
示例13: getDefaultLanguage
/**
* Load default language for this account
*
* @return Gpf_Db_Language
*/
public function getDefaultLanguage()
{
if ($this->defaultLanguage == null) {
$this->defaultLanguage = new Gpf_Db_Language();
$this->defaultLanguage->setIsDefault(true);
$this->defaultLanguage->setAccountId(Gpf_Session::getInstance()->getAuthUser()->getAccountId());
$this->defaultLanguage->loadFromData(array(Gpf_Db_Table_Accounts::ID, self::IS_DEFAULT));
}
return $this->defaultLanguage;
}
示例14: getTimeZoneOffset
/**
* @return time zone offset in format +/-HH:MM
*/
public static function getTimeZoneOffset()
{
$timeOffset = Gpf_Session::getInstance()->getTimeOffset();
$hours = self::addLeadingZero(floor(abs($timeOffset) / 3600));
$minutes = self::addLeadingZero(floor(abs($timeOffset) % 3600 / 60));
return $timeOffset < 0 ? '-' : '+' . $hours . ':' . $minutes;
}
示例15: syncTime
/**
* Set time offset between client and server and store it to session
* Offset is computed as client time - server time
*
* @anonym
* @service
* @param Gpf_Rpc_Params $params
* @return Gpf_Rpc_Action
*/
public function syncTime(Gpf_Rpc_Params $params)
{
$action = new Gpf_Rpc_Action($params);
Gpf_Session::getInstance()->setTimeOffset($action->getParam('offset') / 1000);
$action->addOk();
return $action;
}