Вход Регистрация
Файл: adultscript-2.0.3-pro/files/admin/modules/channel/components/rebuild.php
Строк: 108
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_Admin_channel_rebuild extends VModule_Admin_channel
{
    public function 
__construct()
    {
        
parent::__construct();
    }
    
    public function 
render()
    {
        
$errors     = array();
        
$messages     = array();
        
$warnings    = array();
        
        
$cmodel        VModel::load('channel''channel'true);
        
$nmodel        VModel::load('network''channel'true);
        
        
$channels    $cmodel->channels(array('c.channel_id''c.total_videos'));
        foreach (
$channels as $channel) {
            
$channel_id    = (int) $channel['channel_id'];
            
            
$this->db->query("SELECT COUNT(*) AS total_videos
                              FROM #__video
                              WHERE channel_id = "
.$channel_id."
                              AND status = 1"
);
            
$total_videos = (int) $this->db->fetch_field('total_videos');
            
$this->db->query("UPDATE #__channel
                              SET total_videos = "
.$total_videos."
                              WHERE channel_id = "
.$channel_id."
                              LIMIT 1"
);
        }
        
        
$networks    $nmodel->networks(array('n.network_id'));
        foreach (
$networks as $network) {
            
$network_id     = (int) $network['network_id'];
            
$this->db->query("SELECT SUM(total_videos) AS total_videos
                              FROM #__channel
                              WHERE network_id = "
.$network_id);
            
$total_videos = (int) $this->db->fetch_field('total_videos');
            
$this->db->query("SELECT COUNT(*) AS total_channels
                              FROM #__channel
                              WHERE network_id = "
.$network_id);
            
$total_channels = (int) $this->db->fetch_field('total_channels');
            
$this->db->query("UPDATE #__channel_networks
                              SET total_channels = "
.$total_channels.",
                                  total_videos = "
.$total_videos."
                              WHERE network_id = "
.$network_id."
                              LIMIT 1"
);            
        }
        
        
$tpl                 VF::factory('template');
        
$tpl->menu            'channel';
        
$tpl->submenu        'channel_rebuild';
        
$tpl->meta_title    'Admin::Channel::Rebuild';
        
$tpl->errors        $errors;
        
$tpl->messages        $messages;
        
$tpl->warnings        $warnings;
        
$tpl->load(array('header''channel_rebuild''footer'));
        
$tpl->display();
    }
}
?>
Онлайн: 0
Реклама