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


PHP UserModel::repo方法代码示例

本文整理汇总了PHP中UserModel::repo方法的典型用法代码示例。如果您正苦于以下问题:PHP UserModel::repo方法的具体用法?PHP UserModel::repo怎么用?PHP UserModel::repo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserModel的用法示例。


在下文中一共展示了UserModel::repo方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: indexAction

 public function indexAction()
 {
     $user = $this->get('user');
     $appSettings = $this->get('config')->data['appSettings'];
     if ($user->hasRole('ADMIN')) {
         $userData = $user->getData();
     } else {
         $userEntry = UserModel::repo()->find($user->getId());
         $userData = $userEntry->getData();
     }
     return $this->render('admin/index.html', array('userData' => json_encode($userData), 'installed' => $appSettings['installed'], 'installStatus' => json_encode($this->getInstallStatus()), 'messageSound' => $appSettings['messageSound'], 'defaultAvatars' => json_encode($this->getDefaultAvatars()), 'messageSounds' => $this->getMessageSounds(), 'widgetThemes' => $this->getWidgetThemes()));
 }
开发者ID:migumuno,项目名称:obesity,代码行数:12,代码来源:AdminController.php

示例2: getTypingStatusAction

 public function getTypingStatusAction()
 {
     $request = $this->get('request');
     $userId = $this->get('guest')->getId();
     $userIds = $request->postVar('ids');
     if ($userId) {
         if (is_array($userIds)) {
             $results = array();
             foreach ($userIds as $id) {
                 $results[$id] = UserModel::repo()->getTypingStatus($userId, $id);
             }
             return $this->json(array('success' => true, 'results' => $results));
         }
     }
     return $this->json(array('success' => false));
 }
开发者ID:migumuno,项目名称:obesity,代码行数:16,代码来源:GuestController.php

示例3: validateDb

 public function validateDb()
 {
     $errors = array('message' => 'Database structure is invalid');
     try {
         $db = $this->get('db');
         // Reconnect in case the database was created just now
         $db->reconnect();
         $tables = $db->getTables();
         $expectedTables = array(UserModel::repo()->getTableName(), MessageModel::repo()->getTableName(), DataModel::repo('')->getTableName());
     } catch (Exception $ex) {
         $errors['message'] = 'Database exception: ' . $ex->getMessage();
         return $errors;
     }
     if (count(array_diff($expectedTables, $tables)) !== 0) {
         $errors['message'] = 'Invalid table structure, actual tables: ' . join(', ', $tables) . ', expected tables: ' . join(', ', $expectedTables);
         return $errors;
     }
     return array();
 }
开发者ID:serobalino,项目名称:bolsaempleos,代码行数:19,代码来源:ModelValidation.php

示例4: loginAction

 public function loginAction()
 {
     $security = $this->get('security');
     $request = $this->get('request');
     $config = $this->get('config');
     // Redirect if already logged in
     if ($this->get('user')->getId()) {
         return $this->redirect('Admin:index');
     }
     $errors = false;
     $username = '';
     if ($request->isPost()) {
         // Get credentials
         $username = $security->escapeString($request->postVar('name'));
         $password = $security->encodePassword($request->postVar('password'));
         // Check if user exists and passwords match
         $userToken = null;
         if ($username == $config->data['superUser'] && $password == $security->encodePassword($config->data['superPass'])) {
             // Super user
             $userToken = array('id' => '-1', 'name' => 'admin', 'roles' => array('ADMIN'));
         } else {
             $userEntry = UserModel::repo()->findOneBy(array('mail' => $username, 'roles' => array('LIKE', '%OPERATOR%')));
             if (isset($userEntry->password)) {
                 if ($password == $userEntry->password) {
                     $userToken = array('id' => $userEntry->id, 'name' => $userEntry->name, 'roles' => $userEntry->roles);
                 }
             }
         }
         // Store user's identity in the session
         if ($userToken) {
             $this->get('auth')->setUser($userToken['id'], $userToken['name'], $userToken['roles']);
             // Redirect to admin's panel
             return $this->redirect('Admin:index');
         }
         $errors = true;
     }
     return $this->render('admin/login.html', array('name' => $username, 'errors' => $errors));
 }
开发者ID:srgg6701,项目名称:chat,代码行数:38,代码来源:AuthenticationController.php

示例5: loginAction

 public function loginAction()
 {
     $security = $this->get('security');
     $request = $this->get('request');
     $config = $this->get('config');
     $logger = $this->get('logger');
     // Redirect if already logged in
     if ($this->get('user')->getId()) {
         return $this->redirect('Admin:index');
     }
     // Log in automatically if administrator user has no password (true only at first use/installation)
     $appSettings = $config->data['appSettings'];
     if (empty($appSettings['installed']) && empty($config->data['superPass'])) {
         $userToken = array('id' => '-1', 'name' => $config->data['superUser'], 'roles' => array('ADMIN'));
         $this->get('auth')->setUser($userToken['id'], $userToken['name'], $userToken['roles']);
         // Redirect to admin's panel
         return $this->redirect('Install:index');
     }
     $errors = false;
     $username = '';
     if ($request->isPost()) {
         // Get credentials
         $username = $security->escapeString($request->postVar('name'));
         $password = $security->encodePassword($request->postVar('password'));
         // Check if user exists and passwords match
         $userToken = null;
         if ($username == $config->data['superUser'] && $password == $security->encodePassword($config->data['superPass'])) {
             // Super user
             $userToken = array('id' => '-1', 'name' => $config->data['superUser'], 'roles' => array('ADMIN'));
         } else {
             $userEntry = UserModel::repo()->findOneBy(array('mail' => $username, 'roles' => array('LIKE', '%OPERATOR%')));
             if (isset($userEntry->password)) {
                 if ($password == $userEntry->password) {
                     $userToken = array('id' => $userEntry->id, 'name' => $userEntry->name, 'roles' => $userEntry->roles);
                 }
             }
         }
         // Store user's identity in the session
         if ($userToken) {
             $this->get('auth')->setUser($userToken['id'], $userToken['name'], $userToken['roles']);
             // Log
             $logger->info('Successful login, user: ' . $username);
             // Redirect to admin's panel
             return $this->redirect('Admin:index');
         }
         $errors = true;
         // Log
         $logger->info('Failed login, user: ' . $username);
     }
     return $this->render('admin/login.html', array('name' => $username, 'errors' => $errors));
 }
开发者ID:serobalino,项目名称:bolsaempleos,代码行数:51,代码来源:AuthenticationController.php

示例6: getOnlineUsersAction

 public function getOnlineUsersAction()
 {
     return $this->json(array('success' => true, 'users' => UserModel::repo()->getAllOnline()));
 }
开发者ID:serobalino,项目名称:bolsaempleos,代码行数:4,代码来源:OperatorController.php

示例7: archiveOutdatedMessages

 public function archiveOutdatedMessages()
 {
     // Mark messages from offline guests as read
     self::$db->query('UPDATE ' . $this->getTableName() . ' m INNER JOIN ' . UserModel::repo()->getTableName() . ' u ON m.from_id = u.id ' . 'SET m.is_new = "n" WHERE u.last_activity < "' . date('Y-m-d H:i:s', time() - UserModel::GUEST_SESSION_TIME) . '"');
 }
开发者ID:srgg6701,项目名称:chat,代码行数:5,代码来源:MessageModel.php

示例8: sendAction

 public function sendAction()
 {
     $request = $this->get('request');
     $validators = $this->get('model_validation');
     // Get the input
     $from = $this->get('user')->getId();
     $to = $request->postVar('to');
     $body = $request->postVar('body');
     $talkId = 0;
     // Validate the input
     $errors = $validators->validateMessage(array('from' => $from, 'to' => $to, 'body' => $body));
     if (count($errors) === 0) {
         // Get the users data (to_user_info is initially set to broadcast info)
         $fromUser = UserModel::repo()->find($from);
         $toUser = UserModel::repo()->find($to);
         if (empty($fromUser) || empty($toUser)) {
             return $this->json(array('success' => false));
         }
         // Create the message
         $msg = new MessageModel(array('from_id' => $from, 'to_id' => $to, 'body' => $body, 'talk_id' => $talkId, 'from_user_info' => $fromUser->getData(), 'to_user_info' => $toUser->getData()));
         $msg->save();
         // Return a successful response
         return $this->json(array('success' => true, 'to' => $to, 'message' => $msg));
     }
     // Return an error response
     return $this->json(array('success' => false, 'errors' => $errors));
 }
开发者ID:serobalino,项目名称:bolsaempleos,代码行数:27,代码来源:MessageController.php

示例9: countGuestsOnline

 public function countGuestsOnline()
 {
     $users = UserModel::repo()->findBy(array('roles' => array('LIKE', '%GUEST%')));
     $count = 0;
     if ($users) {
         foreach ($users as $user) {
             $lastActivityTime = strtotime($user->last_activity);
             if (time() - $lastActivityTime <= self::ONLINE_TIME) {
                 $count++;
             }
         }
     }
     return $count;
 }
开发者ID:srgg6701,项目名称:chat,代码行数:14,代码来源:UserModel.php


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