Вход Регистрация
Файл: adultscript-2.0.3-pro/files/admin/modules/video/components/flags.php
Строк: 62
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_Admin_video_flags extends VModule_Admin_video
{
    protected 
$db;
    public function 
__construct()
    {
        
$this->db        = &VF::factory('database');
    }
    
    public function 
render()
    {
        
$tpl        = VF::factory('template');
        
$video_id    = (isset($_GET['id'])) ? (int) trim($_GET['id']) : 0;
        
$errors        = array();
        
$messages    = array();
        
        
$reasons    = array(
            
1 => 'Inappropriate',
            
2 => 'Underage',
            
3 => 'Copyrighted Material',
            
4 => 'Not Playing',
            
5 => 'Other'        
        
);
        
        
$errors     = array();
        
$messages   = array();
        if (isset(
$_POST['action']) && isset($_POST['flag_id'])) {
            
$action = trim($_POST['action']);
            
$flag_id  = (int) trim($_POST['flag_id']);
            if (
$flag_id) {
                if (
$action == 'delete') {
                    
$this->db->query("DELETE FROM #__video_flags WHERE video_id = ".$video_id." AND flag_id = ".$flag_id." LIMIT 1");
                    
$messages[] = 'Flag removed!';
                } else {
                    
$errors[] = 'Invalid action! What exactly did you click!?';
                }
            } else {
                
$errors[]   = 'Invalid static page id! Are you sure this report exists!?';
            }
        }

        if (isset(
$_POST['submit_actions'])) {
            
$ids    = $this->get_checkbox_ids();
            
$action = trim($_POST['action']);
            if (
$ids) {
                if (
$action == 'delete') {
                    
$this->db->query("DELETE FROM #__video_flags WHERE video_id = ".$video_id." AND flag_id IN (".implode(',', $ids).")");
                    
$messages[] = 'Selected flags removed!';
                } else {
                    
$errors[] = 'Invalid action! What exactly did you select!?';
                }
            } else {
                
$errors[] = 'You must select at least one report!';
            }
        }
        
        if (isset(
$_GET['a'])) {
              
$action = trim($_GET['a']);
              switch (
$action) {
                  case 
'unflag':
                      
$this->db->query("UPDATE #__video SET flagged = '0' WHERE video_id = ".$video_id." LIMIT 1");
                      
$this->db->query("DELETE FROM #__video_flags WHERE video_id = ".$video_id);
                      
$messages[] = 'Video unflagged!';
                      break;
                  case 
'delete':
                      
$this->delete_video($video_id);
                      
$messages[] = 'Video deleted!';
                      break;
                  case 
'suspend':
                  case 
'publish':
                      
$status     = ($action == 'publish') ? 1 : 0;
                      
$msg        = ($action == 'publish') ? 'published' : 'suspended';
                      
$this->db->query("UPDATE #__video
                                        SET status = '"
.$status."'
                                        WHERE video_id = "
.$video_id."
                                        LIMIT 1"
);
                      
$messages[] = 'Video '.$msg.'!';
                      break;
                  default:
                      
$errors[] = 'Invalid action! What exactly did you click!?';
              }
        }

        if (
$video_id) {
            
$page                = (isset($_GET['page'])) ? (int) trim($_GET['page']) : 1;
            
$sql_count            = "SELECT COUNT(*) AS total_flags
                                   FROM #__video_flags
                                   WHERE video_id = "
.$video_id;
              
$total_flags           = $this->db->get_field($sql_count, 'total_flags');
              
$tpl->pagination    = VPagination::get($page, $total_flags, 10);
              
$sql                = "SELECT vf.*, u.username
                                     FROM #__video_flags AS vf
                                     LEFT JOIN #__user AS u ON (u.user_id = vf.user_id)
                                     WHERE vf.video_id = "
.$video_id."
                                     ORDER BY vf.flag_id DESC
                                     LIMIT "
.$tpl->pagination['limit'];
              
$tpl->flags         = $this->db->get_rows($sql);
              
$sql                = "SELECT status, flagged
                                     FROM #__video
                                     WHERE video_id = "
.$video_id."
                                     LIMIT 1"
;
              
$tpl->video            = $this->db->get_assoc($sql);
        }
    
        
$tpl->menu                = 'video';
        
$tpl->submenu            = 'video_flags';
        
$tpl->meta_title        = 'Admin::Video::View::Flags';
        
$tpl->vcfg                = VF::cfg('module.video');
        
$tpl->errors            = $errors;
        
$tpl->messages            = $messages;
        
$tpl->video_id            = $video_id;
        
$tpl->reasons            = $reasons;
        
$tpl->load(array('header', 'video_flags', 'footer'));
        
$tpl->display();
    }
    
    private function 
get_checkbox_ids()
    {
        
$ids = array();
        foreach (
$_POST as $key => $value) {
            if (
strpos($key, 'checkbox_flag_') !== FALSE) {
                
$ids[] = (int) str_replace('checkbox_flag_', '', $key);
            }
        }

        return 
$ids;
    }
}
?>
Онлайн: 2
Реклама