本文整理匯總了PHP中Flyspray::compare_tasks方法的典型用法代碼示例。如果您正苦於以下問題:PHP Flyspray::compare_tasks方法的具體用法?PHP Flyspray::compare_tasks怎麽用?PHP Flyspray::compare_tasks使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Flyspray
的用法示例。
在下文中一共展示了Flyspray::compare_tasks方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: edit_task
/**
* Edits the task in $task using the parameters in $args
* @param array $task a task array
* @param array $args usually $_POST
* @access public
* @return array array(STATUS_CODE, msg)
*/
function edit_task($task, $args)
{
global $user, $db, $fs, $proj;
if ($proj->id != Post::val('project_id', $task['project_id'])) {
$proj = new Project(Post::val('project_id', $task['project_id']));
}
if (!$proj->id) {
return array(ERROR_INPUT, L('cannotedittaskglobally'));
}
if (!$user->can_edit_task($task) && !$user->can_correct_task($task)) {
return array(ERROR_PERMS);
}
// check missing fields
if (!array_get($args, 'item_summary') || !array_get($args, 'detailed_desc')) {
return array(ERROR_RECOVER, L('summaryanddetails'));
}
foreach ($proj->fields as $field) {
if ($field->prefs['value_required'] && !array_get($args, 'field' . $field->id) && !($field->prefs['force_default'] && !$user->perms('modify_all_tasks'))) {
return array(ERROR_RECOVER, L('missingrequired') . ' (' . $field->prefs['field_name'] . ')');
}
}
$time = time();
$plugins = trim(implode(' ', array_get($args, 'detailed_desc_syntax_plugins', array())));
if (!$plugins) {
$plugins = $proj->prefs['syntax_plugins'];
}
$db->x->autoExecute('{tasks}', array('project_id' => $proj->id, 'item_summary' => array_get($args, 'item_summary'), 'detailed_desc' => array_get($args, 'detailed_desc'), 'mark_private' => intval($user->can_change_private($task) && array_get($args, 'mark_private')), 'last_edited_by' => intval($user->id), 'last_edited_time' => $time, 'syntax_plugins' => $plugins, 'percent_complete' => array_get($args, 'percent_complete')), MDB2_AUTOQUERY_UPDATE, sprintf('task_id = %d', $task['task_id']));
// Now the custom fields
foreach ($proj->fields as $field) {
$field_value = $field->read(array_get($args, 'field' . $field->id));
$fields = array('field_id' => array('value' => $field->id, 'key' => true), 'task_id' => array('value' => $task['task_id'], 'key' => true), 'field_value' => array('value' => $field_value));
$db->Replace('{field_values}', $fields);
}
// [RED] Update last changed date and user
$db->x->execParam('UPDATE {redundant} SET last_changed_time = ?,
last_changed_by_real_name = ?, last_changed_by_user_name = ?,
last_edited_by_real_name = ?, last_edited_by_user_name = ?
WHERE task_id = ?', array($time, $user->infos['real_name'], $user->infos['user_name'], $user->infos['real_name'], $user->infos['user_name'], $task['task_id']));
// Prepare assignee list
$assignees = explode(';', trim(array_get($args, 'assigned_to')));
$assignees = array_map(array('Flyspray', 'UserNameToId'), $assignees);
$assignees = array_filter($assignees, create_function('$x', 'return ($x > 0);'));
// Update the list of users assigned this task, if changed
if ($user->perms('edit_assignments') && count(array_diff($task['assigned_to'], $assignees)) + count(array_diff($assignees, $task['assigned_to']))) {
// Delete the current assignees for this task
$db->x->execParam('DELETE FROM {assigned}
WHERE task_id = ?', $task['task_id']);
// Store them in the 'assigned' table
foreach ($assignees as $val) {
$fields = array('user_id' => array('value' => $val, 'key' => true), 'task_id' => array('value' => $task['task_id'], 'key' => true));
$db->Replace('{assigned}', $fields);
}
// Log to task history
Flyspray::logEvent($task['task_id'], 14, implode(' ', $assignees), implode(' ', $task['assigned_to']), '', $time);
// Notify the new assignees what happened. This obviously won't happen if the task is now assigned to no-one.
if (count($assignees)) {
$new_assignees = array_diff($assignees, $task['assigned_to']);
// Remove current user from notification list
if (!$user->infos['notify_own']) {
$new_assignees = array_filter($new_assignees, create_function('$u', 'global $user; return $user->id != $u;'));
}
if (count($new_assignees)) {
Notifications::send($new_assignees, ADDRESS_USER, NOTIFY_NEW_ASSIGNEE, array('task_id' => $task['task_id']));
}
}
}
// Get the details of the task we just updated
// To generate the changed-task message
$new_details_full = Flyspray::GetTaskDetails($task['task_id']);
$changes = Flyspray::compare_tasks($task, $new_details_full);
foreach ($changes as $change) {
if ($change[4] == 'assigned_to_name') {
continue;
}
Flyspray::logEvent($task['task_id'], 3, $change[6], $change[5], $change[4], $time);
}
if (count($changes) > 0) {
Notifications::send($task['task_id'], ADDRESS_TASK, NOTIFY_TASK_CHANGED, array('changes' => $changes));
}
Backend::add_comment($task, array_get($args, 'comment_text'), $time);
Backend::delete_files(array_get($args, 'delete_att'));
Backend::upload_files($task['task_id'], '0', 'usertaskfile');
return array(SUBMIT_OK, L('taskupdated'));
}
示例2: array
// Get the details of the task we just updated
// To generate the changed-task message
$new_details_full = Flyspray::GetTaskDetails($task['task_id']);
// Not very nice...maybe combine compare_tasks() and logEvent() ?
$result = $db->Query("SELECT * FROM {tasks} WHERE task_id = ?", array($task['task_id']));
$new_details = $db->FetchRow($result);
foreach ($new_details as $key => $val) {
if (strstr($key, 'last_edited_') || $key == 'assigned_to' || is_numeric($key)) {
continue;
}
if ($val != $task[$key]) {
// Log the changed fields in the task history
Flyspray::logEvent($task['task_id'], 3, $val, $task[$key], $key, $time);
}
}
$changes = Flyspray::compare_tasks($task, $new_details_full);
if (count($changes) > 0) {
$notify->Create(NOTIFY_TASK_CHANGED, $task['task_id'], $changes, null, NOTIFY_BOTH, $proj->prefs['lang_code']);
}
if ($assignees_changed) {
// Log to task history
Flyspray::logEvent($task['task_id'], 14, implode(' ', $assignees), implode(' ', $task['assigned_to']), '', $time);
// Notify the new assignees what happened. This obviously won't happen if the task is now assigned to no-one.
if (count($assignees)) {
$new_assignees = array_diff($task['assigned_to'], $assignees);
// Remove current user from notification list
if (!$user->infos['notify_own']) {
$new_assignees = array_filter($new_assignees, create_function('$u', 'global $user; return $user->id != $u;'));
}
if (count($new_assignees)) {
$notify->Create(NOTIFY_NEW_ASSIGNEE, $task['task_id'], null, $notify->SpecificAddresses($new_assignees), NOTIFY_BOTH, $proj->prefs['lang_code']);