attributes['subtype'] = 'dmperformancelevel'; $this->attributes['access_id'] = ACCESS_PUBLIC; } /** * Returns performance level items * @return mixed Array, false on errors */ public function getItems() { $options = array( 'types' => 'object', 'subtypes' => 'dmitem', 'limit' => 0, 'metadata_name_value_pairs' => array('name' => 'dmperformancelevel', 'value' => $this->guid) ); return elgg_get_entities_from_metadata($options); } /** * Returns random performance level item or false * * @return mixed */ public function getRandomItem() { $items = $this->getItems(); if (is_array($items)) { if (sizeof($items)>1) { $random = array_rand($items, 1); return $items[$random]; } else { return $items[0]; } } return false; } /** * Returns next level from the same subcompetency if possible * * @return mixed */ public function getNextPerformanceLevel() { $options = array( 'types' => 'object', 'subtypes' => 'dmperformancelevel', '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 previous level from the same subcompetency if possible * * @return mixed */ public function getPreviousPerformanceLevel() { $options = array( 'types' => 'object', 'subtypes' => 'dmperformancelevel', '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; } }