public function trigger() { $page = Page::getByID($this->cID); $pk = PermissionKey::getByID($this->pkID); $pk->setPermissionObject($page); return parent::triggerRequest($pk); }
/** * Override the runTask method in order to launch the cancel function * correctly (to trigger user deletion for instance) */ public function runTask($task, WorkflowProgress $wp) { $wpr = parent::runTask($task, $wp); if (!is_object($wpr) && method_exists($this, $task)) { if ($task == 'cancel') { // we check to see if any other outstanding workflowprogress requests have this id // if they don't we proceed $db = Loader::db(); $num = $db->GetOne('select count(wpID) as total from WorkflowProgress where wpID <> ? and wrID = ? and wpIsCompleted = 0', array($wp->getWorkflowProgressID(), $this->getWorkflowRequestID())); if ($num == 0) { $wpr = call_user_func_array(array($this, $task), array($wp)); return $wpr; } } } return $wpr; }
public function validateTrigger(WorkflowRequest $req) { // Check if the current workflow request is not already deleted $wr = $req::getByID($req->getWorkflowRequestID()); if (is_object($wr)) { return true; } return false; }
/** * Creates a WorkflowProgress object (which will be assigned to a Page, File, etc... in our system. * * @param string $wpCategoryHandle * @param Workflow $wf * @param WorkflowRequest $wr * * @return self */ public static function create($wpCategoryHandle, Workflow $wf, WorkflowRequest $wr) { $db = Database::connection(); $wpDateAdded = Core::make('helper/date')->getOverridableNow(); $wpCategoryID = $db->fetchColumn('select wpCategoryID from WorkflowProgressCategories where wpCategoryHandle = ?', array($wpCategoryHandle)); $db->executeQuery('insert into WorkflowProgress (wfID, wrID, wpDateAdded, wpCategoryID) values (?, ?, ?, ?)', array($wf->getWorkflowID(), $wr->getWorkflowRequestID(), $wpDateAdded, $wpCategoryID)); $wp = self::getByID($db->lastInsertId()); $wp->addWorkflowProgressHistoryObject($wr); return $wp; }
/** * Creates a WorkflowProgress object (which will be assigned to a Page, File, etc... in our system. * * @param string $wpCategoryHandle * @param Workflow $wf * @param WorkflowRequest $wr * * @return self */ public static function create($wpCategoryHandle, Workflow $wf, WorkflowRequest $wr) { $db = Database::connection(); $wpDateAdded = Core::make('helper/date')->getOverridableNow(); $wpCategoryID = $db->fetchColumn('select wpCategoryID from WorkflowProgressCategories where wpCategoryHandle = ?', array($wpCategoryHandle)); $db->executeQuery('insert into WorkflowProgress (wfID, wrID, wpDateAdded, wpCategoryID) values (?, ?, ?, ?)', array($wf->getWorkflowID(), $wr->getWorkflowRequestID(), $wpDateAdded, $wpCategoryID)); $wp = self::getByID($db->lastInsertId()); $wp->addWorkflowProgressHistoryObject($wr); if (!$wf instanceof EmptyWorkflow) { $application = \Core::getFacadeApplication(); $type = $application->make('manager/notification/types')->driver('workflow_progress'); $notifier = $type->getNotifier(); $subscription = $type->getSubscription($wp); $notified = $notifier->getUsersToNotify($subscription, $wp); $notification = $type->createNotification($wp); $notifier->notify($notified, $notification); } return $wp; }
/** * Creates a WorkflowProgress object (which will be assigned to a Page, File, etc... in our system. */ public static function add($wpCategoryHandle, Workflow $wf, WorkflowRequest $wr) { $db = Loader::db(); $wpDateAdded = Loader::helper('date')->getOverridableNow(); $wpCategoryID = $db->GetOne('select wpCategoryID from WorkflowProgressCategories where wpCategoryHandle = ?', array($wpCategoryHandle)); $db->Execute('insert into WorkflowProgress (wfID, wrID, wpDateAdded, wpCategoryID) values (?, ?, ?, ?)', array($wf->getWorkflowID(), $wr->getWorkflowRequestID(), $wpDateAdded, $wpCategoryID)); $wp = self::getByID($db->Insert_ID()); $wp->addWorkflowProgressHistoryObject($wr); return $wp; }