本文整理汇总了PHP中eZBasket类的典型用法代码示例。如果您正苦于以下问题:PHP eZBasket类的具体用法?PHP eZBasket怎么用?PHP eZBasket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZBasket类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: fetchBasket
function fetchBasket()
{
$http = eZHTTPTool::instance();
$sessionID = $http->sessionID();
$basketList = eZPersistentObject::fetchObjectList(eZBasket::definition(), null, array("session_id" => $sessionID), null, null, true);
$currentBasket = false;
if (count($basketList) == 0) {
// If we don't have a stored basket we create a temporary
// one which can be returned.
$collection = eZProductCollection::create();
$currentBasket = new eZBasket(array("session_id" => $sessionID, "productcollection_id" => 0));
} else {
$currentBasket = $basketList[0];
}
if ($currentBasket === null) {
$result = array('error' => array('error_type' => 'kernel', 'error_code' => eZError::KERNEL_NOT_FOUND));
} else {
$result = array('result' => $currentBasket);
}
return $result;
}
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:21,代码来源:ezshopfunctioncollection.php
示例2: logoutCurrent
static function logoutCurrent()
{
$http = eZHTTPTool::instance();
$id = false;
$GLOBALS["eZUserGlobalInstance_{$id}"] = false;
$contentObjectID = $http->sessionVariable('eZUserLoggedInID');
// reset session data
$newUserID = self::anonymousId();
eZSession::setUserID($newUserID);
$http->setSessionVariable('eZUserLoggedInID', $newUserID);
// Clear current basket if necessary
$db = eZDB::instance();
$db->begin();
eZBasket::cleanupCurrentBasket();
$db->commit();
if ($contentObjectID) {
//set last visit to minus
self::updateLastVisitByLogout($contentObjectID);
//clean up sessions
self::cleanup();
}
// give user new session id
eZSession::regenerate();
// set the property used to prevent SSO from running again
self::$userHasLoggedOut = true;
}
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:26,代码来源:ezuser.php
示例3: cleanupCurrentBasket
static function cleanupCurrentBasket($useSetting = true)
{
$ini = eZINI::instance();
$removeBasket = true;
if ($useSetting) {
$removeBasket = $ini->hasVariable('ShopSettings', 'ClearBasketOnLogout') ? $ini->variable('ShopSettings', 'ClearBasketOnLogout') == 'enabled' : false;
}
if ($removeBasket) {
$basket = eZBasket::currentBasket();
if (!is_object($basket)) {
return false;
}
$db = eZDB::instance();
$db->begin();
$productCollectionID = $basket->attribute('productcollection_id');
eZProductCollection::cleanupList(array($productCollectionID));
$basket->remove();
$db->commit();
}
return true;
}
开发者ID:rmiguel,项目名称:ezpublish,代码行数:21,代码来源:ezbasket.php
示例4:
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of version 2.0 of the GNU General
// Public License along with this program; if not, write to the Free
// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
// MA 02110-1301, USA.
//
//
// ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
//
$http = eZHTTPTool::instance();
$basket = eZBasket::currentBasket();
$module = $Params['Module'];
$quantity = (int) $module->NamedParameters["Quantity"];
if (!is_numeric($quantity) or $quantity <= 0) {
$quantity = 1;
}
// Verify the ObjectID input
if (!is_numeric($ObjectID)) {
return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
// Check if the object exists on disc
if (!eZContentObject::exists($ObjectID)) {
return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
// Check if the user can read the object
$object = eZContentObject::fetch($ObjectID);
开发者ID:runelangseid,项目名称:ezpublish,代码行数:31,代码来源:add.php
示例5:
{
$cli->output( "Removing all recent items and bookmarks for browse page" );
eZContentBrowseRecent::cleanup();
eZContentBrowseBookmark::cleanup();
}
if ( $clean['tipafriend'] )
{
$cli->output( "Removing all counters for tip-a-friend" );
eZTipafriendCounter::cleanup();
}
if ( $clean['shop'] )
{
$cli->output( "Removing all baskets" );
eZBasket::cleanup();
$cli->output( "Removing all wishlists" );
eZWishList::cleanup();
$cli->output( "Removing all orders" );
eZOrder::cleanup();
$productCount = eZPersistentObject::count( eZProductCollection::definition() );
if ( $productCount > 0 )
{
$cli->warning( "$productCount product collections still exists, must be a leak" );
}
}
if ( $clean['forgotpassword'] )
{
$cli->output( "Removing all forgot password requests" );
eZForgotPassword::cleanup();
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:31,代码来源:cleanup.php
示例6: setCookie
public static function setCookie()
{
$ini = eZINI::instance('scachecookie.ini');
$siteIni = eZINI::instance('site.ini');
$hasUserData = false;
$displayedData = $ini->variable('CacheCookieSettings', 'DisplayedData');
$cookieValue = $ini->variable('CacheCookieSettings', 'CookieValue') || 'true';
if ($cookieValue === true) {
$cookieValue = 'true';
}
$useDetailedValue = $ini->variable('CacheCookieSettings', 'DetailedCookieValue') == 'enabled';
$detailedValue = '';
if (in_array('basket', $displayedData)) {
$http = eZHTTPTool::instance();
$sessionID = $http->sessionID();
$basket = eZBasket::fetch($sessionID);
if ($basket) {
if (!$basket->isEmpty()) {
$hasUserData = true;
if ($useDetailedValue) {
$detailedValue .= ',basket';
}
}
}
}
if ((!$hasUserData || $useDetailedValue) && in_array('wishlist', $displayedData)) {
$user = eZUser::currentUser();
$userID = $user->attribute('contentobject_id');
$WishListArray = eZPersistentObject::fetchObjectList(eZWishList::definition(), null, array("user_id" => $userID), null, null, true);
if (count($WishListArray) > 0) {
if ($WishListArray[0]->itemCount() > 0) {
$hasUserData = true;
if ($useDetailedValue) {
$detailedValue .= ',wishlist';
}
}
}
}
if (!$hasUserData || $useDetailedValue) {
$prefs = eZPreferences::values();
$hasPrefs = false;
foreach ($prefs as $key => $val) {
if ($key != '') {
if (in_array('preferences', $displayedData) || in_array($key, $displayedData)) {
if ($val != '') {
$hasUserData = true;
if ($useDetailedValue) {
if (in_array('preferences', $displayedData) && !$hasPrefs) {
$detailedValue .= ',preferences';
}
if (in_array($key, $displayedData)) {
$detailedValue .= ",{$key}:{$val}";
}
}
$hasPrefs = true;
}
}
}
}
}
$value = $hasUserData ? $cookieValue . $detailedValue : false;
$wwwDir = eZSys::wwwDir();
$cookiePath = $wwwDir != '' ? $wwwDir : '/';
setcookie($ini->variable('CacheCookieSettings', 'CookieName'), $value, time() + (int) $siteIni->variable('Session', 'SessionTimeout'), $cookiePath);
}
开发者ID:stevoland,项目名称:ez_scachecookie,代码行数:65,代码来源:scachecookiehelper.php
示例7: requestInit
protected function requestInit()
{
if ($this->isInitialized) {
return;
}
eZExecution::setCleanExit(false);
$scriptStartTime = microtime(true);
$GLOBALS['eZRedirection'] = false;
$this->access = eZSiteAccess::current();
eZDebug::setScriptStart($scriptStartTime);
eZDebug::addTimingPoint("Script start");
$this->uri = eZURI::instance(eZSys::requestURI());
$GLOBALS['eZRequestedURI'] = $this->uri;
// Be able to do general events early in process
ezpEvent::getInstance()->notify('request/preinput', array($this->uri));
// Initialize module loading
$this->siteBasics['module-repositories'] = eZModule::activeModuleRepositories();
eZModule::setGlobalPathList($this->siteBasics['module-repositories']);
// make sure we get a new $ini instance now that it has been reset
$ini = eZINI::instance();
// start: eZCheckValidity
// pre check, setup wizard related so needs to be before session/db init
// TODO: Move validity check in the constructor? Setup is not meant to be launched at each (sub)request is it?
if ($ini->variable('SiteAccessSettings', 'CheckValidity') === 'true') {
$this->check = array('module' => 'setup', 'function' => 'init');
// Turn off some features that won't bee needed yet
$this->siteBasics['policy-check-omit-list'][] = 'setup';
$this->siteBasics['show-page-layout'] = $ini->variable('SetupSettings', 'PageLayout');
$this->siteBasics['validity-check-required'] = true;
$this->siteBasics['session-required'] = $this->siteBasics['user-object-required'] = false;
$this->siteBasics['db-required'] = $this->siteBasics['no-cache-adviced'] = $this->siteBasics['url-translator-allowed'] = false;
$this->siteBasics['site-design-override'] = $ini->variable('SetupSettings', 'OverrideSiteDesign');
$this->access = eZSiteAccess::change(array('name' => 'setup', 'type' => eZSiteAccess::TYPE_URI));
eZTranslatorManager::enableDynamicTranslations();
}
// stop: eZCheckValidity
if ($this->siteBasics['session-required']) {
// Check if this should be run in a cronjob
if ($ini->variable('Session', 'BasketCleanup') !== 'cronjob') {
eZSession::addCallback('destroy_pre', function (eZDBInterface $db, $key, $escapedKey) {
$basket = eZBasket::fetch($key);
if ($basket instanceof eZBasket) {
$basket->remove();
}
});
eZSession::addCallback('gc_pre', function (eZDBInterface $db, $time) {
eZBasket::cleanupExpired($time);
});
eZSession::addCallback('cleanup_pre', function (eZDBInterface $db) {
eZBasket::cleanup();
});
}
// addCallBack to update session id for shop basket on session regenerate
eZSession::addCallback('regenerate_post', function (eZDBInterface $db, $escNewKey, $escOldKey) {
$db->query("UPDATE ezbasket SET session_id='{$escNewKey}' WHERE session_id='{$escOldKey}'");
});
// TODO: Session starting should be made only once in the constructor
$this->sessionInit();
}
// if $this->siteBasics['db-required'], open a db connection and check that db is connected
if ($this->siteBasics['db-required'] && !eZDB::instance()->isConnected()) {
$this->warningList[] = array('error' => array('type' => 'kernel', 'number' => eZError::KERNEL_NO_DB_CONNECTION), 'text' => 'No database connection could be made, the system might not behave properly.');
}
// eZCheckUser: pre check, RequireUserLogin & FORCE_LOGIN related so needs to be after session init
if (!isset($this->check)) {
$this->check = eZUserLoginHandler::preCheck($this->siteBasics, $this->uri);
}
ezpEvent::getInstance()->notify('request/input', array($this->uri));
// Initialize with locale settings
// TODO: Move to constructor? Is it relevant to init the locale/charset for each (sub)requests?
$this->languageCode = eZLocale::instance()->httpLocaleCode();
$phpLocale = trim($ini->variable('RegionalSettings', 'SystemLocale'));
if ($phpLocale != '') {
setlocale(LC_ALL, explode(',', $phpLocale));
}
$this->httpCharset = eZTextCodec::httpCharset();
// TODO: are these parameters supposed to vary across potential sub-requests?
$this->site = array('title' => $ini->variable('SiteSettings', 'SiteName'), 'design' => $ini->variable('DesignSettings', 'SiteDesign'), 'http_equiv' => array('Content-Type' => 'text/html; charset=' . $this->httpCharset, 'Content-language' => $this->languageCode));
// Read role settings
$this->siteBasics['policy-check-omit-list'] = array_merge($this->siteBasics['policy-check-omit-list'], $ini->variable('RoleSettings', 'PolicyOmitList'));
$this->isInitialized = true;
}
开发者ID:EVE-Corp-Center,项目名称:ECC-Website,代码行数:82,代码来源:ezpkernelweb.php
示例8: activateOrder
function activateOrder($orderID)
{
$order = eZOrder::fetch($orderID);
$db = eZDB::instance();
$db->begin();
$order->activate();
$basket = eZBasket::currentBasket(true, $orderID);
$basket->remove();
$db->commit();
eZHTTPTool::instance()->setSessionVariable("UserOrderID", $orderID);
return array('status' => eZModuleOperationInfo::STATUS_CONTINUE);
}
开发者ID:runelangseid,项目名称:ezpublish,代码行数:12,代码来源:ezshopoperationcollection.php
示例9: eZSessionBasketEmpty
function eZSessionBasketEmpty($db)
{
eZBasket::cleanup();
}
开发者ID:legende91,项目名称:ez,代码行数:4,代码来源:index.php
示例10: logoutCurrent
static function logoutCurrent()
{
$http = eZHTTPTool::instance();
$id = false;
$GLOBALS["eZUserGlobalInstance_$id"] = false;
$contentObjectID = $http->sessionVariable( 'eZUserLoggedInID' );
// reset session data
$newUserID = self::anonymousId();
eZSession::setUserID( $newUserID );
$http->setSessionVariable( 'eZUserLoggedInID', $newUserID );
// Clear current basket if necessary
$db = eZDB::instance();
$db->begin();
if ( eZINI::instance( 'site.ini' )->variable( 'Session', 'UseBasket' ) != 'false' )
{
eZBasket::cleanupCurrentBasket();
}
$db->commit();
if ( $contentObjectID )
self::cleanup();
// give user new session id
eZSession::regenerate();
// set the property used to prevent SSO from running again
self::$userHasLoggedOut = true;
}
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:30,代码来源:ezuser.php
注:本文中的eZBasket类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论