Action condition with a function

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

Action condition with a function

Postby Jean » Sat Apr 21, 2012 1:28 am

Hi Steve and all,

I found this post http://xataface.com/forum/viewtopic.php?t=5169#25151 about a function in the condition for an action :

shannah wrote:Your condition can actually call any php function. So you can define your own function to check this and refer to the function from your condition.

e.g.
In one of your included files:
Code: Select all
function containsEmailField($table){
    ....
}

In your condition directive in the actions.ini file:
Code: Select all
condition="containsEmailField($query['-table'])"


Well I put a function in the delegate class inside the table then in the Delegate class but it seems not being taken into account. I tried all kinds of test but without solving it.
my function is :
Code: Select all
function quelGroupe(){
     $user = $this->getUser();
$groupe=$user->val('groupe');
return $groupe;
}

function belongsTo ($grp){
$auth =& Dataface_AuthenticationTool::getInstance();
     $user = $auth->getLoggedInUser();
$groupe=quelGroupe();
//ie like 11_10
if (stripos($groupe,'_')){
$groupes=explode('_',$groupe);
foreach ($groupes as $val){
if ($val==$grp){
return TRUE;
}
}
}
else {
if ($grp==$groupe){
return TRUE;
}
}
return FALSE;
}

In the actions.ini inside the table I have :
Code: Select all
[mial]
label = "MIAL"
   category = table_tabs
   url = "{$this->url('id_lieu=11')}"
  condition="belongsTo(11)"
  mode = list
   permission = list


My aim is to have profiles for users so that I can display an action according to a value in the users table.
I hope I'm clear ;=)

Thank you

Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Re: Action condition with a function

Postby shannah » Sun Apr 22, 2012 11:18 am

Calling:
Code: Select all
belongsTo(11);

Actually calls a global function, not a method of a delegate class. If you want to call a method of the delegate class you would need to first get the delegate class instance, then call its method on it.
e.g.
Code: Select all
Dataface_Table::loadTable('thetablename')->getDelegate()->belongsTo(11);


Or just define a global belongsTo() method so that you can just call it directly.

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

Re: Action condition with a function

Postby Jean » Mon Apr 23, 2012 4:39 am

Thank you Steve.
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 13 guests

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