From ea8ea3c610582c8d564c5be38bc91b1987410a6b Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sun, 5 Jun 2011 12:14:47 +0000 Subject: merged in r580 and r581 into trunk --- lib/album.php | 7 +++- lib/migrate.php | 2 + lib/tidypics.php | 123 ++++--------------------------------------------------- 3 files changed, 16 insertions(+), 116 deletions(-) (limited to 'lib') diff --git a/lib/album.php b/lib/album.php index 0d5140875..e178acd5d 100644 --- a/lib/album.php +++ b/lib/album.php @@ -209,7 +209,12 @@ class TidypicsAlbum extends ElggObject { protected function deleteImages() { // get all the images from this album as long as less than 999 images - $images = get_entities("object", "image", $this->guid, '', 999); + $images = elgg_get_entities(array( + "type=" => "object", + "subtype" => "image", + "container_guid" => $this->guid, + "limit" => ELGG_ENTITIES_NO_VALUE, + )); if ($images) { foreach ($images as $image) { if ($image) { diff --git a/lib/migrate.php b/lib/migrate.php index f8e68a1be..8c62126f0 100644 --- a/lib/migrate.php +++ b/lib/migrate.php @@ -4,6 +4,8 @@ * * Supports moving photos from the files plugin to Tidypics. All of a users * photos end up in a single album. + * + * Not supported */ // need access to ElggDiskFilestore::make_file_matrix(), which is protected. diff --git a/lib/tidypics.php b/lib/tidypics.php index 67d69e0da..581503a51 100644 --- a/lib/tidypics.php +++ b/lib/tidypics.php @@ -34,7 +34,14 @@ function tp_get_latest_photos($num_images, $owner_guid = 0, $context = 'front') { $prev_context = get_context(); set_context($context); - $image_html = tp_list_entities('object', 'image', $owner_guid, null, $num_images, false, false, false); + $image_html = elgg_list_entities(array( + 'type' => 'object', + 'subtype' => 'image', + 'owner_guid' => $owner_guid, + 'limit' => $num_images, + 'full_view' => false, + 'pagination' => false, + )); set_context($prev_context); return $image_html; } @@ -59,120 +66,6 @@ function tp_get_img_dir() { * that could/should exist in the core */ -/** - * - */ -function tp_get_entities($type = "", $subtype = "", $owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = null, $timelower = 0, $timeupper = 0) { - global $CONFIG; - - if ($subtype === false || $subtype === null || $subtype === 0) - return false; - - if ($order_by == "") $order_by = "time_created desc"; - $order_by = sanitise_string($order_by); - $limit = (int)$limit; - $offset = (int)$offset; - $site_guid = (int) $site_guid; - $timelower = (int) $timelower; - $timeupper = (int) $timeupper; - if ($site_guid == 0) - $site_guid = $CONFIG->site_guid; - - $where = array(); - - 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 { - // @todo: Setting subtype to 0 when $subtype = '' returns entities with - // no subtype. This is different to the non-array behavior - // but may be required in some cases. - $subtypeval = 0; - } - if (!empty($tempwhere)) $tempwhere .= " or "; - $tempwhere .= "(type = '{$typekey}' and subtype = {$subtypeval})"; - } - } - if (!empty($tempwhere)) $where[] = "({$tempwhere})"; - - } else { - - $type = sanitise_string($type); - if ($subtype !== "" AND !$subtype = get_subtype_id($type, $subtype)) - return false; - - if ($type != "") - $where[] = "type='$type'"; - if ($subtype!=="") - $where[] = "subtype=$subtype"; - } - - if ($owner_guid != "") { - if (!is_array($owner_guid)) { - $owner_array = array($owner_guid); - $owner_guid = (int) $owner_guid; - $where[] = "owner_guid = '$owner_guid'"; - } else if (sizeof($owner_guid) > 0) { - $owner_array = array_map('sanitise_int', $owner_guid); - // Cast every element to the owner_guid array to int - $owner_guid = array_map("sanitise_int", $owner_guid); - $owner_guid = implode(",",$owner_guid); - $where[] = "owner_guid in ({$owner_guid})"; - } - } - if ($site_guid > 0) - $where[] = "site_guid = {$site_guid}"; - - if (!is_null($container_guid)) { - 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}"; - } - } - if ($timelower) - $where[] = "time_created >= {$timelower}"; - if ($timeupper) - $where[] = "time_created <= {$timeupper}"; - - if (!$count) { - $query = "SELECT * from {$CONFIG->dbprefix}entities where "; - } else { - $query = "SELECT count(guid) as total from {$CONFIG->dbprefix}entities where "; - } - foreach ($where as $w) - $query .= " $w and "; - $query .= get_access_sql_suffix(); // Add access controls - - if (!$count) { - $query .= " order by $order_by"; - if ($limit) $query .= " limit $offset, $limit"; // Add order and limit - $dt = get_data($query, "entity_row_to_elggstar"); - return $dt; - } else { - $total = get_data_row($query); - return $total->total; - } -} - -function tp_list_entities($type= "", $subtype = "", $owner_guid = 0, $container_guid = null, $limit = 10, $fullview = true, $viewtypetoggle = false, $pagination = true) { - - $offset = (int) get_input('offset'); - $count = tp_get_entities($type, $subtype, $owner_guid, "", $limit, $offset, true, 0, $container_guid); - - $entities = tp_get_entities($type, $subtype, $owner_guid, "", $limit, $offset, false, 0, $container_guid); - - return tp_view_entity_list($entities, $count, $offset, $limit, $fullview, $viewtypetoggle, $pagination); -} - function tp_view_entity_list($entities, $count, $offset, $limit, $fullview = true, $viewtypetoggle = false, $pagination = true) { $context = get_context(); -- cgit v1.2.3