$entity->access_id = $access;
//get images from album and update access on image entities
- $images = get_entities("object","image", $guid, '', 999, '', false);
+ $images = elgg_get_entities(array(
+ "type" => "object",
+ "subtype" => "image",
+ "container_guid" => $guid,
+ "limit" => ELGG_ENTITIES_NO_VALUE,
+ ));
foreach ($images as $im) {
$im->access_id = $access;
$im->save();
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) {
*
* 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.
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;
}
* 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();
$batch = get_input('batch');
if ($batch) {
- $images = get_entities_from_metadata('batch', $batch, 'object', 'image', get_loggedin_userid(), 100);
+ $images = elgg_get_entities_from_metadata(array(
+ 'metadata_name' => 'batch',
+ 'metadata_value' => $batch,
+ 'type' => 'object',
+ 'subtype' => 'image',
+ 'owner_guid' => get_loggedin_userid(),
+ 'limit' => ELGG_ENTITIES_NO_VALUE,
+ ));
} else {
// parse out photo guids
$file_string = get_input('files');
$max = 12;
// grab the html to display the images
-$images = tp_list_entities("object", "image", $user_id, null, $max, false, false, true);
+$images = elgg_list_entities(array(
+ "type" => "object",
+ "subtype" => "image",
+ "owner_guid" => $user_id,
+ "limit" => $max,
+ "full_view" => false,
+));
// this view takes care of the title on the main column and the content wrapper
set_context('search');
set_input('search_viewtype', 'gallery');
if ($owner instanceof ElggGroup) {
- $content .= tp_list_entities("object", "album", 0, $owner->guid, 12, false);
+ $content .= elgg_list_entities(array(
+ "type" => "object",
+ "subtype" => "album",
+ "container_guid" => $owner->guid,
+ "limit" => 12,
+ "full_view" => false,
+));
} else {
- $content .= tp_list_entities("object", "album", $owner->guid, $owner->guid, 12, false);
+ $content .= elgg_list_entities(array(
+ "type" => "object",
+ "subtype" => "album",
+ "container_guid" => $owner->guid,
+ "limit" => 12,
+ "full_view" => false,
+));
}
$area2 = elgg_view('tidypics/content_wrapper', array('title' => $title, 'content' => $content,));
set_context('search');
set_input('search_viewtype', 'gallery');
-$content .= tp_list_entities('object','album', 0, null, $num_albums, false);
+$content .= elgg_list_entities(array(
+ 'type' => 'object',
+ 'subtype' => 'album',
+ 'limit' => $num_albums,
+ 'pagination' => false,
+));
set_context('photos');
$area2 = elgg_view('tidypics/content_wrapper', array('title' => $title, 'content' => $content,));
}
// Extend CSS
- extend_view('css', 'tidypics/css');
+ elgg_extend_view('css', 'tidypics/css');
// Extend hover-over and profile menu
- extend_view('profile/menu/links','tidypics/hover_menu');
+ elgg_extend_view('profile/menu/links','tidypics/hover_menu');
//group view ** psuedo widget view for group pages**
- extend_view('groups/right_column','tidypics/groupprofile_albums');
+ elgg_extend_view('groups/right_column','tidypics/groupprofile_albums');
// rss extensions
- extend_view('extensions/xmlns', 'extensions/tidypics/xmlns');
- extend_view('extensions/channel', 'extensions/tidypics/channel');
+ elgg_extend_view('extensions/xmlns', 'extensions/tidypics/xmlns');
+ elgg_extend_view('extensions/channel', 'extensions/tidypics/channel');
// Register a page handler, so we can have nice URLs
register_page_handler('photos','tidypics_page_handler');
// slideshow plugin hook
register_plugin_hook('tp_slideshow', 'album', 'tidypics_slideshow');
- // ajax handler for uploads when use_only_cookies is set
- register_plugin_hook('forward', 'system', 'tidypics_ajax_session_handler');
+ // ajax handler for uploads when use_only_cookies is set
+ register_plugin_hook('forward', 'system', 'tidypics_ajax_session_handler');
}
/**
$slideshow_link = "javascript:PicLensLite.start({maxScale:0,feedUrl:location.href+'?view=rss'})";
// add the slideshow javascript to the header
- extend_view('metatags', 'tidypics/js/slideshow');
+ elgg_extend_view('metatags', 'tidypics/js/slideshow');
return $slideshow_link;
}
$DB_QUERY_CACHE = $DB_PROFILE = $ENTITY_CACHE = array();
$album = get_entity($guid_obj->guid);
- $images = get_entities("object", "image", $album->guid, '', 9999);
+ $images = elgg_get_entities(array(
+ "type" => "object",
+ "subtype" => "image",
+ "container_guid" => $album->guid,
+ "limit" => ELGG_ENTITIES_NO_VALUE,
+ ));
$image_list = array();
foreach ($images as $image) {
$image_list[] = $image->guid;
$string .= "<div class=\"river_content\">";
- $images = get_entities("object", "image", $album->guid, 'time_created desc', 7);
+ $images = elgg_get_entities(array(
+ "type" => "object",
+ "subtype" => "image",
+ "container_guid" => $album->guid,
+ "limit" => 7,
+ ));
if (count($images)) {
foreach($images as $image) {
}
$owner = page_owner_entity();
-$owner_albums = get_entities("object", "album", page_owner(), "", $number, 0, false);
+$owner_albums = elgg_get_entities(array(
+ "type" => "object",
+ "subtype" => "album",
+ "container_guid" => page_owner(),
+ "limit" => $number,
+));
echo '<div id="tidypics_album_widget_container">';
<?php
-extend_view('metatags', 'tidypics/js/uploader');
+elgg_extend_view('metatags', 'tidypics/js/uploader');
$album = $vars['album'];
$form_body .= elgg_echo( 'flickr:usernamesetup') . " <input style='width: 20%;' type='text' name='flickr_username' value='$flickr_username->value' ' class='input-text' /> <br />";
$form_body .= "<input type='hidden' name='return_url' value='$_SERVER[REQUEST_URI]' />";
-$albums = get_entities( "object", "album", $user->guid );
+$albums = elgg_get_entities(array(
+ "type=" => "object",
+ "subtype" => "album",
+ "owner_guid" => $user->guid,
+));
$options = array( 0 => elgg_echo( 'flickr:selectalbum' ));
foreach( $albums as $album ) {
$title = $album->title;
}
- $images = get_entities("object", "image", 0, "", 0, 0, false, 0, $album->guid);
+ $images = elgg_get_entities(array(
+ "type" => "object",
+ "subtype" => "image",
+ "container_guid" => $album->guid,
+ ));
foreach ($images as $image) {