[RESOLVED] getPreferences and setSecurityFilter

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

[RESOLVED] getPreferences and setSecurityFilter

Postby PolderBoy » Mon Mar 26, 2012 7:31 am

Hello All,

I have a question regarding setSecurityFilter
How can I have multiple 'OfficeID' s in the array?

Situation now is:
In table1 I only see the records belonging to 1 office. Where table1.OfficeID = Offices.OfficeID

New situation:
In table1 I only want to see the records belonging to several offices. (in the table Offices a column: 'Belongs_To')



Code: Select all
   
function getPreferences()
   {
   $table1 =& Dataface_Table::loadtable('table1');
   
   $auth =& Dataface_AuthenticationTool::getInstance();
   $user =& $auth -> getLoggedInUser();
if ($user and $user -> val('Role') == 'HeadOffice')
{
   $this->app =& Dataface_Application::getInstance();
   $result = mysql_query("SELECT OfficeID FROM Offices WHERE Belongs_To = '01' ", $this->app->db());
              // Now I use '01' it will be replaced by the right value.

   if($result)
   {
      while($row = mysql_fetch_array( $result )){
                  $arSecurity = array('OfficeID'=>$row['OfficeID']);
      }
   } else {
      $arSecurity = array('OfficeID'=>'99');
   }

   $table1 -> setSecurityFilter($arSecurity);
   }



Right now it only shows the last one (which is correct as it loops trough the results of the query and it does not add).
If I use: $arSecurity = array('OfficeID'=>'10..30');
It shows all the records between (and including) 10 and 30.
If I use: $arSecurity = array('OfficeID'=>'10&30');
It gives an error.

But I want it to show all the records from the query result.

Thanks in advance.
Brian
Last edited by PolderBoy on Wed Mar 28, 2012 7:21 am, edited 1 time in total.
PolderBoy
 
Posts: 72
Joined: Fri Apr 03, 2009 12:53 am

Re: getPreferences and setSecurityFilter

Postby shannah » Mon Mar 26, 2012 9:24 am

Code: Select all
$arSecurity = array('OfficeID'=>'10 OR 30');

should do what you want.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: getPreferences and setSecurityFilter

Postby PolderBoy » Wed Mar 28, 2012 6:39 am

Thank you Shannah.

That was what I was looking for.
It is working now.

For what it is worth herewith my code:

Code: Select all

         if($result)
         {
            while($row = mysql_fetch_array( $result )){
               $str .= $row['OfficeID'] . " OR " ;
            }
            $str = substr($str,0,-4);
         } else {
            $str = "99";
         }

$table2 -> setSecurityFilter(array('OfficeID'=>$str));


Brian
PolderBoy
 
Posts: 72
Joined: Fri Apr 03, 2009 12:53 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 15 guests

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