Checks if course module has any conditions that may make it unavailable for
all or some of the students

This function is internal and is only used to create CSS classes for the module name/text

@param cm_info $mod
@return bool
966041
protected function is_cm_conditionally_hidden(cm_info $mod) {
        global $CFG;
        $conditionalhidden = false;
        if (!empty($CFG->enableavailability)) {
            $info = new \core_availability\info_module($mod);
            $conditionalhidden = !$info->is_available_for_all();
        }
        return $conditionalhidden;
    }
138675
protected function can_add_activity() {
        global $CFG;
        if (!($modname = $this->get_activitytype())) {
            return false;
        }
        if (!has_capability('moodle/course:manageactivities', context_course::instance($this->courseid))) {
            return false;
        }
        if (!course_allowed_module($this->get_course(), $modname)) {
            return false;
        }
        $libfile = "$CFG->dirroot/mod/$modname/lib.php";
        if (!file_exists($libfile)) {
            return null;
        }
        return true;
    }
221108
protected function can_post($course, $forum, $discussion, $post, $cm, $context) {
        if (!isset($this->canpostto[$discussion->id])) {
            $this->canpostto[$discussion->id] = forum_user_can_post($forum, $discussion, $this->recipient, $cm, $course, $context);
        }
        return $this->canpostto[$discussion->id];
    }
783172
public static function remove_competency_from_course_module($cmorid, $competencyid) {
        static::require_enabled();
        $cm = $cmorid;
        if (!is_object($cmorid)) {
            $cm = get_coursemodule_from_id('', $cmorid, 0, true, MUST_EXIST);
        }
        // Check the user have access to the course module.
        self::validate_course_module($cm);

        // First we do a permissions check.
        $context = context_module::instance($cm->id);

        require_capability('moodle/competency:coursecompetencymanage', $context);

        $record = new stdClass();
        $record->cmid = $cm->id;
        $record->competencyid = $competencyid;

        $competency = new competency($competencyid);
        $exists = course_module_competency::get_record(array('cmid' => $cm->id, 'competencyid' => $competencyid));
        if ($exists) {
            return $exists->delete();
        }
        return false;
    }
743245
protected function section_summary($section, $course, $mods) {
        $classattr = 'section main section-summary clearfix';
        $linkclasses = '';

        // If section is hidden then display grey section link
        if (!$section->visible) {
            $classattr .= ' hidden';
            $linkclasses .= ' dimmed_text';
        } else if (course_get_format($course)->is_section_current($section)) {
            $classattr .= ' current';
        }

        $title = get_section_name($course, $section);
        $o = '';
        $o .= html_writer::start_tag('li', array('id' => 'section-'.$section->section,
            'class' => $classattr, 'role'=>'region', 'aria-label'=> $title));

        $o .= html_writer::tag('div', '', array('class' => 'left side'));
        $o .= html_writer::tag('div', '', array('class' => 'right side'));
        $o .= html_writer::start_tag('div', array('class' => 'content'));

        if ($section->uservisible) {
            $title = html_writer::tag('a', $title,
                    array('href' => course_get_url($course, $section->section), 'class' => $linkclasses));
        }
        $o .= $this->output->heading($title, 3, 'section-title');

        $o .= $this->section_availability($section);
        $o.= html_writer::start_tag('div', array('class' => 'summarytext'));

        if ($section->uservisible || $section->visible) {
            // Show summary if section is available or has availability restriction information.
            // Do not show summary if section is hidden but we still display it because of course setting
            // "Hidden sections are shown in collapsed form".
            $o .= $this->format_summary_text($section);
        }
        $o.= html_writer::end_tag('div');
        $o.= $this->section_activity_summary($section, $course, null);

        $o .= html_writer::end_tag('div');
        $o .= html_writer::end_tag('li');

        return $o;
    }
808318
public function on_course_modules_end() {

        foreach ($this->converter->get_stash('modnameslist') as $modname) {
            $modinfo = $this->converter->get_stash('modinfo_'.$modname);
            foreach ($modinfo['instances'] as $modinstanceid => $modinstance) {
                $cminfo    = $this->converter->get_stash('cminfo_'.$modname, $modinstanceid);
                $directory = 'activities/'.$modname.'_'.$cminfo['id'];

                // write module.xml
                $this->open_xml_writer($directory.'/module.xml');
                $this->write_xml('module', $cminfo, array('/module/id', '/module/version'));
                $this->close_xml_writer();

                // write grades.xml
                $this->open_xml_writer($directory.'/grades.xml');
                $this->xmlwriter->begin_tag('activity_gradebook');
                $gradeitems = $this->converter->get_stash_or_default('gradebook_modgradeitem_'.$modname, $modinstanceid, array());
                if (!empty($gradeitems)) {
                    $this->xmlwriter->begin_tag('grade_items');
                    foreach ($gradeitems as $gradeitem) {
                        $this->write_xml('grade_item', $gradeitem, array('/grade_item/id'));
                    }
                    $this->xmlwriter->end_tag('grade_items');
                }
                $this->write_xml('grade_letters', array()); // no grade_letters in module context in Moodle 1.9
                $this->xmlwriter->end_tag('activity_gradebook');
                $this->close_xml_writer();

                // todo: write proper roles.xml, for now we just make sure the file is present
                $this->make_sure_xml_exists($directory.'/roles.xml', 'roles');
            }
        }
    }
38598
public function checkLimitation ($module, $method)
	{
		
		// If no methods are defined or all is denied
		
		if (!$this->actionLimit || !Parser::_ak ($this->actionLimit, 'all', TRUE))
		{
			
			// Deny all
			
			return FALSE;
			
		}
		
		// If all methods are enabled
		
		if (Parser::_ak ($this->actionLimit, 'all', FALSE))
		{
			
			// Allow all
			
			return TRUE;
			
		}
		
		// If the module method is allowed
		
		if (Parser::_ak ($this->actionLimit, array ($module, $method), FALSE))
		{
			
			// Allow
			
			return TRUE;
			
		}
		
		// If the module is allowed
		
		if (Parser::_ak ($this->actionLimit, $module, FALSE) === TRUE)
		{
			
			// Allow
			
			return TRUE;
			
		}
		
		// Deny
		
		return FALSE;
		
	}
979064
public function hasAllRequiredModules()
    {
        $required = $this->getRequiredModules();
        $available = array_keys($this->module->getList());
        $difference = array_diff($required, array_intersect($required, $available));

        return empty($difference);
    }
908877
public function is_editable() {
        if ($this->is_locked()) {
            return false;
        }

        $grade_item = $this->load_grade_item();

        if ($grade_item->gradetype == GRADE_TYPE_NONE) {
            return false;
        }

        if ($grade_item->is_course_item() or $grade_item->is_category_item()) {
            return (bool)get_config('moodle', 'grade_overridecat');
        }

        return true;
    }
1373267
public function hasModule($name)
	{
	    $name = $this->parseModuleAlias($name);
	    
	    return isset($this->_modules) && in_array($name, $this->_modules);
	}
1363451
public function isDefaultModule($module=null)
	{
	    $mname = '';
	    if (!$module) {
	        $mname = $this->getCurrentModule()->getName();
	    } else {
	        if (is_string($module)) {
	            $mname = $module;
	        } elseif ($module instanceof Module) {
	            $mname = $module->getName();
	        }
	    }
	    
	    return $mname == $this->getDefaultModule()->getName();
	}
521565
private function isEnabled($module)
    {
        if (!array_key_exists($module, $this->enabled)) {
            throw new \InvalidArgumentException("Module '$module' cannot be enabled or disabled. Only [".implode(', ', array_keys($this->enabled)).'] can.');
        }

        return $this->enabled[$module];
    }
813233
public function hasModule($module)
    {
        foreach ($this->data as $index => $row) {
            if ($row[ConstProviderInterface::CONFIG_PARAM_MODULE] == $module) {
                return true;
            }
        }

        return false;
    }
120669
protected function isEnabledModule($module_id)
    {
        $sql = 'SELECT module_id FROM module WHERE module_id=? AND status > 0';
        $result = $this->db->fetchColumn($sql, array($module_id));
        return !empty($result);
    }
783829
public function course_section_cm_text(cm_info $mod, $displayoptions = array()) {
        $output = '';
        if (!$mod->is_visible_on_course_page()) {
            // nothing to be displayed to the user
            return $output;
        }
        $content = $mod->get_formatted_content(array('overflowdiv' => true, 'noclean' => true));
        list($linkclasses, $textclasses) = $this->course_section_cm_classes($mod);
        if ($mod->url && $mod->uservisible) {
            if ($content) {
                // If specified, display extra content after link.
                $output = html_writer::tag('div', $content, array('class' =>
                        trim('contentafterlink ' . $textclasses)));
            }
        } else {
            $groupinglabel = $mod->get_grouping_label($textclasses);

            // No link, so display only content.
            $output = html_writer::tag('div', $content . $groupinglabel,
                    array('class' => 'contentwithoutlink ' . $textclasses));
        }
        return $output;
    }
38477
public static function registerModulesClass(string $class): bool
    {
        if (class_exists($class) === false) {
            return false;
        }
        $check = new ReflectionClass($class);
        if ($check->implementsInterface("TheCMSThread\\Classes\\Modules") === true) {
            self::$modules_class = $class;
            return true;
        } else {
            return false;
        }
    }
1115451
protected function hasMelisCmsModule()
    {
        $modulesSvc = $this->getServiceLocator()->get('MelisAssetManagerModulesService');
        $modules = $modulesSvc->getAllModules();
        $path = $modulesSvc->getModulePath('MelisCms');
        $isExists = 0;

        if (file_exists($path)) {
            $isExists = 1;
        }

        return $isExists;
    }