From 0077cb99704fe863cf731fc5cab792af2ede96c2 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Sun, 17 Apr 2011 20:13:07 -0400 Subject: Backporting retarded amount of changes outside of version control --- admin/newsreel/functions.php | 318 +++++++++++++++++++++---------------------- admin/newsreel/index.php | 92 ++++++------- admin/newsreel/updateDB.php | 87 ++++++------ 3 files changed, 253 insertions(+), 244 deletions(-) (limited to 'admin/newsreel') diff --git a/admin/newsreel/functions.php b/admin/newsreel/functions.php index 6bde17c..f8cb759 100644 --- a/admin/newsreel/functions.php +++ b/admin/newsreel/functions.php @@ -1,160 +1,160 @@ - - - -. - */ - - define(MAX_SLIDES, 6); - - function EditOrder(){ - - global $db; - ?> -
- - - - - -
News Reel Order
- - Click and drag on a slide to change the order. Wait for confirmation indicating the changes have been saved. -
-= MAX_SLIDES){ - ReportError("There are already 6 active slides. You must disable one in order to enable another."); - PageRedirect(3,"?op=newsreel"); - return; - } - $weight = $lastspot+1; - $db->Query("UPDATE `bayonet_newsreel` SET `visible` = 1, `weight` = '$weight' WHERE `slide_id` = '$slide_id' LIMIT 1"); - PageRedirect(0,"?op=newsreel"); - } - - function DisableSlide($slide_id){ - - global $db; - $result = $db->Query("SELECT `weight` FROM `bayonet_newsreel` WHERE `slide_id` = '$slide_id' LIMIT 1"); - $slide = $db->FetchRow($result); - - $oldWeight = $slide['weight']; - - if($oldWeight < MAX_SLIDES){ - $total = getNumOfActive(); - for($i=$oldWeight+1; $i<=$total; $i++){ - //echo "Change Weight:".$i." to ".($i-1)."
"; - $new = $i-1; - $db->Query("UPDATE `bayonet_newsreel` SET `weight` = '$new' WHERE `weight` = '$i' LIMIT 1"); - } - } - - $db->Query("UPDATE `bayonet_newsreel` SET `visible` = 0, `weight` = 0 WHERE `slide_id` = '$slide_id' LIMIT 1"); - PageRedirect(0,"?op=newsreel"); - } - - function ListInactive(){ - - global $db; - echo "

Disabled Slides

"; - $result = $db->Query("SELECT `slide_id`, `title`, `src` FROM `bayonet_newsreel` WHERE `visible` = 0 ORDER BY `slide_id` DESC"); - $row = $db->Fetch($result); - - foreach($row as $slide){ - echo PrintSlide($slide); - echo "


"; - } - } - - function PrintSlide($slide){ - echo "{$slide['title']}"; - if(file_exists("../modules/newsreel/slides/{$slide['src']}") && $slide['src'] != ""){ - echo "
"; - } - } - - function GetLastPosition(){ - - global $db; - $result = $db->Query("SELECT `weight` FROM `bayonet_newsreel` WHERE `visible` = 1 ORDER BY `weight` DESC LIMIT 1"); - $row = $db->FetchRow($result); - - return $row['weight']; - } - - function getNumOfActive(){ - global $db; - $result = $db->Query("SELECT `slide_id` FROM `bayonet_newsreel` WHERE `visible` = 1"); - return $db->Rows($result); - } - - + + + +. + */ + + define(MAX_SLIDES, 6); + + function EditOrder(){ + + global $db; + ?> +
+ + + + + +
News Reel Order
+ + Click and drag on a slide to change the order. Wait for confirmation indicating the changes have been saved. +
+= MAX_SLIDES){ + ReportError("There are already 6 active slides. You must disable one in order to enable another."); + PageRedirect(3,"?op=newsreel"); + return; + } + $weight = $lastspot+1; + $db->Query("UPDATE `bayonet_newsreel` SET `visible` = 1, `weight` = '$weight' WHERE `slide_id` = '$slide_id' LIMIT 1"); + PageRedirect(0,"?op=newsreel"); + } + + function DisableSlide($slide_id){ + + global $db; + $result = $db->Query("SELECT `weight` FROM `bayonet_newsreel` WHERE `slide_id` = '$slide_id' LIMIT 1"); + $slide = $db->FetchRow($result); + + $oldWeight = $slide['weight']; + + if($oldWeight < MAX_SLIDES){ + $total = getNumOfActive(); + for($i=$oldWeight+1; $i<=$total; $i++){ + //echo "Change Weight:".$i." to ".($i-1)."
"; + $new = $i-1; + $db->Query("UPDATE `bayonet_newsreel` SET `weight` = '$new' WHERE `weight` = '$i' LIMIT 1"); + } + } + + $db->Query("UPDATE `bayonet_newsreel` SET `visible` = 0, `weight` = 0 WHERE `slide_id` = '$slide_id' LIMIT 1"); + PageRedirect(0,"?op=newsreel"); + } + + function ListInactive(){ + + global $db; + echo "

Disabled Slides

"; + $result = $db->Query("SELECT `slide_id`, `title`, `src` FROM `bayonet_newsreel` WHERE `visible` = 0 ORDER BY `slide_id` DESC"); + $row = $db->Fetch($result); + + foreach($row as $slide){ + echo PrintSlide($slide); + echo "


"; + } + } + + function PrintSlide($slide){ + echo "{$slide['title']}"; + if(file_exists("../modules/newsreel/slides/{$slide['src']}") && $slide['src'] != ""){ + echo "
"; + } + } + + function GetLastPosition(){ + + global $db; + $result = $db->Query("SELECT `weight` FROM `bayonet_newsreel` WHERE `visible` = 1 ORDER BY `weight` DESC LIMIT 1"); + $row = $db->FetchRow($result); + + return $row['weight']; + } + + function getNumOfActive(){ + global $db; + $result = $db->Query("SELECT `slide_id` FROM `bayonet_newsreel` WHERE `visible` = 1"); + return $db->Rows($result); + } + + ?> \ No newline at end of file diff --git a/admin/newsreel/index.php b/admin/newsreel/index.php index 0b97deb..18a239d 100644 --- a/admin/newsreel/index.php +++ b/admin/newsreel/index.php @@ -1,46 +1,46 @@ -. - */ - -if(!defined("ADMIN_FILE")) -{ - die("Access denied."); -} - -include $basedir.'newsreel/functions.php'; -?> -

- Manage News Reel

- -Add/Edit/Delete needs to be completed. - - - - - -
- -
+. + */ + +if(!defined("ADMIN_FILE")) +{ + die("Access denied."); +} + +include $basedir.'newsreel/functions.php'; +?> +

- Manage News Reel

+ -Add/Edit/Delete needs to be completed. + + + + + +
+ +
diff --git a/admin/newsreel/updateDB.php b/admin/newsreel/updateDB.php index f4031a2..cd1a311 100644 --- a/admin/newsreel/updateDB.php +++ b/admin/newsreel/updateDB.php @@ -1,40 +1,49 @@ -Connect( - $config['sql']['hostname'], - $config['sql']['username'], - $config['sql']['password'] - ); -$db->Select_db($config['sql']['database']); - -if ($action == "updateReelOrder"){ - - $listingCounter = 1; - foreach ($updateRecordsArray as $recordIDValue) { - - $db->Query("UPDATE `bayonet_newsreel` SET `weight` = '$listingCounter' WHERE `slide_id` = '$recordIDValue'"); - $listingCounter = $listingCounter + 1; - } - echo ""; -/* - echo '
';
-	print_r($updateRecordsArray);
-	echo '
'; - echo 'If you refresh the page, you will see that records will stay just as you modified.'; -*/ -} -else{ - echo ""; -} -date_default_timezone_set("America/New_York"); -echo " Updated at ".date("g:i:s a", time()); +Connect($config['sql']['hostname'], $config['sql']['username'], $config['sql']['password']); +$db->Select_db($config['sql']['database']); + +/*----------------------------- */ + +$action = $_POST['action']; +$updateRecordsArray = $_POST['recordsArray']; + +if ($action == "updateReelOrder"){ + + $listingCounter = 1; + foreach ($updateRecordsArray as $recordIDValue) { + + $db->Query("UPDATE `bayonet_newsreel` SET `weight` = '$listingCounter' WHERE `slide_id` = '$recordIDValue'"); + $listingCounter = $listingCounter + 1; + } + echo ""; +/* + echo '
';
+	print_r($updateRecordsArray);
+	echo '
'; + echo 'If you refresh the page, you will see that records will stay just as you modified.'; +*/ +} +else{ + echo ""; +} +date_default_timezone_set("America/New_York"); +echo " Updated at ".date("g:i:s a", time()); ?> \ No newline at end of file -- cgit