Ignore:
Timestamp:
May 2, 2016, 12:09:23 PM (3 years ago)
Author:
jrpelegrina
Message:

Updated to moodle 3.0.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • moodle/trunk/fuentes/lib/classes/plugininfo/portfolio.php

    r136 r1331  
    5555        return new moodle_url('/admin/portfolio.php');
    5656    }
     57
     58    /**
     59     * Defines if there should be a way to uninstall the plugin via the administration UI.
     60     * @return boolean
     61     */
     62    public function is_uninstall_allowed() {
     63        return true;
     64    }
     65
     66    /**
     67     * Pre-uninstall hook.
     68     * This is intended for disabling of plugin, some DB table purging, etc.
     69     */
     70    public function uninstall_cleanup() {
     71        global $DB;
     72
     73        // Get all instances of this portfolio.
     74        $count = $DB->count_records('portfolio_instance', array('plugin' => $this->name));
     75        if ($count > 0) {
     76            // This portfolio is in use, get the it's ID.
     77            $rec = $DB->get_record('portfolio_instance', array('plugin' => $this->name));
     78
     79            // Remove all records from portfolio_instance_config.
     80            $DB->delete_records('portfolio_instance_config', array('instance' => $rec->id));
     81            // Remove all records from portfolio_instance_user.
     82            $DB->delete_records('portfolio_instance_user', array('instance' => $rec->id));
     83            // Remove all records from portfolio_log.
     84            $DB->delete_records('portfolio_log', array('portfolio' => $rec->id));
     85            // Remove all records from portfolio_tempdata.
     86            $DB->delete_records('portfolio_tempdata', array('instance' => $rec->id));
     87
     88            // Remove the record from the portfolio_instance table.
     89            $DB->delete_records('portfolio_instance', array('id' => $rec->id));
     90        }
     91
     92        parent::uninstall_cleanup();
     93    }
    5794}
Note: See TracChangeset for help on using the changeset viewer.