示例#1
0
 /**
  * Creates a new Project -- all required sentryGroups are created for the Project.
  * When a new Project is created, roles for the Project are created as follows, 
  * with their corresponding permissions:
  * 
  *  - Roles::PROJECT_ADMIN, with Permissions::PROJECT_ADMIN, Permissions::PROJECT_WRITE and 
  *  	Permissions::PROJECT_READ;
  *  - Roles::PROJECT_MEMBER, with Permissions::PROJECT_WRITE, and Permissions::PROJECT_READ;
  *  - Roles::PROJECT_GUEST, with Permissions::PROJECT_READ,
  * 
  * Default invitation codes are also created for the Project.
  * 
  * Account credentials for CrowdFlower are also stored as part of the Project information.
  * 
  * @param $projectName Name of the Project to be created.
  */
 public static function createGroup($projectName)
 {
     // $groupName credentials are stored in the Admin Sentry-group
     Sentry::createGroup(['name' => str_replace('#', $projectName, Roles::PROJECT_ADMIN), 'permissions' => [str_replace('#', $projectName, Permissions::PROJECT_ADMIN) => 1, str_replace('#', $projectName, Permissions::PROJECT_WRITE) => 1, str_replace('#', $projectName, Permissions::PROJECT_READ) => 1], 'invite_code' => $projectName . '_invitation_admin', 'credentials' => [ProjectHandler::CF_USER => '', ProjectHandler::CF_PASS => '']]);
     Sentry::createGroup(['name' => str_replace('#', $projectName, Roles::PROJECT_MEMBER), 'permissions' => [str_replace('#', $projectName, Permissions::PROJECT_ADMIN) => 0, str_replace('#', $projectName, Permissions::PROJECT_WRITE) => 1, str_replace('#', $projectName, Permissions::PROJECT_READ) => 1], 'invite_code' => $projectName . '_invitation_member']);
     Sentry::createGroup(['name' => str_replace('#', $projectName, Roles::PROJECT_GUEST), 'permissions' => [str_replace('#', $projectName, Permissions::PROJECT_ADMIN) => 0, str_replace('#', $projectName, Permissions::PROJECT_WRITE) => 0, str_replace('#', $projectName, Permissions::PROJECT_READ) => 1], 'invite_code' => $projectName . '_invitation_guest']);
     // Assign user admin to group admin role.
     ProjectHandler::grantUser(Sentry::findUserByLogin(ProjectHandler::ADMIN_USER), $projectName, Roles::PROJECT_ADMIN);
 }
 /**
  * Handle POST requests to create a new group. 
  */
 public function createGroup()
 {
     $groupName = Input::get('addGrp');
     try {
         ProjectHandler::createGroup($groupName);
         ProjectHandler::grantUser(Auth::user(), $groupName, Roles::PROJECT_ADMIN);
         return Redirect::back()->with('flashSuccess', 'Group <b>' . $groupName . '</b> succesfully created!');
     } catch (\Cartalyst\Sentry\Groups\GroupExistsException $e) {
         return Redirect::back()->with('flashError', 'Group <b>' . $groupName . '</b> already exists!');
     }
 }
示例#3
0
 public function store($documentType, $parameters, $noOfVideos)
 {
     //fastcgi_finish_request();
     $listOfVideoIdentifiers = array();
     $this->listRecords($parameters, $noOfVideos, $listOfVideoIdentifiers);
     // get list of existing projects
     $projects = ProjectHandler::listProjects();
     //	dd("done");
     $status = array();
     try {
         $this->createOpenimagesVideoGetterSoftwareAgent();
     } catch (Exception $e) {
         $status['error']['OnlineData'] = $e->getMessage();
         return $status;
     }
     try {
         $activity = new Activity();
         $activity->softwareAgent_id = "openimagesgetter";
         $activity->save();
     } catch (Exception $e) {
         // Something went wrong with creating the Activity
         $status['error']['OnlineData'] = $e->getMessage();
         $activity->forceDelete();
         return $status;
     }
     $count["count"] = 0;
     foreach ($listOfVideoIdentifiers as $video) {
         $title = $video;
         try {
             $entity = new Unit();
             $entity->_id = $entity->_id;
             $entity->title = strtolower($title);
             $entity->documentType = $documentType;
             $entity->source = "openimages";
             $entity->project = "soundandvision";
             $entity->type = "unit";
             $videoMetadata = $this->getRecord($video, $parameters["metadataPrefix"]);
             $entity->content = $videoMetadata["content"];
             $parents = array();
             $entity->parents = $parents;
             $entity->tags = array("unit");
             $entity->segments = $count;
             $entity->keyframes = $count;
             $hashing = array();
             $hashing["content"] = $entity->content;
             $hashing["project"] = $entity->project;
             $entity->hash = md5(serialize($hashing));
             $entity->activity_id = $activity->_id;
             $entity->save();
             $status['success'][$title] = $title . " was successfully uploaded. (URI: {$entity->_id})";
             // add the project if it doesnt exist yet
             if (!in_array($entity->project, $projects)) {
                 ProjectHandler::createGroup($entity->project);
                 // add the project to the temporary list
                 array_push($projects, $entity->project);
             }
             // add the user to the project if it has no access yet
             if (!ProjectHandler::inGroup($entity->user_id, $entity->project)) {
                 $user = UserAgent::find($entity->user_id);
                 ProjectHandler::grantUser($user, $entity->project, Roles::PROJECT_MEMBER);
             }
         } catch (Exception $e) {
             // Something went wrong with creating the Entity
             $activity->forceDelete();
             $entity->forceDelete();
             $status['error'][$title] = $e->getMessage();
         }
     }
     $status["recno"] = count($listOfVideoIdentifiers);
     return $status;
 }