Ejemplo n.º 1
0
 public function index()
 {
     if (logged_in()) {
         if (user_group('admin')) {
             $this->ag_auth->view('admin/dashboard');
         } else {
             $this->ag_auth->view('home');
         }
     } else {
         $this->logout();
     }
 }
Ejemplo n.º 2
0
/**
 * TODO document
 */
function forum_print_post(&$post, $courseid, $ownpost = false, $reply = false, $link = false, $ratings = NULL, $footer = "", $highlight = "", $post_read = -99)
{
    global $USER, $CFG, $SESSION;
    static $stredit, $strdelete, $strreply, $strparent, $strprune;
    static $strpruneheading, $threadedmode;
    static $strmarkread, $strmarkunread, $istracked;
    $discussion = get_record('forum_discussions', 'id', $post->discussion);
    if (!($cm = get_coursemodule_from_instance('forum', $discussion->forum))) {
        error('Course Module ID was incorrect');
    }
    $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
    if (!forum_user_can_see_post($post->forum, $post->discussion, $post)) {
        if (empty($SESSION->forum_search)) {
            // just viewing, return
            return;
        }
        echo '<a id="p' . $post->id . '"></a>';
        echo '<table cellspacing="0" class="forumpost">';
        echo '<tr class="header"><td class="picture left">';
        //        print_user_picture($post->userid, $courseid, $post->picture);
        echo '</td>';
        if ($post->parent) {
            echo '<td class="topic">';
        } else {
            echo '<td class="topic starter">';
        }
        echo '<div class="subject">' . get_string('forumsubjecthidden', 'forum') . '</div>';
        echo '<div class="author">';
        print_string('forumauthorhidden', 'forum');
        echo '</div></td></tr>';
        echo '<tr><td class="left side">';
        echo '&nbsp;';
        // Actual content
        echo '</td><td class="content">' . "\n";
        echo get_string('forumbodyhidden', 'forum');
        echo '</td></tr></table>';
        return;
    }
    if (empty($stredit)) {
        $stredit = get_string('edit', 'forum');
        $strdelete = get_string('delete', 'forum');
        $strreply = get_string('reply', 'forum');
        $strparent = get_string('parent', 'forum');
        $strpruneheading = get_string('pruneheading', 'forum');
        $strprune = get_string('prune', 'forum');
        $threadedmode = (!empty($USER->mode) and $USER->mode == FORUM_MODE_THREADED);
        $strmarkread = get_string('markread', 'forum');
        $strmarkunread = get_string('markunread', 'forum');
        if (!empty($post->forum)) {
            $istracked = forum_tp_can_track_forums($post->forum) && forum_tp_is_tracked($post->forum);
        } else {
            $istracked = false;
        }
    }
    if ($istracked) {
        if ($post_read == -99) {
            // If we don't know yet...
            // The front page can display a news item post to non-logged in users. This should
            // always appear as 'read'.
            $post_read = empty($USER) || forum_tp_is_post_read($USER->id, $post);
        }
        if ($post_read) {
            $read_style = ' read';
        } else {
            $read_style = ' unread';
            echo '<a name="unread"></a>';
        }
    } else {
        $read_style = '';
    }
    echo '<a id="p' . $post->id . '"></a>';
    echo '<table cellspacing="0" class="forumpost' . $read_style . '">';
    echo '<tr class="header"><td class="picture left">';
    print_user_picture($post->userid, $courseid, $post->picture);
    echo '</td>';
    if ($post->parent) {
        echo '<td class="topic">';
    } else {
        echo '<td class="topic starter">';
    }
    echo '<div class="subject">' . format_string($post->subject) . '</div>';
    echo '<div class="author">';
    $fullname = fullname($post, has_capability('moodle/site:viewfullnames', $modcontext));
    $by->name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $post->userid . '&amp;course=' . $courseid . '">' . $fullname . '</a>';
    $by->date = userdate($post->modified);
    print_string('bynameondate', 'forum', $by);
    echo '</div></td></tr>';
    echo '<tr><td class="left side">';
    if ($group = user_group($courseid, $post->userid)) {
        print_group_picture($group, $courseid, false, false, true);
    } else {
        echo '&nbsp;';
    }
    // Actual content
    echo '</td><td class="content">' . "\n";
    if ($post->attachment) {
        $post->course = $courseid;
        $post->forum = get_field('forum_discussions', 'forum', 'id', $post->discussion);
        echo '<div class="attachments">';
        $attachedimages = forum_print_attachments($post);
        echo '</div>';
    } else {
        $attachedimages = '';
    }
    $options = new Object();
    $options->para = false;
    $options->trusttext = true;
    if ($link and strlen(strip_tags($post->message)) > $CFG->forum_longpost) {
        // Print shortened version
        echo format_text(forum_shorten_post($post->message), $post->format, $options, $courseid);
        $numwords = count_words(strip_tags($post->message));
        echo '<p><a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '">';
        echo get_string('readtherest', 'forum');
        echo '</a> (' . get_string('numwords', '', $numwords) . ')...</p>';
    } else {
        // Print whole message
        if ($highlight) {
            echo highlight($highlight, format_text($post->message, $post->format, $options, $courseid));
        } else {
            echo format_text($post->message, $post->format, $options, $courseid);
        }
        echo $attachedimages;
    }
    // Commands
    $commands = array();
    if ($istracked) {
        // SPECIAL CASE: The front page can display a news item post to non-logged in users.
        // Don't display the mark read / unread controls in this case.
        if ($CFG->forum_usermarksread && !empty($USER)) {
            if ($post_read) {
                $mcmd = '&amp;mark=unread&amp;postid=' . $post->id;
                $mtxt = $strmarkunread;
            } else {
                $mcmd = '&amp;mark=read&amp;postid=' . $post->id;
                $mtxt = $strmarkread;
            }
            if ($threadedmode) {
                $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '&amp;parent=' . $post->id . $mcmd . '">' . $mtxt . '</a>';
            } else {
                $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . $mcmd . '#p' . $post->id . '">' . $mtxt . '</a>';
            }
        }
    }
    if ($post->parent) {
        if ($threadedmode) {
            $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '&amp;parent=' . $post->parent . '">' . $strparent . '</a>';
        } else {
            $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '#p' . $post->parent . '">' . $strparent . '</a>';
        }
    }
    $forumtype = get_field('forum', 'type', 'id', $post->forum);
    $age = time() - $post->created;
    // Hack for allow to edit news posts those are not displayed yet until they are displayed
    if (!$post->parent && $forumtype == 'news' && get_field_sql("SELECT id FROM {$CFG->prefix}forum_discussions WHERE id = {$post->discussion} AND timestart > " . time())) {
        $age = 0;
    }
    $editanypost = has_capability('mod/forum:editanypost', $modcontext);
    if ($ownpost or $editanypost) {
        if ($age < $CFG->maxeditingtime or $editanypost) {
            $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/post.php?edit=' . $post->id . '">' . $stredit . '</a>';
        }
    }
    if (has_capability('mod/forum:splitdiscussions', $modcontext) && $post->parent && $forumtype != 'single') {
        $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/post.php?prune=' . $post->id . '" title="' . $strpruneheading . '">' . $strprune . '</a>';
    }
    if ($ownpost and $age < $CFG->maxeditingtime and has_capability('mod/forum:deleteownpost', $modcontext) or has_capability('mod/forum:deleteanypost', $modcontext)) {
        $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/post.php?delete=' . $post->id . '">' . $strdelete . '</a>';
    }
    if ($reply) {
        $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/post.php?reply=' . $post->id . '">' . $strreply . '</a>';
    }
    echo '<div class="commands">';
    echo implode(' | ', $commands);
    echo '</div>';
    // Ratings
    $ratingsmenuused = false;
    if (!empty($ratings) and !empty($USER->id)) {
        echo '<div class="ratings">';
        $useratings = true;
        if ($ratings->assesstimestart and $ratings->assesstimefinish) {
            if ($post->created < $ratings->assesstimestart or $post->created > $ratings->assesstimefinish) {
                $useratings = false;
            }
        }
        if ($useratings) {
            $mypost = $USER->id == $post->userid;
            $canviewallratings = has_capability('mod/forum:viewanyrating', $modcontext);
            if ($canviewallratings and !$mypost) {
                forum_print_ratings_mean($post->id, $ratings->scale, $canviewallratings);
                if (!empty($ratings->allow)) {
                    echo '&nbsp;';
                    forum_print_rating_menu($post->id, $USER->id, $ratings->scale);
                    $ratingsmenuused = true;
                }
            } else {
                if ($mypost) {
                    forum_print_ratings_mean($post->id, $ratings->scale, true);
                } else {
                    if (!empty($ratings->allow)) {
                        forum_print_rating_menu($post->id, $USER->id, $ratings->scale);
                        $ratingsmenuused = true;
                    }
                }
            }
        }
        echo '</div>';
    }
    // Link to post if required
    if ($link) {
        echo '<div class="link">';
        if ($post->replies == 1) {
            $replystring = get_string('repliesone', 'forum', $post->replies);
        } else {
            $replystring = get_string('repliesmany', 'forum', $post->replies);
        }
        echo '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '">' . get_string('discussthistopic', 'forum') . '</a>&nbsp;(' . $replystring . ')';
        echo '</div>';
    }
    if ($footer) {
        echo '<div class="footer">' . $footer . '</div>';
    }
    echo '</td></tr></table>' . "\n\n";
    if ($istracked && !$CFG->forum_usermarksread && !empty($post->forum)) {
        forum_tp_mark_post_read($USER->id, $post, $post->forum);
    }
    return $ratingsmenuused;
}
Ejemplo n.º 3
0
/**
 * Checks to see if a user can view the blogs of another user.
 * Only blog level is checked here, the capabilities are enforced
 * in blog/index.php
 */
function blog_user_can_view_user_post($targetuserid, $blogEntry = null)
{
    global $CFG, $USER;
    if (empty($CFG->bloglevel)) {
        return false;
        // blog system disabled
    }
    if (!empty($USER->id) and $USER->id == $targetuserid) {
        return true;
        // can view own posts in any case
    }
    $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
    if (has_capability('moodle/blog:manageentries', $sitecontext)) {
        return true;
        // can manage all posts
    }
    // coming for 1 post, make sure it's not a draft
    if ($blogEntry and $blogEntry->publishstate == 'draft') {
        return false;
        // can not view draft of others
    }
    // coming for 1 post, make sure user is logged in, if not a public blog
    if ($blogEntry && $blogEntry->publishstate != 'public' && !isloggedin()) {
        return false;
    }
    switch ($CFG->bloglevel) {
        case BLOG_GLOBAL_LEVEL:
            return true;
            break;
        case BLOG_SITE_LEVEL:
            if (!empty($USER->id)) {
                // not logged in viewers forbidden
                return true;
            }
            return false;
            break;
        case BLOG_COURSE_LEVEL:
            $mycourses = array_keys(get_my_courses($USER->id));
            $usercourses = array_keys(get_my_courses($targetuserid));
            $shared = array_intersect($mycourses, $usercourses);
            if (!empty($shared)) {
                return true;
            }
            return false;
            break;
        case BLOG_GROUP_LEVEL:
            $mycourses = array_keys(get_my_courses($USER->id));
            $usercourses = array_keys(get_my_courses($targetuserid));
            $shared = array_intersect($mycourses, $usercourses);
            foreach ($shared as $courseid) {
                $coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);
                if (has_capability('moodle/site:accessallgroups', $coursecontext) or groupmode($courseid) != SEPARATEGROUPS) {
                    return true;
                } else {
                    if ($usergroups = user_group($courseid, $targetuserid)) {
                        foreach ($usergroups as $usergroup) {
                            if (ismember($usergroup->id)) {
                                return true;
                            }
                        }
                    }
                }
            }
            return false;
            break;
        case BLOG_USER_LEVEL:
        default:
            $personalcontext = get_context_instance(CONTEXT_USER, $targetuserid);
            return has_capability('moodle/user:readuserblogs', $personalcontext);
            break;
    }
}
Ejemplo n.º 4
0
 } else {
     add_to_log($course->id, "mumiemodule", "view grades", "view.php?f={$forum->id}", "{$mumiemodule->id}");
 }
 /// Now we need a menu for separategroups as well!
 if ($groupmode == VISIBLEGROUPS || $groupmode && has_capability('moodle/site:accessallgroups', $context)) {
     if ($groups = get_groups($course->id)) {
         print_box_start('groupmenu');
         print_group_menu($groups, $groupmode, $currentgroup, "{$CFG->wwwroot}/mod/mumiemodule/view.php?id={$cm->id}");
         print_box_end();
         // groupmenu
     }
 } else {
     if ($groupmode == SEPARATEGROUPS) {
         $validgroups = array();
         // Get all the groups this guy is in in this course
         if ($p = user_group($course->id, $USER->id)) {
             /// Extract the name and id for the group
             foreach ($p as $index => $object) {
                 $validgroups[$object->id] = $object->name;
             }
             /// Print them in the menu
             print_box_start('groupmenu');
             print_group_menu($validgroups, $groupmode, $currentgroup, "view.php?id={$cm->id}", 0);
             print_box_end();
             // groupmenu
         }
     }
 }
 echo '<br />';
 if (!empty($showall)) {
     show_grades($currentgroup, $cm, $course, $mumiemodule);
Ejemplo n.º 5
0
/**
 * Print a selection box for groups
 * * modified from forum module
 **/
function nanogong_print_groups($modid, $course, $groupmode, $groupid)
{
    global $USER;
    $context = get_context_instance(CONTEXT_MODULE, $modid);
    /// Now we need a menu for separategroups as well!
    if ($groupmode == VISIBLEGROUPS || $groupmode && has_capability('moodle/site:accessallgroups', $context)) {
        if ($groups = get_records_menu("groups", "courseid", $course->id, "name ASC", "id,name")) {
            ?>
    <form>
    <table cellpadding="2" cellspacing="0" border="0">
    <tr>
        <td>Please select the group:</td>
        <td>
            <select id="groupid" name="groupid" onchange="this.form.submit()">
<?php 
            if ($groupmode && has_capability('moodle/site:accessallgroups', $context)) {
                if ($groupid == 0) {
                    print "<option value=\"0\" selected>" . get_string('allparticipants') . "</option>";
                } else {
                    print "<option value=\"0\">" . get_string('allparticipants') . "</option>";
                }
            }
            foreach ($groups as $key => $value) {
                if ($key == $groupid) {
                    print "<option value=\"" . $key . "\" selected>";
                } else {
                    print "<option value=\"" . $key . "\">";
                }
                p($value);
                print "</option>";
            }
            ?>
            </select></td>
    </tr>
    </table>
    <input id="id" name="id" type="hidden" value="<?php 
            p($modid);
            ?>
" />
    </form>
<?php 
        }
    } else {
        if ($groupmode == SEPARATEGROUPS) {
            if (($groups = user_group($course->id, $USER->id)) && count($groups) > 1) {
                /// Extract the name and id for the group
                ?>
    <form>
    <table cellpadding="2" cellspacing="0" border="0">
    <tr>
        <td>Please select the group:</td>
        <td>
            <select id="groupid" name="groupid" onchange="this.form.submit()">
<?php 
                foreach ($groups as $group) {
                    if ($group->id == $groupid) {
                        print "<option value=\"" . $group->id . "\" selected>";
                    } else {
                        print "<option value=\"" . $group->id . "\">";
                    }
                    p($group->name);
                    print "</option>";
                }
                ?>
            </select></td>
    </tr>
    </table>
    <input id="id" name="id" type="hidden" value="<?php 
                p($modid);
                ?>
" />
    </form>
<?php 
            }
        }
    }
}
Ejemplo n.º 6
0
function lightboxgallery_print_comment($comment, $context)
{
    global $CFG, $COURSE;
    $user = get_record('user', 'id', $comment->userid);
    echo '<table cellspacing="0" width="50%" class="boxaligncenter datacomment forumpost">';
    echo '<tr class="header"><td class="picture left">' . print_user_picture($user, $COURSE->id, $user->picture, 0, true) . '</td>';
    echo '<td class="topic starter" align="left"><a name="c' . $comment->id . '"></a><div class="author">';
    echo '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&amp;course=' . $COURSE->id . '">' . fullname($user, has_capability('moodle/site:viewfullnames', $context)) . '</a> - ' . userdate($comment->timemodified);
    echo '</div></td></tr>';
    echo '<tr><td class="left side">';
    if ($groups = user_group($COURSE->id, $user->id)) {
        print_group_picture($groups, $COURSE->id, false, false, true);
    } else {
        echo '&nbsp;';
    }
    echo '</td><td class="content" align="left">';
    echo format_text($comment->comment, FORMAT_MOODLE);
    echo '<div class="commands">';
    if (has_capability('mod/lightboxgallery:edit', $context)) {
        echo '<a href="' . $CFG->wwwroot . '/mod/lightboxgallery/comment.php?id=' . $comment->gallery . '&amp;delete=' . $comment->id . '">' . get_string('delete') . '</a>';
    }
    echo '</div>';
    echo '</td></tr></table>';
}
Ejemplo n.º 7
0
if (!isset($hiddenfields['lastaccess'])) {
    if ($user->lastaccess) {
        $datestring = userdate($user->lastaccess) . "&nbsp; (" . format_time(time() - $user->lastaccess) . ")";
    } else {
        $datestring = get_string("never");
    }
    print_row(get_string("lastaccess") . ":", $datestring);
}
/// printing roles
if ($rolestring = get_user_roles_in_context($id, $coursecontext)) {
    print_row(get_string('roles') . ':', format_string($rolestring, false));
}
/// Printing groups
$isseparategroups = ($course->groupmode == SEPARATEGROUPS and $course->groupmodeforce and !has_capability('moodle/site:accessallgroups', $coursecontext));
if (!$isseparategroups) {
    if ($usergroups = user_group($course->id, $user->id)) {
        $groupstr = '';
        foreach ($usergroups as $group) {
            $groupstr .= ' <a href="' . $CFG->wwwroot . '/user/index.php?id=' . $course->id . '&amp;group=' . $group->id . '">' . $group->name . '</a>,';
        }
        print_row(get_string("group") . ":", rtrim($groupstr, ', '));
    }
}
/// End of printing groups
echo "</table>";
echo "</td></tr></table>";
$userauth = get_auth_plugin($user->auth);
$passwordchangeurl = false;
if ($userauth->can_change_password()) {
    if ($userauth->change_password_url()) {
        $passwordchangeurl = $userauth->change_password_url();
Ejemplo n.º 8
0
/**
 * TODO document
 */
function forum_print_post(&$post, $courseid, $ownpost = false, $reply = false, $link = false, $ratings = NULL, $footer = "", $highlight = "", $post_read = -99)
{
    global $USER, $CFG, $SESSION;
    static $stredit, $strdelete, $strreply, $strparent, $strprune;
    static $strpruneheading, $threadedmode;
    static $strmarkread, $strmarkunread, $istracked;
    if (empty($post->modcontext)) {
        // Have to generate it, which is expensive!  Should always be set.
        if (empty($post->forum)) {
            $discussion = get_record('forum_discussions', 'id', $post->discussion);
            $post->forum = $discussion->forum;
        }
        if (!($cm = get_coursemodule_from_instance('forum', $post->forum))) {
            error('Course Module ID was incorrect');
        }
        $post->modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
    }
    if (!forum_user_can_see_post($post->forum, $post->discussion, $post)) {
        if (empty($SESSION->forum_search)) {
            // just viewing, return
            return;
        }
        echo '<a id="p' . $post->id . '"></a>';
        echo '<table cellspacing="0" class="forumpost">';
        echo '<tr class="header"><td class="picture left">';
        //        print_user_picture($post->userid, $courseid, $post->picture);
        echo '</td>';
        if ($post->parent) {
            echo '<td class="topic">';
        } else {
            echo '<td class="topic starter">';
        }
        echo '<div class="subject">' . get_string('forumsubjecthidden', 'forum') . '</div>';
        echo '<div class="author">';
        print_string('forumauthorhidden', 'forum');
        echo '</div></td></tr>';
        echo '<tr><td class="left side">';
        echo '&nbsp;';
        // Actual content
        echo '</td><td class="content">' . "\n";
        echo get_string('forumbodyhidden', 'forum');
        echo '</td></tr></table>';
        return;
    }
    if (empty($stredit)) {
        $stredit = get_string('edit', 'forum');
        $strdelete = get_string('delete', 'forum');
        $strreply = get_string('reply', 'forum');
        $strparent = get_string('parent', 'forum');
        $strpruneheading = get_string('pruneheading', 'forum');
        $strprune = get_string('prune', 'forum');
        $threadedmode = (!empty($USER->mode) and $USER->mode == FORUM_MODE_THREADED);
        $strmarkread = get_string('markread', 'forum');
        $strmarkunread = get_string('markunread', 'forum');
        if (!empty($post->forum)) {
            $istracked = forum_tp_can_track_forums($post->forum) && forum_tp_is_tracked($post->forum);
        } else {
            $istracked = false;
        }
    }
    if ($istracked) {
        if ($post_read == -99) {
            // If we don't know yet...
            // The front page can display a news item post to non-logged in users. This should
            // always appear as 'read'.
            $post_read = empty($USER) || forum_tp_is_post_read($USER->id, $post);
        }
        if ($post_read) {
            $read_style = ' read';
        } else {
            $read_style = ' unread';
            echo '<a name="unread"></a>';
        }
    } else {
        $read_style = '';
    }
    echo '<a id="p' . $post->id . '"></a>';
    echo '<table cellspacing="0" class="forumpost' . $read_style . ' ' . PM_POST_CLASS . '" id="m' . $post->id . '">';
    // Picture
    $postuser = new object();
    $postuser->id = $post->userid;
    $postuser->firstname = $post->firstname;
    $postuser->lastname = $post->lastname;
    $postuser->imagealt = $post->imagealt;
    $postuser->picture = $post->picture;
    echo '<tr class="header"><td class="picture left">';
    print_user_picture($postuser, $courseid);
    echo '</td>';
    if ($post->parent) {
        echo '<td class="topic" colspan="3">';
    } else {
        echo '<td class="topic starter" colspan="3">';
    }
    echo '<div class="subject ' . PM_TITLE_CLASS . '">' . format_string($post->subject) . '</div>';
    // #GEOF# Annotations must use a unique value for the user ID
    // This should be a string, and it should be human-readable and suitable for
    // outside consumption.  I'm therefore using username rather than ID.
    // If Moodle displayed these values, the fields wouldn'n need to be hidden.
    $rootpath = $CFG->wwwroot;
    //parse_url( $CFG->wwwroot );
    //$rootpath = $rootpath[ 'path' ];
    $refurl = "{$rootpath}/mod/forum/permalink.php?p={$post->id}";
    $discussurl = "{$rootpath}/mod/forum/discuss.php?d={$post->discussion}";
    // used for summary link
    // This class author, used by Marginalia, must preceed the one below, used by Moodle.  (Well, not in Moodle 1.8)
    // Unfortunately I can't use that one - it's marked author but it is not, in fact, the author
    // - it also includes "by", the date, etc.  (grrr) #geof#
    echo "<span style='display:none' class='" . PM_AUTHOR_CLASS . "' title='" . htmlspecialchars($post->username) . "'>" . htmlspecialchars($post->firstname . ' ' . $post->lastname) . "</span>\n";
    echo "<abbr style='display:none' class='" . PM_DATE_CLASS . "' title='" . date('Ymd', $post->modified) . 'T' . date('HiO', $post->modified) . "'></abbr>\n";
    echo "<a style='display:none' rel='" . PM_URL_REL . "' href='{$refurl}'></a>\n";
    echo '<div class="author">';
    $fullname = fullname($post, has_capability('moodle/site:viewfullnames', $post->modcontext));
    $by->name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $post->userid . '&amp;course=' . $courseid . '">' . $fullname . '</a>';
    $by->date = userdate($post->modified);
    // This, I presume, is to localize string display.  Unfortunately it's
    // unstructured text, so I can't insert the necessary <abbr> element with the date.
    // Instead that's done in a hidden tag above.
    print_string('bynameondate', 'forum', $by);
    echo '</div></td></tr>';
    echo '<tr><td class="left side">';
    if ($group = user_group($courseid, $post->userid)) {
        print_group_picture($group, $courseid, false, false, true);
    } else {
        echo '&nbsp;';
    }
    // Actual content
    echo '</td><td class="content ' . PM_CONTENT_CLASS . '" valign="top">' . "\n";
    if ($post->attachment) {
        $post->course = $courseid;
        $post->forum = get_field('forum_discussions', 'forum', 'id', $post->discussion);
        echo '<div class="attachments">';
        $attachedimages = forum_print_attachments($post);
        echo '</div>';
    } else {
        $attachedimages = '';
    }
    $options = new Object();
    $options->para = false;
    $options->trusttext = true;
    if ($link and strlen(strip_tags($post->message)) > $CFG->forum_longpost) {
        // Print shortened version
        echo format_text(forum_shorten_post($post->message), $post->format, $options, $courseid);
        $numwords = count_words(strip_tags($post->message));
        echo '<p><a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '">';
        echo get_string('readtherest', 'forum');
        echo '</a> (' . get_string('numwords', '', $numwords) . ')...</p>';
    } else {
        // Print whole message
        if ($highlight) {
            echo highlight($highlight, format_text($post->message, $post->format, $options, $courseid));
        } else {
            echo format_text($post->message, $post->format, $options, $courseid);
        }
        echo $attachedimages;
    }
    // Commands
    $commands = array();
    if ($istracked) {
        // SPECIAL CASE: The front page can display a news item post to non-logged in users.
        // Don't display the mark read / unread controls in this case.
        if ($CFG->forum_usermarksread && !empty($USER)) {
            if ($post_read) {
                $mcmd = '&amp;mark=unread&amp;postid=' . $post->id;
                $mtxt = $strmarkunread;
            } else {
                $mcmd = '&amp;mark=read&amp;postid=' . $post->id;
                $mtxt = $strmarkread;
            }
            if ($threadedmode) {
                $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '&amp;parent=' . $post->id . $mcmd . '">' . $mtxt . '</a>';
            } else {
                $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . $mcmd . '#p' . $post->id . '">' . $mtxt . '</a>';
            }
        }
    }
    if ($post->parent) {
        if ($threadedmode) {
            $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '&amp;parent=' . $post->parent . '">' . $strparent . '</a>';
        } else {
            $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '#p' . $post->parent . '">' . $strparent . '</a>';
        }
    }
    if (!isset($post->forumtype)) {
        $post->forumtype = get_field('forum', 'type', 'id', $post->forum);
    }
    $age = time() - $post->created;
    // Hack for allow to edit news posts those are not displayed yet until they are displayed
    if (!$post->parent && $post->forumtype == 'news' && get_field_sql("SELECT id FROM {$CFG->prefix}forum_discussions WHERE id = {$post->discussion} AND timestart > " . time())) {
        $age = 0;
    }
    $editanypost = has_capability('mod/forum:editanypost', $post->modcontext);
    if ($ownpost or $editanypost) {
        if ($age < $CFG->maxeditingtime or $editanypost) {
            $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/post.php?edit=' . $post->id . '">' . $stredit . '</a>';
        }
    }
    if (has_capability('mod/forum:splitdiscussions', $post->modcontext) && $post->parent && $post->forumtype != 'single') {
        $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/post.php?prune=' . $post->id . '" title="' . $strpruneheading . '">' . $strprune . '</a>';
    }
    if ($ownpost and $age < $CFG->maxeditingtime and has_capability('mod/forum:deleteownpost', $post->modcontext) or has_capability('mod/forum:deleteanypost', $post->modcontext)) {
        $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/post.php?delete=' . $post->id . '">' . $strdelete . '</a>';
    }
    // The span below is to allow text-decoration:underline, which doesn't seem
    // to work otherwise (Firefox bug?)
    $commands[] = "<button class='smartquote'><span>Quote</span></button>";
    if ($reply) {
        $commands[] = '<a href="' . $CFG->wwwroot . '/mod/forum/post.php?reply=' . $post->id . '">' . $strreply . '</a>';
    }
    echo '<div class="commands">';
    echo implode(' | ', $commands);
    echo '</div>';
    // Ratings
    $ratingsmenuused = false;
    if (!empty($ratings) and !empty($USER->id)) {
        echo '<div class="ratings">';
        $useratings = true;
        if ($ratings->assesstimestart and $ratings->assesstimefinish) {
            if ($post->created < $ratings->assesstimestart or $post->created > $ratings->assesstimefinish) {
                $useratings = false;
            }
        }
        if ($useratings) {
            $mypost = $USER->id == $post->userid;
            $canviewallratings = has_capability('mod/forum:viewanyrating', $post->modcontext);
            if ($canviewallratings and !$mypost) {
                forum_print_ratings_mean($post->id, $ratings->scale, $canviewallratings);
                if (!empty($ratings->allow)) {
                    echo '&nbsp;';
                    forum_print_rating_menu($post->id, $USER->id, $ratings->scale);
                    $ratingsmenuused = true;
                }
            } else {
                if ($mypost) {
                    forum_print_ratings_mean($post->id, $ratings->scale, true);
                } else {
                    if (!empty($ratings->allow)) {
                        forum_print_rating_menu($post->id, $USER->id, $ratings->scale);
                        $ratingsmenuused = true;
                    }
                }
            }
        }
        echo '</div>';
    }
    // Link to post if required
    if ($link) {
        echo '<div class="link">';
        if ($post->replies == 1) {
            $replystring = get_string('repliesone', 'forum', $post->replies);
        } else {
            $replystring = get_string('repliesmany', 'forum', $post->replies);
        }
        echo '<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '">' . get_string('discussthistopic', 'forum') . '</a>&nbsp;(' . $replystring . ')';
        echo '</div>';
    }
    if ($footer) {
        echo '<div class="footer">' . $footer . '</div>';
    }
    //	if ( $canannotate )
    //	{
    echo "</td><td class='control-margin'><div><button type='button' " . " title='" . htmlspecialchars(get_string('create_button', ANNOTATION_STRINGS)) . "'" . " onclick='window.moodleMarginalia.createAnnotation(event,\"m{$post->id}\")'><span>&gt;</span></button></div></td>\n";
    echo "<td class='" . AN_NOTES_CLASS . "' valign='top'><div>";
    echo "<ol></ol>\n";
    echo "</div></td>\n";
    //	}
    //	else
    //		echo "<td></td><td></td>";
    echo '</tr></table>' . "\n\n";
    if ($istracked && !$CFG->forum_usermarksread && !empty($post->forum)) {
        forum_tp_mark_post_read($USER->id, $post, $post->forum);
    }
    return $ratingsmenuused;
}
Ejemplo n.º 9
0
/**
 * A big combination function to make it easier for modules
 * to set up groups.
 *
 * Terminates if the current user shouldn't be looking at this group
 * Otherwise returns the current group if there is one
 * Otherwise returns false if groups aren't relevant
 *
 * @uses SEPARATEGROUPS
 * @uses VISIBLEGROUPS
 * @param course $course A {@link $COURSE} object
 * @param int $groupmode Either NOGROUPS, SEPARATEGROUPS or VISIBLEGROUPS
 * @param string $urlroot ?
 * @return int|false
 */
function setup_and_print_groups($course, $groupmode, $urlroot)
{
    global $USER, $SESSION;
    //needs his id, need to hack his groups in session
    $changegroup = optional_param('group', -1, PARAM_INT);
    $currentgroup = get_and_set_current_group($course, $groupmode, $changegroup);
    if ($currentgroup === false) {
        return false;
    }
    $context = get_context_instance(CONTEXT_COURSE, $course->id);
    if ($groupmode == SEPARATEGROUPS and !$currentgroup and !has_capability('moodle/site:accessallgroups', $context)) {
        //we are in separate groups and the current group is group 0, as last set.
        //this can mean that either, this guy has no group
        //or, this guy just came from a visible all forum, and he left when he set his current group to 0 (show all)
        if ($usergroups = user_group($course->id, $USER->id)) {
            //for the second situation, we need to perform the trick and get him a group.
            $first = reset($usergroups);
            $currentgroup = get_and_set_current_group($course, $groupmode, $first->id);
        } else {
            //else he has no group in this course
            print_heading(get_string('notingroup'));
            print_footer($course);
            exit;
        }
    }
    if ($groupmode == VISIBLEGROUPS or $groupmode and has_capability('moodle/site:accessallgroups', $context)) {
        if ($groups = get_groups($course->id)) {
            echo '<div class="groupselector">';
            print_group_menu($groups, $groupmode, $currentgroup, $urlroot, 1);
            echo '</div>';
        }
    } else {
        if ($groupmode == SEPARATEGROUPS and has_capability('moodle/course:view', $context)) {
            //get all the groups this guy is in in this course
            if ($usergroups = user_group($course->id, $USER->id)) {
                echo '<div class="groupselector">';
                //print them in the menu
                print_group_menu($usergroups, $groupmode, $currentgroup, $urlroot, 0);
                echo '</div>';
            }
        }
    }
    return $currentgroup;
}
Ejemplo n.º 10
0
					
					<li class="dropdown">
					
							<a id="dLabel" data-target="#" href="#" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
								<span class="glyphicon glyphicon-triangle-bottom"></span>
							</a>
								  
							<ul class="dropdown-menu" aria-labelledby="dLabel">
								
								<li>
									<?php 
    if (user_group('user')) {
        //user as student and to be revise(for search how to)
        echo anchor('student/Profile', 'My Profile');
    } else {
        if (user_group('editor')) {
            echo anchor('teacher/Profile', 'My Profile');
        } else {
        }
    }
    ?>
								</li>
								<li><a href="#">Settings</a><li>
								<li><?php 
    echo anchor('logout', 'Logout');
    ?>
</li>
								
							</ul>
						
					</li>
Ejemplo n.º 11
0
 /**
  * Returns a list of teachers that should be grading given submission
  */
 function get_graders($user)
 {
     //potential graders
     $potgraders = get_users_by_capability($this->context, 'mod/assignment:grade', '', '', '', '', '', '', false, false);
     $graders = array();
     if (groupmode($this->course, $this->cm) == SEPARATEGROUPS) {
         // Separate groups are being used
         if ($groups = user_group($this->course->id, $user->id)) {
             // Try to find all groups
             foreach ($groups as $group) {
                 foreach ($potgraders as $t) {
                     if ($t->id == $user->id) {
                         continue;
                         // do not send self
                     }
                     if (groups_is_member($group->id, $t->id)) {
                         $graders[$t->id] = $t;
                     }
                 }
             }
         } else {
             // user not in group, try to find graders without group
             foreach ($potgraders as $t) {
                 if ($t->id == $user->id) {
                     continue;
                     // do not send self
                 }
                 if (!user_group($this->course->id, $t->id)) {
                     //ugly hack
                     $graders[$t->id] = $t;
                 }
             }
         }
     } else {
         foreach ($potgraders as $t) {
             if ($t->id == $user->id) {
                 continue;
                 // do not send self
             }
             $graders[$t->id] = $t;
         }
     }
     return $graders;
 }
Ejemplo n.º 12
0
<ul id="navigation">
<?php 
if (logged_in()) {
    ?>
		<li><?php 
    echo anchor('admin/dashboard', 'Dashboard');
    ?>
</li>
		<li><?php 
    if (user_group('admin')) {
        echo anchor('admin/users/manage', 'Manage Users');
    }
    ?>
</li>
		<li><?php 
    echo anchor('logout', 'Logout');
    ?>
</li>
	<?php 
} else {
    ?>
		<li><?php 
    echo anchor('login', 'Login');
    ?>
</li>
		<li><?php 
    echo anchor('register', 'Register');
    ?>
</li>
	<?php 
}
 /**
  * Alerts teachers by email of new or changed assignments that need grading
  *
  * First checks whether the option to email teachers is set for this assignment.
  * Sends an email to ALL teachers in the course (or in the group if using separate groups).
  * Uses the methods email_teachers_text() and email_teachers_html() to construct the content.
  * @param $submission object The submission that has changed
  */
 function email_teachers($submission)
 {
     global $CFG;
     if (empty($this->emailteachers)) {
         // No need to do anything
         return;
     }
     $user = get_record('user', 'id', $submission->userid);
     if (groupmode($this->course, $this->cm) == SEPARATEGROUPS) {
         // Separate groups are being used
         if ($groups = user_group($this->course->id, $user->id)) {
             // Try to find groups
             $teachers = array();
             foreach ($groups as $group) {
                 $teachers = array_merge($teachers, get_group_teachers($this->course->id, $group->id));
             }
         } else {
             $teachers = get_group_teachers($this->course->id, 0);
             // Works even if not in group
         }
     } else {
         $teachers = get_course_teachers($this->course->id);
     }
     if ($teachers) {
         $strwebquestscorms = get_string('modulenameplural', 'webquestscorm');
         $strwebquestscorm = get_string('modulename', 'webquestscorm');
         $strsubmitted = get_string('submitted', 'webquestscorm');
         foreach ($teachers as $teacher) {
             unset($info);
             $info->username = fullname($user);
             $info->webquestscorm = format_string($this->wqname, true);
             $info->url = $CFG->wwwroot . '/mod/webquestscorm/editsubmissions.php?cmid=' . $this->cm->id . '&element=uploadedTasks&subelement=all';
             $postsubject = $strsubmitted . ': ' . $info->username . ' -> ' . $this->wqname;
             $posttext = $this->email_teachers_text($this->course->shortname, $this->wqname, $strwebquestscorms, $info);
             $posthtml = $teacher->mailformat == 1 ? $this->email_teachers_html($this->course->id, $this->course->shortname, $this->wqname, $strwebquestscorms, $this->cm->id, $info) : '';
             @email_to_user($teacher, $user, $postsubject, $posttext, $posthtml);
             // If it fails, oh well, too bad.
         }
     }
 }
Ejemplo n.º 14
0
function data_print_comment($data, $comment, $page = 0)
{
    global $USER, $CFG;
    $cm = get_coursemodule_from_instance('data', $data->id);
    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
    $stredit = get_string('edit');
    $strdelete = get_string('delete');
    $user = get_record('user', 'id', $comment->userid);
    echo '<table cellspacing="0" align="center" width="50%" class="datacomment forumpost">';
    echo '<tr class="header"><td class="picture left">';
    print_user_picture($comment->userid, $data->course, $user->picture);
    echo '</td>';
    echo '<td class="topic starter" align="left"><div class="author">';
    $fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
    $by = new object();
    $by->name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&amp;course=' . $data->course . '">' . $fullname . '</a>';
    $by->date = userdate($comment->modified);
    print_string('bynameondate', 'data', $by);
    echo '</div></td></tr>';
    echo '<tr><td class="left side">';
    if ($groups = user_group($data->course, $comment->userid)) {
        print_group_picture($groups, $data->course, false, false, true);
    } else {
        echo '&nbsp;';
    }
    /// Actual content
    echo '</td><td class="content" align="left">' . "\n";
    // Print whole message
    echo format_text($comment->content, $comment->format);
    /// Commands
    echo '<div class="commands">';
    if (data_isowner($comment->recordid) or has_capability('mod/data:managecomments', $context)) {
        echo '<a href="' . $CFG->wwwroot . '/mod/data/comment.php?rid=' . $comment->recordid . '&amp;mode=edit&amp;commentid=' . $comment->id . '&amp;page=' . $page . '">' . $stredit . '</a>';
        echo '| <a href="' . $CFG->wwwroot . '/mod/data/comment.php?rid=' . $comment->recordid . '&amp;mode=delete&amp;commentid=' . $comment->id . '&amp;page=' . $page . '">' . $strdelete . '</a>';
    }
    echo '</div>';
    echo '</td></tr></table>' . "\n\n";
}
Ejemplo n.º 15
0
 /** 
  * Log a user in
  *
  * Log a user in a redirect them to a page specified in the $redirect variable
  *
  * @access public
  * @param string
  */
 function login($redirect = NULL)
 {
     if ($redirect === NULL) {
         $redirect = $this->config['auth_login'];
     }
     $this->CI->form_validation->set_rules('username', 'Username', 'trim|required|min_length[4]|max_length[40]|callback_username_check');
     $this->CI->form_validation->set_rules('password', 'Password', 'trim|required|min_length[4]|max_length[12]');
     $this->CI->form_validation->set_rules('remember', 'Remember Me');
     if ($this->CI->form_validation->run() == FALSE) {
         /*
         			if((array_key_exists('login_attempts', $_COOKIE)) && ($_COOKIE['login_attempts'] >= 5))
         			{
         echo $this->CI->lang->line('max_login_attempts_error');
         			}
         			else
         			{
         */
         $data = array('page_title' => 'Inn Strategy - Login');
         $this->CI->load->vars($data);
         $this->view('login');
         //	}
     } else {
         $username = set_value('username');
         $auth_type = $this->_auth_type($username);
         $password = $this->_salt(set_value('password'));
         $email = set_value('email');
         if (!$this->_verify_details($auth_type, $username, $password)) {
             show_error($this->CI->lang->line('login_details_error'));
             $redirect = $this->config['auth_incorrect_login'];
             redirect($redirect);
         }
         $userdata = $this->CI->db->query("SELECT * FROM `{$this->user_table}` WHERE `{$auth_type}` = '{$username}'");
         $row = $userdata->row_array();
         $data = array($auth_type => $username, 'username' => $row['username'], 'user_id' => $row['id'], 'group_id' => $row['group_id'], 'logged_in' => TRUE, 'UserID' => $row['UserID']);
         $this->CI->session->set_userdata($data);
         if ($this->config['auth_remember'] === TRUE) {
             $this->_generate();
         }
         if (user_group('admin') !== TRUE) {
             $redirect .= '/my';
         }
         redirect($redirect);
     }
 }
    if (!($course = get_record("course", "id", $certificate->course))) {
        error("course is misconfigured");
    }
    if (!($cm = get_coursemodule_from_instance("certificate", $certificate->id, $course->id))) {
        error("course Module ID was incorrect");
    }
}
require_login($course->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/certificate:view', $context);
// log update
add_to_log($course->id, "certificate", "view", "view.php?id={$cm->id}", $certificate->id, $cm->id);
// Get teacher name of group
if (groupmode($course, null) == SEPARATEGROUPS) {
    // Separate groups are being used
    if (!($group = user_group($course->id, $USER->id))) {
        // Try to find a group
        $group->id = 0;
        // Not in a group, never mind
    }
    $teachers = get_group_teachers($course->id, $group->id);
    // Works even if not in group
} else {
    $teachers = get_course_teachers($course->id);
}
//Creating pages
$generate = false;
$unenrolment = false;
$type = $certificate->certificatetype;
$certificateid = $certificate->id;
$certrecord = certificate_get_issue($course, $USER, $certificateid);
Ejemplo n.º 17
0
 function index()
 {
     // Set a few globals
     $data = array('page_title' => 'Inn Strategy - Search');
     $query = $this->get_classifications();
     $data['classification'] = $query->result_array();
     $data['class_count'] = $query->num_rows();
     if (user_group('admin') === TRUE) {
         $query = $this->get_price_type();
         $data['price_type'] = $query->result_array();
         $query = $this->get_link_type();
         $data['link_type'] = $query->result_array();
         $query = $this->get_ad_packages();
         $data['ad_package'] = $query->result_array();
         $query = $this->get_state_list();
         $data['states'] = $query->result_array();
     }
     if ($this->uri->segment(2) === 'demo') {
         set_userID('b2cd1871-34e4-4472-a004-1d6dccb0f0a2');
     }
     /*
     		$Website = '';
     		$Classification = '';
     		$PriceType = '';
     		$BBSpecials = '';
     		$UserReview = '';
     		$Google = '';
     		$Yahoo = '';
     		$MSN = '';
     		$Quantified = '';
     		$Rating = '';
     		$State = '';
     		$LinkType = '';
     		$AdPackage = '';
     		$BBCategory = '';
     		$MaxPR = '';
     		$LinkPR = '';
     		$Limited = '';
     		$query = $this->client_select_many($Website, $Classification, $PriceType, $BBSpecials, $UserReview, $Google, $Yahoo, $MSN, $Quantified, $Rating, $State, $LinkType, $AdPackage, $BBCategory, $MaxPR, $LinkPR, $Limited);
     		$data['bbdata'] = $query->result_array();
     */
     $prev_sort_column = isset($_POST['prev_sort_column']) ? $_POST['prev_sort_column'] : "";
     //$this->input->post("prev_sort_column");
     $sort_column = isset($_POST['sort_column']) ? $_POST['sort_column'] : user_group('admin') === TRUE ? "LastUpdated" : "WebSiteText";
     $data['prev_sort_column'] = $sort_column;
     $sort_direction = user_group('admin') === TRUE ? "DESC" : "ASC";
     if ($prev_sort_column == $sort_column) {
         if (isset($_POST['sort_direction']) && $_POST['sort_direction'] == "ASC") {
             $sort_direction = "DESC";
         } else {
             $sort_direction = "ASC";
         }
     }
     $data['sort_direction'] = $sort_direction;
     $Website = isset($_POST['txtSearch']) ? $_POST['txtSearch'] : '';
     $Classification = $this->get_classification_list($data['classification']);
     $PriceType = $this->get_price_selection();
     $BBSpecials = isset($_POST['rblBBSpecials']) ? $_POST['rblBBSpecials'] : '';
     $UserReview = isset($_POST['rblUserReview']) ? $_POST['rblUserReview'] : '';
     $Google = isset($_POST['rblGoogle']) ? $_POST['rblGoogle'] : '';
     $Yahoo = isset($_POST['rblYahoo']) ? $_POST['rblYahoo'] : '';
     $MSN = isset($_POST['rblMSN']) ? $_POST['rblMSN'] : '';
     $Quantified = isset($_POST['rblQuantified']) ? $_POST['rblQuantified'] : '';
     $VacationRental = isset($_POST['rblVacationRental']) ? $_POST['rblVacationRental'] : '';
     $Rating = $this->get_rating();
     $Limited = $this->uri->segment(2) === 'demo';
     $BBCategory = isset($_POST['rblBBCategory']) ? $_POST['rblBBCategory'] : '';
     $AdPackage = isset($_POST['ddAdPackage']) ? $_POST['ddAdPackage'] : '';
     $State = isset($_POST['ddStates']) ? $_POST['ddStates'] : '';
     $LinkType = isset($_POST['ddLinkType']) ? $_POST['ddLinkType'] : '';
     if ($this->uri->total_segments() == 3 && $this->uri->segment(2) !== 'demo') {
         $UserName = $this->uri->segment(3);
     } else {
         $UserName = userID();
     }
     //'13baaeb6-1bba-4bad-8893-3f0bca64e274'; //'b61fc9d0-d42f-4a8d-a8ae-f75042c1f039';
     $data['client_name'] = $this->get_client_name($UserName);
     $LinkPR = '';
     for ($i = 0; $i < 10; $i++) {
         if (isset($_POST["chkLinkPR{$i}"])) {
             $LinkPR .= ",{$i}";
         }
     }
     if (strpos($LinkPR, ',') == 0) {
         $LinkPR = substr($LinkPR, 1);
     }
     $MaxPR = '';
     for ($i = 0; $i < 10; $i++) {
         if (isset($_POST["chkMaxPR{$i}"])) {
             $MaxPR .= ",{$i}";
         }
     }
     if (strpos($MaxPR, ',') == 0) {
         $MaxPR = substr($MaxPR, 1);
     }
     $my_list = $this->uri->segment(2) == 'my' || $this->uri->segment(3) == 'my';
     //!($this->uri->segment(2) === FALSE) && ($this->uri->segment(2) !== 'demo');
     if (user_group('admin') === TRUE) {
         if ($my_list) {
             $query = $this->client_data_search($Website, $Classification, $PriceType, $BBSpecials, $UserReview, $Google, $Yahoo, $MSN, $Quantified, $VacationRental, $Rating, $Limited, $UserName, $LinkPR, $BBCategory, $LinkType, $sort_column, $sort_direction);
         } else {
             $query = $this->client_admin_search($Rating, $LinkPR, $MaxPR, $Quantified, $BBSpecials, $Yahoo, $BBCategory, $MSN, $Google, $UserReview, $PriceType, $LinkType, $AdPackage, $Website, $Classification, $State, $Limited, $sort_column, $sort_direction);
         }
     } else {
         $query = $this->client_data_search($Website, $Classification, $PriceType, $BBSpecials, $UserReview, $Google, $Yahoo, $MSN, $Quantified, $VacationRental, $Rating, $Limited, $UserName, $LinkPR, $BBCategory, $LinkType, $sort_column, $sort_direction);
     }
     $data['bbdata'] = $query->result_array();
     $data['row_count'] = $query->num_rows();
     $UserName = $this->uri->segment(2) === 'demo' ? 'Demonstration' : userID();
     $this->load->vars($data);
     $this->load->helper('url');
     $this->load->helper('html');
     $this->load->helper('form');
     $this->load->library('ajax');
     $this->load->view(user_group('admin') === TRUE ? 'header_user' : 'header_user');
     $this->load->view($my_list ? 'my_list' : (user_group('admin') === TRUE ? 'admin_search' : 'search'), $data);
     $this->load->view('footer_std');
 }
Ejemplo n.º 18
0
function certificate_email_teachers($certificate)
{
    global $course, $USER, $CFG;
    if ($certificate->emailteachers == 0) {
        // No need to do anything
        return;
    }
    $certrecord = certificate_get_issue($course, $USER, $certificate->id);
    $student = $certrecord->studentname;
    $cm = get_coursemodule_from_instance("certificate", $certificate->id, $course->id);
    if (groupmode($course, $cm) == SEPARATEGROUPS) {
        // Separate groups are being used
        if (!($group = user_group($course->id, $user->id))) {
            // Try to find a group
            $group->id = 0;
            // Not in a group, never mind
        }
        $teachers = get_group_teachers($course->id, $group->id);
        // Works even if not in group
    } else {
        $teachers = get_course_teachers($course->id);
    }
    if ($teachers) {
        $strcertificates = get_string('modulenameplural', 'certificate');
        $strcertificate = get_string('modulename', 'certificate');
        $strawarded = get_string('awarded', 'certificate');
        foreach ($teachers as $teacher) {
            unset($info);
            $info->student = $student;
            $info->course = format_string($course->fullname, true);
            $info->certificate = format_string($certificate->name, true);
            $info->url = $CFG->wwwroot . '/mod/certificate/report.php?id=' . $cm->id;
            $from = $student;
            $postsubject = $strawarded . ': ' . $info->student . ' -> ' . $certificate->name;
            $posttext = certificate_email_teachers_text($info);
            $posthtml = certificate_email_teachers_html($info);
            $posthtml = $teacher->mailformat == 1 ? certificate_email_teachers_html($info) : '';
            @email_to_user($teacher, $from, $postsubject, $posttext, $posthtml);
            // If it fails, oh well, too bad.
            set_field("certificate_issues", "mailed", "1", "certificateid", $certificate->id, "userid", $USER->id);
        }
    }
}
Ejemplo n.º 19
0
function skype_show($skype, $user, $cm, $what = "form")
{
    global $USER;
    $which_group = user_group($cm->course, $user->id);
    if (!$which_group) {
        $g_id = 0;
    } else {
        foreach ($which_group as $www => $xxx) {
            $g_id = $xxx->id;
        }
    }
    if ($skype->participants == '0') {
        //0 for students, 1 for tutors of course
        if ($g_id == 0) {
            $call_users = get_course_users($cm->course);
        } else {
            $call_users = get_group_users($g_id);
        }
    } else {
        $call_users = get_course_teachers($cm->course);
    }
    $return = "";
    if ($call_users) {
        foreach ($call_users as $call_user) {
            if ($call_user->skype) {
                $skypeid = $call_user->skype;
                if ($what == "casts") {
                    $return .= '
					<script type="text/javascript" src="https://feedsskypecasts.skype.com/skypecasts/webservice/get.js?limit=100&amp;user='******'"></script>
					<script language="javascript" type="text/javascript">//<![CDATA[
					var cast;
					var cntx=0;
					for(i in Skypecasts) {
					  cntx=1;
					  cast = Skypecasts[i];
					  document.write("<a target=\\"_blank\\" href=\\""+cast.url_info+"\\"><img src=\\"skypecast_icon.gif\\" border=0 width=\\"76\\" height=\\"76\\" alt=\\""+cast.title+"\\" /></a>");
					  document.write("<p class=\\"skypecast-title\\"><a target=\\"_blank\\" href=\\""+cast.url_info+"\\">"+cast.title+"</a></p>");
					  document.write("<p class=\\"skypecast-host\\">' . get_string("moderator", "skype") . ': "+cast.host_name+"</p>");
					  document.write("<p class=\\"skypecast-date\\">"+cast.start_time_hint+"</p>");
					}
					 if(cntx == 0){
					   document.write("<p class=\\"skypecast-title\\">There are no Skypecasts for you!</p><br><br><br>");
					   document.write("<p class=\\"skypecast-title\\"><br><br><br><br><br><br><br><br>&nbsp;</p>");
					 }
					//]]></script>
					';
                } else {
                    if ($USER->id != $call_user->id) {
                        $return .= "\n\t\t\t\t\t\t<option value='{$skypeid}'>" . fullname($call_user, true) . "</option>";
                    }
                }
            }
        }
    } else {
        $call_users = get_course_users($cm->course);
        if ($call_users) {
            foreach ($call_users as $call_user) {
                if ($call_user->skype) {
                    $skypeid = $call_user->skype;
                    if ($what == "casts") {
                        $return .= '
							<script type="text/javascript" src="https://feedsskypecasts.skype.com/skypecasts/webservice/get.js?limit=100&amp;user='******'"></script>
							<script language="javascript" type="text/javascript">//<![CDATA[
							var cast;
							var cntx=0;
							for(i in Skypecasts) {
							  cntx=1;
							  cast = Skypecasts[i];
							  document.write("<a target=\\"_blank\\" href=\\""+cast.url_info+"\\"><img src=\\"skypecast_icon.gif\\" border=0 width=\\"76\\" height=\\"76\\" alt=\\""+cast.title+"\\" /></a>");
							  document.write("<p class=\\"skypecast-title\\"><a target=\\"_blank\\" href=\\""+cast.url_info+"\\">"+cast.title+"</a></p>");
							  document.write("<p class=\\"skypecast-host\\">' . get_string("moderator", "skype") . ': "+cast.host_name+"</p>");
							  document.write("<p class=\\"skypecast-date\\">"+cast.start_time_hint+"</p>");
							}
							 if(cntx == 0){
							   document.write("<p class=\\"skypecast-title\\">There are no Skypecasts for you!</p><br><br><br>");
							   document.write("<p class=\\"skypecast-title\\"><br><br><br><br><br><br><br><br>&nbsp;</p>");
							 }
							//]]></script>
							';
                    } else {
                        if ($USER->id != $call_user->id) {
                            $return .= "\n\t\t\t\t\t\t\t\t<option value='{$skypeid}'>" . fullname($call_user, true) . "</option>";
                        }
                    }
                }
            }
        }
    }
    return $return;
}
Ejemplo n.º 20
0
    if (user_group('billing')) {
        echo anchor('billing/messaging', 'Messages');
    }
    ?>
				<?php 
    if (user_group('billing')) {
        echo anchor('billing/schedule', 'Schedules');
    }
    ?>
				<?php 
    if (user_group('billing')) {
        echo anchor('billing/billing', 'Financial');
    }
    ?>
				<?php 
    if (user_group('provider') || user_group('assistant') || user_group('billing')) {
        echo '<a href="#" id="nosh_configuration">Configure</a>';
    }
    ?>
				<br>
			</div>
			<div id="header_right">
				<div style="float:left;width:190px">
					<span id="switcher"></span>
				</div>
				<div style="float:left;">
					&nbspVersion <span class="version"></span>&nbsp|&nbsp
					<?php 
    echo $this->session->userdata('displayname') . ' ';
    ?>
&nbsp|&nbsp
            <li><?php 
    echo anchor('admin/users/manage', 'Pengguna');
    ?>
</li>
          </ul>
        </li>
        <?php 
}
?>
      </ul>
      <form class="navbar-form navbar-left" role="search">
         
      </form>
      <ul class="nav navbar-nav navbar-right">
      <?php 
if (logged_in() && user_group('admin')) {
    ?>
	
       <li><?php 
    echo anchor('logout', 'Logout');
    ?>
</li>
   <?php 
}
?>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>
<ul id="navigation"  class="nav nav-pills">
Ejemplo n.º 22
0
<ul id="navigation">
<?php 
if (logged_in()) {
    ?>
		<li><?php 
    echo anchor('admin/dashboard', 'Dashboard');
    ?>
</li>
		<li><?php 
    if (user_group('admin')) {
        echo anchor('admin/users/manage', 'Manage Users');
    }
    ?>
</li>
		<li><?php 
    if (user_group('editor') or user_group('admin')) {
        echo anchor('admin/pages/manage', 'Manage Pages');
    }
    ?>
</li>
		<li><?php 
    echo anchor('logout', 'Logout');
    ?>
</li>
	<?php 
} else {
    ?>
		<li><?php 
    echo anchor('login', 'Login');
    ?>
</li>
Ejemplo n.º 23
0
			<th align="center" scope="col"><a href="#" style="color:White;" onclick="javascript:document.getElementById('sort_column').value='LastUpdated';document.forms[0].submit()">Updated</a></th>
		</tr>
		
		<?php 
$row_num = 0;
?>
		<?php 
foreach ($bbdata as $row) {
    ?>
		<tr style="color:#333333; background-color:#<?php 
    echo $row_num % 2 == 0 ? 'F7F6F3' : 'FFFFFF';
    ?>
;">
			<td align="left"><a href="<?php 
    echo base_url();
    echo user_group('admin') === TRUE ? 'admin_' : '';
    ?>
detail/<?php 
    echo $row['BBDataID'];
    ?>
"><?php 
    echo $row['WebSiteText'];
    ?>
</a></td>
			<td align="left" nowrap="nowrap">
				<?php 
    if ($row['Rating'] == 0) {
        ?>
					NR
				<?php 
    } else {
Ejemplo n.º 24
0
function feedback_email_teachers($cm, $feedback, $course, $userid)
{
    global $CFG;
    if ($feedback->email_notification == 0) {
        // No need to do anything
        return;
    }
    $user = get_record('user', 'id', $userid);
    if (groupmode($course, $cm) == SEPARATEGROUPS) {
        // Separate groups are being used
        if (!($group = user_group($course->id, $user->id))) {
            // Try to find a group
            $group->id = 0;
            // Not in a group, never mind
        }
        $teachers = get_group_teachers($course->id, $group->id);
        // Works even if not in group
    } else {
        $teachers = get_course_teachers($course->id);
    }
    if ($teachers) {
        $strfeedbacks = get_string('modulenameplural', 'feedback');
        $strfeedback = get_string('modulename', 'feedback');
        $strcompleted = get_string('completed', 'feedback');
        foreach ($teachers as $teacher) {
            unset($info);
            $info->username = fullname($user);
            $info->feedback = format_string($feedback->name, true);
            $info->url = $CFG->wwwroot . '/mod/feedback/show_entries.php?id=' . $cm->id . '&userid=' . $userid;
            $postsubject = $strcompleted . ': ' . $info->username . ' -> ' . $feedback->name;
            $posttext = feedback_email_teachers_text($info, $course);
            $posthtml = $teacher->mailformat == 1 ? feedback_email_teachers_html($info, $course, $cm) : '';
            @email_to_user($teacher, $user, $postsubject, $posttext, $posthtml);
        }
    }
}
Ejemplo n.º 25
0
            break;
        case 'save':
            form_save();
            break;
        case 'perm_remove':
            perm_remove();
            break;
        case 'edit':
            top_header();
            group_edit();
            bottom_footer();
            break;
        default:
            if (!api_plugin_hook_function('user_group_admin_action', get_request_var_request('action'))) {
                top_header();
                user_group();
                bottom_footer();
            }
            break;
    }
}
/* --------------------------
    Actions Function
   -------------------------- */
function user_group_disable($id)
{
    db_execute_prepared("UPDATE user_auth_group SET enabled = '' WHERE id = ?", array($id));
}
function user_group_enable($id)
{
    db_execute_prepared("UPDATE user_auth_group SET enabled = 'on' WHERE id = ?", array($id));