public function settingsController_moduleSort_create($sender, $reset = false)
 {
     $sender->permission('Garden.Settings.Manage');
     $sender->addSideMenu('settings/modulesort');
     $sender->addJsFile('html.sortable.min.js', 'plugins/modulesort');
     $sender->addJsFile('modulesort.js', 'plugins/modulesort');
     if (Gdn::request()->isAuthenticatedPostBack()) {
         if ($reset) {
             removeFromConfig('Modules');
             $sender->jsonTarget('', '', 'Refresh');
         } elseif ($sort = json_decode(Gdn::request()->post('Modules'), true)) {
             saveToConfig('Modules', $sort);
         }
     }
     $sender->title(t('Module Sort Order'));
     $sender->render('modulesort', '', 'plugins/modulesort');
 }
Пример #2
0
$Construct->table('Ban')->primaryKey('BanID')->column('BanType', array('IPAddress', 'Name', 'Email'), false, 'unique')->column('BanValue', 'varchar(50)', false, 'unique')->column('Notes', 'varchar(255)', null)->column('CountUsers', 'uint', 0)->column('CountBlockedRegistrations', 'uint', 0)->column('InsertUserID', 'int')->column('DateInserted', 'datetime')->column('InsertIPAddress', 'varchar(15)', true)->column('UpdateUserID', 'int', true)->column('DateUpdated', 'datetime', true)->column('UpdateIPAddress', 'varchar(15)', true)->engine('InnoDB')->set($Explicit, $Drop);
$Construct->table('Spammer')->column('UserID', 'int', false, 'primary')->column('CountSpam', 'usmallint', 0)->column('CountDeletedSpam', 'usmallint', 0)->set($Explicit, $Drop);
$Construct->table('Media')->primaryKey('MediaID')->column('Name', 'varchar(255)')->column('Path', 'varchar(255)')->column('Type', 'varchar(128)')->column('Size', 'int(11)')->column('InsertUserID', 'int(11)')->column('DateInserted', 'datetime')->column('ForeignID', 'int(11)', true, 'index.Foreign')->column('ForeignTable', 'varchar(24)', true, 'index.Foreign')->column('ImageWidth', 'usmallint', null)->column('ImageHeight', 'usmallint', null)->column('ThumbWidth', 'usmallint', null)->column('ThumbHeight', 'usmallint', null)->column('ThumbPath', 'varchar(255)', null)->set(false, false);
// Merge backup.
$Construct->table('UserMerge')->primaryKey('MergeID')->column('OldUserID', 'int', false, 'key')->column('NewUserID', 'int', false, 'key')->column('DateInserted', 'datetime')->column('InsertUserID', 'int')->column('DateUpdated', 'datetime', true)->column('UpdateUserID', 'int', true)->column('Attributes', 'text', true)->set();
$Construct->table('UserMergeItem')->column('MergeID', 'int', false, 'key')->column('Table', 'varchar(30)')->column('Column', 'varchar(30)')->column('RecordID', 'int')->column('OldUserID', 'int')->column('NewUserID', 'int')->set();
$Construct->table('Attachment')->primaryKey('AttachmentID')->column('Type', 'varchar(64)')->column('ForeignID', 'varchar(50)', false, 'index')->column('ForeignUserID', 'int', false, 'key')->column('Source', 'varchar(64)')->column('SourceID', 'varchar(32)')->column('SourceURL', 'varchar(255)')->column('Attributes', 'text', true)->column('DateInserted', 'datetime')->column('InsertUserID', 'int', false, 'key')->column('InsertIPAddress', 'varchar(64)')->column('DateUpdated', 'datetime', true)->column('UpdateUserID', 'int', true)->column('UpdateIPAddress', 'varchar(15)', true)->set($Explicit, $Drop);
// Save the current input formatter to the user's config.
// This will allow us to change the default later and grandfather existing forums in.
saveToConfig('Garden.InputFormatter', c('Garden.InputFormatter'));
// Make sure the default locale is in its canonical form.
$currentLocale = c('Garden.Locale');
$canonicalLocale = Gdn_Locale::canonicalize($currentLocale);
if ($currentLocale !== $canonicalLocale) {
    saveToConfig('Garden.Locale', $canonicalLocale);
}
// We need to undo cleditor's bad behavior for our reformed users.
// If you still need to manipulate this, do it in memory instead (SAVE = false).
if (!c('Garden.Html.SafeStyles')) {
    removeFromConfig('Garden.Html.SafeStyles');
}
// Make sure the smarty folders exist.
if (!file_exists(PATH_CACHE . '/Smarty')) {
    @mkdir(PATH_CACHE . '/Smarty');
}
if (!file_exists(PATH_CACHE . '/Smarty/cache')) {
    @mkdir(PATH_CACHE . '/Smarty/cache');
}
if (!file_exists(PATH_CACHE . '/Smarty/compile')) {
    @mkdir(PATH_CACHE . '/Smarty/compile');
}
 /**
  * Remove the default avatar from config & delete it.
  *
  * @since 2.0.0
  * @access public
  * @param string $transientKey Security token.
  */
 public function removeDefaultAvatar($transientKey = '')
 {
     $session = Gdn::session();
     if ($session->validateTransientKey($transientKey) && $session->checkPermission('Garden.Community.Manage')) {
         $avatar = c('Garden.DefaultAvatar', '');
         $this->deleteDefaultAvatars($avatar);
         removeFromConfig('Garden.DefaultAvatar');
     }
     redirect('dashboard/settings/defaultavatar');
 }
 /**
  *
  */
 public function deleteState()
 {
     removeFromConfig('Garden.Import');
 }
 /**
  * Remove the share image from config & delete it.
  *
  * @since 2.1
  * @param string $TransientKey Security token.
  */
 public function removeShareImage($TransientKey = '')
 {
     $this->permission('Garden.Community.Manage');
     if (Gdn::request()->isAuthenticatedPostBack()) {
         $ShareImage = c('Garden.ShareImage', '');
         removeFromConfig('Garden.ShareImage');
         $Upload = new Gdn_Upload();
         $Upload->delete($ShareImage);
     }
     $this->RedirectUrl = '/settings/banner';
     $this->render('Blank', 'Utility');
 }
Пример #6
0
 /**
  * Unset the default authenticator.
  *
  * @param string $AuthenticationSchemeAlias
  * @return bool
  */
 public function unsetDefaultAuthenticator($AuthenticationSchemeAlias)
 {
     $AuthenticationSchemeAlias = strtolower($AuthenticationSchemeAlias);
     if (C('Garden.Authenticator.DefaultScheme') == $AuthenticationSchemeAlias) {
         removeFromConfig('Garden.Authenticator.DefaultScheme');
         return true;
     }
     return false;
 }
Пример #7
0
 /**
  * Database changes needed for this plugin.
  */
 public function structure()
 {
     $Structure = Gdn::structure();
     $Structure->table('Flag')->column('DiscussionID', 'int(11)', true)->column('InsertUserID', 'int(11)', false, 'key')->column('InsertName', 'varchar(64)')->column('AuthorID', 'int(11)')->column('AuthorName', 'varchar(64)')->column('ForeignURL', 'varchar(255)', false, 'key')->column('ForeignID', 'int(11)')->column('ForeignType', 'varchar(32)')->column('Comment', 'text')->column('DateInserted', 'datetime')->set(false, false);
     // Turn off disabled Flagging plugin (deprecated)
     if (c('Plugins.Flagging.Enabled', null) === false) {
         removeFromConfig('EnabledPlugins.Flagging');
     }
 }
 /**
  * Delete a field.
  */
 public function settingsController_profileFieldDelete_create($Sender, $Args)
 {
     $Sender->permission('Garden.Settings.Manage');
     $Sender->setData('Title', 'Delete Field');
     if (isset($Args[0])) {
         if ($Sender->Form->authenticatedPostBack()) {
             removeFromConfig('ProfileExtender.Fields.' . $Args[0]);
             $Sender->RedirectUrl = url('/settings/profileextender');
         } else {
             $Sender->setData('Field', $this->getProfileField($Args[0]));
         }
     }
     $Sender->render('delete', '', 'plugins/ProfileExtender');
 }
Пример #9
0
 /**
  *
  *
  * @param $ThemeName
  * @param bool $IsMobile
  * @return bool
  * @throws Exception
  */
 public function enableTheme($ThemeName, $IsMobile = false)
 {
     // Make sure to run the setup
     $this->testTheme($ThemeName);
     // Set the theme.
     $ThemeInfo = $this->getThemeInfo($ThemeName);
     $ThemeFolder = val('Folder', $ThemeInfo, '');
     $oldTheme = $IsMobile ? c('Garden.MobileTheme', 'mobile') : c('Garden.Theme', 'default');
     if ($ThemeFolder == '') {
         throw new Exception(t('The theme folder was not properly defined.'));
     } else {
         $Options = valr("{$ThemeName}.Options", $this->AvailableThemes());
         if ($Options) {
             if ($IsMobile) {
                 saveToConfig(array('Garden.MobileTheme' => $ThemeName, 'Garden.MobileThemeOptions.Name' => valr("{$ThemeName}.Name", $this->availableThemes(), $ThemeFolder)));
             } else {
                 saveToConfig(array('Garden.Theme' => $ThemeName, 'Garden.ThemeOptions.Name' => valr("{$ThemeName}.Name", $this->availableThemes(), $ThemeFolder)));
             }
         } else {
             if ($IsMobile) {
                 saveToConfig('Garden.MobileTheme', $ThemeName);
                 removeFromConfig('Garden.MobileThemeOptions');
             } else {
                 saveToConfig('Garden.Theme', $ThemeName);
                 removeFromConfig('Garden.ThemeOptions');
             }
         }
     }
     if ($oldTheme !== $ThemeName) {
         $this->themeHook($ThemeName, self::ACTION_ENABLE, true);
         Logger::event('theme_changed', Logger::NOTICE, 'The {themeType} theme changed from {oldTheme} to {newTheme}.', array('themeType' => $IsMobile ? 'mobile' : 'desktop', 'oldTheme' => $oldTheme, 'newTheme' => $ThemeName));
     }
     // Tell the locale cache to refresh itself.
     Gdn::locale()->refresh();
     return true;
 }
Пример #10
0
 /**
  * Remove the default avatar from config & delete it.
  *
  * @since 2.0.0
  * @access public
  */
 public function removeDefaultAvatar()
 {
     if (Gdn::request()->isAuthenticatedPostBack(true) && Gdn::session()->checkPermission('Garden.Community.Manage')) {
         $avatar = c('Garden.DefaultAvatar', '');
         $this->deleteDefaultAvatars($avatar);
         removeFromConfig('Garden.DefaultAvatar');
         $this->informMessage(sprintf(t('%s deleted.'), t('Avatar')));
     }
     $this->render('blank', 'utility', 'dashboard');
 }
 /**
  * Disable an application.
  *
  * @param string $applicationName The name of the application to disable.
  * @throws \Exception Throws an exception if the application can't be disabled.
  */
 public function disableApplication($applicationName)
 {
     // 1. Check to make sure that this application is allowed to be disabled
     $ApplicationInfo = (array) arrayValueI($applicationName, $this->availableApplications(), array());
     $applicationName = $ApplicationInfo['Index'];
     if (!val('AllowDisable', $ApplicationInfo, true)) {
         throw new Exception(sprintf(t('You cannot disable the %s application.'), $applicationName));
     }
     // 2. Check to make sure that no other enabled applications rely on this one
     foreach ($this->enabledApplications() as $CheckingName => $CheckingInfo) {
         $RequiredApplications = val('RequiredApplications', $CheckingInfo, false);
         if (is_array($RequiredApplications) && array_key_exists($applicationName, $RequiredApplications) === true) {
             throw new Exception(sprintf(t('You cannot disable the %1$s application because the %2$s application requires it in order to function.'), $applicationName, $CheckingName));
         }
     }
     // 3. Check to make sure that no other enabled plugins rely on this one
     $DependendPlugins = array();
     foreach (Gdn::pluginManager()->enabledPlugins() as $CheckingName => $CheckingInfo) {
         $RequiredApplications = val('RequiredApplications', $CheckingInfo, false);
         if (is_array($RequiredApplications) && array_key_exists($applicationName, $RequiredApplications) === true) {
             $DependendPlugins[] = $CheckingName;
         }
     }
     if (!empty($DependendPlugins)) {
         throw new Exception(sprintf(t('You cannot disable the %1$s application because the following plugins require it in order to function: %2$s'), $applicationName, implode(', ', $DependendPlugins)));
     }
     // 2. Disable it
     removeFromConfig("EnabledApplications.{$applicationName}");
     Logger::event('addon_disabled', Logger::NOTICE, 'The {addonName} application was disabled.', array('addonName' => $applicationName));
     // Clear the object caches.
     Gdn_Autoloader::smartFree(Gdn_Autoloader::CONTEXT_APPLICATION, $ApplicationInfo);
     // Redefine the locale manager's settings $Locale->Set($CurrentLocale, $EnabledApps, $EnabledPlugins, true);
     $Locale = Gdn::locale();
     $Locale->set($Locale->current(), $this->enabledApplicationFolders(), Gdn::pluginManager()->enabledPluginFolders(), true);
     $this->EventArguments['AddonName'] = $applicationName;
     Gdn::pluginManager()->callEventHandlers($this, 'ApplicationManager', 'AddonDisabled');
 }
Пример #12
0
 /**
  * Plugin cleanup
  *
  * This method is fired only once, immediately before the plugin is disabled, and is a great place to
  * perform cleanup tasks such as deletion of unsued files and folders.
  */
 public function onDisable()
 {
     removeFromConfig('Plugin.Example.TrimSize');
     removeFromConfig('Plugin.Example.RenderCondition');
     // Never delete from the database OnDisable.
     // Usually, you want re-enabling a plugin to be as if it was never off.
 }
Пример #13
0
        // Query the next batch of users with IP data needing to be migrated.
        $legacyIPAddresses = $SQL->select(['UserID', 'AllIPAddresses', 'InsertIPAddress', 'LastIPAddress', 'DateLastActive'])->from('User')->where('AllIPAddresses is not null')->limit($limit)->get()->resultArray();
    } while (count($legacyIPAddresses) > 0);
    unset($allIPAddresses, $dateLastActive, $insertIPAddress, $lastIPAddress, $userID, $processedUsers);
}
// Save the current input formatter to the user's config.
// This will allow us to change the default later and grandfather existing forums in.
saveToConfig('Garden.InputFormatter', c('Garden.InputFormatter'));
touchConfig('Garden.Email.Format', 'text');
// Make sure the default locale is in its canonical form.
$currentLocale = c('Garden.Locale');
$canonicalLocale = Gdn_Locale::canonicalize($currentLocale);
if ($currentLocale !== $canonicalLocale) {
    saveToConfig('Garden.Locale', $canonicalLocale);
}
// We need to ensure that recaptcha is enabled if this site is upgrading from
// 2.2 and has never had a captcha plugin
touchConfig('EnabledPlugins.recaptcha', true);
// Move recaptcha private key to plugin namespace.
if (c('Garden.Registration.CaptchaPrivateKey')) {
    touchConfig('Recaptcha.PrivateKey', c('Garden.Registration.CaptchaPrivateKey'));
    removeFromConfig('Garden.Registration.CaptchaPrivateKey');
}
// Move recaptcha public key to plugin namespace.
if (c('Garden.Registration.CaptchaPublicKey')) {
    touchConfig('Recaptcha.PublicKey', c('Garden.Registration.CaptchaPublicKey'));
    removeFromConfig('Garden.Registration.CaptchaPublicKey');
}
// Make sure the smarty folders exist.
touchFolder(PATH_CACHE . '/Smarty/cache');
touchFolder(PATH_CACHE . '/Smarty/compile');
Пример #14
0
 /**
  * Disable an application.
  *
  * @param string $applicationName The name of the application to disable.
  * @throws \Exception Throws an exception if the application can't be disabled.
  */
 public function disableApplication($applicationName)
 {
     $addon = $this->addonManager->lookupAddon($applicationName);
     if (!$addon) {
         throw notFoundException('Application');
     }
     $applicationName = $addon->getRawKey();
     // 1. Check to make sure that this application is allowed to be disabled
     if (!$addon->getInfoValue('allowDisable', true)) {
         throw new Exception(sprintf(t('You cannot disable the %s application.'), $applicationName));
     }
     // 2. Check to make sure that no other enabled applications rely on this one.
     try {
         $this->addonManager->checkDependants($addon, true);
     } catch (Exception $ex) {
         throw new Gdn_UserException($ex->getMessage(), $ex->getCode());
     }
     // 2. Disable it
     removeFromConfig("EnabledApplications.{$applicationName}");
     Logger::event('addon_disabled', Logger::NOTICE, 'The {addonName} application was disabled.', array('addonName' => $applicationName));
     // Clear the object caches.
     $this->addonManager->stopAddonsByKey([$applicationName], \Vanilla\Addon::TYPE_ADDON);
 }
 public function onDisable()
 {
     removeFromConfig('Plugins.DiscussionEvent.DisplayInSidepanel');
     removeFromConfig('Plugins.DiscussionEvent.MaxDiscussionEvents');
 }
Пример #16
0
 /**
  * Settings screen for role and restriction choice.
  *
  * @param object $sender SettingsController.
  * @return void.
  * @package ReadOnly
  * @since 0.1
  */
 public function settingsController_readOnly_create($sender)
 {
     // Define general settings properties.
     $sender->permission('Garden.Settings.Manage');
     $sender->addSideMenu('/dashboard/settings/plugins');
     $sender->setData('Title', t('ReadOnly Settings'));
     $sender->setData('Description', t('ReadOnly Settings Description', 'Choose which roles and actions should be restricted.<br/>You
         should inform your users about the read only state by ' . anchor('adding a message', '/dashboard/message/add') . ' to the forum.'));
     // Consolidate/prepare permissions.
     $permissionModel = Gdn::PermissionModel();
     $perms = $permissionModel->PermissionColumns();
     unset($perms['PermissionID']);
     $permissions = array();
     foreach ($perms as $key => $value) {
         $action = substr($key, strrpos($key, '.') + 1);
         $permissions[$action] .= $key . ', ';
     }
     $permissionItems = array();
     foreach ($permissions as $key => $value) {
         $text = $key . '<span>' . trim($value, ', ') . '</span>';
         $permissionItems[$text] = $key;
     }
     // Consolidate/prepare roles.
     $roleModel = new RoleModel();
     $roles = $roleModel->roles();
     $roleItems = array();
     foreach ($roles as $role) {
         $roleItems[$role['Name']] = $role['RoleID'];
     }
     // Build form info.
     $configurationModule = new configurationModule($sender);
     $configurationModule->initialize(array('ReadOnly.Restrictions' => array('Control' => 'CheckBoxList', 'Description' => t('ReadOnly Settings Restrictions', 'Choose the actions that should be restricted. Below each action is a list of all the current permissions with that action."Add" and "Edit" is recommended.'), 'Items' => $permissionItems, 'LabelCode' => 'Restrictions'), 'ReadOnly.Roles' => array('Control' => 'CheckBoxList', 'Description' => t('Choose the roles that should <strong>not</strong> be restricted (Admin users will always have all permissions).'), 'Items' => $roleItems, 'LabelCode' => 'Roles'), 'ReadOnly.Message' => array('Control' => 'TextBox', 'LabelCode' => 'Message Text', 'Description' => 'It is a good idea to ' . anchor('inform your users', '/dashboard/message') . ' about the restrictions so that they now what\'s going on...', 'Options' => array('MultiLine' => true)), 'ReadOnly.ShowAlert' => array('Control' => 'Checkbox', 'Description' => 'You can choose show or deactivate the message, however.', 'LabelCode' => 'Show Message')));
     // Handle alert message.
     if ($sender->Request->isPostBack()) {
         $post = $sender->Request->getRequestArguments('post');
         $messageModel = new MessageModel();
         $messageID = c('ReadOnly.MessageID');
         $message = $messageModel->getID($messageID);
         if (!$post['ReadOnly-dot-Message']) {
             // Delete message when no text is given.
             if ($message) {
                 $messageModel->delete(array('MessageID' => $messageID));
                 removeFromConfig('ReadOnly.MessageID');
             }
         } else {
             // Check if message already exists.
             if ($message) {
                 // Set MessageID so that existing message gets updated
                 $formPostValues['MessageID'] = $messageID;
             }
             $formPostValues['Location'] = '[Base]';
             $formPostValues['AssetTarget'] = 'Content';
             $formPostValues['Content'] = $post['ReadOnly-dot-Message'];
             $formPostValues['CssClass'] = 'AlertMessage';
             $formPostValues['Enabled'] = $post['ReadOnly-dot-ShowAlert'];
             $formPostValues['AllowDismiss'] = false;
             $formPostValues['TransientKey'] = Gdn::session()->transientKey();
             saveToConfig('ReadOnly.MessageID', $messageModel->save($formPostValues));
         }
     }
     // Show form.
     $configurationModule->renderAll();
 }