本文整理汇总了PHP中Task::getVisibleById方法的典型用法代码示例。如果您正苦于以下问题:PHP Task::getVisibleById方法的具体用法?PHP Task::getVisibleById怎么用?PHP Task::getVisibleById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Task
的用法示例。
在下文中一共展示了Task::getVisibleById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: projViewFiles
function projViewFiles()
{
global $PH;
global $auth;
require_once confGet('DIR_STREBER') . "render/render_wiki.inc.php";
### get current project ###
$id = getOnePassedId('prj', 'projects_*');
$project = Project::getVisibleById($id);
if (!$project || !$project->id) {
$PH->abortWarning(__("invalid project-id"));
return;
}
### define from-handle ###
$PH->defineFromHandle(array('prj' => $project->id));
## is viewed by user ##
$project->nowViewedByUser();
## next milestone ##
$next = $project->getNextMilestone();
$page = new Page();
$page->crumbs = build_project_crumbs($project);
$page->options = build_projView_options($project);
$page->cur_tab = 'projects';
$page->title = $project->name;
$page->title_minor = __("Downloads");
if ($project->status == STATUS_TEMPLATE) {
$page->type = __("Project Template");
} else {
if ($project->status >= STATUS_COMPLETED) {
$page->type = __("Inactive Project");
} else {
$page->type = __("Project", "Page Type");
}
}
### render title ###
echo new PageHeader();
echo new PageContentOpen();
measure_stop('init2');
measure_start('info');
$block = new PageBlock(array('id' => 'support'));
$block->render_blockStart();
echo "<div class=text>";
if ($task = Task::getVisibleById(3645)) {
echo wikifieldAsHtml($task, 'description');
}
echo "</div>";
$block->render_blockEnd();
echo new PageContentClose();
echo new PageHtmlEnd();
}
示例2: taskAjax
/**
* test function for development @ingroup pages
*
* the output of this function could be requested with jquery like:
*
* $('#sideboard div').load('index.php?go=taskAjax',{
* go: 'taskAjax',
* tsk: id
* });
*/
function taskAjax()
{
if ($task_id = intval(get('tsk'))) {
require_once "render/render_wiki.inc.php";
### headline ###
$editable = false;
# flag, if this task can be edited
if ($task = Task::getEditableById($task_id)) {
$editable = true;
} else {
if (!($task = Task::getVisibleById($task_id))) {
echo "Failure";
return;
}
}
echo "<h3>" . asHtml($task->name) . "</h3>";
echo wikifieldAsHtml($task, 'description');
}
}
示例3: projViewTasks
/**
* list tasks of a project @ingroup pages
*/
function projViewTasks()
{
global $PH;
global $auth;
### get current project ###
$id = getOnePassedId('prj', 'projects_*');
if (!($project = Project::getVisibleById($id))) {
$PH->abortWarning("invalid project-id");
return;
}
### get upcoming or selected milestone ###
/*
pixtur: 2008-09-60
WARNING: Selecting a milestone directly to limit the viewed tasks
does not work because editing a task with a milestone will compromize
the following task list. I have no idea, why this code is in here,
or weather it is required at all.
*/
$for_milestone = intval(get("for_milestone"));
$milestone = NULL;
if ($for_milestone) {
$milestone = Task::getVisibleById($for_milestone);
}
#if($milestone= $project->getNextMilestone()) {
# $for_milestone= $milestone->id;
#}
$presets = array('all_tasks' => array('name' => __('all'), 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'min' => STATUS_NEW, 'max' => STATUS_CLOSED)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'tree'))), 'open_tasks' => array('name' => __('open'), 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_NEW, STATUS_OPEN, STATUS_BLOCKED, STATUS_COMPLETED), 'min' => STATUS_NEW, 'max' => STATUS_COMPLETED)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'my_open_tasks' => array('name' => __('my open'), 'filter_empty_folders' => true, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_NEW, STATUS_OPEN, STATUS_BLOCKED), 'min' => STATUS_NEW, 'max' => STATUS_BLOCKED), 'assigned_to' => array('id' => 'assigned_to', 'visible' => true, 'active' => true, 'value' => $auth->cur_user->id)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list')), 'new_task_options' => array('task_assign_to_0' => $auth->cur_user->id)), 'next_milestone' => array('name' => __('for milestone'), 'filter_empty_folders' => true, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => false, 'active' => true, 'values' => array(STATUS_NEW, STATUS_OPEN, STATUS_BLOCKED, STATUS_COMPLETED), 'min' => STATUS_NEW, 'max' => STATUS_COMPLETED), 'for_milestone' => array('id' => 'for_milestone', 'visible' => true, 'active' => true, 'value' => $for_milestone)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list')), 'new_task_options' => array('for_milestone' => $for_milestone)), 'needs_feedback' => array('name' => __('modified'), 'filter_empty_folders' => true, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_COMPLETED), 'min' => STATUS_NEW, 'max' => STATUS_COMPLETED), 'not_modified_by' => $auth->cur_user->id), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'approve_tasks' => array('name' => __('needs approval'), 'filter_empty_folders' => true, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_COMPLETED), 'min' => STATUS_COMPLETED, 'max' => STATUS_COMPLETED)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'without_milestone' => array('name' => __('without milestone'), 'filter_empty_folders' => true, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_COMPLETED), 'min' => STATUS_NEW, 'max' => STATUS_COMPLETED), 'for_milestone' => array('id' => 'for_milestone', 'visible' => true, 'active' => true, 'value' => 0)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))), 'closed_tasks' => array('name' => __('closed'), 'filter_empty_folders' => false, 'filters' => array('task_status' => array('id' => 'task_status', 'visible' => true, 'active' => true, 'values' => array(STATUS_APPROVED, STATUS_CLOSED), 'min' => STATUS_APPROVED, 'max' => STATUS_CLOSED)), 'list_settings' => array('tasks' => array('hide_columns' => array(''), 'style' => 'list'))));
## set preset location ##
$preset_location = 'projViewTasks';
$preset_id = 'open_tasks';
# default value
if ($tmp_preset_id = get('preset')) {
if (isset($presets[$tmp_preset_id])) {
$preset_id = $tmp_preset_id;
}
### set cookie
setcookie('STREBER_projViewTasks_preset', $preset_id, time() + 60 * 60 * 24 * 30, '', '', 0);
} else {
if ($tmp_preset_id = get('STREBER_projViewTasks_preset')) {
if (isset($presets[$tmp_preset_id])) {
$preset_id = $tmp_preset_id;
}
}
}
if ($milestone) {
### create from handle ###
$PH->defineFromHandle(array('prj' => $project->id, 'preset_id' => $preset_id, 'for_milestone' => $milestone->id));
} else {
### create from handle ###
$PH->defineFromHandle(array('prj' => $project->id, 'preset_id' => $preset_id));
}
$page = new Page();
### init known filters for preset ###
$list = new ListBlock_tasks(array('active_block_function' => 'tree'));
$list->filters[] = new ListFilter_category_in(array('value' => array(TCATEGORY_TASK, TCATEGORY_BUG)));
$preset = $presets[$preset_id];
foreach ($preset['filters'] as $f_name => $f_settings) {
switch ($f_name) {
case 'task_status':
$list->filters[] = new ListFilter_status_min(array('value' => $f_settings['min']));
$list->filters[] = new ListFilter_status_max(array('value' => $f_settings['max']));
break;
case 'assigned_to':
$list->filters[] = new ListFilter_assigned_to(array('value' => $f_settings['value']));
break;
case 'for_milestone':
$list->filters[] = new ListFilter_for_milestone(array('value' => $f_settings['value']));
break;
case 'not_modified_by':
$list->filters[] = new ListFilter_not_modified_by(array('value' => $f_settings['value']));
break;
default:
trigger_error("Unknown filter setting {$f_name}", E_USER_WARNING);
break;
}
}
$filter_empty_folders = isset($preset['filter_empty_folders']) && $preset['filter_empty_folders'] ? true : NULL;
$page->cur_tab = 'projects';
$page->crumbs = build_project_crumbs($project);
$page->options = build_projView_options($project);
$page->title = $project->name;
if (isset($preset['name'])) {
$page->title_minor = $preset['name'];
if ($preset_id == 'next_milestone' && isset($milestone) && isset($milestone->name)) {
$page->title_minor = __('Milestone') . ' ' . $milestone->name;
}
} else {
$page->title_minor = __("Tasks");
}
if ($project->status == STATUS_TEMPLATE) {
$page->type = __("Project Template");
} else {
if ($project->status >= STATUS_COMPLETED) {
$page->type = __("Inactive Project");
} else {
$page->type = __("Project", "Page Type");
}
//.........这里部分代码省略.........
示例4: effortShowAsCSV
/**
* export selected efforts as a CSV ready for copy and paste into a spread-sheet @ingroup pages
**
*/
function effortShowAsCSV()
{
global $PH;
global $g_effort_status_names;
$effort_ids = getPassedIds('effort', 'efforts_*');
if (!$effort_ids) {
$PH->abortWarning(__("Select some efforts(s) to show"));
exit;
}
$efforts = array();
$different_fields = array();
$edit_fields = array('status', 'pub_level', 'task');
foreach ($effort_ids as $id) {
if ($effort = Effort::getEditableById($id)) {
$efforts[] = $effort;
### check project for first task
if (count($efforts) == 1) {
### make sure all are of same project ###
if (!($project = Project::getVisibleById($effort->project))) {
$PH->abortWarning('could not get project');
}
} else {
if ($effort->project != $efforts[0]->project) {
$PH->abortWarning(__("For editing all efforts must be of same project."));
}
foreach ($edit_fields as $field_name) {
if ($effort->{$field_name} != $efforts[0]->{$field_name}) {
$different_fields[$field_name] = true;
}
}
}
}
}
$page = new Page(array('use_jscalendar' => true));
$page->cur_tab = 'projects';
$page->options[] = new naviOption(array('target_id' => 'effortEdit'));
$page->type = __("Edit multiple efforts", "Page title");
$page->title = sprintf(__("%s efforts for copy and pasting into a spread-sheet", "Page title"), count($efforts));
echo new PageHeader();
echo new PageContentOpen();
$block = new PageBlock(array('id' => 'functions', 'reduced_header' => true));
$block->render_blockStart();
$format = "[Date][Weekday][Task][Comment][Duration]";
preg_match_all("/\\[(.*?)\\]/", $format, $matches);
$overallDuration = 0;
echo "<textarea style='width:96%; height:300px;'>";
echo join("\t", $matches[1]) . "\n";
foreach ($efforts as $e) {
preg_match_all("/\\[(.*?)\\]/", $format, $matches);
$separator = "";
foreach ($matches[1] as $matchedFormat) {
echo $separator;
switch ($matchedFormat) {
case "Date":
echo gmstrftime("%Y-%m-%d", strToGMTime($e->time_start));
break;
case "Weekday":
echo gmstrftime("%a", strToGMTime($e->time_start));
break;
case "Task":
if ($t = Task::getVisibleById($e->task)) {
echo $t->name;
}
break;
case "Comment":
echo $e->name;
break;
case "Duration":
$durationInMinutes = round((strToGMTime($e->time_end) - strToGMTime($e->time_start)) / 60, 0);
$roundUpTo15 = ceil($durationInMinutes / 15) * 15 / 60;
$overallDuration += $roundUpTo15;
echo number_format($roundUpTo15, 2, $dec_point = ',', '');
break;
}
$separator = "\t";
}
echo "\n";
}
echo "</textarea>";
echo "<br>";
echo __("Overall Duration:") . $overallDuration . "h";
$block->render_blockEnd();
echo new PageContentClose();
echo new PageHtmlEnd();
exit;
}
示例5: render_tr
function render_tr(&$item, $style = "")
{
global $PH;
$str_url = "";
$str_name = "";
$str_addon = "";
$isDone = "";
$html_details = "";
$link = "";
if ($type = $item->type) {
switch ($type) {
case ITEM_TASK:
require_once "db/class_task.inc.php";
if ($task = Task::getVisibleById($item->id)) {
$str_name = asHtml($task->name);
$str_url = $PH->getUrl('taskView', array('tsk' => $task->id));
if ($task->status >= STATUS_COMPLETED) {
$isDone = "class=isDone";
}
if ($prj = Project::getVisibleById($task->project)) {
$link = $PH->getLink('projView', $prj->getShort(), array('prj' => $prj->id));
$html_details .= __('in', 'very short for IN folder...') . ' ' . $link;
if ($tmp = $task->getFolderLinks()) {
$html_details .= ' > ' . $tmp;
}
}
}
break;
case ITEM_COMMENT:
require_once "db/class_comment.inc.php";
if ($comment = Comment::getVisibleById($item->id)) {
$str_name = asHtml($comment->name);
if ($comment->comment) {
$str_url = $PH->getUrl('taskView', array('tsk' => $comment->task));
$str_addon = __("(on comment)");
} else {
if ($comment->task) {
$str_url = $PH->getUrl('taskView', array('tsk' => $comment->task));
$str_addon = __("(on task)");
} else {
$str_url = $PH->getUrl('projView', array('prj' => $comment->project));
$str_addon = __("(on project)");
}
}
}
break;
case ITEM_PERSON:
require_once "db/class_person.inc.php";
if ($person = Person::getVisibleById($item->id)) {
$str_name = asHtml($person->name);
$str_url = $PH->getUrl('personView', array('person' => $person->id));
}
break;
case ITEM_EFFORT:
require_once "db/class_effort.inc.php";
if ($e = Effort::getVisibleById($item->id)) {
$str_name = asHtml($e->name);
$str_url = $PH->getUrl('effortEdit', array('effort' => $e->id));
}
if ($prj = Project::getVisibleById($e->project)) {
$link = $PH->getLink('projView', $prj->getShort(), array('prj' => $prj->id));
$html_details .= __('in', 'very short for IN folder...') . ' ' . $link;
}
break;
case ITEM_FILE:
require_once "db/class_file.inc.php";
if ($f = File::getVisibleById($item->id)) {
$str_name = asHtml($f->org_filename);
$str_url = $PH->getUrl('fileView', array('file' => $f->id));
if ($f->status >= STATUS_COMPLETED) {
$isDone = "class=isDone";
}
if ($prj = Project::getVisibleById($f->project)) {
$link = $PH->getLink('projView', $prj->getShort(), array('prj' => $prj->id));
$html_details .= __('in', 'very short for IN folder...') . ' ' . $link;
}
}
break;
case ITEM_PROJECT:
require_once "db/class_project.inc.php";
if ($prj = Project::getVisibleById($item->id)) {
$str_name = asHtml($prj->name);
$str_url = $PH->getUrl('projView', array('prj' => $prj->id));
if ($prj->status >= STATUS_COMPLETED) {
$isDone = "class=isDone";
}
}
break;
case ITEM_COMPANY:
require_once "db/class_company.inc.php";
if ($c = Company::getVisibleById($item->id)) {
$str_name = asHtml($c->name);
$str_url = $PH->getUrl('companyView', array('company' => $c->id));
}
break;
case ITEM_VERSION:
require_once "db/class_task.inc.php";
if ($tsk = Task::getVisibleById($item->id)) {
$str_name = asHtml($tsk->name);
$str_url = $PH->getUrl('taskView', array('tsk' => $tsk->id));
//.........这里部分代码省略.........
示例6: getObjectById
/**
* returns visible object of correct type by an itemId
*
* this is useful, eg. if you when to access common parameters like name,
* regardless of the object's type.
*
* DbProjectItem::getById() would only load to basic fields. Getting the
* complete date required check for type.
*
* @NOTE: This function causes a awkward dependency to classes derived from
* DbProjectItem. It's somehow weird, that this method is placed inside the
* parent class.
*/
public static function getObjectById($id)
{
$id = intval($id);
if (!($item = DbProjectItem::getById($id))) {
return NULL;
}
if ($type = $item->type) {
switch ($type) {
case ITEM_TASK:
require_once "db/class_task.inc.php";
$item_full = Task::getVisibleById($item->id);
break;
case ITEM_COMMENT:
require_once "db/class_comment.inc.php";
$item_full = Comment::getVisibleById($item->id);
break;
case ITEM_PERSON:
require_once "db/class_person.inc.php";
$item_full = Person::getVisibleById($item->id);
break;
case ITEM_EFFORT:
require_once "db/class_effort.inc.php";
$item_full = Effort::getVisibleById($item->id);
break;
case ITEM_FILE:
require_once "db/class_file.inc.php";
$item_full = File::getVisibleById($item->id);
break;
case ITEM_PROJECT:
require_once "db/class_project.inc.php";
$item_full = Project::getVisibleById($item->id);
break;
case ITEM_COMPANY:
require_once "db/class_company.inc.php";
$item_full = Company::getVisibleById($item->id);
break;
case ITEM_VERSION:
require_once "db/class_task.inc.php";
$item_full = Task::getVisibleById($item->id);
break;
default:
$item_full = NULL;
}
return $item_full;
}
}
示例7: render_tr
function render_tr(&$obj, $style = "")
{
global $PH;
if (!isset($obj) || !$obj instanceof Effort) {
trigger_error("ListBlock->render_tr() called without valid object", E_USER_WARNING);
return;
}
$sum = 0.0;
$diff_str = '';
$estimated_str = '';
$str = '';
$percent = '';
/*if($obj->getStatus()){
$sum_task = Effort::getSumEfforts(array('project'=>$obj->project, 'task'=>$obj->task, 'status'=>$obj->status));
}
else{*/
$sum_task = Effort::getSumEfforts(array('project' => $obj->project, 'task' => $obj->task));
#}
if ($sum_task) {
$sum = $sum_task;
}
if ($task = Task::getVisibleById($obj->task)) {
$estimated = $task->estimated;
$estimated_max = $task->estimated_max;
if ($estimated_max) {
$estimated_str = round($estimated_max / 60 / 60, 1) . "h";
$diff = $estimated_max - $sum;
} else {
$estimated_str = round($estimated / 60 / 60, 1) . "h";
$diff = $estimated - $sum;
}
if ($diff) {
$diff_str = "(" . round($diff / 60 / 60, 1) . "h)";
}
$str = $estimated_str . " / " . round($sum / 60 / 60, 1) . "h {$diff_str}";
$percent = __('Completion:') . " " . $task->completion . "%";
}
print "<td class=nowrap title='" . __("Relation between estimated time and booked efforts") . "'>{$str}<br><span class='sub who'>{$percent}</span></td>";
}
示例8: taskEditSubmit
//.........这里部分代码省略.........
#$new_assignment->insert();
$link_items[] = $new_assignment;
}
}
if ($task->isOfCategory(array(TCATEGORY_VERSION, TCATEGORY_MILESTONE))) {
if ($is_released = get('task_is_released')) {
if (!is_null($is_released)) {
$task->is_released = $is_released;
}
}
}
### pub level ###
if ($pub_level = get('task_pub_level')) {
if ($task->id) {
if ($pub_level > $task->getValidUserSetPublicLevels()) {
$PH->abortWarning('invalid data', ERROR_RIGHTS);
}
}
#else {
# #@@@ check for person create rights
#}
$task->pub_level = $pub_level;
}
### check project ###
if ($task->id == 0) {
if (!($task->project = get('task_project'))) {
$PH->abortWarning("task requires project to be set");
}
}
### get parent_task ###
$is_ok = true;
$parent_task = NULL;
if ($task->parent_task) {
$parent_task = Task::getVisibleById($task->parent_task);
}
### validate ###
if (!$task->name) {
new FeedbackWarning(__("Task requires name"));
$task->fields['name']->required = true;
$task->fields['name']->invalid = true;
$is_ok = false;
} else {
if ($task->id == 0) {
$other_tasks = array();
if ($parent_task) {
$other_tasks = Task::getAll(array('project' => $project->id, 'parent_task' => $parent_task->id, 'status_min' => STATUS_NEW, 'status_max' => STATUS_CLOSED, 'visible_only' => false));
} else {
$other_tasks = Task::getAll(array('project' => $project->id, 'parent_task' => 0, 'status_min' => STATUS_NEW, 'status_max' => STATUS_CLOSED, 'visible_only' => false));
}
foreach ($other_tasks as $ot) {
if (!strcasecmp($task->name, $ot->name)) {
$is_ok = false;
new FeedbackWarning(sprintf(__('Task called %s already exists'), $ot->getLink(false)));
break;
}
}
}
}
### automatically close resolved tasks ###
if ($task->resolve_reason && $task->status < STATUS_COMPLETED) {
$task->status = STATUS_COMPLETED;
new FeedbackMessage(sprintf(__('Because task is resolved, its status has been changed to completed.')));
}
### Check if resolved tasks should be completed ###
if ($task->resolved_version != 0 && $task->status < STATUS_COMPLETED) {
new FeedbackWarning(sprintf(__('Task has resolved version but is not completed?')));
示例9: getNextMilestone
public function getNextMilestone()
{
global $auth;
$prefix = confGet('DB_TABLE_PREFIX');
$dbh = new DB_Mysql();
$sth = $dbh->prepare("SELECT i.id\r\n from {$prefix}item i, {$prefix}task t\r\n WHERE\r\n t.category = " . TCATEGORY_MILESTONE . "\r\n AND t.id= i.id\r\n AND i.state = '" . ITEM_STATE_OK . "'\r\n AND i.project= {$this->id}\r\n AND t.status < " . STATUS_COMPLETED . "\r\n ORDER BY t.name, t.id\r\n ")->execute();
$tmp = $sth->fetchall_assoc();
if ($tmp) {
$tmp_values = array_values($tmp[0]);
$next_milestone = Task::getVisibleById($tmp_values[0]);
return $next_milestone;
} else {
return false;
}
}
示例10: renderListCsv
function renderListCsv($list = NULL)
{
if (!count($list)) {
return;
}
## header ##
$ids = array();
$count = 0;
foreach ($list[0]->fields as $field_name => $field) {
if ($field->export) {
switch ($field->type) {
case 'FieldString':
case 'FieldInt':
case 'FieldDatetime':
case 'FieldText':
$ids[] = $field_name;
$count++;
break;
case 'FieldInternal':
if ($field_name == 'task') {
$ids[] = 'task_id';
$ids[] = 'task_name';
} else {
if ($field_name == 'person') {
$ids[] = 'person_id';
$ids[] = 'person_name';
} else {
if ($field_name == 'project') {
$ids[] = 'project_id';
$ids[] = 'project_name';
} else {
$ids[] = $field_name;
}
}
}
break;
default:
break;
}
}
}
## list ##
$values = array();
foreach ($list as $row) {
foreach ($list[0]->fields as $field_name => $field) {
if ($field->export) {
switch ($field->type) {
case 'FieldText':
case 'FieldString':
$values[] = $this->cleanForCSV($row->{$field_name});
break;
case 'FieldInternal':
if ($field_name == 'task') {
$values[] = $row->{$field_name};
if ($task = Task::getVisibleById($row->{$field_name})) {
$values[] = $this->cleanForCSV($task->name);
} else {
$values[] = '';
}
} else {
if ($field_name == 'person') {
$values[] = $row->{$field_name};
if ($person = Person::getVisibleById($row->{$field_name})) {
$values[] = $this->cleanForCSV($person->name);
} else {
$values[] = '-';
}
} else {
if ($field_name == 'project') {
$values[] = $row->{$field_name};
if ($project = Project::getVisibleById($row->{$field_name})) {
$values[] = $this->cleanForCSV($project->name);
} else {
$values[] = '';
}
} else {
$values[] = $row->{$field_name};
}
}
}
break;
case 'FieldInt':
case 'FieldDatetime':
#$values[] = addslashes($row->$field_name,"\0..\37");
$values[] = $row->{$field_name};
break;
default:
break;
}
}
}
}
## export function ##
exportToCSV($ids, $values);
}
示例11: getForQuery
static function getForQuery($search_query, $project = NULL)
{
$count_overall = 0;
$results = array();
global $PH;
require_once confGet('DIR_STREBER') . "db/class_company.inc.php";
$args = array('order_str' => NULL, 'has_id' => NULL, 'search' => $search_query);
foreach ($companies = Company::getAll($args) as $company) {
$rate = RATE_TYPE_COMPANY;
$rate *= SearchResult::RateItem($company);
$rate *= SearchResult::RateTitle($company, $search_query);
$results[] = new SearchResult(array('name' => $company->name, 'rating' => $rate, 'type' => __('Company'), 'jump_id' => 'companyView', 'jump_params' => array('company' => $company->id, 'q' => $search_query), 'item' => $company));
}
require_once confGet('DIR_STREBER') . "db/class_person.inc.php";
foreach ($people = Person::getPeople(array('search' => $search_query)) as $person) {
$rate = RATE_TYPE_PERSON;
$rate *= SearchResult::RateItem($person);
$rate *= SearchResult::RateTitle($person, $search_query);
$results[] = new SearchResult(array('name' => $person->name, 'rating' => $rate, 'type' => __('Person'), 'jump_id' => 'personView', 'jump_params' => array('person' => $person->id, 'q' => $search_query), 'item' => $person));
}
require_once confGet('DIR_STREBER') . "db/class_project.inc.php";
$projects = Project::getAll(array('status_min' => 0, 'status_max' => 10, 'search' => $search_query));
if ($projects) {
foreach ($projects as $project) {
$rate = RATE_TYPE_PROJECT;
if ($project->status == STATUS_TEMPLATE) {
$rate *= RATE_PROJECT_IS_TEMPLATE;
} else {
if ($project->status < STATUS_COMPLETED) {
$rate *= RATE_PROJECT_IS_OPEN;
} else {
$rate *= RATE_PROJECT_IS_CLOSED;
}
}
if ($diz = SearchResult::getExtract($project, $search_query)) {
$rate *= RATE_IN_DETAILS;
}
### status ###
global $g_status_names;
$status = isset($g_status_names[$project->status]) ? $g_status_names[$project->status] : '';
if ($project->status > STATUS_COMPLETED) {
$rate *= RATE_TASK_STATUS_CLOSED;
} else {
if ($project->status >= STATUS_COMPLETED) {
$rate *= RATE_TASK_STATUS_COMPLETED;
}
}
### for company ###
$html_location = '';
if ($company = Company::getVisibleById($project->company)) {
$html_location = __('for') . ' ' . $company->getLink();
}
$rate *= SearchResult::RateItem($project);
$rate *= SearchResult::RateTitle($project, $search_query);
$results[] = new SearchResult(array('name' => $project->name, 'rating' => $rate, 'item' => $project, 'type' => __('Project'), 'jump_id' => 'projView', 'jump_params' => array('prj' => $project->id, 'q' => $search_query), 'extract' => $diz, 'status' => $status, 'html_location' => $html_location));
}
}
require_once confGet('DIR_STREBER') . "db/class_task.inc.php";
$order_str = get('sort_' . $PH->cur_page->id . "_tasks");
$tasks = Task::getAll(array('order_by' => $order_str, 'search' => $search_query, 'status_min' => STATUS_UPCOMING, 'status_max' => STATUS_CLOSED));
if ($tasks) {
foreach ($tasks as $task) {
$rate = RATE_TYPE_TASK;
$rate *= SearchResult::RateItem($task);
$rate *= SearchResult::RateTitle($task, $search_query);
if ($task->category == TCATEGORY_FOLDER) {
$rate *= RATE_TASK_IS_FOLDER;
}
if ($diz = SearchResult::getExtract($task, $search_query)) {
$rate *= RATE_IN_DETAILS;
}
global $g_status_names;
$status = isset($g_status_names[$task->status]) ? $g_status_names[$task->status] : '';
if ($task->status > STATUS_COMPLETED) {
$rate *= RATE_TASK_STATUS_CLOSED;
} else {
if ($task->status >= STATUS_COMPLETED) {
$rate *= RATE_TASK_STATUS_COMPLETED;
}
}
if ($project = Project::getVisibleById($task->project)) {
$prj = $project->getLink();
} else {
$prj = '';
}
$html_location = __('in') . " <b>{$prj}</b> > " . $task->getFolderLinks();
$is_done = $task->status < STATUS_COMPLETED ? false : true;
$results[] = new SearchResult(array('name' => $task->name, 'rating' => $rate, 'extract' => $diz, 'item' => $task, 'type' => $task->getLabel(), 'status' => $status, 'html_location' => $html_location, 'is_done' => $is_done, 'jump_id' => 'taskView', 'jump_params' => array('tsk' => $task->id, 'q' => $search_query)));
}
}
require_once confGet('DIR_STREBER') . "db/class_comment.inc.php";
$comments = Comment::getAll(array('search' => $search_query));
if ($comments) {
foreach ($comments as $comment) {
$rate = RATE_TYPE_COMMENT;
$rate *= SearchResult::RateItem($comment);
$rate *= SearchResult::RateTitle($comment, $search_query);
if ($diz = SearchResult::getExtract($comment, $search_query)) {
$rate *= RATE_IN_DETAILS;
}
//.........这里部分代码省略.........
示例12: TasksMoveToFolder
/**
* to tasks to folder...
*
* @ingroup pages
*
* NOTE: this works either...
* - directly by passing a target folder in 'folder' or 'folders_*'
* - in two steps, whereas
* - the passed task-ids are keept as hidden fields,
* - a list with folders in been rendered
* - a flag 'from_selection' is set
* - after submit, the kept tasks are moved to 'folders_*'
*
* Also check the java-script part for the ajax-functionality in js/task-move.js
*
*
*
*/
function TasksMoveToFolder()
{
global $PH;
$task_ids = getPassedIds('tsk', 'tasks_*');
if (!$task_ids) {
$PH->abortWarning(__("Select some tasks to move"));
exit;
}
/**
* by default render list of folders...
*/
$target_task_id = -1;
/**
* ...but, if folder was given, directly move tasks...
*/
$folder_ids = getPassedIds('folder', 'folders_*');
if (count($folder_ids) == 1) {
if ($folder_task = Task::getVisibleById($folder_ids[0])) {
$target_task_id = $folder_task->id;
}
} else {
if (get('from_selection')) {
$target_task_id = 0;
# if no folders was selected, move tasks to project root
}
}
if ($target_task_id != -1) {
$target_project_id = getOnePassedId("target_prj");
foreach ($task_ids as $task_id) {
_moveTask($task_id, $target_project_id, $target_task_id);
}
### return to from-page? ###
if (!$PH->showFromPage()) {
$PH->show('home');
}
exit;
}
/**
* build page and folder lists...
*/
if (!($task = Task::getVisibleById($task_ids[0]))) {
$PH->abortWarning("could not get task", ERROR_BUG);
}
$project_id = getOnePassedId($name = 'prj', $wild = false, $abort_on_failure = false);
if (!$project_id) {
$project_id = $task->project;
}
if (!($project = Project::getVisibleById($project_id))) {
$PH->abortWarning("task without project?", ERROR_BUG);
}
$page = new Page(array('use_jscalendar' => false));
$page->cur_tab = 'projects';
$page->type = __("Edit tasks");
$page->title = $project->name;
$page->title_minor = __("Select folder to move tasks into");
$page->extra_header_html .= '<script type="text/javascript" src="js/task-move.js' . "?v=" . confGet('STREBER_VERSION') . '"></script>';
$page->extra_onload_js .= 'getAjaxListProjectFolders(' . $project_id . ');initMoveTasksUI();';
$page->crumbs = build_project_crumbs($project);
$page->options[] = new NaviOption(array('target_id' => 'tasksMoveToFolder'));
echo new PageHeader();
echo new PageContentOpen();
### write project-selector ###
$prj_names = array();
if ($projects = Project::getAll()) {
foreach ($projects as $p) {
$prj_names[$p->id] = $p->name;
}
## assigne new person to ptoject ##
$dropdown = new Form_Dropdown('target_prj', __('Target project', 'form label'), array_flip($prj_names), $project_id);
echo $dropdown->render();
}
### write tasks as hidden entry ###
foreach ($task_ids as $id) {
if ($task = Task::getEditableById($id)) {
echo "<input type=hidden name='tasks_{$id}_chk' value='1'>";
}
}
### target container for lazy fetch with ajax ###
echo "<div id='folder_list'></div>";
echo "<input type=hidden name='from_selection' value='1'>";
# keep flag to ungroup tasks
$button_name = __("Move items");
//.........这里部分代码省略.........
示例13: render_quickedit
public function render_quickedit($task)
{
global $PH;
$editable = false;
### make sure it's editable ###
if (Task::getEditableById($task->id)) {
$editable = true;
} else {
if (!Task::getVisibleById($task->id)) {
return false;
}
}
### get parent project ####
if (!($project = Project::getVisibleById($task->project))) {
return;
}
$this->render_blockStart();
require_once confGet('DIR_STREBER') . 'render/render_form.inc.php';
global $REPRODUCIBILITY_VALUES;
global $g_prio_names;
global $g_status_names;
$form = new PageForm();
$form->button_cancel = false;
$form->add($tab_group = new Page_TabGroup());
$tab_group->add($tab = new Page_Tab("comment", __("Add comment")));
### Comment ###
$comment_name = '';
$comment = new Comment(array('id' => 0, 'name' => $comment_name));
$tab->add($comment->fields['name']->getFormElement($comment, __('Comment')));
$e = $comment->fields['description']->getFormElement($comment);
$e->rows = 8;
$tab->add($e);
### request feedback
$tab->add(buildRequestFeedbackInput($project));
### update ###
if ($editable && $task->isOfCategory(array(TCATEGORY_TASK, TCATEGORY_BUG))) {
$tab_group->add($tab = new Page_Tab("update", __("Update")));
#$tab->add(new Form_Dropdown('task_for_milestone', __('For Milestone'), $project->buildPlannedForMilestoneList(), $task->for_milestone));
$tab->add(new Form_DropdownGrouped('task_for_milestone', __('For Milestone'), $project->buildPlannedForMilestoneList(), $task->for_milestone));
$tab->add(new Form_DropdownGrouped('task_resolved_version', __('Resolved in'), $project->buildResolvedInList(), $task->resolved_version));
global $g_resolve_reason_names;
$tab->add(new Form_Dropdown('task_resolve_reason', __('Resolve reason'), array_flip($g_resolve_reason_names), $task->resolve_reason));
### for existing tasks, get already assigned
if ($task->id) {
$assigned_people = $task->getAssignedPeople();
} else {
trigger_error("view a task with zero id?");
}
$team = array(__('- select person -') => 0);
### create team-list ###
foreach ($project->getPeople() as $p) {
$team[$p->name] = $p->id;
}
### create drop-down-lists ###
$count_new = 0;
$count_all = 0;
if (isset($assigned_people)) {
foreach ($assigned_people as $ap) {
if (!($p = Person::getVisibleById($ap->id))) {
continue;
# skip if invalid person
}
if ($task->id) {
$tab->add(new Form_Dropdown('task_assigned_to_' . $ap->id, __("Assigned to"), $team, $ap->id));
} else {
$tab->add(new Form_Dropdown('task_assign_to_' . $count_new, __("Assign to"), $team, $ap->id));
$count_new++;
}
$count_all++;
unset($team[$ap->name]);
}
}
### add empty drop-downlist for new assignments ###
$str_label = $count_all == 0 ? __("Assign to", "Form label") : __("Also assign to", "Form label");
$tab->add(new Form_Dropdown("task_assign_to_{$count_new}", $str_label, $team, 0));
if (!$task->isMilestoneOrVersion()) {
$tab->add(new Form_Dropdown('task_prio', __("Prio", "Form label"), array_flip($g_prio_names), $task->prio));
}
$ar = array(__('undefined') => 0, __('30 min') => 30 * 60, __('1 h') => 60 * 60, __('2 h') => 2 * 60 * 60, __('4 h') => 4 * 60 * 60, __('1 Day') => 1 * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('2 Days') => 2 * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('3 Days') => 3 * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('4 Days') => 4 * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('1 Week') => 1 * confGet('WORKDAYS_PER_WEEK') * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('2 Weeks') => 2 * confGet('WORKDAYS_PER_WEEK') * confGet('WORKHOURS_PER_DAY') * 60 * 60, __('3 Weeks') => 3 * confGet('WORKDAYS_PER_WEEK') * confGet('WORKHOURS_PER_DAY') * 60 * 60);
$tab->add(new Form_Dropdown('task_estimated', __("Estimated time"), $ar, $task->estimated));
$tab->add(new Form_Dropdown('task_estimated_max', __("Estimated worst case"), $ar, $task->estimated_max));
$ar = array(__('undefined') => -1, '0%' => 0, '10%' => 10, '20%' => 20, '30%' => 30, '40%' => 40, '50%' => 50, '60%' => 60, '70%' => 70, '80%' => 80, '90%' => 90, '95%' => 95, '98%' => 98, '99%' => 99, '100%' => 100);
$tab->add(new Form_Dropdown('task_completion', __("Completed"), $ar, $task->completion));
$tab->add($task->fields['parent_task']->getFormElement($task));
$st = array();
foreach ($g_status_names as $s => $n) {
if ($s >= STATUS_NEW) {
$st[$s] = $n;
}
}
if ($task->isMilestoneOrVersion()) {
unset($st[STATUS_NEW]);
}
$tab->add(new Form_Dropdown('task_status', "Status", array_flip($st), $task->status));
}
/**
* to reduce spam, enforce captcha test for guests
*/
global $auth;
if ($auth->cur_user->id == confGet('ANONYMOUS_USER')) {
//.........这里部分代码省略.........
示例14: FilesMoveToFolder
/**
* move files to folder...
*
* NOTE: this works either...
* - directly by passing a target folder in 'folder' or 'folders_*'
* - in two steps, whereas
* - the passed task-ids are keept as hidden fields,
* - a list with folders is been rendered
* - a flag 'from_selection' is set
* - after submit, the kept tasks are moved to 'folders_*'
*
*/
function FilesMoveToFolder()
{
global $PH;
$file_ids = getPassedIds('file', 'files_*');
if (!$file_ids) {
$PH->abortWarning(__("Select some files to move"));
exit;
}
/**
* by default render list of folders...
*/
$target_id = -1;
/**
* ...but, if folder was given, directly move files...
*/
$folder_ids = getPassedIds('folder', 'folders_*');
if (count($folder_ids) == 1) {
if ($folder_task = Task::getVisibleById($folder_ids[0])) {
$target_id = $folder_task->id;
}
} else {
if (get('from_selection')) {
$target_id = 0;
}
}
if ($target_id != -1) {
if ($target_id != 0) {
if (!($target_task = Task::getEditableById($target_id))) {
$PH->abortWarning(__("insufficient rights"));
}
### get path of target to check for cycles ###
$parent_tasks = $target_task->getFolder();
$parent_tasks[] = $target_task;
} else {
$parent_tasks = array();
}
$count = 0;
foreach ($file_ids as $id) {
if ($file = File::getEditableById($id)) {
$file->parent_item = $target_id;
$file->update();
} else {
$PH->messages[] = sprintf(__("Can not edit file %s"), $file->name);
}
}
### return to from-page? ###
if (!$PH->showFromPage()) {
$PH->show('home');
}
exit;
}
#else if($target_id != -1) {
# $PH->abortWarning(__("insufficient rights to edit any of the selected items"));
#}
/**
* build page folder lists...
*/
### get project ####
if (!($file = File::getVisibleById($file_ids[0]))) {
$PH->abortWarning("could not get file", ERROR_BUG);
}
if (!($project = Project::getVisibleById($file->project))) {
$PH->abortWarning("file without project?", ERROR_BUG);
}
$page = new Page(array('use_jscalendar' => false, 'autofocus_field' => 'company_name'));
$page->cur_tab = 'projects';
$page->type = __("Edit files");
$page->title = "{$project->name}";
$page->title_minor = __("Select folder to move files into");
$page->crumbs = build_project_crumbs($project);
$page->options[] = new NaviOption(array('target_id' => 'filesMoveToFolder'));
echo new PageHeader();
echo new PageContentOpen();
### write files as hidden entry ###
foreach ($file_ids as $id) {
if ($file = File::getEditableById($id)) {
echo "<input type=hidden name='files_{$id}_chk' value='1'>";
}
}
require_once confGet('DIR_STREBER') . 'lists/list_tasks.inc.php';
$list = new ListBlock_tasks();
$list->query_options['show_folders'] = true;
#$list->query_options['folders_only']= true;
$list->query_options['project'] = $project->id;
$list->groupings = NULL;
$list->block_functions = NULL;
$list->id = 'folders';
$list->no_items_html = __('No folders available');
//.........这里部分代码省略.........
示例15: getChangeLines
static function getChangeLines($query_options)
{
global $PH;
global $auth;
fillMissingValues($query_options, array('alive_only' => false));
$date_compare = isset($query_options['date_min']) ? $query_options['date_min'] : "0000-00-00";
/**
* get list of items touched by other people
*/
$changed_items = DbProjectItem::getAll($query_options);
/**
* go through list
*/
$changes = array();
foreach ($changed_items as $i) {
$change_type = NULL;
if (!isset($query_options['project'])) {
$project = Project::getVisibleById($i->project);
} else {
$project = NULL;
}
/**
* get item-change-type depeding on dates
*/
if ($i->deleted >= $i->modified) {
$change_type = ITEM_DELETED;
} else {
if ($i->modified > $i->created) {
$change_type = ITEM_MODIFIED;
} else {
$change_type = ITEM_NEW;
}
}
/**
* build up change-list
*/
switch ($change_type) {
case ITEM_NEW:
if ($i->type == ITEM_TASK) {
if (!($task = Task::getVisibleById($i->id))) {
continue;
}
if ($assigned_people = $task->getAssignedPeople()) {
$tmp = array();
foreach ($assigned_people as $ap) {
$tmp[] = $ap->getLink();
}
$html_assignment = __('to', 'very short for assigned tasks TO...') . ' ' . implode(', ', $tmp);
} else {
$html_assignment = '';
}
$html_details = '';
if ($tmp = $task->getFolderLinks(true, $project)) {
$html_details .= __('in', 'very short for IN folder...') . ' ' . $tmp;
}
if ($task->prio != PRIO_NORMAL && $task->prio != PRIO_UNDEFINED) {
global $g_prio_names;
$html_details .= ' / ' . $g_prio_names[$task->prio];
}
$change = new ChangeLine(array('item' => $task, 'person_by' => $i->created_by, 'timestamp' => $i->created, 'item_id' => $i->id, 'html_what' => '<span class=new>' . __('new') . ' ' . $task->getLabel() . '</span>', 'txt_what' => __('new') . ' ' . $task->getLabel(), 'type' => ChangeLine::NEW_TASK, 'html_assignment' => $html_assignment, 'html_details' => $html_details));
$changes[] = $change;
} else {
if ($i->type == ITEM_FILE) {
require_once confGet('DIR_STREBER') . 'db/class_file.inc.php';
if ($file = File::getVisibleById($i->id)) {
$change = new ChangeLine(array('item' => $file, 'person_by' => $i->created_by, 'timestamp' => $i->created, 'item_id' => $i->id, 'html_what' => __('New file'), 'txt_what' => __('New file'), 'type' => ChangeLine::NEW_FILE, 'html_details' => $file->name));
$changes[] = $change;
}
}
}
break;
case ITEM_MODIFIED:
$timestamp_last_change = $date_compare;
# make sure we use the last occured change type
/**
* modified tasks
*/
$type = ChangeLine::UPDATED;
if ($i->type == ITEM_TASK) {
if (!($task = Task::getVisibleById($i->id))) {
continue;
}
if ($assigned_people = $task->getAssignedPeople()) {
$tmp = array();
foreach ($assigned_people as $ap) {
$tmp[] = $ap->getLink();
}
$html_assignment = __('to', 'very short for assigned tasks TO...') . ' ' . implode(', ', $tmp);
} else {
$html_assignment = '';
}
$html_details = '';
if ($tmp = $task->getFolderLinks(true, $project)) {
$html_details .= __('in', 'very short for IN folder...') . ' ' . $tmp;
}
$txt_what = $html_what = __('modified');
$type = ChangeLine::UPDATED;
$html_comment = '';
if ($comments = Comment::getAll(array('person' => $i->modified_by, 'task' => $task->id, 'date_min' => $timestamp_last_change, 'order_by' => 'created ASC'))) {
$last_comment = $comments[count($comments) - 1];
//.........这里部分代码省略.........