Developer's Manual  Using of userint, userbit, and userstr

Using of userint, userbit, and userstr

When building a website it is often required to have password protected pages or pages defined for a special group of users. In addition, a website may have several page types, like news or press releases. Sometimes pages of the same type could be stored under different folders. Finding and displaying those pages to a site visitor could be a complex task. Moreover, a site administrator or a content contributor should have ability to assign page to a group or change the page type in fast and convenient way. For that purposes, SiteSupra has free special fields in the content tables. These fields are userint, userbit, and userstr.

A developer can use userint, userbit, and userstr fields to create page types or define user groups a page will be accessible for. A site administrator or a content contributor can assign one of predefined values to the fields so that a block or a module can analyze the fieldsâŔ™ values and decide whether to show a page to site visitor or not.

Before you can start using userint, userbit, and userstr they should be properly configured in the .htedit file.

<?
$suEDIT
= Array(
    
'jsEdit'                => 0,                            // specifies whether to allow JavaScript or not
    
'userint'               => 'Page type',                  // caption for userint field
    
'userintList'           => Array(                        // specifies elements of userint drop-down menu
                                    
0 => 'None',
                                    
1 => 'Press release',
                                    
2 => 'News',
                                    
3 => 'Product'
                               
),
//  'userstr'               => '',                           // caption for userstr field
    
'userbit'               => 'Main menu|Public',           // captions for userbit field
    
'showHead'              => 1,                            // specifies whether to allow SiteSupra user change <head> tag of a page
    
'showMeta'              => 1,                            // specifies whether to allow SiteSupra user change <meta> tag of a page
    
'showBody'              => 1,                            // specifies whether to allow SiteSupra user change <body> tag of a page
    
'uiLang'                => 'english',                    // user interface language
    
'idleTime'              => 3600,                         //
    
'stylePrefix'           => '.',                          //
    
'chmod'                 => 0640,                         //
    
'chmoddir'              => 0750,                         //
    
'dateTimeFormat'        => 'd-M-y H:i',                  //
    
'leftMenu'              => 0                             //
);
?>

SiteSupra user can easily change userint, userbit, or userstr values using SiteSupra console.


Page properties, userint and userbit

SiteSupra user can easy change userint, userbit, or userstr values using SiteSupra console. The value of userint is the key of selected $userIntList array element. The value of userbit is combination of checkboxes states in bitwise representation. For example, if SiteSupra user ticked checkbox Main Menu, the value of userbit field will be 1 or 00000001 in bitwise format. If SiteSupra user ticked Public checkbox and cleared the Main menu checkbox, the value of userbit will be 2 or 00000010.

The example below illustrates how to retrieve pages of a selected type. In addition, the script analyzes the value of $isLogged variable and if a site visitor is not logged on, the query will return only pages having checkbox Public ticked.

<?
$active
= suPUBL ? ' AND active = 1 ' : '';
$userbit = $isLogged ? '' : ' AND userbit & 2 ';
$query = "SELECT id, title, short FROM " . suPAGES . "
          WHERE userint = 1 "
. $userbit . "
                AND path NOT LIKE '/$/%' "
. $active . "
          ORDER BY date"
;
?>
Please login to add comments.