本文整理汇总了PHP中user::load方法的典型用法代码示例。如果您正苦于以下问题:PHP user::load方法的具体用法?PHP user::load怎么用?PHP user::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user
的用法示例。
在下文中一共展示了user::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: secure
public function secure()
{
if ($user = user::load()) {
return true;
}
return false;
}
示例2: reconcileAllPaymentUids
static function reconcileAllPaymentUids()
{
$txn = new paypal_transaction();
$extraWhere = "bp_biobounce_uid ='0'";
while ($txn->loadNext($extraWhere)) {
$found = false;
$email = $txn->get_variable('bp_paypal_email');
$paypalid = $txn->get_variable('bp_paypal_payer_id');
$txnFind = new paypal_transaction();
$extraWhere2 = "bp_biobounce_uid<>'0' AND bp_paypal_payer_id='" . $paypalid . "'";
if ($txnFind->load($extraWhere2)) {
$bioId = $txnFind->get_variable('bp_biobounce_uid');
$found = true;
//echo "\n\nFOUND THE USER ID BASED ON PREVIOUSLY BEING SET:PAYPALID=" . $paypalid;
} else {
$usr = new user();
$usr->set_variable('users_email', $email);
if ($usr->load()) {
$bioId = $usr->get_variable('users_id');
$found = true;
//echo "\nFOUND THE USER ID BASED ON SAME EMAIL ADDRESS:ADDRESS=" . $email;
}
}
if ($found) {
$txnId = $txn->get_variable('bp_id');
//echo "\nUPDATING TRANSACTION NUMBER=" . $txnId . " to use UID=" . $bioId;
$txn->set_variable('bp_biobounce_uid', $bioId);
$txn->update();
}
}
}
示例3: actionCreate
/**
* Creates a new user model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new user();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例4: get_context_name
/**
* Returns human readable context identifier.
*
* @param boolean $withprefix whether to prefix the name of the context with User
* @param boolean $short does not apply to user context
* @return string the human readable context name.
*/
public function get_context_name($withprefix = true, $short = false)
{
global $DB;
$name = '';
if ($user = new \user($this->_instanceid)) {
$user->load();
if ($withprefix) {
$name = get_string('user', 'local_elisprogram') . ': ';
}
$name .= $user->moodle_fullname();
}
return $name;
}
示例5: updateReferral
public static function updateReferral($newUserId, $referralCode)
{
$referredByUser = new user();
$referredByUser->set_variable('users_referralid', $referralCode);
echo "CHECKING REFERRAL";
if ($referredByUser->load()) {
$rbUid = $referredByUser->get_variable("users_id");
$referral = new referral();
$referral->set_variable("referral_referred_by_userid", $rbUid);
$referral->set_variable("referral_referred_userid", $newUserId);
$referral->set_variable("referral_date", date('Y-m-d'));
$referral->set_variable("referral_paid", 0);
$referral->createNew();
}
}
示例6: test_success
/**
* Test successful user creation.
*/
public function test_success()
{
global $DB;
// Create custom field.
$fieldcat = new field_category();
$fieldcat->name = 'Test';
$fieldcat->save();
$field = new field();
$field->categoryid = $fieldcat->id;
$field->shortname = 'testfield';
$field->name = 'Test Field';
$field->datatype = 'text';
$field->save();
$fieldctx = new field_contextlevel();
$fieldctx->fieldid = $field->id;
$fieldctx->contextlevel = CONTEXT_ELIS_USER;
$fieldctx->save();
$user = array('idnumber' => 'testuser', 'username' => 'testuser', 'firstname' => 'testuser', 'lastname' => 'testuser', 'email' => 'testuser@example.com', 'country' => 'CA', 'field_testfield' => 'Test Field');
$tempuser = new user();
$tempuser->reset_custom_field_list();
$this->give_permissions(array('local/elisprogram:user_create'));
$response = local_datahub_elis_user_create::user_create($user);
$this->assertNotEmpty($response);
$this->assertInternalType('array', $response);
$this->assertArrayHasKey('messagecode', $response);
$this->assertArrayHasKey('message', $response);
$this->assertArrayHasKey('record', $response);
$this->assertEquals(get_string('ws_user_create_success_code', 'local_datahub'), $response['messagecode']);
$this->assertEquals(get_string('ws_user_create_success_msg', 'local_datahub'), $response['message']);
$this->assertInternalType('array', $response['record']);
$this->assertArrayHasKey('id', $response['record']);
// Get user.
$createduser = new user($response['record']['id']);
$createduser->load();
$createduser = $createduser->to_array();
foreach ($user as $param => $val) {
$this->assertArrayHasKey($param, $createduser);
$this->assertEquals($val, $createduser[$param]);
}
}
示例7: getUserByFbId
public function getUserByFbId($fb_id)
{
$user = new user();
$user->load("fb_id = ?", array($fb_id));
return $user;
}
示例8: stillHasDefaultAccount
static function stillHasDefaultAccount()
{
$file = c::get('root.site') . '/' . c::get('panel.folder') . '/accounts/admin.php';
if (file_exists($file)) {
return true;
}
$dir = c::get('root.site') . '/' . c::get('panel.folder') . '/accounts';
$files = dir::read($dir);
$default = array('username' => 'admin', 'password' => 'adminpassword', 'language' => 'en');
foreach ($files as $file) {
$username = f::name($file);
$user = user::load($username);
$diff = array_diff($user, $default);
if (empty($diff)) {
return true;
}
}
return false;
}
示例9: testmenuofchoicesignorescarriagereturns
/**
* Validate that the "menu of choices" custom field type works correctly
* when options are separated by a carriage return and a line feed
*/
public function testmenuofchoicesignorescarriagereturns()
{
global $CFG, $DB;
require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
require_once elis::lib('data/customfield.class.php');
require_once elispm::file('accesslib.php');
require_once elispm::lib('data/user.class.php');
// Setup.
$field = new field(array('shortname' => 'testcustomfieldshortname', 'name' => 'testcustomfieldname', 'datatype' => 'char'));
$category = new field_category(array('name' => 'testcategoryname'));
field::ensure_field_exists_for_context_level($field, CONTEXT_ELIS_USER, $category);
$ownerparams = array('control' => 'menu', 'options' => "option1\r\noption2");
field_owner::ensure_field_owner_exists($field, 'manual', $ownerparams);
// Run the create action.
$record = new stdClass();
$record->action = 'create';
$record->email = 'testuser@mail.com';
$record->username = 'testuser';
$record->idnumber = 'testuserid';
$record->firstname = 'testuserfirstname';
$record->lastname = 'testuserlastname';
$record->country = 'CA';
$record->testcustomfieldshortname = 'option1';
$user = new user();
$user->reset_custom_field_list();
$importplugin = rlip_dataplugin_factory::factory('dhimport_version1elis');
$importplugin->fslogger = new silent_fslogger(null);
$importplugin->process_record('user', (object) $record, 'bogus');
// Validation.
$user = new user(1);
$user->load();
$this->assertEquals('option1', $user->field_testcustomfieldshortname);
}
示例10: class_notcompleted_handler
/**
* Function to handle class not completed events.
*
* @param student $student The class enrolment / student object who is "not completed"
* @uses $CFG
* @uses $DB
* @return boolean TRUE is successful, otherwise FALSE
*/
public static function class_notcompleted_handler($student)
{
global $CFG, $DB;
require_once elispm::lib('notifications.php');
/// Does the user receive a notification?
$sendtouser = elis::$config->local_elisprogram->notify_classnotcompleted_user;
$sendtorole = elis::$config->local_elisprogram->notify_classnotcompleted_role;
$sendtosupervisor = elis::$config->local_elisprogram->notify_classnotcompleted_supervisor;
/// If nobody receives a notification, we're done.
if (!$sendtouser && !$sendtorole && !$sendtosupervisor) {
return true;
}
if (!empty($student->moodlecourseid)) {
if (!($context = context_course::instance($student->moodlecourseid))) {
if (in_cron()) {
mtrace(get_string('invalidcontext'));
} else {
debugging(get_string('invalidcontext'));
}
return true;
}
} else {
$context = context_system::instance();
}
$message = new notification();
/// Set up the text of the message
$text = empty(elis::$config->local_elisprogram->notify_classnotcompleted_message) ? get_string('notifyclassnotcompletedmessagedef', self::LANG_FILE) : elis::$config->local_elisprogram->notify_classnotcompleted_message;
$search = array('%%userenrolname%%', '%%classname%%', '%%coursename%%');
$user = new user($student->userid);
if (!$user) {
if (in_cron()) {
mtrace(get_string('nouser', 'local_elisprogram'));
} else {
debugging(get_string('nouser', 'local_elisprogram'));
}
return true;
}
$user->load();
// Get course info
$pmcourse = $DB->get_record(course::TABLE, array('id' => $student->courseid));
$pmclass = $DB->get_record(pmclass::TABLE, array('id' => $student->classid));
$replace = array($user->moodle_fullname(), $pmclass->idnumber, $pmcourse->name);
$text = str_replace($search, $replace, $text);
$eventlog = new Object();
$eventlog->event = 'class_notcompleted';
$eventlog->instance = $student->classid;
$eventlog->fromuserid = $user->id;
if ($sendtouser) {
$message->send_notification($text, $user, null, $eventlog);
}
$users = array();
if ($sendtorole) {
/// Get all users with the notify_classnotcomplete capability.
if ($roleusers = get_users_by_capability($context, 'local/elisprogram:notify_classnotcomplete')) {
$users = $users + $roleusers;
}
}
if ($sendtosupervisor) {
/// Get parent-context users.
if ($supervisors = pm_get_users_by_capability('user', $user->id, 'local/elisprogram:notify_classnotcomplete')) {
$users = $users + $supervisors;
}
}
// Send notifications to any users who need to receive them.
foreach ($users as $touser) {
$message->send_notification($text, $touser, $user, $eventlog);
}
return true;
}
示例11: user
require_once elispm::lib('deprecatedlib.php');
// cm_get_crlmuserid()
require_once elispm::lib('data/user.class.php');
require_once elispm::lib('data/course.class.php');
require_once elispm::lib('data/certificatesettings.class.php');
require_once elispm::lib('data/certificateissued.class.php');
require_once elispm::lib('data/student.class.php');
require_once elispm::lib('data/instructor.class.php');
$ciid = required_param('id', PARAM_INT);
// Issued certificate id
$csid = required_param('csid', PARAM_INT);
// certificate setting id
global $USER;
$cmuserid = cm_get_crlmuserid($USER->id);
$student = new user($cmuserid);
$student->load();
if (empty($student->id)) {
return get_string('studentnotfound', 'local_elisprogram');
}
// Retrieve the certificate settings record
$certsettingrec = new certificatesettings($csid);
$certsettingrec->load();
// Check if the record exists or if the certificate is disabled
if (empty($certsettingrec->id) and !empty($certsettingrec->disable)) {
// Passing hard coded error code to disallow administrators from changing them to
// custom strings
echo get_string('errorfindingcertsetting', 'local_elisprogram', 'Error 11');
}
// Retrieve the certificate issued record
$certissuedrec = new certificateissued($ciid);
$certissuedrec->load();
示例12: currentUser
function currentUser()
{
global $lang;
$language = _DEFAULT_LANGUAGE_;
if (isset($_SESSION['USER_DATA']) && isset($_SESSION['USER_DATA']['ID'])) {
parent::user($_SESSION['USER_DATA']['ID']);
parent::load();
if (isset($this->details['language'])) {
$language = $this->details['language'];
}
}
// Load strings...
if ($language != $lang->id) {
$this->lang = new language($language, _DEFAULT_SITE_, true);
} else {
$this->lang =& $lang;
}
}
示例13: user
}
}
if (isset($error['top']) && $error['top'] != "" && $filled == TRUE) {
$error['top'] = '<div class="notification red">' . $error['top'] . '</div>';
}
//page
$pagecontent .= "<h3>My account:</h3>\n\t<p><b>Verification:</b> ";
if ($sessus->verified == TRUE) {
$pagecontent .= "Verified.</p>";
} else {
$pagecontent .= "Not verified. Contact website staff for verification.</p>";
}
$pagecontent .= "<p><b>Account state:</b> ";
if ($sessus->banned == TRUE) {
$bannedby = new user($sql, "id", $sessus->banned);
if ($bannedby->load()) {
$bannedby = $bannedby->username;
$pagecontent .= "Banned for " . $sessus->bannedreason . "(at " . $sessus->bannedtime . " by " . $bannedby . ")</p>";
}
} else {
$pagecontent .= "Good.</p>";
}
$pagecontent .= '<h4>Change Password</h4>
<form action="user.php" method="post">
' . $error['top'] . $message . '
<table>
<tr>
<td>Current password</td>
<td><input type="password" name="current" placeholder="Current Password" size="35"></td>
<td>' . $error['current'] . '</td>
示例14: _render_template
function render_video() {
return "<p>Showing recent video in sidebar widget.</p>";
}
private function _render_template($template) {
$tpl = new Template(CURRENT_THEME_FSPATH."/widget_$template.tpl");
return $tpl->fetch();
}
}
// --- controller (part 2)
// find user and badge
$user = new user();
$user->load((int)$login_uid);
try {
$badge = new Badge($user, $badge_tag);
} catch (PAException $e) {
switch ($e->code) {
case CONTENT_HAS_BEEN_DELETED:
case ROW_DOES_NOT_EXIST:
header("Location: " . PA::$url . "/badge_create.php");
exit;
default:
throw $e;
}
}
function badge_disp($content) {
if ($content instanceof Badge_Redirect) {
示例15: user
$filled['password'] = TRUE;
}
}
$isfilled = TRUE;
} else {
$error['top'] .= "<p>Both passwords must be identical.</p>";
$error['password2'] = "Both passwords must be identical.";
}
if ($isfilled == TRUE && $filled['username'] == TRUE && $filled['email'] == TRUE && $filled['password'] == TRUE) {
$user = new user($sql, "username", $_POST['username']);
$user->email = $_POST['email'];
$user->membersince = currentTime();
$user->logLogin();
if ($user->changePW($_POST['password'])) {
if ($user->save()) {
$user->load();
$_SESSION['userid'] = $user->id;
$pagecontent .= '
<div class="notification green">
<p>Your account has been created.</p>
</div>';
} else {
$pagecontent .= '
<div class="notification red">
<p>Failed to save user.</p>
</div>';
}
} else {
$pagecontent .= '
<div class="notification red">
<p>Failed to save user.</p>