Exemplo n.º 1
0
 /**
  * Add this object to be previewed in the form.
  * Uses {@link FORM_PREVIEW_SETTINGS} to store these settings.
  * @param AUDITABLE $obj
  * @param string $title
  * @param boolean $visible
  */
 public function add_preview($obj, $title, $visible = true)
 {
     if (!$obj->exists()) {
         $obj->modifier_id = $this->app->login->id;
         $obj->creator_id = $this->app->login->id;
     }
     parent::add_preview($obj, $title, $visible);
 }
Exemplo n.º 2
0
 /**
  * Is the passed-in object different from this history item's?
  * The object is compared to that previously set with {@link set_object()}. The objects must be the same. That
  * is, their ids must match or the function throws an exception. This function is used to track differences between
  * versions of an object, not to detect differences between objects.
  * @param AUDITABLE $obj
  * @access private
  */
 public function record_differences($obj)
 {
     $objects_are_same_or_new = $obj->exists() == $this->_object->exists() && $obj->id == $this->_object->id;
     $this->assert($objects_are_same_or_new, "Cannot compare two different objects (expected [{$this->_object->id}], got [{$obj->id}]", 'record_differences', 'HISTORY_ITEM');
     if (!$obj->exists()) {
         if (!isset($this->kind)) {
             $this->kind = $obj->history_item_kind_for_new();
         }
         $this->_is_new = true;
     } else {
         if (!isset($this->kind)) {
             $this->kind = History_item_updated;
         }
         $this->_record_differences($this->_object, $obj);
     }
 }
Exemplo n.º 3
0
 /**
  * How is the user subscribed to this object?
  * Returns a list of {@link Subscribe_constants} that match this person and the
  * given object.
  * @param AUDITABLE $obj
  * @return integer[]
  */
 public function receives_notifications_through($obj)
 {
     $Result = array();
     if (isset($this->email) && $obj->exists()) {
         $query = $obj->subscriber_query();
         $query->restrict("subscribers.email = '{$this->email}'");
         $query->set_select('subs.kind as subkind');
         $db = $query->raw_output();
         while ($db->next_record()) {
             $Result[] = $db->f('subkind');
         }
     }
     return $Result;
 }