attributes['subtype'] = 'dmcompetency'; $this->attributes['access_id'] = ACCESS_PUBLIC; } /** * Get list of subcompetencies. * * @param int $limit Limit * @param int $offset Offset * @param bool $count Count */ public function getSubCompetencies($limit = 10, $offset = 0, $count = false) { $options = array( 'types' => 'object', 'subtypes' => 'dmsubcompetency', 'limit' => $limit, 'offset' => $offset, 'count' => $count, 'container_guid' => $this->getGUID(), 'order_by' => 'guid ASC' ); return elgg_get_entities($options); } /** * Returns next competency from the same model if possible * * @return mixed */ public function getNextCompetency() { $options = array( 'types' => 'object', 'subtypes' => 'dmcompetency', 'limit' => 1, 'container_guid' => $this->getContainerGUID(), 'metadata_name_value_pairs' => array('name' => 'level', 'value' => ((int)$this->level + 1)) ); $next = elgg_get_entities_from_metadata($options); if (is_array($next) && sizeof($next)) { return $next[0]; } return false; } /** * returns number of PerformanceLevel objects in competency * * @return int */ public function getPerformanceLevelCount() { $level_count = 0; $subcompetencies = $this->getSubCompetencies(0); if (is_array($subcompetencies) && count($subcompetencies) > 0) { foreach($subcompetencies as $subcompetency) { $level_count += (int)$subcompetency->getPerformanceLevels(0, 0, true); } } return $level_count; } }