Forums | Mahara Community

Developers /
I am going nuts here.


Allen Burker's profile picture
Posts: 112

14 March 2010, 6:58 PM

Hi,

    I really hate posting questions here but, I have been trying to fix this issue all day. The notifications stick and all I see is the Loading.... message. Yesterday it worked fine and today it decides it doesn't want to. There are no error logs, doe anyone know where to look to fix this issue?

Thanks so much:)

Allen Burker's profile picture
Posts: 112

15 March 2010, 4:06 PM

Hello all,

            Sometimes I read my post over and I see how bad my brain is fried on certain days when I look at my spelling.  Anyways, I wanted to clear a few things up with this issue. I haven't modified the notifications or any of the pieforms that would cause this issue.

Penny Leach's profile picture
Posts: 228

15 March 2010, 4:52 PM

Can you install the firefox extension firebug, and watch the xmlhttprequests and have a look at what the request and response says?

 

Here's a howto: http://codeclimber.net.nz/archive/2007/08/01/How-to-debug-XmlHttpRequest-with-Firebug.aspx

 

Allen Burker's profile picture
Posts: 112

15 March 2010, 8:39 PM

I am not real familiar with firebug and I'll just post the information. It seems to be working fine. So, I am not sure.

This was from the post.

Parametersapplication/x-www-form-urlencoded
limit10
offset0
sesskeyM5vGngXfpYTWQIAP
typeall
Source
offset=0&limit=10&type=all&sesskey=M5vGngXfpYTWQIAP

 This was from the response.

 

define('INTERNAL', 1);
define('JSON', 1);

require(dirname(dirname(dirname(__FILE__))) . '/init.php');

json_headers();

$markasread = param_integer('markasread', 0);
$delete = param_integer('delete', 0);
$quiet = param_integer('quiet', 0);

if ($markasread) {
$count = 0;
db_begin();
try {
foreach ($_GET as $k => $v) {
if (preg_match('/^unread\-(\d+)$/',$k,$m)) {
set_field('notification_internal_activity', 'read', 1, 'id', $m[1], 'usr', $USER->get('id'));
$count++;
}
}
}
catch (Exception $e) {
db_rollback();
json_reply('local', get_string('failedtomarkasread', 'activity') . ': ' . $e->getMessage());
}
db_commit();
if ($quiet) {
json_reply(false, null);
}
json_reply(false, array('message' => get_string('markedasread', 'activity'), 'count' => $count));
}
else if ($delete) {
$count = 0;
db_begin();
try {
foreach ($_GET as $k => $v) {
if (preg_match('/^delete\-(\d+)$/',$k,$m)) {
delete_records('notification_internal_activity', 'id', $m[1], 'usr', $USER->get('id'));
$count++;
}
}
}
catch (Exception $e) {
db_rollback();
json_reply('local', get_string('failedtodeletenotifications', 'activity') . ': ' . $e->getMessage());
}
db_commit();

safe_require('notification', 'internal');

json_reply(false, array(
'message' => get_string('deletednotifications', 'activity', $count),
'count' => $count,
'newunreadcount' => call_static_method(generate_class_name('notification', 'internal'), 'unread_count', $USER->get('id'))
));
}

// normal processing

$type = param_alphanum('type', 'all');
$limit = param_integer('limit', 10);
$offset = param_integer('offset', 0);

$userid = $USER->get('id');

if ($type == 'all') {
$count = count_records('notification_internal_activity', 'usr', $userid);
$sql = 'SELECT a.*, at.name AS type,at.plugintype, at.pluginname FROM {notification_internal_activity} a
JOIN {activity_type} at ON a.type = at.id
WHERE a.usr = ? ORDER BY ctime DESC';
$records = get_records_sql_array($sql, array($userid), $offset, $limit);
} else if ($type == 'adminmessages' && $USER->get('admin')) {
$count = count_records_select('notification_internal_activity', 'usr = ? AND type IN (
SELECT id FROM {activity_type} WHERE admin = ?)',
array($userid, 1));
$sql = 'SELECT a.*, at.name AS type,at.plugintype, at.pluginname FROM {notification_internal_activity} a
JOIN {activity_type} at ON a.type = at.id
WHERE a.usr = ? AND at.admin = ? ORDER BY ctime DESC';
$records = get_records_sql_array($sql, array($userid, 1), $offset, $limit);
}
else {
$count = count_records_select('notification_internal_activity', 'usr = ? AND type = ?',
array($userid,$type));
$sql = 'SELECT a.*, at.name AS type,at.plugintype, at.pluginname FROM {notification_internal_activity} a
JOIN {activity_type} at ON a.type = at.id
WHERE a.usr = ? AND a.type = ?';
$records = get_records_sql_array($sql, array($userid, $type), $offset, $limit);
}

if (empty($records)) {
$records = array();
}
$data = array();
$star = $THEME->get_url('images/star.png');
$unread = get_string('unread', 'activity');

foreach ($records as &$r) {
$r->date = format_date(strtotime($r->ctime));
$section = 'activity';
if (!empty($r->plugintype)) {
$section = $r->plugintype . '.' . $r->pluginname;
}
$r->type = get_string('type' . $r->type, $section);
$r->message = clean_html(format_whitespace($r->message));
}

$activity = array(
'count' => $count,
'offset' => $offset,
'limit' => $limit,
'data' => $records,
'star' => $star,
'unread' => $unread,
);

echo json_encode($activity);
?>
 
Penny Leach's profile picture
Posts: 228

16 March 2010, 2:48 AM

ok, that's bizarre.  The script that handles the xmlhttprequest is sending back the php source code, rather than the processed data.

This could either be an apache misconfiguration, which I doubt if it's only happening on the notifications page, or the <?php tag could maybe have been removed from the top of that page?  It's account/activity/index.json.php

Allen Burker's profile picture
Posts: 112

16 March 2010, 7:34 PM

OMG,

        I think it's time to take a break from coding. I spent a whole day looking into the notifications files and I never noticed that the <?php tag was missing. I can't literally stop laughing at myself. 

Now, I have more question concerning the notifications. When any user receives a new message the message stats it's read. I have downloaded mahara and compared those with my php files that pertain to the notifications. They both are identical and can't seem to find why this is happening? I wish I had a error log for this but, there isn't one. Would make it a lot easier to find the issue.  Do you have a guess to why this might happen?

Thanks again for your help.

Penny Leach's profile picture
Posts: 228

17 March 2010, 3:07 AM

If I recall correctly, when an activity noficiation is sent via some other notification plugin than internal (email or email digest), it also adds it to the activity log, but marks it as read.  Could it be the preferences on your local install?

Having said that I'm not sure that's working since I have 544 unread messages on mahara.org and I'm pretty sure that can't all be stuff I haven't had emails about.

Allen Burker's profile picture
Posts: 112

18 March 2010, 10:29 PM

Well, the auto installer installed it. I have looked through the files for a setting but, didn't see anything. Maybe I over looked it.
8 results