@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | return array( |
627 | 627 | max(($this->_perPage * ($pageID - 1)) + 1, 1), |
628 | 628 | min($this->_totalItems, $this->_perPage * $pageID) |
629 | - ); |
|
629 | + ); |
|
630 | 630 | } |
631 | 631 | return array(0, 0); |
632 | 632 | } |
@@ -848,16 +848,16 @@ discard block |
||
848 | 848 | $onclick = str_replace('%d', $this->_linkData[$this->_urlVar], $this->_onclick); |
849 | 849 | } |
850 | 850 | return sprintf('<a href="%s"%s%s%s%s title="%s">%s</a>', |
851 | - // Modified by Ivan Tcholakov, 17-OCT-2008. |
|
852 | - //htmlentities($this->_url . $href, ENT_COMPAT, 'UTF-8'), |
|
853 | - api_htmlentities($this->_url . $href), |
|
854 | - // |
|
855 | - empty($this->_classString) ? '' : ' '.$this->_classString, |
|
856 | - empty($this->_attributes) ? '' : ' '.$this->_attributes, |
|
857 | - empty($this->_accesskey) ? '' : ' accesskey="'.$this->_linkData[$this->_urlVar].'"', |
|
858 | - empty($onclick) ? '' : ' onclick="'.$onclick.'"', |
|
859 | - $altText, |
|
860 | - $linkText |
|
851 | + // Modified by Ivan Tcholakov, 17-OCT-2008. |
|
852 | + //htmlentities($this->_url . $href, ENT_COMPAT, 'UTF-8'), |
|
853 | + api_htmlentities($this->_url . $href), |
|
854 | + // |
|
855 | + empty($this->_classString) ? '' : ' '.$this->_classString, |
|
856 | + empty($this->_attributes) ? '' : ' '.$this->_attributes, |
|
857 | + empty($this->_accesskey) ? '' : ' accesskey="'.$this->_linkData[$this->_urlVar].'"', |
|
858 | + empty($onclick) ? '' : ' onclick="'.$onclick.'"', |
|
859 | + $altText, |
|
860 | + $linkText |
|
861 | 861 | ); |
862 | 862 | } elseif ($this->_httpMethod == 'POST') { |
863 | 863 | $href = $this->_url; |
@@ -865,12 +865,12 @@ discard block |
||
865 | 865 | $href .= '?' . $this->_http_build_query_wrapper($_GET); |
866 | 866 | } |
867 | 867 | return sprintf("<a href='javascript:void(0)' onclick='%s'%s%s%s title='%s'>%s</a>", |
868 | - $this->_generateFormOnClick($href, $this->_linkData), |
|
869 | - empty($this->_classString) ? '' : ' '.$this->_classString, |
|
870 | - empty($this->_attributes) ? '' : ' '.$this->_attributes, |
|
871 | - empty($this->_accesskey) ? '' : ' accesskey=\''.$this->_linkData[$this->_urlVar].'\'', |
|
872 | - $altText, |
|
873 | - $linkText |
|
868 | + $this->_generateFormOnClick($href, $this->_linkData), |
|
869 | + empty($this->_classString) ? '' : ' '.$this->_classString, |
|
870 | + empty($this->_attributes) ? '' : ' '.$this->_attributes, |
|
871 | + empty($this->_accesskey) ? '' : ' accesskey=\''.$this->_linkData[$this->_urlVar].'\'', |
|
872 | + $altText, |
|
873 | + $linkText |
|
874 | 874 | ); |
875 | 875 | } |
876 | 876 | return ''; |
@@ -1120,10 +1120,10 @@ discard block |
||
1120 | 1120 | if ($this->_currentPage > 1) { |
1121 | 1121 | $this->_linkData[$this->_urlVar] = $this->getPreviousPageID(); |
1122 | 1122 | $back = $this->_renderLink($this->_altPrev, $this->_prevImg) |
1123 | - . $this->_spacesBefore . $this->_spacesAfter; |
|
1123 | + . $this->_spacesBefore . $this->_spacesAfter; |
|
1124 | 1124 | } else if ($this->_prevImgEmpty !== null && $this->_totalPages > 1) { |
1125 | 1125 | $back = $this->_prevImgEmpty |
1126 | - . $this->_spacesBefore . $this->_spacesAfter; |
|
1126 | + . $this->_spacesBefore . $this->_spacesAfter; |
|
1127 | 1127 | } |
1128 | 1128 | return $back; |
1129 | 1129 | } |
@@ -1171,12 +1171,12 @@ discard block |
||
1171 | 1171 | if ($this->_currentPage < $this->_totalPages) { |
1172 | 1172 | $this->_linkData[$this->_urlVar] = $this->getNextPageID(); |
1173 | 1173 | $next = $this->_spacesAfter |
1174 | - . $this->_renderLink($this->_altNext, $this->_nextImg) |
|
1175 | - . $this->_spacesBefore . $this->_spacesAfter; |
|
1174 | + . $this->_renderLink($this->_altNext, $this->_nextImg) |
|
1175 | + . $this->_spacesBefore . $this->_spacesAfter; |
|
1176 | 1176 | } else if ($this->_nextImgEmpty !== null && $this->_totalPages > 1) { |
1177 | 1177 | $next = $this->_spacesAfter |
1178 | - . $this->_nextImgEmpty |
|
1179 | - . $this->_spacesBefore . $this->_spacesAfter; |
|
1178 | + . $this->_nextImgEmpty |
|
1179 | + . $this->_spacesBefore . $this->_spacesAfter; |
|
1180 | 1180 | } |
1181 | 1181 | return $next; |
1182 | 1182 | } |
@@ -1632,7 +1632,7 @@ discard block |
||
1632 | 1632 | } |
1633 | 1633 | |
1634 | 1634 | if (!empty($_SESSION[$this->_sessionVar]) && $this->_useSessions) { |
1635 | - $this->_perPage = $_SESSION[$this->_sessionVar]; |
|
1635 | + $this->_perPage = $_SESSION[$this->_sessionVar]; |
|
1636 | 1636 | } |
1637 | 1637 | |
1638 | 1638 | if ($this->_closeSession) { |
@@ -1713,7 +1713,7 @@ discard block |
||
1713 | 1713 | ERROR_PAGER_INVALID => 'invalid', |
1714 | 1714 | ERROR_PAGER_INVALID_PLACEHOLDER => 'invalid format - use "%d" as placeholder.', |
1715 | 1715 | ERROR_PAGER_INVALID_USAGE => 'if $options[\'append\'] is set to false, ' |
1716 | - .' $options[\'fileName\'] MUST contain the "%d" placeholder.', |
|
1716 | + .' $options[\'fileName\'] MUST contain the "%d" placeholder.', |
|
1717 | 1717 | ERROR_PAGER_NOT_IMPLEMENTED => 'not implemented' |
1718 | 1718 | ); |
1719 | 1719 | } |
@@ -625,7 +625,6 @@ discard block |
||
625 | 625 | * The other configuration parameters have not been changed. |
626 | 626 | * |
627 | 627 | * This is how we can get most used paths, for common purpose: |
628 | - |
|
629 | 628 | * api_get_path(REL_PATH) /chamilo/ |
630 | 629 | * api_get_path(REL_COURSE_PATH) /chamilo/courses/ |
631 | 630 | * api_get_path(REL_CODE_PATH) /chamilo/main/ |
@@ -1803,7 +1802,6 @@ discard block |
||
1803 | 1802 | |
1804 | 1803 | /** |
1805 | 1804 | * Returns the current course info array. |
1806 | - |
|
1807 | 1805 | * Now if the course_code is given, the returned array gives info about that |
1808 | 1806 | * particular course, not specially the current one. |
1809 | 1807 | * @param int $id Numeric ID of the course |
@@ -2734,7 +2732,7 @@ discard block |
||
2734 | 2732 | switch ($session_user_status) { |
2735 | 2733 | case 0: |
2736 | 2734 | $session_status['status'] = 'student'; |
2737 | - break; |
|
2735 | + break; |
|
2738 | 2736 | case 2: |
2739 | 2737 | $session_status['status'] = 'coach'; |
2740 | 2738 | break; |
@@ -6492,7 +6490,7 @@ discard block |
||
6492 | 6490 | function api_get_jquery_ui_js($include_jqgrid = false) { |
6493 | 6491 | $libraries = array(); |
6494 | 6492 | if ($include_jqgrid) { |
6495 | - $libraries[]='jqgrid'; |
|
6493 | + $libraries[]='jqgrid'; |
|
6496 | 6494 | } |
6497 | 6495 | return api_get_jquery_libraries_js($libraries); |
6498 | 6496 | } |
@@ -1682,7 +1682,7 @@ discard block |
||
1682 | 1682 | $html .= '<label class="checkbox-inline"> |
1683 | 1683 | <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'false' ? '' : 'checked="checked" ') .' /> '. get_lang('No') .' |
1684 | 1684 | </label>'; |
1685 | - $html .= '<label class="checkbox-inline"> |
|
1685 | + $html .= '<label class="checkbox-inline"> |
|
1686 | 1686 | <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'approval' ? '' : 'checked="checked" ') .' /> '. get_lang('AfterApproval') .' |
1687 | 1687 | </label>'; |
1688 | 1688 | $html .= '</div>'; |
@@ -1716,7 +1716,7 @@ discard block |
||
1716 | 1716 | </div>'; |
1717 | 1717 | |
1718 | 1718 | echo panel($html, get_lang('Platform'), 'platform'); |
1719 | - ?> |
|
1719 | + ?> |
|
1720 | 1720 | <div class='form-group'> |
1721 | 1721 | <div class="col-sm-6"> |
1722 | 1722 | <button type="submit" class="btn btn-default pull-right" name="step3" value="< <?php echo get_lang('Previous'); ?>" ><em class="fa fa-backward"> </em> <?php echo get_lang('Previous'); ?></button> |
@@ -81,7 +81,7 @@ |
||
81 | 81 | |
82 | 82 | // Using the resource linker as a tool for adding resources to the learning path. |
83 | 83 | if ($action == 'add' && $type == 'learnpathitem') { |
84 | - $htmlHeadXtra[] = "<script type='text/javascript'> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>"; |
|
84 | + $htmlHeadXtra[] = "<script type='text/javascript'> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>"; |
|
85 | 85 | } |
86 | 86 | if ((!$is_allowed_to_edit)) { |
87 | 87 | error_log('New LP - User not authorized in lp_add_item.php'); |
@@ -47,10 +47,10 @@ |
||
47 | 47 | " . |
48 | 48 | "\n" . |
49 | 49 | '$().ready(function() {'."\n" . |
50 | - 'if ($(\'#previous\')) {'."\n" . |
|
50 | + 'if ($(\'#previous\')) {'."\n" . |
|
51 | 51 | 'if(\'parent is\'+$(\'#idParent\').val()) {'. |
52 | - 'load_cbo($(\'#idParent\').val());'."\n" . |
|
53 | - '}}'."\n" . |
|
52 | + 'load_cbo($(\'#idParent\').val());'."\n" . |
|
53 | + '}}'."\n" . |
|
54 | 54 | '});</script>'."\n" ; |
55 | 55 | |
56 | 56 | /* Constants and variables */ |
@@ -67,521 +67,521 @@ |
||
67 | 67 | */ |
68 | 68 | class xajaxResponse |
69 | 69 | { |
70 | - /**#@+ |
|
70 | + /**#@+ |
|
71 | 71 | * @access protected |
72 | 72 | */ |
73 | - /** |
|
74 | - * @var string internal XML storage |
|
75 | - */ |
|
76 | - var $xml; |
|
77 | - /** |
|
78 | - * @var string the encoding type to use |
|
79 | - */ |
|
80 | - var $sEncoding; |
|
81 | - /** |
|
82 | - * @var boolean if special characters in the XML should be converted to |
|
83 | - * entities |
|
84 | - */ |
|
85 | - var $bOutputEntities; |
|
86 | - |
|
87 | - /**#@-*/ |
|
88 | - |
|
89 | - /** |
|
90 | - * The constructor's main job is to set the character encoding for the |
|
91 | - * response. |
|
92 | - * |
|
93 | - * <i>Note:</i> to change the character encoding for all of the |
|
94 | - * responses, set the XAJAX_DEFAULT_ENCODING constant before you |
|
95 | - * instantiate xajax. |
|
96 | - * |
|
97 | - * @param string contains the character encoding string to use |
|
98 | - * @param boolean lets you set if you want special characters in the output |
|
99 | - * converted to HTML entities |
|
100 | - * |
|
101 | - */ |
|
102 | - public function __construct($sEncoding=XAJAX_DEFAULT_CHAR_ENCODING, $bOutputEntities=false) |
|
103 | - { |
|
104 | - $this->setCharEncoding($sEncoding); |
|
105 | - $this->bOutputEntities = $bOutputEntities; |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Sets the character encoding for the response based on $sEncoding, which |
|
110 | - * is a string containing the character encoding to use. You don't need to |
|
111 | - * use this method normally, since the character encoding for the response |
|
112 | - * gets set automatically based on the XAJAX_DEFAULT_CHAR_ENCODING |
|
113 | - * constant. |
|
114 | - * |
|
115 | - * @param string |
|
116 | - */ |
|
117 | - function setCharEncoding($sEncoding) |
|
118 | - { |
|
119 | - $this->sEncoding = $sEncoding; |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * Tells the response object to convert special characters to HTML entities |
|
124 | - * automatically (only works if the mb_string extension is available). |
|
125 | - */ |
|
126 | - function outputEntitiesOn() |
|
127 | - { |
|
128 | - $this->bOutputEntities = true; |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * Tells the response object to output special characters intact. (default |
|
133 | - * behavior) |
|
134 | - */ |
|
135 | - function outputEntitiesOff() |
|
136 | - { |
|
137 | - $this->bOutputEntities = false; |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * Adds a confirm commands command message to the XML response. |
|
142 | - * |
|
143 | - * <i>Usage:</i> <kbd>$objResponse->addConfirmCommands(1, "Do you want to preview the new data?");</kbd> |
|
144 | - * |
|
145 | - * @param integer the number of commands to skip if the user presses |
|
146 | - * Cancel in the browsers's confirm dialog |
|
147 | - * @param string the message to show in the browser's confirm dialog |
|
148 | - */ |
|
149 | - function addConfirmCommands($iCmdNumber, $sMessage) |
|
150 | - { |
|
151 | - $this->xml .= $this->_cmdXML(array("n"=>"cc","t"=>$iCmdNumber),$sMessage); |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * Adds an assign command message to the XML response. |
|
156 | - * |
|
157 | - * <i>Usage:</i> <kbd>$objResponse->addAssign("contentDiv", "innerHTML", "Some Text");</kbd> |
|
158 | - * |
|
159 | - * @param string contains the id of an HTML element |
|
160 | - * @param string the part of the element you wish to modify ("innerHTML", |
|
161 | - * "value", etc.) |
|
162 | - * @param string the data you want to set the attribute to |
|
163 | - */ |
|
164 | - function addAssign($sTarget,$sAttribute,$sData) |
|
165 | - { |
|
166 | - $this->xml .= $this->_cmdXML(array("n"=>"as","t"=>$sTarget,"p"=>$sAttribute),$sData); |
|
167 | - } |
|
168 | - |
|
169 | - /** |
|
170 | - * Adds an append command message to the XML response. |
|
171 | - * |
|
172 | - * <i>Usage:</i> <kbd>$objResponse->addAppend("contentDiv", "innerHTML", "Some New Text");</kbd> |
|
173 | - * |
|
174 | - * @param string contains the id of an HTML element |
|
175 | - * @param string the part of the element you wish to modify ("innerHTML", |
|
176 | - * "value", etc.) |
|
177 | - * @param string the data you want to append to the end of the attribute |
|
178 | - */ |
|
179 | - function addAppend($sTarget,$sAttribute,$sData) |
|
180 | - { |
|
181 | - $this->xml .= $this->_cmdXML(array("n"=>"ap","t"=>$sTarget,"p"=>$sAttribute),$sData); |
|
182 | - } |
|
183 | - |
|
184 | - /** |
|
185 | - * Adds an prepend command message to the XML response. |
|
186 | - * |
|
187 | - * <i>Usage:</i> <kbd>$objResponse->addPrepend("contentDiv", "innerHTML", "Some Starting Text");</kbd> |
|
188 | - * |
|
189 | - * @param string contains the id of an HTML element |
|
190 | - * @param string the part of the element you wish to modify ("innerHTML", |
|
191 | - * "value", etc.) |
|
192 | - * @param string the data you want to prepend to the beginning of the |
|
193 | - * attribute |
|
194 | - */ |
|
195 | - function addPrepend($sTarget,$sAttribute,$sData) |
|
196 | - { |
|
197 | - $this->xml .= $this->_cmdXML(array("n"=>"pp","t"=>$sTarget,"p"=>$sAttribute),$sData); |
|
198 | - } |
|
199 | - |
|
200 | - /** |
|
201 | - * Adds a replace command message to the XML response. |
|
202 | - * |
|
203 | - * <i>Usage:</i> <kbd>$objResponse->addReplace("contentDiv", "innerHTML", "text", "<b>text</b>");</kbd> |
|
204 | - * |
|
205 | - * @param string contains the id of an HTML element |
|
206 | - * @param string the part of the element you wish to modify ("innerHTML", |
|
207 | - * "value", etc.) |
|
208 | - * @param string the string to search for |
|
209 | - * @param string the string to replace the search string when found in the |
|
210 | - * attribute |
|
211 | - */ |
|
212 | - function addReplace($sTarget,$sAttribute,$sSearch,$sData) |
|
213 | - { |
|
214 | - $sDta = "<s><![CDATA[$sSearch]]></s><r><![CDATA[$sData]]></r>"; |
|
215 | - $this->xml .= $this->_cmdXML(array("n"=>"rp","t"=>$sTarget,"p"=>$sAttribute),$sDta); |
|
216 | - } |
|
217 | - |
|
218 | - /** |
|
219 | - * Adds a clear command message to the XML response. |
|
220 | - * |
|
221 | - * <i>Usage:</i> <kbd>$objResponse->addClear("contentDiv", "innerHTML");</kbd> |
|
222 | - * |
|
223 | - * @param string contains the id of an HTML element |
|
224 | - * @param string the part of the element you wish to clear ("innerHTML", |
|
225 | - * "value", etc.) |
|
226 | - */ |
|
227 | - function addClear($sTarget,$sAttribute) |
|
228 | - { |
|
229 | - $this->addAssign($sTarget,$sAttribute,''); |
|
230 | - } |
|
231 | - |
|
232 | - /** |
|
233 | - * Adds an alert command message to the XML response. |
|
234 | - * |
|
235 | - * <i>Usage:</i> <kbd>$objResponse->addAlert("This is important information");</kbd> |
|
236 | - * |
|
237 | - * @param string the text to be displayed in the Javascript alert box |
|
238 | - */ |
|
239 | - function addAlert($sMsg) |
|
240 | - { |
|
241 | - $this->xml .= $this->_cmdXML(array("n"=>"al"),$sMsg); |
|
242 | - } |
|
243 | - |
|
244 | - /** |
|
245 | - * Uses the addScript() method to add a Javascript redirect to another URL. |
|
246 | - * |
|
247 | - * <i>Usage:</i> <kbd>$objResponse->addRedirect("http://www.xajaxproject.org");</kbd> |
|
248 | - * |
|
249 | - * @param string the URL to redirect the client browser to |
|
250 | - */ |
|
251 | - function addRedirect($sURL) |
|
252 | - { |
|
253 | - //we need to parse the query part so that the values are rawurlencode()'ed |
|
254 | - //can't just use parse_url() cos we could be dealing with a relative URL which |
|
255 | - // parse_url() can't deal with. |
|
256 | - $queryStart = strpos($sURL, '?', strrpos($sURL, '/')); |
|
257 | - if ($queryStart !== FALSE) |
|
258 | - { |
|
259 | - $queryStart++; |
|
260 | - $queryEnd = strpos($sURL, '#', $queryStart); |
|
261 | - if ($queryEnd === FALSE) |
|
262 | - $queryEnd = strlen($sURL); |
|
263 | - $queryPart = substr($sURL, $queryStart, $queryEnd-$queryStart); |
|
73 | + /** |
|
74 | + * @var string internal XML storage |
|
75 | + */ |
|
76 | + var $xml; |
|
77 | + /** |
|
78 | + * @var string the encoding type to use |
|
79 | + */ |
|
80 | + var $sEncoding; |
|
81 | + /** |
|
82 | + * @var boolean if special characters in the XML should be converted to |
|
83 | + * entities |
|
84 | + */ |
|
85 | + var $bOutputEntities; |
|
86 | + |
|
87 | + /**#@-*/ |
|
88 | + |
|
89 | + /** |
|
90 | + * The constructor's main job is to set the character encoding for the |
|
91 | + * response. |
|
92 | + * |
|
93 | + * <i>Note:</i> to change the character encoding for all of the |
|
94 | + * responses, set the XAJAX_DEFAULT_ENCODING constant before you |
|
95 | + * instantiate xajax. |
|
96 | + * |
|
97 | + * @param string contains the character encoding string to use |
|
98 | + * @param boolean lets you set if you want special characters in the output |
|
99 | + * converted to HTML entities |
|
100 | + * |
|
101 | + */ |
|
102 | + public function __construct($sEncoding=XAJAX_DEFAULT_CHAR_ENCODING, $bOutputEntities=false) |
|
103 | + { |
|
104 | + $this->setCharEncoding($sEncoding); |
|
105 | + $this->bOutputEntities = $bOutputEntities; |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Sets the character encoding for the response based on $sEncoding, which |
|
110 | + * is a string containing the character encoding to use. You don't need to |
|
111 | + * use this method normally, since the character encoding for the response |
|
112 | + * gets set automatically based on the XAJAX_DEFAULT_CHAR_ENCODING |
|
113 | + * constant. |
|
114 | + * |
|
115 | + * @param string |
|
116 | + */ |
|
117 | + function setCharEncoding($sEncoding) |
|
118 | + { |
|
119 | + $this->sEncoding = $sEncoding; |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * Tells the response object to convert special characters to HTML entities |
|
124 | + * automatically (only works if the mb_string extension is available). |
|
125 | + */ |
|
126 | + function outputEntitiesOn() |
|
127 | + { |
|
128 | + $this->bOutputEntities = true; |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * Tells the response object to output special characters intact. (default |
|
133 | + * behavior) |
|
134 | + */ |
|
135 | + function outputEntitiesOff() |
|
136 | + { |
|
137 | + $this->bOutputEntities = false; |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * Adds a confirm commands command message to the XML response. |
|
142 | + * |
|
143 | + * <i>Usage:</i> <kbd>$objResponse->addConfirmCommands(1, "Do you want to preview the new data?");</kbd> |
|
144 | + * |
|
145 | + * @param integer the number of commands to skip if the user presses |
|
146 | + * Cancel in the browsers's confirm dialog |
|
147 | + * @param string the message to show in the browser's confirm dialog |
|
148 | + */ |
|
149 | + function addConfirmCommands($iCmdNumber, $sMessage) |
|
150 | + { |
|
151 | + $this->xml .= $this->_cmdXML(array("n"=>"cc","t"=>$iCmdNumber),$sMessage); |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * Adds an assign command message to the XML response. |
|
156 | + * |
|
157 | + * <i>Usage:</i> <kbd>$objResponse->addAssign("contentDiv", "innerHTML", "Some Text");</kbd> |
|
158 | + * |
|
159 | + * @param string contains the id of an HTML element |
|
160 | + * @param string the part of the element you wish to modify ("innerHTML", |
|
161 | + * "value", etc.) |
|
162 | + * @param string the data you want to set the attribute to |
|
163 | + */ |
|
164 | + function addAssign($sTarget,$sAttribute,$sData) |
|
165 | + { |
|
166 | + $this->xml .= $this->_cmdXML(array("n"=>"as","t"=>$sTarget,"p"=>$sAttribute),$sData); |
|
167 | + } |
|
168 | + |
|
169 | + /** |
|
170 | + * Adds an append command message to the XML response. |
|
171 | + * |
|
172 | + * <i>Usage:</i> <kbd>$objResponse->addAppend("contentDiv", "innerHTML", "Some New Text");</kbd> |
|
173 | + * |
|
174 | + * @param string contains the id of an HTML element |
|
175 | + * @param string the part of the element you wish to modify ("innerHTML", |
|
176 | + * "value", etc.) |
|
177 | + * @param string the data you want to append to the end of the attribute |
|
178 | + */ |
|
179 | + function addAppend($sTarget,$sAttribute,$sData) |
|
180 | + { |
|
181 | + $this->xml .= $this->_cmdXML(array("n"=>"ap","t"=>$sTarget,"p"=>$sAttribute),$sData); |
|
182 | + } |
|
183 | + |
|
184 | + /** |
|
185 | + * Adds an prepend command message to the XML response. |
|
186 | + * |
|
187 | + * <i>Usage:</i> <kbd>$objResponse->addPrepend("contentDiv", "innerHTML", "Some Starting Text");</kbd> |
|
188 | + * |
|
189 | + * @param string contains the id of an HTML element |
|
190 | + * @param string the part of the element you wish to modify ("innerHTML", |
|
191 | + * "value", etc.) |
|
192 | + * @param string the data you want to prepend to the beginning of the |
|
193 | + * attribute |
|
194 | + */ |
|
195 | + function addPrepend($sTarget,$sAttribute,$sData) |
|
196 | + { |
|
197 | + $this->xml .= $this->_cmdXML(array("n"=>"pp","t"=>$sTarget,"p"=>$sAttribute),$sData); |
|
198 | + } |
|
199 | + |
|
200 | + /** |
|
201 | + * Adds a replace command message to the XML response. |
|
202 | + * |
|
203 | + * <i>Usage:</i> <kbd>$objResponse->addReplace("contentDiv", "innerHTML", "text", "<b>text</b>");</kbd> |
|
204 | + * |
|
205 | + * @param string contains the id of an HTML element |
|
206 | + * @param string the part of the element you wish to modify ("innerHTML", |
|
207 | + * "value", etc.) |
|
208 | + * @param string the string to search for |
|
209 | + * @param string the string to replace the search string when found in the |
|
210 | + * attribute |
|
211 | + */ |
|
212 | + function addReplace($sTarget,$sAttribute,$sSearch,$sData) |
|
213 | + { |
|
214 | + $sDta = "<s><![CDATA[$sSearch]]></s><r><![CDATA[$sData]]></r>"; |
|
215 | + $this->xml .= $this->_cmdXML(array("n"=>"rp","t"=>$sTarget,"p"=>$sAttribute),$sDta); |
|
216 | + } |
|
217 | + |
|
218 | + /** |
|
219 | + * Adds a clear command message to the XML response. |
|
220 | + * |
|
221 | + * <i>Usage:</i> <kbd>$objResponse->addClear("contentDiv", "innerHTML");</kbd> |
|
222 | + * |
|
223 | + * @param string contains the id of an HTML element |
|
224 | + * @param string the part of the element you wish to clear ("innerHTML", |
|
225 | + * "value", etc.) |
|
226 | + */ |
|
227 | + function addClear($sTarget,$sAttribute) |
|
228 | + { |
|
229 | + $this->addAssign($sTarget,$sAttribute,''); |
|
230 | + } |
|
231 | + |
|
232 | + /** |
|
233 | + * Adds an alert command message to the XML response. |
|
234 | + * |
|
235 | + * <i>Usage:</i> <kbd>$objResponse->addAlert("This is important information");</kbd> |
|
236 | + * |
|
237 | + * @param string the text to be displayed in the Javascript alert box |
|
238 | + */ |
|
239 | + function addAlert($sMsg) |
|
240 | + { |
|
241 | + $this->xml .= $this->_cmdXML(array("n"=>"al"),$sMsg); |
|
242 | + } |
|
243 | + |
|
244 | + /** |
|
245 | + * Uses the addScript() method to add a Javascript redirect to another URL. |
|
246 | + * |
|
247 | + * <i>Usage:</i> <kbd>$objResponse->addRedirect("http://www.xajaxproject.org");</kbd> |
|
248 | + * |
|
249 | + * @param string the URL to redirect the client browser to |
|
250 | + */ |
|
251 | + function addRedirect($sURL) |
|
252 | + { |
|
253 | + //we need to parse the query part so that the values are rawurlencode()'ed |
|
254 | + //can't just use parse_url() cos we could be dealing with a relative URL which |
|
255 | + // parse_url() can't deal with. |
|
256 | + $queryStart = strpos($sURL, '?', strrpos($sURL, '/')); |
|
257 | + if ($queryStart !== FALSE) |
|
258 | + { |
|
259 | + $queryStart++; |
|
260 | + $queryEnd = strpos($sURL, '#', $queryStart); |
|
261 | + if ($queryEnd === FALSE) |
|
262 | + $queryEnd = strlen($sURL); |
|
263 | + $queryPart = substr($sURL, $queryStart, $queryEnd-$queryStart); |
|
264 | 264 | $queryParts = array(); |
265 | - parse_str($queryPart, $queryParts); |
|
266 | - $newQueryPart = ""; |
|
267 | - foreach($queryParts as $key => $value) |
|
268 | - { |
|
269 | - $newQueryPart .= rawurlencode($key).'='.rawurlencode($value).ini_get('arg_separator.output'); |
|
270 | - } |
|
271 | - $sURL = str_replace($queryPart, $newQueryPart, $sURL); |
|
272 | - } |
|
273 | - $this->addScript('window.location = "'.$sURL.'";'); |
|
274 | - } |
|
275 | - |
|
276 | - /** |
|
277 | - * Adds a Javascript command message to the XML response. |
|
278 | - * |
|
279 | - * <i>Usage:</i> <kbd>$objResponse->addScript("var x = prompt('get some text');");</kbd> |
|
280 | - * |
|
281 | - * @param string contains Javascript code to be executed |
|
282 | - */ |
|
283 | - function addScript($sJS) |
|
284 | - { |
|
285 | - $this->xml .= $this->_cmdXML(array("n"=>"js"),$sJS); |
|
286 | - } |
|
287 | - |
|
288 | - /** |
|
289 | - * Adds a Javascript function call command message to the XML response. |
|
290 | - * |
|
291 | - * <i>Usage:</i> <kbd>$objResponse->addScriptCall("myJSFunction", "arg 1", "arg 2", 12345);</kbd> |
|
292 | - * |
|
293 | - * @param string $sFunc the name of a Javascript function |
|
294 | - * @param mixed $args,... optional arguments to pass to the Javascript function |
|
295 | - */ |
|
296 | - function addScriptCall() { |
|
297 | - $arguments = func_get_args(); |
|
298 | - $sFunc = array_shift($arguments); |
|
299 | - $sData = $this->_buildObjXml($arguments); |
|
300 | - $this->xml .= $this->_cmdXML(array("n"=>"jc","t"=>$sFunc),$sData); |
|
301 | - } |
|
302 | - |
|
303 | - /** |
|
304 | - * Adds a remove element command message to the XML response. |
|
305 | - * |
|
306 | - * <i>Usage:</i> <kbd>$objResponse->addRemove("Div2");</kbd> |
|
307 | - * |
|
308 | - * @param string contains the id of an HTML element to be removed |
|
309 | - */ |
|
310 | - function addRemove($sTarget) |
|
311 | - { |
|
312 | - $this->xml .= $this->_cmdXML(array("n"=>"rm","t"=>$sTarget),''); |
|
313 | - } |
|
314 | - |
|
315 | - /** |
|
316 | - * Adds a create element command message to the XML response. |
|
317 | - * |
|
318 | - * <i>Usage:</i> <kbd>$objResponse->addCreate("parentDiv", "h3", "myid");</kbd> |
|
319 | - * |
|
320 | - * @param string contains the id of an HTML element to to which the new |
|
321 | - * element will be appended. |
|
322 | - * @param string the tag to be added |
|
323 | - * @param string the id to be assigned to the new element |
|
324 | - * @param string deprecated, use the addCreateInput() method instead |
|
325 | - */ |
|
326 | - function addCreate($sParent, $sTag, $sId, $sType="") |
|
327 | - { |
|
328 | - if ($sType) |
|
329 | - { |
|
330 | - trigger_error("The \$sType parameter of addCreate has been deprecated. Use the addCreateInput() method instead.", E_USER_WARNING); |
|
331 | - return; |
|
332 | - } |
|
333 | - $this->xml .= $this->_cmdXML(array("n"=>"ce","t"=>$sParent,"p"=>$sId),$sTag); |
|
334 | - } |
|
335 | - |
|
336 | - /** |
|
337 | - * Adds a insert element command message to the XML response. |
|
338 | - * |
|
339 | - * <i>Usage:</i> <kbd>$objResponse->addInsert("childDiv", "h3", "myid");</kbd> |
|
340 | - * |
|
341 | - * @param string contains the id of the child before which the new element |
|
342 | - * will be inserted |
|
343 | - * @param string the tag to be added |
|
344 | - * @param string the id to be assigned to the new element |
|
345 | - */ |
|
346 | - function addInsert($sBefore, $sTag, $sId) |
|
347 | - { |
|
348 | - $this->xml .= $this->_cmdXML(array("n"=>"ie","t"=>$sBefore,"p"=>$sId),$sTag); |
|
349 | - } |
|
350 | - |
|
351 | - /** |
|
352 | - * Adds a insert element command message to the XML response. |
|
353 | - * |
|
354 | - * <i>Usage:</i> <kbd>$objResponse->addInsertAfter("childDiv", "h3", "myid");</kbd> |
|
355 | - * |
|
356 | - * @param string contains the id of the child after which the new element |
|
357 | - * will be inserted |
|
358 | - * @param string the tag to be added |
|
359 | - * @param string the id to be assigned to the new element |
|
360 | - */ |
|
361 | - function addInsertAfter($sAfter, $sTag, $sId) |
|
362 | - { |
|
363 | - $this->xml .= $this->_cmdXML(array("n"=>"ia","t"=>$sAfter,"p"=>$sId),$sTag); |
|
364 | - } |
|
365 | - |
|
366 | - /** |
|
367 | - * Adds a create input command message to the XML response. |
|
368 | - * |
|
369 | - * <i>Usage:</i> <kbd>$objResponse->addCreateInput("form1", "text", "username", "input1");</kbd> |
|
370 | - * |
|
371 | - * @param string contains the id of an HTML element to which the new input |
|
372 | - * will be appended |
|
373 | - * @param string the type of input to be created (text, radio, checkbox, |
|
374 | - * etc.) |
|
375 | - * @param string the name to be assigned to the new input and the variable |
|
376 | - * name when it is submitted |
|
377 | - * @param string the id to be assigned to the new input |
|
378 | - */ |
|
379 | - function addCreateInput($sParent, $sType, $sName, $sId) |
|
380 | - { |
|
381 | - $this->xml .= $this->_cmdXML(array("n"=>"ci","t"=>$sParent,"p"=>$sId,"c"=>$sType),$sName); |
|
382 | - } |
|
383 | - |
|
384 | - /** |
|
385 | - * Adds an insert input command message to the XML response. |
|
386 | - * |
|
387 | - * <i>Usage:</i> <kbd>$objResponse->addInsertInput("input5", "text", "username", "input1");</kbd> |
|
388 | - * |
|
389 | - * @param string contains the id of the child before which the new element |
|
390 | - * will be inserted |
|
391 | - * @param string the type of input to be created (text, radio, checkbox, |
|
392 | - * etc.) |
|
393 | - * @param string the name to be assigned to the new input and the variable |
|
394 | - * name when it is submitted |
|
395 | - * @param string the id to be assigned to the new input |
|
396 | - */ |
|
397 | - function addInsertInput($sBefore, $sType, $sName, $sId) |
|
398 | - { |
|
399 | - $this->xml .= $this->_cmdXML(array("n"=>"ii","t"=>$sBefore,"p"=>$sId,"c"=>$sType),$sName); |
|
400 | - } |
|
401 | - |
|
402 | - /** |
|
403 | - * Adds an insert input command message to the XML response. |
|
404 | - * |
|
405 | - * <i>Usage:</i> <kbd>$objResponse->addInsertInputAfter("input7", "text", "email", "input2");</kbd> |
|
406 | - * |
|
407 | - * @param string contains the id of the child after which the new element |
|
408 | - * will be inserted |
|
409 | - * @param string the type of input to be created (text, radio, checkbox, |
|
410 | - * etc.) |
|
411 | - * @param string the name to be assigned to the new input and the variable |
|
412 | - * name when it is submitted |
|
413 | - * @param string the id to be assigned to the new input |
|
414 | - */ |
|
415 | - function addInsertInputAfter($sAfter, $sType, $sName, $sId) |
|
416 | - { |
|
417 | - $this->xml .= $this->_cmdXML(array("n"=>"iia","t"=>$sAfter,"p"=>$sId,"c"=>$sType),$sName); |
|
418 | - } |
|
419 | - |
|
420 | - /** |
|
421 | - * Adds an event command message to the XML response. |
|
422 | - * |
|
423 | - * <i>Usage:</i> <kbd>$objResponse->addEvent("contentDiv", "onclick", "alert(\'Hello World\');");</kbd> |
|
424 | - * |
|
425 | - * @param string contains the id of an HTML element |
|
426 | - * @param string the event you wish to set ("onclick", "onmouseover", etc.) |
|
427 | - * @param string the Javascript string you want the event to invoke |
|
428 | - */ |
|
429 | - function addEvent($sTarget,$sEvent,$sScript) |
|
430 | - { |
|
431 | - $this->xml .= $this->_cmdXML(array("n"=>"ev","t"=>$sTarget,"p"=>$sEvent),$sScript); |
|
432 | - } |
|
433 | - |
|
434 | - /** |
|
435 | - * Adds a handler command message to the XML response. |
|
436 | - * |
|
437 | - * <i>Usage:</i> <kbd>$objResponse->addHandler("contentDiv", "onclick", "content_click");</kbd> |
|
438 | - * |
|
439 | - * @param string contains the id of an HTML element |
|
440 | - * @param string the event you wish to set ("onclick", "onmouseover", etc.) |
|
441 | - * @param string the name of a Javascript function that will handle the |
|
442 | - * event. Multiple handlers can be added for the same event |
|
443 | - */ |
|
444 | - function addHandler($sTarget,$sEvent,$sHandler) |
|
445 | - { |
|
446 | - $this->xml .= $this->_cmdXML(array("n"=>"ah","t"=>$sTarget,"p"=>$sEvent),$sHandler); |
|
447 | - } |
|
448 | - |
|
449 | - /** |
|
450 | - * Adds a remove handler command message to the XML response. |
|
451 | - * |
|
452 | - * <i>Usage:</i> <kbd>$objResponse->addRemoveHandler("contentDiv", "onclick", "content_click");</kbd> |
|
453 | - * |
|
454 | - * @param string contains the id of an HTML element |
|
455 | - * @param string the event you wish to remove ("onclick", "onmouseover", |
|
456 | - * etc.) |
|
457 | - * @param string the name of a Javascript handler function that you want to |
|
458 | - * remove |
|
459 | - */ |
|
460 | - function addRemoveHandler($sTarget,$sEvent,$sHandler) |
|
461 | - { |
|
462 | - $this->xml .= $this->_cmdXML(array("n"=>"rh","t"=>$sTarget,"p"=>$sEvent),$sHandler); |
|
463 | - } |
|
464 | - |
|
465 | - /** |
|
466 | - * Adds an include script command message to the XML response. |
|
467 | - * |
|
468 | - * <i>Usage:</i> <kbd>$objResponse->addIncludeScript("functions.js");</kbd> |
|
469 | - * |
|
470 | - * @param string URL of the Javascript file to include |
|
471 | - */ |
|
472 | - function addIncludeScript($sFileName) |
|
473 | - { |
|
474 | - $this->xml .= $this->_cmdXML(array("n"=>"in"),$sFileName); |
|
475 | - } |
|
476 | - |
|
477 | - /** |
|
478 | - * Returns the XML to be returned from your function to the xajax processor |
|
479 | - * on your page. Since xajax 0.2, you can also return an xajaxResponse |
|
480 | - * object from your function directly, and xajax will automatically request |
|
481 | - * the XML using this method call. |
|
482 | - * |
|
483 | - * <i>Usage:</i> <kbd>return $objResponse->getXML();</kbd> |
|
484 | - * |
|
485 | - * @return string response XML data |
|
486 | - */ |
|
487 | - function getXML() |
|
488 | - { |
|
489 | - $sXML = "<?xml version=\"1.0\""; |
|
490 | - if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0) |
|
491 | - $sXML .= " encoding=\"".$this->sEncoding."\""; |
|
492 | - $sXML .= " ?"."><xjx>" . $this->xml . "</xjx>"; |
|
493 | - |
|
494 | - return $sXML; |
|
495 | - } |
|
496 | - |
|
497 | - /** |
|
498 | - * Adds the commands of the provided response XML output to this response |
|
499 | - * object |
|
500 | - * |
|
501 | - * <i>Usage:</i> |
|
502 | - * <code>$r1 = $objResponse1->getXML(); |
|
503 | - * $objResponse2->loadXML($r1); |
|
504 | - * return $objResponse2->getXML();</code> |
|
505 | - * |
|
506 | - * @param string the response XML (returned from a getXML() method) to add |
|
507 | - * to the end of this response object |
|
508 | - */ |
|
509 | - function loadXML($mXML) |
|
510 | - { |
|
511 | - if (is_a($mXML, "xajaxResponse")) { |
|
512 | - $mXML = $mXML->getXML(); |
|
513 | - } |
|
514 | - $sNewXML = ""; |
|
515 | - $iStartPos = strpos($mXML, "<xjx>") + 5; |
|
516 | - $sNewXML = substr($mXML, $iStartPos); |
|
517 | - $iEndPos = strpos($sNewXML, "</xjx>"); |
|
518 | - $sNewXML = substr($sNewXML, 0, $iEndPos); |
|
519 | - $this->xml .= $sNewXML; |
|
520 | - } |
|
521 | - |
|
522 | - /** |
|
523 | - * Generates XML from command data |
|
524 | - * |
|
525 | - * @access private |
|
526 | - * @param array associative array of attributes |
|
527 | - * @param string data |
|
528 | - * @return string XML command |
|
529 | - */ |
|
530 | - function _cmdXML($aAttributes, $sData) |
|
531 | - { |
|
532 | - if ($this->bOutputEntities) { |
|
533 | - // An adaptation for the Dokeos LMS, 22-AUG-2009. |
|
534 | - if (function_exists('api_convert_encoding')) { |
|
535 | - $sData = call_user_func_array('api_convert_encoding', array(&$sData, 'HTML-ENTITIES', $this->sEncoding)); |
|
536 | - } |
|
537 | - //if (function_exists('mb_convert_encoding')) { |
|
538 | - elseif (function_exists('mb_convert_encoding')) { |
|
539 | - // |
|
540 | - $sData = call_user_func_array('mb_convert_encoding', array(&$sData, 'HTML-ENTITIES', $this->sEncoding)); |
|
541 | - } |
|
542 | - else { |
|
543 | - trigger_error("The xajax XML response output could not be converted to HTML entities because the mb_convert_encoding function is not available", E_USER_NOTICE); |
|
544 | - } |
|
545 | - } |
|
546 | - $xml = "<cmd"; |
|
547 | - foreach($aAttributes as $sAttribute => $sValue) |
|
548 | - $xml .= " $sAttribute=\"$sValue\""; |
|
549 | - if ($sData !== null && !stristr($sData,'<![CDATA[')) |
|
550 | - $xml .= "><![CDATA[$sData]]></cmd>"; |
|
551 | - else if ($sData !== null) |
|
552 | - $xml .= ">$sData</cmd>"; |
|
553 | - else |
|
554 | - $xml .= "></cmd>"; |
|
555 | - |
|
556 | - return $xml; |
|
557 | - } |
|
558 | - |
|
559 | - /** |
|
560 | - * Recursively serializes a data structure in XML so it can be sent to |
|
561 | - * the client. It could be thought of as the opposite of |
|
562 | - * {@link xajax::_parseObjXml()}. |
|
563 | - * |
|
564 | - * @access private |
|
565 | - * @param mixed data structure to serialize to XML |
|
566 | - * @return string serialized XML |
|
567 | - */ |
|
568 | - function _buildObjXml($var) { |
|
569 | - if (gettype($var) == "object") $var = get_object_vars($var); |
|
570 | - if (!is_array($var)) { |
|
571 | - return "<![CDATA[$var]]>"; |
|
572 | - } |
|
573 | - else { |
|
574 | - $data = "<xjxobj>"; |
|
575 | - foreach ($var as $key => $value) { |
|
576 | - $data .= "<e>"; |
|
577 | - $data .= "<k>" . htmlspecialchars($key) . "</k>"; |
|
578 | - $data .= "<v>" . $this->_buildObjXml($value) . "</v>"; |
|
579 | - $data .= "</e>"; |
|
580 | - } |
|
581 | - $data .= "</xjxobj>"; |
|
582 | - return $data; |
|
583 | - } |
|
584 | - } |
|
265 | + parse_str($queryPart, $queryParts); |
|
266 | + $newQueryPart = ""; |
|
267 | + foreach($queryParts as $key => $value) |
|
268 | + { |
|
269 | + $newQueryPart .= rawurlencode($key).'='.rawurlencode($value).ini_get('arg_separator.output'); |
|
270 | + } |
|
271 | + $sURL = str_replace($queryPart, $newQueryPart, $sURL); |
|
272 | + } |
|
273 | + $this->addScript('window.location = "'.$sURL.'";'); |
|
274 | + } |
|
275 | + |
|
276 | + /** |
|
277 | + * Adds a Javascript command message to the XML response. |
|
278 | + * |
|
279 | + * <i>Usage:</i> <kbd>$objResponse->addScript("var x = prompt('get some text');");</kbd> |
|
280 | + * |
|
281 | + * @param string contains Javascript code to be executed |
|
282 | + */ |
|
283 | + function addScript($sJS) |
|
284 | + { |
|
285 | + $this->xml .= $this->_cmdXML(array("n"=>"js"),$sJS); |
|
286 | + } |
|
287 | + |
|
288 | + /** |
|
289 | + * Adds a Javascript function call command message to the XML response. |
|
290 | + * |
|
291 | + * <i>Usage:</i> <kbd>$objResponse->addScriptCall("myJSFunction", "arg 1", "arg 2", 12345);</kbd> |
|
292 | + * |
|
293 | + * @param string $sFunc the name of a Javascript function |
|
294 | + * @param mixed $args,... optional arguments to pass to the Javascript function |
|
295 | + */ |
|
296 | + function addScriptCall() { |
|
297 | + $arguments = func_get_args(); |
|
298 | + $sFunc = array_shift($arguments); |
|
299 | + $sData = $this->_buildObjXml($arguments); |
|
300 | + $this->xml .= $this->_cmdXML(array("n"=>"jc","t"=>$sFunc),$sData); |
|
301 | + } |
|
302 | + |
|
303 | + /** |
|
304 | + * Adds a remove element command message to the XML response. |
|
305 | + * |
|
306 | + * <i>Usage:</i> <kbd>$objResponse->addRemove("Div2");</kbd> |
|
307 | + * |
|
308 | + * @param string contains the id of an HTML element to be removed |
|
309 | + */ |
|
310 | + function addRemove($sTarget) |
|
311 | + { |
|
312 | + $this->xml .= $this->_cmdXML(array("n"=>"rm","t"=>$sTarget),''); |
|
313 | + } |
|
314 | + |
|
315 | + /** |
|
316 | + * Adds a create element command message to the XML response. |
|
317 | + * |
|
318 | + * <i>Usage:</i> <kbd>$objResponse->addCreate("parentDiv", "h3", "myid");</kbd> |
|
319 | + * |
|
320 | + * @param string contains the id of an HTML element to to which the new |
|
321 | + * element will be appended. |
|
322 | + * @param string the tag to be added |
|
323 | + * @param string the id to be assigned to the new element |
|
324 | + * @param string deprecated, use the addCreateInput() method instead |
|
325 | + */ |
|
326 | + function addCreate($sParent, $sTag, $sId, $sType="") |
|
327 | + { |
|
328 | + if ($sType) |
|
329 | + { |
|
330 | + trigger_error("The \$sType parameter of addCreate has been deprecated. Use the addCreateInput() method instead.", E_USER_WARNING); |
|
331 | + return; |
|
332 | + } |
|
333 | + $this->xml .= $this->_cmdXML(array("n"=>"ce","t"=>$sParent,"p"=>$sId),$sTag); |
|
334 | + } |
|
335 | + |
|
336 | + /** |
|
337 | + * Adds a insert element command message to the XML response. |
|
338 | + * |
|
339 | + * <i>Usage:</i> <kbd>$objResponse->addInsert("childDiv", "h3", "myid");</kbd> |
|
340 | + * |
|
341 | + * @param string contains the id of the child before which the new element |
|
342 | + * will be inserted |
|
343 | + * @param string the tag to be added |
|
344 | + * @param string the id to be assigned to the new element |
|
345 | + */ |
|
346 | + function addInsert($sBefore, $sTag, $sId) |
|
347 | + { |
|
348 | + $this->xml .= $this->_cmdXML(array("n"=>"ie","t"=>$sBefore,"p"=>$sId),$sTag); |
|
349 | + } |
|
350 | + |
|
351 | + /** |
|
352 | + * Adds a insert element command message to the XML response. |
|
353 | + * |
|
354 | + * <i>Usage:</i> <kbd>$objResponse->addInsertAfter("childDiv", "h3", "myid");</kbd> |
|
355 | + * |
|
356 | + * @param string contains the id of the child after which the new element |
|
357 | + * will be inserted |
|
358 | + * @param string the tag to be added |
|
359 | + * @param string the id to be assigned to the new element |
|
360 | + */ |
|
361 | + function addInsertAfter($sAfter, $sTag, $sId) |
|
362 | + { |
|
363 | + $this->xml .= $this->_cmdXML(array("n"=>"ia","t"=>$sAfter,"p"=>$sId),$sTag); |
|
364 | + } |
|
365 | + |
|
366 | + /** |
|
367 | + * Adds a create input command message to the XML response. |
|
368 | + * |
|
369 | + * <i>Usage:</i> <kbd>$objResponse->addCreateInput("form1", "text", "username", "input1");</kbd> |
|
370 | + * |
|
371 | + * @param string contains the id of an HTML element to which the new input |
|
372 | + * will be appended |
|
373 | + * @param string the type of input to be created (text, radio, checkbox, |
|
374 | + * etc.) |
|
375 | + * @param string the name to be assigned to the new input and the variable |
|
376 | + * name when it is submitted |
|
377 | + * @param string the id to be assigned to the new input |
|
378 | + */ |
|
379 | + function addCreateInput($sParent, $sType, $sName, $sId) |
|
380 | + { |
|
381 | + $this->xml .= $this->_cmdXML(array("n"=>"ci","t"=>$sParent,"p"=>$sId,"c"=>$sType),$sName); |
|
382 | + } |
|
383 | + |
|
384 | + /** |
|
385 | + * Adds an insert input command message to the XML response. |
|
386 | + * |
|
387 | + * <i>Usage:</i> <kbd>$objResponse->addInsertInput("input5", "text", "username", "input1");</kbd> |
|
388 | + * |
|
389 | + * @param string contains the id of the child before which the new element |
|
390 | + * will be inserted |
|
391 | + * @param string the type of input to be created (text, radio, checkbox, |
|
392 | + * etc.) |
|
393 | + * @param string the name to be assigned to the new input and the variable |
|
394 | + * name when it is submitted |
|
395 | + * @param string the id to be assigned to the new input |
|
396 | + */ |
|
397 | + function addInsertInput($sBefore, $sType, $sName, $sId) |
|
398 | + { |
|
399 | + $this->xml .= $this->_cmdXML(array("n"=>"ii","t"=>$sBefore,"p"=>$sId,"c"=>$sType),$sName); |
|
400 | + } |
|
401 | + |
|
402 | + /** |
|
403 | + * Adds an insert input command message to the XML response. |
|
404 | + * |
|
405 | + * <i>Usage:</i> <kbd>$objResponse->addInsertInputAfter("input7", "text", "email", "input2");</kbd> |
|
406 | + * |
|
407 | + * @param string contains the id of the child after which the new element |
|
408 | + * will be inserted |
|
409 | + * @param string the type of input to be created (text, radio, checkbox, |
|
410 | + * etc.) |
|
411 | + * @param string the name to be assigned to the new input and the variable |
|
412 | + * name when it is submitted |
|
413 | + * @param string the id to be assigned to the new input |
|
414 | + */ |
|
415 | + function addInsertInputAfter($sAfter, $sType, $sName, $sId) |
|
416 | + { |
|
417 | + $this->xml .= $this->_cmdXML(array("n"=>"iia","t"=>$sAfter,"p"=>$sId,"c"=>$sType),$sName); |
|
418 | + } |
|
419 | + |
|
420 | + /** |
|
421 | + * Adds an event command message to the XML response. |
|
422 | + * |
|
423 | + * <i>Usage:</i> <kbd>$objResponse->addEvent("contentDiv", "onclick", "alert(\'Hello World\');");</kbd> |
|
424 | + * |
|
425 | + * @param string contains the id of an HTML element |
|
426 | + * @param string the event you wish to set ("onclick", "onmouseover", etc.) |
|
427 | + * @param string the Javascript string you want the event to invoke |
|
428 | + */ |
|
429 | + function addEvent($sTarget,$sEvent,$sScript) |
|
430 | + { |
|
431 | + $this->xml .= $this->_cmdXML(array("n"=>"ev","t"=>$sTarget,"p"=>$sEvent),$sScript); |
|
432 | + } |
|
433 | + |
|
434 | + /** |
|
435 | + * Adds a handler command message to the XML response. |
|
436 | + * |
|
437 | + * <i>Usage:</i> <kbd>$objResponse->addHandler("contentDiv", "onclick", "content_click");</kbd> |
|
438 | + * |
|
439 | + * @param string contains the id of an HTML element |
|
440 | + * @param string the event you wish to set ("onclick", "onmouseover", etc.) |
|
441 | + * @param string the name of a Javascript function that will handle the |
|
442 | + * event. Multiple handlers can be added for the same event |
|
443 | + */ |
|
444 | + function addHandler($sTarget,$sEvent,$sHandler) |
|
445 | + { |
|
446 | + $this->xml .= $this->_cmdXML(array("n"=>"ah","t"=>$sTarget,"p"=>$sEvent),$sHandler); |
|
447 | + } |
|
448 | + |
|
449 | + /** |
|
450 | + * Adds a remove handler command message to the XML response. |
|
451 | + * |
|
452 | + * <i>Usage:</i> <kbd>$objResponse->addRemoveHandler("contentDiv", "onclick", "content_click");</kbd> |
|
453 | + * |
|
454 | + * @param string contains the id of an HTML element |
|
455 | + * @param string the event you wish to remove ("onclick", "onmouseover", |
|
456 | + * etc.) |
|
457 | + * @param string the name of a Javascript handler function that you want to |
|
458 | + * remove |
|
459 | + */ |
|
460 | + function addRemoveHandler($sTarget,$sEvent,$sHandler) |
|
461 | + { |
|
462 | + $this->xml .= $this->_cmdXML(array("n"=>"rh","t"=>$sTarget,"p"=>$sEvent),$sHandler); |
|
463 | + } |
|
464 | + |
|
465 | + /** |
|
466 | + * Adds an include script command message to the XML response. |
|
467 | + * |
|
468 | + * <i>Usage:</i> <kbd>$objResponse->addIncludeScript("functions.js");</kbd> |
|
469 | + * |
|
470 | + * @param string URL of the Javascript file to include |
|
471 | + */ |
|
472 | + function addIncludeScript($sFileName) |
|
473 | + { |
|
474 | + $this->xml .= $this->_cmdXML(array("n"=>"in"),$sFileName); |
|
475 | + } |
|
476 | + |
|
477 | + /** |
|
478 | + * Returns the XML to be returned from your function to the xajax processor |
|
479 | + * on your page. Since xajax 0.2, you can also return an xajaxResponse |
|
480 | + * object from your function directly, and xajax will automatically request |
|
481 | + * the XML using this method call. |
|
482 | + * |
|
483 | + * <i>Usage:</i> <kbd>return $objResponse->getXML();</kbd> |
|
484 | + * |
|
485 | + * @return string response XML data |
|
486 | + */ |
|
487 | + function getXML() |
|
488 | + { |
|
489 | + $sXML = "<?xml version=\"1.0\""; |
|
490 | + if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0) |
|
491 | + $sXML .= " encoding=\"".$this->sEncoding."\""; |
|
492 | + $sXML .= " ?"."><xjx>" . $this->xml . "</xjx>"; |
|
493 | + |
|
494 | + return $sXML; |
|
495 | + } |
|
496 | + |
|
497 | + /** |
|
498 | + * Adds the commands of the provided response XML output to this response |
|
499 | + * object |
|
500 | + * |
|
501 | + * <i>Usage:</i> |
|
502 | + * <code>$r1 = $objResponse1->getXML(); |
|
503 | + * $objResponse2->loadXML($r1); |
|
504 | + * return $objResponse2->getXML();</code> |
|
505 | + * |
|
506 | + * @param string the response XML (returned from a getXML() method) to add |
|
507 | + * to the end of this response object |
|
508 | + */ |
|
509 | + function loadXML($mXML) |
|
510 | + { |
|
511 | + if (is_a($mXML, "xajaxResponse")) { |
|
512 | + $mXML = $mXML->getXML(); |
|
513 | + } |
|
514 | + $sNewXML = ""; |
|
515 | + $iStartPos = strpos($mXML, "<xjx>") + 5; |
|
516 | + $sNewXML = substr($mXML, $iStartPos); |
|
517 | + $iEndPos = strpos($sNewXML, "</xjx>"); |
|
518 | + $sNewXML = substr($sNewXML, 0, $iEndPos); |
|
519 | + $this->xml .= $sNewXML; |
|
520 | + } |
|
521 | + |
|
522 | + /** |
|
523 | + * Generates XML from command data |
|
524 | + * |
|
525 | + * @access private |
|
526 | + * @param array associative array of attributes |
|
527 | + * @param string data |
|
528 | + * @return string XML command |
|
529 | + */ |
|
530 | + function _cmdXML($aAttributes, $sData) |
|
531 | + { |
|
532 | + if ($this->bOutputEntities) { |
|
533 | + // An adaptation for the Dokeos LMS, 22-AUG-2009. |
|
534 | + if (function_exists('api_convert_encoding')) { |
|
535 | + $sData = call_user_func_array('api_convert_encoding', array(&$sData, 'HTML-ENTITIES', $this->sEncoding)); |
|
536 | + } |
|
537 | + //if (function_exists('mb_convert_encoding')) { |
|
538 | + elseif (function_exists('mb_convert_encoding')) { |
|
539 | + // |
|
540 | + $sData = call_user_func_array('mb_convert_encoding', array(&$sData, 'HTML-ENTITIES', $this->sEncoding)); |
|
541 | + } |
|
542 | + else { |
|
543 | + trigger_error("The xajax XML response output could not be converted to HTML entities because the mb_convert_encoding function is not available", E_USER_NOTICE); |
|
544 | + } |
|
545 | + } |
|
546 | + $xml = "<cmd"; |
|
547 | + foreach($aAttributes as $sAttribute => $sValue) |
|
548 | + $xml .= " $sAttribute=\"$sValue\""; |
|
549 | + if ($sData !== null && !stristr($sData,'<![CDATA[')) |
|
550 | + $xml .= "><![CDATA[$sData]]></cmd>"; |
|
551 | + else if ($sData !== null) |
|
552 | + $xml .= ">$sData</cmd>"; |
|
553 | + else |
|
554 | + $xml .= "></cmd>"; |
|
555 | + |
|
556 | + return $xml; |
|
557 | + } |
|
558 | + |
|
559 | + /** |
|
560 | + * Recursively serializes a data structure in XML so it can be sent to |
|
561 | + * the client. It could be thought of as the opposite of |
|
562 | + * {@link xajax::_parseObjXml()}. |
|
563 | + * |
|
564 | + * @access private |
|
565 | + * @param mixed data structure to serialize to XML |
|
566 | + * @return string serialized XML |
|
567 | + */ |
|
568 | + function _buildObjXml($var) { |
|
569 | + if (gettype($var) == "object") $var = get_object_vars($var); |
|
570 | + if (!is_array($var)) { |
|
571 | + return "<![CDATA[$var]]>"; |
|
572 | + } |
|
573 | + else { |
|
574 | + $data = "<xjxobj>"; |
|
575 | + foreach ($var as $key => $value) { |
|
576 | + $data .= "<e>"; |
|
577 | + $data .= "<k>" . htmlspecialchars($key) . "</k>"; |
|
578 | + $data .= "<v>" . $this->_buildObjXml($value) . "</v>"; |
|
579 | + $data .= "</e>"; |
|
580 | + } |
|
581 | + $data .= "</xjxobj>"; |
|
582 | + return $data; |
|
583 | + } |
|
584 | + } |
|
585 | 585 | |
586 | 586 | }// end class xajaxResponse |
587 | 587 | ?> |
@@ -63,12 +63,12 @@ discard block |
||
63 | 63 | echo json_encode($response_data); |
64 | 64 | } |
65 | 65 | break; |
66 | - case 'show_course_information' : |
|
67 | - require_once '../global.inc.php'; |
|
66 | + case 'show_course_information' : |
|
67 | + require_once '../global.inc.php'; |
|
68 | 68 | |
69 | - // Get the name of the database course. |
|
70 | - $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION); |
|
71 | - $course_info = api_get_course_info($_GET['code']); |
|
69 | + // Get the name of the database course. |
|
70 | + $tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION); |
|
71 | + $course_info = api_get_course_info($_GET['code']); |
|
72 | 72 | |
73 | 73 | if ( |
74 | 74 | api_get_setting('course_catalog_hide_private') === 'true' && |
@@ -77,27 +77,27 @@ discard block |
||
77 | 77 | echo get_lang('PrivateAccess'); |
78 | 78 | break; |
79 | 79 | } |
80 | - //echo Display::tag('h2', $course_info['name']); |
|
81 | - //echo '<br />'; |
|
80 | + //echo Display::tag('h2', $course_info['name']); |
|
81 | + //echo '<br />'; |
|
82 | 82 | |
83 | - $sql = "SELECT * FROM $tbl_course_description |
|
83 | + $sql = "SELECT * FROM $tbl_course_description |
|
84 | 84 | WHERE c_id = ".$course_info['real_id']." AND session_id = 0 |
85 | 85 | ORDER BY id"; |
86 | - $result = Database::query($sql); |
|
87 | - if (Database::num_rows($result) > 0 ) { |
|
88 | - while ($description = Database::fetch_object($result)) { |
|
89 | - $descriptions[$description->id] = $description; |
|
90 | - } |
|
86 | + $result = Database::query($sql); |
|
87 | + if (Database::num_rows($result) > 0 ) { |
|
88 | + while ($description = Database::fetch_object($result)) { |
|
89 | + $descriptions[$description->id] = $description; |
|
90 | + } |
|
91 | 91 | // Function that displays the details of the course description in html. |
92 | - echo CourseManager::get_details_course_description_html( |
|
92 | + echo CourseManager::get_details_course_description_html( |
|
93 | 93 | $descriptions, |
94 | 94 | api_get_system_encoding(), |
95 | 95 | false |
96 | 96 | ); |
97 | - } else { |
|
98 | - echo get_lang('NoDescription'); |
|
99 | - } |
|
100 | - break; |
|
97 | + } else { |
|
98 | + echo get_lang('NoDescription'); |
|
99 | + } |
|
100 | + break; |
|
101 | 101 | case 'session_courses_lp_default': |
102 | 102 | /** |
103 | 103 | * @todo this functions need to belong to a class or a special |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $sidx = isset($_REQUEST['sidx']) && !empty($_REQUEST['sidx']) ? $_REQUEST['sidx'] : 'id'; |
113 | 113 | $sord = $_REQUEST['sord']; //asc or desc |
114 | 114 | if (!in_array($sord, array('asc','desc'))) { |
115 | - $sord = 'desc'; |
|
115 | + $sord = 'desc'; |
|
116 | 116 | } |
117 | 117 | $session_id = intval($_REQUEST['session_id']); |
118 | 118 | $course_id = intval($_REQUEST['course_id']); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $my_session_list[] = $item['id_session']; |
128 | 128 | } |
129 | 129 | if (!in_array($session_id, $my_session_list)) { |
130 | - break; |
|
130 | + break; |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | $date = '-'; |
313 | 313 | } |
314 | 314 | |
315 | - //Checking LP publicated and expired_on dates |
|
315 | + //Checking LP publicated and expired_on dates |
|
316 | 316 | |
317 | 317 | if (!empty($lp_item['publicated_on']) && $lp_item['publicated_on'] != '0000-00-00 00:00:00') { |
318 | 318 | $week_data = date('Y', api_strtotime($lp_item['publicated_on'], 'UTC')).' - '.get_week_from_day($lp_item['publicated_on']); |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | $date = '-'; |
441 | 441 | } |
442 | 442 | |
443 | - //Checking LP publicated and expired_on dates |
|
443 | + //Checking LP publicated and expired_on dates |
|
444 | 444 | if (!empty($lp_item['publicated_on']) && $lp_item['publicated_on'] != '0000-00-00 00:00:00') { |
445 | 445 | if ($now < api_strtotime($lp_item['publicated_on'], 'UTC')) { |
446 | 446 | continue; |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | |
495 | 495 | echo json_encode($response); |
496 | 496 | break; |
497 | - default: |
|
498 | - echo ''; |
|
497 | + default: |
|
498 | + echo ''; |
|
499 | 499 | } |
500 | 500 | exit; |
@@ -9,260 +9,260 @@ |
||
9 | 9 | */ |
10 | 10 | class LearnpathLink extends AbstractLink |
11 | 11 | { |
12 | - private $course_info = null; |
|
13 | - private $learnpath_table = null; |
|
14 | - private $learnpath_data = null; |
|
15 | - |
|
16 | - /** |
|
17 | - * Constructor |
|
18 | - */ |
|
19 | - public function __construct() |
|
20 | - { |
|
21 | - parent::__construct(); |
|
22 | - $this->set_type(LINK_LEARNPATH); |
|
23 | - } |
|
24 | - |
|
25 | - /** |
|
26 | - * Generate an array of learnpaths that a teacher hasn't created a link for. |
|
27 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
28 | - */ |
|
29 | - public function get_not_created_links() |
|
30 | - { |
|
31 | - return false; |
|
32 | - if (empty($this->course_code)) |
|
33 | - die('Error in get_not_created_links() : course code not set'); |
|
34 | - |
|
35 | - $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
36 | - |
|
37 | - $sql = 'SELECT id, name from '.$this->get_learnpath_table().' lp |
|
12 | + private $course_info = null; |
|
13 | + private $learnpath_table = null; |
|
14 | + private $learnpath_data = null; |
|
15 | + |
|
16 | + /** |
|
17 | + * Constructor |
|
18 | + */ |
|
19 | + public function __construct() |
|
20 | + { |
|
21 | + parent::__construct(); |
|
22 | + $this->set_type(LINK_LEARNPATH); |
|
23 | + } |
|
24 | + |
|
25 | + /** |
|
26 | + * Generate an array of learnpaths that a teacher hasn't created a link for. |
|
27 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
28 | + */ |
|
29 | + public function get_not_created_links() |
|
30 | + { |
|
31 | + return false; |
|
32 | + if (empty($this->course_code)) |
|
33 | + die('Error in get_not_created_links() : course code not set'); |
|
34 | + |
|
35 | + $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
36 | + |
|
37 | + $sql = 'SELECT id, name from '.$this->get_learnpath_table().' lp |
|
38 | 38 | WHERE c_id = '.$this->course_id.' AND id NOT IN ' |
39 | - .' (SELECT ref_id FROM '.$tbl_grade_links |
|
40 | - .' WHERE type = '.LINK_LEARNPATH |
|
41 | - ." AND course_code = '".$this->get_course_code()."'" |
|
42 | - .') AND lp.session_id='.api_get_session_id().''; |
|
43 | - |
|
44 | - $result = Database::query($sql); |
|
45 | - |
|
46 | - $cats=array(); |
|
47 | - while ($data=Database::fetch_array($result)) { |
|
48 | - $cats[] = array ($data['id'], $data['name']); |
|
49 | - } |
|
50 | - |
|
51 | - return $cats; |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * Generate an array of all learnpaths available. |
|
56 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
57 | - */ |
|
58 | - public function get_all_links() |
|
59 | - { |
|
60 | - if (empty($this->course_code)) |
|
61 | - die('Error in get_not_created_links() : course code not set'); |
|
62 | - |
|
63 | - $session_id = api_get_session_id(); |
|
64 | - if (empty($session_id)) { |
|
65 | - $session_condition = api_get_session_condition(0, true); |
|
66 | - } else { |
|
67 | - $session_condition = api_get_session_condition($session_id, true, true); |
|
68 | - } |
|
69 | - |
|
70 | - $sql = 'SELECT id, name FROM '.$this->get_learnpath_table().' |
|
39 | + .' (SELECT ref_id FROM '.$tbl_grade_links |
|
40 | + .' WHERE type = '.LINK_LEARNPATH |
|
41 | + ." AND course_code = '".$this->get_course_code()."'" |
|
42 | + .') AND lp.session_id='.api_get_session_id().''; |
|
43 | + |
|
44 | + $result = Database::query($sql); |
|
45 | + |
|
46 | + $cats=array(); |
|
47 | + while ($data=Database::fetch_array($result)) { |
|
48 | + $cats[] = array ($data['id'], $data['name']); |
|
49 | + } |
|
50 | + |
|
51 | + return $cats; |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * Generate an array of all learnpaths available. |
|
56 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
57 | + */ |
|
58 | + public function get_all_links() |
|
59 | + { |
|
60 | + if (empty($this->course_code)) |
|
61 | + die('Error in get_not_created_links() : course code not set'); |
|
62 | + |
|
63 | + $session_id = api_get_session_id(); |
|
64 | + if (empty($session_id)) { |
|
65 | + $session_condition = api_get_session_condition(0, true); |
|
66 | + } else { |
|
67 | + $session_condition = api_get_session_condition($session_id, true, true); |
|
68 | + } |
|
69 | + |
|
70 | + $sql = 'SELECT id, name FROM '.$this->get_learnpath_table().' |
|
71 | 71 | WHERE c_id = '.$this->course_id.' '.$session_condition.' '; |
72 | - $result = Database::query($sql); |
|
72 | + $result = Database::query($sql); |
|
73 | 73 | |
74 | - $cats = array(); |
|
75 | - while ($data=Database::fetch_array($result)) { |
|
76 | - $cats[] = array ($data['id'], $data['name']); |
|
77 | - } |
|
74 | + $cats = array(); |
|
75 | + while ($data=Database::fetch_array($result)) { |
|
76 | + $cats[] = array ($data['id'], $data['name']); |
|
77 | + } |
|
78 | 78 | |
79 | - return $cats; |
|
80 | - } |
|
79 | + return $cats; |
|
80 | + } |
|
81 | 81 | |
82 | 82 | |
83 | - /** |
|
84 | - * Has anyone used this learnpath yet ? |
|
85 | - */ |
|
86 | - public function has_results() |
|
87 | - { |
|
88 | - $tbl_stats = Database::get_course_table(TABLE_LP_VIEW); |
|
89 | - $sql = "SELECT count(id) AS number FROM $tbl_stats |
|
83 | + /** |
|
84 | + * Has anyone used this learnpath yet ? |
|
85 | + */ |
|
86 | + public function has_results() |
|
87 | + { |
|
88 | + $tbl_stats = Database::get_course_table(TABLE_LP_VIEW); |
|
89 | + $sql = "SELECT count(id) AS number FROM $tbl_stats |
|
90 | 90 | WHERE c_id = ".$this->course_id." AND lp_id = ".$this->get_ref_id(); |
91 | - $result = Database::query($sql); |
|
92 | - $number = Database::fetch_array($result,'NUM'); |
|
93 | - return ($number[0] != 0); |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Get the progress of this learnpath. Only the last attempt are taken into account. |
|
98 | - * @param $stud_id student id (default: all students who have results - then the average is returned) |
|
99 | - * @return array (score, max) if student is given |
|
100 | - * array (sum of scores, number of scores) otherwise |
|
101 | - * or null if no scores available |
|
102 | - */ |
|
103 | - public function calc_score($stud_id = null, $type = null) |
|
104 | - { |
|
105 | - $tbl_stats = Database::get_course_table(TABLE_LP_VIEW); |
|
106 | - $session_id = api_get_session_id(); |
|
107 | - |
|
108 | - $sql = "SELECT * FROM $tbl_stats |
|
91 | + $result = Database::query($sql); |
|
92 | + $number = Database::fetch_array($result,'NUM'); |
|
93 | + return ($number[0] != 0); |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * Get the progress of this learnpath. Only the last attempt are taken into account. |
|
98 | + * @param $stud_id student id (default: all students who have results - then the average is returned) |
|
99 | + * @return array (score, max) if student is given |
|
100 | + * array (sum of scores, number of scores) otherwise |
|
101 | + * or null if no scores available |
|
102 | + */ |
|
103 | + public function calc_score($stud_id = null, $type = null) |
|
104 | + { |
|
105 | + $tbl_stats = Database::get_course_table(TABLE_LP_VIEW); |
|
106 | + $session_id = api_get_session_id(); |
|
107 | + |
|
108 | + $sql = "SELECT * FROM $tbl_stats |
|
109 | 109 | WHERE |
110 | 110 | c_id = ".$this->course_id." AND |
111 | 111 | lp_id = ".$this->get_ref_id()." AND |
112 | 112 | session_id = $session_id "; |
113 | 113 | |
114 | - if (isset($stud_id)) |
|
115 | - $sql .= ' AND user_id = '.intval($stud_id); |
|
116 | - |
|
117 | - // order by id, that way the student's first attempt is accessed first |
|
118 | - $sql .= ' ORDER BY view_count DESC'; |
|
119 | - |
|
120 | - $scores = Database::query($sql); |
|
121 | - // for 1 student |
|
122 | - if (isset($stud_id)) { |
|
123 | - if ($data = Database::fetch_assoc($scores)) { |
|
124 | - return array ($data['progress'], 100); |
|
125 | - } else |
|
126 | - return null; |
|
127 | - } else { |
|
128 | - // all students -> get average |
|
129 | - $students = array(); // user list, needed to make sure we only |
|
130 | - // take first attempts into account |
|
131 | - $rescount = 0; |
|
132 | - $sum = 0; |
|
133 | - $bestResult = 0; |
|
134 | - $sumResult = 0; |
|
135 | - while ($data = Database::fetch_array($scores)) { |
|
136 | - if (!(array_key_exists($data['user_id'], $students))) { |
|
137 | - $students[$data['user_id']] = $data['progress']; |
|
138 | - $rescount++; |
|
139 | - $sum += $data['progress'] / 100; |
|
140 | - $sumResult += $data['progress']; |
|
141 | - |
|
142 | - if ($data['progress'] > $bestResult) { |
|
143 | - $bestResult = $data['progress']; |
|
144 | - } |
|
145 | - } |
|
146 | - } |
|
147 | - |
|
148 | - if ($rescount == 0) { |
|
149 | - return null; |
|
150 | - } else { |
|
151 | - |
|
152 | - switch ($type) { |
|
153 | - case 'best': |
|
154 | - return array($bestResult, 100); |
|
155 | - break; |
|
156 | - case 'average': |
|
157 | - return array($sumResult/$rescount, 100); |
|
158 | - break; |
|
159 | - case 'ranking': |
|
160 | - return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
161 | - break; |
|
162 | - default: |
|
163 | - return array($sum, $rescount); |
|
164 | - break; |
|
165 | - } |
|
166 | - } |
|
167 | - } |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * Get URL where to go to if the user clicks on the link. |
|
172 | - */ |
|
173 | - public function get_link() |
|
174 | - { |
|
175 | - $url = api_get_path(WEB_PATH).'main/newscorm/lp_controller.php?cidReq='.$this->get_course_code().'&gradebook=view'; |
|
176 | - $session_id = api_get_session_id(); |
|
177 | - if (!api_is_allowed_to_edit() || $this->calc_score(api_get_user_id()) == null) { |
|
178 | - $url .= '&action=view&session_id='.$session_id.'&lp_id='.$this->get_ref_id(); |
|
179 | - } else { |
|
180 | - $url .= '&action=build&session_id='.$session_id.'&lp_id='.$this->get_ref_id(); |
|
181 | - } |
|
182 | - return $url; |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * Get name to display: same as learnpath title |
|
187 | - */ |
|
188 | - public function get_name() |
|
189 | - { |
|
190 | - $data = $this->get_learnpath_data(); |
|
191 | - return $data['name']; |
|
192 | - } |
|
193 | - |
|
194 | - /** |
|
195 | - * Get description to display: same as learnpath description |
|
196 | - */ |
|
197 | - public function get_description() |
|
198 | - { |
|
199 | - $data = $this->get_learnpath_data(); |
|
200 | - return $data['description']; |
|
201 | - } |
|
202 | - |
|
203 | - /** |
|
204 | - * Check if this still links to a learnpath |
|
205 | - */ |
|
206 | - public function is_valid_link() { |
|
207 | - $sql = 'SELECT count(id) FROM '.$this->get_learnpath_table().' |
|
114 | + if (isset($stud_id)) |
|
115 | + $sql .= ' AND user_id = '.intval($stud_id); |
|
116 | + |
|
117 | + // order by id, that way the student's first attempt is accessed first |
|
118 | + $sql .= ' ORDER BY view_count DESC'; |
|
119 | + |
|
120 | + $scores = Database::query($sql); |
|
121 | + // for 1 student |
|
122 | + if (isset($stud_id)) { |
|
123 | + if ($data = Database::fetch_assoc($scores)) { |
|
124 | + return array ($data['progress'], 100); |
|
125 | + } else |
|
126 | + return null; |
|
127 | + } else { |
|
128 | + // all students -> get average |
|
129 | + $students = array(); // user list, needed to make sure we only |
|
130 | + // take first attempts into account |
|
131 | + $rescount = 0; |
|
132 | + $sum = 0; |
|
133 | + $bestResult = 0; |
|
134 | + $sumResult = 0; |
|
135 | + while ($data = Database::fetch_array($scores)) { |
|
136 | + if (!(array_key_exists($data['user_id'], $students))) { |
|
137 | + $students[$data['user_id']] = $data['progress']; |
|
138 | + $rescount++; |
|
139 | + $sum += $data['progress'] / 100; |
|
140 | + $sumResult += $data['progress']; |
|
141 | + |
|
142 | + if ($data['progress'] > $bestResult) { |
|
143 | + $bestResult = $data['progress']; |
|
144 | + } |
|
145 | + } |
|
146 | + } |
|
147 | + |
|
148 | + if ($rescount == 0) { |
|
149 | + return null; |
|
150 | + } else { |
|
151 | + |
|
152 | + switch ($type) { |
|
153 | + case 'best': |
|
154 | + return array($bestResult, 100); |
|
155 | + break; |
|
156 | + case 'average': |
|
157 | + return array($sumResult/$rescount, 100); |
|
158 | + break; |
|
159 | + case 'ranking': |
|
160 | + return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
161 | + break; |
|
162 | + default: |
|
163 | + return array($sum, $rescount); |
|
164 | + break; |
|
165 | + } |
|
166 | + } |
|
167 | + } |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * Get URL where to go to if the user clicks on the link. |
|
172 | + */ |
|
173 | + public function get_link() |
|
174 | + { |
|
175 | + $url = api_get_path(WEB_PATH).'main/newscorm/lp_controller.php?cidReq='.$this->get_course_code().'&gradebook=view'; |
|
176 | + $session_id = api_get_session_id(); |
|
177 | + if (!api_is_allowed_to_edit() || $this->calc_score(api_get_user_id()) == null) { |
|
178 | + $url .= '&action=view&session_id='.$session_id.'&lp_id='.$this->get_ref_id(); |
|
179 | + } else { |
|
180 | + $url .= '&action=build&session_id='.$session_id.'&lp_id='.$this->get_ref_id(); |
|
181 | + } |
|
182 | + return $url; |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * Get name to display: same as learnpath title |
|
187 | + */ |
|
188 | + public function get_name() |
|
189 | + { |
|
190 | + $data = $this->get_learnpath_data(); |
|
191 | + return $data['name']; |
|
192 | + } |
|
193 | + |
|
194 | + /** |
|
195 | + * Get description to display: same as learnpath description |
|
196 | + */ |
|
197 | + public function get_description() |
|
198 | + { |
|
199 | + $data = $this->get_learnpath_data(); |
|
200 | + return $data['description']; |
|
201 | + } |
|
202 | + |
|
203 | + /** |
|
204 | + * Check if this still links to a learnpath |
|
205 | + */ |
|
206 | + public function is_valid_link() { |
|
207 | + $sql = 'SELECT count(id) FROM '.$this->get_learnpath_table().' |
|
208 | 208 | WHERE c_id = '.$this->course_id.' AND id = '.$this->get_ref_id().' '; |
209 | - $result = Database::query($sql); |
|
210 | - $number = Database::fetch_row($result,'NUM'); |
|
211 | - return ($number[0] != 0); |
|
212 | - } |
|
213 | - |
|
214 | - public function get_type_name() |
|
215 | - { |
|
216 | - return get_lang('LearningPaths'); |
|
217 | - } |
|
218 | - |
|
219 | - public function needs_name_and_description() |
|
220 | - { |
|
221 | - return false; |
|
222 | - } |
|
223 | - |
|
224 | - public function needs_max() |
|
225 | - { |
|
226 | - return false; |
|
227 | - } |
|
228 | - |
|
229 | - public function needs_results() |
|
230 | - { |
|
231 | - return false; |
|
232 | - } |
|
233 | - |
|
234 | - public function is_allowed_to_change_name() |
|
235 | - { |
|
236 | - return false; |
|
237 | - } |
|
238 | - |
|
239 | - // INTERNAL FUNCTIONS |
|
240 | - |
|
241 | - /** |
|
242 | - * Lazy load function to get the database table of the learnpath |
|
243 | - */ |
|
244 | - private function get_learnpath_table() |
|
245 | - { |
|
246 | - $this->learnpath_table = Database :: get_course_table(TABLE_LP_MAIN); |
|
247 | - return $this->learnpath_table; |
|
248 | - } |
|
249 | - |
|
250 | - /** |
|
251 | - * Lazy load function to get the database contents of this learnpath |
|
252 | - */ |
|
253 | - private function get_learnpath_data() |
|
254 | - { |
|
255 | - if (!isset($this->learnpath_data)) { |
|
256 | - $sql = 'SELECT * FROM '.$this->get_learnpath_table().' |
|
209 | + $result = Database::query($sql); |
|
210 | + $number = Database::fetch_row($result,'NUM'); |
|
211 | + return ($number[0] != 0); |
|
212 | + } |
|
213 | + |
|
214 | + public function get_type_name() |
|
215 | + { |
|
216 | + return get_lang('LearningPaths'); |
|
217 | + } |
|
218 | + |
|
219 | + public function needs_name_and_description() |
|
220 | + { |
|
221 | + return false; |
|
222 | + } |
|
223 | + |
|
224 | + public function needs_max() |
|
225 | + { |
|
226 | + return false; |
|
227 | + } |
|
228 | + |
|
229 | + public function needs_results() |
|
230 | + { |
|
231 | + return false; |
|
232 | + } |
|
233 | + |
|
234 | + public function is_allowed_to_change_name() |
|
235 | + { |
|
236 | + return false; |
|
237 | + } |
|
238 | + |
|
239 | + // INTERNAL FUNCTIONS |
|
240 | + |
|
241 | + /** |
|
242 | + * Lazy load function to get the database table of the learnpath |
|
243 | + */ |
|
244 | + private function get_learnpath_table() |
|
245 | + { |
|
246 | + $this->learnpath_table = Database :: get_course_table(TABLE_LP_MAIN); |
|
247 | + return $this->learnpath_table; |
|
248 | + } |
|
249 | + |
|
250 | + /** |
|
251 | + * Lazy load function to get the database contents of this learnpath |
|
252 | + */ |
|
253 | + private function get_learnpath_data() |
|
254 | + { |
|
255 | + if (!isset($this->learnpath_data)) { |
|
256 | + $sql = 'SELECT * FROM '.$this->get_learnpath_table().' |
|
257 | 257 | WHERE c_id = '.$this->course_id.' AND id = '.$this->get_ref_id().' '; |
258 | - $result = Database::query($sql); |
|
259 | - $this->learnpath_data = Database::fetch_array($result); |
|
260 | - } |
|
261 | - return $this->learnpath_data; |
|
262 | - } |
|
263 | - |
|
264 | - public function get_icon_name() |
|
265 | - { |
|
266 | - return 'learnpath'; |
|
267 | - } |
|
258 | + $result = Database::query($sql); |
|
259 | + $this->learnpath_data = Database::fetch_array($result); |
|
260 | + } |
|
261 | + return $this->learnpath_data; |
|
262 | + } |
|
263 | + |
|
264 | + public function get_icon_name() |
|
265 | + { |
|
266 | + return 'learnpath'; |
|
267 | + } |
|
268 | 268 | } |
@@ -308,13 +308,13 @@ discard block |
||
308 | 308 | $firstname = $userInfo['firstname']; |
309 | 309 | $lastname = $userInfo['lastname']; |
310 | 310 | |
311 | - if (api_is_western_name_order()) { |
|
312 | - $message = sprintf(get_lang('AttemptingToLoginAs'),$firstname, $lastname, $userId); |
|
313 | - } else { |
|
314 | - $message = sprintf(get_lang('AttemptingToLoginAs'), $lastname, $firstname, $userId); |
|
315 | - } |
|
311 | + if (api_is_western_name_order()) { |
|
312 | + $message = sprintf(get_lang('AttemptingToLoginAs'),$firstname, $lastname, $userId); |
|
313 | + } else { |
|
314 | + $message = sprintf(get_lang('AttemptingToLoginAs'), $lastname, $firstname, $userId); |
|
315 | + } |
|
316 | 316 | |
317 | - if ($userId) { |
|
317 | + if ($userId) { |
|
318 | 318 | |
319 | 319 | // Logout the current user |
320 | 320 | LoginDelete(api_get_user_id()); |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | Display :: display_footer(); |
350 | 350 | exit; |
351 | 351 | |
352 | - } |
|
352 | + } |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | /** |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | }*/ |
389 | 389 | |
390 | 390 | if (!in_array($direction, array('ASC','DESC'))) { |
391 | - $direction = 'ASC'; |
|
391 | + $direction = 'ASC'; |
|
392 | 392 | } |
393 | 393 | $column = intval($column); |
394 | 394 | $from = intval($from); |
@@ -399,23 +399,23 @@ discard block |
||
399 | 399 | $sql .= " WHERE u.creator_id = ".api_get_user_id(); |
400 | 400 | } |
401 | 401 | |
402 | - $sql .= " ORDER BY col$column $direction "; |
|
403 | - $sql .= " LIMIT $from,$number_of_items"; |
|
402 | + $sql .= " ORDER BY col$column $direction "; |
|
403 | + $sql .= " LIMIT $from,$number_of_items"; |
|
404 | 404 | |
405 | - $res = Database::query($sql); |
|
405 | + $res = Database::query($sql); |
|
406 | 406 | |
407 | - $users = array (); |
|
407 | + $users = array (); |
|
408 | 408 | $t = time(); |
409 | - while ($user = Database::fetch_row($res)) { |
|
410 | - $userPicture = UserManager::getUserPicture($user[0], USER_IMAGE_SIZE_SMALL); |
|
411 | - $photo = '<img src="'.$userPicture.'" width="22" height="22" alt="'.api_get_person_name($user[2], $user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" />'; |
|
409 | + while ($user = Database::fetch_row($res)) { |
|
410 | + $userPicture = UserManager::getUserPicture($user[0], USER_IMAGE_SIZE_SMALL); |
|
411 | + $photo = '<img src="'.$userPicture.'" width="22" height="22" alt="'.api_get_person_name($user[2], $user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" />'; |
|
412 | 412 | |
413 | 413 | if ($user[7] == 1 && !empty($user[10])) { |
414 | 414 | // check expiration date |
415 | 415 | $expiration_time = convert_sql_date($user[10]); |
416 | 416 | // if expiration date is passed, store a special value for active field |
417 | 417 | if ($expiration_time < $t) { |
418 | - $user[7] = '-1'; |
|
418 | + $user[7] = '-1'; |
|
419 | 419 | } |
420 | 420 | } |
421 | 421 | |
@@ -433,9 +433,9 @@ discard block |
||
433 | 433 | api_get_local_time($user[9]), |
434 | 434 | $user[0] |
435 | 435 | ); |
436 | - } |
|
436 | + } |
|
437 | 437 | |
438 | - return $users; |
|
438 | + return $users; |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | /** |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | * @return string HTML-code with a mailto-link |
445 | 445 | */ |
446 | 446 | function email_filter($email) { |
447 | - return Display :: encrypted_mailto_link($email, $email); |
|
447 | + return Display :: encrypted_mailto_link($email, $email); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | /** |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | * @return string HTML-code with a mailto-link |
454 | 454 | */ |
455 | 455 | function user_filter($name, $params, $row) { |
456 | - return '<a href="'.api_get_path(WEB_PATH).'whoisonline.php?origin=user_list&id='.$row[0].'">'.$name.'</a>'; |
|
456 | + return '<a href="'.api_get_path(WEB_PATH).'whoisonline.php?origin=user_list&id='.$row[0].'">'.$name.'</a>'; |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | /** |
@@ -464,84 +464,84 @@ discard block |
||
464 | 464 | * @return string Some HTML-code with modify-buttons |
465 | 465 | */ |
466 | 466 | function modify_filter($user_id, $url_params, $row) { |
467 | - global $charset, $_admins_list; |
|
468 | - $is_admin = in_array($user_id,$_admins_list); |
|
469 | - $statusname = api_get_status_langvars(); |
|
470 | - $user_is_anonymous = false; |
|
467 | + global $charset, $_admins_list; |
|
468 | + $is_admin = in_array($user_id,$_admins_list); |
|
469 | + $statusname = api_get_status_langvars(); |
|
470 | + $user_is_anonymous = false; |
|
471 | 471 | $current_user_status_label = $row['7']; |
472 | 472 | |
473 | - if ($current_user_status_label == $statusname[ANONYMOUS]) { |
|
474 | - $user_is_anonymous =true; |
|
475 | - } |
|
476 | - $result = ''; |
|
477 | - if (!$user_is_anonymous) { |
|
478 | - $icon = Display::return_icon('course.png', get_lang('Courses'), array('onmouseout' => 'clear_course_list (\'div_'.$user_id.'\')')); |
|
479 | - $result .= '<a href="javascript:void(0)" onclick="load_course_list(\'div_'.$user_id.'\','.$user_id.')" > |
|
473 | + if ($current_user_status_label == $statusname[ANONYMOUS]) { |
|
474 | + $user_is_anonymous =true; |
|
475 | + } |
|
476 | + $result = ''; |
|
477 | + if (!$user_is_anonymous) { |
|
478 | + $icon = Display::return_icon('course.png', get_lang('Courses'), array('onmouseout' => 'clear_course_list (\'div_'.$user_id.'\')')); |
|
479 | + $result .= '<a href="javascript:void(0)" onclick="load_course_list(\'div_'.$user_id.'\','.$user_id.')" > |
|
480 | 480 | '.$icon.' |
481 | 481 | <div class="blackboard_hide" id="div_'.$user_id.'"> </div> |
482 | 482 | </a>'; |
483 | 483 | |
484 | 484 | $icon = Display::return_icon('session.png', get_lang('Sessions'), array('onmouseout' => 'clear_session_list (\'div_s_'.$user_id.'\')')); |
485 | - $result .= '<a href="javascript:void(0)" onclick="load_session_list(\'div_s_'.$user_id.'\','.$user_id.')" > |
|
485 | + $result .= '<a href="javascript:void(0)" onclick="load_session_list(\'div_s_'.$user_id.'\','.$user_id.')" > |
|
486 | 486 | '.$icon.' |
487 | 487 | <div class="blackboard_hide" id="div_s_'.$user_id.'"> </div> |
488 | 488 | </a>'; |
489 | - } else { |
|
490 | - $result .= Display::return_icon('course_na.png',get_lang('Courses')).' '; |
|
491 | - $result .= Display::return_icon('course_na.png',get_lang('Sessions')).' '; |
|
492 | - } |
|
489 | + } else { |
|
490 | + $result .= Display::return_icon('course_na.png',get_lang('Courses')).' '; |
|
491 | + $result .= Display::return_icon('course_na.png',get_lang('Sessions')).' '; |
|
492 | + } |
|
493 | 493 | |
494 | - if (api_is_platform_admin()) { |
|
495 | - if (!$user_is_anonymous) { |
|
496 | - $result .= '<a href="user_information.php?user_id='.$user_id.'">'.Display::return_icon('synthese_view.gif', get_lang('Info')).'</a> '; |
|
497 | - } else { |
|
498 | - $result .= Display::return_icon('synthese_view_na.gif', get_lang('Info')).' '; |
|
499 | - } |
|
500 | - } |
|
494 | + if (api_is_platform_admin()) { |
|
495 | + if (!$user_is_anonymous) { |
|
496 | + $result .= '<a href="user_information.php?user_id='.$user_id.'">'.Display::return_icon('synthese_view.gif', get_lang('Info')).'</a> '; |
|
497 | + } else { |
|
498 | + $result .= Display::return_icon('synthese_view_na.gif', get_lang('Info')).' '; |
|
499 | + } |
|
500 | + } |
|
501 | 501 | |
502 | 502 | //only allow platform admins to login_as, or session admins only for students (not teachers nor other admins) |
503 | 503 | if (api_is_platform_admin() || (api_is_session_admin() && $current_user_status_label == $statusname[STUDENT])) { |
504 | - if (!$user_is_anonymous) { |
|
504 | + if (!$user_is_anonymous) { |
|
505 | 505 | if (api_global_admin_can_edit_admin($user_id)) { |
506 | 506 | $result .= '<a href="user_list.php?action=login_as&user_id='.$user_id.'&sec_token='.$_SESSION['sec_token'].'">'.Display::return_icon('login_as.png', get_lang('LoginAs')).'</a> '; |
507 | 507 | } else { |
508 | 508 | $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')).' '; |
509 | 509 | } |
510 | - } else { |
|
511 | - $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')).' '; |
|
512 | - } |
|
510 | + } else { |
|
511 | + $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')).' '; |
|
512 | + } |
|
513 | 513 | } else { |
514 | - $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')).' '; |
|
514 | + $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')).' '; |
|
515 | 515 | } |
516 | 516 | |
517 | - if ($current_user_status_label != $statusname[STUDENT]) { |
|
518 | - $result .= Display::return_icon('statistics_na.gif', get_lang('Reporting')).' '; |
|
519 | - } else { |
|
520 | - $result .= '<a href="../mySpace/myStudents.php?student='.$user_id.'">'.Display::return_icon('statistics.gif', get_lang('Reporting')).'</a> '; |
|
521 | - } |
|
517 | + if ($current_user_status_label != $statusname[STUDENT]) { |
|
518 | + $result .= Display::return_icon('statistics_na.gif', get_lang('Reporting')).' '; |
|
519 | + } else { |
|
520 | + $result .= '<a href="../mySpace/myStudents.php?student='.$user_id.'">'.Display::return_icon('statistics.gif', get_lang('Reporting')).'</a> '; |
|
521 | + } |
|
522 | 522 | |
523 | - if (api_is_platform_admin(true)) { |
|
523 | + if (api_is_platform_admin(true)) { |
|
524 | 524 | $editProfileUrl = Display::getProfileEditionLink($user_id, true); |
525 | 525 | |
526 | 526 | if (!$user_is_anonymous && api_global_admin_can_edit_admin($user_id, null, true)) { |
527 | 527 | $result .= '<a href="' . $editProfileUrl . '">'.Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a> '; |
528 | - } else { |
|
528 | + } else { |
|
529 | 529 | $result .= Display::return_icon('edit_na.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a> '; |
530 | - } |
|
531 | - } |
|
530 | + } |
|
531 | + } |
|
532 | 532 | |
533 | - if ($is_admin) { |
|
534 | - $result .= Display::return_icon('admin_star.png', get_lang('IsAdministrator'),array('width'=> ICON_SIZE_SMALL, 'heigth'=> ICON_SIZE_SMALL)); |
|
535 | - } else { |
|
536 | - $result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator')); |
|
537 | - } |
|
533 | + if ($is_admin) { |
|
534 | + $result .= Display::return_icon('admin_star.png', get_lang('IsAdministrator'),array('width'=> ICON_SIZE_SMALL, 'heigth'=> ICON_SIZE_SMALL)); |
|
535 | + } else { |
|
536 | + $result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator')); |
|
537 | + } |
|
538 | 538 | |
539 | - // actions for assigning sessions, courses or users |
|
540 | - if (api_is_session_admin()) { |
|
541 | - /*if ($row[0] == api_get_user_id()) { |
|
539 | + // actions for assigning sessions, courses or users |
|
540 | + if (api_is_session_admin()) { |
|
541 | + /*if ($row[0] == api_get_user_id()) { |
|
542 | 542 | $result .= '<a href="dashboard_add_sessions_to_user.php?user='.$user_id.'">'.Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')).'</a> '; |
543 | 543 | }*/ |
544 | - } else { |
|
544 | + } else { |
|
545 | 545 | if ($current_user_status_label == $statusname[SESSIONADMIN]) { |
546 | 546 | $result .= Display::url( |
547 | 547 | Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')), |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | ); |
572 | 572 | } |
573 | 573 | } |
574 | - } |
|
574 | + } |
|
575 | 575 | |
576 | 576 | if (api_is_platform_admin()) { |
577 | 577 | $result .= ' <a data-title="'.get_lang('FreeBusyCalendar').'" href="'.api_get_path(WEB_AJAX_PATH).'agenda.ajax.php?a=get_user_agenda&user_id='.$user_id.'&modal_size=lg" class="agenda_opener ajax">'. |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | } |
590 | 590 | } |
591 | 591 | } |
592 | - return $result; |
|
592 | + return $result; |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | |
@@ -622,10 +622,10 @@ discard block |
||
622 | 622 | if ($action == 'edit') { |
623 | 623 | $result = Display::return_icon($image.'.png', get_lang('AccountExpired'), array(), 16); |
624 | 624 | } elseif ($row['0']<>$_user['user_id']) { |
625 | - // you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore. |
|
626 | - $result = Display::return_icon($image.'.png', get_lang(ucfirst($action)), array('onclick'=>'active_user(this);', 'id'=>'img_'.$row['0']), 16).'</a>'; |
|
627 | - } |
|
628 | - return $result; |
|
625 | + // you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore. |
|
626 | + $result = Display::return_icon($image.'.png', get_lang(ucfirst($action)), array('onclick'=>'active_user(this);', 'id'=>'img_'.$row['0']), 16).'</a>'; |
|
627 | + } |
|
628 | + return $result; |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | /** |
@@ -638,8 +638,8 @@ discard block |
||
638 | 638 | * @author Patrick Cool <[email protected]>, Ghent University, Belgium |
639 | 639 | */ |
640 | 640 | function status_filter($status) { |
641 | - $statusname = api_get_status_langvars(); |
|
642 | - return $statusname[$status]; |
|
641 | + $statusname = api_get_status_langvars(); |
|
642 | + return $statusname[$status]; |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | if (isset($_GET['keyword']) || isset($_GET['keyword_firstname'])) { |
@@ -655,8 +655,8 @@ discard block |
||
655 | 655 | |
656 | 656 | if (!empty($action)) { |
657 | 657 | $check = Security::check_token('get'); |
658 | - if ($check) { |
|
659 | - switch ($action) { |
|
658 | + if ($check) { |
|
659 | + switch ($action) { |
|
660 | 660 | case 'add_user_to_my_url': |
661 | 661 | $user_id = $_REQUEST["user_id"]; |
662 | 662 | $result = UrlManager::add_user_to_url($user_id, $current_access_url_id); |
@@ -666,45 +666,45 @@ discard block |
||
666 | 666 | $message = Display::return_message($message, 'confirmation'); |
667 | 667 | } |
668 | 668 | break; |
669 | - case 'delete_user': |
|
670 | - if (api_is_platform_admin()) { |
|
669 | + case 'delete_user': |
|
670 | + if (api_is_platform_admin()) { |
|
671 | 671 | $user_to_delete = $_GET['user_id']; |
672 | 672 | $current_user_id = api_get_user_id(); |
673 | 673 | |
674 | - if ($deleteUserAvailable && api_global_admin_can_edit_admin($_GET['user_id'])) { |
|
675 | - if ($user_to_delete != $current_user_id && UserManager :: delete_user($_GET['user_id'])) { |
|
676 | - $message = Display :: return_message(get_lang('UserDeleted'), 'confirmation'); |
|
677 | - } else { |
|
678 | - $message = Display :: return_message(get_lang('CannotDeleteUserBecauseOwnsCourse'), 'error'); |
|
679 | - } |
|
680 | - } else { |
|
681 | - $message = Display :: return_message(get_lang('CannotDeleteUser'),'error'); |
|
682 | - } |
|
683 | - } |
|
684 | - break; |
|
674 | + if ($deleteUserAvailable && api_global_admin_can_edit_admin($_GET['user_id'])) { |
|
675 | + if ($user_to_delete != $current_user_id && UserManager :: delete_user($_GET['user_id'])) { |
|
676 | + $message = Display :: return_message(get_lang('UserDeleted'), 'confirmation'); |
|
677 | + } else { |
|
678 | + $message = Display :: return_message(get_lang('CannotDeleteUserBecauseOwnsCourse'), 'error'); |
|
679 | + } |
|
680 | + } else { |
|
681 | + $message = Display :: return_message(get_lang('CannotDeleteUser'),'error'); |
|
682 | + } |
|
683 | + } |
|
684 | + break; |
|
685 | 685 | case 'delete': |
686 | - if (api_is_platform_admin()) { |
|
687 | - $number_of_selected_users = count($_POST['id']); |
|
688 | - $number_of_deleted_users = 0; |
|
689 | - if (is_array($_POST['id'])) { |
|
690 | - foreach ($_POST['id'] as $index => $user_id) { |
|
691 | - if ($user_id != $_user['user_id']) { |
|
692 | - if (UserManager::delete_user($user_id)) { |
|
693 | - $number_of_deleted_users++; |
|
694 | - } |
|
695 | - } |
|
696 | - } |
|
697 | - } |
|
698 | - if ($number_of_selected_users == $number_of_deleted_users) { |
|
686 | + if (api_is_platform_admin()) { |
|
687 | + $number_of_selected_users = count($_POST['id']); |
|
688 | + $number_of_deleted_users = 0; |
|
689 | + if (is_array($_POST['id'])) { |
|
690 | + foreach ($_POST['id'] as $index => $user_id) { |
|
691 | + if ($user_id != $_user['user_id']) { |
|
692 | + if (UserManager::delete_user($user_id)) { |
|
693 | + $number_of_deleted_users++; |
|
694 | + } |
|
695 | + } |
|
696 | + } |
|
697 | + } |
|
698 | + if ($number_of_selected_users == $number_of_deleted_users) { |
|
699 | 699 | $message = Display :: return_message(get_lang('SelectedUsersDeleted'), 'confirmation'); |
700 | - } else { |
|
700 | + } else { |
|
701 | 701 | $message = Display :: return_message(get_lang('SomeUsersNotDeleted'), 'error'); |
702 | - } |
|
703 | - } |
|
704 | - break; |
|
705 | - } |
|
706 | - Security::clear_token(); |
|
707 | - } |
|
702 | + } |
|
703 | + } |
|
704 | + break; |
|
705 | + } |
|
706 | + Security::clear_token(); |
|
707 | + } |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | // Create a search-box |
@@ -724,24 +724,24 @@ discard block |
||
724 | 724 | |
725 | 725 | $actions = ''; |
726 | 726 | if (api_is_platform_admin()) { |
727 | - $actions .= '<div style="float:right;">'. |
|
728 | - '<a href="'.api_get_path(WEB_CODE_PATH).'admin/user_add.php">'. |
|
729 | - Display::return_icon('new_user.png',get_lang('AddUsers'),'',ICON_SIZE_MEDIUM).'</a>'. |
|
730 | - '</div>'; |
|
727 | + $actions .= '<div style="float:right;">'. |
|
728 | + '<a href="'.api_get_path(WEB_CODE_PATH).'admin/user_add.php">'. |
|
729 | + Display::return_icon('new_user.png',get_lang('AddUsers'),'',ICON_SIZE_MEDIUM).'</a>'. |
|
730 | + '</div>'; |
|
731 | 731 | } |
732 | 732 | $actions .= $form->return_form(); |
733 | 733 | |
734 | 734 | if (isset ($_GET['keyword'])) { |
735 | - $parameters = array ('keyword' => Security::remove_XSS($_GET['keyword'])); |
|
735 | + $parameters = array ('keyword' => Security::remove_XSS($_GET['keyword'])); |
|
736 | 736 | } elseif (isset ($_GET['keyword_firstname'])) { |
737 | - $parameters['keyword_firstname'] = Security::remove_XSS($_GET['keyword_firstname']); |
|
738 | - $parameters['keyword_lastname'] = Security::remove_XSS($_GET['keyword_lastname']); |
|
739 | - $parameters['keyword_username'] = Security::remove_XSS($_GET['keyword_username']); |
|
740 | - $parameters['keyword_email'] = Security::remove_XSS($_GET['keyword_email']); |
|
741 | - $parameters['keyword_officialcode'] = Security::remove_XSS($_GET['keyword_officialcode']); |
|
742 | - $parameters['keyword_status'] = Security::remove_XSS($_GET['keyword_status']); |
|
743 | - $parameters['keyword_active'] = Security::remove_XSS($_GET['keyword_active']); |
|
744 | - $parameters['keyword_inactive'] = Security::remove_XSS($_GET['keyword_inactive']); |
|
737 | + $parameters['keyword_firstname'] = Security::remove_XSS($_GET['keyword_firstname']); |
|
738 | + $parameters['keyword_lastname'] = Security::remove_XSS($_GET['keyword_lastname']); |
|
739 | + $parameters['keyword_username'] = Security::remove_XSS($_GET['keyword_username']); |
|
740 | + $parameters['keyword_email'] = Security::remove_XSS($_GET['keyword_email']); |
|
741 | + $parameters['keyword_officialcode'] = Security::remove_XSS($_GET['keyword_officialcode']); |
|
742 | + $parameters['keyword_status'] = Security::remove_XSS($_GET['keyword_status']); |
|
743 | + $parameters['keyword_active'] = Security::remove_XSS($_GET['keyword_active']); |
|
744 | + $parameters['keyword_inactive'] = Security::remove_XSS($_GET['keyword_inactive']); |
|
745 | 745 | } |
746 | 746 | // Create a sortable table with user-data |
747 | 747 | $parameters['sec_token'] = Security::get_token(); |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | $res_admin = Database::query($sql_admin); |
753 | 753 | $_admins_list = array(); |
754 | 754 | while ($row_admin = Database::fetch_row($res_admin)) { |
755 | - $_admins_list[] = $row_admin[0]; |
|
755 | + $_admins_list[] = $row_admin[0]; |
|
756 | 756 | } |
757 | 757 | |
758 | 758 | // Display Advanced search form. |
@@ -808,11 +808,11 @@ discard block |
||
808 | 808 | $table->set_header(2, get_lang('OfficialCode')); |
809 | 809 | |
810 | 810 | if (api_is_western_name_order()) { |
811 | - $table->set_header(3, get_lang('FirstName')); |
|
812 | - $table->set_header(4, get_lang('LastName')); |
|
811 | + $table->set_header(3, get_lang('FirstName')); |
|
812 | + $table->set_header(4, get_lang('LastName')); |
|
813 | 813 | } else { |
814 | - $table->set_header(3, get_lang('LastName')); |
|
815 | - $table->set_header(4, get_lang('FirstName')); |
|
814 | + $table->set_header(3, get_lang('LastName')); |
|
815 | + $table->set_header(4, get_lang('FirstName')); |
|
816 | 816 | } |
817 | 817 | $table->set_header(5, get_lang('LoginName')); |
818 | 818 | $table->set_header(6, get_lang('Email')); |