本文整理汇总了PHP中JO_Session类的典型用法代码示例。如果您正苦于以下问题:PHP JO_Session类的具体用法?PHP JO_Session怎么用?PHP JO_Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JO_Session类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
}
示例2: 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;
}
示例3: 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());
}
示例4: __construct
public function __construct($to, $type, $pin_id = 0, $board_id = 0, $comment = '')
{
if ($to == JO_Session::get('user[user_id]')) {
return;
} else {
if (!JO_Session::get('user[user_id]')) {
return;
}
}
$history_id = Helper_Db::insert('users_history', array('date_added' => new JO_Db_Expr('NOW()'), 'from_user_id' => (string) JO_Session::get('user[user_id]'), 'to_user_id' => (string) $to, 'history_action' => (int) $type, 'pin_id' => (string) $pin_id, 'board_id' => (string) $board_id, 'comment' => $comment));
if ($history_id) {
if (self::FOLLOW == $type) {
Helper_Db::delete('users_history', array('to_user_id = ?' => (string) $to, 'from_user_id = ?' => (string) JO_Session::get('user[user_id]'), 'history_action = ?' => self::UNFOLLOW, 'board_id = ?' => (string) $board_id));
} elseif (self::UNFOLLOW == $type) {
Helper_Db::delete('users_history', array('to_user_id = ?' => (string) $to, 'from_user_id = ?' => (string) JO_Session::get('user[user_id]'), 'history_action = ?' => self::FOLLOW, 'board_id = ?' => (string) $board_id));
} elseif (self::FOLLOW_USER == $type) {
Helper_Db::delete('users_history', array('to_user_id = ?' => (string) $to, 'from_user_id = ?' => (string) JO_Session::get('user[user_id]'), 'history_action = ?' => self::UNFOLLOW_USER));
} elseif (self::UNFOLLOW_USER == $type) {
Helper_Db::delete('users_history', array('to_user_id = ?' => (string) $to, 'from_user_id = ?' => (string) JO_Session::get('user[user_id]'), 'history_action = ?' => self::FOLLOW_USER));
} elseif (self::LIKEPIN == $type) {
Helper_Db::delete('users_history', array('to_user_id = ?' => (string) $to, 'from_user_id = ?' => (string) JO_Session::get('user[user_id]'), 'history_action = ?' => self::UNLIKEPIN, 'pin_id = ?' => (string) $pin_id));
} elseif (self::UNLIKEPIN == $type) {
Helper_Db::delete('users_history', array('to_user_id = ?' => (string) $to, 'from_user_id = ?' => (string) JO_Session::get('user[user_id]'), 'history_action = ?' => self::LIKEPIN, 'pin_id = ?' => (string) $pin_id));
}
}
}
示例5: __construct
public function __construct($pin_id)
{
$db = JO_Db::getDefaultAdapter();
$query = self::getListPinsQuery();
//$query->columns(array('pin_next'=>new JO_Db_Expr('('.$db->select()->from(array('next'=>'pins'),'pin_id')->where('pin_id > ?', (string)$pin_id)->order('pin_id ASC')->limit(1).')')));
//$query->columns(array('pin_prev'=>new JO_Db_Expr('('.$db->select()->from(array('prev'=>'pins'),'pin_id')->where('pin_id < ?', (string)$pin_id)->order('pin_id DESC')->limit(1).')')));
if (JO_Session::get('user[user_id]')) {
$query->columns(array('following_board' => new JO_Db_Expr('((' . $db->select()->from('users_following_user', 'COUNT(ufu_id)')->where('user_id = ?', JO_Session::get('user[user_id]'))->where('following_id = pins.user_id')->limit(1) . ') + (' . $db->select()->from('users_following', 'COUNT(users_following_id)')->where('user_id = ?', JO_Session::get('user[user_id]'))->where('following_id = pins.user_id')->where('board_id = pins.board_id')->limit(1) . ')-(' . $db->select()->from('users_following_ignore', 'COUNT(users_following_id)')->where('user_id = ?', JO_Session::get('user[user_id]'))->where('following_id = pins.user_id')->where('board_id = pins.board_id')->limit(1) . '))')));
$query->columns(array('following_user' => new JO_Db_Expr('((' . $db->select()->from('users_following_user', 'COUNT(ufu_id)')->where('user_id = ?', JO_Session::get('user[user_id]'))->where('following_id = pins.user_id')->limit(1) . ') + (' . $db->select()->from('users_following', 'COUNT(users_following_id)')->where('user_id = ?', JO_Session::get('user[user_id]'))->where('following_id = pins.user_id')->where('board_id = pins.board_id')->limit(1) . '))')));
$query->columns(array('following_via' => new JO_Db_Expr('((' . $db->select()->from('users_following_user', 'COUNT(ufu_id)')->where('user_id = ?', JO_Session::get('user[user_id]'))->where('following_id = pins.via')->limit(1) . ') + (' . $db->select()->from('users_following', 'COUNT(users_following_id)')->where('user_id = ?', JO_Session::get('user[user_id]'))->where('following_id = pins.via')->where('board_id = pins.board_id')->limit(1) . '))')));
} else {
$query->columns(array('following_board' => new JO_Db_Expr("0")));
$query->columns(array('following_user' => new JO_Db_Expr("0")));
$query->columns(array('following_via' => new JO_Db_Expr("0")));
}
$rows_source = self::describeTable('pins_sources', 'source_');
$query->joinLeft('pins_sources', 'pins.source_id = pins_sources.source_id', $rows_source);
$query->where('pins.pin_id = ?', (string) $pin_id);
//v2.2
if (Helper_Config::get('config_enable_follow_private_profile')) {
$query = self::filterFriend($query);
}
$response = $db->fetchRow($query);
$response = is_array($response) ? $response : array();
$this->data = $response;
// parent::__construct($response);
}
示例6: getPageParents
public static function getPageParents($id)
{
$db = JO_Db::getDefaultAdapter();
$query = $db->select()->from('pages')->joinLeft('pages_description', 'pages_description.id = pages.id AND pages_description.lid = \'' . JO_Session::get('language_id') . '\'', array('lid', 'name', 'text'))->where('visible = ?', 'true')->order('sub_of DESC');
$results = $db->fetchAll($query);
$return = array();
$cnt = count($results);
for ($i = 0; $i < $cnt; $i++) {
if ($results[$i]['id'] == $id) {
$return[] = $results[$i];
$sub_of = $results[$i]['sub_of'];
break;
}
}
$i--;
while ($sub_of > 0 && $i >= 0) {
if ($sub_of == $results[$i]['id']) {
$return[] = $results[$i];
$sub_of = $results[$i]['sub_of'];
}
$i--;
}
$return = array_reverse($return);
return $return;
}
示例7: __construct
public function __construct($data = array())
{
$db = JO_Db::getDefaultAdapter();
try {
$db->beginTransaction();
$data['user_id'] = isset($data['user_id']) ? $data['user_id'] : JO_Session::get('user[user_id]');
$data['public'] = isset($data['public']) ? (int) $data['public'] : 1;
$data['date_added'] = date('Y-m-d H:i:s');
$board_id = Helper_Db::create('boards', $data);
if (!$board_id) {
return $this;
}
Helper_Db::insert('users_boards', array('user_id' => isset($data['user_id']) ? (string) $data['user_id'] : JO_Session::get('user[user_id]'), 'board_id' => $board_id, 'is_author' => 1));
if (isset($data['friends'])) {
foreach ($data['friends'] as $fr) {
Helper_Db::insert('users_boards', array('user_id' => $fr, 'board_id' => $board_id));
}
}
$config_private_boards = Helper_Config::get('config_private_boards');
Helper_Db::update('users', array('boards' => new JO_Db_Expr("(SELECT COUNT(board_id) FROM boards WHERE user_id = '" . (isset($data['user_id']) ? (string) $data['user_id'] : JO_Session::get('user[user_id]')) . "' " . ($config_private_boards ? ' AND public = 1' : '') . ")")), array('user_id = ?' => isset($data['user_id']) ? (string) $data['user_id'] : JO_Session::get('user[user_id]')));
////autoseo
new Model_Boards_Autoseo($board_id);
$this->board_id = $board_id;
$db->commit();
} catch (JO_Exception $e) {
$db->rollBack();
$this->error = $e->getMessage();
}
}
示例8: autocompleteAction
public function autocompleteAction()
{
$request = $this->getRequest();
$this->view->items = array();
if (JO_Session::get('user[user_id]') && $request->getPost('value')) {
$methods = glob(dirname(__FILE__) . '/Search/*.php');
if ($methods) {
foreach ($methods as $file) {
$controller = basename($file, '.php');
$class_name = 'Search_' . $controller;
if (!class_exists($class_name, false)) {
JO_Loader::loadFile($file);
}
$class = new $class_name();
if (method_exists($class, 'autocomplete')) {
$this->view->items = array_merge($this->view->items, $class->autocomplete($request->getPost('value')));
}
}
}
}
$this->view->items[] = array('template' => 'global', 'label' => sprintf($this->translate('Search for %s'), $request->getPost('value')), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=search&q=' . $request->getPost('value')));
if ($request->isXmlHttpRequest()) {
echo $this->renderScript('json');
} else {
$this->forward('error', 'error404');
}
}
示例9: replyMail
public static function replyMail($data)
{
$db = JO_Db::getDefaultAdapter();
$db->insert('users_mails', array('from_user_id' => isset($data['user_id']) ? (string) $data['user_id'] : JO_Session::get('user[user_id]'), 'date_mail' => new JO_Db_Expr('NOW()'), 'text_mail' => (string) $data['text'], 'parent_mail_id' => isset($data['parent']) ? (string) $data['parent'] : 0));
$mail_id = $db->lastInsertId();
if (!$mail_id) {
return false;
}
$replies = self::getReplyConversation($data['parent']);
$recipients = "";
foreach ($replies as $reply) {
if ($reply["from_user_id"] != JO_Session::get('user[user_id]')) {
$pos = strpos($recipients, $reply["from_user_id"] . ",");
if ($pos === false) {
$recipients .= $reply["from_user_id"] . ",";
$db->insert('users_mails_to', array('user_id' => $reply["from_user_id"], 'mail_id' => $mail_id));
}
}
if ($reply["user_id"] != JO_Session::get('user[user_id]')) {
$pos = strpos($recipients, $reply["user_id"] . ",");
if ($pos === false) {
$recipients .= $reply["user_id"] . ",";
$db->insert('users_mails_to', array('user_id' => $reply["user_id"], 'mail_id' => $mail_id));
}
}
}
return array('status' => "OK");
}
示例10: resetAction
public function resetAction()
{
$request = $this->getRequest();
if (!JO_Session::get('user[user_id]')) {
$this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'));
}
$done = $request->issetQuery('done');
if ($done) {
$this->forward('password', 'done');
}
if ($request->isPost()) {
$validate = new Helper_Validate();
$validate->_set_rules($request->getPost('email'), $this->translate('E-mail'), 'not_empty;min_length[5];max_length[100];email');
if ($validate->_valid_form()) {
$result = Model_Users::forgotPassword($request->getPost('email'));
if ($result) {
if ($result['status']) {
$new_password = Model_Users::generatePassword(8);
$key_forgot = md5($result['user_id'] . md5($new_password));
$add_new_pass = Model_Users::edit($result['user_id'], array('new_password' => $new_password, 'new_password_key' => $key_forgot));
if ($add_new_pass) {
$is_mail_smtp = JO_Registry::forceGet('config_mail_smtp');
$mail = new JO_Mail();
if ($is_mail_smtp) {
$mail->setSMTPParams(JO_Registry::forceGet('config_mail_smtp_host'), JO_Registry::forceGet('config_mail_smtp_port'), JO_Registry::forceGet('config_mail_smtp_user'), JO_Registry::forceGet('config_mail_smtp_password'));
}
$this->view->new_password = $new_password;
$this->view->user_info = $result;
$this->view->forgot_password_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login&user_id=' . $result['user_id'] . '&key=' . $key_forgot);
$this->view->header_title = JO_Registry::get('site_name');
$this->view->base_href = WM_Router::create($request->getBaseUrl());
$mail->setFrom(JO_Registry::get('noreply_mail'));
$mail->setReturnPath(JO_Registry::get('noreply_mail'));
$mail->setSubject($this->translate('Request for forgotten password') . ' ' . JO_Registry::get('site_name'));
$mail->setHTML($this->view->render('send_forgot_password_request', 'mail'));
$result_send = (int) $mail->send(array($result['email']), $is_mail_smtp ? 'smtp' : 'mail');
if ($result_send) {
$this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=password&action=reset&done='));
} else {
$this->view->error = $this->translate('There was an error. Please try again later!');
}
} else {
$this->view->error = $this->translate('There was a problem with the record. Please try again!');
}
} else {
$this->view->error = $this->translate('This profile is not active.');
}
} else {
$this->view->error = $this->translate('E-mail address was not found!');
}
} else {
$this->view->error = $validate->_get_error_messages();
}
}
$this->view->form_action = WM_Router::create($request->getBaseUrl() . '?controller=password&action=reset');
$this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
}
示例11: add
public static function add($action, $transactionID, $userID = 0)
{
if ($userID == 0) {
$userID = JO_Session::get('user_id');
}
$db = JO_Db::getDefaultAdapter();
$db->insert(Model_Users::getPrefixDB() . 'history', array('user_id' => $userID, 'action' => $action, 'transaction_id' => $transactionID, 'datetime' => new JO_Db_Expr('NOW()')));
return true;
}
示例12: bind
public function bind($pin_id)
{
$req = new JO_Http_Async();
$request = $this->getRequest();
$user_login_buttons = $this->getByMethod('pin_oncomplete');
foreach ($user_login_buttons as $id => $login) {
$req->curl_get_async($request->getBaseUrl(), array('controller' => 'modules_' . $login . '_pinoncomplete', 'user' => JO_Session::get('user[user_id]'), 'pin' => $pin_id, 'type' => 'edit'));
}
}
示例13: getHistoryV2
public static function getHistoryV2($data, $row = 'to_user_id', $user_id = 0)
{
$db = JO_Db::getDefaultAdapter();
if (!$user_id) {
$user_id = (string) JO_Session::get('user[user_id]');
}
$rows_history = self::describeTable('users_history', 'history_');
$rows_users = self::describeTable('users', 'user_');
switch (Helper_Config::get('config_user_view')) {
case 'username':
$rows_users['user_fullname'] = new JO_Db_Expr('users.username');
break;
case 'firstname':
$rows_users['user_fullname'] = new JO_Db_Expr('users.firstname');
break;
case 'fullname':
default:
$rows_users['user_fullname'] = new JO_Db_Expr('CONCAT(users.firstname, " ", users.lastname)');
break;
}
$query = $db->select()->from('users_history', $rows_history)->joinLeft('users', ($row == 'to_user_id' ? 'users_history.from_user_id' : 'users_history.to_user_id') . ' = users.user_id', $rows_users)->where($row . ' = ?', $user_id);
if (isset($data['filter_history_action']) && (int) $data['filter_history_action']) {
$query->where('users_history.history_action = ?', (int) $data['filter_history_action']);
}
if (isset($data['start']) && isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
$query->limit($data['limit'], $data['start']);
}
if (isset($data['sort']) && strtolower($data['sort']) == 'asc') {
$sort = ' ASC';
} else {
$sort = ' DESC';
}
$allow_sort = array('history_id');
if (isset($data['order']) && in_array($data['order'], $allow_sort)) {
$query->order($data['order'] . $sort);
} else {
$query->order('history_id' . $sort);
}
$results = $db->fetchAll($query);
$data = array();
if ($results) {
foreach ($results as $result) {
$result['history_text_type'] = self::getType($result['history_history_action']);
if ($result['history_text_type']) {
$result['history_date_dif'] = array_shift(WM_Date::dateDiff($result['history_date_added'], time()));
$data[] = $result;
}
}
}
return $data;
}
示例14: 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']));
}
}
}
示例15: autocomplete
public function autocomplete($query)
{
$request = $this->getRequest();
$result = array();
$has_friends = (int) JO_Session::get('user[following]') + (int) JO_Session::get('user[followers]');
$users = $has_friends ? new Model_Users_SearchAutocomplete(array('filter_username' => $query, 'start' => 0, 'limit' => 100)) : new ArrayObject();
if ($has_friends && $users->count()) {
foreach ($users as $user) {
$result[] = array('template' => 'user', 'avatars' => Helper_Uploadimages::userAvatars($user), 'fullname' => $user['fullname'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $user['user_id']));
}
}
return $result;
}