Example #1
0
		public function get($itemsToGet = 0, $offset = 0) {
			$r = parent::get($itemsToGet, $offset);
			foreach($r as $row) {
				$fs = FileSet::getByID($row['fsID']);
				if (is_object($fs)) {
					$this->sets[] = $fs;
				}
			}
			return $this->sets;
		}
Example #2
0
	public function view_detail($fsID, $action = false) {
		Loader::model('file_set');
		$fs = FileSet::getByID($fsID);
		$ph = Loader::controller('/dashboard/system/permissions/files');
		$this->set('ph', $ph);		
		$this->set('fs', $fs);	
		if ($action == 'file_set_updated') {
			$this->set('message', t('File set updated successfully.'));
		}
		$this->view();		
	}		
Example #3
0
 public function view()
 {
     $fs = FileSet::getByID($this->fsID);
     $fileList = new FileList();
     $fileList->filterBySet($fs);
     $fileList->filterByType(FileType::T_IMAGE);
     $fileList->sortByFileSetDisplayOrder();
     $images = $fileList->get(1000, 0);
     $this->set('images', $images);
     $this->set('picture', $this->getPicture());
 }
Example #4
0
	function loadFileSet(){
		if (intval($this->fsID) < 1) {
			return false;
		}
        Loader::helper('concrete/file');
		Loader::model('file_attributes');
		Loader::library('file/types');
		Loader::model('file_list');
		Loader::model('file_set');
		
		$ak = FileAttributeKey::getByHandle('height');

		$fs = FileSet::getByID($this->fsID);
		$fileList = new FileList();		
		$fileList->filterBySet($fs);
		$fileList->filterByType(FileType::T_IMAGE);	
		$fileList->sortByFileSetDisplayOrder();
		
		$files = $fileList->get(1000,0);
		
		
		$image = array();
		$image['duration'] = $this->duration;
		$image['fadeDuration'] = $this->fadeDuration;
		$image['groupSet'] = 0;
		$image['url'] = '';
		$images = array();
		$maxHeight = 0;
		foreach ($files as $f) {
			$fp = new Permissions($f);
			if(!$fp->canViewFile()) { continue; }
			$image['fID'] 			= $f->getFileID();
			$image['fileName'] 		= $f->getFileName();
			$image['fullFilePath'] 	= $f->getPath();
			$image['url']			= $f->getRelativePath();
			
			// find the max height of all the images so slideshow doesn't bounce around while rotating
			$vo = $f->getAttributeValueObject($ak);
			if (is_object($vo)) {
				$image['imgHeight'] = $vo->getValue('height');
			}
			if ($maxHeight == 0 || $image['imgHeight'] > $maxHeight) {
				$maxHeight = $image['imgHeight'];
			}
			$images[] = $image;
		}
		$this->images = $images;
	
	}
 public static function getUnsortedPermittedFilesetImages($fsID)
 {
     Loader::model('file_set');
     Loader::model('file_list');
     $fsHasDisplayOrder = version_compare(APP_VERSION, '5.4.1', '>=');
     $fs = FileSet::getByID($fsID);
     $fl = new FileList();
     $fl->filterBySet($fs);
     $fl->filterByType(FileType::T_IMAGE);
     if ($fsHasDisplayOrder) {
         $fl->sortByFileSetDisplayOrder();
     }
     $all_files = $fl->get();
     $permitted_files = array();
     foreach ($all_files as $f) {
         $fp = new Permissions($f);
         if ($fp->canRead()) {
             $permitted_files[] = $f;
         }
     }
     return $permitted_files;
 }
Example #6
0
 public static function getPermittedFilesetImages($fsID, $use_file_props_for_title_and_caption = false)
 {
     Loader::model('file_set');
     Loader::model('file_list');
     $fsHasDisplayOrder = version_compare(APP_VERSION, '5.4.1', '>=');
     $fs = FileSet::getByID($fsID);
     $fl = new FileList();
     $fl->filterBySet($fs);
     $fl->filterByType(FileType::T_IMAGE);
     if ($fsHasDisplayOrder) {
         $fl->sortByFileSetDisplayOrder();
     }
     $all_files = $fl->get();
     $permitted_files = array();
     foreach ($all_files as $f) {
         $fp = new Permissions($f);
         if ($fp->canRead()) {
             $fv = $f->getRecentVersion();
             $permitted_files[$f->fID] = array('file' => $f, 'fID' => $f->fID, 'position' => $fsHasDisplayOrder ? $f->fsDisplayOrder : 0, 'title' => $use_file_props_for_title_and_caption ? $fv->getTitle() : '', 'caption' => $use_file_props_for_title_and_caption ? $fv->getDescription() : '');
         }
     }
     return $permitted_files;
 }
Example #7
0
 protected function migrateFileSetPermissions()
 {
     $db = Loader::db();
     $tables = $db->MetaTables();
     if (!in_array('FileSetPermissions', $tables)) {
         return false;
     }
     // permissions
     $fpe = FileUploaderPermissionAccessEntity::getOrCreate();
     $permissionMap = array('canRead' => array(PermissionKey::getByHandle('view_file_set_file')), 'canSearch' => array(PermissionKey::getByHandle('search_file_set')), 'canWrite' => array(PermissionKey::getByHandle('edit_file_set_file_properties'), PermissionKey::getByHandle('edit_file_set_file_contents'), PermissionKey::getByHandle('copy_file_set_files'), PermissionKey::getByHandle('delete_file_set_files')), 'canAdmin' => array(PermissionKey::getByHandle('edit_file_set_permissions'), PermissionKey::getByHandle('delete_file_set')));
     $r = $db->Execute('select * from FileSetPermissions order by fsID asc');
     while ($row = $r->FetchRow()) {
         $pe = $this->migrateAccessEntity($row);
         if (!$pe) {
             continue;
         }
         if ($row['fsID'] > 0) {
             $fs = FileSet::getByID($row['fsID']);
         } else {
             $fs = FileSet::getGlobal();
         }
         $permissions = $this->getFileSetPermissionsArray($row);
         if (is_object($fs)) {
             foreach ($permissions as $p => $accessType) {
                 if ($accessType == self::ACCESS_TYPE_MINE) {
                     $_pe = $fpe;
                 } else {
                     $_pe = $pe;
                 }
                 $permissionsToApply = $permissionMap[$p];
                 foreach ($permissionsToApply as $pko) {
                     $pko->setPermissionObject($fs);
                     $pt = $pko->getPermissionAssignmentObject();
                     $pa = $pko->getPermissionAccessObject();
                     if (!is_object($pa)) {
                         $pa = PermissionAccess::create($pko);
                     } else {
                         if ($pa->isPermissionAccessInUse()) {
                             $pa = $pa->duplicate();
                         }
                     }
                     $pa->addListItem($_pe, false, FileSetPermissionKey::ACCESS_TYPE_INCLUDE);
                     $pt->assignPermissionAccess($pa);
                 }
             }
         }
     }
 }
Example #8
0
<?php

defined('C5_EXECUTE') or die("Access Denied.");
Loader::model("file_set");
if ($_REQUEST['fsID'] > 0) {
    $fs = FileSet::getByID($_REQUEST['fsID']);
} else {
    $fs = FileSet::getGlobal();
}
$fsp = new Permissions($fs);
if ($fsp->canEditFileSetPermissions()) {
    Loader::element('permission/details/file_set', array("fileset" => $fs));
}
Example #9
0
 /**
  * Creats a new fileset if set doesn't exists
  *
  * If we find a multiple groups with the same properties,
  * we return an array containing each group
  * @param string $fs_name
  * @param int $fs_type
  * @param int $fs_uid
  * @return Mixed 
  *
  * Dev Note: This will create duplicate sets with the same name if a set exists owned by another user!!! 
  */
 public static function createAndGetSet($fs_name, $fs_type, $fs_uid = false)
 {
     if (!$fs_uid) {
         $u = new User();
         $fs_uid = $u->uID;
     }
     $file_set = new FileSet();
     $criteria = array($fs_name, $fs_type, $fs_uid);
     $matched_sets = $file_set->Find('fsName=? AND fsType=? and uID=?', $criteria);
     if (1 === count($matched_sets)) {
         return $matched_sets[0];
     } else {
         if (1 < count($matched_sets)) {
             return $matched_sets;
         } else {
             //AS: Adodb Active record is complaining a ?/value array mismatch unless
             //we explicatly set the primary key ID field to null
             $file_set->fsID = null;
             $file_set->fsName = $fs_name;
             $file_set->fsOverrideGlobalPermissions = 0;
             $file_set->fsType = $fs_type;
             $file_set->uID = $fs_uid;
             $file_set->save();
             $db = Loader::db();
             $fsID = $db->Insert_Id();
             $fs = FileSet::getByID($fsID);
             Events::fire('on_file_set_add', $fs);
             return $fs;
         }
     }
 }
Example #10
0
	public function getFileSets() {
		$db = Loader::db();
		$fsIDs = $db->Execute("select fsID from FileSetFiles where fID = ?", array($this->getFileID()));
		$filesets = array();
		while ($row = $fsIDs->FetchRow()) {
			$filesets[] = FileSet::getByID($row['fsID']);
		}
		return $filesets;
	}
Example #11
0
<?php

defined('C5_EXECUTE') or die(_("Access Denied."));
$ih = Loader::helper('image');
$fs = FileSet::getByID($file_set);
$fsname = $fs->fsName;
?>

<?php 
if ($enableTitle) {
    echo '<h4>' . $fsname . '</h4>';
}
?>

<?php 
if ($images !== false) {
    ?>
<ul class="clearing-thumbs" data-clearing>
<?php 
    foreach ($images as $image) {
        $thumbnail = $ih->getThumbnail($image, $thumbnailWidth, $thumbnailHeight, true);
        ?>
	<li>
		<a class="th" title="<?php 
        echo $image->getTitle();
        ?>
" href="<?php 
        echo $image->getRelativePath();
        ?>
">
			<img data-caption="<?php 
Example #12
0
 public function view_detail($fsID, $action = false)
 {
     Loader::model('file_set');
     $fs = FileSet::getByID($fsID);
     $ph = Loader::controller('/dashboard/files/access');
     $this->set('ph', $ph);
     $this->set('fs', $fs);
     switch ($action) {
         case 'file_set_order_saved':
             $this->set('message', t('File set order updated.'));
             break;
     }
     $this->view();
 }
Example #13
0
 protected function setupFilePermissions()
 {
     $u = new User();
     if ($this->permissionLevel == false || $u->isSuperUser()) {
         return false;
     }
     $accessEntities = $u->getUserAccessEntityObjects();
     foreach ($accessEntities as $pae) {
         $peIDs[] = $pae->getAccessEntityID();
     }
     $db = Loader::db();
     // figure out which sets can read files in, not read files in, and read only my files in.
     $fsIDs = $db->GetCol('select fsID from FileSets where fsOverrideGlobalPermissions = 1');
     $viewableSets = array(-1);
     $nonviewableSets = array(-1);
     $myviewableSets = array(-1);
     $owpae = FileUploaderPermissionAccessEntity::getOrCreate();
     if (count($fsIDs) > 0) {
         $pk = PermissionKey::getByHandle($this->permissionLevel);
         foreach ($fsIDs as $fsID) {
             $fs = FileSet::getByID($fsID);
             $pk->setPermissionObject($fs);
             $list = $pk->getAccessListItems(PermissionKey::ACCESS_TYPE_ALL, $accessEntities);
             $list = PermissionDuration::filterByActive($list);
             if (count($list) > 0) {
                 foreach ($list as $l) {
                     $pae = $l->getAccessEntityObject();
                     if ($pae->getAccessEntityID() == $owpae->getAccessEntityID()) {
                         $myviewableSets[] = $fs->getFileSetID();
                     } else {
                         if ($l->getAccessType() == PermissionKey::ACCESS_TYPE_INCLUDE) {
                             $viewableSets[] = $fs->getFileSetID();
                         }
                         if ($l->getAccessType() == PermissionKey::ACCESS_TYPE_EXCLUDE) {
                             $nonviewableSets[] = $fs->getFileSetID();
                         }
                     }
                 }
             } else {
                 $nonviewableSets[] = $fs->getFileSetID();
             }
         }
     }
     $fs = FileSet::getGlobal();
     $fk = PermissionKey::getByHandle('search_file_set');
     $fk->setPermissionObject($fs);
     $accessEntities[] = $owpae;
     $list = $fk->getAccessListItems(PermissionKey::ACCESS_TYPE_ALL, $accessEntities);
     $list = PermissionDuration::filterByActive($list);
     foreach ($list as $l) {
         $pae = $l->getAccessEntityObject();
         if ($pae->getAccessEntityID() == $owpae->getAccessEntityID()) {
             $valid = 'mine';
         } else {
             if ($l->getAccessType() == PermissionKey::ACCESS_TYPE_INCLUDE) {
                 $valid = PermissionKey::ACCESS_TYPE_INCLUDE;
             }
             if ($l->getAccessType() == PermissionKey::ACCESS_TYPE_EXCLUDE) {
                 $valid = PermissionKey::ACCESS_TYPE_EXCLUDE;
             }
         }
     }
     $uID = $u->isRegistered() ? $u->getUserID() : 0;
     // This excludes all files found in sets where I may only read mine, and I did not upload the file
     $this->filter(false, '(f.uID = ' . $uID . ' or (select count(fID) from FileSetFiles where FileSetFiles.fID = f.fID and fsID in (' . implode(',', $myviewableSets) . ')) = 0)');
     if ($valid == 'mine') {
         // this means that we're only allowed to read files we've uploaded (unless, of course, those files are in previously covered sets)
         $this->filter(false, '(f.uID = ' . $uID . ' or (select count(fID) from FileSetFiles where FileSetFiles.fID = f.fID and fsID in (' . implode(',', $viewableSets) . ')) > 0)');
     }
     // this excludes all file that are found in sets that I can't find
     $this->filter(false, '((select count(fID) from FileSetFiles where FileSetFiles.fID = f.fID and fsID in (' . implode(',', $nonviewableSets) . ')) = 0)');
     $uID = $u->isRegistered() ? $u->getUserID() : 0;
     // This excludes all files found in sets where I may only read mine, and I did not upload the file
     $this->filter(false, '(f.uID = ' . $uID . ' or (select count(fID) from FileSetFiles where FileSetFiles.fID = f.fID and fsID in (' . implode(',', $myviewableSets) . ')) = 0)');
     $db = Loader::db();
     $vpvPKID = $db->GetOne('select pkID from PermissionKeys where pkHandle = \'view_file\'');
     if ($this->permissionLevel == 'search_file_set') {
         $vpPKID = $db->GetOne('select pkID from PermissionKeys where pkHandle = \'view_file_in_file_manager\'');
     } else {
         $vpPKID = $vpvPKID;
     }
     $pdIDs = $db->GetCol("select distinct pdID from FilePermissionAssignments fpa inner join PermissionAccessList pal on fpa.paID = pal.paID where pkID in (?, ?) and pdID > 0", array($vpPKID, $vpvPKID));
     $activePDIDs = array();
     if (count($pdIDs) > 0) {
         // then we iterate through all of them and find any that are active RIGHT NOW
         foreach ($pdIDs as $pdID) {
             $pd = PermissionDuration::getByID($pdID);
             if ($pd->isActive()) {
                 $activePDIDs[] = $pd->getPermissionDurationID();
             }
         }
     }
     $activePDIDs[] = 0;
     // exclude files where its overridden but I don't have the ability to read
     $this->filter(false, "(f.fOverrideSetPermissions = 0 or (select count(fID) from FilePermissionAssignments fpa inner join PermissionAccessList fpal on fpa.paID = fpal.paID where fpa.fID = f.fID and fpal.accessType = " . PermissionKey::ACCESS_TYPE_INCLUDE . " and fpal.pdID in (" . implode(',', $activePDIDs) . ") and fpal.peID in (" . implode(',', $peIDs) . ") and (if(fpal.peID = " . $owpae->getAccessEntityID() . " and f.uID <> " . $uID . ", false, true)) and (fpa.pkID = " . $vpPKID . ")) > 0)");
     // exclude detail files where read is excluded
     $this->filter(false, "f.fID not in (select ff.fID from Files ff inner join FilePermissionAssignments fpaExclude on ff.fID = fpaExclude.fID inner join PermissionAccessList palExclude on fpaExclude.paID = palExclude.paID where fOverrideSetPermissions = 1 and palExclude.accessType = " . PermissionKey::ACCESS_TYPE_EXCLUDE . " and palExclude.pdID in (" . implode(',', $activePDIDs) . ")\n\t\t\tand palExclude.peID in (" . implode(',', $peIDs) . ") and fpaExclude.pkID in (" . $vpPKID . "," . $vpvPKID . "))");
 }
Example #14
0
	public function getFileSets() {
		$db = Loader::db();
		Loader::model('file_set');
		$fsIDs = $db->Execute("select fsID from FileSetFiles where fID = ?", array($this->getFileID()));
		$filesets = array();
		foreach($fsIDs as $fsID) {
			$filesets[] = FileSet::getByID($fsID);
		}
		return $filesets;
	}
 protected function getBuildFileSets()
 {
     Loader::model('file_set');
     Loader::model('file_list');
     $pl = new MootoolsPluginList();
     $rows = array();
     $fsets = $this->getLoadFileSet();
     foreach ($fsets as $key => $fsID) {
         $fs = FileSet::getByID($fsID);
         $name = $fs->getFileSetName();
         $files = $pl->getMootoolsPluginFiles($fs);
         $rows[$name] = $files;
     }
     return $rows;
 }
Example #16
0
 static function getFilesetImages($fsID, $randomize = false)
 {
     Loader::model('file_set');
     Loader::model('file_list');
     $fs = FileSet::getByID($fsID);
     $fl = new FileList();
     $fl->filterBySet($fs);
     $fl->filterByType(FileType::T_IMAGE);
     $fl->setPermissionLevel('canRead');
     if ($randomize) {
         $fl->sortBy('RAND()', 'asc');
     } else {
         $fl->sortByFileSetDisplayOrder();
         //Requires 5.4.1 or higher: version_compare(APP_VERSION, '5.4.1', '>=');
     }
     $files = $fl->get();
     return $files;
 }
Example #17
0
	
	$fs->state = $state;
	$sets[] = $fs;
}


if ($_POST['task'] == 'add_to_sets') {
	
	foreach($_POST as $key => $value) {
	
		if (preg_match('/fsID:/', $key)) {
			$fsIDst = explode(':', $key);
			$fsID = $fsIDst[1];
			
			// so the affected file set is $fsID, the state of the thing is $value
			$fs = FileSet::getByID($fsID);
			$fsp = new Permissions($fs);
			if ($fsp->canAddFile($f)) {
				switch($value) {
					case '0':
						foreach($files as $f) {
							$fs->removeFileFromSet($f);
						}
						break;
					case '1':
						// do nothing
						break;
					case '2':
						foreach($files as $f) {
							$fs->addFileToSet($f);
						}
 public function getRequestedSearchResults()
 {
     $fileList = new FileList();
     $fileList->enableStickySearchRequest();
     Loader::model('file_set');
     if ($_REQUEST['submit_search']) {
         $fileList->resetSearchRequest();
     }
     $req = $fileList->getSearchRequest();
     // first thing, we check to see if a saved search is being used
     if (isset($_REQUEST['fssID'])) {
         $fs = FileSet::getByID($_REQUEST['fssID']);
         if ($fs->getFileSetType() == FileSet::TYPE_SAVED_SEARCH) {
             $req = $fs->getSavedSearchRequest();
             $columns = $fs->getSavedSearchColumns();
             $colsort = $columns->getDefaultSortColumn();
             $fileList->addToSearchRequest('ccm_order_dir', $colsort->getColumnDefaultSortDirection());
             $fileList->addToSearchRequest('ccm_order_by', $colsort->getColumnKey());
         }
     }
     if (!isset($columns)) {
         $columns = FileManagerColumnSet::getCurrent();
     }
     $this->set('searchRequest', $req);
     $this->set('columns', $columns);
     $col = $columns->getDefaultSortColumn();
     $fileList->sortBy($col->getColumnKey(), $col->getColumnDefaultSortDirection());
     $keywords = htmlentities($req['fKeywords'], ENT_QUOTES, APP_CHARSET);
     if ($keywords != '') {
         $fileList->filterByKeywords($keywords);
     }
     if ($req['numResults']) {
         $fileList->setItemsPerPage($req['numResults']);
     }
     if (isset($req['fsIDNone']) && $req['fsIDNone'] == 1 || is_array($req['fsID']) && in_array(-1, $req['fsID'])) {
         $fileList->filterBySet(false);
     } else {
         if (is_array($req['fsID'])) {
             foreach ($req['fsID'] as $fsID) {
                 $fs = FileSet::getByID($fsID);
                 $fileList->filterBySet($fs);
             }
         } else {
             if (isset($req['fsID']) && $req['fsID'] != '' && $req['fsID'] > 0) {
                 $set = $req['fsID'];
                 $fs = FileSet::getByID($set);
                 $fileList->filterBySet($fs);
             }
         }
     }
     if (isset($_GET['fType']) && $_GET['fType'] != '') {
         $type = $_GET['fType'];
         $fileList->filterByType($type);
     }
     if (isset($_GET['fExtension']) && $_GET['fExtension'] != '') {
         $ext = $_GET['fExtension'];
         $fileList->filterByExtension($ext);
     }
     $selectedSets = array();
     if (is_array($req['selectedSearchField'])) {
         foreach ($req['selectedSearchField'] as $i => $item) {
             // due to the way the form is setup, index will always be one more than the arrays
             if ($item != '') {
                 switch ($item) {
                     case "extension":
                         $extension = $req['extension'];
                         $fileList->filterByExtension($extension);
                         break;
                     case "type":
                         $type = $req['type'];
                         $fileList->filterByType($type);
                         break;
                     case "date_added":
                         $dateFrom = $req['date_from'];
                         $dateTo = $req['date_to'];
                         if ($dateFrom != '') {
                             $dateFrom = date('Y-m-d', strtotime($dateFrom));
                             $fileList->filterByDateAdded($dateFrom, '>=');
                             $dateFrom .= ' 00:00:00';
                         }
                         if ($dateTo != '') {
                             $dateTo = date('Y-m-d', strtotime($dateTo));
                             $dateTo .= ' 23:59:59';
                             $fileList->filterByDateAdded($dateTo, '<=');
                         }
                         break;
                     case 'added_to':
                         $ocID = $req['ocIDSearchField'];
                         if ($ocID > 0) {
                             $fileList->filterByOriginalPageID($ocID);
                         }
                         break;
                     case "size":
                         $from = $req['size_from'];
                         $to = $req['size_to'];
                         $fileList->filterBySize($from, $to);
                         break;
                     default:
                         Loader::model('file_attributes');
                         $akID = $item;
                         $fak = FileAttributeKey::get($akID);
                         $type = $fak->getAttributeType();
                         $cnt = $type->getController();
                         $cnt->setRequestArray($req);
                         $cnt->setAttributeKey($fak);
                         $cnt->searchForm($fileList);
                         break;
                 }
             }
         }
     }
     if (isset($req['numResults'])) {
         $fileList->setItemsPerPage($req['numResults']);
     }
     return $fileList;
 }