Exemplo n.º 1
0
 public static function getByTitle($db, $r, $title)
 {
     $item = new Dase_DBO_Item($db);
     $item->title = $title;
     if ($item->findOne()) {
         return $item->asArray($r);
     } else {
         return false;
     }
 }
Exemplo n.º 2
0
 public static function get($db, $collection_ascii_id, $serial_number)
 {
     if (!$collection_ascii_id || !$serial_number) {
         throw new Exception('missing information');
     }
     $item = new Dase_DBO_Item($db);
     $item->p_collection_ascii_id = $collection_ascii_id;
     $item->serial_number = $serial_number;
     if ($item->findOne()) {
         return $item;
     } else {
         return false;
     }
 }
Exemplo n.º 3
0
 private function _findUniqueName($name, $iter = 0)
 {
     if ($iter) {
         $checkname = $name . '_' . $iter;
     } else {
         $checkname = $name;
     }
     $item = new Dase_DBO_Item($this->db);
     $item->name = $checkname;
     if (!$item->findOne()) {
         return $checkname;
     } else {
         $iter++;
         return $this->_findUniqueName($name, $iter);
     }
 }
Exemplo n.º 4
0
 function createNewItem($serial_number = null, $eid = null)
 {
     if (!$eid) {
         $eid = '_dase';
     }
     $item = new Dase_DBO_Item($this->db);
     $item->collection_id = $this->id;
     if ($serial_number) {
         $item->serial_number = $serial_number;
         if ($item->findOne()) {
             Dase_Log::info(LOG_FILE, "duplicate serial number: " . $serial_number);
             throw new Dase_Exception('duplicate serial number!');
             return;
         }
         $item->status = 'public';
         $item->item_type_id = 0;
         $item->item_type_ascii_id = 'default';
         $item->item_type_name = 'default';
         $item->created = date(DATE_ATOM);
         $item->updated = date(DATE_ATOM);
         $item->created_by_eid = $eid;
         $item->p_collection_ascii_id = $this->ascii_id;
         $item->p_remote_media_host = $this->remote_media_host;
         $item->collection_name = $this->collection_name;
         $item->insert();
         $this->updateItemCount();
         return $item;
     } else {
         $item->status = 'public';
         $item->item_type_id = 0;
         $item->item_type_ascii_id = 'default';
         $item->item_type_name = 'default';
         $item->created = date(DATE_ATOM);
         $item->created_by_eid = $eid;
         $item->p_collection_ascii_id = $this->ascii_id;
         $item->p_remote_media_host = $this->remote_media_host;
         $item->collection_name = $this->collection_name;
         $item->insert();
         //after move to mysql to avoid collisions w/ old sernums
         //replace first '0' w/ '1'
         //todo: better way to generate unique sernum.
         // (do NOT forget to enforce uniqueness in DB)
         //$item->serial_number = sprintf("%09d",$item->id);
         $item->serial_number = '1' . sprintf("%08d", $item->id);
         $item->updated = date(DATE_ATOM);
         $item->update();
         $this->updateItemCount();
         return $item;
     }
 }