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


PHP User类代码示例

本文整理汇总了PHP中User的典型用法代码示例。如果您正苦于以下问题:PHP User类的具体用法?PHP User怎么用?PHP User使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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'] = 'johndow@mail.com';
        
        # 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


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