示例#1
0
 protected function _savePackage($packageID)
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Create rules
     $rules = array('credits' => array('label' => __('credits', 'billing_credits'), 'rules' => array('trim', 'required', 'is_natural_no_zero')), 'price' => array('label' => __('price', 'billing'), 'rules' => array('trim', 'required', 'numeric')), 'active' => array('label' => __('active', 'system'), 'rules' => array('trim', 'required', 'intval')));
     // Assign rules
     validate::setRules($rules);
     // Validate fields
     if (!validate::run()) {
         return false;
     }
     // Get post data
     $package = input::post(array('credits', 'price', 'active'));
     // Save banner group
     if (!($packageID = $this->credits_model->savePackage($packageID, $package))) {
         view::setError(__('save_error', 'system'));
         return false;
     }
     // Success
     view::setInfo(__('package_saved', 'billing_credits'));
     router::redirect('cp/billing/credits/edit/' . $packageID);
 }
示例#2
0
 protected function _sendFeedback()
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Extra rules
     $rules = array('name' => array('rules' => array('required', 'is_string', 'trim', 'min_length' => 2, 'max_length' => 255)), 'email' => array('rules' => array('required', 'is_string', 'trim', 'valid_email', 'min_length' => 4, 'max_length' => 255)), 'subject' => array('rules' => array('required', 'is_string', 'trim', 'min_length' => 5, 'max_length' => 255)), 'message' => array('rules' => array('required', 'is_string', 'trim', 'min_length' => 10, 'max_length' => 10000)));
     if (config::item('feedback_captcha', 'feedback') == 1 || config::item('feedback_captcha', 'feedback') == 2 && !users_helper::isLoggedin()) {
         $rules['captcha'] = array('rules' => array('is_captcha'));
     }
     validate::setRules($rules);
     // Validate form values
     if (!validate::run($rules)) {
         return false;
     }
     // Get values
     $email = input::post('email');
     $subject = input::post('subject');
     $message = input::post('message') . "\n\n--\n" . input::post('name') . ' <' . input::post('email') . '>' . "\n" . input::ipaddress();
     // Send feedback
     if (!$this->feedback_model->sendFeedback($email, $subject, $message)) {
         if (!validate::getTotalErrors()) {
             view::setError(__('send_error', 'system'));
         }
         return false;
     }
     // Success
     view::setInfo(__('message_sent', 'feedback'));
     router::redirect('feedback');
 }
示例#3
0
 public function action_SearchResults()
 {
     //ドロップダウンの値呼び出し
     $this->action_categorize();
     //もし入力されたら
     if (Input::post()) {
         //バリデーション
         $val = Validation::forge();
         $val->add_field('username', 'ユーザID', 'max_length[255]');
         $val->add_field('Title', 'タイトル', 'max_length[255]');
         $val->add_field('Pcontent', '内容', 'max_length[255]');
         $val->add_field('category', 'カテゴリ', 'required');
         $val->add_field('Syear', '開始年', 'required');
         $val->add_field('Smonth', '開始月', 'required');
         $val->add_field('Sday', '開始日', 'required');
         $val->add_field('Eyear', '終了年', 'required');
         $val->add_field('Emonth', '終了月', 'required');
         $val->add_field('Eday', '終了日', 'required');
         //バリデーション起動
         if ($val->run()) {
             //バリデーションOK
             //入力内容の取得
             $username = Input::post('username');
             $title = Input::post('Title');
             $Pcontent = Input::post('Pcontent');
             $category = Input::post('category');
             $Syear = Input::post('Syear');
             $Smonth = Input::post('Smonth');
             $Sday = input::post('Sday');
             $Eyear = Input::post('Eyear');
             $Emonth = Input::post('Emonth');
             $Eday = input::post('Eday');
             //セッションにセット
             Session::set('user', $username);
             Session::set('Title', $title);
             Session::set('Pcontent', $Pcontent);
             Session::set('category', $category);
             Session::set('Syear', $Syear);
             Session::set('Smonth', $Smonth);
             Session::set('Sday', $Sday);
             Session::set('Eyear', $Eyear);
             Session::set('Emonth', $Emonth);
             Session::set('Eday', $Eday);
             //検索処理呼び出し
             //                $kensaku = $this->action_kensaku();
             //ビューにセット
             $view = View::forge('search/SearchResults', $this->action_kensaku($username, $title, $Pcontent, $category, $Syear, $Smonth, $Sday, $Eyear, $Emonth, $Eday));
         } else {
             //バリデーションエラー
             $this->message = $val->error();
             $view = View::forge('search/Search', $this->action_categorize());
             $view->set_global('message', $this->message, false);
         }
     } else {
         $view = View::forge('search/Search', $this->action_categorize());
         $view->set_global('message', $this->message, false);
     }
     return $view;
 }
示例#4
0
文件: ksetup.php 项目: rev087/kennel
 public function login()
 {
     if (input::post('username') && input::post('password') && auth::login(input::post('username'), input::post('password'), self::AUTH_REALM)) {
         $this->index();
     } else {
         return $this->access_denied();
     }
 }
示例#5
0
 public function action_myform()
 {
     $fieldset = \fieldset::forge('form');
     $fieldset->add('title', 'title', array('maxlength' => 50), array(array('required')));
     if (\input::post()) {
         echo \input::post('title');
     }
     return \Response::forge($fieldset);
 }
示例#6
0
 protected function _savePluginSettings($keyword, $value)
 {
     // Toggle classifieds
     if ($keyword == 'classifieds_active') {
         loader::model('system/lists');
         $this->lists_model->toggleItemStatus('classifieds', 'site_user_nav', 'user/classifieds', $value);
     } elseif ($keyword == 'ads_gallery') {
         loader::model('system/lists');
         $this->lists_model->toggleItemStatus('classifieds', 'site_top_nav', 'site/classifieds', input::post('classifieds_active') && $value ? 1 : 0);
     }
 }
示例#7
0
文件: geo.php 项目: soremi/tutornavi
 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);
 }
示例#8
0
 public function validatePayment($gatewayID)
 {
     // Verify payment status
     if (strtolower(input::post('payment_status')) != 'completed' || strtolower(input::post('txn_type')) != 'web_accept') {
         $this->setError('Invalid payment status.');
         return false;
     }
     // Verify receiver's email
     if (strcasecmp($this->config['email'], input::post('business')) || strcasecmp($this->config['email'], input::post('receiver_email'))) {
         $this->setError('Invalid receiver email.');
         return false;
     }
     // Load http library
     loader::library('http');
     // Set parameters
     $params = $_POST;
     $params['cmd'] = '_notify-validate';
     // Run paypal request
     $response = $this->http->run($this->config['test'] ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', 'POST', $params);
     // Verify reponse
     if (strcasecmp(trim($response), 'verified')) {
         $this->setError('Invalid response: ' . $response);
         return false;
     }
     // Get parameters
     $receiptID = input::post('txn_id');
     $invoiceID = input::post('item_number');
     $amount = input::post('mc_gross');
     $currency = input::post('mc_currency');
     // Verify duplicates
     if (!$this->transactions_model->isUniqueTransaction($gatewayID, $receiptID)) {
         $this->setError('Duplicate transaction: ' . $receiptID);
         return false;
     }
     // Get invoice
     if (!($invoice = $this->transactions_model->getInvoice($invoiceID))) {
         $this->setError('Invalid invoice ID: ' . $invoiceID);
         return false;
     }
     // Verify amount
     if (strcmp($invoice['amount'], $amount)) {
         $this->setError('Invalid payment amount: ' . money_helper::symbol(config::item('currency', 'billing')) . $amount);
         return false;
     }
     $invoice['receipt_id'] = $receiptID;
     return $invoice;
 }
示例#9
0
 public function browse()
 {
     // Parameters
     $params = array('join_columns' => array("`u`.`picture_id`!=0"), 'join_items' => array());
     // Process filters
     $params = $this->parseCounters($params, 0);
     // Process query string
     $qstring = $this->parseQuerystring($params['total']);
     // Actions
     $actions = array(0 => __('select', 'system'), 'approve' => __('approve', 'system'), 'decline' => __('decline', 'system'), 'delete' => __('delete', 'system'));
     // Check form action
     if (input::post('do_action')) {
         // Delete selected albums
         if (input::post('action') && isset($actions[input::post('action')]) && input::post('user_id') && is_array(input::post('user_id'))) {
             foreach (input::post('user_id') as $userID) {
                 $userID = (int) $userID;
                 if ($userID && $userID > 0) {
                     $this->action(input::post('action'), $userID);
                 }
             }
         }
         // Success
         view::setInfo(__('action_applied', 'system'));
         router::redirect('cp/users/pictures/browse?' . $qstring['url'] . 'page=' . $qstring['page']);
     }
     // Get pictures
     $users = array();
     if ($params['total']) {
         $users = $this->users_model->getUsers('in_list', isset($params['values']['type']) ? $params['values']['type'] : 0, $params['join_columns'], $params['join_items'], $qstring['order'], $qstring['limit']);
     }
     // Set pagination
     $config = array('base_url' => config::siteURL('cp/users/pictures/browse?' . $qstring['url']), 'total_items' => $params['total'], 'items_per_page' => $this->picturesPerPage, 'current_page' => $qstring['page'], 'uri_segment' => 'page');
     $pagination = loader::library('pagination', $config, null);
     // Assign vars
     view::assign(array('users' => $users, 'pagination' => $pagination, 'actions' => $actions));
     // Set title
     view::setTitle(__('users_pictures_manage', 'system_navigation'));
     // Set trail
     if ($qstring['search_id']) {
         view::setTrail('cp/users/pictures/browse?' . $qstring['url'] . 'page=' . $qstring['page'], __('search_results', 'system'));
     }
     // Assign actions
     view::setAction('#', __('search', 'system'), array('class' => 'icon-text icon-system-search', 'onclick' => '$(\'#pictures-search\').toggle();return false;'));
     // Load view
     view::load('cp/users/pictures/browse');
 }
示例#10
0
 protected function _submitReport($resource, $resourceID, $userID, $itemID, $subjects)
 {
     // Extra rules
     $rules = array('subject' => array('rules' => $subjects ? array('required', 'callback__is_valid_subject' => array($subjects)) : array('callback__is_valid_subject' => array($subjects))), 'message' => array('rules' => array('is_string', 'trim', 'max_length' => 255)));
     validate::setRules($rules);
     // Validate form values
     if (!validate::run($rules)) {
         return false;
     }
     // Get values
     $subject = $subjects ? (int) input::post('subject') : 0;
     $message = input::post('message');
     // Send feedback
     if (!$this->reports_model->saveReport($resourceID, $userID, $itemID, $subject, $message)) {
         if (!validate::getTotalErrors()) {
             view::setError(__('save_error', 'system'));
         }
         return false;
     }
     // Success
     router::redirect('report/sent' . (input::get('modal') ? '?modal=1' : ''));
 }
示例#11
0
 protected function _saveComment($resource, $itemID)
 {
     // Is user logged in?
     if (!users_helper::isLoggedin()) {
         return false;
     }
     // Create rules
     $rules = array('comment' => array('label' => __('comment_body', 'comments'), 'rules' => array('trim', 'required', 'min_length' => config::item('min_length', 'comments'), 'max_length' => config::item('max_length', 'comments'), 'callback__is_comments_delay')));
     // Assign rules
     validate::setRules($rules);
     // Validate fields
     if (!validate::run()) {
         return false;
     }
     // Get comment
     $comment = array('comment' => input::post('comment'));
     // Get table and column names
     $table = config::item('resources', 'core', $resource, 'table');
     $column = config::item('resources', 'core', $resource, 'column');
     $user = config::item('resources', 'core', $resource, 'user');
     // Get resource item
     $item = $this->db->query("SELECT `" . $column . "` " . ($user ? ', `' . $user . '` AS `user_id`' : '') . "\n\t\t\tFROM `:prefix:" . $table . "`\n\t\t\tWHERE `" . $column . "`=? LIMIT 1", array($itemID))->row();
     // Does resource exist?
     if (!$item) {
         return false;
     }
     // Save comment
     if (!$this->comments_model->saveComment(0, $comment, $resource, isset($item['user_id']) ? $item['user_id'] : 0, $itemID)) {
         if (!validate::getTotalErrors()) {
             view::setError(__('save_error', 'system'));
         }
         return false;
     }
     // Reset post values
     $_POST['comment'] = '';
     validate::resetRules();
     return true;
 }
示例#12
0
 protected function _savePage($pageID, $parentID, $page, $fields, $options, $trail)
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Extra rules
     $rules = array();
     foreach ($options as $option) {
         if (isset($option['rules'])) {
             $rules[$option['keyword']] = array('label' => $option['name'], 'rules' => $option['rules']);
         }
     }
     $rules['keyword'] = array('label' => __('keyword', 'system'), 'rules' => array('trim', 'required', 'max_length' => 128, 'callback__is_valid_keyword' => array($parentID, $pageID)));
     // Validate form values
     if (!$this->fields_model->validateValues($fields, $rules)) {
         return false;
     }
     // Did keyword change?
     if ($pageID && $page['system'] && strcmp($page['keyword'], input::post('keyword'))) {
         validate::setFieldError('keyword', __('page_system_rename', 'pages'));
         return false;
     }
     // Extras
     $extra = array();
     $extra['parent_id'] = $parentID;
     $extra['location'] = ($trail ? implode('/', $trail) . '/' : '') . input::post('keyword');
     $extra['keyword'] = input::post('keyword');
     $extra['file_name'] = input::post('file_name');
     $extra['comments'] = config::item('page_comments', 'pages') ? (int) input::post('comments') : 1;
     $extra['likes'] = config::item('page_rating', 'pages') == 'likes' ? (int) input::post('likes') : 1;
     $extra['votes'] = config::item('page_rating', 'pages') == 'stars' ? (int) input::post('votes') : 1;
     $extra['trail'] = (int) input::post('trail');
     $extra['active'] = (int) input::post('active');
     // Save page
     if (!($pageID = $this->pages_model->savePageData($pageID, $parentID, $page, $fields, $extra))) {
         if (!validate::getTotalErrors()) {
             view::setError(__('save_error', 'system'));
         }
         return false;
     }
     // Success
     view::setInfo(__('page_saved', 'pages'));
     router::redirect('cp/content/pages/edit/' . $parentID . '/' . $pageID);
 }
示例#13
0
 public function recipients()
 {
     // Get URI vars
     $newsletterID = (int) uri::segment(5);
     // Get newsletter
     if (!$newsletterID || !($newsletter = $this->newsletters_model->getNewsletter($newsletterID, false))) {
         view::setError(__('no_newsletter', 'newsletters'));
         router::redirect('cp/content/newsletters');
     }
     // Do we need to display recipients?
     if (uri::segment(6) == 'view' && isset($newsletter['params']['conditions'])) {
         // Search users
         $searchID = $this->search_model->searchData('profile', array(), $newsletter['params']['conditions'], $newsletter['params']['values'], array('type_id' => isset($newsletter['params']['values']['type_id']) ? $newsletter['params']['values']['type_id'] : 0));
         // Do we have any search terms?
         if ($searchID != 'no_terms' && $searchID != 'no_results' && ($search = $this->search_model->getSearch($searchID))) {
             // Did total user count change?
             if ($search['results'] != $newsletter['total_users']) {
                 $newsletter = array('total_users' => $search['results']);
                 $this->newsletters_model->saveNewsletter($newsletterID, $newsletter);
             }
             router::redirect('cp/users?search_id=' . $searchID);
         }
     }
     // Set filters
     $filters = array(array('name' => __('user', 'system'), 'type' => 'text', 'keyword' => 'user'), array('name' => __('user_group', 'users'), 'type' => 'checkbox', 'keyword' => 'groups', 'items' => config::item('usergroups', 'core')), array('name' => __('user_type', 'users'), 'type' => 'select', 'keyword' => 'type_id', 'items' => config::item('usertypes', 'core', 'names')));
     foreach (config::item('usertypes', 'core', 'keywords') as $id => $type) {
         $filters['types'][$id] = $this->fields_model->getFields('users', $id, 'edit');
     }
     $filters[] = array('name' => __('verified', 'users'), 'type' => 'boolean', 'keyword' => 'verified');
     $filters[] = array('name' => __('active', 'system'), 'type' => 'boolean', 'keyword' => 'active');
     // Assign vars
     view::assign(array('filters' => $filters, 'values' => array()));
     // Assign vars
     view::assign(array('newsletterID' => $newsletterID, 'newsletter' => $newsletter));
     // Process form values
     if (input::post('do_search')) {
         $this->_saveRecipients($newsletterID, $filters);
     } elseif (isset($newsletter['params']['values'])) {
         // Assign vars
         view::assign(array('values' => $newsletter['params']['values']));
     }
     // Set title
     view::setTitle(__('newsletter_recipients', 'newsletters'));
     // Set trail
     view::setTrail('cp/content/newsletters/edit/' . $newsletterID, __('newsletter_edit', 'newsletters') . ' - ' . text_helper::entities($newsletter['subject']));
     view::setTrail('cp/content/newsletters/recipients/' . $newsletterID, __('newsletter_recipients', 'newsletters'));
     // Load view
     view::load('cp/content/newsletters/recipients');
 }
示例#14
0
 function populate($values = null)
 {
     if ($this->method == 'post') {
         $values = pick($values, input::post());
     } elseif ($this->method == 'get') {
         $values = pick($values, input::get());
     }
     foreach ($this->schema as $field) {
         $input_id = $this->model_name . '_' . $field->name;
         if (array_key_exists($input_id, $values)) {
             $this->values[$input_id] = $values[$input_id];
         } else {
             $this->values[$input_id] = null;
         }
     }
     return $this->values;
 }
示例#15
0
 protected function _saveSubject($subjectID)
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Create rules
     $rules = $input = array();
     // Get subject data
     $subjectData = array();
     foreach (config::item('languages', 'core', 'keywords') as $languageID => $language) {
         $rules['name_' . $language] = array('label' => __('name', 'system') . (count(config::item('languages', 'core', 'keywords')) > 1 ? ' [' . config::item('languages', 'core', 'names', $languageID) . ']' : ''), 'rules' => array('trim', 'required', 'max_length' => 255));
         $input[] = 'name_' . $language;
     }
     // Assign rules
     validate::setRules($rules);
     // Validate fields
     if (!validate::run()) {
         return false;
     }
     // Get subject data
     $subject = input::post($input);
     $subject['active'] = input::post('active') ? 1 : 0;
     // Save subject
     if (!($subjectID = $this->reports_subjects_model->saveSubject($subjectID, $subject))) {
         view::setError(__('save_error', 'system'));
         return false;
     }
     // Success
     view::setInfo(__('subject_saved', 'reports_subjects'));
     router::redirect('cp/content/reports/subjects/edit/' . $subjectID);
 }
示例#16
0
 protected function _resendHash()
 {
     // Create rules
     $rules = array('email' => array('label' => 'email', 'rules' => array('trim', 'required', 'max_length' => 255, 'valid_email')));
     // Assign rules
     validate::setRules($rules);
     // Validate fields
     if (!validate::run()) {
         return false;
     }
     // Does user exist?
     if (!($user = $this->users_model->getUser(input::post('email')))) {
         validate::setFieldError('email', __('email_invalid', 'users_signup'));
         return false;
     }
     // Is user's email already verified?
     if ($user['verified']) {
         view::setError(__('user_already_verified', 'users_signup'));
         return false;
     }
     // Loader
     loader::library('email');
     loader::model('system/requests');
     // Is this a recent request?
     if ($this->requests_model->isRecentRequest('signup', $user['user_id'], 0, 5)) {
         // Success
         view::setError(__('request_recent_sendhash', 'users_signup'));
         return false;
     }
     // Save resend hash request
     $hash = $this->requests_model->saveRequest('signup', $user['user_id']);
     $user['security_hash'] = $hash;
     $user['activation_link'] = config::siteURL('users/signup/confirm/' . $user['user_id'] . '/' . $hash);
     // Send activation email
     $this->email->sendTemplate('users_account_confirm', $user['email'], $user, $user['language_id']);
     // Success
     view::setInfo(__('confirm_email', 'users_signup'));
     router::redirect('users/login/index/verify');
 }
示例#17
0
 protected function _savePlan($planID)
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Rules array
     $rules = array();
     // Data array
     $input = array('duration', 'cycle', 'price', 'group_id', 'signup', 'active');
     // Name
     foreach (config::item('languages', 'core', 'keywords') as $languageID => $languageKey) {
         $rules['name_' . $languageKey] = array('label' => __('name', 'system') . (count(config::item('languages', 'core', 'keywords')) > 1 ? ' [' . config::item('languages', 'core', 'names', $languageID) . ']' : ''), 'rules' => array('trim', 'required', 'max_length' => 255));
         $input[] = 'name_' . $languageKey;
         $rules['description_' . $languageKey] = array('label' => __('description', 'system') . (count(config::item('languages', 'core', 'keywords')) > 1 ? ' [' . config::item('languages', 'core', 'names', $languageID) . ']' : ''), 'rules' => array('trim', 'required'));
         $input[] = 'description_' . $languageKey;
     }
     // Additional rules
     $rules['duration'] = array('label' => __('plan_cycle', 'billing_plans'), 'rules' => array('trim', 'required', 'is_natural_no_zero'));
     $rules['cycle'] = array('label' => __('plan_cycle', 'billing_plans'), 'rules' => array('trim', 'required', 'intval'));
     $rules['price'] = array('label' => __('price', 'billing'), 'rules' => array('trim', 'required', 'numeric'));
     $rules['group_id'] = array('label' => __('user_group', 'users'), 'rules' => array('trim', 'required', 'intval'));
     $rules['signup'] = array('label' => __('plan_show_signup', 'billing_plans'), 'rules' => array('trim', 'required', 'intval'));
     $rules['active'] = array('label' => __('active', 'system'), 'rules' => array('trim', 'required', 'intval'));
     // Assign rules
     validate::setRules($rules);
     // Validate fields
     if (!validate::run()) {
         return false;
     }
     // Get post data
     $plan = input::post($input);
     // Save banner group
     if (!($planID = $this->plans_model->savePlan($planID, $plan))) {
         view::setError(__('save_error', 'system'));
         return false;
     }
     // Success
     view::setInfo(__('plan_saved', 'billing_plans'));
     router::redirect('cp/billing/plans/edit/' . $planID);
 }
示例#18
0
 protected function _saveAlbum($albumID, $album, $fields)
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Extra rules
     $rules = array('comments' => array('rules' => 'intval'), 'privacy' => array('rules' => 'intval'), 'public' => array('rules' => 'intval'));
     // Validate form values
     if (!$this->fields_model->validateValues($fields, $rules)) {
         return false;
     }
     // Extras
     $extra = array();
     $extra['comments'] = config::item('picture_comments', 'pictures') && config::item('picture_privacy_comments', 'pictures') ? (int) input::post('comments') : 1;
     $extra['privacy'] = config::item('album_privacy_view', 'pictures') ? (int) input::post('privacy') : 1;
     $extra['public'] = config::item('album_privacy_public', 'pictures') ? (int) input::post('public') : 1;
     // Save album
     if (!($albumID = $this->pictures_albums_model->saveAlbumData($albumID, 0, $album, $fields, $extra))) {
         if (!validate::getTotalErrors()) {
             view::setError(__('save_error', 'system'));
         }
         return false;
     }
     // Success
     view::setInfo(__('album_saved', 'pictures', array(), array('%1' => html_helper::anchor('cp/plugins/pictures/albums/edit/' . $albumID, '\\1'), '%2' => html_helper::anchor('cp/plugins/pictures/browse/' . $albumID, '\\1'))));
     router::redirect('cp/plugins/pictures/albums/edit/' . $albumID);
 }
示例#19
0
 protected function _savePicture($pictureID, $adID, $picture, $ad, $fields)
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Validate form values
     if (!$this->fields_model->validateValues($fields)) {
         return false;
     }
     // Extras
     $extra = array();
     $extra['active'] = (int) input::post('active');
     // Save picture
     if (!($pictureID = $this->classifieds_pictures_model->savePictureData($pictureID, $adID, $picture, $ad, $fields, $extra))) {
         if (!validate::getTotalErrors()) {
             view::setError(__('save_error', 'system'));
         }
         return false;
     }
     // Success
     view::setInfo(__('picture_saved', 'classifieds'));
     router::redirect('cp/plugins/classifieds/pictures/edit/' . $adID . '/' . $pictureID);
 }
示例#20
0
 protected function _saveTemplate($templateID, $keyword)
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Rules and input arrays
     $rules = $input = array();
     // Build rules
     foreach (config::item('languages', 'core', 'keywords') as $languageID => $language) {
         // Make sure this is not a header/footer template
         if (!in_array($keyword, array('header', 'footer'))) {
             $rules['subject_' . $language] = array('label' => __('template_subject', 'system_email_templates') . (count(config::item('languages', 'core', 'keywords')) > 1 ? ' [' . config::item('languages', 'core', 'names', $languageID) . ']' : ''), 'rules' => array('trim', 'required'));
             $input[] = 'subject_' . $language;
         }
         $rules['message_html_' . $language] = array('label' => __('template_message_html', 'system_email_templates') . (count(config::item('languages', 'core', 'keywords')) > 1 ? ' [' . config::item('languages', 'core', 'names', $languageID) . ']' : ''), 'rules' => array('trim', 'required'));
         $rules['message_text_' . $language] = array('label' => __('template_message_text', 'system_email_templates') . (count(config::item('languages', 'core', 'keywords')) > 1 ? ' [' . config::item('languages', 'core', 'names', $languageID) . ']' : ''), 'rules' => array('trim', 'required'));
         $rules['active'] = array('label' => __('active', 'system'), 'rules' => array('required', 'intval'));
         $input[] = 'message_html_' . $language;
         $input[] = 'message_text_' . $language;
         $input[] = 'active';
     }
     // Assign rules
     validate::setRules($rules);
     // Validate fields
     if (!validate::run()) {
         return false;
     }
     // Get template data
     $template = input::post($input);
     // Save template data
     $this->emailtemplates_model->saveTemplate($templateID, $template);
     // Success
     view::setInfo(__('template_saved', 'system_email_templates'));
     router::redirect('cp/system/emailtemplates/edit/' . $templateID);
 }
示例#21
0
 protected function _saveLanguageData($plugin, $language, $default)
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Create rules
     $rules = array();
     foreach ($default as $section => $groups) {
         foreach ($groups as $group => $types) {
             foreach ($types as $type => $lang) {
                 foreach ($lang as $keyword => $name) {
                     $rules[$group . '_' . $keyword] = array('label' => '', 'rules' => array('trim', 'required'));
                 }
             }
         }
     }
     // Assign rules
     validate::setRules($rules);
     // Validate fields
     if (!validate::run()) {
         return false;
     }
     // Get language data
     $languageData = array();
     foreach ($default as $section => $groups) {
         foreach ($groups as $group => $types) {
             foreach ($types as $type => $lang) {
                 foreach ($lang as $keyword => $name) {
                     $cp = $type == 'cp' ? 1 : 0;
                     // Set language data
                     $data = array('value_' . $language => input::post($group . '_' . $keyword));
                     // Save language string
                     $this->languages_model->saveLanguageData($plugin, $section, $group, $keyword, $data);
                 }
             }
         }
     }
     // Recompile language pack
     $this->languages_model->compile($language);
     // Success
     view::setInfo(__('language_saved', 'system_languages'));
     router::redirect('cp/system/languages/translate/' . $plugin . '/' . $language);
 }
示例#22
0
 protected function _saveTemplate($templateID)
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Create rules
     $rules = array('category_id' => array('label' => __('gift_category', 'gifts'), 'rules' => array('intval')));
     // Get template data
     $rules['name'] = array('label' => __('name', 'system'), 'rules' => array('trim', 'required', 'max_length' => 255));
     $rules['subject'] = array('label' => __('newsletter_subject', 'newsletters'), 'rules' => array('trim', 'required', 'max_length' => 255));
     $rules['message_html'] = array('label' => __('newsletter_message_html', 'newsletters'), 'rules' => array('trim', 'required'));
     $rules['message_text'] = array('label' => __('newsletter_message_text', 'newsletters'), 'rules' => array('trim', 'required'));
     $input = array('name', 'subject', 'message_html', 'message_text');
     // Assign rules
     validate::setRules($rules);
     // Validate fields
     if (!validate::run()) {
         return false;
     }
     // Get template data
     $template = input::post($input);
     // Save template
     if (!($templateID = $this->newsletters_templates_model->saveTemplate($templateID, $template))) {
         view::setError(__('save_error', 'system'));
         return false;
     }
     // Success
     view::setInfo(__('template_saved', 'newsletters_templates'));
     router::redirect('cp/content/newsletters/templates/edit/' . $templateID);
 }
示例#23
0
 protected function _saveField($plugin, $table, $categoryID, $fieldID, $fieldOld, $configs, $hidden)
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Rules array
     $rules = array();
     // Data array
     $inputData = array('keyword', 'type', 'style', 'class', 'required', 'system', 'multilang');
     // Name
     foreach (config::item('languages', 'core', 'keywords') as $languageID => $lang) {
         $rules['name_' . $lang] = array('label' => __('name', 'system_fields') . (count(config::item('languages', 'core', 'keywords')) > 1 ? ' [' . config::item('languages', 'core', 'names', $languageID) . ']' : ''), 'rules' => array('trim', 'required', 'max_length' => 255));
         $rules['vname_' . $lang] = array('label' => __('name_view', 'system_fields') . (count(config::item('languages', 'core', 'keywords')) > 1 ? ' [' . config::item('languages', 'core', 'names', $languageID) . ']' : ''), 'rules' => array('trim', 'max_length' => 255));
         $rules['sname_' . $lang] = array('label' => __('name_search', 'system_fields') . (count(config::item('languages', 'core', 'keywords')) > 1 ? ' [' . config::item('languages', 'core', 'names', $languageID) . ']' : ''), 'rules' => array('trim', 'max_length' => 255));
         $rules['validate_error_' . $lang] = array('label' => __('validate_error', 'system_fields') . (count(config::item('languages', 'core', 'keywords')) > 1 ? ' [' . config::item('languages', 'core', 'names', $languageID) . ']' : ''), 'rules' => array('trim', 'max_length' => 255));
         $inputData[] = 'name_' . $lang;
         $inputData[] = 'vname_' . $lang;
         $inputData[] = 'sname_' . $lang;
         $inputData[] = 'validate_error_' . $lang;
     }
     // Keyword
     $rules['keyword'] = array('label' => __('keyword', 'system'), 'rules' => array('trim', 'required', 'alpha_dash', 'max_length' => 128, 'callback__is_unique_keyword' => array($plugin, $categoryID, $fieldID), 'callback__is_system_field' => array($fieldID ? $fieldOld['keyword'] : '', $fieldID ? $fieldOld['system'] : '')));
     // Type
     $rules['type'] = array('label' => __('field_type', 'system_fields'), 'rules' => array('required', 'callback__is_system_field' => array($fieldID ? $fieldOld['type'] : '', $fieldID ? $fieldOld['system'] : '')));
     // Style value
     $rules['style'] = array('label' => __('style', 'system_fields'), 'rules' => array('trim'));
     // Class value
     $rules['class'] = array('label' => __('class', 'system_fields'), 'rules' => array('trim'));
     // Required
     $rules['required'] = array('label' => __('required', 'system_fields'), 'rules' => array('intval'));
     // Regular expression
     $rules['validate'] = array('label' => __('validate', 'system_fields'), 'rules' => array('trim'));
     $inputData[] = 'validate';
     // Configuration array
     $inputConfig = array();
     foreach (array('custom', input::post('type')) as $conf) {
         if (isset($configs[$conf])) {
             foreach ($configs[$conf] as $option) {
                 $rules['config_' . $conf . '_' . $option['keyword']] = array('label' => utf8::strtolower($option['label']), 'rules' => isset($option['rules']) ? $option['rules'] : array());
                 $inputConfig[$option['keyword']] = 'config_' . $conf . '_' . $option['keyword'];
             }
         }
     }
     // Add items rules
     $items = array();
     $oldItems = $fieldID ? $fieldOld['items'] : array();
     if ($this->fields_model->isMultiValue(input::post('type'))) {
         $itemsPost = input::post('items');
         $sitemsPost = input::post('sitems');
         foreach (config::item('languages', 'core', 'keywords') as $languageID => $lang) {
             $orderID = 1;
             if (isset($itemsPost[$lang]) && is_array($itemsPost[$lang])) {
                 foreach ($itemsPost[$lang] as $itemID => $itemName) {
                     // Trim name
                     $itemName = utf8::trim($itemName);
                     // Assign item data
                     $items[$itemID]['order_id'] = $orderID;
                     $items[$itemID]['name_' . $lang] = $itemName;
                     $items[$itemID]['sname_' . $lang] = $sitemsPost[$lang][$itemID];
                     $orderID++;
                     // Add rule
                     $rules['items[' . $lang . '][' . $itemID . ']'] = array();
                     if ($itemName == '') {
                         validate::setRule('items', '', '');
                         validate::setFieldError('items', __('empty_item', 'system_fields') . (count(config::item('languages', 'core', 'keywords')) > 1 ? ' [' . config::item('languages', 'core', 'names', $languageID) . ']' : ''));
                     }
                 }
             }
         }
         if (!$items) {
             validate::setRule('items', '', '');
             validate::setFieldError('items', __('no_items', 'system_fields'));
         }
         view::assign(array('field' => array('items' => $items)));
     }
     // Assign rules
     validate::setRules($rules);
     // Validate fields
     if (!validate::run()) {
         return false;
     }
     // Get post data
     $fieldData = input::post($inputData);
     // Default data
     $fieldData['system'] = isset($hidden['system']) ? $hidden['system'] : 0;
     $fieldData['multilang'] = isset($hidden['multilang']) ? $hidden['multilang'] : 0;
     // Get config data
     $fieldData['config'] = array();
     foreach ($inputConfig as $key => $val) {
         $fieldData['config'][$key] = input::post($val);
     }
     // Set additional config data
     $fieldData['config']['html'] = input::post('html') ? 1 : 0;
     $fieldData['config']['in_search'] = input::post('in_search') ? 1 : 0;
     $fieldData['config']['in_search_advanced'] = input::post('in_search_advanced') ? 1 : 0;
     if ($fieldData['config']['in_search'] || $fieldData['config']['in_search_advanced']) {
         $fieldData['config']['search_options'] = input::post('search_options') ? input::post('search_options') : '';
     }
     if (input::post('type') == 'checkbox' || input::post('search_options') == 'multiple') {
         $fieldData['config']['columns_number'] = input::post('columns_number') && input::post('columns_number') >= 1 && input::post('columns_number') <= 4 ? input::post('columns_number') : 1;
     }
     // Save field
     if (!($newFieldID = $this->fieldsdb_model->saveField($plugin, $table, $categoryID, $fieldID, $fieldData, $items))) {
         view::setError(__('db_no_alter', 'system_fields'));
         return false;
     }
     // Check if order of items have changed
     if ($fieldID && $this->fields_model->isMultiValue(input::post('type')) && $this->fields_model->isValueColumn(input::post('type'))) {
         // Get old and new item IDs
         $itemsOldIDs = $itemsNewIDs = array();
         foreach ($oldItems as $itemID => $item) {
             $itemsOldIDs[$itemID] = $item['order_id'];
         }
         foreach ($items as $itemID => $item) {
             $itemsNewIDs[$itemID] = $item['order_id'];
         }
         // Do we have any differences?
         if (array_diff_assoc($itemsOldIDs, $itemsNewIDs)) {
             // Update items IDs
             $this->fieldsdb_model->updateItemsIDs($table, $fieldData['keyword'], $itemsOldIDs, $itemsNewIDs);
         }
     }
     // Adjust table column
     $this->fieldsdb_model->adjustColumn($table, $fieldData['keyword'], $newFieldID, $fieldData);
     // Success
     view::setInfo(__('field_saved', 'system_fields'));
     router::redirect('cp/system/fields/' . $plugin . '/edit/' . $categoryID . '/' . $newFieldID);
 }
示例#24
0
 public function _is_valid_field_name($field, $keyword, $fields)
 {
     if (count($fields) > 1 && $field) {
         if (!isset($fields[$field])) {
             validate::setError('_is_valid_field_name', __('type_name_field_invalid', 'users_types'));
             return false;
         } elseif ($keyword == 'field_name_2' && input::post('field_name_1') && $field == input::post('field_name_1')) {
             validate::setError('_is_valid_field_name', __('type_duplicate_field_name', 'users_types'));
             return false;
         } elseif ($keyword == 'field_name_2' && !input::post('field_name_1')) {
             return '';
         }
     }
     return true;
 }
示例#25
0
 protected function _saveTemplate($templateID)
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Create rules
     $rules = array('category_id' => array('label' => __('gift_category', 'gifts'), 'rules' => array('intval')), 'active' => array('label' => __('active', 'system'), 'rules' => array('intval')));
     // Get template data
     $templateData = $input = array();
     foreach (config::item('languages', 'core', 'keywords') as $languageID => $language) {
         $rules['name_' . $language] = array('label' => __('name', 'system') . (count(config::item('languages', 'core', 'keywords')) > 1 ? ' [' . config::item('languages', 'core', 'names', $languageID) . ']' : ''), 'rules' => array('trim', 'required', 'max_length' => 255));
         $rules['subject_' . $language] = array('label' => __('template_subject', 'messages_templates') . (count(config::item('languages', 'core', 'keywords')) > 1 ? ' [' . config::item('languages', 'core', 'names', $languageID) . ']' : ''), 'rules' => array('trim', 'required', 'max_length' => 255));
         $rules['message_' . $language] = array('label' => __('template_message', 'messages_templates') . (count(config::item('languages', 'core', 'keywords')) > 1 ? ' [' . config::item('languages', 'core', 'names', $languageID) . ']' : ''), 'rules' => array('trim', 'required'));
         $input[] = 'name_' . $language;
         $input[] = 'subject_' . $language;
         $input[] = 'message_' . $language;
     }
     // Assign rules
     validate::setRules($rules);
     // Validate fields
     if (!validate::run()) {
         return false;
     }
     // Get template data
     $template = input::post($input);
     $template['active'] = input::post('active') ? 1 : 0;
     // Save template
     if (!($templateID = $this->messages_templates_model->saveTemplate($templateID, $template))) {
         view::setError(__('save_error', 'system'));
         return false;
     }
     // Success
     view::setInfo(__('template_saved', 'messages_templates'));
     router::redirect('cp/plugins/messages/templates/edit/' . $templateID);
 }
示例#26
0
 protected function _saveMessage($messageID, $message)
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Create rules
     $rules = array('message' => array('label' => __('message', 'messages'), 'rules' => array('trim', 'required')));
     // Assign rules
     validate::setRules($rules);
     // Validate fields
     if (!validate::run()) {
         return false;
     }
     // Get input data
     $body = input::post('message');
     // Save message
     if (!($messageID = $this->messages_model->saveMessage($messageID, $message['conversation_id'], $body))) {
         if (!validate::getTotalErrors()) {
             view::setError(__('save_error', 'system'));
         }
         return false;
     }
     // Success
     view::setInfo(__('message_saved', 'messages'));
     router::redirect('cp/plugins/messages/edit/' . $messageID);
 }
示例#27
0
 protected function _saveAlbum($albumID, $album, $fields)
 {
     // Extra rules
     $rules = array('comments' => array('rules' => 'intval'), 'privacy' => array('rules' => 'intval'), 'public' => array('rules' => 'intval'));
     // Validate form values
     if (!$this->fields_model->validateValues($fields, $rules)) {
         return false;
     }
     // Extra fields
     $extra = array();
     $extra['comments'] = config::item('picture_comments', 'pictures') && config::item('picture_privacy_comments', 'pictures') ? (int) input::post('comments') : 1;
     $extra['privacy'] = config::item('album_privacy_view', 'pictures') ? (int) input::post('privacy') : 1;
     $extra['public'] = config::item('album_privacy_public', 'pictures') ? (int) input::post('public') : 1;
     // Save album
     if (!($albumID = $this->pictures_albums_model->saveAlbumData($albumID, session::item('user_id'), $album, $fields, $extra))) {
         if (!validate::getTotalErrors()) {
             view::setError(__('save_error', 'system'));
         }
         return false;
     }
     // Success
     view::setInfo(__('album_saved', 'pictures'));
     router::redirect('pictures/albums/edit/' . $albumID);
 }
示例#28
0
function post($name, $mode = 'title')
{
    return input::post($name, $mode);
}
示例#29
0
 protected function _saveNotifications($userID, $settings)
 {
     // Check if demo mode is enabled
     if (input::demo()) {
         return false;
     }
     // Validate form fields
     foreach ($settings as $keyword => $setting) {
         if (isset($setting['rules'])) {
             validate::setRule($keyword, $setting['name'], $setting['rules']);
         }
     }
     // Validate fields
     if (!validate::run()) {
         return false;
     }
     // Set notifications settings
     $insert = $delete = array();
     foreach ($settings as $keyword => $setting) {
         $data = input::post($keyword);
         if (isset($data['insert']) && isset($data['delete'])) {
             $insert = array_merge($insert, $data['insert']);
             $delete = array_merge($delete, $data['delete']);
         }
     }
     // Save notifications
     if ($insert && !$this->users_model->saveConfig($userID, $insert) || $delete && !$this->users_model->deleteConfig($userID, $delete)) {
         view::setError(__('save_error', 'system'));
         return false;
     }
     // Success
     view::setInfo(__('notifications_saved', 'users_notifications'));
     router::redirect('cp/users/notifications/' . $userID);
 }
示例#30
0
 protected function _reorderItems()
 {
     // Check if demo mode is enabled
     if (input::demo(0)) {
         return false;
     }
     // Get submitted item IDs
     $items = input::post('ids');
     // Do we have any item IDs?
     if ($items && is_array($items)) {
         // Loop through item IDs
         $orderID = 1;
         foreach ($items as $itemID) {
             // Update item ID
             $this->lists_model->updateItem($itemID, array('order_id' => $orderID));
             $orderID++;
         }
     }
 }