Hi

When I set name of channel in node edit, (content type settings per node with option to have own channel name) phpfreechat load but without channel
It show error: missing parameter /join channelname
when I set default channel in phpfreechat settings (admin/settings/phpfreechat), everything works fine.

thanks
Igorik

Comments

permutations’s picture

I'll take a look at this.

So you saw my note about how to fix the "Anonymous" problem? If that solved the problem for you, I'd like to close the issue so please post a note there.

gumdrop’s picture

I am getting the same issues as well.

browlands’s picture

Ditto, same issue, subscribing

2006drupal’s picture

Me too.

sebzur’s picture

And me. No channel at node page.

kasalla’s picture

I have/had the same issue. But only if I close the channel manually. At the initial installation the channel were displayed well.

cronix’s picture

Subscribing. Has anyone found a solution?

cronix’s picture

I have found the error, but I am not able to solve it. Who can help me out with this?

handler.php containts the following around line77

  $args = explode('/', drupal_get_normal_path($path));
  $node = db_fetch_object(db_query('SELECT * FROM {node} n INNER JOIN {phpfreechat} pfc ON pfc.nid = n.nid WHERE n.nid = %d', $args[1]));

I am using pathauto and clean URL's. The code above is expecting that $args[1] contains the node id. But in my installation it holds the string "content" because the URL to my chatroom is: en/content/general-chat. For some reason drupal_get_normal_path is not returning the correct internal path representation.

Who can help with this code? We only need to figure out how to get the proper node id and this issue is solved.

cronix’s picture

Anyone active in this thread? The errors is due to the fact that I use a language prefex in the URL since my site is running multiple languages. The call to drupal_get_normal_path should be (for my example en/content/general-chat URL):

drupal_get_normal_path('content/general', 'en');

and not (which is what currently is happening in the code)

drupal_get_normal_path('en/content/general'

This is very fixeable, but I am unable to retrieve the value of $language in order to get the current users' language. I don't understand why this global is not set in handler.php.

fox mulder’s picture

Hi everybody!

I have got same problem (phpfreechat ignores "pernode" settings).

Some remarks:

If I set to true the debug option on admin/settings/phpfreechat and type some channel name on edit form of the node, than the typed name appears in channels array in Parameters, but the pfcuserconfig_123456789xyz_channels array in Session is empty. Adding a default channel solves the "missing parameter (/join {})" problem, but admin/settings/phpfreechat says:

Leaving this (Default Channels field) blank will auto-generate a string based on the title parameter

If I leave the Default Channels blank, the title of the node appears in channels array in Parameters truly, but not in pfcuserconfig_123456789xyz_channels array in Session.

I think, the problem is not in the Drupal module (I printed out the $params array from phpFreeChat() function of phpFreeChat class (modules/phpfreechat/phpfreechat/src/phpfreechat.class.php), and it contains the correct channels value) but in the phpfreechat itself.

Versions: D 6.12, phpfreechat 1.2, phpfreechat module 6.x-1.1.
Any ideas? Many thanks for the module and sorry about my bad english!

cronix’s picture

It is in the module like I stated in #9. I have hardcoded a fix for myself that includes the language in the drupal_get_normal_path call and all is working.

Are you using language prefixes as well? Then my fix will probably work for you too.

fox mulder’s picture

Hi cronix!

Thank you for your help.
I use only hungarian language, and a drupal_set_message() shows that the module finds the current node correctly. I tried a standalone phpfreechat on localhost, and it worked well.

If I understand your hack correctly, it is inside a(n) if (!function_exist('arg')) {...} statement isn't it? Because arg() function exists (because it is part of Drupal), the modified (and the unmodified too) drupal_get_normal_path() doesn't ever run. How does your hack work?

PS.: I don't know exactly how, but URL aliases cause the ignored "pernode" settings and empty "latest form.." block problems. If a node hasn't got a URL alias or a node has an alias but I use node/nn syntax in location bar of the browser than phpfreechat works correctly.

Any ideas?

wilton.pinheiro’s picture

Same issue here.....

typehost’s picture

I can confirm "fox mulder's" description - i.e. when I changed the name of the node to "node/nn" the per-node defined chat channels did appear correctly in the ppfreechat display for the first time rather than the globals. However, it still does not work when the page is called in a block through a view in a panel page. So maybe the problem is the use of the http extractor to get the node id in handler.php?

  // Use HTTP_REFERER to extract the node ID
  $path = str_replace(array($base_url .'/', '/?q='), '', $_SERVER['HTTP_REFERER']);

I would like to find a way to correct this so the channels work correctly in retrieving the nid even in blocks and panels. Thanks.

reference - handler.php (lines 71-81):

// We will need to load the current node
if (!function_exists('arg')) {
  // Use HTTP_REFERER to extract the node ID
  $path = str_replace(array($base_url .'/', '/?q='), '', $_SERVER['HTTP_REFERER']);
  // Get the real path from the current request
  require_once('./includes/path.inc');
  $args = explode('/', drupal_get_normal_path($path));
  $node = db_fetch_object(db_query('SELECT * FROM {node} n INNER JOIN {phpfreechat} pfc ON pfc.nid = n.nid WHERE n.nid = %d', $args[1]));
  if ($_SESSION['drupal_user']) {
    $user =& $_SESSION['drupal_user'];
  }
jewseppi’s picture

Okay I've got a solution/hack that I can GUARANTEE will work.

The problem is in 'join.class.php' in /phpfreechat/src/commands. I followed the params are far as I could and it looks like they are not being properly passed to the run function in the join.class.php file. It seems that when the run function is constructed the params variable is not yet populated, I tried creating session variables to hold the channel params but again, they were populating after the code in the join.class.php file.

The workaround requires you to set your channel in the join.class.php file. My channels are named based on the node title, but since phpFreeChat is managed by 'handler.php', $_SERVER variables regarding the path refer to the handler, some minor adjustments and we have the path in the address bar and not the path of the handler.php. From the path name, I can locate the nid in the url_alias table, and then extract the node title from the respective nid in the node table.

Works every time! ...

comment out line 20: //$channame = trim($param);
replace with the following:

// extract url alias and nid
$title = explode("/", $_SERVER['HTTP_REFERER']);
$query = db_query("SELECT src FROM `url_alias` WHERE dst = '%s'", $title[3]."/".$title[4]);
$result = db_fetch_object($query)->src;

// extract group title (channel name)
$query = db_query("SELECT title FROM `node` WHERE nid = '%s'", substr($result, strpos($result, "/") + 1));
$result = db_fetch_object($query)->title;

$channame = "Chat on ".$result;

permutations’s picture

Issue summary: View changes

The problem with that solution, from a module perspective, is it's a fix to phpFreeChat itself, not to the module. So maybe this isn't something the module can control.

permutations’s picture

Status: Active » Closed (won't fix)