diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/acl.php | 28 | ||||
-rw-r--r-- | mod/admin.php | 3 | ||||
-rw-r--r-- | mod/follow.php | 45 | ||||
-rw-r--r-- | mod/message.php | 70 | ||||
-rw-r--r-- | mod/network.php | 16 |
5 files changed, 116 insertions, 46 deletions
diff --git a/mod/acl.php b/mod/acl.php index 88f150d7a..168b1f59f 100644 --- a/mod/acl.php +++ b/mod/acl.php @@ -13,6 +13,14 @@ function acl_init(&$a){ $type = (x($_REQUEST,'type')?$_REQUEST['type']:""); + // For use with jquery.autocomplete for private mail completion + + if(x($_REQUEST,'query') && strlen($_REQUEST['query'])) { + $type = 'm'; + $search = $_REQUEST['query']; + } + + if ($search!=""){ $sql_extra = "AND `name` LIKE '%%".dbesc($search)."%%'"; $sql_extra2 = "AND (`attag` LIKE '%%".dbesc($search)."%%' OR `name` LIKE '%%".dbesc($search)."%%' OR `nick` LIKE '%%".dbesc($search)."%%')"; @@ -115,6 +123,26 @@ function acl_init(&$a){ else $r = array(); + + if($type == 'm') { + $x = array(); + $x['query'] = $search; + $x['photos'] = array(); + $x['links'] = array(); + $x['suggestions'] = array(); + $x['data'] = array(); + if(count($r)) { + foreach($r as $g) { + $x['photos'][] = $g['micro']; + $x['links'][] = $g['url']; + $x['suggestions'][] = $g['name']; // sprintf( t('%s [%s]'),$g['name'],$g['url']); + $x['data'][] = intval($g['id']); + } + } + echo json_encode($x); + killme(); + } + if(count($r)) { foreach($r as $g){ $contacts[] = array( diff --git a/mod/admin.php b/mod/admin.php index cfe5a2dd2..2810c8a8a 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -243,6 +243,7 @@ function admin_page_site_post(&$a){ $proxy = ((x($_POST,'proxy')) ? notags(trim($_POST['proxy'])) : ''); $timeout = ((x($_POST,'timeout')) ? intval(trim($_POST['timeout'])) : 60); $delivery_interval = ((x($_POST,'delivery_interval'))? intval(trim($_POST['delivery_interval'])) : 0); + $poll_interval = ((x($_POST,'poll_interval'))? intval(trim($_POST['poll_interval'])) : 0); $maxloadavg = ((x($_POST,'maxloadavg')) ? intval(trim($_POST['maxloadavg'])) : 50); $dfrn_only = ((x($_POST,'dfrn_only')) ? True : False); $ostatus_disabled = !((x($_POST,'ostatus_disabled')) ? True : False); @@ -291,6 +292,7 @@ function admin_page_site_post(&$a){ } set_config('system','ssl_policy',$ssl_policy); set_config('system','delivery_interval',$delivery_interval); + set_config('system','poll_interval',$poll_interval); set_config('system','maxloadavg',$maxloadavg); set_config('config','sitename',$sitename); if ($banner==""){ @@ -436,6 +438,7 @@ function admin_page_site(&$a) { '$proxy' => array('proxy', t("Proxy URL"), get_config('system','proxy'), ""), '$timeout' => array('timeout', t("Network timeout"), (x(get_config('system','curl_timeout'))?get_config('system','curl_timeout'):60), t("Value is in seconds. Set to 0 for unlimited (not recommended).")), '$delivery_interval' => array('delivery_interval', t("Delivery interval"), (x(get_config('system','delivery_interval'))?get_config('system','delivery_interval'):2), t("Delay background delivery processes by this many seconds to reduce system load. Recommend: 4-5 for shared hosts, 2-3 for virtual private servers. 0-1 for large dedicated servers.")), + '$poll_interval' => array('poll_interval', t("Poll interval"), (x(get_config('system','poll_interval'))?get_config('system','poll_interval'):2), t("Delay background polling processes by this many seconds to reduce system load. If 0, use delivery interval.")), '$maxloadavg' => array('maxloadavg', t("Maximum Load Average"), ((intval(get_config('system','maxloadavg')) > 0)?get_config('system','maxloadavg'):50), t("Maximum system load before delivery and poll processes are deferred - default 50.")), '$form_security_token' => get_form_security_token("admin_site"), diff --git a/mod/follow.php b/mod/follow.php index ae8cb200c..4a7f99bf0 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -10,7 +10,10 @@ function follow_init(&$a) { // NOTREACHED } + $uid = local_user(); $url = $orig_url = notags(trim($_REQUEST['url'])); + $return_url = $_SESSION['return_url']; + // remove ajax junk, e.g. Twitter @@ -18,19 +21,25 @@ function follow_init(&$a) { if(! allowed_url($url)) { notice( t('Disallowed profile URL.') . EOL); - goaway($_SESSION['return_url']); + goaway($return_url); // NOTREACHED } if(! $url) { notice( t('Connect URL missing.') . EOL); - goaway($_SESSION['return_url']); + goaway($return_url); // NOTREACHED } + $arr = array('url' => $url, 'contact' => array()); + + call_hooks('follow', $arr); - $ret = probe_url($url); + if(x($arr['contact'],'name')) + $ret = $arr['contact']; + else + $ret = probe_url($url); if($ret['network'] === NETWORK_DFRN) { if(strlen($a->path)) @@ -46,11 +55,11 @@ function follow_init(&$a) { if(get_config('system','dfrn_only')) { notice( t('This site is not configured to allow communications with other networks.') . EOL); notice( t('No compatible communication protocols or feeds were discovered.') . EOL); - goaway($_SESSION['return_url']); + goaway($return_url); } } - // This just confuses things, remove it + // This extra param just confuses things, remove it if($ret['network'] === NETWORK_DIASPORA) $ret['url'] = str_replace('?absolute=true','',$ret['url']); @@ -65,9 +74,11 @@ function follow_init(&$a) { notice( t('An author or name was not found.') . EOL); if(! x($ret,'url')) notice( t('No browser URL could be matched to this address.') . EOL); - if(strpos($url,'@') !== false) - notice('Unable to match @-style Identity Address with a known protocol or email contact'); - goaway($_SESSION['return_url']); + if(strpos($url,'@') !== false) { + notice( t('Unable to match @-style Identity Address with a known protocol or email contact.') . EOL); + notice( t('Use mailto: in front of address to force email check.') . EOL); + } + goaway($return_url); } if($ret['network'] === NETWORK_OSTATUS && get_config('system','ostatus_disabled')) { @@ -94,7 +105,7 @@ function follow_init(&$a) { // indirect links or webfinger links $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `poll` = '%s' LIMIT 1", - intval(local_user()), + intval($uid), dbesc($ret['poll']) ); @@ -104,7 +115,7 @@ function follow_init(&$a) { q("UPDATE `contact` SET `rel` = %d , `readonly` = 0 WHERE `id` = %d AND `uid` = %d LIMIT 1", intval(CONTACT_IS_FRIEND), intval($r[0]['id']), - intval(local_user()) + intval($uid) ); } } @@ -118,7 +129,7 @@ function follow_init(&$a) { $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `batch`, `notify`, `poll`, `poco`, `name`, `nick`, `photo`, `network`, `pubkey`, `rel`, `priority`, `writable`, `hidden`, `blocked`, `readonly`, `pending` ) VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, 0, 0, 0 ) ", - intval(local_user()), + intval($uid), dbesc(datetime_convert()), dbesc($ret['url']), dbesc(normalise_link($ret['url'])), @@ -142,12 +153,12 @@ function follow_init(&$a) { $r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1", dbesc($ret['url']), - intval(local_user()) + intval($uid) ); if(! count($r)) { notice( t('Unable to retrieve contact information.') . EOL); - goaway($_SESSION['return_url']); + goaway($return_url); // NOTREACHED } @@ -156,7 +167,7 @@ function follow_init(&$a) { require_once("Photo.php"); - $photos = import_profile_photo($ret['photo'],local_user(),$contact_id); + $photos = import_profile_photo($ret['photo'],$uid,$contact_id); $r = q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', @@ -200,7 +211,7 @@ function follow_init(&$a) { $r = q("SELECT `contact`.*, `user`.* FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid` WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1", - intval(local_user()) + intval($uid) ); if(count($r)) { @@ -215,9 +226,9 @@ function follow_init(&$a) { } } - if(strstr($_SESSION['return_url'],'contacts')) + if(strstr($return_url,'contacts')) goaway($a->get_baseurl() . '/contacts/' . $contact_id); - goaway($_SESSION['return_url']); + goaway($return_url); // NOTREACHED } diff --git a/mod/message.php b/mod/message.php index dbca45930..71f83b47a 100644 --- a/mod/message.php +++ b/mod/message.php @@ -4,20 +4,7 @@ require_once('include/acl_selectors.php'); require_once('include/message.php'); function message_init(&$a) { - $tabs = array( - /* - array( - 'label' => t('All'), - 'url'=> $a->get_baseurl(true) . '/message', - 'sel'=> ($a->argc == 1), - ), - array( - 'label' => t('Sent'), - 'url' => $a->get_baseurl(true) . '/message/sent', - 'sel'=> ($a->argv[1] == 'sent'), - ), - */ - ); + $tabs = array(); $new = array( 'label' => t('New Message'), 'url' => $a->get_baseurl(true) . '/message/new', @@ -29,6 +16,25 @@ function message_init(&$a) { '$tabs'=>$tabs, '$new'=>$new, )); + $base = $a->get_baseurl(); + + $a->page['htmlhead'] .= '<script src="' . $a->get_baseurl(true) . '/library/jquery_ac/friendica.complete.js" ></script>'; + $a->page['htmlhead'] .= <<< EOT + +<script>$(document).ready(function() { + var a; + a = $("#recip").autocomplete({ + serviceUrl: '$base/acl', + width: 350, + onSelect: function(value,data) { + $("#recip-complete").val(data); + } + }); + +}); + +</script> +EOT; } @@ -93,10 +99,6 @@ function message_content(&$a) { $myprofile = $a->get_baseurl(true) . '/profile/' . $a->user['nickname']; - - - - $tpl = get_markup_template('mail_head.tpl'); $header = replace_macros($tpl, array( '$messages' => t('Messages'), @@ -170,12 +172,36 @@ function message_content(&$a) { )); $preselect = (isset($a->argv[2])?array($a->argv[2]):false); - + + + $prename = $preurl = $preid = ''; + + if($preselect) { + $r = q("select name, url, id from contact where uid = %d and id = %d limit 1", + intval(local_user()), + intval($a->argv[2]) + ); + if(count($r)) { + $prename = $r[0]['name']; + $preurl = $r[0]['url']; + $preid = $r[0]['id']; + } + } + + $prefill = (($preselect) ? $prename : ''); + + // 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( '$header' => t('Send Private Message'), '$to' => t('To:'), + '$showinputs' => 'true', + '$prefill' => $prefill, + '$autocomp' => $autocomp, + '$preid' => $preid, '$subject' => t('Subject:'), '$subjtxt' => ((x($_REQUEST,'subject')) ? strip_tags($_REQUEST['subject']) : ''), '$text' => ((x($_REQUEST,'body')) ? escape_tags(htmlspecialchars($_REQUEST['body'])) : ''), @@ -198,7 +224,7 @@ function message_content(&$a) { $o .= $header; $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", + WHERE `mail`.`uid` = %d GROUP BY `parent-uri` ORDER BY `created` DESC", intval(local_user()), dbesc($myprofile) ); @@ -351,9 +377,10 @@ function message_content(&$a) { $seen = $message['seen']; } + + $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( @@ -368,6 +395,7 @@ function message_content(&$a) { // reply '$header' => t('Send Reply'), '$to' => t('To:'), + '$showinputs' => '', '$subject' => t('Subject:'), '$subjtxt' => template_escape($message['title']), '$readonly' => ' readonly="readonly" style="background: #BBBBBB;" ', diff --git a/mod/network.php b/mod/network.php index 5655f1bfa..e59839ccc 100644 --- a/mod/network.php +++ b/mod/network.php @@ -340,7 +340,7 @@ function network_content(&$a, $update = 0) { info( t('Group is empty')); } - $sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND ( `contact-id` IN ( $contact_str ) OR `allow_gid` REGEXP '<" . intval($group) . ">' ) and deleted = 0 ) "; + $sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND ( `contact-id` IN ( $contact_str ) OR `allow_gid` like '" . protect_sprintf('%<' . intval($group) . '>%') . "' ) and deleted = 0 ) "; $o = '<h2>' . t('Group: ') . $r[0]['name'] . '</h2>' . $o; } elseif($cid) { @@ -398,9 +398,9 @@ function network_content(&$a, $update = 0) { if(x($_GET,'search')) { $search = escape_tags($_GET['search']); - $sql_extra .= sprintf(" AND ( `item`.`body` REGEXP '%s' OR `item`.`tag` REGEXP '%s' ) ", - dbesc(preg_quote($search)), - dbesc('\\]' . preg_quote($search) . '\\[') + $sql_extra .= sprintf(" AND ( `item`.`body` like '%s' OR `item`.`tag` like '%s' ) ", + dbesc(protect_sprintf('%' . $search . '%')), + dbesc(protect_sprintf('%]' . $search . '[%')) ); } if(strlen($file)) { @@ -412,10 +412,10 @@ function network_content(&$a, $update = 0) { $myurl = substr($myurl,strpos($myurl,'://')+3); $myurl = str_replace(array('www.','.'),array('','\\.'),$myurl); $diasp_url = str_replace('/profile/','/u/',$myurl); - $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` regexp '%s' or `tag` regexp '%s' or tag regexp '%s' )) ", - dbesc($myurl . '$'), - dbesc($myurl . '\\]'), - dbesc($diasp_url . '\\]') + $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ", + dbesc(protect_sprintf('%s' . $myurl)), + dbesc(protect_sprintf('%' . $myurl . '\\]%')), + dbesc(protect_sprintf('%' . $diasp_url . '\\]%')) ); } |