Exemplo n.º 1
0
 private function main(\Orm\Model $obj)
 {
     if (!$this->_relations) {
         return;
     }
     foreach ($this->_relations as $props) {
         if (!empty($props['check_changed'])) {
             $check_properties = isset($props['check_changed']['check_properties']) ? $props['check_changed']['check_properties'] : array();
             $ignore_properties = isset($props['check_changed']['ignore_properties']) ? $props['check_changed']['ignore_properties'] : array();
             if (!\Util_Orm::check_is_updated($obj, $check_properties, $ignore_properties)) {
                 continue;
             }
         }
         $this->_model_to = $props['model_to'];
         $this->_conditions = $props['conditions'];
         $this->_execute_func = $props['execute_func'];
         if (!empty($props['check_changed'])) {
             $check_properties = isset($props['check_changed']['check_properties']) ? $props['check_changed']['check_properties'] : array();
             $ignore_properties = isset($props['check_changed']['ignore_properties']) ? $props['check_changed']['ignore_properties'] : array();
             if (!\Util_Orm::check_is_updated($obj, $check_properties, $ignore_properties)) {
                 continue;
             }
         }
         $this->execute($obj);
     }
 }
Exemplo n.º 2
0
 public function before_update(\Orm\Model $obj)
 {
     if (\Util_Orm::check_is_updated($obj, $this->_check_properties, $this->_ignore_properties)) {
         if (!empty($obj->{$this->_property_from})) {
             $obj->{$this->_property} = $obj->{$this->_property_from};
         } else {
             $obj->{$this->_property} = $this->_mysql_timestamp ? \Date::time()->format('mysql') : \Date::time()->get_timestamp();
         }
     }
 }
Exemplo n.º 3
0
 private function main(\Orm\Model $obj)
 {
     if (!$this->_relations) {
         return;
     }
     if (!\Util_Orm::check_is_updated($obj, $this->_check_properties, $this->_ignore_properties)) {
         return;
     }
     foreach ($this->_relations as $props) {
         $this->_model_to = $props['model_to'];
         $this->_conditions = $props['conditions'];
         $this->_update_properties = $props['update_properties'];
         $this->execute($obj);
     }
 }
 private function main(\Orm\Model $obj)
 {
     if (!\Util_Orm::check_is_updated($obj, $this->_check_properties, $this->_ignore_properties)) {
         return;
     }
     if (!($datetime = $this->get_datetime_from_relational_model($obj))) {
         if (!$obj->is_new() || !empty($obj->{$this->_property})) {
             return;
         }
         if (!empty($obj->{$this->_property_created_at})) {
             $datetime = $obj->{$this->_property_created_at};
         } else {
             $datetime = $this->_mysql_timestamp ? \Date::time()->format('mysql') : \Date::time()->get_timestamp();
         }
     }
     $obj->{$this->_property} = $datetime;
 }
Exemplo n.º 5
0
 public function after_update(\Orm\Model $obj)
 {
     if (\Util_Orm::check_is_updated($obj, $this->_check_properties, $this->_ignore_properties)) {
         \Timeline\Site_Util::delete_cache($obj->id, $obj->type);
     }
 }