123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- <?php
- use \ChamiloSession as Session;
- class CurrentUser
- {
-
- public static function instance()
- {
- static $result = null;
- if (empty($result)) {
- $result = new self();
- }
- return $result;
- }
- protected function __construct()
- {
- ;
- }
- public function data()
- {
- global $_user;
- return $_user;
-
- }
- public function is_anonymous()
- {
- return api_is_anonymous();
- }
- public function first_name()
- {
- return $this->get('firstName');
- }
- public function last_name()
- {
- return $this->get('lastName');
- }
- public function email()
- {
- return $this->get('mail');
- }
- public function last_login()
- {
- return $this->get('lastLogin');
- }
- public function official_code()
- {
- return $this->get('official_code');
- }
- public function picture_uri()
- {
- return $this->get('picture_uri');
- }
- public function user_id()
- {
- return (int) $this->get('user_id');
- }
- public function language()
- {
- return $this->get('language');
- }
- public function auth_source()
- {
- return $this->get('auth_source');
- }
- public function theme()
- {
- return $this->get('theme');
- }
-
- public function is_platform_admin()
- {
- return (bool) Session::read('is_platformAdmin', false);
- }
-
- public function is_session_admin($allow_sessions_admins = false)
- {
- global $_user;
- return (bool) $_user['status'] == SESSIONADMIN;
- }
-
- public function is_allowed_to_create_course()
- {
- return (bool) Session::read('is_allowedCreateCourse', false);
- }
-
- public function is_course_admin()
- {
- return (bool) Session::read('is_courseAdmin', false);
- }
-
- public function is_course_member()
- {
- return (bool) Session::read('is_courseMember', false);
- }
-
- public function is_allowed_in_course()
- {
- return (bool) Session::read('is_allowed_in_course', false);
- }
-
- public function is_course_coach()
- {
- return (bool) Session::read('is_courseCoach', false);
- }
-
- public function is_course_tutor()
- {
- return (bool) Session::read('is_courseTutor', false);
- }
- public function get($name, $default = false)
- {
- $data = $this->data();
- return isset($data[$name]) ? $data[$name] : $default;
- }
- }
|