Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Badges

Try Vanilla Forums Cloud product

Ready to contribute?

Amazing! Sign our contributors' agreement and then join us on GitHub.

Update for critical security issue in PHPMailer included in release Vanilla 2.3.1

terabytefrelance New

About

Username
terabytefrelance
Joined
Visits
5
Last Active
Roles
Member
Points
21
Badges
3
  • Re: Pockets Panel Position Index

    // Define the plugin: default.php

    $PluginInfo['Widgets'] = array(
        'Name' => 'Widgets',
        'Description' => "This plugin adds modules/widgets you create to the panel . ",
        'RegisterPermissions' => array('Plugins.Widgets.Twitter.View'),
        'Version' => '1.1',
        'Author' => "VrijVlinder",
        'AuthorEmail' => 'contact@vrijvlinder.com',
        'AuthorUrl' => "http://www.vrijvlinder.com"
    );
    
    class Widgets_Plugin extends Gdn_Plugin{
    
        public function __construct(){
        }
    
        public function base_render_before ($sender) {
    
            if (!isset($sender->Assets['Panel'])) {
                return;
            }
    
            $session = Gdn::session();
    
            $modules = [
                // 'PermissionIdentifier' => 'ModuleName',
                'Twitter' => 'TwitterModule'
            ];
    
            foreach ($modules as $permission => $module) {
                if (isset($sender->Assets['Panel'][$module])) {
                    if (!$session->checkPermission("Plugins.Widgets.{$permission}.View")) {
                        unset($sender->Assets['Panel'][$module]);
                    }
                }
            }
        }
    
        public function DiscussionsController_Render_Before($Sender){
    
            // comment this if you want it in the categories index page
    
            if (IsMobile()) {
                return;
                }
                else {
                    $TwitterModule = new TwitterModule($sender);
                    $Sender->AddModule($TwitterModule);
    
                    // Uncomment the modules you want to use or add more or comment out the ones you dont want to use.
    
                    // $Sender->AddCssFile('widgets.css', 'plugins/Widgets');
            }
        }
    
        public function CategoriesController_Render_Before($Sender){
    
            // comment this if you want it in the categories index page
    
            if (IsMobile()) {
                return;
                }
                else {
                    $TwitterModule = new TwitterModule($sender);
                    $Sender->AddModule($TwitterModule);
    
                    // Uncomment the modules you want to use or add more or comment out the ones you dont want to use.
    
                    // $Sender->AddCssFile('widgets.css', 'plugins/Widgets');
            }
        }
    
        public function Setup(){
            // Register permissions
    
            // Set initial admininstrator permissions.
            $PermissionModel->Save(array(
                'Role' => 'Administrator',
                'Plugins.Widgets.Twitter.View' => 1
            ));
    
        }
    
        public function OnDisable(){
            // Deregister permissions (only in 2.1+)
            if(version_compare(APPLICATION_VERSION, '2.1b1', '>=')) {
                $PermissionModel = Gdn::PermissionModel();
                $PermissionModel->Undefine(
                    array(
                        'Plugins.Widgets.Twitter.View'
                    ));
            }
        }
    }
    

    @vrijvlinder Checking several plugins and with the recommendation of @r_j I have arrived until this code works perfect, in the modules only the widgets would be placed, while the plugin gives access to all of them

    vrijvlinder