wwwroot . "/mod/competencies/competencies.xml"; $all_standards = array(); $all_competencies = array(); $doc = new DOMDocument("1.0", "UTF-8"); $doc->load($filename); $standards = $doc->getElementsByTagName("competencystandard"); foreach ($standards as $standard) { $ids = $standard->getElementsByTagName("id"); $id = $ids->item(0)->nodeValue; $titles = $standard->getElementsByTagName("title"); $title = $titles->item(0)->nodeValue; $all_standards[] = $id; $all_competencies[$id] = $title; // get standard competencies $competencies = $standard->getElementsByTagName("competency"); foreach($competencies as $competency) { $cids = $competency->getElementsByTagName("id"); $cid = $cids->item(0)->nodeValue; $ctitles = $competency->getElementsByTagName("title"); $ctitle = $ctitles->item(0)->nodeValue; $all_competencies[$cid] = $ctitle; } } return array($all_standards, $all_competencies); } function get_competency($id) { $all = get_competencies(); return $all[1][$id]; } function competencies_save($event, $object_type, $object) { if ($object instanceof ElggEntity) { $marker = get_input("competencies_marker"); if ($marker == "on") { $competencies = get_input('competencies'); if (empty($competencies)) $competencies = array(); $object->competencies = $competencies; } } } register_elgg_event_handler('init','system','competencies_init'); register_elgg_event_handler('create', 'all', 'competencies_save'); register_elgg_event_handler('update', 'all', 'competencies_save'); ?>