Exemple #1
0
 /**
  * Get module contents
  *
  * @return  void
  */
 public function run()
 {
     require_once \Component::path('com_feedback') . DS . 'models' . DS . 'quote.php';
     // Get the admin configured settings
     $this->charlimit = $this->params->get('charlimit', 150);
     $this->showauthor = $this->params->get('show_author', 1);
     $this->showall = $this->params->get('show_all_link', 1);
     $quotesrc = $this->params->get('quotesrc', 'miniquote');
     // Get quotes
     $quote = Quote::all()->whereEquals('notable_quote', $this->params->get('quotepool') == 'notable_quotes' ? 1 : 0)->whereEquals('miniquote', $quotesrc == 'miniquote' ? 1 : 0)->limit(1)->rows()->first();
     /*$quote = $sq->find('one', array(
     			'limit'         => 1,
     			'notable_quote' => ($this->params->get('quotepool') == 'notable_quotes' ?  1 : 0),
     			'miniquote'     => ($quotesrc == 'miniquote' ?  1 : 0),
     			'sort'          => 'RAND()',
     			'sort_Dir'      => ''
     		));*/
     if ($quote) {
         $this->quote_to_show = $quotesrc == 'miniquote' ? stripslashes($quote->get('miniquote')) : stripslashes($quote->get('short_quote'));
     } else {
         $this->quote_to_show = '';
     }
     $this->quote = $quote;
     require $this->getLayoutPath($this->params->get('layout', 'default'));
 }
Exemple #2
0
 /**
  * Get module contents
  *
  * @return  void
  */
 public function run()
 {
     require_once Component::path('com_feedback') . DS . 'models' . DS . 'quote.php';
     //Get the admin configured settings
     $this->filters = array('limit' => trim($this->params->get('maxquotes')), 'id' => Request::getInt('quoteid', 0), 'notable_quote' => 1);
     // Get quotes
     $sq = Quote::all()->whereEquals('notable_quote', 1);
     if ($this->filters['id']) {
         $sq->whereEquals('id', $this->filters['id']);
     }
     $this->quotes = $sq->limit($this->filters['limit'])->rows();
     require $this->getLayoutPath($this->module->module);
 }
Exemple #3
0
 /**
  * Save a success story and show a thank you message
  *
  * @return  void
  */
 public function sendstoryTask()
 {
     if (User::isGuest()) {
         $here = Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&task=' . $this->_task);
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($here)), Lang::txt('COM_FEEDBACK_STORY_LOGIN'), 'warning');
     }
     Request::checkToken();
     $fields = Request::getVar('fields', array(), 'post');
     $fields = array_map('trim', $fields);
     $fields['user_id'] = User::get('id');
     // Initiate class and bind posted items to database fields
     $row = Quote::oneOrNew(0)->set($fields);
     // Check that a story was entered
     if (!$row->get('quote')) {
         $this->setError(Lang::txt('COM_FEEDBACK_ERROR_MISSING_STORY'));
         return $this->storyTask($row);
     }
     // Check for an author
     if (!$row->get('fullname')) {
         $this->setError(Lang::txt('COM_FEEDBACK_ERROR_MISSING_AUTHOR'));
         return $this->storyTask($row);
     }
     // Check for an organization
     if (!$row->get('org')) {
         $this->setError(Lang::txt('COM_FEEDBACK_ERROR_MISSING_ORGANIZATION'));
         return $this->storyTask($row);
     }
     // Code cleaner for xhtml transitional compliance
     $row->set('quote', Sanitize::stripAll($row->get('quote')));
     $row->set('quote', str_replace('<br>', '<br />', $row->get('quote')));
     $row->set('date', Date::toSql());
     // Store new content
     if (!$row->save()) {
         $this->setError($row->getError());
         return $this->storyTask($row);
     }
     $addedPictures = array();
     $path = $row->filespace() . DS . $row->get('id');
     if (!is_dir($path)) {
         if (!Filesystem::makeDirectory($path)) {
             $this->setError(Lang::txt('COM_FEEDBACK_ERROR_UNABLE_TO_CREATE_UPLOAD_PATH'));
         }
     }
     // If there is a temp dir for this user then copy the contents to the newly created folder
     $tempDir = $this->tmpPath() . DS . User::get('id');
     if (is_dir($tempDir)) {
         $dirIterator = new DirectoryIterator($tempDir);
         foreach ($dirIterator as $file) {
             if ($file->isDot() || $file->isDir()) {
                 continue;
             }
             $name = $file->getFilename();
             if ($file->isFile()) {
                 if ('cvs' == strtolower($name) || '.svn' == strtolower($name)) {
                     continue;
                 }
                 if (Filesystem::move($tempDir . DS . $name, $path . DS . $name)) {
                     array_push($addedPictures, $name);
                 }
             }
         }
         // Remove temp folder
         Filesystem::deleteDirectory($tempDir);
     }
     $path = substr($row->filespace(), strlen(PATH_ROOT)) . DS . $row->get('id');
     // Set page title
     $this->_buildTitle();
     // Set the pathway
     $this->_buildPathway();
     // Output HTML
     $this->view->set('row', $row)->set('path', $path)->set('addedPictures', $addedPictures)->set('title', $this->_title)->setErrors($this->getErrors())->setLayout('thanks')->display();
 }
Exemple #4
0
 /**
  * Determine task and execute it
  *
  * @return  void
  */
 public function execute()
 {
     $row = Quote::oneOrNew(0);
     $this->path = $row->filespace();
     parent::execute();
 }
Exemple #5
0
 /**
  * Delete one or more entries
  *
  * @return  void
  */
 public function removeTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming
     $ids = Request::getVar('id', array());
     $ids = !is_array($ids) ? array($ids) : $ids;
     // Check for an ID
     if (!count($ids)) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_FEEDBACK_SELECT_QUOTE_TO_DELETE'), 'error');
         return;
     }
     foreach ($ids as $id) {
         $row = Quote::oneOrFail(intval($id));
         // Delete the quote
         if (!$row->destroy()) {
             Notify::error($row->getError());
             continue;
         }
     }
     // Output messsage and redirect
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_FEEDBACK_REMOVED'));
 }
Exemple #6
0
 /**
  * Delete one or more entries
  *
  * @return  void
  */
 public function removeTask()
 {
     // Check for request forgeries
     Request::checkToken();
     if (!User::authorise('core.delete', $this->_option)) {
         App::abort(403, Lang::txt('JERROR_ALERTNOAUTHOR'));
     }
     // Incoming
     $ids = Request::getVar('id', array());
     $ids = !is_array($ids) ? array($ids) : $ids;
     // Check for an ID
     if (!count($ids)) {
         Notify::warning(Lang::txt('COM_FEEDBACK_SELECT_QUOTE_TO_DELETE'));
         return $this->cancelTask();
     }
     $i = 0;
     foreach ($ids as $id) {
         $row = Quote::oneOrFail(intval($id));
         // Delete the quote
         if (!$row->destroy()) {
             Notify::error($row->getError());
             continue;
         }
         $i++;
     }
     // Output messsage and redirect
     if ($i) {
         Notify::success(Lang::txt('COM_FEEDBACK_REMOVED'));
     }
     $this->cancelTask();
 }