示例#1
0
 /**
  * Returns (safe) HTML which displays a field to edit a value
  * @access public
  * @param bool $use_default use default field value or not
  * @param bool $lock lock the field depending on the users perms ornot
  * @param array $task task data
  * @param array $add_options add options to the select?
  * @param array $attrs add attributes to the select
  * @return string
  */
 function edit($use_default = true, $lock = false, $task = array(), $add_options = array(), $attrs = array(), $prefix = '')
 {
     global $user, $proj;
     if ($use_default) {
         $task['field' . $this->id] = $this->prefs['default_value'];
     } else {
         if (!isset($task['field' . $this->id])) {
             $task['field' . $this->id] = '';
         }
     }
     // determine whether or not to lock inputs
     $lock = $lock && $this->prefs['force_default'] && (count($task) > 3 && !$user->can_edit_task($task) || !$user->perms('modify_all_tasks'));
     $html = '';
     switch ($this->prefs['field_type']) {
         case FIELD_LIST:
             if (!$this->prefs['list_id']) {
                 return '';
             }
             $html .= sprintf('<select id="%sfield%d" name="%sfield%d%s" %s ', $prefix, $this->id, $prefix, $this->id, isset($attrs['multiple']) ? '[]' : '', join_attrs($attrs));
             $html .= tpl_disableif($lock) . '>';
             $html .= tpl_options(array_merge($add_options, $proj->get_list($this->prefs, $task['field' . $this->id])), Req::val('field' . $this->id, $task['field' . $this->id]));
             $html .= '</select>';
             break;
         case FIELD_DATE:
             $attrs = array();
             if ($lock) {
                 $attrs = array('readonly' => 'readonly');
             }
             $html .= tpl_datepicker($prefix . 'field' . $this->id, '', Req::val('field' . $this->id, $task['field' . $this->id]), $attrs);
             break;
         case FIELD_TEXT:
             $html .= sprintf('<input type="text" class="text" id="%sfield%d" name="%sfield%d" value="%s"/>', $prefix, $this->id, $prefix, $this->id, Filters::noXSS(Req::val('field' . $this->id, $task['field' . $this->id])));
             break;
         case FIELD_USER:
             $html .= tpl_userselect($prefix . 'field' . $this->id, Req::val('field' . $this->id, $task['field' . $this->id]));
             break;
     }
     return $html;
 }
示例#2
0
/**
 * Creates the options for a date format select
 * @selected The format that should by selected by default
 * @return html formatted options for a select tag
**/
function tpl_date_formats($selected, $detailed = false)
{
    $time = time();
    if (!$detailed) {
        $dateFormats = array('%d.%m.%Y' => strftime('%d.%m.%Y', $time), '%d.%m.%y' => strftime('%d.%m.%y', $time), '%Y.%m.%d' => strftime('%Y.%m.%d', $time), '%y.%m.%d' => strftime('%y.%m.%d', $time), '%d-%m-%Y' => strftime('%d-%m-%Y', $time), '%d-%m-%y' => strftime('%d-%m-%y', $time), '%Y-%m-%d' => strftime('%Y-%m-%d', $time), '%y-%m-%d' => strftime('%y-%m-%d', $time), '%d %b %Y' => strftime('%d %b %Y', $time), '%d %B %Y' => strftime('%d %B %Y', $time), '%b %d %Y' => strftime('%b %d %Y', $time), '%B %d %Y' => strftime('%B %d %Y', $time));
    } else {
        $dateFormats = array('%d.%m.%Y %H:%M' => strftime('%d.%m.%Y %H:%M', $time), '%d.%m.%y %H:%M' => strftime('%d.%m.%y %H:%M', $time), '%d.%m.%Y %I:%M %p' => strftime('%d.%m.%Y %I:%M %p', $time), '%d.%m.%y %I:%M %p' => strftime('%d.%m.%y %I:%M %p', $time), '%Y.%m.%d %H:%M' => strftime('%Y.%m.%d %H:%M', $time), '%y.%m.%d %H:%M' => strftime('%y.%m.%d %H:%M', $time), '%Y.%m.%d %I:%M %p' => strftime('%Y.%m.%d %I:%M %p', $time), '%y.%m.%d %I:%M %p' => strftime('%y.%m.%d %I:%M %p', $time), '%d-%m-%Y %H:%M' => strftime('%d-%m-%Y %H:%M', $time), '%d-%m-%y %H:%M' => strftime('%d-%m-%y %H:%M', $time), '%d-%m-%Y %I:%M %p' => strftime('%d-%m-%Y %I:%M %p', $time), '%d-%m-%y %I:%M %p' => strftime('%d-%m-%y %I:%M %p', $time), '%Y-%m-%d %H:%M' => strftime('%Y-%m-%d %H:%M', $time), '%y-%m-%d %H:%M' => strftime('%y-%m-%d %H:%M', $time), '%Y-%m-%d %I:%M %p' => strftime('%Y-%m-%d %I:%M %p', $time), '%y-%m-%d %I:%M %p' => strftime('%y-%m-%d %I:%M %p', $time), '%d %b %Y %H:%M' => strftime('%d %b %Y %H:%M', $time), '%d %B %Y %H:%M' => strftime('%d %B %Y %H:%M', $time), '%d %b %Y %I:%M %p' => strftime('%d %b %Y %I:%M %p', $time), '%d %B %Y %I:%M %p' => strftime('%d %B %Y %I:%M %p', $time), '%b %d %Y %H:%M' => strftime('%b %d %Y %H:%M', $time), '%B %d %Y %H:%M' => strftime('%B %d %Y %H:%M', $time), '%b %d %Y %I:%M %p' => strftime('%b %d %Y %I:%M %p', $time), '%B %d %Y %I:%M %p' => strftime('%B %d %Y %I:%M %p', $time));
    }
    return tpl_options($dateFormats, $selected);
}
示例#3
0
$prev = Filters::noXSS(str_replace("'", "\\'", tpl_draw_cell($task, $field, '<span class="%s %s">%s</span>')));
$id = sprintf('id="task%d_%s" name="task%d_%s"', $task['task_id'], $field, $task['task_id'], $field);
switch ($field) {
    case 'summary':
        echo '<input type="text" class="text" ' . $id . ' value="' . Filters::noXSS($task['item_summary']) . '" />';
        break;
    case 'project':
        echo '<select ' . $id . '>' . tpl_options($fs->projects, $task['project_id']) . '
		      </select>';
        break;
    case 'progress':
        $arr = array();
        for ($i = 0; $i <= 100; $i += 10) {
            $arr[$i] = $i . '%';
        }
        echo '<select ' . $id . '>' . tpl_options($arr, $task['percent_complete']) . '
              </select>';
        break;
    case 'assignedto':
        // additional permission check is needed
        if (!$user->perms('edit_assignments')) {
            header('HTTP/1.1 400 Bad Request');
            exit;
        }
        $field = 'assigned_to';
        $page = new FSTpl();
        $page->assign('id', 'task' . $task['task_id'] . '_' . $field);
        $list = $db->x->getCol('SELECT u.user_name
                                  FROM {assigned} a, {users} u
                                 WHERE a.user_id = u.user_id AND task_id = ?
                                 ORDER BY u.user_name DESC', null, $task['task_id']);