public function displaycommentsAction() { $this->_helper->layout->disableLayout(); $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; $loginuserRole = $auth->getStorage()->read()->emprole; } $useridsArr = array(); $usernamesArr = array(); $usernames = array(); $userids = ''; $commentsModel = new Default_Model_Comments(); $id = $this->_request->getParam('detailid'); $flag = $this->_request->getParam('dispFlag'); $limitcount = $this->_request->getParam('limcount'); if ($limitcount == '2') { $commentsData = $commentsModel->getComments($id, '2'); } else { $commentsData = $commentsModel->getComments($id, '100'); } $actualcommentData = $commentsModel->getComments($id, 'all'); $j = 0; for ($i = 0; $i < sizeof($commentsData); $i++) { if (!in_array($commentsData[$i]['from_id'], $useridsArr)) { $useridsArr[$j] = $commentsData[$i]['from_id']; $j++; } } $userids = implode(',', $useridsArr); if ($userids != '' || $userids != ',') { $usernamesArr = $commentsModel->getuserNames($userids); } for ($i = 0; $i < sizeof($usernamesArr); $i++) { $usernames[$usernamesArr[$i]['id']] = $usernamesArr[$i]['userfullname']; } $this->view->actualcount = count($actualcommentData); $this->view->limitcount = $limitcount; $this->view->usernames = $usernames; $this->view->commentsData = $commentsData; $this->view->loginuserid = $loginUserId; }
/** * getCommentsFromDatabase * * gets the comments from database * * @param int $id_usr, current user * @param unixtime $time, time if checking for new comments * @return array */ private function getCommentsFromDatabase($id_usr = 0, $time = 0) { $commentModel = new Default_Model_Comments(); $comments = $commentModel->getComments($this->_type, $this->_id, $id_usr, $time); $comments = $time == 0 ? $this->getCommentChilds($comments) : $comments; if (count($comments) != 0) { $this->setLastUpdateTime(); } return $comments; }