Exemple #1
0
 protected function setup($r)
 {
     $this->type = Dase_DBO_ItemType::get($this->db, $r->get('collection_ascii_id'), $r->get('item_type_ascii_id'));
     if (!$this->type) {
         $r->renderError(404);
     }
 }
Exemple #2
0
 function insert($db, $r, $collection)
 {
     //think about using Slug also
     $ascii_id = Dase_Util::dirify($this->getAsciiId());
     if (!$ascii_id) {
         $ascii_id = Dase_Util::dirify($this->getTitle());
     }
     if (!Dase_DBO_ItemType::get($db, $collection->ascii_id, $ascii_id)) {
         $type = new Dase_DBO_ItemType($db);
         $type->ascii_id = $ascii_id;
         $type->name = $this->getTitle();
         $type->collection_id = $collection->id;
         $type->description = $this->getSummary();
         $type->insert();
         return $type;
     } else {
         throw new Dase_Exception('item type exists');
     }
 }
Exemple #3
0
 public function deleteItemTypeAttribute($r)
 {
     $type = Dase_DBO_ItemType::get($this->db, $this->collection->ascii_id, $r->get('type_ascii_id'));
     $att = Dase_DBO_Attribute::get($this->db, $this->collection->ascii_id, $r->get('att_ascii_id'));
     $ita = new Dase_DBO_AttributeItemType($this->db);
     $ita->attribute_id = $att->id;
     $ita->item_type_id = $type->id;
     if ($ita->findOne()) {
         $ita->delete();
         $r->renderOk('done');
     } else {
         $r->renderError(400);
     }
 }
Exemple #4
0
 function addItemType($item_type_ascii)
 {
     $c = $this->getCollection();
     $type = Dase_DBO_ItemType::get($this->db, $c->ascii_id, $item_type_ascii);
     if ($type) {
         $ita = new Dase_DBO_AttributeItemType($this->db);
         $ita->attribute_id = $this->id;
         $ita->item_type_id = $type->id;
         if (!$ita->findOne()) {
             $ita->insert();
         }
     }
 }