<?php /*

 Composr
 Copyright (c) Christopher Graham, 2004-2024

 See docs/LICENSE.md for full licensing information.


 NOTE TO PROGRAMMERS:
   Do not edit this file. If you need to make changes, save your changed file to the appropriate *_custom folder
   **** If you ignore this advice, then your website upgrades (e.g. for bug fixes) will likely kill your changes ****

*/

/**
 * @license    http://opensource.org/licenses/cpal_1.0 Common Public Attribution License
 * @copyright  Christopher Graham
 * @package    points
 */

/**
 * Hook class.
 */
class Hook_addon_registry_points
{
    /**
     * Get a list of file permissions to set.
     *
     * @param  boolean $runtime Whether to include wildcards represented runtime-created chmoddable files
     * @return array File permissions to set
     */
    public function get_chmod_array(bool $runtime = false) : array
    {
        return [];
    }

    /**
     * Get the version of the software this addon is for (used in generating the TAR filename).
     *
     * @return float Version number
     */
    public function get_version() : float
    {
        return cms_version_number();
    }

    /**
     * Get the minimum required version of the website software needed to use this addon.
     *
     * @return float Minimum required website software version
     */
    public function get_min_cms_version() : float
    {
        return 11.0;
    }

    /**
     * Get the maximum compatible version of the website software to use this addon.
     *
     * @return ?float Maximum compatible website software version (null: no maximum version currently)
     */
    public function get_max_cms_version() : ?float
    {
        return 11.9;
    }

    /**
     * Get the addon category.
     *
     * @return string The category
     */
    public function get_category() : string
    {
        return 'Fun and Games';
    }

    /**
     * Get the description of the addon.
     *
     * @return string Description of the addon
     */
    public function get_description() : string
    {
        return 'Allow members to accumulate points via a number of configurable activities, as well as exchange points with each other. Points act as a ranking system as well as a virtual currency.';
    }

    /**
     * Get a list of tutorials that apply to this addon.
     *
     * @return array List of tutorials
     */
    public function get_applicable_tutorials() : array
    {
        return [
            'tut_points',
        ];
    }

    /**
     * Get a mapping of dependency types.
     *
     * @return array A structure specifying dependency information
     */
    public function get_dependencies() : array
    {
        return [
            'requires' => [],
            'recommends' => [],
            'conflicts_with' => [],
        ];
    }

    /**
     * Explicitly say which icon should be used.
     *
     * @return URLPATH Icon
     */
    public function get_default_icon() : string
    {
        return 'themes/default/images/icons/menu/social/points.svg';
    }

    /**
     * Get a list of files that belong to this addon.
     *
     * @return array List of files
     */
    public function get_file_list() : array
    {
        return [
            'adminzone/pages/modules/admin_points.php',
            'lang/EN/points.ini',
            'site/pages/modules/points.php',
            'sources/hooks/modules/admin_import_types/points.php',
            'sources/hooks/modules/admin_stats/points.php',
            'sources/hooks/systems/actionlog/points.php',
            'sources/hooks/systems/addon_registry/points.php',
            'sources/hooks/systems/cleanup/points_recalculate_cpf.php',
            'sources/hooks/systems/cns_cpf_filter/points.php',
            'sources/hooks/systems/cns_warnings/point_transactions.php',
            'sources/hooks/systems/cns_warnings/points.php',
            'sources/hooks/systems/commandr_commands/send_points.php',
            'sources/hooks/systems/commandr_fs_extended_member/point_credits.php',
            'sources/hooks/systems/commandr_fs_extended_member/point_debits.php',
            'sources/hooks/systems/config/enable_anonymous_transactions.php',
            'sources/hooks/systems/config/enable_gift_points.php',
            'sources/hooks/systems/config/point_logs_per_page.php',
            'sources/hooks/systems/config/points_birthday.php',
            'sources/hooks/systems/config/points_foss.php',
            'sources/hooks/systems/config/points_foss_http_header.php',
            'sources/hooks/systems/config/points_foss_reason.php',
            'sources/hooks/systems/config/points_foss_ua_exclude.php',
            'sources/hooks/systems/config/points_foss_ua_include.php',
            'sources/hooks/systems/config/points_if_liked.php',
            'sources/hooks/systems/config/points_joining.php',
            'sources/hooks/systems/config/points_per_currency_unit.php',
            'sources/hooks/systems/config/points_per_daily_visit.php',
            'sources/hooks/systems/config/points_per_day.php',
            'sources/hooks/systems/config/points_rating.php',
            'sources/hooks/systems/config/points_show_personal_stats_gift_points_balance.php',
            'sources/hooks/systems/config/points_show_personal_stats_gift_points_sent.php',
            'sources/hooks/systems/config/points_show_personal_stats_points_balance.php',
            'sources/hooks/systems/config/points_show_personal_stats_points_rank.php',
            'sources/hooks/systems/config/points_show_personal_stats_points_spent.php',
            'sources/hooks/systems/config/points_voting.php',
            'sources/hooks/systems/config/reward_credit_amount.php',
            'sources/hooks/systems/config/reward_credit_chance.php',
            'sources/hooks/systems/config_categories/points.php',
            'sources/hooks/systems/cron/birthday_points.php',
            'sources/hooks/systems/cron/points_daily.php',
            'sources/hooks/systems/cron/points_escrow.php',
            'sources/hooks/systems/cron/points_posts.php',
            'sources/hooks/systems/notifications/points.php',
            'sources/hooks/systems/notifications/points_transaction_staff.php',
            'sources/hooks/systems/page_groupings/points.php',
            'sources/hooks/systems/points/.htaccess',
            'sources/hooks/systems/points/comcode_page__add.php',
            'sources/hooks/systems/points/index.html',
            'sources/hooks/systems/points/points__credit_daily.php',
            'sources/hooks/systems/points/points_escrow__add.php',
            'sources/hooks/systems/points_transact/.htaccess',
            'sources/hooks/systems/points_transact/index.html',
            'sources/hooks/systems/privacy/points.php',
            'sources/hooks/systems/profiles_tabs/points.php',
            'sources/hooks/systems/realtime_rain/points.php',
            'sources/hooks/systems/rss/points.php',
            'sources/hooks/systems/tasks/export_points_ledger.php',
            'sources/hooks/systems/tasks/export_points_overview.php',
            'sources/hooks/systems/tasks/points_recalculate_cpf.php',
            'sources/points.php',
            'sources/points2.php',
            'sources/points3.php',
            'sources/points_escrow.php',
            'sources_custom/hooks/systems/points/.htaccess',
            'sources_custom/hooks/systems/points/index.html',
            'sources_custom/hooks/systems/points_transact/.htaccess',
            'sources_custom/hooks/systems/points_transact/index.html',
            'themes/default/css/points.css',
            'themes/default/images/icons/buttons/points.svg',
            'themes/default/images/icons/menu/adminzone/audit/points_log.svg',
            'themes/default/images/icons/menu/social/points.svg',
            'themes/default/images/icons_monochrome/buttons/points.svg',
            'themes/default/images/icons_monochrome/menu/adminzone/audit/points_log.svg',
            'themes/default/images/icons_monochrome/menu/social/points.svg',
            'themes/default/javascript/points.js',
            'themes/default/javascript/points_escrow.js',
            'themes/default/templates/ESCROW_TRANSACTIONS.tpl',
            'themes/default/templates/POINTS_ESCROW_SCREEN.tpl',
            'themes/default/templates/POINTS_PROFILE.tpl',
            'themes/default/templates/POINTS_SCREEN.tpl',
            'themes/default/templates/POINTS_SEARCH_RESULT.tpl',
            'themes/default/templates/POINTS_SEARCH_SCREEN.tpl',
            'themes/default/templates/POINTS_SEND.tpl',
            'themes/default/text/ESCROW_AMENDED_MAIL.txt',
            'themes/default/text/ESCROW_CANCELLED_MAIL.txt',
            'themes/default/text/ESCROW_DISPUTED_MAIL.txt',
            'themes/default/text/ESCROW_FULLY_SATISFIED_MAIL.txt',
            'themes/default/text/ESCROW_TRANSACTIONS_MAIL.txt',
        ];
    }

    /**
     * Get mapping between template names and the method of this class that can render a preview of them.
     *
     * @return array The mapping
     */
    public function tpl_previews() : array
    {
        return [
            'templates/POINTS_SEARCH_RESULT.tpl' => 'points_search_screen',
            'templates/POINTS_SEARCH_SCREEN.tpl' => 'points_search_screen',
            'templates/POINTS_SEND.tpl' => 'points_screen',
            'templates/POINTS_PROFILE.tpl' => 'points_screen',
            'templates/POINTS_SCREEN.tpl' => 'points_screen',
            'templates/ESCROW_TRANSACTIONS.tpl' => 'points_escrow_transactions',
            'templates/POINTS_ESCROW_SCREEN.tpl' => 'points_escrow_screen',
        ];
    }

    /**
     * Get a preview(s) of a (group of) template(s), as a full standalone piece of HTML in Tempcode format.
     * Uses sources/lorem.php functions to place appropriate stock-text. Should not hard-code things, as the code is intended to be declarative.
     * Assumptions: You can assume all Lang/CSS/JavaScript files in this addon have been pre-required.
     *
     * @return Tempcode Preview
     */
    public function tpl_preview__points_search_screen() : object
    {
        $results = new Tempcode();
        foreach (placeholder_array() as $k => $v) {
            $results->attach(do_lorem_template('POINTS_SEARCH_RESULT', [
                'URL' => placeholder_url(),
                'ID' => placeholder_numeric_id(),
                'USERNAME' => lorem_word(),
            ]));
        }

        return lorem_globalise(do_lorem_template('POINTS_SEARCH_SCREEN', [
            'TITLE' => lorem_screen_title(),
            'RESULTS' => $results,
        ]), null, '', true);
    }

    /**
     * Get a preview(s) of a (group of) template(s), as a full standalone piece of HTML in Tempcode format.
     * Uses sources/lorem.php functions to place appropriate stock-text. Should not hard-code things, as the code is intended to be declarative.
     * Assumptions: You can assume all Lang/CSS/JavaScript files in this addon have been pre-required.
     *
     * @return Tempcode Preview
     */
    public function tpl_preview__points_screen() : object
    {
        $escrow_template = do_lorem_template('ESCROW_TRANSACTIONS', [
            '_GUID' => 'ac97ee94388e4db2b8753273694cb2a1',
            'MEMBER' => placeholder_number(),
            '_VIEWER_POINTS_BALANCE' => placeholder_number(),
            'VIEWER_POINTS_BALANCE' => placeholder_number(),
            '_VIEWER_GIFT_POINTS_BALANCE' => placeholder_number(),
            'VIEWER_GIFT_POINTS_BALANCE' => placeholder_number(),
            'GIFT_POINTS_ENABLED' => true,
            'FORM' => placeholder_button(),
        ]);

        $send_template = do_lorem_template('POINTS_SEND', [
            'SEND_URL' => placeholder_url(),
            'MEMBER' => placeholder_numeric_id(),
            'DEFAULT__TRANS_TYPE' => 'send',
            'DEFAULT__SEND_AMOUNT' => placeholder_number(),
            'DEFAULT__SEND_REASON' => lorem_phrase(),
            '_VIEWER_GIFT_POINTS_BALANCE' => placeholder_number(),
            'VIEWER_GIFT_POINTS_BALANCE' => placeholder_number(),
            '_VIEWER_POINTS_BALANCE' => placeholder_number(),
            'VIEWER_POINTS_BALANCE' => placeholder_number(),
        ]);

        $content = do_lorem_template('POINTS_PROFILE', [
            'MEMBER' => placeholder_numeric_id(),
            'PROFILE_URL' => placeholder_url(),
            'USERNAME' => lorem_word(),
            '_POINTS_RANK' => placeholder_number(),
            'POINTS_RANK' => placeholder_number(),
            '_POINTS_BALANCE' => placeholder_number(),
            'POINTS_BALANCE' => placeholder_number(),
            '_GIFT_POINTS_BALANCE' => placeholder_number(),
            'GIFT_POINTS_BALANCE' => placeholder_number(),
            '_VOTING_POWER' => placeholder_number(),
            'VOTING_POWER' => placeholder_number(),
            '_POINTS_RECEIVED_AGGREGATE' => placeholder_number(),
            'POINTS_RECEIVED_AGGREGATE' => placeholder_number(),
            '_POINTS_RECEIVED' => placeholder_number(),
            'POINTS_RECEIVED' => placeholder_number(),
            '_POINTS_SENT_AGGREGATE' => placeholder_number(),
            'POINTS_SENT_AGGREGATE' => placeholder_number(),
            '_POINTS_SENT' => placeholder_number(),
            'POINTS_SENT' => placeholder_number(),
            '_POINTS_SPENT_AGGREGATE' => placeholder_number(),
            'POINTS_SPENT_AGGREGATE' => placeholder_number(),
            '_POINTS_SPENT' => placeholder_number(),
            'POINTS_SPENT' => placeholder_number(),
            'RECEIVED_TABLE_AGGREGATE' => placeholder_table(),
            'RECEIVED_TABLE' => placeholder_table(),
            'SENT_TABLE_AGGREGATE' => placeholder_table(),
            'SENT_TABLE' => placeholder_table(),
            'SPENT_TABLE_AGGREGATE' => placeholder_table(),
            'SPENT_TABLE' => placeholder_table(),
            'ESCROW_DETAILS' => placeholder_table(),
            'GIVE' => $send_template,
            'ESCROW' => $escrow_template,
            'EXPORT_POINTS_LEDGER' => lorem_sentence_html(),
        ]);

        return lorem_globalise(do_lorem_template('POINTS_SCREEN', [
            'TITLE' => lorem_screen_title(),
            'CONTENT' => $content,
        ]), null, '', true);
    }

    /**
     * Get a preview(s) of a (group of) template(s), as a full standalone piece of HTML in Tempcode format.
     * Uses sources/lorem.php functions to place appropriate stock-text. Should not hard-code things, as the code is intended to be declarative.
     * Assumptions: You can assume all Lang/CSS/JavaScript files in this addon have been pre-required.
     *
     * @return Tempcode Preview
     */
    public function tpl_preview__points_escrow_transactions() : object
    {
        require_lang('points');
        require_code('form_templates');

        $form = new Tempcode();
        $form->attach(do_template('BUTTON_SCREEN', ['_GUID' => 'be2d6b899b75d8ad77d7de2e0da74cdb', 'IMMEDIATE' => false, 'URL' => placeholder_url(), 'TITLE' => do_lang_tempcode('ESCROW_TO'), 'IMG' => 'buttons/proceed', 'HIDDEN' => new Tempcode()]));

        return lorem_globalise(do_lorem_template('ESCROW_TRANSACTIONS', [
            'MEMBER' => placeholder_numeric_id(),
            '_VIEWER_POINTS_BALANCE' => placeholder_numeric_id(),
            'VIEWER_POINTS_BALANCE' => placeholder_numeric_id(),
            '_VIEWER_GIFT_POINTS_BALANCE' => placeholder_numeric_id(),
            'VIEWER_GIFT_POINTS_BALANCE' => placeholder_numeric_id(),
            'GIFT_POINTS_ENABLED' => true,
            'FORM' => $form,
        ]), null, '', true);
    }

    /**
     * Get a preview(s) of a (group of) template(s), as a full standalone piece of HTML in Tempcode format.
     * Uses sources/lorem.php functions to place appropriate stock-text. Should not hard-code things, as the code is intended to be declarative.
     * Assumptions: You can assume all Lang/CSS/JavaScript files in this addon have been pre-required.
     *
     * @return Tempcode Preview
     */
    public function tpl_preview__points_escrow_screen() : object
    {
        return lorem_globalise(do_lorem_template('POINTS_ESCROW_SCREEN', [
            'TITLE' => lorem_screen_title(),
            'FIELDS' => placeholder_fields(),
            'BUTTONS' => placeholder_button(),
            'ESCROW_LOGS' => placeholder_table()
        ]), null, '', true);
    }
}
