示例#1
0
/**
 * Dispatche chat pages.
 *
 * @param array $page
 * @return bool
 */
function chat_page_handler($page)
{
    elgg_load_library('chat');
    if (!isset($page[0])) {
        elgg_push_breadcrumb(elgg_echo('chat'));
        $page[0] = 'all';
    } else {
        elgg_push_breadcrumb(elgg_echo('chat'), 'chat/all');
    }
    switch ($page[0]) {
        case 'messages':
            include __DIR__ . '/messages.php';
            return true;
        case 'notifier':
            include __DIR__ . '/notifier.php';
            return true;
        case 'owner':
            $user = get_user_by_username($page[1]);
            $params = chat_all($user->guid);
            break;
        case 'friends':
            $user = get_user_by_username($page[1]);
            $params = chat_friends($user->guid);
            break;
        case 'add':
            gatekeeper();
            $params = chat_edit();
            break;
        case 'edit':
            gatekeeper();
            $params = chat_edit($page[1]);
            break;
        case 'view':
            $params = chat_view($page[1]);
            break;
        case 'members':
            gatekeeper();
            $params = chat_add_members($page[1]);
            break;
        case 'all':
        default:
            $params = chat_all();
            break;
    }
    $body = elgg_view_layout('content', $params);
    echo elgg_view_page('test', $body);
    return true;
}
示例#2
0
 /**
  * Trigger the course module viewed event and update the module completion status.
  *
  * @param int $chatid the chat instance id
  * @return array of warnings and status result
  * @since Moodle 3.0
  * @throws moodle_exception
  */
 public static function view_chat($chatid)
 {
     global $DB, $CFG;
     $params = self::validate_parameters(self::view_chat_parameters(), array('chatid' => $chatid));
     $warnings = array();
     // Request and permission validation.
     $chat = $DB->get_record('chat', array('id' => $params['chatid']), '*', MUST_EXIST);
     list($course, $cm) = get_course_and_cm_from_instance($chat, 'chat');
     $context = context_module::instance($cm->id);
     self::validate_context($context);
     require_capability('mod/chat:chat', $context);
     // Call the url/lib API.
     chat_view($chat, $course, $cm, $context);
     $result = array();
     $result['status'] = true;
     $result['warnings'] = $warnings;
     return $result;
 }
示例#3
0
文件: view.php 项目: pzhu2004/moodle
        print_error('invalidcoursemodule');
    }
}
require_course_login($course, true, $cm);
$context = context_module::instance($cm->id);
$PAGE->set_context($context);
// Show some info for guests.
if (isguestuser()) {
    $PAGE->set_title($chat->name);
    echo $OUTPUT->header();
    echo $OUTPUT->confirm('<p>' . get_string('noguests', 'chat') . '</p>' . get_string('liketologin'), get_login_url(), $CFG->wwwroot . '/course/view.php?id=' . $course->id);
    echo $OUTPUT->footer();
    exit;
}
// Completion and trigger events.
chat_view($chat, $course, $cm, $context);
$strenterchat = get_string('enterchat', 'chat');
$stridle = get_string('idle', 'chat');
$strcurrentusers = get_string('currentusers', 'chat');
$strnextsession = get_string('nextsession', 'chat');
$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
$title = $courseshortname . ': ' . format_string($chat->name);
// Initialize $PAGE.
$PAGE->set_url('/mod/chat/view.php', array('id' => $cm->id));
$PAGE->set_title($title);
$PAGE->set_heading($course->fullname);
// Print the page header.
echo $OUTPUT->header();
// Check to see if groups are being used here.
$groupmode = groups_get_activity_groupmode($cm);
$currentgroup = groups_get_activity_group($cm, true);