- <?php
- /**
- * <b>Database Class : Modify</b><br />
- * Provides all database modify methods for various uses, and connections to the database.
- * @author Kristen O'Brien <kristen_paristemi-com>
- * @copyright Copyright 2004, Kristen O'Brien
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @link http://www.paristemi.com Paristemi Main Site
- * @package paristemi
- * @subpackage paristemi_database_layer
- * @since Build 0.5
- * @version Build 0.7
- * @filesource
- */
- /**
- * <b>Database Class : Modify</b><br />
- * Provides all database modify methods for various uses, and connections to the database.
- * @author Kristen O'Brien <kristen_paristemi-com>
- * @copyright Copyright 2004, Kristen O'Brien
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @link http://www.paristemi.com Paristemi Main Site
- * @package paristemi
- * @subpackage paristemi_database_layer
- * @since Build 0.5
- * @version Build 0.7
- * @filesource
- */
- class DatabaseModify {
- var $Link;
-
- function DatabaseModify() {
- $this->Link = mysql_connect($GLOBALS['DATABASE_SERVER'],
- $GLOBALS['DATABASE_USER'],
- $GLOBALS['DATABASE_PASS'])
- or $this->Error('Unable to connect to db server.');
- mysql_select_db($GLOBALS['DATABASE_NAME'])
- or $this->Error('Unable to select db');
- }
-
-
- //Only needed if you want to reconnect to a different database. Otherwise
- //the call to mysql_close() occurs when the connection dies.
-
- function Close() {
- mysql_close($this->Link);
- }
-
-
- //For internal use, make sure to type $this->Error('some string');
-
- function Error($str) {
- die($str);
- }
-
- function &SetCalItemData(&$title, &$start, &$stop, &$seriesid,
- &$subseriesid, &$type, &$locationid, &$contactid,
- &$contactemail, &$audioid, &$description, &$notes,
- &$rec, &$recday, &$recend)
- {
- $title = stripslashes($title);
- $type = stripslashes($type);
- $description = stripslashes($description);
- $notes = stripslashes($notes);
- $result = mysql_query("insert into Instance
- (Title, Start, Stop, SeriesID, SubSeriesID, Type,
- LocationID, ContactID, ContactEmail, AudioID, Description,
- Notes, Recursive, RecDay, RecEnd)
- values ('$title', '$start', '$stop', '$seriesid',
- '$subseriesid', '$type', '$locationid', '$contactid',
- '$contactemail', '$audioid', '$description', '$notes',
- '$rec', '$recday', '$recend');")
- or $this->Error('Nothing posted?');
-
-
- $result2 = mysql_query("update Announcement
- set Created = NOW()
- where ID = 2;")
- or $this->Error('Nothing posted6?');
-
- return $result;
- }
-
- function &SetDevotionalItemData(&$title,&$text,&$keyverse,&$verses,
- &$showcase,&$prayer,&$authorid,&$showitem) {
- $result = mysql_query("insert into Devotional
- (Title,Text,KeyVerse,Verses,
- Prayer,AuthorID,ShowItem)
- values('$title','$text','$keyverse','$verses',
- '$prayer',$authorid,$showitem);");
- if($showcase) {
- $result2 = mysql_query("SELECT max(id) FROM Devotional;");
- $row = mysql_fetch_array($result2, MYSQL_ASSOC);
- foreach ($row as $item) { $devoid = $item; }
- $result3 = $this->IncreaseShowcase('Devotional',$devoid);
- }
- return ($result && $result2 && $result3);
- }
-
- function &SetAnnouncementItemData(&$title,&$desc,&$category,$enddate,&$contactid) {
- $result = mysql_query("insert into Announcement
- (Title,Description,Category,EndDate,ContactID,Created)
- values('$title','$desc','$category',
- '$enddate','$contactid',NOW());");
- return $result;
- }
-
- function &SetAudioItemData(&$title, &$link, &$linkdl, &$instanceid,
- &$showmultimedia, &$category, &$book,
- &$startverse, &$stopverse, &$topic, &$description)
- {
- $title = stripslashes($title);
- $topic = stripslashes($topic);
- $description = stripslashes($description);
- $result = mysql_query("insert into Audio
- (Title, Category, LinkStream, LinkDownload, Description, ShowMultimedia,
- BookReference, StartVerse, StopVerse, Topic)
- values ('$title', '$category', '$link', '$linkdl',
- '$description', '$showmultimedia',
- '$book', '$startverse', '$stopverse', '$topic');");
- //or $this->Error('Nothing posted?');
-
- $result4 = mysql_query("SELECT max(id) FROM Audio;")
- or $this->Error('Nothing found4?');
- $row = mysql_fetch_array($result4, MYSQL_ASSOC);
- foreach ($row as $item) { $audioid = $item; }
-
- echo $audioid." ".$instanceid;
-
- $result5 = mysql_query("update Instance
- set AudioID = $audioid
- where ID = $instanceid;")
- or $this->Error('Nothing posted5?');
-
- $result6 = mysql_query("update Announcement
- set Created = NOW()
- where ID = 1;")
- or $this->Error('Nothing posted6?');
-
- return ($result);
- }
-
- function IncreaseShowcase($tablename,$newitemid=0)
- {
- $result = mysql_query("SELECT ID FROM $tablename WHERE Showcase = 1;");
- $row = mysql_fetch_array($result, MYSQL_ASSOC);
- if($row != null) {
- foreach($row as $item) { $itemid = $item; }
- if($newitemid == 0) {
- $result2 = mysql_query("SELECT MIN(ID) FROM $tablename
- WHERE Showcase = 0 AND ID > $itemid;");
- $row = mysql_fetch_array($result2, MYSQL_ASSOC);
- foreach($row as $item) { $newitemid = $item; }
- }
- $result3 = mysql_query("UPDATE $tablename SET Showcase = 0 WHERE ID = $itemid;");
- }
- $result4 = mysql_query("UPDATE $tablename
- SET Showcase = 1, ShowItem = 1
- WHERE ID = $newitemid;");
- return ($result4);
- }
- }
- ?>