Page 1 of 1

If the value 0 in the field do not see for visitors

Posted: Thu Jan 12, 2017 6:06 pm
by saleh

please help
If the value 0 in the field: Activated do not see for visitors
If the value 1 in the field : Activated he sees for visitors

Activated=0 The table not shows for visitors
Activated=1 The table shows for visitors

Meaning it does not cleanse the table to visitors only on condition that if the value of 1 Activated concert

userlevelid :0
userlevelname: Default

I tried this code and failure:

function UserID_Loaded() {
//echo "UserID Loaded: " . $this->UserIDList() . "<br>";
global $Page;
if ($Page && $Page->TableName == "programs" && CurrentUserLevel() == "0") {
$this->AddUserID(-1);
ew_AddFilter($filter, " Activated <> 0 ");
}

The table is:
CREATE TABLE programs (
Programs_id int(11) NOT NULL,
Programs_name varchar(255) NOT NULL,
initiative int(11) NOT NULL,
goal text,
Brief text,
From_date date DEFAULT NULL,
To_date date DEFAULT NULL,
implementation_period int(11) DEFAULT NULL,
Type_Length int(11) DEFAULT NULL,
Beneficiaries int(11) DEFAULT NULL,
number_beneficiaries int(11) DEFAULT NULL,
Results text NOT NULL,
pictures varchar(100) DEFAULT NULL,
Video longblob,
Identity int(11) DEFAULT NULL,
Activated int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


Re: If the value 0 in the field do not see for visitors

Posted: Fri Jan 13, 2017 9:53 am
by mobhar

saleh wrote:
I tried this code and failure:

Always post the error message for discussion.

In addition, you should put this following code in "Recordset_Selecting", and not in "UserID_Loaded' server event:

ew_AddFilter($filter, " Activated <> 0 ");


Re: If the value 0 in the field do not see for visitors

Posted: Fri Jan 13, 2017 1:22 pm
by saleh

When introduced to the database and change my value to the one shown to visitors

Does not appear for the director even change the field from 0 to 1

I want a candidate Visitors to display only

If the value is zero, but can see the manager and Starter only

If value 1 see Visitors and Starter and Director

This code worked successfully
Is there a better way?

// Recordset Selecting event
function Recordset_Selecting(&$filter) {
// Enter your code here
if (CurrentUserLevel() <> 3 && CurrentUserLevel() <> -1) {
ew_AddFilter($filter, " Activated <> 0 ");

}}