Source for file object_config.php

Documentation is available at object_config.php

  1. <?php
  2.     /**
  3.     * Distributor 1.0 configuration form.
  4.     *
  5.     * This is a fragment of HTML which gives the form elements for configuration of a distribution object, v1.0.
  6.     * ONLY the basic form elements should be included.
  7.     * The "form" tags and submit button are already specified outside.
  8.     * The $auth_obj and $sloodleauthid variables will identify the object being configured.
  9.     *
  10.     * @package sloodledistributor
  11.     * @copyright Copyright (c) 2007-8 Sloodle (various contributors)
  12.     * @license http://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3
  13.     *
  14.     * @contributor Peter R. Bloomfield
  15.     *
  16.     */
  17.     
  18.     // IMPORTANT: make sure this is called from within a Sloodle script
  19.     if (!defined('SLOODLE_VERSION')) {
  20.         error('Not called from within a Sloodle script.');
  21.         exit();
  22.     }
  23.     
  24.     // Execute everything within a function to ensure we don't mess up the data in the other file
  25.     sloodle_display_config_form($sloodleauthid$auth_obj);
  26.     
  27.     
  28.     
  29.     function sloodle_display_config_form($sloodleauthid$auth_obj)
  30.     {
  31.     //--------------------------------------------------------
  32.     // SETUP
  33.         
  34.         // Determine which course is being accessed
  35.         $courseid $auth_obj->course->get_course_id();
  36.         
  37.         // We need to fetch a list of visible distributors on the course
  38.         // Get the ID of the Sloodle type
  39.         $rec get_record('modules''name''sloodle');
  40.         if (!$rec{
  41.             sloodle_debug("Failed to get Sloodle module type.");
  42.             exit();
  43.         }
  44.         
  45.         // Get all visible Sloodle modules in the current course
  46.         $recs get_records_select('course_modules'"course = $courseid AND module = {$rec->id} AND visible = 1");
  47.         if (!is_array($recs)) $recs array();
  48.         $distributors array();
  49.         foreach ($recs as $cm{
  50.             // Fetch the distributor instance
  51.             $inst get_record('sloodle''id'$cm->instance'type'SLOODLE_TYPE_DISTRIB);
  52.             if (!$instcontinue;
  53.             // Store the distributor details
  54.             $distributors[$cm->id$inst->name;
  55.         }
  56.         // Sort the list by name
  57.         natcasesort($distributors);
  58.         
  59.     //--------------------------------------------------------
  60.     // FORM
  61.     
  62.         // Get the current object configuration
  63.         $settings SloodleController::get_object_configuration($sloodleauthid);
  64.         
  65.         // Setup our default values
  66.         $sloodlemoduleid = (int)sloodle_get_value($settings'sloodlemoduleid'0);
  67.         $sloodlerefreshtime = (int)sloodle_get_value($settings'sloodlerefreshtime'3600);
  68.  
  69.     
  70.     ///// GENERAL CONFIGURATION /////
  71.         print_box_start('generalbox boxaligncenter');
  72.         echo '<h3>'.get_string('generalconfiguration','sloodle').'</h3>';
  73.         
  74.         // Ask the user to select a distributor
  75.         echo get_string('selectdistributor','sloodle').': ';
  76.         choose_from_menu($distributors'sloodlemoduleid'$sloodlemoduleid'<i>('.get_string('nodistributorinterface','sloodle').')</i>'''0);
  77.         echo "<br><br>\n";
  78.         
  79.         // Ask the user for a refresh period (# seconds between automatic updates)
  80.         echo get_string('refreshtimeseconds','sloodle').': ';
  81.         echo '<input type="text" name="sloodlerefreshtime" value="'.$sloodlerefreshtime.'" size="8" maxlength="8" />';
  82.         echo "<br><br>\n";
  83.         
  84.         print_box_end();
  85.         
  86.         
  87.     ///// ACCESS LEVELS /////
  88.         // There is no need for server access controls, as users cannot access the server through the object
  89.         // (server access is entirely done through Moodle for this one)
  90.         sloodle_print_access_level_options($settingstruetruefalse);
  91.         
  92.     }
  93.     
  94. ?>

Documentation generated on Mon, 07 Jul 2008 12:33:07 +0100 by phpDocumentor 1.4.0