Source for file module_ibank.php

Documentation is available at module_ibank.php

  1. <?php
  2.     // This file is part of the Sloodle project (www.sloodle.org)
  3.     
  4.     /**
  5.     * This file defines the Sloodle iBank module.
  6.     *
  7.     * @package sloodle
  8.     * @copyright Copyright (c) 2008 Sloodle (various contributors)
  9.     * @license http://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3
  10.     *
  11.     * @contributor Peter R. Bloomfield
  12.     * @contributor Paul G. Preibisch - aka Fire Centaur
  13.     */
  14.     
  15.     /** The Sloodle module base. */
  16.     require_once(SLOODLE_LIBROOT.'/modules/module_base.php');
  17.     /** General Sloodle functions. */
  18.     require_once(SLOODLE_LIBROOT.'/general.php');
  19.     
  20.     /** SLOODLE course object data structure */
  21.     require_once(SLOODLE_LIBROOT.'/sloodlecourseobject.php');
  22.  
  23.     /** SLOODLE stipendgiver object data structure */
  24.     require_once(SLOODLE_DIRROOT.'/mod/ibank-1.0/stipendgiver_object.php');
  25.     /** Sloodle Session code. */
  26.         
  27.     /**
  28.     * The Sloodle StipendGiver module class.
  29.     * @package sloodle
  30.     */
  31.     class SloodleModuleiBank extends SloodleModule
  32.     {
  33.     // DATA //
  34.     
  35.         /**
  36.         * Internal for Moodle only - course module instance.
  37.         * Corresponds to one record from the Moodle 'course_modules' table.
  38.         * @var object 
  39.         * @access private
  40.         */
  41.         var $cm = null;
  42.     
  43.         /**
  44.         * Internal only - Sloodle module instance database object.
  45.         * Corresponds to one record from the Moodle 'sloodle' table.
  46.         * @var object 
  47.         * @access private
  48.         */
  49.         var $sloodle_module_instance = null;
  50.         
  51.         /**
  52.         * Internal only - Sloodle StipendGiver instance database object.
  53.         * Corresponds to one record from the Moodle 'sloodle_StipendGiver' table.
  54.         * @var object 
  55.         * @access private
  56.         */
  57.         var $sloodle_stipendgiver_instance = null;
  58.         
  59.         var $sCourseObj = null;
  60.         
  61.  
  62.         
  63.         var $sloodleid = null;       
  64.         
  65.     // FUNCTIONS //
  66.     
  67.         /**
  68.         * Constructor
  69.         */
  70.         function SloodleModuleiBank(&$_session)
  71.         {
  72.             $constructor get_parent_class($this);
  73.             parent::$constructor($_session);
  74.         }
  75.         
  76.         /**
  77.         * Loads data from the database.
  78.         * Note: even if the function fails, it may still have overwritten some or all existing data in the object.
  79.         * @param mixed $id The site-wide unique identifier for all modules. Type depends on VLE. On Moodle, it is an integer course module identifier ('id' field of 'course_modules' table)
  80.         * @return bool True if successful, or false otherwise
  81.         */
  82.         function load($id)
  83.         {
  84.             // Make sure the ID is valid
  85.             if (!is_int($id|| $id <= 0return false;
  86.             
  87.             // Fetch the course module data
  88.             if (!($this->cm = get_coursemodule_from_id('sloodle'$id))) return false;
  89.             // Load from the primary table: Sloodle instance
  90.             if (!($this->sloodle_module_instance = get_record('sloodle''id'$this->cm->instance))) return false;
  91.             // Check that it is the correct type
  92.             
  93.             
  94.             
  95.             if ($this->sloodle_module_instance->type != SLOODLE_TYPE_IBANKreturn false;
  96.             
  97.             // Load from the secondary table: StipendGiver instance
  98.             if (!($this->sloodle_StipendGiver_instance get_record('sloodle_stipendgiver''sloodleid'$this->cm->instance))) return false;
  99.             
  100.             return true;
  101.         }
  102.         
  103.         
  104.         /**
  105.         * Gets a list of all objects for this StipendGiver.
  106.         * @return array An array of strings, each string containing the name of an object in this StipendGiver.
  107.         */
  108.         function get_objects()
  109.         {
  110.             // Get all StipendGiver record entries for this StipendGiver
  111.             $recs get_records('sloodle_ipoint_trans''sloodleid'$this->sloodle_StipendGiver_instance->id);
  112.             if (!$recsreturn array();
  113.             // Convert it to an array of strings
  114.             $entries $recs;
  115.             
  116.             
  117.             return $entries;
  118.         }
  119.         
  120.          /**
  121.     * Gets a list of students in the class
  122.     */
  123.       function get_class_list(){
  124.             $fulluserlist get_users(true'');
  125.             if (!$fulluserlist$fulluserlist array();
  126.             $userlist array();
  127.             // Filter it down to members of the course
  128.             foreach ($fulluserlist as $ful{
  129.                 // Is this user on this course?
  130.                 if (has_capability('moodle/course:view'$this->course_context$ful->id)) {
  131.                     // Copy it to our filtered list and exclude administrators
  132.                     if (!isadmin($ful->id))
  133.                       $userlist[$ful;
  134.                 }
  135.             }
  136.             return $userlist;
  137.       
  138.       }
  139.       
  140.       
  141.         /**
  142.         * This attempts to withdraw money.
  143.         * @param array $info is an array which first lists the intent of what the stipend will be used for
  144.         *  the next element is the uuid of the avatar
  145.         * @return bool True if successful, or false if not
  146.         */
  147.                            
  148.         
  149.         
  150.     // ACCESSORS //
  151.     
  152.         /**
  153.         * Gets the name of this module instance.
  154.         * @return string The name of this controller
  155.         */
  156.         function get_name()
  157.         {
  158.             return $this->sloodle_module_instance->name;
  159.         }
  160.         
  161.         /**
  162.         * Gets the intro description of this module instance, if available.
  163.         * @return string The intro description of this controller
  164.         */
  165.         function get_intro()
  166.         {
  167.             return $this->sloodle_module_instance->intro;
  168.         }
  169.         
  170.         /**
  171.         * Gets the identifier of the course this controller belongs to.
  172.         * @return mixed Course identifier. Type depends on VLE. (In Moodle, it will be an integer).
  173.         */
  174.         function get_course_id()
  175.         {
  176.             return (int)$this->sloodle_module_instance->course;
  177.         }
  178.         
  179.         /**
  180.         * Gets the time at which this instance was created, or 0 if unknown.
  181.         * @return int Timestamp
  182.         */
  183.         function get_creation_time()
  184.         {
  185.             return $this->sloodle_module_instance->timecreated;
  186.         }
  187.         function get_amount(){
  188.           return $this->sloodle_StipendGiver_instance->amount;
  189.       }
  190.         
  191.         /**
  192.         * Gets the time at which this instance was last modified, or 0 if unknown.
  193.         * @return int Timestamp
  194.         */
  195.         function get_modification_time()
  196.         {
  197.             return $this->sloodle_module_instance->timemodified;
  198.         }
  199.         
  200.         
  201.         /**
  202.         * Gets the short type name of this instance.
  203.         * @return string 
  204.         */
  205.         function get_type()
  206.         {
  207.             return SLOODLE_TYPE_IBANK;
  208.         }
  209.  
  210.         /**
  211.         * Gets the full type name of this instance, according to the current language pack, if available.
  212.         * Note: should be overridden by sub-classes.
  213.         * @return string Full type name if possible, or the short name otherwise.
  214.         */
  215.         function get_type_full()
  216.         {
  217.             return get_string('moduletype:'.SLOODLE_TYPE_IBANK'sloodle');
  218.         }
  219.  
  220.     }
  221.  
  222.  
  223. ?>

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