本文整理汇总了PHP中User_Model类的典型用法代码示例。如果您正苦于以下问题:PHP User_Model类的具体用法?PHP User_Model怎么用?PHP User_Model使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了User_Model类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setFirst
public function setFirst()
{
// 获取要赠送的短信的条数
$sms_count = 0;
$fields = array();
// 如果还没设置过信息,则进行设置,并送短信
foreach ($this->_support as $field => $smsCount) {
$this->_field = $field;
if (!$this->hasSet() && $this->_support[$this->_field] > 0) {
$sms_count += $smsCount;
$fields[] = $field;
}
}
if ($sms_count > 0) {
// 赠送短信,并发送通知
$user = User_Model::instance();
$smsUpdateStr = $this->smsUpdateStr();
$content = '您好,这是您第一次设置' . $smsUpdateStr . ',系统赠送了' . $sms_count . '条短信给您';
// echo $content;
try {
// @todo 应该支持事务操作
$updated = $this->updateField($fields);
$user->present_sms($this->_uid, $sms_count, $content, false);
} catch (Exception $e) {
}
}
return $sms_count;
}
示例2: __construct
public function __construct($request)
{
parent::__construct($request);
$this->templateDirectory = realpath(dirname(__FILE__) . "/../template") . "/";
$this->template = "itemEdit.html.php";
$UserModel = new User_Model();
$this->component = "menu";
$itemId = $request->get("itemId");
if (empty($itemId)) {
$this->action = "insert";
} else {
$this->action = "update";
}
$this->aItemSelect = DKY_Item::getItems(null, true);
if (empty($itemId) && !empty($_SESSION["aBlock"][$this->block_id]["itemId"])) {
$itemId = $_SESSION["aBlock"][$this->block_id]["itemId"];
}
if (empty($itemId) || $this->action == "insert") {
$this->action = "insert";
$this->aItem = null;
unset($_SESSION["aBlock"][$this->block_id]["itemId"]);
} else {
$_SESSION["aBlock"][$this->block_id]["itemId"] = $itemId;
$this->aItem = DKY_Item::getItemById($itemId);
$this->action = "update";
unset($this->aItemSelect[$itemId]);
// Can't select itself as a parent.
}
$this->aGroups = $UserModel->getGroups(true);
$this->getItemsURL = DKY_HTTP::makeURL($request->aURL["path"], "menu", "get_items");
$this->cancelURL = DKY_HTTP::makeURL($request->aURL["path"], "menu", "list_items");
}
示例3: play_game
function play_game($shotbox)
{
$usuario = new User_Model();
$toView["view"] = 'battlefield_view';
$toView["userHit"] = $this->user_play($shotbox);
$toView["fired"] = $this->sesion->obtener('fired');
if ($this->check_player() == 1) {
$id = $this->sesion->obtener('id');
$usuario->won($id);
$usuario->finished($id);
$usuario->avgMoves($id, $tries);
$usuario->setRanking($id);
$toView["enemyFleet"] = $this->sesion->obtener('enemyFleet');
$toView["winner"] = 1;
$toView["userHits"] = $this->sesion->obtener('userHits');
$toView["enemyHits"] = $this->sesion->obtener('enemyHits');
$toView["view"] = "results_view";
return $toView;
}
$toView["enemyHit"] = $this->enemy_play();
$toView["userFleet"] = $this->sesion->obtener('userFleet');
if ($this->check_enemy() == 1) {
$id = $this->sesion->obtener('id');
$usuario->lost($id);
$usuario->finished($id);
$usuario->setRanking($id);
$toView["enemyFleet"] = $this->sesion->obtener('enemyFleet');
$toView["winner"] = 2;
$toView["userHits"] = $this->sesion->obtener('userHits');
$toView["enemyHits"] = $this->sesion->obtener('enemyHits');
$toView["view"] = 'results_view';
return $toView;
}
return $toView;
}
示例4: create
public function create()
{
$this->template->content = new View('users/create');
$form = new Validation($_POST);
$form->pre_filter('trim', true);
$form->add_rules('username', 'required')->add_rules('password', 'required')->add_rules('email', 'required', 'valid::email');
$this->template->content->repopulate = $form;
if ($form->validate()) {
// Create new user
$user = new User_Model();
if (!$user->username_exists($this->input->post('username'))) {
foreach ($form->as_array() as $key => $val) {
// Set user data
$user->{$key} = $val;
}
if ($user->validate($form->as_array())) {
if ($user->add(ORM::factory('role', 'login')) and $user->save()) {
// Redirect to the login page
url::redirect('login');
}
}
}
}
// Error
$this->template->content->error = $form->errors('login');
}
示例5: p_delete_action
function p_delete_action($id)
{
$post_Model = new User_Model();
$post_Model->delete_post($id);
$posts = $post_Model->get_all_posts();
require "view/template/user/admin.php";
}
示例6: get_by_id
public function get_by_id($id)
{
$user_model = null;
//DATABASE CONNECTION
$this->db->connect();
//SELECT BY ID
$sql = "SELECT * FROM user WHERE user_id=?";
//PREPARE
$stmt = $this->db->initialize($sql);
//BIND
$stmt->bind_param("i", $id);
//EXECUTE
$stmt->execute();
//BIND RESULT
$stmt->bind_result($user_id, $user_name, $first_name, $last_name, $contact_number, $user_type, $user_status, $user_hash);
while ($stmt->fetch()) {
//instantiate object
$user_model = new User_Model();
$user_model->set_user_id($user_id);
$user_model->set_user_name($user_name);
$user_model->set_first_name($first_name);
$user_model->set_last_name($last_name);
$user_model->set_contact_number($contact_number);
$user_model->set_user_type($user_type);
$user_model->set_user_status($user_status);
$user_model->set_user_hash($user_hash);
}
$this->db->close();
return $user_model;
}
示例7: run
public function run()
{
try {
$m_user = new User_Model();
$view = new Login_View();
$view->setparm('pagetitle', "用户登录" . $TITLE_SUFFIX);
//TODO:反注入
//TODO:验证码
try {
if (isset($_POST['username'])) {
$userid = $m_user->getuserid($_POST['username']);
switch ($m_user->checkpassword($userid, $_POST['password'])) {
case $m_user::CHECKPWD_ACCEPTED:
session_start();
$_SESSION['userid'] = $userid;
$_SESSION['expiretime'] = time() + $SESSION_ADD_TIME;
$_SESSION['absexpiretime'] = time() + $_POST['vaildtime'];
header("Location: " . $MAIN_PAGE_URL);
break;
case $m_user::CHECKPWD_DENIED:
throw new AuthFailed($TXT_PASSWORD_ERROR);
break;
case $m_user::CHECKPWD_RESTRICTED:
throw new AuthFailed($TXT_USER_RESTRICTED);
}
}
} catch (AuthFailed $e) {
$view->setparm('errormsg', $e->getMessage());
}
} catch (ResourceFailed $e) {
$view->setparm('errormsg', $e->getMessage());
}
$view->render();
}
示例8: staff
function staff($id, $display = 'week')
{
$um = new User_Model();
$um->get_by_id($id);
if (!$um->exists()) {
return;
}
$this->data['object'] = $um;
$um->shift->where('status', SHIFT_MODEL::STATUS_ACTIVE);
/* find min and max date */
$max_date = $um->shift->select_max('date')->get()->date;
$min_date = $um->shift->select_min('date')->get()->date;
$shifts = $um->shift->get_iterated();
/* compile dates */
$dates = array();
$date = $min_date;
$this->hc_time->setDateDb($date);
switch ($display) {
case 'week':
$this->hc_time->setStartWeek();
break;
case 'month':
$this->hc_time->setStartMonth();
break;
}
$date = $this->hc_time->formatDate_Db();
while ($date <= $max_date) {
switch ($display) {
case 'week':
$start = $this->hc_time->formatDate_Db();
$this->hc_time->setEndWeek();
$end = $this->hc_time->formatDate_Db();
break;
case 'month':
$start = $this->hc_time->formatDate_Db();
$this->hc_time->setEndMonth();
$end = $this->hc_time->formatDate_Db();
break;
}
$dates[$start . '-' . $end] = array('shift_count' => 0, 'shift_duration' => 0, 'timeoff_count' => 0, 'timeoff_duration' => 0);
$this->hc_time->modify('+1 day');
$date = $this->hc_time->formatDate_Db();
}
foreach ($shifts as $sh) {
reset($dates);
foreach (array_keys($dates) as $dk) {
list($start, $end) = explode('-', $dk);
if ($sh->date >= $start && $sh->date <= $end) {
$dates[$dk]['shift_count']++;
$dates[$dk]['shift_duration'] += $sh->get_duration();
}
}
}
$this->data['dates'] = $dates;
$this->data['display'] = $display;
// $this->conf['path'] = 'admin/users';
$this->set_include('edit/stats', 'admin/users');
$this->load->view($this->template, $this->data);
}
示例9: signUp
/**
* This method will handle the signup process
*
*/
function signUp()
{
$json_data = json_decode(file_get_contents('php://input'));
$data = array('name' => $json_data->{'username'}, 'email' => $json_data->{'email'}, 'password' => $json_data->{'password'}, 'privilages' => 2);
$this->load->model('User_Model');
$user_model = new User_Model();
$isAdded = $user_model->addNewUser($data);
echo json_encode(array("status" => $isAdded));
}
示例10: setup
public function setup()
{
$user = new User_Model();
$user->email = 'geek@hdragomir.com';
$user->username = 'geek';
$user->password = 'geekmeet';
$user->roles = array(new Role_Model(1));
$user->save();
}
示例11: get_all
public function get_all()
{
//ARRAY OBJECT HARU PASS GARNA
$user_list = array();
//DATABASE CONNECTION
$this->db->connect();
//SELECT ALL QUERY
$sql = "SELECT user_id,user_name,first_name,last_name,contact_number,user_type,user_status,gen_id,age FROM user INNER JOIN generaluser ON user_id = u_id";
//fetchquery
$result = $this->db->fetchquery($sql);
//STORE IN OBJECT AND SEND TO VIEW
while ($row = $result->fetch_assoc()) {
$user_model = new User_Model();
$user_model->set_user_id($row['user_id']);
$user_model->set_user_name($row['user_name']);
$user_model->set_first_name($row['first_name']);
$user_model->set_last_name($row['last_name']);
$user_model->set_contact_number($row['contact_number']);
$user_model->set_user_type($row['user_type']);
$user_model->set_user_status($row['user_status']);
array_push($user_list, $user_model);
}
$this->db->close();
return $user_list;
}
示例12: list_all
/**
* View all registered users
*
* @access public
* @return string Returns XML containing list of all users or error message
*/
public function list_all()
{
if (apiler::is_authorized()) {
$users = new User_Model();
$list = $users->list_all_users();
$view = new View('api/user_list');
$view->list = $list;
$view->render(true);
} else {
apiler::not_authorized();
}
}
示例13: createObjectFromData
public function createObjectFromData($row)
{
//Create a new user_model object
$user = new User_Model();
//Set the ID on the user model
$user->setId($row->id);
//Set the username on the user model
$user->setUsername($row->username);
//Set the password on the user model
$user->setPassword($row->password);
//Return the new user object
return $user;
}
示例14: is_authorized
/**
* Check if user is authorized
*
* @access public
* @static
* @return boolean Returns TRUE if authorized and FALSE otherwise
*/
public static function is_authorized()
{
if (isset($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) {
$user = new User_Model();
if ($user->login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) {
return true;
} else {
return false;
}
} else {
return false;
}
}
示例15: insert
public function insert($category, $username, $value)
{
$cat = new Category_Model();
$category = $cat->get_id($category);
$user = new User_Model();
$username = $user->get_id($username);
$results = $this->db->query("INSERT INTO results SET cat_id = ?, user_id = ?, value = ?, result_date = NOW()", $category, $username, $value);
if ($results) {
return true;
} else {
return false;
}
}