本文整理汇总了PHP中User类的典型用法代码示例。如果您正苦于以下问题:PHP User类的具体用法?PHP User怎么用?PHP User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了User类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: view
public function view()
{
$dao = DAO::getDAO('UserDAO');
if (isset($this->params[0]) && trim($this->params[0]) == 'remove') {
// ex: requesting: /user-list/delete/2
$id = trim(sanitizeString($this->params[1]));
$dao->removeById($id);
} else {
if (isset($this->params[0]) && trim($this->params[0]) == 'add') {
$randNum = mt_rand(0, 99999);
$newUser = new User(array('firstName' => 'First', 'lastName' => 'LastName', 'username' => "test{$randNum}", 'email' => "test{$randNum}@example.com", 'createTime' => dbDateTime()));
// #TODO: implement UserDao.create($newUser) instead.
if ($dao->countAll() > 30) {
// Demo mode: clean up if too many users
$dao->execute("DELETE FROM user");
$dao->execute("vacuum");
}
$dao->insertInto("firstName, lastName, username, email, createTime", $newUser->getFields());
}
}
$users = $dao->getAll();
$v = $this->smarty;
$v->assign('title', 'User List');
$v->assign('inc_content', v('user_list.html'));
$v->assign('users', $users);
$v->assign('totalUsers', $dao->countAll());
$this->display($v, v('index.html'));
}
开发者ID:rsanaie,项目名称:Thin-PHP-Framework,代码行数:28,代码来源:UserList.php
示例2: getAllowedFileExtensions
public function getAllowedFileExtensions()
{
$u = new User();
$extensions = array();
if ($u->isSuperUser()) {
$extensions = Loader::helper('concrete/file')->getAllowedFileExtensions();
return $extensions;
}
$pae = $this->getPermissionAccessObject();
if (!is_object($pae)) {
return array();
}
$accessEntities = $u->getUserAccessEntityObjects();
$accessEntities = $pae->validateAndFilterAccessEntities($accessEntities);
$list = $this->getAccessListItems(FileSetPermissionKey::ACCESS_TYPE_ALL, $accessEntities);
$list = PermissionDuration::filterByActive($list);
foreach ($list as $l) {
if ($l->getFileTypesAllowedPermission() == 'N') {
$extensions = array();
}
if ($l->getFileTypesAllowedPermission() == 'C') {
$extensions = array_unique(array_merge($extensions, $l->getFileTypesAllowedArray()));
}
if ($l->getFileTypesAllowedPermission() == 'A') {
$extensions = Loader::helper('concrete/file')->getAllowedFileExtensions();
}
}
return $extensions;
}
开发者ID:Zyqsempai,项目名称:amanet,代码行数:29,代码来源:add_file.php
示例3: tickets_handle_on_milestone_add_links
/**
* Handle on_milestone_add_links event
*
* @param Milestone $milestone
* @param User $user
* @param array $links
* @return null
*/
function tickets_handle_on_milestone_add_links($milestone, $user, &$links)
{
if ($user->getProjectPermission('ticket', $milestone->getProject()) >= PROJECT_PERMISSION_CREATE) {
$links[lang('Ticket')] = tickets_module_add_ticket_url($milestone->getProject(), array('milestone_id' => $milestone->getId()));
}
// if
}
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:15,代码来源:on_milestone_add_links.php
示例4: createParent
public function createParent()
{
$input = Input::all();
if (Input::hasFile('profilepic')) {
$input['profilepic'] = $this->filestore(Input::file('profilepic'));
}
$input['dob'] = date('Y-m-d H:i:s', strtotime(Input::get('dob')));
$input['collegeid'] = Session::get('user')->collegeid;
$input['collegename'] = Admin::where('collegeid', '=', Session::get('user')->collegeid)->first()->collegename;
//$input['collegeid']="dummy";
//$input['collegename']="dummy";
$user = new User();
$user->email = $input['email'];
$user->password = Hash::make($input['password']);
$user->collegeid = $input['collegeid'];
$user->flag = 3;
$user->save();
$input['loginid'] = $user->id;
$removed = array('_token', 'password', 'cpassword');
foreach ($removed as $k) {
unset($input[$k]);
}
Parent::saveFormData($input);
return $input;
}
开发者ID:pankaja455,项目名称:WebSchool,代码行数:25,代码来源:ParentController.php
示例5: setUser
public function setUser(User $user)
{
if ($this->user !== $user) {
$this->user = $user;
$user->setAddress($this);
}
}
开发者ID:Herriniaina,项目名称:iVarotra,代码行数:7,代码来源:Address.php
示例6: updateUser
public static function updateUser()
{
// Process updating of user information
$users = UsersDB::getUsersBy('userId', $_SESSION['arguments']);
if (empty($users)) {
HomeView::show();
header('Location: /' . $_SESSION['base']);
} elseif ($_SERVER["REQUEST_METHOD"] == "GET") {
$_SESSION['users'] = $users;
UserView::showUpdate();
} else {
$parms = $users[0]->getParameters();
$parms['userName'] = array_key_exists('userName', $_POST) ? $_POST['userName'] : "";
$parms['password'] = array_key_exists('password', $_POST) ? $_POST['password'] : "";
$newUser = new User($parms);
$newUser->setUserId($users[0]->getUserId());
$user = UsersDB::updateUser($newUser);
if ($user->getErrorCount() != 0) {
$_SESSION['users'] = array($newUser);
return;
UserView::showUpdate();
} else {
HomeView::show();
header('Location: /' . $_SESSION['base']);
}
}
}
开发者ID:raroseman,项目名称:cs4413-Hoodflix,代码行数:27,代码来源:UserController.class.php
示例7: action_create
public function action_create()
{
$this->template->title = __("Thêm mới tài khoản");
$this->template->section_title = __("Thêm mới tài khoản");
$data = array();
if (Request::$method == "POST") {
$user = new User();
$post = $user->validate_create($_POST);
if ($post->check()) {
$post_values = $post->as_array();
//print_r($post_values);
$t = $user->register($post_values['email'], $post_values['password'], (bool) $post_values['active']);
if ($t) {
//Request::instance()->redirect('admin/user/index');
Request::instance()->redirect('admin/user/role/' . $t->id);
} else {
$post->error('email', 'user_not_save', array('Can\'t save new user!'));
}
} else {
#Repopulate $_POST data
$_POST = $post->as_array();
//error
$data['errors'] = $post->errors('admin/user/form');
//print_r($post->errors());
}
}
$this->template->content = View::factory('admin/user/create', $data);
}
开发者ID:abdul-baten,项目名称:hbcms,代码行数:28,代码来源:user.php
示例8: testFromArrayRecord
public function testFromArrayRecord()
{
$user = new User();
$userArray = $user->toArray();
# add a Phonenumber
$userArray['Phonenumber'][0]['phonenumber'] = '555 321';
# add an Email address
$userArray['Email']['address'] = '[email protected]';
# add group
$userArray['Group'][0]['name'] = 'New Group'; # This is a n-m relationship
# add a group which exists
$userArray['Group'][1]['_identifier'] = $this->previous_group; # This is a n-m relationship where the group was made in prepareData
$user->fromArray($userArray);
$this->assertEqual($user->Phonenumber->count(), 1);
$this->assertEqual($user->Phonenumber[0]->phonenumber, '555 321');
$this->assertEqual($user->Group[0]->name, 'New Group');
$this->assertEqual($user->Group[1]->name, 'Group One');
try {
$user->save();
} catch (Exception $e ) {
$this->fail("Failed saving with " . $e->getMessage());
}
}
开发者ID:prismhdd,项目名称:victorioussecret,代码行数:29,代码来源:FromArrayTestCase.php
示例9: rescan_locale
public function rescan_locale()
{
if ($this->token->validate('rescan_locale')) {
$u = new \User();
if ($u->isSuperUser()) {
\Core::make('cache/request')->disable();
$section = Section::getByID($_REQUEST['locale']);
$target = new MultilingualProcessorTarget($section);
$processor = new Processor($target);
if ($_POST['process']) {
foreach ($processor->receive() as $task) {
$processor->execute($task);
}
$obj = new \stdClass();
$obj->totalItems = $processor->getTotalTasks();
echo json_encode($obj);
exit;
} else {
$processor->process();
}
$totalItems = $processor->getTotalTasks();
\View::element('progress_bar', array('totalItems' => $totalItems, 'totalItemsSummary' => t2("%d task", "%d tasks", $totalItems)));
exit;
}
}
}
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:26,代码来源:copy.php
示例10: load
/**
* Load all orders
*
* @param User $user
* @throws Exception
*/
public function load(User $user)
{
if ($user->getUserGroup() != User::ADMIN_USER_GROUP) {
throw new Exception('Only administrators can get reports');
}
//...
}
开发者ID:vasylmalanka,项目名称:Recruitment-task,代码行数:13,代码来源:OrderCollection.php
示例11: checkCanExecute
protected function checkCanExecute(User $user)
{
if (!$user->matchEditToken($this->getRequest()->getVal('token'), $this->getRequest()->getInt('rcid'))) {
throw new ErrorPageError('sessionfailure-title', 'sessionfailure');
}
return parent::checkCanExecute($user);
}
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:7,代码来源:MarkpatrolledAction.php
示例12: run
/**
* Daily social statistic collect
* Add new access token to Queue
*
* @access public
* @return void
*/
public function run()
{
$types = array('twitter');
$tokens = Access_token::inst()->where_in('type', $types)->get();
$aac = $this->getAAC();
$now = new \DateTime('UTC');
foreach ($tokens as $_token) {
$now->modify('1 minutes');
$user = new User($_token->user_id);
if (!$user->exists()) {
continue;
}
$aac->setUser($user);
if (!$aac->isGrantedPlan('social_activity')) {
continue;
}
$args = $_token->to_array();
foreach ($_token->social_group->get() as $profile) {
$args['profile_id'] = $profile->id;
//Twitter tasks
$this->jobQueue->addJob('tasks/twitter_task/searchUsers', $args, array('thread' => self::SOCIAL_THREAD, 'execute_after' => $now));
$this->jobQueue->addJob('tasks/twitter_task/updateFollowers', $args, array('thread' => self::SOCIAL_THREAD, 'execute_after' => $now));
$this->jobQueue->addJob('tasks/twitter_task/randomRetweet', $args, array('thread' => self::SOCIAL_THREAD, 'execute_after' => $now));
$this->jobQueue->addJob('tasks/twitter_task/randomFavourite', $args, array('thread' => self::SOCIAL_THREAD, 'execute_after' => $now));
$this->jobQueue->addJob('tasks/twitter_task/sendWelcomeMessage', $args, array('thread' => self::SOCIAL_THREAD, 'execute_after' => $now));
$this->jobQueue->addJob('tasks/twitter_task/followNewFollowers', $args, array('thread' => self::SOCIAL_THREAD, 'execute_after' => $now));
$this->jobQueue->addJob('tasks/twitter_task/unfollowUnsubscribedUsers', $args, array('thread' => self::SOCIAL_THREAD, 'execute_after' => $now));
}
}
}
开发者ID:andrewkrug,项目名称:repucaution,代码行数:37,代码来源:twitter_cron.php
示例13: testSet
public function testSet()
{
$lUser = new User();
$lUser->setUsername('hugo');
$lUser->setActive(true);
$this->assertTrue(is_object(PersistentVariableTable::set('affen', $lUser, true)));
}
开发者ID:42medien,项目名称:spreadly,代码行数:7,代码来源:PersistentVariableTableTest.php
示例14: getRespondentsByUser
function getRespondentsByUser(User $user, $filter = 0)
{
global $db;
$respondents = array();
$test = ' and test = 0';
// this can be the supervisor looking
$currentUser = new User($_SESSION['URID']);
if ($currentUser->isTestMode()) {
$test = ' and test = 1';
}
if ($currentUser->getRegionFilter() > 0 && $currentUser->getPuid() > 0) {
//only certain region
$test = ' and puid = ' . $currentUser->getPuid();
}
$result = $db->selectQuery('select *, ' . $this->getDeIdentified() . ' from ' . Config::dbSurvey() . '_respondents where urid = ' . prepareDatabaseString($user->getUrid()) . $test);
while ($row = $db->getRow($result)) {
$respondents[] = new Respondent($row);
}
if ($currentUser->getTestMode() && sizeof($respondents) == 0 && $currentUser->getRegionFilter() <= 0) {
//psu filter!!
if ($currentUser->getUserType() == USER_INTERVIEWER) {
//only add if interviewer!
if (dbConfig::defaultPanel() != PANEL_HOUSEHOLD) {
//only if not household sample
$respondents = $this->addTestRespondents($user);
}
}
}
if ($filter > 0) {
//a filter!!
$respondents = $this->filterRespondents($respondents, $filter);
}
return $respondents;
}
开发者ID:nubissurveying,项目名称:nubis,代码行数:34,代码来源:respondents.php
示例15: setUp
function setUp()
{
global $db, $timedate, $current_user;
$this->original_current_user = $current_user;
$user = new User();
$user->retrieve('1');
$current_user = $user;
if ($db->dbType != 'mysql') {
$this->markTestSkipped('Skipping for non-mysql dbs');
}
$this->meeting = SugarTestMeetingUtilities::createMeeting();
$date_start = $timedate->nowDb();
$this->meeting->date_start = $date_start;
$this->meeting->duration_hours = 2;
$this->meeting->duration_minutes = 30;
$this->meeting->save();
$sql = "UPDATE meetings SET date_end = '{$date_start}' WHERE id = '{$this->meeting->id}'";
$db->query($sql);
$this->call = SugarTestCallUtilities::createCall();
$date_start = $timedate->nowDb();
$this->call->date_start = $date_start;
$this->call->duration_hours = 2;
$this->call->duration_minutes = 30;
$this->call->save();
$sql = "UPDATE calls SET date_end = '{$date_start}' WHERE id = '{$this->call->id}'";
$db->query($sql);
}
开发者ID:netconstructor,项目名称:sugarcrm_dev,代码行数:27,代码来源:UWUtilsTest.php
示例16: getUserUploadsPageHtml
/**
* Generates HTML for the uploads page for the passed user.
*
* @param User $user
* @return string
*/
public function getUserUploadsPageHtml(User $user)
{
$uploadCount = $this->getUserUploadCount($user->getName());
$mobileContext = MobileContext::singleton();
$html = '';
$attrs = array();
if ($uploadCount !== false) {
$threshold = $this->getUploadCountThreshold();
// FIXME: Use Html class?
$html .= '<div class="content">';
if ($mobileContext->userCanUpload()) {
$html .= '<div class="ctaUploadPhoto"></div>';
}
if ($uploadCount > $threshold) {
$msg = $this->msg('mobile-frontend-photo-upload-user-count-over-limit')->text();
} else {
$msg = $this->msg('mobile-frontend-photo-upload-user-count')->numParams($uploadCount)->parse();
if ($uploadCount === 0) {
$attrs = array('style' => 'display:none');
}
}
$html .= Html::openElement('h2', $attrs) . $msg . Html::closeElement('h2');
$html .= '</div>';
}
return $html;
}
开发者ID:micha6554,项目名称:mediawiki-extensions-MobileFrontend,代码行数:32,代码来源:SpecialUploads.php
示例17: actionRegister
/**
* Creates account for new users
*/
public function actionRegister()
{
if (!Yii::app()->user->isGuest) {
Yii::app()->request->redirect('/');
}
$user = new User('register');
$profile = new UserProfile();
if (Yii::app()->request->isPostRequest && isset($_POST['User'], $_POST['UserProfile'])) {
$user->attributes = $_POST['User'];
$profile->attributes = $_POST['UserProfile'];
$valid = $user->validate();
$valid = $profile->validate() && $valid;
if ($valid) {
$user->save();
$profile->save();
$profile->setUser($user);
// Add user to authenticated group
Yii::app()->authManager->assign('Authenticated', $user->id);
$this->addFlashMessage(Yii::t('UsersModule.core', 'Спасибо за регистрацию на нашем сайте.'));
// Authenticate user
$identity = new UserIdentity($user->username, $_POST['User']['password']);
if ($identity->authenticate()) {
Yii::app()->user->login($identity, Yii::app()->user->rememberTime);
Yii::app()->request->redirect($this->createUrl('/users/profile/index'));
}
}
}
$this->render('register', array('user' => $user, 'profile' => $profile));
}
开发者ID:kolbensky,项目名称:rybolove,代码行数:32,代码来源:RegisterController.php
示例18: __construct
/**
* Constructor
*
* @param User $user the user for the feed
* @param User $cur the current authenticated user, if any
* @param boolean $indent flag to turn indenting on or off
*
* @return void
*/
function __construct($user, $cur = null, $indent = true)
{
parent::__construct($cur, $indent);
$this->user = $user;
if (!empty($user)) {
$profile = $user->getProfile();
$ao = ActivityObject::fromProfile($profile);
array_push($ao->extra, $profile->profileInfo($cur));
// XXX: For users, we generate an author _AND_ an <activity:subject>
// This is for backward compatibility with clients (especially
// StatusNet's clients) that assume the Atom will conform to an
// older version of the Activity Streams API. Subject should be
// removed in future versions of StatusNet.
$this->addAuthorRaw($ao->asString('author'));
$depMsg = 'Deprecation warning: activity:subject is present ' . 'only for backward compatibility. It will be ' . 'removed in the next version of StatusNet.';
$this->addAuthorRaw("<!--{$depMsg}-->\n" . $ao->asString('activity:subject'));
}
// TRANS: Title in atom user notice feed. %s is a user name.
$title = sprintf(_("%s timeline"), $user->nickname);
$this->setTitle($title);
$sitename = common_config('site', 'name');
$subtitle = sprintf(_('Updates from %1$s on %2$s!'), $user->nickname, $sitename);
$this->setSubtitle($subtitle);
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
$logo = $avatar ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
$this->setLogo($logo);
$this->setUpdated('now');
$this->addLink(common_local_url('showstream', array('nickname' => $user->nickname)));
$self = common_local_url('ApiTimelineUser', array('id' => $user->id, 'format' => 'atom'));
$this->setId($self);
$this->setSelfLink($self);
$this->addLink(common_local_url('sup', null, null, $user->id), array('rel' => 'http://api.friendfeed.com/2008/03#sup', 'type' => 'application/json'));
}
开发者ID:microcosmx,项目名称:experiments,代码行数:42,代码来源:atomusernoticefeed.php
示例19: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
switch ($ma->getAction()) {
case 'delete_for_user':
$input = $ma->getInput();
if (isset($input['users_id'])) {
$user = new User();
$user->getFromDB($input['users_id']);
foreach ($ids as $id) {
if ($input['users_id'] == Session::getLoginUserID()) {
if ($item->deleteByCriteria(array('users_id' => $input['users_id'], 'itemtype' => $id))) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($user->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($user->getErrorMessage(ERROR_RIGHT));
}
}
} else {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
开发者ID:stweil,项目名称:glpi,代码行数:33,代码来源:displaypreference.class.php
示例20: sendResetPasswordEmail
public function sendResetPasswordEmail($emailOrUserId)
{
$user = new User();
$user->Load("email = ?", array($emailOrUserId));
if (empty($user->id)) {
$user = new User();
$user->Load("username = ?", array($emailOrUserId));
if (empty($user->id)) {
return false;
}
}
$params = array();
//$params['user'] = $user->first_name." ".$user->last_name;
$params['url'] = CLIENT_BASE_URL;
$newPassHash = array();
$newPassHash["CLIENT_NAME"] = CLIENT_NAME;
$newPassHash["oldpass"] = $user->password;
$newPassHash["email"] = $user->email;
$newPassHash["time"] = time();
$json = json_encode($newPassHash);
$encJson = AesCtr::encrypt($json, $user->password, 256);
$encJson = urlencode($user->id . "-" . $encJson);
$params['passurl'] = CLIENT_BASE_URL . "service.php?a=rsp&key=" . $encJson;
$emailBody = file_get_contents(APP_BASE_PATH . '/templates/email/passwordReset.html');
$this->sendEmail("[" . APP_NAME . "] Password Change Request", $user->email, $emailBody, $params);
return true;
}
开发者ID:bravokeyl,项目名称:ems,代码行数:27,代码来源:EmailSender.php
注:本文中的User类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论