<?php
// QuickTicket 2.5 build:20101222
class cTopic extends aQTcontainer implements IOptions
{
// -- Properties --
public $numid = -1;
public $statusdate = '0';
public $wisheddate = '0';
public $tags = '';
public $firstpostid = -1;
public $lastpostid = -1;
public $firstpostuser = -1;
public $lastpostuser = -1;
public $firstpostname;
public $lastpostname;
public $firstpostdate = '0';
public $lastpostdate = '0';
public $x;
public $y;
public $z;
public $actorid = -1;
public $actorname = '';
public $notifiedid = -1;
public $notifiedname = '';
public $views = 0;
public $modifdate = '0';
public $options = '';
public $youreply = '';
public $preview;
public $smile;
function __construct($aTopic=null,$intUser=-1,$intPreviewsize=250)
{
// Change aQTcontainer defaults
$this->type = 'T'; // A=News P=Post. Attention, alphabetic order can be used as display order (i.e. "News on top")
$this->status = 'A'; // A=submitted Z=closed (News 0=closed). Attention user can sort according to the status index.
// Constructor accepts an array or an integer as parameter #1
if ( isset($aTopic) )
{
if ( is_int($aTopic) )
{
if ( $aTopic<0 ) die('cTopic: Wrong id');
global $oDB;
$oDB->Query('SELECT * FROM '.TABTOPIC.' WHERE id='.$aTopic);
$row = $oDB->Getrow();
if ( $row===False ) die('No topic '.$aTopic);
$this->MakeFromArray($row,$intPreviewsize);
if ( $intUser>=0 )
{
// +1 when user is not the topic creator himself
if ( $intUser != $this->firstpostuser )
{
$oDB->Query('UPDATE '.TABTOPIC.' SET views = views+1 WHERE id='.$this->id);
}
}
}
elseif ( is_array($aTopic) )
{
$this->MakeFromArray($aTopic,$intPreviewsize);
}
else
{
die('Invalid constructor parameter #1 in the class cTopic');
}
}
}
// --------
private function DbFields()
{
// relation dbfield=>property (exceptions: forum,replies,param)
return array('id'=>'id','numid'=>'numid','forum'=>'parentid','type'=>'type',
'status'=>'status','statusdate'=>'statusdate',
'wisheddate'=>'wisheddate', 'tags'=>'tags',
'firstpostid'=>'firstpostid','lastpostid'=>'lastpostid',
'firstpostuser'=>'firstpostuser','lastpostuser'=>'lastpostuser',
'firstpostname'=>'firstpostname', 'lastpostname'=>'lastpostname',
'firstpostdate'=>'firstpostdate','lastpostdate'=>'lastpostdate',
'x'=>'x','y'=>'y','z'=>'z',
'actorid'=>'actorid','actorname'=>'actorname',
'notifiedid'=>'notifiedid','notifiedname'=>'notifiedname',
'replies'=>'items','views'=>'views',
'modifdate'=>'modifdate','param'=>'options');
}
// --------
private function MakeFromArray($aTopic,$intPreview=100)
{
foreach($aTopic as $strKey=>$oValue) {
switch ($strKey) {
case 'textmsg': $this->preview = QTcompact(QTunbbc($oValue),$intPreview,' '); break;
case 'id': $this->id = intval($oValue); break;
case 'numid': $this->numid = intval($oValue); break;
case 'forum': $this->parentid = intval($oValue); break;
case 'type': $this->type = $oValue; break;
case 'status': $this->status = $oValue; break;
case 'statusdate': $this->statusdate = $oValue; break;
case 'wisheddate': $this->wisheddate = $oValue; break;
case 'tags': $this->tags = $oValue; break;
case 'firstpostid': $this->firstpostid = intval($oValue); break;
case 'lastpostid': $this->lastpostid = intval($oValue); break;
case 'firstpostuser':$this->firstpostuser= intval($oValue); break;
case 'lastpostuser': $this->lastpostuser = intval($oValue); break;
case 'firstpostname':$this->firstpostname= $oValue; break;
case 'lastpostname': $this->lastpostname = $oValue; break;
case 'firstpostdate':$this->firstpostdate= $oValue; break;
case 'lastpostdate': $this->lastpostdate = $oValue; break;
case 'actorid': $this->actorid = intval($oValue); if ($this->actorid==0) $this->actorid=null; break;
case 'actorname': $this->actorname = $oValue; break;
case 'notifiedid': $this->notifiedid = intval($oValue); if ($this->notifiedid==0) $this->notifiedid=null; break;
case 'notifiedname': $this->notifiedname = $oValue; break;
case 'replies': $this->items = intval($oValue); break;
case 'views': $this->views = intval($oValue); break;
case 'icon': $this->smile = $oValue; break;
case 'title': $this->title = $oValue; break;
case 'modifdate': $this->modifdate = $oValue; break;
case 'x': if ( is_numeric($oValue) ) $this->x = floatval($oValue); break; // must be FLOAT (or NULL)
case 'y': if ( is_numeric($oValue) ) $this->y = floatval($oValue); break; // must be FLOAT (or NULL)
case 'z': if ( is_numeric($oValue) ) $this->z = floatval($oValue); break; // must be FLOAT (or NULL)
case 'param': $this->options = $oValue; break;
}}
}
// --------
public function GetIcon($strSkin='skin/default',$strHref='',$strTitleFormat='%s')
{
$str='';
switch(strtoupper($this->type))
{
case 'T':
global $oVIP;
if ( isset($oVIP->statuses[$this->status]['statusname']) ) { $str=$strSkin.'/'.$oVIP->statuses[$this->status]['icon']; } else { $str=$strSkin.'/ico_topic_t_1.gif'; }
if ( !file_exists($str) ) $str='admin/ico_status.gif';
return AsImg($str,'T',sprintf($strTitleFormat,$this->GetIconName()),'ico ico_t','',$strHref);
break;
case 'I':
$str = $strSkin.'/ico_topic_i_'.($this->status=='Z' ? '1' : '0').'.gif';
if ( !file_exists($str) ) $str='admin/ico_status.gif';
return AsImg($str,$this->type,sprintf($strTitleFormat,$this->GetIconName()),'ico ico_i','',$strHref);
break;
case 'A':
$str = $strSkin.'/ico_topic_a_'.($this->status=='Z' ? '1' : '0').'.gif';
if ( !file_exists($str) ) $str='admin/ico_status.gif';
return AsImg($str,$this->type,sprintf($strTitleFormat,$this->GetIconName()),'ico ico_a','',$strHref);
break;
}
return $str;
}
public function GetIconName()
{
$str='';
switch(strtoupper($this->type))
{
case 'T': global $oVIP; $str = (isset($oVIP->statuses[$this->status]['statusname']) ? $oVIP->statuses[$this->status]['statusname'] : 'unknown status'); break;
case 'I': $str = 'Ico_topic_'.strtolower($this->type).($this->status=='Z' ? 'Z' : ''); break;
case 'A': $str = 'Ico_topic_'.strtolower($this->type).($this->status=='Z' ? 'Z' : ''); break;
}
return L($str);
}
// --------
public function GetTopicTitle()
{
global $oDB;
$oDB->Query('SELECT title FROM '.TABPOST.' WHERE id='.$this->firstpostid);
$row = $oDB->Getrow();
$this->title = $row['title'];
return $this->title;
}
// --------
public function InsertTopic($bUserStat=true,$bCanNotify=true,$oPost=null,$oSEC=null)
{
global $oDB,$L,$oVIP;
// In case of Topic type 'Inspection'
if ( $this->type==='I' && isset($oPost) )
{
$this->status='Z'; // When creating a new inspection, ticket status is closed until creator setup parameters and turn it to 'submitted'.
$this->options = 'Itype=0;Ilevel=3;Istat=mean'; // Initial parameters for an inspection
$this->z=-1 ; // Inspection score < 0 means unknown
}
// Quote each db fieldvalues
$arrValues = array();
foreach($this->DbFields() as $strField=>$strProperty) $arrValues[$strField]=FieldQuote($this->$strProperty,TABTOPIC,$strProperty);
// Insert
$oDB->Query( 'INSERT INTO '.TABTOPIC.' ('.implode(',',array_keys($arrValues)).') VALUES ('.implode(',',$arrValues).')' );
// Status notification
if ( $bCanNotify && $this->type=='T' ) $this->NotifyStatus(-1,$oPost,$oSEC);
// User stats
if ( $bUserStat )
{
$oDB->Query('SELECT count(*) as countid FROM '.TABPOST.' WHERE userid='.$this->firstpostuser);
$row = $oDB->Getrow();
$oDB->Query('UPDATE '.TABUSER.' SET lastdate="'.Date('Ymd His').'", numpost='.$row['countid'].', ip="'.$oDB->ip.'" WHERE id='.$this->firstpostuser);
$_SESSION[QT.'_usr_posts']++;
}
}
// --------
public function NotifyActor($intOldactorid=-1,$oSEC=null)
{
if ( QTI_NOTIFY_NEWACTOR || QTI_NOTIFY_OLDACTOR ) {
if ( $intOldactorid!=$this->actorid ) {
if ( !isset($oSEC) ) $oSEC = new cSection($this->parentid);
if ( $oSEC->notify==1 )
{
global $L;
// prepare mail
$strTopic = ''; if ( $oSEC->numfield!='N' ) $strTopic = sprintf($oSEC->numfield,$this->numid).' ';
$strMails = '';
if ( QTI_NOTIFY_NEWACTOR && $this->actorid>=0 ) $strMails .= GetUserInfo($this->actorid,'mail').',';
if ( QTI_NOTIFY_OLDACTOR && $intOldactorid>=0 ) $strMails .= GetUserInfo($intOldactorid,'mail');
$strMessage = sprintf("{$L['Topic']} %s ",$strTopic);
$strMessage .= sprintf($L['Topic_forwarded'],$this->actorname);
$strSubject = "{$_SESSION[QT]['site_name']}: {$L['Notification']} $strTopic";
// send mail
include('bin/qt_lib_smtp.php');
if ( !empty($strMails) ) QTmail($strMails,QTconv($strSubject,'-4'),QTconv($strMessage,'-4'),QTI_HTML_CHAR);
}
}}
}
public function NotifyStatus($intOldactorid=-1,$oPost=null,$oSEC=null)
{
global $L,$oVIP;
if ( !empty($oVIP->statuses[$this->status]['mailto']) )
{
if ( !isset($oSEC) ) $oSEC = new cSection($this->parentid);
if ( $oSEC->notify==1 )
{
// read message (and get it if not yet defined)
if ( !isset($this->title) && isset($oPost) )
{
if ( is_integer($oPost) ) $oPost = new cPost($oPost); // $oPost can be an integer
$this->title = $oPost->title;
$this->preview = QTcompact(QTunbbc($oPost->text),100,' ');
}
if ( empty($this->title) ) $this->title = '';
if ( empty($this->preview) ) $this->preview = '';
$strTopic = ($oSEC->numfield!='N' ? sprintf($oSEC->numfield,$this->numid).' ' : '').$this->title."\r\n".$this->preview."\r\n".$_SESSION[QT]['site_url'].'/qti_topic.php?t='.$this->id;
$strFile = GetLang().'mail_status.php';
// notify list
$lstMails = explode(',',$oVIP->statuses[$this->status]['mailto']);
$lstMails = array_unique($lstMails);
// notify mails
$arrMails = array();
foreach($lstMails as $intUser)
{
switch ($intUser)
{
case 'MF': $arrMails[] = GetUserInfo("$this->parentid",'mail',$oSEC); break;
case 'MA': if ( $this->actorid>=0 ) $arrMails[] = GetUserInfo($this->actorid,'mail'); break;
case 'U':
$arrMails[] = GetUserInfo(intval($this->firstpostuser),'mail');
if ( $this->notifiedid>=0 ) $arrMails[] = GetUserInfo(intval($this->notifiedid),'mail');
break;
case 'A': $arrMails = $arrMails + GetUserInfo('A','mail'); break;
case 'S': $arrMails = $arrMails + GetUserInfo('S','mail'); break;
default: if ( $intUser>=0 ) $arrMails[] = GetUserInfo(intval($intUser),'mail'); break;
}
}
$arrMails = array_unique($arrMails);
$strMails = implode(', ',$arrMails);
// message containing 2 parameters (the status, the topic preview)
$strMessage = "{$L['Status']}: %s \r\n%s";
if ( file_exists($strFile) ) include($strFile);
$strMessage = sprintf($strMessage,$oVIP->statuses[$this->status]['name'],$strTopic);
$strSubject = $_SESSION[QT]['site_name'].': '.$L['Notification'].' '.$this->title;
// send mail
include('bin/qt_lib_smtp.php');
QTmail($strMails,QTconv($strSubject,'-4'),QTconv($strMessage,'-4'),QTI_HTML_CHAR);
// show send mails
$strMails = '<br /><br />'.$L['Notification'].': '.$strMails;
}
}
}
// --------
public function SetStatus($strStatus='A',$bCanNotify=true,$oPost=null)
{
if ( $this->status==$strStatus ) return false;
if ( $strStatus=='Z' || $this->status=='Z' ) { $b=true; } else { $b=false; }
global $oDB;
$this->status=$strStatus;
$this->statusdate=date('Ymd His');
$oDB->Query('UPDATE '.TABTOPIC.' SET status="'.$this->status.'", statusdate="'.$this->statusdate.'",modifdate="'.date('Ymd His').'" WHERE id='.$this->id);
$this->status=$strStatus;
// NOTIFY
if ( $bCanNotify ) $this->NotifyStatus(-1,$oPost); // $oPost can be an integer
// UPDATE section stats if required (topicsZ and repliesZ)
if ( $b ) { $voidSEC = new cSection(); $voidSEC->id=$this->parentid; $voidSEC->UpdateStats(); }
}
// --------
public function SetType($intId=-1,$str='T')
{
// Check
if ( $intId<0 ) die('Topic->SetType: Wrong id');
// Process
global $oDB;
$oDB->Query( 'UPDATE '.TABTOPIC.' SET type="'.$str.'",modifdate="'.date('Ymd His').'" WHERE id='.$intId );
if ( isset($this) ) $this->type=$str;
}
// --------
public function SetActor($intActor=-1,$bCanNotify=TRUE)
{
$intOldactorid = $this->actorid;
if ( $intActor<0 ) die('Topic->SetActor: Wrong actor id');
global $oDB,$L;
// change actor
$this->actorid = intval($intActor);
$this->actorname = GetUserInfo($this->actorid,'name');
$oDB->Query('UPDATE '.TABTOPIC.' SET actorid='.$this->actorid.', actorname="'.$this->actorname.'",modifdate="'.date('Ymd His').'" WHERE id='.$this->id);
// posting a forward messsage
$oPost = new cPost();
$oPost->id = $oDB->Nextid(TABPOST);
$oPost->section = $this->parentid;
$oPost->topic = $this->id;
$oPost->type = 'F';
$oPost->title = $L['Topic_handled'].' '.strtolower($L['By']).' '.$this->actorname;
$oPost->text = sprintf($L['Topic_forwarded'],$this->actorname);
$oPost->userid = $this->actorid;
$oPost->username = $this->actorname;
$oPost->issuedate = date('Ymd His');
$oPost->modifdate = '';
$oPost->modifuser = '';
$oPost->InsertPost(true,true); // Update topic stat, Update user's stat
if ( $bCanNotify ) $this->NotifyActor($intOldactorid);
}
// --------
public function TagsAdd($str,$oSEC)
{
// Check
if ( !is_string($str) ) die('cTopic->TagsAdd: wrong argument #1');
$str = trim($str);
if ( empty($str) ) return false;
if ( substr($str,-1,1)==';' ) $str = substr($str,0,-1);
if ( $str==';' ) return false;
// Read tags to add
$str = strtr(trim($str),'éèêëÉÈÊËáàâäÁÀÂÄÅåíìîïÍÌÎÏóòôöÓÒÔÖõÕúùûüÚÙÛÜ','eeeeeeeeaaaaaaaaaaiiiiiiiioooooooooouuuuuuuu');
$arrAdd = explode(';',$str);
foreach($arrAdd as $intKey=>$strValue) { $arrAdd[$intKey]=trim($strValue); }
// Read current tags
$arrTag = array();
if ( !empty($this->tags) )
{
$arrTag = explode(';',strtolower($this->tags));
foreach($arrTag as $intKey=>$strValue) { $arrTag[$intKey]=trim($strValue); }
}
// Add tags
foreach($arrAdd as $strValue)
{
if ( !in_array(strtolower($strValue),$arrTag) ) $arrTag[]=$strValue;
}
$this->tags = implode(';',$arrTag);
// Save
global $oDB; $oDB->Query('UPDATE '.TABTOPIC.' SET tags="'.$this->tags.'",modifdate="'.date('Ymd His').'" WHERE id='.$this->id);
// Update section stats
if ( isset($oSEC) ) {
if ( $oSEC->tags==0 && count($arrTag)>0 ) {
$oSEC->stats = QTimplode(QTarradd(QTexplode($oSEC->stats),'tags',count($arrTag)));
$oSEC->WriteStats();
}}
}
// --------
public function TagsDel($str,$oSEC)
{
// Check
if ( !is_string($str) ) die('cTopic->TagsDel: wrong argument #1');
if ( empty($this->tags) ) return false;
$str = trim($str);
if ( empty($str) ) return false;
if ( substr($str,-1,1)==';' ) $str = substr($str,0,-1);
if ( $str==';' ) return false;
global $oDB;
if ( $str=='*' )
{
// Delete [all]
$this->tags='';
$oDB->Query('UPDATE '.TABTOPIC.' SET tags="",modifdate="'.date('Ymd His').'" WHERE id='.$this->id);
}
else
{
// Read tags to delete
$str = strtr(trim($str),'éèêëÉÈÊËáàâäÁÀÂÄÅåíìîïÍÌÎÏóòôöÓÒÔÖõÕúùûüÚÙÛÜ','eeeeeeeeaaaaaaaaaaiiiiiiiioooooooooouuuuuuuu');
$arrDel = explode(';',$str);
foreach($arrDel as $intKey=>$strValue) { $arrDel[$intKey]=strtolower(trim($strValue)); }
// Read current tags
$arrTag = array();
if ( !empty($this->tags) )
{
$arrTag = explode(';',strtolower($this->tags));
foreach($arrTag as $intKey=>$strValue) { $arrTag[$intKey]=trim($strValue); }
}
// Delete tags
$this->tags = '';
foreach($arrTag as $strValue)
{
if ( !in_array(strtolower($strValue),$arrDel) ) $this->tags .= $strValue.';';
}
if ( !empty($this->tags) ) { if ( substr($this->tags,-1,1)==';' ) $this->tags = substr($this->tags,0,-1); }
// Save
$oDB->Query('UPDATE '.TABTOPIC.' SET tags="'.$this->tags.'",modifdate="'.date('Ymd His').'" WHERE id='.$this->id);
}
// Update section stats
if ( isset($oSEC) ) {
if ( $oSEC->tags>0 ) {
$oSEC->stats = QTimplode(QTarradd(QTexplode($oSEC->stats),'tags',cSection::CountItems($oSEC->id,'tags')));
$oSEC->WriteStats();
}}
}
// --------
public function UpdateStats($intMax=100,$bInspectionUpdateScore=true)
{
if ( $this->id<0 ) die('Topic->UpdateStats: Wrong id');
// Count
global $oDB;
$arr = array();
$this->items = 0;
$oDB->Query( 'SELECT id,userid,username,issuedate,type FROM '.TABPOST.' WHERE topic='.$this->id.' ORDER BY issuedate' );
while($row=$oDB->Getrow())
{
$arr[]=$row;
if ( $row['type']=='R' ) $this->items++;
}
// save stats
$oDB->Query( 'UPDATE '.TABTOPIC.' SET replies='.$this->items.',firstpostid='.$arr[0]['id'].',firstpostuser='.$arr[0]['userid'].',firstpostname="'.$arr[0]['username'].'",firstpostdate="'.$arr[0]['issuedate'].'",lastpostid='.$arr[count($arr)-1]['id'].',lastpostuser='.$arr[count($arr)-1]['userid'].',lastpostname="'.$arr[count($arr)-1]['username'].'",lastpostdate="'.$arr[count($arr)-1]['issuedate'].'" WHERE id='.$this->id );
// close topic if full
if ( $intMax>1 ) {
if ( $this->items>$intMax ) {
$oDB->Query( 'UPDATE '.TABTOPIC.' SET status="Z" WHERE id='.$this->id );
}}
// update inspection stats
if ( $this->type==='I' && $bInspectionUpdateScore ) $this->InspectionUpdateScore();
}
// --- INSPECTION ---
public function InspectionUpdateScore()
{
$this->z = $this->InspectionAggregate();
global $oDB;
$oDB->Query( 'UPDATE '.TABTOPIC.' SET z='.$this->z.' WHERE id='.$this->id );
}
function InspectionAggregate()
{
if ( $this->id<0 || $this->items<1 ) return -1; // -1 means no results or unknown
$strIstat = strtolower($this->ReadOptions('Istat')); if ( empty($strIstat) ) $strIstat='mean';
global $oDB;
$i=-1;
switch ($strIstat)
{
case 'mean':
$oDB->Query( 'SELECT title FROM '.TABPOST.' WHERE topic='.$this->id.' AND type="R" AND title<>""' );
$arr = array();
$i=0;
while($row=$oDB->Getrow())
{
$str = strtolower(trim($row['title']));
if ( $str==='' || is_null($str) || $str==='null' ) continue;
if ( strlen($str)>4 ) $str = substr($str,0,4);
if ( !is_numeric($str) ) continue;
$arr[] = floatval($str);
$i++;
}
if ( empty($arr) ) return -1;
$i=(array_sum($arr))/$i;
break;
case 'min':
$oDB->Query( 'SELECT title FROM '.TABPOST.' WHERE topic='.$this->id.' AND type="R" AND title<>""' );
$i=999;
while($row=$oDB->Getrow())
{
$str = strtolower(trim($row['title']));
if ( $str==='' || is_null($str) || $str==='null' ) continue;
if ( strlen($str)>4 ) $str = substr($str,0,4);
if ( !is_numeric($str) ) continue;
if ( floatval($str)<$i ) $i=floatval($str);
}
if ( $i==999 ) return -1;
break;
case 'max':
$oDB->Query( 'SELECT title FROM '.TABPOST.' WHERE topic='.$this->id.' AND type="R" AND title<>""' );
while($row=$oDB->Getrow())
{
$str = strtolower(trim($row['title']));
if ( $str==='' || is_null($str) || $str==='null' ) continue;
if ( strlen($str)>4 ) $str = substr($str,0,4);
if ( !is_numeric($str) ) continue;
if ( floatval($str)>$i ) $i=floatval($str);
}
break;
case 'first':
$oDB->Query( 'SELECT title FROM '.TABPOST.' WHERE topic='.$this->id.' AND type="R" AND title<>"" ORDER BY issuedate' );
while($row=$oDB->Getrow())
{
$str = strtolower(trim($row['title']));
if ( $str==='' || is_null($str) || $str==='null' ) continue;
if ( strlen($str)>4 ) $str = substr($str,0,4);
if ( !is_numeric($str) ) continue;
return round(floatval($str),1);
}
break;
case 'last':
$oDB->Query( 'SELECT title FROM '.TABPOST.' WHERE topic='.$this->id.' AND type="R" AND title<>"" ORDER BY issuedate DESC' );
while($row=$oDB->Getrow())
{
$str = strtolower(trim($row['title']));
if ( $str==='' || is_null($str) || $str==='null' ) continue;
if ( strlen($str)>4 ) $str = substr($str,0,4);
if ( !is_numeric($str) ) continue;
return round(floatval($str),1);
}
break;
default: die('Unknown aggregation function ['.$strIstat.']');
}
return round($i,1);
}
// --------
// aQTcontainer implementations
// --------
public static function Drop($id)
{
if ( !is_int($id) ) die('cTopic->Delete: Argument #1 must be integer');
if ( $id<0 ) die('cTopic->Delete: Wrong argument #1 (id<0)');
global $oDB;
$oDB->Query('DELETE FROM '.TABTOPIC.' WHERE id='.$id);
$oDB->Query('DELETE FROM '.TABPOST.' WHERE topic='.$id);
}
public static function Create($title,$parentid) {} // Not used, see InsertTopic
public static function MoveItems($id,$destination) {} // Not used
public static function CountItems($id,$status)
{
// count number of 'reply'-posts
// post-status is not used
global $oDB;
$oDB->Query('SELECT count(id) as countid FROM '.TABPOST.' WHERE type<>"P"');
$row = $oDB->Getrow();
return (int)$row['countid'];
}
// --------
// IOptions implementations
// --------
public function ChangeOption($strKey,$strValue)
{
QTargs('cTopic->ChangeOption',array($strKey,$strValue));
if ( $strKey==='' ) die ('cTopic->ChangeOption: Missing key'); // $strKey can be ''
$arr = QTarradd(QTexplode($this->options),$strKey,$strValue);
$this->options = QTimplode($arr);
$this->WriteOptions();
return $arr;
}
public function ReadOptions($str='*')
{
// Returns an array of {parameter=>value} when $str is *
// Returns the value when $str is an existing key. Returns '' when $str is not defined or when $str in not an existing key
if ( $str==='*' ) return (empty($this->options) ? array() : QTexplode($this->options));
if ( empty($str) || empty($this->options) ) return '';
$arr = QTexplode($this->options);
if ( isset($arr[$str]) ) return $arr[$str];
return '';
}
public function WriteOptions()
{
global $oDB;
$oDB->Query( 'UPDATE '.TABTOPIC.' SET param="'.addslashes($this->options).'" WHERE id='.$this->id );
}
// --------
}