Try to use elgg_list_entities with these 'wheres' clauses:
'wheres' => function(QueryBuilder $qb, $alias) {
$qb->joinMetadataTable($alias, 'guid', 'status', 'left', 'ma');
return $qb->merge([
$qb->compare('ma.name', '=', 'status', ELGG_VALUE_STRING),
$qb->compare('ma.value', '=', 'active', ELGG_VALUE_STRING),
]);
},
what is $qb and $alias?
And that kind of attitude is why open source projects die. People get afraid to ask questions or suggest input. Thanks for your help though.
And that kind of attitude is why open source projects die.
All I am saying is that people like free buffet. All the solution just served to them on plates. A little curiosity is good. It help you learn new things (and sometimes also contribute to the open source projects, which will definitely keep the project alive). If you would have tried to understand what the piece of code does you could have easily found the solution on your own.
Anyways, It was not to offend you. I am sorry if it was in-appropriate in any way.
Imho Rohit Gupta has provided actual help with actual code. This is what helps a forum as well as open source run. While this will be out of topic : open source projects' deaths have got nothing to do ( or more or less nothing to do) with "attitudes" in general. During the past 10 years or so there has been no significant new open source project in php. No new open source web scripting language as successful as php too. Just think projects like Elgg, Wordpress, Drupal will never happen again. The world is now sheepishly slave to the trio Google-Apple-Facebook. Many entities now have only fb/ address in billboards and elsewhere and not www address. Apps are killing the open and interconnected net, and for Apps you have to be "slave" to Google or Apple ( and MS). Why Apps are something not like http html php websites - where you host your own either on free or paid servers or even your own server ?? No one complains, no lawsuits !!
Opensource generation is a dying generation thus. Despite several ongoing projects, its not that the flourishing majority when Tim Lee "invented" www and Rasmus Lerdorf "created" Php. Its sad. Many "opensource" projects got sold to biggies. And many opensource projects made their own commercial firms like Wordpress and Drupal. Opensource and money earning has no conflict with each other as such ( without money you cannot survive) but the spirit ... I dont know. There will be no more "whiz kids" like Matt (Wordpress), Dries (Drupal) or for that matter Ben Werdmuller who started Elgg but has shifted to other priorities now ( I think so). Many opensource projects actually died as the young ones who started these needed money for survival ( or needed to be "more rich") and commercialization of open source was not that much success for most of them. So they had to devote more and more time to jobs ( or in some cases their own companies or in the companies which "purchased" them). Elgg 2x has many and many more plugins( and thus more adoption) than Elgg 3x will ever have because of the same reason. The number of interested and talented youth who could have contributed are now in look out for actual jobs and money or are absorbed passively in the Apps world or rather than trying out php are chatting on Fb. The existing opensource projects do have some flaws which do not let them flourish, that is another issue.
Short answer: "no". The "jpg" extension is hard-coded and the Elgg core code is written to create jpg files.
Longer (incomplete) answer. "maybe". The creation of the icon files is not done completely within saveIconFromUploadedFile() but there is a cascade of functions that are involved (the functions are split to be able to deal with different parts of the work separately to be able to reuse them depending on the requirements in different situations). The function saveIconFromUploadedFile() calls the functions saveIcon() and within this function the plugin hook "entity:<type>:save", "<entity_type>" is triggered (for example for creation of icons for entities of type object it would be "entity:icon:save", "object"). This seems the only point in the process where you could interrupt Elgg with dealing with the icon creation when registering a callback function for this plugin hook. But then you would have to implement your own code that creates the icon file within this callback function. Additionally, there might be other issues arise then if the icon files are saved as png and not jpg when Elgg tries to output the files expecting it to be jpg files and therefore might serving them with the wrong mimetype which could cause trouble with displaying the images in the browsers (I think Chrome is very sensible with regards to filetype/mimetype).
Short answer: yes.
Maybe a bit more details... For example Tidypics has a page that lists photos in order of most recent comments. The code (in mod/tidypics/views/default/resources/tidypics/lists/recentlycommented.php) used to get the entities in the corresponding order is
$db_prefix = elgg_get_config('dbprefix');
$options = array(
'type' => 'object',
'subtype' => 'image',
'limit' => $limit,
'offset' => $offset,
'joins' => array(
"JOIN {$db_prefix}entities ce ON ce.container_guid = e.guid",
"JOIN {$db_prefix}entity_subtypes cs ON ce.subtype = cs.id AND cs.subtype = 'comment'"),
'order_by' => "ce.time_created DESC",
'full_view' => false,
'list_type' => 'gallery',
'gallery_class' => 'tidypics-gallery'
);
$result = elgg_list_entities($options);
Of course, you would have to modify it a bit for other type of entities and implement it within a view that outputs it. For further reference you could take a look at the code of the Tidypics plugin.
Ismayil this was so close and way easier then what I was trying to do! The only issue is its show the oldest post not the newest post. Any ideas?
Maybe some finetuning is necessary, e.g. additionally to 'group_by' also
'order_by' => 'e.time_created DESC',
Just try with appending either ASC or DESC to the `group_by` and `order_by ' options values to see how it changes the order.
Im trying to use this example I found :
SELECT max(id) as id,
asker
FROM questions
GROUP by asker
ORDER by id DESC
Implemented in Elgg like the following:
$content = elgg_list_entities(array( 'type' => 'object', 'subtype' => 'file', 'selects' => array("max(e.time_created) AS createdtime"), 'order_by' => 'createdtime ASC', 'group_by' => 'e.owner_guid', ));
But this doesn't seem to work still. Any ideas?
Images taken on mobile devices save the image orientation in their exif metadata. If the program used to view the images doesn't make use of the exif data, the images are displayed in their original orientation. Most browsers (all browsers?) don't make an image orientation correction.
Tidypics does correct the orientation on image upload. For image files uploaded with the File plugin you can try out the Image Orientation plugin (https://elgg.org/plugins/1873029; maybe better try the latest release from https://github.com/arckinteractive/image_orientation).
(If I'm not mistaken, the future Elgg 3 will come with image orientation correction already in core.)
It might work with
offset = (int)get_input('offset', 0);
$limit = (int)get_input('limit', 16);
$db_prefix = elgg_get_config('dbprefix');
$meta_status_id = elgg_get_metastring_id('status');
$entities = elgg_list_entities(array(
'type' => 'object',
'subtype' => 'image',
'limit' => $limit,
'offset' => $offset,
'joins' => array(
"JOIN {$db_prefix}users_entity ue ON ue.guid = e.owner_guid",
"JOIN {$db_prefix}metadata md4 ON (md4.owner_guid = e.owner_guid AND md4.name_id = $meta_status_id)",
"JOIN {$db_prefix}metastrings ms4 ON md4.value_id = ms4.id"
),
'wheres' => array(
"ms4.string = 'active'"
),
'group_by' => 'e.guid',
'order_by' => "views DESC",
'full_view' => false,
'list_type' => 'gallery',
'gallery_class' => 'tidypics-gallery'
));
I can't tell if this code is fully correct though (can't test your setup with the status metadata).
I received this error
An exception occurred while executing 'SELECT COUNT(DISTINCT e.guid) as total FROM elgg_entities e JOIN elgg_users_entity ue ON ue.guid = e.owner_guid JOIN elgg_metadata md4 ON (md4.owner_guid = e.owner_guid AND md4.name_id = 283801) JOIN elgg_metastrings ms4 ON md4.value_id = ms4.id WHERE ms4.string = 'active' AND ((e.type = 'object' AND e.subtype IN (11))) AND (e.site_guid IN (1)) AND ((1 = 1) AND (e.enabled = 'yes'))':
SQLSTATE[HY000]: General error: 2013 Lost connection to MySQL server during query
QUERY: SELECT COUNT(DISTINCT e.guid) as total FROM elgg_entities e JOIN elgg_users_entity ue ON ue.guid = e.owner_guid JOIN elgg_metadata md4 ON (md4.owner_guid = e.owner_guid AND md4.name_id = 283801) JOIN elgg_metastrings ms4 ON md4.value_id = ms4.id WHERE ms4.string = 'active' AND ((e.type = 'object' AND e.subtype IN (11))) AND (e.site_guid IN (1)) AND ((1 = 1) AND (e.enabled = 'yes'))
Difficult to say what might be wrong. "Lost connection to MySQL server during query" could mean a timeout issue or a out-of-memory issue of the MySQL server during the query. This might be because the query I suggested is wrong (as I said I can't test it because I don't have the necessary data you require, i.e. the status metadata). Or it might be that the query is correct as such but so complex that your server can't handle it due the limits set in the MySQL server config (timeouts, memory, cache sizes etc.). Maybe the query could get modified to require less server resources. But I can't say how because that's beyond my MySQL knowledge. Or it might be necessary to adjust the MySQL server config to be able to handle this query. But server config support is a complex matter on its own and I have to say it's beyond the support I can provide here.
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.