diff options
Diffstat (limited to 'include/widgets.php')
-rw-r--r-- | include/widgets.php | 178 |
1 files changed, 163 insertions, 15 deletions
diff --git a/include/widgets.php b/include/widgets.php index 032b1c67e..5e40bf54a 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -29,7 +29,7 @@ function widget_tagcloud($args) { $type = TERM_CATEGORY; // FIXME there exists no $authors variable - $r = tagadelic($uid, $count, $authors, $flags, ITEM_WEBPAGE, $type); + $r = tagadelic($uid, $count, $authors, $owner, $flags, ITEM_TYPE_WEBPAGE, $type); if($r) { $o = '<div class="tagblock widget"><h3>' . t('Categories') . '</h3><div class="tags" align="center">'; @@ -155,9 +155,8 @@ function widget_follow($args) { $a = get_app(); $uid =$a->channel['channel_id']; - $r = q("select count(*) as total from abook where abook_channel = %d and not (abook_flags & %d)>0 ", - intval($uid), - intval(ABOOK_FLAG_SELF) + $r = q("select count(*) as total from abook where abook_channel = %d and abook_self = 0 ", + intval($uid) ); if($r) $total_channels = $r[0]['total']; @@ -394,7 +393,7 @@ function widget_tagcloud_wall($arr) { $limit = ((array_key_exists('limit', $arr)) ? intval($arr['limit']) : 50); if(feature_enabled($a->profile['profile_uid'], 'tagadelic')) - return wtagblock($a->profile['profile_uid'], $limit, $a->profile['channel_hash'], ITEM_WALL); + return wtagblock($a->profile['profile_uid'], $limit, '', $a->profile['channel_hash'], 'wall'); return ''; } @@ -409,8 +408,7 @@ function widget_catcloud_wall($arr) { $limit = ((array_key_exists('limit',$arr)) ? intval($arr['limit']) : 50); - return catblock($a->profile['profile_uid'], $limit, $a->profile['channel_hash'], ITEM_WALL); - + return catblock($a->profile['profile_uid'], $limit, '', $a->profile['channel_hash'], 'wall'); } @@ -475,9 +473,8 @@ function widget_settings_menu($arr) { $role = get_pconfig(local_channel(),'system','permissions_role'); - $abk = q("select abook_id from abook where abook_channel = %d and ( abook_flags & %d )>0 limit 1", - intval(local_channel()), - intval(ABOOK_FLAG_SELF) + $abk = q("select abook_id from abook where abook_channel = %d and abook_self = 1 limit 1", + intval(local_channel()) ); if($abk) $abook_self_id = $abk[0]['abook_id']; @@ -608,7 +605,7 @@ function widget_photo_albums($arr) { if(! $a->profile['profile_uid']) return ''; $channelx = channelx_by_n($a->profile['profile_uid']); - if((! $channelx) || (! perm_is_allowed($a->profile['profile_uid'], get_observer_hash(), 'view_photos'))) + if((! $channelx) || (! perm_is_allowed($a->profile['profile_uid'], get_observer_hash(), 'view_storage'))) return ''; require_once('include/photos.php'); @@ -706,7 +703,7 @@ function widget_item($arr) { require_once('include/security.php'); $sql_extra = item_permissions_sql($uid); - $r = q("select * from item where mid = '%s' and uid = %d and item_restrict = " . intval(ITEM_WEBPAGE) . " $sql_extra limit 1", + $r = q("select * from item where mid = '%s' and uid = %d and item_type = " . intval(ITEM_TYPE_WEBPAGE) . " $sql_extra limit 1", dbesc($arr['mid']), intval($uid) ); @@ -904,10 +901,10 @@ function widget_random_block($arr) { $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", + item_type = %d $sql_options order by $randfunc limit 1", intval($channel_id), dbesc('%' . $contains . '%'), - intval(ITEM_BUILDBLOCK) + intval(ITEM_TYPE_BLOCK) ); if($r) { @@ -983,8 +980,159 @@ function widget_rating($arr) { } // used by site ratings pages to provide a return link -function widget_pubsites() { +function widget_pubsites($arr) { if(get_app()->poi) return; return '<div class="widget"><ul class="nav nav-pills"><li><a href="pubsites">' . t('Public Hubs') . '</a></li></ul></div>'; } + + +function widget_forums($arr) { + + $a = get_app(); + + if(! local_channel()) + return ''; + + $o = ''; + + if(is_array($arr) && array_key_exists('limit',$arr)) + $limit = " limit " . intval($limit) . " "; + else + $limit = ''; + + $unseen = 0; + if(is_array($arr) && array_key_exists('unseen',$arr) && intval($arr['unseen'])) + $unseen = 1; + + $perms_sql = item_permissions_sql(local_channel()) . item_normal(); + + $r1 = q("select * from abook left join xchan on abook_xchan = xchan_hash where ( xchan_pubforum = 1 or ((abook_their_perms & %d ) != 0 and (abook_their_perms & %d ) = 0) ) and abook_channel = %d order by xchan_name $limit ", + intval(PERMS_W_TAGWALL), + intval(PERMS_W_STREAM), + intval(local_channel()) + ); + if(! $r1) + return $o; + + $str = ''; + + // Trying to cram all this into a single query with joins and the proper group by's is tough. + // There also should be a way to update this via ajax. + + for($x = 0; $x < count($r1); $x ++) { + $r = q("select sum(item_unseen) as unseen from item where owner_xchan = '%s' and uid = %d $perms_sql ", + dbesc($r1[$x]['xchan_hash']), + intval(local_channel()) + ); + if($r) + $r1[$x]['unseen'] = $r[0]['unseen']; + } + + if($r1) { + $o .= '<div class="widget">'; + $o .= '<h3>' . t('Forums') . '</h3><ul class="nav nav-pills nav-stacked">'; + + foreach($r1 as $rr) { + if($unseen && (! intval($rr['unseen']))) + continue; + $o .= '<li><span class="pull-right">' . ((intval($rr['unseen'])) ? intval($rr['unseen']) : '') . '</span><a href="network?f=&pf=1&cid=' . $rr['abook_id'] . '" ><img src="' . $rr['xchan_photo_s'] . '" style="width: 16px; height: 16px;" /> ' . $rr['xchan_name'] . '</a></li>'; + } + $o .= '</ul></div>'; + } + return $o; + +} + + +function widget_tasklist($arr) { + + + require_once('include/event.php'); + $o .= '<script>var tasksShowAll = 0; $(document).ready(function() { tasksFetch(); $("#tasklist-new-form").submit(function(event) { event.preventDefault(); $.post( "tasks/new", $("#tasklist-new-form").serialize(), function(data) { tasksFetch(); $("#tasklist-new-summary").val(""); } ); return false; } )});</script>'; + $o .= '<script>function taskComplete(id) { $.post("tasks/complete/"+id, function(data) { tasksFetch();}); } + function tasksFetch() { + $.get("tasks/fetch" + ((tasksShowAll) ? "/all" : ""), function(data) { + $(".tasklist-tasks").html(data.html); + }); + } + </script>'; + + $o .= '<div class="widget">' . '<h3>' . t('Tasks') . '</h3><div class="tasklist-tasks">'; + $o .= '</div><form id="tasklist-new-form" action="" ><input id="tasklist-new-summary" type="text" name="summary" value="" /></form>'; + $o .= '</div>'; + return $o; + +} + + +function widget_helpindex($arr) { + $o .= '<div class="widget">' . '<h3>' . t('Documentation') . '</h3>'; + $o .= '<ul class="nav nav-pills nav-stacked">'; + $o .= '<li><a href="help/general">' . t('Project/Site Information') . '</a></li>'; + $o .= '<li><a href="help/members">' . t('For Members') . '</a></li>'; + $o .= '<li><a href="help/admins">' . t('For Administrators') . '</a></li>'; + $o .= '<li><a href="help/develop">' . t('For Developers') . '</a></li>'; + $o .= '</ul></div>'; + return $o; + +} + + + +function widget_admin($arr) { + + /* + * Side bar links + */ + + if(! is_site_admin()) { + return login(false); + } + + + $a = get_app(); + $o = ''; + + // array( url, name, extra css classes ) + + $aside = array( + 'site' => array(z_root() . '/admin/site/', t('Site'), 'site'), + 'users' => array(z_root() . '/admin/users/', t('Accounts'), 'users'), + 'channels' => array(z_root() . '/admin/channels/', t('Channels'), 'channels'), + 'plugins' => array(z_root() . '/admin/plugins/', t('Plugins'), 'plugins'), + 'themes' => array(z_root() . '/admin/themes/', t('Themes'), 'themes'), + 'queue' => array(z_root() . '/admin/queue', t('Inspect queue'), 'queue'), + 'profs' => array(z_root() . '/admin/profs', t('Profile Config'), 'profs'), + 'dbsync' => array(z_root() . '/admin/dbsync/', t('DB updates'), 'dbsync') + + ); + + /* get plugins admin page */ + + $r = q("SELECT * FROM addon WHERE plugin_admin = 1"); + + $aside['plugins_admin'] = array(); + if($r) { + foreach ($r as $h){ + $plugin = $h['name']; + $aside['plugins_admin'][] = array(z_root() . '/admin/plugins/' . $plugin, $plugin, 'plugin'); + // temp plugins with admin + $a->plugins_admin[] = $plugin; + } + } + + $aside['logs'] = array(z_root() . '/admin/logs/', t('Logs'), 'logs'); + + $o .= replace_macros(get_markup_template('admin_aside.tpl'), array( + '$admin' => $aside, + '$admtxt' => t('Admin'), + '$plugadmtxt' => t('Plugin Features'), + '$logtxt' => t('Logs'), + '$h_pending' => t('User registrations waiting for confirmation'), + '$admurl'=> z_root() . '/admin/' + )); + + return $o; + +}
\ No newline at end of file |