ÿØÿà JFIF    ÿÛ „  ( %!1"%)+...383-7(-.+  -%%--------+------------/----------------------------ÿÀ  ¶" ÿÄ     ÿÄ @    !1AQaq‘¡"±ÁÑð2’BRráS‚ñ3b¢CT²Ò #cÿÄ    ÿÄ '   1!AQ2a"‘±#ÿÚ   ? ò(/p‘—–¢·,M|¯G»R£üešT. ôŸEoCFñ‡ 4ÔkåóxR|µÁ¨ÓDà!Ç´µ˜‡p ÍQ‹§!þž^õWsŒy  åÁ§$á«%ºq˜™JyyË0y«^Ϗ -3ÃÏËÈ£Æ\P’ä„s&•‹Üs üô'àWt¹pñCp$bÚF`·7.^)¾!)ÒÙ˜–ÅÏš^h¾ø³·ìe±ŒaeÖ—Í,e=B}Jéߦ$$½—šÙÜCC¯¶è8β–Åkèwx LÉngT±æ¹£Ócœ¿Í/©Éÿ ‰ÚCÒ­mq;Tt¶–}0"zÖPcd1š­¤tˆ„ÐÓâqú[™öUCŠ2޿د­É(¸ßúçšmW,Ò ºf‹Ån™ÄLêÁ8üÁkÁ€L¥ÍuJ1œôrÂSŒÓöt!7EUíïb)AËi¬â-ÙHk8òÁiXYwÅ)O^"ÇØriÛô{»wRUKÙÏÚlÓ¬€‚’שT ] ªb—ÊîKC^×M“xùäñz¬zJ× {4[¹M'IÆeH1LCWÕ]œûº WDæà°OÅ‚¹c²ÞuA–rL`HšpCez‡V’— Ž‚Ë„–ñ­'µR0ÕÖ=À:±G»C\nÆÉ5*¢ †3šhQ4ýÒi$Õ1"Ü]¢p-q3zcQ$ªö¨¥æf›‘»´ÝÚHá„e²JÇ–iÊ:·à¬Øc5Åk»Laª*wi [0Ówk ¦a¦0Õ²ÅÅ‚T¸’³q:Æ<¹ú Ò˜Æ}2VE•Ѐp¡Ô3Úº …h³^LJºçì¥Ánó|˜ÖˆÎˆ+« ¦dø‘Mº–d\ªDðÛ„Ì×LÝ——Ð9Ç|•FèçVm™¨€™3õS–9Äå¢<̉Ìm¢±`·º˜&Z²ž Ë®D«¶»6™‰©­HÈ Àá«h­i³04æ’hxœi3ï¨(ÓL·†‹¶ËpŒ ƒÜÒ? :õdsÀ –3æÓ·Üjâ¬9—]8n¼&]I F£¼…ì–—Œ0v°LǐÅfÛ2TÖ’aµ˜N@ÖBSÏ^à´4-±°b×nÈÈœÆD=KdŒø…ÄÈK,›ÖR§fjü$^ÔÎ!„6^ s:Üun\ôkCÞò÷<—Lúl Í›G¹ÀPá¼Nc¡šÒ…ÙWͳœ±vÊáЄ×9‹P‰cEØ‘™›µŸP<×g1 º©Ø¬wiÁ^l5× I/';Ë+´Z‡ÓÄFÕp[Èð’ HÄ ó 9¬Dl4“é±Ï”V=^Hð;žLädÉa‚°Ë,#/Ž~²BÔÛ QãñQtIeórVB,ÏÂf‹4#Μc‹É3ZIÖ Œ¢¥·üxa‡Ãçè„jŠ[5 Ä!U?,3žÎ×…ðdÓ÷háŠA‰ìÄ4÷ÃÜZÃE{‰®+W\ZÍE[‰»µk»MÝ­`¢©†˜ÃV‹-f¢¡†¢a«eŠ%«Y¨©q%jâd,Ôq`) ¤¦…šˆ ¦E>0Ùb²t–Ÿ  ÷jsςҒKÈcø(é›;k(’#ôŒQ ™C> õ³M9óºÆµ¤çâ;uÀ)5>RÔ¸fÓ~Ȧ—’-$fe«"FâUˆÊwµPÏu w+"åÉó¨6s™Û9(À¨ù©hE°½†n`m~“@©›p!Vkhµ Á1šbEqqÊ@ºèl›2 –Yã%‘‚hÛ{a¶‡ÅÞM²¬çL34®Çl]®‹ŽØŒm'RÜe35æöˆ­Á­ cP9šeÁköo´L³Ì=p8]”‡B¶,šº|ɏdzXˆØk*ÇÚ{#ñ‰pã(€¶‡9ý'šÜ³½¯kƒ†Â’ëSOƒ•Å®H6+a¢µˆ‹Y¨b˜b+XˆÖ!°u!¢"µˆˆn2ˆ Å0Ä`Å Ô®c(ÓÜGº•Ä»Œ âWî%q.áÐÄ÷î%umÍ£+ÜQ,Vn¦-GphU¸¢X­&,Gt ·K¢ÅÅ·¥RÄÊÉbKn N­R2g$VµÕó Qr#–ÓZUÏð0ÎtÙÀœz ëöo“Îk¯n„T°"SÞ+³/…€½"ižãO%Í%&Δâ‘ËØ´IˆÓ°Ë‰ÞM3.™yçÁzit›`4C`k¢¼á!álÄï sÂ[×!¤l¾æo"ƒIÔ'@ªu)3›ô®“@Z à¾] üœ'‡4¸PÞkÁ-qÄH‰ÓÍBd´ÿ —¹°ÄA&ÊUC„öz‚‚RæŠtf¬>˜ÑidšEçÑL÷áý¡V±h§­c¿¥¨ƒ@g¼…Ýö^ÞËc.ž„æ“I[ ª+·zÐÒÚ,½Ð»¶€C›7jk$๖€Ž¾ÅÙpp¶ÍþéΤ ½ØÎŒq ñpæžÅ¥#Øâ49ÃÂK^MYV“,¶Éz_òæ:…;Õ«¦I3âJ£¤û5$7Èxün\â]Êe¯(Ÿ&Ž‹¶2<6Ćf× æ¢ƱqWı[(ÙÂŽç‚T7¨@ÈÉÍß‚ïÙ"&3TYlGށ†)†#5ŠA©^T2ÆÁ†)©†©†¤yGXÁ†©"†)©¼ÅV WS†#©]R–r‹q5ÕbâWþBh¯u+ªÅÄ×ü„nÑ^êkªÁj‰jeœWˆÕÕ`µDµ2Ì+Ä µDµµ5Ô{¤Þ0RF’H÷AÛ<ÊÁ§ ƈæ0Ñ£ê4 öÚµ[¬/1²€â<-¬šö²r×0o×w ´xÐÒË„ g01¬„åEM蛇Ã\6µE›‘fÙO k÷CºnÓ1`iîÒ² áÂ!ÑLÄÿ ³¬\õ*:M=Ç»c‹2[‰ØsÕLò\ŒK L^™üÄN\¶#» Ç\……ßïIœÉ$¸ÎñÍ®ÔHÇ Ûí/´>Li”„†g^$ 7NÍÑÑ2M2ªNg=k½Ð}Ÿl6‡ —JWˆ”ÞéT·+µ¦üÂFè¢Vs6ýÆ4»2+2IÝ9ô9®ÇGÙÇ1+Ä8;*Õ§ž½D*îÑWÚçá3Ma¤·ˆ¥t}š²Ü…Q+Æüµ8HíS”üxGéÁˆ¦Ël„éÈ 5 µÄƒ6äÜ(kIš¯S†fÖ&¸®×v|Äyˆ*禌Éù@7-®Ä[]ÎÖ¿ê`º…=:…žJVnݳvðÖKE¼‚ »mà ÷f®:Ë ™–4rð¡4` ܹçž~‹C=œ…¾Ïj|VDtK.ƒ"9 Ï ­–éXá³6WÒïIL-Ї Ç home/smkb8269/public_html/lms.smk-almanshuriyah.sch.id/lib/classes/dataformat/base.php000064400000017711152267211510024642 0ustar00. /** * Base class for dataformat. * * @package core * @subpackage dataformat * @copyright 2016 Brendan Heywood (brendan@catalyst-au.net) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace core\dataformat; use coding_exception; /** * Base class for dataformat. * * @package core * @subpackage dataformat * @copyright 2016 Brendan Heywood (brendan@catalyst-au.net) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ abstract class base { /** @var $mimetype */ protected $mimetype = "text/plain"; /** @var $extension */ protected $extension = ".txt"; /** @var $filename */ protected $filename = ''; /** @var string The location to store the output content */ protected $filepath = ''; /** * Get the file extension * * @return string file extension */ public function get_extension() { return $this->extension; } /** * Set download filename base * * @param string $filename */ public function set_filename($filename) { $this->filename = $filename; } /** * Set file path when writing to file * * @param string $filepath * @throws coding_exception */ public function set_filepath(string $filepath): void { $filedir = dirname($filepath); if (!is_writable($filedir)) { throw new coding_exception('File path is not writable'); } $this->filepath = $filepath; // Some dataformat writers may expect filename to be set too. $this->set_filename(pathinfo($this->filepath, PATHINFO_FILENAME)); } /** * Set the title of the worksheet inside a spreadsheet * * For some formats this will be ignored. * * @param string $title */ public function set_sheettitle($title) { } /** * Output file headers to initialise the download of the file. */ public function send_http_headers() { if (defined('BEHAT_SITE_RUNNING') || PHPUNIT_TEST) { // For text based formats - we cannot test the output with behat if we force a file download. return; } if (is_https()) { // HTTPS sites - watch out for IE! KB812935 and KB316431. header('Cache-Control: max-age=10'); header('Pragma: '); } else { // Normal http - prevent caching at all cost. header('Cache-Control: private, must-revalidate, pre-check=0, post-check=0, max-age=0'); header('Pragma: no-cache'); } header('Expires: '. gmdate('D, d M Y H:i:s', 0) .' GMT'); header("Content-Type: $this->mimetype\n"); $filename = $this->filename . $this->get_extension(); header("Content-Disposition: attachment; filename=\"$filename\""); } /** * Set the dataformat to be output to current file. Calling code must call {@see base::close_output_to_file()} when finished */ public function start_output_to_file(): void { // Raise memory limit to ensure we can store the entire content. Start collecting output. raise_memory_limit(MEMORY_EXTRA); ob_start(); $this->start_output(); } /** * Write the start of the file. */ public function start_output() { // Override me if needed. } /** * Write the start of the sheet we will be adding data to. * * @param array $columns */ public function start_sheet($columns) { // Override me if needed. } /** * Method to define whether the dataformat supports export of HTML * * @return bool */ public function supports_html(): bool { return false; } /** * Apply formatting to the cells of a given record * * @param array|\stdClass $record * @return array */ protected function format_record($record): array { $record = (array)$record; // If the dataformat supports export of HTML, we need to allow them to manage embedded images. if ($this->supports_html()) { $record = array_map([$this, 'replace_pluginfile_images'], $record); } return $record; } /** * Given a stored_file, return a suitable source attribute for an img element in the export (or null to use the original) * * @param \stored_file $file * @return string|null */ protected function export_html_image_source(\stored_file $file): ?string { return null; } /** * We need to locate all img tags within a given cell that match pluginfile URL's. Partly so the exported file will show * the image without requiring the user is logged in; and also to prevent some of the dataformats requesting the file * themselves, which is likely to fail due to them not having an active session * * @param string|null $content * @return string */ protected function replace_pluginfile_images(?string $content): string { $content = (string)$content; // Examine content to see if it contains any HTML image tags. return preg_replace_callback('/(?
]+src=")(?[^"]*)(?".*>)/i', function(array $matches) {
            $source = $matches['source'];

            // Now check if the image source looks like a pluginfile URL.
            if (preg_match('/pluginfile.php\/(?\d+)\/(?[^\/]+)\/(?[^\/]+)\/(?:(?\d+)\/)?' .
                    '(?.*)/u', $source, $args)) {

                $context = $args['context'];
                $component = clean_param($args['component'], PARAM_COMPONENT);
                $filearea = clean_param($args['filearea'], PARAM_AREA);
                $itemid = $args['itemid'] ?: 0;
                $path = clean_param(urldecode($args['path']), PARAM_PATH);

                // Try and get the matching file from storage, allow the dataformat to define the replacement source.
                $fullpath = "/{$context}/{$component}/{$filearea}/{$itemid}/{$path}";
                if ($file = get_file_storage()->get_file_by_hash(sha1($fullpath))) {
                    $exportsource = $this->export_html_image_source($file);

                    if ($exportsource) {
                        $source = $exportsource;
                    }
                }
            }

            return $matches['pre'] . $source . $matches['post'];
        }, $content);
    }

    /**
     * Write a single record
     *
     * @param array $record
     * @param int $rownum
     */
    abstract public function write_record($record, $rownum);

    /**
     * Write the end of the sheet containing the data.
     *
     * @param array $columns
     */
    public function close_sheet($columns) {
        // Override me if needed.
    }

    /**
     * Write the end of the file.
     */
    public function close_output() {
        // Override me if needed.
    }

    /**
     * Write the data to disk. Calling code should have previously called {@see base::start_output_to_file()}
     *
     * @return bool Whether the write succeeded
     */
    public function close_output_to_file(): bool {
        $this->close_output();

        $filecontent = ob_get_contents();
        ob_end_clean();

        return file_put_contents($this->filepath, $filecontent) !== false;
    }
}
home/smkb8269/public_html/lms.smk-almanshuriyah.sch.id/lib/classes/plugininfo/base.php000064400000064231152267535270024705 0ustar00.

/**
 * Defines classes used for plugin info.
 *
 * @package    core
 * @copyright  2011 David Mudrak 
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
namespace core\plugininfo;

use coding_exception;
use core_component;
use core_plugin_manager;
use moodle_url;

/**
 * Base class providing access to the information about a plugin
 */
abstract class base {

    /** @var string the plugintype name, eg. mod, auth or workshopform */
    public $type;
    /** @var string full path to the location of all the plugins of this type */
    public $typerootdir;
    /** @var string the plugin name, eg. assignment, ldap */
    public $name;
    /** @var string the localized plugin name */
    public $displayname;
    /** @var string the plugin source, one of core_plugin_manager::PLUGIN_SOURCE_xxx constants */
    public $source;
    /** @var string fullpath to the location of this plugin */
    public $rootdir;
    /** @var int|string the version of the plugin's source code */
    public $versiondisk;
    /** @var int|string the version of the installed plugin */
    public $versiondb;
    /** @var int|float|string required version of Moodle core  */
    public $versionrequires;
    /** @var array explicitly supported branches of Moodle core  */
    public $pluginsupported;
    /** @var int first incompatible branch of Moodle core  */
    public $pluginincompatible;
    /** @var mixed human-readable release information */
    public $release;
    /** @var array other plugins that this one depends on, lazy-loaded by {@link get_other_required_plugins()} */
    public $dependencies;
    /** @var int number of instances of the plugin - not supported yet */
    public $instances;
    /** @var int order of the plugin among other plugins of the same type - not supported yet */
    public $sortorder;
    /** @var core_plugin_manager the plugin manager this plugin info is part of */
    public $pluginman;

    /** @var array|null array of {@link \core\update\info} for this plugin */
    protected $availableupdates;

    /** @var int Move a plugin up in the plugin order */
    public const MOVE_UP = -1;

    /** @var int Move a plugin down in the plugin order */
    public const MOVE_DOWN = 1;

    /** @var array hold $plugin->supported in version.php */
    public $supported;

    /** @var int hold $plugin->incompatible in version.php  */
    public $incompatible;

    /** @var string Name of the plugin */
    public $component = '';

    /** @var bool whether the plugin is that of a phase 1 deprecated type or subplugin type. */
    public $deprecatedtype = false;

    /** @var bool whether the plugin is that of a phase 2 deprecated (deleted) type or subplugin type. */
    public $deletedtype = false;

    /**
     * Whether this plugintype supports its plugins being disabled.
     *
     * @return bool
     */
    public static function plugintype_supports_disabling(): bool {
        return false;
    }

    /**
     * Finds all enabled plugins, the result may include missing plugins.
     * @return array|null of enabled plugins $pluginname=>$pluginname, null means unknown
     */
    public static function get_enabled_plugins() {
        return null;
    }

    /**
     * Enable or disable a plugin.
     * When possible, the change will be stored into the config_log table, to let admins check when/who has modified it.
     *
     * @param string $pluginname The plugin name to enable/disable.
     * @param int $enabled Whether the pluginname should be enabled (1) or not (0). This is an integer because some plugins, such
     * as filters or repositories, might support more statuses than just enabled/disabled.
     *
     * @return bool Whether $pluginname has been updated or not.
     */
    public static function enable_plugin(string $pluginname, int $enabled): bool {
        return false;
    }

    /**
     * Returns current status for a pluginname.
     *
     * @param string $pluginname The plugin name to check.
     * @return int The current status (enabled, disabled...) of $pluginname.
     */
    public static function get_enabled_plugin(string $pluginname): int {
        $enabledplugins = static::get_enabled_plugins();
        $value = $enabledplugins && array_key_exists($pluginname, $enabledplugins);
        return (int) $value;
    }

    /**
     * Gathers and returns the information about all plugins of the given type,
     * either on disk or previously installed.
     *
     * This is supposed to be used exclusively by the plugin manager when it is
     * populating its tree of plugins.
     *
     * @param string $type the name of the plugintype, eg. mod, auth or workshopform
     * @param string $typerootdir full path to the location of the plugin dir
     * @param string $typeclass the name of the actually called class
     * @param core_plugin_manager $pluginman the plugin manager calling this method
     * @return array of plugintype classes, indexed by the plugin name
     */
    public static function get_plugins($type, $typerootdir, $typeclass, $pluginman) {
        // Get the information about plugins at the disk, including deprecated plugins.
        $plugins = core_component::get_all_plugins_list($type);

        // Also included deleted plugins.

        $return = array();
        foreach ($plugins as $pluginname => $pluginrootdir) {
            $return[$pluginname] = self::make_plugin_instance($type, $typerootdir,
                $pluginname, $pluginrootdir, $typeclass, $pluginman);
        }

        // Fetch missing incorrectly uninstalled plugins, including deprecated plugins which are not included above.
        $plugins = $pluginman->get_installed_plugins($type);

        foreach ($plugins as $name => $version) {
            if (isset($return[$name])) {
                continue;
            }
            $plugin              = new $typeclass();
            $plugin->type        = $type;
            $plugin->typerootdir = $typerootdir;
            $plugin->name        = $name;
            $plugin->component   = $plugin->type.'_'.$plugin->name;
            $plugin->rootdir     = null;
            $plugin->displayname = $name;
            $plugin->versiondb   = $version;
            $plugin->pluginman   = $pluginman;
            $plugin->init_is_standard();
            $plugin->init_is_deprecated();

            $return[$name] = $plugin;
        }

        return $return;
    }

    /**
     * Makes a new instance of the plugininfo class
     *
     * @param string $type the plugin type, eg. 'mod'
     * @param string $typerootdir full path to the location of all the plugins of this type
     * @param string $name the plugin name, eg. 'workshop'
     * @param string $namerootdir full path to the location of the plugin
     * @param string $typeclass the name of class that holds the info about the plugin
     * @param core_plugin_manager $pluginman the plugin manager of the new instance
     * @return base the instance of $typeclass
     */
    protected static function make_plugin_instance($type, $typerootdir, $name, $namerootdir, $typeclass, $pluginman) {
        $plugin              = new $typeclass();
        $plugin->type        = $type;
        $plugin->typerootdir = $typerootdir;
        $plugin->name        = $name;
        $plugin->rootdir     = $namerootdir;
        $plugin->pluginman   = $pluginman;
        $plugin->component   = $plugin->type.'_'.$plugin->name;

        $plugin->init_display_name();
        $plugin->load_disk_version();
        $plugin->load_db_version();
        $plugin->init_is_standard();
        $plugin->init_is_deprecated();

        return $plugin;
    }

    /**
     * Is this plugin already installed and updated?
     * @return bool true if plugin installed and upgraded.
     */
    public function is_installed_and_upgraded() {
        if (!$this->rootdir) {
            return false;
        }
        if ($this->versiondb === null and $this->versiondisk === null) {
            // There is no version.php or version info inside it.
            return false;
        }

        return ((float)$this->versiondb === (float)$this->versiondisk);
    }

    /**
     * Sets {@link $displayname} property to a localized name of the plugin
     */
    public function init_display_name() {
        if (!get_string_manager()->string_exists('pluginname', $this->component)) {
            $this->displayname = '[pluginname,' . $this->component . ']';
        } else {
            $this->displayname = get_string('pluginname', $this->component);
        }
    }

    /**
     * Magic method getter, redirects to read only values.
     *
     * @param string $name
     * @return mixed
     */
    public function __get($name) {
        switch ($name) {
            case 'component': return $this->type . '_' . $this->name;

            default:
                debugging('Invalid plugin property accessed! '.$name);
                return null;
        }
    }

    /**
     * Return the full path name of a file within the plugin.
     *
     * No check is made to see if the file exists.
     *
     * @param string $relativepath e.g. 'version.php'.
     * @return string e.g. $CFG->dirroot . '/mod/quiz/version.php'.
     */
    public function full_path($relativepath) {
        if (empty($this->rootdir)) {
            return '';
        }
        return $this->rootdir . '/' . $relativepath;
    }

    /**
     * Sets {@link $versiondisk} property to a numerical value representing the
     * version of the plugin's source code.
     *
     * If the value is null after calling this method, either the plugin
     * does not use versioning (typically does not have any database
     * data) or is missing from disk.
     */
    public function load_disk_version() {
        // Note: this includes deprecated plugins.
        $versions = $this->pluginman->get_present_plugins($this->type);

        $this->versiondisk = null;
        $this->versionrequires = null;
        $this->pluginsupported = null;
        $this->pluginincompatible = null;
        $this->dependencies = array();

        if (!isset($versions[$this->name])) {
            return;
        }

        $plugin = $versions[$this->name];

        if (isset($plugin->version)) {
            $this->versiondisk = $plugin->version;
        }
        if (isset($plugin->requires)) {
            $this->versionrequires = $plugin->requires;
        }
        if (isset($plugin->release)) {
            $this->release = $plugin->release;
        }
        if (isset($plugin->dependencies)) {
            $this->dependencies = $plugin->dependencies;
        }

        // Check that supports and incompatible are wellformed, exception otherwise.
        if (isset($plugin->supported)) {
            // Checks for structure of supported.
            $isint = (is_int($plugin->supported[0]) && is_int($plugin->supported[1]));
            $isrange = ($plugin->supported[0] <= $plugin->supported[1] && count($plugin->supported) == 2);

            if (is_array($plugin->supported) && $isint && $isrange) {
                $this->pluginsupported = $plugin->supported;
            } else {
                throw new coding_exception('Incorrect syntax in plugin supported declaration in '."$this->name");
            }
        }

        if (isset($plugin->incompatible) && $plugin->incompatible !== null) {
            if (((is_string($plugin->incompatible) && ctype_digit($plugin->incompatible)) || is_int($plugin->incompatible))
                    && (int) $plugin->incompatible > 0) {
                $this->pluginincompatible = intval($plugin->incompatible);
            } else {
                throw new coding_exception('Incorrect syntax in plugin incompatible declaration in '."$this->name");
            }
        }

    }

    /**
     * Get the list of other plugins that this plugin requires to be installed.
     *
     * @return array with keys the frankenstyle plugin name, and values either
     *      a version string (like '2011101700') or the constant ANY_VERSION.
     */
    public function get_other_required_plugins() {
        if (is_null($this->dependencies)) {
            $this->load_disk_version();
        }
        return $this->dependencies;
    }

    /**
     * Is this is a subplugin?
     *
     * @return boolean
     */
    public function is_subplugin() {
        return ($this->get_parent_plugin() !== false);
    }

    /**
     * If I am a subplugin, return the name of my parent plugin.
     *
     * @return string|bool false if not a subplugin, name of the parent otherwise
     */
    public function get_parent_plugin() {
        return $this->pluginman->get_parent_of_subplugin($this->type, true);
    }

    /**
     * Sets {@link $versiondb} property to a numerical value representing the
     * currently installed version of the plugin.
     *
     * If the value is null after calling this method, either the plugin
     * does not use versioning (typically does not have any database
     * data) or has not been installed yet.
     */
    public function load_db_version() {
        $versions = $this->pluginman->get_installed_plugins($this->type);

        if (isset($versions[$this->name])) {
            $this->versiondb = $versions[$this->name];
        } else {
            $this->versiondb = null;
        }
    }

    /**
     * Sets {@link $source} property to one of core_plugin_manager::PLUGIN_SOURCE_xxx
     * constants.
     *
     * If the property's value is null after calling this method, then
     * the type of the plugin has not been recognized and you should throw
     * an exception.
     */
    public function init_is_standard() {

        $pluginman = $this->pluginman;
        $standard = $pluginman::standard_plugins_list($this->type);

        if ($standard !== false) {
            $standard = array_flip($standard);
            if (isset($standard[$this->name])) {
                $this->source = core_plugin_manager::PLUGIN_SOURCE_STANDARD;
            } else if (!is_null($this->versiondb) and is_null($this->versiondisk)
                and $pluginman::is_deleted_standard_plugin($this->type, $this->name)) {
                $this->source = core_plugin_manager::PLUGIN_SOURCE_STANDARD; // To be deleted.
            } else {
                $this->source = core_plugin_manager::PLUGIN_SOURCE_EXTENSION;
            }
        }
    }

    /**
     * Init some instance props denoting the deprecation state of the plugin.
     *
     * Sets {@see $deprecatedtype} property, indicating whether the plugintype is phase 1 deprecated.
     * Sets {@see $deletedtype} property, indicating whether the plugintype is phase 2 deprecated.
     * Sets {@see $displayname} property to the plugin name phase 2 deprecated plugins since lang string support has then ended.
     *
     * @return void
     */
    final public function init_is_deprecated(): void {
        $this->deprecatedtype = \core_component::is_deprecated_plugin_type($this->type);
        $this->deletedtype = \core_component::is_deleted_plugin_type($this->type);
        $this->displayname = $this->deletedtype ? $this->name : $this->displayname;
    }

    /**
     * Returns true if the plugin is shipped with the official distribution
     * of the current Moodle version, false otherwise.
     *
     * @return bool
     */
    public function is_standard() {
        return $this->source === core_plugin_manager::PLUGIN_SOURCE_STANDARD;
    }

    /**
     * Returns true if the the given Moodle version is enough to run this plugin
     *
     * @param string|int|double $moodleversion
     * @return bool
     */
    public function is_core_dependency_satisfied($moodleversion) {

        if (empty($this->versionrequires)) {
            return true;

        } else {
            return (double)$this->versionrequires <= (double)$moodleversion;
        }
    }

    /**
     * Returns true if the the given moodle branch is not stated incompatible with the plugin
     *
     * @param int $branch the moodle branch number
     * @return bool true if not incompatible with moodle branch
     */
    public function is_core_compatible_satisfied(int $branch): bool {
        if (!empty($this->pluginincompatible) && ($branch >= $this->pluginincompatible)) {
            return false;
        } else {
            return true;
        }
    }

    /**
     * Returns the status of the plugin
     *
     * @return string one of core_plugin_manager::PLUGIN_STATUS_xxx constants
     */
    public function get_status() {

        $pluginman = $this->pluginman;

        if (is_null($this->versiondb) and is_null($this->versiondisk)) {
            return core_plugin_manager::PLUGIN_STATUS_NODB;

        } else if (is_null($this->versiondb) and !is_null($this->versiondisk)) {
            return core_plugin_manager::PLUGIN_STATUS_NEW;

        } else if (!is_null($this->versiondb) and is_null($this->versiondisk)) {
            if ($pluginman::is_deleted_standard_plugin($this->type, $this->name)) {
                return core_plugin_manager::PLUGIN_STATUS_DELETE;
            } else {
                return core_plugin_manager::PLUGIN_STATUS_MISSING;
            }

        } else if ((float)$this->versiondb === (float)$this->versiondisk) {
            // Note: the float comparison should work fine here
            //       because there are no arithmetic operations with the numbers.
            return core_plugin_manager::PLUGIN_STATUS_UPTODATE;

        } else if ($this->versiondb < $this->versiondisk) {
            return core_plugin_manager::PLUGIN_STATUS_UPGRADE;

        } else if ($this->versiondb > $this->versiondisk) {
            return core_plugin_manager::PLUGIN_STATUS_DOWNGRADE;

        } else {
            // $version = pi(); and similar funny jokes - hopefully Donald E. Knuth will never contribute to Moodle ;-)
            throw new coding_exception('Unable to determine plugin state, check the plugin versions');
        }
    }

    /**
     * Returns the information about plugin availability
     *
     * True means that the plugin is enabled. False means that the plugin is
     * disabled. Null means that the information is not available, or the
     * plugin does not support configurable availability or the availability
     * can not be changed.
     *
     * @return null|bool
     */
    public function is_enabled() {
        if (!$this->rootdir) {
            // Plugin missing.
            return false;
        }

        $enabled = $this->pluginman->get_enabled_plugins($this->type);

        if (!is_array($enabled)) {
            return null;
        }

        return isset($enabled[$this->name]);
    }

    /**
     * Return whether this plugin is deprecated (i.e. the plugin type to which it belongs is deprecated).
     *
     * @return bool
     */
    public function is_deprecated(): bool {
        return $this->deprecatedtype;
    }

    /**
     * Return whether this plugin is deleted (i.e. the plugin type to which it belongs is deleted).
     *
     * @return bool
     */
    public function is_deleted(): bool {
        return $this->deletedtype;
    }

    /**
     * If there are updates for this plugin available, returns them.
     *
     * Returns array of {@link \core\update\info} objects, if some update
     * is available. Returns null if there is no update available or if the update
     * availability is unknown.
     *
     * Populates the property {@link $availableupdates} on first call (lazy
     * loading).
     *
     * @return array|null
     */
    public function available_updates() {

        if ($this->availableupdates === null) {
            // Lazy load the information about available updates.
            $this->availableupdates = $this->pluginman->load_available_updates_for_plugin($this->component);
        }

        if (empty($this->availableupdates) or !is_array($this->availableupdates)) {
            $this->availableupdates = array();
            return null;
        }

        $updates = array();

        foreach ($this->availableupdates as $availableupdate) {
            if ($availableupdate->version > $this->versiondisk) {
                $updates[] = $availableupdate;
            }
        }

        if (empty($updates)) {
            return null;
        }

        return $updates;
    }

    /**
     * Returns the node name used in admin settings menu for this plugin settings (if applicable)
     *
     * @return null|string node name or null if plugin does not create settings node (default)
     */
    public function get_settings_section_name() {
        return null;
    }

    /**
     * Returns the URL of the plugin settings screen
     *
     * Null value means that the plugin either does not have the settings screen
     * or its location is not available via this library.
     *
     * @return null|moodle_url
     */
    public function get_settings_url(): ?moodle_url {
        $section = $this->get_settings_section_name();
        if ($section === null) {
            return null;
        }

        $settings = admin_get_root()->locate($section);
        if ($settings && $settings instanceof \core_admin\local\settings\linkable_settings_page) {
            return $settings->get_settings_page_url();
        }

        return null;
    }

    /**
     * Loads plugin settings to the settings tree
     *
     * This function usually includes settings.php file in plugins folder.
     * Alternatively it can create a link to some settings page (instance of admin_externalpage)
     *
     * @param \part_of_admin_tree $adminroot
     * @param string $parentnodename
     * @param bool $hassiteconfig whether the current user has moodle/site:config capability
     */
    public function load_settings(\part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig) {
    }

    /**
     * Should there be a way to uninstall the plugin via the administration UI.
     *
     * By default uninstallation is not allowed, plugin developers must enable it explicitly!
     *
     * @return bool
     */
    public function is_uninstall_allowed() {
        return false;
    }

    /**
     * Optional extra warning before uninstallation, for example number of uses in courses.
     *
     * @return string
     */
    public function get_uninstall_extra_warning() {
        return '';
    }

    /**
     * Pre-uninstall hook.
     *
     * This is intended for disabling of plugin, some DB table purging, etc.
     *
     * NOTE: to be called from uninstall_plugin() only.
     * @private
     */
    public function uninstall_cleanup() {
        // Override when extending class,
        // do not forget to call parent::pre_uninstall_cleanup() at the end.
    }

    /**
     * Returns relative directory of the plugin with heading '/'
     *
     * @return string
     */
    public function get_dir() {
        global $CFG;

        if (!isset($this->rootdir)) {
            return '';
        }

        return substr($this->rootdir, strlen($CFG->dirroot));
    }

    /**
     * Hook method to implement certain steps when uninstalling the plugin.
     *
     * This hook is called by {@link core_plugin_manager::uninstall_plugin()} so
     * it is basically usable only for those plugin types that use the default
     * uninstall tool provided by {@link self::get_default_uninstall_url()}.
     *
     * @param \progress_trace $progress traces the process
     * @return bool true on success, false on failure
     */
    public function uninstall(\progress_trace $progress) {
        return true;
    }

    /**
     * Where should we return after plugin of this type is uninstalled?
     * @param string $return
     * @return moodle_url
     */
    public function get_return_url_after_uninstall($return) {
        if ($return === 'manage') {
            if ($url = $this->get_manage_url()) {
                return $url;
            }
        }
        return new moodle_url('/admin/plugins.php#plugin_type_cell_'.$this->type);
    }

    /**
     * Return URL used for management of plugins of this type.
     * @return moodle_url
     */
    public static function get_manage_url() {
        return null;
    }

    /**
     * Returns URL to a script that handles common plugin uninstall procedure.
     *
     * This URL is intended for all plugin uninstallations.
     *
     * @param string $return either 'overview' or 'manage'
     * @return moodle_url
     */
    final public function get_default_uninstall_url($return = 'overview') {
        return new moodle_url('/admin/plugins.php', array(
            'uninstall' => $this->component,
            'confirm' => 0,
            'return' => $return,
        ));
    }

    /**
     * Whether this plugintype supports ordering of plugins using native functionality.
     *
     * Please note that plugintypes which pre-date this native functionality may still support ordering
     * but will not use the built-in functionality.
     *
     * @return bool
     */
    public static function plugintype_supports_ordering(): bool {
        return false;
    }

    /**
     * Finds all enabled plugins, the result may include missing plugins.
     *
     * @param bool $enabledonly Show all plugins, or only those which are enabled
     * @return array|null of sorted plugins $pluginname => $pluginname, null means unknown
     */
    public static function get_sorted_plugins(bool $enabledonly = false): ?array {
        return null;
    }

    /**
     * Change the order of the plugin relative to other plugins in the plugintype.
     *
     * When possible, the change will be stored into the config_log table, to let admins check when/who has modified it.
     *
     * @param string $pluginname The plugin name to enable/disable.
     * @param int $direction The direction to move the plugin. Negative numbers mean up, Positive mean down.
     * @return bool Whether $pluginname has been updated or not.
     */
    public static function change_plugin_order(string $pluginname, int $direction): bool {
        return false;
    }
}
home/smkb8269/public_html/lms.smk-almanshuriyah.sch.id/ai/classes/aimodel/base.php000064400000003527152267751400023764 0ustar00.

namespace core_ai\aimodel;

use MoodleQuickForm;

/**
 * Base Model class.
 *
 * @package    core_ai
 * @copyright  2025 Huong Nguyen 
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
abstract class base {
    /**
     * Get the display name of the model.
     * This name is used to display the model in the UI.
     *
     * @return string The display name of the model.
     */
    abstract public function get_model_display_name(): string;

    /**
     * Get the name of the model.
     * This name is used to identify the model. The system will use this model name to make the request to the AI services.
     *
     * @return string The name of the model.
     */
    abstract public function get_model_name(): string;

    /**
     * Add the model settings to the form.
     *
     * @param MoodleQuickForm $mform The form to add the model settings to.
     */
    public function add_model_settings(MoodleQuickForm $mform): void {
    }

    /**
     * Check if the model has settings.
     *
     * @return bool Whether the model has settings.
     */
    public function has_model_settings(): bool {
        return false;
    }
}