Файл: adultscript-2.0.3-pro/files/admin/modules/adv/components/sponsor_edit.php
Строк: 65
<?php
defined('_VALID') or die('Restricted Access!');
class VComponent_Admin_adv_sponsor_edit
{
public function __construct()
{
}
public function render()
{
$db = VF::factory('database');
$errors = array();
$messages = array();
$sponsor = array();
$sponsor_id = (isset($_GET['id'])) ? (int) trim($_GET['id']) : 0;
$db->query("SELECT sponsor_id FROM #__video_sponsors WHERE sponsor_id = ".$sponsor_id." LIMIT 1");
if ($db->affected_rows()) {
if (isset($_POST['submit-edit'])) {
$filter = VF::factory('filter');
$sponsor_name = $filter->get('sponsor_name');
$status = (int) trim($_POST['status']);
$adv_id = (int) trim($_POST['adv_id']);
$adv_text_id = (int) trim($_POST['adv_text_id']);
$adv_image_id = (int) trim($_POST['adv_image_id']);
$adv_videos = (isset($_POST['adv_video'])) ? (array) $_POST['adv_video'] : array();
if ($sponsor_name == '') {
$errors[] = 'Sponsor name field cannot be left blank!';
}
if (!$errors) {
$adv_video = array();
foreach ($adv_videos as $key => $value) {
$adv_video[$value] = 1;
}
if (!$adv_video) {
$adv_video = '';
}
$db->query("UPDATE #__video_sponsors
SET sponsor_name = '".$db->escape($sponsor_name)."',
status = '".$status."',
adv_id = ".$adv_id.",
adv_text_id = ".$adv_text_id.",
adv_image_id = ".$adv_image_id.",
adv_video = '".$db->escape(serialize($adv_video))."'
WHERE sponsor_id = ".$sponsor_id."
LIMIT 1");
$messages[] = 'Sponsor updated!';
}
}
$db->query("SELECT * FROM #__video_sponsors WHERE sponsor_id = ".$sponsor_id." LIMIT 1");
$sponsor = $db->fetch_assoc();
$sponsor['adv_video'] = ($sponsor['adv_video'] != '') ? unserialize($sponsor['adv_video']) : array();
}
$db->query("SELECT adv_group_id FROM #__adv_groups WHERE adv_group_slug = 'video-player' LIMIT 1");
$adv_group_id = (int) $db->fetch_field('adv_group_id');
$db->query("SELECT adv_id, adv_name FROM #__adv WHERE adv_group_id = ".$adv_group_id);
$advs = $db->fetch_rows();
$db->query("SELECT adv_id, adv_name FROM #__adv_player WHERE type = 'text' AND status = '1'");
$advs_text = $db->fetch_rows();
$db->query("SELECT adv_id, adv_name FROM #__adv_player WHERE type = 'image' AND status = '1'");
$advs_image = $db->fetch_rows();
$db->query("SELECT adv_id, adv_name, position FROM #__adv_player WHERE type = 'video' AND status = '1'");
$advs_video = $db->fetch_rows();
$tpl = VF::factory('template');
$tpl->menu = 'adv';
$tpl->submenu = 'sponsor_add';
$tpl->meta_title = 'Admin::Advertising::Sponsor::Edit';
$tpl->errors = $errors;
$tpl->messages = $messages;
$tpl->advs = $advs;
$tpl->advs_text = $advs_text;
$tpl->advs_image = $advs_image;
$tpl->advs_video = $advs_video;
$tpl->sponsor = $sponsor;
$tpl->load(array('header', 'adv_sponsor_edit', 'footer'));
$tpl->display();
}
}