/**
  * Constructor
  *
  * @param mixed $arrElementData
  */
 public function __construct($arrElementData)
 {
     parent::__construct($arrElementData);
     // save a cookie to store the voting
     $objCookie = new class_cookie();
     $this->arrCookieValues = explode(",", $objCookie->getCookie($this->STR_COOKIE_NAME));
     //any actions to perform before? e.g. voting...
     if ($this->getAction() == "submitVoting") {
         $this->actionSubmitVoting();
         $this->setAction("list");
     }
 }
 /**
  * Checks, if the record is already rated by the current user to avoid double-ratings
  *
  * @return bool
  */
 public function isRateableByCurrentUser()
 {
     $bitReturn = true;
     //sql-check - only if user is not a guest
     $arrRow = array();
     $arrRow["COUNT(*)"] = 0;
     if ($this->objSession->getUserID() != "") {
         $strQuery = "SELECT COUNT(*) FROM " . $this->objDB->encloseTableName(_dbprefix_ . "rating_history") . "\n\t    \t               WHERE rating_history_rating = ?\n\t    \t                 AND rating_history_user = ?";
         $arrRow = $this->objDB->getPRow($strQuery, array($this->getSystemid(), $this->objSession->getUserID()));
     }
     if ($arrRow["COUNT(*)"] == 0) {
         //cookie available?
         $objCookie = new class_cookie();
         if ($objCookie->getCookie(class_module_rating_rate::RATING_COOKIE) != "") {
             $strRatingCookie = $objCookie->getCookie(class_module_rating_rate::RATING_COOKIE);
             if (uniStrpos($strRatingCookie, $this->getSystemid()) !== false) {
                 $bitReturn = false;
             }
         }
     } else {
         $bitReturn = false;
     }
     return $bitReturn;
 }
示例#3
0
 /**
  * Returns the language the user set for the administration
  * NOTE: THIS IS FOR THE TEXTS, NOT THE CONTENTS
  *
  * @param bool $bitUseCookie
  * @param bool $bitSkipSessionEntry
  *
  * @return string
  */
 public function getAdminLanguage($bitUseCookie = true, $bitSkipSessionEntry = false)
 {
     if (!$bitSkipSessionEntry && $this->getSession(self::STR_SESSION_ADMIN_LANG_KEY) != "") {
         return $this->getSession(self::STR_SESSION_ADMIN_LANG_KEY);
     }
     //Maybe we can load the language from the cookie
     $objCookie = new class_cookie();
     $strLanguage = $objCookie->getCookie("adminlanguage");
     if ($strLanguage != "" && $bitUseCookie) {
         return $strLanguage;
     }
     if ($this->isLoggedin()) {
         if ($this->isAdmin()) {
             if ($this->getUser() != null && $this->getUser()->getStrAdminlanguage() != "") {
                 $strLang = $this->getUser()->getStrAdminlanguage();
                 $this->setSession(self::STR_SESSION_ADMIN_LANG_KEY, $strLang);
                 return $strLang;
             }
         }
     } else {
         //try to load a language the user requested
         $strUserLanguages = str_replace(";", ",", getServer("HTTP_ACCEPT_LANGUAGE"));
         if (uniStrlen($strUserLanguages) > 0) {
             $arrLanguages = explode(",", $strUserLanguages);
             //check, if one of the requested languages is available on our system
             foreach ($arrLanguages as $strOneLanguage) {
                 if (!preg_match("#q\\=[0-9]\\.[0-9]#i", $strOneLanguage)) {
                     if (in_array($strOneLanguage, explode(",", class_carrier::getInstance()->getObjConfig()->getConfig("adminlangs")))) {
                         return $strOneLanguage;
                     }
                 }
             }
         }
     }
     return "";
 }