Beispiel #1
0
 /**
  *
  */
 public function insert($pa_options = null)
 {
     $vn_rc = parent::insert($pa_options);
     if ($this->getPrimaryKey()) {
         // create root in ca_list_items
         $t_item_root = new ca_list_items();
         $t_item_root->setMode(ACCESS_WRITE);
         if ($this->inTransaction()) {
             $t_item_root->setTransaction($this->getTransaction());
         }
         $t_item_root->set('list_id', $this->getPrimaryKey());
         $t_item_root->set('idno', $vs_title = 'Root node for ' . $this->get('list_code'));
         $t_item_root->set('is_enabled', 0);
         $t_item_root->set('item_value', 'Root');
         $t_item_root->insert();
         if ($t_item_root->numErrors()) {
             $this->delete();
             $this->errors = array_merge($this->errors, $t_item_root->errors);
             return false;
         }
         $vn_locale_id = ca_locales::getDefaultCataloguingLocaleID();
         $t_item_root->addLabel(array('name_singular' => $vs_title, 'name_plural' => $vs_title), $vn_locale_id, null, true);
         if ($t_item_root->numErrors()) {
             $this->delete();
             $this->errors = array_merge($this->errors, $t_item_root->errors);
             return false;
         }
     }
     return $vn_rc;
 }