예제 #1
0
 /**
  * Create root user and basic permission structure in the database.
  * For detailed documentation on permission structure, see
  * PermissionHandler class.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     // Create admin user with admin permisions
     Sentry::getUserProvider()->create(['_id' => ProjectHandler::ADMIN_USER, 'password' => 'admin', 'email' => '*****@*****.**', 'firstname' => 'Admin', 'lastname' => 'Crowdtruth']);
     // Create the admin group with special permission Permissions::ALLOW_ALL
     ProjectHandler::createGroup('admin');
     $adminGroup = Sentry::findGroupByName('admin:admin');
     $permissions = $adminGroup->permissions;
     $permissions[Permissions::ALLOW_ALL] = 1;
     // Allowed everything !
     $adminGroup->permissions = $permissions;
     $adminGroup->save();
     // Assign user admin to group admin.
     $root = Sentry::findUserByLogin(ProjectHandler::ADMIN_USER);
     $root->addGroup($adminGroup);
 }
예제 #2
0
 /**
  * Handle POST requests to create a new group. 
  */
 public function createGroup()
 {
     $groupName = Input::get('addGrp');
     try {
         ProjectHandler::createGroup($groupName);
         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
 /**
  * update units to new data structure
  */
 public function postUpdatedb()
 {
     $searchComponent = new MediaSearchComponent();
     // amount of units to index per iteration
     $batchsize = 50;
     $from = Input::get('next');
     $unitCount = Entity::whereIn('tags', ['unit'])->count();
     // reset index on start
     if ($from == 0) {
         $searchComponent->clear();
     }
     // reduce last batch to remaining units
     if ($from + $batchsize > $unitCount) {
         $batchsize = $unitCount - $from;
     }
     // all units in this range
     $units = Entity::distinct('_id')->where('tags', ['unit'])->skip($from)->take($batchsize)->get();
     // get list of existing projects
     $projects = ProjectHandler::listGroups();
     // for each unit get the keys and check if the project exists
     $allKeys = [];
     for ($i = $from; $i < $from + $batchsize; $i++) {
         // get data of unit
         $unit = Entity::where('_id', $units[$i][0])->first();
         switch ($unit['documentType']) {
             case 'annotatedmetadatadescription':
                 $unit['project'] = 'soundandvision';
                 break;
             case 'biographynet-sentence':
                 $unit['project'] = 'biographynet';
                 break;
             case 'drawing':
                 $unit['project'] = 'rijksmuseum';
                 break;
             case 'enrichedvideo':
                 $unit['project'] = 'soundandvision';
                 break;
             case 'enrichedvideov2':
                 $unit['project'] = 'soundandvision';
                 break;
             case 'enrichedvideov3':
                 $unit['project'] = 'soundandvision';
                 break;
             case 'fullvideo':
                 $unit['project'] = 'soundandvision';
                 break;
             case 'metadatadescription':
                 $unit['project'] = 'soundandvision';
                 break;
             case 'metadatadescription-event':
                 $unit['project'] = 'soundandvision';
                 break;
             case 'painting':
                 $unit['project'] = 'rijksmuseum';
                 break;
             case 'relex':
                 $unit['project'] = 'ibmrelex';
                 break;
             case 'relex-sentence':
                 $unit['project'] = 'ibmrelex';
                 break;
             case 'relex-structured-sentence':
                 $unit['project'] = 'ibmrelex';
                 break;
             case 'termpairs-sentence':
                 $unit['project'] = 'ibmdisdis';
                 break;
         }
         // add the project if it doesnt exist yet
         if (!in_array($unit['project'], $projects)) {
             ProjectHandler::createGroup($unit['project']);
             // add the project to the temporary list
             array_push($projects, $unit['project']);
         }
         // add the user to the project if it has no access yet
         if (!ProjectHandler::inGroup($unit['user_id'], $unit['project'])) {
             $user = UserAgent::find($unit['user_id']);
             ProjectHandler::grantUser($user, $unit['project'], Roles::PROJECT_MEMBER);
         }
         $id = explode('/', $unit['_id']);
         if (sizeof($id) == 5) {
             $entity = new Entity();
             // copy properties
             $entity['documentType'] = $unit['documentType'];
             $entity['test'] = 'new';
             $entity->_id = 'entity/' . $entity->documentType . '/' . $id[4];
             $entity->save();
         }
     }
     return ['log' => 'test', 'next' => $from + $batchsize, 'last' => $unitCount];
 }