Ejemplo n.º 1
0
 /**
  *
  * @param type $id
  *
  * @return Tracker_FileInfo
  */
 public function getById($id)
 {
     $row = $this->dao->searchById($id)->getRow();
     if (!$row) {
         return;
     }
     $field_id = $this->dao->searchFieldIdByFileInfoId($id);
     if (!$field_id) {
         return;
     }
     $field = $this->formelement_factory->getFormElementById($field_id);
     if (!$field) {
         return;
     }
     if (!$field->isUsed()) {
         return;
     }
     return new Tracker_FileInfo($row['id'], $field, $row['submitted_by'], $row['description'], $row['filename'], $row['filesize'], $row['filetype']);
 }
Ejemplo n.º 2
0
 /**
  * get an instance of fileinfo, identified by its $id
  *
  * @param Tracker_FormElement_Field_File $field The field the fileinfo belongs to
  * @param int                            $id    The id of the fileinfo
  * @param array                          $row   The raw data of the fileinfo (optionnal)
  *
  * @return Tracker_FileInfo or null if not found
  */
 public static function instance(Tracker_FormElement_Field_File $field, $id, $row = null)
 {
     if (!isset(self::$instances_by_id[$id])) {
         self::$instances_by_id[$id] = null;
         $dao = new Tracker_FileInfoDao();
         //TODO: check that the attachment belongs to the field
         if ($row || ($row = $dao->searchById($id)->getRow())) {
             self::$instances_by_id[$id] = new Tracker_FileInfo($row['id'], $field, $row['submitted_by'], $row['description'], $row['filename'], $row['filesize'], $row['filetype']);
         }
     }
     return self::$instances_by_id[$id];
 }