Example #1
0
function file_river_hook($object_type, $event, $object)
{
    global $CFG;
    $userid = $_SESSION['userid'] == "" ? -1 : $_SESSION['userid'];
    $object_id = $object->ident;
    $object_owner = $object->owner;
    $filepath = $CFG->wwwroot . user_info("username", $userid) . "/files/{$object->folder}/{$object->ident}/" . urlencode($object->originalname);
    $name = $object->originalname;
    $username = user_info("username", $userid);
    if ($userid == false) {
        $username = __gettext("Anonymous user");
    }
    if ($event == "publish") {
        river_save_event($userid, $object_id, $object_owner, $object_type, "<a href=\"" . river_get_userurl($userid) . "\">{$username}</a> uploaded '<a href=\"{$filepath}\">{$name}</a>'", $object->access);
    }
    if ($event == "delete") {
        river_save_event($userid, $object_id, $object_owner, $object_type, "<a href=\"" . river_get_userurl($userid) . "\">{$username}</a> deleted '{$name}'", $object->access);
    }
    return $object;
}
                 $object_title = get_title($comment->object_id, $comment->object_type);
                 $message = __gettext(sprintf("You have received a comment from %s on '%s'. It reads as follows:", $comment->postedname, stripslashes($object_title)));
                 $message .= "\n\n" . stripslashes($comment->body) . "\n\n";
                 $message .= __gettext(sprintf("To reply and see other comments, click here: %s", $redirect_url));
                 $message = wordwrap($message);
                 message_user($object_owner, $comment->owner, stripslashes($object_title), $message);
             }
         }
     }
 } else {
     $messages[] = __gettext("Your comment could not be posted. The system thought it was spam.");
 }
 // If river plugin installed then note comment
 if (function_exists('river_save_event')) {
     $commenturl = $CFG->wwwroot . "mod/generic_comments/comment_page.php?object_id={$comment->object_id}&object_type={$comment->object_type}&comment_sort=ASC";
     $username = "******"" . river_get_userurl($comment->owner) . "\">" . user_info("username", $comment->owner) . "</a>";
     if (!isset($comment->owner)) {
         $comment->owner = -1;
         $username = __gettext("Anonymous user");
     }
     river_save_event($comment->owner, $comment->object_id, $comment->owner, $comment->object_type, $username . " <a href=\"{$commenturl}\">" . __gettext("commented on") . "</a> " . river_get_friendly_id($comment->object_type, $comment->object_id));
 }
 $xml = optional_param('returnformat', '');
 if (!empty($xml)) {
     // If we are returning xml for the ajax response then output message and die.
     if ($ok != true) {
         $ok = "<error>1</error>\n";
     } else {
         $messages[] = __gettext(" Click <a href=\"\">here</a> to refresh");
         $ok = "<error>0</error>\n";
     }
Example #3
0
function community_river_hook($object_type, $event, $object)
{
    global $CFG;
    $userid = $_SESSION['userid'] == "" ? -1 : $_SESSION['userid'];
    $object_id = $object->ident;
    $object_owner = $object->owner;
    $title = trim($object->name);
    $username = user_info("name", $userid);
    $weblogname = "<a href=\"" . river_get_userurl($userid) . "\">" . user_info("name", $object_id) . "</a>'s";
    if ($userid == $object_owner) {
        $weblogname = __gettext("their");
    }
    if ($username == false) {
        $username = __gettext("Anonymous user");
    }
    if ($event == "publish") {
        river_save_event($userid, $object_id, $object_owner, $object_type, "<a href=\"" . river_get_userurl($userid) . "\">{$username}</a> created the community <a href=\"{$CFG->wwwroot}{$object->username}\">{$object->name}</a>.");
    }
    return $object;
}
Example #4
0
function blog_river_hook($object_type, $event, $object)
{
    global $CFG;
    $userid = $_SESSION['userid'] == "" ? -1 : $_SESSION['userid'];
    $object_id = $object->ident;
    $object_owner = $object->owner;
    $title = trim($object->title);
    $weblogid = $object->weblog;
    $username = user_info("username", $userid);
    $weblogname = "<a href=\"" . river_get_userurl($weblogid) . "\">" . user_info("username", $weblogid) . "</a>'s";
    if ($userid == $weblogid) {
        $weblogname = __gettext("their");
    }
    $entryurl = $CFG->wwwroot . $username . "/weblog/" . $object->ident . ".html";
    $titletxt = "";
    if ($title != "") {
        $titletxt = sprintf(__gettext(" called '%s'"), $title);
    }
    if ($username == false) {
        $username = __gettext("Anonymous user");
    }
    if ($event == "publish") {
        river_save_event($userid, $object_id, $object_owner, $object_type, "<a href=\"" . river_get_userurl($userid) . "\">{$username}</a> left a <a href=\"{$entryurl}\">post{$titletxt}</a> in {$weblogname} blog.", $object->access);
    }
    return $object;
}
                         $wl->weblog_post = $comment->post_id;
                         insert_record('weblog_watchlist', $wl);
                     }
                     // Email comment if applicable
                     if ($comment->owner != $post->owner) {
                         $message = sprintf(__gettext("You have received a comment from %s on your blog post '%s'. It reads as follows:"), $comment->postedname, stripslashes($post->title));
                         $message .= "\n\n" . stripslashes($comment->body) . "\n\n";
                         $message .= sprintf(__gettext("To reply and see other comments on this blog post, click here: %s"), $CFG->wwwroot . user_info("username", $post->weblog) . "/weblog/" . $post->ident . ".html");
                         $message = wordwrap($message);
                         message_user($post->owner, $comment->owner, stripslashes($post->title), $message);
                     }
                     // If river plugin installed then note comment
                     if (function_exists('river_save_event')) {
                         $un = user_info("username", $comment->owner);
                         $commenturl = $CFG->wwwroot . "{$un}/weblog/{$comment->post_id}.html#cmt{$comment->ident}";
                         $username = "******"" . river_get_userurl($comment->owner) . "\">{$un}</a>";
                         if (!isset($comment->owner)) {
                             $comment->owner = -1;
                             $username = __gettext("Anonymous user");
                         }
                         river_save_event($post->owner, $comment->ident, $comment->owner, "weblog_post::post", $username . " <a href=\"{$commenturl}\">" . __gettext("commented on") . "</a> " . river_get_friendly_id("weblog_post::post", $comment->post_id));
                     }
                 }
             }
         } else {
             $messages[] = __gettext("Your comment could not be posted. The system thought it was spam.");
         }
         define('redirect_url', url . user_info("username", $post->owner) . "/{$extensionContext}/" . $commentbackup->post_id . ".html");
     }
 } else {
     $messages[] = __gettext("Your comment body or name is empty.");
     }
     // Hook for the river plugin (if installed)
     if (function_exists('river_save_event')) {
         $verb = __gettext("left");
         if ($reply != "") {
             $verb = __gettext("replied to");
         }
         // Wall owner
         $string = sprintf(__gettext("<a href=\"%s\">%s</a> {$verb} a message on <a href=\"%s\">%s's comment wall</a>"), river_get_userurl($comment_owner), user_info("name", $comment_owner), river_get_userurl($wallowner), user_info("name", $wallowner));
         river_save_event($wallowner, $success, $comment_owner, "commentwall::post", $string);
         // Comment owner
         $noun = __gettext("A message");
         if ($reply != "") {
             $noun = __gettext("A reply");
         }
         $string = sprintf(__gettext("{$noun} was left by <a href=\"%s\">%s</a> in <a href=\"%s\">%s's comment wall</a>"), river_get_userurl($comment_owner), user_info("name", $comment_owner), river_get_userurl($wallowner), user_info("name", $wallowner));
         river_save_event($comment_owner, $success, $comment_owner, "commentwall::post", $string);
     }
 } else {
     $messages[] = __gettext("Comment could not be posted.");
 }
 // Are we outputing XML or text
 if ($displaymode == "xml") {
     $message = implode(" \n", $messages);
     if ($success) {
         $err = "0";
     } else {
         $err = "1";
     }
     $page = "<ajax>\n<message>{$message}</message>\n<error>{$err}</error>\n</ajax>\n";
 } else {