예제 #1
0
 function testAddMultiple()
 {
     $equivalent = new Perms_Reflection_PermissionSet();
     $equivalent->add('Anonymous', 'a');
     $equivalent->add('Anonymous', 'b');
     $equivalent->add('Anonymous', 'c');
     $multi = new Perms_Reflection_PermissionSet();
     $multi->add('Anonymous', array('a', 'b', 'c'));
     $this->assertEquals($equivalent, $multi);
 }
예제 #2
0
 private function getCategoryPermissions()
 {
     $categories = $this->getCategories();
     $set = new Perms_Reflection_PermissionSet();
     $count = 0;
     foreach ($categories as $category) {
         $category = $this->factory->get('category', $category);
         foreach ($category->getDirectPermissions()->getPermissionArray() as $group => $perms) {
             foreach ($perms as $perm) {
                 $set->add($group, $perm);
                 ++$count;
             }
         }
     }
     if ($count != 0) {
         return $set;
     }
 }
예제 #3
0
    $newPermissions = get_assign_permissions();
    $filter = TikiFilter::get('text');
    $to_copy = array('perms' => $newPermissions->getPermissionArray(), 'object' => $filter->filter($_REQUEST['objectId']), 'type' => $filter->filter($_REQUEST['objectType']));
    $_SESSION['perms_clipboard'] = $to_copy;
}
if (!empty($_SESSION['perms_clipboard'])) {
    $perms_clipboard = $_SESSION['perms_clipboard'];
    $smarty->assign('perms_clipboard_source', $perms_clipboard['type'] . (empty($perms_clipboard['object']) ? '' : ' : ') . $perms_clipboard['object']);
    if (isset($_REQUEST['paste'])) {
        $access->check_authenticity(tra('Are you sure you want paste the copied permissions onto this object?'));
        unset($_SESSION['perms_clipboard']);
        $set = new Perms_Reflection_PermissionSet();
        if (isset($perms_clipboard['perms'])) {
            foreach ($perms_clipboard['perms'] as $group => $gperms) {
                foreach ($gperms as $perm) {
                    $set->add($group, $perm);
                }
            }
        }
        $permissionApplier->apply($set);
        $smarty->assign('perms_clipboard_source', '');
    }
}
//Quickperms apply {{{
//Test to map permissions of ile galleries into read write admin admin levels.
if ($prefs['feature_quick_object_perms'] == 'y') {
    $qperms = quickperms_get_data();
    $smarty->assign('quickperms', $qperms);
    $quickperms = new Perms_Reflection_Quick();
    foreach ($qperms as $type => $data) {
        $quickperms->configure($type, $data['data']);
예제 #4
0
 function testRevertIfWithinBounds()
 {
     $current = new Perms_Reflection_PermissionSet();
     $current->add('Anonymous', 'view');
     $parent = new Perms_Reflection_PermissionSet();
     $parent->add('Anonymous', 'view');
     $parent->add('Registered', 'edit');
     $parent->add('Admins', 'admin');
     $newSet = new Perms_Reflection_PermissionSet();
     $newSet->add('Anonymous', 'view');
     $newSet->add('Registered', 'edit');
     $newSet->add('Admins', 'admin');
     $target = $this->getMock('Perms_Reflection_Container');
     $target->expects($this->once())->method('getDirectPermissions')->will($this->returnValue($current));
     $target->expects($this->once())->method('getParentPermissions')->will($this->returnValue($parent));
     $target->expects($this->once())->method('remove')->with($this->equalTo('Anonymous'), $this->equalTo('view'));
     $applier = new Perms_Applier();
     $applier->addObject($target);
     $applier->restrictPermissions(array('view', 'edit', 'admin'));
     $applier->apply($newSet);
 }
예제 #5
0
 function testIdenticalHasNoDifferences()
 {
     $a = new Perms_Reflection_PermissionSet();
     $a->add('Anonymous', 'view');
     $b = new Perms_Reflection_PermissionSet();
     $b->add('Anonymous', 'view');
     $comparator = new Perms_Reflection_PermissionComparator($a, $b);
     $this->assertEquals(array(), $comparator->getAdditions());
     $this->assertEquals(array(), $comparator->getRemovals());
 }
예제 #6
0
 function testInheritenceAppiesInMatching()
 {
     $quick = new Perms_Reflection_Quick();
     $quick->configure('basic', array('view'));
     $quick->configure('registered', array('edit'));
     $permissions = new Perms_Reflection_PermissionSet();
     $permissions->add('Registered', 'view');
     $permissions->add('Registered', 'edit');
     $expect = array('Registered' => 'registered');
     $obtained = $quick->getAppliedPermissions($permissions, array('Registered'));
     $this->assertEquals($expect, $obtained);
 }