Changeset 139

Show
Ignore:
Timestamp:
08/23/10 20:55:35 (18 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

Location:
trunk
Files:
6 added
8 modified

Legend:

Unmodified
Added
Removed
  • trunk/actions/delete_educourse.php

    r83 r139  
    99    $educourse = get_entity($guid); 
    1010 
    11     if ($educourse->getSubtype() == 'educourse' && $educourse->canEdit() && edufeedrCanEditEducourse($educourse)) { 
     11    if ($educourse->getSubtype() == 'educourse' && $educourse->canEdit() && edufeedrCanManageEducourse($educourse)) { 
    1212        $rowsaffected = $educourse->delete(); 
    1313        if ($rowsaffected > 0) { 
  • 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?> 
  • trunk/edufeedr_tables.sql

    r93 r139  
    2727        PRIMARY KEY (id) 
    2828) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
     29 
     30CREATE TABLE IF NOT EXISTS prefix_edufeedr_course_facilitators ( 
     31        id bigint(20) unsigned NOT NULL auto_increment, 
     32        course_guid bigint(20) unsigned NOT NULL, 
     33        user_guid bigint(20) unsigned NOT NULL, 
     34        PRIMARY KEY (id) 
     35) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
  • trunk/languages/en.php

    r135 r139  
    77        File: /edufeedr/views/default/edufeedr/educourse_hidden.php 
    88        File: /edufeedr/views/default/edufeedr/educourse_hidden.php 
    9         Lines: 22, 33 
     9        Lines: 23, 35 
    1010        Text: restore 
    1111        _missing_translation_ 
     
    5757        /*  
    5858        File: /edufeedr/actions/unhide_comment.php 
    59         Lines: 21 
     59        Lines: 22 
    6060        Text: Comment could not be restored. 
    6161        _missing_translation_ 
     
    7373        /*  
    7474        File: /edufeedr/actions/unhide_comment.php 
    75         Lines: 18 
     75        Lines: 19 
    7676        Text: Comment restored. 
    7777        _missing_translation_ 
     
    145145        /*  
    146146        File: /edufeedr/api.php 
    147         Lines: 269 
     147        Lines: 278 
    148148        Text: Entered URL has no feed. 
    149149        _missing_translation_ 
     
    194194        File: /edufeedr/actions/remove_assignment.php 
    195195        File: /edufeedr/actions/remove_participant.php 
    196         Lines: 325, 52, 78, 96, 55, 97, 79, 61, 24, 26 
     196        Lines: 334, 52, 78, 96, 55, 97, 79, 61, 24, 26 
    197197        Text: Error occured, object could not be sent to EduSuckr. 
    198198        _missing_translation_ 
     
    210210        /*  
    211211        File: /edufeedr/views/default/edufeedr/educourse_post.php 
    212         File: /edufeedr/views/default/edufeedr/edufeedr_hidden.php 
    213         Lines: 31, 31 
     212        Lines: 31 
    214213        Text: %s comments 
    215214        _missing_translation_ 
     
    228227         
    229228        /*  
     229        File: /edufeedr/views/default/edufeedr/educourse_facilitators.php 
     230        Lines: 78 
     231        Text: Add 
     232        _missing_translation_ 
     233        */ 
     234        "edufeedr:href:button:add" => "Add", 
     235         
     236        /*  
    230237        File: /edufeedr/views/default/edufeedr/forms/edit_assignment.php 
    231238        Lines: 32 
     
    314321        File: /edufeedr/views/default/edufeedr/educourse_post.php 
    315322        File: /edufeedr/views/default/edufeedr/educourse_post.php 
    316         File: /edufeedr/views/default/edufeedr/edufeedr_hidden.php 
    317         File: /edufeedr/views/default/edufeedr/edufeedr_hidden.php 
    318         Lines: 60, 103, 24, 40, 24, 40 
     323        Lines: 60, 103, 24, 40 
    319324        Text: hide 
    320325        _missing_translation_ 
     
    400405        File: /edufeedr/views/default/edufeedr/educourse_hidden.php 
    401406        File: /edufeedr/views/default/edufeedr/educourse_post.php 
    402         File: /edufeedr/views/default/edufeedr/edufeedr_hidden.php 
    403         Lines: 49, 20, 18, 18 
     407        Lines: 49, 21, 18 
    404408        Text: %s by %s 
    405409        _missing_translation_ 
     
    438442        */ 
    439443        "edufeedr:course:edit:participant" => "Edit participant", 
     444         
     445        /*  
     446        File: /edufeedr/views/default/edufeedr/educourse_facilitators.php 
     447        Lines: 75 
     448        Text: Type the username of another user to add and additional facilitator to this course. 
     449        _missing_translation_ 
     450        */ 
     451        "edufeedr:text:add_facilitator" => "Type the username of another user to add and additional facilitator to this course.", 
    440452         
    441453        /*  
     
    486498        /*  
    487499        File: /edufeedr/views/default/edufeedr/educourse_post.php 
    488         File: /edufeedr/views/default/edufeedr/edufeedr_hidden.php 
    489         Lines: 49, 49 
     500        Lines: 49 
    490501        Text: Post a comment 
    491502        _missing_translation_ 
     
    573584        /*  
    574585        File: /edufeedr/api.php 
    575         Lines: 293 
     586        Lines: 302 
    576587        Text: Post not found in blog RSS. 
    577588        _missing_translation_ 
     
    669680         
    670681        /*  
     682        File: /edufeedr/views/default/edufeedr/educourse_facilitators.php 
     683        Lines: 20 
     684        Text: Facilitators 
     685        _missing_translation_ 
     686        */ 
     687        "edufeedr:label:course_facilitators" => "Facilitators", 
     688         
     689        /*  
    671690        File: /edufeedr/join_educourse.php 
    672691        Lines: 20 
     
    694713        /*  
    695714        File: /edufeedr/actions/unhide_post.php 
    696         Lines: 18 
     715        Lines: 19 
    697716        Text: Post restored. 
    698717        _missing_translation_ 
     
    881900        /*  
    882901        File: /edufeedr/api.php 
    883         Lines: 248 
     902        Lines: 257 
    884903        Text: Entered URL does not exist. 
    885904        _missing_translation_ 
     
    942961        /*  
    943962        File: /edufeedr/actions/unhide_post.php 
    944         Lines: 21 
     963        Lines: 22 
    945964        Text: Post could not be restored. 
    946965        _missing_translation_ 
  • trunk/languages/et.php

    r135 r139  
    77        File: /edufeedr/views/default/edufeedr/educourse_hidden.php 
    88        File: /edufeedr/views/default/edufeedr/educourse_hidden.php 
    9         Lines: 22, 33 
     9        Lines: 23, 35 
    1010        Text: restore 
    1111        _missing_translation_ 
     
    5757        /*  
    5858        File: /edufeedr/actions/unhide_comment.php 
    59         Lines: 21 
     59        Lines: 22 
    6060        Text: Comment could not be restored. 
    6161        _missing_translation_ 
     
    7373        /*  
    7474        File: /edufeedr/actions/unhide_comment.php 
    75         Lines: 18 
     75        Lines: 19 
    7676        Text: Comment restored. 
    7777        _missing_translation_ 
     
    145145        /*  
    146146        File: /edufeedr/api.php 
    147         Lines: 269 
     147        Lines: 278 
    148148        Text: Entered URL has no feed. 
    149149        _missing_translation_ 
     
    194194        File: /edufeedr/actions/remove_assignment.php 
    195195        File: /edufeedr/actions/remove_participant.php 
    196         Lines: 325, 52, 78, 96, 55, 97, 79, 61, 24, 26 
     196        Lines: 334, 52, 78, 96, 55, 97, 79, 61, 24, 26 
    197197        Text: Error occured, object could not be sent to EduSuckr. 
    198198        _missing_translation_ 
     
    210210        /*  
    211211        File: /edufeedr/views/default/edufeedr/educourse_post.php 
    212         File: /edufeedr/views/default/edufeedr/edufeedr_hidden.php 
    213         Lines: 31, 31 
     212        Lines: 31 
    214213        Text: %s comments 
    215214        _missing_translation_ 
     
    228227         
    229228        /*  
     229        File: /edufeedr/views/default/edufeedr/educourse_facilitators.php 
     230        Lines: 78 
     231        Text: Add 
     232        _missing_translation_ 
     233        */ 
     234        "edufeedr:href:button:add" => "Add", 
     235         
     236        /*  
    230237        File: /edufeedr/views/default/edufeedr/forms/edit_assignment.php 
    231238        Lines: 32 
     
    314321        File: /edufeedr/views/default/edufeedr/educourse_post.php 
    315322        File: /edufeedr/views/default/edufeedr/educourse_post.php 
    316         File: /edufeedr/views/default/edufeedr/edufeedr_hidden.php 
    317         File: /edufeedr/views/default/edufeedr/edufeedr_hidden.php 
    318         Lines: 60, 103, 24, 40, 24, 40 
     323        Lines: 60, 103, 24, 40 
    319324        Text: hide 
    320325        _missing_translation_ 
     
    400405        File: /edufeedr/views/default/edufeedr/educourse_hidden.php 
    401406        File: /edufeedr/views/default/edufeedr/educourse_post.php 
    402         File: /edufeedr/views/default/edufeedr/edufeedr_hidden.php 
    403         Lines: 49, 20, 18, 18 
     407        Lines: 49, 21, 18 
    404408        Text: %s by %s 
    405409        _missing_translation_ 
     
    438442        */ 
    439443        "edufeedr:course:edit:participant" => "Edit participant", 
     444         
     445        /*  
     446        File: /edufeedr/views/default/edufeedr/educourse_facilitators.php 
     447        Lines: 75 
     448        Text: Type the username of another user to add and additional facilitator to this course. 
     449        _missing_translation_ 
     450        */ 
     451        "edufeedr:text:add_facilitator" => "Type the username of another user to add and additional facilitator to this course.", 
    440452         
    441453        /*  
     
    486498        /*  
    487499        File: /edufeedr/views/default/edufeedr/educourse_post.php 
    488         File: /edufeedr/views/default/edufeedr/edufeedr_hidden.php 
    489         Lines: 49, 49 
     500        Lines: 49 
    490501        Text: Post a comment 
    491502        _missing_translation_ 
     
    573584        /*  
    574585        File: /edufeedr/api.php 
    575         Lines: 293 
     586        Lines: 302 
    576587        Text: Post not found in blog RSS. 
    577588        _missing_translation_ 
     
    669680         
    670681        /*  
     682        File: /edufeedr/views/default/edufeedr/educourse_facilitators.php 
     683        Lines: 20 
     684        Text: Facilitators 
     685        _missing_translation_ 
     686        */ 
     687        "edufeedr:label:course_facilitators" => "Facilitators", 
     688         
     689        /*  
    671690        File: /edufeedr/join_educourse.php 
    672691        Lines: 20 
     
    694713        /*  
    695714        File: /edufeedr/actions/unhide_post.php 
    696         Lines: 18 
     715        Lines: 19 
    697716        Text: Post restored. 
    698717        _missing_translation_ 
     
    881900        /*  
    882901        File: /edufeedr/api.php 
    883         Lines: 248 
     902        Lines: 257 
    884903        Text: Entered URL does not exist. 
    885904        _missing_translation_ 
     
    942961        /*  
    943962        File: /edufeedr/actions/unhide_post.php 
    944         Lines: 21 
     963        Lines: 22 
    945964        Text: Post could not be restored. 
    946965        _missing_translation_ 
  • trunk/start.php

    r137 r139  
    170170        register_action('edufeedr/unhide_post', false, $CONFIG->pluginspath . 'edufeedr/actions/unhide_post.php'); 
    171171        register_action('edufeedr/unhide_comment', false, $CONFIG->pluginspath . 'edufeedr/actions/unhide_comment.php'); 
     172        register_action('edufeedr/add_facilitator', false, $CONFIG->pluginspath . 'edufeedr/actions/ajax/add_facilitator.php'); 
     173        register_action('edufeedr/remove_facilitator', false, $CONFIG->pluginspath . 'edufeedr/actions/ajax/remove_facilitator.php'); 
    172174?> 
  • trunk/views/default/edufeedr/forms/edit_educourse.php

    r129 r139  
    9191                $course_stop_aggregate_label = elgg_echo('edufeedr:label:educourse_stop_aggregate'); 
    9292                $course_stop_aggregate_input = elgg_view('input/edufeedr_calendar', array('internalname' => 'stop_aggregate', 'value' => $stop_aggregate)); 
     93 
     94                $course_facilitators_input = elgg_view('edufeedr/educourse_facilitators', array('entity' => $vars['entity'], 'type' => 'edit')); 
     95 
    9396                $form_aggregate_edit_addition = <<<EOT 
    9497                <p> 
     
    99102                        <label>$course_stop_aggregate_label</label>$field_required<br /> 
    100103            $course_stop_aggregate_input 
    101         </p> 
     104                </p> 
     105            $course_facilitators_input 
     106         
    102107EOT; 
    103108        } else { 
  • trunk/views/default/object/educourse.php

    r115 r139  
    4848            if ($vars['entity']->canEdit() && edufeedrCanEditEducourse($vars['entity'])) { 
    4949                $body .= '<div id="edufeedr_educourse_action_controls">'; 
    50                 $body .= '<a href="' . $vars['url'] . 'pg/edufeedr/edit_educourse/' . $vars['entity']->getGUID() . '" title="' . elgg_echo('edit') . '"><img src="'. $vars['url'] .'mod/edufeedr/views/default/graphics/edit.png" alt="edit" /></a>'; 
    51                 $body .= '&nbsp;&nbsp;'; 
    52                 $body .= elgg_view('output/edufeedr_confirmlink', array( 
     50                        $body .= '<a href="' . $vars['url'] . 'pg/edufeedr/edit_educourse/' . $vars['entity']->getGUID() . '" title="' . elgg_echo('edit') . '"><img src="'. $vars['url'] .'mod/edufeedr/views/default/graphics/edit.png" alt="edit" /></a>'; 
     51                        if (edufeedrCanManageEducourse($vars['entity'])) { 
     52                        $body .= '&nbsp;&nbsp;'; 
     53                        $body .= elgg_view('output/edufeedr_confirmlink', array( 
    5354                    'href' => $vars['url'] . 'action/edufeedr/delete_educourse?educourse=' . $vars['entity']->getGUID(), 
    5455                                        'text' => elgg_echo('delete'), 
     
    5758                    ) 
    5859                                ); 
     60                        } 
    5961                $body .= '</div>'; 
    6062                } 
    6163 
    6264                // Display teacher 
    63                 $body .= '<div class="edufeedr_course_teachers">'; 
    64                 /*translation:Facilitator*/ 
    65                 $body .= '<label>' . elgg_echo('edufeedr:label:course:facilitator') . ':</label><br />'; 
    66                 $teacher = $vars['entity']->getOwnerEntity(); 
    67                 $body .= $teacher->name . ' / '; 
    68                 $body .= elgg_view('output/email', array('value' => $teacher->email)) . ' / '; 
    69                 $body .= elgg_view('output/url', array('href' => $vars['entity']->course_blog, 'target' => '_blank')); 
    70                 $body .= '</div>'; 
     65                $body .= elgg_view('edufeedr/educourse_facilitators', array('entity' => $vars['entity'], 'type' => 'view')); 
    7166 
    7267                $body .= '</div>';