diff options
author | zottel <github@zottel.net> | 2012-04-02 08:52:24 +0200 |
---|---|---|
committer | zottel <github@zottel.net> | 2012-04-02 08:52:24 +0200 |
commit | 7127626f55f0ae5843d38145bf80022b98e4a8d8 (patch) | |
tree | 59813e196f7288be421cf187c2231adedca7d4b6 /mod | |
parent | f39e8126773e2a030cf84c8b9d428cc78546c1b9 (diff) | |
parent | 1f74bd1b78f7db4940f0fded0d6f7716579218f0 (diff) | |
download | volse-hubzilla-7127626f55f0ae5843d38145bf80022b98e4a8d8.tar.gz volse-hubzilla-7127626f55f0ae5843d38145bf80022b98e4a8d8.tar.bz2 volse-hubzilla-7127626f55f0ae5843d38145bf80022b98e4a8d8.zip |
Merge remote branch 'upstream/master'
Diffstat (limited to 'mod')
-rwxr-xr-x | mod/dfrn_request.php | 6 | ||||
-rwxr-xr-x | mod/editpost.php | 2 | ||||
-rwxr-xr-x | mod/filer.php | 4 | ||||
-rw-r--r-- | mod/filerm.php | 4 | ||||
-rwxr-xr-x | mod/item.php | 30 | ||||
-rwxr-xr-x | mod/message.php | 30 | ||||
-rwxr-xr-x | mod/network.php | 2 | ||||
-rwxr-xr-x | mod/newmember.php | 2 | ||||
-rwxr-xr-x | mod/profile.php | 21 | ||||
-rwxr-xr-x | mod/register.php | 11 | ||||
-rwxr-xr-x | mod/search.php | 15 | ||||
-rwxr-xr-x | mod/settings.php | 40 | ||||
-rw-r--r-- | mod/view.php | 3 | ||||
-rw-r--r-- | mod/wallmessage.php | 149 |
14 files changed, 267 insertions, 52 deletions
diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index c2d37dac7..5881b7b51 100755 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -664,8 +664,8 @@ function dfrn_request_content(&$a) { else $tpl = get_markup_template('auto_request.tpl'); - $page_desc = sprintf( t('Diaspora members: Please do not use this form. Instead, enter "%s" into your Diaspora search bar.'), - $target_addr) . EOL . EOL; + # $page_desc = sprintf( t('Diaspora members: Please do not use this form. Instead, enter "%s" into your Diaspora search bar.'), + # $target_addr) . EOL . EOL; $page_desc .= t("Please enter your 'Identity Address' from one of the following supported communications networks:"); @@ -699,7 +699,7 @@ function dfrn_request_content(&$a) { '$friendica' => t('Friendica'), '$statusnet' => t('StatusNet/Federated Social Web'), '$diaspora' => t('Diaspora'), - '$diasnote' => t('- please share from your own site as noted above'), + '$diasnote' => sprintf (t(' - please do not use this form. Instead, enter %s into your Diaspora search bar.'),$target_addr), '$your_address' => t('Your Identity Address:'), '$invite_desc' => $invite_desc, '$emailnet' => $emailnet, diff --git a/mod/editpost.php b/mod/editpost.php index 2ddba36aa..4c00201ca 100755 --- a/mod/editpost.php +++ b/mod/editpost.php @@ -115,6 +115,8 @@ function editpost_content(&$a) { '$jotnets' => $jotnets, '$title' => $itm[0]['title'], '$placeholdertitle' => t('Set title'), + '$category' => file_tag_file_to_list($itm[0]['file'], 'category'), + '$placeholdercategory' => t('Categories (comma-separated list)'), '$emtitle' => t('Example: bob@example.com, mary@example.com'), '$lockstate' => $lockstate, '$acl' => '', // populate_acl((($group) ? $group_acl : $a->user), $celeb), diff --git a/mod/filer.php b/mod/filer.php index 3b3a37931..3cd1bfe22 100755 --- a/mod/filer.php +++ b/mod/filer.php @@ -11,8 +11,8 @@ function filer_content(&$a) { killme(); } - $term = notags(trim($_GET['term'])); - $item_id = (($a->argc > 1) ? notags(trim($a->argv[1])) : 0); + $term = unxmlify(trim($_GET['term'])); + $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0); logger('filer: tag ' . $term . ' item ' . $item_id); diff --git a/mod/filerm.php b/mod/filerm.php index 66b684dc9..c520fec7a 100644 --- a/mod/filerm.php +++ b/mod/filerm.php @@ -6,8 +6,8 @@ function filerm_content(&$a) { killme(); } - $term = notags(trim($_GET['term'])); - $item_id = (($a->argc > 1) ? notags(trim($a->argv[1])) : 0); + $term = unxmlify(trim($_GET['term'])); + $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0); logger('filerm: tag ' . $term . ' item ' . $item_id); diff --git a/mod/item.php b/mod/item.php index 24730f53e..72e63865b 100755 --- a/mod/item.php +++ b/mod/item.php @@ -216,8 +216,6 @@ function item_post(&$a) { $emailcc = notags(trim($_REQUEST['emailcc'])); $body = escape_tags(trim($_REQUEST['body'])); - // $categories = TODO - $private = ((strlen($str_group_allow) || strlen($str_contact_allow) || strlen($str_group_deny) || strlen($str_contact_deny)) ? 1 : 0); if(($parent_item) && @@ -255,6 +253,19 @@ function item_post(&$a) { } } + if(strlen($categories)) { + // get the "fileas" tags for this post + $filedas = file_tag_file_to_list($categories, 'file'); + } + // save old and new categories, so we can determine what needs to be deleted from pconfig + $categories_old = $categories; + $categories = file_tag_list_to_file(trim($_REQUEST['category']), 'category'); + $categories_new = $categories; + if(strlen($filedas)) { + // append the fileas stuff to the new categories list + $categories .= file_tag_list_to_file($filedas, 'file'); + } + // Work around doubled linefeeds in Tinymce 3.5b2 // First figure out if it's a status post that would've been // created using tinymce. Otherwise leave it alone. @@ -572,6 +583,9 @@ function item_post(&$a) { intval($profile_uid) ); + // update filetags in pconfig + file_tag_update_pconfig($uid,$categories_old,$categories_new,'category'); + proc_run('php', "include/notifier.php", 'edit_post', "$post_id"); if((x($_REQUEST,'return')) && strlen($return_path)) { logger('return: ' . $return_path); @@ -585,8 +599,8 @@ function item_post(&$a) { $r = q("INSERT INTO `item` (`guid`, `uid`,`type`,`wall`,`gravity`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`, `author-name`, `author-link`, `author-avatar`, `created`, `edited`, `commented`, `received`, `changed`, `uri`, `thr-parent`, `title`, `body`, `app`, `location`, `coord`, - `tag`, `inform`, `verb`, `postopts`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail`, `attach`, `bookmark`,`origin`, `moderated` ) - VALUES( '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d )", + `tag`, `inform`, `verb`, `postopts`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail`, `attach`, `bookmark`,`origin`, `moderated`, `file` ) + VALUES( '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, '%s' )", dbesc($datarray['guid']), intval($datarray['uid']), dbesc($datarray['type']), @@ -624,8 +638,9 @@ function item_post(&$a) { dbesc($datarray['attach']), intval($datarray['bookmark']), intval($datarray['origin']), - intval($datarray['moderated']) - ); + intval($datarray['moderated']), + dbesc($datarray['file']) + ); $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1", dbesc($datarray['uri'])); @@ -633,6 +648,9 @@ function item_post(&$a) { $post_id = $r[0]['id']; logger('mod_item: saved item ' . $post_id); + // update filetags in pconfig + file_tag_update_pconfig($uid,$categories_old,$categories_new,'category'); + if($parent) { // This item is the last leaf and gets the comment box, clear any ancestors diff --git a/mod/message.php b/mod/message.php index 949e5616c..1369fde2e 100755 --- a/mod/message.php +++ b/mod/message.php @@ -192,15 +192,12 @@ function message_content(&$a) { return $o; } - if(($a->argc == 1) || ($a->argc == 2 && $a->argv[1] === 'sent')) { + if($a->argc == 1) { + + // list messages $o .= $header; - if($a->argc == 2) - $eq = sprintf( "AND `from-url` = '%s'", dbesc($myprofile)); - else - $eq = ''; - $r = q("SELECT count(*) AS `total` FROM `mail` WHERE `mail`.`uid` = %d AND `from-url` $eq '%s' GROUP BY `parent-uri` ORDER BY `created` DESC", intval(local_user()), @@ -213,7 +210,7 @@ function message_content(&$a) { `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 $eq GROUP BY `parent-uri` ORDER BY `mailcreated` DESC LIMIT %d , %d ", + WHERE `mail`.`uid` = %d GROUP BY `parent-uri` ORDER BY `mailcreated` DESC LIMIT %d , %d ", intval(local_user()), // intval($a->pager['start']), @@ -226,9 +223,13 @@ function message_content(&$a) { $tpl = get_markup_template('mail_list.tpl'); foreach($r as $rr) { - if ($rr['from-url'] == $myprofile){ + 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 { + } + else { $partecipants = sprintf( t("%s and You"), $rr['from-name']); } @@ -237,7 +238,7 @@ function message_content(&$a) { '$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'], + '$from_photo' => (($rr['thumb']) ? $rr['thumb'] : $rr['from-photo']), '$subject' => template_escape((($rr['mailseen']) ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>')), '$delete' => t('Delete conversation'), '$body' => template_escape($rr['body']), @@ -300,7 +301,11 @@ function message_content(&$a) { $mails = array(); $seen = 0; + $unknown = false; + foreach($messages as $message) { + if($message['unknown']) + $unknown = true; if($message['from-url'] == $myprofile) { $from_url = $myprofile; $sparkle = ''; @@ -326,7 +331,7 @@ function message_content(&$a) { } $select = $message['name'] . '<input type="hidden" name="messageto" value="' . $contact_id . '" />'; $parent = '<input type="hidden" name="replyto" value="' . $message['parent-uri'] . '" />'; - + $tpl = get_markup_template('mail_display.tpl'); $o = replace_macros($tpl, array( @@ -334,7 +339,8 @@ function message_content(&$a) { '$thread_subject' => $message['title'], '$thread_seen' => $seen, '$delete' => t('Delete conversation'), - + '$canreply' => (($unknown) ? false : '1'), + '$unknown_text' => t("No secure communications available. You <strong>may</strong> be able to respond from the sender's profile page."), '$mails' => $mails, // reply diff --git a/mod/network.php b/mod/network.php index 5ca0a8c7d..d27945a86 100755 --- a/mod/network.php +++ b/mod/network.php @@ -393,7 +393,7 @@ function network_content(&$a, $update = 0) { ); } if(strlen($file)) { - $sql_extra .= file_tag_file_query('item',$file); + $sql_extra .= file_tag_file_query('item',unxmlify($file)); } if($conv) { diff --git a/mod/newmember.php b/mod/newmember.php index 2ecc89024..683463ecb 100755 --- a/mod/newmember.php +++ b/mod/newmember.php @@ -13,6 +13,8 @@ function newmember_content(&$a) { $o .= '<ul>'; + $o .= '<li>' . '<a target="newmember" href="/help/guide">' . t('On your <em>Quick Start</em> page - find a brief introduction to your profile and network tabs, connect to Facebook, make some new connections, and find some groups to join.') . '</a></li>' . EOL; + $o .= '<li>' . '<a target="newmember" href="settings">' . t('On your <em>Settings</em> page - change your initial password. Also make a note of your Identity Address. This looks just like an email address - and will be useful in making friends on the free social web.') . '</a></li>' . EOL; $o .= '<li>' . '<a target="newmember" href="settings">' . t('Review the other settings, particularly the privacy settings. An unpublished directory listing is like having an unlisted phone number. In general, you should probably publish your listing - unless all of your friends and potential friends know exactly how to find you.') . '</a></li>' . EOL; diff --git a/mod/profile.php b/mod/profile.php index 782d17d83..26b33d5f1 100755 --- a/mod/profile.php +++ b/mod/profile.php @@ -2,6 +2,11 @@ function profile_init(&$a) { + require_once('include/contact_widgets.php'); + + if(! x($a->page,'aside')) + $a->page['aside'] = ''; + $blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false); if($a->argc > 1) @@ -59,6 +64,13 @@ function profile_init(&$a) { function profile_content(&$a, $update = 0) { + if (x($a->category)) { + $category = $a->category; + } + else { + $category = ((x($_GET,'category')) ? $_GET['category'] : ''); + } + if(get_config('system','block_public') && (! local_user()) && (! remote_user())) { return login(); } @@ -112,7 +124,8 @@ function profile_content(&$a, $update = 0) { return; } - + $a->page['aside'] .= categories_widget($a->get_baseurl(true) . '/profile/' . $a->profile['nickname'],(x($category) ? xmlify($category) : '')); + if(! $update) { if(x($_GET,'tab')) $tab = notags(trim($_GET['tab'])); @@ -135,6 +148,7 @@ function profile_content(&$a, $update = 0) { $celeb = ((($a->profile['page-flags'] == PAGE_SOAPBOX) || ($a->profile['page-flags'] == PAGE_COMMUNITY)) ? true : false); + if(can_write_wall($a,$a->profile['profile_uid'])) { $x = array( @@ -178,6 +192,10 @@ function profile_content(&$a, $update = 0) { } else { + if(x($category)) { + $sql_extra .= file_tag_file_query('item',$category,'category'); + } + $r = q("SELECT COUNT(*) AS `total` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 @@ -204,6 +222,7 @@ function profile_content(&$a, $update = 0) { intval($a->profile['profile_uid']) ); + } $parents_arr = array(); diff --git a/mod/register.php b/mod/register.php index 6d0e2700b..630c0a675 100755 --- a/mod/register.php +++ b/mod/register.php @@ -8,6 +8,8 @@ function register_post(&$a) { $verified = 0; $blocked = 1; + $arr = array('post' => $_POST); + call_hooks('register_post', $arr); $max_dailies = intval(get_config('system','max_daily_registrations')); if($max_dailes) { @@ -218,8 +220,8 @@ function register_post(&$a) { $spubkey = $spkey["key"]; $r = q("INSERT INTO `user` ( `guid`, `username`, `password`, `email`, `openid`, `nickname`, - `pubkey`, `prvkey`, `spubkey`, `sprvkey`, `register_date`, `verified`, `blocked` ) - VALUES ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d )", + `pubkey`, `prvkey`, `spubkey`, `sprvkey`, `register_date`, `verified`, `blocked`, `timezone` ) + VALUES ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, 'UTC' )", dbesc(generate_user_guid()), dbesc($username), dbesc($new_password_encoded), @@ -540,6 +542,11 @@ function register_content(&$a) { $license = ''; $o = get_markup_template("register.tpl"); + + $arr = array('template' => $o); + + call_hooks('register_form',$arr); + $o = replace_macros($o, array( '$oidhtml' => $oidhtml, '$invitations' => get_config('system','invitation_only'), diff --git a/mod/search.php b/mod/search.php index 50e7a6abc..6495fc8e5 100755 --- a/mod/search.php +++ b/mod/search.php @@ -97,19 +97,16 @@ function search_content(&$a) { // OR your own posts if you are a logged in member // No items will be shown if the member has a blocked profile wall. - $s_regx = sprintf("AND ( `item`.`body` REGEXP '%s' OR `item`.`tag` REGEXP '%s' )", - dbesc(preg_quote($search)), dbesc('\\]' . preg_quote($search) . '\\[')); - - $search_alg = $s_regx; - $r = q("SELECT COUNT(*) AS `total` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid` WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 AND (( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `user`.`hidewall` = 0) OR `item`.`uid` = %d ) AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - $search_alg ", - intval(local_user()) + AND ( `item`.`body` REGEXP '%s' OR `item`.`tag` REGEXP '%s' )", + intval(local_user()), + dbesc(preg_quote($search)), + dbesc('\\]' . preg_quote($search) . '\\[') ); if(count($r)) @@ -131,9 +128,11 @@ function search_content(&$a) { AND (( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `user`.`hidewall` = 0 ) OR `item`.`uid` = %d ) AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - $search_alg + AND ( `item`.`body` REGEXP '%s' OR `item`.`tag` REGEXP '%s' ) ORDER BY `received` DESC LIMIT %d , %d ", intval(local_user()), + dbesc(preg_quote($search)), + dbesc('\\]' . preg_quote($search) . '\\['), intval($a->pager['start']), intval($a->pager['itemspage']) diff --git a/mod/settings.php b/mod/settings.php index ce5ceea82..926d1faa5 100755 --- a/mod/settings.php +++ b/mod/settings.php @@ -303,7 +303,8 @@ function settings_post(&$a) { $page_flags = (((x($_POST,'page-flags')) && (intval($_POST['page-flags']))) ? intval($_POST['page-flags']) : 0); $blockwall = (((x($_POST,'blockwall')) && (intval($_POST['blockwall']) == 1)) ? 0: 1); // this setting is inverted! $blocktags = (((x($_POST,'blocktags')) && (intval($_POST['blocktags']) == 1)) ? 0: 1); // this setting is inverted! - + $unkmail = (((x($_POST,'unkmail')) && (intval($_POST['unkmail']) == 1)) ? 1: 0); + $cntunkmail = ((x($_POST,'cntunkmail')) ? intval($_POST['cntunkmail']) : 0); $suggestme = ((x($_POST,'suggestme')) ? intval($_POST['suggestme']) : 0); $hide_friends = (($_POST['hide-friends'] == 1) ? 1: 0); $hidewall = (($_POST['hidewall'] == 1) ? 1: 0); @@ -391,7 +392,7 @@ function settings_post(&$a) { set_pconfig(local_user(),'system','suggestme', $suggestme); - $r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `openid` = '%s', `timezone` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `notify-flags` = %d, `page-flags` = %d, `default-location` = '%s', `allow_location` = %d, `maxreq` = %d, `expire` = %d, `openidserver` = '%s', `blockwall` = %d, `hidewall` = %d, `blocktags` = %d WHERE `uid` = %d LIMIT 1", + $r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `openid` = '%s', `timezone` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `notify-flags` = %d, `page-flags` = %d, `default-location` = '%s', `allow_location` = %d, `maxreq` = %d, `expire` = %d, `openidserver` = '%s', `blockwall` = %d, `hidewall` = %d, `blocktags` = %d, `unkmail` = %d, `cntunkmail` = %d WHERE `uid` = %d LIMIT 1", dbesc($username), dbesc($email), dbesc($openid), @@ -410,6 +411,8 @@ function settings_post(&$a) { intval($blockwall), intval($hidewall), intval($blocktags), + intval($unkmail), + intval($cntunkmail), intval(local_user()) ); if($r) @@ -760,17 +763,19 @@ function settings_content(&$a) { if(count($p)) $profile = $p[0]; - $username = $a->user['username']; - $email = $a->user['email']; - $nickname = $a->user['nickname']; - $timezone = $a->user['timezone']; - $notify = $a->user['notify-flags']; - $defloc = $a->user['default-location']; - $openid = $a->user['openid']; - $maxreq = $a->user['maxreq']; - $expire = ((intval($a->user['expire'])) ? $a->user['expire'] : ''); - $blockwall = $a->user['blockwall']; - $blocktags = $a->user['blocktags']; + $username = $a->user['username']; + $email = $a->user['email']; + $nickname = $a->user['nickname']; + $timezone = $a->user['timezone']; + $notify = $a->user['notify-flags']; + $defloc = $a->user['default-location']; + $openid = $a->user['openid']; + $maxreq = $a->user['maxreq']; + $expire = ((intval($a->user['expire'])) ? $a->user['expire'] : ''); + $blockwall = $a->user['blockwall']; + $blocktags = $a->user['blocktags']; + $unkmail = $a->user['unkmail']; + $cntunkmail = $a->user['cntunkmail']; $expire_items = get_pconfig(local_user(), 'expire','items'); $expire_items = (($expire_items===false)? '1' : $expire_items); // default if not set: 1 @@ -870,6 +875,12 @@ function settings_content(&$a) { )); + $unkmail = replace_macros($opt_tpl,array( + '$field' => array('unkmail', t('Permit unknown people to send you private mail?'), $unkmail, '', array(t('No'),t('Yes'))), + + )); + + $invisible = (((! $profile['publish']) && (! $profile['net-publish'])) ? true : false); @@ -946,7 +957,8 @@ function settings_content(&$a) { '$profile_in_net_dir' => $profile_in_net_dir, '$hide_friends' => $hide_friends, '$hide_wall' => $hide_wall, - + '$unkmail' => $unkmail, + '$cntunkmail' => array('cntunkmail', t('Maximum private messages per day from unknown people:'), $cntunkmail ,t("\x28to prevent spam abuse\x29")), '$h_not' => t('Notification Settings'), diff --git a/mod/view.php b/mod/view.php index 33aa23f44..15b3733b3 100644 --- a/mod/view.php +++ b/mod/view.php @@ -9,7 +9,8 @@ function view_init($a){ if ($a->argc == 4){ $theme = $a->argv[2]; $THEMEPATH = "view/theme/$theme"; - require_once("view/theme/$theme/style.php"); + if(file_exists("view/theme/$theme/style.php")) + require_once("view/theme/$theme/style.php"); } killme(); diff --git a/mod/wallmessage.php b/mod/wallmessage.php new file mode 100644 index 000000000..1a4882b64 --- /dev/null +++ b/mod/wallmessage.php @@ -0,0 +1,149 @@ +<?php + +require_once('include/message.php'); + +function wallmessage_post(&$a) { + + $replyto = get_my_url(); + if(! $replyto) { + notice( t('Permission denied.') . EOL); + return; + } + + $subject = ((x($_REQUEST,'subject')) ? notags(trim($_REQUEST['subject'])) : ''); + $body = ((x($_REQUEST,'body')) ? escape_tags(trim($_REQUEST['body'])) : ''); + + $recipient = (($a->argc > 1) ? notags($a->argv[1]) : ''); + if((! $recipient) || (! $body)) { + return; + } + + $r = q("select * from user where nickname = '%s' limit 1", + dbesc($recipient) + ); + + if(! count($r)) { + logger('wallmessage: no recipient'); + return; + } + + $user = $r[0]; + + if(! intval($user['unkmail'])) { + notice( t('Permission denied.') . EOL); + return; + } + + $r = q("select count(*) as total from mail where uid = %d and created > UTC_TIMESTAMP() - INTERVAL 1 day and unknown = 1", + intval($user['uid']) + ); + + if($r[0]['total'] > $user['cntunkmail']) { + notice( sprintf( t('Number of daily wall messages for %s exceeded. Message failed.', $user['username']))); + return; + } + + // Work around doubled linefeeds in Tinymce 3.5b2 +dbg(1); + $body = str_replace("\r\n","\n",$body); + $body = str_replace("\n\n","\n",$body); + + + $ret = send_wallmessage($user, $body, $subject, $replyto); + + switch($ret){ + case -1: + notice( t('No recipient selected.') . EOL ); + break; + case -2: + notice( t('Unable to check your home location.') . EOL ); + break; + case -3: + notice( t('Message could not be sent.') . EOL ); + break; + case -4: + notice( t('Message collection failure.') . EOL ); + break; + default: + info( t('Message sent.') . EOL ); + } +dbg(0); +// goaway($a->get_baseurl() . '/profile/' . $user['nickname']); + +} + + +function wallmessage_content(&$a) { + + if(! get_my_url()) { + notice( t('Permission denied.') . EOL); + return; + } + + $recipient = (($a->argc > 1) ? $a->argv[1] : ''); + + if(! $recipient) { + notice( t('No recipient.') . EOL); + return; + } + + $r = q("select * from user where nickname = '%s' limit 1", + dbesc($recipient) + ); + + if(! count($r)) { + notice( t('No recipient.') . EOL); + logger('wallmessage: no recipient'); + return; + } + + $user = $r[0]; + + if(! intval($user['unkmail'])) { + notice( t('Permission denied.') . EOL); + return; + } + + $r = q("select count(*) as total from mail where uid = %d and created > UTC_TIMESTAMP() - INTERVAL 1 day and unknown = 1", + intval($user['uid']) + ); + + if($r[0]['total'] > $user['cntunkmail']) { + notice( sprintf( t('Number of daily wall messages for %s exceeded. Message failed.', $user['username']))); + return; + } + + + + $tpl = get_markup_template('wallmsg-header.tpl'); + + $a->page['htmlhead'] .= replace_macros($tpl, array( + '$baseurl' => $a->get_baseurl(true), + '$editselect' => '/(profile-jot-text|prvmail-text)/', + '$nickname' => $user['nickname'], + '$linkurl' => t('Please enter a link URL:') + )); + + + + $tpl = get_markup_template('wallmessage.tpl'); + $o .= replace_macros($tpl,array( + '$header' => t('Send Private Message'), + '$subheader' => sprintf( t('If you wish for %s to respond, please check that the privacy settings on your site allow private mail from unknown senders.'), $user['username']), + '$to' => t('To:'), + '$subject' => t('Subject:'), + '$recipname' => $user['username'], + '$nickname' => $user['nickname'], + '$subjtxt' => ((x($_REQUEST,'subject')) ? strip_tags($_REQUEST['subject']) : ''), + '$text' => ((x($_REQUEST,'body')) ? escape_tags(htmlspecialchars($_REQUEST['body'])) : ''), + '$readonly' => '', + '$yourmessage' => t('Your message:'), + '$select' => $select, + '$parent' => '', + '$upload' => t('Upload photo'), + '$insert' => t('Insert web link'), + '$wait' => t('Please wait') + )); + + return $o; + } |