本文整理汇总了PHP中Backend::create_task方法的典型用法代码示例。如果您正苦于以下问题:PHP Backend::create_task方法的具体用法?PHP Backend::create_task怎么用?PHP Backend::create_task使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Backend
的用法示例。
在下文中一共展示了Backend::create_task方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_newtask
function action_newtask()
{
global $user;
list($task_id, $token, $ok) = Backend::create_task($_POST);
// Status and redirect
if ($ok) {
$url = CreateURL(array('details', 'task' . $task_id));
if ($user->isAnon()) {
$url = CreateURL(array('details', 'task' . $task_id), array('task_token' => $token));
}
if (Post::val('more_tasks')) {
$url = '';
}
return array(SUBMIT_OK, L('newtaskadded'), $url);
} else {
return array($task_id, $token);
// create_task will out error info there
}
}
示例2: count
$length = count($_POST['detailed_desc']);
for ($i = 0; $i < $length; $i++) {
$ticket = array();
foreach ($_POST as $key => $value) {
if ($key == "assigned_to") {
$sql = $db->Query("SELECT user_id FROM {users} WHERE user_name = ? or real_name = ?", array($value[$i], $value[$i]));
$ticket["rassigned_to"] = array(intval($db->FetchOne($sql)));
continue;
}
if (is_array($value)) {
$ticket[$key] = $value[$i];
} else {
$ticket[$key] = $value;
}
}
list($task_id, $token) = Backend::create_task($ticket);
if (!$task_id) {
$flag = false;
break;
}
}
if (!$flag) {
Flyspray::show_error(L('databasemodfailed'));
break;
}
$_SESSION['SUCCESS'] = L('newtaskadded');
Flyspray::Redirect(CreateURL('index', $proj->id));
break;
// ##################
// Modifying an existing task
// ##################
示例3: array
// 'last_edited_time' => time(),
$args['opened_by'] = $reporter;
$args['product_category'] = $category;
$args['task_severity'] = 1;
$args['task_priority'] = 1;
// 'task_type', , 'product_version',
// 'operating_system', , 'estimated_effort',
// 'supertask_id',
$sql = $db->Query("SELECT project_title FROM {projects} WHERE project_id = ?", array($project));
$projectname = $db->FetchOne($sql);
$subject = $subjects[rand(0, count($subjects) - 1)];
$subject = sprintf($subject, $projectname);
$args['item_summary'] = "Task {$i} ({$subject})";
// 'detailed_desc'
// echo $args['item_summary'] . "\r\n";
$ok = Backend::create_task($args);
if ($ok === 0) {
echo "Failed to create task.\r\n";
} else {
list($id, $token) = $ok;
$db->Query('UPDATE {tasks} SET opened_by = ?, date_opened = ? WHERE task_id = ?', array($reporter, $opened, $id));
}
}
// One task in ten of is unconfirmed, probably just bullshit, not assigned to anyone,
// and we add just a comment "Cannot reproduce".
for ($i = 1; $i <= $maxcomments; $i++) {
$taskid = rand(2, $maxtasks + 1);
$task = Flyspray::GetTaskDetails($taskid, true);
$project = $task['project_id'];
$added = time() - rand(1, 315360000);
// Find someone who is allowed to add comment, do not use global groups
示例4: unset
if (Req::num('task_id')) {
$task = Flyspray::GetTaskDetails(Req::num('task_id'));
}
if (isset($_SESSION)) {
unset($_SESSION['SUCCESS'], $_SESSION['ERROR']);
}
switch ($action = Req::val('action')) {
// ##################
// Adding a new task
// ##################
case 'newtask.newtask':
if (!Post::val('item_summary') || !Post::val('detailed_desc')) {
Flyspray::show_error(L('summaryanddetails'));
break;
}
list($task_id, $token) = Backend::create_task($_POST);
// Status and redirect
if ($task_id) {
$_SESSION['SUCCESS'] = L('newtaskadded');
if ($user->isAnon()) {
Flyspray::Redirect(CreateURL('details', $task_id, null, array('task_token' => $token)));
} else {
Flyspray::Redirect(CreateURL('details', $task_id));
}
} else {
Flyspray::show_error(L('databasemodfailed'));
break;
}
break;
// ##################
// Modifying an existing task
示例5: createTestData
//.........这里部分代码省略.........
$password = $user_name;
$time_zone = 0;
// Assign different ones!
$email = null;
// $user_name . '@example.com';
$group = 4;
Backend::create_user($user_name, $password, $real_name, '', $email, 0, $time_zone, $group, 1);
}
// But that was not enough for all needed permission, so in practice, every
// project also has between 1 AND 20 project groups.
//
// Must recreate, so rights for new projects get loaded. Otherwise,
// even first user in database can't create tasks.
$user = new User(1);
// And that's why we've got $maxtasks opened within the last 10 years
for ($i = 1; $i <= $maxtasks; $i++) {
$project = rand(2, $maxproducts);
// Find someone who is allowed to open a task, do not use global groups
$sql = $db->Query("SELECT uig.user_id\n\t\t\tFROM {users_in_groups} uig\n\t\t\tJOIN {groups} g ON g.group_id = uig.group_id AND g.open_new_tasks = 1 AND (g.project_id = 0 OR g.project_id = ?)\n\t\t\tWHERE g.group_id NOT IN (1, 2, 7, 8, 9)\n\t\t\tORDER BY {$RANDOP} LIMIT 1", array($project));
$reporter = $db->FetchOne($sql);
$sql = $db->Query("SELECT category_id FROM {list_category}\n\t\t\tWHERE project_id = ?\n\t\t\tAND category_name <> 'root'\n\t\t\tORDER BY {$RANDOP} LIMIT 1", array($project));
$category = $db->FetchOne($sql);
$opened = time() - rand(1, 315360000);
$args = array();
$args['project_id'] = $project;
$args['date_opened'] = time() - rand(1, 315360000);
// 'last_edited_time' => time(),
$args['opened_by'] = $reporter;
$args['product_category'] = $category;
$args['task_severity'] = 1;
$args['task_priority'] = 1;
// 'task_type', , 'product_version',
// 'operating_system', , 'estimated_effort',
// 'supertask_id',
$sql = $db->Query("SELECT project_title FROM {projects} WHERE project_id = ?", array($project));
$projectname = $db->FetchOne($sql);
$subject = $subjects[rand(0, count($subjects) - 1)];
$subject = sprintf($subject, $projectname);
$args['item_summary'] = "Task {$i} ({$subject})";
// 'detailed_desc'
// echo $args['item_summary'] . "\r\n";
$ok = Backend::create_task($args);
if ($ok === 0) {
echo "Failed to create task.\r\n";
} else {
list($id, $token) = $ok;
$db->Query('UPDATE {tasks} SET opened_by = ?, date_opened = ? WHERE task_id = ?', array($reporter, $opened, $id));
}
}
# end for maxtasks
// One task in ten of is unconfirmed, probably just bullshit, not assigned to anyone,
// and we add just a comment "Cannot reproduce".
for ($i = 1; $i <= $maxcomments; $i++) {
$taskid = rand(2, $maxtasks + 1);
$task = Flyspray::GetTaskDetails($taskid, true);
$project = $task['project_id'];
$added = time() - rand(1, 315360000);
// Find someone who is allowed to add comment, do not use global groups
$sqltext = "SELECT uig.user_id\n\t\t\tFROM {users_in_groups} uig\n JOIN {groups} g ON g.group_id = uig.group_id AND g.add_comments = 1\n AND (g.project_id = 0 OR g.project_id = ?)\n WHERE g.group_id NOT IN (1, 2, 7, 8, 9)\n ORDER BY {$RANDOP} ";
$sql = $db->Query($sqltext, array($project));
$row = $db->FetchRow($sql);
$reporter = new User($row['user_id']);
// User might still not be able to add a comment, if he can not see the task...
// Just try again until a suitable one comes out from the query. It will finally.
// Try to enhance the query also to return fewer unsuitable ones.
while (!$reporter->can_view_task($task)) {
$row = $db->FetchRow($sql);
$reporter = new User($row['user_id']);
}
$comment = 'Comment.';
Backend::add_comment($task, $comment);
$sql = $db->Query('SELECT MAX(comment_id) FROM {comments}');
$comment_id = $db->FetchOne($sql);
$db->Query('UPDATE {comments} SET user_id = ?, date_added = ? WHERE comment_id = ?', array($reporter->id, $added, $comment_id));
}
# end for maxcomments
// And $maxattachments total, either to task or comment
for ($i = 1; $i <= $maxattachments; $i++) {
$sql = $db->Query("SELECT comment_id, task_id, user_id, date_added FROM {comments} ORDER BY {$RANDOP} LIMIT 1");
list($comment_id, $task_id, $user_id, $date_added) = $db->FetchRow($sql);
$fname = "Attachment {$i}";
if (rand(1, 100) == 1) {
$comment_id = 0;
}
$origname = getAttachmentDescription() . " {$i}";
$db->Query("INSERT INTO {attachments}\n ( task_id, comment_id, file_name,\n file_type, file_size, orig_name,\n added_by, date_added)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?)", array($task_id, $comment_id, $fname, 'application/octet-stream', 1024, $origname, $user_id, $date_added));
}
// // But at least we have been able to solve approximately half of the tasks
// Of course, many of the tasks are somehow related to each other, so add
// parents, relationships, dependencies, duplicates etc. last.
// Do this ones last, after creating all the other data.
// Approximately 200 hundred of our projects are already closed or deleted.
// Cannot be sure when using random...
for ($i = 1; $i < 200; $i++) {
}
// Some of our developers AND project managers couldn't take all that AND have already left the premises
// No wonder, because we've got those corporate AND individual users always complaining
// AND whining, not to speak about our management.
$db->dbClose();
}
示例6: createTestData
//.........这里部分代码省略.........
// But that was not enough for all needed permission, so in practice, every
// project also has between 1 AND 20 project groups.
//
// Must recreate, so rights for new projects get loaded. Otherwise,
// even first user in database can't create tasks.
$user = new User(1);
// And that's why we've got 1000000 tasks opened within the last 10 years
for ($i = 1; $i <= $maxtasks; $i++) {
$project = rand(2, $maxproducts);
// Find someone who is allowed to open a task, do not use global groups
$sql = $db->Query("SELECT uig.user_id\n FROM {users_in_groups} uig\n JOIN {groups} g ON g.group_id = uig.group_id AND g.open_new_tasks = 1\n AND (g.project_id = 0 OR g.project_id = ?)\n WHERE g.group_id NOT IN (1, 2, 7, 8, 9)\n ORDER BY {$RANDOP} LIMIT 1", array($project));
$reporter = $db->FetchOne($sql);
$sql = $db->Query("SELECT category_id FROM {list_category} WHERE project_id = ? AND category_name <> 'root' ORDER BY {$RANDOP} LIMIT 1", array($project));
$category = $db->FetchOne($sql);
$opened = time() - rand(1, 315360000);
$args = array();
$args['project_id'] = $project;
$args['date_opened'] = time() - rand(1, 315360000);
// 'last_edited_time' => time(),
$args['opened_by'] = $reporter;
$args['product_category'] = $category;
$args['task_severity'] = 1;
$args['task_priority'] = 1;
// 'task_type', , 'product_version',
// 'operating_system', , 'estimated_effort',
// 'supertask_id',
$sql = $db->Query("SELECT project_title FROM {projects} WHERE project_id = ?", array($project));
$projectname = $db->FetchOne($sql);
$subject = $subjects[rand(0, count($subjects) - 1)];
$subject = sprintf($subject, $projectname);
$args['item_summary'] = "Task {$i} ({$subject})";
// 'detailed_desc'
// echo $args['item_summary'] . "\r\n";
$ok = Backend::create_task($args);
if ($ok === 0) {
echo "Failed to create task.\r\n";
} else {
list($id, $token) = $ok;
$db->Query('UPDATE {tasks} SET opened_by = ?, date_opened = ? WHERE task_id = ?', array($reporter, $opened, $id));
}
}
// One task in ten of is unconfirmed, probably just bullshit, not assigned to anyone,
// and we add just a comment "Cannot reproduce".
for ($i = 1; $i <= $maxcomments; $i++) {
$taskid = rand(2, $maxtasks + 1);
$task = Flyspray::GetTaskDetails($taskid, true);
$project = $task['project_id'];
$added = time() - rand(1, 315360000);
// Find someone who is allowed to add comment, do not use global groups
$sqltext = "SELECT uig.user_id\n FROM {users_in_groups} uig\n JOIN {groups} g ON g.group_id = uig.group_id AND g.add_comments = 1\n AND (g.project_id = 0 OR g.project_id = ?)\n WHERE g.group_id NOT IN (1, 2, 7, 8, 9)\n ORDER BY {$RANDOP} ";
$sql = $db->Query($sqltext, array($project));
$row = $db->FetchRow($sql);
$reporter = new User($row['user_id']);
// User might still not be able to add a comment, if he can not see the task...
// Just try again until a suitable one comes out from the query. It will finally.
// Try to enhance the query also to return fewer unsuitable ones.
while (!$reporter->can_view_task($task)) {
$row = $db->FetchRow($sql);
$reporter = new User($row['user_id']);
}
$comment = 'Comment.';
Backend::add_comment($task, $comment);
$sql = $db->Query('SELECT MAX(comment_id) FROM {comments}');
$comment_id = $db->FetchOne($sql);
$db->Query('UPDATE {comments} SET user_id = ?, date_added = ? WHERE comment_id = ?', array($reporter->id, $added, $comment_id));
}