[pLog-svn] r2504 - plog/trunk/class/dao
oscar at devel.plogworld.net
oscar at devel.plogworld.net
Wed Sep 21 19:38:46 GMT 2005
Author: oscar
Date: 2005-09-21 19:38:45 +0000 (Wed, 21 Sep 2005)
New Revision: 2504
Modified:
plog/trunk/class/dao/mylinks.class.php
plog/trunk/class/dao/mylinkscategories.class.php
Log:
added code for updating link categories correctly
Modified: plog/trunk/class/dao/mylinks.class.php
===================================================================
--- plog/trunk/class/dao/mylinks.class.php 2005-09-21 19:16:18 UTC (rev 2503)
+++ plog/trunk/class/dao/mylinks.class.php 2005-09-21 19:38:45 UTC (rev 2504)
@@ -160,6 +160,9 @@
*/
function updateMyLink( &$myLink )
{
+ // get the previous version of this link before saving it
+ $prevVersion = $this->getMyLink( $myLink->getId());
+
$result = $this->update( $myLink );
if( !$result ) {
@@ -169,9 +172,23 @@
// mark the corresponding link categories as modified now
$linkCategories = new MyLinksCategories();
$linkCategories->updateCategoryModificationDate( $myLink->getCategoryId());
-
+ // clean the cache
$this->_cache->removeData( $myLink->getId(), CACHE_MYLINKS );
- $this->_cache->removeData( "all", CACHE_MYLINKS_ALL );
+ $this->_cache->removeData( $myLink->getBlogId(), CACHE_MYLINKS_ALL );
+ // and update the link category counters
+ include_once( PLOG_CLASS_PATH."class/dao/mylinkscategories.class.php" );
+ $linkCategories = new MyLinksCategories();
+ if( $prevVersion->getCategoryId() != $myLink->getCategoryId()) {
+ // add one to the new category
+ $newCategory = $myLink->getMyLinkCategory();
+ $newCategory->setNumLinks( $newCategory->getNumLinks() + 1 );
+ // remove one from the old category
+ $oldCategory = $prevVersion->getMyLinkCategory();
+ $oldCategory->setNumLinks( $oldCategory->getNumLinks() - 1 );
+ // update the categories
+ $linkCategories->updateMyLinksCategory( $newCategory );
+ $linkCategories->updateMyLinksCategory( $oldCategory );
+ }
return true;
}
Modified: plog/trunk/class/dao/mylinkscategories.class.php
===================================================================
--- plog/trunk/class/dao/mylinkscategories.class.php 2005-09-21 19:16:18 UTC (rev 2503)
+++ plog/trunk/class/dao/mylinkscategories.class.php 2005-09-21 19:38:45 UTC (rev 2504)
@@ -188,7 +188,7 @@
include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
$category = $this->getMyLinksCategory( $categoryId );
if( $category ) {
- $category->setModificationDate( Timestamp::getNowTimestamp());
+ $category->setLastModification( Timestamp::getNowTimestamp());
return( $this->update( $category ));
}
else
More information about the pLog-svn
mailing list