/** * Get a list of all the current user's tasks in JSON format * */ public function listAction() { if ($this->_getParam('_ajax')) { $this->renderRawView('task/list.php'); } else { $page = ifset($this->_getAllParams(), 'page', 1); $number = $this->_getParam('rp', za()->getConfig('project_list_size', 10)); $sort = $this->_getParam('sortname', 'due'); $order = $this->_getParam('sortorder', 'asc'); $items = $this->projectService->getUserTasks(za()->getUser(), array('complete=' => 0), 'task.' . $sort . ' ' . $order, $page, $number); $dummy = new Task(); $listFields = $dummy->listFields(); $asArr = array(); $aggrRow = array(); foreach ($items as $item) { $cell = array(); foreach ($listFields as $name => $display) { if (method_exists($item, $name)) { $cell[] = $item->{$name}(); } else { $cell[] = $item->{$name}; } } $row = array('id' => $item->id, 'cell' => $cell); $asArr[] = $row; } $obj = new stdClass(); $obj->page = ifset($this->_getAllParams(), 'page', 1); $obj->total = $items->getTotalResults(); $obj->rows = $asArr; $this->getResponse()->setHeader('Content-type', 'text/x-json'); $json = Zend_Json::encode($obj); echo $json; } }