$controller->view->menu = 'seotools'; $controller->layout = 'ajax'; $controller->set('sectionHead', 'Websites'); if ($_SERVER['REQUEST_METHOD'] == 'POST') { switch ($_POST['sec']) { case "create": $controller->createWebsite($_POST); break; case "update": $controller->updateWebsite($_POST); break; } } else { switch ($_GET['sec']) { case "Activate": $controller->__changeStatus($_GET['websiteId'], 1); $controller->listWebsites($_GET); break; case "Inactivate": $controller->__changeStatus($_GET['websiteId'], 0); $controller->listWebsites($_GET); break; case "delete": $controller->__deleteWebsite($_GET['websiteId']); $controller->listWebsites($_GET); break; case "edit": $controller->editWebsite($_GET['websiteId']); break; case "new": $controller->newWebsite($_GET);
function __changeStatus($userId, $status) { $userId = intval($userId); $sql = "update users set status={$status} where id={$userId}"; $this->db->query($sql); # deaactivate all websites under this user if (empty($status)) { $websiteCtrler = new WebsiteController(); $websiteList = $websiteCtrler->__getAllWebsites($userId); foreach ($websiteList as $websiteInfo) { $websiteCtrler->__changeStatus($websiteInfo['id'], 0); } } }