Topic: Issues getting get_items_access flags
I am trying to determine which item_access flags are enabled for an item from the decimal value received by requesting get_items_access on wialon kit/hosting.
I have so far managed to get this far:
<?php
$access_flags[] = array('ds'=>'View item and its basic properties' ,'dec'=>1);
$access_flags[] = array('ds'=>'View detailed item properties' ,'dec'=>2);
$access_flags[] = array('ds'=>'Manage access to this item' ,'dec'=>4);
$access_flags[] = array('ds'=>'Delete item' ,'dec'=>8);
$access_flags[] = array('ds'=>'Rename item' ,'dec'=>16);
$access_flags[] = array('ds'=>'View custom fields' ,'dec'=>32);
$access_flags[] = array('ds'=>'Manage custom fields' ,'dec'=>64);
$access_flags[] = array('ds'=>'Edit not mentioned properties' ,'dec'=>128);
$access_flags[] = array('ds'=>'Change icon' ,'dec'=>256);
$access_flags[] = array('ds'=>'Query reports or messages' ,'dec'=>512);
$access_flags[] = array('ds'=>'Edit ACL propagated items' ,'dec'=>1024);
$access_flags[] = array('ds'=>'Manage item log' ,'dec'=>2048);
$access_flags[] = array('ds'=>'View administrative fields' ,'dec'=>4096);
$access_flags[] = array('ds'=>'Edit administrative fields' ,'dec'=>8192);
$access_flags[] = array('ds'=>'Edit connectivity settings (device type, UID, phone, access password, messages filter)' ,'dec'=>1048576);
$access_flags[] = array('ds'=>'Create, edit, and delete sensors' ,'dec'=>2097152);
$access_flags[] = array('ds'=>'Edit counters' ,'dec'=>4194304);
$access_flags[] = array('ds'=>'Delete messages' ,'dec'=>8388608);
$access_flags[] = array('ds'=>'Execute commands' ,'dec'=>16777216);
$access_flags[] = array('ds'=>'Register events' ,'dec'=>33554432);
$access_flags[] = array('ds'=>'View service intervals' ,'dec'=>268435456);
$access_flags[] = array('ds'=>'Create, edit, and delete service intervals' ,'dec'=>536870912);
$access_flags[] = array('ds'=>'Import messages' ,'dec'=>1073741824);
$access_flags[] = array('ds'=>'Export messages' ,'dec'=>2147483648);
$access_flags[] = array('ds'=>'View commands' ,'dec'=>17179869184);
$access_flags[] = array('ds'=>'Create, edit, and delete commands' ,'dec'=>34359738368);
$access_flags[] = array('ds'=>'Edit trip detector and fuel consumption' ,'dec'=>274877906944);
$access_flags[] = array('ds'=>'Use unit in jobs, notifications, routes, retranslators' ,'dec'=>549755813888);
/*
for example the sum of the decimal flag value of the following items
View item and its basic properties
View detailed item properties
Manage access to this item
Delete item
Rename item
View custom fields
Manage item log
View administrative fields
= 6207
*/
$get_items_access = 6207;
foreach($access_flags as $k=>$v){
$dec =$v['dec'];
$ds =$v['ds'];
$result = $dec & $get_items_access; //bitwise
if($result>0){
$selected =1;
echo "<br />$ds";
} else{
$selected =0;
}
}
?>
But the problem with this method is that the last four items
0400000000 View commands
0800000000 Create, edit, and delete commands
4000000000 Edit trip detector and fuel consumption
8000000000 Use unit in jobs, notifications, routes, retranslators
cannot be resolved since PHP does not seem to handle bitwise operations on numbers larger than 32 bit.
for example if i include
0800000000 Create, edit, and delete commands
the get_items_access number will become:
$get_items_access = 34359744575;
And it will not show the last four settings.
Does anyone have a solution.
Implementation Specialist, Middle East, Gurtam
"Computer science is no more about computers than astronomy is about telescopes."