Вход Регистрация
Файл: adultscript-2.0.3-pro/files/admin/modules/adv/components/group_edit.php
Строк: 67
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_Admin_adv_group_edit
{
    public function 
__construct()
    {
    }
    
    public function 
render()
    {
        
$db VF::factory('database');
        
        
$errors        = array();
        
$messages    = array();
        
$group        = array();
        
$id            = (isset($_GET['id'])) ? (int) trim($_GET['id']) : 0;
        
        
$db->query("SELECT adv_group_id FROM #__adv_groups WHERE adv_group_id = ".$id." LIMIT 1");
        if (
$db->affected_rows()) {        
            if (isset(
$_POST['submit_group_edit'])) {
                
$filter        VF::factory('filter');
                
$name        $filter->get('adv_group_name');
                
$desc        $filter->get('adv_group_desc');
                
$slug        $filter->get('adv_group_slug');
                
$rotate        = (int) trim($_POST['adv_rotate']);
                
$status        = (int) trim($_POST['status']);
            
                if (
$name == '') {
                    
$errors[]    = 'Please enter advertising group name!';
                } elseif (
strlen($name) > 100) {
                    
$errors[]    = 'Advertising group name can contain maximum 100 characters!';
                } else {
                    
$group['adv_group_name']    = $name;
                }
            
                if (
$desc != '') {
                    if (
strlen($desc) > 255) {
                        
$errors[]    = 'Advertising group description can contain maximum 255 characters!';
                    }
                }
            
                if (
$slug == '') {
                    
$errors[]    = 'Please enter the advertising group slug identifier!';
                } elseif (!
preg_match('/[A-za-z0-9_-]+/'$slug)) {
                    
$errors[]    = 'Advertising group slug identifier can contain only letters, numbers, dashes and underscores!';
                } elseif (
strlen($slug) > 50) {
                    
$errors[]    = 'Advertising group slug identifier can contain maximum 50 characters!';
                } else {
                    
$db->query("SELECT adv_group_id
                                FROM #__adv_groups
                                WHERE adv_group_slug = '"
.$db->escape($slug)."'
                                AND adv_group_id != "
.$id."
                                LIMIT 1"
);
                    if (
$db->affected_rows()) {
                        
$errors[] = 'Advertising group slug identifier is already used as a identifier for another group!';
                    }
                }
            
            
                if (!
$errors) {
                    
$db->query("UPDATE #__adv_groups
                                  SET adv_group_name = '"
.$db->escape($name)."',
                                      adv_group_desc = '"
.$db->escape($desc)."',
                                    adv_group_slug = '"
.$db->escape($slug)."',
                                    adv_rotate = '"
.$rotate."',
                                    status = '"
.$status."'
                                WHERE adv_group_id = "
.$id."
                                LIMIT 1"
);
                    
$messages[] = 'Advertising group updated !';
                }
            }
            
            
$db->query("SELECT * FROM #__adv_groups WHERE adv_group_id = ".$id." LIMIT 1");
            
$group $db->fetch_assoc();
        } else {
            
$errors[] = 'Invalid advertising group! Are you sure this advertising group exists!?';
        }
        
        
$tpl    VF::factory('template');
        
$tpl->menu            'adv';
        
$tpl->submenu        'adv_group';
        
$tpl->meta_title    'Admin::Advertising::Group::Add';
        
$tpl->errors        $errors;
        
$tpl->messages        $messages;
        
$tpl->group            $group;
        
$tpl->load(array('header''adv_group_edit''footer'));
        
$tpl->display();
    }
}
?>
Онлайн: 1
Реклама