Hey,
I am really trying to get a part of code to work on another page in the same script but I dont know what Im doing wrong…
The script is jcow, a social network script.
On the main page it shows all community activity (Posts, signups etc.) but once logged in, it only shows activity of people that are “friends” - So its blank until people start adding friends.
I want to have the page showing the same logged in as a guest / logged out.
I have included the code from both below…I have tried this so many times now so hoping someone can help!
The “newsfeed” function below is the one I want to replace:
<?php
class dashboard{
function dashboard() {
global $content, $db, $client, $settings, $tab_menu, $current_sub_menu, $menuon;
member_only();
$menuon = 'dashboard';
set_menu_path('dashboard');
}
function index() {
global $content, $db, $apps, $client, $settings, $config;
if ($client['id']) {
if ($slogan = get_gvar('site_slogan')) {
set_title($slogan);
}
else {
set_title(t('Home'));
}
if (allow_access(3)) {
ass(array(
'title'=>'Administration',
'content'=>'Go to <strong>'.url('admin',t('Administration Panel') ).'</strong>'));
}
block(
paid_roles()
);
block(
my_account()
);
block(
friends_birthday()
);
$lblocks[] = array('title' => t('Welcome!'),'content'=>'<table style="border-collapse: collapse; width: 100%;">
<tbody>
<tr>
<td><img border="0px" alt="North West Ireland Welcome" title="North West Ireland Welcome" src="themes/blue/welcome1.jpg" /></td>
<td>
<span style="font- weight: bold;">Welcome to North West Social, your local site for all things North West Ireland!</span><br>
We have a list of current events, a <a title="North West Ireland Forum" href="/forum/index.php">community forum</a> to chat with others from the NW, <a href="/index.php?p=Attractions" title="Things to do / Attractions in the North West Ireland">things to do</a> in the NW, a <a title="North West Ireland Restaurant / Takeaway Guide & Menus" href="/index.php? p=test/test1">restaurant and takeaway guide</a> and a social network to connect and
share with others in the NW community!<br>
Simply scroll down this page to view the status of your friends and update your status in the "Quick Share" box below!</td>
</tr>
</tbody>
</table>');
$lblocks[] = array('title' => t('Find new friends!'),'content'=>'<table style="border-collapse: collapse; width: 100%;">
<tbody>
<tr>
<td><img border="0px" alt="Find friends Derry Tyrone Donegal" title="Find friends Derry Tyrone Donegal" src="http://chakra-project.org/wiki/images/thumb/6/6f/User-group-new.png/64px-User-group-new.png" /></td>
<td>
<span style="font- weight: bold;">North West Social is a great place to meet new people, if you are from the North West or would like to meet other NW visitors and residents.
<br>
To find new friends, or friends you already know, simply <a href="/index.php?p=browse">click here to browse our members</a> and search by gender, age and location.
</tr>
</tbody>
</table>');
$lblocks[] = array('title' => t('Quick share'),'content'=>stream_form($client ['id']).'<div style="height:1px"></div>');
$lblocks[] = $this->newsfeed(10);
if (is_array($lblocks)) {
foreach ($lblocks as $lblock) {
section($lblock);
}
}
$hooks = check_hooks('dashboard');
if ($hooks) {
foreach ($hooks as $hook) {
$hook_func = $hook.'_dashboard';
$hook_func($sections,$parr);
}
}
}
}
private function newsfeed($num=5) {
global $client;
$uids[] = $client['id'];
$res = sql_query("select f.fid from ".tb()."friends as f left join ".tb()."accounts as u on u.id=f.fid where f.uid='{$client['id']}' order by u.lastlogin desc limit 5");
while ($row = sql_fetch_array($res)) {
$uids[] = $row['fid'];
}
$res = sql_query("select f.fid from ".tb()."followers as f left join ".tb()."accounts as u on u.id=f.fid where f.uid='{$client['id']}' order by u.lastlogin desc limit 5");
while ($row = sql_fetch_array($res)) {
$uids[] = $row['fid'];
}
if (is_array($uids)) {
$output .= activity_get($uids,$num,0,0,1);
}
else $output = t('No people');
return array('title'=>t('News feed'),'content'=>$output);
}
private function newsfeed1($num=5) {
$output = t('No people');
return array('title'=>t('News feed'),'content'=>$output);
}
}
function paid_roles() {
global $client;
$res = sql_query("select * from ".tb()."roles "." where id > 9 order by id");
if (!sql_counts($res)) {
return false;
}
else {
while ($role = sql_fetch_array($res)) {
$key_1m = 'pm_role'.$role['id'].'_1m';
$key_3m = 'pm_role'.$role['id'].'_3m';
$key_12m = 'pm_role'.$role['id'].'_12m';
$value_1m = get_gvar($key_1m) ? get_gvar($key_1m) : 0;
$value_3m = get_gvar($key_3m) ? get_gvar($key_3m) : 0;
$value_12m = get_gvar($key_12m) ? get_gvar($key_12m) : 0;
if ($value_1m || $value_3m || $value_12m) {
$paid_roles[] = $role;
}
}
if (!is_array($paid_roles)) return false;
$output = '<ul>';
foreach($paid_roles as $role) {
if (!is_array($client['roles']) || !in_array($role['id'],$client['roles'])) {
$role['link'] = url('purchase/member_roles/'.$role['id'],t('Subscribe'));
}
$output .= '<li>'.$role['name'].' '.$role['link'].'</li>';
}
$output .= '</ul>';
return array('title'=>t('Member roles'),'content'=>$output);
}
}
function my_account() {
global $client, $apps;
if (!$client['id']) return false;
$res = sql_query("select * from `".tb()."profiles` where id='{$client['id']}'");
$row = sql_fetch_array($res);
if ($client['avatar'] == 'undefined.jpg') {
$uf[] = url('account/avatar', t('Avatar picture'));
}
if (is_array($uf)) {
sys_notice(t("You haven't finished editing your profile").' : '.implode(', ',$uf));
}
$profile_views = $row['views'];
$res = sql_query("select count(*) as num from ".tb()."friends where uid='{$client['id']}'");
$row = sql_fetch_array($res);
$friends = $row['num'];
$res = sql_query("select count(*) as num from ".tb()."followers where fid='{$client['id']}'");
$row = sql_fetch_array($res);
$followers = $row['num'];
$content =
t('Your profile was viewed {1} times.','<strong>'.$profile_views.'</strong>').'
<div class="hr"></div>'.
t('You have {1} friends and {2} followers.','<strong>'.$friends.'</strong>','<strong>'.$followers.'</strong>');
$content .= '<div class="hr"></div>';
$content .= '
<table style="border-collapse: collapse; width: 100%;">
<tbody>
<tr>
<td><img border="0px" src="themes/blue/account.png" title="Comment" alt="Your Account" style="width: 35px; height: 35px;" /></td>
<td>
<li>'.url('u/'.$client['username'],t('My Profile')).'</li>
<li>'.url('follow/myfollowers',t('My Followers').'('.$followers.')' ).'</li>
<li>'.url('follow/imfollowing',t('My Following') ).'</li>
<li>'.url('preference',t('Preference')).'</li></span></td>
</tr>
</tbody>
</table>';
return array('title'=>t('Account'), 'content' => $content);
}
$blocks[] = array('title' => t('Upcoming Events'),'content'=>'<div>
<p><strong>Thur 3rd March 9pm </strong><br>
Masons Comedy Club
<br />
<strong>Fri 4th March 8pm </strong> <br />
Waterside Theatre - Glorious
<br />
<strong>Sat 6th March 8pm <br />
</strong>Millennium Forum<strong> - <a href="http://www.millenniumforum.co.uk/index.php?view=details&id=73%3Adominic-kirwan&option=com_eventlist&Itemid=8">DOMINIC KIRWAN</a></strong><br>
<strong>Mon 7th March 8pm </strong>
<br />
Cafe Del Mondo - Open Mic Night
<br />
<strong>Wed 9th March <br />
</strong>City Hotel - The Y Factor</p>
<p><a href="Http://www.northwestsocial.com/index.php?p=upcoming_events_derry">Full events here </a><br>
</div>
');
function friends_birthday() {
global $client;
$m = date('n');
$d = date('j');
$next = $m+1;
if ($m<10) $m = '0'.$m;
if ($next > 12) $next = '01';
if ($d > 20) {
$nextm = " or (f.uid='{$client['id']}' and birthmonth='$next' and birthday<$d) ";
}
$res = sql_query("select u.* from ".tb()."friends as f left join ".tb()."accounts as u on u.id=f.fid where (f.uid='{$client['id']}' and u.birthmonth='$m' and u.birthday>$d) $nextm order by u.lastlogin desc limit 15");
$content = '<ul>';
while ($user = sql_fetch_array($res)) {
$total++;
if ($user['birthmonth'] < 10) $user['birthmonth'] = '0'.$user['birthmonth'];
if ($user['birthday'] < 10) $user['birthday'] = '0'.$user['birthday'];
$content .= '<li>'.url('u/'.$user['username'],$user['username']).' - <strong>'.$user ['birthmonth'].'/'.$user ['birthday'].'</strong></li>';
}
$content .= '</ul>';
if (!$total) $content = 'none';
return array('title'=>t('Friends birthday coming up'), 'content' => $content);
}
Below Im trying to use the “community activities / recent activities”
<div class="block">
<div class="block_title">'.t('Community activities').'</div>
<div class="block_content">
<script type="text/javascript" src="'.uhome().'/js/jquery.vtricker.js"></script>
<script>
jQuery(document).ready(function($) {
$("#recent_activites").fadeIn();
$(\\'#recent_activites\\').vTicker({
speed: 800,
pause: 5000,
showItems: 4,
animation: \\'fade\\',
mousePause: false,
height: 350,
direction: \\'down\\'
});
});
</script>
<style>
#recent_activites li{
margin:0;
padding:0;
}
</style>
<div id="recent_activites" style="display:none">
<ul>
Hopefully someone can help, Im sure this is really simple for someone that actually knows PHP
Thanks for any help!