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


PHP UserUtils::create_user方法代码示例

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


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

示例1: adduser

function adduser($course, $tmp_roles, $new_username, $mysqli)
{
    $new_password = trim($_POST['new_password']);
    $new_surname = StringUtils::my_ucwords(trim($_POST['new_surname']));
    $new_title = $_POST['new_users_title'];
    $new_email = trim($_POST['new_email']);
    $new_first_names = StringUtils::my_ucwords(trim($_POST['new_first_names']));
    $new_year = $_POST['new_year'];
    $new_gender = $_POST['new_gender'];
    $userid = UserUtils::create_user($new_username, $new_password, $new_title, $new_first_names, $new_surname, $new_email, $course, $new_gender, $new_year, $tmp_roles, '', $mysqli);
    return $userid;
}
开发者ID:vinod-co,项目名称:centa,代码行数:12,代码来源:register.php

示例2: update_module_enrolement

 function update_module_enrolement($module, $idMod, $sms_api, $mysqli = 'NOTSET', $session = 'NOTSET', $demomode = false)
 {
     // run module enrolement for select code
     if ($mysqli == 'NOTSET') {
         global $mysqli;
     }
     if ($session == 'NOTSET') {
         $session = date_utils::get_current_academic_year();
     }
     $session_parts = explode('/', $session);
     $enrolements = 0;
     $deletions = 0;
     $enrolement_details = '';
     $deletion_details = '';
     // UoN code to strip off prefix codes.
     //------------------------------------
     $replaced_module = str_replace('_UNMC', '', $module);
     $replaced_module = str_replace('_UNNC', '', $replaced_module);
     //------------------------------------
     // Get the currently enrolled students in Rogo for the module.
     $current_users = array();
     $student_data = $mysqli->prepare("SELECT modules_student.id, users.id, username, grade, title, surname, first_names, initials, roles, yearofstudy, auto_update, sid.student_id FROM (modules_student, users) LEFT JOIN sid ON users.id = sid.userID WHERE modules_student.userID = users.id AND calendar_year = ? AND idMod = ?");
     $student_data->bind_param('si', $session, $idMod);
     $student_data->execute();
     $student_data->store_result();
     $student_data->bind_result($sm_id, $uid, $username, $grade, $title, $surname, $first_names, $initials, $roles, $year, $auto_update, $student_id);
     while ($student_data->fetch()) {
         $current_users[$username]['delete'] = $auto_update;
         // Set users to be deleted if added via SATURN, set otherwise lower down after checking with SMS
         $current_users[$username]['smID'] = $sm_id;
         $current_users[$username]['userID'] = $uid;
         $current_users[$username]['grade'] = $grade;
         $current_users[$username]['title'] = $title;
         $current_users[$username]['surname'] = $surname;
         $current_users[$username]['first_names'] = $first_names;
         $current_users[$username]['initials'] = $initials;
         $current_users[$username]['roles'] = $roles;
         $current_users[$username]['year'] = $year;
         $current_users[$username]['auto_update'] = $auto_update;
         $current_users[$username]['student_id'] = $student_id;
     }
     $student_data->close();
     $c_u = $current_users;
     // Look up SMS
     $returned_data = @file_get_contents($sms_api . "&code={$replaced_module}&year=" . $session_parts[0]);
     $xml = false;
     if ($returned_data !== false) {
         $xml = new SimpleXMLElement($returned_data);
     }
     if (is_object($xml) and !isset($xml->ErrorMessage) and !isset($xml->Module->ModuleError)) {
         foreach ($xml->Module->Membership->Student as $sms) {
             $sms->Title = trim($sms->Title);
             $sms->Surname = trim($sms->Surname);
             $sms->Forename = trim($sms->Forename);
             $sms->CourseCode = trim($sms->CourseCode);
             $sms->Username = trim($sms->Username);
             $sms->Email = trim($sms->Email);
             $sms->Gender = trim($sms->Gender);
             $sms->YearofStudy = trim($sms->YearofStudy);
             $sms->StudentID = trim($sms->StudentID);
             $lookup_username = trim($sms->Username);
             // Make sure we have a proper username - it can sometimes be blank in SATURN data
             if ($sms->Email != '') {
                 // Try to extract from email address
                 $un_parts = explode('@', $sms->Email);
                 $lookup_username = $un_parts[0];
             }
             if ($lookup_username != '') {
                 if (isset($current_users[$lookup_username]['delete'])) {
                     $current_users[$lookup_username]['delete'] = 0;
                     // Mark as being legitimate
                 } else {
                     // Student missing from Rogo module
                     $student_data = $mysqli->prepare("SELECT id, yearofstudy, initials, grade, title, surname, first_names, roles, email, COALESCE(sid.student_id,'SID_ERROR') FROM users LEFT JOIN sid ON users.id = sid.userID WHERE username = ? LIMIT 1");
                     // Do they have a Rogo user record?
                     $student_data->bind_param('s', $lookup_username);
                     $student_data->execute();
                     $student_data->store_result();
                     $student_data->bind_result($tmp_userID, $tmp_yearofstudy, $tmp_initials, $tmp_grade, $tmp_title, $tmp_surname, $tmp_first_names, $tmp_roles, $tmp_email, $tmp_student_id);
                     $student_data->fetch();
                     if ($student_data->num_rows == 0) {
                         // Going to have to create a whole new account for the user
                         $names = explode(' ', $sms->Forename);
                         $initials = '';
                         foreach ($names as $tmp_name) {
                             $initials .= $tmp_name[0];
                         }
                         if (!$demomode) {
                             $tmp_userID = UserUtils::create_user($lookup_username, '', $sms->Title, $sms->Forename, $sms->Surname, $sms->Email, $sms->CourseCode, $sms->Gender, $sms->YearofStudy, 'Student', $sms->StudentID, $mysqli);
                             if ($tmp_userID == false) {
                                 echo 'ERROR: unable to establish surname for ' . $lookup_username . '<br />';
                                 continue;
                             }
                         }
                         $current_users[$lookup_username]['userID'] = $tmp_userID;
                         $current_users[$lookup_username]['grade'] = $sms->CourseCode;
                         $current_users[$lookup_username]['title'] = $sms->Title;
                         $current_users[$lookup_username]['surname'] = $sms->Surname;
                         $current_users[$lookup_username]['first_names'] = $tmp_first_names;
                         $current_users[$lookup_username]['initials'] = $initials;
//.........这里部分代码省略.........
开发者ID:vinod-co,项目名称:centa,代码行数:101,代码来源:uon_saturn.class.php

示例3: createAccount

 public function createAccount()
 {
     $userObject = UserObject::get_instance();
     if (!$userObject->has_role('SysAdmin')) {
         return 'AccessDenied';
     }
     if (!isset($_POST['data'])) {
         return 'No data';
     }
     $xml = new SimpleXMLElement($_POST['data']);
     $fields = array('username', 'password', 'firstnames', 'title', 'surname', 'email', 'course', 'gender', 'yearofstudy', 'roles');
     foreach ($fields as $field) {
         if (isset($xml->{$field}) and $xml->{$field} != '') {
             ${$field} = $xml->{$field};
         } else {
             return 'Missing data: ' . $field;
         }
     }
     if (isset($xml->studentid)) {
         $studentid = $xml->studentid;
     } else {
         $studentid = '';
     }
     if ($roles != 'Student' and $roles != 'Staff' and $roles != 'Staff,Admin' and $roles != 'Staff,SysAdmin') {
         return 'Incorrect value for roles: ' . $roles;
     }
     $success = UserUtils::create_user($username, $password, $title, $firstnames, $surname, $email, $course, $gender, $yearofstudy, $roles, $studentid, $this->db);
     if ($success === false) {
         return false;
     } else {
         return $success;
     }
 }
开发者ID:vinod-co,项目名称:centa,代码行数:33,代码来源:webServiceRestAPI.php

示例4: createDatabase


//.........这里部分代码省略.........
         self::$db->query($sql);
         if (self::$db->errno != 0) {
             self::displayError(array('013' => $string['wdatabaseuser'] . self::$cfg_db_sct_user . $string['wnotpermission'] . ' ' . self::$db->error));
             self::$db->rollback();
         }
     }
     self::$db->commit();
     $priv_SQL = array();
     //create 'database user Invigilator user' and grant permissions
     self::$db->query("CREATE USER  '" . self::$cfg_db_inv_user . "'@'" . self::$cfg_web_host . "' IDENTIFIED BY '" . self::$cfg_db_inv_passwd . "'");
     if (self::$db->errno != 0) {
         self::displayError(array('013' => $string['wdatabaseuser'] . self::$cfg_db_inv_user . $string['wnotcreated'] . ' ' . self::$db->error));
     }
     //$priv_SQL[] = "REVOKE ALL PRIVILEGES ON $dbname.* FROM '". self::$cfg_db_inv_user . "'@'". self::$cfg_web_host . "'";
     $priv_SQL[] = "GRANT SELECT ON " . $dbname . ".exam_announcements TO '" . self::$cfg_db_inv_user . "'@'" . self::$cfg_web_host . "'";
     $priv_SQL[] = "GRANT SELECT ON " . $dbname . ".client_identifiers TO '" . self::$cfg_db_inv_user . "'@'" . self::$cfg_web_host . "'";
     $priv_SQL[] = "GRANT SELECT ON " . $dbname . ".labs TO '" . self::$cfg_db_inv_user . "'@'" . self::$cfg_web_host . "'";
     $priv_SQL[] = "GRANT SELECT ON " . $dbname . ".log2 TO '" . self::$cfg_db_inv_user . "'@'" . self::$cfg_web_host . "'";
     $priv_SQL[] = "GRANT SELECT ON " . $dbname . ".log_metadata TO '" . self::$cfg_db_inv_user . "'@'" . self::$cfg_web_host . "'";
     $priv_SQL[] = "GRANT SELECT, INSERT, UPDATE, DELETE ON " . $dbname . ".log_extra_time TO '" . self::$cfg_db_inv_user . "'@'" . self::$cfg_web_host . "'";
     $priv_SQL[] = "GRANT SELECT, INSERT, UPDATE, DELETE ON " . $dbname . ".log_lab_end_time TO '" . self::$cfg_db_inv_user . "'@'" . self::$cfg_web_host . "'";
     $priv_SQL[] = "GRANT SELECT ON " . $dbname . ".modules_student TO '" . self::$cfg_db_inv_user . "'@'" . self::$cfg_web_host . "'";
     $priv_SQL[] = "GRANT SELECT, INSERT, UPDATE ON " . $dbname . ".paper_notes TO '" . self::$cfg_db_inv_user . "'@'" . self::$cfg_web_host . "'";
     $priv_SQL[] = "GRANT SELECT ON " . $dbname . ".properties TO '" . self::$cfg_db_inv_user . "'@'" . self::$cfg_web_host . "'";
     $priv_SQL[] = "GRANT SELECT ON " . $dbname . ".properties_modules TO '" . self::$cfg_db_inv_user . "'@'" . self::$cfg_web_host . "'";
     $priv_SQL[] = "GRANT SELECT ON " . $dbname . ".modules TO '" . self::$cfg_db_inv_user . "'@'" . self::$cfg_web_host . "'";
     $priv_SQL[] = "GRANT SELECT ON " . $dbname . ".papers TO '" . self::$cfg_db_inv_user . "'@'" . self::$cfg_web_host . "'";
     $priv_SQL[] = "GRANT SELECT ON " . $dbname . ".questions TO '" . self::$cfg_db_inv_user . "'@'" . self::$cfg_web_host . "'";
     $priv_SQL[] = "GRANT SELECT ON " . $dbname . ".question_statuses TO '" . self::$cfg_db_inv_user . "'@'" . self::$cfg_web_host . "'";
     $priv_SQL[] = "GRANT SELECT, INSERT, UPDATE ON " . $dbname . ".student_notes TO '" . self::$cfg_db_inv_user . "'@'" . self::$cfg_web_host . "'";
     $priv_SQL[] = "GRANT SELECT ON " . $dbname . ".sid TO '" . self::$cfg_db_inv_user . "'@'" . self::$cfg_web_host . "'";
     $priv_SQL[] = "GRANT SELECT ON " . $dbname . ".special_needs TO '" . self::$cfg_db_inv_user . "'@'" . self::$cfg_web_host . "'";
     $priv_SQL[] = "GRANT SELECT ON " . $dbname . ".users TO '" . self::$cfg_db_inv_user . "'@'" . self::$cfg_web_host . "'";
     $priv_SQL[] = "GRANT INSERT ON " . $dbname . ".access_log TO '" . self::$cfg_db_inv_user . "'@'" . self::$cfg_web_host . "'";
     $priv_SQL[] = "GRANT INSERT ON " . $dbname . ".denied_log TO '" . self::$cfg_db_inv_user . "'@'" . self::$cfg_web_host . "'";
     $priv_SQL[] = "GRANT SELECT, INSERT, DELETE ON " . $dbname . ".toilet_breaks TO '" . self::$cfg_db_inv_user . "'@'" . self::$cfg_web_host . "'";
     $priv_SQL[] = "FLUSH PRIVILEGES";
     foreach ($priv_SQL as $sql) {
         self::$db->query($sql);
         @ob_flush();
         @flush();
         if (self::$db->errno != 0) {
             self::displayError(array('013' => $string['wdatabaseuser'] . self::$cfg_db_inv_user . $string['wnotpermission'] . ' ' . self::$db->error));
             self::$db->rollback();
         }
     }
     self::$db->commit();
     $priv_SQL = array();
     //create 'database user sysadmin user' and grant permissions
     self::$db->query("CREATE USER  '" . self::$cfg_db_sysadmin_user . "'@'" . self::$cfg_web_host . "' IDENTIFIED BY '" . self::$cfg_db_sysadmin_passwd . "'");
     if (self::$db->errno != 0) {
         self::displayError(array('013' => $string['wdatabaseuser'] . self::$cfg_db_sysadmin_user . $string['wnotcreated'] . ' ' . self::$db->error));
     }
     //$priv_SQL[] = "REVOKE ALL PRIVILEGES ON $dbname.* FROM '". self::$cfg_db_sysadmin_user . "'@'". self::$cfg_web_host . "'";
     $priv_SQL[] = "GRANT SELECT, INSERT, UPDATE, DELETE, ALTER, DROP  ON " . $dbname . ".* TO '" . self::$cfg_db_sysadmin_user . "'@'" . self::$cfg_web_host . "'";
     $priv_SQL[] = "FLUSH PRIVILEGES";
     foreach ($priv_SQL as $sql) {
         self::$db->query($sql);
         @ob_flush();
         @flush();
         if (self::$db->errno != 0) {
             echo self::$db->error . "<br />";
             self::displayError(array('013' => $string['wdatabaseuser'] . self::$cfg_db_sysadmin_user . $string['wnotpermission'] . ' ' . self::$db->error));
             self::$db->rollback();
         }
     }
     self::$db->commit();
     //create sysadmin user
     UserUtils::create_user($_POST['SysAdmin_username'], $_POST['SysAdmin_password'], $_POST['SysAdmin_title'], $_POST['SysAdmin_first'], $_POST['SysAdmin_last'], $_POST['SysAdmin_email'], 'University Lecturer', '', '1', 'Staff,SysAdmin', '', self::$db);
     //create cron user
     UserUtils::create_user(self::$cfg_cron_user, self::$cfg_cron_passwd, '', '', 'cron', '', '', '', '', 'Staff,SysCron', '', self::$db);
     //create 100 guest accounts
     for ($i = 1; $i <= 100; $i++) {
         UserUtils::create_user('user' . $i, '', 'Dr', 'A', 'User' . $i, '', 'none', '', '1', 'Student', '', self::$db);
     }
     self::$db->commit();
     //add unknown school & faculty
     $facultyID = FacultyUtils::add_faculty('UNKNOWN Faculty', self::$db);
     $scoolID = SchoolUtils::add_school($facultyID, 'UNKNOWN School', self::$db);
     //add traing school
     $facultyID = FacultyUtils::add_faculty('Administrative and Support Units', self::$db);
     $scoolID = SchoolUtils::add_school($facultyID, 'Training', self::$db);
     //create special modules
     module_utils::add_modules('TRAIN', 'Training Module', 1, $scoolID, '', '', 0, false, false, false, true, null, null, self::$db, 0, 0, 1, 1, '07/01');
     module_utils::add_modules('SYSTEM', 'Online Help', 1, $scoolID, '', '', 0, true, true, true, true, null, null, self::$db, 0, 0, 1, 1, '07/01');
     self::$db->commit();
     // Create default question statuses
     $statuses = array(array('name' => 'Normal', 'exclude_marking' => false, 'retired' => false, 'is_default' => true, 'change_locked' => true, 'validate' => true, 'display_warning' => 0, 'colour' => '#000000', 'display_order' => 0), array('name' => 'Retired', 'exclude_marking' => false, 'retired' => true, 'is_default' => false, 'change_locked' => true, 'validate' => false, 'display_warning' => 1, 'colour' => '#808080', 'display_order' => 1), array('name' => 'Incomplete', 'exclude_marking' => false, 'retired' => false, 'is_default' => false, 'change_locked' => false, 'validate' => false, 'display_warning' => 1, 'colour' => '#000000', 'display_order' => 2), array('name' => 'Experimental', 'exclude_marking' => true, 'retired' => false, 'is_default' => false, 'change_locked' => false, 'validate' => true, 'display_warning' => 0, 'colour' => '#808080', 'display_order' => 3), array('name' => 'Beta', 'exclude_marking' => false, 'retired' => false, 'is_default' => false, 'change_locked' => false, 'validate' => true, 'display_warning' => 1, 'colour' => '#000000', 'display_order' => 4));
     foreach ($statuses as $data) {
         $qs = new QuestionStatus(self::$db, $string, $data);
         $qs->save();
     }
     //FLUSH PRIVILEGES
     self::$db->query("FLUSH PRIVILEGES");
     if (self::$db->errno != 0) {
         self::logWarning(array('014' => $string['logwarning20']));
     }
     self::$db->commit();
     self::$db->autocommit(false);
 }
开发者ID:vinod-co,项目名称:centa,代码行数:101,代码来源:installutils.class.php

示例5: trim

            $tmp_roles = 'Student';
            break;
    }
    $new_password = trim($_POST['new_password']);
    $new_surname = UserUtils::my_ucwords(trim($_POST['new_surname']));
    $new_username = trim($_POST['new_username']);
    $new_email = trim($_POST['new_email']);
    $new_first_names = UserUtils::my_ucwords(trim($_POST['new_first_names']));
    $new_grade = $_POST['new_grade'];
    $new_year = isset($_POST['new_year']) ? $_POST['new_year'] : 1;
}
if (isset($_POST['submit']) and $unique_username == true) {
    if ($new_username == '' or strpos($new_username, '_') !== false or $new_surname == '' or $new_email == '' or $new_first_names == '' or $new_grade == '') {
        $problem = true;
    } else {
        $new_userID = UserUtils::create_user($new_username, $new_password, $_POST['new_users_title'], $new_first_names, $new_surname, $new_email, $new_grade, $_POST['new_gender'], $new_year, $tmp_roles, $_POST['new_sid'], $mysqli);
        // Send out email welcome.
        if (isset($_POST['new_welcome']) and $_POST['new_welcome'] != '') {
            $result = $mysqli->prepare("SELECT email FROM users WHERE username = ?");
            $result->bind_param('s', $userObject->get_username());
            $result->execute();
            $result->bind_result($tmp_email);
            $result->fetch();
            $result->close();
            $subject = "{$string['newrogoaccount']}";
            $headers = "From: {$tmp_email}\n";
            $headers .= "MIME-Version: 1.0\nContent-type: text/html; charset=UTF-8\n";
            $headers .= "bcc: {$tmp_email}\n";
            $sname = ucwords($_POST['new_surname']);
            $message = <<<MESSAGE
<!DOCTYPE html>
开发者ID:vinod-co,项目名称:centa,代码行数:31,代码来源:create_new_user.php


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