当前位置: 首页>>代码示例>>PHP>>正文


PHP validation::greater_than_equal_to方法代码示例

本文整理汇总了PHP中validation::greater_than_equal_to方法的典型用法代码示例。如果您正苦于以下问题:PHP validation::greater_than_equal_to方法的具体用法?PHP validation::greater_than_equal_to怎么用?PHP validation::greater_than_equal_to使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在validation的用法示例。


在下文中一共展示了validation::greater_than_equal_to方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: tu_validation

/**
 * Проверка данных из формы.
 */
function tu_validation(&$tservice, $is_exist_feedbacks = 0)
{
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/city.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/tservices/tservices_categories.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/tservices/validation.php';
    $errors = array();
    $validator = new validation();
    $tservices_categories = new tservices_categories();
    //---
    //$tservice->title = trim(htmlspecialchars(InPost('title'),ENT_QUOTES,'cp1251'));
    //$tservice->title = antispam(__paramInit('string', NULL, 'name', NULL, 60, TRUE));
    $tservice->title = sentence_case(__paramInit('html', null, 'title', null, 100, true));
    $title = trim(stripslashes(InPost('title')));
    if (!$validator->required($title)) {
        $errors['title'] = validation::VALIDATION_MSG_REQUIRED;
    } elseif (!$validator->symbols_interval($title, 4, 100)) {
        $errors['title'] = sprintf(validation::VALIDATION_MSG_SYMBOLS_INTERVAL, 4, 100);
    }
    //---
    $tservice->price = intval(trim(InPost('price')));
    if (!$validator->is_natural_no_zero($tservice->price)) {
        $errors['price'] = validation::VALIDATION_MSG_REQUIRED_PRICE;
    } elseif (!$validator->greater_than_equal_to($tservice->price, 300)) {
        $errors['price'] = sprintf(validation::VALIDATION_MSG_PRICE_GREATER_THAN_EQUAL_TO, '300 р.');
    } elseif (!$validator->less_than_equal_to($tservice->price, 999999)) {
        $errors['price'] = sprintf(validation::VALIDATION_MSG_PRICE_LESS_THAN_EQUAL_TO, '999 999 р.');
    }
    //---
    $days_db_id = intval(trim(InPost('days_db_id')));
    if (!$validator->is_natural_no_zero($days_db_id) || !in_array($days_db_id, array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 14, 21, 30, 45, 60, 90))) {
        $errors['days'] = validation::VALIDATION_MSG_FROM_LIST;
        $days_db_id = 1;
    }
    $tservice->days = $days_db_id;
    //---
    //Если есть отзывы то не даем изменить категорию
    if (!(InPost('action') == 'save' && $is_exist_feedbacks > 0)) {
        $category_id = intval(trim(InPost('category_db_id')));
        $parent_category_id = $tservices_categories->getCategoryParentId($category_id);
        if ($parent_category_id === false) {
            $errors['category'] = validation::VALIDATION_MSG_CATEGORY_FROM_LIST;
        } else {
            $tservice->category_id = $category_id;
            //$this->property()->parent_category_id = $parent_category_id;
        }
    }
    //---
    $str_tags = trim(preg_replace('/\\s+/s', ' ', strip_tags(InPost('tags'))));
    $tags = strlen($str_tags) > 0 ? array_unique(array_map('trim', explode(',', $str_tags))) : array();
    $tags = array_filter($tags, function ($el) {
        $len = strlen(stripslashes($el));
        return $len < 80 && $len > 2;
    });
    $tags_cnt = count(array_unique(array_map('strtolower', $tags)));
    $tags = array_map(function ($value) {
        return htmlspecialchars($value, ENT_QUOTES, 'cp1251');
    }, $tags);
    $tservice->tags = $tags;
    if (!$validator->required($str_tags)) {
        $errors['tags'] = validation::VALIDATION_MSG_REQUIRED;
    } elseif ($tags_cnt > 10) {
        $errors['tags'] = sprintf(validation::VALIDATION_MSG_MAX_TAGS, 10);
    }
    //---
    $videos = __paramInit('array', null, 'videos', array());
    $videos = is_array($videos) ? array_values($videos) : array();
    if (count($videos)) {
        $tservice->videos = null;
        foreach ($videos as $key => $video) {
            if ($validator->required($video)) {
                $_video_data = array('url' => $video, 'video' => false, 'image' => false);
                //$_video = $validator->video_validate($video);
                $_video = $validator->video_validate($video);
                $is_error = true;
                if ($_video) {
                    $_video_data['url'] = $_video;
                    if ($_video_meta = $validator->video_validate_with_thumbs($_video, 0)) {
                        $_video_data = array_merge($_video_data, $_video_meta);
                        $is_error = false;
                    }
                }
                if ($is_error) {
                    $errors['videos'][$key] = validation::VALIDATION_MSG_BAD_LINK;
                }
                $tservice->videos[$key] = $_video_data;
            }
        }
    }
    //---
    //$tservice->description = trim(htmlspecialchars(InPost('description'),ENT_QUOTES, "cp1251"));
    //$description = trim(InPost('description'));
    $tservice->description = trim(__paramInit('html', null, 'description', null, 5000, true));
    $description = trim(stripslashes(InPost('description')));
    if (!$validator->required($description)) {
        $errors['description'] = validation::VALIDATION_MSG_REQUIRED;
    } elseif (!$validator->symbols_interval($description, 4, 5000)) {
        $errors['description'] = sprintf(validation::VALIDATION_MSG_SYMBOLS_INTERVAL, 4, 5000);
//.........这里部分代码省略.........
开发者ID:kapai69,项目名称:fl-ru-damp,代码行数:101,代码来源:functions.php

示例2: tservicesOrdersSetPrice

/**
 * Редактирование стоимости и сроков заказа ТУ
 * 
 * @param type $order_id
 * @param type $price
 * @param type $days
 * 
 * @return \xajaxResponse
 */
function tservicesOrdersSetPrice($order_id, $price, $days, $paytype)
{
    $objResponse =& new xajaxResponse();
    $uid = get_uid(false);
    $price = intval($price);
    $days = intval($days);
    $paytype = intval($paytype);
    //Валидация входных параметров
    $validator = new validation();
    $valid = $validator->is_natural_no_zero($price) && $validator->greater_than_equal_to($price, 300);
    $valid = $valid && $validator->is_natural_no_zero($days) && $validator->numeric_interval($days, 1, 730);
    $valid = $valid && in_array($valid, array(TServiceOrderModel::PAYTYPE_DEFAULT, TServiceOrderModel::PAYTYPE_RESERVE));
    if (!$valid) {
        return $objResponse;
    }
    //Получение заказа
    $orderModel = TServiceOrderModel::model();
    $order_id = intval($order_id);
    $old_order = $orderModel->getCard($order_id, $uid);
    if (!$old_order) {
        return $objResponse;
    }
    //Валидация возможности изменений
    $is_new_status = $old_order['status'] == TServiceOrderModel::STATUS_NEW;
    $is_owner = $old_order['emp_id'] == $uid;
    $is_reserve_accepted = isset($old_order['reserve_data']);
    if (!($is_new_status && $is_owner && !$is_reserve_accepted)) {
        return $objResponse;
    }
    //Проверка возможности смены типа оплаты
    $is_reserve = tservices_helper::isOrderReserve($paytype);
    if ($is_reserve && !tservices_helper::isAllowOrderReserve($old_order['category_id'])) {
        return $objResponse;
    }
    if (!$is_reserve) {
        $paytype = TServiceOrderModel::PAYTYPE_DEFAULT;
    }
    $data = array('order_price' => $price, 'order_days' => $days, 'pay_type' => $paytype);
    //Меняем
    if ($orderModel->edit($order_id, $data, $old_order['tax'])) {
        $order = $old_order;
        $order['order_price'] = $price;
        $order['order_days'] = $days;
        $order['pay_type'] = $paytype;
        //Сохранить действие в историю
        $history = new tservices_order_history($order_id);
        $history->save($order, $old_order);
        //Уведомление на почту
        $tservices_smail = new tservices_smail();
        $tservices_smail->changeOrder2($order, $old_order);
        //Обновляем интерфейс цен и сроков
        $objResponse->script("\$('tu-container-price').set('html', '" . tservices_helper::cost_format($price) . "');");
        $objResponse->script("\$('tu-container-days').set('html', '" . tservices_helper::days_format($days) . "');");
        $objResponse->script("\$('tu_edit_budjet_price').set('value', '" . $price . "');");
        $objResponse->script("\$('tu_edit_budjet_days').set('value', '" . $days . "');");
        //Обновляем сообщение статуса, т.к. вторая сторона тоже могла его изменить
        $tserviceOrderStatusWidget = new TServiceOrderStatus();
        $tserviceOrderStatusWidget->setIsEmp(true);
        $tserviceOrderStatusWidget->setOrder($order);
        $tserviceOrderStatusWidget->init();
        ob_start();
        $tserviceOrderStatusWidget->run();
        $statusHtml = ob_get_contents();
        ob_end_clean();
        $objResponse->assign('tservices_order_status_' . $order_id, 'innerHTML', $statusHtml);
        $objResponse->script("\n            \$('tu-container-price').getParent()\n            .removeClass('b-layout__link_bordbot_dot_" . ($is_reserve ? '000' : 'ee1d16') . "')\n            .addClass('b-layout__link_bordbot_dot_" . ($is_reserve ? 'ee1d16' : '000') . "');\n            \$('tu-container-price').getPrevious('span').set('html','" . ($is_reserve ? 'Бюджет:' : 'Стоимость:') . "');    \n        ");
    }
    return $objResponse;
}
开发者ID:Nikitian,项目名称:fl-ru-damp,代码行数:78,代码来源:tservices_orders.server.php


注:本文中的validation::greater_than_equal_to方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。