/**
 * @copyright Copyright (C) 1999-2011 eZ Systems AS. All rights reserved.
 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 * @version //autogentag//
 * @package kernel
 */

function checkRelationAssignments( $module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage, &$validation )
{
    $http = eZHTTPTool::instance();
    // Add object relations
    if ( $module->isCurrentAction( 'AddRelatedObject' ) )
    {
        $selectedObjectIDArray = eZContentBrowse::result( 'AddRelatedObject' );
        $relatedObjects = $object->relatedContentObjectArray( $editVersion, false, 0, array( 'AllRelations' => eZContentObject::RELATION_COMMON ) );
        $relatedObjectIDArray = array();
        $objectID = $object->attribute( 'id' );

        foreach (  $relatedObjects as  $relatedObject )
            $relatedObjectIDArray[] = $relatedObject->attribute( 'id' );

        if ( is_array( $selectedObjectIDArray ) )
        {
            $db = eZDB::instance();
            $db->begin();
            foreach ( $selectedObjectIDArray as $selectedObjectID )
            {
                if ( $selectedObjectID != $objectID && !in_array( $selectedObjectID, $relatedObjectIDArray ) )
                    $object->addContentObjectRelation( $selectedObjectID, $editVersion );
            }
            $db->commit();
        }

        $module->redirectToView( 'edit', array( $object->attribute( 'id' ), $editVersion, $editLanguage, $fromLanguage ),
                                 null, false, 'content-relation-items' );
        return eZModule::HOOK_STATUS_CANCEL_RUN;
    }
    if ( $module->isCurrentAction( 'UploadedFileRelation' ) )
    {
        $relatedObjectID = eZContentUpload::result( 'RelatedObjectUpload' );
        if ( $relatedObjectID )
        {
            $db = eZDB::instance();
            $db->begin();
            $object->addContentObjectRelation( $relatedObjectID, $editVersion );
            $db->commit();
        }
        // We redirect to the edit page to get the correct url,
        // also we use the anchor 'content-relation-items' to make sure the
        // browser scrolls down the relation list (if the anchor exists).
        $module->redirectToView( 'edit', array( $object->attribute( 'id' ), $editVersion, $editLanguage, $fromLanguage ),
                                 null, false, 'content-relation-items' );
        return eZModule::HOOK_STATUS_CANCEL_RUN;
    }
}
        eZDiscountSubRuleValue::removeBySubRuleID($discountRuleID);
        eZDiscountSubRule::remove($discountRuleID);
    }
    $db->commit();
    // we changed prices => remove content cache
    eZContentCacheManager::clearAllContentCache();
    $module->redirectTo($module->functionURI("discountgroupview") . "/" . $discountGroupID);
    return;
}
if ($http->hasPostVariable("AddCustomerButton")) {
    eZContentBrowse::browse(array('action_name' => 'AddCustomer', 'description_template' => 'design:shop/browse_discountcustomer.tpl', 'keys' => array('discountgroup_id' => $discountGroupID), 'content' => array('discountgroup_id' => $discountGroupID), 'from_page' => "/shop/discountgroupview/{$discountGroupID}"), $module);
    return;
}
// Add customer or customer group to this rule
if ($module->isCurrentAction('AddCustomer')) {
    $selectedObjectIDArray = eZContentBrowse::result('AddCustomer');
    $userIDArray = eZUserDiscountRule::fetchUserID($discountGroupID);
    $db = eZDB::instance();
    $db->begin();
    foreach ($selectedObjectIDArray as $objectID) {
        if (!in_array($objectID, $userIDArray)) {
            $userRule = eZUserDiscountRule::create($discountGroupID, $objectID);
            $userRule->store();
        }
    }
    $db->commit();
    // because we changed users, we have to remove content cache
    eZContentCacheManager::clearAllContentCache();
}
if ($http->hasPostVariable("RemoveCustomerButton")) {
    if ($http->hasPostVariable("CustomerIDArray")) {
function chooseOptionsToCopy($Module, &$Result, $srcNode, $chooseVersions, $chooseCreator, $chooseTime)
{
    $selectedNodeIDArray = eZContentBrowse::result($Module->currentAction());
    $tpl = eZTemplate::factory();
    $tpl->setVariable('node', $srcNode);
    $tpl->setVariable('selected_node_id', $selectedNodeIDArray[0]);
    $tpl->setVariable('choose_versions', $chooseVersions);
    $tpl->setVariable('choose_creator', $chooseCreator);
    $tpl->setVariable('choose_time', $chooseTime);
    $Result['content'] = $tpl->fetch('design:content/copy_subtree.tpl');
    $Result['path'] = array(array('url' => false, 'text' => ezpI18n::tr('kernel/content', 'Content')), array('url' => false, 'text' => ezpI18n::tr('kernel/content', 'Copy subtree')));
}
Beispiel #4
0
$checkCurrAction = false;
//Checks if it is needed to clear $parameterValue
$currentAction = $module->currentAction();
if ($currentAction == 'BackToToolbars') {
    return $Module->redirectToView('toolbarlist', array());
} elseif ($currentAction == 'SelectToolbarNode') {
    $selectedNodeIDArray = eZContentBrowse::result('SelectToolbarNode');
    $nodeID = $selectedNodeIDArray[0];
    if (is_numeric($nodeID)) {
        $toolIndex = $http->variable('tool_index');
        $parameterName = $http->variable('parameter_name');
        $iniAppend->setVariable("Tool_" . $toolbarPosition . "_" . $toolArray[$toolIndex] . "_" . ($toolIndex + 1), $parameterName, $nodeID);
        $succeed = $iniAppend->save(false, false, false, false, true, true);
    }
} elseif ($currentAction == 'SelectToolbarNodePath') {
    $selectedNodeIDArray = eZContentBrowse::result('SelectToolbarNode');
    $nodeID = $selectedNodeIDArray[0];
    if (!$http->hasPostVariable('BrowseCancelButton')) {
        if (!is_numeric($nodeID)) {
            $nodeID = 2;
        }
        $toolIndex = $http->variable('tool_index');
        $parameterName = $http->variable('parameter_name');
        $iniAppend->setVariable("Tool_" . $toolbarPosition . "_" . $toolArray[$toolIndex] . "_" . ($toolIndex + 1), $parameterName, $nodeID);
        $succeed = $iniAppend->save(false, false, false, false, true, true);
    }
} elseif ($currentAction == 'NewTool' || $currentAction == 'UpdatePlacement' || $currentAction == 'Browse' || $currentAction == 'Remove') {
    $deleteToolArray = array();
    if ($currentAction == 'Remove' && $http->hasPostVariable('deleteToolArray')) {
        $deleteToolArray = $http->postVariable('deleteToolArray');
    }
Beispiel #5
0
 $nodeID = $module->actionParameter('NodeID');
 $object = eZContentObject::fetch($objectID);
 if (!$object) {
     return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
 }
 $user = eZUser::currentUser();
 if (!$object->checkAccess('edit') && !$user->attribute('has_manage_locations')) {
     return $module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel');
 }
 $existingNode = eZContentObjectTreeNode::fetch($nodeID);
 if (!$existingNode) {
     return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
 }
 $class = $object->contentClass();
 if ($module->isCurrentAction('AddAssignment')) {
     $selectedNodeIDArray = eZContentBrowse::result('AddNodeAssignment');
     if (!is_array($selectedNodeIDArray)) {
         $selectedNodeIDArray = array();
     }
     if (eZOperationHandler::operationIsAvailable('content_addlocation')) {
         $operationResult = eZOperationHandler::execute('content', 'addlocation', array('node_id' => $nodeID, 'object_id' => $objectID, 'select_node_id_array' => $selectedNodeIDArray), null, true);
     } else {
         eZContentOperationCollection::addAssignment($nodeID, $objectID, $selectedNodeIDArray);
     }
 } else {
     if ($module->isCurrentAction('SelectAssignmentLocation')) {
         $ignoreNodesSelect = array();
         $ignoreNodesClick = array();
         $assigned = eZNodeAssignment::fetchForObject($objectID, $object->attribute('current_version'), 0, false);
         $publishedAssigned = $object->assignedNodes(false);
         $isTopLevel = false;
        $discountRuleName = ezpI18n::tr( 'design/admin/shop/discountruleedit', 'New discount rule' );
        $discountRulePercent = 0.0;
        $discountRuleSelectedClasses = array( -1 );
        $discountRuleSelectedSections = array( -1 );
        $discountRuleSelectedProducts = array();

        $discountRule = array( 'id' => 0,
                               'name' => $discountRuleName,
                               'discount_percent' => $discountRulePercent );
    }
}

if ( $module->isCurrentAction( 'FindProduct' ) )
{
    // returning from browse; add products to product list
    $result = eZContentBrowse::result( 'FindProduct' );
    if ( $result )
    {
        $discountRuleSelectedProducts = array_merge( $discountRuleSelectedProducts, $result );
        $discountRuleSelectedProducts = array_unique( $discountRuleSelectedProducts );
    }
}

if ( $http->hasPostVariable( 'DeleteProductButton' ) )
{
    // remove products from list:
    if ( $http->hasPostVariable( 'DeleteProductIDArray' ) )
    {
        $deletedIDList = $http->postVariable( 'DeleteProductIDArray' );
        $arrayKeys = array_keys( $discountRuleSelectedProducts );
Beispiel #7
0
function checkNodeMovements( $module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage, $FromLanguage, &$validation )
{
    $http = eZHTTPTool::instance();

    // If the object has been previously published we do not allow node assignment operations
    if ( $object->attribute( 'status' ) != eZContentObject::STATUS_DRAFT )
    {
        return;
    }

    // If node assignment handling is diabled we return immedieately
    $useNodeAssigments = true;
    if ( $http->hasPostVariable( 'UseNodeAssigments' ) )
        $useNodeAssigments = (bool)$http->postVariable( 'UseNodeAssigments' );

    if ( !$useNodeAssigments )
        return;

    $ObjectID = $object->attribute( 'id' );
    // Move to another node
    if ( $module->isCurrentAction( 'MoveNodeAssignment' ) )
    {
        $selectedNodeIDArray = eZContentBrowse::result( 'MoveNodeAssignment' );
        $fromNodeID = $http->postVariable( "FromNodeID" );
        $oldAssignmentParentID = $http->postVariable( 'OldAssignmentParentID' );

        if ( $selectedNodeIDArray != null )
        {
            $assignedNodes = $version->nodeAssignments();
            $assignedIDArray = array();
            foreach ( $assignedNodes as  $assignedNode )
            {
                $assignedNodeID = $assignedNode->attribute( 'parent_node' );
                $assignedIDArray[] = $assignedNodeID;
            }
            foreach ( $selectedNodeIDArray as $nodeID )
            {
                if ( !in_array( $nodeID, $assignedIDArray ) )
                {
                    $isPermitted = true;
                    // Check access
                    $newNode = eZContentObjectTreeNode::fetch( $nodeID );
                    $newNodeObject = $newNode->attribute( 'object' );

                    $canCreate = $newNodeObject->checkAccess( 'create', $class->attribute( 'id' ), $newNodeObject->attribute( 'contentclass_id' ) ) == 1;
                    eZDebug::writeDebug( $canCreate,"can create");
                    if ( !$canCreate )
                    {
                        $isPermitted = false;
                    }
                    else
                    {
                        $canCreateClassList = $newNodeObject->attribute( 'can_create_class_list' );
                        $canCreateClassIDList = array();
                        foreach ( array_keys( $canCreateClassList ) as $key )
                        {
                            $canCreateClassIDList[] = $canCreateClassList[$key]['id'];
                        }
                        $objectClassID = $object->attribute( 'contentclass_id' );
                        if ( !in_array( $objectClassID, $canCreateClassIDList ) )
                             $isPermitted = false;
                    }
                    if ( !$isPermitted )
                    {
                        eZDebug::writeError( $newNode->pathWithNames(), "You are not allowed to place this object under:" );
                        $validation[ 'placement' ][] = array( 'text' => ezpI18n::tr( 'kernel/content', "You are not allowed to place this object under: %1", null, array( $newNode->pathWithNames() ) ) );
                        $validation[ 'processed' ] = true;
                        // Error message.
                    }
                    else
                    {
                        $oldAssignment = eZPersistentObject::fetchObject( eZNodeAssignment::definition(),
                                                                           null,
                                                                           array( 'contentobject_id' => $object->attribute( 'id' ),
                                                                                  'parent_node' => $oldAssignmentParentID,
                                                                                  'contentobject_version' => $version->attribute( 'version' )
                                                                                  ),
                                                                           true );

                        $realNode = eZContentObjectTreeNode::fetchNode( $version->attribute( 'contentobject_id' ), $oldAssignment->attribute( 'parent_node' ) );

                        $db = eZDB::instance();
                        $db->begin();
                        // No longer remove then add assignment, instead change the existing one
                        if ( $realNode  === null )
                        {
                            $fromNodeID = 0;
                        }
                        if ( $oldAssignment->attribute( 'is_main' ) == '1' )
                        {
                            $oldAssignment->setAttribute( 'parent_node', $nodeID );
                            $oldAssignment->setAttribute( 'is_main', 1 );
                            $oldAssignment->setAttribute( 'from_node_id', $fromNodeID );
//                            $version->assignToNode( $nodeID, 1, $fromNodeID, $oldAssignment->attribute( 'sort_field' ), $oldAssignment->attribute( 'sort_order' ) );
                        }
                        else
                        {
                            $oldAssignment->setAttribute( 'parent_node', $nodeID );
                            $oldAssignment->setAttribute( 'is_main', 0 );
                            $oldAssignment->setAttribute( 'from_node_id', $fromNodeID );
//                            $version->assignToNode( $nodeID, 0, $fromNodeID, $oldAssignment->attribute( 'sort_field' ), $oldAssignment->attribute( 'sort_order' ) );
                        }
                        $oldAssignment->setAttribute( 'op_code', eZNodeAssignment::OP_CODE_MOVE );
                        $oldAssignment->store();
                        //$version->removeAssignment( $oldAssignmentParentID );
                        $db->commit();
                    }
                }
            }
        }
    }
}
    }
    if ( $http->hasPostVariable( 'NeedRedirectBack' ) )
    {
        return $Module->redirectTo( $http->postVariable( 'RedirectURI', $http->sessionVariable( 'LastAccessesURI', '/' ) ) );
    }
}
else if ( $Module->isCurrentAction( 'Add' )  )
{
    return eZContentBrowse::browse( array( 'action_name' => 'AddBookmark',
                                           'description_template' => 'design:content/browse_bookmark.tpl',
                                           'from_page' => "/content/bookmark" ),
                                    $Module );
}
else if ( $Module->isCurrentAction( 'AddBookmark' )  )
{
    $nodeList = eZContentBrowse::result( 'AddBookmark' );
    if ( $nodeList )
    {
        $db = eZDB::instance();
        $db->begin();
        foreach ( $nodeList as $nodeID )
        {
            $node = eZContentObjectTreeNode::fetch( $nodeID );
            if ( $node )
            {
                $nodeName = $node->attribute( 'name' );
                eZContentBrowseBookmark::createNew( $userID, $nodeID, $nodeName );
            }
        }
        $db->commit();
    }
Beispiel #9
0
{
    $section = eZSection::fetch( $SectionID );
    if ( !is_object( $section ) )
    {
        eZDebug::writeError( "Cannot fetch section (ID = $SectionID).", 'section/assign' );
    }
    else
    {
        $currentUser = eZUser::currentUser();

        if ( $currentUser->canAssignSection( $SectionID ) )
        {
            if ( $Module->isCurrentAction( 'AssignSection' ) )
            {   // Assign section to subtree of node

                $selectedNodeIDArray = eZContentBrowse::result( 'AssignSection' );
                if ( is_array( $selectedNodeIDArray ) and count( $selectedNodeIDArray ) > 0 )
                {
                    $nodeList = eZContentObjectTreeNode::fetch( $selectedNodeIDArray );
                    if ( !is_array( $nodeList ) and is_object( $nodeList ) )
                    {
                        $nodeList = array( $nodeList );
                    }

                    $allowedNodeIDList = array();
                    $deniedNodeIDList = array();
                    foreach ( $nodeList as $node )
                    {
                        $nodeID = $node->attribute( 'node_id' );
                        $object = $node->attribute( 'object' );
                        if ( $currentUser->canAssignSectionToObject( $SectionID, $object ) )
Beispiel #10
0
        $db = eZDB::instance();
        $db->begin();
        foreach ($deleteIDArray as $deleteID) {
            eZRole::removeRole($deleteID);
        }
        // Clear role caches.
        eZRole::expireCache();
        // Clear all content cache.
        eZContentCacheManager::clearAllContentCache();
        $db->commit();
    }
}
// Redirect to content node browse in the user tree
// Assign the role for a user or group
if ($Module->isCurrentAction('AssignRole')) {
    $selectedObjectIDArray = eZContentBrowse::result('AssignRole');
    foreach ($selectedObjectIDArray as $objectID) {
        $role->assignToUser($objectID);
    }
    // Clear role caches.
    eZRole::expireCache();
    // Clear all content cache.
    eZContentCacheManager::clearAllContentCache();
}
if ($http->hasPostVariable('NewButton')) {
    $role = eZRole::createNew();
    return $Module->redirectToView('edit', array($role->attribute('id')));
}
$viewParameters = array('offset' => $offset);
$tpl = eZTemplate::factory();
$roles = eZRole::fetchByOffset($offset, $limit, $asObject = true, $ignoreTemp = true);
 function customClassAttributeHTTPAction($http, $action, $classAttribute)
 {
     switch ($action) {
         case 'browse_for_placement':
             $module = $classAttribute->currentModule();
             $customActionName = 'CustomActionButton[' . $classAttribute->attribute('id') . '_browsed_for_placement]';
             eZContentBrowse::browse(array('action_name' => 'SelectObjectRelationListNode', 'content' => array('contentclass_id' => $classAttribute->attribute('contentclass_id'), 'contentclass_attribute_id' => $classAttribute->attribute('id'), 'contentclass_version' => $classAttribute->attribute('version'), 'contentclass_attribute_identifier' => $classAttribute->attribute('identifier')), 'persistent_data' => array($customActionName => '', 'ContentClassHasInput' => false), 'description_template' => 'design:class/datatype/browse_objectrelationlist_placement.tpl', 'from_page' => $module->currentRedirectionURI()), $module);
             break;
         case 'browsed_for_placement':
             $nodeSelection = eZContentBrowse::result('SelectObjectRelationListNode');
             if ($nodeSelection and count($nodeSelection) > 0) {
                 $nodeID = $nodeSelection[0];
                 $content = $classAttribute->content();
                 $content['default_placement'] = array('node_id' => $nodeID);
                 $classAttribute->setContent($content);
             }
             break;
         case 'disable_placement':
             $content = $classAttribute->content();
             $content['default_placement'] = false;
             $classAttribute->setContent($content);
             break;
         default:
             eZDebug::writeError("Unknown objectrelationlist action '{$action}'", __METHOD__);
             break;
     }
 }
Beispiel #12
0
// ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
//
$http = eZHTTPTool::instance();
$module = $Params["Module"];
$NodeID = $Params['NodeID'];
$exportTypeParam = $Params['ExportType'];
$tpl = eZTemplate::factory();
$success = true;
if ($http->hasPostVariable("ExportButton")) {
    eZContentBrowse::browse(array('action_name' => 'OOPlace', 'description_template' => 'design:ezodf/browse_place.tpl', 'content' => array(), 'from_page' => '/ezodf/export/', 'cancel_page' => '/ezodf/export/'), $module);
    return;
}
$doExport = false;
if ($module->isCurrentAction('OOPlace')) {
    // We have the file and the placement. Do the actual import.
    $selectedNodeIDArray = eZContentBrowse::result('OOPlace');
    $nodeID = $selectedNodeIDArray[0];
    $doExport = true;
}
if ($http->hasPostVariable("NodeID")) {
    $nodeID = $http->postVariable("NodeID");
    $doExport = true;
} else {
    if (is_numeric($NodeID)) {
        $nodeID = $NodeID;
        $doExport = true;
    }
}
$exportType = false;
if ($http->hasPostVariable("ExportType")) {
    $type = $http->postVariable("ExportType");
Beispiel #13
0
function chooseObjectVersionsToCopy($Module, &$Result, $object)
{
    $selectedNodeIDArray = eZContentBrowse::result($Module->currentAction());
    $tpl = eZTemplate::factory();
    $tpl->setVariable('object', $object);
    $tpl->setVariable('selected_node_id', $selectedNodeIDArray[0]);
    $Result['content'] = $tpl->fetch('design:content/copy.tpl');
    $Result['path'] = array(array('url' => false, 'text' => ezpI18n::tr('kernel/content', 'Content')), array('url' => false, 'text' => ezpI18n::tr('kernel/content', 'Copy')));
}
Beispiel #14
0
function chooseObjectVersionsToCopy($Module, &$Result, $object)
{
    $selectedNodeIDArray = eZContentBrowse::result($Module->currentAction());
    require_once 'kernel/common/template.php';
    $tpl = templateInit();
    $tpl->setVariable('object', $object);
    $tpl->setVariable('selected_node_id', $selectedNodeIDArray[0]);
    $Result['content'] = $tpl->fetch('design:content/copy.tpl');
    $Result['path'] = array(array('url' => false, 'text' => ezi18n('kernel/content', 'Content')), array('url' => false, 'text' => ezi18n('kernel/content', 'Copy')));
}