Вход Регистрация
Файл: adultscript-2.0.3-pro/files/admin/modules/channel/components/network_edit.php
Строк: 119
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_Admin_channel_network_edit extends VModule_Admin_channel
{
    public function 
__construct()
    {
        
parent::__construct();
    }
    
    public function 
render()
    {
        
$errors     = array();
        
$messages     = array();
        
$nmodel        VModel::load('network''channel'true);
        
$network    = array();
        
$network_id    = (isset($_GET['id'])) ? (int) trim($_GET['id']) : 0;
        
        if (
$nmodel->exists('network_id'$network_id)) {
            if (isset(
$_POST['submit-edit-network'])) {
                
$filter            VF::factory('filter');
                
$username        $filter->get('username');
                
$name            $filter->get('name');
                
$slug            $filter->get('slug');
                
$description    trim($_POST['description']);
                
$total_channels    = (int) trim($_POST['total_channels']);
                
$total_videos    = (int) trim($_POST['total_videos']);
            
                if (
$username == '') {
                    
$errors[]    = 'Network username field cannot be left blank!';
                } else {
                    
$user_id VModel::load('user''user'true)->exists('username'$username);
                    if (!
$user_id) {
                        
$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!';
                }
            
                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$network_id)) {
                        
$errors[]    = 'SLUG is already used for another channel!';
                    }
                }
            
                if (!
$errors) {
                    
$network    = array(
                        
'user_id'            => $user_id,
                        
'name'                => $name,
                        
'slug'                => $slug,
                        
'description'        => $description,
                        
'total_videos'        => $total_videos,
                        
'total_channels'    => $total_channels
                    
);
                
                    if (
$nmodel->update($network_id$network)) {
                        
$messages[]    = 'Channel network updated!';
                    } else {
                        
$errors[]    = 'Failed to update channel!';
                    }            
                }
            }
            
            
$network    $nmodel->get($network_id);
        }
        
        
$tpl                 VF::factory('template');
        
$tpl->menu            'channel';
        
$tpl->submenu        'channel_network';
        
$tpl->extramenu        'channel_network_edit';
        
$tpl->meta_title    'Admin::Network::Manage';
        
$tpl->errors        $errors;
        
$tpl->messages        $messages;
        
$tpl->network        $network;
        
$tpl->load(array('header''channel_network_edit''footer'));
        
$tpl->display();
    }
}
?>
Онлайн: 2
Реклама