PageRenderTime 54ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 1ms

/lib/deprecatedlib.php

https://bitbucket.org/synergylearning/campusconnect
PHP | 4708 lines | 3174 code | 320 blank | 1214 comment | 134 complexity | e83db44b6a623570d008321a8d2afa47 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-3.0, GPL-3.0, LGPL-2.1, Apache-2.0, BSD-3-Clause, AGPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. // This file is part of Moodle - http://moodle.org/
  3. //
  4. // Moodle is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // Moodle is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
  16. /**
  17. * deprecatedlib.php - Old functions retained only for backward compatibility
  18. *
  19. * Old functions retained only for backward compatibility. New code should not
  20. * use any of these functions.
  21. *
  22. * @package core
  23. * @subpackage deprecated
  24. * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
  25. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  26. * @deprecated
  27. */
  28. defined('MOODLE_INTERNAL') || die();
  29. /**
  30. * Factory method that was returning moodle_session object.
  31. *
  32. * @deprecated since 2.6
  33. * @return \core\session\manager
  34. */
  35. function session_get_instance() {
  36. // Note: the new session manager includes all methods from the original session class.
  37. static $deprecatedinstance = null;
  38. debugging('session_get_instance() is deprecated, use \core\session\manager instead', DEBUG_DEVELOPER);
  39. if (!$deprecatedinstance) {
  40. $deprecatedinstance = new \core\session\manager();
  41. }
  42. return $deprecatedinstance;
  43. }
  44. /**
  45. * Returns true if legacy session used.
  46. *
  47. * @deprecated since 2.6
  48. * @return bool
  49. */
  50. function session_is_legacy() {
  51. debugging('session_is_legacy() is deprecated, do not use any more', DEBUG_DEVELOPER);
  52. return false;
  53. }
  54. /**
  55. * Terminates all sessions, auth hooks are not executed.
  56. * Useful in upgrade scripts.
  57. *
  58. * @deprecated since 2.6
  59. */
  60. function session_kill_all() {
  61. debugging('session_kill_all() is deprecated, use \core\session\manager::kill_all_sessions() instead', DEBUG_DEVELOPER);
  62. \core\session\manager::kill_all_sessions();
  63. }
  64. /**
  65. * Mark session as accessed, prevents timeouts.
  66. *
  67. * @deprecated since 2.6
  68. * @param string $sid
  69. */
  70. function session_touch($sid) {
  71. debugging('session_touch() is deprecated, use \core\session\manager::touch_session() instead', DEBUG_DEVELOPER);
  72. \core\session\manager::touch_session($sid);
  73. }
  74. /**
  75. * Terminates one sessions, auth hooks are not executed.
  76. *
  77. * @deprecated since 2.6
  78. * @param string $sid session id
  79. */
  80. function session_kill($sid) {
  81. debugging('session_kill() is deprecated, use \core\session\manager::kill_session() instead', DEBUG_DEVELOPER);
  82. \core\session\manager::kill_session($sid);
  83. }
  84. /**
  85. * Terminates all sessions of one user, auth hooks are not executed.
  86. * NOTE: This can not work for file based sessions!
  87. *
  88. * @deprecated since 2.6
  89. * @param int $userid user id
  90. */
  91. function session_kill_user($userid) {
  92. debugging('session_kill_user() is deprecated, use \core\session\manager::kill_user_sessions() instead', DEBUG_DEVELOPER);
  93. \core\session\manager::kill_user_sessions($userid);
  94. }
  95. // PHP 5.6 includes session_gc(), we cannot define it any more.
  96. if (!function_exists('session_gc')) {
  97. /**
  98. * Session garbage collection
  99. * - verify timeout for all users
  100. * - kill sessions of all deleted users
  101. * - kill sessions of users with disabled plugins or 'nologin' plugin
  102. *
  103. * @deprecated since 2.6
  104. */
  105. function session_gc()
  106. {
  107. debugging('session_gc() is deprecated, use \core\session\manager::gc() instead', DEBUG_DEVELOPER);
  108. \core\session\manager::gc();
  109. }
  110. }
  111. /**
  112. * Setup $USER object - called during login, loginas, etc.
  113. *
  114. * Call sync_user_enrolments() manually after log-in, or log-in-as.
  115. *
  116. * @deprecated since 2.6
  117. * @param stdClass $user full user record object
  118. * @return void
  119. */
  120. function session_set_user($user) {
  121. debugging('session_set_user() is deprecated, use \core\session\manager::set_user() instead', DEBUG_DEVELOPER);
  122. \core\session\manager::set_user($user);
  123. }
  124. /**
  125. * Is current $USER logged-in-as somebody else?
  126. * @deprecated since 2.6
  127. * @return bool
  128. */
  129. function session_is_loggedinas() {
  130. debugging('session_is_loggedinas() is deprecated, use \core\session\manager::is_loggedinas() instead', DEBUG_DEVELOPER);
  131. return \core\session\manager::is_loggedinas();
  132. }
  133. /**
  134. * Returns the $USER object ignoring current login-as session
  135. * @deprecated since 2.6
  136. * @return stdClass user object
  137. */
  138. function session_get_realuser() {
  139. debugging('session_get_realuser() is deprecated, use \core\session\manager::get_realuser() instead', DEBUG_DEVELOPER);
  140. return \core\session\manager::get_realuser();
  141. }
  142. /**
  143. * Login as another user - no security checks here.
  144. * @deprecated since 2.6
  145. * @param int $userid
  146. * @param stdClass $context
  147. * @return void
  148. */
  149. function session_loginas($userid, $context) {
  150. debugging('session_loginas() is deprecated, use \core\session\manager::loginas() instead', DEBUG_DEVELOPER);
  151. \core\session\manager::loginas($userid, $context);
  152. }
  153. /**
  154. * Minify JavaScript files.
  155. *
  156. * @deprecated since 2.6
  157. *
  158. * @param array $files
  159. * @return string
  160. */
  161. function js_minify($files) {
  162. debugging('js_minify() is deprecated, use core_minify::js_files() or core_minify::js() instead.');
  163. return core_minify::js_files($files);
  164. }
  165. /**
  166. * Minify CSS files.
  167. *
  168. * @deprecated since 2.6
  169. *
  170. * @param array $files
  171. * @return string
  172. */
  173. function css_minify_css($files) {
  174. debugging('css_minify_css() is deprecated, use core_minify::css_files() or core_minify::css() instead.');
  175. return core_minify::css_files($files);
  176. }
  177. /**
  178. * Function to call all event handlers when triggering an event
  179. *
  180. * @deprecated since 2.6
  181. *
  182. * @param string $eventname name of the event
  183. * @param mixed $eventdata event data object
  184. * @return int number of failed events
  185. */
  186. function events_trigger($eventname, $eventdata) {
  187. // TODO: uncomment after conversion of all events in standard distribution
  188. // debugging('events_trigger() is deprecated, please use new events instead', DEBUG_DEVELOPER);
  189. return events_trigger_legacy($eventname, $eventdata);
  190. }
  191. /**
  192. * List all core subsystems and their location
  193. *
  194. * This is a whitelist of components that are part of the core and their
  195. * language strings are defined in /lang/en/<<subsystem>>.php. If a given
  196. * plugin is not listed here and it does not have proper plugintype prefix,
  197. * then it is considered as course activity module.
  198. *
  199. * The location is optionally dirroot relative path. NULL means there is no special
  200. * directory for this subsystem. If the location is set, the subsystem's
  201. * renderer.php is expected to be there.
  202. *
  203. * @deprecated since 2.6, use core_component::get_core_subsystems()
  204. *
  205. * @param bool $fullpaths false means relative paths from dirroot, use true for performance reasons
  206. * @return array of (string)name => (string|null)location
  207. */
  208. function get_core_subsystems($fullpaths = false) {
  209. global $CFG;
  210. // NOTE: do not add any other debugging here, keep forever.
  211. $subsystems = core_component::get_core_subsystems();
  212. if ($fullpaths) {
  213. return $subsystems;
  214. }
  215. debugging('Short paths are deprecated when using get_core_subsystems(), please fix the code to use fullpaths instead.', DEBUG_DEVELOPER);
  216. $dlength = strlen($CFG->dirroot);
  217. foreach ($subsystems as $k => $v) {
  218. if ($v === null) {
  219. continue;
  220. }
  221. $subsystems[$k] = substr($v, $dlength+1);
  222. }
  223. return $subsystems;
  224. }
  225. /**
  226. * Lists all plugin types.
  227. *
  228. * @deprecated since 2.6, use core_component::get_plugin_types()
  229. *
  230. * @param bool $fullpaths false means relative paths from dirroot
  231. * @return array Array of strings - name=>location
  232. */
  233. function get_plugin_types($fullpaths = true) {
  234. global $CFG;
  235. // NOTE: do not add any other debugging here, keep forever.
  236. $types = core_component::get_plugin_types();
  237. if ($fullpaths) {
  238. return $types;
  239. }
  240. debugging('Short paths are deprecated when using get_plugin_types(), please fix the code to use fullpaths instead.', DEBUG_DEVELOPER);
  241. $dlength = strlen($CFG->dirroot);
  242. foreach ($types as $k => $v) {
  243. if ($k === 'theme') {
  244. $types[$k] = 'theme';
  245. continue;
  246. }
  247. $types[$k] = substr($v, $dlength+1);
  248. }
  249. return $types;
  250. }
  251. /**
  252. * Use when listing real plugins of one type.
  253. *
  254. * @deprecated since 2.6, use core_component::get_plugin_list()
  255. *
  256. * @param string $plugintype type of plugin
  257. * @return array name=>fulllocation pairs of plugins of given type
  258. */
  259. function get_plugin_list($plugintype) {
  260. // NOTE: do not add any other debugging here, keep forever.
  261. if ($plugintype === '') {
  262. $plugintype = 'mod';
  263. }
  264. return core_component::get_plugin_list($plugintype);
  265. }
  266. /**
  267. * Get a list of all the plugins of a given type that define a certain class
  268. * in a certain file. The plugin component names and class names are returned.
  269. *
  270. * @deprecated since 2.6, use core_component::get_plugin_list_with_class()
  271. *
  272. * @param string $plugintype the type of plugin, e.g. 'mod' or 'report'.
  273. * @param string $class the part of the name of the class after the
  274. * frankenstyle prefix. e.g 'thing' if you are looking for classes with
  275. * names like report_courselist_thing. If you are looking for classes with
  276. * the same name as the plugin name (e.g. qtype_multichoice) then pass ''.
  277. * @param string $file the name of file within the plugin that defines the class.
  278. * @return array with frankenstyle plugin names as keys (e.g. 'report_courselist', 'mod_forum')
  279. * and the class names as values (e.g. 'report_courselist_thing', 'qtype_multichoice').
  280. */
  281. function get_plugin_list_with_class($plugintype, $class, $file) {
  282. // NOTE: do not add any other debugging here, keep forever.
  283. return core_component::get_plugin_list_with_class($plugintype, $class, $file);
  284. }
  285. /**
  286. * Returns the exact absolute path to plugin directory.
  287. *
  288. * @deprecated since 2.6, use core_component::get_plugin_directory()
  289. *
  290. * @param string $plugintype type of plugin
  291. * @param string $name name of the plugin
  292. * @return string full path to plugin directory; NULL if not found
  293. */
  294. function get_plugin_directory($plugintype, $name) {
  295. // NOTE: do not add any other debugging here, keep forever.
  296. if ($plugintype === '') {
  297. $plugintype = 'mod';
  298. }
  299. return core_component::get_plugin_directory($plugintype, $name);
  300. }
  301. /**
  302. * Normalize the component name using the "frankenstyle" names.
  303. *
  304. * @deprecated since 2.6, use core_component::normalize_component()
  305. *
  306. * @param string $component
  307. * @return array as (string)$type => (string)$plugin
  308. */
  309. function normalize_component($component) {
  310. // NOTE: do not add any other debugging here, keep forever.
  311. return core_component::normalize_component($component);
  312. }
  313. /**
  314. * Return exact absolute path to a plugin directory.
  315. *
  316. * @deprecated since 2.6, use core_component::normalize_component()
  317. *
  318. * @param string $component name such as 'moodle', 'mod_forum'
  319. * @return string full path to component directory; NULL if not found
  320. */
  321. function get_component_directory($component) {
  322. // NOTE: do not add any other debugging here, keep forever.
  323. return core_component::get_component_directory($component);
  324. }
  325. // === Deprecated before 2.6.0 ===
  326. /**
  327. * Hack to find out the GD version by parsing phpinfo output
  328. *
  329. * @return int GD version (1, 2, or 0)
  330. */
  331. function check_gd_version() {
  332. // TODO: delete function in Moodle 2.7
  333. debugging('check_gd_version() is deprecated, GD extension is always available now');
  334. $gdversion = 0;
  335. if (function_exists('gd_info')){
  336. $gd_info = gd_info();
  337. if (substr_count($gd_info['GD Version'], '2.')) {
  338. $gdversion = 2;
  339. } else if (substr_count($gd_info['GD Version'], '1.')) {
  340. $gdversion = 1;
  341. }
  342. } else {
  343. ob_start();
  344. phpinfo(INFO_MODULES);
  345. $phpinfo = ob_get_contents();
  346. ob_end_clean();
  347. $phpinfo = explode("\n", $phpinfo);
  348. foreach ($phpinfo as $text) {
  349. $parts = explode('</td>', $text);
  350. foreach ($parts as $key => $val) {
  351. $parts[$key] = trim(strip_tags($val));
  352. }
  353. if ($parts[0] == 'GD Version') {
  354. if (substr_count($parts[1], '2.0')) {
  355. $parts[1] = '2.0';
  356. }
  357. $gdversion = intval($parts[1]);
  358. }
  359. }
  360. }
  361. return $gdversion; // 1, 2 or 0
  362. }
  363. /**
  364. * Not used any more, the account lockout handling is now
  365. * part of authenticate_user_login().
  366. * @deprecated
  367. */
  368. function update_login_count() {
  369. // TODO: delete function in Moodle 2.6
  370. debugging('update_login_count() is deprecated, all calls need to be removed');
  371. }
  372. /**
  373. * Not used any more, replaced by proper account lockout.
  374. * @deprecated
  375. */
  376. function reset_login_count() {
  377. // TODO: delete function in Moodle 2.6
  378. debugging('reset_login_count() is deprecated, all calls need to be removed');
  379. }
  380. /**
  381. * Insert or update log display entry. Entry may already exist.
  382. * $module, $action must be unique
  383. * @deprecated
  384. *
  385. * @param string $module
  386. * @param string $action
  387. * @param string $mtable
  388. * @param string $field
  389. * @return void
  390. *
  391. */
  392. function update_log_display_entry($module, $action, $mtable, $field) {
  393. global $DB;
  394. debugging('The update_log_display_entry() is deprecated, please use db/log.php description file instead.');
  395. }
  396. /**
  397. * Given some text in HTML format, this function will pass it
  398. * through any filters that have been configured for this context.
  399. *
  400. * @deprecated use the text formatting in a standard way instead (http://docs.moodle.org/dev/Output_functions)
  401. * this was abused mostly for embedding of attachments
  402. * @todo final deprecation of this function in MDL-40607
  403. * @param string $text The text to be passed through format filters
  404. * @param int $courseid The current course.
  405. * @return string the filtered string.
  406. */
  407. function filter_text($text, $courseid = NULL) {
  408. global $CFG, $COURSE;
  409. debugging('filter_text() is deprecated, use format_text(), format_string() etc instead.', DEBUG_DEVELOPER);
  410. if (!$courseid) {
  411. $courseid = $COURSE->id;
  412. }
  413. if (!$context = context_course::instance($courseid, IGNORE_MISSING)) {
  414. return $text;
  415. }
  416. return filter_manager::instance()->filter_text($text, $context);
  417. }
  418. /**
  419. * This function indicates that current page requires the https
  420. * when $CFG->loginhttps enabled.
  421. *
  422. * By using this function properly, we can ensure 100% https-ized pages
  423. * at our entire discretion (login, forgot_password, change_password)
  424. * @deprecated use $PAGE->https_required() instead
  425. * @todo final deprecation of this function in MDL-40607
  426. */
  427. function httpsrequired() {
  428. global $PAGE;
  429. debugging('httpsrequired() is deprecated use $PAGE->https_required() instead.', DEBUG_DEVELOPER);
  430. $PAGE->https_required();
  431. }
  432. /**
  433. * Given a physical path to a file, returns the URL through which it can be reached in Moodle.
  434. *
  435. * @deprecated use moodle_url factory methods instead
  436. *
  437. * @param string $path Physical path to a file
  438. * @param array $options associative array of GET variables to append to the URL
  439. * @param string $type (questionfile|rssfile|httpscoursefile|coursefile)
  440. * @return string URL to file
  441. */
  442. function get_file_url($path, $options=null, $type='coursefile') {
  443. global $CFG;
  444. $path = str_replace('//', '/', $path);
  445. $path = trim($path, '/'); // no leading and trailing slashes
  446. // type of file
  447. switch ($type) {
  448. case 'questionfile':
  449. $url = $CFG->wwwroot."/question/exportfile.php";
  450. break;
  451. case 'rssfile':
  452. $url = $CFG->wwwroot."/rss/file.php";
  453. break;
  454. case 'httpscoursefile':
  455. $url = $CFG->httpswwwroot."/file.php";
  456. break;
  457. case 'coursefile':
  458. default:
  459. $url = $CFG->wwwroot."/file.php";
  460. }
  461. if ($CFG->slasharguments) {
  462. $parts = explode('/', $path);
  463. foreach ($parts as $key => $part) {
  464. /// anchor dash character should not be encoded
  465. $subparts = explode('#', $part);
  466. $subparts = array_map('rawurlencode', $subparts);
  467. $parts[$key] = implode('#', $subparts);
  468. }
  469. $path = implode('/', $parts);
  470. $ffurl = $url.'/'.$path;
  471. $separator = '?';
  472. } else {
  473. $path = rawurlencode('/'.$path);
  474. $ffurl = $url.'?file='.$path;
  475. $separator = '&amp;';
  476. }
  477. if ($options) {
  478. foreach ($options as $name=>$value) {
  479. $ffurl = $ffurl.$separator.$name.'='.$value;
  480. $separator = '&amp;';
  481. }
  482. }
  483. return $ffurl;
  484. }
  485. /**
  486. * @deprecated use get_string("pluginname", "auth_[PLUINNAME]") instead.
  487. * @todo remove completely in MDL-40517
  488. */
  489. function auth_get_plugin_title($authtype) {
  490. throw new coding_exception('Function auth_get_plugin_title() is deprecated, please use standard get_string("pluginname", "auth_'.$authtype.'")!');
  491. }
  492. /**
  493. * @deprecated use indivividual enrol plugin settings instead
  494. * @todo remove completely in MDL-40517
  495. */
  496. function get_default_course_role($course) {
  497. throw new coding_exception('get_default_course_role() can not be used any more, please use enrol plugin settings instead!');
  498. }
  499. /**
  500. * @deprecated use get_string_manager()->get_list_of_translations() instead.
  501. * @todo remove completely in MDL-40517
  502. */
  503. function get_list_of_languages($refreshcache=false, $returnall=false) {
  504. throw new coding_exception('get_list_of_languages() can not be used any more, please use get_string_manager()->get_list_of_translations() instead.');
  505. }
  506. /**
  507. * @deprecated use get_string_manager()->get_list_of_currencies() instead.
  508. * @todo remove completely in MDL-40517
  509. */
  510. function get_list_of_currencies() {
  511. throw new coding_exception('get_list_of_currencies() can not be used any more, please use get_string_manager()->get_list_of_currencies() instead.');
  512. }
  513. /**
  514. * @deprecated use get_string_manager()->get_list_of_countries() instead.
  515. * @todo remove completely in MDL-40517
  516. */
  517. function get_list_of_countries() {
  518. throw new coding_exception('get_list_of_countries() can not be used any more, please use get_string_manager()->get_list_of_countries() instead.');
  519. }
  520. /**
  521. * Return all course participant for a given course
  522. *
  523. * @deprecated use get_enrolled_users($context) instead.
  524. * @todo final deprecation of this function in MDL-40607
  525. * @param integer $courseid
  526. * @return array of user
  527. */
  528. function get_course_participants($courseid) {
  529. debugging('get_course_participants() is deprecated, use get_enrolled_users() instead.', DEBUG_DEVELOPER);
  530. return get_enrolled_users(context_course::instance($courseid));
  531. }
  532. /**
  533. * Return true if the user is a participant for a given course
  534. *
  535. * @deprecated use is_enrolled($context, $userid) instead.
  536. * @todo final deprecation of this function in MDL-40607
  537. * @param integer $userid
  538. * @param integer $courseid
  539. * @return boolean
  540. */
  541. function is_course_participant($userid, $courseid) {
  542. debugging('is_course_participant() is deprecated, use is_enrolled() instead.', DEBUG_DEVELOPER);
  543. return is_enrolled(context_course::instance($courseid), $userid);
  544. }
  545. /**
  546. * Searches logs to find all enrolments since a certain date
  547. *
  548. * used to print recent activity
  549. *
  550. * @param int $courseid The course in question.
  551. * @param int $timestart The date to check forward of
  552. * @return object|false {@link $USER} records or false if error.
  553. */
  554. function get_recent_enrolments($courseid, $timestart) {
  555. global $DB;
  556. debugging('get_recent_enrolments() is deprecated as it returned inaccurate results.', DEBUG_DEVELOPER);
  557. $context = context_course::instance($courseid);
  558. $sql = "SELECT u.id, u.firstname, u.lastname, MAX(l.time)
  559. FROM {user} u, {role_assignments} ra, {log} l
  560. WHERE l.time > ?
  561. AND l.course = ?
  562. AND l.module = 'course'
  563. AND l.action = 'enrol'
  564. AND ".$DB->sql_cast_char2int('l.info')." = u.id
  565. AND u.id = ra.userid
  566. AND ra.contextid ".get_related_contexts_string($context)."
  567. GROUP BY u.id, u.firstname, u.lastname
  568. ORDER BY MAX(l.time) ASC";
  569. $params = array($timestart, $courseid);
  570. return $DB->get_records_sql($sql, $params);
  571. }
  572. ########### FROM weblib.php ##########################################################################
  573. /**
  574. * @deprecated use $OUTPUT->box() instead.
  575. * @todo remove completely in MDL-40517
  576. */
  577. function print_simple_box($message, $align='', $width='', $color='', $padding=5, $class='generalbox', $id='', $return=false) {
  578. throw new coding_exception('print_simple_box can not be used any more. Please use $OUTPUT->box() instead');
  579. }
  580. /**
  581. * @deprecated use $OUTPUT->box_start instead.
  582. * @todo remove completely in MDL-40517
  583. */
  584. function print_simple_box_start($align='', $width='', $color='', $padding=5, $class='generalbox', $id='', $return=false) {
  585. throw new coding_exception('print_simple_box_start can not be used any more. Please use $OUTPUT->box_start instead');
  586. }
  587. /**
  588. * @deprecated use $OUTPUT->box_end instead.
  589. * @todo remove completely in MDL-40517
  590. */
  591. function print_simple_box_end($return=false) {
  592. throw new coding_exception('print_simple_box_end can not be used any more. Please use $OUTPUT->box_end instead');
  593. }
  594. /**
  595. * @deprecated the urltolink filter now does this job.
  596. * @todo remove completely in MDL-40517
  597. */
  598. function convert_urls_into_links($text) {
  599. throw new coding_exception('convert_urls_into_links() can not be used any more and replaced by the urltolink filter');
  600. }
  601. /**
  602. * @deprecated use the emoticon_manager class instead.
  603. * @todo remove completely in MDL-40517
  604. */
  605. function get_emoticons_list_for_help_file() {
  606. throw new coding_exception('get_emoticons_list_for_help_file() can not be used any more, use the new emoticon_manager API instead');
  607. }
  608. /**
  609. * @deprecated use emoticon filter now does this job.
  610. * @todo remove completely in MDL-40517
  611. */
  612. function replace_smilies(&$text) {
  613. throw new coding_exception('replace_smilies() can not be used any more and replaced with the emoticon filter.');
  614. }
  615. /**
  616. * @deprecated use clean_param($string, PARAM_FILE) instead.
  617. * @todo final deprecation of this function in MDL-40607
  618. *
  619. * @param string $string ?
  620. * @param int $allowdots ?
  621. * @return bool
  622. */
  623. function detect_munged_arguments($string, $allowdots=1) {
  624. debugging('detect_munged_arguments() is deprecated, please use clean_param(,PARAM_FILE) instead.', DEBUG_DEVELOPER);
  625. if (substr_count($string, '..') > $allowdots) { // Sometimes we allow dots in references
  626. return true;
  627. }
  628. if (preg_match('/[\|\`]/', $string)) { // check for other bad characters
  629. return true;
  630. }
  631. if (empty($string) or $string == '/') {
  632. return true;
  633. }
  634. return false;
  635. }
  636. /**
  637. * Unzip one zip file to a destination dir
  638. * Both parameters must be FULL paths
  639. * If destination isn't specified, it will be the
  640. * SAME directory where the zip file resides.
  641. *
  642. * @global object
  643. * @param string $zipfile The zip file to unzip
  644. * @param string $destination The location to unzip to
  645. * @param bool $showstatus_ignored Unused
  646. */
  647. function unzip_file($zipfile, $destination = '', $showstatus_ignored = true) {
  648. global $CFG;
  649. //Extract everything from zipfile
  650. $path_parts = pathinfo(cleardoubleslashes($zipfile));
  651. $zippath = $path_parts["dirname"]; //The path of the zip file
  652. $zipfilename = $path_parts["basename"]; //The name of the zip file
  653. $extension = $path_parts["extension"]; //The extension of the file
  654. //If no file, error
  655. if (empty($zipfilename)) {
  656. return false;
  657. }
  658. //If no extension, error
  659. if (empty($extension)) {
  660. return false;
  661. }
  662. //Clear $zipfile
  663. $zipfile = cleardoubleslashes($zipfile);
  664. //Check zipfile exists
  665. if (!file_exists($zipfile)) {
  666. return false;
  667. }
  668. //If no destination, passed let's go with the same directory
  669. if (empty($destination)) {
  670. $destination = $zippath;
  671. }
  672. //Clear $destination
  673. $destpath = rtrim(cleardoubleslashes($destination), "/");
  674. //Check destination path exists
  675. if (!is_dir($destpath)) {
  676. return false;
  677. }
  678. $packer = get_file_packer('application/zip');
  679. $result = $packer->extract_to_pathname($zipfile, $destpath);
  680. if ($result === false) {
  681. return false;
  682. }
  683. foreach ($result as $status) {
  684. if ($status !== true) {
  685. return false;
  686. }
  687. }
  688. return true;
  689. }
  690. /**
  691. * Zip an array of files/dirs to a destination zip file
  692. * Both parameters must be FULL paths to the files/dirs
  693. *
  694. * @global object
  695. * @param array $originalfiles Files to zip
  696. * @param string $destination The destination path
  697. * @return bool Outcome
  698. */
  699. function zip_files ($originalfiles, $destination) {
  700. global $CFG;
  701. //Extract everything from destination
  702. $path_parts = pathinfo(cleardoubleslashes($destination));
  703. $destpath = $path_parts["dirname"]; //The path of the zip file
  704. $destfilename = $path_parts["basename"]; //The name of the zip file
  705. $extension = $path_parts["extension"]; //The extension of the file
  706. //If no file, error
  707. if (empty($destfilename)) {
  708. return false;
  709. }
  710. //If no extension, add it
  711. if (empty($extension)) {
  712. $extension = 'zip';
  713. $destfilename = $destfilename.'.'.$extension;
  714. }
  715. //Check destination path exists
  716. if (!is_dir($destpath)) {
  717. return false;
  718. }
  719. //Check destination path is writable. TODO!!
  720. //Clean destination filename
  721. $destfilename = clean_filename($destfilename);
  722. //Now check and prepare every file
  723. $files = array();
  724. $origpath = NULL;
  725. foreach ($originalfiles as $file) { //Iterate over each file
  726. //Check for every file
  727. $tempfile = cleardoubleslashes($file); // no doubleslashes!
  728. //Calculate the base path for all files if it isn't set
  729. if ($origpath === NULL) {
  730. $origpath = rtrim(cleardoubleslashes(dirname($tempfile)), "/");
  731. }
  732. //See if the file is readable
  733. if (!is_readable($tempfile)) { //Is readable
  734. continue;
  735. }
  736. //See if the file/dir is in the same directory than the rest
  737. if (rtrim(cleardoubleslashes(dirname($tempfile)), "/") != $origpath) {
  738. continue;
  739. }
  740. //Add the file to the array
  741. $files[] = $tempfile;
  742. }
  743. $zipfiles = array();
  744. $start = strlen($origpath)+1;
  745. foreach($files as $file) {
  746. $zipfiles[substr($file, $start)] = $file;
  747. }
  748. $packer = get_file_packer('application/zip');
  749. return $packer->archive_to_pathname($zipfiles, $destpath . '/' . $destfilename);
  750. }
  751. /**
  752. * Get the IDs for the user's groups in the given course.
  753. *
  754. * @global object
  755. * @param int $courseid The course being examined - the 'course' table id field.
  756. * @return array|bool An _array_ of groupids, or false
  757. * (Was return $groupids[0] - consequences!)
  758. * @deprecated use groups_get_all_groups() instead.
  759. * @todo final deprecation of this function in MDL-40607
  760. */
  761. function mygroupid($courseid) {
  762. global $USER;
  763. debugging('mygroupid() is deprecated, please use groups_get_all_groups() instead.', DEBUG_DEVELOPER);
  764. if ($groups = groups_get_all_groups($courseid, $USER->id)) {
  765. return array_keys($groups);
  766. } else {
  767. return false;
  768. }
  769. }
  770. /**
  771. * Returns the current group mode for a given course or activity module
  772. *
  773. * Could be false, SEPARATEGROUPS or VISIBLEGROUPS (<-- Martin)
  774. *
  775. * @param object $course Course Object
  776. * @param object $cm Course Manager Object
  777. * @return mixed $course->groupmode
  778. */
  779. function groupmode($course, $cm=null) {
  780. if (isset($cm->groupmode) && empty($course->groupmodeforce)) {
  781. return $cm->groupmode;
  782. }
  783. return $course->groupmode;
  784. }
  785. /**
  786. * Sets the current group in the session variable
  787. * When $SESSION->currentgroup[$courseid] is set to 0 it means, show all groups.
  788. * Sets currentgroup[$courseid] in the session variable appropriately.
  789. * Does not do any permission checking.
  790. *
  791. * @global object
  792. * @param int $courseid The course being examined - relates to id field in
  793. * 'course' table.
  794. * @param int $groupid The group being examined.
  795. * @return int Current group id which was set by this function
  796. */
  797. function set_current_group($courseid, $groupid) {
  798. global $SESSION;
  799. return $SESSION->currentgroup[$courseid] = $groupid;
  800. }
  801. /**
  802. * Gets the current group - either from the session variable or from the database.
  803. *
  804. * @global object
  805. * @param int $courseid The course being examined - relates to id field in
  806. * 'course' table.
  807. * @param bool $full If true, the return value is a full record object.
  808. * If false, just the id of the record.
  809. * @return int|bool
  810. */
  811. function get_current_group($courseid, $full = false) {
  812. global $SESSION;
  813. if (isset($SESSION->currentgroup[$courseid])) {
  814. if ($full) {
  815. return groups_get_group($SESSION->currentgroup[$courseid]);
  816. } else {
  817. return $SESSION->currentgroup[$courseid];
  818. }
  819. }
  820. $mygroupid = mygroupid($courseid);
  821. if (is_array($mygroupid)) {
  822. $mygroupid = array_shift($mygroupid);
  823. set_current_group($courseid, $mygroupid);
  824. if ($full) {
  825. return groups_get_group($mygroupid);
  826. } else {
  827. return $mygroupid;
  828. }
  829. }
  830. if ($full) {
  831. return false;
  832. } else {
  833. return 0;
  834. }
  835. }
  836. /**
  837. * Inndicates fatal error. This function was originally printing the
  838. * error message directly, since 2.0 it is throwing exception instead.
  839. * The error printing is handled in default exception handler.
  840. *
  841. * Old method, don't call directly in new code - use print_error instead.
  842. *
  843. * @param string $message The message to display to the user about the error.
  844. * @param string $link The url where the user will be prompted to continue. If no url is provided the user will be directed to the site index page.
  845. * @return void, always throws moodle_exception
  846. */
  847. function error($message, $link='') {
  848. throw new moodle_exception('notlocalisederrormessage', 'error', $link, $message, 'error() is a deprecated function, please call print_error() instead of error()');
  849. }
  850. /**
  851. * @deprecated use $PAGE->requires->js_module() instead.
  852. */
  853. function require_js($lib) {
  854. throw new coding_exception('require_js() was removed, use new JS api');
  855. }
  856. /**
  857. * @deprecated use $PAGE->theme->name instead.
  858. * @todo final deprecation of this function in MDL-40607
  859. * @return string the name of the current theme.
  860. */
  861. function current_theme() {
  862. global $PAGE;
  863. debugging('current_theme() is deprecated, please use $PAGE->theme->name instead', DEBUG_DEVELOPER);
  864. return $PAGE->theme->name;
  865. }
  866. /**
  867. * Prints some red text using echo
  868. *
  869. * @deprecated
  870. * @param string $error The text to be displayed in red
  871. */
  872. function formerr($error) {
  873. debugging('formerr() has been deprecated. Please change your code to use $OUTPUT->error_text($string).');
  874. global $OUTPUT;
  875. echo $OUTPUT->error_text($error);
  876. }
  877. /**
  878. * Return the markup for the destination of the 'Skip to main content' links.
  879. * Accessibility improvement for keyboard-only users.
  880. *
  881. * Used in course formats, /index.php and /course/index.php
  882. *
  883. * @deprecated use $OUTPUT->skip_link_target() in instead.
  884. * @todo final deprecation of this function in MDL-40607
  885. * @return string HTML element.
  886. */
  887. function skip_main_destination() {
  888. global $OUTPUT;
  889. debugging('skip_main_destination() is deprecated, please use $OUTPUT->skip_link_target() instead.', DEBUG_DEVELOPER);
  890. return $OUTPUT->skip_link_target();
  891. }
  892. /**
  893. * @deprecated use $OUTPUT->heading() instead.
  894. * @todo remove completely in MDL-40517
  895. */
  896. function print_headline($text, $size=2, $return=false) {
  897. throw new coding_exception('print_headline() can not be used any more. Please use $OUTPUT->heading() instead.');
  898. }
  899. /**
  900. * @deprecated use $OUTPUT->heading() instead.
  901. * @todo remove completely in MDL-40517
  902. */
  903. function print_heading($text, $deprecated = '', $size = 2, $class = 'main', $return = false, $id = '') {
  904. throw new coding_exception('print_heading() can not be used any more. Please use $OUTPUT->heading() instead.');
  905. }
  906. /**
  907. * @deprecated use $OUTPUT->heading() instead.
  908. * @todo remove completely in MDL-40517
  909. */
  910. function print_heading_block($heading, $class='', $return=false) {
  911. throw new coding_exception('print_heading_with_block() can not be used any more. Please use $OUTPUT->heading() instead.');
  912. }
  913. /**
  914. * @deprecated use $OUTPUT->box() instead.
  915. * @todo remove completely in MDL-40517
  916. */
  917. function print_box($message, $classes='generalbox', $ids='', $return=false) {
  918. throw new coding_exception('print_box() can not be used any more. Please use $OUTPUT->box() instead.');
  919. }
  920. /**
  921. * @deprecated use $OUTPUT->box_start() instead.
  922. * @todo remove completely in MDL-40517
  923. */
  924. function print_box_start($classes='generalbox', $ids='', $return=false) {
  925. throw new coding_exception('print_box_start() can not be used any more. Please use $OUTPUT->box_start() instead.');
  926. }
  927. /**
  928. * @deprecated use $OUTPUT->box_end() instead.
  929. * @todo remove completely in MDL-40517
  930. */
  931. function print_box_end($return=false) {
  932. throw new coding_exception('print_box_end() can not be used any more. Please use $OUTPUT->box_end() instead.');
  933. }
  934. /**
  935. * Print a message in a standard themed container.
  936. *
  937. * @deprecated use $OUTPUT->container() instead.
  938. * @todo final deprecation of this function in MDL-40607
  939. * @param string $message, the content of the container
  940. * @param boolean $clearfix clear both sides
  941. * @param string $classes, space-separated class names.
  942. * @param string $idbase
  943. * @param boolean $return, return as string or just print it
  944. * @return string|void Depending on value of $return
  945. */
  946. function print_container($message, $clearfix=false, $classes='', $idbase='', $return=false) {
  947. global $OUTPUT;
  948. debugging('print_container() is deprecated. Please use $OUTPUT->container() instead.', DEBUG_DEVELOPER);
  949. if ($clearfix) {
  950. $classes .= ' clearfix';
  951. }
  952. $output = $OUTPUT->container($message, $classes, $idbase);
  953. if ($return) {
  954. return $output;
  955. } else {
  956. echo $output;
  957. }
  958. }
  959. /**
  960. * Starts a container using divs
  961. *
  962. * @deprecated use $OUTPUT->container_start() instead.
  963. * @todo final deprecation of this function in MDL-40607
  964. * @param boolean $clearfix clear both sides
  965. * @param string $classes, space-separated class names.
  966. * @param string $idbase
  967. * @param boolean $return, return as string or just print it
  968. * @return string|void Based on value of $return
  969. */
  970. function print_container_start($clearfix=false, $classes='', $idbase='', $return=false) {
  971. global $OUTPUT;
  972. debugging('print_container_start() is deprecated. Please use $OUTPUT->container_start() instead.', DEBUG_DEVELOPER);
  973. if ($clearfix) {
  974. $classes .= ' clearfix';
  975. }
  976. $output = $OUTPUT->container_start($classes, $idbase);
  977. if ($return) {
  978. return $output;
  979. } else {
  980. echo $output;
  981. }
  982. }
  983. /**
  984. * @deprecated do not use any more, is not automatic
  985. * @todo remove completely in MDL-40517
  986. */
  987. function check_theme_arrows() {
  988. throw new coding_exception('check_theme_arrows() has been deprecated, do not use it anymore, it is now automatic.');
  989. }
  990. /**
  991. * Simple function to end a container (see above)
  992. *
  993. * @deprecated use $OUTPUT->container_end() instead.
  994. * @todo final deprecation of this function in MDL-40607
  995. * @param boolean $return, return as string or just print it
  996. * @return string|void Based on $return
  997. */
  998. function print_container_end($return=false) {
  999. global $OUTPUT;
  1000. debugging('print_container_end() is deprecated. Please use $OUTPUT->container_end() instead.', DEBUG_DEVELOPER);
  1001. $output = $OUTPUT->container_end();
  1002. if ($return) {
  1003. return $output;
  1004. } else {
  1005. echo $output;
  1006. }
  1007. }
  1008. /**
  1009. * Print a bold message in an optional color.
  1010. *
  1011. * @deprecated use $OUTPUT->notification instead.
  1012. * @param string $message The message to print out
  1013. * @param string $style Optional style to display message text in
  1014. * @param string $align Alignment option
  1015. * @param bool $return whether to return an output string or echo now
  1016. * @return string|bool Depending on $result
  1017. */
  1018. function notify($message, $classes = 'notifyproblem', $align = 'center', $return = false) {
  1019. global $OUTPUT;
  1020. if ($classes == 'green') {
  1021. debugging('Use of deprecated class name "green" in notify. Please change to "notifysuccess".', DEBUG_DEVELOPER);
  1022. $classes = 'notifysuccess'; // Backward compatible with old color system
  1023. }
  1024. $output = $OUTPUT->notification($message, $classes);
  1025. if ($return) {
  1026. return $output;
  1027. } else {
  1028. echo $output;
  1029. }
  1030. }
  1031. /**
  1032. * Print a continue button that goes to a particular URL.
  1033. *
  1034. * @deprecated use $OUTPUT->continue_button() instead.
  1035. * @todo final deprecation of this function in MDL-40607
  1036. *
  1037. * @param string $link The url to create a link to.
  1038. * @param bool $return If set to true output is returned rather than echoed, default false
  1039. * @return string|void HTML String if return=true nothing otherwise
  1040. */
  1041. function print_continue($link, $return = false) {
  1042. global $CFG, $OUTPUT;
  1043. debugging('print_continue() is deprecated. Please use $OUTPUT->continue_button() instead.', DEBUG_DEVELOPER);
  1044. if ($link == '') {
  1045. if (!empty($_SERVER['HTTP_REFERER'])) {
  1046. $link = $_SERVER['HTTP_REFERER'];
  1047. $link = str_replace('&', '&amp;', $link); // make it valid XHTML
  1048. } else {
  1049. $link = $CFG->wwwroot .'/';
  1050. }
  1051. }
  1052. $output = $OUTPUT->continue_button($link);
  1053. if ($return) {
  1054. return $output;
  1055. } else {
  1056. echo $output;
  1057. }
  1058. }
  1059. /**
  1060. * Print a standard header
  1061. *
  1062. * @deprecated use $PAGE methods instead.
  1063. * @todo final deprecation of this function in MDL-40607
  1064. * @param string $title Appears at the top of the window
  1065. * @param string $heading Appears at the top of the page
  1066. * @param string $navigation Array of $navlinks arrays (keys: name, link, type) for use as breadcrumbs links
  1067. * @param string $focus Indicates form element to get cursor focus on load eg inputform.password
  1068. * @param string $meta Meta tags to be added to the header
  1069. * @param boolean $cache Should this page be cacheable?
  1070. * @param string $button HTML code for a button (usually for module editing)
  1071. * @param string $menu HTML code for a popup menu
  1072. * @param boolean $usexml use XML for this page
  1073. * @param string $bodytags This text will be included verbatim in the <body> tag (useful for onload() etc)
  1074. * @param bool $return If true, return the visible elements of the header instead of echoing them.
  1075. * @return string|void If return=true then string else void
  1076. */
  1077. function print_header($title='', $heading='', $navigation='', $focus='',
  1078. $meta='', $cache=true, $button='&nbsp;', $menu=null,
  1079. $usexml=false, $bodytags='', $return=false) {
  1080. global $PAGE, $OUTPUT;
  1081. debugging('print_header() is deprecated. Please use $PAGE methods instead.', DEBUG_DEVELOPER);
  1082. $PAGE->set_title($title);
  1083. $PAGE->set_heading($heading);
  1084. $PAGE->set_cacheable($cache);
  1085. if ($button == '') {
  1086. $button = '&nbsp;';
  1087. }
  1088. $PAGE->set_button($button);
  1089. $PAGE->set_headingmenu($menu);
  1090. // TODO $menu
  1091. if ($meta) {
  1092. throw new coding_exception('The $meta parameter to print_header is no longer supported. '.
  1093. 'You should be able to do everything you want with $PAGE->requires and other such mechanisms.');
  1094. }
  1095. if ($usexml) {
  1096. throw new coding_exception('The $usexml parameter to print_header is no longer supported.');
  1097. }
  1098. if ($bodytags) {
  1099. throw new coding_exception('The $bodytags parameter to print_header is no longer supported.');
  1100. }
  1101. $output = $OUTPUT->header();
  1102. if ($return) {
  1103. return $output;
  1104. } else {
  1105. echo $output;
  1106. }
  1107. }
  1108. /**
  1109. * This version of print_header is simpler because the course name does not have to be
  1110. * provided explicitly in the strings. It can be used on the site page as in courses
  1111. * Eventually all print_header could be replaced by print_header_simple
  1112. *
  1113. * @deprecated use $PAGE methods instead.
  1114. * @todo final deprecation of this function in MDL-40607
  1115. * @param string $title Appears at the top of the window
  1116. * @param string $heading Appears at the top of the page
  1117. * @param string $navigation Premade navigation string (for use as breadcrumbs links)
  1118. * @param string $focus Indicates form element to get cursor focus on load eg inputform.password
  1119. * @param string $meta Meta tags to be added to the header
  1120. * @param boolean $cache Should this page be cacheable?
  1121. * @param string $button HTML code for a button (usually for module editing)
  1122. * @param string $menu HTML code for a popup menu
  1123. * @param boolean $usexml use XML for this page
  1124. * @param string $bodytags This text will be included verbatim in the <body> tag (useful for onload() etc)
  1125. * @param bool $return If true, return the visible elements of the header instead of echoing them.
  1126. * @return string|void If $return=true the return string else nothing
  1127. */
  1128. function print_header_simple($title='', $heading='', $navigation='', $focus='', $meta='',
  1129. $cache=true, $button='&nbsp;', $menu='', $usexml=false, $bodytags='', $return=false) {
  1130. global $COURSE, $CFG, $PAGE, $OUTPUT;
  1131. debugging('print_header_simple() is deprecated. Please use $PAGE methods instead.', DEBUG_DEVELOPER);
  1132. if ($meta) {
  1133. throw new coding_exception('The $meta parameter to print_header is no longer supported. '.
  1134. 'You should be able to do everything you want with $PAGE->requires and other such mechanisms.');
  1135. }
  1136. if ($usexml) {
  1137. throw new coding_exception('The $usexml parameter to print_header is no longer supported.');
  1138. }
  1139. if ($bodytags) {
  1140. throw new coding_exception('The $bodytags parameter to print_header is no longer supported.');
  1141. }
  1142. $PAGE->set_title($title);
  1143. $PAGE->set_heading($heading);
  1144. $PAGE->set_cacheable(true);
  1145. $PAGE->set_button($button);
  1146. $output = $OUTPUT->header();
  1147. if ($return) {
  1148. return $output;
  1149. } else {
  1150. echo $output;
  1151. }
  1152. }
  1153. /**
  1154. * @deprecated use $OUTPUT->footer() instead.
  1155. * @todo remove completely in MDL-40517
  1156. */
  1157. function print_footer($course = NULL, $usercourse = NULL, $return = false) {
  1158. throw new coding_exception('print_footer() cant be used anymore. Please use $OUTPUT->footer() instead.');
  1159. }
  1160. /**
  1161. * @deprecated use theme layouts instead.
  1162. * @todo remove completely in MDL-40517
  1163. */
  1164. function user_login_string($course='ignored', $user='ignored') {
  1165. throw new coding_exception('user_login_info() cant be used anymore. User login info is now handled via themes layouts.');
  1166. }
  1167. /**
  1168. * Prints a nice side block with an optional header. The content can either
  1169. * be a block of HTML or a list of text with optional icons.
  1170. *
  1171. * @static int $block_id Increments for each call to the function
  1172. * @param string $heading HTML for the heading. Can include full HTML or just
  1173. * plain text - plain text will automatically be enclosed in the appropriate
  1174. * heading tags.
  1175. * @param string $content HTML for the content
  1176. * @param array $list an alternative to $content, it you want a list of things with optional icons.
  1177. * @param array $icons optional icons for the things in $list.
  1178. * @param string $footer Extra HTML content that gets output at the end, inside a &lt;div class="footer">
  1179. * @param array $attributes an array of attribute => value pairs that are put on the
  1180. * outer div of this block. If there is a class attribute ' block' gets appended to it. If there isn't
  1181. * already a class, class='block' is used.
  1182. * @param string $title Plain text title, as embedded in the $heading.
  1183. * @deprecated use $OUTPUT->block() instead.
  1184. * @todo final deprecation of this function in MDL-40607
  1185. */
  1186. function print_side_block($heading='', $content='', $list=NULL, $icons=NULL, $footer='', $attributes = array(), $title='') {
  1187. global $OUTPUT;
  1188. debugging('print_side_block() is deprecated, please use $OUTPUT->block() instead.', DEBUG_DEVELOPER);
  1189. // We don't use $heading, becuse it often contains HTML that we don't want.
  1190. // However, sometimes $title is not set, but $heading is.
  1191. if (empty($title)) {
  1192. $title = strip_tags($heading);
  1193. }
  1194. // Render list contents to HTML if required.
  1195. if (empty($content) && $list) {
  1196. $content = $OUTPUT->list_block_contents($icons, $list);
  1197. }
  1198. $bc = new block_contents();
  1199. $bc->content = $content;
  1200. $bc->footer = $footer;
  1201. $bc->title = $title;
  1202. if (isset($attributes['id'])) {
  1203. $bc->id = $attributes['id'];
  1204. unset($attributes['id']);
  1205. }
  1206. $bc->attributes = $attributes;
  1207. echo $OUTPUT->block($bc, BLOCK_POS_LEFT); // POS LEFT may be wrong, but no way to get a better guess here.
  1208. }
  1209. /**
  1210. * @deprecated blocks are now printed by theme.
  1211. * @todo remove completely in MDL-40517
  1212. */
  1213. function blocks_have_content(&$blockmanager, $region) {
  1214. throw new coding_exception('blocks_have_content() can no longer be used. Blocks are now printed by the theme.');
  1215. }
  1216. /**
  1217. * @deprecated blocks are now printed by the theme.
  1218. * @todo remove completely in MDL-40517
  1219. */
  1220. function blocks_print_group($page, $blockmanager, $region) {
  1221. throw new coding_exception('function blocks_print_group() can no longer be used. Blocks are now printed by the theme.');
  1222. }
  1223. /**
  1224. * @deprecated blocks are now printed by the theme.
  1225. * @todo remove completely in MDL-40517
  1226. */
  1227. function blocks_setup(&$page, $pinned = BLOCKS_PINNED_FALSE) {
  1228. throw new coding_exception('blocks_print_group() can no longer be used. Blocks are now printed by the theme.');
  1229. }
  1230. /**
  1231. * @deprecated Layout is now controlled by the theme.
  1232. * @todo remove completely in MDL-40517
  1233. */
  1234. function blocks_preferred_width($instances) {
  1235. throw new coding_exception('blocks_print_group() can no longer be used. Blocks are now printed by the theme.');
  1236. }
  1237. /**
  1238. * @deprecated use html_writer::table() instead.
  1239. * @todo remove completely in MDL-40517
  1240. */
  1241. function print_table($table, $return=false) {
  1242. throw new coding_exception('print_table() can no longer be used. Use html_writer::table() instead.');
  1243. }
  1244. /**
  1245. * @deprecated use $OUTPUT->action_link() instead (note: popups are discouraged for accesibility reasons)
  1246. * @todo remove completely in MDL-40517
  1247. */
  1248. function link_to_popup_window ($url, $name=null, $linkname=null, $height=400, $width=500, $title=null, $options=null, $return=false) {
  1249. throw new coding_exception('link_to_popup_window() can no longer be used. Please to use $OUTPUT->action_link() instead.');
  1250. }
  1251. /**
  1252. * @deprecated use $OUTPUT->single_button() instead.
  1253. * @todo remove completely in MDL-40517
  1254. */
  1255. function button_to_popup_window ($url, $name=null, $linkname=null,
  1256. $height=400, $width=500, $title=null, $options=null, $return=false,
  1257. $id=null, $class=null) {
  1258. throw new coding_exception('button_to_popup_window() can no longer be used. Please use $OUTPUT->single_button() instead.');
  1259. }
  1260. /**
  1261. * @deprecated use $OUTPUT->single_button() instead.
  1262. * @todo remove completely in MDL-40517
  1263. */
  1264. function print_single_button($link, $options, $label='OK', $method='get', $notusedanymore='',
  1265. $return=false, $tooltip='', $disabled = false, $jsconfirmmessage='', $formid = '') {
  1266. throw new coding_exception('print_single_button() can no longer be used. Please use $OUTPUT->single_button() instead.');
  1267. }
  1268. /**
  1269. * @deprecated use $OUTPUT->spacer() instead.
  1270. * @todo remove completely in MDL-40517
  1271. */
  1272. function print_spacer($height=1, $width=1, $br=true, $return=false) {
  1273. throw new coding_exception('print_spacer() can no longer be used. Please use $OUTPUT->spacer() instead.');
  1274. }
  1275. /**
  1276. * @deprecated use $OUTPUT->user_picture() instead.
  1277. * @todo remove completely in MDL-40517
  1278. */
  1279. function print_user_picture($user, $courseid, $picture=NULL, $size=0, $return=false, $link=true, $target='', $alttext=true) {
  1280. throw new coding_exception('print_user_picture() can no longer be used. Please use $OUTPUT->user_picture($user, array(\'courseid\'=>$courseid) instead.');
  1281. }
  1282. /**
  1283. * Prints a basic textarea field.
  1284. *
  1285. * @deprecated since Moodle 2.0
  1286. *
  1287. * When using this function, you should
  1288. *
  1289. * @global object
  1290. * @param bool $unused No longer used.
  1291. * @param int $rows Number of rows to display (minimum of 10 when $height is non-null)
  1292. * @param int $cols Number of columns to display (minimum of 65 when $width is non-null)
  1293. * @param null $width (Deprecated) Width of the element; if a value is passed, the minimum value for $cols will be 65. Value is otherwise ignored.
  1294. * @param null $height (Deprecated) Height of the element; if a value is passe, the minimum value for $rows will be 10. Value is otherwise ignored.
  1295. * @param string $name Name to use for the textarea element.
  1296. * @param string $value Initial content to display in the textarea.
  1297. * @param int $obsolete deprecated
  1298. * @param bool $return If false, will output string. If true, will return string value.
  1299. * @param string $id CSS ID to add to the textarea element.
  1300. * @return string|void depending on the value of $return
  1301. */
  1302. function print_textarea($unused, $rows, $cols, $width, $height, $name, $value='', $obsolete=0, $return=false, $id='') {
  1303. /// $width and height are legacy fi…

Large files files are truncated, but you can click here to view the full file