<?php
RegisterPlugin("CiyunPublisher", "ActivePlugin_CiyunPublisher");

function ActivePlugin_CiyunPublisher() {
    Add_Filter_Plugin('Filter_Plugin_Admin_LeftMenu', 'CiyunPublisher_AddMenu');
}

function CiyunPublisher_AddMenu(&$m) {
    global $zbp;
    $m[] = MakeLeftMenu("root", "CiyunPublisher", $zbp->host . "zb_users/plugin/CiyunPublisher/main.php", "nav_CiyunPublisher", "aCiyunPublisher", "");
}

function InstallPlugin_CiyunPublisher() {
    global $zbp;
    if (!$zbp->HasConfig('CiyunPublisher') || !$zbp->Config('CiyunPublisher')->HasKey('token')) {
        $zbp->Config('CiyunPublisher')->token = bin2hex(random_bytes(24));
        $zbp->Config('CiyunPublisher')->whitelist_ips = '';
        $zbp->Config('CiyunPublisher')->force_draft = '1';
        $zbp->SaveConfig('CiyunPublisher');
    }
}

function UninstallPlugin_CiyunPublisher() {}

function UpdatePlugin_CiyunPublisher() {
    InstallPlugin_CiyunPublisher();
}

function CiyunPublisher_Updated() {
    UpdatePlugin_CiyunPublisher();
}
