]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
merged in r580 and r581 into trunk
authorCash Costello <cash.costello@gmail.com>
Sun, 5 Jun 2011 12:14:47 +0000 (12:14 +0000)
committerCash Costello <cash.costello@gmail.com>
Sun, 5 Jun 2011 12:14:47 +0000 (12:14 +0000)
15 files changed:
actions/edit.php
lib/album.php
lib/migrate.php
lib/tidypics.php
pages/edit_multiple.php
pages/lists/mostrecentimages.php
pages/ownedalbums.php
pages/world.php
start.php
upgrades/2010073101.php
views/default/river/object/album/create.php
views/default/tidypics/albums.php
views/default/tidypics/forms/ajax_upload.php
views/default/tidypics/forms/setupFlickr.php
views/rss/object/album.php

index cca66941a36ff19614b51e7d9855bce70619dc5f..df65448c8a22ff16bd6b72d457451aafd24cb9db 100644 (file)
@@ -36,7 +36,12 @@ if ($subtype == 'album' && $entity->access_id != $access) {
        $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();
index 0d514087578a716b9cbe114d46987272b41fa249..e178acd5df51f175fbe6c40d45a7ffd34bfac7e3 100644 (file)
@@ -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) {
index f8e68a1be22347d48ae218d1d826c1c3b55e1e47..8c62126f040442ebda6b60e55c29e051430ca294 100644 (file)
@@ -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.
index 67d69e0dacafca0f115cb0da283844f6cdd95fbe..581503a518813b4ee641523f98a8453d1f0064e0 100644 (file)
 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();
 
index 938ac203c9c4c248ee59d859260bda25bf5bbcc5..7c7b989cfc9ed6d9817417e9be8bb242b42e0063 100644 (file)
@@ -15,7 +15,14 @@ set_page_owner(get_loggedin_userid());
 
 $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');
index 722f1fc328d0c334ac10afcf24eada345f22fd43..0a2595c855179c65dc6e161ee347991914735d4b 100644 (file)
@@ -44,7 +44,13 @@ if ($slideshow_link) {
 $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
index 67583c65ca3f39f723ff91ffb960edc4fbfdf3c7..9483512c63cf4e1621d8d948453fd59b372f248f 100644 (file)
@@ -41,9 +41,21 @@ $area2 = elgg_view_title($title);
 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,));
index fe97a882dc3e88bedde5526b4256ca6399ddd53e..25a69da52a78c0a56d074627b4cde28f927b7c68 100644 (file)
@@ -18,7 +18,12 @@ $area2 = elgg_view_title($title);
 
 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,));
index 1401c2c2c62c52d63547c116ff4b165e4204880b..d7110dfd0fd408b8f7b86c8b8a82bdaff487b585 100644 (file)
--- a/start.php
+++ b/start.php
@@ -25,17 +25,17 @@ function tidypics_init() {
        }
 
        // 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');
@@ -69,8 +69,8 @@ function tidypics_init() {
        // 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');
 }
 
 /**
@@ -456,7 +456,7 @@ function tidypics_slideshow($hook, $entity_type, $returnvalue, $params) {
        $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;
 }
index 20fd33144e8b480974d2094f28f937777581d40b..587490500174c98729fdf1a61c5eaab49aaf83e5 100644 (file)
@@ -11,7 +11,12 @@ while ($guid_obj = mysql_fetch_object($album_guids)) {
        $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;
index 47d20f3ae2349969dd9929b8c799a3557c71cccf..4d797d8428ac373f0dbb15ee77f2fc38cb0cfa45 100644 (file)
@@ -28,7 +28,12 @@ if ($album_river_view == "cover") {
 
        $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) {
index 7e0cd2d6cb11d9bc1ce3412b7d082c5647b5431b..61daadba701a25e7a70efa9271ac82a54de0aff5 100644 (file)
@@ -7,7 +7,12 @@ if (!$number) {
 }
 
 $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">';
 
index c81c9173d2242f7babaab93ee91092b84b44939c..4a7a05c0c9145187224c1259adce26f05d949cbe 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-extend_view('metatags', 'tidypics/js/uploader');
+elgg_extend_view('metatags', 'tidypics/js/uploader');
 
 $album = $vars['album'];
 
index 54f0a37d1b699d950061a69c9bd6d4b44b622612..6c461176dd60e9054cb9c4bb0e3528e116e341b8 100644 (file)
@@ -11,7 +11,11 @@ $form_body = "<p>". elgg_echo( 'flickr:intro' ) . "</p><p>";
 $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;
index 8a8f97cc20b46a8a69a1bc92b8ec9f829b800041..a37fdd041085f4bb515196c7955c0246d462b4a3 100644 (file)
@@ -43,7 +43,11 @@ if (get_context() == "search" && get_input('search_viewtype') == "gallery") {
        }
 
 
-       $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) {