/** * * @param <type> $request */ public function execute($request) { $this->setForm(new CopyActivityForm()); $projectId = $request->getParameter('projectId'); $this->form->bind($request->getParameter($this->form->getName())); $projectActivityList = $this->getProjectService()->getActivityListByProjectId($projectId); if ($this->form->isValid()) { $activityNameList = $request->getParameter('activityNames', array()); $activities = new Doctrine_Collection('ProjectActivity'); $isUnique = true; foreach ($activityNameList as $activityName) { foreach ($projectActivityList as $projectActivity) { if (strtolower($activityName) == strtolower($projectActivity->getName())) { $isUnique = false; break; } } } if ($isUnique) { foreach ($activityNameList as $activityName) { $activity = new ProjectActivity(); $activity->setProjectId($projectId); $activity->setName($activityName); $activity->setIsDeleted(ProjectActivity::ACTIVE_PROJECT); $activities->add($activity); } $activities->save(); $this->getUser()->setFlash('templateMessageAct', array('success', __('Successfully Copied'))); } else { $this->getUser()->setFlash('templateMessageAct', array('failure', __('Name Already Exists'))); } $this->redirect('admin/saveProject?projectId=' . $projectId); } }
public function parseEditData($postArr) { $activityId = trim($postArr['activityId']); $activity = new ProjectActivity($activityId); $activity->setProjectId(trim($postArr['cmbProjectId'])); $activity->setName(trim($postArr['activityName'])); return $activity; }
public function save() { $projectId = $this->getValue('projectId'); $activityId = $this->getValue('activityId'); if (!empty($activityId)) { $activity = $this->getProjectService()->getProjectActivityById($activityId); $this->edited = true; } else { $activity = new ProjectActivity(); } $activity->setProjectId($projectId); $activity->setName($this->getValue('activityName')); $activity->setIsDeleted(ProjectActivity::ACTIVE_PROJECT); $activity->save(); return $projectId; }
/** * Add an activity to the database and saves it in the $this->activities * array * * @param int $projectId The project Id * @param string $name The Activity name * @param bool $deleted Create activity in deleted state * * @return ProjectActivity The activity object that was created. */ private function _addActivity($projectId, $name, $deleted = false) { $activity = new ProjectActivity(); $activity->setName($name); $activity->setProjectId($projectId); $activity->setDeleted($deleted); $activity->save(); $this->activities[$projectId][$name] = $activity; return $activity; }
/** * Creates a ProjectActivity object from a resultset row * * @param array $row Resultset row from the database. * @return ProjectActivity Project activity object. */ private static function _createFromRow($row) { $tmp = new ProjectActivity($row[self::DB_FIELD_ACTIVITY_ID]); $tmp->setProjectId($row[self::DB_FIELD_PROJECT_ID]); $tmp->setName($row[self::DB_FIELD_NAME]); $tmp->setDeleted((bool) $row[self::DB_FIELD_DELETED]); return $tmp; }
/** * Create a ProjectActivity object with the passed parameters */ private function _getActivityObject($activity_id, $project_id, $name, $deleted) { $activity = new ProjectActivity($activity_id); $activity->setProjectId($project_id); $activity->setName($name); $activity->setDeleted($deleted); return $activity; }