public function view() { // Get URI vars $newsID = (int) uri::segment(3); // Get news entry if (!$newsID || !($news = $this->news_model->getEntry($newsID, 'in_view')) || !$news['active']) { error::show404(); } // Do we have views enabled? if (config::item('news_views', 'news')) { // Update views counter $this->news_model->updateViews($newsID); } // Load ratings if (config::item('news_rating', 'news') == 'stars') { // Load votes model loader::model('comments/votes'); // Get votes $news['user_vote'] = $this->votes_model->getVote('news', $newsID); } elseif (config::item('news_rating', 'news') == 'likes') { // Load likes model loader::model('comments/likes'); // Get likes $news['user_vote'] = $this->likes_model->getLike('news', $newsID); } // Assign vars view::assign(array('newsID' => $newsID, 'news' => $news)); // Set title view::setTitle($news['data_title']); // Set meta tags view::setMetaDescription($news['data_meta_description']); view::setMetaKeywords($news['data_meta_keywords']); // Load view view::load('news/view'); }
public function __construct() { parent::__construct(); if (!config::item('news_blog', 'news') && uri::segment(1) != 'news') { router::redirect('news/' . utf8::substr(uri::getURI(), 5)); } }
public function delete() { // Get URI vars $slugID = urldecode(utf8::trim(uri::segment(4))); // Do we have a slug ID? if ($slugID == '') { error::show404(); } // Get user if (!($user = $this->users_model->getUser($slugID)) || !$user['active'] || !$user['verified']) { error::show404(); } elseif ($user['user_id'] == session::item('user_id')) { router::redirect($user['slug']); } // Does user exist? if (!($blocked = $this->users_blocked_model->getUser($user['user_id'], true))) { view::setError(__('no_blocked_user', 'users_blocked')); router::redirect('users/blocked'); } // Delete blocked user $this->users_blocked_model->deleteBlockedUser(session::item('user_id'), $user['user_id']); // Success view::setInfo(__('user_unblocked', 'users_blocked')); router::redirect(input::get('page') ? 'users/blocked' : $user['slug']); }
public function delete() { // Get URI vars $fieldID = (int) uri::segment(7); // Delete custom field $this->deleteField('pages', 'pages_data', 0, $fieldID); }
public function render() { if (!$this->links) { throw new Kohana_User_Exception("Navbar not implemented correctly", "Links have not been set. Please call <code>$navbar->set_links({$links})</code>"); } else { if ($this->view) { return $this->render_to_view($this->view); } else { $html = ""; $i = 0; foreach ($this->links as $link) { $class = ""; if (str_replace("site", "", url::current()) == $link->seoURL || url::current() == $link->seoURL || uri::segment(1) == $link->seoURL) { $class .= "selected"; } if ($i == 0) { $class .= " first"; } if ($i == count($this->links) - 1) { $class .= " last"; } $html .= '<li class="' . $class . '" id="menu0' . ($i + 1) . '"><a href="' . url::site() . $link->seoURL . '" class="' . $class . '">' . $link->title . '</a></li>'; $i++; } # $html .= "</ul>"; return $html; } } }
public function delete() { // Get URI vars $typeID = (int) uri::segment(6); $fieldID = (int) uri::segment(7); $typeID = $typeID == 0 || $typeID == 1 ? $typeID : 0; // Delete custom field $this->deleteField('pictures', 'pictures_' . ($typeID == 1 ? 'albums_' : '') . 'data', $typeID, $fieldID); }
public function click() { $bannerID = (int) uri::segment(3); if ($bannerID && $bannerID > 0) { loader::model('banners/banners'); $this->banners_model->updateClicks($bannerID); } exit; }
public function __construct() { parent::__construct(); $authID = session::item('auth_id'); $userID = session::item('user_id'); $ipaddress = substr(input::ipaddress(), 0, 15); $useragent = substr(input::useragent(), 0, 255); $user = array(); if ($authID && ($user = $this->getSession($authID, $userID, $ipaddress, $useragent))) { if ($user['active_date'] < date_helper::now() - 60 * $this->timeout) { $this->saveSession($authID, $userID, $ipaddress, $useragent); if (isset($user['user_id']) && $user['user_id']) { $this->saveLastvisit($user['user_id']); } } } else { $cookie = cookie::item('sessdata'); $cookie = $cookie ? @json_decode($cookie, true) : array(); if ($cookie && is_array($cookie)) { $userID = isset($cookie['user_id']) ? $cookie['user_id'] : ''; $email = isset($cookie['email']) ? $cookie['email'] : ''; $passhash = isset($cookie['passhash']) ? $cookie['passhash'] : ''; if ($userID && is_numeric($userID) && $userID > 0) { if ($user = $this->getUser($userID, false, false)) { $newPasshash = $this->generatePasshash($email, $user['password']); if ($user['active'] && $user['verified'] && strcmp($email, $user['email']) == 0 && strcmp($passhash, $newPasshash) == 0) { $authID = $this->saveSession(0, $user['user_id'], $ipaddress, $useragent); $this->saveLastvisit($user['user_id']); } else { $user = array(); } } } } } if (!$user || !isset($user['user_id']) || !$user['user_id'] || !$this->createUserSession($user)) { $userID = 0; if (!$user) { $authID = $this->saveSession(0, $userID, $ipaddress, $useragent); } $this->createGuestSession(); } session::set('auth_id', $authID); session::set('user_id', $userID); // Is the site offline? if (!input::isCP() && !config::item('site_online', 'system') && !session::permission('site_access_offline', 'system') && uri::getURI() != 'site/offline' && uri::segment(1) != 'load') { router::redirect('site/offline'); } elseif (input::isCP() && !session::permission('site_access_cp', 'system') && (uri::getURI() != 'cp' && uri::getURI() != 'cp/users/login' && uri::getURI() != 'cp/users/login/license')) { router::redirect('cp/users/login'); } if (!input::isCP() && $this->isLoggedin() && session::permission('site_access_cp', 'system') && uri::segment(1) != 'load' && input::demo(0, '', session::item('user_id'))) { $this->logout(); view::setInfo('For the purposes of this demo you may not use front end of the site under the administrator account. As such we have now logged you out.<br/>Feel free ' . html_helper::anchor('users/signup', 'register on the site') . ' to test user end functionality or ' . html_helper::anchor('users/login', 'login') . ' using your existing account details if you have one already.'); router::redirect(); } }
public function confirm() { $class = uri::segment(4); $action = uri::segment(5) == 'signup' ? 'signup' : 'login'; $service = $this->users_authentication_model->getService($class); if ($service) { loader::library('authentication/' . uri::segment(4), $service['settings'], 'users_authentication_' . $class . '_model'); $this->{'users_authentication_' . $class . '_model'}->confirm($action); } router::redirect('users/login'); }
public function index() { $service = config::item('default_captcha', 'security'); $settings = config::item('default_captcha_settings', 'security'); // Load library $captcha = loader::library('captcha', $settings, null); if (uri::segment(3) == 'reload') { $captcha->create(); } echo $captcha->render(); exit; }
public function delete() { // Get URI vars $typeID = (int) uri::segment(6); $fieldID = (int) uri::segment(7); // Get user type if (!$typeID || !($type = $this->users_types_model->getType($typeID))) { view::setError(__('no_type', 'users_types')); router::redirect('cp/userstypes'); } // Delete profile question $this->deleteField('users', 'users_data_' . $type['keyword'], $typeID, $fieldID); }
public function css() { // echo 123; // exit; $template = strtolower(uri::segment(3)); if ($template != 'cp' && !in_array($template, config::item('templates', 'core', 'keywords'))) { error::show404(); } $output = $this->getStylesheets($template, $template == 'cp' ? true : false); codebreeder::setHeader('Content-Type: text/css'); echo $output; exit; }
public function submit() { // Does user have permission to submit reports? if (!session::permission('reports_post', 'reports')) { view::setError(__('no_action', 'system')); view::load('system/elements/blank', array('autoclose' => true)); return false; } $resource = uri::segment(3); $itemID = uri::segment(4); if (!$resource || !($resourceID = config::item('resources', 'core', $resource, 'resource_id')) || !config::item('resources', 'core', $resource, 'report')) { view::setError(__('resource_invalid', 'system')); view::load('system/elements/blank', array('autoclose' => true)); return false; } if (!$itemID || !is_numeric($itemID) || $itemID < 0) { view::setError(__('item_invalid', 'reports')); view::load('system/elements/blank', array('autoclose' => true)); return false; } // Does this item exist? if (!($userID = $this->reports_model->getUserID($resource, $itemID))) { view::setError(__('item_invalid', 'reports')); view::load('system/elements/blank', array('autoclose' => true)); return false; } // Did we report this already? if ($this->reports_model->isReported($resourceID, $itemID)) { view::setError(__('report_exists', 'reports')); view::load('system/elements/blank', array('autoclose' => true)); return false; } // Get subjects $subjects = array(); $data = $this->reports_subjects_model->getSubjects(false, true); foreach ($data as $subject) { $subjects[$subject['subject_id']] = $subject['name']; } $subjects = $subjects ? array('' => __('select', 'system')) + $subjects : $subjects; // Assign vars view::assign(array('subjects' => $subjects)); // Process form values if (input::post('do_submit_report')) { $this->_submitReport($resource, $resourceID, $userID, $itemID, $subjects); } // Set title view::setTitle(__('report_submit', 'reports')); // Load view view::load('report/index'); }
public function cities() { $stateID = uri::segment(3); $data = array(); if (input::post('title') == 'any') { $data[''] = __('any', 'system', array(), array(), false); } else { $data[''] = __('select', 'system', array(), array(), false); } foreach (geo_helper::getCities($stateID) as $id => $name) { $data[$id . ' '] = $name; } view::ajaxResponse($data); }
public function checkout() { // Get URI vars $planID = (int) uri::segment(4); $gatewayID = uri::segment(5); // Get plan if (!$planID || !($plan = $this->plans_model->getPlan($planID, false)) || !$plan['active']) { view::setError(__('no_plan', 'billing_plans')); router::redirect('billing/plans'); } $retval = $this->process($gatewayID, session::item('user_id'), 'plans', $planID, $plan['name'], $plan['price'], '', 'billing/plans'); if (!$retval) { router::redirect('billing/plans/payment/' . $planID); } }
public function checkout() { // Get URI vars $packageID = (int) uri::segment(4); $gatewayID = uri::segment(5); // Get package if (!$packageID || !($package = $this->credits_model->getPackage($packageID)) || !$package['active']) { view::setError(__('no_package', 'billing_credits')); router::redirect('billing/credits'); } // Set package name $name = __('credits_info', 'billing_credits', array('%s' => $package['credits'])); $retval = $this->process($gatewayID, session::item('user_id'), 'credits', $packageID, $name, $package['price'], '', 'billing/credits'); if (!$retval) { router::redirect('billing/credits/payment/' . $packageID); } }
public function run() { $shash = uri::segment(3); // Verify security string if (!$shash || strcmp($shash, config::item('cron_shash', 'system')) !== 0) { error::show('Invalid security string.'); } if (strcmp(config::item('cron_last_run', 'system'), date('Ymd', date_helper::now())) === 0) { error::show('You may run this file only once per day.'); } // Action hook hook::action('cron/run'); echo "Performed tasks:<br/>"; echo implode(" <br/>\n", $this->cron_model->getLog()); $this->cron_model->finalize(); exit; }
public function usersSettingsAccountOptions($settings, $user = array()) { if (input::isCP()) { if (uri::segment(3) == 'edit') { loader::helper('array'); $expiration = array('name' => __('expire_date', 'users_account'), 'keyword' => 'expire_date', 'type' => 'date', 'value' => $user ? $user['expire_date'] : 0, 'rules' => array('valid_date'), 'select' => true); $credits = array('name' => __('credits_current', 'users_account'), 'keyword' => 'total_credits', 'type' => 'number', 'value' => $user ? $user['total_credits'] : 0, 'rules' => array('required' => 1, 'min_value' => 0)); $settings = array_helper::spliceArray($settings, 'group_id', $credits, 'total_credits'); $settings = array_helper::spliceArray($settings, 'group_id', $expiration, 'expire_date'); } } else { if (config::item('subscriptions_active', 'billing')) { $settings['subscription'] = array('name' => __('plan_current', 'users_account'), 'keyword' => 'subscription', 'type' => 'static', 'value' => config::item('usergroups', 'core', session::item('group_id')) . (session::item('expire_date') ? ' (' . __('expire_date', 'users_account') . ': ' . date_helper::formatDate(session::item('expire_date'), 'date') . ')' : '') . (session::permission('plans_purchase', 'billing') ? ' - ' . html_helper::anchor('billing/plans', __('plan_change', 'users_account')) : '')); } if (config::item('credits_active', 'billing')) { $settings['credits'] = array('name' => __('credits_current', 'users_account'), 'keyword' => 'subscription', 'type' => 'static', 'value' => session::item('total_credits') . (session::permission('credits_purchase', 'billing') ? ' - ' . html_helper::anchor('billing/credits', __('credits_purchase', 'users_account')) : '')); } } return $settings; }
public function edit() { // Get URI vars $plugin = uri::segment(5, 'system'); // Assign vars view::assign(array('plugin' => $plugin)); // Does plugin exist? if (!config::item('plugins', 'core', $plugin)) { view::setError(__('no_config_plugin', 'system_config')); router::redirect('cp/system/config/' . $plugin); } // Get meta tags if (!($tags = $this->metatags_model->getMetaTags($plugin))) { view::setError(__('no_meta_tags', 'system_metatags')); router::redirect('cp/system/config/' . $plugin); } // Process form values if (input::post('do_save_meta_tags')) { $this->_saveMetaTags($plugin, $tags); } // Assign vars view::assign(array('tags' => $tags)); // Set title view::setTitle(__('system_meta_tags_manage', 'system_navigation')); // Set trail view::setTrail('cp/system/metatags/edit/' . $plugin, text_helper::entities(config::item('plugins', 'core', $plugin, 'name'))); // Set actions if (count(config::item('languages', 'core', 'keywords')) > 1) { view::setAction('translate', ''); } // Set tabs foreach ($tags as $keyword => $group) { view::setTab('#' . $keyword, __($keyword, $plugin . '_metatags'), array('class' => 'group_' . $keyword)); } // Load view view::load('cp/system/metatags/edit'); }
public function update() { // Get URI vars $plugin = uri::segment(5); // Get plugins if (!($plugins = $this->recalculate_model->getPlugins())) { view::setInfo(__('no_plugins', 'system_plugins')); router::redirect('cp/system/config/system'); } // Get captcha if (!$plugin || !isset($plugins[$plugin])) { view::setError(__('no_plugin', 'utilities_counters')); router::redirect('cp/utilities/counters'); } // Load plugin model $model = loader::model($plugin . '/' . $plugin, array(), null); // Update counters $result = $model->updateDbCounters(); // Do we have redirect uri? if (isset($result['output']) && isset($result['redirect'])) { $result['redirect'] = $result['redirect'] ? 'update/' . $plugin . '/' . $result['redirect'] : ''; $result['output'] .= '<br/>' . __('progress_redirect', 'utilities_counters', array(), array('%' => html_helper::anchor('cp/utilities/counters/' . $result['redirect'], '\\1'))); if (!$result['redirect']) { view::setInfo(__('progress_done', 'utilities_counters', array('%1' => $plugins[$plugin]))); } // Assign vars view::assign(array('output' => $result['output'], 'redirect' => $result['redirect'])); if (input::isAjaxRequest()) { view::ajaxResponse(array('output' => $result['output'], 'redirect' => $result['redirect'])); } } // Set title view::setTitle(__('utilities_counters_manage', 'system_navigation') . ' - ' . $plugins[$plugin]); // Load view view::load('cp/utilities/counters/update'); }
/** * Get data and display feed * * @param string $description - For top of feed * @return void * @author Dan Chadwick */ function index($description = null) { $model = steamcore::get_controls_model($this->uri->segment(2)); $tbl = $model->table_name; //Set limit $limit = uri::segment(3, Kohana::config('rss.limit')); //Limit the number of feed items by adding a third segment to the url if ($limit == -1) { $limit = null; } /* Set filter * Filters can be added to the rss string like so: ?filter_[filter_field_name]=[filter_value] */ $get = Kohana::instance()->input->get(); foreach ($get as $key => $filter_value) { if (strstr($key, 'filter_')) { $filter_column = substr($key, 7, strlen($key) - 7); $model->like($filter_column, $filter_value); } } $model->orderby(array('date_added' => 'desc')); $result = $model->find_all($limit); $v = Kohana::find_file('views', 'rss/' . $tbl) ? $tbl : 'feed-view'; // You can use a new rss view (named after the table) for specific tables if differnet fields are to be displayed $p = new View('rss/' . $v); header('Content-type: application/rss+xml'); $link = $tbl != 'pages' ? $tbl . '/' : ''; $p->set('description', $description); $p->set('link_data', 'page/' . $link); $p->set('feed_data', $result); try { $p->render(TRUE); } catch (Exception $ex) { throw new Kohana_Exception('debug', 'Rss error'); } }
public function ipn() { // Get URI vars $gatewayID = uri::segment(4); // Get gateway if (!$gatewayID || !($gateway = $this->gateways_model->getGateway($gatewayID)) || !$gateway['active']) { die(__('no_gateway', 'billing_gateways')); } // Update gateway ID $gatewayID = $gateway['gateway_id']; // Load payment library $payment = loader::library('payments/' . $gateway['keyword'], $gateway['settings'], null); // Run IPN function if (!($invoice = $payment->validatePayment($gatewayID))) { $this->transactions_model->saveLog(0, $gatewayID, 0, $payment->getError()); die($payment->getError()); } // Save transaction if ($transactionID = $this->transactions_model->saveTransaction(0, $gatewayID, $invoice['invoice_id'], $invoice['receipt_id'], $invoice['user_id'], $invoice['amount'])) { // Mark invoice as paid $this->transactions_model->payInvoice($invoice['invoice_id'], $invoice['user_id'], $invoice['amount']); } // Get payment type if (!($type = $this->payments_model->getPaymentType($invoice['type_id']))) { return false; } // Load payment type model $product = loader::model('billing/' . $type['keyword'], array(), null); // Setup product $product->process($invoice['user_id'], $invoice['product_id'], $invoice['params']); // Run complete function $payment->completePayment(); // Log transaction $logID = $this->transactions_model->saveLog(0, $gatewayID, 1); die('ok'); }
public function getCities($stateID = false, $return = false, $multilang = false) { $stateID = $stateID ? $stateID : uri::segment(3); $output = array(); $result = $this->db->query("SELECT * FROM `:prefix:geo_cities` WHERE `state_id`=? ORDER BY `name` ASC", array($stateID))->result(); foreach ($result as $row) { if ($multilang) { $output[$row['city_id']] = $row; } else { $output[$row['city_id']] = $row['name']; } } if ($return) { return $output; } else { echo json_encode($output); exit; } }
public function action($action, $actionID = false) { // Check if demo mode is enabled if (input::demo(1, 'cp/users')) { return false; } // Get URI vars $userID = $actionID ? $actionID : (int) uri::segment(4); // Get user if (!$userID || !($user = $this->users_model->getUser($userID))) { view::setError(__('no_user', 'users')); router::redirect('cp/users'); } // Make sure we're not trying to decline ourselves if ($userID != session::item('user_id')) { switch ($action) { case 'approve': case 'approve_email': if ($this->users_model->toggleUserStatus($userID, $user, 1) && $action == 'approve_email') { loader::library('email'); $this->email->sendTemplate('users_account_welcome', $user['email'], $user, $user['language_id']); } $str = __('user_approved', 'users'); break; case 'decline': case 'decline_email': if ($this->users_model->toggleUserStatus($userID, $user, 0) && $action == 'decline_email') { loader::library('email'); $this->email->sendTemplate('users_account_declined', $user['email'], $user, $user['language_id']); } $str = __('user_declined', 'users'); break; case 'verify': $this->users_model->toggleVerifiedStatus($userID, $user, 1); $str = __('user_verified', 'users'); break; case 'unverify': $this->users_model->toggleVerifiedStatus($userID, $user, 0); $str = __('user_unverified', 'users'); break; case 'delete': $this->users_model->deleteUser($userID, $user); $str = __('user_deleted', 'users'); break; } } else { $str = ''; } // Is this an action call? if ($actionID) { return; } // Process query string $qstring = $this->parseQuerystring(); // Success view::setInfo($str); router::redirect('cp/users?' . $qstring['url'] . 'page=' . $qstring['page']); }
protected function parseCounters($params = array(), $type = 'index') { // Assign vars view::assign(array('filters' => array(), 'values' => array())); // Do we have permission to search? if (session::permission('albums_search', 'pictures')) { // Get fields $filters = $this->fields_model->getFields('pictures', 1, 'edit', 'in_search', true); // Set extra fields $filters[] = array('name' => __('search_keyword', 'system'), 'type' => 'text', 'keyword' => 'q'); // Assign vars view::assign(array('filters' => $filters)); // Did user submit the filter form? if (input::post_get('do_search') && session::permission('albums_search', 'pictures')) { $values = array(); $params['total'] = $params['max'] = 0; // Check extra keyword $keyword = utf8::trim(input::post_get('q')); if ($keyword) { $params['join_columns'][] = $this->search_model->prepareValue($keyword, 'a', array('data_title', 'data_description')); $values['q'] = $keyword; } // Search albums $searchID = $this->search_model->searchData('picture_album', $filters, $params['join_columns'], $values); // Do we have any search terms? if ($searchID == 'no_terms') { view::setError(__('search_no_terms', 'system')); } elseif ($searchID == 'no_results') { view::setError(__('search_no_results', 'system')); return $params; } else { switch ($type) { case 'user': router::redirect('pictures/user/' . uri::segment(4) . '?search_id=' . $searchID); break; case 'manage': router::redirect('pictures/manage?search_id=' . $searchID); break; default: router::redirect('pictures?search_id=' . $searchID); break; } } } // Do we have a search ID? if (!input::post_get('do_search') && input::get('search_id')) { // Get search if (!($search = $this->search_model->getSearch(input::get('search_id')))) { view::setError(__('search_expired', 'system')); switch ($type) { case 'user': router::redirect('pictures/user/' . uri::segment(4)); break; case 'manage': router::redirect('pictures/manage'); break; default: router::redirect('pictures'); break; } } // Set results $params['join_columns'] = $search['conditions']['columns']; $params['join_items'] = $search['conditions']['items']; $params['values'] = $search['values']; $params['total'] = $search['results']; $params['max'] = config::item('max_search_results', 'system') && config::item('max_search_results', 'system') < $params['total'] ? config::item('max_search_results', 'system') : $params['total']; // Assign vars view::assign(array('values' => $search['values'])); } } if (!input::get('search_id')) { // Count albums if ($type == 'manage' && !$params['total'] || $type != 'manage' && !($params['total'] = $this->counters_model->countData('picture_album', 0, 0, $params['join_columns'], $params['join_items'], $params))) { if ($type == 'manage') { view::setInfo(__('no_albums_self', 'pictures')); } else { view::setInfo(__('no_albums', 'pictures')); } } $params['max'] = $params['total']; } return $params; }
public function translate() { // Get URI vars $plugin = uri::segment(5); $language = uri::segment(6); // Get plugin if (!config::item('plugins', 'core', $plugin)) { view::setError(__('no_plugin', 'system_plugins')); router::redirect('cp/system/languages/plugins/' . $language); } // Is this a system language? if ($language == 'system') { $language = array('keyword' => 'system', 'name' => 'System'); } elseif (!($language = $this->languages_model->getLanguage($language))) { view::setError(__('no_language', 'system_languages')); router::redirect('cp/system/languages'); } // Get default language data if (!($default = $this->languages_model->getLanguageData('system', $plugin))) { view::setError(__('no_language', 'system_languages')); router::redirect('cp/system/languages'); } // Get language data if (!($data = $this->languages_model->getLanguageData($language['keyword'], $plugin, true))) { view::setError(__('no_language', 'system_languages')); router::redirect('cp/system/languages'); } // Set language sections $sections = array(); foreach ($data as $section => $groups) { foreach ($groups as $group => $types) { $translated = $total = 0; foreach ($types as $type => $items) { foreach ($items as $index => $value) { if (utf8::strcasecmp($default[$section][$group][$type][$index], $value)) { $translated++; } $total++; } } $translated = $translated ? round($translated / $total * 100) : 0; $translated = $translated > 100 ? 100 : $translated; if (__('language_' . $group, $plugin . '_config') !== false) { $name = __('language_' . $group, $plugin . '_config'); } elseif (__('language_' . $group, 'users_config') !== false) { $name = __('language_' . $group, 'users_config'); } elseif (__('language_' . $group, 'system_config') !== false) { $name = __('language_' . $group, 'system_config'); } elseif ($section == $group) { $name = __('language_system', 'system_config'); } else { $name = '!' . $group; } $sections[$section . '_' . $group] = '[' . config::item('plugins', 'core', $section, 'name') . '] ' . $name . ($language['keyword'] != 'english' ? ' - ' . $translated . '%' : '') . (config::item('devmode', 'system') == 2 ? ' [' . $group . ']' : ''); } } asort($sections); // Assign vars view::assign(array('plugin' => $plugin, 'default' => $default, 'sections' => $sections, 'language' => $data)); // Process form values if (input::post('do_save_language')) { $this->_saveLanguageData($plugin, $language['keyword'], $default); } // Set title view::setTitle(__('language_translate', 'system_languages')); // Set trail view::setTrail('cp/system/languages/plugins/' . $language['keyword'], __('language_translate', 'system_languages') . ' - ' . text_helper::entities($language['name'])); view::setTrail('cp/system/languages/translate/' . $plugin . '/' . $language['keyword'], text_helper::entities(config::item('plugins', 'core', $plugin, 'name'))); // Load view view::load('cp/system/languages/translate'); }
public function delete() { // Check if demo mode is enabled if (input::demo(1, 'cp/plugins/messages/templates')) { return false; } // Get URI vars $templateID = (int) uri::segment(6); // Get template if (!$templateID || !($template = $this->messages_templates_model->getTemplate($templateID))) { view::setError(__('no_template', 'messages_templates')); router::redirect('cp/plugins/messages/templates'); } // Delete template $this->messages_templates_model->deleteTemplate($templateID, $template); // Success view::setInfo(__('template_deleted', 'messages_templates')); router::redirect('cp/plugins/messages/templates'); }
public function addGnG() { if (request::method() == 'post') { if (is_numeric($product_id = uri::segment(3))) { $product = ORM::factory('product')->find($product_id); if ($product->id == 0) { url::redirect('/products'); } } $totalAmount = $_POST['bags']; $coinUnitPrice = $product->getUnitPriceForAmount($totalAmount); //create basket for Grab And Go $basket = ORM::factory('orders_basket'); $basket->product_id = $product->id; $basket->foil_id = $product->foil_id; $basket->flavor_id = $product->flavor_id; $basket->style_id = 1; $basket->order_id = ORM::factory('order')->getCurrentOrder()->id; $basket->save(); //set product qty and rate $basket->qty = $totalAmount; $basket->rate = $coinUnitPrice->price; $basket->subtotal = $totalAmount * $basket->rate; $basket->save(); //options if (isset($_POST['options'])) { foreach ($_POST['options'] as $option_id => $value) { $ob_gngo = ORM::factory('orders_baskets_gngoption'); $ob_gngo->orders_basket_id = $basket->id; $ob_gngo->name = ORM::factory('gngoption', $option_id)->name; $ob_gngo->value = $value; $ob_gngo->save(); } } url::redirect('/shopping_cart'); } else { url::redirect('/products'); } }
public function toggle() { // Get URI vars $templateID = (int) uri::segment(5); // Get template if (!$templateID || !($template = $this->emailtemplates_model->getTemplate($templateID))) { view::setError(__('no_template', 'system_email_templates')); router::redirect('cp/system/config/system'); } $this->emailtemplates_model->toggleStatus($templateID, $template); router::redirect('cp/system/emailtemplates/browse/' . text_helper::entities(config::item('plugins', 'core', $template['plugin'], 'keyword'))); }
public function order_again() { $id = uri::segment(3); $prevorder = ORM::factory('order', $id); if ($prevorder->id == 0 || $prevorder->user_id != User_Model::logged_user()->id || $prevorder->site_id != self::getCurrentSite()->id) { url::redirect('/customers/my_account'); } $order = ORM::factory('order')->getCurrentOrder(); $_has_fee = FALSE; foreach ($prevorder->orders_baskets as $prevorders_basket) { //basic orders_basket $orders_basket = $prevorders_basket->cloneThis(); $orders_basket->order_id = $order->id; $orders_basket->save(); if ($orders_basket->second_side_fee != 0) { $_has_fee = $orders_basket->id; } //orders_baskets_images foreach ($prevorders_basket->orders_baskets_images as $prev) { $new = $prev->cloneThis(); $new->orders_basket_id = $orders_basket->id; $new->save(); } //orders_baskets_texts foreach ($prevorders_basket->orders_baskets_texts as $prev) { $new = $prev->cloneThis(); $new->orders_basket_id = $orders_basket->id; $new->save(); } //orders_baskets_datas foreach ($prevorders_basket->orders_baskets_datas as $prev) { $new = $prev->cloneThis(); $new->orders_basket_id = $orders_basket->id; $new->save(); } } if (FALSE !== $_has_fee) { foreach ($order->orders_baskets as $orders_basket) { if ($orders_basket->id != $_has_fee) { $orders_basket->basket_with_fee = $_has_fee; $orders_basket->save(); } } } url::redirect('/shopping_cart'); }