本文整理汇总了PHP中JO_Session::set方法的典型用法代码示例。如果您正苦于以下问题:PHP JO_Session::set方法的具体用法?PHP JO_Session::set怎么用?PHP JO_Session::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JO_Session
的用法示例。
在下文中一共展示了JO_Session::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initSession
public static function initSession($user_id)
{
$db = JO_Db::getDefaultAdapter();
$query = $db->select()->from(self::getPrefixDB() . 'users')->where('user_id = ?', (int) $user_id)->limit(1, 0);
$user_data = $db->fetchRow($query);
if ($user_data && $user_data['status'] == 'activate') {
$groups = unserialize($user_data['groups']);
if (is_array($groups) && count($groups) > 0) {
$query_group = $db->select()->from(self::getPrefixDB() . 'user_groups')->where("ug_id IN (?)", new JO_Db_Expr(implode(',', array_keys($groups))));
$fetch_all = $db->fetchAll($query_group);
$user_data['access'] = array();
if ($fetch_all) {
foreach ($fetch_all as $row) {
$modules = unserialize($row['rights']);
if (is_array($modules)) {
foreach ($modules as $module => $ison) {
$user_data['access'][$module] = $module;
}
}
}
}
}
if (isset($user_data['access']) && count($user_data['access'])) {
$user_data['is_admin'] = true;
}
$db->update(self::getPrefixDB() . 'users', array('last_login_datetime' => new JO_Db_Expr('NOW()'), 'ip_address' => JO_Request::getInstance()->getClientIp()), array('user_id = ?' => (int) $user_id));
JO_Session::set($user_data);
}
return $user_data;
}
示例2: logoutAction
public function logoutAction()
{
$this->setInvokeArg('noViewRenderer', true);
@setcookie('csrftoken_', md5(JO_Session::get('user[user_id]') . $this->getRequest()->getDomain() . JO_Session::get('user[date_added]')), time() - 100, '/', '.' . $this->getRequest()->getDomain());
JO_Session::set(array('user' => false));
$this->redirect(JO_Request::getInstance()->getBaseUrl());
}
示例3: initSessionCookie
public static function initSessionCookie($cookie)
{
$db = JO_Db::getDefaultAdapter();
$query = $db->select()->from('users', array('*', 'fullname' => "CONCAT(firstname,' ',lastname)"))->where("MD5(CONCAT(user_id,'" . JO_Request::getInstance()->getDomain() . "',date_added)) = ?", (string) $cookie)->limit(1);
$user_data = $db->fetchRow($query);
if ($user_data && $user_data['status']) {
$groups = unserialize($user_data['groups']);
if (is_array($groups) && count($groups) > 0) {
$query_group = $db->select()->from('user_groups')->where("ug_id IN (?)", new JO_Db_Expr(implode(',', array_keys($groups))));
$fetch_all = $db->fetchAll($query_group);
$user_data['access'] = array();
if ($fetch_all) {
foreach ($fetch_all as $row) {
$modules = unserialize($row['rights']);
if (is_array($modules)) {
foreach ($modules as $module => $ison) {
foreach ($ison as $m => $on) {
$user_data['access'][$module][$m] = $m;
}
}
}
}
}
}
$db->update('users', array('last_action_datetime' => new JO_Db_Expr('NOW()'), 'ip_address' => JO_Request_Server::encode_ip(JO_Request::getInstance()->getClientIp())), array('user_id = ?' => (string) $user_data['user_id']));
}
// foreach($user_data AS $key => $data) {
// self::{$key} = $data;
// }
JO_Session::set(array('user' => $user_data));
return $user_data;
}
示例4: get_avatarAction
public function get_avatarAction()
{
$this->noLayout(true);
$request = $this->getRequest();
if (JO_Session::get('user[user_id]')) {
$connectObject = new Model_Facebook_Login();
$user_info = $connectObject->getDataByUserId(JO_Session::get('user[user_id]'));
$user_id = 0;
if ($user_info) {
$user_id = $user_info['oauth_uid'];
} else {
$facebookObject = new Helper_Modules_Facebook();
$user_data = $facebookObject->getUser(true);
if ($user_data && isset($user_data['id'])) {
$user_id = $user_data['id'];
}
}
if ($user_id) {
$ph = new WM_Facebook_Photo();
$image = $ph->getRealUrl('http://graph.facebook.com/' . $user_id . '/picture?type=large');
$image_info = @getimagesize($image);
if ($image_info) {
$image_data = @file_get_contents($image);
if ($image_data) {
JO_Session::set('upload_avatar', array('name' => basename($image), 'type' => $image_info['mime'], 'data' => $image_data));
$this->view->success = WM_Router::create($request->getBaseUrl() . '?controller=settings&action=temporary_avatar&hash=' . microtime(true));
}
}
} else {
$this->view->error = $this->translate('There is no established connection with facebook!');
}
}
echo $this->renderScript('json');
}
示例5: loginInit
private function loginInit($id)
{
$event_data = WM_Users::initSession($id);
if ($event_data) {
JO_Session::set(array('user' => $event_data));
}
$this->redirect(WM_Router::create($this->getRequest()->getBaseUrl()));
}
示例6: connectAction
public function connectAction()
{
$request = $this->getRequest();
$this->noLayout(true);
$this->view->close_box = false;
if (JO_Session::get('user[user_id]')) {
$facebookObject = new Helper_Modules_Facebook();
if ($request->getQuery('scope')) {
$facebookObject->scope = $request->getQuery('scope');
}
$user_data = $facebookObject->getUser(true);
$connectObject = new Model_Facebook_Login();
$connectObject->facebook = $facebookObject->facebook;
$user_info = $connectObject->getDataByUserId(JO_Session::get('user[user_id]'));
if ($user_data) {
$connectObjectCheck = new Model_Facebook_Login($user_data['id']);
if ($connectObjectCheck->row) {
if ($connectObjectCheck->row['user_id'] == JO_Session::get('user[user_id]')) {
$enable_action = true;
} else {
$is_user = new Model_Users_User($connectObjectCheck->row['user_id']);
if (!$is_user->count()) {
$enable_action = true;
$connectObject->deleteDataByUserId($connectObjectCheck->row['user_id']);
} else {
$enable_action = $this->translate('There is another profile that is associated with your facebook account');
}
}
} else {
$enable_action = true;
}
if ($enable_action === true) {
if ($user_info) {
if ($connectObject->deleteDataByUserId(JO_Session::get('user[user_id]'))) {
$this->view->close_box = true;
} else {
$this->view->close_box = true;
}
} else {
$res = $connectObject->insert(array('email' => isset($user_data['email']) ? $user_data['email'] : '', 'user_id' => JO_Session::get('user[user_id]'), 'oauth_uid' => $user_data['id'], 'access_token' => $facebookObject->facebook->getAccessToken()));
if ($res) {
$this->view->close_box = true;
} else {
$this->view->close_box = true;
}
}
} else {
JO_Session::set('connect_error', $enable_action);
$this->view->close_box = true;
}
} else {
$redirect = $facebookObject->getLoginUrl(WM_Router::create($request->getBaseUrl() . '?controller=settings'), 'modules_facebook_connect&action=connect');
$this->redirect($redirect);
}
} else {
$this->view->close_box = true;
}
}
示例7: indexAction
public function indexAction()
{
$request = $this->getRequest();
$settings = Model_Extensions::getSettingsPairs('facebook');
if (!isset($settings['facebook_login_with_facebook']) || !$settings['facebook_login_with_facebook']) {
$this->forward('error', 'error404');
} elseif (!isset($settings['facebook_module_status_enable']) || !$settings['facebook_module_status_enable']) {
$this->forward('error', 'error404');
}
$facebook = new Helper_Modules_Facebook();
$user_data = $facebook->getUser(true);
if ($user_data) {
$modelLogin = new Model_Facebook_Login($user_data['id']);
$error = true;
if ($modelLogin->row) {
$userObject = new Model_Users_User($modelLogin->row['user_id']);
if ($userObject->count()) {
if (JO_Session::get('user[user_id]')) {
if ($modelLogin->row['user_id'] == JO_Session::get('user[user_id]')) {
JO_Session::set('user', $userObject->toArray());
}
} else {
JO_Session::set('user', $userObject->toArray());
}
new Model_Users_Edit($modelLogin->row['user_id'], array('last_login' => new JO_Db_Expr('NOW()')));
$modelLogin->facebook = $facebook;
$modelLogin->update($user_data);
if ($request->getQuery('next')) {
$this->redirect(urldecode($request->getQuery('next')));
} else {
$this->redirect(WM_Router::create($this->getRequest()->getBaseUrl()));
}
}
} elseif (Helper_Config::get('enable_free_registration')) {
$this->forward('modules_facebook_register');
} elseif (JO_Session::get('user[user_id]')) {
$this->redirect($request->getBaseUrl());
}
$this->setViewChange('no_account');
$page_login_trouble = Model_Pages::getPage(Helper_Config::get('page_login_trouble'));
if ($page_login_trouble) {
$this->view->page_login_trouble = array('title' => $page_login_trouble['title'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=pages&action=read&page_id=' . $page_login_trouble['page_id']));
}
} else {
//not session
$this->setViewChange('error_login');
$page_login_trouble = Model_Pages::getPage(Helper_Config::get('page_login_trouble'));
if ($page_login_trouble) {
$this->view->page_login_trouble = array('title' => $page_login_trouble['title'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=pages&action=read&page_id=' . $page_login_trouble['page_id']));
}
}
}
示例8: __construct
public function __construct()
{
$request = JO_Request::getInstance();
parent::__construct();
if (Model_Allowips::getTotalWords()) {
if (!Model_Allowips::getTotalWords(array('filete_ip' => $request->getClientIp()))) {
if (!in_array($request->getController(), array('login', 'error'))) {
$this->forward('error', 'noPermission');
}
}
}
//set default timezone if is not set
if (!ini_get('date.timezone')) {
ini_set('date.timezone', 'UTC');
}
WM_Users::initSession(JO_Session::get('user[user_id]'));
if (!JO_Session::get('user[user_id]')) {
JO_Session::set('user', array('user_id' => 0));
}
//admin check login
$login_page = $request->getController() != 'login';
if (JO_Session::get('user[is_developer]')) {
$login_page = false;
} else {
if (JO_Session::get('user[is_admin]')) {
$login_page = false;
}
}
if (in_array($request->getController(), array('login', 'error'))) {
$login_page = false;
}
if ($login_page) {
$this->forward('login', 'index');
}
//admin top menu
Helper_Config::set('adminmenupermisions', WM_Users::initPermision());
//no permisions
$controller_name = JO_Front::getInstance()->formatControllerName($request->getController());
if (!class_exists($controller_name, false)) {
JO_Loader::loadFile(APPLICATION_PATH . '/modules/' . $request->getModule() . '/controllers/' . JO_Front::getInstance()->classToFilename($controller_name));
}
if (method_exists($controller_name, 'config')) {
$data = call_user_func(array($controller_name, 'config'));
if (isset($data['has_permision']) && $data['has_permision'] && !WM_Users::allow('read', $request->getController())) {
$this->forward('error', 'noPermission');
}
}
WM_Rebuild::getInformation();
WM_Licensecheck::checkIt();
}
示例9: indexAction
public function indexAction()
{
$request = $this->getRequest();
if (!JO_Session::get('user_id')) {
$this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'));
}
if (JO_Session::get('msg_success')) {
$this->view->msg_error = JO_Session::get('msg_success');
JO_Session::clear('msg_success');
}
if (JO_Session::get('msg_error')) {
$this->view->msg_error = JO_Session::get('msg_error');
JO_Session::clear('msg_error');
}
$this->view->questions = $questions = Model_Quiz::getAllQuestions(0, 0, '', 'RAND()');
$this->view->answers = $answers = Model_Quiz::getAllAnswers(0, 0, '', true);
if ($request->isPost()) {
$rightAnswers = 0;
$user_answers = $request->getPost('answers');
if (is_array($user_answers)) {
foreach ($user_answers as $question => $answer) {
if (isset($answers[$question][$answer]) && $answers[$question][$answer]['right'] == 'true') {
$rightAnswers++;
}
}
}
if ($rightAnswers > 0 && count($questions) == $rightAnswers) {
$_SESSION['user']['quiz'] = 'true';
JO_Session::set('quiz', 'true');
Model_Users::updateQuiz(JO_Session::get('user_id'), 'true');
JO_Session::set('msg_success', 'You have successfully completed the quiz');
$this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=upload'));
} else {
JO_Session::set('msg_error', 'You have to answer all questions correctly. You have ' . $rightAnswers . ' right answers from ' . $question . ' questions');
$this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=quiz'));
}
}
$this->view->usersCount = Model_Users::countUsers();
$this->view->itemsCount = Model_Items::countItems();
$this->getLayout()->meta_title = $this->translate('Quiz');
$this->getLayout()->meta_description = $this->translate('Quiz');
$this->view->page_name = $this->translate('Quiz');
/* CRUMBS */
$this->view->crumbs = array();
$this->view->crumbs[] = array('name' => $this->view->translate('Home'), 'href' => $request->getBaseUrl());
$this->view->children = array();
$this->view->children['header_part'] = 'layout/header_part';
$this->view->children['footer_part'] = 'layout/footer_part';
}
示例10: indexAction
public function indexAction()
{
if (!WM_Users::allow('edit', 'modules')) {
JO_Session::set('error_permision', $this->translate('You do not have permission to this action'));
$this->redirect($this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/modules_oauth/');
}
$request = $this->getRequest();
if (JO_Session::get('successfu_edite')) {
$this->view->successfu_edite = true;
JO_Session::clear('successfu_edite');
}
if ($request->isPost()) {
//validate app id
$validate = new Helper_Modules_Facebook($request->getPost('facebook[facebook_oauth_key]'), $request->getPost('facebook[facebook_oauth_secret]'));
if ($validate->checkValidAppId()) {
Model_Settings::updateAll(array('facebook' => $request->getPost('facebook')));
JO_Session::set('successfu_edite', true);
$this->redirect($this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/modules_oauth_facebook/');
} else {
$this->view->error = $this->translate('Invalid appID');
}
}
$this->view->modules_url = $this->getRequest()->getModule() . '/modules';
$this->view->modules_oauth_url = $this->getRequest()->getModule() . '/modules_oauth';
$methods = $this->getClassResources();
$this->view->methods = array();
$ignore = array('index', 'error404', 'install', 'uninstall');
foreach ($methods as $type => $mods) {
foreach ($mods as $key => $value) {
if (in_array($value, $ignore)) {
continue;
}
if ($type == 'actions') {
$this->view->methods[$type][] = array('title' => $this->translate($value), 'edit' => $this->getRequest()->getModule() . '/modules_oauth_facebook/' . strtolower($value));
} elseif ($type == 'radio') {
$this->view->methods[$type][] = array('title' => $this->translate(str_replace('_', ' ', $value)), 'key' => 'facebook_' . strtolower($value));
}
}
}
$store_config = Model_Settings::getSettingsPairs(array('filter_group' => 'facebook'));
foreach ($store_config as $key => $data) {
if ($request->issetPost('facebook[' . $key . ']')) {
$this->view->{$key} = $request->getPost('facebook[' . $key . ']');
} else {
$this->view->{$key} = $data;
}
}
}
示例11: indexAction
public function indexAction()
{
$request = $this->getRequest();
if (JO_Session::get('user[user_id]')) {
$this->redirect(WM_Router::create($this->getRequest()->getBaseUrl()));
}
if (Helper_Config::get('enable_free_registration')) {
$this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=register'));
}
$this->view->login = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login');
if (JO_Session::get('successfu_edite')) {
$this->view->successfu_edite = true;
JO_Session::clear('successfu_edite');
}
if ($request->isPost()) {
$validate = new Helper_Validate();
$validate->_set_rules($request->getPost('email'), $this->translate('Email'), 'not_empty;min_length[5];max_length[100];email');
if ($validate->_valid_form()) {
$shared_contentObject = new Model_Users_Invate();
$shared_content = $shared_contentObject->isInvatedByEmail($request->getPost('email'));
if ($shared_content == 1) {
$this->view->error = $this->translate('This e-mail address is already registered');
} else {
if ($shared_content == 2) {
$this->view->error = $this->translate('This e-mail address is already registered');
} else {
if (($key = Model_Users::addSharedContent($request->getPost('email'))) !== false) {
JO_Session::set('successfu_edite', true);
if (Helper_Config::get('not_ri')) {
Model_Email::send(Helper_Config::get('report_mail'), Helper_Config::get('noreply_mail'), $this->translate('New invitation request'), $this->translate('Hello, there is new invitation request in ') . ' ' . Helper_Config::get('site_name'));
}
$this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=landing'));
} else {
$this->view->error = $this->translate('There was an error. Please try again later!');
}
}
}
} else {
$this->view->error = $validate->_get_error_messages();
}
}
$this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
}
示例12: indexAction
public function indexAction()
{
$request = $this->getRequest();
$rows = array('groups_pin_email', 'comments_email', 'likes_email', 'repins_email', 'follows_email', 'email_interval', 'digest_email', 'news_email');
$user_data = Model_Users::getUser(JO_Session::get('user[user_id]'));
if ($request->isPost()) {
$update = array();
foreach ($rows as $row) {
$update[$row] = (int) $request->getRequest($row);
}
// var_dump($update);exit;
Model_Users::edit(JO_Session::get('user[user_id]'), $update);
JO_Session::set('successfu_edite', true);
$this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=settings'));
}
$this->view->user_data = $user_data;
$this->view->settings_href = WM_Router::create($request->getBaseUrl() . '?controller=settings');
$this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
}
示例13: sendWelcomeAction
public function sendWelcomeAction()
{
if (JO_Session::get('user[user_id]')) {
new Model_Users_Edit(JO_Session::get('user[user_id]'), array('first_login' => '0'));
JO_Session::clear('category_id');
$this->view->user_info = JO_Session::get('user');
$this->view->user_info['first_login'] = 0;
JO_Session::set('user', $this->view->user_info);
$template = Model_Notification::getTemplate('welcome');
if ($template) {
$template_data = array('user_id' => JO_Session::get('user[user_id]'), 'user_firstname' => JO_Session::get('user[firstname]'), 'user_lastname' => JO_Session::get('user[lastname]'), 'user_fullname' => JO_Session::get('user[fullname]'), 'user_username' => JO_Session::get('user[username]'), 'site_url' => $this->getRequest()->getBaseUrl(), 'site_name' => Helper_Config::get('site_name'), 'mail_footer' => html_entity_decode(Helper_Config::get('mail_footer'), ENT_QUOTES, 'utf-8'));
if (!$template['title']) {
$template['title'] = $this->translate('Welcome to ${site_name}!');
}
$title = Model_Notification::parseTemplate(html_entity_decode($template['title'], ENT_QUOTES, 'utf-8'), $template_data);
$body = Model_Notification::parseTemplate(html_entity_decode($template['template'], ENT_QUOTES, 'utf-8'), $template_data);
Model_Email::send(JO_Session::get('user[email]'), Helper_Config::get('noreply_mail'), $title, $body);
}
}
$this->noViewRenderer(true);
}
示例14: send_mailAction
public function send_mailAction()
{
$this->noViewRenderer(true);
$request = $this->getRequest();
if ($request->isPost()) {
if ($this->validateForm()) {
$issue_id = $request->getPost('issue_id');
if ($issue_id > 0) {
$category_issue = Model_Contactscategories::getCategory($issue_id);
$category = $category_issue['name'];
} else {
$category = $this->translate('Not selected');
}
$request->setParams('issue', $category);
$res = Model_Contacts::addContact($request->getParams());
JO_Session::set('msg_success', $this->translate('The mail is sent successfully'));
} else {
JO_Session::set('msg_error', $this->error);
JO_Session::set('data', $request->getParams());
}
}
$this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=contacts'));
}
示例15: indexAction
public function indexAction()
{
if (!WM_Users::allow('create', $this->getRequest()->getController())) {
$this->forward('error', 'noPermission');
}
$request = $this->getRequest();
$this->view->user = $request->getPost('user');
$this->view->title = $request->getPost('title');
$this->view->description = $request->getPost('description');
$this->view->users = Model_Users::getUsers(array('filter_email' => '@'));
if (JO_Session::get('successfu_edite')) {
$this->view->successfu_edite = true;
JO_Session::clear('successfu_edite');
}
$this->view->errors = array();
if ($request->isPost()) {
if ($this->getRequest()->issetPost('user')) {
$result = '';
if ($this->getRequest()->getPost('user') == 'all') {
$email_list = Model_Users::getUsers(array('filter_email' => '@'));
foreach ($email_list as $email) {
if (JO_Validate::validateEmail($email["email"])) {
$result = Model_Email::send($email["email"], Helper_Config::get('noreply_mail'), $this->getRequest()->getPost('title'), html_entity_decode($this->getRequest()->getPost('description'), ENT_QUOTES, 'utf-8'));
}
}
} elseif (JO_Validate::validateEmail($this->getRequest()->getPost('user'))) {
$result = Model_Email::send($this->getRequest()->getPost('user'), Helper_Config::get('noreply_mail'), $this->getRequest()->getPost('title'), html_entity_decode($this->getRequest()->getPost('description'), ENT_QUOTES, 'utf-8'));
}
if ($result) {
JO_Session::set('successfu_edite', true);
$this->redirect($this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/massmail/');
} else {
$this->view->errors['no_emails'] = $this->translate('There was an error with sending the mail!');
}
}
}
}