dowload file IF file is belongs to a specific set AND logged ind user belongs to a specific Group.

Permalink 1 user found helpful
Hello there, i am trying to make a script where users associated to a specific group can download files associated to specific set.
And if not user is, he is simply redirectet to another page.

So something like this :p
If file-getFileSet("some set") = 1
and user-getUserGroup("some group") = 1
then...



Here is what i got...

I'm trying my way out at the bottom og this file:
concrete/controllers/download_file.php
private function download($file,$rcID=NULL) {
      //$mime_type = finfo_file(DIR_FILES_UPLOADED."/".$filename);
      //header('Content-type: $mime_type');
      // everything else lets just download
      $filename = $file->getFilename();
      $file->trackDownload($rcID);
      $ci = Loader::helper('file');
      $ci->forceDownload($file->getPath());      
   }



Can anyone please give me a hint on how to do this?

I have tried a bunch of things with this, but i am no php shark.
$file->getFileSets()

Hope you can help!

 
jordanlev replied on at Permalink Best Answer Reply
jordanlev
For the user:
Loader::model('user');
Loader::model('groups');
$u = new User();
$g = Group::getByName('groupname');
if ($u->inGroup($g)) {
  //user is in group
}


For the file:
Loader::model('file_set');
$fileID = 123;
$fileSet = FileSet::getByName('filesetname');
if ($fileSet->hasFileID($fileID)) {
  //file is in set
}
innodia replied on at Permalink Reply
Perfect!!
Thank you so much Jordanlev!