Change the dataset based on a seession variable
Change the dataset based on a seession variable
Hello,
I am trying to change the records a user sees based on a session variable. In my case the session variable is auth level. Here is a generic sampl that does not work.
[code]
Editor::inst( $db, 'caseinfo' )
->fields(
Field::inst( 'casename' ),
Field::inst( 'factsnum' ),
Field::inst( 'socialsecurity' ),
Field::inst( 'primdob' )
->validator( 'Validate::dateFormat', 'D, j M y' )
->getFormatter( 'Format::date_sql_to_format', 'D, j M y' )
->setFormatter( 'Format::date_format_to_sql', 'D, j M y' ),
Field::inst( 'id' )
)
switch ($_SESSION['auth_level']) {
case 2:
->where( 'userid', 2, '=' );
break;
case 4:
->where( 'agencyid', 2, '=' );
break;
}
->process( $_POST )
->json();
[/code]
I am trying to change the records a user sees based on a session variable. In my case the session variable is auth level. Here is a generic sampl that does not work.
[code]
Editor::inst( $db, 'caseinfo' )
->fields(
Field::inst( 'casename' ),
Field::inst( 'factsnum' ),
Field::inst( 'socialsecurity' ),
Field::inst( 'primdob' )
->validator( 'Validate::dateFormat', 'D, j M y' )
->getFormatter( 'Format::date_sql_to_format', 'D, j M y' )
->setFormatter( 'Format::date_format_to_sql', 'D, j M y' ),
Field::inst( 'id' )
)
switch ($_SESSION['auth_level']) {
case 2:
->where( 'userid', 2, '=' );
break;
case 4:
->where( 'agencyid', 2, '=' );
break;
}
->process( $_POST )
->json();
[/code]
This discussion has been closed.
Replies
[code]
$editor = Editor::inst( $db, 'caseinfo' )
->fields(
Field::inst( 'casename' ),
Field::inst( 'factsnum' ),
Field::inst( 'socialsecurity' ),
Field::inst( 'primdob' )
->validator( 'Validate::dateFormat', 'D, j M y' )
->getFormatter( 'Format::date_sql_to_format', 'D, j M y' )
->setFormatter( 'Format::date_format_to_sql', 'D, j M y' ),
Field::inst( 'id' )
);
switch ($_SESSION['auth_level']) {
case 2:
$editor->where( 'userid', 2, '=' );
break;
case 4:
$editor->where( 'agencyid', 2, '=' );
break;
}
$editor
->process( $_POST )
->json();
[/code]
Allan