aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorStefan Parviainen <saparvia@caterva.eu>2014-11-08 20:53:41 +0100
committerStefan Parviainen <saparvia@caterva.eu>2014-11-08 20:53:41 +0100
commitb5fad9feefd0f261807222d8a4c42ead6253a65c (patch)
tree399cd4a1b79f61530924ea59670af0bdd6cee5be /mod
parent89aea081825ec7b11b00833a9bec2c74900bfcb6 (diff)
parentb29a968be8df52cd7c9b6d5bebb618534788337c (diff)
downloadvolse-hubzilla-b5fad9feefd0f261807222d8a4c42ead6253a65c.tar.gz
volse-hubzilla-b5fad9feefd0f261807222d8a4c42ead6253a65c.tar.bz2
volse-hubzilla-b5fad9feefd0f261807222d8a4c42ead6253a65c.zip
Fix merge conflict
Diffstat (limited to 'mod')
-rw-r--r--mod/acl.php12
-rw-r--r--mod/channel.php2
-rw-r--r--mod/connedit.php23
-rw-r--r--mod/feed.php3
-rw-r--r--mod/help.php26
-rw-r--r--mod/item.php52
-rwxr-xr-xmod/like.php17
-rw-r--r--mod/locs.php70
-rw-r--r--mod/page.php22
-rw-r--r--mod/photos.php303
-rw-r--r--mod/ping.php184
-rw-r--r--mod/post.php28
-rw-r--r--mod/settings.php282
-rw-r--r--mod/tagrm.php120
-rw-r--r--mod/zotfeed.php2
15 files changed, 714 insertions, 432 deletions
diff --git a/mod/acl.php b/mod/acl.php
index 5658a05c5..01f5103f1 100644
--- a/mod/acl.php
+++ b/mod/acl.php
@@ -11,7 +11,7 @@ function acl_init(&$a){
$count = (x($_REQUEST,'count')?$_REQUEST['count']:100);
$search = (x($_REQUEST,'search')?$_REQUEST['search']:"");
$type = (x($_REQUEST,'type')?$_REQUEST['type']:"");
-
+ $noforums = (x($_REQUEST,'n') ? $_REQUEST['n'] : false);
// For use with jquery.autocomplete for private mail completion
@@ -87,7 +87,7 @@ function acl_init(&$a){
$contact_count = (int)$r[0]['c'];
}
- elseif ($type == 'a') {
+ elseif (($type == 'a')||($type == 'p')) {
// autocomplete for Contacts
@@ -168,7 +168,7 @@ function acl_init(&$a){
intval(XCHAN_FLAGS_DELETED)
);
}
- elseif($type == 'a') {
+ elseif(($type == 'a') || ($type == 'p')) {
$r = q("SELECT abook_id as id, xchan_name as name, xchan_hash as hash, xchan_addr as nick, xchan_photo_s as micro, xchan_network as network, xchan_url as url, xchan_addr as attag , abook_their_perms FROM abook left join xchan on abook_xchan = xchan_hash
WHERE abook_channel = %d
and not (xchan_flags & %d)
@@ -204,7 +204,7 @@ function acl_init(&$a){
$r = array();
- if($type == 'm' || $type == 'a') {
+ if($type == 'm' || $type == 'a' || $type == 'p') {
$x = array();
$x['query'] = $search;
$x['photos'] = array();
@@ -216,7 +216,7 @@ function acl_init(&$a){
$x['photos'][] = $g['micro'];
$x['links'][] = $g['url'];
$x['suggestions'][] = $g['name'];
- $x['data'][] = $g['id'];
+ $x['data'][] = (($type === 'p') ? '@' . str_replace(' ','_',$g['name']) : $g['id']);
}
}
echo json_encode($x);
@@ -230,7 +230,7 @@ function acl_init(&$a){
if(strpos($g['hash'],'/'))
continue;
- if(($g['abook_their_perms'] & PERMS_W_TAGWALL) && $type == 'c') {
+ if(($g['abook_their_perms'] & PERMS_W_TAGWALL) && $type == 'c' && (! $noforums)) {
$contacts[] = array(
"type" => "c",
"photo" => "images/twopeople.png",
diff --git a/mod/channel.php b/mod/channel.php
index 395160d2c..e4a7173c0 100644
--- a/mod/channel.php
+++ b/mod/channel.php
@@ -64,7 +64,7 @@ function channel_content(&$a, $update = 0, $load = false) {
if($update) {
// Ensure we've got a profile owner if updating.
- $a->profile['profile_uid'] = $update;
+ $a->profile['profile_uid'] = $a->profile_uid = $update;
}
else {
if($a->profile['profile_uid'] == local_user()) {
diff --git a/mod/connedit.php b/mod/connedit.php
index 7ad719738..60f284797 100644
--- a/mod/connedit.php
+++ b/mod/connedit.php
@@ -68,6 +68,14 @@ function connedit_post(&$a) {
call_hooks('contact_edit_post', $_POST);
+ if($orig_record[0]['abook_flags'] & ABOOK_FLAG_SELF) {
+ $autoperms = intval($_POST['autoperms']);
+ }
+ else {
+ $autoperms = null;
+ }
+
+
$profile_id = $_POST['profile_assign'];
if($profile_id) {
$r = q("SELECT profile_guid FROM profile WHERE profile_guid = '%s' AND `uid` = %d LIMIT 1",
@@ -121,7 +129,7 @@ function connedit_post(&$a) {
if($orig_record[0]['abook_profile'] != $profile_id) {
//Update profile photo permissions
- logger('As a new profile was assigned updating profile photos');
+ logger('A new profile was assigned - updating profile photos');
require_once('mod/profile_photo.php');
profile_photo_set_profile_perms($profile_id);
@@ -208,6 +216,10 @@ function connedit_post(&$a) {
$arr = array('channel_id' => local_user(), 'abook' => $a->poi);
call_hooks('accept_follow', $arr);
}
+dbg(1);
+ if(! is_null($autoperms))
+ set_pconfig(local_user(),'system','autoperms',(($autoperms) ? $abook_my_perms : 0));
+dbg(0);
connedit_clone($a);
@@ -261,6 +273,8 @@ function connedit_content(&$a) {
$x = get_role_perms($role);
if($x['perms_accept'])
$my_perms = $x['perms_accept'];
+ else
+ $my_perms = get_channel_default_perms(local_user());
}
if($my_perms) {
$o .= "<script>function connectDefaultShare() {
@@ -516,16 +530,17 @@ function connedit_content(&$a) {
if((! $self) && ($existing[$k]))
$thisperm = "1";
- $perms[] = array('perms_' . $k, $v[3], (($contact['abook_their_perms'] & $v[1]) ? "1" : ""),$thisperm, $v[1], (($channel[$v[0]] == PERMS_SPECIFIC) ? '' : '1'), $v[4]);
+ $perms[] = array('perms_' . $k, $v[3], (($contact['abook_their_perms'] & $v[1]) ? "1" : ""),$thisperm, $v[1], (($channel[$v[0]] == PERMS_SPECIFIC || $self) ? '' : '1'), $v[4]);
}
$o .= replace_macros($tpl,array(
- '$header' => (($self) ? t('Automatic Permissions Settings') : sprintf( t('Connections: settings for %s'),$contact['xchan_name'])),
+ '$header' => (($self) ? t('Connection Default Permissions') : sprintf( t('Connections: settings for %s'),$contact['xchan_name'])),
+ '$autoperms' => array('autoperms',t('Apply these permissions automatically'), ((get_pconfig(local_user(),'system','autoperms')) ? 1 : 0), ''),
'$addr' => $contact['xchan_addr'],
'$notself' => (($self) ? '' : '1'),
'$self' => (($self) ? '1' : ''),
- '$autolbl' => t('When receiving a channel introduction, any permissions provided here will be applied to the new connection automatically and the introduction approved. Leave this page if you do not wish to use this feature.'),
+ '$autolbl' => t('Apply the permissions indicated on this page to all new connections.'),
'$viewprof' => t('View Profile'),
'$lbl_slider' => t('Slide to adjust your degree of friendship'),
'$slide' => $slide,
diff --git a/mod/feed.php b/mod/feed.php
index 776f9787f..3b622fc17 100644
--- a/mod/feed.php
+++ b/mod/feed.php
@@ -12,6 +12,9 @@ function feed_init(&$a) {
$params['type'] = ((stristr(argv(0),'json')) ? 'json' : 'xml');
$params['pages'] = ((x($_REQUEST,'pages')) ? intval($_REQUEST['pages']) : 0);
$params['top'] = ((x($_REQUEST,'top')) ? intval($_REQUEST['top']) : 0);
+ $params['start'] = ((x($params,'start')) ? intval($params['start']) : 0);
+ $params['records'] = ((x($params,'records')) ? intval($params['records']) : 40);
+ $params['direction'] = ((x($params,'direction')) ? dbesc($params['direction']) : 'desc');
$channel = '';
if(argc() > 1) {
diff --git a/mod/help.php b/mod/help.php
index 81ecd6ba9..4823f1c07 100644
--- a/mod/help.php
+++ b/mod/help.php
@@ -34,8 +34,6 @@ function help_content(&$a) {
$doctype = 'markdown';
- require_once('library/markdown.php');
-
$text = '';
if(argc() > 1) {
@@ -73,17 +71,22 @@ function help_content(&$a) {
));
}
- $text = preg_replace_callback("/#include (.*?)\;/ism", 'preg_callback_help_include', $text);
-
if($doctype === 'html')
$content = $text;
- if($doctype === 'markdown')
+ if($doctype === 'markdown') {
+ require_once('library/markdown.php');
+ # escape #include tags
+ $text = preg_replace('/#include/ism', '%%include', $text);
$content = Markdown($text);
+ $content = preg_replace('/%%include/ism', '#include', $content);
+ }
if($doctype === 'bbcode') {
require_once('include/bbcode.php');
$content = bbcode($text);
}
+ $content = preg_replace_callback("/#include (.*?)\;/ism", 'preg_callback_help_include', $content);
+
return replace_macros(get_markup_template("help.tpl"), array(
'$content' => $content
));
@@ -93,8 +96,17 @@ function help_content(&$a) {
function preg_callback_help_include($matches) {
- if($matches[1])
- return str_replace($matches[0],load_doc_file($matches[1]),$matches[0]);
+ if($matches[1]) {
+ $include = str_replace($matches[0],load_doc_file($matches[1]),$matches[0]);
+ if(preg_match('/\.bb$/', $matches[1])) {
+ require_once('include/bbcode.php');
+ $include = bbcode($include);
+ } elseif(preg_match('/\.md$/', $matches[1])) {
+ require_once('library/markdown.php');
+ $include = Markdown($include);
+ }
+ return $include;
+ }
}
diff --git a/mod/item.php b/mod/item.php
index ac15e50e8..e7d886b00 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -77,7 +77,7 @@ function item_post(&$a) {
$preview = ((x($_REQUEST,'preview')) ? intval($_REQUEST['preview']) : 0);
$categories = ((x($_REQUEST,'category')) ? escape_tags($_REQUEST['category']) : '');
$webpage = ((x($_REQUEST,'webpage')) ? intval($_REQUEST['webpage']) : 0);
- $pagetitle = ((x($_REQUEST,'pagetitle')) ? escape_tags($_REQUEST['pagetitle']) : '');
+ $pagetitle = ((x($_REQUEST,'pagetitle')) ? escape_tags(urlencode($_REQUEST['pagetitle'])) : '');
$layout_mid = ((x($_REQUEST,'layout_mid')) ? escape_tags($_REQUEST['layout_mid']): '');
$plink = ((x($_REQUEST,'permalink')) ? escape_tags($_REQUEST['permalink']) : '');
@@ -112,6 +112,7 @@ function item_post(&$a) {
$parent = ((x($_REQUEST,'parent')) ? intval($_REQUEST['parent']) : 0);
$parent_mid = ((x($_REQUEST,'parent_mid')) ? trim($_REQUEST['parent_mid']) : '');
+ $route = '';
$parent_item = null;
$parent_contact = null;
$thr_parent = '';
@@ -163,6 +164,7 @@ function item_post(&$a) {
$thr_parent = $parent_mid;
+ $route = $parent_item['route'];
}
@@ -257,8 +259,25 @@ function item_post(&$a) {
killme();
}
+ $walltowall = false;
+ $walltowall_comment = false;
+
if($observer) {
logger('mod_item: post accepted from ' . $observer['xchan_name'] . ' for ' . $owner_xchan['xchan_name'], LOGGER_DEBUG);
+
+ // wall-to-wall detection.
+ // For top-level posts, if the author and owner are different it's a wall-to-wall
+ // For comments, We need to additionally look at the parent and see if it's a wall post that originated locally.
+
+ if($observer['xchan_name'] != $owner_xchan['xchan_name']) {
+ if($parent_item && ($parent_item['item_flags'] & (ITEM_WALL|ITEM_ORIGIN)) == (ITEM_WALL|ITEM_ORIGIN)) {
+ $walltowall_comment = true;
+ $walltowall = true;
+ }
+ if(! $parent) {
+ $walltowall = true;
+ }
+ }
}
$public_policy = ((x($_REQUEST,'public_policy')) ? escape_tags($_REQUEST['public_policy']) : map_scope($channel['channel_r_stream'],true));
@@ -329,6 +348,15 @@ function item_post(&$a) {
$str_group_deny = $channel['channel_deny_gid'];
$str_contact_deny = $channel['channel_deny_cid'];
}
+ elseif($walltowall) {
+
+ // use the channel owner's default permissions
+
+ $str_group_allow = $channel['channel_allow_gid'];
+ $str_contact_allow = $channel['channel_allow_cid'];
+ $str_group_deny = $channel['channel_deny_gid'];
+ $str_contact_deny = $channel['channel_deny_cid'];
+ }
else {
// use the posted permissions
@@ -570,7 +598,14 @@ function item_post(&$a) {
logger('handle_tag: ' . print_r($success,tue), LOGGER_DATA);
if(($access_tag) && (! $parent_item)) {
logger('access_tag: ' . $tag . ' ' . print_r($access_tag,true), LOGGER_DATA);
- if ($first_access_tag) {
+ if ($first_access_tag && (! get_pconfig($profile_uid,'system','no_private_mention_acl_override'))) {
+
+ // This is a tough call, hence configurable. The issue is that one can type in a @!privacy mention
+ // and also have a default ACL (perhaps from viewing a collection) and could be suprised that the
+ // privacy mention wasn't the only recipient. So the default is to wipe out the existing ACL if a
+ // private mention is found. This can be over-ridden if you wish private mentions to be in
+ // addition to the current ACL settings.
+
$str_contact_allow = '';
$str_group_allow = '';
$first_access_tag = false;
@@ -720,6 +755,7 @@ function item_post(&$a) {
$datarray['comment_policy'] = map_scope($channel['channel_w_comment']);
$datarray['term'] = $post_tags;
$datarray['plink'] = $plink;
+ $datarray['route'] = $route;
// preview mode - prepare the body for display and send it via json
@@ -859,10 +895,9 @@ function item_post(&$a) {
if($parent) {
// Store the comment signature information in case we need to relay to Diaspora
-//FIXME
$ditem = $datarray;
$ditem['author'] = $observer;
- store_diaspora_comment_sig($ditem,$channel,$parent_item, $post_id);
+ store_diaspora_comment_sig($ditem,$channel,$parent_item, $post_id, (($walltowall_comment) ? 1 : 0));
}
update_remote_id($channel,$post_id,$webpage,$pagetitle,$namespace,$remote_id,$mid);
@@ -1137,6 +1172,8 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag) {
// $r is set if we found something
+ $channel = get_app()->get_channel();
+
if($r) {
$profile = $r[0]['xchan_url'];
$newname = $r[0]['xchan_name'];
@@ -1156,9 +1193,10 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag) {
if(local_user() && local_user() == $profile_uid) {
require_once('include/group.php');
$grp = group_byname($profile_uid,$name);
+
if($grp) {
$g = q("select hash from groups where id = %d and visible = 1 limit 1",
- intval($grp[0]['id'])
+ intval($grp)
);
if($g && $exclusive) {
$access_tag .= 'gid:' . $g[0]['hash'];
@@ -1172,6 +1210,10 @@ function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag) {
}
}
+ if(($exclusive) && (! $access_tag)) {
+ $access_tag .= 'cid:' . $channel['channel_hash'];
+ }
+
// if there is an url for this channel
if(isset($profile)) {
diff --git a/mod/like.php b/mod/like.php
index 916faf230..f4fd33787 100755
--- a/mod/like.php
+++ b/mod/like.php
@@ -209,13 +209,17 @@ function like_content(&$a) {
}
else {
+ // this is used to like an item or comment
+
$item_id = ((argc() == 2) ? notags(trim(argv(1))) : 0);
logger('like: verb ' . $verb . ' item ' . $item_id, LOGGER_DEBUG);
+ // get the item. Allow linked photos (which are normally hidden) to be liked
- $r = q("SELECT * FROM item WHERE id = %d and item_restrict = 0 LIMIT 1",
- dbesc($item_id)
+ $r = q("SELECT * FROM item WHERE id = %d and (item_restrict = 0 or item_restrict = %d) LIMIT 1",
+ intval($item_id),
+ intval(ITEM_HIDDEN)
);
if(! $item_id || (! $r)) {
@@ -325,6 +329,15 @@ function like_content(&$a) {
if($item['item_flags'] & ITEM_WALL)
$item_flags |= ITEM_WALL;
+ // if this was a linked photo and was hidden, unhide it.
+
+ if($item['item_restrict'] & ITEM_HIDDEN) {
+ $r = q("update item set item_restrict = (item_restrict ^ %d) where id = %d limit 1",
+ intval(ITEM_HIDDEN),
+ intval($item['id'])
+ );
+ }
+
}
if($verb === 'like')
diff --git a/mod/locs.php b/mod/locs.php
index 95aa7a579..b707f6bd9 100644
--- a/mod/locs.php
+++ b/mod/locs.php
@@ -1,34 +1,6 @@
<?php /** @file */
-/**
- Placeholder file at present. This is going to involve a bit of work.
-
- This file will deal with the deletion of channels and management of hublocs.
-
- We need to provide the following functionality:
-
- - Delete my account and all channels from the entire network
-
- - Delete my account and all channels from this server
-
- - Delete a channel from the entire network
-
- - Delete a channel from this server
-
- - List all hub locations for this channel
-
- - Remove this/some hub location from this channel
-
- - promote this/some hub location to primary
-
- - Remove hub location 'xyz' from this channel, (this should possibly only be allowed if that hub has been down for a period of time)
-
- - Some of these actions should probably require email verification
-
-*/
-
-
function locs_post(&$a) {
if(! local_user())
@@ -87,4 +59,46 @@ function locs_post(&$a) {
return;
}
}
+}
+
+
+
+function locs_content(&$a) {
+
+
+
+ if(! local_user()) {
+ notice( t('Permission denied.') . EOL);
+ return;
+ }
+
+ $channel = $a->get_channel();
+
+ $r = q("select * from hubloc where hubloc_hash = '%s'",
+ dbesc($channel['channel_hash'])
+ );
+
+ if(! $r) {
+ notice( t('No locations found.') . EOL);
+ return;
+ }
+
+
+ for($x = 0; $x < count($r); $x ++) {
+ $r[$x]['primary'] = (($r[$x]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) ? true : false);
+ $r[$x]['deleted'] = (($r[$x]['hubloc_flags'] & HUBLOC_FLAGS_DELETED) ? true : false);
+ }
+
+
+
+ $o = replace_macros(get_markup_template('locmanage.tpl'), array(
+ '$header' => t('Manage Channel Locations'),
+ '$loc' => t('Location (address)'),
+ '$mkprm' => t('Primary Location'),
+ '$drop' => t('Drop location'),
+ '$submit' => t('Submit'),
+ '$hubs' => $r
+ ));
+
+ return $o;
} \ No newline at end of file
diff --git a/mod/page.php b/mod/page.php
index b3f53a227..e8f17ebda 100644
--- a/mod/page.php
+++ b/mod/page.php
@@ -14,13 +14,11 @@ function page_init(&$a) {
if($a->profile['profile_uid'])
head_set_icon($a->profile['thumb']);
-}
-
+ // load the item here in the init function because we need to extract
+ // the page layout and initialise the correct theme.
-function page_content(&$a) {
-
$observer = $a->get_observer();
$ob_hash = (($observer) ? $observer['xchan_hash'] : '');
@@ -97,11 +95,27 @@ function page_content(&$a) {
}
}
+ $a->data['webpage'] = $r;
+
+
+
+}
+
+
+
+
+function page_content(&$a) {
+
+ $r = $a->data['webpage'];
+ if(! $r)
+ return;
// logger('layout: ' . print_r($a->layout,true));
// Use of widgets should be determined by Comanche, but we don't have it on system pages yet, so...
+ // I recommend we now get rid of this bit - it's quite a hack to work around... - mike
+
if ($perms['write_pages']) {
$chan = $a->channel['channel_id'];
$who = $channel_address;
diff --git a/mod/photos.php b/mod/photos.php
index 06c566f47..2367067a7 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -196,7 +196,7 @@ function photos_post(&$a) {
}
}
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ goaway($a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . $_SESSION['album_return']);
}
if(($a->argc > 2) && ((x($_POST,'desc') !== false) || (x($_POST,'newtag') !== false)) || (x($_POST,'albname') !== false)) {
@@ -206,6 +206,7 @@ function photos_post(&$a) {
$rawtags = ((x($_POST,'newtag')) ? notags(trim($_POST['newtag'])) : '');
$item_id = ((x($_POST,'item_id')) ? intval($_POST['item_id']) : 0);
$albname = ((x($_POST,'albname')) ? notags(trim($_POST['albname'])) : '');
+ $adult = ((x($_POST,'adult')) ? intval($_POST['adult']) : 0);
$str_group_allow = perms2str($_POST['group_allow']);
$str_contact_allow = perms2str($_POST['contact_allow']);
$str_group_deny = perms2str($_POST['group_deny']);
@@ -273,13 +274,11 @@ function photos_post(&$a) {
}
}
- $p = q("SELECT * FROM `photo` WHERE `resource_id` = '%s' AND `uid` = %d and ( photo_flags = %d or photo_flags = %d ) ORDER BY `scale` DESC",
+ $p = q("SELECT * FROM `photo` WHERE `resource_id` = '%s' AND `uid` = %d ORDER BY `scale` DESC",
dbesc($resource_id),
- intval($page_owner_uid),
- intval(PHOTO_NORMAL),
- intval(PHOTO_PROFILE)
+ intval($page_owner_uid)
);
- if(count($p)) {
+ if($p) {
$ext = $phototypes[$p[0]['type']];
$r = q("UPDATE `photo` SET `description` = '%s', `album` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' WHERE `resource_id` = '%s' AND `uid` = %d",
@@ -296,6 +295,14 @@ function photos_post(&$a) {
$item_private = (($str_contact_allow || $str_group_allow || $str_contact_deny || $str_group_deny) ? true : false);
+ $old_adult = (($p[0]['photo_flags'] & PHOTO_ADULT) ? 1 : 0);
+ if($old_adult != $adult) {
+ $r = q("update photo set photo_flags = ( photo_flags ^ %d) where resource_id = '%s' and uid = %d",
+ intval(PHOTO_ADULT),
+ dbesc($resource_id),
+ intval($page_owner_uid)
+ );
+ }
/* Don't make the item visible if the only change was the album name */
@@ -313,12 +320,14 @@ function photos_post(&$a) {
intval($item_id),
intval($page_owner_uid)
);
- }
- if($r) {
- $old_tag = $r[0]['tag'];
- $old_inform = $r[0]['inform'];
+
+ if($r) {
+ $old_tag = $r[0]['tag'];
+ $old_inform = $r[0]['inform'];
+ }
}
+
// make sure the linked item has the same permissions as the photo regardless of any other changes
$x = q("update item set allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', item_private = %d
where id = %d limit 1",
@@ -380,6 +389,7 @@ function photos_post(&$a) {
if($success['replaced']) {
$tagged[] = $tag;
+
$post_tags[] = array(
'uid' => $a->profile['profile_uid'],
'type' => $success['termtype'],
@@ -397,8 +407,14 @@ function photos_post(&$a) {
);
if($r) {
+ $r = fetch_post_tags($r,true);
$datarray = $r[0];
- $datarray['term'] = $post_tags;
+ if($post_tags) {
+ if((! array_key_exists('term',$datarray)) || (! is_array($datarray['term'])))
+ $datarray['term'] = $post_tags;
+ else
+ $datarray['term'] = array_merge($datarray['term'],$post_tags);
+ }
item_store_update($datarray,$execflag);
}
@@ -420,8 +436,11 @@ function photos_post(&$a) {
if(! $r['success']) {
notice($r['message'] . EOL);
}
-
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+
+ if($_REQUEST['newalbum'])
+ goaway($a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($_REQUEST['newalbum']));
+ else
+ goaway($a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex(datetime_convert('UTC',date_default_timezone_get(),'now', 'Y')));
}
@@ -431,20 +450,17 @@ function photos_content(&$a) {
// URLs:
// photos/name
- // photos/name/upload
- // photos/name/upload/xxxxx (xxxxx is album name)
- // photos/name/album/xxxxx
- // photos/name/album/xxxxx/edit
+ // photos/name/album/xxxxx (xxxxx is album name)
// photos/name/image/xxxxx
- // photos/name/image/xxxxx/edit
if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
notice( t('Public access denied.') . EOL);
return;
}
-
-
+
+ $unsafe = ((array_key_exists('unsafe',$_REQUEST) && $_REQUEST['unsafe']) ? 1 : 0);
+
require_once('include/bbcode.php');
require_once('include/security.php');
require_once('include/conversation.php');
@@ -468,11 +484,9 @@ function photos_content(&$a) {
if(argc() > 3) {
$datatype = argv(2);
$datum = argv(3);
- }
- elseif((argc() > 2) && (argv(2) === 'upload'))
- $datatype = 'upload';
- else
+ } else {
$datatype = 'summary';
+ }
if(argc() > 4)
$cmd = argv(4);
@@ -495,7 +509,6 @@ function photos_content(&$a) {
$can_post = perm_is_allowed($owner_uid,$observer['xchan_hash'],'post_photos');
$can_view = perm_is_allowed($owner_uid,$observer['xchan_hash'],'view_photos');
-
if(! $can_view) {
notice( t('Access to this item is restricted.') . EOL);
return;
@@ -513,42 +526,11 @@ function photos_content(&$a) {
$_is_owner = (local_user() && (local_user() == $owner_uid));
$o .= profile_tabs($a,$_is_owner, $a->data['channel']['channel_address']);
- //
- // dispatch request
- //
-
/**
* Display upload form
*/
- if($datatype === 'upload') {
- if(! ($can_post)) {
- notice( t('Permission denied.'));
- return;
- }
-
-
-
- if(array_key_exists('albums', $a->data))
- $albums = get_app()->data['albums'];
- else
- $albums = photos_albums_list($a->data['channel'],$a->data['observer']);
-
-
- $selname = (($datum) ? hex2bin($datum) : '');
- $albumselect = '<select id="photos-upload-album-select" name="album" size="4">';
-
- $albumselect .= '<option value="" ' . ((! $selname) ? ' selected="selected" ' : '') . '>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
- if(count($albums['albums'])) {
- foreach($albums['albums'] as $album) {
- if(! $album['text'])
- continue;
- $selected = (($selname === $album['text']) ? ' selected="selected" ' : '');
- $albumselect .= '<option value="' . $album['text'] . '"' . $selected . '>' . $album['text'] . '</option>';
- }
- }
-
- $albumselect .= '</select>';
+ if( $can_post) {
$uploader = '';
@@ -556,12 +538,8 @@ function photos_content(&$a) {
'addon_text' => $uploader,
'default_upload' => true);
-
call_hooks('photo_upload_form',$ret);
- $default_upload = '<input id="photos-upload-choose" type="file" name="userfile" /> <div class="photos-upload-submit-wrapper" >
- <input type="submit" name="submit" value="' . t('Submit') . '" id="photos-upload-submit" /> </div>';
-
/* Show space usage */
$r = q("select sum(size) as total from photo where aid = %d and scale = 0 ",
@@ -571,10 +549,10 @@ function photos_content(&$a) {
$limit = service_class_fetch($a->data['channel']['channel_id'],'photo_upload_limit');
if($limit !== false) {
- $usage_message = sprintf( t("You have used %1$.2f Mbytes of %2$.2f Mbytes photo storage."), $r[0]['total'] / 1024000, $limit / 1024000 );
+ $usage_message = sprintf( t("%1$.2f MB of %2$.2f MB photo storage used."), $r[0]['total'] / 1024000, $limit / 1024000 );
}
else {
- $usage_message = sprintf( t('You have used %1$.2f Mbytes of photo storage.'), $r[0]['total'] / 1024000 );
+ $usage_message = sprintf( t('%1$.2f MB photo storage used.'), $r[0]['total'] / 1024000 );
}
if($_is_owner) {
@@ -586,38 +564,51 @@ function photos_content(&$a) {
'deny_cid' => $channel['channel_deny_cid'],
'deny_gid' => $channel['channel_deny_gid']
);
- }
- $albumselect_e = $albumselect;
+ $lockstate = (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock');
+ }
+
$aclselect_e = (($_is_owner) ? populate_acl($channel_acl,false) : '');
+ $selname = (($datum) ? hex2bin($datum) : '');
+
+ $albums = ((array_key_exists('albums', $a->data)) ? $a->data['albums'] : photos_albums_list($a->data['channel'],$a->data['observer']));
+
$tpl = get_markup_template('photos_upload.tpl');
- $o .= replace_macros($tpl,array(
+ $upload_form = replace_macros($tpl,array(
'$pagename' => t('Upload Photos'),
'$sessid' => session_id(),
'$usage' => $usage_message,
'$nickname' => $a->data['channel']['channel_address'],
- '$newalbum' => t('New album name: '),
- '$existalbumtext' => t('or existing album name: '),
+ '$newalbum_label' => t('Enter a new album name'),
+ '$newalbum_placeholder' => t('or select an existing one (doubleclick)'),
'$nosharetext' => t('Do not show a status post for this upload'),
- '$albumselect' => $albumselect_e,
+ '$albums' => $albums['albums'],
+ '$selname' => $selname,
'$permissions' => t('Permissions'),
'$aclselect' => $aclselect_e,
+ '$lockstate' => $lockstate,
'$uploader' => $ret['addon_text'],
- '$default' => (($ret['default_upload']) ? $default_upload : ''),
- '$uploadurl' => $ret['post_url']
+ '$default' => (($ret['default_upload']) ? true : false),
+ '$uploadurl' => $ret['post_url'],
+ '$submit' => t('Submit')
));
- return $o;
}
+ //
+ // dispatch request
+ //
+
/*
* Display a single photo album
*/
if($datatype === 'album') {
+
+
if((strlen($datum) & 1) || (! ctype_xdigit($datum))) {
notice( t('Album name could not be decoded') . EOL);
logger('mod_photos: illegal album encoding: ' . $datum);
@@ -627,15 +618,17 @@ function photos_content(&$a) {
$album = hex2bin($datum);
$r = q("SELECT `resource_id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` = '%s'
- AND `scale` <= 4 and (photo_flags = %d or photo_flags = %d ) $sql_extra GROUP BY `resource_id`",
+ AND `scale` <= 4 and ((photo_flags = %d) or (photo_flags & %d )) $sql_extra GROUP BY `resource_id`",
intval($owner_uid),
dbesc($album),
intval(PHOTO_NORMAL),
- intval(PHOTO_PROFILE)
+ intval(($unsafe) ? (PHOTO_PROFILE|PHOTO_ADULT) : PHOTO_PROFILE)
);
if(count($r)) {
$a->set_pager_total(count($r));
$a->set_pager_itemspage(60);
+ } else {
+ goaway($a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address']);
}
if($_GET['order'] === 'posted')
@@ -644,42 +637,37 @@ function photos_content(&$a) {
$order = 'DESC';
$r = q("SELECT `resource_id`, `id`, `filename`, type, max(`scale`) AS `scale`, `description` FROM `photo` WHERE `uid` = %d AND `album` = '%s'
- AND `scale` <= 4 and (photo_flags = %d or photo_flags = %d ) $sql_extra GROUP BY `resource_id` ORDER BY `created` $order LIMIT %d , %d",
+ AND `scale` <= 4 and ((photo_flags = %d) or (photo_flags & %d )) $sql_extra GROUP BY `resource_id` ORDER BY `created` $order LIMIT %d , %d",
intval($owner_uid),
dbesc($album),
intvaL(PHOTO_NORMAL),
- intval(PHOTO_PROFILE),
+ intval(($unsafe) ? (PHOTO_PROFILE|PHOTO_ADULT) : PHOTO_PROFILE),
intval($a->pager['start']),
intval($a->pager['itemspage'])
);
- if($cmd === 'edit') {
- if(($album !== t('Profile Photos')) && ($album !== 'Profile Photos') && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) {
- if($can_post) {
- if($a->get_template_engine() === 'internal') {
- $album_e = template_escape($album);
- }
- else {
- $album_e = $album;
- }
-
- $edit_tpl = get_markup_template('album_edit.tpl');
- $o .= replace_macros($edit_tpl,array(
- '$nametext' => t('New album name: '),
- '$nickname' => $a->data['channel']['channel_address'],
- '$album' => $album_e,
- '$hexalbum' => bin2hex($album),
- '$submit' => t('Submit'),
- '$dropsubmit' => t('Delete Album')
- ));
+ //edit album name
+ $album_edit = null;
+ if(($album !== t('Profile Photos')) && ($album !== 'Profile Photos') && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) {
+ if($can_post) {
+ if($a->get_template_engine() === 'internal') {
+ $album_e = template_escape($album);
}
- }
- }
- else {
- if(($album !== t('Profile Photos')) && ($album !== 'Profile Photos') && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) {
- if($can_post) {
- $edit = array(t('Edit Album'), $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($album) . '/edit');
- }
+ else {
+ $album_e = $album;
+ }
+ $albums = ((array_key_exists('albums', $a->data)) ? $a->data['albums'] : photos_albums_list($a->data['channel'],$a->data['observer']));
+ $edit_tpl = get_markup_template('album_edit.tpl');
+ $album_edit = replace_macros($edit_tpl,array(
+ '$nametext' => t('Enter a new album name'),
+ '$name_placeholder' => t('or select an existing one (doubleclick)'),
+ '$nickname' => $a->data['channel']['channel_address'],
+ '$album' => $album_e,
+ '$albums' => $albums['albums'],
+ '$hexalbum' => bin2hex($album),
+ '$submit' => t('Submit'),
+ '$dropsubmit' => t('Delete Album')
+ ));
}
}
@@ -719,6 +707,7 @@ function photos_content(&$a) {
'desc'=> $desc_e,
'ext' => $ext,
'hash'=> $rr['resource_id'],
+ 'unknown' => t('Unknown')
);
}
}
@@ -741,10 +730,12 @@ function photos_content(&$a) {
$o .= replace_macros($tpl, array(
'$photos' => $photos,
'$album' => $album,
+ '$album_edit' => array(t('Edit Album'), $album_edit),
'$can_post' => $can_post,
'$upload' => array(t('Upload'), $a->get_baseurl() . '/photos/' . $a->data['channel']['channel_address'] . '/upload/' . bin2hex($album)),
'$order' => $order,
- '$edit' => $edit
+ '$upload_form' => $upload_form,
+ '$usage' => $usage_message
));
}
@@ -770,25 +761,18 @@ function photos_content(&$a) {
// fetch image, item containing image, then comments
$ph = q("SELECT aid,uid,xchan,resource_id,created,edited,title,`description`,album,filename,`type`,height,width,`size`,scale,profile,photo_flags,allow_cid,allow_gid,deny_cid,deny_gid FROM `photo` WHERE `uid` = %d AND `resource_id` = '%s'
- and (photo_flags = %d or photo_flags = %d ) $sql_extra ORDER BY `scale` ASC ",
+ $sql_extra ORDER BY `scale` ASC ",
intval($owner_uid),
- dbesc($datum),
- intval(PHOTO_NORMAL),
- intval(PHOTO_PROFILE)
-
+ dbesc($datum)
);
if(! $ph) {
/* Check again - this time without specifying permissions */
- $ph = q("SELECT id FROM photo WHERE uid = %d AND resource_id = '%s'
- and ( photo_flags = %d or photo_flags = %d )
- LIMIT 1",
+ $ph = q("SELECT id FROM photo WHERE uid = %d AND resource_id = '%s' LIMIT 1",
intval($owner_uid),
- dbesc($datum),
- intval(PHOTO_NORMAL),
- intval(PHOTO_PROFILE)
+ dbesc($datum)
);
if($ph)
notice( t('Permission denied. Access to this item may be restricted.') . EOL);
@@ -809,11 +793,9 @@ function photos_content(&$a) {
$prvnxt = q("SELECT `resource_id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0
- and ( photo_flags = %d or photo_flags = %d ) $sql_extra ORDER BY `created` $order ",
+ $sql_extra ORDER BY `created` $order ",
dbesc($ph[0]['album']),
- intval($owner_uid),
- intval(PHOTO_NORMAL),
- intval(PHOTO_PROFILE)
+ intval($owner_uid)
);
if(count($prvnxt)) {
@@ -857,11 +839,11 @@ function photos_content(&$a) {
);
}
- // lock
- $lock = ( ( (strlen($ph[0]['allow_cid']) || strlen($ph[0]['allow_gid'])
+ // lockstate
+ $lockstate = ( ( (strlen($ph[0]['allow_cid']) || strlen($ph[0]['allow_gid'])
|| strlen($ph[0]['deny_cid']) || strlen($ph[0]['deny_gid'])) )
- ? t('Private Photo')
- : Null);
+ ? array('lock', t('Private Photo'))
+ : array('unlock', Null));
$a->page['htmlhead'] .= '<script>$(document).keydown(function(event) {' . "\n";
if($prevlink)
@@ -910,21 +892,19 @@ function photos_content(&$a) {
$r = conv_sort($r,'commented');
}
-
-
$tags = array();
if($link_item['term']) {
$cnt = 0;
- foreach($link_item['term'] as $t)
+ foreach($link_item['term'] as $t) {
$tags[$cnt] = array(0 => format_term_for_display($t));
if($can_post && ($ph[0]['uid'] == $owner_uid)) {
- $tags[$cnt][1] = 'tagrm?f=&item=' . $link_item['id'];
+ $tags[$cnt][1] = 'tagrm/drop/' . $link_item['id'] . '/' . bin2hex($t['term']); //?f=&item=' . $link_item['id'];
$tags[$cnt][2] = t('Remove');
}
$cnt ++;
+ }
}
-
if((local_user()) && (local_user() == $link_item['uid'])) {
q("UPDATE `item` SET item_flags = (item_flags ^ %d) WHERE parent = %d and uid = %d and (item_flags & %d)",
intval(ITEM_UNSEEN),
@@ -943,23 +923,22 @@ function photos_content(&$a) {
$edit = null;
if($can_post) {
- if(array_key_exists('albums', $a->data))
- $albums = get_app()->data['albums'];
- else
- $albums = photos_albums_list($a->data['channel'],$a->data['observer']);
-
$album_e = $ph[0]['album'];
$caption_e = $ph[0]['description'];
$aclselect_e = populate_acl($ph[0]);
+ $albums = ((array_key_exists('albums', $a->data)) ? $a->data['albums'] : photos_albums_list($a->data['channel'],$a->data['observer']));
+
+ $_SESSION['album_return'] = bin2hex($ph[0]['album']);
$edit = array(
'edit' => t('Edit photo'),
- 'id' => $link_item['id'], //$ph[0]['id'],
+ 'id' => $link_item['id'],
'rotatecw' => t('Rotate CW (right)'),
'rotateccw' => t('Rotate CCW (left)'),
'albums' => $albums['albums'],
'album' => $album_e,
- 'newalbum' => t('New album name'),
+ 'newalbum_label' => t('Enter a new album name'),
+ 'newalbum_placeholder' => t('or select an existing one (doubleclick)'),
'nickname' => $a->data['channel']['channel_address'],
'resource_id' => $ph[0]['resource_id'],
'capt_label' => t('Caption'),
@@ -967,8 +946,10 @@ function photos_content(&$a) {
'tag_label' => t('Add a Tag'),
'permissions' => t('Permissions'),
'aclselect' => $aclselect_e,
- 'help_tags' => t('Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping'),
+ 'lockstate' => $lockstate[0],
+ 'help_tags' => t('Example: @bob, @Barbara_Jensen, @jim@example.com'),
'item_id' => ((count($linked_items)) ? $link_item['id'] : 0),
+ 'adult' => array('adult',t('Flag as adult in album view'), (($ph[0]['photo_flags'] & PHOTO_ADULT) ? 1 : 0),''),
'submit' => t('Submit'),
'delete' => t('Delete Photo')
);
@@ -1023,7 +1004,7 @@ function photos_content(&$a) {
$like = '';
$dislike = '';
- // display comments
+
if($r) {
foreach($r as $item) {
@@ -1031,10 +1012,33 @@ function photos_content(&$a) {
like_puller($a,$item,$dlike,'dislike');
}
- $like = ((isset($alike[$link_item['id']])) ? format_like($alike[$link_item['id']],$alike[$link_item['id'] . '-l'],'like',$link_item['id']) : '');
- $dislike = ((isset($dlike[$link_item['id']])) ? format_like($dlike[$link_item['id']],$dlike[$link_item['id'] . '-l'],'dislike',$link_item['id']) : '');
+ $like_count = ((x($alike,$link_item['mid'])) ? $alike[$link_item['mid']] : '');
+ $like_list = ((x($alike,$link_item['mid'])) ? $alike[$link_item['mid'] . '-l'] : '');
+ if (count($like_list) > MAX_LIKERS) {
+ $like_list_part = array_slice($like_list, 0, MAX_LIKERS);
+ array_push($like_list_part, '<a href="#" data-toggle="modal" data-target="#likeModal-' . $this->get_id() . '"><b>' . t('View all') . '</b></a>');
+ } else {
+ $like_list_part = '';
+ }
+ $like_button_label = tt('Like','Likes',$like_count,'noun');
+
+ //if (feature_enabled($conv->get_profile_owner(),'dislike')) {
+ $dislike_count = ((x($dlike,$link_item['mid'])) ? $dlike[$link_item['mid']] : '');
+ $dislike_list = ((x($dlike,$link_item['mid'])) ? $dlike[$link_item['mid'] . '-l'] : '');
+ $dislike_button_label = tt('Dislike','Dislikes',$dislike_count,'noun');
+ if (count($dislike_list) > MAX_LIKERS) {
+ $dislike_list_part = array_slice($dislike_list, 0, MAX_LIKERS);
+ array_push($dislike_list_part, '<a href="#" data-toggle="modal" data-target="#dislikeModal-' . $this->get_id() . '"><b>' . t('View all') . '</b></a>');
+ } else {
+ $dislike_list_part = '';
+ }
+ //}
+
+ $like = ((isset($alike[$link_item['mid']])) ? format_like($alike[$link_item['mid']],$alike[$link_item['mid'] . '-l'],'like',$link_item['mid']) : '');
+ $dislike = ((isset($dlike[$link_item['mid']])) ? format_like($dlike[$link_item['mid']],$dlike[$link_item['mid'] . '-l'],'dislike',$link_item['mid']) : '');
+ // display comments
foreach($r as $item) {
$comment = '';
@@ -1115,7 +1119,7 @@ function photos_content(&$a) {
'$id' => $link_item['id'], //$ph[0]['id'],
'$album' => $album_e,
'$tools' => $tools,
- '$lock' => $lock,
+ '$lock' => $lockstate[1],
'$photo' => $photo,
'$prevlink' => $prevlink,
'$nextlink' => $nextlink,
@@ -1128,6 +1132,17 @@ function photos_content(&$a) {
'$likebuttons' => $likebuttons,
'$like' => $like_e,
'$dislike' => $dislike_e,
+ '$like_count' => $like_count,
+ '$like_list' => $like_list,
+ '$like_list_part' => $like_list_part,
+ '$like_button_label' => $like_button_label,
+ '$like_modal_title' => t('Likes','noun'),
+ '$dislike_modal_title' => t('Dislikes','noun'),
+ '$dislike_count' => $dislike_count, //((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike_count : ''),
+ '$dislike_list' => $dislike_list, //((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike_list : ''),
+ '$dislike_list_part' => $dislike_list_part, //((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike_list_part : ''),
+ '$dislike_button_label' => $dislike_button_label, //((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike_button_label : ''),
+ '$modal_dismiss' => t('Close'),
'$comments' => $comments,
'$commentbox' => $commentbox,
'$paginate' => $paginate,
@@ -1142,12 +1157,12 @@ function photos_content(&$a) {
//$o = '';
$r = q("SELECT `resource_id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
- and ( photo_flags = %d or photo_flags = %d ) $sql_extra GROUP BY `resource_id`",
+ and ((photo_flags = %d) or (photo_flags & %d)) $sql_extra GROUP BY `resource_id`",
intval($a->data['channel']['channel_id']),
dbesc('Contact Photos'),
dbesc( t('Contact Photos')),
intval(PHOTO_NORMAL),
- intval(PHOTO_PROFILE)
+ intval(($unsafe) ? (PHOTO_PROFILE|PHOTO_ADULT) : PHOTO_PROFILE)
);
if(count($r)) {
$a->set_pager_total(count($r));
@@ -1156,13 +1171,13 @@ function photos_content(&$a) {
$r = q("SELECT `resource_id`, `id`, `filename`, type, `album`, max(`scale`) AS `scale` FROM `photo`
WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
- and ( photo_flags = %d or photo_flags = %d )
+ and ( (photo_flags = %d) or (photo_flags & %d ))
$sql_extra GROUP BY `resource_id` ORDER BY `created` DESC LIMIT %d , %d",
intval($a->data['channel']['channel_id']),
dbesc('Contact Photos'),
dbesc( t('Contact Photos')),
intval(PHOTO_NORMAL),
- intval(PHOTO_PROFILE),
+ intval(($unsafe) ? (PHOTO_PROFILE|PHOTO_ADULT) : PHOTO_PROFILE),
intval($a->pager['start']),
intval($a->pager['itemspage'])
);
@@ -1225,6 +1240,8 @@ function photos_content(&$a) {
'$can_post' => $can_post,
'$upload' => array(t('Upload'), $a->get_baseurl().'/photos/'.$a->data['channel']['channel_address'].'/upload'),
'$photos' => $photos,
+ '$upload_form' => $upload_form,
+ '$usage' => $usage_message
));
}
diff --git a/mod/ping.php b/mod/ping.php
index 49475de66..98584cb14 100644
--- a/mod/ping.php
+++ b/mod/ping.php
@@ -41,6 +41,19 @@ function ping_init(&$a) {
header("content-type: application/json");
+ $vnotify = false;
+
+ if(local_user()) {
+ $vnotify = get_pconfig(local_user(),'system','vnotify');
+ $evdays = intval(get_pconfig(local_user(),'system','evdays'));
+ }
+
+ // if unset show all visual notification types
+ if($vnotify === false)
+ $vnotify = (-1);
+ if($evdays < 1)
+ $evdays = 3;
+
/**
* If you have several windows open to this site and switch to a different channel
* in one of them, the others may get into a confused state showing you a page or options
@@ -71,6 +84,11 @@ function ping_init(&$a) {
}
unset($_SESSION['sysmsg_info']);
}
+ if(! ($vnotify & VNOTIFY_INFO))
+ $result['info'] = array();
+ if(! ($vnotify & VNOTIFY_ALERT))
+ $result['notice'] = array();
+
if($a->install) {
echo json_encode($result);
@@ -303,7 +321,7 @@ function ping_init(&$a) {
WHERE `event`.`uid` = %d AND start < '%s' AND start > '%s' and `ignore` = 0
ORDER BY `start` DESC ",
intval(local_user()),
- dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + 7 days')),
+ dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + ' . intval($evdays) . ' days')),
dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days'))
);
@@ -341,101 +359,125 @@ function ping_init(&$a) {
* Normal ping - just the counts, no detail
*/
- $t = q("select count(*) as total from notify where uid = %d and seen = 0",
- intval(local_user())
- );
- if($t)
- $result['notify'] = intval($t[0]['total']);
+ if($vnotify & VNOTIFY_SYSTEM) {
+ $t = q("select count(*) as total from notify where uid = %d and seen = 0",
+ intval(local_user())
+ );
+ if($t)
+ $result['notify'] = intval($t[0]['total']);
+ }
$t1 = dba_timer();
- $r = q("SELECT id, item_restrict, item_flags FROM item
- WHERE (item_restrict = %d) and ( item_flags & %d ) and uid = %d",
- intval(ITEM_VISIBLE),
- intval(ITEM_UNSEEN),
- intval(local_user())
- );
+ if($vnotify & (VNOTIFY_NETWORK|VNOTIFY_CHANNEL)) {
+ $r = q("SELECT id, item_restrict, item_flags FROM item
+ WHERE (item_restrict = %d) and ( item_flags & %d ) and uid = %d",
+ intval(ITEM_VISIBLE),
+ intval(ITEM_UNSEEN),
+ intval(local_user())
+ );
- if(count($r)) {
- $arr = array('items' => $r);
- call_hooks('network_ping', $arr);
+ if($r) {
+ $arr = array('items' => $r);
+ call_hooks('network_ping', $arr);
- foreach ($r as $it) {
- if($it['item_flags'] & ITEM_WALL)
- $result['home'] ++;
- else
- $result['network'] ++;
+ foreach ($r as $it) {
+ if($it['item_flags'] & ITEM_WALL)
+ $result['home'] ++;
+ else
+ $result['network'] ++;
+ }
}
}
+ if(! ($vnotify & VNOTIFY_NETWORK))
+ $result['network'] = 0;
+ if(! ($vnotify & VNOTIFY_CHANNEL))
+ $result['home'] = 0;
+
$t2 = dba_timer();
- $intr = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d) and not ((abook_flags & %d) or (xchan_flags & %d))",
- intval(local_user()),
- intval(ABOOK_FLAG_PENDING),
- intval(ABOOK_FLAG_SELF|ABOOK_FLAG_IGNORED),
- intval(XCHAN_FLAGS_DELETED|XCHAN_FLAGS_ORPHAN)
- );
+ if($vnotify & VNOTIFY_INTRO) {
+ $intr = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d) and not ((abook_flags & %d) or (xchan_flags & %d))",
+ intval(local_user()),
+ intval(ABOOK_FLAG_PENDING),
+ intval(ABOOK_FLAG_SELF|ABOOK_FLAG_IGNORED),
+ intval(XCHAN_FLAGS_DELETED|XCHAN_FLAGS_ORPHAN)
+ );
- $t3 = dba_timer();
+ $t3 = dba_timer();
- if($intr)
- $result['intros'] = intval($intr[0]['total']);
+ if($intr)
+ $result['intros'] = intval($intr[0]['total']);
+ }
$t4 = dba_timer();
$channel = get_app()->get_channel();
- $mails = q("SELECT count(id) as total from mail
- WHERE channel_id = %d AND not (mail_flags & %d) and from_xchan != '%s' ",
- intval(local_user()),
- intval(MAIL_SEEN),
- dbesc($channel['channel_hash'])
- );
- if($mails)
- $result['mail'] = intval($mails[0]['total']);
-
- if ($a->config['system']['register_policy'] == REGISTER_APPROVE && is_site_admin()) {
- $regs = q("SELECT count(account_id) as total from account where (account_flags & %d)",
- intval(ACCOUNT_PENDING)
+ if($vnotify & VNOTIFY_MAIL) {
+ $mails = q("SELECT count(id) as total from mail
+ WHERE channel_id = %d AND not (mail_flags & %d) and from_xchan != '%s' ",
+ intval(local_user()),
+ intval(MAIL_SEEN),
+ dbesc($channel['channel_hash'])
);
- if($regs)
- $result['register'] = intval($regs[0]['total']);
+ if($mails)
+ $result['mail'] = intval($mails[0]['total']);
+ }
+
+ if($vnotify & VNOTIFY_REGISTER) {
+ if ($a->config['system']['register_policy'] == REGISTER_APPROVE && is_site_admin()) {
+ $regs = q("SELECT count(account_id) as total from account where (account_flags & %d)",
+ intval(ACCOUNT_PENDING)
+ );
+ if($regs)
+ $result['register'] = intval($regs[0]['total']);
+ }
}
$t5 = dba_timer();
- $events = q("SELECT type, start, adjust FROM `event`
- WHERE `event`.`uid` = %d AND start < '%s' AND start > '%s' and `ignore` = 0
- ORDER BY `start` ASC ",
- intval(local_user()),
- dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + 7 days')),
- dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days'))
- );
-
- if($events) {
- $result['all_events'] = count($events);
-
- if($result['all_events']) {
- $str_now = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y-m-d');
- foreach($events as $x) {
- $bd = false;
- if($x['type'] === 'birthday') {
- $result['birthdays'] ++;
- $bd = true;
- }
- else {
- $result['events'] ++;
- }
- if(datetime_convert('UTC', ((intval($x['adjust'])) ? date_default_timezone_get() : 'UTC'), $x['start'], 'Y-m-d') === $str_now) {
- $result['all_events_today'] ++;
- if($bd)
- $result['birthdays_today'] ++;
- else
- $result['events_today'] ++;
+ if($vnotify & (VNOTIFY_EVENT|VNOTIFY_EVENTTODAY|VNOTIFY_BIRTHDAY)) {
+ $events = q("SELECT type, start, adjust FROM `event`
+ WHERE `event`.`uid` = %d AND start < '%s' AND start > '%s' and `ignore` = 0
+ ORDER BY `start` ASC ",
+ intval(local_user()),
+ dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + ' . intval($evdays) . ' days')),
+ dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days'))
+ );
+
+ if($events) {
+ $result['all_events'] = count($events);
+
+ if($result['all_events']) {
+ $str_now = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y-m-d');
+ foreach($events as $x) {
+ $bd = false;
+ if($x['type'] === 'birthday') {
+ $result['birthdays'] ++;
+ $bd = true;
+ }
+ else {
+ $result['events'] ++;
+ }
+ if(datetime_convert('UTC', ((intval($x['adjust'])) ? date_default_timezone_get() : 'UTC'), $x['start'], 'Y-m-d') === $str_now) {
+ $result['all_events_today'] ++;
+ if($bd)
+ $result['birthdays_today'] ++;
+ else
+ $result['events_today'] ++;
+ }
}
}
}
}
+ if(! ($vnotify & VNOTIFY_EVENT))
+ $result['all_events'] = $result['events'] = 0;
+ if(! ($vnotify & VNOTIFY_EVENTTODAY))
+ $result['all_events_today'] = $result['events_today'] = 0;
+ if(! ($vnotify & VNOTIFY_BIRTHDAY))
+ $result['birthdays'] = 0;
+
$x = json_encode($result);
diff --git a/mod/post.php b/mod/post.php
index d62233ca1..c21af83e4 100644
--- a/mod/post.php
+++ b/mod/post.php
@@ -507,6 +507,7 @@ function post_post(&$a) {
json_return_and_die($ret);
}
+
if($msgtype === 'pickup') {
/**
@@ -597,11 +598,24 @@ function post_post(&$a) {
$ret['success'] = true;
$ret['pickup'] = array();
foreach($r as $rr) {
- $ret['pickup'][] = array('notify' => json_decode($rr['outq_notify'],true),'message' => json_decode($rr['outq_msg'],true));
+ if($rr['outq_msg']) {
+ $x = json_decode($rr['outq_msg'],true);
- $x = q("delete from outq where outq_hash = '%s' limit 1",
- dbesc($rr['outq_hash'])
- );
+ if(! $x)
+ continue;
+
+ if(array_key_exists('message_list',$x)) {
+ foreach($x['message_list'] as $xx) {
+ $ret['pickup'][] = array('notify' => json_decode($rr['outq_notify'],true),'message' => $xx);
+ }
+ }
+ else
+ $ret['pickup'][] = array('notify' => json_decode($rr['outq_notify'],true),'message' => $x);
+
+ $x = q("delete from outq where outq_hash = '%s' limit 1",
+ dbesc($rr['outq_hash'])
+ );
+ }
}
}
@@ -796,6 +810,12 @@ function post_post(&$a) {
json_return_and_die($ret);
}
+ if($msgtype === 'request') {
+ // request a particular post/conversation by message_id
+ $x = zot_process_message_request($data);
+ json_return_and_die($x);
+ }
+
if($msgtype === 'purge') {
if($recipients) {
diff --git a/mod/settings.php b/mod/settings.php
index 876216871..309be0797 100644
--- a/mod/settings.php
+++ b/mod/settings.php
@@ -39,7 +39,9 @@ function settings_post(&$a) {
if(! local_user())
return;
- // logger('mod_settings: ' . print_r($_REQUEST,true));
+ $channel = $a->get_channel();
+
+ logger('mod_settings: ' . print_r($_REQUEST,true));
if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
return;
@@ -152,14 +154,11 @@ function settings_post(&$a) {
set_pconfig(local_user(),'system','mobile_theme',$mobile_theme);
}
-// $chanview_full = ((x($_POST,'chanview_full')) ? intval($_POST['chanview_full']) : 0);
set_pconfig(local_user(),'system','user_scalable',$user_scalable);
set_pconfig(local_user(),'system','update_interval', $browser_update);
set_pconfig(local_user(),'system','itemspage', $itemspage);
set_pconfig(local_user(),'system','no_smilies',$nosmile);
set_pconfig(local_user(),'system','title_tosource',$title_tosource);
-// set_pconfig(local_user(),'system','chanview_full',$chanview_full);
-
if ($theme == $a->channel['channel_theme']){
// call theme_post only if theme has not been changed
@@ -257,14 +256,111 @@ function settings_post(&$a) {
call_hooks('settings_post', $_POST);
-
+ $set_perms = '';
+
+ $role = ((x($_POST,'permissions_role')) ? notags(trim($_POST['permissions_role'])) : '');
+ $oldrole = get_pconfig(local_user(),'system','permissions_role');
+
+ if(($role != $oldrole) || ($role === 'custom')) {
+
+ if($role === 'custom') {
+ $hide_presence = (((x($_POST,'hide_presence')) && (intval($_POST['hide_presence']) == 1)) ? 1: 0);
+ $publish = (((x($_POST,'profile_in_directory')) && (intval($_POST['profile_in_directory']) == 1)) ? 1: 0);
+ $def_group = ((x($_POST,'group-selection')) ? notags(trim($_POST['group-selection'])) : '');
+ $r = q("update channel set channel_default_group = '%s' where channel_id = %d limit 1",
+ dbesc($def_group),
+ intval(local_user())
+ );
+
+ $global_perms = get_perms();
+
+ foreach($global_perms as $k => $v) {
+ $set_perms .= ', ' . $v[0] . ' = ' . intval($_POST[$k]) . ' ';
+ }
+
+ $str_group_allow = perms2str($_POST['group_allow']);
+ $str_contact_allow = perms2str($_POST['contact_allow']);
+ $str_group_deny = perms2str($_POST['group_deny']);
+ $str_contact_deny = perms2str($_POST['contact_deny']);
+ $r = q("update channel set channel_allow_cid = '%s', channel_allow_gid = '%s', channel_deny_cid = '%s', channel_deny_gid = '%s'
+ where channel_id = %d limit 1",
+ dbesc($str_contact_allow),
+ dbesc($str_group_allow),
+ dbesc($str_contact_deny),
+ dbesc($str_group_deny),
+ intval(local_user())
+ );
+ }
+ else {
+ $role_permissions = get_role_perms($_POST['permissions_role']);
+ if(! $role_permissions) {
+ notice('Permissions category could not be found.');
+ return;
+ }
+ $hide_presence = 1 - (intval($role_permissions['online']));
+ if($role_permissions['default_collection']) {
+ $r = q("select hash from groups where uid = %d and name = '%s' limit 1",
+ intval(local_user()),
+ dbesc( t('Friends') )
+ );
+ if(! $r) {
+ require_once('include/group.php');
+ group_add(local_user(), t('Friends'));
+ group_add_member(local_user(),t('Friends'),$channel['channel_hash']);
+ $r = q("select hash from groups where uid = %d and name = '%s' limit 1",
+ intval(local_user()),
+ dbesc( t('Friends') )
+ );
+ }
+ if($r) {
+ q("update channel set channel_default_group = '%s', channel_allow_gid = '%s', channel_allow_cid = '', channel_deny_gid = '', channel_deny_cid = '' where channel_id = %d limit 1",
+ dbesc($r[0]['hash']),
+ dbesc('<' . $r[0]['hash'] . '>'),
+ intval(local_user())
+ );
+ }
+ else {
+ notice( sprintf('Default privacy collection \'%s\' not found. Please create and re-submit permission change.', t('Friends')) . EOL);
+ return;
+ }
+ }
+ // no default collection
+ else {
+ q("update channel set channel_default_group = '', channel_allow_gid = '', channel_allow_cid = '', channel_deny_gid = '',
+ channel_deny_cid = '' where channel_id = %d limit 1",
+ intval(local_user())
+ );
+ }
+
+ $r = q("update abook set abook_my_perms = %d where abook_channel = %d and (abook_flags & %d) limit 1",
+ intval(($role_permissions['perms_auto']) ? intval($role_permissions['perms_accept']) : 0),
+ intval(local_user()),
+ intval(ABOOK_FLAG_SELF)
+ );
+ set_pconfig(local_user(),'system','autoperms',(($role_permissions['perms_auto']) ? intval($role_permissions['perms_accept']) : 0));
+
+ foreach($role_permissions as $p => $v) {
+ if(strpos($p,'channel_') !== false) {
+ $set_perms .= ', ' . $p . ' = ' . intval($v) . ' ';
+ }
+ if($p === 'directory_publish') {
+ $publish = intval($v);
+ }
+ }
+ }
+
+ set_pconfig(local_user(),'system','hide_online_status',$hide_presence);
+ set_pconfig(local_user(),'system','permissions_role',$role);
+ }
+
$username = ((x($_POST,'username')) ? notags(trim($_POST['username'])) : '');
$timezone = ((x($_POST,'timezone')) ? notags(trim($_POST['timezone'])) : '');
$defloc = ((x($_POST,'defloc')) ? notags(trim($_POST['defloc'])) : '');
$openid = ((x($_POST,'openid_url')) ? notags(trim($_POST['openid_url'])) : '');
$maxreq = ((x($_POST,'maxreq')) ? intval($_POST['maxreq']) : 0);
$expire = ((x($_POST,'expire')) ? intval($_POST['expire']) : 0);
- $def_group = ((x($_POST,'group-selection')) ? notags(trim($_POST['group-selection'])) : '');
+ $evdays = ((x($_POST,'evdays')) ? intval($_POST['evdays']) : 3);
+
$channel_menu = ((x($_POST['channel_menu'])) ? htmlspecialchars_decode(trim($_POST['channel_menu']),ENT_QUOTES) : '');
$expire_items = ((x($_POST,'expire_items')) ? intval($_POST['expire_items']) : 0);
@@ -273,17 +369,13 @@ function settings_post(&$a) {
$expire_network_only = ((x($_POST,'expire_network_only'))? intval($_POST['expire_network_only']) : 0);
$allow_location = (((x($_POST,'allow_location')) && (intval($_POST['allow_location']) == 1)) ? 1: 0);
- $hide_presence = (((x($_POST,'hide_presence')) && (intval($_POST['hide_presence']) == 1)) ? 1: 0);
- $publish = (((x($_POST,'profile_in_directory')) && (intval($_POST['profile_in_directory']) == 1)) ? 1: 0);
- $page_flags = (((x($_POST,'page-flags')) && (intval($_POST['page-flags']))) ? intval($_POST['page-flags']) : 0);
- $blockwall = (((x($_POST,'blockwall')) && (intval($_POST['blockwall']) == 1)) ? 0: 1); // this setting is inverted!
+
$blocktags = (((x($_POST,'blocktags')) && (intval($_POST['blocktags']) == 1)) ? 0: 1); // this setting is inverted!
$unkmail = (((x($_POST,'unkmail')) && (intval($_POST['unkmail']) == 1)) ? 1: 0);
$cntunkmail = ((x($_POST,'cntunkmail')) ? intval($_POST['cntunkmail']) : 0);
$suggestme = ((x($_POST,'suggestme')) ? intval($_POST['suggestme']) : 0);
- $hide_friends = (($_POST['hide_friends'] == 1) ? 1: 0);
- $hidewall = (($_POST['hidewall'] == 1) ? 1: 0);
+
$post_newfriend = (($_POST['post_newfriend'] == 1) ? 1: 0);
$post_joingroup = (($_POST['post_joingroup'] == 1) ? 1: 0);
$post_profilechange = (($_POST['post_profilechange'] == 1) ? 1: 0);
@@ -295,63 +387,6 @@ function settings_post(&$a) {
if($adult != $existing_adult)
$pageflags = ($pageflags ^ PAGE_ADULT);
- $arr = array();
- $arr['channel_r_stream'] = (($_POST['view_stream']) ? $_POST['view_stream'] : 0);
- $arr['channel_r_profile'] = (($_POST['view_profile']) ? $_POST['view_profile'] : 0);
- $arr['channel_r_photos'] = (($_POST['view_photos']) ? $_POST['view_photos'] : 0);
- $arr['channel_r_abook'] = (($_POST['view_contacts']) ? $_POST['view_contacts'] : 0);
- $arr['channel_w_stream'] = (($_POST['send_stream']) ? $_POST['send_stream'] : 0);
- $arr['channel_w_wall'] = (($_POST['post_wall']) ? $_POST['post_wall'] : 0);
- $arr['channel_w_tagwall'] = (($_POST['tag_deliver']) ? $_POST['tag_deliver'] : 0);
- $arr['channel_w_comment'] = (($_POST['post_comments']) ? $_POST['post_comments'] : 0);
- $arr['channel_w_mail'] = (($_POST['post_mail']) ? $_POST['post_mail'] : 0);
- $arr['channel_w_photos'] = (($_POST['post_photos']) ? $_POST['post_photos'] : 0);
- $arr['channel_w_chat'] = (($_POST['chat']) ? $_POST['chat'] : 0);
- $arr['channel_a_delegate'] = (($_POST['delegate']) ? $_POST['delegate'] : 0);
- $arr['channel_r_storage'] = (($_POST['view_storage']) ? $_POST['view_storage'] : 0);
- $arr['channel_w_storage'] = (($_POST['write_storage']) ? $_POST['write_storage'] : 0);
- $arr['channel_r_pages'] = (($_POST['view_pages']) ? $_POST['view_pages'] : 0);
- $arr['channel_w_pages'] = (($_POST['write_pages']) ? $_POST['write_pages'] : 0);
- $arr['channel_a_republish'] = (($_POST['republish']) ? $_POST['republish'] : 0);
- $arr['channel_w_like'] = (($_POST['post_like']) ? $_POST['post_like'] : 0);
-
- $defperms = 0;
- if(x($_POST['def_view_stream']))
- $defperms += $_POST['def_view_stream'];
- if(x($_POST['def_view_profile']))
- $defperms += $_POST['def_view_profile'];
- if(x($_POST['def_view_photos']))
- $defperms += $_POST['def_view_photos'];
- if(x($_POST['def_view_contacts']))
- $defperms += $_POST['def_view_contacts'];
- if(x($_POST['def_send_stream']))
- $defperms += $_POST['def_send_stream'];
- if(x($_POST['def_post_wall']))
- $defperms += $_POST['def_post_wall'];
- if(x($_POST['def_tag_deliver']))
- $defperms += $_POST['def_tag_deliver'];
- if(x($_POST['def_post_comments']))
- $defperms += $_POST['def_post_comments'];
- if(x($_POST['def_post_mail']))
- $defperms += $_POST['def_post_mail'];
- if(x($_POST['def_post_photos']))
- $defperms += $_POST['def_post_photos'];
- if(x($_POST['def_chat']))
- $defperms += $_POST['def_chat'];
- if(x($_POST['def_delegate']))
- $defperms += $_POST['def_delegate'];
- if(x($_POST['def_view_storage']))
- $defperms += $_POST['def_view_storage'];
- if(x($_POST['def_write_storage']))
- $defperms += $_POST['def_write_storage'];
- if(x($_POST['def_view_pages']))
- $defperms += $_POST['def_view_pages'];
- if(x($_POST['def_write_pages']))
- $defperms += $_POST['def_write_pages'];
- if(x($_POST['def_republish']))
- $defperms += $_POST['def_republish'];
- if(x($_POST['def_post_like']))
- $defperms += $_POST['def_post_like'];
$notify = 0;
@@ -373,6 +408,31 @@ function settings_post(&$a) {
$notify += intval($_POST['notify8']);
+ $vnotify = 0;
+
+ if(x($_POST,'vnotify1'))
+ $vnotify += intval($_POST['vnotify1']);
+ if(x($_POST,'vnotify2'))
+ $vnotify += intval($_POST['vnotify2']);
+ if(x($_POST,'vnotify3'))
+ $vnotify += intval($_POST['vnotify3']);
+ if(x($_POST,'vnotify4'))
+ $vnotify += intval($_POST['vnotify4']);
+ if(x($_POST,'vnotify5'))
+ $vnotify += intval($_POST['vnotify5']);
+ if(x($_POST,'vnotify6'))
+ $vnotify += intval($_POST['vnotify6']);
+ if(x($_POST,'vnotify7'))
+ $vnotify += intval($_POST['vnotify7']);
+ if(x($_POST,'vnotify8'))
+ $vnotify += intval($_POST['vnotify8']);
+ if(x($_POST,'vnotify9'))
+ $vnotify += intval($_POST['vnotify9']);
+ if(x($_POST,'vnotify10'))
+ $vnotify += intval($_POST['vnotify10']);
+ if(x($_POST,'vnotify11'))
+ $vnotify += intval($_POST['vnotify11']);
+
$channel = $a->get_channel();
$err = '';
@@ -389,27 +449,22 @@ function settings_post(&$a) {
}
}
-
if($timezone != $channel['channel_timezone']) {
if(strlen($timezone))
date_default_timezone_set($timezone);
}
- $str_group_allow = perms2str($_POST['group_allow']);
- $str_contact_allow = perms2str($_POST['contact_allow']);
- $str_group_deny = perms2str($_POST['group_deny']);
- $str_contact_deny = perms2str($_POST['contact_deny']);
-
set_pconfig(local_user(),'system','use_browser_location',$allow_location);
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);
set_pconfig(local_user(),'system','blocktags',$blocktags);
- set_pconfig(local_user(),'system','hide_online_status',$hide_presence);
set_pconfig(local_user(),'system','channel_menu',$channel_menu);
+ set_pconfig(local_user(),'system','vnotify',$vnotify);
+ set_pconfig(local_user(),'system','evdays',$evdays);
- $r = q("update channel set channel_name = '%s', channel_pageflags = %d, channel_timezone = '%s', channel_location = '%s', channel_notifyflags = %d, channel_max_anon_mail = %d, channel_max_friend_req = %d, channel_expire_days = %d, channel_default_group = '%s', channel_r_stream = %d, channel_r_profile = %d, channel_r_photos = %d, channel_r_abook = %d, channel_w_stream = %d, channel_w_wall = %d, channel_w_tagwall = %d, channel_w_comment = %d, channel_w_mail = %d, channel_w_photos = %d, channel_w_chat = %d, channel_a_delegate = %d, channel_r_storage = %d, channel_w_storage = %d, channel_r_pages = %d, channel_w_pages = %d, channel_a_republish = %d, channel_w_like = %d, channel_allow_cid = '%s', channel_allow_gid = '%s', channel_deny_cid = '%s', channel_deny_gid = '%s' where channel_id = %d limit 1",
+ $r = q("update channel set channel_name = '%s', channel_pageflags = %d, channel_timezone = '%s', channel_location = '%s', channel_notifyflags = %d, channel_max_anon_mail = %d, channel_max_friend_req = %d, channel_expire_days = %d $set_perms where channel_id = %d limit 1",
dbesc($username),
intval($pageflags),
dbesc($timezone),
@@ -418,42 +473,17 @@ function settings_post(&$a) {
intval($unkmail),
intval($maxreq),
intval($expire),
- dbesc($def_group),
- intval($arr['channel_r_stream']),
- intval($arr['channel_r_profile']),
- intval($arr['channel_r_photos']),
- intval($arr['channel_r_abook']),
- intval($arr['channel_w_stream']),
- intval($arr['channel_w_wall']),
- intval($arr['channel_w_tagwall']),
- intval($arr['channel_w_comment']),
- intval($arr['channel_w_mail']),
- intval($arr['channel_w_photos']),
- intval($arr['channel_w_chat']),
- intval($arr['channel_a_delegate']),
- intval($arr['channel_r_storage']),
- intval($arr['channel_w_storage']),
- intval($arr['channel_r_pages']),
- intval($arr['channel_w_pages']),
- intval($arr['channel_a_republish']),
- intval($arr['channel_w_like']),
- dbesc($str_contact_allow),
- dbesc($str_group_allow),
- dbesc($str_contact_deny),
- dbesc($str_group_deny),
intval(local_user())
);
if($r)
info( t('Settings updated.') . EOL);
- $r = q("UPDATE `profile`
- SET `publish` = %d,
- `hide_friends` = %d
- WHERE `is_default` = 1 AND `uid` = %d LIMIT 1",
- intval($publish),
- intval($hide_friends),
- intval(local_user())
- );
+ if(! is_null($publish)) {
+ $r = q("UPDATE profile SET publish = %d WHERE is_default = 1 AND uid = %d LIMIT 1",
+ intval($publish),
+ intval(local_user())
+ );
+ }
if($name_change) {
$r = q("update xchan set xchan_name = '%s', xchan_name_date = '%s' where xchan_hash = '%s' limit 1",
@@ -786,8 +816,6 @@ function settings_content(&$a) {
require_once('include/permissions.php');
-
-
$p = q("SELECT * FROM `profile` WHERE `is_default` = 1 AND `uid` = %d LIMIT 1",
intval(local_user())
);
@@ -840,9 +868,8 @@ function settings_content(&$a) {
$expire = $channel['channel_expire_days'];
$adult_flag = intval($channel['channel_pageflags'] & PAGE_ADULT);
- $blockwall = $a->user['blockwall'];
- $unkmail = $a->user['unkmail'];
- $cntunkmail = $a->user['cntunkmail'];
+// $unkmail = $a->user['unkmail'];
+// $cntunkmail = $a->user['cntunkmail'];
$hide_presence = intval(get_pconfig(local_user(), 'system','hide_online_status'));
@@ -880,8 +907,6 @@ function settings_content(&$a) {
$timezone = date_default_timezone_get();
-
-
$opt_tpl = get_markup_template("field_yesno.tpl");
if(get_config('system','publish_all')) {
$profile_in_dir = '<input type="hidden" name="profile_in_directory" value="1" />';
@@ -935,9 +960,15 @@ function settings_content(&$a) {
}
}
+ $evdays = get_pconfig(local_user(),'system','evdays');
+ if(! $evdays)
+ $evdays = 3;
$permissions_role = get_pconfig(local_user(),'system','permissions_role');
$permissions_set = (($permissions_role && $permissions_role != 'custom') ? true : false);
+ $vnotify = get_pconfig(local_user(),'system','vnotify');
+ if($vnotify === false)
+ $vnotify = (-1);
$o .= replace_macros($stpl,array(
'$ptitle' => t('Channel Settings'),
@@ -980,9 +1011,10 @@ function settings_content(&$a) {
'$permdesc' => t("\x28click to open/close\x29"),
'$aclselect' => populate_acl($perm_defaults,false),
'$suggestme' => $suggestme,
-
'$group_select' => $group_select,
+ '$role_lbl' => t('Channel permissions category:'),
+ '$role_select' => role_selector($permissions_role),
'$profile_in_dir' => $profile_in_dir,
'$hide_friends' => $hide_friends,
@@ -1006,7 +1038,23 @@ function settings_content(&$a) {
'$notify7' => array('notify7', t('You are tagged in a post'), ($notify & NOTIFY_TAGSELF), NOTIFY_TAGSELF, ''),
'$notify8' => array('notify8', t('You are poked/prodded/etc. in a post'), ($notify & NOTIFY_POKE), NOTIFY_POKE, ''),
-
+
+ '$lbl_vnot' => t('Show visual notifications including:'),
+
+ '$vnotify1' => array('vnotify1', t('Unseen matrix activity'), ($vnotify & VNOTIFY_NETWORK), VNOTIFY_NETWORK, ''),
+ '$vnotify2' => array('vnotify2', t('Unseen channel activity'), ($vnotify & VNOTIFY_CHANNEL), VNOTIFY_CHANNEL, ''),
+ '$vnotify3' => array('vnotify3', t('Unseen private messages'), ($vnotify & VNOTIFY_MAIL), VNOTIFY_MAIL, t('Recommended')),
+ '$vnotify4' => array('vnotify4', t('Upcoming events'), ($vnotify & VNOTIFY_EVENT), VNOTIFY_EVENT, ''),
+ '$vnotify5' => array('vnotify5', t('Events today'), ($vnotify & VNOTIFY_EVENTTODAY), VNOTIFY_EVENTTODAY, ''),
+ '$vnotify6' => array('vnotify6', t('Upcoming birthdays'), ($vnotify & VNOTIFY_BIRTHDAY), VNOTIFY_BIRTHDAY, t('Not available in all themes')),
+ '$vnotify7' => array('vnotify7', t('System (personal) notifications'), ($vnotify & VNOTIFY_SYSTEM), VNOTIFY_SYSTEM, ''),
+ '$vnotify8' => array('vnotify8', t('System info messages'), ($vnotify & VNOTIFY_INFO), VNOTIFY_INFO, t('Recommended')),
+ '$vnotify9' => array('vnotify9', t('System critical alerts'), ($vnotify & VNOTIFY_ALERT), VNOTIFY_ALERT, t('Recommended')),
+ '$vnotify10' => array('vnotify10', t('New connections'), ($vnotify & VNOTIFY_INTRO), VNOTIFY_INTRO, t('Recommended')),
+ '$vnotify11' => array('vnotify11', t('System Registrations'), ($vnotify & VNOTIFY_REGISTER), VNOTIFY_REGISTER, ''),
+
+ '$evdays' => array('evdays', t('Notify me of events this many days in advance'), $evdays, t('Must be greater than 0')),
+
'$h_advn' => t('Advanced Account/Page Type Settings'),
'$h_descadvn' => t('Change the behaviour of this account for special situations'),
'$pagetype' => $pagetype,
diff --git a/mod/tagrm.php b/mod/tagrm.php
index 957cf0d71..38787cb0b 100644
--- a/mod/tagrm.php
+++ b/mod/tagrm.php
@@ -19,24 +19,27 @@ function tagrm_post(&$a) {
intval(local_user())
);
- if(! count($r))
+ if(! $r)
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
- $arr = explode(',', $r[0]['tag']);
- for($x = 0; $x < count($arr); $x ++) {
- if($arr[$x] === $tag) {
- unset($arr[$x]);
- break;
+ $r = fetch_post_tags($r,true);
+
+ $item = $r[0];
+ $new_tags = array();
+
+ if($item['term']) {
+ for($x = 0; $x < count($item['term']); $x ++) {
+ if($item['term'][$x]['term'] !== hex2bin($tag))
+ $new_tags[] = $item['term'][$x];
}
}
- $tag_str = implode(',',$arr);
+ if($new_tags)
+ $item['term'] = $new_tags;
+ else
+ unset($item['term']);
- q("UPDATE `item` SET `tag` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
- dbesc($tag_str),
- intval($item),
- intval(local_user())
- );
+ item_store_update($item);
info( t('Tag removed') . EOL );
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
@@ -49,51 +52,90 @@ function tagrm_post(&$a) {
function tagrm_content(&$a) {
- $o = '';
-
if(! local_user()) {
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
// NOTREACHED
}
- $item = (($a->argc > 1) ? intval($a->argv[1]) : 0);
- if(! $item) {
+ // remove tag on the fly if item and tag are provided
+ if((argc() == 4) && (argv(1) === 'drop') && intval(argv(2))) {
+
+ $item = intval(argv(2));
+ $tag = argv(3);
+
+ $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
+ intval($item),
+ intval(local_user())
+ );
+
+ if(! $r)
+ goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+
+ $r = fetch_post_tags($r,true);
+
+ $item = $r[0];
+
+ $new_tags = array();
+
+ if($item['term']) {
+ for($x = 0; $x < count($item['term']); $x ++) {
+ if($item['term'][$x]['term'] !== hex2bin($tag))
+ $new_tags[] = $item['term'][$x];
+ }
+ }
+
+ if($new_tags)
+ $item['term'] = $new_tags;
+ else
+ unset($item['term']);
+
+ item_store_update($item);
+
+ info( t('Tag removed') . EOL );
goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
- // NOTREACHED
+
}
+ //if we got only the item print a list of tags to select
+ if((argc() == 3) && (argv(1) === 'drop') && intval(argv(2))) {
- $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
- intval($item),
- intval(local_user())
- );
+ $o = '';
- if(! count($r))
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ $item = intval(argv(2));
- $arr = explode(',', $r[0]['tag']);
+ $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
+ intval($item),
+ intval(local_user())
+ );
- if(! count($arr))
- goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
+ if(! $r)
+ goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
- $o .= '<h3>' . t('Remove Item Tag') . '</h3>';
+ $r = fetch_post_tags($r,true);
- $o .= '<p id="tag-remove-desc">' . t('Select a tag to remove: ') . '</p>';
+ if(! count($r[0]['term']))
+ goaway($a->get_baseurl() . '/' . $_SESSION['photo_return']);
- $o .= '<form id="tagrm" action="tagrm" method="post" >';
- $o .= '<input type="hidden" name="item" value="' . $item . '" />';
- $o .= '<ul>';
+ $o .= '<h3>' . t('Remove Item Tag') . '</h3>';
+ $o .= '<p id="tag-remove-desc">' . t('Select a tag to remove: ') . '</p>';
- foreach($arr as $x) {
- $o .= '<li><input type="checkbox" name="tag" value="' . bin2hex($x) . '" >' . bbcode($x) . '</input></li>';
- }
+ $o .= '<form id="tagrm" action="tagrm" method="post" >';
+ $o .= '<input type="hidden" name="item" value="' . $item . '" />';
+ $o .= '<ul>';
- $o .= '</ul>';
- $o .= '<input id="tagrm-submit" type="submit" name="submit" value="' . t('Remove') .'" />';
- $o .= '<input id="tagrm-cancel" type="submit" name="submit" value="' . t('Cancel') .'" />';
- $o .= '</form>';
- return $o;
+ foreach($r[0]['term'] as $x) {
+ $o .= '<li><input type="checkbox" name="tag" value="' . bin2hex($x['term']) . '" >' . bbcode($x['term']) . '</input></li>';
+ }
+
+ $o .= '</ul>';
+ $o .= '<input id="tagrm-submit" type="submit" name="submit" value="' . t('Remove') .'" />';
+ $o .= '<input id="tagrm-cancel" type="submit" name="submit" value="' . t('Cancel') .'" />';
+ $o .= '</form>';
+
+ return $o;
+
+ }
}
diff --git a/mod/zotfeed.php b/mod/zotfeed.php
index 480e886cd..c730e4162 100644
--- a/mod/zotfeed.php
+++ b/mod/zotfeed.php
@@ -38,7 +38,7 @@ function zotfeed_init(&$a) {
logger('zotfeed request: ' . $r[0]['channel_name'], LOGGER_DEBUG);
- $result['messages'] = zot_feed($r[0]['channel_id'],$observer['xchan_hash'],$mindate);
+ $result['messages'] = zot_feed($r[0]['channel_id'],$observer['xchan_hash'],array('mindate' => $mindate));
$result['success'] = true;
json_return_and_die($result);