aboutsummaryrefslogtreecommitdiffstats
path: root/include/widgets.php
diff options
context:
space:
mode:
authorHabeas Codice <habeascodice@federated.social>2014-11-26 11:02:30 -0800
committerHabeas Codice <habeascodice@federated.social>2014-11-26 11:02:30 -0800
commitd3ffdbf2a4e25636cb2762f35c69fcc1abbcf7d5 (patch)
tree0dd876ff9767998ec13c73cab2ff02f5cbce371a /include/widgets.php
parent1a57f3ed517e7dd68bd6c7a23802ebee138c128f (diff)
parent3bb0ef8a82ec660ff8ef37b9abc93da94234649a (diff)
downloadvolse-hubzilla-d3ffdbf2a4e25636cb2762f35c69fcc1abbcf7d5.tar.gz
volse-hubzilla-d3ffdbf2a4e25636cb2762f35c69fcc1abbcf7d5.tar.bz2
volse-hubzilla-d3ffdbf2a4e25636cb2762f35c69fcc1abbcf7d5.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'include/widgets.php')
-rw-r--r--include/widgets.php57
1 files changed, 51 insertions, 6 deletions
diff --git a/include/widgets.php b/include/widgets.php
index 076a8fa91..f7b8a20bd 100644
--- a/include/widgets.php
+++ b/include/widgets.php
@@ -659,9 +659,11 @@ function widget_bookmarkedchats($arr) {
$r = q("select * from xchat where xchat_xchan = '%s' group by xchat_url order by xchat_desc",
dbesc($h)
);
-
- for($x = 0; $x < count($r); $x ++)
- $r[$x]['xchat_url'] = zid($r[$x]['xchat_url']);
+ if($r) {
+ for($x = 0; $x < count($r); $x ++) {
+ $r[$x]['xchat_url'] = zid($r[$x]['xchat_url']);
+ }
+ }
return replace_macros(get_markup_template('bookmarkedchats.tpl'),array(
'$header' => t('Bookmarked Chatrooms'),
'$rooms' => $r
@@ -677,9 +679,11 @@ function widget_suggestedchats($arr) {
if(! $h)
return;
$r = q("select *, count(xchat_url) as total from xchat group by xchat_url order by total desc, xchat_desc limit 24");
-
- for($x = 0; $x < count($r); $x ++)
- $r[$x]['xchat_url'] = zid($r[$x]['xchat_url']);
+ if($r) {
+ for($x = 0; $x < count($r); $x ++) {
+ $r[$x]['xchat_url'] = zid($r[$x]['xchat_url']);
+ }
+ }
return replace_macros(get_markup_template('bookmarkedchats.tpl'),array(
'$header' => t('Suggested Chatrooms'),
'$rooms' => $r
@@ -874,3 +878,44 @@ function widget_photo_rand($arr) {
return $o;
}
+
+
+function widget_random_block($arr) {
+
+ $channel_id = 0;
+ if(array_key_exists('channel_id',$arr) && intval($arr['channel_id']))
+ $channel_id = intval($arr['channel_id']);
+ if(! $channel_id)
+ $channel_id = get_app()->profile_uid;
+ if(! $channel_id)
+ return '';
+
+ if(array_key_exists('contains',$arr))
+ $contains = $arr['contains'];
+
+ $o = '';
+
+ require_once('include/security.php');
+ $sql_options = item_permissions_sql($channel_id);
+
+ $randfunc = db_getfunc('RAND');
+
+ $r = q("select item.* from item left join item_id on item.id = item_id.iid
+ where item.uid = %d and sid like '%s' and service = 'BUILDBLOCK' and
+ item_restrict = %d $sql_options order by $randfunc limit 1",
+ intval($channel_id),
+ dbesc('%' . $contains . '%'),
+ intval(ITEM_BUILDBLOCK)
+ );
+
+ if($r) {
+ $o = '<div class="widget bblock">';
+ if($r[0]['title'])
+ $o .= '<h3>' . $r[0]['title'] . '</h3>';
+ $o .= prepare_text($r[0]['body'],$r[0]['mimetype']);
+ $o .= '</div>';
+
+ }
+ return $o;
+
+} \ No newline at end of file