Skip to content

Commit

Permalink
Code cleaning on pfcglobalconfig and pfccontainer singleton instances
Browse files Browse the repository at this point in the history
git-svn-id: https://phpfreechat.svn.sourceforge.net/svnroot/phpfreechat/trunk@956 2772adf2-ac07-0410-9d30-e29d8120292e
  • Loading branch information
kerphi committed Feb 15, 2007
1 parent 02f3a69 commit c472519
Show file tree
Hide file tree
Showing 52 changed files with 262 additions and 309 deletions.
10 changes: 5 additions & 5 deletions demo/demo27_customized_command.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ function run(&$xml_reponse, $p)
$recipient = $p["recipient"];
$recipientid = $p["recipientid"];

$c =& $this->c;
$c =& pfcGlobalConfig::Instance();

$nick = $c->nick;
$container =& $c->getContainerInstance();
$text = trim($param);
$nick = $c->nick;
$ct =& pfcContainer::Instance();
$text = trim($param);

// Call parse roll
require_once dirname(__FILE__).'/demo27_dice.class.php';
Expand All @@ -33,7 +33,7 @@ function run(&$xml_reponse, $p)
else
{
$result = $dice->roll();
$container->write($recipient, $nick, "send", $result);
$ct->write($recipient, $nick, "send", $result);
}
if ($c->debug) pxlog("Cmd_roll[".$c->sessionid."]: msg=".$result, "chat", $c->getId());
}
Expand Down
1 change: 1 addition & 0 deletions demo/demo55_mysql_container.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

require_once dirname(__FILE__)."/../src/phpfreechat.class.php";
$params = array();
$params["serverid"] = md5(__FILE__); // calculate a unique id for this chat
$params["nick"] = "guest".rand(1,1000);
$params["container_type"] = "mysql";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

div#pfc_container {
border: black double 5px;
background-image: url("proxy.php?p=mytheme/images/brick.jpg");
background-image: url("<?php echo $c->getFileUrlFromTheme('images/brick.jpg'); ?>");
background-repeat: repeat;
padding: 20px;
color: black;
Expand All @@ -17,13 +17,13 @@

div.pfc_message {
background-color: transparent;
background-image: url("proxy.php?p=mytheme/images/newmsg.gif");
background-image: url("<?php echo $c->getFileUrlFromTheme('images/newmsg.gif'); ?>");
background-repeat: no-repeat;
background-position: right center;
}

div.pfc_oldmsg {
background-image: url("proxy.php?p=mytheme/images/oldmsg.gif");
background-image: url("<?php echo $c->getFileUrlFromTheme('images/oldmsg.gif'); ?>");
}

span.pfc_heure {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/asknick.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ function run(&$xml_reponse, $p)
$recipient = $p["recipient"];
$recipientid = $p["recipientid"];

$c =& $this->c;
$u =& $this->u;
$c =& pfcGlobalConfig::Instance();
$u =& pfcUserConfig::Instance();

$nicktochange = phpFreeChat::FilterNickname($param);

Expand Down
6 changes: 3 additions & 3 deletions src/commands/ban.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ function run(&$xml_reponse, $p)
$recipient = $p["recipient"];
$recipientid = $p["recipientid"];

$c =& $this->c;
$u =& $this->u;
$c =& pfcGlobalConfig::Instance();
$u =& pfcUserConfig::Instance();

$nick = isset($params[0]) ? $params[0] : '';
$reason = isset($params[1]) ? $params[1] : '';
Expand All @@ -34,7 +34,7 @@ function run(&$xml_reponse, $p)
return;
}

$ct =& $c->getContainerInstance();
$ct =& pfcContainer::Instance();
$nickidtoban = $ct->getNickId($nick);

// notify all the channel
Expand Down
6 changes: 3 additions & 3 deletions src/commands/banlist.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class pfcCommand_banlist extends pfcCommand

function run(&$xml_reponse, $p)
{
$c =& $this->c;
$u =& $this->u;
$c =& pfcGlobalConfig::Instance();
$u =& pfcUserConfig::Instance();

$ct =& $c->getContainerInstance();
$ct =& pfcContainer::Instance();
$banlist = $ct->getChanMeta($p["recipient"], 'banlist_nickid');

if ($banlist == NULL) $banlist = array(); else $banlist = unserialize($banlist);
Expand Down
4 changes: 2 additions & 2 deletions src/commands/clear.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class pfcCommand_clear extends pfcCommand
{
function run(&$xml_reponse, $p)
{
$c =& $this->c;
$u =& $this->u;
$c =& pfcGlobalConfig::Instance();
$u =& pfcUserConfig::Instance();

$xml_reponse->script("pfc.handleResponse('".$this->name."', 'ok', '');");
}
Expand Down
6 changes: 3 additions & 3 deletions src/commands/connect.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ function run(&$xml_reponse, $p)
$recipientid = $p["recipientid"];
$getoldmsg = isset($p["getoldmsg"]) ? $p["getoldmsg"] : true;

$c =& $this->c;
$u =& $this->u;
$ct =& $c->getContainerInstance();
$c =& pfcGlobalConfig::Instance();
$u =& pfcUserConfig::Instance();
$ct =& pfcContainer::Instance();

// reset the message id indicator (see getnewmsg.class.php)
// i.e. be ready to re-get all last posted messages
Expand Down
4 changes: 2 additions & 2 deletions src/commands/debug.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class pfcCommand_debug extends pfcCommand
{
function run(&$xml_reponse, $p)
{
$c =& $this->c;
$u =& $this->u;
$c =& pfcGlobalConfig::Instance();
$u =& pfcUserConfig::Instance();

if ($p["param"] == "userconfig")
{
Expand Down
6 changes: 3 additions & 3 deletions src/commands/deop.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class pfcCommand_deop extends pfcCommand

function run(&$xml_reponse, $p)
{
$c =& $this->c;
$u =& $this->u;
$c =& pfcGlobalConfig::Instance();
$u =& pfcUserConfig::Instance();

if (trim($p["param"]) == "")
{
Expand All @@ -24,7 +24,7 @@ function run(&$xml_reponse, $p)

// just change the "isadmin" meta flag
$nicktodeop = trim($p["param"]);
$container =& $c->getContainerInstance();
$container =& pfcContainer::Instance();
$nicktodeopid = $container->getNickId($nicktodeop);
$container->setUserMeta($nicktodeopid, 'isadmin', false);

Expand Down
2 changes: 1 addition & 1 deletion src/commands/error.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class pfcCommand_error extends pfcCommand
{
function run(&$xml_reponse, $p)
{
$c =& $this->c;
$c =& pfcGlobalConfig::Instance();
$errors = $p["param"];
if (is_array($errors))
{
Expand Down
4 changes: 2 additions & 2 deletions src/commands/getnewmsg.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function run(&$xml_reponse, $p)
$recipient = $p["recipient"];
$recipientid = $p["recipientid"];

$c =& $this->c;
$c =& pfcGlobalConfig::Instance();
// do nothing if the recipient is not defined
if ($recipient == "") return;

Expand All @@ -50,7 +50,7 @@ function run(&$xml_reponse, $p)


// read the last from_id value
$container =& $c->getContainerInstance();
$container =& pfcContainer::Instance();
$from_id_sid = "pfc_from_id_".$c->getId()."_".$clientid."_".$recipientid;
$from_id = 0;
if (isset($_SESSION[$from_id_sid]))
Expand Down
4 changes: 2 additions & 2 deletions src/commands/help.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ function run(&$xml_reponse, $p)
$recipient = $p["recipient"];
$recipientid = $p["recipientid"];

$c =& $this->c;
$u =& $this->u;
$c =& pfcGlobalConfig::Instance();
$u =& pfcUserConfig::Instance();

$ignore = array("updatemynick", "getnewmsg", "notice", "getonlinenick", "error", "update", "asknick");

Expand Down
6 changes: 3 additions & 3 deletions src/commands/identify.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ function run(&$xml_reponse, $p)
$recipient = $p["recipient"];
$recipientid = $p["recipientid"];

$c =& $this->c;
$u =& $this->u;
$c =& pfcGlobalConfig::Instance();
$u =& pfcUserConfig::Instance();

$password = trim($param);
$isadmin = false;
Expand All @@ -57,7 +57,7 @@ function run(&$xml_reponse, $p)
if ($isadmin)
{
// ok the current user is an admin, just save the isadmin flag in the metadata
$ct =& $c->getContainerInstance();
$ct =& pfcContainer::Instance();
$ct->setUserMeta($u->nickid, 'isadmin', $isadmin);
$this->forceWhoisReload($u->nick);

Expand Down
4 changes: 2 additions & 2 deletions src/commands/init.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ function run(&$xml_reponse, $p)
$recipient = $p["recipient"];
$recipientid = $p["recipientid"];

$c =& $this->c;
$u =& $this->u;
$c =& pfcGlobalConfig::Instance();
$u =& pfcUserConfig::Instance();

$cmd =& pfcCommand::Factory("quit");
$cmd->run($xml_reponse, $p);
Expand Down
6 changes: 3 additions & 3 deletions src/commands/invite.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ function run(&$xml_reponse, $p)
$recipient = $p["recipient"];
$recipientid = $p["recipientid"];

$c =& $this->c; // pfcGlobalConfig
$u =& $this->u; // pfcUserConfig
$ct =& $c->getContainerInstance(); // Connection to the chatbackend
$c =& pfcGlobalConfig::Instance(); // pfcGlobalConfig
$u =& pfcUserConfig::Instance(); // pfcUserConfig
$ct =& pfcContainer::Instance(); // Connection to the chatbackend

$nicktoinvite = isset($params[0]) ? $params[0] : '';
$channeltarget = isset($params[1]) ? $params[1] : $u->channels[$recipientid]["name"]; // Default: current channel
Expand Down
6 changes: 3 additions & 3 deletions src/commands/join.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ function run(&$xml_reponse, $p)
$recipient = $p["recipient"];
$recipientid = $p["recipientid"];

$c =& $this->c;
$u =& $this->u;
$c =& pfcGlobalConfig::Instance();
$u =& pfcUserConfig::Instance();

$channame = trim($param);
$chanrecip = pfcCommand_join::GetRecipient($channame);
Expand Down Expand Up @@ -55,7 +55,7 @@ function run(&$xml_reponse, $p)
}

// register the user (and his metadata) in the channel
$ct =& $c->getContainerInstance();
$ct =& pfcContainer::Instance();
$ct->createNick($chanrecip, $u->nick, $u->nickid);
$this->forceWhoisReload($u->nick);

Expand Down
6 changes: 3 additions & 3 deletions src/commands/kick.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ function run(&$xml_reponse, $p)
$recipient = $p["recipient"];
$recipientid = $p["recipientid"];

$c =& $this->c;
$u =& $this->u;
$c =& pfcGlobalConfig::Instance();
$u =& pfcUserConfig::Instance();

$nick = isset($params[0]) ? $params[0] : '';
$reason = isset($params[1]) ? $params[1] : '';
Expand All @@ -34,7 +34,7 @@ function run(&$xml_reponse, $p)
}

// kicking a user just add a command to play to the aimed user metadata.
$ct =& $c->getContainerInstance();
$ct =& pfcContainer::Instance();
$otherid = $ct->getNickId($nick);
$channame = $u->channels[$recipientid]["name"];
$cmdstr = 'leave';
Expand Down
6 changes: 3 additions & 3 deletions src/commands/leave.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ function run(&$xml_reponse, $p)
$recipient = $p["recipient"];
$recipientid = $p["recipientid"];

$c =& $this->c;
$u =& $this->u;
$ct =& $c->getContainerInstance();
$c =& pfcGlobalConfig::Instance();
$u =& pfcUserConfig::Instance();
$ct =& pfcContainer::Instance();

$type = isset($params[0]) ? $params[0] : '';
$name = isset($params[1]) ? $params[1] : '';
Expand Down
6 changes: 3 additions & 3 deletions src/commands/me.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ function run(&$xml_reponse, $p)
$recipient = $p["recipient"];
$recipientid = $p["recipientid"];

$c =& $this->c;
$u =& $this->u;
$c =& pfcGlobalConfig::Instance();
$u =& pfcUserConfig::Instance();

if (trim($param) == "")
{
Expand All @@ -28,7 +28,7 @@ function run(&$xml_reponse, $p)
return;
}

$container =& $c->getContainerInstance();
$container =& pfcContainer::Instance();
$msg = phpFreeChat::PreFilterMsg($param);
$container->write($recipient, "*me*", $this->name, $u->nick." ".$msg);

Expand Down
6 changes: 3 additions & 3 deletions src/commands/nick.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ function run(&$xml_reponse, $p)
$recipient = $p["recipient"];
$recipientid = $p["recipientid"];

$c =& $this->c;
$u =& $this->u;
$c =& pfcGlobalConfig::Instance();
$u =& pfcUserConfig::Instance();

if (trim($param) == "")
{
Expand All @@ -31,7 +31,7 @@ function run(&$xml_reponse, $p)
$newnick = phpFreeChat::FilterNickname($param);
$oldnick = $u->nick;

$container =& $c->getContainerInstance();
$container =& pfcContainer::Instance();
$newnickid = $container->getNickId($newnick);
$oldnickid = $container->getNickId($oldnick);

Expand Down
6 changes: 3 additions & 3 deletions src/commands/notice.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ function run(&$xml_reponse, $p)
$recipientid = $p["recipientid"];
$flag = isset($p["flag"]) ? $p["flag"] : 3;

$c =& $this->c;
$u =& $this->u;
$c =& pfcGlobalConfig::Instance();
$u =& pfcUserConfig::Instance();

if ($c->shownotice > 0 &&
($c->shownotice & $flag) == $flag)
{
$container =& $c->getContainerInstance();
$container =& pfcContainer::Instance();
$msg = phpFreeChat::FilterSpecialChar($msg);
$res = $container->write($recipient, $u->nick, "notice", $msg);
if (is_array($res))
Expand Down
6 changes: 3 additions & 3 deletions src/commands/op.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ function run(&$xml_reponse, $p)
$recipient = $p["recipient"];
$recipientid = $p["recipientid"];

$c =& $this->c;
$u =& $this->u;
$c =& pfcGlobalConfig::Instance();
$u =& pfcUserConfig::Instance();

if (trim($param) == "")
{
Expand All @@ -30,7 +30,7 @@ function run(&$xml_reponse, $p)

// just change the "isadmin" meta flag
$nicktoop = trim($param);
$container =& $c->getContainerInstance();
$container =& pfcContainer::Instance();
$nicktoopid = $container->getNickId($nicktoop);
$container->setUserMeta($nicktoopid, 'isadmin', true);

Expand Down
8 changes: 4 additions & 4 deletions src/commands/privmsg.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ function run(&$xml_reponse, $p)
$recipient = $p["recipient"];
$recipientid = $p["recipientid"];

$c =& $this->c;
$u =& $this->u;
$c =& pfcGlobalConfig::Instance();
$u =& pfcUserConfig::Instance();

$pvname = $param;

// check the pvname exists on the server
$container =& $c->getContainerInstance();
$container =& pfcContainer::Instance();
$pvnickid = $container->getNickId($pvname);
$nickid = $u->nickid;

Expand Down Expand Up @@ -83,7 +83,7 @@ function run(&$xml_reponse, $p)
}

// register the user (and his metadata) in this pv
$ct =& $c->getContainerInstance();
$ct =& pfcContainer::Instance();
$ct->createNick($pvrecipient, $u->nick, $u->nickid);
$this->forceWhoisReload($u->nick);

Expand Down
Loading

0 comments on commit c472519

Please sign in to comment.