Source for file ibank.php

Documentation is available at ibank.php

  1. <?php
  2. /**
  3. * Defines a class for viewing the SLOODLE iBank module in Moodle.
  4. * Derived from the module view base class.
  5. *
  6. @package sloodle
  7. @copyright Copyright (c) 2008 Sloodle (various contributors)
  8. @license http://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3
  9. @see http://slisweb.sjsu.edu/sl/index.php/Sloodle_Stipend_Giver
  10. *
  11. @contributer Paul G. Preibisch - aka Fire Centaur
  12. */
  13.  
  14. /** The base module view class */
  15. require_once(SLOODLE_DIRROOT.'/view/base/base_view_module.php');
  16.        
  17.  /** SLOODLE course data structure */
  18. require_once(SLOODLE_LIBROOT.'/course.php');
  19.  
  20. /** SLOODLE course object data structure */
  21. require_once(SLOODLE_LIBROOT.'/sloodlecourseobject.php');
  22. /** SLOODLE course object data structure */
  23. require_once(SLOODLE_LIBROOT.'/ipointbank_object.php');
  24. /** SLOODLE stipendgiver object data structure */
  25. require_once(SLOODLE_DIRROOT.'/mod/ibank-1.0/stipendgiver_object.php');
  26. /** Sloodle Session code. */
  27. require_once(SLOODLE_LIBROOT.'/sloodle_session.php');
  28.  
  29. /** General Sloodle functionality. */
  30. require_once(SLOODLE_LIBROOT.'/general.php');   
  31.                
  32. /**
  33. * Class for rendering a view of a Distributor module in Moodle.
  34. @package sloodle
  35. */
  36. {
  37.     
  38.     /**
  39.     * SLOODLE course object, retrieved directly from database.
  40.     * @var object 
  41.     * @access private
  42.     */
  43.     var $sloodleCourse = null;
  44.     
  45.     var $renderMessage=null;
  46.     
  47.     /**
  48.     * The result number to start displaying from
  49.     * @var integer 
  50.     * @access private
  51.     */
  52.     var $start = 0;  
  53.     
  54.     /**
  55.     * A List of records of the transactions for this stipend
  56.     * @var Array 
  57.     * @access private
  58.     */   
  59.     var $transactionRecords = null;
  60.     /**
  61.     * A List of all users avatar UUID's who have collected a stipend
  62.     * @var Array 
  63.     * @access private
  64.     */     
  65.     
  66.     var $stipendCollectors_uuidnull;
  67.  
  68.     /**
  69.     * A List of usrs moodle id's who have collected a stipend
  70.     * @var Array 
  71.     * @access private
  72.     */     
  73.     var $stipendCollectors_moodleidnull;
  74.     
  75.     
  76.    /**
  77.    * A List of all the students in this course
  78.    * @var Array 
  79.    * @access private
  80.    */ 
  81.    var $userListnull;
  82.     
  83.    var $initialized=false;        
  84.        /**
  85.     * sloodleId The instance of this moodle module
  86.     * @var bigInt(10) 
  87.     * @access private
  88.     */  
  89.        
  90.    var $sloodleId = null;
  91.    /**
  92.     * session is a dummy session object to be used as a parameter when creating a sloodleUser object
  93.     * @var SloodleSession Object
  94.     * @access private
  95.     */  
  96.        
  97.    var $sessionnull;
  98.    /**
  99.     * @var $iPb a pointer to the iPoint bank object base class;
  100.     */
  101.    var $iPb = null;
  102.    /**
  103.     * @var $sCourseObj - a pointer to the sloodleCourseObject with useful functions to access course data
  104.     */   
  105.    var $sCourseObj = null;
  106.    /**
  107.     * @var $iPts are the number of iPoints
  108.     *   if iPoints were selected as icurrency
  109.     */
  110.    var $iPts = null;
  111.    
  112.    var $showInitForm = false;
  113.    /**
  114.     * @var $icurrency - currency of this stopend - can be Lindens, or iPoints
  115.     */
  116.    var $icurrency
  117.    /**
  118.     * @var $stipendGiverObj - a pointer to the stipendGiverObject with useful functions to access the stipendGiver
  119.     */   
  120.    var $stipendGiverObj = null;
  121.    
  122.      /**
  123.     * The course module instance, retrieved directly from the database (table: course_modules)
  124.     * @var object 
  125.     * @access private
  126.     */
  127.     var $cm = null;
  128.  
  129.     /**
  130.     * The main SLOODLE module instance, retreived directly from the database (table: sloodle)
  131.     * @var object 
  132.     * @access private
  133.     */
  134.     var $sloodle = null;
  135.  
  136.     /**
  137.     * The VLE course object, retrieved directly from the database (table: course)
  138.     * @var object 
  139.     * @access private
  140.     */
  141.     var $course = null;
  142.  
  143.     /**
  144.     * The SLOODLE course object.
  145.     * @var SloodleCourse 
  146.     * @access private
  147.     */
  148.     var $sloodle_course = null;
  149.  
  150.     /**
  151.     * Context object for permissions in the Moodle course.
  152.     * @var object 
  153.     * @access private
  154.     */
  155.     var $course_context = null;
  156.  
  157.     /**
  158.     * Context object for permissions in the Moodle module.
  159.     * @var object 
  160.     * @access private
  161.     */
  162.    /**
  163.     * Constructor.
  164.     * This constructor creates a sloodleCourseObject which gives us useful functions to access course data
  165.     * Also creats a stipendGiver Object which gives us useful functions to access stipendGiver data
  166.     * 
  167.     */
  168.    
  169.     
  170.     function sloodle_view_ibank()    
  171.     {
  172.             
  173.              $sloodleid required_param('id'PARAM_INT);   
  174.              
  175.              //set Sloodle Course Obj - this object will give us things like: userlist of the course, sloodle id etc.
  176.             $this->sCourseObj = new sloodleCourseObj($sloodleid);
  177.             $this->sloodle$this->sCourseObj->sloodleRec;
  178.  
  179.             $this->cm = $this->sCourseObj->cm;
  180.             $this->course = $this->sCourseObj->courseRec;
  181.             $this->course_context = $this->sCourseObj->courseContext;
  182.             
  183.     }
  184.     /**
  185.     * Check that the user has permission to view this module, and check if they can edit it too.
  186.     */
  187.     function check_permission()
  188.     {
  189.         // Make sure the user is logged-in
  190.         require_course_login($this->coursetrue$this->cm);
  191.  
  192.         add_to_log($this->course->id'sloodle''view sloodle module'"view.php?id={$this->cm->id}""{$this->sloodle->id}"$this->cm->id);
  193.         
  194.         // Check for permissions
  195.         $this->module_context = get_context_instance(CONTEXT_MODULE$this->cm->id);
  196.         $this->course_context = get_context_instance(CONTEXT_COURSE$this->course->id);
  197.         if (has_capability('moodle/course:manageactivities'$this->module_context)) $this->canedit = true;
  198.  
  199.         // If the module is hidden, then can the user still view it?
  200.         if (empty($this->cm->visible&& !has_capability('moodle/course:viewhiddenactivities'$this->module_context)) notice(get_string('activityiscurrentlyhidden'));
  201.     }
  202.     
  203.     /**
  204.     * Check and process the request parameters.
  205.     */
  206.     function process_request()
  207.     {
  208.         global $CFG$USER;
  209.     
  210.     
  211.         //====================== Get all course related information
  212.            //coursemodule id
  213.             $sloodleid required_param('id'PARAM_INT);      
  214.             $this->start = optional_param('start'0PARAM_INT);
  215.             $this->sloodleId = $this->sCourseObj->getSloodleId();           
  216.             //get stipendGiver Object (iBank Object)
  217.             $this->stipendGiverObj = new stipendGiverObject($sloodleid);
  218.             if ($this->start < 0$this->start = 0;
  219.             //get icurrency type of points
  220.             $this->icurrency$this->stipendGiverObj->geticurrency();
  221.             //get users in this course
  222.             $this->userList = $this->sCourseObj->getUserList()
  223.  
  224.             
  225.     }
  226.    
  227.     
  228.     /**
  229.     * Process any form data which has been submitted.
  230.     */
  231.     function process_form()
  232.     {        
  233.         //STEP 1 - HAS THE DEFAULT STIPEND AMOUNT BEEN ALLOCATED TO EVERY USER?       
  234.         //======================== creates initial default stipend records for all users 
  235.         //if no transactions exist        
  236.  
  237.         if (!$this->stipendGiverObj->getTransactionRecords()) {
  238.               //create stipend transactions for each student!
  239.               //get student list
  240.                
  241.                //for each user in the class insert a transaction record with following values:
  242.                //avuuid,userid,avname,amount,type,timemodified
  243.              
  244.              foreach ($this->sCourseObj->getUserList(as $u)
  245.              //Ipoints can be various types - ie: real lindens, or just points.                         
  246.                     $iTransaction new stdClass();
  247.                     $iTransaction->userid       $u->id;
  248.                     $iTransaction->sloodleid    $this->stipendGiverObj->getSloodleId();                 
  249.                     $iTransaction->icurrency     $this->stipendGiverObj->geticurrency();
  250.                     $iTransaction->amount       $this->stipendGiverObj->getStartingBalance();
  251.                     $iTransaction->itype "stipend";
  252.                     $iTransaction->timemodified time();
  253.                     $this->stipendGiverObj->makeTransaction($iTransaction);
  254.              }    
  255.            //insert iTransaction into db            
  256.            }
  257.               
  258.         
  259.        //STEP 2 - Transactions exist for this stipend already, check to see if new students have been added
  260.        //========================= HAVE NEW STUDENTS BEEN ADDED 
  261.        else 
  262.        {
  263.            $this->stipendGiverObj->updateUserList($this->sCourseObj->getUserList());
  264.         }
  265.         //============== STEP 3 - CHECK TO SEE IF THERE ARE PENDING UPDATES TO EXISTING STUDENTS
  266.            //check if we need to update allocations 
  267.            //if "update" param exists, that means someone submitted a form using the update butotn in printUserTable function
  268.            $updateoptional_param("update");
  269.             if ($update){
  270.                 
  271.                 //check each allotment value from form, and compare against db. change where necessary
  272.                 $newBudgets=optional_param("newbudgets");
  273.                 $userIds optional_param("userIds");
  274.                 $userNames optional_param("usernames");
  275.                 $currIndex=0;   
  276.                 $updatedRecs Array();
  277.                 $errorString=''
  278.                 foreach ($userIds as $userId{
  279.                     //retreive saved budget for this user from the database
  280.                     $savedBudget $this->stipendGiverObj->getStipendBudget($userId,$this->userList);                    
  281.                     //compare saved budget with the budget submitted in the form field for this user
  282.                    
  283.                     if ((int)$newBudgets[$currIndex!==$savedBudget){
  284.                         //The user has submited a new stipend allotment for this user, because the new budget 
  285.                         //from the form differs from what has been saved in the db.
  286.                         //so we must update the alloted amount in db
  287.                         //STEP 1 First we should check if the user has already withdrawn any stipends
  288.                         $withdrawnAmount 0;
  289.                         $withdrawnAmount $this->stipendGiverObj->getUserDebits($userId,$this->userList);
  290.                         if ($withdrawnAmount $newBudgets[$currIndex]){
  291.                             $errorString "<br>".$userNames[$currIndex]." ".get_string('stipendgiver:alreadywd','stipendgiver'$withdrawnAmount;
  292.                             $errorString =  get_string('stipendgiver:alreadywd2','stipendgiver');
  293.                         }else{
  294.                                 //STEP 2 - get id of transaction to update
  295.                                 $stipendRec $this->stipendGiverObj->getStipendRec($userId);
  296.                                
  297.                                 $transactionUpdate new stdClass();
  298.                                 $transactionUpdate->id=$stipendRec->id;
  299.                                 $transactionUpdate->amount=$newBudgets[$currIndex];                            
  300.                                 $transactionUpdate->timemodifiedtime();
  301.                                 $this->stipendGiverObj->updateTransaction($transactionUpdate);
  302.                                 $updatedRecs[]=$userNames[$currIndex];
  303.                                 
  304.                         }
  305.                     }
  306.                     $currIndex++;     
  307.                     
  308.                 }
  309.                 //create and print confirmation message to the user
  310.                 $confirmedMessage get_string("stipendgiver:successfullupdate","sloodle");
  311.                 $confirmedMessage .= $this->addCommas($updatedRecs);
  312.                 
  313.                 //send confirmation Message
  314.                 $this->setRenderMessage($confirmedMessage $errorString);
  315.                 //updater stipendgier ibank
  316.                 $this->stipendGiverObj->update();
  317.             }
  318.        
  319.        
  320.     
  321.  
  322.  
  323.       /**
  324.     * Override the base_view_module print_header for formatting reasons
  325.     */
  326.     
  327.      function print_header()
  328.     {             
  329.         global $CFG;
  330.  
  331.         // Offer the user an 'update' button if they are allowed to edit the module
  332.         $editbuttons '';
  333.         if ($this->canedit{
  334.             $editbuttons update_module_button($this->cm->id$this->course->idget_string('modulename''sloodle'));
  335.         }
  336.         // Display the header: Sloodle with edit buttons
  337.         $navigation "<a href=\"index.php?{$this->course->id}\">".get_string('modulenameplural','sloodle')."</a> ->";
  338.         print_header_simple(format_string($this->sloodle->name)"""{$navigation} ".format_string($this->sloodle->name""""true$editbuttonsnavmenu($this->course$this->cm)));
  339.  
  340.         // Display the module name: Sloodle StipendGiver
  341.         $img '<img src="'.$CFG->wwwroot.'/mod/sloodle/icon.gif" width="16" height="16" alt=""/> ';
  342.         print_heading($img.$this->sloodle->name'center');
  343.     
  344.         // Display the module type and description
  345.         $fulltypename get_string("moduletype:{$this->sloodle->type}"'sloodle');
  346.         echo '<h4 style="text-align:center;">'.get_string('moduletype''sloodle').': '.$fulltypename;
  347.         echo helpbutton("moduletype_{$this->sloodle->type}"$fulltypename'sloodle'truefalse''true).'</h4>';
  348.     
  349.          
  350.     }   
  351.  
  352.  /**
  353.  * printUserTable function
  354.  * @desc This function will display an HTML table of the users transactions
  355.  *  Columns displayed will be:  UserName | Avatar  |  Amount Alloted  |  Balance Remaining
  356.  * @staticvar null 
  357.  * @param $userData - an array of users
  358.  * @link http://sloodle.googlecode.com
  359.  * @return null 
  360.  */ 
  361.     function printUserTable($userData){        
  362.         global $CFG;
  363.         global $USER;
  364.         $allotedString="";
  365.         
  366.          //===================== Build table with headers, set alignment and width of cells
  367.         //Create HTML table object
  368.         $sloodletable new stdClass();
  369.         //Row Data
  370.         
  371.         //Create Sloodle Table Column Labels
  372.         //User | Avatar  |  Amount Alloted  |  Balance Remaining
  373.         if ($this->icurrency=="Lindens"){      
  374.                          $allotedString get_string('stipendgiver:alloted''sloodle');   
  375.                      }else if ($this->icurrency=="iPoints"){
  376.                         $allotedString get_string('stipendgiver:iPoints''sloodle');    
  377.                          
  378.                      }
  379.             
  380.         if ($this->sCourseObj->is_teacher($USER->id)){        
  381.             $allotedString .=' <input type="submit"';
  382.             $allotedString .=' name="update" ';
  383.             $allotedString .='  value="'.get_string("stipendgiver:update","sloodle".'">';      
  384.         }
  385.         if ($this->icurrency=="Lindens"){
  386.         $sloodletable->head array('',
  387.                                     get_string('stipendgiver:username''sloodle'),
  388.                                   //  get_string('user', 'sloodle'),  
  389.                                     $allotedString,
  390.                                     get_string('stipendgiver:avatars''sloodle'),   
  391.                                     get_string('stipendgiver:debits''sloodle'),   
  392.                                     get_string('stipendgiver:balance''sloodle'));
  393.         }else if ($this->icurrency=="iPoints"){
  394.         $sloodletable->head array('',
  395.                                     get_string('stipendgiver:username''sloodle'),
  396.                                     //get_string('user', 'sloodle'),  
  397.                                     $allotedString,
  398.                                     get_string('stipendgiver:avatars''sloodle'),   
  399.                                     
  400.                                     get_string('stipendgiver:totalipoints''sloodle'));
  401.         }
  402.         //set alignment of table cells                                        
  403.         $sloodletable->align array('left',  'center''left','right','center');
  404.         //set size of table cells
  405.         $sloodletable->size array('2%','15%''5%','45%','3%');
  406.         $avs='';
  407.         $debits='';
  408.         
  409.         $checkBoxId=0
  410.         if (!empty($userData)){
  411.                         
  412.             foreach ($userData as $u){
  413.                  $rowDataArray();  
  414.                 
  415.                 // Construct URLs to this user's Moodle and SLOODLE profile pages
  416.                 $url_moodleprofile $this->sCourseObj->get_moodleUserProfile($u);
  417.                 $url_sloodleprofile $this->sCourseObj->get_sloodleprofile($u);
  418.                 //==========print check box
  419.                 //if ($this->sCourseObj->is_teacher($USER->id)){  
  420.                //     $rowData[]= '<input type="checkbox" id="cb'.$checkBoxId++.' name="cid[]" value="'.$u->id.'" checked>';               
  421.                // }      else
  422.                 $rowData[]='';
  423.                  //==========print hidden user id for form processing
  424.                 $userIdFormElement '<input type="hidden" name="userIds[]" value="'.$u->id.'">';
  425.                 $userIdFormElement .= '<input type="hidden" name="usernames[]" value="'.$u->username.'">';
  426.                 //========= print url link to Moodle name
  427.                 $rowData[]$userIdFormElement "<a href=\"{$url_moodleprofile}\">{$u->firstname} {$u->lastname}</a>";
  428.                 //$rowData[]=  "<a href=\"{$url_moodleprofile}\">{$u->username}</a>"; 
  429.                 // Construct URLs to this user's Moodle and SLOODLE profile pages     
  430.                 // Get the Sloodle data for this Moodle user
  431.                 $ownedAvatars null;;
  432.                 $ownedAvatars get_records('sloodle_users''userid'$u->id,'avname DESC','userid,uuid,avname');                        
  433.                 //=========*** print stipend amount alloted for this moodle user (Prints 0 if no stipend alloted
  434.                 $editField='';
  435.                 $budget$this->stipendGiverObj->getStipendBudget($u->id,$this->userList);
  436.                 if ($this->sCourseObj->is_teacher($USER->id)){  
  437.                   $editField '<input style="text-align:right;" type="text" size="6" name="newbudgets[]" value="'.$budget.'">';
  438.                 }else  $editField$budget;
  439.                 $rowData[]=$editField;
  440.                 
  441.                 //========= print names of avatars this moodle user has, and the amount's they've withdrawn and the dates
  442.                     //===== build inner Avatar names table
  443.                        
  444.                         //===== BUILD Avatar table if user has avatars
  445.                             //initialize Av table data;
  446.                                      
  447.                             //if this user has an avatar associated with the accound
  448.                             $userAvatar=null;
  449.                             $avs='';  
  450.                             $debits=''
  451.                             if ($ownedAvatars{
  452.                                
  453.                                
  454.                                 foreach ($ownedAvatars as $userAvatar{
  455.                               
  456.                                  
  457.                                    // If this entry is empty, then skip it
  458.                                     if (empty($userAvatar->avname|| ctype_space($userAvatar->avname)) {
  459.                               
  460.                                          continue;
  461.                                     }
  462.                                     // ========= print avatar name 
  463.                                     $avs "<a href=\"{$url_sloodleprofile}\">{$userAvatar->avname}</a><br>";
  464.                                     //========== print amount withdrawn by this avatar
  465.                                         //search transactions to see if this user made a debit and return amount. If they havent withdrew any, 0 will be returned
  466.                                     $debits .= $this->stipendGiverObj->getAvatarDebits($userAvatar->uuid"<br>";
  467.                                 }
  468.                                 
  469.                                 
  470.                             }else
  471.                          //======= build an empty avatars names table if no avatars                     
  472.                                  //Build Avatar names table
  473.                                  //even though this user has no avatars associated with account, check to see if transactions                     
  474.                                  $transAmount=$this->stipendGiverObj->getUserDebits($u->id);
  475.                                  //have been made with this moodle user id.                     
  476.                                if ($transAmount>0){
  477.                                      //if they have, notify teacher that transaction has been made
  478.                                      //search transaction records and find out which avatar was used
  479.                                      $transRecs $this->stipendGiverObj->getTransactionRecords($u->id);                                      
  480.                                      $deletedAvsArray();                                    
  481.                                      if($transRecs)
  482.                                         foreach ($transRecs as $t){
  483.                                             if ($u->id == $t->userid)
  484.                                                 $deletedAvs[]=$t->avname;
  485.                                             
  486.                                             }
  487.                                      //print avs that made transactions, but no longer are registered to this user
  488.                                     $avs$this->addCommas($deletedAvs);
  489.                                  else {
  490.                                      
  491.                                      $debits $transAmount;
  492.                                      $avs get_string('stipendgiver:noneregistered','sloodle');
  493.                                  }
  494.                                
  495.                                }
  496.                                 
  497.                      //========= now print Inner AvTable
  498.                      //add the collective RowData to inner avTable that will sit in this cell of the bigger user html table
  499.                                              //now place this inner avTable inside the bigger user html table 
  500.                      // the "true" in print_table($table,true) returns the html rather than print it
  501.                      $rowData[]$avs;
  502.                      if ($this->icurrency=="Lindens"){      
  503.                          $rowData[]$debits;
  504.                      }           
  505.                      $rowData[]$this->stipendGiverObj->getStipendBudget($u->id,$this->userList$this->stipendGiverObj->getUserDebits($u->id);
  506.                       //===== NOW print the actual User table                 
  507.                       $sloodletable->data[$rowData;
  508.                 
  509.             }
  510.             print ('<form action="" method="POST">');
  511.             print_table($sloodletable);  
  512.             print('</form>');  
  513.         }  
  514.   
  515.           
  516.                
  517.             
  518.     }  
  519.    
  520.             
  521.       
  522.     /**
  523.     * Render the view of the Stipend Giver.
  524.     */
  525.     function render()              
  526.     {
  527.         global $CFG$USER;   
  528.         $this->courseid $this->course->id
  529.         $sloodleid=$this->sloodle->id;
  530.     
  531.         // Print a Table Intro / Amount  / Purpose 
  532.         // of Stipend        
  533.         print_box_start('generalbox boxaligncenter boxwidthnormal leftpara')
  534.             $iTable new stdClass();
  535.             $iRow array();            
  536.             //********* PRINT DESCRIPTION
  537.             print('<b style="color:Black;text-align:left;">'.get_string('stipendgiver:description','sloodle').':</b>'.$this->sloodle->intro.'<br> ');             
  538.             if ($this->icurrency=="Lindens"){      
  539.                  $iRow[='<b style="color:green;text-align:left;">'.get_string('stipendgiver:totalallocations','sloodle').'</b>:';
  540.                  $iRow[]=$this->stipendGiverObj->getStipendBudget(null,$this->userList." "$this->stipendGiverObj->geticurrency();
  541.             }else if ($this->icurrency=="iPoints"){
  542.                     $iRow[='<b style="color:green;text-align:left;">'.get_string('stipendgiver:totalawarded','sloodle').'</b>:';
  543.                      $iRow[]=$this->stipendGiverObj->getStipendBudget(null,$this->userList." "$this->stipendGiverObj->geticurrency();
  544.             }           
  545.             $iTable->data[$iRow;
  546.             //********* PRINT TOTAL DEBITS
  547.             if ($this->icurrency=="Lindens"){      
  548.                 $iRow array();            
  549.                             $iRow[='<b style="color:red;text-align:left;">'.get_string('stipendgiver:totaldebits','sloodle').'</b>:&nbsp&nbsp';
  550.                 $iRow[=$this->stipendGiverObj->getUserDebits(" ".$this->stipendGiverObj->geticurrency();
  551.                 $iTable->data[$iRow;    
  552.                 //********* PRINT STARTING BALANCE
  553.                 $iRow array();                        
  554.                 $iRow[='<b style="color:blue;text-align:left;">'.get_string('stipendgiver:startingbalance','sloodle').'</b>:&nbsp&nbsp';
  555.                 $iRow[=$this->stipendGiverObj->getStartingBalance(." "$this->stipendGiverObj->geticurrency();
  556.                 $iTable->data[$iRow;
  557.                 $iRow array();             
  558.             }    
  559.             
  560.             print_table($iTable);
  561.             
  562.         print_box_end();      
  563.         //==================================================================================================================
  564.        
  565.        if ($this->getRenderMessage()){
  566.         print_box_start('generalbox boxaligncenter boxwidthnarrow leftpara')
  567.             print ($this->getRenderMessage());
  568.         print_box_end();
  569.        }
  570.        
  571.        
  572.        //print_box_start('generalbox boxaligncenter boxwidthnarrow leftpara'); 
  573.             //======Print TRANSACTIONS TITLE
  574.   if ($this->icurrency=="Lindens"){      
  575.                           print('<h3 style="color:black;text-align:center;">'.get_string('stipendgiver:transactions','sloodle')).'</h3> ';
  576.           
  577.                      }else if ($this->icurrency=="iPoints"){
  578.             print('<h3 style="color:black;text-align:center;">'.get_string('stipendgiver:scoreboard','sloodle')).'</h3> ';
  579.           
  580.                          
  581.                      }           
  582.            
  583.             //======Print STUDENT TRANSACTIONS
  584.              
  585.             if ($this->sCourseObj->getUserList()){
  586.             
  587.                 $this->printUserTable($this->sCourseObj->getUserList());
  588.             }
  589.             else print "no student transaction";
  590.             
  591.         //==================================================================================================================
  592.            
  593.              //  $this->destroy();        
  594.         
  595.      
  596.     }
  597.     
  598.  
  599.  
  600.  
  601.  
  602.  
  603.   /**
  604.  * addCommas takes an array of strings and add commas between elements except at the last element, or if there is only one element
  605.  * @param array $arrList 
  606.  * @return string 
  607.  */ 
  608.  function addCommas($arrList){
  609.      $runTwice=false;  //for the comma to print correctly
  610.      $newList '';
  611.      foreach ($arrList as $arr){
  612.          
  613.          if ($runTwice$newList.=",";
  614.          $runTwice true;
  615.          $newList .=$arr
  616.      }
  617.      return $newList;
  618.  
  619.  
  620.  }  
  621.   
  622.  /**
  623.  * buildAvTable function
  624.  * @desc Simply sets up the inner avatar table, alignment, and sizes
  625.  * @staticvar object $avTable 
  626.  * @param null 
  627.  * @link http://sloodle.googlecode.com
  628.  * @return object 
  629.  */ 
  630.  function buildAvTable(){
  631.  //create inter avatar table
  632.         $avTable new stdClass();        
  633.         $avTable->align array('left','right');
  634.         $avTable->size array('70%','30%');
  635.         $avTable->data null;
  636.    return $avTable;
  637.  
  638.  }  
  639.  
  640.  function setRenderMessage($str){
  641.     $this->renderMessage=$str;
  642.     
  643.  }
  644.  function getRenderMessage(){
  645.     return $this->renderMessage;
  646.  }
  647.  
  648. function destroy(){
  649.     //debugging only
  650.                       //test file to access db and play with forms
  651.         $dbtype  'mysql';
  652.         $dbhost    'localhost';
  653.         $dbname    'eslteach_moodle';
  654.         $dbuser    'eslteach_moodle';
  655.         $dbpass    'evkingmoodle555';
  656.           
  657.           //connect to db
  658.           $con mysql_connect("localhost",$dbuser,$dbpass);
  659.         if (!$con)
  660.           {
  661.           die('Could not connect: ' mysql_error());
  662.           }
  663.           //use databse
  664.           mysql_select_db($dbname);
  665.           
  666.         $result mysql_query("TRUNCATE TABLE `mdl_sloodle_stipendgiver_trans`");
  667.                
  668.  
  669.         mysql_close($con);    
  670.     
  671.     
  672. }
  673.  
  674.           
  675. ?>

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