Esempio n. 1
0
function get_subject($resource_id, $type)
{
    switch ($type) {
        case 0:
            // comment
            return Comment::GetSubject($resource_id);
        case 1:
            // pm
            return PrivateMessage::GetSubject($resource_id);
        default:
            return '';
    }
}
Esempio n. 2
0
function save_post($message_id)
{
    global $link, $db, $message, $current_user, $globals, $site_key;
    $message = new PrivateMessage();
    $to_user = User::get_valid_username($_POST['to_user']);
    if (!$to_user) {
        echo 'ERROR: ' . _('nombre de usuario erróneo');
        die;
    }
    $to = User::get_user_id($to_user);
    if (!$to > 0) {
        echo 'ERROR: ' . _('usuario erróneo');
        die;
    }
    if (!PrivateMessage::can_send($current_user->user_id, $to)) {
        echo 'ERROR: ' . _('el destinatario no lo tiene amigado');
        die;
    }
    $_POST['post'] = clean_text_with_tags($_POST['post'], 0, false, $globals['posts_len']);
    if (!empty($_FILES['image']['tmp_name'])) {
        $limit_exceded = Upload::current_user_limit_exceded($_FILES['image']['size']);
        if ($limit_exceded) {
            echo 'ERROR: ' . $limit_exceded;
            die;
        }
    }
    if (mb_strlen($_POST['post']) < 2) {
        echo 'ERROR: ' . _('texto muy corto');
        die;
    }
    if ($current_user->user_id != intval($_POST['author'])) {
        die;
    }
    // Check the post wasn't already stored
    $message->randkey = intval($_POST['key']);
    $message->author = $current_user->user_id;
    $message->to = $to;
    $message->content = $_POST['post'];
    $db->transaction();
    $dupe = intval($db->get_var("select count(*) from privates where user = {$current_user->user_id} and date > date_sub(now(), interval 5 minute) and randkey = {$message->randkey} FOR UPDATE"));
    if (!$dupe) {
        // Verify that there are a period of 1 minute between posts.
        if (intval($db->get_var("select count(*) from privates where user= {$current_user->user_id} and date > date_sub(now(), interval 15 second)")) > 0) {
            echo 'ERROR: ' . _('debe esperar 15 segundos entre mensajes');
            $db->rollback();
            die;
        }
        // Verify that there less than X messages from the same user in a day
        if (intval($db->get_var("select count(*) from privates where user= {$current_user->user_id} and date > date_sub(now(), interval 1 day)")) > 160) {
            echo 'ERROR: ' . _('demasiados mensajes en un día');
            die;
        }
        $db->commit();
        $message->store();
        notify_user($current_user->user_id, $to, $message->content);
        User::add_notification($message->to, 'private');
    } else {
        $db->commit();
        echo 'ERROR: ' . _('mensaje grabado previamente');
        die;
    }
    // Check image upload or delete
    if ($_POST['image_delete']) {
        $message->delete_image();
    } else {
        $message->store_image_from_form('image');
    }
    $message = PrivateMessage::from_db($message->id);
    // Reread the object
    $message->print_summary();
}
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = PrivateMessage::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Esempio n. 4
0
 * License: http://www.bluethrust.com/license.php
 *
 */
include_once "../../../_setup.php";
include_once "../../../classes/member.php";
include_once "../../../classes/rank.php";
include_once "../../../classes/pmfolder.php";
include_once "../../../classes/privatemessage.php";
// Start Page
$consoleObj = new ConsoleOption($mysqli);
$cID = $consoleObj->findConsoleIDByName("Private Messages");
$consoleObj->select($cID);
$consoleInfo = $consoleObj->get_info_filtered();
$member = new Member($mysqli);
$member->select($_SESSION['btUsername']);
$pmObj = new PrivateMessage($mysqli);
$multiMemPMObj = $pmObj->multiMemPMObj;
// Check Login
$LOGIN_FAIL = true;
if ($member->authorizeLogin($_SESSION['btPassword']) && $member->hasAccess($consoleObj)) {
    $memberInfo = $member->get_info_filtered();
    $arrPM = array();
    $arrPMMID = array();
    $pmFolderObj = new PMFolder($mysqli);
    $pmFolderObj->intMemberID = $memberInfo['member_id'];
    // Stick Folder Conditions in variables
    $isFolderSet = isset($_POST['folder']);
    $selectedFolder = $pmFolderObj->select($_POST['folder']);
    $condition1 = !$selectedFolder || $selectedFolder && !$pmFolderObj->isMemberFolder();
    $arrStandardFolders = array(0, -1, -2);
    // Folder Checks
//$globals['alternate_db_server'] = 'backend';
include '../config.php';
$db->connect_timeout = 3;
if (!$current_user->user_id) {
    die;
}
if (!empty($_GET['redirect'])) {
    do_redirect($_GET['redirect']);
    exit(0);
}
header('Content-Type: application/json; charset=utf-8');
http_cache(5);
$notifications = new stdClass();
$notifications->posts = (int) Post::get_unread_conversations($current_user->user_id);
$notifications->comments = (int) Comment::get_unread_conversations($current_user->user_id);
$notifications->privates = (int) PrivateMessage::get_unread($current_user->user_id);
$notifications->friends = count(User::get_new_friends($current_user->user_id));
$notifications->total = $notifications->posts + $notifications->privates + $notifications->friends + $notifications->comments;
echo json_encode($notifications);
function do_redirect($type)
{
    global $globals, $current_user;
    $url = '/';
    // If everything fails, it will be redirected to the home
    switch ($type) {
        case 'privates':
            $url = post_get_base_url('_priv');
            break;
        case 'posts':
            $url = post_get_base_url($current_user->user_login) . '/_conversation';
            break;
Esempio n. 6
0
<?php

if (false) {
    $pm = new PrivateMessage();
}
$senderName = $pm->getSender()->getName();
$recipientName = $pm->getRecipient()->getName();
$subject = $pm->getSubject();
$content = trim($pm->getBody());
$length = strlen($content);
if ($length > 200) {
    $content = substr($content, 0, 200);
    $content = $content . "...";
}
$pmLink = link_to("{$subject}", 'message/read?id=' . $pm->getId(), array('absolute' => true));
?>

<p>DO NOT REPLY TO THIS EMAIL!<br />
***************************<br /><br />

Hello <?php 
echo $recipientName;
?>
,<br /><br />

You have received a private message at Rayku.com from <?php 
echo $senderName;
?>
, titled: "<b><?php 
echo $pmLink;
?>
Esempio n. 7
0
File: User.php Progetto: rayku/rayku
 /**
  * Sends a private message from this user to $recipientID
  *
  * @param int $recipientID
  * @param string $subject
  * @param string $message
  * @return bool
  */
 public function sendMessage($recipientID, $subject, $message, $stripTags = true)
 {
     //If the user is banned, they can't send a message
     if ($this->getHidden()) {
         return false;
     }
     $recipient = UserPeer::retrieveByPK($recipientID);
     if (!$recipient) {
         return false;
     }
     $pm = new PrivateMessage();
     $pm->setSenderId($this->getId());
     $pm->setRecipientID($recipientID);
     //  $subject = $stripTags ? strip_tags($subject, sfConfig::get('app_general_allowed_html_tags')) : $subject;
     $pm->setSubject($subject);
     //   $message = $stripTags ? strip_tags($message, sfConfig::get('app_general_allowed_html_tags')) : $message;
     $pm->setBody($message);
     $saveStatus = $pm->save();
     $c = new Criteria();
     $c->add(NotificationEmailsPeer::USER_ID, $recipientID);
     $notifies = NotificationEmailsPeer::doSelectOne($c);
     if ($notifies != NULL) {
         if ($notifies->getOnOff() == 0) {
             if ($saveStatus) {
                 $mailer = Mailman::createMailer();
                 $mailer->setContentType('text/html');
                 $mailer->addAddress($recipient->getEmail());
                 $mailer->setSubject('New Private Message from Rayku.com');
                 sfProjectConfiguration::getActive()->loadHelpers(array('Url', 'Partial'));
                 $mailer->setBody(get_partial('global/mail/newPMNotification', array('pm' => $pm)));
                 //Send the e-mail off
                 $mailer->send();
             }
         }
     } else {
         if ($saveStatus) {
             $mailer = Mailman::createMailer();
             $mailer->setContentType('text/html');
             $mailer->addAddress($recipient->getEmail());
             $mailer->setSubject('New Private Message from Rayku.com');
             sfProjectConfiguration::getActive()->loadHelpers(array('Url', 'Partial'));
             $mailer->setBody(get_partial('global/mail/newPMNotification', array('pm' => $pm)));
             //Send the e-mail off
             $mailer->send();
         }
     }
     return $saveStatus;
 }
Esempio n. 8
0
     } else {
         $args['privatemessages'] = PrivateMessage::ListAll($args['userinfo']['id']);
         Error::generate('debug', $args['privatemessages']);
         foreach ($args['privatemessages'] as $k => $pm) {
             $args['privatemessages'][$k]['creator'] = User::GetAttrib(PrivateMessage::GetAttrib($pm['id'], 'creator'), 'name');
         }
         include "{$ROOT}/user/views/listprivatemessages.view.php";
     }
 } else {
     if ($action == 'submitprivatemessage') {
         $args['userinfo']['id'] = User::GetAuthenticatedID();
         if (!$args['userinfo']['id']) {
             $_SESSION['saved'] = $params;
             redirect('user', 'login');
         } else {
             $status = PrivateMessage::Create(array('mailbox' => User::GetUserID($params['user']), 'creator' => $args['userinfo']['id'], 'subject' => $params['subject'], 'body' => $params['msg']));
             if (!$status) {
                 include "{$ROOT}/user/views/privatemessage.view.php";
             } else {
                 redirect('user', 'listprivatemessages');
             }
         }
     } else {
         if ($action == 'privatemessage') {
             $args['userinfo']['id'] = User::GetAuthenticatedID();
             if (!$args['userinfo']['id']) {
                 $_SESSION['last_rendered_page'] = $_SERVER['REQUEST_URI'];
                 redirect('user', 'login');
             }
             include "{$ROOT}/user/views/privatemessage.view.php";
         } else {
Esempio n. 9
0
*  Subversion Keywords:
*
*  $Id$
*  $LastChangedDate$
*  $LastChangedRevision$
*  $LastChangedBy$
*  $URL$
*/
DEFINE('V2EX_BABEL', 1);
require 'core/PrivateMessageCore.php';
if (isset($_GET['m'])) {
    $m = strtolower(trim($_GET['m']));
} else {
    $m = 'home';
}
$p = new PrivateMessage();
switch ($m) {
    default:
    case 'home':
        $p->vxHome();
        break;
    case 'compose':
        $p->vxCompose();
        break;
    case 'create':
        $p->vxCreate();
        break;
    case 'inbox':
        $p->vxInbox();
        break;
    case 'sent':
Esempio n. 10
0
     $dispToMember = $pmObj->getRecipients(true);
 } elseif ($memberInfo['member_id'] == $pmInfo['sender_id'] && $senderResult->num_rows > 0) {
     // Member is the sender
     $blnMultiPM = true;
     $dispToMember = $pmObj->getRecipients(true);
 }
 $dispPreviousMessages = "";
 // Folder Info
 $multiPM = isset($_GET['pmMID']);
 $pmFolderID = $pmObj->getFolder($memberInfo['member_id'], $multiPM);
 $pmFolderObj = new PMFolder($mysqli);
 $pmFolderObj->select($pmFolderID);
 $pmFolderInfo = $pmFolderObj->get_info_filtered();
 if ($pmInfo['originalpm_id'] != 0) {
     $result = $mysqli->query("SELECT * FROM " . $dbprefix . "privatemessages WHERE originalpm_id = '" . $pmInfo['originalpm_id'] . "' AND pm_id != '" . $pmInfo['pm_id'] . "' ORDER BY datesent DESC");
     $oldPMObj = new PrivateMessage($mysqli);
     $dispPreviousMessages .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='main' colspan='2'><br><br>\n\t\t\t\t\t\t<b>Previous Messages:</b>\n\t\t\t\t\t\t<div class='dottedLine' style='width: 90%; padding-top: 5px'></div><br>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t";
     while ($row = $result->fetch_assoc()) {
         $oldPMObj->select($row['pm_id']);
         if ($row['receiver_id'] != 0) {
             $member->select($row['receiver_id']);
             $dispToPrevMember = $member->getMemberLink();
         } else {
             $dispToPrevMember = $oldPMObj->getRecipients(true);
             $pmObj->select($row['pm_id']);
             $arrReceivers = $pmObj->getAssociateIDs();
         }
         $member->select($row['sender_id']);
         $dispFromPrevMember = $member->getMemberLink();
         $dispPreviousMessages .= "\n\t\t\t\t\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td class='formLabel'>To:</td>\n\t\t\t\t\t\t<td class='main'>\n\t\t\t\t\t\t\t" . $dispToPrevMember . "\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td class='formLabel'>Date:</td>\n\t\t\t\t\t\t<td class='main'>\n\t\t\t\t\t\t\t" . getPreciseTime($row['datesent']) . "\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td class='formLabel'>From:</td>\n\t\t\t\t\t\t<td class='main'>\n\t\t\t\t\t\t\t" . $dispFromPrevMember . "\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td class='formLabel'>Subject:</td>\n\t\t\t\t\t\t<td class='main'>" . $row['subject'] . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td colspan='2'><br></td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td class='formLabel' valign='top'>Message:</td>\n\t\t\t\t\t\t<td class='main'>\n\t\t\t\t\t\t\t<div style='position: relative; word-wrap:break-word'>\n\t\t\t\t\t\t\t\t" . nl2br(parseBBCode($row['message'])) . "\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td colspan='2' class='main'>\n\t\t\t\t\t\t\t<div class='dottedLine' style='width: 90%; margin-top: 30px; margin-bottom: 30px'></div>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t";
     }
Esempio n. 11
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      PrivateMessage $value A PrivateMessage object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(PrivateMessage $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Esempio n. 12
0
// Start Page
$consoleObj = new ConsoleOption($mysqli);
$cID = $consoleObj->findConsoleIDByName("Private Messages");
$consoleObj->select($cID);
$consoleInfo = $consoleObj->get_info_filtered();
$member = new Member($mysqli);
$member->select($_SESSION['btUsername']);
$memberInfo = $member->get_info_filtered();
$pmFolderObj = new PMFolder($mysqli);
$checkFolder = $pmFolderObj->select($_POST['newFolder']);
$pmFolderObj->setFolder($_POST['newFolder']);
$pmFolderObj->intMemberID = $memberInfo['member_id'];
// Check Login
$LOGIN_FAIL = true;
if ($member->authorizeLogin($_SESSION['btPassword']) && $member->hasAccess($consoleObj) && ($checkFolder || $pmFolderObj->isMemberFolder())) {
    $pmObj = new PrivateMessage($mysqli);
    $arrPMIDS = json_decode($_POST['movePMs']);
    foreach ($arrPMIDS as $pmID) {
        $pmMID = "";
        if (strpos($pmID, "_") !== false) {
            $tempPMID = substr($pmID, 0, strpos($pmID, "_"));
            $pmMID = str_replace($tempPMID . "_", "", $pmID);
            $pmID = $tempPMID;
        }
        if ($pmObj->select($pmID)) {
            $tempPMInfo = $pmObj->get_info_filtered();
            $arrRecipients = $pmObj->getRecipients();
            if ($tempPMInfo['sender_id'] == $memberInfo['member_id'] && $pmMID == "") {
                // Sender
                echo "hi";
                $pmObj->update(array("senderfolder_id"), array($_POST['newFolder']));