本文整理汇总了PHP中UserModel类的典型用法代码示例。如果您正苦于以下问题:PHP UserModel类的具体用法?PHP UserModel怎么用?PHP UserModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UserModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removeUser
/**
* Removes the $userId from this project.
* Note that you still need to call write() to persist the model.
* @param string $userId
*/
public function removeUser($userId)
{
$this->_removeUser($userId);
$userModel = new UserModel($userId);
$userModel->_removeProject($this->id);
$userModel->write();
}
示例2: infoAction
/**
* 节的详细页(视频学习页)
*
*/
function infoAction()
{
$videoId = (int) $this->get("video_id", 0);
$videoId = $videoId ? $videoId : $this->section['video_id'];
$videoModel = new VideoModel();
$video = $videoModel->getVideo($videoId);
$video['is_user_like'] = $videoModel->isUserLikeOrDislike($this->uid, $videoId);
$data = array('course_id' => $this->course['id'], 'course_name' => $this->course['name'], 'chapter_id' => $this->chapter['id'], 'chapter_name' => $this->chapter['name'], 'chatper_seq' => $this->chapter['seq'], 'section_id' => $this->section['id'], 'section_name' => $this->section['name'], 'section_seq' => $this->section['seq'], 'video_id' => $video['id'], 'video_url' => $video['url'], 'video_duration' => $video['duration'], 'duration' => $video['duration'], 'video_image' => $video['image'], 'video_like_num' => $video['like_num'], 'video_dislike_num' => $video['dislike_num'], 'video_view_num' => $video['view_num'], 'is_user_like' => $video['is_user_like']);
if (!$this->teacher || $this->teacher['id'] != $video['user_id']) {
$userModel = new UserModel();
$this->teacher = $userModel->getTeacher($video['user_id']);
}
$data['teacher'] = array('id' => $this->teacher['id'], 'name' => $this->teacher['name'], 'job_title' => $this->teacher['job_title'], 'avator' => $this->teacher['avator']);
if ($this->isMobile) {
$this->displayJson(Common_Error::ERROR_SUCCESS, $data);
}
if ($this->course['type'] == 1) {
$practiseModel = new PractiseModel();
$practise = $practiseModel->getVideoBelongPractise($videoId, $this->course['id']);
$this->assign("practise", $practise);
}
$this->assign("course", $this->course);
$this->assign("chapter", $this->chapter);
$this->assign("section", $this->section);
$this->assign("teacher", $this->teacher);
$this->assign("video", $video);
}
示例3: run
public function run()
{
$autorize = Project::getSecurityManager()->getAutorize();
$controller_class = $autorize->getController()->name;
$controller = new $controller_class();
$controller->init($autorize->getController(), $autorize->getAction());
$action_function = $autorize->getAction()->name . 'Action';
setcookie('PHPSESSID', session_id(), null, null, Project::getUser()->getDbUser()->login . '.next24.ru');
$controller->{$action_function}();
$this->_request_complete = true;
// Сохраняем время пользователя на серваке
$user = Project::getUser()->getDbUser();
if ($user->id) {
$userModel = new UserModel();
$userModel->refreshUsersOnline();
if (!$userModel->isUserOnline($user->id)) {
$userModel->addUserOnline($user->id);
} else {
$userModel->updateUserOnline($user->id);
}
$userModel = new UserModel();
$user = $userModel->getUserById($user->id);
$userModel->checkForUserBans($user);
}
// END Сохраняем время пользователя на серваке
return $controller;
}
示例4: loadBy
/**
* Load user by a particular field
* @param string $field The field to find by
* @param string $value The field value
* @return UserModel
*/
public static function loadBy($field, $value)
{
global $wpdb;
$UserModel = new UserModel();
switch ($field) {
case 'id':
$memberData = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}{$UserModel->_tableName} WHERE user_id = %d AND status != 'deleted'", $value), ARRAY_A);
break;
case 'verification_code':
$memberData = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}{$UserModel->_tableName} WHERE verification_code = %s AND status != 'deleted'", $value), ARRAY_A);
break;
case 'reset_password_code':
$memberData = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}{$UserModel->_tableName} WHERE reset_password_code = %s AND status != 'deleted'", $value), ARRAY_A);
break;
case 'email_address':
$memberData = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->prefix}{$UserModel->_tableName} WHERE email_address = %s AND status != 'deleted'", $value), ARRAY_A);
break;
}
if ($memberData) {
$UserModel->setId($memberData['user_id']);
$UserModel->populateFromArray($memberData);
if ($UserModel->getStatus() == 'deleted') {
return new UserModel();
}
}
return $UserModel;
}
示例5: onedaysummaryAction
public function onedaysummaryAction()
{
$now = time();
$onedaybefore = $now - 60 * 60 * 24;
$threadModel = new ThreadModel();
$newThread = $threadModel->newThreadsFrom($onedaybefore);
$topThread = $threadModel->topThreadsFrom(10, $onedaybefore);
$bbsHero = $threadModel->topBbsHero(10, $onedaybefore);
$newscenter = new NewscenterModel();
$news = $newscenter->news(1, 10, "apple");
$data = array();
$data["newThread"] = $newThread;
$data["topThread"] = $topThread;
$data["bbsHero"] = $bbsHero;
$data["news"] = $news;
$mail = new MailModel();
$userModel = new UserModel();
$users = $userModel->dailyNewsUser();
foreach ($users as $user) {
$data["user"] = $user;
$page = $this->makePage("MailTemplate", "dailysummary", $data);
$mail->generateMail($user["email"], "OurCoders社区 <noreply@OurCoders.com>", "OurCoders社区每日精选", $page, 0);
}
echo "ok";
}
示例6: indexAction
public function indexAction()
{
$p = $_REQUEST;
$pPhone = empty($p['phone']) ? '' : trim($p['phone']);
$pNewptxt = empty($p['newptxt']) ? '' : trim($p['newptxt']);
$pCode = empty($p['code']) ? '' : intval(trim($p['code']));
$tTime = time();
if (empty($pPhone)) {
Tool_Fnc::ajaxMsg('请输入手机号码');
}
if (empty($pNewptxt)) {
Tool_Fnc::ajaxMsg('请输入新密码');
}
if (!Tool_Validate::mo($pPhone)) {
Tool_Fnc::ajaxMsg('手机号不正确');
}
$tMO = new UserModel();
$tRow = $tMO->field('*')->where('phone = \'' . $pPhone . '\'')->fRow();
if (empty($tRow['id'])) {
Tool_Fnc::ajaxMsg('用户不存在');
}
$tCodeMO = new PhonecodeModel();
$tCodeCRow = $tCodeMO->check($pPhone, 2, $pCode);
if ($tCodeCRow['status'] == 0) {
Tool_Fnc::ajaxMsg($tCodeCRow['msg']);
}
$tKey = Tool_Fnc::newrand(4);
$tMd5str = Tool_Fnc::markmd5($pNewptxt, $tKey);
$tData = array('passwd' => $tMd5str, 'id' => $tRow['id'], 'private_key' => $tKey);
if ($tMO->update($tData)) {
Tool_Fnc::ajaxMsg('密码修改成功', 1);
}
Tool_Fnc::ajaxMsg('密码修改失败');
}
示例7: index
public function index()
{
//var_dump($_SESSION['qq']);
$articleId = $_GET['articleId'];
$article = new ArticleModel();
$content = $article->getArticleById($articleId);
$collect = new CollectModel();
$comment = new CommentModel();
$commentNum = $comment->getCommentCountByArticleId($articleId);
$content['commentNum'] = $commentNum;
if ($this->isLogin()) {
if ($collect->getCollects($article, $_SESSION['qq']['userId'])) {
$this->assign('collects', '已收藏');
} else {
$collectNum = $collect->getCollectCountByuserId($article);
$this->assign('collectNum', $collectNum);
$this->assign('collects', '收藏');
}
}
$this->assign('article', $content);
//评论查询
$comments = $comment->getComment($articleId);
$user = new UserModel();
$arr = array();
foreach ($comments as $key => $val) {
$val[$key]['user'] = $user->getUserById($val['userId']);
}
$this->assign('comments', $comments);
$this->display();
}
示例8: DebuguserresetMethod
public function DebuguserresetMethod()
{
$this->bAjaxMethod = true;
$oUser = new UserModel();
echo $oUser->DebugUserReset();
$oUser->oPDO = NULL;
}
示例9: indexAction
public function indexAction()
{
$auth = Zend_Auth::getInstance();
if (!$auth->hasIdentity()) {
throw new Exception("Please login");
}
$user = User::factory($auth->getIdentity());
if (!$user->isAdmin()) {
throw new Exception("You must be an admin to view this page.");
}
$this->_helper->viewRenderer->setNoRender();
Zend_Loader::loadClass("UserModel");
$usermodel = new UserModel();
$users = $usermodel->getUserList();
foreach ($users as $username) {
$user = User::factory($username);
$memcount = $usermodel->getMemberCount($user);
for ($i = 0; $i < $memcount; $i++) {
$member = $usermodel->getMember($user, $i);
if (!empty($member->email)) {
echo "{$member->email}, ";
}
}
}
}
示例10: validateOptions
/**
* Returns whether or not the user meets the criteria necessary to trigger the event
*
* @param mixed $options
* @param UserModel $user
* @param array $params
*
* @return bool
*/
public function validateOptions($options, UserModel $user, array $params = array())
{
$isNewUser = isset($params['isNewUser']) && $params['isNewUser'];
$onlyWhenNew = isset($options['usersSaveUserOnlyWhenNew']) && $options['usersSaveUserOnlyWhenNew'];
// If any user groups were checked
// Make sure the user is in one of the groups
if (!empty($options['usersSaveUserGroupIds']) && count($options['usersSaveUserGroupIds'])) {
$inGroup = false;
$userGroups = $user->getGroups('id');
foreach ($options['usersSaveUserGroupIds'] as $groupId) {
if (array_key_exists($groupId, $userGroups)) {
$inGroup = true;
}
}
if (!$inGroup) {
return false;
}
}
// If only new users was checked
// Make sure this user is new
if (!$onlyWhenNew || $onlyWhenNew && $isNewUser) {
return true;
}
return false;
}
示例11: getStaffDetails
public function getStaffDetails($userid)
{
$user_model = new UserModel();
//GET NECESSARY USER DETAILS FROM MODEL
$staff_details = $user_model->getUserDetails($userid);
//GET USER EXISTING ROLE(S)
$user_roles = $user_model->getUserRoles($userid);
//EXTRACT ROLE ID(S)
$user_role_ids = array();
foreach ($user_roles as $role) {
array_push($user_role_ids, $role[PermissionRoleTable::staff_role_id]);
}
//GET ALL STAFF ROLES
$all_roles = $user_model->getAllRoles();
//COMPARE USER EXISTING ROLE(S) WITH ALL STAFF ROLES TO EXTRACT
//UNASSIGNED ROLES
$available_roles = array();
foreach ($all_roles as $role) {
if (!in_array($role[StaffRoleTable::staff_role_id], $user_role_ids)) {
array_push($available_roles, $role);
}
}
//POPULATE ROLES IN RESPONSE ACCORDING TO AVAILABILITY
$staff_details[ROLES][EXISTING] = $user_roles;
$staff_details[ROLES][AVAILABLE] = $available_roles;
return $staff_details;
}
示例12: indexAction
public function indexAction()
{
$model = new UserModel();
$user = $model->findById(1);
echo $user->id;
return FALSE;
}
示例13: actionInsert
public function actionInsert()
{
if (isset($_POST['submit']) && $_POST['submit'] == 'Insert Procuct') {
$pro = new ProModel();
$pro->name = $_POST['product_name'];
$pro->description = $_POST['product_desc'];
$product_image = $_FILES['product_image']['name'];
$product_image_tmp = $_FILES['product_image']['tmp_name'];
move_uploaded_file($product_image_tmp, "img/{$product_image}");
$pro->image = $product_image;
$pro->price = $_POST['product_price'];
$pro->save();
header('Location: http://localhost/task/task2/admin_area/index.php');
exit;
}
if (isset($_POST['sub'])) {
$user = new UserModel();
$user->first_name = $_POST['fn'];
$user->last_name = $_POST['ln'];
$user->email = $_POST['em'];
$user->save();
$ord = new OrdersModel();
$ord->user_id = $_POST['id'];
$ord->sum = $_POST['price'];
$ord->order_date = date("Y/m/d h:i:s");
$ord->save();
$ordPro = new OrdersProModel();
$ordPro->order_id = $_POST['id'];
$ordPro->product_id = $_POST['id'];
$ordPro->qty = $_POST['quantity'];
$ordPro->save();
header('Location: http://localhost/task/task2/admin_area/index.php');
exit;
}
}
示例14: __construct
/**
* construct function
*/
public function __construct($controller, $action)
{
parent::__construct($controller, $action);
$um = new UserModel();
$this->user = $um->loadUser();
$this->setView('curUser', $this->user);
}
示例15: setReadAction
/**
* 处理已读消息
*/
public function setReadAction()
{
echo date('Y-m-d H:i:s') . ' setRead is started!' . PHP_EOL;
$queueKey = Yaf\Application::app()->getConfig()->redisKeys->setReadQueue;
$readKeyPrefix = Yaf\Application::app()->getConfig()->redisKeys->readKeyPrefix;
$redis = RedisFactory::instance('ims', true);
while (true) {
while ($userId = $redis->lPop($queueKey)) {
$key = $readKeyPrefix . '_' . $userId;
while ($messageId = $redis->lpop($key)) {
$messageModel = new MessageModel($userId);
$messageModel->setIsRead($messageId);
}
//推送未读消息变动通知
$userModel = new UserModel();
pushModel::unreadMessageNotice($userModel->getUnreadMessageList(true));
}
try {
// 闲置时检查Redis连接
$redis->ping();
} catch (\Exception $e) {
$redis = RedisFactory::instance('ims', true, true);
//重连
}
sleep(1);
}
exit;
}