} // Check for redirection to current page if ($module->hasActionParameter('UploadRedirectBack')) { if ($module->actionParameter('UploadRedirectBack') == 1) { $parameters['result_uri'] = eZRedirectManager::redirectURI($module, 'content/view/full/2', true); } else { if ($module->actionParameter('UploadRedirectBack') == 2) { $parameters['result_uri'] = eZRedirectManager::redirectURI($module, 'content/view/full/2', false); } } } // Check for redirection to specific page if ($module->hasActionParameter('UploadRedirectURI')) { $parameters['result_uri'] = $module->actionParameter('UploadRedirectURI'); } eZContentUpload::upload($parameters, $module); return; } else { if (!isset($result)) { return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel'); } } } } } } } } } } }
function checkRelationActions($module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage) { $http = eZHTTPTool::instance(); if ($module->isCurrentAction('BrowseForObjects')) { $objectID = $object->attribute('id'); $assignedNodes = $object->attribute('assigned_nodes'); $assignedNodesIDs = array(); foreach ($assignedNodes as $node) { $assignedNodesIDs = $node->attribute('node_id'); } unset($assignedNodes); eZContentBrowse::browse(array('action_name' => 'AddRelatedObject', 'description_template' => 'design:content/browse_related.tpl', 'content' => array('object_id' => $objectID, 'object_version' => $editVersion, 'object_language' => $editLanguage), 'keys' => array('class' => $class->attribute('id'), 'class_id' => $class->attribute('identifier'), 'classgroup' => $class->attribute('ingroup_id_list'), 'section' => $object->attribute('section_id')), 'ignore_nodes_select' => $assignedNodesIDs, 'from_page' => $module->redirectionURI('content', 'edit', array($objectID, $editVersion, $editLanguage, $fromLanguage))), $module); return eZModule::HOOK_STATUS_CANCEL_RUN; } if ($module->isCurrentAction('UploadFileRelation')) { $objectID = $object->attribute('id'); $section = eZSection::fetch($object->attribute('section_id')); $navigationPart = false; if ($section) { $navigationPart = $section->attribute('navigation_part_identifier'); } $location = false; if ($module->hasActionParameter('UploadRelationLocation')) { $location = $module->actionParameter('UploadRelationLocation'); } // We only do direct uploading if we have the uploaded HTTP file // if not we need to go to the content/upload page. if (eZHTTPFile::canFetch('UploadRelationFile')) { $upload = new eZContentUpload(); if ($upload->handleUpload($result, 'UploadRelationFile', $location, false)) { $relatedObjectID = $result['contentobject_id']; if ($relatedObjectID) { $db = eZDB::instance(); $db->begin(); $object->addContentObjectRelation($relatedObjectID, $editVersion); $db->commit(); } } } else { eZContentUpload::upload(array('action_name' => 'RelatedObjectUpload', 'description_template' => 'design:content/upload_related.tpl', 'navigation_part_identifier' => $navigationPart, 'content' => array('object_id' => $objectID, 'object_version' => $editVersion, 'object_language' => $editLanguage), 'keys' => array('class' => $class->attribute('id'), 'class_id' => $class->attribute('identifier'), 'classgroup' => $class->attribute('ingroup_id_list'), 'section' => $object->attribute('section_id')), 'result_action_name' => 'UploadedFileRelation', 'ui_context' => 'edit', 'result_module' => array('content', 'edit', array($objectID, $editVersion, $editLanguage, $fromLanguage))), $module); return eZModule::HOOK_STATUS_CANCEL_RUN; } } if ($module->isCurrentAction('DeleteRelation')) { $objectID = $object->attribute('id'); if ($http->hasPostVariable('DeleteRelationIDArray')) { $relationObjectIDs = $http->postVariable('DeleteRelationIDArray'); } else { $relationObjectIDs = array(); } $db = eZDB::instance(); $db->begin(); foreach ($relationObjectIDs as $relationObjectID) { $object->removeContentObjectRelation($relationObjectID, $editVersion); } $db->commit(); } if ($module->isCurrentAction('NewObject')) { if ($http->hasPostVariable('ClassID')) { if ($http->hasPostVariable('SectionID')) { $sectionID = $http->postVariable('SectionID'); } else { $sectionID = 0; /* Will be changed later */ } $contentClassID = $http->postVariable('ClassID'); $class = eZContentClass::fetch($contentClassID); $db = eZDB::instance(); $db->begin(); $relatedContentObject = $class->instantiate(false, $sectionID); $db->commit(); $newObjectID = $relatedContentObject->attribute('id'); $relatedContentVersion = $relatedContentObject->attribute('current'); if ($relatedContentObject->attribute('can_edit')) { $db = eZDB::instance(); $db->begin(); $assignmentHandler = new eZContentObjectAssignmentHandler($relatedContentObject, $relatedContentVersion); $sectionID = (int) $assignmentHandler->setupAssignments(array('group-name' => 'RelationAssignmentSettings', 'default-variable-name' => 'DefaultAssignment', 'specific-variable-name' => 'ClassSpecificAssignment', 'section-id-wanted' => true, 'fallback-node-id' => $object->attribute('main_node_id'))); $http->setSessionVariable('ParentObject', array($object->attribute('id'), $editVersion, $editLanguage)); $http->setSessionVariable('NewObjectID', $newObjectID); /* Change section ID to the same one as the main node placement */ $db->query("UPDATE ezcontentobject SET section_id = {$sectionID} WHERE id = {$newObjectID}"); $db->commit(); $module->redirectToView('edit', array($relatedContentObject->attribute('id'), $relatedContentObject->attribute('current_version'), false)); } else { $db = eZDB::instance(); $db->begin(); $relatedContentObject->purge(); $db->commit(); } return; } } }