PageRenderTime 398ms CodeModel.GetById 173ms app.highlight 12ms RepoModel.GetById 151ms app.codeStats 9ms

/php/lib/survey_manager/component/rights_editor.class.php

https://bitbucket.org/chamilo/chamilo-app-survey/
PHP | 96 lines | 45 code | 26 blank | 25 comment | 5 complexity | c04d054c3344ef42c64bf30a0904d79a MD5 | raw file
 1<?php 
 2namespace application\survey;
 3
 4use common\libraries\DelegateComponent;
 5use common\libraries\Breadcrumb;
 6use common\libraries\BreadcrumbTrail;
 7use common\libraries\Translation;
 8use common\libraries\Request;
 9use common\extensions\rights_editor_manager\RightsEditorManager;
10
11
12class SurveyManagerRightsEditorComponent extends SurveyManager implements DelegateComponent
13{
14
15    /**
16     * Runs this component and displays its output.
17     */
18    function run()
19    {
20        
21        //have to be fixed in reighteditormanager, if array is set as paramater, rightsmenu don't work anymore
22        
23
24        $publications = Request :: get(SurveyManager :: PARAM_PUBLICATION_ID);
25        
26        //        if ($publications && ! is_array($publications))
27        //        {
28        //            $publications = array($publications);
29        //        }
30        
31
32        $this->set_parameter(SurveyManager :: PARAM_PUBLICATION_ID, $publications);
33        
34        if ($publications && ! is_array($publications))
35        {
36            $publications = array($publications);
37        }
38        
39        $locations = array();
40        
41        foreach ($publications as $publication_id)
42        {
43            
44            $publication = SurveyDataManager :: get_instance()->retrieve_survey_publication($publication_id);
45            $user_ids = array();
46            if ($this->get_user()->is_platform_admin() || $publication->get_publisher() == $this->get_user_id())
47            {
48                $locations[] = SurveyRights :: get_location_by_identifier_from_surveys_subtree($publication_id, SurveyRights :: TYPE_PUBLICATION);
49                
50//                $rights = SurveyRights :: get_available_rights_for_publications();
51//                foreach ($rights as $right)
52//                {
53//                    $publication_user_ids = SurveyRights :: get_allowed_users($right, $publication_id, SurveyRights :: TYPE_PUBLICATION);
54//                    $user_ids = array_merge($user_ids, $publication_user_ids);
55//                }
56            }
57        }
58        
59        
60        
61//        $user_ids = array_unique($user_ids);
62           
63        $manager = new RightsEditorManager($this, $locations);
64        
65//        if (count($user_ids) > 0)
66//        {
67//            $manager->limit_users($user_ids);
68//        }
69//        else
70//        {
71//            $manager->limit_users(array(0));
72//        }
73//        
74//        $manager->set_types(array(RightsEditorManager :: TYPE_USER));
75        $manager->run();
76    }
77
78    function get_available_rights()
79    {
80        
81        return SurveyRights :: get_available_rights_for_publications();
82    
83    }
84
85    function add_additional_breadcrumbs(BreadcrumbTrail $breadcrumbtrail)
86    {
87        $breadcrumbtrail->add(new Breadcrumb($this->get_url(array(self :: PARAM_ACTION => self :: ACTION_BROWSE)), Translation :: get('BrowseSurveys')));
88    }
89
90    function get_additional_parameters()
91    {
92        return array(self :: PARAM_PUBLICATION_ID);
93    }
94
95}
96?>