Example #1
0
 /**
  * Uninstall Reviews.
  *
  * @return boolean True on success, false otherwise.
  */
 public function uninstall()
 {
     // delete stored object workflows
     $result = Zikula_Workflow_Util::deleteWorkflowsForModule($this->getName());
     if ($result === false) {
         return LogUtil::registerError($this->__f('An error was encountered while removing stored object workflows for the %s extension.', array($this->getName())));
     }
     try {
         DoctrineHelper::dropSchema($this->entityManager, $this->listEntityClasses());
     } catch (\Exception $e) {
         if (System::isDevelopmentMode()) {
             return LogUtil::registerError($this->__('Doctrine Exception: ') . $e->getMessage());
         }
         return LogUtil::registerError($this->__f('An error was encountered while dropping tables for the %s extension.', array($this->name)));
     }
     // unregister persistent event handlers
     EventUtil::unregisterPersistentModuleHandlers($this->name);
     // unregister hook subscriber bundles
     HookUtil::unregisterSubscriberBundles($this->version->getHookSubscriberBundles());
     // remove all module vars
     $this->delVars();
     // remove category registry entries
     ModUtil::dbInfoLoad('Categories');
     DBUtil::deleteWhere('categories_registry', 'modname = \'' . $this->name . '\'');
     // remove all thumbnails
     $manager = $this->getServiceManager()->getService('systemplugin.imagine.manager');
     $manager->setModule($this->name);
     $manager->cleanupModuleThumbs();
     // remind user about upload folders not being deleted
     $uploadPath = FileUtil::getDataDirectory() . '/' . $this->name . '/';
     LogUtil::registerStatus($this->__f('The upload directories at [%s] can be removed manually.', $uploadPath));
     // uninstallation successful
     return true;
 }
Example #2
0
 /**
  * Sets/retrieves the workflow details.
  *
  * @param boolean $forceLoading load the workflow record.
  */
 public function initWorkflow($forceLoading = false)
 {
     $currentFunc = FormUtil::getPassedValue('func', 'main', 'GETPOST', FILTER_SANITIZE_STRING);
     $isReuse = FormUtil::getPassedValue('astemplate', '', 'GETPOST', FILTER_SANITIZE_STRING);
     // apply workflow with most important information
     $idColumn = 'id';
     $serviceManager = ServiceUtil::getManager();
     $workflowHelper = new MUVideo_Util_Workflow($serviceManager);
     $schemaName = $workflowHelper->getWorkflowName($this['_objectType']);
     $this['__WORKFLOW__'] = array('module' => 'MUVideo', 'state' => $this['workflowState'], 'obj_table' => $this['_objectType'], 'obj_idcolumn' => $idColumn, 'obj_id' => $this[$idColumn], 'schemaname' => $schemaName);
     // load the real workflow only when required (e. g. when func is edit or delete)
     if (!in_array($currentFunc, array('main', 'view', 'display')) && empty($isReuse) || $forceLoading) {
         $result = Zikula_Workflow_Util::getWorkflowForObject($this, $this['_objectType'], $idColumn, 'MUVideo');
         if (!$result) {
             $dom = ZLanguage::getModuleDomain('MUVideo');
             LogUtil::registerError(__('Error! Could not load the associated workflow.', $dom));
         }
     }
     if (!is_object($this['__WORKFLOW__']) && !isset($this['__WORKFLOW__']['schemaname'])) {
         $workflow = $this['__WORKFLOW__'];
         $workflow['schemaname'] = $schemaName;
         $this['__WORKFLOW__'] = $workflow;
     }
 }
Example #3
0
 /**
  * Execute workflow operation within action.
  *
  * @param string $operation Operation name.
  * @param array  &$obj       Data object.
  * @param string &$nextState Next state.
  *
  * @return mixed|false
  */
 public function executeOperation($operation, &$obj, &$nextState)
 {
     $params = $operation['parameters'];
     if (isset($params['nextstate'])) {
         $nextState = $params['nextstate'];
     }
     $params['nextstate'] = $nextState;
     // test operation file exists
     $path = Zikula_Workflow_Util::_findpath("operations/function.{$operation['name']}.php", $this->module);
     if (!$path) {
         throw new \Exception(__f('Operation file [%s] does not exist', $operation['name']));
     }
     // load file and test if function exists
     include_once $path;
     $function = "{$this->module}_operation_{$operation['name']}";
     if (!function_exists($function)) {
         throw new \Exception(__f('Operation function [%s] is not defined', $function));
     }
     // execute operation and return result
     $result = $function($obj, $params);
     $states = array_keys($this->stateMap);
     // checks for an invalid next state value
     if (!in_array($params['nextstate'], $states)) {
         LogUtil::addErrorPopup(__f('Invalid next-state value [%1$s] retrieved by the \'%2$s\' operation for the workflow \'%3$s\' [\'%4$s\'].', array($nextState, $operation, $this->getID(), $this->getModule())));
     } else {
         $nextState = $params['nextstate'];
     }
     return $result;
 }
Example #4
0
 /**
  * Executes a certain workflow action for a given entity object.
  *
  * @param \Zikula_EntityAccess $entity   The given entity instance.
  * @param string               $actionId Name of action to be executed.
  * @param bool                 $recursive true if the function called itself.  
  *
  * @return bool False on error or true if everything worked well.
  */
 public function executeAction($entity, $actionId = '', $recursive = false)
 {
     $objectType = $entity['_objectType'];
     $schemaName = $this->getWorkflowName($objectType);
     $entity->initWorkflow(true);
     $idcolumn = $entity['__WORKFLOW__']['obj_idcolumn'];
     $result = Zikula_Workflow_Util::executeAction($schemaName, $entity, $actionId, $objectType, $this->name, $idcolumn);
     if ($result !== false && !$recursive) {
         $entities = $entity->getRelatedObjectsToPersist();
         foreach ($entities as $rel) {
             if ($rel->getWorkflowState() == 'initial') {
                 $this->executeAction($rel, $actionId, true);
             }
         }
     }
     return $result !== false;
 }
Example #5
0
 /**
  * Uninstall MUBoard.
  *
  * @return boolean True on success, false otherwise.
  */
 public function uninstall()
 {
     // delete stored object workflows
     $result = Zikula_Workflow_Util::deleteWorkflowsForModule($this->getName());
     if ($result === false) {
         return LogUtil::registerError($this->__f('An error was encountered while removing stored object workflows for the %s module.', array($this->getName())));
     }
     try {
         DoctrineHelper::dropSchema($this->entityManager, $this->listEntityClasses());
     } catch (Exception $e) {
         if (System::isDevelopmentMode()) {
             LogUtil::registerError($this->__('Doctrine Exception: ') . $e->getMessage());
         }
         return LogUtil::registerError($this->__f('An error was encountered while dropping the tables for the %s module.', array($this->getName())));
     }
     // unregister persistent event handlers
     EventUtil::unregisterPersistentModuleHandlers('MUBoard');
     // unregister hook subscriber bundles
     HookUtil::unregisterSubscriberBundles($this->version->getHookSubscriberBundles());
     // remove all module vars
     $this->delVars();
     // deletion successful
     return true;
 }