From 3116db1a74657f1f9f87ef91181104819d01fd95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20H=C3=B6=C3=9Fl?= Date: Sun, 22 Apr 2012 13:28:54 +0000 Subject: Add a hook --- mod/ping.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'mod') diff --git a/mod/ping.php b/mod/ping.php index e911aaf1f..63aaa0f45 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -134,6 +134,8 @@ function ping_init(&$a) { function xmlize($href, $name, $url, $photo, $date, $seen, $message){ + $data = array('href' => &$href, 'name' => &$name, 'url'=>&$url, 'photo'=>&$photo, 'date'=>&$date, 'seen'=>&$seen, 'messsage'=>&$message); + call_hooks('ping_xmlize', $data); $notsxml = '%s'; return sprintf ( $notsxml, xmlify($href), xmlify($name), xmlify($url), xmlify($photo), xmlify($date), xmlify($seen), xmlify($message) -- cgit v1.2.3 From 76aa9b3037a69d7d3be7e2f7c1416438a30dd577 Mon Sep 17 00:00:00 2001 From: Michael Johnston Date: Sun, 22 Apr 2012 13:37:25 -0400 Subject: api: add support for StatusNet-style media param to API --- mod/wall_upload.php | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'mod') diff --git a/mod/wall_upload.php b/mod/wall_upload.php index f341cc9cd..fa66561e8 100644 --- a/mod/wall_upload.php +++ b/mod/wall_upload.php @@ -5,19 +5,26 @@ require_once('Photo.php'); function wall_upload_post(&$a) { if($a->argc > 1) { - $nick = $a->argv[1]; - $r = q("SELECT `user`.*, `contact`.`id` FROM `user` LEFT JOIN `contact` on `user`.`uid` = `contact`.`uid` WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0 and `contact`.`self` = 1 LIMIT 1", - dbesc($nick) - ); - if(! count($r)) - return; - + if(! x($_FILES,'media')) { + $nick = $a->argv[1]; + $r = q("SELECT `user`.*, `contact`.`id` FROM `user` LEFT JOIN `contact` on `user`.`uid` = `contact`.`uid` WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0 and `contact`.`self` = 1 LIMIT 1", + dbesc($nick) + ); + + if(! count($r)) + return; + } + else { + $user_info = api_get_user($a); + $r = q("SELECT `user`.*, `contact`.`id` FROM `user` LEFT JOIN `contact` on `user`.`uid` = `contact`.`uid` WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0 and `contact`.`self` = 1 LIMIT 1", + dbesc($user_info['screen_name']) + ); + } } else return; - $can_post = false; $visitor = 0; @@ -47,12 +54,19 @@ function wall_upload_post(&$a) { killme(); } - if(! x($_FILES,'userfile')) + if(! x($_FILES,'userfile') && ! x($_FILES,'media')) killme(); - $src = $_FILES['userfile']['tmp_name']; - $filename = basename($_FILES['userfile']['name']); - $filesize = intval($_FILES['userfile']['size']); + if(x($_FILES,'userfile')) { + $src = $_FILES['userfile']['tmp_name']; + $filename = basename($_FILES['userfile']['name']); + $filesize = intval($_FILES['userfile']['size']); + } + elseif(x($_FILES,'media')) { + $src = $_FILES['media']['tmp_name']; + $filename = basename($_FILES['media']['name']); + $filesize = intval($_FILES['media']['size']); + } $maximagesize = get_config('system','maximagesize'); -- cgit v1.2.3 From 00cb7f9efb4826a6ad5c0791f26bc5e8db644f77 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 22 Apr 2012 16:24:29 -0700 Subject: don't allow non-existent themes as choices --- mod/settings.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/settings.php b/mod/settings.php index 721468437..8c8b3062d 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -696,8 +696,8 @@ function settings_content(&$a) { $allowed_themes_raw = explode(',',$allowed_themes_str); $allowed_themes = array(); if(count($allowed_themes_raw)) - foreach($allowed_themes_raw as $x) - if(strlen(trim($x))) + foreach($allowed_themes_raw as $x) + if(strlen(trim($x)) && is_dir("view/theme/$x")) $allowed_themes[] = trim($x); -- cgit v1.2.3 From 8f0f644295ba292ebcc44edb1d8679bfb6a1d3a6 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 23 Apr 2012 05:16:57 -0700 Subject: protect jappixmini/proxy from typo check, more work on email2 connector --- mod/dfrn_request.php | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 77a3124f7..74d25adbf 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -314,7 +314,7 @@ function dfrn_request_post(&$a) { if($email_follow) { - if(! strpos($url,'@')) { + if(! validate_email($url)) { notice( t('Invalid email address.') . EOL); return; } @@ -346,11 +346,59 @@ function dfrn_request_post(&$a) { } } + $r = q("insert into contact ( uid, created, addr, name, nick, url, nurl, poll, notify, blocked, pending, network, rel ) + values( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d ) ", + intval($uid), + dbesc(datetime_convert()), + dbesc($addr), + dbesc($name), + dbesc($nick), + dbesc($url), + dbesc($nurl), + dbesc($poll), + dbesc($notify), + intval($blocked), + intval($pending), + dbesc($network), + intval($rel) + ); + + $r = q("select id from contact where poll = '%s' and uid = %d limit 1", + dbesc($poll), + intval($uid) + ); + if(count($r)) { + $contact_id = $r[0]['id']; + + $photo = avatar_img($addr); + + $r = q("UPDATE `contact` SET + `photo` = '%s', + `thumb` = '%s', + `micro` = '%s', + `name-date` = '%s', + `uri-date` = '%s', + `avatar-date` = '%s', + `hidden` = 0, + WHERE `id` = %d LIMIT 1 + ", + dbesc($photos[0]), + dbesc($photos[1]), + dbesc($photos[2]), + dbesc(datetime_convert()), + dbesc(datetime_convert()), + dbesc(datetime_convert()), + intval($contact_id) + ); + } + // contact is created. Now send an email verify form to the requestor. + // } + else { // Canonicalise email-style profile locator -- cgit v1.2.3 From f265863435b15ab08e3312343672ef8d43aea76e Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 23 Apr 2012 18:28:33 -0700 Subject: more work on mail2 (introductions), added 'm' (mail) flag to ACL backend for autocomplete of PM recips --- mod/acl.php | 39 +++++++++++++++++++++++++++++++++++---- mod/dfrn_request.php | 16 ++++++++++++++-- 2 files changed, 49 insertions(+), 6 deletions(-) (limited to 'mod') diff --git a/mod/acl.php b/mod/acl.php index fe353d1eb..c23ee1a67 100644 --- a/mod/acl.php +++ b/mod/acl.php @@ -38,6 +38,22 @@ function acl_init(&$a){ intval(local_user()) ); $contact_count = (int)$r[0]['c']; + } + elseif ($type == 'm') { + + // autocomplete for Private Messages + + $r = q("SELECT COUNT(`id`) AS c FROM `contact` + WHERE `uid` = %d AND `self` = 0 + AND `blocked` = 0 AND `pending` = 0 + AND `network` IN ('%s','%s','%s') $sql_extra2" , + intval(local_user()), + dbesc(NETWORK_DFRN), + dbesc(NETWORK_ZOT), + dbesc(NETWORK_DIASPORA) + ); + $contact_count = (int)$r[0]['c']; + } else { $contact_count = 0; } @@ -83,6 +99,23 @@ function acl_init(&$a){ ORDER BY `name` ASC ", intval(local_user()) ); + } + 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 `network` IN ('%s','%s','%s') + $sql_extra2 + ORDER BY `name` ASC ", + intval(local_user()), + dbesc(NETWORK_DFRN), + dbesc(NETWORK_ZOT), + dbesc(NETWORK_DIASPORA) + ); + } + else + $r = array(); + + if(count($r)) { foreach($r as $g){ $contacts[] = array( "type" => "c", @@ -93,11 +126,9 @@ function acl_init(&$a){ "link" => $g['url'], "nick" => ($g['attag']) ? $g['attag'] : $g['nick'], ); - } - + } } - - + $items = array_merge($groups, $contacts); $o = array( diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 74d25adbf..79583ea18 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -392,10 +392,22 @@ function dfrn_request_post(&$a) { ); } - // contact is created. Now send an email verify form to the requestor. - // + // contact is created. Now create an introduction + $hash = random_string(); + $r = q("insert into intro ( uid, `contact-id`, knowyou, note, hash, datetime, blocked ) + values( %d , %d, %d, '%s', '%s', '%s', %d ) ", + intval($uid), + intval($contact_id), + ((x($_POST,'knowyou') && ($_POST['knowyou'] == 1)) ? 1 : 0), + dbesc(notags(trim($_POST['dfrn-request-message']))), + dbesc($hash), + dbesc(datetime_convert()), + 1 + ); + + // Next send an email verify form to the requestor. } -- cgit v1.2.3 From 363753411914ab9d2678c5b47f432e5357ad7a04 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 23 Apr 2012 19:42:57 -0700 Subject: move unfriend to standalone function for use in account removal --- mod/contacts.php | 37 ++++--------------------------------- 1 file changed, 4 insertions(+), 33 deletions(-) (limited to 'mod') diff --git a/mod/contacts.php b/mod/contacts.php index 9d29d4bd1..8670c0c80 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -144,7 +144,7 @@ function contacts_content(&$a) { goaway($a->get_baseurl(true) . '/contacts'); return; // NOTREACHED } - + if($cmd === 'update') { // pull feed and consume it, which should subscribe to the hub. @@ -184,38 +184,9 @@ function contacts_content(&$a) { if($cmd === 'drop') { - // create an unfollow slap - - if($orig_record[0]['network'] === NETWORK_OSTATUS) { - $tpl = get_markup_template('follow_slap.tpl'); - $slap = replace_macros($tpl, array( - '$name' => $a->user['username'], - '$profile_page' => $a->get_baseurl() . '/profile/' . $a->user['nickname'], - '$photo' => $a->contact['photo'], - '$thumb' => $a->contact['thumb'], - '$published' => datetime_convert('UTC','UTC', 'now', ATOM_TIME), - '$item_id' => 'urn:X-dfrn:' . $a->get_hostname() . ':unfollow:' . random_string(), - '$title' => '', - '$type' => 'text', - '$content' => t('stopped following'), - '$nick' => $a->user['nickname'], - '$verb' => 'http://ostatus.org/schema/1.0/unfollow', // ACTIVITY_UNFOLLOW, - '$ostat_follow' => '' // 'http://ostatus.org/schema/1.0/unfollow' . "\r\n" - )); - - if((x($orig_record[0],'notify')) && (strlen($orig_record[0]['notify']))) { - require_once('include/salmon.php'); - slapper($a->user,$orig_record[0]['notify'],$slap); - } - } - elseif($orig_record[0]['network'] === NETWORK_DIASPORA) { - require_once('include/diaspora.php'); - diaspora_unshare($a->user,$orig_record[0]); - } - elseif($orig_record[0]['network'] === NETWORK_DFRN) { - require_once('include/items.php'); - dfrn_deliver($a->user,$orig_record[0],'placeholder', 1); - } + require_once('include/Contact.php'); + + terminate_friendship($a->user,$a->contact,$orig_record[0]); contact_remove($orig_record[0]['id']); info( t('Contact has been removed.') . EOL ); -- cgit v1.2.3 From 2064d86cb39c20b738ba5f8ca35d4102216a5c30 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 23 Apr 2012 22:41:32 -0700 Subject: separate tag search from body search --- mod/item.php | 2 +- mod/search.php | 30 ++++++++++++++++++++++-------- mod/tagger.php | 8 ++++---- 3 files changed, 27 insertions(+), 13 deletions(-) (limited to 'mod') diff --git a/mod/item.php b/mod/item.php index 642a6758a..1436f7ffc 100644 --- a/mod/item.php +++ b/mod/item.php @@ -872,7 +872,7 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) { //base tag has the tags name only $basetag = str_replace('_',' ',substr($tag,1)); //create text for link - $newtag = '#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]'; + $newtag = '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]'; //replace tag by the link $body = str_replace($tag, $newtag, $body); diff --git a/mod/search.php b/mod/search.php index 4ca7db9bb..d467764b0 100644 --- a/mod/search.php +++ b/mod/search.php @@ -87,11 +87,26 @@ function search_content(&$a) { else $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : ''); + $tag = false; + if(x($_GET,'tag')) { + $tag = true; + $search = ((x($_GET,'tag')) ? notags(trim(rawurldecode($_GET['tag']))) : ''); + } + + $o .= search($search,'search-box','/search',((local_user()) ? true : false)); if(! $search) return $o; + if($tag) + $sql_extra = sprintf(" AND `item`.`tag` REGEXP '%s' ", dbesc('\\]' . preg_quote($search) . '\\[')); + else + $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(preg_quote($search))); + + + + // Here is the way permissions work in the search module... // Only public posts can be shown // OR your own posts if you are a logged in member @@ -103,10 +118,8 @@ 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 - AND ( `item`.`body` REGEXP '%s' OR `item`.`tag` REGEXP '%s' ) group by `item`.`uri` ", - intval(local_user()), - dbesc(preg_quote($search)), - dbesc('\\]' . preg_quote($search) . '\\[') + $sql_extra group by `item`.`uri` ", + intval(local_user()) ); if(count($r)) @@ -127,18 +140,19 @@ 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 - AND ( `item`.`body` REGEXP '%s' OR `item`.`tag` REGEXP '%s' ) + $sql_extra group by `item`.`uri` 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']) ); - $o .= '

Search results for: ' . $search . '

'; + if($tag) + $o .= '

Items tagged with: ' . $search . '

'; + else + $o .= '

Search results for: ' . $search . '

'; $o .= conversation($a,$r,'search',false); diff --git a/mod/tagger.php b/mod/tagger.php index 3ff5d57aa..8ee499f5f 100644 --- a/mod/tagger.php +++ b/mod/tagger.php @@ -86,7 +86,7 @@ function tagger_content(&$a) { EOT; - $tagid = $a->get_baseurl() . '/search?search=' . $term; + $tagid = $a->get_baseurl() . '/search?tag=' . $term; $objtype = ACTIVITY_OBJ_TAGTERM; $obj = <<< EOT @@ -105,7 +105,7 @@ EOT; if(! isset($bodyverb)) return; - $termlink = html_entity_decode('⌗') . '[url=' . $a->get_baseurl() . '/search?search=' . urlencode($term) . ']'. $term . '[/url]'; + $termlink = html_entity_decode('⌗') . '[url=' . $a->get_baseurl() . '/search?tag=' . urlencode($term) . ']'. $term . '[/url]'; $arr = array(); @@ -161,7 +161,7 @@ EOT; if((! $blocktags) && (! stristr($item['tag'], ']' . $term . '[' ))) { q("update item set tag = '%s' where id = %d limit 1", - dbesc($item['tag'] . (strlen($item['tag']) ? ',' : '') . '#[url=' . $a->get_baseurl() . '/search?search=' . $term . ']'. $term . '[/url]'), + dbesc($item['tag'] . (strlen($item['tag']) ? ',' : '') . '#[url=' . $a->get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'), intval($item['id']) ); } @@ -177,7 +177,7 @@ EOT; ); if(count($x) && !$x[0]['blocktags'] && (! stristr($r[0]['tag'], ']' . $term . '['))) { q("update item set tag = '%s' where id = %d limit 1", - dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . $a->get_baseurl() . '/search?search=' . $term . ']'. $term . '[/url]'), + dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . $a->get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'), intval($r[0]['id']) ); } -- cgit v1.2.3 From c9e5609cbfd89db35b536a22eb2ce6cbf7992783 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 25 Apr 2012 05:41:32 -0700 Subject: bug #307, explaining decentralised private photos is impossible. --- mod/message.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'mod') diff --git a/mod/message.php b/mod/message.php index 260f4bb14..dbca45930 100644 --- a/mod/message.php +++ b/mod/message.php @@ -313,6 +313,29 @@ function message_content(&$a) { $from_url = $a->get_baseurl(true) . '/redir/' . $message['contact-id']; $sparkle = ' sparkle'; } + + + $Text = $message['body']; + $saved_image = ''; + $img_start = strpos($Text,'[img]data:'); + $img_end = strpos($Text,'[/img]'); + + if($img_start !== false && $img_end !== false && $img_end > $img_start) { + $start_fragment = substr($Text,0,$img_start); + $img_start += strlen('[img]'); + $saved_image = substr($Text,$img_start,$img_end - $img_start); + $end_fragment = substr($Text,$img_end + strlen('[/img]')); + $Text = $start_fragment . '[!#saved_image#!]' . $end_fragment; + $search = '/\[url\=(.*?)\]\[!#saved_image#!\]\[\/url\]' . '/is'; + $replace = '[url=' . z_path() . '/redir/' . $message['contact-id'] + . '?f=1&url=' . '$1' . '][!#saved_image#!][/url]' ; + + $Text = preg_replace($search,$replace,$Text); + + if(strlen($saved_image)) + $message['body'] = str_replace('[!#saved_image#!]', '[img]' . $saved_image . '[/img]',$Text); + } + $mails[] = array( 'id' => $message['id'], 'from_name' => template_escape($message['from-name']), -- cgit v1.2.3 From 77a0570162aa00bc9695bd7c15636ae56337a0f5 Mon Sep 17 00:00:00 2001 From: tommy tomson Date: Thu, 26 Apr 2012 17:21:27 +0200 Subject: add link "remove account" to /mod/settings.php --- mod/settings.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'mod') diff --git a/mod/settings.php b/mod/settings.php index 8c8b3062d..3072d3d65 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -75,6 +75,11 @@ EOT; 'label' => t('Export personal data'), 'url' => $a->get_baseurl(true) . '/uexport', 'selected' => '' + ), + array( + 'label' => t('Remove account'), + 'url' => $a->get_baseurl(true) . '/removeme', + 'selected' => '' ) ); -- cgit v1.2.3 From ecc4962bd1455d4ded6570f6d08ccab7e838fe8b Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 27 Apr 2012 16:23:25 -0700 Subject: pass zrl to dfrn_request as fallback --- mod/dfrn_request.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'mod') diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 79583ea18..18798aa15 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -753,6 +753,11 @@ function dfrn_request_content(&$a) { $myaddr = ((x($_GET,'address')) ? $_GET['address'] : ''); } + // last, try a zrl + if(! strlen($myaddr)) + $myaddr = get_my_url(); + + $target_addr = $a->profile['nickname'] . '@' . substr(z_root(), strpos(z_root(),'://') + 3 ); -- cgit v1.2.3 From 26c53580d128d3ebbbc3d6172525b80690a63255 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 27 Apr 2012 17:17:58 -0700 Subject: implement contact archival --- mod/acl.php | 8 ++++---- mod/contacts.php | 43 ++++++++++++++++++++++++++++++++++++++----- mod/viewcontacts.php | 4 ++-- 3 files changed, 44 insertions(+), 11 deletions(-) (limited to 'mod') diff --git a/mod/acl.php b/mod/acl.php index c23ee1a67..88f150d7a 100644 --- a/mod/acl.php +++ b/mod/acl.php @@ -33,7 +33,7 @@ function acl_init(&$a){ if ($type=='' || $type=='c'){ $r = q("SELECT COUNT(`id`) AS c FROM `contact` WHERE `uid` = %d AND `self` = 0 - AND `blocked` = 0 AND `pending` = 0 + AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `notify` != '' $sql_extra2" , intval(local_user()) ); @@ -45,7 +45,7 @@ function acl_init(&$a){ $r = q("SELECT COUNT(`id`) AS c FROM `contact` WHERE `uid` = %d AND `self` = 0 - AND `blocked` = 0 AND `pending` = 0 + AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `network` IN ('%s','%s','%s') $sql_extra2" , intval(local_user()), dbesc(NETWORK_DFRN), @@ -94,7 +94,7 @@ function acl_init(&$a){ if ($type=='' || $type=='c'){ $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 `notify` != '' + WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `notify` != '' $sql_extra2 ORDER BY `name` ASC ", intval(local_user()) @@ -102,7 +102,7 @@ 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 + 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 ", diff --git a/mod/contacts.php b/mod/contacts.php index 8670c0c80..754350ae5 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -182,6 +182,22 @@ function contacts_content(&$a) { return; // NOTREACHED } + + if($cmd === 'archive') { + $archived = (($orig_record[0]['archive']) ? 0 : 1); + $r = q("UPDATE `contact` SET `archive` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($archived), + intval($contact_id), + intval(local_user()) + ); + if($r) { + //notice( t('Contact has been ') . (($archived) ? t('archived') : t('unarchived')) . EOL ); + info( (($archived) ? t('Contact has been archived') : t('Contact has been unarchived')) . EOL ); + } + goaway($a->get_baseurl(true) . '/contacts/' . $contact_id); + return; // NOTREACHED + } + if($cmd === 'drop') { require_once('include/Contact.php'); @@ -280,6 +296,12 @@ function contacts_content(&$a) { 'url' => $a->get_baseurl(true) . '/contacts/' . $contact_id . '/ignore', 'sel' => '', ), + + array( + 'label' => (($contact['archive']) ? t('Unarchive') : t('Archive') ), + 'url' => $a->get_baseurl(true) . '/contacts/' . $contact_id . '/archive', + 'sel' => '', + ), array( 'label' => t('Repair'), 'url' => $a->get_baseurl(true) . '/crepair/' . $contact_id, @@ -324,6 +346,7 @@ function contacts_content(&$a) { '$info' => $contact['info'], '$blocked' => (($contact['blocked']) ? t('Currently blocked') : ''), '$ignored' => (($contact['readonly']) ? t('Currently ignored') : ''), + '$archived' => (($contact['archive']) ? t('Currently archived') : ''), '$hidden' => array('hidden', t('Hide this contact from others'), ($contact['hidden'] == 1), t('Replies/likes to your public posts may still be visible')), '$photo' => $contact['photo'], '$name' => $contact['name'], @@ -365,6 +388,10 @@ function contacts_content(&$a) { $sql_extra = " AND `readonly` = 1 "; $ignored = true; } + elseif(($a->argc == 2) && ($a->argv[1] === 'archived')) { + $sql_extra = " AND `archive` = 1 "; + $archived = true; + } else $sql_extra = " AND `blocked` = 0 "; @@ -383,25 +410,31 @@ function contacts_content(&$a) { 'sel' => ($all) ? 'active' : '', ), array( - 'label' => t('Unblocked Contacts'), + 'label' => t('Unblocked'), 'url' => $a->get_baseurl(true) . '/contacts', - 'sel' => ((! $all) && (! $blocked) && (! $hidden) && (! $search) && (! $nets) && (! $ignored)) ? 'active' : '', + 'sel' => ((! $all) && (! $blocked) && (! $hidden) && (! $search) && (! $nets) && (! $ignored) && (! $archived)) ? 'active' : '', ), array( - 'label' => t('Blocked Contacts'), + 'label' => t('Blocked'), 'url' => $a->get_baseurl(true) . '/contacts/blocked', 'sel' => ($blocked) ? 'active' : '', ), array( - 'label' => t('Ignored Contacts'), + 'label' => t('Ignored'), 'url' => $a->get_baseurl(true) . '/contacts/ignored', 'sel' => ($ignored) ? 'active' : '', ), array( - 'label' => t('Hidden Contacts'), + 'label' => t('Archived'), + 'url' => $a->get_baseurl(true) . '/contacts/archived', + 'sel' => ($archived) ? 'active' : '', + ), + + array( + 'label' => t('Hidden'), 'url' => $a->get_baseurl(true) . '/contacts/hidden', 'sel' => ($hidden) ? 'active' : '', ), diff --git a/mod/viewcontacts.php b/mod/viewcontacts.php index e7d26b73e..8e261e711 100644 --- a/mod/viewcontacts.php +++ b/mod/viewcontacts.php @@ -24,13 +24,13 @@ function viewcontacts_content(&$a) { } - $r = q("SELECT COUNT(*) as `total` FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 ", + $r = q("SELECT COUNT(*) as `total` FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0 ", intval($a->profile['uid']) ); if(count($r)) $a->set_pager_total($r[0]['total']); - $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 ORDER BY `name` ASC LIMIT %d , %d ", + $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0 ORDER BY `name` ASC LIMIT %d , %d ", intval($a->profile['uid']), intval($a->pager['start']), intval($a->pager['itemspage']) -- cgit v1.2.3 From 39d0926d09b28a70ba70a66c0b29f9ea51a8f9a0 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 27 Apr 2012 19:39:19 -0700 Subject: PRIVACY: if wall is blocked, don't provide public keywords in HTML meta --- mod/profile.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/profile.php b/mod/profile.php index de1e27248..e9d4ca344 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -32,6 +32,8 @@ function profile_init(&$a) { profile_load($a,$which,$profile); + $userblock = (($a->profile['hidewall'] && (! local_user()) && (! remote_user())) ? true : false); + if((x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY)) { $a->page['htmlhead'] .= ''; } @@ -41,8 +43,8 @@ function profile_init(&$a) { $delegate = ((strstr($a->profile['openid'],'://')) ? $a->profile['openid'] : 'http://' . $a->profile['openid']); $a->page['htmlhead'] .= '' . "\r\n"; } - - if(! $blocked) { + // site block + if((! $blocked) && (! $userblock)) { $keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : ''); $keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$keywords); if(strlen($keywords)) -- cgit v1.2.3 From f163aed66d2aec038131131c68110043de36137a Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 27 Apr 2012 23:17:40 -0700 Subject: break up poller into separate processes --- mod/admin.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/admin.php b/mod/admin.php index cdc45c8e3..3b6d186d5 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -235,6 +235,7 @@ function admin_page_site_post(&$a){ $proxyuser = ((x($_POST,'proxyuser')) ? notags(trim($_POST['proxyuser'])) : ''); $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); $dfrn_only = ((x($_POST,'dfrn_only')) ? True : False); $ostatus_disabled = !((x($_POST,'ostatus_disabled')) ? True : False); $diaspora_enabled = ((x($_POST,'diaspora_enabled')) ? True : False); @@ -281,7 +282,7 @@ function admin_page_site_post(&$a){ } } set_config('system','ssl_policy',$ssl_policy); - + set_config('system','delivery_interval',$delivery_interval); set_config('config','sitename',$sitename); if ($banner==""){ // don't know why, but del_config doesn't work... @@ -425,6 +426,7 @@ function admin_page_site(&$a) { '$proxyuser' => array('proxyuser', t("Proxy user"), get_config('system','proxyuser'), ""), '$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.")), '$form_security_token' => get_form_security_token("admin_site"), -- cgit v1.2.3 From a9dba2720bc0a5ffd9472f3233cf0ea3034019c4 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 29 Apr 2012 01:42:48 -0700 Subject: enhanced profile reporting for single values --- mod/profiles.php | 66 +++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 51 insertions(+), 15 deletions(-) (limited to 'mod') diff --git a/mod/profiles.php b/mod/profiles.php index 7a33a03e4..478aab8a5 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -139,21 +139,49 @@ function profiles_post(&$a) { $changes = array(); + $value = ''; if($is_default) { - if($marital != $orig[0]['marital']) $changes[] = '♥ ' . t('Marital Status'); - if($withchanged) $changes[] = '♥ ' . t('Romantic Partner'); - if($work != $orig[0]['work']) $changes[] = t('Work/Employment'); - if($religion != $orig[0]['religion']) $changes[] = t('Religion'); - if($politic != $orig[0]['politic']) $changes[] = t('Political Views'); - if($gender != $orig[0]['gender']) $changes[] = t('Gender'); - if($sexual != $orig[0]['sexual']) $changes[] = t('Sexual Preference'); - if($homepage != $orig[0]['homepage']) $changes[] = t('Homepage'); - if($interest != $orig[0]['interest']) $changes[] = t('Interests'); + if($marital != $orig[0]['marital']) { + $changes[] = '♥ ' . t('Marital Status'); + $value = $marital; + } + if($withchanged) { + $changes[] = '♥ ' . t('Romantic Partner'); + $value = strip_tags($with); + } + if($work != $orig[0]['work']) { + $changes[] = t('Work/Employment'); + } + if($religion != $orig[0]['religion']) { + $changes[] = t('Religion'); + $value = $religion; + } + if($politic != $orig[0]['politic']) { + $changes[] = t('Political Views'); + $value = $politic; + } + if($gender != $orig[0]['gender']) { + $changes[] = t('Gender'); + $value = $gender; + } + if($sexual != $orig[0]['sexual']) { + $changes[] = t('Sexual Preference'); + $value = $sexual; + } + if($homepage != $orig[0]['homepage']) { + $changes[] = t('Homepage'); + $value = $homepage; + } + if($interest != $orig[0]['interest']) { + $changes[] = t('Interests'); + $value = $interest; + } if($address != $orig[0]['address'] || $locality != $orig[0]['locality'] || $region != $orig[0]['region'] - || $country_name != $orig[0]['country_name']) - $changes[] = t('Location'); + || $country_name != $orig[0]['country_name']) { + $changes[] = t('Location'); + } - profile_activity($changes); + profile_activity($changes,$value); } @@ -245,7 +273,7 @@ function profiles_post(&$a) { } -function profile_activity($changed) { +function profile_activity($changed, $value) { $a = get_app(); if(! local_user() || ! is_array($changed) || ! count($changed)) @@ -289,7 +317,7 @@ function profile_activity($changed) { foreach($changed as $ch) { if(strlen($changes)) { if ($z == ($t - 1)) - $changes .= ' and '; + $changes .= t(' and '); else $changes .= ', '; } @@ -299,7 +327,15 @@ function profile_activity($changed) { $prof = '[url=' . $self[0]['url'] . '?tab=profile' . ']' . t('public profile') . '[/url]'; - $arr['body'] = sprintf( t('%1$s has an updated %2$s, changing %3$s.'), $A, $prof, $changes); + if($t == 1 && strlen($value)) { + $message = sprintf( t('%1$s changed %2$s to %3$s'), $A, $changes, $value); + $message .= "\n\n" . sprintf( t(' - Visit %1$s\'s %2$s'), $A, $prof); + } + else + $message = sprintf( t('%1$s has an updated %2$s, changing %3$s.'), $A, $prof, $changes); + + + $arr['body'] = $message; $arr['object'] = '' . ACTIVITY_OBJ_PROFILE . '' . $self[0]['name'] . '' . '' . $self[0]['url'] . '/' . $self[0]['name'] . ''; -- cgit v1.2.3 From 735f518fd8547fab37ca39c7717e8d89e07e3337 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 29 Apr 2012 01:49:54 -0700 Subject: fix location change notification --- mod/profiles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/profiles.php b/mod/profiles.php index 478aab8a5..d640ba1ba 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -177,7 +177,7 @@ function profiles_post(&$a) { $value = $interest; } if($address != $orig[0]['address'] || $locality != $orig[0]['locality'] || $region != $orig[0]['region'] - || $country_name != $orig[0]['country_name']) { + || $country_name != $orig[0]['country-name']) { $changes[] = t('Location'); } -- cgit v1.2.3 From def6f0b408680c4e5f209890bbf1ad6bf40b5add Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 29 Apr 2012 02:11:33 -0700 Subject: the heart should really be red. --- mod/profiles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/profiles.php b/mod/profiles.php index d640ba1ba..3a52c8fa5 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -142,7 +142,7 @@ function profiles_post(&$a) { $value = ''; if($is_default) { if($marital != $orig[0]['marital']) { - $changes[] = '♥ ' . t('Marital Status'); + $changes[] = '[color=#ff0000]♥[/color] ' . t('Marital Status'); $value = $marital; } if($withchanged) { -- cgit v1.2.3 From 0153d86b7f4e2913b1eb985a905f7eb94822b589 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 29 Apr 2012 19:10:07 -0700 Subject: admin page to manage failed updates --- mod/admin.php | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) (limited to 'mod') diff --git a/mod/admin.php b/mod/admin.php index 3b6d186d5..b07ef851a 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -61,6 +61,9 @@ function admin_post(&$a){ case 'logs': admin_page_logs_post($a); break; + case 'dbsync': + admin_page_dbsync_post($a); + break; case 'update': admin_page_remoteupdate_post($a); break; @@ -94,7 +97,8 @@ function admin_content(&$a) { 'users' => Array($a->get_baseurl(true)."/admin/users/", t("Users") , "users"), 'plugins'=> Array($a->get_baseurl(true)."/admin/plugins/", t("Plugins") , "plugins"), 'themes' => Array($a->get_baseurl(true)."/admin/themes/", t("Themes") , "themes"), - 'update' => Array($a->get_baseurl(true)."/admin/update/", t("Update") , "update") + 'dbsync' => Array($a->get_baseurl(true)."/admin/dbsync/", t('DB updates'), "dbsync"), + 'update' => Array($a->get_baseurl(true)."/admin/update/", t("Software Update") , "update") ); /* get plugins admin page */ @@ -142,6 +146,9 @@ function admin_content(&$a) { case 'logs': $o = admin_page_logs($a); break; + case 'dbsync': + $o = admin_page_dbsync($a); + break; case 'update': $o = admin_page_remoteupdate($a); break; @@ -435,6 +442,62 @@ function admin_page_site(&$a) { } +function admin_page_dbsync(&$a) { + + $o = ''; + + if($a->argc > 3 && intval($a->argv[3]) && $a->argv[2] === 'mark') { + set_config('database', 'update_' . intval($a->argv[3]), 'success'); + info( t('Update has been marked successful') . EOL); + goaway($a->get_baseurl(true) . '/admin/dbsync'); + } + + if($a->argc > 2 && intval($a->argv[2])) { + require_once('update.php'); + $func = 'update_' . intval($a->argv[2]); + if(function_exists($func)) { + $retval = $func(); + if($retval === UPDATE_FAILED) { + $o .= sprintf( t('Executing %s failed. Check system logs.'), $func); + } + elseif($retval === UPDATE_SUCCESS) { + $o .= sprintf( t('Update %s was successfully applied.', $func)); + set_config('database',$func, 'success'); + } + else + $o .= sprintf( t('Update %s did not return a status. Unknown if it succeeded.'), $func); + } + else + $o .= sprintf( t('Update function %s could not be found.'), $func); + return $o; + } + + $failed = array(); + $r = q("select * from config where `cat` = 'database' "); + if(count($r)) { + foreach($r as $rr) { + $upd = intval(substr($rr['k'],7)); + if($upd < 1139 || $rr['v'] === 'success') + continue; + $failed[] = $upd; + } + } + if(! count($failed)) + return '

' . t('No failed updates.') . '

'; + + $o = replace_macros(get_markup_template('failed_updates.tpl'),array( + '$base' => $a->get_baseurl(true), + '$banner' => t('Failed Updates'), + '$desc' => t('This does not include updates prior to 1139, which did not return a status.'), + '$mark' => t('Mark success (if update was manually applied)'), + '$apply' => t('Attempt to execute this update step automatically'), + '$failed' => $failed + )); + + return $o; + +} + /** * Users admin page * @@ -979,7 +1042,6 @@ readable."); $size = 5000000; $seek = fseek($fp,0-$size,SEEK_END); if($seek === 0) { - fgets($fp); // throw away the first partial line $data = escape_tags(fread($fp,$size)); while(! feof($fp)) $data .= escape_tags(fread($fp,4096)); -- cgit v1.2.3 From 928faf3b9712e88e030b2ccbbc630e3991e03d03 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 29 Apr 2012 22:34:05 -0700 Subject: typo in profile_selectors, fix remote tagging --- mod/tagger.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'mod') diff --git a/mod/tagger.php b/mod/tagger.php index 8ee499f5f..6212e2b9b 100644 --- a/mod/tagger.php +++ b/mod/tagger.php @@ -66,14 +66,14 @@ function tagger_content(&$a) { } $uri = item_new_uri($a->get_hostname(),$owner_uid); - + $xterm = xmlify($term); $post_type = (($item['resource-id']) ? t('photo') : t('status')); $targettype = (($item['resource-id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE ); $link = xmlify('' . "\n") ; - $body = $item['body']; + $body = xmlify($item['body']); $target = <<< EOT @@ -95,8 +95,8 @@ EOT; 1 $tagid $tagid - $term - $term + $xterm + $xterm
EOT; -- cgit v1.2.3 From 3ff8fe53a23778f1894bfb166c80c75c6e411c09 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 30 Apr 2012 01:25:25 -0700 Subject: provide "xxx joined yyy" notifications --- mod/dfrn_confirm.php | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) (limited to 'mod') diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index efb5be3a4..6f7b925ac 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -434,9 +434,14 @@ function dfrn_confirm_post(&$a,$handsfree = null) { else $contact = null; - if(isset($new_relation) && $new_relation == CONTACT_IS_FRIEND) { - if(($contact) && ($contact['network'] === NETWORK_DIASPORA)) { + $forum_type = false; + if($user['page-flags'] == PAGE_SOAPBOX || $user['page-flags'] == PAGE_COMMUNITY) + $forum_type = true; + + if((isset($new_relation) && $new_relation == CONTACT_IS_FRIEND) || ($forum_type)) { + + if(($contact) && ($contact['network'] === NETWORK_DIASPORA) && (! $forum_type)) { require_once('include/diaspora.php'); $ret = diaspora_share($user[0],$r[0]); logger('mod_follow: diaspora_share returns: ' . $ret); @@ -468,19 +473,37 @@ function dfrn_confirm_post(&$a,$handsfree = null) { $arr['author-name'] = $arr['owner-name'] = $self[0]['name']; $arr['author-link'] = $arr['owner-link'] = $self[0]['url']; $arr['author-avatar'] = $arr['owner-avatar'] = $self[0]['thumb']; - $arr['verb'] = ACTIVITY_FRIEND; - $arr['object-type'] = ACTIVITY_OBJ_PERSON; - + $A = '[url=' . $self[0]['url'] . ']' . $self[0]['name'] . '[/url]'; + $APhoto = '[url=' . $self[0]['url'] . ']' . '[img]' . $self[0]['thumb'] . '[/img][/url]'; + $B = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]'; $BPhoto = '[url=' . $contact['url'] . ']' . '[img]' . $contact['thumb'] . '[/img][/url]'; - $arr['body'] = sprintf( t('%1$s is now friends with %2$s'), $A, $B)."\n\n\n".$BPhoto; - $arr['object'] = '' . ACTIVITY_OBJ_PERSON . '' . $contact['name'] . '' - . '' . $contact['url'] . '/' . $contact['name'] . ''; - $arr['object'] .= '' . xmlify('' . "\n"); - $arr['object'] .= xmlify('' . "\n"); - $arr['object'] .= '' . "\n"; + if($forum_type) { + $arr['verb'] = ACTIVITY_JOIN; + $arr['object-type'] = ACTIVITY_OBJ_GROUP; + $arr['body'] = sprintf( t('%1$s joined %2$s'), $B, $A)."\n\n\n".$APhoto; + $arr['object'] = '' . ACTIVITY_OBJ_GROUP . '' . $self[0]['name'] . '' + . '' . $self[0]['url'] . '/' . $self[0]['name'] . ''; + $arr['object'] .= '' . xmlify('' . "\n"); + $arr['object'] .= xmlify('' . "\n"); + $arr['object'] .= '' . "\n"; + + } + else { + $arr['verb'] = ACTIVITY_FRIEND; + $arr['object-type'] = ACTIVITY_OBJ_PERSON; + $arr['body'] = sprintf( t('%1$s is now friends with %2$s'), $A, $B)."\n\n\n".$BPhoto; + + $arr['object'] = '' . ACTIVITY_OBJ_PERSON . '' . $contact['name'] . '' + . '' . $contact['url'] . '/' . $contact['name'] . ''; + $arr['object'] .= '' . xmlify('' . "\n"); + $arr['object'] .= xmlify('' . "\n"); + $arr['object'] .= '' . "\n"; + } + + $arr['last-child'] = 1; $arr['allow_cid'] = $user[0]['allow_cid']; -- cgit v1.2.3 From 5d10672fb84e467a09c31cc06a21cc10d4082a48 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 30 Apr 2012 04:11:42 -0700 Subject: fix join group notifications --- mod/dfrn_confirm.php | 9 +++++---- mod/dfrn_request.php | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'mod') diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index 6f7b925ac..f27c29daf 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -207,7 +207,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) { if($duplex == 1) $params['duplex'] = 1; - if($user['page-flags'] == PAGE_COMMUNITY) + if($user[0]['page-flags'] == PAGE_COMMUNITY) $params['page'] = 1; logger('dfrn_confirm: Confirm: posting data to ' . $dfrn_confirm . ': ' . print_r($params,true), LOGGER_DATA); @@ -436,7 +436,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) { $forum_type = false; - if($user['page-flags'] == PAGE_SOAPBOX || $user['page-flags'] == PAGE_COMMUNITY) + if($user[0]['page-flags'] == PAGE_SOAPBOX || $user[0]['page-flags'] == PAGE_COMMUNITY) $forum_type = true; if((isset($new_relation) && $new_relation == CONTACT_IS_FRIEND) || ($forum_type)) { @@ -452,6 +452,8 @@ function dfrn_confirm_post(&$a,$handsfree = null) { $r = q("SELECT `hide-friends` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1", intval($uid) ); + + if((count($r)) && ($activity) && (! $hidden)) { require_once('include/items.php'); @@ -483,13 +485,12 @@ function dfrn_confirm_post(&$a,$handsfree = null) { if($forum_type) { $arr['verb'] = ACTIVITY_JOIN; $arr['object-type'] = ACTIVITY_OBJ_GROUP; - $arr['body'] = sprintf( t('%1$s joined %2$s'), $B, $A)."\n\n\n".$APhoto; + $arr['body'] = sprintf( t('%1$s welcomes new member %2$s'), $A, $B)."\n\n\n" .$BPhoto; $arr['object'] = '' . ACTIVITY_OBJ_GROUP . '' . $self[0]['name'] . '' . '' . $self[0]['url'] . '/' . $self[0]['name'] . ''; $arr['object'] .= '' . xmlify('' . "\n"); $arr['object'] .= xmlify('' . "\n"); $arr['object'] .= '' . "\n"; - } else { $arr['verb'] = ACTIVITY_FRIEND; diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 18798aa15..2169c494c 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -700,7 +700,8 @@ function dfrn_request_content(&$a) { 'node' => $r[0]['nickname'], 'dfrn_id' => $r[0]['issued-id'], 'intro_id' => $intro[0]['id'], - 'duplex' => (($r[0]['page-flags'] == PAGE_FREELOVE) ? 1 : 0) + 'duplex' => (($r[0]['page-flags'] == PAGE_FREELOVE) ? 1 : 0), + 'activity' => intval(get_pconfig($r[0]['uid'],'system','post_newfriend')) ); dfrn_confirm_post($a,$handsfree); } -- cgit v1.2.3 From 05df5337dd19827b1b6482e4d38db90a614101a3 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 30 Apr 2012 05:15:29 -0700 Subject: start adding tooltips to tab menus --- mod/contacts.php | 11 +++++++++++ mod/network.php | 7 +++++++ 2 files changed, 18 insertions(+) (limited to 'mod') diff --git a/mod/contacts.php b/mod/contacts.php index 754350ae5..3b428914c 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -290,22 +290,26 @@ function contacts_content(&$a) { 'label' => (($contact['blocked']) ? t('Unblock') : t('Block') ), 'url' => $a->get_baseurl(true) . '/contacts/' . $contact_id . '/block', 'sel' => '', + 'title' => t('Toggle Blocked status'), ), array( 'label' => (($contact['readonly']) ? t('Unignore') : t('Ignore') ), 'url' => $a->get_baseurl(true) . '/contacts/' . $contact_id . '/ignore', 'sel' => '', + 'title' => t('Toggle Ignored status'), ), array( 'label' => (($contact['archive']) ? t('Unarchive') : t('Archive') ), 'url' => $a->get_baseurl(true) . '/contacts/' . $contact_id . '/archive', 'sel' => '', + 'title' => t('Toggle Archive status'), ), array( 'label' => t('Repair'), 'url' => $a->get_baseurl(true) . '/crepair/' . $contact_id, 'sel' => '', + 'title' => t('Advanced Contact Settings'), ) ); $tab_tpl = get_markup_template('common_tabs.tpl'); @@ -403,40 +407,47 @@ function contacts_content(&$a) { 'label' => t('Suggestions'), 'url' => $a->get_baseurl(true) . '/suggest', 'sel' => '', + 'title' => t('Suggest potential friends'), ), array( 'label' => t('All Contacts'), 'url' => $a->get_baseurl(true) . '/contacts/all', 'sel' => ($all) ? 'active' : '', + 'title' => t('Show all contacts'), ), array( 'label' => t('Unblocked'), 'url' => $a->get_baseurl(true) . '/contacts', 'sel' => ((! $all) && (! $blocked) && (! $hidden) && (! $search) && (! $nets) && (! $ignored) && (! $archived)) ? 'active' : '', + 'title' => t('Only show unblocked contacts'), ), array( 'label' => t('Blocked'), 'url' => $a->get_baseurl(true) . '/contacts/blocked', 'sel' => ($blocked) ? 'active' : '', + 'title' => t('Only show blocked contacts'), ), array( 'label' => t('Ignored'), 'url' => $a->get_baseurl(true) . '/contacts/ignored', 'sel' => ($ignored) ? 'active' : '', + 'title' => t('Only show ignored contacts'), ), array( 'label' => t('Archived'), 'url' => $a->get_baseurl(true) . '/contacts/archived', 'sel' => ($archived) ? 'active' : '', + 'title' => t('Only show archived contacts'), ), array( 'label' => t('Hidden'), 'url' => $a->get_baseurl(true) . '/contacts/hidden', 'sel' => ($hidden) ? 'active' : '', + 'title' => t('Only show hidden contacts'), ), ); diff --git a/mod/network.php b/mod/network.php index b12bd16da..5655f1bfa 100644 --- a/mod/network.php +++ b/mod/network.php @@ -171,37 +171,44 @@ function network_content(&$a, $update = 0) { 'label' => t('Commented Order'), 'url'=>$a->get_baseurl(true) . '/' . str_replace('/new', '', $a->cmd) . ((x($_GET,'cid')) ? '?f=&cid=' . $_GET['cid'] : ''), 'sel'=>$all_active, + 'title'=> t('Sort by Comment Date'), ), array( 'label' => t('Posted Order'), 'url'=>$a->get_baseurl(true) . '/' . str_replace('/new', '', $a->cmd) . '?f=&order=post' . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : ''), 'sel'=>$postord_active, + 'title' => t('Sort by Post Date'), ), array( 'label' => t('Personal'), 'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $a->cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&conv=1', 'sel' => $conv_active, + 'title' => t('Posts that mention or involve you'), ), array( 'label' => t('New'), 'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $a->cmd) . '/new' . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : ''), 'sel' => $new_active, + 'title' => t('Activity Stream - by date'), ), array( 'label' => t('Starred'), 'url'=>$a->get_baseurl(true) . '/' . str_replace('/new', '', $a->cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&star=1', 'sel'=>$starred_active, + 'title' => t('Favourite Posts'), ), array( 'label' => t('Shared Links'), 'url'=>$a->get_baseurl(true) . '/' . str_replace('/new', '', $a->cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '') . '&bmark=1', 'sel'=>$bookmarked_active, + 'title'=> t('Interesting Links'), ), // array( // 'label' => t('Spam'), // 'url'=>$a->get_baseurl(true) . '/network?f=&spam=1' // 'sel'=> $spam_active, +// 'title' => t('Posts flagged as SPAM'), // ), -- cgit v1.2.3 From 3c0cf727161d824dd166d3c9cd8bc42248780590 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 30 Apr 2012 19:01:41 -0700 Subject: make 'aaa joined group bbb' work from the initiating end, new privacy pref to control it also hidewall wasn't properly checked before sending 'xxx is friends with yyy' messages --- mod/dfrn_confirm.php | 103 ++++++++++++++++++++++++++++++++++++--------------- mod/settings.php | 6 +++ 2 files changed, 80 insertions(+), 29 deletions(-) (limited to 'mod') diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index f27c29daf..2b25095fd 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -435,13 +435,9 @@ function dfrn_confirm_post(&$a,$handsfree = null) { $contact = null; - $forum_type = false; - if($user[0]['page-flags'] == PAGE_SOAPBOX || $user[0]['page-flags'] == PAGE_COMMUNITY) - $forum_type = true; + if((isset($new_relation) && $new_relation == CONTACT_IS_FRIEND)) { - if((isset($new_relation) && $new_relation == CONTACT_IS_FRIEND) || ($forum_type)) { - - if(($contact) && ($contact['network'] === NETWORK_DIASPORA) && (! $forum_type)) { + if(($contact) && ($contact['network'] === NETWORK_DIASPORA)) { require_once('include/diaspora.php'); $ret = diaspora_share($user[0],$r[0]); logger('mod_follow: diaspora_share returns: ' . $ret); @@ -453,8 +449,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) { intval($uid) ); - - if((count($r)) && ($activity) && (! $hidden)) { + if((count($r)) && ($r[0]['hide-friends'] == 0) && ($activity) && (! $hidden)) { require_once('include/items.php'); @@ -482,28 +477,15 @@ function dfrn_confirm_post(&$a,$handsfree = null) { $B = '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]'; $BPhoto = '[url=' . $contact['url'] . ']' . '[img]' . $contact['thumb'] . '[/img][/url]'; - if($forum_type) { - $arr['verb'] = ACTIVITY_JOIN; - $arr['object-type'] = ACTIVITY_OBJ_GROUP; - $arr['body'] = sprintf( t('%1$s welcomes new member %2$s'), $A, $B)."\n\n\n" .$BPhoto; - $arr['object'] = '' . ACTIVITY_OBJ_GROUP . '' . $self[0]['name'] . '' - . '' . $self[0]['url'] . '/' . $self[0]['name'] . ''; - $arr['object'] .= '' . xmlify('' . "\n"); - $arr['object'] .= xmlify('' . "\n"); - $arr['object'] .= '' . "\n"; - } - else { - $arr['verb'] = ACTIVITY_FRIEND; - $arr['object-type'] = ACTIVITY_OBJ_PERSON; - $arr['body'] = sprintf( t('%1$s is now friends with %2$s'), $A, $B)."\n\n\n".$BPhoto; - - $arr['object'] = '' . ACTIVITY_OBJ_PERSON . '' . $contact['name'] . '' - . '' . $contact['url'] . '/' . $contact['name'] . ''; - $arr['object'] .= '' . xmlify('' . "\n"); - $arr['object'] .= xmlify('' . "\n"); - $arr['object'] .= '' . "\n"; - } + $arr['verb'] = ACTIVITY_FRIEND; + $arr['object-type'] = ACTIVITY_OBJ_PERSON; + $arr['body'] = sprintf( t('%1$s is now friends with %2$s'), $A, $B)."\n\n\n".$BPhoto; + $arr['object'] = '' . ACTIVITY_OBJ_PERSON . '' . $contact['name'] . '' + . '' . $contact['url'] . '/' . $contact['name'] . ''; + $arr['object'] .= '' . xmlify('' . "\n"); + $arr['object'] .= xmlify('' . "\n"); + $arr['object'] .= '' . "\n"; $arr['last-child'] = 1; @@ -734,6 +716,10 @@ function dfrn_confirm_post(&$a,$handsfree = null) { WHERE `contact`.`id` = %d LIMIT 1", intval($dfrn_record) ); + + if(count($r)) + $combined = $r[0]; + if((count($r)) && ($r[0]['notify-flags'] & NOTIFY_CONFIRM)) { push_lang($r[0]['language']); @@ -762,6 +748,65 @@ function dfrn_confirm_post(&$a,$handsfree = null) { } pop_lang(); } + + // Send a new friend post if we are allowed to... + + if($page && intval(get_pconfig($local_uid,'system','post_joingroup'))) { + $r = q("SELECT `hide-friends` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1", + intval($local_uid) + ); + + if((count($r)) && ($r[0]['hide-friends'] == 0)) { + + require_once('include/items.php'); + + $self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1", + intval($local_uid) + ); + + if(count($self)) { + + $arr = array(); + $arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), $local_uid); + $arr['uid'] = $local_uid; + $arr['contact-id'] = $self[0]['id']; + $arr['wall'] = 1; + $arr['type'] = 'wall'; + $arr['gravity'] = 0; + $arr['origin'] = 1; + $arr['author-name'] = $arr['owner-name'] = $self[0]['name']; + $arr['author-link'] = $arr['owner-link'] = $self[0]['url']; + $arr['author-avatar'] = $arr['owner-avatar'] = $self[0]['thumb']; + + $A = '[url=' . $self[0]['url'] . ']' . $self[0]['name'] . '[/url]'; + $APhoto = '[url=' . $self[0]['url'] . ']' . '[img]' . $self[0]['thumb'] . '[/img][/url]'; + + $B = '[url=' . $combined['url'] . ']' . $combined['name'] . '[/url]'; + $BPhoto = '[url=' . $combined['url'] . ']' . '[img]' . $combined['thumb'] . '[/img][/url]'; + + $arr['verb'] = ACTIVITY_JOIN; + $arr['object-type'] = ACTIVITY_OBJ_GROUP; + $arr['body'] = sprintf( t('%1$s has joined %2$s'), $A, $B)."\n\n\n" .$BPhoto; + $arr['object'] = '' . ACTIVITY_OBJ_GROUP . '' . $combined['name'] . '' + . '' . $combined['url'] . '/' . $combined['name'] . ''; + $arr['object'] .= '' . xmlify('' . "\n"); + $arr['object'] .= xmlify('' . "\n"); + $arr['object'] .= '' . "\n"; + + $arr['last-child'] = 1; + + $arr['allow_cid'] = $user[0]['allow_cid']; + $arr['allow_gid'] = $user[0]['allow_gid']; + $arr['deny_cid'] = $user[0]['deny_cid']; + $arr['deny_gid'] = $user[0]['deny_gid']; + + $i = item_store($arr); + if($i) + proc_run('php',"include/notifier.php","activity","$i"); + + } + } + } xml_status(0); // Success return; // NOTREACHED diff --git a/mod/settings.php b/mod/settings.php index 3072d3d65..5f5b2ab2e 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -352,6 +352,7 @@ function settings_post(&$a) { $hide_friends = (($_POST['hide-friends'] == 1) ? 1: 0); $hidewall = (($_POST['hidewall'] == 1) ? 1: 0); $post_newfriend = (($_POST['post_newfriend'] == 1) ? 1: 0); + $post_joingroup = (($_POST['post_joingroup'] == 1) ? 1: 0); $post_profilechange = (($_POST['post_profilechange'] == 1) ? 1: 0); @@ -436,6 +437,7 @@ function settings_post(&$a) { set_pconfig(local_user(),'system','suggestme', $suggestme); set_pconfig(local_user(),'system','post_newfriend', $post_newfriend); + set_pconfig(local_user(),'system','post_joingroup', $post_joingroup); set_pconfig(local_user(),'system','post_profilechange', $post_profilechange); @@ -802,6 +804,9 @@ function settings_content(&$a) { $post_newfriend = get_pconfig(local_user(), 'system','post_newfriend'); $post_newfriend = (($post_newfriend===false)? '0': $post_newfriend); // default if not set: 0 + $post_joingroup = get_pconfig(local_user(), 'system','post_joingroup'); + $post_joingroup = (($post_joingroup===false)? '0': $post_joingroup); // default if not set: 0 + $post_profilechange = get_pconfig(local_user(), 'system','post_profilechange'); $post_profilechange = (($post_profilechange===false)? '0': $post_profilechange); // default if not set: 0 @@ -976,6 +981,7 @@ function settings_content(&$a) { '$h_not' => t('Notification Settings'), '$activity_options' => t('By default post a status message when:'), '$post_newfriend' => array('post_newfriend', t('accepting a friend request'), $post_newfriend, ''), + '$post_joingroup' => array('post_joingroup', t('joining a forum/community'), $post_joingroup, ''), '$post_profilechange' => array('post_profilechange', t('making an interesting profile change'), $post_profilechange, ''), '$lbl_not' => t('Send a notification email when:'), '$notify1' => array('notify1', t('You receive an introduction'), ($notify & NOTIFY_INTRO), NOTIFY_INTRO, ''), -- cgit v1.2.3 From d48cd0f9a3210c14bb98a502188358982261d9df Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 30 Apr 2012 23:07:52 -0700 Subject: hidden plugins (add .hidden file to dir) --- mod/friendica.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/friendica.php b/mod/friendica.php index 52a064224..28807b5b5 100644 --- a/mod/friendica.php +++ b/mod/friendica.php @@ -18,10 +18,18 @@ function friendica_init(&$a) { $admin = false; } + $visible_plugins = array(); + if(is_array($a->plugins) && count($a->plugins)) { + $r = q("select * from addon where hidden = 0"); + if(count($r)) + foreach($r as $rr) + $visible_plugins[] = $rr['name']; + } + $data = Array( 'version' => FRIENDICA_VERSION, 'url' => z_root(), - 'plugins' => $a->plugins, + 'plugins' => $visible_plugins, 'register_policy' => $register_policy[$a->config['register_policy']], 'admin' => $admin, 'site_name' => $a->config['sitename'], @@ -54,9 +62,18 @@ function friendica_content(&$a) { $o .= '

'; - if(count($a->plugins)) { + $visible_plugins = array(); + if(is_array($a->plugins) && count($a->plugins)) { + $r = q("select * from addon where hidden = 0"); + if(count($r)) + foreach($r as $rr) + $visible_plugins[] = $rr['name']; + } + + + if(count($visible_plugins)) { $o .= '

' . t('Installed plugins/addons/apps:') . '

'; - $sorted = $a->plugins; + $sorted = $visible_plugins; $s = ''; sort($sorted); foreach($sorted as $p) { -- cgit v1.2.3 From 8bd6e1aef9bcace19e4517b4f53c976d4c0a2760 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 1 May 2012 19:16:18 -0700 Subject: first try common friends for visitors --- mod/profile.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'mod') diff --git a/mod/profile.php b/mod/profile.php index e9d4ca344..41c5eed4b 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -143,6 +143,10 @@ function profile_content(&$a, $update = 0) { return $o; } + + $o .= common_friends_vistor_widget($a->profile['profile_uid']); + + if(x($_SESSION,'new_member') && $_SESSION['new_member'] && $is_owner) $o .= '' . t('Tips for New Members') . '' . EOL; -- cgit v1.2.3 From 91085f0969afbdca93c79d9be3d8fa815e9dfa27 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 1 May 2012 19:24:22 -0700 Subject: really fat fingers today - though none of this has gone further than my own site --- mod/profile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/profile.php b/mod/profile.php index 41c5eed4b..69f044e89 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -144,7 +144,7 @@ function profile_content(&$a, $update = 0) { } - $o .= common_friends_vistor_widget($a->profile['profile_uid']); + $o .= common_friends_visitor_widget($a->profile['profile_uid']); if(x($_SESSION,'new_member') && $_SESSION['new_member'] && $is_owner) -- cgit v1.2.3 From 06d6ab481280d786c40b0741ebd0b787addee40d Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 2 May 2012 01:07:23 -0700 Subject: delineate the new profile changes from the rest of the text --- mod/profiles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/profiles.php b/mod/profiles.php index 3a52c8fa5..4de9057dc 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -328,7 +328,7 @@ function profile_activity($changed, $value) { $prof = '[url=' . $self[0]['url'] . '?tab=profile' . ']' . t('public profile') . '[/url]'; if($t == 1 && strlen($value)) { - $message = sprintf( t('%1$s changed %2$s to %3$s'), $A, $changes, $value); + $message = sprintf( t('%1$s changed %2$s to "%3$s"'), $A, $changes, $value); $message .= "\n\n" . sprintf( t(' - Visit %1$s\'s %2$s'), $A, $prof); } else -- cgit v1.2.3 From 5d957c3803936b8be54b5e197246d670fdcfa223 Mon Sep 17 00:00:00 2001 From: Zach Prezkuta Date: Wed, 2 May 2012 21:12:57 -0600 Subject: Modify events_post() in mod/events.php to set the `private` field to true when an event is shared with specific people. This is necessary to have event posts show correctly in Diaspora if an event is created visible only to self, but modified later to be visible to others. --- mod/events.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'mod') diff --git a/mod/events.php b/mod/events.php index e66a2dc44..1f11e7503 100644 --- a/mod/events.php +++ b/mod/events.php @@ -28,6 +28,9 @@ function events_post(&$a) { $adjust = intval($_POST['adjust']); $nofinish = intval($_POST['nofinish']); + // The default setting for the `private` field in event_store() is false, so mirror that + $private_event = false; + $start = sprintf('%d-%d-%d %d:%d:0',$startyear,$startmonth,$startday,$starthour,$startminute); if($nofinish) @@ -70,8 +73,23 @@ function events_post(&$a) { $str_contact_allow = perms2str($_POST['contact_allow']); $str_group_deny = perms2str($_POST['group_deny']); $str_contact_deny = perms2str($_POST['contact_deny']); + + // Undo the pseudo-contact of self, since there are real contacts now + if( strpos($str_contact_allow, '<' . local_user() . '>') !== false ) + { + $str_contact_allow = str_replace('<' . local_user() . '>', '', $str_contact_allow); + } + // Make sure to set the `private` field as true. This is necessary to + // have the posts show up correctly in Diaspora if an event is created + // as visible only to self at first, but then edited to display to others. + if( strlen($str_group_allow) or strlen($str_contact_allow) or strlen($str_group_deny) or strlen($str_contact_deny) ) + { + $private_event = true; + } } else { + // Note: do not set `private` field for self-only events. It will + // keep even you from seeing them! $str_contact_allow = '<' . local_user() . '>'; $str_group_allow = $str_contact_deny = $str_group_deny = ''; } @@ -91,6 +109,7 @@ function events_post(&$a) { $datarray['allow_gid'] = $str_group_allow; $datarray['deny_cid'] = $str_contact_deny; $datarray['deny_gid'] = $str_group_deny; + $datarray['private'] = $private_event; $datarray['id'] = $event_id; $datarray['created'] = $created; $datarray['edited'] = $edited; -- cgit v1.2.3 From e7580b71e1825dc6e049d7c1f945ab701bf8f6cd Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 2 May 2012 21:00:39 -0700 Subject: use cid rather than uid in perms --- mod/events.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/events.php b/mod/events.php index 1f11e7503..069046ff9 100644 --- a/mod/events.php +++ b/mod/events.php @@ -68,6 +68,15 @@ function events_post(&$a) { $share = ((intval($_POST['share'])) ? intval($_POST['share']) : 0); + $c = q("select id from contact where uid = %d and self = 1 limit 1", + intval(local_user()) + ); + if(count($c)) + $self = $c[0]['id']; + else + $self = 0; + + if($share) { $str_group_allow = perms2str($_POST['group_allow']); $str_contact_allow = perms2str($_POST['contact_allow']); @@ -75,9 +84,9 @@ function events_post(&$a) { $str_contact_deny = perms2str($_POST['contact_deny']); // Undo the pseudo-contact of self, since there are real contacts now - if( strpos($str_contact_allow, '<' . local_user() . '>') !== false ) + if( strpos($str_contact_allow, '<' . $self . '>') !== false ) { - $str_contact_allow = str_replace('<' . local_user() . '>', '', $str_contact_allow); + $str_contact_allow = str_replace('<' . $self . '>', '', $str_contact_allow); } // Make sure to set the `private` field as true. This is necessary to // have the posts show up correctly in Diaspora if an event is created @@ -90,7 +99,7 @@ function events_post(&$a) { else { // Note: do not set `private` field for self-only events. It will // keep even you from seeing them! - $str_contact_allow = '<' . local_user() . '>'; + $str_contact_allow = '<' . $self . '>'; $str_group_allow = $str_contact_deny = $str_group_deny = ''; } -- cgit v1.2.3 From e7ff35f27d7f2a7f7caed63f9bf48bd8104cc336 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 2 May 2012 22:33:51 -0700 Subject: Avoid tagging both '@Robert Johnson' and also '@Robert', when '@Robert Johnson' was already matched, and '@Robert' might be somebody different entirely. --- mod/item.php | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'mod') diff --git a/mod/item.php b/mod/item.php index 1436f7ffc..639379fe0 100644 --- a/mod/item.php +++ b/mod/item.php @@ -444,9 +444,28 @@ function item_post(&$a) { $tags[] = '@' . $parent_contact['nick']; } + $tagged = array(); + + if(count($tags)) { foreach($tags as $tag) { - handle_tag($a, $body, $inform, $str_tags, (local_user()) ? local_user() : $profile_uid , $tag); + + // If we already tagged 'Robert Johnson', don't try and tag 'Robert'. + // Robert Johnson should be first in the $tags array + + $fullnametagged = false; + for($x = 0; $x < count($tagged); $x ++) { + if(stristr($tagged[$x],$tag . ' ')) { + $fullnametagged = true; + break; + } + } + if($fullnametagged) + continue; + + $success = handle_tag($a, $body, $inform, $str_tags, (local_user()) ? local_user() : $profile_uid , $tag); + if($success) + $tagged[] = $tag; } } @@ -861,21 +880,27 @@ function item_content(&$a) { * @param unknown_type $str_tags string to add the tag to * @param unknown_type $profile_uid * @param unknown_type $tag the tag to replace + * + * @return boolean true if replaced, false if not replaced */ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) { + + $replaced = false; + //is it a hash tag? if(strpos($tag,'#') === 0) { //if the tag is replaced... if(strpos($tag,'[url=')) //...do nothing - return; + return $replaced; //base tag has the tags name only $basetag = str_replace('_',' ',substr($tag,1)); //create text for link $newtag = '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]'; //replace tag by the link $body = str_replace($tag, $newtag, $body); - + $replaced = true; + //is the link already in str_tags? if(! stristr($str_tags,$newtag)) { //append or set str_tags @@ -883,13 +908,13 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) { $str_tags .= ','; $str_tags .= $newtag; } - return; + return $replaced; } //is it a person tag? if(strpos($tag,'@') === 0) { //is it already replaced? if(strpos($tag,'[url=')) - return; + return $replaced; $stat = false; //get the person's name $name = substr($tag,1); @@ -965,6 +990,7 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) { } //if there is an url for this persons profile if(isset($profile)) { + $replaced = true; //create profile link $profile = str_replace(',','%2c',$profile); $newtag = '@[url=' . $profile . ']' . $newname . '[/url]'; @@ -989,4 +1015,6 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) { } } } + + return $replaced; } -- cgit v1.2.3 From f3e18df55dc259e70e9acdfd6e851b97ec062f46 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 3 May 2012 16:55:03 -0700 Subject: string update --- mod/profiles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/profiles.php b/mod/profiles.php index 4de9057dc..558044842 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -329,7 +329,7 @@ function profile_activity($changed, $value) { if($t == 1 && strlen($value)) { $message = sprintf( t('%1$s changed %2$s to "%3$s"'), $A, $changes, $value); - $message .= "\n\n" . sprintf( t(' - Visit %1$s\'s %2$s'), $A, $prof); + $message .= "\n\n" . sprintf( t(" - Visit %1$s\'s %2$s"), $A, $prof); } else $message = sprintf( t('%1$s has an updated %2$s, changing %3$s.'), $A, $prof, $changes); -- cgit v1.2.3 From 2818cb28e98f54fe413885bac34592fbfa7e07f5 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 3 May 2012 17:19:53 -0700 Subject: use html symbols for double quotes --- mod/profiles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/profiles.php b/mod/profiles.php index 558044842..c72a233c2 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -328,7 +328,7 @@ function profile_activity($changed, $value) { $prof = '[url=' . $self[0]['url'] . '?tab=profile' . ']' . t('public profile') . '[/url]'; if($t == 1 && strlen($value)) { - $message = sprintf( t('%1$s changed %2$s to "%3$s"'), $A, $changes, $value); + $message = sprintf( t('%1$s changed %2$s to “%3$s”'), $A, $changes, $value); $message .= "\n\n" . sprintf( t(" - Visit %1$s\'s %2$s"), $A, $prof); } else -- cgit v1.2.3 From 421acee65b846947c24257f256c900d4881256da Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 3 May 2012 21:50:48 -0700 Subject: implement max load average before queuing/deferring delivery and poller processes --- mod/admin.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/admin.php b/mod/admin.php index b07ef851a..cfe5a2dd2 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); + $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); $diaspora_enabled = ((x($_POST,'diaspora_enabled')) ? True : False); @@ -290,6 +291,7 @@ function admin_page_site_post(&$a){ } set_config('system','ssl_policy',$ssl_policy); set_config('system','delivery_interval',$delivery_interval); + set_config('system','maxloadavg',$maxloadavg); set_config('config','sitename',$sitename); if ($banner==""){ // don't know why, but del_config doesn't work... @@ -434,7 +436,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.")), - + '$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"), )); -- cgit v1.2.3 From 9ecd128e5e2aba527138c1a4afa2ff17caebe896 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 4 May 2012 01:46:36 -0700 Subject: "show more" friends in common --- mod/common.php | 77 +++++++++++++++++++++++++++++++++++++++++++++----------- mod/contacts.php | 2 +- 2 files changed, 63 insertions(+), 16 deletions(-) (limited to 'mod') diff --git a/mod/common.php b/mod/common.php index 852388c14..617b5b670 100644 --- a/mod/common.php +++ b/mod/common.php @@ -5,25 +5,33 @@ require_once('include/socgraph.php'); function common_content(&$a) { $o = ''; - if(! local_user()) { - notice( t('Permission denied.') . EOL); - return; - } - if($a->argc > 1) - $cid = intval($a->argv[1]); - if(! $cid) + $cmd = $a->argv[1]; + $uid = intval($a->argv[2]); + $cid = intval($a->argv[3]); + $zcid = 0; + + if($cmd !== 'loc' && $cmd != 'rem') + return; + if(! $uid) return; - $c = q("select name, url, photo from contact where id = %d and uid = %d limit 1", - intval($cid), - intval(local_user()) - ); + if($cmd === 'loc' && $cid) { + $c = q("select name, url, photo from contact where id = %d and uid = %d limit 1", + intval($cid), + intval($uid) + ); + } + else { + $c = q("select name, url, photo from contact where self = 1 and uid = %d limit 1", + intval($uid) + ); + } $a->page['aside'] .= '
' . '
' . $c[0]['name'] . '
' . '
' - . '' . $c[0]['name'] . '
' . '
'; @@ -33,13 +41,52 @@ function common_content(&$a) { $o .= '

' . t('Common Friends') . '

'; -// $o .= '

' . sprintf( t('You and %s'),$c[0]['name']) . '

'; + if(! $cid) { + if(get_my_url()) { + $r = q("select id from contact where nurl = '%s' and uid = %d limit 1", + dbesc(normalise_link(get_my_url())), + intval($profile_uid) + ); + if(count($r)) + $cid = $r[0]['id']; + else { + $r = q("select id from gcontact where nurl = '%s' limit 1", + dbesc(normalise_link(get_my_url())) + ); + if(count($r)) + $zcid = $r[0]['id']; + } + } + } + + + + if($cid == 0 && $zcid == 0) + return; + + + if($cid) + $t = count_common_friends($uid,$cid); + else + $t = count_common_friends_zcid($uid,$zcid); + + + $a->set_pager_total($t); + + if(! $t) { + notice( t('No contacts in common.') . EOL); + return $o; + } + + + if($cid) + $r = common_friends($uid,$cid); + else + $r = common_friends_zcid($uid,$zcid); - $r = common_friends(local_user(),$cid); if(! count($r)) { - $o .= t('No friends in common.'); return $o; } diff --git a/mod/contacts.php b/mod/contacts.php index 3b428914c..769239fe0 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -325,7 +325,7 @@ function contacts_content(&$a) { '$lbl_info1' => t('Contact Information / Notes'), '$infedit' => t('Edit contact notes'), '$common_text' => $common_text, - '$common_link' => $a->get_baseurl(true) . '/common/' . $contact['id'], + '$common_link' => $a->get_baseurl(true) . '/common/loc/' . local_user() . '/' . $contact['id'], '$all_friends' => $all_friends, '$relation_text' => $relation_text, '$visit' => sprintf( t('Visit %s\'s profile [%s]'),$contact['name'],$contact['url']), -- cgit v1.2.3 From 10754ced3e51f796102005b9661b747c06fd4e0b Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 4 May 2012 06:42:56 -0700 Subject: category removal --- mod/filerm.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/filerm.php b/mod/filerm.php index c520fec7a..d2b57d447 100644 --- a/mod/filerm.php +++ b/mod/filerm.php @@ -7,12 +7,18 @@ function filerm_content(&$a) { } $term = unxmlify(trim($_GET['term'])); + $cat = unxmlify(trim($_GET['cat'])); + + $category = (($cat) ? true : false); + if($category) + $term = $cat; + $item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0); logger('filerm: tag ' . $term . ' item ' . $item_id); if($item_id && strlen($term)) - file_tag_unsave_file(local_user(),$item_id,$term); + file_tag_unsave_file(local_user(),$item_id,$term, $category); if(x($_SESSION,'return_url')) goaway($a->get_baseurl() . '/' . $_SESSION['return_url']); -- cgit v1.2.3 From 49ccefd6c7add622ba84c72769a68d08ef043ef5 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 5 May 2012 17:53:23 -0700 Subject: bad sql left after the mailbox in/out merge --- mod/message.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod') diff --git a/mod/message.php b/mod/message.php index dbca45930..aa8851e46 100644 --- a/mod/message.php +++ b/mod/message.php @@ -198,7 +198,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) ); -- cgit v1.2.3 From 57920849c4138920b5715931a268dd2a55c76003 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 6 May 2012 19:53:34 -0700 Subject: email recip autocomplete --- mod/acl.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'mod') diff --git a/mod/acl.php b/mod/acl.php index 88f150d7a..402d37376 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,23 @@ function acl_init(&$a){ else $r = array(); + + if($type == 'm') { + $x = array(); + $x['query'] = $search; + $x['suggestions'] = array(); + $x['data'] = array(); + if(count($r)) { + foreach($r as $g) { + $x['suggestions'][] = sprintf( t('%s [%s]'),$g['name'],$g['url']); + // '' . t('Image/photo') . '' . + $x['data'][] = intval($g['id']); + } + } + echo json_encode($x); + killme(); + } + if(count($r)) { foreach($r as $g){ $contacts[] = array( -- cgit v1.2.3 From 851264161f1b0e638a818a0ebfa80feeb46dfa44 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 6 May 2012 19:55:39 -0700 Subject: mail autcomplete testing --- mod/message.php | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'mod') diff --git a/mod/message.php b/mod/message.php index aa8851e46..70b85b84c 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,20 @@ function message_init(&$a) { '$tabs'=>$tabs, '$new'=>$new, )); + $base = $a->get_baseurl(); + + $a->page['htmlhead'] .= ''; + $a->page['htmlhead'] .= <<< EOT + + +EOT; } @@ -171,7 +172,9 @@ function message_content(&$a) { $preselect = (isset($a->argv[2])?array($a->argv[2]):false); - $select = contact_select('messageto','message-to-select', $preselect, 4, true, false, false, 10); +// $select = contact_select('messageto','message-to-select', $preselect, 4, true, false, false, 10); + $select = ''; + $tpl = get_markup_template('prv_message.tpl'); $o .= replace_macros($tpl,array( '$header' => t('Send Private Message'), -- cgit v1.2.3 From b74a776162b86b6257acf0406e7df4da236c8f09 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 6 May 2012 20:06:39 -0700 Subject: I'll leave the private mail recipient autocomplete partially done. Need a good UI/JS person to finish it off. --- mod/message.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/message.php b/mod/message.php index 70b85b84c..6fa128808 100644 --- a/mod/message.php +++ b/mod/message.php @@ -23,7 +23,7 @@ function message_init(&$a) { @@ -95,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'), @@ -173,27 +173,34 @@ function message_content(&$a) { $preselect = (isset($a->argv[2])?array($a->argv[2]):false); - if(defined('EMAIL_AUTOCOMP')) { - // here's where we want to do contact autocomplete - // just figure out how to make it do the right thing - // pictures would be nice, but that didn't work when I tried. - // It sort of barely works, but needs help - // (the json backend is found in mod/acl.php) + $prename = $preurl = $preid = ''; - $select = ''; - } - else { + 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']; + } + } - // the ugly select box + $prefill = (($preselect) ? $prename . ' [' . $preurl . ']' : ''); - $select = contact_select('messageto','message-to-select', $preselect, 4, true, false, false, 10); - } + // 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:'), + '$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'])) : ''), -- cgit v1.2.3 From 547007e1993a21347db327f5c030dd1dac60f28f Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 10 May 2012 19:29:01 -0700 Subject: add photos to PM autocomplete, improved appearance --- mod/acl.php | 7 +++++-- mod/message.php | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'mod') diff --git a/mod/acl.php b/mod/acl.php index 402d37376..168b1f59f 100644 --- a/mod/acl.php +++ b/mod/acl.php @@ -127,12 +127,15 @@ function acl_init(&$a){ 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['suggestions'][] = sprintf( t('%s [%s]'),$g['name'],$g['url']); - // '' . t('Image/photo') . '' . + $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']); } } diff --git a/mod/message.php b/mod/message.php index 8cfa0256c..29a2fa253 100644 --- a/mod/message.php +++ b/mod/message.php @@ -18,7 +18,7 @@ function message_init(&$a) { )); $base = $a->get_baseurl(); - $a->page['htmlhead'] .= ''; + $a->page['htmlhead'] .= ''; $a->page['htmlhead'] .= <<< EOT