aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorVasudev Kamath <kamathvasudev@gmail.com>2012-04-27 22:43:26 +0530
committerVasudev Kamath <kamathvasudev@gmail.com>2012-04-27 22:43:26 +0530
commit214ec91a3f2c5fec6cced93f669b3a9725f0e40a (patch)
treed05fd4c7e65cc89cf46d8347a2d0e6df135ed864 /mod
parentf1d84c10458986a0a014f844e784617401764b29 (diff)
parent4b92e3543c9af26e590cfecf561ff7483e66e6c9 (diff)
downloadvolse-hubzilla-214ec91a3f2c5fec6cced93f669b3a9725f0e40a.tar.gz
volse-hubzilla-214ec91a3f2c5fec6cced93f669b3a9725f0e40a.tar.bz2
volse-hubzilla-214ec91a3f2c5fec6cced93f669b3a9725f0e40a.zip
Merge branch 'master' of git://github.com/friendica/friendica
Diffstat (limited to 'mod')
-rw-r--r--mod/acl.php39
-rw-r--r--mod/contacts.php37
-rw-r--r--mod/dfrn_request.php62
-rw-r--r--mod/item.php2
-rw-r--r--mod/message.php23
-rw-r--r--mod/ping.php2
-rw-r--r--mod/search.php30
-rw-r--r--mod/settings.php9
-rw-r--r--mod/tagger.php8
-rw-r--r--mod/wall_upload.php38
10 files changed, 185 insertions, 65 deletions
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/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' => '' // '<as:verb>http://ostatus.org/schema/1.0/unfollow</as:verb>' . "\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 );
diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php
index 77a3124f7..79583ea18 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,71 @@ 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 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.
}
+
else {
// Canonicalise email-style profile locator
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/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']),
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 = '<note href="%s" name="%s" url="%s" photo="%s" date="%s" seen="%s" >%s</note>';
return sprintf ( $notsxml,
xmlify($href), xmlify($name), xmlify($url), xmlify($photo), xmlify($date), xmlify($seen), xmlify($message)
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 .= '<h2>Search results for: ' . $search . '</h2>';
+ if($tag)
+ $o .= '<h2>Items tagged with: ' . $search . '</h2>';
+ else
+ $o .= '<h2>Search results for: ' . $search . '</h2>';
$o .= conversation($a,$r,'search',false);
diff --git a/mod/settings.php b/mod/settings.php
index 721468437..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' => ''
)
);
@@ -696,8 +701,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);
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) {
</target>
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('&#x2317;') . '[url=' . $a->get_baseurl() . '/search?search=' . urlencode($term) . ']'. $term . '[/url]';
+ $termlink = html_entity_decode('&#x2317;') . '[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'])
);
}
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');