aboutsummaryrefslogtreecommitdiff
path: root/lib/elearning/ConnectedLink.class.php
blob: 2be5a1259dd8359c1dff924e085a2fe473335e1d (plain)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
# Lifter002: TODO
# Lifter007: TODO
# Lifter003: TODO
# Lifter010: TODO
/**
* class to generate links to connected systems
*
* This class contains methods to generate links to connected content-management-systems.
*
* @author   Arne Schröder <schroeder@data-quest.de>
* @access   public
* @modulegroup  elearning_interface_modules
* @module       ConnectedLink
* @package  ELearning-Interface
*/

use Studip\Button, Studip\LinkButton;

class ConnectedLink
{
    var $cms_type;
    var $cms_link;
    /**
    * constructor
    *
    * init class. don't call directly, class is loaded by ConnectedCMS.
    * @access public
    * @param string $cms system-type
    */
    function __construct($cms)
    {
        global $ELEARNING_INTERFACE_MODULES;

        $this->cms_type = $cms;
        $this->cms_link = $ELEARNING_INTERFACE_MODULES[$cms]["ABSOLUTE_PATH_ELEARNINGMODULES"] . $ELEARNING_INTERFACE_MODULES[$cms]["target_file"];
    }

    /**
    * get link to create new account
    *
    * returns link to create new user-account
    * @access public
    * @return string html-code
    */
    function getNewAccountLink()
    {
        global $connected_cms, $cms_select, $current_module;

        $output .= "<form method=\"POST\" action=\"" . URLHelper::getLink() . "\">\n";
        $output .= CSRFProtection::tokenTag();
        $output .= "<input type=\"HIDDEN\" name=\"view\" value=\"" . Request::option('view') . "\">\n";
        $output .= "<input type=\"HIDDEN\" name=\"ref_id\" value=\"" . htmlReady($connected_cms[$this->cms_type]->content_module[$current_module]->getId()) . "\">\n";
        $output .= "<input type=\"HIDDEN\" name=\"module_type\" value=\"" . htmlReady($connected_cms[$this->cms_type]->content_module[$current_module]->getModuleType()) . "\">\n";
        $output .= "<input type=\"HIDDEN\" name=\"search_key\" value=\"" . htmlReady(Request::get('search_key')) . "\">\n";
        $output .= "<input type=\"HIDDEN\" name=\"cms_select\" value=\"" . htmlReady($cms_select) . "\">\n";
        $output .= "<input type=\"HIDDEN\" name=\"new_account_cms\" value=\"" . htmlReady($this->cms_type) . "\">\n";
        $output .= "<input type=\"HIDDEN\" name=\"new_account_step\" value=\"0\">\n";
        $output .= Button::createAccept(_('Starten'), 'start');
        $output .= "</form>";
        return $output;
    }

    /**
    * get module-links for user
    *
    * dummy-method. returns false. must be overwritten by subclass.
    * @access public
    * @return boolean returns false
    */
    function getUserModuleLinks()
    {
        return false;
    }

    /**
    * get module-links for admin
    *
    * returns links to remove or add module to object
    * @access public
    * @return string html-code
    */
    function getAdminModuleLinks()
    {
        global $connected_cms, $view, $search_key, $cms_select, $current_module;

        $output .= "<form method=\"POST\" action=\"" . URLHelper::getLink() . "\">\n";
        $output .= CSRFProtection::tokenTag();
        $output .= "<input type=\"HIDDEN\" name=\"view\" value=\"" . htmlReady($view) . "\">\n";
        $output .= "<input type=\"HIDDEN\" name=\"search_key\" value=\"" . htmlReady($search_key) . "\">\n";
        $output .= "<input type=\"HIDDEN\" name=\"cms_select\" value=\"" . htmlReady($cms_select) . "\">\n";
        $output .= "<input type=\"HIDDEN\" name=\"module_type\" value=\"" . htmlReady($connected_cms[$this->cms_type]->content_module[$current_module]->getModuleType()) . "\">\n";
        $output .= "<input type=\"HIDDEN\" name=\"module_id\" value=\"" . htmlReady($connected_cms[$this->cms_type]->content_module[$current_module]->getId()) . "\">\n";
        $output .= "<input type=\"HIDDEN\" name=\"module_system_type\" value=\"" . htmlReady($this->cms_type) . "\">\n";

        if ($connected_cms[$this->cms_type]->content_module[$current_module]->isConnected())
            $output .= "&nbsp;" . Button::create(_('Entfernen'), 'remove');
        else
            $output .= "&nbsp;" . Button::create(_('Hinzufügen'), 'add');
        $output .= "</form>";

        return $output;
    }

    /**
    * get new module link
    *
    * dummy-method. returns false. must be overwritten by subclass.
    * @access public
    * @return boolean returns false
    */
    function getNewModuleLink()
    {
        return false;
    }

    /**
    * get start page link
    *
    * dummy-method. returns false. must be overwritten by subclass.
    * @access public
    * @return boolean returns false
    */
    function getStartpageLink()
    {
        return false;
    }
}
?>