Examples of SID Specification

SID is the most important parameter at installation of the public component of the module at a website. By the value of this field the availability of previously created public requests for the website visitors is determined. That is why the value of this field must be unique. In this section several short examples of generating "sid" depending on the purpose of the public component are given in the PHP language.

Private Requests

The delimitation of access for viewing only own requests for registered website users can be implemented by substituting hash from the specified keyword and user's identifier at the website to the "sid" value:

<?php
//--- get user details from cache or DB
$user_info=GetUserInfo($_SESSION['user_id']);
?>
<script type="text/javascript">
var tw_servicedesk_params={
        url:      'https://team.yourdomain.com',
        sid:      '<?php echo md5("Change_This_Secret_Word_".$user_info['id']);
        // hash from the line: keyword + user's id at the website ?>',
        container:'servicedesk',
        user_name:'<?php echo json_encode($user_info['name']);
        // for outputting use the function of outputting with screening of special symbols ?>',
};
</script>

In this example it is obligatory to change the "Change_This_Secret_Word_" keyword to your own.

In the "url" parameter you should specify the address of your TeamWox server.

Requests of Anonymous Users

In order to give the unregistered users the possibility of viewing the requests created by them, you can use cookies for generating the value of "sid". In this case the MD5 if taken from cookies and a secret word:

<?php
//--- if cookies are not installed, install them
if(!isset($_COOKIE['name_cookie']))
  {
   $cookie=md5(uniqid(''));
   //--- installation of cookies to user
   setcookie('name_cookie',$cookie,time()+315360000);
  }
else
  {
   //--- get previously installed cookies
   $cookie = $_COOKIE['name_cookie'];
  }
?>
<script type="text/javascript">
var tw_servicedesk_params={
        url:      'https://team.yourdomain.com',
        sid:      '<?php echo md5("Change_This_Secret_Word_".$cookie);
                // hash from the line: secret word + identifier of website user ?>',
        container:'service_desk',
        user_name:'Anonymous',
};
</script>

In this example it is obligatory to change the "Change_This_Secret_Word_" keyword to your own.

In the "url" parameter you should specify the address of your TeamWox server.

The example of cookies installation is also given here in case they were not installed to the user before. The "name-cookie" value must be changed to your own name of installed cookies.

It is necessary to remember that an anonymous user will be able to view his/her own requests only until the cookies are not deleted.

The same "sid" will be generated for the users who have cookies disabled in their browsers. This kind of users will be able to view the requests of each other.

Collaboration with Public Component

In order to organize the working with requests without the delimitation of access rights to them, it is necessary to specify a fixed value of "sid". In this case, all the users will be able to view the previously created public requests when entering the public part of the "Service Desk" module.