/** * Method used to add a new anonymous based issue in the system. * * @return integer The new issue ID */ public static function addAnonymousReport() { $prj_id = (int) $_POST['project']; $options = Project::getAnonymousPostOptions($prj_id); $initial_status = Project::getInitialStatus($prj_id); $usr_id = (int) $options['reporter']; $params = array('iss_prj_id' => $prj_id, 'iss_prc_id' => $options['category'], 'iss_pre_id' => 0, 'iss_pri_id' => $options['priority'], 'iss_usr_id' => $usr_id, 'iss_created_date' => Date_Helper::getCurrentDateGMT(), 'iss_last_public_action_date' => Date_Helper::getCurrentDateGMT(), 'iss_last_public_action_type' => 'created', 'iss_summary' => $_POST['summary'], 'iss_description' => $_POST['description'], 'iss_root_message_id' => Mail_Helper::generateMessageID()); if ($initial_status) { $params['iss_sta_id'] = $initial_status; } $stmt = 'INSERT INTO {{%issue}} SET ' . DB_Helper::buildSet($params); try { DB_Helper::getInstance()->query($stmt, $params); } catch (DbException $e) { return -1; } $issue_id = DB_Helper::get_last_insert_id(); // log the creation of the issue History::add($issue_id, APP_SYSTEM_USER_ID, 'issue_opened_anon', 'Issue opened anonymously'); // process any files being uploaded // TODO: handle ajax uploads if (isset($_FILES['file'])) { $iaf_ids = Attachment::addFiles($_FILES['file']); if ($iaf_ids) { Attachment::attachFiles($issue_id, $usr_id, $iaf_ids, false, 'Files uploaded anonymously'); } } // need to process any custom fields ? if (@count($_POST['custom_fields']) > 0) { foreach ($_POST['custom_fields'] as $fld_id => $value) { Custom_Field::associateIssue($issue_id, $fld_id, $value); } } // now add the user/issue association $assign = array(); $users = @$options['users']; $actions = Notification::getDefaultActions($issue_id, false, 'anon_issue'); foreach ($users as $user) { Notification::subscribeUser(APP_SYSTEM_USER_ID, $issue_id, $user, $actions); self::addUserAssociation(APP_SYSTEM_USER_ID, $issue_id, $user); $assign[] = $user; } Workflow::handleNewIssue($prj_id, $issue_id, false, false); // also notify any users that want to receive emails anytime a new issue is created Notification::notifyNewIssue($prj_id, $issue_id); return $issue_id; }
* @copyright (c) Eventum Team * @license GNU General Public License, version 2 or later (GPL-2+) * * For the full copyright and license information, * please see the COPYING and AUTHORS files * that were distributed with this source code. */ require_once __DIR__ . '/../../init.php'; $tpl = new Template_Helper(); $tpl->setTemplate('manage/anonymous.tpl.html'); Auth::checkAuthentication(); @($prj_id = $_POST['prj_id'] ? $_POST['prj_id'] : $_GET['prj_id']); $role_id = Auth::getCurrentRole(); if ($role_id < User::ROLE_MANAGER) { Misc::setMessage(ev_gettext('Sorry, you are not allowed to access this page.'), Misc::MSG_ERROR); $tpl->displayTemplate(); exit; } if (@$_POST['cat'] == 'update') { $res = Project::updateAnonymousPost($prj_id); $tpl->assign('result', $res); Misc::mapMessages($res, array(1 => array(ev_gettext('Thank you, the information was updated successfully.'), Misc::MSG_INFO), -1 => array(ev_gettext('An error occurred while trying to update the information.'), Misc::MSG_ERROR))); } // load the form fields $tpl->assign('project', Project::getDetails($prj_id)); $tpl->assign('cats', Category::getAssocList($prj_id)); $tpl->assign('priorities', Priority::getList($prj_id)); $tpl->assign('users', Project::getUserAssocList($prj_id, 'active')); $tpl->assign('options', Project::getAnonymousPostOptions($prj_id)); $tpl->assign('prj_id', $prj_id); $tpl->displayTemplate();
$tpl->assign("new_issue_id", $res); } else { // need to show everything again $tpl->assign("error_msg", "1"); } } elseif (@$HTTP_GET_VARS["post_form"] == "yes") { // only list those projects that are allowing anonymous reporting of new issues $projects = Project::getAnonymousList(); if (empty($projects)) { $tpl->assign("no_projects", "1"); } else { if (!in_array($HTTP_GET_VARS["project"], array_keys($projects))) { $tpl->assign("no_projects", "1"); } else { // get list of custom fields for the selected project $options = Project::getAnonymousPostOptions($HTTP_GET_VARS["project"]); if (@$options["show_custom_fields"] == "yes") { $tpl->assign("custom_fields", Custom_Field::getListByProject($HTTP_GET_VARS["project"], 'anonymous_form')); } $tpl->assign("project_name", Project::getName($HTTP_GET_VARS["project"])); } } } else { // only list those projects that are allowing anonymous reporting of new issues $projects = Project::getAnonymousList(); if (empty($projects)) { $tpl->assign("no_projects", "1"); } else { if (count($projects) == 1) { $project_ids = array_keys($projects); Auth::redirect('post.php?post_form=yes&project=' . $project_ids[0]);
$tpl->assign('new_issue_id', $res); } else { // need to show everything again $tpl->assign('error_msg', '1'); } } elseif (@$_GET['post_form'] == 'yes') { // only list those projects that are allowing anonymous reporting of new issues $projects = Project::getAnonymousList(); if (empty($projects)) { $tpl->assign('no_projects', '1'); } else { if (!in_array($_GET['project'], array_keys($projects))) { $tpl->assign('no_projects', '1'); } else { // get list of custom fields for the selected project $options = Project::getAnonymousPostOptions($_GET['project']); if (@$options['show_custom_fields'] == 'yes') { $tpl->assign('custom_fields', Custom_Field::getListByProject($_GET['project'], 'anonymous_form')); } $tpl->assign('project_name', Project::getName($_GET['project'])); } } } else { // only list those projects that are allowing anonymous reporting of new issues $projects = Project::getAnonymousList(); if (empty($projects)) { $tpl->assign('no_projects', '1'); } else { if (count($projects) == 1) { $project_ids = array_keys($projects); Auth::redirect('post.php?post_form=yes&project=' . $project_ids[0]);
/** * Method used to add a new anonymous based issue in the system. * * @access public * @return integer The new issue ID */ function addAnonymousReport() { global $HTTP_POST_VARS, $HTTP_POST_FILES; $options = Project::getAnonymousPostOptions($HTTP_POST_VARS["project"]); $initial_status = Project::getInitialStatus($HTTP_POST_VARS["project"]); $stmt = "INSERT INTO\n " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue\n (\n iss_prj_id,\n iss_prc_id,\n iss_pre_id,\n iss_pri_id,\n iss_usr_id,"; if (!empty($initial_status)) { $stmt .= "iss_sta_id,"; } $stmt .= "\n iss_created_date,\n iss_last_public_action_date,\n iss_last_public_action_type,\n iss_summary,\n iss_description,\n iss_root_message_id\n ) VALUES (\n " . Misc::escapeInteger($HTTP_POST_VARS["project"]) . ",\n " . $options["category"] . ",\n 0,\n " . $options["priority"] . ",\n " . $options["reporter"] . ","; if (!empty($initial_status)) { $stmt .= "{$initial_status},"; } $stmt .= "\n '" . Date_API::getCurrentDateGMT() . "',\n '" . Date_API::getCurrentDateGMT() . "',\n 'created',\n '" . Misc::escapeString($HTTP_POST_VARS["summary"]) . "',\n '" . Misc::escapeString($HTTP_POST_VARS["description"]) . "',\n '" . Misc::escapeString(Mail_API::generateMessageID()) . "'\n )"; $res = $GLOBALS["db_api"]->dbh->query($stmt); if (PEAR::isError($res)) { Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); return $res; } else { $new_issue_id = $GLOBALS["db_api"]->get_last_insert_id(); // log the creation of the issue History::add($new_issue_id, APP_SYSTEM_USER_ID, History::getTypeID('issue_opened_anon'), 'Issue opened anonymously'); // now process any files being uploaded $found = 0; for ($i = 0; $i < count(@$HTTP_POST_FILES["file"]["name"]); $i++) { if (!@empty($HTTP_POST_FILES["file"]["name"][$i])) { $found = 1; break; } } if ($found) { $attachment_id = Attachment::add($new_issue_id, $options["reporter"], 'files uploaded anonymously'); for ($i = 0; $i < count(@$HTTP_POST_FILES["file"]["name"]); $i++) { $filename = @$HTTP_POST_FILES["file"]["name"][$i]; if (empty($filename)) { continue; } $blob = Misc::getFileContents($HTTP_POST_FILES["file"]["tmp_name"][$i]); if (!empty($blob)) { Attachment::addFile($attachment_id, $new_issue_id, $filename, $HTTP_POST_FILES["file"]["type"][$i], $blob); } } } // need to process any custom fields ? if (@count($HTTP_POST_VARS["custom_fields"]) > 0) { foreach ($HTTP_POST_VARS["custom_fields"] as $fld_id => $value) { Custom_Field::associateIssue($new_issue_id, $fld_id, $value); } } // now add the user/issue association $assign = array(); $users = @$options["users"]; $actions = Notification::getDefaultActions(); for ($i = 0; $i < count($users); $i++) { Notification::subscribeUser(APP_SYSTEM_USER_ID, $new_issue_id, $users[$i], $actions); Issue::addUserAssociation(APP_SYSTEM_USER_ID, $new_issue_id, $users[$i]); $assign[] = $users[$i]; } // also notify any users that want to receive emails anytime a new issue is created Notification::notifyNewIssue($HTTP_POST_VARS['project'], $new_issue_id); Workflow::handleNewIssue(Misc::escapeInteger($HTTP_POST_VARS["project"]), $new_issue_id, false, false); return $new_issue_id; } }