function FormatPropertiesForDatabaseInput() { $this->RoleName = FormatStringForDatabaseInput($this->RoleName, 1); $this->Icon = FormatStringForDatabaseInput($this->Icon, 1); $this->Description = FormatStringForDatabaseInput($this->Description, 1); if (is_array($this->Permissions)) { // Make sure to remove the hard-coded permissions from the array before saving if (array_key_exists('PERMISSION_SIGN_IN', $this->Permissions)) { unset($this->Permissions['PERMISSION_SIGN_IN']); } if (array_key_exists('PERMISSION_HTML_ALLOWED', $this->Permissions)) { unset($this->Permissions['PERMISSION_HTML_ALLOWED']); } if (array_key_exists('PERMISSION_RECEIVE_APPLICATION_NOTIFICATION', $this->Permissions)) { unset($this->Permissions['PERMISSION_RECEIVE_APPLICATION_NOTIFICATION']); } // Now serialize the array $this->Permissions = SerializeArray($this->Permissions); } }
function SaveUserPreferences($User) { if ($User->UserID > 0) { // Serialize and save the settings $SerializedPreferences = SerializeArray($User->Preferences); $s = $this->Context->ObjectFactory->NewContextObject($this->Context, 'SqlBuilder'); $s->SetMainTable('User', 'u'); $s->AddFieldNameValue('Preferences', $SerializedPreferences); $s->AddWhere('u', 'UserID', '', $User->UserID, '='); $this->Context->Database->Update($s, $this->Name, 'SaveUserPreferences', 'An error occurred while manipulating user preferences.'); } return true; }
$Permissions['PERMISSION_EDIT_USERS'] = ForceBool(@$Row['AdminUsers'], 0); $Permissions['PERMISSION_IP_ADDRESSES_VISIBLE'] = ForceBool(@$Row['CanViewIps'], 0); $Permissions['PERMISSION_MANAGE_REGISTRATION'] = ForceBool(@$Row['AdminUsers'], 0); $Permissions['PERMISSION_SORT_ROLES'] = ForceBool(@$Row['AdminUsers'], 0); $Permissions['PERMISSION_ADD_ROLES'] = ForceBool(@$Row['AdminUsers'], 0); $Permissions['PERMISSION_EDIT_ROLES'] = ForceBool(@$Row['AdminUsers'], 0); $Permissions['PERMISSION_REMOVE_ROLES'] = ForceBool(@$Row['AdminUsers'], 0); // Administrative Permissions $Permissions['PERMISSION_CHECK_FOR_UPDATES'] = ForceBool(@$Row['MasterAdmin'], 0); $Permissions['PERMISSION_CHANGE_APPLICATION_SETTINGS'] = ForceBool(@$Row['MasterAdmin'], 0); $Permissions['PERMISSION_MANAGE_EXTENSIONS'] = ForceBool(@$Row['MasterAdmin'], 0); $Permissions['PERMISSION_MANAGE_LANGUAGE'] = ForceBool(@$Row['MasterAdmin'], 0); $Permissions['PERMISSION_MANAGE_THEMES'] = ForceBool(@$Row['MasterAdmin'], 0); $Permissions['PERMISSION_MANAGE_STYLES'] = ForceBool(@$Row['MasterAdmin'], 0); $Permissions['PERMISSION_ALLOW_DEBUG_INFO'] = ForceBool(@$Row['MasterAdmin'], 0); $UpdateSQL = "update " . $DatabaseTables['Role'] . " set Permissions = '" . SerializeArray($Permissions) . "' where RoleID = " . $RoleID; if (!@mysql_query($UpdateSQL, $Connection)) { $Context->WarningCollector->Add("An error occurred while updating LUM_Role data. MySQL reported the following error: <code>" . mysql_error($Connection) . '</code>'); break; } // Clear out the permissions array $Permissions = array(); } } } // 1d. Remove old permission columns if ($Context->WarningCollector->Count() == 0) { // Silently drop these columns. If any errors occur, it doesn't // really slow anything down to leave them behind. It's just clutter. if (in_array('CanPostDiscussion', $RoleColumns)) { $AlterSQL = "alter table " . $DatabaseTables['Role'] . " drop column CanPostDiscussion";
function SwitchUserSetting($SettingName, $Switch, $DefaultValue = "0") { $Switch = ForceBool($Switch, 0); if ($this->Context->Session->UserID == 0) { $this->Context->WarningCollector->Add($this->Context->GetDefinition("ErrUserID")); } if ($this->Context->WarningCollector->Count() == 0) { $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder"); // Set the value for the user $this->Context->Session->User->Settings[$SettingName] = $Switch; // Serialize and save the settings $SerializedSettings = SerializeArray($this->Context->Session->User->Settings); $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder"); $s->SetMainTable("User"); $s->AddFieldNameValue("Settings", $SerializedSettings); $s->AddWhere("UserID", $this->Context->Session->User->UserID, "="); $this->Context->Database->Update($this->Context, $s, $this->Name, "SwitchUserSetting", "An error occurred while manipulating user settings."); } return $this->Context->WarningCollector->Iif(); }
function FormatPropertiesForDatabaseInput() { $this->CustomStyle = FormatStringForDatabaseInput($this->CustomStyle, 1); $this->Name = FormatStringForDatabaseInput($this->Name, 1); $this->FirstName = FormatStringForDatabaseInput($this->FirstName, 1); $this->LastName = FormatStringForDatabaseInput($this->LastName, 1); $this->Email = FormatStringForDatabaseInput($this->Email, 1); $this->Icon = FormatStringForDatabaseInput($this->Icon, 1); $this->Picture = FormatStringForDatabaseInput($this->Picture, 1); $this->Password = FormatStringForDatabaseInput($this->Password, 1); $this->OldPassword = FormatStringForDatabaseInput($this->OldPassword, 1); $this->NewPassword = FormatStringForDatabaseInput($this->NewPassword, 1); $this->ConfirmPassword = FormatStringForDatabaseInput($this->ConfirmPassword, 1); $this->VerificationKey = FormatStringForDatabaseInput($this->VerificationKey); $this->Attributes = SerializeArray($this->Attributes); $this->Discovery = FormatStringForDatabaseInput($this->Discovery, 1); }