Example #1
0
function admin_pagesetup()
{
    global $PAGE, $CFG;
    /*
        if (isadmin()) {
            $PAGE->menu_top [] = array( 'name' => 'admin',
                                        //'html' => a_href("{$CFG->wwwroot}_admin/",
                                        //                "Administration"));
                                        'html' => "<li><a href=\"" . $CFG->wwwroot . "mod/admin/\">" . __gettext("Administration") . "</a></li>");
        }
    */
    if (defined("context") && context == "account") {
        $PAGE->menu_sub[] = array('name' => 'user:edit', 'html' => a_href("{$CFG->wwwroot}_userdetails/", __gettext("Edit user details")));
        /*$PAGE->menu_sub[] = array (
        		'name' => 'user:icon',
        		'html' => a_href("{$CFG->wwwroot}_icons/",__gettext("Your site picture")));*/
    }
    if (defined("context") && context == "admin" && isloggedin() && user_flag_get("admin", $_SESSION['userid'])) {
        $PAGE->menu_sub[] = array('name' => 'admin', 'html' => a_href(get_url(-1, 'admin::main'), __gettext("Main")));
        $PAGE->menu_sub[] = array('name' => 'admin:users:add', 'html' => a_href(get_url(-1, 'admin::users::add'), __gettext("Add users")));
        $PAGE->menu_sub[] = array('name' => 'admin:users', 'html' => a_href(get_url(-1, 'admin::users'), __gettext("Manage users")));
        $PAGE->menu_sub[] = array('name' => 'admin:users:banned', 'html' => a_href(get_url(-1, 'admin::users::banned'), __gettext("Banned users")));
        $PAGE->menu_sub[] = array('name' => 'admin:users:admin', 'html' => a_href(get_url(-1, 'admin::users::admin'), __gettext("Admin users")));
        $PAGE->menu_sub[] = array('name' => 'admin:flags', 'html' => a_href(get_url(-1, 'admin::flags'), __gettext("Manage flagged content")));
        $PAGE->menu_sub[] = array('name' => 'admin:spam', 'html' => a_href(get_url(-1, 'admin::spam'), __gettext("Spam control")));
    }
}
Example #2
0
/**
 * Sets up submenus for the file system.  Triggered on pagesetup.
 *
 */
function file_submenus()
{
    global $CONFIG;
    $page_owner = page_owner_entity();
    // Group submenu option
    if ($page_owner instanceof ElggGroup && get_context() == "groups") {
        if ($page_owner->files_enable != "no") {
            add_submenu_item(sprintf(elgg_echo("file:group"), $page_owner->name), $CONFIG->wwwroot . "pg/file/" . $page_owner->username);
        }
    }
    // General submenu options
    if (get_context() == "file") {
        if ((page_owner() == $_SESSION['guid'] || !page_owner()) && isloggedin()) {
            add_submenu_item(sprintf(elgg_echo("file:yours"), $page_owner->name), $CONFIG->wwwroot . "pg/file/" . $page_owner->username);
            add_submenu_item(sprintf(elgg_echo('file:yours:friends'), $page_owner->name), $CONFIG->wwwroot . "pg/file/" . $page_owner->username . "/friends/");
        } else {
            if (page_owner()) {
                add_submenu_item(sprintf(elgg_echo("file:user"), $page_owner->name), $CONFIG->wwwroot . "pg/file/" . $page_owner->username);
                if ($page_owner instanceof ElggUser) {
                    // This one's for users, not groups
                    add_submenu_item(sprintf(elgg_echo('file:friends'), $page_owner->name), $CONFIG->wwwroot . "pg/file/" . $page_owner->username . "/friends/");
                }
            }
        }
        add_submenu_item(elgg_echo('file:all'), $CONFIG->wwwroot . "mod/file/world.php");
        if (can_write_to_container($_SESSION['guid'], page_owner())) {
            add_submenu_item(elgg_echo('file:upload'), $CONFIG->wwwroot . "pg/file/" . $page_owner->username . "/new/");
        }
    }
}
Example #3
0
function file_pagesetup()
{
    // register links --
    global $profile_id;
    global $PAGE;
    global $CFG;
    global $metatags;
    require_once dirname(__FILE__) . "/lib/file_config.php";
    $page_owner = $profile_id;
    if (isloggedin()) {
        if (defined("context") && context == "files" && $page_owner == $_SESSION['userid']) {
            $PAGE->menu[] = array('name' => 'files', 'html' => "<li><a href=\"{$CFG->wwwroot}{$_SESSION['username']}/files/\" class=\"selected\" >" . __gettext("Photos") . '</a></li>');
        } else {
            $PAGE->menu[] = array('name' => 'files', 'html' => "<li><a href=\"{$CFG->wwwroot}{$_SESSION['username']}/files/\" >" . __gettext("Photos") . '</a></li>');
        }
    }
    if (defined("context") && context == "files") {
        $files_username = user_info('username', $page_owner);
        if ($page_owner != -1) {
            if ($page_owner == $_SESSION['userid'] && $page_owner != -1) {
                $PAGE->menu_sub[] = array('name' => 'file:rss', 'html' => '<a href="' . $CFG->wwwroot . $_SESSION['username'] . '/files/rss/"><img src="' . $CFG->wwwroot . 'mod/template/icons/rss.png" border="0" alt="rss" /></a>');
            }
        }
        if ($page_owner == $_SESSION['userid'] && $page_owner != -1) {
            $PAGE->menu_sub[] = array('name' => 'file:add', 'html' => a_href("{$CFG->wwwroot}{$_SESSION['username']}/files/addphoto", __gettext("Add a Photo")));
        }
        if ($page_owner == $_SESSION['userid'] && $page_owner != -1) {
            $PAGE->menu_sub[] = array('name' => 'file:add', 'html' => a_href("{$CFG->wwwroot}{$_SESSION['username']}/files/addfolder", __gettext("Add a folder")));
        }
    }
    // Adding the file's selector wizard
    $options = array('options' => 'width=600,height=300,left=20,top=20,scrollbars=yes,resizable=yes', 'name' => 'mediapopup', 'url' => $CFG->wwwroot . "mod/file/file_include_wizard.php?owner=" . page_owner());
    add_content_tool_button("mediapopup", __gettext("Add File"), "image.png", "f", $options);
}
Example #4
0
/**
 * Sets up submenus. Triggered on pagesetup.
 *
 */
function plugins_add_submenus()
{
    global $CONFIG;
    $plugins_base = "{$CONFIG->wwwroot}pg/plugins";
    if (get_context() == 'admin') {
        $title = elgg_echo("plugins:admin:menu");
        add_submenu_item($title, "{$plugins_base}/admin/");
        return;
    }
    if (get_context() != "plugins") {
        return;
    }
    $page_owner = page_owner_entity();
    if (isloggedin() && page_owner() == get_loggedin_userid()) {
        $title = sprintf(elgg_echo("plugins:yours"), elgg_echo('plugins:types:'));
        add_submenu_item($title, "{$plugins_base}/developer/{$page_owner->username}");
        //add_submenu_item(sprintf(elgg_echo('plugins:yours:friends'),page_owner_entity()->name), $CONFIG->wwwroot . "pg/plugins/". $page_owner->username . "/friends/");
    } else {
        if (page_owner()) {
            $title = sprintf(elgg_echo("plugins:user"), $page_owner->name, elgg_echo('plugins:types:'));
            add_submenu_item($title, "{$plugins_base}/developer/{$page_owner->username}");
            //if ($page_owner instanceof ElggUser) // This one's for users, not groups
            //add_submenu_item(sprintf(elgg_echo('plugins:friends'),$page_owner->name), $CONFIG->wwwroot . "pg/plugins/". $page_owner->username . "/friends/");
        }
    }
    add_submenu_item(elgg_echo('plugins:all'), "{$plugins_base}/all/");
    // add upload link when viewing own plugin page
    if (get_loggedin_userid() == page_owner()) {
        add_submenu_item(elgg_echo('plugins:upload'), "{$plugins_base}/new/project/{$page_owner->username}");
    }
}
Example #5
0
/**
 * Returns whether ajax is enabled/allowed or not.
 * @param array $browsers optional list of alowed browsers, empty means use default list
 * @return bool
 */
function ajaxenabled(array $browsers = null)
{
    global $CFG, $USER;
    if (!empty($browsers)) {
        $valid = false;
        foreach ($browsers as $brand => $version) {
            if (check_browser_version($brand, $version)) {
                $valid = true;
            }
        }
        if (!$valid) {
            return false;
        }
    }
    $ie = check_browser_version('MSIE', 6.0);
    $ff = check_browser_version('Gecko', 20051106);
    $op = check_browser_version('Opera', 9.0);
    $sa = check_browser_version('Safari', 412);
    if (!$ie && !$ff && !$op && !$sa) {
        /** @see http://en.wikipedia.org/wiki/User_agent */
        // Gecko build 20051107 is what is in Firefox 1.5.
        // We still have issues with AJAX in other browsers.
        return false;
    }
    if (!empty($CFG->enableajax) && (!empty($USER->ajax) || !isloggedin())) {
        return true;
    } else {
        return false;
    }
}
Example #6
0
/**
 * Returns HTML for a blog post.
 *
 * @param int $guid of a blog entity.
 * @return string html
 */
function blog_get_page_content_read($owner_guid = NULL, $guid = NULL)
{
    $content = elgg_view('page_elements/content_header', array('context' => $context, 'type' => 'blog'));
    if ($guid) {
        $blog = get_entity($guid);
        if (!elgg_instanceof($blog, 'object', 'blog') && $blog->status == 'final') {
            $content .= elgg_echo('blog:error:post_not_found');
        } else {
            elgg_push_breadcrumb($blog->title, $blog->getURL());
            $content .= elgg_view_entity($blog, TRUE);
        }
    } else {
        $options = array('type' => 'object', 'subtype' => 'blog', 'full_view' => FALSE, 'order_by_metadata' => array('name' => 'publish_date', 'direction' => 'DESC', 'as' => 'int'));
        if ($owner_guid) {
            $options['owner_guid'] = $owner_guid;
        }
        // show all posts for admin or users looking at their own blogs
        // show only published posts for other users.
        if (!(isadminloggedin() || isloggedin() && $owner_guid == get_loggedin_userid())) {
            $options['metadata_name_value_pairs'] = array(array('name' => 'status', 'value' => 'published'), array('name' => 'publish_date', 'operand' => '<', 'value' => time()));
        }
        $content .= elgg_list_entities_from_metadata($options);
    }
    return array('content' => $content);
}
Example #7
0
function toolbar_mainbody($vars)
{
    global $CFG;
    require_once $CFG->dirroot . 'lib/filelib.php';
    // to ensure file_get_contents()
    if (isloggedin()) {
        $toolbar = file_get_contents($CFG->dirroot . "mod/toolbar/toolbar.inc");
    } else {
        //$toolbar = file_get_contents($CFG->dirroot . "mod/toolbar/toolbarloggedout.inc");
    }
    if (isset($vars[1]) && $vars[1] == 'box') {
        $css = file_get_contents($CFG->dirroot . "mod/toolbar/css-box");
    } else {
        $css = file_get_contents($CFG->dirroot . "mod/toolbar/css");
    }
    $css = str_replace("{{url}}", $CFG->wwwroot, $css);
    $toolbar .= "{$css}";
    $toolbar = str_replace("{{url}}", $CFG->wwwroot, $toolbar);
    $toolbar = str_replace("{{menu}}", templates_variables_substitute(array(array(), "menu")), $toolbar);
    $toolbar = str_replace("{{topmenu}}", templates_variables_substitute(array(array(), "topmenu")), $toolbar);
    $toolbar = str_replace("{{logon}}", __gettext("Log on:"), $toolbar);
    $toolbar = str_replace("{{username}}", __gettext("Username"), $toolbar);
    $toolbar = str_replace("{{password}}", __gettext("Password"), $toolbar);
    $toolbar = str_replace("{{poweredby}}", __gettext("Powered by Elgg"), $toolbar);
    $toolbar = str_replace("{{remember}}", __gettext("Remember me"), $toolbar);
    if (isloggedin()) {
        $toolbar = str_replace("{{usericon}}", "<a href=\"{$CFG->wwwroot}{$_SESSION['username']}\">" . user_icon_html($_SESSION['userid'], 50) . "</a>", $toolbar);
    } else {
        $toolbar = str_replace("{{usericon}}", user_icon_html(-1, 50), $toolbar);
    }
    return $toolbar;
}
/**
 * Check if an activity is configured to only show navbuttons when
 * complete and then check if the activity is complete
 * @param cm_info $cm the course module for the activity
 * @return boolean true if the navbuttons should be shown
 */
function navbuttons_activity_showbuttons($cm)
{
    $modname = $cm->modname;
    $show = get_config('block_navbuttons', 'activity' . $modname);
    if ($show === false || $show == NAVBUTTONS_ACTIVITY_ALWAYS) {
        return true;
        // No config or 'always show'
    }
    if ($show == NAVBUTTONS_ACTIVITY_NEVER) {
        return false;
    }
    if ($show == NAVBUTTONS_ACTIVITY_COMPLETE) {
        $completion = new completion_info($cm->get_course());
        if (!$completion->is_enabled($cm)) {
            return true;
            // No completion tracking - show the buttons
        }
        $cmcompletion = $completion->get_data($cm);
        if ($cmcompletion->completionstate == COMPLETION_INCOMPLETE) {
            return false;
        }
        return true;
    }
    if (!isloggedin() || isguestuser()) {
        return true;
        // Always show the buttons if not logged in
    }
    // NAVBUTTONS_ACTIVITY_CUSTOM
    $funcname = 'navbuttons_mod_' . $modname . '_showbuttons';
    if (!function_exists($funcname)) {
        return true;
        // Shouldn't have got to here, but allow the buttons anyway
    }
    return $funcname($cm);
}
Example #9
0
    function get_content() {
        global $CFG;
        if ($this->content !== NULL) {
            return $this->content;
        }
		if(!isloggedin()){
			return $this->content;
		}
		//if(is_siteadmin()){
		//	return $this->content;
		//}
		//if(has_capability('local_collegestructure:manage', context_system::instance())){
		//	return $this->content;
		//}

      
        // Prep the content
        $this->content = new stdClass();
		require_once('events.php');
		$events = get_events();
        $this->content->text = $events;
        return $this->content;
        // Prepare the footer for this block
        // No footer to display
        $this->content->footer = '';
		// Return the content object
        return $this->content;
    }
Example #10
0
 function get_content()
 {
     if ($this->content !== NULL) {
         return $this->content;
     }
     if (empty($this->instance)) {
         return null;
     }
     $this->content->footer = '';
     $this->content->text = '';
     if (isloggedin() && !isguestuser()) {
         // Show the block
         $cmt = new stdclass();
         $cmt->context = $this->instance->context;
         $cmt->area = 'block_comments';
         $cmt->itemid = $this->instance->id;
         $cmt->course = $this->page->course;
         // this is a hack to adjust commenting UI
         // in block_comments
         $cmt->env = 'block_comments';
         $cmt->linktext = get_string('showcomments');
         $comment = new comment($cmt);
         $this->content = new stdClass();
         $this->content->text = $comment->init(true);
         $this->content->footer = '';
     }
     return $this->content;
 }
function bookmarks_pagesetup()
{
    global $CONFIG;
    // Set up menu for logged in users
    //add submenu options
    if (get_context() == "bookmarks") {
        if (isloggedin()) {
            add_submenu_item(elgg_echo('bookmarks:inbox'), $CONFIG->wwwroot . "pg/bookmarks/" . $_SESSION['user']->username . "/inbox");
            if (page_owner()) {
                $page_owner = page_owner_entity();
                add_submenu_item(sprintf(elgg_echo('bookmarks:read'), $page_owner->name), $CONFIG->wwwroot . "pg/bookmarks/" . $page_owner->username . "/items");
            }
            if (!$page_owner instanceof ElggGroup) {
                add_submenu_item(elgg_echo('bookmarks:friends'), $CONFIG->wwwroot . "pg/bookmarks/" . $_SESSION['user']->username . "/friends");
            }
        }
        //if(!$page_owner instanceof ElggGroup)
        //	add_submenu_item(elgg_echo('bookmarks:everyone'),$CONFIG->wwwroot."mod/bookmarks/everyone.php");
        // Bookmarklet
        if (isloggedin() && page_owner() && can_write_to_container(0, page_owner())) {
            $page_owner = page_owner_entity();
            $bmtext = elgg_echo('bookmarks:bookmarklet');
            if ($page_owner instanceof ElggGroup) {
                $bmtext = elgg_echo('bookmarks:bookmarklet:group');
            }
            add_submenu_item($bmtext, $CONFIG->wwwroot . "pg/bookmarks/{$page_owner->username}/bookmarklet");
        }
    }
    $page_owner = page_owner_entity();
    if ($page_owner instanceof ElggGroup && get_context() == 'groups') {
        if ($page_owner->bookmarks_enable != "no") {
            add_submenu_item(sprintf(elgg_echo("bookmarks:group"), $page_owner->name), $CONFIG->wwwroot . "pg/bookmarks/" . $page_owner->username . '/items');
        }
    }
}
 function get_content()
 {
     global $CFG, $USER, $DB, $OUTPUT;
     // shortcut -  only for logged in users!
     if (!isloggedin() || isguestuser()) {
         return false;
     }
     // according to start_jump_session,
     // remote users can't on-jump
     // so don't show this block to them
     if (is_mnet_remote_user($USER)) {
         if (debugging() and !empty($CFG->debugdisplay)) {
             $this->content = new stdClass();
             $this->content->footer = html_writer::tag('span', get_string('error_localusersonly', 'block_mnet_hosts'), array('class' => 'error'));
             return $this->content;
         } else {
             return '';
         }
     }
     if (!is_enabled_auth('mnet')) {
         if (debugging() and !empty($CFG->debugdisplay)) {
             $this->content = new stdClass();
             $this->content->footer = html_writer::tag('span', get_string('error_authmnetneeded', 'block_mnet_hosts'), array('class' => 'error'));
             return $this->content;
         } else {
             return '';
         }
     }
     if (!has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM), NULL, false)) {
         if (debugging() and !empty($CFG->debugdisplay)) {
             $this->content = new stdClass();
             $this->content->footer = html_writer::tag('span', get_string('error_roamcapabilityneeded', 'block_mnet_hosts'), array('class' => 'error'));
             return $this->content;
         } else {
             return '';
         }
     }
     if ($this->content !== NULL) {
         return $this->content;
     }
     // TODO: Test this query - it's appropriate? It works?
     // get the hosts and whether we are doing SSO with them
     $sql = "\n             SELECT DISTINCT\n                 h.id,\n                 h.name,\n                 h.wwwroot,\n                 a.name as application,\n                 a.display_name\n             FROM\n                 {mnet_host} h,\n                 {mnet_application} a,\n                 {mnet_host2service} h2s_IDP,\n                 {mnet_service} s_IDP,\n                 {mnet_host2service} h2s_SP,\n                 {mnet_service} s_SP\n             WHERE\n                 h.id <> ? AND\n                 h.id <> ? AND\n                 h.id = h2s_IDP.hostid AND\n                 h.deleted = 0 AND\n                 h.applicationid = a.id AND\n                 h2s_IDP.serviceid = s_IDP.id AND\n                 s_IDP.name = 'sso_idp' AND\n                 h2s_IDP.publish = '1' AND\n                 h.id = h2s_SP.hostid AND\n                 h2s_SP.serviceid = s_SP.id AND\n                 s_SP.name = 'sso_idp' AND\n                 h2s_SP.publish = '1'\n             ORDER BY\n                 a.display_name,\n                 h.name";
     $hosts = $DB->get_records_sql($sql, array($CFG->mnet_localhost_id, $CFG->mnet_all_hosts_id));
     $this->content = new stdClass();
     $this->content->items = array();
     $this->content->icons = array();
     $this->content->footer = '';
     if ($hosts) {
         foreach ($hosts as $host) {
             $icon = '<img src="' . $OUTPUT->pix_url('i/' . $host->application . '_host') . '"' . ' class="icon" alt="' . get_string('server', 'block_mnet_hosts') . '" />&nbsp;';
             if ($host->id == $USER->mnethostid) {
                 $this->content->items[] = "<a title=\"" . s($host->name) . "\" href=\"{$host->wwwroot}\">" . $icon . s($host->name) . "</a>";
             } else {
                 $this->content->items[] = "<a title=\"" . s($host->name) . "\" href=\"{$CFG->wwwroot}/auth/mnet/jump.php?hostid={$host->id}\">" . $icon . s($host->name) . "</a>";
             }
         }
     }
     return $this->content;
 }
 /**
  * Renders a custom menu object (located in outputcomponents.php)
  *
  * The custom menu this method override the render_custom_menu function
  * in outputrenderers.php
  * @staticvar int $menucount
  * @param custom_menu $menu
  * @return string
  */
 protected function render_custom_menu(custom_menu $menu)
 {
     // Generate custom My Courses dropdown.
     $mycourses = $this->page->navigation->get('mycourses');
     $mycoursetitle = $this->page->theme->settings->mycoursetitle;
     if (isloggedin() && $mycourses && $mycourses->has_children()) {
         $branchurl = new moodle_url('/my/index.php');
         $branchsort = 10000;
         if ($mycoursetitle == 'module') {
             $branchlabel = get_string('mymodules', 'theme_rocket');
         } else {
             if ($mycoursetitle == 'unit') {
                 $branchlabel = get_string('myunits', 'theme_rocket');
             } else {
                 if ($mycoursetitle == 'class') {
                     $branchlabel = get_string('myclasses', 'theme_rocket');
                 } else {
                     $branchlabel = get_string('mycourses', 'theme_rocket');
                 }
             }
         }
         $branchtitle = $branchlabel;
         $branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort);
         foreach ($mycourses->children as $coursenode) {
             $branch->add($coursenode->get_content(), $coursenode->action, $coursenode->get_title());
         }
     } else {
         if ($mycoursetitle == 'module') {
             $branchlabel = get_string('allmodules', 'theme_rocket');
         } else {
             if ($mycoursetitle == 'unit') {
                 $branchlabel = get_string('allunits', 'theme_rocket');
             } else {
                 if ($mycoursetitle == 'class') {
                     $branchlabel = get_string('allclasses', 'theme_rocket');
                 } else {
                     $branchlabel = get_string('allcourses', 'theme_rocket');
                 }
             }
         }
         $branchtitle = $branchlabel;
         $branchurl = new moodle_url('/course/index.php');
         $branchsort = 10000;
         $branch = $menu->add($branchlabel, $branchurl, $branchtitle, $branchsort);
     }
     // If the menu has no children return an empty string.
     if (!$menu->has_children()) {
         return '';
     }
     // Initialise this custom menu.
     $content = html_writer::start_tag('ul', array('class' => 'dropdown dropdown-horizontal'));
     // Render each child.
     foreach ($menu->get_children() as $item) {
         $content .= $this->render_custom_menu_item($item);
     }
     // Close the open tags.
     $content .= html_writer::end_tag('ul');
     // Return the custom menu.
     return $content;
 }
Example #14
0
/**
 * OBU Apps - Provide left hand navigation links
 *
 * @package    obu_apps
 * @category   local
 * @copyright  2015, Oxford Brookes University {@link http://www.brookes.ac.uk/}
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function local_obu_apps_extend_navigation($navigation)
{
    global $CFG;
    if (!isloggedin() || isguestuser()) {
        return;
    }
    // Find the 'apps' node
    $nodeApps = $navigation->find(get_string('apps', 'local_obu_apps'), navigation_node::TYPE_SYSTEM);
    // If necessary, add the 'apps' node to 'home'
    if (!$nodeApps) {
        $nodeHome = $navigation->children->get('1')->parent;
        if ($nodeHome) {
            $nodeApps = $nodeHome->add(get_string('apps', 'local_obu_apps'), null, navigation_node::TYPE_SYSTEM);
        }
    }
    if ($nodeApps) {
        // BRISC
        if (get_config('local_obu_apps', 'showbrisc') == '1' && has_capability('moodle/blog:create', context_system::instance())) {
            $nodeApps->add('BRISC', '/local/obu_apps/brisc.php');
            // BRISC web app
        }
        // QuAK
        if (get_config('local_obu_apps', 'showquak') == '1' && !empty($CFG->navadduserpostslinks)) {
            $nodeApps->add('QuAK', '/local/obu_apps/quak.php');
            // QuAK web app
        }
        // Polls
        if (get_config('local_obu_apps', 'showpolls') == '1') {
            $nodeApps->add('polls.brookes', '/local/obu_apps/polls.php');
            // Polls web app
        }
    }
}
Example #15
0
function newsclient_pagesetup()
{
    // register links --
    global $profile_id;
    global $PAGE;
    global $CFG;
    $page_owner = $profile_id;
    $rss_username = user_info('username', $page_owner);
    if (isloggedin()) {
        /*if (defined("context") && context == "resources" && $page_owner == $_SESSION['userid']) {
              $PAGE->menu[] = array( 'name' => 'feeds',
                                     'html' => "<li><a href=\"{$CFG->wwwroot}{$_SESSION['username']}/feeds/\" class=\"selected\" >" .__gettext("Your Resources").'</a></li>');
          } else {
              $PAGE->menu[] = array( 'name' => 'feeds',
                                     'html' => "<li><a href=\"{$CFG->wwwroot}{$_SESSION['username']}/feeds/\" >" .__gettext("Your Resources").'</a></li>');
          }*/
    }
    if (defined("context") && context == "resources") {
        if ($page_owner != -1) {
            $PAGE->menu_sub[] = array('name' => 'newsfeed:subscription', 'html' => a_href($CFG->wwwroot . $rss_username . "/feeds/", __gettext("Feeds")));
            if (permissions_check("profile", $page_owner) && isloggedin()) {
                $PAGE->menu_sub[] = array('name' => 'newsfeed:subscription:publish:blog', 'html' => a_href($CFG->wwwroot . "_rss/blog.php?profile_name=" . user_info("username", $page_owner), __gettext("Publish to blog")));
            }
            $PAGE->menu_sub[] = array('name' => 'newsclient', 'html' => a_href($CFG->wwwroot . $rss_username . "/feeds/all/", __gettext("View aggregator")));
        }
        $PAGE->menu_sub[] = array('name' => 'feed', 'html' => a_href($CFG->wwwroot . "_rss/popular.php", __gettext("Popular Feeds")));
        /*
        $PAGE->menu_sub[] = array( 'name' => 'feed',
                                   'html' => a_href( $CFG->wwwroot."help/feeds_help.php",
                                                      "Page help"));
        */
    }
}
 function get_content()
 {
     global $CFG, $USER;
     if ($this->content !== NULL) {
         return $this->content;
     }
     $content = '';
     $footer = '';
     $nologin_auths = block_repository_nopasswd_auths();
     if (!empty($USER->auth) && in_array($USER->auth, $nologin_auths)) {
         return '';
     }
     if (isloggedin() && file_exists($CFG->dirroot . '/file/repository/alfresco/repository.php')) {
         require_once $CFG->dirroot . '/file/repository/repository.class.php';
         if (isset($CFG->repository_plugins_enabled) && strstr($CFG->repository_plugins_enabled, 'alfresco')) {
             if ($repo = repository_factory::factory('alfresco')) {
                 if ($repo->alfresco_userdir($USER->username) !== false) {
                     // Fix username
                     $username = repository_plugin_alfresco::fix_username($USER->username);
                     // So that we don't conflict with the default Alfresco admin account.
                     $username = $username == 'admin' ? $CFG->repository_alfresco_admin_username : $username;
                     $hastenant = false;
                     // We must include the tenant portion of the username here.
                     if (($tenantname = strpos($CFG->repository_alfresco_server_username, '@')) > 0) {
                         $username .= substr($CFG->repository_alfresco_server_username, $tenantname);
                         $hastenant = true;
                     }
                     // Display a link to access the Alfresco repository directly.
                     $content .= get_string('webappaccess', 'block_repository', $repo->get_webapp_url()) . '<br /><br />';
                     // Display a link to the configured embedded WebDAV client (if defined).
                     if (!empty($CFG->block_course_repository_webdav_client)) {
                         $content .= get_string('embeddedwebdavlink', 'block_repository', $CFG->block_course_repository_webdav_client) . '<br /><br />';
                     }
                     if ($hastenant || $username != $USER->username) {
                         $content .= get_string('usernametenantinfo', 'block_repository', $username);
                     } else {
                         $content .= get_string('usernameinfo', 'block_repository', $username);
                     }
                     // Display a link to defined help files
                     if (!empty($CFG->block_course_repository_help_link)) {
                         $footer = get_string('helpfileslink', 'block_repository', $CFG->block_course_repository_help_link);
                     }
                 }
             }
         }
     }
     // If there is no content and the current user can actually modify the site settings, display some text
     // in the block explaining what is happening.
     if (empty($content) && has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
         if (file_exists($CFG->dirroot . '/admin/file/repositories.php')) {
             $content = get_string('alfresconotconfigured', 'block_repository', $CFG->wwwroot . '/admin/file/' . 'repositories.php');
         } else {
             $content = get_string('norepositorypluginsystem', 'block_repository');
         }
     }
     $this->content = new stdClass();
     $this->content->text = $content;
     $this->content->footer = $footer;
     return $this->content;
 }
Example #17
0
function newsclient_pagesetup()
{
    // register links --
    global $profile_id;
    global $PAGE;
    global $CFG;
    $page_owner = $profile_id;
    if (isloggedin() && $CFG->your_resources_enabled) {
        if (defined("context") && context == "resources" && $page_owner == $_SESSION['userid']) {
            $PAGE->menu[] = array('name' => 'resources', 'html' => "<li><a href=\"{$CFG->wwwroot}{$_SESSION['username']}/feeds/\" class=\"selected\" >" . gettext("Your Resources") . '</a></li>');
        } else {
            $PAGE->menu[] = array('name' => 'resources', 'html' => "<li><a href=\"{$CFG->wwwroot}{$_SESSION['username']}/feeds/\" >" . gettext("Your Resources") . '</a></li>');
        }
        $rss_username = run("users:id_to_name", $page_owner);
    }
    if (defined("context") && context == "resources" && $CFG->your_resources_enabled) {
        if ($page_owner != -1) {
            if (run("permissions:check", "rss") && logged_on && $page_owner == $_SESSION['userid']) {
                $PAGE->menu_sub[] = array('name' => 'newsfeed:subscription', 'html' => a_hrefg($CFG->wwwroot . $_SESSION['username'] . "/feeds/", gettext("Feeds")));
                $PAGE->menu_sub[] = array('name' => 'newsfeed:subscription:publish:blog', 'html' => a_hrefg($CFG->wwwroot . "_rss/blog.php?page_owner=" . $_SESSION['userid'], gettext("Publish to blog")));
            }
            $PAGE->menu_sub[] = array('name' => 'newsclient', 'html' => a_hrefg($CFG->wwwroot . $rss_username . "/feeds/all/", gettext("View aggregator")));
        }
        $PAGE->menu_sub[] = array('name' => 'feed', 'html' => a_hrefg($CFG->wwwroot . "_rss/popular.php", gettext("Popular Feeds")));
        /*
        $PAGE->menu_sub[] = array( 'name' => 'feed',
                                   'html' => a_hrefg( $CFG->wwwroot."help/feeds_help.php", 
                                                      "Page help"));
        */
    }
}
 function get_content()
 {
     global $THEME, $CFG, $USER;
     // only for logged in users!
     if (!isloggedin() || isguest()) {
         return false;
     }
     // check for outgoing roaming permission first
     if (!has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM), NULL, false)) {
         return '';
     }
     if ($this->content !== NULL) {
         return $this->content;
     }
     // TODO: Test this query - it's appropriate? It works?
     // get the hosts and whether we are doing SSO with them
     $sql = "\n             SELECT DISTINCT \n                 h.id, \n                 h.name,\n                 h.wwwroot,\n                 a.name as application,\n                 a.display_name\n             FROM \n                 {$CFG->prefix}mnet_host h,\n                 {$CFG->prefix}mnet_application a,\n                 {$CFG->prefix}mnet_host2service h2s_IDP,\n                 {$CFG->prefix}mnet_service s_IDP,\n                 {$CFG->prefix}mnet_host2service h2s_SP,\n                 {$CFG->prefix}mnet_service s_SP\n             WHERE\n                 h.id != '{$CFG->mnet_localhost_id}' AND\n                 h.id = h2s_IDP.hostid AND\n                 h.applicationid = a.id AND\n                 h2s_IDP.serviceid = s_IDP.id AND\n                 s_IDP.name = 'sso_idp' AND\n                 h2s_IDP.publish = '1' AND\n                 h.id = h2s_SP.hostid AND\n                 h2s_SP.serviceid = s_SP.id AND\n                 s_SP.name = 'sso_idp' AND\n                 h2s_SP.publish = '1'\n             ORDER BY\n                 a.display_name,\n                 h.name";
     $hosts = get_records_sql($sql);
     $this->content = new stdClass();
     $this->content->items = array();
     $this->content->icons = array();
     $this->content->footer = '';
     if ($hosts) {
         foreach ($hosts as $host) {
             $icon = '<img src="' . $CFG->pixpath . '/i/' . $host->application . '_host.gif"' . ' class="icon" alt="' . get_string('server', 'block_mnet_hosts') . '" />';
             $this->content->icons[] = $icon;
             if ($host->id == $USER->mnethostid) {
                 $this->content->items[] = "<a title=\"" . s($host->name) . "\" href=\"{$host->wwwroot}\">" . s($host->name) . "</a>";
             } else {
                 $this->content->items[] = "<a title=\"" . s($host->name) . "\" href=\"{$CFG->wwwroot}/auth/mnet/jump.php?hostid={$host->id}\">" . s($host->name) . "</a>";
             }
         }
     }
     return $this->content;
 }
 /**
  * Gets a stored file for the backup course filearea directory.
  *
  * @param int $itemid item ID
  * @param string $filepath file path
  * @param string $filename file name
  * @return file_info|null file_info instance or null if not found or access not allowed
  */
 protected function get_area_backup_course($itemid, $filepath, $filename)
 {
     global $CFG;
     if (!isloggedin()) {
         return null;
     }
     if (!has_any_capability(array('moodle/backup:backupcourse', 'moodle/restore:restorecourse'), $this->context)) {
         return null;
     }
     if (is_null($itemid)) {
         return $this;
     }
     $fs = get_file_storage();
     $filepath = is_null($filepath) ? '/' : $filepath;
     $filename = is_null($filename) ? '.' : $filename;
     if (!($storedfile = $fs->get_file($this->context->id, 'backup', 'course', 0, $filepath, $filename))) {
         if ($filepath === '/' && $filename === '.') {
             $storedfile = new virtual_root_file($this->context->id, 'backup', 'course', 0);
         } else {
             // Not found.
             return null;
         }
     }
     $downloadable = has_capability('moodle/backup:downloadfile', $this->context);
     $uploadable = has_capability('moodle/restore:uploadfile', $this->context);
     $urlbase = $CFG->wwwroot . '/pluginfile.php';
     return new file_info_stored($this->browser, $this->context, $storedfile, $urlbase, get_string('coursebackup', 'repository'), false, $downloadable, $uploadable, false);
 }
Example #20
0
 /**
  * Get the content of the block.
  *
  * @return stdObject
  */
 public function get_content()
 {
     global $USER, $DB;
     if (!isloggedin()) {
         return null;
     }
     if ($this->content !== null) {
         return $this->content;
     }
     $this->content = new \stdClass();
     $this->content->text = '';
     $this->content->footer = '';
     try {
         $o365connected = \local_o365\utils::is_o365_connected($USER->id);
         if ($o365connected === true) {
             $this->content->text .= $this->get_content_connected();
         } else {
             $connection = $DB->get_record('local_o365_connections', ['muserid' => $USER->id]);
             if (!empty($connection)) {
                 $uselogin = !empty($connection->uselogin) ? true : false;
                 $this->content->text .= $this->get_content_matched($connection->aadupn, $uselogin);
             } else {
                 $this->content->text .= $this->get_content_notconnected();
             }
         }
     } catch (\Exception $e) {
         $this->content->text = $e->getMessage();
     }
     return $this->content;
 }
Example #21
0
function profile_pagesetup()
{
    // register links --
    global $profile_id;
    global $PAGE;
    global $CFG;
    // don't clobber $page_owner, use a
    // local $pgowner instead for clarity
    $pgowner = $profile_id;
    if (isloggedin()) {
        if (defined("context") && context == "profile" && $pgowner == $_SESSION['userid']) {
            $PAGE->menu[] = array('name' => 'profile', 'html' => '<li><a href="' . $CFG->wwwroot . $_SESSION['username'] . '/profile/" class="selected">' . __gettext("Profile") . '</a></li>');
        } else {
            $PAGE->menu[] = array('name' => 'profile', 'html' => '<li><a href="' . $CFG->wwwroot . $_SESSION['username'] . '/profile/">' . __gettext("Profile") . '</a></li>');
        }
        if (profile_permissions_check("profile") && defined("context") && context == "profile") {
            if (user_type($pgowner) == "person") {
                $PAGE->menu_sub[] = array('name' => 'profile:edit', 'html' => '<a href="' . $CFG->wwwroot . 'profile/edit.php?profile_id=' . $pgowner . '">' . __gettext("Edit this profile") . '</a>');
                $PAGE->menu_sub[] = array('name' => 'profile:picedit', 'html' => '<a href="' . $CFG->wwwroot . '_icons/?context=profile&amp;profile_id=' . $pgowner . '">' . __gettext("Change site picture") . '</a>');
                if (!empty($CFG->uses_YUI)) {
                    $PAGE->menu_sub[] = array('name' => 'profile:widget:manage', 'html' => '<a href="' . $CFG->wwwroot . 'mod/widget/manage_widgets.php">' . __gettext("Manage widgets") . '</a>');
                }
                /*else {
                			$PAGE->menu_sub[] = array (
                				'name' => 'profile:widget:add',
                				'html' => '<a href="' . $CFG->wwwroot . 'mod/profile/add.php?owner=' . $pgowner . '">' . __gettext("Add widget") . '</a>');
                		}*/
            }
        }
    }
    $PAGE->search_menu[] = array('name' => __gettext("People"), 'user_type' => 'person');
}
 /**
  * Render the badge element (message count)
  *
  * @param null $userid
  * @return string
  */
 public function badge($userid = null)
 {
     global $USER, $DB, $COURSE, $PAGE;
     // Only for logged in folks and when we are enabled.
     if (!isset($USER->message_badge_disabled)) {
         if (mr_off('badge', 'message') or !isloggedin() or isguestuser()) {
             $USER->message_badge_disabled = true;
         } else {
             $USER->message_badge_disabled = $DB->record_exists('message_processors', array('name' => 'badge', 'enabled' => 0));
         }
     }
     if ($USER->message_badge_disabled) {
         return '';
     }
     if ($this->is_mobile()) {
         return $this->mobile($userid);
     }
     $repo = new message_output_badge_repository_message();
     $forwardurl = new moodle_url('/message/output/badge/view.php', array('action' => 'forward', 'courseid' => $COURSE->id));
     $total = $repo->count_user_unread_messages($userid);
     $PAGE->requires->js_init_call('M.snap_message_badge.init_badge', array($forwardurl->out(false), $COURSE->id), false, $this->get_js_module());
     if (!empty($total)) {
         $countdiv = html_writer::tag('span', $total, array('id' => html_writer::random_id(), 'class' => 'message_badge_count'));
     } else {
         $countdiv = '';
     }
     return $countdiv;
 }
Example #23
0
function pages_pagesetup()
{
    // backward compatibilty
    global $CFG, $PAGE;
    // menu keyword
    $CFG->templates->variables_substitute['pagesmenu'][] = 'pages_tplkw_menu';
    $CFG->templates->variables_substitute['page'][] = 'pages_tplkw_page';
    $CFG->templates->variables_substitute['sysadminemail'][] = 'pages_tplkw_sysadminemail';
    if (defined('context') && context == 'pages' || defined('pages_external')) {
        if (pages_enabled() && permissions_check('pages::edit', page_owner())) {
            $page_name = optional_param('page');
            $do_action = optional_param('do');
            if ($do_action != 'edit') {
                // new page link
                pages_submenu_add('pages:edit', __gettext('New page'), pages_url('New_page', 'pages::edit', page_owner()), 0);
                // edit this page link
                pages_submenu_add('pages:edit', __gettext('Edit this page'), pages_url($page_name, 'pages::edit', page_owner()), 1);
            }
        }
    }
    if (!PAGES_DISABLE_USERS && isloggedin()) {
        pages_menu_add('pages', __gettext('Your Content'), get_url($_SESSION['userid'], 'pages::'));
    }
    if (pages_enabled()) {
        // not show main site pages on sidebar
        sidebar_add(25, 'pages_sidebar', null, true, __gettext('Your Content'));
    }
}
Example #24
0
 function get_content()
 {
     global $USER, $CFG, $SESSION;
     $wwwroot = '';
     $signup = '';
     if ($this->content !== NULL) {
         return $this->content;
     }
     if (empty($CFG->loginhttps)) {
         $wwwroot = $CFG->wwwroot;
     } else {
         // This actually is not so secure ;-), 'cause we're
         // in unencrypted connection...
         $wwwroot = str_replace("http://", "https://", $CFG->wwwroot);
     }
     if (!empty($CFG->registerauth)) {
         $authplugin = get_auth_plugin($CFG->registerauth);
         if ($authplugin->can_signup()) {
             $signup = $wwwroot . '/login/signup.php';
         }
     }
     // TODO: now that we have multiauth it is hard to find out if there is a way to change password
     $forgot = $wwwroot . '/login/forgot_password.php';
     if (!empty($CFG->loginpasswordautocomplete)) {
         $autocomplete = 'autocomplete="off"';
     } else {
         $autocomplete = '';
     }
     $username = get_moodle_cookie();
     $this->content = new stdClass();
     $this->content->footer = '';
     $this->content->text = '';
     if (!isloggedin() or isguestuser()) {
         // Show the block
         if (empty($CFG->authloginviaemail)) {
             $strusername = get_string('username');
         } else {
             $strusername = get_string('usernameemail');
         }
         $this->content->text .= "\n" . '<form class="loginform" id="login" method="post" action="' . get_login_url() . '" ' . $autocomplete . '>';
         $this->content->text .= '<div class="c1 fld username"><label for="login_username">' . $strusername . '</label>';
         $this->content->text .= '<input type="text" name="username" id="login_username" value="' . s($username) . '" /></div>';
         $this->content->text .= '<div class="c1 fld password"><label for="login_password">' . get_string('password') . '</label>';
         $this->content->text .= '<input type="password" name="password" id="login_password" value="" ' . $autocomplete . ' /></div>';
         if (isset($CFG->rememberusername) and $CFG->rememberusername == 2) {
             $checked = $username ? 'checked="checked"' : '';
             $this->content->text .= '<div class="c1 rememberusername"><input type="checkbox" name="rememberusername" id="rememberusername" value="1" ' . $checked . '/>';
             $this->content->text .= ' <label for="rememberusername">' . get_string('rememberusername', 'admin') . '</label></div>';
         }
         $this->content->text .= '<div class="c1 btn"><input type="submit" value="' . get_string('login') . '" /></div>';
         $this->content->text .= "</form>\n";
         if (!empty($signup)) {
             $this->content->footer .= '<div><a href="' . $signup . '">' . get_string('startsignup') . '</a></div>';
         }
         if (!empty($forgot)) {
             $this->content->footer .= '<div><a href="' . $forgot . '">' . get_string('forgotaccount') . '</a></div>';
         }
     }
     return $this->content;
 }
 function get_content()
 {
     if ($this->content !== NULL) {
         return $this->content;
     }
     if (!isloggedin() || is_guest($this->context)) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->footer = '';
     $this->content->icons = array();
     if (!$this->import_checklist_plugin()) {
         $this->content->items = array(get_string('nochecklistplugin', 'block_checklist'));
         return $this->content;
     }
     if (!empty($this->config->checklistoverview)) {
         return $this->show_checklist_overview();
     }
     if (!empty($this->config->checklistid)) {
         return $this->show_single_checklist($this->config->checklistid);
     }
     // No checklist configured.
     $this->content->items = array(get_string('nochecklist', 'block_checklist'));
     return $this->content;
 }
Example #26
0
 function get_content()
 {
     global $CFG, $USER;
     if ($this->content !== NULL) {
         return $this->content;
     }
     if (!isloggedin()) {
         return $this->content;
     }
     if (is_siteadmin()) {
         return $this->content;
     }
     //this block is for students
     $usercontext = context_user::instance($USER->id);
     if (!has_capability('local/clclasses:enrollclass', $usercontext)) {
         return $this->content;
     }
     // Prep the content
     $this->content = new stdClass();
     require_once 'academic_status.php';
     //$id=optional_param('id',5,PARAM_INT);
     $events = get_semslist();
     $this->content->text = $events;
     return $this->content;
     // Prepare the footer for this block
     // No footer to display
     $this->content->footer = '';
     // Return the content object
     return $this->content;
 }
 /**
  * Renders a custom menu object (located in outputcomponents.php)
  *
  * The custom menu this method override the render_custom_menu function
  * in outputrenderers.php
  * @staticvar int $menucount
  * @param custom_menu $menu
  * @return string
  */
 protected function render_custom_menu(custom_menu $menu)
 {
     // If the menu has no children return an empty string
     if (!$menu->has_children()) {
         return '';
     }
     // Add a login or logout link
     if (isloggedin()) {
         $branchlabel = get_string('logout');
         $branchurl = new moodle_url('/login/logout.php');
     } else {
         $branchlabel = get_string('login');
         $branchurl = new moodle_url('/login/index.php');
     }
     $branch = $menu->add($branchlabel, $branchurl, $branchlabel, -1);
     // Initialise this custom menu
     $content = html_writer::start_tag('ul', array('class' => 'dropdown dropdown-horizontal'));
     // Render each child
     foreach ($menu->get_children() as $item) {
         $content .= $this->render_custom_menu_item($item);
     }
     // Close the open tags
     $content .= html_writer::end_tag('ul');
     // Return the custom menu
     return $content;
 }
 /**
  * Taken from /format/renderer.php
  * Generate a summary of the activites in a section
  *
  * @param stdClass $section The course_section entry from DB
  * @param stdClass $course the course record from DB
  * @param array    $mods (argument not used)
  * @return string HTML to output.
  */
 public static function section_activity_summary($section, $course, $mods)
 {
     global $CFG;
     require_once $CFG->libdir . '/completionlib.php';
     $modinfo = get_fast_modinfo($course);
     if (empty($modinfo->sections[$section->section])) {
         return '';
     }
     // Generate array with count of activities in this section.
     $sectionmods = array();
     $total = 0;
     $complete = 0;
     $cancomplete = isloggedin() && !isguestuser();
     $completioninfo = new completion_info($course);
     foreach ($modinfo->sections[$section->section] as $cmid) {
         $thismod = $modinfo->cms[$cmid];
         if ($thismod->uservisible) {
             if (isset($sectionmods[$thismod->modname])) {
                 $sectionmods[$thismod->modname]['name'] = $thismod->modplural;
                 $sectionmods[$thismod->modname]['count']++;
             } else {
                 $sectionmods[$thismod->modname]['name'] = $thismod->modfullname;
                 $sectionmods[$thismod->modname]['count'] = 1;
             }
             if ($cancomplete && $completioninfo->is_enabled($thismod) != COMPLETION_TRACKING_NONE) {
                 $total++;
                 $completiondata = $completioninfo->get_data($thismod, true);
                 if ($completiondata->completionstate == COMPLETION_COMPLETE || $completiondata->completionstate == COMPLETION_COMPLETE_PASS) {
                     $complete++;
                 }
             }
         }
     }
     if (empty($sectionmods)) {
         // No sections.
         return '';
     }
     // Output section activities summary.
     $o = '';
     $o .= "<div class='section-summary-activities mdl-right'>";
     foreach ($sectionmods as $mod) {
         $o .= "<span class='activity-count'>";
         $o .= $mod['name'] . ': ' . $mod['count'];
         $o .= "</span>";
     }
     $o .= "</div>";
     $a = false;
     // Output section completion data.
     if ($total > 0) {
         $a = new stdClass();
         $a->complete = $complete;
         $a->total = $total;
         $a->percentage = $complete / $total * 100;
         $o .= "<div class='section-summary-activities mdl-right'>";
         $o .= "<span class='activity-count'>" . get_string('progresstotal', 'completion', $a) . "</span>";
         $o .= "</div>";
     }
     $retobj = (object) array('output' => $o, 'progress' => $a, 'complete' => $complete, 'total' => $total);
     return $retobj;
 }
 /**
  *
  * @uses $USER
  */
 function get_content()
 {
     global $USER;
     if ($this->content !== NULL) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->items = array();
     $this->content->icons = array();
     $this->content->footer = "";
     if (!isset($USER->id) || $USER->id == 1) {
         $this->content->text = '<div class="description">' . get_string('noaccess', 'block_mynotes') . '</div>';
     } else {
         if (isloggedin()) {
             $systemcontext = get_context_instance(CONTEXT_SYSTEM, 0);
             $isadmin = has_capability('moodle/site:doanything', $systemcontext);
             if ($isadmin) {
                 // Creates entries for all three types of users
                 $this->fm_make_entries();
             }
             // If some parts are disabled, this will display the Fmanager properly to the user
             $this->fm_check_user_rights();
             $this->display_filemanager_link();
             $sharedlinks = count_records('fmanager_shared', 'userid', $USER->id);
             $sharedlinks += count_records('fmanager_shared', 'userid', 0);
             if ($sharedlinks > 0) {
                 $this->display_sharedfiles_link();
             }
             if ($isadmin) {
                 $this->display_admin_config();
             }
         }
     }
     return $this->content;
 }
Example #30
0
 function doListAnnotations($url, $username, $block, $all)
 {
     $handler = annotation_summary_query::handler_for_url($url);
     $user = get_record('user', 'username', $username);
     $summary = new annotation_summary_query($url, $handler, null, $user, null, false, $all);
     if ($summary->error) {
         $this->httpError(400, 'Bad Request', 'Bad URL 1');
         return null;
     } elseif (!isloggedin() && ANNOTATION_REQUIRE_USER) {
         $this->httpError(403, 'Forbidden', 'Anonymous listing not allowed');
         return null;
     } else {
         $querysql = $summary->sql('section_type, section_name, quote_title, start_block, start_line, start_word, start_char, end_block, end_line, end_word, end_char');
         $annotation_set = get_records_sql($querysql);
         $annotations = array();
         if ($annotation_set) {
             $i = 0;
             foreach ($annotation_set as $r) {
                 $annotations[$i++] = annotation_globals::record_to_annotation($r);
             }
         }
         $format = $this->getQueryParam('format', 'atom');
         $logurl = 'annotate.php?format=' . $format . ($user ? '&user='******'') . '&url=' . $url;
         add_to_log($summary->handler->courseid, 'annotation', 'list', $logurl);
         return $annotations;
     }
 }