Esempio n. 1
0
    echo isset($view_options[0]['pd_option_view_actions']) ? $view_options[0]['pd_option_view_actions'] : 1;
    ?>
" />
	<input type="hidden" name="opt_view_addtsks" value="<?php 
    echo isset($view_options[0]['pd_option_view_addtasks']) ? $view_options[0]['pd_option_view_addtasks'] : 1;
    ?>
" />
	<input type="hidden" name="opt_view_files" value="<?php 
    echo isset($view_options[0]['pd_option_view_files']) ? $view_options[0]['pd_option_view_files'] : 1;
    ?>
" />
</form>

<?php 
    $priorities = w2Pgetsysval('TaskPriority');
    $types = w2Pgetsysval('TaskType');
    $durntype = w2PgetSysVal('TaskDurationType');
    global $task_access;
    $task_access = is_array($task_access) ? $task_access : array();
    $extra = array(0 => '(none)', 1 => 'Milestone', 2 => 'Dynamic Task', 3 => 'Inactive Task');
    $sel_priorities = arraySelect($priorities, 'add_task_priority0', 'style="width:80px" class="text"', '0');
    $sel_types = arraySelect($types, 'add_task_type0', 'style="width:80px" class="text"', '');
    $sel_access = arraySelect($task_access, 'add_task_access0', 'style="width:80px" class="text"', '');
    $sel_extra = arraySelect($extra, 'add_task_extra0', 'style="width:80px" class="text"', '');
    $sel_durntype = arraySelect($durntype, 'add_task_durntype0', 'style="width:80px" class="text"', '', true);
    ?>
<script language="javascript">
// security improvement:
// some javascript functions may not appear on client side in case of user not having write permissions
// else users would be able to arbitrarily run 'bad' functions
<?php 
Esempio n. 2
0
<?php

/* $Id: vw_actions.php 2003 2011-07-24 01:46:02Z caseydk $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/tags/version2.4/modules/projectdesigner/vw_actions.php $ */
if (!defined('W2P_BASE_DIR')) {
    die('You should not access this file directly.');
}
global $task_access, $task_priority, $project_id;
$type = w2Pgetsysval('TaskType');
$stype = array('' => '(' . $AppUI->_('Type') . ')') + $type;
$priority = w2Pgetsysval('TaskPriority');
$spriority = array('' => '(' . $AppUI->_('Priority') . ')') + $priority;
$task_access = array(CTask::ACCESS_PUBLIC => $AppUI->_('Public'), CTask::ACCESS_PROTECTED => $AppUI->_('Protected'), CTask::ACCESS_PARTICIPANT => $AppUI->_('Participant'), CTask::ACCESS_PRIVATE => $AppUI->_('Private'));
$stask_access = array('' => '(' . $AppUI->_('Access') . ')') + $task_access;
$durntype = w2PgetSysval('TaskDurationType');
$sdurntype = array('' => '(' . $AppUI->_('Duration Type') . ')') + $durntype;
$sother = array('' => '(' . $AppUI->_('Other Operations') . ')', '1' => $AppUI->_('Mark Tasks as Finished'), '8' => $AppUI->_('Mark Tasks as Active'), '9' => $AppUI->_('Mark Tasks as Inactive'), '2' => $AppUI->_('Mark Tasks as Milestones'), '3' => $AppUI->_('Mark Tasks as Non Milestone'), '4' => $AppUI->_('Mark Tasks as Dynamic'), '5' => $AppUI->_('Mark Tasks as Non Dynamic'), '6' => $AppUI->_('Add Task Reminder'), '7' => $AppUI->_('Remove Task Reminder'), '10' => $AppUI->_('Remove Tasks Description'), '99' => $AppUI->_('Delete Tasks'));
//Pull all users
$users = $perms->getPermittedUsers();
$sowners = array('' => '(' . $AppUI->_('Task Owner') . ')') + $perms->getPermittedUsers('tasks');
$sassign = array('' => '(' . $AppUI->_('Assign User') . ')') + $perms->getPermittedUsers('tasks');
$sunassign = array('' => '(' . $AppUI->_('Unassign User') . ')') + $users;
$obj = new CTask();
$allowedTasks = $obj->getAllowedSQL($AppUI->user_id, 'tasks.task_id');
$obj->load($task_id);
$task_project = $project_id ? $project_id : ($obj->task_project ? $obj->task_project : 0);
// let's get root tasks
$q = new w2p_Database_Query();
$q->addQuery('task_id, task_name, task_end_date, task_start_date, task_milestone, task_parent, task_dynamic');
$q->addTable('tasks');
$q->addWhere('task_project = ' . (int) $task_project);
$q->addWhere('task_id = task_parent');
function showtask_pr(&$a, $level = 0, $today_view = false)
{
    global $AppUI, $w2Pconfig, $done, $query_string, $durnTypes, $userAlloc, $showEditCheckbox;
    global $task_access, $task_priority;
    $types = w2Pgetsysval('TaskType');
    $now = new w2p_Utilities_Date();
    $tf = $AppUI->getPref('TIMEFORMAT');
    $df = $AppUI->getPref('SHDATEFORMAT');
    $fdf = $df . ' ' . $tf;
    $perms =& $AppUI->acl();
    $show_all_assignees = $w2Pconfig['show_all_task_assignees'] ? true : false;
    $done[] = $a['task_id'];
    $start_date = intval($a['task_start_date']) ? new w2p_Utilities_Date($a['task_start_date']) : null;
    $end_date = intval($a['task_end_date']) ? new w2p_Utilities_Date($a['task_end_date']) : null;
    $last_update = isset($a['last_update']) && intval($a['last_update']) ? new w2p_Utilities_Date($a['last_update']) : null;
    // prepare coloured highlight of task time information
    $sign = 1;
    $style = '';
    if ($start_date) {
        if (!$end_date) {
            $end_date = new w2p_Utilities_Date('0000-00-00 00:00:00');
        }
        $days = $now->dateDiff($end_date) * $sign;
    }
    $s = '<tr>';
    // dots
    $s .= '<td nowrap width="20%">';
    for ($y = 0; $y < $level; $y++) {
        if ($y + 1 == $level) {
            $s .= '<img src="' . w2PfindImage('corner-dots.gif', $m) . '" width="16" height="12" border="0" alt="" />';
        } else {
            $s .= '<img src="' . w2PfindImage('shim.gif', $m) . '" width="16" height="12"  border="0" alt="" />';
        }
    }
    // name link
    $alt = mb_strlen($a['task_description']) > 80 ? mb_substr($a['task_description'], 0, 80) . '...' : $a['task_description'];
    // instead of the statement below
    $alt = mb_str_replace('"', "&quot;", $alt);
    $alt = mb_str_replace("\r", ' ', $alt);
    $alt = mb_str_replace("\n", ' ', $alt);
    $open_link = w2PshowImage('collapse.gif');
    if ($a['task_milestone'] > 0) {
        $s .= '&nbsp;<b>' . $a["task_name"] . '</b><!--</a>--> <img src="' . w2PfindImage('icons/milestone.gif', $m) . '" border="0" alt="" /></td>';
    } elseif ($a['task_dynamic'] == '1') {
        $s .= $open_link;
        $s .= '<strong>' . $a['task_name'] . '</strong>';
    } else {
        $s .= $a['task_name'];
    }
    // percent complete
    $s .= '<td align="right">' . (int) $a['task_percent_complete'] . '%</td>';
    $s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . ($start_date ? $start_date->format($df . ' ' . $tf) : '-') . '</td>';
    $s .= '</td>';
    $s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . ($end_date ? $end_date->format($df . ' ' . $tf) : '-') . '</td>';
    $s .= '</td>';
    $s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . ($last_update ? $last_update->format($df . ' ' . $tf) : '-') . '</td>';
    return $s;
}
function showtask_pd_ed(&$arr, $level = 0, $today_view = false)
{
    global $AppUI, $w2Pconfig, $done, $userAlloc, $showEditCheckbox;
    global $task_access, $PROJDESIGN_CONFIG, $m, $expanded;
    $durnTypes = w2PgetSysVal('TaskDurationType');
    //Check for Tasks Access
    $tmpTask = new CTask();
    $tmpTask->load($arr['task_id']);
    $canAccess = $tmpTask->canAccess();
    if (!$canAccess) {
        return false;
    }
    $htmlHelper = new w2p_Output_HTMLHelper($AppUI);
    $htmlHelper->df .= ' ' . $AppUI->getPref('TIMEFORMAT');
    $htmlHelper->stageRowData($arr);
    $types = w2Pgetsysval('TaskType');
    $show_all_assignees = $w2Pconfig['show_all_task_assignees'] ? true : false;
    $done[] = $arr['task_id'];
    // prepare coloured highlight of task time information
    $class = w2pFindTaskComplete($arr['task_start_date'], $arr['task_end_date'], $arr['task_percent_complete']);
    $jsTaskId = 'task_proj_' . $arr['task_project'] . '_level-' . $level . '-task_' . $arr['task_id'] . '_';
    if ($expanded) {
        $s = '<tr id="' . $jsTaskId . '" class="' . $class . '" onclick="select_row(\'selected_task\', \'' . $arr['task_id'] . '\', \'frm_tasks\')">';
        // edit icon
    } else {
        $s = '<tr id="' . $jsTaskId . '" class="' . $class . '" onclick="select_row(\'selected_task\', \'' . $arr['task_id'] . '\', \'frm_tasks\')" ' . ($level ? 'style="display:none"' : '') . '>';
        // edit icon
    }
    $s .= '<td class="data _edit">';
    $canEdit = $arr['task_represents_project'] ? false : true;
    if ($canEdit) {
        $s .= '<a href="?m=tasks&a=addedit&task_id=' . $arr['task_id'] . '">' . w2PshowImage('icons/pencil.gif', 12, 12) . '</a>';
    }
    $s .= '</td>';
    $s .= $htmlHelper->createCell('task_percent_complete', $arr['task_percent_complete']);
    $s .= $htmlHelper->createCell('task_priority', $arr['task_priority']);
    $s .= $htmlHelper->createCell('user_task_priority', $arr['user_task_priority']);
    $s .= $htmlHelper->createCell('other', mb_substr($task_access[$arr['task_access']], 0, 3));
    $s .= $htmlHelper->createCell('other', mb_substr($types[$arr['task_type']], 0, 3));
    // reminders set
    $s .= $htmlHelper->createCell('other', $arr['queue_id'] ? 'Yes' : '');
    $s .= $htmlHelper->createCell('other', $arr['task_status'] == -1 ? 'Yes' : '');
    // add log
    $s .= '<td align="center" nowrap="nowrap">';
    if ($arr['task_dynamic'] != 1 && 0 == $arr['task_represents_project']) {
        $s .= '<a href="?m=tasks&a=view&tab=1&project_id=' . $arr['task_project'] . '&task_id=' . $arr['task_id'] . '">' . w2PtoolTip('tasks', 'add work log to this task') . w2PshowImage('edit_add.png') . w2PendTip() . '</a>';
    }
    $s .= '</td>';
    // dots
    $s .= '<td style="width: ' . ($today_view ? '20%' : '50%') . '" class="data _name">';
    for ($y = 0; $y < $level; $y++) {
        if ($y + 1 == $level) {
            $image = w2PfindImage('corner-dots.gif', $m);
        } else {
            $image = w2PfindImage('shim.gif', $m);
        }
        $s .= '<img src="' . $image . '" width="16" height="12"  border="0" alt="" />';
    }
    // name link
    if ($arr['task_description']) {
        $s .= w2PtoolTip('Task Description', $arr['task_description'], true);
    }
    $jsTaskId = 'task_proj_' . $arr['task_project'] . '_level-' . $level . '-task_' . $arr['task_id'] . '_';
    $open_link = '<a href="javascript: void(0);" onclick="selected_task_' . $arr['task_id'] . '.checked=true"><img onclick="expand_collapse(\'' . $jsTaskId . '\', \'tblProjects\',\'\',' . ($level + 1) . ');" id="' . $jsTaskId . '_collapse" src="' . w2PfindImage('icons/collapse.gif', $m) . '" border="0" align="center" ' . (!$expanded ? 'style="display:none"' : '') . ' alt="" /><img onclick="expand_collapse(\'' . $jsTaskId . '\', \'tblProjects\',\'\',' . ($level + 1) . ');" id="' . $jsTaskId . '_expand" src="' . w2PfindImage('icons/expand.gif', $m) . '" border="0" align="center" ' . ($expanded ? 'style="display:none"' : '') . ' alt="" /></a>';
    $taskObj = new CTask();
    $taskObj->load($arr['task_id']);
    if (count($taskObj->getChildren())) {
        $is_parent = true;
    } else {
        $is_parent = false;
    }
    if ($arr['task_milestone'] > 0) {
        $s .= '&nbsp;<a href="./index.php?m=tasks&a=view&task_id=' . $arr['task_id'] . '" ><b>' . $arr['task_name'] . '</b></a> <img src="' . w2PfindImage('icons/milestone.gif', $m) . '" border="0" alt="" /></td>';
    } elseif ($arr['task_dynamic'] == '1' || $is_parent) {
        $s .= $open_link;
        if ($arr['task_dynamic'] == '1') {
            $s .= '&nbsp;<a href="./index.php?m=tasks&a=view&task_id=' . $arr['task_id'] . '" ><b><i>' . $arr['task_name'] . '</i></b></a></td>';
        } else {
            $s .= '&nbsp;<a href="./index.php?m=tasks&a=view&task_id=' . $arr['task_id'] . '" >' . $arr['task_name'] . '</a></td>';
        }
    } else {
        $s .= '&nbsp;<a href="./index.php?m=tasks&a=view&task_id=' . $arr['task_id'] . '" >' . $arr['task_name'] . '</a></td>';
    }
    if ($arr['task_description']) {
        $s .= w2PendTip();
    }
    // task description
    if ($PROJDESIGN_CONFIG['show_task_descriptions']) {
        $s .= '<td align="justified">' . $arr['task_description'] . '</td>';
    }
    // task owner
    $s .= $htmlHelper->createCell('task_owner', $arr['contact_name']);
    $s .= $htmlHelper->createCell('task_start_datetime', $arr['task_start_date']);
    // duration or milestone
    $s .= $htmlHelper->createCell('task_duration', $arr['task_duration'] . ' ' . mb_substr($AppUI->_($durnTypes[$arr['task_duration_type']]), 0, 1));
    $s .= $htmlHelper->createCell('task_end_datetime', $arr['task_end_date']);
    if (isset($arr['task_assigned_users']) && ($assigned_users = $arr['task_assigned_users'])) {
        $a_u_tmp_array = array();
        if ($show_all_assignees) {
            $s .= '<td align="left">';
            foreach ($assigned_users as $val) {
                $aInfo = '<a href="?m=users&a=view&user_id=' . $val['user_id'] . '"';
                $aInfo .= 'title="' . (w2PgetConfig('check_overallocation') ? $AppUI->_('Extent of Assignment') . ':' . $userAlloc[$val['user_id']]['charge'] . '%; ' . $AppUI->_('Free Capacity') . ':' . $userAlloc[$val['user_id']]['freeCapacity'] . '%' : '') . '">';
                $aInfo .= $val['contact_name'] . ' (' . $val['perc_assignment'] . '%)</a>';
                $a_u_tmp_array[] = $aInfo;
            }
            $s .= join(', ', $a_u_tmp_array);
            $s .= '</td>';
        } else {
            $s .= '<td align="left" nowrap="nowrap">';
            $s .= '<a href="?m=users&a=view&user_id=' . $assigned_users[0]['user_id'] . '"';
            $s .= 'title="' . (w2PgetConfig('check_overallocation') ? $AppUI->_('Extent of Assignment') . ':' . $userAlloc[$assigned_users[0]['user_id']]['charge'] . '%; ' . $AppUI->_('Free Capacity') . ':' . $userAlloc[$assigned_users[0]['user_id']]['freeCapacity'] . '%' : '') . '">';
            $s .= $assigned_users[0]['contact_name'] . ' (' . $assigned_users[0]['perc_assignment'] . '%)</a>';
            if ($arr['assignee_count'] > 1) {
                $id = $arr['task_id'];
                $s .= '<a href="javascript: void(0);"  onclick="toggle_users(\'users_' . $id . '\');" title="' . join(', ', $a_u_tmp_array) . '">(+' . ($arr['assignee_count'] - 1) . ')</a>';
                $s .= '<span style="display: none" id="users_' . $id . '">';
                $a_u_tmp_array[] = $assigned_users[0]['user_username'];
                for ($i = 1, $i_cmp = count($assigned_users); $i < $i_cmp; $i++) {
                    $a_u_tmp_array[] = $assigned_users[$i]['user_username'];
                    $s .= '<br /><a href="?m=users&a=view&user_id=';
                    $s .= $assigned_users[$i]['user_id'] . '" title="' . (w2PgetConfig('check_overallocation') ? $AppUI->_('Extent of Assignment') . ':' . $userAlloc[$assigned_users[$i]['user_id']]['charge'] . '%; ' . $AppUI->_('Free Capacity') . ':' . $userAlloc[$assigned_users[$i]['user_id']]['freeCapacity'] . '%' : '') . '">';
                    $s .= $assigned_users[$i]['contact_name'] . ' (' . $assigned_users[$i]['perc_assignment'] . '%)</a>';
                }
                $s .= '</span>';
            }
            $s .= '</td>';
        }
    } else {
        // No users asigned to task
        $s .= '<td class="data">-</td>';
    }
    // Assignment checkbox
    if ($showEditCheckbox && 0 == $arr['task_represents_project']) {
        $s .= '<td class="data"><input type="checkbox" onclick="select_box(\'multi_check\', ' . $arr['task_id'] . ',\'project_' . $arr['task_project'] . '_level-' . $level . '-task_' . $arr['task_id'] . '_\',\'frm_tasks\')" onfocus="is_check=true;" onblur="is_check=false;" id="selected_task_' . $arr['task_id'] . '" name="selected_task" value="' . $arr['task_id'] . '"/></td>';
    }
    $s .= '</tr>';
    return $s;
}