[Andrew] Moderator Panel

[Andrew] Moderator Panel 1.9.4

No permission to download
Alright, if you uninstall the add-on and the reinstall then notes should work. I clearly am doing something wrong with creating the table on upgrades but it should work fine on new installs. If you uninstall and reinstall then you will need to redo permissions and options.

When you add something in the DB as a upgrade, you need to do something like this:
PHP:
    public function upgrade1010070Step1()
    {
        $sm = $this->schemaManager();

        $sm->alterTable('xf_ozzmodz_spaminator_log', function (Alter $table)
        {
              $table->addColumn('url', 'VARCHAR', 2500)->setDefault('')->after('email1');
        });
    }

public function upgrade1010070Step1 is the version you are updating to. so in your case, you would have had to do something like so:

PHP:
public function upgrade1020070Step1()
    {
        $sm = $this->schemaManager();

        $sm->alterTable('xf_andrew_mp_user_note', function (Alter $table)
        {
              $table->addColumn('note_id', 'int')->autoIncrement();
              $table->addColumn('note_user_id', 'int')->nullable(true)->setDefault(null);
        });
    }

If you add the above to the addon, you'll have to change the upgrade # to the next version.
 
I was just writing a quick guide and got ninja'd by Ozzy.. 🥷

--EDIT--
The notes are only just being added, so you'd basically copy the install step to the upgrade.. (y)
 
So in your case, if you update the addon to 1.3.0 the setup file would be this:
PHP:
<?php

namespace Andrew\ModeratorPanel;

use XF\AddOn\AbstractSetup;
use XF\AddOn\StepRunnerInstallTrait;
use XF\AddOn\StepRunnerUninstallTrait;
use XF\AddOn\StepRunnerUpgradeTrait;

use XF\Db\Schema\Create;

class Setup extends AbstractSetup
{
    use StepRunnerInstallTrait;
    use StepRunnerUpgradeTrait;
    use StepRunnerUninstallTrait;

    public function installStep1()
    {
        $this->schemaManager()->createTable('xf_andrew_mp_user_note', function(Create $table)
        {
            $table->addColumn('note_id', 'int')->autoIncrement();
            $table->addColumn('note_user_id', 'int')->nullable(true)->setDefault(null);
            $table->addColumn('user_id', 'int')->nullable(true)->setDefault(null);
            $table->addColumn('username','varchar', 250)->nullable(true)->setDefault(null);
            $table->addColumn('create_date', 'int',10)->nullable(true)->setDefault(\XF::$time);
            $table->addColumn('message', 'mediumtext')->nullable(true)->setDefault(null);

            $table->addPrimaryKey('note_id');
        });
    }

    public function upgrade1030070Step1()
    {
        $sm = $this->schemaManager();

        $sm->alterTable('xf_andrew_mp_user_note', function (Alter $table)
        {
            $table->addColumn('note_id', 'int')->autoIncrement();
            $table->addColumn('note_user_id', 'int')->nullable(true)->setDefault(null);

            $table->addPrimaryKey('note_id');
        });
    }

    public function uninstallStep1()
    {
        $this->schemaManager()->dropTable('xf_andrew_mp_user_note');
    }
}

Assuming that is the only two new columns.
 
So in your case, if you update the addon to 1.3.0 the setup file would be this:
PHP:
<?php

namespace Andrew\ModeratorPanel;

use XF\AddOn\AbstractSetup;
use XF\AddOn\StepRunnerInstallTrait;
use XF\AddOn\StepRunnerUninstallTrait;
use XF\AddOn\StepRunnerUpgradeTrait;

use XF\Db\Schema\Create;

class Setup extends AbstractSetup
{
    use StepRunnerInstallTrait;
    use StepRunnerUpgradeTrait;
    use StepRunnerUninstallTrait;

    public function installStep1()
    {
        $this->schemaManager()->createTable('xf_andrew_mp_user_note', function(Create $table)
        {
            $table->addColumn('note_id', 'int')->autoIncrement();
            $table->addColumn('note_user_id', 'int')->nullable(true)->setDefault(null);
            $table->addColumn('user_id', 'int')->nullable(true)->setDefault(null);
            $table->addColumn('username','varchar', 250)->nullable(true)->setDefault(null);
            $table->addColumn('create_date', 'int',10)->nullable(true)->setDefault(\XF::$time);
            $table->addColumn('message', 'mediumtext')->nullable(true)->setDefault(null);

            $table->addPrimaryKey('note_id');
        });
    }

    public function upgrade1030070Step1()
    {
        $sm = $this->schemaManager();

        $sm->alterTable('xf_andrew_mp_user_note', function (Alter $table)
        {
            $table->addColumn('note_id', 'int')->autoIncrement();
            $table->addColumn('note_user_id', 'int')->nullable(true)->setDefault(null);

            $table->addPrimaryKey('note_id');
        });
    }

    public function uninstallStep1()
    {
        $this->schemaManager()->dropTable('xf_andrew_mp_user_note');
    }
}

Assuming that is the only two new columns.
Thanks, you nailed it. I just uploaded a fixed version. I really appreciate the help.
 
Did you change the version for the update? I had the above code set for 1.3.0
Yes, I changed it to 1.2.2.

PHP:
    public function upgrade1020270Step1()
    {

            $sm = $this->schemaManager();
            $sm->CreateTable('xf_andrew_mp_user_note', function (Create $table)
            {

                $table->addColumn('note_id', 'int')->autoIncrement();
                $table->addColumn('note_user_id', 'int')->nullable(true)->setDefault(null);
                $table->addColumn('user_id', 'int')->nullable(true)->setDefault(null);
                $table->addColumn('username','varchar', 250)->nullable(true)->setDefault(null);
                $table->addColumn('create_date', 'int',10)->nullable(true)->setDefault(\XF::$time);
                $table->addColumn('message', 'mediumtext')->nullable(true)->setDefault(null);

                $table->addPrimaryKey('note_id');

            });
    }
 
Now that the upgrade issue is out of the way..

The biggest updates in the latest version are user notes, and moderated users. If any bugs are found then I will address them over the next few days. The next three items I want to work on are the ability for moderators to moderate users (add them to he defined user group), and ability to discourage users. I will be busier when I return to work next week so no ETA on these updates.
 
I am getting this error when trying to install:

Line 120: Unknown tag profilebanner encountered. - Template name: public:andrew_moderatorpanel_user_view
 
Try removing:
Code:
<xf:profilebanner user="$user" size="l" class="memberHeader-main" toggle="memberHeader--withBanner">

From:
andrew_moderatorpanel_user_view
 
I will say that you could run into other issues as well. Is there a particular reason that you have not upgraded to XF 2.2?
 
Top Bottom