Example #1
0
 /**
  * This function performs the validation work for complex object models.
  *
  * In addition to checking the current object, all related objects will
  * also be validated.  If all pass then <code>true</code> is returned; otherwise
  * an aggreagated array of ValidationFailed objects will be returned.
  *
  * @param      array $columns Array of column names to validate.
  * @return     mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  */
 protected function doValidate($columns = null)
 {
     if (!$this->alreadyInValidation) {
         $this->alreadyInValidation = true;
         $retval = null;
         $failureMap = array();
         // We call the validate method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aEvent !== null) {
             if (!$this->aEvent->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aEvent->getValidationFailures());
             }
         }
         if ($this->aWing !== null) {
             if (!$this->aWing->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aWing->getValidationFailures());
             }
         }
         if (($retval = EventWingsPeer::doValidate($this, $columns)) !== true) {
             $failureMap = array_merge($failureMap, $retval);
         }
         $this->alreadyInValidation = false;
     }
     return !empty($failureMap) ? $failureMap : true;
 }
Example #2
0
 function create($aData)
 {
     if (!isset($aData['EVN_UID']) || $aData['EVN_UID'] == '') {
         $aData['EVN_UID'] = G::generateUniqueID();
     }
     $oConnection = Propel::getConnection(EventPeer::DATABASE_NAME);
     try {
         $oEvent = new Event();
         $oEvent->setEvnUid($aData['EVN_UID']);
         $oEvent->setProUid($aData['PRO_UID']);
         if (isset($aData['EVN_RELATED_TO'])) {
             $oEvent->setEvnRelatedTo($aData['EVN_RELATED_TO']);
             if ($aData['EVN_RELATED_TO'] == 'SINGLE') {
                 if (isset($aData['TAS_UID'])) {
                     $oEvent->setTasUid($aData['TAS_UID']);
                 }
                 $oEvent->setEvnTasUidTo('');
                 $oEvent->setEvnTasUidFrom('');
             } else {
                 $oEvent->setTasUid('');
                 if (isset($aData['EVN_TAS_UID_TO'])) {
                     $oEvent->setEvnTasUidTo($aData['EVN_TAS_UID_TO']);
                 }
                 if (isset($aData['EVN_TAS_UID_FROM'])) {
                     $oEvent->setEvnTasUidFrom($aData['EVN_TAS_UID_FROM']);
                 }
             }
         }
         if (isset($aData['EVN_POSX'])) {
             $oEvent->setEvnPosx($aData['EVN_POSX']);
         }
         if (isset($aData['EVN_POSY'])) {
             $oEvent->setEvnPosy($aData['EVN_POSY']);
         }
         if (isset($aData['EVN_TYPE'])) {
             $oEvent->setEvnType($aData['EVN_TYPE']);
         }
         if (isset($aData['EVN_TAS_ESTIMATED_DURATION'])) {
             $oEvent->setEvnTasEstimatedDuration($aData['EVN_TAS_ESTIMATED_DURATION']);
         }
         if (isset($aData['EVN_WHEN_OCCURS'])) {
             $oEvent->setEvnWhenOccurs($aData['EVN_WHEN_OCCURS']);
         }
         if (isset($aData['EVN_ACTION'])) {
             $oEvent->setEvnAction($aData['EVN_ACTION']);
         }
         if (isset($aData['EVN_CONDITIONS'])) {
             $oEvent->setEvnConditions($aData['EVN_CONDITIONS']);
         }
         if (isset($aData['EVN_STATUS'])) {
             $oEvent->setEvnStatus($aData['EVN_STATUS']);
         }
         if (isset($aData['EVN_WHEN'])) {
             $oEvent->setEvnWhen($aData['EVN_WHEN']);
         }
         $oEvent->setEvnMaxAttempts(3);
         //start the transaction
         $oConnection->begin();
         if (isset($aData['EVN_TYPE'])) {
             if ($aData['EVN_TYPE'] === 'bpmnEventEmptyEnd') {
                 unset($aData['TRI_UID']);
             }
         }
         if (isset($aData['TRI_UID'])) {
             $oTrigger = new Triggers();
             if (trim($aData['TRI_UID']) === "" || !$oTrigger->TriggerExists($aData['TRI_UID'])) {
                 //create an empty trigger
                 $aTrigger = array();
                 $aTrigger['PRO_UID'] = $aData['PRO_UID'];
                 $aTrigger['TRI_TITLE'] = 'For event: ' . $aData['EVN_DESCRIPTION'];
                 $aTrigger['TRI_DESCRIPTION'] = 'Autogenerated ' . $aTrigger['TRI_TITLE'];
                 $aTrigger['TRI_WEBBOT'] = '// ' . $aTrigger['TRI_DESCRIPTION'];
                 $oTrigger->create($aTrigger);
             } else {
                 $oTrigger = TriggersPeer::retrieveByPk($aData['TRI_UID']);
             }
             $oEvent->setTriUid($oTrigger->getTriUid());
             $parameters = new StdClass();
             $parameters->hash = md5($oTrigger->getTriWebbot());
             if (isset($aData['EVN_ACTION_PARAMETERS']->SUBJECT)) {
                 $parameters->SUBJECT = $aData['EVN_ACTION_PARAMETERS']->SUBJECT;
                 $parameters->TO = $aData['EVN_ACTION_PARAMETERS']->TO;
                 $parameters->CC = $aData['EVN_ACTION_PARAMETERS']->CC;
                 $parameters->BCC = $aData['EVN_ACTION_PARAMETERS']->BCC;
                 $parameters->TEMPLATE = $aData['EVN_ACTION_PARAMETERS']->TEMPLATE;
             }
             $oEvent->setEvnActionParameters(serialize($parameters));
         }
         if ($oEvent->validate()) {
             $iResult = $oEvent->save();
             if (isset($aData['EVN_DESCRIPTION'])) {
                 $oEvent->setEvnDescription($aData['EVN_DESCRIPTION']);
             }
             $oConnection->commit();
             return $aData['EVN_UID'];
         } else {
             $sMessage = '';
             $aValidationFailures = $oEvent->getValidationFailures();
             foreach ($aValidationFailures as $oValidationFailure) {
                 $sMessage .= $oValidationFailure->getMessage() . '<br />';
             }
             throw new Exception('The row Event cannot be created!<br />' . $sMessage);
         }
     } catch (Exception $oError) {
         $oConnection->rollback();
         throw $oError;
     }
 }
 if (isset($_POST["max_attendance"])) {
     $max_attendance = htmlspecialchars($_POST["max_attendance"]);
 }
 // set up event object
 $event = new Event();
 $event->setTitle($title);
 $event->setDate($date);
 $event->setStartTime($start_time);
 $event->setEndTime($end_time);
 $event->setLocation($location);
 $event->setDescription($description);
 $event->setMaxAttendance($max_attendance);
 $event->setCreatorUserId($_SESSION['uid']);
 $failure_messages = array();
 if (!$event->validate()) {
     foreach ($event->getValidationFailures() as $failure) {
         $message = '<p><strong>Error in ' . $failure->getPropertyPath() . ' field!</strong> ' . $failure->getMessage() . '</p>';
         array_push($failure_messages, $message);
         // clear out the bad data
         $_POST[$failure->getPropertyPath()] = '';
     }
     unset($message);
 } else {
     // validate date fields
     //$now = new DateTime('now');
     $st = DateTime::createFromFormat("m/d/Y H:i A", $date . " " . $start_time);
     $et = DateTime::createFromFormat("m/d/Y H:i A", $date . " " . $end_time);
     /*
             if($now > $st) {
                 array_push($failure_messages, "<p><strong>Error:</strong> You cannot create an event that has already started</p>");
                 } else */