상속: extends User_Controller
예제 #1
0
 public function show($phone)
 {
     if (\Request::ajax()) {
         $data = Inbox::where('SenderNumber', 'like', '%' . $phone)->get();
         return \Response::json(['inbox' => $data]);
     }
 }
예제 #2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     // delete
     $inbox = Inbox::find($id);
     $inbox->delete();
     Logfile::addData('Xóa', 'Tin nhắn', $inbox->id, $inbox->name);
     // redirect
     Session::flash('message', 'Tin Đã bị xóa!');
     return Redirect::to('inboxs');
 }
예제 #3
0
 function addMessage($subject, $message, $user_id = null, $sender_id = null, $parent_id = null, $send_email = true)
 {
     $logged_in = !!$this->Auth->loggedIn();
     if (!$user_id) {
         $user_id = $logged_in ? $this->Auth->user()->id : null;
     }
     if (!$sender_id) {
         $sender_id = $logged_in ? $this->Auth->user()->id : null;
     }
     if (!is_a($message, "DbObject")) {
         $mso = new Inbox_message($this->w);
         $mso->message = $message;
         $mso->insert();
     } else {
         $mso = $message;
     }
     $msg = new Inbox($this->w);
     $msg->user_id = $user_id;
     $msg->parent_message_id = $parent_id;
     $msg->subject = $subject;
     if ($sender_id) {
         $msg->sender_id = $sender_id;
     }
     $msg->message_id = $mso->id;
     $msg->dt_created = time();
     $msg->is_new = 1;
     $msg->is_archived = 0;
     $msg->insert();
     $receiver = $this->Auth->getUser($user_id);
     // Notify users via email if specified and the user isn't sending a message to themselves
     $this->w->Log->debug("IDs: " . var_export($msg->user_id, true) . " - " . var_export($msg->sender_id, true));
     if (!empty($mso) && !empty($msg) && !empty($receiver)) {
         $rContact = $receiver->getContact();
         $lSender = $this->w->Auth->getUser($msg->sender_id);
         if (!empty($rContact) && !empty($lSender)) {
             $lContact = $lSender->getContact();
             if (!empty($lContact) && $send_email === true && $msg->user_id !== $msg->sender_id) {
                 $this->w->Mail->sendMail($rContact->email, $logged_in ? $lContact->email : "*****@*****.**", $msg->subject, $mso->message);
             }
         }
     }
 }
예제 #4
0
 public function actionC()
 {
     $u =& $this->iuser;
     $model = new Inbox();
     if (isset($_POST['Inbox'])) {
         $model->attributes = $_POST['Inbox'];
         $dest_user = User::model()->findByPk($_POST['Inbox']['dest_id']);
         $model->c_time = Time::now();
         $model->source_id = $u->id;
         $model->memo = strip_tags($model->memo);
         if ($model->save()) {
             $this->redirect(array('index'));
             exit;
         }
     } else {
         $dest_user = User::model()->findByPk($_GET['dest_id']);
         if ($dest_user == null) {
             throw new CHttpException(404, 'The requested Node does not exist.');
         }
         $model->dest_id = $dest_user->id;
     }
     $this->render('create', array('dest_user' => $dest_user, 'm' => $u, 'model' => $model), false, true);
 }
 function handle($data)
 {
     // JSON object with Twitter data
     $status = $data['status'];
     // Twitter user ID this incoming data belongs to.
     $receiver = $data['for_user'];
     $importer = new TwitterImport();
     $notice = $importer->importStatus($status);
     if ($notice) {
         $flink = Foreign_link::getByForeignID(TWITTER_SERVICE, $receiver);
         if ($flink) {
             // @fixme this should go through more regular channels?
             Inbox::insertNotice($flink->user_id, $notice->id);
         }
     }
     return true;
 }
예제 #6
0
 function handle($data)
 {
     // JSON object with Twitter data
     $status = $data['status'];
     // Twitter user ID this incoming data belongs to.
     $receiver = $data['for_user'];
     $importer = new TwitterImport();
     $notice = $importer->importStatus($status);
     if ($notice) {
         $flink = Foreign_link::getByForeignID($receiver, TWITTER_SERVICE);
         if ($flink) {
             common_log(LOG_DEBUG, "TweetInQueueHandler - Got flink so add notice " . $notice->id . " to inbox " . $flink->user_id);
             // @fixme this should go through more regular channels?
             Inbox::insertNotice($flink->user_id, $notice->id);
         } else {
             common_log(LOG_DEBUG, "TweetInQueueHandler - No flink found for foreign user " . $receiver);
         }
     }
     return true;
 }
예제 #7
0
<?php

include "../config/checkSession.php";
include "../config/conn.php";
$Profile = new Profile($conn);
$Relation = new Relation($conn);
$User = new User($conn);
$Inbox = new Inbox($conn);
if (isset($_POST['action']) && !empty($_POST['action'])) {
    $act = $_POST['action'];
    switch ($act) {
        case 'create_profile':
            // Store all Data in array to pass to Model
            $data = array('id' => $_POST['id'], 'workout_exp' => $_POST['workout_exp'], 'goal' => $_POST['goal'], 'latitude' => $_POST['latitude'], 'longitude' => $_POST['longitude']);
            echo $data[id];
            return $Profile->setPreferences($data);
            break;
        case 'edit_profile':
            $data = array('id' => $_POST['id'], 'dob' => $_POST['dob'], 'goal' => $_POST['goal'], 'workout_exp' => $_POST['workout_exp'], 'latitude' => $_POST['latitude'], 'longitude' => $_POST['longitude'], 'gym' => $_POST['gym'], 'body_fat' => $_POST['body_fat'], 'weight' => $_POST['weight'], 'bio' => $_POST['bio'], 'avatar' => basename($_POST['avatar']));
            echo $Profile->editProfile($data);
            break;
        case 'check_postcode':
            $postal_code = $_POST['postal_code'];
            $coords = $Profile->returnPostalCode($postal_code);
            $coords = json_decode($coords);
            $coords->address = $Profile->returnCoordinates($coords->lat, $coords->lng);
            echo json_encode($coords);
            break;
        case 'return_address':
            $latitude = $_POST['latitude'];
            $longitude = $_POST['longitude'];
예제 #8
0
$UserID = $LoggedUser['ID'];
authorize();
replace */
if (!isset($_POST['messages']) || !is_array($_POST['messages'])) {
    error('You forgot to select messages to delete.');
    header('Location: ' . Inbox::get_inbox_link());
    die;
}
$Messages = $_POST['messages'];
foreach ($Messages as $ConvID) {
    $ConvID = trim($ConvID);
    if (!is_number($ConvID)) {
        error(0);
    }
}
$ConvIDs = implode(',', $Messages);
$DB->query("\n\tSELECT COUNT(ConvID)\n\tFROM pm_conversations_users\n\tWHERE ConvID IN ({$ConvIDs})\n\t\tAND UserID={$UserID}");
list($MessageCount) = $DB->next_record();
if ($MessageCount != count($Messages)) {
    error(0);
}
if (isset($_POST['delete'])) {
    $DB->query("\n\t\tUPDATE pm_conversations_users\n\t\tSET\n\t\t\tInInbox='0',\n\t\t\tInSentbox='0',\n\t\t\tSticky='0',\n\t\t\tUnRead='0'\n\t\tWHERE ConvID IN({$ConvIDs})\n\t\t\tAND UserID={$UserID}");
} elseif (isset($_POST['unread'])) {
    $DB->query("\n\t\tUPDATE pm_conversations_users\n\t\tSET Unread='1'\n\t\tWHERE ConvID IN({$ConvIDs}) AND UserID={$UserID}");
} elseif (isset($_POST['read'])) {
    $DB->query("\n\t\tUPDATE pm_conversations_users\n\t\tSET Unread='0'\n\t\tWHERE ConvID IN({$ConvIDs}) AND UserID={$UserID}");
}
$Cache->delete_value('inbox_new_' . $UserID);
header('Location: ' . Inbox::get_inbox_link());
예제 #9
0
 function ownFriendsTimeline($offset = 0, $limit = NOTICES_PER_PAGE, $since_id = 0, $before_id = 0)
 {
     return Inbox::streamNotices($this->id, $offset, $limit, $since_id, $before_id, true);
 }
예제 #10
0
파일: User.php 프로젝트: Grasia/bolotweet
 /**
  * Register a new user account and profile and set up default subscriptions.
  * If a new-user welcome message is configured, this will be sent.
  *
  * @param array $fields associative array of optional properties
  *              string 'bio'
  *              string 'email'
  *              bool 'email_confirmed' pass true to mark email as pre-confirmed
  *              string 'fullname'
  *              string 'homepage'
  *              string 'location' informal string description of geolocation
  *              float 'lat' decimal latitude for geolocation
  *              float 'lon' decimal longitude for geolocation
  *              int 'location_id' geoname identifier
  *              int 'location_ns' geoname namespace to interpret location_id
  *              string 'nickname' REQUIRED
  *              string 'password' (may be missing for eg OpenID registrations)
  *              string 'code' invite code
  *              ?string 'uri' permalink to notice; defaults to local notice URL
  * @return mixed User object or false on failure
  */
 static function register($fields)
 {
     // MAGICALLY put fields into current scope
     extract($fields);
     $profile = new Profile();
     if (!empty($email)) {
         $email = common_canonical_email($email);
     }
     $nickname = common_canonical_nickname($nickname);
     $profile->nickname = $nickname;
     if (!User::allowed_nickname($nickname)) {
         common_log(LOG_WARNING, sprintf("Attempted to register a nickname that is not allowed: %s", $profile->nickname), __FILE__);
         return false;
     }
     $profile->profileurl = common_profile_url($nickname);
     if (!empty($fullname)) {
         $profile->fullname = $fullname;
     }
     if (!empty($homepage)) {
         $profile->homepage = $homepage;
     }
     if (!empty($bio)) {
         $profile->bio = $bio;
     }
     if (!empty($location)) {
         $profile->location = $location;
         $loc = Location::fromName($location);
         if (!empty($loc)) {
             $profile->lat = $loc->lat;
             $profile->lon = $loc->lon;
             $profile->location_id = $loc->location_id;
             $profile->location_ns = $loc->location_ns;
         }
     }
     $profile->created = common_sql_now();
     $user = new User();
     $user->nickname = $nickname;
     $invite = null;
     // Users who respond to invite email have proven their ownership of that address
     if (!empty($code)) {
         $invite = Invitation::staticGet($code);
         if ($invite && $invite->address && $invite->address_type == 'email' && $invite->address == $email) {
             $user->email = $invite->address;
         }
     }
     if (isset($email_confirmed) && $email_confirmed) {
         $user->email = $email;
     }
     // This flag is ignored but still set to 1
     $user->inboxed = 1;
     // Set default-on options here, otherwise they'll be disabled
     // initially for sites using caching, since the initial encache
     // doesn't know about the defaults in the database.
     $user->emailnotifysub = 1;
     $user->emailnotifyfav = 1;
     $user->emailnotifynudge = 1;
     $user->emailnotifymsg = 1;
     $user->emailnotifyattn = 1;
     $user->emailmicroid = 1;
     $user->emailpost = 1;
     $user->jabbermicroid = 1;
     $user->created = common_sql_now();
     if (Event::handle('StartUserRegister', array(&$user, &$profile))) {
         $profile->query('BEGIN');
         $id = $profile->insert();
         if (empty($id)) {
             common_log_db_error($profile, 'INSERT', __FILE__);
             return false;
         }
         $user->id = $id;
         if (!empty($uri)) {
             $user->uri = $uri;
         } else {
             $user->uri = common_user_uri($user);
         }
         if (!empty($password)) {
             // may not have a password for OpenID users
             $user->password = common_munge_password($password, $id);
         }
         $result = $user->insert();
         if (!$result) {
             common_log_db_error($user, 'INSERT', __FILE__);
             return false;
         }
         // Everyone gets an inbox
         $inbox = new Inbox();
         $inbox->user_id = $user->id;
         $inbox->notice_ids = '';
         $result = $inbox->insert();
         if (!$result) {
             common_log_db_error($inbox, 'INSERT', __FILE__);
             return false;
         }
         // Everyone is subscribed to themself
         $subscription = new Subscription();
         $subscription->subscriber = $user->id;
         $subscription->subscribed = $user->id;
         $subscription->created = $user->created;
         $result = $subscription->insert();
         if (!$result) {
             common_log_db_error($subscription, 'INSERT', __FILE__);
             return false;
         }
         // Mark that this invite was converted
         if (!empty($invite)) {
             $invite->convert($user);
         }
         if (!empty($email) && !$user->email) {
             $confirm = new Confirm_address();
             $confirm->code = common_confirmation_code(128);
             $confirm->user_id = $user->id;
             $confirm->address = $email;
             $confirm->address_type = 'email';
             $result = $confirm->insert();
             if (!$result) {
                 common_log_db_error($confirm, 'INSERT', __FILE__);
                 return false;
             }
         }
         if (!empty($code) && $user->email) {
             $user->emailChanged();
         }
         // Default system subscription
         $defnick = common_config('newuser', 'default');
         if (!empty($defnick)) {
             $defuser = User::staticGet('nickname', $defnick);
             if (empty($defuser)) {
                 common_log(LOG_WARNING, sprintf("Default user %s does not exist.", $defnick), __FILE__);
             } else {
                 Subscription::start($user, $defuser);
             }
         }
         $profile->query('COMMIT');
         if (!empty($email) && !$user->email) {
             mail_confirm_address($user, $confirm->code, $profile->nickname, $email);
         }
         // Welcome message
         $welcome = common_config('newuser', 'welcome');
         if (!empty($welcome)) {
             $welcomeuser = User::staticGet('nickname', $welcome);
             if (empty($welcomeuser)) {
                 common_log(LOG_WARNING, sprintf("Welcome user %s does not exist.", $defnick), __FILE__);
             } else {
                 $notice = Notice::saveNew($welcomeuser->id, sprintf(_('Welcome to %1$s, @%2$s!'), common_config('site', 'name'), $user->nickname), 'system');
             }
         }
         Event::handle('EndUserRegister', array(&$profile, &$user));
     }
     return $user;
 }
예제 #11
0
<?php

include "../config/checkSession.php";
include "../config/conn.php";
$Profile = new Profile($conn);
$User = new User($conn);
$Inbox = new Inbox($conn);
if (isset($_POST['action']) && !empty($_POST['action'])) {
    $act = $_POST['action'];
    switch ($act) {
        case 'get_inbox':
            echo json_encode($Inbox->getInbox($_POST['user_id']));
            break;
        case 'start_inbox':
            $data = array('msg' => $_POST['msg'], 'to_id' => $_POST['to_id'], 'from_id' => $_POST['from_id']);
            if ($Inbox->startInbox($data)) {
                echo 1;
            } else {
                echo 0;
            }
            break;
        case 'get_convo':
            $convo = $Inbox->getConvo($_POST['inbox_id']);
            foreach ($convo as $x) {
                $Inbox->setViewed($x['id']);
            }
            echo json_encode($convo);
            break;
        case 'send_message':
            $date = date('Y-m-d H:i:s');
            $data = array('inbox_id' => $_POST['inbox_id'], 'user_id' => $_POST['user_id'], 'message' => $_POST['message'], 'date_sent' => $date);
예제 #12
0
 public function addInbox(Inbox $l)
 {
     $this->collInboxs[] = $l;
     $l->setEmployee($this);
 }
예제 #13
0
 function stream($user_id, $offset, $limit, $since_id, $max_id, $own = false)
 {
     $inbox = Inbox::staticGet('user_id', $user_id);
     if (empty($inbox)) {
         $inbox = Inbox::fromNoticeInbox($user_id);
         if (empty($inbox)) {
             return array();
         } else {
             $inbox->encache();
         }
     }
     $ids = $inbox->unpack();
     if (!empty($since_id)) {
         $newids = array();
         foreach ($ids as $id) {
             if ($id > $since_id) {
                 $newids[] = $id;
             }
         }
         $ids = $newids;
     }
     if (!empty($max_id)) {
         $newids = array();
         foreach ($ids as $id) {
             if ($id <= $max_id) {
                 $newids[] = $id;
             }
         }
         $ids = $newids;
     }
     $ids = array_slice($ids, $offset, $limit);
     return $ids;
 }
예제 #14
0
function initInbox()
{
    printfnq("Ensuring all users have an inbox...");
    $user = new User();
    $user->whereAdd('not exists (select user_id from inbox where user_id = user.id)');
    $user->orderBy('id');
    if ($user->find()) {
        while ($user->fetch()) {
            try {
                $notice = new Notice();
                $notice->selectAdd();
                $notice->selectAdd('id');
                $notice->joinAdd(array('profile_id', 'subscription:subscribed'));
                $notice->whereAdd('subscription.subscriber = ' . $user->id);
                $notice->whereAdd('notice.created >= subscription.created');
                $ids = array();
                if ($notice->find()) {
                    while ($notice->fetch()) {
                        $ids[] = $notice->id;
                    }
                }
                $notice = null;
                $inbox = new Inbox();
                $inbox->user_id = $user->id;
                $inbox->pack($ids);
                $inbox->insert();
            } catch (Exception $e) {
                printv("Error initializing inbox: " . $e->getMessage());
            }
        }
    }
    printfnq("DONE.\n");
}
예제 #15
0
});
$stream->hookEvent('delete', function ($data, $context) {
    printf("Deleted status notification: %s\n", $data->status->id);
});
$stream->hookEvent('scrub_geo', function ($data, $context) {
    printf("Req to scrub geo data for user id %s up to status ID %s\n", $data->user_id, $data->up_to_status_id);
});
$stream->hookEvent('status', function ($data, $context) {
    printf("Received status update from %s: %s\n", $data->user->screen_name, $data->text);
    if (have_option('import')) {
        $importer = new TwitterImport();
        printf("\timporting...");
        $notice = $importer->importStatus($data);
        if ($notice) {
            global $myuser;
            Inbox::insertNotice($myuser->id, $notice->id);
            printf(" %s\n", $notice->id);
        } else {
            printf(" FAIL\n");
        }
    }
});
$stream->hookEvent('direct_message', function ($data) {
    printf("Direct message from %s to %s: %s\n", $data->sender->screen_name, $data->recipient->screen_name, $data->text);
});
class TwitterManager extends IoManager
{
    function __construct(TwitterStreamReader $stream)
    {
        $this->stream = $stream;
    }
 function getTimeline($flink)
 {
     if (empty($flink)) {
         common_log(LOG_WARNING, $this->name() . " - Can't retrieve Foreign_link for foreign ID {$fid}");
         return;
     }
     common_debug($this->name() . ' - Trying to get timeline for Twitter user ' . $flink->foreign_id);
     $client = null;
     if (TwitterOAuthClient::isPackedToken($flink->credentials)) {
         $token = TwitterOAuthClient::unpackToken($flink->credentials);
         $client = new TwitterOAuthClient($token->key, $token->secret);
         common_debug($this->name() . ' - Grabbing friends timeline with OAuth.');
     } else {
         common_debug("Skipping friends timeline for {$flink->foreign_id} since not OAuth.");
     }
     $timeline = null;
     $lastId = Twitter_synch_status::getLastId($flink->foreign_id, 'home_timeline');
     common_debug("Got lastId value '{$lastId}' for foreign id '{$flink->foreign_id}' and timeline 'home_timeline'");
     try {
         $timeline = $client->statusesHomeTimeline($lastId);
     } catch (Exception $e) {
         common_log(LOG_WARNING, $this->name() . ' - Twitter client unable to get friends timeline for user ' . $flink->user_id . ' - code: ' . $e->getCode() . 'msg: ' . $e->getMessage());
     }
     if (empty($timeline)) {
         common_log(LOG_WARNING, $this->name() . " - Empty timeline.");
         return;
     }
     common_debug(LOG_INFO, $this->name() . ' - Retrieved ' . sizeof($timeline) . ' statuses from Twitter.');
     // Reverse to preserve order
     foreach (array_reverse($timeline) as $status) {
         // Hacktastic: filter out stuff coming from this StatusNet
         $source = mb_strtolower(common_config('integration', 'source'));
         if (preg_match("/{$source}/", mb_strtolower($status->source))) {
             common_debug($this->name() . ' - Skipping import of status ' . $status->id . ' with source ' . $source);
             continue;
         }
         // Don't save it if the user is protected
         // FIXME: save it but treat it as private
         if ($status->user->protected) {
             continue;
         }
         $notice = $this->saveStatus($status);
         if (!empty($notice)) {
             Inbox::insertNotice($flink->user_id, $notice->id);
         }
     }
     if (!empty($timeline)) {
         Twitter_synch_status::setLastId($flink->foreign_id, 'home_timeline', $timeline[0]->id);
         common_debug("Set lastId value '{$timeline[0]->id}' for foreign id '{$flink->foreign_id}' and timeline 'home_timeline'");
     }
     // Okay, record the time we synced with Twitter for posterity
     $flink->last_noticesync = common_sql_now();
     $flink->update();
 }
예제 #17
0
 public function despacharProyecto()
 {
     require_once 'lib/model/base/Proyecto.class.php';
     require_once 'lib/model/base/Inbox.class.php';
     require_once 'lib/model/base/Bitacora.class.php';
     require_once 'lib/model/base/Accion.class.php';
     $idProyecto = isset($_REQUEST['id_proyecto']) ? $_REQUEST['id_proyecto'] : null;
     if ($_POST) {
         $bitacora = new Bitacora();
         $bitacora->idProyecto = $idProyecto;
         $bitacora->idAccion = $_POST['accion_usuario'];
         $bitacora->idUsuario = $_SESSION['usuario'];
         $bitacora->fechaCreacion = date('Y-m-d');
         $bitacora->observacion = $_POST['observacion'];
         $bitacora->save();
         if ($_POST['id_inbox']) {
             $bind = Inbox::find($_POST['id_inbox']);
             $inbox = new Inbox($bind);
         } else {
             $inbox = new Inbox();
         }
         $inbox->idProyecto = $idProyecto;
         $inbox->fechaDespacho = date('Y-m-d');
         $inbox->idEmisor = $_SESSION['usuario'];
         $inbox->idDestinatario = $_POST['id_destinatario'];
         if (isset($_POST['id_accion'])) {
             $inbox->idAccion = $_POST['id_accion'];
         }
         $inbox->save();
         $bind = Proyecto::find($idProyecto);
         $proyecto = new Proyecto($bind);
         $bindAccion = Accion::find($_POST['id_accion']);
         $accion = new Accion($bindAccion);
         $proyecto->idEstadoProyecto = $accion->idEstadoInicial;
         $proyecto->save();
     }
 }
예제 #18
0
 /**
  *
  */
 private function makeInbox($info)
 {
     $heads = \Ydin\ArrayKit\Dot::factory($info['headers']);
     if (false !== strstr($heads('from'), '<')) {
         // has name
         $fromName = strip_tags($heads('from'));
         $fromEmail = trim(strstr($heads('from'), '<'), '<>');
     } else {
         $fromName = '';
         $fromEmail = $heads('from');
     }
     if (false !== strstr($heads('to'), '<')) {
         // has name
         $toName = strip_tags($heads('to'));
         $toEmail = trim(strstr($heads('to'), '<'), '<>');
     } else {
         $toName = '';
         $toEmail = $heads('to');
     }
     $inbox = new \Inbox();
     $inbox->setMessageId($heads('message-id'));
     $inbox->setReferenceMessageIds($heads('references'));
     $inbox->setFromEmail($fromEmail);
     $inbox->setToEmail($toEmail);
     $inbox->setFromName($fromName);
     $inbox->setToName($toName);
     $inbox->setSubject($heads('subject'));
     $date = $this->timezoneConvert($heads('date'), 'UTC', conf('app.timezone'));
     $inbox->setEmailCreateTime(strtotime($date));
     $inbox->setProperty('googleMessageId', $info['googleMessageId']);
     $inbox->setProperty('headers', $info['headers']);
     $inbox->setProperty('data', $info['data']);
     if ($info['body']) {
         $inbox->setBodySnippet($info['body']);
     }
     /*
     foreach ($info['data'] as $item) {
         if ( 'text/plain' === $item['mimeType'] && isset($item['content']) ) {
             $inbox->setBodySnippet($item['content']);
         }
     }
     */
     $referenceMessageIds = $inbox->getReferenceMessageIds();
     if (!$referenceMessageIds) {
         $parentId = 0;
     } else {
         $tmp = explode(" ", $referenceMessageIds);
         $firstReferenceMessageId = $tmp[0];
         $inboxes = new \Inboxes();
         $theInbox = $inboxes->getInboxByMessageId($firstReferenceMessageId);
         if ($theInbox) {
             $parentId = $theInbox->getId();
         } else {
             // 找不到 message id, 這可能是一個大問題
             // 但也有可能只是一個小問題 -> 新信件 比 舊信件 先被匯入
             // 之後需要想辦法重新串起來
             $parentId = -1;
         }
     }
     $inbox->setParentId($parentId);
     return $inbox;
 }
예제 #19
0
 /**
  * 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.
  */
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['id'])) {
             $this->_model = Inbox::model()->findbyPk($_GET['id']);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }
예제 #20
0
 public function getUnread_inbox_count()
 {
     $a = Inbox::model()->count("is_read =0 AND dest_id = " . User()->id . " AND parent_id = {$this->id} ");
     $b = $this->is_read ? 0 : 1;
     return $a + $b;
 }
예제 #21
0
 public function postLienHe()
 {
     $validator = Validator::make(Input::all(), Inbox::$rules);
     var_dump(Input::all());
     // process the login
     if ($validator->fails()) {
         return Redirect::to('users/lien-he')->withErrors($validator)->withInput(Input::except('password'));
     } else {
         $inbox = new Inbox();
         $inbox->name = Input::get('name');
         $inbox->phone = Input::get('phone');
         $inbox->content = Input::get('content');
         $inbox->save();
         Logfile::addData('Gửi', 'Tin nhắn', $inbox->id, $inbox->name);
         // redirect
         Session::flash('message', 'Gửi Tin nhắn thành công!');
         return Redirect::to('users/lien-he');
     }
 }
예제 #22
0
 public function fillEnvelope()
 {
     $inbox = new Inbox();
     $return = $inbox->fillEnvelope();
     $return['method'] = __FUNCTION__;
     $return['webClass'] = __CLASS__;
     Mold::both("inbox/fillEnvelope", $return);
 }
예제 #23
0
 /**
  *  get db object by record
  *  @param  row
  *  @return TahScan object
  */
 public function mapRow($row)
 {
     $object = new Inbox();
     $object->setId($row['id']);
     $object->setParentId($row['parent_id']);
     $object->setFromEmail($row['from_email']);
     $object->setToEmail($row['to_email']);
     $object->setFromName($row['from_name']);
     $object->setToName($row['to_name']);
     $object->setSubject($row['subject']);
     $object->setBodySnippet($row['body_snippet']);
     $object->setEmailCreateTime(strtotime($row['email_create_time']));
     $object->setMessageId($row['message_id']);
     $object->setReferenceMessageIds($row['reference_message_ids']);
     $object->setProperties(unserialize($row['properties']));
     return $object;
 }
예제 #24
0
파일: Inbox.php 프로젝트: Grasia/bolotweet
 static function bulkInsert($notice_id, $user_ids)
 {
     foreach ($user_ids as $user_id) {
         Inbox::insertNotice($user_id, $notice_id);
     }
 }
예제 #25
0
    $DB->query("\n\t\tUPDATE pm_conversations_users\n\t\tSET UnRead = '0'\n\t\tWHERE ConvID = '{$ConvID}'\n\t\t\tAND UserID = '{$UserID}'");
    // Clear the caches of the inbox and sentbox
    $Cache->decrement("inbox_new_{$UserID}");
}
View::show_header("View conversation {$Subject}", 'comments,inbox,bbcode,jquery.validate,form_validate');
// Get messages
$DB->query("\n\tSELECT SentDate, SenderID, Body, ID\n\tFROM pm_messages\n\tWHERE ConvID = '{$ConvID}'\n\tORDER BY ID");
?>
<div class="thin">
	<h2><?php 
echo $Subject . ($ForwardedID > 0 ? " (Forwarded to {$ForwardedName})" : '');
?>
</h2>
	<div class="linkbox">
		<a href="<?php 
echo Inbox::get_inbox_link();
?>
" class="brackets">Back to inbox</a>
	</div>
<?php 
while (list($SentDate, $SenderID, $Body, $MessageID) = $DB->next_record()) {
    ?>
	<div class="box vertical_space">
		<div class="head" style="overflow: hidden;">
			<div style="float: left;">
				<strong><?php 
    echo $Users[(int) $SenderID]['UserStr'];
    ?>
</strong> <?php 
    echo time_diff($SentDate);
    ?>
예제 #26
0
function initializeInbox($user)
{
    if (!have_option('q', 'quiet')) {
        print "Initializing inbox for {$user->nickname}...";
    }
    $inbox = Inbox::staticGet('user_id', $user->id);
    if ($inbox && !empty($inbox->fake)) {
        if (!have_option('q', 'quiet')) {
            echo "(replacing faux cached inbox)";
        }
        $inbox = false;
    }
    if (!empty($inbox)) {
        if (!have_option('q', 'quiet')) {
            print "SKIP\n";
        }
    } else {
        $inbox = Inbox::initialize($user->id);
        if (!have_option('q', 'quiet')) {
            if (empty($inbox)) {
                print "ERR\n";
            } else {
                print "DONE\n";
            }
        }
    }
}
예제 #27
0
 function distribute()
 {
     // We always insert for the author so they don't
     // have to wait
     $user = User::staticGet('id', $this->profile_id);
     if (!empty($user)) {
         Inbox::insertNotice($user->id, $this->id);
     }
     if (common_config('queue', 'inboxes')) {
         // If there's a failure, we want to _force_
         // distribution at this point.
         try {
             $qm = QueueManager::get();
             $qm->enqueue($this, 'distrib');
         } catch (Exception $e) {
             // If the exception isn't transient, this
             // may throw more exceptions as DQH does
             // its own enqueueing. So, we ignore them!
             try {
                 $handler = new DistribQueueHandler();
                 $handler->handle($this);
             } catch (Exception $e) {
                 common_log(LOG_ERR, "emergency redistribution resulted in " . $e->getMessage());
             }
             // Re-throw so somebody smarter can handle it.
             throw $e;
         }
     } else {
         $handler = new DistribQueueHandler();
         $handler->handle($this);
     }
 }
 public function fetchReceiverName($msg_id)
 {
     $thisMessage = Inbox::where('id', '=', $msg_id)->first();
     $thisMessageReceiverID = $thisMessage->receiver_id;
     $usr = User::find($thisMessageReceiverID);
     $usrName = $usr->fullname;
     return $usrName;
 }
예제 #29
0
 /**
  * Get IDs in a range
  *
  * @param int $offset   Offset from start
  * @param int $limit    Limit of number to get
  * @param int $since_id Since this notice
  * @param int $max_id   Before this notice
  *
  * @return Array IDs found
  */
 function getNoticeIds($offset, $limit, $since_id, $max_id)
 {
     if (empty($this->inbox)) {
         $this->inbox = Inbox::fromNoticeInbox($user_id);
         if (empty($this->inbox)) {
             return array();
         } else {
             $this->inbox->encache();
         }
     }
     $ids = $this->inbox->unpack();
     if (!empty($since_id)) {
         $newids = array();
         foreach ($ids as $id) {
             if ($id > $since_id) {
                 $newids[] = $id;
             }
         }
         $ids = $newids;
     }
     if (!empty($max_id)) {
         $newids = array();
         foreach ($ids as $id) {
             if ($id <= $max_id) {
                 $newids[] = $id;
             }
         }
         $ids = $newids;
     }
     $ids = array_slice($ids, $offset, $limit);
     return $ids;
 }
 function searchCb($word, $accid, $begin = 0, $limit = 20)
 {
     global $db;
     $acc = new Account();
     $reply = new InboxReply();
     $q = "\n        \n        (SELECT {$this->searchColoms} FROM {$this->table_name} INNER JOIN {$acc->table_name}\n        ON ({$this->table_name}.inbox_from = {$acc->table_name}.admin_id)\n        WHERE\n            (inbox_from = '{$accid}' OR inbox_to = '{$accid}') AND inbox_type = 'cb' AND \n            (inbox_judul LIKE '%{$word}%' OR inbox_msg LIKE '%{$word}%' OR admin_nama_depan LIKE '%{$word}%') \n        )\n        UNION\n        (SELECT {$this->searchColoms} FROM {$this->table_name} INNER JOIN {$acc->table_name}\n        ON ({$this->table_name}.inbox_to = {$acc->table_name}.admin_id)\n        WHERE\n            (inbox_from = '{$accid}' OR inbox_to = '{$accid}') AND inbox_type = 'cb' AND \n            (inbox_judul LIKE '%{$word}%' OR inbox_msg LIKE '%{$word}%' OR admin_nama_depan LIKE '%{$word}%') \n        )        \n        ORDER BY inbox_changedate DESC LIMIT {$begin},{$limit}\n     \n        ";
     $arr = $db->query($q, 2);
     // pr($arr);
     // echo $q;
     $newMurid = array();
     foreach ($arr as $databasemurid) {
         $m = new Inbox();
         $m->fill(toRow($databasemurid));
         $newMurid[] = $m;
     }
     //return jumlah totalnya
     $q = "        \n        (SELECT {$this->searchColoms} FROM {$this->table_name} INNER JOIN {$acc->table_name}\n        ON ({$this->table_name}.inbox_from = {$acc->table_name}.admin_id)\n        WHERE\n            (inbox_from = '{$accid}' OR inbox_to = '{$accid}') AND inbox_type = 'cb' AND \n            (inbox_judul LIKE '%{$word}%' OR inbox_msg LIKE '%{$word}%' OR admin_nama_depan LIKE '%{$word}%') \n        )\n        UNION\n        (SELECT {$this->searchColoms} FROM {$this->table_name} INNER JOIN {$acc->table_name}\n        ON ({$this->table_name}.inbox_to = {$acc->table_name}.admin_id)\n        WHERE\n            (inbox_from = '{$accid}' OR inbox_to = '{$accid}') AND inbox_type = 'cb' AND \n            (inbox_judul LIKE '%{$word}%' OR inbox_msg LIKE '%{$word}%' OR admin_nama_depan LIKE '%{$word}%') \n        )                     \n        ";
     $arr2 = $db->query($q, 2);
     return array("arrMsg" => $newMurid, "total" => count($arr2));
     //die();
 }