Пример #1
0
	/**
	 * returns the FileVersion object for the provided fvID
	 * if none provided returns the approved version
	 * @param int $fvID
	 * @return FileVersion
	 */
	public function getVersion($fvID = null) {
		if ($fvID == null) {
			$fvID = $this->fvID; // approved version
		}
		
		$fv = Cache::get('file_version_' . $this->getFileID(), $fvID);
		if (is_object($fv)) {
			return $fv;
		}
		
		$db = Loader::db();
		$row = $db->GetRow("select * from FileVersions where fvID = ? and fID = ?", array($fvID, $this->fID));
		$row['fvAuthorName'] = $db->GetOne("select uName from Users where uID = ?", array($row['fvAuthorUID']));
		
		$fv = new FileVersion();
		$row['fslID'] = $this->fslID;
		$fv->setPropertiesFromArray($row);
		$fv->populateAttributes();
		
		Cache::set('file_version_' . $this->getFileID(), $fvID, $fv);		
		return $fv;
	}
Пример #2
0
	/**
	 * returns the FileVersion object for the provided fvID
	 * if none provided returns the approved version
	 * @param int $fvID
	 * @return FileVersion
	 */
	public function getVersion($fvID = null) {

		if ($fvID == null) {
			$fvID = $this->fvID; // approved version
		}
		$fv = CacheLocal::getEntry('file', $this->getFileID() . ':' . $fvID);
		if ($fv === -1) {
			return false;
		}
		if ($fv) {
			return $fv;
		}

		$db = Loader::db();
		$row = $db->GetRow("select * from FileVersions where fvID = ? and fID = ?", array($fvID, $this->fID));
		$row['fvAuthorName'] = $db->GetOne("select uName from Users where uID = ?", array($row['fvAuthorUID']));
		
		$fv = new FileVersion();
		$row['fslID'] = $this->fslID;
		$fv->setPropertiesFromArray($row);
		
		CacheLocal::set('file', $this->getFileID() . ':' . $fvID, $fv);
		return $fv;
	}