<?php
class VisibilityList {
var $giftId;
var $users;
function VisibilityList($giftId)
{
global $database;
$this->giftId = (int) $giftId;
$this->users = $database->fetch("select u.id, u.name, v.giftId is not null as isVisible from gft_user u LEFT OUTER JOIN gft_visibility v ON (u.id = v.userId AND v.giftId = ".$this->giftId.")");
}
function saveVisibilityList($visible)
{
global $database;
$database->query("delete from gft_visibility where giftId = ".$this->giftId);
foreach (explode(" ", $visible) as $user) {
if (!empty($user))
$database->query("insert into gft_visibility (giftId, userId) values(".$this->giftId.", '".addslashes($user)."')");
}
return 0;
}
function getParams()
{
}
}
Controler::registerHandler("visibilityList", "display", "VisibilityList", array("id"), true);
Controler::registerHandler("editVisibilityList", "display", "VisibilityList", array("id"), true);
Controler::registerHandler("saveVisibilityList", "action", "VisibilityList", array("id", "visible"), true);
Controler::registerNextAction("saveVisibilityList", "myList");
?>