Location: PHPKode > projects > QuickTalk Forum > quicktalk/bin/qtf_class_dom.php
<?php

// QuickTalk 2.5 build:20100924

class cDomain
{

var $id = -1;
var $title = '';

// --------

function cDomain($aDom=null)
{
  if ( isset($aDom) )
  {
    if ( is_int($aDom) )
    {
      if ( $aDom<0 ) die('No domain '.$aDom);      
      global $oDB;      
      $oDB->Query('SELECT * FROM '.TABDOMAIN.' WHERE id='.$aDom);
      $row = $oDB->Getrow();
      if ( $row===False ) die('No domain '.$aDom);
      $this->MakeFromArray($row);
    }
    elseif ( is_array($aDom) )
    {
      $this->MakeFromArray($aDom);
    }
    else
    {
      die('Invalid constructor parameter #1 for the class cDomain');
    }
  }
}

// --------

function MakeFromArray($arr)
{
  foreach($arr as $strKey=>$oValue) {
  switch ($strKey) {
    case 'id':        $this->id = intval($oValue); break;
    case 'title':     $this->title = $oValue; break;
  }}
}

// --- [i] ---

function Add($str='')
{ 
  if ( !is_string($str) ) die('cDomain->Add: Argument #1 must be a string');
  global $oDB;
  $oDB->Query('INSERT INTO '.TABDOMAIN.' (id,title,titleorder) VALUES ('.$oDB->Nextid(TABDOMAIN).',"'.addslashes($str).'",0)');
}

// --- [i] ---

function Delete($id)
{
  if ( !is_int($id) ) die('cDomain->Delete: Argument #1 must be a integer');
  if ( $id<1 ) die('cDomain->Delete: Cannot delete domain 0');
  global $oDB;
  $oDB->Query('UPDATE '.TABSECTION.' SET domainid=0 WHERE domainid='.$id); // sections return to domain 0  
  $oDB->Query('DELETE FROM '.TABDOMAIN.' WHERE id='.$id);
  cVIP::LangDel('domain','d'.$id);
  if ( isset($_SESSION[QT]['sys_sections']) ) Unset($_SESSION[QT]['sys_sections']);
}

// --- [i] ---

function MoveSections($s=-1,$t=-1)
{
  QTargs( 'cDomain->MoveSections',array($s,$t),array('int','int') );
  global $oDB;
  $oDB->Query('UPDATE '.TABSECTION.' SET domainid='.$t.' WHERE domainid='.$s);
}

// --------

function Rename($str='')
{
  if ( !is_string($str) || empty($str) ) die('cDomain->Rename: Argument #1 must be a string');
  global $oDB;
  $oDB->Query('UPDATE '.TABDOMAIN.' SET title="'.addslashes($str).'" WHERE id='.$this->id);
  if ( isset($_SESSION[QT]['sys_sections']) ) Unset($_SESSION[QT]['sys_sections']);
}

// --------

}

?>
Return current item: QuickTalk Forum