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


PHP users::getInstance方法代码示例

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


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

示例1: get_roles

 /**
  * Returns an array of available roles
  * @return array of availble roles
  */
 function get_roles() {
     global $DB;
     $myuser = users::getInstance();
     $context = context_system::instance();
     $rs = $DB->get_records_sql("SELECT * FROM {role} WHERE archetype = 'student'");
     $role = array();
     foreach ($rs as $r) {
         $role[$r->id] = ucwords($r->shortname);
     }
     $systemroles = $myuser->systemroles_custom();
     $roles = array(0 => get_string('anyrole', 'filters')) + $systemroles + $role;
     return $roles;
 }
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:17,代码来源:globalrole.php

示例2: user_download_xls

function user_download_xls($fields) {
    $hier = new hierarchy();
    $schools = $hier->get_assignedschools();

    global $CFG, $DB;
    require_once("$CFG->libdir/excellib.class.php");
    $filename = clean_filename('Users.xls');
    $workbook = new MoodleExcelWorkbook('-');
    $workbook->send($filename);
    $worksheet = array();
    $worksheet[0] = $workbook->add_worksheet('');
    $col = 0;
    foreach ($fields as $fieldname) {
        $worksheet[0]->write(0, $col, $fieldname);
        $col++;
    }

    $sheetrow = 1;
    $myuser = users::getInstance();

    $users = $DB->get_records_sql("SELECT u.id, u.username, u.email, u.firstname, u.lastname, u.city, u.country,
                                            u.lastaccess, u.confirmed, u.mnethostid, u.suspended FROM {user} u, {local_users} lu
                                            WHERE lu.userid = u.id ");

    foreach ($users as $user) {
        $rid = $myuser->get_rolename($user->id);
        $post = new stdclass();
        $post->firstname = $user->firstname;
        $post->lastname = $user->lastname;
        $post->email = $user->email;

        $post->schoolname = $myuser->get_schoolnames($user);
        $post->roleid = $myuser->get_rolename($user->id);
        $col = 0;
        foreach ($fields as $fieldname) {
            $worksheet[0]->write($sheetrow, $col, $post->$fieldname);
            $col++;
        }
        $sheetrow++;
    }

    $workbook->close();
    die;
}
开发者ID:anilch,项目名称:Personel,代码行数:44,代码来源:download_all.php

示例3: require_login

$currentcss = '/local/courseregistration/css/styles.css';
$PAGE->requires->css($currentcss);
$PAGE->requires->js('/local/courseregistration/js/expand.js');
/* ---check the context level of the user and check weather the user is login to the system or not--- */
$PAGE->set_context($systemcontext);
if ($CFG->forcelogin) {
    require_login();
} else {
    user_accesstime_log();
}
$PAGE->set_url('/local/courseregistration/mycur.php');

/* ---Header and the navigation bar--- */
$PAGE->set_heading($SITE->fullname);
$PAGE->navbar->add(get_string('mycurriculum', 'local_curriculum'));
$users = users::getInstance();
echo $OUTPUT->header();
/* ---Heading of the page--- */
echo $OUTPUT->heading(get_string('mycurriculum', 'local_curriculum'));

/* ---Moodle 2.2 and onwards--- */
$currenttab = 'myplan';
/* ---adding tabs--- */
$exams->studentside_tabs($currenttab);
if (isset($CFG->allowframembedding) and ! $CFG->allowframembedding) {
    echo $OUTPUT->box(get_string('mycurriculumdec', 'local_curriculum'));
}

// -----used get to cuurent active semesterid--------------------------------
$hier = new hierarchy();
$semesterid = $hier->get_allmyactivesemester($USER->id);
开发者ID:anilch,项目名称:Personel,代码行数:31,代码来源:mycurplan.php

示例4: require_once

//require_once($CFG->dirroot . '/local/admission/lib.php');
require_once($CFG->dirroot . '/local/users/user_form.php');
require_once($CFG->dirroot . '/local/costcenter/lib.php');
require_once($CFG->dirroot . '/user/editlib.php');
require_once($CFG->dirroot . '/user/profile/lib.php');
require_once($CFG->libdir . '/gdlib.php');
require_once($CFG->libdir . '/adminlib.php');
require_once($CFG->dirroot . '/local/positions/lib.php');

$id = optional_param('id', -1, PARAM_INT);
$delete = optional_param('delete', 0, PARAM_INT);
$visible = optional_param('visible', -1, PARAM_INT);
$confirm = optional_param('confirm', 0, PARAM_INT);
global $CFG;

$myuser = users::getInstance();
$costcenter = new costcenter();
$conf = new object();

$systemcontext = context_system::instance();
//get the admin layout
$PAGE->set_pagelayout('admin');
//check the context level of the user and check weather the user is login to the system or not
$PAGE->set_context($systemcontext);

require_login();

//if (!has_capability('local/costcenter:manage', $systemcontext)) {
//    print_error('You dont have permissions');
//}
$PAGE->set_url('/local/users/user.php');
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:31,代码来源:user.php

示例5: student_currculum_progress

/**
 * @method student_currculum_progress
 * @todo to print student curriculum progress bar
 * @param int $curid curriculum id, int $schoid schoolid
 * @return- print progress bar
 */
function student_currculum_progress($curid, $schoid) {

    global $CFG, $DB, $USER;
    $myuser = users::getInstance();
    $courses = $DB->get_records('local_curriculum_plancourses', array('curriculumid' => $curid));
    $course_count = sizeof($courses);
    $enrolled = 0;
    $completed = 0;
    foreach ($courses as $course) {
        $status = $myuser->get_coursestatus($course->courseid, $USER->id);
        if ($status != 'Not Enrolled') {
            $enrolled++;
            if ($status != 'Enrolled (Inprogress)')
                $completed++;
        }
    }

    $curculum = $DB->get_record('local_curriculum', array('id' => $curid));
    $program = $DB->get_record('local_program', array('id' => $curculum->programid));
    $grades = $DB->get_record('local_cobalt_gpasettings', array('schoolid' => $schoid, 'sub_entityid' => $program->programlevel));
    $cgpa = $DB->get_field('local_graduation', 'finalcgpa', array('userid' => $USER->id, 'schoolid' => $schoid, 'curriculumid' => $curid));
    if (empty($cgpa)) {
        $cgpa = 'Not Graded';
    }
    $totalcredit = $DB->get_field('local_level_settings', 'mincredithours', array('schoolid' => $schoid, 'levelid' => $curculum->programid, 'level' => 'PL'));
    if (empty($totalcredit)) {
        $totalcredit = 'Not Applicable';
    }
    $usercredits = "SELECT sum(totcredithours) as total FROM {local_user_sem_details} WHERE userid={$USER->id} AND curriculumid={$curid}";
    $usercredit = $DB->get_record_sql($usercredits);
    $gpasql = "SELECT * FROM {local_user_sem_details} WHERE userid={$USER->id} AND curriculumid={$curid}";
    $gpaqry = $DB->get_records_sql($gpasql);
    $gpacount = sizeof($gpaqry);
    if ($completed < $enrolled || $enrolled == 0) {
        $one = "<img src='pix/unsuccess.png'>";
    } else {
        $one = "<img src='pix/success.png'>";
    }
    if ($totalcredit <= $usercredit->total) {
        $two = "<img src='pix/success.png'>";
    } else {
        $two = "<img src='pix/unsuccess.png'>";
    }
    /*
     * ###Bugreport#181-Curriculum
     * @author Naveen Kumar<naveen@eabyas.in>
     * (Resolved) checking both empty and less than or equal to cgpa 
     */
    if (round($grades->cgpa) <= $cgpa && !empty($grades->cgpa)) {
        $three = "<img src='pix/success.png'>";
    } else {
        $three = "<img src='pix/unsuccess.png'>";
    }
    
    $string .= html_writer::start_tag('div', array('style'=>'border: 1px solid #E8E8E8; background: #EAEAEA; padding: 10px; width: 97%; margin: 25px 0 25px; font-weight: bold; overflow: auto;'));
    $string .= html_writer::tag('div', $program->fullname, array('style'=>'float: left;'));
    $string .= html_writer::tag('div', $curculum->fullname, array('style'=>'float: right;'));
    $string .= html_writer::end_tag('div');
    
    echo $string;
    
    //========By Vinod for DYPatil
//    $table = new html_table();
//    $table->align = array('left', 'left', 'left', 'left');
//    $table->size = array('20%', '36%', '32%', '12%');
//    $table->width = '100%';
//    $cell = new html_table_cell();
//    $cell->text = 'Graduation will be given if following conditions are met<br> ' . $one . ' Need to complete all enrolled courses in curriculum .<br> ' . $two . ' Credithours should be greater than or equal to required credit hours.<br> 
//		' . $three . ' CGPA achieved is equal or greater than to required CGPA.<br>  ';
//    $cell->colspan = 3;
//    $table->data[] = array('Program Name', '<b>' . $program->fullname . '</b>', 'Total Number of Courses', '<b>' . $course_count . '</b>');
//    $table->data[] = array('Curriculum Name', '<b>' . $curculum->fullname . '</b>', 'Total Number of Enroled Courses', '<b>' . $enrolled . '</b>');
//    $table->data[] = array('Required Credithours', '<b>' . $totalcredit . '</b>', 'Total Number of Completed Courses', '<b>' . $completed . '</b>');
//    $table->data[] = array('Credithours Achieved', '<b>' . $usercredit->total . '</b>', 'Required CGPA', '<b>' . round($grades->cgpa) . '</b>');
//
//    $table->data[] = array('Progress', get_my_progress($USER->id, 0, $curid), 'CGPA Achieved', '<b>' . round($cgpa) . '</b>');
//    $table->data[] = array('Description', $cell);
//
//    echo html_writer::table($table);
}
开发者ID:anilch,项目名称:Personel,代码行数:86,代码来源:lib.php


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