[pLog-svn] r2823 - plog/trunk/class/dao/userdata
Mark Wu
markplace at gmail.com
Fri Jan 20 02:45:22 GMT 2006
Hi Jon:
This is what I did in getUsersBlogs() method, kindly see the red line..
in newPost the results is 1,1,SELECT * FROM lt_blogs WHERE owner_id = 1 AND
status = '1'
but, is editPost the results is 1,BLOG_STATUS_ACTIVE,SELECT * FROM lt_blogs
WHERE owner_id = 1 AND status = 'BLOG_STATUS_ACTIVE'
Mark
=======
/**
* Returns an array of BlogInfo objects with the information of all
the blogs to which
* a user belongs
*
* @param userId Identifier of the user
* @return An array of BlogInfo objects to whom the user belongs.
*/
function getUsersBlogs( $userid, $status = BLOG_STATUS_ALL )
{
include_once(
PLOG_CLASS_PATH."class/dao/blogs.class.php" );
$usersBlogs = Array();
$blogs = new Blogs();
$ids = Array();
// check if the user is the owner of any blog
echo BLOG_STATUS_ACTIVE.",";
$prefix = $this->getPrefix();
$owner = "SELECT * FROM {$prefix}blogs WHERE owner_id =
".$userid;
if( $status != BLOG_STATUS_ALL )
$owner .= " AND status = '".Db::qstr(
$status )."'";
$result = $this->Execute( $owner );
echo $status.",";
echo $owner;
while( $row = $result->FetchRow($result)) {
$usersBlogs[] = $blogs->mapRow( $row );
$ids[] = $row["id"];
}
// and now check to which other blogs he or she belongs
$otherBlogs = "SELECT b.* FROM {$prefix}blogs b,
{$prefix}users_permissions p
WHERE p.user_id = '".Db::qstr($userid)."' AND
b.id = p.blog_id";
if( !empty($usersBlogs)) {
$blogIds = implode( ",", $ids );
$otherBlogs .= " AND p.blog_id NOT IN
(".$blogIds.")";
}
if( $status != BLOG_STATUS_ALL )
$otherBlogs .= " AND b.status = '".Db::qstr( $status )."'";
$result = $this->Execute( $otherBlogs );
// now we know to which he or she belongs, so we only have
// to load the information about those blogs
while( $row = $result->FetchRow($result)) {
$usersBlogs[] = $blogs->mapRow( $row );
}
return $usersBlogs;
}
> -----Original Message-----
> From: plog-svn-bounces at devel.lifetype.net
> [mailto:plog-svn-bounces at devel.lifetype.net] On Behalf Of Jon Daley
> Sent: Friday, January 20, 2006 10:22 AM
> To: plog-svn at devel.lifetype.net
> Subject: RE: [pLog-svn] r2823 - plog/trunk/class/dao/userdata
>
> This looks wrong to me:
> line 104 of baseuserdataprovider.class.php:
> $owner .= " AND status = '".Db::qstr( $status )."'";
>
> Seems to have extra quotes in it.
>
>
> Also, in adminmainaction.class.php, it seems that
> blogs.class.php is not included? So the BLOG_STATUS_ACTIVE
> on line 38 is treated as a string?
>
> (I don't have a copy of 1.1 running so I can't debug it currently.
>
> I don't see the include in adminaction.class.php either,
> though there is a long list of includes there, so maybe it
> gets included somewhere.
>
> I would print out the value of $status in getUsersBlogs, and
> if it is 'BLOG_STATUS_ACTIVE', print out a stack trace, to
> see where it is coming from. I think the trace will be
> different depending on if it is '1' or 'BLOG_STATUS_ACTIVE'?
>
>
> On Fri, 20 Jan 2006, Mark Wu wrote:
>
> > The same line.....
> >
> > The same program(script), the same input (BLOG_STATUS_ACTIVE) but
> > generte two different results...
> >
> > For example, in the newPost page,
> >
> > When I echo the BLOG_STATUS_ACTIVE, it just show me 1, and
> the query
> > (echo $owner variable) is SELECT * FROM lt_blogs WHERE
> owner_id = 1
> > AND status = '1'
> >
> > But, in editPost page,
> >
> > When I echo the BLOG_STATUS_ACTIVE, it also show me 1, but
> the query
> > (echo $owner variable) is SELECT * FROM lt_blogs WHERE
> owner_id = 1
> > AND status = 'BLOG_STATUS_ACTIVE'
> >
> > That's why the blog selection does not show anything, because the
> > $result of the sql statement is EMPTY...
> >
> > That's what I said "sometimes" ...
> >
> > Really weird..
> >
> > Mark
> >> -----Original Message-----
> >> From: plog-svn-bounces at devel.lifetype.net
> >> [mailto:plog-svn-bounces at devel.lifetype.net] On Behalf Of Jon Daley
> >> Sent: Friday, January 20, 2006 9:56 AM
> >> To: plog-svn at devel.lifetype.net
> >> Subject: RE: [pLog-svn] r2823 - plog/trunk/class/dao/userdata
> >>
> >> On Fri, 20 Jan 2006, Mark Wu wrote:
> >>> I echo BLOG_STATUS_ACTIVE, it always show "1" without any
> >> problems ...
> >>>
> >>> But, when I echo $owner (the squery statement), it show .....='1'
> >>> sometimes and ......='BLOG_STATUS_ACTIVE' sometimes ...
> >>
> >> When you say "sometimes" do you mean on the same line, or in
> >> different places in the file?
> >> _______________________________________________
> >> pLog-svn mailing list
> >> pLog-svn at devel.lifetype.net
> >> http://devel.lifetype.net/mailman/listinfo/plog-svn
> >
> > _______________________________________________
> > pLog-svn mailing list
> > pLog-svn at devel.lifetype.net
> > http://devel.lifetype.net/mailman/listinfo/plog-svn
> >
>
> **************************************
> Jon Daley
> http://jon.limedaley.com/
>
> After your hands become coated with grease,
> your nose will begin to itch.
> -- Lorenz's Law of Mechanical Repair
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://devel.lifetype.net/mailman/listinfo/plog-svn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http:// devel.lifetype.net/pipermail/plog-svn/attachments/20060120/53471345/attachment-0001.html
More information about the pLog-svn
mailing list