コード例 #1
0
ファイル: class.faq.php プロジェクト: juliogallardo1326/proc
 /**
  * Method used to add a FAQ entry to the system.
  *
  * @access  public
  * @return  integer 1 if the insert worked, -1 otherwise
  */
 function insert()
 {
     global $HTTP_POST_VARS;
     if (Validation::isWhitespace($HTTP_POST_VARS["title"])) {
         return -2;
     }
     if (Validation::isWhitespace($HTTP_POST_VARS["message"])) {
         return -3;
     }
     $stmt = "INSERT INTO\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "faq\n                 (\n                    faq_prj_id,\n                    faq_usr_id,\n                    faq_created_date,\n                    faq_title,\n                    faq_message,\n                    faq_rank\n                 ) VALUES (\n                    " . $HTTP_POST_VARS['project'] . ",\n                    " . Auth::getUserID() . ",\n                    '" . Date_API::getCurrentDateGMT() . "',\n                    '" . Misc::escapeString($HTTP_POST_VARS["title"]) . "',\n                    '" . Misc::escapeString($HTTP_POST_VARS["message"]) . "',\n                    " . $HTTP_POST_VARS['rank'] . "\n                 )";
     $res = $GLOBALS["db_api"]->dbh->query($stmt);
     if (PEAR::isError($res)) {
         Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
         return -1;
     } else {
         $new_faq_id = $GLOBALS["db_api"]->get_last_insert_id();
         if (Customer::doesBackendUseSupportLevels(Misc::escapeInteger($HTTP_POST_VARS['project']))) {
             // now populate the faq-support level mapping table
             foreach ($HTTP_POST_VARS['support_levels'] as $support_level_id) {
                 FAQ::addSupportLevelAssociation($new_faq_id, $support_level_id);
             }
         }
         return 1;
     }
 }