Source for file object_config.php

Documentation is available at object_config.php

  1. <?php
  2.     /**
  3.     * IBank 1.0 configuration form.
  4.     *
  5.     * This is a fragment of HTML which gives the form elements for configuration of the SLOODLE demo 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.     * The name of each form element becomes the name of a configuration parameter which is passed (via link message) to your scripts in SL.
  11.     * For example, a form element called "sloodlemoduleid" will pass a value to your script in SL called "sloodlemoduleid".
  12.     *
  13.     *
  14.     * @package sloodle
  15.     * @copyright Copyright (c) 2009 Sloodle (various contributors)
  16.     * @license http://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3
  17.     *
  18.     * @contributor Peter R. Bloomfield
  19.     *  @contributor Paul G. Preibisch
  20.     */
  21.     
  22.     // IMPORTANT: make sure this is called from within a Sloodle script
  23.     if (!defined('SLOODLE_VERSION')) {
  24.         error('Not called from within a Sloodle script.');
  25.         exit();
  26.     }
  27.     
  28.     // Execute everything within a function to ensure we don't mess up the data in the other file
  29.     sloodle_display_config_form($sloodleauthid$auth_obj);
  30.     
  31.     
  32.     
  33.     function sloodle_display_config_form($sloodleauthid$auth_obj)
  34.     {
  35.     //--------------------------------------------------------
  36.      // SETUP
  37.         
  38.         // Determine which course is being accessed
  39.         $courseid $auth_obj->course->get_course_id();
  40.         
  41.         // We need to fetch a list of visible distributors on the course
  42.         // Get the ID of the Sloodle type
  43.         $rec get_record('modules''name''sloodle');
  44.         if (!$rec{
  45.             sloodle_debug("Failed to get Sloodle module type.");
  46.             exit();
  47.         }
  48.         
  49.         // Get all visible Sloodle modules in the current course
  50.         $recs get_records_select('course_modules'"course = $courseid AND module = {$rec->id} AND visible = 1");
  51.         if (!is_array($recs)) $recs array();
  52.         $stipendgivers array();
  53.         foreach ($recs as $cm{
  54.             // Fetch the stipendgiver instance
  55.             $inst get_record('sloodle''id'$cm->instance'type'SLOODLE_TYPE_IBANK);
  56.             if (!$instcontinue;
  57.             // Store the stipendgiver details
  58.             $stipendgivers[$cm->id$inst->name;
  59.         }
  60.         // Sort the list by name
  61.         natcasesort($stipendgivers);
  62.     
  63.         //--------------------------------------------------------
  64.     // FORM
  65.     
  66.         // Get the current object configuration
  67.         $settings SloodleController::get_object_configuration($sloodleauthid);
  68.         
  69.         // Setup our default values
  70.         //sloodlemoduleid comes from the mdl_course_modules table and is the id of the actual distributer module
  71.         $sloodlemoduleid = (int)sloodle_get_value($settings'sloodlemoduleid'0);
  72.         $sloodlerefreshtime = (int)sloodle_get_value($settings'sloodlerefreshtime'3600);
  73.  
  74.     
  75.     ///// GENERAL CONFIGURATION /////
  76.         // We will now display the configuration form.
  77.     
  78.         // Create a new section box for general configuration options
  79.         print_box_start('generalbox boxaligncenter');
  80.         echo '<h3>'.get_string('generalconfiguration','sloodle').'</h3>';
  81.          // Ask the user to select an assignment
  82.         echo get_string('stipendgiver:selectstipend','sloodle').': ';
  83.         
  84.         
  85.         choose_from_menu($stipendgivers'sloodlemoduleid'$sloodlemoduleid'');
  86.         echo "<br>\n";
  87.      
  88.     
  89.        
  90.         
  91.       
  92.         // Close the general section
  93.         print_box_end();
  94.         
  95.         
  96.     ///// ACCESS LEVELS /////
  97.         // This is common to nearly all objects, although variations are possible.
  98.         // There are 3 access settings, in two categories:
  99.         //  In-world: use and control
  100.         //  Server: access
  101.         //
  102.         // The in-world 'use' setting determines who can generally use the object, whether it is public, limited to an SL group, or owner-only. (Public by default)
  103.         // The in-world 'control' setting determines who has authority to control the object, which can similarly be public, group, or owner-only. (Owner-only by default)
  104.         // The server access lets you limit usage to avatars which are registered or enrolled, or to members of staff. By default though, it is public.
  105.         //
  106.         // The following function displays the appropriate form data.
  107.         // We pass in the existing settings so that it can setup defaults.
  108.         // The subsequent 3 parameters determine if each type of access setting should be visible, in the order specified above.
  109.         // They are optional, and all default to true if not specified.
  110.     
  111.         sloodle_print_access_level_options($settingstruetruetrue);
  112.         
  113.     }
  114.     
  115. ?>

Documentation generated on Fri, 17 Jul 2009 11:02:18 +0100 by phpDocumentor 1.4.0