Page 1 of 1

User Name in Dashboard

PostPosted: Tue Jul 05, 2011 7:56 pm
by J1N
Hi Guys,

I'm VERY new to Xataface and was hoping someone could point me in the right direction:

I want to be able to get the logged in user to appear on the dashboard title i.e. "Welcome Steve Smith!" and then i want to use the user name to create custom searches to find records with the user's name in the assigned to field. It'll pretty much show whats in that users queue.

Everything I've tried hasn't worked at all! Any help would be great!

Thanks
J1N

Re: User Name in Dashboard

PostPosted: Wed Jul 06, 2011 2:40 pm
by J1N
FYI you can use {$ENV.SESSION.UserName}

Re: User Name in Dashboard

PostPosted: Wed Aug 03, 2011 1:25 pm
by thesnowsnake
What code would I use to place the current user into a field, in the selected table.?

Re: User Name in Dashboard

PostPosted: Wed Aug 03, 2011 1:37 pm
by shannah
Can you elaborate?

Re: User Name in Dashboard

PostPosted: Wed Aug 03, 2011 2:06 pm
by thesnowsnake
Well again remember I'm new. Old but new lol.

This is my LOGO code that worked for me.

INSERT INTO `feedback` ( `ID_feedback`, `author`, `client_ref`,`FBrate`, `FBcomment`, `FB_date`)

VALUES (
NULL,
<code type="user" />,
'<input name="client_ref" required= "y" />',
'<input title="Feedback Rating" type="list" options="Good,1;Fair,2;Poor,3"/>',
'<input name="FBcomment" required= "y" />',
'<input name="FB_date" type="date" out="Y-m-d" default="today" />'),
'<input name="FBlastname" required= "y" />',
'<input name="FBphone" required= "y" />',
'<input name="FBcity" required= "y" />'


Now to start with a lot of these fields needed to be filled by (preloadin another table) Pain in the ask me.
but the " <code type="user" />," inserted the id number of the user from my joomla users table.
I will try to get rid of Joomla in the future as my site is pretty well just a database feedback site and not really suited to all the neat joomla stuff ( It was down and dirty to set up).

Re: User Name in Dashboard

PostPosted: Wed Aug 03, 2011 2:21 pm
by thesnowsnake
What I would like to get working is open a large client table, select one client (or add if not found) then load a feedback form with list options for feedback levels and a comment field. Then insert into feedback table.

We have other tables involved but there are to display a graphic in the table etc. But Im sure I can use both LOGO and xataface together, until I get moved over completely.
My major problem was the query that required loading of one table with considerations and inserting into another. It had to be done in stages and I had very little support on this problem. LOGO was a paid for product and very well done but (Toby) the author is very busy with other stuff plus the general membership is much smaller then xatafaces.

I really like your grid, and it will be perfect after a color change, <grin>

Thanks for all your help
ps I think your video was really helpful I hope Mr. Campbell liked it too.

Re: User Name in Dashboard

PostPosted: Wed Aug 03, 2011 2:44 pm
by shannah
Is it the case that, when saving a record (in the new record form or edit record form) you want column to prepopulate with the username of the currently logged in user?

If so, then:
1. I assume you've set up basic authentication with your Xataface app.
2. You should use the beforeInsert() or beforeSave() delegate class triggers. These are called before a record is inserted/saved in the database so you can modify the information that is going to be inserted at that time. e.g.
Code: Select all
function beforeInsert($record){
    $currentUser = Dataface_AuthenticationTool::getInstance()->getLoggedInUser();
    if ( $currentUser ){
        $record->val('posted_by', $currentUser->val('username'));
    }
}


This snippet would be placed in a delegate class for a table that has a field 'posted_by' that is supposed to house the name of the user that posted a row. It assumes that you've set up basic auth and that your users table has a field named 'username'.

-Steve

Re: User Name in Dashboard

PostPosted: Wed Aug 03, 2011 2:49 pm
by shannah
What I would like to get working is open a large client table, select one client (or add if not found) then load a feedback form with list options for feedback levels and a comment field. Then insert into feedback table.


It would be easier to comment if I knew the database structure. But assuming you have a "feedback" table with fields like:
client_id
feedback_level
comments

Then you could just use the basic new record form on the feedback table. Use the "lookup" widget for the client_id field (so that you can select an existing client - or add a new one if it doesn't yet exist), then a select widget on the feedback level field, and a regular text area on the comments field.

Re: User Name in Dashboard

PostPosted: Thu Aug 04, 2011 8:31 am
by thesnowsnake
Wow just like that eh..Cool but I really don't follow so I will start to one step in thru. I know I will have problems so no sky jumping or any silly stuff till I get it eh...

I could send you the database structure or preload whatever so you can lead me in the right direction...Oh I miss the days of pascal and c....lol
But I really think we can get this working really slick.

Re: User Name in Dashboard

PostPosted: Thu Aug 04, 2011 8:35 am
by thesnowsnake
Here is the database structure.





ID_feedback int(11) No
client_ref int(11) No
author int(11) No which contracter rated this client
authorcompany varchar(50) No
FBrate int(1) No 1=pos 2=neutral 3=negitive feedback rate
FBcomment mediumtext No
FB_date date No
LastUpdate date No
customergrade int(2) No General Interaction Grade
FBlastname varchar(25) No
FBphone varchar(14) No
FBcity varchar(25) No



Looks Good?

Don