public function __construct(Step $step, $userIds = []) { $this->step = $step; $this->userIds = $userIds; $this->details = ['unlock' => ['path' => $step->getPath()->getId(), 'step' => $step->getId(), 'stepname' => $step->getName()]]; parent::__construct($step->getPath()->getResourceNode(), $this->details); }
public function getParentsSecondaryResources() { $resources = []; if (!empty($this->parent)) { if (!empty($this->parent->parameters)) { $parameters = $this->parent->parameters; } elseif (!empty($this->parent->activity)) { $parameters = $this->parent->activity->getParameters(); } if (!empty($parameters)) { $resources = $parameters->getSecondaryResources()->toArray(); } // Jump to parent $parentResources = $this->parent->getParentsSecondaryResources(); if (!empty($parentResources)) { $resources = array_merge($resources, $parentResources); } } return $resources; }
/** * Transform Step data to export it * @param \Innova\PathBundle\Entity\Step $step * @return array */ public function export(Step $step) { $parent = $step->getParent(); $activity = $step->getActivity(); $data = array('uid' => $step->getId(), 'parent' => !empty($parent) ? $parent->getId() : null, 'activityId' => !empty($activity) ? $activity->getId() : null, 'activityNodeId' => !empty($activity) ? $activity->getResourceNode()->getId() : null, 'order' => $step->getOrder(), 'lvl' => $step->getLvl(), 'inheritedResources' => array()); $inheritedResources = $step->getInheritedResources(); foreach ($inheritedResources as $inherited) { $data['inheritedResources'][] = array('resource' => $inherited->getResource()->getId(), 'lvl' => $inherited->getLvl()); } return $data; }
public function jsonSerialize() { return array('id' => $this->id, 'userId' => $this->user->getId(), 'stepId' => $this->step->getId(), 'status' => $this->status, 'authorized' => $this->authorized); }
public function jsonSerialize() { return ['id' => $this->id, 'userId' => $this->user instanceof User ? $this->user->getId() : 0, 'stepId' => $this->step->getId(), 'status' => $this->status, 'authorized' => $this->authorized, 'locked' => $this->locked, 'lockedcall' => $this->lockedcall]; }
/** * Set step * * @param \Innova\PathBundle\Entity\Step $step * * @return StepCondition */ public function setStep(\Innova\PathBundle\Entity\Step $step = null) { if ($step !== $this->step) { $this->step = $step; if (null !== $step) { $step->setCondition($this); } } return $this; }
/** * Clean conditions data which no long exist in the current path * * @param array $neededCondition * @param array $existingCondition * @param Step $step * @return PublishingManager */ protected function cleanCondition($neededCondition = null, $existingCondition = null, Step $step) { //echo "inside cleanCondition<br>\n"; //echo "typeof(existingData)";var_dump(is_object($existingCondition));//echo "<br>\ntypeof(neededData)";var_dump(is_object($neededCondition)); if ($existingCondition->getId() != $neededCondition->getId()) { $step->setCondition(null); $this->om->remove($neededCondition); } return $this; }
public function updateParameters(Step $step, \stdClass $stepStructure) { $parameters = $step->getParameters(); if (empty($parameters)) { $parameters = new ActivityParameters(); } // Update parameters properties $duration = !empty($stepStructure->duration) ? $stepStructure->duration : null; $parameters->setMaxDuration($duration); $withTutor = !empty($stepStructure->withTutor) ? $stepStructure->withTutor : false; $parameters->setWithTutor($withTutor); $who = !empty($stepStructure->who) ? $stepStructure->who : null; $parameters->setWho($who); $where = !empty($stepStructure->where) ? $stepStructure->where : null; $parameters->setWhere($where); // Set resources $this->updateSecondaryResources($parameters, $stepStructure); // Persist parameters to generate ID $this->om->persist($parameters); // Store parameters in Step $step->setParameters($parameters); return $this; }
/** * Set parent * @param \Innova\PathBundle\Entity\Step $parent * @return \Innova\PathBundle\Entity\Step */ public function setParent(Step $parent = null) { if ($parent != $this->parent) { $this->parent = $parent; $parent->addChild($this); } return $this; }
/** * Manage resource inheritance * @param \Innova\PathBundle\Entity\Step $step * @param array $propagatedResources * @param array $excludedResources * @return \Innova\PathBundle\Manager\PublishingManager */ protected function publishPropagatedResources(Step $step, array $propagatedResources = array(), array $excludedResources = array()) { $inheritedResources = array(); $currentInherited = $step->getInheritedResources(); if (!empty($propagatedResources)) { foreach ($propagatedResources as $resource) { if (!in_array($resource['id'], $excludedResources)) { // Resource is not excluded => link it to step // Retrieve resource node $resourceNode = $this->om->getRepository('ClarolineCoreBundle:Resource\\ResourceNode')->findOneById($resource['resourceId']); if (!($inherited = $step->hasInheritedResource($resourceNode->getId()))) { // Inherited resource doesn't exist => Create inherited resource $inherited = new InheritedResource(); } // Update inherited resource properties $inherited->setResource($resourceNode); $inherited->setLvl($resource['lvl']); // Add inherited resource to Step $step->addInheritedResource($inherited); $this->om->persist($inherited); // Store resource ID to clean step $inheritedResources[] = $resourceNode->getId(); } } } // Clean inherited resources which no long exists foreach ($currentInherited as $inherited) { $resourceId = $inherited->getResource()->getId(); if (!in_array($resourceId, $inheritedResources)) { $step->removeInheritedResource($inherited); $this->om->remove($inherited); } } return $this; }
/** * @param Step $step * * @return \Symfony\Component\HttpFoundation\JsonResponse * @Route( * "/stepunlock/{step}", * name = "innova_path_step_callforunlock", * options = { "expose" = true } * ) * @Method("GET") */ public function callForUnlock(Step $step) { //array of user id to send the notification to = users who will receive the call : the path creator $creator = $step->getPath()->getCreator()->getId(); $userIds = [$creator]; //create an event, and pass parameters $event = new LogStepUnlockEvent($step, $userIds); //send the event to the event dispatcher $this->eventDispatcher->dispatch('log', $event); //update lockedcall value : set to true = called $user = $this->securityToken->getToken()->getUser(); $progression = $this->userProgressionManager->updateLockedState($user, $step, true, null, null, ''); //return response return new JsonResponse($progression); }