Файл: adultscript-2.0.3-pro/files/admin/modules/photo/components/flagged.php
Строк: 67
<?php
defined('_VALID') or die('Restricted Access!');
class VComponent_Admin_photo_flagged extends VModule_Admin_photo
{
public function __construct()
{
parent::__construct();
}
public function render()
{
$errors = array();
$messages = array();
$reasons = array(
1 => 'Inappropriate',
2 => 'Underage',
3 => 'Copyrighted Material',
4 => 'Not Playing',
5 => 'Other'
);
if (isset($_POST['action']) && isset($_POST['photo_id'])) {
$action = trim($_POST['action']);
$photo_id = (int) trim($_POST['photo_id']);
if ($action == 'activate' OR $action == 'suspend') {
$status = ($action == 'activate') ? 1 : 0;
$msg = ($action == 'activate') ? 'published' : 'suspended';
$this->db->query("UPDATE #__photo SET status = '".$status."' WHERE photo_id = ".$photo_id." LIMIT 1");
$album['status'] = $status;
$messages[] = 'Photo '.$msg.'!';
} elseif ($action == 'delete') {
$this->delete_photo($photo_id, $album_id);
$messages[] = 'Photo deleted!';
} else {
$errors[] = 'Invalid photo action! What exactly did you click!?';
}
}
if (isset($_POST['submit_actions'])) {
$ids = (isset($_POST['checked'])) ? (array) $_POST['checked'] : array();
$action = trim($_POST['action']);
if ($ids) {
if ($action == 'suspend' OR $action == 'activate') {
$status = ($action == 'activate') ? 1 : 0;
$msg = ($action == 'activate') ? 'published' : 'suspended';
$this->db->query("UPDATE #__photo SET status = '".$status."' WHERE photo_id IN (".implode(',', array_keys($ids)).")");
$messages[] = 'Selected photos '.$msg.'!';
} elseif ($action == 'delete') {
foreach ($ids as $photo_id) {
$this->delete_photo((int) $photo_id);
}
$messages[] = 'Selected photos deleted!';
} else {
$errors[] = 'Invalid action!';
}
} else {
$errors[] = 'Please select at least one photo!';
}
}
$page = (isset($_GET['page'])) ? (int) $_GET['page'] : 1;
$sql_count = "SELECT COUNT(*) AS total_photos
FROM #__photo AS p
WHERE p.flagged = '1'";
$total_photos = $this->db->get_field($sql_count, 'total_photos');
$pagination = VPagination::get($page, $total_photos, 20);
$sql = "SELECT p.photo_id, p.caption, p.ext, p.total_views, p.total_comments,
p.total_favorites, p.rating, p.rated_by, p.add_date, p.flagged,
p.status, p.album_id, a.title
FROM #__photo AS p
LEFT JOIN #__photo_albums AS a ON (a.album_id = p.album_id)
WHERE p.flagged = '1'
ORDER BY p.photo_id DESC
LIMIT ".$pagination['limit'];
$photos = $this->db->get_rows($sql);
$tpl = VF::factory('template');
$tpl->menu = 'photo';
$tpl->submenu = 'photo_flags';
$tpl->meta_title = 'Admin::Photo::Flagged';
$tpl->vcfg = VF::cfg('module.photo');
$tpl->errors = $errors;
$tpl->messages = $messages;
$tpl->reasons = $reasons;
$tpl->photos = $photos;
$tpl->pagination = $pagination;
$tpl->load(array('header', 'photo_flagged', 'footer'));
$tpl->display();
}
}
?>