PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/administrator/components/com_redirect/tables/link.php

https://github.com/joebushi/joomla
PHP | 94 lines | 37 code | 7 blank | 50 comment | 4 complexity | a07a2460c5c9201badf2baeed0eae3f1 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1. <?php
  2. /**
  3. * @version $Id$
  4. * @package Joomla.Administrator
  5. * @subpackage com_redirect
  6. * @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
  7. * @license GNU General Public License version 2 or later; see LICENSE.txt
  8. */
  9. defined('_JEXEC') or die('Invalid Request.');
  10. /**
  11. * Link Table for Redirect.
  12. *
  13. * @package Joomla.Administrator
  14. * @subpackage com_redirect
  15. * @version 1.6
  16. */
  17. class RedirectTableLink extends JTable
  18. {
  19. /**
  20. * @var int
  21. */
  22. public $id = null;
  23. /**
  24. * @var varchar
  25. */
  26. public $old_url = null;
  27. /**
  28. * @var varchar
  29. */
  30. public $new_url = null;
  31. /**
  32. * @var varchar
  33. */
  34. public $comment = null;
  35. /**
  36. * @var int unsigned
  37. */
  38. public $published = null;
  39. /**
  40. * @var int unsigned
  41. */
  42. public $created_date = null;
  43. /**
  44. * @var int unsigned
  45. */
  46. public $updated_date = null;
  47. /**
  48. * Constructor
  49. *
  50. * @param object Database object
  51. * @return void
  52. * @since 1.0
  53. */
  54. public function __construct(&$db)
  55. {
  56. parent::__construct('#__redirect_links', 'id', $db);
  57. }
  58. /**
  59. * Overloaded check function
  60. *
  61. * @return boolean
  62. */
  63. public function check()
  64. {
  65. $this->old_url = trim($this->old_url);
  66. $this->new_url = trim($this->new_url);
  67. // Check for valid name.
  68. if (empty($this->old_url))
  69. {
  70. $this->setError(JText::_('Redir_Error_Source_URL_Required'));
  71. return false;
  72. }
  73. // Check for valid name.
  74. if (empty($this->new_url))
  75. {
  76. $this->setError(JText::_('Redir_Error_Destination_URL_Required'));
  77. return false;
  78. }
  79. // Check for duplicates
  80. if ($this->old_url == $this->new_url)
  81. {
  82. $this->setError(JText::_('Redir_Error_Duplicate_URLs'));
  83. return false;
  84. }
  85. return true;
  86. }
  87. }