<?php /* $Id$ */ header("Content-Type: text/xml; charset=utf-8"); print "<" . "?xml version=\"1.0\" encoding=\"utf-8\" ?" . ">\n"; ?> <rss version="2.0"> <channel> <?php //----------------------------------- // First round of error checking //----------------------------------- $error = FALSE; ob_start(); // Do some checking to make sure that we have valid parts we are looking for. if (get_class($thisSite) == 'site' && slot::exists($thisSite->name)) { $site = $thisSite->name; } else { if ($thisSite) { unset($thisSite); print "The requested site does not exist. Please update your link."; $error = TRUE; } } if (!$error) { if (get_class($thisSection) == 'section') { $section = $thisSection->id; } else { if ($thisSection || $_REQUEST['section'] && !in_array($_REQUEST['section'], $thisSite->getField('sections'))) { unset($thisSection); print "The requested section does not exist. Please update your link.";
/** * Build an array of all of the sites and slots that the user * is either the owner of or an editor (has permission add, edit, and delete) of */ function allSitesSlots($user) { global $classes, $usersFutureClasses; $allsites = array(); // The user's personal site if ($user == slot::getOwner($user) || !slot::exists($user)) { $allsites[$user] = array(); $allsites[$user]['slot_name'] = $user; $allsites[$user]['slot_type'] = 'personal'; $allsites[$user]['owner_uname'] = $user; $allsites[$user]['site_exits'] = false; } // Add slots that the user is an owner of. // This will include all of the created sites as well $allsites = array_merge($allsites, $slots); // Add the sites that the user is a Site-Level Editor for. $allsites = array_merge($allsites, segue::getSiteInfoWhereUserIsSiteLevelEditor($user)); $sitesEditorOf = segue::getSiteInfoWhereUserIsSiteLevelEditor($user); $usersAllClasses = array(); if ($_SESSION[atype] == 'prof') { foreach ($classes as $n => $v) { $usersAllClasses[] = $n; } foreach ($usersFutureClasses as $n => $v) { $usersAllClasses[] = $n; } } printpre($allsites); printpre($usersAllClasses); printpre($sitesEditorOf); printpre($sitesOwnerOf); printpre($slots); $allsites = array_unique(array_merge($allsites, $usersAllClasses, $sitesOwnerOf, $sitesEditorOf, $slots)); $allGroups = group::getGroupsOwnedBy($user); $sitesInGroups = array(); foreach ($allGroups as $n => $g) { $sitesInGroups = array_unique(array_merge($sitesInGroups, group::getClassesFromName($g))); } foreach ($allsites as $n => $site) { if (!in_array($site, $sitesInGroups)) { $allsites2[] = $site; } } $allsites = array_merge($allsites2, $allGroups); asort($allsites); /* print "<pre>"; print_r($usersAllClasses); print "</pre>"; */ $sites = array(); $slots = array(); foreach ($allsites as $n => $site) { $siteObj =& new site($site); $exists = $siteObj->fetchFromDB(); if ($exists) { $sites[] = $site; } else { $slots[] = $site; } } return array($sites, $slots); }
if ($_SESSION[settings][step] == 5 && !$_REQUEST[link]) { $_SESSION[siteObj]->setField("footer", $_REQUEST[footer]); } if ($_REQUEST[copyfooter]) { $_SESSION[siteObj]->setField("header", $_SESSION[siteObj]->getField("footer")); } if ($_REQUEST[copyheader]) { $_SESSION[siteObj]->setField("footer", $_SESSION[siteObj]->getField("header")); } } if (!isset($_SESSION["settings"]) || !isset($_SESSION["siteObj"])) { // create the settings array with default values. $settings must be passed along with each link. // The array will be saved on clicking a save button. $_SESSION[settings] = array("sitename" => $_REQUEST[sitename], "add" => 0, "edit" => 0, "step" => 1, "recursiveenable" => "", "copydownpermissions" => "", "template" => "template0", "comingFrom" => $_REQUEST[comingFrom]); $_SESSION[siteObj] =& new site($_REQUEST[sitename]); if (slot::exists($_REQUEST[sitename])) { $slotObj = new slot($_REQUEST[sitename]); $_SESSION[siteObj]->setField("type", $slotObj->getField("type")); } else { if (isclass($_REQUEST[sitename])) { $_SESSION[siteObj]->setField("type", "class"); } else { if (!$_SESSION[siteObj]->getField("type") || $_SESSION[siteObj]->getField("type") == "") { $_SESSION[siteObj]->setField("type", "personal"); } } } $_SESSION[settings][className] = $_REQUEST[sitename]; if ($_REQUEST[action] == 'add_site') { $_SESSION[settings][add] = 1; $_SESSION[settings][edit] = 0;
function insertDB() { global $error; if (segue::siteExists($this->name) || slot::exists($this->name, 0)) { error("That site name, " . $this->name . ", is already in use."); } if (!ereg("^([0-9a-zA-Z_.-]{0,})\$", $this->name)) { error("Your slot name is invalid. It may only contain alphanumeric characters, '-', '_' and '.'"); } if (!$error) { // get id for owner of slot $query = "SELECT user_id FROM user WHERE user_uname = '" . addslashes($this->owner) . "'"; /* echo $query."<br />"; */ $r = db_query($query); if (!db_num_rows($r)) { return false; } $a = db_fetch_assoc($r); $owner_id = $a[user_id]; if ($this->site) { $site = "'" . addslashes($this->site) . "'"; } else { $site = "NULL"; } if ($this->assocSite) { // get id for assoc_site of slot $query = "SELECT slot_id FROM slot WHERE slot_name = '" . addslashes($this->assocSite) . "'"; /* echo $query."<br />"; */ $r = db_query($query); $a = db_fetch_assoc($r); $assocSite = "'" . addslashes($a[slot_id]) . "'"; } else { $assocSite = "NULL"; } if (preg_match('/^[0-9]*$/', $this->uploadlimit)) { $uploadLimit = $this->uploadlimit; } else { $uploadLimit = "NULL"; } if (!$this->name) { error("Slot name not specified. Please notify the administrator of the steps that took you to this point."); print "Slot name not specified. Please notify the administrator of the steps that took you to this point."; exit; } $query = "\n\t\t\t\tINSERT INTO \n\t\t\t\t\tslot \n\t\t\t\tSET \n\t\t\t\t\tFK_owner= '" . addslashes($owner_id) . "',\n\t\t\t\t\tslot_name='" . addslashes($this->name) . "',\n\t\t\t\t\tslot_type='" . addslashes($this->type) . "',\n\t\t\t\t\tFK_site=" . $site . ",\n\t\t\t\t\tFK_assocsite=" . $assocSite . ",\n\t\t\t\t\tslot_uploadlimit=" . $this->uploadlimit . "\n\t\t\t"; /* print $query; */ db_query($query); echo mysql_error(); } }
function insertDB($down = 0, $copysite = 0, $importing = 0, $keepDiscussions = 0) { $a = $this->createSQLArray(1); if (!$importing) { $a[] = "FK_createdby='" . addslashes($_SESSION[aid]) . "'"; $a[] = $this->_datafields[addedtimestamp][1][0] . "=NOW()"; $a[] = "FK_updatedby='" . addslashes($_SESSION[aid]) . "'"; } else { $a[] = "FK_createdby=" . db_get_value("user", "user_id", "user_uname='" . addslashes($this->data[addedby]) . "'"); $a[] = $this->_datafields[addedtimestamp][1][0] . "='" . addslashes($this->getField("addedtimestamp")) . "'"; $a[] = "FK_updatedby=" . db_get_value("user", "user_id", "user_uname='" . addslashes($this->data[editedby]) . "'"); $a[] = $this->_datafields[editedtimestamp][1][0] . "='" . addslashes($this->getField("editedtimestamp")) . "'"; } // insert into the site table $query = "INSERT INTO site SET " . implode(",", $a) . ";"; /* print "<br />query = $query<br />"; */ db_query($query); $this->id = lastid(); /* print "<H1>ID = ".$this->id."</H1>"; */ // in order to insert a site, the active user must own a slot // update the name for that slot if (slot::exists($this->data[name])) { $query = "UPDATE slot"; $where = " WHERE slot_name = '" . addslashes($this->data[name]) . "' AND FK_owner = '" . addslashes($_SESSION[aid]) . "'"; } else { $query = "INSERT INTO slot"; $where = ""; } $query .= " \n\t\t\tSET \n\t\t\t\tslot_name = '" . addslashes($this->data[name]) . "',\n\t\t\t\tFK_owner = '" . addslashes($_SESSION[aid]) . "',\n\t\t\t\tslot_type = '" . addslashes($this->data[type]) . "',\n\t\t\t\tFK_site = '" . addslashes($this->id) . "'" . $where; /* echo $query."<br />"; */ db_query($query); // See if there is a site hash (meaning that we are being copied). // If so, try to match our id with the hash entry for 'NEXT'. if ($GLOBALS['__site_hash']['site'] && ($oldId = array_search('NEXT', $GLOBALS['__site_hash']['site']))) { $GLOBALS['__site_hash']['site'][$oldId] = $this->name; } // the sections haven't been created yet, so we don't have to insert data[sections] for now // add new permissions entry.. force update $this->updatePermissionsDB(1); // add log entry /* log_entry("add_site",$this->name,"","","$_SESSION[auser] added ".$this->name); */ // insert down (insert sections) if ($down && $this->fetcheddown && $this->sections) { foreach (array_keys($this->sections) as $id) { // Mark our Id as the next one to set if (is_array($GLOBALS['__site_hash']['sections'])) { $GLOBALS['__site_hash']['sections'][$id] = 'NEXT'; } $this->sections[$id]->id = 0; // createSQLArray uses this to tell if we are inserting or updating $this->sections[$id]->insertDB(1, $this->name, $copysite, $importing, $keepDiscussions); } } return 1; }
$curraction = $_REQUEST['action']; //$default_uploadlimit = $userdirlimit/1048576; // if they want to delete a slot if ($curraction == 'del') { $id = $_REQUEST['id']; if ($id > 0) { // delete a slot $slotObj = new slot("", "", "", "", $id); $slotObj->delete(); $message = "Slot ID {$id} deleted successfully."; } } // if they want to add a slot... if ($curraction == 'add') { // check for errors first if (slot::exists($_REQUEST['name'])) { error("A slot with that name already exists."); } if (!$_REQUEST['name']) { error("You must enter a name."); } if (!user::userExists($_REQUEST['owner'])) { error("User, '" . $_REQUEST['owner'] . "', does not exist. Please choose an existing user."); } if (!$_REQUEST['owner']) { error("You must enter an valid owner."); } if (!is_numeric($_REQUEST['uploadlimit'])) { error("Upload Limit must be an number."); } // all good