예제 #1
0
 public function __construct($attributes = array(), $guard_attributes = TRUE, $instantiating_via_find = FALSE, $new_record = TRUE)
 {
     parent::__construct($attributes, $guard_attributes, $instantiating_via_find, $new_record);
     $this->CI =& get_instance();
     $this->CI->load->helper('oa');
     $this->CI->load->library('uploader/OrmUploader');
     $this->CI->load->library('JsonBind');
     $this->CI->load->library('Cfg');
 }
예제 #2
0
 public function attributes()
 {
     $attributes = parent::attributes();
     foreach ($attributes as $k => $v) {
         if ($v instanceof ActiveRecord\DateTime) {
             $attributes[$k] = $v->format('Y-m-d H:i:s');
         }
     }
     return $attributes;
 }
예제 #3
0
파일: Menu.php 프로젝트: bparks/pails-menu
 function __get($name)
 {
     if ($name == 'menu_items') {
         if (isset(self::$menu_defs[$this->slug])) {
             return array_merge($this->__menu_items->to_array(), self::$menu_defs[$this->slug]);
         } else {
             return $this->__menu_items;
         }
     }
     return parent::__get($name);
 }
예제 #4
0
 /**
  * @return array
  */
 public function to_array()
 {
     $a = parent::to_array();
     $a['parent'] = $this->parent_id ? $this->parent->to_array() : null;
     return $a;
 }
예제 #5
0
 public function tableModel()
 {
     \ActiveRecord\Model::$table_name = $this->table;
 }
예제 #6
0
 public function __construct()
 {
     parent::__construct();
 }
예제 #7
0
 public function save($validate = true, $location = '')
 {
     //replace all \" to ", to prevent " loopback when saving (client->server " -> \")
     /*$config = static::getFieldsConfig();
       foreach ($config as $key => $value) {
           if (!static::ISFLOWFIELD($key) && !static::ISSYSTEMFIELD($key)) {
               $this->{$key} = str_replace('\\"', '"', $this->{$key});//quocdunginfo, need to find other approach
               $this->{$key} = str_replace("\\'", "'", $this->{$key});//quocdunginfo, need to find other approach
           }
       }*/
     //check permission
     if (!$this->checkPermission(__FUNCTION__)) {
         return false;
     }
     //do validate and save
     if (!$validate || $this->QDVALIDATE()) {
         $action = $this->is_new_record() ? QdLog::$ACTION_INSERT : QdLog::$ACTION_MODIFY;
         if (!$this->checkMandatory()) {
             return false;
         }
         //assign no series before insert
         if ($this->id === null || $this->id === false || $this->id === 0 || $this->id === '0') {
             $use_noseries = $this->getNoSeries();
             if ($use_noseries === false) {
                 //do not use noseries
             } else {
                 //use no series
                 $tmpnose = $this->getNoFromNoSeries($use_noseries);
                 if ($tmpnose === false) {
                     $this->pushValidateError('', 'NoSeries Fail', 'error');
                     return false;
                 } else {
                     $this->id = $tmpnose;
                     if (static::hasFieldName('noseries')) {
                         $this->noseries = $use_noseries;
                     }
                 }
             }
         } else {
             //manual or update => do not get next no
         }
         try {
             $re = parent::save($validate);
             //checked on July 05, 2015, Only 1 root save called
             $class_name = $this->getCalledClassName();
             $location .= "|{$class_name}|save";
             if ($re && $class_name != 'QdLog') {
                 //write log
                 $this->writeLog($action, $location);
                 //quocdunginfo
             }
             return $re;
         } catch (Exception $ex) {
             //$this->id = 0;
             $this->pushValidateError('', $ex, 'error');
             return false;
         }
     } else {
         return false;
     }
 }