<?php
// --------------------------------------------------------------------------
//
// Esvon Classifieds v.4.0
// Copyright(C), Esvon LTD, 2001-2010, All Rights Reserved.
// E-mail: hide@address.com
//
// All forms of reproduction, including, but not limited to, internet posting,
// printing, e-mailing, faxing and recording are strictly prohibited.
// One license required per site running Esvon Classifieds.
// To obtain a license for using Esvon Classifieds, please register at
// http://www.esvon.com/pg/products/p_classifieds/
//
// --------------------------------------------------------------------------
if(!defined('SITE_PATH')) die('Access denied');
require SITE_PATH.'inc/class.item_adm.php';
class SiteReviewAdm extends SiteItemAdm {
function SiteReviewAdm(){ // constructor
parent::SiteItemAdm();
$this->TBL_ITEM = hwModTable(HW_MOD,'data');
$this->ADM_TPL_PATH = HW_MOD_TPL.'rev_'; // with files prefix
$this->PAGE_URL = HW_MOD_URL.'&';
$this->FS_FILE = HW_MOD_TPL.'rev_fields.txt';
if(is_array($_POST['ch_all'])){
$s_id = '"'.implode('","', array_map('intval', $_POST['ch_all'])).'"';
$this->db->query('UPDATE '.$this->TBL_ITEM.' SET approved="0" WHERE id IN('.$s_id.')');
}
if(is_array($_POST['ch_on'])){
$s_id = '"'.implode('","', array_map('intval', $_POST['ch_on'])).'"';
$this->db->query('UPDATE '.$this->TBL_ITEM.' SET approved="1" WHERE id IN('.$s_id.')');
}
/*if(is_array($_POST['delete_img'])){
$Img_Obj = &Factory::create('Media_Image');
$Img_Obj->DB_TABLE = $this->TBL_ITEM;
$Img_Obj->DB_KEY_NAME = $this->IDX;
$v402plus = method_exists($Img_Obj, 'DeleteFiles');
if($v402plus){
$Img_Obj->SetDBKeyVal((int)$_GET['id']);
$Img_Obj->DeleteFiles($_POST['delete_img'], true);
}
else{
hwDeleteFiles($_POST['delete_img']);
// also DB update is needed
}
}*/
}
function ListRenderTpl(){
$a_v = array(
'disabled'=>'Disabled',
'approved'=>'Approved',
);
$z = array();
$z['f_type'] = GetAdmSel($a_v,$_REQUEST['f_type']);
return $z;
}
function ListSQLGet(){
$ql = parent::ListSQLGet();
$f_type = $_REQUEST['f_type'];
if($f_type=='approved') $ql.=' AND approved="1"';
elseif($f_type=='disabled') $ql.=' AND approved="0"';
return $ql;
}
function ListRenderRow(&$v){
$v['approved'] = $v['approved'] ? 'checked' : '';
}
function ListNavGet(){
return array_merge(parent::ListNavGet(), array('f_type'));
}
function ListSQLResultReview($res,&$tpl){
if(mysql_num_rows($res)==0){
$tpl->AddCell('row','','no');
return;
}
$A_LID = array();
while($v = mysql_fetch_assoc($res)){
$A_LID[$v[$this->IDX]] = $v['link_id'];
}
mysql_data_seek($res,0);
$A_CID = $this->db->two_col_assoc('SELECT link_id,catid FROM '.TBL_AD.' WHERE link_id IN('.implode(',',array_values($A_LID)).')');
$A_OUT = array();
foreach($A_LID as $rid=>$lid) $A_OUT[$rid]['cid'] = $A_CID[$lid];
return $A_OUT;
}
function ItemValidate(){
$err_msg = parent::ItemValidate();
if(!$err_msg){
$lid = $this->db->one_data('SELECT link_id FROM '.TBL_AD.' WHERE link_id='.(int)$_POST['link_id']);
if(!$lid) $err_msg = 'Incorrect {Item} ID: '.html_esc($_POST['link_id']);
}
return $err_msg;
}
/*function ItemRender(&$tpl, $w_hidden=true, $auto=true){
$a_v = parent::ItemRender($tpl, $w_hidden, $auto);
if($this->ID){
$a_v['images'] = trim($this->db->one_data('SELECT images FROM '.$this->TBL_ITEM.' WHERE '.$this->IDX.'='.$this->ID));
if($a_v['images']){
$a_img = explode("\n", $a_v['images']);
$cols = 2;
$a_v['images'] = '<table border=0><tr>';
$i = 1;
foreach($a_img as $img){
$a_v['images'].='<td align=center><a target="_blank" href="'.SITE_URL.'files/'.$img.'"><img src="'.
SITE_URL.'files/small/'.$img.'" border=0></a><br><input
type=checkbox name="delete_img[]" value="'.$img.'"> {delete}</td>';
if($i%$cols==0) $a_v['images'].='</tr><tr>';
$i++;
}
$a_v['images'].= '</tr></table>';
}
}
else $a_v['images'] = '';
return $a_v;
}
function ItemsDelete() {
$s_id = $this->ItemsDeleteSQLIds();
if(!$s_id) return;
$Img_Obj = &Factory::create('Media_Image');
$Img_Obj->DB_TABLE = $this->TBL_ITEM;
$Img_Obj->DB_KEY_NAME = $this->IDX;
$v402plus = method_exists($Img_Obj, 'DeleteFiles');
$res = $this->db->query('SELECT images FROM '.$this->TBL_ITEM." WHERE $this->IDX IN($s_id)");
while($v = mysql_fetch_assoc($res)){
$a_f = array();
if($v['images']) $a_f = explode("\n",trim($v['images']));
if($a_f){
if($v402plus) $Img_Obj->DeleteFiles($a_f);
else hwDeleteFiles($a_f);
}
}
parent::ItemsDelete();
}*/
}
// main func
$O_ADM = new SiteReviewAdm;
$O_ADM->ShowPage();
?>