Source for file ChangeStatus.class.php

Documentation is available at ChangeStatus.class.php

  1. <?php
  2. /**
  3.  * ChangeStatus for user blocking in the session
  4.  *
  5.  * LICENSE: CREATIVE COMMONS PUBLIC LICENSE  "Namensnennung — Nicht-kommerziell 2.0"
  6.  *
  7.  * @copyright  2009 <SEDesign />
  8.  * @license    http://creativecommons.org/licenses/by-nc/2.0/de/
  9.  * @version    $3.0.6$
  10.  * @link       http://www.sedesign.de/de_produkte_chat-v3.html
  11.  * @since      File available since Alpha 1.0
  12.  */
  13.  
  14. {
  15.     /**
  16.     * Constructor
  17.     *
  18.     * @uses ConnectDB::sqlSet()
  19.     * @uses ConnectDB::close()
  20.     * @return void 
  21.     */
  22.     public function __construct (){
  23.     
  24.         // call parent Constructor from class DbConectionMaker
  25.         parent::__construct();
  26.     
  27.         session_start();
  28.         
  29.         // all documentc requested per AJAX should have this part to turn off the browser and proxy cache for any XHR request
  30.         header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0');
  31.         
  32.         // Test if this status is allowed to be used by this user
  33.         if (!$this->checkRightsOfStatus($_POST['img'])) {
  34.             $_POST['img']=""
  35.             $_POST['text']="";
  36.             echo "Not allowed operation.";
  37.             return false;
  38.         }
  39.         
  40.         // no image is just online status
  41.         if($_POST['img']=="status_online"){$_POST['img']=""$_POST['text']="";}
  42.  
  43.         // change status in the session table
  44.         $this->dbObj->sqlSet("UPDATE {$this->_prefix}etchat_useronline SET 
  45.             etchat_user_online_user_status_img = '".addslashes($_POST['img'])."',
  46.             etchat_user_online_user_status_text = '".addslashes(urldecode($_POST['text']))."'
  47.             WHERE etchat_onlineuser_fid = ".(int)$_SESSION['etchat_'.$this->_prefix.'user_id']);
  48.         
  49.         // close DB connection
  50.         $this->dbObj->close();
  51.         
  52.         echo "1";
  53.     }
  54.     
  55.     /**
  56.     * Test if this status is allowed to be used by this user
  57.     *
  58.     * @uses LangXml object creation
  59.     * @uses LangXml::getLang() parser method
  60.     * @return bool
  61.     */
  62.     private function checkRightsOfStatus($statusImagename){
  63.         
  64.         // create new LangXml Object
  65.         $langObj = new LangXml();
  66.         $lang=$langObj->getLang();
  67.         
  68.         foreach($lang->chat_js[0]->status as $status_value
  69.             if ($status_value->tagAttrs['imagename']==$statusImagename && $status_value->tagAttrs['rights']!='all')    
  70.                 $thisStatusImagenameRights[]=$status_value->tagAttrs['rights'];
  71.         
  72.         if (!is_array($thisStatusImagenameRights)) return true;
  73.         else{
  74.             if (in_array($_SESSION['etchat_'.$this->_prefix.'user_priv']$thisStatusImagenameRights)) return true;
  75.             else return false;
  76.         }
  77.     }

Documentation generated on Tue, 22 Dec 2009 09:42:46 +0100 by phpDocumentor 1.4.1