本文整理汇总了PHP中eZContentCacheManager类的典型用法代码示例。如果您正苦于以下问题:PHP eZContentCacheManager类的具体用法?PHP eZContentCacheManager怎么用?PHP eZContentCacheManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZContentCacheManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: remove
static function remove($objectID, $removeSubtrees = true)
{
eZContentCacheManager::clearContentCacheIfNeeded($objectID);
$object = eZContentObject::fetch($objectID);
if (!is_object($object)) {
return false;
}
// TODO: Is content cache cleared for all objects in subtree ??
if ($removeSubtrees) {
$assignedNodes = $object->attribute('assigned_nodes');
if (count($assignedNodes) == 0) {
$object->purge();
eZContentObject::expireAllViewCache();
return true;
}
$assignedNodeIDArray = array();
foreach ($assignedNodes as $node) {
$assignedNodeIDArray[] = $node->attribute('node_id');
}
eZContentObjectTreeNode::removeSubtrees($assignedNodeIDArray, false);
} else {
$object->purge();
}
return true;
}
示例2: feZMetaData_ContentActionHandler
function feZMetaData_ContentActionHandler( &$module, &$http, &$objectID )
{
// Action when user clicks on the Add Button
if( $http->hasPostVariable( 'AddMetaDataButton' ) )
{
$link = 'fezmetadata/edit/0/(contentObjectID)/'.$objectID;
$link .= '/(metaDataName)/'.$_POST['metaDataName'];
$link .= '/(language)/'.$_POST['language'];
eZURI::transformURI( $link );
$http->redirect( $link );
}
// Action when user clicks on the Remove Button
if( $http->hasPostVariable( 'RemoveMetaDataButton' ) and $http->hasPostVariable( 'MetaDataIDSelection' ) )
{
$metaDataSelection = $http->postVariable( 'MetaDataIDSelection' );
foreach( $metaDataSelection as $metaData )
{
$metaDataObject = feZMetaData::fetch( $metaData );
$metaDataObject->remove();
}
eZContentCacheManager::clearContentCache( $objectID );
$ContentObject = eZContentObject::fetch( $objectID );
$ContentNodeID = $ContentObject->mainNodeID();
return $module->redirect( 'content', 'view', array( 'full', $ContentNodeID ) );
}
}
示例3: sectionEditActionCheck
function sectionEditActionCheck($module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage)
{
if (!$module->isCurrentAction('SectionEdit')) {
return;
}
$http = eZHTTPTool::instance();
if (!$http->hasPostVariable('SelectedSectionId')) {
return;
}
$selectedSection = eZSection::fetch((int) $http->postVariable('SelectedSectionId'));
if (!$selectedSection instanceof eZSection) {
return;
}
$selectedSection->applyTo($object);
eZContentCacheManager::clearContentCacheIfNeeded($object->attribute('id'));
$module->redirectToView('edit', array($object->attribute('id'), $editVersion, $editLanguage, $fromLanguage));
}
示例4: execute
function execute($process, $event)
{
// get object being published
$parameters = $process->attribute('parameter_list');
$objectId = $parameters['object_id'];
eZDebug::writeDebug('Expire remote cache event begins execution for object ' . $objectId);
$ini = eZINI::instance('ezworkflowcollection.ini');
$object = eZContentObject::fetch($objectId);
if ($object != null) {
if ($ini->variable('ExpireRemoteCacheFlowSettings', 'ExpireOnlyObjectNodes') == 'enabled') {
// basic version
// get list of nodes this object is published with
$assigned_nodes = $object->attribute('assigned_nodes');
} else {
// smart-cache enabled version
// get list of nodes whose view-cache is expired
$assigned_nodes = array();
eZContentCacheManager::nodeListForObject($object, true, eZContentCacheManager::CLEAR_DEFAULT, $assigned_nodes, $handledObjectList);
foreach ($assigned_nodes as $i => $nodeID) {
$assigned_nodes[$i] = eZContentObjectTreeNode::fetch($nodeID);
}
}
$domains = $ini->variable('ExpireRemoteCacheFlowSettings', 'ExpireDomains');
foreach ($assigned_nodes as $assigned_node) {
// for every node, call eZHTTPCacheManager to clean the remote cache
$url = $assigned_node->urlAlias();
if (is_array($domains) && (count($domains) > 1 || count($domains) > 0 && $domains[0] != '')) {
eZURI::transformURI($url);
foreach ($domains as $domain) {
eZHTTPCacheManager::execute($domain . $url);
}
} else {
eZURI::transformURI($url, false, 'full');
eZHTTPCacheManager::execute($url);
}
}
} else {
eZDebug::writeError('Expire remote cache event triggered for inexisting object: ' . $objectId);
return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
}
return eZWorkflowType::STATUS_ACCEPTED;
}
示例5: updatePriority
/**
* Updating priority sorting for given node
*
* @param mixed $args
* @return array
*/
public static function updatePriority( $args )
{
$http = eZHTTPTool::instance();
if ( !$http->hasPostVariable('ContentNodeID')
|| !$http->hasPostVariable('PriorityID')
|| !$http->hasPostVariable('Priority') )
{
return array();
}
$contentNodeID = $http->postVariable('ContentNodeID');
$priorityArray = $http->postVariable('Priority');
$priorityIDArray = $http->postVariable('PriorityID');
$contentNode = eZContentObjectTreeNode::fetch( $contentNodeID );
if ( !$contentNode->attribute( 'can_edit' ) )
{
eZDebug::writeError( 'Current user can not update the priorities because he has no permissions to edit the node' );
return array();
}
if ( eZOperationHandler::operationIsAvailable( 'content_updatepriority' ) )
{
$operationResult = eZOperationHandler::execute( 'content', 'updatepriority',
array( 'node_id' => $contentNodeID,
'priority' => $priorityArray,
'priority_id' => $priorityIDArray ), null, true );
}
else
{
eZContentOperationCollection::updatePriority( $contentNodeID, $priorityArray, $priorityIDArray );
}
if ( $http->hasPostVariable( 'ContentObjectID' ) )
{
$objectID = $http->postVariable( 'ContentObjectID' );
eZContentCacheManager::clearContentCache( $objectID );
}
}
示例6: execute
/**
* @param eZWorkflowProcess $process
* @param eZWorkflowEvent $event
* @return int
*/
function execute( $process, $event )
{
// Get some information about the object being passed
$parameters = $process->attribute( 'parameter_list' );
$object = eZContentObject::fetch( $parameters['object_id'] );
if($object->ClassIdentifier != 'article')
return self::STATUS_ACCEPTED;
/* @type $dataMap eZContentObjectAttribute[] */
$dataMap = $object->dataMap();
if(isset($dataMap['source']))
{
$sourceString = MMNewsSource::getSourceString($object);
if($sourceString)
{
$dataMap['source']->setAttribute('data_text', $sourceString);
$dataMap['source']->store();
}
eZContentCacheManager::clearContentCache($object->attribute('id'));
}
return self::STATUS_ACCEPTED;
}
示例7: removeRelatedCache
function removeRelatedCache($siteAccess)
{
// Delete compiled template
$ini = eZINI::instance();
$iniPath = eZSiteAccess::findPathToSiteAccess($siteAccess);
$siteINI = eZINI::instance('site.ini.append', $iniPath);
if ($siteINI->hasVariable('FileSettings', 'CacheDir')) {
$cacheDir = $siteINI->variable('FileSettings', 'CacheDir');
if ($cacheDir[0] == "/") {
$cacheDir = eZDir::path(array($cacheDir));
} else {
if ($siteINI->hasVariable('FileSettings', 'VarDir')) {
$varDir = $siteINI->variable('FileSettings', 'VarDir');
$cacheDir = eZDir::path(array($varDir, $cacheDir));
}
}
} else {
if ($siteINI->hasVariable('FileSettings', 'VarDir')) {
$varDir = $siteINI->variable('FileSettings', 'VarDir');
$cacheDir = $ini->variable('FileSettings', 'CacheDir');
$cacheDir = eZDir::path(array($varDir, $cacheDir));
} else {
$cacheDir = eZSys::cacheDirectory();
}
}
$compiledTemplateDir = $cacheDir . "/template/compiled";
eZDir::unlinkWildcard($compiledTemplateDir . "/", "*pagelayout*.*");
eZCache::clearByTag('template-block');
// Expire content view cache
eZContentCacheManager::clearAllContentCache();
}
示例8: setFailedLoginAttempts
static function setFailedLoginAttempts($userID, $value = false, $setByForce = false)
{
$trustedUser = eZUser::isTrusted();
// If user is trusted we should stop processing
if ($trustedUser and !$setByForce) {
return true;
}
$maxNumberOfFailedLogin = eZUser::maxNumberOfFailedLogin();
if ($maxNumberOfFailedLogin == '0' and !$setByForce) {
return true;
}
$userID = (int) $userID;
$userObject = eZUser::fetch($userID);
if (!$userObject) {
return true;
}
$isEnabled = $userObject->isEnabled();
// If current user is disabled we should not continue
if (!$isEnabled and !$setByForce) {
return true;
}
$db = eZDB::instance();
$db->begin();
$userVisitArray = $db->arrayQuery("SELECT 1 FROM ezuservisit WHERE user_id={$userID}");
if (isset($userVisitArray[0])) {
if ($value === false) {
$failedLoginAttempts = $userObject->failedLoginAttempts();
$failedLoginAttempts += 1;
} else {
$failedLoginAttempts = (int) $value;
}
$db->query("UPDATE ezuservisit SET failed_login_attempts={$failedLoginAttempts} WHERE user_id={$userID}");
} else {
if ($value === false) {
$failedLoginAttempts = 1;
} else {
$failedLoginAttempts = (int) $value;
}
$db->query("INSERT INTO ezuservisit ( failed_login_attempts, user_id ) VALUES ( {$failedLoginAttempts}, {$userID} )");
}
$db->commit();
eZContentCacheManager::clearContentCacheIfNeeded($userID);
eZContentCacheManager::generateObjectViewCache($userID);
}
示例9: storeObjectAttribute
function storeObjectAttribute($attribute)
{
$ini = eZINI::instance();
// Delete compiled template
$siteINI = eZINI::instance();
if ($siteINI->hasVariable('FileSettings', 'CacheDir')) {
$cacheDir = $siteINI->variable('FileSettings', 'CacheDir');
if ($cacheDir[0] == "/") {
$cacheDir = eZDir::path(array($cacheDir));
} else {
if ($siteINI->hasVariable('FileSettings', 'VarDir')) {
$varDir = $siteINI->variable('FileSettings', 'VarDir');
$cacheDir = eZDir::path(array($varDir, $cacheDir));
}
}
} else {
if ($siteINI->hasVariable('FileSettings', 'VarDir')) {
$varDir = $siteINI->variable('FileSettings', 'VarDir');
$cacheDir = $ini->variable('FileSettings', 'CacheDir');
$cacheDir = eZDir::path(array($varDir, $cacheDir));
} else {
$cacheDir = eZSys::cacheDirectory();
}
}
$compiledTemplateDir = $cacheDir . "/template/compiled";
eZDir::unlinkWildcard($compiledTemplateDir . "/", "*pagelayout*.*");
// Expire template block cache
eZContentCacheManager::clearTemplateBlockCacheIfNeeded(false);
}
示例10: array
// Sort objectDepthList by depth to apply updatechildren in the right order
if (!array_multisort($objectDepthList[0], SORT_ASC, $objectDepthList[1], SORT_ASC)) {
eZDebug::writeError('Error in array_multisort', 'ezmbpaex_updatechildren.php');
} else {
// Generate array of paex objects to update
$paexObjectArray = array();
foreach ($objectDepthList[1] as $contentobjectId) {
if (isset($pendingList[$contentobjectId])) {
// Generate update children data for every pending object in pendingIDList
$paexObjectArray = $pendingList[$contentobjectId]->generateUpdateChildren($paexObjectArray);
} else {
eZDebug::writeError('Found contentobject_id [' . $contentobjectId . '] not present in the pendingIDList', 'ezmbpaex_updatechildren.php');
}
}
// Reset pending object updatechildren attribute in pendingIDList objects and add to the array of paex objects to update
foreach ($pendingList as $pendingObject) {
$pendingObject->setAttribute('updatechildren', 0);
$paexObjectArray[$pendingObject->attribute('contentobject_id')] = $pendingObject;
}
// Store updated paex objects in the DB
$db = eZDB::instance();
$db->begin();
foreach ($paexObjectArray as $paexObject) {
$paexObject->store();
eZContentCacheManager::clearContentCacheIfNeeded($paexObject->attribute('contentobject_id'));
}
$db->commit();
}
}
$cli->output("eZPaEx: Update children process end");
}
示例11: clearViewCacheForSubtree
/**
* Clears the view cache for a subtree
*
* @param eZContentObjectTreeNode $node
* @param bool $clearForRootNode
* @return bool
*/
static function clearViewCacheForSubtree(eZContentObjectTreeNode $node, $clearForRootNode = true)
{
// Max nodes to fetch at a time
static $limit = 200;
if ($clearForRootNode) {
$objectID = $node->attribute('contentobject_id');
eZContentCacheManager::clearContentCacheIfNeeded($objectID);
}
$offset = 0;
$params = array('AsObject' => false, 'Depth' => false, 'Limitation' => array());
// Empty array means no permission checking
$subtreeCount = $node->subTreeCount($params);
while ($offset < $subtreeCount) {
$params['Offset'] = $offset;
$params['Limit'] = $limit;
$subtreeChunk = $node->subTree($params);
$nNodesInChunk = count($subtreeChunk);
$offset += $nNodesInChunk;
if ($nNodesInChunk == 0) {
break;
}
$objectIDList = array();
foreach ($subtreeChunk as $curNode) {
$objectIDList[] = $curNode['id'];
}
unset($subtreeChunk);
eZContentCacheManager::clearContentCacheIfNeeded(array_unique($objectIDList));
}
return true;
}
示例12: generateObjectViewCache
static function generateObjectViewCache($objectID)
{
// Generate the view cache
$ini = eZINI::instance();
$object = eZContentObject::fetch($objectID);
$user = eZUser::currentUser();
eZDebug::accumulatorStart('generate_cache', '', 'Generating view cache');
if ($ini->variable('ContentSettings', 'PreViewCache') == 'enabled') {
$preCacheSiteaccessArray = $ini->variable('ContentSettings', 'PreCacheSiteaccessArray');
$currentSiteAccess = $GLOBALS['eZCurrentAccess'];
// This is the default view parameters for content/view
$viewParameters = array('offset' => false, 'year' => false, 'month' => false, 'day' => false, 'namefilter' => false);
if (is_array($preCacheSiteaccessArray) && count($preCacheSiteaccessArray) > 0) {
foreach ($preCacheSiteaccessArray as $changeToSiteAccess) {
$newSiteAccess = $currentSiteAccess;
$newSiteAccess['name'] = $changeToSiteAccess;
unset($newSiteAccess['uri_part']);
//eZSiteAccess::load() will take care of setting correct one
eZSiteAccess::load($newSiteAccess);
$tpl = eZTemplate::factory();
// Get the sitedesign and cached view preferences for this siteaccess
$siteini = eZINI::instance('site.ini');
$cachedViewPreferences = $siteini->variable('ContentSettings', 'CachedViewPreferences');
$language = false;
// Needs to be specified if you want to generate the cache for a specific language
$viewMode = 'full';
$assignedNodes = $object->assignedNodes();
foreach ($assignedNodes as $node) {
// We want to generate the cache for the specified user
$previewCacheUsers = $ini->variable('ContentSettings', 'PreviewCacheUsers');
foreach ($previewCacheUsers as $previewCacheUserID) {
// If the text is 'anon' we need to fetch the Anonymous user ID.
if ($previewCacheUserID === 'anonymous') {
$previewCacheUserID = $siteini->variable("UserSettings", "AnonymousUserID");
$previewCacheUser = eZUser::fetch($previewCacheUserID);
} else {
if ($previewCacheUserID === 'current') {
$previewCacheUser = $user;
} else {
$previewCacheUser = eZUser::fetch($previewCacheUserID);
}
}
if (!$previewCacheUser) {
continue;
}
// Before we generate the view cache we must change the currently logged in user to $previewCacheUser
// If not the templates might read in wrong personalized data (preferences etc.)
eZUser::setCurrentlyLoggedInUser($previewCacheUser, $previewCacheUser->attribute('contentobject_id'), eZUser::NO_SESSION_REGENERATE);
// Cache the current node
$cacheFileArray = eZNodeviewfunctions::generateViewCacheFile($previewCacheUser, $node->attribute('node_id'), false, false, $language, $viewMode, $viewParameters, $cachedViewPreferences);
$tmpRes = eZNodeviewfunctions::generateNodeView($tpl, $node, $node->attribute('object'), $language, $viewMode, false, $cacheFileArray['cache_dir'], $cacheFileArray['cache_path'], true, $viewParameters);
// Cache the parent node
$parentNode = $node->attribute('parent');
$objectID = $parentNode->attribute('contentobject_id');
// if parent objectID is null or is 0 we should not create cache.
if ($objectID) {
$cacheFileArray = eZNodeviewfunctions::generateViewCacheFile($previewCacheUser, $parentNode->attribute('node_id'), 0, false, $language, $viewMode, $viewParameters, $cachedViewPreferences);
$tmpRes = eZNodeviewfunctions::generateNodeView($tpl, $parentNode, $parentNode->attribute('object'), $language, $viewMode, 0, $cacheFileArray['cache_dir'], $cacheFileArray['cache_path'], true, $viewParameters);
}
}
}
}
// Restore the old user as the current one
eZUser::setCurrentlyLoggedInUser($user, $user->attribute('contentobject_id'), eZUser::NO_SESSION_REGENERATE);
// restore siteaccess
eZSiteAccess::load($currentSiteAccess);
}
}
if ($ini->variable('ContentSettings', 'StaticCache') == 'enabled') {
$nodes = array();
$ini = eZINI::instance();
$useURLAlias =& $GLOBALS['eZContentObjectTreeNodeUseURLAlias'];
$pathPrefix = $ini->variable('SiteAccessSettings', 'PathPrefix');
// get staticCacheHandler instance
$optionArray = array('iniFile' => 'site.ini', 'iniSection' => 'ContentSettings', 'iniVariable' => 'StaticCacheHandler');
$options = new ezpExtensionOptions($optionArray);
$staticCacheHandler = eZExtension::getHandlerClass($options);
if (!isset($useURLAlias)) {
$useURLAlias = $ini->variable('URLTranslator', 'Translation') == 'enabled';
}
eZContentCacheManager::nodeListForObject($object, true, self::CLEAR_DEFAULT, $nodes, $handledObjectList);
// If no nodes returns it means that ClearCacheMethod = self::CLEAR_NO_CACHE
if (count($nodes)) {
foreach ($nodes as $nodeID) {
if ($useURLAlias) {
$oNode = eZContentObjectTreeNode::fetch($nodeID, false, true);
if (!isset($oNode)) {
continue;
}
$urlAlias = $oNode->urlAlias();
if ($pathPrefix != '') {
$tempAlias = substr($pathPrefix, strlen($pathPrefix) - 1) == '/' ? $urlAlias . '/' : $urlAlias;
if (strncmp($tempAlias, $pathPrefix, strlen($tempAlias)) == 0) {
$urlAlias = substr($tempAlias, strlen($pathPrefix));
}
}
} else {
$urlAlias = 'content/view/full/' . $nodeID;
}
$staticCacheHandler->cacheURL('/' . $urlAlias, $nodeID);
//.........这里部分代码省略.........
示例13:
if ($existingNotification) {
$tpl->setVariable('success_message', ezpI18n::tr('ezcomments/comment/add', 'You have already subscribed to comment updates on this content.'));
} else {
$tpl->setVariable('success_message', ezpI18n::tr('ezcomments/comment/add', 'You will receive comment updates on the content.'));
}
} else {
$tpl->setVariable('success_message', ezpI18n::tr('ezcomments/comment/add', 'A confirmation email has been sent to your email address. You will receive comment updates after confirmation.'));
}
}
//remember cookies
$cookieManager = ezcomCookieManager::instance();
if ($http->postVariable('CommentRememberme', false) !== false || !$user->isAnonymous()) {
$cookieManager->storeCookie($comment);
} else {
$cookieManager->clearCookie();
}
eZContentCacheManager::clearContentCacheIfNeeded($contentObjectId);
if (!$changeNotification) {
$commentINI = eZINI::instance('ezcomments.ini');
if ($commentINI->variable('GlobalSettings', 'RedirectAfterCommenting') === 'true') {
$module->redirectTo($redirectURI);
}
} else {
$tpl->setVariable('redirect_uri', $redirectURI);
}
}
} else {
$tpl->setVariable('error_message', ezpI18n::tr('ezcomments/comment/add', 'You should not access this view directly.'));
}
$Result['content'] = $tpl->fetch('design:comment/add.tpl');
return $Result;
示例14: swapNodes
function swapNodes( $params )
{
$nodeInfo1 = $params['src_node'];
$nodeInfo2 = $params['dst_node'];
//init vars
$node1 = $this->nodeIdByName( $nodeInfo1 );
$node2 = $this->nodeIdByName( $nodeInfo2 );
$nodeID = $node1;
$node = eZContentObjectTreeNode::fetch( $nodeID );
if( !is_object( $node ) )
{
$this->reportError( "Can't fetch node '$nodeID'", 'eZSiteInstaller::swapNodes' );
return false;
}
if( !$node->canSwap() )
{
$this->reportError( "Cannot swap node '$nodeID' (no edit permission)", 'eZSiteInstaller::swapNodes' );
return false;
}
$nodeParentNodeID = $node->attribute( 'parent_node_id' );
$object = $node->object();
if( !is_object( $object ) )
{
$this->reportError( "Cannot fetch object for node '$nodeID'", 'eZSiteInstaller::swapNodes' );
return false;
}
$objectID = $object->attribute( 'id' );
$objectVersion = $object->attribute( 'current_version' );
$class = $object->contentClass();
$classID = $class->attribute( 'id' );
$selectedNodeID = $node2;
$selectedNode = eZContentObjectTreeNode::fetch( $selectedNodeID );
if( !is_object( $selectedNode ) )
{
$this->reportError( "Cannot fetch node '$selectedNodeID'", 'eZSiteInstaller::swapNodes' );
return false;
}
if( !$selectedNode->canSwap() )
{
$this->reportError( "Cannot use node $selectedNodeID as the exchanging node for $nodeID, the current user does not have edit permission for it",
'eZSiteInstaller::swapNodes' );
return false;
}
// clear cache.
eZContentCacheManager::clearContentCacheIfNeeded( $objectID );
$selectedObject = $selectedNode->object();
$selectedObjectID = $selectedObject->attribute( 'id' );
$selectedObjectVersion = $selectedObject->attribute( 'current_version' );
$selectedNodeParentNodeID = $selectedNode->attribute( 'parent_node_id' );
/* In order to swap node1 and node2 a user should have the following permissions:
* 1. move_from: move node1
* 2. move_from: move node2
* 3. move_to: move an object of the same class as node2 under parent of node1
* 4. move_to: move an object of the same class as node1 under parent of node2
*
* The First two has already been checked. Let's check the rest.
*/
$nodeParent = $node->attribute( 'parent' );
$selectedNodeParent = $selectedNode->attribute( 'parent' );
$objectClassID = $object->attribute( 'contentclass_id' );
$selectedObjectClassID = $selectedObject->attribute( 'contentclass_id' );
if( !$nodeParent || !$selectedNodeParent )
{
$this->reportError( "No $nodeParent or no !$selectedNodeParent received.",
'eZSiteInstaller::swapNodes' );
return false;
}
if( !$nodeParent->canMoveTo( $selectedObjectClassID ) )
{
$this->reportError( "Cannot move an object of class $selectedObjectClassID to node $nodeParentNodeID (no create permission)",
'eZSiteInstaller::swapNodes' );
return false;
}
if( !$selectedNodeParent->canMoveTo( $objectClassID ) )
{
$this->reportError( "Cannot move an object of class $objectClassID to node $selectedNodeParentNodeID (no create permission)",
'eZSiteInstaller::swapNodes' );
return false;
}
// exchange contentobject ids and versions.
$node->setAttribute( 'contentobject_id', $selectedObjectID );
//.........这里部分代码省略.........
示例15: rate
/**
* Create a ezsrRatingDataObject and store it.
* Note: No access checks or input validation is done other then on rating
*
* @param int $contentobjectId
* @param int $contentobjectAttributeId
* @param int $rate (above 0 and bellow or equal 5)
* @param bool $onlyStoreIfUserNotAlreadyRated
* @return null|ezsrRatingDataObject
*/
static function rate($contentobjectId, $contentobjectAttributeId, $rate)
{
$rating = null;
if (is_numeric($contentobjectId) && is_numeric($contentobjectAttributeId) && is_numeric($rate) && $rate <= 5 && $rate > 0) {
$row = array('contentobject_attribute_id' => $contentobjectAttributeId, 'contentobject_id' => $contentobjectId, 'rating' => $rate);
$rating = self::create($row);
if (!$rating->userHasRated()) {
$rating->store();
$avgRating = $rating->getAverageRating();
$avgRating->updateFromRatingData();
$avgRating->store();
// clear the cache for all nodes associated with this object
eZContentCacheManager::clearContentCacheIfNeeded($contentobjectId, true, false);
}
}
return $rating;
}