public function setArticleRank() { $article_id = intval($this->request->postVar('id')); $old_rank = intval($this->request->postVar('old_rank')); $new_rank = intval($this->request->postVar('new_rank')); $type = $this->request->postVar('type'); $target = $this->request->postVar('target'); $is_new = $this->request->postVar('is_new'); if ($is_new == 1) { // new item coming in, add and reorder $this->news_manager->moveNewsArticle($article_id, $new_rank, $target); $this->news_manager->sortNewsArticles($article_id, $new_rank, $old_rank, true, false, $target); } elseif ($type == $target) { //sorting within section, reorder $this->news_manager->sortNewsArticles($article_id, $new_rank, $old_rank, false, false, $type); $this->news_manager->moveNewsArticle($article_id, $new_rank, $target); } else { //item removed, reorder $this->news_manager->sortNewsArticles($article_id, $new_rank, $old_rank, false, true, $type); } }