public static function GetUserRole() { uUserLogin::TryLogin(); if (!isset($_SESSION['current_user'])) { return FALSE; } if (!self::$roleCache) { $obj = utopia::GetInstance('uUsersList'); $obj->BypassSecurity(true); $user = $obj->LookupRecord(array('user_id' => $_SESSION['current_user']), true); $obj->BypassSecurity(false); if ($user['_roles_pk'] === NULL) { return FALSE; } $obj = utopia::GetInstance('uUserRoles'); $obj->BypassSecurity(true); $role = $obj->LookupRecord($user['_roles_pk'], true); // clear fixed filters $obj->BypassSecurity(false); self::$roleCache = array($role['role_id'], utopia::jsonTryDecode($role['allow'])); } return self::$roleCache; }
public function SetupFields() { $this->CreateTable('user'); $this->CreateTable('detail', 'tabledef_UserProfile', 'user', 'user_id'); $this->AddSpacer('<b style="font-size:1.2em">Personal Details</b>'); $l = uUserLogin::IsLoggedIn(); $this->AddFilter('user_id', ctEQ, itNONE, $l); $this->AddField('user_id_detail', 'user_id', 'detail'); $this->SetDefaultValue('user_id_detail', $l); $this->AddField('username', 'username', 'user'); $this->AddField('visible_name', '(IF(TRIM(CONCAT(COALESCE({first_name},\'\'),\' \',COALESCE({last_name},\'\'))) != \'\',TRIM(CONCAT(COALESCE({first_name},\'\'),\' \',COALESCE({last_name},\'\'))),`user`.`username`))', 'detail'); $this->AddField('first_name', 'first_name', 'detail', 'First Name', itTEXT); $this->AddField('last_name', 'last_name', 'detail', 'Last Name', itTEXT); $this->AddField('phone', 'phone', 'detail', 'Home Phone', itTEXT); $this->AddField('mobile', 'mobile', 'detail', 'Mobile Phone', itTEXT); $this->AddSpacer(); $this->AddField('address1', 'address1', 'detail', 'Address', itTEXT); $this->AddField('address2', 'address2', 'detail', '', itTEXT); $this->AddField('town', 'town', 'detail', 'Town', itTEXT); $this->AddField('county', 'county', 'detail', 'County', itTEXT); $this->AddField('country', 'country', 'detail', 'Country', itTEXT); $this->AddField('postcode', 'postcode', 'detail', 'Post Code', itTEXT); }
public function UpdateField($fieldAlias, $newValue, &$pkVal = NULL) { $cUser = $this->LookupRecord(array('user_id' => uUserLogin::IsLoggedIn())); if ($fieldAlias == 'username') { $newValue = trim($newValue); if ($newValue === $cUser['username']) { return; } if (!preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$/i', $newValue)) { uNotices::AddNotice('You must enter a valid email address.', NOTICE_TYPE_ERROR); return; } if (uUsersList::TestCredentials($cUser['username'], $_POST[$this->CreateSqlField('current_password_email', $pkVal)]) === false) { uNotices::AddNotice('The password you entered does not match our records.', NOTICE_TYPE_ERROR); return; } uNotices::AddNotice('You must validate your new email address before you are able to log in with it.'); } if ($fieldAlias == 'password') { if (!$newValue) { return; } if ($newValue !== $_POST[$this->CreateSqlField('confirm_password', $pkVal)]) { uNotices::AddNotice('Password confirmation did not match, please try again.', NOTICE_TYPE_WARNING); return; } if (uUsersList::TestCredentials($cUser['username'], $_POST[$this->CreateSqlField('current_password', $pkVal)]) === false) { uNotices::AddNotice('The password you entered does not match our records.', NOTICE_TYPE_ERROR); return; } uNotices::AddNotice('Your password has been updated.'); } return parent::UpdateField($fieldAlias, $newValue, $pkVal); }
public function SetupFields() { $this->CreateTable('news'); $this->CreateTable('tags', 'tabledef_NewsTags', 'news', 'news_id'); $this->CreateTable('author', 'tabledef_Users', 'news', array('author' => 'user_id')); $this->AddField('time', 'time', 'news', 'Post Date', itDATE); $this->AddField('author', 'author', 'news', 'Author', itCOMBO, 'SELECT user_id,username FROM ' . TABLE_PREFIX . 'tabledef_Users ORDER BY username'); $this->SetDefaultValue('author', uUserLogin::IsLoggedIn()); $this->AddField('heading', 'heading', 'news', 'Title', itTEXT); $this->AddField('description', 'description', 'news', 'Description', itTEXT); // $this->FieldStyles_Set('description',array('width'=>'60%')); $this->AddField('tags', 'tag', 'tags', 'tags', itTEXT, 'SELECT DISTINCT tag FROM tabledef_NewsTags'); $this->AddPreProcessCallback('tags', array($this, 'ppTag')); // $this->FieldStyles_Set('tags',array('width'=>'60%')); $this->AddField('featured', 'featured', 'news', 'Featured', itCHECKBOX); $this->AddField('noindex', 'noindex', 'news', 'noindex', itCHECKBOX); $this->AddField('nofollow', 'nofollow', 'news', 'nofollow', itCHECKBOX); $this->AddField('text', 'text', 'news', 'Content', itHTML); $this->FieldStyles_Set('text', array('width' => '100%', 'height' => '10em')); $this->AddField('curr_image', 'image', 'news', 'Current Image'); $this->FieldStyles_Set('curr_image', array('height' => 100)); $this->AddField('image', 'image', 'news', 'Image', itFILE); $this->AddField('archive', 'archive', 'news', 'Archive', itCHECKBOX); }