コード例 #1
0
ファイル: class.faq.php プロジェクト: juliogallardo1326/proc
 /**
  * Method used to update a FAQ entry in the system.
  *
  * @access  public
  * @return  integer 1 if the update worked, -1 otherwise
  */
 function update()
 {
     global $HTTP_POST_VARS;
     $HTTP_POST_VARS['id'] = Misc::escapeInteger($HTTP_POST_VARS['id']);
     if (Validation::isWhitespace($HTTP_POST_VARS["title"])) {
         return -2;
     }
     if (Validation::isWhitespace($HTTP_POST_VARS["message"])) {
         return -3;
     }
     $stmt = "UPDATE\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "faq\n                 SET\n                    faq_prj_id=" . $HTTP_POST_VARS['project'] . ",\n                    faq_updated_date='" . Date_API::getCurrentDateGMT() . "',\n                    faq_title='" . Misc::escapeString($HTTP_POST_VARS["title"]) . "',\n                    faq_message='" . Misc::escapeString($HTTP_POST_VARS["message"]) . "',\n                    faq_rank=" . $HTTP_POST_VARS['rank'] . "\n                 WHERE\n                    faq_id=" . $HTTP_POST_VARS["id"];
     $res = $GLOBALS["db_api"]->dbh->query($stmt);
     if (PEAR::isError($res)) {
         Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
         return -1;
     } else {
         // remove all of the associations with support levels, then add them all again
         FAQ::removeSupportLevelAssociations($HTTP_POST_VARS['id']);
         if (Customer::doesBackendUseSupportLevels($HTTP_POST_VARS['project'])) {
             foreach ($HTTP_POST_VARS['support_levels'] as $support_level_id) {
                 FAQ::addSupportLevelAssociation($HTTP_POST_VARS['id'], $support_level_id);
             }
         }
         return 1;
     }
 }