/**
  * Perform actions triggered from the user list page (/users). Actions performed:
  * addGroup    - Adds a given user to a given CT-group
  * assignRole  - Assigns the given role to a given user on the given CT-group.
  * removeGroup - Removes the given user from the given CT-group.
  * 
  * Browser is redirected to calling page (hopefully /users), with a flashError or 
  * flashSuccess message indicating the result.
  */
 public function groupActions($groupName)
 {
     $targetUserName = Input::get('usedId');
     $targetUser = UserAgent::find($targetUserName);
     if (!$targetUser) {
         return Redirect::back()->with('flashError', 'User does not exist: ' . $targetUserName);
     }
     $action = Input::get('action');
     if ($action == 'addGroup') {
         $userRole = ProjectHandler::grantUser($targetUser, $groupName, Roles::PROJECT_GUEST);
         return Redirect::back()->with('flashSuccess', 'User ' . $targetUserName . ' added to group ' . $groupName);
     } elseif ($action == 'assignRole') {
         $roleName = Input::get('role');
         $role = Roles::getRoleByName($roleName);
         $userRole = ProjectHandler::grantUser($targetUser, $groupName, $role);
         return Redirect::back()->with('flashSuccess', 'User ' . $targetUserName . ' assigned role ' . $roleName . ' on group ' . $groupName);
     } elseif ($action == 'removeGroup') {
         ProjectHandler::revokeUser($targetUser, $groupName);
         return Redirect::back()->with('flashSuccess', 'User ' . $targetUserName . ' removed from group ' . $groupName);
     } else {
         return Redirect::back()->with('flashError', 'Invalid action selected: ' . $action);
     }
 }
示例#2
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;
 }