Ejemplo n.º 1
0
 function testReadGroupList()
 {
     $builder = new Services_Workspace_ProfileBuilder();
     $builder->addGroup('Base', $builder->user('group'));
     $builder->addGroup('World', $builder->user('group') . ' World', true);
     $builder->setManagingGroup('Base');
     $builder->setPermissions('Base', 'category', $builder->user('category'), array('view', 'edit'));
     $builder->setPermissions('World', 'category', $builder->user('category'), array('view'));
     $profile = Tiki_Profile::fromString($builder->getContent());
     $analyser = new Services_Workspace_ProfileAnalyser($profile);
     $this->assertEquals(array('Base' => array('name' => '{group}', 'managing' => true, 'autojoin' => false, 'permissions' => array('view', 'edit')), 'World' => array('name' => '{group} World', 'managing' => false, 'autojoin' => true, 'permissions' => array('view'))), $analyser->getGroups('category', $analyser->user('category')));
 }
Ejemplo n.º 2
0
 function action_edit_template($input)
 {
     if (!Perms::get()->admin) {
         throw new Services_Exception_Denied();
     }
     global $prefs;
     $template = $this->utilities->getTemplate($input->id->int());
     if ($template['is_advanced'] == 'y') {
         return array('FORWARD' => array('action' => 'advanced_edit', 'id' => $input->id->int()));
     }
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $builder = new Services_Workspace_ProfileBuilder();
         if ($prefs['feature_areas'] == 'y' && $input->area->int()) {
             $builder->addObject('area_binding', 'binding', array('category' => $builder->user('category'), 'perspective' => $builder->user('perspective')));
         }
         foreach ($input->groups as $internal => $info) {
             $permissions = array_filter(preg_split('/\\W+/', $info->permissions->none()));
             $builder->addGroup($internal, $info->name->text(), $info->autojoin->int() > 0);
             $builder->setPermissions($internal, 'category', $builder->user('category'), $permissions);
         }
         $builder->setManagingGroup($input->managingGroup->word());
         foreach ($input->pages as $page) {
             $builder->addObject('wiki_page', uniqid(), array('name' => $page->name->pagename(), 'namespace' => $page->namespace->pagename(), 'content' => $page->content->wikicontent(), 'categories' => $builder->user('category')));
         }
         $this->utilities->replaceTemplate($input->id->int(), array('name' => $input->name->text(), 'definition' => $builder->getContent()));
     }
     $template = $this->utilities->getTemplate($input->id->int());
     $profile = Tiki_Profile::fromString($template['definition']);
     $analyser = new Services_Workspace_ProfileAnalyser($profile);
     $hasArea = $analyser->contains(array('type' => 'area_binding', 'ref' => 'binding', 'category' => $analyser->user('category'), 'perspective' => $analyser->user('perspective'))) ? 'y' : 'n';
     return array('title' => tr('Edit template %0', $template['name']), 'id' => $input->id->int(), 'name' => $template['name'], 'area' => $prefs['feature_areas'] == 'y' ? $hasArea : null, 'groups' => $analyser->getGroups('category', $analyser->user('category')), 'pages' => $analyser->getObjects('wiki_page', array('name' => '{namespace}', 'namespace' => null, 'content' => '')));
 }
Ejemplo n.º 3
0
    function testReplaceSimpleSyntax()
    {
        $builder = new Services_Workspace_ProfileBuilder();
        $builder->addGroup('Base', '{group}');
        $builder->setManagingGroup('Base');
        $expect = <<<EXPECT
---
mappings: 
  Base: \$profilerequest:group\$undefined\$
permissions: 
  Base: 
    description: \$profilerequest:group\$undefined\$
    objects: 
      - 
        type: group
        id: Base
        allow: 
          - group_view
          - group_view_members
          - group_add_member
          - group_remove_member
EXPECT;
        $this->assertIs($expect, $builder->getContent());
    }