[pLog-svn] r3853 - plog/trunk/class/dao
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Wed Aug 9 18:44:09 GMT 2006
Author: oscar
Date: 2006-08-09 18:44:08 +0000 (Wed, 09 Aug 2006)
New Revision: 3853
Modified:
plog/trunk/class/dao/blogs.class.php
Log:
now we can also guarantee the uniqueness of blog mangled names when updating the blog settings. The fix is a bit hackish but it works and it passes the test case.
Modified: plog/trunk/class/dao/blogs.class.php
===================================================================
--- plog/trunk/class/dao/blogs.class.php 2006-08-09 18:17:26 UTC (rev 3852)
+++ plog/trunk/class/dao/blogs.class.php 2006-08-09 18:44:08 UTC (rev 3853)
@@ -100,7 +100,7 @@
* @param blogInfo A BlogInfo object containing all the information of the blog
* @param return Returns true if everything's ok or false otherwise
*/
- function updateBlog( $blog )
+ function updateBlog( &$blog )
{
// load the previous version of this blog
$prevVersion = $this->getBlogInfo( $blog->getId());
@@ -108,6 +108,20 @@
// check that the mangled_blog field is unique
$mangledBlog = $blog->getMangledBlogName();
$i = 1;
+ // check if there already is a blog with the same mangled name
+ $done = false;
+ while(( $tmpBlog = $this->getBlogInfoByName( $mangledBlog )) && !$done)
+ {
+ if( $tmpBlog->getId() != $blog->getId()) {
+ $i++;
+ $mangledBlog = substr($mangledBlog, 0,
+ ($i > 2) ? strlen($mangledBlog)-strlen($i-1) : strlen($mangledBlog)).$i;
+ }
+ else {
+ $done = true;
+ }
+ }
+ $blog->setMangledBlogName($mangledBlog);
if( ($result = $this->update( $blog ))) {
// reset the caches
More information about the pLog-svn
mailing list