Example #1
0
 /**
  * Check collision with another plage regarding defined in class spec
  *
  * @return string Collision message
  */
 function hasCollisions()
 {
     if ($this->_skip_collisions) {
         return null;
     }
     // Check whether mandatory collision keys are defined
     $keys = $this->_spec->collision_keys;
     if (!is_array($keys)) {
         CModelObject::error("CPlageHoraire-collision_keys", $this->_class);
     }
     $this->completeField("date", "debut", "fin");
     $this->completeField($keys);
     // Get all other plages the same day
     $where[$this->_spec->key] = "!= '{$this->_id}'";
     $where["date"] = "= '{$this->date}'";
     $where["debut"] = "< '{$this->fin}'";
     $where["fin"] = "> '{$this->debut}'";
     // Append collision keys clauses
     foreach ($keys as $_key) {
         $where[$_key] = "= '{$this->{$_key}}'";
     }
     // Load collision
     /** @var CPlageHoraire $plage */
     $plage = new $this->_class();
     $this->_colliding_plages = $plage->loadList($where);
     // Build collision message
     $msgs = array();
     foreach ($this->_colliding_plages as $_plage) {
         /** @var CPlageHoraire $_plage */
         $msgs[] = "Collision avec la plage de '{$_plage->debut}' à '{$_plage->fin}'";
     }
     return count($msgs) ? implode(", ", $msgs) : null;
 }
Example #2
0
 /**
  * constructor
  *
  * @param CSourcePOP $source Source POP
  */
 function __construct($source)
 {
     //stock the source
     $this->source = $source;
     if (!function_exists("imap_open")) {
         CModelObject::error("FE-IMAP-support-not-available");
     }
     //initialise open TIMEOUT
     imap_timeout(1, $this->source->timeout);
     //lets create the string for stream
     $type = $this->source->type == "pop3" ? "/" . $this->source->type : "";
     $ssl = $this->source->auth_ssl == "SSL/TLS" ? "/ssl/novalidate-cert" : "/notls";
     $port = $this->source->port ? ":" . $this->source->port : "";
     $extension = $this->source->extension ? $this->source->extension : "";
     return $this->_server = "{" . $this->source->host . $port . $type . $ssl . "}" . $extension;
 }
Example #3
0
 /**
  * Staticly build object handlers array
  *
  * @return void
  */
 protected static final function makeHandlers()
 {
     if (is_array(self::$handlers)) {
         return;
     }
     // Static initialisations
     self::$handlers = array();
     foreach (CAppUI::conf("eai_handlers") as $_class => $_active) {
         if ($_active) {
             if (!class_exists($_class)) {
                 CModelObject::error("application-eai-handler-missing-class%s", $_class);
                 continue;
             }
             self::$handlers[$_class] = new $_class();
         }
     }
 }
 /**
  * Load target of meta object
  *
  * @param bool $cache Utilisation du cache
  *
  * @return CMbObject
  */
 function loadTargetObject($cache = true)
 {
     if ($this->_ref_object || !$this->object_class) {
         return $this->_ref_object;
     }
     if (!class_exists($this->object_class)) {
         $ex_object = CExObject::getValidObject($this->object_class);
         if (!$ex_object) {
             CModelObject::error("Unable-to-create-instance-of-object_class%s-class", $this->object_class);
             return null;
         } else {
             $ex_object->load($this->object_id);
             $this->_ref_object = $ex_object;
         }
     } else {
         $this->_ref_object = $this->loadFwdRef("object_id", $cache);
     }
     if (!$this->_ref_object->_id) {
         $this->_ref_object->load(null);
         $this->_ref_object->_view = "Element supprimé";
     }
     return $this->_ref_object;
 }
 /**
  * Check collision with another plage regarding defined in class spec
  *
  * @return array Collision list
  */
 function getCollisions()
 {
     // Check whether mandatory collision keys are defined
     $keys = $this->_spec->collision_keys;
     if (!is_array($keys)) {
         CModelObject::error("class%s-collision_keys-not-available", $this->_class);
         return array();
     }
     $keys = $this->_spec->collision_keys;
     $this->completeField("start", "end");
     $this->completeField($keys);
     // Get all other plages the same day
     //chevauchement & inside
     $where[$this->_spec->key] = "!= '{$this->_id}'";
     // OLD METHOD
     /*$where[] = "(`start` < '$this->start' AND `end` > '$this->start') OR
       (`start` < '$this->end' AND `end` > '$this->end') OR
       (`start` > '$this->end' AND `end` < '$this->end')";*/
     $where["start"] = "< '{$this->end}'";
     $where["end"] = "> '{$this->start}'";
     // Append collision keys clauses
     foreach ($keys as $_key) {
         $where[$_key] = "= '{$this->{$_key}}'";
     }
     // Load collision
     /** @var CPlageCalendaire $plages */
     $plages = new $this->_class();
     $this->_colliding_plages = $plages->loadList($where);
     // Build collision message
     $msgs = array();
     /** @var $_plage CPlageCalendaire */
     foreach ($this->_colliding_plages as $_plage) {
         $msgs[] = CAppUI::tr("CPlageCalendaire-collision-with-plageNb%d-start%s-end%s", $_plage->_id, $_plage->start, $_plage->end);
     }
     return $this->_collisionList = $msgs;
 }
 /**
  * Registers a table in the module
  *
  * @param string $table Table name
  *
  * @return void
  */
 function addTable($table)
 {
     if (in_array($table, $this->tables)) {
         CModelObject::error("Table-table%s-already-exists", $table);
     }
     $this->tables[] = $table;
 }