예제 #1
0
파일: user.php 프로젝트: ortodesign/cms
 public function onCreateDocument(DataSource_Hybrid_Document $doc)
 {
     if ($this->set_current) {
         $doc->set($this->name, Auth::get_id());
     }
     return $this->onUpdateDocument($doc, $doc);
 }
예제 #2
0
 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
0
 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
0
 /**
  * 
  * @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
0
 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
0
 /**
  * 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
0
파일: meta.php 프로젝트: ZerGabriel/cms-1
 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
0
파일: profile.php 프로젝트: ortodesign/cms
?>
	</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
0
 /**
  * Пользователь - создатель документа
  * 
  * @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
0
파일: users.php 프로젝트: ZerGabriel/cms-1
 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
0
파일: navbar.php 프로젝트: ZerGabriel/cms-1
    ?>
 <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
0
파일: page.php 프로젝트: ZerGabriel/cms-1
 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
0
파일: edit.php 프로젝트: ZerGabriel/cms-1
		<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
0
<?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
0
파일: Template.php 프로젝트: kodicms/core
 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;
     }
 }
예제 #16
0
 /**
  * Пользователь - создатель раздела
  * 
  * @param integer $user_id
  * @return boolean
  */
 public function is_creator($user_id = NULL)
 {
     if ($user_id === NULL) {
         $user_id = Auth::get_id();
     }
     return ACL::is_admin($user_id) or $this->_created_by_id == (int) $user_id;
 }