コード例 #1
0
 /**
  * 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();
             }
         }
     }
 }
コード例 #2
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;
 }