/**
  * Up
  **/
 public function up()
 {
     if ($this->db->tableExists('#__support_tickets')) {
         $this->db->setQuery("SELECT id, report FROM `#__support_tickets` WHERE `created` < '2013-01-01 00:00:00' AND `report` LIKE '%\\\\\\'%' AND `type`=0 AND `open`=1");
         if ($records = $this->db->loadObjectList()) {
             $path = PATH_CORE . DS . 'components' . DS . 'com_support' . DS . 'tables' . DS . 'ticket.php';
             if (!file_exists($path)) {
                 $path = PATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_support' . DS . 'tables' . DS . 'ticket.php';
             }
             include_once $path;
             // Update the query
             foreach ($records as $record) {
                 if (class_exists('SupportTicket')) {
                     $row = new SupportTicket($this->db);
                 } else {
                     $row = new \Components\Support\Tables\Ticket($this->db);
                 }
                 $row->bind($record);
                 $row->report = str_replace('&quot;', '"', $row->report);
                 $row->report = stripslashes($row->report);
                 $row->report = html_entity_decode($row->report);
                 $row->summary = substr($row->report, 0, 70);
                 if (strlen($row->summary) >= 70) {
                     $row->summary .= '...';
                 }
                 $row->store();
             }
         }
     }
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 3
0
        $name = '<a rel="profile" href="' . Route::url('index.php?option=com_members&id=' . $submitter->get('id')) . '">' . $this->escape(stripslashes($this->row->get('name'))) . ' (' . $this->escape(stripslashes($this->row->get('login'))) . ')</a>';
        $unknown = 0;
    } else {
        $name = '<a rel="email" href="mailto:' . $this->row->get('email') . '">';
        $name .= $this->row->get('login') ? $this->escape(stripslashes($this->row->get('name'))) . ' (' . $this->escape(stripslashes($this->row->get('login'))) . ')' : $this->escape(stripslashes($this->row->get('name')));
        $name .= '</a>';
    }
} else {
    $name = '<a rel="email" href="mailto:' . $this->row->get('email') . '">' . $this->escape(stripslashes($this->row->get('name'))) . '</a>';
}
$prev = null;
$next = null;
$sq = new \Components\Support\Tables\Query($this->database);
$sq->load($this->filters['show']);
if ($sq->conditions) {
    $tbl = new \Components\Support\Tables\Ticket($this->database);
    $sq->query = $sq->getQuery($sq->conditions);
    $this->filters['sort'] = $sq->sort;
    $this->filters['sortdir'] = $sq->sort_dir;
    if ($rows = $tbl->getRecords($sq->query, $this->filters)) {
        foreach ($rows as $key => $row) {
            if ($row->id == $this->row->get('id')) {
                if (isset($rows[$key - 1])) {
                    $next = $rows[$key - 1];
                }
                if (isset($rows[$key + 1])) {
                    $prev = $rows[$key + 1];
                }
                break;
            }
        }
Ejemplo n.º 4
0
 /**
  * Suggest license
  *
  * @return     string
  */
 protected function _suggestLicense()
 {
     // Incoming
     $pid = $this->_pid ? $this->_pid : Request::getInt('pid', 0);
     $version = Request::getVar('version', 'default');
     $ajax = Request::getInt('ajax', 0);
     // Load publication
     $pub = new \Components\Publications\Models\Publication($pid, $version);
     if (!$pub->exists()) {
         $this->setError(Lang::txt('PLG_PROJECTS_PUBLICATIONS_PUBLICATION_NOT_FOUND'));
         $this->_task = '';
         return $this->browse();
     }
     // File a support ticket
     if ($this->_task == 'save_license') {
         $l_title = htmlentities(Request::getVar('license_title', '', 'post'));
         $l_url = htmlentities(Request::getVar('license_url', '', 'post'));
         $l_text = htmlentities(Request::getVar('details', '', 'post'));
         if (!$l_title && !$l_url && !$l_text) {
             $this->setError(Lang::txt('PLG_PROJECTS_PUBLICATIONS_LICENSE_SUGGESTION_ERROR'));
         } else {
             // Include support scripts
             include_once PATH_CORE . DS . 'components' . DS . 'com_support' . DS . 'tables' . DS . 'ticket.php';
             include_once PATH_CORE . DS . 'components' . DS . 'com_support' . DS . 'tables' . DS . 'comment.php';
             // Load the support config
             $sparams = Component::params('com_support');
             $row = new \Components\Support\Tables\Ticket($this->_database);
             $row->created = Date::toSql();
             $row->login = User::get('username');
             $row->email = User::get('email');
             $row->name = User::get('name');
             $row->summary = Lang::txt('PLG_PROJECTS_PUBLICATIONS_LICENSE_SUGGESTION_NEW');
             $report = Lang::txt('PLG_PROJECTS_PUBLICATIONS_LICENSE_TITLE') . ': ' . $l_title . "\r\n";
             $report .= Lang::txt('PLG_PROJECTS_PUBLICATIONS_LICENSE_URL') . ': ' . $l_url . "\r\n";
             $report .= Lang::txt('PLG_PROJECTS_PUBLICATIONS_LICENSE_COMMENTS') . ': ' . $l_text . "\r\n";
             $row->report = $report;
             $row->referrer = Request::getVar('HTTP_REFERER', NULL, 'server');
             $row->type = 0;
             $row->severity = 'normal';
             $admingroup = $this->model->config()->get('admingroup', '');
             $group = \Hubzero\User\Group::getInstance($admingroup);
             $row->group = $group ? $group->get('cn') : '';
             if (!$row->store()) {
                 $this->setError($row->getError());
             } else {
                 $ticketid = $row->id;
                 // Notify project admins
                 $message = $row->name . ' ' . Lang::txt('PLG_PROJECTS_PUBLICATIONS_LICENSE_SUGGESTED') . "\r\n";
                 $message .= '----------------------------' . "\r\n";
                 $message .= $report;
                 $message .= '----------------------------' . "\r\n";
                 if ($ticketid) {
                     $message .= Lang::txt('PLG_PROJECTS_PUBLICATIONS_LICENSE_TICKET_PATH') . "\n";
                     $message .= Request::base() . 'support/ticket/' . $ticketid . "\n\n";
                 }
                 if ($group) {
                     $members = $group->get('members');
                     $managers = $group->get('managers');
                     $admins = array_merge($members, $managers);
                     $admins = array_unique($admins);
                     // Send out email to admins
                     if (!empty($admins)) {
                         \Components\Projects\Helpers\Html::sendHUBMessage($this->_option, $this->model, $admins, Lang::txt('PLG_PROJECTS_PUBLICATIONS_LICENSE_SUGGESTION_NEW'), 'projects_new_project_admin', 'admin', $message);
                     }
                 }
                 $this->_msg = Lang::txt('PLG_PROJECTS_PUBLICATIONS_LICENSE_SUGGESTION_SENT');
             }
         }
     } else {
         $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'publications', 'name' => 'suggestlicense'));
         // Output HTML
         $view->option = $this->_option;
         $view->database = $this->_database;
         $view->project = $this->model;
         $view->uid = $this->_uid;
         $view->pid = $pid;
         $view->pub = $pub;
         $view->task = $this->_task;
         $view->config = $this->model->config();
         $view->pubconfig = $this->_pubconfig;
         $view->ajax = $ajax;
         $view->version = $version;
         $view->title = $this->_area['title'];
         // Get messages	and errors
         $view->msg = $this->_msg;
         if ($this->getError()) {
             $view->setError($this->getError());
         }
         return $view->loadTemplate();
     }
     // Pass error or success message
     if ($this->getError()) {
         \Notify::message($this->getError(), 'error', 'projects');
     } elseif (!empty($this->_msg)) {
         \Notify::message($this->_msg, 'success', 'projects');
     }
     // Redirect
     App::redirect(Route::url($pub->link('editversion') . '&section=license'));
     return;
 }