static function removeUser($userID) { $user = eZUser::fetch($userID); if (!$user) { eZDebug::writeError("unable to find user with ID {$userID}", __METHOD__); return false; } eZUser::removeSessionData($userID); eZSubtreeNotificationRule::removeByUserID($userID); eZCollaborationNotificationRule::removeByUserID($userID); eZUserSetting::removeByUserID($userID); eZUserAccountKey::removeByUserID($userID); eZForgotPassword::removeByUserID($userID); eZWishList::removeByUserID($userID); eZGeneralDigestUserSettings::removeByUserId($userID); eZPersistentObject::removeObject(eZUser::definition(), array('contentobject_id' => $userID)); return true; }
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(); }
static function removeUser($userID) { $user = eZUser::fetch($userID); if (!$user) { eZDebug::writeError("unable to find user with ID {$userID}", __METHOD__); return false; } eZUser::removeSessionData($userID); eZSubtreeNotificationRule::removeByUserID($userID); eZCollaborationNotificationRule::removeByUserID($userID); eZUserSetting::removeByUserID($userID); eZUserAccountKey::removeByUserID($userID); eZForgotPassword::removeByUserID($userID); eZWishList::removeByUserID($userID); // only remove general digest setting if there are no other users with the same e-mail $email = $user->attribute('email'); $usersWithEmailCount = eZPersistentObject::count(eZUser::definition(), array('email' => $email)); if ($usersWithEmailCount == 1) { eZGeneralDigestUserSettings::removeByAddress($email); } eZPersistentObject::removeObject(eZUser::definition(), array('contentobject_id' => $userID)); return true; }
/** * Returns wish list for currently logged in user * * @return array */ function fetchCurrentWishList() { $wishList = eZWishList::currentWishList(); return array( 'result' => $wishList ); }
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); }
/** * Deletes the current object, all versions and translations, and corresponding tree nodes from the database * * Transaction unsafe. If you call several transaction unsafe methods you must enclose * the calls within a db transaction; thus within db->begin and db->commit. */ function purge() { $delID = $this->ID; // Who deletes which content should be logged. eZAudit::writeAudit( 'content-delete', array( 'Object ID' => $delID, 'Content Name' => $this->attribute( 'name' ), 'Comment' => 'Purged the current object: eZContentObject::purge()' ) ); $db = eZDB::instance(); $db->begin(); $attrOffset = 0; $attrLimit = 20; while ( $contentobjectAttributes = $this->allContentObjectAttributes( $delID, true, array( 'limit' => $attrLimit, 'offset' => $attrOffset ) ) ) { foreach ( $contentobjectAttributes as $contentobjectAttribute ) { $dataType = $contentobjectAttribute->dataType(); if ( !$dataType ) continue; $dataType->deleteStoredObjectAttribute( $contentobjectAttribute ); } $attrOffset += $attrLimit; } eZInformationCollection::removeContentObject( $delID ); eZContentObjectTrashNode::purgeForObject( $delID ); $db->query( "DELETE FROM ezcontentobject_tree WHERE contentobject_id='$delID'" ); $db->query( "DELETE FROM ezcontentobject_attribute WHERE contentobject_id='$delID'" ); $db->query( "DELETE FROM ezcontentobject_version WHERE contentobject_id='$delID'" ); $db->query( "DELETE FROM ezcontentobject_name WHERE contentobject_id='$delID'" ); $db->query( "DELETE FROM ezcobj_state_link WHERE contentobject_id=$delID" ); $db->query( "DELETE FROM ezcontentobject WHERE id='$delID'" ); $db->query( "DELETE FROM eznode_assignment WHERE contentobject_id = '$delID'" ); $db->query( "DELETE FROM ezuser_role WHERE contentobject_id = '$delID'" ); $db->query( "DELETE FROM ezuser_discountrule WHERE contentobject_id = '$delID'" ); eZContentObject::fixReverseRelations( $delID, 'remove' ); eZSearch::removeObjectById( $delID ); // Check if deleted object is in basket/wishlist $sql = 'SELECT DISTINCT ezproductcollection_item.productcollection_id FROM ezbasket, ezwishlist, ezproductcollection_item WHERE ( ezproductcollection_item.productcollection_id=ezbasket.productcollection_id OR ezproductcollection_item.productcollection_id=ezwishlist.productcollection_id ) AND ezproductcollection_item.contentobject_id=' . $delID; $rows = $db->arrayQuery( $sql ); if ( count( $rows ) > 0 ) { $countElements = 50; $deletedArray = array(); // Create array of productCollectionID will be removed from ezwishlist and ezproductcollection_item foreach ( $rows as $row ) { $deletedArray[] = $row['productcollection_id']; } // Split $deletedArray into several arrays with $countElements values $splitted = array_chunk( $deletedArray, $countElements ); // Remove eZProductCollectionItem and eZWishList foreach ( $splitted as $value ) { eZPersistentObject::removeObject( eZProductCollectionItem::definition(), array( 'productcollection_id' => array( $value, '' ) ) ); eZPersistentObject::removeObject( eZWishList::definition(), array( 'productcollection_id' => array( $value, '' ) ) ); } } $db->query( 'UPDATE ezproductcollection_item SET contentobject_id = 0 WHERE contentobject_id = ' . $delID ); // Cleanup relations in two steps to avoid locking table for to long $db->query( "DELETE FROM ezcontentobject_link WHERE from_contentobject_id = '$delID'" ); $db->query( "DELETE FROM ezcontentobject_link WHERE to_contentobject_id = '$delID'" ); // Cleanup properties: LastVisit, Creator, Owner $db->query( "DELETE FROM ezuservisit WHERE user_id = '$delID'" ); $db->query( "UPDATE ezcontentobject_version SET creator_id = 0 WHERE creator_id = '$delID'" ); $db->query( "UPDATE ezcontentobject SET owner_id = 0 WHERE owner_id = '$delID'" ); if ( isset( $GLOBALS["eZWorkflowTypeObjects"] ) and is_array( $GLOBALS["eZWorkflowTypeObjects"] ) ) { $registeredTypes =& $GLOBALS["eZWorkflowTypeObjects"]; } else { $registeredTypes = eZWorkflowType::fetchRegisteredTypes(); } // Cleanup ezworkflow_event etc... foreach ( array_keys( $registeredTypes ) as $registeredTypeKey ) { $registeredType = $registeredTypes[$registeredTypeKey]; $registeredType->cleanupAfterRemoving( array( 'DeleteContentObject' => $delID ) ); } $db->commit(); }
return; } $productItemsCount = array(); // Create array of productItemID (as index) and productItemCount (as value) foreach ($productItemIDlist as $key => $productItemID) { if (isset($productItemCountList[$key])) { $productItemsCount[$productItemID] = $productItemCountList[$key]; } } $db = eZDB::instance(); $db->begin(); foreach ($collectionItems as $item) { $itemID = $item->attribute('id'); if (isset($productItemsCount[$itemID])) { $item->setAttribute('item_count', $productItemsCount[$itemID]); $item->store(); } } $db->commit(); $module->redirectTo($module->functionURI("wishlist") . "/"); return; } } $tpl = eZTemplate::factory(); $wishList = eZWishList::currentWishList(); $tpl->setVariable("wish_list", $wishList); $viewParameters = array('offset' => $offset); $tpl->setVariable('view_parameters', $viewParameters); $Result = array(); $Result['content'] = $tpl->fetch("design:shop/wishlist.tpl"); $Result['path'] = array(array('url' => false, 'text' => ezpI18n::tr('kernel/shop', 'Wishlist')));
static function removeByUserID($userID) { eZPersistentObject::removeObject(eZWishList::definition(), array('user_id' => $userID)); }