| [ Index ] |
PHP Cross Reference of Joomla 2.5.4 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @package Joomla.Administrator 4 * @subpackage com_redirect 5 * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved. 6 * @license GNU General Public License version 2 or later; see LICENSE.txt 7 */ 8 9 defined('_JEXEC') or die; 10 11 /** 12 * Link Table for Redirect. 13 * 14 * @package Joomla.Administrator 15 * @subpackage com_redirect 16 * @version 1.6 17 */ 18 class RedirectTableLink extends JTable 19 { 20 /** 21 * Constructor 22 * 23 * @param object Database object 24 * 25 * @return void 26 * @since 1.6 27 */ 28 public function __construct(&$db) 29 { 30 parent::__construct('#__redirect_links', 'id', $db); 31 } 32 33 /** 34 * Overloaded check function 35 * 36 * @return boolean 37 * @since 1.6 38 */ 39 public function check() 40 { 41 $this->old_url = trim($this->old_url); 42 $this->new_url = trim($this->new_url); 43 44 // Check for valid name. 45 if (empty($this->old_url)) { 46 $this->setError(JText::_('COM_REDIRECT_ERROR_SOURCE_URL_REQUIRED')); 47 return false; 48 } 49 50 // Check for valid name. 51 if (empty($this->new_url)) { 52 $this->setError(JText::_('COM_REDIRECT_ERROR_DESTINATION_URL_REQUIRED')); 53 return false; 54 } 55 56 // Check for duplicates 57 if ($this->old_url == $this->new_url) { 58 $this->setError(JText::_('COM_REDIRECT_ERROR_DUPLICATE_URLS')); 59 return false; 60 } 61 62 $db = $this->getDbo(); 63 64 // Check for existing name 65 $query = 'SELECT id FROM #__redirect_links WHERE old_url ='.$db->Quote($this->old_url); 66 $db->setQuery($query); 67 68 $xid = intval($db->loadResult()); 69 70 if ($xid && $xid != intval($this->id)) { 71 $this->setError(JText::_('COM_REDIRECT_ERROR_DUPLICATE_OLD_URL')); 72 return false; 73 } 74 75 return true; 76 } 77 78 /** 79 * Overriden store method to set dates. 80 * 81 * @param boolean True to update fields even if they are null. 82 * 83 * @return boolean True on success. 84 * @see JTable::store 85 * @since 1.6 86 */ 87 public function store($updateNulls = false) 88 { 89 // Initialise variables. 90 $date = JFactory::getDate()->toSql(); 91 92 if ($this->id) { 93 // Existing item 94 $this->modified_date = $date; 95 } else { 96 // New record. 97 $this->created_date = $date; 98 } 99 100 return parent::store($updateNulls); 101 } 102 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Apr 3 11:40:28 2012 | Cross-referenced by PHPXref 0.7.1 |