/** * Method used to update a canned email response 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; } $stmt = "UPDATE\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "email_response\n SET\n ere_title='" . Misc::escapeString($HTTP_POST_VARS["title"]) . "',\n ere_response_body='" . Misc::escapeString($HTTP_POST_VARS["response_body"]) . "'\n WHERE\n ere_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 projects, then add them all again Email_Response::removeProjectAssociations($HTTP_POST_VARS['id']); foreach ($HTTP_POST_VARS['projects'] as $prj_id) { Email_Response::addProjectAssociation($HTTP_POST_VARS['id'], $prj_id); } return 1; } }