/** * Returns a collection of MetaDataRelation objects based on the relations mask generated by the four parameters * <code> * $relations = MetaDataRelations::getRelations(1); * // returns relations for organisation_id 1 * * $relations = MetaDataRelations::getRelations(1, "student"); * // returns relations for members of the "student" group in organisation_id 1 * </code> * @param int $organisation * @param string $group * @param string $role * @param int $user Proxy ID * @return MetaDataRelations */ public static function getRelations($organisation = null, $group = null, $role = null, $user = null) { $cache = SimpleCache::getCache(); $relation_set = $cache->get("MetaTypeRelation", "{$organization}-{$group}-{$role}-{$user}"); if ($relation_set) { return $relation_set; } global $db; $conditions = generateMaskConditions($organisation, $group, $role, $user); $query = "SELECT * from `meta_type_relations`"; if ($conditions) { $query .= "\n WHERE " . $conditions; } $results = $db->getAll($query); $relations = array(); if ($results) { foreach ($results as $result) { $relation = MetaDataRelation::fromArray($result); $relations[] = $relation; } } $relation_set = new self($relations); $cache->set($relation_set, "MetaTypeRelation", "{$organization}-{$group}-{$role}-{$user}"); return $relation_set; }
/** * Returns a MetaDataRelation object belonging to the specified id, if one exists. * @param int $meta_data_relation_id * @return MetaDataRelation */ public function get($meta_data_relation_id) { $cache = SimpleCache::getCache(); $relation = $cache->get("MetaDataRelation", $meta_data_relation_id); if (!$relation) { global $db; $query = "SELECT * FROM `meta_data_relations` WHERE `meta_data_relation_id` = ?"; $result = $db->getRow($query, array($meta_data_relation_id)); if ($result) { $relation = self::fromArray($result); } } return $relation; }
/** * Returns the Organisation corresponding to the supplied ID * @param int $organisation_id * @return Organisation */ static function get($organisation_id) { $cache = SimpleCache::getCache(); $organisation = $cache->get("Organisation", $organisation_id); if (!$organisation) { global $db; $query = "SELECT * FROM `" . AUTH_DATABASE . "`.`organisations` WHERE `organisation_id` = " . $db->qstr($organisation_id); $result = $db->getRow($query); if ($result) { $organisation = new Organisation($result['organisation_id'], $result['organisation_title'], $result['organisation_address1'], $result['organisation_address2'], $result['organisation_city'], $result['organisation_province'], $result['organisation_country'], $result['organisation_postcode'], $result['organisation_telephone'], $result['organisation_fax'], $result['organisation_email'], $result['organisation_url'], $result['organisation_desc'], $result['aamc_institution_id'], $result['aamc_institution_name'], $result['aamc_program_id'], $result['aamc_program_name'], $result['organisation_active']); } } return $organisation; }
/** * Returns an Event specified by the provided ID * @param unknown_type $event_id * @return unknown */ public static function get($event_id) { $cache = SimpleCache::getCache(); $event = $cache->get("Event", $event_id); if (!$user) { global $db; $query = "SELECT * FROM `events` WHERE `id` = " . $db->qstr($event_id); $result = $db->getRow($query); if ($result) { $event = new Event($result['event_id'], $result['recurring_id'], $result['region_id'], $result['course_id'], $result['event_phase'], $result['event_title'], $result['event_description'], $result['event_goals'], $result['event_objectives'], $result['event_message'], $result['event_location'], $result['event_start'], $result['event_finish'], $result['event_duration'], $result['release_date'], $result['release_until'], $result['updated_date'], $result['updated_by']); } } return $user; }
/** * Removes this Value from the dabatase */ public function delete() { $cache = SimpleCache::getCache(); $cache->remove("MetaValue", $this->meta_value_id); global $db; $query = "DELETE FROM `meta_values` where `meta_value_id`=?"; if (!$db->Execute($query, array($this->meta_value_id))) { add_error("Failed to remove meta data from database."); application_log("error", "Unable to delete a meta_values record. Database said: " . $db->ErrorMsg()); } }
/** * Returns a NotificationUser specified by the provided ID * @param unknown_type $event_id * @return unknown */ public static function getByID($nuser_id) { $cache = SimpleCache::getCache(); $notification_user = $cache->get("NotificationUser", $nuser_id); if (!$notification_user) { global $db; $query = "SELECT * FROM `notification_users` WHERE `nuser_id` = " . $db->qstr($nuser_id); $result = $db->getRow($query); if ($result) { $notification_user = self::fromArray($result); } } return $notification_user; }
/** * Returns an Notification specified by the provided ID * @param int $notification_id * @return Notification */ public static function get($notification_id) { global $db; $cache = SimpleCache::getCache(); $notification = $cache->get("Notification", $notification_id); if (!$notification) { $query = "SELECT * FROM `notifications` WHERE `notification_id` = " . $db->qstr($notification_id); $result = $db->getRow($query); if ($result) { $notification = self::fromArray($result); } } return $notification; }
/** * Returns a MetaDataType corresponding to the provided ID * <code> * $type_id = 1234; * $type = MetaDataType::get($type_id); * </code> * @param int $meta_type_id * @return MetaDataType */ public static function get($meta_type_id) { $cache = SimpleCache::getCache(); $type = $cache->get("MetaDataType", $meta_type_id); if (!$type) { global $db; $query = "SELECT * FROM `meta_types` WHERE `meta_type_id` = ?"; $result = $db->getRow($query, array($meta_type_id)); if ($result) { $type = self::fromArray($result); } } return $type; }
/** * Returns the Course belonging to the specified ID * @param int $course_id * @return Course */ public static function get($course_id) { $cache = SimpleCache::getCache(); $course = $cache->get("Course", $course_id); if (!$course) { global $db; $query = "SELECT * FROM `courses` WHERE `course_id` = " . $db->qstr($course_id); $result = $db->getRow($query); if ($result) { $course = self::fromArray($result); } } return $course; }
/** * {@inheritDoc} * * @param string $key * * @return boolean **/ public function getCache($key) { return parent::getCache($this->getHierarchicalKey($key)); }