本文整理汇总了PHP中Users::findById方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::findById方法的具体用法?PHP Users::findById怎么用?PHP Users::findById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Users
的用法示例。
在下文中一共展示了Users::findById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeReport
/**
* Execute report
*
* @param User $user
* @param TimeReport $report
* @param Project $project
* @return array
*/
function executeReport($user, $report, $project = null)
{
$conditions = $report->prepareConditions($user, $project);
if (empty($conditions)) {
return null;
}
// if
if ($report->getSumByUser()) {
$rows = db_execute_all('SELECT SUM(float_field_1) AS total_time, integer_field_1 AS user_id FROM ' . TABLE_PREFIX . 'project_objects WHERE ' . $conditions . ' GROUP BY integer_field_1');
if (is_foreachable($rows)) {
$result = array();
foreach ($rows as $row) {
$user = Users::findById($row['user_id']);
if (instance_of($user, 'User')) {
$result[] = array('user' => $user, 'total_time' => float_format($row['total_time'], 2));
}
// if
}
// foreach
return $result;
} else {
return null;
}
// if
} else {
return TimeRecords::findBySQL('SELECT * FROM ' . TABLE_PREFIX . 'project_objects WHERE ' . $conditions . ' ORDER BY date_field_1');
}
// if
}
示例2: render_sharing_users
/**
* Render project users combo.
*
* @param String $name
* @param array $attributes
* @return String All users I am sharing something with.
*/
function render_sharing_users($name, $attributes = null)
{
//TODO: This functions must be rebuilt
$perms = ObjectUserPermissions::getAllPermissionsByUser(logged_user());
$options = array(option_tag(lang('none'), 0));
$my_id = logged_user()->getId();
if (isset($perms)) {
foreach ($perms as $perm) {
$file_id = $perm->getFileId();
if (trim($file_id) != '') {
$users = ObjectUserPermissions::getAllPermissionsByObjectIdAndManager($file_id, 'ProjectFiles');
foreach ($users as $user_perm) {
$user_id = $user_perm->getUserId();
if ($user_id != null && trim($user_id) != '' && $user_id != $my_id) {
$user = Users::findById($user_id);
if ($user != null) {
//foreach user
$options[] = option_tag($user->getUserName(), $user->getUserName());
}
}
}
}
}
}
$options = array_unique($options);
return select_box($name, $options, $attributes);
}
示例3: getUser
/**
* Return user object
*
* @param void
* @return User
*/
function getUser()
{
if (is_null($this->user)) {
$this->user = Users::findById($this->getUserId());
}
return $this->user;
}
示例4: setSystemUser
/**
* Set user object from the system
*
* @param void
* @return null
*/
function setSystemUser()
{
if (is_null($this->system_user)) {
$this->system_user = Users::findById($this->getUserId());
}
// if
}
示例5: getResponsibleUser
/**
* Return parent user
*
* @param void
* @return User
*/
function getResponsibleUser()
{
if (is_null($this->user)) {
$this->user = Users::findById($this->getResponsibleUserId());
}
// if
return $this->user;
}
示例6: getUserName
function getUserName()
{
$user = Users::findById($this->getCreatedById());
if ($user instanceof User) {
return $user->getUsername();
} else {
return null;
}
}
示例7: initUser
function initUser($id)
{
$this->user = Users::findById($id);
if ($this->user != null) {
CompanyWebsite::instance()->setLoggedUser($this->user);
} else {
ImportLogger::instance()->logError("User not found: id={$id}");
die("User not found: id={$id}");
}
}
示例8: setAction
public function setAction($id = null)
{
$this->view->title = "Set Password - ";
$this->view->selectmenu = "password";
if ($this->request->isPost()) {
$user = Users::findById($id);
$password = $this->request->getPost('password');
$user->password = $this->security->hash($password);
$response = $id;
$user->save();
return $this->dispatcher->forward(array('action' => 'index', 'params' => array($this->view->title, $this->view->selectmenu, $response)));
}
}
示例9: getLeader
/**
* Return project leader
*
* @param void
* @return User
*/
function getLeader()
{
if ($this->leader === false) {
if ($this->getLeaderId()) {
$this->leader = Users::findById($this->getLeaderId());
}
// if
if (!instance_of($this->leader, 'User')) {
$this->leader = new AnonymousUser($this->getLeaderName(), $this->getLeaderEmail());
}
}
// if
return $this->leader;
}
示例10: delete
/**
* Delete specific user
*
* @access public
* @param void
* @return null
*/
function delete()
{
$this->setTemplate('del_user');
$user = Users::findById(get_id());
if (!$user instanceof User) {
flash_error(lang('user dnx'));
$this->redirectTo('administration');
}
// if
if (!$user->canDelete(logged_user())) {
flash_error(lang('no access permissions'));
$this->redirectToReferer(get_url('dashboard'));
}
// if
$delete_data = array_var($_POST, 'deleteUser');
tpl_assign('user', $user);
tpl_assign('delete_data', $delete_data);
if (!is_array($delete_data)) {
$delete_data = array('really' => 0, 'password' => '');
// array
tpl_assign('delete_data', $delete_data);
} else {
if ($delete_data['really'] == 1) {
$password = $delete_data['password'];
if (trim($password) == '') {
tpl_assign('error', new Error(lang('password value missing')));
return $this->render();
}
if (!logged_user()->isValidPassword($password)) {
tpl_assign('error', new Error(lang('invalid login data')));
return $this->render();
}
try {
DB::beginWork();
$user->delete();
ApplicationLogs::createLog($user, null, ApplicationLogs::ACTION_DELETE);
DB::commit();
flash_success(lang('success delete user', $user->getDisplayName()));
} catch (Exception $e) {
DB::rollback();
flash_error(lang('error delete user'));
}
// try
$this->redirectToUrl($user->getCompany()->getViewUrl());
} else {
flash_error(lang('error delete user'));
$this->redirectToUrl($user->getCompany()->getViewUrl());
}
}
}
示例11: SetData
function SetData($billing_chart_data){
$this->data = array();
foreach ($billing_chart_data as $row){
$value = 0;
$user = Users::findById($row['user']);
if ($user instanceof User){
$this->data['values'][0]['labels'][] = $user->getDisplayName();
$this->data['values'][0]['values'][] = $row['total_billing'];
}
$this->total += $row['total_billing'];
} // foreach
$this->data['values'][0]['name'] = lang('current');
}
示例12: user
/**
* Display user details
*/
function user()
{
$user_id = $this->request->get('object_id');
if ($user_id) {
$current_user = Users::findById($user_id);
}
// if
if (!instance_of($current_user, 'User')) {
$this->httpError(HTTP_ERR_NOT_FOUND);
}
if (!in_array($current_user->getId(), $this->logged_user->visibleUserIds())) {
$this->httpError(HTTP_ERR_NOT_FOUND);
}
// if
$current_user_company = $current_user->getCompany();
$this->smarty->assign(array("current_user" => $current_user, "current_user_company" => $current_user->getCompany(), "page_title" => $current_user->getName(), "page_back_url" => mobile_access_module_get_view_url($current_user_company)));
}
示例13: __construct
/**
* Construct Profile Controller
*
* @param void
* @return null
*/
function __construct($request)
{
parent::__construct($request);
$user_id = $this->request->get('user_id');
if ($user_id) {
$this->active_user = Users::findById($user_id);
}
// if
if (instance_of($this->active_user, 'User')) {
if (!in_array($this->active_user->getId(), $this->logged_user->visibleUserIds())) {
$this->httpError(HTTP_ERR_NOT_FOUND);
}
// if
$this->wireframe->addBreadCrumb($this->active_user->getName(), $this->active_user->getViewUrl());
if ($this->active_user->getId() == $this->logged_user->getId()) {
$this->wireframe->current_menu_item = 'profile';
}
// if
} else {
$this->active_user = new User();
}
// if
$this->smarty->assign('active_user', $this->active_user);
}
示例14: define
og.events_selected = 0;
og.eventSelected(0);
</script>
<?php
define('PX_HEIGHT', 42);
$year = isset($_GET['year']) ? $_GET['year'] : (isset($_SESSION['year']) ? $_SESSION['year'] : date('Y'));
$month = isset($_GET['month']) ? $_GET['month'] : (isset($_SESSION['month']) ? $_SESSION['month'] : date('n'));
$day = isset($_GET['day']) ? $_GET['day'] : (isset($_SESSION['day']) ? $_SESSION['day'] : date('j'));
$_SESSION['year'] = $year;
$_SESSION['month'] = $month;
$_SESSION['day'] = $day;
$tags = active_tag();
$user_filter = $userPreferences['user_filter'];
$status_filter = $userPreferences['status_filter'];
$user = Users::findById(array('id' => $user_filter));
if ($user == null) {
$user = logged_user();
}
$use_24_hours = user_config_option('time_format_use_24');
$date_format = user_config_option('date_format');
if ($use_24_hours) {
$timeformat = 'G:i';
} else {
$timeformat = 'g:i A';
}
echo stylesheet_tag('event/day.css');
$today = DateTimeValueLib::now();
$today->add('h', logged_user()->getTimezone());
$currentday = $today->format("j");
$currentmonth = $today->format("n");
示例15: delete_avatar
/**
* Delete avatar
*
* @param void
* @return null
*/
function delete_avatar()
{
$user = Users::findById(get_id());
if (!$user instanceof User) {
flash_error(lang('user dnx'));
$this->redirectTo('dashboard');
}
// if
if (!$user->canUpdateProfile(logged_user())) {
flash_error(lang('no access permissions'));
$this->redirectTo('dashboard');
}
// if
$redirect_to = array_var($_GET, 'redirect_to');
if (trim($redirect_to) == '' || !is_valid_url($redirect_to)) {
$redirect_to = $user->getUpdateAvatarUrl();
}
// if
tpl_assign('redirect_to', $redirect_to);
if (!$user->hasAvatar()) {
flash_error(lang('avatar dnx'));
$this->redirectToUrl($redirect_to);
}
// if
try {
DB::beginWork();
$user->deleteAvatar();
$user->save();
ApplicationLogs::createLog($user, null, ApplicationLogs::ACTION_EDIT);
DB::commit();
flash_success(lang('success delete avatar'));
} catch (Exception $e) {
DB::rollback();
flash_error(lang('error delete avatar'));
}
// try
$this->redirectToUrl($redirect_to);
}