本文整理汇总了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'));
}
}