Changeset 139 for trunk/api.php

Show
Ignore:
Timestamp:
08/23/10 20:55:35 (21 months ago)
Author:
gnum
Message:

References #96, facilitators can now be added to course. Still need to check it all again and see if everything is working well. NB! This will require additional table declared in edufeedr_tables.sql

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/api.php

    r138 r139  
    2020                if (isadminloggedin()) 
    2121                        return true; 
    22                 else if (isloggedin() && $educourse->getSubtype() == 'educourse' && $educourse->getOwner() == get_loggedin_userid()) 
    23                         return true; 
    24  
     22                else if (isloggedin() && $educourse->getSubtype() == 'educourse' && ($educourse->getOwner() == get_loggedin_userid() || edufeedrIsFacilitator($educourse))) 
     23                        return true; 
     24 
     25                return false; 
     26        } 
     27 
     28        function edufeedrCanManageEducourse($educourse) { 
     29                if (isadminloggedin()) { 
     30                        return true; 
     31                } else if (isloggedin() && $educourse->getSubtype() == 'educourse' && $educourse->getOwner()== get_loggedin_userid()) { 
     32                        return true; 
     33                } 
    2534                return false; 
    2635        } 
     
    361370                return get_data_row("SELECT * FROM {$CONFIG->dbprefix}edufeedr_course_assignments WHERE course_guid = $course_guid and id = $assignment_id"); 
    362371        } 
     372 
     373        function edufeedrCourseFacilitators($educourse) { 
     374                global $CONFIG; 
     375                if ($educourse && $educourse->getSubtype() == 'educourse') { 
     376                        return get_data("SELECT * FROM {$CONFIG->dbprefix}edufeedr_course_facilitators WHERE course_guid = {$educourse->getGUID()}"); 
     377                } 
     378                return false; 
     379        } 
     380 
     381        function edufeedrIsFacilitator($educourse) { 
     382                global $CONFIG; 
     383                if ($educourse && $educourse->getSubtype() == 'educourse') { 
     384                        $current_user_guid = get_loggedin_userid(); 
     385                        $is_facilitator = get_data_row("SELECT id FROM {$CONFIG->dbprefix}edufeedr_course_facilitators WHERE course_guid = {$educourse->getGUID()} and user_guid=$current_user_guid"); 
     386                        if ($is_facilitator) { 
     387                                return true; 
     388                        } 
     389                } 
     390                return false; 
     391        } 
    363392?>