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"; }
/** * Adds a rating-value to the record saved in the db * * @param float $floatRating * * @return bool */ public function saveRating($floatRating) { if ($floatRating < 0 || !$this->isRateableByCurrentUser() || $floatRating > class_module_rating_rate::$intMaxRatingValue) { return false; } $floatRatingOriginal = $floatRating; $objRatingAlgo = new class_module_rating_algo_gaussian(); $floatRating = $objRatingAlgo->doRating($this, $floatRating); class_logger::getInstance()->addLogRow("updated rating of record " . $this->getSystemid() . ", added " . $floatRating, class_logger::$levelInfo); //update the values to remain consistent $this->setFloatRating($floatRating); $this->setIntHits($this->getIntHits() + 1); //save a hint in the history table //if($this->objSession->getUserID() != "") { $strInsert = "INSERT INTO " . $this->objDB->encloseTableName(_dbprefix_ . "rating_history") . "\n \t (rating_history_id, rating_history_rating, rating_history_user, rating_history_timestamp, rating_history_value) VALUES\n \t (?, ?, ?, ?, ?)"; $this->objDB->_pQuery($strInsert, array(generateSystemid(), $this->getSystemid(), $this->objSession->getUserID(), (int) time(), $floatRatingOriginal)); //} //and save it in a cookie $objCookie = new class_cookie(); $objCookie->setCookie(class_module_rating_rate::RATING_COOKIE, getCookie(class_module_rating_rate::RATING_COOKIE) . $this->getSystemid() . ","); //flush the page-cache to have all pages rendered using the correct values $this->flushCompletePagesCache(); return true; }
/** * 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)); } } } }