Example #1
0
 public function __construct()
 {
     //start up system
     $this->objTemplates = class_carrier::getInstance()->getObjTemplate();
     $this->objLang = class_carrier::getInstance()->getObjLang();
     //init session-support
     $this->objSession = class_carrier::getInstance()->getObjSession();
     //set a different language?
     if (issetGet("language")) {
         if (in_array(getGet("language"), explode(",", class_carrier::getInstance()->getObjConfig()->getConfig("adminlangs")))) {
             $this->objLang->setStrTextLanguage(getGet("language"));
             //and save to a cookie
             $objCookie = new class_cookie();
             $objCookie->setCookie("adminlanguage", getGet("language"));
         }
     } else {
         //init correct text-file handling as in admins
         $this->objLang->setStrTextLanguage($this->objSession->getAdminLanguage(true));
     }
     $this->STR_ORIG_CONFIG_FILE = class_resourceloader::getInstance()->getCorePathForModule("module_system") . "/module_system/system/config/config.php";
     $this->STR_PROJECT_CONFIG_FILE = _realpath_ . "/project/system/config/config.php";
 }
 /**
  * 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;
 }
 /**
  * Stores the submitted data to the backend / the loginprovider
  *
  * @return string
  */
 protected function actionSaveUser()
 {
     $strReturn = "";
     $bitSelfedit = false;
     $objUsersources = new class_module_user_sourcefactory();
     if ($this->getParam("mode") == "new") {
         if (!$this->getObjModule()->rightEdit()) {
             return $this->getLang("commons_error_permissions");
         }
         $objSubsystem = $objUsersources->getUsersource($this->getParam("usersource"));
         $objBlankUser = $objSubsystem->getNewUser();
         $objForm = $this->getUserForm($objBlankUser, false, "new");
     } else {
         if (!$this->getObjModule()->rightEdit()) {
             if ($this->getSystemid() == $this->objSession->getUserID() && class_module_system_setting::getConfigValue("_user_selfedit_") == "true") {
                 $bitSelfedit = true;
             } else {
                 return $this->getLang("commons_error_permissions");
             }
         }
         $objUser = new class_module_user_user($this->getSystemid());
         $objSourceUser = $objUsersources->getSourceUser($objUser);
         $objForm = $this->getUserForm($objSourceUser, $bitSelfedit, "edit");
     }
     if (($this->getParam("mode") == "new" && !$this->checkAdditionalNewData($objForm)) | ($this->getParam("mode") == "edit" && !$this->checkAdditionalEditData($objForm)) | !$objForm->validateForm()) {
         return $this->actionNewUser($this->getParam("mode"), $objForm);
     }
     $objUser = null;
     if ($this->getParam("mode") == "new") {
         //create a new user and pass all relevant data
         $objUser = new class_module_user_user();
         $objUser->setStrSubsystem($this->getParam("usersource"));
         $objUser->setStrUsername($this->getParam("user_username"));
         $objUser->setIntActive($this->getParam("user_active") != "" && $this->getParam("user_active") == "checked" ? 1 : 0);
         $objUser->setIntAdmin($this->getParam("user_adminlogin") != "" && $this->getParam("user_adminlogin") == "checked" ? 1 : 0);
         $objUser->setIntPortal($this->getParam("user_portal") != "" && $this->getParam("user_portal") == "checked" ? 1 : 0);
     } else {
         if ($this->getParam("mode") == "edit") {
             //create a new user and pass all relevant data
             $objUser = new class_module_user_user($this->getSystemid());
             if (!$bitSelfedit) {
                 $objUser->setStrUsername($this->getParam("user_username"));
                 $objUser->setIntActive($this->getParam("user_active") != "" && $this->getParam("user_active") == "checked" ? 1 : 0);
                 $objUser->setIntAdmin($this->getParam("user_adminlogin") != "" && $this->getParam("user_adminlogin") == "checked" ? 1 : 0);
                 $objUser->setIntPortal($this->getParam("user_portal") != "" && $this->getParam("user_portal") == "checked" ? 1 : 0);
             }
         }
     }
     $objUser->setStrAdminskin($this->getParam("user_skin"));
     $objUser->setStrAdminlanguage($this->getParam("user_language"));
     $objUser->setStrAdminModule($this->getParam("user_startmodule"));
     $objUser->setIntItemsPerPage($this->getParam("user_items_per_page"));
     $objUser->updateObjectToDb();
     $objSourceUser = $objUser->getObjSourceUser();
     $objForm = $this->getUserForm($objSourceUser, $bitSelfedit, $this->getParam("mode"));
     $objForm->updateSourceObject();
     $objSourceUser->updateObjectToDb();
     // assign user to the same groups if we have an user where we inherit the group settings
     if ($this->getParam("mode") == "new") {
         $strInheritUserId = $this->getParam("user_inherit_permissions_id");
         if (!empty($strInheritUserId)) {
             $objInheritUser = new class_module_user_user($strInheritUserId);
             $arrGroupIds = $objInheritUser->getArrGroupIds();
             foreach ($arrGroupIds as $strGroupId) {
                 $objGroup = new class_module_user_group($strGroupId);
                 $objSourceGroup = $objGroup->getObjSourceGroup();
                 $objSourceGroup->addMember($objUser->getObjSourceUser());
             }
             $this->adminReload(class_link::getLinkAdminHref($this->getArrModule("modul"), "editMemberships", "&systemid=" . $objUser->getStrSystemid()));
             return "";
         }
     }
     if ($this->getParam("mode") == "edit") {
         //Reset the admin-skin cookie to force the new skin
         $objCookie = new class_cookie();
         //flush the db-cache
         class_carrier::getInstance()->getObjDB()->flushQueryCache();
         $this->objSession->resetUser();
         //and update the cookie
         $objCookie->setCookie("adminskin", $this->objSession->getAdminSkin(false, true));
         //update language set before
         $objCookie->setCookie("adminlanguage", $this->objSession->getAdminLanguage(false, true));
     }
     //flush the navigation cache in order to get new items for a possible updated list
     class_admin_helper::flushActionNavigationCache();
     if ($this->getObjModule()->rightView()) {
         $this->adminReload(class_link::getLinkAdminHref($this->getArrModule("modul"), "list"));
     } else {
         $this->adminReload(class_link::getLinkAdminHref($objUser->getStrAdminModule()));
     }
     return $strReturn;
 }
 /**
  * Generates the form to fetch the credentials required to authenticate a user
  *
  * @return string
  */
 protected function actionAdminLogin()
 {
     if ($this->objSession->login($this->getParam("name"), $this->getParam("passwort"))) {
         //user allowed to access admin?
         if (!$this->objSession->isAdmin()) {
             //no, reset session
             $this->objSession->logout();
         }
         //save the current skin as a cookie
         $objCookie = new class_cookie();
         $objCookie->setCookie("adminskin", $this->objSession->getAdminSkin(false, true));
         $objCookie->setCookie("adminlanguage", $this->objSession->getAdminLanguage(false, true));
         $this->loadPostLoginSite();
         return true;
     } else {
         class_response_object::getInstance()->setStrRedirectUrl(class_link::getLinkAdminHref("login", "login", "&loginerror=1"));
         return false;
     }
 }
 /**
  * Helper method, does the internal updates of the voting-answers
  *
  * @return void
  * @permissions right1
  */
 private function actionSubmitVoting()
 {
     //load the current voting
     $objVoting = new class_module_votings_voting($this->arrElementData["char1"]);
     // check if the submitted vote matches the current one -> multiple votings per page
     if ($objVoting->getSystemid() == $this->getParam("systemid")) {
         //recheck permissions
         if (!in_array($objVoting->getSystemid(), $this->arrCookieValues)) {
             //load the submitted answer
             $strAnswerID = $this->getParam("voting_" . $objVoting->getSystemid());
             if (validateSystemid($strAnswerID)) {
                 $objAnswer = new class_module_votings_answer($strAnswerID);
                 $objAnswer->setIntHits($objAnswer->getIntHits() + 1);
                 $objAnswer->updateObjectToDb();
                 $this->arrCookieValues[] = $objVoting->getSystemid();
                 $objCookie = new class_cookie();
                 $objCookie->setCookie($this->STR_COOKIE_NAME, implode(",", $this->arrCookieValues));
             }
         }
     }
 }
Example #6
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 "";
 }