Membership: List CURRENT USER items only

25 posts by 6 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: August 4, 2011   (RSS)

By s2smedia - March 24, 2010

Im in need of the same functionality...

heres my scenerio...

When a project is created, I have a drop down of Employees to assign it to.. the drop down pulls in a field "id" which is a field I added to the Accounts section.

so I just need to adjust this code accordingly:

(I added the code you suggested to the other person in this thread, I also have another where clause i need to keep in there "project_status = 'Active'")

<?php

require_once "admin/lib/viewer_functions.php";

list($projectsRecords, $projectsMetaData) = getRecords(array(
'tableName' => 'projects',
'where' => " project_status = 'Active' " "mysql_escapef(" project_manager LIKE ? ", "%\t".$CURRENT_USER['id']."\t%" )",
));

?>

Re: [s2smedia] Membership: List CURRENT USER items only

By Jason - March 24, 2010

Hi,

I think all you'll need to do put those two statements together with an AND statement:

'where' => " project_status = 'Active' AND mysql_escapef(" project_manager LIKE ? ", "%\t".$CURRENT_USER['id']."\t%" )", [/#000000]

Give that a try.[/#000000]
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Membership: List CURRENT USER items only

By s2smedia - March 24, 2010

hmm im getting this error:

Parse error: syntax error, unexpected T_STRING, expecting ')' in /hermes/bosweb/web255/b2559/ipw.s2smedia/frontdesk/index.php on line 18

Re: [s2smedia] Membership: List CURRENT USER items only

By Jason - March 25, 2010

Sorry about that. This should work better:
list($projectsRecords, $projectsMetaData) = getRecords(array(
'tableName' => 'projects',
'where' => 'project_status=\'Active\' AND'. mysql_escapef(" project_manager LIKE ? ", "%\t".$CURRENT_USER['id']."\t%" ) ,
));


Let me know if that works.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Membership: List CURRENT USER items only

By s2smedia - March 25, 2010

ok... error is gone.

But now the areas where the content should display, is blank.

not sure if maybe I need to flip the code or something..

so basically when I create a "Project"

I select from a drop down (project_manager) which pulls in values "id" from "accounts"

it seems like the code should work... not sure what maybe happening...

Re: [Jason] Membership: List CURRENT USER items only

By s2smedia - March 25, 2010

no.. sorry for confusion.

I attached a PDF that will explain... its fairly simple what I need.
Attachments:

it_pdf.pdf 559K

Re: [s2smedia] Membership: List CURRENT USER items only

By Jason - March 25, 2010

Hi,

Okay, we're going to try a couple of things. First, we're going to change our "where" statement to the following:
'where' => 'project_manager= "'. $CURRENT_USER['id'] .'"' ,

See if that gives you the records you're looking for. If not add this line right underneath the "where" statement:
'debugSql' => true,

This will display the SQL query. Send me that information along with the php file you are using and I'll take a look.

Let's give that a try. Let me know what happens.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Membership: List CURRENT USER items only

By s2smedia - March 25, 2010

PERFECTO!

now I just need i the where=> project_status "active"

Re: [s2smedia] Membership: List CURRENT USER items only

By Dave - March 26, 2010

Hi s2smedia,

You can add that back with this:
'where' => 'project_status="Active" AND project_manager= "'. $CURRENT_USER['id'] .'"' ,

If that works, great! If not, and it makes all your results disappear it probably means "Active" isn't the actual value you're wanting to match (or that you don't have any active records).

If that's the case you can remove it again and examine the records being returned by temporarily adding this line:
<?php showme($projectsRecords); ?>

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com