add function remove_follower in follow.php
[code]
function remove_follower($fid = 0) {
global $client;
if (!$user = valid_user($fid) ) {
die('wrong uid');
}
$res = sql_query("select * from ".tb()."followers where uid='$fid' and fid='{$client['id']}' limit 1");
if (sql_counts($res)) {
sql_query("delete from ".tb()."followers where uid='$fid' and fid='{$client['id']}'");
sql_query("update ".tb()."accounts set followers=followers-1 where id='{$client['id']}'");
}
redirect(url('follow/myfollowers'),1);
}
[/code]
some modification in function my followers
[code]
function myfollowers() {
global $client, $apps, $uhome,$ubase, $offset, $num_per_page, $page;
nav(t('My Followers'));
c('
<ul class="small_avatars">');
$res = sql_query("select u.id,u.username,u.avatar from ".tb()."followers as f left join ".tb()."accounts as u on u.id=f.uid where f.fid='{$client['id']}' order by u.lastlogin DESC limit $offset, $num_per_page");
$output = '';
while ($row = sql_fetch_array($res)) {
$f = 1;
c('<li><span>'.url('u/'.$row['username'],$row['username']).'</span><br />
'.avatar($row).'<br />
'.url('follow/remove_follower/'.$row['id'],t('Remove')).'</li>');
}
c('</ul>');
// pager
$res = sql_query("select count(*) as total from ".tb()."followers where fid='{$client['id']}' ".dbhold() );
$row = sql_fetch_array($res);
$total = $row['total'];
$pb = new PageBar($total, $num_per_page, $page);
$pb->paras = $ubase.'follow/myfollowers';
$pagebar = $pb->whole_num_bar();
$output .= $pagebar;
c($output);
if (!$total) {
c('<p>'.t('You have no follower.').'</p>');
}
section_close(t('My Followers'));
}
[/code] |