Вход Регистрация
Файл: adultscript-2.0.3-pro/files/admin/modules/channel/components/network_add.php
Строк: 108
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_Admin_channel_network_add extends VModule_Admin_channel
{
    public function 
__construct()
    {
        
parent::__construct();
    }
    
    public function 
render()
    {
        
$errors     = array();
        
$messages     = array();
        
$nmodel        VModel::load('network''channel'true);
        
$network    = array(
            
'username'        => '',
            
'user_id'        => 0,
            
'name'            => '',
            
'slug'            => '',
            
'description'    => ''
        
);
        
        if (isset(
$_POST['submit-add-network'])) {
            
$filter            VF::factory('filter');
            
$username        $filter->get('username');
            
$name            $filter->get('name');
            
$slug            $filter->get('slug');
            
$description    trim($_POST['description']);
            
            if (
$username == '') {
                
$errors[]    = 'Network username field cannot be left blank!';
            } else {
                if (
$user_id VModel::load('user''user'true)->exists('username'$username)) {
                    
$network['user_id']        = $user_id;
                    
$network['username']    = $username;
                } else {
                    
$errors[]    = 'Invalid username!';
                }
            }

            if (
$name == '') {
                
$errors[] = 'Network name field cannot be left blank!';
            } elseif (!
VValid::length($name2100)) {
                
$errors[] = 'Network name can contain maximum 100 characters!';
            } else {
                
$network['name']    = $name;
            }
            
            if (
$slug == '') {
                
$errors[] = 'Network SLUG field cannot be left blank!';
            } elseif (!
VValid::length($slug2100)) {
                
$errors[] = 'Network SLUG can contain maximum 16 characters!';
            } elseif (!
VValid::slug($slug)) {
                
$errors[] = 'Network SLUG can contain only lowercase letters, numbers and dashes!';
            } else {
                if (
$nmodel->exists('slug'$slug)) {
                    
$errors[]    = 'SLUG is already used for another channel!';
                } else {
                    
$network['slug']    = $slug;
                }
            }
            
            
$network['description']        = $description;

            if (!
$errors) {
                if (
$network_id $nmodel->add($network)) {
                    
$messages[]    = 'Channel network added!';
                } else {
                    
$errors[]    = 'Failed to create channel!';
                }            
            }
        }
        
        
$tpl                 VF::factory('template');
        
$tpl->menu            'channel';
        
$tpl->submenu        'channel_network';
        
$tpl->extramenu        'channel_network_add';
        
$tpl->meta_title    'Admin::Network::Add';
        
$tpl->errors        $errors;
        
$tpl->messages        $messages;
        
$tpl->network        $network;
        
$tpl->load(array('header''channel_network_add''footer'));
        
$tpl->display();
    }
}
?>
Онлайн: 0
Реклама