/**
  * Method used to quickly change the ranking of a reminder entry
  * from the administration screen.
  *
  * @access  public
  * @param   integer $pri_id The reminder entry ID
  * @param   string $rank_type Whether we should change the reminder ID down or up (options are 'asc' or 'desc')
  * @return  boolean
  */
 function changeRank($prj_id, $pri_id, $rank_type)
 {
     // check if the current rank is not already the first or last one
     $ranking = Priority::_getRanking($prj_id);
     $ranks = array_values($ranking);
     $ids = array_keys($ranking);
     $last = end($ids);
     $first = reset($ids);
     if ($rank_type == 'asc' && $pri_id == $first || $rank_type == 'desc' && $pri_id == $last) {
         return false;
     }
     if ($rank_type == 'asc') {
         $diff = -1;
     } else {
         $diff = 1;
     }
     $new_rank = $ranking[$pri_id] + $diff;
     if (in_array($new_rank, $ranks)) {
         // switch the rankings here...
         $index = array_search($new_rank, $ranks);
         $replaced_pri_id = $ids[$index];
         $stmt = "UPDATE\n                        " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_priority\n                     SET\n                        pri_rank=" . Misc::escapeInteger($ranking[$pri_id]) . "\n                     WHERE\n                        pri_prj_id=" . Misc::escapeInteger($prj_id) . " AND\n                        pri_id=" . Misc::escapeInteger($replaced_pri_id);
         $GLOBALS["db_api"]->dbh->query($stmt);
     }
     $stmt = "UPDATE\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "project_priority\n                 SET\n                    pri_rank=" . Misc::escapeInteger($new_rank) . "\n                 WHERE\n                    pri_prj_id=" . Misc::escapeInteger($prj_id) . " AND\n                    pri_id=" . Misc::escapeInteger($pri_id);
     $GLOBALS["db_api"]->dbh->query($stmt);
     return true;
 }