Commit 7df8ef5f9b6e57a3a6f13b70b71ccf855306ecc3
1 parent
832b7be8
added support for active news items
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1847 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
6 changed files
with
49 additions
and
14 deletions
lib/dashboard/DashboardNews.inc
| ... | ... | @@ -5,7 +5,7 @@ require_once("$default->fileSystemRoot/lib/documentmanagement/PhysicalDocumentMa |
| 5 | 5 | /** |
| 6 | 6 | * $Id$ |
| 7 | 7 | * |
| 8 | - * Represents a dahsboard news item. | |
| 8 | + * Represents a dashboard news item. | |
| 9 | 9 | * |
| 10 | 10 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
| 11 | 11 | * |
| ... | ... | @@ -52,6 +52,10 @@ class DashboardNews { |
| 52 | 52 | * The maximum allowable height of an image |
| 53 | 53 | */ |
| 54 | 54 | var $iMaxImageHeight = 40; |
| 55 | + /** | |
| 56 | + * Is this news item active | |
| 57 | + */ | |
| 58 | + var $bActive; | |
| 55 | 59 | |
| 56 | 60 | /** |
| 57 | 61 | * Constructs a news item |
| ... | ... | @@ -199,6 +203,22 @@ class DashboardNews { |
| 199 | 203 | } |
| 200 | 204 | |
| 201 | 205 | /** |
| 206 | + * Retrieve the active status | |
| 207 | + */ | |
| 208 | + function getActive() { | |
| 209 | + return $this->bActive; | |
| 210 | + } | |
| 211 | + | |
| 212 | + /** | |
| 213 | + * Set the active status | |
| 214 | + * | |
| 215 | + * @param boolean new active status | |
| 216 | + */ | |
| 217 | + function setActive($bNewActive) { | |
| 218 | + $this->bActive = $bNewActive; | |
| 219 | + } | |
| 220 | + | |
| 221 | + /** | |
| 202 | 222 | * Retrieve the maximum image width |
| 203 | 223 | */ |
| 204 | 224 | function getMaxImageWidth() { |
| ... | ... | @@ -274,9 +294,9 @@ class DashboardNews { |
| 274 | 294 | //if the id >= 0, then the object has already been created |
| 275 | 295 | if ($this->iId < 0) { |
| 276 | 296 | $sql = $default->db; |
| 277 | - $result = $sql->query("INSERT INTO $default->owl_news_table (synopsis, body, rank, image, image_size, image_mime_type_id) " . | |
| 297 | + $result = $sql->query("INSERT INTO $default->owl_news_table (synopsis, body, rank, image, image_size, image_mime_type_id, active) " . | |
| 278 | 298 | "VALUES ('" . addslashes($this->sSynopsis) . "', '" . addslashes($this->sBody) . "', $this->iRank, " . |
| 279 | - "'" . addslashes($this->sImage) . "', $this->iImageSize, $this->iImageMimeTypeID)"); | |
| 299 | + "'" . addslashes($this->sImage) . "', $this->iImageSize, $this->iImageMimeTypeID, " . ($this->bActive ? "1" : "0") . ")"); | |
| 280 | 300 | if ($result) { |
| 281 | 301 | //set the current news item primary key |
| 282 | 302 | $this->iId = $sql->insert_id(); |
| ... | ... | @@ -302,11 +322,21 @@ class DashboardNews { |
| 302 | 322 | "rank = $this->iRank, " . |
| 303 | 323 | "image = '" . addslashes($this->sImage) . "', " . |
| 304 | 324 | "image_size = $this->iImageSize " . |
| 305 | - ($this->iImageMimeTypeID ? ", image_mime_type_id = $this->iImageMimeTypeID " : "") . | |
| 325 | + ($this->iImageMimeTypeID ? ", image_mime_type_id = $this->iImageMimeTypeID " : " ") . | |
| 306 | 326 | "WHERE id = $this->iId"; |
| 327 | + | |
| 307 | 328 | $result = $sql->query($sQuery); |
| 308 | 329 | if ($result) { |
| 309 | - return true; | |
| 330 | + if ($this->bActive) { | |
| 331 | + // we're setting this entry to active, so set all the others to inactive | |
| 332 | + $sql->query("UPDATE $default->owl_news_table SET active=0"); | |
| 333 | + // now set our entry to active | |
| 334 | + $sql->query("UPDATE $default->owl_news_table SET active=1 where id=$this->iId"); | |
| 335 | + } else { | |
| 336 | + // set this to inactive | |
| 337 | + $sql->query("UPDATE $default->owl_news_table SET active=0 where id=$this->iId"); | |
| 338 | + } | |
| 339 | + return true; | |
| 310 | 340 | } |
| 311 | 341 | return false; |
| 312 | 342 | } |
| ... | ... | @@ -350,6 +380,7 @@ class DashboardNews { |
| 350 | 380 | "mimetypeid" => $sql->f("image_mime_type_id") ); |
| 351 | 381 | $oDashboardNews = & new DashboardNews(stripslashes($sql->f("synopsis")), stripslashes($sql->f("body")), $sql->f("rank"), $aImage); |
| 352 | 382 | $oDashboardNews->iId = $iNewsID; |
| 383 | + $oDashboardNews->setActive($sql->f("active")); | |
| 353 | 384 | return $oDashboardNews; |
| 354 | 385 | } |
| 355 | 386 | return false; | ... | ... |
presentation/lookAndFeel/knowledgeTree/administration/news/addNewsBL.php
| ... | ... | @@ -29,6 +29,7 @@ if (checkSession()) { |
| 29 | 29 | if ($fStore) { |
| 30 | 30 | // construct the news object |
| 31 | 31 | $oDashboardNews = new DashboardNews($fSynopsis, $fBody, $fRank); |
| 32 | + $oDashboardNews->setActive($fActive); | |
| 32 | 33 | |
| 33 | 34 | if (isset($fSynopsis) && isset($fBody) && isset($fRank)) { |
| 34 | 35 | // if we have a new image | ... | ... |
presentation/lookAndFeel/knowledgeTree/administration/news/editNewsBL.php
| ... | ... | @@ -41,6 +41,7 @@ if (checkSession()) { |
| 41 | 41 | if ($oDashboardNews->getRank() <> $fRank) { |
| 42 | 42 | $oDashboardNews->setRank($fRank); |
| 43 | 43 | } |
| 44 | + $oDashboardNews->setActive($fActive); | |
| 44 | 45 | // if we have a new image |
| 45 | 46 | if (strlen($_FILES['fImage']['name']) > 0) { |
| 46 | 47 | // return the size of the image | ... | ... |
presentation/lookAndFeel/knowledgeTree/administration/news/newsUI.inc
| ... | ... | @@ -30,16 +30,16 @@ function renderErrorMessage($sErrorMessage) { |
| 30 | 30 | */ |
| 31 | 31 | function renderNewsTable() { |
| 32 | 32 | global $default; |
| 33 | - $sQuery = "SELECT id, synopsis, IF(LENGTH(body) > 25, CONCAT(LEFT(body,25),'...'), body) AS body, rank, IF(LENGTH(image)>0, 'yes', 'no') as image, 'Edit' AS edit, 'Preview' AS preview, 'Delete' AS del " . | |
| 33 | + $sQuery = "SELECT id, synopsis, IF(LENGTH(body) > 25, CONCAT(LEFT(body,25),'...'), body) AS body, rank, IF(LENGTH(image)>0, 'yes', 'no') as image, active, 'Edit' AS edit, 'Preview' AS preview, 'Delete' AS del " . | |
| 34 | 34 | "FROM $default->owl_news_table ORDER BY rank ASC"; |
| 35 | - $aColumns = array("synopsis", "body", "rank", "image", "edit", "preview", "del"); | |
| 36 | - $aColumnHeaders = array("Synopsis", "Body", "Rank", "Image"); | |
| 37 | - $aColumnTypes = array(1,1,1,1,3,3,3); | |
| 35 | + $aColumns = array("synopsis", "body", "rank", "image", "active", "edit", "preview", "del"); | |
| 36 | + $aColumnHeaders = array("Synopsis", "Body", "Rank", "Image", "Active"); | |
| 37 | + $aColumnTypes = array(1,1,1,1,2,3,3,3); | |
| 38 | 38 | $aDBColumnArray = array("id"); |
| 39 | 39 | $aQueryStringVariableNames = array("fNewsID"); |
| 40 | - $aLinkURLs = array(4=> "$default->rootUrl/control.php?action=editNews", | |
| 41 | - 5=> "$default->rootUrl/control.php?action=previewNews", | |
| 42 | - 6=> "$default->rootUrl/control.php?action=removeNews"); | |
| 40 | + $aLinkURLs = array(5=> "$default->rootUrl/control.php?action=editNews", | |
| 41 | + 6=> "$default->rootUrl/control.php?action=previewNews", | |
| 42 | + 7=> "$default->rootUrl/control.php?action=removeNews"); | |
| 43 | 43 | |
| 44 | 44 | $oPatternTableSqlQuery = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnHeaders, "100%", $aLinkURLs,$aDBColumnArray,$aQueryStringVariableNames); |
| 45 | 45 | $oPatternTableSqlQuery->setTableHeading("Dashboard News"); |
| ... | ... | @@ -77,6 +77,7 @@ function renderEditAddNewsForm($oDashboardNews, $bUpdate) { |
| 77 | 77 | $sToRender .= "<tr><td>Body:</td><td><textarea name=\"fBody\" cols=\"35\" rows=\"10\">" . ($oDashboardNews ? $oDashboardNews->getBody() : "") . "</textarea></td></tr>"; |
| 78 | 78 | $sToRender .= "<tr><td>Rank:</td><td><input type=\"text\" name=\"fRank\" value=\"" . ($oDashboardNews ? $oDashboardNews->getRank() : "") . "\"></td></tr>"; |
| 79 | 79 | $sToRender .= "<tr><td>Image:</td><td><input type=\"file\" name=\"fImage\"></td></tr>"; |
| 80 | + $sToRender .= "<tr><td>Active:</td><td><input type=\"checkbox\" name=\"fActive\" " . ($oDashboardNews ? ($oDashboardNews->getActive() ? "checked" : "") : "") . "\"></td></tr>"; | |
| 80 | 81 | |
| 81 | 82 | if ($bUpdate) { |
| 82 | 83 | $sToRender .= "<input type=\"hidden\" name=\"fNewsID\" value=\"" . $oDashboardNews->getID() . "\">"; | ... | ... |
presentation/lookAndFeel/knowledgeTree/dashboardUI.inc
| ... | ... | @@ -150,7 +150,7 @@ function renderDashboardNews() { |
| 150 | 150 | global $default; |
| 151 | 151 | |
| 152 | 152 | // retrieve all news items |
| 153 | - $aDashboardNews = DashboardNews::getList(); | |
| 153 | + $aDashboardNews = DashboardNews::getList("active=1"); | |
| 154 | 154 | |
| 155 | 155 | $sToRender .= "\t\t\t<table border=\"0\" width=\"100%\">\n"; |
| 156 | 156 | // the main news item | ... | ... |
sql/tables.sql