public function create($label)
 {
     $_data = array();
     $_data['slug'] = $this->_generate_slug($label);
     $_data['label'] = $label;
     return parent::create($_data);
 }
 public function create($data, $return_object = FALSE)
 {
     //	Some basic sanity testing
     if (empty($data->label)) {
         $this->_set_error('"label" is a required field.');
         return FALSE;
     }
     // --------------------------------------------------------------------------
     $this->db->trans_begin();
     //	Create a new blank object to work with
     $_data = array('label' => $data->label);
     $_id = parent::create($_data);
     if (!$_id) {
         $this->_set_error('Unable to create base category object.');
         $this->db->trans_rollback();
         return FALSE;
     } elseif ($this->update($_id, $data)) {
         $this->db->trans_commit();
         if ($return_object) {
             return $this->get_by_id($_id);
         } else {
             return $_id;
         }
     } else {
         $this->db->trans_rollback();
         return FALSE;
     }
 }
Example #3
0
 public function create($data)
 {
     //	Some basic sanity testing
     //	Check the data
     if (empty($data->data->template)) {
         $this->_set_error('"data.template" is a required field.');
         return FALSE;
     }
     // --------------------------------------------------------------------------
     $this->db->trans_begin();
     //	Create a new blank row to work with
     $_id = parent::create();
     if (!$_id) {
         $this->_set_error('Unable to create base page object.');
         $this->db->trans_rollback();
         return FALSE;
     }
     //	Try and update it depending on how the update went, commit & update or rollback
     if ($this->update($_id, $data)) {
         $this->db->trans_commit();
         return $_id;
     } else {
         $this->db->trans_rollback();
         return FALSE;
     }
 }