I have written a /topic command.. it stores the topic in chanmeta data and works with sites that have multiple rooms, only operators and admins can change the topic.
/src/commands/topic.class.php
- Code: Select all
<?php
require_once(dirname(__FILE__)."/../pfccommand.class.php");
class pfcCommand_topic extends pfcCommand
{
var $usage = "/topic {message}";
function run(&$xml_reponse, $p)
{
$clientid = $p["clientid"];
$param = $p["param"];
$sender = $p["sender"];
$recipient = $p["recipient"];
$recipientid = $p["recipientid"];
$c =& pfcGlobalConfig::Instance();
$u =& pfcUserConfig::Instance();
$ct =& pfcContainer::Instance();
$isadmin = $ct->getUserMeta($u->nickid, 'isadmin');
if (trim($param) == "")
{
$room = str_replace('ch_', "", $recipient);
$topic = $ct->getChanMeta($recipient, "topic");
$ct->write($recipient, "*notice*", $this->name, "[b]".$room."[/b] - current topic: [i][u]".$topic."[/i][/u]");
return;
}
if ($isadmin) {
$msg = phpFreeChat::PreFilterMsg($param);
$ct->setChanMeta($recipient, "topic", $msg);
$cmdp = $p;
$cmdp["recipient"] = $recipient;
$cmdp["recipientid"] = $recipientid;
$cmdp["param"] = _pfc('%s changes the topic to: %s',$u->getNickname(), $msg);
$cmd =& pfcCommand::Factory("notice");
$cmd->run($xml_reponse, $cmdp);
}else{
$xml_reponse->script("pfc.handleResponse('help', 'ok', 'only ops can change the topic');");
}
}
?>
Add this next line to the main.php file for the language your using. These files are located in the /i18n/ folder.
example: /i18n/en_US/main.php (line 405)
- Code: Select all
// topic.class.php
$GLOBALS["i18n"]["%s changes the topic to: %s"] = "%s changes the topic to: %s";
Then add these few lines to /join to display the topic to the room when a new user enters.
/src/commands/join.php (line 56)
- Code: Select all
//topic displayed when joining
$topic = $ct->getChanMeta($chanrecip, "topic");
if ($topic != ""){
$ct->write($chanrecip, "*notice*", "topic", "[b]".$channame."[/b] - current topic: [i][u]".$topic."[/i][/u]");
} else {
$ct->write($chanrecip, "*notice*", "topic", "[b]".$channame."[/b] - current topic: [i][u]no topic set[/i][/u]");
}
enjoy!