public function getDates($type = '', $subtype = '', $container_guid = 0, $order_by = 'time_created')
{
$where = array();
if ($type != "") {
$type = sanitise_string($type);
$where[] = "type='{$type}'";
}
if (is_array($subtype)) {
$tempwhere = "";
if (sizeof($subtype)) {
foreach ($subtype as $typekey => $subtypearray) {
foreach ($subtypearray as $subtypeval) {
$typekey = sanitise_string($typekey);
if (!empty($subtypeval)) {
if (!($subtypeval = (int) get_subtype_id($typekey, $subtypeval))) {
return false;
}
} else {
$subtypeval = 0;
}
if (!empty($tempwhere)) {
$tempwhere .= " or ";
}
$tempwhere .= "(type = '{$typekey}' and subtype = {$subtypeval})";
}
}
}
if (!empty($tempwhere)) {
$where[] = "({$tempwhere})";
}
} else {
if ($subtype) {
if (!($subtype_id = get_subtype_id($type, $subtype))) {
return false;
} else {
$where[] = "subtype={$subtype_id}";
}
}
}
if ($container_guid !== 0) {
if (is_array($container_guid)) {
foreach ($container_guid as $key => $val) {
$container_guid[$key] = (int) $val;
}
$where[] = "container_guid in (" . implode(",", $container_guid) . ")";
} else {
$container_guid = (int) $container_guid;
$where[] = "container_guid = {$container_guid}";
}
}
$where[] = _elgg_get_access_where_sql(array('table_alias' => ''));
$sql = "SELECT DISTINCT EXTRACT(YEAR_MONTH FROM FROM_UNIXTIME(time_created)) AS yearmonth\n\t\t\tFROM {$this->db->prefix}entities where ";
foreach ($where as $w) {
$sql .= " {$w} and ";
}
$sql .= "1=1 ORDER BY {$order_by}";
if ($result = $this->db->getData($sql)) {
$endresult = array();
foreach ($result as $res) {
$endresult[] = $res->yearmonth;
}
return $endresult;
}
return false;
}