本文整理汇总了PHP中Task::setState方法的典型用法代码示例。如果您正苦于以下问题:PHP Task::setState方法的具体用法?PHP Task::setState怎么用?PHP Task::setState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Task
的用法示例。
在下文中一共展示了Task::setState方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
//.........这里部分代码省略.........
}
} else {
$query = "insert into healingcrystals_assignments_action_request (user_id, is_action_request, is_fyi, selected_by_user_id, comment_id, date_added) values ('" . $id . "', '1', '0', '" . $this->logged_user->getId() . "', '" . $this->active_comment->getId() . "', now())";
mysql_query($query);
$new_ar_users[] = $id;
}
}
$query = "update healingcrystals_assignments_action_request set is_action_request='0' where comment_id='" . $this->active_comment->getId() . "' and user_id not in (" . implode(', ', $action_request_user_id) . ")";
mysql_query($query);
} else {
$query = "update healingcrystals_assignments_action_request set is_action_request='0' where comment_id='" . $this->active_comment->getId() . "'";
mysql_query($query);
}
mysql_query("delete from healingcrystals_assignments_action_request where comment_id='" . $this->active_comment->getId() . "' and is_action_request='0' and is_fyi='0' and marked_for_email='0'");
//EOF:task_1260
foreach ($action_request_users as $id) {
if (!in_array($id, $existing_ar_users)) {
//unassign
$query = "select object_id from actionrequests_to_tasklist where comment_id='" . $this->active_comment->getId() . "' and user_id='" . $id . "' and type='Task'";
$result = mysql_query($query);
if (mysql_num_rows($result)) {
$info = mysql_fetch_assoc($result);
$task = new Task($info['object_id']);
$task->delete();
mysql_query("delete from actionrequests_to_tasklist where comment_id='" . $this->active_comment->getId() . "' and user_id='" . $id . "' and type='Task'");
}
}
}
foreach ($new_ar_users as $id) {
//assign
//BOF:mod 20130429
/*
//EOF:mod 20130429
$priority = '0';
$query = "select * from healingcrystals_assignments_action_request where comment_id='" . $this->active_comment->getId() . "' and user_id='" . $id . "'";
$result = mysql_query($query, $link);
if (mysql_num_rows($result)){
$query1 = "update healingcrystals_assignments_action_request set is_action_request='1', priority_actionrequest='" . $priority . "' where comment_id='" . $this->active_comment->getId() . "' and user_id='" . $id . "'";
mysql_query($query1, $link);
} else {
$query1 = "insert into healingcrystals_assignments_action_request (user_id, is_action_request, is_fyi, selected_by_user_id, comment_id, date_added, priority_actionrequest) values ('" . $id . "', '1', '0', '" . $this->logged_user->getId() . "', '" . $this->active_comment->getId() . "', now(), '" . $priority . "')";
mysql_query($query1, $link);
}
//BOF:mod 20130429
*/
//EOF:mod 20130429
$task = new Task();
$task->setProjectId(TASK_LIST_PROJECT_ID);
$task->setParentId(Page::getTaskPageIdForUser($id));
$task->setParentType('Page');
$task->setCreatedBy($this->logged_user);
$task->setVisibility(VISIBILITY_NORMAL);
$task->setState(STATE_VISIBLE);
$task_body = '';
$parent = $this->active_comment->getParent();
$url = $parent->getViewUrl() . '#comment' . $this->active_comment->getId();
$comment_body = $this->active_comment->getBody();
$comment_body = strip_tags($comment_body);
if (strlen($comment_body) > 525) {
$task_body .= substr($comment_body, 0, 525) . '..';
} else {
$task_body .= $comment_body;
}
$task_body .= '<br/><a href="' . $url . '">View Task in Full</a>';
$attachments = $this->active_comment->getAttachments();
if (is_foreachable($attachments)) {
$task_body .= '<br/>Attachments:<br/>';
foreach ($attachments as $attachment) {
$task_body .= '<a href="' . $attachment->getViewUrl() . '">' . $attachment->getName() . '</a><br/>';
}
}
$task->setBody($task_body);
$savetask = $task->save();
if ($savetask && !is_error($savetask)) {
$task->ready();
mysql_query("insert into actionrequests_to_tasklist (comment_id, user_id, type, object_id) values ('" . $this->active_comment->getId() . "', '" . $id . "', 'Task', '" . $task->getId() . "')");
}
}
if ($this->request->getFormat() == FORMAT_HTML) {
flash_success('Comment has been updated');
$this->redirectToUrl($this->active_comment->getRealViewUrl());
} else {
$this->serveData($this->active_comment, 'comment');
}
// if
} else {
if ($this->request->getFormat() == FORMAT_HTML) {
$this->smarty->assign('errors', $save);
} else {
$this->serveData($save);
}
// if
}
// if
}
// if
//BOF:task_1260
//mysql_close($link);
//EOF:task_1260
}
示例2: add
/**
* Show and process add task form
*
* @param void
* @return null
*/
function add()
{
$this->wireframe->print_button = false;
if (!instance_of($this->active_task_parent, 'ProjectObject')) {
$this->httpError(HTTP_ERR_NOT_FOUND);
}
// if
if (!$this->active_task_parent->canSubtask($this->logged_user)) {
$this->httpError(HTTP_ERR_FORBIDDEN);
}
// if
$task_data = $this->request->post('task');
$this->smarty->assign(array('task_data' => $task_data, 'page_tab' => $this->active_task_parent->getProjectTab()));
if ($this->request->isSubmitted()) {
db_begin_work();
$this->active_task = new Task();
// just in case...
$this->active_task->log_activities = false;
$this->active_task->setAttributes($task_data);
$this->active_task->setParent($this->active_task_parent);
$this->active_task->setProjectId($this->active_project->getId());
if (trim($this->active_task->getCreatedByName()) == '' || trim($this->active_task->getCreatedByEmail()) == '') {
$this->active_task->setCreatedBy($this->logged_user);
}
// if
$this->active_task->setState(STATE_VISIBLE);
$this->active_task->setVisibility($this->active_task_parent->getVisibility());
$save = $this->active_task->save();
if ($save && !is_error($save)) {
$subscribers = array($this->logged_user->getId());
if (is_foreachable(array_var($task_data['assignees'], 0))) {
$subscribers = array_merge($subscribers, array_var($task_data['assignees'], 0));
} else {
$subscribers[] = $this->active_project->getLeaderId();
}
// if
if (!in_array($this->active_project->getLeaderId(), $subscribers)) {
$subscribers[] = $this->active_project->getLeaderId();
}
// if
Subscriptions::subscribeUsers($subscribers, $this->active_task);
$activity = new NewTaskActivityLog();
$activity->log($this->active_task, $this->logged_user);
db_commit();
$this->active_task->ready();
//BOF:mod
$recurring_flag = $task_data['recurring_flag'];
$recurring_period = $task_data['recurring_period'];
$recurring_period_type = $task_data['recurring_period_type'];
$recurring_period_condition = $task_data['recurring_period_condition'];
//$recurring_end_date = str_replace('/', '-', $task_data['recurring_end_date']);
/// $reminder = str_replace('/', '-', $task_data['reminder']);
$recurring_end_date = dateval($task_data['recurring_end_date']);
/*$reminder = dateval($task_data['reminder']);
$reminderhours = (int)$task_data['reminderhours'];
$reminderminutes = (int)$task_data['reminderminutes'];
$remindermeridian = $task_data['remindermeridian'];
if (!empty($reminder)){
if (!empty($remindermeridian) && $remindermeridian=='PM' && $reminderhours<12){
$reminderhours += 12;
} elseif (!empty($remindermeridian) && $remindermeridian=='AM' && $reminderhours==12){
$reminderhours = 0;
}
$reminder = $reminder . ' ' . $reminderhours . ':' . $reminderminutes;
}*/
$email_flag = empty($task_data['email_flag']) ? '0' : '1';
if ($email_flag == '1') {
$email_reminder_period = (int) $task_data['figure_before_due_date'];
$email_reminder_unit = empty($task_data['unit_before_due_date']) ? 'D' : $task_data['unit_before_due_date'];
$email_reminder_hours = empty($task_data['reminderhours']) ? '6' : $task_data['reminderhours'];
$email_reminder_minutes = (int) $task_data['reminderminutes'];
$email_reminder_meridian = empty($task_data['remindermeridian']) ? 'AM' : $task_data['remindermeridian'];
$email_reminder_time = '';
if ($email_reminder_meridian == 'PM' && $email_reminder_hours < 12) {
$email_reminder_time = $email_reminder_hours + 12 . ':';
} elseif ($email_reminder_meridian == 'AM' && $email_reminder_hours == 12) {
$email_reminder_time = '00:';
} else {
$email_reminder_time = str_pad($email_reminder_hours, 2, '0', STR_PAD_LEFT) . ':';
}
$email_reminder_time .= $email_reminder_minutes;
}
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
mysql_select_db(DB_NAME);
//if (empty($recurring_flag) && empty($reminder) && empty($email_flag)){
if (empty($recurring_flag) && empty($email_flag)) {
$query = "delete from healingcrystals_project_object_misc where object_id='" . $this->active_task->getId() . "'";
mysql_query($query, $link);
} else {
if (empty($recurring_flag)) {
$recurring_period = '';
$recurring_period_type = '';
$recurring_period_condition = '';
$recurring_end_date = '';
//.........这里部分代码省略.........
示例3: complete
//.........这里部分代码省略.........
} else {
$this->setCompletedBy($by);
$this->setCompletedOn(new DateTimeValue());
$save = $this->save();
if ($save && !is_error($save)) {
event_trigger('on_project_object_completed', array(&$this, &$by, $comment));
$activity_log = new TaskCompletedActivityLog();
$activity_log->log($this, $by);
if (instance_of($this, 'Task')) {
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
mysql_select_db(DB_NAME);
$query = "select * from healingcrystals_project_object_misc where object_id='" . $this->getId() . "'";
$result = mysql_query($query, $link);
$flag_continue = true;
if (mysql_num_rows($result)) {
$info = mysql_fetch_assoc($result);
if (empty($info['recurring_period'])) {
$flag_continue = false;
}
if ($flag_continue) {
$recurring_period = $info['recurring_period'];
$recurring_period_type = $info['recurring_period_type'];
$recurring_period_condition = $info['recurring_period_condition'];
$recurring_end_date = $info['recurring_end_date'];
$auto_email_status = $info['auto_email_status'];
$email_reminder_period = $info['email_reminder_period'];
$email_reminder_unit = $info['email_reminder_unit'];
$email_reminder_time = $info['email_reminder_time'];
if ($recurring_period_condition == 'after_due_date') {
$due_date = new DateTime($this->getDueOn());
} else {
$due_date = new DateTime();
}
switch ($recurring_period_type) {
case 'D':
$recurring_period_type = 'day' . ($recurring_period == 1 ? '' : 's');
break;
case 'W':
$recurring_period_type = 'week' . ($recurring_period == 1 ? '' : 's');
break;
case 'M':
$recurring_period_type = 'month' . ($recurring_period == 1 ? '' : 's');
break;
}
$due_date->modify('+' . $recurring_period . ' ' . $recurring_period_type);
if (!empty($recurring_end_date) && $recurring_end_date != '0000-00-00') {
if (strtotime($due_date->format('Y-m-d')) - strtotime($recurring_end_date) > 0) {
$flag_continue = false;
}
}
}
if ($flag_continue) {
$new_task = new Task();
$new_task->setSource($this->getSource());
$new_task->setType($this->getType());
$new_task->setModule('resources');
$new_task->setProjectId($this->getProjectId());
$new_task->setMilestoneId($this->getMilestoneId());
$new_task->setParentId($this->getParentId());
$new_task->setParentType($this->getParentType());
//$new_task->setName($this->getName());
$new_task->setBody($this->getBody());
$new_task->setState($this->getState());
$new_task->setVisibility($this->getVisibility());
$new_task->setPriority($this->getPriority());
$new_task->setCreatedOn(date('Y-m-d H:i:s'));
$new_task->setCreatedById($this->getCreatedById());
$new_task->setCreatedByName($this->getCreatedByName());
$new_task->setCreatedByEmail($this->getCreatedByEmail());
$new_task->setDueOn($due_date->format('Y-m-d'));
$query02 = "insert into healingcrystals_project_objects (source, type, module, project_id, milestone_id, parent_id, parent_type, body, state, visibility, priority, created_on, created_by_id, created_by_name, created_by_email, due_on) values ('{$new_task->getSource()}' , '{$new_task->getType()}', '{$new_task->getModule()}', '{$new_task->getProjectId()}', '{$new_task->getMilestoneId()}', '{$new_task->getParentId()}', '{$new_task->getParentType()}', '" . mysql_real_escape_string($new_task->getBody()) . "', '{$new_task->getState()}', '{$new_task->getVisibility()}', '{$new_task->getPriority()}', '{$new_task->getCreatedOn()}', '{$new_task->getCreatedById()}', '{$new_task->getCreatedByName()}', '{$new_task->getCreatedByEmail()}', '{$new_task->getDueOn()}')";
mysql_query($query02);
$new_task_id = mysql_insert_id($link);
if ($new_task_id) {
$_SESSION['new_recurring_task_id'] = $new_task_id;
$query02 = "select * from healingcrystals_assignments where object_id='" . $this->getId() . "'";
$result02 = mysql_query($query02, $link);
if (mysql_num_rows($result02)) {
$query03 = "insert into healingcrystals_assignments \n\t\t\t\t\t\t\t\t\t\t\tselect user_id, '{$new_task_id}', is_owner from healingcrystals_assignments where object_id='" . $this->getId() . "'";
mysql_query($query03);
}
$query02 = "insert into healingcrystals_project_object_misc \n\t\t\t\t\t\t\t\t\t\tselect '{$new_task_id}', reminder_date, recurring_period, recurring_period_type, recurring_period_condition, recurring_end_date, now(), null, auto_email_status, email_reminder_period, email_reminder_unit, email_reminder_time, null from healingcrystals_project_object_misc where object_id='" . $this->getId() . "'";
mysql_query($query02);
}
}
}
$query = "select comment_id, user_id from actionrequests_to_tasklist where object_id='" . $this->getId() . "'";
$result = mysql_query($query);
if (mysql_num_rows($result)) {
$info = mysql_fetch_assoc($result);
$query = "update healingcrystals_assignments_action_request set is_action_request='-1', last_modified=now() where is_action_request='1' and user_id='" . $info['user_id'] . "' and comment_id='" . $info['comment_id'] . "'";
mysql_query($query);
}
//mysql_close();
}
}
// if
return $save;
}
}
示例4: lang
/**
* Quick add checklist
*
* @param void
* @return null
*/
function quick_add()
{
if (!Checklist::canAdd($this->logged_user, $this->active_project)) {
$this->httpError(HTTP_ERR_FORBIDDEN, lang("You don't have permission for this action"), true, true);
}
// if
$this->skip_layout = true;
$checklist_data = $this->request->post('checklist');
if (!is_array($checklist_data)) {
$checklist_data = array('visibility' => $this->active_project->getDefaultVisibility());
}
//if
$this->smarty->assign(array('checklist_data' => $checklist_data, 'quick_add_url' => assemble_url('project_checklists_quick_add', array('project_id' => $this->active_project->getId()))));
if ($this->request->isSubmitted()) {
db_begin_work();
$this->active_checklist = new Checklist();
$this->active_checklist->setAttributes($checklist_data);
$this->active_checklist->setProjectId($this->active_project->getId());
$this->active_checklist->setCreatedBy($this->logged_user);
$this->active_checklist->setState(STATE_VISIBLE);
$subscribers = array($this->logged_user->getId());
if (is_foreachable(array_var($checklist_data['assignees'], 0))) {
$subscribers = array_merge($subscribers, array_var($checklist_data['assignees'], 0));
} else {
$subscribers[] = $this->active_project->getLeaderId();
}
// if
Subscriptions::subscribeUsers($subscribers, $this->active_checklist);
$this->active_checklist->ready();
// ready
$save = $this->active_checklist->save();
if ($save && !is_error($save)) {
if (isset($checklist_data['tasks']) && is_foreachable($checklist_data['tasks'])) {
foreach ($checklist_data['tasks'] as $task_text) {
$task_text = trim($task_text);
if ($task_text != '') {
$task = new Task();
$task->setBody($task_text);
$task->setPriority(PRIORITY_NORMAL);
$task->setProjectId($this->active_project->getId());
$task->setParent($this->active_checklist);
$task->setCreatedBy($this->logged_user);
$task->setState(STATE_VISIBLE);
$task->setVisibility(VISIBILITY_NORMAL);
$task->new_assignees = $checklist_data['assignees'];
$task->save();
Subscriptions::subscribeUsers($subscribers, $task);
$task->ready();
}
// if
}
// if
}
// if
db_commit();
$this->smarty->assign(array('active_checklist' => $this->active_checklist, 'checklist_data' => array('visibility' => $this->active_project->getDefaultVisibility()), 'project_id' => $this->active_project->getId()));
} else {
db_rollback();
$this->httpError(HTTP_ERR_OPERATION_FAILED, $save->getErrorsAsString(), true, true);
}
// if
}
// if
}
示例5: importPendingEmailToTaskList
function importPendingEmailToTaskList(&$incoming_mail, &$project, &$user, $page_id, $comment)
{
//$link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
//mysql_select_db(DB_NAME, $link);
//mysql_query("insert into testing (date_added, content) values (now(), 'in task list adde func:Page " . $page_id . " / comment: " . $comment->getId() . "')");
//mysql_query("insert into testing (date_added, content) values (now(), '" . mysql_real_escape_string($incoming_mail->getSubject()) . "')");
//EOF:mod 20120820
list($user_name, $priority) = explode('-', $incoming_mail->getSubject());
$user_name = trim($user_name);
$priority = trim($priority);
$name_parts = explode(' ', $user_name);
list($first_name, $last_name) = $name_parts;
//mysql_query("insert into testing (date_added, content) values (now(), '" . mysql_real_escape_string($priority) . "')");
//BOF:mod 20120820
/*
//EOF:mod 20120820
$link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
mysql_select_db(DB_NAME, $link);
$query = "select id from healingcrystals_users where first_name='" . mysql_real_escape_string($first_name) . "' " . (!empty($last_name) ? " and last_name='" . mysql_real_escape_string($last_name) . "' " : "");
$result = mysql_query($query, $link);
if (mysql_num_rows($result)){
$info = mysql_fetch_assoc($result);
$user_id = $info['id'];
$task_meant_for_user = Users::findById($user_id);
$page_title = $task_meant_for_user->getName() . ' - Task List';
//echo $page_title . '<br/>';
$query2 = "select id from healingcrystals_project_objects where type='Page' and project_id='" . TASK_LIST_PROJECT_ID . "' and name='" . mysql_real_escape_string($page_title) . "'";
//echo $query2 . '<br/>';
$result2 = mysql_query($query2,$link);
if (mysql_num_rows($result2)){
$info2 = mysql_fetch_assoc($result2);
$page_id = $info2['id'];
} else {
$query3 = "select id from healingcrystals_project_objects where type='Category' and module='pages' and project_id='" . TASK_LIST_PROJECT_ID . "' and name='General'";
//echo $query3 . '<br/>';
$page_category = mysql_query($query3, $link);
$page_category_info = mysql_fetch_assoc($page_category);
$category_id = $page_category_info['id'];
//echo $category_id . '<br/>';
$page_data = array(
'type' => 'Page',
'module' => 'pages',
'visibility' => VISIBILITY_NORMAL,
'name' => $page_title,
'body' => 'Auto-generated Task List Page',
'integer_field_1' => '1',
);
//print_r($page_data);
//db_begin_work();
$page = new Page();
$page->setAttributes($page_data);
$page->setProjectId(TASK_LIST_PROJECT_ID);
$page->setCreatedBy($user);
$page->setState(STATE_VISIBLE);
$page->setParentId($category_id);
$page->save();
$page->ready();
$page_id = $page->getId();
}
}
mysql_close($link);
//BOF:mod 20120820
*/
//EOF:mod 20120820
$task = new Task();
$task->setProjectId($project->getId());
$task->setParentId($page_id);
$task->setParentType('Page');
$task->setCreatedBy($user);
$task->setCreatedOn($incoming_mail->getCreatedOn());
$task->setVisibility(VISIBILITY_NORMAL);
$task->setState(STATE_VISIBLE);
$task->setSource(OBJECT_SOURCE_EMAIL);
if (!empty($priority)) {
$constant_name = 'PRIORITY_' . strtoupper(str_replace(' ', '', $priority));
$priority_val = '';
$priority_val_set = false;
if (defined($constant_name)) {
switch ($constant_name) {
case 'PRIORITY_HOLD':
$priority_val = '-4';
$priority_val_set = true;
break;
//BOF:mod 20121107
/*
//EOF:mod 20121107
case 'PRIORITY_ONGOING':
$priority_val = '-3';
$priority_val_set = true;
break;
//BOF:mod 20121107
*/
//EOF:mod 20121107
//BOF:mod 20121107
/*
//EOF:mod 20121107
case 'PRIORITY_ONGOING':
$priority_val = '-3';
$priority_val_set = true;
//.........这里部分代码省略.........