private function getForm() { $request = $this->getRequest(); $id = $request->getQuery('id'); if ($id) { $info = Model_Countries::getCountry($id); } $this->view->page_num = $this->getRequest()->getRequest('page', 1); if ($request->getPost('name')) { $this->view->name = $request->getPost('name'); } elseif (isset($info)) { $this->view->name = $info['name']; } else { $this->view->name = ''; } if ($request->getPost('visible')) { $this->view->visible = $request->getPost('visible'); } elseif (isset($info)) { $this->view->visible = $info['visible']; } else { $this->view->visible = 'true'; } if (isset($info)) { $this->view->photo = $info['photo']; } else { $this->view->photo = ''; } }
private function getForm() { $request = $this->getRequest(); $user_id = $request->getQuery('id'); $url = ''; if ($request->getQuery('sort')) { $url .= '&sort=' . $request->getQuery('sort'); } if ($request->getQuery('order')) { $url .= '&order=' . $request->getQuery('order'); } if ($request->getQuery('page')) { $url .= '&page=' . $request->getQuery('page'); } if ($request->getQuery('filter_id')) { $url .= '&filter_id=' . $request->getQuery('filter_id'); } if ($request->getQuery('filter_username')) { $url .= '&filter_username='******'filter_username'); } if ($request->getQuery('filter_total')) { $url .= '&filter_total=' . $request->getQuery('filter_total'); } if ($request->getQuery('filter_sales')) { $url .= '&filter_sales=' . $request->getQuery('filter_sales'); } if ($request->getQuery('filter_sold')) { $url .= '&filter_sold=' . $request->getQuery('filter_sold'); } if ($request->getQuery('filter_web_profit2')) { $url .= '&filter_web_profit2=' . $request->getQuery('filter_web_profit2'); } if ($request->getQuery('filter_commission')) { $url .= '&filter_commission=' . $request->getQuery('filter_commission'); } if ($request->getQuery('filter_items')) { $url .= '&filter_items=' . $request->getQuery('filter_items'); } if ($request->getQuery('filter_referals')) { $url .= '&filter_referals=' . $request->getQuery('filter_referals'); } if ($request->getQuery('filter_referal_money')) { $url .= '&filter_referal_money=' . $request->getQuery('filter_referal_money'); } if ($request->getQuery('filter_featured_author')) { $url .= '&filter_featured_author=' . $request->getQuery('filter_featured_author'); } $this->view->cancel_href = $this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/users/?' . $url; $model_users = new Model_Users(); if ($user_id) { $user_info = $model_users->getUser($user_id); } if (isset($user_info)) { $this->view->user_id = $user_id; $this->view->username = $user_info['username']; $this->view->names = $user_info['firstname'] . ' ' . $user_info['lastname']; $this->view->email = $user_info['email']; $this->view->exclusive_author = $user_info['exclusive_author']; $model_images = new Model_Images(); $this->view->avatar = $model_images->resize($user_info['avatar'], 80, 80, true); $this->view->profile_title = $user_info['profile_title']; $this->view->profile_desc = $user_info['profile_desc']; $this->view->country_id = $user_info['country_id']; $this->view->author_status = $user_info['author_status']; $this->view->author_status_description = $user_info['author_status_description']; $country_info = Model_Countries::getCountry($user_info['country_id']); if ($country_info) { $this->view->country = $country_info['name']; } $this->view->live_city = $user_info['live_city']; $register_datetime = new JO_Date($user_info['register_datetime'], 'dd MM yy'); $this->view->register_datetime = $register_datetime->toString(); $last_login_datetime = new JO_Date($user_info['last_login_datetime'], 'dd MM yy'); $this->view->last_login_datetime = $last_login_datetime->toString(); $other = Model_Users::getStatistic($user_id); $this->view->deposit = WM_Currency::format($other['deposit']); $this->view->total = WM_Currency::format($other['total']); $this->view->items = array(); foreach ($other['items'] as $item) { $datetime = new JO_Date($item['datetime'], 'dd MM yy'); $this->view->items[] = array('id' => $item['item_id'], 'item_name' => $item['item_name'], 'price' => WM_Currency::format($item['price']), 'href' => WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&item_id=' . $item['item_id']), 'datetime' => $datetime->toString()); } } if ($request->getPost('commission_percent')) { $this->view->commission_percent = $request->getPost('commission_percent'); } elseif (isset($user_info)) { $this->view->commission_percent = $user_info['commission_percent']; } if ($request->getPost('featured_author')) { $this->view->featured_author = $request->getPost('featured_author'); } elseif (isset($user_info)) { $this->view->featured_author = $user_info['featured_author']; } if ($request->getPost('status')) { $this->view->status = $request->getPost('status'); } elseif (isset($user_info)) { $this->view->status = $user_info['status']; } if ($request->getPost('groups')) { $this->view->groups = $request->getPost('groups'); } elseif (isset($user_info)) { $this->view->groups = (array) unserialize($user_info['groups']); } else { $this->view->groups = array(); } if ($request->getPost('badges')) { $this->view->badges = $request->getPost('badges'); } elseif (isset($user_info)) { $this->view->badges = explode(',', $user_info['badges']); } else { $this->view->badges = array(); } $this->view->groups_list = Model_Usergroups::getGroups(); $this->view->badges_list = Model_Badges::getBadges(array('filter_type' => 'other')); }
private function getForm() { $request = $this->getRequest(); $language_id = $request->getQuery('id'); $model_language = new Model_Language(); if ($language_id) { $language_info = $model_language->getLanguage($language_id); } $countrycode = Model_Countries::getCountriesPairs(); $this->view->locale_territories = array(); $locale_territories = JO_Locale::listTerritory(); if ($locale_territories) { $sort_order = array(); foreach ($locale_territories as $iso2 => $lt) { if (isset($countrycode[$iso2])) { $sort_order[$lt] = $countrycode[$iso2]; $this->view->locale_territories[$lt] = array('code' => $lt, 'name' => $countrycode[$iso2]); } else { $sort_order[$lt] = $iso2; $this->view->locale_territories[$lt] = array('code' => $lt, 'name' => $iso2); } } array_multisort($sort_order, SORT_ASC, $this->view->locale_territories); } $this->view->flags = $this->getFlags(); if ($request->getPost('name')) { $this->view->name = $request->getPost('name'); } elseif (isset($language_info)) { $this->view->name = $language_info['name']; } if ($request->getPost('code')) { $this->view->code = $request->getPost('code'); } elseif (isset($language_info)) { $this->view->code = $language_info['code']; } if ($request->getPost('locale')) { $this->view->locale = $request->getPost('locale'); } elseif (isset($language_info)) { $this->view->locale = $language_info['locale']; } if ($request->getPost('locale_territory')) { $this->view->locale_territory = $request->getPost('locale_territory'); } elseif (isset($language_info)) { $this->view->locale_territory = $language_info['locale_territory']; } if ($request->getPost('image')) { $this->view->image = $request->getPost('image'); } elseif (isset($language_info)) { $this->view->image = $language_info['image']; } if ($request->getPost('status')) { $this->view->status = $request->getPost('status'); } elseif (isset($language_info)) { $this->view->status = $language_info['status']; } }
public function editAction() { $request = $this->getRequest(); if (!JO_Session::get('user_id')) { JO_Session::set('msg_error', $this->translate('You must be logged to change your profile')); $redir = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'); if ($request->getRequest('tool') == 'change_avatar') { die(json_encode(array('logout' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=login')))); } else { $this->redirect($redir); } } $this->getLayout()->meta_title = $this->translate('Edit settings'); $this->getLayout()->meta_description = $this->translate('Edit settings'); if (JO_Session::get('msg_success')) { $this->view->msg_success = JO_Session::get('msg_success'); JO_Session::clear('msg_success'); } elseif (JO_Session::get('msg_error')) { $this->view->error = JO_Session::get('msg_error'); JO_Session::clear('msg_error'); } $tool = $request->getRequest('tool'); $username = JO_Session::get('username'); $this->view->user = Model_Users::getByUserName($username); $this->view->author_header = Helper_Author::authorHeader($this->view->user); $this->view->settings_box = Helper_Author::getSettingsBox($tool); $this->view->crumbs = array(array('name' => $this->translate('Home'), 'href' => $request->getBaseUrl()), array('name' => $this->translate('Profile'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'name' => $this->translate('Settings'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=edit'))); switch ($tool) { case 'change_avatar': $image = $request->getFile('file'); if ($image) { $users_path = '/users/' . JO_Date::getInstance(JO_Session::get('register_datetime'), 'yy/mm') . '/' . JO_Session::get('user_id') . '/'; $upload_folder = realpath(BASE_PATH . '/uploads'); $upload_folder .= $users_path; $upload = new JO_Upload(); $upload->setFile($image)->setExtension(array('.jpg', '.jpeg', '.png', '.gif'))->setUploadDir($upload_folder); $new_name = md5(time() . serialize($image)); if ($upload->upload($new_name)) { $info = $upload->getFileInfo(); if ($info) { $file_path = $users_path . $info['name']; $model_images = new Model_Images(); if (JO_Session::get('avatar')) { $model_images->deleteImages(JO_Session::get('avatar'), true); } $thumb = $model_images->resize($file_path, JO_Registry::forceGet('user_avatar_width'), JO_Registry::forceGet('user_avatar_height'), true); Model_Users::editAvatar(JO_Session::get('user_id'), $file_path); die('{ "avatar": "' . $thumb . '", "msg_success": "' . $this->translate('You have successfully changed your avatar') . '"}'); } else { die('{ "msg_error": "' . $this->translate('There was an unexpected error with uploading the file') . '"}'); } } else { die('{ "msg_error": "' . $this->translate('The file must be valid image') . '" }'); } } break; case 'change_password': if ($request->isPost()) { $s = Model_Users::editPassword(JO_Session::get('user_id'), array('password' => $request->getPost('password'), 'new_password' => $request->getPost('new_password'), 'new_password_confirm' => $request->getPost('new_password_confirm'))); if ($s === true) { $this->session->set('msg_success', $this->translate('You have successfully updated your password')); } else { $this->session->set('msg_error', $s); } $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=users&action=edit&tool=change_password')); } $this->view->formtitle = $this->translate('Change your password'); $this->view->crumbs[] = array('name' => $this->view->formtitle); $this->view->author_form = $this->view->renderByModule('single_user/change_password', 'users', 'themes'); break; case 'exclusive_author': if ($request->isPost()) { $exclusive_author = $request->getPost('exclusive_author'); Model_Users::editExclusive(JO_Session::get('user_id'), $exclusive_author); if ($exclusive_author == 'true') { JO_Session::set('msg_success', $this->translate('You have successfully changed to exclusive author')); } else { JO_Session::set('msg_success', $this->translate('You have successfully changed to non exclusive author')); } $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=users&action=edit&tool=exclusive_author')); } if ($this->view->user['exclusive_author'] == 'true') { $this->view->formtitle = $this->translate('Exclusive Author'); $this->view->button = $this->translate('Unsubscribe me as exclusive author'); } else { $this->view->formtitle = $this->translate('Non-Exclusive Author'); $this->view->button = $this->translate('Subscribe me as exclusive author'); } $this->view->top_text = $this->translate('Agreeing to keep your portfolio of items for sale exclusive to the Marketplaces entitles you to a higher percentage of each sale - from 40% to 70%. You can still sell other items elsewhere (on other marketplaces, your own site) however any items you place on an Marketplace must be exclusively sold there.'); $this->view->bottom_text = $this->translate('You can opt-out of the exclusivity program by clicking the button below. You will be given a 30 day grace period wherein the agreement is still observed after which your payments will return to normal and you may commence selling your items elsewhere.'); $this->view->crumbs[] = array('name' => $this->view->formtitle); $this->view->author_form = $this->view->renderByModule('single_user/exclusive_author', 'users', 'themes'); break; case 'sale_license': if ($request->isPost()) { if ($request->getPost('license')) { Model_Users::editLicense(JO_Session::get('user_id'), $request->getPost('license')); JO_Session::set('msg_success', $this->translate('You have successfully changed the license types')); } else { JO_Session::set('msg_error', $this->translate('You have to choose your license')); } $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=users&action=edit&tool=sale_license')); } $this->view->formtitle = $this->translate('Sale License'); $this->view->crumbs[] = array('name' => $this->view->formtitle); $this->view->license = unserialize($this->view->user['license']); $this->view->author_form = $this->view->renderByModule('single_user/sale_license', 'users', 'themes'); break; case 'social': if ($request->issetParam('sn')) { $sn = (int) $request->getParam('sn'); unset($this->view->user['social'][$sn - 1]); $this->view->user['social'] = array_values($this->view->user['social']); Model_Users::editSocial(JO_Session::get('user_id'), $this->view->user['social']); $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=edit&tool=social')); } if ($request->isPost()) { $socials = array(); $errors = array(); $social_links = $request->getPost('social_link'); $social_names = $request->getPost('social_name'); $cnt = count($social_links) < count($social_names) ? count($social_names) : count($social_links); for ($i = 0; $i < $cnt; $i++) { $social_names[$i] = trim($social_names[$i]); $social_links[$i] = trim($social_links[$i]); if (empty($social_names[$i]) && empty($social_links[$i])) { break; } if (empty($social_names[$i])) { $errors[$i]['social_name'] = $this->translate('You must fill the name of the social media'); } if (empty($social_links[$i])) { $errors[$i]['social_link'] = $this->translate('You must fill valid link for your profile'); } $socials[] = array('name' => $social_names[$i], 'href' => $social_links[$i]); } if (empty($errors)) { Model_Users::editSocial(JO_Session::get('user_id'), $socials); JO_Session::set('msg_success', $this->translate('You have successfully changed your social media profiles')); } else { JO_Session::set('msg_error', $errors); $this->session->set('data', $socials); } $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=edit&tool=social')); } if ($this->session->issetKey('data')) { $social = $this->session->get('data'); $this->session->clear('data'); if (count($social) > count($this->view->user['social'])) { $last = end($social); $this->view->new_user = $last['name']; $this->view->new_href = $last['href']; } } $this->view->formtitle = $this->translate('Social Media profiles'); $this->view->crumbs[] = array('name' => $this->view->formtitle); $this->view->author_form = $this->view->renderByModule('single_user/social', 'users', 'themes'); break; default: if ($request->isPost()) { $firstname = trim($request->getPost('firstname')); $lastname = trim($request->getPost('lastname')); $email = trim($request->getPost('email')); if (empty($firstname)) { $error['firstname'] = $this->translate('You must fill your firstname'); } if (empty($lastname)) { $error['lastname'] = $this->translate('You must fill your lastname'); } if (empty($email)) { $error['email'] = $this->translate('You must fill your email'); } elseif (!Model_Users::ValidMail($email)) { $this->view->error['email'] = $this->translate('You must fill valid email'); } if ($request->getPost('facebook') == 1) { if ($this->view->user['fb_id'] == 0) { $facebook = new WM_Facebook_Api(array('appId' => JO_Registry::forceGet('facebook_appid'), 'secret' => JO_Registry::forceGet('facebook_secret'))); $fbData = $facebook->api('/me'); $request->setParams('fb_id', $fbData['id']); } else { $request->setParams('fb_id', $this->view->user['fb_id']); } } else { $request->setParams('fb_id', 0); } if (!count($error)) { Model_Users::editPersonal($this->view->user['user_id'], $request->getParams()); JO_Session::set('msg_success', $this->translate('Your personal data has been successfully saved')); } else { JO_Session::set('msg_error', $error); } $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=edit')); } $this->view->formtitle = $this->translate('Avatar and Personal Information'); $this->view->crumbs[] = array('name' => $this->view->formtitle); $model_images = new Helper_Images(); if ($this->view->user['avatar']) { $thumb = $model_images->resize($this->view->user['avatar'], JO_Registry::forceGet('user_avatar_width'), JO_Registry::forceGet('user_avatar_height'), true); } else { $this->view->user['avatar'] = 'data/themes/images/noavatar.png'; } $this->view->upl_form_action = WM_Router::create($request->getBaseUrl() . '?controller=users&action=edit&tool=change_avatar'); $this->view->countries = Model_Countries::getCountries(); $this->view->author_form = $this->view->renderByModule('single_user/avatar', 'users', 'themes'); } $this->view->children = array(); $this->view->children['header_part'] = 'layout/header_part'; $this->view->children['footer_part'] = 'layout/footer_part'; }
public static function userBadges($user) { $user_badges = array(); if (!$user) { return $user_badges; } $badges_data = Model_Badges::getAllFront(); $other_badges = isset($user['badges']) ? array_map('trim', explode(',', $user['badges'])) : array(); if (isset($user['exclusive_author']) && $user['exclusive_author'] == 'true' && isset($badges_data['system']['is_exclusive_author'])) { if ($badges_data['system']['is_exclusive_author']['photo'] && file_exists("uploads/badges/" . $badges_data['system']['is_exclusive_author']['photo'])) { $user_badges[] = array('name' => $badges_data['system']['is_exclusive_author']['name'], 'photo' => 'uploads/badges/' . $badges_data['system']['is_exclusive_author']['photo']); } } if (isset($user['featured_author']) && $user['featured_author'] == 'true' && isset($badges_data['system']['has_been_featured'])) { if ($badges_data['system']['has_been_featured']['photo'] && file_exists("uploads/badges/" . $badges_data['system']['has_been_featured']['photo'])) { $user_badges[] = array('name' => $badges_data['system']['has_been_featured']['name'], 'photo' => 'uploads/badges/' . $badges_data['system']['has_been_featured']['photo']); } } if (isset($user['statuses']['freefile']) && $user['statuses']['freefile'] && isset($badges_data['system']['has_free_file_month'])) { if ($badges_data['system']['has_free_file_month']['photo'] && file_exists("uploads/badges/" . $badges_data['system']['has_free_file_month']['photo'])) { $user_badges[] = array('name' => $badges_data['system']['has_free_file_month']['name'], 'photo' => 'uploads/badges/' . $badges_data['system']['has_free_file_month']['photo']); } } if (isset($user['statuses']['featured']) && $user['statuses']['featured'] && isset($badges_data['system']['has_had_item_featured'])) { if ($badges_data['system']['has_free_file_month']['photo'] && file_exists("uploads/badges/" . $badges_data['system']['has_had_item_featured']['photo'])) { $user_badges[] = array('name' => $badges_data['system']['has_had_item_featured']['name'], 'photo' => 'uploads/badges/' . $badges_data['system']['has_had_item_featured']['photo']); } } if (isset($user['buy']) && $user['buy'] && isset($badges_data['buyers']) && is_array($badges_data['buyers'])) { foreach ($badges_data['buyers'] as $k => $v) { list($from, $to) = explode('-', $k); if ($from <= $user['buy'] && $to >= $user['buy']) { if ($v['photo'] && file_exists("uploads/badges/" . $v['photo'])) { $user_badges[] = array('name' => $v['name'], 'photo' => 'uploads/badges/' . $v['photo']); } break; } } } if (isset($user['sold']) && $user['sold'] && isset($badges_data['authors']) && is_array($badges_data['authors'])) { foreach ($badges_data['authors'] as $k => $v) { list($from, $to) = explode('-', $k); if ($from <= $user['sold'] && $to >= $user['sold']) { if ($v['photo'] && file_exists("uploads/badges/" . $v['photo'])) { $user_badges[] = array('name' => $v['name'], 'photo' => 'uploads/badges/' . $v['photo']); } break; } } } if (isset($user['referals']) && $user['referals'] && isset($badges_data['referrals']) && is_array($badges_data['referrals'])) { foreach ($badges_data['referrals'] as $k => $v) { list($from, $to) = explode('-', $k); if ($from <= $user['referals'] && $to >= $user['referals']) { if ($v['photo'] && file_exists("uploads/badges/" . $v['photo'])) { $user_badges[] = array('name' => $v['name'], 'photo' => 'uploads/badges/' . $v['photo']); } break; } } } if (isset($badges_data['other']) && is_array($badges_data['other'])) { foreach ($badges_data['other'] as $k => $b) { if (in_array($k, $other_badges) && $b['photo'] && file_exists("uploads/badges/" . $b['photo'])) { $user_badges[] = array('name' => $b['name'], 'photo' => 'uploads/badges/' . $b['photo']); } } } if (isset($user['country_id']) && $user['country_id']) { $country = Model_Countries::get($user['country_id']); if ($country) { $user['country'] = $country; } } if (isset($user['country']['photo']) && $user['country']['photo'] && file_exists("uploads/countries/" . $user['country']['photo'])) { $user_badges[] = array('name' => $user['country']['name'], 'photo' => 'uploads/countries/' . $user['country']['photo']); } elseif (isset($badges_data['system']['location_global_community']) && $badges_data['system']['location_global_community']['photo'] && file_exists("uploads/badges/" . $badges_data['system']['location_global_community']['photo'])) { $user_badges[] = array('name' => $badges_data['system']['location_global_community']['name'], 'photo' => 'uploads/badges/' . $badges_data['system']['location_global_community']['photo']); } return $user_badges; }