Exemplo n.º 1
0
 public function __construct(Site $site, &$session, $post)
 {
     $tasks = new Tasks($site);
     $user = $session[User::SESSION_NAME];
     $root = $site->getRoot();
     if (isset($post['add'])) {
         $day = strip_tags($post['day']);
         $title = strip_tags($post['title']);
         $notes = strip_tags($post['notes']);
         $notes = $notes === null ? '' : $notes;
         $priority = strip_tags($post['priority']);
         $row = array("id" => 0, "day" => $day, "title" => $title, "notes" => $notes, "priority" => $priority);
         $task = new Task($row);
         $tasks->addTask($user->getId(), $task);
         $this->redirect = "/tasks.php";
         return;
     }
     if (isset($post['edit'])) {
         $id = strip_tags($post['id']);
         $day = strip_tags($post['day']);
         $title = strip_tags($post['title']);
         $notes = strip_tags($post['notes']);
         $notes = $notes === null ? '' : $notes;
         $priority = strip_tags($post['priority']);
         $row = array("id" => $id, "day" => $day, "title" => $title, "notes" => $notes, "priority" => $priority);
         $task = new Task($row);
         $tasks->updateTask($user->getId(), $task);
         $this->redirect = "/tasks.php";
         return;
     }
     if (isset($post['delete'])) {
         $id = strip_tags($post['id']);
         $tasks->deleteTask($user->getId(), $id);
         $this->redirect = "/tasks.php";
         return;
     }
 }
Exemplo n.º 2
0
 /**
  * Delete Activity
  * @var string $prj_uid. Uid for Process
  * @var string $act_uid. Uid for Activity
  *
  * @author Brayan Pereyra (Cochalo) <*****@*****.**>
  * @copyright Colosa - Bolivia
  *
  * return object
  */
 public function deleteTask($prj_uid, $act_uid)
 {
     try {
         $prj_uid = $this->validateProUid($prj_uid);
         $act_uid = $this->validateActUid($act_uid);
         G::LoadClass('tasks');
         $tasks = new \Tasks();
         $tasks->deleteTask($act_uid);
     } catch (Exception $e) {
         throw $e;
     }
 }
Exemplo n.º 3
0
 /**
  * deleteSubProcess
  *
  * @param string $sProcessUID
  * @param string $sTaskUID
  * @return boolean true
  * throw Exception $oError
  */
 public function deleteSubProcess($sProcessUID = '', $sTaskUID = '')
 {
     try {
         $oTasks = new Tasks();
         $oTasks->deleteTask($sTaskUID);
         $oCriteria = new Criteria('workflow');
         $oCriteria->addSelectColumn('SP_UID');
         $oCriteria->add(SubProcessPeer::PRO_PARENT, $sProcessUID);
         $oCriteria->add(SubProcessPeer::TAS_PARENT, $sTaskUID);
         $oDataset = SubProcessPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         $aRow = $oDataset->getRow();
         $oSubProcess = new SubProcess();
         $oSubProcess->remove($aRow['SP_UID']);
         return true;
     } catch (Exception $oError) {
         throw $oError;
     }
 }
Exemplo n.º 4
0
 /**
  * Delete WebEntry
  *
  * @param string $webEntryUid     Unique id of WebEntry
  * @param string $webEntryTaskUid WebEntry, unique id of Task
  *
  * return void
  */
 public function deleteWebEntry($webEntryUid, $webEntryTaskUid)
 {
     try {
         if ($webEntryTaskUid != "") {
             $obj = \TaskPeer::retrieveByPK($webEntryTaskUid);
             if (!is_null($obj)) {
                 $task = new \Tasks();
                 $task->deleteTask($webEntryTaskUid);
             }
         }
         if ($webEntryUid != "") {
             $obj = \WebEntryPeer::retrieveByPK($webEntryUid);
             if (!is_null($obj)) {
                 $this->webEntry->delete($webEntryUid);
             }
         }
     } catch (\Exception $e) {
         throw $e;
     }
 }
Exemplo n.º 5
0
    /**
     * Create/Update Process
     *
     * @param string $option
     * @param array  $arrayDefineProcessData
     *
     * return array  Return data array with new UID for each element
     *
     * @access public
     */
    public function defineProcess($option, $arrayDefineProcessData)
    {
        if (!isset($arrayDefineProcessData["process"]) || count($arrayDefineProcessData["process"]) == 0) {
            throw (new \Exception("Process data do not exist"));
        }

        //Process
        $process = new \Process();

        $arrayProcessData = $arrayDefineProcessData["process"];

        unset($arrayProcessData["tasks"]);
        unset($arrayProcessData["routes"]);

        switch ($option) {
            case "CREATE":
                if (!isset($arrayProcessData["USR_UID"]) || trim($arrayProcessData["USR_UID"]) == "") {
                    throw (new \Exception("User data do not exist"));
                }

                if (!isset($arrayProcessData["PRO_TITLE"]) || trim($arrayProcessData["PRO_TITLE"]) == "") {
                    throw (new \Exception("Process title data do not exist"));
                }

                if (!isset($arrayProcessData["PRO_DESCRIPTION"])) {
                    throw (new \Exception("Process description data do not exist"));
                }

                if (!isset($arrayProcessData["PRO_CATEGORY"])) {
                    throw (new \Exception("Process category data do not exist"));
                }
                break;
            case "UPDATE":
                break;
        }

        if (isset($arrayProcessData["PRO_TITLE"])) {
            $arrayProcessData["PRO_TITLE"] = trim($arrayProcessData["PRO_TITLE"]);
        }

        if (isset($arrayProcessData["PRO_DESCRIPTION"])) {
            $arrayProcessData["PRO_DESCRIPTION"] = trim($arrayProcessData["PRO_DESCRIPTION"]);
        }

        if (isset($arrayProcessData["PRO_TITLE"]) && $process->existsByProTitle($arrayProcessData["PRO_TITLE"])) {
            throw (new \Exception(\G::LoadTranslation("ID_PROCESSTITLE_ALREADY_EXISTS", SYS_LANG, array("PRO_TITLE" => $arrayProcessData["PRO_TITLE"]))));
        }

        $arrayProcessData["PRO_DYNAFORMS"] = array ();
        $arrayProcessData["PRO_DYNAFORMS"]["PROCESS"] = (isset($arrayProcessData["PRO_SUMMARY_DYNAFORM"]))? $arrayProcessData["PRO_SUMMARY_DYNAFORM"] : "";

        unset($arrayProcessData["PRO_SUMMARY_DYNAFORM"]);

        switch ($option) {
            case "CREATE":
                $processUid = $process->create($arrayProcessData, false);

                //Call plugins
                //$arrayData = array(
                //    "PRO_UID"      => $processUid,
                //    "PRO_TEMPLATE" => (isset($arrayProcessData["PRO_TEMPLATE"]) && $arrayProcessData["PRO_TEMPLATE"] != "")? $arrayProcessData["PRO_TEMPLATE"] : "",
                //    "PROCESSMAP"   => $this //?
                //);
                //
                //$oPluginRegistry = &PMPluginRegistry::getSingleton();
                //$oPluginRegistry->executeTriggers(PM_NEW_PROCESS_SAVE, $arrayData);
                break;
            case "UPDATE":
                $result = $process->update($arrayProcessData);

                $processUid = $arrayProcessData["PRO_UID"];
                break;
        }

        //Process - Save Calendar ID for this process
        if (isset($arrayProcessData["PRO_CALENDAR"]) && $arrayProcessData["PRO_CALENDAR"] != "") {
            $calendar = new \Calendar();
            $calendar->assignCalendarTo($processUid, $arrayProcessData["PRO_CALENDAR"], "PROCESS");
        }

        $uidAux = $arrayDefineProcessData["process"]["PRO_UID"];
        $arrayDefineProcessData["process"]["PRO_UID"] = $processUid;
        $arrayDefineProcessData["process"]["PRO_UID_OLD"] = $uidAux;

        //Tasks
        if (isset($arrayDefineProcessData["process"]["tasks"]) && count($arrayDefineProcessData["process"]["tasks"]) > 0) {
            $arrayTaskData = $arrayDefineProcessData["process"]["tasks"];

            foreach ($arrayTaskData as $index => $value) {
                $t = $value;
                $t["PRO_UID"] = $processUid;

                $arrayData = $t;

                $action = $arrayData["_action"];

                unset($arrayData["_action"]);

                switch ($action) {
                    case "CREATE":
                        //Create task
                        $arrayDataAux = array(
                            "TAS_UID"   => $arrayData["TAS_UID"],
                            "PRO_UID"   => $arrayData["PRO_UID"],
                            "TAS_TITLE" => $arrayData["TAS_TITLE"],
                            "TAS_DESCRIPTION" => $arrayData["TAS_DESCRIPTION"],
                            "TAS_POSX"  => $arrayData["TAS_POSX"],
                            "TAS_POSY"  => $arrayData["TAS_POSY"],
                            "TAS_START" => $arrayData["TAS_START"]
                        );

                        $task = new \Task();

                        $taskUid = $task->create($arrayDataAux, false);

                        $uidAux = $arrayDefineProcessData["process"]["tasks"][$index]["TAS_UID"];
                        $arrayDefineProcessData["process"]["tasks"][$index]["TAS_UID"] = $taskUid;
                        $arrayDefineProcessData["process"]["tasks"][$index]["TAS_UID_OLD"] = $uidAux;

                        //Update task properties
                        $task2 = new \ProcessMaker\BusinessModel\Task();

                        $arrayResult = $task2->updateProperties($taskUid, $processUid, $arrayData);

                        //Update array routes
                        if (isset($arrayDefineProcessData["process"]["routes"]) && count($arrayDefineProcessData["process"]["routes"]) > 0) {
                            $arrayDefineProcessData["process"]["routes"] = $this->routeUpdateTaskUidInArray($arrayDefineProcessData["process"]["routes"], $taskUid, $t["TAS_UID"]);
                        }
                        break;
                    case "UPDATE":
                        //Update task
                        $task = new \Task();

                        $result = $task->update($arrayData);

                        //Update task properties
                        $task2 = new \ProcessMaker\BusinessModel\Task();

                        $arrayResult = $task2->updateProperties($arrayData["TAS_UID"], $processUid, $arrayData);
                        break;
                    case "DELETE":
                        $tasks = new \Tasks();

                        $tasks->deleteTask($arrayData["TAS_UID"]);
                        break;
                }
            }
        }

        //Routes
        if (isset($arrayDefineProcessData["process"]["routes"]) && count($arrayDefineProcessData["process"]["routes"]) > 0) {
            $arrayRouteData = $arrayDefineProcessData["process"]["routes"];

            foreach ($arrayRouteData as $index => $value) {
                $r = $value;

                $routeUid = $this->defineRoute( //***** New method
                    $processUid,
                    $r["TAS_UID"],
                    $r["ROU_NEXT_TASK"],
                    $r["ROU_TYPE"],
                    false
                );

                $uidAux = $arrayDefineProcessData["process"]["routes"][$index]["ROU_UID"];
                $arrayDefineProcessData["process"]["routes"][$index]["ROU_UID"] = $routeUid;
                $arrayDefineProcessData["process"]["routes"][$index]["ROU_UID_OLD"] = $uidAux;
            }
        }

        return $arrayDefineProcessData;
    }