if (!$_POST['orgname']) { // Where's our bloody data? header("Location: ."); exit; } else { if ($_POST['id'] && !$data->isOrgAdmin($auth->getUserID(), $_POST['id'])) { // User is not an admin of this org graceful_exit("Sorry, you are not authorized to administer that organization."); } else { if ($data->getUserID($_POST['orgname']) && strtolower($auth->getUserName()) != strtolower($_POST['orgname'])) { // Username equal to specified org name exists and is not this user graceful_exit("Sorry, you cannot name an organization with the username of another user."); } else { if ($data->getOrgID($_POST['orgname']) && $data->getOrgID($_POST['orgname'] != $_POST['id'])) { // Org name exists and is not this same org graceful_exit("Sorry, an organization with that name already exists."); } } } } if ($_POST['id']) { // Update the organization's name $data->setOrgName($_POST['id'], $_POST['orgname']); } else { // Create the organization $data->createOrg($_POST['orgname'], $auth->getUserID()); } header("Location: ."); break; default: header("Location: .");
<?php // Defines define('GRPSTATE_OPEN', 1); define('GRPSTATE_CLOSED', 2); define('GRPSTATE_HIDDEN', 3); define('GRPSTATE_INACTIVE', 4); // Load the site config require_once "config.php"; // Load utility and class includes require_once "functions.php"; require_once "data.class.php"; require_once "auth.class.php"; session_start(); // Instantiate (or retrieve from the session) our objects $data = new data($config); if (!$data) { graceful_exit("Sorry, could not instantiate the data handler."); } if (!$_SESSION['auth']) { $_SESSION['auth'] = new auth(); // auth uses the global $data if (!$_SESSION['auth']) { graceful_exit("Sorry, could not instantiate the authorization handler."); } } $auth = $_SESSION['auth'];