diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/channel.php | 2 | ||||
-rw-r--r-- | mod/chat.php | 4 | ||||
-rw-r--r-- | mod/connedit.php | 5 | ||||
-rw-r--r-- | mod/dreport.php | 47 | ||||
-rw-r--r-- | mod/home.php | 6 | ||||
-rw-r--r-- | mod/import.php | 6 | ||||
-rw-r--r-- | mod/item.php | 23 | ||||
-rw-r--r-- | mod/mail.php | 94 | ||||
-rw-r--r-- | mod/photos.php | 110 | ||||
-rwxr-xr-x | mod/setup.php | 6 | ||||
-rw-r--r-- | mod/siteinfo.php | 2 |
11 files changed, 203 insertions, 102 deletions
diff --git a/mod/channel.php b/mod/channel.php index f1b74136e..0af2666cc 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -173,7 +173,7 @@ function channel_content(&$a, $update = 0, $load = false) { $r = q("SELECT distinct parent AS `item_id`, created from item left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) WHERE uid = %d $item_normal - AND item_wall = 1 AND item_unseen = 1 + AND item_wall = 1 $simple_update AND (abook.abook_blocked = 0 or abook.abook_flags is null) $sql_extra ORDER BY created DESC", diff --git a/mod/chat.php b/mod/chat.php index ef9089b6f..79a5c050b 100644 --- a/mod/chat.php +++ b/mod/chat.php @@ -59,6 +59,9 @@ function chat_post(&$a) { $arr = $acl->get(); $arr['name'] = $room; + $arr['expire'] = intval($_POST['chat_expire']); + if(intval($arr['expire']) < 0) + $arr['expire'] = 0; chatroom_create($channel,$arr); @@ -204,6 +207,7 @@ function chat_content(&$a) { $o = replace_macros(get_markup_template('chatroom_new.tpl'),array( '$header' => t('New Chatroom'), '$name' => array('room_name',t('Chatroom Name'),'', ''), + '$chat_expire' => array('chat_expire',t('Expiration of chats (minutes)'),120,''), '$permissions' => t('Permissions'), '$acl' => populate_acl($channel_acl,false), '$submit' => t('Submit') diff --git a/mod/connedit.php b/mod/connedit.php index 75a5fd719..6170d05a8 100644 --- a/mod/connedit.php +++ b/mod/connedit.php @@ -190,7 +190,7 @@ function connedit_post(&$a) { } } - $abook_pending = $new_friend ? 0 : $orig_record[0]['abook_pending']; + $abook_pending = (($new_friend) ? 0 : $orig_record[0]['abook_pending']; $r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_pending = %d, abook_incl = '%s', abook_excl = '%s' @@ -214,7 +214,6 @@ function connedit_post(&$a) { } - if($r) info( t('Connection updated.') . EOL); else @@ -222,7 +221,7 @@ function connedit_post(&$a) { if($a->poi && $a->poi['abook_my_perms'] != $abook_my_perms && (! intval($a->poi['abook_self']))) { - proc_run('php', 'include/notifier.php', 'permission_update', $contact_id); + proc_run('php', 'include/notifier.php', (($new_friend) ? 'permission_create' : 'permission_update'), $contact_id); } if($new_friend) { diff --git a/mod/dreport.php b/mod/dreport.php index 31a6274c8..c320bf0e6 100644 --- a/mod/dreport.php +++ b/mod/dreport.php @@ -7,14 +7,44 @@ function dreport_content(&$a) { return; } + $table = 'item'; + $channel = $a->get_channel(); $mid = ((argc() > 1) ? argv(1) : ''); + if($mid === 'mail') { + $table = 'mail'; + $mid = ((argc() > 2) ? argv(2) : ''); + } + + if(! $mid) { notice( t('Invalid message') . EOL); return; } + + switch($table) { + case 'item': + $i = q("select id from item where mid = '%s' and author_xchan = '%s' ", + dbesc($mid), + dbesc($channel['channel_hash']) + ); + break; + case 'mail': + $i = q("select id from mail where mid = '%s' and from_xchan = '%s'", + dbesc($mid), + dbesc($channel['channel_hash']) + ); + break; + default: + break; + } + + if(! $i) { + notice( t('Permission denied') . EOL); + return; + } $r = q("select * from dreport where dreport_xchan = '%s' and dreport_mid = '%s'", dbesc($channel['channel_hash']), @@ -33,6 +63,11 @@ function dreport_content(&$a) { for($x = 0; $x < count($r); $x++ ) { $r[$x]['name'] = escape_tags(substr($r[$x]['dreport_recip'],strpos($r[$x]['dreport_recip'],' '))); + // This has two purposes: 1. make the delivery report strings translateable, and + // 2. assign an ordering to item delivery results so we can group them and provide + // a readable report with more interesting events listed toward the top and lesser + // interesting items towards the bottom + switch($r[$x]['dreport_result']) { case 'channel sync processed': $r[$x]['gravity'] = 0; @@ -61,6 +96,18 @@ function dreport_content(&$a) { $r[$x]['dreport_result'] = t('permission denied'); $r[$x]['gravity'] = 6; break; + case 'recipient not found': + $r[$x]['dreport_result'] = t('recipient not found'); + break; + case 'mail recalled': + $r[$x]['dreport_result'] = t('mail recalled'); + break; + case 'duplicate mail received': + $r[$x]['dreport_result'] = t('duplicate mail received'); + break; + case 'mail delivered': + $r[$x]['dreport_result'] = t('mail delivered'); + break; default: $r[$x]['gravity'] = 1; break; diff --git a/mod/home.php b/mod/home.php index 242b2dcec..bf2463bbc 100644 --- a/mod/home.php +++ b/mod/home.php @@ -59,12 +59,14 @@ function home_content(&$a, $update = 0, $load = false) { return $o; } } + if(strpos($frontpage,'http') !== 0) + $frontpage = z_root() . '/' . $frontpage; if(intval(get_config('system','mirror_frontpage'))) { - $o = '<html><head><title>' . t('$Projectname') . '</title></head><body style="margin: 0; padding: 0; border: none;" ><iframe src="' . z_root() . '/' . $frontpage . '" width="100%" height="100%" style="margin: 0; padding: 0; border: none;" ></iframe></body></html>'; + $o = '<html><head><title>' . t('$Projectname') . '</title></head><body style="margin: 0; padding: 0; border: none;" ><iframe src="' . $frontpage . '" width="100%" height="100%" style="margin: 0; padding: 0; border: none;" ></iframe></body></html>'; echo $o; killme(); } - goaway(z_root() . '/' . $frontpage); + goaway($frontpage); } diff --git a/mod/import.php b/mod/import.php index b6e36d734..72d8f92e9 100644 --- a/mod/import.php +++ b/mod/import.php @@ -441,6 +441,12 @@ function import_post(&$a) { if(is_array($data['chatroom'])) import_chatrooms($channel,$data['chatroom']); + if(is_array($data['conv'])) + import_conv($channel,$data['conv']); + + if(is_array($data['mail'])) + import_mail($channel,$data['mail']); + if(is_array($data['event'])) import_events($channel,$data['event']); diff --git a/mod/item.php b/mod/item.php index 93f24bd1a..7488e709b 100644 --- a/mod/item.php +++ b/mod/item.php @@ -372,12 +372,23 @@ function item_post(&$a) { } else { - if((! $walltowall) && - ((array_key_exists('contact_allow',$_REQUEST)) - || (array_key_exists('group_allow',$_REQUEST)) - || (array_key_exists('contact_deny',$_REQUEST)) - || (array_key_exists('group_deny',$_REQUEST)))) { - $acl->set_from_array($_REQUEST); + if(! $walltowall) { + if((array_key_exists('contact_allow',$_REQUEST)) + || (array_key_exists('group_allow',$_REQUEST)) + || (array_key_exists('contact_deny',$_REQUEST)) + || (array_key_exists('group_deny',$_REQUEST))) { + $acl->set_from_array($_REQUEST); + } + elseif(! $api_source) { + + // if no ACL has been defined and we aren't using the API, the form + // didn't send us any parameters. This means there's no ACL or it has + // been reset to the default audience. + // If $api_source is set and there are no ACL parameters, we default + // to the channel permissions which were set in the ACL contructor. + + $acl->set(array('allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '')); + } } diff --git a/mod/mail.php b/mod/mail.php index e4a5ebafd..884c41565 100644 --- a/mod/mail.php +++ b/mod/mail.php @@ -97,7 +97,11 @@ function mail_post(&$a) { $ret = send_message(0, $recipient, $body, $subject, $replyto, $expires); - if(! $ret['success']) { + if($ret['success']) { + xchan_mail_query($ret['mail']); + build_sync_packet(0,array('conv' => array($ret['conv']),'mail' => array(encode_mail($ret['mail'],true)))); + } + else { notice($ret['message']); } @@ -149,6 +153,14 @@ function mail_content(&$a) { intval(argv(3)), intval(local_channel()) ); + $x = q("select * from mail where id = %d and channel_id = %d", + intval(argv(3)), + intval(local_channel()) + ); + if($x) { + build_sync_packet(local_channel(),array('mail' => encode_mail($x[0],true))); + } + proc_run('php','include/notifier.php','mail',intval(argv(3))); if($r) { @@ -185,68 +197,48 @@ function mail_content(&$a) { $a->page['htmlhead'] .= $header; - - $preselect = (isset($a->argv[2])?array($a->argv[2]):false); - $prename = $preurl = $preid = ''; - + $prename = ''; + $preid = ''; + if(x($_REQUEST,'hash')) { + $r = q("select abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and abook_xchan = '%s' limit 1", intval(local_channel()), dbesc($_REQUEST['hash']) ); - if($r) { - $prename = $r[0]['xchan_name']; - $preurl = $r[0]['xchan_url']; - $preid = $r[0]['abook_id']; - $preselect = array($preid); - } - } + if(!$r) { + $r = q("select * from xchan where xchan_hash = '%s' and xchan_network = 'zot' limit 1", + dbesc($_REQUEST['hash']) + ); + } - if($preselect) { - $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_channel()), - intval(argv(2)) - ); if($r) { - $prename = $r[0]['xchan_name']; + $prename = (($r[0]['abook_id']) ? $r[0]['xchan_name'] : $r[0]['xchan_addr']); $preurl = $r[0]['xchan_url']; - $preid = $r[0]['abook_id']; + $preid = (($r[0]['abook_id']) ? ($r[0]['xchan_hash']) : ''); + } + else { + notice( t('Requested channel is not in this network') . EOL ); } - } - - $prefill = (($preselect) ? $prename : ''); - if(! $prefill) { - if(array_key_exists('to',$_REQUEST)) - $prefill = $_REQUEST['to']; } - // the ugly select box - - $select = contact_select('messageto','message-to-select', $preselect, 4, true, false, false, 10); - $tpl = get_markup_template('prv_message.tpl'); $o .= replace_macros($tpl,array( + '$new' => true, '$header' => t('Send Private Message'), '$to' => t('To:'), - '$showinputs' => 'true', - '$prefill' => $prefill, - '$autocomp' => $autocomp, + '$prefill' => $prename, '$preid' => $preid, '$subject' => t('Subject:'), '$subjtxt' => ((x($_REQUEST,'subject')) ? strip_tags($_REQUEST['subject']) : ''), '$text' => ((x($_REQUEST,'body')) ? htmlspecialchars($_REQUEST['body'], ENT_COMPAT, 'UTF-8') : ''), - '$readonly' => '', '$yourmessage' => t('Your message:'), - '$select' => $select, '$parent' => '', - '$upload' => t('Upload photo'), '$attach' => t('Attach file'), '$insert' => t('Insert web link'), - '$wait' => t('Please wait'), '$submit' => t('Send'), '$defexpire' => '', '$feature_expire' => ((feature_enabled(local_channel(),'content_expire')) ? true : false), @@ -254,8 +246,6 @@ function mail_content(&$a) { '$feature_encrypt' => ((feature_enabled(local_channel(),'content_encrypt')) ? true : false), '$encrypt' => t('Encrypt text'), '$cipher' => $cipher, - - )); return $o; @@ -285,7 +275,14 @@ function mail_content(&$a) { // if( local_channel() && feature_enabled(local_channel(),'richtext') ) // $plaintext = false; - $messages = private_messages_fetch_conversation(local_channel(), $mid, true); + + + if($mailbox == 'combined') { + $messages = private_messages_fetch_conversation(local_channel(), $mid, true); + } + else { + $messages = private_messages_fetch_message(local_channel(), $mid, true); + } if(! $messages) { //info( t('Message not found.') . EOL); @@ -324,6 +321,7 @@ function mail_content(&$a) { $mails[] = array( 'mailbox' => $mailbox, 'id' => $message['id'], + 'mid' => $message['mid'], 'from_name' => $message['from']['xchan_name'], 'from_url' => chanlink_hash($message['from_xchan']), 'from_photo' => $message['from']['xchan_photo_s'], @@ -333,6 +331,7 @@ function mail_content(&$a) { 'subject' => $message['title'], 'body' => smilies(bbcode($message['body']) . $s), 'delete' => t('Delete message'), + 'dreport' => t('Delivery report'), 'recall' => t('Recall message'), 'can_recall' => (($channel['channel_hash'] == $message['from_xchan']) ? true : false), 'is_recalled' => (intval($message['mail_recalled']) ? t('Message has been recalled.') : ''), @@ -345,10 +344,6 @@ function mail_content(&$a) { $recp = (($message['from_xchan'] === $channel['channel_hash']) ? 'to' : 'from'); -// FIXME - move this HTML to template - - $select = $message[$recp]['xchan_name'] . '<input type="hidden" name="messageto" value="' . $message[$recp]['xchan_hash'] . '" />'; - $parent = '<input type="hidden" name="replyto" value="' . $message['parent_mid'] . '" />'; $tpl = get_markup_template('mail_display.tpl'); $o = replace_macros($tpl, array( '$mailbox' => $mailbox, @@ -364,19 +359,16 @@ function mail_content(&$a) { // reply '$header' => t('Send Reply'), '$to' => t('To:'), - '$showinputs' => '', + '$reply' => true, '$subject' => t('Subject:'), '$subjtxt' => $message['title'], - '$readonly' => 'readonly="readonly"', - '$yourmessage' => t('Your message:'), + '$yourmessage' => sprintf(t('Your message for %s (%s):'), $message[$recp]['xchan_name'], $message[$recp]['xchan_addr']), '$text' => '', - '$select' => $select, - '$parent' => $parent, - '$upload' => t('Upload photo'), + '$parent' => $message['parent_mid'], + '$recphash' => $message[$recp]['xchan_hash'], '$attach' => t('Attach file'), '$insert' => t('Insert web link'), '$submit' => t('Submit'), - '$wait' => t('Please wait'), '$defexpire' => '', '$feature_expire' => ((feature_enabled(local_channel(),'content_expire')) ? true : false), '$expires' => t('Set expiration date'), diff --git a/mod/photos.php b/mod/photos.php index cd293b39d..0442a5d24 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -149,8 +149,9 @@ function photos_post(&$a) { if($r) { foreach($r as $i) { attach_delete($page_owner_uid, $i['resource_id'], 1 ); - drop_item($i['id'],false,DROPITEM_PHASE1,true /* force removal of linked items */); - proc_run('php','include/notifier.php','drop',$i['id']); + // This is now being done in attach_delete() + // drop_item($i['id'],false,DROPITEM_PHASE1,true /* force removal of linked items */); + // proc_run('php','include/notifier.php','drop',$i['id']); } } @@ -182,12 +183,17 @@ function photos_post(&$a) { ); if($r) { + + /* this happens in attach_delete q("DELETE FROM `photo` WHERE `uid` = %d AND `resource_id` = '%s'", intval($page_owner_uid), dbesc($r[0]['resource_id']) ); + */ + attach_delete($page_owner_uid, $r[0]['resource_id'], 1 ); + /* this happens in attach_delete $i = q("SELECT * FROM `item` WHERE `resource_id` = '%s' AND resource_type = 'photo' and `uid` = %d LIMIT 1", dbesc($r[0]['resource_id']), intval($page_owner_uid) @@ -196,6 +202,7 @@ function photos_post(&$a) { drop_item($i[0]['id'],true,DROPITEM_PHASE1); $url = $a->get_baseurl(); } + */ } goaway($a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . $_SESSION['album_return']); @@ -229,15 +236,46 @@ function photos_post(&$a) { intval($page_owner_uid) ); if(count($r)) { - $ph = photo_factory(dbunescbin($r[0]['data']), $r[0]['type']); + $d = (($r[0]['os_storage']) ? @file_get_contents($r[0]['data']) : dbunescbin($r[0]['data'])); + $ph = photo_factory($d, $r[0]['type']); if($ph->is_valid()) { $rotate_deg = ( (intval($_POST['rotate']) == 1) ? 270 : 90 ); $ph->rotate($rotate_deg); $width = $ph->getWidth(); $height = $ph->getHeight(); + + if(intval($r[0]['os_storage'])) { + @file_put_contents($r[0]['data'],$ph->imageString()); + $data = $r[0]['data']; + $fsize = @filesize($r[0]['data']); + q("update attach set filesize = %d where hash = '%s' and uid = %d limit 1", + intval($fsize), + dbesc($resource_id), + intval($page_owner_uid) + ); + } + else { + $data = $ph->imageString(); + $fsize = strlen($data); + } + + $x = q("update photo set data = '%s', `size` = %d, height = %d, width = %d where `resource_id` = '%s' and uid = %d and scale = 0", + dbescbin($data), + intval($fsize), + intval($height), + intval($width), + dbesc($resource_id), + intval($page_owner_uid) + ); + + if($width > 1024 || $height > 1024) + $ph->scaleImage(1024); + + $width = $ph->getWidth(); + $height = $ph->getHeight(); - $x = q("update photo set data = '%s', height = %d, width = %d where `resource_id` = '%s' and uid = %d and scale = 0", + $x = q("update photo set data = '%s', height = %d, width = %d where `resource_id` = '%s' and uid = %d and scale = 1", dbescbin($ph->imageString()), intval($height), intval($width), @@ -245,38 +283,40 @@ function photos_post(&$a) { intval($page_owner_uid) ); - if($width > 640 || $height > 640) { + + if($width > 640 || $height > 640) $ph->scaleImage(640); - $width = $ph->getWidth(); - $height = $ph->getHeight(); - - $x = q("update photo set data = '%s', height = %d, width = %d where `resource_id` = '%s' and uid = %d and scale = 1", - dbescbin($ph->imageString()), - intval($height), - intval($width), - dbesc($resource_id), - intval($page_owner_uid) - ); - } - if($width > 320 || $height > 320) { + $width = $ph->getWidth(); + $height = $ph->getHeight(); + + $x = q("update photo set data = '%s', height = %d, width = %d where `resource_id` = '%s' and uid = %d and scale = 2", + dbescbin($ph->imageString()), + intval($height), + intval($width), + dbesc($resource_id), + intval($page_owner_uid) + ); + + + if($width > 320 || $height > 320) $ph->scaleImage(320); - $width = $ph->getWidth(); - $height = $ph->getHeight(); - $x = q("update photo set data = '%s', height = %d, width = %d where `resource_id` = '%s' and uid = %d and scale = 2", - dbescbin($ph->imageString()), - intval($height), - intval($width), - dbesc($resource_id), - intval($page_owner_uid) - ); - } + $width = $ph->getWidth(); + $height = $ph->getHeight(); + + $x = q("update photo set data = '%s', height = %d, width = %d where `resource_id` = '%s' and uid = %d and scale = 3", + dbescbin($ph->imageString()), + intval($height), + intval($width), + dbesc($resource_id), + intval($page_owner_uid) + ); } } } - $p = q("SELECT * FROM `photo` WHERE `resource_id` = '%s' AND `uid` = %d ORDER BY `scale` DESC", + $p = q("SELECT type, is_nsfw, description, resource_id, scale, allow_cid, allow_gid, deny_cid, deny_gid FROM photo WHERE resource_id = '%s' AND uid = %d ORDER BY scale DESC", dbesc($resource_id), intval($page_owner_uid) ); @@ -982,13 +1022,13 @@ function photos_content(&$a) { $likebuttons = ''; if($can_post || $can_comment) { - $likebuttons = replace_macros($like_tpl,array( - '$id' => $link_item['id'], - '$likethis' => t("I like this \x28toggle\x29"), - '$nolike' => t("I don't like this \x28toggle\x29"), - '$share' => t('Share'), - '$wait' => t('Please wait') - )); + $likebuttons = array( + 'id' => $link_item['id'], + 'likethis' => t("I like this \x28toggle\x29"), + 'nolike' => t("I don't like this \x28toggle\x29"), + 'share' => t('Share'), + 'wait' => t('Please wait') + ); } $comments = ''; diff --git a/mod/setup.php b/mod/setup.php index 15820f14e..e5ac25965 100755 --- a/mod/setup.php +++ b/mod/setup.php @@ -292,7 +292,7 @@ function setup_content(&$a) { case 2: { // Database config - $dbhost = ((x($_POST,'dbhost')) ? notags(trim($_POST['dbhost'])) : 'localhost'); + $dbhost = ((x($_POST,'dbhost')) ? notags(trim($_POST['dbhost'])) : '127.0.0.1'); $dbuser = notags(trim($_POST['dbuser'])); $dbport = intval(notags(trim($_POST['dbport']))); $dbpass = notags(trim($_POST['dbpass'])); @@ -312,7 +312,7 @@ function setup_content(&$a) { '$status' => $wizard_status, - '$dbhost' => array('dbhost', t('Database Server Name'), $dbhost, t('Default is localhost')), + '$dbhost' => array('dbhost', t('Database Server Name'), $dbhost, t('Default is 127.0.0.1')), '$dbport' => array('dbport', t('Database Port'), $dbport, t('Communication port number - use 0 for default')), '$dbuser' => array('dbuser', t('Database Login Name'), $dbuser, ''), '$dbpass' => array('dbpass', t('Database Login Password'), $dbpass, ''), @@ -334,7 +334,7 @@ function setup_content(&$a) { }; break; case 3: { // Site settings require_once('include/datetime.php'); - $dbhost = ((x($_POST,'dbhost')) ? notags(trim($_POST['dbhost'])) : 'localhost'); + $dbhost = ((x($_POST,'dbhost')) ? notags(trim($_POST['dbhost'])) : '127.0.0.1'); $dbport = intval(notags(trim($_POST['dbuser']))); $dbuser = notags(trim($_POST['dbuser'])); $dbpass = notags(trim($_POST['dbpass'])); diff --git a/mod/siteinfo.php b/mod/siteinfo.php index 14aaef144..2fffccc73 100644 --- a/mod/siteinfo.php +++ b/mod/siteinfo.php @@ -165,7 +165,7 @@ function siteinfo_content(&$a) { '$loadavg_all' => $loadavg[0] . ', ' . $loadavg[1] . ', ' . $loadavg[2], '$commit' => $commit, '$web_location' => t('Running at web location') . ' ' . z_root(), - '$visit' => t('Please visit <a href="https://redmatrix.me">redmatrix.me</a> to learn more about $Projectname.'), + '$visit' => t('Please visit <a href="http://hubzilla.org">hubzilla.org</a> to learn more about $Projectname.'), '$bug_text' => t('Bug reports and issues: please visit'), '$bug_link_url' => 'https://github.com/redmatrix/hubzilla/issues', '$bug_link_text' => t('$projectname issues'), |