예제 #1
0
파일: Movie.php 프로젝트: robbrandt/MUVideo
 /**
  * Post-Process the data after an insert operation.
  *
  * @ORM\PostPersist
  * @see MUVideo_Entity_Movie::performPostPersistCallback()
  * @return void.
  */
 public function postPersistCallback()
 {
     $request = new Zikula_Request_Http();
     $func = $request->query->filter('func', 'main', FILTER_SANITIZE_STRING);
     if ($func == 'getVideos') {
         $id = $this->getId();
         $workflowHelper = new Zikula_Workflow('none', 'MUVideo');
         $obj['__WORKFLOW__']['obj_table'] = 'movie';
         $obj['__WORKFLOW__']['obj_idcolumn'] = 'id';
         $obj['id'] = $id;
         $workflowHelper->registerWorkflow($obj, 'approved');
     }
     $this->performPostPersistCallback();
 }
예제 #2
0
 /**
  * upgrade
  */
 public function upgrade($oldversion)
 {
     // Upgrade dependent on old version number
     switch ($oldversion) {
         case '2.4':
             $prefix = $this->serviceManager['prefix'];
             $connection = Doctrine_Manager::getInstance()->getConnection('default');
             $sql = 'RENAME TABLE ' . $prefix . '_' . 'reviews' . ' TO ' . 'reviews';
             $stmt = $connection->prepare($sql);
             try {
                 $stmt->execute();
             } catch (Exception $e) {
                 LogUtil::registerError($e);
             }
         case '2.4.1':
             try {
                 DoctrineHelper::updateSchema($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 extension.', array($this->getName())));
             }
             $repository = $this->getEntityManager()->getRepository('Reviews_Entity_Review');
             // we get all old entries
             $result = DBUtil::executeSQL('SELECT * FROM `reviews`');
             $reviews = $result->fetchAll(Doctrine::FETCH_ASSOC);
             $dom = ZLanguage::getModuleDomain($this->name);
             $workflowHelper = new Zikula_Workflow('standard', 'Reviews');
             // we get serviceManager
             $serviceManager = ServiceUtil::getManager();
             // we get entityManager
             $entityManager = $serviceManager->getService('doctrine.entitymanager');
             if (count($reviews) > 0) {
                 foreach ($reviews as $key => $review) {
                     $newReview = new Reviews_Entity_Review();
                     $newReview->setWorkflowState('approved');
                     $newReview->setTitle($review['pn_title']);
                     $newReview->setText($review['pn_text']);
                     if ($review['pn_reviewer'] != '') {
                         $newReview->setReviewer($review['pn_reviewer']);
                     } else {
                         $newReview->setReviewer(__('Unknown', $dom));
                     }
                     if ($review['pn_email'] != '') {
                         $newReview->setEmail($review['pn_email']);
                     } else {
                         $adminmail = UserUtil::getVar('email', 2);
                         $newReview->setEmail(__($adminmail));
                     }
                     $newReview->setScore($review['pn_score']);
                     $newReview->setCover($review['pn_cover']);
                     $newReview->setUrl($review['pn_url']);
                     $newReview->setUrl_title($review['pn_url_title']);
                     $newReview->setHits($review['pn_hits']);
                     $newReview->setZlanguage($review['pn_language']);
                     $createdDate = new Datetime($review['pn_cr_date']);
                     $newReview->setCreatedDate($createdDate);
                     $updatedDate = new DateTime($review['pn_lu_date']);
                     $newReview->setUpdatedDate($updatedDate);
                     $newReview->setCreatedUserId($review['pn_cr_uid']);
                     $newReview->setUpdatedUserId($review['pn_lu_uid']);
                     $entityManager->persist($newReview);
                     $entityManager->flush();
                 }
             }
             $result2 = DBUtil::executeSQL('SELECT * FROM `reviews_review`');
             $reviews2 = $result2->fetchAll(Doctrine::FETCH_ASSOC);
             // we set the workflow
             foreach ($reviews2 as $key => $review2) {
                 $obj['__WORKFLOW__']['obj_table'] = 'review';
                 $obj['__WORKFLOW__']['obj_idcolumn'] = 'id';
                 $obj['id'] = $review2['id'];
                 $workflowHelper->registerWorkflow($obj, 'approved');
             }
             // move relations from categories_mapobj to reviews_category
             // then delete old data
             $connection = $this->entityManager->getConnection();
             $sqls = array();
             $sqls[] = "INSERT INTO reviews_review_category (entityId, registryId, categoryId) SELECT obj_id, reg_id, category_id FROM categories_mapobj WHERE modname = 'Reviews' AND tablename = 'reviews'";
             $sqls[] = "DELETE FROM categories_mapobj WHERE modname = 'Reviews' AND tablename = 'reviews'";
             // update category registry data to change tablename to EntityName
             $sqls[] = "UPDATE categories_registry SET tablename = 'Review' WHERE tablename = 'reviews'";
             // do changes
             foreach ($sqls as $sql) {
                 $stmt = $connection->prepare($sql);
                 try {
                     $stmt->execute();
                 } catch (Exception $e) {
                     LogUtil::registerError($e->getMessage());
                 }
             }
             $pagesize = $this->getVar('itemsperpage');
             $this->setVar('pagesize', $pagesize);
             $this->delVar('itemsperpage');
             $this->setVar('scoreForUsers', false);
             $addcategorytitletopermalink = $this->getVar('addcategorytitletopermalink');
             $this->setVar('addcategorytitletopermalink');
             // register persistent event handlers
             $this->registerPersistentEventHandlers();
             // register hook subscriber bundles
             HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles());
             DBUtil::dropTable('reviews');
         case '2.5.0':
             // later upgrades
     }
     // upgrade successful
     return true;
 }
예제 #3
0
파일: Util.php 프로젝트: Silwereth/core
 /**
  * Execute action.
  *
  * @param string $schema Name of workflow schema.
  * @param array  &$obj     Data object.
  * @param string $actionID Action to perform.
  * @param string $table    Table where data will be stored (default = null).
  * @param string $module   Name of module (defaults calling module).
  * @param string $idcolumn ID column of table.
  *
  * @return mixed
  */
 public static function executeAction($schema, &$obj, $actionID, $table = null, $module = null, $idcolumn = 'id')
 {
     if (!isset($obj)) {
         throw new \Exception(__f('%1$s: %2$s not set.', array('Zikula_Workflow_Util', 'obj')));
     }
     if (!is_array($obj) && !is_object($obj)) {
         throw new \Exception(__f('%1$s: %2$s must be an array or an object.', array('Zikula_Workflow_Util', 'obj')));
     }
     if (empty($schema)) {
         throw new \Exception(__f('%1$s: %2$s needs to be named', array('Zikula_Workflow_Util', 'schema')));
     }
     if (is_null($module)) {
         // default to calling module
         $module = ModUtil::getName();
     }
     $stateID = self::getWorkflowState($obj, $table, $idcolumn, $module);
     if (!$stateID) {
         $stateID = 'initial';
     }
     // instanciate workflow
     $workflow = new Zikula_Workflow($schema, $module);
     return $workflow->executeAction($actionID, $obj, $stateID);
 }
예제 #4
0
 public function __construct($schema, $module)
 {
     parent::__construct($schema, $module);
     LogUtil::log(__f('Warning! Class %1$s is deprecated. Please use %2$s instead.', array(__CLASS__ , 'Zikula_Workflow')), E_USER_DEPRECATED);
 }