chamilo-app-survey /php/lib/survey_manager/component/rights_editor.class.php

Language PHP Lines 96
MD5 Hash c04d054c3344ef42c64bf30a0904d79a Estimated Cost $993 (why?)
Repository https://bitbucket.org/chamilo/chamilo-app-survey/ View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php 
namespace application\survey;

use common\libraries\DelegateComponent;
use common\libraries\Breadcrumb;
use common\libraries\BreadcrumbTrail;
use common\libraries\Translation;
use common\libraries\Request;
use common\extensions\rights_editor_manager\RightsEditorManager;


class SurveyManagerRightsEditorComponent extends SurveyManager implements DelegateComponent
{

    /**
     * Runs this component and displays its output.
     */
    function run()
    {
        
        //have to be fixed in reighteditormanager, if array is set as paramater, rightsmenu don't work anymore
        

        $publications = Request :: get(SurveyManager :: PARAM_PUBLICATION_ID);
        
        //        if ($publications && ! is_array($publications))
        //        {
        //            $publications = array($publications);
        //        }
        

        $this->set_parameter(SurveyManager :: PARAM_PUBLICATION_ID, $publications);
        
        if ($publications && ! is_array($publications))
        {
            $publications = array($publications);
        }
        
        $locations = array();
        
        foreach ($publications as $publication_id)
        {
            
            $publication = SurveyDataManager :: get_instance()->retrieve_survey_publication($publication_id);
            $user_ids = array();
            if ($this->get_user()->is_platform_admin() || $publication->get_publisher() == $this->get_user_id())
            {
                $locations[] = SurveyRights :: get_location_by_identifier_from_surveys_subtree($publication_id, SurveyRights :: TYPE_PUBLICATION);
                
//                $rights = SurveyRights :: get_available_rights_for_publications();
//                foreach ($rights as $right)
//                {
//                    $publication_user_ids = SurveyRights :: get_allowed_users($right, $publication_id, SurveyRights :: TYPE_PUBLICATION);
//                    $user_ids = array_merge($user_ids, $publication_user_ids);
//                }
            }
        }
        
        
        
//        $user_ids = array_unique($user_ids);
           
        $manager = new RightsEditorManager($this, $locations);
        
//        if (count($user_ids) > 0)
//        {
//            $manager->limit_users($user_ids);
//        }
//        else
//        {
//            $manager->limit_users(array(0));
//        }
//        
//        $manager->set_types(array(RightsEditorManager :: TYPE_USER));
        $manager->run();
    }

    function get_available_rights()
    {
        
        return SurveyRights :: get_available_rights_for_publications();
    
    }

    function add_additional_breadcrumbs(BreadcrumbTrail $breadcrumbtrail)
    {
        $breadcrumbtrail->add(new Breadcrumb($this->get_url(array(self :: PARAM_ACTION => self :: ACTION_BROWSE)), Translation :: get('BrowseSurveys')));
    }

    function get_additional_parameters()
    {
        return array(self :: PARAM_PUBLICATION_ID);
    }

}
?>
Back to Top