Exemplo n.º 1
0
 /**
  * Executes index action
  *
  */
 public function executeShow()
 {
     $c = new Criteria();
     $c->add(TagPeer::NORMALIZED_TAG, $this->getRequestParameter('tag'));
     $this->tag = TagPeer::doSelectOne($c);
     $this->events = EventPeer::getTaggedEvents($this->getRequestParameter('tag'));
     $this->forward404Unless($this->events);
 }
Exemplo n.º 2
0
 /**
  * Get list for Events
  * @var string $pro_uid. Uid for Process
  * @var string $filter.
  * @var string $evn_uid. Uid for Process
  *
  * @access public
  * @author Brayan Pereyra (Cochalo) <*****@*****.**>
  * @copyright Colosa - Bolivia
  *
  * @return array
  */
 public function getEvents($pro_uid, $filter = '', $evn_uid = '')
 {
     $pro_uid = $this->validateProUid($pro_uid);
     if ($evn_uid != '') {
         $evn_uid = $this->validateEvnUid($evn_uid);
     }
     $oProcess = new \Process();
     if (!$oProcess->processExists($pro_uid)) {
         throw new \Exception(\G::LoadTranslation("ID_PROCESS_NOT_EXIST", array('pro_uid', $pro_uid)));
     }
     $sDelimiter = \DBAdapter::getStringDelimiter();
     $oCriteria = new \Criteria('workflow');
     $oCriteria->addSelectColumn(\EventPeer::EVN_UID);
     $oCriteria->addSelectColumn(\EventPeer::EVN_ACTION);
     $oCriteria->addSelectColumn(\EventPeer::EVN_STATUS);
     $oCriteria->addSelectColumn(\EventPeer::EVN_WHEN_OCCURS);
     $oCriteria->addSelectColumn(\EventPeer::EVN_RELATED_TO);
     $oCriteria->addAsColumn('EVN_DESCRIPTION', \ContentPeer::CON_VALUE);
     $aConditions = array();
     $aConditions[] = array(\EventPeer::EVN_UID, \ContentPeer::CON_ID);
     $aConditions[] = array(\ContentPeer::CON_CATEGORY, $sDelimiter . 'EVN_DESCRIPTION' . $sDelimiter);
     $aConditions[] = array(\ContentPeer::CON_LANG, $sDelimiter . SYS_LANG . $sDelimiter);
     $oCriteria->addJoinMC($aConditions, \Criteria::LEFT_JOIN);
     $oCriteria->add(\EventPeer::PRO_UID, $pro_uid);
     if ($evn_uid != '') {
         $oCriteria->add(\EventPeer::EVN_UID, $evn_uid);
     }
     switch ($filter) {
         case 'message':
             $oCriteria->add(\EventPeer::EVN_ACTION, "SEND_MESSAGE");
             break;
         case 'conditional':
             $oCriteria->add(\EventPeer::EVN_ACTION, "EXECUTE_CONDITIONAL_TRIGGER");
             break;
         case 'multiple':
             $oCriteria->add(\EventPeer::EVN_ACTION, "EXECUTE_TRIGGER");
             break;
     }
     $eventsArray = array();
     $oDataset = \EventPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     while ($aRow = $oDataset->getRow()) {
         $oEvent = new \Event();
         $aFields = $oEvent->load($aRow['EVN_UID']);
         $aRow = array_merge($aRow, $aFields);
         $eventsArray[] = array_change_key_case($aRow, CASE_LOWER);
         $oDataset->next();
     }
     if ($evn_uid != '' && empty($eventsArray)) {
         throw new \Exception(\G::LoadTranslation("ID_ROW_DOES_NOT_EXIST"));
     } elseif ($evn_uid != '' && !empty($eventsArray)) {
         return current($eventsArray);
     }
     return $eventsArray;
 }
Exemplo n.º 3
0
 public function execute(&$value, &$error)
 {
     $slug = myTools::stripText($value);
     $event_id_param = $this->getParameter('event_id');
     $event_id = $this->getContext()->getRequest()->getParameter($event_id_param);
     $c = new Criteria();
     $c->add(EventPeer::SLUG, $slug);
     $event_slug = EventPeer::doSelectOne($c);
     if ($event_slug && $event_slug->getId() != $event_id) {
         $error = $this->getParameter('slug_error');
         return false;
     }
     return true;
 }
Exemplo n.º 4
0
    public static function getTaggedEvents($tag)
    {
        $conn = Propel::getConnection();
        $query = '
      SELECT DISTINCT(%s.*)
      FROM %s as event
      LEFT OUTER JOIN %s event_tag ON (%s = %s)
      LEFT OUTER JOIN %s tag ON (%s = %s)
      LEFT OUTER JOIN %s etime ON (%s = %s)
      LEFT OUTER JOIN %s etime_tag ON (%s = %s)
      LEFT OUTER JOIN %s t ON (t.id = %s)
      WHERE
        tag.normalized_tag = ?
        OR
        t.normalized_tag = ?

    ';
        $query = sprintf($query, EventPeer::TABLE_NAME, EventPeer::TABLE_NAME, EventTagPeer::TABLE_NAME, EventPeer::ID, EventTagPeer::EVENT_ID, TagPeer::TABLE_NAME, TagPeer::ID, EventTagPeer::TAG_ID, EtimePeer::TABLE_NAME, EventPeer::ID, EtimePeer::EVENT_ID, EtimeTagPeer::TABLE_NAME, EtimePeer::ID, EtimeTagPeer::ETIME_ID, TagPeer::TABLE_NAME, EtimeTagPeer::TAG_ID);
        $stmt = $conn->prepareStatement($query);
        $stmt->setString(1, $tag);
        $stmt->setString(2, $tag);
        $resultset = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
        return EventPeer::populateObjects($resultset);
    }
Exemplo n.º 5
0
 public function getEventsOnSameDay()
 {
     $other_events = array();
     if (!$this->getEtimes()) {
         return $other_events;
     }
     $where = "";
     foreach ($this->getEtimes() as $etime) {
         if ($where == "") {
             $where = "AND (";
             $where .= " etime.start_date::date = '{$etime->getStartDate()}'::date";
         } else {
             $where .= " OR etime.start_date::date = '{$etime->getStartDate()}'::date";
         }
         $where .= " OR etime.end_date::date = '{$etime->getEndDate()}'::date";
     }
     $where .= ") ";
     $conn = Propel::getConnection();
     $query = "SELECT DISTINCT ON (event.title) * " . "FROM event " . "JOIN etime ON (event.id = etime.event_id) " . "WHERE " . "event.id != {$this->getId()} " . "AND event.published = true " . "{$where}" . "ORDER BY event.title " . "";
     $stmt = $conn->prepareStatement($query);
     $resultset = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
     $other_events = EventPeer::populateObjects($resultset);
     return $other_events;
 }
Exemplo n.º 6
0
 public function verifyDependecies($TRI_UID)
 {
     require_once "classes/model/Event.php";
     require_once "classes/model/StepTrigger.php";
     $oResult = new stdClass();
     $oResult->dependencies = array();
     $oCriteria = new Criteria();
     $oCriteria->addSelectColumn(EventPeer::EVN_UID);
     $oCriteria->addSelectColumn(EventPeer::TRI_UID);
     $oCriteria->add(EventPeer::EVN_ACTION, '', Criteria::NOT_EQUAL);
     $oCriteria->add(EventPeer::TRI_UID, $TRI_UID);
     $oDataset = EventPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $aRows = array();
     while ($oDataset->next()) {
         array_push($aRows, $oDataset->getRow());
     }
     $oResult->dependencies['Events'] = array();
     if (count($aRows) == 0) {
         $oResult->code = 0;
     } else {
         $oResult->code = 1;
         foreach ($aRows as $row) {
             $oTrigger = TriggersPeer::retrieveByPK($row['TRI_UID']);
             array_push($oResult->dependencies['Events'], array('UID' => $oTrigger->getTriUid(), 'DESCRIPTION' => $oTrigger->getTriTitle()));
         }
     }
     //for tasks dependencies
     $oCriteria = new Criteria();
     $oCriteria->addSelectColumn(StepTriggerPeer::TAS_UID);
     $oCriteria->addSelectColumn(StepTriggerPeer::TRI_UID);
     $oCriteria->add(StepTriggerPeer::TRI_UID, $TRI_UID);
     $oDataset = StepTriggerPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $aRows = array();
     while ($oDataset->next()) {
         array_push($aRows, $oDataset->getRow());
     }
     $oResult->dependencies['Tasks'] = array();
     if ($oResult->code == 0 && count($aRows) == 0) {
         $oResult->code = 0;
     } elseif (count($aRows) > 0) {
         $oResult->code = 1;
         foreach ($aRows as $row) {
             $oTask = TaskPeer::retrieveByPK($row['TAS_UID']);
             array_push($oResult->dependencies['Tasks'], array('UID' => $oTask->getTasUid(), 'DESCRIPTION' => $oTask->getTasTitle()));
         }
     }
     //Tasks, assignment rules dependencies
     $criteria = new Criteria();
     $criteria->addSelectColumn(TaskPeer::TAS_UID);
     $criteria->add(TaskPeer::TAS_SELFSERVICE_TIMEOUT, 1);
     $criteria->add(TaskPeer::TAS_SELFSERVICE_TRIGGER_UID, $TRI_UID);
     $rsCriteria = TaskPeer::doSelectRS($criteria);
     $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $arrayRow = array();
     while ($rsCriteria->next()) {
         array_push($arrayRow, $rsCriteria->getRow());
     }
     $oResult->dependencies["Assignment rules"] = array();
     if ($oResult->code == 0 && count($arrayRow) == 0) {
         $oResult->code = 0;
     } else {
         if (count($arrayRow) > 0) {
             foreach ($arrayRow as $row) {
                 $task = TaskPeer::retrieveByPK($row["TAS_UID"]);
                 array_push($oResult->dependencies["Assignment rules"], array("UID" => $task->getTasUid(), "DESCRIPTION" => $task->getTasTitle()));
             }
             $oResult->code = 1;
         }
     }
     return $oResult;
 }
Exemplo n.º 7
0
 public function executeEventSignup(sfWebRequest $request)
 {
     $this->event = EventPeer::retrieveByPK($request->getParameter('id'));
 }
Exemplo n.º 8
0
     $aData['TAS_EVN_UID'] = '';
     $oTask->update($aData);
     break;
 case 'deleteStartEvent':
     $aData['TAS_UID'] = $oData->tas_uid;
     $aData['TAS_START'] = $oData->tas_start;
     $aData['TAS_EVN_UID'] = '';
     $oTask->update($aData);
     if (isset($oData->evn_uid)) {
         $oEvent->remove($oData->evn_uid);
     }
     break;
 case 'updateEvent':
     $aData['EVN_UID'] = $oData->evn_uid;
     $aData['EVN_TYPE'] = $oData->evn_type;
     $oEvent = EventPeer::retrieveByPK($aData['EVN_UID']);
     if (!is_null($oEvent)) {
         $oEvent->update($aData);
     }
     break;
 case 'saveEvents':
     $sOutput = $oProcessMap->saveExtEvents($oData);
     echo $sOutput;
     break;
 case 'addEvent':
     $sOutput = $oProcessMap->saveExtddEvents($oData);
     echo $sOutput;
     /*
               $aData['PRO_UID']  = $oData->uid;
               $aData['EVN_TYPE']  = $oData->tas_type;
               $aData['EVN_STATUS'] = 'ACTIVE';
Exemplo n.º 9
0
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      Connection $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *       rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(EventPeer::EVN_UID, $pks, Criteria::IN);
         $objs = EventPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Exemplo n.º 10
0
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = EventPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setTitle($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setSlug($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setStatusId($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setCategoryId($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setPublished($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setMediaPotential($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setDescription($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setNotes($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setImageUrl($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setUpdatedAt($arr[$keys[10]]);
     }
 }
Exemplo n.º 11
0
 public function saveExtddEvents($oData)
 {
     $oTask = new Task();
     $oEvent = new Event();
     $sEvn_uid = '';
     $aData = array();
     $aData['PRO_UID'] = $oData->uid;
     $aData['EVN_TYPE'] = $oData->evn_type;
     $aData['EVN_POSX'] = $oData->position->x;
     $aData['EVN_POSY'] = $oData->position->y;
     $aData['EVN_STATUS'] = 'ACTIVE';
     $aData['EVN_WHEN'] = '1';
     $aData['EVN_ACTION'] = '';
     if (preg_match("/Inter/", $aData['EVN_TYPE'])) {
         $aData['EVN_RELATED_TO'] = 'MULTIPLE';
     }
     if (preg_match("/Start/", $aData['EVN_TYPE'])) {
         $aData['EVN_RELATED_TO'] = 'MULTIPLE';
     }
     $sEvn_uid = $oData->evn_uid;
     $oEventData = EventPeer::retrieveByPK($sEvn_uid);
     if (is_null($oEventData)) {
         $sEvn_uid = $oEvent->create($aData);
     } else {
         $aData['EVN_UID'] = $sEvn_uid;
         $oEvent->update($aData);
     }
     $oEncode->uid = $sEvn_uid;
     //$oJSON = new Services_JSON();
     return Bootstrap::json_encode($oEncode);
     //$oJSON->encode( $oEncode );
 }
Exemplo n.º 12
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
  * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = EventPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setEvnUid($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setProUid($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setEvnStatus($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setEvnWhenOccurs($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setEvnRelatedTo($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setTasUid($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setEvnTasUidFrom($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setEvnTasUidTo($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setEvnTasEstimatedDuration($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setEvnTimeUnit($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setEvnWhen($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setEvnMaxAttempts($arr[$keys[11]]);
     }
     if (array_key_exists($keys[12], $arr)) {
         $this->setEvnAction($arr[$keys[12]]);
     }
     if (array_key_exists($keys[13], $arr)) {
         $this->setEvnConditions($arr[$keys[13]]);
     }
     if (array_key_exists($keys[14], $arr)) {
         $this->setEvnActionParameters($arr[$keys[14]]);
     }
     if (array_key_exists($keys[15], $arr)) {
         $this->setTriUid($arr[$keys[15]]);
     }
     if (array_key_exists($keys[16], $arr)) {
         $this->setEvnPosx($arr[$keys[16]]);
     }
     if (array_key_exists($keys[17], $arr)) {
         $this->setEvnPosy($arr[$keys[17]]);
     }
     if (array_key_exists($keys[18], $arr)) {
         $this->setEvnType($arr[$keys[18]]);
     }
     if (array_key_exists($keys[19], $arr)) {
         $this->setTasEvnUid($arr[$keys[19]]);
     }
 }
Exemplo n.º 13
0
 public function getEventsJoinStatus($criteria = null, $con = null)
 {
     include_once 'lib/model/om/BaseEventPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collEvents === null) {
         if ($this->isNew()) {
             $this->collEvents = array();
         } else {
             $criteria->add(EventPeer::CATEGORY_ID, $this->getId());
             $this->collEvents = EventPeer::doSelectJoinStatus($criteria, $con);
         }
     } else {
         $criteria->add(EventPeer::CATEGORY_ID, $this->getId());
         if (!isset($this->lastEventCriteria) || !$this->lastEventCriteria->equals($criteria)) {
             $this->collEvents = EventPeer::doSelectJoinStatus($criteria, $con);
         }
     }
     $this->lastEventCriteria = $criteria;
     return $this->collEvents;
 }
Exemplo n.º 14
0
 public function validateEdit()
 {
     $has_errors = false;
     $msg = "Required";
     $guest_data = $this->getRequestParameter('guest');
     $event_id = $this->getRequestParameter('event_id');
     $c = new Criteria();
     $c->add(EventPeer::ID, $event_id);
     $event = EventPeer::doSelectOne($c);
     if (is_array($guest_data)) {
         $validator = new sfStringValidator();
         $validator->initialize($this->getContext(), array('min' => 1));
         foreach ($guest_data as $field => $data) {
             $c = new Criteria();
             $c->add(RegFieldPeer::NAME, $field);
             $regField = RegFieldPeer::doSelectOne($c);
             if ($regField) {
                 $c = new Criteria();
                 $c->add(RegFormPeer::EVENT_ID, $event->getId());
                 $c->add(RegFormPeer::REG_FIELD_ID, $regField->getId());
                 $regForm = RegFormPeer::doSelectOne($c);
                 if ($regForm->getRequiredField() && !$validator->execute($data, $msg)) {
                     $this->getRequest()->setError('guest{' . $field . '}', 'Required');
                     $has_errors = true;
                 }
             }
         }
         if ($has_errors) {
             return false;
         }
         return true;
     }
     return false;
 }
Exemplo n.º 15
0
 /**
  * Get the associated Event object
  *
  * @param      PropelPDO Optional Connection object.
  * @return     Event The associated Event object.
  * @throws     PropelException
  */
 public function getEvent(PropelPDO $con = null)
 {
     if ($this->aEvent === null && $this->event_id !== null) {
         $c = new Criteria(EventPeer::DATABASE_NAME);
         $c->add(EventPeer::ID, $this->event_id);
         $this->aEvent = EventPeer::doSelectOne($c, $con);
         /* The following can be used additionally to
         		   guarantee the related object contains a reference
         		   to this object.  This level of coupling may, however, be
         		   undesirable since it could result in an only partially populated collection
         		   in the referenced object.
         		   $this->aEvent->addEventReservations($this);
         		 */
     }
     return $this->aEvent;
 }
Exemplo n.º 16
0
 /**
  * Save client event
  * @param web request $request
  */
 public function executeUpdateEvent($request)
 {
     $sf_user = $this->getUser();
     $sf_user_id = $sf_user->getGuardUser()->getId();
     $client_id = $request->getParameter('id');
     $client_profile = ProfilePeer::retrieveByPK($client_id);
     $sfguard_user_profile = $sf_user->getProfile();
     $sfguard_fullname = $sfguard_user_profile->getFullname();
     $sfguard_email = $sfguard_user_profile->getEmail();
     $start_hour = $request->getParameter('start_hour');
     $start_min = $request->getParameter('start_min');
     $time_mode = $request->getParameter('start_mn');
     $client_branch_id = BranchUsersPeer::getUserBranchId($client_profile->getUserId());
     $hour = sfConfig::get('mod_client_outlook_shour');
     $sc_hour = sfConfig::get('mod_client_secondhalf_shhour');
     if ($request->isMethod('post')) {
         $event_id = $this->getRequestParameter('event_id');
         $event_details = '';
         if ($event_id) {
             $event_details = pmProjectObjectsPeer::retrieveByPK($event_id);
             $this->form = new ClientEventForm($event_details);
         } else {
             $this->form = new ClientEventForm();
         }
         $event_data = $request->getParameter('pm_project_objects');
         if ($time_mode == 'AM') {
             $start_hour_value = $start_hour == 11 ? '00' : $hour[$start_hour];
             $date_field_1 = $event_data['date_field_1'] . ' ' . $start_hour_value . ':' . $start_min . ':00';
         } elseif ($time_mode == 'PM') {
             $start_hour_value = $start_hour == 11 ? $hour[$start_hour] : $sc_hour[$start_hour];
             $date_field_1 = $event_data['date_field_1'] . ' ' . $start_hour_value . ':' . $start_min . ':00';
         }
         $event_data['module'] = 'client event';
         $event_data['tree_left'] = $client_branch_id;
         $event_data['tree_right'] = $sf_user_id;
         $event_data['integer_field_2'] = $client_id;
         $event_data['date_field_1'] = $date_field_1;
         $event_data['contract_id'] = $request->getParameter('contract_id');
         $event_data['created_by_id'] = $sf_user_id;
         $event_data['updated_by_id'] = $sf_user_id;
         $this->form->bind($event_data);
         if ($this->form->isValid()) {
             $client_event = $this->form->save();
             $client_event->setParentId($client_event->getId());
             $client_event->setUpdatedAt($date_field_1);
             $client_event->save();
             // create instance of event class and add client event in event table
             $event = '';
             $c = new Criteria();
             $c->add(EventPeer::CEVENT_ID, $event_id);
             $event = EventPeer::doSelectOne($c);
             if (!$event) {
                 $event = new Event();
             }
             $event_start_date = $client_event->getDateField1();
             $client_full_name = $client_profile->getFname() . ' ' . $client_profile->getLname();
             $event->setUserId($client_profile->getUserId());
             $event->setSubject($client_full_name . ': ' . $client_event->getName() . ': ' . $client_event->getBody());
             $event->setBody($client_event->getName() . ': ' . $client_event->getBody());
             $event->setEventType('client event');
             $event->setStartTime($date_field_1);
             $event->setEndTime($date_field_1);
             $event->setCeventId($client_event->getId());
             $event->setCalendarId(calendarsPeer::getCalendarIdByUserId($sf_user_id));
             $event->save();
             $ical = $this->getICalData($event);
             $event->setUri($ical->filename);
             $event->setIcsData($ical->createCalendar());
             $event->setCreatedById($sf_user_id);
             $event->save();
             $events = $event;
             if ($time_mode == 'PM') {
                 $hour = sfConfig::get('mod_client_outlook_shour');
             } else {
                 $hour = sfConfig::get('mod_client_outlook_shour');
             }
             $start_time = strtotime($event_start_date);
             $end_time = strtotime($event_start_date);
             $hour_start = $hour[$start_hour];
             //set default 9:00am
             $minute_start = $start_min;
             $end_hr = $start_min;
             // star time
             $start = array('year' => date('Y', $start_time), 'month' => date('m', $start_time), 'day' => date('d', $start_time), 'hour' => $hour_start, 'min' => $minute_start, 'sec' => date('s', $start_time));
             $outlook_start = date('d-m-Y', $start_time);
             $metting_start_time = $hour_start . ':' . $minute_start . ':' . '00';
             $mode = $time_mode == 'PM' ? ' PM' : ' AM';
             $metting_start_time = $metting_start_time . $mode;
             sfConfig::set('sf_web_debug', false);
             $description = get_partial('message_data', array());
             $sender = str_replace('sender', "{$client_full_name}", $description);
             $topic = str_replace('topic', "{$client_event->getName()}", $sender);
             $time = str_replace('start', "{$outlook_start}", $topic);
             $s_t = str_replace('s_t', "{$metting_start_time}", $time);
             $place = str_replace('place', "{$client_event->getVarcharField1()}", $s_t);
             $subject = str_replace('subject', "{$client_event->getBody()}", $place);
             $involved_user = $client_event->getContractId();
             $c = new Criteria();
             $c->add(ProfilePeer::USER_ID, $involved_user);
             $involved_user_profile = ProfilePeer::doSelectOne($c);
             $organizer = $involved_user_profile->getEmail();
             if ($time_mode == 'PM') {
                 $outlook_hour = sfConfig::get('mod_client_soutlook_dhour');
             } else {
                 $outlook_hour = sfConfig::get('mod_client_secoutlook_sechour');
             }
             $time_start = array('year' => date('Y', $start_time), 'month' => date('m', $start_time), 'day' => date('d', $start_time), 'hour' => $outlook_hour[$hour_start], 'min' => $minute_start, 'sec' => date('s', $start_time));
             $v_event = new vevent();
             $v_event->setProperty("organizer", 'MAILTO:' . $organizer);
             //$v_event->setProperty("recurrence-id", $start);
             $v_event->setProperty('uid', md5($events->getId()));
             $v_event->setProperty('dtstamp', $events->getCreatedAt());
             $v_event->setProperty('dtstart', $time_start);
             $v_event->setProperty('location', $client_event->getVarcharField1());
             $v_event->setProperty('dtend', $time_start);
             $v_event->setProperty('summary', $events->getSubject());
             $v_event->setProperty('description', $subject);
             $v_event->setProperty("status", "CONFIRMED");
             $v_timezone = new vtimezone();
             $v_timezone->setProperty("tzid", "Pacific/Auckland");
             $v_event->setComponent($v_timezone);
             $cal_events[] = $v_event;
             $v_alarm = new valarm();
             $v_alarm->setProperty('trigger', 'PT15M');
             $v_alarm->setProperty('action', 'display');
             $v_alarm->setProperty('Description', "Reminder: " . $subject);
             $v_event->setComponent($v_alarm);
             $calendar_events = $cal_events;
             $config = array('unique_id' => 'ravebuild.com');
             $v_calendar = new vcalendar();
             $v_calendar->setProperty("method", "REQUEST");
             $mail_data = $this->setIcalEvents($v_calendar, $calendar_events);
             $all_events = $v_calendar->createCalendar();
             $send_mail = new mailSend();
             $send_mail->sendInvitationToUser($organizer, null, $all_events);
             $event_type = $event_id ? 'updated' : 'added';
             $modification_message = $event_id ? 'Update Client Event' : 'Add Client Event';
             $client_user_id = $client_profile->getUserId();
             $this->saveHistory($modification_message, $client_user_id);
             $sf_user->setFlash('notice', 'The Event "' . $client_event->getBody() . '" has been ' . $event_type . ' successfully.');
             $this->redirect($request->getReferer());
         }
     }
 }
Exemplo n.º 17
0
    /**
     * Delete Process
     *
     * @param string $processUid
     * @param bool   $checkCases
     *
     * return bool   Return true, if is succesfully
     *
     * @access public

    DEPRECATED
    public function deleteProcess($processUid, $checkCases = true)
    {
        if ($checkCases) {
            $process = new \Process();

            $arrayCases = $process->getCasesCountInAllProcesses($processUid);

            $sum = 0;

            if (isset($arrayCases[$processUid]) && count($arrayCases[$processUid]) > 0) {
                foreach ($arrayCases[$processUid] as $value) {
                    $sum = $sum + $value;
                }
            }

            if ($sum > 0) {
                throw (new \Exception("You can't delete the process, because it has $sum cases"));
            }
        }

        $processMap = new \processMap();

        return $processMap->deleteProcess($processUid);

    }*/

    public function deleteProcess($sProcessUID)
    {
        try {
            G::LoadClass('case');
            G::LoadClass('reportTables');
            //Instance all classes necesaries
            $oProcess = new Process();
            $oDynaform = new Dynaform();
            $oInputDocument = new InputDocument();
            $oOutputDocument = new OutputDocument();
            $oTrigger = new Triggers();
            $oRoute = new Route();
            $oGateway = new Gateway();
            $oEvent = new Event();
            $oSwimlaneElement = new SwimlanesElements();
            $oConfiguration = new Configuration();
            $oDbSource = new DbSource();
            $oReportTable = new ReportTables();
            $oCaseTracker = new CaseTracker();
            $oCaseTrackerObject = new CaseTrackerObject();
            //Delete the applications of process
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(ApplicationPeer::PRO_UID, $sProcessUID);
            $oDataset = ApplicationPeer::doSelectRS($oCriteria);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            $oCase = new Cases();
            while ($aRow = $oDataset->getRow()) {
                $oCase->removeCase($aRow['APP_UID']);
                $oDataset->next();
            }
            //Delete the tasks of process
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(TaskPeer::PRO_UID, $sProcessUID);
            $oDataset = TaskPeer::doSelectRS($oCriteria);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            while ($aRow = $oDataset->getRow()) {
                $this->deleteTask($aRow['TAS_UID']);
                $oDataset->next();
            }
            //Delete the dynaforms of process
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(DynaformPeer::PRO_UID, $sProcessUID);
            $oDataset = DynaformPeer::doSelectRS($oCriteria);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            while ($aRow = $oDataset->getRow()) {
                $oDynaform->remove($aRow['DYN_UID']);
                $oDataset->next();
            }
            //Delete the input documents of process
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(InputDocumentPeer::PRO_UID, $sProcessUID);
            $oDataset = InputDocumentPeer::doSelectRS($oCriteria);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            while ($aRow = $oDataset->getRow()) {
                $oInputDocument->remove($aRow['INP_DOC_UID']);
                $oDataset->next();
            }
            //Delete the output documents of process
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(OutputDocumentPeer::PRO_UID, $sProcessUID);
            $oDataset = OutputDocumentPeer::doSelectRS($oCriteria);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            while ($aRow = $oDataset->getRow()) {
                $oOutputDocument->remove($aRow['OUT_DOC_UID']);
                $oDataset->next();
            }

            //Delete the triggers of process
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(TriggersPeer::PRO_UID, $sProcessUID);
            $oDataset = TriggersPeer::doSelectRS($oCriteria);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            while ($aRow = $oDataset->getRow()) {
                $oTrigger->remove($aRow['TRI_UID']);
                $oDataset->next();
            }

            //Delete the routes of process
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(RoutePeer::PRO_UID, $sProcessUID);
            $oDataset = RoutePeer::doSelectRS($oCriteria);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            while ($aRow = $oDataset->getRow()) {
                $oRoute->remove($aRow['ROU_UID']);
                $oDataset->next();
            }

            //Delete the gateways of process
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(GatewayPeer::PRO_UID, $sProcessUID);
            $oDataset = GatewayPeer::doSelectRS($oCriteria);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            while ($aRow = $oDataset->getRow()) {
                $oGateway->remove($aRow['GAT_UID']);
                $oDataset->next();
            }

            //Delete the Event of process
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(EventPeer::PRO_UID, $sProcessUID);
            $oDataset = EventPeer::doSelectRS($oCriteria);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            while ($aRow = $oDataset->getRow()) {
                $oEvent->remove($aRow['EVN_UID']);
                $oDataset->next();
            }

            //Delete the swimlanes elements of process
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(SwimlanesElementsPeer::PRO_UID, $sProcessUID);
            $oDataset = SwimlanesElementsPeer::doSelectRS($oCriteria);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            while ($aRow = $oDataset->getRow()) {
                $oSwimlaneElement->remove($aRow['SWI_UID']);
                $oDataset->next();
            }
            //Delete the configurations of process
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(ConfigurationPeer::PRO_UID, $sProcessUID);
            $oDataset = ConfigurationPeer::doSelectRS($oCriteria);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            while ($aRow = $oDataset->getRow()) {
                $oConfiguration->remove($aRow['CFG_UID'], $aRow['OBJ_UID'], $aRow['PRO_UID'], $aRow['USR_UID'], $aRow['APP_UID']);
                $oDataset->next();
            }
            //Delete the DB sources of process
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(DbSourcePeer::PRO_UID, $sProcessUID);
            $oDataset = DbSourcePeer::doSelectRS($oCriteria);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            while ($aRow = $oDataset->getRow()) {

                /**
                 * note added by gustavo cruz gustavo-at-colosa-dot-com 27-01-2010
                 * in order to solve the bug 0004389, we use the validation function Exists
                 * inside the remove function in order to verify if the DbSource record
                 * exists in the Database, however there is a strange behavior within the
                 * propel engine, when the first record is erased somehow the "_deleted"
                 * attribute of the next row is set to true, so when propel tries to erase
                 * it, obviously it can't and trows an error. With the "Exist" function
                 * we ensure that if there is the record in the database, the _delete attribute must be false.
                 *
                 * note added by gustavo cruz gustavo-at-colosa-dot-com 28-01-2010
                 * I have just identified the source of the issue, when is created a $oDbSource DbSource object
                 * it's used whenever a record is erased or removed in the db, however the problem
                 * it's that the same object is used every time, and the delete method invoked
                 * sets the _deleted attribute to true when its called, of course as we use
                 * the same object, the first time works fine but trowns an error with the
                 * next record, cos it's the same object and the delete method checks if the _deleted
                 * attribute it's true or false, the attrib _deleted is setted to true the
                 * first time and later is never changed, the issue seems to be part of
                 * every remove function in the model classes, not only DbSource
                 * i recommend that a more general solution must be achieved to resolve
                 * this issue in every model class, to prevent future problems.
                 */
                $oDbSource->remove($aRow['DBS_UID'], $sProcessUID);
                $oDataset->next();
            }
            //Delete the supervisors
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(ProcessUserPeer::PRO_UID, $sProcessUID);
            ProcessUserPeer::doDelete($oCriteria);
            //Delete the object permissions
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(ObjectPermissionPeer::PRO_UID, $sProcessUID);
            ObjectPermissionPeer::doDelete($oCriteria);
            //Delete the step supervisors
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(StepSupervisorPeer::PRO_UID, $sProcessUID);
            StepSupervisorPeer::doDelete($oCriteria);
            //Delete the report tables
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(ReportTablePeer::PRO_UID, $sProcessUID);
            $oDataset = ReportTablePeer::doSelectRS($oCriteria);
            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            $oDataset->next();
            while ($aRow = $oDataset->getRow()) {
                $oReportTable->deleteReportTable($aRow['REP_TAB_UID']);
                $oDataset->next();
            }
            //Delete case tracker configuration
            $oCaseTracker->remove($sProcessUID);
            //Delete case tracker objects
            $oCriteria = new Criteria('workflow');
            $oCriteria->add(CaseTrackerObjectPeer::PRO_UID, $sProcessUID);
            ProcessUserPeer::doDelete($oCriteria);
            //Delete the process
            try {
                $oProcess->remove($sProcessUID);
            } catch (Exception $oError) {
                throw ($oError);
            }
            return true;
        } catch (Exception $oError) {
            throw ($oError);
        }
    }
Exemplo n.º 18
0
 /**
  * Implementation for 'GET' method for Rest API
  *
  * @param  mixed $evnUid Primary key
  *
  * @return array $result Returns array within multiple records or a single record depending if
  *                       a single selection was requested passing id(s) as param
  */
 protected function get($evnUid = null)
 {
     $result = array();
     try {
         $noArguments = true;
         $argumentList = func_get_args();
         foreach ($argumentList as $arg) {
             if (!is_null($arg)) {
                 $noArguments = false;
             }
         }
         if ($noArguments) {
             $criteria = new Criteria('workflow');
             $criteria->addSelectColumn(EventPeer::EVN_UID);
             $criteria->addSelectColumn(EventPeer::PRO_UID);
             $criteria->addSelectColumn(EventPeer::EVN_STATUS);
             $criteria->addSelectColumn(EventPeer::EVN_WHEN_OCCURS);
             $criteria->addSelectColumn(EventPeer::EVN_RELATED_TO);
             $criteria->addSelectColumn(EventPeer::TAS_UID);
             $criteria->addSelectColumn(EventPeer::EVN_TAS_UID_FROM);
             $criteria->addSelectColumn(EventPeer::EVN_TAS_UID_TO);
             $criteria->addSelectColumn(EventPeer::EVN_TAS_ESTIMATED_DURATION);
             $criteria->addSelectColumn(EventPeer::EVN_TIME_UNIT);
             $criteria->addSelectColumn(EventPeer::EVN_WHEN);
             $criteria->addSelectColumn(EventPeer::EVN_MAX_ATTEMPTS);
             $criteria->addSelectColumn(EventPeer::EVN_ACTION);
             $criteria->addSelectColumn(EventPeer::EVN_CONDITIONS);
             $criteria->addSelectColumn(EventPeer::EVN_ACTION_PARAMETERS);
             $criteria->addSelectColumn(EventPeer::TRI_UID);
             $criteria->addSelectColumn(EventPeer::EVN_POSX);
             $criteria->addSelectColumn(EventPeer::EVN_POSY);
             $criteria->addSelectColumn(EventPeer::EVN_TYPE);
             $criteria->addSelectColumn(EventPeer::TAS_EVN_UID);
             $dataset = AppEventPeer::doSelectRS($criteria);
             $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
             while ($dataset->next()) {
                 $result[] = $dataset->getRow();
             }
         } else {
             $record = EventPeer::retrieveByPK($evnUid);
             if ($record) {
                 $result = $record->toArray(BasePeer::TYPE_FIELDNAME);
             } else {
                 $paramValues = "";
                 foreach ($argumentList as $arg) {
                     $paramValues .= strlen($paramValues) ? ', ' : '';
                     if (!is_null($arg)) {
                         $paramValues .= "{$arg}";
                     } else {
                         $paramValues .= "NULL";
                     }
                 }
                 throw new RestException(417, "table Event ({$paramValues})");
             }
         }
     } catch (RestException $e) {
         throw new RestException($e->getCode(), $e->getMessage());
     } catch (Exception $e) {
         throw new RestException(412, $e->getMessage());
     }
     return $result;
 }
Exemplo n.º 19
0
 public function deleteProcess($sProcessUID, $flagRemoveCases = true)
 {
     try {
         //G::LoadClass('case');
         //G::LoadClass('reportTables');
         //Instance all classes necesaries
         $oProcess = new \Process();
         $oDynaform = new \Dynaform();
         $oInputDocument = new \InputDocument();
         $oOutputDocument = new \OutputDocument();
         $oTrigger = new \Triggers();
         $oRoute = new \Route();
         $oGateway = new \Gateway();
         $oEvent = new \Event();
         $oSwimlaneElement = new \SwimlanesElements();
         $oConfiguration = new \Configuration();
         $oDbSource = new \DbSource();
         $oReportTable = new \ReportTables();
         $oCaseTracker = new \CaseTracker();
         $oCaseTrackerObject = new \CaseTrackerObject();
         //Update PROCESS_FILES_CHECKED
         $configuration = \ConfigurationPeer::retrieveByPK("PROCESS_FILES_CHECKED", "", "", "", "");
         if (!is_null($configuration)) {
             $arrayProjectUid = unserialize($configuration->getCfgValue());
             unset($arrayProjectUid[$sProcessUID]);
             $conf = new \Configuration();
             $result = $conf->update(array("CFG_UID" => "PROCESS_FILES_CHECKED", "OBJ_UID" => "", "CFG_VALUE" => serialize($arrayProjectUid), "PRO_UID" => "", "USR_UID" => "", "APP_UID" => ""));
         }
         //Delete the applications of process
         if ($flagRemoveCases) {
             $case = new \Cases();
             $criteria = new \Criteria("workflow");
             $criteria->addSelectColumn(\ApplicationPeer::APP_UID);
             $criteria->add(\ApplicationPeer::PRO_UID, $sProcessUID, \Criteria::EQUAL);
             $rsCriteria = \ApplicationPeer::doSelectRS($criteria);
             $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
             while ($rsCriteria->next()) {
                 $row = $rsCriteria->getRow();
                 $result = $case->removeCase($row["APP_UID"]);
             }
         }
         //Delete the tasks of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\TaskPeer::PRO_UID, $sProcessUID);
         $oDataset = \TaskPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             //$this->deleteTask($aRow['TAS_UID']);
             $oTasks = new \Tasks();
             $oTasks->deleteTask($aRow['TAS_UID']);
             $oDataset->next();
         }
         //Delete the dynaforms of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\DynaformPeer::PRO_UID, $sProcessUID);
         $oDataset = \DynaformPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oDynaform->remove($aRow['DYN_UID']);
             $oDataset->next();
         }
         //Delete the input documents of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\InputDocumentPeer::PRO_UID, $sProcessUID);
         $oDataset = \InputDocumentPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oInputDocument->remove($aRow['INP_DOC_UID']);
             $oDataset->next();
         }
         //Delete the output documents of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\OutputDocumentPeer::PRO_UID, $sProcessUID);
         $oDataset = \OutputDocumentPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oOutputDocument->remove($aRow['OUT_DOC_UID']);
             $oDataset->next();
         }
         //Delete the triggers of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\TriggersPeer::PRO_UID, $sProcessUID);
         $oDataset = \TriggersPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oTrigger->remove($aRow['TRI_UID']);
             $oDataset->next();
         }
         //Delete the routes of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\RoutePeer::PRO_UID, $sProcessUID);
         $oDataset = \RoutePeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oRoute->remove($aRow['ROU_UID']);
             $oDataset->next();
         }
         //Delete the gateways of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\GatewayPeer::PRO_UID, $sProcessUID);
         $oDataset = \GatewayPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oGateway->remove($aRow['GAT_UID']);
             $oDataset->next();
         }
         //Delete the Event of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\EventPeer::PRO_UID, $sProcessUID);
         $oDataset = \EventPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oEvent->remove($aRow['EVN_UID']);
             $oDataset->next();
         }
         //Delete the swimlanes elements of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\SwimlanesElementsPeer::PRO_UID, $sProcessUID);
         $oDataset = \SwimlanesElementsPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oSwimlaneElement->remove($aRow['SWI_UID']);
             $oDataset->next();
         }
         //Delete the configurations of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\ConfigurationPeer::PRO_UID, $sProcessUID);
         $oDataset = \ConfigurationPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oConfiguration->remove($aRow['CFG_UID'], $aRow['OBJ_UID'], $aRow['PRO_UID'], $aRow['USR_UID'], $aRow['APP_UID']);
             $oDataset->next();
         }
         //Delete the DB sources of process
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\DbSourcePeer::PRO_UID, $sProcessUID);
         $oDataset = \DbSourcePeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             /**
              * note added by gustavo cruz gustavo-at-colosa-dot-com 27-01-2010
              * in order to solve the bug 0004389, we use the validation function Exists
              * inside the remove function in order to verify if the DbSource record
              * exists in the Database, however there is a strange behavior within the
              * propel engine, when the first record is erased somehow the "_deleted"
              * attribute of the next row is set to true, so when propel tries to erase
              * it, obviously it can't and trows an error. With the "Exist" function
              * we ensure that if there is the record in the database, the _delete attribute must be false.
              *
              * note added by gustavo cruz gustavo-at-colosa-dot-com 28-01-2010
              * I have just identified the source of the issue, when is created a $oDbSource DbSource object
              * it's used whenever a record is erased or removed in the db, however the problem
              * it's that the same object is used every time, and the delete method invoked
              * sets the _deleted attribute to true when its called, of course as we use
              * the same object, the first time works fine but trowns an error with the
              * next record, cos it's the same object and the delete method checks if the _deleted
              * attribute it's true or false, the attrib _deleted is setted to true the
              * first time and later is never changed, the issue seems to be part of
              * every remove function in the model classes, not only DbSource
              * i recommend that a more general solution must be achieved to resolve
              * this issue in every model class, to prevent future problems.
              */
             $oDbSource->remove($aRow['DBS_UID'], $sProcessUID);
             $oDataset->next();
         }
         //Delete the supervisors
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\ProcessUserPeer::PRO_UID, $sProcessUID);
         \ProcessUserPeer::doDelete($oCriteria);
         //Delete the object permissions
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\ObjectPermissionPeer::PRO_UID, $sProcessUID);
         \ObjectPermissionPeer::doDelete($oCriteria);
         //Delete the step supervisors
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\StepSupervisorPeer::PRO_UID, $sProcessUID);
         \StepSupervisorPeer::doDelete($oCriteria);
         //Delete the report tables
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\ReportTablePeer::PRO_UID, $sProcessUID);
         $oDataset = \ReportTablePeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oReportTable->deleteReportTable($aRow['REP_TAB_UID']);
             $oDataset->next();
         }
         //Delete case tracker configuration
         $oCaseTracker->remove($sProcessUID);
         //Delete case tracker objects
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\CaseTrackerObjectPeer::PRO_UID, $sProcessUID);
         \ProcessUserPeer::doDelete($oCriteria);
         //Delete SubProcess
         $criteria = new \Criteria("workflow");
         $criteria->add(\SubProcessPeer::PRO_PARENT, $sProcessUID, \Criteria::EQUAL);
         $result = \SubProcessPeer::doDelete($criteria);
         //Delete WebEntries
         $webEntry = new \ProcessMaker\BusinessModel\WebEntry();
         $criteria = new \Criteria("workflow");
         $criteria->addSelectColumn(\WebEntryPeer::WE_UID);
         $criteria->add(\WebEntryPeer::PRO_UID, $sProcessUID, \Criteria::EQUAL);
         $rsCriteria = \WebEntryPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             $webEntry->delete($row["WE_UID"]);
         }
         //Delete WebEntry-Events
         $webEntryEvent = new \ProcessMaker\BusinessModel\WebEntryEvent();
         $criteria = new \Criteria("workflow");
         $criteria->addSelectColumn(\WebEntryEventPeer::WEE_UID);
         $criteria->add(\WebEntryEventPeer::PRJ_UID, $sProcessUID, \Criteria::EQUAL);
         $rsCriteria = \WebEntryEventPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             $webEntryEvent->delete($row["WEE_UID"]);
         }
         //Delete MessageTypes
         $messageType = new \ProcessMaker\BusinessModel\MessageType();
         $criteria = new \Criteria("workflow");
         $criteria->addSelectColumn(\MessageTypePeer::MSGT_UID);
         $criteria->add(\MessageTypePeer::PRJ_UID, $sProcessUID, \Criteria::EQUAL);
         $rsCriteria = \MessageTypePeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             $messageType->delete($row["MSGT_UID"]);
         }
         //Delete Message-Event-Relation
         $messageEventRelation = new \ProcessMaker\BusinessModel\MessageEventRelation();
         $messageEventRelation->deleteWhere(array(\MessageEventRelationPeer::PRJ_UID => $sProcessUID));
         //Delete Message-Event-Task-Relation
         $elementTaskRelation = new \ProcessMaker\BusinessModel\ElementTaskRelation();
         $elementTaskRelation->deleteWhere(array(\ElementTaskRelationPeer::PRJ_UID => $sProcessUID));
         //Delete Message-Event-Definition
         $messageEventDefinition = new \ProcessMaker\BusinessModel\MessageEventDefinition();
         $criteria = new \Criteria("workflow");
         $criteria->addSelectColumn(\MessageEventDefinitionPeer::MSGED_UID);
         $criteria->add(\MessageEventDefinitionPeer::PRJ_UID, $sProcessUID, \Criteria::EQUAL);
         $rsCriteria = \MessageEventDefinitionPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             $messageEventDefinition->delete($row["MSGED_UID"]);
         }
         //Delete Script-Task
         $scriptTask = new \ProcessMaker\BusinessModel\ScriptTask();
         $scriptTask->deleteWhere(array(\ScriptTaskPeer::PRJ_UID => array($sProcessUID, \Criteria::EQUAL)));
         //Delete Timer-Event
         $timerEvent = new \ProcessMaker\BusinessModel\TimerEvent();
         $timerEvent->deleteWhere(array(\TimerEventPeer::PRJ_UID => array($sProcessUID, \Criteria::EQUAL)));
         //Delete Email-Event
         $emailEvent = new \ProcessMaker\BusinessModel\EmailEvent();
         $criteria = new \Criteria("workflow");
         $criteria->addSelectColumn(\EmailEventPeer::EMAIL_EVENT_UID);
         $criteria->add(\EmailEventPeer::PRJ_UID, $sProcessUID, \Criteria::EQUAL);
         $rsCriteria = \EmailEventPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             $emailEvent->delete($sProcessUID, $row["EMAIL_EVENT_UID"], false);
         }
         //Delete files Manager
         $filesManager = new \ProcessMaker\BusinessModel\FilesManager();
         $criteria = new \Criteria("workflow");
         $criteria->addSelectColumn(\ProcessFilesPeer::PRF_UID);
         $criteria->add(\ProcessFilesPeer::PRO_UID, $sProcessUID, \Criteria::EQUAL);
         $rsCriteria = \ProcessFilesPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             $filesManager->deleteProcessFilesManager($sProcessUID, $row["PRF_UID"]);
         }
         //Delete the actions by email
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(\AbeConfigurationPeer::PRO_UID, $sProcessUID);
         \AbeConfigurationPeer::doDelete($oCriteria);
         //Delete the process
         try {
             $oProcess->remove($sProcessUID);
         } catch (\Exception $oError) {
             throw $oError;
         }
         return true;
     } catch (\Exception $oError) {
         throw $oError;
     }
 }
Exemplo n.º 20
0
 public function getEvent($con = null)
 {
     if ($this->aEvent === null && $this->event_id !== null) {
         include_once 'lib/model/om/BaseEventPeer.php';
         $this->aEvent = EventPeer::retrieveByPK($this->event_id, $con);
     }
     return $this->aEvent;
 }
Exemplo n.º 21
0
 public static function doSelectJoinAll(Criteria $c, $con = null)
 {
     $c = clone $c;
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     EtimePeer::addSelectColumns($c);
     $startcol2 = EtimePeer::NUM_COLUMNS - EtimePeer::NUM_LAZY_LOAD_COLUMNS + 1;
     EventPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + EventPeer::NUM_COLUMNS;
     $c->addJoin(EtimePeer::EVENT_ID, EventPeer::ID);
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $omClass = EtimePeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($rs);
         $omClass = EventPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj2 = new $cls();
         $obj2->hydrate($rs, $startcol2);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj2 = $temp_obj1->getEvent();
             if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj2->addEtime($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj2->initEtimes();
             $obj2->addEtime($obj1);
         }
         $results[] = $obj1;
     }
     return $results;
 }
Exemplo n.º 22
0
 public function getStartingEvent()
 {
     require_once 'classes/model/Event.php';
     $oCriteria = new Criteria('workflow');
     $oCriteria->addSelectColumn(EventPeer::EVN_UID);
     $oCriteria->add(EventPeer::EVN_TAS_UID_TO, $this->tas_uid);
     //$oCriteria->add(EventPeer::EVN_TYPE, 'bpmnEventMessageStart');
     $oDataset = EventPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     if ($oDataset->next()) {
         $row = $oDataset->getRow();
         $event_uid = $row['EVN_UID'];
     } else {
         $event_uid = '';
     }
     return $event_uid;
 }
Exemplo n.º 23
0
 public function getRowByTaskUidFrom($TAS_UID_FROM)
 {
     $oCriteria = new Criteria('workflow');
     $oCriteria->add(EventPeer::EVN_TAS_UID_FROM, $TAS_UID_FROM);
     $oDataset = EventPeer::doSelectRs($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     $aRow = $oDataset->getRow();
     return $aRow;
 }
Exemplo n.º 24
0
 public function executeEvents($sNow, $debug = false, &$log = array(), $cron = 0)
 {
     require_once 'classes/model/Configuration.php';
     require_once 'classes/model/Triggers.php';
     G::LoadClass('case');
     $debug = 1;
     $oCase = new Cases();
     try {
         $oCriteria = new Criteria('workflow');
         $oCriteria->addSelectColumn(AppEventPeer::APP_UID);
         $oCriteria->addSelectColumn(AppEventPeer::DEL_INDEX);
         $oCriteria->addSelectColumn(AppEventPeer::EVN_UID);
         $oCriteria->addSelectColumn(AppEventPeer::APP_EVN_ACTION_DATE);
         $oCriteria->addSelectColumn(AppEventPeer::APP_EVN_ATTEMPTS);
         $oCriteria->addSelectColumn(AppEventPeer::APP_EVN_LAST_EXECUTION_DATE);
         $oCriteria->addSelectColumn(AppEventPeer::APP_EVN_STATUS);
         $oCriteria->addSelectColumn(EventPeer::PRO_UID);
         $oCriteria->addSelectColumn(EventPeer::EVN_ACTION);
         $oCriteria->addSelectColumn(EventPeer::TRI_UID);
         $oCriteria->addSelectColumn(EventPeer::EVN_ACTION_PARAMETERS);
         $oCriteria->addSelectColumn(EventPeer::EVN_RELATED_TO);
         $oCriteria->addSelectColumn(AppDelegationPeer::TAS_UID);
         $oCriteria->addSelectColumn(AppDelegationPeer::USR_UID);
         $oCriteria->addSelectColumn(AppDelegationPeer::DEL_TASK_DUE_DATE);
         $oCriteria->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
         $oCriteria->addJoin(AppEventPeer::EVN_UID, EventPeer::EVN_UID, Criteria::JOIN);
         $aConditions = array();
         array_push($aConditions, array(AppEventPeer::APP_UID, AppDelegationPeer::APP_UID));
         array_push($aConditions, array(AppEventPeer::DEL_INDEX, AppDelegationPeer::DEL_INDEX));
         $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN);
         $oCriteria->addJoin(ApplicationPeer::APP_UID, AppEventPeer::APP_UID);
         $oCriteria->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL);
         //by me
         $oCriteria->add(AppEventPeer::APP_EVN_STATUS, 'OPEN');
         $oCriteria->add(AppEventPeer::APP_EVN_ACTION_DATE, $sNow, Criteria::LESS_EQUAL);
         $oDataset = AppEventPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $c = 0;
         while ($oDataset->next()) {
             if ($cron == 1) {
                 $arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
                 $arrayCron["processcTimeStart"] = time();
                 @file_put_contents(PATH_DATA . "cron", serialize($arrayCron));
             }
             $c++;
             $aRow = $oDataset->getRow();
             $oTrigger = new Triggers();
             $aFields = $oCase->loadCase($aRow['APP_UID']);
             $oAppEvent = AppEventPeer::retrieveByPK($aRow['APP_UID'], $aRow['DEL_INDEX'], $aRow['EVN_UID']);
             //g::pr($aRow); //die;
             if ($debug) {
                 require_once 'classes/model/Application.php';
                 $oApp = ApplicationPeer::retrieveByPk($aRow['APP_UID']);
                 $oEv = EventPeer::retrieveByPk($aRow['EVN_UID']);
                 $log[] = 'Event ' . $oEv->getEvnDescription() . ' with ID ' . $aRow['EVN_UID'];
                 println("\nOK+ event \"" . $oEv->getEvnDescription() . "\" with ID {} was found");
                 println(" - PROCESS................" . $aRow['PRO_UID']);
                 println(" - APPLICATION............" . $aRow['APP_UID'] . " CASE #" . $oApp->getAppNumber());
                 println(" - ACTION DATE............" . $aRow['APP_EVN_ACTION_DATE']);
                 println(" - ATTEMPTS..............." . $aRow['APP_EVN_ATTEMPTS']);
                 println(" - INTERVAL WITH TASKS...." . $aRow['EVN_RELATED_TO']);
             }
             if ($aRow['TRI_UID'] == '') {
                 //a rare case when the tri_uid is not set.
                 $log[] = " (!) Any trigger was set................................SKIPPED and will be CLOSED";
                 if ($debug) {
                     println(" (!) Any trigger was set................................SKIPPED and will be CLOSED");
                 }
                 $oAppEvent->setAppEvnStatus('CLOSE');
                 $oAppEvent->save();
                 continue;
             }
             $oTrigger = TriggersPeer::retrieveByPk($aRow['TRI_UID']);
             if (!is_object($oTrigger)) {
                 //the trigger record doesn't exist..
                 $log[] = ' (!) The trigger ' . $aRow['TRI_UID'] . ' ' . $oTrigger->getTriTitle() . " doesn't exist.......SKIPPED and will be CLOSED";
                 if ($debug) {
                     println(" (!) The trigger {$aRow['TRI_UID']} {$oTrigger->getTriTitle()} doesn't exist.......SKIPPED and will be CLOSED");
                 }
                 $oAppEvent->setAppEvnStatus('CLOSE');
                 $oAppEvent->save();
                 continue;
             }
             global $oPMScript;
             $oPMScript = new PMScript();
             $task = new Task();
             $taskFields = $task->Load($aRow['TAS_UID']);
             $aFields['APP_DATA']['APP_NUMBER'] = $aFields['APP_NUMBER'];
             $aFields['APP_DATA']['TAS_TITLE'] = $taskFields['TAS_TITLE'];
             $aFields['APP_DATA']['DEL_TASK_DUE_DATE'] = $aRow['DEL_TASK_DUE_DATE'];
             $oPMScript->setFields($aFields['APP_DATA']);
             $oPMScript->setScript($oTrigger->getTriWebbot());
             $oPMScript->execute();
             $oAppEvent->setAppEvnLastExecutionDate(date('Y-m-d H:i:s'));
             if (sizeof($_SESSION['TRIGGER_DEBUG']['ERRORS']) == 0) {
                 $log[] = ' - The trigger ' . $oTrigger->getTriTitle() . ' was executed successfully!';
                 if ($debug) {
                     println(" - The trigger '{$oTrigger->getTriTitle()}' was executed successfully!");
                     //g::pr($aFields);
                 }
                 $aFields['APP_DATA'] = $oPMScript->aFields;
                 $oCase->updateCase($aRow['APP_UID'], $aFields);
                 $oAppEvent->setAppEvnStatus('CLOSE');
             } else {
                 if ($debug) {
                     $log[] = ' - The trigger ' . $aRow['TRI_UID'] . ' throw some errors!';
                     println(" - The trigger {$aRow['TRI_UID']} throw some errors!");
                     print_r($_SESSION['TRIGGER_DEBUG']['ERRORS']);
                 }
                 if ($oAppEvent->getAppEvnAttempts() > 0) {
                     $oAppEvent->setAppEvnAttempts($oAppEvent->getAppEvnAttempts() - 1);
                 } else {
                     $oAppEvent->setAppEvnStatus('CLOSE');
                 }
             }
             $oAppEvent->save();
         }
         return $c;
     } catch (Exception $oError) {
         $log[] = ' Error execute event : ' . $oError->getMessage();
         die($oError->getMessage());
         return $oError->getMessage();
     }
 }
Exemplo n.º 25
0
 private function getAllEvents()
 {
     $id = $this->getRequestParameter('id');
     $c1 = new Criteria();
     $c1->add(MissionPhotoPeer::ID, $id);
     $eId = MissionPhotoPeer::doSelect($c1);
     $c = new Criteria();
     $events = EventPeer::doSelect($c);
     $str = '';
     $str .= '<th>Events</th><td><select name="event_id">';
     foreach ($events as $event) {
         if (!empty($eId)) {
             if ($eId[0]->getEventId() == $event->getId()) {
                 $str .= '<option value="' . $event->getId() . '" selected="selected">' . $event->getEventName() . '</option>';
             } else {
                 $str .= '<option value="' . $event->getId() . '">' . $event->getEventName() . '</option>';
             }
         } else {
             $str .= '<option value="' . $event->getId() . '">' . $event->getEventName() . '</option>';
         }
     }
     $str .= '</select></td>';
     return $str;
 }
Exemplo n.º 26
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = EventPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setEventName($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setEventDate($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setEventTime($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setLocation($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setShortDesc($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setLongDesc($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setContactInfo($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setEmailSentDate($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setOnlineReservation($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setAdultCost($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setChildCost($arr[$keys[11]]);
     }
     if (array_key_exists($keys[12], $arr)) {
         $this->setAdultDoorCost($arr[$keys[12]]);
     }
     if (array_key_exists($keys[13], $arr)) {
         $this->setChildDoorCost($arr[$keys[13]]);
     }
     if (array_key_exists($keys[14], $arr)) {
         $this->setSignupDeadline($arr[$keys[14]]);
     }
     if (array_key_exists($keys[15], $arr)) {
         $this->setOnsiteSignupOk($arr[$keys[15]]);
     }
     if (array_key_exists($keys[16], $arr)) {
         $this->setMaxPersons($arr[$keys[16]]);
     }
     if (array_key_exists($keys[17], $arr)) {
         $this->setCollectSecureInfo($arr[$keys[17]]);
     }
     if (array_key_exists($keys[18], $arr)) {
         $this->setAddlInfoFields($arr[$keys[18]]);
     }
     if (array_key_exists($keys[19], $arr)) {
         $this->setAddlInfoFieldsHelp($arr[$keys[19]]);
     }
 }
Exemplo n.º 27
0
    /**

     * this function remove all Process except the PROCESS ROW

     *

     * @param string $sProUid

     * @return boolean

     */

    public function removeProcessRows ($sProUid)

    {

        try {

            //Instance all classes necesaries

            $oProcess = new Process();

            $oDynaform = new Dynaform();

            $oInputDocument = new InputDocument();

            $oOutputDocument = new OutputDocument();

            $oTrigger = new Triggers();

            $oStepTrigger = new StepTrigger();

            $oRoute = new Route();

            $oStep = new Step();

            $oSubProcess = new SubProcess();

            $oCaseTracker = new CaseTracker();

            $oCaseTrackerObject = new CaseTrackerObject();

            $oObjectPermission = new ObjectPermission();

            $oSwimlaneElement = new SwimlanesElements();

            $oConnection = new DbSource();

            $oStage = new Stage();

            $oEvent = new Event();

            $oCaseScheduler = new CaseScheduler();

            $oConfig = new Configuration();



            //Delete the tasks of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( TaskPeer::PRO_UID, $sProUid );

            $oDataset = TaskPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            $oTask = new Task();

            while ($aRow = $oDataset->getRow()) {

                $oCriteria = new Criteria( 'workflow' );

                $oCriteria->add( StepTriggerPeer::TAS_UID, $aRow['TAS_UID'] );

                StepTriggerPeer::doDelete( $oCriteria );

                if ($oTask->taskExists( $aRow['TAS_UID'] )) {

                    $oTask->remove( $aRow['TAS_UID'] );

                }

                $oDataset->next();

            }



            //Delete the dynaforms of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( DynaformPeer::PRO_UID, $sProUid );

            $oDataset = DynaformPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                $sWildcard = PATH_DYNAFORM . $aRow['PRO_UID'] . PATH_SEP . $aRow['DYN_UID'] . '_tmp*';

                foreach (glob( $sWildcard ) as $fn) {

                    @unlink( $fn );

                }

                $sWildcard = PATH_DYNAFORM . $aRow['PRO_UID'] . PATH_SEP . $aRow['DYN_UID'] . '.*';

                foreach (glob( $sWildcard ) as $fn) {

                    @unlink( $fn );

                }

                if ($oDynaform->dynaformExists( $aRow['DYN_UID'] )) {

                    $oDynaform->remove( $aRow['DYN_UID'] );

                }

                $oDataset->next();

            }



            //Delete the input documents of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( InputDocumentPeer::PRO_UID, $sProUid );

            $oDataset = InputDocumentPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oInputDocument->InputExists( $aRow['INP_DOC_UID'] )) {

                    $oInputDocument->remove( $aRow['INP_DOC_UID'] );

                }

                $oDataset->next();

            }



            //Delete the output documents of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( OutputDocumentPeer::PRO_UID, $sProUid );

            $oDataset = OutputDocumentPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oOutputDocument->OutputExists( $aRow['OUT_DOC_UID'] )) {

                    $oOutputDocument->remove( $aRow['OUT_DOC_UID'] );

                }

                $oDataset->next();

            }



            //Delete the steps

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( StepPeer::PRO_UID, $sProUid );

            $oDataset = StepPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                //Delete the steptrigger of process

                /*$oCriteria = new Criteria('workflow');

                  $oCriteria->add(StepTriggerPeer::STEP_UID, $aRow['STEP_UID']);

                  $oDataseti = StepTriggerPeer::doSelectRS($oCriteria);

                  $oDataseti->setFetchmode(ResultSet::FETCHMODE_ASSOC);

                  $oDataseti->next();

                  while ($aRowi = $oDataseti->getRow()) {

                  if ($oStepTrigger->stepTriggerExists($aRowi['STEP_UID'], $aRowi['TAS_UID'], $aRowi['TRI_UID'], $aRowi['ST_TYPE']))

                  $oStepTrigger->remove($aRowi['STEP_UID'], $aRowi['TAS_UID'], $aRowi['TRI_UID'], $aRowi['ST_TYPE']);

                  $oDataseti->next();

                  }*/

                $oStep->remove( $aRow['STEP_UID'] );

                $oDataset->next();

            }



            //Delete the StepSupervisor

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( StepSupervisorPeer::PRO_UID, $sProUid );

            $oDataset = StepSupervisorPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oStep->StepExists( $aRow['STEP_UID'] )) {

                    $oStep->remove( $aRow['STEP_UID'] );

                }

                $oDataset->next();

            }



            //Delete the triggers of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( TriggersPeer::PRO_UID, $sProUid );

            $oDataset = TriggersPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oTrigger->TriggerExists( $aRow['TRI_UID'] )) {

                    $oTrigger->remove( $aRow['TRI_UID'] );

                }

                $oDataset->next();

            }

            //Delete the routes of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( RoutePeer::PRO_UID, $sProUid );

            $oDataset = RoutePeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oRoute->routeExists( $aRow['ROU_UID'] )) {

                    $oRoute->remove( $aRow['ROU_UID'] );

                }

                $oDataset->next();

            }

            //Delete the swimlanes elements of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( SwimlanesElementsPeer::PRO_UID, $sProUid );

            $oDataset = SwimlanesElementsPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oSwimlaneElement->swimlanesElementsExists( $aRow['SWI_UID'] )) {

                    $oSwimlaneElement->remove( $aRow['SWI_UID'] );

                }

                $oDataset->next();

            }



            //Delete the DB connections of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( DbSourcePeer::PRO_UID, $sProUid );

            $oDataset = DbSourcePeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oConnection->Exists( $aRow['DBS_UID'], $aRow['PRO_UID'] )) {

                    $oConnection->remove( $aRow['DBS_UID'], $aRow['PRO_UID'] );

                }

                $oDataset->next();

            }



            //Delete the sub process of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( SubProcessPeer::PRO_PARENT, $sProUid );

            $oDataset = SubProcessPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oSubProcess->subProcessExists( $aRow['SP_UID'] )) {

                    $oSubProcess->remove( $aRow['SP_UID'] );

                }

                $oDataset->next();

            }



            //Delete the caseTracker of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( CaseTrackerPeer::PRO_UID, $sProUid );

            $oDataset = CaseTrackerPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oCaseTracker->caseTrackerExists( $aRow['PRO_UID'] )) {

                    $oCaseTracker->remove( $aRow['PRO_UID'] );

                }

                $oDataset->next();

            }



            //Delete the caseTrackerObject of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( CaseTrackerObjectPeer::PRO_UID, $sProUid );

            $oDataset = CaseTrackerObjectPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oCaseTrackerObject->caseTrackerObjectExists( $aRow['CTO_UID'] )) {

                    $oCaseTrackerObject->remove( $aRow['CTO_UID'] );

                }

                $oDataset->next();

            }



            //Delete the ObjectPermission of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( ObjectPermissionPeer::PRO_UID, $sProUid );

            $oDataset = ObjectPermissionPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oObjectPermission->Exists( $aRow['OP_UID'] )) {

                    $oObjectPermission->remove( $aRow['OP_UID'] );

                }

                $oDataset->next();

            }



            //Delete the Stage of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( StagePeer::PRO_UID, $sProUid );

            $oDataset = StagePeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oStage->Exists( $aRow['STG_UID'] )) {

                    $oStage->remove( $aRow['STG_UID'] );

                }

                $oDataset->next();

            }



            //Delete the Event of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( EventPeer::PRO_UID, $sProUid );

            $oDataset = EventPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oEvent->Exists( $aRow['EVN_UID'] )) {

                    $oEvent->remove( $aRow['EVN_UID'] );

                }

                $oDataset->next();

                if ($oEvent->existsByTaskUidFrom( $aRow['TAS_UID'] )) {

                    $aRowEvent = $oEvent->getRowByTaskUidFrom( $aRow['TAS_UID'] );

                    $oEvent->remove( $aRowEvent['EVN_UID'] );

                }

                $oDataset->next();

            }



            //Delete the CaseScheduler of process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->add( CaseSchedulerPeer::PRO_UID, $sProUid );

            $oDataset = CaseSchedulerPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oCaseScheduler->Exists( $aRow['SCH_UID'] )) {

                    $oCaseScheduler->remove( $aRow['SCH_UID'] );

                }

                $oDataset->next();

            }



            //Delete the TaskExtraProperties of the process

            $oCriteria = new Criteria( 'workflow' );

            $oCriteria->addSelectColumn( ConfigurationPeer::CFG_UID );

            $oCriteria->addSelectColumn( ConfigurationPeer::OBJ_UID );

            $oCriteria->addSelectColumn( ConfigurationPeer::CFG_VALUE );

            $oCriteria->addSelectColumn( TaskPeer::PRO_UID );

            $oCriteria->addSelectColumn( ConfigurationPeer::USR_UID );

            $oCriteria->addSelectColumn( ConfigurationPeer::APP_UID );

            $oCriteria->add( TaskPeer::PRO_UID, $sProUid );

            $oCriteria->add( ConfigurationPeer::CFG_UID, 'TAS_EXTRA_PROPERTIES' );

            $oCriteria->addJoin( ConfigurationPeer::OBJ_UID, TaskPeer::TAS_UID );

            $oDataset = ConfigurationPeer::doSelectRS( $oCriteria );

            $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );

            $oDataset->next();

            while ($aRow = $oDataset->getRow()) {

                if ($oConfig->exists($aRow['CFG_UID'], $aRow['OBJ_UID'], $aRow['PRO_UID'], $aRow['USR_UID'], $aRow['APP_UID'])) {

                    $oConfig->remove( $aRow['CFG_UID'], $aRow['OBJ_UID'], $aRow['PRO_UID'], $aRow['USR_UID'], $aRow['APP_UID'] );

                }

                $oDataset->next();

            }



            return true;

        } catch (Exception $oError) {

            throw ($oError);

        }

    }
Exemplo n.º 28
0
 private function getEventFromSlug($slug)
 {
     $c = new Criteria();
     $c->add(EventPeer::SLUG, $slug);
     return EventPeer::doSelectOne($c);
 }
Exemplo n.º 29
0
 /**
  * Selects a collection of EventReservation objects pre-filled with all related objects.
  *
  * @param      Criteria  $c
  * @param      PropelPDO $con
  * @param      String    $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN
  * @return     array Array of EventReservation objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAll(Criteria $c, $con = null, $join_behavior = Criteria::LEFT_JOIN)
 {
     foreach (sfMixer::getCallables('BaseEventReservationPeer:doSelectJoinAll:doSelectJoinAll') as $callable) {
         call_user_func($callable, 'BaseEventReservationPeer', $c, $con);
     }
     $c = clone $c;
     // Set the correct dbName if it has not been overridden
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     EventReservationPeer::addSelectColumns($c);
     $startcol2 = EventReservationPeer::NUM_COLUMNS - EventReservationPeer::NUM_LAZY_LOAD_COLUMNS;
     EventPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + (EventPeer::NUM_COLUMNS - EventPeer::NUM_LAZY_LOAD_COLUMNS);
     $c->addJoin(array(EventReservationPeer::EVENT_ID), array(EventPeer::ID), $join_behavior);
     $stmt = BasePeer::doSelect($c, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $key1 = EventReservationPeer::getPrimaryKeyHashFromRow($row, 0);
         if (null !== ($obj1 = EventReservationPeer::getInstanceFromPool($key1))) {
             // We no longer rehydrate the object, since this can cause data loss.
             // See http://propel.phpdb.org/trac/ticket/509
             // $obj1->hydrate($row, 0, true); // rehydrate
         } else {
             $omClass = EventReservationPeer::getOMClass();
             $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
             $obj1 = new $cls();
             $obj1->hydrate($row);
             EventReservationPeer::addInstanceToPool($obj1, $key1);
         }
         // if obj1 already loaded
         // Add objects for joined Event rows
         $key2 = EventPeer::getPrimaryKeyHashFromRow($row, $startcol2);
         if ($key2 !== null) {
             $obj2 = EventPeer::getInstanceFromPool($key2);
             if (!$obj2) {
                 $omClass = EventPeer::getOMClass();
                 $cls = substr('.' . $omClass, strrpos('.' . $omClass, '.') + 1);
                 $obj2 = new $cls();
                 $obj2->hydrate($row, $startcol2);
                 EventPeer::addInstanceToPool($obj2, $key2);
             }
             // if obj2 loaded
             // Add the $obj1 (EventReservation) to the collection in $obj2 (Event)
             $obj2->addEventReservation($obj1);
         }
         // if joined row not null
         $results[] = $obj1;
     }
     $stmt->closeCursor();
     return $results;
 }
Exemplo n.º 30
0
 public function executeDelete()
 {
     $event = EventPeer::retrieveByPk($this->getRequestParameter('id'));
     $this->forward404Unless($event);
     $event->delete();
     return $this->redirect('event/list');
 }