[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/components/com_weblinks/controllers/ -> weblink.php (source)

   1  <?php
   2  /**
   3   * @version        $Id: weblink.php 14401 2010-01-26 14:10:00Z louis $
   4   * @package        Joomla
   5   * @subpackage    Content
   6   * @copyright    Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
   7   * @license        GNU/GPL, see LICENSE.php
   8   * Joomla! is free software. This version may have been modified pursuant to the
   9   * GNU General Public License, and as distributed it includes or is derivative
  10   * of works licensed under the GNU General Public License or other free or open
  11   * source software licenses. See COPYRIGHT.php for copyright notices and
  12   * details.
  13   */
  14  
  15  // Check to ensure this file is included in Joomla!
  16  defined('_JEXEC') or die( 'Restricted access' );
  17  
  18  jimport('joomla.application.component.controller');
  19  
  20  /**
  21   * Weblinks Weblink Controller
  22   *
  23   * @package        Joomla
  24   * @subpackage    Weblinks
  25   * @since 1.5
  26   */
  27  class WeblinksControllerWeblink extends WeblinksController
  28  {
  29      /**
  30      * Edit a weblink and show the edit form
  31      *
  32      * @acces public
  33      * @since 1.5
  34      */
  35  	function edit()
  36      {
  37          $user = & JFactory::getUser();
  38  
  39          // Make sure you are logged in
  40          if ($user->get('aid', 0) < 1) {
  41              JError::raiseError( 403, JText::_('ALERTNOTAUTH') );
  42              return;
  43          }
  44  
  45          JRequest::setVar('view', 'weblink');
  46          JRequest::setVar('layout', 'form');
  47  
  48          $model =& $this->getModel('weblink');
  49          $model->checkout();
  50  
  51          parent::display();
  52      }
  53  
  54      /**
  55      * Saves the record on an edit form submit
  56      *
  57      * @acces public
  58      * @since 1.5
  59      */
  60  	function save()
  61      {
  62          // Check for request forgeries
  63          JRequest::checkToken() or jexit( 'Invalid Token' );
  64  
  65          // Get some objects from the JApplication
  66          $db        =& JFactory::getDBO();
  67          $user    =& JFactory::getUser();
  68  
  69          // Must be logged in
  70          if ($user->get('id') < 1) {
  71              JError::raiseError( 403, JText::_('ALERTNOTAUTH') );
  72              return;
  73          }
  74  
  75          //get data from the request
  76          $post = JRequest::getVar('jform', array(), 'post', 'array');
  77  
  78          $model = $this->getModel('weblink');
  79  
  80          if ($model->store($post)) {
  81              $msg = JText::_( 'Weblink Saved' );
  82          } else {
  83              $msg = JText::_( 'Error Saving Weblink' );
  84          }
  85  
  86          // Check the table in so it can be edited.... we are done with it anyway
  87          $model->checkin();
  88  
  89          // admin users gid
  90          $gid = 25;
  91  
  92          // list of admins
  93          $query = 'SELECT email, name' .
  94                  ' FROM #__users' .
  95                  ' WHERE gid = ' . $gid .
  96                  ' AND sendEmail = 1';
  97          $db->setQuery($query);
  98          if (!$db->query()) {
  99              JError::raiseError( 500, $db->stderr(true));
 100              return;
 101          }
 102          $adminRows = $db->loadObjectList();
 103  
 104          // send email notification to admins
 105          foreach ($adminRows as $adminRow) {
 106              JUtility::sendAdminMail($adminRow->name, $adminRow->email, '',  JText::_('Web Link'), $post['title']." URL link ".$post[url], $user->get('username'), JURI::base());
 107          }
 108  
 109          $this->setRedirect(JRoute::_('index.php?option=com_weblinks&view=category&id='.$post['catid'], false), $msg);
 110      }
 111  
 112      /**
 113      * Cancel the editing of a web link
 114      *
 115      * @access    public
 116      * @since    1.5
 117      */
 118  	function cancel()
 119      {
 120          // Get some objects from the JApplication
 121          $user    = & JFactory::getUser();
 122  
 123          // Must be logged in
 124          if ($user->get('id') < 1) {
 125              JError::raiseError( 403, JText::_('ALERTNOTAUTH') );
 126              return;
 127          }
 128  
 129          // Checkin the weblink
 130          $model = $this->getModel('weblink');
 131          $model->checkin();
 132  
 133          $this->setRedirect(JRoute::_('index.php?option=com_weblinks&view=categories', false));
 134      }
 135  }
 136  
 137  ?>


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1