<?php
/**
* @author moufer<moufer@163.com>
* @copyright www.modoer.com
*/
!defined('IN_MUDDER') && exit('Access Denied');
class moFriendModel {

    function moFriendModel() {
    }

    function getTotal($uid) {
        $totalnum = uc_friend_totalnum($uid, 0);
        return $totalnum;
    }

    function & read($uid, $limit) {
        if(is_numeric($limit) && $limit>0) {
            $start = 0;
            $offset = $limit;
        } elseif(is_array($limit)&&count($limit)==2) {
            $start = $limit[0];
            $offset = $limit[1];
        } else {
            $start = 0;
            $offset = 10;
        }
        $result = uc_friend_ls($uid, $start, $offset, 10, 0);
        if(empty($result)) {
            $result = array();
        } else {
            $result = array();
            foreach($result as $key => $val) {
                $result[$key]['fid'] = $val['friendid'];
                $result[$key]['fuid'] = $val['friendid'];
                $result[$key]['fusername'] = $val['username'];
                $result[$key]['face'] = UC_API.'/avatar.php?uid='.$val['friendid'].'&size=small';
                $result[$key]['point'] = 0;
            }
        }
        return $result;
    }

    function add(& $post) {
    }

    function delete($uids) {
    }
}
?>