Source for file poll.class.php

Documentation is available at poll.class.php

  1. <?php
  2. /**
  3. @package Mambo
  4. @subpackage Polls
  5. @copyright  Refer to copyright.php
  6. @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
  7. @author Mambo Foundation Inc see README.php
  8. */ 
  9.  
  10. //** ensure this file is being included by a parent file */
  11. defined'_VALID_MOS' or die'Direct Access to this location is not allowed.' );
  12.  
  13. class mosPoll extends mosDBTable {
  14.     /** @var int Primary key */
  15.     var $id=null;
  16.     /** @var string */
  17.     var $title=null;
  18.     /** @var string */
  19.     var $checked_out=null;
  20.     /** @var time */
  21.     var $checked_out_time=null;
  22.     /** @var boolean */
  23.     var $published=null;
  24.     /** @var int */
  25.     var $access=null;
  26.     /** @var int */
  27.     var $lag=null;
  28.  
  29.     /**
  30.     * @param database A database connector object
  31.     */
  32.     function mosPoll&$db {
  33.         $this->mosDBTable'#__polls''id'$db );
  34.     }
  35.     // overloaded check function
  36.     function check({
  37.         // check for valid name
  38.         if (trim$this->title == ''{
  39.             $this->_error = T_('Your Poll must contain a title.');
  40.             return false;
  41.         }
  42.         // check for valid lag
  43.         $this->lag = intval$this->lag );
  44.         if ($this->lag == 0{
  45.             $this->_error = T_("Your Poll must have a non-zero lag time.");
  46.             return false;
  47.         }
  48.         // check for existing title
  49.         $this->_db->setQuery"SELECT id FROM #__polls WHERE title='$this->title'"
  50.         );
  51.  
  52.         $xid intval$this->_db->loadResult() );
  53.         if ($xid && $xid != intval$this->id )) {
  54.             $this->_error = T_("There is a module already with that name, please try again.");
  55.             return false;
  56.         }
  57.  
  58.         // sanitise some data
  59.         if (!get_magic_quotes_gpc()) {
  60.             $row->title addslashes$row->title );
  61.         }
  62.  
  63.         return true;
  64.     }
  65.     // overloaded delete function
  66.     function delete$oid=null {
  67.         $k $this->_tbl_key;
  68.         if ($oid{
  69.             $this->$k intval$oid );
  70.         }
  71.  
  72.         if (mosDBTable::delete$oid )) {
  73.             $this->_db->setQuery"DELETE FROM #__poll_data WHERE pollid='".$this->$k."'" );
  74.             if (!$this->_db->query()) {
  75.                 $this->_error .= $this->_db->getErrorMsg("\n";
  76.             }
  77.  
  78.             $this->_db->setQuery"DELETE FROM #__poll_date WHERE pollid='".$this->$k."'" );
  79.             if (!$this->_db->query()) {
  80.                 $this->_error .= $this->_db->getErrorMsg("\n";
  81.             }
  82.  
  83.             $this->_db->setQuery"DELETE from #__poll_menu where pollid='".$this->$k."'" );
  84.             if (!$this->_db->query()) {
  85.                 $this->_error .= $this->_db->getErrorMsg("\n";
  86.             }
  87.  
  88.             return true;
  89.         else {
  90.             return false;
  91.         }
  92.     }
  93. }
  94. ?>

Documentation generated on Mon, 05 May 2008 16:22:31 +0400 by phpDocumentor 1.4.0