| Línea 21... | Línea 21... | 
          
            | 21 |  * @subpackage course
 | 21 |  * @subpackage course
 | 
          
            | 22 |  * @copyright  2013 Marina Glancy
 | 22 |  * @copyright  2013 Marina Glancy
 | 
          
            | 23 |  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 | 23 |  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 | 
          
            | 24 |  */
 | 24 |  */
 | 
          
            | Línea 25... | Línea 25... | 
          
            | 25 |  
 | 25 |  
 | 
          
            | Línea 26... | Línea 26... | 
          
            | 26 | defined('MOODLE_INTERNAL') || die();
 | 26 | use core\exception\moodle_exception;
 | 
          
            | 27 |  
 | 27 |  
 | 
          
            | 28 | /**
 | 28 | /**
 | 
          
            | 29 |  * Class to store, cache, render and manage course category
 | 29 |  * Class to store, cache, render and manage course category
 | 
          
            | Línea 270... | Línea 270... | 
          
            | 270 |         }
 | 270 |         }
 | 
          
            | Línea 271... | Línea 271... | 
          
            | 271 |  
 | 271 |  
 | 
          
            | 272 |         if (!$coursecat) {
 | 272 |         if (!$coursecat) {
 | 
          
            | 273 |             // Course category not found.
 | 273 |             // Course category not found.
 | 
          
            | 274 |             if ($strictness == MUST_EXIST) {
 | 274 |             if ($strictness == MUST_EXIST) {
 | 
          
            | 275 |                 throw new moodle_exception('unknowncategory');
 | 275 |                 throw new moodle_exception('unknowncategory', a: $id);
 | 
          
            | 276 |             }
 | 276 |             }
 | 
          
            | 277 |             $coursecat = null;
 | 277 |             $coursecat = null;
 | 
          
            | 278 |         } else if (!$alwaysreturnhidden && !$coursecat->is_uservisible($user)) {
 | 278 |         } else if (!$alwaysreturnhidden && !$coursecat->is_uservisible($user)) {
 | 
          
            | 279 |             // Course category is found but user can not access it.
 | 279 |             // Course category is found but user can not access it.
 | 
          
            | Línea 1664... | Línea 1664... | 
          
            | 1664 |                 $where = 'ctx.id in (SELECT distinct bi.parentcontextid FROM {block_instances} bi
 | 1664 |                 $where = 'ctx.id in (SELECT distinct bi.parentcontextid FROM {block_instances} bi
 | 
          
            | 1665 |                     WHERE bi.blockname = :blockname)';
 | 1665 |                     WHERE bi.blockname = :blockname)';
 | 
          
            | 1666 |                 $params = array('blockname' => $blockname);
 | 1666 |                 $params = array('blockname' => $blockname);
 | 
          
            | 1667 |             } else if (!empty($search['modulelist'])) {
 | 1667 |             } else if (!empty($search['modulelist'])) {
 | 
          
            | 1668 |                 // Search courses that have module with specified name.
 | 1668 |                 // Search courses that have module with specified name.
 | 
          
            | - |   | 1669 |                 if (array_key_exists($search['modulelist'], core_component::get_plugin_list('mod'))) {
 | 
          
            | - |   | 1670 |                     // If module plugin exists, use module name as table name.
 | 
          
            | 1669 |                 $where = "c.id IN (SELECT DISTINCT module.course ".
 | 1671 |                     $where = "c.id IN (SELECT DISTINCT module.course FROM {{$search['modulelist']}} module)";
 | 
          
            | - |   | 1672 |                 } else {
 | 
          
            | 1670 |                         "FROM {".$search['modulelist']."} module)";
 | 1673 |                     // Otherwise, return empty list of courses.
 | 
          
            | - |   | 1674 |                     $where = '1=0';
 | 
          
            | - |   | 1675 |                 }
 | 
          
            | 1671 |                 $params = array();
 | 1676 |                 $params = array();
 | 
          
            | 1672 |             } else if (!empty($search['tagid'])) {
 | 1677 |             } else if (!empty($search['tagid'])) {
 | 
          
            | 1673 |                 // Search courses that are tagged with the specified tag.
 | 1678 |                 // Search courses that are tagged with the specified tag.
 | 
          
            | 1674 |                 $where = "c.id IN (SELECT t.itemid ".
 | 1679 |                 $where = "c.id IN (SELECT t.itemid ".
 | 
          
            | 1675 |                         "FROM {tag_instance} t WHERE t.tagid = :tagid AND t.itemtype = :itemtype AND t.component = :component)";
 | 1680 |                         "FROM {tag_instance} t WHERE t.tagid = :tagid AND t.itemtype = :itemtype AND t.component = :component)";
 | 
          
            | Línea 2054... | Línea 2059... | 
          
            | 2054 |         grade_course_category_delete($this->id, 0, $showfeedback);
 | 2059 |         grade_course_category_delete($this->id, 0, $showfeedback);
 | 
          
            | 2055 |         $cb = new \core_contentbank\contentbank();
 | 2060 |         $cb = new \core_contentbank\contentbank();
 | 
          
            | 2056 |         if (!$cb->delete_contents($this->get_context())) {
 | 2061 |         if (!$cb->delete_contents($this->get_context())) {
 | 
          
            | 2057 |             throw new moodle_exception('errordeletingcontentfromcategory', 'contentbank', '', $this->get_formatted_name());
 | 2062 |             throw new moodle_exception('errordeletingcontentfromcategory', 'contentbank', '', $this->get_formatted_name());
 | 
          
            | 2058 |         }
 | 2063 |         }
 | 
          
            | 2059 |         if (!question_delete_course_category($this, null)) {
 | - |   | 
          
            | 2060 |             throw new moodle_exception('cannotdeletecategoryquestions', '', '', $this->get_formatted_name());
 | - |   | 
          
            | 2061 |         }
 | - |   | 
          
            | Línea 2062... | Línea 2064... | 
          
            | 2062 |  
 | 2064 |  
 | 
          
            | 2063 |         // Delete all events in the category.
 | 2065 |         // Delete all events in the category.
 | 
          
            | Línea 2064... | Línea 2066... | 
          
            | 2064 |         $DB->delete_records('event', array('categoryid' => $this->id));
 | 2066 |         $DB->delete_records('event', array('categoryid' => $this->id));
 | 
          
            | Línea 2243... | Línea 2245... | 
          
            | 2243 |                         get_string('errordeletingcontentbankfromcategory', 'contentbank', $catname),
 | 2245 |                         get_string('errordeletingcontentbankfromcategory', 'contentbank', $catname),
 | 
          
            | 2244 |                         'notifysuccess'
 | 2246 |                         'notifysuccess'
 | 
          
            | 2245 |                 );
 | 2247 |                 );
 | 
          
            | 2246 |             }
 | 2248 |             }
 | 
          
            | 2247 |         }
 | 2249 |         }
 | 
          
            | 2248 |         if (!question_delete_course_category($this, $newparentcat)) {
 | - |   | 
          
            | 2249 |             if ($showfeedback) {
 | - |   | 
          
            | 2250 |                 echo $OUTPUT->notification(get_string('errordeletingquestionsfromcategory', 'question', $catname), 'notifysuccess');
 | - |   | 
          
            | 2251 |             }
 | - |   | 
          
            | 2252 |             return false;
 | - |   | 
          
            | 2253 |         }
 | - |   | 
          
            | Línea 2254... | Línea 2250... | 
          
            | 2254 |  
 | 2250 |  
 | 
          
            | 2255 |         // Finally delete the category and it's context.
 | 2251 |         // Finally delete the category and it's context.
 | 
          
            | 2256 |         $categoryrecord = $this->get_db_record();
 | 2252 |         $categoryrecord = $this->get_db_record();
 | 
          
            | 2257 |         $DB->delete_records('course_categories', array('id' => $this->id));
 | 2253 |         $DB->delete_records('course_categories', array('id' => $this->id));
 |