Source for file sl_setup_notecard.php

Documentation is available at sl_setup_notecard.php

  1. <?php
  2.  
  3.     /**
  4.     * Sloodle configuration notecard generation script.
  5.     *
  6.     * Can be accessed by a Moodle administrator via web-browser to generate text for a configuration notecard.
  7.     *
  8.     * @package sloodle
  9.     * @copyright Copyright (c) 2007-8 Sloodle (various contributors)
  10.     * @license http://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3
  11.     *
  12.     * @contributor Edmund Edgar
  13.     * @contributor Peter R. Bloomfield
  14.     *
  15.     */
  16.  
  17.     /** Sloodle/Moodle configuration */
  18.     require_once('config.php');
  19.     /** General Sloodle functionality */
  20.     require_once(SLOODLE_DIRROOT.'/lib/sl_generallib.php');
  21.  
  22.     $courseid optional_param('courseid',null,PARAM_RAW);
  23.  
  24.     print_header(get_string("cfgnotecard:header""sloodle")''''''false''''false'');
  25.     print_heading(get_string("cfgnotecard:header""sloodle"));
  26.  
  27.     require_login();
  28.     if (isadmin()) {
  29.  
  30.         if ( (sloodle_get_prim_password(== null|| (sloodle_get_prim_password(== '') ) {
  31.     
  32.             $sloodle_pwd = (string)mtrand(100000000,999999999);
  33.             $result sloodle_set_config('sloodle_prim_password',$sloodle_pwd);
  34.  
  35.             if (!$result{
  36.  
  37.                 print get_string("primpass:errornotset""sloodle");
  38.                 exit;
  39.  
  40.             }
  41.         }
  42.  
  43.         if ($courseid == NULL{
  44.  
  45.             print '<h3>'get_string("choosecourse""sloodle".'</h3>';
  46.             print '<p>'get_string("cfgnotecard:choosecourse""sloodle".'</p>';
  47.             print '<form method="post" action="sl_setup_notecard.php">';
  48.             $courses get_courses();
  49.                         // Sort the array of courses by name
  50.                         $sortedcourses array();
  51.                         foreach ($courses as $cid => $c{
  52.                             $sortedcourses[$cid$c->fullname;
  53.                         }
  54.                         asort($sortedcourses);
  55.  
  56.  
  57.             foreach($sortedcourses as $cid => $cname{
  58.                 print '<input type="radio" name="courseid" value="'.$cid.'" />'.$cname;
  59.                 print '<br />';
  60.             }
  61.             print '<br/><input type="submit" value="'get_string("cfgnotecard:generate""sloodle".'" />';
  62.             print '</form>';
  63.  
  64.         else {
  65.  
  66.             sloodle_print_config_notecard($CFG->wwwrootsloodle_get_prim_password()$courseid);
  67.  
  68.         }
  69.  
  70.     else {
  71.  
  72.         print get_string("needadmin""sloodle");;
  73.  
  74.     }
  75.  
  76.     print_footer();
  77.  
  78.     exit;
  79.  
  80.     function sloodle_print_config_notecard($wwwroot,$pwd,$courseid{
  81.         global $CFG;
  82.         print '<div align="center">';
  83.         print '<p>'get_string("cfgnotecard:instructions""sloodle".'</p>';
  84.        print '<p>'get_string("cfgnotecard:security""sloodle".'</p>';
  85.         print '<textarea cols=60 rows=4>';
  86.         print 'set:sloodleserverroot|'.$wwwroot;
  87.         print "\n";
  88.         print 'set:pwd|'.$pwd;
  89.         print "\n";
  90.         print 'set:sloodle_courseid|'.$courseid;
  91.         print "\n";
  92.         print '</textarea>';
  93.         print '<p>'get_string("cfgnotecard:setnote""sloodle".'</p>';
  94.         print '<p><a href="'.$CFG->wwwroot.'/admin/module.php?module=sloodle">'get_string("backtosloodlesetup""sloodle".'</a>.';
  95.         print '</div>';
  96.  
  97.     }
  98.  
  99. ?>

Documentation generated on Tue, 04 Mar 2008 15:08:55 +0000 by phpDocumentor 1.4.0