本文整理汇总了PHP中eZOperationHandler::operationIsAvailable方法的典型用法代码示例。如果您正苦于以下问题:PHP eZOperationHandler::operationIsAvailable方法的具体用法?PHP eZOperationHandler::operationIsAvailable怎么用?PHP eZOperationHandler::operationIsAvailable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZOperationHandler
的用法示例。
在下文中一共展示了eZOperationHandler::operationIsAvailable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
function execute($process, $event)
{
// get object being published
$parameters = $process->attribute('parameter_list');
$objectID = $parameters['object_id'];
eZDebug::writeDebug('Update object state for object: ' . $objectID);
$object = eZContentObject::fetch($objectID);
$state_before = $event->attribute('state_before');
$state_after = $event->attribute('state_after');
if ($object == null) {
eZDebug::writeError('Update object state failed for inexisting object: ' . $objectID, __METHOD__);
return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
}
if ($state_before == null || $state_after == null) {
eZDebug::writeError('Update object state failed: badly configured states', __METHOD__);
return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
}
$currentStateIDArray = $object->attribute('state_id_array');
if (in_array($state_before->attribute('id'), $currentStateIDArray)) {
$canAssignStateIDList = $object->attribute('allowed_assign_state_id_list');
if (!in_array($state_after->attribute('id'), $canAssignStateIDList)) {
eZDebug::writeWarning("Not enough rights to assign state to object {$objectID}: " . $state_after->attribute('id'), __METHOD__);
} else {
eZDebug::writeDebug('Changing object state from ' . $state_before->attribute('name') . ' to ' . $state_after->attribute('name'), __METHOD__);
if (eZOperationHandler::operationIsAvailable('content_updateobjectstate')) {
$operationResult = eZOperationHandler::execute('content', 'updateobjectstate', array('object_id' => $objectID, 'state_id_list' => array($state_after->attribute('id'))));
} else {
eZContentOperationCollection::updateObjectState($objectID, array($state_after->attribute('id')));
}
}
}
return eZWorkflowType::STATUS_ACCEPTED;
}
示例2: runOperation
function runOperation(&$node)
{
if (eZOperationHandler::operationIsAvailable('content_updatealwaysavailable')) {
$operationResult = eZOperationHandler::execute('content', 'updatealwaysavailable', array('object_id' => $node->attribute('contentobject_id'), 'new_always_available' => $this->available, 'node_id' => $node->attribute('node_id')));
} else {
eZContentOperationCollection::updateAlwaysAvailable($node->attribute('contentobject_id'), $this->available);
}
return true;
}
示例3: sectionEditActionCheck
function sectionEditActionCheck( $module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage )
{
if ( $module->isCurrentAction( 'SectionEdit' ) )
{
$http = eZHTTPTool::instance();
if ( $http->hasPostVariable( 'SelectedSectionId' ) )
{
$selectedSectionID = (int) $http->postVariable( 'SelectedSectionId' );
$selectedSection = eZSection::fetch( $selectedSectionID );
if ( is_object( $selectedSection ) )
{
$currentUser = eZUser::currentUser();
if ( $currentUser->canAssignSectionToObject( $selectedSectionID, $object ) )
{
$db = eZDB::instance();
$db->begin();
$assignedNodes = $object->attribute( 'assigned_nodes' );
if ( count( $assignedNodes ) > 0 )
{
foreach ( $assignedNodes as $node )
{
if ( eZOperationHandler::operationIsAvailable( 'content_updatesection' ) )
{
$operationResult = eZOperationHandler::execute( 'content',
'updatesection',
array( 'node_id' => $node->attribute( 'node_id' ),
'selected_section_id' => $selectedSectionID ),
null,
true );
}
else
{
eZContentOperationCollection::updateSection( $node->attribute( 'node_id' ), $selectedSectionID );
}
}
}
else
{
// If there are no assigned nodes we should update db for the current object.
$objectID = $object->attribute( 'id' );
$db->query( "UPDATE ezcontentobject SET section_id='$selectedSectionID' WHERE id = '$objectID'" );
$db->query( "UPDATE ezsearch_object_word_link SET section_id='$selectedSectionID' WHERE contentobject_id = '$objectID'" );
}
$object->expireAllViewCache();
$db->commit();
}
else
{
eZDebug::writeError( "You do not have permissions to assign the section <" . $selectedSection->attribute( 'name' ) .
"> to the object <" . $object->attribute( 'name' ) . ">." );
}
$module->redirectToView( 'edit', array( $object->attribute( 'id' ), $editVersion, $editLanguage, $fromLanguage ) );
}
}
}
}
示例4: testEnablingPartialOperation
/**
* Test scenario for issue #15883: Enable only before (or after) operation doesn't work (patch)
*
* Test outline
* -------------
* 1. Enable a partial operation in workflow.ini (before_content_read)
* 2. Call eZOperationHandler::isOperationAvailable( 'content_read' )
*
* @result: false
* @expected: true
* @link http://issues.ez.no/15883
* @group issue_15883
*/
function testEnablingPartialOperation()
{
$wfINI = eZINI::instance('workflow.ini');
// before
$wfINI->setVariable('OperationSettings', 'AvailableOperationList', array('before_content_read'));
$this->assertTrue(eZOperationHandler::operationIsAvailable('content_read'));
// after
$wfINI->setVariable('OperationSettings', 'AvailableOperationList', array('after_content_read'));
$this->assertTrue(eZOperationHandler::operationIsAvailable('content_read'));
// complete
$wfINI->setVariable('OperationSettings', 'AvailableOperationList', array('content_read'));
$this->assertTrue(eZOperationHandler::operationIsAvailable('content_read'));
// unknown one
$this->assertFalse(eZOperationHandler::operationIsAvailable('foo_bar'));
}
示例5: stateEditActionCheck
function stateEditActionCheck($module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage)
{
if ($module->isCurrentAction('StateEdit')) {
$http = eZHTTPTool::instance();
if ($http->hasPostVariable('SelectedStateIDList')) {
$selectedStateIDList = $http->postVariable('SelectedStateIDList');
$objectID = $object->attribute('id');
if (eZOperationHandler::operationIsAvailable('content_updateobjectstate')) {
$operationResult = eZOperationHandler::execute('content', 'updateobjectstate', array('object_id' => $objectID, 'state_id_list' => $selectedStateIDList));
} else {
eZContentOperationCollection::updateObjectState($objectID, $selectedStateIDList);
}
}
}
}
示例6: 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 );
}
}
示例7: array
/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
* @version //autogentag//
* @package kernel
*/
$Module = $Params['Module'];
$NodeID = $Params['NodeID'];
$curNode = eZContentObjectTreeNode::fetch($NodeID);
if (!$curNode) {
return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
if (!$curNode->attribute('can_hide')) {
return $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel');
}
if (eZOperationHandler::operationIsAvailable('content_hide')) {
$operationResult = eZOperationHandler::execute('content', 'hide', array('node_id' => $NodeID), null, true);
} else {
eZContentOperationCollection::changeHideStatus($NodeID);
}
$hasRedirect = eZRedirectManager::redirectTo($Module, false);
if (!$hasRedirect) {
// redirect to the parent node
if (($parentNodeID = $curNode->attribute('parent_node_id')) == 1) {
$redirectNodeID = $NodeID;
} else {
$redirectNodeID = $parentNodeID;
}
return $Module->redirectToView('view', array('full', $redirectNodeID));
}
示例8: array
if (isset($Params['AttributeValidation'])) {
$validation = $Params['AttributeValidation'];
}
$res = eZTemplateDesignResource::instance();
$keys = $res->keys();
if (isset($keys['layout'])) {
$layout = $keys['layout'];
} else {
$layout = false;
}
$viewParameters = array('offset' => $Offset, 'year' => $Year, 'month' => $Month, 'day' => $Day, 'namefilter' => false);
$viewParameters = array_merge($viewParameters, $UserParameters);
$user = eZUser::currentUser();
eZDebugSetting::addTimingPoint('kernel-content-view', 'Operation start');
$operationResult = array();
if (eZOperationHandler::operationIsAvailable('content_read')) {
$operationResult = eZOperationHandler::execute('content', 'read', array('node_id' => $NodeID, 'user_id' => $user->id(), 'language_code' => $LanguageCode), null, true);
}
if (isset($operationResult['status']) && $operationResult['status'] != eZModuleOperationInfo::STATUS_CONTINUE) {
switch ($operationResult['status']) {
case eZModuleOperationInfo::STATUS_HALTED:
case eZModuleOperationInfo::STATUS_REPEAT:
if (isset($operationResult['redirect_url'])) {
$Module->redirectTo($operationResult['redirect_url']);
return;
} else {
if (isset($operationResult['result'])) {
$result = $operationResult['result'];
$resultContent = false;
if (is_array($result)) {
if (isset($result['content'])) {
示例9: doRemove
/**
* Does the remove job.
* Will use content_delete operation if available (workflow support)
* @param array $aNodeID
* @param bool $moveToTrash Indicates if we move content to trash or not. True by default
* @internal
*/
private function doRemove(array $aNodeID, $moveToTrash = true)
{
if (eZOperationHandler::operationIsAvailable('content_delete')) {
$operationResult = eZOperationHandler::execute('content', 'delete', array('node_id_list' => $aNodeID, 'move_to_trash' => $moveToTrash), null, true);
} else {
eZContentOperationCollection::deleteObject($aNodeID, $moveToTrash);
}
}
示例10: array
return $module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel');
}
// Then make sure we have node id parameter
if (!$http->hasPostVariable('NodeID')) {
eZDebug::writeError('Create/ Remove NodeFeed: missing node ID parameter.', 'content-action-handler');
return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
$nodeID = $http->postVariable('NodeID');
if ($http->hasPostVariable('CreateNodeFeed')) {
if (eZOperationHandler::operationIsAvailable('content_createnodefeed')) {
$operationResult = eZOperationHandler::execute('content', 'createnodefeed', array('node_id' => $nodeID), null, true);
} else {
$operationResult = eZContentOperationCollection::createFeedForNode($nodeID);
}
} else {
if (eZOperationHandler::operationIsAvailable('content_removenodefeed')) {
$operationResult = eZOperationHandler::execute('content', 'removenodefeed', array('node_id' => $nodeID), null, true);
} else {
$operationResult = eZContentOperationCollection::removeFeedForNode($nodeID);
}
}
if (!isset($operationResult['status']) || !$operationResult['status']) {
return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
return $module->redirectToView('view', array('full', $nodeID));
} else {
// Check if there are any custom actions to handle
$customActions = eZINI::instance('datatype.ini')->variable('ViewSettings', 'CustomActionMap');
foreach ($customActions as $customActionName => $customActionUrl) {
if ($http->hasPostVariable($customActionName)) {
if (strpos($customActionUrl, '/') !== false) {
示例11: array
}
$newAlwaysAvailable = $module->hasActionParameter('AlwaysAvailable');
if (eZOperationHandler::operationIsAvailable('content_updatealwaysavailable')) {
$operationResult = eZOperationHandler::execute('content', 'updatealwaysavailable', array('object_id' => $objectID, 'new_always_available' => $newAlwaysAvailable, 'node_id' => $nodeID));
} else {
eZContentOperationCollection::updateAlwaysAvailable($objectID, $newAlwaysAvailable);
}
return $module->redirectToView('view', array($viewMode, $nodeID, $languageCode));
} else {
if ($module->isCurrentAction('RemoveTranslation')) {
if (!$module->hasActionParameter('LanguageID')) {
return $module->redirectToView('view', array($viewMode, $nodeID, $languageCode));
}
$languageIDArray = $module->actionParameter('LanguageID');
if ($module->hasActionParameter('ConfirmRemoval') && $module->actionParameter('ConfirmRemoval')) {
if (eZOperationHandler::operationIsAvailable('content_removetranslation')) {
$operationResult = eZOperationHandler::execute('content', 'removetranslation', array('object_id' => $objectID, 'language_id_list' => $languageIDArray, 'node_id' => $nodeID));
} else {
eZContentOperationCollection::removeTranslation($objectID, $languageIDArray);
}
return $module->redirectToView('view', array($viewMode, $nodeID, $languageCode));
}
$languages = array();
foreach ($languageIDArray as $languageID) {
$language = eZContentLanguage::fetch($languageID);
if ($language) {
$languages[] = $language;
}
}
if (!$languages) {
return $module->redirectToView('view', array($viewMode, $nodeID, $languageCode));
示例12: processUserActivation
/**
* Processes user activation
*
* @param eZUser $user
* @param string $password
*/
public static function processUserActivation($user, $password)
{
$ini = eZINI::instance();
$tpl = eZTemplate::factory();
$tpl->setVariable('user', $user);
$tpl->setVariable('object', $user->contentObject());
$tpl->setVariable('hostname', eZSys::hostname());
$tpl->setVariable('password', $password);
// Check whether account activation is required.
$verifyUserType = $ini->variable('UserSettings', 'VerifyUserType');
$sendUserMail = !!$verifyUserType;
// For compatibility with old setting
if ($verifyUserType === 'email' && $ini->hasVariable('UserSettings', 'VerifyUserEmail') && $ini->variable('UserSettings', 'VerifyUserEmail') !== 'enabled') {
$verifyUserType = false;
}
if ($verifyUserType === 'email') {
// Disable user account and send verification mail to the user
$userID = $user->attribute('contentobject_id');
// Create enable account hash and send it to the newly registered user
$hash = md5(mt_rand() . time() . $userID);
if (eZOperationHandler::operationIsAvailable('user_activation')) {
eZOperationHandler::execute('user', 'activation', array('user_id' => $userID, 'user_hash' => $hash, 'is_enabled' => false));
} else {
eZUserOperationCollection::activation($userID, $hash, false);
}
// Log out current user
eZUser::logoutCurrent();
$tpl->setVariable('hash', $hash);
$sendUserMail = true;
} else {
if ($verifyUserType) {
$verifyUserTypeClass = false;
// load custom verify user settings
if ($ini->hasGroup('VerifyUserType_' . $verifyUserType)) {
if ($ini->hasVariable('VerifyUserType_' . $verifyUserType, 'File')) {
include_once $ini->variable('VerifyUserType_' . $verifyUserType, 'File');
}
$verifyUserTypeClass = $ini->variable('VerifyUserType_' . $verifyUserType, 'Class');
}
// try to call the verify user class with function verifyUser
if ($verifyUserTypeClass && method_exists($verifyUserTypeClass, 'verifyUser')) {
$sendUserMail = call_user_func(array($verifyUserTypeClass, 'verifyUser'), $user, $tpl);
} else {
eZDebug::writeWarning("Unknown VerifyUserType '{$verifyUserType}'", 'ngconnect/profile');
}
}
}
// send verification mail to user if email type or custom verify user type returned true
if ($sendUserMail) {
$mail = new eZMail();
$templateResult = $tpl->fetch('design:user/registrationinfo.tpl');
if ($tpl->hasVariable('content_type')) {
$mail->setContentType($tpl->variable('content_type'));
}
$emailSender = $ini->variable('MailSettings', 'EmailSender');
if ($tpl->hasVariable('email_sender')) {
$emailSender = $tpl->variable('email_sender');
} else {
if (!$emailSender) {
$emailSender = $ini->variable('MailSettings', 'AdminEmail');
}
}
$mail->setSender($emailSender);
if ($tpl->hasVariable('subject')) {
$subject = $tpl->variable('subject');
} else {
$subject = ezpI18n::tr('kernel/user/register', 'Registration info');
}
$mail->setSubject($subject);
$mail->setReceiver($user->attribute('email'));
$mail->setBody($templateResult);
eZMailTransport::send($mail);
}
}
示例13: array
$function = $http->postVariable('Function');
} else {
$function = $Params['Function'];
}
if ($http->hasPostVariable('Key')) {
$key = $http->postVariable('Key');
} else {
$key = $Params['Key'];
}
if ($http->hasPostVariable('Value')) {
$value = $http->postVariable('Value');
} else {
$value = $Params['Value'];
}
// Set user preferences
if (eZOperationHandler::operationIsAvailable('user_preferences')) {
$operationResult = eZOperationHandler::execute('user', 'preferences', array('key' => $key, 'value' => $value));
} else {
eZPreferences::setValue($key, $value);
}
// For use by ajax calls
if ($function === 'set_and_exit') {
eZDB::checkTransactionCounter();
eZExecution::cleanExit();
}
if ($http->hasPostVariable('RedirectURIAfterSet')) {
$url = $http->postVariable('RedirectURIAfterSet');
} else {
// Extract URL to redirect to from user parameters.
$urlArray = array_splice($Params['Parameters'], 3);
foreach ($urlArray as $key => $val) {
示例14: foreach
// - The total child count must be zero
// - There must be no object removal (i.e. it is the only node for the object)
if ( $totalChildCount == 0 )
{
$canRemove = true;
foreach ( $deleteResult as $item )
{
if ( $item['object_node_count'] <= 1 )
{
$canRemove = false;
break;
}
}
if ( $canRemove )
{
if ( eZOperationHandler::operationIsAvailable( 'content_removelocation' ) )
{
$operationResult = eZOperationHandler::execute( 'content',
'removelocation',
array( 'node_list' => array_keys( $deleteNodeIdArray ),
'move_to_trash' => $moveToTrash ),
null, true );
}
else
{
eZContentOperationCollection::removeNodes( array_keys( $deleteNodeIdArray ) );
}
if ( $http->hasSessionVariable( 'RedirectURIAfterRemove' )
&& $http->sessionVariable( 'RedirectURIAfterRemove' ) )
{
示例15: array
$accountActivated = false;
$alreadyActive = false;
$isPending = false;
$accountKey = $hash ? eZUserAccountKey::fetchByKey($hash) : false;
if ($accountKey) {
$accountActivated = true;
$userID = $accountKey->attribute('user_id');
$userContentObject = eZContentObject::fetch($userID);
if (!$userContentObject instanceof eZContentObject) {
return $Module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
}
if ($userContentObject->attribute('main_node_id') != $mainNodeID) {
return $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel');
}
// Enable user account
if (eZOperationHandler::operationIsAvailable('user_activation')) {
$operationResult = eZOperationHandler::execute('user', 'activation', array('user_id' => $userID, 'user_hash' => $hash, 'is_enabled' => true));
} else {
eZUserOperationCollection::activation($userID, $hash, true);
}
// execute operation to publish the user object
$publishResult = eZOperationHandler::execute('user', 'register', array('user_id' => $userID));
if ($publishResult['status'] === eZModuleOperationInfo::STATUS_HALTED) {
$isPending = true;
} else {
// Log in user
$user = eZUser::fetch($userID);
if ($user === null) {
return $Module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
}
$user->loginCurrent();