Beispiel #1
0
 public function getReservationreasons($criteria = null, PropelPDO $con = null)
 {
     if (is_null($criteria)) {
         $criteria = new Criteria();
         $criteria->addAscendingOrderByColumn(ReservationreasonPeer::NAME);
     }
     return parent::getReservationreasons($criteria, $con);
 }
Beispiel #2
0
 /**
  * Returns a peer instance associated with this om.
  *
  * Since Peer classes are not to have any instance attributes, this method returns the
  * same instance for all member of this class. The method could therefore
  * be static, but this would prevent one from overriding the behavior.
  *
  * @return     ActivityPeer
  */
 public function getPeer()
 {
     if (self::$peer === null) {
         self::$peer = new ActivityPeer();
     }
     return self::$peer;
 }
Beispiel #3
0
 public function setMeta($v)
 {
     parent::setMeta(json_encode($v));
     return $this;
 }
Beispiel #4
0
 function sendTo($from, $activityId, $split = false)
 {
     //1: if we are in a join check if this instance is also in other activity
     //if so do nothing
     $type = $this->getOne("SELECT `type` FROM `" . GALAXIA_TABLE_PREFIX . "activities` WHERE `activityId`=?", array((int) $activityId));
     // Verify the existance of a transition
     if (!$this->getOne("SELECT count(*) FROM `" . GALAXIA_TABLE_PREFIX . "transitions` WHERE `actFromId`=? AND `actToId`=?", array($from, (int) $activityId))) {
         trigger_error(tra('Fatal error: trying to send an instance to an activity but no transition found'), E_USER_WARNING);
     }
     //Use the nextUser
     if ($this->nextUser) {
         $putuser = $this->nextUser;
     } else {
         //Try to determine the user or *
         $candidates = array();
         $query = "SELECT `roleId` FROM `" . GALAXIA_TABLE_PREFIX . "activity_roles` WHERE `activityId`=?";
         $result = $this->query($query, array((int) $activityId));
         while ($res = $result->fetchRow()) {
             $roleId = $res['roleId'];
             $query2 = "SELECT `user` FROM `" . GALAXIA_TABLE_PREFIX . "user_roles` WHERE `roleId`=?";
             $result2 = $this->query($query2, array((int) $roleId));
             while ($res2 = $result2->fetchRow()) {
                 $candidates[] = $res2['user'];
             }
         }
         $putuser = count($candidates) == 1 ? $candidates[0] : '*';
     }
     $now = date("U");
     $iid = $this->instanceId;
     // Test if the join activity has preceding activities that are not completed yet
     if ($type == 'join') {
         // Calculate 1)how many incoming transitions the activity has, and 2)how many of those are completed
         $querycant = "SELECT COUNT(*) FROM `" . GALAXIA_TABLE_PREFIX . "transitions` WHERE actToId = ?";
         $querycomp = "SELECT COUNT(*) FROM `" . GALAXIA_TABLE_PREFIX . "transitions` tr " . "INNER JOIN " . GALAXIA_TABLE_PREFIX . "instance_activities gia ON tr.actFromId=gia.activityId\r\n                     WHERE tr.pid=? AND tr.actToId=? AND gia.instanceId=? AND gia.status = ?";
         $transcant = $this->getone($querycant, array($activityId));
         $transcomp = $this->getone($querycomp, array($this->pId, $activityId, $iid, 'completed'));
         // if there are still preceding activities not completed, STOP
         if ($nb = $transcant - $transcomp) {
             //echo 'Pending preceding activities = ' . $nb;
             return;
         }
     }
     $query = "DELETE FROM `" . GALAXIA_TABLE_PREFIX . "instance_activities` WHERE `instanceId`=? AND `activityId`=?";
     $this->query($query, array((int) $iid, (int) $activityId));
     $query = "INSERT INTO `" . GALAXIA_TABLE_PREFIX . "instance_activities` (`instanceId`, `activityId`, `user`, `status`, `started`) VALUES (?,?,?,?,?)";
     $this->query($query, array((int) $iid, (int) $activityId, $putuser, 'running', (int) $now));
     // Check whether the activity we're sending the instance to is interactive
     $isInteractive = $this->getOne("SELECT `isInteractive` FROM `" . GALAXIA_TABLE_PREFIX . "activities` WHERE `activityId`=?", array((int) $activityId));
     //if the activity is not interactive then execute its code and complete it
     if ($isInteractive == 'n') {
         // These are necessary to determine if the activity needs to be recompiled
         $proc = new Process($this->db);
         $proc->getProcess($this->pId);
         $baseact = new BaseActivity($this->db);
         $act = $baseact->getActivity($activityId);
         // Get paths for original and compiled activity code
         $origcode = 'lib/Galaxia/processes/' . $proc->getNormalizedName() . '/code/activities/' . $act->getNormalizedName() . '.php';
         $compcode = 'lib/Galaxia/processes/' . $proc->getNormalizedName() . '/compiled/' . $act->getNormalizedName() . '.php';
         // Check whether the activity code is newer than its compiled counterpart,
         // i.e. check if the source code was changed; if so, we need to recompile
         if (filemtime($origcode) > filemtime($compcode)) {
             // Recompile
             include_once 'lib/Galaxia/src/ProcessManager/ActivityManager.php';
             include_once 'lib/Galaxia/src/ProcessManager/ProcessManager.php';
             $am = new ActivityManager($this->db);
             $am->compile_activity($this->pId, $activityId);
         }
         // Now execute the code for the activity (function galaxia_execute_activity
         // is defined in lib/Galaxia/config.php)
         galaxia_execute_activity($activityId, $iid, 1);
         // Reload in case the activity did some change
         $this->getInstance($this->instanceId);
         $this->complete($activityId);
     }
 }