| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: poll.php 14401 2010-01-26 14:10:00Z louis $ 4 * @package Joomla 5 * @subpackage Polls 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 9 * to the GNU General Public License, and as distributed it includes or 10 * is derivative of works licensed under the GNU General Public License or 11 * other free or open source software licenses. 12 * See COPYRIGHT.php for copyright notices and details. 13 */ 14 15 // Check to ensure this file is included in Joomla! 16 defined('_JEXEC') or die( 'Restricted access' ); 17 18 /** 19 * @package Joomla 20 * @subpackage Polls 21 */ 22 class TablePoll extends JTable 23 { 24 /** @var int Primary key */ 25 var $id = 0; 26 /** @var string */ 27 var $title = ''; 28 /** @var string */ 29 var $alias = ''; 30 /** @var string */ 31 var $checked_out = 0; 32 /** @var time */ 33 var $checked_out_time = 0; 34 /** @var boolean */ 35 var $published = 0; 36 /** @var int */ 37 var $access = 0; 38 /** @var int */ 39 var $lag = 0; 40 41 /** 42 * @param database A database connector object 43 */ 44 function __construct( &$db ) 45 { 46 parent::__construct( '#__polls', 'id', $db ); 47 } 48 49 /** 50 * Binds an array to the object 51 * @param array Named array 52 * @param string Space separated list of fields not to bind 53 * @return boolean 54 */ 55 function bind( $array, $ignore='' ) 56 { 57 $result = parent::bind( $array ); 58 // cast properties 59 $this->id = (int) $this->id; 60 61 return $result; 62 } 63 64 /** 65 * Overloaded check function 66 * 67 * @access public 68 * @return boolean 69 * @see JTable::check 70 * @since 1.5 71 */ 72 function check() 73 { 74 // check for valid name 75 if (trim( $this->title ) == '') 76 { 77 $this->setError(JText::_( 'Your Poll must contain a title.' )); 78 return false; 79 } 80 // check for valid lag 81 $this->lag = intval( $this->lag ); 82 if ($this->lag == 0) { 83 $this->setError(JText::_( 'Your Poll must have a non-zero lag time.' )); 84 return false; 85 } 86 87 if(empty($this->alias)) { 88 $this->alias = $this->title; 89 } 90 $this->alias = JFilterOutput::stringURLSafe($this->alias); 91 if(trim(str_replace('-','',$this->alias)) == '') { 92 $datenow =& JFactory::getDate(); 93 $this->alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S"); 94 } 95 96 return true; 97 } 98 99 // overloaded delete function 100 function delete( $oid=null ) 101 { 102 $k = $this->_tbl_key; 103 if ( $oid ) { 104 $this->$k = intval( $oid ); 105 } 106 107 if ( parent::delete( $oid )) 108 { 109 $query = 'DELETE FROM #__poll_data' 110 . ' WHERE pollid = '.(int) $this->$k 111 ; 112 $this->_db->setQuery( $query ); 113 if ( !$this->_db->query() ) { 114 $this->_error .= $this->_db->getErrorMsg() . "\n"; 115 } 116 117 $query = 'DELETE FROM #__poll_date' 118 . ' WHERE poll_id = '.(int) $this->$k 119 ; 120 $this->_db->setQuery( $query ); 121 if ( !$this->_db->query() ) { 122 $this->_error .= $this->_db->getErrorMsg() . "\n"; 123 } 124 125 $query = 'DELETE from #__poll_menu' 126 . ' WHERE pollid = '.(int) $this->$k 127 ; 128 $this->_db->setQuery( $query ); 129 if ( !$this->_db->query() ) { 130 $this->_error .= $this->_db->getErrorMsg() . "\n"; 131 } 132 133 return true; 134 } 135 136 return false; 137 } 138 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |