"Posted by" showing number

A place for users and developers of the Xataface to discuss and receive support.

"Posted by" showing number

Postby titleistfour » Wed Jan 25, 2012 10:16 am

Hello,

Just wanted to first say that I discovered Xataface 2 days and love it! Great piece of software, thank you for the work you have put in it.

So, my small issue. When I post a record, the "Posted by" text is showing a number. For example, "Posted by 9", "Posted by 2". Should that be more description? Such as "Posted by jsmith"? I know can hide this, but I think for us it would be useful to see how posted the record.

I am running xataface 1.3rc6

Thanks for any pointers!

Jay
titleistfour
 
Posts: 18
Joined: Wed Jan 25, 2012 10:12 am

Re: "Posted by" showing number

Postby titleistfour » Wed Jan 25, 2012 11:06 am

Ok, so did a little digging and found the code the builds the text to display 'Posted by'.

getCreatorField() and getCreator() in Table.php. These 2 functions query my tables to find out the creator if the field falls in this set of column names

/(created.*by)|(owner)|(posted*by)|(author)|(creator)/


So, that being found, I updated my tables to add that column, and filled in some test data. That fixed my original problem, but leads to another question.

How do I get Xataface to add the creator in automatically based on the logged in user?

Thanks
titleistfour
 
Posts: 18
Joined: Wed Jan 25, 2012 10:12 am

Re: "Posted by" showing number

Postby shannah » Wed Jan 25, 2012 11:43 am

Good question. Currently there's nothing automatic. You would need to do it in your beforeInsert() trigger.
e.g.
Code: Select all
function beforeInsert($record){
    $username = Dataface_AuthenticationTool::getInstance()->getLoggedInUserName();
    $record->setValue('creator', $username);
}


It would be a good feature to make this configurable in the fields.ini ... but that isn't set up yet (that I can recall).

Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: "Posted by" showing number

Postby titleistfour » Wed Jan 25, 2012 1:18 pm

Ok, thank you for the code snippet!
titleistfour
 
Posts: 18
Joined: Wed Jan 25, 2012 10:12 am

Re: "Posted by" showing number

Postby sim » Thu Jan 26, 2012 12:55 am

I think there is a typo shouldnt it be prefixed with &
like follows
function beforeInsert(&$record){
$username = Dataface_AuthenticationTool::getInstance()->getLoggedInUserName();
$record->setValue('creator', $username);
}
sim
 
Posts: 12
Joined: Fri Dec 02, 2011 2:35 am

Re: "Posted by" showing number

Postby titleistfour » Thu Jan 26, 2012 10:31 am

You are correct. I fixed that, but forgot to reply to the previous post. Thanks
titleistfour
 
Posts: 18
Joined: Wed Jan 25, 2012 10:12 am

Re: "Posted by" showing number

Postby shannah » Thu Jan 26, 2012 10:41 am

Actually since we're all on PHP 5 now, it doesn't make a difference. Usually I now omit the &.
The only exception to this rule is if you're passing an array and it needs to be by reference. Arrays are still passed by value by default. Objects are now always passed by reference.

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 10 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved