本文整理匯總了PHP中is_primary_admin函數的典型用法代碼示例。如果您正苦於以下問題:PHP is_primary_admin函數的具體用法?PHP is_primary_admin怎麽用?PHP is_primary_admin使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了is_primary_admin函數的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}
示例2: print_error
// Actually suspend the user.
company_user::suspend($user->id);
}
} else {
if ($unsuspend and confirm_sesskey()) {
// Unsuspends a selected user, after confirmation.
if (!iomad::has_capability('block/iomad_company_admin:editusers', $systemcontext)) {
print_error('nopermissions', 'error', '', 'suspend a user');
}
if (!($user = $DB->get_record('user', array('id' => $unsuspend)))) {
print_error('nousers', 'error');
}
if (!company::check_canedit_user($companyid, $user->id)) {
print_error('invaliduserid');
}
if (is_primary_admin($user->id)) {
print_error('nopermissions', 'error', '', 'delete the primary admin user');
}
if ($confirm != md5($unsuspend)) {
$fullname = fullname($user, true);
echo $OUTPUT->heading(get_string('unsuspenduser', 'block_iomad_company_admin') . " " . $fullname);
$optionsyes = array('unsuspend' => $unsuspend, 'confirm' => md5($unsuspend), 'sesskey' => sesskey());
echo $OUTPUT->confirm(get_string('unsuspendcheckfull', 'block_iomad_company_admin', "'{$fullname}'"), new moodle_url('editusers.php', $optionsyes), 'editusers.php');
echo $OUTPUT->footer();
die;
} else {
// Actually unsuspend the user.
company_user::unsuspend($user->id);
}
} else {
if ($acl and confirm_sesskey()) {
示例3: generate_user_settings
//.........這裏部分代碼省略.........
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()));
$useraccount->add(get_string('securitykeys', 'webservice'), $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));
$useraccount->add(get_string('messaging', 'message'), $url, self::TYPE_SETTING);
}
// Blogs.
if ($currentuser && !empty($CFG->enableblogs)) {
$blog = $usersetting->add(get_string('blogs', 'blog'), null, navigation_node::TYPE_CONTAINER, null, 'blogs');
if (has_capability('moodle/blog:view', $systemcontext)) {
$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', $systemcontext)) {
$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);
}
// Remove the blog node if empty.
$blog->trim_if_empty();
}
// Badges.
if ($currentuser && !empty($CFG->enablebadges)) {
$badges = $usersetting->add(get_string('badges'), null, navigation_node::TYPE_CONTAINER, null, 'badges');
if (has_capability('moodle/badges:manageownbadges', $usercontext)) {
$url = new moodle_url('/badges/mybadges.php');
$badges->add(get_string('managebadges', 'badges'), $url, self::TYPE_SETTING);
}
$badges->add(get_string('preferences', 'badges'), new moodle_url('/badges/preferences.php'), navigation_node::TYPE_SETTING);
if (!empty($CFG->badges_allowexternalbackpack)) {
$badges->add(get_string('backpackdetails', 'badges'), new moodle_url('/badges/mybackpack.php'), navigation_node::TYPE_SETTING);
}
}
// Let plugins hook into user settings navigation.
$pluginsfunction = get_plugins_with_function('extend_navigation_user_settings', 'lib.php');
foreach ($pluginsfunction as $plugintype => $plugins) {
foreach ($plugins as $pluginfunction) {
$pluginfunction($usersetting, $user, $usercontext, $course, $coursecontext);
}
}
return $usersetting;
}
示例4: can_do_delete
function can_do_delete()
{
global $USER;
// make sure we don't delete the admin user, or ourselves
$userid = cm_get_moodleuserid($this->required_param('id', PARAM_INT));
return !is_primary_admin($userid) && $userid != $USER->id && $this->_has_capability('block/curr_admin:user:delete');
}
示例5: tabobject
if (isguestuser() or !isloggedin()) {
// guests and not logged in can not edit own profile
} else {
if ($USER->id == $user->id) {
if (has_capability('moodle/user:update', $systemcontext)) {
$edittype = 'advanced';
} else {
if (has_capability('moodle/user:editownprofile', $systemcontext)) {
$edittype = 'normal';
}
}
} else {
if (has_capability('moodle/user:update', $systemcontext) and !is_primary_admin($user->id)) {
$edittype = 'advanced';
} else {
if (has_capability('moodle/user:editprofile', $personalcontext) and !is_primary_admin($user->id)) {
//teachers, parents, etc.
$edittype = 'normal';
}
}
}
}
}
}
if ($edittype == 'advanced') {
$toprow[] = new tabobject('editprofile', $wwwroot . '/user/editadvanced.php?id=' . $user->id . '&course=' . $course->id, get_string('editmyprofile'));
} else {
if ($edittype == 'normal') {
$toprow[] = new tabobject('editprofile', $wwwroot . '/user/edit.php?id=' . $user->id . '&course=' . $course->id, get_string('editmyprofile'));
}
}
示例6: require_capability
$user->id = -1;
$user->auth = 'manual';
$user->confirmed = 1;
$user->deleted = 0;
} else {
// editing existing user
require_capability('moodle/user:update', $systemcontext);
if (!($user = $DB->get_record('user', array('id' => $id)))) {
print_error('invaliduserid');
}
}
// remote users cannot be edited
if ($user->id != -1 and is_mnet_remote_user($user)) {
redirect($CFG->wwwroot . "/user/view.php?id={$id}&course={$course->id}");
}
if ($user->id != $USER->id and is_primary_admin($user->id)) {
// Can't edit primary admin
print_error('adminprimarynoedit');
}
if (isguestuser($user->id)) {
// the real guest user can not be edited
print_error('guestnoeditprofileother');
}
if ($user->deleted) {
print_header();
print_heading(get_string('userdeleted'));
print_footer($course);
die;
}
//load user preferences
useredit_load_preferences($user);
示例7: delete
public function delete()
{
global $CFG;
$result = false;
$muser = cm_get_moodleuserid($this->id);
if (empty($muser) || !is_primary_admin($muser)) {
$level = context_level_base::get_custom_context_level('user', 'block_curr_admin');
$result = attendance::delete_for_user($this->id);
$result = $result && curriculumstudent::delete_for_user($this->id);
$result = $result && instructor::delete_for_user($this->id);
$result = $result && student::delete_for_user($this->id);
$result = $result && student_grade::delete_for_user($this->id);
$result = $result && usertrack::delete_for_user($this->id);
$result = $result && usercluster::delete_for_user($this->id);
$result = $result && clusterassignment::delete_for_user($this->id);
$result = $result && waitlist::delete_for_user($this->id);
$result = $result && delete_context($level, $this->id);
// Delete Moodle user.
if ($muser = get_record('user', 'idnumber', $this->idnumber, 'mnethostid', $CFG->mnet_localhost_id, 'deleted', 0)) {
$result = $result && delete_user($muser);
}
$result = $result && parent::delete();
}
return $result;
}
示例8: delete
public function delete()
{
global $CFG;
$muser = $this->get_moodleuser();
if (empty($muser) || !is_primary_admin($muser->id)) {
// delete associated data
require_once elis::lib('data/data_filter.class.php');
$filter = new field_filter('userid', $this->id);
curriculumstudent::delete_records($filter, $this->_db);
student::delete_records($filter, $this->_db);
student_grade::delete_records($filter, $this->_db);
waitlist::delete_records($filter, $this->_db);
instructor::delete_records($filter, $this->_db);
usertrack::delete_records($filter, $this->_db);
clusterassignment::delete_records($filter, $this->_db);
//delete association to Moodle user, if applicable
require_once elispm::lib('data/usermoodle.class.php');
$filter = new field_filter('cuserid', $this->id);
usermoodle::delete_records($filter, $this->_db);
// Delete Moodle user.
if (!empty($muser)) {
delete_user($muser);
}
parent::delete();
$context = \local_elisprogram\context\user::instance($this->id);
$context->delete();
}
}
示例9: generate_user_settings
//.........這裏部分代碼省略.........
}
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_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()));
$usersetting->add(get_string('securitykeys', 'webservice'), $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('messaging', 'message'), $url, self::TYPE_SETTING);
}
// Blogs
if ($currentuser && !empty($CFG->enableblogs)) {
$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', context_system::instance())) {
$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);
}
}
// Badges.
if ($currentuser && !empty($CFG->enablebadges)) {
$badges = $usersetting->add(get_string('badges'), null, navigation_node::TYPE_CONTAINER, null, 'badges');
$badges->add(get_string('preferences'), new moodle_url('/badges/preferences.php'), navigation_node::TYPE_SETTING);
if (!empty($CFG->badges_allowexternalbackpack)) {
$badges->add(get_string('backpackdetails', 'badges'), new moodle_url('/badges/mybackpack.php'), navigation_node::TYPE_SETTING);
}
}
// Add reports node.
$reporttab = $usersetting->add(get_string('activityreports'));
$reports = get_plugin_list_with_function('report', 'extend_navigation_user', 'lib.php');
foreach ($reports as $reportfunction) {
$reportfunction($reporttab, $user, $course);
}
$anyreport = has_capability('moodle/user:viewuseractivitiesreport', $usercontext);
if ($anyreport || $course->showreports && $currentuser) {
// Add grade hardcoded grade report if necessary.
$gradeaccess = false;
if (has_capability('moodle/grade:viewall', $coursecontext)) {
// Can view all course grades.
示例10: print_section_fn
//.........這裏部分代碼省略.........
$act_compl = is_saved_or_submitted($mod, $USER->id, $resubmission);
if ($act_compl == 'submitted') {
// $completiondata->completionstate = COMPLETION_WAITFORGRADE_FN;
} else {
if ($act_compl == 'waitinggrade') {
$completiondata->completionstate = COMPLETION_WAITFORGRADE_FN;
} else {
if ($act_compl == 'saved') {
$completiondata->completionstate = COMPLETION_SAVED_FN;
}
}
}
}
switch ($completiondata->completionstate) {
case COMPLETION_INCOMPLETE:
$completionicon = 'auto-n';
break;
case COMPLETION_COMPLETE:
$completionicon = 'auto-y';
break;
case COMPLETION_COMPLETE_PASS:
$completionicon = 'auto-pass';
break;
case COMPLETION_COMPLETE_FAIL:
$completionicon = 'auto-fail';
break;
case COMPLETION_WAITFORGRADE_FN:
$completionicon = 'submitted';
break;
case COMPLETION_SAVED_FN:
$completionicon = 'saved';
break;
}
}
}
}
if ($completionicon) {
$imgsrc = '' . $CFG->wwwroot . '/course/format/' . $this->course->format . '/pix/completion-' . $completionicon . '.gif';
$imgalt = s(get_string('completion-alt-' . $completionicon, 'format_octabs'));
if ($completion == COMPLETION_TRACKING_MANUAL && !$isediting && has_capability('mod/assignment:submit', get_context_instance(CONTEXT_COURSE, $course->id)) && !is_primary_admin($USER->id)) {
$imgtitle = s(get_string('completion-title-' . $completionicon, 'format_octabs'));
$newstate = $completiondata->completionstate == COMPLETION_COMPLETE ? COMPLETION_INCOMPLETE : COMPLETION_COMPLETE;
// In manual mode the icon is a toggle form...
// If this completion state is used by the
// conditional activities system, we need to turn
// off the JS.i
/* oncampus
if (!empty($CFG->enableavailability) &&
condition_info::completion_value_used_as_condition($course, $mod)) {
$extraclass = ' preventjs';
} else {
$extraclass = '';
}
echo "
<form class='togglecompletion$extraclass' method='post' action='" . $CFG->wwwroot . "/course/togglecompletion.php'><div>
<input type='hidden' name='id' value='{$mod->id}' />
<input type='hidden' name='sesskey' value='" . sesskey() . "' />
<input type='hidden' name='completionstate' value='$newstate' />
<input type='image' src='$imgsrc' alt='$imgalt' title='$imgtitle' />
</div></form>";
*/
} else {
// In auto mode, or when editing, the icon is just an image
/* echo "<span class='autocompletion'>";
echo "<img src='$imgsrc' alt='$imgalt' title='$imgalt' /></span>"; */
}
}
}
// If there is content AND a link, then display the content here
// (AFTER any icons). Otherwise it was displayed before
if (!empty($url)) {
echo $contentpart;
}
// Show availability information (for someone who isn't allowed to
// see the activity itself, or for staff)
if (!$mod->uservisible) {
echo '<div class="availabilityinfo">' . $mod->availableinfo . '</div>';
} else {
if ($canviewhidden && !empty($CFG->enableavailability)) {
$ci = new condition_info($mod);
$fullinfo = $ci->get_full_information();
if ($fullinfo) {
echo '<div class="availabilityinfo">' . get_string($mod->showavailability ? 'userrestriction_visible' : 'userrestriction_hidden', 'condition', $fullinfo) . '</div>';
}
}
}
echo html_writer::end_tag('div');
echo html_writer::end_tag('li') . "\n";
}
} elseif ($ismoving) {
echo "<ul class=\"section\">\n";
}
if ($ismoving) {
echo '<li><a title="' . $strmovefull . '"' . ' href="' . $CFG->wwwroot . '/course/mod.php?movetosection=' . $section->id . '&sesskey=' . sesskey() . '">' . '<img class="movetarget" src="' . $OUTPUT->pix_url('movehere') . '" ' . ' alt="' . $strmovehere . '" /></a></li>
';
}
if (!empty($section->sequence) || $ismoving) {
echo "</ul><!--class='section'-->\n\n";
}
}
示例11: get_content
//.........這裏部分代碼省略.........
$this->content->text .= '<div class="myprofileitem skype">';
$this->content->text .= 'Skype: ' . $user->skype;
$this->content->text .= '</div>';
}
if (!empty($this->config->display_yahoo) && !empty($user->yahoo)) {
$this->content->text .= '<div class="myprofileitem yahoo">';
$this->content->text .= 'Yahoo: ' . $user->yahoo;
$this->content->text .= '</div>';
}
if (!empty($this->config->display_aim) && !empty($user->aim)) {
$this->content->text .= '<div class="myprofileitem aim">';
$this->content->text .= 'AIM: ' . $user->aim;
$this->content->text .= '</div>';
}
if (!empty($this->config->display_msn) && !empty($user->msn)) {
$this->content->text .= '<div class="myprofileitem msn">';
$this->content->text .= 'MSN: ' . $user->msn;
$this->content->text .= '</div>';
}
if (!empty($this->config->display_phone1) && !empty($user->phone1)) {
$this->content->text .= '<div class="myprofileitem phone1">';
$this->content->text .= get_string('phone') . ': ' . $user->phone1;
$this->content->text .= '</div>';
}
if (!empty($this->config->display_phone2) && !empty($user->phone2)) {
$this->content->text .= '<div class="myprofileitem phone2">';
$this->content->text .= get_string('phone') . ': ' . $user->phone2;
$this->content->text .= '</div>';
}
if (!empty($this->config->display_institution) && !empty($user->institution)) {
$this->content->text .= '<div class="myprofileitem institution">';
$this->content->text .= $user->institution;
$this->content->text .= '</div>';
}
if (!empty($this->config->display_address) && !empty($user->address)) {
$this->content->text .= '<div class="myprofileitem address">';
$this->content->text .= $user->address;
$this->content->text .= '</div>';
}
if (!empty($this->config->display_firstaccess) && !empty($user->firstaccess)) {
$this->content->text .= '<div class="myprofileitem firstaccess">';
$this->content->text .= get_string('firstaccess') . ': ' . userdate($user->firstaccess);
$this->content->text .= '</div>';
}
if (!empty($this->config->display_lastaccess) && !empty($user->lastaccess)) {
$this->content->text .= '<div class="myprofileitem lastaccess">';
$this->content->text .= get_string('lastaccess') . ': ' . userdate($user->lastaccess);
$this->content->text .= '</div>';
}
if (!empty($this->config->display_currentlogin) && !empty($user->currentlogin)) {
$this->content->text .= '<div class="myprofileitem currentlogin">';
$this->content->text .= get_string('login') . ': ' . userdate($user->currentlogin);
$this->content->text .= '</div>';
}
if (!empty($this->config->display_lastip) && !empty($user->lastip)) {
$this->content->text .= '<div class="myprofileitem lastip">';
$this->content->text .= 'IP: ' . $user->lastip;
$this->content->text .= '</div>';
}
$editscript = NULL;
if (isguestuser($user)) {
// guest account can not be edited
} else {
if (is_mnet_remote_user($user)) {
// cannot edit remote users
} else {
if (isguestuser() or !isloggedin()) {
// guests and not logged in can not edit own profile
} else {
if ($USER->id == $user->id) {
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
if (has_capability('moodle/user:update', $systemcontext)) {
$editscript = '/user/editadvanced.php';
} else {
if (has_capability('moodle/user:editownprofile', $systemcontext)) {
$editscript = '/user/edit.php';
}
}
} else {
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
$personalcontext = get_context_instance(CONTEXT_USER, $user->id);
if (has_capability('moodle/user:update', $systemcontext) and !is_primary_admin($user->id)) {
$editscript = '/user/editadvanced.php';
} else {
if (has_capability('moodle/user:editprofile', $personalcontext) and !is_primary_admin($user->id)) {
//teachers, parents, etc.
$editscript = '/user/edit.php';
}
}
}
}
}
}
if ($editscript) {
$this->content->text .= '<div class="myprofileitem edit">';
$this->content->text .= '<a href="' . $CFG->wwwroot . $editscript . '?id=' . $user->id . '&course=' . $course->id . '">' . get_string('editmyprofile') . '</a>';
$this->content->text .= '</div>';
}
return $this->content;
}
示例12: can_do_delete
function can_do_delete()
{
global $USER;
// make sure we don't delete the admin user, or ourselves
$cuser = new user($this->required_param('id', PARAM_INT));
$muser = $cuser->get_moodleuser();
if (!isset($muser->id)) {
//no corresponding Moodle user, so just check the capability
return $this->_has_capability('local/elisprogram:user_delete');
}
return !is_primary_admin($muser->id) && $muser->id != $USER->id && $this->_has_capability('local/elisprogram:user_delete');
}