public function Base_Render_Before(&$Sender) { $Session = Gdn::Session(); // Enable theme previewing if ($Session->IsValid()) { $PreviewThemeFolder = $Session->GetPreference('PreviewThemeFolder', ''); // echo 'test'.$PreviewThemeFolder; if ($PreviewThemeFolder != '') { $Sender->Theme = $PreviewThemeFolder; $Sender->AddAsset('Content', $Sender->FetchView('previewtheme', 'settingscontroller', 'dashboard')); $Sender->AddCssFile('previewtheme.css'); } } // Add Message Modules (if necessary) $MessageCache = Gdn::Config('Garden.Messages.Cache', array()); $Location = $Sender->Application . '/' . substr($Sender->ControllerName, 0, -10) . '/' . $Sender->RequestMethod; if ($Sender->MasterView != 'empty' && in_array('Base', $MessageCache) || InArrayI($Location, $MessageCache)) { $MessageModel = new MessageModel(); $MessageData = $MessageModel->GetMessagesForLocation($Location); foreach ($MessageData as $Message) { $MessageModule = new MessageModule($Sender, $Message); $Sender->AddModule($MessageModule); } } }
public function Base_Render_Before(&$Sender) { $Session = Gdn::Session(); // Enable theme previewing if ($Session->IsValid()) { $PreviewThemeFolder = $Session->GetPreference('PreviewThemeFolder', ''); // echo 'test'.$PreviewThemeFolder; if ($PreviewThemeFolder != '') { $Sender->Theme = $PreviewThemeFolder; $Sender->AddAsset('Content', $Sender->FetchView('previewtheme', 'settingscontroller', 'dashboard')); $Sender->AddCssFile('previewtheme.css'); } } // 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 ($Sender->MasterView == 'admin') { $Exceptions[] = '[Admin]'; } else { if (in_array($Sender->MasterView, array('', 'default'))) { $Exceptions[] = '[NonAdmin]'; } } if ($Sender->MasterView != 'empty' && ArrayInArray($Exceptions, $MessageCache, FALSE) || InArrayI($Location, $MessageCache)) { $MessageModel = new MessageModel(); $MessageData = $MessageModel->GetMessagesForLocation($Location, $Exceptions); foreach ($MessageData as $Message) { $MessageModule = new MessageModule($Sender, $Message); $Sender->AddModule($MessageModule); } } // If there are applicants, alert admins by showing in the main menu if (in_array($Sender->MasterView, array('', 'default')) && $Sender->Menu && C('Garden.Registration.Method') == 'Approval') { $CountApplicants = Gdn::UserModel()->GetApplicants()->NumRows(); if ($CountApplicants > 0) { $Sender->Menu->AddLink('Applicants', T('Applicants') . ' <span>' . $CountApplicants . '</span>', '/dashboard/user/applicants', array('Garden.Registration.Manage')); } } }
/** * * @param Gdn_Controller $Sender */ public function Base_Render_Before(&$Sender) { $Session = Gdn::Session(); // Enable theme previewing if ($Session->IsValid()) { $PreviewThemeName = $Session->GetPreference('PreviewThemeName', ''); $PreviewThemeFolder = $Session->GetPreference('PreviewThemeFolder', ''); if ($PreviewThemeName != '') { $Sender->Theme = $PreviewThemeName; $Sender->InformMessage(sprintf(T('You are previewing the %s theme.'), Wrap($PreviewThemeName, 'em')) . '<div class="PreviewButtons">' . Anchor(T('Apply'), 'settings/themes/' . $PreviewThemeName . '/' . $Session->TransientKey(), 'PreviewButton') . ' ' . Anchor(T('Cancel'), 'settings/cancelpreview/', 'PreviewButton') . '</div>', 'DoNotDismiss'); } } if ($Session->IsValid() && ($EmailKey = Gdn::Session()->GetAttribute('EmailKey'))) { $NotifyEmailConfirm = TRUE; // If this user was manually moved out of the confirmation role, get rid of their 'awaiting confirmation' flag $ConfirmEmailRole = C('Garden.Registration.ConfirmEmailRole', FALSE); $UserRoles = array(); $RoleData = Gdn::UserModel()->GetRoles($Session->UserID); if ($RoleData !== FALSE && $RoleData->NumRows() > 0) { $UserRoles = ConsolidateArrayValuesByKey($RoleData->Result(DATASET_TYPE_ARRAY), 'RoleID', 'Name'); } if ($ConfirmEmailRole !== FALSE && !array_key_exists($ConfirmEmailRole, $UserRoles)) { Gdn::UserModel()->SaveAttribute($Session->UserID, "EmailKey", NULL); $NotifyEmailConfirm = FALSE; } if ($NotifyEmailConfirm) { $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]'); // 2011-09-09 - mosullivan - No longer allowing messages in dashboard // if ($Sender->MasterView == 'admin') // $Exceptions[] = '[Admin]'; // else if (in_array($Sender->MasterView, array('', 'default'))) if (in_array($Sender->MasterView, array('', 'default'))) { $Exceptions[] = '[NonAdmin]'; } if ($Sender->MasterView != 'admin' && (GetValue('MessagesLoaded', $Sender) != '1' && $Sender->MasterView != 'empty' && ArrayInArray($Exceptions, $MessageCache, FALSE) || InArrayI($Location, $MessageCache))) { $MessageModel = new MessageModel(); $MessageData = $MessageModel->GetMessagesForLocation($Location, $Exceptions); foreach ($MessageData as $Message) { $MessageModule = new MessageModule($Sender, $Message); $Sender->AddModule($MessageModule); } $Sender->MessagesLoaded = '1'; // Fixes a bug where render gets called more than once and messages are loaded/displayed redundantly. } // If there are applicants, alert admins by showing in the main menu if (in_array($Sender->MasterView, array('', 'default')) && $Sender->Menu && C('Garden.Registration.Method') == 'Approval') { $CountApplicants = Gdn::UserModel()->GetApplicantCount(); if ($CountApplicants > 0) { $Sender->Menu->AddLink('Applicants', T('Applicants') . ' <span class="Alert">' . $CountApplicants . '</span>', '/dashboard/user/applicants', array('Garden.Applicants.Manage')); } } if ($Sender->DeliveryType() == DELIVERY_TYPE_ALL) { $Gdn_Statistics = Gdn::Factory('Statistics'); $Gdn_Statistics->Check($Sender); } // Allow forum embedding if (C('Garden.Embed.Allow')) { $Sender->AddJsFile('js/embed_local.js'); } }
/** * * @param Gdn_Controller $Sender */ public function Base_Render_Before($Sender) { $Session = Gdn::Session(); // Enable theme previewing if ($Session->IsValid()) { $PreviewThemeName = $Session->GetPreference('PreviewThemeName', ''); $PreviewThemeFolder = $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()) { $ConfirmEmail = C('Garden.Registration.ConfirmEmail', false); $Confirmed = GetValue('Confirmed', Gdn::Session()->User, true); if ($ConfirmEmail && !$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]'); // 2011-09-09 - mosullivan - No longer allowing messages in dashboard // if ($Sender->MasterView == 'admin') // $Exceptions[] = '[Admin]'; // else if (in_array($Sender->MasterView, array('', 'default'))) 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') && (GetValue('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); } // Force embedding? if (!IsSearchEngine() && !IsMobile() && strtolower($Sender->ControllerName) != 'entry') { $Sender->AddDefinition('ForceEmbedForum', C('Garden.Embed.ForceForum') ? '1' : '0'); $Sender->AddDefinition('ForceEmbedDashboard', C('Garden.Embed.ForceDashboard') ? '1' : '0'); } $Sender->AddDefinition('Path', Gdn::Request()->Path()); // $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 = Gdn_CookieIdentity::GetCookiePayload('VanillaNoMobile'); if ($ForceNoMobile !== FALSE && is_array($ForceNoMobile) && in_array('force', $ForceNoMobile)) { $Sender->AddAsset('Foot', Wrap(Anchor(T('Back to Mobile Site'), '/profile/nomobile/1'), 'div'), 'MobileLink'); } }
/** * * @param Gdn_Controller $Sender */ public function Base_Render_Before($Sender) { $Session = Gdn::Session(); // Enable theme previewing if ($Session->IsValid()) { $PreviewThemeName = $Session->GetPreference('PreviewThemeName', ''); $PreviewThemeFolder = $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() && ($EmailKey = Gdn::Session()->GetAttribute('EmailKey'))) { $NotifyEmailConfirm = TRUE; // If this user was manually moved out of the confirmation role, get rid of their 'awaiting confirmation' flag $ConfirmEmailRole = C('Garden.Registration.ConfirmEmailRole', FALSE); $UserRoles = array(); $RoleData = Gdn::UserModel()->GetRoles($Session->UserID); if ($RoleData !== FALSE && $RoleData->NumRows() > 0) { $UserRoles = ConsolidateArrayValuesByKey($RoleData->Result(DATASET_TYPE_ARRAY), 'RoleID', 'Name'); } if ($ConfirmEmailRole !== FALSE && !array_key_exists($ConfirmEmailRole, $UserRoles)) { Gdn::UserModel()->SaveAttribute($Session->UserID, "EmailKey", NULL); $NotifyEmailConfirm = FALSE; } if ($NotifyEmailConfirm) { $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]'); // 2011-09-09 - mosullivan - No longer allowing messages in dashboard // if ($Sender->MasterView == 'admin') // $Exceptions[] = '[Admin]'; // else if (in_array($Sender->MasterView, array('', 'default'))) 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' && (GetValue('MessagesLoaded', $Sender) != '1' && $Sender->MasterView != 'empty' && ArrayInArray($Exceptions, $MessageCache, FALSE) || InArrayI($Location, $MessageCache))) { $MessageModel = new MessageModel(); $MessageData = $MessageModel->GetMessagesForLocation($Location, $Exceptions); 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 there are applicants, alert admins by showing in the main menu if (in_array($Sender->MasterView, array('', 'default')) && $Sender->Menu && C('Garden.Registration.Method') == 'Approval') { // $CountApplicants = Gdn::UserModel()->GetApplicantCount(); // if ($CountApplicants > 0) // $Sender->Menu->AddLink('Applicants', T('Applicants').' <span class="Alert">'.$CountApplicants.'</span>', '/dashboard/user/applicants', array('Garden.Applicants.Manage')); $Sender->Menu->AddLink('Applicants', T('Applicants'), '/dashboard/user/applicants', array('Garden.Applicants.Manage')); } if ($Sender->DeliveryType() == DELIVERY_TYPE_ALL) { $Gdn_Statistics = Gdn::Factory('Statistics'); $Gdn_Statistics->Check($Sender); } // Allow forum embedding if (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); } // Force embedding? if (!IsSearchEngine() && !IsMobile()) { $Sender->AddDefinition('ForceEmbedForum', C('Garden.Embed.ForceForum') ? '1' : '0'); $Sender->AddDefinition('ForceEmbedDashboard', C('Garden.Embed.ForceDashboard') ? '1' : '0'); } $Sender->AddDefinition('Path', Gdn::Request()->Path()); // $Sender->AddDefinition('MasterView', $Sender->MasterView); $Sender->AddDefinition('InDashboard', $Sender->MasterView == 'admin' ? '1' : '0'); $Sender->AddJsFile('js/embed_local.js'); } // Allow return to mobile site $ForceNoMobile = Gdn_CookieIdentity::GetCookiePayload('VanillaNoMobile'); if ($ForceNoMobile !== FALSE && is_array($ForceNoMobile) && in_array('force', $ForceNoMobile)) { $Sender->AddAsset('Foot', Wrap(Anchor(T('Back to Mobile Site'), '/profile/nomobile/1'), 'div'), 'MobileLink'); } }