本文整理匯總了PHP中hierarchy::get_registrar_roleid方法的典型用法代碼示例。如果您正苦於以下問題:PHP hierarchy::get_registrar_roleid方法的具體用法?PHP hierarchy::get_registrar_roleid怎麽用?PHP hierarchy::get_registrar_roleid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類hierarchy
的用法示例。
在下文中一共展示了hierarchy::get_registrar_roleid方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: add_users
/**
* @method add_users
* @todo add_users is the function to add the registrar to a school
* @param array $userids user array
* @param int $schoolid Schoolid
*/
public function add_users($userids, $schoolid) {
global $CFG, $DB, $OUTPUT, $USER;
$hierarchy = new hierarchy ();
$currenturl = "{$CFG->wwwroot}/local/collegestructure/assignusers.php";
if (empty($userids)) {
/* ---nothing to do--- */
return;
}
$userids = array_reverse($userids);
foreach ($userids as $userid) {
$registrar = new stdClass();
$registrar->userid = $userid;
$registrar->schoolid = $schoolid;
$getroleid = $hierarchy->get_registrar_roleid();
foreach ($getroleid as $getid) {
$context = context_user::instance($userid);
$systemcontext = context_system::instance();
if (has_capability('local/clclasses:approveclclasses', $context)) {
$roleid = $getid->id;
} elseif (has_capability('local/collegestructure:manage', $systemcontext)) {
$roleid = $getid->id;
} elseif (has_capability('local/clclasses:submitgrades', $systemcontext)) {
$roleid = $getid->id;
} elseif (!has_capability('local/clclasses:submitgrades', $systemcontext)) {
$roleid = $getid->id;
} elseif (!has_capability('local/clclasses:approveclclasses', $context)) {
$roleid = $getid->id;
} else {
$roleid = $getid->id;
}
}
$registrar->roleid = $roleid;
$now = date("d-m-Y");
$registrar->timecreated = strtotime($now);
$registrar->usermodified = $USER->id;
$school = $DB->get_record('local_school', array('id' => $schoolid));
$checkexist = $DB->get_record('local_school_permissions', array('userid' => $userid, 'schoolid' => $schoolid));
if ($checkexist) {
$hierarchy->set_confirmation(get_string('alreadyassigned', 'local_collegestructure', array('school' => $school->fullname)), $currenturl);
} else {
$ll = $DB->insert_record('local_school_permissions', $registrar);
}
if ($ll) {
/* ---start of vijaya--- */
$conf = new object();
$conf->username = $DB->get_field('user', 'username', array('id' => $userid));
$conf->schoolname = $DB->get_field('local_school', 'fullname', array('id' => $schoolid));
$message = get_string('msg_add_reg_schl', 'local_collegestructure', $conf);
$userfrom = $DB->get_record('user', array('id' => $USER->id));
$userto = $DB->get_record('user', array('id' => $userid));
$message_post_message = message_post_message($userfrom, $userto, $message, FORMAT_HTML);
/* ---end of vijaya--- */
// $hierarchy->set_confirmation(get_string('assignedsuccess', 'local_collegestructure'), $currenturl,array('style' => 'notifysuccess'));
}
}
if ($ll) {
$hierarchy->set_confirmation(get_string('assignedsuccess', 'local_collegestructure'), $currenturl, array('style' => 'notifysuccess'));
} else {
$hierarchy->set_confirmation(get_string('assignedfailed', 'local_collegestructure'), $currenturl, array('style' => 'notifyproblem'));
}
}