/** * Display a list of questions * * @apiMethod GET * @apiUri /answers/questions/list * @apiParameter { * "name": "limit", * "description": "Number of result to return.", * "required": false, * "default": 25 * } * @apiParameter { * "name": "start", * "description": "Number of where to start returning results.", * "required": false, * "default": 0 * } * @apiParameter { * "name": "search", * "description": "A word or phrase to search for.", * "required": false, * "default": "" * } * @apiParameter { * "name": "sort", * "description": "Field to sort results by.", * "required": false, * "default": "created", * "allowedValues": "created, title, alias, id, publish_up, publish_down, state" * } * @apiParameter { * "name": "sort_Dir", * "description": "Direction to sort results by.", * "required": false, * "default": "desc", * "allowedValues": "asc, desc" * } * @return void */ public function listTask() { $database = \App::get('db'); $model = new \Components\Answers\Tables\Question($database); $filters = array('limit' => Request::getInt('limit', 25), 'start' => Request::getInt('limitstart', 0), 'search' => Request::getVar('search', ''), 'filterby' => Request::getword('filterby', ''), 'sortby' => Request::getWord('sort', 'date'), 'sort_Dir' => strtoupper(Request::getWord('sortDir', 'DESC'))); $response = new stdClass(); $response->questions = array(); $response->total = $model->getCount($filters); if ($response->total) { $base = rtrim(Request::base(), '/'); foreach ($model->getResults($filters) as $i => $q) { $question = new \Components\Answers\Models\Question($q); $obj = new stdClass(); $obj->id = $question->get('id'); $obj->subject = $question->subject(); $obj->quesion = $question->content(); $obj->state = $question->get('state'); $obj->url = str_replace('/api', '', $base . '/' . ltrim(Route::url($question->link()), '/')); $obj->responses = $question->comments('count'); $response->questions[] = $obj; } } $response->success = true; $this->send($response); }
/** * Display the status of the current app * * @return void */ public function statusTask() { $this->view->setLayout('status'); if (!$this->_toolid) { $this->_toolid = Request::getInt('toolid', 0); } // Create a Tool object $obj = new \Components\Tools\Tables\Tool($this->database); // do we have an alias? if ($this->_toolid == 0) { if ($alias = Request::getVar('app', '')) { $this->_toolid = $obj->getToolId($alias); } } // Couldn't get ID, exit if (!$this->_toolid) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller)); return; } if (!$this->_error) { $this->_error = ''; } if (!$this->_msg) { $this->_msg = Request::getVar('msg', '', 'post'); } // check access rights if (!$this->_checkAccess($this->_toolid)) { App::abort(403, Lang::txt('COM_TOOLS_ALERTNOTAUTH')); return; } // get tool status $obj->getToolStatus($this->_toolid, $this->_option, $status, 'dev'); if (!$status) { App::abort(404, Lang::txt('COM_TOOLS_ERR_STATUS_CANNOT_FIND')); return; } // get tickets/wishes/questions if ($status['published']) { $status['questions'] = 'N/A'; if (Component::isEnabled('com_answers')) { require_once PATH_CORE . DS . 'components' . DS . 'com_answers' . DS . 'tables' . DS . 'question.php'; require_once PATH_CORE . DS . 'components' . DS . 'com_answers' . DS . 'tables' . DS . 'response.php'; require_once PATH_CORE . DS . 'components' . DS . 'com_answers' . DS . 'tables' . DS . 'log.php'; require_once PATH_CORE . DS . 'components' . DS . 'com_answers' . DS . 'tables' . DS . 'questionslog.php'; $aq = new \Components\Answers\Tables\Question($this->database); $status['questions'] = $aq->getCount(array('filterby' => 'all', 'sortby' => 'date', 'tag' => 'tool' . $status['toolname'])); } $status['wishes'] = 'N/A'; if (Component::isEnabled('com_wishlist')) { require_once PATH_CORE . DS . 'components' . DS . 'com_wishlist' . DS . 'models' . DS . 'wishlist.php'; require_once PATH_CORE . DS . 'components' . DS . 'com_wishlist' . DS . 'site' . DS . 'controllers' . DS . 'wishlists.php'; $objWishlist = new \Components\Wishlist\Tables\Wishlist($this->database); $objWish = new \Components\Wishlist\Tables\Wish($this->database); $listid = $objWishlist->get_wishlistID($status['resourceid'], 'resource'); if ($listid) { $controller = new \Components\Wishlist\Controllers\Wishlist(); $filters = $controller->getFilters(1); $wishes = $objWish->get_wishes($listid, $filters, 1, User::getRoot()); $status['wishes'] = count($wishes); } else { $status['wishes'] = 0; } } } $this->view->status = $status; $this->view->msg = isset($this->_msg) ? $this->_msg : ''; $this->view->config = $this->config; $this->view->admin = $this->config->get('access-admin-component'); // Set the page title $this->view->title = Lang::txt(strtoupper($this->_option)) . ': ' . Lang::txt(strtoupper($this->_option . '_' . $this->_task)); $this->view->title .= $status['toolname'] ? ' ' . Lang::txt('COM_TOOLS_FOR') . ' ' . $status['toolname'] : ''; Document::setTitle($this->view->title); if (Pathway::count() <= 0) { Pathway::append(Lang::txt(strtoupper($this->_option)), 'index.php?option=' . $this->_option); } Pathway::append(Lang::txt('COM_TOOLS_PIPELINE'), 'index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=pipeline'); Pathway::append(Lang::txt('COM_TOOLS_STATUS_FOR', $status['toolname']), 'index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=status&app=' . $status['toolname']); foreach ($this->getErrors() as $error) { $this->view->setError($error); } $this->view->display(); }