/** * Updates the current object to the database * <b>ATTENTION</b> If you don't want to update the password, set it to "" before! * * @param bool $strPrevid * * @return bool */ public function updateObjectToDb($strPrevid = false) { if ($this->getSystemid() == "") { $strUserid = generateSystemid(); $this->setSystemid($strUserid); $strQuery = "INSERT INTO " . _dbprefix_ . "user (\n user_id, user_active,\n user_admin, user_portal,\n user_admin_skin, user_admin_language,\n user_logins, user_lastlogin, user_authcode, user_subsystem, user_username, user_admin_module, user_deleted, user_items_per_page\n\n ) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; class_logger::getInstance(class_logger::USERSOURCES)->addLogRow("new user for subsystem " . $this->getStrSubsystem() . " / " . $this->getStrUsername(), class_logger::$levelInfo); $bitReturn = $this->objDB->_pQuery($strQuery, array($strUserid, (int) $this->getIntActive(), (int) $this->getIntAdmin(), (int) $this->getIntPortal(), $this->getStrAdminskin(), $this->getStrAdminlanguage(), 0, 0, $this->getStrAuthcode(), $this->getStrSubsystem(), $this->getStrUsername(), $this->getStrAdminModule(), 0, $this->getIntItemsPerPage())); //create the new instance on the remote-system $objSources = new class_module_user_sourcefactory(); $objProvider = $objSources->getUsersource($this->getStrSubsystem()); $objTargetUser = $objProvider->getNewUser(); $objTargetUser->updateObjectToDb(); $objTargetUser->setNewRecordId($this->getSystemid()); $this->objDB->flushQueryCache(); return $bitReturn; } else { if (version_compare(class_module_system_module::getModuleByName("user")->getStrVersion(), "4.6.5", ">=")) { $strQuery = "UPDATE " . _dbprefix_ . "user SET\n user_active=?, user_admin=?, user_portal=?, user_admin_skin=?, user_admin_language=?, user_logins = ?, user_lastlogin = ?, user_authcode = ?, user_subsystem = ?,\n user_username =?, user_admin_module = ?, user_items_per_page = ?\n WHERE user_id = ?"; } else { if (version_compare(class_module_system_module::getModuleByName("user")->getStrVersion(), "4.4", ">=")) { $strQuery = "UPDATE " . _dbprefix_ . "user SET\n user_active=?, user_admin=?, user_portal=?, user_admin_skin=?, user_admin_language=?, user_logins = ?, user_lastlogin = ?, user_authcode = ?, user_subsystem = ?,\n user_username =?, user_admin_module = ?\n WHERE user_id = ?"; } else { $strQuery = "UPDATE " . _dbprefix_ . "user SET\n user_active=?, user_admin=?, user_portal=?, user_admin_skin=?, user_admin_language=?, user_logins = ?, user_lastlogin = ?, user_authcode = ?, user_subsystem = ?,\n user_username =?\n WHERE user_id = ?"; } } $arrParams = array((int) $this->getIntActive(), (int) $this->getIntAdmin(), (int) $this->getIntPortal(), $this->getStrAdminskin(), $this->getStrAdminlanguage(), (int) $this->getIntLogins(), (int) $this->getIntLastLogin(), $this->getStrAuthcode(), $this->getStrSubsystem(), $this->getStrUsername()); if (version_compare(class_module_system_module::getModuleByName("user")->getStrVersion(), "4.4", ">=")) { $arrParams[] = $this->getStrAdminModule(); } if (version_compare(class_module_system_module::getModuleByName("user")->getStrVersion(), "4.6.5", ">=")) { $arrParams[] = $this->getIntItemsPerPage(); } $arrParams[] = $this->getSystemid(); class_logger::getInstance(class_logger::USERSOURCES)->addLogRow("updated user for subsystem " . $this->getStrSubsystem() . " / " . $this->getStrUsername(), class_logger::$levelInfo); return $this->objDB->_pQuery($strQuery, $arrParams); } }
/** * Saves the memberships passed by param * * @return string "" in case of success * @permissions edit */ protected function actionSaveMembership() { $objUser = new class_module_user_user($this->getSystemid()); $objUsersources = new class_module_user_sourcefactory(); $objSourcesytem = $objUsersources->getUsersource($objUser->getStrSubsystem()); $arrGroups = $objSourcesytem->getAllGroupIds(); $arrUserGroups = $objUser->getArrGroupIds(); //validate possible blocked groups $objConfig = class_config::getInstance("blockedgroups.php"); $arrBlockedGroups = explode(",", $objConfig->getConfig("blockedgroups")); //Searching for groups to enter foreach ($arrGroups as $strSingleGroup) { $objGroup = new class_module_user_group($strSingleGroup); //skipped for blocked groups, those won't be updated if (!$this->isGroupEditable($objGroup)) { continue; } if ($this->getParam($strSingleGroup) != "") { //add the user to this group if (!in_array($strSingleGroup, $arrUserGroups)) { $objGroup->getObjSourceGroup()->addMember($objUser->getObjSourceUser()); } else { //user is already in the group, remove the marker foreach ($arrUserGroups as $strKey => $strValue) { if ($strValue == $strSingleGroup) { $arrUserGroups[$strKey] = null; } } } } } //check, if the current user is member of the admin-group. //if not, remain the admin-group as-is if (!class_carrier::getInstance()->getObjSession()->isSuperAdmin()) { $intKey = array_search(class_module_system_setting::getConfigValue("_admins_group_id_"), $arrUserGroups); if ($intKey !== false) { $arrUserGroups[$intKey] = null; } foreach ($arrBlockedGroups as $strOneGroup) { $intKey = array_search($strOneGroup, $arrUserGroups); if ($intKey !== false) { $arrUserGroups[$intKey] = null; } } } //loop the users' list in order to remove unwanted relations foreach ($arrUserGroups as $strValue) { if (validateSystemid($strValue)) { $objGroup = new class_module_user_group($strValue); $objGroup->getObjSourceGroup()->removeMember($objUser->getObjSourceUser()); } } if ($this->getParam("folderview")) { $this->adminReload(class_link::getLinkAdminHref($this->getArrModule("modul"), "list", "&peClose=1&blockAction=1")); } else { $this->adminReload(class_link::getLinkAdminHref($this->getArrModule("modul"), "list")); } }
/** * Updates the current object to the database * * @param bool $strPrevId * * @return bool */ public function updateObjectToDb($strPrevId = false) { //mode-splitting if ($this->getSystemid() == "") { class_logger::getInstance(class_logger::USERSOURCES)->addLogRow("saved new group subsystem " . $this->getStrSubsystem() . " / " . $this->getStrSystemid(), class_logger::$levelInfo); $strGrId = generateSystemid(); $this->setSystemid($strGrId); $strQuery = "INSERT INTO " . _dbprefix_ . "user_group\n (group_id, group_subsystem, group_name) VALUES\n (?, ?, ?)"; $bitReturn = $this->objDB->_pQuery($strQuery, array($strGrId, $this->getStrSubsystem(), $this->getStrName())); //create the new instance on the remote-system $objSources = new class_module_user_sourcefactory(); $objProvider = $objSources->getUsersource($this->getStrSubsystem()); $objTargetGroup = $objProvider->getNewGroup(); $objTargetGroup->updateObjectToDb(); $objTargetGroup->setNewRecordId($this->getSystemid()); $this->objDB->flushQueryCache(); return $bitReturn; } else { class_logger::getInstance(class_logger::USERSOURCES)->addLogRow("updated group " . $this->getStrName(), class_logger::$levelInfo); $strQuery = "UPDATE " . _dbprefix_ . "user_group\n SET group_subsystem=?,\n group_name=?\n WHERE group_id=?"; return $this->objDB->_pQuery($strQuery, array($this->getStrSubsystem(), $this->getStrName(), $this->getSystemid())); } }