コード例 #1
0
ファイル: file.php プロジェクト: notzen/concrete5
	public function addVersion($filename, $prefix, $data = array()) {
		$u = new User();
		$uID = (isset($data['uID']) && $data['uID'] > 0) ? $data['uID'] : $u->getUserID();
		
		if ($uID < 1) {
			$uID = 0;
		}
		
		$fvTitle = (isset($data['fvTitle'])) ? $data['fvTitle'] : '';
		$fvDescription = (isset($data['fvDescription'])) ? $data['fvDescription'] : '';
		$fvTags = (isset($data['fvTags'])) ? FileVersion::cleanTags($data['fvTags']) : '';
		$fvIsApproved = (isset($data['fvIsApproved'])) ? $data['fvIsApproved'] : '1';

		$db = Loader::db();
		$dh = Loader::helper('date');
		$date = $dh->getSystemDateTime();
		
		$fvID = $db->GetOne("select max(fvID) from FileVersions where fID = ?", array($this->fID));
		if ($fvID > 0) {
			$fvID++;
		} else {
			$fvID = 1;
		}
		
		$db->Execute('insert into FileVersions (fID, fvID, fvFilename, fvPrefix, fvDateAdded, fvIsApproved, fvApproverUID, fvAuthorUID, fvActivateDateTime, fvTitle, fvDescription, fvTags, fvExtension) 
		values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array(
			$this->fID, 
			$fvID,
			$filename,
			$prefix, 
			$date,
			$fvIsApproved, 
			$uID, 
			$uID, 
			$date,
			$fvTitle,
			$fvDescription, 
			$fvTags,
			''));;
			
		$fv = $this->getVersion($fvID);
		Events::fire('on_file_version_add', $fv);
		return $fv;
	}
コード例 #2
0
ファイル: file_version.php プロジェクト: nbourguig/concrete5
	public function updateTags($tags) {
		$db = Loader::db();
		$tags = FileVersion::cleanTags($tags);
		$db->Execute("update FileVersions set fvTags = ? where fID = ? and fvID = ?", array($tags, $this->getFileID(), $this->getFileVersionID()));
		$this->logVersionUpdate(FileVersion::UT_TAGS);
		$this->fvTitle = $tags;
		Events::fire('on_file_version_update_tags', $this, $tags);
		$fo = $this->getFile();
		$fo->refreshCache();
	}
コード例 #3
0
ファイル: version_530.php プロジェクト: Zyqsempai/amanet
 public function run()
 {
     $db = Loader::db();
     Loader::model('collection_attributes');
     Loader::model('single_page');
     Loader::model('file_version');
     // Add in stuff that may have gotten missed before
     $p = Page::getByPath('/profile');
     if ($p->isError()) {
         $d1 = SinglePage::add('/profile');
         $d2 = SinglePage::add('/profile/edit');
         $d3 = SinglePage::add('/profile/avatar');
     }
     $p2 = Page::getByPath('/dashboard/users/registration');
     if ($p2->isError()) {
         $d4 = SinglePage::add('/dashboard/users/registration');
     }
     // Move any global blocks to new scrapbook page.
     $sc = Page::getByPath("/dashboard/scrapbook/global");
     $scn = Page::getByPath('/dashboard/scrapbook');
     $scu = Page::getByPath('/dashboard/scrapbook/user');
     if (!$sc->isError()) {
         $blocks = $sc->getBlocks("Global Scrapbook");
         if (count($blocks) > 0) {
             // we create the new shared scrapbook 1
             $a = Area::getOrCreate($scn, t('Shared Scrapbook 1'));
             foreach ($blocks as $_b) {
                 // we move them into the area on the new page.
                 $_b->move($scn, $a);
                 $_b->refreshCacheAll();
             }
         }
         $sc->delete();
     }
     if (!$scu->isError()) {
         $scu->delete();
     }
     //add the new collection attribute keys
     $cak = CollectionAttributeKey::getByHandle('header_extra_content');
     if (!is_object($cak)) {
         CollectionAttributeKey::add('header_extra_content', t('Header Extra Content'), true, null, 'TEXT');
     }
     $cak = CollectionAttributeKey::getByHandle('exclude_search_index');
     if (!is_object($cak)) {
         CollectionAttributeKey::add('exclude_search_index', t('Exclude From Search Index'), true, null, 'BOOLEAN');
     }
     //convert file tags to new format, cleaned up with leading and trailing line breaks
     $fileVersionsData = $db->GetAll('SELECT fID, fvID, fvTags FROM FileVersions');
     foreach ($fileVersionsData as $fvData) {
         $vals = array(FileVersion::cleanTags($fvData['fvTags']), $fvData['fID'], $fvData['fvID']);
         $db->query('UPDATE FileVersions SET fvTags=? WHERE fID=? AND fvID=?', $vals);
     }
 }