本文整理汇总了PHP中Auth::get_id方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::get_id方法的具体用法?PHP Auth::get_id怎么用?PHP Auth::get_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Auth
的用法示例。
在下文中一共展示了Auth::get_id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onCreateDocument
public function onCreateDocument(DataSource_Hybrid_Document $doc)
{
if ($this->set_current) {
$doc->set($this->name, Auth::get_id());
}
return $this->onUpdateDocument($doc, $doc);
}
示例2: rest_delete
public function rest_delete()
{
$id = (int) $this->param('id', NULL, TRUE);
$user_id = DB::select('user_id')->from('calendar')->where('id', '=', $id)->execute()->get('user_id');
if ($user_id == 0 or $user_id == Auth::get_id()) {
$status = DB::delete('calendar')->where('id', '=', $id)->execute();
} else {
$this->message('No access');
$status = FALSE;
}
$this->response((bool) $status);
}
示例3: get_list
public function get_list()
{
$this->get_get();
$messages = $this->json['response'];
$response_messages = array();
foreach ($messages as $msg) {
$msg = (object) $msg;
if ($msg->is_read == Model_API_Message::STATUS_NEW) {
Api::post('user-messages.mark_read', array('id' => $msg->id, 'uid' => Auth::get_id()));
}
$response_messages[] = (string) View::factory('messages/item')->set('message', (object) $msg);
}
$this->response($response_messages);
}
示例4: _create
/**
*
* @param string $type
*/
private function _create($type)
{
$section = Datasource_Section::factory($type);
$data = $this->request->post();
$data['created_by_id'] = Auth::get_id();
try {
$ds_id = $section->validate($data)->create($data);
} catch (Validation_Exception $e) {
Messages::errors($e->errors('validation'));
$this->go_back();
} catch (DataSource_Exception_Section $e) {
Messages::errors($e->getMessage());
$this->go_back();
}
Messages::success(__('Datasource has been saved!'));
$this->go(Route::get('datasources')->uri(array('directory' => 'datasources', 'controller' => 'section', 'action' => 'edit', 'id' => $ds_id)));
}
示例5: action_view
public function action_view()
{
$id = (int) $this->request->param('id');
$user_id = Auth::get_id();
$message = Api::get('user-messages.get_by_id', array('id' => $id, 'uid' => $user_id, 'fields' => 'author,title,is_read,created_on,text,is_starred'))->as_object();
if (!$message->response) {
throw new HTTP_Exception_404('Message not found');
}
if ($this->request->method() === Request::POST) {
$this->auto_render = FALSE;
$post = $this->request->post();
$post['from_user_id'] = $user_id;
$post['parent_id'] = $id;
return $this->_send(Api::put('user-messages', $post), $id);
}
$read = Api::post('user-messages.mark_read', array('id' => $id, 'uid' => $user_id));
$messages = Api::get('user-messages.get', array('uid' => $user_id, 'fields' => 'author,from_user_id,title,is_read,created_on,text,is_starred', 'pid' => $id))->as_object();
$this->template->content = View::factory('messages/view', array('tpl' => View::factory('messages/item'), 'message' => $message->response, 'messages' => $messages->response, 'from_user' => ORM::factory('user', $message->response->from_user_id)));
$this->set_title($message->response->title);
}
示例6: write
/**
* Writes each of the messages into the database table.
*
* $writer->write($messages);
*
* @param array $messages
* @return void
*/
public function write(array $messages)
{
$user = Auth::get_record(ORM::factory('user'));
$request = Request::initial();
if ($user === NULL) {
return;
}
$logs_level = (int) Config::get('site', 'log_level');
foreach ($messages as $message) {
if ($message['level'] < $logs_level) {
continue;
}
$values = array(':user' => HTML::anchor(Route::get('backend')->uri(array('controller' => 'users', 'action' => 'profile', 'id' => $user->id)), '@' . $user->username), ':controller' => $request !== NULL ? $request->controller() : 'none');
$message['additional'][':url'] = $request !== NULL ? $request->url() : 'none';
$message['additional'][':ip'] = Request::$client_ip;
$message['body'] = strtr($message['body'], $values);
$data = array('created_on' => date('Y-m-d H:i:s'), 'user_id' => Auth::get_id(), 'level' => $message['level'], 'message' => $message['body'], 'additional' => json_encode($message['additional']));
// Write each message into the log database table
DB::insert($this->_table, array_keys($data))->values($data)->execute();
}
}
示例7: _clear_cache
protected static function _clear_cache($user_id = NULL)
{
if ($user_id === NULL) {
$user_id = Auth::get_id();
}
unset(self::$_cache[$user_id]);
Cache::instance()->delete('Database::cache(user_meta' . $user_id . ')');
}
示例8: array
?>
</div>
<div class="profile-row">
<div class="left-col">
<div class="profile-block">
<div class="panel profile-photo">
<?php
echo HTML::anchor('http://gravatar.com/emails/', $user->gravatar(100, NULL), array('target' => '_blank'));
?>
</div>
<br />
<?php
if (Acl::check('users.edit') or $user->id == Auth::get_id()) {
?>
<?php
echo HTML::anchor(Route::get('backend')->uri(array('controller' => 'users', 'action' => 'edit', 'id' => $user->id)), __('Edit profile'), array('class' => 'btn btn-success btn-sm', 'data-icon' => 'user'));
?>
<?php
}
?>
</div>
</div>
<div class="right-col">
<hr class="profile-content-hr no-grid-gutter-h">
<div class="profile-content tabbable">
<?php
示例9: is_creator
/**
* Пользователь - создатель документа
*
* @param integer $user_id
* @return boolean
*/
public function is_creator($user_id = NULL)
{
if ($this->_is_authored === TRUE) {
if ($user_id === NULL) {
$user_id = Auth::get_id();
}
$created_by_id = (int) Arr::get($this->system_fields(), 'created_by_id');
return ACL::is_admin($user_id) or $created_by_id == (int) $user_id;
}
return TRUE;
}
示例10: _edit
private function _edit($user)
{
$data = $this->request->post('user');
$profile = $this->request->post('profile');
$this->auto_render = FALSE;
if (ACL::check('users.change_password') or $user->id == Auth::get_id()) {
if (strlen($data['password']) == 0) {
unset($data['password'], $data['password_confirm']);
}
} else {
unset($data['password']);
}
if (empty($profile['notice'])) {
$profile['notice'] = 0;
}
try {
if ($user->update_user($data, array('email', 'username', 'password'))) {
$profile['user_id'] = $user->id;
$user->profile->values($profile)->save();
if (Acl::check('users.change_roles') and $user->id > 1) {
// now we need to add permissions
$user_roles = $this->request->post('user_roles');
if (!empty($user_roles)) {
$user->update_related_ids('roles', explode(',', $user_roles));
}
}
Messages::success(__('User has been saved!'));
}
} catch (ORM_Validation_Exception $e) {
Messages::errors($e->errors('validation'));
$this->go_back();
}
// save and quit or save and continue editing?
if ($this->request->post('commit') !== NULL) {
$this->go();
} else {
$this->go(array('action' => 'edit', 'id' => $user->id));
}
}
示例11: __
?>
<small><?php
echo Auth::get_record()->email;
?>
</small></p>
</li>
<li class="user-body">
<div class="col-xs-6">
<?php
echo HTML::anchor(Route::get('backend')->uri(array('controller' => 'users', 'action' => 'profile')), __('Profile'), array('data-icon' => 'user'));
?>
</div>
<div class="col-xs-6">
<?php
echo HTML::anchor(Route::get('backend')->uri(array('controller' => 'users', 'action' => 'edit', 'id' => Auth::get_id())), __('Settings'), array('data-icon' => 'cog'));
?>
</div>
</li>
<li class="user-footer">
<?php
echo HTML::anchor(Route::get('user')->uri(array('action' => 'logout')), __('Logout'), array('data-icon' => 'power-off text-danger', 'class' => 'btn btn-default btn-xs text-bold pull-right'));
?>
</li>
</ul>
</li>
<?php
}
?>
</ul>
</div>
示例12: before_update
public function before_update()
{
if (empty($this->published_on) and $this->status_id == Model_Page::STATUS_PUBLISHED) {
$this->published_on = date('Y-m-d H:i:s');
}
if (empty($this->use_redirect)) {
$this->redirect_url = NULL;
}
// Если запрещены теги в Заголовке, удаляем их
if (Config::get('site', 'allow_html_title') == Config::NO) {
$this->title = strip_tags(trim($this->title));
}
$this->updated_by_id = Auth::get_id();
Observer::notify('page_edit_before_save', $this);
return TRUE;
}
示例13: array
<div class="form-group">
<?php
echo $user->profile->label('locale', array('class' => 'control-label col-md-3'));
?>
<div class="col-md-4">
<?php
echo $user->profile->field('locale', array('class' => 'form-control', 'prefix' => 'profile'));
?>
</div>
</div>
</div>
<?php
if (ACL::check('users.change_password') or $user->id == Auth::get_id() or !$user->loaded()) {
?>
<div class="panel-heading">
<span class="panel-title"><?php
echo __('Password');
?>
</span>
</div>
<?php
if ($action == 'edit') {
?>
<div class="note note-warning">
<?php
echo UI::icon('lightbulb-o fa-lg');
?>
<?php
示例14:
<?php
if (!$document->loaded() and $field->set_current === TRUE) {
$value = Auth::get_id();
}
?>
<div class="form-group form-inline">
<label class="<?php
echo Arr::get($form, 'label_class');
?>
" for="<?php
echo $field->name;
?>
">
<?php
echo $field->header;
?>
<?php
if ($field->isreq) {
?>
*<?php
}
?>
</label>
<div class="<?php
echo Arr::get($form, 'input_container_class');
?>
">
<div class="input-group">
<?php
示例15: init_media
public function init_media()
{
$this->template_js_params = array('CURRENT_URL' => Request::current()->url(TRUE) . URL::query(), 'BASE_URL' => URL::backend(ADMIN_DIR_NAME, TRUE), 'SITE_URL' => URL::base(TRUE), 'ADMIN_DIR_NAME' => ADMIN_DIR_NAME, 'ADMIN_RESOURCES' => ADMIN_RESOURCES, 'PUBLIC_URL' => PUBLIC_URL, 'LOCALE' => I18n::lang(), 'CONTROLLER' => strtolower(Request::current()->controller()), 'ACTION' => Request::current()->action(), 'USER_ID' => Auth::get_id(), 'DATE_FORMAT' => Config::get('site', 'date_format'), 'IS_BACKEND' => IS_BACKEND, 'CLOSE_POPUP' => Session::instance()->get_once('close_popup', FALSE));
foreach (Messages::get() as $type => $messages) {
$this->template_js_params['MESSAGE_' . strtoupper($type)] = $messages;
}
}