function support_data_update($group_id, $support_id, $priority, $support_status_id, $support_category_id, $assigned_to, $summary, $canned_response, $details)
{
    global $feedback;
    if (!$group_id || !$support_id || !$assigned_to || !$status_id || !$support_category_id || !$canned_response) {
        $feedback .= "ERROR: Missing required parameters to support_data_update<BR>";
        return false;
    }
    $count = count($support_id);
    if ($count > 0) {
        for ($i = 0; $i < $count; $i++) {
            //get this patch from the db
            $sql = "SELECT * FROM support WHERE support_id='{$support_id[$i]}'";
            $result = db_query($sql);
            $group_id = db_result($result, 0, 'group_id');
            if (!(db_numrows($result) > 0 && user_ismember($group_id, 'C2'))) {
                //verify permissions
                $feedback .= ' ERROR - permission denied ';
                return false;
            }
            // We should assume no update is needed until otherwise
            // verified (imagine all the possible unnecessary queries
            // for a 50 item bug list!) -- G
            $update = false;
            $sql = "UPDATE support SET ";
            /*
            	See which fields changed during the modification
            */
            $sql .= "support_status_id='";
            if (db_result($result, 0, 'support_status_id') != $status_id && $status_id != 100) {
                support_data_create_history('support_status_id', db_result($result, 0, 'support_status_id'), $support_id[$i]);
                $update = true;
                $sql .= $status_id;
            } else {
                $sql .= db_result($result, 0, 'support_status_id');
            }
            $sql .= "', support_category_id='";
            if (db_result($result, 0, 'support_category_id') != $support_category_id && $support_category_id != 100) {
                support_data_create_history('support_category_id', db_result($result, 0, 'support_category_id'), $support_id[$i]);
                $update = true;
                $sql .= $support_category_id;
            } else {
                $sql .= db_result($result, 0, 'support_category_id');
            }
            $sql .= "', priority='";
            if (db_result($result, 0, 'priority') != $priority && $priority != 100) {
                support_data_create_history('priority', db_result($result, 0, 'priority'), $support_id[$i]);
                $update = true;
                $sql .= $priority;
            } else {
                $sql .= db_result($result, 0, 'priority');
            }
            $sql .= "', assigned_to='";
            if (db_result($result, 0, 'assigned_to') != $assigned_to && $assigned_to != 100) {
                support_data_create_history('assigned_to', db_result($result, 0, 'assigned_to'), $support_id[$i]);
                $update = true;
                $sql .= $assigned_to;
            } else {
                $sql .= db_result($result, 0, 'assigned_to');
            }
            $sql .= "'";
            if (db_result($result, 0, 'summary') != stripslashes(htmlspecialchars($summary)) && $summary != '') {
                support_data_create_history('summary', htmlspecialchars(addslashes(db_result($result, 0, 'summary'))), $support_id[$i]);
                $update = true;
                $sql .= ", summary='" . htmlspecialchars($summary) . "'";
            }
            /*
            	Enter the timestamp if we are changing to closed
            */
            if ($support_status_id != "1") {
                $now = time();
                $sql .= ", close_date='{$now}'";
                support_data_create_history('close_date', db_result($result, 0, 'close_date'), $support_id[$i]);
            }
            /*
            	Finally, update the patch itself
            */
            if ($update) {
                $sql .= " WHERE support_id='{$support_id[$i]}'";
                $result = db_query($sql);
                if (!$result) {
                    $feedback .= 'Error - update failed!<BR>';
                    return false;
                } else {
                    $feedback .= " Successfully Modified Support Ticket {$support_id[$i]}<BR>\n";
                }
                /*
                	see if we're supposed to send all modifications to an address
                */
                $project = project_get_object($group_id);
                if ($project->sendAllPatchUpdates()) {
                    $address = $project->getNewPatchAddress();
                }
                /*
                	now send the email
                	it's no longer optional due to the group-level notification address
                */
                /*
                	handle canned responses
                */
                if ($canned_response != 100) {
                    //don't care if this response is for this group - could be hacked
                    $sql = "SELECT * FROM support_canned_responses WHERE support_canned_id='{$canned_response}'";
                    $result2 = db_query($sql);
                    if ($result2 && db_numrows($result2) > 0) {
                        support_data_create_message(util_unconvert_htmlspecialchars(db_result($result2, 0, 'body')), $support_id[$i], user_getname() . '@' . $GLOBALS['sys_users_host']);
                        $feedback .= ' Canned Response Used<BR> ';
                    } else {
                        $feedback .= ' Unable to Use Canned Response ';
                    }
                }
                mail_followup($support_id[$i], $address);
                /*
                Details field is handled a little differently
                
                Details are comments attached to bugs
                They are still stored in the bug_history (audit 
                trail) system, but they are not shown in the
                 regular audit trail
                
                Someday, these should technically be split into
                 their own table.
                */
                if ($details != '') {
                    //create the first message for this ticket
                    support_data_create_message($details, $support_id, user_getname() . '@' . $GLOBALS['sys_users_host']);
                    $feedback .= " Comment added to support request {$support_id[$i]}<BR>";
                }
            } else {
                $feedback .= "Support ticket {$support_id[$i]} was not modified<BR>\n";
            }
        }
    }
    return true;
}
Exemplo n.º 2
0
function patch_data_handle_update($project, $patch_id, $upload_new, $uploaded_data, $code, $patch_status_id, $patch_category_id, $assigned_to, $summary, $details)
{
    global $feedback;
    $group_id = $project->getGroupID();
    $sql = "SELECT * FROM patch WHERE patch_id='{$patch_id}' AND group_id='{$group_id}'";
    $result = db_query($sql);
    if (db_numrows($result) < 1 || !$project->userIsPatchAdmin()) {
        $feedback .= ' ERROR - permission denied ';
        return false;
    }
    //user is uploading a new version of the patch
    if ($upload_new) {
        $code = addslashes(fread(fopen($uploaded_data, 'r'), filesize($uploaded_data)));
        if (strlen($code) > 20 && strlen($code) < 512000) {
            $codesql = ", code='" . htmlspecialchars($code) . "' ";
            patch_history_create('Patch Code', 'Modified - New Version', $patch_id);
        } else {
            $feedback .= ' Patch not changed - patch must be > 20 chars and < 512000 chars in length ';
            return false;
        }
    } else {
        $codesql = '';
    }
    db_begin();
    /*
    	See which fields changed during the modification
    */
    if (db_result($result, 0, 'patch_status_id') != $patch_status_id) {
        patch_history_create('patch_status_id', db_result($result, 0, 'patch_status_id'), $patch_id);
    }
    if (db_result($result, 0, 'patch_category_id') != $patch_category_id) {
        patch_history_create('patch_category_id', db_result($result, 0, 'patch_category_id'), $patch_id);
    }
    if (db_result($result, 0, 'assigned_to') != $assigned_to) {
        patch_history_create('assigned_to', db_result($result, 0, 'assigned_to'), $patch_id);
    }
    if (db_result($result, 0, 'summary') != stripslashes(htmlspecialchars($summary))) {
        patch_history_create('summary', htmlspecialchars(addslashes(db_result($result, 0, 'summary'))), $patch_id);
    }
    /*
    		Details field is handled a little differently
    	Details are comments attached to patches
    		They are still stored in the patch_history (audit trail)
    		system, but they are not shown in the regular audit trail
    	Someday, these should technically be split into their own table.
    */
    if ($details != '') {
        patch_history_create('details', htmlspecialchars($details), $patch_id);
    }
    /*
    	Enter the timestamp if we are changing to closed
    */
    if ($patch_status_id != "1" && $patch_status_id != "100") {
        $now = time();
        $close_date = ", close_date='{$now}' ";
        patch_history_create('close_date', db_result($result, 0, 'close_date'), $patch_id);
    } else {
        $close_date = '';
    }
    /*
    	Finally, update the patch itself
    */
    $sql = "UPDATE patch SET patch_status_id='{$patch_status_id}'{$close_date} {$codesql}, patch_category_id='{$patch_category_id}', " . "assigned_to='{$assigned_to}', summary='" . htmlspecialchars($summary) . "' " . "WHERE patch_id='{$patch_id}'";
    $result = db_query($sql);
    if (!$result) {
        $feedback .= ' ERROR - update failed! ' . db_error();
        db_rollback();
        return false;
    } else {
        $feedback .= " Successfully Modified Patch ";
    }
    if ($project->sendAllPatchUpdates()) {
        $address = $project->getNewPatchAddress();
    }
    /*
    	now send the email
    	it's no longer optional due to the group-level notification address
    */
    mail_followup($patch_id, $address);
    db_commit();
    return true;
}
Exemplo n.º 3
0
function feature_data_update($project, $feature_id, $priority, $feature_status_id, $feature_category_id, $assigned_to, $summary, $canned_response, $details)
{
    global $feedback;
    $group_id = $project->getGroupID();
    if (!is_Array($feature_id)) {
        $feature_id = array($feature_id);
    }
    if (!$group_id || !$feature_id || !$assigned_to || !$feature_status_id || !$feature_category_id || !$canned_response) {
        $feedback .= " ERROR: Missing required parameters to feature_data_update ";
        return false;
    }
    $count = count($feature_id);
    if ($count > 0) {
        for ($i = 0; $i < $count; $i++) {
            //get this feature from the db
            $sql = "SELECT * FROM feature WHERE feature_id='{$feature_id[$i]}' AND group_id='{$group_id}'";
            $result = db_query($sql);
            $group_id = db_result($result, 0, 'group_id');
            if (db_numrows($result) < 1 || !$project->userIsFeatureAdmin()) {
                //verify permissions
                $feedback .= 'ERROR - permission denied';
                return false;
            }
            // We should assume no update is needed until otherwise
            // verified (imagine all the possible unnecessary queries
            // for a 50 item bug list!) -- G
            $update = false;
            $sql = "UPDATE feature SET ";
            db_begin();
            /*
            	See which fields changed during the modification
            */
            $sql .= "feature_status_id='";
            if (db_result($result, 0, 'feature_status_id') != $feature_status_id && $feature_status_id != 100) {
                feature_data_create_history('feature_status_id', db_result($result, 0, 'feature_status_id'), $feature_id[$i]);
                $update = true;
                $sql .= $feature_status_id;
            } else {
                $sql .= db_result($result, 0, 'feature_status_id');
            }
            $sql .= "', feature_category_id='";
            if (db_result($result, 0, 'feature_category_id') != $feature_category_id && $feature_category_id != 100) {
                feature_data_create_history('feature_category_id', db_result($result, 0, 'feature_category_id'), $feature_id[$i]);
                $update = true;
                $sql .= $feature_category_id;
            } else {
                $sql .= db_result($result, 0, 'feature_category_id');
            }
            $sql .= "', priority='";
            if (db_result($result, 0, 'priority') != $priority && $priority != 100) {
                feature_data_create_history('priority', db_result($result, 0, 'priority'), $feature_id[$i]);
                $update = true;
                $sql .= $priority;
            } else {
                $sql .= db_result($result, 0, 'priority');
            }
            $sql .= "', assigned_to='";
            if (db_result($result, 0, 'assigned_to') != $assigned_to && $assigned_to != 100) {
                feature_data_create_history('assigned_to', db_result($result, 0, 'assigned_to'), $feature_id[$i]);
                $update = true;
                $sql .= $assigned_to;
            } else {
                $sql .= db_result($result, 0, 'assigned_to');
            }
            $sql .= "'";
            if (db_result($result, 0, 'summary') != stripslashes(htmlspecialchars($summary)) && $summary != '') {
                feature_data_create_history('summary', htmlspecialchars(addslashes(db_result($result, 0, 'summary'))), $feature_id[$i]);
                $update = true;
                $sql .= ", summary='" . htmlspecialchars($summary) . "'";
            }
            /*
            	Enter the timestamp if we are changing to closed
            */
            if ($feature_status_id != "1") {
                $now = time();
                $sql .= ", close_date='{$now}'";
                feature_data_create_history('close_date', db_result($result, 0, 'close_date'), $feature_id[$i]);
            }
            /*
            	Finally, update the feature itself
            */
            if ($update) {
                $sql .= " WHERE feature_id='{$feature_id[$i]}'";
                $result = db_query($sql);
                if (!$result) {
                    $feedback .= ' Error - update failed! ';
                    db_rollback();
                    return false;
                } else {
                    $feedback .= " Successfully Modified Feature Ticket {$feature_id[$i]} ";
                }
            }
            /*
            	Details field is handled a little differently
            
            	Details are comments attached to bugs
            	They are still stored in the bug_history (audit 
            	trail) system, but they are not shown in the
            	 regular audit trail
            
            	Someday, these should technically be split into
            	 their own table.
            */
            if ($details != '') {
                //create the first message for this ticket
                if (!feature_data_create_message($details, $feature_id[$i], user_getname() . '@' . $GLOBALS['sys_users_host'])) {
                    db_rollback();
                    return false;
                } else {
                    $feedback .= ' Comment added to feature request ' . $feature_id[$i] . ' ';
                    $send_message = true;
                }
            }
            /*
            	handle canned responses
            */
            if ($canned_response != 100) {
                //don't care if this response is for this group - could be hacked
                $sql = "SELECT * FROM feature_canned_responses WHERE feature_canned_id='{$canned_response}'";
                $result2 = db_query($sql);
                if ($result2 && db_numrows($result2) > 0) {
                    if (!feature_data_create_message(util_unconvert_htmlspecialchars(db_result($result2, 0, 'body')), $feature_id[$i], user_getname() . '@' . $GLOBALS['sys_users_host'])) {
                        db_rollback();
                        return false;
                    } else {
                        $feedback .= ' Canned Response Used For Feature Request ID ' . $feature_id[$i] . '';
                        $send_message = true;
                    }
                } else {
                    $feedback .= ' Unable to Use Canned Response ';
                }
            }
            if ($update || $send_message) {
                /*
                	see if we're supposed to send all modifications to an address
                */
                $project = project_get_object($group_id);
                if ($project->sendAllFeatureUpdates()) {
                    $address = $project->getNewFeatureAddress();
                }
                /*
                	now send the email
                	it's no longer optional due to the group-level notification address
                */
                mail_followup($feature_id[$i], $address);
                db_commit();
            } else {
                //nothing changed, so cancel the transaction
                db_rollback();
            }
        }
    }
    return true;
}
Exemplo n.º 4
0
/**
 *	bug_data_create_bug()
 *	add a bug to this project's bug tracker
 *
 *	@param $project object
 *	@param $summary of this bug
 *	@param
 */
function bug_data_create_bug($project, $summary, $details, $category_id, $bug_group_id, $priority, $assigned_to)
{
    global $feedback;
    $group_id = $project->getGroupID();
    if (!$category_id) {
        //default category
        $category_id = 100;
    }
    if (!$bug_group_id) {
        //default group
        $bug_group_id = 100;
    }
    if (!$assigned_to) {
        //default assignment
        $assigned_to = 100;
    }
    if (!$priority) {
        //default priority
        $priority = 5;
    }
    //we don't force them to be logged in to submit a bug
    if (!user_isloggedin()) {
        $user = 100;
    } else {
        $user = user_getid();
    }
    if (!$group_id || !$summary || !$details) {
        $feedback .= ' ERROR - Missing Params ';
        return false;
    }
    //first check to make sure this wasn't double-submitted
    $res = db_query("SELECT * FROM bug WHERE submitted_by='{$user}' AND summary='{$summary}'");
    if ($res && db_numrows($res) > 0) {
        $feedback = ' ERROR - DOUBLE SUBMISSION. You are trying to double-submit this bug. Please don\'t do that ';
        return false;
    }
    $sql = "INSERT INTO bug (close_date,group_id,status_id,priority,category_id," . "submitted_by,assigned_to,date,summary,details,bug_group_id,resolution_id) " . "VALUES ('0','{$group_id}','1','{$priority}','{$category_id}','{$user}','{$assigned_to}','" . time() . "','" . htmlspecialchars($summary) . "','" . htmlspecialchars($details) . "','{$bug_group_id}','100')";
    db_begin();
    $result = db_query($sql);
    $bug_id = db_insertid($result, 'bug', 'bug_id');
    if (!$bug_id) {
        $feedback .= ' ERROR getting bug_id ';
        db_rollback();
        return false;
    }
    /*
    	set up the default rows in the dependency table
    	both rows will be dependent on id=100
    */
    if (!bug_data_insert_dependent_bugs($array, $bug_id)) {
        $feedback .= ' ERROR inserting dependent bugs ';
        db_rollback();
        return false;
    }
    if (!bug_data_insert_dependent_tasks($array, $bug_id)) {
        $feedback .= ' ERROR inserting dependent tasks ';
        db_rollback();
        return false;
    }
    //mail a followup
    mail_followup($bug_id, $project->getNewBugAddress());
    //now return the bug_id
    db_commit();
    return $bug_id;
}
Exemplo n.º 5
0
function pm_data_update_task($group_project_id, $project_task_id, $start_month, $start_day, $start_year, $end_month, $end_day, $end_year, $summary, $details, $percent_complete, $priority, $hours, $status_id, $assigned_to, $dependent_on, $new_group_project_id, $group_id)
{
    global $feedback;
    if (!$group_project_id || !$project_task_id || !$status_id || !$start_month || !$start_day || !$start_year || !$end_month || !$end_day || !$end_year || !$summary || !$priority || !$new_group_project_id || !$group_id) {
        $feedback .= ' ERROR - Missing Parameters ';
        return false;
    }
    $sql = "SELECT * FROM project_task WHERE project_task_id='{$project_task_id}' AND group_project_id='{$group_project_id}'";
    $result = db_query($sql);
    if (db_numrows($result) < 1) {
        $feedback .= ' ERROR - Task Doesn\'t Exist In This Subproject ';
        return false;
    }
    /*
    	Enforce start date > end date
    */
    if (mktime(0, 0, 0, $start_month, $start_day, $start_year) > mktime(0, 0, 0, $end_month, $end_day, $end_year)) {
        $feedback .= ' ERROR - End Date Must Be Greater Than Start Date ';
        return false;
    }
    db_begin();
    /*
    	If changing subproject, verify the new subproject belongs to this project
    */
    if ($group_project_id != $new_group_project_id) {
        $sql = "SELECT group_id FROM project_group_list WHERE group_project_id='{$new_group_project_id}'";
        if (db_result(db_query($sql), 0, 'group_id') != $group_id) {
            $feedback .= ' You can not put this task into the subproject of another group. ';
            db_rollback();
            return false;
        } else {
            pm_data_create_history('subproject_id', $group_project_id, $project_task_id);
        }
    }
    /*
    	See which fields changed during the modification
    	and create audit trail
    */
    if (db_result($result, 0, 'status_id') != $status_id) {
        pm_data_create_history('status_id', db_result($result, 0, 'status_id'), $project_task_id);
    }
    if (db_result($result, 0, 'priority') != $priority) {
        pm_data_create_history('priority', db_result($result, 0, 'priority'), $project_task_id);
    }
    if (db_result($result, 0, 'summary') != htmlspecialchars(stripslashes($summary))) {
        pm_data_create_history('summary', addslashes(db_result($result, 0, 'summary')), $project_task_id);
    }
    if (db_result($result, 0, 'percent_complete') != $percent_complete) {
        pm_data_create_history('percent_complete', db_result($result, 0, 'percent_complete'), $project_task_id);
    }
    if (db_result($result, 0, 'hours') != $hours) {
        pm_data_create_history('hours', db_result($result, 0, 'hours'), $project_task_id);
    }
    if (db_result($result, 0, 'start_date') != mktime(0, 0, 0, $start_month, $start_day, $start_year)) {
        pm_data_create_history('start_date', db_result($result, 0, 'start_date'), $project_task_id);
    }
    if (db_result($result, 0, 'end_date') != mktime(0, 0, 0, $end_month, $end_day, $end_year)) {
        pm_data_create_history('end_date', db_result($result, 0, 'end_date'), $project_task_id);
    }
    /*
    	Details field is handled a little differently
    
    	Details are comments attached to bugs
    	They are still stored in the project_history (audit trail)
    	system, but they are not shown in the regular audit trail
    
    	Someday, these should technically be split into their own table.
    */
    if ($details != '') {
        pm_data_create_history('details', htmlspecialchars($details), $project_task_id);
    }
    if (!pm_data_update_dependent_tasks($dependent_on, $project_task_id)) {
        db_rollback();
        $feedback .= ' ERROR updating dependent tasks ';
        return false;
    }
    if (!pm_data_update_assigned_to($assigned_to, $project_task_id)) {
        db_rollback();
        $feedback .= ' ERROR updating assigned to ';
        return false;
    }
    /*
    	Update the actual db record
    */
    $sql = "UPDATE project_task SET status_id='{$status_id}', priority='{$priority}'," . "summary='" . htmlspecialchars($summary) . "',start_date='" . mktime(0, 0, 0, $start_month, $start_day, $start_year) . "',end_date='" . mktime(0, 0, 0, $end_month, $end_day, $end_year) . "',hours='{$hours}'," . "percent_complete='{$percent_complete}', " . "group_project_id='{$new_group_project_id}' " . "WHERE project_task_id='{$project_task_id}' AND group_project_id='{$group_project_id}'";
    $result = db_query($sql);
    if (!$result) {
        $feedback .= ' ERROR - Database Update Failed ' . db_error();
        db_rollback();
        return false;
    } else {
        $feedback .= ' Successfully Modified Task ';
        mail_followup($project_task_id, $new_group_project_id);
        db_commit();
        return true;
    }
}