还是项目管理模块的大问题!

lsf001 2016-02-16 13:16:43
 /**
     * Get project list.
     * 
     * @param  string  $status 
     * @access public
     * @return array
     */
    public function getList($status = null, $pager = null)
    {
        $projects = $this->dao->select('*')->from(TABLE_PROJECT)
            ->where('deleted')->eq(0)
            ->beginIF($status and $status != 'involved')->andWhere('status')->eq($status)->fi()
            ->beginIF($status and $status == 'involved')->andWhere('status')->eq('doing')->fi()
            ->page($pager)
            ->fetchAll('id');

        $members = $this->dao->select('*')->from(TABLE_TEAM)->where('type')->eq('project')->fetchGroup('id', 'account');

        foreach($projects as $project)
        {
            $project->members = isset($members[$project->id]) ? $members[$project->id] : array();

            foreach($project->members as $member) if($member->role == 'manager') $project->PM = $member->account;

            if($status == 'involved' and !isset($project->members[$this->app->user->account])) unset($projects[$project->id]);
            if(!$this->checkPriv($project->id)) unset($projects[$project->id]);
        }
        return $projects;

    }

这段代码有问题,主要出在   ->page($pager)上,当每页显示10行时,

   $projects = $this->dao->select('*')->from(TABLE_PROJECT)
            ->where('deleted')->eq(0)
            ->beginIF($status and $status != 'involved')->andWhere('status')->eq($status)->fi()
            ->beginIF($status and $status == 'involved')->andWhere('status')->eq('doing')->fi()
            ->page($pager)
            ->fetchAll('id');

projects 只会返回10个记录,比如系统一共有36个项目,当前用户建立了其中的2个,当10个记录循环时,如果当前用户建立的2个记录不在这10个记录里,   if(!$this->checkPriv($project->id)) unset($projects[$project->id]); 这个就把 10个记录都unset了,当前用户 显示空白,实际上该用户是有记录的。


回帖列表
chujilu 2016-02-16 13:48:40
我记录一下,谢谢反馈
1/ 1
鲁ICP备18054969号
ZSITE8.6