예제 #1
0
 /**
  * Fetch the element
  *
  * @param   string  $name          Element name
  * @param   string  $value         Element value
  * @param   object  &$node         XMLElement node object containing the settings for the element
  * @param   string  $control_name  Control name
  * @return  string
  * @since   1.3.1
  */
 public function fetchElement($name, $value, &$node, $control_name)
 {
     $db = \App::get('db');
     $html = array();
     $html[] = '<select name="' . $control_name . '[' . $name . ']" id="' . $control_name . $name . '">';
     include_once PATH_CORE . DS . 'components' . DS . 'com_support' . DS . 'tables' . DS . 'status.php';
     $sr = new \Components\Support\Tables\Status($db);
     $status = $sr->find('list', array('sort' => 'open', 'sort_Dir' => 'DESC'));
     $html[] = '<option value=""' . ($value === '' || $value === null ? ' selected="selected"' : '') . '>--</option>';
     $html[] = '<option value="0"' . ($value === 0 || $value === '0' ? ' selected="selected"' : '') . '>open: New</option>';
     $switched = false;
     foreach ($status as $anode) {
         if (!$anode->open && !$switched) {
             $html[] = '<option value="-1"' . ($value == -1 ? ' selected="selected"' : '') . '>closed: No resolution</option>';
             $switched = true;
         }
         $html[] = '<option value="' . $anode->id . '"' . ($value == $anode->id ? ' selected="selected"' : '') . '>' . ($anode->open ? 'open: ' : 'closed: ') . stripslashes($anode->title) . '</option>';
     }
     $html[] = '</select>';
     return implode("\n", $html);
 }
예제 #2
0
 /**
  * Display a list of tickets
  *
  * @apiMethod GET
  * @apiUri    /support/list
  * @apiParameter {
  * 		"name":          "limit",
  * 		"description":   "Number of result to return.",
  * 		"type":          "integer",
  * 		"required":      false,
  * 		"default":       25
  * }
  * @apiParameter {
  * 		"name":          "limitstart",
  * 		"description":   "Number of where to start returning results.",
  * 		"type":          "integer",
  * 		"required":      false,
  * 		"default":       0
  * }
  * @apiParameter {
  * 		"name":          "search",
  * 		"description":   "A word or phrase to search for.",
  * 		"type":          "string",
  * 		"required":      false,
  * 		"default":       ""
  * }
  * @apiParameter {
  * 		"name":          "sort",
  * 		"description":   "Field to sort results by.",
  * 		"type":          "string",
  * 		"required":      false,
  *      "default":       "created",
  * 		"allowedValues": "created, id, state"
  * }
  * @apiParameter {
  * 		"name":          "sort_Dir",
  * 		"description":   "Direction to sort results by.",
  * 		"type":          "string",
  * 		"required":      false,
  * 		"default":       "desc",
  * 		"allowedValues": "asc, desc"
  * }
  * @return    void
  */
 public function listTask()
 {
     $this->requiresAuthentication();
     if (!$this->acl->check('read', 'tickets')) {
         throw new Exception(Lang::txt('Not authorized'), 403);
     }
     $obj = new \Components\Support\Tables\Ticket($this->database);
     $filters = array('limit' => Request::getInt('limit', 25), 'start' => Request::getInt('limitstart', 0), 'search' => Request::getVar('search', ''), 'sort' => Request::getWord('sort', 'created'), 'sortdir' => strtoupper(Request::getWord('sort_Dir', 'DESC')), 'group' => Request::getVar('group', ''), 'reportedby' => Request::getVar('reporter', ''), 'owner' => Request::getVar('owner', ''), 'type' => Request::getInt('type', 0), 'status' => strtolower(Request::getWord('status', '')), 'tag' => Request::getWord('tag', ''));
     $filters['opened'] = $this->_toTimestamp(Request::getVar('opened', ''));
     $filters['closed'] = $this->_toTimestamp(Request::getVar('closed', ''));
     $response = new stdClass();
     $response->success = true;
     $response->total = 0;
     $response->tickets = array();
     // Get a list of all statuses
     $sobj = new \Components\Support\Tables\Status($this->database);
     $statuses = array();
     if ($data = $sobj->find('all')) {
         foreach ($data as $status) {
             $statuses[$status->id] = $status;
         }
     }
     // Get a count of tickets
     $response->total = $obj->getTicketsCount($filters);
     if ($response->total) {
         $response->tickets = $obj->getTickets($filters);
         foreach ($response->tickets as $i => $ticket) {
             $owner = $ticket->owner;
             $response->tickets[$i]->owner = new stdClass();
             $response->tickets[$i]->owner->username = $ticket->username;
             $response->tickets[$i]->owner->name = $ticket->owner_name;
             $response->tickets[$i]->owner->id = $ticket->owner_id;
             unset($response->tickets[$i]->owner_name);
             unset($response->tickets[$i]->owner_id);
             unset($response->tickets[$i]->username);
             $response->tickets[$i]->reporter = new stdClass();
             $response->tickets[$i]->reporter->name = $ticket->name;
             $response->tickets[$i]->reporter->username = $ticket->login;
             $response->tickets[$i]->reporter->email = $ticket->email;
             unset($response->tickets[$i]->name);
             unset($response->tickets[$i]->login);
             unset($response->tickets[$i]->email);
             $status = $response->tickets[$i]->status;
             $response->tickets[$i]->status = new stdClass();
             if (!$status) {
                 $response->tickets[$i]->status->alias = 'new';
                 $response->tickets[$i]->status->title = 'New';
             } else {
                 $response->tickets[$i]->status->alias = isset($statuses[$status]) ? $statuses[$status]->alias : 'unknown';
                 $response->tickets[$i]->status->title = isset($statuses[$status]) ? $statuses[$status]->title : 'unknown';
             }
             $response->tickets[$i]->status->id = $status;
             $response->tickets[$i]->url = str_replace('/api', '', rtrim(Request::base(), '/') . '/' . ltrim(Route::url('index.php?option=com_support&controller=tickets&task=tickets&id=' . $response->tickets[$i]->id), '/'));
         }
     }
     $this->send($response);
 }
예제 #3
0
								<th scope="row"><?php 
echo Lang::txt('COM_SUPPORT_STATS_NO_RESOLUTION');
?>
</th>
								<td><?php 
echo isset($res[0]) ? $res[0] : '0';
?>
</td>
								<td><?php 
echo isset($res[0]) ? $res[0] / $total : '0';
?>
</td>
							</tr>
						<?php 
$sr = new \Components\Support\Tables\Status($database);
$resolutions = $sr->find('list', array('open' => 0));
$cls = 'odd';
$data = array("{label: '" . Lang::txt('COM_SUPPORT_STATS_NO_RESOLUTION') . "', data: " . (isset($res[0]) ? $res[0] / $total : '0') . ", color: '" . $colors[0] . "'}");
$i = 1;
foreach ($resolutions as $resolution) {
    $r = "{label: '" . $this->escape(addslashes($resolution->title)) . "', data: ";
    $r .= isset($res[$resolution->id]) ? round($res[$resolution->id] / $total * 100, 2) : 0;
    $r .= ", color: '" . $colors[$i] . "'}";
    $data[] = $r;
    $cls = $cls == 'even' ? 'odd' : 'even';
    ?>
							<tr class="<?php 
    echo $cls;
    ?>
">
								<th scope="row"><?php 
예제 #4
0
 /**
  * Create a new record
  *
  * @return    object
  */
 public function getConditions()
 {
     $conditions = new stdClass();
     $conditions->owner = $this->_expression(array($this->_operator('=', 'is', true), $this->_operator('!=', 'is not', false), $this->_operator('LIKE \'%$1%\'', 'contains', false), $this->_operator('LIKE \'$1%\'', 'starts with', false), $this->_operator('LIKE \'%$1\'', 'ends with', false), $this->_operator('NOT LIKE \'%$1%\'', 'does not contain', false), $this->_operator('NOT LIKE \'$1%\'', 'does not start with', false), $this->_operator('NOT LIKE \'%$1\'', 'does not end with', false)), 'text');
     // Groups
     $items = array($this->_value('*', Lang::txt('(any of mine)'), true));
     if ($xgroups = \Hubzero\User\Helper::getGroups(User::get('id'), 'members')) {
         foreach ($xgroups as $xgroup) {
             $xgroup->description = trim($xgroup->description) ?: $xgroup->cn;
             $items[] = $this->_value($xgroup->cn, stripslashes($this->escape($xgroup->description)), false);
         }
     }
     $conditions->group = $this->_expression(array($this->_operator('=', 'is', true), $this->_operator('!=', 'is not', false), $this->_operator('LIKE \'%$1%\'', 'contains', false), $this->_operator('LIKE \'$1%\'', 'starts with', false), $this->_operator('LIKE \'%$1\'', 'ends with', false), $this->_operator('NOT LIKE \'%$1%\'', 'does not contain', false), $this->_operator('NOT LIKE \'$1%\'', 'does not start with', false), $this->_operator('NOT LIKE \'%$1\'', 'does not end with', false)), $items);
     $conditions->login = $this->_expression(array($this->_operator('=', 'is', true), $this->_operator('!=', 'is not', false), $this->_operator('LIKE \'%$1%\'', 'contains', false), $this->_operator('LIKE \'$1%\'', 'starts with', false), $this->_operator('LIKE \'%$1\'', 'ends with', false), $this->_operator('NOT LIKE \'%$1%\'', 'does not contain', false), $this->_operator('NOT LIKE \'$1%\'', 'does not start with', false), $this->_operator('NOT LIKE \'%$1\'', 'does not end with', false)), 'text');
     $conditions->id = $this->_expression(array($this->_operator('=', 'is', true), $this->_operator('!=', 'is not', false), $this->_operator('lt', 'less than', false), $this->_operator('gt', 'grater than', false), $this->_operator('=lt', 'less than or equal to', false), $this->_operator('gt=', 'greater than or equal to', false)), 'text');
     $conditions->report = $this->_expression(array($this->_operator('=', 'is', false), $this->_operator('!=', 'is not', false), $this->_operator('LIKE \'%$1%\'', 'contains', true), $this->_operator('LIKE \'$1%\'', 'starts with', false), $this->_operator('LIKE \'%$1\'', 'ends with', false), $this->_operator('NOT LIKE \'%$1%\'', 'does not contain', false), $this->_operator('NOT LIKE \'$1%\'', 'does not start with', false), $this->_operator('NOT LIKE \'%$1\'', 'does not end with', false)), 'text');
     $conditions->open = $this->_expression(array($this->_operator('=', 'is', true), $this->_operator('!=', 'is not', false)), array($this->_value('1', 'open', true), $this->_value('0', 'closed', false)));
     $sr = new \Components\Support\Tables\Status($this->database);
     $status = $sr->find('list', array('sort' => 'open', 'sort_Dir' => 'DESC'));
     $items = array();
     $items[] = $this->_value(0, $this->escape('open: New'), true);
     if (isset($status) && is_array($status)) {
         $switched = false;
         foreach ($status as $anode) {
             if (!$anode->open && !$switched) {
                 $items[] = $this->_value(-1, $this->escape('closed: No resolution'), false);
                 $switched = true;
             }
             $items[] = $this->_value($anode->id, $this->escape(($anode->open ? 'open: ' : 'closed: ') . stripslashes($anode->title)), false);
         }
     }
     $conditions->status = $this->_expression(array($this->_operator('=', 'is', true), $this->_operator('!=', 'is not', false)), $items);
     $conditions->created = $this->_expression(array($this->_operator('=', 'on', true), $this->_operator('lt', 'before', false), $this->_operator('gt', 'after', false)), 'text');
     $conditions->closed = $this->_expression(array($this->_operator('=', 'on', true), $this->_operator('lt', 'before', false), $this->_operator('gt', 'after', false)), 'text');
     $conditions->tag = $this->_expression(array($this->_operator('=', 'is', true), $this->_operator('!=', 'is not', false)), 'text');
     $conditions->type = $this->_expression(array($this->_operator('=', 'is', true), $this->_operator('!=', 'is not', false)), array($this->_value('0', 'user submitted', true), $this->_value('1', 'automatic', false), $this->_value('3', 'tool', false)));
     $severities = Utilities::getSeverities($this->config->get('severities'));
     $items = 'text';
     if (isset($severities) && is_array($severities)) {
         $items = array();
         foreach ($severities as $severity) {
             $sel = false;
             if ($severity == 'normal') {
                 $sel = true;
             }
             $items[] = $this->_value($severity, $severity, $sel);
         }
     }
     $conditions->severity = $this->_expression(array($this->_operator('=', 'is', true), $this->_operator('!=', 'is not', false)), $items);
     $sc = new Category($this->database);
     $categories = $sc->find('list');
     $items = 'text';
     if (isset($categories) && is_array($categories)) {
         $items = array();
         foreach ($categories as $anode) {
             $sel = false;
             $items[] = $this->_value($this->escape($anode->alias), $this->escape(stripslashes($anode->title)), $sel);
         }
     }
     $conditions->category = $this->_expression(array($this->_operator('=', 'is', true), $this->_operator('!=', 'is not', false)), $items);
     return $conditions;
 }