Файловый менеджер - Редактировать - /var/www/html/administrator/components/com_jchat/Controller/LamessagesController.php
Ðазад
<?php namespace JExtstore\Component\JChat\Administrator\Controller; /** * @package JCHAT::LAMESSAGES::administrator::components::com_jchat * @subpackage controllers * @author Joomla! Extensions Store * @Copyright (C) 2015 - Joomla! Extensions Store * @license GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html */ defined ( '_JEXEC' ) or die ( 'Restricted access' ); use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Factory\MVCFactoryInterface; use JExtstore\Component\JChat\Administrator\Framework\Helpers\Mailer as JChatHelpersMailer; use JExtstore\Component\JChat\Administrator\Framework\Controller as JChatController; /** * Main controller leaved messages * @package JCHAT::LAMESSAGES::administrator::components::com_jchat * @subpackage controllers * @since 1.0 */ class LamessagesController extends JChatController { /** * Setta il model state a partire dallo userstate di sessione * @access protected * @return object */ protected function setModelState($scope = 'default', $ordering = true): object { // User state specific $option= $this->option; // Get default model $defaultModel = $this->getModel(); $filter_order = $this->getUserStateFromRequest( "$option.$scope.filter_order", 'filter_order', 'a.sentdate', 'cmd' ); $filter_order_Dir = $this->getUserStateFromRequest ( "$option.$scope.filter_order_Dir", 'filter_order_Dir', 'desc', 'word' ); $fromPeriod = $this->getUserStateFromRequest( "$option.$scope.fromperiod", 'fromperiod'); $toPeriod = $this->getUserStateFromRequest( "$option.$scope.toperiod", 'toperiod'); $worked = $this->getUserStateFromRequest( "$option.$scope.workedfilter", 'workedfilter'); $closed = $this->getUserStateFromRequest( "$option.$scope.closedfilter", 'closedfilter'); parent::setModelState($scope); // Set model state $defaultModel->setState('order', $filter_order); $defaultModel->setState('order_dir', $filter_order_Dir ); $defaultModel->setState('fromPeriod', $fromPeriod); $defaultModel->setState('toPeriod', $toPeriod); $defaultModel->setState('workedfilter', $worked); $defaultModel->setState('closedfilter', $closed); return $defaultModel; } /** * Default listEntities * * @access public * @param $cachable string * the view output will be cached * @return void */ public function display($cachable = false, $urlparams = false) { // Set model state $defaultModel = $this->setModelState('lamessages'); // Parent construction and view display parent::display($cachable); } /** * Avvia il processo di esportazione records * * @access public * @return void */ public function exportMessages() { // Set model state $this->setModelState(); // Mapping fields to load to column header $fieldsToLoadArray = array( 'a.name'=>Text::_('COM_JCHAT_LAMESSAGE_NAME'), 'a.email'=>Text::_('COM_JCHAT_LAMESSAGE_EMAIL'), 'a.phonenumber'=>Text::_('COM_JCHAT_LAMESSAGE_PHONENUMBER'), 'a.message'=>Text::_('COM_JCHAT_MESSAGE'), 'a.sentdate'=>Text::_('COM_JCHAT_SENT'), 'a.worked'=>Text::_('COM_JCHAT_WORKED_STATE'), 'a.closed_ticket'=>Text::_('COM_JCHAT_CLOSED_TICKET'), 'u.name AS username_logged'=>Text::_('COM_JCHAT_USERID'), 'a.id AS msg_id'=>Text::_('ID'), 'a.responses'=>Text::_('COM_JCHAT_TICKET_RESPONSES')); $fieldsFunctionTransformation = array(); $model = $this->getModel(); // Additional phone number field if(!$model->getComponentParams()->get('tickets_form_include_phonenumber', 0)) { unset($fieldsToLoadArray['a.phonenumber']); } $data = $model->exportMessages($fieldsToLoadArray, $fieldsFunctionTransformation); if(!$data) { $this->setRedirect('index.php?option=' . $this->option . '&task=lamessages.display', Text::_('COM_JCHAT_NODATA_EXPORT')); return false; } // Get view $viewType = $this->document->getType(); $viewName = $this->input->get('view', $this->default_view); $viewLayout = $this->input->get('layout', 'default', 'string'); $view = $this->getView($viewName, $viewType, '', array('base_path' => $this->basePath, 'layout' => $viewLayout)); $view->sendCSVMessages($data, $fieldsFunctionTransformation); } /** * Manage answered worked state for the ticket * * @access public */ public function stateFlags() { // Access check if (! $this->allowEditState ( $this->option )) { $this->setRedirect ( "index.php?option=" . $this->option . "&task=" . $this->name . ".display", Text::_ ( 'COM_JCHAT_ERROR_ALERT_NOACCESS' ), 'notice' ); return false; } $cid = $this->app->input->get ( 'cid', array ( 0 ), 'array' ); $idEntity = ( int ) $cid [0]; $model = $this->getModel (); if (! $model->changeTicketState($idEntity, $this->task)) { // Model set exceptions for something gone wrong, so enqueue exceptions and levels on application object then set redirect and exit $modelException = $model->getError ( null, false ); $this->app->enqueueMessage ( $modelException->getMessage (), $modelException->getErrorLevel () ); $this->setRedirect ( "index.php?option=" . $this->option . "&task=" . $this->name . ".display", Text::_ ( 'COM_JCHAT_ERROR_STATE_CHANGE' ) ); return false; } $this->setRedirect ( "index.php?option=" . $this->option . "&task=" . $this->name . ".display", Text::_ ( 'COM_JCHAT_LAMESSAGE_STATE_CHANGED' ) ); } /** * Risponde all'email del richiedente con il messaggio inserito dall'agente * richiedendo la serializzazione delle risposte nell'apposito db field * * @access public * @return void */ public function responseMessage() { $task = $this->app->input->get('task', 'responseMessage'); $responseSubject = $this->app->input->getString('email_subject'); $responseText = $this->app->input->getRaw('response', ''); $idEntity = $this->app->input->getInt('id'); // Response text vuota validazione lato server con return false if(!trim($responseSubject)) { $controllerTask = 'editEntity&cid[]=' . $idEntity; $this->setRedirect ( "index.php?option=" . $this->option . "&task=lamessages.$controllerTask", Text::_('COM_JCHAT_VALIDATION_ERROR')); return false; } $model = $this->getModel(); // Root controller -> dependency injection $mailer = JChatHelpersMailer::getInstance('Joomla'); if (! $model->sendResponseStore($mailer, $idEntity, $responseSubject, $responseText)) { // Model set exceptions for something gone wrong, so enqueue exceptions and levels on application object then set redirect and exit $modelException = $model->getError ( null, false ); $this->app->enqueueMessage ( $modelException->getMessage (), $modelException->getErrorLevel () ); $this->setRedirect ( "index.php?option=" . $this->option . "&task=" . $this->name . ".editEntity&cid[]=" . $this->app->input->get ( 'id' ), Text::_ ( 'COM_JCHAT_ERROR_SEND_MESSAGE' ) ); return false; } $controllerTask = 'editEntity&cid[]=' . $idEntity; $this->setRedirect ( "index.php?option=" . $this->option . "&task=lamessages.$controllerTask", Text::_('COM_JCHAT_SUCCESS_SEND_MESSAGE')); } /** * Class constructor * @return Object& */ public function __construct($config = array(), MVCFactoryInterface $factory = null, $app = null, $input = null) { parent::__construct($config, $factory, $app, $input); // Registering alias task $this->registerTask('applyEntity', 'saveEntity'); $this->registerTask('workedFlagOff', 'stateFlags'); $this->registerTask('workedFlagOn', 'stateFlags'); $this->registerTask('closedFlagOff', 'stateFlags'); $this->registerTask('closedFlagOn', 'stateFlags'); } }
| ver. 1.1 | |
.
| PHP 8.4.18 | Ð“ÐµÐ½ÐµÑ€Ð°Ñ†Ð¸Ñ Ñтраницы: 0 |
proxy
|
phpinfo
|
ÐаÑтройка