Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 public function indexAction()
 {
     $request = $this->getRequest();
     $this->view->invate_limit = 5;
     if ($request->isPost()) {
         $emails = array();
         $this->view->send = array();
         for ($i = 1; $i < $this->view->invate_limit; $i++) {
             $this->view->send[$i] = array('success' => false, 'error' => false);
             $validate = new Helper_Validate();
             if ($request->getPost('email-' . $i) != $this->translate('Email Adress ' . $i)) {
                 $validate->_set_rules($request->getPost('email-' . $i), $this->translate('Email Adress ' . $i), 'not_empty;min_length[5];max_length[100];email');
                 if ($validate->_valid_form()) {
                     $shared_content = Model_Users::sharedContentInvate($request->getPost('email-' . $i));
                     if ($shared_content == 1) {
                         $this->view->send[$i]['error'] = $this->translate('With this email address is already registered users!');
                     } else {
                         if ($shared_content == 2) {
                             $this->view->send[$i]['error'] = $this->translate('To this email has been sent an invitation!');
                         } else {
                             $inser_key = Model_Users::sharedContent($request->getPost('email-' . $i));
                             if ($inser_key == -1) {
                                 $this->view->send[$i]['error'] = $this->translate('There was an error. Please try again later!');
                             } else {
                                 $template = Model_Notification::getTemplate('send_invate');
                                 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_message' => $request->getPost('note') != $this->translate('Add a personal note') ? $request->getPost('note') : '', 'site_url' => $request->getBaseUrl(), 'site_name' => Helper_Config::get('site_name'), 'invate_url' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=register&user_id=' . JO_Session::get('user[user_id]') . '&key=' . $inser_key), 'mail_footer' => html_entity_decode(Helper_Config::get('mail_footer'), ENT_QUOTES, 'utf-8'));
                                     if (!$template['title']) {
                                         $template['title'] = $this->translate('Join and create your own pinboards');
                                     }
                                     $title = Model_Notification::parseTemplate(html_entity_decode($template['title'], ENT_QUOTES, 'utf-8'), $template_data);
                                     $template = Model_Notification::parseTemplate(html_entity_decode($template['template'], ENT_QUOTES, 'utf-8'), $template_data);
                                     $result = Model_Email::send($request->getPost('email-' . $i), Helper_Config::get('noreply_mail'), $title, $template);
                                     if ($result) {
                                         $this->view->send[$i]['success'] = $this->translate('The invitation was sent successfully!');
                                     } else {
                                         $this->view->send[$i]['error'] = $this->translate('There was an error. Please try again later!');
                                     }
                                 } else {
                                     $this->view->send[$i]['error'] = $this->translate('There was an error. Please try again later!');
                                 }
                             }
                         }
                     }
                 } else {
                     $this->view->send[$i]['error'] = strip_tags($validate->_get_error_messages());
                 }
             }
         }
         if ($request->isXmlHttpRequest()) {
             echo $this->renderScript('json');
             exit;
         } else {
             JO_Session::set('result_from_invate', $this->view->send);
             $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=invites'));
         }
     }
     if (JO_Session::get('result_from_invate')) {
         $this->view->result_from_invate = JO_Session::get('result_from_invate');
         JO_Session::clear('result_from_invate');
     }
     $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part', 'methodsforinvates' => 'invates/methodsforinvates');
 }
Ejemplo n.º 3
0
 public function emailAction()
 {
     $request = $this->getRequest();
     $pin_id = $request->getRequest('pin_id');
     $pin_info = new Model_Pins_Pin($pin_id);
     if (!$pin_info->count()) {
         $this->forward('error', 'error404');
     }
     $pin_info = $pin_info->data;
     $this->view->pin_id = $pin_id;
     $this->view->pin_href = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin_id);
     $this->view->url_form = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=email&pin_id=' . $pin_id);
     if ($request->issetPost('name')) {
         $this->view->Recipient_name = $request->getPost('name');
     } else {
         $this->view->Recipient_name = '';
     }
     if ($request->issetPost('email')) {
         $this->view->Recipient_email = $request->getPost('email');
     } else {
         $this->view->Recipient_email = '';
     }
     if ($request->issetPost('message')) {
         $this->view->Recipient_message = $request->getPost('message');
     } else {
         $this->view->Recipient_message = '';
     }
     $this->view->pins_details = $this->view->render('email', 'pin');
     $this->view->error = '';
     if ($request->isPost()) {
         $validate = new Helper_Validate();
         $validate->_set_rules($request->getPost('name'), $this->translate('Recipient Name'), 'not_empty;min_length[3];max_length[100]');
         $validate->_set_rules($request->getPost('email'), $this->translate('Recipient Email'), 'not_empty;min_length[5];max_length[100];email');
         //			$validate->_set_rules($request->getPost('message'), $this->translate('Message'), 'not_empty;min_length[15]');
         if ($validate->_valid_form()) {
             $this->view->is_posted = true;
             $shared_content = new Model_Users_Invate($request->getPost('email'));
             $shared_content_url = $request->getBaseUrl();
             if (!$shared_content->is_user) {
                 if ($shared_content->key) {
                     $shared_content_url = WM_Router::create($request->getBaseUrl() . '?controller=users&action=register&user_id=' . JO_Session::get('user[user_id]') . '&key=' . $shared_content->key);
                 }
             }
             $template = Model_Notification::getTemplate('send_pin');
             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]'), 'recipient_name' => $request->getPost('name'), 'site_url' => $request->getBaseUrl(), 'site_name' => Helper_Config::get('site_name'), 'invate_url' => $shared_content_url, 'pin_url' => WM_Router::pinAction($pin_id), 'user_message' => nl2br($request->getPost('message')), 'mail_footer' => html_entity_decode(Helper_Config::get('mail_footer'), ENT_QUOTES, 'utf-8'));
                 if (!$template['title']) {
                     $template['title'] = $this->translate('Shared content from') . ' ${user_firstname}';
                 }
                 $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);
                 $result = Model_Email::send($request->getPost('email'), Helper_Config::get('noreply_mail'), $title, $body);
                 if ($result) {
                     $this->setViewChange('message_email');
                 } else {
                     $this->view->error = $this->translate('There was an error. Please try again later!');
                 }
             } else {
                 $this->view->error = $this->translate('There was an error. Please try again later!');
             }
         } else {
             $this->view->error = $validate->_get_error_messages();
         }
     }
     if ($this->view->error) {
         $this->setViewChange('email');
     }
     $this->noLayout(true);
 }
Ejemplo n.º 4
0
 public function followAction()
 {
     $this->noViewRenderer(true);
     $request = $this->getRequest();
     if ($request->isXmlHttpRequest()) {
         if ((int) JO_Session::get('user[user_id]')) {
             $user_id = $request->getRequest('user_id');
             $user_info = new Model_Users_User($user_id);
             if ($user_info->count()) {
                 $follow = new Model_Users_Follow($user_id);
                 if ($user_info['following_user']) {
                     $result = $follow->unfollowUser();
                     if ($result === true) {
                         new Model_History_AddHistory($user_id, Model_History_Abstract::UNFOLLOW_USER);
                         $this->view->ok = $this->translate('Follow');
                         $this->view->classs = 'add';
                         $this->view->boardauthorid = $user_id;
                     } else {
                         $this->view->error = $this->translate('There was a problem with the record. Please try again!');
                     }
                 } else {
                     $result = $follow->followUser();
                     if ($result === true) {
                         new Model_History_AddHistory($user_id, Model_History_Abstract::FOLLOW_USER);
                         $this->view->ok = $this->translate('Unfollow');
                         $this->view->classs = 'remove';
                         $this->view->boardauthorid = $user_id;
                         if ($user_info['email_interval'] && $user_info['follows_email']) {
                             $template = Model_Notification::getTemplate('follow_user');
                             if ($template) {
                                 $template_data = array('user_id' => $user_info['user_id'], 'user_firstname' => $user_info['firstname'], 'user_lastname' => $user_info['lastname'], 'user_fullname' => $user_info['fullname'], 'user_username' => $user_info['username'], 'author_url' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . JO_Session::get('user[user_id]')), 'author_fullname' => JO_Session::get('user[fullname]'), 'mail_footer' => html_entity_decode(Helper_Config::get('mail_footer'), ENT_QUOTES, 'utf-8'));
                                 if (!$template['title']) {
                                     $template['title'] = '${author_fullname} ' . $this->translate('now follow you');
                                 }
                                 $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($user_info['email'], Helper_Config::get('noreply_mail'), $title, $body);
                             }
                         }
                     } else {
                         $this->view->error = $this->translate('There was a problem with the record. Please try again!');
                     }
                 }
             } else {
                 $this->view->error = $this->translate('There was a problem with the record. Please try again!');
             }
         } else {
             $this->view->location = WM_Router::create($request->getBaseUrl() . '?controller=landing');
         }
     } else {
         $this->forward('error', 'error404');
     }
     echo $this->renderScript('json');
 }
Ejemplo n.º 5
0
 public function indexAction()
 {
     $request = $this->getRequest();
     if (!JO_Session::get('user[user_id]')) {
         $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login&popup=true&next=' . urlencode($request->getFullUrl())));
     }
     $this->view->createBoard = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=create');
     $boards = new Model_Boards_BoardsWithShared(array('filter_user_id' => JO_Session::get('user[user_id]')));
     $this->view->boards = array();
     if ($boards->count()) {
         foreach ($boards as $board) {
             $this->view->boards[] = array('board_id' => $board['board_board_id'], 'title' => $board['board_title']);
         }
     }
     ///////////////// Extension on create //////////////////
     $this->view->form_extensions = array();
     $extensions = Model_Extensions::getByMethod('pin_oncreateform');
     if ($extensions) {
         $front = JO_Front::getInstance();
         foreach ($extensions as $id => $ext) {
             $this->view->form_extensions[] = array('html' => $this->view->callChildren('modules_' . $ext . '_oncreateform'), 'view' => $this->view->callChildrenView('modules_' . $ext . '_oncreateform'), 'key' => $ext);
         }
     }
     $this->view->title = JO_Utf8::convertToUtf8($request->getQuery('title'));
     $this->view->url = JO_Utf8::convertToUtf8(urldecode($request->getQuery('url')));
     $this->view->media = JO_Utf8::convertToUtf8($request->getQuery('media'));
     $this->view->is_video = JO_Utf8::convertToUtf8($request->getQuery('is_video'));
     $this->view->description = JO_Utf8::convertToUtf8($request->getQuery('description'));
     $this->view->charset = JO_Utf8::convertToUtf8($request->getQuery('charset'));
     if (is_array($request->getPost())) {
         foreach ($request->getPost() as $k => $v) {
             $this->view->{$k} = $v;
         }
     }
     if (!trim($this->view->description)) {
         $this->view->description = $this->view->title;
     }
     if (JO_Session::get('success_added')) {
         return $this->success();
     } else {
         if ($request->isPost()) {
             $validate = new Helper_Validate();
             $validate->_set_rules($request->getPost('description'), $this->translate('Description'), 'not_empty;min_length[1];max_length[500]');
             $validate->_set_rules($request->getPost('board_id'), $this->translate('Board'), 'not_empty;');
             if ($validate->_valid_form()) {
                 $result = new Model_Pins_Create($request->getPost());
                 if ($result->count()) {
                     $result = $result->data;
                     ///add history
                     new Model_History_AddHistory(JO_Session::get('user[user_id]'), Model_History_Abstract::ADDPIN, $result['pin_id']);
                     //send notification
                     $users = new Model_Users_GroupBoardUsers($request->getPost('board_id'));
                     if ($users->count()) {
                         $template = Model_Notification::getTemplate('group_board');
                         if ($template) {
                             $pin_info = new Model_Pins_Pin($result['pin_id']);
                             if ($pin_info->count()) {
                                 $mail_footer = html_entity_decode(Helper_Config::get('mail_footer'), ENT_QUOTES, 'utf-8');
                                 foreach ($users as $user) {
                                     if ($user['email_interval'] == 1 && $user['groups_pin_email']) {
                                         $template_data = array('user_id' => $user['user_id'], 'user_firstname' => $user['firstname'], 'user_lastname' => $user['lastname'], 'user_fullname' => $user['fullname'], 'user_username' => $user['username'], 'author_url' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $pin_info['user_user_id']), 'author_fullname' => $pin_info['user_fullname'], 'board_url' => WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin_info['user_user_id'] . '&board_id=' . $pin_info['board_board_id']), 'board_name' => $pin_info['board_title'], 'pin_url' => WM_Router::pinAction($result['pin_id']), 'mail_footer' => $mail_footer);
                                         if (!$template['title']) {
                                             $template['title'] = '${author_fullname} ' . $this->translate('added new pin to a group board');
                                         }
                                         $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($user['email'], Helper_Config::get('noreply_mail'), $title, $body);
                                     }
                                 }
                             }
                         }
                     }
                     JO_Session::set('success_added', $result['pin_id']);
                     $this->redirect($request->getBaseUrl() . '?controller=bookmarklet');
                 } else {
                     if ($result->error) {
                         $this->view->error = $result->error;
                     } else {
                         $this->view->error = $this->translate('There was a problem with the record. Please try again!');
                     }
                 }
             } else {
                 $this->view->error = $validate->_get_error_messages();
             }
         }
     }
 }
Ejemplo n.º 6
0
 public function createAction()
 {
     $request = $this->getRequest();
     if (JO_Session::get('user[user_id]')) {
         if ($request->isPost()) {
             $validate = new Helper_Validate();
             $validate->_set_rules($request->getPost('newboard'), $this->translate('Board Name'), 'not_empty;min_length[3];max_length[100]');
             $validate->_set_rules($request->getPost('category_id'), $this->translate('Board Category'), 'not_empty');
             if ($validate->_valid_form()) {
                 $postData = array_merge($request->getPost(), array('title' => $request->getPost('newboard')));
                 if (Helper_Config::get('config_private_boards')) {
                     $postData['public'] = (int) (!$request->issetPost('public'));
                 }
                 $result = new Model_Boards_Create($postData);
                 if ($result->board_id) {
                     $this->view->redirect = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . JO_Session::get('user[user_id]') . '&board_id=' . $result->board_id);
                     $this->view->created = true;
                     //send notifications
                     if (is_array($request->getPost('friends'))) {
                         $template = Model_Notification::getTemplate('board_invite');
                         if ($template) {
                             $mail_footer = html_entity_decode(Helper_Config::get('mail_footer'), ENT_QUOTES, 'utf-8');
                             foreach ($request->getPost('friends') as $user_id) {
                                 $user = new Model_Users_User($user_id);
                                 if ($user->count()) {
                                     if ($user['email_interval'] == 1 && $user['groups_pin_email']) {
                                         $template_data = array('user_id' => $user['user_id'], 'user_firstname' => $user['firstname'], 'user_lastname' => $user['lastname'], 'user_fullname' => $user['fullname'], 'user_username' => $user['username'], 'author_url' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . JO_Session::get('user[user_id]')), 'author_fullname' => JO_Session::get('user[fullname]'), 'board_url' => WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . JO_Session::get('user[user_id]') . '&board_id=' . $result->board_id), 'board_name' => $request->getPost('newboard'), 'mail_footer' => $mail_footer);
                                         if (!$template['title']) {
                                             $template['title'] = '${author_fullname} ' . $this->translate('invited you to add pins');
                                         }
                                         $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($user['email'], Helper_Config::get('noreply_mail'), $title, $body);
                                     }
                                 }
                             }
                         }
                     }
                 } else {
                     $this->view->error = $this->translate('There was a problem with the record. Please try again!');
                 }
             } else {
                 $this->view->error = $validate->_get_error_messages();
             }
             echo $this->renderScript('json');
         } else {
             $this->view->avatars = Helper_Uploadimages::userAvatars(JO_Session::get('user'));
             $this->view->fullname = JO_Session::get('user[fullname]');
             $this->view->userhref = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . JO_Session::get('user[user_id]'));
             $this->view->friends_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=friends');
             $this->view->form_action = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=create');
             $this->view->private = 1;
             /////private boards
             $this->view->enable_private_boards = Helper_Config::get('config_private_boards');
             $private_boards = Model_Pages::getPage(Helper_Config::get('page_private_boards'));
             if ($private_boards) {
                 $this->view->text_private_boards = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=pages&action=read&page_id=' . Helper_Config::get('page_private_boards'));
             }
             //////////// Categories ////////////
             $this->view->categories = Model_Categories::getCategories(array('filter_status' => 1));
             $this->view->config_board_description_enable = Helper_Config::get('config_board_description_enable');
             $this->view->popup_main_box = $this->view->render('popup_form', 'boards');
             $this->setViewChange('form');
             if ($request->isXmlHttpRequest()) {
                 $this->view->popup = true;
                 echo $this->view->popup_main_box;
                 $this->noViewRenderer(true);
             } else {
                 $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part', 'left_part' => 'layout/left_part');
             }
         }
     } else {
         $this->view->redirect = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login');
         // 			echo $this->renderScript('json');
         $this->setViewChange('redirect');
     }
 }
Ejemplo n.º 7
0
 public function pinMediaCallbackAction()
 {
     $request = $this->getRequest();
     if (JO_Session::get('user[user_id]')) {
         $media = Model_Instagram_Media::getMedia($request->getPost('media_id'));
         if ($media) {
             if ($media['user_id'] == JO_Session::get('user[user_id]')) {
                 $result = new Model_Pins_Create(array('title' => $media['title'], 'from' => $media['from'], 'image' => $media['media'], 'description' => $media['title'], 'board_id' => JO_Session::get('instagram_media[board_id]')));
                 if ($result->count()) {
                     $result = $result->data;
                     $this->view->pin_url = WM_Router::pinAction($result['pin_id']);
                     Model_Instagram_Media::setPinMedia($media['media_id'], $result['pin_id']);
                     ///add history
                     new Model_History_AddHistory(JO_Session::get('user[user_id]'), Model_History_Abstract::ADDPIN, $result['pin_id']);
                     //send notification
                     $users = new Model_Users_GroupBoardUsers(JO_Session::get('instagram_media[board_id]'));
                     if ($users->count()) {
                         $template = Model_Notification::getTemplate('group_board');
                         if ($template) {
                             $pin_info = new Model_Pins_Pin($result['pin_id']);
                             if ($pin_info->count()) {
                                 $mail_footer = html_entity_decode(Helper_Config::get('mail_footer'), ENT_QUOTES, 'utf-8');
                                 foreach ($users as $user) {
                                     if ($user['email_interval'] == 1 && $user['groups_pin_email']) {
                                         $template_data = array('user_id' => $user['user_id'], 'user_firstname' => $user['firstname'], 'user_lastname' => $user['lastname'], 'user_fullname' => $user['fullname'], 'user_username' => $user['username'], 'author_url' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $pin_info['user_user_id']), 'author_fullname' => $pin_info['user_fullname'], 'board_url' => WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin_info['user_user_id'] . '&board_id=' . $pin_info['board_board_id']), 'board_name' => $pin_info['board_title'], 'pin_url' => WM_Router::pinAction($pin_info['pin_pin_id']), 'mail_footer' => $mail_footer);
                                         if (!$template['title']) {
                                             $template['title'] = '${author_fullname} ' . $this->translate('added new pin to a group board');
                                         }
                                         $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($user['email'], Helper_Config::get('noreply_mail'), $title, $body);
                                     }
                                 }
                             }
                         }
                     }
                     $this->view->ok = true;
                 } else {
                     $this->view->error = $this->translate('There was a problem with the record. Please try again!');
                 }
             } else {
                 $this->view->error = $this->translate('Private media!');
             }
         } else {
             $this->view->error = $this->translate('Media not found!');
         }
     } else {
         $this->view->location = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login');
     }
     echo $this->renderScript('json');
 }
Ejemplo n.º 8
0
 public function header_partAction()
 {
     $request = $this->getRequest();
     if (JO_Session::get('user[user_id]') && JO_Session::get('category_id')) {
         new Model_Users_Edit(JO_Session::get('user[user_id]'), array('first_login' => '0'));
         JO_Session::clear('category_id');
         $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' => $request->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->view->show_landing = !Helper_Config::get('enable_free_registration');
     $this->getLayout()->placeholder('site_name', Helper_Config::get('site_name'));
     $this->view->site_name = Helper_Config::get('site_name');
     $this->view->meta_title = Helper_Config::get('meta_title');
     $this->getLayout()->placeholder('google_analytics', html_entity_decode(Helper_Config::get('google_analytics'), ENT_QUOTES, 'utf-8'));
     $this->view->baseUrl = $request->getBaseUrl();
     $this->view->site_logo = $request->getBaseUrl() . 'data/images/logo.png';
     if (Helper_Config::get('site_logo') && file_exists(BASE_PATH . '/uploads' . Helper_Config::get('site_logo'))) {
         $this->view->site_logo = $request->getBaseUrl() . 'uploads' . Helper_Config::get('site_logo');
     }
     ///global metas
     if (!JO_Layout::getInstance()->placeholder('header_metas')) {
         $to_title = '';
         if (JO_Session::get('user[user_id]')) {
             $to_title = JO_Session::get('user[fullname]') . ' / ';
         }
         $this->getLayout()->placeholder('title', $to_title . Helper_Config::get('meta_title'));
         JO_Layout::getInstance()->placeholder('header_metas', $this->view->callChildren('layout/header_metas', array('meta_title' => Helper_Config::get('meta_title'), 'meta_description' => Helper_Config::get('meta_description'), 'meta_keywords' => Helper_Config::get('meta_keywords'), 'site_logo' => $this->view->site_logo)));
     }
     if (Helper_Config::get('favicon') && file_exists(BASE_PATH . '/uploads' . Helper_Config::get('favicon'))) {
         $this->getLayout()->placeholder('favicon', $request->getBaseUrl() . 'uploads' . Helper_Config::get('favicon'));
     }
     $this->getLayout()->placeholder('site_logo', $this->view->site_logo);
     $this->view->show_header_invate = !JO_Session::get('user[user_id]');
     $this->view->controller_open = $request->getController();
     //==== brand =====//
     $this->view->show_brand = false;
     /*if( JO_Registry::get('license_powered_check') == 'false' && Helper_Config::get('config_hide_brand') ) {
     			$this->view->show_brand = false;
     		}*/
     ////////// CURRENCY
     //autoupdate currency if set
     if (Helper_Config::get('config_currency_auto_update')) {
         WM_Currency::updateCurrencies();
     }
     //////////// Categories ////////////
     $this->view->categories = array();
     $this->view->category_active = false;
     $categories = Model_Categories::getCategories(array('filter_status' => 1));
     foreach ($categories as $category) {
         $category['href'] = WM_Router::create($request->getBaseUrl() . '?controller=category&category_id=' . $category['category_id']);
         $category['active'] = $category['category_id'] == $request->getRequest('category_id');
         if ($category['active']) {
             $this->view->category_active = $category['title'];
         } else {
         }
         $this->view->categories[] = $category;
     }
     ////////////////////////////// USER MENU ///////////////////////////
     $this->view->is_loged = JO_Session::get('user[user_id]');
     if ($this->view->is_loged) {
         $model_images = new Helper_Images();
         $avatar = Helper_Uploadimages::avatar(JO_Session::get('user'), '_A');
         $this->view->self_avatar = Helper_Uploadimages::userAvatars(JO_Session::get('user'));
         $this->view->self_profile = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $this->view->is_loged);
         $this->view->self_firstname = JO_Session::get('user[firstname]');
         $this->view->logout = WM_Router::create($request->getBaseUrl() . '?controller=users&action=logout');
         $this->view->user_pins = WM_Router::create($request->getBaseUrl() . '?controller=users&action=pins&user_id=' . $this->view->is_loged);
         $this->view->user_pins_likes = WM_Router::create($request->getBaseUrl() . '?controller=users&action=pins&user_id=' . $this->view->is_loged . '&filter=likes');
         $this->view->settings = WM_Router::create($request->getBaseUrl() . '?controller=settings');
     }
     $this->view->login = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login');
     $this->view->landing = WM_Router::create($request->getBaseUrl() . '?controller=landing');
     $this->view->registration = WM_Router::create($request->getBaseUrl() . '?controller=users&action=register');
     ////////////////////////////// GIFTS ///////////////////////////
     $this->view->gifts = WM_Router::create($request->getBaseUrl() . '?controller=gifts');
     $this->view->giftSums = array();
     $sums = Model_Gifts::getAll();
     foreach ($sums as $sum) {
         if ($sum['price_from'] || $sum['price_to']) {
             $title = WM_Currency::format($sum['price_from']);
             $url = '';
             if ($sum['price_to']) {
                 $title .= ' - ';
                 $title .= WM_Currency::format($sum['price_to']);
                 $url = '&price_to=' . $sum['price_to'];
             } else {
                 $title .= '+';
             }
             $this->view->giftSums[] = array('title' => $title, 'href' => WM_Router::create($request->getBaseUrl() . '?controller=gifts&price_from=' . $sum['price_from'] . $url));
         }
     }
     //////////// Video ////////////
     $this->view->video_url = WM_Router::create($request->getBaseUrl() . '?controller=videos');
     //////////// Popular ////////////
     $this->view->popular_url = WM_Router::create($request->getBaseUrl() . '?controller=popular');
     //////////// ALL PINS ////////////
     $this->view->all_url = WM_Router::create($request->getBaseUrl() . '?controller=all');
     ////////////////////////////// SEARCH ///////////////////////////
     //$this->view->search_action = WM_Router::create($request->getBaseUrl() . '?controller=search');
     if ($request->getAction() != 'index' && $request->getController() == 'search') {
         $with_action = $request->getAction();
         $this->view->search_action = WM_Router::create($request->getBaseUrl() . '?controller=search&action=' . $request->getAction());
     } else {
         $with_action = 0;
         $this->view->search_action = WM_Router::create($request->getBaseUrl() . '?controller=search');
     }
     $this->view->search_autocomplete = WM_Router::create($request->getBaseUrl() . '?controller=search&action=autocomplete');
     if (strpos($this->view->search, '?') !== false) {
         $this->view->show_hidden = true;
         $this->view->with_action = $with_action;
     }
     $this->view->keywords = $request->issetQuery('q') ? $request->getQuery('q') : $this->translate('Search');
     ////////////////////////////// ADD PIN ///////////////////////////
     $this->view->addPin = WM_Router::create($request->getBaseUrl() . '?controller=addpin');
     ////////////////////////////// user ignore search engine ///////////////////////////
     if ($request->getRequest('user_id')) {
         $user_info = Model_Users::getUser($request->getRequest('user_id'));
         if ($user_info && $user_info['dont_search_index']) {
             $this->getLayout()->placeholder('inhead', '<meta name="robots" content="noindex"/>');
         }
     }
     ////////////////////////////// ABOUT MENU ///////////////////////////
     $about_menu = Model_Pages::getMenu(0);
     $this->view->about_menu = array();
     foreach ($about_menu as $row => $page) {
         $class = '';
         if ($row == 0) {
             $class .= ' first';
         } else {
             if (count($about_menu) - 1 == $row) {
                 $class .= ' last';
             }
         }
         if ($page['page_id'] == -1) {
             $has = true;
         } else {
             if ($page['status']) {
                 if (isset($has) && $has) {
                     $class .= " group";
                     $has = false;
                 }
                 $this->view->about_menu[] = array('class' => trim($class), 'title' => $page['title'], 'href' => WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=pages&action=read&page_id=' . $page['page_id']));
             }
             $has = false;
         }
     }
     ////////////////////////////// NEW PASSWORD ///////////////////////////
     $this->view->show_new_password = false;
     if (JO_Session::get('user[user_id]') && JO_Session::get('user[email]') != JO_Session::get('user[new_email]')) {
         /*switch(true) {
         			case 'index' == $request->getController():
         			case 'all' == $request->getController():
         			case 'category' == $request->getController():
         			case 'videos' == $request->getController():
         			case 'popular' == $request->getController():
         			case 'gifts' == $request->getController():
         				$this->view->show_new_password = true;
         			break;
         		}*/
         $this->view->show_new_password = true;
     }
     ////////////////////////////// Board category ///////////////////////////
     if (($board_info = JO_Registry::forceGet('board_category_change')) instanceof ArrayObject) {
         $this->view->board_category_change = array('title' => $board_info['board_title'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=boards&action=edit&user_id=' . $board_info['board_user_id'] . '&board_id=' . $board_info['board_board_id']));
     }
     ///////////////////// invate menu user /////////////////////////////
     $methodsforinvates = $this->view->callChildrenView('invates/methodsforinvates');
     $this->view->methodsforinvates = (array) $methodsforinvates->user_invate_friends;
     ///////////////////// extra metatags /////////////////////////////
     $extra_metas = '';
     $extra_metas_get = Model_Extensions::getByMethod('extra_metas');
     foreach ($extra_metas_get as $id => $mod) {
         $extra_metas .= $this->view->callChildren('modules_' . $mod . '_extrametas');
     }
     if ($extra_metas) {
         JO_Layout::getInstance()->placeholder('header_metas', $extra_metas);
     }
 }
Ejemplo n.º 9
0
 public function indexAction()
 {
     $request = $this->getRequest();
     $user_data = Model_Users::getUser(JO_Session::get('user[user_id]'));
     $upload = new JO_Upload_SessionStore();
     $upload->setName('upload_avatar');
     $info = $upload->getFileInfo();
     if (JO_Session::get('successfu_edite')) {
         $this->view->successfu_edite = true;
         JO_Session::clear('successfu_edite');
     }
     if (JO_Session::get('connect_error')) {
         $this->view->error = JO_Session::get('connect_error');
         JO_Session::clear('connect_error');
     }
     $this->view->config_enable_follow_private_profile = Helper_Config::get('config_enable_follow_private_profile');
     if ($request->isPost()) {
         $validate = new Helper_Validate();
         $validate->_set_rules($request->getPost('username'), $this->translate('Username'), 'not_empty;min_length[3];max_length[100];username');
         $validate->_set_rules($request->getPost('firstname'), $this->translate('First name'), 'not_empty;min_length[3];max_length[100]');
         $validate->_set_rules($request->getPost('lastname'), $this->translate('Last name'), 'not_empty;min_length[3];max_length[100]');
         $validate->_set_rules($request->getPost('email'), $this->translate('Email'), 'not_empty;min_length[5];max_length[100];email');
         $data = $request->getPost();
         if ($validate->_valid_form()) {
             if (Model_Users::isExistEmail($request->getPost('email'), JO_Session::get('user[email]'))) {
                 $validate->_set_form_errors($this->translate('This e-mail address is already used'));
                 $validate->_set_valid_form(false);
             }
             if (Model_Users::isExistUsername($request->getPost('username'), JO_Session::get('user[username]'))) {
                 $validate->_set_form_errors($this->translate('This username is already used'));
                 $validate->_set_valid_form(false);
             }
         }
         if ($validate->_valid_form()) {
             $data['dont_search_index'] = (int) $request->issetPost('dont_search_index');
             $data['facebook_timeline'] = (int) $request->issetPost('facebook_timeline');
             /* v2.2 */
             if ($this->view->config_enable_follow_private_profile) {
                 $data['enable_follow'] = (int) (!$request->issetPost('enable_follow'));
                 $data['public'] = (int) (!$request->issetPost('public'));
             }
             /* v2.2 */
             if ($info) {
                 if (!@file_exists(BASE_PATH . '/cache/avatar/') || !is_dir(BASE_PATH . '/cache/avatar/')) {
                     mkdir(BASE_PATH . '/cache/avatar/');
                 }
                 $filename = BASE_PATH . '/cache/avatar/' . md5(mt_rand() . time()) . $upload->get_extension($info['name']);
                 if (file_put_contents($filename, $info['data'])) {
                     $data['avatar'] = $filename;
                 }
             }
             $new_email_key = md5(JO_Session::get('user[email]') . mt_rand() . time());
             if (JO_Session::get('user[email]') != $request->getPost('email')) {
                 $data['new_email_key'] = $new_email_key;
             } else {
                 $data['new_email_key'] = '';
             }
             $data['new_email'] = $data['email'];
             unset($data['email']);
             $result = new Model_Users_Edit(JO_Session::get('user[user_id]'), $data);
             if ($result->affected_rows) {
                 JO_Session::set('successfu_edite', true);
                 $upload->getFileInfo(true);
                 if (JO_Session::get('user[email]') != $request->getPost('email')) {
                     /*$this->view->verify_email_href = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=login&user_id='.JO_Session::get('user[user_id]').'&verify=' . $new_email_key );
                     		$this->view->user_info = $user_data;
                     		Model_Email::send(
                       	        	$request->getPost('email'),
                       	        	Helper_Config::get('noreply_mail'),
                       	        	$this->translate('Please verify your email'),
                       	        	$this->view->render('verify_email', 'mail')
                       	        );*/
                     $template = Model_Notification::getTemplate('verify_email');
                     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]'), 'verify_email_url' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=login&user_id=' . JO_Session::get('user[user_id]') . '&verify=' . $new_email_key), 'site_url' => $request->getBaseUrl(), 'site_name' => Helper_Config::get('site_name'), 'user_message' => '', 'mail_footer' => html_entity_decode(Helper_Config::get('mail_footer'), ENT_QUOTES, 'utf-8'));
                         if (!$template['title']) {
                             $template['title'] = $this->translate('Please verify your email');
                         }
                         $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($request->getPost('email'), Helper_Config::get('noreply_mail'), $title, $body);
                     }
                 }
                 $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=settings'));
             } else {
                 $this->view->error = $this->translate('There was a problem with the record. Please try again!');
             }
         } else {
             $this->view->error = $validate->_get_error_messages();
         }
         foreach ($data as $k => $v) {
             if (isset($user_data[$k])) {
                 $user_data[$k] = $v;
             }
         }
     }
     if ($info) {
         $user_data['avatar'] = WM_Router::create($request->getBaseUrl() . '?controller=settings&action=temporary_avatar&s=' . microtime(true));
         $user_data['has_avatar'] = true;
     } else {
         $avatar = Helper_Uploadimages::avatar($user_data, '_C');
         $user_data['avatar'] = $avatar['image'] . '?s=' . microtime(true);
         $user_data['has_avatar'] = @getimagesize($user_data['avatar']) ? true : false;
     }
     $this->view->instagram_enable = JO_Registry::get('oauth_in_key');
     $this->view->twitteroauth_enable = JO_Registry::get('oauth_tw_key');
     $this->view->facebook_enable = JO_Registry::get('oauth_fb_key');
     $this->view->user_data = $user_data;
     $this->view->form_action = WM_Router::create($request->getBaseUrl() . '?controller=settings&action=upload_avatar');
     $this->view->check_username = WM_Router::create($request->getBaseUrl() . '?controller=settings&action=check_username');
     $this->view->delete_username = WM_Router::create($request->getBaseUrl() . '?controller=users&action=delete&user_id=' . $user_data['user_id']);
     $this->view->prefs_action = WM_Router::create($request->getBaseUrl() . '?controller=prefs');
     $this->view->new_password = WM_Router::create($request->getBaseUrl() . '?controller=password&action=change');
     $this->view->site_name = JO_Registry::get('site_name');
     $this->view->base_href = $request->getBaseUrl();
     $this->view->delete_account = '';
     if (JO_Registry::get('delete_account')) {
         $page_description = Model_Pages::getPage(JO_Registry::get('delete_account'));
         if ($page_description) {
             $this->view->delete_account = html_entity_decode($page_description['description'], ENT_QUOTES, 'utf-8');
         }
     }
     //extensions
     $this->view->user_login_buttons = array();
     $user_login_buttons = Model_Extensions::getByMethod('user_login');
     foreach ($user_login_buttons as $id => $login) {
         $this->view->user_login_buttons[] = $this->view->callChildren('modules_' . $login . '_connect', WM_Router::create($request->getBaseUrl() . '?controller=modules_' . $login . '_register'));
     }
     $this->view->user_avatars = array();
     $user_login_buttons = Model_Extensions::getByMethod('user_avatar');
     foreach ($user_login_buttons as $id => $login) {
         $this->view->user_avatars[] = $this->view->callChildren('modules_' . $login . '_useravatar', WM_Router::create($request->getBaseUrl() . '?controller=modules_' . $login . '_register'));
     }
     $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
 }