当前位置: 首页>>代码示例>>PHP>>正文


PHP repository::get_editable_types方法代码示例

本文整理汇总了PHP中repository::get_editable_types方法的典型用法代码示例。如果您正苦于以下问题:PHP repository::get_editable_types方法的具体用法?PHP repository::get_editable_types怎么用?PHP repository::get_editable_types使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在repository的用法示例。


在下文中一共展示了repository::get_editable_types方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generate_user_settings


//.........这里部分代码省略.........
             $url = new moodle_url('/user/editadvanced.php', array('id' => $user->id, 'course' => $course->id));
             $usersetting->add(get_string('editmyprofile'), $url, self::TYPE_SETTING);
         } else {
             if (has_capability('moodle/user:editprofile', $usercontext) && !is_siteadmin($user) || $currentuser && has_capability('moodle/user:editownprofile', $systemcontext)) {
                 if ($userauthplugin && $userauthplugin->can_edit_profile()) {
                     $url = $userauthplugin->edit_profile_url();
                     if (empty($url)) {
                         $url = new moodle_url('/user/edit.php', array('id' => $user->id, 'course' => $course->id));
                     }
                     $usersetting->add(get_string('editmyprofile'), $url, self::TYPE_SETTING);
                 }
             }
         }
     }
     // Change password link
     if ($userauthplugin && $currentuser && !session_is_loggedinas() && !isguestuser() && has_capability('moodle/user:changeownpassword', $systemcontext) && $userauthplugin->can_change_password()) {
         $passwordchangeurl = $userauthplugin->change_password_url();
         if (empty($passwordchangeurl)) {
             $passwordchangeurl = new moodle_url('/login/change_password.php', array('id' => $course->id));
         }
         $usersetting->add(get_string("changepassword"), $passwordchangeurl, self::TYPE_SETTING);
     }
     // View the roles settings
     if (has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride', 'moodle/role:override', 'moodle/role:manage'), $usercontext)) {
         $roles = $usersetting->add(get_string('roles'), null, self::TYPE_SETTING);
         $url = new moodle_url('/admin/roles/usersroles.php', array('userid' => $user->id, 'courseid' => $course->id));
         $roles->add(get_string('thisusersroles', 'role'), $url, self::TYPE_SETTING);
         $assignableroles = get_assignable_roles($usercontext, ROLENAME_BOTH);
         if (!empty($assignableroles)) {
             $url = new moodle_url('/admin/roles/assign.php', array('contextid' => $usercontext->id, 'userid' => $user->id, 'courseid' => $course->id));
             $roles->add(get_string('assignrolesrelativetothisuser', 'role'), $url, self::TYPE_SETTING);
         }
         if (has_capability('moodle/role:review', $usercontext) || count(get_overridable_roles($usercontext, ROLENAME_BOTH)) > 0) {
             $url = new moodle_url('/admin/roles/permissions.php', array('contextid' => $usercontext->id, 'userid' => $user->id, 'courseid' => $course->id));
             $roles->add(get_string('permissions', 'role'), $url, self::TYPE_SETTING);
         }
         $url = new moodle_url('/admin/roles/check.php', array('contextid' => $usercontext->id, 'userid' => $user->id, 'courseid' => $course->id));
         $roles->add(get_string('checkpermissions', 'role'), $url, self::TYPE_SETTING);
     }
     // Portfolio
     if ($currentuser && !empty($CFG->enableportfolios) && has_capability('moodle/portfolio:export', $systemcontext)) {
         require_once $CFG->libdir . '/portfoliolib.php';
         if (portfolio_instances(true, false)) {
             $portfolio = $usersetting->add(get_string('portfolios', 'portfolio'), null, self::TYPE_SETTING);
             $url = new moodle_url('/user/portfolio.php', array('courseid' => $course->id));
             $portfolio->add(get_string('configure', 'portfolio'), $url, self::TYPE_SETTING);
             $url = new moodle_url('/user/portfoliologs.php', array('courseid' => $course->id));
             $portfolio->add(get_string('logs', 'portfolio'), $url, self::TYPE_SETTING);
         }
     }
     $enablemanagetokens = false;
     if (!empty($CFG->enablerssfeeds)) {
         $enablemanagetokens = true;
     } else {
         if (!is_siteadmin($USER->id) && !empty($CFG->enablewebservices) && has_capability('moodle/webservice:createtoken', get_system_context())) {
             $enablemanagetokens = true;
         }
     }
     // Security keys
     if ($currentuser && $enablemanagetokens) {
         $url = new moodle_url('/user/managetoken.php', array('sesskey' => sesskey()));
         $usersetting->add(get_string('securitykeys', 'webservice'), $url, self::TYPE_SETTING);
     }
     // Repository
     if (!$currentuser && $usercontext->contextlevel == CONTEXT_USER) {
         if (!$this->cache->cached('contexthasrepos' . $usercontext->id)) {
             require_once $CFG->dirroot . '/repository/lib.php';
             $editabletypes = repository::get_editable_types($usercontext);
             $haseditabletypes = !empty($editabletypes);
             unset($editabletypes);
             $this->cache->set('contexthasrepos' . $usercontext->id, $haseditabletypes);
         } else {
             $haseditabletypes = $this->cache->{'contexthasrepos' . $usercontext->id};
         }
         if ($haseditabletypes) {
             $url = new moodle_url('/repository/manage_instances.php', array('contextid' => $usercontext->id));
             $usersetting->add(get_string('repositories', 'repository'), $url, self::TYPE_SETTING);
         }
     }
     // Messaging
     if ($currentuser && has_capability('moodle/user:editownmessageprofile', $systemcontext) || !isguestuser($user) && has_capability('moodle/user:editmessageprofile', $usercontext) && !is_primary_admin($user->id)) {
         $url = new moodle_url('/message/edit.php', array('id' => $user->id));
         $usersetting->add(get_string('editmymessage', 'message'), $url, self::TYPE_SETTING);
     }
     // Blogs
     if ($currentuser && !empty($CFG->bloglevel)) {
         $blog = $usersetting->add(get_string('blogs', 'blog'), null, navigation_node::TYPE_CONTAINER, null, 'blogs');
         $blog->add(get_string('preferences', 'blog'), new moodle_url('/blog/preferences.php'), navigation_node::TYPE_SETTING);
         if (!empty($CFG->useexternalblogs) && $CFG->maxexternalblogsperuser > 0 && has_capability('moodle/blog:manageexternal', get_context_instance(CONTEXT_SYSTEM))) {
             $blog->add(get_string('externalblogs', 'blog'), new moodle_url('/blog/external_blogs.php'), navigation_node::TYPE_SETTING);
             $blog->add(get_string('addnewexternalblog', 'blog'), new moodle_url('/blog/external_blog_edit.php'), navigation_node::TYPE_SETTING);
         }
     }
     // Login as ...
     if (!$user->deleted and !$currentuser && !session_is_loggedinas() && has_capability('moodle/user:loginas', $coursecontext) && !is_siteadmin($user->id)) {
         $url = new moodle_url('/course/loginas.php', array('id' => $course->id, 'user' => $user->id, 'sesskey' => sesskey()));
         $usersetting->add(get_string('loginas'), $url, self::TYPE_SETTING);
     }
     return $usersetting;
 }
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:101,代码来源:navigationlib.php

示例2: display_instances_list

 /**
  * Display a repository instance list (with edit/delete/create links)
  *
  * @static
  * @param stdClass $context the context for which we display the instance
  * @param string $typename if set, we display only one type of instance
  */
 public static function display_instances_list($context, $typename = null)
 {
     global $CFG, $USER, $OUTPUT;
     $output = $OUTPUT->box_start('generalbox');
     //if the context is SYSTEM, so we call it from administration page
     $admin = $context->id == SYSCONTEXTID ? true : false;
     if ($admin) {
         $baseurl = new moodle_url('/' . $CFG->admin . '/repositoryinstance.php', array('sesskey' => sesskey()));
         $output .= $OUTPUT->heading(get_string('siteinstances', 'repository'));
     } else {
         $baseurl = new moodle_url('/repository/manage_instances.php', array('contextid' => $context->id, 'sesskey' => sesskey()));
     }
     $namestr = get_string('name');
     $pluginstr = get_string('plugin', 'repository');
     $settingsstr = get_string('settings');
     $deletestr = get_string('delete');
     // Retrieve list of instances. In administration context we want to display all
     // instances of a type, even if this type is not visible. In course/user context we
     // want to display only visible instances, but for every type types. The repository::get_instances()
     // third parameter displays only visible type.
     $params = array();
     $params['context'] = array($context);
     $params['currentcontext'] = $context;
     $params['return_types'] = 0;
     $params['onlyvisible'] = !$admin;
     $params['type'] = $typename;
     $instances = repository::get_instances($params);
     $instancesnumber = count($instances);
     $alreadyplugins = array();
     $table = new html_table();
     $table->head = array($namestr, $pluginstr, $settingsstr, $deletestr);
     $table->align = array('left', 'left', 'center', 'center');
     $table->data = array();
     $updowncount = 1;
     foreach ($instances as $i) {
         $settings = '';
         $delete = '';
         $type = repository::get_type_by_id($i->options['typeid']);
         if ($type->get_contextvisibility($context)) {
             if (!$i->readonly) {
                 $settingurl = new moodle_url($baseurl);
                 $settingurl->param('type', $i->options['type']);
                 $settingurl->param('edit', $i->id);
                 $settings .= html_writer::link($settingurl, $settingsstr);
                 $deleteurl = new moodle_url($baseurl);
                 $deleteurl->param('delete', $i->id);
                 $deleteurl->param('type', $i->options['type']);
                 $delete .= html_writer::link($deleteurl, $deletestr);
             }
         }
         $type = repository::get_type_by_id($i->options['typeid']);
         $table->data[] = array(format_string($i->name), $type->get_readablename(), $settings, $delete);
         //display a grey row if the type is defined as not visible
         if (isset($type) && !$type->get_visible()) {
             $table->rowclasses[] = 'dimmed_text';
         } else {
             $table->rowclasses[] = '';
         }
         if (!in_array($i->name, $alreadyplugins)) {
             $alreadyplugins[] = $i->name;
         }
     }
     $output .= html_writer::table($table);
     $instancehtml = '<div>';
     $addable = 0;
     //if no type is set, we can create all type of instance
     if (!$typename) {
         $instancehtml .= '<h3>';
         $instancehtml .= get_string('createrepository', 'repository');
         $instancehtml .= '</h3><ul>';
         $types = repository::get_editable_types($context);
         foreach ($types as $type) {
             if (!empty($type) && $type->get_visible()) {
                 // If the user does not have the permission to view the repository, it won't be displayed in
                 // the list of instances. Hiding the link to create new instances will prevent the
                 // user from creating them without being able to find them afterwards, which looks like a bug.
                 if (!has_capability('repository/' . $type->get_typename() . ':view', $context)) {
                     continue;
                 }
                 $instanceoptionnames = repository::static_function($type->get_typename(), 'get_instance_option_names');
                 if (!empty($instanceoptionnames)) {
                     $baseurl->param('new', $type->get_typename());
                     $instancehtml .= '<li><a href="' . $baseurl->out() . '">' . get_string('createxxinstance', 'repository', get_string('pluginname', 'repository_' . $type->get_typename())) . '</a></li>';
                     $baseurl->remove_params('new');
                     $addable++;
                 }
             }
         }
         $instancehtml .= '</ul>';
     } else {
         $instanceoptionnames = repository::static_function($typename, 'get_instance_option_names');
         if (!empty($instanceoptionnames)) {
             //create a unique type of instance
//.........这里部分代码省略.........
开发者ID:isuruAb,项目名称:moodle,代码行数:101,代码来源:lib.php

示例3: generate_user_settings


//.........这里部分代码省略.........
             if ($currentuser && has_capability('moodle/user:editownprofile', $systemcontext) || has_capability('moodle/user:editprofile', $usercontext)) {
                 $url = new moodle_url('/user/editor.php', array('id' => $user->id, 'course' => $course->id));
                 $useraccount->add(get_string('editorpreferences'), $url, self::TYPE_SETTING);
             }
         }
     }
     // Add "Course preferences" link.
     if (isloggedin() && !isguestuser($user)) {
         if ($currentuser && has_capability('moodle/user:editownprofile', $systemcontext) || has_capability('moodle/user:editprofile', $usercontext)) {
             $url = new moodle_url('/user/course.php', array('id' => $user->id, 'course' => $course->id));
             $useraccount->add(get_string('coursepreferences'), $url, self::TYPE_SETTING, null, 'coursepreferences');
         }
     }
     // View the roles settings.
     if (has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride', 'moodle/role:override', 'moodle/role:manage'), $usercontext)) {
         $roles = $usersetting->add(get_string('roles'), null, self::TYPE_SETTING);
         $url = new moodle_url('/admin/roles/usersroles.php', array('userid' => $user->id, 'courseid' => $course->id));
         $roles->add(get_string('thisusersroles', 'role'), $url, self::TYPE_SETTING);
         $assignableroles = get_assignable_roles($usercontext, ROLENAME_BOTH);
         if (!empty($assignableroles)) {
             $url = new moodle_url('/admin/roles/assign.php', array('contextid' => $usercontext->id, 'userid' => $user->id, 'courseid' => $course->id));
             $roles->add(get_string('assignrolesrelativetothisuser', 'role'), $url, self::TYPE_SETTING);
         }
         if (has_capability('moodle/role:review', $usercontext) || count(get_overridable_roles($usercontext, ROLENAME_BOTH)) > 0) {
             $url = new moodle_url('/admin/roles/permissions.php', array('contextid' => $usercontext->id, 'userid' => $user->id, 'courseid' => $course->id));
             $roles->add(get_string('permissions', 'role'), $url, self::TYPE_SETTING);
         }
         $url = new moodle_url('/admin/roles/check.php', array('contextid' => $usercontext->id, 'userid' => $user->id, 'courseid' => $course->id));
         $roles->add(get_string('checkpermissions', 'role'), $url, self::TYPE_SETTING);
     }
     // Repositories.
     if (!$this->cache->cached('contexthasrepos' . $usercontext->id)) {
         require_once $CFG->dirroot . '/repository/lib.php';
         $editabletypes = repository::get_editable_types($usercontext);
         $haseditabletypes = !empty($editabletypes);
         unset($editabletypes);
         $this->cache->set('contexthasrepos' . $usercontext->id, $haseditabletypes);
     } else {
         $haseditabletypes = $this->cache->{'contexthasrepos' . $usercontext->id};
     }
     if ($haseditabletypes) {
         $repositories = $usersetting->add(get_string('repositories', 'repository'), null, self::TYPE_SETTING);
         $repositories->add(get_string('manageinstances', 'repository'), new moodle_url('/repository/manage_instances.php', array('contextid' => $usercontext->id)));
     }
     // Portfolio.
     if ($currentuser && !empty($CFG->enableportfolios) && has_capability('moodle/portfolio:export', $systemcontext)) {
         require_once $CFG->libdir . '/portfoliolib.php';
         if (portfolio_has_visible_instances()) {
             $portfolio = $usersetting->add(get_string('portfolios', 'portfolio'), null, self::TYPE_SETTING);
             $url = new moodle_url('/user/portfolio.php', array('courseid' => $course->id));
             $portfolio->add(get_string('configure', 'portfolio'), $url, self::TYPE_SETTING);
             $url = new moodle_url('/user/portfoliologs.php', array('courseid' => $course->id));
             $portfolio->add(get_string('logs', 'portfolio'), $url, self::TYPE_SETTING);
         }
     }
     $enablemanagetokens = false;
     if (!empty($CFG->enablerssfeeds)) {
         $enablemanagetokens = true;
     } else {
         if (!is_siteadmin($USER->id) && !empty($CFG->enablewebservices) && has_capability('moodle/webservice:createtoken', context_system::instance())) {
             $enablemanagetokens = true;
         }
     }
     // Security keys.
     if ($currentuser && $enablemanagetokens) {
         $url = new moodle_url('/user/managetoken.php', array('sesskey' => sesskey()));
开发者ID:evltuma,项目名称:moodle,代码行数:67,代码来源:navigationlib.php

示例4: load_course_settings


//.........这里部分代码省略.........
                         //stop when the first visible plugin is found
                         $reportavailable = true;
                         break;
                     }
                 }
             }
         }
     }
     if ($reportavailable) {
         $url = new moodle_url('/grade/report/index.php', array('id' => $course->id));
         $gradenode = $coursenode->add(get_string('grades'), $url, self::TYPE_SETTING, null, 'grades', new pix_icon('i/grades', ''));
     }
     //  Add outcome if permitted
     if (!empty($CFG->enableoutcomes) && has_capability('moodle/course:update', $coursecontext)) {
         $url = new moodle_url('/grade/edit/outcome/course.php', array('id' => $course->id));
         $coursenode->add(get_string('outcomes', 'grades'), $url, self::TYPE_SETTING, null, 'outcomes', new pix_icon('i/outcomes', ''));
     }
     //Add badges navigation
     require_once $CFG->libdir . '/badgeslib.php';
     badges_add_course_navigation($coursenode, $course);
     // Backup this course
     if (has_capability('moodle/backup:backupcourse', $coursecontext)) {
         $url = new moodle_url('/backup/backup.php', array('id' => $course->id));
         $coursenode->add(get_string('backup'), $url, self::TYPE_SETTING, null, 'backup', new pix_icon('i/backup', ''));
     }
     // Restore to this course
     if (has_capability('moodle/restore:restorecourse', $coursecontext)) {
         $url = new moodle_url('/backup/restorefile.php', array('contextid' => $coursecontext->id));
         $coursenode->add(get_string('restore'), $url, self::TYPE_SETTING, null, 'restore', new pix_icon('i/restore', ''));
     }
     // Import data from other courses
     if (has_capability('moodle/restore:restoretargetimport', $coursecontext)) {
         $url = new moodle_url('/backup/import.php', array('id' => $course->id));
         $coursenode->add(get_string('import'), $url, self::TYPE_SETTING, null, 'import', new pix_icon('i/import', ''));
     }
     // Publish course on a hub
     if (has_capability('moodle/course:publish', $coursecontext)) {
         $url = new moodle_url('/course/publish/index.php', array('id' => $course->id));
         $coursenode->add(get_string('publish'), $url, self::TYPE_SETTING, null, 'publish', new pix_icon('i/publish', ''));
     }
     // Reset this course
     if (has_capability('moodle/course:reset', $coursecontext)) {
         $url = new moodle_url('/course/reset.php', array('id' => $course->id));
         $coursenode->add(get_string('reset'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/return', ''));
     }
     // Questions
     require_once $CFG->libdir . '/questionlib.php';
     question_extend_settings_navigation($coursenode, $coursecontext)->trim_if_empty();
     if (has_capability('moodle/course:update', $coursecontext)) {
         // Repository Instances
         if (!$this->cache->cached('contexthasrepos' . $coursecontext->id)) {
             require_once $CFG->dirroot . '/repository/lib.php';
             $editabletypes = repository::get_editable_types($coursecontext);
             $haseditabletypes = !empty($editabletypes);
             unset($editabletypes);
             $this->cache->set('contexthasrepos' . $coursecontext->id, $haseditabletypes);
         } else {
             $haseditabletypes = $this->cache->{'contexthasrepos' . $coursecontext->id};
         }
         if ($haseditabletypes) {
             $url = new moodle_url('/repository/manage_instances.php', array('contextid' => $coursecontext->id));
             $coursenode->add(get_string('repositories'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/repository', ''));
         }
     }
     // Manage files
     if ($course->legacyfiles == 2 and has_capability('moodle/course:managefiles', $coursecontext)) {
         // hidden in new courses and courses where legacy files were turned off
         $url = new moodle_url('/files/index.php', array('contextid' => $coursecontext->id));
         $coursenode->add(get_string('courselegacyfiles'), $url, self::TYPE_SETTING, null, 'coursefiles', new pix_icon('i/folder', ''));
     }
     // Switch roles
     $roles = array();
     $assumedrole = $this->in_alternative_role();
     if ($assumedrole !== false) {
         $roles[0] = get_string('switchrolereturn');
     }
     if (has_capability('moodle/role:switchroles', $coursecontext)) {
         $availableroles = get_switchable_roles($coursecontext);
         if (is_array($availableroles)) {
             foreach ($availableroles as $key => $role) {
                 if ($assumedrole == (int) $key) {
                     continue;
                 }
                 $roles[$key] = $role;
             }
         }
     }
     if (is_array($roles) && count($roles) > 0) {
         $switchroles = $this->add(get_string('switchroleto'));
         if (count($roles) == 1 && array_key_exists(0, $roles) || $assumedrole !== false) {
             $switchroles->force_open();
         }
         foreach ($roles as $key => $name) {
             $url = new moodle_url('/course/switchrole.php', array('id' => $course->id, 'sesskey' => sesskey(), 'switchrole' => $key, 'returnurl' => $this->page->url->out_as_local_url(false)));
             $switchroles->add($name, $url, self::TYPE_SETTING, null, $key, new pix_icon('i/switchrole', ''));
         }
     }
     // Return we are done
     return $coursenode;
 }
开发者ID:achocoza,项目名称:moodle26,代码行数:101,代码来源:navigationlib.php

示例5: tabobject

    if (portfolio_instances(true, false)) {
        $toprow[] = new tabobject('portfolios', $CFG->wwwroot . '/user/portfolio.php', get_string('portfolios', 'portfolio'));
        if (in_array($currenttab, array('portfolioconf', 'portfoliologs'))) {
            $inactive = array('portfolios');
            $activetwo = array('portfolios');
            $secondrow = array();
            $secondrow[] = new tabobject('portfolioconf', $CFG->wwwroot . '/user/portfolio.php', get_string('configure', 'portfolio'));
            $secondrow[] = new tabobject('portfoliologs', $CFG->wwwroot . '/user/portfoliologs.php', get_string('logs', 'portfolio'));
        }
    }
}
// Repository Tab
if (!empty($user) and $user->id == $USER->id) {
    require_once $CFG->dirroot . '/repository/lib.php';
    $usercontext = get_context_instance(CONTEXT_USER, $user->id);
    $editabletypes = repository::get_editable_types($usercontext);
    if (!empty($usercontext) && $usercontext->contextlevel == CONTEXT_USER && !empty($editabletypes)) {
        $toprow[] = new tabobject('repositories', $CFG->wwwroot . '/repository/manage_instances.php?contextid=' . $usercontext->id, get_string('repositories', 'repository'));
    }
}
/// Messaging tab
if (!empty($user) and empty($userindexpage) and has_capability('moodle/user:editownmessageprofile', $systemcontext)) {
    $toprow[] = new tabobject('editmessage', $CFG->wwwroot . '/message/edit.php?id=' . $user->id . '&amp;course=' . $course->id, get_string('editmymessage', 'message'));
}
/// Add second row to display if there is one
if (!empty($secondrow)) {
    $tabs = array($toprow, $secondrow);
} else {
    $tabs = array($toprow);
}
if ($currenttab == 'editprofile' && $user->id == $USER->id && user_not_fully_set_up($USER)) {
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:31,代码来源:tabs.php

示例6: get_content


//.........这里部分代码省略.........
                 $this->content->items[] = '<span class="dimmed_text">' . $strchildcourses . '</span>';
                 $this->content->icons[] = '<img src="' . $CFG->pixpath . '/i/course.gif" class="icon" alt="" />';
             }
         }
     }
     /// Manage groups in this course
     if ($course->id !== SITEID && ($course->groupmode || !$course->groupmodeforce) && has_capability('moodle/course:managegroups', $context)) {
         $strgroups = get_string('groups');
         $this->content->items[] = '<a title="' . $strgroups . '" href="' . $CFG->wwwroot . '/group/index.php?id=' . $course->id . '">' . $strgroups . '</a>';
         $this->content->icons[] = '<img src="' . $CFG->pixpath . '/i/group.gif" class="icon" alt="" />';
     }
     /// Backup this course
     if ($course->id !== SITEID and has_capability('moodle/site:backup', $context)) {
         $this->content->items[] = '<a href="' . $CFG->wwwroot . '/backup/backup.php?id=' . $course->id . '">' . get_string('backup') . '</a>';
         $this->content->icons[] = '<img src="' . $CFG->pixpath . '/i/backup.gif" class="icon" alt="" />';
     }
     /// Restore to this course
     if ($course->id !== SITEID and has_capability('moodle/site:restore', $context)) {
         $this->content->items[] = '<a href="' . $CFG->wwwroot . '/files/index.php?id=' . $course->id . '&amp;wdir=/backupdata">' . get_string('restore') . '</a>';
         $this->content->icons[] = '<img src="' . $CFG->pixpath . '/i/restore.gif" class="icon" alt="" />';
     }
     /// Import data from other courses
     if ($course->id !== SITEID and has_capability('moodle/site:import', $context)) {
         $this->content->items[] = '<a href="' . $CFG->wwwroot . '/course/import.php?id=' . $course->id . '">' . get_string('import') . '</a>';
         $this->content->icons[] = '<img src="' . $CFG->pixpath . '/i/restore.gif" class="icon" alt="" />';
     }
     /// Reset this course
     if ($course->id !== SITEID and has_capability('moodle/course:reset', $context)) {
         $this->content->items[] = '<a href="' . $CFG->wwwroot . '/course/reset.php?id=' . $course->id . '">' . get_string('reset') . '</a>';
         $this->content->icons[] = '<img src="' . $CFG->pixpath . '/i/return.gif" class="icon" alt="" />';
     }
     /// View course reports
     if ($course->id !== SITEID and has_capability('moodle/site:viewreports', $context)) {
         // basic capability for listing of reports
         $this->content->items[] = '<a href="' . $CFG->wwwroot . '/course/report.php?id=' . $course->id . '">' . get_string('reports') . '</a>';
         $this->content->icons[] = '<img src="' . $CFG->pixpath . '/i/stats.gif" class="icon" alt="" />';
     }
     /// Manage questions
     if ($course->id !== SITEID) {
         $questionlink = '';
         $questioncaps = array('moodle/question:add', 'moodle/question:editmine', 'moodle/question:editall', 'moodle/question:viewmine', 'moodle/question:viewall', 'moodle/question:movemine', 'moodle/question:moveall');
         foreach ($questioncaps as $questioncap) {
             if (has_capability($questioncap, $context)) {
                 $questionlink = 'edit.php';
                 break;
             }
         }
         if (!$questionlink && has_capability('moodle/question:managecategory', $context)) {
             $questionlink = 'category.php';
         }
         if ($questionlink) {
             $this->content->items[] = '<a href="' . $CFG->wwwroot . '/question/' . $questionlink . '?courseid=' . $course->id . '">' . get_string('questions', 'quiz') . '</a>';
             $this->content->icons[] = '<img src="' . $CFG->pixpath . '/i/questions.gif" class="icon" alt="" />';
         }
     }
     /// Repository Instances
     require_once $CFG->dirroot . '/repository/lib.php';
     $editabletypes = repository::get_editable_types($context);
     if ($course->id !== SITEID && has_capability('moodle/course:update', $context) && !empty($editabletypes)) {
         $this->content->items[] = '<a href="' . $CFG->wwwroot . '/repository/manage_instances.php?contextid=' . $context->id . '">' . get_string('repositories') . '</a>';
         $this->content->icons[] = '<img src="' . $CFG->pixpath . '/i/repository.png" alt=""/>';
     }
     /// Manage files
     if ($course->id !== SITEID and has_capability('moodle/course:managefiles', $context)) {
         $this->content->items[] = '<a href="' . $CFG->wwwroot . '/files/index.php?id=' . $course->id . '">' . get_string('files') . '</a>';
         $this->content->icons[] = '<img src="' . $CFG->pixpath . '/i/files.gif" class="icon" alt=""/>';
     }
     /// Authorize hooks
     if ($course->enrol == 'authorize' || empty($course->enrol) && $CFG->enrol == 'authorize' && $course->id !== SITEID) {
         require_once $CFG->dirroot . '/enrol/authorize/const.php';
         $paymenturl = '<a href="' . $CFG->wwwroot . '/enrol/authorize/index.php?course=' . $course->id . '">' . get_string('payments') . '</a> ';
         if (has_capability('enrol/authorize:managepayments', $context)) {
             if ($cnt = $DB->count_records('enrol_authorize', array('status' => AN_STATUS_AUTH, 'courseid' => $course->id))) {
                 $paymenturl .= '<a href="' . $CFG->wwwroot . '/enrol/authorize/index.php?status=' . AN_STATUS_AUTH . '&amp;course=' . $course->id . '">' . get_string('paymentpending', 'moodle', $cnt) . '</a>';
             }
         }
         $this->content->items[] = $paymenturl;
         $this->content->icons[] = '<img src="' . $CFG->pixpath . '/i/payment.gif" class="icon" alt="" />';
     }
     /// Unenrol link
     if (empty($course->metacourse) && $course->id !== SITEID) {
         if (has_capability('moodle/legacy:guest', $context, NULL, false)) {
             // Are a guest now
             $this->content->items[] = '<a href="' . $CFG->wwwroot . '/course/enrol.php?id=' . $course->id . '">' . get_string('enrolme', '', format_string($course->shortname)) . '</a>';
             $this->content->icons[] = '<img src="' . $CFG->pixpath . '/i/user.gif" class="icon" alt="" />';
         } else {
             if (has_capability('moodle/role:unassignself', $context, NULL, false) and get_user_roles($context, $USER->id, false)) {
                 // Have some role
                 $this->content->items[] = '<a href="' . $CFG->wwwroot . '/course/unenrol.php?id=' . $course->id . '">' . get_string('unenrolme', '', format_string($course->shortname)) . '</a>';
                 $this->content->icons[] = '<img src="' . $CFG->pixpath . '/i/user.gif" class="icon" alt="" />';
             }
         }
     }
     /// Link to the user own profile (except guests)
     if (!isguestuser() and isloggedin()) {
         $this->content->items[] = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $USER->id . '&amp;course=' . $course->id . '">' . get_string('profile') . '</a>';
         $this->content->icons[] = '<img src="' . $CFG->pixpath . '/i/user.gif" alt="" />';
     }
     return $this->content;
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:101,代码来源:block_admin.php

示例7: display_instances_list

 /**
  * Display a repository instance list (with edit/delete/create links)
  * @global object $CFG
  * @global object $USER
  * @param object $context the context for which we display the instance
  * @param string $typename if set, we display only one type of instance
  */
 public static function display_instances_list($context, $typename = null)
 {
     global $CFG, $USER, $OUTPUT;
     $output = $OUTPUT->box_start('generalbox');
     //if the context is SYSTEM, so we call it from administration page
     $admin = $context->id == SYSCONTEXTID ? true : false;
     if ($admin) {
         $baseurl = "{$CFG->httpswwwroot}/{$CFG->admin}/repositoryinstance.php?sesskey=" . sesskey();
         $output .= "<div ><h2 style='text-align: center'>" . get_string('siteinstances', 'repository') . " ";
         $output .= "</h2></div>";
     } else {
         $baseurl = $CFG->httpswwwroot . '/repository/manage_instances.php?contextid=' . $context->id . '&amp;sesskey=' . sesskey();
     }
     $namestr = get_string('name');
     $pluginstr = get_string('plugin', 'repository');
     $settingsstr = get_string('settings');
     $deletestr = get_string('delete');
     $updown = get_string('updown', 'repository');
     //retrieve list of instances. In administration context we want to display all
     //instances of a type, even if this type is not visible. In course/user context we
     //want to display only visible instances, but for every type types. The repository_get_instances()
     //third parameter displays only visible type.
     $instances = repository::get_instances(array($context), null, !$admin, $typename);
     $instancesnumber = count($instances);
     $alreadyplugins = array();
     $table = new html_table();
     $table->head = array($namestr, $pluginstr, $deletestr, $settingsstr);
     $table->align = array('left', 'left', 'center', 'center');
     $table->data = array();
     $updowncount = 1;
     foreach ($instances as $i) {
         $settings = '';
         $delete = '';
         $settings .= '<a href="' . $baseurl . '&amp;type=' . $typename . '&amp;edit=' . $i->id . '">' . $settingsstr . '</a>' . "\n";
         if (!$i->readonly) {
             $delete .= '<a href="' . $baseurl . '&amp;type=' . $typename . '&amp;delete=' . $i->id . '">' . $deletestr . '</a>' . "\n";
         }
         $type = repository::get_type_by_id($i->options['typeid']);
         $table->data[] = array($i->name, $type->get_readablename(), $delete, $settings);
         //display a grey row if the type is defined as not visible
         if (isset($type) && !$type->get_visible()) {
             $table->rowclasses[] = 'dimmed_text';
         } else {
             $table->rowclasses[] = '';
         }
         if (!in_array($i->name, $alreadyplugins)) {
             $alreadyplugins[] = $i->name;
         }
     }
     $output .= $OUTPUT->table($table);
     $instancehtml = '<div>';
     $addable = 0;
     //if no type is set, we can create all type of instance
     if (!$typename) {
         $instancehtml .= '<h3>';
         $instancehtml .= get_string('createrepository', 'repository');
         $instancehtml .= '</h3><ul>';
         $types = repository::get_editable_types($context);
         foreach ($types as $type) {
             if (!empty($type) && $type->get_visible()) {
                 $instanceoptionnames = repository::static_function($type->get_typename(), 'get_instance_option_names');
                 if (!empty($instanceoptionnames)) {
                     $instancehtml .= '<li><a href="' . $baseurl . '&amp;new=' . $type->get_typename() . '">' . get_string('createxxinstance', 'repository', get_string('repositoryname', 'repository_' . $type->get_typename())) . '</a></li>';
                     $addable++;
                 }
             }
         }
         $instancehtml .= '</ul>';
     } else {
         $instanceoptionnames = repository::static_function($typename, 'get_instance_option_names');
         if (!empty($instanceoptionnames)) {
             //create a unique type of instance
             $addable = 1;
             $instancehtml .= "<form action='" . $baseurl . "&amp;new=" . $typename . "' method='post'>\n                    <p style='text-align:center'><input type='submit' value='" . get_string('createinstance', 'repository') . "'/></p>\n                    </form>";
         }
     }
     if ($addable) {
         $instancehtml .= '</div>';
         $output .= $instancehtml;
     }
     $output .= $OUTPUT->box_end();
     //print the list + creation links
     print $output;
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:91,代码来源:lib.php


注:本文中的repository::get_editable_types方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。