$RoleModel->define(array('Name' => 'Applicant', 'Type' => RoleModel::TYPE_APPLICANT, 'RoleID' => 4, 'Sort' => $Sort++, 'Deletable' => '0', 'CanSession' => '1', 'Description' => t('Applicant Role Description', 'Users who have applied for membership, but have not yet been accepted. They have the same permissions as guests.'))); $RoleModel->define(array('Name' => 'Member', 'Type' => RoleModel::TYPE_MEMBER, 'RoleID' => 8, 'Sort' => $Sort++, 'Deletable' => '1', 'CanSession' => '1', 'Description' => t('Member Role Description', 'Members can participate in discussions.'))); $RoleModel->define(array('Name' => 'Moderator', 'Type' => RoleModel::TYPE_MODERATOR, 'RoleID' => 32, 'Sort' => $Sort++, 'Deletable' => '1', 'CanSession' => '1', 'Description' => t('Moderator Role Description', 'Moderators have permission to edit most content.'))); $RoleModel->define(array('Name' => 'Administrator', 'Type' => RoleModel::TYPE_ADMINISTRATOR, 'RoleID' => 16, 'Sort' => $Sort++, 'Deletable' => '1', 'CanSession' => '1', 'Description' => t('Administrator Role Description', 'Administrators have permission to do anything.'))); } // User Table $Construct->table('User'); $PhotoIDExists = $Construct->columnExists('PhotoID'); $PhotoExists = $Construct->columnExists('Photo'); $UserExists = $Construct->tableExists(); $ConfirmedExists = $Construct->columnExists('Confirmed'); $Construct->primaryKey('UserID')->column('Name', 'varchar(50)', false, 'key')->column('Password', 'varbinary(100)')->column('HashMethod', 'varchar(10)', true)->column('Photo', 'varchar(255)', null)->column('Title', 'varchar(100)', null)->column('Location', 'varchar(100)', null)->column('About', 'text', true)->column('Email', 'varchar(100)', false, 'index')->column('ShowEmail', 'tinyint(1)', '0')->column('Gender', array('u', 'm', 'f'), 'u')->column('CountVisits', 'int', '0')->column('CountInvitations', 'int', '0')->column('CountNotifications', 'int', null)->column('InviteUserID', 'int', true)->column('DiscoveryText', 'text', true)->column('Preferences', 'text', true)->column('Permissions', 'text', true)->column('Attributes', 'text', true)->column('DateSetInvitations', 'datetime', true)->column('DateOfBirth', 'datetime', true)->column('DateFirstVisit', 'datetime', true)->column('DateLastActive', 'datetime', true, 'index')->column('LastIPAddress', 'varchar(15)', true)->column('AllIPAddresses', 'varchar(100)', true)->column('DateInserted', 'datetime', false, 'index')->column('InsertIPAddress', 'varchar(15)', true)->column('DateUpdated', 'datetime', true)->column('UpdateIPAddress', 'varchar(15)', true)->column('HourOffset', 'int', '0')->column('Score', 'float', null)->column('Admin', 'tinyint(1)', '0')->column('Confirmed', 'tinyint(1)', '1')->column('Verified', 'tinyint(1)', '0')->column('Banned', 'tinyint(1)', '0')->column('Deleted', 'tinyint(1)', '0')->column('Points', 'int', 0)->set($Explicit, $Drop); // Modify all users with ConfirmEmail role to be unconfirmed if ($UserExists && !$ConfirmedExists) { $ConfirmEmailRoleID = RoleModel::getDefaultRoles(RoleModel::TYPE_UNCONFIRMED); if (UserModel::requireConfirmEmail() && !empty($ConfirmEmailRoleID)) { // Select unconfirmed users $Users = Gdn::sql()->select('UserID')->from('UserRole')->where('RoleID', $ConfirmEmailRoleID)->get(); $UserIDs = array(); while ($User = $Users->nextRow(DATASET_TYPE_ARRAY)) { $UserIDs[] = $User['UserID']; } // Update Gdn::sql()->update('User')->set('Confirmed', 0)->whereIn('UserID', $UserIDs)->put(); Gdn::sql()->delete('UserRole', array('RoleID' => $ConfirmEmailRoleID, 'UserID' => $UserIDs)); } } // Make sure the system user is okay. $SystemUserID = c('Garden.SystemUserID'); if ($SystemUserID) { $SysUser = Gdn::userModel()->getID($SystemUserID);
/** * Edit a user account. * * @since 2.0.0 * @access public * @param int $UserID Unique ID. */ public function edit($UserID) { $this->permission('Garden.Users.Edit'); // Page setup $this->addJsFile('user.js'); $this->title(t('Edit User')); $this->setHighlightRoute('dashboard/user'); // Only admins can reassign roles $RoleModel = new RoleModel(); $AllRoles = $RoleModel->getArray(); $RoleData = $RoleModel->getAssignable(); $UserModel = new UserModel(); $User = $UserModel->getID($UserID, DATASET_TYPE_ARRAY); // Determine if username can be edited $CanEditUsername = (bool) c("Garden.Profile.EditUsernames") || Gdn::session()->checkPermission('Garden.Users.Edit'); $this->setData('_CanEditUsername', $CanEditUsername); // Determine if emails can be edited $CanEditEmail = Gdn::session()->checkPermission('Garden.Users.Edit'); $this->setData('_CanEditEmail', $CanEditEmail); // Decide if they have ability to confirm users $Confirmed = (bool) valr('Confirmed', $User); $CanConfirmEmail = UserModel::requireConfirmEmail() && Gdn::session()->checkPermission('Garden.Users.Edit'); $this->setData('_CanConfirmEmail', $CanConfirmEmail); $this->setData('_EmailConfirmed', $Confirmed); $User['ConfirmEmail'] = (int) $Confirmed; // Determine whether user being edited is privileged (can escalate permissions) $UserModel = new UserModel(); $EditingPrivilegedUser = $UserModel->checkPermission($User, 'Garden.Settings.Manage'); // Determine our password reset options // Anyone with user editing my force reset over email $this->ResetOptions = array(0 => t('Keep current password.'), 'Auto' => t('Force user to reset their password and send email notification.')); // Only admins may manually reset passwords for other admins if (checkPermission('Garden.Settings.Manage') || !$EditingPrivilegedUser) { $this->ResetOptions['Manual'] = t('Manually set user password. No email notification.'); } // Set the model on the form. $this->Form->setModel($UserModel); // Make sure the form knows which item we are editing. $this->Form->addHidden('UserID', $UserID); try { $AllowEditing = true; $this->EventArguments['AllowEditing'] =& $AllowEditing; $this->EventArguments['TargetUser'] =& $User; // These are all the 'effective' roles for this edit action. This list can // be trimmed down from the real list to allow subsets of roles to be edited. $this->EventArguments['RoleData'] =& $RoleData; $UserRoleData = $UserModel->getRoles($UserID)->resultArray(); $RoleIDs = array_column($UserRoleData, 'RoleID'); $RoleNames = array_column($UserRoleData, 'Name'); $UserRoleData = arrayCombine($RoleIDs, $RoleNames); $this->EventArguments['UserRoleData'] =& $UserRoleData; $this->fireEvent("BeforeUserEdit"); $this->setData('AllowEditing', $AllowEditing); $BanReversible = $User['Banned'] & (BanModel::BAN_AUTOMATIC | BanModel::BAN_MANUAL); $this->setData('BanFlag', $BanReversible ? $User['Banned'] : 1); $this->setData('BannedOtherReasons', $User['Banned'] & ~BanModel::BAN_MANUAL); $this->Form->setData($User); if ($this->Form->authenticatedPostBack(true)) { // Do not re-validate or change the username if disabled or exactly the same. $nameUnchanged = $User['Name'] === $this->Form->getValue('Name'); if (!$CanEditUsername || $nameUnchanged) { $this->Form->removeFormValue("Name"); } // Allow mods to confirm/unconfirm emails $this->Form->removeFormValue('Confirmed'); $Confirmation = $this->Form->getFormValue('ConfirmEmail', null); $Confirmation = !is_null($Confirmation) ? (bool) $Confirmation : null; if ($CanConfirmEmail && is_bool($Confirmation)) { $this->Form->setFormValue('Confirmed', (int) $Confirmation); } $ResetPassword = $this->Form->getValue('ResetPassword', false); // If we're an admin or this isn't a privileged user, allow manual setting of password $AllowManualReset = checkPermission('Garden.Settings.Manage') || !$EditingPrivilegedUser; if ($ResetPassword == 'Manual' && $AllowManualReset) { // If a new password was specified, add it to the form's collection $NewPassword = $this->Form->getValue('NewPassword', ''); $this->Form->setFormValue('Password', $NewPassword); } // Role changes // These are the new roles the editing user wishes to apply to the target // user, adjusted for his ability to affect those roles $RequestedRoles = $this->Form->getFormValue('RoleID'); if (!is_array($RequestedRoles)) { $RequestedRoles = array(); } $RequestedRoles = array_flip($RequestedRoles); $UserNewRoles = array_intersect_key($RoleData, $RequestedRoles); // These roles will stay turned on regardless of the form submission contents // because the editing user does not have permission to modify them $ImmutableRoles = array_diff_key($AllRoles, $RoleData); $UserImmutableRoles = array_intersect_key($ImmutableRoles, $UserRoleData); // Apply immutable roles foreach ($UserImmutableRoles as $IMRoleID => $IMRoleName) { $UserNewRoles[$IMRoleID] = $IMRoleName; } // Put the data back into the forum object as if the user had submitted // this themselves $this->Form->setFormValue('RoleID', array_keys($UserNewRoles)); $Banned = $this->Form->getFormValue('Banned'); if (!$Banned) { // Checkbox was unchecked; bitmask to remove any reversible bans. if ($BanReversible) { $reversedBans = $User['Banned'] & ~(BanModel::BAN_AUTOMATIC | BanModel::BAN_MANUAL); $this->Form->setFormValue('Banned', $reversedBans); } } else { // Bitmask to add a manual ban. $this->Form->setFormValue('Banned', $User['Banned'] | BanModel::BAN_MANUAL); } if ($this->Form->save(array('SaveRoles' => true)) !== false) { if ($this->Form->getValue('ResetPassword', '') == 'Auto') { $UserModel->PasswordRequest($User['Email']); $UserModel->setField($UserID, 'HashMethod', 'Reset'); } $this->informMessage(t('Your changes have been saved.')); } $UserRoleData = $UserNewRoles; } } catch (Exception $Ex) { $this->Form->addError($Ex); } $this->setData('User', $User); $this->setData('Roles', $RoleData); $this->setData('UserRoles', $UserRoleData); $this->render(); }
/** * Edit user account. * * @since 2.0.0 * @access public * @param mixed $UserReference Username or User ID. */ public function edit($UserReference = '', $Username = '', $UserID = '') { $this->permission('Garden.SignIn.Allow'); $this->getUserInfo($UserReference, $Username, $UserID, true); $UserID = valr('User.UserID', $this); $Settings = array(); // Set up form $User = Gdn::userModel()->getID($UserID, DATASET_TYPE_ARRAY); $this->Form->setModel(Gdn::userModel()); $this->Form->setData($User); // Decide if they have ability to edit the username $CanEditUsername = (bool) c("Garden.Profile.EditUsernames") || Gdn::session()->checkPermission('Garden.Users.Edit'); $this->setData('_CanEditUsername', $CanEditUsername); // Decide if they have ability to edit the email $EmailEnabled = (bool) c('Garden.Profile.EditEmails', true) && !UserModel::noEmail(); $CanEditEmail = $EmailEnabled && $UserID == Gdn::session()->UserID || checkPermission('Garden.Users.Edit'); $this->setData('_CanEditEmail', $CanEditEmail); // Decide if they have ability to confirm users $Confirmed = (bool) valr('User.Confirmed', $this); $CanConfirmEmail = UserModel::requireConfirmEmail() && checkPermission('Garden.Users.Edit'); $this->setData('_CanConfirmEmail', $CanConfirmEmail); $this->setData('_EmailConfirmed', $Confirmed); $this->Form->setValue('ConfirmEmail', (int) $Confirmed); // Decide if we can *see* email $this->setData('_CanViewPersonalInfo', Gdn::session()->UserID == val('UserID', $User) || checkPermission('Garden.PersonalInfo.View') || checkPermission('Garden.Users.Edit')); // Define gender dropdown options $this->GenderOptions = array('u' => t('Unspecified'), 'm' => t('Male'), 'f' => t('Female')); $this->fireEvent('BeforeEdit'); // If seeing the form for the first time... if ($this->Form->authenticatedPostBack()) { $this->Form->setFormValue('UserID', $UserID); if (!$CanEditUsername) { $this->Form->setFormValue("Name", $User['Name']); } else { $UsernameError = t('UsernameError', 'Username can only contain letters, numbers, underscores, and must be between 3 and 20 characters long.'); Gdn::userModel()->Validation->applyRule('Name', 'Username', $UsernameError); } // API // These options become available when POSTing as a user with Garden.Settings.Manage permissions if (Gdn::session()->checkPermission('Garden.Settings.Manage')) { // Role change $RequestedRoles = $this->Form->getFormValue('RoleID', null); if (!is_null($RequestedRoles)) { $RoleModel = new RoleModel(); $AllRoles = $RoleModel->getArray(); if (!is_array($RequestedRoles)) { $RequestedRoles = is_numeric($RequestedRoles) ? array($RequestedRoles) : array(); } $RequestedRoles = array_flip($RequestedRoles); $UserNewRoles = array_intersect_key($AllRoles, $RequestedRoles); // Put the data back into the forum object as if the user had submitted // this themselves $this->Form->setFormValue('RoleID', array_keys($UserNewRoles)); // Allow saving roles $Settings['SaveRoles'] = true; } // Password change $NewPassword = $this->Form->getFormValue('Password', null); if (!is_null($NewPassword)) { } } // Allow mods to confirm emails $this->Form->removeFormValue('Confirmed'); $Confirmation = $this->Form->getFormValue('ConfirmEmail', null); $Confirmation = !is_null($Confirmation) ? (bool) $Confirmation : null; if ($CanConfirmEmail && is_bool($Confirmation)) { $this->Form->setFormValue('Confirmed', (int) $Confirmation); } if ($this->Form->save($Settings) !== false) { $User = Gdn::userModel()->getID($UserID, DATASET_TYPE_ARRAY); $this->setData('Profile', $User); $this->informMessage(sprite('Check', 'InformSprite') . t('Your changes have been saved.'), 'Dismissable AutoDismiss HasSprite'); } if (!$CanEditEmail) { $this->Form->setFormValue("Email", $User['Email']); } } $this->title(t('Edit Profile')); $this->_setBreadcrumbs(t('Edit Profile'), '/profile/edit'); $this->render(); }
/** * Fire before every page render. * * @param Gdn_Controller $Sender */ public function base_render_before($Sender) { $Session = Gdn::session(); if ($Sender->MasterView == 'admin') { if (val('Form', $Sender)) { $Sender->Form->setStyles('bootstrap'); } $Sender->CssClass = htmlspecialchars($Sender->CssClass); $Sections = Gdn_Theme::section(null, 'get'); if (is_array($Sections)) { foreach ($Sections as $Section) { $Sender->CssClass .= ' Section-' . $Section; } } // Get our plugin nav items. $navAdapter = new NestedCollectionAdapter(DashboardNavModule::getDashboardNav()); $Sender->EventArguments['SideMenu'] = $navAdapter; $Sender->fireEvent('GetAppSettingsMenuItems'); $Sender->removeJsFile('jquery.popup.js'); $Sender->addJsFile('vendors/jquery.checkall.min.js', 'dashboard'); $Sender->addJsFile('dashboard.js', 'dashboard'); $Sender->addJsFile('jquery.expander.js'); $Sender->addJsFile('settings.js', 'dashboard'); $Sender->addJsFile('vendors/tether.min.js', 'dashboard'); $Sender->addJsFile('vendors/bootstrap/util.js', 'dashboard'); $Sender->addJsFile('vendors/drop.min.js', 'dashboard'); $Sender->addJsFile('vendors/moment.min.js', 'dashboard'); $Sender->addJsFile('vendors/daterangepicker.js', 'dashboard'); $Sender->addJsFile('vendors/bootstrap/tooltip.js', 'dashboard'); $Sender->addJsFile('vendors/clipboard.min.js', 'dashboard'); $Sender->addJsFile('vendors/bootstrap/dropdown.js', 'dashboard'); $Sender->addJsFile('vendors/bootstrap/collapse.js', 'dashboard'); $Sender->addJsFile('vendors/bootstrap/modal.js', 'dashboard'); $Sender->addJsFile('vendors/icheck.min.js', 'dashboard'); $Sender->addJsFile('jquery.tablejenga.js', 'dashboard'); $Sender->addJsFile('jquery.fluidfixed.js', 'dashboard'); $Sender->addJsFile('vendors/prettify/prettify.js', 'dashboard'); $Sender->addJsFile('vendors/ace/ace.js', 'dashboard'); $Sender->addJsFile('vendors/ace/ext-searchbox.js', 'dashboard'); $Sender->addCssFile('vendors/tomorrow.css', 'dashboard'); } // Check the statistics. if ($Sender->deliveryType() == DELIVERY_TYPE_ALL) { Gdn::statistics()->check(); } // Inform user of theme previewing if ($Session->isValid()) { $PreviewThemeFolder = htmlspecialchars($Session->getPreference('PreviewThemeFolder', '')); $PreviewMobileThemeFolder = htmlspecialchars($Session->getPreference('PreviewMobileThemeFolder', '')); $PreviewThemeName = htmlspecialchars($Session->getPreference('PreviewThemeName', $PreviewThemeFolder)); $PreviewMobileThemeName = htmlspecialchars($Session->getPreference('PreviewMobileThemeName', $PreviewMobileThemeFolder)); if ($PreviewThemeFolder != '') { $Sender->informMessage(sprintf(t('You are previewing the %s desktop theme.'), wrap($PreviewThemeName, 'em')) . '<div class="PreviewThemeButtons">' . anchor(t('Apply'), 'settings/themes/' . $PreviewThemeFolder . '/' . $Session->transientKey(), 'PreviewThemeButton') . ' ' . anchor(t('Cancel'), 'settings/cancelpreview/' . $PreviewThemeFolder . '/' . $Session->transientKey(), 'PreviewThemeButton') . '</div>', 'DoNotDismiss'); } if ($PreviewMobileThemeFolder != '') { $Sender->informMessage(sprintf(t('You are previewing the %s mobile theme.'), wrap($PreviewMobileThemeName, 'em')) . '<div class="PreviewThemeButtons">' . anchor(t('Apply'), 'settings/mobilethemes/' . $PreviewMobileThemeFolder . '/' . $Session->transientKey(), 'PreviewThemeButton') . ' ' . anchor(t('Cancel'), 'settings/cancelpreview/' . $PreviewMobileThemeFolder . '/' . $Session->transientKey(), 'PreviewThemeButton') . '</div>', 'DoNotDismiss'); } } if ($Session->isValid()) { $Confirmed = val('Confirmed', Gdn::session()->User, true); if (UserModel::requireConfirmEmail() && !$Confirmed) { $Message = formatString(t('You need to confirm your email address.', 'You need to confirm your email address. Click <a href="{/entry/emailconfirmrequest,url}">here</a> to resend the confirmation email.')); $Sender->informMessage($Message, ''); } } // Add Message Modules (if necessary) $MessageCache = Gdn::config('Garden.Messages.Cache', array()); $Location = $Sender->Application . '/' . substr($Sender->ControllerName, 0, -10) . '/' . $Sender->RequestMethod; $Exceptions = array('[Base]'); if (in_array($Sender->MasterView, array('', 'default'))) { $Exceptions[] = '[NonAdmin]'; } // SignIn popup is a special case $SignInOnly = $Sender->deliveryType() == DELIVERY_TYPE_VIEW && $Location == 'Dashboard/entry/signin'; if ($SignInOnly) { $Exceptions = array(); } if ($Sender->MasterView != 'admin' && !$Sender->data('_NoMessages') && (val('MessagesLoaded', $Sender) != '1' && $Sender->MasterView != 'empty' && ArrayInArray($Exceptions, $MessageCache, false) || InArrayI($Location, $MessageCache))) { $MessageModel = new MessageModel(); $MessageData = $MessageModel->getMessagesForLocation($Location, $Exceptions, $Sender->data('Category.CategoryID')); foreach ($MessageData as $Message) { $MessageModule = new MessageModule($Sender, $Message); if ($SignInOnly) { // Insert special messages even in SignIn popup echo $MessageModule; } elseif ($Sender->deliveryType() == DELIVERY_TYPE_ALL) { $Sender->addModule($MessageModule); } } $Sender->MessagesLoaded = '1'; // Fixes a bug where render gets called more than once and messages are loaded/displayed redundantly. } if ($Sender->deliveryType() == DELIVERY_TYPE_ALL) { $Gdn_Statistics = Gdn::factory('Statistics'); $Gdn_Statistics->check($Sender); } // Allow forum embedding if ($Embed = c('Garden.Embed.Allow')) { // Record the remote url where the forum is being embedded. $RemoteUrl = c('Garden.Embed.RemoteUrl'); if (!$RemoteUrl) { $RemoteUrl = GetIncomingValue('remote'); if ($RemoteUrl) { saveToConfig('Garden.Embed.RemoteUrl', $RemoteUrl); } } if ($RemoteUrl) { $Sender->addDefinition('RemoteUrl', $RemoteUrl); } if ($remoteUrlFormat = c('Garden.Embed.RemoteUrlFormat')) { $Sender->addDefinition('RemoteUrlFormat', $remoteUrlFormat); } // Force embedding? if (!IsSearchEngine() && strtolower($Sender->ControllerName) != 'entry') { if (IsMobile()) { $forceEmbedForum = c('Garden.Embed.ForceMobile') ? '1' : '0'; } else { $forceEmbedForum = c('Garden.Embed.ForceForum') ? '1' : '0'; } $Sender->addDefinition('ForceEmbedForum', $forceEmbedForum); $Sender->addDefinition('ForceEmbedDashboard', c('Garden.Embed.ForceDashboard') ? '1' : '0'); } $Sender->addDefinition('Path', Gdn::request()->path()); $get = Gdn::request()->get(); unset($get['p']); // kludge for old index.php?p=/path $Sender->addDefinition('Query', http_build_query($get)); // $Sender->addDefinition('MasterView', $Sender->MasterView); $Sender->addDefinition('InDashboard', $Sender->MasterView == 'admin' ? '1' : '0'); if ($Embed === 2) { $Sender->addJsFile('vanilla.embed.local.js'); } else { $Sender->addJsFile('embed_local.js'); } } else { $Sender->setHeader('X-Frame-Options', 'SAMEORIGIN'); } // Allow return to mobile site $ForceNoMobile = val('X-UA-Device-Force', $_COOKIE); if ($ForceNoMobile === 'desktop') { $Sender->addAsset('Foot', wrap(Anchor(t('Back to Mobile Site'), '/profile/nomobile/1'), 'div'), 'MobileLink'); } // Allow global translation of TagHint $Sender->addDefinition("TagHint", t("TagHint", "Start to type...")); // Add symbols. if ($Sender->deliveryMethod() === DELIVERY_METHOD_XHTML) { $Sender->addAsset('Symbols', $Sender->fetchView('symbols', '', 'Dashboard')); } }
/** * Fire before every page render. * * @param Gdn_Controller $Sender */ public function base_render_before($Sender) { $Session = Gdn::session(); // Check the statistics. if ($Sender->deliveryType() == DELIVERY_TYPE_ALL) { Gdn::statistics()->check(); } // Enable theme previewing if ($Session->isValid()) { $PreviewThemeName = htmlspecialchars($Session->getPreference('PreviewThemeName', '')); $PreviewThemeFolder = htmlspecialchars($Session->getPreference('PreviewThemeFolder', '')); if ($PreviewThemeName != '') { $Sender->Theme = $PreviewThemeName; $Sender->informMessage(sprintf(t('You are previewing the %s theme.'), wrap($PreviewThemeName, 'em')) . '<div class="PreviewThemeButtons">' . anchor(t('Apply'), 'settings/themes/' . $PreviewThemeName . '/' . $Session->transientKey(), 'PreviewThemeButton') . ' ' . anchor(t('Cancel'), 'settings/cancelpreview/', 'PreviewThemeButton') . '</div>', 'DoNotDismiss'); } } if ($Session->isValid()) { $Confirmed = val('Confirmed', Gdn::session()->User, true); if (UserModel::requireConfirmEmail() && !$Confirmed) { $Message = formatString(t('You need to confirm your email address.', 'You need to confirm your email address. Click <a href="{/entry/emailconfirmrequest,url}">here</a> to resend the confirmation email.')); $Sender->informMessage($Message, ''); } } // Add Message Modules (if necessary) $MessageCache = Gdn::config('Garden.Messages.Cache', array()); $Location = $Sender->Application . '/' . substr($Sender->ControllerName, 0, -10) . '/' . $Sender->RequestMethod; $Exceptions = array('[Base]'); if (in_array($Sender->MasterView, array('', 'default'))) { $Exceptions[] = '[NonAdmin]'; } // SignIn popup is a special case $SignInOnly = $Sender->deliveryType() == DELIVERY_TYPE_VIEW && $Location == 'Dashboard/entry/signin'; if ($SignInOnly) { $Exceptions = array(); } if ($Sender->MasterView != 'admin' && !$Sender->data('_NoMessages') && (val('MessagesLoaded', $Sender) != '1' && $Sender->MasterView != 'empty' && ArrayInArray($Exceptions, $MessageCache, false) || InArrayI($Location, $MessageCache))) { $MessageModel = new MessageModel(); $MessageData = $MessageModel->getMessagesForLocation($Location, $Exceptions, $Sender->data('Category.CategoryID')); foreach ($MessageData as $Message) { $MessageModule = new MessageModule($Sender, $Message); if ($SignInOnly) { // Insert special messages even in SignIn popup echo $MessageModule; } elseif ($Sender->deliveryType() == DELIVERY_TYPE_ALL) { $Sender->addModule($MessageModule); } } $Sender->MessagesLoaded = '1'; // Fixes a bug where render gets called more than once and messages are loaded/displayed redundantly. } if ($Sender->deliveryType() == DELIVERY_TYPE_ALL) { $Gdn_Statistics = Gdn::factory('Statistics'); $Gdn_Statistics->check($Sender); } // Allow forum embedding if ($Embed = c('Garden.Embed.Allow')) { // Record the remote url where the forum is being embedded. $RemoteUrl = c('Garden.Embed.RemoteUrl'); if (!$RemoteUrl) { $RemoteUrl = GetIncomingValue('remote'); if ($RemoteUrl) { saveToConfig('Garden.Embed.RemoteUrl', $RemoteUrl); } } if ($RemoteUrl) { $Sender->addDefinition('RemoteUrl', $RemoteUrl); } if ($remoteUrlFormat = c('Garden.Embed.RemoteUrlFormat')) { $Sender->addDefinition('RemoteUrlFormat', $remoteUrlFormat); } // Force embedding? if (!IsSearchEngine() && strtolower($Sender->ControllerName) != 'entry') { if (IsMobile()) { $forceEmbedForum = c('Garden.Embed.ForceMobile') ? '1' : '0'; } else { $forceEmbedForum = c('Garden.Embed.ForceForum') ? '1' : '0'; } $Sender->addDefinition('ForceEmbedForum', $forceEmbedForum); $Sender->addDefinition('ForceEmbedDashboard', c('Garden.Embed.ForceDashboard') ? '1' : '0'); } $Sender->addDefinition('Path', Gdn::request()->path()); $get = Gdn::request()->get(); unset($get['p']); // kludge for old index.php?p=/path $Sender->addDefinition('Query', http_build_query($get)); // $Sender->addDefinition('MasterView', $Sender->MasterView); $Sender->addDefinition('InDashboard', $Sender->MasterView == 'admin' ? '1' : '0'); if ($Embed === 2) { $Sender->addJsFile('vanilla.embed.local.js'); } else { $Sender->addJsFile('embed_local.js'); } } else { $Sender->setHeader('X-Frame-Options', 'SAMEORIGIN'); } // Allow return to mobile site $ForceNoMobile = val('X-UA-Device-Force', $_COOKIE); if ($ForceNoMobile === 'desktop') { $Sender->addAsset('Foot', wrap(Anchor(t('Back to Mobile Site'), '/profile/nomobile/1'), 'div'), 'MobileLink'); } // Allow global translation of TagHint $Sender->addDefinition("TagHint", t("TagHint", "Start to type...")); }