[ Index ]
 

Code source de Joomla 1.0.13

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/components/com_poll/ -> poll.class.php (source)

   1  <?php
   2  /**
   3  * @version $Id: poll.class.php 5072 2006-09-15 16:24:06Z friesengeist $
   4  * @package Joomla
   5  * @subpackage Polls
   6  * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
   7  * @license http://www.gnu.org/copyleft/gpl.html 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  /// no direct access
  16  defined( '_VALID_MOS' ) or die( 'Restricted access' );
  17  
  18  /**
  19  * @package Joomla
  20  * @subpackage Polls
  21  */
  22  class mosPoll extends mosDBTable {
  23      /** @var int Primary key */
  24      var $id                    = null;
  25      /** @var string */
  26      var $title                = null;
  27      /** @var string */
  28      var $checked_out        = null;
  29      /** @var time */
  30      var $checked_out_time    = null;
  31      /** @var boolean */
  32      var $published            = null;
  33      /** @var int */
  34      var $access                = null;
  35      /** @var int */
  36      var $lag                = null;
  37  
  38      /**
  39      * @param database A database connector object
  40      */
  41  	function mosPoll( &$db ) {
  42          $this->mosDBTable( '#__polls', 'id', $db );
  43      }
  44  
  45      // overloaded check function
  46  	function check() {
  47          // check for valid name
  48          if (trim( $this->title ) == '') {
  49              $this->_error = 'Your Poll must contain a title.';
  50              return false;
  51          }
  52          // check for valid lag
  53          $this->lag = intval( $this->lag );
  54          if ($this->lag == 0) {
  55              $this->_error = 'Your Poll must have a non-zero lag time.';
  56              return false;
  57          }
  58          // check for existing title
  59          $query = "SELECT id"
  60          . "\n FROM #__polls"
  61          . "\n WHERE title = " . $this->_db->Quote( $this->title )
  62          ;
  63          $this->_db->setQuery( $query );
  64  
  65          $xid = intval( $this->_db->loadResult() );
  66          if ( $xid && $xid != intval( $this->id ) ) {
  67              $this->_error = 'There is a module already with that name, please try again.';
  68              return false;
  69          }
  70  
  71          return true;
  72      }
  73  
  74      // overloaded delete function
  75  	function delete( $oid=null ) {
  76          $k = $this->_tbl_key;
  77          if ( $oid ) {
  78              $this->$k = intval( $oid );
  79          }
  80  
  81          if (mosDBTable::delete( $oid )) {
  82              $query = "DELETE FROM #__poll_data"
  83              . "\n WHERE pollid = " . (int) $this->$k
  84              ;
  85              $this->_db->setQuery( $query );
  86              if ( !$this->_db->query() ) {
  87                  $this->_error .= $this->_db->getErrorMsg() . "\n";
  88              }
  89  
  90              $query = "DELETE FROM #__poll_date"
  91              . "\n WHERE poll_id = " . (int) $this->$k
  92              ;
  93              $this->_db->setQuery( $query );
  94              if ( !$this->_db->query() ) {
  95                  $this->_error .= $this->_db->getErrorMsg() . "\n";
  96              }
  97  
  98              $query = "DELETE from #__poll_menu"
  99              . "\n WHERE pollid = " . (int) $this->$k
 100              ;
 101              $this->_db->setQuery( $query );
 102              if ( !$this->_db->query() ) {
 103                  $this->_error .= $this->_db->getErrorMsg() . "\n";
 104              }
 105  
 106              return true;
 107          } else {
 108              return false;
 109          }
 110      }
 111  }
 112  ?>


Généré le : Wed Nov 21 14:43:32 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics