function unserialize_recursive($str = '') { if (!is_string($str)) { return $str; } else { $str = unserialize($str); return unserialize_recursive($str); } }
/** * Return all versions given a content ID; the most recent version can be found by sending (content_id, null, 1) */ public function get_all($content_id = 0, $version_datetime = null, $limit = null, $sq = '') { $ci =& get_instance(); // for use with the rdf_store if (!empty($content_id)) { $this->db->where('content_id', $content_id); } $this->db->order_by('version_num', 'desc'); if (!empty($version_datetime)) { $this->db->where('created <=', $version_datetime); } // Don't run $sq here because it might return an older version than the most recent if (!empty($limit)) { $this->db->limit($limit); } $query = $this->db->get($this->versions_table); $result = $query->result(); if (!empty($sq)) { for ($j = count($result) - 1; $j >= 0; $j--) { if (!self::filter_result_i($result[$j], $sq)) { unset($result[$j]); } } } foreach ($result as $key => $value) { $result[$key]->urn = $this->urn($result[$key]->version_id); $result[$key]->attribution = unserialize_recursive($result[$key]->attribution); $result[$key]->rdf = $ci->rdf_store->get_by_urn('urn:scalar:version:' . $result[$key]->version_id); } return $result; }