PageRenderTime 27ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/admin/users/institutions.php

https://github.com/ybozhko/phd-mahara
PHP | 653 lines | 549 code | 55 blank | 49 comment | 98 complexity | 006a49f829fe721c296306dfe62f0ab5 MD5 | raw file
Possible License(s): GPL-3.0, MIT, AGPL-1.0, LGPL-2.1
  1. <?php
  2. /**
  3. * Mahara: Electronic portfolio, weblog, resume builder and social networking
  4. * Copyright (C) 2006-2009 Catalyst IT Ltd and others; see:
  5. * http://wiki.mahara.org/Contributors
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. * @package mahara
  21. * @subpackage admin
  22. * @author Catalyst IT Ltd
  23. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL
  24. * @copyright (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
  25. *
  26. */
  27. define('INTERNAL', 1);
  28. define('INSTITUTIONALADMIN', 1);
  29. require(dirname(dirname(dirname(__FILE__))) . '/init.php');
  30. define('TITLE', get_string('institutions', 'admin'));
  31. define('SECTION_PLUGINTYPE', 'core');
  32. define('SECTION_PLUGINNAME', 'admin');
  33. define('SECTION_PAGE', 'institutions');
  34. require_once('pieforms/pieform.php');
  35. define('MENUITEM', 'manageinstitutions/institutions');
  36. $institution = param_variable('i', '');
  37. $add = param_boolean('add');
  38. $edit = param_boolean('edit');
  39. $delete = param_boolean('delete');
  40. $query = param_variable('query', '');
  41. $offset = param_integer('offset', 0);
  42. $limit = 20;
  43. if (!$USER->get('admin')) {
  44. // Institutional admins with only 1 institution go straight to the edit page for that institution
  45. // They cannot add or delete institutions, or edit an institution they don't administer
  46. $add = false;
  47. $delete = false;
  48. if (!empty($institution) && !$USER->is_institutional_admin($institution)) {
  49. $institution = '';
  50. $edit = false;
  51. }
  52. if (empty($institution) && count($USER->get('admininstitutions')) == 1) {
  53. redirect(get_config('wwwroot') . 'admin/users/institutions.php?i='
  54. . key($USER->get('admininstitutions')));
  55. }
  56. }
  57. if ($institution || $add) {
  58. $authinstances = auth_get_auth_instances_for_institution($institution);
  59. if (false == $authinstances) {
  60. $authinstances = array();
  61. }
  62. if ($delete) {
  63. function delete_validate(Pieform $form, $values) {
  64. if (get_field('usr_institution', 'COUNT(*)', 'institution', $values['i'])) {
  65. throw new ConfigException('Attempt to delete an institution that has members');
  66. }
  67. }
  68. function delete_cancel_submit() {
  69. redirect('/admin/users/institutions.php');
  70. }
  71. function delete_submit(Pieform $form, $values) {
  72. global $SESSION;
  73. $authinstanceids = get_column('auth_instance', 'id', 'institution', $values['i']);
  74. $viewids = get_column('view', 'id', 'institution', $values['i']);
  75. $artefactids = get_column('artefact', 'id', 'institution', $values['i']);
  76. db_begin();
  77. if ($viewids) {
  78. require_once(get_config('libroot') . 'view.php');
  79. foreach ($viewids as $viewid) {
  80. $view = new View($viewid);
  81. $view->delete();
  82. }
  83. }
  84. if ($artefactids) {
  85. foreach ($artefactids as $artefactid) {
  86. try {
  87. $a = artefact_instance_from_id($artefactid);
  88. $a->delete();
  89. }
  90. catch (ArtefactNotFoundException $e) {
  91. // Awesome, it's already gone.
  92. }
  93. }
  94. }
  95. foreach ($authinstanceids as $id) {
  96. delete_records('auth_instance_config', 'instance', $id);
  97. }
  98. delete_records('auth_instance', 'institution', $values['i']);
  99. delete_records('host', 'institution', $values['i']);
  100. delete_records('institution_locked_profile_field', 'name', $values['i']);
  101. delete_records('usr_institution_request', 'institution', $values['i']);
  102. delete_records('institution', 'name', $values['i']);
  103. db_commit();
  104. $SESSION->add_ok_msg(get_string('institutiondeletedsuccessfully', 'admin'));
  105. redirect('/admin/users/institutions.php');
  106. }
  107. $form = array(
  108. 'name' => 'delete',
  109. 'elements' => array(
  110. 'i' => array(
  111. 'type' => 'hidden',
  112. 'value' => $institution
  113. ),
  114. 'delete' => array(
  115. 'type' => 'hidden',
  116. 'value' => 1
  117. ),
  118. 'submit' => array(
  119. 'type' => 'submitcancel',
  120. 'value' => array(get_string('yes'), get_string('no'))
  121. )
  122. )
  123. );
  124. $deleteform = pieform($form);
  125. $smarty = smarty();
  126. $smarty->assign('delete_form', $deleteform);
  127. $smarty->assign('institutionname', get_field('institution', 'displayname', 'name', $institution));
  128. $smarty->display('admin/users/institutions.tpl');
  129. exit;
  130. }
  131. $instancearray = array();
  132. $instancestring = '';
  133. $c = count($authinstances);
  134. $inuse = '';
  135. $sitelockedfields = (array) get_column('institution_locked_profile_field', 'profilefield', 'name', 'mahara');
  136. if (!$add) {
  137. $data = get_record('institution', 'name', $institution);
  138. $lockedprofilefields = (array) get_column('institution_locked_profile_field', 'profilefield', 'name', $institution);
  139. // TODO: Find a better way to work around Smarty's minimal looping logic
  140. if (!empty($authinstances)) {
  141. foreach($authinstances as $key => $val) {
  142. $authinstances[$key]->index = $key;
  143. $authinstances[$key]->total = $c;
  144. $instancearray[] = (int)$val->id;
  145. }
  146. $instancestring = implode(',',$instancearray);
  147. $inuserecords = array();
  148. if ($records = get_records_sql_assoc('select authinstance, count(id) from {usr} where authinstance in ('.$instancestring.') group by authinstance', array())) {
  149. foreach ($records as $record) {
  150. $inuserecords[] = $record->authinstance;
  151. }
  152. }
  153. $inuse = implode(',',$inuserecords);
  154. }
  155. $authtypes = auth_get_available_auth_types($institution);
  156. }
  157. else {
  158. $data = new StdClass;
  159. $data->displayname = '';
  160. $data->expiry = null;
  161. if (!get_config('usersuniquebyusername')) {
  162. $data->registerallowed = 1;
  163. }
  164. $data->theme = 'sitedefault';
  165. $data->defaultmembershipperiod = null;
  166. $lockedprofilefields = array();
  167. $authtypes = auth_get_available_auth_types();
  168. }
  169. $themeoptions = get_institution_themes($institution);
  170. $themeoptions['sitedefault'] = '- ' . get_string('sitedefault', 'admin') . ' (' . $themeoptions[get_config('theme')] . ') -';
  171. uksort($themeoptions, 'theme_sort');
  172. $sitename = get_config('sitename');
  173. safe_require('artefact', 'internal');
  174. $elements = array(
  175. 'name' => array(
  176. 'type' => 'text',
  177. 'title' => get_string('institutionname', 'admin'),
  178. 'rules' => array(
  179. 'required' => true,
  180. 'maxlength' => 255,
  181. 'regex' => '/^[a-zA-Z]+$/'
  182. ),
  183. 'ignore' => !$add,
  184. 'help' => true,
  185. ),
  186. 'add' => array(
  187. 'type' => 'hidden',
  188. 'value' => true,
  189. 'ignore' => !$add
  190. ),
  191. 'inuse' => array(
  192. 'type' => 'hidden',
  193. 'value' => $inuse,
  194. 'id' => 'inuse',
  195. 'ignore' => $add
  196. ),
  197. 'i' => array(
  198. 'type' => 'hidden',
  199. 'value' => $institution,
  200. 'ignore' => $add
  201. ),
  202. 'displayname' => array(
  203. 'type' => 'text',
  204. 'title' => get_string('institutiondisplayname', 'admin'),
  205. 'defaultvalue' => $data->displayname,
  206. 'rules' => array(
  207. 'required' => true,
  208. 'maxlength' => 255
  209. ),
  210. 'help' => true,
  211. ),
  212. );
  213. if ($USER->get('admin') && $institution != 'mahara') {
  214. $elements['expiry'] = array(
  215. 'type' => 'date',
  216. 'title' => get_string('institutionexpiry', 'admin'),
  217. 'description' => get_string('institutionexpirydescription', 'admin', hsc($sitename)),
  218. 'defaultvalue' => is_null($data->expiry) ? null : strtotime($data->expiry),
  219. 'help' => true,
  220. 'minyear' => date('Y') - 2,
  221. 'maxyear' => date('Y') + 10,
  222. );
  223. }
  224. if ($USER->get('admin')) {
  225. $elements['authplugin'] = array(
  226. 'type' => 'authlist',
  227. 'title' => get_string('authplugin', 'admin'),
  228. 'options' => $authinstances,
  229. 'authtypes' => $authtypes,
  230. 'instancearray' => $instancearray,
  231. 'instancestring' => $instancestring,
  232. 'institution' => $institution,
  233. 'help' => true,
  234. 'ignore' => count($authtypes) == 0 || $institution == ''
  235. );
  236. }
  237. if (!$add && empty($authinstances)) {
  238. if ($USER->get('admin')) {
  239. $SESSION->add_error_msg(get_string('adminnoauthpluginforinstitution', 'admin'));
  240. }
  241. else {
  242. $SESSION->add_error_msg(get_string('noauthpluginforinstitution', 'admin'));
  243. }
  244. }
  245. if (!get_config('usersuniquebyusername')) {
  246. $elements['registerallowed'] = array(
  247. 'type' => 'checkbox',
  248. 'title' => get_string('registrationallowed', 'admin'),
  249. 'description' => get_string('registrationalloweddescription2', 'admin'),
  250. 'defaultvalue' => $data->registerallowed,
  251. 'help' => true,
  252. );
  253. }
  254. if (empty($data->name) || $data->name != 'mahara') {
  255. $elements['defaultmembershipperiod'] = array(
  256. 'type' => 'expiry',
  257. 'title' => get_string('defaultmembershipperiod', 'admin'),
  258. 'description' => get_string('defaultmembershipperioddescription', 'admin'),
  259. 'defaultvalue' => $data->defaultmembershipperiod,
  260. 'help' => true,
  261. );
  262. $elements['theme'] = array(
  263. 'type' => 'select',
  264. 'title' => get_string('theme'),
  265. 'description' => get_string('sitethemedescription','admin'),
  266. 'defaultvalue' => $data->theme ? $data->theme : 'sitedefault',
  267. 'collapseifoneoption' => true,
  268. 'options' => $themeoptions,
  269. 'help' => true,
  270. );
  271. if ($USER->get('admin')) {
  272. $elements['maxuseraccounts'] = array(
  273. 'type' => 'text',
  274. 'title' => get_string('maxuseraccounts','admin'),
  275. 'description' => get_string('maxuseraccountsdescription','admin'),
  276. 'defaultvalue' => empty($data->maxuseraccounts) ? '' : $data->maxuseraccounts,
  277. 'rules' => array(
  278. 'regex' => '/^\d*$/',
  279. 'maxlength' => 8,
  280. ),
  281. 'size' => 5,
  282. );
  283. }
  284. }
  285. $elements['lockedfields'] = array(
  286. 'type' => 'fieldset',
  287. 'legend' => get_string('Lockedfields', 'admin'),
  288. 'collapsible' => true,
  289. 'collapsed' => true,
  290. 'elements' => array(),
  291. );
  292. if ($institution != 'mahara') {
  293. $elements['lockedfields']['elements']['description'] = array(
  294. 'type' => 'html',
  295. 'value' => get_string('disabledlockedfieldhelp', 'admin', get_field('institution', 'displayname', 'name', 'mahara')),
  296. );
  297. }
  298. foreach (ArtefactTypeProfile::get_all_fields() as $field => $type) {
  299. $elements['lockedfields']['elements'][$field] = array(
  300. 'type' => 'checkbox',
  301. 'title' => get_string($field, 'artefact.internal'),
  302. 'defaultvalue' => in_array($field, $lockedprofilefields) || ($institution != 'mahara' && in_array($field, $sitelockedfields)),
  303. 'disabled' => $institution != 'mahara' && in_array($field, $sitelockedfields)
  304. );
  305. }
  306. $elements['lockedfieldshelp'] = array(
  307. 'value' => '<tr id="lockedfieldshelp"><th colspan="2">'
  308. . get_help_icon('core', 'admin', 'institution', 'lockedfields')
  309. . '</th></tr>'
  310. );
  311. $elements['submit'] = array(
  312. 'type' => 'submitcancel',
  313. 'value' => array(get_string('submit'), get_string('cancel'))
  314. );
  315. $institutionform = pieform(array(
  316. 'name' => 'institution',
  317. 'renderer' => 'table',
  318. 'plugintype' => 'core',
  319. 'pluginname' => 'admin',
  320. 'elements' => $elements
  321. ));
  322. }
  323. else {
  324. // Get a list of institutions
  325. require_once(get_config('libroot') . 'institution.php');
  326. if (!$USER->get('admin')) { // Filter the list for institutional admins
  327. $filter = $USER->get('admininstitutions');
  328. $showdefault = false;
  329. }
  330. else {
  331. $filter = false;
  332. $showdefault = true;
  333. }
  334. $data = build_institutions_html($filter, $showdefault, $query, $limit, $offset, $count);
  335. $smarty = smarty(array('lib/pieforms/static/core/pieforms.js', 'paginator'));
  336. $smarty->assign('results', $data);
  337. $smarty->assign('countinstitutions', $count);
  338. /*search institution form*/
  339. $searchform = pieform(array(
  340. 'name' => 'search',
  341. 'renderer' => 'oneline',
  342. 'elements' => array(
  343. 'query' => array(
  344. 'type' => 'text',
  345. 'defaultvalue' => $query
  346. ),
  347. 'submit' => array(
  348. 'type' => 'submit',
  349. 'value' => get_string('search')
  350. )
  351. )
  352. ));
  353. $smarty->assign('searchform', $searchform);
  354. $js = <<< EOF
  355. addLoadEvent(function () {
  356. p = {$data['pagination_js']}
  357. connect('search_submit', 'onclick', function (event) {
  358. replaceChildNodes('messages');
  359. var params = {'query': $('search_query').value};
  360. p.sendQuery(params);
  361. event.stop();
  362. });
  363. });
  364. EOF;
  365. $smarty->assign('INLINEJAVASCRIPT', $js);
  366. $smarty->assign('siteadmin', $USER->get('admin'));
  367. $smarty->assign('PAGEHEADING', get_string('admininstitutions', 'admin'));
  368. $smarty->display('admin/users/institutions.tpl');
  369. exit;
  370. }
  371. function institution_validate(Pieform $form, $values) {
  372. if (!empty($values['name']) && !$form->get_error('name') && record_exists('institution', 'name', $values['name'])) {
  373. $form->set_error('name', get_string('institutionnamealreadytaken', 'admin'));
  374. }
  375. }
  376. function institution_submit(Pieform $form, $values) {
  377. global $SESSION, $institution, $add, $instancearray, $USER, $authinstances;
  378. db_begin();
  379. // Update the basic institution record...
  380. $newinstitution = new StdClass;
  381. if ($add) {
  382. $institution = $newinstitution->name = strtolower($values['name']);
  383. }
  384. $newinstitution->displayname = $values['displayname'];
  385. $newinstitution->authplugin = empty($values['authplugin']) ? null : $values['authplugin'];
  386. if (get_config('usersuniquebyusername')) {
  387. // Registering absolutely not allowed when this setting is on, it's a
  388. // security risk. See the documentation for the usersuniquebyusername
  389. // setting for more information
  390. $newinstitution->registerallowed = 0;
  391. }
  392. else {
  393. $newinstitution->registerallowed = ($values['registerallowed']) ? 1 : 0;
  394. }
  395. $newinstitution->theme = (empty($values['theme']) || $values['theme'] == 'sitedefault') ? null : $values['theme'];
  396. if ($institution != 'mahara') {
  397. $newinstitution->defaultmembershipperiod = ($values['defaultmembershipperiod']) ? intval($values['defaultmembershipperiod']) : null;
  398. if ($USER->get('admin')) {
  399. $newinstitution->maxuseraccounts = ($values['maxuseraccounts']) ? intval($values['maxuseraccounts']) : null;
  400. $newinstitution->expiry = db_format_timestamp($values['expiry']);
  401. }
  402. }
  403. if (!empty($values['authplugin'])) {
  404. $allinstances = array_merge($values['authplugin']['instancearray'], $values['authplugin']['deletearray']);
  405. if (array_diff($allinstances, $instancearray)) {
  406. throw new ConfigException('Attempt to delete or update another institution\'s auth instance');
  407. }
  408. if (array_diff($instancearray, $allinstances)) {
  409. throw new ConfigException('One of your instances is unaccounted for in this transaction');
  410. }
  411. foreach($values['authplugin']['instancearray'] as $priority => $instanceid) {
  412. if (in_array($instanceid, $values['authplugin']['deletearray'])) {
  413. // Should never happen:
  414. throw new SystemException('Attempt to update AND delete an auth instance');
  415. }
  416. $record = new StdClass;
  417. $record->priority = $priority;
  418. $record->id = $instanceid;
  419. update_record('auth_instance', $record, array('id' => $instanceid));
  420. }
  421. foreach($values['authplugin']['deletearray'] as $instanceid) {
  422. // If this authinstance is the only xmlrpc authinstance that references a host, delete the host record.
  423. $hostwwwroot = null;
  424. foreach ($authinstances as $ai) {
  425. if ($ai->id == $instanceid && $ai->authname == 'xmlrpc') {
  426. $hostwwwroot = get_field_sql("SELECT \"value\" FROM {auth_instance_config} WHERE \"instance\" = ? AND field = 'wwwroot'", array($instanceid));
  427. if ($hostwwwroot && count_records_select('auth_instance_config', "field = 'wwwroot' AND \"value\" = ?", array($hostwwwroot)) == 1) {
  428. // Unfortunately, it's possible that this host record could belong to a different institution,
  429. // so specify the institution here.
  430. delete_records('host', 'wwwroot', $hostwwwroot, 'institution', $institution);
  431. // We really need to fix this, either by removing the institution from the host table, or refusing to allow the
  432. // institution to be changed in the host record when another institution's authinstance is still pointing at it.
  433. }
  434. break;
  435. }
  436. }
  437. delete_records('auth_remote_user', 'authinstance', $instanceid);
  438. delete_records('auth_instance_config', 'instance', $instanceid);
  439. delete_records('auth_instance', 'id', $instanceid);
  440. }
  441. }
  442. if ($add) {
  443. insert_record('institution', $newinstitution);
  444. // If registration has been turned on, then we automatically insert an
  445. // internal authentication authinstance
  446. if ($newinstitution->registerallowed) {
  447. $authinstance = (object)array(
  448. 'instancename' => 'internal',
  449. 'priority' => 0,
  450. 'institution' => $newinstitution->name,
  451. 'authname' => 'internal',
  452. );
  453. insert_record('auth_instance', $authinstance);
  454. }
  455. }
  456. else {
  457. $where = new StdClass;
  458. $where->name = $institution;
  459. $oldtheme = get_field('institution', 'theme', 'name', $institution);
  460. update_record('institution', $newinstitution, $where);
  461. }
  462. delete_records('institution_locked_profile_field', 'name', $institution);
  463. foreach (ArtefactTypeProfile::get_all_fields() as $field => $type) {
  464. if ($values[$field]) {
  465. $profilefield = new StdClass;
  466. $profilefield->name = $institution;
  467. $profilefield->profilefield = $field;
  468. insert_record('institution_locked_profile_field', $profilefield);
  469. }
  470. }
  471. db_commit();
  472. if ($add) {
  473. if ($newinstitution->registerallowed) {
  474. // If registration is not allowed, then an authinstance will not
  475. // have been created, and thus cause the institution page to add
  476. // its own error message on the next page load
  477. $SESSION->add_ok_msg(get_string('institutionaddedsuccessfully2', 'admin'));
  478. }
  479. $nexturl = '/admin/users/institutions.php?i='.urlencode($institution);
  480. }
  481. else {
  482. $message = get_string('institutionupdatedsuccessfully', 'admin');
  483. if (isset($values['theme']) && $oldtheme != $values['theme']
  484. && (!empty($oldtheme) || $values['theme'] != 'sitedefault')) {
  485. $USER->update_theme();
  486. $message .= ' ' . get_string('usersseenewthemeonlogin', 'admin');
  487. }
  488. $SESSION->add_ok_msg($message);
  489. $nexturl = '/admin/users/institutions.php';
  490. }
  491. redirect($nexturl);
  492. }
  493. function institution_cancel_submit() {
  494. redirect('/admin/users/institutions.php');
  495. }
  496. if ($institution && $institution != 'mahara') {
  497. $_institution = get_record('institution', 'name', $institution);
  498. $suspended = $_institution->suspended;
  499. if ($USER->get('admin')) {
  500. function institution_suspend_submit(Pieform $form, $values) {
  501. global $SESSION, $USER;
  502. if (!$USER->get('admin')) {
  503. $SESSION->add_error_msg(get_string('errorwhilesuspending', 'admin'));
  504. }
  505. else {
  506. set_field('institution', 'suspended', 1, 'name', $values['i']);
  507. $SESSION->add_ok_msg(get_string('institutionsuspended', 'admin'));
  508. }
  509. redirect('/admin/users/institutions.php?i=' . $values['i']);
  510. }
  511. function institution_unsuspend_submit(Pieform $form, $values) {
  512. global $SESSION, $USER;
  513. if (!$USER->get('admin')) {
  514. $SESSION->add_error_msg(get_string('errorwhileunsuspending', 'admin'));
  515. }
  516. else {
  517. set_field('institution', 'suspended', 0, 'name', $values['i']);
  518. $SESSION->add_ok_msg(get_string('institutionunsuspended', 'admin'));
  519. }
  520. redirect('/admin/users/institutions.php?i=' . $values['i']);
  521. }
  522. // Suspension controls
  523. if (empty($suspended)) {
  524. $suspendformdef = array(
  525. 'name' => 'institution_suspend',
  526. 'plugintype' => 'core',
  527. 'pluginname' => 'admin',
  528. 'elements' => array(
  529. 'i' => array(
  530. 'type' => 'hidden',
  531. 'value' => $institution,
  532. ),
  533. 'submit' => array(
  534. 'type' => 'submit',
  535. 'value' => get_string('suspendinstitution','admin'),
  536. 'description' => get_string('suspendinstitutiondescription','admin'),
  537. ),
  538. )
  539. );
  540. $suspendform = pieform($suspendformdef);
  541. }
  542. else {
  543. $suspendformdef = array(
  544. 'name' => 'institution_unsuspend',
  545. 'plugintype' => 'core',
  546. 'pluginname' => 'admin',
  547. 'elements' => array(
  548. 'i' => array(
  549. 'type' => 'hidden',
  550. 'value' => $institution,
  551. ),
  552. 'submit' => array(
  553. 'type' => 'submit',
  554. 'value' => get_string('unsuspendinstitution','admin'),
  555. 'description' => get_string('unsuspendinstitutiondescription','admin'),
  556. ),
  557. )
  558. );
  559. $suspendform = pieform($suspendformdef);
  560. // Create a second forms for unsuspension to go in the suspend message.
  561. // This keeps the HTML IDs unique
  562. $suspendformdef['name'] = 'institution_unsuspend_top';
  563. $suspendformdef['renderer'] = 'oneline';
  564. $suspendformdef['successcallback'] = 'institution_unsuspend_submit';
  565. $suspendform_top = pieform($suspendformdef);
  566. }
  567. }
  568. }
  569. function search_submit(Pieform $form, $values) {
  570. redirect('/admin/users/institutions.php' . (!empty($values['query']) ? '?query=' . urlencode($values['query']) : ''));
  571. }
  572. $smarty = smarty();
  573. $smarty->assign('institution_form', $institutionform);
  574. $smarty->assign('instancestring', $instancestring);
  575. $smarty->assign('add', $add);
  576. if (isset($suspended)) {
  577. if ($suspended) {
  578. $smarty->assign('suspended', get_string('suspendedinstitutionmessage', 'admin'));
  579. }
  580. if (isset($suspendform)) {
  581. $smarty->assign('suspendform', $suspendform);
  582. if (isset($suspendform_top)) {
  583. $smarty->assign('suspendform_top', $suspendform_top);
  584. }
  585. }
  586. }
  587. $smarty->assign('PAGEHEADING', get_string('admininstitutions', 'admin'));
  588. $smarty->display('admin/users/institutions.tpl');
  589. function theme_sort($a, $b) {
  590. if ($a == 'sitedefault') {
  591. return -1;
  592. }
  593. if ($b == 'sitedefault') {
  594. return 1;
  595. }
  596. return $a > $b;
  597. }
  598. ?>