diff options
author | friendica <info@friendica.com> | 2012-12-04 18:24:46 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2012-12-04 18:24:46 -0800 |
commit | e17ba14696d6ee7532bacce6b5519594e001f13f (patch) | |
tree | 490c90c8ec7cebc3fec94a7ad4c1eab4e9bacab3 | |
parent | 707397580c1c4547c0e308f90df61bc68e91b219 (diff) | |
download | volse-hubzilla-e17ba14696d6ee7532bacce6b5519594e001f13f.tar.gz volse-hubzilla-e17ba14696d6ee7532bacce6b5519594e001f13f.tar.bz2 volse-hubzilla-e17ba14696d6ee7532bacce6b5519594e001f13f.zip |
DB: do the mail table again. Mail almost working onsite, still needs to zot though
-rw-r--r-- | boot.php | 7 | ||||
-rw-r--r-- | include/message.php | 188 | ||||
-rw-r--r-- | include/nav.php | 2 | ||||
-rw-r--r-- | install/database.sql | 10 | ||||
-rw-r--r-- | library/jquery_ac/friendica.complete.js | 4 | ||||
-rw-r--r-- | mod/acl.php | 16 | ||||
-rw-r--r-- | mod/message.php | 208 | ||||
-rw-r--r-- | mod/ping.php | 9 | ||||
-rw-r--r-- | version.inc | 2 | ||||
-rw-r--r-- | view/js/mod_connections.js | 2 | ||||
-rw-r--r-- | view/tpl/mail_conv.tpl | 2 | ||||
-rw-r--r-- | view/tpl/mail_list.tpl | 9 |
12 files changed, 174 insertions, 285 deletions
@@ -194,6 +194,13 @@ define ( 'ABOOK_FLAG_PENDING' , 0x0010); define ( 'ABOOK_FLAG_SELF' , 0x0080); + +define ( 'MAIL_DELETED', 0x0001); +define ( 'MAIL_REPLIED', 0x0002); +define ( 'MAIL_ISREPLY', 0x0004); +define ( 'MAIL_SEEN', 0x0008); + + /** * Maximum number of "people who like (or don't like) this" that we will list by name */ diff --git a/include/message.php b/include/message.php index cf0fe96da..fd9698381 100644 --- a/include/message.php +++ b/include/message.php @@ -1,11 +1,10 @@ <?php - // send a private message - - +// send a private message + -function send_message($recipient=0, $body='', $subject='', $replyto=''){ +function send_message($uid = 0, $recipient='', $body='', $subject='', $replyto=''){ $a = get_app(); @@ -14,107 +13,60 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){ if(! strlen($subject)) $subject = t('[no subject]'); - $me = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", - intval(local_user()) - ); - $contact = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($recipient), - intval(local_user()) - ); - - if(! (count($me) && (count($contact)))) { - return -2; - } - - $hash = random_string(); - $uri = 'urn:X-dfrn:' . $a->get_baseurl() . ':' . local_user() . ':' . $hash ; - - $convid = 0; - $reply = false; - // look for any existing conversation structure - - if(strlen($replyto)) { - $reply = true; - $r = q("select convid from mail where uid = %d and ( uri = '%s' or `parent_uri` = '%s' ) limit 1", - intval(local_user()), - dbesc($replyto), - dbesc($replyto) + if($uid) { + $r = q("select * from channel where channel_id = %d limit 1", + intval($uid) ); - if(count($r)) - $convid = $r[0]['convid']; - } - - if(! $convid) { - - // create a new conversation - - $conv_guid = get_guid(); - - $recip_host = substr($contact[0]['url'],strpos($contact[0]['url'],'://')+3); - $recip_host = substr($recip_host,0,strpos($recip_host,'/')); + if($r) + $channel = $r[0]; + } + else { + $channel = get_app()->get_channel(); + } - $recip_handle = (($contact[0]['addr']) ? $contact[0]['addr'] : $contact[0]['nick'] . '@' . $recip_host); - $sender_handle = $a->user['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3); - $handles = $recip_handle . ';' . $sender_handle; + do { + $dups = false; + $hash = random_string(); - $r = q("insert into conv (uid,guid,creator,created,updated,subject,recips) values(%d, '%s', '%s', '%s', '%s', '%s', '%s') ", - intval(local_user()), - dbesc($conv_guid), - dbesc($sender_handle), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - dbesc($subject), - dbesc($handles) - ); + $uri = $hash . '@' . get_app()->get_hostname(); - $r = q("select * from conv where guid = '%s' and uid = %d limit 1", - dbesc($conv_guid), - intval(local_user()) - ); + $r = q("SELECT `id` FROM mail WHERE `uri` = '%s' LIMIT 1", + dbesc($uri)); if(count($r)) - $convid = $r[0]['id']; - } + $dups = true; + } while($dups == true); - if(! $convid) { - logger('send message: conversation not found.'); - return -4; - } if(! strlen($replyto)) { $replyto = $uri; } + - $r = q("INSERT INTO `mail` ( `uid`, `guid`, `convid`, `from-name`, `from-photo`, `from-url`, - `contact-id`, `title`, `body`, `seen`, `reply`, `replied`, `uri`, `parent_uri`, `created`) - VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, %d, '%s', '%s', '%s' )", + $r = q("INSERT INTO `mail` ( account_id, channel_id, from_xchan, to_xchan, title, body, uri, parent_uri, created ) + VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s' )", + intval($channel['channel_account_id']), intval(local_user()), - dbesc(get_guid()), - intval($convid), - dbesc($me[0]['name']), - dbesc($me[0]['thumb']), - dbesc($me[0]['url']), - intval($recipient), + dbesc($channel['channel_hash']), + dbesc($recipient), dbesc($subject), dbesc($body), - 1, - intval($reply), - 0, dbesc($uri), dbesc($replyto), - datetime_convert() + dbesc(datetime_convert()) ); - $r = q("SELECT * FROM `mail` WHERE `uri` = '%s' and `uid` = %d LIMIT 1", + $r = q("SELECT * FROM `mail` WHERE uri = '%s' and channel_id = %d LIMIT 1", dbesc($uri), intval(local_user()) ); if(count($r)) $post_id = $r[0]['id']; + /** * * When a photo was uploaded into the message using the (profile wall) ajax @@ -158,85 +110,3 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){ } - - - -function send_wallmessage($recipient='', $body='', $subject='', $replyto=''){ - - $a = get_app(); - - if(! $recipient) return -1; - - if(! strlen($subject)) - $subject = t('[no subject]'); - - $hash = random_string(); - $uri = 'urn:X-dfrn:' . $a->get_baseurl() . ':' . local_user() . ':' . $hash ; - - $convid = 0; - $reply = false; - - require_once('include/Scrape.php'); - - $me = probe_url($replyto); - - if(! $me['name']) - return -2; - - $conv_guid = get_guid(); - - $recip_handle = $recipient['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3); - - $sender_nick = basename($replyto); - $sender_host = substr($replyto,strpos($replyto,'://')+3); - $sender_host = substr($sender_host,0,strpos($sender_host,'/')); - $sender_handle = $sender_nick . '@' . $sender_host; - - $handles = $recip_handle . ';' . $sender_handle; - - $r = q("insert into conv (uid,guid,creator,created,updated,subject,recips) values(%d, '%s', '%s', '%s', '%s', '%s', '%s') ", - intval(local_user()), - dbesc($conv_guid), - dbesc($sender_handle), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - dbesc($subject), - dbesc($handles) - ); - - $r = q("select * from conv where guid = '%s' and uid = %d limit 1", - dbesc($conv_guid), - intval($recipient['uid']) - ); - if(count($r)) - $convid = $r[0]['id']; - - if(! $convid) { - logger('send message: conversation not found.'); - return -4; - } - - $r = q("INSERT INTO `mail` ( `uid`, `guid`, `convid`, `from-name`, `from-photo`, `from-url`, - `contact-id`, `title`, `body`, `seen`, `reply`, `replied`, `uri`, `parent_uri`, `created`, `unknown`) - VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, %d, '%s', '%s', '%s', %d )", - intval($recipient['uid']), - dbesc(get_guid()), - intval($convid), - dbesc($me['name']), - dbesc($me['photo']), - dbesc($me['url']), - 0, - dbesc($subject), - dbesc($body), - 0, - 0, - 0, - dbesc($uri), - dbesc($replyto), - datetime_convert(), - 1 - ); - - return 0; - -} diff --git a/include/nav.php b/include/nav.php index 24449409b..eacb0f29a 100644 --- a/include/nav.php +++ b/include/nav.php @@ -23,7 +23,7 @@ function nav(&$a) { minChars: 2, width: 250, }); - a.setOptions({ params: { type: 'x' }}); + a.setOptions({ params: { autoSubmit: true, type: 'x' }}); }); diff --git a/install/database.sql b/install/database.sql index bcdf969c4..24c9b9922 100644 --- a/install/database.sql +++ b/install/database.sql @@ -594,7 +594,8 @@ CREATE TABLE IF NOT EXISTS `item_id` ( CREATE TABLE IF NOT EXISTS `mail` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `mail_flags` int(10) unsigned NOT NULL DEFAULT '0', - `author_xchan` char(255) NOT NULL DEFAULT '', + `from_xchan` char(255) NOT NULL DEFAULT '', + `to_xchan` char(255) NOT NULL DEFAULT '', `account_id` int(10) unsigned NOT NULL DEFAULT '0', `channel_id` int(10) unsigned NOT NULL, `title` char(255) NOT NULL, @@ -606,11 +607,12 @@ CREATE TABLE IF NOT EXISTS `mail` ( KEY `uri` (`uri`), KEY `created` (`created`), KEY `mail_flags` (`mail_flags`), - KEY `author_xchan` (`author_xchan`), KEY `account_id` (`account_id`), KEY `channel_id` (`channel_id`), - KEY `parent_uri` (`parent_uri`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; + KEY `parent_uri` (`parent_uri`), + KEY `from_xchan` (`from_xchan`), + KEY `to_xchan` (`to_xchan`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `manage` ( `id` int(11) NOT NULL AUTO_INCREMENT, diff --git a/library/jquery_ac/friendica.complete.js b/library/jquery_ac/friendica.complete.js index ff2c37437..4599c7bc1 100644 --- a/library/jquery_ac/friendica.complete.js +++ b/library/jquery_ac/friendica.complete.js @@ -167,10 +167,10 @@ default:
return;
}
- if(e.keyCode != 13) {
+ // if(e.keyCode != 13) {
e.stopImmediatePropagation();
e.preventDefault();
- }
+ //}
},
onKeyUp: function(e) {
diff --git a/mod/acl.php b/mod/acl.php index 0db8af45e..248ba23d0 100644 --- a/mod/acl.php +++ b/mod/acl.php @@ -127,15 +127,11 @@ function acl_init(&$a){ ); } elseif($type == 'm') { - $r = q("SELECT `id`, `name`, `nick`, `micro`, `network`, `url`, `attag` FROM `contact` - WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 - AND `network` IN ('%s','%s','%s') - $sql_extra2 - ORDER BY `name` ASC ", - intval(local_user()), - dbesc(NETWORK_DFRN), - dbesc(NETWORK_ZOT), - dbesc(NETWORK_DIASPORA) + $r = q("SELECT xchan_hash as id, xchan_name as name, xchan_photo_s as micro, xchan_url as url from xchan + where 1 + $sql_extra3 + ORDER BY `xchan_name` ASC ", + intval(local_user()) ); } elseif($type == 'a') { @@ -170,7 +166,7 @@ function acl_init(&$a){ $x['photos'][] = $g['micro']; $x['links'][] = $g['url']; $x['suggestions'][] = (($type === 'x') ? '@' : '') . $g['name']; - $x['data'][] = intval($g['id']); + $x['data'][] = $g['id']; } } echo json_encode($x); diff --git a/mod/message.php b/mod/message.php index 2e4f175e2..34aee10a8 100644 --- a/mod/message.php +++ b/mod/message.php @@ -8,7 +8,7 @@ function message_init(&$a) { $new = array( 'label' => t('New Message'), 'url' => $a->get_baseurl(true) . '/message/new', - 'sel'=> ($a->argv[1] == 'new'), + 'sel'=> (argv(1) == 'new'), ); $tpl = get_markup_template('message_side.tpl'); @@ -48,13 +48,13 @@ function message_post(&$a) { $replyto = ((x($_REQUEST,'replyto')) ? notags(trim($_REQUEST['replyto'])) : ''); $subject = ((x($_REQUEST,'subject')) ? notags(trim($_REQUEST['subject'])) : ''); $body = ((x($_REQUEST,'body')) ? escape_tags(trim($_REQUEST['body'])) : ''); - $recipient = ((x($_REQUEST,'messageto')) ? intval($_REQUEST['messageto']) : 0 ); + $recipient = ((x($_REQUEST,'messageto')) ? notags(trim($_REQUEST['messageto'])) : ''); if(feature_enabled(local_user(),'richtext')) { $body = fix_mce_lf($body); } - $ret = send_message($recipient, $body, $subject, $replyto); + $ret = send_message(local_user(), $recipient, $body, $subject, $replyto); $norecip = false; switch($ret){ @@ -181,13 +181,13 @@ function message_content(&$a) { )); - if(($a->argc == 3) && ($a->argv[1] === 'drop' || $a->argv[1] === 'dropconv')) { - if(! intval($a->argv[2])) + if((argc() == 3) && (argv(1) === 'drop' || argv(1) === 'dropconv')) { + if(! intval(argv(2))) return; - $cmd = $a->argv[1]; + $cmd = argv(1); if($cmd === 'drop') { - $r = q("DELETE FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($a->argv[2]), + $r = q("DELETE FROM `mail` WHERE `id` = %d AND channel_id = %d LIMIT 1", + intval(argv(2)), intval(local_user()) ); if($r) { @@ -196,15 +196,15 @@ function message_content(&$a) { goaway($a->get_baseurl(true) . '/message' ); } else { - $r = q("SELECT `parent_uri`,`convid` FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($a->argv[2]), + $r = q("SELECT `parent_uri` FROM `mail` WHERE `id` = %d AND channel_id = %d LIMIT 1", + intval(argv(2)), intval(local_user()) ); if(count($r)) { $parent = $r[0]['parent_uri']; - $convid = $r[0]['convid']; - $r = q("DELETE FROM `mail` WHERE `parent_uri` = '%s' AND `uid` = %d ", + + $r = q("DELETE FROM `mail` WHERE `parent_uri` = '%s' AND channel_id = %d ", dbesc($parent), intval(local_user()) ); @@ -217,21 +217,24 @@ function message_content(&$a) { } - if(($a->argc > 1) && ($a->argv[1] === 'new')) { + $channel = $a->get_channel(); + + if((argc() > 1) && ($a->argv[1] === 'new')) { $o .= $header; $plaintext = false; if(intval(get_pconfig(local_user(),'system','plaintext'))) $plaintext = true; - + if(! feature_enabled(local_user(),'richtext')) + $plaintext = true; $tpl = get_markup_template('msg-header.tpl'); $a->page['htmlhead'] .= replace_macros($tpl, array( '$baseurl' => $a->get_baseurl(true), '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), - '$nickname' => $a->user['nickname'], + '$nickname' => $channel['channel_addr'], '$linkurl' => t('Please enter a link URL:') )); @@ -241,14 +244,15 @@ function message_content(&$a) { $prename = $preurl = $preid = ''; if($preselect) { - $r = q("select name, url, id from contact where uid = %d and id = %d limit 1", + $r = q("select abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash + where abook_channel = %d and abook_id = %d limit 1", intval(local_user()), - intval($a->argv[2]) + intval(argv(2)) ); - if(count($r)) { - $prename = $r[0]['name']; - $preurl = $r[0]['url']; - $preid = $r[0]['id']; + if($r) { + $prename = $r[0]['xchan_name']; + $preurl = $r[0]['xchan_url']; + $preid = $r[0]['abook_id']; } } @@ -282,7 +286,7 @@ function message_content(&$a) { return $o; } - if($a->argc == 1) { + if(argc() == 1) { // list messages @@ -290,103 +294,110 @@ function message_content(&$a) { $r = q("SELECT count(*) AS `total` FROM `mail` - WHERE `mail`.`uid` = %d GROUP BY `parent_uri` ORDER BY `created` DESC", - intval(local_user()), - dbesc($myprofile) + WHERE channel_id = %d", + intval(local_user()) ); - if(count($r)) + if($r) $a->set_pager_total($r[0]['total']); - $r = q("SELECT max(`mail`.`created`) AS `mailcreated`, min(`mail`.`seen`) AS `mailseen`, - `mail`.* , `contact`.`name`, `contact`.`url`, `contact`.`thumb` , `contact`.`network`, - count( * ) as count - FROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id` - WHERE `mail`.`uid` = %d GROUP BY `parent_uri` ORDER BY `mailcreated` DESC LIMIT %d , %d ", + $r = q("SELECT * from mail WHERE channel_id = %d order by created desc limit %d, %d", intval(local_user()), - // intval($a->pager['start']), intval($a->pager['itemspage']) ); - - if(! count($r)) { + if(! $r) { info( t('No messages.') . EOL); return $o; } + $chans = array(); + foreach($r as $rr) { + $s = "'" . dbesc(trim($rr['from_xchan'])) . "'"; + if(! in_array($s,$chans)) + $chans[] = $s; + $s = "'" . dbesc(trim($rr['to_xchan'])) . "'"; + if(! in_array($s,$chans)) + $chans[] = $s; + } + + $c = q("select * from xchan where xchan_hash in (" . implode(',',$chans) . ")"); + $tpl = get_markup_template('mail_list.tpl'); foreach($r as $rr) { - if($rr['unknown']) { - $partecipants = sprintf( t("Unknown sender - %s"),$rr['from-name']); - } - elseif (link_compare($rr['from-url'],$myprofile)){ - $partecipants = sprintf( t("You and %s"), $rr['name']); - } - else { - $partecipants = sprintf( t("%s and You"), $rr['from-name']); - } - + $rr['from'] = find_xchan_in_array($rr['from_xchan'],$c); + $rr['to'] = find_xchan_in_array($rr['to_xchan'],$c); + $rr['seen'] = (($rr['mail_flags'] & MAIL_SEEN) ? 1 : ""); + $o .= replace_macros($tpl, array( '$id' => $rr['id'], - '$from_name' => $partecipants, - '$from_url' => (($rr['network'] === NETWORK_DFRN) ? $a->get_baseurl(true) . '/redir/' . $rr['contact-id'] : $rr['url']), - '$sparkle' => ' sparkle', - '$from_photo' => (($rr['thumb']) ? $rr['thumb'] : $rr['from-photo']), - '$subject' => template_escape((($rr['mailseen']) ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>')), - '$delete' => t('Delete conversation'), + '$from_name' => template_escape($rr['from']['xchan_name']), + '$from_url' => z_root() . '/chanview/?f=&hash=' . $rr['from_xchan'], + '$from_photo' => $rr['from']['xchan_photo_s'], + '$to_name' => template_escape($rr['to']['xchan_name']), + '$to_url' => z_root() . '/chanview/?f=&hash=' . $rr['to_xchan'], + '$to_photo' => $rr['to']['xchan_photo_s'], + '$subject' => template_escape((($rr['seen']) ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>')), + '$delete' => t('Delete message'), '$body' => template_escape($rr['body']), - '$to_name' => template_escape($rr['name']), - '$date' => datetime_convert('UTC',date_default_timezone_get(),$rr['mailcreated'], t('D, d M Y - g:i A')), - '$seen' => $rr['mailseen'], - '$count' => sprintf( tt('%d message', '%d messages', $rr['count']), $rr['count']), + '$date' => datetime_convert('UTC',date_default_timezone_get(),$rr['created'], t('D, d M Y - g:i A')), + '$seen' => $rr['seen'] )); } $o .= paginate($a); return $o; } - if(($a->argc > 1) && (intval($a->argv[1]))) { + if((argc() > 1) && (intval(argv(1)))) { $o .= $header; - $r = q("SELECT `mail`.*, `contact`.`name`, `contact`.`url`, `contact`.`thumb` - FROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id` - WHERE `mail`.`uid` = %d AND `mail`.`id` = %d LIMIT 1", + $r = q("SELECT parent_uri from mail WHERE channel_id = %d and id = %d limit 1", intval(local_user()), - intval($a->argv[1]) + intval(argv(1)) ); - if(count($r)) { - $contact_id = $r[0]['contact-id']; - $convid = $r[0]['convid']; - - $sql_extra = sprintf(" and `mail`.`parent_uri` = '%s' ", dbesc($r[0]['parent_uri'])); - if($convid) - $sql_extra = sprintf(" and ( `mail`.`parent_uri` = '%s' OR `mail`.`convid` = '%d' ) ", - dbesc($r[0]['parent_uri']), - intval($convid) - ); - - $messages = q("SELECT `mail`.*, `contact`.`name`, `contact`.`url`, `contact`.`thumb` - FROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id` - WHERE `mail`.`uid` = %d $sql_extra ORDER BY `mail`.`created` ASC", - intval(local_user()) - ); - } - if(! count($messages)) { - notice( t('Message not available.') . EOL ); + + if(! $r) { + info( t('Message not found.') . EOL); return $o; } - $r = q("UPDATE `mail` SET `seen` = 1 WHERE `parent_uri` = '%s' AND `uid` = %d", + $messages = q("select * from mail where parent_uri = '%s' and channel_id = %d order by created asc", dbesc($r[0]['parent_uri']), intval(local_user()) ); + if(! $messages) { + info( t('Message not found.') . EOL); + return $o; + } + + $chans = array(); + foreach($messages as $rr) { + $s = "'" . dbesc(trim($rr['from_xchan'])) . "'"; + if(! in_array($s,$chans)) + $chans[] = $s; + $s = "'" . dbesc(trim($rr['to_xchan'])) . "'"; + if(! in_array($s,$chans)) + $chans[] = $s; + } + + +dbg(1); + $c = q("select * from xchan where xchan_hash in (" . implode(',',$chans) . ")"); + + $r = q("UPDATE `mail` SET mail_flags = (mail_flags ^ %d) where not (mail_flags & %d) and parent_uri = '%s' AND channel_id = %d", + intval(MAIL_SEEN), + intval(MAIL_SEEN), + dbesc($r[0]['parent_uri']), + intval(local_user()) + ); +dbg(0); require_once("include/bbcode.php"); $tpl = get_markup_template('msg-header.tpl'); $a->page['htmlhead'] .= replace_macros($tpl, array( - '$nickname' => $a->user['nickname'], + '$nickname' => $channel['channel_addr'], '$baseurl' => $a->get_baseurl(true) )); @@ -396,40 +407,39 @@ function message_content(&$a) { $unknown = false; foreach($messages as $message) { - if($message['unknown']) - $unknown = true; - if($message['from-url'] == $myprofile) { - $from_url = $myprofile; - $sparkle = ''; - } - else { - $from_url = $a->get_baseurl(true) . '/redir/' . $message['contact-id']; - $sparkle = ' sparkle'; - } + $message['from'] = find_xchan_in_array($message['from_xchan'],$c); + $message['to'] = find_xchan_in_array($message['to_xchan'],$c); + +logger('message: ' . print_r($message,true)); - $extracted = item_extract_images($message['body']); - if($extracted['images']) - $message['body'] = item_redir_and_replace_images($extracted['body'], $extracted['images'], $message['contact-id']); +// $extracted = item_extract_images($message['body']); +// if($extracted['images']) +// $message['body'] = item_redir_and_replace_images($extracted['body'], $extracted['images'], $message['contact-id']); $mails[] = array( 'id' => $message['id'], - 'from_name' => template_escape($message['from-name']), - 'from_url' => $from_url, - 'sparkle' => $sparkle, - 'from_photo' => $message['from-photo'], + 'from_name' => template_escape($message['from']['xchan_name']), + 'from_url' => z_root() . '/chanview/?f=&hash=' . $message['from_xchan'], + 'from_photo' => $message['from']['xchan_photo_m'], + 'to_name' => template_escape($message['to']['xchan_name']), + 'to_url' => z_root() . '/chanview/?f=&hash=' . $message['to_xchan'], + 'to_photo' => $message['to']['xchan_photo_m'], 'subject' => template_escape($message['title']), 'body' => template_escape(smilies(bbcode($message['body']))), 'delete' => t('Delete message'), - 'to_name' => template_escape($message['name']), 'date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'],'D, d M Y - g:i A'), ); $seen = $message['seen']; + } + logger('mails: ' . print_r($mails,true)); + + $recp = (($message['from_xchan'] === $channel['channel_hash']) ? 'to_xchan' : 'from_xchan'); - $select = $message['name'] . '<input type="hidden" name="messageto" value="' . $contact_id . '" />'; + $select = $message[$recp]['xchan_name'] . '<input type="hidden" name="messageto" value="' . $message[$recp]['xchan_hash'] . '" />'; $parent = '<input type="hidden" name="replyto" value="' . $message['parent_uri'] . '" />'; $tpl = get_markup_template('mail_display.tpl'); diff --git a/mod/ping.php b/mod/ping.php index 9650f2aec..f32384952 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -200,12 +200,13 @@ function ping_init(&$a) { $result['intros'] = intval($intros); $t4 = dba_timer(); + $channel = get_app()->get_channel(); - $myurl = $a->get_baseurl() . '/channel/' . $a->user['nickname'] ; - $mails = q("SELECT *, COUNT(*) AS `total` FROM `mail` - WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ", + $mails = q("SELECT count(id) as total from mail + WHERE channel_id = %d AND not (mail_flags & %d) and from_xchan != '%s' ", intval(local_user()), - dbesc($myurl) + intval(MAIL_SEEN), + dbesc($channel['channel_hash']) ); if($mails) $result['mail'] = intval($mails[0]['total']); diff --git a/version.inc b/version.inc index 4f3f1e040..fe7087514 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2012-12-03.158 +2012-12-04.159 diff --git a/view/js/mod_connections.js b/view/js/mod_connections.js index 410786cf5..b7352d336 100644 --- a/view/js/mod_connections.js +++ b/view/js/mod_connections.js @@ -5,7 +5,7 @@ $(document).ready(function() { minChars: 2, width: 350, }); - a.setOptions({ params: { type: 'a' }}); + a.setOptions({ params: { autoSubmit: true, type: 'a' }}); }); diff --git a/view/tpl/mail_conv.tpl b/view/tpl/mail_conv.tpl index 75a4506f6..fe115d223 100644 --- a/view/tpl/mail_conv.tpl +++ b/view/tpl/mail_conv.tpl @@ -1,9 +1,9 @@ <div class="mail-conv-outside-wrapper"> <div class="mail-conv-sender" > <a href="$mail.from_url" class="mail-conv-sender-url" ><img class="mframe mail-conv-sender-photo$mail.sparkle" src="$mail.from_photo" heigth="80" width="80" alt="$mail.from_name" /></a> + <div class="mail-conv-sender-name" >$mail.from_name</div> </div> <div class="mail-conv-detail" > - <div class="mail-conv-sender-name" >$mail.from_name</div> <div class="mail-conv-date">$mail.date</div> <div class="mail-conv-subject">$mail.subject</div> <div class="mail-conv-body">$mail.body</div> diff --git a/view/tpl/mail_list.tpl b/view/tpl/mail_list.tpl index 22e35dec8..4417d1863 100644 --- a/view/tpl/mail_list.tpl +++ b/view/tpl/mail_list.tpl @@ -1,9 +1,12 @@ <div class="mail-list-outside-wrapper"> <div class="mail-list-sender" > - <a href="$from_url" class="mail-list-sender-url" ><img class="mail-list-sender-photo$sparkle" src="$from_photo" height="80" width="80" alt="$from_name" /></a> - </div> - <div class="mail-list-detail"> + <a href="$from_url" class="mail-list-sender-url" ><img class="mail-list-sender-photo" src="$from_photo" height="32" width="32" alt="$from_name" /></a> <div class="mail-list-sender-name" >$from_name</div> + </div> + <div class="mail-list-recip" > + <a href="$to_url" class="mail-list-recip-url" ><img class="mail-list-recip-photo" src="$to_photo" height="32" width="32" alt="$to_name" /></a> + <div class="mail-list-recip-name" >$to_name</div> + </div> <div class="mail-list-date">$date</div> <div class="mail-list-subject"><a href="message/$id" class="mail-list-link">$subject</a></div> <div class="mail-list-delete-wrapper" id="mail-list-delete-wrapper-$id" > |