/** * Check the limit of number of child-categories * * 'PEPPER_LIMIT' 2 * 'YOU_LIMIT' 2 * 'NEWS_LIMIT' 5 * * @param int $parent_id value of cat-id in post-data * @param int $child_id ID of child category * @return boolean result of validation * * @since 1.0 * @version 1.0 * @access public * @author Nguyen Van Hiep */ public static function _validation_child_limit($parent_id, $child_id = null) { if ($parent_id < C_PEPPER or $parent_id > C_NEWS) { return true; } switch ($parent_id) { case C_PEPPER: $limit = PEPPER_LIMIT; break; case C_YOU: $limit = YOU_LIMIT; break; case C_NEWS: $limit = NEWS_LIMIT; break; default: break; } $is_child = Model_Categories::is_child($child_id, $parent_id); $nmber_child = Model_Categories::child_number_excluding_cat($parent_id, Input::post('lang'), $child_id); if ($is_child and $nmber_child < $limit) { return true; } $num_child = Model_Categories::number_of_child($parent_id, Input::post('lang')); Validation::active()->set_message('child_limit', __('message.over_child_limit')); return $num_child < $limit ? true : false; }